n8n-nodes-base 1.89.0 → 1.90.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/Transform/Summarize/utils.js +7 -7
- package/dist/nodes/Transform/Summarize/utils.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
|
@@ -75,12 +75,12 @@ class CustomerIoApi {
|
|
|
75
75
|
}
|
|
76
76
|
async authenticate(credentials, requestOptions) {
|
|
77
77
|
const url = new URL(requestOptions.url ? requestOptions.url : requestOptions.uri);
|
|
78
|
-
if (url.hostname === "track.customer.io" || url.hostname === "api.customer.io") {
|
|
78
|
+
if (url.hostname === "track.customer.io" || url.hostname === "track-eu.customer.io" || url.hostname === "api.customer.io" || url.hostname === "api-eu.customer.io") {
|
|
79
79
|
const basicAuthKey = Buffer.from(
|
|
80
80
|
`${credentials.trackingSiteId}:${credentials.trackingApiKey}`
|
|
81
81
|
).toString("base64");
|
|
82
82
|
Object.assign(requestOptions.headers, { Authorization: `Basic ${basicAuthKey}` });
|
|
83
|
-
} else if (url.hostname === "beta-api.customer.io") {
|
|
83
|
+
} else if (url.hostname === "beta-api.customer.io" || url.hostname === "beta-api-eu.customer.io") {
|
|
84
84
|
Object.assign(requestOptions.headers, {
|
|
85
85
|
Authorization: `Bearer ${credentials.appApiKey}`
|
|
86
86
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../credentials/CustomerIoApi.credentials.ts"],"sourcesContent":["import { ApplicationError } from 'n8n-workflow';\nimport type {\n\tICredentialDataDecryptedObject,\n\tICredentialType,\n\tIHttpRequestOptions,\n\tINodeProperties,\n} from 'n8n-workflow';\n\nexport class CustomerIoApi implements ICredentialType {\n\tname = 'customerIoApi';\n\n\tdisplayName = 'Customer.io API';\n\n\tdocumentationUrl = 'customerIo';\n\n\tproperties: INodeProperties[] = [\n\t\t{\n\t\t\tdisplayName: 'Tracking API Key',\n\t\t\tname: 'trackingApiKey',\n\t\t\ttype: 'string',\n\t\t\ttypeOptions: { password: true },\n\t\t\tdefault: '',\n\t\t\tdescription: 'Required for tracking API',\n\t\t\trequired: true,\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Region',\n\t\t\tname: 'region',\n\t\t\ttype: 'options',\n\t\t\toptions: [\n\t\t\t\t{\n\t\t\t\t\tname: 'EU region',\n\t\t\t\t\tvalue: 'track-eu.customer.io',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'Global region',\n\t\t\t\t\tvalue: 'track.customer.io',\n\t\t\t\t},\n\t\t\t],\n\t\t\tdefault: 'track.customer.io',\n\t\t\tdescription: 'Should be set based on your account region',\n\t\t\thint: 'The region will be omitted when being used with the HTTP node',\n\t\t\trequired: true,\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Tracking Site ID',\n\t\t\tname: 'trackingSiteId',\n\t\t\ttype: 'string',\n\t\t\tdefault: '',\n\t\t\tdescription: 'Required for tracking API',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'App API Key',\n\t\t\tname: 'appApiKey',\n\t\t\ttype: 'string',\n\t\t\ttypeOptions: { password: true },\n\t\t\tdefault: '',\n\t\t\tdescription: 'Required for App API',\n\t\t},\n\t];\n\n\tasync authenticate(\n\t\tcredentials: ICredentialDataDecryptedObject,\n\t\trequestOptions: IHttpRequestOptions,\n\t): Promise<IHttpRequestOptions> {\n\t\t// @ts-ignore\n\t\tconst url = new URL(requestOptions.url ? requestOptions.url : requestOptions.uri);\n\t\tif (
|
|
1
|
+
{"version":3,"sources":["../../credentials/CustomerIoApi.credentials.ts"],"sourcesContent":["import { ApplicationError } from 'n8n-workflow';\nimport type {\n\tICredentialDataDecryptedObject,\n\tICredentialType,\n\tIHttpRequestOptions,\n\tINodeProperties,\n} from 'n8n-workflow';\n\nexport class CustomerIoApi implements ICredentialType {\n\tname = 'customerIoApi';\n\n\tdisplayName = 'Customer.io API';\n\n\tdocumentationUrl = 'customerIo';\n\n\tproperties: INodeProperties[] = [\n\t\t{\n\t\t\tdisplayName: 'Tracking API Key',\n\t\t\tname: 'trackingApiKey',\n\t\t\ttype: 'string',\n\t\t\ttypeOptions: { password: true },\n\t\t\tdefault: '',\n\t\t\tdescription: 'Required for tracking API',\n\t\t\trequired: true,\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Region',\n\t\t\tname: 'region',\n\t\t\ttype: 'options',\n\t\t\toptions: [\n\t\t\t\t{\n\t\t\t\t\tname: 'EU region',\n\t\t\t\t\tvalue: 'track-eu.customer.io',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'Global region',\n\t\t\t\t\tvalue: 'track.customer.io',\n\t\t\t\t},\n\t\t\t],\n\t\t\tdefault: 'track.customer.io',\n\t\t\tdescription: 'Should be set based on your account region',\n\t\t\thint: 'The region will be omitted when being used with the HTTP node',\n\t\t\trequired: true,\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Tracking Site ID',\n\t\t\tname: 'trackingSiteId',\n\t\t\ttype: 'string',\n\t\t\tdefault: '',\n\t\t\tdescription: 'Required for tracking API',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'App API Key',\n\t\t\tname: 'appApiKey',\n\t\t\ttype: 'string',\n\t\t\ttypeOptions: { password: true },\n\t\t\tdefault: '',\n\t\t\tdescription: 'Required for App API',\n\t\t},\n\t];\n\n\tasync authenticate(\n\t\tcredentials: ICredentialDataDecryptedObject,\n\t\trequestOptions: IHttpRequestOptions,\n\t): Promise<IHttpRequestOptions> {\n\t\t// @ts-ignore\n\t\tconst url = new URL(requestOptions.url ? requestOptions.url : requestOptions.uri);\n\t\tif (\n\t\t\turl.hostname === 'track.customer.io' ||\n\t\t\turl.hostname === 'track-eu.customer.io' ||\n\t\t\turl.hostname === 'api.customer.io' ||\n\t\t\turl.hostname === 'api-eu.customer.io'\n\t\t) {\n\t\t\tconst basicAuthKey = Buffer.from(\n\t\t\t\t`${credentials.trackingSiteId}:${credentials.trackingApiKey}`,\n\t\t\t).toString('base64');\n\t\t\t// @ts-ignore\n\t\t\tObject.assign(requestOptions.headers, { Authorization: `Basic ${basicAuthKey}` });\n\t\t} else if (\n\t\t\turl.hostname === 'beta-api.customer.io' ||\n\t\t\turl.hostname === 'beta-api-eu.customer.io'\n\t\t) {\n\t\t\t// @ts-ignore\n\t\t\tObject.assign(requestOptions.headers, {\n\t\t\t\tAuthorization: `Bearer ${credentials.appApiKey as string}`,\n\t\t\t});\n\t\t} else {\n\t\t\tthrow new ApplicationError('Unknown way of authenticating', { level: 'warning' });\n\t\t}\n\n\t\treturn requestOptions;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAiC;AAQ1B,MAAM,cAAyC;AAAA,EAA/C;AACN,gBAAO;AAEP,uBAAc;AAEd,4BAAmB;AAEnB,sBAAgC;AAAA,MAC/B;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,aAAa,EAAE,UAAU,KAAK;AAAA,QAC9B,SAAS;AAAA,QACT,aAAa;AAAA,QACb,UAAU;AAAA,MACX;AAAA,MACA;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,UACR;AAAA,YACC,MAAM;AAAA,YACN,OAAO;AAAA,UACR;AAAA,UACA;AAAA,YACC,MAAM;AAAA,YACN,OAAO;AAAA,UACR;AAAA,QACD;AAAA,QACA,SAAS;AAAA,QACT,aAAa;AAAA,QACb,MAAM;AAAA,QACN,UAAU;AAAA,MACX;AAAA,MACA;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,QACT,aAAa;AAAA,MACd;AAAA,MACA;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,aAAa,EAAE,UAAU,KAAK;AAAA,QAC9B,SAAS;AAAA,QACT,aAAa;AAAA,MACd;AAAA,IACD;AAAA;AAAA,EAEA,MAAM,aACL,aACA,gBAC+B;AAE/B,UAAM,MAAM,IAAI,IAAI,eAAe,MAAM,eAAe,MAAM,eAAe,GAAG;AAChF,QACC,IAAI,aAAa,uBACjB,IAAI,aAAa,0BACjB,IAAI,aAAa,qBACjB,IAAI,aAAa,sBAChB;AACD,YAAM,eAAe,OAAO;AAAA,QAC3B,GAAG,YAAY,cAAc,IAAI,YAAY,cAAc;AAAA,MAC5D,EAAE,SAAS,QAAQ;AAEnB,aAAO,OAAO,eAAe,SAAS,EAAE,eAAe,SAAS,YAAY,GAAG,CAAC;AAAA,IACjF,WACC,IAAI,aAAa,0BACjB,IAAI,aAAa,2BAChB;AAED,aAAO,OAAO,eAAe,SAAS;AAAA,QACrC,eAAe,UAAU,YAAY,SAAmB;AAAA,MACzD,CAAC;AAAA,IACF,OAAO;AACN,YAAM,IAAI,qCAAiB,iCAAiC,EAAE,OAAO,UAAU,CAAC;AAAA,IACjF;AAEA,WAAO;AAAA,EACR;AACD;","names":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
aws: {
|
|
26
|
+
region: "eu-central-1",
|
|
27
|
+
accessKeyId: "key",
|
|
28
|
+
secretAccessKey: "secret"
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
credentials
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/Aws/__tests__/credentials.ts"],"sourcesContent":["export const credentials = {\n\taws: {\n\t\tregion: 'eu-central-1',\n\t\taccessKeyId: 'key',\n\t\tsecretAccessKey: 'secret',\n\t},\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,cAAc;AAAA,EAC1B,KAAK;AAAA,IACJ,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,iBAAiB;AAAA,EAClB;AACD;","names":[]}
|
|
@@ -32,12 +32,27 @@ __export(Pyodide_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(Pyodide_exports);
|
|
34
34
|
var import_node_path = require("node:path");
|
|
35
|
+
var import_node_vm = require("node:vm");
|
|
35
36
|
let pyodideInstance;
|
|
36
37
|
async function LoadPyodide(packageCacheDir) {
|
|
37
38
|
if (pyodideInstance === void 0) {
|
|
38
39
|
const { loadPyodide } = await import("pyodide");
|
|
40
|
+
const { XMLHttpRequest } = await import("xmlhttprequest-ssl");
|
|
39
41
|
const indexURL = (0, import_node_path.dirname)(require.resolve("pyodide"));
|
|
40
|
-
|
|
42
|
+
const context = (0, import_node_vm.createContext)({
|
|
43
|
+
loadPyodide,
|
|
44
|
+
indexURL,
|
|
45
|
+
packageCacheDir,
|
|
46
|
+
jsglobals: {
|
|
47
|
+
Object,
|
|
48
|
+
console,
|
|
49
|
+
XMLHttpRequest
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
pyodideInstance = await (0, import_node_vm.runInContext)(
|
|
53
|
+
"loadPyodide({ indexURL, packageCacheDir, jsglobals })",
|
|
54
|
+
context
|
|
55
|
+
);
|
|
41
56
|
await pyodideInstance.runPythonAsync(`
|
|
42
57
|
from _pyodide_core import jsproxy_typedict
|
|
43
58
|
from js import Object
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../nodes/Code/Pyodide.ts"],"sourcesContent":["import { dirname } from 'node:path';\nimport type { PyodideInterface } from 'pyodide';\n\nlet pyodideInstance: PyodideInterface | undefined;\n\nexport async function LoadPyodide(packageCacheDir: string): Promise<PyodideInterface> {\n\tif (pyodideInstance === undefined) {\n\t\tconst { loadPyodide } = await import('pyodide');\n\t\tconst indexURL = dirname(require.resolve('pyodide'));\n\t\tpyodideInstance = await loadPyodide({ indexURL, packageCacheDir });\n\n\t\tawait pyodideInstance.runPythonAsync(`\nfrom _pyodide_core import jsproxy_typedict\nfrom js import Object\n`);\n\t}\n\n\treturn pyodideInstance;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAwB;
|
|
1
|
+
{"version":3,"sources":["../../../nodes/Code/Pyodide.ts"],"sourcesContent":["import { dirname } from 'node:path';\nimport { createContext, runInContext } from 'node:vm';\nimport type { PyodideInterface } from 'pyodide';\n\nlet pyodideInstance: PyodideInterface | undefined;\n\nexport async function LoadPyodide(packageCacheDir: string): Promise<PyodideInterface> {\n\tif (pyodideInstance === undefined) {\n\t\tconst { loadPyodide } = await import('pyodide');\n\t\tconst { XMLHttpRequest } = await import('xmlhttprequest-ssl');\n\t\tconst indexURL = dirname(require.resolve('pyodide'));\n\t\tconst context = createContext({\n\t\t\tloadPyodide,\n\t\t\tindexURL,\n\t\t\tpackageCacheDir,\n\t\t\tjsglobals: {\n\t\t\t\tObject,\n\t\t\t\tconsole,\n\t\t\t\tXMLHttpRequest,\n\t\t\t},\n\t\t});\n\t\tpyodideInstance = (await runInContext(\n\t\t\t'loadPyodide({ indexURL, packageCacheDir, jsglobals })',\n\t\t\tcontext,\n\t\t)) as PyodideInterface;\n\n\t\tawait pyodideInstance.runPythonAsync(`\nfrom _pyodide_core import jsproxy_typedict\nfrom js import Object\n`);\n\t}\n\n\treturn pyodideInstance;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAwB;AACxB,qBAA4C;AAG5C,IAAI;AAEJ,eAAsB,YAAY,iBAAoD;AACrF,MAAI,oBAAoB,QAAW;AAClC,UAAM,EAAE,YAAY,IAAI,MAAM,OAAO,SAAS;AAC9C,UAAM,EAAE,eAAe,IAAI,MAAM,OAAO,oBAAoB;AAC5D,UAAM,eAAW,0BAAQ,gBAAgB,SAAS,CAAC;AACnD,UAAM,cAAU,8BAAc;AAAA,MAC7B;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD,CAAC;AACD,sBAAmB,UAAM;AAAA,MACxB;AAAA,MACA;AAAA,IACD;AAEA,UAAM,gBAAgB,eAAe;AAAA;AAAA;AAAA,CAGtC;AAAA,EACA;AAEA,SAAO;AACR;","names":[]}
|
|
@@ -35,8 +35,8 @@ var import_imap = require("@n8n/imap");
|
|
|
35
35
|
var import_isEmpty = __toESM(require("lodash/isEmpty"));
|
|
36
36
|
var import_n8n_workflow = require("n8n-workflow");
|
|
37
37
|
var import_rfc2047 = __toESM(require("rfc2047"));
|
|
38
|
-
var import_utils = require("./utils");
|
|
39
38
|
var import_Imap = require("../../../credentials/Imap.credentials");
|
|
39
|
+
var import_utils = require("./utils");
|
|
40
40
|
const versionDescription = {
|
|
41
41
|
displayName: "Email Trigger (IMAP)",
|
|
42
42
|
name: "emailReadImap",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/EmailReadImap/v2/EmailReadImapV2.node.ts"],"sourcesContent":["import type { ImapSimple, ImapSimpleOptions, Message, MessagePart } from '@n8n/imap';\nimport { connect as imapConnect } from '@n8n/imap';\nimport isEmpty from 'lodash/isEmpty';\nimport type {\n\tITriggerFunctions,\n\tIBinaryData,\n\tICredentialsDecrypted,\n\tICredentialTestFunctions,\n\tIDataObject,\n\tINodeCredentialTestResult,\n\tINodeType,\n\tINodeTypeBaseDescription,\n\tINodeTypeDescription,\n\tITriggerResponse,\n\tJsonObject,\n} from 'n8n-workflow';\nimport { NodeConnectionTypes, NodeOperationError, TriggerCloseError } from 'n8n-workflow';\nimport rfc2047 from 'rfc2047';\n\nimport { getNewEmails } from './utils';\nimport type { ICredentialsDataImap } from '../../../credentials/Imap.credentials';\nimport { isCredentialsDataImap } from '../../../credentials/Imap.credentials';\n\nconst versionDescription: INodeTypeDescription = {\n\tdisplayName: 'Email Trigger (IMAP)',\n\tname: 'emailReadImap',\n\ticon: 'fa:inbox',\n\ticonColor: 'green',\n\tgroup: ['trigger'],\n\tversion: 2,\n\tdescription: 'Triggers the workflow when a new email is received',\n\teventTriggerDescription: 'Waiting for you to receive an email',\n\tdefaults: {\n\t\tname: 'Email Trigger (IMAP)',\n\t\tcolor: '#44AA22',\n\t},\n\ttriggerPanel: {\n\t\theader: '',\n\t\texecutionsHelp: {\n\t\t\tinactive:\n\t\t\t\t\"<b>While building your workflow</b>, click the 'listen' button, then send an email to make an event happen. This will trigger an execution, which will show up in this editor.<br /> <br /><b>Once you're happy with your workflow</b>, <a data-key='activate'>activate</a> it. Then every time an email is received, the workflow will execute. These executions will show up in the <a data-key='executions'>executions list</a>, but not in the editor.\",\n\t\t\tactive:\n\t\t\t\t\"<b>While building your workflow</b>, click the 'listen' button, then send an email to make an event happen. This will trigger an execution, which will show up in this editor.<br /> <br /><b>Your workflow will also execute automatically</b>, since it's activated. Every time an email is received, this node will trigger an execution. These executions will show up in the <a data-key='executions'>executions list</a>, but not in the editor.\",\n\t\t},\n\t\tactivationHint:\n\t\t\t\"Once you’ve finished building your workflow, <a data-key='activate'>activate</a> it to have it also listen continuously (you just won’t see those executions here).\",\n\t},\n\tusableAsTool: true,\n\tinputs: [],\n\toutputs: [NodeConnectionTypes.Main],\n\tcredentials: [\n\t\t{\n\t\t\tname: 'imap',\n\t\t\trequired: true,\n\t\t\ttestedBy: 'imapConnectionTest',\n\t\t},\n\t],\n\tproperties: [\n\t\t{\n\t\t\tdisplayName: 'Mailbox Name',\n\t\t\tname: 'mailbox',\n\t\t\ttype: 'string',\n\t\t\tdefault: 'INBOX',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Action',\n\t\t\tname: 'postProcessAction',\n\t\t\ttype: 'options',\n\t\t\toptions: [\n\t\t\t\t{\n\t\t\t\t\tname: 'Mark as Read',\n\t\t\t\t\tvalue: 'read',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'Nothing',\n\t\t\t\t\tvalue: 'nothing',\n\t\t\t\t},\n\t\t\t],\n\t\t\tdefault: 'read',\n\t\t\tdescription:\n\t\t\t\t'What to do after the email has been received. If \"nothing\" gets selected it will be processed multiple times.',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Download Attachments',\n\t\t\tname: 'downloadAttachments',\n\t\t\ttype: 'boolean',\n\t\t\tdefault: false,\n\t\t\tdisplayOptions: {\n\t\t\t\tshow: {\n\t\t\t\t\tformat: ['simple'],\n\t\t\t\t},\n\t\t\t},\n\t\t\tdescription:\n\t\t\t\t'Whether attachments of emails should be downloaded. Only set if needed as it increases processing.',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Format',\n\t\t\tname: 'format',\n\t\t\ttype: 'options',\n\t\t\toptions: [\n\t\t\t\t{\n\t\t\t\t\tname: 'RAW',\n\t\t\t\t\tvalue: 'raw',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Returns the full email message data with body content in the raw field as a base64url encoded string; the payload field is not used',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'Resolved',\n\t\t\t\t\tvalue: 'resolved',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Returns the full email with all data resolved and attachments saved as binary data',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'Simple',\n\t\t\t\t\tvalue: 'simple',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Returns the full email; do not use if you wish to gather inline attachments',\n\t\t\t\t},\n\t\t\t],\n\t\t\tdefault: 'simple',\n\t\t\tdescription: 'The format to return the message in',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Property Prefix Name',\n\t\t\tname: 'dataPropertyAttachmentsPrefixName',\n\t\t\ttype: 'string',\n\t\t\tdefault: 'attachment_',\n\t\t\tdisplayOptions: {\n\t\t\t\tshow: {\n\t\t\t\t\tformat: ['resolved'],\n\t\t\t\t},\n\t\t\t},\n\t\t\tdescription:\n\t\t\t\t'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is \"attachment_\" the first attachment is saved to \"attachment_0\"',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Property Prefix Name',\n\t\t\tname: 'dataPropertyAttachmentsPrefixName',\n\t\t\ttype: 'string',\n\t\t\tdefault: 'attachment_',\n\t\t\tdisplayOptions: {\n\t\t\t\tshow: {\n\t\t\t\t\tformat: ['simple'],\n\t\t\t\t\tdownloadAttachments: [true],\n\t\t\t\t},\n\t\t\t},\n\t\t\tdescription:\n\t\t\t\t'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is \"attachment_\" the first attachment is saved to \"attachment_0\"',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Options',\n\t\t\tname: 'options',\n\t\t\ttype: 'collection',\n\t\t\tplaceholder: 'Add option',\n\t\t\tdefault: {},\n\t\t\toptions: [\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Custom Email Rules',\n\t\t\t\t\tname: 'customEmailConfig',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: '[\"UNSEEN\"]',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Custom email fetching rules. See <a href=\"https://github.com/mscdex/node-imap\">node-imap</a>\\'s search function for more details.',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Force Reconnect Every Minutes',\n\t\t\t\t\tname: 'forceReconnect',\n\t\t\t\t\ttype: 'number',\n\t\t\t\t\tdefault: 60,\n\t\t\t\t\tdescription: 'Sets an interval (in minutes) to force a reconnection',\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t],\n};\n\nexport class EmailReadImapV2 implements INodeType {\n\tdescription: INodeTypeDescription;\n\n\tconstructor(baseDescription: INodeTypeBaseDescription) {\n\t\tthis.description = {\n\t\t\t...baseDescription,\n\t\t\t...versionDescription,\n\t\t};\n\t}\n\n\tmethods = {\n\t\tcredentialTest: {\n\t\t\tasync imapConnectionTest(\n\t\t\t\tthis: ICredentialTestFunctions,\n\t\t\t\tcredential: ICredentialsDecrypted,\n\t\t\t): Promise<INodeCredentialTestResult> {\n\t\t\t\tif (isCredentialsDataImap(credential.data)) {\n\t\t\t\t\tconst credentials = credential.data as ICredentialsDataImap;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst config: ImapSimpleOptions = {\n\t\t\t\t\t\t\timap: {\n\t\t\t\t\t\t\t\tuser: credentials.user,\n\t\t\t\t\t\t\t\tpassword: credentials.password,\n\t\t\t\t\t\t\t\thost: credentials.host.trim(),\n\t\t\t\t\t\t\t\tport: credentials.port,\n\t\t\t\t\t\t\t\ttls: credentials.secure,\n\t\t\t\t\t\t\t\tauthTimeout: 20000,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst tlsOptions: IDataObject = {};\n\n\t\t\t\t\t\tif (credentials.allowUnauthorizedCerts) {\n\t\t\t\t\t\t\ttlsOptions.rejectUnauthorized = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (credentials.secure) {\n\t\t\t\t\t\t\ttlsOptions.servername = credentials.host.trim();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!isEmpty(tlsOptions)) {\n\t\t\t\t\t\t\tconfig.imap.tlsOptions = tlsOptions;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst connection = await imapConnect(config);\n\t\t\t\t\t\tawait connection.getBoxes();\n\t\t\t\t\t\tconnection.end();\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tstatus: 'Error',\n\t\t\t\t\t\t\tmessage: (error as Error).message,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstatus: 'OK',\n\t\t\t\t\t\tmessage: 'Connection successful!',\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstatus: 'Error',\n\t\t\t\t\t\tmessage: 'Credentials are no IMAP credentials.',\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t};\n\n\tasync trigger(this: ITriggerFunctions): Promise<ITriggerResponse> {\n\t\tconst credentialsObject = await this.getCredentials('imap');\n\t\tconst credentials = isCredentialsDataImap(credentialsObject) ? credentialsObject : undefined;\n\t\tif (!credentials) {\n\t\t\tthrow new NodeOperationError(this.getNode(), 'Credentials are not valid for imap node.');\n\t\t}\n\t\tconst mailbox = this.getNodeParameter('mailbox') as string;\n\t\tconst postProcessAction = this.getNodeParameter('postProcessAction') as string;\n\t\tconst options = this.getNodeParameter('options', {}) as IDataObject;\n\n\t\tconst staticData = this.getWorkflowStaticData('node');\n\t\tthis.logger.debug('Loaded static data for node \"EmailReadImap\"', { staticData });\n\n\t\tlet connection: ImapSimple;\n\t\tlet closeFunctionWasCalled = false;\n\t\tlet isCurrentlyReconnecting = false;\n\n\t\t// Returns the email text\n\n\t\tconst getText = async (\n\t\t\tparts: MessagePart[],\n\t\t\tmessage: Message,\n\t\t\tsubtype: string,\n\t\t): Promise<string> => {\n\t\t\tif (!message.attributes.struct) {\n\t\t\t\treturn '';\n\t\t\t}\n\n\t\t\tconst textParts = parts.filter((part) => {\n\t\t\t\treturn (\n\t\t\t\t\tpart.type.toUpperCase() === 'TEXT' && part.subtype.toUpperCase() === subtype.toUpperCase()\n\t\t\t\t);\n\t\t\t});\n\n\t\t\tconst part = textParts[0];\n\t\t\tif (!part) {\n\t\t\t\treturn '';\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst partData = await connection.getPartData(message, part);\n\t\t\t\treturn partData.toString();\n\t\t\t} catch {\n\t\t\t\treturn '';\n\t\t\t}\n\t\t};\n\n\t\t// Returns the email attachments\n\t\tconst getAttachment = async (\n\t\t\timapConnection: ImapSimple,\n\t\t\tparts: MessagePart[],\n\t\t\tmessage: Message,\n\t\t): Promise<IBinaryData[]> => {\n\t\t\tif (!message.attributes.struct) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\t// Check if the message has attachments and if so get them\n\t\t\tconst attachmentParts = parts.filter(\n\t\t\t\t(part) => part.disposition?.type?.toUpperCase() === 'ATTACHMENT',\n\t\t\t);\n\n\t\t\tconst decodeFilename = (filename: string) => {\n\t\t\t\tconst regex = /=\\?([\\w-]+)\\?Q\\?.*\\?=/i;\n\t\t\t\tif (regex.test(filename)) {\n\t\t\t\t\treturn rfc2047.decode(filename);\n\t\t\t\t}\n\t\t\t\treturn filename;\n\t\t\t};\n\n\t\t\tconst attachmentPromises = [];\n\t\t\tlet attachmentPromise;\n\t\t\tfor (const attachmentPart of attachmentParts) {\n\t\t\t\tattachmentPromise = imapConnection\n\t\t\t\t\t.getPartData(message, attachmentPart)\n\t\t\t\t\t.then(async (partData) => {\n\t\t\t\t\t\t// if filename contains utf-8 encoded characters, decode it\n\t\t\t\t\t\tconst fileName = decodeFilename(\n\t\t\t\t\t\t\t((attachmentPart.disposition as IDataObject)?.params as IDataObject)\n\t\t\t\t\t\t\t\t?.filename as string,\n\t\t\t\t\t\t);\n\t\t\t\t\t\t// Return it in the format n8n expects\n\t\t\t\t\t\treturn await this.helpers.prepareBinaryData(partData.buffer, fileName);\n\t\t\t\t\t});\n\n\t\t\t\tattachmentPromises.push(attachmentPromise);\n\t\t\t}\n\n\t\t\treturn await Promise.all(attachmentPromises);\n\t\t};\n\n\t\tconst returnedPromise = this.helpers.createDeferredPromise();\n\n\t\tconst establishConnection = async (): Promise<ImapSimple> => {\n\t\t\tlet searchCriteria = ['UNSEEN'] as Array<string | string[]>;\n\t\t\tif (options.customEmailConfig !== undefined) {\n\t\t\t\ttry {\n\t\t\t\t\tsearchCriteria = JSON.parse(options.customEmailConfig as string) as Array<\n\t\t\t\t\t\tstring | string[]\n\t\t\t\t\t>;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new NodeOperationError(this.getNode(), 'Custom email config is not valid JSON.');\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst config: ImapSimpleOptions = {\n\t\t\t\timap: {\n\t\t\t\t\tuser: credentials.user,\n\t\t\t\t\tpassword: credentials.password,\n\t\t\t\t\thost: credentials.host.trim(),\n\t\t\t\t\tport: credentials.port,\n\t\t\t\t\ttls: credentials.secure,\n\t\t\t\t\tauthTimeout: 20000,\n\t\t\t\t},\n\t\t\t\tonMail: async () => {\n\t\t\t\t\tif (connection) {\n\t\t\t\t\t\tif (staticData.lastMessageUid !== undefined) {\n\t\t\t\t\t\t\tsearchCriteria.push(['UID', `${staticData.lastMessageUid as number}:*`]);\n\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t * A short explanation about UIDs and how they work\n\t\t\t\t\t\t\t * can be found here: https://dev.to/kehers/imap-new-messages-since-last-check-44gm\n\t\t\t\t\t\t\t * TL;DR:\n\t\t\t\t\t\t\t * - You cannot filter using ['UID', 'CURRENT ID + 1:*'] because IMAP\n\t\t\t\t\t\t\t * won't return correct results if current id + 1 does not yet exist.\n\t\t\t\t\t\t\t * - UIDs can change but this is not being treated here.\n\t\t\t\t\t\t\t * If the mailbox is recreated (lets say you remove all emails, remove\n\t\t\t\t\t\t\t * the mail box and create another with same name, UIDs will change)\n\t\t\t\t\t\t\t * - You can check if UIDs changed in the above example\n\t\t\t\t\t\t\t * by checking UIDValidity.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tthis.logger.debug('Querying for new messages on node \"EmailReadImap\"', {\n\t\t\t\t\t\t\t\tsearchCriteria,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst returnData = await getNewEmails.call(\n\t\t\t\t\t\t\t\tthis,\n\t\t\t\t\t\t\t\tconnection,\n\t\t\t\t\t\t\t\tsearchCriteria,\n\t\t\t\t\t\t\t\tstaticData,\n\t\t\t\t\t\t\t\tpostProcessAction,\n\t\t\t\t\t\t\t\tgetText,\n\t\t\t\t\t\t\t\tgetAttachment,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (returnData.length) {\n\t\t\t\t\t\t\t\tthis.emit([returnData]);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tthis.logger.error('Email Read Imap node encountered an error fetching new emails', {\n\t\t\t\t\t\t\t\terror: error as Error,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t// Wait with resolving till the returnedPromise got resolved, else n8n will be unhappy\n\t\t\t\t\t\t\t// if it receives an error before the workflow got activated\n\t\t\t\t\t\t\tawait returnedPromise.promise.then(() => {\n\t\t\t\t\t\t\t\tthis.emitError(error as Error);\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tonUpdate: async (seqNo: number, info) => {\n\t\t\t\t\tthis.logger.debug(`Email Read Imap:update ${seqNo}`, info);\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst tlsOptions: IDataObject = {};\n\n\t\t\tif (credentials.allowUnauthorizedCerts) {\n\t\t\t\ttlsOptions.rejectUnauthorized = false;\n\t\t\t}\n\n\t\t\tif (credentials.secure) {\n\t\t\t\ttlsOptions.servername = credentials.host.trim();\n\t\t\t}\n\n\t\t\tif (!isEmpty(tlsOptions)) {\n\t\t\t\tconfig.imap.tlsOptions = tlsOptions;\n\t\t\t}\n\n\t\t\t// Connect to the IMAP server and open the mailbox\n\t\t\t// that we get informed whenever a new email arrives\n\t\t\treturn await imapConnect(config).then(async (conn) => {\n\t\t\t\tconn.on('close', async (_hadError: boolean) => {\n\t\t\t\t\tif (isCurrentlyReconnecting) {\n\t\t\t\t\t\tthis.logger.debug('Email Read Imap: Connected closed for forced reconnecting');\n\t\t\t\t\t} else if (closeFunctionWasCalled) {\n\t\t\t\t\t\tthis.logger.debug('Email Read Imap: Shutting down workflow - connected closed');\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.logger.error('Email Read Imap: Connected closed unexpectedly');\n\t\t\t\t\t\tthis.emitError(new Error('Imap connection closed unexpectedly'));\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tconn.on('error', async (error) => {\n\t\t\t\t\tconst errorCode = ((error as JsonObject).code as string).toUpperCase();\n\t\t\t\t\tthis.logger.debug(`IMAP connection experienced an error: (${errorCode})`, {\n\t\t\t\t\t\terror: error as Error,\n\t\t\t\t\t});\n\t\t\t\t\tthis.emitError(error as Error);\n\t\t\t\t});\n\t\t\t\treturn conn;\n\t\t\t});\n\t\t};\n\n\t\tconnection = await establishConnection();\n\n\t\tawait connection.openBox(mailbox);\n\n\t\tlet reconnectionInterval: NodeJS.Timeout | undefined;\n\n\t\tconst handleReconnect = async () => {\n\t\t\tthis.logger.debug('Forcing reconnect to IMAP server');\n\t\t\ttry {\n\t\t\t\tisCurrentlyReconnecting = true;\n\t\t\t\tif (connection.closeBox) await connection.closeBox(false);\n\t\t\t\tconnection.end();\n\t\t\t\tconnection = await establishConnection();\n\t\t\t\tawait connection.openBox(mailbox);\n\t\t\t} catch (error) {\n\t\t\t\tthis.logger.error(error as string);\n\t\t\t} finally {\n\t\t\t\tisCurrentlyReconnecting = false;\n\t\t\t}\n\t\t};\n\n\t\tif (options.forceReconnect !== undefined) {\n\t\t\treconnectionInterval = setInterval(\n\t\t\t\thandleReconnect,\n\t\t\t\t(options.forceReconnect as number) * 1000 * 60,\n\t\t\t);\n\t\t}\n\n\t\t// When workflow and so node gets set to inactive close the connection\n\t\tconst closeFunction = async () => {\n\t\t\tcloseFunctionWasCalled = true;\n\t\t\tif (reconnectionInterval) {\n\t\t\t\tclearInterval(reconnectionInterval);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tif (connection.closeBox) await connection.closeBox(false);\n\t\t\t\tconnection.end();\n\t\t\t} catch (error) {\n\t\t\t\tthrow new TriggerCloseError(this.getNode(), { cause: error as Error, level: 'warning' });\n\t\t\t}\n\t\t};\n\n\t\t// Resolve returned-promise so that waiting errors can be emitted\n\t\treturnedPromise.resolve();\n\n\t\treturn {\n\t\t\tcloseFunction,\n\t\t};\n\t}\n}\n"],"mapp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B,YAAI,WAAW,SAAU,OAAM,WAAW,SAAS,KAAK;AACxD,mBAAW,IAAI;AACf,qBAAa,MAAM,oBAAoB;AACvC,cAAM,WAAW,QAAQ,OAAO;AAAA,MACjC,SAAS,OAAO;AACf,aAAK,OAAO,MAAM,KAAe;AAAA,MAClC,UAAE;AACD,kCAA0B;AAAA,MAC3B;AAAA,IACD;AAEA,QAAI,QAAQ,mBAAmB,QAAW;AACzC,6BAAuB;AAAA,QACtB;AAAA,QACC,QAAQ,iBAA4B,MAAO;AAAA,MAC7C;AAAA,IACD;AAGA,UAAM,gBAAgB,YAAY;AACjC,+BAAyB;AACzB,UAAI,sBAAsB;AACzB,sBAAc,oBAAoB;AAAA,MACnC;AACA,UAAI;AACH,YAAI,WAAW,SAAU,OAAM,WAAW,SAAS,KAAK;AACxD,mBAAW,IAAI;AAAA,MAChB,SAAS,OAAO;AACf,cAAM,IAAI,sCAAkB,KAAK,QAAQ,GAAG,EAAE,OAAO,OAAgB,OAAO,UAAU,CAAC;AAAA,MACxF;AAAA,IACD;AAGA,oBAAgB,QAAQ;AAExB,WAAO;AAAA,MACN;AAAA,IACD;AAAA,EACD;AACD;","names":["isEmpty","imapConnect","part","rfc2047"]}
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/EmailReadImap/v2/EmailReadImapV2.node.ts"],"sourcesContent":["import type { ImapSimple, ImapSimpleOptions, Message, MessagePart } from '@n8n/imap';\nimport { connect as imapConnect } from '@n8n/imap';\nimport isEmpty from 'lodash/isEmpty';\nimport type {\n\tITriggerFunctions,\n\tIBinaryData,\n\tICredentialsDecrypted,\n\tICredentialTestFunctions,\n\tIDataObject,\n\tINodeCredentialTestResult,\n\tINodeType,\n\tINodeTypeBaseDescription,\n\tINodeTypeDescription,\n\tITriggerResponse,\n\tJsonObject,\n} from 'n8n-workflow';\nimport { NodeConnectionTypes, NodeOperationError, TriggerCloseError } from 'n8n-workflow';\nimport rfc2047 from 'rfc2047';\n\nimport type { ICredentialsDataImap } from '@credentials/Imap.credentials';\nimport { isCredentialsDataImap } from '@credentials/Imap.credentials';\n\nimport { getNewEmails } from './utils';\n\nconst versionDescription: INodeTypeDescription = {\n\tdisplayName: 'Email Trigger (IMAP)',\n\tname: 'emailReadImap',\n\ticon: 'fa:inbox',\n\ticonColor: 'green',\n\tgroup: ['trigger'],\n\tversion: 2,\n\tdescription: 'Triggers the workflow when a new email is received',\n\teventTriggerDescription: 'Waiting for you to receive an email',\n\tdefaults: {\n\t\tname: 'Email Trigger (IMAP)',\n\t\tcolor: '#44AA22',\n\t},\n\ttriggerPanel: {\n\t\theader: '',\n\t\texecutionsHelp: {\n\t\t\tinactive:\n\t\t\t\t\"<b>While building your workflow</b>, click the 'listen' button, then send an email to make an event happen. This will trigger an execution, which will show up in this editor.<br /> <br /><b>Once you're happy with your workflow</b>, <a data-key='activate'>activate</a> it. Then every time an email is received, the workflow will execute. These executions will show up in the <a data-key='executions'>executions list</a>, but not in the editor.\",\n\t\t\tactive:\n\t\t\t\t\"<b>While building your workflow</b>, click the 'listen' button, then send an email to make an event happen. This will trigger an execution, which will show up in this editor.<br /> <br /><b>Your workflow will also execute automatically</b>, since it's activated. Every time an email is received, this node will trigger an execution. These executions will show up in the <a data-key='executions'>executions list</a>, but not in the editor.\",\n\t\t},\n\t\tactivationHint:\n\t\t\t\"Once you’ve finished building your workflow, <a data-key='activate'>activate</a> it to have it also listen continuously (you just won’t see those executions here).\",\n\t},\n\tusableAsTool: true,\n\tinputs: [],\n\toutputs: [NodeConnectionTypes.Main],\n\tcredentials: [\n\t\t{\n\t\t\tname: 'imap',\n\t\t\trequired: true,\n\t\t\ttestedBy: 'imapConnectionTest',\n\t\t},\n\t],\n\tproperties: [\n\t\t{\n\t\t\tdisplayName: 'Mailbox Name',\n\t\t\tname: 'mailbox',\n\t\t\ttype: 'string',\n\t\t\tdefault: 'INBOX',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Action',\n\t\t\tname: 'postProcessAction',\n\t\t\ttype: 'options',\n\t\t\toptions: [\n\t\t\t\t{\n\t\t\t\t\tname: 'Mark as Read',\n\t\t\t\t\tvalue: 'read',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'Nothing',\n\t\t\t\t\tvalue: 'nothing',\n\t\t\t\t},\n\t\t\t],\n\t\t\tdefault: 'read',\n\t\t\tdescription:\n\t\t\t\t'What to do after the email has been received. If \"nothing\" gets selected it will be processed multiple times.',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Download Attachments',\n\t\t\tname: 'downloadAttachments',\n\t\t\ttype: 'boolean',\n\t\t\tdefault: false,\n\t\t\tdisplayOptions: {\n\t\t\t\tshow: {\n\t\t\t\t\tformat: ['simple'],\n\t\t\t\t},\n\t\t\t},\n\t\t\tdescription:\n\t\t\t\t'Whether attachments of emails should be downloaded. Only set if needed as it increases processing.',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Format',\n\t\t\tname: 'format',\n\t\t\ttype: 'options',\n\t\t\toptions: [\n\t\t\t\t{\n\t\t\t\t\tname: 'RAW',\n\t\t\t\t\tvalue: 'raw',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Returns the full email message data with body content in the raw field as a base64url encoded string; the payload field is not used',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'Resolved',\n\t\t\t\t\tvalue: 'resolved',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Returns the full email with all data resolved and attachments saved as binary data',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'Simple',\n\t\t\t\t\tvalue: 'simple',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Returns the full email; do not use if you wish to gather inline attachments',\n\t\t\t\t},\n\t\t\t],\n\t\t\tdefault: 'simple',\n\t\t\tdescription: 'The format to return the message in',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Property Prefix Name',\n\t\t\tname: 'dataPropertyAttachmentsPrefixName',\n\t\t\ttype: 'string',\n\t\t\tdefault: 'attachment_',\n\t\t\tdisplayOptions: {\n\t\t\t\tshow: {\n\t\t\t\t\tformat: ['resolved'],\n\t\t\t\t},\n\t\t\t},\n\t\t\tdescription:\n\t\t\t\t'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is \"attachment_\" the first attachment is saved to \"attachment_0\"',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Property Prefix Name',\n\t\t\tname: 'dataPropertyAttachmentsPrefixName',\n\t\t\ttype: 'string',\n\t\t\tdefault: 'attachment_',\n\t\t\tdisplayOptions: {\n\t\t\t\tshow: {\n\t\t\t\t\tformat: ['simple'],\n\t\t\t\t\tdownloadAttachments: [true],\n\t\t\t\t},\n\t\t\t},\n\t\t\tdescription:\n\t\t\t\t'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is \"attachment_\" the first attachment is saved to \"attachment_0\"',\n\t\t},\n\t\t{\n\t\t\tdisplayName: 'Options',\n\t\t\tname: 'options',\n\t\t\ttype: 'collection',\n\t\t\tplaceholder: 'Add option',\n\t\t\tdefault: {},\n\t\t\toptions: [\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Custom Email Rules',\n\t\t\t\t\tname: 'customEmailConfig',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefault: '[\"UNSEEN\"]',\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t'Custom email fetching rules. See <a href=\"https://github.com/mscdex/node-imap\">node-imap</a>\\'s search function for more details.',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tdisplayName: 'Force Reconnect Every Minutes',\n\t\t\t\t\tname: 'forceReconnect',\n\t\t\t\t\ttype: 'number',\n\t\t\t\t\tdefault: 60,\n\t\t\t\t\tdescription: 'Sets an interval (in minutes) to force a reconnection',\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t],\n};\n\nexport class EmailReadImapV2 implements INodeType {\n\tdescription: INodeTypeDescription;\n\n\tconstructor(baseDescription: INodeTypeBaseDescription) {\n\t\tthis.description = {\n\t\t\t...baseDescription,\n\t\t\t...versionDescription,\n\t\t};\n\t}\n\n\tmethods = {\n\t\tcredentialTest: {\n\t\t\tasync imapConnectionTest(\n\t\t\t\tthis: ICredentialTestFunctions,\n\t\t\t\tcredential: ICredentialsDecrypted,\n\t\t\t): Promise<INodeCredentialTestResult> {\n\t\t\t\tif (isCredentialsDataImap(credential.data)) {\n\t\t\t\t\tconst credentials = credential.data as ICredentialsDataImap;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst config: ImapSimpleOptions = {\n\t\t\t\t\t\t\timap: {\n\t\t\t\t\t\t\t\tuser: credentials.user,\n\t\t\t\t\t\t\t\tpassword: credentials.password,\n\t\t\t\t\t\t\t\thost: credentials.host.trim(),\n\t\t\t\t\t\t\t\tport: credentials.port,\n\t\t\t\t\t\t\t\ttls: credentials.secure,\n\t\t\t\t\t\t\t\tauthTimeout: 20000,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst tlsOptions: IDataObject = {};\n\n\t\t\t\t\t\tif (credentials.allowUnauthorizedCerts) {\n\t\t\t\t\t\t\ttlsOptions.rejectUnauthorized = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (credentials.secure) {\n\t\t\t\t\t\t\ttlsOptions.servername = credentials.host.trim();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!isEmpty(tlsOptions)) {\n\t\t\t\t\t\t\tconfig.imap.tlsOptions = tlsOptions;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst connection = await imapConnect(config);\n\t\t\t\t\t\tawait connection.getBoxes();\n\t\t\t\t\t\tconnection.end();\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tstatus: 'Error',\n\t\t\t\t\t\t\tmessage: (error as Error).message,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstatus: 'OK',\n\t\t\t\t\t\tmessage: 'Connection successful!',\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstatus: 'Error',\n\t\t\t\t\t\tmessage: 'Credentials are no IMAP credentials.',\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t};\n\n\tasync trigger(this: ITriggerFunctions): Promise<ITriggerResponse> {\n\t\tconst credentialsObject = await this.getCredentials('imap');\n\t\tconst credentials = isCredentialsDataImap(credentialsObject) ? credentialsObject : undefined;\n\t\tif (!credentials) {\n\t\t\tthrow new NodeOperationError(this.getNode(), 'Credentials are not valid for imap node.');\n\t\t}\n\t\tconst mailbox = this.getNodeParameter('mailbox') as string;\n\t\tconst postProcessAction = this.getNodeParameter('postProcessAction') as string;\n\t\tconst options = this.getNodeParameter('options', {}) as IDataObject;\n\n\t\tconst staticData = this.getWorkflowStaticData('node');\n\t\tthis.logger.debug('Loaded static data for node \"EmailReadImap\"', { staticData });\n\n\t\tlet connection: ImapSimple;\n\t\tlet closeFunctionWasCalled = false;\n\t\tlet isCurrentlyReconnecting = false;\n\n\t\t// Returns the email text\n\n\t\tconst getText = async (\n\t\t\tparts: MessagePart[],\n\t\t\tmessage: Message,\n\t\t\tsubtype: string,\n\t\t): Promise<string> => {\n\t\t\tif (!message.attributes.struct) {\n\t\t\t\treturn '';\n\t\t\t}\n\n\t\t\tconst textParts = parts.filter((part) => {\n\t\t\t\treturn (\n\t\t\t\t\tpart.type.toUpperCase() === 'TEXT' && part.subtype.toUpperCase() === subtype.toUpperCase()\n\t\t\t\t);\n\t\t\t});\n\n\t\t\tconst part = textParts[0];\n\t\t\tif (!part) {\n\t\t\t\treturn '';\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst partData = await connection.getPartData(message, part);\n\t\t\t\treturn partData.toString();\n\t\t\t} catch {\n\t\t\t\treturn '';\n\t\t\t}\n\t\t};\n\n\t\t// Returns the email attachments\n\t\tconst getAttachment = async (\n\t\t\timapConnection: ImapSimple,\n\t\t\tparts: MessagePart[],\n\t\t\tmessage: Message,\n\t\t): Promise<IBinaryData[]> => {\n\t\t\tif (!message.attributes.struct) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\t// Check if the message has attachments and if so get them\n\t\t\tconst attachmentParts = parts.filter(\n\t\t\t\t(part) => part.disposition?.type?.toUpperCase() === 'ATTACHMENT',\n\t\t\t);\n\n\t\t\tconst decodeFilename = (filename: string) => {\n\t\t\t\tconst regex = /=\\?([\\w-]+)\\?Q\\?.*\\?=/i;\n\t\t\t\tif (regex.test(filename)) {\n\t\t\t\t\treturn rfc2047.decode(filename);\n\t\t\t\t}\n\t\t\t\treturn filename;\n\t\t\t};\n\n\t\t\tconst attachmentPromises = [];\n\t\t\tlet attachmentPromise;\n\t\t\tfor (const attachmentPart of attachmentParts) {\n\t\t\t\tattachmentPromise = imapConnection\n\t\t\t\t\t.getPartData(message, attachmentPart)\n\t\t\t\t\t.then(async (partData) => {\n\t\t\t\t\t\t// if filename contains utf-8 encoded characters, decode it\n\t\t\t\t\t\tconst fileName = decodeFilename(\n\t\t\t\t\t\t\t((attachmentPart.disposition as IDataObject)?.params as IDataObject)\n\t\t\t\t\t\t\t\t?.filename as string,\n\t\t\t\t\t\t);\n\t\t\t\t\t\t// Return it in the format n8n expects\n\t\t\t\t\t\treturn await this.helpers.prepareBinaryData(partData.buffer, fileName);\n\t\t\t\t\t});\n\n\t\t\t\tattachmentPromises.push(attachmentPromise);\n\t\t\t}\n\n\t\t\treturn await Promise.all(attachmentPromises);\n\t\t};\n\n\t\tconst returnedPromise = this.helpers.createDeferredPromise();\n\n\t\tconst establishConnection = async (): Promise<ImapSimple> => {\n\t\t\tlet searchCriteria = ['UNSEEN'] as Array<string | string[]>;\n\t\t\tif (options.customEmailConfig !== undefined) {\n\t\t\t\ttry {\n\t\t\t\t\tsearchCriteria = JSON.parse(options.customEmailConfig as string) as Array<\n\t\t\t\t\t\tstring | string[]\n\t\t\t\t\t>;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthrow new NodeOperationError(this.getNode(), 'Custom email config is not valid JSON.');\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst config: ImapSimpleOptions = {\n\t\t\t\timap: {\n\t\t\t\t\tuser: credentials.user,\n\t\t\t\t\tpassword: credentials.password,\n\t\t\t\t\thost: credentials.host.trim(),\n\t\t\t\t\tport: credentials.port,\n\t\t\t\t\ttls: credentials.secure,\n\t\t\t\t\tauthTimeout: 20000,\n\t\t\t\t},\n\t\t\t\tonMail: async () => {\n\t\t\t\t\tif (connection) {\n\t\t\t\t\t\tif (staticData.lastMessageUid !== undefined) {\n\t\t\t\t\t\t\tsearchCriteria.push(['UID', `${staticData.lastMessageUid as number}:*`]);\n\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t * A short explanation about UIDs and how they work\n\t\t\t\t\t\t\t * can be found here: https://dev.to/kehers/imap-new-messages-since-last-check-44gm\n\t\t\t\t\t\t\t * TL;DR:\n\t\t\t\t\t\t\t * - You cannot filter using ['UID', 'CURRENT ID + 1:*'] because IMAP\n\t\t\t\t\t\t\t * won't return correct results if current id + 1 does not yet exist.\n\t\t\t\t\t\t\t * - UIDs can change but this is not being treated here.\n\t\t\t\t\t\t\t * If the mailbox is recreated (lets say you remove all emails, remove\n\t\t\t\t\t\t\t * the mail box and create another with same name, UIDs will change)\n\t\t\t\t\t\t\t * - You can check if UIDs changed in the above example\n\t\t\t\t\t\t\t * by checking UIDValidity.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tthis.logger.debug('Querying for new messages on node \"EmailReadImap\"', {\n\t\t\t\t\t\t\t\tsearchCriteria,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst returnData = await getNewEmails.call(\n\t\t\t\t\t\t\t\tthis,\n\t\t\t\t\t\t\t\tconnection,\n\t\t\t\t\t\t\t\tsearchCriteria,\n\t\t\t\t\t\t\t\tstaticData,\n\t\t\t\t\t\t\t\tpostProcessAction,\n\t\t\t\t\t\t\t\tgetText,\n\t\t\t\t\t\t\t\tgetAttachment,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (returnData.length) {\n\t\t\t\t\t\t\t\tthis.emit([returnData]);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tthis.logger.error('Email Read Imap node encountered an error fetching new emails', {\n\t\t\t\t\t\t\t\terror: error as Error,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t// Wait with resolving till the returnedPromise got resolved, else n8n will be unhappy\n\t\t\t\t\t\t\t// if it receives an error before the workflow got activated\n\t\t\t\t\t\t\tawait returnedPromise.promise.then(() => {\n\t\t\t\t\t\t\t\tthis.emitError(error as Error);\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tonUpdate: async (seqNo: number, info) => {\n\t\t\t\t\tthis.logger.debug(`Email Read Imap:update ${seqNo}`, info);\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst tlsOptions: IDataObject = {};\n\n\t\t\tif (credentials.allowUnauthorizedCerts) {\n\t\t\t\ttlsOptions.rejectUnauthorized = false;\n\t\t\t}\n\n\t\t\tif (credentials.secure) {\n\t\t\t\ttlsOptions.servername = credentials.host.trim();\n\t\t\t}\n\n\t\t\tif (!isEmpty(tlsOptions)) {\n\t\t\t\tconfig.imap.tlsOptions = tlsOptions;\n\t\t\t}\n\n\t\t\t// Connect to the IMAP server and open the mailbox\n\t\t\t// that we get informed whenever a new email arrives\n\t\t\treturn await imapConnect(config).then(async (conn) => {\n\t\t\t\tconn.on('close', async (_hadError: boolean) => {\n\t\t\t\t\tif (isCurrentlyReconnecting) {\n\t\t\t\t\t\tthis.logger.debug('Email Read Imap: Connected closed for forced reconnecting');\n\t\t\t\t\t} else if (closeFunctionWasCalled) {\n\t\t\t\t\t\tthis.logger.debug('Email Read Imap: Shutting down workflow - connected closed');\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.logger.error('Email Read Imap: Connected closed unexpectedly');\n\t\t\t\t\t\tthis.emitError(new Error('Imap connection closed unexpectedly'));\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tconn.on('error', async (error) => {\n\t\t\t\t\tconst errorCode = ((error as JsonObject).code as string).toUpperCase();\n\t\t\t\t\tthis.logger.debug(`IMAP connection experienced an error: (${errorCode})`, {\n\t\t\t\t\t\terror: error as Error,\n\t\t\t\t\t});\n\t\t\t\t\tthis.emitError(error as Error);\n\t\t\t\t});\n\t\t\t\treturn conn;\n\t\t\t});\n\t\t};\n\n\t\tconnection = await establishConnection();\n\n\t\tawait connection.openBox(mailbox);\n\n\t\tlet reconnectionInterval: NodeJS.Timeout | undefined;\n\n\t\tconst handleReconnect = async () => {\n\t\t\tthis.logger.debug('Forcing reconnect to IMAP server');\n\t\t\ttry {\n\t\t\t\tisCurrentlyReconnecting = true;\n\t\t\t\tif (connection.closeBox) await connection.closeBox(false);\n\t\t\t\tconnection.end();\n\t\t\t\tconnection = await establishConnection();\n\t\t\t\tawait connection.openBox(mailbox);\n\t\t\t} catch (error) {\n\t\t\t\tthis.logger.error(error as string);\n\t\t\t} finally {\n\t\t\t\tisCurrentlyReconnecting = false;\n\t\t\t}\n\t\t};\n\n\t\tif (options.forceReconnect !== undefined) {\n\t\t\treconnectionInterval = setInterval(\n\t\t\t\thandleReconnect,\n\t\t\t\t(options.forceReconnect as number) * 1000 * 60,\n\t\t\t);\n\t\t}\n\n\t\t// When workflow and so node gets set to inactive close the connection\n\t\tconst closeFunction = async () => {\n\t\t\tcloseFunctionWasCalled = true;\n\t\t\tif (reconnectionInterval) {\n\t\t\t\tclearInterval(reconnectionInterval);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tif (connection.closeBox) await connection.closeBox(false);\n\t\t\t\tconnection.end();\n\t\t\t} catch (error) {\n\t\t\t\tthrow new TriggerCloseError(this.getNode(), { cause: error as Error, level: 'warning' });\n\t\t\t}\n\t\t};\n\n\t\t// Resolve returned-promise so that waiting errors can be emitted\n\t\treturnedPromise.resolve();\n\n\t\treturn {\n\t\t\tcloseFunction,\n\t\t};\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAuC;AACvC,qBAAoB;AAcpB,0BAA2E;AAC3E,qBAAoB;AAGpB,kBAAsC;AAEtC,mBAA6B;AAE7B,MAAM,qBAA2C;AAAA,EAChD,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,WAAW;AAAA,EACX,OAAO,CAAC,SAAS;AAAA,EACjB,SAAS;AAAA,EACT,aAAa;AAAA,EACb,yBAAyB;AAAA,EACzB,UAAU;AAAA,IACT,MAAM;AAAA,IACN,OAAO;AAAA,EACR;AAAA,EACA,cAAc;AAAA,IACb,QAAQ;AAAA,IACR,gBAAgB;AAAA,MACf,UACC;AAAA,MACD,QACC;AAAA,IACF;AAAA,IACA,gBACC;AAAA,EACF;AAAA,EACA,cAAc;AAAA,EACd,QAAQ,CAAC;AAAA,EACT,SAAS,CAAC,wCAAoB,IAAI;AAAA,EAClC,aAAa;AAAA,IACZ;AAAA,MACC,MAAM;AAAA,MACN,UAAU;AAAA,MACV,UAAU;AAAA,IACX;AAAA,EACD;AAAA,EACA,YAAY;AAAA,IACX;AAAA,MACC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACA;AAAA,MACC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,QACR;AAAA,UACC,MAAM;AAAA,UACN,OAAO;AAAA,QACR;AAAA,QACA;AAAA,UACC,MAAM;AAAA,UACN,OAAO;AAAA,QACR;AAAA,MACD;AAAA,MACA,SAAS;AAAA,MACT,aACC;AAAA,IACF;AAAA,IACA;AAAA,MACC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAA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AAW,QAAQ,OAAO;AAEhC,QAAI;AAEJ,UAAM,kBAAkB,YAAY;AACnC,WAAK,OAAO,MAAM,kCAAkC;AACpD,UAAI;AACH,kCAA0B;AAC1B,YAAI,WAAW,SAAU,OAAM,WAAW,SAAS,KAAK;AACxD,mBAAW,IAAI;AACf,qBAAa,MAAM,oBAAoB;AACvC,cAAM,WAAW,QAAQ,OAAO;AAAA,MACjC,SAAS,OAAO;AACf,aAAK,OAAO,MAAM,KAAe;AAAA,MAClC,UAAE;AACD,kCAA0B;AAAA,MAC3B;AAAA,IACD;AAEA,QAAI,QAAQ,mBAAmB,QAAW;AACzC,6BAAuB;AAAA,QACtB;AAAA,QACC,QAAQ,iBAA4B,MAAO;AAAA,MAC7C;AAAA,IACD;AAGA,UAAM,gBAAgB,YAAY;AACjC,+BAAyB;AACzB,UAAI,sBAAsB;AACzB,sBAAc,oBAAoB;AAAA,MACnC;AACA,UAAI;AACH,YAAI,WAAW,SAAU,OAAM,WAAW,SAAS,KAAK;AACxD,mBAAW,IAAI;AAAA,MAChB,SAAS,OAAO;AACf,cAAM,IAAI,sCAAkB,KAAK,QAAQ,GAAG,EAAE,OAAO,OAAgB,OAAO,UAAU,CAAC;AAAA,MACxF;AAAA,IACD;AAGA,oBAAgB,QAAQ;AAExB,WAAO;AAAA,MACN;AAAA,IACD;AAAA,EACD;AACD;","names":["isEmpty","imapConnect","part","rfc2047"]}
|
|
@@ -26,7 +26,9 @@ async function loadSubWorkflowInputs() {
|
|
|
26
26
|
const { fields, dataMode, subworkflowInfo } = await import_GenericFunctions.loadWorkflowInputMappings.bind(this)();
|
|
27
27
|
let emptyFieldsNotice;
|
|
28
28
|
if (fields.length === 0) {
|
|
29
|
-
const
|
|
29
|
+
const { triggerId, workflowId } = subworkflowInfo ?? {};
|
|
30
|
+
const path = (workflowId ?? "") + (triggerId ? `/${triggerId.slice(0, 6)}` : "");
|
|
31
|
+
const subworkflowLink = workflowId ? `<a href="/workflow/${path}" target="_blank">sub-workflow\u2019s trigger</a>` : "sub-workflow\u2019s trigger";
|
|
30
32
|
switch (dataMode) {
|
|
31
33
|
case "passthrough":
|
|
32
34
|
emptyFieldsNotice = `This sub-workflow will consume all input data passed to it. You can define specific expected input in the ${subworkflowLink}.`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../nodes/ExecuteWorkflow/ExecuteWorkflow/methods/localResourceMapping.ts"],"sourcesContent":["import type { ILocalLoadOptionsFunctions, ResourceMapperFields } from 'n8n-workflow';\n\nimport { loadWorkflowInputMappings } from '@utils/workflowInputsResourceMapping/GenericFunctions';\n\nexport async function loadSubWorkflowInputs(\n\tthis: ILocalLoadOptionsFunctions,\n): Promise<ResourceMapperFields> {\n\tconst { fields, dataMode, subworkflowInfo } = await loadWorkflowInputMappings.bind(this)();\n\tlet emptyFieldsNotice: string | undefined;\n\tif (fields.length === 0) {\n\t\tconst
|
|
1
|
+
{"version":3,"sources":["../../../../../nodes/ExecuteWorkflow/ExecuteWorkflow/methods/localResourceMapping.ts"],"sourcesContent":["import type { ILocalLoadOptionsFunctions, ResourceMapperFields } from 'n8n-workflow';\n\nimport { loadWorkflowInputMappings } from '@utils/workflowInputsResourceMapping/GenericFunctions';\n\nexport async function loadSubWorkflowInputs(\n\tthis: ILocalLoadOptionsFunctions,\n): Promise<ResourceMapperFields> {\n\tconst { fields, dataMode, subworkflowInfo } = await loadWorkflowInputMappings.bind(this)();\n\tlet emptyFieldsNotice: string | undefined;\n\tif (fields.length === 0) {\n\t\tconst { triggerId, workflowId } = subworkflowInfo ?? {};\n\t\tconst path = (workflowId ?? '') + (triggerId ? `/${triggerId.slice(0, 6)}` : '');\n\t\tconst subworkflowLink = workflowId\n\t\t\t? `<a href=\"/workflow/${path}\" target=\"_blank\">sub-workflow’s trigger</a>`\n\t\t\t: 'sub-workflow’s trigger';\n\n\t\tswitch (dataMode) {\n\t\t\tcase 'passthrough':\n\t\t\t\temptyFieldsNotice = `This sub-workflow will consume all input data passed to it. You can define specific expected input in the ${subworkflowLink}.`;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\temptyFieldsNotice = `The sub-workflow isn't set up to accept any inputs. Change this in the ${subworkflowLink}.`;\n\t\t\t\tbreak;\n\t\t}\n\t}\n\treturn { fields, emptyFieldsNotice };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,8BAA0C;AAE1C,eAAsB,wBAEW;AAChC,QAAM,EAAE,QAAQ,UAAU,gBAAgB,IAAI,MAAM,kDAA0B,KAAK,IAAI,EAAE;AACzF,MAAI;AACJ,MAAI,OAAO,WAAW,GAAG;AACxB,UAAM,EAAE,WAAW,WAAW,IAAI,mBAAmB,CAAC;AACtD,UAAM,QAAQ,cAAc,OAAO,YAAY,IAAI,UAAU,MAAM,GAAG,CAAC,CAAC,KAAK;AAC7E,UAAM,kBAAkB,aACrB,sBAAsB,IAAI,sDAC1B;AAEH,YAAQ,UAAU;AAAA,MACjB,KAAK;AACJ,4BAAoB,6GAA6G,eAAe;AAChJ;AAAA,MACD;AACC,4BAAoB,0EAA0E,eAAe;AAC7G;AAAA,IACF;AAAA,EACD;AACA,SAAO,EAAE,QAAQ,kBAAkB;AACpC;","names":[]}
|
|
@@ -30,9 +30,7 @@ const getBinaryDataFromNode = (context, nodeName) => {
|
|
|
30
30
|
const binaryResponse = async (context) => {
|
|
31
31
|
const inputDataFieldName = context.getNodeParameter("inputDataFieldName", "");
|
|
32
32
|
const parentNodes = context.getParentNodes(context.getNode().name);
|
|
33
|
-
const binaryNode = parentNodes.find(
|
|
34
|
-
(node) => getBinaryDataFromNode(context, node?.name)?.hasOwnProperty(inputDataFieldName)
|
|
35
|
-
);
|
|
33
|
+
const binaryNode = parentNodes.reverse().find((node) => getBinaryDataFromNode(context, node?.name)?.hasOwnProperty(inputDataFieldName));
|
|
36
34
|
if (!binaryNode) {
|
|
37
35
|
throw new import_n8n_workflow.OperationalError(`No binary data with field ${inputDataFieldName} found.`);
|
|
38
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../nodes/Form/formCompletionUtils.ts"],"sourcesContent":["import { type Response } from 'express';\nimport {\n\ttype NodeTypeAndVersion,\n\ttype IWebhookFunctions,\n\ttype IWebhookResponseData,\n\ttype IBinaryData,\n\ttype IDataObject,\n\tOperationalError,\n} from 'n8n-workflow';\n\nimport { sanitizeCustomCss, sanitizeHtml } from './utils';\n\nconst getBinaryDataFromNode = (context: IWebhookFunctions, nodeName: string): IDataObject => {\n\treturn context.evaluateExpression(`{{ $('${nodeName}').first().binary }}`) as IDataObject;\n};\n\nexport const binaryResponse = async (\n\tcontext: IWebhookFunctions,\n): Promise<{ data: string | Buffer; fileName: string; type: string }> => {\n\tconst inputDataFieldName = context.getNodeParameter('inputDataFieldName', '') as string;\n\tconst parentNodes = context.getParentNodes(context.getNode().name);\n\tconst binaryNode = parentNodes.
|
|
1
|
+
{"version":3,"sources":["../../../nodes/Form/formCompletionUtils.ts"],"sourcesContent":["import { type Response } from 'express';\nimport {\n\ttype NodeTypeAndVersion,\n\ttype IWebhookFunctions,\n\ttype IWebhookResponseData,\n\ttype IBinaryData,\n\ttype IDataObject,\n\tOperationalError,\n} from 'n8n-workflow';\n\nimport { sanitizeCustomCss, sanitizeHtml } from './utils';\n\nconst getBinaryDataFromNode = (context: IWebhookFunctions, nodeName: string): IDataObject => {\n\treturn context.evaluateExpression(`{{ $('${nodeName}').first().binary }}`) as IDataObject;\n};\n\nexport const binaryResponse = async (\n\tcontext: IWebhookFunctions,\n): Promise<{ data: string | Buffer; fileName: string; type: string }> => {\n\tconst inputDataFieldName = context.getNodeParameter('inputDataFieldName', '') as string;\n\tconst parentNodes = context.getParentNodes(context.getNode().name);\n\tconst binaryNode = parentNodes\n\t\t.reverse()\n\t\t.find((node) => getBinaryDataFromNode(context, node?.name)?.hasOwnProperty(inputDataFieldName));\n\tif (!binaryNode) {\n\t\tthrow new OperationalError(`No binary data with field ${inputDataFieldName} found.`);\n\t}\n\tconst binaryData = getBinaryDataFromNode(context, binaryNode?.name)[\n\t\tinputDataFieldName\n\t] as IBinaryData;\n\n\treturn {\n\t\t// If a binaryData has an id, the following field is set:\n\t\t// N8N_DEFAULT_BINARY_DATA_MODE=filesystem\n\t\tdata: binaryData.id\n\t\t\t? await context.helpers.binaryToBuffer(await context.helpers.getBinaryStream(binaryData.id))\n\t\t\t: atob(binaryData.data),\n\t\tfileName: binaryData.fileName ?? 'file',\n\t\ttype: binaryData.mimeType,\n\t};\n};\n\nexport const renderFormCompletion = async (\n\tcontext: IWebhookFunctions,\n\tres: Response,\n\ttrigger: NodeTypeAndVersion,\n): Promise<IWebhookResponseData> => {\n\tconst completionTitle = context.getNodeParameter('completionTitle', '') as string;\n\tconst completionMessage = context.getNodeParameter('completionMessage', '') as string;\n\tconst redirectUrl = context.getNodeParameter('redirectUrl', '') as string;\n\tconst options = context.getNodeParameter('options', {}) as {\n\t\tformTitle: string;\n\t\tcustomCss?: string;\n\t};\n\tconst responseText = context.getNodeParameter('responseText', '') as string;\n\tconst binary =\n\t\tcontext.getNodeParameter('respondWith', '') === 'returnBinary'\n\t\t\t? await binaryResponse(context)\n\t\t\t: '';\n\n\tlet title = options.formTitle;\n\tif (!title) {\n\t\ttitle = context.evaluateExpression(`{{ $('${trigger?.name}').params.formTitle }}`) as string;\n\t}\n\tconst appendAttribution = context.evaluateExpression(\n\t\t`{{ $('${trigger?.name}').params.options?.appendAttribution === false ? false : true }}`,\n\t) as boolean;\n\n\tres.render('form-trigger-completion', {\n\t\ttitle: completionTitle,\n\t\tmessage: completionMessage,\n\t\tformTitle: title,\n\t\tappendAttribution,\n\t\tresponseText: sanitizeHtml(responseText),\n\t\tresponseBinary: encodeURIComponent(JSON.stringify(binary)),\n\t\tdangerousCustomCss: sanitizeCustomCss(options.customCss),\n\t\tredirectUrl,\n\t});\n\n\treturn { noWebhookResponse: true };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;A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AS,IAAI,wBAAwB;AAAA,EAClF;AACA,QAAM,oBAAoB,QAAQ;AAAA,IACjC,SAAS,SAAS,IAAI;AAAA,EACvB;AAEA,MAAI,OAAO,2BAA2B;AAAA,IACrC,OAAO;AAAA,IACP,SAAS;AAAA,IACT,WAAW;AAAA,IACX;AAAA,IACA,kBAAc,2BAAa,YAAY;AAAA,IACvC,gBAAgB,mBAAmB,KAAK,UAAU,MAAM,CAAC;AAAA,IACzD,wBAAoB,gCAAkB,QAAQ,SAAS;AAAA,IACvD;AAAA,EACD,CAAC;AAED,SAAO,EAAE,mBAAmB,KAAK;AAClC;","names":[]}
|
|
@@ -499,12 +499,16 @@ class GoogleSheetsTrigger {
|
|
|
499
499
|
options.dateTimeRenderOption || "FORMATTED_STRING"
|
|
500
500
|
);
|
|
501
501
|
if (Array.isArray(sheetData) && sheetData.length !== 0) {
|
|
502
|
-
|
|
503
|
-
|
|
502
|
+
sheetData.splice(0, 1);
|
|
503
|
+
}
|
|
504
|
+
let dataStartIndex = 0;
|
|
505
|
+
if (rangeDefinition === "specifyRange" && keyRow < startIndex) {
|
|
506
|
+
dataStartIndex = startIndex - keyRow - 1;
|
|
504
507
|
}
|
|
505
508
|
if (this.getMode() === "manual") {
|
|
506
509
|
if (Array.isArray(sheetData)) {
|
|
507
|
-
const
|
|
510
|
+
const sheetDataFromStartIndex = sheetData.slice(dataStartIndex);
|
|
511
|
+
const returnData = (0, import_GoogleSheetsTrigger.arrayOfArraysToJson)(sheetDataFromStartIndex, columns);
|
|
508
512
|
if (Array.isArray(returnData) && returnData.length !== 0) {
|
|
509
513
|
return [this.helpers.returnJsonArray(returnData)];
|
|
510
514
|
}
|
|
@@ -515,7 +519,11 @@ class GoogleSheetsTrigger {
|
|
|
515
519
|
workflowStaticData.lastIndexChecked = sheetData.length;
|
|
516
520
|
return null;
|
|
517
521
|
}
|
|
518
|
-
const
|
|
522
|
+
const rowsStartIndex = Math.max(
|
|
523
|
+
workflowStaticData.lastIndexChecked,
|
|
524
|
+
dataStartIndex
|
|
525
|
+
);
|
|
526
|
+
const addedRows = sheetData?.slice(rowsStartIndex) || [];
|
|
519
527
|
const returnData = (0, import_GoogleSheetsTrigger.arrayOfArraysToJson)(addedRows, columns);
|
|
520
528
|
workflowStaticData.lastIndexChecked = sheetData.length;
|
|
521
529
|
if (Array.isArray(returnData) && returnData.length !== 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../nodes/Google/Sheet/GoogleSheetsTrigger.node.ts"],"sourcesContent":["import type {\n\tIDataObject,\n\tINodeExecutionData,\n\tINodeType,\n\tINodeTypeDescription,\n\tIPollFunctions,\n} from 'n8n-workflow';\nimport { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';\n\nimport {\n\tarrayOfArraysToJson,\n\tBINARY_MIME_TYPE,\n\tcompareRevisions,\n\tgetRevisionFile,\n\tsheetBinaryToArrayOfArrays,\n} from './GoogleSheetsTrigger.utils';\nimport { GoogleSheet } from './v2/helpers/GoogleSheet';\nimport type { ResourceLocator, ValueRenderOption } from './v2/helpers/GoogleSheets.types';\nimport { sheetsSearch, spreadSheetsSearch } from './v2/methods/listSearch';\nimport { getSheetHeaderRowAndSkipEmpty } from './v2/methods/loadOptions';\nimport { apiRequest } from './v2/transport';\nimport { GOOGLE_DRIVE_FILE_URL_REGEX, GOOGLE_SHEETS_SHEET_URL_REGEX } from '../constants';\n\nexport class GoogleSheetsTrigger implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Google Sheets Trigger',\n\t\tname: 'googleSheetsTrigger',\n\t\ticon: 'file:googleSheets.svg',\n\t\tgroup: ['trigger'],\n\t\tversion: 1,\n\t\tsubtitle: '={{($parameter[\"event\"])}}',\n\t\tdescription: 'Starts the workflow when Google Sheets events occur',\n\t\tdefaults: {\n\t\t\tname: 'Google Sheets Trigger',\n\t\t},\n\t\tinputs: [],\n\t\toutputs: [NodeConnectionTypes.Main],\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'googleSheetsTriggerOAuth2Api',\n\t\t\t\trequired: true,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tauthentication: ['triggerOAuth2'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\tpolling: true,\n\t\tproperties: [\n\t\t\t// trigger shared logic with GoogleSheets node, leaving this here for compatibility\n\t\t\t{\n\t\t\t\tdisplayName: 'Authentication',\n\t\t\t\tname: 'authentication',\n\t\t\t\ttype: 'hidden',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased\n\t\t\t\t\t\tname: 'OAuth2 (recommended)',\n\t\t\t\t\t\tvalue: 'triggerOAuth2',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'triggerOAuth2',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Document',\n\t\t\t\tname: 'documentId',\n\t\t\t\ttype: 'resourceLocator',\n\t\t\t\tdefault: { mode: 'list', value: '' },\n\t\t\t\trequired: true,\n\t\t\t\tmodes: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'From List',\n\t\t\t\t\t\tname: 'list',\n\t\t\t\t\t\ttype: 'list',\n\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\tsearchListMethod: 'spreadSheetsSearch',\n\t\t\t\t\t\t\tsearchable: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'By URL',\n\t\t\t\t\t\tname: 'url',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\textractValue: {\n\t\t\t\t\t\t\ttype: 'regex',\n\t\t\t\t\t\t\tregex: GOOGLE_DRIVE_FILE_URL_REGEX,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tvalidation: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'regex',\n\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\tregex: GOOGLE_DRIVE_FILE_URL_REGEX,\n\t\t\t\t\t\t\t\t\terrorMessage: 'Not a valid Google Drive File URL',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'By ID',\n\t\t\t\t\t\tname: 'id',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tvalidation: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'regex',\n\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\tregex: '[a-zA-Z0-9\\\\-_]{2,}',\n\t\t\t\t\t\t\t\t\terrorMessage: 'Not a valid Google Drive File ID',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\turl: '=https://docs.google.com/spreadsheets/d/{{$value}}/edit',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Sheet',\n\t\t\t\tname: 'sheetName',\n\t\t\t\ttype: 'resourceLocator',\n\t\t\t\tdefault: { mode: 'list', value: '' },\n\t\t\t\t// default: '', //empty string set to progresivly reveal fields\n\t\t\t\trequired: true,\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tloadOptionsDependsOn: ['documentId.value'],\n\t\t\t\t},\n\t\t\t\tmodes: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'From List',\n\t\t\t\t\t\tname: 'list',\n\t\t\t\t\t\ttype: 'list',\n\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\tsearchListMethod: 'sheetsSearch',\n\t\t\t\t\t\t\tsearchable: false,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'By URL',\n\t\t\t\t\t\tname: 'url',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\textractValue: {\n\t\t\t\t\t\t\ttype: 'regex',\n\t\t\t\t\t\t\tregex: GOOGLE_SHEETS_SHEET_URL_REGEX,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tvalidation: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'regex',\n\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\tregex: GOOGLE_SHEETS_SHEET_URL_REGEX,\n\t\t\t\t\t\t\t\t\terrorMessage: 'Not a valid Sheet URL',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'By ID',\n\t\t\t\t\t\tname: 'id',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tvalidation: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'regex',\n\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\tregex: '((gid=)?[0-9]{1,})',\n\t\t\t\t\t\t\t\t\terrorMessage: 'Not a valid Sheet ID',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Trigger On',\n\t\t\t\tname: 'event',\n\t\t\t\ttype: 'options',\n\t\t\t\tdescription:\n\t\t\t\t\t\"It will be triggered also by newly created columns (if the 'Columns to Watch' option is not set)\",\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Row Added',\n\t\t\t\t\t\tvalue: 'rowAdded',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Row Updated',\n\t\t\t\t\t\tvalue: 'rowUpdate',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Row Added or Updated',\n\t\t\t\t\t\tvalue: 'anyUpdate',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'anyUpdate',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Include in Output',\n\t\t\t\tname: 'includeInOutput',\n\t\t\t\ttype: 'options',\n\t\t\t\tdefault: 'new',\n\t\t\t\tdescription: 'This option will be effective only when automatically executing the workflow',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'New Version',\n\t\t\t\t\t\tvalue: 'new',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Old Version',\n\t\t\t\t\t\tvalue: 'old',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Both Versions',\n\t\t\t\t\t\tvalue: 'both',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\thide: {\n\t\t\t\t\t\tevent: ['rowAdded'],\n\t\t\t\t\t},\n\t\t\t\t},\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: 'Columns to Watch',\n\t\t\t\t\t\tname: 'columnsToWatch',\n\t\t\t\t\t\ttype: 'multiOptions',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Choose from the list, or specify IDs using an <a href=\"https://docs.n8n.io/code/expressions/\">expression</a>',\n\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\tloadOptionsDependsOn: ['sheetName.value'],\n\t\t\t\t\t\t\tloadOptionsMethod: 'getSheetHeaderRowAndSkipEmpty',\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdefault: [],\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t'/event': ['anyUpdate', 'rowUpdate'],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Data Location on Sheet',\n\t\t\t\t\t\tname: 'dataLocationOnSheet',\n\t\t\t\t\t\ttype: 'fixedCollection',\n\t\t\t\t\t\tplaceholder: 'Select Range',\n\t\t\t\t\t\tdefault: { values: { rangeDefinition: 'specifyRangeA1' } },\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'Values',\n\t\t\t\t\t\t\t\tname: 'values',\n\t\t\t\t\t\t\t\tvalues: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdisplayName: 'Range Definition',\n\t\t\t\t\t\t\t\t\t\tname: 'rangeDefinition',\n\t\t\t\t\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'Specify Range (A1 Notation)',\n\t\t\t\t\t\t\t\t\t\t\t\tvalue: 'specifyRangeA1',\n\t\t\t\t\t\t\t\t\t\t\t\tdescription: 'Manually specify the data range',\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'Specify Range (Rows)',\n\t\t\t\t\t\t\t\t\t\t\t\tvalue: 'specifyRange',\n\t\t\t\t\t\t\t\t\t\t\t\tdescription: 'Manually specify the data range',\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdisplayName: 'Header Row',\n\t\t\t\t\t\t\t\t\t\tname: 'headerRow',\n\t\t\t\t\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\t\t\t\t\tminValue: 1,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tdefault: 1,\n\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t'Index of the row which contains the keys. Starts at 1. The incoming node data is matched to the keys for assignment. The matching is case sensitive.',\n\t\t\t\t\t\t\t\t\t\thint: 'First row is row 1',\n\t\t\t\t\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t\t\t\t\trangeDefinition: ['specifyRange'],\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdisplayName: 'First Data Row',\n\t\t\t\t\t\t\t\t\t\tname: 'firstDataRow',\n\t\t\t\t\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\t\t\t\t\tminValue: 1,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tdefault: 2,\n\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t'Index of the first row which contains the actual data and not the keys. Starts with 1.',\n\t\t\t\t\t\t\t\t\t\thint: 'First row is row 1',\n\t\t\t\t\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t\t\t\t\trangeDefinition: ['specifyRange'],\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdisplayName: 'Range',\n\t\t\t\t\t\t\t\t\t\tname: 'range',\n\t\t\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\t\t\t\t\tplaceholder: 'A:Z',\n\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t'The table range to read from or to append data to. See the Google <a href=\"https://developers.google.com/sheets/api/guides/values#writing\">documentation</a> for the details.',\n\t\t\t\t\t\t\t\t\t\thint: 'You can specify both the rows and the columns, e.g. C4:E7',\n\t\t\t\t\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t\t\t\t\trangeDefinition: ['specifyRangeA1'],\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Value Render',\n\t\t\t\t\t\tname: 'valueRender',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Unformatted',\n\t\t\t\t\t\t\t\tvalue: 'UNFORMATTED_VALUE',\n\t\t\t\t\t\t\t\tdescription: 'Values will be calculated, but not formatted in the reply',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Formatted',\n\t\t\t\t\t\t\t\tvalue: 'FORMATTED_VALUE',\n\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\"Values will be formatted and calculated according to the cell's formatting (based on the spreadsheet's locale)\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Formula',\n\t\t\t\t\t\t\t\tvalue: 'FORMULA',\n\t\t\t\t\t\t\t\tdescription: 'Values will not be calculated. The reply will include the formulas.',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdefault: 'UNFORMATTED_VALUE',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Determines how values will be rendered in the output. <a href=\"https://developers.google.com/sheets/api/reference/rest/v4/ValueRenderOption\" target=\"_blank\">More info</a>.',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\t\t'/event': ['anyUpdate', 'rowUpdate'],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'DateTime Render',\n\t\t\t\t\t\tname: 'dateTimeRenderOption',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Serial Number',\n\t\t\t\t\t\t\t\tvalue: 'SERIAL_NUMBER',\n\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t'Fields will be returned as doubles in \"serial number\" format (as popularized by Lotus 1-2-3)',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Formatted String',\n\t\t\t\t\t\t\t\tvalue: 'FORMATTED_STRING',\n\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t'Fields will be rendered as strings in their given number format (which depends on the spreadsheet locale)',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdefault: 'SERIAL_NUMBER',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Determines how dates should be rendered in the output. <a href=\"https://developers.google.com/sheets/api/reference/rest/v4/DateTimeRenderOption\" target=\"_blank\">More info</a>.',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\t\t'/event': ['anyUpdate', 'rowUpdate'],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tmethods = {\n\t\tlistSearch: { spreadSheetsSearch, sheetsSearch },\n\t\tloadOptions: { getSheetHeaderRowAndSkipEmpty },\n\t};\n\n\tasync poll(this: IPollFunctions): Promise<INodeExecutionData[][] | null> {\n\t\ttry {\n\t\t\tconst workflowStaticData = this.getWorkflowStaticData('node');\n\t\t\tconst event = this.getNodeParameter('event', 0) as string;\n\n\t\t\tconst documentId = this.getNodeParameter('documentId', undefined, {\n\t\t\t\textractValue: true,\n\t\t\t}) as string;\n\n\t\t\tconst sheetWithinDocument = this.getNodeParameter('sheetName', undefined, {\n\t\t\t\textractValue: true,\n\t\t\t}) as string;\n\t\t\tconst { mode: sheetMode } = this.getNodeParameter('sheetName', 0) as {\n\t\t\t\tmode: ResourceLocator;\n\t\t\t};\n\n\t\t\tconst googleSheet = new GoogleSheet(documentId, this);\n\t\t\tconst { sheetId, title: sheetName } = await googleSheet.spreadsheetGetSheet(\n\t\t\t\tthis.getNode(),\n\t\t\t\tsheetMode,\n\t\t\t\tsheetWithinDocument,\n\t\t\t);\n\n\t\t\tconst options = this.getNodeParameter('options') as IDataObject;\n\n\t\t\t// If the documentId or sheetId changed, reset the workflow static data\n\t\t\tif (\n\t\t\t\tthis.getMode() !== 'manual' &&\n\t\t\t\t(workflowStaticData.documentId !== documentId || workflowStaticData.sheetId !== sheetId)\n\t\t\t) {\n\t\t\t\tworkflowStaticData.documentId = documentId;\n\t\t\t\tworkflowStaticData.sheetId = sheetId;\n\t\t\t\tworkflowStaticData.lastRevision = undefined;\n\t\t\t\tworkflowStaticData.lastRevisionLink = undefined;\n\t\t\t\tworkflowStaticData.lastIndexChecked = undefined;\n\t\t\t}\n\n\t\t\tconst previousRevision = workflowStaticData.lastRevision as number;\n\t\t\tconst previousRevisionLink = workflowStaticData.lastRevisionLink as string;\n\n\t\t\tif (event !== 'rowAdded') {\n\t\t\t\tlet pageToken;\n\t\t\t\tdo {\n\t\t\t\t\tconst { revisions, nextPageToken } = await apiRequest.call(\n\t\t\t\t\t\tthis,\n\t\t\t\t\t\t'GET',\n\t\t\t\t\t\t'',\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfields: 'revisions(id, exportLinks), nextPageToken',\n\t\t\t\t\t\t\tpageToken,\n\t\t\t\t\t\t\tpageSize: 1000,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t`https://www.googleapis.com/drive/v3/files/${documentId}/revisions`,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (nextPageToken) {\n\t\t\t\t\t\tpageToken = nextPageToken as string;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpageToken = undefined;\n\n\t\t\t\t\t\tconst lastRevision = +revisions[revisions.length - 1].id;\n\t\t\t\t\t\tif (lastRevision <= previousRevision) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (this.getMode() !== 'manual') {\n\t\t\t\t\t\t\t\tworkflowStaticData.lastRevision = lastRevision;\n\t\t\t\t\t\t\t\tworkflowStaticData.lastRevisionLink =\n\t\t\t\t\t\t\t\t\trevisions[revisions.length - 1].exportLinks[BINARY_MIME_TYPE];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} while (pageToken);\n\t\t\t}\n\n\t\t\tlet range = 'A:ZZZ';\n\t\t\tlet keyRow = 1;\n\t\t\tlet startIndex = 2;\n\n\t\t\tlet rangeDefinition = '';\n\n\t\t\tconst [from, to] = range.split(':');\n\t\t\tlet keyRange = `${from}${keyRow}:${to}${keyRow}`;\n\t\t\tlet rangeToCheck = `${from}${keyRow}:${to}`;\n\n\t\t\tif (options.dataLocationOnSheet) {\n\t\t\t\tconst locationDefine = (options.dataLocationOnSheet as IDataObject).values as IDataObject;\n\t\t\t\trangeDefinition = locationDefine.rangeDefinition as string;\n\n\t\t\t\tif (rangeDefinition === 'specifyRangeA1') {\n\t\t\t\t\tif (locationDefine.range === '') {\n\t\t\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t\t\t\"The field 'Range' is empty, please provide a range\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\trange = locationDefine.range as string;\n\t\t\t\t}\n\n\t\t\t\tif (rangeDefinition === 'specifyRange') {\n\t\t\t\t\tkeyRow = parseInt(locationDefine.headerRow as string, 10);\n\t\t\t\t\tstartIndex = parseInt(locationDefine.firstDataRow as string, 10);\n\t\t\t\t}\n\n\t\t\t\tconst [rangeFrom, rangeTo] = range.split(':');\n\t\t\t\tconst cellDataFrom = rangeFrom.match(/([a-zA-Z]{1,10})([0-9]{0,10})/) || [];\n\t\t\t\tconst cellDataTo = rangeTo.match(/([a-zA-Z]{1,10})([0-9]{0,10})/) || [];\n\n\t\t\t\tif (rangeDefinition === 'specifyRangeA1' && cellDataFrom[2] !== undefined) {\n\t\t\t\t\tkeyRange = `${cellDataFrom[1]}${+cellDataFrom[2]}:${cellDataTo[1]}${+cellDataFrom[2]}`;\n\t\t\t\t\trangeToCheck = `${cellDataFrom[1]}${+cellDataFrom[2] + 1}:${rangeTo}`;\n\t\t\t\t} else {\n\t\t\t\t\tkeyRange = `${cellDataFrom[1]}${keyRow}:${cellDataTo[1]}${keyRow}`;\n\t\t\t\t\trangeToCheck = `${cellDataFrom[1]}${keyRow}:${rangeTo}`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst qs: IDataObject = {};\n\n\t\t\tObject.assign(qs, options);\n\n\t\t\tif (event === 'rowAdded') {\n\t\t\t\tconst [columns] = ((\n\t\t\t\t\t(await apiRequest.call(\n\t\t\t\t\t\tthis,\n\t\t\t\t\t\t'GET',\n\t\t\t\t\t\t`/v4/spreadsheets/${documentId}/values/${encodeURIComponent(sheetName)}!${keyRange}`,\n\t\t\t\t\t)) as IDataObject\n\t\t\t\t).values as string[][]) || [[]];\n\n\t\t\t\tif (!columns?.length) {\n\t\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t\t'Could not retrieve the columns from key row',\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst sheetData = await googleSheet.getData(\n\t\t\t\t\t`${sheetName}!${rangeToCheck}`,\n\t\t\t\t\t(options.valueRender as ValueRenderOption) || 'UNFORMATTED_VALUE',\n\t\t\t\t\t(options.dateTimeRenderOption as string) || 'FORMATTED_STRING',\n\t\t\t\t);\n\n\t\t\t\tif (Array.isArray(sheetData) && sheetData.length !== 0) {\n\t\t\t\t\tconst zeroBasedKeyRow = keyRow - 1;\n\t\t\t\t\tsheetData.splice(zeroBasedKeyRow, 1); // Remove key row\n\t\t\t\t}\n\n\t\t\t\tif (this.getMode() === 'manual') {\n\t\t\t\t\tif (Array.isArray(sheetData)) {\n\t\t\t\t\t\tconst returnData = arrayOfArraysToJson(sheetData, columns);\n\n\t\t\t\t\t\tif (Array.isArray(returnData) && returnData.length !== 0) {\n\t\t\t\t\t\t\treturn [this.helpers.returnJsonArray(returnData)];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (Array.isArray(sheetData) && this.getMode() !== 'manual') {\n\t\t\t\t\tif (workflowStaticData.lastIndexChecked === undefined) {\n\t\t\t\t\t\tworkflowStaticData.lastIndexChecked = sheetData.length;\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst addedRows = sheetData?.slice(workflowStaticData.lastIndexChecked as number) || [];\n\t\t\t\t\tconst returnData = arrayOfArraysToJson(addedRows, columns);\n\n\t\t\t\t\tworkflowStaticData.lastIndexChecked = sheetData.length;\n\n\t\t\t\t\tif (Array.isArray(returnData) && returnData.length !== 0) {\n\t\t\t\t\t\treturn [this.helpers.returnJsonArray(returnData)];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (event === 'anyUpdate' || event === 'rowUpdate') {\n\t\t\t\tif (sheetName.length > 31) {\n\t\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t\t'Sheet name is too long choose a name with 31 characters or less',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst sheetRange = `${sheetName}!${range}`;\n\n\t\t\t\tlet dataStartIndex = startIndex - 1;\n\t\t\t\tif (rangeDefinition !== 'specifyRangeA1') {\n\t\t\t\t\tdataStartIndex = keyRow < startIndex ? startIndex - 2 : startIndex - 1;\n\t\t\t\t}\n\n\t\t\t\tconst currentData =\n\t\t\t\t\t((await googleSheet.getData(\n\t\t\t\t\t\tsheetRange,\n\t\t\t\t\t\t'UNFORMATTED_VALUE',\n\t\t\t\t\t\t'SERIAL_NUMBER',\n\t\t\t\t\t)) as string[][]) || [];\n\n\t\t\t\tif (previousRevision === undefined) {\n\t\t\t\t\tif (currentData.length === 0) {\n\t\t\t\t\t\treturn [[]];\n\t\t\t\t\t}\n\t\t\t\t\tconst zeroBasedKeyRow = keyRow - 1;\n\t\t\t\t\tconst columns = currentData[zeroBasedKeyRow];\n\t\t\t\t\tcurrentData.splice(zeroBasedKeyRow, 1); // Remove key row\n\n\t\t\t\t\tlet returnData;\n\t\t\t\t\tif (rangeDefinition !== 'specifyRangeA1') {\n\t\t\t\t\t\treturnData = arrayOfArraysToJson(currentData.slice(dataStartIndex), columns);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturnData = arrayOfArraysToJson(currentData, columns);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (Array.isArray(returnData) && returnData.length !== 0 && this.getMode() === 'manual') {\n\t\t\t\t\t\treturn [this.helpers.returnJsonArray(returnData)];\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst previousRevisionBinaryData = await getRevisionFile.call(this, previousRevisionLink);\n\n\t\t\t\tconst previousRevisionSheetData =\n\t\t\t\t\tsheetBinaryToArrayOfArrays(\n\t\t\t\t\t\tpreviousRevisionBinaryData,\n\t\t\t\t\t\tsheetName,\n\t\t\t\t\t\trangeDefinition === 'specifyRangeA1' ? range : undefined,\n\t\t\t\t\t) || [];\n\n\t\t\t\tconst includeInOutput = this.getNodeParameter('includeInOutput', 'new') as string;\n\n\t\t\t\tlet returnData;\n\t\t\t\tif (options.columnsToWatch) {\n\t\t\t\t\treturnData = compareRevisions(\n\t\t\t\t\t\tpreviousRevisionSheetData,\n\t\t\t\t\t\tcurrentData,\n\t\t\t\t\t\tkeyRow,\n\t\t\t\t\t\tincludeInOutput,\n\t\t\t\t\t\toptions.columnsToWatch as string[],\n\t\t\t\t\t\tdataStartIndex,\n\t\t\t\t\t\tevent,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\treturnData = compareRevisions(\n\t\t\t\t\t\tpreviousRevisionSheetData,\n\t\t\t\t\t\tcurrentData,\n\t\t\t\t\t\tkeyRow,\n\t\t\t\t\t\tincludeInOutput,\n\t\t\t\t\t\t[],\n\t\t\t\t\t\tdataStartIndex,\n\t\t\t\t\t\tevent,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (Array.isArray(returnData) && returnData.length !== 0) {\n\t\t\t\t\treturn [this.helpers.returnJsonArray(returnData)];\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (\n\t\t\t\terror?.description\n\t\t\t\t\t?.toLowerCase()\n\t\t\t\t\t.includes('user does not have sufficient permissions for file')\n\t\t\t) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t\"Edit access to the document is required for the 'Row Update' and 'Row Added or Updated' triggers. Request edit access to the document's owner or select the 'Row Added' trigger in the 'Trigger On' dropdown.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (\n\t\t\t\terror?.error?.error?.message !== undefined &&\n\t\t\t\t!(error.error.error.message as string).toLocaleLowerCase().includes('unknown error') &&\n\t\t\t\t!(error.error.error.message as string).toLocaleLowerCase().includes('bad request')\n\t\t\t) {\n\t\t\t\t// eslint-disable-next-line prefer-const\n\t\t\t\tlet [message, ...description] = (error.error.error.message as string).split('. ');\n\t\t\t\tif (message.toLowerCase() === 'access not configured') {\n\t\t\t\t\tmessage = 'Missing Google Drive API';\n\t\t\t\t}\n\t\t\t\tthrow new NodeOperationError(this.getNode(), message, {\n\t\t\t\t\tdescription: description.join('.\\n '),\n\t\t\t\t});\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t\treturn null;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,0BAAwD;AAExD,iCAMO;AACP,yBAA4B;AAE5B,wBAAiD;AACjD,yBAA8C;AAC9C,uBAA2B;AAC3B,uBAA2E;AAEpE,MAAM,oBAAyC;AAAA,EAA/C;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,SAAS;AAAA,MACjB,SAAS;AAAA,MACT,UAAU;AAAA,MACV,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,QAAQ,CAAC;AAAA,MACT,SAAS,CAAC,wCAAoB,IAAI;AAAA,MAClC,aAAa;AAAA,QACZ;AAAA,UACC,MAAM;AAAA,UACN,UAAU;AAAA,UACV,gBAAgB;AAAA,YACf,MAAM;AAAA,cACL,gBAAgB,CAAC,eAAe;AAAA,YACjC;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MACA,SAAS;AAAA,MACT,YAAY;AAAA;AAAA,QAEX;AAAA,UACC,aAAa;AAAA,UACb,MAAM;AAAA,UACN,MAAM;AAAA,UACN,SAAS;AAAA,YACR;AAAA;AAAA,cAEC,MAAM;AAAA,cACN,OAAO;AAAA,YACR;AAAA,UACD;AAAA,UACA,SAAS;AAAA,QACV;AAAA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X;AACA,cAAM,IAAI,uCAAmB,KAAK,QAAQ,GAAG,SAAS;AAAA,UACrD,aAAa,YAAY,KAAK,MAAM;AAAA,QACrC,CAAC;AAAA,MACF;AACA,YAAM;AAAA,IACP;AACA,WAAO;AAAA,EACR;AACD;","names":["returnData"]}
|
|
1
|
+
{"version":3,"sources":["../../../../nodes/Google/Sheet/GoogleSheetsTrigger.node.ts"],"sourcesContent":["import type {\n\tIDataObject,\n\tINodeExecutionData,\n\tINodeType,\n\tINodeTypeDescription,\n\tIPollFunctions,\n} from 'n8n-workflow';\nimport { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';\n\nimport {\n\tarrayOfArraysToJson,\n\tBINARY_MIME_TYPE,\n\tcompareRevisions,\n\tgetRevisionFile,\n\tsheetBinaryToArrayOfArrays,\n} from './GoogleSheetsTrigger.utils';\nimport { GoogleSheet } from './v2/helpers/GoogleSheet';\nimport type { ResourceLocator, ValueRenderOption } from './v2/helpers/GoogleSheets.types';\nimport { sheetsSearch, spreadSheetsSearch } from './v2/methods/listSearch';\nimport { getSheetHeaderRowAndSkipEmpty } from './v2/methods/loadOptions';\nimport { apiRequest } from './v2/transport';\nimport { GOOGLE_DRIVE_FILE_URL_REGEX, GOOGLE_SHEETS_SHEET_URL_REGEX } from '../constants';\n\nexport class GoogleSheetsTrigger implements INodeType {\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Google Sheets Trigger',\n\t\tname: 'googleSheetsTrigger',\n\t\ticon: 'file:googleSheets.svg',\n\t\tgroup: ['trigger'],\n\t\tversion: 1,\n\t\tsubtitle: '={{($parameter[\"event\"])}}',\n\t\tdescription: 'Starts the workflow when Google Sheets events occur',\n\t\tdefaults: {\n\t\t\tname: 'Google Sheets Trigger',\n\t\t},\n\t\tinputs: [],\n\t\toutputs: [NodeConnectionTypes.Main],\n\t\tcredentials: [\n\t\t\t{\n\t\t\t\tname: 'googleSheetsTriggerOAuth2Api',\n\t\t\t\trequired: true,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tauthentication: ['triggerOAuth2'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\tpolling: true,\n\t\tproperties: [\n\t\t\t// trigger shared logic with GoogleSheets node, leaving this here for compatibility\n\t\t\t{\n\t\t\t\tdisplayName: 'Authentication',\n\t\t\t\tname: 'authentication',\n\t\t\t\ttype: 'hidden',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\t// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased\n\t\t\t\t\t\tname: 'OAuth2 (recommended)',\n\t\t\t\t\t\tvalue: 'triggerOAuth2',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'triggerOAuth2',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Document',\n\t\t\t\tname: 'documentId',\n\t\t\t\ttype: 'resourceLocator',\n\t\t\t\tdefault: { mode: 'list', value: '' },\n\t\t\t\trequired: true,\n\t\t\t\tmodes: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'From List',\n\t\t\t\t\t\tname: 'list',\n\t\t\t\t\t\ttype: 'list',\n\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\tsearchListMethod: 'spreadSheetsSearch',\n\t\t\t\t\t\t\tsearchable: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'By URL',\n\t\t\t\t\t\tname: 'url',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\textractValue: {\n\t\t\t\t\t\t\ttype: 'regex',\n\t\t\t\t\t\t\tregex: GOOGLE_DRIVE_FILE_URL_REGEX,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tvalidation: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'regex',\n\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\tregex: GOOGLE_DRIVE_FILE_URL_REGEX,\n\t\t\t\t\t\t\t\t\terrorMessage: 'Not a valid Google Drive File URL',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'By ID',\n\t\t\t\t\t\tname: 'id',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tvalidation: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'regex',\n\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\tregex: '[a-zA-Z0-9\\\\-_]{2,}',\n\t\t\t\t\t\t\t\t\terrorMessage: 'Not a valid Google Drive File ID',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\turl: '=https://docs.google.com/spreadsheets/d/{{$value}}/edit',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Sheet',\n\t\t\t\tname: 'sheetName',\n\t\t\t\ttype: 'resourceLocator',\n\t\t\t\tdefault: { mode: 'list', value: '' },\n\t\t\t\t// default: '', //empty string set to progresivly reveal fields\n\t\t\t\trequired: true,\n\t\t\t\ttypeOptions: {\n\t\t\t\t\tloadOptionsDependsOn: ['documentId.value'],\n\t\t\t\t},\n\t\t\t\tmodes: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'From List',\n\t\t\t\t\t\tname: 'list',\n\t\t\t\t\t\ttype: 'list',\n\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\tsearchListMethod: 'sheetsSearch',\n\t\t\t\t\t\t\tsearchable: false,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'By URL',\n\t\t\t\t\t\tname: 'url',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\textractValue: {\n\t\t\t\t\t\t\ttype: 'regex',\n\t\t\t\t\t\t\tregex: GOOGLE_SHEETS_SHEET_URL_REGEX,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tvalidation: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'regex',\n\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\tregex: GOOGLE_SHEETS_SHEET_URL_REGEX,\n\t\t\t\t\t\t\t\t\terrorMessage: 'Not a valid Sheet URL',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'By ID',\n\t\t\t\t\t\tname: 'id',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tvalidation: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'regex',\n\t\t\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\t\t\tregex: '((gid=)?[0-9]{1,})',\n\t\t\t\t\t\t\t\t\terrorMessage: 'Not a valid Sheet ID',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Trigger On',\n\t\t\t\tname: 'event',\n\t\t\t\ttype: 'options',\n\t\t\t\tdescription:\n\t\t\t\t\t\"It will be triggered also by newly created columns (if the 'Columns to Watch' option is not set)\",\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Row Added',\n\t\t\t\t\t\tvalue: 'rowAdded',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Row Updated',\n\t\t\t\t\t\tvalue: 'rowUpdate',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Row Added or Updated',\n\t\t\t\t\t\tvalue: 'anyUpdate',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'anyUpdate',\n\t\t\t\trequired: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Include in Output',\n\t\t\t\tname: 'includeInOutput',\n\t\t\t\ttype: 'options',\n\t\t\t\tdefault: 'new',\n\t\t\t\tdescription: 'This option will be effective only when automatically executing the workflow',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'New Version',\n\t\t\t\t\t\tvalue: 'new',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Old Version',\n\t\t\t\t\t\tvalue: 'old',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Both Versions',\n\t\t\t\t\t\tvalue: 'both',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\thide: {\n\t\t\t\t\t\tevent: ['rowAdded'],\n\t\t\t\t\t},\n\t\t\t\t},\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: 'Columns to Watch',\n\t\t\t\t\t\tname: 'columnsToWatch',\n\t\t\t\t\t\ttype: 'multiOptions',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Choose from the list, or specify IDs using an <a href=\"https://docs.n8n.io/code/expressions/\">expression</a>',\n\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\tloadOptionsDependsOn: ['sheetName.value'],\n\t\t\t\t\t\t\tloadOptionsMethod: 'getSheetHeaderRowAndSkipEmpty',\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdefault: [],\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t'/event': ['anyUpdate', 'rowUpdate'],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Data Location on Sheet',\n\t\t\t\t\t\tname: 'dataLocationOnSheet',\n\t\t\t\t\t\ttype: 'fixedCollection',\n\t\t\t\t\t\tplaceholder: 'Select Range',\n\t\t\t\t\t\tdefault: { values: { rangeDefinition: 'specifyRangeA1' } },\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdisplayName: 'Values',\n\t\t\t\t\t\t\t\tname: 'values',\n\t\t\t\t\t\t\t\tvalues: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdisplayName: 'Range Definition',\n\t\t\t\t\t\t\t\t\t\tname: 'rangeDefinition',\n\t\t\t\t\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'Specify Range (A1 Notation)',\n\t\t\t\t\t\t\t\t\t\t\t\tvalue: 'specifyRangeA1',\n\t\t\t\t\t\t\t\t\t\t\t\tdescription: 'Manually specify the data range',\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tname: 'Specify Range (Rows)',\n\t\t\t\t\t\t\t\t\t\t\t\tvalue: 'specifyRange',\n\t\t\t\t\t\t\t\t\t\t\t\tdescription: 'Manually specify the data range',\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdisplayName: 'Header Row',\n\t\t\t\t\t\t\t\t\t\tname: 'headerRow',\n\t\t\t\t\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\t\t\t\t\tminValue: 1,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tdefault: 1,\n\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t'Index of the row which contains the keys. Starts at 1. The incoming node data is matched to the keys for assignment. The matching is case sensitive.',\n\t\t\t\t\t\t\t\t\t\thint: 'First row is row 1',\n\t\t\t\t\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t\t\t\t\trangeDefinition: ['specifyRange'],\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdisplayName: 'First Data Row',\n\t\t\t\t\t\t\t\t\t\tname: 'firstDataRow',\n\t\t\t\t\t\t\t\t\t\ttype: 'number',\n\t\t\t\t\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\t\t\t\t\tminValue: 1,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tdefault: 2,\n\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t'Index of the first row which contains the actual data and not the keys. Starts with 1.',\n\t\t\t\t\t\t\t\t\t\thint: 'First row is row 1',\n\t\t\t\t\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t\t\t\t\trangeDefinition: ['specifyRange'],\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tdisplayName: 'Range',\n\t\t\t\t\t\t\t\t\t\tname: 'range',\n\t\t\t\t\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\t\t\t\t\tplaceholder: 'A:Z',\n\t\t\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\t\t'The table range to read from or to append data to. See the Google <a href=\"https://developers.google.com/sheets/api/guides/values#writing\">documentation</a> for the details.',\n\t\t\t\t\t\t\t\t\t\thint: 'You can specify both the rows and the columns, e.g. C4:E7',\n\t\t\t\t\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\t\t\t\t\tshow: {\n\t\t\t\t\t\t\t\t\t\t\t\trangeDefinition: ['specifyRangeA1'],\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Value Render',\n\t\t\t\t\t\tname: 'valueRender',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Unformatted',\n\t\t\t\t\t\t\t\tvalue: 'UNFORMATTED_VALUE',\n\t\t\t\t\t\t\t\tdescription: 'Values will be calculated, but not formatted in the reply',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Formatted',\n\t\t\t\t\t\t\t\tvalue: 'FORMATTED_VALUE',\n\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\"Values will be formatted and calculated according to the cell's formatting (based on the spreadsheet's locale)\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Formula',\n\t\t\t\t\t\t\t\tvalue: 'FORMULA',\n\t\t\t\t\t\t\t\tdescription: 'Values will not be calculated. The reply will include the formulas.',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdefault: 'UNFORMATTED_VALUE',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Determines how values will be rendered in the output. <a href=\"https://developers.google.com/sheets/api/reference/rest/v4/ValueRenderOption\" target=\"_blank\">More info</a>.',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\t\t'/event': ['anyUpdate', 'rowUpdate'],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'DateTime Render',\n\t\t\t\t\t\tname: 'dateTimeRenderOption',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Serial Number',\n\t\t\t\t\t\t\t\tvalue: 'SERIAL_NUMBER',\n\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t'Fields will be returned as doubles in \"serial number\" format (as popularized by Lotus 1-2-3)',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Formatted String',\n\t\t\t\t\t\t\t\tvalue: 'FORMATTED_STRING',\n\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t'Fields will be rendered as strings in their given number format (which depends on the spreadsheet locale)',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdefault: 'SERIAL_NUMBER',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Determines how dates should be rendered in the output. <a href=\"https://developers.google.com/sheets/api/reference/rest/v4/DateTimeRenderOption\" target=\"_blank\">More info</a>.',\n\t\t\t\t\t\tdisplayOptions: {\n\t\t\t\t\t\t\thide: {\n\t\t\t\t\t\t\t\t'/event': ['anyUpdate', 'rowUpdate'],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tmethods = {\n\t\tlistSearch: { spreadSheetsSearch, sheetsSearch },\n\t\tloadOptions: { getSheetHeaderRowAndSkipEmpty },\n\t};\n\n\tasync poll(this: IPollFunctions): Promise<INodeExecutionData[][] | null> {\n\t\ttry {\n\t\t\tconst workflowStaticData = this.getWorkflowStaticData('node');\n\t\t\tconst event = this.getNodeParameter('event', 0) as string;\n\n\t\t\tconst documentId = this.getNodeParameter('documentId', undefined, {\n\t\t\t\textractValue: true,\n\t\t\t}) as string;\n\n\t\t\tconst sheetWithinDocument = this.getNodeParameter('sheetName', undefined, {\n\t\t\t\textractValue: true,\n\t\t\t}) as string;\n\t\t\tconst { mode: sheetMode } = this.getNodeParameter('sheetName', 0) as {\n\t\t\t\tmode: ResourceLocator;\n\t\t\t};\n\n\t\t\tconst googleSheet = new GoogleSheet(documentId, this);\n\t\t\tconst { sheetId, title: sheetName } = await googleSheet.spreadsheetGetSheet(\n\t\t\t\tthis.getNode(),\n\t\t\t\tsheetMode,\n\t\t\t\tsheetWithinDocument,\n\t\t\t);\n\n\t\t\tconst options = this.getNodeParameter('options') as IDataObject;\n\n\t\t\t// If the documentId or sheetId changed, reset the workflow static data\n\t\t\tif (\n\t\t\t\tthis.getMode() !== 'manual' &&\n\t\t\t\t(workflowStaticData.documentId !== documentId || workflowStaticData.sheetId !== sheetId)\n\t\t\t) {\n\t\t\t\tworkflowStaticData.documentId = documentId;\n\t\t\t\tworkflowStaticData.sheetId = sheetId;\n\t\t\t\tworkflowStaticData.lastRevision = undefined;\n\t\t\t\tworkflowStaticData.lastRevisionLink = undefined;\n\t\t\t\tworkflowStaticData.lastIndexChecked = undefined;\n\t\t\t}\n\n\t\t\tconst previousRevision = workflowStaticData.lastRevision as number;\n\t\t\tconst previousRevisionLink = workflowStaticData.lastRevisionLink as string;\n\n\t\t\tif (event !== 'rowAdded') {\n\t\t\t\tlet pageToken;\n\t\t\t\tdo {\n\t\t\t\t\tconst { revisions, nextPageToken } = await apiRequest.call(\n\t\t\t\t\t\tthis,\n\t\t\t\t\t\t'GET',\n\t\t\t\t\t\t'',\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfields: 'revisions(id, exportLinks), nextPageToken',\n\t\t\t\t\t\t\tpageToken,\n\t\t\t\t\t\t\tpageSize: 1000,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t`https://www.googleapis.com/drive/v3/files/${documentId}/revisions`,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (nextPageToken) {\n\t\t\t\t\t\tpageToken = nextPageToken as string;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpageToken = undefined;\n\n\t\t\t\t\t\tconst lastRevision = +revisions[revisions.length - 1].id;\n\t\t\t\t\t\tif (lastRevision <= previousRevision) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (this.getMode() !== 'manual') {\n\t\t\t\t\t\t\t\tworkflowStaticData.lastRevision = lastRevision;\n\t\t\t\t\t\t\t\tworkflowStaticData.lastRevisionLink =\n\t\t\t\t\t\t\t\t\trevisions[revisions.length - 1].exportLinks[BINARY_MIME_TYPE];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} while (pageToken);\n\t\t\t}\n\n\t\t\tlet range = 'A:ZZZ';\n\t\t\tlet keyRow = 1;\n\t\t\tlet startIndex = 2;\n\n\t\t\tlet rangeDefinition = '';\n\n\t\t\tconst [from, to] = range.split(':');\n\t\t\tlet keyRange = `${from}${keyRow}:${to}${keyRow}`;\n\t\t\tlet rangeToCheck = `${from}${keyRow}:${to}`;\n\n\t\t\tif (options.dataLocationOnSheet) {\n\t\t\t\tconst locationDefine = (options.dataLocationOnSheet as IDataObject).values as IDataObject;\n\t\t\t\trangeDefinition = locationDefine.rangeDefinition as string;\n\n\t\t\t\tif (rangeDefinition === 'specifyRangeA1') {\n\t\t\t\t\tif (locationDefine.range === '') {\n\t\t\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t\t\t\"The field 'Range' is empty, please provide a range\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\trange = locationDefine.range as string;\n\t\t\t\t}\n\n\t\t\t\tif (rangeDefinition === 'specifyRange') {\n\t\t\t\t\tkeyRow = parseInt(locationDefine.headerRow as string, 10);\n\t\t\t\t\tstartIndex = parseInt(locationDefine.firstDataRow as string, 10);\n\t\t\t\t}\n\n\t\t\t\tconst [rangeFrom, rangeTo] = range.split(':');\n\t\t\t\tconst cellDataFrom = rangeFrom.match(/([a-zA-Z]{1,10})([0-9]{0,10})/) || [];\n\t\t\t\tconst cellDataTo = rangeTo.match(/([a-zA-Z]{1,10})([0-9]{0,10})/) || [];\n\n\t\t\t\tif (rangeDefinition === 'specifyRangeA1' && cellDataFrom[2] !== undefined) {\n\t\t\t\t\tkeyRange = `${cellDataFrom[1]}${+cellDataFrom[2]}:${cellDataTo[1]}${+cellDataFrom[2]}`;\n\t\t\t\t\trangeToCheck = `${cellDataFrom[1]}${+cellDataFrom[2] + 1}:${rangeTo}`;\n\t\t\t\t} else {\n\t\t\t\t\tkeyRange = `${cellDataFrom[1]}${keyRow}:${cellDataTo[1]}${keyRow}`;\n\t\t\t\t\trangeToCheck = `${cellDataFrom[1]}${keyRow}:${rangeTo}`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst qs: IDataObject = {};\n\n\t\t\tObject.assign(qs, options);\n\n\t\t\tif (event === 'rowAdded') {\n\t\t\t\tconst [columns] = ((\n\t\t\t\t\t(await apiRequest.call(\n\t\t\t\t\t\tthis,\n\t\t\t\t\t\t'GET',\n\t\t\t\t\t\t`/v4/spreadsheets/${documentId}/values/${encodeURIComponent(sheetName)}!${keyRange}`,\n\t\t\t\t\t)) as IDataObject\n\t\t\t\t).values as string[][]) || [[]];\n\n\t\t\t\tif (!columns?.length) {\n\t\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t\t'Could not retrieve the columns from key row',\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst sheetData = await googleSheet.getData(\n\t\t\t\t\t`${sheetName}!${rangeToCheck}`,\n\t\t\t\t\t(options.valueRender as ValueRenderOption) || 'UNFORMATTED_VALUE',\n\t\t\t\t\t(options.dateTimeRenderOption as string) || 'FORMATTED_STRING',\n\t\t\t\t);\n\n\t\t\t\tif (Array.isArray(sheetData) && sheetData.length !== 0) {\n\t\t\t\t\tsheetData.splice(0, 1); // Remove header row\n\t\t\t\t}\n\n\t\t\t\tlet dataStartIndex = 0;\n\t\t\t\tif (rangeDefinition === 'specifyRange' && keyRow < startIndex) {\n\t\t\t\t\tdataStartIndex = startIndex - keyRow - 1;\n\t\t\t\t}\n\n\t\t\t\tif (this.getMode() === 'manual') {\n\t\t\t\t\tif (Array.isArray(sheetData)) {\n\t\t\t\t\t\tconst sheetDataFromStartIndex = sheetData.slice(dataStartIndex);\n\t\t\t\t\t\tconst returnData = arrayOfArraysToJson(sheetDataFromStartIndex, columns);\n\n\t\t\t\t\t\tif (Array.isArray(returnData) && returnData.length !== 0) {\n\t\t\t\t\t\t\treturn [this.helpers.returnJsonArray(returnData)];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (Array.isArray(sheetData) && this.getMode() !== 'manual') {\n\t\t\t\t\tif (workflowStaticData.lastIndexChecked === undefined) {\n\t\t\t\t\t\tworkflowStaticData.lastIndexChecked = sheetData.length;\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst rowsStartIndex = Math.max(\n\t\t\t\t\t\tworkflowStaticData.lastIndexChecked as number,\n\t\t\t\t\t\tdataStartIndex,\n\t\t\t\t\t);\n\t\t\t\t\tconst addedRows = sheetData?.slice(rowsStartIndex) || [];\n\t\t\t\t\tconst returnData = arrayOfArraysToJson(addedRows, columns);\n\n\t\t\t\t\tworkflowStaticData.lastIndexChecked = sheetData.length;\n\n\t\t\t\t\tif (Array.isArray(returnData) && returnData.length !== 0) {\n\t\t\t\t\t\treturn [this.helpers.returnJsonArray(returnData)];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (event === 'anyUpdate' || event === 'rowUpdate') {\n\t\t\t\tif (sheetName.length > 31) {\n\t\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t\t'Sheet name is too long choose a name with 31 characters or less',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst sheetRange = `${sheetName}!${range}`;\n\n\t\t\t\tlet dataStartIndex = startIndex - 1;\n\t\t\t\tif (rangeDefinition !== 'specifyRangeA1') {\n\t\t\t\t\tdataStartIndex = keyRow < startIndex ? startIndex - 2 : startIndex - 1;\n\t\t\t\t}\n\n\t\t\t\tconst currentData =\n\t\t\t\t\t((await googleSheet.getData(\n\t\t\t\t\t\tsheetRange,\n\t\t\t\t\t\t'UNFORMATTED_VALUE',\n\t\t\t\t\t\t'SERIAL_NUMBER',\n\t\t\t\t\t)) as string[][]) || [];\n\n\t\t\t\tif (previousRevision === undefined) {\n\t\t\t\t\tif (currentData.length === 0) {\n\t\t\t\t\t\treturn [[]];\n\t\t\t\t\t}\n\t\t\t\t\tconst zeroBasedKeyRow = keyRow - 1;\n\t\t\t\t\tconst columns = currentData[zeroBasedKeyRow];\n\t\t\t\t\tcurrentData.splice(zeroBasedKeyRow, 1); // Remove key row\n\n\t\t\t\t\tlet returnData;\n\t\t\t\t\tif (rangeDefinition !== 'specifyRangeA1') {\n\t\t\t\t\t\treturnData = arrayOfArraysToJson(currentData.slice(dataStartIndex), columns);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturnData = arrayOfArraysToJson(currentData, columns);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (Array.isArray(returnData) && returnData.length !== 0 && this.getMode() === 'manual') {\n\t\t\t\t\t\treturn [this.helpers.returnJsonArray(returnData)];\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst previousRevisionBinaryData = await getRevisionFile.call(this, previousRevisionLink);\n\n\t\t\t\tconst previousRevisionSheetData =\n\t\t\t\t\tsheetBinaryToArrayOfArrays(\n\t\t\t\t\t\tpreviousRevisionBinaryData,\n\t\t\t\t\t\tsheetName,\n\t\t\t\t\t\trangeDefinition === 'specifyRangeA1' ? range : undefined,\n\t\t\t\t\t) || [];\n\n\t\t\t\tconst includeInOutput = this.getNodeParameter('includeInOutput', 'new') as string;\n\n\t\t\t\tlet returnData;\n\t\t\t\tif (options.columnsToWatch) {\n\t\t\t\t\treturnData = compareRevisions(\n\t\t\t\t\t\tpreviousRevisionSheetData,\n\t\t\t\t\t\tcurrentData,\n\t\t\t\t\t\tkeyRow,\n\t\t\t\t\t\tincludeInOutput,\n\t\t\t\t\t\toptions.columnsToWatch as string[],\n\t\t\t\t\t\tdataStartIndex,\n\t\t\t\t\t\tevent,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\treturnData = compareRevisions(\n\t\t\t\t\t\tpreviousRevisionSheetData,\n\t\t\t\t\t\tcurrentData,\n\t\t\t\t\t\tkeyRow,\n\t\t\t\t\t\tincludeInOutput,\n\t\t\t\t\t\t[],\n\t\t\t\t\t\tdataStartIndex,\n\t\t\t\t\t\tevent,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (Array.isArray(returnData) && returnData.length !== 0) {\n\t\t\t\t\treturn [this.helpers.returnJsonArray(returnData)];\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (\n\t\t\t\terror?.description\n\t\t\t\t\t?.toLowerCase()\n\t\t\t\t\t.includes('user does not have sufficient permissions for file')\n\t\t\t) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t\"Edit access to the document is required for the 'Row Update' and 'Row Added or Updated' triggers. Request edit access to the document's owner or select the 'Row Added' trigger in the 'Trigger On' dropdown.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (\n\t\t\t\terror?.error?.error?.message !== undefined &&\n\t\t\t\t!(error.error.error.message as string).toLocaleLowerCase().includes('unknown error') &&\n\t\t\t\t!(error.error.error.message as string).toLocaleLowerCase().includes('bad request')\n\t\t\t) {\n\t\t\t\t// eslint-disable-next-line prefer-const\n\t\t\t\tlet [message, ...description] = (error.error.error.message as string).split('. ');\n\t\t\t\tif (message.toLowerCase() === 'access not configured') {\n\t\t\t\t\tmessage = 'Missing Google Drive API';\n\t\t\t\t}\n\t\t\t\tthrow new NodeOperationError(this.getNode(), message, {\n\t\t\t\t\tdescription: description.join('.\\n '),\n\t\t\t\t});\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t\treturn null;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,0BAAwD;AAExD,iCAMO;AACP,yBAA4B;AAE5B,wBAAiD;AACjD,yBAA8C;AAC9C,uBAA2B;AAC3B,uBAA2E;AAEpE,MAAM,oBAAyC;AAAA,EAA/C;AACN,uBAAoC;AAAA,MACnC,aAAa;AAAA,MACb,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,CAAC,SAAS;AAAA,MACjB,SAAS;AAAA,MACT,UAAU;AAAA,MACV,aAAa;AAAA,MACb,UAAU;AAAA,QACT,MAAM;AAAA,MACP;AAAA,MACA,QAAQ,CAAC;AAAA,MACT,SAAS,CAAC,wCAAoB,IAAI;AAAA,MAClC,aAAa;AAAA,QACZ;AAAA,UACC,MAAM;AAAA,UACN,UAAU;AAAA,UACV,gBAAgB;AAAA,YACf,MAAM;AAAA,cACL,gBAAgB,CAAC,eAAe;AAAA,YACjC;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MACA,SAAS;AAAA,MACT,YAAY;AAAA;AAAA,QAEX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K,QAAQ;AAAA,UACb;AAAA,QACD;AAAA,MACD;AACA,UACC,OAAO,OAAO,OAAO,YAAY,UACjC,CAAE,MAAM,MAAM,MAAM,QAAmB,kBAAkB,EAAE,SAAS,eAAe,KACnF,CAAE,MAAM,MAAM,MAAM,QAAmB,kBAAkB,EAAE,SAAS,aAAa,GAChF;AAED,YAAI,CAAC,SAAS,GAAG,WAAW,IAAK,MAAM,MAAM,MAAM,QAAmB,MAAM,IAAI;AAChF,YAAI,QAAQ,YAAY,MAAM,yBAAyB;AACtD,oBAAU;AAAA,QACX;AACA,cAAM,IAAI,uCAAmB,KAAK,QAAQ,GAAG,SAAS;AAAA,UACrD,aAAa,YAAY,KAAK,MAAM;AAAA,QACrC,CAAC;AAAA,MACF;AACA,YAAM;AAAA,IACP;AACA,WAAO;AAAA,EACR;AACD;","names":["returnData"]}
|
|
@@ -82,14 +82,18 @@ async function jiraSoftwareCloudApiRequestAllItems(propertyName, endpoint, metho
|
|
|
82
82
|
const returnData = [];
|
|
83
83
|
let responseData;
|
|
84
84
|
query.startAt = 0;
|
|
85
|
-
body.startAt = 0;
|
|
86
85
|
query.maxResults = 100;
|
|
87
|
-
|
|
86
|
+
if (method !== "GET") {
|
|
87
|
+
body.startAt = 0;
|
|
88
|
+
body.maxResults = 100;
|
|
89
|
+
}
|
|
88
90
|
do {
|
|
89
91
|
responseData = await jiraSoftwareCloudApiRequest.call(this, endpoint, method, body, query);
|
|
90
92
|
returnData.push.apply(returnData, responseData[propertyName]);
|
|
91
93
|
query.startAt = responseData.startAt + responseData.maxResults;
|
|
92
|
-
|
|
94
|
+
if (method !== "GET") {
|
|
95
|
+
body.startAt = responseData.startAt + responseData.maxResults;
|
|
96
|
+
}
|
|
93
97
|
} while (responseData.startAt + responseData.maxResults < responseData.total);
|
|
94
98
|
return returnData;
|
|
95
99
|
}
|