@fsai-flow/workflow 0.0.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 (113) hide show
  1. package/.eslintrc.json +33 -0
  2. package/README.md +11 -0
  3. package/dist/README.md +11 -0
  4. package/dist/package.json +42 -0
  5. package/dist/src/index.d.ts +21 -0
  6. package/dist/src/index.js +33 -0
  7. package/dist/src/index.js.map +1 -0
  8. package/dist/src/lib/Constants.d.ts +68 -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 +6 -0
  12. package/dist/src/lib/DeferredPromise.js +11 -0
  13. package/dist/src/lib/DeferredPromise.js.map +1 -0
  14. package/dist/src/lib/Expression.d.ts +65 -0
  15. package/dist/src/lib/Expression.js +215 -0
  16. package/dist/src/lib/Expression.js.map +1 -0
  17. package/dist/src/lib/Interfaces.d.ts +1569 -0
  18. package/dist/src/lib/Interfaces.js +44 -0
  19. package/dist/src/lib/Interfaces.js.map +1 -0
  20. package/dist/src/lib/LoggerProxy.d.ts +9 -0
  21. package/dist/src/lib/LoggerProxy.js +40 -0
  22. package/dist/src/lib/LoggerProxy.js.map +1 -0
  23. package/dist/src/lib/MetadataUtils.d.ts +4 -0
  24. package/dist/src/lib/MetadataUtils.js +27 -0
  25. package/dist/src/lib/MetadataUtils.js.map +1 -0
  26. package/dist/src/lib/NodeErrors.d.ts +82 -0
  27. package/dist/src/lib/NodeErrors.js +289 -0
  28. package/dist/src/lib/NodeErrors.js.map +1 -0
  29. package/dist/src/lib/NodeHelpers.d.ts +198 -0
  30. package/dist/src/lib/NodeHelpers.js +1348 -0
  31. package/dist/src/lib/NodeHelpers.js.map +1 -0
  32. package/dist/src/lib/ObservableObject.d.ts +5 -0
  33. package/dist/src/lib/ObservableObject.js +61 -0
  34. package/dist/src/lib/ObservableObject.js.map +1 -0
  35. package/dist/src/lib/RoutingNode.d.ts +18 -0
  36. package/dist/src/lib/RoutingNode.js +508 -0
  37. package/dist/src/lib/RoutingNode.js.map +1 -0
  38. package/dist/src/lib/TelemetryHelpers.d.ts +3 -0
  39. package/dist/src/lib/TelemetryHelpers.js +69 -0
  40. package/dist/src/lib/TelemetryHelpers.js.map +1 -0
  41. package/dist/src/lib/TypeValidation.d.ts +21 -0
  42. package/dist/src/lib/TypeValidation.js +385 -0
  43. package/dist/src/lib/TypeValidation.js.map +1 -0
  44. package/dist/src/lib/VersionedNodeType.d.ts +9 -0
  45. package/dist/src/lib/VersionedNodeType.js +26 -0
  46. package/dist/src/lib/VersionedNodeType.js.map +1 -0
  47. package/dist/src/lib/Workflow.d.ts +248 -0
  48. package/dist/src/lib/Workflow.js +901 -0
  49. package/dist/src/lib/Workflow.js.map +1 -0
  50. package/dist/src/lib/WorkflowDataProxy.d.ts +87 -0
  51. package/dist/src/lib/WorkflowDataProxy.js +556 -0
  52. package/dist/src/lib/WorkflowDataProxy.js.map +1 -0
  53. package/dist/src/lib/WorkflowErrors.d.ts +9 -0
  54. package/dist/src/lib/WorkflowErrors.js +18 -0
  55. package/dist/src/lib/WorkflowErrors.js.map +1 -0
  56. package/dist/src/lib/WorkflowHooks.d.ts +11 -0
  57. package/dist/src/lib/WorkflowHooks.js +34 -0
  58. package/dist/src/lib/WorkflowHooks.js.map +1 -0
  59. package/dist/src/lib/errors/base/base.error.d.ts +30 -0
  60. package/dist/src/lib/errors/base/base.error.js +45 -0
  61. package/dist/src/lib/errors/base/base.error.js.map +1 -0
  62. package/dist/src/lib/errors/base/operational.error.d.ts +15 -0
  63. package/dist/src/lib/errors/base/operational.error.js +19 -0
  64. package/dist/src/lib/errors/base/operational.error.js.map +1 -0
  65. package/dist/src/lib/errors/error.types.d.ts +11 -0
  66. package/dist/src/lib/errors/error.types.js +3 -0
  67. package/dist/src/lib/errors/error.types.js.map +1 -0
  68. package/dist/src/lib/errors/index.d.ts +1 -0
  69. package/dist/src/lib/errors/index.js +6 -0
  70. package/dist/src/lib/errors/index.js.map +1 -0
  71. package/dist/src/lib/result.d.ts +19 -0
  72. package/dist/src/lib/result.js +36 -0
  73. package/dist/src/lib/result.js.map +1 -0
  74. package/dist/src/lib/utils.d.ts +50 -0
  75. package/dist/src/lib/utils.js +110 -0
  76. package/dist/src/lib/utils.js.map +1 -0
  77. package/eslint.config.js +19 -0
  78. package/jest.config.ts +10 -0
  79. package/package.json +40 -0
  80. package/project.json +19 -0
  81. package/src/index.ts +33 -0
  82. package/src/lib/Constants.ts +124 -0
  83. package/src/lib/DeferredPromise.ts +14 -0
  84. package/src/lib/Expression.ts +375 -0
  85. package/src/lib/Interfaces.ts +2229 -0
  86. package/src/lib/LoggerProxy.ts +43 -0
  87. package/src/lib/MetadataUtils.ts +34 -0
  88. package/src/lib/NodeErrors.ts +332 -0
  89. package/src/lib/NodeHelpers.ts +1666 -0
  90. package/src/lib/ObservableObject.ts +77 -0
  91. package/src/lib/RoutingNode.ts +862 -0
  92. package/src/lib/TelemetryHelpers.ts +86 -0
  93. package/src/lib/TypeValidation.ts +431 -0
  94. package/src/lib/VersionedNodeType.ts +30 -0
  95. package/src/lib/Workflow.ts +1266 -0
  96. package/src/lib/WorkflowDataProxy.ts +708 -0
  97. package/src/lib/WorkflowErrors.ts +18 -0
  98. package/src/lib/WorkflowHooks.ts +51 -0
  99. package/src/lib/errors/base/base.error.ts +68 -0
  100. package/src/lib/errors/base/operational.error.ts +21 -0
  101. package/src/lib/errors/error.types.ts +14 -0
  102. package/src/lib/errors/index.ts +1 -0
  103. package/src/lib/result.ts +34 -0
  104. package/src/lib/utils.ts +132 -0
  105. package/tests/Helpers.ts +667 -0
  106. package/tests/NodeHelpers.test.ts +3053 -0
  107. package/tests/ObservableObject.test.ts +171 -0
  108. package/tests/RoutingNode.test.ts +1680 -0
  109. package/tests/Workflow.test.ts +1284 -0
  110. package/tests/WorkflowDataProxy.test.ts +199 -0
  111. package/tsconfig.json +27 -0
  112. package/tsconfig.lib.json +11 -0
  113. package/tsconfig.spec.json +14 -0
@@ -0,0 +1,2229 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /* eslint-disable import/no-extraneous-dependencies */
3
+ /* eslint-disable import/no-cycle */
4
+ // eslint-disable-next-line import/no-extraneous-dependencies
5
+ // eslint-disable-next-line max-classes-per-file
6
+ import * as express from 'express';
7
+ import * as FormData from 'form-data';
8
+ import { URLSearchParams } from 'url';
9
+ import { IDeferredPromise } from './DeferredPromise';
10
+ import { WorkflowHooks } from './WorkflowHooks';
11
+ import { WorkflowOperationError } from './WorkflowErrors';
12
+ import { NodeApiError, NodeOperationError } from './NodeErrors';
13
+ import { Workflow } from './Workflow';
14
+ import { CODE_EXECUTION_MODES, CODE_LANGUAGES, LOG_LEVELS } from './Constants';
15
+
16
+ export interface IAdditionalCredentialOptions {
17
+ oauth2?: IOAuth2Options;
18
+ credentialsDecrypted?: ICredentialsDecrypted;
19
+ }
20
+
21
+ export type IAllExecuteFunctions =
22
+ | IExecuteFunctions
23
+ | IExecutePaginationFunctions
24
+ | IExecuteSingleFunctions
25
+ | IHookFunctions
26
+ | ILoadOptionsFunctions
27
+ | IPollFunctions
28
+ | ITriggerFunctions
29
+ | IWebhookFunctions
30
+ | ISupplyDataFunctions;
31
+
32
+ export interface IBinaryData {
33
+ [key: string]: string | undefined;
34
+ data: string;
35
+ mimeType: string;
36
+ fileName?: string;
37
+ directory?: string;
38
+ fileExtension?: string;
39
+ id?: string;
40
+ }
41
+
42
+ export interface IOAuth2Options {
43
+ includeCredentialsOnRefreshOnBody?: boolean;
44
+ property?: string;
45
+ tokenType?: string;
46
+ keepBearer?: boolean;
47
+ tokenExpiredStatusCode?: number;
48
+ }
49
+
50
+ export interface IConnection {
51
+ // The node the connection is to
52
+ node: string;
53
+
54
+ // The type of the input on destination node (for example "main")
55
+ type: string;
56
+
57
+ // The output/input-index of destination node (if node has multiple inputs/outputs of the same type)
58
+ index: number;
59
+ }
60
+
61
+ export type ExecutionError = WorkflowOperationError | NodeOperationError | NodeApiError;
62
+
63
+ // Get used to gives nodes access to credentials
64
+ export interface IGetCredentials {
65
+ get(type: string, id: string | null): Promise<ICredentialsEncrypted>;
66
+ }
67
+
68
+ export abstract class ICredentials {
69
+ id?: string;
70
+
71
+ name: string;
72
+
73
+ type: string;
74
+
75
+ data: string | undefined;
76
+
77
+ nodesAccess: ICredentialNodeAccess[];
78
+
79
+ constructor(
80
+ nodeCredentials: INodeCredentialsDetails,
81
+ type: string,
82
+ nodesAccess: ICredentialNodeAccess[],
83
+ data?: string,
84
+ ) {
85
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
86
+ this.id = nodeCredentials.id || undefined;
87
+ this.name = nodeCredentials.name;
88
+ this.type = type;
89
+ this.nodesAccess = nodesAccess;
90
+ this.data = data;
91
+ }
92
+
93
+ abstract getData(encryptionKey: string, nodeType?: string): ICredentialDataDecryptedObject;
94
+
95
+ abstract getDataKey(key: string, encryptionKey: string, nodeType?: string): CredentialInformation;
96
+
97
+ abstract getDataToSave(): ICredentialsEncrypted;
98
+
99
+ abstract hasNodeAccess(nodeType: string): boolean;
100
+
101
+ abstract setData(data: ICredentialDataDecryptedObject, encryptionKey: string): void;
102
+
103
+ abstract setDataKey(key: string, data: CredentialInformation, encryptionKey: string): void;
104
+ }
105
+
106
+ // Defines which nodes are allowed to access the credentials and
107
+ // when that access got grented from which user
108
+ export interface ICredentialNodeAccess {
109
+ nodeType: string;
110
+ user?: string;
111
+ date?: Date;
112
+ }
113
+
114
+ export interface ICredentialsDecrypted {
115
+ id: string | number;
116
+ name: string;
117
+ type: string;
118
+ nodesAccess: ICredentialNodeAccess[];
119
+ data?: ICredentialDataDecryptedObject;
120
+ }
121
+
122
+ export interface ICredentialsEncrypted {
123
+ id?: string | number;
124
+ name: string;
125
+ type: string;
126
+ nodesAccess: ICredentialNodeAccess[];
127
+ data?: string;
128
+ }
129
+
130
+ export type NodeTypeAndVersion = {
131
+ name: string;
132
+ type: string;
133
+ typeVersion: number;
134
+ disabled: boolean;
135
+ parameters?: INodeParameters;
136
+ };
137
+
138
+ export interface ICredentialsExpressionResolveValues {
139
+ connectionInputData: INodeExecutionData[];
140
+ itemIndex: number;
141
+ node: INode;
142
+ runExecutionData: IRunExecutionData | null;
143
+ runIndex: number;
144
+ workflow: Workflow;
145
+ }
146
+
147
+ // Simplified options of request library
148
+ export interface IRequestOptionsSimplified {
149
+ auth?: {
150
+ username: string;
151
+ password: string;
152
+ };
153
+ body: IDataObject;
154
+ headers: IDataObject;
155
+ qs: IDataObject;
156
+ }
157
+
158
+ export abstract class ICredentialsHelper {
159
+ encryptionKey: string;
160
+
161
+ constructor(encryptionKey: string) {
162
+ this.encryptionKey = encryptionKey;
163
+ }
164
+
165
+ abstract getParentTypes(name: string): string[];
166
+
167
+ abstract authenticate(
168
+ credentials: ICredentialDataDecryptedObject,
169
+ typeName: string,
170
+ requestOptions: IHttpRequestOptions | IRequestOptionsSimplified,
171
+ workflow: Workflow,
172
+ node: INode,
173
+ ): Promise<IHttpRequestOptions>;
174
+
175
+ abstract getCredentials(
176
+ nodeCredentials: INodeCredentialsDetails,
177
+ type: string,
178
+ ): Promise<ICredentials>;
179
+
180
+ abstract getDecrypted(
181
+ nodeCredentials: INodeCredentialsDetails,
182
+ type: string,
183
+ mode: WorkflowExecuteMode,
184
+ raw?: boolean,
185
+ expressionResolveValues?: ICredentialsExpressionResolveValues,
186
+ ): Promise<ICredentialDataDecryptedObject>;
187
+
188
+ abstract updateCredentials(
189
+ nodeCredentials: INodeCredentialsDetails,
190
+ type: string,
191
+ data: ICredentialDataDecryptedObject,
192
+ ): Promise<void>;
193
+ }
194
+
195
+ export interface IAuthenticateBase {
196
+ type: string;
197
+ properties: {
198
+ [key: string]: string;
199
+ };
200
+ }
201
+
202
+ export abstract class Node {
203
+ abstract description: INodeTypeDescription;
204
+ execute?(context: IExecuteFunctions): Promise<INodeExecutionData[][]>;
205
+ webhook?(context: IWebhookFunctions): Promise<IWebhookResponseData>;
206
+ poll?(context: IPollFunctions): Promise<INodeExecutionData[][] | null>;
207
+ }
208
+
209
+ export interface IAuthenticateBasicAuth extends IAuthenticateBase {
210
+ type: 'basicAuth';
211
+ properties: {
212
+ userPropertyName?: string;
213
+ passwordPropertyName?: string;
214
+ };
215
+ }
216
+
217
+ export interface IAuthenticateBearer extends IAuthenticateBase {
218
+ type: 'bearer';
219
+ properties: {
220
+ tokenPropertyName?: string;
221
+ };
222
+ }
223
+
224
+ export interface IAuthenticateHeaderAuth extends IAuthenticateBase {
225
+ type: 'headerAuth';
226
+ properties: {
227
+ name: string;
228
+ value: string;
229
+ };
230
+ }
231
+
232
+ export interface IAuthenticateQueryAuth extends IAuthenticateBase {
233
+ type: 'queryAuth';
234
+ properties: {
235
+ key: string;
236
+ value: string;
237
+ };
238
+ }
239
+
240
+ export type IAuthenticate =
241
+ | ((
242
+ credentials: ICredentialDataDecryptedObject,
243
+ requestOptions: IHttpRequestOptions,
244
+ ) => Promise<IHttpRequestOptions>)
245
+ | IAuthenticateBasicAuth
246
+ | IAuthenticateBearer
247
+ | IAuthenticateHeaderAuth
248
+ | IAuthenticateQueryAuth;
249
+
250
+ export interface IAuthenticateRuleBase {
251
+ type: string;
252
+ properties: {
253
+ [key: string]: string | number;
254
+ };
255
+ errorMessage?: string;
256
+ }
257
+
258
+ export interface IAuthenticateRuleResponseCode extends IAuthenticateRuleBase {
259
+ type: 'responseCode';
260
+ properties: {
261
+ value: number;
262
+ message: string;
263
+ };
264
+ }
265
+
266
+ export interface ICredentialTestRequest {
267
+ request: IHttpRequestOptions;
268
+ rules?: IAuthenticateRuleResponseCode[];
269
+ }
270
+
271
+ export interface ICredentialTestRequestData {
272
+ nodeType?: INodeType;
273
+ testRequest: ICredentialTestRequest;
274
+ }
275
+
276
+ export type IconRef = `fa:${string}` | `node:${string}.${string}`;
277
+ export type IconFile = `file:${string}.png` | `file:${string}.svg`;
278
+ export type Icon = IconRef | Themed<IconFile>;
279
+
280
+ type ICredentialHttpRequestNode = {
281
+ name: string;
282
+ docsUrl: string;
283
+ hidden?: boolean;
284
+ } & ({ apiBaseUrl: string } | { apiBaseUrlPlaceholder: string });
285
+
286
+ export interface ICredentialType {
287
+ name: string;
288
+ displayName: string;
289
+ icon?: Icon | string;
290
+ iconColor?: ThemeIconColor;
291
+ iconUrl?: Themed<string>;
292
+ extends?: string[];
293
+ properties: INodeProperties[];
294
+ documentationUrl?: string;
295
+ __overwrittenProperties?: string[];
296
+ authenticate?: IAuthenticate;
297
+ test?: ICredentialTestRequest;
298
+ httpRequestNode?: ICredentialHttpRequestNode;
299
+ supportedNodes?: string[];
300
+ }
301
+
302
+ export interface ICredentialTypes {
303
+ credentialTypes?: ICredentialTypeData;
304
+ init(credentialTypes?: ICredentialTypeData): Promise<void>;
305
+ getAll(): ICredentialType[];
306
+ getByName(credentialType: string): ICredentialType;
307
+ }
308
+
309
+ // The way the credentials get saved in the database (data encrypted)
310
+ export interface ICredentialData {
311
+ id?: string;
312
+ name: string;
313
+ data: string; // Contains the access data as encrypted JSON string
314
+ nodesAccess: ICredentialNodeAccess[];
315
+ }
316
+
317
+ // The encrypted credentials which the nodes can access
318
+ export type CredentialInformation = string | number | boolean | IDataObject;
319
+
320
+ // The encrypted credentials which the nodes can access
321
+ export interface ICredentialDataDecryptedObject {
322
+ [key: string]: CredentialInformation;
323
+ }
324
+
325
+ // First array index: The output/input-index (if node has multiple inputs/outputs of the same type)
326
+ // Second array index: The different connections (if one node is connected to multiple nodes)
327
+ export type NodeInputConnections = IConnection[][];
328
+
329
+ export interface INodeConnections {
330
+ // Input name
331
+ [key: string]: NodeInputConnections;
332
+ }
333
+
334
+ export interface IConnections {
335
+ // Node name
336
+ [key: string]: INodeConnections;
337
+ }
338
+
339
+ export type GenericValue = string | object | number | boolean | undefined | null;
340
+
341
+ // export type IExecuteResponsePromiseData = IDataObject;
342
+ export type IExecuteResponsePromiseData = IDataObject | IN8nHttpFullResponse;
343
+
344
+ export interface INodeTypeNameVersion {
345
+ name: string;
346
+ version: number;
347
+ }
348
+
349
+ export interface IGetExecutePollFunctions {
350
+ (
351
+ workflow: Workflow,
352
+ node: INode,
353
+ additionalData: IWorkflowExecuteAdditionalData,
354
+ mode: WorkflowExecuteMode,
355
+ activation: WorkflowActivateMode,
356
+ ): IPollFunctions;
357
+ }
358
+
359
+ export interface IGetExecuteTriggerFunctions {
360
+ (
361
+ workflow: Workflow,
362
+ node: INode,
363
+ additionalData: IWorkflowExecuteAdditionalData,
364
+ mode: WorkflowExecuteMode,
365
+ activation: WorkflowActivateMode,
366
+ ): ITriggerFunctions;
367
+ }
368
+
369
+ export interface IGetExecuteFunctions {
370
+ (
371
+ workflow: Workflow,
372
+ runExecutionData: IRunExecutionData,
373
+ runIndex: number,
374
+ connectionInputData: INodeExecutionData[],
375
+ inputData: ITaskDataConnections,
376
+ node: INode,
377
+ additionalData: IWorkflowExecuteAdditionalData,
378
+ mode: WorkflowExecuteMode,
379
+ nodeTypeData: INodeType,
380
+ closeFunctions: CloseFunction[],
381
+ ): IExecuteFunctions;
382
+ }
383
+
384
+ export interface IGetExecuteSingleFunctions {
385
+ (
386
+ workflow: Workflow,
387
+ runExecutionData: IRunExecutionData,
388
+ runIndex: number,
389
+ connectionInputData: INodeExecutionData[],
390
+ inputData: ITaskDataConnections,
391
+ node: INode,
392
+ itemIndex: number,
393
+ additionalData: IWorkflowExecuteAdditionalData,
394
+ mode: WorkflowExecuteMode,
395
+ ): IExecuteSingleFunctions;
396
+ }
397
+
398
+ export interface IGetExecuteHookFunctions {
399
+ (
400
+ workflow: Workflow,
401
+ node: INode,
402
+ additionalData: IWorkflowExecuteAdditionalData,
403
+ mode: WorkflowExecuteMode,
404
+ activation: WorkflowActivateMode,
405
+ isTest?: boolean,
406
+ webhookData?: IWebhookData,
407
+ ): IHookFunctions;
408
+ }
409
+
410
+ export interface IGetExecuteWebhookFunctions {
411
+ (
412
+ workflow: Workflow,
413
+ node: INode,
414
+ additionalData: IWorkflowExecuteAdditionalData,
415
+ mode: WorkflowExecuteMode,
416
+ webhookData: IWebhookData,
417
+ runExecutionData: IRunExecutionData | undefined,
418
+ ): IWebhookFunctions;
419
+ }
420
+
421
+ export interface IExecuteData {
422
+ data: ITaskDataConnections;
423
+ node: INode;
424
+ }
425
+
426
+ export type IContextObject = {
427
+ [key: string]: any;
428
+ };
429
+
430
+ export interface IExecuteContextData {
431
+ // Keys are: "flow" | "node:<NODE_NAME>"
432
+ [key: string]: IContextObject;
433
+ }
434
+
435
+ export type IHttpRequestMethods = 'DELETE' | 'GET' | 'HEAD' | 'PATCH' | 'POST' | 'PUT';
436
+
437
+ export interface IHttpRequestOptions {
438
+ url: string;
439
+ baseURL?: string;
440
+ headers?: IDataObject;
441
+ method?: IHttpRequestMethods;
442
+ body?: FormData | GenericValue | GenericValue[] | Buffer | URLSearchParams;
443
+ qs?: IDataObject;
444
+ arrayFormat?: 'indices' | 'brackets' | 'repeat' | 'comma';
445
+ auth?: {
446
+ username: string;
447
+ password: string;
448
+ };
449
+ disableFollowRedirect?: boolean;
450
+ encoding?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream';
451
+ skipSslCertificateValidation?: boolean;
452
+ returnFullResponse?: boolean;
453
+ ignoreHttpStatusErrors?: boolean;
454
+ proxy?: {
455
+ host: string;
456
+ port: number;
457
+ auth?: {
458
+ username: string;
459
+ password: string;
460
+ };
461
+ protocol?: string;
462
+ };
463
+ timeout?: number;
464
+ json?: boolean;
465
+ }
466
+
467
+ export type IN8nHttpResponse = IDataObject | Buffer | GenericValue | GenericValue[] | null;
468
+
469
+ export interface IN8nHttpFullResponse {
470
+ body: IN8nHttpResponse;
471
+ headers: IDataObject;
472
+ statusCode: number;
473
+ statusMessage?: string;
474
+ }
475
+
476
+ export interface IN8nRequestOperations {
477
+ pagination?:
478
+ | IN8nRequestOperationPaginationOffset
479
+ | ((
480
+ this: IExecutePaginationFunctions,
481
+ requestOptions: IRequestOptionsFromParameters,
482
+ ) => Promise<INodeExecutionData[]>);
483
+ }
484
+
485
+ export interface IN8nRequestOperationPaginationBase {
486
+ type: string;
487
+ properties: {
488
+ [key: string]: string | number;
489
+ };
490
+ }
491
+
492
+ export interface IN8nRequestOperationPaginationOffset extends IN8nRequestOperationPaginationBase {
493
+ type: 'offset';
494
+ properties: {
495
+ limitParameter: string;
496
+ offsetParameter: string;
497
+ pageSize: number;
498
+ rootProperty?: string; // Optional Path to option array
499
+ type: 'body' | 'query';
500
+ };
501
+ }
502
+
503
+ export interface ITaskSubRunMetadata {
504
+ node: string;
505
+ runIndex: number;
506
+ }
507
+
508
+ export interface RelatedExecution {
509
+ executionId: string;
510
+ workflowId: string;
511
+ }
512
+
513
+ export interface ITaskMetadata {
514
+ subRun?: ITaskSubRunMetadata[];
515
+ parentExecution?: RelatedExecution;
516
+ subExecution?: RelatedExecution;
517
+ subExecutionsCount?: number;
518
+ }
519
+
520
+ export type AINodeConnectionType = Exclude<NodeConnectionType, typeof NodeConnectionTypes.Main>;
521
+
522
+ namespace RecordReturning {
523
+ export type NodeParameter = 'additionalFields' | 'filters' | 'options' | 'updateFields';
524
+ }
525
+
526
+ export interface IExecuteFunctions {
527
+ continueOnFail(): boolean;
528
+ evaluateExpression(
529
+ expression: string,
530
+ itemIndex: number,
531
+ ): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[];
532
+ executeWorkflow(
533
+ workflowInfo: IExecuteWorkflowInfo,
534
+ inputData?: INodeExecutionData[],
535
+ ): Promise<any>;
536
+ getContext(type: string): IContextObject;
537
+ getCredentials(
538
+ type: string,
539
+ itemIndex?: number,
540
+ ): Promise<ICredentialDataDecryptedObject | undefined>;
541
+ getCredentials<T extends object = ICredentialDataDecryptedObject>(
542
+ type: string,
543
+ itemIndex?: number,
544
+ ): Promise<T>;
545
+ getInputData(inputIndex?: number, inputName?: string): INodeExecutionData[];
546
+ getInstanceId(): string;
547
+ getMode(): WorkflowExecuteMode;
548
+ getNode(): INode;
549
+ getNodeParameter<T extends { resource: string }>(
550
+ parameterName: 'resource',
551
+ itemIndex?: number,
552
+ ): T['resource'];
553
+ // getNodeParameter(parameterName: 'operation', itemIndex?: number): string;
554
+ getNodeParameter(
555
+ parameterName: string,
556
+ itemIndex: number,
557
+ fallbackValue?: any,
558
+ options?: IGetNodeParameterOptions,
559
+ ): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object;
560
+ getNodeParameter(
561
+ parameterName: RecordReturning.NodeParameter,
562
+ itemIndex: number,
563
+ fallbackValue?: IDataObject,
564
+ options?: IGetNodeParameterOptions,
565
+ ): IDataObject;
566
+ getExecutionCancelSignal(): AbortSignal | undefined;
567
+ getWorkflowDataProxy(itemIndex: number): IWorkflowDataProxyData;
568
+ getWorkflowStaticData(type: string): IDataObject;
569
+ getRestApiUrl(): string;
570
+ getTimezone(): string;
571
+ getWorkflow(): IWorkflowMetadata;
572
+ prepareOutputData(
573
+ outputData: INodeExecutionData[],
574
+ outputIndex?: number,
575
+ ): Promise<INodeExecutionData[][]>;
576
+ putExecutionToWait(waitTill: Date): Promise<void>;
577
+ sendMessageToUI(message: any): void; // tslint:disable-line:no-any
578
+ sendResponse(response: IExecuteResponsePromiseData): void; // tslint:disable-line:no-any
579
+ addInputData(
580
+ data: INodeExecutionData[][] | ExecutionError,
581
+ node: INode,
582
+ ): { index: number, inputExecutionData: IRunExecutionData };
583
+ addOutputData(
584
+ data: INodeExecutionData[][] | ExecutionError,
585
+ node: INode,
586
+ ): { outputExecutionData: IRunExecutionData };
587
+ getInputConnectionData(
588
+ connectionType: AINodeConnectionType,
589
+ itemIndex: number,
590
+ inputIndex?: number,
591
+ ): Promise<unknown>;
592
+ getNodeOutputs?(): INodeOutputConfiguration[];
593
+ helpers: {
594
+ httpRequest(
595
+ requestOptions: IHttpRequestOptions,
596
+ ): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
597
+ httpRequestWithAuthentication(
598
+ this: IAllExecuteFunctions,
599
+ credentialsType: string,
600
+ requestOptions: IHttpRequestOptions,
601
+ additionalCredentialOptions?: IAdditionalCredentialOptions,
602
+ ): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
603
+ assertBinaryData(itemIndex: number, propertyName: string, inputIndex?: number): IBinaryData;
604
+ getBinaryDataBuffer(itemIndex: number, propertyName: string, inputIndex?: number): Promise<Buffer>;
605
+ [key: string]: (...args: any[]) => any; // tslint:disable-line:no-any
606
+ };
607
+ }
608
+
609
+ export interface INodeInputFilter {
610
+ nodes: string[];
611
+ }
612
+
613
+ export interface INodeInputConfiguration {
614
+ category?: string;
615
+ displayName?: string;
616
+ required?: boolean;
617
+ type: NodeConnectionType;
618
+ filter?: INodeInputFilter;
619
+ maxConnections?: number;
620
+ }
621
+
622
+ export interface INodeOutputConfiguration {
623
+ category?: 'error';
624
+ displayName?: string;
625
+ maxConnections?: number;
626
+ required?: boolean;
627
+ type: NodeConnectionType;
628
+ }
629
+
630
+ export type ISupplyDataFunctions = {
631
+ logger: Logger;
632
+ continueOnFail(): boolean;
633
+ evaluateExpression(
634
+ expression: string,
635
+ itemIndex: number,
636
+ ): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[];
637
+ executeWorkflow(
638
+ workflowInfo: IExecuteWorkflowInfo,
639
+ inputData?: INodeExecutionData[],
640
+ ): Promise<any>;
641
+ getContext(type: string): IContextObject;
642
+ getCredentials(
643
+ type: string,
644
+ itemIndex?: number,
645
+ ): Promise<ICredentialDataDecryptedObject | undefined>;
646
+ getInputData(inputIndex?: number, inputName?: string): INodeExecutionData[];
647
+ getInstanceId(): string;
648
+ getMode(): WorkflowExecuteMode;
649
+ getNode(): INode;
650
+ getNodeParameter<T extends { resource: string }>(
651
+ parameterName: 'resource',
652
+ itemIndex?: number,
653
+ ): T['resource'];
654
+ getNodeParameter(
655
+ parameterName: string,
656
+ itemIndex: number,
657
+ fallbackValue?: any,
658
+ ): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object;
659
+ getWorkflowDataProxy(itemIndex: number): IWorkflowDataProxyData;
660
+ getWorkflowStaticData(type: string): IDataObject;
661
+ getRestApiUrl(): string;
662
+ getTimezone(): string;
663
+ getWorkflow(): IWorkflowMetadata;
664
+ prepareOutputData(
665
+ outputData: INodeExecutionData[],
666
+ outputIndex?: number,
667
+ ): Promise<INodeExecutionData[][]>;
668
+ putExecutionToWait(waitTill: Date): Promise<void>;
669
+ sendMessageToUI(message: any): void; // tslint:disable-line:no-any
670
+ sendResponse(response: IExecuteResponsePromiseData): void; // tslint:disable-line:no-any
671
+
672
+ getInputConnectionData(
673
+ connectionType: NodeConnectionType,
674
+ itemIndex: number,
675
+ inputIndex?: number,
676
+ ): Promise<unknown>;
677
+ addInputData(
678
+ data: INodeExecutionData[][] | ExecutionError,
679
+ node: INode,
680
+ ): { index: number, inputExecutionData: IRunExecutionData };
681
+ addOutputData(
682
+ data: INodeExecutionData[][] | ExecutionError,
683
+ node: INode,
684
+ ): { outputExecutionData: IRunExecutionData };
685
+ helpers: {
686
+ httpRequest(
687
+ requestOptions: IHttpRequestOptions,
688
+ ): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
689
+ httpRequestWithAuthentication(
690
+ this: IAllExecuteFunctions,
691
+ credentialsType: string,
692
+ requestOptions: IHttpRequestOptions,
693
+ additionalCredentialOptions?: IAdditionalCredentialOptions,
694
+ ): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
695
+ assertBinaryData(itemIndex: number, propertyName: string, inputIndex?: number): IBinaryData;
696
+ getBinaryDataBuffer(itemIndex: number, propertyName: string, inputIndex?: number): Promise<Buffer>;
697
+ [key: string]: (...args: any[]) => any; // tslint:disable-line:no-any
698
+ };
699
+ }
700
+
701
+ export interface IExecuteSingleFunctions {
702
+ continueOnFail(): boolean;
703
+ evaluateExpression(
704
+ expression: string,
705
+ itemIndex: number | undefined,
706
+ ): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[];
707
+ getContext(type: string): IContextObject;
708
+ getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined>;
709
+ getInputData(inputIndex?: number, inputName?: string): INodeExecutionData;
710
+ getMode(): WorkflowExecuteMode;
711
+ getNode(): INode;
712
+ getNodeParameter(
713
+ parameterName: string,
714
+ fallbackValue?: any,
715
+ ): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object;
716
+ getRestApiUrl(): string;
717
+ getTimezone(): string;
718
+ getWorkflow(): IWorkflowMetadata;
719
+ getWorkflowDataProxy(): IWorkflowDataProxyData;
720
+ getWorkflowStaticData(type: string): IDataObject;
721
+ helpers: {
722
+ httpRequest(
723
+ requestOptions: IHttpRequestOptions,
724
+ ): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
725
+ httpRequestWithAuthentication(
726
+ this: IAllExecuteFunctions,
727
+ credentialsType: string,
728
+ requestOptions: IHttpRequestOptions,
729
+ additionalCredentialOptions?: IAdditionalCredentialOptions,
730
+ ): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
731
+ [key: string]: (...args: any[]) => any; // tslint:disable-line:no-any
732
+ };
733
+ }
734
+
735
+ export interface IExecutePaginationFunctions extends IExecuteSingleFunctions {
736
+ makeRoutingRequest(
737
+ this: IAllExecuteFunctions,
738
+ requestOptions: IRequestOptionsFromParameters,
739
+ ): Promise<INodeExecutionData[]>;
740
+ }
741
+ export interface IExecuteWorkflowInfo {
742
+ code?: IWorkflowBase;
743
+ id?: string;
744
+ }
745
+
746
+ export type ICredentialTestFunction = (
747
+ this: ICredentialTestFunctions,
748
+ credential: ICredentialsDecrypted,
749
+ ) => Promise<INodeCredentialTestResult>;
750
+
751
+ export interface ICredentialTestFunctions {
752
+ helpers: {
753
+ [key: string]: (...args: any[]) => any;
754
+ };
755
+ }
756
+
757
+ export interface ILoadOptionsFunctions {
758
+ getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined>;
759
+ getNode(): INode;
760
+ getNodeParameter(
761
+ parameterName: string,
762
+ fallbackValue?: any,
763
+ ): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object;
764
+ getCurrentNodeParameter(
765
+ parameterName: string,
766
+ ):
767
+ | NodeParameterValue
768
+ | INodeParameters
769
+ | NodeParameterValue[]
770
+ | INodeParameters[]
771
+ | object
772
+ | undefined;
773
+ getCurrentNodeParameters(): INodeParameters | undefined;
774
+ getTimezone(): string;
775
+ getRestApiUrl(): string;
776
+ helpers: {
777
+ httpRequest(
778
+ requestOptions: IHttpRequestOptions,
779
+ ): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
780
+ // TODO: Remove from here. Add it only now to LoadOptions as many nodes do import
781
+ // from @fsai-flow/workflow instead of n8n-core
782
+ requestWithAuthentication(
783
+ this: IAllExecuteFunctions,
784
+ credentialsType: string,
785
+ requestOptions: any, // tslint:disable-line:no-any
786
+ additionalCredentialOptions?: IAdditionalCredentialOptions,
787
+ ): Promise<any>;
788
+ httpRequestWithAuthentication(
789
+ this: IAllExecuteFunctions,
790
+ credentialsType: string,
791
+ requestOptions: IHttpRequestOptions,
792
+ additionalCredentialOptions?: IAdditionalCredentialOptions,
793
+ ): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
794
+ [key: string]: ((...args: any[]) => any) | undefined; // tslint:disable-line:no-any
795
+ };
796
+ }
797
+
798
+ export interface IHookFunctions {
799
+ getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined>;
800
+ getMode(): WorkflowExecuteMode;
801
+ getActivationMode(): WorkflowActivateMode;
802
+ getNode(): INode;
803
+ getNodeWebhookUrl: (name: string) => string | undefined;
804
+ getNodeParameter(
805
+ parameterName: string,
806
+ fallbackValue?: any,
807
+ ): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object;
808
+ getTimezone(): string;
809
+ getWebhookDescription(name: string): IWebhookDescription | undefined;
810
+ getWebhookName(): string;
811
+ getWorkflow(): IWorkflowMetadata;
812
+ getWorkflowStaticData(type: string): IDataObject;
813
+ helpers: {
814
+ httpRequest(
815
+ requestOptions: IHttpRequestOptions,
816
+ ): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
817
+ httpRequestWithAuthentication(
818
+ this: IAllExecuteFunctions,
819
+ credentialsType: string,
820
+ requestOptions: IHttpRequestOptions,
821
+ additionalCredentialOptions?: IAdditionalCredentialOptions,
822
+ ): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
823
+ [key: string]: (...args: any[]) => any; // tslint:disable-line:no-any
824
+ };
825
+ }
826
+
827
+ export interface IPollFunctions {
828
+ __emit(data: INodeExecutionData[][]): void;
829
+ getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined>;
830
+ getMode(): WorkflowExecuteMode;
831
+ getActivationMode(): WorkflowActivateMode;
832
+ getNode(): INode;
833
+ getNodeParameter(
834
+ parameterName: string,
835
+ fallbackValue?: any,
836
+ ): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object;
837
+ getRestApiUrl(): string;
838
+ getTimezone(): string;
839
+ getWorkflow(): IWorkflowMetadata;
840
+ getWorkflowStaticData(type: string): IDataObject;
841
+ helpers: {
842
+ httpRequest(
843
+ requestOptions: IHttpRequestOptions,
844
+ ): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
845
+ httpRequestWithAuthentication(
846
+ this: IAllExecuteFunctions,
847
+ credentialsType: string,
848
+ requestOptions: IHttpRequestOptions,
849
+ additionalCredentialOptions?: IAdditionalCredentialOptions,
850
+ ): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
851
+ [key: string]: (...args: any[]) => any; // tslint:disable-line:no-any
852
+ };
853
+ }
854
+
855
+ export interface ITriggerFunctions {
856
+ emit(
857
+ data: INodeExecutionData[][],
858
+ responsePromise?: IDeferredPromise<IExecuteResponsePromiseData>,
859
+ ): void;
860
+ getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined>;
861
+ getMode(): WorkflowExecuteMode;
862
+ getActivationMode(): WorkflowActivateMode;
863
+ getNode(): INode;
864
+ getNodeParameter(
865
+ parameterName: string,
866
+ fallbackValue?: any,
867
+ ): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object;
868
+ getRestApiUrl(): string;
869
+ getTimezone(): string;
870
+ getWorkflow(): IWorkflowMetadata;
871
+ getWorkflowStaticData(type: string): IDataObject;
872
+ helpers: {
873
+ httpRequest(
874
+ requestOptions: IHttpRequestOptions,
875
+ ): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
876
+ httpRequestWithAuthentication(
877
+ this: IAllExecuteFunctions,
878
+ credentialsType: string,
879
+ requestOptions: IHttpRequestOptions,
880
+ additionalCredentialOptions?: IAdditionalCredentialOptions,
881
+ ): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
882
+ [key: string]: (...args: any[]) => any; // tslint:disable-line:no-any
883
+ };
884
+ }
885
+
886
+
887
+ export type ResourceLocatorModes = 'id' | 'url' | 'list' | string;
888
+ export interface INodeParameterResourceLocator {
889
+ __rl: true;
890
+ mode: ResourceLocatorModes;
891
+ value: NodeParameterValue;
892
+ cachedResultName?: string;
893
+ cachedResultUrl?: string;
894
+ __regex?: string;
895
+ }
896
+
897
+ export interface ResourceMapperField {
898
+ id: string;
899
+ displayName: string;
900
+ defaultMatch: boolean;
901
+ canBeUsedToMatch?: boolean;
902
+ required: boolean;
903
+ display: boolean;
904
+ type?: FieldType;
905
+ removed?: boolean;
906
+ options?: INodePropertyOptions[];
907
+ readOnly?: boolean;
908
+ }
909
+
910
+ export interface IDataObject {
911
+ [key: string]: GenericValue | IDataObject | GenericValue[] | IDataObject[];
912
+ }
913
+
914
+ export type ResourceMapperValue = {
915
+ mappingMode: string;
916
+ value: { [key: string]: string | number | boolean | null } | null;
917
+ matchingColumns: string[];
918
+ schema: ResourceMapperField[];
919
+ attemptToConvertTypes: boolean;
920
+ convertFieldsToString: boolean;
921
+ };
922
+
923
+ export type FilterOperatorType =
924
+ | 'string'
925
+ | 'number'
926
+ | 'boolean'
927
+ | 'array'
928
+ | 'object'
929
+ | 'dateTime'
930
+ | 'any';
931
+
932
+ export interface FilterOperatorValue {
933
+ type: FilterOperatorType;
934
+ operation: string;
935
+ rightType?: FilterOperatorType;
936
+ singleValue?: boolean; // default = false
937
+ }
938
+
939
+ export type FilterOptionsValue = {
940
+ caseSensitive: boolean;
941
+ leftValue: string;
942
+ typeValidation: 'strict' | 'loose';
943
+ version: 1 | 2;
944
+ };
945
+
946
+ export type FilterConditionValue = {
947
+ id: string;
948
+ leftValue: NodeParameterValue | NodeParameterValue[];
949
+ operator: FilterOperatorValue;
950
+ rightValue: NodeParameterValue | NodeParameterValue[];
951
+ };
952
+
953
+ export type FilterTypeCombinator = 'and' | 'or';
954
+
955
+ export type FilterValue = {
956
+ options: FilterOptionsValue;
957
+ conditions: FilterConditionValue[];
958
+ combinator: FilterTypeCombinator;
959
+ };
960
+
961
+ export type AssignmentValue = {
962
+ id: string;
963
+ name: string;
964
+ value: NodeParameterValue;
965
+ type?: string;
966
+ };
967
+
968
+
969
+ export type AssignmentCollectionValue = {
970
+ assignments: AssignmentValue[];
971
+ };
972
+
973
+ export type NodeParameterValueType =
974
+ // TODO: Later also has to be possible to add multiple ones with the name name. So array has to be possible
975
+ | NodeParameterValue
976
+ | INodeParameters
977
+ | INodeParameterResourceLocator
978
+ | ResourceMapperValue
979
+ | FilterValue
980
+ | AssignmentCollectionValue
981
+ | NodeParameterValue[]
982
+ | INodeParameters[]
983
+ | INodeParameterResourceLocator[]
984
+ | ResourceMapperValue[];
985
+
986
+ interface NodeHelperFunctions {
987
+ copyBinaryFile(filePath: string, fileName: string, mimeType?: string): Promise<IBinaryData>;
988
+ }
989
+
990
+ export interface IWebhookFunctions {
991
+ logger: Logger;
992
+ getBodyData(): IDataObject;
993
+ getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined>;
994
+ getHeaderData(): object;
995
+ getMode(): WorkflowExecuteMode;
996
+ getNode(): INode;
997
+ getNodeParameter(
998
+ parameterName: string,
999
+ fallbackValue?: any,
1000
+ options?: IGetNodeParameterOptions,
1001
+ ): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object;
1002
+ evaluateExpression(expression: string, itemIndex?: number): NodeParameterValueType;
1003
+ getNodeWebhookUrl: (name: string) => string | undefined;
1004
+ getParamsData(): object;
1005
+ getQueryData(): object;
1006
+ getRequestObject(): express.Request;
1007
+ getResponseObject(): express.Response;
1008
+ getParentNodes(nodeName: string): NodeTypeAndVersion[];
1009
+ getInstanceId(): string;
1010
+ getTimezone(): string;
1011
+ getWebhookName(): string;
1012
+ getWorkflowStaticData(type: string): IDataObject;
1013
+ getWorkflow(): IWorkflowMetadata;
1014
+ getChildNodes(
1015
+ nodeName: string,
1016
+ options?: { includeNodeParameters?: boolean },
1017
+ ): NodeTypeAndVersion[];
1018
+ prepareOutputData(
1019
+ outputData: INodeExecutionData[],
1020
+ outputIndex?: number,
1021
+ ): Promise<INodeExecutionData[][]>;
1022
+ nodeHelpers: NodeHelperFunctions;
1023
+ helpers: {
1024
+ httpRequest(
1025
+ requestOptions: IHttpRequestOptions,
1026
+ ): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
1027
+ httpRequestWithAuthentication(
1028
+ this: IAllExecuteFunctions,
1029
+ credentialsType: string,
1030
+ requestOptions: IHttpRequestOptions,
1031
+ additionalCredentialOptions?: IAdditionalCredentialOptions,
1032
+ ): Promise<IN8nHttpResponse | IN8nHttpFullResponse>;
1033
+ [key: string]: (...args: any[]) => any; // tslint:disable-line:no-any
1034
+ };
1035
+ addInputData(
1036
+ data: INodeExecutionData[][] | ExecutionError,
1037
+ node?: INode,
1038
+ ): { index: number, inputExecutionData: IRunExecutionData };
1039
+ addOutputData(
1040
+ data: INodeExecutionData[][] | ExecutionError,
1041
+ node?: INode,
1042
+ ): { outputExecutionData: IRunExecutionData };
1043
+ logAiEvent(event: AiEvent, data?: string): void;
1044
+ }
1045
+
1046
+ export interface INodeCredentialsDetails {
1047
+ id: string | null;
1048
+ name: string;
1049
+ }
1050
+
1051
+ export interface INodeCredentials {
1052
+ [key: string]: INodeCredentialsDetails;
1053
+ }
1054
+ export type OnError = 'continueErrorOutput' | 'continueRegularOutput' | 'stopWorkflow';
1055
+ export interface INode {
1056
+ id: string;
1057
+ name: string;
1058
+ typeVersion: number | number[];
1059
+ type: string;
1060
+ position: [number, number];
1061
+ disabled?: boolean;
1062
+ notes?: string;
1063
+ notesInFlow?: boolean;
1064
+ retryOnFail?: boolean;
1065
+ maxTries?: number;
1066
+ waitBetweenTries?: number;
1067
+ alwaysOutputData?: boolean;
1068
+ executeOnce?: boolean;
1069
+ onError?: OnError;
1070
+ continueOnFail?: boolean;
1071
+ parameters: INodeParameters;
1072
+ credentials?: INodeCredentials;
1073
+ webhookId?: string;
1074
+ extendsCredential?: string;
1075
+ rewireOutputLogTo?: NodeConnectionType;
1076
+ }
1077
+
1078
+ export interface INodes {
1079
+ [key: string]: INode;
1080
+ }
1081
+
1082
+ export interface IObservableObject {
1083
+ [key: string]: any;
1084
+ __dataChanged: boolean;
1085
+ }
1086
+
1087
+ export interface IBinaryKeyData {
1088
+ [key: string]: IBinaryData;
1089
+ }
1090
+
1091
+ export interface INodeExecutionData {
1092
+ [key: string]: IDataObject | IBinaryKeyData | NodeApiError | NodeOperationError | undefined;
1093
+ json: IDataObject;
1094
+ binary?: IBinaryKeyData;
1095
+ error?: NodeApiError | NodeOperationError;
1096
+ }
1097
+
1098
+ export interface INodeExecuteFunctions {
1099
+ getExecutePollFunctions: IGetExecutePollFunctions;
1100
+ getExecuteTriggerFunctions: IGetExecuteTriggerFunctions;
1101
+ getExecuteFunctions: IGetExecuteFunctions;
1102
+ getExecuteSingleFunctions: IGetExecuteSingleFunctions;
1103
+ getExecuteHookFunctions: IGetExecuteHookFunctions;
1104
+ getExecuteWebhookFunctions: IGetExecuteWebhookFunctions;
1105
+ }
1106
+
1107
+ // The values a node property can have
1108
+ export type NodeParameterValue = string | number | boolean | undefined | null;
1109
+
1110
+ export interface INodeParameters {
1111
+ // TODO: Later also has to be possible to add multiple ones with the name name. So array has to be possible
1112
+ [key: string]: NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[];
1113
+ }
1114
+
1115
+ export type NodePropertyTypes =
1116
+ | 'boolean'
1117
+ | 'button'
1118
+ | 'collection'
1119
+ | 'color'
1120
+ | 'dateTime'
1121
+ | 'fixedCollection'
1122
+ | 'hidden'
1123
+ | 'json'
1124
+ | 'notice'
1125
+ | 'multiOptions'
1126
+ | 'number'
1127
+ | 'options'
1128
+ | 'string'
1129
+ | 'credentialsSelect'
1130
+ | 'resourceLocator'
1131
+ | 'curlImport'
1132
+ | 'resourceMapper'
1133
+ | 'filter'
1134
+ | 'assignmentCollection'
1135
+ | 'credentials'
1136
+ | 'workflowSelector';
1137
+
1138
+ export type CodeAutocompleteTypes = 'function' | 'functionItem';
1139
+
1140
+ export type EditorTypes = 'code' | 'json' | 'htmlEditor';
1141
+ export type CodeNodeEditorLanguage = (typeof CODE_LANGUAGES)[number];
1142
+ export type CodeExecutionMode = (typeof CODE_EXECUTION_MODES)[number];
1143
+
1144
+ export interface ILoadOptions {
1145
+ routing?: {
1146
+ operations?: IN8nRequestOperations;
1147
+ output?: INodeRequestOutput;
1148
+ request?: IHttpRequestOptionsFromParameters;
1149
+ };
1150
+ }
1151
+
1152
+ export interface INodePropertyTypeOptions {
1153
+ alwaysOpenEditWindow?: boolean; // Supported by: string
1154
+ codeAutocomplete?: CodeAutocompleteTypes; // Supported by: string
1155
+ editor?: EditorTypes; // Supported by: string
1156
+ loadOptionsDependsOn?: string[]; // Supported by: options
1157
+ loadOptionsMethod?: string; // Supported by: options
1158
+ loadOptions?: ILoadOptions; // Supported by: options
1159
+ maxValue?: number; // Supported by: number
1160
+ minValue?: number; // Supported by: number
1161
+ multipleValues?: boolean; // Supported by: <All>
1162
+ multipleValueButtonText?: string; // Supported when "multipleValues" set to true
1163
+ numberPrecision?: number; // Supported by: number
1164
+ password?: boolean; // Supported by: string
1165
+ rows?: number; // Supported by: string
1166
+ showAlpha?: boolean; // Supported by: color
1167
+ sortable?: boolean; // Supported when "multipleValues" set to true
1168
+ [key: string]: any;
1169
+ }
1170
+
1171
+ export type DisplayCondition =
1172
+ | { _cnd: { eq: NodeParameterValue } }
1173
+ | { _cnd: { not: NodeParameterValue } }
1174
+ | { _cnd: { gte: number | string } }
1175
+ | { _cnd: { lte: number | string } }
1176
+ | { _cnd: { gt: number | string } }
1177
+ | { _cnd: { lt: number | string } }
1178
+ | { _cnd: { between: { from: number | string; to: number | string } } }
1179
+ | { _cnd: { startsWith: string } }
1180
+ | { _cnd: { endsWith: string } }
1181
+ | { _cnd: { includes: string } }
1182
+ | { _cnd: { regex: string } }
1183
+ | { _cnd: { exists: true } };
1184
+
1185
+
1186
+ export interface IDisplayOptions {
1187
+ hide?: {
1188
+ [key: string]: Array<NodeParameterValue | DisplayCondition> | NodeParameterValue[] | undefined;
1189
+ };
1190
+ show?: {
1191
+ [key: string]: Array<NodeParameterValue | DisplayCondition> | NodeParameterValue[] | undefined;
1192
+ };
1193
+ }
1194
+
1195
+ export type FieldTypeMap = {
1196
+ // eslint-disable-next-line id-denylist
1197
+ boolean: boolean;
1198
+ // eslint-disable-next-line id-denylist
1199
+ number: number;
1200
+ // eslint-disable-next-line id-denylist
1201
+ string: string;
1202
+ 'string-alphanumeric': string;
1203
+ dateTime: string;
1204
+ time: string;
1205
+ array: unknown[];
1206
+ object: object;
1207
+ options: any;
1208
+ url: string;
1209
+ jwt: string;
1210
+ 'form-fields': FormFieldsParameter;
1211
+ };
1212
+
1213
+ export type ValidationResult<T extends FieldType = FieldType> =
1214
+ | { valid: false; errorMessage: string }
1215
+ | {
1216
+ valid: true;
1217
+ newValue?: FieldTypeMap[T];
1218
+ };
1219
+
1220
+ export type FieldType = keyof FieldTypeMap;
1221
+
1222
+ export namespace MultiPartFormData {
1223
+ export interface File {
1224
+ filepath: string;
1225
+ mimetype?: string;
1226
+ originalFilename?: string;
1227
+ newFilename: string;
1228
+ size?: number;
1229
+ }
1230
+
1231
+ export type Request = express.Request<
1232
+ {},
1233
+ {},
1234
+ {
1235
+ data: Record<string, string | string[]>;
1236
+ files: Record<string, File | File[]>;
1237
+ }
1238
+ >;
1239
+ }
1240
+
1241
+ export interface IVersionedNodeType {
1242
+ nodeVersions: {
1243
+ [key: number]: INodeType;
1244
+ };
1245
+ currentVersion: number;
1246
+ description: INodeTypeBaseDescription;
1247
+ getNodeType: (version?: number) => INodeType;
1248
+ }
1249
+
1250
+ export interface INodePropertyModeValidation {
1251
+ type: string;
1252
+ properties: {};
1253
+ }
1254
+
1255
+ export interface INodePropertyValueExtractorFunction {
1256
+ (
1257
+ this: IExecuteSingleFunctions,
1258
+ value: string | NodeParameterValue,
1259
+ ): Promise<string | NodeParameterValue> | (string | NodeParameterValue);
1260
+ }
1261
+
1262
+ export interface INodePropertyValueExtractorBase {
1263
+ type: string;
1264
+ }
1265
+
1266
+ export interface INodePropertyValueExtractorRegex extends INodePropertyValueExtractorBase {
1267
+ type: 'regex';
1268
+ regex: string | RegExp;
1269
+ }
1270
+
1271
+ export type INodePropertyValueExtractor = INodePropertyValueExtractorRegex;
1272
+
1273
+ export interface INodePropertyModeTypeOptions {
1274
+ searchListMethod?: string; // Supported by: options
1275
+ searchFilterRequired?: boolean;
1276
+ searchable?: boolean;
1277
+ }
1278
+
1279
+
1280
+ export interface INodePropertyMode {
1281
+ displayName: string;
1282
+ name: string;
1283
+ type: 'string' | 'list';
1284
+ hint?: string;
1285
+ validation?: Array<
1286
+ INodePropertyModeValidation | { (this: IExecuteSingleFunctions, value: string): void }
1287
+ >;
1288
+ placeholder?: string;
1289
+ url?: string;
1290
+ extractValue?: INodePropertyValueExtractor;
1291
+ initType?: string;
1292
+ entryTypes?: {
1293
+ [name: string]: {
1294
+ selectable?: boolean;
1295
+ hidden?: boolean;
1296
+ queryable?: boolean;
1297
+ data?: {
1298
+ request?: IHttpRequestOptions;
1299
+ output?: INodeRequestOutput;
1300
+ };
1301
+ };
1302
+ };
1303
+ search?: INodePropertyRouting;
1304
+ typeOptions?: INodePropertyModeTypeOptions;
1305
+ }
1306
+
1307
+ export interface INodeProperties {
1308
+ displayName: string;
1309
+ name: string;
1310
+ type: NodePropertyTypes;
1311
+ typeOptions?: INodePropertyTypeOptions;
1312
+ default: NodeParameterValue | INodeParameters | INodeParameters[] | NodeParameterValue[];
1313
+ description?: string;
1314
+ hint?: string;
1315
+ displayOptions?: IDisplayOptions;
1316
+ options?: Array<INodePropertyOptions | INodeProperties | INodePropertyCollection>;
1317
+ placeholder?: string;
1318
+ isNodeSetting?: boolean;
1319
+ noDataExpression?: boolean;
1320
+ required?: boolean;
1321
+ routing?: INodePropertyRouting;
1322
+ modes?: INodePropertyMode[];
1323
+ validateType?: FieldType;
1324
+ ignoreValidationDuringExecution?: boolean;
1325
+ disabledOptions?: {
1326
+ show?: {
1327
+ [key: string]: Array<NodeParameterValue | DisplayCondition> | NodeParameterValue[] | undefined;
1328
+ };
1329
+ };
1330
+ }
1331
+ export interface INodePropertyOptions {
1332
+ name: string;
1333
+ value: string | number | boolean;
1334
+ action?: string;
1335
+ description?: string;
1336
+ routing?: INodePropertyRouting;
1337
+ outputConnectionType?: NodeConnectionType;
1338
+ }
1339
+
1340
+ export interface INodePropertyCollection {
1341
+ displayName: string;
1342
+ name: string;
1343
+ values: INodeProperties[];
1344
+ }
1345
+
1346
+ export interface IParameterDependencies {
1347
+ [key: string]: string[];
1348
+ }
1349
+
1350
+ export interface IPollResponse {
1351
+ closeFunction?: () => Promise<void>;
1352
+ }
1353
+
1354
+ export interface ITriggerResponse {
1355
+ closeFunction?: () => Promise<void>;
1356
+ // To manually trigger the run
1357
+ manualTriggerFunction?: () => Promise<void>;
1358
+ // Gets added automatically at manual workflow runs resolves with
1359
+ // the first emitted data
1360
+ manualTriggerResponse?: Promise<INodeExecutionData[][]>;
1361
+ }
1362
+
1363
+ export interface SupplyData {
1364
+ metadata?: IDataObject;
1365
+ response: unknown;
1366
+ closeFunction?: () => Promise<void>;
1367
+ }
1368
+
1369
+ namespace ExecuteFunctions {
1370
+ namespace StringReturning {
1371
+ export type NodeParameter =
1372
+ | 'binaryProperty'
1373
+ | 'binaryPropertyName'
1374
+ | 'binaryPropertyOutput'
1375
+ | 'dataPropertyName'
1376
+ | 'dataBinaryProperty'
1377
+ | 'resource'
1378
+ | 'operation'
1379
+ | 'filePath'
1380
+ | 'encodingType';
1381
+ }
1382
+
1383
+ namespace NumberReturning {
1384
+ export type NodeParameter = 'limit';
1385
+ }
1386
+
1387
+ namespace BooleanReturning {
1388
+ export type NodeParameter =
1389
+ | 'binaryData'
1390
+ | 'download'
1391
+ | 'jsonParameters'
1392
+ | 'returnAll'
1393
+ | 'rawData'
1394
+ | 'resolveData';
1395
+ }
1396
+
1397
+ namespace RecordReturning {
1398
+ export type NodeParameter = 'additionalFields' | 'filters' | 'options' | 'updateFields';
1399
+ }
1400
+
1401
+ export type GetNodeParameterFn = {
1402
+ // @TECH_DEBT: Refactor to remove this barely used overload - N8N-5632
1403
+ getNodeParameter<T extends { resource: string }>(
1404
+ parameterName: 'resource',
1405
+ itemIndex?: number,
1406
+ ): T['resource'];
1407
+
1408
+ getNodeParameter(
1409
+ parameterName: StringReturning.NodeParameter,
1410
+ itemIndex: number,
1411
+ fallbackValue?: string,
1412
+ options?: IGetNodeParameterOptions,
1413
+ ): string;
1414
+ getNodeParameter(
1415
+ parameterName: RecordReturning.NodeParameter,
1416
+ itemIndex: number,
1417
+ fallbackValue?: IDataObject,
1418
+ options?: IGetNodeParameterOptions,
1419
+ ): IDataObject;
1420
+ getNodeParameter(
1421
+ parameterName: BooleanReturning.NodeParameter,
1422
+ itemIndex: number,
1423
+ fallbackValue?: boolean,
1424
+ options?: IGetNodeParameterOptions,
1425
+ ): boolean;
1426
+ getNodeParameter(
1427
+ parameterName: NumberReturning.NodeParameter,
1428
+ itemIndex: number,
1429
+ fallbackValue?: number,
1430
+ options?: IGetNodeParameterOptions,
1431
+ ): number;
1432
+ getNodeParameter(
1433
+ parameterName: string,
1434
+ itemIndex: number,
1435
+ fallbackValue?: any,
1436
+ options?: IGetNodeParameterOptions,
1437
+ ): NodeParameterValueType | object;
1438
+ };
1439
+ }
1440
+
1441
+ export interface INodeListSearchItems extends INodePropertyOptions {
1442
+ icon?: string;
1443
+ url?: string;
1444
+ }
1445
+
1446
+ export interface INodeListSearchResult {
1447
+ results: INodeListSearchItems[];
1448
+ paginationToken?: unknown;
1449
+ }
1450
+
1451
+ export type IWorkflowNodeContext = ExecuteFunctions.GetNodeParameterFn &
1452
+ Pick<FunctionsBase, 'getNode' | 'getWorkflow'>;
1453
+
1454
+ export interface ILocalLoadOptionsFunctions {
1455
+ getWorkflowNodeContext(nodeType: string): Promise<IWorkflowNodeContext | null>;
1456
+ }
1457
+
1458
+ export type LogLevel = (typeof LOG_LEVELS)[number];
1459
+ export type LogMetadata = {
1460
+ [key: string]: unknown;
1461
+ scopes?: unknown[];
1462
+ file?: string;
1463
+ function?: string;
1464
+ };
1465
+ export type Logger = Record<
1466
+ Exclude<LogLevel, 'silent'>,
1467
+ (message: string, metadata?: LogMetadata) => void
1468
+ >;
1469
+
1470
+ export interface FunctionsBase {
1471
+ logger: Logger;
1472
+ getCredentials<T extends object = ICredentialDataDecryptedObject>(
1473
+ type: string,
1474
+ itemIndex?: number,
1475
+ ): Promise<T>;
1476
+ getCredentialsProperties(type: string): INodeProperties[];
1477
+ getExecutionId(): string;
1478
+ getNode(): INode;
1479
+ getWorkflow(): IWorkflowMetadata;
1480
+ getWorkflowStaticData(type: string): IDataObject;
1481
+ getTimezone(): string;
1482
+ getRestApiUrl(): string;
1483
+ getInstanceBaseUrl(): string;
1484
+ getInstanceId(): string;
1485
+ getChildNodes(
1486
+ nodeName: string,
1487
+ options?: { includeNodeParameters?: boolean },
1488
+ ): NodeTypeAndVersion[];
1489
+ getParentNodes(nodeName: string): NodeTypeAndVersion[];
1490
+ getKnownNodeTypes(): IDataObject;
1491
+ getMode?: () => WorkflowExecuteMode;
1492
+ getActivationMode?: () => WorkflowActivateMode;
1493
+
1494
+ /** @deprecated */
1495
+ prepareOutputData(outputData: INodeExecutionData[]): Promise<INodeExecutionData[][]>;
1496
+ }
1497
+
1498
+ export interface ResourceMapperFields {
1499
+ fields: ResourceMapperField[];
1500
+ emptyFieldsNotice?: string;
1501
+ }
1502
+
1503
+ export interface INodeType {
1504
+ description: INodeTypeDescription;
1505
+ supplyData?(this: ISupplyDataFunctions | IWebhookFunctions, itemIndex: number): Promise<SupplyData>;
1506
+ execute?(this: IExecuteFunctions): Promise<INodeExecutionData[][] | null>;
1507
+ executeSingle?(this: IExecuteSingleFunctions): Promise<INodeExecutionData>;
1508
+ poll?(this: IPollFunctions): Promise<INodeExecutionData[][] | null>;
1509
+ trigger?(this: ITriggerFunctions): Promise<ITriggerResponse | undefined>;
1510
+ webhook?(this: IWebhookFunctions, workflow?: Workflow): Promise<IWebhookResponseData>;
1511
+ hooks?: {
1512
+ [key: string]: (this: IHookFunctions) => Promise<boolean>;
1513
+ };
1514
+ methods?: {
1515
+ loadOptions?: {
1516
+ [key: string]: (this: ILoadOptionsFunctions) => Promise<INodePropertyOptions[]>;
1517
+ };
1518
+ listSearch?: {
1519
+ [key: string]: (
1520
+ this: ILoadOptionsFunctions,
1521
+ filter?: string,
1522
+ paginationToken?: string,
1523
+ ) => Promise<INodeListSearchResult>;
1524
+ };
1525
+ credentialTest?: {
1526
+ // Contains a group of functins that test credentials.
1527
+ [functionName: string]: ICredentialTestFunction;
1528
+ };
1529
+ resourceMapping?: {
1530
+ [functionName: string]: (this: ILoadOptionsFunctions) => Promise<ResourceMapperFields>;
1531
+ };
1532
+ localResourceMapping?: {
1533
+ [functionName: string]: (this: ILocalLoadOptionsFunctions) => Promise<ResourceMapperFields>;
1534
+ };
1535
+ actionHandler?: {
1536
+ [functionName: string]: (
1537
+ this: ILoadOptionsFunctions,
1538
+ payload: IDataObject | string | undefined,
1539
+ ) => Promise<NodeParameterValueType>;
1540
+ };
1541
+ };
1542
+ webhookMethods?: {
1543
+ [key: string]: IWebhookSetupMethods;
1544
+ };
1545
+ }
1546
+
1547
+ export interface INodeVersionedType {
1548
+ nodeVersions: {
1549
+ [key: number]: INodeType;
1550
+ };
1551
+ currentVersion: number;
1552
+ description: INodeTypeBaseDescription;
1553
+ getNodeType: (version?: number) => INodeType;
1554
+ }
1555
+ export interface INodeCredentialTestResult {
1556
+ status: 'OK' | 'Error';
1557
+ message: string;
1558
+ }
1559
+
1560
+ export interface INodeCredentialTestRequest {
1561
+ nodeToTestWith?: string; // node name i.e. slack
1562
+ credentials: ICredentialsDecrypted;
1563
+ }
1564
+
1565
+ export type WebhookSetupMethodNames = 'checkExists' | 'create' | 'delete';
1566
+
1567
+ export interface IWebhookSetupMethods {
1568
+ [key: string]: ((this: IHookFunctions) => Promise<boolean>) | undefined;
1569
+ checkExists?: (this: IHookFunctions) => Promise<boolean>;
1570
+ create?: (this: IHookFunctions) => Promise<boolean>;
1571
+ delete?: (this: IHookFunctions) => Promise<boolean>;
1572
+ }
1573
+
1574
+ export interface INodeCredentialDescription {
1575
+ name: string;
1576
+ required?: boolean;
1577
+ displayOptions?: IDisplayOptions;
1578
+ testedBy?: ICredentialTestRequest | string; // Name of a function inside `loadOptions.credentialTest`
1579
+ }
1580
+
1581
+ export type FormFieldsParameter = Array<{
1582
+ fieldLabel: string;
1583
+ elementName?: string;
1584
+ fieldType?: string;
1585
+ requiredField?: boolean;
1586
+ fieldOptions?: { values: Array<{ option: string }> };
1587
+ multiselect?: boolean;
1588
+ multipleFiles?: boolean;
1589
+ acceptFileTypes?: string;
1590
+ formatDate?: string;
1591
+ html?: string;
1592
+ placeholder?: string;
1593
+ fieldName?: string;
1594
+ fieldValue?: string;
1595
+ }>;
1596
+
1597
+ export const NodeConnectionTypes = {
1598
+ AiAgent: 'ai_agent',
1599
+ AiChain: 'ai_chain',
1600
+ AiDocument: 'ai_document',
1601
+ AiEmbedding: 'ai_embedding',
1602
+ AiLanguageModel: 'ai_languageModel',
1603
+ AiMemory: 'ai_memory',
1604
+ AiOutputParser: 'ai_outputParser',
1605
+ AiRetriever: 'ai_retriever',
1606
+ AiTextSplitter: 'ai_textSplitter',
1607
+ AiTool: 'ai_tool',
1608
+ AiVectorStore: 'ai_vectorStore',
1609
+ Main: 'main',
1610
+ } as const;
1611
+
1612
+ export type NodeConnectionType = (typeof NodeConnectionTypes)[keyof typeof NodeConnectionTypes];
1613
+
1614
+ export type INodeIssueTypes = 'credentials' | 'execution' | 'parameters' | 'typeUnknown';
1615
+
1616
+ export interface INodeIssueObjectProperty {
1617
+ [key: string]: string[];
1618
+ }
1619
+
1620
+ export interface INodeIssueData {
1621
+ node: string;
1622
+ type: INodeIssueTypes;
1623
+ value: boolean | string | string[] | INodeIssueObjectProperty;
1624
+ }
1625
+
1626
+ export interface INodeIssues {
1627
+ execution?: boolean;
1628
+ credentials?: INodeIssueObjectProperty;
1629
+ parameters?: INodeIssueObjectProperty;
1630
+ typeUnknown?: boolean;
1631
+ [key: string]: undefined | boolean | INodeIssueObjectProperty;
1632
+ }
1633
+
1634
+ export interface IWorfklowIssues {
1635
+ [key: string]: INodeIssues;
1636
+ }
1637
+
1638
+ export type ThemeIconColor =
1639
+ | 'gray'
1640
+ | 'black'
1641
+ | 'blue'
1642
+ | 'light-blue'
1643
+ | 'dark-blue'
1644
+ | 'orange'
1645
+ | 'orange-red'
1646
+ | 'pink-red'
1647
+ | 'red'
1648
+ | 'light-green'
1649
+ | 'green'
1650
+ | 'dark-green'
1651
+ | 'azure'
1652
+ | 'purple'
1653
+ | 'crimson';
1654
+
1655
+ export type Themed<T> = T | { light: T; dark: T };
1656
+
1657
+ export interface INodeTypeBaseDescription {
1658
+ displayName: string;
1659
+ name: string;
1660
+ icon?: string | Icon;
1661
+ iconColor?: ThemeIconColor;
1662
+ iconUrl?: Themed<string>;
1663
+ group: string[];
1664
+ description: string;
1665
+ documentationUrl?: string;
1666
+ subtitle?: string;
1667
+ defaultVersion?: number;
1668
+ codex?: CodexData;
1669
+ }
1670
+
1671
+ export interface INodePropertyRouting {
1672
+ operations?: IN8nRequestOperations; // Should be changed, does not sound right
1673
+ output?: INodeRequestOutput;
1674
+ request?: IHttpRequestOptionsFromParameters;
1675
+ send?: INodeRequestSend;
1676
+ }
1677
+
1678
+ export interface IPostReceiveBase {
1679
+ type: string;
1680
+ enabled?: boolean | string;
1681
+ properties: {
1682
+ [key: string]: string | number | boolean | IDataObject;
1683
+ };
1684
+ errorMessage?: string;
1685
+ }
1686
+
1687
+ export interface IPostReceiveFilter extends IPostReceiveBase {
1688
+ type: 'filter';
1689
+ properties: {
1690
+ pass: boolean | string;
1691
+ };
1692
+ }
1693
+
1694
+ export interface IPostReceiveLimit extends IPostReceiveBase {
1695
+ type: 'limit';
1696
+ properties: {
1697
+ maxResults: number | string;
1698
+ };
1699
+ }
1700
+
1701
+ export type PostReceiveAction =
1702
+ | ((
1703
+ this: IExecuteSingleFunctions,
1704
+ items: INodeExecutionData[],
1705
+ response: IN8nHttpFullResponse,
1706
+ ) => Promise<INodeExecutionData[]>)
1707
+ | IPostReceiveBinaryData
1708
+ | IPostReceiveFilter
1709
+ | IPostReceiveLimit
1710
+ | IPostReceiveRootProperty
1711
+ | IPostReceiveSet
1712
+ | IPostReceiveSetKeyValue
1713
+ | IPostReceiveSort;
1714
+
1715
+ export type PreSendAction = (
1716
+ this: IExecuteSingleFunctions,
1717
+ requestOptions: IHttpRequestOptions,
1718
+ ) => Promise<IHttpRequestOptions>;
1719
+
1720
+ export interface INodeRequestOutput {
1721
+ maxResults?: number | string;
1722
+ postReceive?: PostReceiveAction[];
1723
+ }
1724
+
1725
+ export interface INodeRequestSend {
1726
+ preSend?: PreSendAction[];
1727
+ paginate?: boolean | string; // Where should this life?
1728
+ property?: string; // Maybe: propertyName, destinationProperty?
1729
+ propertyInDotNotation?: boolean; // Enabled by default
1730
+ type?: 'body' | 'query';
1731
+ value?: string;
1732
+ }
1733
+
1734
+ export interface IPostReceiveBinaryData extends IPostReceiveBase {
1735
+ type: 'binaryData';
1736
+ properties: {
1737
+ destinationProperty: string;
1738
+ };
1739
+ }
1740
+
1741
+ export interface IPostReceiveRootProperty extends IPostReceiveBase {
1742
+ type: 'rootProperty';
1743
+ properties: {
1744
+ property: string;
1745
+ };
1746
+ }
1747
+
1748
+ export interface IPostReceiveSet extends IPostReceiveBase {
1749
+ type: 'set';
1750
+ properties: {
1751
+ value: string;
1752
+ };
1753
+ }
1754
+
1755
+ export interface IPostReceiveSetKeyValue extends IPostReceiveBase {
1756
+ type: 'setKeyValue';
1757
+ properties: {
1758
+ [key: string]: string | number;
1759
+ };
1760
+ }
1761
+
1762
+ export interface IPostReceiveSort extends IPostReceiveBase {
1763
+ type: 'sort';
1764
+ properties: {
1765
+ key: string;
1766
+ };
1767
+ }
1768
+
1769
+ export interface IHttpRequestOptionsFromParameters extends Partial<IHttpRequestOptions> {
1770
+ url?: string;
1771
+ }
1772
+
1773
+ export interface IRequestOptionsFromParameters {
1774
+ maxResults?: number | string;
1775
+ options: IHttpRequestOptionsFromParameters;
1776
+ paginate?: boolean | string;
1777
+ preSend: PreSendAction[];
1778
+ postReceive: Array<{
1779
+ data: {
1780
+ parameterValue: string | IDataObject | undefined;
1781
+ };
1782
+ actions: PostReceiveAction[];
1783
+ }>;
1784
+ requestOperations?: IN8nRequestOperations;
1785
+ }
1786
+
1787
+ export type TriggerPanelDefinition = {
1788
+ hideContent?: boolean | string;
1789
+ header?: string;
1790
+ executionsHelp?: string | { active: string; inactive: string };
1791
+ activationHint?: string | { active: string; inactive: string };
1792
+ };
1793
+
1794
+
1795
+ export type ExpressionString = `={{${string}}}`;
1796
+
1797
+ export interface INodeTypeDescription extends INodeTypeBaseDescription {
1798
+ version: number | number[];
1799
+ defaults: INodeParameters;
1800
+ triggerPanel?: TriggerPanelDefinition | boolean;
1801
+ eventTriggerDescription?: string;
1802
+ activationMessage?: string;
1803
+ inputs: Array<NodeConnectionType | INodeInputConfiguration>;
1804
+ inputNames?: string[];
1805
+ outputs: Array<NodeConnectionType | INodeOutputConfiguration>;
1806
+ outputNames?: string[];
1807
+ properties: INodeProperties[];
1808
+ credentials?: INodeCredentialDescription[];
1809
+ maxNodes?: number; // How many nodes of that type can be created in a workflow
1810
+ polling?: boolean;
1811
+ requestDefaults?: IHttpRequestOptionsFromParameters;
1812
+ requestOperations?: IN8nRequestOperations;
1813
+ hooks?: {
1814
+ [key: string]: INodeHookDescription[] | undefined;
1815
+ activate?: INodeHookDescription[];
1816
+ deactivate?: INodeHookDescription[];
1817
+ };
1818
+ webhooks?: IWebhookDescription[];
1819
+ translation?: { [key: string]: object };
1820
+ supportsCORS?: true | undefined;
1821
+ __loadOptionsMethods?: string[]; // only for validation during build
1822
+ }
1823
+
1824
+ export interface INodeHookDescription {
1825
+ method: string;
1826
+ }
1827
+
1828
+ export interface IWebhookData {
1829
+ httpMethod: WebhookHttpMethod;
1830
+ node: string;
1831
+ path: string;
1832
+ webhookDescription: IWebhookDescription;
1833
+ workflowId: string;
1834
+ workflowExecuteAdditionalData: IWorkflowExecuteAdditionalData;
1835
+ webhookId?: string;
1836
+ }
1837
+
1838
+ export interface IWebhookDescription {
1839
+ [key: string]: WebhookHttpMethod | WebhookResponseMode | boolean | string | undefined;
1840
+ httpMethod: WebhookHttpMethod | string;
1841
+ isFullPath?: boolean;
1842
+ name: string;
1843
+ path: string;
1844
+ responseBinaryPropertyName?: string;
1845
+ responseContentType?: string;
1846
+ responsePropertyName?: string;
1847
+ responseMode?: WebhookResponseMode | string;
1848
+ responseData?: WebhookResponseData | string;
1849
+ restartWebhook?: boolean;
1850
+ }
1851
+
1852
+ export interface IWorkflowDataProxyData {
1853
+ [key: string]: any;
1854
+ $binary: any;
1855
+ $data: any;
1856
+ $env: any;
1857
+ $evaluateExpression: any;
1858
+ $item: any;
1859
+ $items: any;
1860
+ $json: any;
1861
+ $node: any;
1862
+ $parameter: any;
1863
+ $position: any;
1864
+ $workflow: any;
1865
+ $: any;
1866
+ $input: any;
1867
+ $thisItem: any;
1868
+ $thisRunIndex: number;
1869
+ $thisItemIndex: number;
1870
+ $now: any;
1871
+ $today: any;
1872
+ }
1873
+
1874
+ export type IWorkflowDataProxyAdditionalKeys = IDataObject;
1875
+
1876
+ export interface IWorkflowMetadata {
1877
+ id?: number | string;
1878
+ name?: string;
1879
+ active: boolean;
1880
+ }
1881
+
1882
+ export type WebhookHttpMethod = 'DELETE' | 'GET' | 'HEAD' | 'PATCH' | 'POST' | 'PUT' | 'OPTIONS';
1883
+
1884
+ export interface IWebhookResponseData {
1885
+ workflowData?: INodeExecutionData[][];
1886
+ webhookResponse?: any;
1887
+ noWebhookResponse?: boolean;
1888
+ }
1889
+
1890
+ export type WebhookResponseData = 'allEntries' | 'firstEntryJson' | 'firstEntryBinary' | 'noData';
1891
+ export type WebhookResponseMode = 'onReceived' | 'lastNode';
1892
+
1893
+ export interface INodeTypes {
1894
+ nodeTypes: INodeTypeData;
1895
+ init(nodeTypes?: INodeTypeData): Promise<void>;
1896
+ getAll(): Array<INodeType | INodeVersionedType>;
1897
+ getByNameAndVersion(nodeType: string, version?: number | number[]): INodeType | undefined;
1898
+ }
1899
+
1900
+ export interface ICredentialTypeData {
1901
+ [key: string]: {
1902
+ type: ICredentialType;
1903
+ sourcePath: string;
1904
+ };
1905
+ }
1906
+
1907
+ export interface INodeTypeData {
1908
+ [key: string]: {
1909
+ type: INodeType | INodeVersionedType;
1910
+ sourcePath: string;
1911
+ };
1912
+ }
1913
+
1914
+ export interface IRun {
1915
+ data: IRunExecutionData;
1916
+ finished?: boolean;
1917
+ mode: WorkflowExecuteMode;
1918
+ waitTill?: Date;
1919
+ startedAt: Date;
1920
+ stoppedAt?: Date;
1921
+ }
1922
+
1923
+
1924
+ export type EnsureTypeOptions = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'json';
1925
+ export interface IGetNodeParameterOptions {
1926
+ contextNode?: INode;
1927
+ // make sure that returned value would be of specified type, converts it if needed
1928
+ ensureType?: EnsureTypeOptions;
1929
+ // extract value from regex, works only when parameter type is resourceLocator
1930
+ extractValue?: boolean;
1931
+ // get raw value of parameter with unresolved expressions
1932
+ rawExpressions?: boolean;
1933
+ }
1934
+
1935
+ // Contains all the data which is needed to execute a workflow and so also to
1936
+ // start restart it again after it did fail.
1937
+ // The RunData, ExecuteData and WaitForExecution contain often the same data.
1938
+ export interface IRunExecutionData {
1939
+ startData?: {
1940
+ destinationNode?: string;
1941
+ runNodeFilter?: string[];
1942
+ };
1943
+ resultData: {
1944
+ error?: ExecutionError;
1945
+ runData: IRunData;
1946
+ lastNodeExecuted?: string;
1947
+ };
1948
+ executionData?: {
1949
+ contextData: IExecuteContextData;
1950
+ nodeExecutionStack: IExecuteData[];
1951
+ waitingExecution: IWaitingForExecution;
1952
+ };
1953
+ waitTill?: Date;
1954
+ }
1955
+
1956
+ export interface IRunData {
1957
+ // node-name: result-data
1958
+ [key: string]: ITaskData[];
1959
+ }
1960
+
1961
+ // The data that gets returned when a node runs
1962
+ export interface ITaskData {
1963
+ startTime: number;
1964
+ executionTime: number;
1965
+ data?: ITaskDataConnections;
1966
+ error?: ExecutionError;
1967
+ }
1968
+
1969
+ // The data for al the different kind of connectons (like main) and all the indexes
1970
+ export interface ITaskDataConnections {
1971
+ // Key for each input type and because there can be multiple inputs of the same type it is an array
1972
+ // null is also allowed because if we still need data for a later while executing the workflow set teompoary to null
1973
+ // the nodes get as input TaskDataConnections which is identical to this one except that no null is allowed.
1974
+ [key: string]: Array<INodeExecutionData[] | null>;
1975
+ }
1976
+
1977
+ // Keeps data while workflow gets executed and allows when provided to restart execution
1978
+ export interface IWaitingForExecution {
1979
+ // Node name
1980
+ [key: string]: {
1981
+ // Run index
1982
+ [key: number]: ITaskDataConnections;
1983
+ };
1984
+ }
1985
+
1986
+ export interface IWorkflowBase {
1987
+ id?: number | string | any;
1988
+ name: string;
1989
+ active: boolean;
1990
+ createdAt: Date;
1991
+ updatedAt: Date;
1992
+ nodes: INode[];
1993
+ connections: IConnections;
1994
+ settings?: IWorkflowSettings;
1995
+ staticData?: IDataObject;
1996
+ }
1997
+
1998
+ export interface IWorkflowCredentials {
1999
+ [credentialType: string]: {
2000
+ [id: string]: ICredentialsEncrypted;
2001
+ };
2002
+ }
2003
+
2004
+ export interface IWorkflowExecuteHooks {
2005
+ [key: string]: Array<(...args: any[]) => Promise<void>> | undefined;
2006
+ nodeExecuteAfter?: Array<
2007
+ (nodeName: string, data: ITaskData, executionData: IRunExecutionData) => Promise<void>
2008
+ >;
2009
+ nodeExecuteBefore?: Array<(nodeName: string) => Promise<void>>;
2010
+ workflowExecuteAfter?: Array<(data: IRun, newStaticData: IDataObject) => Promise<void>>;
2011
+ workflowExecuteBefore?: Array<(workflow: Workflow, data: IRunExecutionData) => Promise<void>>;
2012
+ sendResponse?: Array<(response: IExecuteResponsePromiseData) => Promise<void>>;
2013
+ }
2014
+
2015
+ export interface IWorkflowExecuteAdditionalData {
2016
+ credentialsHelper: ICredentialsHelper;
2017
+ encryptionKey: string;
2018
+ executeWorkflow: (
2019
+ workflowInfo: IExecuteWorkflowInfo,
2020
+ additionalData: IWorkflowExecuteAdditionalData,
2021
+ inputData?: INodeExecutionData[],
2022
+ parentExecutionId?: string,
2023
+ loadedWorkflowData?: IWorkflowBase,
2024
+ loadedRunData?: any,
2025
+ ) => Promise<any>;
2026
+ // hooks?: IWorkflowExecuteHooks;
2027
+ executionId?: string;
2028
+ hooks?: WorkflowHooks;
2029
+ httpResponse?: express.Response;
2030
+ httpRequest?: express.Request;
2031
+ restApiUrl: string;
2032
+ sendMessageToUI?: (source: string, message: any) => void;
2033
+ timezone: string;
2034
+ webhookBaseUrl: string;
2035
+ webhookWaitingBaseUrl: string;
2036
+ webhookTestBaseUrl: string;
2037
+ currentNodeParameters?: INodeParameters;
2038
+ executionTimeoutTimestamp?: number;
2039
+ userId: string;
2040
+ }
2041
+
2042
+ export type WorkflowExecuteMode =
2043
+ | 'cli'
2044
+ | 'error'
2045
+ | 'integrated'
2046
+ | 'internal'
2047
+ | 'manual'
2048
+ | 'retry'
2049
+ | 'trigger'
2050
+ | 'webhook';
2051
+ export type WorkflowActivateMode = 'init' | 'create' | 'update' | 'activate' | 'manual';
2052
+
2053
+ export interface IWorkflowHooksOptionalParameters {
2054
+ parentProcessMode?: string;
2055
+ retryOf?: string;
2056
+ sessionId?: string;
2057
+ }
2058
+
2059
+ export interface IWorkflowSettings {
2060
+ [key: string]: IDataObject | string | number | boolean | undefined;
2061
+ }
2062
+
2063
+ export type LogTypes = 'debug' | 'verbose' | 'info' | 'warn' | 'error';
2064
+
2065
+ export interface ILogger {
2066
+ log: (type: LogTypes, message: string, meta?: object) => void;
2067
+ debug: (message: string, meta?: object) => void;
2068
+ verbose: (message: string, meta?: object) => void;
2069
+ info: (message: string, meta?: object) => void;
2070
+ warn: (message: string, meta?: object) => void;
2071
+ error: (message: string, meta?: object) => void;
2072
+ }
2073
+
2074
+ export interface IStatusCodeMessages {
2075
+ [key: string]: string;
2076
+ }
2077
+
2078
+ export interface INodeInputFilter {
2079
+ // TODO: Later add more filter options like categories, subcatogries,
2080
+ // regex, allow to exclude certain nodes, ... ?
2081
+ // Potentially change totally after alpha/beta. Is not a breaking change after all.
2082
+ nodes: string[]; // Allowed nodes
2083
+ }
2084
+
2085
+ export interface INodeInputConfiguration {
2086
+ category?: string;
2087
+ displayName?: string;
2088
+ required?: boolean;
2089
+ type: NodeConnectionType;
2090
+ filter?: INodeInputFilter;
2091
+ maxConnections?: number;
2092
+ }
2093
+
2094
+ export interface INodeOutputConfiguration {
2095
+ category?: 'error';
2096
+ displayName?: string;
2097
+ maxConnections?: number;
2098
+ required?: boolean;
2099
+ type: NodeConnectionType;
2100
+ }
2101
+
2102
+ export type NodeLoadingDetails = LoadingDetails;
2103
+
2104
+ export type LoadingDetails = {
2105
+ className: string;
2106
+ sourcePath: string;
2107
+ };
2108
+
2109
+ export type CredentialLoadingDetails = LoadingDetails & {
2110
+ supportedNodes?: string[];
2111
+ extends?: string[];
2112
+ };
2113
+
2114
+ export type DocumentationLink = {
2115
+ url: string;
2116
+ };
2117
+
2118
+ export type KnownNodesAndCredentials = {
2119
+ nodes: Record<string, NodeLoadingDetails>;
2120
+ credentials: Record<string, CredentialLoadingDetails>;
2121
+ };
2122
+
2123
+ export type CodexData = {
2124
+ categories?: string[];
2125
+ subcategories?: { [category: string]: string[] };
2126
+ resources?: {
2127
+ credentialDocumentation?: DocumentationLink[];
2128
+ primaryDocumentation?: DocumentationLink[];
2129
+ };
2130
+ alias?: string[];
2131
+ };
2132
+
2133
+ export type JsonValue = string | number | boolean | null | JsonObject | JsonValue[];
2134
+
2135
+ export type JsonObject = { [key: string]: JsonValue };
2136
+
2137
+ export type AllEntities<M> = M extends { [key: string]: string } ? Entity<M, keyof M> : never;
2138
+
2139
+ export type Entity<M, K> = K extends keyof M ? { resource: K; operation: M[K] } : never;
2140
+
2141
+ export type PropertiesOf<M extends { resource: string; operation: string }> = Array<
2142
+ Omit<INodeProperties, 'displayOptions'> & {
2143
+ displayOptions?: {
2144
+ [key in 'show' | 'hide']?: {
2145
+ resource?: Array<M['resource']>;
2146
+ operation?: Array<M['operation']>;
2147
+ [otherKey: string]: NodeParameterValue[] | undefined;
2148
+ };
2149
+ };
2150
+ }
2151
+ >;
2152
+
2153
+ // Telemetry
2154
+
2155
+ export interface INodesGraph {
2156
+ node_types: string[];
2157
+ node_connections: IDataObject[];
2158
+ nodes: INodesGraphNode;
2159
+ }
2160
+
2161
+ export interface INodesGraphNode {
2162
+ [key: string]: INodeGraphItem;
2163
+ }
2164
+
2165
+ export interface INodeGraphItem {
2166
+ type: string;
2167
+ resource?: string;
2168
+ operation?: string;
2169
+ domain?: string;
2170
+ position: [number, number];
2171
+ mode?: string;
2172
+ }
2173
+
2174
+ export interface INodeNameIndex {
2175
+ [name: string]: string;
2176
+ }
2177
+
2178
+ export interface INodesGraphResult {
2179
+ nodeGraph: INodesGraph;
2180
+ nameIndices: INodeNameIndex;
2181
+ }
2182
+
2183
+ export interface ITelemetryClientConfig {
2184
+ url: string;
2185
+ key: string;
2186
+ }
2187
+
2188
+ export interface ITelemetrySettings {
2189
+ enabled: boolean;
2190
+ config?: ITelemetryClientConfig;
2191
+ }
2192
+ export interface ISourceData {
2193
+ previousNode: string;
2194
+ previousNodeOutput?: number; // If undefined "0" gets used
2195
+ previousNodeRun?: number; // If undefined "0" gets used
2196
+ }
2197
+ export interface IPairedItemData {
2198
+ item: number;
2199
+ input?: number; // If undefined "0" gets used
2200
+ sourceOverwrite?: ISourceData;
2201
+ }
2202
+
2203
+ export type CloseFunction = () => Promise<void>;
2204
+
2205
+ export interface SupplyData {
2206
+ metadata?: IDataObject;
2207
+ response: unknown;
2208
+ closeFunction?: CloseFunction;
2209
+ }
2210
+
2211
+ type FunctionsBaseWithRequiredKeys<Keys extends keyof FunctionsBase> = FunctionsBase & {
2212
+ [K in Keys]: NonNullable<FunctionsBase[K]>;
2213
+ };
2214
+
2215
+ export type AiEvent =
2216
+ | 'ai-messages-retrieved-from-memory'
2217
+ | 'ai-message-added-to-memory'
2218
+ | 'ai-output-parsed'
2219
+ | 'ai-documents-retrieved'
2220
+ | 'ai-document-embedded'
2221
+ | 'ai-query-embedded'
2222
+ | 'ai-document-processed'
2223
+ | 'ai-text-split'
2224
+ | 'ai-tool-called'
2225
+ | 'ai-vector-store-searched'
2226
+ | 'ai-llm-generated-output'
2227
+ | 'ai-llm-errored'
2228
+ | 'ai-vector-store-populated'
2229
+ | 'ai-vector-store-updated';