@fsai-flow/core 0.0.4 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/dist/index.d.ts +17 -0
  2. package/dist/index.js +61 -0
  3. package/dist/{src/lib → lib}/ActiveWebhooks.d.ts +1 -1
  4. package/dist/lib/ActiveWebhooks.js +177 -0
  5. package/dist/{src/lib → lib}/ActiveWorkflows.d.ts +3 -3
  6. package/dist/lib/ActiveWorkflows.js +465 -0
  7. package/dist/{src/lib → lib}/BinaryDataManager/FileSystem.d.ts +1 -1
  8. package/dist/lib/BinaryDataManager/FileSystem.js +180 -0
  9. package/dist/{src/lib → lib}/BinaryDataManager/index.d.ts +2 -2
  10. package/dist/lib/BinaryDataManager/index.js +129 -0
  11. package/dist/{src/lib → lib}/ChangeCase.js +11 -11
  12. package/dist/lib/Constants.js +18 -0
  13. package/dist/{src/lib → lib}/Credentials.d.ts +1 -1
  14. package/dist/{src/lib → lib}/Credentials.js +7 -8
  15. package/dist/{src/lib → lib}/FileSystem.d.ts +1 -1
  16. package/dist/lib/FileSystem.js +180 -0
  17. package/dist/{src/lib → lib}/InputConnectionDataLegacy.d.ts +1 -1
  18. package/dist/lib/InputConnectionDataLegacy.js +72 -0
  19. package/dist/{src/lib → lib}/Interfaces.d.ts +47 -48
  20. package/dist/{src/lib → lib}/Interfaces.js +0 -1
  21. package/dist/{src/lib → lib}/LoadNodeParameterOptions.d.ts +1 -1
  22. package/dist/lib/LoadNodeParameterOptions.js +152 -0
  23. package/dist/{src/lib → lib}/NodeExecuteFunctions.d.ts +9 -10
  24. package/dist/lib/NodeExecuteFunctions.js +2467 -0
  25. package/dist/{src/lib → lib}/NodesLoader/constants.d.ts +1 -1
  26. package/dist/lib/NodesLoader/constants.js +105 -0
  27. package/dist/{src/lib → lib}/NodesLoader/custom-directory-loader.d.ts +1 -1
  28. package/dist/lib/NodesLoader/custom-directory-loader.js +35 -0
  29. package/dist/{src/lib → lib}/NodesLoader/directory-loader.d.ts +1 -1
  30. package/dist/{src/lib → lib}/NodesLoader/directory-loader.js +80 -38
  31. package/dist/lib/NodesLoader/index.d.ts +5 -0
  32. package/dist/{src/lib → lib}/NodesLoader/index.js +5 -6
  33. package/dist/{src/lib → lib}/NodesLoader/lazy-package-directory-loader.d.ts +1 -1
  34. package/dist/lib/NodesLoader/lazy-package-directory-loader.js +44 -0
  35. package/dist/{src/lib → lib}/NodesLoader/load-class-in-isolation.js +6 -11
  36. package/dist/{src/lib → lib}/NodesLoader/package-directory-loader.d.ts +2 -2
  37. package/dist/{src/lib → lib}/NodesLoader/package-directory-loader.js +28 -36
  38. package/dist/{src/lib → lib}/NodesLoader/types.js +0 -1
  39. package/dist/{src/lib → lib}/RedisLeaderElectionManager.d.ts +1 -1
  40. package/dist/lib/RedisLeaderElectionManager.js +279 -0
  41. package/dist/lib/RequestTypes.d.ts +58 -0
  42. package/dist/lib/RequestTypes.js +8 -0
  43. package/dist/{src/lib → lib}/UserSettings.d.ts +1 -1
  44. package/dist/lib/UserSettings.js +269 -0
  45. package/dist/{src/lib → lib}/WorkflowExecute.d.ts +4 -4
  46. package/dist/{src/lib → lib}/WorkflowExecute.js +230 -178
  47. package/dist/{src/lib → lib}/index.d.ts +2 -2
  48. package/dist/lib/index.js +129 -0
  49. package/dist/{src/utils → utils}/crypto.js +2 -3
  50. package/package.json +59 -52
  51. package/dist/README.md +0 -31
  52. package/dist/package.json +0 -54
  53. package/dist/src/index.d.ts +0 -16
  54. package/dist/src/index.js +0 -30
  55. package/dist/src/index.js.map +0 -1
  56. package/dist/src/lib/ActiveWebhooks.js +0 -184
  57. package/dist/src/lib/ActiveWebhooks.js.map +0 -1
  58. package/dist/src/lib/ActiveWorkflows.js +0 -456
  59. package/dist/src/lib/ActiveWorkflows.js.map +0 -1
  60. package/dist/src/lib/BinaryDataManager/FileSystem.js +0 -179
  61. package/dist/src/lib/BinaryDataManager/FileSystem.js.map +0 -1
  62. package/dist/src/lib/BinaryDataManager/index.js +0 -146
  63. package/dist/src/lib/BinaryDataManager/index.js.map +0 -1
  64. package/dist/src/lib/ChangeCase.js.map +0 -1
  65. package/dist/src/lib/Constants.js +0 -19
  66. package/dist/src/lib/Constants.js.map +0 -1
  67. package/dist/src/lib/Credentials.js.map +0 -1
  68. package/dist/src/lib/FileSystem.js +0 -179
  69. package/dist/src/lib/FileSystem.js.map +0 -1
  70. package/dist/src/lib/InputConnectionDataLegacy.js +0 -79
  71. package/dist/src/lib/InputConnectionDataLegacy.js.map +0 -1
  72. package/dist/src/lib/Interfaces.js.map +0 -1
  73. package/dist/src/lib/LoadNodeParameterOptions.js +0 -150
  74. package/dist/src/lib/LoadNodeParameterOptions.js.map +0 -1
  75. package/dist/src/lib/NodeExecuteFunctions.js +0 -2479
  76. package/dist/src/lib/NodeExecuteFunctions.js.map +0 -1
  77. package/dist/src/lib/NodesLoader/constants.js +0 -106
  78. package/dist/src/lib/NodesLoader/constants.js.map +0 -1
  79. package/dist/src/lib/NodesLoader/custom-directory-loader.js +0 -36
  80. package/dist/src/lib/NodesLoader/custom-directory-loader.js.map +0 -1
  81. package/dist/src/lib/NodesLoader/directory-loader.js.map +0 -1
  82. package/dist/src/lib/NodesLoader/index.d.ts +0 -5
  83. package/dist/src/lib/NodesLoader/index.js.map +0 -1
  84. package/dist/src/lib/NodesLoader/lazy-package-directory-loader.js +0 -52
  85. package/dist/src/lib/NodesLoader/lazy-package-directory-loader.js.map +0 -1
  86. package/dist/src/lib/NodesLoader/load-class-in-isolation.js.map +0 -1
  87. package/dist/src/lib/NodesLoader/package-directory-loader.js.map +0 -1
  88. package/dist/src/lib/NodesLoader/types.js.map +0 -1
  89. package/dist/src/lib/RedisLeaderElectionManager.js +0 -294
  90. package/dist/src/lib/RedisLeaderElectionManager.js.map +0 -1
  91. package/dist/src/lib/UserSettings.js +0 -261
  92. package/dist/src/lib/UserSettings.js.map +0 -1
  93. package/dist/src/lib/WorkflowExecute.js.map +0 -1
  94. package/dist/src/lib/index.js +0 -146
  95. package/dist/src/lib/index.js.map +0 -1
  96. package/dist/src/utils/crypto.js.map +0 -1
  97. package/eslint.config.js +0 -19
  98. package/jest.config.ts +0 -10
  99. package/project.json +0 -19
  100. package/src/index.ts +0 -28
  101. package/src/lib/ActiveWebhooks.ts +0 -245
  102. package/src/lib/ActiveWorkflows.ts +0 -575
  103. package/src/lib/BinaryDataManager/FileSystem.ts +0 -214
  104. package/src/lib/BinaryDataManager/index.ts +0 -187
  105. package/src/lib/ChangeCase.ts +0 -45
  106. package/src/lib/Constants.ts +0 -16
  107. package/src/lib/Credentials.ts +0 -108
  108. package/src/lib/FileSystem.ts +0 -214
  109. package/src/lib/InputConnectionDataLegacy.ts +0 -123
  110. package/src/lib/Interfaces.ts +0 -338
  111. package/src/lib/LoadNodeParameterOptions.ts +0 -235
  112. package/src/lib/NodeExecuteFunctions.ts +0 -3700
  113. package/src/lib/NodesLoader/constants.ts +0 -112
  114. package/src/lib/NodesLoader/custom-directory-loader.ts +0 -31
  115. package/src/lib/NodesLoader/directory-loader.ts +0 -458
  116. package/src/lib/NodesLoader/index.ts +0 -5
  117. package/src/lib/NodesLoader/lazy-package-directory-loader.ts +0 -55
  118. package/src/lib/NodesLoader/load-class-in-isolation.ts +0 -19
  119. package/src/lib/NodesLoader/package-directory-loader.ts +0 -107
  120. package/src/lib/NodesLoader/types.ts +0 -14
  121. package/src/lib/RedisLeaderElectionManager.ts +0 -334
  122. package/src/lib/UserSettings.ts +0 -292
  123. package/src/lib/WorkflowExecute.ts +0 -1128
  124. package/src/lib/index.ts +0 -187
  125. package/src/utils/crypto.ts +0 -5
  126. package/tests/Credentials.test.ts +0 -88
  127. package/tests/Helpers.ts +0 -808
  128. package/tests/WorkflowExecute.test.ts +0 -1242
  129. package/tsconfig.json +0 -41
  130. package/tsconfig.lib.json +0 -10
  131. package/tsconfig.spec.json +0 -14
  132. /package/dist/{src/lib → lib}/ChangeCase.d.ts +0 -0
  133. /package/dist/{src/lib → lib}/Constants.d.ts +0 -0
  134. /package/dist/{src/lib → lib}/NodesLoader/load-class-in-isolation.d.ts +0 -0
  135. /package/dist/{src/lib → lib}/NodesLoader/types.d.ts +0 -0
  136. /package/dist/{src/utils → utils}/crypto.d.ts +0 -0
@@ -1,4 +1,4 @@
1
- import type { INodeProperties } from '@fsai-flow/workflow';
1
+ import type { INodeProperties } from "@fsai-flow/workflow";
2
2
  export declare const CUSTOM_NODES_CATEGORY = "Custom Nodes";
3
3
  export declare const commonPollingParameters: INodeProperties[];
4
4
  export declare const commonCORSParameters: INodeProperties[];
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.commonDeclarativeNodeOptionParameters = exports.commonCORSParameters = exports.commonPollingParameters = exports.CUSTOM_NODES_CATEGORY = void 0;
4
+ const workflow_1 = require("@fsai-flow/workflow");
5
+ exports.CUSTOM_NODES_CATEGORY = "Custom Nodes";
6
+ exports.commonPollingParameters = [
7
+ {
8
+ displayName: "Poll Times",
9
+ name: "pollTimes",
10
+ type: "fixedCollection",
11
+ typeOptions: {
12
+ multipleValues: true,
13
+ multipleValueButtonText: "Add Poll Time",
14
+ },
15
+ default: { item: [{ mode: "everyMinute" }] },
16
+ description: "Time at which polling should occur",
17
+ placeholder: "Add Poll Time",
18
+ options: workflow_1.cronNodeOptions,
19
+ },
20
+ ];
21
+ exports.commonCORSParameters = [
22
+ {
23
+ displayName: "Allowed Origins (CORS)",
24
+ name: "allowedOrigins",
25
+ type: "string",
26
+ default: "*",
27
+ description: "Comma-separated list of URLs allowed for cross-origin non-preflight requests. Use * (default) to allow all origins.",
28
+ },
29
+ ];
30
+ exports.commonDeclarativeNodeOptionParameters = {
31
+ displayName: "Request Options",
32
+ name: "requestOptions",
33
+ type: "collection",
34
+ isNodeSetting: true,
35
+ placeholder: "Add Option",
36
+ default: {},
37
+ options: [
38
+ {
39
+ displayName: "Batching",
40
+ name: "batching",
41
+ placeholder: "Add Batching",
42
+ type: "fixedCollection",
43
+ typeOptions: {
44
+ multipleValues: false,
45
+ },
46
+ default: {
47
+ batch: {},
48
+ },
49
+ options: [
50
+ {
51
+ displayName: "Batching",
52
+ name: "batch",
53
+ values: [
54
+ {
55
+ displayName: "Items per Batch",
56
+ name: "batchSize",
57
+ type: "number",
58
+ typeOptions: {
59
+ minValue: -1,
60
+ },
61
+ default: 50,
62
+ description: "Input will be split in batches to throttle requests. -1 for disabled. 0 will be treated as 1.",
63
+ },
64
+ {
65
+ displayName: "Batch Interval (ms)",
66
+ name: "batchInterval",
67
+ type: "number",
68
+ typeOptions: {
69
+ minValue: 0,
70
+ },
71
+ default: 1000,
72
+ description: "Time (in milliseconds) between each batch of requests. 0 for disabled.",
73
+ },
74
+ ],
75
+ },
76
+ ],
77
+ },
78
+ {
79
+ displayName: "Ignore SSL Issues (Insecure)",
80
+ name: "allowUnauthorizedCerts",
81
+ type: "boolean",
82
+ noDataExpression: true,
83
+ default: false,
84
+ description: "Whether to accept the response even if SSL certificate validation is not possible",
85
+ },
86
+ {
87
+ displayName: "Proxy",
88
+ name: "proxy",
89
+ type: "string",
90
+ default: "",
91
+ placeholder: "e.g. http://myproxy:3128",
92
+ description: "HTTP proxy to use. If authentication is required it can be defined as follow: http://username:password@myproxy:3128",
93
+ },
94
+ {
95
+ displayName: "Timeout",
96
+ name: "timeout",
97
+ type: "number",
98
+ typeOptions: {
99
+ minValue: 1,
100
+ },
101
+ default: 10000,
102
+ description: "Time in ms to wait for the server to send response headers (and start the response body) before aborting the request",
103
+ },
104
+ ],
105
+ };
@@ -1,4 +1,4 @@
1
- import { DirectoryLoader } from './directory-loader';
1
+ import { DirectoryLoader } from "./directory-loader";
2
2
  /**
3
3
  * Loader for source files of nodes and credentials located in a custom dir,
4
4
  * e.g. `~/.n8n/custom`
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CustomDirectoryLoader = void 0;
7
+ const fast_glob_1 = __importDefault(require("fast-glob"));
8
+ const directory_loader_1 = require("./directory-loader");
9
+ /**
10
+ * Loader for source files of nodes and credentials located in a custom dir,
11
+ * e.g. `~/.n8n/custom`
12
+ */
13
+ class CustomDirectoryLoader extends directory_loader_1.DirectoryLoader {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.packageName = "CUSTOM";
17
+ }
18
+ async loadAll() {
19
+ const nodes = await (0, fast_glob_1.default)("**/*.node.js", {
20
+ cwd: this.directory,
21
+ absolute: true,
22
+ });
23
+ for (const nodePath of nodes) {
24
+ this.loadNodeFromFile(nodePath);
25
+ }
26
+ const credentials = await (0, fast_glob_1.default)("**/*.credentials.js", {
27
+ cwd: this.directory,
28
+ absolute: true,
29
+ });
30
+ for (const credentialPath of credentials) {
31
+ this.loadCredentialFromFile(credentialPath);
32
+ }
33
+ }
34
+ }
35
+ exports.CustomDirectoryLoader = CustomDirectoryLoader;
@@ -1,4 +1,4 @@
1
- import type { ICredentialType, ICredentialTypeData, INodeCredentialDescription, INodeType, INodeTypeBaseDescription, INodeTypeData, INodeTypeNameVersion, IVersionedNodeType, KnownNodesAndCredentials } from '@fsai-flow/workflow';
1
+ import type { ICredentialType, ICredentialTypeData, INodeCredentialDescription, INodeType, INodeTypeBaseDescription, INodeTypeData, INodeTypeNameVersion, IVersionedNodeType, KnownNodesAndCredentials } from "@fsai-flow/workflow";
2
2
  export type Types = {
3
3
  nodes: INodeTypeBaseDescription[];
4
4
  credentials: ICredentialType[];
@@ -1,14 +1,52 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
39
  exports.DirectoryLoader = void 0;
4
- const tslib_1 = require("tslib");
5
- const uniqBy_1 = tslib_1.__importDefault(require("lodash/uniqBy"));
40
+ const path = __importStar(require("node:path"));
6
41
  const workflow_1 = require("@fsai-flow/workflow");
7
- const path = tslib_1.__importStar(require("path"));
42
+ const uniqBy_1 = __importDefault(require("lodash/uniqBy"));
8
43
  const constants_1 = require("./constants");
9
44
  const load_class_in_isolation_1 = require("./load-class-in-isolation");
10
45
  function toJSON() {
11
- return Object.assign(Object.assign({}, this), { authenticate: typeof this.authenticate === 'function' ? {} : this.authenticate });
46
+ return {
47
+ ...this,
48
+ authenticate: typeof this.authenticate === "function" ? {} : this.authenticate,
49
+ };
12
50
  }
13
51
  /**
14
52
  * Base class for loading n8n nodes and credentials from a directory.
@@ -45,13 +83,13 @@ class DirectoryLoader {
45
83
  }
46
84
  loadClass(sourcePath) {
47
85
  const filePath = this.resolvePath(sourcePath);
48
- const [className] = path.parse(sourcePath).name.split('.');
86
+ const [className] = path.parse(sourcePath).name.split(".");
49
87
  try {
50
88
  return (0, load_class_in_isolation_1.loadClassInIsolation)(filePath, className);
51
89
  }
52
90
  catch (error) {
53
91
  throw error instanceof TypeError
54
- ? new Error('Class could not be found. Please check if the class is named correctly.')
92
+ ? new Error("Class could not be found. Please check if the class is named correctly.")
55
93
  : error;
56
94
  }
57
95
  }
@@ -68,7 +106,7 @@ class DirectoryLoader {
68
106
  }
69
107
  this.fixIconPaths(tempNode.description, filePath);
70
108
  let nodeVersion = 1;
71
- if ('nodeVersions' in tempNode) {
109
+ if ("nodeVersions" in tempNode) {
72
110
  for (const versionNode of Object.values(tempNode.nodeVersions)) {
73
111
  this.fixIconPaths(versionNode.description, filePath);
74
112
  }
@@ -79,7 +117,7 @@ class DirectoryLoader {
79
117
  const currentVersionNode = tempNode.nodeVersions[tempNode.currentVersion];
80
118
  this.addCodex(currentVersionNode, filePath);
81
119
  nodeVersion = tempNode.currentVersion;
82
- if (currentVersionNode.hasOwnProperty('executeSingle')) {
120
+ if (Object.hasOwn(currentVersionNode, "executeSingle")) {
83
121
  throw new Error('"executeSingle" has been removed. Please update the code of this node to use "execute" instead.');
84
122
  }
85
123
  }
@@ -103,9 +141,9 @@ class DirectoryLoader {
103
141
  name: nodeType,
104
142
  version: nodeVersion,
105
143
  });
106
- this.getVersionedNodeTypeAll(tempNode).forEach(({ description }) => {
144
+ for (const { description } of this.getVersionedNodeTypeAll(tempNode)) {
107
145
  this.types.nodes.push(description);
108
- });
146
+ }
109
147
  for (const credential of this.getCredentialsForNode(tempNode)) {
110
148
  if (!this.nodesByCredential[credential.name]) {
111
149
  this.nodesByCredential[credential.name] = [];
@@ -163,12 +201,11 @@ class DirectoryLoader {
163
201
  * For versioned nodes, combines and deduplicates credentials from all versions.
164
202
  */
165
203
  getCredentialsForNode(object) {
166
- var _a;
167
- if ('nodeVersions' in object) {
168
- const credentials = Object.values(object.nodeVersions).flatMap(({ description }) => { var _a; return (_a = description.credentials) !== null && _a !== void 0 ? _a : []; });
169
- return (0, uniqBy_1.default)(credentials, 'name');
204
+ if ("nodeVersions" in object) {
205
+ const credentials = Object.values(object.nodeVersions).flatMap(({ description }) => description.credentials ?? []);
206
+ return (0, uniqBy_1.default)(credentials, "name");
170
207
  }
171
- return (_a = object.description.credentials) !== null && _a !== void 0 ? _a : [];
208
+ return object.description.credentials ?? [];
172
209
  }
173
210
  /**
174
211
  * Returns an array of all versions of a node type.
@@ -176,7 +213,7 @@ class DirectoryLoader {
176
213
  * For versioned nodes, returns all available versions.
177
214
  */
178
215
  getVersionedNodeTypeAll(object) {
179
- if ('nodeVersions' in object) {
216
+ if ("nodeVersions" in object) {
180
217
  const nodeVersions = Object.values(object.nodeVersions).map((element) => {
181
218
  element.description.name = object.description.name;
182
219
  element.description.codex = object.description.codex;
@@ -184,7 +221,7 @@ class DirectoryLoader {
184
221
  });
185
222
  return (0, uniqBy_1.default)(nodeVersions.reverse(), (node) => {
186
223
  const { version } = node.description;
187
- return Array.isArray(version) ? version.join(',') : version.toString();
224
+ return Array.isArray(version) ? version.join(",") : version.toString();
188
225
  });
189
226
  }
190
227
  return [object];
@@ -196,17 +233,22 @@ class DirectoryLoader {
196
233
  getCodex(filePath) {
197
234
  const codexFilePath = this.resolvePath(`${filePath}on`); // .js to .json
198
235
  const { categories, subcategories, resources: { primaryDocumentation, credentialDocumentation }, alias, } = module.require(codexFilePath);
199
- return Object.assign(Object.assign(Object.assign(Object.assign({}, (categories && { categories })), (subcategories && { subcategories })), (alias && { alias })), { resources: {
236
+ return {
237
+ ...(categories && { categories }),
238
+ ...(subcategories && { subcategories }),
239
+ ...(alias && { alias }),
240
+ resources: {
200
241
  primaryDocumentation,
201
242
  credentialDocumentation,
202
- } });
243
+ },
244
+ };
203
245
  }
204
246
  /**
205
247
  * Adds a node codex `categories` and `subcategories` (if defined)
206
248
  * to a node description `codex` property.
207
249
  */
208
250
  addCodex(node, filePath) {
209
- const isCustom = this.packageName === 'CUSTOM';
251
+ const isCustom = this.packageName === "CUSTOM";
210
252
  try {
211
253
  let codex;
212
254
  if (!isCustom) {
@@ -222,7 +264,7 @@ class DirectoryLoader {
222
264
  }
223
265
  node.description.codex = codex;
224
266
  }
225
- catch (_a) {
267
+ catch {
226
268
  console.debug(`No codex available for: ${node.description.name}`);
227
269
  if (isCustom) {
228
270
  node.description.codex = {
@@ -232,8 +274,7 @@ class DirectoryLoader {
232
274
  }
233
275
  }
234
276
  addLoadOptionsMethods(node) {
235
- var _a;
236
- if ((_a = node === null || node === void 0 ? void 0 : node.methods) === null || _a === void 0 ? void 0 : _a.loadOptions) {
277
+ if (node?.methods?.loadOptions) {
237
278
  node.description.__loadOptionsMethods = Object.keys(node.methods.loadOptions);
238
279
  }
239
280
  }
@@ -243,7 +284,7 @@ class DirectoryLoader {
243
284
  properties.unshift(...constants_1.commonPollingParameters);
244
285
  }
245
286
  if (nodeType.webhook && supportsCORS) {
246
- const optionsProperty = properties.find(({ name }) => name === 'options');
287
+ const optionsProperty = properties.find(({ name }) => name === "options");
247
288
  if (optionsProperty)
248
289
  optionsProperty.options = [
249
290
  ...constants_1.commonCORSParameters,
@@ -255,21 +296,21 @@ class DirectoryLoader {
255
296
  DirectoryLoader.applyDeclarativeNodeOptionParameters(nodeType);
256
297
  }
257
298
  getIconPath(icon, filePath) {
258
- const iconPath = path.join(path.dirname(filePath), icon.replace('file:', ''));
299
+ const iconPath = path.join(path.dirname(filePath), icon.replace("file:", ""));
259
300
  return `icons/${this.packageName}/${iconPath}`;
260
301
  }
261
302
  fixIconPaths(obj, filePath) {
262
303
  const { icon } = obj;
263
304
  if (!icon)
264
305
  return;
265
- if (typeof icon === 'string') {
266
- if (icon.startsWith('file:')) {
306
+ if (typeof icon === "string") {
307
+ if (icon.startsWith("file:")) {
267
308
  obj.iconUrl = this.getIconPath(icon, filePath);
268
309
  obj.icon = undefined;
269
310
  }
270
311
  }
271
- else if (icon.light.startsWith('file:') &&
272
- icon.dark.startsWith('file:')) {
312
+ else if (icon.light.startsWith("file:") &&
313
+ icon.dark.startsWith("file:")) {
273
314
  obj.iconUrl = {
274
315
  light: this.getIconPath(icon.light, filePath),
275
316
  dark: this.getIconPath(icon.dark, filePath),
@@ -279,7 +320,6 @@ class DirectoryLoader {
279
320
  }
280
321
  /** Augments additional `Request Options` property on declarative node-type */
281
322
  static applyDeclarativeNodeOptionParameters(nodeType) {
282
- var _a, _b, _c, _d;
283
323
  if (!!nodeType.execute ||
284
324
  !!nodeType.trigger ||
285
325
  !!nodeType.webhook ||
@@ -294,16 +334,19 @@ class DirectoryLoader {
294
334
  // Was originally under "options" instead of "requestOptions" so the chance
295
335
  // that that existed was quite high. With this name the chance is actually
296
336
  // very low that it already exists but lets leave it in anyway to be sure.
297
- const existingRequestOptionsIndex = parameters.findIndex((parameter) => parameter.name === 'requestOptions');
337
+ const existingRequestOptionsIndex = parameters.findIndex((parameter) => parameter.name === "requestOptions");
298
338
  if (existingRequestOptionsIndex !== -1) {
299
- parameters[existingRequestOptionsIndex] = Object.assign(Object.assign({}, constants_1.commonDeclarativeNodeOptionParameters), { options: [
300
- ...((_a = constants_1.commonDeclarativeNodeOptionParameters.options) !== null && _a !== void 0 ? _a : []),
301
- ...((_c = (_b = parameters[existingRequestOptionsIndex]) === null || _b === void 0 ? void 0 : _b.options) !== null && _c !== void 0 ? _c : []),
302
- ] });
303
- const options = (_d = parameters[existingRequestOptionsIndex]) === null || _d === void 0 ? void 0 : _d.options;
339
+ parameters[existingRequestOptionsIndex] = {
340
+ ...constants_1.commonDeclarativeNodeOptionParameters,
341
+ options: [
342
+ ...(constants_1.commonDeclarativeNodeOptionParameters.options ?? []),
343
+ ...(parameters[existingRequestOptionsIndex]?.options ?? []),
344
+ ],
345
+ };
346
+ const options = parameters[existingRequestOptionsIndex]?.options;
304
347
  if (options) {
305
348
  options.sort((a, b) => {
306
- if ('displayName' in a && 'displayName' in b) {
349
+ if ("displayName" in a && "displayName" in b) {
307
350
  if (a.displayName < b.displayName) {
308
351
  return -1;
309
352
  }
@@ -322,4 +365,3 @@ class DirectoryLoader {
322
365
  }
323
366
  }
324
367
  exports.DirectoryLoader = DirectoryLoader;
325
- //# sourceMappingURL=directory-loader.js.map
@@ -0,0 +1,5 @@
1
+ export { CustomDirectoryLoader } from "./custom-directory-loader";
2
+ export { DirectoryLoader, type Types } from "./directory-loader";
3
+ export { LazyPackageDirectoryLoader } from "./lazy-package-directory-loader";
4
+ export { PackageDirectoryLoader } from "./package-directory-loader";
5
+ export type { n8n } from "./types";
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LazyPackageDirectoryLoader = exports.PackageDirectoryLoader = exports.CustomDirectoryLoader = exports.DirectoryLoader = void 0;
4
- var directory_loader_1 = require("./directory-loader");
5
- Object.defineProperty(exports, "DirectoryLoader", { enumerable: true, get: function () { return directory_loader_1.DirectoryLoader; } });
3
+ exports.PackageDirectoryLoader = exports.LazyPackageDirectoryLoader = exports.DirectoryLoader = exports.CustomDirectoryLoader = void 0;
6
4
  var custom_directory_loader_1 = require("./custom-directory-loader");
7
5
  Object.defineProperty(exports, "CustomDirectoryLoader", { enumerable: true, get: function () { return custom_directory_loader_1.CustomDirectoryLoader; } });
8
- var package_directory_loader_1 = require("./package-directory-loader");
9
- Object.defineProperty(exports, "PackageDirectoryLoader", { enumerable: true, get: function () { return package_directory_loader_1.PackageDirectoryLoader; } });
6
+ var directory_loader_1 = require("./directory-loader");
7
+ Object.defineProperty(exports, "DirectoryLoader", { enumerable: true, get: function () { return directory_loader_1.DirectoryLoader; } });
10
8
  var lazy_package_directory_loader_1 = require("./lazy-package-directory-loader");
11
9
  Object.defineProperty(exports, "LazyPackageDirectoryLoader", { enumerable: true, get: function () { return lazy_package_directory_loader_1.LazyPackageDirectoryLoader; } });
12
- //# sourceMappingURL=index.js.map
10
+ var package_directory_loader_1 = require("./package-directory-loader");
11
+ Object.defineProperty(exports, "PackageDirectoryLoader", { enumerable: true, get: function () { return package_directory_loader_1.PackageDirectoryLoader; } });
@@ -1,4 +1,4 @@
1
- import { PackageDirectoryLoader } from './package-directory-loader';
1
+ import { PackageDirectoryLoader } from "./package-directory-loader";
2
2
  /**
3
3
  * This loader extends PackageDirectoryLoader to load node and credentials lazily, if possible
4
4
  */
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LazyPackageDirectoryLoader = void 0;
4
+ const package_directory_loader_1 = require("./package-directory-loader");
5
+ /**
6
+ * This loader extends PackageDirectoryLoader to load node and credentials lazily, if possible
7
+ */
8
+ class LazyPackageDirectoryLoader extends package_directory_loader_1.PackageDirectoryLoader {
9
+ async loadAll() {
10
+ try {
11
+ this.known.nodes = await this.readJSON("dist/known/nodes.json");
12
+ this.known.credentials = await this.readJSON("dist/known/credentials.json");
13
+ this.types.nodes = await this.readJSON("dist/types/nodes.json");
14
+ this.types.credentials = await this.readJSON("dist/types/credentials.json");
15
+ if (this.includeNodes.length) {
16
+ const allowedNodes = {};
17
+ for (const nodeType of this.includeNodes) {
18
+ if (nodeType in this.known.nodes) {
19
+ allowedNodes[nodeType] = this.known.nodes[nodeType];
20
+ }
21
+ }
22
+ this.known.nodes = allowedNodes;
23
+ this.types.nodes = this.types.nodes.filter((nodeType) => this.includeNodes.includes(nodeType.name));
24
+ }
25
+ if (this.excludeNodes.length) {
26
+ for (const nodeType of this.excludeNodes) {
27
+ delete this.known.nodes[nodeType];
28
+ }
29
+ this.types.nodes = this.types.nodes.filter((nodeType) => !this.excludeNodes.includes(nodeType.name));
30
+ }
31
+ console.debug(`Lazy-loading nodes and credentials from ${this.packageJson.name}`, {
32
+ nodes: this.types.nodes?.length ?? 0,
33
+ credentials: this.types.credentials?.length ?? 0,
34
+ });
35
+ this.isLazyLoaded = true;
36
+ return; // We can load nodes and credentials lazily now
37
+ }
38
+ catch {
39
+ console.debug("Can't enable lazy-loading");
40
+ await super.loadAll();
41
+ }
42
+ }
43
+ }
44
+ exports.LazyPackageDirectoryLoader = LazyPackageDirectoryLoader;
@@ -1,22 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadClassInIsolation = void 0;
4
- const vm_1 = require("vm");
4
+ const node_vm_1 = require("node:vm");
5
5
  const Constants_1 = require("../Constants");
6
- const context = (0, vm_1.createContext)({ require });
6
+ const context = (0, node_vm_1.createContext)({ require });
7
7
  const loadClassInIsolation = (filePath, className) => {
8
- if (process.platform === 'win32') {
9
- filePath = filePath.replace(/\\/g, '/');
10
- }
8
+ const normalizedPath = process.platform === "win32" ? filePath.replace(/\\/g, "/") : filePath;
11
9
  // Note: Skip the isolation because it breaks nock mocks in tests
12
10
  if (Constants_1.inTest) {
13
11
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access
14
- return new (require(filePath)[className])();
15
- }
16
- else {
17
- const script = new vm_1.Script(`new (require('${filePath}').${className})()`);
18
- return script.runInContext(context);
12
+ return new (require(normalizedPath)[className])();
19
13
  }
14
+ const script = new node_vm_1.Script(`new (require('${normalizedPath}').${className})()`);
15
+ return script.runInContext(context);
20
16
  };
21
17
  exports.loadClassInIsolation = loadClassInIsolation;
22
- //# sourceMappingURL=load-class-in-isolation.js.map
@@ -1,5 +1,5 @@
1
- import { DirectoryLoader } from './directory-loader';
2
- import type { n8n } from './types';
1
+ import { DirectoryLoader } from "./directory-loader";
2
+ import type { n8n } from "./types";
3
3
  /**
4
4
  * Loader for source files of nodes and credentials located in a package dir,
5
5
  * e.g. /nodes-base or community packages.
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PackageDirectoryLoader = void 0;
4
- const tslib_1 = require("tslib");
5
- const workflow_1 = require("@fsai-flow/workflow");
6
4
  const node_fs_1 = require("node:fs");
7
5
  const promises_1 = require("node:fs/promises");
6
+ const workflow_1 = require("@fsai-flow/workflow");
8
7
  const directory_loader_1 = require("./directory-loader");
9
8
  /**
10
9
  * Loader for source files of nodes and credentials located in a package dir,
@@ -13,53 +12,49 @@ const directory_loader_1 = require("./directory-loader");
13
12
  class PackageDirectoryLoader extends directory_loader_1.DirectoryLoader {
14
13
  constructor(directory, excludeNodes = [], includeNodes = []) {
15
14
  super(directory, excludeNodes, includeNodes);
16
- this.packageJson = this.readJSONSync('package.json');
15
+ this.packageJson = this.readJSONSync("package.json");
17
16
  this.packageName = this.packageJson.name;
18
17
  this.excludeNodes = this.extractNodeTypes(excludeNodes);
19
18
  this.includeNodes = this.extractNodeTypes(includeNodes);
20
19
  }
21
20
  extractNodeTypes(fullNodeTypes) {
22
21
  return fullNodeTypes
23
- .map((fullNodeType) => fullNodeType.split('.'))
22
+ .map((fullNodeType) => fullNodeType.split("."))
24
23
  .filter(([packageName]) => packageName === this.packageName)
25
24
  .map(([_, nodeType]) => nodeType);
26
25
  }
27
- loadAll() {
28
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
29
- var _a, _b;
30
- const { n8n } = this.packageJson;
31
- if (!n8n)
32
- return;
33
- const { nodes, credentials } = n8n;
34
- if (Array.isArray(nodes)) {
35
- for (const nodePath of nodes) {
36
- this.loadNodeFromFile(nodePath);
37
- }
26
+ async loadAll() {
27
+ const { n8n } = this.packageJson;
28
+ if (!n8n)
29
+ return;
30
+ const { nodes, credentials } = n8n;
31
+ if (Array.isArray(nodes)) {
32
+ for (const nodePath of nodes) {
33
+ this.loadNodeFromFile(nodePath);
38
34
  }
39
- if (Array.isArray(credentials)) {
40
- for (const credentialPath of credentials) {
41
- this.loadCredentialFromFile(credentialPath);
42
- }
35
+ }
36
+ if (Array.isArray(credentials)) {
37
+ for (const credentialPath of credentials) {
38
+ this.loadCredentialFromFile(credentialPath);
43
39
  }
44
- this.inferSupportedNodes();
45
- console.debug(`Loaded all credentials and nodes from ${this.packageName}`, {
46
- credentials: (_a = credentials === null || credentials === void 0 ? void 0 : credentials.length) !== null && _a !== void 0 ? _a : 0,
47
- nodes: (_b = nodes === null || nodes === void 0 ? void 0 : nodes.length) !== null && _b !== void 0 ? _b : 0,
48
- });
40
+ }
41
+ this.inferSupportedNodes();
42
+ console.debug(`Loaded all credentials and nodes from ${this.packageName}`, {
43
+ credentials: credentials?.length ?? 0,
44
+ nodes: nodes?.length ?? 0,
49
45
  });
50
46
  }
51
47
  inferSupportedNodes() {
52
- var _a, _b;
53
48
  const knownCredentials = this.known.credentials;
54
49
  for (const { type: credentialType } of Object.values(this.credentialTypes)) {
55
- const supportedNodes = (_a = knownCredentials[credentialType.name].supportedNodes) !== null && _a !== void 0 ? _a : [];
50
+ const supportedNodes = knownCredentials[credentialType.name].supportedNodes ?? [];
56
51
  if (supportedNodes.length > 0 && credentialType.httpRequestNode) {
57
52
  credentialType.httpRequestNode.hidden = true;
58
53
  }
59
54
  credentialType.supportedNodes = supportedNodes;
60
55
  if (!credentialType.iconUrl && !credentialType.icon) {
61
56
  for (const supportedNode of supportedNodes) {
62
- const nodeDescription = (_b = this.nodeTypes[supportedNode]) === null || _b === void 0 ? void 0 : _b.type.description;
57
+ const nodeDescription = this.nodeTypes[supportedNode]?.type.description;
63
58
  if (!nodeDescription)
64
59
  continue;
65
60
  if (nodeDescription.icon) {
@@ -79,22 +74,19 @@ class PackageDirectoryLoader extends directory_loader_1.DirectoryLoader {
79
74
  try {
80
75
  return (0, workflow_1.jsonParse)(fileString);
81
76
  }
82
- catch (error) {
77
+ catch (_error) {
83
78
  throw new Error(`Failed to parse JSON, ${filePath}`);
84
79
  }
85
80
  }
86
81
  readJSONSync(file) {
87
82
  const filePath = this.resolvePath(file);
88
- const fileString = (0, node_fs_1.readFileSync)(filePath, 'utf8');
83
+ const fileString = (0, node_fs_1.readFileSync)(filePath, "utf8");
89
84
  return this.parseJSON(fileString, filePath);
90
85
  }
91
- readJSON(file) {
92
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
93
- const filePath = this.resolvePath(file);
94
- const fileString = yield (0, promises_1.readFile)(filePath, 'utf8');
95
- return this.parseJSON(fileString, filePath);
96
- });
86
+ async readJSON(file) {
87
+ const filePath = this.resolvePath(file);
88
+ const fileString = await (0, promises_1.readFile)(filePath, "utf8");
89
+ return this.parseJSON(fileString, filePath);
97
90
  }
98
91
  }
99
92
  exports.PackageDirectoryLoader = PackageDirectoryLoader;
100
- //# sourceMappingURL=package-directory-loader.js.map