@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.
Files changed (113) hide show
  1. package/README.md +11 -0
  2. package/dist/README.md +11 -0
  3. package/dist/package.json +44 -0
  4. package/dist/src/index.d.ts +15 -0
  5. package/dist/src/index.js +29 -0
  6. package/dist/src/index.js.map +1 -0
  7. package/dist/src/lib/ActiveWebhooks.d.ts +59 -0
  8. package/dist/src/lib/ActiveWebhooks.js +184 -0
  9. package/dist/src/lib/ActiveWebhooks.js.map +1 -0
  10. package/dist/src/lib/ActiveWorkflows.d.ts +58 -0
  11. package/dist/src/lib/ActiveWorkflows.js +244 -0
  12. package/dist/src/lib/ActiveWorkflows.js.map +1 -0
  13. package/dist/src/lib/BinaryDataManager/FileSystem.d.ts +26 -0
  14. package/dist/src/lib/BinaryDataManager/FileSystem.js +179 -0
  15. package/dist/src/lib/BinaryDataManager/FileSystem.js.map +1 -0
  16. package/dist/src/lib/BinaryDataManager/index.d.ts +21 -0
  17. package/dist/src/lib/BinaryDataManager/index.js +146 -0
  18. package/dist/src/lib/BinaryDataManager/index.js.map +1 -0
  19. package/dist/src/lib/ChangeCase.d.ts +9 -0
  20. package/dist/src/lib/ChangeCase.js +43 -0
  21. package/dist/src/lib/ChangeCase.js.map +1 -0
  22. package/dist/src/lib/Constants.d.ts +14 -0
  23. package/dist/src/lib/Constants.js +19 -0
  24. package/dist/src/lib/Constants.js.map +1 -0
  25. package/dist/src/lib/Credentials.d.ts +27 -0
  26. package/dist/src/lib/Credentials.js +89 -0
  27. package/dist/src/lib/Credentials.js.map +1 -0
  28. package/dist/src/lib/FileSystem.d.ts +26 -0
  29. package/dist/src/lib/FileSystem.js +179 -0
  30. package/dist/src/lib/FileSystem.js.map +1 -0
  31. package/dist/src/lib/InputConnectionDataLegacy.d.ts +2 -0
  32. package/dist/src/lib/InputConnectionDataLegacy.js +79 -0
  33. package/dist/src/lib/InputConnectionDataLegacy.js.map +1 -0
  34. package/dist/src/lib/Interfaces.d.ts +148 -0
  35. package/dist/src/lib/Interfaces.js +3 -0
  36. package/dist/src/lib/Interfaces.js.map +1 -0
  37. package/dist/src/lib/LoadNodeParameterOptions.d.ts +39 -0
  38. package/dist/src/lib/LoadNodeParameterOptions.js +150 -0
  39. package/dist/src/lib/LoadNodeParameterOptions.js.map +1 -0
  40. package/dist/src/lib/NodeExecuteFunctions.d.ts +226 -0
  41. package/dist/src/lib/NodeExecuteFunctions.js +2483 -0
  42. package/dist/src/lib/NodeExecuteFunctions.js.map +1 -0
  43. package/dist/src/lib/NodesLoader/constants.d.ts +5 -0
  44. package/dist/src/lib/NodesLoader/constants.js +106 -0
  45. package/dist/src/lib/NodesLoader/constants.js.map +1 -0
  46. package/dist/src/lib/NodesLoader/custom-directory-loader.d.ts +9 -0
  47. package/dist/src/lib/NodesLoader/custom-directory-loader.js +36 -0
  48. package/dist/src/lib/NodesLoader/custom-directory-loader.js.map +1 -0
  49. package/dist/src/lib/NodesLoader/directory-loader.d.ts +66 -0
  50. package/dist/src/lib/NodesLoader/directory-loader.js +325 -0
  51. package/dist/src/lib/NodesLoader/directory-loader.js.map +1 -0
  52. package/dist/src/lib/NodesLoader/index.d.ts +5 -0
  53. package/dist/src/lib/NodesLoader/index.js +12 -0
  54. package/dist/src/lib/NodesLoader/index.js.map +1 -0
  55. package/dist/src/lib/NodesLoader/lazy-package-directory-loader.d.ts +7 -0
  56. package/dist/src/lib/NodesLoader/lazy-package-directory-loader.js +52 -0
  57. package/dist/src/lib/NodesLoader/lazy-package-directory-loader.js.map +1 -0
  58. package/dist/src/lib/NodesLoader/load-class-in-isolation.d.ts +1 -0
  59. package/dist/src/lib/NodesLoader/load-class-in-isolation.js +22 -0
  60. package/dist/src/lib/NodesLoader/load-class-in-isolation.js.map +1 -0
  61. package/dist/src/lib/NodesLoader/package-directory-loader.d.ts +17 -0
  62. package/dist/src/lib/NodesLoader/package-directory-loader.js +100 -0
  63. package/dist/src/lib/NodesLoader/package-directory-loader.js.map +1 -0
  64. package/dist/src/lib/NodesLoader/types.d.ts +14 -0
  65. package/dist/src/lib/NodesLoader/types.js +3 -0
  66. package/dist/src/lib/NodesLoader/types.js.map +1 -0
  67. package/dist/src/lib/UserSettings.d.ts +80 -0
  68. package/dist/src/lib/UserSettings.js +261 -0
  69. package/dist/src/lib/UserSettings.js.map +1 -0
  70. package/dist/src/lib/WorkflowExecute.d.ts +53 -0
  71. package/dist/src/lib/WorkflowExecute.js +835 -0
  72. package/dist/src/lib/WorkflowExecute.js.map +1 -0
  73. package/dist/src/lib/index.d.ts +21 -0
  74. package/dist/src/lib/index.js +146 -0
  75. package/dist/src/lib/index.js.map +1 -0
  76. package/dist/src/utils/crypto.d.ts +1 -0
  77. package/dist/src/utils/crypto.js +8 -0
  78. package/dist/src/utils/crypto.js.map +1 -0
  79. package/eslint.config.js +19 -0
  80. package/jest.config.ts +10 -0
  81. package/package.json +44 -0
  82. package/project.json +19 -0
  83. package/src/index.ts +27 -0
  84. package/src/lib/ActiveWebhooks.ts +245 -0
  85. package/src/lib/ActiveWorkflows.ts +304 -0
  86. package/src/lib/BinaryDataManager/FileSystem.ts +214 -0
  87. package/src/lib/BinaryDataManager/index.ts +187 -0
  88. package/src/lib/ChangeCase.ts +45 -0
  89. package/src/lib/Constants.ts +16 -0
  90. package/src/lib/Credentials.ts +108 -0
  91. package/src/lib/FileSystem.ts +214 -0
  92. package/src/lib/InputConnectionDataLegacy.ts +123 -0
  93. package/src/lib/Interfaces.ts +338 -0
  94. package/src/lib/LoadNodeParameterOptions.ts +235 -0
  95. package/src/lib/NodeExecuteFunctions.ts +3704 -0
  96. package/src/lib/NodesLoader/constants.ts +112 -0
  97. package/src/lib/NodesLoader/custom-directory-loader.ts +31 -0
  98. package/src/lib/NodesLoader/directory-loader.ts +458 -0
  99. package/src/lib/NodesLoader/index.ts +5 -0
  100. package/src/lib/NodesLoader/lazy-package-directory-loader.ts +55 -0
  101. package/src/lib/NodesLoader/load-class-in-isolation.ts +19 -0
  102. package/src/lib/NodesLoader/package-directory-loader.ts +107 -0
  103. package/src/lib/NodesLoader/types.ts +14 -0
  104. package/src/lib/UserSettings.ts +292 -0
  105. package/src/lib/WorkflowExecute.ts +1108 -0
  106. package/src/lib/index.ts +187 -0
  107. package/src/utils/crypto.ts +5 -0
  108. package/tests/Credentials.test.ts +88 -0
  109. package/tests/Helpers.ts +808 -0
  110. package/tests/WorkflowExecute.test.ts +1242 -0
  111. package/tsconfig.json +42 -0
  112. package/tsconfig.lib.json +10 -0
  113. package/tsconfig.spec.json +14 -0
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # core
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build core` to build the library.
8
+
9
+ ## Running unit tests
10
+
11
+ Run `nx test core` to execute the unit tests via [Jest](https://jestjs.io).
package/dist/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # core
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build core` to build the library.
8
+
9
+ ## Running unit tests
10
+
11
+ Run `nx test core` to execute the unit tests via [Jest](https://jestjs.io).
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@fsai-flow/core",
3
+ "version": "0.0.1",
4
+ "dependencies": {
5
+ "@fsai-flow/workflow": "workspace:^",
6
+ "client-oauth2": "^4.3.3",
7
+ "cron": "~3.3.0",
8
+ "crypto-js": "~4.2.0",
9
+ "file-type": "^16.0.0",
10
+ "form-data": "^4.0.0",
11
+ "https-proxy-agent": "^7.0.6",
12
+ "lodash": "^4.17.21",
13
+ "mime-types": "^2.1.27",
14
+ "oauth-1.0a": "^2.2.6",
15
+ "p-cancelable": "^2.0.0",
16
+ "qs": "^6.10.1",
17
+ "request": "^2.88.2",
18
+ "request-promise-native": "^1.0.9",
19
+ "simple-oauth2": "^5.1.0",
20
+ "tslib": "^2.3.0",
21
+ "uuid": "^11.0.3",
22
+ "fast-glob": "catalog:"
23
+ },
24
+ "devDependencies": {
25
+ "@types/crypto-js": "^4.0.1",
26
+ "@types/express": "^5.0.0",
27
+ "@types/lodash": "^4.17.13",
28
+ "@types/lodash.get": "^4.4.9",
29
+ "@types/mime-types": "^2.1.0",
30
+ "@types/node": "^22.10.2",
31
+ "@types/qs": "^6.9.17",
32
+ "@types/request": "^2.48.12",
33
+ "@types/request-promise-native": "^1.0.15",
34
+ "@types/simple-oauth2": "^5.0.7",
35
+ "@types/uuid": "^10.0.0",
36
+ "axios": "^1.7.9",
37
+ "jsonc-eslint-parser": "^2.4.0",
38
+ "typescript": "~5.7.2"
39
+ },
40
+ "type": "commonjs",
41
+ "main": "dist/src/index",
42
+ "types": "dist/src/index.d.ts",
43
+ "private": true
44
+ }
@@ -0,0 +1,15 @@
1
+ import * as NodeExecuteFunctions from './lib/NodeExecuteFunctions';
2
+ import * as UserSettings from './lib/UserSettings';
3
+ import * as getInputConnectionDataLegacy from './lib/InputConnectionDataLegacy';
4
+ export * from './lib/ActiveWorkflows';
5
+ export * from './lib/ActiveWebhooks';
6
+ export * from './lib/BinaryDataManager';
7
+ export * from './lib/Constants';
8
+ export * from './lib/Credentials';
9
+ export * from './lib/Interfaces';
10
+ export * from './lib/LoadNodeParameterOptions';
11
+ export * from './lib/NodeExecuteFunctions';
12
+ export * from './lib/WorkflowExecute';
13
+ export * from './lib/ChangeCase';
14
+ export * from './lib/NodesLoader';
15
+ export { NodeExecuteFunctions, UserSettings, getInputConnectionDataLegacy };
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getInputConnectionDataLegacy = exports.UserSettings = exports.NodeExecuteFunctions = void 0;
4
+ const tslib_1 = require("tslib");
5
+ /* eslint-disable import/no-cycle */
6
+ const NodeExecuteFunctions = tslib_1.__importStar(require("./lib/NodeExecuteFunctions"));
7
+ exports.NodeExecuteFunctions = NodeExecuteFunctions;
8
+ const UserSettings = tslib_1.__importStar(require("./lib/UserSettings"));
9
+ exports.UserSettings = UserSettings;
10
+ const getInputConnectionDataLegacy = tslib_1.__importStar(require("./lib/InputConnectionDataLegacy"));
11
+ exports.getInputConnectionDataLegacy = getInputConnectionDataLegacy;
12
+ try {
13
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, import/no-extraneous-dependencies, global-require, @typescript-eslint/no-var-requires
14
+ require('source-map-support').install();
15
+ // eslint-disable-next-line no-empty
16
+ }
17
+ catch (error) { }
18
+ tslib_1.__exportStar(require("./lib/ActiveWorkflows"), exports);
19
+ tslib_1.__exportStar(require("./lib/ActiveWebhooks"), exports);
20
+ tslib_1.__exportStar(require("./lib/BinaryDataManager"), exports);
21
+ tslib_1.__exportStar(require("./lib/Constants"), exports);
22
+ tslib_1.__exportStar(require("./lib/Credentials"), exports);
23
+ tslib_1.__exportStar(require("./lib/Interfaces"), exports);
24
+ tslib_1.__exportStar(require("./lib/LoadNodeParameterOptions"), exports);
25
+ tslib_1.__exportStar(require("./lib/NodeExecuteFunctions"), exports);
26
+ tslib_1.__exportStar(require("./lib/WorkflowExecute"), exports);
27
+ tslib_1.__exportStar(require("./lib/ChangeCase"), exports);
28
+ tslib_1.__exportStar(require("./lib/NodesLoader"), exports);
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,oCAAoC;AACpC,yFAAmE;AAsBlE,oDAAoB;AArBrB,yEAAmD;AAsBlD,oCAAY;AArBb,sGAAgF;AAsB/E,oEAA4B;AApB7B,IAAI,CAAC;IACJ,gMAAgM;IAChM,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,EAAE,CAAC;IACxC,oCAAoC;AACrC,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC,CAAA,CAAC;AAElB,gEAAsC;AACtC,+DAAqC;AACrC,kEAAwC;AACxC,0DAAgC;AAChC,4DAAkC;AAClC,2DAAiC;AACjC,yEAA+C;AAC/C,qEAA2C;AAC3C,gEAAsC;AACtC,2DAAiC;AACjC,4DAAkC"}
@@ -0,0 +1,59 @@
1
+ import { IWebhookData, WebhookHttpMethod, Workflow, WorkflowActivateMode, WorkflowExecuteMode } from '@fsai-flow/workflow';
2
+ export declare class ActiveWebhooks {
3
+ private workflowWebhooks;
4
+ private webhookUrls;
5
+ testWebhooks: boolean;
6
+ /**
7
+ * Adds a new webhook
8
+ *
9
+ * @param {IWebhookData} webhookData
10
+ * @param {WorkflowExecuteMode} mode
11
+ * @returns {Promise<void>}
12
+ * @memberof ActiveWebhooks
13
+ */
14
+ add(workflow: Workflow, webhookData: IWebhookData, mode: WorkflowExecuteMode, activation: WorkflowActivateMode): Promise<void>;
15
+ /**
16
+ * Returns webhookData if a webhook with matches is currently registered
17
+ *
18
+ * @param {WebhookHttpMethod} httpMethod
19
+ * @param {string} path
20
+ * @param {(string | undefined)} webhookId
21
+ * @returns {(IWebhookData | undefined)}
22
+ * @memberof ActiveWebhooks
23
+ */
24
+ get(httpMethod: WebhookHttpMethod, path: string, webhookId?: string): IWebhookData | undefined;
25
+ /**
26
+ * Gets all request methods associated with a single webhook
27
+ * @param path
28
+ */
29
+ getWebhookMethods(path: string): string[];
30
+ /**
31
+ * Returns the ids of all the workflows which have active webhooks
32
+ *
33
+ * @returns {string[]}
34
+ * @memberof ActiveWebhooks
35
+ */
36
+ getWorkflowIds(): string[];
37
+ /**
38
+ * Returns key to uniquely identify a webhook
39
+ *
40
+ * @param {WebhookHttpMethod} httpMethod
41
+ * @param {string} path
42
+ * @param {(string | undefined)} webhookId
43
+ * @returns {string}
44
+ * @memberof ActiveWebhooks
45
+ */
46
+ getWebhookKey(httpMethod: WebhookHttpMethod, path: string, webhookId?: string): string;
47
+ /**
48
+ * Removes all webhooks of a workflow
49
+ *
50
+ * @param {Workflow} workflow
51
+ * @returns {boolean}
52
+ * @memberof ActiveWebhooks
53
+ */
54
+ removeWorkflow(workflow: Workflow): Promise<boolean>;
55
+ /**
56
+ * Removes all the webhooks of the given workflows
57
+ */
58
+ removeAll(workflows: Workflow[]): Promise<void>;
59
+ }
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActiveWebhooks = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // eslint-disable-next-line import/no-cycle
6
+ const src_1 = require("../../src");
7
+ class ActiveWebhooks {
8
+ constructor() {
9
+ this.workflowWebhooks = {};
10
+ this.webhookUrls = {};
11
+ this.testWebhooks = false;
12
+ }
13
+ /**
14
+ * Adds a new webhook
15
+ *
16
+ * @param {IWebhookData} webhookData
17
+ * @param {WorkflowExecuteMode} mode
18
+ * @returns {Promise<void>}
19
+ * @memberof ActiveWebhooks
20
+ */
21
+ add(workflow, webhookData, mode, activation) {
22
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
23
+ if (workflow.id === undefined) {
24
+ throw new Error('Webhooks can only be added for saved workflows as an id is needed!');
25
+ }
26
+ if (webhookData.path.endsWith('/')) {
27
+ // eslint-disable-next-line no-param-reassign
28
+ webhookData.path = webhookData.path.slice(0, -1);
29
+ }
30
+ const webhookKey = this.getWebhookKey(webhookData.httpMethod, webhookData.path, webhookData.webhookId);
31
+ // check that there is not a webhook already registed with that path/method
32
+ if (this.webhookUrls[webhookKey] && !webhookData.webhookId) {
33
+ throw new Error(`The URL path that the "${webhookData.node}" node uses is already taken. Please change it to something else.`);
34
+ }
35
+ if (this.workflowWebhooks[webhookData.workflowId] === undefined) {
36
+ this.workflowWebhooks[webhookData.workflowId] = [];
37
+ }
38
+ // Make the webhook available directly because sometimes to create it successfully
39
+ // it gets called
40
+ if (!this.webhookUrls[webhookKey]) {
41
+ this.webhookUrls[webhookKey] = [];
42
+ }
43
+ this.webhookUrls[webhookKey].push(webhookData);
44
+ try {
45
+ const webhookExists = yield workflow.runWebhookMethod('checkExists', webhookData, src_1.NodeExecuteFunctions, mode, activation, this.testWebhooks);
46
+ if (webhookExists !== true) {
47
+ // If webhook does not exist yet create it
48
+ yield workflow.runWebhookMethod('create', webhookData, src_1.NodeExecuteFunctions, mode, activation, this.testWebhooks);
49
+ }
50
+ }
51
+ catch (error) {
52
+ // If there was a problem unregister the webhook again
53
+ if (this.webhookUrls[webhookKey].length <= 1) {
54
+ delete this.webhookUrls[webhookKey];
55
+ }
56
+ else {
57
+ this.webhookUrls[webhookKey] = this.webhookUrls[webhookKey].filter((webhook) => webhook.path !== webhookData.path);
58
+ }
59
+ throw error;
60
+ }
61
+ this.workflowWebhooks[webhookData.workflowId].push(webhookData);
62
+ });
63
+ }
64
+ /**
65
+ * Returns webhookData if a webhook with matches is currently registered
66
+ *
67
+ * @param {WebhookHttpMethod} httpMethod
68
+ * @param {string} path
69
+ * @param {(string | undefined)} webhookId
70
+ * @returns {(IWebhookData | undefined)}
71
+ * @memberof ActiveWebhooks
72
+ */
73
+ get(httpMethod, path, webhookId) {
74
+ const webhookKey = this.getWebhookKey(httpMethod, path, webhookId);
75
+ if (this.webhookUrls[webhookKey] === undefined) {
76
+ return undefined;
77
+ }
78
+ let webhook;
79
+ let maxMatches = 0;
80
+ const pathElementsSet = new Set(path.split('/'));
81
+ // check if static elements match in path
82
+ // if more results have been returned choose the one with the most static-route matches
83
+ this.webhookUrls[webhookKey].forEach((dynamicWebhook) => {
84
+ const staticElements = dynamicWebhook.path.split('/').filter((ele) => !ele.startsWith(':'));
85
+ const allStaticExist = staticElements.every((staticEle) => pathElementsSet.has(staticEle));
86
+ if (allStaticExist && staticElements.length > maxMatches) {
87
+ maxMatches = staticElements.length;
88
+ webhook = dynamicWebhook;
89
+ }
90
+ // handle routes with no static elements
91
+ else if (staticElements.length === 0 && !webhook) {
92
+ webhook = dynamicWebhook;
93
+ }
94
+ });
95
+ return webhook;
96
+ }
97
+ /**
98
+ * Gets all request methods associated with a single webhook
99
+ * @param path
100
+ */
101
+ getWebhookMethods(path) {
102
+ const methods = [];
103
+ Object.keys(this.webhookUrls)
104
+ .filter((key) => key.includes(path))
105
+ // eslint-disable-next-line array-callback-return
106
+ .map((key) => {
107
+ methods.push(key.split('|')[0]);
108
+ });
109
+ return methods;
110
+ }
111
+ /**
112
+ * Returns the ids of all the workflows which have active webhooks
113
+ *
114
+ * @returns {string[]}
115
+ * @memberof ActiveWebhooks
116
+ */
117
+ getWorkflowIds() {
118
+ return Object.keys(this.workflowWebhooks);
119
+ }
120
+ /**
121
+ * Returns key to uniquely identify a webhook
122
+ *
123
+ * @param {WebhookHttpMethod} httpMethod
124
+ * @param {string} path
125
+ * @param {(string | undefined)} webhookId
126
+ * @returns {string}
127
+ * @memberof ActiveWebhooks
128
+ */
129
+ getWebhookKey(httpMethod, path, webhookId) {
130
+ if (webhookId) {
131
+ if (path.startsWith(webhookId)) {
132
+ const cutFromIndex = path.indexOf('/') + 1;
133
+ // eslint-disable-next-line no-param-reassign
134
+ path = path.slice(cutFromIndex);
135
+ }
136
+ return `${httpMethod}|${webhookId}|${path.split('/').length}`;
137
+ }
138
+ return `${httpMethod}|${path}`;
139
+ }
140
+ /**
141
+ * Removes all webhooks of a workflow
142
+ *
143
+ * @param {Workflow} workflow
144
+ * @returns {boolean}
145
+ * @memberof ActiveWebhooks
146
+ */
147
+ removeWorkflow(workflow) {
148
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
149
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
150
+ const workflowId = workflow.id.toString();
151
+ if (this.workflowWebhooks[workflowId] === undefined) {
152
+ // If it did not exist then there is nothing to remove
153
+ return false;
154
+ }
155
+ const webhooks = this.workflowWebhooks[workflowId];
156
+ const mode = 'internal';
157
+ // Go through all the registered webhooks of the workflow and remove them
158
+ // eslint-disable-next-line no-restricted-syntax
159
+ for (const webhookData of webhooks) {
160
+ // eslint-disable-next-line no-await-in-loop
161
+ yield workflow.runWebhookMethod('delete', webhookData, src_1.NodeExecuteFunctions, mode, 'update', this.testWebhooks);
162
+ delete this.webhookUrls[this.getWebhookKey(webhookData.httpMethod, webhookData.path, webhookData.webhookId)];
163
+ }
164
+ // Remove also the workflow-webhook entry
165
+ delete this.workflowWebhooks[workflowId];
166
+ return true;
167
+ });
168
+ }
169
+ /**
170
+ * Removes all the webhooks of the given workflows
171
+ */
172
+ removeAll(workflows) {
173
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
174
+ const removePromises = [];
175
+ // eslint-disable-next-line no-restricted-syntax
176
+ for (const workflow of workflows) {
177
+ removePromises.push(this.removeWorkflow(workflow));
178
+ }
179
+ yield Promise.all(removePromises);
180
+ });
181
+ }
182
+ }
183
+ exports.ActiveWebhooks = ActiveWebhooks;
184
+ //# sourceMappingURL=ActiveWebhooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActiveWebhooks.js","sourceRoot":"","sources":["../../../src/lib/ActiveWebhooks.ts"],"names":[],"mappings":";;;;AAQA,2CAA2C;AAC3C,mCAAiD;AAEjD,MAAa,cAAc;IAA3B;QACS,qBAAgB,GAEpB,EAAE,CAAC;QAEC,gBAAW,GAEf,EAAE,CAAC;QAEP,iBAAY,GAAG,KAAK,CAAC;IAgOtB,CAAC;IA9NA;;;;;;;OAOG;IACG,GAAG,CACR,QAAkB,EAClB,WAAyB,EACzB,IAAyB,EACzB,UAAgC;;YAEhC,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;gBAC/B,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;YACvF,CAAC;YACD,IAAI,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBACpC,6CAA6C;gBAC7C,WAAW,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAClD,CAAC;YAED,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CACpC,WAAW,CAAC,UAAU,EACtB,WAAW,CAAC,IAAI,EAChB,WAAW,CAAC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CAAC,CAAC;QACnC,CAAC;KAAA;CACD;AAzOD,wCAyOC"}
@@ -0,0 +1,58 @@
1
+ import { IGetExecutePollFunctions, IGetExecuteTriggerFunctions, INode, IPollResponse, IWorkflowExecuteAdditionalData, Workflow, WorkflowActivateMode, WorkflowExecuteMode } from '@fsai-flow/workflow';
2
+ import { IWorkflowData } from '../../src';
3
+ export declare class ActiveWorkflows {
4
+ private workflowData;
5
+ /**
6
+ * Returns if the workflow is active
7
+ *
8
+ * @param {string} id The id of the workflow to check
9
+ * @returns {boolean}
10
+ * @memberof ActiveWorkflows
11
+ */
12
+ isActive(id: string): boolean;
13
+ /**
14
+ * Returns the ids of the currently active workflows
15
+ *
16
+ * @returns {string[]}
17
+ * @memberof ActiveWorkflows
18
+ */
19
+ allActiveWorkflows(): string[];
20
+ /**
21
+ * Returns the Workflow data for the workflow with
22
+ * the given id if it is currently active
23
+ *
24
+ * @param {string} id
25
+ * @returns {(WorkflowData | undefined)}
26
+ * @memberof ActiveWorkflows
27
+ */
28
+ get(id: string): IWorkflowData | undefined;
29
+ /**
30
+ * Makes a workflow active
31
+ *
32
+ * @param {string} id The id of the workflow to activate
33
+ * @param {Workflow} workflow The workflow to activate
34
+ * @param {IWorkflowExecuteAdditionalData} additionalData The additional data which is needed to run workflows
35
+ * @returns {Promise<void>}
36
+ * @memberof ActiveWorkflows
37
+ */
38
+ add(id: string, workflow: Workflow, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, activation: WorkflowActivateMode, getTriggerFunctions: IGetExecuteTriggerFunctions, getPollFunctions: IGetExecutePollFunctions): Promise<void>;
39
+ /**
40
+ * Activates polling for the given node
41
+ *
42
+ * @param {INode} node
43
+ * @param {Workflow} workflow
44
+ * @param {IWorkflowExecuteAdditionalData} additionalData
45
+ * @param {IGetExecutePollFunctions} getPollFunctions
46
+ * @returns {Promise<IPollResponse>}
47
+ * @memberof ActiveWorkflows
48
+ */
49
+ activatePolling(node: INode, workflow: Workflow, additionalData: IWorkflowExecuteAdditionalData, getPollFunctions: IGetExecutePollFunctions, mode: WorkflowExecuteMode, activation: WorkflowActivateMode): Promise<IPollResponse>;
50
+ /**
51
+ * Makes a workflow inactive
52
+ *
53
+ * @param {string} id The id of the workflow to deactivate
54
+ * @returns {Promise<void>}
55
+ * @memberof ActiveWorkflows
56
+ */
57
+ remove(id: string): Promise<void>;
58
+ }