@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
@@ -1,235 +0,0 @@
1
- /* eslint-disable no-restricted-syntax */
2
- /* eslint-disable @typescript-eslint/no-unsafe-return */
3
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
4
- /* eslint-disable @typescript-eslint/restrict-template-expressions */
5
- /* eslint-disable @typescript-eslint/no-unsafe-call */
6
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
7
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
8
-
9
- import {
10
- ILoadOptions,
11
- INode,
12
- INodeCredentials,
13
- INodeExecutionData,
14
- INodeParameters,
15
- INodeProperties,
16
- INodePropertyOptions,
17
- INodeType,
18
- INodeTypeNameVersion,
19
- INodeTypes,
20
- IRunExecutionData,
21
- ITaskDataConnections,
22
- IWorkflowExecuteAdditionalData,
23
- RoutingNode,
24
- Workflow,
25
- } from '@fsai-flow/workflow';
26
-
27
- // eslint-disable-next-line import/no-cycle
28
- import { NodeExecuteFunctions } from '..';
29
-
30
- const TEMP_NODE_NAME = 'Temp-Node';
31
- const TEMP_WORKFLOW_NAME = 'Temp-Workflow';
32
-
33
- export class LoadNodeParameterOptions {
34
- currentNodeParameters: INodeParameters;
35
-
36
- path: string;
37
-
38
- workflow: Workflow;
39
-
40
- constructor(
41
- nodeTypeNameAndVersion: INodeTypeNameVersion,
42
- nodeTypes: INodeTypes,
43
- path: string,
44
- currentNodeParameters: INodeParameters,
45
- credentials?: INodeCredentials,
46
- ) {
47
- const nodeType = nodeTypes.getByNameAndVersion(
48
- nodeTypeNameAndVersion.name,
49
- nodeTypeNameAndVersion.version,
50
- );
51
- this.currentNodeParameters = currentNodeParameters;
52
- this.path = path;
53
- if (nodeType === undefined) {
54
- throw new Error(
55
- `The node-type "${nodeTypeNameAndVersion.name} v${nodeTypeNameAndVersion.version}" is not known!`,
56
- );
57
- }
58
-
59
- const nodeData: INode = {
60
- parameters: currentNodeParameters,
61
- name: TEMP_NODE_NAME,
62
- type: nodeTypeNameAndVersion.name,
63
- typeVersion: nodeTypeNameAndVersion.version,
64
- position: [0, 0],
65
- id: '',
66
- };
67
- if (credentials) {
68
- nodeData.credentials = credentials;
69
- }
70
-
71
- const workflowData = {
72
- nodes: [nodeData],
73
- connections: {},
74
- };
75
-
76
- this.workflow = new Workflow({
77
- nodes: workflowData.nodes,
78
- connections: workflowData.connections,
79
- active: false,
80
- nodeTypes,
81
- });
82
- }
83
-
84
- /**
85
- * Returns data of a fake workflow
86
- *
87
- * @returns
88
- * @memberof LoadNodeParameterOptions
89
- */
90
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
91
- getWorkflowData() {
92
- return {
93
- name: TEMP_WORKFLOW_NAME,
94
- active: false,
95
- connections: {},
96
- nodes: Object.values(this.workflow.nodes),
97
- createdAt: new Date(),
98
- updatedAt: new Date(),
99
- };
100
- }
101
-
102
- /**
103
- * Returns the available options via a predefined method
104
- *
105
- * @param {string} methodName The name of the method of which to get the data from
106
- * @param {IWorkflowExecuteAdditionalData} additionalData
107
- * @returns {Promise<INodePropertyOptions[]>}
108
- * @memberof LoadNodeParameterOptions
109
- */
110
- async getOptionsViaMethodName(
111
- methodName: string,
112
- additionalData: IWorkflowExecuteAdditionalData,
113
- ): Promise<INodePropertyOptions[]> {
114
- const node = this.workflow.getNode(TEMP_NODE_NAME);
115
-
116
- const nodeType = this.workflow.nodeTypes.getByNameAndVersion(node!.type, node?.typeVersion);
117
-
118
- if (
119
- !nodeType ||
120
- nodeType.methods === undefined ||
121
- nodeType.methods.loadOptions === undefined ||
122
- nodeType.methods.loadOptions[methodName] === undefined
123
- ) {
124
- throw new Error(
125
- `The node-type "${node!.type}" does not have the method "${methodName}" defined!`,
126
- );
127
- }
128
-
129
- const thisArgs = NodeExecuteFunctions.getLoadOptionsFunctions(
130
- this.workflow,
131
- node!,
132
- this.path,
133
- additionalData,
134
- );
135
-
136
- try {
137
- return await nodeType.methods.loadOptions[methodName].call(thisArgs);
138
- } catch (error) {
139
- return [{
140
- name: 'Error trying to load options',
141
- value: '',
142
- description: (error as Error).message || 'Error trying to load options.'
143
- }];
144
- }
145
- }
146
-
147
- /**
148
- * Returns the available options via a load request informatoin
149
- *
150
- * @param {ILoadOptions} loadOptions The load options which also contain the request information
151
- * @param {IWorkflowExecuteAdditionalData} additionalData
152
- * @returns {Promise<INodePropertyOptions[]>}
153
- * @memberof LoadNodeParameterOptions
154
- */
155
- async getOptionsViaRequestProperty(
156
- loadOptions: ILoadOptions,
157
- additionalData: IWorkflowExecuteAdditionalData,
158
- ): Promise<INodePropertyOptions[]> {
159
- const node = this.workflow.getNode(TEMP_NODE_NAME);
160
-
161
- const nodeType = this.workflow.nodeTypes.getByNameAndVersion(node!.type, node?.typeVersion);
162
-
163
- if (
164
- nodeType === undefined ||
165
- !nodeType.description.requestDefaults ||
166
- !nodeType.description.requestDefaults.baseURL
167
- ) {
168
- // This in in here for now for security reasons.
169
- // Background: As the full data for the request to make does get send, and the auth data
170
- // will then be applied, would it be possible to retrieve that data like that. By at least
171
- // requiring a baseURL to be defined can at least not a random server be called.
172
- // In the future this code has to get improved that it does not use the request information from
173
- // the request rather resolves it via the parameter-path and nodeType data.
174
- throw new Error(
175
- `The node-type "${
176
- node!.type
177
- }" does not exist or does not have "requestDefaults.baseURL" defined!`,
178
- );
179
- }
180
-
181
- const mode = 'internal';
182
- const runIndex = 0;
183
- const connectionInputData: INodeExecutionData[] = [];
184
- const runExecutionData: IRunExecutionData = { resultData: { runData: {} } };
185
-
186
- const routingNode = new RoutingNode(
187
- this.workflow,
188
- node!,
189
- connectionInputData,
190
- runExecutionData ?? null,
191
- additionalData,
192
- mode,
193
- );
194
-
195
- // Create copy of node-type with the single property we want to get the data off
196
- const tempNode: INodeType = {
197
- ...nodeType,
198
- ...{
199
- description: {
200
- ...nodeType.description,
201
- properties: [
202
- {
203
- displayName: '',
204
- type: 'string',
205
- name: '',
206
- default: '',
207
- routing: loadOptions.routing,
208
- } as INodeProperties,
209
- ],
210
- },
211
- },
212
- };
213
-
214
- const inputData: ITaskDataConnections = {
215
- main: [[{ json: {} }]],
216
- };
217
-
218
- const optionsData = await routingNode.runNode(
219
- inputData,
220
- runIndex,
221
- tempNode,
222
- NodeExecuteFunctions,
223
- );
224
-
225
- if (optionsData?.length === 0) {
226
- return [];
227
- }
228
-
229
- if (!Array.isArray(optionsData)) {
230
- throw new Error('The returned data is not an array!');
231
- }
232
-
233
- return optionsData[0].map((item) => item.json) as unknown as INodePropertyOptions[];
234
- }
235
- }