n8n-core 1.65.0 → 1.66.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import type { AxiosRequestConfig } from 'axios';
2
2
  import { IncomingMessage } from 'http';
3
- import type { CloseFunction, IAdditionalCredentialOptions, IAllExecuteFunctions, IBinaryData, ICredentialDataDecryptedObject, ICredentialTestFunctions, IDataObject, IExecuteData, IExecuteFunctions, IExecuteSingleFunctions, IGetNodeParameterOptions, IHookFunctions, IHttpRequestOptions, ILoadOptionsFunctions, INode, INodeExecutionData, INodeType, IOAuth2Options, IPairedItemData, IPollFunctions, IRequestOptions, IRunExecutionData, ITaskDataConnections, ITriggerFunctions, IWebhookData, IWebhookDescription, IWebhookFunctions, IWorkflowDataProxyAdditionalKeys, IWorkflowExecuteAdditionalData, NodeExecutionWithMetadata, NodeParameterValueType, Workflow, WorkflowActivateMode, WorkflowExecuteMode, EnsureTypeOptions, IDeduplicationOutput, IDeduplicationOutputItems, ICheckProcessedOptions, DeduplicationScope, DeduplicationItemTypes, ICheckProcessedContextData } from 'n8n-workflow';
3
+ import type { CloseFunction, IAdditionalCredentialOptions, IAllExecuteFunctions, IBinaryData, ICredentialDataDecryptedObject, ICredentialTestFunctions, IDataObject, IExecuteData, IExecuteFunctions, IExecuteSingleFunctions, IGetNodeParameterOptions, IHookFunctions, IHttpRequestOptions, ILoadOptionsFunctions, INode, INodeExecutionData, INodeType, IOAuth2Options, IPairedItemData, IPollFunctions, IRequestOptions, IRunExecutionData, ITaskDataConnections, ITriggerFunctions, IWebhookData, IWebhookDescription, IWebhookFunctions, IWorkflowDataProxyAdditionalKeys, IWorkflowExecuteAdditionalData, NodeExecutionWithMetadata, NodeParameterValueType, Workflow, WorkflowActivateMode, WorkflowExecuteMode, EnsureTypeOptions, IDeduplicationOutput, IDeduplicationOutputItems, ICheckProcessedOptions, DeduplicationScope, DeduplicationItemTypes, ICheckProcessedContextData, ISupplyDataFunctions } from 'n8n-workflow';
4
4
  import { Readable } from 'stream';
5
5
  import type { BinaryData } from './BinaryData/types';
6
6
  export declare function parseRequestObject(requestObject: IRequestOptions): Promise<AxiosRequestConfig<any>>;
@@ -48,6 +48,7 @@ export declare function copyInputItems(items: INodeExecutionData[], properties:
48
48
  export declare function getExecutePollFunctions(workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, activation: WorkflowActivateMode): IPollFunctions;
49
49
  export declare function getExecuteTriggerFunctions(workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, activation: WorkflowActivateMode): ITriggerFunctions;
50
50
  export declare function getExecuteFunctions(workflow: Workflow, runExecutionData: IRunExecutionData, runIndex: number, connectionInputData: INodeExecutionData[], inputData: ITaskDataConnections, node: INode, additionalData: IWorkflowExecuteAdditionalData, executeData: IExecuteData, mode: WorkflowExecuteMode, closeFunctions: CloseFunction[], abortSignal?: AbortSignal): IExecuteFunctions;
51
+ export declare function getSupplyDataFunctions(workflow: Workflow, runExecutionData: IRunExecutionData, runIndex: number, connectionInputData: INodeExecutionData[], inputData: ITaskDataConnections, node: INode, additionalData: IWorkflowExecuteAdditionalData, executeData: IExecuteData, mode: WorkflowExecuteMode, closeFunctions: CloseFunction[], abortSignal?: AbortSignal): ISupplyDataFunctions;
51
52
  export declare function getExecuteSingleFunctions(workflow: Workflow, runExecutionData: IRunExecutionData, runIndex: number, connectionInputData: INodeExecutionData[], inputData: ITaskDataConnections, node: INode, itemIndex: number, additionalData: IWorkflowExecuteAdditionalData, executeData: IExecuteData, mode: WorkflowExecuteMode, abortSignal?: AbortSignal): IExecuteSingleFunctions;
52
53
  export declare function getCredentialTestFunctions(): ICredentialTestFunctions;
53
54
  export declare function getLoadOptionsFunctions(workflow: Workflow, node: INode, path: string, additionalData: IWorkflowExecuteAdditionalData): ILoadOptionsFunctions;
@@ -62,6 +62,7 @@ exports.copyInputItems = copyInputItems;
62
62
  exports.getExecutePollFunctions = getExecutePollFunctions;
63
63
  exports.getExecuteTriggerFunctions = getExecuteTriggerFunctions;
64
64
  exports.getExecuteFunctions = getExecuteFunctions;
65
+ exports.getSupplyDataFunctions = getSupplyDataFunctions;
65
66
  exports.getExecuteSingleFunctions = getExecuteSingleFunctions;
66
67
  exports.getCredentialTestFunctions = getCredentialTestFunctions;
67
68
  exports.getLoadOptionsFunctions = getLoadOptionsFunctions;
@@ -1782,7 +1783,7 @@ const addExecutionDataFunctions = async (type, nodeName, data, runExecutionData,
1782
1783
  });
1783
1784
  }
1784
1785
  };
1785
- async function getInputConnectionData(workflow, runExecutionData, runIndex, connectionInputData, additionalData, executeData, mode, closeFunctions, inputName, itemIndex) {
1786
+ async function getInputConnectionData(workflow, runExecutionData, runIndex, connectionInputData, inputData, additionalData, executeData, mode, closeFunctions, inputName, itemIndex, abortSignal) {
1786
1787
  const node = this.getNode();
1787
1788
  const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
1788
1789
  const inputs = n8n_workflow_1.NodeHelpers.getNodeInputs(workflow, node, nodeType.description);
@@ -1816,26 +1817,7 @@ async function getInputConnectionData(workflow, runExecutionData, runIndex, conn
1816
1817
  .filter((connectedNode) => connectedNode.disabled !== true)
1817
1818
  .map(async (connectedNode) => {
1818
1819
  const nodeType = workflow.nodeTypes.getByNameAndVersion(connectedNode.type, connectedNode.typeVersion);
1819
- const context = Object.assign({}, this);
1820
- context.getNodeParameter = (parameterName, itemIndex, fallbackValue, options) => {
1821
- return getNodeParameter(workflow, runExecutionData, runIndex, connectionInputData, connectedNode, parameterName, itemIndex, mode, getAdditionalKeys(additionalData, mode, runExecutionData), executeData, fallbackValue, { ...(options || {}), contextNode: node });
1822
- };
1823
- context.getNode = () => {
1824
- return (0, n8n_workflow_1.deepCopy)(connectedNode);
1825
- };
1826
- context.getCredentials = async (key) => {
1827
- try {
1828
- return await getCredentials(workflow, connectedNode, key, additionalData, mode, executeData, runExecutionData, runIndex, connectionInputData, itemIndex);
1829
- }
1830
- catch (error) {
1831
- let currentNodeRunIndex = 0;
1832
- if (runExecutionData.resultData.runData.hasOwnProperty(node.name)) {
1833
- currentNodeRunIndex = runExecutionData.resultData.runData[node.name].length;
1834
- }
1835
- await addExecutionDataFunctions('input', connectedNode.name, error, runExecutionData, inputName, additionalData, node.name, runIndex, currentNodeRunIndex);
1836
- throw error;
1837
- }
1838
- };
1820
+ const context = getSupplyDataFunctions(workflow, runExecutionData, runIndex, connectionInputData, inputData, connectedNode, additionalData, executeData, mode, closeFunctions, abortSignal);
1839
1821
  if (!nodeType.supplyData) {
1840
1822
  if (nodeType.description.outputs.includes("ai_tool")) {
1841
1823
  nodeType.supplyData = async function () {
@@ -2313,7 +2295,7 @@ function getExecuteFunctions(workflow, runExecutionData, runIndex, connectionInp
2313
2295
  continueOnFail: () => {
2314
2296
  return continueOnFail(node);
2315
2297
  },
2316
- evaluateExpression: (expression, itemIndex) => {
2298
+ evaluateExpression(expression, itemIndex) {
2317
2299
  return workflow.expression.resolveSimpleParameterValue(`=${expression}`, {}, runExecutionData, runIndex, itemIndex, node.name, connectionInputData, mode, getAdditionalKeys(additionalData, mode, runExecutionData), executeData);
2318
2300
  },
2319
2301
  async executeWorkflow(workflowInfo, inputData, parentCallbackManager) {
@@ -2331,7 +2313,7 @@ function getExecuteFunctions(workflow, runExecutionData, runIndex, connectionInp
2331
2313
  return n8n_workflow_1.NodeHelpers.getContext(runExecutionData, type, node);
2332
2314
  },
2333
2315
  async getInputConnectionData(inputName, itemIndex) {
2334
- return await getInputConnectionData.call(this, workflow, runExecutionData, runIndex, connectionInputData, additionalData, executeData, mode, closeFunctions, inputName, itemIndex);
2316
+ return await getInputConnectionData.call(this, workflow, runExecutionData, runIndex, connectionInputData, inputData, additionalData, executeData, mode, closeFunctions, inputName, itemIndex, abortSignal);
2335
2317
  },
2336
2318
  getNodeInputs() {
2337
2319
  const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
@@ -2458,7 +2440,7 @@ function getExecuteFunctions(workflow, runExecutionData, runIndex, connectionInp
2458
2440
  constructExecutionMetaData,
2459
2441
  },
2460
2442
  nodeHelpers: getNodeHelperFunctions(additionalData, workflow.id),
2461
- logAiEvent: async (eventName, msg) => {
2443
+ logAiEvent: (eventName, msg) => {
2462
2444
  return additionalData.logAiEvent(eventName, {
2463
2445
  executionId: additionalData.executionId ?? 'unsaved-execution',
2464
2446
  nodeName: node.name,
@@ -2473,6 +2455,120 @@ function getExecuteFunctions(workflow, runExecutionData, runIndex, connectionInp
2473
2455
  };
2474
2456
  })(workflow, runExecutionData, connectionInputData, inputData, node);
2475
2457
  }
2458
+ function getSupplyDataFunctions(workflow, runExecutionData, runIndex, connectionInputData, inputData, node, additionalData, executeData, mode, closeFunctions, abortSignal) {
2459
+ return {
2460
+ ...getCommonWorkflowFunctions(workflow, node, additionalData),
2461
+ ...executionCancellationFunctions(abortSignal),
2462
+ getMode: () => mode,
2463
+ getCredentials: async (type, itemIndex) => await getCredentials(workflow, node, type, additionalData, mode, executeData, runExecutionData, runIndex, connectionInputData, itemIndex),
2464
+ continueOnFail: () => continueOnFail(node),
2465
+ evaluateExpression: (expression, itemIndex) => workflow.expression.resolveSimpleParameterValue(`=${expression}`, {}, runExecutionData, runIndex, itemIndex, node.name, connectionInputData, mode, getAdditionalKeys(additionalData, mode, runExecutionData), executeData),
2466
+ executeWorkflow: async (workflowInfo, inputData, parentCallbackManager) => await additionalData
2467
+ .executeWorkflow(workflowInfo, additionalData, {
2468
+ parentWorkflowId: workflow.id?.toString(),
2469
+ inputData,
2470
+ parentWorkflowSettings: workflow.settings,
2471
+ node,
2472
+ parentCallbackManager,
2473
+ })
2474
+ .then(async (result) => await typedi_1.default.get(BinaryData_service_1.BinaryDataService).duplicateBinaryData(workflow.id, additionalData.executionId, result)),
2475
+ getNodeOutputs() {
2476
+ const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
2477
+ return n8n_workflow_1.NodeHelpers.getNodeOutputs(workflow, node, nodeType.description).map((output) => {
2478
+ if (typeof output === 'string') {
2479
+ return {
2480
+ type: output,
2481
+ };
2482
+ }
2483
+ return output;
2484
+ });
2485
+ },
2486
+ async getInputConnectionData(inputName, itemIndex) {
2487
+ return await getInputConnectionData.call(this, workflow, runExecutionData, runIndex, connectionInputData, inputData, additionalData, executeData, mode, closeFunctions, inputName, itemIndex, abortSignal);
2488
+ },
2489
+ getInputData: (inputIndex = 0, inputName = 'main') => {
2490
+ if (!inputData.hasOwnProperty(inputName)) {
2491
+ return [];
2492
+ }
2493
+ if (inputData[inputName].length < inputIndex) {
2494
+ throw new n8n_workflow_1.ApplicationError('Could not get input with given index', {
2495
+ extra: { inputIndex, inputName },
2496
+ });
2497
+ }
2498
+ if (inputData[inputName][inputIndex] === null) {
2499
+ throw new n8n_workflow_1.ApplicationError('Value of input was not set', {
2500
+ extra: { inputIndex, inputName },
2501
+ });
2502
+ }
2503
+ return inputData[inputName][inputIndex];
2504
+ },
2505
+ getNodeParameter: ((parameterName, itemIndex, fallbackValue, options) => getNodeParameter(workflow, runExecutionData, runIndex, connectionInputData, node, parameterName, itemIndex, mode, getAdditionalKeys(additionalData, mode, runExecutionData), executeData, fallbackValue, options)),
2506
+ getWorkflowDataProxy: (itemIndex) => new n8n_workflow_1.WorkflowDataProxy(workflow, runExecutionData, runIndex, itemIndex, node.name, connectionInputData, {}, mode, getAdditionalKeys(additionalData, mode, runExecutionData), executeData).getDataProxy(),
2507
+ sendMessageToUI(...args) {
2508
+ if (mode !== 'manual') {
2509
+ return;
2510
+ }
2511
+ try {
2512
+ if (additionalData.sendDataToUI) {
2513
+ args = args.map((arg) => {
2514
+ if (arg.isLuxonDateTime && arg.invalidReason)
2515
+ return { ...arg };
2516
+ if (arg.isLuxonDateTime)
2517
+ return new Date(arg.ts).toString();
2518
+ if (arg instanceof Date)
2519
+ return arg.toString();
2520
+ return arg;
2521
+ });
2522
+ additionalData.sendDataToUI('sendConsoleMessage', {
2523
+ source: `[Node: "${node.name}"]`,
2524
+ messages: args,
2525
+ });
2526
+ }
2527
+ }
2528
+ catch (error) {
2529
+ n8n_workflow_1.LoggerProxy.warn(`There was a problem sending message to UI: ${error.message}`);
2530
+ }
2531
+ },
2532
+ logAiEvent: (eventName, msg) => additionalData.logAiEvent(eventName, {
2533
+ executionId: additionalData.executionId ?? 'unsaved-execution',
2534
+ nodeName: node.name,
2535
+ workflowName: workflow.name ?? 'Unnamed workflow',
2536
+ nodeType: node.type,
2537
+ workflowId: workflow.id ?? 'unsaved-workflow',
2538
+ msg,
2539
+ }),
2540
+ addInputData(connectionType, data) {
2541
+ const nodeName = this.getNode().name;
2542
+ let currentNodeRunIndex = 0;
2543
+ if (runExecutionData.resultData.runData.hasOwnProperty(nodeName)) {
2544
+ currentNodeRunIndex = runExecutionData.resultData.runData[nodeName].length;
2545
+ }
2546
+ addExecutionDataFunctions('input', this.getNode().name, data, runExecutionData, connectionType, additionalData, node.name, runIndex, currentNodeRunIndex).catch((error) => {
2547
+ n8n_workflow_1.LoggerProxy.warn(`There was a problem logging input data of node "${this.getNode().name}": ${error.message}`);
2548
+ });
2549
+ return { index: currentNodeRunIndex };
2550
+ },
2551
+ addOutputData(connectionType, currentNodeRunIndex, data) {
2552
+ addExecutionDataFunctions('output', this.getNode().name, data, runExecutionData, connectionType, additionalData, node.name, runIndex, currentNodeRunIndex).catch((error) => {
2553
+ n8n_workflow_1.LoggerProxy.warn(`There was a problem logging output data of node "${this.getNode().name}": ${error.message}`);
2554
+ });
2555
+ },
2556
+ helpers: {
2557
+ createDeferredPromise: n8n_workflow_1.createDeferredPromise,
2558
+ copyInputItems,
2559
+ ...getRequestHelperFunctions(workflow, node, additionalData, runExecutionData, connectionInputData),
2560
+ ...getSSHTunnelFunctions(),
2561
+ ...getFileSystemHelperFunctions(node),
2562
+ ...getBinaryHelperFunctions(additionalData, workflow.id),
2563
+ ...getCheckProcessedHelperFunctions(workflow, node),
2564
+ assertBinaryData: (itemIndex, propertyName) => assertBinaryData(inputData, node, itemIndex, propertyName, 0),
2565
+ getBinaryDataBuffer: async (itemIndex, propertyName) => await getBinaryDataBuffer(inputData, itemIndex, propertyName, 0),
2566
+ returnJsonArray,
2567
+ normalizeItems,
2568
+ constructExecutionMetaData,
2569
+ },
2570
+ };
2571
+ }
2476
2572
  function getExecuteSingleFunctions(workflow, runExecutionData, runIndex, connectionInputData, inputData, node, itemIndex, additionalData, executeData, mode, abortSignal) {
2477
2573
  return ((workflow, runExecutionData, connectionInputData, inputData, node, itemIndex) => {
2478
2574
  return {
@@ -2532,7 +2628,7 @@ function getExecuteSingleFunctions(workflow, runExecutionData, runIndex, connect
2532
2628
  assertBinaryData: (propertyName, inputIndex = 0) => assertBinaryData(inputData, node, itemIndex, propertyName, inputIndex),
2533
2629
  getBinaryDataBuffer: async (propertyName, inputIndex = 0) => await getBinaryDataBuffer(inputData, itemIndex, propertyName, inputIndex),
2534
2630
  },
2535
- logAiEvent: async (eventName, msg) => {
2631
+ logAiEvent: (eventName, msg) => {
2536
2632
  return additionalData.logAiEvent(eventName, {
2537
2633
  executionId: additionalData.executionId ?? 'unsaved-execution',
2538
2634
  nodeName: node.name,
@@ -2655,7 +2751,7 @@ function getExecuteWebhookFunctions(workflow, node, additionalData, mode, webhoo
2655
2751
  source: null,
2656
2752
  };
2657
2753
  const runIndex = 0;
2658
- return await getInputConnectionData.call(this, workflow, runExecutionData, runIndex, connectionInputData, additionalData, executeData, mode, closeFunctions, inputName, itemIndex);
2754
+ return await getInputConnectionData.call(this, workflow, runExecutionData, runIndex, connectionInputData, {}, additionalData, executeData, mode, closeFunctions, inputName, itemIndex);
2659
2755
  },
2660
2756
  getMode: () => mode,
2661
2757
  evaluateExpression: (expression, evaluateItemIndex) => {