@fsai-flow/core 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.
- package/README.md +11 -0
- package/dist/README.md +11 -0
- package/dist/package.json +44 -0
- package/dist/src/index.d.ts +15 -0
- package/dist/src/index.js +29 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib/ActiveWebhooks.d.ts +59 -0
- package/dist/src/lib/ActiveWebhooks.js +184 -0
- package/dist/src/lib/ActiveWebhooks.js.map +1 -0
- package/dist/src/lib/ActiveWorkflows.d.ts +58 -0
- package/dist/src/lib/ActiveWorkflows.js +244 -0
- package/dist/src/lib/ActiveWorkflows.js.map +1 -0
- package/dist/src/lib/BinaryDataManager/FileSystem.d.ts +26 -0
- package/dist/src/lib/BinaryDataManager/FileSystem.js +179 -0
- package/dist/src/lib/BinaryDataManager/FileSystem.js.map +1 -0
- package/dist/src/lib/BinaryDataManager/index.d.ts +21 -0
- package/dist/src/lib/BinaryDataManager/index.js +146 -0
- package/dist/src/lib/BinaryDataManager/index.js.map +1 -0
- package/dist/src/lib/ChangeCase.d.ts +9 -0
- package/dist/src/lib/ChangeCase.js +43 -0
- package/dist/src/lib/ChangeCase.js.map +1 -0
- package/dist/src/lib/Constants.d.ts +14 -0
- package/dist/src/lib/Constants.js +19 -0
- package/dist/src/lib/Constants.js.map +1 -0
- package/dist/src/lib/Credentials.d.ts +27 -0
- package/dist/src/lib/Credentials.js +89 -0
- package/dist/src/lib/Credentials.js.map +1 -0
- package/dist/src/lib/FileSystem.d.ts +26 -0
- package/dist/src/lib/FileSystem.js +179 -0
- package/dist/src/lib/FileSystem.js.map +1 -0
- package/dist/src/lib/InputConnectionDataLegacy.d.ts +2 -0
- package/dist/src/lib/InputConnectionDataLegacy.js +79 -0
- package/dist/src/lib/InputConnectionDataLegacy.js.map +1 -0
- package/dist/src/lib/Interfaces.d.ts +148 -0
- package/dist/src/lib/Interfaces.js +3 -0
- package/dist/src/lib/Interfaces.js.map +1 -0
- package/dist/src/lib/LoadNodeParameterOptions.d.ts +39 -0
- package/dist/src/lib/LoadNodeParameterOptions.js +150 -0
- package/dist/src/lib/LoadNodeParameterOptions.js.map +1 -0
- package/dist/src/lib/NodeExecuteFunctions.d.ts +226 -0
- package/dist/src/lib/NodeExecuteFunctions.js +2483 -0
- package/dist/src/lib/NodeExecuteFunctions.js.map +1 -0
- package/dist/src/lib/NodesLoader/constants.d.ts +5 -0
- package/dist/src/lib/NodesLoader/constants.js +106 -0
- package/dist/src/lib/NodesLoader/constants.js.map +1 -0
- package/dist/src/lib/NodesLoader/custom-directory-loader.d.ts +9 -0
- package/dist/src/lib/NodesLoader/custom-directory-loader.js +36 -0
- package/dist/src/lib/NodesLoader/custom-directory-loader.js.map +1 -0
- package/dist/src/lib/NodesLoader/directory-loader.d.ts +66 -0
- package/dist/src/lib/NodesLoader/directory-loader.js +325 -0
- package/dist/src/lib/NodesLoader/directory-loader.js.map +1 -0
- package/dist/src/lib/NodesLoader/index.d.ts +5 -0
- package/dist/src/lib/NodesLoader/index.js +12 -0
- package/dist/src/lib/NodesLoader/index.js.map +1 -0
- package/dist/src/lib/NodesLoader/lazy-package-directory-loader.d.ts +7 -0
- package/dist/src/lib/NodesLoader/lazy-package-directory-loader.js +52 -0
- package/dist/src/lib/NodesLoader/lazy-package-directory-loader.js.map +1 -0
- package/dist/src/lib/NodesLoader/load-class-in-isolation.d.ts +1 -0
- package/dist/src/lib/NodesLoader/load-class-in-isolation.js +22 -0
- package/dist/src/lib/NodesLoader/load-class-in-isolation.js.map +1 -0
- package/dist/src/lib/NodesLoader/package-directory-loader.d.ts +17 -0
- package/dist/src/lib/NodesLoader/package-directory-loader.js +100 -0
- package/dist/src/lib/NodesLoader/package-directory-loader.js.map +1 -0
- package/dist/src/lib/NodesLoader/types.d.ts +14 -0
- package/dist/src/lib/NodesLoader/types.js +3 -0
- package/dist/src/lib/NodesLoader/types.js.map +1 -0
- package/dist/src/lib/UserSettings.d.ts +80 -0
- package/dist/src/lib/UserSettings.js +261 -0
- package/dist/src/lib/UserSettings.js.map +1 -0
- package/dist/src/lib/WorkflowExecute.d.ts +53 -0
- package/dist/src/lib/WorkflowExecute.js +835 -0
- package/dist/src/lib/WorkflowExecute.js.map +1 -0
- package/dist/src/lib/index.d.ts +21 -0
- package/dist/src/lib/index.js +146 -0
- package/dist/src/lib/index.js.map +1 -0
- package/dist/src/utils/crypto.d.ts +1 -0
- package/dist/src/utils/crypto.js +8 -0
- package/dist/src/utils/crypto.js.map +1 -0
- package/eslint.config.js +19 -0
- package/jest.config.ts +10 -0
- package/package.json +44 -0
- package/project.json +19 -0
- package/src/index.ts +27 -0
- package/src/lib/ActiveWebhooks.ts +245 -0
- package/src/lib/ActiveWorkflows.ts +304 -0
- package/src/lib/BinaryDataManager/FileSystem.ts +214 -0
- package/src/lib/BinaryDataManager/index.ts +187 -0
- package/src/lib/ChangeCase.ts +45 -0
- package/src/lib/Constants.ts +16 -0
- package/src/lib/Credentials.ts +108 -0
- package/src/lib/FileSystem.ts +214 -0
- package/src/lib/InputConnectionDataLegacy.ts +123 -0
- package/src/lib/Interfaces.ts +338 -0
- package/src/lib/LoadNodeParameterOptions.ts +235 -0
- package/src/lib/NodeExecuteFunctions.ts +3704 -0
- package/src/lib/NodesLoader/constants.ts +112 -0
- package/src/lib/NodesLoader/custom-directory-loader.ts +31 -0
- package/src/lib/NodesLoader/directory-loader.ts +458 -0
- package/src/lib/NodesLoader/index.ts +5 -0
- package/src/lib/NodesLoader/lazy-package-directory-loader.ts +55 -0
- package/src/lib/NodesLoader/load-class-in-isolation.ts +19 -0
- package/src/lib/NodesLoader/package-directory-loader.ts +107 -0
- package/src/lib/NodesLoader/types.ts +14 -0
- package/src/lib/UserSettings.ts +292 -0
- package/src/lib/WorkflowExecute.ts +1108 -0
- package/src/lib/index.ts +187 -0
- package/src/utils/crypto.ts +5 -0
- package/tests/Credentials.test.ts +88 -0
- package/tests/Helpers.ts +808 -0
- package/tests/WorkflowExecute.test.ts +1242 -0
- package/tsconfig.json +42 -0
- package/tsconfig.lib.json +10 -0
- package/tsconfig.spec.json +14 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import {
|
|
3
|
+
IAdditionalCredentialOptions,
|
|
4
|
+
IAllExecuteFunctions,
|
|
5
|
+
IBinaryData,
|
|
6
|
+
ICredentialTestFunctions as ICredentialTestFunctionsBase,
|
|
7
|
+
ICredentialType,
|
|
8
|
+
IDataObject,
|
|
9
|
+
IExecuteFunctions as IExecuteFunctionsBase,
|
|
10
|
+
IExecuteSingleFunctions as IExecuteSingleFunctionsBase,
|
|
11
|
+
IHookFunctions as IHookFunctionsBase,
|
|
12
|
+
IHttpRequestOptions,
|
|
13
|
+
ILoadOptionsFunctions as ILoadOptionsFunctionsBase,
|
|
14
|
+
INodeExecutionData,
|
|
15
|
+
INodeType,
|
|
16
|
+
IOAuth2Options,
|
|
17
|
+
IPollFunctions as IPollFunctionsBase,
|
|
18
|
+
IPollResponse,
|
|
19
|
+
ITriggerFunctions as ITriggerFunctionsBase,
|
|
20
|
+
ITriggerResponse,
|
|
21
|
+
IWebhookFunctions as IWebhookFunctionsBase,
|
|
22
|
+
IWorkflowSettings as IWorkflowSettingsWorkflow,
|
|
23
|
+
} from '@fsai-flow/workflow';
|
|
24
|
+
|
|
25
|
+
import { OptionsWithUri, OptionsWithUrl } from 'request';
|
|
26
|
+
import * as requestPromise from 'request-promise-native';
|
|
27
|
+
|
|
28
|
+
interface Constructable<T> {
|
|
29
|
+
new (): T;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface IProcessMessage {
|
|
33
|
+
data?: any;
|
|
34
|
+
type: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type Class<T = object, A extends unknown[] = unknown[]> = new (...args: A) => T;
|
|
38
|
+
|
|
39
|
+
export interface IExecuteFunctions extends IExecuteFunctionsBase {
|
|
40
|
+
helpers: {
|
|
41
|
+
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>; // tslint:disable-line:no-any
|
|
42
|
+
prepareBinaryData(
|
|
43
|
+
binaryData: Buffer,
|
|
44
|
+
filePath?: string,
|
|
45
|
+
mimeType?: string,
|
|
46
|
+
): Promise<IBinaryData>;
|
|
47
|
+
assertBinaryData(itemIndex: number, propertyName: string, inputIndex?:number): IBinaryData;
|
|
48
|
+
getBinaryDataBuffer(itemIndex: number, propertyName: string, inputIndex?:number): Promise<Buffer>;
|
|
49
|
+
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>; // tslint:disable-line:no-any
|
|
50
|
+
requestWithAuthentication(
|
|
51
|
+
this: IAllExecuteFunctions,
|
|
52
|
+
credentialsType: string,
|
|
53
|
+
requestOptions: OptionsWithUri | requestPromise.RequestPromiseOptions,
|
|
54
|
+
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
|
55
|
+
): Promise<any>;
|
|
56
|
+
requestOAuth2(
|
|
57
|
+
this: IAllExecuteFunctions,
|
|
58
|
+
credentialsType: string,
|
|
59
|
+
requestOptions: OptionsWithUri | requestPromise.RequestPromiseOptions,
|
|
60
|
+
oAuth2Options?: IOAuth2Options,
|
|
61
|
+
): Promise<any>; // tslint:disable-line:no-any
|
|
62
|
+
requestOAuth1(
|
|
63
|
+
this: IAllExecuteFunctions,
|
|
64
|
+
credentialsType: string,
|
|
65
|
+
requestOptions: OptionsWithUrl | requestPromise.RequestPromiseOptions,
|
|
66
|
+
): Promise<any>; // tslint:disable-line:no-any
|
|
67
|
+
returnJsonArray(jsonData: IDataObject | IDataObject[]): INodeExecutionData[];
|
|
68
|
+
normalizeItems(items: INodeExecutionData | INodeExecutionData[]): INodeExecutionData[];
|
|
69
|
+
httpRequestWithAuthentication(
|
|
70
|
+
this: IAllExecuteFunctions,
|
|
71
|
+
credentialsType: string,
|
|
72
|
+
requestOptions: IHttpRequestOptions,
|
|
73
|
+
): Promise<any>;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface IExecuteSingleFunctions extends IExecuteSingleFunctionsBase {
|
|
78
|
+
helpers: {
|
|
79
|
+
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>; // tslint:disable-line:no-any
|
|
80
|
+
prepareBinaryData(
|
|
81
|
+
binaryData: Buffer,
|
|
82
|
+
filePath?: string,
|
|
83
|
+
mimeType?: string,
|
|
84
|
+
): Promise<IBinaryData>;
|
|
85
|
+
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>; // tslint:disable-line:no-any
|
|
86
|
+
requestWithAuthentication(
|
|
87
|
+
this: IAllExecuteFunctions,
|
|
88
|
+
credentialsType: string,
|
|
89
|
+
requestOptions: OptionsWithUri | requestPromise.RequestPromiseOptions,
|
|
90
|
+
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
|
91
|
+
): Promise<any>;
|
|
92
|
+
requestOAuth2(
|
|
93
|
+
this: IAllExecuteFunctions,
|
|
94
|
+
credentialsType: string,
|
|
95
|
+
requestOptions: OptionsWithUri | requestPromise.RequestPromiseOptions,
|
|
96
|
+
oAuth2Options?: IOAuth2Options,
|
|
97
|
+
): Promise<any>; // tslint:disable-line:no-any
|
|
98
|
+
requestOAuth1(
|
|
99
|
+
this: IAllExecuteFunctions,
|
|
100
|
+
credentialsType: string,
|
|
101
|
+
requestOptions: OptionsWithUrl | requestPromise.RequestPromiseOptions,
|
|
102
|
+
): Promise<any>; // tslint:disable-line:no-any
|
|
103
|
+
httpRequestWithAuthentication(
|
|
104
|
+
this: IAllExecuteFunctions,
|
|
105
|
+
credentialsType: string,
|
|
106
|
+
requestOptions: IHttpRequestOptions,
|
|
107
|
+
): Promise<any>;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface IPollFunctions extends IPollFunctionsBase {
|
|
112
|
+
helpers: {
|
|
113
|
+
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>; // tslint:disable-line:no-any
|
|
114
|
+
prepareBinaryData(
|
|
115
|
+
binaryData: Buffer,
|
|
116
|
+
filePath?: string,
|
|
117
|
+
mimeType?: string,
|
|
118
|
+
): Promise<IBinaryData>;
|
|
119
|
+
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>; // tslint:disable-line:no-any
|
|
120
|
+
requestWithAuthentication(
|
|
121
|
+
this: IAllExecuteFunctions,
|
|
122
|
+
credentialsType: string,
|
|
123
|
+
requestOptions: OptionsWithUri | requestPromise.RequestPromiseOptions,
|
|
124
|
+
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
|
125
|
+
): Promise<any>;
|
|
126
|
+
requestOAuth2(
|
|
127
|
+
this: IAllExecuteFunctions,
|
|
128
|
+
credentialsType: string,
|
|
129
|
+
requestOptions: OptionsWithUri | requestPromise.RequestPromiseOptions,
|
|
130
|
+
oAuth2Options?: IOAuth2Options,
|
|
131
|
+
): Promise<any>; // tslint:disable-line:no-any
|
|
132
|
+
requestOAuth1(
|
|
133
|
+
this: IAllExecuteFunctions,
|
|
134
|
+
credentialsType: string,
|
|
135
|
+
requestOptions: OptionsWithUrl | requestPromise.RequestPromiseOptions,
|
|
136
|
+
): Promise<any>; // tslint:disable-line:no-any
|
|
137
|
+
returnJsonArray(jsonData: IDataObject | IDataObject[]): INodeExecutionData[];
|
|
138
|
+
httpRequestWithAuthentication(
|
|
139
|
+
this: IAllExecuteFunctions,
|
|
140
|
+
credentialsType: string,
|
|
141
|
+
requestOptions: IHttpRequestOptions,
|
|
142
|
+
): Promise<any>;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface IResponseError extends Error {
|
|
147
|
+
statusCode?: number;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface ITriggerFunctions extends ITriggerFunctionsBase {
|
|
151
|
+
helpers: {
|
|
152
|
+
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>; // tslint:disable-line:no-any
|
|
153
|
+
prepareBinaryData(
|
|
154
|
+
binaryData: Buffer,
|
|
155
|
+
filePath?: string,
|
|
156
|
+
mimeType?: string,
|
|
157
|
+
): Promise<IBinaryData>;
|
|
158
|
+
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>; // tslint:disable-line:no-any
|
|
159
|
+
requestWithAuthentication(
|
|
160
|
+
this: IAllExecuteFunctions,
|
|
161
|
+
credentialsType: string,
|
|
162
|
+
requestOptions: OptionsWithUri | requestPromise.RequestPromiseOptions,
|
|
163
|
+
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
|
164
|
+
): Promise<any>;
|
|
165
|
+
requestOAuth2(
|
|
166
|
+
this: IAllExecuteFunctions,
|
|
167
|
+
credentialsType: string,
|
|
168
|
+
requestOptions: OptionsWithUri | requestPromise.RequestPromiseOptions,
|
|
169
|
+
oAuth2Options?: IOAuth2Options,
|
|
170
|
+
): Promise<any>; // tslint:disable-line:no-any
|
|
171
|
+
requestOAuth1(
|
|
172
|
+
this: IAllExecuteFunctions,
|
|
173
|
+
credentialsType: string,
|
|
174
|
+
requestOptions: OptionsWithUrl | requestPromise.RequestPromiseOptions,
|
|
175
|
+
): Promise<any>; // tslint:disable-line:no-any
|
|
176
|
+
returnJsonArray(jsonData: IDataObject | IDataObject[]): INodeExecutionData[];
|
|
177
|
+
httpRequestWithAuthentication(
|
|
178
|
+
this: IAllExecuteFunctions,
|
|
179
|
+
credentialsType: string,
|
|
180
|
+
requestOptions: IHttpRequestOptions,
|
|
181
|
+
): Promise<any>;
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export interface ITriggerTime {
|
|
186
|
+
mode: string;
|
|
187
|
+
hour: number;
|
|
188
|
+
minute: number;
|
|
189
|
+
dayOfMonth: number;
|
|
190
|
+
weekeday: number;
|
|
191
|
+
[key: string]: string | number;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export interface IUserSettings {
|
|
195
|
+
encryptionKey?: string;
|
|
196
|
+
tunnelSubdomain?: string;
|
|
197
|
+
instanceId?: string;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export interface ILoadOptionsFunctions extends ILoadOptionsFunctionsBase {
|
|
201
|
+
helpers: {
|
|
202
|
+
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>; // tslint:disable-line:no-any
|
|
203
|
+
request?: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>; // tslint:disable-line:no-any
|
|
204
|
+
requestWithAuthentication(
|
|
205
|
+
this: IAllExecuteFunctions,
|
|
206
|
+
credentialsType: string,
|
|
207
|
+
requestOptions: OptionsWithUri | requestPromise.RequestPromiseOptions,
|
|
208
|
+
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
|
209
|
+
): Promise<any>;
|
|
210
|
+
requestOAuth2?: (
|
|
211
|
+
this: IAllExecuteFunctions,
|
|
212
|
+
credentialsType: string,
|
|
213
|
+
requestOptions: OptionsWithUri | requestPromise.RequestPromiseOptions,
|
|
214
|
+
oAuth2Options?: IOAuth2Options,
|
|
215
|
+
) => Promise<any>; // tslint:disable-line:no-any
|
|
216
|
+
requestOAuth1?(
|
|
217
|
+
this: IAllExecuteFunctions,
|
|
218
|
+
credentialsType: string,
|
|
219
|
+
requestOptions: OptionsWithUrl | requestPromise.RequestPromiseOptions,
|
|
220
|
+
): Promise<any>; // tslint:disable-line:no-any
|
|
221
|
+
httpRequestWithAuthentication(
|
|
222
|
+
this: IAllExecuteFunctions,
|
|
223
|
+
credentialsType: string,
|
|
224
|
+
requestOptions: IHttpRequestOptions,
|
|
225
|
+
): Promise<any>;
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export interface ICredentialTestFunctions extends ICredentialTestFunctionsBase {
|
|
230
|
+
helpers: {
|
|
231
|
+
request?: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>; // tslint:disable-line:no-any
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export interface IHookFunctions extends IHookFunctionsBase {
|
|
236
|
+
helpers: {
|
|
237
|
+
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>; // tslint:disable-line:no-any
|
|
238
|
+
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>; // tslint:disable-line:no-any
|
|
239
|
+
requestWithAuthentication(
|
|
240
|
+
this: IAllExecuteFunctions,
|
|
241
|
+
credentialsType: string,
|
|
242
|
+
requestOptions: OptionsWithUri | requestPromise.RequestPromiseOptions,
|
|
243
|
+
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
|
244
|
+
): Promise<any>;
|
|
245
|
+
requestOAuth2(
|
|
246
|
+
this: IAllExecuteFunctions,
|
|
247
|
+
credentialsType: string,
|
|
248
|
+
requestOptions: OptionsWithUri | requestPromise.RequestPromiseOptions,
|
|
249
|
+
oAuth2Options?: IOAuth2Options,
|
|
250
|
+
): Promise<any>; // tslint:disable-line:no-any
|
|
251
|
+
requestOAuth1(
|
|
252
|
+
this: IAllExecuteFunctions,
|
|
253
|
+
credentialsType: string,
|
|
254
|
+
requestOptions: OptionsWithUrl | requestPromise.RequestPromiseOptions,
|
|
255
|
+
): Promise<any>; // tslint:disable-line:no-any
|
|
256
|
+
httpRequestWithAuthentication(
|
|
257
|
+
this: IAllExecuteFunctions,
|
|
258
|
+
credentialsType: string,
|
|
259
|
+
requestOptions: IHttpRequestOptions,
|
|
260
|
+
): Promise<any>;
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export interface IWebhookFunctions extends IWebhookFunctionsBase {
|
|
265
|
+
helpers: {
|
|
266
|
+
httpRequest(requestOptions: IHttpRequestOptions): Promise<any>; // tslint:disable-line:no-any
|
|
267
|
+
prepareBinaryData(
|
|
268
|
+
binaryData: Buffer,
|
|
269
|
+
filePath?: string,
|
|
270
|
+
mimeType?: string,
|
|
271
|
+
): Promise<IBinaryData>;
|
|
272
|
+
request: (uriOrObject: string | IDataObject | any, options?: IDataObject) => Promise<any>; // tslint:disable-line:no-any
|
|
273
|
+
requestWithAuthentication(
|
|
274
|
+
this: IAllExecuteFunctions,
|
|
275
|
+
credentialsType: string,
|
|
276
|
+
requestOptions: OptionsWithUri | requestPromise.RequestPromiseOptions,
|
|
277
|
+
additionalCredentialOptions?: IAdditionalCredentialOptions,
|
|
278
|
+
): Promise<any>;
|
|
279
|
+
requestOAuth2(
|
|
280
|
+
this: IAllExecuteFunctions,
|
|
281
|
+
credentialsType: string,
|
|
282
|
+
requestOptions: OptionsWithUri | requestPromise.RequestPromiseOptions,
|
|
283
|
+
oAuth2Options?: IOAuth2Options,
|
|
284
|
+
): Promise<any>; // tslint:disable-line:no-any
|
|
285
|
+
requestOAuth1(
|
|
286
|
+
this: IAllExecuteFunctions,
|
|
287
|
+
credentialsType: string,
|
|
288
|
+
requestOptions: OptionsWithUrl | requestPromise.RequestPromiseOptions,
|
|
289
|
+
): Promise<any>; // tslint:disable-line:no-any
|
|
290
|
+
returnJsonArray(jsonData: IDataObject | IDataObject[]): INodeExecutionData[];
|
|
291
|
+
httpRequestWithAuthentication(
|
|
292
|
+
this: IAllExecuteFunctions,
|
|
293
|
+
credentialsType: string,
|
|
294
|
+
requestOptions: IHttpRequestOptions,
|
|
295
|
+
): Promise<any>;
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export interface IWorkflowSettings extends IWorkflowSettingsWorkflow {
|
|
300
|
+
errorWorkflow?: string;
|
|
301
|
+
timezone?: string;
|
|
302
|
+
saveManualRuns?: boolean;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// New node definition in file
|
|
306
|
+
export interface INodeDefinitionFile {
|
|
307
|
+
[key: string]: Constructable<INodeType | ICredentialType>;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Is identical to TaskDataConnections but does not allow null value to be used as input for nodes
|
|
311
|
+
export interface INodeInputDataConnections {
|
|
312
|
+
[key: string]: INodeExecutionData[][];
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export interface IWorkflowData {
|
|
316
|
+
pollResponses?: IPollResponse[];
|
|
317
|
+
triggerResponses?: ITriggerResponse[];
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export interface IBinaryDataConfig {
|
|
321
|
+
mode: 'default' | 'filesystem';
|
|
322
|
+
availableModes: string;
|
|
323
|
+
localStoragePath: string;
|
|
324
|
+
binaryDataTTL: number;
|
|
325
|
+
persistedBinaryDataTTL: number;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export interface IBinaryDataManager {
|
|
329
|
+
init(startPurger: boolean): Promise<void>;
|
|
330
|
+
storeBinaryData(binaryBuffer: Buffer, executionId: string): Promise<string>;
|
|
331
|
+
retrieveBinaryDataByIdentifier(identifier: string): Promise<Buffer>;
|
|
332
|
+
markDataForDeletionByExecutionId(executionId: string): Promise<void>;
|
|
333
|
+
deleteMarkedFiles(): Promise<unknown>;
|
|
334
|
+
deleteBinaryDataByIdentifier(identifier: string): Promise<void>;
|
|
335
|
+
duplicateBinaryDataByIdentifier(binaryDataId: string, prefix: string): Promise<string>;
|
|
336
|
+
deleteBinaryDataByExecutionId(executionId: string): Promise<void>;
|
|
337
|
+
persistBinaryDataForExecutionId(executionId: string): Promise<void>;
|
|
338
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/* eslint-disable no-restricted-syntax */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
4
|
+
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
ILoadOptions,
|
|
11
|
+
INode,
|
|
12
|
+
INodeCredentials,
|
|
13
|
+
INodeExecutionData,
|
|
14
|
+
INodeParameters,
|
|
15
|
+
INodeProperties,
|
|
16
|
+
INodePropertyOptions,
|
|
17
|
+
INodeType,
|
|
18
|
+
INodeTypeNameVersion,
|
|
19
|
+
INodeTypes,
|
|
20
|
+
IRunExecutionData,
|
|
21
|
+
ITaskDataConnections,
|
|
22
|
+
IWorkflowExecuteAdditionalData,
|
|
23
|
+
RoutingNode,
|
|
24
|
+
Workflow,
|
|
25
|
+
} from '@fsai-flow/workflow';
|
|
26
|
+
|
|
27
|
+
// eslint-disable-next-line import/no-cycle
|
|
28
|
+
import { NodeExecuteFunctions } from '../../src';
|
|
29
|
+
|
|
30
|
+
const TEMP_NODE_NAME = 'Temp-Node';
|
|
31
|
+
const TEMP_WORKFLOW_NAME = 'Temp-Workflow';
|
|
32
|
+
|
|
33
|
+
export class LoadNodeParameterOptions {
|
|
34
|
+
currentNodeParameters: INodeParameters;
|
|
35
|
+
|
|
36
|
+
path: string;
|
|
37
|
+
|
|
38
|
+
workflow: Workflow;
|
|
39
|
+
|
|
40
|
+
constructor(
|
|
41
|
+
nodeTypeNameAndVersion: INodeTypeNameVersion,
|
|
42
|
+
nodeTypes: INodeTypes,
|
|
43
|
+
path: string,
|
|
44
|
+
currentNodeParameters: INodeParameters,
|
|
45
|
+
credentials?: INodeCredentials,
|
|
46
|
+
) {
|
|
47
|
+
const nodeType = nodeTypes.getByNameAndVersion(
|
|
48
|
+
nodeTypeNameAndVersion.name,
|
|
49
|
+
nodeTypeNameAndVersion.version,
|
|
50
|
+
);
|
|
51
|
+
this.currentNodeParameters = currentNodeParameters;
|
|
52
|
+
this.path = path;
|
|
53
|
+
if (nodeType === undefined) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
`The node-type "${nodeTypeNameAndVersion.name} v${nodeTypeNameAndVersion.version}" is not known!`,
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const nodeData: INode = {
|
|
60
|
+
parameters: currentNodeParameters,
|
|
61
|
+
name: TEMP_NODE_NAME,
|
|
62
|
+
type: nodeTypeNameAndVersion.name,
|
|
63
|
+
typeVersion: nodeTypeNameAndVersion.version,
|
|
64
|
+
position: [0, 0],
|
|
65
|
+
id: '',
|
|
66
|
+
};
|
|
67
|
+
if (credentials) {
|
|
68
|
+
nodeData.credentials = credentials;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const workflowData = {
|
|
72
|
+
nodes: [nodeData],
|
|
73
|
+
connections: {},
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
this.workflow = new Workflow({
|
|
77
|
+
nodes: workflowData.nodes,
|
|
78
|
+
connections: workflowData.connections,
|
|
79
|
+
active: false,
|
|
80
|
+
nodeTypes,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Returns data of a fake workflow
|
|
86
|
+
*
|
|
87
|
+
* @returns
|
|
88
|
+
* @memberof LoadNodeParameterOptions
|
|
89
|
+
*/
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
91
|
+
getWorkflowData() {
|
|
92
|
+
return {
|
|
93
|
+
name: TEMP_WORKFLOW_NAME,
|
|
94
|
+
active: false,
|
|
95
|
+
connections: {},
|
|
96
|
+
nodes: Object.values(this.workflow.nodes),
|
|
97
|
+
createdAt: new Date(),
|
|
98
|
+
updatedAt: new Date(),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Returns the available options via a predefined method
|
|
104
|
+
*
|
|
105
|
+
* @param {string} methodName The name of the method of which to get the data from
|
|
106
|
+
* @param {IWorkflowExecuteAdditionalData} additionalData
|
|
107
|
+
* @returns {Promise<INodePropertyOptions[]>}
|
|
108
|
+
* @memberof LoadNodeParameterOptions
|
|
109
|
+
*/
|
|
110
|
+
async getOptionsViaMethodName(
|
|
111
|
+
methodName: string,
|
|
112
|
+
additionalData: IWorkflowExecuteAdditionalData,
|
|
113
|
+
): Promise<INodePropertyOptions[]> {
|
|
114
|
+
const node = this.workflow.getNode(TEMP_NODE_NAME);
|
|
115
|
+
|
|
116
|
+
const nodeType = this.workflow.nodeTypes.getByNameAndVersion(node!.type, node?.typeVersion);
|
|
117
|
+
|
|
118
|
+
if (
|
|
119
|
+
!nodeType ||
|
|
120
|
+
nodeType.methods === undefined ||
|
|
121
|
+
nodeType.methods.loadOptions === undefined ||
|
|
122
|
+
nodeType.methods.loadOptions[methodName] === undefined
|
|
123
|
+
) {
|
|
124
|
+
throw new Error(
|
|
125
|
+
`The node-type "${node!.type}" does not have the method "${methodName}" defined!`,
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const thisArgs = NodeExecuteFunctions.getLoadOptionsFunctions(
|
|
130
|
+
this.workflow,
|
|
131
|
+
node!,
|
|
132
|
+
this.path,
|
|
133
|
+
additionalData,
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
try {
|
|
137
|
+
return await nodeType.methods.loadOptions[methodName].call(thisArgs);
|
|
138
|
+
} catch (error) {
|
|
139
|
+
return [{
|
|
140
|
+
name: 'Error trying to load options',
|
|
141
|
+
value: '',
|
|
142
|
+
description: (error as Error).message || 'Error trying to load options.'
|
|
143
|
+
}];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Returns the available options via a load request informatoin
|
|
149
|
+
*
|
|
150
|
+
* @param {ILoadOptions} loadOptions The load options which also contain the request information
|
|
151
|
+
* @param {IWorkflowExecuteAdditionalData} additionalData
|
|
152
|
+
* @returns {Promise<INodePropertyOptions[]>}
|
|
153
|
+
* @memberof LoadNodeParameterOptions
|
|
154
|
+
*/
|
|
155
|
+
async getOptionsViaRequestProperty(
|
|
156
|
+
loadOptions: ILoadOptions,
|
|
157
|
+
additionalData: IWorkflowExecuteAdditionalData,
|
|
158
|
+
): Promise<INodePropertyOptions[]> {
|
|
159
|
+
const node = this.workflow.getNode(TEMP_NODE_NAME);
|
|
160
|
+
|
|
161
|
+
const nodeType = this.workflow.nodeTypes.getByNameAndVersion(node!.type, node?.typeVersion);
|
|
162
|
+
|
|
163
|
+
if (
|
|
164
|
+
nodeType === undefined ||
|
|
165
|
+
!nodeType.description.requestDefaults ||
|
|
166
|
+
!nodeType.description.requestDefaults.baseURL
|
|
167
|
+
) {
|
|
168
|
+
// This in in here for now for security reasons.
|
|
169
|
+
// Background: As the full data for the request to make does get send, and the auth data
|
|
170
|
+
// will then be applied, would it be possible to retrieve that data like that. By at least
|
|
171
|
+
// requiring a baseURL to be defined can at least not a random server be called.
|
|
172
|
+
// In the future this code has to get improved that it does not use the request information from
|
|
173
|
+
// the request rather resolves it via the parameter-path and nodeType data.
|
|
174
|
+
throw new Error(
|
|
175
|
+
`The node-type "${
|
|
176
|
+
node!.type
|
|
177
|
+
}" does not exist or does not have "requestDefaults.baseURL" defined!`,
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const mode = 'internal';
|
|
182
|
+
const runIndex = 0;
|
|
183
|
+
const connectionInputData: INodeExecutionData[] = [];
|
|
184
|
+
const runExecutionData: IRunExecutionData = { resultData: { runData: {} } };
|
|
185
|
+
|
|
186
|
+
const routingNode = new RoutingNode(
|
|
187
|
+
this.workflow,
|
|
188
|
+
node!,
|
|
189
|
+
connectionInputData,
|
|
190
|
+
runExecutionData ?? null,
|
|
191
|
+
additionalData,
|
|
192
|
+
mode,
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
// Create copy of node-type with the single property we want to get the data off
|
|
196
|
+
const tempNode: INodeType = {
|
|
197
|
+
...nodeType,
|
|
198
|
+
...{
|
|
199
|
+
description: {
|
|
200
|
+
...nodeType.description,
|
|
201
|
+
properties: [
|
|
202
|
+
{
|
|
203
|
+
displayName: '',
|
|
204
|
+
type: 'string',
|
|
205
|
+
name: '',
|
|
206
|
+
default: '',
|
|
207
|
+
routing: loadOptions.routing,
|
|
208
|
+
} as INodeProperties,
|
|
209
|
+
],
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
const inputData: ITaskDataConnections = {
|
|
215
|
+
main: [[{ json: {} }]],
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
const optionsData = await routingNode.runNode(
|
|
219
|
+
inputData,
|
|
220
|
+
runIndex,
|
|
221
|
+
tempNode,
|
|
222
|
+
NodeExecuteFunctions,
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
if (optionsData?.length === 0) {
|
|
226
|
+
return [];
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (!Array.isArray(optionsData)) {
|
|
230
|
+
throw new Error('The returned data is not an array!');
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return optionsData[0].map((item) => item.json) as unknown as INodePropertyOptions[];
|
|
234
|
+
}
|
|
235
|
+
}
|