From df86a901beba4e7714b97960919565b53959627f Mon Sep 17 00:00:00 2001 From: Michael Kret Date: Mon, 15 May 2023 11:28:17 +0300 Subject: [PATCH 1/5] :zap: setup --- .../ExecutionData/ExecutionData.node.json | 22 ++++ .../nodes/ExecutionData/ExecutionData.node.ts | 113 ++++++++++++++++++ packages/nodes-base/package.json | 1 + 3 files changed, 136 insertions(+) create mode 100644 packages/nodes-base/nodes/ExecutionData/ExecutionData.node.json create mode 100644 packages/nodes-base/nodes/ExecutionData/ExecutionData.node.ts diff --git a/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.json b/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.json new file mode 100644 index 0000000000000..3552581db2775 --- /dev/null +++ b/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.json @@ -0,0 +1,22 @@ +{ + "node": "n8n-nodes-base.executionData", + "nodeVersion": "1.0", + "codexVersion": "1.0", + "categories": ["Core Nodes", "Utility"], + "resources": { + "credentialDocumentation": [ + { + "url": "https://docs.n8n.io/credentials/executionData" + } + ], + "primaryDocumentation": [ + { + "url": "https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.executionData/" + } + ] + }, + "alias": ["Filter", "Set", "Data"], + "subcategories": { + "Core Nodes": ["Data Transformation"] + } +} diff --git a/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.ts b/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.ts new file mode 100644 index 0000000000000..6635617bd6bc7 --- /dev/null +++ b/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.ts @@ -0,0 +1,113 @@ +/* eslint-disable n8n-nodes-base/node-class-description-missing-subtitle */ +import type { + IDataObject, + IExecuteFunctions, + INodeExecutionData, + INodeType, + INodeTypeDescription, +} from 'n8n-workflow'; + +import { getSandboxContext } from '../Code/Sandbox'; + +export class ExecutionData implements INodeType { + description: INodeTypeDescription = { + displayName: 'Execution Data', + name: 'executionData', + icon: 'fa:list', + group: ['input'], + version: 1, + description: 'Add execution data', + defaults: { + name: 'Execution Data', + color: '#0000FF', + }, + inputs: ['main'], + outputs: ['main'], + properties: [ + { + displayName: + "Use this node to save fields you want to use later to easily find an execution (e.g. a user ID). You'll be able to search by this data in the 'executions' tab.
This feature is available on our Pro and Enterprise plans. More Info", + name: 'notice', + type: 'notice', + default: '', + }, + { + displayName: 'Operation', + name: 'operation', + type: 'options', + default: 'saveData', + noDataExpression: true, + options: [ + { + // eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased + name: 'Save execution data for search', + value: 'saveData', + action: 'Save execution data for search', + }, + ], + }, + { + displayName: 'Data to Save', + name: 'dataToSave', + placeholder: 'Add Saved Field', + type: 'fixedCollection', + typeOptions: { + multipleValueButtonText: 'Add Saved Field', + multipleValues: true, + }, + displayOptions: { + show: { + operation: ['saveData'], + }, + }, + default: {}, + options: [ + { + displayName: 'Values', + name: 'values', + values: [ + { + displayName: 'Key', + name: 'key', + type: 'string', + default: '', + placeholder: 'e.g. myKey', + }, + { + displayName: 'Value', + name: 'value', + type: 'string', + default: '', + placeholder: 'e.g. myValue', + }, + ], + }, + ], + }, + ], + }; + + async execute(this: IExecuteFunctions): Promise { + const context = getSandboxContext.call(this, 0); + + const items = this.getInputData(); + const operations = this.getNodeParameter('operation', 0); + + if (operations === 'saveData') { + for (let i = 0; i < items.length; i++) { + const dataToSave = + ((this.getNodeParameter('dataToSave', i, {}) as IDataObject).values as IDataObject[]) || + []; + + const values = dataToSave.reduce((acc, { key, value }) => { + acc[key as string] = value; + return acc; + }, {} as IDataObject); + + context.$execution.customData.setAll(values); + } + } + + return [this.getInputData()]; + } +} diff --git a/packages/nodes-base/package.json b/packages/nodes-base/package.json index edb68e4f2114e..2e2376450d5d9 100644 --- a/packages/nodes-base/package.json +++ b/packages/nodes-base/package.json @@ -445,6 +445,7 @@ "dist/nodes/ExecuteCommand/ExecuteCommand.node.js", "dist/nodes/ExecuteWorkflow/ExecuteWorkflow.node.js", "dist/nodes/ExecuteWorkflowTrigger/ExecuteWorkflowTrigger.node.js", + "dist/nodes/ExecutionData/ExecutionData.node.js", "dist/nodes/Facebook/FacebookGraphApi.node.js", "dist/nodes/Facebook/FacebookTrigger.node.js", "dist/nodes/Figma/FigmaTrigger.node.js", From 878c38dcccdc4e878b35e65de54ae90a881c59e4 Mon Sep 17 00:00:00 2001 From: Michael Kret Date: Mon, 15 May 2023 12:41:41 +0300 Subject: [PATCH 2/5] :zap: renamed operation --- .../nodes/ExecutionData/ExecutionData.node.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.ts b/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.ts index 6635617bd6bc7..ea8291c899935 100644 --- a/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.ts +++ b/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.ts @@ -35,13 +35,13 @@ export class ExecutionData implements INodeType { displayName: 'Operation', name: 'operation', type: 'options', - default: 'saveData', + default: 'save', noDataExpression: true, options: [ { // eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased name: 'Save execution data for search', - value: 'saveData', + value: 'save', action: 'Save execution data for search', }, ], @@ -57,7 +57,7 @@ export class ExecutionData implements INodeType { }, displayOptions: { show: { - operation: ['saveData'], + operation: ['save'], }, }, default: {}, @@ -93,7 +93,7 @@ export class ExecutionData implements INodeType { const items = this.getInputData(); const operations = this.getNodeParameter('operation', 0); - if (operations === 'saveData') { + if (operations === 'save') { for (let i = 0; i < items.length; i++) { const dataToSave = ((this.getNodeParameter('dataToSave', i, {}) as IDataObject).values as IDataObject[]) || @@ -108,6 +108,6 @@ export class ExecutionData implements INodeType { } } - return [this.getInputData()]; + return [items]; } } From 2f360383f99e39c03a2fd6ced284723d483daf32 Mon Sep 17 00:00:00 2001 From: Michael Kret Date: Mon, 15 May 2023 12:58:38 +0300 Subject: [PATCH 3/5] :zap: cleanup --- packages/nodes-base/nodes/ExecutionData/ExecutionData.node.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.ts b/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.ts index ea8291c899935..4bb68dd0bb526 100644 --- a/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.ts +++ b/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.ts @@ -7,8 +7,6 @@ import type { INodeTypeDescription, } from 'n8n-workflow'; -import { getSandboxContext } from '../Code/Sandbox'; - export class ExecutionData implements INodeType { description: INodeTypeDescription = { displayName: 'Execution Data', @@ -88,7 +86,7 @@ export class ExecutionData implements INodeType { }; async execute(this: IExecuteFunctions): Promise { - const context = getSandboxContext.call(this, 0); + const context = this.getWorkflowDataProxy(0); const items = this.getInputData(); const operations = this.getNodeParameter('operation', 0); From e71eb08e47966d5f82e32507f54e83c0b5d556e4 Mon Sep 17 00:00:00 2001 From: Giulio Andreini Date: Tue, 23 May 2023 17:07:07 +0200 Subject: [PATCH 4/5] Updates: icon, color, copy. --- .../nodes/ExecutionData/ExecutionData.node.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.ts b/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.ts index 4bb68dd0bb526..8d68f30135b26 100644 --- a/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.ts +++ b/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.ts @@ -11,20 +11,20 @@ export class ExecutionData implements INodeType { description: INodeTypeDescription = { displayName: 'Execution Data', name: 'executionData', - icon: 'fa:list', + icon: 'fa:tasks', group: ['input'], version: 1, - description: 'Add execution data', + description: 'Add execution data for search', defaults: { name: 'Execution Data', - color: '#0000FF', + color: '#29A568', }, inputs: ['main'], outputs: ['main'], properties: [ { displayName: - "Use this node to save fields you want to use later to easily find an execution (e.g. a user ID). You'll be able to search by this data in the 'executions' tab.
This feature is available on our Pro and Enterprise plans. More Info", + "Use this node to save fields you want to use later to easily find an execution (e.g. a user ID). You'll be able to search by this data in the 'executions' tab.
This feature is available on our Pro and Enterprise plans. More Info.", name: 'notice', type: 'notice', default: '', @@ -38,7 +38,7 @@ export class ExecutionData implements INodeType { options: [ { // eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased - name: 'Save execution data for search', + name: 'Save Execution Data for Search', value: 'save', action: 'Save execution data for search', }, From 80dc88637ec18d27f0f206053b5986ee7194d6c7 Mon Sep 17 00:00:00 2001 From: Michael Kret Date: Wed, 24 May 2023 08:38:18 +0300 Subject: [PATCH 5/5] :zap: subcategory update --- .../nodes/ExecutionData/ExecutionData.node.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.json b/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.json index 3552581db2775..9f48902cf9e9f 100644 --- a/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.json +++ b/packages/nodes-base/nodes/ExecutionData/ExecutionData.node.json @@ -2,7 +2,10 @@ "node": "n8n-nodes-base.executionData", "nodeVersion": "1.0", "codexVersion": "1.0", - "categories": ["Core Nodes", "Utility"], + "categories": ["Development", "Core Nodes"], + "subcategories": { + "Core Nodes": ["Helpers"] + }, "resources": { "credentialDocumentation": [ { @@ -15,8 +18,5 @@ } ] }, - "alias": ["Filter", "Set", "Data"], - "subcategories": { - "Core Nodes": ["Data Transformation"] - } + "alias": ["Filter", "Set", "Data"] }