@ductape/sdk 0.0.4-v43 → 0.0.4-v44
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/apps/services/app.service.js +16 -69
- package/dist/apps/services/app.service.js.map +1 -1
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.d.ts +1 -2
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.js +2 -15
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.d.ts +1 -2
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.js +2 -14
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.js.map +1 -1
- package/dist/database/adapters/dynamodb.adapter.d.ts +8 -0
- package/dist/database/adapters/dynamodb.adapter.js +243 -11
- package/dist/database/adapters/dynamodb.adapter.js.map +1 -1
- package/dist/database/adapters/mongodb.adapter.d.ts +1 -0
- package/dist/database/adapters/mongodb.adapter.js +170 -5
- package/dist/database/adapters/mongodb.adapter.js.map +1 -1
- package/dist/database/adapters/mysql.adapter.d.ts +5 -0
- package/dist/database/adapters/mysql.adapter.js +215 -19
- package/dist/database/adapters/mysql.adapter.js.map +1 -1
- package/dist/database/adapters/postgresql.adapter.d.ts +5 -0
- package/dist/database/adapters/postgresql.adapter.js +199 -15
- package/dist/database/adapters/postgresql.adapter.js.map +1 -1
- package/dist/database/database.service.d.ts +5 -0
- package/dist/database/database.service.js +45 -95
- package/dist/database/database.service.js.map +1 -1
- package/dist/database/types/aggregation.types.d.ts +28 -28
- package/dist/database/types/database.types.d.ts +2 -1
- package/dist/database/types/database.types.js +1 -0
- package/dist/database/types/database.types.js.map +1 -1
- package/dist/database/types/index.types.d.ts +20 -20
- package/dist/database/types/migration.types.d.ts +12 -12
- package/dist/database/types/query.types.d.ts +59 -28
- package/dist/index.d.ts +169 -142
- package/dist/index.js +196 -169
- package/dist/index.js.map +1 -1
- package/dist/processor/services/processor.service.js +51 -35
- package/dist/processor/services/processor.service.js.map +1 -1
- package/dist/test/test.processor.js +1 -3
- package/dist/test/test.processor.js.map +1 -1
- package/dist/types/appBuilder.types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -297,15 +297,27 @@ class ProcessorService {
|
|
|
297
297
|
await this.productBuilderService.initializeProductByTag(product_tag);
|
|
298
298
|
const { version, envs: appEnvs } = await this.productBuilderService.fetchApp(access_tag);
|
|
299
299
|
const app = await this.productBuilderService.fetchThirdPartyAppByAccessTag(access_tag);
|
|
300
|
-
const
|
|
300
|
+
const appVersion = app.versions.find((data) => data.tag === version);
|
|
301
|
+
if (!appVersion) {
|
|
302
|
+
throw new Error(`Version ${version} not found for app ${access_tag}`);
|
|
303
|
+
}
|
|
304
|
+
const { webhooks, actions } = appVersion;
|
|
301
305
|
if (!webhooks) {
|
|
302
306
|
throw new Error(`Webhooks not found for app ${access_tag}`);
|
|
303
307
|
}
|
|
308
|
+
if (!actions) {
|
|
309
|
+
throw new Error(`Actions not found for app ${access_tag}`);
|
|
310
|
+
}
|
|
304
311
|
await validators_1.RegisterWebhookEnvSchema.validateAsync(envs);
|
|
305
312
|
const webhook = webhooks.find((data) => data.tag === webhook_tag);
|
|
306
313
|
if (!webhook) {
|
|
307
314
|
throw new Error(`Webhook tag ${webhook_tag} not found`);
|
|
308
315
|
}
|
|
316
|
+
// Get the action associated with this webhook
|
|
317
|
+
const action = actions.find((act) => act.tag === webhook.action);
|
|
318
|
+
if (!action) {
|
|
319
|
+
throw new Error(`Action ${webhook.action} not found for webhook ${webhook_tag}`);
|
|
320
|
+
}
|
|
309
321
|
const productEnvs = await this.productBuilderService.fetchEnvs();
|
|
310
322
|
productEnvs.map((env) => {
|
|
311
323
|
const exists = envs.findIndex((dbEnv) => dbEnv.slug === env.slug);
|
|
@@ -314,6 +326,7 @@ class ProcessorService {
|
|
|
314
326
|
}
|
|
315
327
|
});
|
|
316
328
|
const dataArray = await Promise.all(envs.map(async (env) => {
|
|
329
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
317
330
|
await this.validateActionDataMappingInput(env.auth, types_1.WebhookEventTypes.WEBHOOK_REGISTER);
|
|
318
331
|
const productEnvData = productEnvs.find((data) => data.slug === env.slug);
|
|
319
332
|
if (!productEnvData) {
|
|
@@ -324,44 +337,47 @@ class ProcessorService {
|
|
|
324
337
|
throw new Error(`Error finding env data for ${env.slug}`);
|
|
325
338
|
}
|
|
326
339
|
const { app_env_slug: appEnv, product_env_slug: productEnv } = envData;
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
340
|
+
// Get the action's environment configuration
|
|
341
|
+
const actionEnvConfig = (_a = action.envs) === null || _a === void 0 ? void 0 : _a.find((actionEnv) => actionEnv.slug === appEnv);
|
|
342
|
+
if (!actionEnvConfig) {
|
|
343
|
+
throw new Error(`Action ${action.tag} is not configured for env ${appEnv}`);
|
|
330
344
|
}
|
|
331
345
|
const uuid = (0, uuid_1.v4)();
|
|
332
346
|
const url = `${urls_1.WEBHOOK_BASE_URL}/webhooks/v1/process/${uuid}`;
|
|
333
347
|
let active = false;
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
348
|
+
// Construct the registration payload using the action's configuration
|
|
349
|
+
const samples = {
|
|
350
|
+
query: ((_c = (_b = action.query) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.filter((data) => data.parent_key === 'query')) || [],
|
|
351
|
+
params: ((_e = (_d = action.params) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.filter((data) => data.parent_key === 'params')) || [],
|
|
352
|
+
body: ((_g = (_f = action.body) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.filter((data) => data.parent_key === 'body')) || [],
|
|
353
|
+
headers: ((_j = (_h = action.headers) === null || _h === void 0 ? void 0 : _h.data) === null || _j === void 0 ? void 0 : _j.filter((data) => data.parent_key === 'headers')) || [],
|
|
354
|
+
};
|
|
355
|
+
let payload = (await this.constructJSONDataPayloads(env.auth, {}, samples, {
|
|
356
|
+
app: access_tag,
|
|
357
|
+
event: '',
|
|
358
|
+
input: env.auth,
|
|
359
|
+
type: types_1.FeatureEventTypes.ACTION,
|
|
360
|
+
retries: 0,
|
|
361
|
+
allow_fail: false,
|
|
362
|
+
}));
|
|
363
|
+
const { updatedObj, replacedUrl } = (0, processor_utils_1.updateUrlsInObject)(payload, url);
|
|
364
|
+
if (replacedUrl && replacedUrl !== env.url && replacedUrl) {
|
|
365
|
+
throw new Error(`Ductape expects the url ${replacedUrl} in request body to match inputted url ${env.url}`);
|
|
366
|
+
}
|
|
367
|
+
const exists = await this.fetchEnv(env.slug, {});
|
|
368
|
+
if (!exists) {
|
|
369
|
+
throw new Error(`Env ${env.slug} does not exist`);
|
|
370
|
+
}
|
|
371
|
+
payload = updatedObj;
|
|
372
|
+
if (!replacedUrl) {
|
|
373
|
+
payload.body.url = url;
|
|
374
|
+
}
|
|
375
|
+
// Use the action's resource and base_url to construct the registration URL
|
|
376
|
+
const baseUrl = actionEnvConfig.base_url || action.base_url || '';
|
|
377
|
+
const resource = action.resource || '';
|
|
378
|
+
const registrationUrl = new URL(resource, baseUrl);
|
|
379
|
+
await this.sendActionRequest(registrationUrl.origin, registrationUrl.pathname, payload, action.method, env.slug);
|
|
380
|
+
active = true;
|
|
365
381
|
return {
|
|
366
382
|
appEnv,
|
|
367
383
|
productEnv,
|