mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
BINARY_ENCODING,
|
||||
IWebhookFunctions,
|
||||
} from 'n8n-core';
|
||||
import { BINARY_ENCODING, IWebhookFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
ICredentialDataDecryptedObject,
|
||||
@@ -56,10 +53,13 @@ export class Webhook implements INodeType {
|
||||
triggerPanel: {
|
||||
header: '',
|
||||
executionsHelp: {
|
||||
inactive: 'Webhooks have two modes: test and production. <br /> <br /> <b>Use test mode while you build your workflow</b>. Click the \'listen\' button, then make a request to the test URL. The executions will show up in the editor.<br /> <br /> <b>Use production mode to run your workflow automatically</b>. <a data-key=\"activate\">Activate</a> the workflow, then make requests to the production URL. These executions will show up in the executions list, but not in the editor.',
|
||||
active: 'Webhooks have two modes: test and production. <br /> <br /> <b>Use test mode while you build your workflow</b>. Click the \'listen\' button, then make a request to the test URL. The executions will show up in the editor.<br /> <br /> <b>Use production mode to run your workflow automatically</b>. Since the workflow is activated, you can make requests to the production URL. These executions will show up in the <a data-key=\"executions\">executions list</a>, but not in the editor.',
|
||||
inactive:
|
||||
'Webhooks have two modes: test and production. <br /> <br /> <b>Use test mode while you build your workflow</b>. Click the \'listen\' button, then make a request to the test URL. The executions will show up in the editor.<br /> <br /> <b>Use production mode to run your workflow automatically</b>. <a data-key="activate">Activate</a> the workflow, then make requests to the production URL. These executions will show up in the executions list, but not in the editor.',
|
||||
active:
|
||||
'Webhooks have two modes: test and production. <br /> <br /> <b>Use test mode while you build your workflow</b>. Click the \'listen\' button, then make a request to the test URL. The executions will show up in the editor.<br /> <br /> <b>Use production mode to run your workflow automatically</b>. Since the workflow is activated, you can make requests to the production URL. These executions will show up in the <a data-key="executions">executions list</a>, but not in the editor.',
|
||||
},
|
||||
activationHint: 'Once you’ve finished building your workflow, run it without having to click this button by using the production webhook URL.',
|
||||
activationHint:
|
||||
'Once you’ve finished building your workflow, run it without having to click this button by using the production webhook URL.',
|
||||
},
|
||||
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
|
||||
inputs: [],
|
||||
@@ -70,9 +70,7 @@ export class Webhook implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'basicAuth',
|
||||
],
|
||||
authentication: ['basicAuth'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -81,9 +79,7 @@ export class Webhook implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'headerAuth',
|
||||
],
|
||||
authentication: ['headerAuth'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -95,7 +91,8 @@ export class Webhook implements INodeType {
|
||||
isFullPath: true,
|
||||
responseCode: '={{$parameter["responseCode"]}}',
|
||||
responseMode: '={{$parameter["responseMode"]}}',
|
||||
responseData: '={{$parameter["responseData"] || ($parameter.options.noResponseBody ? "noData" : undefined) }}',
|
||||
responseData:
|
||||
'={{$parameter["responseData"] || ($parameter.options.noResponseBody ? "noData" : undefined) }}',
|
||||
responseBinaryPropertyName: '={{$parameter["responseBinaryPropertyName"]}}',
|
||||
responseContentType: '={{$parameter["options"]["responseContentType"]}}',
|
||||
responsePropertyName: '={{$parameter["options"]["responsePropertyName"]}}',
|
||||
@@ -183,7 +180,7 @@ export class Webhook implements INodeType {
|
||||
description: 'Returns data of the last-executed node',
|
||||
},
|
||||
{
|
||||
name: 'Using \'Respond to Webhook\' Node',
|
||||
name: "Using 'Respond to Webhook' Node",
|
||||
value: 'responseNode',
|
||||
description: 'Response defined in that node',
|
||||
},
|
||||
@@ -192,14 +189,13 @@ export class Webhook implements INodeType {
|
||||
description: 'When and how to respond to the webhook',
|
||||
},
|
||||
{
|
||||
displayName: 'Insert a \'Respond to Webhook\' node to control when and how you respond. <a href="https://docs.n8n.io/nodes/n8n-nodes-base.respondToWebhook" target="_blank">More details</a>',
|
||||
displayName:
|
||||
'Insert a \'Respond to Webhook\' node to control when and how you respond. <a href="https://docs.n8n.io/nodes/n8n-nodes-base.respondToWebhook" target="_blank">More details</a>',
|
||||
name: 'webhookNotice',
|
||||
type: 'notice',
|
||||
displayOptions: {
|
||||
show: {
|
||||
responseMode: [
|
||||
'responseNode',
|
||||
],
|
||||
responseMode: ['responseNode'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -210,9 +206,7 @@ export class Webhook implements INodeType {
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
hide: {
|
||||
responseMode: [
|
||||
'responseNode',
|
||||
],
|
||||
responseMode: ['responseNode'],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -228,9 +222,7 @@ export class Webhook implements INodeType {
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
responseMode: [
|
||||
'lastNode',
|
||||
],
|
||||
responseMode: ['lastNode'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -242,12 +234,14 @@ export class Webhook implements INodeType {
|
||||
{
|
||||
name: 'First Entry JSON',
|
||||
value: 'firstEntryJson',
|
||||
description: 'Returns the JSON data of the first entry of the last node. Always returns a JSON object.',
|
||||
description:
|
||||
'Returns the JSON data of the first entry of the last node. Always returns a JSON object.',
|
||||
},
|
||||
{
|
||||
name: 'First Entry Binary',
|
||||
value: 'firstEntryBinary',
|
||||
description: 'Returns the binary data of the first entry of the last node. Always returns a binary file.',
|
||||
description:
|
||||
'Returns the binary data of the first entry of the last node. Always returns a binary file.',
|
||||
},
|
||||
{
|
||||
name: 'No Response Body',
|
||||
@@ -256,7 +250,8 @@ export class Webhook implements INodeType {
|
||||
},
|
||||
],
|
||||
default: 'firstEntryJson',
|
||||
description: 'What data should be returned. If it should return all items as an array or only the first item as object.',
|
||||
description:
|
||||
'What data should be returned. If it should return all items as an array or only the first item as object.',
|
||||
},
|
||||
{
|
||||
displayName: 'Property Name',
|
||||
@@ -266,9 +261,7 @@ export class Webhook implements INodeType {
|
||||
default: 'data',
|
||||
displayOptions: {
|
||||
show: {
|
||||
responseData: [
|
||||
'firstEntryBinary',
|
||||
],
|
||||
responseData: ['firstEntryBinary'],
|
||||
},
|
||||
},
|
||||
description: 'Name of the binary property to return',
|
||||
@@ -286,11 +279,7 @@ export class Webhook implements INodeType {
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'/httpMethod': [
|
||||
'PATCH',
|
||||
'PUT',
|
||||
'POST',
|
||||
],
|
||||
'/httpMethod': ['PATCH', 'PUT', 'POST'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -304,19 +293,19 @@ export class Webhook implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
binaryData: [
|
||||
true,
|
||||
],
|
||||
binaryData: [true],
|
||||
},
|
||||
},
|
||||
description: 'Name of the binary property to write the data of the received file to. If the data gets received via "Form-Data Multipart" it will be the prefix and a number starting with 0 will be attached to it.',
|
||||
description:
|
||||
'Name of the binary property to write the data of the received file to. If the data gets received via "Form-Data Multipart" it will be the prefix and a number starting with 0 will be attached to it.',
|
||||
},
|
||||
{
|
||||
displayName: 'Ignore Bots',
|
||||
name: 'ignoreBots',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to ignore requests from bots like link previewers and web crawlers',
|
||||
description:
|
||||
'Whether to ignore requests from bots like link previewers and web crawlers',
|
||||
},
|
||||
{
|
||||
displayName: 'No Response Body',
|
||||
@@ -326,14 +315,10 @@ export class Webhook implements INodeType {
|
||||
description: 'Whether to send any body in the response',
|
||||
displayOptions: {
|
||||
hide: {
|
||||
'rawBody': [
|
||||
true,
|
||||
],
|
||||
rawBody: [true],
|
||||
},
|
||||
show: {
|
||||
'/responseMode': [
|
||||
'onReceived',
|
||||
],
|
||||
'/responseMode': ['onReceived'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -343,12 +328,8 @@ export class Webhook implements INodeType {
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
hide: {
|
||||
binaryData: [
|
||||
true,
|
||||
],
|
||||
'noResponseBody': [
|
||||
true,
|
||||
],
|
||||
binaryData: [true],
|
||||
noResponseBody: [true],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -361,14 +342,10 @@ export class Webhook implements INodeType {
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'/responseMode': [
|
||||
'onReceived',
|
||||
],
|
||||
'/responseMode': ['onReceived'],
|
||||
},
|
||||
hide: {
|
||||
'noResponseBody': [
|
||||
true,
|
||||
],
|
||||
noResponseBody: [true],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -381,18 +358,15 @@ export class Webhook implements INodeType {
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'/responseData': [
|
||||
'firstEntryJson',
|
||||
],
|
||||
'/responseMode': [
|
||||
'lastNode',
|
||||
],
|
||||
'/responseData': ['firstEntryJson'],
|
||||
'/responseMode': ['lastNode'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
placeholder: 'application/xml',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-json
|
||||
description: 'Set a custom content-type to return if another one as the "application/json" should be returned',
|
||||
description:
|
||||
'Set a custom content-type to return if another one as the "application/json" should be returned',
|
||||
},
|
||||
{
|
||||
displayName: 'Response Headers',
|
||||
@@ -433,12 +407,8 @@ export class Webhook implements INodeType {
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'/responseData': [
|
||||
'firstEntryJson',
|
||||
],
|
||||
'/responseMode': [
|
||||
'lastNode',
|
||||
],
|
||||
'/responseData': ['firstEntryJson'],
|
||||
'/responseMode': ['lastNode'],
|
||||
},
|
||||
},
|
||||
default: 'data',
|
||||
@@ -483,7 +453,10 @@ export class Webhook implements INodeType {
|
||||
return authorizationError(resp, realm, 401);
|
||||
}
|
||||
|
||||
if (basicAuthData.name !== httpBasicAuth!.user || basicAuthData.pass !== httpBasicAuth!.password) {
|
||||
if (
|
||||
basicAuthData.name !== httpBasicAuth!.user ||
|
||||
basicAuthData.pass !== httpBasicAuth!.password
|
||||
) {
|
||||
// Provided authentication data is wrong
|
||||
return authorizationError(resp, realm, 403);
|
||||
}
|
||||
@@ -496,15 +469,17 @@ export class Webhook implements INodeType {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
if (httpHeaderAuth === undefined || !httpHeaderAuth.name || !httpHeaderAuth.value) {
|
||||
// Data is not defined on node so can not authenticate
|
||||
return authorizationError(resp, realm, 500, 'No authentication data defined on node!');
|
||||
}
|
||||
const headerName = (httpHeaderAuth.name as string).toLowerCase();
|
||||
const headerValue = (httpHeaderAuth.value as string);
|
||||
const headerValue = httpHeaderAuth.value as string;
|
||||
|
||||
if (!headers.hasOwnProperty(headerName) || (headers as IDataObject)[headerName] !== headerValue) {
|
||||
if (
|
||||
!headers.hasOwnProperty(headerName) ||
|
||||
(headers as IDataObject)[headerName] !== headerValue
|
||||
) {
|
||||
// Provided authentication data is wrong
|
||||
return authorizationError(resp, realm, 403);
|
||||
}
|
||||
@@ -517,7 +492,6 @@ export class Webhook implements INodeType {
|
||||
const form = new formidable.IncomingForm({ multiples: true });
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
form.parse(req, async (err, data, files) => {
|
||||
const returnItem: INodeExecutionData = {
|
||||
binary: {},
|
||||
@@ -534,7 +508,7 @@ export class Webhook implements INodeType {
|
||||
const processFiles: formidable.File[] = [];
|
||||
let multiFile = false;
|
||||
if (Array.isArray(files[xfile])) {
|
||||
processFiles.push(...files[xfile] as formidable.File[]);
|
||||
processFiles.push(...(files[xfile] as formidable.File[]));
|
||||
multiFile = true;
|
||||
} else {
|
||||
processFiles.push(files[xfile] as formidable.File);
|
||||
@@ -556,20 +530,19 @@ export class Webhook implements INodeType {
|
||||
const fileJson = file.toJSON() as unknown as IDataObject;
|
||||
const fileContent = await fs.promises.readFile(file.path);
|
||||
|
||||
returnItem.binary![binaryPropertyName] = await this.helpers.prepareBinaryData(Buffer.from(fileContent), fileJson.name as string, fileJson.type as string);
|
||||
returnItem.binary![binaryPropertyName] = await this.helpers.prepareBinaryData(
|
||||
Buffer.from(fileContent),
|
||||
fileJson.name as string,
|
||||
fileJson.type as string,
|
||||
);
|
||||
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
resolve({
|
||||
workflowData: [
|
||||
[
|
||||
returnItem,
|
||||
],
|
||||
],
|
||||
workflowData: [[returnItem]],
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -593,14 +566,12 @@ export class Webhook implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
returnItem.binary![binaryPropertyName as string] = await this.helpers.prepareBinaryData(Buffer.concat(data));
|
||||
returnItem.binary![binaryPropertyName as string] = await this.helpers.prepareBinaryData(
|
||||
Buffer.concat(data),
|
||||
);
|
||||
|
||||
return resolve({
|
||||
workflowData: [
|
||||
[
|
||||
returnItem,
|
||||
],
|
||||
],
|
||||
workflowData: [[returnItem]],
|
||||
});
|
||||
});
|
||||
|
||||
@@ -636,11 +607,7 @@ export class Webhook implements INodeType {
|
||||
|
||||
return {
|
||||
webhookResponse,
|
||||
workflowData: [
|
||||
[
|
||||
response,
|
||||
],
|
||||
],
|
||||
workflowData: [[response]],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user