mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
🚚 Directorize and alphabetize nodes (#2445)
* 🚚 Directorize nodes * ⚡ Alphabetize nodes and credentials * 🔥 Remove unused node * 🔥 Remove unused codex * 🔥 Remove duplicate cred file references * 🐛 Fix node file paths * 🔥 Remove duplicate node reference
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"node": "n8n-nodes-base.respondToWebhook",
|
||||
"nodeVersion": "1.0",
|
||||
"codexVersion": "1.0",
|
||||
"categories": [
|
||||
"Core Nodes",
|
||||
"Utility"
|
||||
],
|
||||
"resources": {
|
||||
"primaryDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/nodes/n8n-nodes-base.respondToWebhook/"
|
||||
}
|
||||
]
|
||||
},
|
||||
"subcategories": {
|
||||
"Core Nodes":["Flow"]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,278 @@
|
||||
import {
|
||||
BINARY_ENCODING,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
IN8nHttpFullResponse,
|
||||
IN8nHttpResponse,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export class RespondToWebhook implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Respond to Webhook',
|
||||
icon: 'file:webhook.svg',
|
||||
name: 'respondToWebhook',
|
||||
group: ['transform'],
|
||||
version: 1,
|
||||
description: 'Returns data for Webhook',
|
||||
defaults: {
|
||||
name: 'Respond to Webhook',
|
||||
color: '#885577',
|
||||
},
|
||||
inputs: ['main'],
|
||||
outputs: ['main'],
|
||||
credentials: [
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Respond With',
|
||||
name: 'respondWith',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'First Incoming Item',
|
||||
value: 'firstIncomingItem',
|
||||
},
|
||||
{
|
||||
name: 'Text',
|
||||
value: 'text',
|
||||
},
|
||||
{
|
||||
name: 'JSON',
|
||||
value: 'json',
|
||||
},
|
||||
{
|
||||
name: 'Binary',
|
||||
value: 'binary',
|
||||
},
|
||||
{
|
||||
name: 'No Data',
|
||||
value: 'noData',
|
||||
},
|
||||
],
|
||||
default: 'firstIncomingItem',
|
||||
description: 'The data that should be returned',
|
||||
},
|
||||
{
|
||||
displayName: 'When using expressions, note that this node will only run for the first item in the input data.',
|
||||
name: 'webhookNotice',
|
||||
type: 'notice',
|
||||
displayOptions: {
|
||||
show: {
|
||||
respondWith: [
|
||||
'json',
|
||||
'text',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Response Body',
|
||||
name: 'responseBody',
|
||||
type: 'json',
|
||||
displayOptions: {
|
||||
show: {
|
||||
respondWith: [
|
||||
'json',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
placeholder: '{ "key": "value" }',
|
||||
description: 'The HTTP Response JSON data',
|
||||
},
|
||||
{
|
||||
displayName: 'Response Body',
|
||||
name: 'responseBody',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
respondWith: [
|
||||
'text',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
placeholder: 'e.g. Workflow started',
|
||||
description: 'The HTTP Response text data',
|
||||
},
|
||||
{
|
||||
displayName: 'Response Data Source',
|
||||
name: 'responseDataSource',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
respondWith: [
|
||||
'binary',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Choose Automatically From Input',
|
||||
value: 'automatically',
|
||||
description: 'Use if input data will contain a single piece of binary data',
|
||||
},
|
||||
{
|
||||
name: 'Specify Myself',
|
||||
value: 'set',
|
||||
description: 'Enter the name of the input field the binary data will be in',
|
||||
},
|
||||
],
|
||||
default: 'automatically',
|
||||
},
|
||||
{
|
||||
displayName: 'Input Field Name',
|
||||
name: 'inputFieldName',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: 'data',
|
||||
displayOptions: {
|
||||
show: {
|
||||
respondWith: [
|
||||
'binary',
|
||||
],
|
||||
responseDataSource: [
|
||||
'set',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'The name of the node input field with the binary data',
|
||||
},
|
||||
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Option',
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Response Code',
|
||||
name: 'responseCode',
|
||||
type: 'number',
|
||||
typeOptions: {
|
||||
minValue: 100,
|
||||
maxValue: 599,
|
||||
},
|
||||
default: 200,
|
||||
description: 'The HTTP Response code to return. Defaults to 200.',
|
||||
},
|
||||
{
|
||||
displayName: 'Response Headers',
|
||||
name: 'responseHeaders',
|
||||
placeholder: 'Add Response Header',
|
||||
description: 'Add headers to the webhook response',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
name: 'entries',
|
||||
displayName: 'Entries',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Name of the header',
|
||||
},
|
||||
{
|
||||
displayName: 'Value',
|
||||
name: 'value',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Value of the header',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
|
||||
const respondWith = this.getNodeParameter('respondWith', 0) as string;
|
||||
const options = this.getNodeParameter('options', 0, {}) as IDataObject;
|
||||
|
||||
const headers = {} as IDataObject;
|
||||
if (options.responseHeaders) {
|
||||
for (const header of (options.responseHeaders as IDataObject).entries as IDataObject[]) {
|
||||
if (typeof header.name !== 'string') {
|
||||
header.name = header.name?.toString();
|
||||
}
|
||||
headers[header.name?.toLowerCase() as string] = header.value?.toString();
|
||||
}
|
||||
}
|
||||
|
||||
let responseBody: IN8nHttpResponse;
|
||||
if (respondWith === 'json') {
|
||||
const responseBodyParameter = this.getNodeParameter('responseBody', 0) as string;
|
||||
if (responseBodyParameter) {
|
||||
responseBody = JSON.parse(responseBodyParameter);
|
||||
}
|
||||
} else if (respondWith === 'firstIncomingItem') {
|
||||
responseBody = items[0].json;
|
||||
} else if (respondWith === 'text') {
|
||||
responseBody = this.getNodeParameter('responseBody', 0) as string;
|
||||
} else if (respondWith === 'binary') {
|
||||
const item = this.getInputData()[0];
|
||||
|
||||
if (item.binary === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on the first item!');
|
||||
}
|
||||
|
||||
let responseBinaryPropertyName: string;
|
||||
|
||||
const responseDataSource = this.getNodeParameter('responseDataSource', 0) as string;
|
||||
|
||||
if (responseDataSource === 'set') {
|
||||
responseBinaryPropertyName = this.getNodeParameter('inputFieldName', 0) as string;
|
||||
} else {
|
||||
const binaryKeys = Object.keys(item.binary);
|
||||
if (binaryKeys.length === 0) {
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on the first item!');
|
||||
}
|
||||
responseBinaryPropertyName = binaryKeys[0];
|
||||
}
|
||||
|
||||
const binaryData = item.binary[responseBinaryPropertyName];
|
||||
|
||||
if (binaryData === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), `No binary data property "${responseBinaryPropertyName}" does not exists on item!`);
|
||||
}
|
||||
|
||||
if (headers['content-type']) {
|
||||
headers['content-type'] = binaryData.mimeType;
|
||||
}
|
||||
responseBody = Buffer.from(binaryData.data, BINARY_ENCODING);
|
||||
} else if (respondWith !== 'noData') {
|
||||
throw new NodeOperationError(this.getNode(), `The Response Data option "${respondWith}" is not supported!`);
|
||||
}
|
||||
|
||||
const response: IN8nHttpFullResponse = {
|
||||
body: responseBody,
|
||||
headers,
|
||||
statusCode: options.responseCode as number || 200,
|
||||
};
|
||||
|
||||
this.sendResponse(response);
|
||||
|
||||
return this.prepareOutputData(items);
|
||||
}
|
||||
|
||||
}
|
||||
1
packages/nodes-base/nodes/RespondToWebhook/webhook.svg
Normal file
1
packages/nodes-base/nodes/RespondToWebhook/webhook.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48px" height="48px"><path fill="#37474f" d="M35,37c-2.2,0-4-1.8-4-4s1.8-4,4-4s4,1.8,4,4S37.2,37,35,37z"/><path fill="#37474f" d="M35,43c-3,0-5.9-1.4-7.8-3.7l3.1-2.5c1.1,1.4,2.9,2.3,4.7,2.3c3.3,0,6-2.7,6-6s-2.7-6-6-6 c-1,0-2,0.3-2.9,0.7l-1.7,1L23.3,16l3.5-1.9l5.3,9.4c1-0.3,2-0.5,3-0.5c5.5,0,10,4.5,10,10S40.5,43,35,43z"/><path fill="#37474f" d="M14,43C8.5,43,4,38.5,4,33c0-4.6,3.1-8.5,7.5-9.7l1,3.9C9.9,27.9,8,30.3,8,33c0,3.3,2.7,6,6,6 s6-2.7,6-6v-2h15v4H23.8C22.9,39.6,18.8,43,14,43z"/><path fill="#e91e63" d="M14,37c-2.2,0-4-1.8-4-4s1.8-4,4-4s4,1.8,4,4S16.2,37,14,37z"/><path fill="#37474f" d="M25,19c-2.2,0-4-1.8-4-4s1.8-4,4-4s4,1.8,4,4S27.2,19,25,19z"/><path fill="#e91e63" d="M15.7,34L12.3,32l5.9-9.7c-2-1.9-3.2-4.5-3.2-7.3c0-5.5,4.5-10,10-10c5.5,0,10,4.5,10,10 c0,0.9-0.1,1.7-0.3,2.5l-3.9-1c0.1-0.5,0.2-1,0.2-1.5c0-3.3-2.7-6-6-6s-6,2.7-6,6c0,2.1,1.1,4,2.9,5.1l1.7,1L15.7,34z"/></svg>
|
||||
|
After Width: | Height: | Size: 958 B |
Reference in New Issue
Block a user