@ductape/sdk 0.0.3-beta12 → 0.0.3-beta14

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 (65) hide show
  1. package/dist/api/services/appApi.service.d.ts +3 -1
  2. package/dist/api/services/appApi.service.js +41 -1
  3. package/dist/api/services/appApi.service.js.map +1 -1
  4. package/dist/api/services/productsApi.service.d.ts +2 -1
  5. package/dist/api/services/productsApi.service.js +1 -1
  6. package/dist/api/services/productsApi.service.js.map +1 -1
  7. package/dist/api/services/userApi.service.d.ts +2 -1
  8. package/dist/api/services/userApi.service.js +1 -1
  9. package/dist/api/services/userApi.service.js.map +1 -1
  10. package/dist/api/services/webhooksApi.service.d.ts +4 -1
  11. package/dist/api/services/webhooksApi.service.js +6 -3
  12. package/dist/api/services/webhooksApi.service.js.map +1 -1
  13. package/dist/api/services/workspaceApi.service.d.ts +2 -1
  14. package/dist/api/services/workspaceApi.service.js +1 -1
  15. package/dist/api/services/workspaceApi.service.js.map +1 -1
  16. package/dist/api/utils/cache.utils.d.ts +3 -0
  17. package/dist/api/utils/cache.utils.js +18 -0
  18. package/dist/api/utils/cache.utils.js.map +1 -0
  19. package/dist/apps/services/app.service.js +65 -24
  20. package/dist/apps/services/app.service.js.map +1 -1
  21. package/dist/apps/validators/joi-validators/create.appWebhook.validator.js +1 -1
  22. package/dist/apps/validators/joi-validators/create.appWebhook.validator.js.map +1 -1
  23. package/dist/apps/validators/joi-validators/create.appWebhookEvent.validator.js +1 -0
  24. package/dist/apps/validators/joi-validators/create.appWebhookEvent.validator.js.map +1 -1
  25. package/dist/apps/validators/joi-validators/update.appWebhookEvent.validator.js +2 -0
  26. package/dist/apps/validators/joi-validators/update.appWebhookEvent.validator.js.map +1 -1
  27. package/dist/clients/webhooks.client.d.ts +2 -1
  28. package/dist/clients/webhooks.client.js +2 -2
  29. package/dist/clients/webhooks.client.js.map +1 -1
  30. package/dist/imports/imports.service.d.ts +2 -3
  31. package/dist/imports/imports.service.js +4 -45
  32. package/dist/imports/imports.service.js.map +1 -1
  33. package/dist/imports/imports.types.d.ts +238 -0
  34. package/dist/imports/repos/openApi.repo.d.ts +5 -11
  35. package/dist/imports/repos/openApi.repo.js +77 -27
  36. package/dist/imports/repos/openApi.repo.js.map +1 -1
  37. package/dist/index.d.ts +4 -1
  38. package/dist/index.js +7 -1
  39. package/dist/index.js.map +1 -1
  40. package/dist/logs/logs.service.d.ts +1 -1
  41. package/dist/processor/services/fallback.service.d.ts +1 -2
  42. package/dist/processor/services/fallback.service.js +0 -17
  43. package/dist/processor/services/fallback.service.js.map +1 -1
  44. package/dist/processor/services/processor.service.d.ts +10 -7
  45. package/dist/processor/services/processor.service.js +152 -59
  46. package/dist/processor/services/processor.service.js.map +1 -1
  47. package/dist/processor/services/quota.service.d.ts +3 -1
  48. package/dist/processor/services/quota.service.js +1 -1
  49. package/dist/processor/services/quota.service.js.map +1 -1
  50. package/dist/processor/utils/processor.utils.d.ts +3 -1
  51. package/dist/processor/utils/processor.utils.js +5 -2
  52. package/dist/processor/utils/processor.utils.js.map +1 -1
  53. package/dist/products/services/products.service.d.ts +2 -1
  54. package/dist/products/services/products.service.js +9 -5
  55. package/dist/products/services/products.service.js.map +1 -1
  56. package/dist/test/test.import.openapi.d.ts +1 -0
  57. package/dist/test/test.import.openapi.js +76 -0
  58. package/dist/test/test.import.openapi.js.map +1 -0
  59. package/dist/types/appBuilder.types.d.ts +3 -1
  60. package/dist/types/enums.d.ts +1 -0
  61. package/dist/types/enums.js +1 -0
  62. package/dist/types/enums.js.map +1 -1
  63. package/dist/types/processor.types.d.ts +1 -0
  64. package/dist/types/productsBuilder.types.d.ts +4 -4
  65. package/package.json +5 -2
@@ -52,7 +52,7 @@ const types_1 = require("../../types");
52
52
  const logs_service_1 = __importDefault(require("../../logs/logs.service"));
53
53
  const inputs_service_1 = __importDefault(require("../../inputs/inputs.service"));
54
54
  const processor_utils_1 = require("../utils/processor.utils");
55
- const http_client_1 = __importDefault(require("../../clients/http.client"));
55
+ const axios_1 = __importDefault(require("axios"));
56
56
  const processorApi_service_1 = require("../../api/services/processorApi.service");
57
57
  const expo_client_1 = __importDefault(require("../../clients/expo.client"));
58
58
  const handlebars_1 = require("handlebars");
@@ -69,8 +69,6 @@ const postgres_repo_1 = require("../repos/postgres.repo");
69
69
  const storage_util_1 = require("../utils/storage.util");
70
70
  const sms_repo_1 = require("../repos/sms.repo");
71
71
  const quota_service_1 = __importDefault(require("./quota.service"));
72
- const fallback_service_1 = __importDefault(require("./fallback.service"));
73
- const productsApi_service_1 = require("../../api/services/productsApi.service");
74
72
  async function loadBrokerService() {
75
73
  if (typeof window === 'undefined') {
76
74
  const { createBrokerService } = await Promise.resolve().then(() => __importStar(require('./messagebrokers')));
@@ -98,6 +96,7 @@ class ProcessorService {
98
96
  user_id,
99
97
  token,
100
98
  env_type,
99
+ redis_client
101
100
  });
102
101
  this.inputService = new inputs_service_1.default();
103
102
  this.requestTime = 0;
@@ -114,7 +113,6 @@ class ProcessorService {
114
113
  if (redis_client) {
115
114
  this.redisClient = redis_client;
116
115
  }
117
- this.productApi = new productsApi_service_1.ProductsApiService(env_type);
118
116
  }
119
117
  async generateSession(payload) {
120
118
  try {
@@ -278,7 +276,6 @@ class ProcessorService {
278
276
  }
279
277
  async processQuota(data) {
280
278
  this.start = Date.now();
281
- this.input = data;
282
279
  const { product: product_tag, env, input, tag: quota_tag } = data;
283
280
  try {
284
281
  this.productTag = product_tag;
@@ -300,6 +297,9 @@ class ProcessorService {
300
297
  data: input,
301
298
  };
302
299
  this.quota = this.fetchQuota(quota_tag, additional_logs);
300
+ if (!this.quota) {
301
+ throw new Error(`Quota ${quota_tag} not found`);
302
+ }
303
303
  this.logService.setFeatureId(this.quota._id);
304
304
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Process quota initiated', data: Object.assign(Object.assign({}, data), { input: (0, processor_utils_1.anonymizeObject)(data.input) }), status: types_1.LogEventStatus.PROCESSING }));
305
305
  this.processEnv = this.fetchEnv(env, additional_logs);
@@ -311,32 +311,91 @@ class ProcessorService {
311
311
  this.validateJSONFeatureInput(input, quotaInput, additional_logs);
312
312
  // split processes
313
313
  //this.sequenceLevels = this.splitSequenceIntoLevels(sequence, additional_logs);
314
- return await this.runQuotaOptions(options, additional_logs);
314
+ return await this.runQuotaOptions(options, input, additional_logs);
315
315
  }
316
316
  catch (e) {
317
317
  this.end = Date.now();
318
- this.logService.publish();
318
+ await this.logService.publish();
319
319
  throw e;
320
320
  }
321
321
  }
322
- async runQuotaOptions(options, additional_logs) {
323
- const quotaManager = new quota_service_1.default(options);
322
+ async runQuotaOptions(options, input, additional_logs) {
323
+ const quotaManager = new quota_service_1.default(options, this.redisClient);
324
324
  const getNextProvider = quotaManager.getNextProvider();
325
- await this.processEvent({
325
+ const quotaInput = await this.mapQuotaFallbackInput(getNextProvider.input, input, getNextProvider.app);
326
+ return await this.processEvent({
327
+ app: getNextProvider.app,
326
328
  type: getNextProvider.type,
327
329
  event: getNextProvider.event,
328
- input: getNextProvider.input,
330
+ input: quotaInput,
329
331
  retries: getNextProvider.retries,
330
332
  allow_fail: false
331
333
  });
332
334
  }
333
- async runFallbackOptions(options, additional_logs) {
334
- const fallbackManager = new fallback_service_1.default(options);
335
- await fallbackManager.executeActionWithFallback(this.processEvent);
335
+ async mapQuotaFallbackInput(providerInput, quotaInput, app) {
336
+ if (Array.isArray(providerInput)) {
337
+ return providerInput.map(async (item) => await this.mapQuotaFallbackInput(item, quotaInput, app));
338
+ }
339
+ else if (providerInput && typeof providerInput === 'object') {
340
+ const result = {};
341
+ for (const key in providerInput) {
342
+ result[key] = await this.mapQuotaFallbackInput(providerInput[key], quotaInput, app);
343
+ }
344
+ return result;
345
+ }
346
+ else {
347
+ // Base case: primitive value
348
+ return await this.overrideQuotaFallbackInput(providerInput, quotaInput, app);
349
+ }
350
+ }
351
+ async overrideQuotaFallbackInput(value, quotaInput, app) {
352
+ if (value.startsWith('$Input{')) {
353
+ return quotaInput[(0, string_utils_1.extractStages)(value)[0]];
354
+ }
355
+ else if (value.startsWith('$Auth')) {
356
+ return await this.generateAuthValue((0, string_utils_1.extractStages)(value), app, [], {});
357
+ }
358
+ else if (value.startsWith('$')) {
359
+ this.input = Object.assign(Object.assign({}, this.input), { input: quotaInput });
360
+ return await this.generateOperatorValues(value, '', {});
361
+ }
362
+ else {
363
+ return value;
364
+ }
365
+ }
366
+ async runFallbackOptions(options, input, additional_logs) {
367
+ return await this.executeActionWithFallback(options, input);
368
+ }
369
+ async executeActionWithFallback(providers, input) {
370
+ let index = 0;
371
+ for (const provider of providers) {
372
+ try {
373
+ const payload = {
374
+ app: provider.app,
375
+ type: provider.type,
376
+ event: provider.event,
377
+ input: await this.mapQuotaFallbackInput(provider.input, input, provider.app),
378
+ retries: provider.retries,
379
+ allow_fail: false
380
+ };
381
+ const result = await this.processEvent(payload);
382
+ if (result.status === types_1.LogEventStatus.FAIL) {
383
+ throw new Error(result.errors);
384
+ }
385
+ index++;
386
+ }
387
+ catch (error) {
388
+ console.log(error);
389
+ if (index > 0) {
390
+ throw error;
391
+ }
392
+ console.warn(`${provider.app || provider.event} failed: ${error}`);
393
+ }
394
+ }
395
+ //throw new Error("All providers failed.");
336
396
  }
337
397
  async processFallback(data) {
338
398
  this.start = Date.now();
339
- this.input = data;
340
399
  const { product: product_tag, env, input, tag: fallback_tag } = data;
341
400
  try {
342
401
  this.productTag = product_tag;
@@ -353,12 +412,15 @@ class ProcessorService {
353
412
  product_id: this.productId,
354
413
  workspace_id: this.workspace_id,
355
414
  env,
356
- type: types_1.LogEventTypes.QUOTA,
415
+ type: types_1.LogEventTypes.FALLBACK,
357
416
  process_id,
358
417
  data: input,
359
418
  };
360
419
  this.fallback = this.fetchFallback(fallback_tag, additional_logs);
361
- this.logService.setFeatureId(this.quota._id);
420
+ if (!this.fallback) {
421
+ throw new Error(`Fallback "${fallback_tag}" not found`);
422
+ }
423
+ this.logService.setFeatureId(this.fallback._id);
362
424
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Process fallback initiated', data: Object.assign(Object.assign({}, data), { input: (0, processor_utils_1.anonymizeObject)(data.input) }), status: types_1.LogEventStatus.PROCESSING }));
363
425
  this.processEnv = this.fetchEnv(env, additional_logs);
364
426
  if (!this.processEnv.active) {
@@ -369,15 +431,15 @@ class ProcessorService {
369
431
  this.validateJSONFeatureInput(input, fallbackInput, additional_logs);
370
432
  // split processes
371
433
  //this.sequenceLevels = this.splitSequenceIntoLevels(sequence, additional_logs);
372
- return await this.runFallbackOptions(options, additional_logs);
434
+ return await this.runFallbackOptions(options, input, additional_logs);
373
435
  }
374
436
  catch (e) {
375
437
  this.end = Date.now();
376
- this.logService.publish();
438
+ await this.logService.publish();
377
439
  throw e;
378
440
  }
379
441
  }
380
- async processFeature(data) {
442
+ async processFeature(data, awaitResolution = false) {
381
443
  this.start = Date.now();
382
444
  this.input = data;
383
445
  const { product: product_tag, env, input, tag: feature_tag } = data;
@@ -394,6 +456,9 @@ class ProcessorService {
394
456
  const process_id = this.process_id || (0, processor_utils_1.generateObjectId)();
395
457
  this.process_id = process_id;
396
458
  this.feature = this.fetchFeature(feature_tag, additional_logs);
459
+ if (!this.feature) {
460
+ throw new Error(`Feature "${feature_tag}" not found`);
461
+ }
397
462
  this.baseLogs = {
398
463
  product_tag: this.productTag,
399
464
  product_id: this.productId,
@@ -424,7 +489,7 @@ class ProcessorService {
424
489
  this.end = Date.now();
425
490
  if (this.logService) {
426
491
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Process feature - failed', data: Object.assign(Object.assign({}, data), { input: (0, processor_utils_1.anonymizeObject)(data.input) }), status: types_1.LogEventStatus.PROCESSING }));
427
- this.logService.publish();
492
+ await this.logService.publish();
428
493
  if (passedValidation) {
429
494
  return { process_id: this.process_id };
430
495
  }
@@ -433,7 +498,6 @@ class ProcessorService {
433
498
  }
434
499
  }
435
500
  else {
436
- console.log("FAILING HERE TOOO");
437
501
  throw e;
438
502
  }
439
503
  }
@@ -586,14 +650,13 @@ class ProcessorService {
586
650
  }
587
651
  if (previousLevelComplete && !this.published) {
588
652
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { successful_feature_execution: true, message: 'Process feature - success', data: {}, status: types_1.LogEventStatus.SUCCESS }));
589
- this.logService.publish();
653
+ await this.logService.publish();
590
654
  this.end = Date.now();
591
655
  this.writeResult(types_1.LogEventStatus.SUCCESS);
592
656
  }
593
657
  }
594
658
  catch (e) {
595
659
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Process levels - failed', data: { e }, status: types_1.LogEventStatus.FAIL }));
596
- console.log("SEQUENCE PROCESSING FAILED!!!");
597
660
  throw e;
598
661
  }
599
662
  }
@@ -928,7 +991,7 @@ class ProcessorService {
928
991
  return await this.sumValues(value, app, additional_logs, sample, index, key, loopIndex);
929
992
  }
930
993
  else if (value.startsWith('$Substract(') && value.endsWith(')')) {
931
- return await this.sumValues(value, app, additional_logs, sample, index, key, loopIndex);
994
+ return await this.subtractValues(value, app, additional_logs, sample, index, key, loopIndex);
932
995
  }
933
996
  else if (value.startsWith('$Pick(') && value.endsWith(')')) {
934
997
  return await this.pickValue(value, app, additional_logs, sample, index, key, loopIndex);
@@ -1320,7 +1383,7 @@ class ProcessorService {
1320
1383
  }
1321
1384
  }
1322
1385
  decorateValue(value, sample) {
1323
- if (sample.decorator) {
1386
+ if (sample && sample.decorator) {
1324
1387
  if (sample.decoratorPosition &&
1325
1388
  sample.decoratorPosition == types_1.DecoratorPostions.APPEND &&
1326
1389
  !value.endsWith(sample.decorator)) {
@@ -1416,12 +1479,14 @@ class ProcessorService {
1416
1479
  return this.runFallback(event as unknown as IFallbackEvent);
1417
1480
  }*/
1418
1481
  if (event.type === types_1.FeatureEventTypes.ACTION) {
1482
+ console.log("APP AND EVENT!!!!", event.app);
1419
1483
  const additional_logs = {
1420
- parent_tag: (0, string_utils_1.extractOriginAndTag)(event.app),
1484
+ parent_tag: event.app,
1421
1485
  child_tag: event.event,
1422
1486
  type: types_1.LogEventTypes.ACTION,
1423
1487
  name: 'Process feature action',
1424
1488
  };
1489
+ console.log("EVENTER!!!!!!===>>>>>>", event);
1425
1490
  return this.runAction(event, additional_logs);
1426
1491
  }
1427
1492
  if (event.type === types_1.FeatureEventTypes.DB_ACTION) {
@@ -1445,8 +1510,12 @@ class ProcessorService {
1445
1510
  return this.runStorage(event, additional_logs);
1446
1511
  }
1447
1512
  if (event.type === types_1.FeatureEventTypes.FEATURE) {
1448
- // this.processFeature({})
1449
- // this.processFeature TODO: do some processing to get this to reuse this.processFeature from abov
1513
+ const additional_logs = {
1514
+ parent_tag: event.event,
1515
+ type: types_1.LogEventTypes.FEATURE,
1516
+ name: 'Process sub-feature',
1517
+ };
1518
+ return this.runFeature(event, additional_logs);
1450
1519
  }
1451
1520
  if (event.type === types_1.FeatureEventTypes.NOTIFICATION) {
1452
1521
  const [parent_tag, child_tag] = event.event.split(':');
@@ -1485,6 +1554,23 @@ class ProcessorService {
1485
1554
  throw e;
1486
1555
  }
1487
1556
  }
1557
+ async runFeature(event, additional_logs) {
1558
+ const freshInstance = Object.assign(Object.create(Object.getPrototypeOf(this)), this);
1559
+ const result = await freshInstance.processFeature({
1560
+ product: this.productTag,
1561
+ tag: event.event,
1562
+ env: this.processEnv.slug,
1563
+ input: event.input,
1564
+ }, true);
1565
+ const output = await freshInstance.generateOutput(result.process_id);
1566
+ if (output.status === types_1.LogEventStatus.FAIL) {
1567
+ await this.addToFailureOutput(output.errors, event, { process_id: result.process_id }, Object.assign(Object.assign({}, additional_logs), { process_id: result.process_id }));
1568
+ }
1569
+ else if (output.status === types_1.LogEventStatus.SUCCESS) {
1570
+ await this.addToSuccessOutput(event, output.data, Object.assign(Object.assign({}, additional_logs), { process_id: result.process_id }));
1571
+ }
1572
+ return output;
1573
+ }
1488
1574
  runJob(event, additional_logs) {
1489
1575
  throw new Error('Method not implemented.');
1490
1576
  }
@@ -1612,7 +1698,7 @@ class ProcessorService {
1612
1698
  await this.processEvent(event);
1613
1699
  this.end = Date.now();
1614
1700
  this.writeResult(types_1.LogEventStatus.SUCCESS);
1615
- this.logService.publish();
1701
+ await this.logService.publish();
1616
1702
  }
1617
1703
  return { process_id };
1618
1704
  }
@@ -1753,7 +1839,7 @@ class ProcessorService {
1753
1839
  // generate indexes
1754
1840
  return (0, processor_utils_1.generateIndexes)(operator, iter, init, valueValue);
1755
1841
  }
1756
- async runAction(event, additional_logs, returnValue = false) {
1842
+ async runAction(event, additional_logs, returnValue = true) {
1757
1843
  try {
1758
1844
  const { event: action_tag, app: access_tag, condition, cache: cache_tag } = event;
1759
1845
  let indexes = [];
@@ -1767,6 +1853,7 @@ class ProcessorService {
1767
1853
  indexes = await this.extractLoopIndexes(event, additional_logs);
1768
1854
  }
1769
1855
  let app = await this.fetchThirdPartyApp(access_tag);
1856
+ console.log("RUNNING ACTION APP ====>>>>", app.envs, access_tag);
1770
1857
  const { actions, envs: appEnvs, retries, workspace_id: recipient_workspace_id, active } = app;
1771
1858
  const productApp = this.productBuilderService.fetchApp(access_tag);
1772
1859
  const { envs: productEnvs, version } = productApp;
@@ -1784,6 +1871,7 @@ class ProcessorService {
1784
1871
  throw new Error(`Action ${action_tag} not found in ${access_tag}`);
1785
1872
  }
1786
1873
  const { query, headers, body, params, request_type, method, base_url, resource } = action;
1874
+ console.log("BASE URLS!!!!!!", base_url, env.base_url);
1787
1875
  let request_base_url = base_url;
1788
1876
  if (env.base_url) {
1789
1877
  request_base_url = env.base_url;
@@ -1817,9 +1905,12 @@ class ProcessorService {
1817
1905
  }
1818
1906
  }
1819
1907
  }
1820
- if (request_type === types_1.DataFormats.JSON || !request_type) {
1908
+ if (request_type === types_1.DataFormats.JSON || request_type === types_1.DataFormats.URLENCODED || !request_type) {
1821
1909
  if (indexes.length == 0) {
1822
1910
  payloads = await this.constructJSONDataPayloads(event.input, additional_logs, samples, event);
1911
+ if (request_type === types_1.DataFormats.URLENCODED) {
1912
+ payloads.body = (0, processor_utils_1.toFormUrlEncoded)(payloads.body);
1913
+ }
1823
1914
  additional_logs.recipient_workspace_id = recipient_workspace_id;
1824
1915
  result = await this.processRequest({ request_base_url, resource, method, env, payloads, app_id: app._id }, event, retries, additional_logs, returnValue);
1825
1916
  }
@@ -1884,7 +1975,7 @@ class ProcessorService {
1884
1975
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Process http request - failed', failed_execution: true, data: { e }, status: types_1.LogEventStatus.FAIL, app_id, action: event.event, start,
1885
1976
  end }));
1886
1977
  try {
1887
- const value = this.addToFailureOutput(e, event, {
1978
+ const value = await this.addToFailureOutput(e, event, {
1888
1979
  request_base_url,
1889
1980
  resource,
1890
1981
  method,
@@ -1925,7 +2016,7 @@ class ProcessorService {
1925
2016
  }
1926
2017
  // addToSkippedOutput()
1927
2018
  }
1928
- addToFailureOutput(e, event, payload, additional_logs, policy = {}) {
2019
+ async addToFailureOutput(e, event, payload, additional_logs, policy = {}) {
1929
2020
  try {
1930
2021
  const exists = this.processingOutput.failure.findIndex((item) => {
1931
2022
  if (item.event.sequence_tag) {
@@ -1970,7 +2061,6 @@ class ProcessorService {
1970
2061
  this.processingOutput.failure.push(output);
1971
2062
  }
1972
2063
  if (retries_left > 0) {
1973
- //console.log("RETRY AT", retry_at)
1974
2064
  setTimeout(() => {
1975
2065
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Retrying Request', data: Object.assign(Object.assign({}, output), { payload: (0, processor_utils_1.anonymizeObject)(output.payload) }), status: types_1.LogEventStatus.PROCESSING }));
1976
2066
  if (event.type === types_1.FeatureEventTypes.ACTION) {
@@ -1990,10 +2080,9 @@ class ProcessorService {
1990
2080
  }
1991
2081
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Ran out of retries - failed', data: Object.assign(Object.assign({}, output), { payload: (0, processor_utils_1.anonymizeObject)(output.payload) }), status: types_1.LogEventStatus.FAIL }));
1992
2082
  //throw new Error("Run out of retries")
1993
- console.log("REQUEST TIME", this.requestTime, this.totalRequests, this.end - this.start);
1994
2083
  this.end = Date.now();
1995
2084
  this.writeResult(types_1.LogEventStatus.FAIL);
1996
- this.logService.publish();
2085
+ await this.logService.publish();
1997
2086
  this.published = true;
1998
2087
  //throw new Error("Terminate Process")
1999
2088
  }
@@ -2062,20 +2151,24 @@ class ProcessorService {
2062
2151
  }
2063
2152
  }
2064
2153
  const authHeaders = headers;
2154
+ if (!base_url.endsWith('/') && !resource.startsWith('/')) {
2155
+ base_url = base_url + '/';
2156
+ }
2065
2157
  const request = {
2066
2158
  url: resource,
2067
2159
  method,
2160
+ baseURL: base_url,
2068
2161
  data: body,
2069
2162
  params: query,
2070
2163
  headers: authHeaders,
2164
+ timeout: 15000,
2165
+ withCredentials: false
2071
2166
  };
2072
- if (!base_url.endsWith('/') && !resource.startsWith('/')) {
2073
- base_url = base_url + '/';
2074
- }
2075
- const response = await (0, http_client_1.default)(base_url).request(request);
2167
+ const response = await axios_1.default.request(request);
2076
2168
  return response.data;
2077
2169
  }
2078
2170
  catch (e) {
2171
+ console.error("LOG ERROR", e);
2079
2172
  throw e;
2080
2173
  }
2081
2174
  }
@@ -2120,13 +2213,13 @@ class ProcessorService {
2120
2213
  this.end = Date.now();
2121
2214
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Storing file - success', data: { input: this.clone, result }, status: types_1.LogEventStatus.SUCCESS }));
2122
2215
  this.writeResult(types_1.LogEventStatus.SUCCESS);
2123
- this.logService.publish();
2216
+ await this.logService.publish();
2124
2217
  return result;
2125
2218
  }
2126
2219
  catch (e) {
2127
2220
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Storing file - failed', data: { e }, status: types_1.LogEventStatus.FAIL }));
2128
2221
  this.end = Date.now();
2129
- this.logService.publish();
2222
+ await this.logService.publish();
2130
2223
  return { process_id: this.process_id };
2131
2224
  }
2132
2225
  }
@@ -2169,13 +2262,13 @@ class ProcessorService {
2169
2262
  this.end = Date.now();
2170
2263
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Subscribe to topic - success', data: { input: this.clone, result }, status: types_1.LogEventStatus.SUCCESS }));
2171
2264
  this.writeResult(types_1.LogEventStatus.SUCCESS);
2172
- this.logService.publish();
2265
+ await this.logService.publish();
2173
2266
  return result;
2174
2267
  }
2175
2268
  catch (e) {
2176
2269
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Subscribe to topic - failed', data: { e }, status: types_1.LogEventStatus.FAIL }));
2177
2270
  this.end = Date.now();
2178
- this.logService.publish();
2271
+ await this.logService.publish();
2179
2272
  return { process_id: this.process_id };
2180
2273
  }
2181
2274
  }
@@ -2222,13 +2315,13 @@ class ProcessorService {
2222
2315
  this.end = Date.now();
2223
2316
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Publishing to topic - success', data: { input: (0, processor_utils_1.anonymizeObject)(this.clone), result }, status: types_1.LogEventStatus.SUCCESS }));
2224
2317
  this.writeResult(types_1.LogEventStatus.SUCCESS);
2225
- this.logService.publish();
2318
+ await this.logService.publish();
2226
2319
  return result;
2227
2320
  }
2228
2321
  catch (e) {
2229
2322
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Publishing to topic - failed', data: { e }, status: types_1.LogEventStatus.FAIL }));
2230
2323
  this.end = Date.now();
2231
- this.logService.publish();
2324
+ await this.logService.publish();
2232
2325
  return { process_id: this.process_id };
2233
2326
  }
2234
2327
  }
@@ -2414,7 +2507,7 @@ class ProcessorService {
2414
2507
  }
2415
2508
  catch (e) {
2416
2509
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { failed_execution: true, message: 'Attempt notification - failed', data: { e: e.toString() }, status: types_1.LogEventStatus.FAIL }));
2417
- //this.logService.publish();
2510
+ //await this.logService.publish();
2418
2511
  throw e;
2419
2512
  }
2420
2513
  }
@@ -2494,7 +2587,7 @@ class ProcessorService {
2494
2587
  }
2495
2588
  catch (e) {
2496
2589
  this.logService.add(Object.assign(Object.assign({}, this.baseLogs), { failed_execution: true, message: 'Attempt migration - failed', data: e, status: types_1.LogEventStatus.FAIL }));
2497
- this.logService.publish();
2590
+ await this.logService.publish();
2498
2591
  }
2499
2592
  }
2500
2593
  /*async runFunction(data: IFeatureEvent, additional_logs: Partial<ILogData>): Promise<any> {
@@ -2587,7 +2680,7 @@ class ProcessorService {
2587
2680
  data: e,
2588
2681
  status: LogEventStatus.FAIL,
2589
2682
  });
2590
- this.logService.publish();
2683
+ await this.logService.publish();
2591
2684
  }
2592
2685
  }*/
2593
2686
  async runStorage(data, additional_logs = {}) {
@@ -2748,7 +2841,7 @@ class ProcessorService {
2748
2841
  result = await pgHandler[databaseAction.type](databaseAction.data, template, input.data);
2749
2842
  }
2750
2843
  }
2751
- //this.logService.publish();
2844
+ //await this.logService.publish();
2752
2845
  // const result = this.processDBRequest(db_action, input, database_tag, databaseEnv, action_tag, additional_logs);
2753
2846
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { successful_execution: true, message: 'Run database action query - success', data: { result: (0, processor_utils_1.anonymizeObject)(result) }, status: types_1.LogEventStatus.SUCCESS }));
2754
2847
  await this.addToSuccessOutput(db_action, result, additional_logs);
@@ -2910,7 +3003,7 @@ class ProcessorService {
2910
3003
  }
2911
3004
  catch (e) {
2912
3005
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { failed_execution: true, message: 'Run storage request - failed', data: { e }, status: types_1.LogEventStatus.FAIL }));
2913
- const value = this.addToFailureOutput(e, data, { storageEnv }, additional_logs);
3006
+ const value = await this.addToFailureOutput(e, data, { storageEnv }, additional_logs);
2914
3007
  throw e;
2915
3008
  }
2916
3009
  }
@@ -2933,7 +3026,7 @@ class ProcessorService {
2933
3026
  }
2934
3027
  catch (e) {
2935
3028
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { failed_execution: true, message: 'Running database query - failed', data: { payload: (0, processor_utils_1.anonymizeObject)(input), e }, status: types_1.LogEventStatus.FAIL }));
2936
- const value = this.addToFailureOutput(e, db_action, {
3029
+ const value = await this.addToFailureOutput(e, db_action, {
2937
3030
  db_action,
2938
3031
  input,
2939
3032
  database_tag,
@@ -3021,14 +3114,14 @@ class ProcessorService {
3021
3114
  this.end = Date.now();
3022
3115
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Execute action - success', data: { input: (0, processor_utils_1.anonymizeObject)(input), result: (0, processor_utils_1.anonymizeObject)(result) }, status: types_1.LogEventStatus.SUCCESS }));
3023
3116
  this.writeResult(types_1.LogEventStatus.SUCCESS);
3024
- this.logService.publish();
3117
+ await this.logService.publish();
3025
3118
  return result;
3026
3119
  }
3027
3120
  catch (e) {
3028
3121
  console.log(e);
3029
3122
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Execute action - failed', data: { e }, status: types_1.LogEventStatus.FAIL }));
3030
3123
  this.end = Date.now();
3031
- this.logService.publish();
3124
+ await this.logService.publish();
3032
3125
  return { process_id: this.process_id };
3033
3126
  }
3034
3127
  }
@@ -3076,13 +3169,13 @@ class ProcessorService {
3076
3169
  this.end = Date.now();
3077
3170
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Execute database action', data: { input: (0, processor_utils_1.anonymizeObject)(input), result: (0, processor_utils_1.anonymizeObject)(result) }, status: types_1.LogEventStatus.SUCCESS }));
3078
3171
  this.writeResult(types_1.LogEventStatus.SUCCESS);
3079
- this.logService.publish();
3172
+ await this.logService.publish();
3080
3173
  return result;
3081
3174
  }
3082
3175
  catch (e) {
3083
3176
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Execute database action', data: { e }, status: types_1.LogEventStatus.FAIL }));
3084
3177
  this.end = Date.now();
3085
- this.logService.publish();
3178
+ await this.logService.publish();
3086
3179
  return { process_id: this.process_id };
3087
3180
  }
3088
3181
  }
@@ -3131,13 +3224,13 @@ class ProcessorService {
3131
3224
  this.end = Date.now();
3132
3225
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Send notification - success', data: { input: (0, processor_utils_1.anonymizeObject)(input), result: (0, processor_utils_1.anonymizeObject)(result) }, status: types_1.LogEventStatus.SUCCESS }));
3133
3226
  this.writeResult(types_1.LogEventStatus.SUCCESS);
3134
- this.logService.publish();
3227
+ await this.logService.publish();
3135
3228
  return { process_id };
3136
3229
  }
3137
3230
  catch (e) {
3138
3231
  this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Send notification - failed', data: { e }, status: types_1.LogEventStatus.FAIL }));
3139
3232
  this.end = Date.now();
3140
- this.logService.publish();
3233
+ await this.logService.publish();
3141
3234
  return { process_id: this.process_id };
3142
3235
  }
3143
3236
  }