@fsai-flow/workflow 0.0.2 → 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/README.md +31 -0
  2. package/dist/package.json +42 -0
  3. package/dist/src/index.d.ts +22 -0
  4. package/dist/src/index.d.ts.map +1 -0
  5. package/dist/src/index.js +68 -0
  6. package/dist/src/index.js.map +1 -0
  7. package/dist/src/lib/Constants.d.ts +69 -0
  8. package/dist/src/lib/Constants.d.ts.map +1 -0
  9. package/dist/src/lib/Constants.js +106 -0
  10. package/dist/src/lib/Constants.js.map +1 -0
  11. package/dist/src/lib/DeferredPromise.d.ts +7 -0
  12. package/dist/src/lib/DeferredPromise.d.ts.map +1 -0
  13. package/dist/src/lib/DeferredPromise.js +11 -0
  14. package/dist/src/lib/DeferredPromise.js.map +1 -0
  15. package/dist/src/lib/Expression.d.ts +66 -0
  16. package/dist/src/lib/Expression.d.ts.map +1 -0
  17. package/dist/src/lib/Expression.js +247 -0
  18. package/dist/src/lib/Expression.js.map +1 -0
  19. package/dist/src/lib/Interfaces.d.ts +1623 -0
  20. package/dist/src/lib/Interfaces.d.ts.map +1 -0
  21. package/dist/src/lib/Interfaces.js +44 -0
  22. package/dist/src/lib/Interfaces.js.map +1 -0
  23. package/dist/src/lib/LoggerProxy.d.ts +10 -0
  24. package/dist/src/lib/LoggerProxy.d.ts.map +1 -0
  25. package/dist/src/lib/LoggerProxy.js +40 -0
  26. package/dist/src/lib/LoggerProxy.js.map +1 -0
  27. package/dist/src/lib/MetadataUtils.d.ts +5 -0
  28. package/dist/src/lib/MetadataUtils.d.ts.map +1 -0
  29. package/dist/src/lib/MetadataUtils.js +27 -0
  30. package/dist/src/lib/MetadataUtils.js.map +1 -0
  31. package/dist/src/lib/NodeErrors.d.ts +83 -0
  32. package/dist/src/lib/NodeErrors.d.ts.map +1 -0
  33. package/dist/src/lib/NodeErrors.js +284 -0
  34. package/dist/src/lib/NodeErrors.js.map +1 -0
  35. package/dist/src/lib/NodeHelpers.d.ts +199 -0
  36. package/dist/src/lib/NodeHelpers.d.ts.map +1 -0
  37. package/dist/src/lib/NodeHelpers.js +1335 -0
  38. package/dist/src/lib/NodeHelpers.js.map +1 -0
  39. package/dist/src/lib/ObservableObject.d.ts +6 -0
  40. package/dist/src/lib/ObservableObject.d.ts.map +1 -0
  41. package/dist/src/lib/ObservableObject.js +61 -0
  42. package/dist/src/lib/ObservableObject.js.map +1 -0
  43. package/dist/src/lib/RoutingNode.d.ts +24 -0
  44. package/dist/src/lib/RoutingNode.d.ts.map +1 -0
  45. package/dist/src/lib/RoutingNode.js +528 -0
  46. package/dist/src/lib/RoutingNode.js.map +1 -0
  47. package/dist/src/lib/TelemetryHelpers.d.ts +4 -0
  48. package/dist/src/lib/TelemetryHelpers.d.ts.map +1 -0
  49. package/dist/src/lib/TelemetryHelpers.js +67 -0
  50. package/dist/src/lib/TelemetryHelpers.js.map +1 -0
  51. package/dist/src/lib/TypeValidation.d.ts +22 -0
  52. package/dist/src/lib/TypeValidation.d.ts.map +1 -0
  53. package/dist/src/lib/TypeValidation.js +376 -0
  54. package/dist/src/lib/TypeValidation.js.map +1 -0
  55. package/dist/src/lib/VersionedNodeType.d.ts +10 -0
  56. package/dist/src/lib/VersionedNodeType.d.ts.map +1 -0
  57. package/dist/src/lib/VersionedNodeType.js +24 -0
  58. package/dist/src/lib/VersionedNodeType.js.map +1 -0
  59. package/dist/src/lib/Workflow.d.ts +249 -0
  60. package/dist/src/lib/Workflow.d.ts.map +1 -0
  61. package/dist/src/lib/Workflow.js +899 -0
  62. package/dist/src/lib/Workflow.js.map +1 -0
  63. package/dist/src/lib/WorkflowDataProxy.d.ts +88 -0
  64. package/dist/src/lib/WorkflowDataProxy.d.ts.map +1 -0
  65. package/dist/src/lib/WorkflowDataProxy.js +583 -0
  66. package/dist/src/lib/WorkflowDataProxy.js.map +1 -0
  67. package/dist/src/lib/WorkflowErrors.d.ts +10 -0
  68. package/dist/src/lib/WorkflowErrors.d.ts.map +1 -0
  69. package/dist/src/lib/WorkflowErrors.js +18 -0
  70. package/dist/src/lib/WorkflowErrors.js.map +1 -0
  71. package/dist/src/lib/WorkflowHooks.d.ts +12 -0
  72. package/dist/src/lib/WorkflowHooks.d.ts.map +1 -0
  73. package/dist/src/lib/WorkflowHooks.js +32 -0
  74. package/dist/src/lib/WorkflowHooks.js.map +1 -0
  75. package/dist/src/lib/errors/base/base.error.d.ts +30 -0
  76. package/dist/src/lib/errors/base/base.error.d.ts.map +1 -0
  77. package/dist/src/lib/errors/base/base.error.js +47 -0
  78. package/dist/src/lib/errors/base/base.error.js.map +1 -0
  79. package/dist/src/lib/errors/base/operational.error.d.ts +16 -0
  80. package/dist/src/lib/errors/base/operational.error.d.ts.map +1 -0
  81. package/dist/src/lib/errors/base/operational.error.js +19 -0
  82. package/dist/src/lib/errors/base/operational.error.js.map +1 -0
  83. package/dist/src/lib/errors/error.types.d.ts +14 -0
  84. package/dist/src/lib/errors/error.types.d.ts.map +1 -0
  85. package/dist/src/lib/errors/error.types.js +3 -0
  86. package/dist/src/lib/errors/error.types.js.map +1 -0
  87. package/dist/src/lib/errors/index.d.ts +2 -0
  88. package/dist/src/lib/errors/index.d.ts.map +1 -0
  89. package/dist/src/lib/errors/index.js +6 -0
  90. package/dist/src/lib/errors/index.js.map +1 -0
  91. package/dist/src/lib/result.d.ts +20 -0
  92. package/dist/src/lib/result.d.ts.map +1 -0
  93. package/dist/src/lib/result.js +36 -0
  94. package/dist/src/lib/result.js.map +1 -0
  95. package/dist/src/lib/utils.d.ts +51 -0
  96. package/dist/src/lib/utils.d.ts.map +1 -0
  97. package/dist/src/lib/utils.js +119 -0
  98. package/dist/src/lib/utils.js.map +1 -0
  99. package/package.json +49 -35
  100. package/.eslintrc.json +0 -33
  101. package/eslint.config.js +0 -19
  102. package/jest.config.ts +0 -10
  103. package/project.json +0 -19
  104. package/src/index.ts +0 -33
  105. package/src/lib/Constants.ts +0 -124
  106. package/src/lib/DeferredPromise.ts +0 -14
  107. package/src/lib/Expression.ts +0 -375
  108. package/src/lib/Interfaces.ts +0 -2262
  109. package/src/lib/LoggerProxy.ts +0 -43
  110. package/src/lib/MetadataUtils.ts +0 -34
  111. package/src/lib/NodeErrors.ts +0 -332
  112. package/src/lib/NodeHelpers.ts +0 -1666
  113. package/src/lib/ObservableObject.ts +0 -77
  114. package/src/lib/RoutingNode.ts +0 -862
  115. package/src/lib/TelemetryHelpers.ts +0 -86
  116. package/src/lib/TypeValidation.ts +0 -431
  117. package/src/lib/VersionedNodeType.ts +0 -30
  118. package/src/lib/Workflow.ts +0 -1270
  119. package/src/lib/WorkflowDataProxy.ts +0 -708
  120. package/src/lib/WorkflowErrors.ts +0 -18
  121. package/src/lib/WorkflowHooks.ts +0 -51
  122. package/src/lib/errors/base/base.error.ts +0 -68
  123. package/src/lib/errors/base/operational.error.ts +0 -21
  124. package/src/lib/errors/error.types.ts +0 -14
  125. package/src/lib/errors/index.ts +0 -1
  126. package/src/lib/result.ts +0 -34
  127. package/src/lib/utils.ts +0 -166
  128. package/tests/Helpers.ts +0 -667
  129. package/tests/NodeHelpers.test.ts +0 -3053
  130. package/tests/ObservableObject.test.ts +0 -171
  131. package/tests/RoutingNode.test.ts +0 -1680
  132. package/tests/Workflow.test.ts +0 -1284
  133. package/tests/WorkflowDataProxy.test.ts +0 -199
  134. package/tsconfig.json +0 -27
  135. package/tsconfig.lib.json +0 -11
  136. package/tsconfig.spec.json +0 -14
package/tests/Helpers.ts DELETED
@@ -1,667 +0,0 @@
1
- import get from 'lodash.get';
2
- import {
3
- CredentialInformation,
4
- IAdditionalCredentialOptions,
5
- IAllExecuteFunctions,
6
- IContextObject,
7
- ICredentialDataDecryptedObject,
8
- ICredentials,
9
- ICredentialsEncrypted,
10
- ICredentialsHelper,
11
- IDataObject,
12
- IExecuteFunctions,
13
- IExecuteResponsePromiseData,
14
- IExecuteSingleFunctions,
15
- IExecuteWorkflowInfo,
16
- IHttpRequestOptions,
17
- IN8nHttpFullResponse,
18
- IN8nHttpResponse,
19
- INode,
20
- INodeCredentialsDetails,
21
- INodeExecutionData,
22
- INodeParameters,
23
- INodeType,
24
- INodeTypeData,
25
- INodeTypes,
26
- INodeVersionedType,
27
- IRunExecutionData,
28
- ITaskDataConnections,
29
- IWorkflowBase,
30
- IWorkflowDataProxyAdditionalKeys,
31
- IWorkflowDataProxyData,
32
- IWorkflowExecuteAdditionalData,
33
- NodeConnectionType,
34
- NodeHelpers,
35
- NodeParameterValue,
36
- Workflow,
37
- WorkflowDataProxy,
38
- WorkflowExecuteMode,
39
- WorkflowHooks,
40
- } from '..';
41
-
42
- export interface INodeTypesObject {
43
- [key: string]: INodeType;
44
- }
45
-
46
- export class Credentials extends ICredentials {
47
- hasNodeAccess(nodeType: string): boolean {
48
- return true;
49
- }
50
-
51
- setData(data: ICredentialDataDecryptedObject, encryptionKey: string): void {
52
- this.data = JSON.stringify(data);
53
- }
54
-
55
- setDataKey(key: string, data: CredentialInformation, encryptionKey: string): void {
56
- let fullData;
57
- try {
58
- fullData = this.getData(encryptionKey);
59
- } catch (e) {
60
- fullData = {};
61
- }
62
-
63
- fullData[key] = data;
64
-
65
- return this.setData(fullData, encryptionKey);
66
- }
67
-
68
- getData(encryptionKey: string, nodeType?: string): ICredentialDataDecryptedObject {
69
- if (this.data === undefined) {
70
- throw new Error('No data is set so nothing can be returned.');
71
- }
72
- return JSON.parse(this.data);
73
- }
74
-
75
- getDataKey(key: string, encryptionKey: string, nodeType?: string): CredentialInformation {
76
- const fullData = this.getData(encryptionKey, nodeType);
77
-
78
- if (fullData === null) {
79
- throw new Error(`No data was set.`);
80
- }
81
-
82
- // eslint-disable-next-line no-prototype-builtins
83
- if (!fullData.hasOwnProperty(key)) {
84
- throw new Error(`No data for key "${key}" exists.`);
85
- }
86
-
87
- return fullData[key];
88
- }
89
-
90
- getDataToSave(): ICredentialsEncrypted {
91
- if (this.data === undefined) {
92
- throw new Error(`No credentials were set to save.`);
93
- }
94
-
95
- return {
96
- id: this.id,
97
- name: this.name,
98
- type: this.type,
99
- data: this.data,
100
- nodesAccess: this.nodesAccess,
101
- };
102
- }
103
- }
104
-
105
- export class CredentialsHelper extends ICredentialsHelper {
106
- async authenticate(
107
- credentials: ICredentialDataDecryptedObject,
108
- typeName: string,
109
- requestParams: IHttpRequestOptions,
110
- ): Promise<IHttpRequestOptions> {
111
- return requestParams;
112
- }
113
-
114
- getParentTypes(name: string): string[] {
115
- return [];
116
- }
117
-
118
- async getDecrypted(
119
- nodeCredentials: INodeCredentialsDetails,
120
- type: string,
121
- ): Promise<ICredentialDataDecryptedObject> {
122
- return {};
123
- }
124
-
125
- async getCredentials(
126
- nodeCredentials: INodeCredentialsDetails,
127
- type: string,
128
- ): Promise<ICredentials> {
129
- return new Credentials({ id: null, name: '' }, '', [], '');
130
- }
131
-
132
- async updateCredentials(
133
- nodeCredentials: INodeCredentialsDetails,
134
- type: string,
135
- data: ICredentialDataDecryptedObject,
136
- // eslint-disable-next-line @typescript-eslint/no-empty-function
137
- ): Promise<void> {}
138
- }
139
-
140
- export function getNodeParameter(
141
- workflow: Workflow,
142
- runExecutionData: IRunExecutionData | null,
143
- runIndex: number,
144
- connectionInputData: INodeExecutionData[],
145
- node: INode,
146
- parameterName: string,
147
- itemIndex: number,
148
- mode: WorkflowExecuteMode,
149
- additionalKeys: IWorkflowDataProxyAdditionalKeys,
150
- fallbackValue?: any,
151
- ): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object {
152
- const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
153
- if (nodeType === undefined) {
154
- throw new Error(`Node type "${node.type}" is not known so can not return paramter value!`);
155
- }
156
-
157
- const value = get(node.parameters, parameterName, fallbackValue);
158
-
159
- if (value === undefined) {
160
- throw new Error(`Could not get parameter "${parameterName}"!`);
161
- }
162
-
163
- let returnData;
164
- try {
165
- returnData = workflow.expression.getParameterValue(
166
- value,
167
- runExecutionData,
168
- runIndex,
169
- itemIndex,
170
- node.name,
171
- connectionInputData,
172
- mode,
173
- additionalKeys,
174
- );
175
- } catch (e: any) {
176
- e.message += ` [Error in parameter: "${parameterName}"]`;
177
- throw e;
178
- }
179
-
180
- return returnData;
181
- }
182
-
183
- export function getExecuteFunctions(
184
- workflow: Workflow,
185
- runExecutionData: IRunExecutionData,
186
- runIndex: number,
187
- connectionInputData: INodeExecutionData[],
188
- inputData: ITaskDataConnections,
189
- node: INode,
190
- itemIndex: number,
191
- additionalData: IWorkflowExecuteAdditionalData,
192
- mode: WorkflowExecuteMode,
193
- ): IExecuteFunctions {
194
- return ((workflow, runExecutionData, connectionInputData, inputData, node) => {
195
- return {
196
- continueOnFail: () => {
197
- return false;
198
- },
199
- evaluateExpression: (expression: string, itemIndex: number) => {
200
- return expression;
201
- },
202
- async executeWorkflow(
203
- workflowInfo: IExecuteWorkflowInfo,
204
- inputData?: INodeExecutionData[],
205
- ): Promise<any> {
206
- return additionalData.executeWorkflow(workflowInfo, additionalData, inputData);
207
- },
208
- getContext(type: string): IContextObject {
209
- return NodeHelpers.getContext(runExecutionData, type, node);
210
- },
211
- async getCredentials(
212
- type: string,
213
- itemIndex?: number,
214
- ): Promise<ICredentialDataDecryptedObject | undefined> {
215
- return {
216
- apiKey: '12345',
217
- };
218
- },
219
- getExecutionId: (): string => {
220
- return additionalData.executionId!;
221
- },
222
- getInputData: (inputIndex = 0, inputName = 'main') => {
223
- // eslint-disable-next-line no-prototype-builtins
224
- if (!inputData.hasOwnProperty(inputName)) {
225
- // Return empty array because else it would throw error when nothing is connected to input
226
- return [];
227
- }
228
-
229
- if (inputData[inputName].length < inputIndex) {
230
- throw new Error(`Could not get input index "${inputIndex}" of input "${inputName}"!`);
231
- }
232
-
233
- if (inputData[inputName][inputIndex] === null) {
234
- // return [];
235
- throw new Error(`Value "${inputIndex}" of input "${inputName}" did not get set!`);
236
- }
237
-
238
- return inputData[inputName][inputIndex] as INodeExecutionData[];
239
- },
240
- getNodeParameter: (
241
- parameterName: string,
242
- itemIndex: number,
243
- fallbackValue?: any,
244
- ):
245
- | NodeParameterValue
246
- | INodeParameters
247
- | NodeParameterValue[]
248
- | INodeParameters[]
249
- | object => {
250
- return getNodeParameter(
251
- workflow,
252
- runExecutionData,
253
- runIndex,
254
- connectionInputData,
255
- node,
256
- parameterName,
257
- itemIndex,
258
- mode,
259
- {},
260
- fallbackValue,
261
- );
262
- },
263
- getMode: (): WorkflowExecuteMode => {
264
- return mode;
265
- },
266
- getNode: () => {
267
- return JSON.parse(JSON.stringify(node));
268
- },
269
- getRestApiUrl: (): string => {
270
- return additionalData.restApiUrl;
271
- },
272
- getTimezone: (): string => {
273
- return additionalData.timezone;
274
- },
275
- getWorkflow: () => {
276
- return {
277
- id: workflow.id,
278
- name: workflow.name,
279
- active: workflow.active,
280
- };
281
- },
282
- getWorkflowDataProxy: (itemIndex: number): IWorkflowDataProxyData => {
283
- const dataProxy = new WorkflowDataProxy(
284
- workflow,
285
- runExecutionData,
286
- runIndex,
287
- itemIndex,
288
- node.name,
289
- connectionInputData,
290
- {},
291
- mode,
292
- {},
293
- );
294
- return dataProxy.getDataProxy();
295
- },
296
- getWorkflowStaticData(type: string): IDataObject {
297
- return workflow.getStaticData(type, node);
298
- },
299
- prepareOutputData: NodeHelpers.prepareOutputData,
300
- async putExecutionToWait(waitTill: Date): Promise<void> {
301
- runExecutionData.waitTill = waitTill;
302
- },
303
- sendMessageToUI(...args: any[]): void {
304
- if (mode !== 'manual') {
305
- return;
306
- }
307
- try {
308
- if (additionalData.sendMessageToUI) {
309
- additionalData.sendMessageToUI(node.name, args);
310
- }
311
- } catch (error: any) {
312
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
313
- console.error(`There was a problem sending messsage to UI: ${error.message}`);
314
- }
315
- },
316
- async sendResponse(response: IExecuteResponsePromiseData): Promise<void> {
317
- await additionalData.hooks?.executeHookFunctions('sendResponse', [response]);
318
- },
319
- helpers: {
320
- async httpRequest(
321
- requestOptions: IHttpRequestOptions,
322
- ): Promise<IN8nHttpFullResponse | IN8nHttpResponse> {
323
- return {
324
- body: {
325
- headers: {},
326
- statusCode: 200,
327
- requestOptions,
328
- },
329
- };
330
- },
331
- async requestWithAuthentication(
332
- this: IAllExecuteFunctions,
333
- credentialsType: string,
334
- requestOptions: IHttpRequestOptions,
335
- additionalCredentialOptions?: IAdditionalCredentialOptions,
336
- ): Promise<any> {
337
- return {
338
- body: {
339
- headers: {},
340
- statusCode: 200,
341
- credentialsType,
342
- requestOptions,
343
- additionalCredentialOptions,
344
- },
345
- };
346
- },
347
- async httpRequestWithAuthentication(
348
- this: IAllExecuteFunctions,
349
- credentialsType: string,
350
- requestOptions: IHttpRequestOptions,
351
- additionalCredentialOptions?: IAdditionalCredentialOptions,
352
- ): Promise<any> {
353
- return {
354
- body: {
355
- headers: {},
356
- statusCode: 200,
357
- credentialsType,
358
- requestOptions,
359
- additionalCredentialOptions,
360
- },
361
- };
362
- },
363
- },
364
- };
365
- })(workflow, runExecutionData, connectionInputData, inputData, node);
366
- }
367
-
368
- export function getExecuteSingleFunctions(
369
- workflow: Workflow,
370
- runExecutionData: IRunExecutionData,
371
- runIndex: number,
372
- connectionInputData: INodeExecutionData[],
373
- inputData: ITaskDataConnections,
374
- node: INode,
375
- itemIndex: number,
376
- additionalData: IWorkflowExecuteAdditionalData,
377
- mode: WorkflowExecuteMode,
378
- ): IExecuteSingleFunctions {
379
- return ((workflow, runExecutionData, connectionInputData, inputData, node, itemIndex) => {
380
- return {
381
- continueOnFail: () => {
382
- return false;
383
- },
384
- evaluateExpression: (expression: string, evaluateItemIndex: number | undefined) => {
385
- return expression;
386
- },
387
- getContext(type: string): IContextObject {
388
- return NodeHelpers.getContext(runExecutionData, type, node);
389
- },
390
- async getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined> {
391
- return {
392
- apiKey: '12345',
393
- };
394
- },
395
- getInputData: (inputIndex = 0, inputName = 'main') => {
396
- // eslint-disable-next-line no-prototype-builtins
397
- if (!inputData.hasOwnProperty(inputName)) {
398
- // Return empty array because else it would throw error when nothing is connected to input
399
- return { json: {} };
400
- }
401
-
402
- if (inputData[inputName].length < inputIndex) {
403
- throw new Error(`Could not get input index "${inputIndex}" of input "${inputName}"!`);
404
- }
405
-
406
- const allItems = inputData[inputName][inputIndex];
407
-
408
- if (allItems === null) {
409
- // return [];
410
- throw new Error(`Value "${inputIndex}" of input "${inputName}" did not get set!`);
411
- }
412
-
413
- if (allItems[itemIndex] === null) {
414
- // return [];
415
- throw new Error(
416
- `Value "${inputIndex}" of input "${inputName}" with itemIndex "${itemIndex}" did not get set!`,
417
- );
418
- }
419
-
420
- return allItems[itemIndex];
421
- },
422
- getMode: (): WorkflowExecuteMode => {
423
- return mode;
424
- },
425
- getNode: () => {
426
- return JSON.parse(JSON.stringify(node));
427
- },
428
- getRestApiUrl: (): string => {
429
- return additionalData.restApiUrl;
430
- },
431
- getTimezone: (): string => {
432
- return additionalData.timezone;
433
- },
434
- getNodeParameter: (
435
- parameterName: string,
436
- fallbackValue?: any,
437
- ):
438
- | NodeParameterValue
439
- | INodeParameters
440
- | NodeParameterValue[]
441
- | INodeParameters[]
442
- | object => {
443
- return getNodeParameter(
444
- workflow,
445
- runExecutionData,
446
- runIndex,
447
- connectionInputData,
448
- node,
449
- parameterName,
450
- itemIndex,
451
- mode,
452
- {},
453
- fallbackValue,
454
- );
455
- },
456
- getWorkflow: () => {
457
- return {
458
- id: workflow.id,
459
- name: workflow.name,
460
- active: workflow.active,
461
- };
462
- },
463
- getWorkflowDataProxy: (): IWorkflowDataProxyData => {
464
- const dataProxy = new WorkflowDataProxy(
465
- workflow,
466
- runExecutionData,
467
- runIndex,
468
- itemIndex,
469
- node.name,
470
- connectionInputData,
471
- {},
472
- mode,
473
- {},
474
- );
475
- return dataProxy.getDataProxy();
476
- },
477
- getWorkflowStaticData(type: string): IDataObject {
478
- return workflow.getStaticData(type, node);
479
- },
480
- helpers: {
481
- async httpRequest(
482
- requestOptions: IHttpRequestOptions,
483
- ): Promise<IN8nHttpFullResponse | IN8nHttpResponse> {
484
- return {
485
- body: {
486
- headers: {},
487
- statusCode: 200,
488
- requestOptions,
489
- },
490
- };
491
- },
492
- async requestWithAuthentication(
493
- this: IAllExecuteFunctions,
494
- credentialsType: string,
495
- requestOptions: IHttpRequestOptions,
496
- additionalCredentialOptions?: IAdditionalCredentialOptions,
497
- ): Promise<any> {
498
- return {
499
- body: {
500
- headers: {},
501
- statusCode: 200,
502
- credentialsType,
503
- requestOptions,
504
- additionalCredentialOptions,
505
- },
506
- };
507
- },
508
- async httpRequestWithAuthentication(
509
- this: IAllExecuteFunctions,
510
- credentialsType: string,
511
- requestOptions: IHttpRequestOptions,
512
- additionalCredentialOptions?: IAdditionalCredentialOptions,
513
- ): Promise<any> {
514
- return {
515
- body: {
516
- headers: {},
517
- statusCode: 200,
518
- credentialsType,
519
- requestOptions,
520
- additionalCredentialOptions,
521
- },
522
- };
523
- },
524
- },
525
- };
526
- })(workflow, runExecutionData, connectionInputData, inputData, node, itemIndex);
527
- }
528
-
529
- class NodeTypesClass implements INodeTypes {
530
- nodeTypes: INodeTypeData = {
531
- 'test.set': {
532
- sourcePath: '',
533
- type: {
534
- description: {
535
- displayName: 'Set',
536
- name: 'set',
537
- group: ['input'],
538
- version: 1,
539
- description: 'Sets a value',
540
- defaults: {
541
- name: 'Set',
542
- color: '#0000FF',
543
- },
544
- inputs: [NodeConnectionTypes.Main],
545
- outputs: [NodeConnectionTypes.Main],
546
- properties: [
547
- {
548
- displayName: 'Value1',
549
- name: 'value1',
550
- type: 'string',
551
- default: 'default-value1',
552
- },
553
- {
554
- displayName: 'Value2',
555
- name: 'value2',
556
- type: 'string',
557
- default: 'default-value2',
558
- },
559
- ],
560
- },
561
- },
562
- },
563
- 'test.setMulti': {
564
- sourcePath: '',
565
- type: {
566
- description: {
567
- displayName: 'Set Multi',
568
- name: 'setMulti',
569
- group: ['input'],
570
- version: 1,
571
- description: 'Sets multiple values',
572
- defaults: {
573
- name: 'Set Multi',
574
- color: '#0000FF',
575
- },
576
- inputs: [NodeConnectionTypes.Main],
577
- outputs: [NodeConnectionTypes.Main],
578
- properties: [
579
- {
580
- displayName: 'Values',
581
- name: 'values',
582
- type: 'fixedCollection',
583
- typeOptions: {
584
- multipleValues: true,
585
- },
586
- default: {},
587
- options: [
588
- {
589
- name: 'string',
590
- displayName: 'String',
591
- values: [
592
- {
593
- displayName: 'Name',
594
- name: 'name',
595
- type: 'string',
596
- default: 'propertyName',
597
- placeholder: 'Name of the property to write data to.',
598
- },
599
- {
600
- displayName: 'Value',
601
- name: 'value',
602
- type: 'string',
603
- default: '',
604
- placeholder: 'The string value to write in the property.',
605
- },
606
- ],
607
- },
608
- ],
609
- },
610
- ],
611
- },
612
- },
613
- },
614
- };
615
-
616
- // eslint-disable-next-line @typescript-eslint/no-empty-function
617
- async init(nodeTypes: INodeTypeData): Promise<void> {}
618
-
619
- getAll(): INodeType[] {
620
- return Object.values(this.nodeTypes).map((data) => NodeHelpers.getVersionedNodeType(data.type));
621
- }
622
-
623
- getByName(nodeType: string): INodeType | INodeVersionedType | undefined {
624
- return this.getByNameAndVersion(nodeType);
625
- }
626
-
627
- getByNameAndVersion(nodeType: string, version?: number): INodeType {
628
- return NodeHelpers.getVersionedNodeType(this.nodeTypes[nodeType].type, version);
629
- }
630
- }
631
-
632
- let nodeTypesInstance: NodeTypesClass | undefined;
633
-
634
- export function NodeTypes(): NodeTypesClass {
635
- if (nodeTypesInstance === undefined) {
636
- nodeTypesInstance = new NodeTypesClass();
637
- }
638
-
639
- return nodeTypesInstance;
640
- }
641
-
642
- export function WorkflowExecuteAdditionalData(): IWorkflowExecuteAdditionalData {
643
- const workflowData: IWorkflowBase = {
644
- name: '',
645
- createdAt: new Date(),
646
- updatedAt: new Date(),
647
- active: true,
648
- nodes: [],
649
- connections: {},
650
- };
651
-
652
- return {
653
- credentialsHelper: new CredentialsHelper(''),
654
- hooks: new WorkflowHooks({}, 'trigger', '1', workflowData),
655
- // eslint-disable-next-line @typescript-eslint/no-empty-function
656
- executeWorkflow: async (workflowInfo: IExecuteWorkflowInfo): Promise<any> => {},
657
- // eslint-disable-next-line @typescript-eslint/no-empty-function
658
- sendMessageToUI: (message: string) => {},
659
- restApiUrl: '',
660
- encryptionKey: 'test',
661
- timezone: 'America/New_York',
662
- webhookBaseUrl: 'webhook',
663
- webhookWaitingBaseUrl: 'webhook-waiting',
664
- webhookTestBaseUrl: 'webhook-test',
665
- userId: '123',
666
- };
667
- }