mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
feat(Execution Data Node): New node (#6247)
This commit is contained in:
parent
96144bd983
commit
3f7c4f0ad4
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"node": "n8n-nodes-base.executionData",
|
||||
"nodeVersion": "1.0",
|
||||
"codexVersion": "1.0",
|
||||
"categories": ["Development", "Core Nodes"],
|
||||
"subcategories": {
|
||||
"Core Nodes": ["Helpers"]
|
||||
},
|
||||
"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"]
|
||||
}
|
111
packages/nodes-base/nodes/ExecutionData/ExecutionData.node.ts
Normal file
111
packages/nodes-base/nodes/ExecutionData/ExecutionData.node.ts
Normal file
|
@ -0,0 +1,111 @@
|
|||
/* eslint-disable n8n-nodes-base/node-class-description-missing-subtitle */
|
||||
import type {
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export class ExecutionData implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Execution Data',
|
||||
name: 'executionData',
|
||||
icon: 'fa:tasks',
|
||||
group: ['input'],
|
||||
version: 1,
|
||||
description: 'Add execution data for search',
|
||||
defaults: {
|
||||
name: 'Execution Data',
|
||||
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.<br>This feature is available on our Pro and Enterprise plans. <a href='https://n8n.io/pricing/' target='_blank'>More Info</a>.",
|
||||
name: 'notice',
|
||||
type: 'notice',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
default: 'save',
|
||||
noDataExpression: true,
|
||||
options: [
|
||||
{
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased
|
||||
name: 'Save Execution Data for Search',
|
||||
value: 'save',
|
||||
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: ['save'],
|
||||
},
|
||||
},
|
||||
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<INodeExecutionData[][]> {
|
||||
const context = this.getWorkflowDataProxy(0);
|
||||
|
||||
const items = this.getInputData();
|
||||
const operations = this.getNodeParameter('operation', 0);
|
||||
|
||||
if (operations === 'save') {
|
||||
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 [items];
|
||||
}
|
||||
}
|
|
@ -447,6 +447,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",
|
||||
|
|
Loading…
Reference in a new issue