n8n-core 1.72.1 → 1.74.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.
- package/LICENSE.md +5 -3
- package/dist/ActiveWorkflows.d.ts +9 -3
- package/dist/ActiveWorkflows.js +25 -14
- package/dist/ActiveWorkflows.js.map +1 -1
- package/dist/BinaryData/BinaryData.service.js +3 -3
- package/dist/BinaryData/BinaryData.service.js.map +1 -1
- package/dist/BinaryData/ObjectStore.manager.js +2 -2
- package/dist/BinaryData/ObjectStore.manager.js.map +1 -1
- package/dist/Cipher.js +2 -2
- package/dist/Cipher.js.map +1 -1
- package/dist/Constants.d.ts +5 -0
- package/dist/Constants.js +29 -1
- package/dist/Constants.js.map +1 -1
- package/dist/CreateNodeAsTool.d.ts +2 -2
- package/dist/CreateNodeAsTool.js +30 -44
- package/dist/CreateNodeAsTool.js.map +1 -1
- package/dist/Credentials.js +2 -2
- package/dist/Credentials.js.map +1 -1
- package/dist/DirectoryLoader.d.ts +3 -0
- package/dist/DirectoryLoader.js +26 -6
- package/dist/DirectoryLoader.js.map +1 -1
- package/dist/InstanceSettings.d.ts +11 -3
- package/dist/InstanceSettings.js +53 -24
- package/dist/InstanceSettings.js.map +1 -1
- package/dist/InstanceSettingsConfig.d.ts +3 -0
- package/dist/InstanceSettingsConfig.js +9 -1
- package/dist/InstanceSettingsConfig.js.map +1 -1
- package/dist/NodeExecuteFunctions.d.ts +2 -7
- package/dist/NodeExecuteFunctions.js +27 -125
- package/dist/NodeExecuteFunctions.js.map +1 -1
- package/dist/ObjectStore/ObjectStore.service.ee.d.ts +3 -1
- package/dist/ObjectStore/ObjectStore.service.ee.js +9 -4
- package/dist/ObjectStore/ObjectStore.service.ee.js.map +1 -1
- package/dist/RoutingNode.d.ts +18 -0
- package/dist/RoutingNode.js +560 -0
- package/dist/RoutingNode.js.map +1 -0
- package/dist/SSHClientsManager.js +2 -2
- package/dist/SSHClientsManager.js.map +1 -1
- package/dist/ScheduledTaskManager.js +2 -2
- package/dist/ScheduledTaskManager.js.map +1 -1
- package/dist/SerializedBuffer.d.ts +6 -0
- package/dist/SerializedBuffer.js +16 -0
- package/dist/SerializedBuffer.js.map +1 -0
- package/dist/TriggersAndPollers.d.ts +5 -0
- package/dist/TriggersAndPollers.js +70 -0
- package/dist/TriggersAndPollers.js.map +1 -0
- package/dist/WorkflowExecute.d.ts +9 -1
- package/dist/WorkflowExecute.js +267 -117
- package/dist/WorkflowExecute.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/decorators/index.d.ts +1 -0
- package/dist/decorators/index.js +6 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/memoized.d.ts +1 -0
- package/dist/decorators/memoized.js +23 -0
- package/dist/decorators/memoized.js.map +1 -0
- package/dist/error-reporter.d.ts +18 -0
- package/dist/error-reporter.js +184 -0
- package/dist/error-reporter.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/logging/logger.d.ts +34 -0
- package/dist/logging/logger.js +210 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/node-execution-context/base-execute-context.d.ts +1 -3
- package/dist/node-execution-context/base-execute-context.js +2 -10
- package/dist/node-execution-context/base-execute-context.js.map +1 -1
- package/dist/node-execution-context/execute-context.d.ts +2 -2
- package/dist/node-execution-context/execute-context.js +4 -2
- package/dist/node-execution-context/execute-context.js.map +1 -1
- package/dist/node-execution-context/execute-single-context.js +1 -0
- package/dist/node-execution-context/execute-single-context.js.map +1 -1
- package/dist/node-execution-context/index.d.ts +2 -1
- package/dist/node-execution-context/index.js +5 -3
- package/dist/node-execution-context/index.js.map +1 -1
- package/dist/node-execution-context/local-load-options-context.d.ts +10 -0
- package/dist/node-execution-context/local-load-options-context.js +49 -0
- package/dist/node-execution-context/local-load-options-context.js.map +1 -0
- package/dist/node-execution-context/node-execution-context.d.ts +10 -4
- package/dist/node-execution-context/node-execution-context.js +70 -8
- package/dist/node-execution-context/node-execution-context.js.map +1 -1
- package/dist/node-execution-context/supply-data-context.d.ts +5 -6
- package/dist/node-execution-context/supply-data-context.js +9 -19
- package/dist/node-execution-context/supply-data-context.js.map +1 -1
- package/dist/node-execution-context/utils/cleanupParameterData.d.ts +2 -0
- package/dist/node-execution-context/utils/cleanupParameterData.js +27 -0
- package/dist/node-execution-context/utils/cleanupParameterData.js.map +1 -0
- package/dist/node-execution-context/utils/ensureType.d.ts +6 -0
- package/dist/node-execution-context/utils/ensureType.js +75 -0
- package/dist/node-execution-context/utils/ensureType.js.map +1 -0
- package/dist/node-execution-context/utils/getAdditionalKeys.d.ts +4 -0
- package/dist/node-execution-context/utils/getAdditionalKeys.js +57 -0
- package/dist/node-execution-context/utils/getAdditionalKeys.js.map +1 -0
- package/dist/node-execution-context/utils/getInputConnectionData.d.ts +4 -0
- package/dist/node-execution-context/utils/getInputConnectionData.js +99 -0
- package/dist/node-execution-context/utils/getInputConnectionData.js.map +1 -0
- package/dist/node-execution-context/utils/validateValueAgainstSchema.d.ts +2 -0
- package/dist/node-execution-context/utils/validateValueAgainstSchema.js +129 -0
- package/dist/node-execution-context/utils/validateValueAgainstSchema.js.map +1 -0
- package/dist/node-execution-context/webhook-context.d.ts +2 -2
- package/dist/node-execution-context/webhook-context.js +2 -1
- package/dist/node-execution-context/webhook-context.js.map +1 -1
- package/dist/node-execution-context/workflow-node-context.d.ts +6 -0
- package/dist/node-execution-context/workflow-node-context.js +14 -0
- package/dist/node-execution-context/workflow-node-context.js.map +1 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +10 -0
- package/dist/utils.js.map +1 -0
- package/package.json +13 -8
- package/dist/node-execution-context/utils.d.ts +0 -11
- package/dist/node-execution-context/utils.js +0 -275
- package/dist/node-execution-context/utils.js.map +0 -1
|
@@ -5,25 +5,29 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
8
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
13
|
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.ObjectStoreService = void 0;
|
|
16
|
+
const di_1 = require("@n8n/di");
|
|
13
17
|
const aws4_1 = require("aws4");
|
|
14
18
|
const axios_1 = __importDefault(require("axios"));
|
|
15
19
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
16
20
|
const node_crypto_1 = require("node:crypto");
|
|
17
|
-
const
|
|
21
|
+
const logger_1 = require("../logging/logger");
|
|
18
22
|
const utils_1 = require("./utils");
|
|
19
23
|
let ObjectStoreService = class ObjectStoreService {
|
|
20
|
-
constructor() {
|
|
24
|
+
constructor(logger) {
|
|
25
|
+
this.logger = logger;
|
|
21
26
|
this.host = '';
|
|
22
27
|
this.bucket = { region: '', name: '' };
|
|
23
28
|
this.credentials = { accessKeyId: '', secretAccessKey: '' };
|
|
24
29
|
this.isReady = false;
|
|
25
30
|
this.isReadOnly = false;
|
|
26
|
-
this.logger = n8n_workflow_1.LoggerProxy;
|
|
27
31
|
}
|
|
28
32
|
async init(host, bucket, credentials) {
|
|
29
33
|
this.host = host;
|
|
@@ -183,6 +187,7 @@ let ObjectStoreService = class ObjectStoreService {
|
|
|
183
187
|
};
|
|
184
188
|
exports.ObjectStoreService = ObjectStoreService;
|
|
185
189
|
exports.ObjectStoreService = ObjectStoreService = __decorate([
|
|
186
|
-
(0,
|
|
190
|
+
(0, di_1.Service)(),
|
|
191
|
+
__metadata("design:paramtypes", [logger_1.Logger])
|
|
187
192
|
], ObjectStoreService);
|
|
188
193
|
//# sourceMappingURL=ObjectStore.service.ee.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectStore.service.ee.js","sourceRoot":"","sources":["../../src/ObjectStore/ObjectStore.service.ee.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ObjectStore.service.ee.js","sourceRoot":"","sources":["../../src/ObjectStore/ObjectStore.service.ee.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gCAAkC;AAClC,+BAA4B;AAE5B,kDAA0B;AAE1B,+CAAgD;AAChD,6CAAyC;AAGzC,6CAA0C;AAU1C,mCAAkE;AAI3D,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAW9B,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QAVnC,SAAI,GAAG,EAAE,CAAC;QAEV,WAAM,GAAW,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;QAE1C,gBAAW,GAAoB,EAAE,WAAW,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC;QAExE,YAAO,GAAG,KAAK,CAAC;QAEhB,eAAU,GAAG,KAAK,CAAC;IAEmB,CAAC;IAE/C,KAAK,CAAC,IAAI,CAAC,IAAY,EAAE,MAAc,EAAE,WAAoC;QAC5E,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QAC/B,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAEnC,IAAI,CAAC,WAAW,GAAG;YAClB,WAAW,EAAE,WAAW,CAAC,SAAS;YAClC,eAAe,EAAE,WAAW,CAAC,YAAY;SACzC,CAAC;QAEF,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC;QAE7B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,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YAClC,MAAM;YACN,GAAG,EAAE,WAAW,IAAI,GAAG,IAAI,EAAE;YAC7B,OAAO,EAAE,aAAa,CAAC,OAAO;SAC9B,CAAC;QAEF,IAAI,IAAI;YAAE,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;QAC7B,IAAI,YAAY;YAAE,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;QAErD,IAAI,CAAC;YACJ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;YAEvD,OAAO,MAAM,eAAK,CAAC,OAAO,CAAI,MAAM,CAAC,CAAC;QACvC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,MAAM,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAEzD,MAAM,OAAO,GAAG,yBAAyB,KAAK,CAAC,OAAO,EAAE,CAAC;YAEzD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;YAEvC,MAAM,IAAI,+BAAgB,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;QAC1E,CAAC;IACF,CAAC;CACD,CAAA;AAxQY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,YAAO,GAAE;qCAY4B,eAAM;GAX/B,kBAAkB,CAwQ9B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ICredentialsDecrypted, IN8nHttpFullResponse, INode, INodeExecutionData, INodePropertyOptions, INodeType, DeclarativeRestApiSettings, IRunExecutionData, ITaskDataConnections, IWorkflowDataProxyAdditionalKeys, IWorkflowExecuteAdditionalData, WorkflowExecuteMode, IDataObject, IExecuteData, IExecuteSingleFunctions, IN8nRequestOperations, INodeProperties, NodeParameterValueType, PostReceiveAction, Workflow } from 'n8n-workflow';
|
|
2
|
+
export declare class RoutingNode {
|
|
3
|
+
additionalData: IWorkflowExecuteAdditionalData;
|
|
4
|
+
connectionInputData: INodeExecutionData[];
|
|
5
|
+
node: INode;
|
|
6
|
+
mode: WorkflowExecuteMode;
|
|
7
|
+
runExecutionData: IRunExecutionData;
|
|
8
|
+
workflow: Workflow;
|
|
9
|
+
constructor(workflow: Workflow, node: INode, connectionInputData: INodeExecutionData[], runExecutionData: IRunExecutionData, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode);
|
|
10
|
+
runNode(inputData: ITaskDataConnections, runIndex: number, nodeType: INodeType, executeData: IExecuteData, credentialsDecrypted?: ICredentialsDecrypted, abortSignal?: AbortSignal): Promise<INodeExecutionData[][] | null | undefined>;
|
|
11
|
+
mergeOptions(destinationOptions: DeclarativeRestApiSettings.ResultOptions, sourceOptions?: DeclarativeRestApiSettings.ResultOptions): void;
|
|
12
|
+
runPostReceiveAction(executeSingleFunctions: IExecuteSingleFunctions, action: PostReceiveAction, inputData: INodeExecutionData[], responseData: IN8nHttpFullResponse, parameterValue: string | IDataObject | undefined, itemIndex: number, runIndex: number): Promise<INodeExecutionData[]>;
|
|
13
|
+
postProcessResponseData(executeSingleFunctions: IExecuteSingleFunctions, responseData: IN8nHttpFullResponse, requestData: DeclarativeRestApiSettings.ResultOptions, itemIndex: number, runIndex: number): Promise<INodeExecutionData[]>;
|
|
14
|
+
rawRoutingRequest(executeSingleFunctions: IExecuteSingleFunctions, requestData: DeclarativeRestApiSettings.ResultOptions, credentialType?: string, credentialsDecrypted?: ICredentialsDecrypted): Promise<IN8nHttpFullResponse>;
|
|
15
|
+
makeRoutingRequest(requestData: DeclarativeRestApiSettings.ResultOptions, executeSingleFunctions: IExecuteSingleFunctions, itemIndex: number, runIndex: number, credentialType?: string, requestOperations?: IN8nRequestOperations, credentialsDecrypted?: ICredentialsDecrypted): Promise<INodeExecutionData[]>;
|
|
16
|
+
getParameterValue(parameterValue: NodeParameterValueType, itemIndex: number, runIndex: number, executeData: IExecuteData, additionalKeys?: IWorkflowDataProxyAdditionalKeys, returnObjectAsString?: boolean): NodeParameterValueType;
|
|
17
|
+
getRequestOptionsFromParameters(executeSingleFunctions: IExecuteSingleFunctions, nodeProperties: INodeProperties | INodePropertyOptions, itemIndex: number, runIndex: number, path: string, additionalKeys?: IWorkflowDataProxyAdditionalKeys): DeclarativeRestApiSettings.ResultOptions | undefined;
|
|
18
|
+
}
|
|
@@ -0,0 +1,560 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.RoutingNode = void 0;
|
|
7
|
+
const get_1 = __importDefault(require("lodash/get"));
|
|
8
|
+
const merge_1 = __importDefault(require("lodash/merge"));
|
|
9
|
+
const set_1 = __importDefault(require("lodash/set"));
|
|
10
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
11
|
+
const node_url_1 = __importDefault(require("node:url"));
|
|
12
|
+
const node_execution_context_1 = require("./node-execution-context");
|
|
13
|
+
class RoutingNode {
|
|
14
|
+
constructor(workflow, node, connectionInputData, runExecutionData, additionalData, mode) {
|
|
15
|
+
this.additionalData = additionalData;
|
|
16
|
+
this.connectionInputData = connectionInputData;
|
|
17
|
+
this.runExecutionData = runExecutionData;
|
|
18
|
+
this.mode = mode;
|
|
19
|
+
this.node = node;
|
|
20
|
+
this.workflow = workflow;
|
|
21
|
+
}
|
|
22
|
+
async runNode(inputData, runIndex, nodeType, executeData, credentialsDecrypted, abortSignal) {
|
|
23
|
+
const items = inputData.main[0];
|
|
24
|
+
const returnData = [];
|
|
25
|
+
const closeFunctions = [];
|
|
26
|
+
const executeFunctions = new node_execution_context_1.ExecuteContext(this.workflow, this.node, this.additionalData, this.mode, this.runExecutionData, runIndex, this.connectionInputData, inputData, executeData, closeFunctions, abortSignal);
|
|
27
|
+
let credentialDescription;
|
|
28
|
+
if (nodeType.description.credentials?.length) {
|
|
29
|
+
if (nodeType.description.credentials.length === 1) {
|
|
30
|
+
credentialDescription = nodeType.description.credentials[0];
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const authenticationMethod = executeFunctions.getNodeParameter('authentication', 0);
|
|
34
|
+
credentialDescription = nodeType.description.credentials.find((x) => x.displayOptions?.show?.authentication?.includes(authenticationMethod));
|
|
35
|
+
if (!credentialDescription) {
|
|
36
|
+
throw new n8n_workflow_1.NodeOperationError(this.node, `Node type "${this.node.type}" does not have any credentials of type "${authenticationMethod}" defined`, { level: 'warning' });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
let credentials;
|
|
41
|
+
if (credentialsDecrypted) {
|
|
42
|
+
credentials = credentialsDecrypted.data;
|
|
43
|
+
}
|
|
44
|
+
else if (credentialDescription) {
|
|
45
|
+
try {
|
|
46
|
+
credentials =
|
|
47
|
+
(await executeFunctions.getCredentials(credentialDescription.name, 0)) || {};
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (credentialDescription.required) {
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
credentialDescription = undefined;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const { batching } = executeFunctions.getNodeParameter('requestOptions', 0, {});
|
|
59
|
+
const batchSize = batching?.batch?.batchSize > 0 ? batching?.batch?.batchSize : 1;
|
|
60
|
+
const batchInterval = batching?.batch.batchInterval;
|
|
61
|
+
const requestPromises = [];
|
|
62
|
+
const itemContext = [];
|
|
63
|
+
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
|
64
|
+
if (itemIndex > 0 && batchSize >= 0 && batchInterval > 0) {
|
|
65
|
+
if (itemIndex % batchSize === 0) {
|
|
66
|
+
await (0, n8n_workflow_1.sleep)(batchInterval);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const thisArgs = new node_execution_context_1.ExecuteSingleContext(this.workflow, this.node, this.additionalData, this.mode, this.runExecutionData, runIndex, this.connectionInputData, inputData, itemIndex, executeData, abortSignal);
|
|
70
|
+
itemContext.push({
|
|
71
|
+
thisArgs,
|
|
72
|
+
requestData: {
|
|
73
|
+
options: {
|
|
74
|
+
qs: {},
|
|
75
|
+
body: {},
|
|
76
|
+
headers: {},
|
|
77
|
+
},
|
|
78
|
+
preSend: [],
|
|
79
|
+
postReceive: [],
|
|
80
|
+
requestOperations: {},
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
const { proxy, timeout, allowUnauthorizedCerts } = itemContext[itemIndex].thisArgs.getNodeParameter('requestOptions', 0, {});
|
|
84
|
+
if (nodeType.description.requestOperations) {
|
|
85
|
+
itemContext[itemIndex].requestData.requestOperations = {
|
|
86
|
+
...nodeType.description.requestOperations,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
if (nodeType.description.requestDefaults) {
|
|
90
|
+
for (const key of Object.keys(nodeType.description.requestDefaults)) {
|
|
91
|
+
let value = nodeType.description.requestDefaults[key];
|
|
92
|
+
value = this.getParameterValue(value, itemIndex, runIndex, executeData, { $credentials: credentials, $version: this.node.typeVersion }, false);
|
|
93
|
+
itemContext[itemIndex].requestData.options[key] = value;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
for (const property of nodeType.description.properties) {
|
|
97
|
+
let value = (0, get_1.default)(this.node.parameters, property.name, []);
|
|
98
|
+
value = this.getParameterValue(value, itemIndex, runIndex, executeData, { $credentials: credentials, $version: this.node.typeVersion }, false);
|
|
99
|
+
const tempOptions = this.getRequestOptionsFromParameters(itemContext[itemIndex].thisArgs, property, itemIndex, runIndex, '', { $credentials: credentials, $value: value, $version: this.node.typeVersion });
|
|
100
|
+
this.mergeOptions(itemContext[itemIndex].requestData, tempOptions);
|
|
101
|
+
}
|
|
102
|
+
if (proxy) {
|
|
103
|
+
const proxyParsed = node_url_1.default.parse(proxy);
|
|
104
|
+
const proxyProperties = ['host', 'port'];
|
|
105
|
+
for (const property of proxyProperties) {
|
|
106
|
+
if (!(property in proxyParsed) ||
|
|
107
|
+
proxyParsed[property] === null) {
|
|
108
|
+
throw new n8n_workflow_1.NodeOperationError(this.node, 'The proxy is not value', {
|
|
109
|
+
runIndex,
|
|
110
|
+
itemIndex,
|
|
111
|
+
description: `The proxy URL does not contain a valid value for "${property}"`,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
itemContext[itemIndex].requestData.options.proxy = {
|
|
116
|
+
host: proxyParsed.hostname,
|
|
117
|
+
port: parseInt(proxyParsed.port),
|
|
118
|
+
protocol: proxyParsed.protocol?.replace(/:$/, '') || undefined,
|
|
119
|
+
};
|
|
120
|
+
if (proxyParsed.auth) {
|
|
121
|
+
const [username, password] = proxyParsed.auth.split(':');
|
|
122
|
+
itemContext[itemIndex].requestData.options.proxy.auth = {
|
|
123
|
+
username,
|
|
124
|
+
password,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (allowUnauthorizedCerts) {
|
|
129
|
+
itemContext[itemIndex].requestData.options.skipSslCertificateValidation =
|
|
130
|
+
allowUnauthorizedCerts;
|
|
131
|
+
}
|
|
132
|
+
if (timeout) {
|
|
133
|
+
itemContext[itemIndex].requestData.options.timeout = timeout;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
itemContext[itemIndex].requestData.options.timeout = 300_000;
|
|
137
|
+
}
|
|
138
|
+
requestPromises.push(this.makeRoutingRequest(itemContext[itemIndex].requestData, itemContext[itemIndex].thisArgs, itemIndex, runIndex, credentialDescription?.name, itemContext[itemIndex].requestData.requestOperations, credentialsDecrypted));
|
|
139
|
+
}
|
|
140
|
+
const promisesResponses = await Promise.allSettled(requestPromises);
|
|
141
|
+
let responseData;
|
|
142
|
+
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
|
143
|
+
responseData = promisesResponses.shift();
|
|
144
|
+
if (responseData.status !== 'fulfilled') {
|
|
145
|
+
if (responseData.reason.statusCode === 429) {
|
|
146
|
+
responseData.reason.message =
|
|
147
|
+
"Try spacing your requests out using the batching settings under 'Options'";
|
|
148
|
+
}
|
|
149
|
+
const error = responseData.reason;
|
|
150
|
+
if (itemContext[itemIndex].thisArgs?.continueOnFail()) {
|
|
151
|
+
returnData.push({ json: {}, error: error });
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (error instanceof n8n_workflow_1.NodeApiError) {
|
|
155
|
+
(0, set_1.default)(error, 'context.itemIndex', itemIndex);
|
|
156
|
+
(0, set_1.default)(error, 'context.runIndex', runIndex);
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
throw new n8n_workflow_1.NodeApiError(this.node, error, {
|
|
160
|
+
runIndex,
|
|
161
|
+
itemIndex,
|
|
162
|
+
message: error?.message,
|
|
163
|
+
description: error?.description,
|
|
164
|
+
httpCode: error.isAxiosError && error.response ? String(error.response?.status) : 'none',
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
if (itemContext[itemIndex].requestData.maxResults) {
|
|
168
|
+
responseData.value.splice(itemContext[itemIndex].requestData.maxResults);
|
|
169
|
+
}
|
|
170
|
+
returnData.push(...responseData.value);
|
|
171
|
+
}
|
|
172
|
+
return [returnData];
|
|
173
|
+
}
|
|
174
|
+
mergeOptions(destinationOptions, sourceOptions) {
|
|
175
|
+
if (sourceOptions) {
|
|
176
|
+
destinationOptions.paginate = destinationOptions.paginate ?? sourceOptions.paginate;
|
|
177
|
+
destinationOptions.maxResults = sourceOptions.maxResults
|
|
178
|
+
? sourceOptions.maxResults
|
|
179
|
+
: destinationOptions.maxResults;
|
|
180
|
+
(0, merge_1.default)(destinationOptions.options, sourceOptions.options);
|
|
181
|
+
destinationOptions.preSend.push(...sourceOptions.preSend);
|
|
182
|
+
destinationOptions.postReceive.push(...sourceOptions.postReceive);
|
|
183
|
+
if (sourceOptions.requestOperations && destinationOptions.requestOperations) {
|
|
184
|
+
destinationOptions.requestOperations = Object.assign(destinationOptions.requestOperations, sourceOptions.requestOperations);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
async runPostReceiveAction(executeSingleFunctions, action, inputData, responseData, parameterValue, itemIndex, runIndex) {
|
|
189
|
+
if (typeof action === 'function') {
|
|
190
|
+
return await action.call(executeSingleFunctions, inputData, responseData);
|
|
191
|
+
}
|
|
192
|
+
if (action.type === 'rootProperty') {
|
|
193
|
+
try {
|
|
194
|
+
return inputData.flatMap((item) => {
|
|
195
|
+
let itemContent = (0, get_1.default)(item.json, action.properties.property);
|
|
196
|
+
if (!Array.isArray(itemContent)) {
|
|
197
|
+
itemContent = [itemContent];
|
|
198
|
+
}
|
|
199
|
+
return itemContent.map((json) => {
|
|
200
|
+
return {
|
|
201
|
+
json,
|
|
202
|
+
};
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
throw new n8n_workflow_1.NodeOperationError(this.node, error, {
|
|
208
|
+
runIndex,
|
|
209
|
+
itemIndex,
|
|
210
|
+
description: `The rootProperty "${action.properties.property}" could not be found on item.`,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (action.type === 'filter') {
|
|
215
|
+
const passValue = action.properties.pass;
|
|
216
|
+
inputData = inputData.filter((item) => {
|
|
217
|
+
return this.getParameterValue(passValue, itemIndex, runIndex, executeSingleFunctions.getExecuteData(), {
|
|
218
|
+
$response: responseData,
|
|
219
|
+
$responseItem: item.json,
|
|
220
|
+
$value: parameterValue,
|
|
221
|
+
$version: this.node.typeVersion,
|
|
222
|
+
}, false);
|
|
223
|
+
});
|
|
224
|
+
return inputData;
|
|
225
|
+
}
|
|
226
|
+
if (action.type === 'limit') {
|
|
227
|
+
const maxResults = this.getParameterValue(action.properties.maxResults, itemIndex, runIndex, executeSingleFunctions.getExecuteData(), { $response: responseData, $value: parameterValue, $version: this.node.typeVersion }, false);
|
|
228
|
+
return inputData.slice(0, parseInt(maxResults, 10));
|
|
229
|
+
}
|
|
230
|
+
if (action.type === 'set') {
|
|
231
|
+
const { value } = action.properties;
|
|
232
|
+
return [
|
|
233
|
+
{
|
|
234
|
+
json: this.getParameterValue(value, itemIndex, runIndex, executeSingleFunctions.getExecuteData(), { $response: responseData, $value: parameterValue, $version: this.node.typeVersion }, false),
|
|
235
|
+
},
|
|
236
|
+
];
|
|
237
|
+
}
|
|
238
|
+
if (action.type === 'sort') {
|
|
239
|
+
const sortKey = action.properties.key;
|
|
240
|
+
inputData.sort((a, b) => {
|
|
241
|
+
const aSortValue = a.json[sortKey]?.toString().toLowerCase() ?? '';
|
|
242
|
+
const bSortValue = b.json[sortKey]?.toString().toLowerCase() ?? '';
|
|
243
|
+
if (aSortValue < bSortValue) {
|
|
244
|
+
return -1;
|
|
245
|
+
}
|
|
246
|
+
if (aSortValue > bSortValue) {
|
|
247
|
+
return 1;
|
|
248
|
+
}
|
|
249
|
+
return 0;
|
|
250
|
+
});
|
|
251
|
+
return inputData;
|
|
252
|
+
}
|
|
253
|
+
if (action.type === 'setKeyValue') {
|
|
254
|
+
const returnData = [];
|
|
255
|
+
inputData.forEach((item) => {
|
|
256
|
+
const returnItem = {};
|
|
257
|
+
for (const key of Object.keys(action.properties)) {
|
|
258
|
+
let propertyValue = action.properties[key];
|
|
259
|
+
propertyValue = this.getParameterValue(propertyValue, itemIndex, runIndex, executeSingleFunctions.getExecuteData(), {
|
|
260
|
+
$response: responseData,
|
|
261
|
+
$responseItem: item.json,
|
|
262
|
+
$value: parameterValue,
|
|
263
|
+
$version: this.node.typeVersion,
|
|
264
|
+
}, false);
|
|
265
|
+
returnItem[key] = propertyValue;
|
|
266
|
+
}
|
|
267
|
+
returnData.push({ json: returnItem });
|
|
268
|
+
});
|
|
269
|
+
return returnData;
|
|
270
|
+
}
|
|
271
|
+
if (action.type === 'binaryData') {
|
|
272
|
+
const body = (responseData.body = Buffer.from(responseData.body));
|
|
273
|
+
let { destinationProperty } = action.properties;
|
|
274
|
+
destinationProperty = this.getParameterValue(destinationProperty, itemIndex, runIndex, executeSingleFunctions.getExecuteData(), { $response: responseData, $value: parameterValue, $version: this.node.typeVersion }, false);
|
|
275
|
+
const binaryData = await executeSingleFunctions.helpers.prepareBinaryData(body);
|
|
276
|
+
return inputData.map((item) => {
|
|
277
|
+
if (typeof item.json === 'string') {
|
|
278
|
+
item.json = {};
|
|
279
|
+
}
|
|
280
|
+
item.binary = {
|
|
281
|
+
[destinationProperty]: binaryData,
|
|
282
|
+
};
|
|
283
|
+
return item;
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
return [];
|
|
287
|
+
}
|
|
288
|
+
async postProcessResponseData(executeSingleFunctions, responseData, requestData, itemIndex, runIndex) {
|
|
289
|
+
let returnData = [
|
|
290
|
+
{
|
|
291
|
+
json: responseData.body,
|
|
292
|
+
},
|
|
293
|
+
];
|
|
294
|
+
if (requestData.postReceive.length) {
|
|
295
|
+
for (const postReceiveMethod of requestData.postReceive) {
|
|
296
|
+
for (const action of postReceiveMethod.actions) {
|
|
297
|
+
returnData = await this.runPostReceiveAction(executeSingleFunctions, action, returnData, responseData, postReceiveMethod.data.parameterValue, itemIndex, runIndex);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
if (Array.isArray(responseData.body)) {
|
|
303
|
+
returnData = responseData.body.map((json) => {
|
|
304
|
+
return {
|
|
305
|
+
json,
|
|
306
|
+
};
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
returnData[0].json = responseData.body;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return returnData;
|
|
314
|
+
}
|
|
315
|
+
async rawRoutingRequest(executeSingleFunctions, requestData, credentialType, credentialsDecrypted) {
|
|
316
|
+
let responseData;
|
|
317
|
+
requestData.options.returnFullResponse = true;
|
|
318
|
+
if (credentialType) {
|
|
319
|
+
responseData = (await executeSingleFunctions.helpers.httpRequestWithAuthentication.call(executeSingleFunctions, credentialType, requestData.options, { credentialsDecrypted }));
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
responseData = (await executeSingleFunctions.helpers.httpRequest(requestData.options));
|
|
323
|
+
}
|
|
324
|
+
return responseData;
|
|
325
|
+
}
|
|
326
|
+
async makeRoutingRequest(requestData, executeSingleFunctions, itemIndex, runIndex, credentialType, requestOperations, credentialsDecrypted) {
|
|
327
|
+
let responseData;
|
|
328
|
+
for (const preSendMethod of requestData.preSend) {
|
|
329
|
+
requestData.options = await preSendMethod.call(executeSingleFunctions, requestData.options);
|
|
330
|
+
}
|
|
331
|
+
const makeRoutingRequest = async (requestOptions) => {
|
|
332
|
+
return await this.rawRoutingRequest(executeSingleFunctions, requestOptions, credentialType, credentialsDecrypted).then(async (data) => await this.postProcessResponseData(executeSingleFunctions, data, requestData, itemIndex, runIndex));
|
|
333
|
+
};
|
|
334
|
+
const executePaginationFunctions = Object.create(executeSingleFunctions, {
|
|
335
|
+
makeRoutingRequest: { value: makeRoutingRequest },
|
|
336
|
+
});
|
|
337
|
+
if (requestData.paginate && requestOperations?.pagination) {
|
|
338
|
+
if (typeof requestOperations.pagination === 'function') {
|
|
339
|
+
responseData = await requestOperations.pagination.call(executePaginationFunctions, requestData);
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
responseData = [];
|
|
343
|
+
if (!requestData.options.qs) {
|
|
344
|
+
requestData.options.qs = {};
|
|
345
|
+
}
|
|
346
|
+
if (requestOperations.pagination.type === 'generic') {
|
|
347
|
+
let tempResponseData;
|
|
348
|
+
let tempResponseItems;
|
|
349
|
+
let makeAdditionalRequest;
|
|
350
|
+
let paginateRequestData;
|
|
351
|
+
const additionalKeys = {
|
|
352
|
+
$request: requestData.options,
|
|
353
|
+
$response: {},
|
|
354
|
+
$version: this.node.typeVersion,
|
|
355
|
+
};
|
|
356
|
+
do {
|
|
357
|
+
additionalKeys.$request = requestData.options;
|
|
358
|
+
paginateRequestData = this.getParameterValue(requestOperations.pagination.properties.request, itemIndex, runIndex, executeSingleFunctions.getExecuteData(), additionalKeys, false);
|
|
359
|
+
tempResponseData = await this.rawRoutingRequest(executeSingleFunctions, { ...requestData, options: { ...requestData.options, ...paginateRequestData } }, credentialType, credentialsDecrypted);
|
|
360
|
+
additionalKeys.$response = tempResponseData;
|
|
361
|
+
tempResponseItems = await this.postProcessResponseData(executeSingleFunctions, tempResponseData, requestData, itemIndex, runIndex);
|
|
362
|
+
responseData.push(...tempResponseItems);
|
|
363
|
+
makeAdditionalRequest = this.getParameterValue(requestOperations.pagination.properties.continue, itemIndex, runIndex, executeSingleFunctions.getExecuteData(), additionalKeys, false);
|
|
364
|
+
} while (makeAdditionalRequest);
|
|
365
|
+
}
|
|
366
|
+
else if (requestOperations.pagination.type === 'offset') {
|
|
367
|
+
const { properties } = requestOperations.pagination;
|
|
368
|
+
const optionsType = properties.type === 'body' ? 'body' : 'qs';
|
|
369
|
+
if (properties.type === 'body' && !requestData.options.body) {
|
|
370
|
+
requestData.options.body = {};
|
|
371
|
+
}
|
|
372
|
+
requestData.options[optionsType][properties.limitParameter] =
|
|
373
|
+
properties.pageSize;
|
|
374
|
+
requestData.options[optionsType][properties.offsetParameter] = 0;
|
|
375
|
+
let tempResponseData;
|
|
376
|
+
do {
|
|
377
|
+
if (requestData?.maxResults) {
|
|
378
|
+
const resultsMissing = requestData?.maxResults - responseData.length;
|
|
379
|
+
if (resultsMissing < 1) {
|
|
380
|
+
break;
|
|
381
|
+
}
|
|
382
|
+
requestData.options[optionsType][properties.limitParameter] =
|
|
383
|
+
Math.min(properties.pageSize, resultsMissing);
|
|
384
|
+
}
|
|
385
|
+
tempResponseData = await this.rawRoutingRequest(executeSingleFunctions, requestData, credentialType, credentialsDecrypted).then(async (data) => await this.postProcessResponseData(executeSingleFunctions, data, requestData, itemIndex, runIndex));
|
|
386
|
+
requestData.options[optionsType][properties.offsetParameter] =
|
|
387
|
+
requestData.options[optionsType][properties.offsetParameter] + properties.pageSize;
|
|
388
|
+
if (properties.rootProperty) {
|
|
389
|
+
const tempResponseValue = (0, get_1.default)(tempResponseData[0].json, properties.rootProperty);
|
|
390
|
+
if (tempResponseValue === undefined) {
|
|
391
|
+
throw new n8n_workflow_1.NodeOperationError(this.node, `The rootProperty "${properties.rootProperty}" could not be found on item.`, { runIndex, itemIndex });
|
|
392
|
+
}
|
|
393
|
+
tempResponseData = tempResponseValue.map((item) => {
|
|
394
|
+
return {
|
|
395
|
+
json: item,
|
|
396
|
+
};
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
responseData.push(...tempResponseData);
|
|
400
|
+
} while (tempResponseData.length && tempResponseData.length === properties.pageSize);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
responseData = await this.rawRoutingRequest(executeSingleFunctions, requestData, credentialType, credentialsDecrypted).then(async (data) => await this.postProcessResponseData(executeSingleFunctions, data, requestData, itemIndex, runIndex));
|
|
406
|
+
}
|
|
407
|
+
return responseData;
|
|
408
|
+
}
|
|
409
|
+
getParameterValue(parameterValue, itemIndex, runIndex, executeData, additionalKeys, returnObjectAsString = false) {
|
|
410
|
+
if (typeof parameterValue === 'object' ||
|
|
411
|
+
(typeof parameterValue === 'string' && parameterValue.charAt(0) === '=')) {
|
|
412
|
+
return this.workflow.expression.getParameterValue(parameterValue, this.runExecutionData ?? null, runIndex, itemIndex, this.node.name, this.connectionInputData, this.mode, additionalKeys ?? {}, executeData, returnObjectAsString);
|
|
413
|
+
}
|
|
414
|
+
return parameterValue;
|
|
415
|
+
}
|
|
416
|
+
getRequestOptionsFromParameters(executeSingleFunctions, nodeProperties, itemIndex, runIndex, path, additionalKeys) {
|
|
417
|
+
const returnData = {
|
|
418
|
+
options: {
|
|
419
|
+
qs: {},
|
|
420
|
+
body: {},
|
|
421
|
+
headers: {},
|
|
422
|
+
},
|
|
423
|
+
preSend: [],
|
|
424
|
+
postReceive: [],
|
|
425
|
+
requestOperations: {},
|
|
426
|
+
};
|
|
427
|
+
let basePath = path ? `${path}.` : '';
|
|
428
|
+
if (!n8n_workflow_1.NodeHelpers.displayParameter(this.node.parameters, nodeProperties, this.node, this.node.parameters)) {
|
|
429
|
+
return undefined;
|
|
430
|
+
}
|
|
431
|
+
if (nodeProperties.routing) {
|
|
432
|
+
let parameterValue;
|
|
433
|
+
if (basePath + nodeProperties.name && 'type' in nodeProperties) {
|
|
434
|
+
const shouldExtractValue = nodeProperties.extractValue !== undefined || nodeProperties.type === 'resourceLocator';
|
|
435
|
+
parameterValue = executeSingleFunctions.getNodeParameter(basePath + nodeProperties.name, undefined, { extractValue: shouldExtractValue });
|
|
436
|
+
}
|
|
437
|
+
if (nodeProperties.routing.operations) {
|
|
438
|
+
returnData.requestOperations = { ...nodeProperties.routing.operations };
|
|
439
|
+
}
|
|
440
|
+
if (nodeProperties.routing.request) {
|
|
441
|
+
for (const key of Object.keys(nodeProperties.routing.request)) {
|
|
442
|
+
let propertyValue = nodeProperties.routing.request[key];
|
|
443
|
+
propertyValue = this.getParameterValue(propertyValue, itemIndex, runIndex, executeSingleFunctions.getExecuteData(), { ...additionalKeys, $value: parameterValue }, false);
|
|
444
|
+
returnData.options[key] = propertyValue;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
if (nodeProperties.routing.send) {
|
|
448
|
+
let propertyName = nodeProperties.routing.send.property;
|
|
449
|
+
if (propertyName !== undefined) {
|
|
450
|
+
propertyName = this.getParameterValue(propertyName, itemIndex, runIndex, executeSingleFunctions.getExecuteData(), additionalKeys, true);
|
|
451
|
+
let value = parameterValue;
|
|
452
|
+
if (nodeProperties.routing.send.value) {
|
|
453
|
+
const valueString = nodeProperties.routing.send.value;
|
|
454
|
+
value = this.getParameterValue(valueString, itemIndex, runIndex, executeSingleFunctions.getExecuteData(), { ...additionalKeys, $value: value }, false);
|
|
455
|
+
}
|
|
456
|
+
if (nodeProperties.routing.send.type === 'body') {
|
|
457
|
+
if (nodeProperties.routing.send.propertyInDotNotation === false) {
|
|
458
|
+
returnData.options.body[propertyName] = value;
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
(0, set_1.default)(returnData.options.body, propertyName, value);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
else {
|
|
465
|
+
if (nodeProperties.routing.send.propertyInDotNotation === false) {
|
|
466
|
+
returnData.options.qs[propertyName] = value;
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
(0, set_1.default)(returnData.options.qs, propertyName, value);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
if (nodeProperties.routing.send.paginate !== undefined) {
|
|
474
|
+
let paginateValue = nodeProperties.routing.send.paginate;
|
|
475
|
+
if (typeof paginateValue === 'string' && paginateValue.charAt(0) === '=') {
|
|
476
|
+
paginateValue = this.getParameterValue(paginateValue, itemIndex, runIndex, executeSingleFunctions.getExecuteData(), { ...additionalKeys, $value: parameterValue }, true);
|
|
477
|
+
}
|
|
478
|
+
returnData.paginate = !!paginateValue;
|
|
479
|
+
}
|
|
480
|
+
if (nodeProperties.routing.send.preSend) {
|
|
481
|
+
returnData.preSend.push(...nodeProperties.routing.send.preSend);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
if (nodeProperties.routing.output) {
|
|
485
|
+
if (nodeProperties.routing.output.maxResults !== undefined) {
|
|
486
|
+
let maxResultsValue = nodeProperties.routing.output.maxResults;
|
|
487
|
+
if (typeof maxResultsValue === 'string' && maxResultsValue.charAt(0) === '=') {
|
|
488
|
+
maxResultsValue = this.getParameterValue(maxResultsValue, itemIndex, runIndex, executeSingleFunctions.getExecuteData(), { ...additionalKeys, $value: parameterValue }, true);
|
|
489
|
+
}
|
|
490
|
+
returnData.maxResults = maxResultsValue;
|
|
491
|
+
}
|
|
492
|
+
if (nodeProperties.routing.output.postReceive) {
|
|
493
|
+
const postReceiveActions = nodeProperties.routing.output.postReceive.filter((action) => {
|
|
494
|
+
if (typeof action === 'function') {
|
|
495
|
+
return true;
|
|
496
|
+
}
|
|
497
|
+
if (typeof action.enabled === 'string' && action.enabled.charAt(0) === '=') {
|
|
498
|
+
return this.getParameterValue(action.enabled, itemIndex, runIndex, executeSingleFunctions.getExecuteData(), { ...additionalKeys, $value: parameterValue }, true);
|
|
499
|
+
}
|
|
500
|
+
return action.enabled !== false;
|
|
501
|
+
});
|
|
502
|
+
if (postReceiveActions.length) {
|
|
503
|
+
returnData.postReceive.push({
|
|
504
|
+
data: {
|
|
505
|
+
parameterValue,
|
|
506
|
+
},
|
|
507
|
+
actions: postReceiveActions,
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
if (!Object.prototype.hasOwnProperty.call(nodeProperties, 'options')) {
|
|
514
|
+
return returnData;
|
|
515
|
+
}
|
|
516
|
+
nodeProperties = nodeProperties;
|
|
517
|
+
let value;
|
|
518
|
+
if (nodeProperties.type === 'options') {
|
|
519
|
+
const optionValue = n8n_workflow_1.NodeHelpers.getParameterValueByPath(this.node.parameters, nodeProperties.name, basePath.slice(0, -1));
|
|
520
|
+
const selectedOption = nodeProperties.options.filter((option) => option.value === optionValue);
|
|
521
|
+
if (selectedOption.length) {
|
|
522
|
+
const tempOptions = this.getRequestOptionsFromParameters(executeSingleFunctions, selectedOption[0], itemIndex, runIndex, `${basePath}${nodeProperties.name}`, { $value: optionValue, $version: this.node.typeVersion });
|
|
523
|
+
this.mergeOptions(returnData, tempOptions);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
else if (nodeProperties.type === 'collection') {
|
|
527
|
+
value = n8n_workflow_1.NodeHelpers.getParameterValueByPath(this.node.parameters, nodeProperties.name, basePath.slice(0, -1));
|
|
528
|
+
for (const propertyOption of nodeProperties.options) {
|
|
529
|
+
if (Object.keys(value).includes(propertyOption.name) &&
|
|
530
|
+
propertyOption.type !== undefined) {
|
|
531
|
+
const tempOptions = this.getRequestOptionsFromParameters(executeSingleFunctions, propertyOption, itemIndex, runIndex, `${basePath}${nodeProperties.name}`, { $version: this.node.typeVersion });
|
|
532
|
+
this.mergeOptions(returnData, tempOptions);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
else if (nodeProperties.type === 'fixedCollection') {
|
|
537
|
+
basePath = `${basePath}${nodeProperties.name}.`;
|
|
538
|
+
for (const propertyOptions of nodeProperties.options) {
|
|
539
|
+
value = n8n_workflow_1.NodeHelpers.getParameterValueByPath(this.node.parameters, propertyOptions.name, basePath.slice(0, -1));
|
|
540
|
+
if (value === undefined) {
|
|
541
|
+
continue;
|
|
542
|
+
}
|
|
543
|
+
if (!Array.isArray(value)) {
|
|
544
|
+
value = [value];
|
|
545
|
+
}
|
|
546
|
+
value = this.getParameterValue(value, itemIndex, runIndex, executeSingleFunctions.getExecuteData(), { ...additionalKeys }, false);
|
|
547
|
+
const loopBasePath = `${basePath}${propertyOptions.name}`;
|
|
548
|
+
for (let i = 0; i < value.length; i++) {
|
|
549
|
+
for (const option of propertyOptions.values) {
|
|
550
|
+
const tempOptions = this.getRequestOptionsFromParameters(executeSingleFunctions, option, itemIndex, runIndex, nodeProperties.typeOptions?.multipleValues ? `${loopBasePath}[${i}]` : loopBasePath, { ...(additionalKeys || {}), $index: i, $parent: value[i] });
|
|
551
|
+
this.mergeOptions(returnData, tempOptions);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
return returnData;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
exports.RoutingNode = RoutingNode;
|
|
560
|
+
//# sourceMappingURL=RoutingNode.js.map
|