@fsai-flow/core 0.0.4 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/dist/index.d.ts +17 -0
  2. package/dist/index.js +61 -0
  3. package/dist/{src/lib → lib}/ActiveWebhooks.d.ts +1 -1
  4. package/dist/lib/ActiveWebhooks.js +177 -0
  5. package/dist/{src/lib → lib}/ActiveWorkflows.d.ts +3 -3
  6. package/dist/lib/ActiveWorkflows.js +465 -0
  7. package/dist/{src/lib → lib}/BinaryDataManager/FileSystem.d.ts +1 -1
  8. package/dist/lib/BinaryDataManager/FileSystem.js +180 -0
  9. package/dist/{src/lib → lib}/BinaryDataManager/index.d.ts +2 -2
  10. package/dist/lib/BinaryDataManager/index.js +129 -0
  11. package/dist/{src/lib → lib}/ChangeCase.js +11 -11
  12. package/dist/lib/Constants.js +18 -0
  13. package/dist/{src/lib → lib}/Credentials.d.ts +1 -1
  14. package/dist/{src/lib → lib}/Credentials.js +7 -8
  15. package/dist/{src/lib → lib}/FileSystem.d.ts +1 -1
  16. package/dist/lib/FileSystem.js +180 -0
  17. package/dist/{src/lib → lib}/InputConnectionDataLegacy.d.ts +1 -1
  18. package/dist/lib/InputConnectionDataLegacy.js +72 -0
  19. package/dist/{src/lib → lib}/Interfaces.d.ts +47 -48
  20. package/dist/{src/lib → lib}/Interfaces.js +0 -1
  21. package/dist/{src/lib → lib}/LoadNodeParameterOptions.d.ts +1 -1
  22. package/dist/lib/LoadNodeParameterOptions.js +152 -0
  23. package/dist/{src/lib → lib}/NodeExecuteFunctions.d.ts +9 -10
  24. package/dist/lib/NodeExecuteFunctions.js +2467 -0
  25. package/dist/{src/lib → lib}/NodesLoader/constants.d.ts +1 -1
  26. package/dist/lib/NodesLoader/constants.js +105 -0
  27. package/dist/{src/lib → lib}/NodesLoader/custom-directory-loader.d.ts +1 -1
  28. package/dist/lib/NodesLoader/custom-directory-loader.js +35 -0
  29. package/dist/{src/lib → lib}/NodesLoader/directory-loader.d.ts +1 -1
  30. package/dist/{src/lib → lib}/NodesLoader/directory-loader.js +80 -38
  31. package/dist/lib/NodesLoader/index.d.ts +5 -0
  32. package/dist/{src/lib → lib}/NodesLoader/index.js +5 -6
  33. package/dist/{src/lib → lib}/NodesLoader/lazy-package-directory-loader.d.ts +1 -1
  34. package/dist/lib/NodesLoader/lazy-package-directory-loader.js +44 -0
  35. package/dist/{src/lib → lib}/NodesLoader/load-class-in-isolation.js +6 -11
  36. package/dist/{src/lib → lib}/NodesLoader/package-directory-loader.d.ts +2 -2
  37. package/dist/{src/lib → lib}/NodesLoader/package-directory-loader.js +28 -36
  38. package/dist/{src/lib → lib}/NodesLoader/types.js +0 -1
  39. package/dist/{src/lib → lib}/RedisLeaderElectionManager.d.ts +1 -1
  40. package/dist/lib/RedisLeaderElectionManager.js +279 -0
  41. package/dist/lib/RequestTypes.d.ts +58 -0
  42. package/dist/lib/RequestTypes.js +8 -0
  43. package/dist/{src/lib → lib}/UserSettings.d.ts +1 -1
  44. package/dist/lib/UserSettings.js +269 -0
  45. package/dist/{src/lib → lib}/WorkflowExecute.d.ts +4 -4
  46. package/dist/{src/lib → lib}/WorkflowExecute.js +230 -178
  47. package/dist/{src/lib → lib}/index.d.ts +2 -2
  48. package/dist/lib/index.js +129 -0
  49. package/dist/{src/utils → utils}/crypto.js +2 -3
  50. package/package.json +59 -52
  51. package/dist/README.md +0 -31
  52. package/dist/package.json +0 -54
  53. package/dist/src/index.d.ts +0 -16
  54. package/dist/src/index.js +0 -30
  55. package/dist/src/index.js.map +0 -1
  56. package/dist/src/lib/ActiveWebhooks.js +0 -184
  57. package/dist/src/lib/ActiveWebhooks.js.map +0 -1
  58. package/dist/src/lib/ActiveWorkflows.js +0 -456
  59. package/dist/src/lib/ActiveWorkflows.js.map +0 -1
  60. package/dist/src/lib/BinaryDataManager/FileSystem.js +0 -179
  61. package/dist/src/lib/BinaryDataManager/FileSystem.js.map +0 -1
  62. package/dist/src/lib/BinaryDataManager/index.js +0 -146
  63. package/dist/src/lib/BinaryDataManager/index.js.map +0 -1
  64. package/dist/src/lib/ChangeCase.js.map +0 -1
  65. package/dist/src/lib/Constants.js +0 -19
  66. package/dist/src/lib/Constants.js.map +0 -1
  67. package/dist/src/lib/Credentials.js.map +0 -1
  68. package/dist/src/lib/FileSystem.js +0 -179
  69. package/dist/src/lib/FileSystem.js.map +0 -1
  70. package/dist/src/lib/InputConnectionDataLegacy.js +0 -79
  71. package/dist/src/lib/InputConnectionDataLegacy.js.map +0 -1
  72. package/dist/src/lib/Interfaces.js.map +0 -1
  73. package/dist/src/lib/LoadNodeParameterOptions.js +0 -150
  74. package/dist/src/lib/LoadNodeParameterOptions.js.map +0 -1
  75. package/dist/src/lib/NodeExecuteFunctions.js +0 -2479
  76. package/dist/src/lib/NodeExecuteFunctions.js.map +0 -1
  77. package/dist/src/lib/NodesLoader/constants.js +0 -106
  78. package/dist/src/lib/NodesLoader/constants.js.map +0 -1
  79. package/dist/src/lib/NodesLoader/custom-directory-loader.js +0 -36
  80. package/dist/src/lib/NodesLoader/custom-directory-loader.js.map +0 -1
  81. package/dist/src/lib/NodesLoader/directory-loader.js.map +0 -1
  82. package/dist/src/lib/NodesLoader/index.d.ts +0 -5
  83. package/dist/src/lib/NodesLoader/index.js.map +0 -1
  84. package/dist/src/lib/NodesLoader/lazy-package-directory-loader.js +0 -52
  85. package/dist/src/lib/NodesLoader/lazy-package-directory-loader.js.map +0 -1
  86. package/dist/src/lib/NodesLoader/load-class-in-isolation.js.map +0 -1
  87. package/dist/src/lib/NodesLoader/package-directory-loader.js.map +0 -1
  88. package/dist/src/lib/NodesLoader/types.js.map +0 -1
  89. package/dist/src/lib/RedisLeaderElectionManager.js +0 -294
  90. package/dist/src/lib/RedisLeaderElectionManager.js.map +0 -1
  91. package/dist/src/lib/UserSettings.js +0 -261
  92. package/dist/src/lib/UserSettings.js.map +0 -1
  93. package/dist/src/lib/WorkflowExecute.js.map +0 -1
  94. package/dist/src/lib/index.js +0 -146
  95. package/dist/src/lib/index.js.map +0 -1
  96. package/dist/src/utils/crypto.js.map +0 -1
  97. package/eslint.config.js +0 -19
  98. package/jest.config.ts +0 -10
  99. package/project.json +0 -19
  100. package/src/index.ts +0 -28
  101. package/src/lib/ActiveWebhooks.ts +0 -245
  102. package/src/lib/ActiveWorkflows.ts +0 -575
  103. package/src/lib/BinaryDataManager/FileSystem.ts +0 -214
  104. package/src/lib/BinaryDataManager/index.ts +0 -187
  105. package/src/lib/ChangeCase.ts +0 -45
  106. package/src/lib/Constants.ts +0 -16
  107. package/src/lib/Credentials.ts +0 -108
  108. package/src/lib/FileSystem.ts +0 -214
  109. package/src/lib/InputConnectionDataLegacy.ts +0 -123
  110. package/src/lib/Interfaces.ts +0 -338
  111. package/src/lib/LoadNodeParameterOptions.ts +0 -235
  112. package/src/lib/NodeExecuteFunctions.ts +0 -3700
  113. package/src/lib/NodesLoader/constants.ts +0 -112
  114. package/src/lib/NodesLoader/custom-directory-loader.ts +0 -31
  115. package/src/lib/NodesLoader/directory-loader.ts +0 -458
  116. package/src/lib/NodesLoader/index.ts +0 -5
  117. package/src/lib/NodesLoader/lazy-package-directory-loader.ts +0 -55
  118. package/src/lib/NodesLoader/load-class-in-isolation.ts +0 -19
  119. package/src/lib/NodesLoader/package-directory-loader.ts +0 -107
  120. package/src/lib/NodesLoader/types.ts +0 -14
  121. package/src/lib/RedisLeaderElectionManager.ts +0 -334
  122. package/src/lib/UserSettings.ts +0 -292
  123. package/src/lib/WorkflowExecute.ts +0 -1128
  124. package/src/lib/index.ts +0 -187
  125. package/src/utils/crypto.ts +0 -5
  126. package/tests/Credentials.test.ts +0 -88
  127. package/tests/Helpers.ts +0 -808
  128. package/tests/WorkflowExecute.test.ts +0 -1242
  129. package/tsconfig.json +0 -41
  130. package/tsconfig.lib.json +0 -10
  131. package/tsconfig.spec.json +0 -14
  132. /package/dist/{src/lib → lib}/ChangeCase.d.ts +0 -0
  133. /package/dist/{src/lib → lib}/Constants.d.ts +0 -0
  134. /package/dist/{src/lib → lib}/NodesLoader/load-class-in-isolation.d.ts +0 -0
  135. /package/dist/{src/lib → lib}/NodesLoader/types.d.ts +0 -0
  136. /package/dist/{src/utils → utils}/crypto.d.ts +0 -0
@@ -1,146 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BinaryDataManager = void 0;
4
- const tslib_1 = require("tslib");
5
- const Constants_1 = require("./Constants");
6
- const FileSystem_1 = require("./FileSystem");
7
- class BinaryDataManager {
8
- constructor(config) {
9
- this.binaryDataMode = config.mode;
10
- this.availableModes = config.availableModes.split(',');
11
- this.managers = {};
12
- }
13
- static init(config_1) {
14
- return tslib_1.__awaiter(this, arguments, void 0, function* (config, mainManager = false) {
15
- if (BinaryDataManager.instance) {
16
- throw new Error('Binary Data Manager already initialized');
17
- }
18
- BinaryDataManager.instance = new BinaryDataManager(config);
19
- if (BinaryDataManager.instance.availableModes.includes('filesystem')) {
20
- BinaryDataManager.instance.managers['filesystem'] = new FileSystem_1.BinaryDataFileSystem(config);
21
- yield BinaryDataManager.instance.managers['filesystem'].init(mainManager);
22
- }
23
- return undefined;
24
- });
25
- }
26
- static getInstance() {
27
- if (!BinaryDataManager.instance) {
28
- throw new Error('Binary Data Manager not initialized');
29
- }
30
- return BinaryDataManager.instance;
31
- }
32
- storeBinaryData(binaryData, binaryBuffer, executionId) {
33
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
34
- const retBinaryData = binaryData;
35
- if (this.managers[this.binaryDataMode]) {
36
- return this.managers[this.binaryDataMode]
37
- .storeBinaryData(binaryBuffer, executionId)
38
- .then((filename) => {
39
- retBinaryData.id = this.generateBinaryId(filename);
40
- return retBinaryData;
41
- });
42
- }
43
- retBinaryData.data = binaryBuffer.toString(Constants_1.BINARY_ENCODING);
44
- return binaryData;
45
- });
46
- }
47
- retrieveBinaryData(binaryData) {
48
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
49
- if (binaryData.id) {
50
- return this.retrieveBinaryDataByIdentifier(binaryData.id);
51
- }
52
- return Buffer.from(binaryData.data, Constants_1.BINARY_ENCODING);
53
- });
54
- }
55
- retrieveBinaryDataByIdentifier(identifier) {
56
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
57
- const { mode, id } = this.splitBinaryModeFileId(identifier);
58
- if (this.managers[mode]) {
59
- return this.managers[mode].retrieveBinaryDataByIdentifier(id);
60
- }
61
- throw new Error('Storage mode used to store binary data not available');
62
- });
63
- }
64
- markDataForDeletionByExecutionId(executionId) {
65
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
66
- if (this.managers[this.binaryDataMode]) {
67
- return this.managers[this.binaryDataMode].markDataForDeletionByExecutionId(executionId);
68
- }
69
- return Promise.resolve();
70
- });
71
- }
72
- persistBinaryDataForExecutionId(executionId) {
73
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
74
- if (this.managers[this.binaryDataMode]) {
75
- return this.managers[this.binaryDataMode].persistBinaryDataForExecutionId(executionId);
76
- }
77
- return Promise.resolve();
78
- });
79
- }
80
- deleteBinaryDataByExecutionId(executionId) {
81
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
82
- if (this.managers[this.binaryDataMode]) {
83
- return this.managers[this.binaryDataMode].deleteBinaryDataByExecutionId(executionId);
84
- }
85
- return Promise.resolve();
86
- });
87
- }
88
- duplicateBinaryData(inputData, executionId) {
89
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
90
- if (inputData && this.managers[this.binaryDataMode]) {
91
- const returnInputData = inputData.map((executionDataArray) => tslib_1.__awaiter(this, void 0, void 0, function* () {
92
- if (executionDataArray) {
93
- return Promise.all(executionDataArray.map((executionData) => {
94
- if (executionData.binary) {
95
- return this.duplicateBinaryDataInExecData(executionData, executionId);
96
- }
97
- return executionData;
98
- }));
99
- }
100
- return executionDataArray;
101
- }));
102
- return Promise.all(returnInputData);
103
- }
104
- return Promise.resolve(inputData);
105
- });
106
- }
107
- generateBinaryId(filename) {
108
- return `${this.binaryDataMode}:${filename}`;
109
- }
110
- splitBinaryModeFileId(fileId) {
111
- const [mode, id] = fileId.split(':');
112
- return { mode, id };
113
- }
114
- duplicateBinaryDataInExecData(executionData, executionId) {
115
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
116
- const binaryManager = this.managers[this.binaryDataMode];
117
- if (executionData.binary) {
118
- const binaryDataKeys = Object.keys(executionData.binary);
119
- const bdPromises = binaryDataKeys.map((key) => tslib_1.__awaiter(this, void 0, void 0, function* () {
120
- if (!executionData.binary) {
121
- return { key, newId: undefined };
122
- }
123
- const binaryDataId = executionData.binary[key].id;
124
- if (!binaryDataId) {
125
- return { key, newId: undefined };
126
- }
127
- return binaryManager === null || binaryManager === void 0 ? void 0 : binaryManager.duplicateBinaryDataByIdentifier(this.splitBinaryModeFileId(binaryDataId).id, executionId).then((filename) => ({
128
- newId: this.generateBinaryId(filename),
129
- key,
130
- }));
131
- }));
132
- return Promise.all(bdPromises).then((b) => {
133
- return b.reduce((acc, curr) => {
134
- if (acc.binary && curr) {
135
- acc.binary[curr.key].id = curr.newId;
136
- }
137
- return acc;
138
- }, executionData);
139
- });
140
- }
141
- return executionData;
142
- });
143
- }
144
- }
145
- exports.BinaryDataManager = BinaryDataManager;
146
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":";;;;AACA,2CAA8C;AAE9C,6CAAoD;AAEpD,MAAa,iBAAiB;IAW7B,YAAY,MAAyB;QACpC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACvD,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;IACpB,CAAC;IAED,MAAM,CAAO,IAAI;qEAAC,MAAyB,EAAE,WAAW,GAAG,KAAK;YAC/D,IAAI,iBAAi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C,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;wBACtC,CAAC;wBAED,OAAO,GAAG,CAAC;oBACZ,CAAC,EAAE,aAAa,CAAC,CAAC;gBACnB,CAAC,CAAC,CAAC;YACJ,CAAC;YAED,OAAO,aAAa,CAAC;QACtB,CAAC;KAAA;CACD;AArLD,8CAqLC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../../src/utils/crypto.ts"],"names":[],"mappings":";;AAEA,gDAEC;AAJD,mCAAmC;AAEnC,SAAgB,kBAAkB,CAAC,GAAW,EAAE,GAAW;IACvD,OAAO,IAAA,kBAAS,EAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC/B,CAAC"}
package/eslint.config.js DELETED
@@ -1,19 +0,0 @@
1
- const baseConfig = require('../../eslint.config.js');
2
-
3
- module.exports = [
4
- ...baseConfig,
5
- {
6
- files: ['**/*.json'],
7
- rules: {
8
- '@nx/dependency-checks': [
9
- 'error',
10
- {
11
- ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs}'],
12
- },
13
- ],
14
- },
15
- languageOptions: {
16
- parser: require('jsonc-eslint-parser'),
17
- },
18
- },
19
- ];
package/jest.config.ts DELETED
@@ -1,10 +0,0 @@
1
- export default {
2
- displayName: 'core',
3
- preset: '../../jest.preset.js',
4
- testEnvironment: 'node',
5
- transform: {
6
- '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
7
- },
8
- moduleFileExtensions: ['ts', 'js', 'html'],
9
- coverageDirectory: '../../coverage/libs/core',
10
- };
package/project.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "name": "core",
3
- "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
- "sourceRoot": "libs/core/src",
5
- "projectType": "library",
6
- "tags": [],
7
- "targets": {
8
- "build": {
9
- "executor": "@nx/js:tsc",
10
- "outputs": ["{options.outputPath}"],
11
- "options": {
12
- "outputPath": "libs/core/dist",
13
- "main": "libs/core/src/index.ts",
14
- "tsConfig": "libs/core/tsconfig.lib.json",
15
- "assets": ["libs/core/*.md"]
16
- }
17
- }
18
- }
19
- }
package/src/index.ts DELETED
@@ -1,28 +0,0 @@
1
- /* eslint-disable import/no-cycle */
2
- import * as NodeExecuteFunctions from './lib/NodeExecuteFunctions';
3
- import * as UserSettings from './lib/UserSettings';
4
- import * as getInputConnectionDataLegacy from './lib/InputConnectionDataLegacy';
5
-
6
- try {
7
- // 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
8
- require('source-map-support').install();
9
- // eslint-disable-next-line no-empty
10
- } catch (error) {}
11
-
12
- export * from './lib/ActiveWorkflows';
13
- export * from './lib/ActiveWebhooks';
14
- export * from './lib/BinaryDataManager';
15
- export * from './lib/Constants';
16
- export * from './lib/Credentials';
17
- export * from './lib/Interfaces';
18
- export * from './lib/RedisLeaderElectionManager';
19
- export * from './lib/LoadNodeParameterOptions';
20
- export * from './lib/NodeExecuteFunctions';
21
- export * from './lib/WorkflowExecute';
22
- export * from './lib/ChangeCase';
23
- export * from './lib/NodesLoader';
24
- export {
25
- NodeExecuteFunctions,
26
- UserSettings,
27
- getInputConnectionDataLegacy
28
- };
@@ -1,245 +0,0 @@
1
- import {
2
- IWebhookData,
3
- WebhookHttpMethod,
4
- Workflow,
5
- WorkflowActivateMode,
6
- WorkflowExecuteMode,
7
- } from '@fsai-flow/workflow';
8
-
9
- // eslint-disable-next-line import/no-cycle
10
- import { NodeExecuteFunctions } from '..';
11
-
12
- export class ActiveWebhooks {
13
- private workflowWebhooks: {
14
- [key: string]: IWebhookData[];
15
- } = {};
16
-
17
- private webhookUrls: {
18
- [key: string]: IWebhookData[];
19
- } = {};
20
-
21
- testWebhooks = false;
22
-
23
- /**
24
- * Adds a new webhook
25
- *
26
- * @param {IWebhookData} webhookData
27
- * @param {WorkflowExecuteMode} mode
28
- * @returns {Promise<void>}
29
- * @memberof ActiveWebhooks
30
- */
31
- async add(
32
- workflow: Workflow,
33
- webhookData: IWebhookData,
34
- mode: WorkflowExecuteMode,
35
- activation: WorkflowActivateMode,
36
- ): Promise<void> {
37
- if (workflow.id === undefined) {
38
- throw new Error('Webhooks can only be added for saved workflows as an id is needed!');
39
- }
40
- if (webhookData.path.endsWith('/')) {
41
- // eslint-disable-next-line no-param-reassign
42
- webhookData.path = webhookData.path.slice(0, -1);
43
- }
44
-
45
- const webhookKey = this.getWebhookKey(
46
- webhookData.httpMethod,
47
- webhookData.path,
48
- webhookData.webhookId,
49
- );
50
-
51
- // check that there is not a webhook already registed with that path/method
52
- if (this.webhookUrls[webhookKey] && !webhookData.webhookId) {
53
- throw new Error(
54
- `The URL path that the "${webhookData.node}" node uses is already taken. Please change it to something else.`,
55
- );
56
- }
57
-
58
- if (this.workflowWebhooks[webhookData.workflowId] === undefined) {
59
- this.workflowWebhooks[webhookData.workflowId] = [];
60
- }
61
-
62
- // Make the webhook available directly because sometimes to create it successfully
63
- // it gets called
64
- if (!this.webhookUrls[webhookKey]) {
65
- this.webhookUrls[webhookKey] = [];
66
- }
67
- this.webhookUrls[webhookKey].push(webhookData);
68
-
69
- try {
70
- const webhookExists = await workflow.runWebhookMethod(
71
- 'checkExists',
72
- webhookData,
73
- NodeExecuteFunctions,
74
- mode,
75
- activation,
76
- this.testWebhooks,
77
- );
78
- if (webhookExists !== true) {
79
- // If webhook does not exist yet create it
80
- await workflow.runWebhookMethod(
81
- 'create',
82
- webhookData,
83
- NodeExecuteFunctions,
84
- mode,
85
- activation,
86
- this.testWebhooks,
87
- );
88
- }
89
- } catch (error) {
90
- // If there was a problem unregister the webhook again
91
- if (this.webhookUrls[webhookKey].length <= 1) {
92
- delete this.webhookUrls[webhookKey];
93
- } else {
94
- this.webhookUrls[webhookKey] = this.webhookUrls[webhookKey].filter(
95
- (webhook) => webhook.path !== webhookData.path,
96
- );
97
- }
98
-
99
- throw error;
100
- }
101
- this.workflowWebhooks[webhookData.workflowId].push(webhookData);
102
- }
103
-
104
- /**
105
- * Returns webhookData if a webhook with matches is currently registered
106
- *
107
- * @param {WebhookHttpMethod} httpMethod
108
- * @param {string} path
109
- * @param {(string | undefined)} webhookId
110
- * @returns {(IWebhookData | undefined)}
111
- * @memberof ActiveWebhooks
112
- */
113
- get(httpMethod: WebhookHttpMethod, path: string, webhookId?: string): IWebhookData | undefined {
114
- const webhookKey = this.getWebhookKey(httpMethod, path, webhookId);
115
- if (this.webhookUrls[webhookKey] === undefined) {
116
- return undefined;
117
- }
118
-
119
- let webhook: IWebhookData | undefined;
120
- let maxMatches = 0;
121
- const pathElementsSet = new Set(path.split('/'));
122
- // check if static elements match in path
123
- // if more results have been returned choose the one with the most static-route matches
124
- this.webhookUrls[webhookKey].forEach((dynamicWebhook) => {
125
- const staticElements = dynamicWebhook.path.split('/').filter((ele) => !ele.startsWith(':'));
126
- const allStaticExist = staticElements.every((staticEle) => pathElementsSet.has(staticEle));
127
-
128
- if (allStaticExist && staticElements.length > maxMatches) {
129
- maxMatches = staticElements.length;
130
- webhook = dynamicWebhook;
131
- }
132
- // handle routes with no static elements
133
- else if (staticElements.length === 0 && !webhook) {
134
- webhook = dynamicWebhook;
135
- }
136
- });
137
-
138
- return webhook;
139
- }
140
-
141
- /**
142
- * Gets all request methods associated with a single webhook
143
- * @param path
144
- */
145
- getWebhookMethods(path: string): string[] {
146
- const methods: string[] = [];
147
-
148
- Object.keys(this.webhookUrls)
149
- .filter((key) => key.includes(path))
150
- // eslint-disable-next-line array-callback-return
151
- .map((key) => {
152
- methods.push(key.split('|')[0]);
153
- });
154
-
155
- return methods;
156
- }
157
-
158
- /**
159
- * Returns the ids of all the workflows which have active webhooks
160
- *
161
- * @returns {string[]}
162
- * @memberof ActiveWebhooks
163
- */
164
- getWorkflowIds(): string[] {
165
- return Object.keys(this.workflowWebhooks);
166
- }
167
-
168
- /**
169
- * Returns key to uniquely identify a webhook
170
- *
171
- * @param {WebhookHttpMethod} httpMethod
172
- * @param {string} path
173
- * @param {(string | undefined)} webhookId
174
- * @returns {string}
175
- * @memberof ActiveWebhooks
176
- */
177
- getWebhookKey(httpMethod: WebhookHttpMethod, path: string, webhookId?: string): string {
178
- if (webhookId) {
179
- if (path.startsWith(webhookId)) {
180
- const cutFromIndex = path.indexOf('/') + 1;
181
- // eslint-disable-next-line no-param-reassign
182
- path = path.slice(cutFromIndex);
183
- }
184
- return `${httpMethod}|${webhookId}|${path.split('/').length}`;
185
- }
186
- return `${httpMethod}|${path}`;
187
- }
188
-
189
- /**
190
- * Removes all webhooks of a workflow
191
- *
192
- * @param {Workflow} workflow
193
- * @returns {boolean}
194
- * @memberof ActiveWebhooks
195
- */
196
- async removeWorkflow(workflow: Workflow): Promise<boolean> {
197
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
198
- const workflowId = workflow.id!.toString();
199
-
200
- if (this.workflowWebhooks[workflowId] === undefined) {
201
- // If it did not exist then there is nothing to remove
202
- return false;
203
- }
204
-
205
- const webhooks = this.workflowWebhooks[workflowId];
206
-
207
- const mode = 'internal';
208
-
209
- // Go through all the registered webhooks of the workflow and remove them
210
- // eslint-disable-next-line no-restricted-syntax
211
- for (const webhookData of webhooks) {
212
- // eslint-disable-next-line no-await-in-loop
213
- await workflow.runWebhookMethod(
214
- 'delete',
215
- webhookData,
216
- NodeExecuteFunctions,
217
- mode,
218
- 'update',
219
- this.testWebhooks,
220
- );
221
-
222
- delete this.webhookUrls[
223
- this.getWebhookKey(webhookData.httpMethod, webhookData.path, webhookData.webhookId)
224
- ];
225
- }
226
-
227
- // Remove also the workflow-webhook entry
228
- delete this.workflowWebhooks[workflowId];
229
-
230
- return true;
231
- }
232
-
233
- /**
234
- * Removes all the webhooks of the given workflows
235
- */
236
- async removeAll(workflows: Workflow[]): Promise<void> {
237
- const removePromises = [];
238
- // eslint-disable-next-line no-restricted-syntax
239
- for (const workflow of workflows) {
240
- removePromises.push(this.removeWorkflow(workflow));
241
- }
242
-
243
- await Promise.all(removePromises);
244
- }
245
- }