n8n-core 1.66.0 → 1.67.1

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 (35) hide show
  1. package/dist/NodeExecuteFunctions.d.ts +17 -4
  2. package/dist/NodeExecuteFunctions.js +33 -305
  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 +102 -0
  13. package/dist/node-execution-context/execute-single-context.js.map +1 -0
  14. package/dist/node-execution-context/hook-context.d.ts +14 -0
  15. package/dist/node-execution-context/hook-context.js +41 -0
  16. package/dist/node-execution-context/hook-context.js.map +1 -0
  17. package/dist/node-execution-context/index.d.ts +6 -0
  18. package/dist/node-execution-context/index.js +16 -0
  19. package/dist/node-execution-context/index.js.map +1 -0
  20. package/dist/node-execution-context/load-options-context.d.ts +11 -0
  21. package/dist/node-execution-context/load-options-context.js +44 -0
  22. package/dist/node-execution-context/load-options-context.js.map +1 -0
  23. package/dist/node-execution-context/node-execution-context.d.ts +30 -0
  24. package/dist/node-execution-context/node-execution-context.js +83 -0
  25. package/dist/node-execution-context/node-execution-context.js.map +1 -0
  26. package/dist/node-execution-context/poll-context.d.ts +12 -0
  27. package/dist/node-execution-context/poll-context.js +42 -0
  28. package/dist/node-execution-context/poll-context.js.map +1 -0
  29. package/dist/node-execution-context/trigger-context.d.ts +12 -0
  30. package/dist/node-execution-context/trigger-context.js +43 -0
  31. package/dist/node-execution-context/trigger-context.js.map +1 -0
  32. package/dist/node-execution-context/webhook-context.d.ts +24 -0
  33. package/dist/node-execution-context/webhook-context.js +109 -0
  34. package/dist/node-execution-context/webhook-context.js.map +1 -0
  35. 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 { BinaryHelperFunctions, CloseFunction, FileSystemHelperFunctions, 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, NodeHelperFunctions, NodeParameterValueType, PaginationOptions, RequestHelperFunctions, Workflow, WorkflowActivateMode, WorkflowExecuteMode, EnsureTypeOptions, SSHTunnelFunctions, DeduplicationHelperFunctions, IDeduplicationOutput, IDeduplicationOutputItems, ICheckProcessedOptions, DeduplicationScope, DeduplicationItemTypes, ICheckProcessedContextData, ISupplyDataFunctions, WebhookType, SchedulingFunctions } 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,9 +47,17 @@ 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>;
53
+ export declare const getRequestHelperFunctions: (workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, runExecutionData?: IRunExecutionData | null, connectionInputData?: INodeExecutionData[]) => RequestHelperFunctions;
54
+ export declare const getSSHTunnelFunctions: () => SSHTunnelFunctions;
55
+ export declare const getSchedulingFunctions: (workflow: Workflow) => SchedulingFunctions;
46
56
  export declare function isFilePathBlocked(filePath: string): boolean;
57
+ export declare const getFileSystemHelperFunctions: (node: INode) => FileSystemHelperFunctions;
58
+ export declare const getNodeHelperFunctions: ({ executionId }: IWorkflowExecuteAdditionalData, workflowId: string) => NodeHelperFunctions;
59
+ export declare const getBinaryHelperFunctions: ({ executionId }: IWorkflowExecuteAdditionalData, workflowId: string) => BinaryHelperFunctions;
60
+ export declare const getCheckProcessedHelperFunctions: (workflow: Workflow, node: INode) => DeduplicationHelperFunctions;
47
61
  export declare function copyInputItems(items: INodeExecutionData[], properties: string[]): IDataObject[];
48
62
  export declare function getExecutePollFunctions(workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, activation: WorkflowActivateMode): IPollFunctions;
49
63
  export declare function getExecuteTriggerFunctions(workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, activation: WorkflowActivateMode): ITriggerFunctions;
@@ -51,6 +65,5 @@ export declare function getExecuteFunctions(workflow: Workflow, runExecutionData
51
65
  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
66
  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
67
  export declare function getCredentialTestFunctions(): ICredentialTestFunctions;
54
- export declare function getLoadOptionsFunctions(workflow: Workflow, node: INode, path: string, additionalData: IWorkflowExecuteAdditionalData): ILoadOptionsFunctions;
55
68
  export declare function getExecuteHookFunctions(workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, activation: WorkflowActivateMode, webhookData?: IWebhookData): IHookFunctions;
56
69
  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.getCheckProcessedHelperFunctions = exports.getBinaryHelperFunctions = exports.getNodeHelperFunctions = exports.getFileSystemHelperFunctions = exports.getSchedulingFunctions = exports.getSSHTunnelFunctions = exports.getRequestHelperFunctions = 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,6 +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");
106
+ const node_execution_context_1 = require("./node-execution-context");
102
107
  const ScheduledTaskManager_1 = require("./ScheduledTaskManager");
103
108
  const Secrets_1 = require("./Secrets");
104
109
  const SSHClientsManager_1 = require("./SSHClientsManager");
@@ -153,6 +158,7 @@ const validateUrl = (url) => {
153
158
  return false;
154
159
  }
155
160
  };
161
+ exports.validateUrl = validateUrl;
156
162
  function searchForHeader(config, headerName) {
157
163
  if (config.headers === undefined) {
158
164
  return undefined;
@@ -1964,7 +1970,7 @@ const getRequestHelperFunctions = (workflow, node, additionalData, runExecutionD
1964
1970
  do {
1965
1971
  paginateRequestData = getResolvedValue(paginationOptions.request, itemIndex, runIndex, executeData, additionalKeys, false);
1966
1972
  const tempRequestOptions = applyPaginationRequestData(requestOptions, paginateRequestData);
1967
- if (!validateUrl(tempRequestOptions.uri)) {
1973
+ if (!(0, exports.validateUrl)(tempRequestOptions.uri)) {
1968
1974
  throw new n8n_workflow_1.NodeOperationError(node, `'${paginateRequestData.url}' is not a valid URL.`, {
1969
1975
  itemIndex,
1970
1976
  runIndex,
@@ -2084,15 +2090,18 @@ const getRequestHelperFunctions = (workflow, node, additionalData, runExecutionD
2084
2090
  },
2085
2091
  };
2086
2092
  };
2093
+ exports.getRequestHelperFunctions = getRequestHelperFunctions;
2087
2094
  const getSSHTunnelFunctions = () => ({
2088
2095
  getSSHClient: async (credentials) => await typedi_1.default.get(SSHClientsManager_1.SSHClientsManager).getClient(credentials),
2089
2096
  });
2097
+ exports.getSSHTunnelFunctions = getSSHTunnelFunctions;
2090
2098
  const getSchedulingFunctions = (workflow) => {
2091
2099
  const scheduledTaskManager = typedi_1.default.get(ScheduledTaskManager_1.ScheduledTaskManager);
2092
2100
  return {
2093
2101
  registerCron: (cronExpression, onTick) => scheduledTaskManager.registerCron(workflow, cronExpression, onTick),
2094
2102
  };
2095
2103
  };
2104
+ exports.getSchedulingFunctions = getSchedulingFunctions;
2096
2105
  const getAllowedPaths = () => {
2097
2106
  const restrictFileAccessTo = process.env[Constants_1.RESTRICT_FILE_ACCESS_TO];
2098
2107
  if (!restrictFileAccessTo) {
@@ -2177,9 +2186,11 @@ const getFileSystemHelperFunctions = (node) => ({
2177
2186
  return await (0, promises_1.writeFile)(filePath, content, { encoding: 'binary', flag });
2178
2187
  },
2179
2188
  });
2189
+ exports.getFileSystemHelperFunctions = getFileSystemHelperFunctions;
2180
2190
  const getNodeHelperFunctions = ({ executionId }, workflowId) => ({
2181
2191
  copyBinaryFile: async (filePath, fileName, mimeType) => await copyBinaryFile(workflowId, executionId, filePath, fileName, mimeType),
2182
2192
  });
2193
+ exports.getNodeHelperFunctions = getNodeHelperFunctions;
2183
2194
  const getBinaryHelperFunctions = ({ executionId }, workflowId) => ({
2184
2195
  getBinaryPath,
2185
2196
  getBinaryStream,
@@ -2192,6 +2203,7 @@ const getBinaryHelperFunctions = ({ executionId }, workflowId) => ({
2192
2203
  throw new n8n_workflow_1.ApplicationError('`copyBinaryFile` has been removed. Please upgrade this node.');
2193
2204
  },
2194
2205
  });
2206
+ exports.getBinaryHelperFunctions = getBinaryHelperFunctions;
2195
2207
  const getCheckProcessedHelperFunctions = (workflow, node) => ({
2196
2208
  async checkProcessedAndRecord(items, scope, options) {
2197
2209
  return await checkProcessedAndRecord(items, scope, { node, workflow }, options);
@@ -2209,6 +2221,7 @@ const getCheckProcessedHelperFunctions = (workflow, node) => ({
2209
2221
  return await getProcessedDataCount(scope, { node, workflow }, options);
2210
2222
  },
2211
2223
  });
2224
+ exports.getCheckProcessedHelperFunctions = getCheckProcessedHelperFunctions;
2212
2225
  function copyInputItems(items, properties) {
2213
2226
  return items.map((item) => {
2214
2227
  const newItem = {};
@@ -2224,65 +2237,10 @@ function copyInputItems(items, properties) {
2224
2237
  });
2225
2238
  }
2226
2239
  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);
2240
+ return new node_execution_context_1.PollContext(workflow, node, additionalData, mode, activation);
2255
2241
  }
2256
2242
  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);
2243
+ return new node_execution_context_1.TriggerContext(workflow, node, additionalData, mode, activation);
2286
2244
  }
2287
2245
  function getExecuteFunctions(workflow, runExecutionData, runIndex, connectionInputData, inputData, node, additionalData, executeData, mode, closeFunctions, abortSignal) {
2288
2246
  return ((workflow, runExecutionData, connectionInputData, inputData, node) => {
@@ -2428,18 +2386,18 @@ function getExecuteFunctions(workflow, runExecutionData, runIndex, connectionInp
2428
2386
  helpers: {
2429
2387
  createDeferredPromise: n8n_workflow_1.createDeferredPromise,
2430
2388
  copyInputItems,
2431
- ...getRequestHelperFunctions(workflow, node, additionalData, runExecutionData, connectionInputData),
2432
- ...getSSHTunnelFunctions(),
2433
- ...getFileSystemHelperFunctions(node),
2434
- ...getBinaryHelperFunctions(additionalData, workflow.id),
2435
- ...getCheckProcessedHelperFunctions(workflow, node),
2389
+ ...(0, exports.getRequestHelperFunctions)(workflow, node, additionalData, runExecutionData, connectionInputData),
2390
+ ...(0, exports.getSSHTunnelFunctions)(),
2391
+ ...(0, exports.getFileSystemHelperFunctions)(node),
2392
+ ...(0, exports.getBinaryHelperFunctions)(additionalData, workflow.id),
2393
+ ...(0, exports.getCheckProcessedHelperFunctions)(workflow, node),
2436
2394
  assertBinaryData: (itemIndex, propertyName) => assertBinaryData(inputData, node, itemIndex, propertyName, 0),
2437
2395
  getBinaryDataBuffer: async (itemIndex, propertyName) => await getBinaryDataBuffer(inputData, itemIndex, propertyName, 0),
2438
2396
  returnJsonArray,
2439
2397
  normalizeItems,
2440
2398
  constructExecutionMetaData,
2441
2399
  },
2442
- nodeHelpers: getNodeHelperFunctions(additionalData, workflow.id),
2400
+ nodeHelpers: (0, exports.getNodeHelperFunctions)(additionalData, workflow.id),
2443
2401
  logAiEvent: (eventName, msg) => {
2444
2402
  return additionalData.logAiEvent(eventName, {
2445
2403
  executionId: additionalData.executionId ?? 'unsaved-execution',
@@ -2556,11 +2514,11 @@ function getSupplyDataFunctions(workflow, runExecutionData, runIndex, connection
2556
2514
  helpers: {
2557
2515
  createDeferredPromise: n8n_workflow_1.createDeferredPromise,
2558
2516
  copyInputItems,
2559
- ...getRequestHelperFunctions(workflow, node, additionalData, runExecutionData, connectionInputData),
2560
- ...getSSHTunnelFunctions(),
2561
- ...getFileSystemHelperFunctions(node),
2562
- ...getBinaryHelperFunctions(additionalData, workflow.id),
2563
- ...getCheckProcessedHelperFunctions(workflow, node),
2517
+ ...(0, exports.getRequestHelperFunctions)(workflow, node, additionalData, runExecutionData, connectionInputData),
2518
+ ...(0, exports.getSSHTunnelFunctions)(),
2519
+ ...(0, exports.getFileSystemHelperFunctions)(node),
2520
+ ...(0, exports.getBinaryHelperFunctions)(additionalData, workflow.id),
2521
+ ...(0, exports.getCheckProcessedHelperFunctions)(workflow, node),
2564
2522
  assertBinaryData: (itemIndex, propertyName) => assertBinaryData(inputData, node, itemIndex, propertyName, 0),
2565
2523
  getBinaryDataBuffer: async (itemIndex, propertyName) => await getBinaryDataBuffer(inputData, itemIndex, propertyName, 0),
2566
2524
  returnJsonArray,
@@ -2570,252 +2528,22 @@ function getSupplyDataFunctions(workflow, runExecutionData, runIndex, connection
2570
2528
  };
2571
2529
  }
2572
2530
  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);
2531
+ return new node_execution_context_1.ExecuteSingleContext(workflow, node, additionalData, mode, runExecutionData, runIndex, connectionInputData, inputData, itemIndex, executeData, abortSignal);
2643
2532
  }
2644
2533
  function getCredentialTestFunctions() {
2645
2534
  return {
2646
2535
  helpers: {
2647
- ...getSSHTunnelFunctions(),
2536
+ ...(0, exports.getSSHTunnelFunctions)(),
2648
2537
  request: async (uriOrObject, options) => {
2649
2538
  return await proxyRequestToAxios(undefined, undefined, undefined, uriOrObject, options);
2650
2539
  },
2651
2540
  },
2652
2541
  };
2653
2542
  }
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
2543
  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);
2544
+ return new node_execution_context_1.HookContext(workflow, node, additionalData, mode, activation, webhookData);
2719
2545
  }
2720
2546
  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);
2547
+ return new node_execution_context_1.WebhookContext(workflow, node, additionalData, mode, webhookData, closeFunctions, runExecutionData);
2820
2548
  }
2821
2549
  //# sourceMappingURL=NodeExecuteFunctions.js.map