n8n-nodes-base 1.89.0 → 1.90.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/credentials/CustomerIoApi.credentials.js +2 -2
- package/dist/credentials/CustomerIoApi.credentials.js.map +1 -1
- package/dist/nodes/Aws/__tests__/credentials.js +35 -0
- package/dist/nodes/Aws/__tests__/credentials.js.map +1 -0
- package/dist/nodes/Code/Pyodide.js +16 -1
- package/dist/nodes/Code/Pyodide.js.map +1 -1
- package/dist/nodes/EmailReadImap/v2/EmailReadImapV2.node.js +1 -1
- package/dist/nodes/EmailReadImap/v2/EmailReadImapV2.node.js.map +1 -1
- package/dist/nodes/ExecuteWorkflow/ExecuteWorkflow/methods/localResourceMapping.js +3 -1
- package/dist/nodes/ExecuteWorkflow/ExecuteWorkflow/methods/localResourceMapping.js.map +1 -1
- package/dist/nodes/Form/formCompletionUtils.js +1 -3
- package/dist/nodes/Form/formCompletionUtils.js.map +1 -1
- package/dist/nodes/Google/Sheet/GoogleSheetsTrigger.node.js +12 -4
- package/dist/nodes/Google/Sheet/GoogleSheetsTrigger.node.js.map +1 -1
- package/dist/nodes/Jira/GenericFunctions.js +7 -3
- package/dist/nodes/Jira/GenericFunctions.js.map +1 -1
- package/dist/nodes/Jira/Jira.node.js +4 -6
- package/dist/nodes/Jira/Jira.node.js.map +1 -1
- package/dist/nodes/Microsoft/AzureCosmosDb/test/credentials.js +36 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/test/credentials.js.map +1 -0
- package/dist/nodes/Microsoft/Excel/test/credentials.js +36 -0
- package/dist/nodes/Microsoft/Excel/test/credentials.js.map +1 -0
- package/dist/nodes/Microsoft/Storage/test/credentials.js +57 -0
- package/dist/nodes/Microsoft/Storage/test/credentials.js.map +1 -0
- package/dist/nodes/Microsoft/Teams/test/credentials.js +36 -0
- package/dist/nodes/Microsoft/Teams/test/credentials.js.map +1 -0
- package/dist/nodes/SplitInBatches/v3/SplitInBatchesV3.node.js +1 -1
- package/dist/nodes/SplitInBatches/v3/SplitInBatchesV3.node.js.map +1 -1
- package/dist/nodes/Wordpress/__tests__/workflow/credentials.js +36 -0
- package/dist/nodes/Wordpress/__tests__/workflow/credentials.js.map +1 -0
- package/dist/test/globalSetup.js +3 -0
- package/dist/test/globalSetup.js.map +1 -1
- package/dist/test/nodes/ExecuteWorkflow.js +3 -2
- package/dist/test/nodes/ExecuteWorkflow.js.map +1 -1
- package/dist/test/nodes/Helpers.js +4 -17
- package/dist/test/nodes/Helpers.js.map +1 -1
- package/dist/test/nodes/credentials-helper.js +9 -13
- package/dist/test/nodes/credentials-helper.js.map +1 -1
- package/dist/types/nodes.json +3 -3
- package/dist/utils/workflowInputsResourceMapping/GenericFunctions.js +6 -1
- package/dist/utils/workflowInputsResourceMapping/GenericFunctions.js.map +1 -1
- package/package.json +11 -10
- package/dist/test/nodes/FakeCredentialsMap.js +0 -313
- package/dist/test/nodes/FakeCredentialsMap.js.map +0 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var credentials_exports = {};
|
|
20
|
+
__export(credentials_exports, {
|
|
21
|
+
credentials: () => credentials
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(credentials_exports);
|
|
24
|
+
const credentials = {
|
|
25
|
+
azureStorageOAuth2Api: {
|
|
26
|
+
grantType: "authorizationCode",
|
|
27
|
+
authUrl: "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
|
|
28
|
+
accessTokenUrl: "https://login.microsoftonline.com/common/oauth2/v2.0/token",
|
|
29
|
+
clientId: "CLIENTID",
|
|
30
|
+
clientSecret: "CLIENTSECRET",
|
|
31
|
+
scope: "https://storage.azure.com/user_impersonation",
|
|
32
|
+
authQueryParameters: "response_mode=query",
|
|
33
|
+
authentication: "body",
|
|
34
|
+
oauthTokenData: {
|
|
35
|
+
token_type: "Bearer",
|
|
36
|
+
scope: "https://storage.azure.com/user_impersonation",
|
|
37
|
+
expires_in: 4730,
|
|
38
|
+
ext_expires_in: 4730,
|
|
39
|
+
access_token: "ACCESSTOKEN",
|
|
40
|
+
callbackQueryString: {
|
|
41
|
+
session_state: "SESSIONSTATE"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
account: "myaccount",
|
|
45
|
+
baseUrl: "https://myaccount.blob.core.windows.net"
|
|
46
|
+
},
|
|
47
|
+
azureStorageSharedKeyApi: {
|
|
48
|
+
account: "devstoreaccount1",
|
|
49
|
+
key: "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==",
|
|
50
|
+
baseUrl: "https://myaccount.blob.core.windows.net"
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
+
0 && (module.exports = {
|
|
55
|
+
credentials
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../nodes/Microsoft/Storage/test/credentials.ts"],"sourcesContent":["export const credentials = {\n\tazureStorageOAuth2Api: {\n\t\tgrantType: 'authorizationCode',\n\t\tauthUrl: 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',\n\t\taccessTokenUrl: 'https://login.microsoftonline.com/common/oauth2/v2.0/token',\n\t\tclientId: 'CLIENTID',\n\t\tclientSecret: 'CLIENTSECRET',\n\t\tscope: 'https://storage.azure.com/user_impersonation',\n\t\tauthQueryParameters: 'response_mode=query',\n\t\tauthentication: 'body',\n\t\toauthTokenData: {\n\t\t\ttoken_type: 'Bearer',\n\t\t\tscope: 'https://storage.azure.com/user_impersonation',\n\t\t\texpires_in: 4730,\n\t\t\text_expires_in: 4730,\n\t\t\taccess_token: 'ACCESSTOKEN',\n\t\t\tcallbackQueryString: {\n\t\t\t\tsession_state: 'SESSIONSTATE',\n\t\t\t},\n\t\t},\n\t\taccount: 'myaccount',\n\t\tbaseUrl: 'https://myaccount.blob.core.windows.net',\n\t},\n\tazureStorageSharedKeyApi: {\n\t\taccount: 'devstoreaccount1',\n\t\tkey: 'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==',\n\t\tbaseUrl: 'https://myaccount.blob.core.windows.net',\n\t},\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,cAAc;AAAA,EAC1B,uBAAuB;AAAA,IACtB,WAAW;AAAA,IACX,SAAS;AAAA,IACT,gBAAgB;AAAA,IAChB,UAAU;AAAA,IACV,cAAc;AAAA,IACd,OAAO;AAAA,IACP,qBAAqB;AAAA,IACrB,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,MACf,YAAY;AAAA,MACZ,OAAO;AAAA,MACP,YAAY;AAAA,MACZ,gBAAgB;AAAA,MAChB,cAAc;AAAA,MACd,qBAAqB;AAAA,QACpB,eAAe;AAAA,MAChB;AAAA,IACD;AAAA,IACA,SAAS;AAAA,IACT,SAAS;AAAA,EACV;AAAA,EACA,0BAA0B;AAAA,IACzB,SAAS;AAAA,IACT,KAAK;AAAA,IACL,SAAS;AAAA,EACV;AACD;","names":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var credentials_exports = {};
|
|
20
|
+
__export(credentials_exports, {
|
|
21
|
+
credentials: () => credentials
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(credentials_exports);
|
|
24
|
+
const credentials = {
|
|
25
|
+
microsoftTeamsOAuth2Api: {
|
|
26
|
+
scope: "openid",
|
|
27
|
+
oauthTokenData: {
|
|
28
|
+
access_token: "token"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
credentials
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../nodes/Microsoft/Teams/test/credentials.ts"],"sourcesContent":["export const credentials = {\n\tmicrosoftTeamsOAuth2Api: {\n\t\tscope: 'openid',\n\t\toauthTokenData: {\n\t\t\taccess_token: 'token',\n\t\t},\n\t},\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,cAAc;AAAA,EAC1B,yBAAyB;AAAA,IACxB,OAAO;AAAA,IACP,gBAAgB;AAAA,MACf,cAAc;AAAA,IACf;AAAA,EACD;AACD;","names":[]}
|
|
@@ -68,7 +68,7 @@ class SplitInBatchesV3 {
|
|
|
68
68
|
name: "reset",
|
|
69
69
|
type: "boolean",
|
|
70
70
|
default: false,
|
|
71
|
-
description: "Whether the node
|
|
71
|
+
description: "Whether the node starts again from the beginning of the input items. This will treat incoming data as a new set rather than continuing with the previous items."
|
|
72
72
|
}
|
|
73
73
|
]
|
|
74
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/SplitInBatches/v3/SplitInBatchesV3.node.ts"],"sourcesContent":["import type {\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeType,\n\tINodeTypeDescription,\n\tIPairedItemData,\n} from 'n8n-workflow';\nimport { NodeConnectionTypes, deepCopy } from 'n8n-workflow';\n\nexport class SplitInBatchesV3 implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Loop Over Items (Split in Batches)',\n\t\tname: 'splitInBatches',\n\t\ticon: 'fa:sync',\n\t\ticonColor: 'dark-green',\n\t\tgroup: ['organization'],\n\t\tversion: 3,\n\t\tdescription: 'Split data into batches and iterate over each batch',\n\t\tdefaults: {\n\t\t\tname: 'Loop Over Items',\n\t\t\tcolor: '#007755',\n\t\t},\n\t\tinputs: [NodeConnectionTypes.Main],\n\n\t\toutputs: [NodeConnectionTypes.Main, NodeConnectionTypes.Main],\n\t\toutputNames: ['done', 'loop'],\n\t\tproperties: [\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'You may not need this node — n8n nodes automatically run once for each input item. <a href=\"https://docs.n8n.io/getting-started/key-concepts/looping.html#using-loops-in-n8n\" target=\"_blank\">More info</a>',\n\t\t\t\tname: 'splitInBatchesNotice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Batch Size',\n\t\t\t\tname: 'batchSize',\n\t\t\t\ttype: 'number',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tminValue: 1,\n\t\t\t\t},\n\t\t\t\tdefault: 1,\n\t\t\t\tdescription: 'The number of items to return with each call',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'collection',\n\t\t\t\tplaceholder: 'Add option',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Reset',\n\t\t\t\t\t\tname: 'reset',\n\t\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\t\tdefault: false,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Whether the node
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/SplitInBatches/v3/SplitInBatchesV3.node.ts"],"sourcesContent":["import type {\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeType,\n\tINodeTypeDescription,\n\tIPairedItemData,\n} from 'n8n-workflow';\nimport { NodeConnectionTypes, deepCopy } from 'n8n-workflow';\n\nexport class SplitInBatchesV3 implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Loop Over Items (Split in Batches)',\n\t\tname: 'splitInBatches',\n\t\ticon: 'fa:sync',\n\t\ticonColor: 'dark-green',\n\t\tgroup: ['organization'],\n\t\tversion: 3,\n\t\tdescription: 'Split data into batches and iterate over each batch',\n\t\tdefaults: {\n\t\t\tname: 'Loop Over Items',\n\t\t\tcolor: '#007755',\n\t\t},\n\t\tinputs: [NodeConnectionTypes.Main],\n\n\t\toutputs: [NodeConnectionTypes.Main, NodeConnectionTypes.Main],\n\t\toutputNames: ['done', 'loop'],\n\t\tproperties: [\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'You may not need this node — n8n nodes automatically run once for each input item. <a href=\"https://docs.n8n.io/getting-started/key-concepts/looping.html#using-loops-in-n8n\" target=\"_blank\">More info</a>',\n\t\t\t\tname: 'splitInBatchesNotice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Batch Size',\n\t\t\t\tname: 'batchSize',\n\t\t\t\ttype: 'number',\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tminValue: 1,\n\t\t\t\t},\n\t\t\t\tdefault: 1,\n\t\t\t\tdescription: 'The number of items to return with each call',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'collection',\n\t\t\t\tplaceholder: 'Add option',\n\t\t\t\tdefault: {},\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Reset',\n\t\t\t\t\t\tname: 'reset',\n\t\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\t\tdefault: false,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Whether the node starts again from the beginning of the input items. This will treat incoming data as a new set rather than continuing with the previous items.',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tasync execute(this: IExecuteFunctions): Promise<INodeExecutionData[][] | null> {\n\t\t// Get the input data and create a new array so that we can remove\n\t\t// items without a problem\n\t\tconst items = this.getInputData().slice();\n\n\t\tconst nodeContext = this.getContext('node');\n\n\t\tconst batchSize = this.getNodeParameter('batchSize', 0) as number;\n\n\t\tconst returnItems: INodeExecutionData[] = [];\n\n\t\tconst options = this.getNodeParameter('options', 0, {});\n\n\t\tif (nodeContext.items === undefined || options.reset === true) {\n\t\t\t// Is the first time the node runs\n\n\t\t\tconst sourceData = this.getInputSourceData();\n\n\t\t\tnodeContext.currentRunIndex = 0;\n\t\t\tnodeContext.maxRunIndex = Math.ceil(items.length / batchSize);\n\t\t\tnodeContext.sourceData = deepCopy(sourceData);\n\n\t\t\t// Get the items which should be returned\n\t\t\treturnItems.push.apply(returnItems, items.splice(0, batchSize));\n\n\t\t\t// Save the incoming items to be able to return them for later runs\n\t\t\tnodeContext.items = [...items];\n\n\t\t\t// Reset processedItems as they get only added starting from the first iteration\n\t\t\tnodeContext.processedItems = [];\n\t\t} else {\n\t\t\t// The node has been called before. So return the next batch of items.\n\t\t\tnodeContext.currentRunIndex += 1;\n\t\t\treturnItems.push.apply(\n\t\t\t\treturnItems,\n\t\t\t\t(nodeContext.items as INodeExecutionData[]).splice(0, batchSize),\n\t\t\t);\n\n\t\t\tconst addSourceOverwrite = (pairedItem: IPairedItemData | number): IPairedItemData => {\n\t\t\t\tif (typeof pairedItem === 'number') {\n\t\t\t\t\treturn {\n\t\t\t\t\t\titem: pairedItem,\n\t\t\t\t\t\tsourceOverwrite: nodeContext.sourceData,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...pairedItem,\n\t\t\t\t\tsourceOverwrite: nodeContext.sourceData,\n\t\t\t\t};\n\t\t\t};\n\n\t\t\tfunction getPairedItemInformation(\n\t\t\t\titem: INodeExecutionData,\n\t\t\t): IPairedItemData | IPairedItemData[] {\n\t\t\t\tif (item.pairedItem === undefined) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\titem: 0,\n\t\t\t\t\t\tsourceOverwrite: nodeContext.sourceData,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tif (Array.isArray(item.pairedItem)) {\n\t\t\t\t\treturn item.pairedItem.map(addSourceOverwrite);\n\t\t\t\t}\n\n\t\t\t\treturn addSourceOverwrite(item.pairedItem);\n\t\t\t}\n\n\t\t\tconst sourceOverwrite = this.getInputSourceData();\n\n\t\t\tconst newItems = items.map((item, index) => {\n\t\t\t\treturn {\n\t\t\t\t\t...item,\n\t\t\t\t\tpairedItem: {\n\t\t\t\t\t\tsourceOverwrite,\n\t\t\t\t\t\titem: index,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t});\n\n\t\t\tnodeContext.processedItems = [...nodeContext.processedItems, ...newItems];\n\n\t\t\treturnItems.map((item) => {\n\t\t\t\titem.pairedItem = getPairedItemInformation(item);\n\t\t\t});\n\t\t}\n\n\t\tnodeContext.noItemsLeft = nodeContext.items.length === 0;\n\n\t\tif (returnItems.length === 0) {\n\t\t\tnodeContext.done = true;\n\t\t\treturn [nodeContext.processedItems, []];\n\t\t}\n\n\t\tnodeContext.done = false;\n\n\t\treturn [[], returnItems];\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,0BAA8C;AAEvC,MAAM,iBAAsC;AAAA,EAA5C;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,WAAW;AAAA,MACX,OAAO,CAAC,cAAc;AAAA,MACtB,SAAS;AAAA,MACT,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,QACN,OAAO;AAAA,MACR;AAAA,MACA,QAAQ,CAAC,wCAAoB,IAAI;AAAA,MAEjC,SAAS,CAAC,wCAAoB,MAAM,wCAAoB,IAAI;AAAA,MAC5D,aAAa,CAAC,QAAQ,MAAM;AAAA,MAC5B,YAAY;AAAA,QACX;AAAA,UACC,aACC;AAAA,UACD,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,QACV;AAAA,QACA;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,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AApBT,kBAAY,mBAAmB;AAC/B,kBAAY,KAAK;AAAA,QAChB;AAAA,QACC,YAAY,MAA+B,OAAO,GAAG,SAAS;AAAA,MAChE;AAEA,YAAM,qBAAqB,CAAC,eAA0D;AACrF,YAAI,OAAO,eAAe,UAAU;AACnC,iBAAO;AAAA,YACN,MAAM;AAAA,YACN,iBAAiB,YAAY;AAAA,UAC9B;AAAA,QACD;AAEA,eAAO;AAAA,UACN,GAAG;AAAA,UACH,iBAAiB,YAAY;AAAA,QAC9B;AAAA,MACD;AAmBA,YAAM,kBAAkB,KAAK,mBAAmB;AAEhD,YAAM,WAAW,MAAM,IAAI,CAAC,MAAM,UAAU;AAC3C,eAAO;AAAA,UACN,GAAG;AAAA,UACH,YAAY;AAAA,YACX;AAAA,YACA,MAAM;AAAA,UACP;AAAA,QACD;AAAA,MACD,CAAC;AAED,kBAAY,iBAAiB,CAAC,GAAG,YAAY,gBAAgB,GAAG,QAAQ;AAExE,kBAAY,IAAI,CAAC,SAAS;AACzB,aAAK,aAAaA,0BAAyB,IAAI;AAAA,MAChD,CAAC;AAAA,IACF;AAEA,gBAAY,cAAc,YAAY,MAAM,WAAW;AAEvD,QAAI,YAAY,WAAW,GAAG;AAC7B,kBAAY,OAAO;AACnB,aAAO,CAAC,YAAY,gBAAgB,CAAC,CAAC;AAAA,IACvC;AAEA,gBAAY,OAAO;AAEnB,WAAO,CAAC,CAAC,GAAG,WAAW;AAAA,EACxB;AACD;","names":["getPairedItemInformation"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var credentials_exports = {};
|
|
20
|
+
__export(credentials_exports, {
|
|
21
|
+
credentials: () => credentials
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(credentials_exports);
|
|
24
|
+
const credentials = {
|
|
25
|
+
wordpressApi: {
|
|
26
|
+
url: "https://myblog.com",
|
|
27
|
+
allowUnauthorizedCerts: false,
|
|
28
|
+
username: "nodeqa",
|
|
29
|
+
password: "fake-password"
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
credentials
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../nodes/Wordpress/__tests__/workflow/credentials.ts"],"sourcesContent":["export const credentials = {\n\twordpressApi: {\n\t\turl: 'https://myblog.com',\n\t\tallowUnauthorizedCerts: false,\n\t\tusername: 'nodeqa',\n\t\tpassword: 'fake-password',\n\t},\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,cAAc;AAAA,EAC1B,cAAc;AAAA,IACb,KAAK;AAAA,IACL,wBAAwB;AAAA,IACxB,UAAU;AAAA,IACV,UAAU;AAAA,EACX;AACD;","names":[]}
|
package/dist/test/globalSetup.js
CHANGED
|
@@ -34,5 +34,8 @@ module.exports = __toCommonJS(globalSetup_exports);
|
|
|
34
34
|
var import_nock = __toESM(require("nock"));
|
|
35
35
|
var globalSetup_default = async () => {
|
|
36
36
|
import_nock.default.disableNetConnect();
|
|
37
|
+
import_nock.default.emitter.on("no match", (req) => {
|
|
38
|
+
console.error("No mock for network request: ", req);
|
|
39
|
+
});
|
|
37
40
|
};
|
|
38
41
|
//# sourceMappingURL=globalSetup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../test/globalSetup.ts"],"sourcesContent":["import nock from 'nock';\n\nexport default async () => {\n\tnock.disableNetConnect();\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,IAAO,sBAAQ,YAAY;AAC1B,cAAAA,QAAK,kBAAkB;
|
|
1
|
+
{"version":3,"sources":["../../test/globalSetup.ts"],"sourcesContent":["import nock from 'nock';\n\nexport default async () => {\n\tnock.disableNetConnect();\n\n\tnock.emitter.on('no match', (req) => {\n\t\tconsole.error('No mock for network request: ', req);\n\t});\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,IAAO,sBAAQ,YAAY;AAC1B,cAAAA,QAAK,kBAAkB;AAEvB,cAAAA,QAAK,QAAQ,GAAG,YAAY,CAAC,QAAQ;AACpC,YAAQ,MAAM,iCAAiC,GAAG;AAAA,EACnD,CAAC;AACF;","names":["nock"]}
|
|
@@ -38,9 +38,10 @@ var import_n8n_workflow = require("n8n-workflow");
|
|
|
38
38
|
var import_nock = __toESM(require("nock"));
|
|
39
39
|
var import_credentials_helper = require("./credentials-helper");
|
|
40
40
|
var import_node_types = require("./node-types");
|
|
41
|
-
var import_Helpers = require("./Helpers");
|
|
42
41
|
async function executeWorkflow(testData) {
|
|
43
42
|
const nodeTypes = import_di.Container.get(import_node_types.NodeTypes);
|
|
43
|
+
const credentialsHelper = import_di.Container.get(import_credentials_helper.CredentialsHelper);
|
|
44
|
+
credentialsHelper.setCredentials(testData.credentials ?? {});
|
|
44
45
|
if (testData.nock) {
|
|
45
46
|
const { baseUrl, mocks } = testData.nock;
|
|
46
47
|
const agent = (0, import_nock.default)(baseUrl);
|
|
@@ -81,11 +82,11 @@ async function executeWorkflow(testData) {
|
|
|
81
82
|
});
|
|
82
83
|
hooks.addHandler("workflowExecuteAfter", (fullRunData) => waitPromise.resolve(fullRunData));
|
|
83
84
|
const additionalData = (0, import_jest_mock_extended.mock)({
|
|
84
|
-
credentialsHelper: import_di.Container.get(import_credentials_helper.CredentialsHelper),
|
|
85
85
|
hooks,
|
|
86
86
|
// Get from node.parameters
|
|
87
87
|
currentNodeParameters: void 0
|
|
88
88
|
});
|
|
89
|
+
additionalData.credentialsHelper = credentialsHelper;
|
|
89
90
|
let executionData;
|
|
90
91
|
const runExecutionData = {
|
|
91
92
|
resultData: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../test/nodes/ExecuteWorkflow.ts"],"sourcesContent":["import { Container } from '@n8n/di';\nimport { mock } from 'jest-mock-extended';\nimport { ExecutionLifecycleHooks, WorkflowExecute } from 'n8n-core';\nimport type {\n\tIRun,\n\tIRunExecutionData,\n\tIWorkflowExecuteAdditionalData,\n\tWorkflowTestData,\n} from 'n8n-workflow';\nimport { createDeferredPromise, Workflow } from 'n8n-workflow';\nimport nock from 'nock';\n\nimport { CredentialsHelper } from './credentials-helper';\nimport { NodeTypes } from './node-types';\n\
|
|
1
|
+
{"version":3,"sources":["../../../test/nodes/ExecuteWorkflow.ts"],"sourcesContent":["import { Container } from '@n8n/di';\nimport { mock } from 'jest-mock-extended';\nimport { ExecutionLifecycleHooks, WorkflowExecute } from 'n8n-core';\nimport type {\n\tIRun,\n\tIRunExecutionData,\n\tIWorkflowExecuteAdditionalData,\n\tWorkflowTestData,\n} from 'n8n-workflow';\nimport { createDeferredPromise, Workflow } from 'n8n-workflow';\nimport nock from 'nock';\n\nimport { CredentialsHelper } from './credentials-helper';\nimport { NodeTypes } from './node-types';\n\nexport async function executeWorkflow(testData: WorkflowTestData) {\n\tconst nodeTypes = Container.get(NodeTypes);\n\n\tconst credentialsHelper = Container.get(CredentialsHelper);\n\tcredentialsHelper.setCredentials(testData.credentials ?? {});\n\n\tif (testData.nock) {\n\t\tconst { baseUrl, mocks } = testData.nock;\n\t\tconst agent = nock(baseUrl);\n\t\tmocks.forEach(\n\t\t\t({\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tstatusCode,\n\t\t\t\trequestBody,\n\t\t\t\trequestHeaders,\n\t\t\t\tresponseBody,\n\t\t\t\tresponseHeaders,\n\t\t\t}) => {\n\t\t\t\tlet mock = agent[method](path, requestBody);\n\n\t\t\t\t// nock interceptor reqheaders option is ignored, so we chain matchHeader()\n\t\t\t\t// agent[method](path, requestBody, { reqheaders: requestHeaders }).reply(statusCode, responseBody, responseHeaders)\n\t\t\t\t// https://github.com/nock/nock/issues/2545\n\t\t\t\tif (requestHeaders && Object.keys(requestHeaders).length > 0) {\n\t\t\t\t\tObject.entries(requestHeaders).forEach(([key, value]) => {\n\t\t\t\t\t\tmock = mock.matchHeader(key, value);\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tmock.reply(statusCode, responseBody, responseHeaders);\n\t\t\t},\n\t\t);\n\t}\n\n\tconst executionMode = testData.trigger?.mode ?? 'manual';\n\tconst workflowInstance = new Workflow({\n\t\tid: 'test',\n\t\tnodes: testData.input.workflowData.nodes,\n\t\tconnections: testData.input.workflowData.connections,\n\t\tactive: false,\n\t\tnodeTypes,\n\t\tsettings: testData.input.workflowData.settings,\n\t});\n\tconst waitPromise = createDeferredPromise<IRun>();\n\tconst nodeExecutionOrder: string[] = [];\n\n\tconst hooks = new ExecutionLifecycleHooks('trigger', '1', mock());\n\thooks.addHandler('nodeExecuteAfter', (nodeName) => {\n\t\tnodeExecutionOrder.push(nodeName);\n\t});\n\thooks.addHandler('workflowExecuteAfter', (fullRunData) => waitPromise.resolve(fullRunData));\n\n\tconst additionalData = mock<IWorkflowExecuteAdditionalData>({\n\t\thooks,\n\t\t// Get from node.parameters\n\t\tcurrentNodeParameters: undefined,\n\t});\n\tadditionalData.credentialsHelper = credentialsHelper;\n\n\tlet executionData: IRun;\n\tconst runExecutionData: IRunExecutionData = {\n\t\tresultData: {\n\t\t\trunData: {},\n\t\t},\n\t\texecutionData: {\n\t\t\tmetadata: {},\n\t\t\tcontextData: {},\n\t\t\twaitingExecution: {},\n\t\t\twaitingExecutionSource: null,\n\t\t\tnodeExecutionStack: [\n\t\t\t\t{\n\t\t\t\t\tnode: workflowInstance.getStartNode()!,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tmain: [[testData.trigger?.input ?? { json: {} }]],\n\t\t\t\t\t},\n\t\t\t\t\tsource: null,\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t};\n\tconst workflowExecute = new WorkflowExecute(additionalData, executionMode, runExecutionData);\n\texecutionData = await workflowExecute.processRunExecutionData(workflowInstance);\n\n\tconst result = await waitPromise.promise;\n\treturn { executionData, result, nodeExecutionOrder };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAA0B;AAC1B,gCAAqB;AACrB,sBAAyD;AAOzD,0BAAgD;AAChD,kBAAiB;AAEjB,gCAAkC;AAClC,wBAA0B;AAE1B,eAAsB,gBAAgB,UAA4B;AACjE,QAAM,YAAY,oBAAU,IAAI,2BAAS;AAEzC,QAAM,oBAAoB,oBAAU,IAAI,2CAAiB;AACzD,oBAAkB,eAAe,SAAS,eAAe,CAAC,CAAC;AAE3D,MAAI,SAAS,MAAM;AAClB,UAAM,EAAE,SAAS,MAAM,IAAI,SAAS;AACpC,UAAM,YAAQ,YAAAA,SAAK,OAAO;AAC1B,UAAM;AAAA,MACL,CAAC;AAAA,QACA;AAAA,QACA;AA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A,QACnB;AAAA,UACC,MAAM,iBAAiB,aAAa;AAAA,UACpC,MAAM;AAAA,YACL,MAAM,CAAC,CAAC,SAAS,SAAS,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;AAAA,UACjD;AAAA,UACA,QAAQ;AAAA,QACT;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACA,QAAM,kBAAkB,IAAI,gCAAgB,gBAAgB,eAAe,gBAAgB;AAC3F,kBAAgB,MAAM,gBAAgB,wBAAwB,gBAAgB;AAE9E,QAAM,SAAS,MAAM,YAAY;AACjC,SAAO,EAAE,eAAe,QAAQ,mBAAmB;AACpD;","names":["nock","mock"]}
|
|
@@ -33,7 +33,6 @@ __export(Helpers_exports, {
|
|
|
33
33
|
equalityTest: () => equalityTest,
|
|
34
34
|
getResultNodeData: () => getResultNodeData,
|
|
35
35
|
getWorkflowFilenames: () => getWorkflowFilenames,
|
|
36
|
-
initBinaryDataService: () => initBinaryDataService,
|
|
37
36
|
readJsonFileSync: () => readJsonFileSync,
|
|
38
37
|
testWorkflows: () => testWorkflows,
|
|
39
38
|
workflowToTests: () => workflowToTests
|
|
@@ -41,7 +40,6 @@ __export(Helpers_exports, {
|
|
|
41
40
|
module.exports = __toCommonJS(Helpers_exports);
|
|
42
41
|
var import_di = require("@n8n/di");
|
|
43
42
|
var import_fs = require("fs");
|
|
44
|
-
var import_jest_mock_extended = require("jest-mock-extended");
|
|
45
43
|
var import_lodash = require("lodash");
|
|
46
44
|
var import_lodash2 = require("lodash");
|
|
47
45
|
var import_n8n_core = require("n8n-core");
|
|
@@ -60,16 +58,6 @@ beforeEach(() => import_nock.default.disableNetConnect());
|
|
|
60
58
|
function createTemporaryDir(prefix = "n8n") {
|
|
61
59
|
return (0, import_fs.mkdtempSync)(import_path.default.join((0, import_os.tmpdir)(), prefix));
|
|
62
60
|
}
|
|
63
|
-
async function initBinaryDataService() {
|
|
64
|
-
const binaryDataConfig = (0, import_jest_mock_extended.mock)({
|
|
65
|
-
mode: "default",
|
|
66
|
-
availableModes: ["default"],
|
|
67
|
-
localStoragePath: createTemporaryDir()
|
|
68
|
-
});
|
|
69
|
-
const binaryDataService = new import_n8n_core.BinaryDataService(binaryDataConfig);
|
|
70
|
-
await binaryDataService.init();
|
|
71
|
-
import_di.Container.set(import_n8n_core.BinaryDataService, binaryDataService);
|
|
72
|
-
}
|
|
73
61
|
function getResultNodeData(result, testData) {
|
|
74
62
|
return Object.keys(testData.output.nodeData).map((nodeName) => {
|
|
75
63
|
const error = result.data.resultData.error;
|
|
@@ -134,7 +122,7 @@ const preparePinData = (pinData) => {
|
|
|
134
122
|
);
|
|
135
123
|
return returnData;
|
|
136
124
|
};
|
|
137
|
-
const workflowToTests = (workflowFiles) => {
|
|
125
|
+
const workflowToTests = (workflowFiles, credentials) => {
|
|
138
126
|
const testCases = [];
|
|
139
127
|
for (const filePath of workflowFiles) {
|
|
140
128
|
const description = filePath.replace(".json", "");
|
|
@@ -158,12 +146,12 @@ const workflowToTests = (workflowFiles) => {
|
|
|
158
146
|
delete workflowData.trigger;
|
|
159
147
|
const input = { workflowData };
|
|
160
148
|
const output = { nodeData };
|
|
161
|
-
testCases.push({ description, input, output, trigger });
|
|
149
|
+
testCases.push({ description, input, output, trigger, credentials });
|
|
162
150
|
}
|
|
163
151
|
return testCases;
|
|
164
152
|
};
|
|
165
|
-
const testWorkflows = (workflows) => {
|
|
166
|
-
const tests = workflowToTests(workflows);
|
|
153
|
+
const testWorkflows = (workflows, credentials) => {
|
|
154
|
+
const tests = workflowToTests(workflows, credentials);
|
|
167
155
|
for (const testData of tests) {
|
|
168
156
|
test(testData.description, async () => await equalityTest(testData));
|
|
169
157
|
}
|
|
@@ -204,7 +192,6 @@ const createMockExecuteFunction = (nodeParameters, nodeMock, continueBool = fals
|
|
|
204
192
|
equalityTest,
|
|
205
193
|
getResultNodeData,
|
|
206
194
|
getWorkflowFilenames,
|
|
207
|
-
initBinaryDataService,
|
|
208
195
|
readJsonFileSync,
|
|
209
196
|
testWorkflows,
|
|
210
197
|
workflowToTests
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../test/nodes/Helpers.ts"],"sourcesContent":["import { Container } from '@n8n/di';\nimport { readFileSync, readdirSync, mkdtempSync } from 'fs';\nimport { mock } from 'jest-mock-extended';\nimport { get } from 'lodash';\nimport { isEmpty } from 'lodash';\nimport { type BinaryDataConfig, BinaryDataService, constructExecutionMetaData } from 'n8n-core';\nimport type {\n\tIDataObject,\n\tIExecuteFunctions,\n\tIGetNodeParameterOptions,\n\tINode,\n\tIRun,\n\tIWorkflowBase,\n\tWorkflowTestData,\n} from 'n8n-workflow';\nimport { ApplicationError } from 'n8n-workflow';\nimport nock from 'nock';\nimport { tmpdir } from 'os';\nimport path from 'path';\n\nimport { executeWorkflow } from './ExecuteWorkflow';\nimport { LoadNodesAndCredentials } from './load-nodes-and-credentials';\n\nconst baseDir = path.resolve(__dirname, '../..');\n\nexport const readJsonFileSync = <T = any>(filePath: string) =>\n\tJSON.parse(readFileSync(path.join(baseDir, filePath), 'utf-8')) as T;\n\nconst loadNodesAndCredentials = new LoadNodesAndCredentials(baseDir);\nContainer.set(LoadNodesAndCredentials, loadNodesAndCredentials);\n\nbeforeAll(async () => await loadNodesAndCredentials.init());\nbeforeEach(() => nock.disableNetConnect());\n\nexport function createTemporaryDir(prefix = 'n8n') {\n\treturn mkdtempSync(path.join(tmpdir(), prefix));\n}\n\nexport async function initBinaryDataService() {\n\tconst binaryDataConfig = mock<BinaryDataConfig>({\n\t\tmode: 'default',\n\t\tavailableModes: ['default'],\n\t\tlocalStoragePath: createTemporaryDir(),\n\t});\n\tconst binaryDataService = new BinaryDataService(binaryDataConfig);\n\tawait binaryDataService.init();\n\tContainer.set(BinaryDataService, binaryDataService);\n}\n\nexport function getResultNodeData(result: IRun, testData: WorkflowTestData) {\n\treturn Object.keys(testData.output.nodeData).map((nodeName) => {\n\t\tconst error = result.data.resultData.error;\n\t\t// If there was an error running the workflow throw it for easier debugging\n\t\t// and to surface all issues\n\t\tif (error?.cause) throw error.cause;\n\t\tif (error) throw error;\n\n\t\tif (result.data.resultData.runData[nodeName] === undefined) {\n\t\t\t// log errors from other nodes\n\t\t\tObject.keys(result.data.resultData.runData).forEach((key) => {\n\t\t\t\tconst error = result.data.resultData.runData[key][0]?.error;\n\t\t\t\tif (error) {\n\t\t\t\t\tconsole.log(`Node ${key}\\n`, error);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tthrow new ApplicationError(`Data for node \"${nodeName}\" is missing!`, { level: 'warning' });\n\t\t}\n\t\tconst resultData = result.data.resultData.runData[nodeName].map((nodeData) => {\n\t\t\tif (nodeData.data === undefined) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn nodeData.data.main[0]!.map((entry) => {\n\t\t\t\tif (entry.binary && isEmpty(entry.binary)) delete entry.binary;\n\t\t\t\tdelete entry.pairedItem;\n\t\t\t\treturn entry;\n\t\t\t});\n\t\t});\n\t\treturn {\n\t\t\tnodeName,\n\t\t\tresultData,\n\t\t};\n\t});\n}\n\nexport const equalityTest = async (testData: WorkflowTestData) => {\n\t// execute workflow\n\tconst { result } = await executeWorkflow(testData);\n\n\t// check if result node data matches expected test data\n\tconst resultNodeData = getResultNodeData(result, testData);\n\tresultNodeData.forEach(({ nodeName, resultData }) => {\n\t\tconst msg = `Equality failed for \"${testData.description}\" at node \"${nodeName}\"`;\n\t\tresultData.forEach((item) => {\n\t\t\titem?.forEach(({ binary, json }) => {\n\t\t\t\tif (binary) {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tdelete binary.data.data;\n\t\t\t\t\tdelete binary.data.directory;\n\t\t\t\t}\n\n\t\t\t\t// Convert errors to JSON so tests can compare\n\t\t\t\tif (json?.error instanceof Error) {\n\t\t\t\t\tjson.error = JSON.parse(\n\t\t\t\t\t\tJSON.stringify(json.error, ['message', 'name', 'description', 'context']),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t\treturn expect(resultData, msg).toEqual(testData.output.nodeData[nodeName]);\n\t});\n\n\texpect(result.finished || result.status === 'waiting').toEqual(true);\n};\n\nconst preparePinData = (pinData: IDataObject) => {\n\tconst returnData = Object.keys(pinData).reduce(\n\t\t(acc, key) => {\n\t\t\tconst data = pinData[key] as IDataObject[];\n\t\t\tacc[key] = [data];\n\t\t\treturn acc;\n\t\t},\n\t\t{} as {\n\t\t\t[key: string]: IDataObject[][];\n\t\t},\n\t);\n\treturn returnData;\n};\n\nexport const workflowToTests = (workflowFiles: string[]) => {\n\tconst testCases: WorkflowTestData[] = [];\n\tfor (const filePath of workflowFiles) {\n\t\tconst description = filePath.replace('.json', '');\n\t\tconst workflowData = readJsonFileSync<IWorkflowBase & Pick<WorkflowTestData, 'trigger'>>(\n\t\t\tfilePath,\n\t\t);\n\t\tconst testDir = path.join(baseDir, path.dirname(filePath));\n\t\tworkflowData.nodes.forEach((node) => {\n\t\t\tif (node.parameters) {\n\t\t\t\tnode.parameters = JSON.parse(\n\t\t\t\t\tJSON.stringify(node.parameters).replace(/\"C:\\\\\\\\Test\\\\\\\\(.*)\"/, `\"${testDir}/$1\"`),\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\t\tif (workflowData.pinData === undefined) {\n\t\t\tthrow new ApplicationError('Workflow data does not contain pinData', { level: 'warning' });\n\t\t}\n\n\t\tconst nodeData = preparePinData(workflowData.pinData);\n\t\tdelete workflowData.pinData;\n\n\t\tconst { trigger } = workflowData;\n\t\tdelete workflowData.trigger;\n\n\t\tconst input = { workflowData };\n\t\tconst output = { nodeData };\n\n\t\ttestCases.push({ description, input, output, trigger });\n\t}\n\treturn testCases;\n};\n\nexport const testWorkflows = (workflows: string[]) => {\n\tconst tests = workflowToTests(workflows);\n\n\tfor (const testData of tests) {\n\t\ttest(testData.description, async () => await equalityTest(testData));\n\t}\n};\n\nexport const getWorkflowFilenames = (dirname: string) => {\n\tconst workflows: string[] = [];\n\n\tconst filenames = readdirSync(dirname);\n\tconst testFolder = dirname.split(`${path.sep}nodes-base${path.sep}`)[1];\n\tfilenames.forEach((file) => {\n\t\tif (file.endsWith('.json')) {\n\t\t\tworkflows.push(path.join(testFolder, file));\n\t\t}\n\t});\n\n\treturn workflows;\n};\n\nexport const createMockExecuteFunction = <T = IExecuteFunctions>(\n\tnodeParameters: IDataObject,\n\tnodeMock: INode,\n\tcontinueBool = false,\n) => {\n\tconst fakeExecuteFunction = {\n\t\tgetNodeParameter(\n\t\t\tparameterName: string,\n\t\t\t_itemIndex: number,\n\t\t\tfallbackValue?: IDataObject | undefined,\n\t\t\toptions?: IGetNodeParameterOptions | undefined,\n\t\t) {\n\t\t\tconst parameter = options?.extractValue ? `${parameterName}.value` : parameterName;\n\t\t\treturn get(nodeParameters, parameter, fallbackValue);\n\t\t},\n\t\tgetNode() {\n\t\t\treturn nodeMock;\n\t\t},\n\t\tcontinueOnFail() {\n\t\t\treturn continueBool;\n\t\t},\n\t\thelpers: {\n\t\t\tconstructExecutionMetaData,\n\t\t},\n\t} as unknown as T;\n\treturn fakeExecuteFunction;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAA0B;AAC1B,gBAAuD;AACvD,gCAAqB;AACrB,oBAAoB;AACpB,IAAAA,iBAAwB;AACxB,sBAAqF;AAUrF,0BAAiC;AACjC,kBAAiB;AACjB,gBAAuB;AACvB,kBAAiB;AAEjB,6BAAgC;AAChC,wCAAwC;AAExC,MAAM,UAAU,YAAAC,QAAK,QAAQ,WAAW,OAAO;AAExC,MAAM,mBAAmB,CAAU,aACzC,KAAK,UAAM,wBAAa,YAAAA,QAAK,KAAK,SAAS,QAAQ,GAAG,OAAO,CAAC;AAE/D,MAAM,0BAA0B,IAAI,0DAAwB,OAAO;AACnE,oBAAU,IAAI,2DAAyB,uBAAuB;AAE9D,UAAU,YAAY,MAAM,wBAAwB,KAAK,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AACR;AAEO,MAAM,4BAA4B,CACxC,gBACA,UACA,eAAe,UACX;AACJ,QAAM,sBAAsB;AAAA,IAC3B,iBACC,eACA,YACA,eACA,SACC;AACD,YAAM,YAAY,SAAS,eAAe,GAAG,aAAa,WAAW;AACrE,iBAAO,mBAAI,gBAAgB,WAAW,aAAa;AAAA,IACpD;AAAA,IACA,UAAU;AACT,aAAO;AAAA,IACR;AAAA,IACA,iBAAiB;AAChB,aAAO;AAAA,IACR;AAAA,IACA,SAAS;AAAA,MACR;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;","names":["import_lodash","path","nock","error"]}
|
|
1
|
+
{"version":3,"sources":["../../../test/nodes/Helpers.ts"],"sourcesContent":["import { Container } from '@n8n/di';\nimport { readFileSync, readdirSync, mkdtempSync } from 'fs';\nimport { get } from 'lodash';\nimport { isEmpty } from 'lodash';\nimport { constructExecutionMetaData } from 'n8n-core';\nimport type {\n\tICredentialDataDecryptedObject,\n\tIDataObject,\n\tIExecuteFunctions,\n\tIGetNodeParameterOptions,\n\tINode,\n\tIRun,\n\tIWorkflowBase,\n\tWorkflowTestData,\n} from 'n8n-workflow';\nimport { ApplicationError } from 'n8n-workflow';\nimport nock from 'nock';\nimport { tmpdir } from 'os';\nimport path from 'path';\n\nimport { executeWorkflow } from './ExecuteWorkflow';\nimport { LoadNodesAndCredentials } from './load-nodes-and-credentials';\n\nconst baseDir = path.resolve(__dirname, '../..');\n\nexport const readJsonFileSync = <T = any>(filePath: string) =>\n\tJSON.parse(readFileSync(path.join(baseDir, filePath), 'utf-8')) as T;\n\nconst loadNodesAndCredentials = new LoadNodesAndCredentials(baseDir);\nContainer.set(LoadNodesAndCredentials, loadNodesAndCredentials);\n\nbeforeAll(async () => await loadNodesAndCredentials.init());\nbeforeEach(() => nock.disableNetConnect());\n\nexport function createTemporaryDir(prefix = 'n8n') {\n\treturn mkdtempSync(path.join(tmpdir(), prefix));\n}\n\nexport function getResultNodeData(result: IRun, testData: WorkflowTestData) {\n\treturn Object.keys(testData.output.nodeData).map((nodeName) => {\n\t\tconst error = result.data.resultData.error;\n\t\t// If there was an error running the workflow throw it for easier debugging\n\t\t// and to surface all issues\n\t\tif (error?.cause) throw error.cause;\n\t\tif (error) throw error;\n\n\t\tif (result.data.resultData.runData[nodeName] === undefined) {\n\t\t\t// log errors from other nodes\n\t\t\tObject.keys(result.data.resultData.runData).forEach((key) => {\n\t\t\t\tconst error = result.data.resultData.runData[key][0]?.error;\n\t\t\t\tif (error) {\n\t\t\t\t\tconsole.log(`Node ${key}\\n`, error);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tthrow new ApplicationError(`Data for node \"${nodeName}\" is missing!`, { level: 'warning' });\n\t\t}\n\t\tconst resultData = result.data.resultData.runData[nodeName].map((nodeData) => {\n\t\t\tif (nodeData.data === undefined) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn nodeData.data.main[0]!.map((entry) => {\n\t\t\t\tif (entry.binary && isEmpty(entry.binary)) delete entry.binary;\n\t\t\t\tdelete entry.pairedItem;\n\t\t\t\treturn entry;\n\t\t\t});\n\t\t});\n\t\treturn {\n\t\t\tnodeName,\n\t\t\tresultData,\n\t\t};\n\t});\n}\n\nexport const equalityTest = async (testData: WorkflowTestData) => {\n\t// execute workflow\n\tconst { result } = await executeWorkflow(testData);\n\n\t// check if result node data matches expected test data\n\tconst resultNodeData = getResultNodeData(result, testData);\n\tresultNodeData.forEach(({ nodeName, resultData }) => {\n\t\tconst msg = `Equality failed for \"${testData.description}\" at node \"${nodeName}\"`;\n\t\tresultData.forEach((item) => {\n\t\t\titem?.forEach(({ binary, json }) => {\n\t\t\t\tif (binary) {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tdelete binary.data.data;\n\t\t\t\t\tdelete binary.data.directory;\n\t\t\t\t}\n\n\t\t\t\t// Convert errors to JSON so tests can compare\n\t\t\t\tif (json?.error instanceof Error) {\n\t\t\t\t\tjson.error = JSON.parse(\n\t\t\t\t\t\tJSON.stringify(json.error, ['message', 'name', 'description', 'context']),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t\treturn expect(resultData, msg).toEqual(testData.output.nodeData[nodeName]);\n\t});\n\n\texpect(result.finished || result.status === 'waiting').toEqual(true);\n};\n\nconst preparePinData = (pinData: IDataObject) => {\n\tconst returnData = Object.keys(pinData).reduce(\n\t\t(acc, key) => {\n\t\t\tconst data = pinData[key] as IDataObject[];\n\t\t\tacc[key] = [data];\n\t\t\treturn acc;\n\t\t},\n\t\t{} as {\n\t\t\t[key: string]: IDataObject[][];\n\t\t},\n\t);\n\treturn returnData;\n};\n\nexport const workflowToTests = (\n\tworkflowFiles: string[],\n\tcredentials?: Record<string, ICredentialDataDecryptedObject>,\n) => {\n\tconst testCases: WorkflowTestData[] = [];\n\tfor (const filePath of workflowFiles) {\n\t\tconst description = filePath.replace('.json', '');\n\t\tconst workflowData = readJsonFileSync<IWorkflowBase & Pick<WorkflowTestData, 'trigger'>>(\n\t\t\tfilePath,\n\t\t);\n\t\tconst testDir = path.join(baseDir, path.dirname(filePath));\n\t\tworkflowData.nodes.forEach((node) => {\n\t\t\tif (node.parameters) {\n\t\t\t\tnode.parameters = JSON.parse(\n\t\t\t\t\tJSON.stringify(node.parameters).replace(/\"C:\\\\\\\\Test\\\\\\\\(.*)\"/, `\"${testDir}/$1\"`),\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\t\tif (workflowData.pinData === undefined) {\n\t\t\tthrow new ApplicationError('Workflow data does not contain pinData', { level: 'warning' });\n\t\t}\n\n\t\tconst nodeData = preparePinData(workflowData.pinData);\n\t\tdelete workflowData.pinData;\n\n\t\tconst { trigger } = workflowData;\n\t\tdelete workflowData.trigger;\n\n\t\tconst input = { workflowData };\n\t\tconst output = { nodeData };\n\n\t\ttestCases.push({ description, input, output, trigger, credentials });\n\t}\n\treturn testCases;\n};\n\nexport const testWorkflows = (\n\tworkflows: string[],\n\tcredentials?: Record<string, ICredentialDataDecryptedObject>,\n) => {\n\tconst tests = workflowToTests(workflows, credentials);\n\n\tfor (const testData of tests) {\n\t\ttest(testData.description, async () => await equalityTest(testData));\n\t}\n};\n\nexport const getWorkflowFilenames = (dirname: string) => {\n\tconst workflows: string[] = [];\n\n\tconst filenames = readdirSync(dirname);\n\tconst testFolder = dirname.split(`${path.sep}nodes-base${path.sep}`)[1];\n\tfilenames.forEach((file) => {\n\t\tif (file.endsWith('.json')) {\n\t\t\tworkflows.push(path.join(testFolder, file));\n\t\t}\n\t});\n\n\treturn workflows;\n};\n\nexport const createMockExecuteFunction = <T = IExecuteFunctions>(\n\tnodeParameters: IDataObject,\n\tnodeMock: INode,\n\tcontinueBool = false,\n) => {\n\tconst fakeExecuteFunction = {\n\t\tgetNodeParameter(\n\t\t\tparameterName: string,\n\t\t\t_itemIndex: number,\n\t\t\tfallbackValue?: IDataObject | undefined,\n\t\t\toptions?: IGetNodeParameterOptions | undefined,\n\t\t) {\n\t\t\tconst parameter = options?.extractValue ? `${parameterName}.value` : parameterName;\n\t\t\treturn get(nodeParameters, parameter, fallbackValue);\n\t\t},\n\t\tgetNode() {\n\t\t\treturn nodeMock;\n\t\t},\n\t\tcontinueOnFail() {\n\t\t\treturn continueBool;\n\t\t},\n\t\thelpers: {\n\t\t\tconstructExecutionMetaData,\n\t\t},\n\t} as unknown as T;\n\treturn fakeExecuteFunction;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAA0B;AAC1B,gBAAuD;AACvD,oBAAoB;AACpB,IAAAA,iBAAwB;AACxB,sBAA2C;AAW3C,0BAAiC;AACjC,kBAAiB;AACjB,gBAAuB;AACvB,kBAAiB;AAEjB,6BAAgC;AAChC,wCAAwC;AAExC,MAAM,UAAU,YAAAC,QAAK,QAAQ,WAAW,OAAO;AAExC,MAAM,mBAAmB,CAAU,aACzC,KAAK,UAAM,wBAAa,YA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,IAC3B,iBACC,eACA,YACA,eACA,SACC;AACD,YAAM,YAAY,SAAS,eAAe,GAAG,aAAa,WAAW;AACrE,iBAAO,mBAAI,gBAAgB,WAAW,aAAa;AAAA,IACpD;AAAA,IACA,UAAU;AACT,aAAO;AAAA,IACR;AAAA,IACA,iBAAiB;AAChB,aAAO;AAAA,IACR;AAAA,IACA,SAAS;AAAA,MACR;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;","names":["import_lodash","path","nock","error"]}
|
|
@@ -33,8 +33,14 @@ var import_di = require("@n8n/di");
|
|
|
33
33
|
var import_n8n_core = require("n8n-core");
|
|
34
34
|
var import_n8n_workflow = require("n8n-workflow");
|
|
35
35
|
var import_credential_types = require("./credential-types");
|
|
36
|
-
var import_FakeCredentialsMap = require("./FakeCredentialsMap");
|
|
37
36
|
let CredentialsHelper = class extends import_n8n_workflow.ICredentialsHelper {
|
|
37
|
+
constructor() {
|
|
38
|
+
super(...arguments);
|
|
39
|
+
this.credentialsMap = {};
|
|
40
|
+
}
|
|
41
|
+
setCredentials(credentialsMap) {
|
|
42
|
+
this.credentialsMap = credentialsMap;
|
|
43
|
+
}
|
|
38
44
|
getCredentialsProperties() {
|
|
39
45
|
return [];
|
|
40
46
|
}
|
|
@@ -51,24 +57,14 @@ let CredentialsHelper = class extends import_n8n_workflow.ICredentialsHelper {
|
|
|
51
57
|
getParentTypes(_name) {
|
|
52
58
|
return [];
|
|
53
59
|
}
|
|
54
|
-
async getDecrypted(_additionalData,
|
|
55
|
-
return this.
|
|
60
|
+
async getDecrypted(_additionalData, _nodeCredentials, type) {
|
|
61
|
+
return this.credentialsMap[type] ?? {};
|
|
56
62
|
}
|
|
57
63
|
async getCredentials(_nodeCredentials, _type) {
|
|
58
64
|
return new import_n8n_core.Credentials({ id: null, name: "" }, "", "");
|
|
59
65
|
}
|
|
60
66
|
async updateCredentials(_nodeCredentials, _type, _data) {
|
|
61
67
|
}
|
|
62
|
-
getFakeDecryptedCredentials(nodeCredentials, type) {
|
|
63
|
-
const credentialsMap = import_FakeCredentialsMap.FAKE_CREDENTIALS_DATA;
|
|
64
|
-
if (nodeCredentials && credentialsMap[JSON.stringify(nodeCredentials)]) {
|
|
65
|
-
return credentialsMap[JSON.stringify(nodeCredentials)];
|
|
66
|
-
}
|
|
67
|
-
if (type && credentialsMap[type]) {
|
|
68
|
-
return credentialsMap[type];
|
|
69
|
-
}
|
|
70
|
-
return {};
|
|
71
|
-
}
|
|
72
68
|
};
|
|
73
69
|
CredentialsHelper = __decorateClass([
|
|
74
70
|
(0, import_di.Service)()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../test/nodes/credentials-helper.ts"],"sourcesContent":["import { Container, Service } from '@n8n/di';\nimport { Credentials } from 'n8n-core';\nimport { ICredentialsHelper } from 'n8n-workflow';\nimport type {\n\tICredentialDataDecryptedObject,\n\
|
|
1
|
+
{"version":3,"sources":["../../../test/nodes/credentials-helper.ts"],"sourcesContent":["import { Container, Service } from '@n8n/di';\nimport { Credentials } from 'n8n-core';\nimport { ICredentialsHelper } from 'n8n-workflow';\nimport type {\n\tICredentialDataDecryptedObject,\n\tIHttpRequestHelper,\n\tIHttpRequestOptions,\n\tINode,\n\tINodeCredentialsDetails,\n\tIWorkflowExecuteAdditionalData,\n} from 'n8n-workflow';\n\nimport { CredentialTypes } from './credential-types';\n\n@Service()\nexport class CredentialsHelper extends ICredentialsHelper {\n\tprivate credentialsMap: Record<string, ICredentialDataDecryptedObject> = {};\n\n\tsetCredentials(credentialsMap: Record<string, ICredentialDataDecryptedObject>) {\n\t\tthis.credentialsMap = credentialsMap;\n\t}\n\n\tgetCredentialsProperties() {\n\t\treturn [];\n\t}\n\n\tasync authenticate(\n\t\tcredentials: ICredentialDataDecryptedObject,\n\t\ttypeName: string,\n\t\trequestParams: IHttpRequestOptions,\n\t): Promise<IHttpRequestOptions> {\n\t\tconst credentialType = Container.get(CredentialTypes).getByName(typeName);\n\t\tif (typeof credentialType.authenticate === 'function') {\n\t\t\treturn await credentialType.authenticate(credentials, requestParams);\n\t\t}\n\t\treturn requestParams;\n\t}\n\n\tasync preAuthentication(\n\t\t_helpers: IHttpRequestHelper,\n\t\t_credentials: ICredentialDataDecryptedObject,\n\t\t_typeName: string,\n\t\t_node: INode,\n\t\t_credentialsExpired: boolean,\n\t): Promise<ICredentialDataDecryptedObject | undefined> {\n\t\treturn undefined;\n\t}\n\n\tgetParentTypes(_name: string): string[] {\n\t\treturn [];\n\t}\n\n\tasync getDecrypted(\n\t\t_additionalData: IWorkflowExecuteAdditionalData,\n\t\t_nodeCredentials: INodeCredentialsDetails,\n\t\ttype: string,\n\t): Promise<ICredentialDataDecryptedObject> {\n\t\treturn this.credentialsMap[type] ?? {};\n\t}\n\n\tasync getCredentials(\n\t\t_nodeCredentials: INodeCredentialsDetails,\n\t\t_type: string,\n\t): Promise<Credentials> {\n\t\treturn new Credentials({ id: null, name: '' }, '', '');\n\t}\n\n\tasync updateCredentials(\n\t\t_nodeCredentials: INodeCredentialsDetails,\n\t\t_type: string,\n\t\t_data: ICredentialDataDecryptedObject,\n\t): Promise<void> {}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAmC;AACnC,sBAA4B;AAC5B,0BAAmC;AAUnC,8BAAgC;AAGzB,IAAM,oBAAN,cAAgC,uCAAmB;AAAA,EAAnD;AAAA;AACN,SAAQ,iBAAiE,CAAC;AAAA;AAAA,EAE1E,eAAe,gBAAgE;AAC9E,SAAK,iBAAiB;AAAA,EACvB;AAAA,EAEA,2BAA2B;AAC1B,WAAO,CAAC;AAAA,EACT;AAAA,EAEA,MAAM,aACL,aACA,UACA,eAC+B;AAC/B,UAAM,iBAAiB,oBAAU,IAAI,uCAAe,EAAE,UAAU,QAAQ;AACxE,QAAI,OAAO,eAAe,iBAAiB,YAAY;AACtD,aAAO,MAAM,eAAe,aAAa,aAAa,aAAa;AAAA,IACpE;AACA,WAAO;AAAA,EACR;AAAA,EAEA,MAAM,kBACL,UACA,cACA,WACA,OACA,qBACsD;AACtD,WAAO;AAAA,EACR;AAAA,EAEA,eAAe,OAAyB;AACvC,WAAO,CAAC;AAAA,EACT;AAAA,EAEA,MAAM,aACL,iBACA,kBACA,MAC0C;AAC1C,WAAO,KAAK,eAAe,IAAI,KAAK,CAAC;AAAA,EACtC;AAAA,EAEA,MAAM,eACL,kBACA,OACuB;AACvB,WAAO,IAAI,4BAAY,EAAE,IAAI,MAAM,MAAM,GAAG,GAAG,IAAI,EAAE;AAAA,EACtD;AAAA,EAEA,MAAM,kBACL,kBACA,OACA,OACgB;AAAA,EAAC;AACnB;AAzDa,oBAAN;AAAA,MADN,mBAAQ;AAAA,GACI;","names":[]}
|