n8n-core 1.66.0 → 1.67.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.
Files changed (47) hide show
  1. package/dist/NodeExecuteFunctions.d.ts +10 -4
  2. package/dist/NodeExecuteFunctions.js +14 -300
  3. package/dist/NodeExecuteFunctions.js.map +1 -1
  4. package/dist/WorkflowExecute.d.ts +1 -1
  5. package/dist/WorkflowExecute.js +6 -6
  6. package/dist/WorkflowExecute.js.map +1 -1
  7. package/dist/build.tsbuildinfo +1 -1
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.js +1 -0
  10. package/dist/index.js.map +1 -1
  11. package/dist/node-execution-context/execute-single-context.d.ts +28 -0
  12. package/dist/node-execution-context/execute-single-context.js +104 -0
  13. package/dist/node-execution-context/execute-single-context.js.map +1 -0
  14. package/dist/node-execution-context/helpers/binary-helpers.d.ts +15 -0
  15. package/dist/node-execution-context/helpers/binary-helpers.js +117 -0
  16. package/dist/node-execution-context/helpers/binary-helpers.js.map +1 -0
  17. package/dist/node-execution-context/helpers/request-helpers.d.ts +20 -0
  18. package/dist/node-execution-context/helpers/request-helpers.js +192 -0
  19. package/dist/node-execution-context/helpers/request-helpers.js.map +1 -0
  20. package/dist/node-execution-context/helpers/scheduling-helpers.d.ts +8 -0
  21. package/dist/node-execution-context/helpers/scheduling-helpers.js +21 -0
  22. package/dist/node-execution-context/helpers/scheduling-helpers.js.map +1 -0
  23. package/dist/node-execution-context/helpers/ssh-tunnel-helpers.d.ts +6 -0
  24. package/dist/node-execution-context/helpers/ssh-tunnel-helpers.js +20 -0
  25. package/dist/node-execution-context/helpers/ssh-tunnel-helpers.js.map +1 -0
  26. package/dist/node-execution-context/hook-context.d.ts +14 -0
  27. package/dist/node-execution-context/hook-context.js +42 -0
  28. package/dist/node-execution-context/hook-context.js.map +1 -0
  29. package/dist/node-execution-context/index.d.ts +6 -0
  30. package/dist/node-execution-context/index.js +16 -0
  31. package/dist/node-execution-context/index.js.map +1 -0
  32. package/dist/node-execution-context/load-options-context.d.ts +11 -0
  33. package/dist/node-execution-context/load-options-context.js +46 -0
  34. package/dist/node-execution-context/load-options-context.js.map +1 -0
  35. package/dist/node-execution-context/node-execution-context.d.ts +30 -0
  36. package/dist/node-execution-context/node-execution-context.js +83 -0
  37. package/dist/node-execution-context/node-execution-context.js.map +1 -0
  38. package/dist/node-execution-context/poll-context.d.ts +12 -0
  39. package/dist/node-execution-context/poll-context.js +45 -0
  40. package/dist/node-execution-context/poll-context.js.map +1 -0
  41. package/dist/node-execution-context/trigger-context.d.ts +12 -0
  42. package/dist/node-execution-context/trigger-context.js +47 -0
  43. package/dist/node-execution-context/trigger-context.js.map +1 -0
  44. package/dist/node-execution-context/webhook-context.d.ts +24 -0
  45. package/dist/node-execution-context/webhook-context.js +111 -0
  46. package/dist/node-execution-context/webhook-context.js.map +1 -0
  47. package/package.json +6 -6
@@ -1,12 +1,16 @@
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, ISupplyDataFunctions } from 'n8n-workflow';
3
+ import type { CloseFunction, IAdditionalCredentialOptions, IAllExecuteFunctions, IBinaryData, ICredentialDataDecryptedObject, ICredentialTestFunctions, IDataObject, IExecuteData, IExecuteFunctions, IExecuteSingleFunctions, IGetNodeParameterOptions, IHookFunctions, IHttpRequestOptions, IN8nHttpFullResponse, IN8nHttpResponse, INode, INodeExecutionData, INodeType, IOAuth2Options, IPairedItemData, IPollFunctions, IRequestOptions, IRunExecutionData, ITaskDataConnections, ITriggerFunctions, IWebhookData, IWebhookDescription, IWebhookFunctions, IWorkflowDataProxyAdditionalKeys, IWorkflowExecuteAdditionalData, NodeExecutionWithMetadata, NodeParameterValueType, PaginationOptions, Workflow, WorkflowActivateMode, WorkflowExecuteMode, EnsureTypeOptions, IDeduplicationOutput, IDeduplicationOutputItems, ICheckProcessedOptions, DeduplicationScope, DeduplicationItemTypes, ICheckProcessedContextData, ISupplyDataFunctions, WebhookType } from 'n8n-workflow';
4
+ import { NodeConnectionType } from 'n8n-workflow';
4
5
  import { Readable } from 'stream';
5
6
  import type { BinaryData } from './BinaryData/types';
7
+ export declare const validateUrl: (url?: string) => boolean;
6
8
  export declare function parseRequestObject(requestObject: IRequestOptions): Promise<AxiosRequestConfig<any>>;
7
9
  export declare function parseIncomingMessage(message: IncomingMessage): void;
10
+ export declare function binaryToString(body: Buffer | Readable, encoding?: BufferEncoding): Promise<string>;
8
11
  export declare function proxyRequestToAxios(workflow: Workflow | undefined, additionalData: IWorkflowExecuteAdditionalData | undefined, node: INode | undefined, uriOrObject: string | IRequestOptions, options?: IRequestOptions): Promise<any>;
9
12
  export declare const removeEmptyBody: (requestOptions: IHttpRequestOptions | IRequestOptions) => void;
13
+ export declare function httpRequest(requestOptions: IHttpRequestOptions): Promise<IN8nHttpFullResponse | IN8nHttpResponse>;
10
14
  export declare function getBinaryPath(binaryDataId: string): string;
11
15
  export declare function getBinaryMetadata(binaryDataId: string): Promise<BinaryData.Metadata>;
12
16
  export declare function getBinaryStream(binaryDataId: string, chunkSize?: number): Promise<Readable>;
@@ -14,11 +18,13 @@ export declare function assertBinaryData(inputData: ITaskDataConnections, node:
14
18
  export declare function getBinaryDataBuffer(inputData: ITaskDataConnections, itemIndex: number, propertyName: string, inputIndex: number): Promise<Buffer>;
15
19
  export declare function setBinaryDataBuffer(binaryData: IBinaryData, bufferOrStream: Buffer | Readable, workflowId: string, executionId: string): Promise<IBinaryData>;
16
20
  export declare function copyBinaryFile(workflowId: string, executionId: string, filePath: string, fileName: string, mimeType?: string): Promise<IBinaryData>;
21
+ export declare function prepareBinaryData(binaryData: Buffer | Readable, executionId: string, workflowId: string, filePath?: string, mimeType?: string): Promise<IBinaryData>;
17
22
  export declare function checkProcessedAndRecord(items: DeduplicationItemTypes[], scope: DeduplicationScope, contextData: ICheckProcessedContextData, options: ICheckProcessedOptions): Promise<IDeduplicationOutput>;
18
23
  export declare function checkProcessedItemsAndRecord(key: string, items: IDataObject[], scope: DeduplicationScope, contextData: ICheckProcessedContextData, options: ICheckProcessedOptions): Promise<IDeduplicationOutputItems>;
19
24
  export declare function removeProcessed(items: DeduplicationItemTypes[], scope: DeduplicationScope, contextData: ICheckProcessedContextData, options: ICheckProcessedOptions): Promise<void>;
20
25
  export declare function clearAllProcessedItems(scope: DeduplicationScope, contextData: ICheckProcessedContextData, options: ICheckProcessedOptions): Promise<void>;
21
26
  export declare function getProcessedDataCount(scope: DeduplicationScope, contextData: ICheckProcessedContextData, options: ICheckProcessedOptions): Promise<number>;
27
+ export declare function applyPaginationRequestData(requestData: IRequestOptions, paginationRequestData: PaginationOptions['request']): IRequestOptions;
22
28
  export declare function requestOAuth2(this: IAllExecuteFunctions, credentialsType: string, requestOptions: IHttpRequestOptions | IRequestOptions, node: INode, additionalData: IWorkflowExecuteAdditionalData, oAuth2Options?: IOAuth2Options, isN8nRequest?: boolean): Promise<any>;
23
29
  export declare function requestOAuth1(this: IAllExecuteFunctions, credentialsType: string, requestOptions: IHttpRequestOptions | IRequestOptions, isN8nRequest?: boolean): Promise<any>;
24
30
  export declare function httpRequestWithAuthentication(this: IAllExecuteFunctions, credentialsType: string, requestOptions: IHttpRequestOptions, workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, additionalCredentialOptions?: IAdditionalCredentialOptions): Promise<any>;
@@ -41,8 +47,9 @@ export declare function ensureType(toType: EnsureTypeOptions, parameterValue: an
41
47
  }): string | number | boolean | object;
42
48
  export declare function getNodeParameter(workflow: Workflow, runExecutionData: IRunExecutionData | null, runIndex: number, connectionInputData: INodeExecutionData[], node: INode, parameterName: string, itemIndex: number, mode: WorkflowExecuteMode, additionalKeys: IWorkflowDataProxyAdditionalKeys, executeData?: IExecuteData, fallbackValue?: any, options?: IGetNodeParameterOptions): NodeParameterValueType | object;
43
49
  export declare function continueOnFail(node: INode): boolean;
44
- export declare function getNodeWebhookUrl(name: string, workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, additionalKeys: IWorkflowDataProxyAdditionalKeys, isTest?: boolean): string | undefined;
45
- export declare function getWebhookDescription(name: string, workflow: Workflow, node: INode): IWebhookDescription | undefined;
50
+ export declare function getNodeWebhookUrl(name: WebhookType, workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, additionalKeys: IWorkflowDataProxyAdditionalKeys, isTest?: boolean): string | undefined;
51
+ export declare function getWebhookDescription(name: WebhookType, workflow: Workflow, node: INode): IWebhookDescription | undefined;
52
+ export declare function getInputConnectionData(this: IAllExecuteFunctions, workflow: Workflow, runExecutionData: IRunExecutionData, runIndex: number, connectionInputData: INodeExecutionData[], inputData: ITaskDataConnections, additionalData: IWorkflowExecuteAdditionalData, executeData: IExecuteData, mode: WorkflowExecuteMode, closeFunctions: CloseFunction[], inputName: NodeConnectionType, itemIndex: number, abortSignal?: AbortSignal): Promise<unknown>;
46
53
  export declare function isFilePathBlocked(filePath: string): boolean;
47
54
  export declare function copyInputItems(items: INodeExecutionData[], properties: string[]): IDataObject[];
48
55
  export declare function getExecutePollFunctions(workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, activation: WorkflowActivateMode): IPollFunctions;
@@ -51,6 +58,5 @@ export declare function getExecuteFunctions(workflow: Workflow, runExecutionData
51
58
  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;
52
59
  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;
53
60
  export declare function getCredentialTestFunctions(): ICredentialTestFunctions;
54
- export declare function getLoadOptionsFunctions(workflow: Workflow, node: INode, path: string, additionalData: IWorkflowExecuteAdditionalData): ILoadOptionsFunctions;
55
61
  export declare function getExecuteHookFunctions(workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, activation: WorkflowActivateMode, webhookData?: IWebhookData): IHookFunctions;
56
62
  export declare function getExecuteWebhookFunctions(workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, webhookData: IWebhookData, closeFunctions: CloseFunction[], runExecutionData: IRunExecutionData | null): IWebhookFunctions;
@@ -26,10 +26,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.validateValueAgainstSchema = exports.removeEmptyBody = void 0;
29
+ exports.validateValueAgainstSchema = exports.removeEmptyBody = exports.validateUrl = void 0;
30
30
  exports.parseRequestObject = parseRequestObject;
31
31
  exports.parseIncomingMessage = parseIncomingMessage;
32
+ exports.binaryToString = binaryToString;
32
33
  exports.proxyRequestToAxios = proxyRequestToAxios;
34
+ exports.httpRequest = httpRequest;
33
35
  exports.getBinaryPath = getBinaryPath;
34
36
  exports.getBinaryMetadata = getBinaryMetadata;
35
37
  exports.getBinaryStream = getBinaryStream;
@@ -37,11 +39,13 @@ exports.assertBinaryData = assertBinaryData;
37
39
  exports.getBinaryDataBuffer = getBinaryDataBuffer;
38
40
  exports.setBinaryDataBuffer = setBinaryDataBuffer;
39
41
  exports.copyBinaryFile = copyBinaryFile;
42
+ exports.prepareBinaryData = prepareBinaryData;
40
43
  exports.checkProcessedAndRecord = checkProcessedAndRecord;
41
44
  exports.checkProcessedItemsAndRecord = checkProcessedItemsAndRecord;
42
45
  exports.removeProcessed = removeProcessed;
43
46
  exports.clearAllProcessedItems = clearAllProcessedItems;
44
47
  exports.getProcessedDataCount = getProcessedDataCount;
48
+ exports.applyPaginationRequestData = applyPaginationRequestData;
45
49
  exports.requestOAuth2 = requestOAuth2;
46
50
  exports.requestOAuth1 = requestOAuth1;
47
51
  exports.httpRequestWithAuthentication = httpRequestWithAuthentication;
@@ -57,6 +61,7 @@ exports.getNodeParameter = getNodeParameter;
57
61
  exports.continueOnFail = continueOnFail;
58
62
  exports.getNodeWebhookUrl = getNodeWebhookUrl;
59
63
  exports.getWebhookDescription = getWebhookDescription;
64
+ exports.getInputConnectionData = getInputConnectionData;
60
65
  exports.isFilePathBlocked = isFilePathBlocked;
61
66
  exports.copyInputItems = copyInputItems;
62
67
  exports.getExecutePollFunctions = getExecutePollFunctions;
@@ -65,7 +70,6 @@ exports.getExecuteFunctions = getExecuteFunctions;
65
70
  exports.getSupplyDataFunctions = getSupplyDataFunctions;
66
71
  exports.getExecuteSingleFunctions = getExecuteSingleFunctions;
67
72
  exports.getCredentialTestFunctions = getCredentialTestFunctions;
68
- exports.getLoadOptionsFunctions = getLoadOptionsFunctions;
69
73
  exports.getExecuteHookFunctions = getExecuteHookFunctions;
70
74
  exports.getExecuteWebhookFunctions = getExecuteWebhookFunctions;
71
75
  const client_oauth2_1 = require("@n8n/client-oauth2");
@@ -99,7 +103,7 @@ const data_deduplication_service_1 = require("./data-deduplication-service");
99
103
  const ExecutionMetadata_1 = require("./ExecutionMetadata");
100
104
  const ExtractValue_1 = require("./ExtractValue");
101
105
  const InstanceSettings_1 = require("./InstanceSettings");
102
- const ScheduledTaskManager_1 = require("./ScheduledTaskManager");
106
+ const node_execution_context_1 = require("./node-execution-context");
103
107
  const Secrets_1 = require("./Secrets");
104
108
  const SSHClientsManager_1 = require("./SSHClientsManager");
105
109
  axios_1.default.defaults.timeout = 300000;
@@ -153,6 +157,7 @@ const validateUrl = (url) => {
153
157
  return false;
154
158
  }
155
159
  };
160
+ exports.validateUrl = validateUrl;
156
161
  function searchForHeader(config, headerName) {
157
162
  if (config.headers === undefined) {
158
163
  return undefined;
@@ -1964,7 +1969,7 @@ const getRequestHelperFunctions = (workflow, node, additionalData, runExecutionD
1964
1969
  do {
1965
1970
  paginateRequestData = getResolvedValue(paginationOptions.request, itemIndex, runIndex, executeData, additionalKeys, false);
1966
1971
  const tempRequestOptions = applyPaginationRequestData(requestOptions, paginateRequestData);
1967
- if (!validateUrl(tempRequestOptions.uri)) {
1972
+ if (!(0, exports.validateUrl)(tempRequestOptions.uri)) {
1968
1973
  throw new n8n_workflow_1.NodeOperationError(node, `'${paginateRequestData.url}' is not a valid URL.`, {
1969
1974
  itemIndex,
1970
1975
  runIndex,
@@ -2087,12 +2092,6 @@ const getRequestHelperFunctions = (workflow, node, additionalData, runExecutionD
2087
2092
  const getSSHTunnelFunctions = () => ({
2088
2093
  getSSHClient: async (credentials) => await typedi_1.default.get(SSHClientsManager_1.SSHClientsManager).getClient(credentials),
2089
2094
  });
2090
- const getSchedulingFunctions = (workflow) => {
2091
- const scheduledTaskManager = typedi_1.default.get(ScheduledTaskManager_1.ScheduledTaskManager);
2092
- return {
2093
- registerCron: (cronExpression, onTick) => scheduledTaskManager.registerCron(workflow, cronExpression, onTick),
2094
- };
2095
- };
2096
2095
  const getAllowedPaths = () => {
2097
2096
  const restrictFileAccessTo = process.env[Constants_1.RESTRICT_FILE_ACCESS_TO];
2098
2097
  if (!restrictFileAccessTo) {
@@ -2224,65 +2223,10 @@ function copyInputItems(items, properties) {
2224
2223
  });
2225
2224
  }
2226
2225
  function getExecutePollFunctions(workflow, node, additionalData, mode, activation) {
2227
- return ((workflow, node) => {
2228
- return {
2229
- ...getCommonWorkflowFunctions(workflow, node, additionalData),
2230
- __emit: () => {
2231
- throw new n8n_workflow_1.ApplicationError('Overwrite NodeExecuteFunctions.getExecutePollFunctions.__emit function');
2232
- },
2233
- __emitError() {
2234
- throw new n8n_workflow_1.ApplicationError('Overwrite NodeExecuteFunctions.getExecutePollFunctions.__emitError function');
2235
- },
2236
- getMode: () => mode,
2237
- getActivationMode: () => activation,
2238
- getCredentials: async (type) => await getCredentials(workflow, node, type, additionalData, mode),
2239
- getNodeParameter: (parameterName, fallbackValue, options) => {
2240
- const runExecutionData = null;
2241
- const itemIndex = 0;
2242
- const runIndex = 0;
2243
- const connectionInputData = [];
2244
- return getNodeParameter(workflow, runExecutionData, runIndex, connectionInputData, node, parameterName, itemIndex, mode, getAdditionalKeys(additionalData, mode, runExecutionData), undefined, fallbackValue, options);
2245
- },
2246
- helpers: {
2247
- createDeferredPromise: n8n_workflow_1.createDeferredPromise,
2248
- ...getRequestHelperFunctions(workflow, node, additionalData),
2249
- ...getBinaryHelperFunctions(additionalData, workflow.id),
2250
- ...getSchedulingFunctions(workflow),
2251
- returnJsonArray,
2252
- },
2253
- };
2254
- })(workflow, node);
2226
+ return new node_execution_context_1.PollContext(workflow, node, additionalData, mode, activation);
2255
2227
  }
2256
2228
  function getExecuteTriggerFunctions(workflow, node, additionalData, mode, activation) {
2257
- return ((workflow, node) => {
2258
- return {
2259
- ...getCommonWorkflowFunctions(workflow, node, additionalData),
2260
- emit: () => {
2261
- throw new n8n_workflow_1.ApplicationError('Overwrite NodeExecuteFunctions.getExecuteTriggerFunctions.emit function');
2262
- },
2263
- emitError: () => {
2264
- throw new n8n_workflow_1.ApplicationError('Overwrite NodeExecuteFunctions.getExecuteTriggerFunctions.emit function');
2265
- },
2266
- getMode: () => mode,
2267
- getActivationMode: () => activation,
2268
- getCredentials: async (type) => await getCredentials(workflow, node, type, additionalData, mode),
2269
- getNodeParameter: (parameterName, fallbackValue, options) => {
2270
- const runExecutionData = null;
2271
- const itemIndex = 0;
2272
- const runIndex = 0;
2273
- const connectionInputData = [];
2274
- return getNodeParameter(workflow, runExecutionData, runIndex, connectionInputData, node, parameterName, itemIndex, mode, getAdditionalKeys(additionalData, mode, runExecutionData), undefined, fallbackValue, options);
2275
- },
2276
- helpers: {
2277
- createDeferredPromise: n8n_workflow_1.createDeferredPromise,
2278
- ...getSSHTunnelFunctions(),
2279
- ...getRequestHelperFunctions(workflow, node, additionalData),
2280
- ...getBinaryHelperFunctions(additionalData, workflow.id),
2281
- ...getSchedulingFunctions(workflow),
2282
- returnJsonArray,
2283
- },
2284
- };
2285
- })(workflow, node);
2229
+ return new node_execution_context_1.TriggerContext(workflow, node, additionalData, mode, activation);
2286
2230
  }
2287
2231
  function getExecuteFunctions(workflow, runExecutionData, runIndex, connectionInputData, inputData, node, additionalData, executeData, mode, closeFunctions, abortSignal) {
2288
2232
  return ((workflow, runExecutionData, connectionInputData, inputData, node) => {
@@ -2570,76 +2514,7 @@ function getSupplyDataFunctions(workflow, runExecutionData, runIndex, connection
2570
2514
  };
2571
2515
  }
2572
2516
  function getExecuteSingleFunctions(workflow, runExecutionData, runIndex, connectionInputData, inputData, node, itemIndex, additionalData, executeData, mode, abortSignal) {
2573
- return ((workflow, runExecutionData, connectionInputData, inputData, node, itemIndex) => {
2574
- return {
2575
- ...getCommonWorkflowFunctions(workflow, node, additionalData),
2576
- ...executionCancellationFunctions(abortSignal),
2577
- continueOnFail: () => continueOnFail(node),
2578
- evaluateExpression: (expression, evaluateItemIndex) => {
2579
- evaluateItemIndex = evaluateItemIndex === undefined ? itemIndex : evaluateItemIndex;
2580
- return workflow.expression.resolveSimpleParameterValue(`=${expression}`, {}, runExecutionData, runIndex, evaluateItemIndex, node.name, connectionInputData, mode, getAdditionalKeys(additionalData, mode, runExecutionData), executeData);
2581
- },
2582
- getContext(type) {
2583
- return n8n_workflow_1.NodeHelpers.getContext(runExecutionData, type, node);
2584
- },
2585
- getCredentials: async (type) => await getCredentials(workflow, node, type, additionalData, mode, executeData, runExecutionData, runIndex, connectionInputData, itemIndex),
2586
- getInputData: (inputIndex = 0, inputName = 'main') => {
2587
- if (!inputData.hasOwnProperty(inputName)) {
2588
- return { json: {} };
2589
- }
2590
- if (inputData[inputName].length < inputIndex) {
2591
- throw new n8n_workflow_1.ApplicationError('Could not get input index', {
2592
- extra: { inputIndex, inputName },
2593
- });
2594
- }
2595
- const allItems = inputData[inputName][inputIndex];
2596
- if (allItems === null) {
2597
- throw new n8n_workflow_1.ApplicationError('Input index was not set', {
2598
- extra: { inputIndex, inputName },
2599
- });
2600
- }
2601
- if (allItems[itemIndex] === null) {
2602
- throw new n8n_workflow_1.ApplicationError('Value of input with given index was not set', {
2603
- extra: { inputIndex, inputName, itemIndex },
2604
- });
2605
- }
2606
- return allItems[itemIndex];
2607
- },
2608
- getInputSourceData: (inputIndex = 0, inputName = 'main') => {
2609
- if (executeData?.source === null) {
2610
- throw new n8n_workflow_1.ApplicationError('Source data is missing');
2611
- }
2612
- return executeData.source[inputName][inputIndex];
2613
- },
2614
- getItemIndex: () => itemIndex,
2615
- getMode: () => mode,
2616
- getExecuteData: () => executeData,
2617
- getNodeParameter: (parameterName, fallbackValue, options) => {
2618
- return getNodeParameter(workflow, runExecutionData, runIndex, connectionInputData, node, parameterName, itemIndex, mode, getAdditionalKeys(additionalData, mode, runExecutionData), executeData, fallbackValue, options);
2619
- },
2620
- getWorkflowDataProxy: () => {
2621
- const dataProxy = new n8n_workflow_1.WorkflowDataProxy(workflow, runExecutionData, runIndex, itemIndex, node.name, connectionInputData, {}, mode, getAdditionalKeys(additionalData, mode, runExecutionData), executeData);
2622
- return dataProxy.getDataProxy();
2623
- },
2624
- helpers: {
2625
- createDeferredPromise: n8n_workflow_1.createDeferredPromise,
2626
- ...getRequestHelperFunctions(workflow, node, additionalData, runExecutionData, connectionInputData),
2627
- ...getBinaryHelperFunctions(additionalData, workflow.id),
2628
- assertBinaryData: (propertyName, inputIndex = 0) => assertBinaryData(inputData, node, itemIndex, propertyName, inputIndex),
2629
- getBinaryDataBuffer: async (propertyName, inputIndex = 0) => await getBinaryDataBuffer(inputData, itemIndex, propertyName, inputIndex),
2630
- },
2631
- logAiEvent: (eventName, msg) => {
2632
- return additionalData.logAiEvent(eventName, {
2633
- executionId: additionalData.executionId ?? 'unsaved-execution',
2634
- nodeName: node.name,
2635
- workflowName: workflow.name ?? 'Unnamed workflow',
2636
- nodeType: node.type,
2637
- workflowId: workflow.id ?? 'unsaved-workflow',
2638
- msg,
2639
- });
2640
- },
2641
- };
2642
- })(workflow, runExecutionData, connectionInputData, inputData, node, itemIndex);
2517
+ return new node_execution_context_1.ExecuteSingleContext(workflow, node, additionalData, mode, runExecutionData, runIndex, connectionInputData, inputData, itemIndex, executeData, abortSignal);
2643
2518
  }
2644
2519
  function getCredentialTestFunctions() {
2645
2520
  return {
@@ -2651,171 +2526,10 @@ function getCredentialTestFunctions() {
2651
2526
  },
2652
2527
  };
2653
2528
  }
2654
- function getLoadOptionsFunctions(workflow, node, path, additionalData) {
2655
- return ((workflow, node, path) => {
2656
- return {
2657
- ...getCommonWorkflowFunctions(workflow, node, additionalData),
2658
- getCredentials: async (type) => await getCredentials(workflow, node, type, additionalData, 'internal'),
2659
- getCurrentNodeParameter: (parameterPath, options) => {
2660
- const nodeParameters = additionalData.currentNodeParameters;
2661
- if (parameterPath.charAt(0) === '&') {
2662
- parameterPath = `${path.split('.').slice(1, -1).join('.')}.${parameterPath.slice(1)}`;
2663
- }
2664
- let returnData = (0, get_1.default)(nodeParameters, parameterPath);
2665
- if (options?.extractValue) {
2666
- const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
2667
- if (nodeType === undefined) {
2668
- throw new n8n_workflow_1.ApplicationError('Node type is not known so cannot return parameter value', {
2669
- tags: { nodeType: node.type },
2670
- });
2671
- }
2672
- returnData = (0, ExtractValue_1.extractValue)(returnData, parameterPath, node, nodeType);
2673
- }
2674
- return returnData;
2675
- },
2676
- getCurrentNodeParameters: () => additionalData.currentNodeParameters,
2677
- getNodeParameter: (parameterName, fallbackValue, options) => {
2678
- const runExecutionData = null;
2679
- const itemIndex = 0;
2680
- const runIndex = 0;
2681
- const mode = 'internal';
2682
- const connectionInputData = [];
2683
- return getNodeParameter(workflow, runExecutionData, runIndex, connectionInputData, node, parameterName, itemIndex, mode, getAdditionalKeys(additionalData, mode, runExecutionData), undefined, fallbackValue, options);
2684
- },
2685
- helpers: {
2686
- ...getSSHTunnelFunctions(),
2687
- ...getRequestHelperFunctions(workflow, node, additionalData),
2688
- },
2689
- };
2690
- })(workflow, node, path);
2691
- }
2692
2529
  function getExecuteHookFunctions(workflow, node, additionalData, mode, activation, webhookData) {
2693
- return ((workflow, node) => {
2694
- return {
2695
- ...getCommonWorkflowFunctions(workflow, node, additionalData),
2696
- getCredentials: async (type) => await getCredentials(workflow, node, type, additionalData, mode),
2697
- getMode: () => mode,
2698
- getActivationMode: () => activation,
2699
- getNodeParameter: (parameterName, fallbackValue, options) => {
2700
- const runExecutionData = null;
2701
- const itemIndex = 0;
2702
- const runIndex = 0;
2703
- const connectionInputData = [];
2704
- return getNodeParameter(workflow, runExecutionData, runIndex, connectionInputData, node, parameterName, itemIndex, mode, getAdditionalKeys(additionalData, mode, runExecutionData), undefined, fallbackValue, options);
2705
- },
2706
- getNodeWebhookUrl: (name) => {
2707
- return getNodeWebhookUrl(name, workflow, node, additionalData, mode, getAdditionalKeys(additionalData, mode, null), webhookData?.isTest);
2708
- },
2709
- getWebhookName() {
2710
- if (webhookData === undefined) {
2711
- throw new n8n_workflow_1.ApplicationError('Only supported in webhook functions');
2712
- }
2713
- return webhookData.webhookDescription.name;
2714
- },
2715
- getWebhookDescription: (name) => getWebhookDescription(name, workflow, node),
2716
- helpers: getRequestHelperFunctions(workflow, node, additionalData),
2717
- };
2718
- })(workflow, node);
2530
+ return new node_execution_context_1.HookContext(workflow, node, additionalData, mode, activation, webhookData);
2719
2531
  }
2720
2532
  function getExecuteWebhookFunctions(workflow, node, additionalData, mode, webhookData, closeFunctions, runExecutionData) {
2721
- return ((workflow, node, runExecutionData) => {
2722
- return {
2723
- ...getCommonWorkflowFunctions(workflow, node, additionalData),
2724
- getBodyData() {
2725
- if (additionalData.httpRequest === undefined) {
2726
- throw new n8n_workflow_1.ApplicationError('Request is missing');
2727
- }
2728
- return additionalData.httpRequest.body;
2729
- },
2730
- getCredentials: async (type) => await getCredentials(workflow, node, type, additionalData, mode),
2731
- getHeaderData() {
2732
- if (additionalData.httpRequest === undefined) {
2733
- throw new n8n_workflow_1.ApplicationError('Request is missing');
2734
- }
2735
- return additionalData.httpRequest.headers;
2736
- },
2737
- async getInputConnectionData(inputName, itemIndex) {
2738
- const connectionInputData = [
2739
- { json: additionalData.httpRequest?.body || {} },
2740
- ];
2741
- const runExecutionData = {
2742
- resultData: {
2743
- runData: {},
2744
- },
2745
- };
2746
- const executeData = {
2747
- data: {
2748
- main: [connectionInputData],
2749
- },
2750
- node,
2751
- source: null,
2752
- };
2753
- const runIndex = 0;
2754
- return await getInputConnectionData.call(this, workflow, runExecutionData, runIndex, connectionInputData, {}, additionalData, executeData, mode, closeFunctions, inputName, itemIndex);
2755
- },
2756
- getMode: () => mode,
2757
- evaluateExpression: (expression, evaluateItemIndex) => {
2758
- const itemIndex = evaluateItemIndex === undefined ? 0 : evaluateItemIndex;
2759
- const runIndex = 0;
2760
- let connectionInputData = [];
2761
- let executionData;
2762
- if (runExecutionData?.executionData !== undefined) {
2763
- executionData = runExecutionData.executionData.nodeExecutionStack[0];
2764
- if (executionData !== undefined) {
2765
- connectionInputData = executionData.data.main[0];
2766
- }
2767
- }
2768
- const additionalKeys = getAdditionalKeys(additionalData, mode, runExecutionData);
2769
- return workflow.expression.resolveSimpleParameterValue(`=${expression}`, {}, runExecutionData, runIndex, itemIndex, node.name, connectionInputData, mode, additionalKeys, executionData);
2770
- },
2771
- getNodeParameter: (parameterName, fallbackValue, options) => {
2772
- const itemIndex = 0;
2773
- const runIndex = 0;
2774
- let connectionInputData = [];
2775
- let executionData;
2776
- if (runExecutionData?.executionData !== undefined) {
2777
- executionData = runExecutionData.executionData.nodeExecutionStack[0];
2778
- if (executionData !== undefined) {
2779
- connectionInputData = executionData.data.main[0];
2780
- }
2781
- }
2782
- const additionalKeys = getAdditionalKeys(additionalData, mode, runExecutionData);
2783
- return getNodeParameter(workflow, runExecutionData, runIndex, connectionInputData, node, parameterName, itemIndex, mode, additionalKeys, executionData, fallbackValue, options);
2784
- },
2785
- getParamsData() {
2786
- if (additionalData.httpRequest === undefined) {
2787
- throw new n8n_workflow_1.ApplicationError('Request is missing');
2788
- }
2789
- return additionalData.httpRequest.params;
2790
- },
2791
- getQueryData() {
2792
- if (additionalData.httpRequest === undefined) {
2793
- throw new n8n_workflow_1.ApplicationError('Request is missing');
2794
- }
2795
- return additionalData.httpRequest.query;
2796
- },
2797
- getRequestObject() {
2798
- if (additionalData.httpRequest === undefined) {
2799
- throw new n8n_workflow_1.ApplicationError('Request is missing');
2800
- }
2801
- return additionalData.httpRequest;
2802
- },
2803
- getResponseObject() {
2804
- if (additionalData.httpResponse === undefined) {
2805
- throw new n8n_workflow_1.ApplicationError('Response is missing');
2806
- }
2807
- return additionalData.httpResponse;
2808
- },
2809
- getNodeWebhookUrl: (name) => getNodeWebhookUrl(name, workflow, node, additionalData, mode, getAdditionalKeys(additionalData, mode, null)),
2810
- getWebhookName: () => webhookData.webhookDescription.name,
2811
- helpers: {
2812
- createDeferredPromise: n8n_workflow_1.createDeferredPromise,
2813
- ...getRequestHelperFunctions(workflow, node, additionalData),
2814
- ...getBinaryHelperFunctions(additionalData, workflow.id),
2815
- returnJsonArray,
2816
- },
2817
- nodeHelpers: getNodeHelperFunctions(additionalData, workflow.id),
2818
- };
2819
- })(workflow, node, runExecutionData);
2533
+ return new node_execution_context_1.WebhookContext(workflow, node, additionalData, mode, webhookData, closeFunctions, runExecutionData);
2820
2534
  }
2821
2535
  //# sourceMappingURL=NodeExecuteFunctions.js.map