@ductape/sdk 0.0.3-beta1 → 0.0.3-beta11

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 (81) hide show
  1. package/dist/api/services/appApi.service.js +2 -2
  2. package/dist/api/services/appApi.service.js.map +1 -1
  3. package/dist/api/services/processorApi.service.d.ts +3 -1
  4. package/dist/api/services/processorApi.service.js +9 -0
  5. package/dist/api/services/processorApi.service.js.map +1 -1
  6. package/dist/api/services/productsApi.service.js +1 -1
  7. package/dist/api/services/productsApi.service.js.map +1 -1
  8. package/dist/api/urls.d.ts +1 -0
  9. package/dist/api/urls.js +2 -1
  10. package/dist/api/urls.js.map +1 -1
  11. package/dist/apps/services/app.service.d.ts +3 -3
  12. package/dist/apps/services/app.service.js +84 -50
  13. package/dist/apps/services/app.service.js.map +1 -1
  14. package/dist/apps/validators/joi-validators/update.appAction.validator.d.ts +2 -2
  15. package/dist/apps/validators/joi-validators/update.appAction.validator.js +11 -11
  16. package/dist/apps/validators/joi-validators/update.appAction.validator.js.map +1 -1
  17. package/dist/imports/repos/postmanV21.repo.js +1 -1
  18. package/dist/imports/repos/postmanV21.repo.js.map +1 -1
  19. package/dist/index.d.ts +14 -2
  20. package/dist/index.js +47 -4
  21. package/dist/index.js.map +1 -1
  22. package/dist/inputs/validators/inputs.validator.parse.js +1 -0
  23. package/dist/inputs/validators/inputs.validator.parse.js.map +1 -1
  24. package/dist/logs/logs.service.js +1 -1
  25. package/dist/logs/logs.service.js.map +1 -1
  26. package/dist/logs/logs.types.d.ts +1 -0
  27. package/dist/logs/logs.types.js.map +1 -1
  28. package/dist/processor/services/fallback.service.d.ts +2 -2
  29. package/dist/processor/services/fallback.service.js +11 -10
  30. package/dist/processor/services/fallback.service.js.map +1 -1
  31. package/dist/processor/services/processor.service.d.ts +4 -1
  32. package/dist/processor/services/processor.service.js +98 -19
  33. package/dist/processor/services/processor.service.js.map +1 -1
  34. package/dist/processor/services/quota.service.d.ts +4 -13
  35. package/dist/processor/services/quota.service.js +11 -2
  36. package/dist/processor/services/quota.service.js.map +1 -1
  37. package/dist/processor/utils/storage.util.js +1 -0
  38. package/dist/processor/utils/storage.util.js.map +1 -1
  39. package/dist/products/services/products.service.d.ts +40 -32
  40. package/dist/products/services/products.service.js +236 -141
  41. package/dist/products/services/products.service.js.map +1 -1
  42. package/dist/products/utils/string.utils.js +1 -0
  43. package/dist/products/utils/string.utils.js.map +1 -1
  44. package/dist/products/validators/index.d.ts +3 -1
  45. package/dist/products/validators/index.js +5 -1
  46. package/dist/products/validators/index.js.map +1 -1
  47. package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js +25 -18
  48. package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js.map +1 -1
  49. package/dist/products/validators/joi-validators/create.productFeature.validator.js +2 -0
  50. package/dist/products/validators/joi-validators/create.productFeature.validator.js.map +1 -1
  51. package/dist/products/validators/joi-validators/create.productNotificationMessage.validator.js +1 -1
  52. package/dist/products/validators/joi-validators/create.productQuota.validator.js +2 -0
  53. package/dist/products/validators/joi-validators/create.productQuota.validator.js.map +1 -1
  54. package/dist/products/validators/joi-validators/create.userAuth.validator.d.ts +3 -0
  55. package/dist/products/validators/joi-validators/create.userAuth.validator.js +47 -0
  56. package/dist/products/validators/joi-validators/create.userAuth.validator.js.map +1 -0
  57. package/dist/products/validators/joi-validators/update.dataValue.validator.d.ts +1 -1
  58. package/dist/products/validators/joi-validators/update.dataValue.validator.js +3 -2
  59. package/dist/products/validators/joi-validators/update.dataValue.validator.js.map +1 -1
  60. package/dist/products/validators/joi-validators/update.productFeature.validator.js +2 -0
  61. package/dist/products/validators/joi-validators/update.productFeature.validator.js.map +1 -1
  62. package/dist/products/validators/joi-validators/update.productNotificationMessage.validator.js +2 -1
  63. package/dist/products/validators/joi-validators/update.productNotificationMessage.validator.js.map +1 -1
  64. package/dist/products/validators/joi-validators/update.productQuota.validator.js +8 -7
  65. package/dist/products/validators/joi-validators/update.productQuota.validator.js.map +1 -1
  66. package/dist/products/validators/joi-validators/update.userAuth.validator.d.ts +3 -0
  67. package/dist/products/validators/joi-validators/update.userAuth.validator.js +47 -0
  68. package/dist/products/validators/joi-validators/update.userAuth.validator.js.map +1 -0
  69. package/dist/test/test.logs.js +6 -6
  70. package/dist/test/test.logs.js.map +1 -1
  71. package/dist/types/appBuilder.types.d.ts +16 -0
  72. package/dist/types/enums.d.ts +5 -0
  73. package/dist/types/enums.js +7 -1
  74. package/dist/types/enums.js.map +1 -1
  75. package/dist/types/inputs.types.d.ts +2 -0
  76. package/dist/types/inputs.types.js.map +1 -1
  77. package/dist/types/processor.types.d.ts +15 -0
  78. package/dist/types/processor.types.js.map +1 -1
  79. package/dist/types/productsBuilder.types.d.ts +14 -1
  80. package/dist/types/productsBuilder.types.js.map +1 -1
  81. package/package.json +2 -1
@@ -190,6 +190,59 @@ class ProductsBuilderService {
190
190
  }
191
191
  return this.product;
192
192
  }
193
+ async createSession(data) {
194
+ try {
195
+ // TODO: figure out a way to check if this has run before, halt if it has
196
+ if (!this.fetchSession(data.tag)) {
197
+ await validators_1.CreateProductSessionSchema.validateAsync(data);
198
+ data.schema_data = (await this.inputsService.parseJson({
199
+ data: data.schema,
200
+ expected: inputs_types_1.ExpectedValues.PARSESAMPLE,
201
+ category: enums_1.Categories.DATA,
202
+ }));
203
+ await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { component: enums_1.ProductComponents.SESSION, action: enums_1.RequestAction.CREATE }), this.getUserAccess());
204
+ await this.initializeProduct(this.product_id);
205
+ }
206
+ }
207
+ catch (e) {
208
+ throw e;
209
+ }
210
+ }
211
+ async updateSession(tag, data) {
212
+ try {
213
+ const auth = this.fetchSession(tag);
214
+ if (!auth) {
215
+ throw new Error(`Session ${tag} not found`);
216
+ }
217
+ //const { _id } = auth;
218
+ await validators_1.UpdateProductSessionSchema.validateAsync(data); // Change to update;
219
+ if (data.tag && this.fetchEnv(data.tag) && data.tag !== tag) {
220
+ throw new Error(`tag ${data.tag} is in use`); // TODO: also check on the backend
221
+ }
222
+ if (!data.tag) {
223
+ data.tag = tag;
224
+ }
225
+ if (data.schema) {
226
+ data.schema_data = (await this.inputsService.parseJson({
227
+ data: data.schema,
228
+ expected: inputs_types_1.ExpectedValues.PARSESAMPLE,
229
+ category: enums_1.Categories.DATA,
230
+ }));
231
+ }
232
+ await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, Object.assign(Object.assign({}, auth), data)), { component: enums_1.ProductComponents.SESSION, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
233
+ await this.initializeProduct(this.product_id);
234
+ }
235
+ catch (e) {
236
+ throw e;
237
+ }
238
+ }
239
+ fetchSession(tag) {
240
+ var _a;
241
+ return (_a = this.product.sessions) === null || _a === void 0 ? void 0 : _a.find((auth) => auth.tag === tag);
242
+ }
243
+ fetchSessions() {
244
+ return this.product.sessions;
245
+ }
193
246
  async createMessageBrokerTopic(data, throwErrorIfExists = false) {
194
247
  try {
195
248
  if (!data.tag) {
@@ -315,37 +368,26 @@ class ProductsBuilderService {
315
368
  }
316
369
  this.isQuotaFallbackInput = false;
317
370
  }
318
- async validateQuotaFallbackOutput(
319
- /*app: string,
320
- event: string,
321
- response: Record<string, unknown>,
322
- input: Record<string, IFeatureInput>,*/
323
- option, pastResponse, input) {
324
- /*const { version, ...appData } = await this.fetchThirdPartyAppByAccessTag(option.app);
325
-
371
+ async validateQuotaFallbackOutput(option, pastResponse, input) {
372
+ const _a = await this.fetchThirdPartyAppByAccessTag(option.app), { version } = _a, appData = __rest(_a, ["version"]);
326
373
  if (!appData) {
327
- throw new Error(`App ${option.app} not found`);
374
+ throw new Error(`App ${option.app} not found`);
328
375
  }
329
-
330
376
  const { actions } = appData.versions.find((data) => data.tag === version);
331
-
332
377
  const action = actions.find((data) => data.tag === option.event);
333
-
334
378
  if (!appData) {
335
- throw new Error(`Action ${event} not found in ${option.app} version ${version}`);
379
+ throw new Error(`Action ${event} not found in ${option.app} version ${version}`);
336
380
  }
337
- if (pastResponse) {
338
- validateObjectKeys(response, pastResponse);
339
- }
340
-
341
- const res = action.responses.find((item) => item.success === true);
381
+ const response = action.responses.find((item) => item.success === true);
342
382
  // fetch success result
343
-
344
- if (!res) {
345
- throw new Error(`event ${event} does not have a success response`);
383
+ if (!response) {
384
+ throw new Error(`event ${event} does not have a success response`);
346
385
  }
347
-
348
- await this.validateActionResponse(response, res)*/
386
+ if (pastResponse) {
387
+ (0, objects_utils_2.validateObjectKeys)(option.output, pastResponse);
388
+ }
389
+ // validate that each response matches the expected format
390
+ /**await this.validateActionResponse(response, res)*/
349
391
  }
350
392
  async createQuota(data) {
351
393
  try {
@@ -359,22 +401,27 @@ class ProductsBuilderService {
359
401
  data.total_init = 0;
360
402
  await Promise.all(data.options.map(async (d) => {
361
403
  data.total_quota += d.quota;
362
- const app = await this.fetchThirdPartyAppByAccessTag(d.app);
363
- if (!app) {
364
- throw new Error(`App with access tag ${d.app} not found`);
365
- }
366
- const version = app.versions.find((version) => version.tag === app.version);
367
- const action = version.actions.find((action) => action.tag === d.event);
368
- if (!action) {
369
- throw new Error(`Cannot find action ${d.event} on app ${app.tag} version ${app.version}`);
370
- }
371
- if (d.healthcheck) {
372
- const action = version.actions.find((action) => action.tag === d.healthcheck);
373
- if (!d.check_interval) {
374
- d.check_interval = 10000;
404
+ if (d.type === productsBuilder_types_1.FeatureEventTypes.ACTION) {
405
+ const app = await this.fetchThirdPartyAppByAccessTag(d.app);
406
+ if (!app) {
407
+ throw new Error(`App with access tag ${d.app} not found`);
375
408
  }
409
+ const version = app.versions.find((version) => version.tag === app.version);
410
+ const action = version.actions.find((action) => action.tag === d.event);
376
411
  if (!action) {
377
- throw new Error(`Cannot find healthcheck action ${d.healthcheck} on app ${app.tag} version ${app.version}`);
412
+ throw new Error(`Cannot find action ${d.event} on app ${app.tag} version ${app.version}`);
413
+ }
414
+ if (d.healthcheck) {
415
+ const action = version.actions.find((action) => action.tag === d.healthcheck);
416
+ if (!d.check_interval) {
417
+ d.check_interval = 10000;
418
+ }
419
+ if (!action) {
420
+ throw new Error(`Cannot find healthcheck action ${d.healthcheck} on app ${app.tag} version ${app.version}`);
421
+ }
422
+ }
423
+ if (action.headers.data.length > 0 || action.body.data.length > 0 || action.params.data.length > 0 || action.query.data.length > 0) {
424
+ throw new Error('Healthcheck action is expected to have no headers, body, params or query');
378
425
  }
379
426
  }
380
427
  d.last_checked = new Date();
@@ -391,7 +438,54 @@ class ProductsBuilderService {
391
438
  throw e;
392
439
  }
393
440
  }
394
- async updateQuota(tag, data) { }
441
+ async updateQuota(tag, data) {
442
+ try {
443
+ if (this.fetchQuota(tag)) {
444
+ await validators_1.UpdateProductQuotaSchema.validateAsync(data);
445
+ if (data.options) {
446
+ await this.validateQuotaFallbackInputAndOutput(data);
447
+ data.total_quota = 0;
448
+ data.total_init = 0;
449
+ await Promise.all(data.options.map(async (d) => {
450
+ data.total_quota += d.quota;
451
+ if (d.type === productsBuilder_types_1.FeatureEventTypes.ACTION) {
452
+ const app = await this.fetchThirdPartyAppByAccessTag(d.app);
453
+ if (!app) {
454
+ throw new Error(`App with access tag ${d.app} not found`);
455
+ }
456
+ const version = app.versions.find((version) => version.tag === app.version);
457
+ const action = version.actions.find((action) => action.tag === d.event);
458
+ if (!action) {
459
+ throw new Error(`Cannot find action ${d.event} on app ${app.tag} version ${app.version}`);
460
+ }
461
+ if (d.healthcheck) {
462
+ const action = version.actions.find((action) => action.tag === d.healthcheck);
463
+ if (!d.check_interval) {
464
+ d.check_interval = 10000;
465
+ }
466
+ if (!action) {
467
+ throw new Error(`Cannot find healthcheck action ${d.healthcheck} on app ${app.tag} version ${app.version}`);
468
+ }
469
+ if (action.headers.data.length > 0 || action.body.data.length > 0 || action.params.data.length > 0 || action.query.data.length > 0) {
470
+ throw new Error('Healthcheck action is expected to have no headers, body, params or query');
471
+ }
472
+ }
473
+ }
474
+ d.last_checked = new Date();
475
+ d.provider_status = productsBuilder_types_1.ProviderStatus.AVAILABLE;
476
+ d.last_available = true;
477
+ }));
478
+ }
479
+ await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { component: enums_1.ProductComponents.QUOTA, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
480
+ }
481
+ else {
482
+ throw new Error(`Quota with tag ${data.tag} not found`);
483
+ }
484
+ }
485
+ catch (e) {
486
+ throw e;
487
+ }
488
+ }
395
489
  fetchQuota(tag) {
396
490
  return this.fetchQuotas().find((data) => data.tag === tag);
397
491
  }
@@ -407,22 +501,27 @@ class ProductsBuilderService {
407
501
  await validators_1.CreateProductFallbackSchema.validateAsync(data);
408
502
  await this.validateQuotaFallbackInputAndOutput(data);
409
503
  await Promise.all(data.options.map(async (d) => {
410
- const app = await this.fetchThirdPartyAppByAccessTag(d.app);
411
- if (!app) {
412
- throw new Error(`App with access tag ${d.app} not found`);
413
- }
414
- const version = app.versions.find((version) => version.tag === app.version);
415
- const action = version.actions.find((action) => action.tag === d.event);
416
- if (!action) {
417
- throw new Error(`Cannot find action ${d.event} on app ${app.tag} version ${app.version}`);
418
- }
419
- if (d.healthcheck) {
420
- const action = version.actions.find((action) => action.tag === d.healthcheck);
421
- if (!d.check_interval) {
422
- d.check_interval = 10000;
504
+ if (d.type === productsBuilder_types_1.FeatureEventTypes.ACTION) {
505
+ const app = await this.fetchThirdPartyAppByAccessTag(d.app);
506
+ if (!app) {
507
+ throw new Error(`App with access tag ${d.app} not found`);
423
508
  }
509
+ const version = app.versions.find((version) => version.tag === app.version);
510
+ const action = version.actions.find((action) => action.tag === d.event);
424
511
  if (!action) {
425
- throw new Error(`Cannot find healthcheck action ${d.healthcheck} on app ${app.tag} version ${app.version}`);
512
+ throw new Error(`Cannot find action ${d.event} on app ${app.tag} version ${app.version}`);
513
+ }
514
+ if (d.healthcheck) {
515
+ const action = version.actions.find((action) => action.tag === d.healthcheck);
516
+ if (!d.check_interval) {
517
+ d.check_interval = 10000;
518
+ }
519
+ if (!action) {
520
+ throw new Error(`Cannot find healthcheck action ${d.healthcheck} on app ${app.tag} version ${app.version}`);
521
+ }
522
+ if (action.headers.data.length > 0 || action.body.data.length > 0 || action.params.data.length > 0 || action.query.data.length > 0) {
523
+ throw new Error('Healthcheck action is expected to have no headers, body, params or query');
524
+ }
426
525
  }
427
526
  }
428
527
  d.last_checked = new Date();
@@ -440,74 +539,49 @@ class ProductsBuilderService {
440
539
  }
441
540
  }
442
541
  async updateFallback(tag, data) {
443
- /*try {
444
-
445
- if (!data.tag) {
446
- throw new Error('tag field is required');
447
- }
448
-
449
- if (this.fetchQuota(tag)) {
450
-
451
- if(data.tag && tag !== data.tag && this.fetchFallback(data.tag)) {
452
- throw new Error(`Fallback with new tag ${data.tag} already exists`)
542
+ try {
543
+ if (this.fetchFallback(tag)) {
544
+ await validators_1.UpdateProductFallbackSchema.validateAsync(data);
545
+ if (data.options) {
546
+ await this.validateQuotaFallbackInputAndOutput(data);
547
+ await Promise.all(data.options.map(async (d) => {
548
+ if (d.type === productsBuilder_types_1.FeatureEventTypes.ACTION) {
549
+ const app = await this.fetchThirdPartyAppByAccessTag(d.app);
550
+ if (!app) {
551
+ throw new Error(`App with access tag ${d.app} not found`);
552
+ }
553
+ const version = app.versions.find((version) => version.tag === app.version);
554
+ const action = version.actions.find((action) => action.tag === d.event);
555
+ if (!action) {
556
+ throw new Error(`Cannot find action ${d.event} on app ${app.tag} version ${app.version}`);
557
+ }
558
+ if (d.healthcheck) {
559
+ const action = version.actions.find((action) => action.tag === d.healthcheck);
560
+ if (!d.check_interval) {
561
+ d.check_interval = 10000;
562
+ }
563
+ if (!action) {
564
+ throw new Error(`Cannot find healthcheck action ${d.healthcheck} on app ${app.tag} version ${app.version}`);
565
+ }
566
+ if (action.headers.data.length > 0 || action.body.data.length > 0 || action.params.data.length > 0 || action.query.data.length > 0) {
567
+ throw new Error('Healthcheck action is expected to have no headers, body, params or query');
568
+ }
569
+ }
570
+ }
571
+ d.last_checked = new Date();
572
+ d.provider_status = productsBuilder_types_1.ProviderStatus.AVAILABLE;
573
+ d.last_available = true;
574
+ }));
575
+ }
576
+ await this.productApi.updateProduct(this.product_id, Object.assign(Object.assign({}, data), { component: enums_1.ProductComponents.FALLBACK, action: enums_1.RequestAction.UPDATE }), this.getUserAccess());
453
577
  }
454
-
455
- if(!data.tag) {
456
- data.tag = tag;
578
+ else {
579
+ throw new Error(`Quota with tag ${data.tag} not found`);
457
580
  }
458
-
459
- await UpdateProductFallbackSchema.validateAsync(data);
460
-
461
- await this.validateQuotaFallbackInputAndOutput(data);
462
-
463
- await Promise.all(data.options.map(async (d) => {
464
-
465
- const app = await this.fetchThirdPartyAppByAccessTag(d.app);
466
-
467
- if (!app) {
468
- throw new Error(`App with access tag ${d.app} not found`)
469
- }
470
-
471
- const version = app.versions.find((version) => version.tag === app.version);
472
- const action = version.actions.find((action) => action.tag === d.event)
473
-
474
- if (!action) {
475
- throw new Error(`Cannot find action ${d.event} on app ${app.tag} version ${app.version}`)
476
- }
477
-
478
- if (d.healthcheck) {
479
- const action = version.actions.find((action) => action.tag === d.healthcheck)
480
-
481
- if (!d.check_interval) {
482
- d.check_interval = 10000;
483
- }
484
-
485
- if (!action) {
486
- throw new Error(`Cannot find healthcheck action ${d.healthcheck} on app ${app.tag} version ${app.version}`)
487
- }
488
- }
489
-
490
- d.last_checked = new Date();
491
- d.provider_status = ProviderStatus.AVAILABLE;
492
- d.last_available = true;
493
- }))
494
-
495
- await this.productApi.updateProduct(
496
- this.product_id,
497
- {
498
- ...data,
499
- component: ProductComponents.FALLBACK,
500
- },
501
- this.getUserAccess(),
502
- );
503
-
504
- } else {
505
- throw new Error(`Quota with tag ${data.tag} already exists`)
506
- }
507
-
508
- } catch (e) {
509
- throw e;
510
- }*/
581
+ }
582
+ catch (e) {
583
+ throw e;
584
+ }
511
585
  }
512
586
  fetchFallback(tag) {
513
587
  return this.fetchFallbacks().find((data) => data.tag === tag);
@@ -599,7 +673,7 @@ class ProductsBuilderService {
599
673
  if (data.tag && this.fetchMessageBroker(data.tag)) {
600
674
  throw new Error(`tag ${tag} is in use`); // TODO: also check on the backend
601
675
  }
602
- console.log("2", data.envs);
676
+ console.log('2', data.envs);
603
677
  data.envs = data.envs.map((env) => {
604
678
  const exists = this.fetchEnv(env.slug);
605
679
  if (!exists) {
@@ -662,6 +736,7 @@ class ProductsBuilderService {
662
736
  return messageBroker;
663
737
  }
664
738
  fetchMessageBrokers() {
739
+ console.log("PROD!", this.product);
665
740
  return this.product.messageBrokers.map((broker) => {
666
741
  return this.fetchMessageBroker(broker.tag);
667
742
  });
@@ -1054,8 +1129,7 @@ class ProductsBuilderService {
1054
1129
  }
1055
1130
  fetchFunction(tag) {
1056
1131
  const func = this.product.functions.find((data) => data.tag === tag);
1057
- if (!func)
1058
- throw new Error(`Function ${tag} not found`);
1132
+ // if (!func) throw new Error(`Function ${tag} not found`);
1059
1133
  return func;
1060
1134
  }
1061
1135
  async createCache(data, throwErrorIfExists = false) {
@@ -1165,7 +1239,7 @@ class ProductsBuilderService {
1165
1239
  data.email_data = [...emailTemaplate, ...subjectTemplate];
1166
1240
  }
1167
1241
  if (data.push_notification) {
1168
- data.push_notification_data = (0, string_utils_1.extractPlaceholders)(JSON.stringify(data.push_notification));
1242
+ //data.push_notification_data = extractPlaceholders(JSON.stringify(data.push_notification));
1169
1243
  const titleTemplate = (0, string_utils_1.extractPlaceholders)(data.push_notification.title, 'title');
1170
1244
  const bodyTemplate = (0, string_utils_1.extractPlaceholders)(data.push_notification.body, 'body');
1171
1245
  const dataTemplate = (0, string_utils_1.extractPlaceholders)(JSON.stringify(data.push_notification.data || {}), 'data');
@@ -1206,7 +1280,7 @@ class ProductsBuilderService {
1206
1280
  if (!notificationTag || !messageTag) {
1207
1281
  throw new Error(`tag is expected to be defined as "notification_tag:message_tag"`);
1208
1282
  }
1209
- const notification = this.product.notifications.find((data) => data.tag === notificationTag);
1283
+ const notification = this.fetchNotification(notificationTag);
1210
1284
  if (!notification)
1211
1285
  throw new Error(`Notification ${notificationTag} not found`);
1212
1286
  const message = notification.messages.find((data) => data.tag === messageTag);
@@ -1222,6 +1296,7 @@ class ProductsBuilderService {
1222
1296
  }
1223
1297
  async updateNotificationMessage(data) {
1224
1298
  try {
1299
+ console.log("NOTIFICATION DATA!!", data);
1225
1300
  await update_productNotificationMessage_validator_1.default.validateAsync(data);
1226
1301
  if (!data.tag) {
1227
1302
  throw new Error('tag field is required');
@@ -1241,7 +1316,7 @@ class ProductsBuilderService {
1241
1316
  data.email_data = [...emailTemaplate, ...subjectTemplate];
1242
1317
  }
1243
1318
  if (data.push_notification) {
1244
- data.push_notification_data = (0, string_utils_1.extractPlaceholders)(JSON.stringify(data.push_notification));
1319
+ //data.push_notification_data = extractPlaceholders(JSON.stringify(data.push_notification));
1245
1320
  const titleTemplate = (0, string_utils_1.extractPlaceholders)(data.push_notification.title, 'title');
1246
1321
  const bodyTemplate = (0, string_utils_1.extractPlaceholders)(data.push_notification.body, 'body');
1247
1322
  const dataTemplate = (0, string_utils_1.extractPlaceholders)(JSON.stringify(data.push_notification.data || {}), 'data');
@@ -1466,7 +1541,7 @@ class ProductsBuilderService {
1466
1541
  await this.validateActionDataInput(data, func, event.input, event_index, sequence_index);
1467
1542
  }
1468
1543
  async checkAndValidateDBActionDataInput(data, sequence_index, event, event_index) {
1469
- console.log("EVENTY", event.event);
1544
+ console.log('EVENTY', event.event);
1470
1545
  const { filterData, data: dbData, filterTemplate, template } = this.fetchDatabaseAction(event.event);
1471
1546
  await this.validateDBActionDataInput(data, { filterData, data: dbData, template, filter: filterTemplate }, event.input, event_index, sequence_index);
1472
1547
  }
@@ -1606,7 +1681,11 @@ class ProductsBuilderService {
1606
1681
  const _a = event_input.email, { recipients } = _a, email = __rest(_a, ["recipients"]);
1607
1682
  await this.validateActionInputData({
1608
1683
  obj: email.subject,
1609
- sample: { type: enums_1.InputsTypes.JSON, sample: '', data: action.email.filter((value) => value.parent_key === 'subject') },
1684
+ sample: {
1685
+ type: enums_1.InputsTypes.JSON,
1686
+ sample: '',
1687
+ data: action.email.filter((value) => value.parent_key === 'subject'),
1688
+ },
1610
1689
  event_index,
1611
1690
  sequence_index,
1612
1691
  feature: data,
@@ -1615,7 +1694,11 @@ class ProductsBuilderService {
1615
1694
  }, true);
1616
1695
  await this.validateActionInputData({
1617
1696
  obj: email.template,
1618
- sample: { type: enums_1.InputsTypes.JSON, sample: '', data: action.email.filter((value) => value.parent_key === 'template') },
1697
+ sample: {
1698
+ type: enums_1.InputsTypes.JSON,
1699
+ sample: '',
1700
+ data: action.email.filter((value) => value.parent_key === 'template'),
1701
+ },
1619
1702
  event_index,
1620
1703
  sequence_index,
1621
1704
  feature: data,
@@ -1627,7 +1710,11 @@ class ProductsBuilderService {
1627
1710
  const _b = event_input.push_notification, { device_tokens } = _b, push_notification = __rest(_b, ["device_tokens"]);
1628
1711
  await this.validateActionInputData({
1629
1712
  obj: push_notification.body,
1630
- sample: { type: enums_1.InputsTypes.JSON, sample: '', data: action.notification.filter((value) => value.parent_key === 'body') },
1713
+ sample: {
1714
+ type: enums_1.InputsTypes.JSON,
1715
+ sample: '',
1716
+ data: action.notification.filter((value) => value.parent_key === 'body'),
1717
+ },
1631
1718
  event_index,
1632
1719
  sequence_index,
1633
1720
  feature: data,
@@ -1635,10 +1722,14 @@ class ProductsBuilderService {
1635
1722
  indexes: Object.assign(Object.assign({}, indexes), { parent_key: 'body', level: 1 }),
1636
1723
  }, true);
1637
1724
  if (push_notification.data) {
1638
- console.log("JUMANJI", push_notification.data);
1725
+ console.log('JUMANJI', push_notification.data);
1639
1726
  await this.validateActionInputData({
1640
1727
  obj: push_notification.data,
1641
- sample: { type: enums_1.InputsTypes.JSON, sample: '', data: action.notification.filter((value) => value.parent_key === 'data') },
1728
+ sample: {
1729
+ type: enums_1.InputsTypes.JSON,
1730
+ sample: '',
1731
+ data: action.notification.filter((value) => value.parent_key === 'data'),
1732
+ },
1642
1733
  event_index,
1643
1734
  sequence_index,
1644
1735
  feature: data,
@@ -1649,7 +1740,11 @@ class ProductsBuilderService {
1649
1740
  if (push_notification.title)
1650
1741
  await this.validateActionInputData({
1651
1742
  obj: push_notification.title,
1652
- sample: { type: enums_1.InputsTypes.JSON, sample: '', data: action.notification.filter((value) => value.parent_key === 'title') },
1743
+ sample: {
1744
+ type: enums_1.InputsTypes.JSON,
1745
+ sample: '',
1746
+ data: action.notification.filter((value) => value.parent_key === 'title'),
1747
+ },
1653
1748
  event_index,
1654
1749
  sequence_index,
1655
1750
  feature: data,
@@ -1914,7 +2009,7 @@ class ProductsBuilderService {
1914
2009
  //console.log(payload)
1915
2010
  return;
1916
2011
  }
1917
- if ((this.isQuotaFallbackInput) && (0, string_utils_1.startsWithAny)(value, ['$Sequence{', '$Response{'])) {
2012
+ if (this.isQuotaFallbackInput && (0, string_utils_1.startsWithAny)(value, ['$Sequence{', '$Response{'])) {
1918
2013
  throw new Error(`Value ${value} cannot be a $Sequence or $Response value when defining Quota & Fallback input`);
1919
2014
  }
1920
2015
  if (value.startsWith('$Input{')) {
@@ -2243,14 +2338,11 @@ class ProductsBuilderService {
2243
2338
  enums_1.DataTypes.NUMBER_STRING,
2244
2339
  enums_1.DataTypes.INTEGER,
2245
2340
  ];
2246
- const dateTypes = [
2247
- enums_1.DataTypes.DATE,
2248
- enums_1.DataTypes.DATE_STRING
2249
- ];
2250
- const strException = ((datapoint.type === enums_1.DataTypes.STRING || found_input.type === enums_1.DataTypes.STRING) &&
2251
- (strTypes.includes(found_input.type) || strTypes.includes(datapoint.type)));
2252
- const dateException = ((datapoint.type === enums_1.DataTypes.INTEGER || found_input.type === enums_1.DataTypes.INTEGER) &&
2253
- (dateTypes.includes(found_input.type) || dateTypes.includes(datapoint.type)));
2341
+ const dateTypes = [enums_1.DataTypes.DATE, enums_1.DataTypes.DATE_STRING];
2342
+ const strException = (datapoint.type === enums_1.DataTypes.STRING || found_input.type === enums_1.DataTypes.STRING) &&
2343
+ (strTypes.includes(found_input.type) || strTypes.includes(datapoint.type));
2344
+ const dateException = (datapoint.type === enums_1.DataTypes.INTEGER || found_input.type === enums_1.DataTypes.INTEGER) &&
2345
+ (dateTypes.includes(found_input.type) || dateTypes.includes(datapoint.type));
2254
2346
  if (datapoint.type !== found_input.type && !strException && !dateException) {
2255
2347
  //console.log("STR EXCEPTION", strException, found_input.type, datapoint.type)
2256
2348
  throw new Error(`${value} is required to be ${datapoint.type} not ${found_input.type}`);
@@ -2285,7 +2377,7 @@ class ProductsBuilderService {
2285
2377
  );
2286
2378
  });
2287
2379
  if (!datapoint) {
2288
- console.log("VALIDATE", data.key, data.value, actionData, indexes);
2380
+ console.log('VALIDATE', data.key, data.value, actionData, indexes);
2289
2381
  throw new Error(`Key ${data.key} not found for ${data.type} for sequence ${sequence.tag} event ${sequence.events[data.event_index].event}`);
2290
2382
  }
2291
2383
  return datapoint;
@@ -2454,6 +2546,9 @@ class ProductsBuilderService {
2454
2546
  }
2455
2547
  fetchDatabase(tag, throwErrorIfExists = false) {
2456
2548
  const database = this.product.databases.find((data) => data.tag === tag);
2549
+ database.envs.map((env) => {
2550
+ env.connection_url = (0, processor_utils_1.decrypt)(env.connection_url, this.fetchProduct().private_key);
2551
+ });
2457
2552
  if (!database && throwErrorIfExists)
2458
2553
  throw new Error(`Database ${tag} not found`);
2459
2554
  return database;