@ductape/sdk 0.0.4-v3 → 0.0.4-v30
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/dist/api/services/appApi.service.d.ts +2 -2
- package/dist/api/services/appApi.service.js +1 -2
- package/dist/api/services/appApi.service.js.map +1 -1
- package/dist/api/services/pricingApi.service.d.ts +10 -0
- package/dist/api/services/pricingApi.service.js +34 -0
- package/dist/api/services/pricingApi.service.js.map +1 -0
- package/dist/api/services/processorApi.service.d.ts +12 -2
- package/dist/api/services/processorApi.service.js +12 -2
- package/dist/api/services/processorApi.service.js.map +1 -1
- package/dist/api/services/productsApi.service.d.ts +5 -1
- package/dist/api/services/productsApi.service.js +22 -0
- package/dist/api/services/productsApi.service.js.map +1 -1
- package/dist/api/services/userApi.service.js +1 -0
- package/dist/api/services/userApi.service.js.map +1 -1
- package/dist/api/services/workspaceApi.service.js +1 -0
- package/dist/api/services/workspaceApi.service.js.map +1 -1
- package/dist/api/urls.d.ts +6 -1
- package/dist/api/urls.js +12 -2
- package/dist/api/urls.js.map +1 -1
- package/dist/api/utils/strings.utils.d.ts +2 -0
- package/dist/api/utils/strings.utils.js +14 -0
- package/dist/api/utils/strings.utils.js.map +1 -1
- package/dist/apps/services/app.service.d.ts +8 -1
- package/dist/apps/services/app.service.js +174 -25
- package/dist/apps/services/app.service.js.map +1 -1
- package/dist/apps/validators/joi-validators/create.appAction.validator.d.ts +1 -2
- package/dist/apps/validators/joi-validators/create.appAction.validator.js +21 -2
- package/dist/apps/validators/joi-validators/create.appAction.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appAction.validator.js +11 -1
- package/dist/apps/validators/joi-validators/update.appAction.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appActionResponse.validator.d.ts +1 -1
- package/dist/apps/validators/joi-validators/update.appActionResponse.validator.js +34 -1
- package/dist/apps/validators/joi-validators/update.appActionResponse.validator.js.map +1 -1
- package/dist/clients/apps.client.js +1 -1
- package/dist/clients/apps.client.js.map +1 -1
- package/dist/clients/pricing.client.d.ts +3 -0
- package/dist/clients/pricing.client.js +33 -0
- package/dist/clients/pricing.client.js.map +1 -0
- package/dist/imports/imports.service.d.ts +3 -3
- package/dist/imports/imports.service.js +7 -7
- package/dist/imports/imports.service.js.map +1 -1
- package/dist/imports/imports.types.d.ts +8 -0
- package/dist/imports/repos/openApi.repo.d.ts +1 -2
- package/dist/imports/repos/openApi.repo.js +43 -71
- package/dist/imports/repos/openApi.repo.js.map +1 -1
- package/dist/imports/repos/postmanV21.repo.d.ts +1 -1
- package/dist/imports/repos/postmanV21.repo.js +29 -2
- package/dist/imports/repos/postmanV21.repo.js.map +1 -1
- package/dist/index.d.ts +965 -47
- package/dist/index.js +924 -81
- package/dist/index.js.map +1 -1
- package/dist/inputs/inputs.service.js +2 -2
- package/dist/inputs/inputs.service.js.map +1 -1
- package/dist/inputs/utils/inputs.utils.create.js +1 -1
- package/dist/inputs/utils/inputs.utils.create.js.map +1 -1
- package/dist/logs/logs.service.js +1 -0
- package/dist/logs/logs.service.js.map +1 -1
- package/dist/logs/logs.types.d.ts +5 -0
- package/dist/logs/logs.types.js.map +1 -1
- package/dist/parsers/index.d.ts +3 -0
- package/dist/parsers/index.js +27 -0
- package/dist/parsers/index.js.map +1 -0
- package/dist/parsers/pipelines/postman.pipelines.d.ts +15 -0
- package/dist/parsers/pipelines/postman.pipelines.js +103 -0
- package/dist/parsers/pipelines/postman.pipelines.js.map +1 -0
- package/dist/parsers/types/postman.types.d.ts +200 -0
- package/dist/parsers/types/postman.types.js +3 -0
- package/dist/parsers/types/postman.types.js.map +1 -0
- package/dist/parsers/utils/postman.utils.d.ts +12 -0
- package/dist/parsers/utils/postman.utils.js +116 -0
- package/dist/parsers/utils/postman.utils.js.map +1 -0
- package/dist/parsers/validators/postman-auth.validators.d.ts +10 -0
- package/dist/parsers/validators/postman-auth.validators.js +127 -0
- package/dist/parsers/validators/postman-auth.validators.js.map +1 -0
- package/dist/parsers/validators/postman-request.validators.d.ts +13 -0
- package/dist/parsers/validators/postman-request.validators.js +139 -0
- package/dist/parsers/validators/postman-request.validators.js.map +1 -0
- package/dist/parsers/validators/postman-response.validators.d.ts +13 -0
- package/dist/parsers/validators/postman-response.validators.js +150 -0
- package/dist/parsers/validators/postman-response.validators.js.map +1 -0
- package/dist/parsers/validators/postman-variable.validators.d.ts +14 -0
- package/dist/parsers/validators/postman-variable.validators.js +163 -0
- package/dist/parsers/validators/postman-variable.validators.js.map +1 -0
- package/dist/pricing/pricing.repo.d.ts +0 -0
- package/dist/pricing/pricing.repo.js +1 -0
- package/dist/pricing/pricing.repo.js.map +1 -0
- package/dist/pricing/pricing.service.d.ts +24 -0
- package/dist/pricing/pricing.service.js +51 -0
- package/dist/pricing/pricing.service.js.map +1 -0
- package/dist/pricing/pricing.types.d.ts +76 -0
- package/dist/pricing/pricing.types.js +21 -0
- package/dist/pricing/pricing.types.js.map +1 -0
- package/dist/pricing/utils/string.utils.d.ts +1 -0
- package/dist/pricing/utils/string.utils.js +9 -0
- package/dist/pricing/utils/string.utils.js.map +1 -0
- package/dist/processor/repos/sms.repo.d.ts +4 -4
- package/dist/processor/repos/sms.repo.js +23 -10
- package/dist/processor/repos/sms.repo.js.map +1 -1
- package/dist/processor/services/processor.service.d.ts +36 -5
- package/dist/processor/services/processor.service.js +568 -201
- package/dist/processor/services/processor.service.js.map +1 -1
- package/dist/processor/services/request.service.d.ts +36 -0
- package/dist/processor/services/request.service.js +304 -0
- package/dist/processor/services/request.service.js.map +1 -0
- package/dist/processor/types/request.types.d.ts +14 -0
- package/dist/processor/types/request.types.js +3 -0
- package/dist/processor/types/request.types.js.map +1 -0
- package/dist/processor/utils/processor.utils.d.ts +3 -0
- package/dist/processor/utils/processor.utils.js +88 -5
- package/dist/processor/utils/processor.utils.js.map +1 -1
- package/dist/processor/utils/request.utils.d.ts +20 -0
- package/dist/processor/utils/request.utils.js +113 -0
- package/dist/processor/utils/request.utils.js.map +1 -0
- package/dist/processor/utils/storage.util.js +54 -40
- package/dist/processor/utils/storage.util.js.map +1 -1
- package/dist/products/services/products.service.d.ts +20 -7
- package/dist/products/services/products.service.js +269 -43
- package/dist/products/services/products.service.js.map +1 -1
- package/dist/products/utils/string.utils.d.ts +1 -1
- package/dist/products/utils/string.utils.js +14 -2
- package/dist/products/utils/string.utils.js.map +1 -1
- package/dist/products/validators/index.d.ts +2 -1
- package/dist/products/validators/index.js +3 -1
- package/dist/products/validators/index.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productEnv.validator.js +1 -0
- package/dist/products/validators/joi-validators/create.productEnv.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productHealthcheck.validator.d.ts +4 -0
- package/dist/products/validators/joi-validators/create.productHealthcheck.validator.js +58 -0
- package/dist/products/validators/joi-validators/create.productHealthcheck.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.userAuth.validator.js +1 -0
- package/dist/products/validators/joi-validators/create.userAuth.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.dataValue.validator.js +1 -0
- package/dist/products/validators/joi-validators/update.dataValue.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productEnv.validator.js +3 -0
- package/dist/products/validators/joi-validators/update.productEnv.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.userAuth.validator.js +1 -0
- package/dist/products/validators/joi-validators/update.userAuth.validator.js.map +1 -1
- package/dist/test/test.health.d.ts +1 -0
- package/dist/test/test.health.js +49 -0
- package/dist/test/test.health.js.map +1 -0
- package/dist/test/test.import.js +51 -4
- package/dist/test/test.import.js.map +1 -1
- package/dist/test/test.imports.js +22 -7
- package/dist/test/test.imports.js.map +1 -1
- package/dist/test/test.processor.js +32 -115
- package/dist/test/test.processor.js.map +1 -1
- package/dist/test/test.products.d.ts +1 -0
- package/dist/test/test.products.js +49 -0
- package/dist/test/test.products.js.map +1 -0
- package/dist/types/appBuilder.types.d.ts +4 -11
- package/dist/types/enums.d.ts +3 -1
- package/dist/types/enums.js +2 -0
- package/dist/types/enums.js.map +1 -1
- package/dist/types/index.types.d.ts +4 -0
- package/dist/types/pricing.types.d.ts +4 -0
- package/dist/types/pricing.types.js +3 -0
- package/dist/types/pricing.types.js.map +1 -0
- package/dist/types/processor.types.d.ts +66 -9
- package/dist/types/processor.types.js.map +1 -1
- package/dist/types/productsBuilder.types.d.ts +52 -5
- package/dist/types/productsBuilder.types.js +9 -1
- package/dist/types/productsBuilder.types.js.map +1 -1
- package/dist/types/request-tracker.interface.d.ts +0 -0
- package/dist/types/request-tracker.interface.js +1 -0
- package/dist/types/request-tracker.interface.js.map +1 -0
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.js +5 -0
- package/dist/utils/constants.js.map +1 -0
- package/package.json +14 -3
package/dist/index.js
CHANGED
|
@@ -44,38 +44,63 @@ const filePath = __importStar(require("path"));
|
|
|
44
44
|
const products_service_1 = __importDefault(require("./products/services/products.service"));
|
|
45
45
|
const fs_1 = require("fs");
|
|
46
46
|
const index_types_1 = require("./types/index.types");
|
|
47
|
+
const enums_1 = require("./types/enums");
|
|
47
48
|
const productsApi_service_1 = require("./api/services/productsApi.service");
|
|
48
49
|
const imports_service_1 = __importDefault(require("./imports/imports.service"));
|
|
49
50
|
const processor_service_1 = __importDefault(require("./processor/services/processor.service"));
|
|
50
51
|
const logs_service_1 = __importDefault(require("./logs/logs.service"));
|
|
51
52
|
const utils_1 = require("./utils");
|
|
52
53
|
const mime = __importStar(require("mime-types"));
|
|
54
|
+
const processor_utils_1 = require("./processor/utils/processor.utils");
|
|
53
55
|
class Ductape {
|
|
54
56
|
async loadRedis() {
|
|
55
57
|
if (typeof window !== 'undefined') {
|
|
56
58
|
throw new Error("RedisService can only be used in a server environment.");
|
|
57
59
|
}
|
|
58
|
-
|
|
59
|
-
return redis;
|
|
60
|
+
return await Promise.resolve().then(() => __importStar(require('ioredis')));
|
|
60
61
|
}
|
|
61
62
|
constructor({ workspace_id, private_key, user_id, env_type, redis_url }) {
|
|
63
|
+
/**
|
|
64
|
+
* Product-related operations for managing products, sessions, apps, quotas, and fallbacks.
|
|
65
|
+
*/
|
|
62
66
|
this.product = {
|
|
67
|
+
/**
|
|
68
|
+
* Creates a new product.
|
|
69
|
+
* @param {IProduct} data - The product data.
|
|
70
|
+
* @returns {Promise<void>} Resolves when the product is created. Throws on error.
|
|
71
|
+
*/
|
|
63
72
|
create: async (data) => {
|
|
64
73
|
await this.initProduct();
|
|
65
74
|
return this.productBuilder.createProduct(data);
|
|
66
75
|
},
|
|
76
|
+
/**
|
|
77
|
+
* Fetches a product by tag.
|
|
78
|
+
* @param {string} tag - The product tag.
|
|
79
|
+
* @returns {Promise<IProduct|null>} The fetched product, or null if not found.
|
|
80
|
+
*/
|
|
67
81
|
fetch: async (tag) => {
|
|
68
82
|
await this.initProduct();
|
|
69
83
|
await this.productBuilder.initializeProductByTag(tag);
|
|
70
84
|
this.productInit = false;
|
|
71
85
|
return this.productBuilder.fetchProduct();
|
|
72
86
|
},
|
|
87
|
+
/**
|
|
88
|
+
* Updates a product by tag.
|
|
89
|
+
* @param {string} tag - The product tag.
|
|
90
|
+
* @param {Partial<IProduct>} data - The product data to update.
|
|
91
|
+
* @returns {Promise<void>} Resolves when the product is updated. Throws on error.
|
|
92
|
+
*/
|
|
73
93
|
update: async (tag, data) => {
|
|
74
94
|
await this.initProduct();
|
|
75
95
|
await this.productBuilder.initializeProductByTag(tag);
|
|
76
96
|
this.productInit = false;
|
|
77
97
|
return this.productBuilder.updateProduct(data);
|
|
78
98
|
},
|
|
99
|
+
/**
|
|
100
|
+
* Initializes a product by tag.
|
|
101
|
+
* @param {string} productTag - The product tag.
|
|
102
|
+
* @returns {Promise<void>} Resolves when initialization is complete. Throws on error.
|
|
103
|
+
*/
|
|
79
104
|
init: async (productTag) => {
|
|
80
105
|
try {
|
|
81
106
|
console.log(`Product initialized with tag: ${productTag}`);
|
|
@@ -89,185 +114,408 @@ class Ductape {
|
|
|
89
114
|
}
|
|
90
115
|
},
|
|
91
116
|
sessions: {
|
|
92
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Creates a new product session.
|
|
119
|
+
* @param {IProductSession} payload - The session payload.
|
|
120
|
+
* @returns {Promise<void>} Resolves when the session is created. Throws on error.
|
|
121
|
+
*/
|
|
122
|
+
create: async (payload) => {
|
|
93
123
|
this.checkProductInit();
|
|
94
124
|
return this.productBuilder.createSession(payload);
|
|
95
125
|
},
|
|
96
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Updates a product session by tag.
|
|
128
|
+
* @param {string} tag - The session tag.
|
|
129
|
+
* @param {Partial<IProductSession>} payload - The session data to update.
|
|
130
|
+
* @returns {Promise<void>} Resolves when the session is updated. Throws on error.
|
|
131
|
+
*/
|
|
132
|
+
update: async (tag, payload) => {
|
|
97
133
|
this.checkProductInit();
|
|
98
134
|
return this.productBuilder.updateSession(tag, payload);
|
|
99
135
|
},
|
|
136
|
+
/**
|
|
137
|
+
* Fetches all product sessions.
|
|
138
|
+
* @returns {IProductSession[]} The list of sessions.
|
|
139
|
+
*/
|
|
100
140
|
fetchAll: () => {
|
|
101
141
|
this.checkProductInit();
|
|
102
142
|
return this.productBuilder.fetchSessions();
|
|
103
143
|
},
|
|
144
|
+
/**
|
|
145
|
+
* Fetches a product session by tag.
|
|
146
|
+
* @param {string} tag - The session tag.
|
|
147
|
+
* @returns {IProductSession|null} The fetched session, or null if not found.
|
|
148
|
+
*/
|
|
104
149
|
fetch: (tag) => {
|
|
105
150
|
this.checkProductInit();
|
|
106
151
|
return this.productBuilder.fetchSession(tag);
|
|
152
|
+
},
|
|
153
|
+
/**
|
|
154
|
+
* Fetches users for a session.
|
|
155
|
+
* @param {IFetchUsersPayload} data - The user fetch payload.
|
|
156
|
+
* @returns {Promise<any[]>} The users for the session.
|
|
157
|
+
*/
|
|
158
|
+
users: (data) => {
|
|
159
|
+
this.checkProductInit();
|
|
160
|
+
return this.productBuilder.fetchSessionUsers(data);
|
|
107
161
|
}
|
|
108
162
|
},
|
|
109
163
|
apps: {
|
|
164
|
+
/**
|
|
165
|
+
* Connects an app to a product by app tag.
|
|
166
|
+
* @param {string} appTag - The app tag.
|
|
167
|
+
* @returns {Promise<IAppAccess>} The result of the connection.
|
|
168
|
+
*/
|
|
110
169
|
connect: async (appTag) => {
|
|
111
170
|
this.checkProductInit();
|
|
112
171
|
return this.productBuilder.createAppAccessTag(appTag);
|
|
113
172
|
},
|
|
173
|
+
/**
|
|
174
|
+
* Adds an app to a product.
|
|
175
|
+
* @param {IProductApp} app - The app data.
|
|
176
|
+
* @returns {Promise<void>} Resolves when the app is added. Throws on error.
|
|
177
|
+
*/
|
|
114
178
|
add: async (app) => {
|
|
115
179
|
this.checkProductInit();
|
|
116
180
|
return this.productBuilder.addApp(app);
|
|
117
181
|
},
|
|
182
|
+
/**
|
|
183
|
+
* Fetches all apps for a product.
|
|
184
|
+
* @returns {IProductApp[]} The list of apps.
|
|
185
|
+
*/
|
|
118
186
|
fetchAll: async () => {
|
|
119
187
|
this.checkProductInit();
|
|
120
188
|
return this.productBuilder.fetchApps();
|
|
121
189
|
},
|
|
190
|
+
/**
|
|
191
|
+
* Fetches an app by tag.
|
|
192
|
+
* @param {string} tag - The app tag.
|
|
193
|
+
* @returns {IProductApp|null} The fetched app, or null if not found.
|
|
194
|
+
*/
|
|
122
195
|
fetch: async (tag) => {
|
|
123
196
|
this.checkProductInit();
|
|
124
197
|
return this.productBuilder.fetchApp(tag);
|
|
125
198
|
},
|
|
199
|
+
/**
|
|
200
|
+
* Updates an app by access tag.
|
|
201
|
+
* @param {string} accessTag - The app access tag.
|
|
202
|
+
* @param {Partial<IProductApp>} data - The app data to update.
|
|
203
|
+
* @returns {Promise<void>} Resolves when the app is updated. Throws on error.
|
|
204
|
+
*/
|
|
126
205
|
update: async (accessTag, data) => {
|
|
127
206
|
this.checkProductInit();
|
|
128
207
|
return this.productBuilder.updateApp(accessTag, data);
|
|
129
208
|
},
|
|
130
209
|
webhooks: {
|
|
210
|
+
/**
|
|
211
|
+
* Fetches all webhooks for an app by access tag.
|
|
212
|
+
* @param {string} accessTag - The app access tag.
|
|
213
|
+
* @returns {Promise<IAppWebhook[]>} The list of webhooks.
|
|
214
|
+
*/
|
|
131
215
|
fetchAll: async (accessTag) => {
|
|
132
216
|
this.checkProductInit();
|
|
133
217
|
return this.productBuilder.fetchAppWebhooks(accessTag);
|
|
134
218
|
},
|
|
219
|
+
/**
|
|
220
|
+
* Enables a webhook for an app.
|
|
221
|
+
* @param {IRegisterWebhook} data - The webhook registration data.
|
|
222
|
+
* @returns {Promise<void>} Resolves when the webhook is enabled. Throws on error.
|
|
223
|
+
*/
|
|
135
224
|
enable: async (data) => {
|
|
136
225
|
const processorService = await this.createNewProcessor();
|
|
137
226
|
return processorService.registerWebhook(data);
|
|
138
227
|
},
|
|
228
|
+
/**
|
|
229
|
+
* Generates a webhook link for an app.
|
|
230
|
+
* @param {IGenerateWebhookLink} data - The webhook link data.
|
|
231
|
+
* @returns {Promise<string>} The generated webhook link.
|
|
232
|
+
*/
|
|
139
233
|
generateLink: async (data) => {
|
|
140
234
|
const processorService = await this.createNewProcessor();
|
|
141
235
|
return processorService.generateWebhookLink(data);
|
|
142
236
|
},
|
|
143
237
|
},
|
|
238
|
+
health: {
|
|
239
|
+
/**
|
|
240
|
+
* Creates a health check for an app.
|
|
241
|
+
* @param {Partial<IProductAppHealth>} data - The health check data.
|
|
242
|
+
* @returns {Promise<void>} Resolves when the health check is created. Throws on error.
|
|
243
|
+
*/
|
|
244
|
+
create: async (data) => {
|
|
245
|
+
await this.checkProductInit();
|
|
246
|
+
return await this.productBuilder.createHealthcheck(data);
|
|
247
|
+
},
|
|
248
|
+
/**
|
|
249
|
+
* Updates a health check by tag.
|
|
250
|
+
* @param {string} tag - The health check tag.
|
|
251
|
+
* @param {Partial<IProductAppHealth>} data - The health check data to update.
|
|
252
|
+
* @returns {Promise<void>} Resolves when the health check is updated. Throws on error.
|
|
253
|
+
*/
|
|
254
|
+
update: async (tag, data) => {
|
|
255
|
+
this.checkProductInit();
|
|
256
|
+
return this.productBuilder.updateHealthcheck(tag, data);
|
|
257
|
+
},
|
|
258
|
+
/**
|
|
259
|
+
* Fetches a health check by access tag and tag.
|
|
260
|
+
* @param {string} access_tag - The app access tag.
|
|
261
|
+
* @param {string} tag - The health check tag.
|
|
262
|
+
* @returns {Promise<IProductAppHealth|null>} The fetched health check, or null if not found.
|
|
263
|
+
*/
|
|
264
|
+
fetch: async (access_tag, tag) => {
|
|
265
|
+
this.checkProductInit();
|
|
266
|
+
return this.productBuilder.fetchHealthcheck(access_tag, tag);
|
|
267
|
+
},
|
|
268
|
+
/**
|
|
269
|
+
* Fetches all health checks for an app by access tag.
|
|
270
|
+
* @param {string} access_tag - The app access tag.
|
|
271
|
+
* @returns {Promise<IProductAppHealth[]>} The list of health checks.
|
|
272
|
+
*/
|
|
273
|
+
fetchAll: async (access_tag) => {
|
|
274
|
+
this.checkProductInit();
|
|
275
|
+
return this.productBuilder.fetchHealthchecks(access_tag);
|
|
276
|
+
},
|
|
277
|
+
}
|
|
144
278
|
},
|
|
279
|
+
/**
|
|
280
|
+
* Creates a quota for a product.
|
|
281
|
+
* @param {Partial<IProductQuota>} data - The quota data.
|
|
282
|
+
* @returns {Promise<void>} Resolves when the quota is created. Throws on error.
|
|
283
|
+
*/
|
|
145
284
|
quota: {
|
|
146
285
|
create: async (data) => {
|
|
147
286
|
await this.initProduct();
|
|
148
287
|
return this.productBuilder.createQuota(data);
|
|
149
288
|
},
|
|
289
|
+
/**
|
|
290
|
+
* Fetches a quota by tag.
|
|
291
|
+
* @param {string} tag - The quota tag.
|
|
292
|
+
* @returns {IProductQuota|null} The fetched quota, or null if not found.
|
|
293
|
+
*/
|
|
150
294
|
fetch: (tag) => {
|
|
151
295
|
return this.productBuilder.fetchQuota(tag);
|
|
152
296
|
},
|
|
297
|
+
/**
|
|
298
|
+
* Fetches all quotas for a product.
|
|
299
|
+
* @returns {IProductQuota[]} The list of quotas.
|
|
300
|
+
*/
|
|
153
301
|
fetchAll: () => {
|
|
154
302
|
return this.productBuilder.fetchQuotas();
|
|
155
303
|
},
|
|
304
|
+
/**
|
|
305
|
+
* Updates a quota by tag.
|
|
306
|
+
* @param {string} tag - The quota tag.
|
|
307
|
+
* @param {Partial<IProductQuota>} data - The quota data to update.
|
|
308
|
+
* @returns {Promise<void>} Resolves when the quota is updated. Throws on error.
|
|
309
|
+
*/
|
|
156
310
|
update: async (tag, data) => {
|
|
157
311
|
await this.initProduct();
|
|
158
312
|
return this.productBuilder.updateQuota(tag, data);
|
|
159
313
|
},
|
|
160
314
|
},
|
|
315
|
+
/**
|
|
316
|
+
* Creates a fallback for a product.
|
|
317
|
+
* @param {Partial<IProductFallback>} data - The fallback data.
|
|
318
|
+
* @returns {Promise<void>} Resolves when the fallback is created. Throws on error.
|
|
319
|
+
*/
|
|
161
320
|
fallback: {
|
|
162
321
|
create: async (data) => {
|
|
163
322
|
this.checkProductInit();
|
|
164
323
|
return this.productBuilder.createFallback(data);
|
|
165
324
|
},
|
|
325
|
+
/**
|
|
326
|
+
* Fetches a fallback by tag.
|
|
327
|
+
* @param {string} tag - The fallback tag.
|
|
328
|
+
* @returns {IProductFallback|null} The fetched fallback, or null if not found.
|
|
329
|
+
*/
|
|
166
330
|
fetch: (tag) => {
|
|
167
331
|
this.checkProductInit();
|
|
168
332
|
return this.productBuilder.fetchFallback(tag);
|
|
169
333
|
},
|
|
334
|
+
/**
|
|
335
|
+
* Fetches all fallbacks for a product.
|
|
336
|
+
* @returns {IProductFallback[]} The list of fallbacks.
|
|
337
|
+
*/
|
|
170
338
|
fetchAll: () => {
|
|
171
339
|
this.checkProductInit();
|
|
172
340
|
return this.productBuilder.fetchFallbacks();
|
|
173
341
|
},
|
|
342
|
+
/**
|
|
343
|
+
* Updates a fallback by tag.
|
|
344
|
+
* @param {string} tag - The fallback tag.
|
|
345
|
+
* @param {Partial<IProductFallback>} data - The fallback data to update.
|
|
346
|
+
* @returns {Promise<void>} Resolves when the fallback is updated. Throws on error.
|
|
347
|
+
*/
|
|
174
348
|
update: async (tag, data) => {
|
|
175
349
|
this.checkProductInit();
|
|
176
350
|
return this.productBuilder.updateFallback(tag, data);
|
|
177
351
|
},
|
|
178
352
|
},
|
|
353
|
+
/**
|
|
354
|
+
* Updates data validation for a product.
|
|
355
|
+
* @param {string} tag - The product tag.
|
|
356
|
+
* @param {Partial<IParsedSample>} update - The update data.
|
|
357
|
+
* @returns {Promise<void>} Resolves when the validation is updated. Throws on error.
|
|
358
|
+
*/
|
|
179
359
|
updateValidation: async (tag, update) => {
|
|
180
360
|
this.checkProductInit();
|
|
181
361
|
return this.productBuilder.updateDataValidation(tag, update);
|
|
182
362
|
},
|
|
183
363
|
environments: {
|
|
364
|
+
/**
|
|
365
|
+
* Creates an environment for a product.
|
|
366
|
+
* @param {IProductEnv} data - The environment data.
|
|
367
|
+
* @returns {Promise<void>} Resolves when the environment is created. Throws on error.
|
|
368
|
+
*/
|
|
184
369
|
create: async (data) => {
|
|
185
370
|
this.checkProductInit();
|
|
186
371
|
return this.productBuilder.createEnv(data);
|
|
187
372
|
},
|
|
373
|
+
/**
|
|
374
|
+
* Fetches all environments for a product.
|
|
375
|
+
* @returns {IAppEnv[]} The list of environments.
|
|
376
|
+
*/
|
|
188
377
|
fetchAll: () => {
|
|
189
378
|
this.checkProductInit();
|
|
190
379
|
return this.productBuilder.fetchEnvs();
|
|
191
380
|
},
|
|
381
|
+
/**
|
|
382
|
+
* Fetches an environment by slug.
|
|
383
|
+
* @param {string} slug - The environment slug.
|
|
384
|
+
* @returns {IAppEnv|null} The fetched environment, or null if not found.
|
|
385
|
+
*/
|
|
192
386
|
fetch: (slug) => {
|
|
193
387
|
this.checkProductInit();
|
|
194
388
|
return this.productBuilder.fetchEnv(slug);
|
|
195
389
|
},
|
|
390
|
+
/**
|
|
391
|
+
* Updates an environment by slug.
|
|
392
|
+
* @param {string} slug - The environment slug.
|
|
393
|
+
* @param {Partial<IProductEnv>} data - The environment data to update.
|
|
394
|
+
* @returns {Promise<void>} Resolves when the environment is updated. Throws on error.
|
|
395
|
+
*/
|
|
196
396
|
update: async (slug, data) => {
|
|
197
397
|
this.checkProductInit();
|
|
198
398
|
return this.productBuilder.updateEnv(slug, data);
|
|
199
399
|
},
|
|
200
400
|
},
|
|
201
401
|
storage: {
|
|
402
|
+
/**
|
|
403
|
+
* Creates a storage for a product.
|
|
404
|
+
* @param {IProductStorage} data - The storage data.
|
|
405
|
+
* @returns {Promise<void>} Resolves when the storage is created. Throws on error.
|
|
406
|
+
*/
|
|
202
407
|
create: async (data) => {
|
|
203
408
|
this.checkProductInit();
|
|
204
409
|
return this.productBuilder.createStorage(data);
|
|
205
410
|
},
|
|
411
|
+
/**
|
|
412
|
+
* Fetches all storages for a product.
|
|
413
|
+
* @returns {IProductStorage[]} The list of storages.
|
|
414
|
+
*/
|
|
206
415
|
fetchAll: () => {
|
|
207
416
|
this.checkProductInit();
|
|
208
417
|
return this.productBuilder.fetchStorages();
|
|
209
418
|
},
|
|
419
|
+
/**
|
|
420
|
+
* Fetches a storage by tag.
|
|
421
|
+
* @param {string} tag - The storage tag.
|
|
422
|
+
* @returns {IProductStorage|null} The fetched storage, or null if not found.
|
|
423
|
+
*/
|
|
210
424
|
fetch: (tag) => {
|
|
211
425
|
this.checkProductInit();
|
|
212
426
|
return this.productBuilder.fetchStorage(tag);
|
|
213
427
|
},
|
|
428
|
+
/**
|
|
429
|
+
* Updates a storage by tag.
|
|
430
|
+
* @param {string} tag - The storage tag.
|
|
431
|
+
* @param {Partial<IProductStorage>} data - The storage data to update.
|
|
432
|
+
* @returns {Promise<void>} Resolves when the storage is updated. Throws on error.
|
|
433
|
+
*/
|
|
214
434
|
update: async (tag, data) => {
|
|
215
435
|
this.checkProductInit();
|
|
216
436
|
return this.productBuilder.updateStorage(tag, data);
|
|
217
437
|
},
|
|
438
|
+
/**
|
|
439
|
+
* Fetches storage files for a product.
|
|
440
|
+
* @param {IFetchFilesPayload} data - The fetch files payload.
|
|
441
|
+
* @returns {Promise<void>} Resolves when the storage files are fetched. Throws on error.
|
|
442
|
+
*/
|
|
218
443
|
files: async (data) => {
|
|
219
444
|
this.checkProductInit();
|
|
220
445
|
return this.productBuilder.fetchStorageFiles(data);
|
|
221
446
|
}
|
|
222
447
|
},
|
|
223
|
-
/*cloudFunctions: {
|
|
224
|
-
create: async (data: IProductFunction) => {
|
|
225
|
-
this.checkProductInit();
|
|
226
|
-
return this.productBuilder.createFunction(data);
|
|
227
|
-
},
|
|
228
|
-
fetchAll: () => {
|
|
229
|
-
this.checkProductInit();
|
|
230
|
-
return this.productBuilder.fetchFunctions();
|
|
231
|
-
},
|
|
232
|
-
fetch: (tag: string) => {
|
|
233
|
-
this.checkProductInit();
|
|
234
|
-
return this.productBuilder.fetchFunction(tag);
|
|
235
|
-
},
|
|
236
|
-
update: async (tag: string, data: Partial<IProductFunction>) => {
|
|
237
|
-
this.checkProductInit();
|
|
238
|
-
return this.productBuilder.updateFunction(tag, data);
|
|
239
|
-
},
|
|
240
|
-
},*/
|
|
241
448
|
messageBrokers: {
|
|
449
|
+
/**
|
|
450
|
+
* Creates a message broker for a product.
|
|
451
|
+
* @param {Partial<IProductMessageBroker>} data - The message broker data.
|
|
452
|
+
* @returns {Promise<void>} Resolves when the message broker is created. Throws on error.
|
|
453
|
+
*/
|
|
242
454
|
create: async (data) => {
|
|
243
455
|
this.checkProductInit();
|
|
244
456
|
return this.productBuilder.createMessageBroker(data);
|
|
245
457
|
},
|
|
458
|
+
/**
|
|
459
|
+
* Fetches all message brokers for a product.
|
|
460
|
+
* @returns {IProductMessageBroker[]} The list of message brokers.
|
|
461
|
+
*/
|
|
246
462
|
fetchAll: () => {
|
|
247
463
|
this.checkProductInit();
|
|
248
464
|
return this.productBuilder.fetchMessageBrokers();
|
|
249
465
|
},
|
|
466
|
+
/**
|
|
467
|
+
* Fetches a message broker by tag.
|
|
468
|
+
* @param {string} tag - The message broker tag.
|
|
469
|
+
* @returns {IProductMessageBroker|null} The fetched message broker, or null if not found.
|
|
470
|
+
*/
|
|
250
471
|
fetch: (tag) => {
|
|
251
472
|
this.checkProductInit();
|
|
252
473
|
return this.productBuilder.fetchMessageBroker(tag);
|
|
253
474
|
},
|
|
475
|
+
/**
|
|
476
|
+
* Updates a message broker by tag.
|
|
477
|
+
* @param {string} tag - The message broker tag.
|
|
478
|
+
* @param {Partial<IProductMessageBroker>} data - The message broker data to update.
|
|
479
|
+
* @returns {Promise<void>} Resolves when the message broker is updated. Throws on error.
|
|
480
|
+
*/
|
|
254
481
|
update: async (tag, data) => {
|
|
255
482
|
this.checkProductInit();
|
|
256
483
|
return this.productBuilder.updateMessageBroker(tag, data);
|
|
257
484
|
},
|
|
258
485
|
topics: {
|
|
486
|
+
/**
|
|
487
|
+
* Creates a message broker topic for a product.
|
|
488
|
+
* @param {IProductMessageBrokerTopic} data - The message broker topic data.
|
|
489
|
+
* @returns {Promise<void>} Resolves when the message broker topic is created. Throws on error.
|
|
490
|
+
*/
|
|
259
491
|
create: async (data) => {
|
|
260
492
|
this.checkProductInit();
|
|
261
493
|
return this.productBuilder.createMessageBrokerTopic(data);
|
|
262
494
|
},
|
|
495
|
+
/**
|
|
496
|
+
* Fetches all message broker topics for a message broker by tag.
|
|
497
|
+
* @param {string} messageBrokerTag - The message broker tag.
|
|
498
|
+
* @returns {IProductMessageBrokerTopic[]} The list of message broker topics.
|
|
499
|
+
*/
|
|
263
500
|
fetchAll: (messageBrokerTag) => {
|
|
264
501
|
this.checkProductInit();
|
|
265
502
|
return this.productBuilder.fetchMessageBrokerTopics(messageBrokerTag);
|
|
266
503
|
},
|
|
504
|
+
/**
|
|
505
|
+
* Fetches a message broker topic by tag.
|
|
506
|
+
* @param {string} tag - The message broker topic tag.
|
|
507
|
+
* @returns {IProductMessageBrokerTopic|null} The fetched message broker topic, or null if not found.
|
|
508
|
+
*/
|
|
267
509
|
fetch: (tag) => {
|
|
268
510
|
this.checkProductInit();
|
|
269
511
|
return this.productBuilder.fetchMessageBrokerTopic(tag);
|
|
270
512
|
},
|
|
513
|
+
/**
|
|
514
|
+
* Updates a message broker topic by tag.
|
|
515
|
+
* @param {string} tag - The message broker topic tag.
|
|
516
|
+
* @param {Partial<IProductMessageBrokerTopic>} data - The message broker topic data to update.
|
|
517
|
+
* @returns {Promise<void>} Resolves when the message broker topic is updated. Throws on error.
|
|
518
|
+
*/
|
|
271
519
|
update: (tag, data) => {
|
|
272
520
|
this.checkProductInit();
|
|
273
521
|
return this.productBuilder.updateMessageBrokerTopic(Object.assign(Object.assign({}, data), { tag }));
|
|
@@ -275,35 +523,76 @@ class Ductape {
|
|
|
275
523
|
},
|
|
276
524
|
},
|
|
277
525
|
notifications: {
|
|
526
|
+
/**
|
|
527
|
+
* Creates a notification for a product.
|
|
528
|
+
* @param {IProductNotification} data - The notification data.
|
|
529
|
+
* @returns {Promise<void>} Resolves when the notification is created. Throws on error.
|
|
530
|
+
*/
|
|
278
531
|
create: async (data) => {
|
|
279
532
|
this.checkProductInit();
|
|
280
533
|
return this.productBuilder.createNotification(data);
|
|
281
534
|
},
|
|
535
|
+
/**
|
|
536
|
+
* Fetches all notifications for a product.
|
|
537
|
+
* @returns {IProductNotification[]} The list of notifications.
|
|
538
|
+
*/
|
|
282
539
|
fetchAll: () => {
|
|
283
540
|
this.checkProductInit();
|
|
284
541
|
return this.productBuilder.fetchNotifications();
|
|
285
542
|
},
|
|
543
|
+
/**
|
|
544
|
+
* Fetches a notification by tag.
|
|
545
|
+
* @param {string} tag - The notification tag.
|
|
546
|
+
* @returns {IProductNotification|null} The fetched notification, or null if not found.
|
|
547
|
+
*/
|
|
286
548
|
fetch: (tag) => {
|
|
287
549
|
this.checkProductInit();
|
|
288
550
|
return this.productBuilder.fetchNotification(tag);
|
|
289
551
|
},
|
|
552
|
+
/**
|
|
553
|
+
* Updates a notification by tag.
|
|
554
|
+
* @param {string} tag - The notification tag.
|
|
555
|
+
* @param {Partial<IProductNotification>} data - The notification data to update.
|
|
556
|
+
* @returns {Promise<void>} Resolves when the notification is updated. Throws on error.
|
|
557
|
+
*/
|
|
290
558
|
update: async (tag, data) => {
|
|
291
559
|
this.checkProductInit();
|
|
292
560
|
return this.productBuilder.updateNotification(tag, data);
|
|
293
561
|
},
|
|
294
562
|
messages: {
|
|
563
|
+
/**
|
|
564
|
+
* Creates a notification message for a product.
|
|
565
|
+
* @param {IProductNotificationTemplate} data - The notification message data.
|
|
566
|
+
* @returns {Promise<void>} Resolves when the notification message is created. Throws on error.
|
|
567
|
+
*/
|
|
295
568
|
create: async (data) => {
|
|
296
569
|
this.checkProductInit();
|
|
297
570
|
return this.productBuilder.createNotificationMessage(data);
|
|
298
571
|
},
|
|
572
|
+
/**
|
|
573
|
+
* Fetches all notification messages for a notification by tag.
|
|
574
|
+
* @param {string} notificationTag - The notification tag.
|
|
575
|
+
* @returns {IProductNotificationTemplate[]} The list of notification messages.
|
|
576
|
+
*/
|
|
299
577
|
fetchAll: (notificationTag) => {
|
|
300
578
|
this.checkProductInit();
|
|
301
579
|
return this.productBuilder.fetchNotificationMessages(notificationTag);
|
|
302
580
|
},
|
|
581
|
+
/**
|
|
582
|
+
* Fetches a notification message by tag.
|
|
583
|
+
* @param {string} tag - The notification message tag.
|
|
584
|
+
* @returns {IProductNotificationTemplate|null} The fetched notification message, or null if not found.
|
|
585
|
+
*/
|
|
303
586
|
fetch: (tag) => {
|
|
304
587
|
this.checkProductInit();
|
|
305
588
|
return this.productBuilder.fetchNotificationMessage(tag);
|
|
306
589
|
},
|
|
590
|
+
/**
|
|
591
|
+
* Updates a notification message by tag.
|
|
592
|
+
* @param {string} tag - The notification message tag.
|
|
593
|
+
* @param {Partial<IProductNotificationTemplate>} data - The notification message data to update.
|
|
594
|
+
* @returns {Promise<void>} Resolves when the notification message is updated. Throws on error.
|
|
595
|
+
*/
|
|
307
596
|
update: async (tag, data) => {
|
|
308
597
|
this.checkProductInit();
|
|
309
598
|
return this.productBuilder.updateNotificationMessage(Object.assign(Object.assign({}, data), { tag }));
|
|
@@ -311,53 +600,115 @@ class Ductape {
|
|
|
311
600
|
},
|
|
312
601
|
},
|
|
313
602
|
databases: {
|
|
603
|
+
/**
|
|
604
|
+
* Creates a database for a product.
|
|
605
|
+
* @param {IProductDatabase} data - The database data.
|
|
606
|
+
* @returns {Promise<void>} Resolves when the database is created. Throws on error.
|
|
607
|
+
*/
|
|
314
608
|
create: async (data) => {
|
|
315
609
|
this.checkProductInit();
|
|
316
610
|
return this.productBuilder.createDatabase(data);
|
|
317
611
|
},
|
|
612
|
+
/**
|
|
613
|
+
* Fetches all databases for a product.
|
|
614
|
+
* @returns {IProductDatabase[]} The list of databases.
|
|
615
|
+
*/
|
|
318
616
|
fetchAll: () => {
|
|
319
617
|
this.checkProductInit();
|
|
320
618
|
return this.productBuilder.fetchDatabases();
|
|
321
619
|
},
|
|
620
|
+
/**
|
|
621
|
+
* Fetches a database by tag.
|
|
622
|
+
* @param {string} tag - The database tag.
|
|
623
|
+
* @returns {IProductDatabase|null} The fetched database, or null if not found.
|
|
624
|
+
*/
|
|
322
625
|
fetch: (tag) => {
|
|
323
626
|
this.checkProductInit();
|
|
324
627
|
return this.productBuilder.fetchDatabase(tag);
|
|
325
628
|
},
|
|
629
|
+
/**
|
|
630
|
+
* Updates a database by tag.
|
|
631
|
+
* @param {string} tag - The database tag.
|
|
632
|
+
* @param {Partial<IProductDatabase>} data - The database data to update.
|
|
633
|
+
* @returns {Promise<void>} Resolves when the database is updated. Throws on error.
|
|
634
|
+
*/
|
|
326
635
|
update: async (tag, data) => {
|
|
327
636
|
this.checkProductInit();
|
|
328
637
|
return this.productBuilder.updateDatabase(tag, data);
|
|
329
638
|
},
|
|
330
639
|
actions: {
|
|
640
|
+
/**
|
|
641
|
+
* Creates a database action for a product.
|
|
642
|
+
* @param {IProductDatabaseAction} data - The database action data.
|
|
643
|
+
* @returns {Promise<void>} Resolves when the database action is created. Throws on error.
|
|
644
|
+
*/
|
|
331
645
|
create: async (data) => {
|
|
332
646
|
this.checkProductInit();
|
|
333
647
|
return this.productBuilder.createDatabaseAction(data);
|
|
334
648
|
},
|
|
649
|
+
/**
|
|
650
|
+
* Fetches all database actions for a product.
|
|
651
|
+
* @param {string} databaseTag - The database tag.
|
|
652
|
+
* @returns {IProductDatabaseAction[]} The list of database actions.
|
|
653
|
+
*/
|
|
335
654
|
fetchAll: (databaseTag) => {
|
|
336
655
|
this.checkProductInit();
|
|
337
656
|
return this.productBuilder.fetchDatabaseActions(databaseTag);
|
|
338
657
|
},
|
|
658
|
+
/**
|
|
659
|
+
* Fetches a database action by tag.
|
|
660
|
+
* @param {string} tag - The database action tag.
|
|
661
|
+
* @returns {IProductDatabaseAction|null} The fetched database action, or null if not found.
|
|
662
|
+
*/
|
|
339
663
|
fetch: (tag) => {
|
|
340
664
|
this.checkProductInit();
|
|
341
665
|
return this.productBuilder.fetchDatabaseAction(tag);
|
|
342
666
|
},
|
|
667
|
+
/**
|
|
668
|
+
* Updates a database action by tag.
|
|
669
|
+
* @param {string} tag - The database action tag.
|
|
670
|
+
* @param {Partial<IProductDatabaseAction>} data - The database action data to update.
|
|
671
|
+
* @returns {Promise<void>} Resolves when the database action is updated. Throws on error.
|
|
672
|
+
*/
|
|
343
673
|
update: async (tag, data) => {
|
|
344
674
|
this.checkProductInit();
|
|
345
675
|
return this.productBuilder.updateDatabaseAction(Object.assign(Object.assign({}, data), { tag }));
|
|
346
676
|
},
|
|
347
677
|
},
|
|
348
678
|
migrations: {
|
|
679
|
+
/**
|
|
680
|
+
* Creates a database migration for a product.
|
|
681
|
+
* @param {IProductDatabaseMigration} data - The database migration data.
|
|
682
|
+
* @returns {void} Resolves when the database migration is created. Throws on error.
|
|
683
|
+
*/
|
|
349
684
|
create: (data) => {
|
|
350
685
|
this.checkProductInit();
|
|
351
686
|
return this.productBuilder.createDatabaseMigration(data);
|
|
352
687
|
},
|
|
688
|
+
/**
|
|
689
|
+
* Fetches all database migrations for a product.
|
|
690
|
+
* @param {string} databaseTag - The database tag.
|
|
691
|
+
* @returns {IProductDatabaseMigration[]} The list of database migrations.
|
|
692
|
+
*/
|
|
353
693
|
fetchAll: (databaseTag) => {
|
|
354
694
|
this.checkProductInit();
|
|
355
695
|
return this.productBuilder.fetchDatabaseMigrations(databaseTag);
|
|
356
696
|
},
|
|
697
|
+
/**
|
|
698
|
+
* Fetches a database migration by tag.
|
|
699
|
+
* @param {string} tag - The database migration tag.
|
|
700
|
+
* @returns {IProductDatabaseMigration|null} The fetched database migration, or null if not found.
|
|
701
|
+
*/
|
|
357
702
|
fetch: (tag) => {
|
|
358
703
|
this.checkProductInit();
|
|
359
704
|
return this.productBuilder.fetchDatabaseMigration(tag);
|
|
360
705
|
},
|
|
706
|
+
/**
|
|
707
|
+
* Updates a database migration by tag.
|
|
708
|
+
* @param {string} tag - The database migration tag.
|
|
709
|
+
* @param {Partial<IProductDatabaseMigration>} data - The database migration data to update.
|
|
710
|
+
* @returns {void} Resolves when the database migration is updated. Throws on error.
|
|
711
|
+
*/
|
|
361
712
|
update: (tag, data) => {
|
|
362
713
|
this.checkProductInit();
|
|
363
714
|
return this.productBuilder.updateDatabaseMigration(Object.assign(Object.assign({}, data), { tag }));
|
|
@@ -365,36 +716,76 @@ class Ductape {
|
|
|
365
716
|
},
|
|
366
717
|
},
|
|
367
718
|
jobs: {
|
|
719
|
+
/**
|
|
720
|
+
* Creates a job for a product.
|
|
721
|
+
* @param {Partial<IProductJobs>} data - The job data.
|
|
722
|
+
* @returns {Promise<void>} Resolves when the job is created. Throws on error.
|
|
723
|
+
*/
|
|
368
724
|
create: async (data) => {
|
|
369
725
|
this.checkProductInit();
|
|
370
726
|
return this.productBuilder.createJob(data);
|
|
371
727
|
},
|
|
728
|
+
/**
|
|
729
|
+
* Fetches all jobs for a product.
|
|
730
|
+
* @returns {IProductJobs[]} The list of jobs.
|
|
731
|
+
*/
|
|
372
732
|
fetchAll: () => {
|
|
373
733
|
this.checkProductInit();
|
|
374
734
|
return this.productBuilder.fetchJobs();
|
|
375
735
|
},
|
|
736
|
+
/**
|
|
737
|
+
* Fetches a job by tag.
|
|
738
|
+
* @param {string} tag - The job tag.
|
|
739
|
+
* @returns {IProductJobs|null} The fetched job, or null if not found.
|
|
740
|
+
*/
|
|
376
741
|
fetch: (tag) => {
|
|
377
742
|
this.checkProductInit();
|
|
378
743
|
return this.productBuilder.fetchJob(tag);
|
|
379
744
|
},
|
|
745
|
+
/**
|
|
746
|
+
* Updates a job by tag.
|
|
747
|
+
* @param {string} tag - The job tag.
|
|
748
|
+
* @param {Partial<IProductJobs>} data - The job data to update.
|
|
749
|
+
* @returns {Promise<void>} Resolves when the job is updated. Throws on error.
|
|
750
|
+
*/
|
|
380
751
|
update: async (tag, data) => {
|
|
381
752
|
this.checkProductInit();
|
|
382
753
|
return this.productBuilder.updateJob(tag, data);
|
|
383
754
|
},
|
|
384
755
|
},
|
|
385
756
|
caches: {
|
|
757
|
+
/**
|
|
758
|
+
* Creates a cache for a product.
|
|
759
|
+
* @param {IProductCache} data - The cache data.
|
|
760
|
+
* @returns {Promise<void>} Resolves when the cache is created. Throws on error.
|
|
761
|
+
*/
|
|
386
762
|
create: async (data) => {
|
|
387
763
|
this.checkProductInit();
|
|
388
764
|
return this.productBuilder.createCache(data);
|
|
389
765
|
},
|
|
766
|
+
/**
|
|
767
|
+
* Fetches all caches for a product.
|
|
768
|
+
* @returns {IProductCache[]} The list of caches.
|
|
769
|
+
*/
|
|
390
770
|
fetchAll: () => {
|
|
391
771
|
this.checkProductInit();
|
|
392
772
|
return this.productBuilder.fetchCaches();
|
|
393
773
|
},
|
|
774
|
+
/**
|
|
775
|
+
* Fetches a cache by tag.
|
|
776
|
+
* @param {string} tag - The cache tag.
|
|
777
|
+
* @returns {IProductCache|null} The fetched cache, or null if not found.
|
|
778
|
+
*/
|
|
394
779
|
fetch: (tag) => {
|
|
395
780
|
this.checkProductInit();
|
|
396
781
|
return this.productBuilder.fetchCache(tag);
|
|
397
782
|
},
|
|
783
|
+
/**
|
|
784
|
+
* Updates a cache by tag.
|
|
785
|
+
* @param {string} tag - The cache tag.
|
|
786
|
+
* @param {Partial<IProductCache>} data - The cache data to update.
|
|
787
|
+
* @returns {Promise<void>} Resolves when the cache is updated. Throws on error.
|
|
788
|
+
*/
|
|
398
789
|
update: async (tag, data) => {
|
|
399
790
|
this.checkProductInit();
|
|
400
791
|
return this.productBuilder.updateCache(tag, data);
|
|
@@ -405,41 +796,85 @@ class Ductape {
|
|
|
405
796
|
},
|
|
406
797
|
},
|
|
407
798
|
features: {
|
|
799
|
+
/**
|
|
800
|
+
* Creates a feature for a product.
|
|
801
|
+
* @param {Partial<IProductFeature>} data - The feature data.
|
|
802
|
+
* @returns {Promise<void>} Resolves when the feature is created. Throws on error.
|
|
803
|
+
*/
|
|
408
804
|
create: async (data) => {
|
|
409
805
|
this.checkProductInit();
|
|
410
806
|
return this.productBuilder.createFeature(data);
|
|
411
807
|
},
|
|
808
|
+
/**
|
|
809
|
+
* Fetches all features for a product.
|
|
810
|
+
* @returns {IProductFeature[]} The list of features.
|
|
811
|
+
*/
|
|
412
812
|
fetchAll: () => {
|
|
413
813
|
this.checkProductInit();
|
|
414
814
|
return this.productBuilder.fetchFeatures();
|
|
415
815
|
},
|
|
816
|
+
/**
|
|
817
|
+
* Fetches a feature by tag.
|
|
818
|
+
* @param {string} tag - The feature tag.
|
|
819
|
+
* @returns {IProductFeature|null} The fetched feature, or null if not found.
|
|
820
|
+
*/
|
|
416
821
|
fetch: (tag) => {
|
|
417
822
|
this.checkProductInit();
|
|
418
823
|
return this.productBuilder.fetchFeature(tag);
|
|
419
824
|
},
|
|
825
|
+
/**
|
|
826
|
+
* Updates a feature by tag.
|
|
827
|
+
* @param {string} tag - The feature tag.
|
|
828
|
+
* @param {Partial<IProductCache>} data - The feature data to update.
|
|
829
|
+
* @returns {Promise<void>} Resolves when the feature is updated. Throws on error.
|
|
830
|
+
*/
|
|
420
831
|
update: async (tag, data) => {
|
|
421
832
|
this.checkProductInit();
|
|
422
833
|
return this.productBuilder.updateFeature(tag, data);
|
|
423
834
|
},
|
|
424
835
|
},
|
|
425
836
|
};
|
|
837
|
+
/**
|
|
838
|
+
* App-related operations for managing apps, variables, constants, actions, auths, webhooks, environments, and validation.
|
|
839
|
+
*/
|
|
426
840
|
this.app = {
|
|
841
|
+
/**
|
|
842
|
+
* Creates a new app.
|
|
843
|
+
* @param {ICreateAppBuilder} data - The app data.
|
|
844
|
+
* @returns {Promise<{ app_id: string }>} The ID of the created app.
|
|
845
|
+
*/
|
|
427
846
|
create: async (data) => {
|
|
428
847
|
await this.initApp();
|
|
429
848
|
return this.appBuilder.createApp(data);
|
|
430
849
|
},
|
|
850
|
+
/**
|
|
851
|
+
* Fetches an app by tag.
|
|
852
|
+
* @param {string} tag - The app tag.
|
|
853
|
+
* @returns {Promise<IApp|null>} The fetched app, or null if not found.
|
|
854
|
+
*/
|
|
431
855
|
fetch: async (tag) => {
|
|
432
856
|
await this.initApp();
|
|
433
857
|
await this.appBuilder.initializeAppByTag(tag);
|
|
434
858
|
this.appInit = false;
|
|
435
859
|
return this.appBuilder.fetchApp();
|
|
436
860
|
},
|
|
861
|
+
/**
|
|
862
|
+
* Updates an app by tag.
|
|
863
|
+
* @param {string} tag - The app tag.
|
|
864
|
+
* @param {Partial<IApp>} data - The app data to update.
|
|
865
|
+
* @returns {Promise<void>} Resolves when the app is updated. Throws on error.
|
|
866
|
+
*/
|
|
437
867
|
update: async (tag, data) => {
|
|
438
868
|
await this.initApp();
|
|
439
869
|
await this.appBuilder.initializeAppByTag(tag);
|
|
440
870
|
this.appInit = false;
|
|
441
871
|
return this.appBuilder.updateApp(data);
|
|
442
872
|
},
|
|
873
|
+
/**
|
|
874
|
+
* Initializes an app by tag.
|
|
875
|
+
* @param {string} appTag - The app tag.
|
|
876
|
+
* @returns {Promise<void>} Resolves when initialization is complete. Throws on error.
|
|
877
|
+
*/
|
|
443
878
|
init: async (appTag) => {
|
|
444
879
|
console.log(`App initialized with tag: ${appTag}`);
|
|
445
880
|
await this.initApp();
|
|
@@ -447,43 +882,93 @@ class Ductape {
|
|
|
447
882
|
this.appInit = true;
|
|
448
883
|
},
|
|
449
884
|
variables: {
|
|
885
|
+
/**
|
|
886
|
+
* Creates a variable for an app.
|
|
887
|
+
* @param {IAppVariables} data - The variable data.
|
|
888
|
+
* @returns {Promise<void>} Resolves when the variable is created. Throws on error.
|
|
889
|
+
*/
|
|
450
890
|
create: async (data) => {
|
|
451
891
|
this.checkAppInit();
|
|
452
892
|
return this.appBuilder.createVariable(data);
|
|
453
893
|
},
|
|
894
|
+
/**
|
|
895
|
+
* Fetches all variables for an app.
|
|
896
|
+
* @returns {IAppVariables[]} The list of variables.
|
|
897
|
+
*/
|
|
454
898
|
fetchAll: () => {
|
|
455
899
|
this.checkAppInit();
|
|
456
900
|
return this.appBuilder.fetchVariables();
|
|
457
901
|
},
|
|
902
|
+
/**
|
|
903
|
+
* Fetches a variable by tag.
|
|
904
|
+
* @param {string} tag - The variable tag.
|
|
905
|
+
* @returns {IAppVariables|null} The fetched variable, or null if not found.
|
|
906
|
+
*/
|
|
458
907
|
fetch: (tag) => {
|
|
459
908
|
this.checkAppInit();
|
|
460
909
|
return this.appBuilder.fetchVariable(tag);
|
|
461
910
|
},
|
|
911
|
+
/**
|
|
912
|
+
* Updates a variable by tag.
|
|
913
|
+
* @param {string} tag - The variable tag.
|
|
914
|
+
* @param {Partial<IAppVariables>} data - The variable data to update.
|
|
915
|
+
* @returns {Promise<void>} Resolves when the variable is updated. Throws on error.
|
|
916
|
+
*/
|
|
462
917
|
update: async (tag, data) => {
|
|
463
918
|
this.checkAppInit();
|
|
464
919
|
return this.appBuilder.updateVariable(tag, data);
|
|
465
920
|
},
|
|
466
921
|
},
|
|
467
922
|
constants: {
|
|
923
|
+
/**
|
|
924
|
+
* Creates a constant for an app.
|
|
925
|
+
* @param {IAppConstants} data - The constant data.
|
|
926
|
+
* @returns {Promise<void>} Resolves when the constant is created. Throws on error.
|
|
927
|
+
*/
|
|
468
928
|
create: async (data) => {
|
|
469
929
|
this.checkAppInit();
|
|
470
930
|
return this.appBuilder.createConstant(data);
|
|
471
931
|
},
|
|
932
|
+
/**
|
|
933
|
+
* Fetches all constants for an app.
|
|
934
|
+
* @returns {IAppConstants[]} The list of constants.
|
|
935
|
+
*/
|
|
472
936
|
fetchAll: () => {
|
|
473
937
|
this.checkAppInit();
|
|
474
938
|
return this.appBuilder.fetchConstants();
|
|
475
939
|
},
|
|
940
|
+
/**
|
|
941
|
+
* Fetches a constant by tag.
|
|
942
|
+
* @param {string} tag - The constant tag.
|
|
943
|
+
* @returns {IAppConstants|null} The fetched constant, or null if not found.
|
|
944
|
+
*/
|
|
476
945
|
fetch: (tag) => {
|
|
477
946
|
this.checkAppInit();
|
|
478
947
|
return this.appBuilder.fetchConstant(tag);
|
|
479
948
|
},
|
|
949
|
+
/**
|
|
950
|
+
* Updates a constant by tag.
|
|
951
|
+
* @param {string} tag - The constant tag.
|
|
952
|
+
* @param {Partial<IAppVariables>} data - The constant data to update.
|
|
953
|
+
* @returns {Promise<void>} Resolves when the constant is updated. Throws on error.
|
|
954
|
+
*/
|
|
480
955
|
update: async (tag, data) => {
|
|
481
956
|
this.checkAppInit();
|
|
482
957
|
return this.appBuilder.updateConstant(tag, data);
|
|
483
958
|
},
|
|
484
959
|
},
|
|
485
960
|
actions: {
|
|
486
|
-
|
|
961
|
+
/**
|
|
962
|
+
* Imports actions for an app from a file.
|
|
963
|
+
* @param {Object} params - The import parameters.
|
|
964
|
+
* @param {Buffer} params.file - The file buffer.
|
|
965
|
+
* @param {ImportDocsTypes} params.type - The import type.
|
|
966
|
+
* @param {string} params.version - The version.
|
|
967
|
+
* @param {string} [params.appTag] - The app tag (optional).
|
|
968
|
+
* @param {boolean} [params.updateIfExists] - Whether to update if actions exist (optional).
|
|
969
|
+
* @returns {Promise<void>} Resolves when the import is complete. Throws on error.
|
|
970
|
+
*/
|
|
971
|
+
import: async ({ file, type, version, appTag, updateIfExists, isAdminImport, }) => {
|
|
487
972
|
var _a;
|
|
488
973
|
if (!this.token)
|
|
489
974
|
await this.initUserAuth();
|
|
@@ -503,69 +988,155 @@ class Ductape {
|
|
|
503
988
|
}
|
|
504
989
|
app_id = app._id;
|
|
505
990
|
}
|
|
506
|
-
return this.importService.importApp(file, type, version, updateIfExists, app_id);
|
|
507
|
-
},
|
|
991
|
+
return this.importService.importApp(file, type, version, updateIfExists, app_id, isAdminImport);
|
|
992
|
+
},
|
|
993
|
+
/**
|
|
994
|
+
* Updates an action by tag.
|
|
995
|
+
* @param {string} tag - The action tag.
|
|
996
|
+
* @param {Partial<IActionUpdate>} data - The action data to update.
|
|
997
|
+
* @returns {Promise<void>} Resolves when the action is updated. Throws on error.
|
|
998
|
+
*/
|
|
508
999
|
update: async (tag, data) => {
|
|
509
1000
|
this.checkAppInit();
|
|
510
1001
|
return this.appBuilder.updateAction(tag, data);
|
|
511
1002
|
},
|
|
1003
|
+
/**
|
|
1004
|
+
* Updates an action by tag.
|
|
1005
|
+
* @param {string} tag - The action tag.
|
|
1006
|
+
* @param {Partial<IActionUpdate>} data - The action data to update.
|
|
1007
|
+
* @returns {Promise<void>} Resolves when the action is updated. Throws on error.
|
|
1008
|
+
*/
|
|
1009
|
+
create: async (data) => {
|
|
1010
|
+
this.checkAppInit();
|
|
1011
|
+
return this.appBuilder.createAction(data);
|
|
1012
|
+
},
|
|
1013
|
+
/**
|
|
1014
|
+
* Fetches all actions for an app.
|
|
1015
|
+
* @returns {IAppAction[]} The list of actions.
|
|
1016
|
+
*/
|
|
512
1017
|
fetchAll: () => {
|
|
513
1018
|
this.checkAppInit();
|
|
514
1019
|
return this.appBuilder.fetchActions();
|
|
515
1020
|
},
|
|
1021
|
+
/**
|
|
1022
|
+
* Fetches an action by tag.
|
|
1023
|
+
* @param {string} tag - The action tag.
|
|
1024
|
+
* @returns {IAppAction|null} The fetched action, or null if not found.
|
|
1025
|
+
*/
|
|
516
1026
|
fetch: (tag) => {
|
|
517
1027
|
this.checkAppInit();
|
|
518
1028
|
return this.appBuilder.fetchAction(tag);
|
|
519
1029
|
},
|
|
520
1030
|
},
|
|
521
1031
|
auths: {
|
|
1032
|
+
/**
|
|
1033
|
+
* Creates an auth for an app.
|
|
1034
|
+
* @param {IAppAuth} data - The auth data.
|
|
1035
|
+
* @returns {Promise<void>} Resolves when the auth is created. Throws on error.
|
|
1036
|
+
*/
|
|
522
1037
|
create: async (data) => {
|
|
523
1038
|
this.checkAppInit();
|
|
524
1039
|
return this.appBuilder.createAuth(data);
|
|
525
1040
|
},
|
|
1041
|
+
/**
|
|
1042
|
+
* Fetches all auths for an app.
|
|
1043
|
+
* @returns {IAppAuth[]} The list of auths.
|
|
1044
|
+
*/
|
|
526
1045
|
fetchAll: () => {
|
|
527
1046
|
this.checkAppInit();
|
|
528
1047
|
return this.appBuilder.fetchAuths();
|
|
529
1048
|
},
|
|
1049
|
+
/**
|
|
1050
|
+
* Fetches an auth by tag.
|
|
1051
|
+
* @param {string} tag - The auth tag.
|
|
1052
|
+
* @returns {IAppAuth|null} The fetched auth, or null if not found.
|
|
1053
|
+
*/
|
|
530
1054
|
fetch: (tag) => {
|
|
531
1055
|
this.checkAppInit();
|
|
532
1056
|
return this.appBuilder.fetchAuth(tag);
|
|
533
1057
|
},
|
|
1058
|
+
/**
|
|
1059
|
+
* Updates an auth by tag.
|
|
1060
|
+
* @param {string} tag - The auth tag.
|
|
1061
|
+
* @param {Partial<IAppAuth>} data - The auth data to update.
|
|
1062
|
+
* @returns {Promise<void>} Resolves when the auth is updated. Throws on error.
|
|
1063
|
+
*/
|
|
534
1064
|
update: async (tag, data) => {
|
|
535
1065
|
this.checkAppInit();
|
|
536
1066
|
return this.appBuilder.updateAuth(tag, data);
|
|
537
1067
|
},
|
|
538
1068
|
},
|
|
539
1069
|
webhooks: {
|
|
1070
|
+
/**
|
|
1071
|
+
* Creates a webhook for an app.
|
|
1072
|
+
* @param {Partial<IAppWebhook>} data - The webhook data.
|
|
1073
|
+
* @returns {Promise<void>} Resolves when the webhook is created. Throws on error.
|
|
1074
|
+
*/
|
|
540
1075
|
create: async (data) => {
|
|
541
1076
|
this.checkAppInit();
|
|
542
1077
|
return this.appBuilder.createWebhook(data);
|
|
543
1078
|
},
|
|
1079
|
+
/**
|
|
1080
|
+
* Fetches all webhooks for an app.
|
|
1081
|
+
* @returns {IAppWebhook[]} The list of webhooks.
|
|
1082
|
+
*/
|
|
544
1083
|
fetchAll: () => {
|
|
545
1084
|
this.checkAppInit();
|
|
546
1085
|
return this.appBuilder.fetchWebhooks();
|
|
547
1086
|
},
|
|
1087
|
+
/**
|
|
1088
|
+
* Fetches a webhook by tag.
|
|
1089
|
+
* @param {string} tag - The webhook tag.
|
|
1090
|
+
* @returns {IAppWebhook|null} The fetched webhook, or null if not found.
|
|
1091
|
+
*/
|
|
548
1092
|
fetch: (tag) => {
|
|
549
1093
|
this.checkAppInit();
|
|
550
1094
|
return this.appBuilder.fetchWebhook(tag);
|
|
551
1095
|
},
|
|
1096
|
+
/**
|
|
1097
|
+
* Updates a webhook by tag.
|
|
1098
|
+
* @param {string} tag - The webhook tag.
|
|
1099
|
+
* @param {Partial<IAppWebhook>} data - The webhook data to update.
|
|
1100
|
+
* @returns {Promise<void>} Resolves when the webhook is updated. Throws on error.
|
|
1101
|
+
*/
|
|
552
1102
|
update: async (tag, data) => {
|
|
553
1103
|
this.checkAppInit();
|
|
554
1104
|
return this.appBuilder.updateWebhook(tag, data);
|
|
555
1105
|
},
|
|
556
1106
|
events: {
|
|
1107
|
+
/**
|
|
1108
|
+
* Creates a webhook event for an app.
|
|
1109
|
+
* @param {IAppWebhookEvent} data - The webhook event data.
|
|
1110
|
+
* @returns {Promise<void>} Resolves when the webhook event is created. Throws on error.
|
|
1111
|
+
*/
|
|
557
1112
|
create: async (data) => {
|
|
558
1113
|
this.checkAppInit();
|
|
559
1114
|
return this.appBuilder.createWebhookEvent(data);
|
|
560
1115
|
},
|
|
1116
|
+
/**
|
|
1117
|
+
* Fetches all webhook events for a webhook by tag.
|
|
1118
|
+
* @param {string} webhookTag - The webhook tag.
|
|
1119
|
+
* @returns {IAppWebhookEvent[]} The list of webhook events.
|
|
1120
|
+
*/
|
|
561
1121
|
fetchAll: (webhookTag) => {
|
|
562
1122
|
this.checkAppInit();
|
|
563
1123
|
return this.appBuilder.fetchWebhookEvents(webhookTag);
|
|
564
1124
|
},
|
|
1125
|
+
/**
|
|
1126
|
+
* Fetches a webhook event by tag.
|
|
1127
|
+
* @param {string} tag - The webhook event tag.
|
|
1128
|
+
* @returns {IAppWebhookEvent|null} The fetched webhook event, or null if not found.
|
|
1129
|
+
*/
|
|
565
1130
|
fetch: (tag) => {
|
|
566
1131
|
this.checkAppInit();
|
|
567
1132
|
return this.appBuilder.fetchWebhookEvent(tag);
|
|
568
1133
|
},
|
|
1134
|
+
/**
|
|
1135
|
+
* Updates a webhook event by tag.
|
|
1136
|
+
* @param {string} tag - The webhook event tag.
|
|
1137
|
+
* @param {Partial<IAppWebhookEvent>} data - The webhook event data to update.
|
|
1138
|
+
* @returns {Promise<void>} Resolves when the webhook event is updated. Throws on error.
|
|
1139
|
+
*/
|
|
569
1140
|
update: async (tag, data) => {
|
|
570
1141
|
this.checkAppInit();
|
|
571
1142
|
return this.appBuilder.updateWebhookEvent(Object.assign(Object.assign({}, data), { tag }));
|
|
@@ -573,102 +1144,223 @@ class Ductape {
|
|
|
573
1144
|
},
|
|
574
1145
|
},
|
|
575
1146
|
environments: {
|
|
1147
|
+
/**
|
|
1148
|
+
* Creates an environment for an app.
|
|
1149
|
+
* @param {IAppEnv} data - The environment data.
|
|
1150
|
+
* @returns {Promise<void>} Resolves when the environment is created. Throws on error.
|
|
1151
|
+
*/
|
|
576
1152
|
create: async (data) => {
|
|
577
1153
|
this.checkAppInit();
|
|
578
1154
|
return this.appBuilder.createEnv(data);
|
|
579
1155
|
},
|
|
1156
|
+
/**
|
|
1157
|
+
* Fetches all environments for an app.
|
|
1158
|
+
* @returns {IAppEnv[]} The list of environments.
|
|
1159
|
+
*/
|
|
580
1160
|
fetchAll: () => {
|
|
581
1161
|
this.checkAppInit();
|
|
582
1162
|
return this.appBuilder.fetchEnvs();
|
|
583
1163
|
},
|
|
1164
|
+
/**
|
|
1165
|
+
* Fetches an environment by slug.
|
|
1166
|
+
* @param {string} slug - The environment slug.
|
|
1167
|
+
* @returns {IAppEnv|null} The fetched environment, or null if not found.
|
|
1168
|
+
*/
|
|
584
1169
|
fetch: (slug) => {
|
|
585
1170
|
this.checkAppInit();
|
|
586
1171
|
return this.appBuilder.fetchEnv(slug);
|
|
587
1172
|
},
|
|
1173
|
+
/**
|
|
1174
|
+
* Updates an environment by slug.
|
|
1175
|
+
* @param {string} slug - The environment slug.
|
|
1176
|
+
* @param {Partial<IAppEnv>} data - The environment data to update.
|
|
1177
|
+
* @returns {Promise<void>} Resolves when the environment is updated. Throws on error.
|
|
1178
|
+
*/
|
|
588
1179
|
update: async (slug, data) => {
|
|
589
1180
|
this.checkAppInit();
|
|
590
1181
|
return this.appBuilder.updateEnv(slug, data);
|
|
591
1182
|
},
|
|
592
1183
|
},
|
|
1184
|
+
/**
|
|
1185
|
+
* Updates data validation for an app.
|
|
1186
|
+
* @param {string} selector - The selector for the data validation.
|
|
1187
|
+
* @param {Partial<IParsedSample>} update - The update data.
|
|
1188
|
+
* @returns {Promise<void>} Resolves when the validation is updated. Throws on error.
|
|
1189
|
+
*/
|
|
593
1190
|
validation: (selector, update) => {
|
|
594
1191
|
this.checkAppInit();
|
|
595
1192
|
return this.appBuilder.updateDataValidation(selector, update);
|
|
596
1193
|
},
|
|
597
1194
|
};
|
|
1195
|
+
/**
|
|
1196
|
+
* Processor-related operations for running jobs, actions, database actions, sessions, features, quotas, fallbacks, notifications, storage, and message broker.
|
|
1197
|
+
*/
|
|
598
1198
|
this.processor = {
|
|
599
1199
|
job: {
|
|
1200
|
+
/**
|
|
1201
|
+
* Schedules a job for a product.
|
|
1202
|
+
* @param {IProduct} data - The product data.
|
|
1203
|
+
* @returns {Promise<any>} The result of the job scheduling.
|
|
1204
|
+
*/
|
|
600
1205
|
schedule: async (data) => {
|
|
601
1206
|
const processorService = await this.createNewProcessor();
|
|
602
1207
|
//return processorService.processJob()
|
|
603
1208
|
},
|
|
604
1209
|
},
|
|
605
1210
|
action: {
|
|
1211
|
+
/**
|
|
1212
|
+
* Runs an action processor.
|
|
1213
|
+
* @param {IActionProcessorInput} data - The action processor input.
|
|
1214
|
+
* @returns {Promise<any>} The result of the action processing.
|
|
1215
|
+
*/
|
|
606
1216
|
run: async (data) => {
|
|
607
1217
|
const processorService = await this.createNewProcessor();
|
|
608
1218
|
return processorService.processAction(data);
|
|
609
1219
|
},
|
|
610
1220
|
},
|
|
611
1221
|
db: {
|
|
1222
|
+
/**
|
|
1223
|
+
* Executes a database action processor.
|
|
1224
|
+
* @param {IDBActionProcessorInput} data - The database action processor input.
|
|
1225
|
+
* @returns {Promise<any>} The result of the database action processing.
|
|
1226
|
+
*/
|
|
612
1227
|
execute: async (data) => {
|
|
613
1228
|
const processorService = await this.createNewProcessor();
|
|
614
1229
|
return processorService.processDBAction(data);
|
|
615
1230
|
},
|
|
616
1231
|
migration: {
|
|
1232
|
+
/**
|
|
1233
|
+
* Runs a database migration.
|
|
1234
|
+
* @param {Object} params - The migration parameters.
|
|
1235
|
+
* @param {string} params.migration - The migration name.
|
|
1236
|
+
* @param {string} params.env - The environment.
|
|
1237
|
+
* @param {string} params.product - The product name.
|
|
1238
|
+
* @returns {Promise<any>} The result of the migration.
|
|
1239
|
+
*/
|
|
617
1240
|
run: async ({ migration, env, product }) => {
|
|
618
|
-
//this.checkProductInit();
|
|
619
1241
|
const processorService = await this.createNewProcessor();
|
|
620
1242
|
return processorService.runMigration(product, migration, env, 'up');
|
|
621
1243
|
},
|
|
1244
|
+
/**
|
|
1245
|
+
* Rolls back a database migration.
|
|
1246
|
+
* @param {Object} params - The migration parameters.
|
|
1247
|
+
* @param {string} params.migration - The migration name.
|
|
1248
|
+
* @param {string} params.env - The environment.
|
|
1249
|
+
* @param {string} params.product - The product name.
|
|
1250
|
+
* @returns {Promise<any>} The result of the rollback.
|
|
1251
|
+
*/
|
|
622
1252
|
rollback: async ({ migration, env, product }) => {
|
|
623
|
-
//this.checkProductInit();
|
|
624
1253
|
const processorService = await this.createNewProcessor();
|
|
625
1254
|
return processorService.runMigration(product, migration, env, 'down');
|
|
626
1255
|
},
|
|
627
1256
|
},
|
|
628
1257
|
},
|
|
629
1258
|
sessions: {
|
|
630
|
-
|
|
1259
|
+
/**
|
|
1260
|
+
* Starts a new session.
|
|
1261
|
+
* @param {ISessionInput} data - The session input data.
|
|
1262
|
+
* @returns {Promise<any>} The result of the session generation.
|
|
1263
|
+
*/
|
|
1264
|
+
start: async (data) => {
|
|
631
1265
|
const processorService = await this.createNewProcessor();
|
|
632
1266
|
return processorService.generateSession(data);
|
|
1267
|
+
},
|
|
1268
|
+
/**
|
|
1269
|
+
* Decrypts a session.
|
|
1270
|
+
* @param {ISessionPayload} data - The session payload.
|
|
1271
|
+
* @returns {Promise<any>} The decrypted session.
|
|
1272
|
+
*/
|
|
1273
|
+
decrypt: async (data) => {
|
|
1274
|
+
const processorService = await this.createNewProcessor();
|
|
1275
|
+
return processorService.decryptSession(data);
|
|
1276
|
+
},
|
|
1277
|
+
/**
|
|
1278
|
+
* Refreshes a session.
|
|
1279
|
+
* @param {ISessionRefreshPayload} data - The session refresh payload.
|
|
1280
|
+
* @returns {Promise<any>} The refreshed session.
|
|
1281
|
+
*/
|
|
1282
|
+
refresh: async (data) => {
|
|
1283
|
+
const processorService = await this.createNewProcessor();
|
|
1284
|
+
return processorService.refreshSession(data);
|
|
633
1285
|
}
|
|
634
1286
|
},
|
|
635
1287
|
feature: {
|
|
1288
|
+
/**
|
|
1289
|
+
* Runs a feature processor.
|
|
1290
|
+
* @param {IProcessorInput} data - The feature processor input.
|
|
1291
|
+
* @returns {Promise<any>} The result of the feature processing.
|
|
1292
|
+
*/
|
|
636
1293
|
run: async (data) => {
|
|
637
1294
|
const processorService = await this.createNewProcessor();
|
|
638
1295
|
return await processorService.processFeature(data);
|
|
639
1296
|
},
|
|
1297
|
+
/**
|
|
1298
|
+
* Generates output for a process by ID.
|
|
1299
|
+
* @param {string} process_id - The process ID.
|
|
1300
|
+
* @returns {Promise<any>} The generated output.
|
|
1301
|
+
*/
|
|
640
1302
|
output: async (process_id) => {
|
|
641
1303
|
const processorService = await this.createNewProcessor();
|
|
642
1304
|
return await processorService.generateOutput(process_id);
|
|
643
1305
|
},
|
|
1306
|
+
/**
|
|
1307
|
+
* Replays a process by ID.
|
|
1308
|
+
* @param {string} process_id - The process ID.
|
|
1309
|
+
* @returns {Promise<any>} The result of the replay.
|
|
1310
|
+
*/
|
|
644
1311
|
replay: async (process_id) => {
|
|
645
1312
|
const processorService = await this.createNewProcessor();
|
|
646
1313
|
return await processorService.replayProcess(process_id);
|
|
647
1314
|
},
|
|
1315
|
+
/**
|
|
1316
|
+
* Resumes a process by ID.
|
|
1317
|
+
* @param {string} process_id - The process ID.
|
|
1318
|
+
* @returns {Promise<any>} The result of the resume.
|
|
1319
|
+
*/
|
|
648
1320
|
resume: async (process_id) => {
|
|
649
1321
|
const processorService = await this.createNewProcessor();
|
|
650
1322
|
return await processorService.resumeProcess(process_id);
|
|
651
1323
|
},
|
|
652
1324
|
},
|
|
653
1325
|
quota: {
|
|
1326
|
+
/**
|
|
1327
|
+
* Runs a quota processor.
|
|
1328
|
+
* @param {IProcessorInput} data - The quota processor input.
|
|
1329
|
+
* @returns {Promise<any>} The result of the quota processing.
|
|
1330
|
+
*/
|
|
654
1331
|
run: async (data) => {
|
|
655
1332
|
const processorService = await this.createNewProcessor();
|
|
656
1333
|
return processorService.processQuota(data);
|
|
657
1334
|
},
|
|
658
1335
|
},
|
|
659
1336
|
fallback: {
|
|
1337
|
+
/**
|
|
1338
|
+
* Runs a fallback processor.
|
|
1339
|
+
* @param {IProcessorInput} data - The fallback processor input.
|
|
1340
|
+
* @returns {Promise<any>} The result of the fallback processing.
|
|
1341
|
+
*/
|
|
660
1342
|
run: async (data) => {
|
|
661
1343
|
const processorService = await this.createNewProcessor();
|
|
662
1344
|
return processorService.processFallback(data);
|
|
663
1345
|
},
|
|
664
1346
|
},
|
|
665
1347
|
notification: {
|
|
1348
|
+
/**
|
|
1349
|
+
* Sends a notification using the notification processor.
|
|
1350
|
+
* @param {INotificationProcessorInput} data - The notification processor input.
|
|
1351
|
+
* @returns {Promise<any>} The result of the notification processing.
|
|
1352
|
+
*/
|
|
666
1353
|
send: async (data) => {
|
|
667
1354
|
const processorService = await this.createNewProcessor();
|
|
668
1355
|
return processorService.processNotification(data);
|
|
669
1356
|
},
|
|
670
1357
|
},
|
|
671
1358
|
storage: {
|
|
1359
|
+
/**
|
|
1360
|
+
* Reads a file from storage.
|
|
1361
|
+
* @param {string} path - The file path.
|
|
1362
|
+
* @returns {Promise<IFileReadResult>} The file read result.
|
|
1363
|
+
*/
|
|
672
1364
|
readFile: async (path) => {
|
|
673
1365
|
try {
|
|
674
1366
|
const buffer = await fs_1.promises.readFile(path);
|
|
@@ -680,29 +1372,48 @@ class Ductape {
|
|
|
680
1372
|
throw error;
|
|
681
1373
|
}
|
|
682
1374
|
},
|
|
1375
|
+
/**
|
|
1376
|
+
* Saves data to storage using the storage processor.
|
|
1377
|
+
* @param {IStorageProcessorInput} data - The storage processor input.
|
|
1378
|
+
* @returns {Promise<any>} The result of the storage processing.
|
|
1379
|
+
*/
|
|
683
1380
|
save: async (data) => {
|
|
684
1381
|
const processorService = await this.createNewProcessor();
|
|
685
1382
|
return processorService.processStorage(data);
|
|
686
1383
|
},
|
|
687
1384
|
},
|
|
688
|
-
/*cloudFunction: {
|
|
689
|
-
invoke: async (data: IFunctionProcessorInput) => {
|
|
690
|
-
const processorService = this.createNewProcessor();
|
|
691
|
-
return processorService.processFunction(data);
|
|
692
|
-
},
|
|
693
|
-
},*/
|
|
694
1385
|
messageBroker: {
|
|
1386
|
+
/**
|
|
1387
|
+
* Publishes a message using the message broker processor.
|
|
1388
|
+
* @param {IMessageBrokerPublishInput} data - The publish input.
|
|
1389
|
+
* @returns {Promise<any>} The result of the publish operation.
|
|
1390
|
+
*/
|
|
695
1391
|
publish: async (data) => {
|
|
696
1392
|
const processorService = await this.createNewProcessor();
|
|
697
1393
|
return processorService.processMessageBrokerPublish(data);
|
|
698
1394
|
},
|
|
1395
|
+
/**
|
|
1396
|
+
* Subscribes to a message broker topic.
|
|
1397
|
+
* @param {IMessageBrokerSubscribeInput} data - The subscribe input.
|
|
1398
|
+
* @returns {Promise<any>} The result of the subscribe operation.
|
|
1399
|
+
*/
|
|
699
1400
|
subcribe: async (data) => {
|
|
700
1401
|
const processorService = await this.createNewProcessor();
|
|
701
1402
|
return processorService.processMessageBrokerSubscribe(data);
|
|
702
1403
|
},
|
|
703
1404
|
},
|
|
704
1405
|
};
|
|
1406
|
+
/**
|
|
1407
|
+
* Logs-related operations for initializing and fetching logs.
|
|
1408
|
+
*/
|
|
705
1409
|
this.logs = {
|
|
1410
|
+
/**
|
|
1411
|
+
* Initializes the logger service for a product or app.
|
|
1412
|
+
* @param {string} [productTag] - The product tag (optional).
|
|
1413
|
+
* @param {string} [appTag] - The app tag (optional).
|
|
1414
|
+
* @throws {Error} If neither productTag nor appTag is provided.
|
|
1415
|
+
* @returns {Promise<void>} Resolves when logger is initialized.
|
|
1416
|
+
*/
|
|
706
1417
|
init: async (productTag, appTag) => {
|
|
707
1418
|
if (!productTag && !appTag) {
|
|
708
1419
|
throw new Error('At least one of productTag or appTag must be provided');
|
|
@@ -721,48 +1432,9 @@ class Ductape {
|
|
|
721
1432
|
},
|
|
722
1433
|
add: async () => { },
|
|
723
1434
|
/**
|
|
724
|
-
* Fetches logs based on
|
|
725
|
-
*
|
|
726
|
-
* @
|
|
727
|
-
* @param params.type - Optional. Type of analysis ('apps', 'process', 'feature', 'integrations', etc.)
|
|
728
|
-
* @param params.groupBy - Optional. Time period for grouping ('day', 'week', 'month', 'year')
|
|
729
|
-
* @param params.search - Optional. Search term for filtering logs
|
|
730
|
-
* @param params.page - Optional. Page number for pagination (≥ 1)
|
|
731
|
-
* @param params.limit - Optional. Number of items per page (≥ 1)
|
|
732
|
-
* @param params.status - Optional. Filter by status ('success', 'processing', 'fail')
|
|
733
|
-
*
|
|
734
|
-
* For component='app':
|
|
735
|
-
* @param params.tag - Optional. Tag identifier (only valid when type='actions')
|
|
736
|
-
* @param params.env - Optional. Environment filter
|
|
737
|
-
* @param params.name - Optional. Name filter
|
|
738
|
-
* @param params.action - Optional. Specific action filter
|
|
739
|
-
*
|
|
740
|
-
* For component='product':
|
|
741
|
-
* @param params.env - Optional. Environment filter
|
|
742
|
-
* @param params.name - Optional. Name filter
|
|
743
|
-
* @param params.action - Optional. Specific action filter
|
|
744
|
-
*
|
|
745
|
-
* @throws {Error} If logger service is not initialized
|
|
746
|
-
* @throws {Error} If required parameters are missing or invalid
|
|
747
|
-
* @throws {Error} If API request fails
|
|
748
|
-
*
|
|
749
|
-
* @returns {Promise<any>} The fetched log data
|
|
750
|
-
*
|
|
751
|
-
* @example
|
|
752
|
-
* // Fetch app logs
|
|
753
|
-
* const appLogs = await logs.fetch({
|
|
754
|
-
* component: 'app',
|
|
755
|
-
* type: 'actions',
|
|
756
|
-
* groupBy: 'day',
|
|
757
|
-
* limit: 20
|
|
758
|
-
* });
|
|
759
|
-
*
|
|
760
|
-
* // Fetch product logs
|
|
761
|
-
* const productLogs = await logs.fetch({
|
|
762
|
-
* component: 'product',
|
|
763
|
-
* type: 'database',
|
|
764
|
-
* status: 'success'
|
|
765
|
-
* });
|
|
1435
|
+
* Fetches logs based on provided query parameters.
|
|
1436
|
+
* @param {LogQueryParams} params - The log query parameters.
|
|
1437
|
+
* @returns {Promise<any>} The fetched log data.
|
|
766
1438
|
*/
|
|
767
1439
|
fetch: async (params) => {
|
|
768
1440
|
if (!this.loggerService) {
|
|
@@ -789,7 +1461,23 @@ class Ductape {
|
|
|
789
1461
|
this.redis_url = redis_url;
|
|
790
1462
|
return (0, utils_1.createDeepProxy)(this, this.environment);
|
|
791
1463
|
}
|
|
792
|
-
async
|
|
1464
|
+
async loadBullMQ() {
|
|
1465
|
+
if (typeof window !== 'undefined') {
|
|
1466
|
+
throw new Error("Bullmq can only be used in a server environment.");
|
|
1467
|
+
}
|
|
1468
|
+
const bull = await Promise.resolve().then(() => __importStar(require('bullmq')));
|
|
1469
|
+
return {
|
|
1470
|
+
Queue: bull.Queue,
|
|
1471
|
+
Worker: bull.Worker,
|
|
1472
|
+
Job: bull.Job,
|
|
1473
|
+
};
|
|
1474
|
+
}
|
|
1475
|
+
/**
|
|
1476
|
+
* Connects to Redis and initializes job and health check queues and workers.
|
|
1477
|
+
* @throws {Error} If called in a browser environment or if Redis URL is missing.
|
|
1478
|
+
* @returns {Promise<void>} Resolves when Redis and queues are initialized.
|
|
1479
|
+
*/
|
|
1480
|
+
async monitor() {
|
|
793
1481
|
if (typeof window !== 'undefined') {
|
|
794
1482
|
throw new Error("RedisService can only be used in a server environment.");
|
|
795
1483
|
}
|
|
@@ -797,16 +1485,162 @@ class Ductape {
|
|
|
797
1485
|
throw new Error("Redis URL is not provided.");
|
|
798
1486
|
}
|
|
799
1487
|
if (this.redisClient) {
|
|
800
|
-
// Already connected
|
|
1488
|
+
// Already connected
|
|
1489
|
+
return;
|
|
1490
|
+
}
|
|
1491
|
+
// TODO: remove this requirement
|
|
1492
|
+
if (!this.redisClient) {
|
|
801
1493
|
return;
|
|
802
1494
|
}
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
1495
|
+
if (!this.public_key) {
|
|
1496
|
+
await this.initUserAuth(false);
|
|
1497
|
+
}
|
|
1498
|
+
const Redis = await this.loadRedis();
|
|
1499
|
+
const { Queue, Worker: BullWorker } = await this.loadBullMQ();
|
|
1500
|
+
// Create Redis client with required options for BullMQ
|
|
1501
|
+
this.redisClient = new Redis.default(this.redis_url, {
|
|
1502
|
+
maxRetriesPerRequest: null, // Required by BullMQ
|
|
1503
|
+
});
|
|
1504
|
+
// Initialize job queues
|
|
1505
|
+
this.jobsQueue = new Queue('ductape_jobs', {
|
|
1506
|
+
connection: this.redisClient,
|
|
1507
|
+
});
|
|
1508
|
+
this.healthCheckQueue = new Queue('ductape_healthchecks', {
|
|
1509
|
+
connection: this.redisClient,
|
|
1510
|
+
});
|
|
1511
|
+
this.healthCheckUpdaterQueue = new Queue('healthchecks-updater', {
|
|
1512
|
+
connection: this.redisClient
|
|
1513
|
+
});
|
|
1514
|
+
// Schedule healthcheck jobs for all products/environments
|
|
1515
|
+
await this.scheduleAllHealthcheckJobs();
|
|
1516
|
+
// Initialize job worker
|
|
1517
|
+
this.jobsWorker = new BullWorker('ductape_jobs', async (job) => {
|
|
1518
|
+
console.log(`Processing job ${job.id} of type ${job.name}`, job.data);
|
|
1519
|
+
const processor = await this.createNewProcessor();
|
|
1520
|
+
await processor.runJobs(job);
|
|
1521
|
+
}, {
|
|
1522
|
+
connection: this.redisClient,
|
|
1523
|
+
});
|
|
1524
|
+
// Initialize health check worker
|
|
1525
|
+
this.healthCheckWorker = new BullWorker('ductape_healthchecks', async (job) => {
|
|
1526
|
+
console.log(`Running health check job ${job.id}`, job.data);
|
|
1527
|
+
const processor = await this.createNewProcessor();
|
|
1528
|
+
console.log("FIND JOB!!!!", job.data);
|
|
1529
|
+
if (job && job.data && Object.keys(job.data).length) {
|
|
1530
|
+
// Call processAction with job.data
|
|
1531
|
+
const result = await processor.processAction(job.data);
|
|
1532
|
+
// Write result to Redis cache
|
|
1533
|
+
await processor.writeHealthcheckResultToCache(job.data, Object.assign({ status: (result === null || result === void 0 ? void 0 : result.status) || 'unknown', lastChecked: Date.now() }, result));
|
|
1534
|
+
// Re-enqueue the job for continuous healthchecks
|
|
1535
|
+
//await this.scheduleHealthcheckJob(job.data);
|
|
1536
|
+
}
|
|
1537
|
+
}, {
|
|
1538
|
+
connection: this.redisClient,
|
|
1539
|
+
});
|
|
1540
|
+
// Add a repeatable job to update DB every 10 minutes
|
|
1541
|
+
await this.healthCheckUpdaterQueue.add('healthchecks-updater', {}, {
|
|
1542
|
+
jobId: 'healthchecks-updater',
|
|
1543
|
+
repeat: { every: 5 * 60 * 1000 }
|
|
1544
|
+
});
|
|
1545
|
+
// Healthcheck updater worker
|
|
1546
|
+
this.healthCheckUpdaterWorker = new BullWorker('healthchecks-updater', async (job) => {
|
|
1547
|
+
console.log('Init Processor for healthcheck Updater');
|
|
1548
|
+
if (job.name !== 'healthchecks-updater')
|
|
1549
|
+
return;
|
|
1550
|
+
// Gather all healthcheck results from Redis
|
|
1551
|
+
const keys = await this.redisClient.keys('healthcheck:*');
|
|
1552
|
+
console.log("Found Keys for healthcheck updater", JSON.stringify(keys));
|
|
1553
|
+
const envResults = {};
|
|
1554
|
+
for (const key of keys) {
|
|
1555
|
+
const [_, productTag, tag, envSlug] = key.split(':');
|
|
1556
|
+
console.log(`${productTag} , ${tag}, ${envSlug}`);
|
|
1557
|
+
const data = JSON.parse(await this.redisClient.get(key));
|
|
1558
|
+
if (!envResults[productTag])
|
|
1559
|
+
envResults[productTag] = {};
|
|
1560
|
+
if (!envResults[productTag][tag])
|
|
1561
|
+
envResults[productTag][tag] = {};
|
|
1562
|
+
envResults[productTag][tag][envSlug] = data;
|
|
1563
|
+
}
|
|
1564
|
+
for (const productTag in envResults) {
|
|
1565
|
+
const tagsData = Object.entries(envResults[productTag]).map(([tag, envs]) => ({
|
|
1566
|
+
tag,
|
|
1567
|
+
environments: Object.entries(envs).map(([slug, data]) => (Object.assign({ slug }, data))),
|
|
1568
|
+
}));
|
|
1569
|
+
console.log();
|
|
1570
|
+
const processor = await this.createNewProcessor();
|
|
1571
|
+
console.log('PROCESSING ENV RESULT', productTag, tagsData);
|
|
1572
|
+
await processor.updateHealthcheckOnProcessor(productTag, tagsData);
|
|
1573
|
+
}
|
|
1574
|
+
}, {
|
|
1575
|
+
connection: this.redisClient,
|
|
1576
|
+
});
|
|
1577
|
+
// Attach error listeners
|
|
1578
|
+
this.jobsWorker.on('failed', (job, err) => {
|
|
1579
|
+
console.error(`Job ${job === null || job === void 0 ? void 0 : job.id} failed:`, err);
|
|
1580
|
+
});
|
|
1581
|
+
this.healthCheckWorker.on('failed', (job, err) => {
|
|
1582
|
+
console.error(`Health check ${job === null || job === void 0 ? void 0 : job.id} failed:`, err);
|
|
1583
|
+
});
|
|
806
1584
|
}
|
|
1585
|
+
/**
|
|
1586
|
+
* Schedules all healthcheck jobs for all products and environments.
|
|
1587
|
+
*/
|
|
1588
|
+
async scheduleAllHealthcheckJobs() {
|
|
1589
|
+
// Fetch all products (or use this.products if already loaded)
|
|
1590
|
+
const products = this.products || await this.productsApi.fetchWorkspaceProducts(enums_1.PublicStates.ALL, {
|
|
1591
|
+
token: this.token,
|
|
1592
|
+
public_key: this.public_key,
|
|
1593
|
+
user_id: this.user_id,
|
|
1594
|
+
workspace_id: this.workspace_id,
|
|
1595
|
+
});
|
|
1596
|
+
for (const product of products) {
|
|
1597
|
+
const healthchecks = product.healthchecks || [];
|
|
1598
|
+
const privateKey = product.private_key;
|
|
1599
|
+
for (const healthcheck of healthchecks) {
|
|
1600
|
+
for (const env of healthcheck.envs) {
|
|
1601
|
+
let decryptedInput = env.input;
|
|
1602
|
+
if (typeof decryptedInput === 'string') {
|
|
1603
|
+
decryptedInput = JSON.parse((0, processor_utils_1.decrypt)(decryptedInput, privateKey));
|
|
1604
|
+
}
|
|
1605
|
+
const jobData = {
|
|
1606
|
+
healthcheck: healthcheck.tag,
|
|
1607
|
+
env: env.slug,
|
|
1608
|
+
product: product.tag,
|
|
1609
|
+
app: healthcheck.app,
|
|
1610
|
+
input: decryptedInput,
|
|
1611
|
+
event: healthcheck.event,
|
|
1612
|
+
retries: healthcheck.retries || 0,
|
|
1613
|
+
};
|
|
1614
|
+
const jobId = `healthcheck-exec-${healthcheck.tag}-${env.slug}`;
|
|
1615
|
+
await this.scheduleHealthcheckJob(jobId, jobData, healthcheck.interval);
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
/**
|
|
1621
|
+
* Schedules a single healthcheck job with the given interval (ms).
|
|
1622
|
+
* If interval is not provided, defaults to 60s.
|
|
1623
|
+
*/
|
|
1624
|
+
async scheduleHealthcheckJob(jobId, jobData, interval) {
|
|
1625
|
+
console.log("JOBBERMAN", { jobId, jobData, interval });
|
|
1626
|
+
const job = await this.healthCheckQueue.getJob(jobId);
|
|
1627
|
+
if (job) {
|
|
1628
|
+
await job.remove();
|
|
1629
|
+
}
|
|
1630
|
+
const repeat = interval ? { every: interval } : { every: 60000 };
|
|
1631
|
+
await this.healthCheckQueue.add('healthchecks-updater', jobData, { repeat, jobId });
|
|
1632
|
+
}
|
|
1633
|
+
/**
|
|
1634
|
+
* Sets the authentication token for API requests.
|
|
1635
|
+
* @param {string} token - The authentication token.
|
|
1636
|
+
*/
|
|
807
1637
|
setToken(token) {
|
|
808
1638
|
this.token = token;
|
|
809
1639
|
}
|
|
1640
|
+
/**
|
|
1641
|
+
* Sets the public key for API requests.
|
|
1642
|
+
* @param {string} public_key - The public key.
|
|
1643
|
+
*/
|
|
810
1644
|
setPublicKey(public_key) {
|
|
811
1645
|
this.public_key = public_key;
|
|
812
1646
|
}
|
|
@@ -878,6 +1712,8 @@ class Ductape {
|
|
|
878
1712
|
user_id: this.user_id,
|
|
879
1713
|
token: this.token,
|
|
880
1714
|
env_type: this.environment,
|
|
1715
|
+
redis_client: this.redisClient,
|
|
1716
|
+
queues: { health: this.healthCheckQueue, jobs: this.jobsQueue }
|
|
881
1717
|
});
|
|
882
1718
|
}
|
|
883
1719
|
createNewImporter() {
|
|
@@ -996,6 +1832,13 @@ class Ductape {
|
|
|
996
1832
|
throw error;
|
|
997
1833
|
}
|
|
998
1834
|
}
|
|
1835
|
+
/**
|
|
1836
|
+
* Fetches the latest healthcheck status for a product/env from Redis cache via processor service.
|
|
1837
|
+
*/
|
|
1838
|
+
async getHealthcheckStatus(productTag, envSlug) {
|
|
1839
|
+
const processor = await this.createNewProcessor();
|
|
1840
|
+
return processor.getHealthcheckStatusFromCache(productTag, envSlug);
|
|
1841
|
+
}
|
|
999
1842
|
}
|
|
1000
1843
|
exports.default = Ductape;
|
|
1001
1844
|
//# sourceMappingURL=index.js.map
|