mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
refactor: Format nodes-base package (A-F) (#3800)
* 🔨 prettier formated nodes - A * 🔨 prettier formated nodes - B * ⚡ prettier formated nodes - C * ⚡ prettier formated nodes - D * ⚡ prettier formated nodes - E-F * 🎨 Adjust nodes-base formatting command (#3805) * Format additional files in nodes A-F (#3811) * ⚡ fixes * 🎨 Add Mindee to ignored dirs Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IHookFunctions, IWebhookFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
ILoadOptionsFunctions,
|
||||
@@ -11,9 +8,7 @@ import {
|
||||
IWebhookResponseData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
formIoApiRequest,
|
||||
} from './GenericFunctions';
|
||||
import { formIoApiRequest } from './GenericFunctions';
|
||||
|
||||
export class FormIoTrigger implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -53,21 +48,21 @@ export class FormIoTrigger implements INodeType {
|
||||
},
|
||||
required: true,
|
||||
default: '',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
},
|
||||
{
|
||||
displayName: 'Form Name or ID',
|
||||
name: 'formId',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsDependsOn: [
|
||||
'projectId',
|
||||
],
|
||||
loadOptionsDependsOn: ['projectId'],
|
||||
loadOptionsMethod: 'getForms',
|
||||
},
|
||||
required: true,
|
||||
default: '',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
},
|
||||
{
|
||||
displayName: 'Trigger Events',
|
||||
@@ -91,7 +86,8 @@ export class FormIoTrigger implements INodeType {
|
||||
name: 'simple',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description: 'Whether to return a simplified version of the response instead of the raw data',
|
||||
description:
|
||||
'Whether to return a simplified version of the response instead of the raw data',
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -133,12 +129,19 @@ export class FormIoTrigger implements INodeType {
|
||||
const formId = this.getNodeParameter('formId') as string;
|
||||
const projectId = this.getNodeParameter('projectId') as string;
|
||||
const method = this.getNodeParameter('events') as string[];
|
||||
const actions = await formIoApiRequest.call(this, 'GET', `/project/${projectId}/form/${formId}/action`);
|
||||
const actions = await formIoApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/project/${projectId}/form/${formId}/action`,
|
||||
);
|
||||
for (const action of actions) {
|
||||
if (action.name === 'webhook') {
|
||||
if (action.settings.url === webhookUrl &&
|
||||
// tslint:disable-next-line: no-any
|
||||
(action.method.length === method.length && action.method.every((value: any) => method.includes(value)))) {
|
||||
if (
|
||||
action.settings.url === webhookUrl &&
|
||||
action.method.length === method.length &&
|
||||
// tslint:disable-next-line:no-any
|
||||
action.method.every((value: any) => method.includes(value))
|
||||
) {
|
||||
webhookData.webhookId = action._id;
|
||||
return true;
|
||||
}
|
||||
@@ -158,9 +161,7 @@ export class FormIoTrigger implements INodeType {
|
||||
name: `webhook`,
|
||||
title: `webhook-n8n:${webhookUrl}`,
|
||||
method,
|
||||
handler: [
|
||||
'after',
|
||||
],
|
||||
handler: ['after'],
|
||||
priority: 0,
|
||||
settings: {
|
||||
method: 'post',
|
||||
@@ -172,7 +173,12 @@ export class FormIoTrigger implements INodeType {
|
||||
},
|
||||
},
|
||||
};
|
||||
const webhook = await formIoApiRequest.call(this, 'POST', `/project/${projectId}/form/${formId}/action`, payload);
|
||||
const webhook = await formIoApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/project/${projectId}/form/${formId}/action`,
|
||||
payload,
|
||||
);
|
||||
webhookData.webhookId = webhook._id;
|
||||
return true;
|
||||
},
|
||||
@@ -181,7 +187,11 @@ export class FormIoTrigger implements INodeType {
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
const formId = this.getNodeParameter('formId') as string;
|
||||
const projectId = this.getNodeParameter('projectId') as string;
|
||||
await formIoApiRequest.call(this, 'DELETE', `/project/${projectId}/form/${formId}/action/${webhookData.webhookId}`);
|
||||
await formIoApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/project/${projectId}/form/${formId}/action/${webhookData.webhookId}`,
|
||||
);
|
||||
delete webhookData.webhookId;
|
||||
return true;
|
||||
},
|
||||
@@ -196,9 +206,7 @@ export class FormIoTrigger implements INodeType {
|
||||
response = response.data;
|
||||
}
|
||||
return {
|
||||
workflowData: [
|
||||
this.helpers.returnJsonArray(response),
|
||||
],
|
||||
workflowData: [this.helpers.returnJsonArray(response)],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user