n8n-core 1.69.0 → 1.71.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/dist/BinaryData/BinaryData.service.js +17 -7
- package/dist/BinaryData/BinaryData.service.js.map +1 -1
- package/dist/CreateNodeAsTool.d.ts +6 -3
- package/dist/CreateNodeAsTool.js.map +1 -1
- package/dist/DirectoryLoader.js +17 -7
- package/dist/DirectoryLoader.js.map +1 -1
- package/dist/NodeExecuteFunctions.d.ts +18 -17
- package/dist/NodeExecuteFunctions.js +39 -759
- package/dist/NodeExecuteFunctions.js.map +1 -1
- package/dist/PartialExecutionUtils/DirectedGraph.d.ts +1 -0
- package/dist/PartialExecutionUtils/DirectedGraph.js +23 -8
- package/dist/PartialExecutionUtils/DirectedGraph.js.map +1 -1
- package/dist/PartialExecutionUtils/filterDisabledNodes.d.ts +2 -0
- package/dist/PartialExecutionUtils/filterDisabledNodes.js +16 -0
- package/dist/PartialExecutionUtils/filterDisabledNodes.js.map +1 -0
- package/dist/PartialExecutionUtils/findStartNodes.d.ts +2 -2
- package/dist/PartialExecutionUtils/findStartNodes.js +2 -2
- package/dist/PartialExecutionUtils/findStartNodes.js.map +1 -1
- package/dist/PartialExecutionUtils/findSubgraph.js +1 -8
- package/dist/PartialExecutionUtils/findSubgraph.js.map +1 -1
- package/dist/PartialExecutionUtils/findTriggerForPartialExecution.js +17 -7
- package/dist/PartialExecutionUtils/findTriggerForPartialExecution.js.map +1 -1
- package/dist/PartialExecutionUtils/getIncomingData.js +17 -7
- package/dist/PartialExecutionUtils/getIncomingData.js.map +1 -1
- package/dist/PartialExecutionUtils/handleCycles.js +17 -7
- package/dist/PartialExecutionUtils/handleCycles.js.map +1 -1
- package/dist/PartialExecutionUtils/index.d.ts +1 -0
- package/dist/PartialExecutionUtils/index.js +3 -1
- package/dist/PartialExecutionUtils/index.js.map +1 -1
- package/dist/PartialExecutionUtils/recreateNodeExecutionStack.js +17 -7
- package/dist/PartialExecutionUtils/recreateNodeExecutionStack.js.map +1 -1
- package/dist/WorkflowExecute.d.ts +1 -1
- package/dist/WorkflowExecute.js +34 -16
- package/dist/WorkflowExecute.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/data-deduplication-service.js +17 -7
- package/dist/data-deduplication-service.js.map +1 -1
- package/dist/index.js +17 -7
- package/dist/index.js.map +1 -1
- package/dist/node-execution-context/base-execute-context.d.ts +29 -0
- package/dist/node-execution-context/base-execute-context.js +120 -0
- package/dist/node-execution-context/base-execute-context.js.map +1 -0
- package/dist/node-execution-context/execute-context.d.ts +20 -0
- package/dist/node-execution-context/execute-context.js +92 -0
- package/dist/node-execution-context/execute-context.js.map +1 -0
- package/dist/node-execution-context/execute-single-context.d.ts +5 -19
- package/dist/node-execution-context/execute-single-context.js +8 -56
- package/dist/node-execution-context/execute-single-context.js.map +1 -1
- package/dist/node-execution-context/helpers/binary-helpers.d.ts +0 -0
- package/dist/node-execution-context/helpers/binary-helpers.js +2 -0
- package/dist/node-execution-context/helpers/binary-helpers.js.map +1 -0
- package/dist/node-execution-context/hook-context.d.ts +1 -2
- package/dist/node-execution-context/hook-context.js +2 -9
- package/dist/node-execution-context/hook-context.js.map +1 -1
- package/dist/node-execution-context/index.d.ts +3 -0
- package/dist/node-execution-context/index.js +7 -1
- package/dist/node-execution-context/index.js.map +1 -1
- package/dist/node-execution-context/load-options-context.d.ts +0 -1
- package/dist/node-execution-context/load-options-context.js +1 -8
- package/dist/node-execution-context/load-options-context.js.map +1 -1
- package/dist/node-execution-context/node-execution-context.d.ts +11 -2
- package/dist/node-execution-context/node-execution-context.js +115 -1
- package/dist/node-execution-context/node-execution-context.js.map +1 -1
- package/dist/node-execution-context/poll-context.d.ts +1 -2
- package/dist/node-execution-context/poll-context.js +1 -8
- package/dist/node-execution-context/poll-context.js.map +1 -1
- package/dist/node-execution-context/supply-data-context.d.ts +14 -0
- package/dist/node-execution-context/supply-data-context.js +65 -0
- package/dist/node-execution-context/supply-data-context.js.map +1 -0
- package/dist/node-execution-context/trigger-context.d.ts +1 -2
- package/dist/node-execution-context/trigger-context.js +1 -8
- package/dist/node-execution-context/trigger-context.js.map +1 -1
- package/dist/node-execution-context/utils.d.ts +11 -0
- package/dist/node-execution-context/utils.js +275 -0
- package/dist/node-execution-context/utils.js.map +1 -0
- package/dist/node-execution-context/webhook-context.d.ts +1 -4
- package/dist/node-execution-context/webhook-context.js +12 -34
- package/dist/node-execution-context/webhook-context.js.map +1 -1
- package/package.json +5 -4
|
@@ -15,19 +15,31 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.getCheckProcessedHelperFunctions = exports.getBinaryHelperFunctions = exports.getNodeHelperFunctions = exports.getFileSystemHelperFunctions = exports.getSchedulingFunctions = exports.getSSHTunnelFunctions = exports.getRequestHelperFunctions = exports.
|
|
39
|
+
exports.getCheckProcessedHelperFunctions = exports.getBinaryHelperFunctions = exports.getNodeHelperFunctions = exports.getFileSystemHelperFunctions = exports.getSchedulingFunctions = exports.getSSHTunnelFunctions = exports.getRequestHelperFunctions = exports.addExecutionDataFunctions = exports.removeEmptyBody = exports.validateUrl = void 0;
|
|
30
40
|
exports.parseRequestObject = parseRequestObject;
|
|
41
|
+
exports.parseContentType = parseContentType;
|
|
42
|
+
exports.parseContentDisposition = parseContentDisposition;
|
|
31
43
|
exports.parseIncomingMessage = parseIncomingMessage;
|
|
32
44
|
exports.binaryToString = binaryToString;
|
|
33
45
|
exports.proxyRequestToAxios = proxyRequestToAxios;
|
|
@@ -53,12 +65,6 @@ exports.returnJsonArray = returnJsonArray;
|
|
|
53
65
|
exports.constructExecutionMetaData = constructExecutionMetaData;
|
|
54
66
|
exports.normalizeItems = normalizeItems;
|
|
55
67
|
exports.requestWithAuthentication = requestWithAuthentication;
|
|
56
|
-
exports.getAdditionalKeys = getAdditionalKeys;
|
|
57
|
-
exports.getCredentials = getCredentials;
|
|
58
|
-
exports.cleanupParameterData = cleanupParameterData;
|
|
59
|
-
exports.ensureType = ensureType;
|
|
60
|
-
exports.getNodeParameter = getNodeParameter;
|
|
61
|
-
exports.continueOnFail = continueOnFail;
|
|
62
68
|
exports.getNodeWebhookUrl = getNodeWebhookUrl;
|
|
63
69
|
exports.getWebhookDescription = getWebhookDescription;
|
|
64
70
|
exports.getInputConnectionData = getInputConnectionData;
|
|
@@ -67,7 +73,6 @@ exports.copyInputItems = copyInputItems;
|
|
|
67
73
|
exports.getExecutePollFunctions = getExecutePollFunctions;
|
|
68
74
|
exports.getExecuteTriggerFunctions = getExecuteTriggerFunctions;
|
|
69
75
|
exports.getExecuteFunctions = getExecuteFunctions;
|
|
70
|
-
exports.getSupplyDataFunctions = getSupplyDataFunctions;
|
|
71
76
|
exports.getExecuteSingleFunctions = getExecuteSingleFunctions;
|
|
72
77
|
exports.getCredentialTestFunctions = getCredentialTestFunctions;
|
|
73
78
|
exports.getExecuteHookFunctions = getExecuteHookFunctions;
|
|
@@ -81,11 +86,11 @@ const fs_1 = require("fs");
|
|
|
81
86
|
const promises_1 = require("fs/promises");
|
|
82
87
|
const http_1 = require("http");
|
|
83
88
|
const https_1 = require("https");
|
|
89
|
+
const iconv_lite_1 = __importDefault(require("iconv-lite"));
|
|
84
90
|
const get_1 = __importDefault(require("lodash/get"));
|
|
85
91
|
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
86
92
|
const merge_1 = __importDefault(require("lodash/merge"));
|
|
87
93
|
const pick_1 = __importDefault(require("lodash/pick"));
|
|
88
|
-
const luxon_1 = require("luxon");
|
|
89
94
|
const mime_types_1 = require("mime-types");
|
|
90
95
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
91
96
|
const oauth_1_0a_1 = __importDefault(require("oauth-1.0a"));
|
|
@@ -94,18 +99,14 @@ const qs_1 = require("qs");
|
|
|
94
99
|
const stream_1 = require("stream");
|
|
95
100
|
const typedi_1 = __importDefault(require("typedi"));
|
|
96
101
|
const url_1 = __importStar(require("url"));
|
|
97
|
-
const Agent_1 = require("./Agent");
|
|
98
102
|
const BinaryData_service_1 = require("./BinaryData/BinaryData.service");
|
|
99
103
|
const utils_1 = require("./BinaryData/utils");
|
|
100
104
|
const Constants_1 = require("./Constants");
|
|
101
105
|
const CreateNodeAsTool_1 = require("./CreateNodeAsTool");
|
|
102
106
|
const data_deduplication_service_1 = require("./data-deduplication-service");
|
|
103
|
-
const ExecutionMetadata_1 = require("./ExecutionMetadata");
|
|
104
|
-
const ExtractValue_1 = require("./ExtractValue");
|
|
105
107
|
const InstanceSettings_1 = require("./InstanceSettings");
|
|
106
108
|
const node_execution_context_1 = require("./node-execution-context");
|
|
107
109
|
const ScheduledTaskManager_1 = require("./ScheduledTaskManager");
|
|
108
|
-
const Secrets_1 = require("./Secrets");
|
|
109
110
|
const SSHClientsManager_1 = require("./SSHClientsManager");
|
|
110
111
|
axios_1.default.defaults.timeout = 300000;
|
|
111
112
|
axios_1.default.defaults.headers.post = {};
|
|
@@ -524,7 +525,11 @@ function digestAuthAxiosConfig(axiosConfig, response, auth) {
|
|
|
524
525
|
function parseHeaderParameters(parameters) {
|
|
525
526
|
return parameters.reduce((acc, param) => {
|
|
526
527
|
const [key, value] = param.split('=');
|
|
527
|
-
|
|
528
|
+
let decodedValue = decodeURIComponent(value).trim();
|
|
529
|
+
if (decodedValue.startsWith('"') && decodedValue.endsWith('"')) {
|
|
530
|
+
decodedValue = decodedValue.slice(1, -1);
|
|
531
|
+
}
|
|
532
|
+
acc[key.toLowerCase().trim()] = decodedValue;
|
|
528
533
|
return acc;
|
|
529
534
|
}, {});
|
|
530
535
|
}
|
|
@@ -538,16 +543,6 @@ function parseContentType(contentType) {
|
|
|
538
543
|
parameters: { charset: 'utf-8', ...parseHeaderParameters(parameters) },
|
|
539
544
|
};
|
|
540
545
|
}
|
|
541
|
-
function parseFileName(filename) {
|
|
542
|
-
if (filename?.startsWith('"') && filename?.endsWith('"')) {
|
|
543
|
-
return filename.slice(1, -1);
|
|
544
|
-
}
|
|
545
|
-
return filename;
|
|
546
|
-
}
|
|
547
|
-
function parseFileNameStar(filename) {
|
|
548
|
-
const [_encoding, _locale, content] = parseFileName(filename)?.split("'") ?? [];
|
|
549
|
-
return content;
|
|
550
|
-
}
|
|
551
546
|
function parseContentDisposition(contentDisposition) {
|
|
552
547
|
if (!contentDisposition) {
|
|
553
548
|
return null;
|
|
@@ -557,10 +552,13 @@ function parseContentDisposition(contentDisposition) {
|
|
|
557
552
|
}
|
|
558
553
|
const [type, ...parameters] = contentDisposition.split(';');
|
|
559
554
|
const parsedParameters = parseHeaderParameters(parameters);
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
555
|
+
let { filename } = parsedParameters;
|
|
556
|
+
const wildcard = parsedParameters['filename*'];
|
|
557
|
+
if (wildcard) {
|
|
558
|
+
const [_encoding, _locale, content] = wildcard?.split("'") ?? [];
|
|
559
|
+
filename = content;
|
|
560
|
+
}
|
|
561
|
+
return { type, filename };
|
|
564
562
|
}
|
|
565
563
|
function parseIncomingMessage(message) {
|
|
566
564
|
const contentType = parseContentType(message.headers['content-type']);
|
|
@@ -575,12 +573,12 @@ function parseIncomingMessage(message) {
|
|
|
575
573
|
}
|
|
576
574
|
}
|
|
577
575
|
async function binaryToString(body, encoding) {
|
|
578
|
-
const buffer = await (0, utils_1.binaryToBuffer)(body);
|
|
579
576
|
if (!encoding && body instanceof http_1.IncomingMessage) {
|
|
580
577
|
parseIncomingMessage(body);
|
|
581
578
|
encoding = body.encoding;
|
|
582
579
|
}
|
|
583
|
-
|
|
580
|
+
const buffer = await (0, utils_1.binaryToBuffer)(body);
|
|
581
|
+
return iconv_lite_1.default.decode(buffer, encoding ?? 'utf-8');
|
|
584
582
|
}
|
|
585
583
|
async function proxyRequestToAxios(workflow, additionalData, node, uriOrObject, options) {
|
|
586
584
|
let axiosConfig = {
|
|
@@ -1319,375 +1317,6 @@ async function requestWithAuthentication(credentialsType, requestOptions, workfl
|
|
|
1319
1317
|
}
|
|
1320
1318
|
}
|
|
1321
1319
|
}
|
|
1322
|
-
function getAdditionalKeys(additionalData, mode, runExecutionData, options) {
|
|
1323
|
-
const executionId = additionalData.executionId || Constants_1.PLACEHOLDER_EMPTY_EXECUTION_ID;
|
|
1324
|
-
const resumeUrl = `${additionalData.webhookWaitingBaseUrl}/${executionId}`;
|
|
1325
|
-
const resumeFormUrl = `${additionalData.formWaitingBaseUrl}/${executionId}`;
|
|
1326
|
-
return {
|
|
1327
|
-
$execution: {
|
|
1328
|
-
id: executionId,
|
|
1329
|
-
mode: mode === 'manual' ? 'test' : 'production',
|
|
1330
|
-
resumeUrl,
|
|
1331
|
-
resumeFormUrl,
|
|
1332
|
-
customData: runExecutionData
|
|
1333
|
-
? {
|
|
1334
|
-
set(key, value) {
|
|
1335
|
-
try {
|
|
1336
|
-
(0, ExecutionMetadata_1.setWorkflowExecutionMetadata)(runExecutionData, key, value);
|
|
1337
|
-
}
|
|
1338
|
-
catch (e) {
|
|
1339
|
-
if (mode === 'manual') {
|
|
1340
|
-
throw e;
|
|
1341
|
-
}
|
|
1342
|
-
n8n_workflow_1.LoggerProxy.debug(e.message);
|
|
1343
|
-
}
|
|
1344
|
-
},
|
|
1345
|
-
setAll(obj) {
|
|
1346
|
-
try {
|
|
1347
|
-
(0, ExecutionMetadata_1.setAllWorkflowExecutionMetadata)(runExecutionData, obj);
|
|
1348
|
-
}
|
|
1349
|
-
catch (e) {
|
|
1350
|
-
if (mode === 'manual') {
|
|
1351
|
-
throw e;
|
|
1352
|
-
}
|
|
1353
|
-
n8n_workflow_1.LoggerProxy.debug(e.message);
|
|
1354
|
-
}
|
|
1355
|
-
},
|
|
1356
|
-
get(key) {
|
|
1357
|
-
return (0, ExecutionMetadata_1.getWorkflowExecutionMetadata)(runExecutionData, key);
|
|
1358
|
-
},
|
|
1359
|
-
getAll() {
|
|
1360
|
-
return (0, ExecutionMetadata_1.getAllWorkflowExecutionMetadata)(runExecutionData);
|
|
1361
|
-
},
|
|
1362
|
-
}
|
|
1363
|
-
: undefined,
|
|
1364
|
-
},
|
|
1365
|
-
$vars: additionalData.variables,
|
|
1366
|
-
$secrets: options?.secretsEnabled ? (0, Secrets_1.getSecretsProxy)(additionalData) : undefined,
|
|
1367
|
-
$executionId: executionId,
|
|
1368
|
-
$resumeWebhookUrl: resumeUrl,
|
|
1369
|
-
};
|
|
1370
|
-
}
|
|
1371
|
-
async function getCredentials(workflow, node, type, additionalData, mode, executeData, runExecutionData, runIndex, connectionInputData, itemIndex) {
|
|
1372
|
-
const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
|
|
1373
|
-
if (nodeType === undefined) {
|
|
1374
|
-
throw new n8n_workflow_1.NodeOperationError(node, `Node type "${node.type}" is not known so can not get credentials`);
|
|
1375
|
-
}
|
|
1376
|
-
const fullAccess = [Constants_1.HTTP_REQUEST_NODE_TYPE, Constants_1.HTTP_REQUEST_TOOL_NODE_TYPE].includes(node.type);
|
|
1377
|
-
let nodeCredentialDescription;
|
|
1378
|
-
if (!fullAccess) {
|
|
1379
|
-
if (nodeType.description.credentials === undefined) {
|
|
1380
|
-
throw new n8n_workflow_1.NodeOperationError(node, `Node type "${node.type}" does not have any credentials defined`, { level: 'warning' });
|
|
1381
|
-
}
|
|
1382
|
-
nodeCredentialDescription = nodeType.description.credentials.find((credentialTypeDescription) => credentialTypeDescription.name === type);
|
|
1383
|
-
if (nodeCredentialDescription === undefined) {
|
|
1384
|
-
throw new n8n_workflow_1.NodeOperationError(node, `Node type "${node.type}" does not have any credentials of type "${type}" defined`, { level: 'warning' });
|
|
1385
|
-
}
|
|
1386
|
-
if (!n8n_workflow_1.NodeHelpers.displayParameter(additionalData.currentNodeParameters || node.parameters, nodeCredentialDescription, node, node.parameters)) {
|
|
1387
|
-
throw new n8n_workflow_1.NodeOperationError(node, 'Credentials not found');
|
|
1388
|
-
}
|
|
1389
|
-
}
|
|
1390
|
-
if (!fullAccess && !node.credentials?.[type]) {
|
|
1391
|
-
if (nodeCredentialDescription?.required === true) {
|
|
1392
|
-
if (!node.credentials) {
|
|
1393
|
-
throw new n8n_workflow_1.NodeOperationError(node, 'Node does not have any credentials set', {
|
|
1394
|
-
level: 'warning',
|
|
1395
|
-
});
|
|
1396
|
-
}
|
|
1397
|
-
if (!node.credentials[type]) {
|
|
1398
|
-
throw new n8n_workflow_1.NodeOperationError(node, `Node does not have any credentials set for "${type}"`, {
|
|
1399
|
-
level: 'warning',
|
|
1400
|
-
});
|
|
1401
|
-
}
|
|
1402
|
-
}
|
|
1403
|
-
else {
|
|
1404
|
-
throw new n8n_workflow_1.NodeOperationError(node, 'Node does not require credentials');
|
|
1405
|
-
}
|
|
1406
|
-
}
|
|
1407
|
-
if (fullAccess && !node.credentials?.[type]) {
|
|
1408
|
-
throw new n8n_workflow_1.NodeOperationError(node, 'Credentials not found');
|
|
1409
|
-
}
|
|
1410
|
-
let expressionResolveValues;
|
|
1411
|
-
if (connectionInputData && runExecutionData && runIndex !== undefined) {
|
|
1412
|
-
expressionResolveValues = {
|
|
1413
|
-
connectionInputData,
|
|
1414
|
-
itemIndex: itemIndex || 0,
|
|
1415
|
-
node,
|
|
1416
|
-
runExecutionData,
|
|
1417
|
-
runIndex,
|
|
1418
|
-
workflow,
|
|
1419
|
-
};
|
|
1420
|
-
}
|
|
1421
|
-
const nodeCredentials = node.credentials
|
|
1422
|
-
? node.credentials[type]
|
|
1423
|
-
: {};
|
|
1424
|
-
const decryptedDataObject = await additionalData.credentialsHelper.getDecrypted(additionalData, nodeCredentials, type, mode, executeData, false, expressionResolveValues);
|
|
1425
|
-
return decryptedDataObject;
|
|
1426
|
-
}
|
|
1427
|
-
function cleanupParameterData(inputData) {
|
|
1428
|
-
if (typeof inputData !== 'object' || inputData === null) {
|
|
1429
|
-
return;
|
|
1430
|
-
}
|
|
1431
|
-
if (Array.isArray(inputData)) {
|
|
1432
|
-
inputData.forEach((value) => cleanupParameterData(value));
|
|
1433
|
-
return;
|
|
1434
|
-
}
|
|
1435
|
-
if (typeof inputData === 'object') {
|
|
1436
|
-
Object.keys(inputData).forEach((key) => {
|
|
1437
|
-
const value = inputData[key];
|
|
1438
|
-
if (typeof value === 'object') {
|
|
1439
|
-
if (luxon_1.DateTime.isDateTime(value)) {
|
|
1440
|
-
inputData[key] = value.toString();
|
|
1441
|
-
}
|
|
1442
|
-
else {
|
|
1443
|
-
cleanupParameterData(value);
|
|
1444
|
-
}
|
|
1445
|
-
}
|
|
1446
|
-
});
|
|
1447
|
-
}
|
|
1448
|
-
}
|
|
1449
|
-
const validateResourceMapperValue = (parameterName, paramValues, node, skipRequiredCheck = false) => {
|
|
1450
|
-
const result = { valid: true, newValue: paramValues };
|
|
1451
|
-
const paramNameParts = parameterName.split('.');
|
|
1452
|
-
if (paramNameParts.length !== 2) {
|
|
1453
|
-
return result;
|
|
1454
|
-
}
|
|
1455
|
-
const resourceMapperParamName = paramNameParts[0];
|
|
1456
|
-
const resourceMapperField = node.parameters[resourceMapperParamName];
|
|
1457
|
-
if (!resourceMapperField || !(0, n8n_workflow_1.isResourceMapperValue)(resourceMapperField)) {
|
|
1458
|
-
return result;
|
|
1459
|
-
}
|
|
1460
|
-
const schema = resourceMapperField.schema;
|
|
1461
|
-
const paramValueNames = Object.keys(paramValues);
|
|
1462
|
-
for (let i = 0; i < paramValueNames.length; i++) {
|
|
1463
|
-
const key = paramValueNames[i];
|
|
1464
|
-
const resolvedValue = paramValues[key];
|
|
1465
|
-
const schemaEntry = schema.find((s) => s.id === key);
|
|
1466
|
-
if (!skipRequiredCheck &&
|
|
1467
|
-
schemaEntry?.required === true &&
|
|
1468
|
-
schemaEntry.type !== 'boolean' &&
|
|
1469
|
-
!resolvedValue) {
|
|
1470
|
-
return {
|
|
1471
|
-
valid: false,
|
|
1472
|
-
errorMessage: `The value "${String(key)}" is required but not set`,
|
|
1473
|
-
fieldName: key,
|
|
1474
|
-
};
|
|
1475
|
-
}
|
|
1476
|
-
if (schemaEntry?.type) {
|
|
1477
|
-
const validationResult = (0, n8n_workflow_1.validateFieldType)(key, resolvedValue, schemaEntry.type, {
|
|
1478
|
-
valueOptions: schemaEntry.options,
|
|
1479
|
-
});
|
|
1480
|
-
if (!validationResult.valid) {
|
|
1481
|
-
return { ...validationResult, fieldName: key };
|
|
1482
|
-
}
|
|
1483
|
-
else {
|
|
1484
|
-
paramValues[key] = validationResult.newValue;
|
|
1485
|
-
}
|
|
1486
|
-
}
|
|
1487
|
-
}
|
|
1488
|
-
return result;
|
|
1489
|
-
};
|
|
1490
|
-
const validateCollection = (node, runIndex, itemIndex, propertyDescription, parameterPath, validationResult) => {
|
|
1491
|
-
let nestedDescriptions;
|
|
1492
|
-
if (propertyDescription.type === 'fixedCollection') {
|
|
1493
|
-
nestedDescriptions = propertyDescription.options.find((entry) => entry.name === parameterPath[1])?.values;
|
|
1494
|
-
}
|
|
1495
|
-
if (propertyDescription.type === 'collection') {
|
|
1496
|
-
nestedDescriptions = propertyDescription.options;
|
|
1497
|
-
}
|
|
1498
|
-
if (!nestedDescriptions) {
|
|
1499
|
-
return validationResult;
|
|
1500
|
-
}
|
|
1501
|
-
const validationMap = {};
|
|
1502
|
-
for (const prop of nestedDescriptions) {
|
|
1503
|
-
if (!prop.validateType || prop.ignoreValidationDuringExecution)
|
|
1504
|
-
continue;
|
|
1505
|
-
validationMap[prop.name] = {
|
|
1506
|
-
type: prop.validateType,
|
|
1507
|
-
displayName: prop.displayName,
|
|
1508
|
-
options: prop.validateType === 'options' ? prop.options : undefined,
|
|
1509
|
-
};
|
|
1510
|
-
}
|
|
1511
|
-
if (!Object.keys(validationMap).length) {
|
|
1512
|
-
return validationResult;
|
|
1513
|
-
}
|
|
1514
|
-
if (validationResult.valid) {
|
|
1515
|
-
for (const value of Array.isArray(validationResult.newValue)
|
|
1516
|
-
? validationResult.newValue
|
|
1517
|
-
: [validationResult.newValue]) {
|
|
1518
|
-
for (const key of Object.keys(value)) {
|
|
1519
|
-
if (!validationMap[key])
|
|
1520
|
-
continue;
|
|
1521
|
-
const fieldValidationResult = (0, n8n_workflow_1.validateFieldType)(key, value[key], validationMap[key].type, {
|
|
1522
|
-
valueOptions: validationMap[key].options,
|
|
1523
|
-
});
|
|
1524
|
-
if (!fieldValidationResult.valid) {
|
|
1525
|
-
throw new n8n_workflow_1.ExpressionError(`Invalid input for field '${validationMap[key].displayName}' inside '${propertyDescription.displayName}' in [item ${itemIndex}]`, {
|
|
1526
|
-
description: fieldValidationResult.errorMessage,
|
|
1527
|
-
runIndex,
|
|
1528
|
-
itemIndex,
|
|
1529
|
-
nodeCause: node.name,
|
|
1530
|
-
});
|
|
1531
|
-
}
|
|
1532
|
-
value[key] = fieldValidationResult.newValue;
|
|
1533
|
-
}
|
|
1534
|
-
}
|
|
1535
|
-
}
|
|
1536
|
-
return validationResult;
|
|
1537
|
-
};
|
|
1538
|
-
const validateValueAgainstSchema = (node, nodeType, parameterValue, parameterName, runIndex, itemIndex) => {
|
|
1539
|
-
const parameterPath = parameterName.split('.');
|
|
1540
|
-
const propertyDescription = nodeType.description.properties.find((prop) => parameterPath[0] === prop.name && n8n_workflow_1.NodeHelpers.displayParameter(node.parameters, prop, node));
|
|
1541
|
-
if (!propertyDescription) {
|
|
1542
|
-
return parameterValue;
|
|
1543
|
-
}
|
|
1544
|
-
let validationResult = { valid: true, newValue: parameterValue };
|
|
1545
|
-
if (parameterPath.length === 1 &&
|
|
1546
|
-
propertyDescription.validateType &&
|
|
1547
|
-
!propertyDescription.ignoreValidationDuringExecution) {
|
|
1548
|
-
validationResult = (0, n8n_workflow_1.validateFieldType)(parameterName, parameterValue, propertyDescription.validateType);
|
|
1549
|
-
}
|
|
1550
|
-
else if (propertyDescription.type === 'resourceMapper' &&
|
|
1551
|
-
parameterPath[1] === 'value' &&
|
|
1552
|
-
typeof parameterValue === 'object') {
|
|
1553
|
-
validationResult = validateResourceMapperValue(parameterName, parameterValue, node, propertyDescription.typeOptions?.resourceMapper?.mode !== 'add');
|
|
1554
|
-
}
|
|
1555
|
-
else if (['fixedCollection', 'collection'].includes(propertyDescription.type)) {
|
|
1556
|
-
validationResult = validateCollection(node, runIndex, itemIndex, propertyDescription, parameterPath, validationResult);
|
|
1557
|
-
}
|
|
1558
|
-
if (!validationResult.valid) {
|
|
1559
|
-
throw new n8n_workflow_1.ExpressionError(`Invalid input for '${validationResult.fieldName
|
|
1560
|
-
? String(validationResult.fieldName)
|
|
1561
|
-
: propertyDescription.displayName}' [item ${itemIndex}]`, {
|
|
1562
|
-
description: validationResult.errorMessage,
|
|
1563
|
-
runIndex,
|
|
1564
|
-
itemIndex,
|
|
1565
|
-
nodeCause: node.name,
|
|
1566
|
-
});
|
|
1567
|
-
}
|
|
1568
|
-
return validationResult.newValue;
|
|
1569
|
-
};
|
|
1570
|
-
exports.validateValueAgainstSchema = validateValueAgainstSchema;
|
|
1571
|
-
function ensureType(toType, parameterValue, parameterName, errorOptions) {
|
|
1572
|
-
let returnData = parameterValue;
|
|
1573
|
-
if (returnData === null) {
|
|
1574
|
-
throw new n8n_workflow_1.ExpressionError(`Parameter '${parameterName}' must not be null`, errorOptions);
|
|
1575
|
-
}
|
|
1576
|
-
if (returnData === undefined) {
|
|
1577
|
-
throw new n8n_workflow_1.ExpressionError(`Parameter '${parameterName}' could not be 'undefined'`, errorOptions);
|
|
1578
|
-
}
|
|
1579
|
-
if (['object', 'array', 'json'].includes(toType)) {
|
|
1580
|
-
if (typeof returnData !== 'object') {
|
|
1581
|
-
if (typeof returnData === 'string' && returnData.length) {
|
|
1582
|
-
try {
|
|
1583
|
-
const parsedValue = JSON.parse(returnData);
|
|
1584
|
-
returnData = parsedValue;
|
|
1585
|
-
}
|
|
1586
|
-
catch (error) {
|
|
1587
|
-
throw new n8n_workflow_1.ExpressionError(`Parameter '${parameterName}' could not be parsed`, {
|
|
1588
|
-
...errorOptions,
|
|
1589
|
-
description: error.message,
|
|
1590
|
-
});
|
|
1591
|
-
}
|
|
1592
|
-
}
|
|
1593
|
-
else {
|
|
1594
|
-
throw new n8n_workflow_1.ExpressionError(`Parameter '${parameterName}' must be an ${toType}, but we got '${String(parameterValue)}'`, errorOptions);
|
|
1595
|
-
}
|
|
1596
|
-
}
|
|
1597
|
-
else if (toType === 'json') {
|
|
1598
|
-
try {
|
|
1599
|
-
JSON.stringify(returnData);
|
|
1600
|
-
}
|
|
1601
|
-
catch (error) {
|
|
1602
|
-
throw new n8n_workflow_1.ExpressionError(`Parameter '${parameterName}' is not valid JSON`, {
|
|
1603
|
-
...errorOptions,
|
|
1604
|
-
description: error.message,
|
|
1605
|
-
});
|
|
1606
|
-
}
|
|
1607
|
-
}
|
|
1608
|
-
if (toType === 'array' && !Array.isArray(returnData)) {
|
|
1609
|
-
throw new n8n_workflow_1.ExpressionError(`Parameter '${parameterName}' must be an array, but we got object`, errorOptions);
|
|
1610
|
-
}
|
|
1611
|
-
}
|
|
1612
|
-
try {
|
|
1613
|
-
if (toType === 'string') {
|
|
1614
|
-
if (typeof returnData === 'object') {
|
|
1615
|
-
returnData = JSON.stringify(returnData);
|
|
1616
|
-
}
|
|
1617
|
-
else {
|
|
1618
|
-
returnData = String(returnData);
|
|
1619
|
-
}
|
|
1620
|
-
}
|
|
1621
|
-
if (toType === 'number') {
|
|
1622
|
-
returnData = Number(returnData);
|
|
1623
|
-
if (Number.isNaN(returnData)) {
|
|
1624
|
-
throw new n8n_workflow_1.ExpressionError(`Parameter '${parameterName}' must be a number, but we got '${parameterValue}'`, errorOptions);
|
|
1625
|
-
}
|
|
1626
|
-
}
|
|
1627
|
-
if (toType === 'boolean') {
|
|
1628
|
-
returnData = Boolean(returnData);
|
|
1629
|
-
}
|
|
1630
|
-
}
|
|
1631
|
-
catch (error) {
|
|
1632
|
-
if (error instanceof n8n_workflow_1.ExpressionError)
|
|
1633
|
-
throw error;
|
|
1634
|
-
throw new n8n_workflow_1.ExpressionError(`Parameter '${parameterName}' could not be converted to ${toType}`, {
|
|
1635
|
-
...errorOptions,
|
|
1636
|
-
description: error.message,
|
|
1637
|
-
});
|
|
1638
|
-
}
|
|
1639
|
-
return returnData;
|
|
1640
|
-
}
|
|
1641
|
-
function getNodeParameter(workflow, runExecutionData, runIndex, connectionInputData, node, parameterName, itemIndex, mode, additionalKeys, executeData, fallbackValue, options) {
|
|
1642
|
-
const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
|
|
1643
|
-
if (nodeType === undefined) {
|
|
1644
|
-
throw new n8n_workflow_1.ApplicationError('Node type is unknown so cannot return parameter value', {
|
|
1645
|
-
tags: { nodeType: node.type },
|
|
1646
|
-
});
|
|
1647
|
-
}
|
|
1648
|
-
const value = (0, get_1.default)(node.parameters, parameterName, fallbackValue);
|
|
1649
|
-
if (value === undefined) {
|
|
1650
|
-
throw new n8n_workflow_1.ApplicationError('Could not get parameter', { extra: { parameterName } });
|
|
1651
|
-
}
|
|
1652
|
-
if (options?.rawExpressions) {
|
|
1653
|
-
return value;
|
|
1654
|
-
}
|
|
1655
|
-
let returnData;
|
|
1656
|
-
try {
|
|
1657
|
-
returnData = workflow.expression.getParameterValue(value, runExecutionData, runIndex, itemIndex, node.name, connectionInputData, mode, additionalKeys, executeData, false, {}, options?.contextNode?.name);
|
|
1658
|
-
cleanupParameterData(returnData);
|
|
1659
|
-
}
|
|
1660
|
-
catch (e) {
|
|
1661
|
-
if (e instanceof n8n_workflow_1.ExpressionError && node.continueOnFail && node.type === 'n8n-nodes-base.set') {
|
|
1662
|
-
returnData = [{ name: undefined, value: undefined }];
|
|
1663
|
-
}
|
|
1664
|
-
else {
|
|
1665
|
-
if (e.context)
|
|
1666
|
-
e.context.parameter = parameterName;
|
|
1667
|
-
e.cause = value;
|
|
1668
|
-
throw e;
|
|
1669
|
-
}
|
|
1670
|
-
}
|
|
1671
|
-
if (options?.extractValue) {
|
|
1672
|
-
returnData = (0, ExtractValue_1.extractValue)(returnData, parameterName, node, nodeType, itemIndex);
|
|
1673
|
-
}
|
|
1674
|
-
if (options?.ensureType) {
|
|
1675
|
-
returnData = ensureType(options.ensureType, returnData, parameterName, {
|
|
1676
|
-
itemIndex,
|
|
1677
|
-
runIndex,
|
|
1678
|
-
nodeCause: node.name,
|
|
1679
|
-
});
|
|
1680
|
-
}
|
|
1681
|
-
returnData = (0, exports.validateValueAgainstSchema)(node, nodeType, returnData, parameterName, runIndex, itemIndex);
|
|
1682
|
-
return returnData;
|
|
1683
|
-
}
|
|
1684
|
-
function continueOnFail(node) {
|
|
1685
|
-
const onError = (0, get_1.default)(node, 'onError', undefined);
|
|
1686
|
-
if (onError === undefined) {
|
|
1687
|
-
return (0, get_1.default)(node, 'continueOnFail', false);
|
|
1688
|
-
}
|
|
1689
|
-
return ['continueRegularOutput', 'continueErrorOutput'].includes(onError);
|
|
1690
|
-
}
|
|
1691
1320
|
function getNodeWebhookUrl(name, workflow, node, additionalData, mode, additionalKeys, isTest) {
|
|
1692
1321
|
let baseUrl = additionalData.webhookBaseUrl;
|
|
1693
1322
|
if (isTest === true) {
|
|
@@ -1796,6 +1425,7 @@ const addExecutionDataFunctions = async (type, nodeName, data, runExecutionData,
|
|
|
1796
1425
|
});
|
|
1797
1426
|
}
|
|
1798
1427
|
};
|
|
1428
|
+
exports.addExecutionDataFunctions = addExecutionDataFunctions;
|
|
1799
1429
|
async function getInputConnectionData(workflow, runExecutionData, runIndex, connectionInputData, inputData, additionalData, executeData, mode, closeFunctions, inputName, itemIndex, abortSignal) {
|
|
1800
1430
|
const node = this.getNode();
|
|
1801
1431
|
const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
|
|
@@ -1830,7 +1460,7 @@ async function getInputConnectionData(workflow, runExecutionData, runIndex, conn
|
|
|
1830
1460
|
.filter((connectedNode) => connectedNode.disabled !== true)
|
|
1831
1461
|
.map(async (connectedNode) => {
|
|
1832
1462
|
const nodeType = workflow.nodeTypes.getByNameAndVersion(connectedNode.type, connectedNode.typeVersion);
|
|
1833
|
-
const context =
|
|
1463
|
+
const context = new node_execution_context_1.SupplyDataContext(workflow, connectedNode, additionalData, mode, runExecutionData, runIndex, connectionInputData, inputData, executeData, closeFunctions, abortSignal);
|
|
1834
1464
|
if (!nodeType.supplyData) {
|
|
1835
1465
|
if (nodeType.description.outputs.includes("ai_tool")) {
|
|
1836
1466
|
nodeType.supplyData = async function () {
|
|
@@ -1862,7 +1492,7 @@ async function getInputConnectionData(workflow, runExecutionData, runIndex, conn
|
|
|
1862
1492
|
if (runExecutionData.resultData.runData.hasOwnProperty(node.name)) {
|
|
1863
1493
|
currentNodeRunIndex = runExecutionData.resultData.runData[node.name].length;
|
|
1864
1494
|
}
|
|
1865
|
-
await addExecutionDataFunctions('input', connectedNode.name, error, runExecutionData, inputName, additionalData, node.name, runIndex, currentNodeRunIndex);
|
|
1495
|
+
await (0, exports.addExecutionDataFunctions)('input', connectedNode.name, error, runExecutionData, inputName, additionalData, node.name, runIndex, currentNodeRunIndex);
|
|
1866
1496
|
throw new n8n_workflow_1.NodeOperationError(connectedNode, `Error in sub-node ${connectedNode.name}`, {
|
|
1867
1497
|
itemIndex,
|
|
1868
1498
|
functionality: 'configuration-node',
|
|
@@ -1882,60 +1512,6 @@ async function getInputConnectionData(workflow, runExecutionData, runIndex, conn
|
|
|
1882
1512
|
? (nodes || [])[0]?.response
|
|
1883
1513
|
: nodes.map((node) => node.response);
|
|
1884
1514
|
}
|
|
1885
|
-
const getCommonWorkflowFunctions = (workflow, node, additionalData) => ({
|
|
1886
|
-
logger: n8n_workflow_1.LoggerProxy,
|
|
1887
|
-
getExecutionId: () => additionalData.executionId,
|
|
1888
|
-
getNode: () => (0, n8n_workflow_1.deepCopy)(node),
|
|
1889
|
-
getWorkflow: () => ({
|
|
1890
|
-
id: workflow.id,
|
|
1891
|
-
name: workflow.name,
|
|
1892
|
-
active: workflow.active,
|
|
1893
|
-
}),
|
|
1894
|
-
getWorkflowStaticData: (type) => workflow.getStaticData(type, node),
|
|
1895
|
-
getChildNodes: (nodeName) => {
|
|
1896
|
-
const output = [];
|
|
1897
|
-
const nodes = workflow.getChildNodes(nodeName);
|
|
1898
|
-
for (const nodeName of nodes) {
|
|
1899
|
-
const node = workflow.nodes[nodeName];
|
|
1900
|
-
output.push({
|
|
1901
|
-
name: node.name,
|
|
1902
|
-
type: node.type,
|
|
1903
|
-
typeVersion: node.typeVersion,
|
|
1904
|
-
});
|
|
1905
|
-
}
|
|
1906
|
-
return output;
|
|
1907
|
-
},
|
|
1908
|
-
getParentNodes: (nodeName) => {
|
|
1909
|
-
const output = [];
|
|
1910
|
-
const nodes = workflow.getParentNodes(nodeName);
|
|
1911
|
-
for (const nodeName of nodes) {
|
|
1912
|
-
const node = workflow.nodes[nodeName];
|
|
1913
|
-
output.push({
|
|
1914
|
-
name: node.name,
|
|
1915
|
-
type: node.type,
|
|
1916
|
-
typeVersion: node.typeVersion,
|
|
1917
|
-
});
|
|
1918
|
-
}
|
|
1919
|
-
return output;
|
|
1920
|
-
},
|
|
1921
|
-
getKnownNodeTypes: () => workflow.nodeTypes.getKnownTypes(),
|
|
1922
|
-
getRestApiUrl: () => additionalData.restApiUrl,
|
|
1923
|
-
getInstanceBaseUrl: () => additionalData.instanceBaseUrl,
|
|
1924
|
-
getInstanceId: () => typedi_1.default.get(InstanceSettings_1.InstanceSettings).instanceId,
|
|
1925
|
-
getTimezone: () => workflow.timezone,
|
|
1926
|
-
getCredentialsProperties: (type) => additionalData.credentialsHelper.getCredentialsProperties(type),
|
|
1927
|
-
prepareOutputData: async (outputData) => [outputData],
|
|
1928
|
-
});
|
|
1929
|
-
const executionCancellationFunctions = (abortSignal) => ({
|
|
1930
|
-
getExecutionCancelSignal: () => abortSignal,
|
|
1931
|
-
onExecutionCancellation: (handler) => {
|
|
1932
|
-
const fn = () => {
|
|
1933
|
-
abortSignal?.removeEventListener('abort', fn);
|
|
1934
|
-
handler();
|
|
1935
|
-
};
|
|
1936
|
-
abortSignal?.addEventListener('abort', fn);
|
|
1937
|
-
},
|
|
1938
|
-
});
|
|
1939
1515
|
const getRequestHelperFunctions = (workflow, node, additionalData, runExecutionData = null, connectionInputData = []) => {
|
|
1940
1516
|
const getResolvedValue = (parameterValue, itemIndex, runIndex, executeData, additionalKeys, returnObjectAsString = false) => {
|
|
1941
1517
|
const mode = 'internal';
|
|
@@ -2250,303 +1826,7 @@ function getExecuteTriggerFunctions(workflow, node, additionalData, mode, activa
|
|
|
2250
1826
|
return new node_execution_context_1.TriggerContext(workflow, node, additionalData, mode, activation);
|
|
2251
1827
|
}
|
|
2252
1828
|
function getExecuteFunctions(workflow, runExecutionData, runIndex, connectionInputData, inputData, node, additionalData, executeData, mode, closeFunctions, abortSignal) {
|
|
2253
|
-
return (
|
|
2254
|
-
return {
|
|
2255
|
-
...getCommonWorkflowFunctions(workflow, node, additionalData),
|
|
2256
|
-
...executionCancellationFunctions(abortSignal),
|
|
2257
|
-
getMode: () => mode,
|
|
2258
|
-
getCredentials: async (type, itemIndex) => await getCredentials(workflow, node, type, additionalData, mode, executeData, runExecutionData, runIndex, connectionInputData, itemIndex),
|
|
2259
|
-
getExecuteData: () => executeData,
|
|
2260
|
-
setMetadata: (metadata) => {
|
|
2261
|
-
executeData.metadata = {
|
|
2262
|
-
...(executeData.metadata ?? {}),
|
|
2263
|
-
...metadata,
|
|
2264
|
-
};
|
|
2265
|
-
},
|
|
2266
|
-
continueOnFail: () => {
|
|
2267
|
-
return continueOnFail(node);
|
|
2268
|
-
},
|
|
2269
|
-
evaluateExpression(expression, itemIndex) {
|
|
2270
|
-
return workflow.expression.resolveSimpleParameterValue(`=${expression}`, {}, runExecutionData, runIndex, itemIndex, node.name, connectionInputData, mode, getAdditionalKeys(additionalData, mode, runExecutionData), executeData);
|
|
2271
|
-
},
|
|
2272
|
-
async executeWorkflow(workflowInfo, inputData, parentCallbackManager, options) {
|
|
2273
|
-
return await additionalData
|
|
2274
|
-
.executeWorkflow(workflowInfo, additionalData, {
|
|
2275
|
-
...options,
|
|
2276
|
-
parentWorkflowId: workflow.id?.toString(),
|
|
2277
|
-
inputData,
|
|
2278
|
-
parentWorkflowSettings: workflow.settings,
|
|
2279
|
-
node,
|
|
2280
|
-
parentCallbackManager,
|
|
2281
|
-
})
|
|
2282
|
-
.then(async (result) => {
|
|
2283
|
-
const data = await typedi_1.default.get(BinaryData_service_1.BinaryDataService).duplicateBinaryData(workflow.id, additionalData.executionId, result.data);
|
|
2284
|
-
return { ...result, data };
|
|
2285
|
-
});
|
|
2286
|
-
},
|
|
2287
|
-
getContext(type) {
|
|
2288
|
-
return n8n_workflow_1.NodeHelpers.getContext(runExecutionData, type, node);
|
|
2289
|
-
},
|
|
2290
|
-
async getInputConnectionData(inputName, itemIndex) {
|
|
2291
|
-
return await getInputConnectionData.call(this, workflow, runExecutionData, runIndex, connectionInputData, inputData, additionalData, executeData, mode, closeFunctions, inputName, itemIndex, abortSignal);
|
|
2292
|
-
},
|
|
2293
|
-
getNodeInputs() {
|
|
2294
|
-
const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
|
|
2295
|
-
return n8n_workflow_1.NodeHelpers.getNodeInputs(workflow, node, nodeType.description).map((output) => {
|
|
2296
|
-
if (typeof output === 'string') {
|
|
2297
|
-
return {
|
|
2298
|
-
type: output,
|
|
2299
|
-
};
|
|
2300
|
-
}
|
|
2301
|
-
return output;
|
|
2302
|
-
});
|
|
2303
|
-
},
|
|
2304
|
-
getNodeOutputs() {
|
|
2305
|
-
const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
|
|
2306
|
-
return n8n_workflow_1.NodeHelpers.getNodeOutputs(workflow, node, nodeType.description).map((output) => {
|
|
2307
|
-
if (typeof output === 'string') {
|
|
2308
|
-
return {
|
|
2309
|
-
type: output,
|
|
2310
|
-
};
|
|
2311
|
-
}
|
|
2312
|
-
return output;
|
|
2313
|
-
});
|
|
2314
|
-
},
|
|
2315
|
-
getInputData: (inputIndex = 0, inputName = 'main') => {
|
|
2316
|
-
if (!inputData.hasOwnProperty(inputName)) {
|
|
2317
|
-
return [];
|
|
2318
|
-
}
|
|
2319
|
-
if (inputData[inputName].length < inputIndex) {
|
|
2320
|
-
throw new n8n_workflow_1.ApplicationError('Could not get input with given index', {
|
|
2321
|
-
extra: { inputIndex, inputName },
|
|
2322
|
-
});
|
|
2323
|
-
}
|
|
2324
|
-
if (inputData[inputName][inputIndex] === null) {
|
|
2325
|
-
throw new n8n_workflow_1.ApplicationError('Value of input was not set', {
|
|
2326
|
-
extra: { inputIndex, inputName },
|
|
2327
|
-
});
|
|
2328
|
-
}
|
|
2329
|
-
return inputData[inputName][inputIndex];
|
|
2330
|
-
},
|
|
2331
|
-
getInputSourceData: (inputIndex = 0, inputName = 'main') => {
|
|
2332
|
-
if (executeData?.source === null) {
|
|
2333
|
-
throw new n8n_workflow_1.ApplicationError('Source data is missing');
|
|
2334
|
-
}
|
|
2335
|
-
return executeData.source[inputName][inputIndex];
|
|
2336
|
-
},
|
|
2337
|
-
getNodeParameter: (parameterName, itemIndex, fallbackValue, options) => {
|
|
2338
|
-
return getNodeParameter(workflow, runExecutionData, runIndex, connectionInputData, node, parameterName, itemIndex, mode, getAdditionalKeys(additionalData, mode, runExecutionData), executeData, fallbackValue, options);
|
|
2339
|
-
},
|
|
2340
|
-
getWorkflowDataProxy: (itemIndex) => {
|
|
2341
|
-
const dataProxy = new n8n_workflow_1.WorkflowDataProxy(workflow, runExecutionData, runIndex, itemIndex, node.name, connectionInputData, {}, mode, getAdditionalKeys(additionalData, mode, runExecutionData), executeData);
|
|
2342
|
-
return dataProxy.getDataProxy();
|
|
2343
|
-
},
|
|
2344
|
-
async putExecutionToWait(waitTill) {
|
|
2345
|
-
runExecutionData.waitTill = waitTill;
|
|
2346
|
-
if (additionalData.setExecutionStatus) {
|
|
2347
|
-
additionalData.setExecutionStatus('waiting');
|
|
2348
|
-
}
|
|
2349
|
-
},
|
|
2350
|
-
logNodeOutput(...args) {
|
|
2351
|
-
if (mode === 'manual') {
|
|
2352
|
-
this.sendMessageToUI(...args);
|
|
2353
|
-
return;
|
|
2354
|
-
}
|
|
2355
|
-
if (process.env.CODE_ENABLE_STDOUT === 'true') {
|
|
2356
|
-
console.log(`[Workflow "${this.getWorkflow().id}"][Node "${node.name}"]`, ...args);
|
|
2357
|
-
}
|
|
2358
|
-
},
|
|
2359
|
-
sendMessageToUI(...args) {
|
|
2360
|
-
if (mode !== 'manual') {
|
|
2361
|
-
return;
|
|
2362
|
-
}
|
|
2363
|
-
try {
|
|
2364
|
-
if (additionalData.sendDataToUI) {
|
|
2365
|
-
args = args.map((arg) => {
|
|
2366
|
-
if (arg.isLuxonDateTime && arg.invalidReason)
|
|
2367
|
-
return { ...arg };
|
|
2368
|
-
if (arg.isLuxonDateTime)
|
|
2369
|
-
return new Date(arg.ts).toString();
|
|
2370
|
-
if (arg instanceof Date)
|
|
2371
|
-
return arg.toString();
|
|
2372
|
-
return arg;
|
|
2373
|
-
});
|
|
2374
|
-
additionalData.sendDataToUI('sendConsoleMessage', {
|
|
2375
|
-
source: `[Node: "${node.name}"]`,
|
|
2376
|
-
messages: args,
|
|
2377
|
-
});
|
|
2378
|
-
}
|
|
2379
|
-
}
|
|
2380
|
-
catch (error) {
|
|
2381
|
-
n8n_workflow_1.LoggerProxy.warn(`There was a problem sending message to UI: ${error.message}`);
|
|
2382
|
-
}
|
|
2383
|
-
},
|
|
2384
|
-
async sendResponse(response) {
|
|
2385
|
-
await additionalData.hooks?.executeHookFunctions('sendResponse', [response]);
|
|
2386
|
-
},
|
|
2387
|
-
addInputData(connectionType, data) {
|
|
2388
|
-
const nodeName = this.getNode().name;
|
|
2389
|
-
let currentNodeRunIndex = 0;
|
|
2390
|
-
if (runExecutionData.resultData.runData.hasOwnProperty(nodeName)) {
|
|
2391
|
-
currentNodeRunIndex = runExecutionData.resultData.runData[nodeName].length;
|
|
2392
|
-
}
|
|
2393
|
-
addExecutionDataFunctions('input', this.getNode().name, data, runExecutionData, connectionType, additionalData, node.name, runIndex, currentNodeRunIndex).catch((error) => {
|
|
2394
|
-
n8n_workflow_1.LoggerProxy.warn(`There was a problem logging input data of node "${this.getNode().name}": ${error.message}`);
|
|
2395
|
-
});
|
|
2396
|
-
return { index: currentNodeRunIndex };
|
|
2397
|
-
},
|
|
2398
|
-
addOutputData(connectionType, currentNodeRunIndex, data, metadata) {
|
|
2399
|
-
addExecutionDataFunctions('output', this.getNode().name, data, runExecutionData, connectionType, additionalData, node.name, runIndex, currentNodeRunIndex, metadata).catch((error) => {
|
|
2400
|
-
n8n_workflow_1.LoggerProxy.warn(`There was a problem logging output data of node "${this.getNode().name}": ${error.message}`);
|
|
2401
|
-
});
|
|
2402
|
-
},
|
|
2403
|
-
helpers: {
|
|
2404
|
-
createDeferredPromise: n8n_workflow_1.createDeferredPromise,
|
|
2405
|
-
copyInputItems,
|
|
2406
|
-
...(0, exports.getRequestHelperFunctions)(workflow, node, additionalData, runExecutionData, connectionInputData),
|
|
2407
|
-
...(0, exports.getSSHTunnelFunctions)(),
|
|
2408
|
-
...(0, exports.getFileSystemHelperFunctions)(node),
|
|
2409
|
-
...(0, exports.getBinaryHelperFunctions)(additionalData, workflow.id),
|
|
2410
|
-
...(0, exports.getCheckProcessedHelperFunctions)(workflow, node),
|
|
2411
|
-
assertBinaryData: (itemIndex, propertyName) => assertBinaryData(inputData, node, itemIndex, propertyName, 0),
|
|
2412
|
-
getBinaryDataBuffer: async (itemIndex, propertyName) => await getBinaryDataBuffer(inputData, itemIndex, propertyName, 0),
|
|
2413
|
-
returnJsonArray,
|
|
2414
|
-
normalizeItems,
|
|
2415
|
-
constructExecutionMetaData,
|
|
2416
|
-
},
|
|
2417
|
-
nodeHelpers: (0, exports.getNodeHelperFunctions)(additionalData, workflow.id),
|
|
2418
|
-
logAiEvent: (eventName, msg) => {
|
|
2419
|
-
return additionalData.logAiEvent(eventName, {
|
|
2420
|
-
executionId: additionalData.executionId ?? 'unsaved-execution',
|
|
2421
|
-
nodeName: node.name,
|
|
2422
|
-
workflowName: workflow.name ?? 'Unnamed workflow',
|
|
2423
|
-
nodeType: node.type,
|
|
2424
|
-
workflowId: workflow.id ?? 'unsaved-workflow',
|
|
2425
|
-
msg,
|
|
2426
|
-
});
|
|
2427
|
-
},
|
|
2428
|
-
getParentCallbackManager: () => additionalData.parentCallbackManager,
|
|
2429
|
-
startJob: (0, Agent_1.createAgentStartJob)(additionalData, inputData, node, workflow, runExecutionData, runIndex, node.name, connectionInputData, {}, mode, executeData),
|
|
2430
|
-
};
|
|
2431
|
-
})(workflow, runExecutionData, connectionInputData, inputData, node);
|
|
2432
|
-
}
|
|
2433
|
-
function getSupplyDataFunctions(workflow, runExecutionData, runIndex, connectionInputData, inputData, node, additionalData, executeData, mode, closeFunctions, abortSignal) {
|
|
2434
|
-
return {
|
|
2435
|
-
...getCommonWorkflowFunctions(workflow, node, additionalData),
|
|
2436
|
-
...executionCancellationFunctions(abortSignal),
|
|
2437
|
-
getMode: () => mode,
|
|
2438
|
-
getCredentials: async (type, itemIndex) => await getCredentials(workflow, node, type, additionalData, mode, executeData, runExecutionData, runIndex, connectionInputData, itemIndex),
|
|
2439
|
-
continueOnFail: () => continueOnFail(node),
|
|
2440
|
-
evaluateExpression: (expression, itemIndex) => workflow.expression.resolveSimpleParameterValue(`=${expression}`, {}, runExecutionData, runIndex, itemIndex, node.name, connectionInputData, mode, getAdditionalKeys(additionalData, mode, runExecutionData), executeData),
|
|
2441
|
-
executeWorkflow: async (workflowInfo, inputData, parentCallbackManager, options) => await additionalData
|
|
2442
|
-
.executeWorkflow(workflowInfo, additionalData, {
|
|
2443
|
-
parentWorkflowId: workflow.id?.toString(),
|
|
2444
|
-
inputData,
|
|
2445
|
-
parentWorkflowSettings: workflow.settings,
|
|
2446
|
-
node,
|
|
2447
|
-
parentCallbackManager,
|
|
2448
|
-
...options,
|
|
2449
|
-
})
|
|
2450
|
-
.then(async (result) => {
|
|
2451
|
-
const data = await typedi_1.default.get(BinaryData_service_1.BinaryDataService).duplicateBinaryData(workflow.id, additionalData.executionId, result.data);
|
|
2452
|
-
return { ...result, data };
|
|
2453
|
-
}),
|
|
2454
|
-
getNodeOutputs() {
|
|
2455
|
-
const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
|
|
2456
|
-
return n8n_workflow_1.NodeHelpers.getNodeOutputs(workflow, node, nodeType.description).map((output) => {
|
|
2457
|
-
if (typeof output === 'string') {
|
|
2458
|
-
return {
|
|
2459
|
-
type: output,
|
|
2460
|
-
};
|
|
2461
|
-
}
|
|
2462
|
-
return output;
|
|
2463
|
-
});
|
|
2464
|
-
},
|
|
2465
|
-
async getInputConnectionData(inputName, itemIndex) {
|
|
2466
|
-
return await getInputConnectionData.call(this, workflow, runExecutionData, runIndex, connectionInputData, inputData, additionalData, executeData, mode, closeFunctions, inputName, itemIndex, abortSignal);
|
|
2467
|
-
},
|
|
2468
|
-
getInputData: (inputIndex = 0, inputName = 'main') => {
|
|
2469
|
-
if (!inputData.hasOwnProperty(inputName)) {
|
|
2470
|
-
return [];
|
|
2471
|
-
}
|
|
2472
|
-
if (inputData[inputName].length < inputIndex) {
|
|
2473
|
-
throw new n8n_workflow_1.ApplicationError('Could not get input with given index', {
|
|
2474
|
-
extra: { inputIndex, inputName },
|
|
2475
|
-
});
|
|
2476
|
-
}
|
|
2477
|
-
if (inputData[inputName][inputIndex] === null) {
|
|
2478
|
-
throw new n8n_workflow_1.ApplicationError('Value of input was not set', {
|
|
2479
|
-
extra: { inputIndex, inputName },
|
|
2480
|
-
});
|
|
2481
|
-
}
|
|
2482
|
-
return inputData[inputName][inputIndex];
|
|
2483
|
-
},
|
|
2484
|
-
getNodeParameter: ((parameterName, itemIndex, fallbackValue, options) => getNodeParameter(workflow, runExecutionData, runIndex, connectionInputData, node, parameterName, itemIndex, mode, getAdditionalKeys(additionalData, mode, runExecutionData), executeData, fallbackValue, options)),
|
|
2485
|
-
getWorkflowDataProxy: (itemIndex) => new n8n_workflow_1.WorkflowDataProxy(workflow, runExecutionData, runIndex, itemIndex, node.name, connectionInputData, {}, mode, getAdditionalKeys(additionalData, mode, runExecutionData), executeData).getDataProxy(),
|
|
2486
|
-
sendMessageToUI(...args) {
|
|
2487
|
-
if (mode !== 'manual') {
|
|
2488
|
-
return;
|
|
2489
|
-
}
|
|
2490
|
-
try {
|
|
2491
|
-
if (additionalData.sendDataToUI) {
|
|
2492
|
-
args = args.map((arg) => {
|
|
2493
|
-
if (arg.isLuxonDateTime && arg.invalidReason)
|
|
2494
|
-
return { ...arg };
|
|
2495
|
-
if (arg.isLuxonDateTime)
|
|
2496
|
-
return new Date(arg.ts).toString();
|
|
2497
|
-
if (arg instanceof Date)
|
|
2498
|
-
return arg.toString();
|
|
2499
|
-
return arg;
|
|
2500
|
-
});
|
|
2501
|
-
additionalData.sendDataToUI('sendConsoleMessage', {
|
|
2502
|
-
source: `[Node: "${node.name}"]`,
|
|
2503
|
-
messages: args,
|
|
2504
|
-
});
|
|
2505
|
-
}
|
|
2506
|
-
}
|
|
2507
|
-
catch (error) {
|
|
2508
|
-
n8n_workflow_1.LoggerProxy.warn(`There was a problem sending message to UI: ${error.message}`);
|
|
2509
|
-
}
|
|
2510
|
-
},
|
|
2511
|
-
logAiEvent: (eventName, msg) => additionalData.logAiEvent(eventName, {
|
|
2512
|
-
executionId: additionalData.executionId ?? 'unsaved-execution',
|
|
2513
|
-
nodeName: node.name,
|
|
2514
|
-
workflowName: workflow.name ?? 'Unnamed workflow',
|
|
2515
|
-
nodeType: node.type,
|
|
2516
|
-
workflowId: workflow.id ?? 'unsaved-workflow',
|
|
2517
|
-
msg,
|
|
2518
|
-
}),
|
|
2519
|
-
addInputData(connectionType, data) {
|
|
2520
|
-
const nodeName = this.getNode().name;
|
|
2521
|
-
let currentNodeRunIndex = 0;
|
|
2522
|
-
if (runExecutionData.resultData.runData.hasOwnProperty(nodeName)) {
|
|
2523
|
-
currentNodeRunIndex = runExecutionData.resultData.runData[nodeName].length;
|
|
2524
|
-
}
|
|
2525
|
-
addExecutionDataFunctions('input', this.getNode().name, data, runExecutionData, connectionType, additionalData, node.name, runIndex, currentNodeRunIndex).catch((error) => {
|
|
2526
|
-
n8n_workflow_1.LoggerProxy.warn(`There was a problem logging input data of node "${this.getNode().name}": ${error.message}`);
|
|
2527
|
-
});
|
|
2528
|
-
return { index: currentNodeRunIndex };
|
|
2529
|
-
},
|
|
2530
|
-
addOutputData(connectionType, currentNodeRunIndex, data, metadata) {
|
|
2531
|
-
addExecutionDataFunctions('output', this.getNode().name, data, runExecutionData, connectionType, additionalData, node.name, runIndex, currentNodeRunIndex, metadata).catch((error) => {
|
|
2532
|
-
n8n_workflow_1.LoggerProxy.warn(`There was a problem logging output data of node "${this.getNode().name}": ${error.message}`);
|
|
2533
|
-
});
|
|
2534
|
-
},
|
|
2535
|
-
helpers: {
|
|
2536
|
-
createDeferredPromise: n8n_workflow_1.createDeferredPromise,
|
|
2537
|
-
copyInputItems,
|
|
2538
|
-
...(0, exports.getRequestHelperFunctions)(workflow, node, additionalData, runExecutionData, connectionInputData),
|
|
2539
|
-
...(0, exports.getSSHTunnelFunctions)(),
|
|
2540
|
-
...(0, exports.getFileSystemHelperFunctions)(node),
|
|
2541
|
-
...(0, exports.getBinaryHelperFunctions)(additionalData, workflow.id),
|
|
2542
|
-
...(0, exports.getCheckProcessedHelperFunctions)(workflow, node),
|
|
2543
|
-
assertBinaryData: (itemIndex, propertyName) => assertBinaryData(inputData, node, itemIndex, propertyName, 0),
|
|
2544
|
-
getBinaryDataBuffer: async (itemIndex, propertyName) => await getBinaryDataBuffer(inputData, itemIndex, propertyName, 0),
|
|
2545
|
-
returnJsonArray,
|
|
2546
|
-
normalizeItems,
|
|
2547
|
-
constructExecutionMetaData,
|
|
2548
|
-
},
|
|
2549
|
-
};
|
|
1829
|
+
return new node_execution_context_1.ExecuteContext(workflow, node, additionalData, mode, runExecutionData, runIndex, connectionInputData, inputData, executeData, closeFunctions, abortSignal);
|
|
2550
1830
|
}
|
|
2551
1831
|
function getExecuteSingleFunctions(workflow, runExecutionData, runIndex, connectionInputData, inputData, node, itemIndex, additionalData, executeData, mode, abortSignal) {
|
|
2552
1832
|
return new node_execution_context_1.ExecuteSingleContext(workflow, node, additionalData, mode, runExecutionData, runIndex, connectionInputData, inputData, itemIndex, executeData, abortSignal);
|