@fsai-flow/core 0.0.5 → 0.1.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.
Files changed (92) hide show
  1. package/dist/index.d.ts +17 -0
  2. package/dist/index.js +61 -0
  3. package/dist/lib/ActiveWebhooks.d.ts +59 -0
  4. package/dist/lib/ActiveWebhooks.js +177 -0
  5. package/dist/lib/ActiveWorkflows.d.ts +87 -0
  6. package/dist/lib/ActiveWorkflows.js +465 -0
  7. package/dist/lib/BinaryDataManager/FileSystem.d.ts +26 -0
  8. package/dist/lib/BinaryDataManager/FileSystem.js +180 -0
  9. package/dist/lib/BinaryDataManager/index.d.ts +21 -0
  10. package/dist/lib/BinaryDataManager/index.js +129 -0
  11. package/dist/lib/ChangeCase.d.ts +9 -0
  12. package/dist/lib/ChangeCase.js +43 -0
  13. package/dist/lib/Constants.d.ts +14 -0
  14. package/dist/lib/Constants.js +18 -0
  15. package/dist/lib/Credentials.d.ts +27 -0
  16. package/dist/lib/Credentials.js +88 -0
  17. package/dist/lib/FileSystem.d.ts +26 -0
  18. package/dist/lib/FileSystem.js +180 -0
  19. package/dist/lib/InputConnectionDataLegacy.d.ts +2 -0
  20. package/dist/lib/InputConnectionDataLegacy.js +72 -0
  21. package/dist/lib/Interfaces.d.ts +147 -0
  22. package/dist/lib/Interfaces.js +2 -0
  23. package/dist/lib/LoadNodeParameterOptions.d.ts +39 -0
  24. package/dist/lib/LoadNodeParameterOptions.js +152 -0
  25. package/dist/lib/NodeExecuteFunctions.d.ts +225 -0
  26. package/dist/lib/NodeExecuteFunctions.js +2467 -0
  27. package/dist/lib/NodesLoader/constants.d.ts +5 -0
  28. package/dist/lib/NodesLoader/constants.js +105 -0
  29. package/dist/lib/NodesLoader/custom-directory-loader.d.ts +9 -0
  30. package/dist/lib/NodesLoader/custom-directory-loader.js +35 -0
  31. package/dist/lib/NodesLoader/directory-loader.d.ts +66 -0
  32. package/dist/lib/NodesLoader/directory-loader.js +367 -0
  33. package/dist/lib/NodesLoader/index.d.ts +5 -0
  34. package/dist/lib/NodesLoader/index.js +11 -0
  35. package/dist/lib/NodesLoader/lazy-package-directory-loader.d.ts +7 -0
  36. package/dist/lib/NodesLoader/lazy-package-directory-loader.js +44 -0
  37. package/dist/lib/NodesLoader/load-class-in-isolation.d.ts +1 -0
  38. package/dist/lib/NodesLoader/load-class-in-isolation.js +17 -0
  39. package/dist/lib/NodesLoader/package-directory-loader.d.ts +17 -0
  40. package/dist/lib/NodesLoader/package-directory-loader.js +92 -0
  41. package/dist/lib/NodesLoader/types.d.ts +14 -0
  42. package/dist/lib/NodesLoader/types.js +2 -0
  43. package/dist/lib/RedisLeaderElectionManager.d.ts +53 -0
  44. package/dist/lib/RedisLeaderElectionManager.js +279 -0
  45. package/dist/lib/RequestTypes.d.ts +58 -0
  46. package/dist/lib/RequestTypes.js +8 -0
  47. package/dist/lib/UserSettings.d.ts +80 -0
  48. package/dist/lib/UserSettings.js +269 -0
  49. package/dist/lib/WorkflowExecute.d.ts +53 -0
  50. package/dist/lib/WorkflowExecute.js +906 -0
  51. package/dist/lib/index.d.ts +21 -0
  52. package/dist/lib/index.js +129 -0
  53. package/dist/utils/crypto.d.ts +1 -0
  54. package/dist/utils/crypto.js +7 -0
  55. package/package.json +52 -52
  56. package/dist/README.md +0 -31
  57. package/dist/package.json +0 -54
  58. package/eslint.config.js +0 -19
  59. package/jest.config.ts +0 -10
  60. package/project.json +0 -19
  61. package/src/index.ts +0 -28
  62. package/src/lib/ActiveWebhooks.ts +0 -245
  63. package/src/lib/ActiveWorkflows.ts +0 -575
  64. package/src/lib/BinaryDataManager/FileSystem.ts +0 -214
  65. package/src/lib/BinaryDataManager/index.ts +0 -187
  66. package/src/lib/ChangeCase.ts +0 -45
  67. package/src/lib/Constants.ts +0 -16
  68. package/src/lib/Credentials.ts +0 -108
  69. package/src/lib/FileSystem.ts +0 -214
  70. package/src/lib/InputConnectionDataLegacy.ts +0 -123
  71. package/src/lib/Interfaces.ts +0 -338
  72. package/src/lib/LoadNodeParameterOptions.ts +0 -235
  73. package/src/lib/NodeExecuteFunctions.ts +0 -3700
  74. package/src/lib/NodesLoader/constants.ts +0 -112
  75. package/src/lib/NodesLoader/custom-directory-loader.ts +0 -31
  76. package/src/lib/NodesLoader/directory-loader.ts +0 -458
  77. package/src/lib/NodesLoader/index.ts +0 -5
  78. package/src/lib/NodesLoader/lazy-package-directory-loader.ts +0 -55
  79. package/src/lib/NodesLoader/load-class-in-isolation.ts +0 -19
  80. package/src/lib/NodesLoader/package-directory-loader.ts +0 -107
  81. package/src/lib/NodesLoader/types.ts +0 -14
  82. package/src/lib/RedisLeaderElectionManager.ts +0 -334
  83. package/src/lib/UserSettings.ts +0 -292
  84. package/src/lib/WorkflowExecute.ts +0 -1128
  85. package/src/lib/index.ts +0 -187
  86. package/src/utils/crypto.ts +0 -5
  87. package/tests/Credentials.test.ts +0 -88
  88. package/tests/Helpers.ts +0 -808
  89. package/tests/WorkflowExecute.test.ts +0 -1242
  90. package/tsconfig.json +0 -41
  91. package/tsconfig.lib.json +0 -10
  92. package/tsconfig.spec.json +0 -14
@@ -0,0 +1,21 @@
1
+ import type { IBinaryData, INodeExecutionData } from "@fsai-flow/workflow";
2
+ import type { IBinaryDataConfig } from "./Interfaces";
3
+ export declare class BinaryDataManager {
4
+ private static instance;
5
+ private managers;
6
+ private binaryDataMode;
7
+ private availableModes;
8
+ constructor(config: IBinaryDataConfig);
9
+ static init(config: IBinaryDataConfig, mainManager?: boolean): Promise<void>;
10
+ static getInstance(): BinaryDataManager;
11
+ storeBinaryData(binaryData: IBinaryData, binaryBuffer: Buffer, executionId: string): Promise<IBinaryData>;
12
+ retrieveBinaryData(binaryData: IBinaryData): Promise<Buffer>;
13
+ retrieveBinaryDataByIdentifier(identifier: string): Promise<Buffer>;
14
+ markDataForDeletionByExecutionId(executionId: string): Promise<void>;
15
+ persistBinaryDataForExecutionId(executionId: string): Promise<void>;
16
+ deleteBinaryDataByExecutionId(executionId: string): Promise<void>;
17
+ duplicateBinaryData(inputData: Array<INodeExecutionData[] | null> | unknown, executionId: string): Promise<INodeExecutionData[][]>;
18
+ private generateBinaryId;
19
+ private splitBinaryModeFileId;
20
+ private duplicateBinaryDataInExecData;
21
+ }
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BinaryDataManager = void 0;
4
+ const Constants_1 = require("./Constants");
5
+ const FileSystem_1 = require("./FileSystem");
6
+ class BinaryDataManager {
7
+ constructor(config) {
8
+ this.binaryDataMode = config.mode;
9
+ this.availableModes = config.availableModes.split(",");
10
+ this.managers = {};
11
+ }
12
+ static async init(config, mainManager = false) {
13
+ if (BinaryDataManager.instance) {
14
+ throw new Error("Binary Data Manager already initialized");
15
+ }
16
+ BinaryDataManager.instance = new BinaryDataManager(config);
17
+ if (BinaryDataManager.instance.availableModes.includes("filesystem")) {
18
+ BinaryDataManager.instance.managers["filesystem"] =
19
+ new FileSystem_1.BinaryDataFileSystem(config);
20
+ await BinaryDataManager.instance.managers["filesystem"].init(mainManager);
21
+ }
22
+ return undefined;
23
+ }
24
+ static getInstance() {
25
+ if (!BinaryDataManager.instance) {
26
+ throw new Error("Binary Data Manager not initialized");
27
+ }
28
+ return BinaryDataManager.instance;
29
+ }
30
+ async storeBinaryData(binaryData, binaryBuffer, executionId) {
31
+ const retBinaryData = binaryData;
32
+ if (this.managers[this.binaryDataMode]) {
33
+ return this.managers[this.binaryDataMode]
34
+ .storeBinaryData(binaryBuffer, executionId)
35
+ .then((filename) => {
36
+ retBinaryData.id = this.generateBinaryId(filename);
37
+ return retBinaryData;
38
+ });
39
+ }
40
+ retBinaryData.data = binaryBuffer.toString(Constants_1.BINARY_ENCODING);
41
+ return binaryData;
42
+ }
43
+ async retrieveBinaryData(binaryData) {
44
+ if (binaryData.id) {
45
+ return this.retrieveBinaryDataByIdentifier(binaryData.id);
46
+ }
47
+ return Buffer.from(binaryData.data, Constants_1.BINARY_ENCODING);
48
+ }
49
+ async retrieveBinaryDataByIdentifier(identifier) {
50
+ const { mode, id } = this.splitBinaryModeFileId(identifier);
51
+ if (this.managers[mode]) {
52
+ return this.managers[mode].retrieveBinaryDataByIdentifier(id);
53
+ }
54
+ throw new Error("Storage mode used to store binary data not available");
55
+ }
56
+ async markDataForDeletionByExecutionId(executionId) {
57
+ if (this.managers[this.binaryDataMode]) {
58
+ return this.managers[this.binaryDataMode].markDataForDeletionByExecutionId(executionId);
59
+ }
60
+ return Promise.resolve();
61
+ }
62
+ async persistBinaryDataForExecutionId(executionId) {
63
+ if (this.managers[this.binaryDataMode]) {
64
+ return this.managers[this.binaryDataMode].persistBinaryDataForExecutionId(executionId);
65
+ }
66
+ return Promise.resolve();
67
+ }
68
+ async deleteBinaryDataByExecutionId(executionId) {
69
+ if (this.managers[this.binaryDataMode]) {
70
+ return this.managers[this.binaryDataMode].deleteBinaryDataByExecutionId(executionId);
71
+ }
72
+ return Promise.resolve();
73
+ }
74
+ async duplicateBinaryData(inputData, executionId) {
75
+ if (inputData && this.managers[this.binaryDataMode]) {
76
+ const returnInputData = inputData.map(async (executionDataArray) => {
77
+ if (executionDataArray) {
78
+ return Promise.all(executionDataArray.map((executionData) => {
79
+ if (executionData.binary) {
80
+ return this.duplicateBinaryDataInExecData(executionData, executionId);
81
+ }
82
+ return executionData;
83
+ }));
84
+ }
85
+ return executionDataArray;
86
+ });
87
+ return Promise.all(returnInputData);
88
+ }
89
+ return Promise.resolve(inputData);
90
+ }
91
+ generateBinaryId(filename) {
92
+ return `${this.binaryDataMode}:${filename}`;
93
+ }
94
+ splitBinaryModeFileId(fileId) {
95
+ const [mode, id] = fileId.split(":");
96
+ return { mode, id };
97
+ }
98
+ async duplicateBinaryDataInExecData(executionData, executionId) {
99
+ const binaryManager = this.managers[this.binaryDataMode];
100
+ if (executionData.binary) {
101
+ const binaryDataKeys = Object.keys(executionData.binary);
102
+ const bdPromises = binaryDataKeys.map(async (key) => {
103
+ if (!executionData.binary) {
104
+ return { key, newId: undefined };
105
+ }
106
+ const binaryDataId = executionData.binary[key].id;
107
+ if (!binaryDataId) {
108
+ return { key, newId: undefined };
109
+ }
110
+ return binaryManager
111
+ ?.duplicateBinaryDataByIdentifier(this.splitBinaryModeFileId(binaryDataId).id, executionId)
112
+ .then((filename) => ({
113
+ newId: this.generateBinaryId(filename),
114
+ key,
115
+ }));
116
+ });
117
+ return Promise.all(bdPromises).then((b) => {
118
+ return b.reduce((acc, curr) => {
119
+ if (acc.binary && curr) {
120
+ acc.binary[curr.key].id = curr.newId;
121
+ }
122
+ return acc;
123
+ }, executionData);
124
+ });
125
+ }
126
+ return executionData;
127
+ }
128
+ }
129
+ exports.BinaryDataManager = BinaryDataManager;
@@ -0,0 +1 @@
1
+ export declare function secureRandomNumber(min: number, max: number): number;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.secureRandomNumber = secureRandomNumber;
4
+ const node_crypto_1 = require("node:crypto");
5
+ function secureRandomNumber(min, max) {
6
+ return (0, node_crypto_1.randomInt)(min, max);
7
+ }
package/package.json CHANGED
@@ -1,54 +1,54 @@
1
1
  {
2
- "name": "@fsai-flow/core",
3
- "version": "0.0.5",
4
- "dependencies": {
5
- "@fsai-flow/workflow": "0.0.3",
6
- "client-oauth2": "^4.3.3",
7
- "cron": "~3.3.0",
8
- "crypto-js": "~4.2.0",
9
- "file-type": "^16.0.0",
10
- "form-data": "4.0.4",
11
- "https-proxy-agent": "^7.0.6",
12
- "ioredis": "^5.3.2",
13
- "lodash": "^4.17.21",
14
- "mime-types": "^2.1.27",
15
- "oauth-1.0a": "^2.2.6",
16
- "p-cancelable": "^2.0.0",
17
- "qs": "^6.10.1",
18
- "request": "^2.88.2",
19
- "request-promise-native": "^1.0.9",
20
- "simple-oauth2": "^5.1.0",
21
- "tslib": "^2.3.0",
22
- "uuid": "^11.0.3",
23
- "fast-glob": "3.2.12"
24
- },
25
- "devDependencies": {
26
- "@types/crypto-js": "^4.0.1",
27
- "@types/express": "^5.0.0",
28
- "@types/lodash": "^4.17.13",
29
- "@types/lodash.get": "^4.4.9",
30
- "@types/mime-types": "^2.1.0",
31
- "@types/node": "^22.10.2",
32
- "@types/qs": "^6.9.17",
33
- "@types/request": "^2.48.12",
34
- "@types/request-promise-native": "^1.0.15",
35
- "@types/simple-oauth2": "^5.0.7",
36
- "@types/uuid": "^10.0.0",
37
- "axios": "^1.7.9",
38
- "ioredis": "^5.3.2",
39
- "jsonc-eslint-parser": "^2.4.0",
40
- "typescript": "~5.7.2"
41
- },
42
- "type": "commonjs",
43
- "main": "dist/src/index",
44
- "types": "dist/src/index.d.ts",
45
- "overrides": {
46
- "request": {
47
- "form-data": "2.5.4",
48
- "tough-cookie": "4.1.3"
49
- },
50
- "request-promise-native": {
51
- "tough-cookie": "4.1.3"
52
- }
53
- }
2
+ "name": "@fsai-flow/core",
3
+ "version": "0.1.1",
4
+ "dependencies": {
5
+ "@fsai-flow/workflow": "0.1.0",
6
+ "client-oauth2": "^4.3.3",
7
+ "cron": "~4.4.0",
8
+ "crypto-js": "~4.2.0",
9
+ "fast-glob": "3.3.3",
10
+ "file-type": "^21.3.1",
11
+ "form-data": "4.0.5",
12
+ "https-proxy-agent": "^7.0.6",
13
+ "ioredis": "^5.10.0",
14
+ "lodash": "^4.17.23",
15
+ "mime-types": "^3.0.2",
16
+ "oauth-1.0a": "^2.2.6",
17
+ "p-cancelable": "^4.0.1",
18
+ "qs": "^6.15.0",
19
+ "simple-oauth2": "^5.1.0",
20
+ "tslib": "^2.8.1",
21
+ "uuid": "^13.0.0"
22
+ },
23
+ "devDependencies": {
24
+ "@biomejs/biome": "^2.4.6",
25
+ "@types/crypto-js": "^4.2.2",
26
+ "@types/express": "^5.0.6",
27
+ "@types/lodash": "^4.17.24",
28
+ "@types/lodash.get": "^4.4.9",
29
+ "@types/mime-types": "^3.0.1",
30
+ "@types/node": "^25.4.0",
31
+ "@types/qs": "^6.15.0",
32
+ "@types/simple-oauth2": "^5.0.8",
33
+ "@types/uuid": "^11.0.0",
34
+ "@vitest/coverage-v8": "^4.0.18",
35
+ "axios": "^1.13.6",
36
+ "ioredis": "^5.10.0",
37
+ "typescript": "~5.9.3",
38
+ "vitest": "^4.0.18"
39
+ },
40
+ "scripts": {
41
+ "build": "tsc -p tsconfig.lib.json",
42
+ "test": "vitest run",
43
+ "check": "biome check .",
44
+ "prepublishOnly": "npm run check && npm run build && npm run test"
45
+ },
46
+ "type": "commonjs",
47
+ "main": "dist/index",
48
+ "types": "dist/index.d.ts",
49
+ "files": [
50
+ "dist",
51
+ "README.md",
52
+ "LICENSE"
53
+ ]
54
54
  }
package/dist/README.md DELETED
@@ -1,31 +0,0 @@
1
- # @fsai-flow/core
2
-
3
- This library is a dependency for [FSAI-Flow](https://github.com/your-org/flowx) that contains base classes and types used throughout the application.
4
-
5
- ## Installation
6
-
7
- This project is published to the npm registry. To use it in your project:
8
-
9
- ```bash
10
- npm install @fsai-flow/core
11
- ```
12
-
13
- ## Building
14
-
15
- Run `nx build core` to build the library.
16
-
17
- ## Running unit tests
18
-
19
- Run `nx test core` to execute the unit tests via [Jest](https://jestjs.io).
20
-
21
- ## Contributing
22
-
23
- To contribute to this project:
24
-
25
- 1. Clone this repository
26
- 2. Make your changes
27
- 3. Open a Pull Request
28
-
29
- ## Publishing
30
-
31
- Maintainers can publish a new version to the npm package registry.
package/dist/package.json DELETED
@@ -1,54 +0,0 @@
1
- {
2
- "name": "@fsai-flow/core",
3
- "version": "0.0.4",
4
- "dependencies": {
5
- "@fsai-flow/workflow": "0.0.3",
6
- "client-oauth2": "^4.3.3",
7
- "cron": "~3.3.0",
8
- "crypto-js": "~4.2.0",
9
- "file-type": "^16.0.0",
10
- "form-data": "4.0.4",
11
- "https-proxy-agent": "^7.0.6",
12
- "ioredis": "^5.3.2",
13
- "lodash": "^4.17.21",
14
- "mime-types": "^2.1.27",
15
- "oauth-1.0a": "^2.2.6",
16
- "p-cancelable": "^2.0.0",
17
- "qs": "^6.10.1",
18
- "request": "^2.88.2",
19
- "request-promise-native": "^1.0.9",
20
- "simple-oauth2": "^5.1.0",
21
- "tslib": "^2.3.0",
22
- "uuid": "^11.0.3",
23
- "fast-glob": "3.2.12"
24
- },
25
- "devDependencies": {
26
- "@types/crypto-js": "^4.0.1",
27
- "@types/express": "^5.0.0",
28
- "@types/lodash": "^4.17.13",
29
- "@types/lodash.get": "^4.4.9",
30
- "@types/mime-types": "^2.1.0",
31
- "@types/node": "^22.10.2",
32
- "@types/qs": "^6.9.17",
33
- "@types/request": "^2.48.12",
34
- "@types/request-promise-native": "^1.0.15",
35
- "@types/simple-oauth2": "^5.0.7",
36
- "@types/uuid": "^10.0.0",
37
- "axios": "^1.7.9",
38
- "ioredis": "^5.3.2",
39
- "jsonc-eslint-parser": "^2.4.0",
40
- "typescript": "~5.7.2"
41
- },
42
- "type": "commonjs",
43
- "main": "dist/src/index",
44
- "types": "dist/src/index.d.ts",
45
- "overrides": {
46
- "request": {
47
- "form-data": "2.5.4",
48
- "tough-cookie": "4.1.3"
49
- },
50
- "request-promise-native": {
51
- "tough-cookie": "4.1.3"
52
- }
53
- }
54
- }
package/eslint.config.js DELETED
@@ -1,19 +0,0 @@
1
- const baseConfig = require('../../eslint.config.js');
2
-
3
- module.exports = [
4
- ...baseConfig,
5
- {
6
- files: ['**/*.json'],
7
- rules: {
8
- '@nx/dependency-checks': [
9
- 'error',
10
- {
11
- ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs}'],
12
- },
13
- ],
14
- },
15
- languageOptions: {
16
- parser: require('jsonc-eslint-parser'),
17
- },
18
- },
19
- ];
package/jest.config.ts DELETED
@@ -1,10 +0,0 @@
1
- export default {
2
- displayName: 'core',
3
- preset: '../../jest.preset.js',
4
- testEnvironment: 'node',
5
- transform: {
6
- '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
7
- },
8
- moduleFileExtensions: ['ts', 'js', 'html'],
9
- coverageDirectory: '../../coverage/libs/core',
10
- };
package/project.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "name": "core",
3
- "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
- "sourceRoot": "libs/core/src",
5
- "projectType": "library",
6
- "tags": [],
7
- "targets": {
8
- "build": {
9
- "executor": "@nx/js:tsc",
10
- "outputs": ["{options.outputPath}"],
11
- "options": {
12
- "outputPath": "libs/core/dist",
13
- "main": "libs/core/src/index.ts",
14
- "tsConfig": "libs/core/tsconfig.lib.json",
15
- "assets": ["libs/core/*.md"]
16
- }
17
- }
18
- }
19
- }
package/src/index.ts DELETED
@@ -1,28 +0,0 @@
1
- /* eslint-disable import/no-cycle */
2
- import * as NodeExecuteFunctions from './lib/NodeExecuteFunctions';
3
- import * as UserSettings from './lib/UserSettings';
4
- import * as getInputConnectionDataLegacy from './lib/InputConnectionDataLegacy';
5
-
6
- try {
7
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, import/no-extraneous-dependencies, global-require, @typescript-eslint/no-var-requires
8
- require('source-map-support').install();
9
- // eslint-disable-next-line no-empty
10
- } catch (error) {}
11
-
12
- export * from './lib/ActiveWorkflows';
13
- export * from './lib/ActiveWebhooks';
14
- export * from './lib/BinaryDataManager';
15
- export * from './lib/Constants';
16
- export * from './lib/Credentials';
17
- export * from './lib/Interfaces';
18
- export * from './lib/RedisLeaderElectionManager';
19
- export * from './lib/LoadNodeParameterOptions';
20
- export * from './lib/NodeExecuteFunctions';
21
- export * from './lib/WorkflowExecute';
22
- export * from './lib/ChangeCase';
23
- export * from './lib/NodesLoader';
24
- export {
25
- NodeExecuteFunctions,
26
- UserSettings,
27
- getInputConnectionDataLegacy
28
- };