@fsai-flow/core 0.0.5 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/index.d.ts +17 -0
  2. package/dist/index.js +61 -0
  3. package/dist/lib/ActiveWebhooks.d.ts +59 -0
  4. package/dist/lib/ActiveWebhooks.js +177 -0
  5. package/dist/lib/ActiveWorkflows.d.ts +87 -0
  6. package/dist/lib/ActiveWorkflows.js +465 -0
  7. package/dist/lib/BinaryDataManager/FileSystem.d.ts +26 -0
  8. package/dist/lib/BinaryDataManager/FileSystem.js +180 -0
  9. package/dist/lib/BinaryDataManager/index.d.ts +21 -0
  10. package/dist/lib/BinaryDataManager/index.js +129 -0
  11. package/dist/lib/ChangeCase.d.ts +9 -0
  12. package/dist/lib/ChangeCase.js +43 -0
  13. package/dist/lib/Constants.d.ts +14 -0
  14. package/dist/lib/Constants.js +18 -0
  15. package/dist/lib/Credentials.d.ts +27 -0
  16. package/dist/lib/Credentials.js +88 -0
  17. package/dist/lib/FileSystem.d.ts +26 -0
  18. package/dist/lib/FileSystem.js +180 -0
  19. package/dist/lib/InputConnectionDataLegacy.d.ts +2 -0
  20. package/dist/lib/InputConnectionDataLegacy.js +72 -0
  21. package/dist/lib/Interfaces.d.ts +147 -0
  22. package/dist/lib/Interfaces.js +2 -0
  23. package/dist/lib/LoadNodeParameterOptions.d.ts +39 -0
  24. package/dist/lib/LoadNodeParameterOptions.js +152 -0
  25. package/dist/lib/NodeExecuteFunctions.d.ts +225 -0
  26. package/dist/lib/NodeExecuteFunctions.js +2467 -0
  27. package/dist/lib/NodesLoader/constants.d.ts +5 -0
  28. package/dist/lib/NodesLoader/constants.js +105 -0
  29. package/dist/lib/NodesLoader/custom-directory-loader.d.ts +9 -0
  30. package/dist/lib/NodesLoader/custom-directory-loader.js +35 -0
  31. package/dist/lib/NodesLoader/directory-loader.d.ts +66 -0
  32. package/dist/lib/NodesLoader/directory-loader.js +367 -0
  33. package/dist/lib/NodesLoader/index.d.ts +5 -0
  34. package/dist/lib/NodesLoader/index.js +11 -0
  35. package/dist/lib/NodesLoader/lazy-package-directory-loader.d.ts +7 -0
  36. package/dist/lib/NodesLoader/lazy-package-directory-loader.js +44 -0
  37. package/dist/lib/NodesLoader/load-class-in-isolation.d.ts +1 -0
  38. package/dist/lib/NodesLoader/load-class-in-isolation.js +17 -0
  39. package/dist/lib/NodesLoader/package-directory-loader.d.ts +17 -0
  40. package/dist/lib/NodesLoader/package-directory-loader.js +92 -0
  41. package/dist/lib/NodesLoader/types.d.ts +14 -0
  42. package/dist/lib/NodesLoader/types.js +2 -0
  43. package/dist/lib/RedisLeaderElectionManager.d.ts +53 -0
  44. package/dist/lib/RedisLeaderElectionManager.js +279 -0
  45. package/dist/lib/RequestTypes.d.ts +58 -0
  46. package/dist/lib/RequestTypes.js +8 -0
  47. package/dist/lib/UserSettings.d.ts +80 -0
  48. package/dist/lib/UserSettings.js +269 -0
  49. package/dist/lib/WorkflowExecute.d.ts +53 -0
  50. package/dist/lib/WorkflowExecute.js +906 -0
  51. package/dist/lib/index.d.ts +21 -0
  52. package/dist/lib/index.js +129 -0
  53. package/dist/utils/crypto.d.ts +1 -0
  54. package/dist/utils/crypto.js +7 -0
  55. package/package.json +52 -52
  56. package/dist/README.md +0 -31
  57. package/dist/package.json +0 -54
  58. package/eslint.config.js +0 -19
  59. package/jest.config.ts +0 -10
  60. package/project.json +0 -19
  61. package/src/index.ts +0 -28
  62. package/src/lib/ActiveWebhooks.ts +0 -245
  63. package/src/lib/ActiveWorkflows.ts +0 -575
  64. package/src/lib/BinaryDataManager/FileSystem.ts +0 -214
  65. package/src/lib/BinaryDataManager/index.ts +0 -187
  66. package/src/lib/ChangeCase.ts +0 -45
  67. package/src/lib/Constants.ts +0 -16
  68. package/src/lib/Credentials.ts +0 -108
  69. package/src/lib/FileSystem.ts +0 -214
  70. package/src/lib/InputConnectionDataLegacy.ts +0 -123
  71. package/src/lib/Interfaces.ts +0 -338
  72. package/src/lib/LoadNodeParameterOptions.ts +0 -235
  73. package/src/lib/NodeExecuteFunctions.ts +0 -3700
  74. package/src/lib/NodesLoader/constants.ts +0 -112
  75. package/src/lib/NodesLoader/custom-directory-loader.ts +0 -31
  76. package/src/lib/NodesLoader/directory-loader.ts +0 -458
  77. package/src/lib/NodesLoader/index.ts +0 -5
  78. package/src/lib/NodesLoader/lazy-package-directory-loader.ts +0 -55
  79. package/src/lib/NodesLoader/load-class-in-isolation.ts +0 -19
  80. package/src/lib/NodesLoader/package-directory-loader.ts +0 -107
  81. package/src/lib/NodesLoader/types.ts +0 -14
  82. package/src/lib/RedisLeaderElectionManager.ts +0 -334
  83. package/src/lib/UserSettings.ts +0 -292
  84. package/src/lib/WorkflowExecute.ts +0 -1128
  85. package/src/lib/index.ts +0 -187
  86. package/src/utils/crypto.ts +0 -5
  87. package/tests/Credentials.test.ts +0 -88
  88. package/tests/Helpers.ts +0 -808
  89. package/tests/WorkflowExecute.test.ts +0 -1242
  90. package/tsconfig.json +0 -41
  91. package/tsconfig.lib.json +0 -10
  92. package/tsconfig.spec.json +0 -14
@@ -0,0 +1,147 @@
1
+ import type { IAdditionalCredentialOptions, IAllExecuteFunctions, IBinaryData, ICredentialTestFunctions as ICredentialTestFunctionsBase, ICredentialType, IDataObject, IExecuteFunctions as IExecuteFunctionsBase, IExecuteSingleFunctions as IExecuteSingleFunctionsBase, IHookFunctions as IHookFunctionsBase, IHttpRequestOptions, ILoadOptionsFunctions as ILoadOptionsFunctionsBase, IN8nHttpFullResponse, IN8nHttpResponse, INodeExecutionData, INodeType, IOAuth2Options, IPollFunctions as IPollFunctionsBase, IPollResponse, ITriggerFunctions as ITriggerFunctionsBase, ITriggerResponse, IWebhookFunctions as IWebhookFunctionsBase, IWorkflowSettings as IWorkflowSettingsWorkflow } from "@fsai-flow/workflow";
2
+ import type { OptionsWithUri, OptionsWithUrl, RequestPromiseOptions } from "./RequestTypes";
3
+ interface Constructable<T> {
4
+ new (): T;
5
+ }
6
+ export interface IProcessMessage {
7
+ data?: unknown;
8
+ type: string;
9
+ }
10
+ export type Class<T = object, A extends unknown[] = unknown[]> = new (...args: A) => T;
11
+ export interface IExecuteFunctions extends IExecuteFunctionsBase {
12
+ helpers: {
13
+ httpRequest(requestOptions: IHttpRequestOptions): Promise<IN8nHttpFullResponse | IN8nHttpResponse>;
14
+ prepareBinaryData(binaryData: Buffer, filePath?: string, mimeType?: string): Promise<IBinaryData>;
15
+ assertBinaryData(itemIndex: number, propertyName: string, inputIndex?: number): IBinaryData;
16
+ getBinaryDataBuffer(itemIndex: number, propertyName: string, inputIndex?: number): Promise<Buffer>;
17
+ request: (uriOrObject: string | IDataObject | unknown, options?: IDataObject) => Promise<unknown>;
18
+ requestWithAuthentication(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUri | RequestPromiseOptions, additionalCredentialOptions?: IAdditionalCredentialOptions): Promise<unknown>;
19
+ requestOAuth2(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUri | RequestPromiseOptions, oAuth2Options?: IOAuth2Options): Promise<unknown>;
20
+ requestOAuth1(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUrl | RequestPromiseOptions): Promise<unknown>;
21
+ returnJsonArray(jsonData: IDataObject | IDataObject[]): INodeExecutionData[];
22
+ normalizeItems(items: INodeExecutionData | INodeExecutionData[]): INodeExecutionData[];
23
+ httpRequestWithAuthentication(this: IAllExecuteFunctions, credentialsType: string, requestOptions: IHttpRequestOptions): Promise<IN8nHttpFullResponse | IN8nHttpResponse>;
24
+ };
25
+ }
26
+ export interface IExecuteSingleFunctions extends IExecuteSingleFunctionsBase {
27
+ helpers: {
28
+ httpRequest(requestOptions: IHttpRequestOptions): Promise<IN8nHttpFullResponse | IN8nHttpResponse>;
29
+ prepareBinaryData(binaryData: Buffer, filePath?: string, mimeType?: string): Promise<IBinaryData>;
30
+ request: (uriOrObject: string | IDataObject | unknown, options?: IDataObject) => Promise<unknown>;
31
+ requestWithAuthentication(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUri | RequestPromiseOptions, additionalCredentialOptions?: IAdditionalCredentialOptions): Promise<unknown>;
32
+ requestOAuth2(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUri | RequestPromiseOptions, oAuth2Options?: IOAuth2Options): Promise<unknown>;
33
+ requestOAuth1(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUrl | RequestPromiseOptions): Promise<unknown>;
34
+ httpRequestWithAuthentication(this: IAllExecuteFunctions, credentialsType: string, requestOptions: IHttpRequestOptions): Promise<IN8nHttpFullResponse | IN8nHttpResponse>;
35
+ };
36
+ }
37
+ export interface IPollFunctions extends IPollFunctionsBase {
38
+ helpers: {
39
+ httpRequest(requestOptions: IHttpRequestOptions): Promise<IN8nHttpFullResponse | IN8nHttpResponse>;
40
+ prepareBinaryData(binaryData: Buffer, filePath?: string, mimeType?: string): Promise<IBinaryData>;
41
+ request: (uriOrObject: string | IDataObject | unknown, options?: IDataObject) => Promise<unknown>;
42
+ requestWithAuthentication(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUri | RequestPromiseOptions, additionalCredentialOptions?: IAdditionalCredentialOptions): Promise<unknown>;
43
+ requestOAuth2(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUri | RequestPromiseOptions, oAuth2Options?: IOAuth2Options): Promise<unknown>;
44
+ requestOAuth1(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUrl | RequestPromiseOptions): Promise<unknown>;
45
+ returnJsonArray(jsonData: IDataObject | IDataObject[]): INodeExecutionData[];
46
+ httpRequestWithAuthentication(this: IAllExecuteFunctions, credentialsType: string, requestOptions: IHttpRequestOptions): Promise<IN8nHttpFullResponse | IN8nHttpResponse>;
47
+ };
48
+ }
49
+ export interface IResponseError extends Error {
50
+ statusCode?: number;
51
+ }
52
+ export interface ITriggerFunctions extends ITriggerFunctionsBase {
53
+ helpers: {
54
+ httpRequest(requestOptions: IHttpRequestOptions): Promise<IN8nHttpFullResponse | IN8nHttpResponse>;
55
+ prepareBinaryData(binaryData: Buffer, filePath?: string, mimeType?: string): Promise<IBinaryData>;
56
+ request: (uriOrObject: string | IDataObject | unknown, options?: IDataObject) => Promise<unknown>;
57
+ requestWithAuthentication(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUri | RequestPromiseOptions, additionalCredentialOptions?: IAdditionalCredentialOptions): Promise<unknown>;
58
+ requestOAuth2(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUri | RequestPromiseOptions, oAuth2Options?: IOAuth2Options): Promise<unknown>;
59
+ requestOAuth1(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUrl | RequestPromiseOptions): Promise<unknown>;
60
+ returnJsonArray(jsonData: IDataObject | IDataObject[]): INodeExecutionData[];
61
+ httpRequestWithAuthentication(this: IAllExecuteFunctions, credentialsType: string, requestOptions: IHttpRequestOptions): Promise<IN8nHttpFullResponse | IN8nHttpResponse>;
62
+ };
63
+ }
64
+ export interface ITriggerTime {
65
+ mode: string;
66
+ hour: number;
67
+ minute: number;
68
+ dayOfMonth: number;
69
+ weekeday: number;
70
+ [key: string]: string | number;
71
+ }
72
+ export interface IUserSettings {
73
+ encryptionKey?: string;
74
+ tunnelSubdomain?: string;
75
+ instanceId?: string;
76
+ }
77
+ export interface ILoadOptionsFunctions extends ILoadOptionsFunctionsBase {
78
+ helpers: {
79
+ httpRequest(requestOptions: IHttpRequestOptions): Promise<IN8nHttpFullResponse | IN8nHttpResponse>;
80
+ request?: (uriOrObject: string | IDataObject | unknown, options?: IDataObject) => Promise<unknown>;
81
+ requestWithAuthentication(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUri | RequestPromiseOptions, additionalCredentialOptions?: IAdditionalCredentialOptions): Promise<unknown>;
82
+ requestOAuth2?: (this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUri | RequestPromiseOptions, oAuth2Options?: IOAuth2Options) => Promise<unknown>;
83
+ requestOAuth1?(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUrl | RequestPromiseOptions): Promise<unknown>;
84
+ httpRequestWithAuthentication(this: IAllExecuteFunctions, credentialsType: string, requestOptions: IHttpRequestOptions): Promise<IN8nHttpFullResponse | IN8nHttpResponse>;
85
+ };
86
+ }
87
+ export interface ICredentialTestFunctions extends ICredentialTestFunctionsBase {
88
+ helpers: {
89
+ request?: (uriOrObject: string | IDataObject | unknown, options?: IDataObject) => Promise<unknown>;
90
+ };
91
+ }
92
+ export interface IHookFunctions extends IHookFunctionsBase {
93
+ helpers: {
94
+ httpRequest(requestOptions: IHttpRequestOptions): Promise<IN8nHttpFullResponse | IN8nHttpResponse>;
95
+ request: (uriOrObject: string | IDataObject | unknown, options?: IDataObject) => Promise<unknown>;
96
+ requestWithAuthentication(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUri | RequestPromiseOptions, additionalCredentialOptions?: IAdditionalCredentialOptions): Promise<unknown>;
97
+ requestOAuth2(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUri | RequestPromiseOptions, oAuth2Options?: IOAuth2Options): Promise<unknown>;
98
+ requestOAuth1(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUrl | RequestPromiseOptions): Promise<unknown>;
99
+ httpRequestWithAuthentication(this: IAllExecuteFunctions, credentialsType: string, requestOptions: IHttpRequestOptions): Promise<IN8nHttpFullResponse | IN8nHttpResponse>;
100
+ };
101
+ }
102
+ export interface IWebhookFunctions extends IWebhookFunctionsBase {
103
+ helpers: {
104
+ httpRequest(requestOptions: IHttpRequestOptions): Promise<IN8nHttpFullResponse | IN8nHttpResponse>;
105
+ prepareBinaryData(binaryData: Buffer, filePath?: string, mimeType?: string): Promise<IBinaryData>;
106
+ request: (uriOrObject: string | IDataObject | unknown, options?: IDataObject) => Promise<unknown>;
107
+ requestWithAuthentication(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUri | RequestPromiseOptions, additionalCredentialOptions?: IAdditionalCredentialOptions): Promise<unknown>;
108
+ requestOAuth2(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUri | RequestPromiseOptions, oAuth2Options?: IOAuth2Options): Promise<unknown>;
109
+ requestOAuth1(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUrl | RequestPromiseOptions): Promise<unknown>;
110
+ returnJsonArray(jsonData: IDataObject | IDataObject[]): INodeExecutionData[];
111
+ httpRequestWithAuthentication(this: IAllExecuteFunctions, credentialsType: string, requestOptions: IHttpRequestOptions): Promise<IN8nHttpFullResponse | IN8nHttpResponse>;
112
+ };
113
+ }
114
+ export interface IWorkflowSettings extends IWorkflowSettingsWorkflow {
115
+ errorWorkflow?: string;
116
+ timezone?: string;
117
+ saveManualRuns?: boolean;
118
+ }
119
+ export interface INodeDefinitionFile {
120
+ [key: string]: Constructable<INodeType | ICredentialType>;
121
+ }
122
+ export interface INodeInputDataConnections {
123
+ [key: string]: INodeExecutionData[][];
124
+ }
125
+ export interface IWorkflowData {
126
+ pollResponses?: IPollResponse[];
127
+ triggerResponses?: ITriggerResponse[];
128
+ }
129
+ export interface IBinaryDataConfig {
130
+ mode: "default" | "filesystem";
131
+ availableModes: string;
132
+ localStoragePath: string;
133
+ binaryDataTTL: number;
134
+ persistedBinaryDataTTL: number;
135
+ }
136
+ export interface IBinaryDataManager {
137
+ init(startPurger: boolean): Promise<void>;
138
+ storeBinaryData(binaryBuffer: Buffer, executionId: string): Promise<string>;
139
+ retrieveBinaryDataByIdentifier(identifier: string): Promise<Buffer>;
140
+ markDataForDeletionByExecutionId(executionId: string): Promise<void>;
141
+ deleteMarkedFiles(): Promise<unknown>;
142
+ deleteBinaryDataByIdentifier(identifier: string): Promise<void>;
143
+ duplicateBinaryDataByIdentifier(binaryDataId: string, prefix: string): Promise<string>;
144
+ deleteBinaryDataByExecutionId(executionId: string): Promise<void>;
145
+ persistBinaryDataForExecutionId(executionId: string): Promise<void>;
146
+ }
147
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,39 @@
1
+ import { type ILoadOptions, type INode, type INodeCredentials, type INodeParameters, type INodePropertyOptions, type INodeTypeNameVersion, type INodeTypes, type IWorkflowExecuteAdditionalData, Workflow } from "@fsai-flow/workflow";
2
+ export declare class LoadNodeParameterOptions {
3
+ currentNodeParameters: INodeParameters;
4
+ path: string;
5
+ workflow: Workflow;
6
+ constructor(nodeTypeNameAndVersion: INodeTypeNameVersion, nodeTypes: INodeTypes, path: string, currentNodeParameters: INodeParameters, credentials?: INodeCredentials);
7
+ /**
8
+ * Returns data of a fake workflow
9
+ *
10
+ * @returns
11
+ * @memberof LoadNodeParameterOptions
12
+ */
13
+ getWorkflowData(): {
14
+ name: string;
15
+ active: boolean;
16
+ connections: {};
17
+ nodes: INode[];
18
+ createdAt: Date;
19
+ updatedAt: Date;
20
+ };
21
+ /**
22
+ * Returns the available options via a predefined method
23
+ *
24
+ * @param {string} methodName The name of the method of which to get the data from
25
+ * @param {IWorkflowExecuteAdditionalData} additionalData
26
+ * @returns {Promise<INodePropertyOptions[]>}
27
+ * @memberof LoadNodeParameterOptions
28
+ */
29
+ getOptionsViaMethodName(methodName: string, additionalData: IWorkflowExecuteAdditionalData): Promise<INodePropertyOptions[]>;
30
+ /**
31
+ * Returns the available options via a load request informatoin
32
+ *
33
+ * @param {ILoadOptions} loadOptions The load options which also contain the request information
34
+ * @param {IWorkflowExecuteAdditionalData} additionalData
35
+ * @returns {Promise<INodePropertyOptions[]>}
36
+ * @memberof LoadNodeParameterOptions
37
+ */
38
+ getOptionsViaRequestProperty(loadOptions: ILoadOptions, additionalData: IWorkflowExecuteAdditionalData): Promise<INodePropertyOptions[]>;
39
+ }
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ /* eslint-disable no-restricted-syntax */
3
+ /* eslint-disable @typescript-eslint/no-unsafe-return */
4
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
5
+ /* eslint-disable @typescript-eslint/restrict-template-expressions */
6
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
7
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
8
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.LoadNodeParameterOptions = void 0;
11
+ const workflow_1 = require("@fsai-flow/workflow");
12
+ // eslint-disable-next-line import/no-cycle
13
+ const __1 = require("..");
14
+ const TEMP_NODE_NAME = "Temp-Node";
15
+ const TEMP_WORKFLOW_NAME = "Temp-Workflow";
16
+ class LoadNodeParameterOptions {
17
+ constructor(nodeTypeNameAndVersion, nodeTypes, path, currentNodeParameters, credentials) {
18
+ const nodeType = nodeTypes.getByNameAndVersion(nodeTypeNameAndVersion.name, nodeTypeNameAndVersion.version);
19
+ this.currentNodeParameters = currentNodeParameters;
20
+ this.path = path;
21
+ if (nodeType === undefined) {
22
+ throw new Error(`The node-type "${nodeTypeNameAndVersion.name} v${nodeTypeNameAndVersion.version}" is not known!`);
23
+ }
24
+ const nodeData = {
25
+ parameters: currentNodeParameters,
26
+ name: TEMP_NODE_NAME,
27
+ type: nodeTypeNameAndVersion.name,
28
+ typeVersion: nodeTypeNameAndVersion.version,
29
+ position: [0, 0],
30
+ id: "",
31
+ };
32
+ if (credentials) {
33
+ nodeData.credentials = credentials;
34
+ }
35
+ const workflowData = {
36
+ nodes: [nodeData],
37
+ connections: {},
38
+ };
39
+ this.workflow = new workflow_1.Workflow({
40
+ nodes: workflowData.nodes,
41
+ connections: workflowData.connections,
42
+ active: false,
43
+ nodeTypes,
44
+ });
45
+ }
46
+ /**
47
+ * Returns data of a fake workflow
48
+ *
49
+ * @returns
50
+ * @memberof LoadNodeParameterOptions
51
+ */
52
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
53
+ getWorkflowData() {
54
+ return {
55
+ name: TEMP_WORKFLOW_NAME,
56
+ active: false,
57
+ connections: {},
58
+ nodes: Object.values(this.workflow.nodes),
59
+ createdAt: new Date(),
60
+ updatedAt: new Date(),
61
+ };
62
+ }
63
+ /**
64
+ * Returns the available options via a predefined method
65
+ *
66
+ * @param {string} methodName The name of the method of which to get the data from
67
+ * @param {IWorkflowExecuteAdditionalData} additionalData
68
+ * @returns {Promise<INodePropertyOptions[]>}
69
+ * @memberof LoadNodeParameterOptions
70
+ */
71
+ async getOptionsViaMethodName(methodName, additionalData) {
72
+ const node = this.workflow.getNode(TEMP_NODE_NAME);
73
+ const nodeType = this.workflow.nodeTypes.getByNameAndVersion(node.type, node?.typeVersion);
74
+ if (!nodeType ||
75
+ nodeType.methods === undefined ||
76
+ nodeType.methods.loadOptions === undefined ||
77
+ nodeType.methods.loadOptions[methodName] === undefined) {
78
+ throw new Error(`The node-type "${node?.type}" does not have the method "${methodName}" defined!`);
79
+ }
80
+ const thisArgs = __1.NodeExecuteFunctions.getLoadOptionsFunctions(this.workflow, node, this.path, additionalData);
81
+ try {
82
+ return await nodeType.methods.loadOptions[methodName].call(thisArgs);
83
+ }
84
+ catch (error) {
85
+ return [
86
+ {
87
+ name: "Error trying to load options",
88
+ value: "",
89
+ description: error.message || "Error trying to load options.",
90
+ },
91
+ ];
92
+ }
93
+ }
94
+ /**
95
+ * Returns the available options via a load request informatoin
96
+ *
97
+ * @param {ILoadOptions} loadOptions The load options which also contain the request information
98
+ * @param {IWorkflowExecuteAdditionalData} additionalData
99
+ * @returns {Promise<INodePropertyOptions[]>}
100
+ * @memberof LoadNodeParameterOptions
101
+ */
102
+ async getOptionsViaRequestProperty(loadOptions, additionalData) {
103
+ const node = this.workflow.getNode(TEMP_NODE_NAME);
104
+ const nodeType = this.workflow.nodeTypes.getByNameAndVersion(node.type, node?.typeVersion);
105
+ if (nodeType === undefined ||
106
+ !nodeType.description.requestDefaults ||
107
+ !nodeType.description.requestDefaults.baseURL) {
108
+ // This in in here for now for security reasons.
109
+ // Background: As the full data for the request to make does get send, and the auth data
110
+ // will then be applied, would it be possible to retrieve that data like that. By at least
111
+ // requiring a baseURL to be defined can at least not a random server be called.
112
+ // In the future this code has to get improved that it does not use the request information from
113
+ // the request rather resolves it via the parameter-path and nodeType data.
114
+ throw new Error(`The node-type "${node?.type}" does not exist or does not have "requestDefaults.baseURL" defined!`);
115
+ }
116
+ const mode = "internal";
117
+ const runIndex = 0;
118
+ const connectionInputData = [];
119
+ const runExecutionData = { resultData: { runData: {} } };
120
+ const routingNode = new workflow_1.RoutingNode(this.workflow, node, connectionInputData, runExecutionData ?? null, additionalData, mode);
121
+ // Create copy of node-type with the single property we want to get the data off
122
+ const tempNode = {
123
+ ...nodeType,
124
+ ...{
125
+ description: {
126
+ ...nodeType.description,
127
+ properties: [
128
+ {
129
+ displayName: "",
130
+ type: "string",
131
+ name: "",
132
+ default: "",
133
+ routing: loadOptions.routing,
134
+ },
135
+ ],
136
+ },
137
+ },
138
+ };
139
+ const inputData = {
140
+ main: [[{ json: {} }]],
141
+ };
142
+ const optionsData = await routingNode.runNode(inputData, runIndex, tempNode, __1.NodeExecuteFunctions);
143
+ if (optionsData?.length === 0) {
144
+ return [];
145
+ }
146
+ if (!Array.isArray(optionsData)) {
147
+ throw new Error("The returned data is not an array!");
148
+ }
149
+ return optionsData[0].map((item) => item.json);
150
+ }
151
+ }
152
+ exports.LoadNodeParameterOptions = LoadNodeParameterOptions;
@@ -0,0 +1,225 @@
1
+ import { type CloseFunction, type IAdditionalCredentialOptions, type IAllExecuteFunctions, type IBinaryData, type ICredentialDataDecryptedObject, type IDataObject, type IExecuteFunctions, type IExecuteSingleFunctions, type IHttpRequestOptions, type INode, type INodeExecutionData, type INodeParameters, type INodeType, type IOAuth2Options, type IPollFunctions, type IRunExecutionData, type ISupplyDataFunctions, type ITaskDataConnections, type ITriggerFunctions, type IWebhookData, type IWebhookDescription, type IWebhookFunctions, type IWorkflowDataProxyAdditionalKeys, type IWorkflowExecuteAdditionalData, type IWorkflowMetadata, type NodeConnectionType, type NodeParameterValue, type Workflow, type WorkflowActivateMode, type WorkflowExecuteMode } from "@fsai-flow/workflow";
2
+ import { type ICredentialTestFunctions, type IHookFunctions, type ILoadOptionsFunctions } from "..";
3
+ import type { OptionsWithUri, OptionsWithUrl, RequestPromiseOptions } from "./RequestTypes";
4
+ /**
5
+ * Returns binary data buffer for given item index and property name.
6
+ *
7
+ * @export
8
+ * @param {ITaskDataConnections} inputData
9
+ * @param {number} itemIndex
10
+ * @param {string} propertyName
11
+ * @param {number} inputIndex
12
+ * @returns {Promise<Buffer>}
13
+ */
14
+ export declare function getBinaryDataBuffer(inputData: ITaskDataConnections, itemIndex: number, propertyName: string, inputIndex: number): Promise<Buffer>;
15
+ /**
16
+ * Takes a buffer and converts it into the format n8n uses. It encodes the binary data as
17
+ * base64 and adds metadata.
18
+ *
19
+ * @export
20
+ * @param {Buffer} binaryData
21
+ * @param {string} [filePath]
22
+ * @param {string} [mimeType]
23
+ * @returns {Promise<IBinaryData>}
24
+ */
25
+ export declare function prepareBinaryData(binaryData: Buffer, executionId: string, filePath?: string, mimeType?: string): Promise<IBinaryData>;
26
+ export declare function getCurrentOAuth2AccessToken(this: IAllExecuteFunctions, credentialsType: string, node: INode, additionalData: IWorkflowExecuteAdditionalData, oAuth2Options?: IOAuth2Options): Promise<string>;
27
+ export declare function requestOAuth2(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUri | RequestPromiseOptions | IHttpRequestOptions, node: INode, additionalData: IWorkflowExecuteAdditionalData, oAuth2Options?: IOAuth2Options, isN8nRequest?: boolean): Promise<unknown>;
28
+ export declare function requestOAuth1(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUrl | OptionsWithUri | RequestPromiseOptions | IHttpRequestOptions, isN8nRequest?: boolean): Promise<unknown>;
29
+ export declare function httpRequestWithAuthentication(this: IAllExecuteFunctions, credentialsType: string, requestOptions: IHttpRequestOptions, workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, additionalCredentialOptions?: IAdditionalCredentialOptions): Promise<unknown>;
30
+ /**
31
+ * Takes generic input data and brings it into the json format n8n uses.
32
+ *
33
+ * @export
34
+ * @param {(IDataObject | IDataObject[])} jsonData
35
+ * @returns {INodeExecutionData[]}
36
+ */
37
+ export declare function returnJsonArray(jsonData: IDataObject | IDataObject[]): INodeExecutionData[];
38
+ /**
39
+ * Automatically put the objects under a 'json' key and don't error,
40
+ * if some objects contain json/binary keys and others don't, throws error 'Inconsistent item format'
41
+ *
42
+ * @export
43
+ * @param {INodeExecutionData | INodeExecutionData[]} executionData
44
+ * @returns {INodeExecutionData[]}
45
+ */
46
+ export declare function normalizeItems(executionData: INodeExecutionData | INodeExecutionData[]): INodeExecutionData[];
47
+ export declare function requestWithAuthentication(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUri | RequestPromiseOptions, workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, additionalCredentialOptions?: IAdditionalCredentialOptions): Promise<unknown>;
48
+ /**
49
+ * Returns the additional keys for Expressions and Function-Nodes
50
+ *
51
+ * @export
52
+ * @param {IWorkflowExecuteAdditionalData} additionalData
53
+ * @returns {(IWorkflowDataProxyAdditionalKeys)}
54
+ */
55
+ export declare function getAdditionalKeys(additionalData: IWorkflowExecuteAdditionalData): IWorkflowDataProxyAdditionalKeys;
56
+ /**
57
+ * Returns the requested decrypted credentials if the node has access to them.
58
+ *
59
+ * @export
60
+ * @param {Workflow} workflow Workflow which requests the data
61
+ * @param {INode} node Node which request the data
62
+ * @param {string} type The credential type to return
63
+ * @param {IWorkflowExecuteAdditionalData} additionalData
64
+ * @returns {(ICredentialDataDecryptedObject | undefined)}
65
+ */
66
+ export declare function getCredentials(workflow: Workflow, node: INode, type: string, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, runExecutionData?: IRunExecutionData | null, runIndex?: number, connectionInputData?: INodeExecutionData[], itemIndex?: number): Promise<ICredentialDataDecryptedObject | undefined>;
67
+ /**
68
+ * Returns a copy of the node
69
+ *
70
+ * @export
71
+ * @param {INode} node
72
+ * @returns {INode}
73
+ */
74
+ export declare function getNode(node: INode): INode;
75
+ /**
76
+ * Returns the requested resolved (all expressions replaced) node parameters.
77
+ *
78
+ * @export
79
+ * @param {Workflow} workflow
80
+ * @param {(IRunExecutionData | null)} runExecutionData
81
+ * @param {number} runIndex
82
+ * @param {INodeExecutionData[]} connectionInputData
83
+ * @param {INode} node
84
+ * @param {string} parameterName
85
+ * @param {number} itemIndex
86
+ * @param {*} [fallbackValue]
87
+ * @returns {(NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object)}
88
+ */
89
+ export declare function getNodeParameter(workflow: Workflow, runExecutionData: IRunExecutionData | null, runIndex: number, connectionInputData: INodeExecutionData[], node: INode, parameterName: string, itemIndex: number, mode: WorkflowExecuteMode, additionalKeys: IWorkflowDataProxyAdditionalKeys, fallbackValue?: unknown): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object;
90
+ /**
91
+ * Returns if execution should be continued even if there was an error.
92
+ *
93
+ * @export
94
+ * @param {INode} node
95
+ * @returns {boolean}
96
+ */
97
+ export declare function continueOnFail(node: INode): boolean;
98
+ /**
99
+ * Returns the webhook URL of the webhook with the given name
100
+ *
101
+ * @export
102
+ * @param {string} name
103
+ * @param {Workflow} workflow
104
+ * @param {INode} node
105
+ * @param {IWorkflowExecuteAdditionalData} additionalData
106
+ * @param {boolean} [isTest]
107
+ * @returns {(string | undefined)}
108
+ */
109
+ export declare function getNodeWebhookUrl(name: string, workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, additionalKeys: IWorkflowDataProxyAdditionalKeys, isTest?: boolean): string | undefined;
110
+ /**
111
+ * Returns the timezone for the workflow
112
+ *
113
+ * @export
114
+ * @param {Workflow} workflow
115
+ * @param {IWorkflowExecuteAdditionalData} additionalData
116
+ * @returns {string}
117
+ */
118
+ export declare function getTimezone(workflow: Workflow, additionalData: IWorkflowExecuteAdditionalData): string;
119
+ /**
120
+ * Returns the full webhook description of the webhook with the given name
121
+ *
122
+ * @export
123
+ * @param {string} name
124
+ * @param {Workflow} workflow
125
+ * @param {INode} node
126
+ * @returns {(IWebhookDescription | undefined)}
127
+ */
128
+ export declare function getWebhookDescription(name: string, workflow: Workflow, node: INode): IWebhookDescription | undefined;
129
+ /**
130
+ * Returns the workflow metadata
131
+ *
132
+ * @export
133
+ * @param {Workflow} workflow
134
+ * @returns {IWorkflowMetadata}
135
+ */
136
+ export declare function getWorkflowMetadata(workflow: Workflow): IWorkflowMetadata;
137
+ /**
138
+ * Returns the execute functions the poll nodes have access to.
139
+ *
140
+ * @export
141
+ * @param {Workflow} workflow
142
+ * @param {INode} node
143
+ * @param {IWorkflowExecuteAdditionalData} additionalData
144
+ * @param {WorkflowExecuteMode} mode
145
+ * @returns {ITriggerFunctions}
146
+ */
147
+ export declare function getExecutePollFunctions(workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, activation: WorkflowActivateMode): IPollFunctions;
148
+ /**
149
+ * Returns the execute functions the trigger nodes have access to.
150
+ *
151
+ * @export
152
+ * @param {Workflow} workflow
153
+ * @param {INode} node
154
+ * @param {IWorkflowExecuteAdditionalData} additionalData
155
+ * @param {WorkflowExecuteMode} mode
156
+ * @returns {ITriggerFunctions}
157
+ */
158
+ export declare function getExecuteTriggerFunctions(workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, activation: WorkflowActivateMode): ITriggerFunctions;
159
+ /**
160
+ * Returns the execute functions regular nodes have access to.
161
+ *
162
+ * @export
163
+ * @param {Workflow} workflow
164
+ * @param {IRunExecutionData} runExecutionData
165
+ * @param {number} runIndex
166
+ * @param {INodeExecutionData[]} connectionInputData
167
+ * @param {ITaskDataConnections} inputData
168
+ * @param {INode} node
169
+ * @param {IWorkflowExecuteAdditionalData} additionalData
170
+ * @param {WorkflowExecuteMode} mode
171
+ * @returns {IExecuteFunctions}
172
+ */
173
+ export declare function getExecuteFunctions(workflow: Workflow, runExecutionData: IRunExecutionData, runIndex: number, connectionInputData: INodeExecutionData[], inputData: ITaskDataConnections, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, nodeTypeData: INodeType, closeFunctions: CloseFunction[]): IExecuteFunctions;
174
+ /**
175
+ * Returns the execute functions regular nodes have access to when single-function is defined.
176
+ *
177
+ * @export
178
+ * @param {Workflow} workflow
179
+ * @param {IRunExecutionData} runExecutionData
180
+ * @param {number} runIndex
181
+ * @param {INodeExecutionData[]} connectionInputData
182
+ * @param {ITaskDataConnections} inputData
183
+ * @param {INode} node
184
+ * @param {number} itemIndex
185
+ * @param {IWorkflowExecuteAdditionalData} additionalData
186
+ * @param {WorkflowExecuteMode} mode
187
+ * @returns {IExecuteSingleFunctions}
188
+ */
189
+ export declare function getExecuteSingleFunctions(workflow: Workflow, runExecutionData: IRunExecutionData, runIndex: number, connectionInputData: INodeExecutionData[], inputData: ITaskDataConnections, node: INode, itemIndex: number, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode): IExecuteSingleFunctions;
190
+ export declare function getCredentialTestFunctions(): ICredentialTestFunctions;
191
+ /**
192
+ * Returns the execute functions regular nodes have access to in load-options-function.
193
+ *
194
+ * @export
195
+ * @param {Workflow} workflow
196
+ * @param {INode} node
197
+ * @param {IWorkflowExecuteAdditionalData} additionalData
198
+ * @returns {ILoadOptionsFunctions}
199
+ */
200
+ export declare function getLoadOptionsFunctions(workflow: Workflow, node: INode, path: string, additionalData: IWorkflowExecuteAdditionalData): ILoadOptionsFunctions;
201
+ /**
202
+ * Returns the execute functions regular nodes have access to in hook-function.
203
+ *
204
+ * @export
205
+ * @param {Workflow} workflow
206
+ * @param {INode} node
207
+ * @param {IWorkflowExecuteAdditionalData} additionalData
208
+ * @param {WorkflowExecuteMode} mode
209
+ * @returns {IHookFunctions}
210
+ */
211
+ export declare function getExecuteHookFunctions(workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, activation: WorkflowActivateMode, isTest?: boolean, webhookData?: IWebhookData): IHookFunctions;
212
+ /**
213
+ * Returns the execute functions regular nodes have access to when webhook-function is defined.
214
+ *
215
+ * @export
216
+ * @param {Workflow} workflow
217
+ * @param {IRunExecutionData} runExecutionData
218
+ * @param {INode} node
219
+ * @param {IWorkflowExecuteAdditionalData} additionalData
220
+ * @param {WorkflowExecuteMode} mode
221
+ * @returns {IWebhookFunctions}
222
+ */
223
+ export declare function getExecuteWebhookFunctions(workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, webhookData: IWebhookData, initialRunExecutionData: IRunExecutionData | undefined): IWebhookFunctions;
224
+ export declare function getSupplyDataFunctions(workflow: Workflow, runExecutionData: IRunExecutionData, runIndex: number, connectionInputData: INodeExecutionData[], inputData: ITaskDataConnections, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, nodeTypeData: INodeType, closeFunctions: CloseFunction[]): ISupplyDataFunctions;
225
+ export declare function getInputConnectionData(this: IExecuteFunctions | ISupplyDataFunctions, workflow: Workflow, runExecutionData: IRunExecutionData, runIndex: number, connectionInputData: INodeExecutionData[], inputData: ITaskDataConnections, additionalData: IWorkflowExecuteAdditionalData, connectionType: NodeConnectionType, mode: WorkflowExecuteMode, itemIndex: number, nodeTypeData: INodeType, closeFunctions: CloseFunction[]): Promise<unknown>;