n8n-core 1.57.0 → 1.58.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/ActiveWorkflows.js +1 -2
- package/dist/ActiveWorkflows.js.map +1 -1
- package/dist/BinaryData/BinaryData.service.js +2 -2
- package/dist/BinaryData/BinaryData.service.js.map +1 -1
- package/dist/BinaryData/FileSystem.manager.js +1 -2
- package/dist/BinaryData/FileSystem.manager.js.map +1 -1
- package/dist/CreateNodeAsTool.d.ts +6 -0
- package/dist/CreateNodeAsTool.js +122 -0
- package/dist/CreateNodeAsTool.js.map +1 -0
- package/dist/DirectoryLoader.js +6 -10
- package/dist/DirectoryLoader.js.map +1 -1
- package/dist/ExtractValue.js +4 -6
- package/dist/ExtractValue.js.map +1 -1
- package/dist/InstanceSettings.js +2 -4
- package/dist/InstanceSettings.js.map +1 -1
- package/dist/NodeExecuteFunctions.js +101 -123
- package/dist/NodeExecuteFunctions.js.map +1 -1
- package/dist/ObjectStore/ObjectStore.service.ee.js +1 -2
- package/dist/ObjectStore/ObjectStore.service.ee.js.map +1 -1
- package/dist/SSHClientsManager.js +1 -2
- package/dist/SSHClientsManager.js.map +1 -1
- package/dist/ScheduledTaskManager.js +1 -2
- package/dist/ScheduledTaskManager.js.map +1 -1
- package/dist/WorkflowExecute.js +15 -20
- package/dist/WorkflowExecute.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/errors/invalid-execution-metadata.error.js +1 -1
- package/dist/errors/invalid-execution-metadata.error.js.map +1 -1
- package/package.json +7 -5
|
@@ -93,6 +93,7 @@ const InstanceSettings_1 = require("./InstanceSettings");
|
|
|
93
93
|
const ScheduledTaskManager_1 = require("./ScheduledTaskManager");
|
|
94
94
|
const SSHClientsManager_1 = require("./SSHClientsManager");
|
|
95
95
|
const utils_1 = require("./BinaryData/utils");
|
|
96
|
+
const CreateNodeAsTool_1 = require("./CreateNodeAsTool");
|
|
96
97
|
axios_1.default.defaults.timeout = 300000;
|
|
97
98
|
axios_1.default.defaults.headers.post = {};
|
|
98
99
|
axios_1.default.defaults.headers.put = {};
|
|
@@ -110,7 +111,7 @@ axios_1.default.interceptors.request.use((config) => {
|
|
|
110
111
|
return config;
|
|
111
112
|
});
|
|
112
113
|
const pushFormDataValue = (form, key, value) => {
|
|
113
|
-
if (
|
|
114
|
+
if (value?.hasOwnProperty('value') && value.hasOwnProperty('options')) {
|
|
114
115
|
form.append(key, value.value, value.options);
|
|
115
116
|
}
|
|
116
117
|
else {
|
|
@@ -176,9 +177,8 @@ async function generateContentLengthHeader(config) {
|
|
|
176
177
|
}
|
|
177
178
|
}
|
|
178
179
|
const getHostFromRequestObject = (requestObject) => {
|
|
179
|
-
var _a;
|
|
180
180
|
try {
|
|
181
|
-
const url = (
|
|
181
|
+
const url = (requestObject.url ?? requestObject.uri);
|
|
182
182
|
return new url_1.URL(url, requestObject.baseURL).hostname;
|
|
183
183
|
}
|
|
184
184
|
catch (error) {
|
|
@@ -186,14 +186,13 @@ const getHostFromRequestObject = (requestObject) => {
|
|
|
186
186
|
}
|
|
187
187
|
};
|
|
188
188
|
const getBeforeRedirectFn = (agentOptions, axiosConfig) => (redirectedRequest) => {
|
|
189
|
-
var _a;
|
|
190
189
|
const redirectAgent = new https_1.Agent({
|
|
191
190
|
...agentOptions,
|
|
192
191
|
servername: redirectedRequest.hostname,
|
|
193
192
|
});
|
|
194
193
|
redirectedRequest.agent = redirectAgent;
|
|
195
194
|
redirectedRequest.agents.https = redirectAgent;
|
|
196
|
-
if (
|
|
195
|
+
if (axiosConfig.headers?.Authorization) {
|
|
197
196
|
redirectedRequest.headers.Authorization = axiosConfig.headers.Authorization;
|
|
198
197
|
}
|
|
199
198
|
if (axiosConfig.auth) {
|
|
@@ -201,7 +200,6 @@ const getBeforeRedirectFn = (agentOptions, axiosConfig) => (redirectedRequest) =
|
|
|
201
200
|
}
|
|
202
201
|
};
|
|
203
202
|
async function parseRequestObject(requestObject) {
|
|
204
|
-
var _a, _b, _c, _d, _e;
|
|
205
203
|
const axiosConfig = {};
|
|
206
204
|
if (requestObject.headers !== undefined) {
|
|
207
205
|
axiosConfig.headers = requestObject.headers;
|
|
@@ -209,7 +207,7 @@ async function parseRequestObject(requestObject) {
|
|
|
209
207
|
const contentTypeHeaderKeyName = axiosConfig.headers &&
|
|
210
208
|
Object.keys(axiosConfig.headers).find((headerName) => headerName.toLowerCase() === 'content-type');
|
|
211
209
|
const contentType = contentTypeHeaderKeyName &&
|
|
212
|
-
|
|
210
|
+
axiosConfig.headers?.[contentTypeHeaderKeyName];
|
|
213
211
|
if (contentType === 'application/x-www-form-urlencoded' && requestObject.formData === undefined) {
|
|
214
212
|
if (typeof requestObject.body === 'string') {
|
|
215
213
|
axiosConfig.data = requestObject.body;
|
|
@@ -224,7 +222,7 @@ async function parseRequestObject(requestObject) {
|
|
|
224
222
|
}
|
|
225
223
|
}
|
|
226
224
|
}
|
|
227
|
-
else if (contentType
|
|
225
|
+
else if (contentType?.includes('multipart/form-data')) {
|
|
228
226
|
if (requestObject.formData !== undefined && requestObject.formData instanceof form_data_1.default) {
|
|
229
227
|
axiosConfig.data = requestObject.formData;
|
|
230
228
|
}
|
|
@@ -235,7 +233,7 @@ async function parseRequestObject(requestObject) {
|
|
|
235
233
|
};
|
|
236
234
|
axiosConfig.data = createFormDataObject(allData);
|
|
237
235
|
}
|
|
238
|
-
|
|
236
|
+
delete axiosConfig.headers?.[contentTypeHeaderKeyName];
|
|
239
237
|
const headers = axiosConfig.data.getHeaders();
|
|
240
238
|
axiosConfig.headers = Object.assign(axiosConfig.headers || {}, headers);
|
|
241
239
|
await generateContentLengthHeader(axiosConfig);
|
|
@@ -263,9 +261,8 @@ async function parseRequestObject(requestObject) {
|
|
|
263
261
|
if (axiosConfig.headers !== undefined) {
|
|
264
262
|
const headers = Object.keys(axiosConfig.headers);
|
|
265
263
|
headers.forEach((header) => {
|
|
266
|
-
var _a;
|
|
267
264
|
if (header.toLowerCase() === 'content-type') {
|
|
268
|
-
|
|
265
|
+
delete axiosConfig.headers?.[header];
|
|
269
266
|
}
|
|
270
267
|
});
|
|
271
268
|
}
|
|
@@ -287,13 +284,13 @@ async function parseRequestObject(requestObject) {
|
|
|
287
284
|
}
|
|
288
285
|
}
|
|
289
286
|
if (requestObject.uri !== undefined) {
|
|
290
|
-
axiosConfig.url =
|
|
287
|
+
axiosConfig.url = requestObject.uri?.toString();
|
|
291
288
|
}
|
|
292
289
|
if (requestObject.url !== undefined) {
|
|
293
|
-
axiosConfig.url =
|
|
290
|
+
axiosConfig.url = requestObject.url?.toString();
|
|
294
291
|
}
|
|
295
292
|
if (requestObject.baseURL !== undefined) {
|
|
296
|
-
axiosConfig.baseURL =
|
|
293
|
+
axiosConfig.baseURL = requestObject.baseURL?.toString();
|
|
297
294
|
}
|
|
298
295
|
if (requestObject.method !== undefined) {
|
|
299
296
|
axiosConfig.method = requestObject.method;
|
|
@@ -467,7 +464,6 @@ async function parseRequestObject(requestObject) {
|
|
|
467
464
|
return axiosConfig;
|
|
468
465
|
}
|
|
469
466
|
function digestAuthAxiosConfig(axiosConfig, response, auth) {
|
|
470
|
-
var _a;
|
|
471
467
|
const authDetails = response.headers['www-authenticate']
|
|
472
468
|
.split(',')
|
|
473
469
|
.map((v) => v.split('='));
|
|
@@ -484,19 +480,19 @@ function digestAuthAxiosConfig(axiosConfig, response, auth) {
|
|
|
484
480
|
.replace(/"/g, '');
|
|
485
481
|
const ha1 = crypto_1.default
|
|
486
482
|
.createHash('md5')
|
|
487
|
-
.update(`${auth
|
|
483
|
+
.update(`${auth?.username}:${realm}:${auth?.password}`)
|
|
488
484
|
.digest('hex');
|
|
489
485
|
const urlURL = new url_1.default.URL(axios_1.default.getUri(axiosConfig));
|
|
490
486
|
const path = urlURL.pathname + urlURL.search;
|
|
491
487
|
const ha2 = crypto_1.default
|
|
492
488
|
.createHash('md5')
|
|
493
|
-
.update(`${
|
|
489
|
+
.update(`${axiosConfig.method ?? 'GET'}:${path}`)
|
|
494
490
|
.digest('hex');
|
|
495
491
|
const response = crypto_1.default
|
|
496
492
|
.createHash('md5')
|
|
497
493
|
.update(`${ha1}:${nonce}:${nonceCount}:${cnonce}:auth:${ha2}`)
|
|
498
494
|
.digest('hex');
|
|
499
|
-
let authorization = `Digest username="${auth
|
|
495
|
+
let authorization = `Digest username="${auth?.username}",realm="${realm}",` +
|
|
500
496
|
`nonce="${nonce}",uri="${path}",qop="auth",algorithm="MD5",` +
|
|
501
497
|
`response="${response}",nc="${nonceCount}",cnonce="${cnonce}"`;
|
|
502
498
|
if (opaque) {
|
|
@@ -529,18 +525,16 @@ function parseContentType(contentType) {
|
|
|
529
525
|
};
|
|
530
526
|
}
|
|
531
527
|
function parseFileName(filename) {
|
|
532
|
-
if (
|
|
528
|
+
if (filename?.startsWith('"') && filename?.endsWith('"')) {
|
|
533
529
|
return filename.slice(1, -1);
|
|
534
530
|
}
|
|
535
531
|
return filename;
|
|
536
532
|
}
|
|
537
533
|
function parseFileNameStar(filename) {
|
|
538
|
-
|
|
539
|
-
const [_encoding, _locale, content] = (_b = (_a = parseFileName(filename)) === null || _a === void 0 ? void 0 : _a.split("'")) !== null && _b !== void 0 ? _b : [];
|
|
534
|
+
const [_encoding, _locale, content] = parseFileName(filename)?.split("'") ?? [];
|
|
540
535
|
return content;
|
|
541
536
|
}
|
|
542
537
|
function parseContentDisposition(contentDisposition) {
|
|
543
|
-
var _a;
|
|
544
538
|
if (!contentDisposition) {
|
|
545
539
|
return null;
|
|
546
540
|
}
|
|
@@ -551,7 +545,7 @@ function parseContentDisposition(contentDisposition) {
|
|
|
551
545
|
const parsedParameters = parseHeaderParameters(parameters);
|
|
552
546
|
return {
|
|
553
547
|
type,
|
|
554
|
-
filename:
|
|
548
|
+
filename: parseFileNameStar(parsedParameters['filename*']) ?? parseFileName(parsedParameters.filename),
|
|
555
549
|
};
|
|
556
550
|
}
|
|
557
551
|
function parseIncomingMessage(message) {
|
|
@@ -575,7 +569,6 @@ async function binaryToString(body, encoding) {
|
|
|
575
569
|
return buffer.toString(encoding);
|
|
576
570
|
}
|
|
577
571
|
async function proxyRequestToAxios(workflow, additionalData, node, uriOrObject, options) {
|
|
578
|
-
var _a, _b, _c;
|
|
579
572
|
let axiosConfig = {
|
|
580
573
|
maxBodyLength: Infinity,
|
|
581
574
|
maxContentLength: Infinity,
|
|
@@ -585,19 +578,18 @@ async function proxyRequestToAxios(workflow, additionalData, node, uriOrObject,
|
|
|
585
578
|
configObject = { uri: uriOrObject, ...options };
|
|
586
579
|
}
|
|
587
580
|
else {
|
|
588
|
-
configObject = uriOrObject
|
|
581
|
+
configObject = uriOrObject ?? {};
|
|
589
582
|
}
|
|
590
583
|
axiosConfig = Object.assign(axiosConfig, await parseRequestObject(configObject));
|
|
591
584
|
let requestFn;
|
|
592
|
-
if (
|
|
585
|
+
if (configObject.auth?.sendImmediately === false) {
|
|
593
586
|
requestFn = async () => {
|
|
594
|
-
var _a;
|
|
595
587
|
try {
|
|
596
588
|
return await (0, axios_1.default)(axiosConfig);
|
|
597
589
|
}
|
|
598
590
|
catch (error) {
|
|
599
591
|
const { response } = error;
|
|
600
|
-
if (
|
|
592
|
+
if (response?.status !== 401 || !response.headers['www-authenticate']?.includes('nonce')) {
|
|
601
593
|
throw error;
|
|
602
594
|
}
|
|
603
595
|
const { auth } = axiosConfig;
|
|
@@ -619,7 +611,7 @@ async function proxyRequestToAxios(workflow, additionalData, node, uriOrObject,
|
|
|
619
611
|
else if (body === '') {
|
|
620
612
|
body = axiosConfig.responseType === 'arraybuffer' ? Buffer.alloc(0) : undefined;
|
|
621
613
|
}
|
|
622
|
-
await
|
|
614
|
+
await additionalData?.hooks?.executeHookFunctions('nodeFetchedData', [workflow?.id, node]);
|
|
623
615
|
return configObject.resolveWithFullResponse
|
|
624
616
|
? {
|
|
625
617
|
body,
|
|
@@ -634,7 +626,7 @@ async function proxyRequestToAxios(workflow, additionalData, node, uriOrObject,
|
|
|
634
626
|
const { config, response } = error;
|
|
635
627
|
if (error.isAxiosError) {
|
|
636
628
|
error.config = error.request = undefined;
|
|
637
|
-
error.options = (0, pick_1.default)(config
|
|
629
|
+
error.options = (0, pick_1.default)(config ?? {}, ['url', 'method', 'data', 'headers']);
|
|
638
630
|
if (response) {
|
|
639
631
|
n8n_workflow_1.LoggerProxy.debug('Request proxied to Axios failed', { status: response.status });
|
|
640
632
|
let responseData = response.data;
|
|
@@ -662,7 +654,7 @@ async function proxyRequestToAxios(workflow, additionalData, node, uriOrObject,
|
|
|
662
654
|
response: (0, pick_1.default)(response, ['headers', 'status', 'statusText']),
|
|
663
655
|
});
|
|
664
656
|
}
|
|
665
|
-
else if ('rejectUnauthorized' in configObject &&
|
|
657
|
+
else if ('rejectUnauthorized' in configObject && error.code?.includes('CERT')) {
|
|
666
658
|
throw new n8n_workflow_1.NodeSslError(error);
|
|
667
659
|
}
|
|
668
660
|
}
|
|
@@ -670,10 +662,9 @@ async function proxyRequestToAxios(workflow, additionalData, node, uriOrObject,
|
|
|
670
662
|
}
|
|
671
663
|
}
|
|
672
664
|
function convertN8nRequestToAxios(n8nRequest) {
|
|
673
|
-
var _a;
|
|
674
665
|
const { headers, method, timeout, auth, proxy, url } = n8nRequest;
|
|
675
666
|
const axiosRequest = {
|
|
676
|
-
headers: headers
|
|
667
|
+
headers: headers ?? {},
|
|
677
668
|
method,
|
|
678
669
|
timeout,
|
|
679
670
|
auth,
|
|
@@ -722,7 +713,7 @@ function convertN8nRequestToAxios(n8nRequest) {
|
|
|
722
713
|
axiosRequest.headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
723
714
|
}
|
|
724
715
|
}
|
|
725
|
-
else if (
|
|
716
|
+
else if (axiosRequest.headers?.[existingContentTypeHeaderKey] === 'application/x-www-form-urlencoded') {
|
|
726
717
|
axiosRequest.data = new url_1.URLSearchParams(n8nRequest.body);
|
|
727
718
|
}
|
|
728
719
|
if (typeof body === 'string' || (typeof body === 'object' && !(0, n8n_workflow_1.isObjectEmpty)(body))) {
|
|
@@ -759,7 +750,6 @@ const removeEmptyBody = (requestOptions) => {
|
|
|
759
750
|
};
|
|
760
751
|
exports.removeEmptyBody = removeEmptyBody;
|
|
761
752
|
async function httpRequest(requestOptions) {
|
|
762
|
-
var _a, _b;
|
|
763
753
|
(0, exports.removeEmptyBody)(requestOptions);
|
|
764
754
|
let axiosRequest = convertN8nRequestToAxios(requestOptions);
|
|
765
755
|
if (axiosRequest.data === undefined ||
|
|
@@ -771,9 +761,9 @@ async function httpRequest(requestOptions) {
|
|
|
771
761
|
result = await (0, axios_1.default)(axiosRequest);
|
|
772
762
|
}
|
|
773
763
|
catch (error) {
|
|
774
|
-
if (
|
|
764
|
+
if (requestOptions.auth?.sendImmediately === false) {
|
|
775
765
|
const { response } = error;
|
|
776
|
-
if (
|
|
766
|
+
if (response?.status !== 401 || !response.headers['www-authenticate']?.includes('nonce')) {
|
|
777
767
|
throw error;
|
|
778
768
|
}
|
|
779
769
|
const { auth } = axiosRequest;
|
|
@@ -864,14 +854,14 @@ async function copyBinaryFile(workflowId, executionId, filePath, fileName, mimeT
|
|
|
864
854
|
return await typedi_1.default.get(BinaryData_service_1.BinaryDataService).copyBinaryFile(workflowId, executionId, returnData, filePath);
|
|
865
855
|
}
|
|
866
856
|
async function prepareBinaryData(binaryData, executionId, workflowId, filePath, mimeType) {
|
|
867
|
-
var _a, _b, _c, _d, _e;
|
|
868
857
|
let fileExtension;
|
|
869
858
|
if (binaryData instanceof http_1.IncomingMessage) {
|
|
870
859
|
if (!filePath) {
|
|
871
860
|
try {
|
|
872
861
|
const { responseUrl } = binaryData;
|
|
873
862
|
filePath =
|
|
874
|
-
|
|
863
|
+
binaryData.contentDisposition?.filename ??
|
|
864
|
+
((responseUrl && new url_1.URL(responseUrl).pathname) ?? binaryData.req?.path)?.slice(1);
|
|
875
865
|
}
|
|
876
866
|
catch { }
|
|
877
867
|
}
|
|
@@ -945,7 +935,6 @@ function applyPaginationRequestData(requestData, paginationRequestData) {
|
|
|
945
935
|
return (0, merge_1.default)({}, requestData, preparedPaginationData);
|
|
946
936
|
}
|
|
947
937
|
async function requestOAuth2(credentialsType, requestOptions, node, additionalData, oAuth2Options, isN8nRequest = false) {
|
|
948
|
-
var _a, _b, _c;
|
|
949
938
|
(0, exports.removeEmptyBody)(requestOptions);
|
|
950
939
|
const credentials = (await this.getCredentials(credentialsType));
|
|
951
940
|
if (credentials.grantType === 'authorizationCode' && credentials.oauthTokenData === undefined) {
|
|
@@ -957,7 +946,7 @@ async function requestOAuth2(credentialsType, requestOptions, node, additionalDa
|
|
|
957
946
|
accessTokenUri: credentials.accessTokenUrl,
|
|
958
947
|
scopes: credentials.scope.split(' '),
|
|
959
948
|
ignoreSSLIssues: credentials.ignoreSSLIssues,
|
|
960
|
-
authentication:
|
|
949
|
+
authentication: credentials.authentication ?? 'header',
|
|
961
950
|
});
|
|
962
951
|
let oauthTokenData = credentials.oauthTokenData;
|
|
963
952
|
if (credentials.grantType === 'clientCredentials' &&
|
|
@@ -965,7 +954,7 @@ async function requestOAuth2(credentialsType, requestOptions, node, additionalDa
|
|
|
965
954
|
Object.keys(oauthTokenData).length === 0 ||
|
|
966
955
|
oauthTokenData.access_token === '')) {
|
|
967
956
|
const { data } = await oAuthClient.credentials.getToken();
|
|
968
|
-
if (!
|
|
957
|
+
if (!node.credentials?.[credentialsType]) {
|
|
969
958
|
throw new n8n_workflow_1.ApplicationError('Node does not have credential type', {
|
|
970
959
|
extra: { nodeName: node.name },
|
|
971
960
|
tags: { credentialType: credentialsType },
|
|
@@ -976,31 +965,30 @@ async function requestOAuth2(credentialsType, requestOptions, node, additionalDa
|
|
|
976
965
|
await additionalData.credentialsHelper.updateCredentials(nodeCredentials, credentialsType, credentials);
|
|
977
966
|
oauthTokenData = data;
|
|
978
967
|
}
|
|
979
|
-
const accessToken = (0, get_1.default)(oauthTokenData, oAuth2Options
|
|
968
|
+
const accessToken = (0, get_1.default)(oauthTokenData, oAuth2Options?.property) || oauthTokenData.accessToken;
|
|
980
969
|
const refreshToken = oauthTokenData.refreshToken;
|
|
981
970
|
const token = oAuthClient.createToken({
|
|
982
971
|
...oauthTokenData,
|
|
983
972
|
...(accessToken ? { access_token: accessToken } : {}),
|
|
984
973
|
...(refreshToken ? { refresh_token: refreshToken } : {}),
|
|
985
|
-
},
|
|
974
|
+
}, oAuth2Options?.tokenType || oauthTokenData.tokenType);
|
|
986
975
|
requestOptions.rejectUnauthorized = !credentials.ignoreSSLIssues;
|
|
987
976
|
const newRequestOptions = token.sign(requestOptions);
|
|
988
|
-
const newRequestHeaders = (newRequestOptions.headers =
|
|
989
|
-
if (
|
|
977
|
+
const newRequestHeaders = (newRequestOptions.headers = newRequestOptions.headers ?? {});
|
|
978
|
+
if (oAuth2Options?.keepBearer === false && typeof newRequestHeaders.Authorization === 'string') {
|
|
990
979
|
newRequestHeaders.Authorization = newRequestHeaders.Authorization.split(' ')[1];
|
|
991
980
|
}
|
|
992
|
-
if (oAuth2Options
|
|
981
|
+
if (oAuth2Options?.keyToIncludeInAccessTokenHeader) {
|
|
993
982
|
Object.assign(newRequestHeaders, {
|
|
994
983
|
[oAuth2Options.keyToIncludeInAccessTokenHeader]: token.accessToken,
|
|
995
984
|
});
|
|
996
985
|
}
|
|
997
986
|
if (isN8nRequest) {
|
|
998
987
|
return await this.helpers.httpRequest(newRequestOptions).catch(async (error) => {
|
|
999
|
-
|
|
1000
|
-
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
|
|
988
|
+
if (error.response?.status === 401) {
|
|
1001
989
|
n8n_workflow_1.LoggerProxy.debug(`OAuth2 token for "${credentialsType}" used by node "${node.name}" expired. Should revalidate.`);
|
|
1002
990
|
const tokenRefreshOptions = {};
|
|
1003
|
-
if (oAuth2Options
|
|
991
|
+
if (oAuth2Options?.includeCredentialsOnRefreshOnBody) {
|
|
1004
992
|
const body = {
|
|
1005
993
|
client_id: credentials.clientId,
|
|
1006
994
|
...(credentials.grantType === 'authorizationCode' && {
|
|
@@ -1022,7 +1010,7 @@ async function requestOAuth2(credentialsType, requestOptions, node, additionalDa
|
|
|
1022
1010
|
}
|
|
1023
1011
|
n8n_workflow_1.LoggerProxy.debug(`OAuth2 token for "${credentialsType}" used by node "${node.name}" has been renewed.`);
|
|
1024
1012
|
credentials.oauthTokenData = newToken.data;
|
|
1025
|
-
if (!
|
|
1013
|
+
if (!node.credentials?.[credentialsType]) {
|
|
1026
1014
|
throw new n8n_workflow_1.ApplicationError('Node does not have credential type', {
|
|
1027
1015
|
extra: { nodeName: node.name, credentialType: credentialsType },
|
|
1028
1016
|
});
|
|
@@ -1030,7 +1018,7 @@ async function requestOAuth2(credentialsType, requestOptions, node, additionalDa
|
|
|
1030
1018
|
const nodeCredentials = node.credentials[credentialsType];
|
|
1031
1019
|
await additionalData.credentialsHelper.updateCredentials(nodeCredentials, credentialsType, credentials);
|
|
1032
1020
|
const refreshedRequestOption = newToken.sign(requestOptions);
|
|
1033
|
-
if (oAuth2Options
|
|
1021
|
+
if (oAuth2Options?.keyToIncludeInAccessTokenHeader) {
|
|
1034
1022
|
Object.assign(newRequestHeaders, {
|
|
1035
1023
|
[oAuth2Options.keyToIncludeInAccessTokenHeader]: token.accessToken,
|
|
1036
1024
|
});
|
|
@@ -1040,9 +1028,9 @@ async function requestOAuth2(credentialsType, requestOptions, node, additionalDa
|
|
|
1040
1028
|
throw error;
|
|
1041
1029
|
});
|
|
1042
1030
|
}
|
|
1043
|
-
const tokenExpiredStatusCode =
|
|
1031
|
+
const tokenExpiredStatusCode = oAuth2Options?.tokenExpiredStatusCode === undefined
|
|
1044
1032
|
? 401
|
|
1045
|
-
: oAuth2Options
|
|
1033
|
+
: oAuth2Options?.tokenExpiredStatusCode;
|
|
1046
1034
|
return await this.helpers
|
|
1047
1035
|
.request(newRequestOptions)
|
|
1048
1036
|
.then((response) => {
|
|
@@ -1055,10 +1043,9 @@ async function requestOAuth2(credentialsType, requestOptions, node, additionalDa
|
|
|
1055
1043
|
return response;
|
|
1056
1044
|
})
|
|
1057
1045
|
.catch(async (error) => {
|
|
1058
|
-
var _a, _b;
|
|
1059
1046
|
if (error.statusCode === tokenExpiredStatusCode) {
|
|
1060
1047
|
const tokenRefreshOptions = {};
|
|
1061
|
-
if (oAuth2Options
|
|
1048
|
+
if (oAuth2Options?.includeCredentialsOnRefreshOnBody) {
|
|
1062
1049
|
const body = {
|
|
1063
1050
|
client_id: credentials.clientId,
|
|
1064
1051
|
client_secret: credentials.clientSecret,
|
|
@@ -1078,7 +1065,7 @@ async function requestOAuth2(credentialsType, requestOptions, node, additionalDa
|
|
|
1078
1065
|
}
|
|
1079
1066
|
n8n_workflow_1.LoggerProxy.debug(`OAuth2 token for "${credentialsType}" used by node "${node.name}" has been renewed.`);
|
|
1080
1067
|
credentials.oauthTokenData = newToken.data;
|
|
1081
|
-
if (!
|
|
1068
|
+
if (!node.credentials?.[credentialsType]) {
|
|
1082
1069
|
throw new n8n_workflow_1.ApplicationError('Node does not have credential type', {
|
|
1083
1070
|
tags: { credentialType: credentialsType },
|
|
1084
1071
|
extra: { nodeName: node.name },
|
|
@@ -1088,8 +1075,8 @@ async function requestOAuth2(credentialsType, requestOptions, node, additionalDa
|
|
|
1088
1075
|
await additionalData.credentialsHelper.updateCredentials(nodeCredentials, credentialsType, credentials);
|
|
1089
1076
|
n8n_workflow_1.LoggerProxy.debug(`OAuth2 token for "${credentialsType}" used by node "${node.name}" has been saved to database successfully.`);
|
|
1090
1077
|
const newRequestOptions = newToken.sign(requestOptions);
|
|
1091
|
-
newRequestOptions.headers =
|
|
1092
|
-
if (oAuth2Options
|
|
1078
|
+
newRequestOptions.headers = newRequestOptions.headers ?? {};
|
|
1079
|
+
if (oAuth2Options?.keyToIncludeInAccessTokenHeader) {
|
|
1093
1080
|
Object.assign(newRequestOptions.headers, {
|
|
1094
1081
|
[oAuth2Options.keyToIncludeInAccessTokenHeader]: token.accessToken,
|
|
1095
1082
|
});
|
|
@@ -1151,7 +1138,6 @@ async function requestOAuth1(credentialsType, requestOptions, isN8nRequest = fal
|
|
|
1151
1138
|
});
|
|
1152
1139
|
}
|
|
1153
1140
|
async function httpRequestWithAuthentication(credentialsType, requestOptions, workflow, node, additionalData, additionalCredentialOptions) {
|
|
1154
|
-
var _a;
|
|
1155
1141
|
(0, exports.removeEmptyBody)(requestOptions);
|
|
1156
1142
|
let credentialsDecrypted;
|
|
1157
1143
|
try {
|
|
@@ -1160,9 +1146,9 @@ async function httpRequestWithAuthentication(credentialsType, requestOptions, wo
|
|
|
1160
1146
|
return await requestOAuth1.call(this, credentialsType, requestOptions, true);
|
|
1161
1147
|
}
|
|
1162
1148
|
if (parentTypes.includes('oAuth2Api')) {
|
|
1163
|
-
return await requestOAuth2.call(this, credentialsType, requestOptions, node, additionalData, additionalCredentialOptions
|
|
1149
|
+
return await requestOAuth2.call(this, credentialsType, requestOptions, node, additionalData, additionalCredentialOptions?.oauth2, true);
|
|
1164
1150
|
}
|
|
1165
|
-
if (additionalCredentialOptions
|
|
1151
|
+
if (additionalCredentialOptions?.credentialsDecrypted) {
|
|
1166
1152
|
credentialsDecrypted = additionalCredentialOptions.credentialsDecrypted.data;
|
|
1167
1153
|
}
|
|
1168
1154
|
else {
|
|
@@ -1180,7 +1166,7 @@ async function httpRequestWithAuthentication(credentialsType, requestOptions, wo
|
|
|
1180
1166
|
return await httpRequest(requestOptions);
|
|
1181
1167
|
}
|
|
1182
1168
|
catch (error) {
|
|
1183
|
-
if (
|
|
1169
|
+
if (error.response?.status === 401 &&
|
|
1184
1170
|
additionalData.credentialsHelper.preAuthentication !== undefined) {
|
|
1185
1171
|
try {
|
|
1186
1172
|
if (credentialsDecrypted !== undefined) {
|
|
@@ -1205,7 +1191,7 @@ function returnJsonArray(jsonData) {
|
|
|
1205
1191
|
jsonData = [jsonData];
|
|
1206
1192
|
}
|
|
1207
1193
|
jsonData.forEach((data) => {
|
|
1208
|
-
if (data
|
|
1194
|
+
if (data?.json) {
|
|
1209
1195
|
returnData.push({ ...data, json: data.json });
|
|
1210
1196
|
}
|
|
1211
1197
|
else {
|
|
@@ -1261,9 +1247,9 @@ async function requestWithAuthentication(credentialsType, requestOptions, workfl
|
|
|
1261
1247
|
return await requestOAuth1.call(this, credentialsType, requestOptions, false);
|
|
1262
1248
|
}
|
|
1263
1249
|
if (credentialsType === 'oAuth2Api' || parentTypes.includes('oAuth2Api')) {
|
|
1264
|
-
return await requestOAuth2.call(this, credentialsType, requestOptions, node, additionalData, additionalCredentialOptions
|
|
1250
|
+
return await requestOAuth2.call(this, credentialsType, requestOptions, node, additionalData, additionalCredentialOptions?.oauth2, false);
|
|
1265
1251
|
}
|
|
1266
|
-
if (additionalCredentialOptions
|
|
1252
|
+
if (additionalCredentialOptions?.credentialsDecrypted) {
|
|
1267
1253
|
credentialsDecrypted = additionalCredentialOptions.credentialsDecrypted.data;
|
|
1268
1254
|
}
|
|
1269
1255
|
else {
|
|
@@ -1342,13 +1328,12 @@ function getAdditionalKeys(additionalData, mode, runExecutionData, options) {
|
|
|
1342
1328
|
: undefined,
|
|
1343
1329
|
},
|
|
1344
1330
|
$vars: additionalData.variables,
|
|
1345
|
-
$secrets:
|
|
1331
|
+
$secrets: options?.secretsEnabled ? (0, Secrets_1.getSecretsProxy)(additionalData) : undefined,
|
|
1346
1332
|
$executionId: executionId,
|
|
1347
1333
|
$resumeWebhookUrl: resumeUrl,
|
|
1348
1334
|
};
|
|
1349
1335
|
}
|
|
1350
1336
|
async function getCredentials(workflow, node, type, additionalData, mode, executeData, runExecutionData, runIndex, connectionInputData, itemIndex) {
|
|
1351
|
-
var _a, _b;
|
|
1352
1337
|
const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
|
|
1353
1338
|
if (nodeType === undefined) {
|
|
1354
1339
|
throw new n8n_workflow_1.NodeOperationError(node, `Node type "${node.type}" is not known so can not get credentials`);
|
|
@@ -1367,8 +1352,8 @@ async function getCredentials(workflow, node, type, additionalData, mode, execut
|
|
|
1367
1352
|
throw new n8n_workflow_1.NodeOperationError(node, 'Credentials not found');
|
|
1368
1353
|
}
|
|
1369
1354
|
}
|
|
1370
|
-
if (!fullAccess && !
|
|
1371
|
-
if (
|
|
1355
|
+
if (!fullAccess && !node.credentials?.[type]) {
|
|
1356
|
+
if (nodeCredentialDescription?.required === true) {
|
|
1372
1357
|
if (!node.credentials) {
|
|
1373
1358
|
throw new n8n_workflow_1.NodeOperationError(node, 'Node does not have any credentials set', {
|
|
1374
1359
|
level: 'warning',
|
|
@@ -1384,7 +1369,7 @@ async function getCredentials(workflow, node, type, additionalData, mode, execut
|
|
|
1384
1369
|
throw new n8n_workflow_1.NodeOperationError(node, 'Node does not require credentials');
|
|
1385
1370
|
}
|
|
1386
1371
|
}
|
|
1387
|
-
if (fullAccess && !
|
|
1372
|
+
if (fullAccess && !node.credentials?.[type]) {
|
|
1388
1373
|
throw new n8n_workflow_1.NodeOperationError(node, 'Credentials not found');
|
|
1389
1374
|
}
|
|
1390
1375
|
let expressionResolveValues;
|
|
@@ -1444,7 +1429,7 @@ const validateResourceMapperValue = (parameterName, paramValues, node, skipRequi
|
|
|
1444
1429
|
const resolvedValue = paramValues[key];
|
|
1445
1430
|
const schemaEntry = schema.find((s) => s.id === key);
|
|
1446
1431
|
if (!skipRequiredCheck &&
|
|
1447
|
-
|
|
1432
|
+
schemaEntry?.required === true &&
|
|
1448
1433
|
schemaEntry.type !== 'boolean' &&
|
|
1449
1434
|
!resolvedValue) {
|
|
1450
1435
|
return {
|
|
@@ -1453,7 +1438,7 @@ const validateResourceMapperValue = (parameterName, paramValues, node, skipRequi
|
|
|
1453
1438
|
fieldName: key,
|
|
1454
1439
|
};
|
|
1455
1440
|
}
|
|
1456
|
-
if (schemaEntry
|
|
1441
|
+
if (schemaEntry?.type) {
|
|
1457
1442
|
const validationResult = (0, n8n_workflow_1.validateFieldType)(key, resolvedValue, schemaEntry.type, {
|
|
1458
1443
|
valueOptions: schemaEntry.options,
|
|
1459
1444
|
});
|
|
@@ -1468,10 +1453,9 @@ const validateResourceMapperValue = (parameterName, paramValues, node, skipRequi
|
|
|
1468
1453
|
return result;
|
|
1469
1454
|
};
|
|
1470
1455
|
const validateCollection = (node, runIndex, itemIndex, propertyDescription, parameterPath, validationResult) => {
|
|
1471
|
-
var _a;
|
|
1472
1456
|
let nestedDescriptions;
|
|
1473
1457
|
if (propertyDescription.type === 'fixedCollection') {
|
|
1474
|
-
nestedDescriptions =
|
|
1458
|
+
nestedDescriptions = propertyDescription.options.find((entry) => entry.name === parameterPath[1])?.values;
|
|
1475
1459
|
}
|
|
1476
1460
|
if (propertyDescription.type === 'collection') {
|
|
1477
1461
|
nestedDescriptions = propertyDescription.options;
|
|
@@ -1517,7 +1501,6 @@ const validateCollection = (node, runIndex, itemIndex, propertyDescription, para
|
|
|
1517
1501
|
return validationResult;
|
|
1518
1502
|
};
|
|
1519
1503
|
const validateValueAgainstSchema = (node, nodeType, parameterValue, parameterName, runIndex, itemIndex) => {
|
|
1520
|
-
var _a, _b;
|
|
1521
1504
|
const parameterPath = parameterName.split('.');
|
|
1522
1505
|
const propertyDescription = nodeType.description.properties.find((prop) => parameterPath[0] === prop.name && n8n_workflow_1.NodeHelpers.displayParameter(node.parameters, prop, node));
|
|
1523
1506
|
if (!propertyDescription) {
|
|
@@ -1532,7 +1515,7 @@ const validateValueAgainstSchema = (node, nodeType, parameterValue, parameterNam
|
|
|
1532
1515
|
else if (propertyDescription.type === 'resourceMapper' &&
|
|
1533
1516
|
parameterPath[1] === 'value' &&
|
|
1534
1517
|
typeof parameterValue === 'object') {
|
|
1535
|
-
validationResult = validateResourceMapperValue(parameterName, parameterValue, node,
|
|
1518
|
+
validationResult = validateResourceMapperValue(parameterName, parameterValue, node, propertyDescription.typeOptions?.resourceMapper?.mode !== 'add');
|
|
1536
1519
|
}
|
|
1537
1520
|
else if (['fixedCollection', 'collection'].includes(propertyDescription.type)) {
|
|
1538
1521
|
validationResult = validateCollection(node, runIndex, itemIndex, propertyDescription, parameterPath, validationResult);
|
|
@@ -1621,7 +1604,6 @@ function ensureType(toType, parameterValue, parameterName, errorOptions) {
|
|
|
1621
1604
|
return returnData;
|
|
1622
1605
|
}
|
|
1623
1606
|
function getNodeParameter(workflow, runExecutionData, runIndex, connectionInputData, node, parameterName, itemIndex, mode, additionalKeys, executeData, fallbackValue, options) {
|
|
1624
|
-
var _a;
|
|
1625
1607
|
const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
|
|
1626
1608
|
if (nodeType === undefined) {
|
|
1627
1609
|
throw new n8n_workflow_1.ApplicationError('Node type is unknown so cannot return parameter value', {
|
|
@@ -1632,12 +1614,12 @@ function getNodeParameter(workflow, runExecutionData, runIndex, connectionInputD
|
|
|
1632
1614
|
if (value === undefined) {
|
|
1633
1615
|
throw new n8n_workflow_1.ApplicationError('Could not get parameter', { extra: { parameterName } });
|
|
1634
1616
|
}
|
|
1635
|
-
if (options
|
|
1617
|
+
if (options?.rawExpressions) {
|
|
1636
1618
|
return value;
|
|
1637
1619
|
}
|
|
1638
1620
|
let returnData;
|
|
1639
1621
|
try {
|
|
1640
|
-
returnData = workflow.expression.getParameterValue(value, runExecutionData, runIndex, itemIndex, node.name, connectionInputData, mode, additionalKeys, executeData, false, {},
|
|
1622
|
+
returnData = workflow.expression.getParameterValue(value, runExecutionData, runIndex, itemIndex, node.name, connectionInputData, mode, additionalKeys, executeData, false, {}, options?.contextNode?.name);
|
|
1641
1623
|
cleanupParameterData(returnData);
|
|
1642
1624
|
}
|
|
1643
1625
|
catch (e) {
|
|
@@ -1651,10 +1633,10 @@ function getNodeParameter(workflow, runExecutionData, runIndex, connectionInputD
|
|
|
1651
1633
|
throw e;
|
|
1652
1634
|
}
|
|
1653
1635
|
}
|
|
1654
|
-
if (options
|
|
1636
|
+
if (options?.extractValue) {
|
|
1655
1637
|
returnData = (0, ExtractValue_1.extractValue)(returnData, parameterName, node, nodeType, itemIndex);
|
|
1656
1638
|
}
|
|
1657
|
-
if (options
|
|
1639
|
+
if (options?.ensureType) {
|
|
1658
1640
|
returnData = ensureType(options.ensureType, returnData, parameterName, {
|
|
1659
1641
|
itemIndex,
|
|
1660
1642
|
runIndex,
|
|
@@ -1700,7 +1682,7 @@ function getWebhookDescription(name, workflow, node) {
|
|
|
1700
1682
|
return undefined;
|
|
1701
1683
|
}
|
|
1702
1684
|
const addExecutionDataFunctions = async (type, nodeName, data, runExecutionData, connectionType, additionalData, sourceNodeName, sourceNodeRunIndex, currentNodeRunIndex) => {
|
|
1703
|
-
if (connectionType ===
|
|
1685
|
+
if (connectionType === "main") {
|
|
1704
1686
|
throw new n8n_workflow_1.ApplicationError('Setting type is not supported for main connection', {
|
|
1705
1687
|
extra: { type },
|
|
1706
1688
|
});
|
|
@@ -1779,7 +1761,6 @@ const addExecutionDataFunctions = async (type, nodeName, data, runExecutionData,
|
|
|
1779
1761
|
}
|
|
1780
1762
|
};
|
|
1781
1763
|
async function getInputConnectionData(workflow, runExecutionData, runIndex, connectionInputData, additionalData, executeData, mode, closeFunctions, inputName, itemIndex) {
|
|
1782
|
-
var _a, _b, _c;
|
|
1783
1764
|
const node = this.getNode();
|
|
1784
1765
|
const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
|
|
1785
1766
|
const inputs = n8n_workflow_1.NodeHelpers.getNodeInputs(workflow, node, nodeType.description);
|
|
@@ -1802,7 +1783,7 @@ async function getInputConnectionData(workflow, runExecutionData, runIndex, conn
|
|
|
1802
1783
|
const parentNodes = workflow.getParentNodes(node.name, inputName, 1);
|
|
1803
1784
|
if (parentNodes.length === 0) {
|
|
1804
1785
|
if (inputConfiguration.required) {
|
|
1805
|
-
throw new n8n_workflow_1.NodeOperationError(node, `A ${
|
|
1786
|
+
throw new n8n_workflow_1.NodeOperationError(node, `A ${inputConfiguration?.displayName ?? inputName} sub-node must be connected`);
|
|
1806
1787
|
}
|
|
1807
1788
|
return inputConfiguration.maxConnections === 1 ? undefined : [];
|
|
1808
1789
|
}
|
|
@@ -1813,11 +1794,6 @@ async function getInputConnectionData(workflow, runExecutionData, runIndex, conn
|
|
|
1813
1794
|
.filter((connectedNode) => connectedNode.disabled !== true)
|
|
1814
1795
|
.map(async (connectedNode) => {
|
|
1815
1796
|
const nodeType = workflow.nodeTypes.getByNameAndVersion(connectedNode.type, connectedNode.typeVersion);
|
|
1816
|
-
if (!nodeType.supplyData) {
|
|
1817
|
-
throw new n8n_workflow_1.ApplicationError('Node does not have a `supplyData` method defined', {
|
|
1818
|
-
extra: { nodeName: connectedNode.name },
|
|
1819
|
-
});
|
|
1820
|
-
}
|
|
1821
1797
|
const context = Object.assign({}, this);
|
|
1822
1798
|
context.getNodeParameter = (parameterName, itemIndex, fallbackValue, options) => {
|
|
1823
1799
|
return getNodeParameter(workflow, runExecutionData, runIndex, connectionInputData, connectedNode, parameterName, itemIndex, mode, getAdditionalKeys(additionalData, mode, runExecutionData), executeData, fallbackValue, { ...(options || {}), contextNode: node });
|
|
@@ -1838,6 +1814,18 @@ async function getInputConnectionData(workflow, runExecutionData, runIndex, conn
|
|
|
1838
1814
|
throw error;
|
|
1839
1815
|
}
|
|
1840
1816
|
};
|
|
1817
|
+
if (!nodeType.supplyData) {
|
|
1818
|
+
if (nodeType.description.outputs.includes("ai_tool")) {
|
|
1819
|
+
nodeType.supplyData = async function () {
|
|
1820
|
+
return (0, CreateNodeAsTool_1.getNodeAsTool)(this, nodeType, this.getNode().parameters);
|
|
1821
|
+
};
|
|
1822
|
+
}
|
|
1823
|
+
else {
|
|
1824
|
+
throw new n8n_workflow_1.ApplicationError('Node does not have a `supplyData` method defined', {
|
|
1825
|
+
extra: { nodeName: connectedNode.name },
|
|
1826
|
+
});
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1841
1829
|
try {
|
|
1842
1830
|
const response = await nodeType.supplyData.call(context, itemIndex);
|
|
1843
1831
|
if (response.closeFunction) {
|
|
@@ -1867,14 +1855,14 @@ async function getInputConnectionData(workflow, runExecutionData, runIndex, conn
|
|
|
1867
1855
|
});
|
|
1868
1856
|
const nodes = await Promise.all(constParentNodes);
|
|
1869
1857
|
if (inputConfiguration.required && nodes.length === 0) {
|
|
1870
|
-
throw new n8n_workflow_1.NodeOperationError(node, `A ${
|
|
1858
|
+
throw new n8n_workflow_1.NodeOperationError(node, `A ${inputConfiguration?.displayName ?? inputName} sub-node must be connected`);
|
|
1871
1859
|
}
|
|
1872
1860
|
if (inputConfiguration.maxConnections !== undefined &&
|
|
1873
1861
|
nodes.length > inputConfiguration.maxConnections) {
|
|
1874
1862
|
throw new n8n_workflow_1.NodeOperationError(node, `Only ${inputConfiguration.maxConnections} ${inputName} sub-nodes are/is allowed to be connected`);
|
|
1875
1863
|
}
|
|
1876
1864
|
return inputConfiguration.maxConnections === 1
|
|
1877
|
-
? (
|
|
1865
|
+
? (nodes || [])[0]?.response
|
|
1878
1866
|
: nodes.map((node) => node.response);
|
|
1879
1867
|
}
|
|
1880
1868
|
const getCommonWorkflowFunctions = (workflow, node, additionalData) => ({
|
|
@@ -1925,10 +1913,10 @@ const executionCancellationFunctions = (abortSignal) => ({
|
|
|
1925
1913
|
getExecutionCancelSignal: () => abortSignal,
|
|
1926
1914
|
onExecutionCancellation: (handler) => {
|
|
1927
1915
|
const fn = () => {
|
|
1928
|
-
abortSignal
|
|
1916
|
+
abortSignal?.removeEventListener('abort', fn);
|
|
1929
1917
|
handler();
|
|
1930
1918
|
};
|
|
1931
|
-
abortSignal
|
|
1919
|
+
abortSignal?.addEventListener('abort', fn);
|
|
1932
1920
|
},
|
|
1933
1921
|
});
|
|
1934
1922
|
const getRequestHelperFunctions = (workflow, node, additionalData) => {
|
|
@@ -1938,14 +1926,13 @@ const getRequestHelperFunctions = (workflow, node, additionalData) => {
|
|
|
1938
1926
|
const mode = 'internal';
|
|
1939
1927
|
if (typeof parameterValue === 'object' ||
|
|
1940
1928
|
(typeof parameterValue === 'string' && parameterValue.charAt(0) === '=')) {
|
|
1941
|
-
return workflow.expression.getParameterValue(parameterValue, runExecutionData, runIndex, itemIndex, node.name, connectionInputData, mode, additionalKeys
|
|
1929
|
+
return workflow.expression.getParameterValue(parameterValue, runExecutionData, runIndex, itemIndex, node.name, connectionInputData, mode, additionalKeys ?? {}, executeData, returnObjectAsString);
|
|
1942
1930
|
}
|
|
1943
1931
|
return parameterValue;
|
|
1944
1932
|
};
|
|
1945
1933
|
return {
|
|
1946
1934
|
httpRequest,
|
|
1947
1935
|
async requestWithAuthenticationPaginated(requestOptions, itemIndex, paginationOptions, credentialsType, additionalCredentialOptions) {
|
|
1948
|
-
var _a, _b;
|
|
1949
1936
|
const responseData = [];
|
|
1950
1937
|
if (!requestOptions.qs) {
|
|
1951
1938
|
requestOptions.qs = {};
|
|
@@ -1996,7 +1983,7 @@ const getRequestHelperFunctions = (workflow, node, additionalData) => {
|
|
|
1996
1983
|
let contentBody;
|
|
1997
1984
|
if (newResponse.body instanceof stream_1.Readable && paginationOptions.binaryResult !== true) {
|
|
1998
1985
|
contentBody = await binaryToString(newResponse.body);
|
|
1999
|
-
const responseContentType =
|
|
1986
|
+
const responseContentType = newResponse.headers['content-type']?.toString() ?? '';
|
|
2000
1987
|
if (responseContentType.includes('application/json')) {
|
|
2001
1988
|
newResponse.body = (0, n8n_workflow_1.jsonParse)(contentBody, { fallbackValue: {} });
|
|
2002
1989
|
}
|
|
@@ -2065,7 +2052,7 @@ const getRequestHelperFunctions = (workflow, node, additionalData) => {
|
|
|
2065
2052
|
else if (typeof data === 'object') {
|
|
2066
2053
|
data = JSON.stringify(data);
|
|
2067
2054
|
}
|
|
2068
|
-
throw Object.assign(new Error(`${tempResponseData.statusCode} - "${data
|
|
2055
|
+
throw Object.assign(new Error(`${tempResponseData.statusCode} - "${data?.toString()}"`), {
|
|
2069
2056
|
statusCode: tempResponseData.statusCode,
|
|
2070
2057
|
error: data,
|
|
2071
2058
|
isAxiosError: true,
|
|
@@ -2286,21 +2273,16 @@ function getExecuteFunctions(workflow, runExecutionData, runIndex, connectionInp
|
|
|
2286
2273
|
getMode: () => mode,
|
|
2287
2274
|
getCredentials: async (type, itemIndex) => await getCredentials(workflow, node, type, additionalData, mode, executeData, runExecutionData, runIndex, connectionInputData, itemIndex),
|
|
2288
2275
|
getExecuteData: () => executeData,
|
|
2289
|
-
continueOnFail: (
|
|
2290
|
-
|
|
2291
|
-
if (error && shouldContinue && !(error instanceof n8n_workflow_1.ApplicationError)) {
|
|
2292
|
-
error.message = n8n_workflow_1.OBFUSCATED_ERROR_MESSAGE;
|
|
2293
|
-
}
|
|
2294
|
-
return shouldContinue;
|
|
2276
|
+
continueOnFail: () => {
|
|
2277
|
+
return continueOnFail(node);
|
|
2295
2278
|
},
|
|
2296
2279
|
evaluateExpression: (expression, itemIndex) => {
|
|
2297
2280
|
return workflow.expression.resolveSimpleParameterValue(`=${expression}`, {}, runExecutionData, runIndex, itemIndex, node.name, connectionInputData, mode, getAdditionalKeys(additionalData, mode, runExecutionData), executeData);
|
|
2298
2281
|
},
|
|
2299
2282
|
async executeWorkflow(workflowInfo, inputData, parentCallbackManager) {
|
|
2300
|
-
var _a;
|
|
2301
2283
|
return await additionalData
|
|
2302
2284
|
.executeWorkflow(workflowInfo, additionalData, {
|
|
2303
|
-
parentWorkflowId:
|
|
2285
|
+
parentWorkflowId: workflow.id?.toString(),
|
|
2304
2286
|
inputData,
|
|
2305
2287
|
parentWorkflowSettings: workflow.settings,
|
|
2306
2288
|
node,
|
|
@@ -2353,7 +2335,7 @@ function getExecuteFunctions(workflow, runExecutionData, runIndex, connectionInp
|
|
|
2353
2335
|
return inputData[inputName][inputIndex];
|
|
2354
2336
|
},
|
|
2355
2337
|
getInputSourceData: (inputIndex = 0, inputName = 'main') => {
|
|
2356
|
-
if (
|
|
2338
|
+
if (executeData?.source === null) {
|
|
2357
2339
|
throw new n8n_workflow_1.ApplicationError('Source data is missing');
|
|
2358
2340
|
}
|
|
2359
2341
|
return executeData.source[inputName][inputIndex];
|
|
@@ -2397,8 +2379,7 @@ function getExecuteFunctions(workflow, runExecutionData, runIndex, connectionInp
|
|
|
2397
2379
|
}
|
|
2398
2380
|
},
|
|
2399
2381
|
async sendResponse(response) {
|
|
2400
|
-
|
|
2401
|
-
await ((_a = additionalData.hooks) === null || _a === void 0 ? void 0 : _a.executeHookFunctions('sendResponse', [response]));
|
|
2382
|
+
await additionalData.hooks?.executeHookFunctions('sendResponse', [response]);
|
|
2402
2383
|
},
|
|
2403
2384
|
addInputData(connectionType, data) {
|
|
2404
2385
|
const nodeName = this.getNode().name;
|
|
@@ -2431,13 +2412,12 @@ function getExecuteFunctions(workflow, runExecutionData, runIndex, connectionInp
|
|
|
2431
2412
|
},
|
|
2432
2413
|
nodeHelpers: getNodeHelperFunctions(additionalData, workflow.id),
|
|
2433
2414
|
logAiEvent: async (eventName, msg) => {
|
|
2434
|
-
var _a, _b, _c;
|
|
2435
2415
|
return await additionalData.logAiEvent(eventName, {
|
|
2436
|
-
executionId:
|
|
2416
|
+
executionId: additionalData.executionId ?? 'unsaved-execution',
|
|
2437
2417
|
nodeName: node.name,
|
|
2438
|
-
workflowName:
|
|
2418
|
+
workflowName: workflow.name ?? 'Unnamed workflow',
|
|
2439
2419
|
nodeType: node.type,
|
|
2440
|
-
workflowId:
|
|
2420
|
+
workflowId: workflow.id ?? 'unsaved-workflow',
|
|
2441
2421
|
msg,
|
|
2442
2422
|
});
|
|
2443
2423
|
},
|
|
@@ -2482,7 +2462,7 @@ function getExecuteSingleFunctions(workflow, runExecutionData, runIndex, connect
|
|
|
2482
2462
|
return allItems[itemIndex];
|
|
2483
2463
|
},
|
|
2484
2464
|
getInputSourceData: (inputIndex = 0, inputName = 'main') => {
|
|
2485
|
-
if (
|
|
2465
|
+
if (executeData?.source === null) {
|
|
2486
2466
|
throw new n8n_workflow_1.ApplicationError('Source data is missing');
|
|
2487
2467
|
}
|
|
2488
2468
|
return executeData.source[inputName][inputIndex];
|
|
@@ -2505,13 +2485,12 @@ function getExecuteSingleFunctions(workflow, runExecutionData, runIndex, connect
|
|
|
2505
2485
|
getBinaryDataBuffer: async (propertyName, inputIndex = 0) => await getBinaryDataBuffer(inputData, itemIndex, propertyName, inputIndex),
|
|
2506
2486
|
},
|
|
2507
2487
|
logAiEvent: async (eventName, msg) => {
|
|
2508
|
-
var _a, _b, _c;
|
|
2509
2488
|
return await additionalData.logAiEvent(eventName, {
|
|
2510
|
-
executionId:
|
|
2489
|
+
executionId: additionalData.executionId ?? 'unsaved-execution',
|
|
2511
2490
|
nodeName: node.name,
|
|
2512
|
-
workflowName:
|
|
2491
|
+
workflowName: workflow.name ?? 'Unnamed workflow',
|
|
2513
2492
|
nodeType: node.type,
|
|
2514
|
-
workflowId:
|
|
2493
|
+
workflowId: workflow.id ?? 'unsaved-workflow',
|
|
2515
2494
|
msg,
|
|
2516
2495
|
});
|
|
2517
2496
|
},
|
|
@@ -2539,7 +2518,7 @@ function getLoadOptionsFunctions(workflow, node, path, additionalData) {
|
|
|
2539
2518
|
parameterPath = `${path.split('.').slice(1, -1).join('.')}.${parameterPath.slice(1)}`;
|
|
2540
2519
|
}
|
|
2541
2520
|
let returnData = (0, get_1.default)(nodeParameters, parameterPath);
|
|
2542
|
-
if (options
|
|
2521
|
+
if (options?.extractValue) {
|
|
2543
2522
|
const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
|
|
2544
2523
|
if (nodeType === undefined) {
|
|
2545
2524
|
throw new n8n_workflow_1.ApplicationError('Node type is not known so cannot return parameter value', {
|
|
@@ -2581,7 +2560,7 @@ function getExecuteHookFunctions(workflow, node, additionalData, mode, activatio
|
|
|
2581
2560
|
return getNodeParameter(workflow, runExecutionData, runIndex, connectionInputData, node, parameterName, itemIndex, mode, getAdditionalKeys(additionalData, mode, runExecutionData), undefined, fallbackValue, options);
|
|
2582
2561
|
},
|
|
2583
2562
|
getNodeWebhookUrl: (name) => {
|
|
2584
|
-
return getNodeWebhookUrl(name, workflow, node, additionalData, mode, getAdditionalKeys(additionalData, mode, null), webhookData
|
|
2563
|
+
return getNodeWebhookUrl(name, workflow, node, additionalData, mode, getAdditionalKeys(additionalData, mode, null), webhookData?.isTest);
|
|
2585
2564
|
},
|
|
2586
2565
|
getWebhookName() {
|
|
2587
2566
|
if (webhookData === undefined) {
|
|
@@ -2612,9 +2591,8 @@ function getExecuteWebhookFunctions(workflow, node, additionalData, mode, webhoo
|
|
|
2612
2591
|
return additionalData.httpRequest.headers;
|
|
2613
2592
|
},
|
|
2614
2593
|
async getInputConnectionData(inputName, itemIndex) {
|
|
2615
|
-
var _a;
|
|
2616
2594
|
const connectionInputData = [
|
|
2617
|
-
{ json:
|
|
2595
|
+
{ json: additionalData.httpRequest?.body || {} },
|
|
2618
2596
|
];
|
|
2619
2597
|
const runExecutionData = {
|
|
2620
2598
|
resultData: {
|
|
@@ -2637,7 +2615,7 @@ function getExecuteWebhookFunctions(workflow, node, additionalData, mode, webhoo
|
|
|
2637
2615
|
const runIndex = 0;
|
|
2638
2616
|
let connectionInputData = [];
|
|
2639
2617
|
let executionData;
|
|
2640
|
-
if (
|
|
2618
|
+
if (runExecutionData?.executionData !== undefined) {
|
|
2641
2619
|
executionData = runExecutionData.executionData.nodeExecutionStack[0];
|
|
2642
2620
|
if (executionData !== undefined) {
|
|
2643
2621
|
connectionInputData = executionData.data.main[0];
|