@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.
- package/dist/index.d.ts +17 -0
- package/dist/index.js +61 -0
- package/dist/{src/lib → lib}/ActiveWebhooks.d.ts +1 -1
- package/dist/lib/ActiveWebhooks.js +177 -0
- package/dist/{src/lib → lib}/ActiveWorkflows.d.ts +3 -3
- package/dist/lib/ActiveWorkflows.js +465 -0
- package/dist/{src/lib → lib}/BinaryDataManager/FileSystem.d.ts +1 -1
- package/dist/lib/BinaryDataManager/FileSystem.js +180 -0
- package/dist/{src/lib → lib}/BinaryDataManager/index.d.ts +2 -2
- package/dist/lib/BinaryDataManager/index.js +129 -0
- package/dist/{src/lib → lib}/ChangeCase.js +11 -11
- package/dist/lib/Constants.js +18 -0
- package/dist/{src/lib → lib}/Credentials.d.ts +1 -1
- package/dist/{src/lib → lib}/Credentials.js +7 -8
- package/dist/{src/lib → lib}/FileSystem.d.ts +1 -1
- package/dist/lib/FileSystem.js +180 -0
- package/dist/{src/lib → lib}/InputConnectionDataLegacy.d.ts +1 -1
- package/dist/lib/InputConnectionDataLegacy.js +72 -0
- package/dist/{src/lib → lib}/Interfaces.d.ts +47 -48
- package/dist/{src/lib → lib}/Interfaces.js +0 -1
- package/dist/{src/lib → lib}/LoadNodeParameterOptions.d.ts +1 -1
- package/dist/lib/LoadNodeParameterOptions.js +152 -0
- package/dist/{src/lib → lib}/NodeExecuteFunctions.d.ts +9 -10
- package/dist/lib/NodeExecuteFunctions.js +2467 -0
- package/dist/{src/lib → lib}/NodesLoader/constants.d.ts +1 -1
- package/dist/lib/NodesLoader/constants.js +105 -0
- package/dist/{src/lib → lib}/NodesLoader/custom-directory-loader.d.ts +1 -1
- package/dist/lib/NodesLoader/custom-directory-loader.js +35 -0
- package/dist/{src/lib → lib}/NodesLoader/directory-loader.d.ts +1 -1
- package/dist/{src/lib → lib}/NodesLoader/directory-loader.js +80 -38
- package/dist/lib/NodesLoader/index.d.ts +5 -0
- package/dist/{src/lib → lib}/NodesLoader/index.js +5 -6
- package/dist/{src/lib → lib}/NodesLoader/lazy-package-directory-loader.d.ts +1 -1
- package/dist/lib/NodesLoader/lazy-package-directory-loader.js +44 -0
- package/dist/{src/lib → lib}/NodesLoader/load-class-in-isolation.js +6 -11
- package/dist/{src/lib → lib}/NodesLoader/package-directory-loader.d.ts +2 -2
- package/dist/{src/lib → lib}/NodesLoader/package-directory-loader.js +28 -36
- package/dist/{src/lib → lib}/NodesLoader/types.js +0 -1
- package/dist/{src/lib → lib}/RedisLeaderElectionManager.d.ts +1 -1
- package/dist/lib/RedisLeaderElectionManager.js +279 -0
- package/dist/lib/RequestTypes.d.ts +58 -0
- package/dist/lib/RequestTypes.js +8 -0
- package/dist/{src/lib → lib}/UserSettings.d.ts +1 -1
- package/dist/lib/UserSettings.js +269 -0
- package/dist/{src/lib → lib}/WorkflowExecute.d.ts +4 -4
- package/dist/{src/lib → lib}/WorkflowExecute.js +230 -178
- package/dist/{src/lib → lib}/index.d.ts +2 -2
- package/dist/lib/index.js +129 -0
- package/dist/{src/utils → utils}/crypto.js +2 -3
- package/package.json +59 -52
- package/dist/README.md +0 -31
- package/dist/package.json +0 -54
- package/dist/src/index.d.ts +0 -16
- package/dist/src/index.js +0 -30
- package/dist/src/index.js.map +0 -1
- package/dist/src/lib/ActiveWebhooks.js +0 -184
- package/dist/src/lib/ActiveWebhooks.js.map +0 -1
- package/dist/src/lib/ActiveWorkflows.js +0 -456
- package/dist/src/lib/ActiveWorkflows.js.map +0 -1
- package/dist/src/lib/BinaryDataManager/FileSystem.js +0 -179
- package/dist/src/lib/BinaryDataManager/FileSystem.js.map +0 -1
- package/dist/src/lib/BinaryDataManager/index.js +0 -146
- package/dist/src/lib/BinaryDataManager/index.js.map +0 -1
- package/dist/src/lib/ChangeCase.js.map +0 -1
- package/dist/src/lib/Constants.js +0 -19
- package/dist/src/lib/Constants.js.map +0 -1
- package/dist/src/lib/Credentials.js.map +0 -1
- package/dist/src/lib/FileSystem.js +0 -179
- package/dist/src/lib/FileSystem.js.map +0 -1
- package/dist/src/lib/InputConnectionDataLegacy.js +0 -79
- package/dist/src/lib/InputConnectionDataLegacy.js.map +0 -1
- package/dist/src/lib/Interfaces.js.map +0 -1
- package/dist/src/lib/LoadNodeParameterOptions.js +0 -150
- package/dist/src/lib/LoadNodeParameterOptions.js.map +0 -1
- package/dist/src/lib/NodeExecuteFunctions.js +0 -2479
- package/dist/src/lib/NodeExecuteFunctions.js.map +0 -1
- package/dist/src/lib/NodesLoader/constants.js +0 -106
- package/dist/src/lib/NodesLoader/constants.js.map +0 -1
- package/dist/src/lib/NodesLoader/custom-directory-loader.js +0 -36
- package/dist/src/lib/NodesLoader/custom-directory-loader.js.map +0 -1
- package/dist/src/lib/NodesLoader/directory-loader.js.map +0 -1
- package/dist/src/lib/NodesLoader/index.d.ts +0 -5
- package/dist/src/lib/NodesLoader/index.js.map +0 -1
- package/dist/src/lib/NodesLoader/lazy-package-directory-loader.js +0 -52
- package/dist/src/lib/NodesLoader/lazy-package-directory-loader.js.map +0 -1
- package/dist/src/lib/NodesLoader/load-class-in-isolation.js.map +0 -1
- package/dist/src/lib/NodesLoader/package-directory-loader.js.map +0 -1
- package/dist/src/lib/NodesLoader/types.js.map +0 -1
- package/dist/src/lib/RedisLeaderElectionManager.js +0 -294
- package/dist/src/lib/RedisLeaderElectionManager.js.map +0 -1
- package/dist/src/lib/UserSettings.js +0 -261
- package/dist/src/lib/UserSettings.js.map +0 -1
- package/dist/src/lib/WorkflowExecute.js.map +0 -1
- package/dist/src/lib/index.js +0 -146
- package/dist/src/lib/index.js.map +0 -1
- package/dist/src/utils/crypto.js.map +0 -1
- package/eslint.config.js +0 -19
- package/jest.config.ts +0 -10
- package/project.json +0 -19
- package/src/index.ts +0 -28
- package/src/lib/ActiveWebhooks.ts +0 -245
- package/src/lib/ActiveWorkflows.ts +0 -575
- package/src/lib/BinaryDataManager/FileSystem.ts +0 -214
- package/src/lib/BinaryDataManager/index.ts +0 -187
- package/src/lib/ChangeCase.ts +0 -45
- package/src/lib/Constants.ts +0 -16
- package/src/lib/Credentials.ts +0 -108
- package/src/lib/FileSystem.ts +0 -214
- package/src/lib/InputConnectionDataLegacy.ts +0 -123
- package/src/lib/Interfaces.ts +0 -338
- package/src/lib/LoadNodeParameterOptions.ts +0 -235
- package/src/lib/NodeExecuteFunctions.ts +0 -3700
- package/src/lib/NodesLoader/constants.ts +0 -112
- package/src/lib/NodesLoader/custom-directory-loader.ts +0 -31
- package/src/lib/NodesLoader/directory-loader.ts +0 -458
- package/src/lib/NodesLoader/index.ts +0 -5
- package/src/lib/NodesLoader/lazy-package-directory-loader.ts +0 -55
- package/src/lib/NodesLoader/load-class-in-isolation.ts +0 -19
- package/src/lib/NodesLoader/package-directory-loader.ts +0 -107
- package/src/lib/NodesLoader/types.ts +0 -14
- package/src/lib/RedisLeaderElectionManager.ts +0 -334
- package/src/lib/UserSettings.ts +0 -292
- package/src/lib/WorkflowExecute.ts +0 -1128
- package/src/lib/index.ts +0 -187
- package/src/utils/crypto.ts +0 -5
- package/tests/Credentials.test.ts +0 -88
- package/tests/Helpers.ts +0 -808
- package/tests/WorkflowExecute.test.ts +0 -1242
- package/tsconfig.json +0 -41
- package/tsconfig.lib.json +0 -10
- package/tsconfig.spec.json +0 -14
- /package/dist/{src/lib → lib}/ChangeCase.d.ts +0 -0
- /package/dist/{src/lib → lib}/Constants.d.ts +0 -0
- /package/dist/{src/lib → lib}/NodesLoader/load-class-in-isolation.d.ts +0 -0
- /package/dist/{src/lib → lib}/NodesLoader/types.d.ts +0 -0
- /package/dist/{src/utils → utils}/crypto.d.ts +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { INodeProperties } from
|
|
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
|
+
};
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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(
|
|
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 (
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
|
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 (
|
|
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(
|
|
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
|
|
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 ===
|
|
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
|
|
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
|
-
|
|
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 ===
|
|
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(
|
|
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 ===
|
|
266
|
-
if (icon.startsWith(
|
|
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(
|
|
272
|
-
icon.dark.startsWith(
|
|
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 ===
|
|
337
|
+
const existingRequestOptionsIndex = parameters.findIndex((parameter) => parameter.name === "requestOptions");
|
|
298
338
|
if (existingRequestOptionsIndex !== -1) {
|
|
299
|
-
parameters[existingRequestOptionsIndex] =
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
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 (
|
|
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.
|
|
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
|
|
9
|
-
Object.defineProperty(exports, "
|
|
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
|
-
|
|
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; } });
|
|
@@ -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
|
|
4
|
+
const node_vm_1 = require("node:vm");
|
|
5
5
|
const Constants_1 = require("../Constants");
|
|
6
|
-
const context = (0,
|
|
6
|
+
const context = (0, node_vm_1.createContext)({ require });
|
|
7
7
|
const loadClassInIsolation = (filePath, className) => {
|
|
8
|
-
|
|
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(
|
|
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
|
|
2
|
-
import type { n8n } from
|
|
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(
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
}
|
|
36
|
+
if (Array.isArray(credentials)) {
|
|
37
|
+
for (const credentialPath of credentials) {
|
|
38
|
+
this.loadCredentialFromFile(credentialPath);
|
|
43
39
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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 =
|
|
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 =
|
|
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 (
|
|
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,
|
|
83
|
+
const fileString = (0, node_fs_1.readFileSync)(filePath, "utf8");
|
|
89
84
|
return this.parseJSON(fileString, filePath);
|
|
90
85
|
}
|
|
91
|
-
readJSON(file) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|