@ductape/sdk 0.0.4-v4 → 0.0.4-v6
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/clients/apps.client.js +1 -1
- package/dist/clients/apps.client.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -2
- package/dist/index.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 +1 -0
- package/dist/logs/logs.types.js.map +1 -1
- 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 +4 -2
- package/dist/processor/services/processor.service.js +111 -121
- package/dist/processor/services/processor.service.js.map +1 -1
- package/dist/processor/utils/processor.utils.js +24 -3
- package/dist/processor/utils/processor.utils.js.map +1 -1
- 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 +1 -1
- package/dist/products/services/products.service.js +62 -15
- package/dist/products/services/products.service.js.map +1 -1
- 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.userAuth.validator.js +1 -0
- package/dist/products/validators/joi-validators/update.userAuth.validator.js.map +1 -1
- package/dist/types/processor.types.d.ts +13 -0
- package/dist/types/processor.types.js.map +1 -1
- package/dist/types/productsBuilder.types.d.ts +3 -1
- package/dist/types/productsBuilder.types.js.map +1 -1
- package/package.json +5 -1
|
@@ -152,6 +152,7 @@ class ProcessorService {
|
|
|
152
152
|
throw e;
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
+
async decryptSession(payload) { }
|
|
155
156
|
async registerWebhook(data) {
|
|
156
157
|
const { product: product_tag, access_tag, webhook_tag, envs } = data;
|
|
157
158
|
await this.productBuilderService.initializeProductByTag(product_tag);
|
|
@@ -301,7 +302,6 @@ class ProcessorService {
|
|
|
301
302
|
throw new Error(`Quota ${quota_tag} not found`);
|
|
302
303
|
}
|
|
303
304
|
this.logService.setFeatureId(this.quota._id);
|
|
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);
|
|
306
306
|
if (!this.processEnv.active) {
|
|
307
307
|
throw new Error(`Environment ${data.env} is not active`);
|
|
@@ -311,6 +311,7 @@ class ProcessorService {
|
|
|
311
311
|
this.validateJSONFeatureInput(input, quotaInput, additional_logs);
|
|
312
312
|
// split processes
|
|
313
313
|
//this.sequenceLevels = this.splitSequenceIntoLevels(sequence, additional_logs);
|
|
314
|
+
await this.logService.publish();
|
|
314
315
|
return await this.runQuotaOptions(options, input, additional_logs);
|
|
315
316
|
}
|
|
316
317
|
catch (e) {
|
|
@@ -320,17 +321,25 @@ class ProcessorService {
|
|
|
320
321
|
}
|
|
321
322
|
}
|
|
322
323
|
async runQuotaOptions(options, input, additional_logs) {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
324
|
+
try {
|
|
325
|
+
const quotaManager = new quota_service_1.default(options, this.redisClient);
|
|
326
|
+
const getNextProvider = quotaManager.getNextProvider();
|
|
327
|
+
const quotaInput = await this.mapQuotaFallbackInput(getNextProvider.input, input, getNextProvider.app);
|
|
328
|
+
const result = await this.processEvent({
|
|
329
|
+
app: getNextProvider.app,
|
|
330
|
+
type: getNextProvider.type,
|
|
331
|
+
event: getNextProvider.event,
|
|
332
|
+
input: quotaInput,
|
|
333
|
+
retries: getNextProvider.retries,
|
|
334
|
+
allow_fail: false
|
|
335
|
+
});
|
|
336
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Process quota successful', successful_execution: true, data: { result: (0, processor_utils_1.anonymizeObject)(result) }, status: types_1.LogEventStatus.PROCESSING }));
|
|
337
|
+
return result;
|
|
338
|
+
}
|
|
339
|
+
catch (e) {
|
|
340
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Process quota failed', failed_execution: true, data: { e }, status: types_1.LogEventStatus.PROCESSING }));
|
|
341
|
+
throw e;
|
|
342
|
+
}
|
|
334
343
|
}
|
|
335
344
|
async mapQuotaFallbackInput(providerInput, quotaInput, app) {
|
|
336
345
|
if (Array.isArray(providerInput)) {
|
|
@@ -420,7 +429,6 @@ class ProcessorService {
|
|
|
420
429
|
throw new Error(`Fallback "${fallback_tag}" not found`);
|
|
421
430
|
}
|
|
422
431
|
this.logService.setFeatureId(this.fallback._id);
|
|
423
|
-
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 }));
|
|
424
432
|
this.processEnv = this.fetchEnv(env, additional_logs);
|
|
425
433
|
if (!this.processEnv.active) {
|
|
426
434
|
throw new Error(`Environment ${data.env} is not active`);
|
|
@@ -470,7 +478,6 @@ class ProcessorService {
|
|
|
470
478
|
feature_id: this.feature._id,
|
|
471
479
|
};
|
|
472
480
|
this.logService.setFeatureId(this.feature._id);
|
|
473
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Process feature initiated', data: Object.assign(Object.assign({}, data), { input: (0, processor_utils_1.anonymizeObject)(data.input) }), status: types_1.LogEventStatus.PROCESSING }));
|
|
474
481
|
this.processEnv = this.fetchEnv(env, additional_logs);
|
|
475
482
|
if (!this.processEnv.active) {
|
|
476
483
|
throw new Error(`Environment ${data.env} is not active`);
|
|
@@ -502,13 +509,7 @@ class ProcessorService {
|
|
|
502
509
|
}
|
|
503
510
|
}
|
|
504
511
|
async intializeProduct(additional_logs) {
|
|
505
|
-
|
|
506
|
-
if (this.productTag) {
|
|
507
|
-
await this.productBuilderService.initializeProductByTag(this.productTag); // validate product_exists
|
|
508
|
-
}
|
|
509
|
-
else {
|
|
510
|
-
await this.productBuilderService.initializeProduct(this.productId);
|
|
511
|
-
}
|
|
512
|
+
if (!this.logService) {
|
|
512
513
|
this.logService = new logs_service_1.default({
|
|
513
514
|
product_id: this.productId,
|
|
514
515
|
workspace_id: this.workspace_id,
|
|
@@ -517,6 +518,14 @@ class ProcessorService {
|
|
|
517
518
|
token: this.token,
|
|
518
519
|
env_type: this.environment,
|
|
519
520
|
});
|
|
521
|
+
}
|
|
522
|
+
try {
|
|
523
|
+
if (this.productTag) {
|
|
524
|
+
await this.productBuilderService.initializeProductByTag(this.productTag); // validate product_exists
|
|
525
|
+
}
|
|
526
|
+
else {
|
|
527
|
+
await this.productBuilderService.initializeProduct(this.productId);
|
|
528
|
+
}
|
|
520
529
|
const { _id: product_id, workspace_id } = this.productBuilderService.fetchProduct();
|
|
521
530
|
this.productId = product_id;
|
|
522
531
|
if (workspace_id !== this.workspace_id) {
|
|
@@ -531,7 +540,6 @@ class ProcessorService {
|
|
|
531
540
|
}
|
|
532
541
|
fetchFeature(tag, additional_logs) {
|
|
533
542
|
try {
|
|
534
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Fetch feature - initiated', data: { tag }, status: types_1.LogEventStatus.PROCESSING }));
|
|
535
543
|
const feature = this.productBuilderService.fetchFeature(tag); // validate feature exists
|
|
536
544
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Fetch feature - success', data: { tag, feature }, status: types_1.LogEventStatus.SUCCESS }));
|
|
537
545
|
return feature;
|
|
@@ -543,7 +551,6 @@ class ProcessorService {
|
|
|
543
551
|
}
|
|
544
552
|
fetchQuota(tag, additional_logs) {
|
|
545
553
|
try {
|
|
546
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Fetch quota - initiated', data: { tag }, status: types_1.LogEventStatus.PROCESSING }));
|
|
547
554
|
const quota = this.productBuilderService.fetchQuota(tag); // validate feature exists
|
|
548
555
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Fetch quota - success', data: { tag, quota }, status: types_1.LogEventStatus.SUCCESS }));
|
|
549
556
|
return quota;
|
|
@@ -555,7 +562,6 @@ class ProcessorService {
|
|
|
555
562
|
}
|
|
556
563
|
fetchFallback(tag, additional_logs) {
|
|
557
564
|
try {
|
|
558
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Fetch fallback - initiated', data: { tag }, status: types_1.LogEventStatus.PROCESSING }));
|
|
559
565
|
const fallback = this.productBuilderService.fetchFallback(tag); // validate feature exists
|
|
560
566
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Fetch fallback - success', data: { tag, fallback }, status: types_1.LogEventStatus.SUCCESS }));
|
|
561
567
|
return fallback;
|
|
@@ -567,7 +573,6 @@ class ProcessorService {
|
|
|
567
573
|
}
|
|
568
574
|
fetchEnv(env, additional_logs) {
|
|
569
575
|
try {
|
|
570
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Fetch environment - initiated', data: { slug: env }, status: types_1.LogEventStatus.PROCESSING }));
|
|
571
576
|
const product_env = this.productBuilderService.fetchEnv(env); // validate env exists
|
|
572
577
|
if (!product_env) {
|
|
573
578
|
throw new Error(`Env ${env} not found`);
|
|
@@ -582,7 +587,6 @@ class ProcessorService {
|
|
|
582
587
|
}
|
|
583
588
|
validateJSONFeatureInput(input, feature_input, additional_logs) {
|
|
584
589
|
try {
|
|
585
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Input validation - initiated', data: { input: (0, processor_utils_1.anonymizeObject)(input), feature_input }, status: types_1.LogEventStatus.PROCESSING }));
|
|
586
590
|
(0, processor_utils_1.validateFeatureJSONInput)(input, feature_input);
|
|
587
591
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Input validation - success', data: {}, status: types_1.LogEventStatus.SUCCESS }));
|
|
588
592
|
}
|
|
@@ -593,7 +597,6 @@ class ProcessorService {
|
|
|
593
597
|
}
|
|
594
598
|
async splitSequenceIntoLevels(data, additional_logs) {
|
|
595
599
|
try {
|
|
596
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Split sequence - initiated', data: {}, status: types_1.LogEventStatus.PROCESSING }));
|
|
597
600
|
const levels = {};
|
|
598
601
|
const tagMap = new Map(data.map((seq) => [seq.tag, seq]));
|
|
599
602
|
const assignedLevels = new Map();
|
|
@@ -630,7 +633,6 @@ class ProcessorService {
|
|
|
630
633
|
}
|
|
631
634
|
async processSequenceLevels(additional_logs) {
|
|
632
635
|
try {
|
|
633
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Process levels - initiated', data: { levels: this.sequenceLevels }, status: types_1.LogEventStatus.PROCESSING }));
|
|
634
636
|
const levelEvents = {};
|
|
635
637
|
Object.entries(this.sequenceLevels).forEach(([level, sequences]) => {
|
|
636
638
|
levelEvents[parseInt(level)] = this.fetchLevelEvents(sequences, parseInt(level));
|
|
@@ -658,7 +660,6 @@ class ProcessorService {
|
|
|
658
660
|
successful_feature_execution = true;
|
|
659
661
|
}
|
|
660
662
|
else if (this.processingFailure) {
|
|
661
|
-
console.log("PROCESSING FAILURE", this.processingFailure);
|
|
662
663
|
message = 'Process feature - processing';
|
|
663
664
|
status = types_1.LogEventStatus.PROCESSING;
|
|
664
665
|
successful_feature_execution = false;
|
|
@@ -674,7 +675,7 @@ class ProcessorService {
|
|
|
674
675
|
return true;
|
|
675
676
|
}
|
|
676
677
|
catch (e) {
|
|
677
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Process levels - failed', data: { e }, status: types_1.LogEventStatus.FAIL }));
|
|
678
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Process sequence levels - failed', data: { e }, status: types_1.LogEventStatus.FAIL }));
|
|
678
679
|
throw e;
|
|
679
680
|
}
|
|
680
681
|
}
|
|
@@ -702,7 +703,6 @@ class ProcessorService {
|
|
|
702
703
|
const { failure } = this.processingOutput;
|
|
703
704
|
const promises = failure.map((failed) => {
|
|
704
705
|
if (failed.retries_left > 0 && new Date().getTime() > failed.retry_at) {
|
|
705
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Reprocess failed events - initiated', data: Object.assign({}, failed), status: types_1.LogEventStatus.PROCESSING }));
|
|
706
706
|
return this.processEvent(failed.event); // process events should also take care of this.processingOutput
|
|
707
707
|
}
|
|
708
708
|
if (failed.retries_left === 0 && !failed.allow_fail) {
|
|
@@ -747,7 +747,6 @@ class ProcessorService {
|
|
|
747
747
|
}
|
|
748
748
|
fetchActionRequestDependents(input, additional_logs) {
|
|
749
749
|
try {
|
|
750
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Fetch request dependencies - initialized', data: input, status: types_1.LogEventStatus.PROCESSING }));
|
|
751
750
|
const dependents = [];
|
|
752
751
|
if (input.query) {
|
|
753
752
|
dependents.push(...this.fetchDependents(input.query, additional_logs));
|
|
@@ -779,7 +778,6 @@ class ProcessorService {
|
|
|
779
778
|
}
|
|
780
779
|
fetchDependents(obj, additional_logs) {
|
|
781
780
|
try {
|
|
782
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Fetch dependents - initiated', data: obj, status: types_1.LogEventStatus.PROCESSING }));
|
|
783
781
|
const dependants = [];
|
|
784
782
|
for (const key in obj) {
|
|
785
783
|
const value = obj[key];
|
|
@@ -821,7 +819,6 @@ class ProcessorService {
|
|
|
821
819
|
return dependants;
|
|
822
820
|
}
|
|
823
821
|
catch (e) {
|
|
824
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Fetch dependents - failed', data: { e }, status: types_1.LogEventStatus.FAIL }));
|
|
825
822
|
throw e;
|
|
826
823
|
}
|
|
827
824
|
}
|
|
@@ -855,7 +852,6 @@ class ProcessorService {
|
|
|
855
852
|
}
|
|
856
853
|
async constructJSONDataPayloads(object, additional_logs, samples, event, loopIndex = 0) {
|
|
857
854
|
try {
|
|
858
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Construct JSON payloads - initiated', data: { object, samples }, status: types_1.LogEventStatus.PROCESSING }));
|
|
859
855
|
const payload = {};
|
|
860
856
|
const { body: actionBody, query: actionQuery, headers: actionHeaders, params: actionParams } = object;
|
|
861
857
|
if (actionBody) {
|
|
@@ -912,7 +908,6 @@ class ProcessorService {
|
|
|
912
908
|
}
|
|
913
909
|
async generatePayload(obj, event, additional_logs, sample = [], index = {}, loopIndex = null) {
|
|
914
910
|
try {
|
|
915
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Generate payload - initiated', data: { obj, event, sample }, status: types_1.LogEventStatus.PROCESSING }));
|
|
916
911
|
const payload = {};
|
|
917
912
|
const keys = Object.keys(obj);
|
|
918
913
|
for (let i = 0; i < keys.length; i++) {
|
|
@@ -1432,7 +1427,6 @@ class ProcessorService {
|
|
|
1432
1427
|
}
|
|
1433
1428
|
async fetchAuthData(app_tag, additional_logs) {
|
|
1434
1429
|
try {
|
|
1435
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Fetching auth data - initiated', data: { app_tag, env: this.processEnv.slug }, status: types_1.LogEventStatus.PROCESSING }));
|
|
1436
1430
|
const app = this.productBuilderService.fetchApp(app_tag);
|
|
1437
1431
|
if (!app) {
|
|
1438
1432
|
throw new Error(`App ${app_tag} not found in $Auth value`);
|
|
@@ -1591,12 +1585,19 @@ class ProcessorService {
|
|
|
1591
1585
|
throw new Error('Method not implemented.');
|
|
1592
1586
|
}
|
|
1593
1587
|
async processFailedAndWaiting() { }
|
|
1594
|
-
async
|
|
1595
|
-
var _a, _b, _c, _d;
|
|
1588
|
+
async fetchResult(process_id) {
|
|
1596
1589
|
const result = await this.processorApiService.fetchResult(process_id, this.getUserAccess());
|
|
1597
1590
|
if (!result) {
|
|
1598
1591
|
throw new Error(`Invalid process id ${process_id}`);
|
|
1599
1592
|
}
|
|
1593
|
+
await this.productBuilderService.initializeProduct(result.product_id);
|
|
1594
|
+
result.result = JSON.parse((0, processor_utils_1.decrypt)(String(result.result), this.productBuilderService.fetchProduct().private_key));
|
|
1595
|
+
result.input = JSON.parse((0, processor_utils_1.decrypt)(String(result.input), this.productBuilderService.fetchProduct().private_key));
|
|
1596
|
+
return result;
|
|
1597
|
+
}
|
|
1598
|
+
async generateOutput(process_id) {
|
|
1599
|
+
var _a, _b, _c, _d;
|
|
1600
|
+
const result = await this.fetchResult(process_id);
|
|
1600
1601
|
if (result.component === types_1.LogEventTypes.FEATURE) {
|
|
1601
1602
|
const additional_logs = {
|
|
1602
1603
|
parent_tag: result.input.tag,
|
|
@@ -1635,7 +1636,7 @@ class ProcessorService {
|
|
|
1635
1636
|
}
|
|
1636
1637
|
}
|
|
1637
1638
|
async resumeProcess(process_id) {
|
|
1638
|
-
const result =
|
|
1639
|
+
const result = await this.fetchResult(process_id);
|
|
1639
1640
|
if (!result) {
|
|
1640
1641
|
throw new Error(`Invalid process id ${process_id}`);
|
|
1641
1642
|
}
|
|
@@ -1677,7 +1678,7 @@ class ProcessorService {
|
|
|
1677
1678
|
}
|
|
1678
1679
|
async replayProcess(process_id) {
|
|
1679
1680
|
var _a, _b, _c;
|
|
1680
|
-
const result =
|
|
1681
|
+
const result = await this.fetchResult(process_id);
|
|
1681
1682
|
if (!result) {
|
|
1682
1683
|
throw new Error(`Invalid process id ${process_id}`);
|
|
1683
1684
|
}
|
|
@@ -1805,7 +1806,6 @@ class ProcessorService {
|
|
|
1805
1806
|
}
|
|
1806
1807
|
async processConditionalCheck(event, additional_logs = {}) {
|
|
1807
1808
|
const parts = (0, string_utils_1.extractConditionalParts)(event.condition.check);
|
|
1808
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Check conditional - initiated', data: { condition: event.condition, parts }, status: types_1.LogEventStatus.PROCESSING, action: event.event }));
|
|
1809
1809
|
const [, initiator, operator, value] = parts;
|
|
1810
1810
|
const initiatorValue = await this.generateStringValues(initiator, event.app, additional_logs);
|
|
1811
1811
|
let valueValue;
|
|
@@ -1817,7 +1817,6 @@ class ProcessorService {
|
|
|
1817
1817
|
else {
|
|
1818
1818
|
valueValue = value;
|
|
1819
1819
|
}
|
|
1820
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Validate check conditional - initiated', data: { condition: { initiatorValue, operator, valueValue } }, status: types_1.LogEventStatus.PROCESSING, action: event.event }));
|
|
1821
1820
|
const pass = (0, processor_utils_1.compareValues)(initiatorValue, operator, valueValue);
|
|
1822
1821
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Validate check condition - success', data: { condition: { initiatorValue, operator, valueValue }, pass }, status: types_1.LogEventStatus.SUCCESS, action: event.event }));
|
|
1823
1822
|
if (!pass) {
|
|
@@ -1842,7 +1841,6 @@ class ProcessorService {
|
|
|
1842
1841
|
}
|
|
1843
1842
|
async extractLoopIndexes(event, additional_logs = {}) {
|
|
1844
1843
|
const parts = (0, string_utils_1.extractConditionalParts)(event.condition.check);
|
|
1845
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Loop conditional - initiated', data: { condition: event.condition, parts }, status: types_1.LogEventStatus.PROCESSING, action: event.event }));
|
|
1846
1844
|
const [, initiator, operator, value] = parts;
|
|
1847
1845
|
let valueValue;
|
|
1848
1846
|
if (!(0, string_utils_1.isNumeric)(value)) {
|
|
@@ -1913,10 +1911,10 @@ class ProcessorService {
|
|
|
1913
1911
|
input: inputString,
|
|
1914
1912
|
privateKey: product.private_key,
|
|
1915
1913
|
expiry: productCache.expiry,
|
|
1916
|
-
});
|
|
1914
|
+
}, additional_logs);
|
|
1917
1915
|
if (check) {
|
|
1918
1916
|
result = JSON.parse(check);
|
|
1919
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Run action -
|
|
1917
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Run action - response from cache', data: { result: (0, processor_utils_1.anonymizeObject)(result) }, status: types_1.LogEventStatus.SUCCESS, cache_tag, action: event.event }));
|
|
1920
1918
|
if (returnValue) {
|
|
1921
1919
|
return result;
|
|
1922
1920
|
}
|
|
@@ -1955,18 +1953,17 @@ class ProcessorService {
|
|
|
1955
1953
|
component_tag: action_tag,
|
|
1956
1954
|
component_type: types_1.ProductComponents.ACTION,
|
|
1957
1955
|
product_tag: this.productTag,
|
|
1958
|
-
});
|
|
1956
|
+
}, additional_logs);
|
|
1959
1957
|
}
|
|
1960
1958
|
return result;
|
|
1961
1959
|
}
|
|
1962
1960
|
catch (e) {
|
|
1963
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), {
|
|
1961
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Run Action - failed', data: { e }, status: types_1.LogEventStatus.FAIL }));
|
|
1964
1962
|
throw e;
|
|
1965
1963
|
}
|
|
1966
1964
|
}
|
|
1967
1965
|
async processRequest(payload, event, retries, additional_logs, returnValue = false) {
|
|
1968
1966
|
const { request_base_url, resource, payloads, method, env, app_id } = payload;
|
|
1969
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Process http request - initiated', data: { request: (0, processor_utils_1.anonymizeObject)(payload) }, status: types_1.LogEventStatus.PROCESSING, app_id, action: event.event }));
|
|
1970
1967
|
const start = Date.now();
|
|
1971
1968
|
try {
|
|
1972
1969
|
let results = (0, processor_utils_1.generateMockData)(resource, env.slug, payloads);
|
|
@@ -1988,11 +1985,16 @@ class ProcessorService {
|
|
|
1988
1985
|
}
|
|
1989
1986
|
catch (e) {
|
|
1990
1987
|
const end = Date.now();
|
|
1988
|
+
let error = e;
|
|
1989
|
+
if (e.response.data) {
|
|
1990
|
+
error = e.response.data;
|
|
1991
|
+
}
|
|
1991
1992
|
this.requestTime += end - start;
|
|
1992
1993
|
this.totalRequests += 1;
|
|
1993
|
-
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,
|
|
1994
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Process http request - failed', failed_execution: true, data: { e: error, input: (0, processor_utils_1.anonymizeObject)(payloads) }, status: types_1.LogEventStatus.FAIL, app_id, action: event.event, start,
|
|
1994
1995
|
end }));
|
|
1995
1996
|
try {
|
|
1997
|
+
console.log(e);
|
|
1996
1998
|
const value = await this.addToFailureOutput(e, event, {
|
|
1997
1999
|
request_base_url,
|
|
1998
2000
|
resource,
|
|
@@ -2022,6 +2024,9 @@ class ProcessorService {
|
|
|
2022
2024
|
this.processingOutput.failure = this.processingOutput.failure.filter((data) => !(data.event.sequence_tag === event.sequence_tag && data.event.event === event.event));
|
|
2023
2025
|
this.processingOutput.skipped = this.processingOutput.skipped.filter((data) => !(data.event.sequence_tag === event.sequence_tag && data.event.event === event.event));
|
|
2024
2026
|
this.processingOutput.waiting = this.processingOutput.waiting.filter((data) => !(data.event.sequence_tag === event.sequence_tag && data.event.event === event.event));
|
|
2027
|
+
if (event.type === types_1.FeatureEventTypes.STORAGE) {
|
|
2028
|
+
event = (0, processor_utils_1.cleanBlob)(event);
|
|
2029
|
+
}
|
|
2025
2030
|
this.processingOutput.success.push({ event, output });
|
|
2026
2031
|
await this.processWaitingEvents(additional_logs);
|
|
2027
2032
|
if (this.checkIsSuccessful() && this.doneWithProcessing) {
|
|
@@ -2076,6 +2081,12 @@ class ProcessorService {
|
|
|
2076
2081
|
max = metrices.max;
|
|
2077
2082
|
}
|
|
2078
2083
|
const { allow_fail, retries } = event;
|
|
2084
|
+
let retryable = true;
|
|
2085
|
+
if (event.type === types_1.FeatureEventTypes.STORAGE) {
|
|
2086
|
+
event = (0, processor_utils_1.cleanBlob)(event);
|
|
2087
|
+
if (!this.feature || (this.feature && !event.allow_fail))
|
|
2088
|
+
retryable = false;
|
|
2089
|
+
}
|
|
2079
2090
|
let retries_left = retries || max;
|
|
2080
2091
|
if (exists > -1) {
|
|
2081
2092
|
retries_left = this.processingOutput.failure[exists].retries_left - 1;
|
|
@@ -2122,7 +2133,7 @@ class ProcessorService {
|
|
|
2122
2133
|
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 }));
|
|
2123
2134
|
//throw new Error("Run out of retries")
|
|
2124
2135
|
this.end = Date.now();
|
|
2125
|
-
await this.writeResult(types_1.LogEventStatus.FAIL);
|
|
2136
|
+
await this.writeResult(types_1.LogEventStatus.FAIL, retryable);
|
|
2126
2137
|
await this.logService.publish();
|
|
2127
2138
|
//throw new Error("Terminate Process")
|
|
2128
2139
|
}
|
|
@@ -2239,7 +2250,6 @@ class ProcessorService {
|
|
|
2239
2250
|
if (!productEnv.active) {
|
|
2240
2251
|
throw new Error(`Environment ${env} is not active`);
|
|
2241
2252
|
}
|
|
2242
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Storing file - initiated', status: types_1.LogEventStatus.PROCESSING, storage: new Blob([action.input.buffer]).size }));
|
|
2243
2253
|
const payload = {
|
|
2244
2254
|
type: types_1.FeatureEventTypes.STORAGE,
|
|
2245
2255
|
event,
|
|
@@ -2254,7 +2264,7 @@ class ProcessorService {
|
|
|
2254
2264
|
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 }));
|
|
2255
2265
|
await this.writeResult(types_1.LogEventStatus.SUCCESS);
|
|
2256
2266
|
await this.logService.publish();
|
|
2257
|
-
return result;
|
|
2267
|
+
return Object.assign(Object.assign({}, result), { process_id: this.process_id });
|
|
2258
2268
|
}
|
|
2259
2269
|
catch (e) {
|
|
2260
2270
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Storing file - failed', data: { e }, status: types_1.LogEventStatus.FAIL }));
|
|
@@ -2341,7 +2351,6 @@ class ProcessorService {
|
|
|
2341
2351
|
if (!productEnv.active) {
|
|
2342
2352
|
throw new Error(`Environment ${data.env} is not active`);
|
|
2343
2353
|
}
|
|
2344
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Publish to topic - initiated', data: Object.assign(Object.assign({}, data), { input: (0, processor_utils_1.anonymizeObject)(data.input) }), status: types_1.LogEventStatus.PROCESSING }));
|
|
2345
2354
|
const payload = {
|
|
2346
2355
|
type: types_1.FeatureEventTypes.PUBLISH,
|
|
2347
2356
|
event: data.event,
|
|
@@ -2404,24 +2413,18 @@ class ProcessorService {
|
|
|
2404
2413
|
}
|
|
2405
2414
|
}
|
|
2406
2415
|
async ProcessExpoNotification(notification, template, payload, additional_logs) {
|
|
2407
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Validate notification payload - initiated', data: { notification, payload: (0, processor_utils_1.anonymizeObject)(payload) }, status: types_1.LogEventStatus.PROCESSING }));
|
|
2408
2416
|
(0, processor_utils_1.validateNotification)(template, payload);
|
|
2409
2417
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Validate notification payload - success', data: {}, status: types_1.LogEventStatus.SUCCESS }));
|
|
2410
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Generate notification template - initiated', data: {}, status: types_1.LogEventStatus.PROCESSING }));
|
|
2411
2418
|
const { title, body, data } = (0, processor_utils_1.generateNotificationTemplate)(template, payload);
|
|
2412
2419
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Generate notification template - success', data: { title, body, data: (0, processor_utils_1.anonymizeObject)(data) }, status: types_1.LogEventStatus.SUCCESS }));
|
|
2413
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Send Expo notification - initiated', data: {}, status: types_1.LogEventStatus.PROCESSING }));
|
|
2414
2420
|
await this.sendExpoNotification({ title, body, data }, payload.device_tokens);
|
|
2415
2421
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Send Expo notification - success', data: { title, body, data: (0, processor_utils_1.anonymizeObject)(data) }, status: types_1.LogEventStatus.SUCCESS }));
|
|
2416
2422
|
}
|
|
2417
2423
|
async ProcessFirebaseNotification(notification, template, payload, additional_logs) {
|
|
2418
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Validate Firebase notification payload - initiated', data: { notification, payload: (0, processor_utils_1.anonymizeObject)(payload) }, status: types_1.LogEventStatus.PROCESSING }));
|
|
2419
2424
|
(0, processor_utils_1.validateNotification)(template, payload);
|
|
2420
2425
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Validate Firebase notification payload - success', data: {}, status: types_1.LogEventStatus.SUCCESS }));
|
|
2421
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Generate Firebase notification template - initiated', data: {}, status: types_1.LogEventStatus.PROCESSING }));
|
|
2422
2426
|
const { title, body, data } = (0, processor_utils_1.generateNotificationTemplate)(template, payload);
|
|
2423
2427
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Generate Firebase notification template - success', data: { title, body: (0, processor_utils_1.anonymizeObject)(data), data: (0, processor_utils_1.anonymizeObject)(data) }, status: types_1.LogEventStatus.SUCCESS }));
|
|
2424
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Send Firebase notification - initiated', data: {}, status: types_1.LogEventStatus.PROCESSING }));
|
|
2425
2428
|
await this.sendFirebaseNotification({ title, body, data }, payload.device_tokens, notification.credentials);
|
|
2426
2429
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Send Firebase notification - success', data: { title, body: (0, processor_utils_1.anonymizeObject)(data), data: (0, processor_utils_1.anonymizeObject)(data) }, status: types_1.LogEventStatus.SUCCESS }));
|
|
2427
2430
|
}
|
|
@@ -2431,8 +2434,6 @@ class ProcessorService {
|
|
|
2431
2434
|
const input = notification.input;
|
|
2432
2435
|
try {
|
|
2433
2436
|
//await this.intializeProduct(additional_logs);
|
|
2434
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Attempting notification', data: { notification }, status: types_1.LogEventStatus.PROCESSING }));
|
|
2435
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Fetching notification details', data: { notification }, status: types_1.LogEventStatus.PROCESSING }));
|
|
2436
2437
|
const notificationEvent = this.productBuilderService.fetchNotification(event.split(":")[0]);
|
|
2437
2438
|
const message = this.productBuilderService.fetchNotificationMessage(event);
|
|
2438
2439
|
if (!message) {
|
|
@@ -2452,15 +2453,23 @@ class ProcessorService {
|
|
|
2452
2453
|
expected: types_1.ExpectedValues.PARSEINPUT,
|
|
2453
2454
|
}));
|
|
2454
2455
|
//await this.inputService.validateInput(validationPayload, message.push_notification_data, "Push Notifications");
|
|
2455
|
-
if (push && notifications.type === types_1.Notifiers.FIREBASE) {
|
|
2456
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Processing Expo notification - initiated', data: { notification, input: (0, processor_utils_1.anonymizeObject)(input.push_notification) }, status: types_1.LogEventStatus.PROCESSING }));
|
|
2457
|
-
await this.ProcessExpoNotification(notifications, message, input.push_notification, additional_logs);
|
|
2458
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Processing Expo notification - success', data: {}, status: types_1.LogEventStatus.SUCCESS }));
|
|
2459
|
-
}
|
|
2460
2456
|
if (push && notifications.type === types_1.Notifiers.EXPO) {
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2457
|
+
try {
|
|
2458
|
+
await this.ProcessExpoNotification(notifications, message, input.push_notification, additional_logs);
|
|
2459
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { successful_execution: true, message: 'Processing Expo notification - success', data: {}, status: types_1.LogEventStatus.SUCCESS }));
|
|
2460
|
+
}
|
|
2461
|
+
catch (e) {
|
|
2462
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { failed_execution: true, message: 'Processing Expo notification - failed', data: {}, status: types_1.LogEventStatus.SUCCESS }));
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
if (push && notifications.type === types_1.Notifiers.FIREBASE) {
|
|
2466
|
+
try {
|
|
2467
|
+
await this.ProcessFirebaseNotification(notifications, message, input.push_notification, additional_logs);
|
|
2468
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { successful_execution: true, message: 'Processing Firebase notification - success', data: { notification, input: (0, processor_utils_1.anonymizeObject)(input.push_notification) }, status: types_1.LogEventStatus.SUCCESS }));
|
|
2469
|
+
}
|
|
2470
|
+
catch (e) {
|
|
2471
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { failed_execution: true, message: 'Processing Firebase notification - failed', data: { notification, input: (0, processor_utils_1.anonymizeObject)(input.push_notification) }, status: types_1.LogEventStatus.FAIL }));
|
|
2472
|
+
}
|
|
2464
2473
|
}
|
|
2465
2474
|
if (email && emails) {
|
|
2466
2475
|
input.email.subject = await this.generatePayload(input.email.subject, notification, additional_logs, message.email_data.filter((data) => data.parent_key === 'subject'));
|
|
@@ -2472,37 +2481,28 @@ class ProcessorService {
|
|
|
2472
2481
|
}));
|
|
2473
2482
|
//await this.inputService.validateInput(validationPayload, message.email_data);
|
|
2474
2483
|
input.email.recipients.map((email) => this.inputService.validateEmailString({ key: 'to', value: email }));
|
|
2475
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Process email - initiated', data: { email: (0, processor_utils_1.anonymizeObject)(email), input: (0, processor_utils_1.anonymizeObject)(input.email) }, status: types_1.LogEventStatus.PROCESSING }));
|
|
2476
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Attempt email auth fetch - initiated', data: { emails: (0, processor_utils_1.anonymizeObject)(emails) }, status: types_1.LogEventStatus.PROCESSING }));
|
|
2477
2484
|
const { sender_email: from } = emails, auth = __rest(emails, ["sender_email"]);
|
|
2478
2485
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Attempt email auth fetch - success', data: { from: (0, processor_utils_1.anonymizeValue)(from), host: (0, processor_utils_1.anonymizeValue)(auth.host), port: (0, processor_utils_1.anonymizeValue)(auth.port) }, status: types_1.LogEventStatus.SUCCESS }));
|
|
2479
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Generate email template - initiated', data: {
|
|
2480
|
-
template: (0, processor_utils_1.anonymizeValue)(email.template),
|
|
2481
|
-
subject: (0, processor_utils_1.anonymizeValue)(email.subject),
|
|
2482
|
-
input: (0, processor_utils_1.anonymizeObject)(input.email),
|
|
2483
|
-
}, status: types_1.LogEventStatus.PROCESSING }));
|
|
2484
2486
|
const templateMaker = (0, handlebars_1.compile)(email.template);
|
|
2485
2487
|
const template = templateMaker(input.email.template);
|
|
2486
2488
|
const subject = (0, processor_utils_1.replacePlaceholderString)(email.subject, input.email.subject || {});
|
|
2487
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Generate email template - success', data: { template: (0, processor_utils_1.anonymizeValue)(template), subject: (0, processor_utils_1.anonymizeValue)(subject) }, status: types_1.LogEventStatus.SUCCESS }));
|
|
2489
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Generate email template - success', data: { template: (0, processor_utils_1.anonymizeValue)(template), subject: (0, processor_utils_1.anonymizeValue)(subject), input: (0, processor_utils_1.anonymizeObject)(input.email), }, status: types_1.LogEventStatus.SUCCESS }));
|
|
2488
2490
|
const mailOptions = {
|
|
2489
2491
|
from,
|
|
2490
2492
|
to: input.email.recipients,
|
|
2491
2493
|
subject,
|
|
2492
2494
|
template,
|
|
2493
2495
|
};
|
|
2494
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Send email - initiated', data: { template: (0, processor_utils_1.anonymizeValue)(template), subject: (0, processor_utils_1.anonymizeValue)(subject), to: input.email.recipients.map((data) => (0, processor_utils_1.anonymizeValue)(data)) }, status: types_1.LogEventStatus.PROCESSING }));
|
|
2495
2496
|
try {
|
|
2496
2497
|
const transporter = await (0, processor_utils_1.mailerClient)(auth);
|
|
2497
2498
|
const response = await transporter.sendMail(mailOptions);
|
|
2498
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Send email - success', data: { response }, status: types_1.LogEventStatus.SUCCESS }));
|
|
2499
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Send email - success', successful_execution: true, data: { response }, status: types_1.LogEventStatus.SUCCESS }));
|
|
2499
2500
|
}
|
|
2500
2501
|
catch (e) {
|
|
2501
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Send email - failed', data: { e }, status: types_1.LogEventStatus.FAIL }));
|
|
2502
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { failed_execution: true, message: 'Send email - failed', data: { e }, status: types_1.LogEventStatus.FAIL }));
|
|
2502
2503
|
}
|
|
2503
2504
|
}
|
|
2504
2505
|
if (callback && callbacks) {
|
|
2505
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Process callback - initiated', data: Object.assign(Object.assign({}, callbacks), { data: (0, processor_utils_1.anonymizeObject)(callback) }), status: types_1.LogEventStatus.PROCESSING }));
|
|
2506
2506
|
const payload = {
|
|
2507
2507
|
query: Object.assign(Object.assign({}, (_a = input.callback) === null || _a === void 0 ? void 0 : _a.query), (_b = callbacks.auth) === null || _b === void 0 ? void 0 : _b.query),
|
|
2508
2508
|
headers: Object.assign(Object.assign({}, (_c = input.callback) === null || _c === void 0 ? void 0 : _c.headers), (_d = callbacks.auth) === null || _d === void 0 ? void 0 : _d.headers),
|
|
@@ -2518,32 +2518,29 @@ class ProcessorService {
|
|
|
2518
2518
|
expected: types_1.ExpectedValues.PARSEINPUT,
|
|
2519
2519
|
}));
|
|
2520
2520
|
//this.inputService.validateInput(validationPayload, message.callback_data);
|
|
2521
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Generate callback payload - initiated', data: Object.assign(Object.assign({}, callbacks), { data: (0, processor_utils_1.anonymizeObject)(payload) }), status: types_1.LogEventStatus.PROCESSING }));
|
|
2522
2521
|
const url = new URL(callbacks.url);
|
|
2523
2522
|
try {
|
|
2524
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Send callback - initiated', data: {}, status: types_1.LogEventStatus.PROCESSING }));
|
|
2525
2523
|
await this.sendActionRequest(url.origin, url.pathname, payload, callbacks.method, '');
|
|
2526
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { name: 'Send callback - success', data: {}, status: types_1.LogEventStatus.SUCCESS }));
|
|
2524
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { successful_execution: true, name: 'Send callback - success', data: {}, status: types_1.LogEventStatus.SUCCESS }));
|
|
2527
2525
|
}
|
|
2528
2526
|
catch (e) {
|
|
2529
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Send callback - failed', data: { e }, status: types_1.LogEventStatus.FAIL }));
|
|
2527
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { failed_execution: true, message: 'Send callback - failed', data: { e }, status: types_1.LogEventStatus.FAIL }));
|
|
2530
2528
|
}
|
|
2531
2529
|
}
|
|
2532
2530
|
if (sms && smses) {
|
|
2533
2531
|
try {
|
|
2534
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Process sms - initiated', data: { data: sms, config: (0, processor_utils_1.anonymizeObject)(smses) }, status: types_1.LogEventStatus.PROCESSING }));
|
|
2535
2532
|
input.sms.body = await (0, processor_utils_1.replacePlaceholderString)(sms, input.sms.body);
|
|
2536
2533
|
const SmsClient = await (0, sms_repo_1.loadSMSClient)();
|
|
2537
2534
|
const smsClient = new SmsClient(smses);
|
|
2538
2535
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { name: 'Send sms - initiated', data: { message: input.sms.body, config: (0, processor_utils_1.anonymizeObject)(smses) }, status: types_1.LogEventStatus.SUCCESS }));
|
|
2539
2536
|
const res = await smsClient.sendMessage(input.sms.body, input.sms.recipients);
|
|
2540
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { name: 'Send sms - success', data: res, status: types_1.LogEventStatus.SUCCESS }));
|
|
2537
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { name: 'Send sms - success', successful_execution: true, data: res, status: types_1.LogEventStatus.SUCCESS }));
|
|
2541
2538
|
}
|
|
2542
2539
|
catch (e) {
|
|
2543
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Process sms - failed', data: { e }, status: types_1.LogEventStatus.FAIL }));
|
|
2540
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { failed_execution: true, message: 'Process sms - failed', data: { e }, status: types_1.LogEventStatus.FAIL }));
|
|
2544
2541
|
}
|
|
2545
2542
|
}
|
|
2546
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), {
|
|
2543
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Attempt notification - success', data: notification, status: types_1.LogEventStatus.SUCCESS }));
|
|
2547
2544
|
}
|
|
2548
2545
|
catch (e) {
|
|
2549
2546
|
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 }));
|
|
@@ -2728,8 +2725,6 @@ class ProcessorService {
|
|
|
2728
2725
|
const input = data.input;
|
|
2729
2726
|
try {
|
|
2730
2727
|
await this.intializeProduct(additional_logs);
|
|
2731
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Attempt storage - initiated', data: this.clone, status: types_1.LogEventStatus.PROCESSING }));
|
|
2732
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Fetch storage details - initiated', data: this.clone, status: types_1.LogEventStatus.PROCESSING }));
|
|
2733
2728
|
const storage = await this.productBuilderService.fetchStorage(event);
|
|
2734
2729
|
const storageEnv = storage.envs.find((el) => el.slug === env.slug);
|
|
2735
2730
|
if (!storageEnv) {
|
|
@@ -2749,19 +2744,17 @@ class ProcessorService {
|
|
|
2749
2744
|
input: inputString,
|
|
2750
2745
|
privateKey: product.private_key,
|
|
2751
2746
|
expiry: productCache.expiry,
|
|
2752
|
-
});
|
|
2747
|
+
}, additional_logs);
|
|
2753
2748
|
if (check) {
|
|
2754
2749
|
result = JSON.parse(check);
|
|
2755
2750
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Store file - return from cache', data: { result }, status: types_1.LogEventStatus.PROCESSING }));
|
|
2756
2751
|
return result;
|
|
2757
2752
|
}
|
|
2758
2753
|
}
|
|
2759
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Store file - initiated', data: {}, status: types_1.LogEventStatus.PROCESSING }));
|
|
2760
2754
|
input.buffer = input.buffer ? await this.generateStringValues(input.buffer, '', additional_logs, []) : undefined;
|
|
2761
2755
|
input.fileName = input.fileName ? await this.generateStringValues(input.fileName, '', additional_logs, []) : undefined;
|
|
2762
2756
|
input.mimeType = input.mimeType ? await this.generateStringValues(input.mimeType, '', additional_logs, []) : undefined;
|
|
2763
2757
|
result = await this.processStorageRequest(data, input, storageEnv, additional_logs);
|
|
2764
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { successful_execution: true, message: 'Store file - success', data: { result }, status: types_1.LogEventStatus.PROCESSING }));
|
|
2765
2758
|
if (cache_tag && this.redisClient) {
|
|
2766
2759
|
const productCache = this.productBuilderService.fetchCache(cache_tag);
|
|
2767
2760
|
if (!productCache) {
|
|
@@ -2777,12 +2770,11 @@ class ProcessorService {
|
|
|
2777
2770
|
component_tag: event,
|
|
2778
2771
|
component_type: types_1.ProductComponents.STORAGE,
|
|
2779
2772
|
product_tag: this.productTag,
|
|
2780
|
-
});
|
|
2773
|
+
}, additional_logs);
|
|
2781
2774
|
}
|
|
2782
2775
|
return result;
|
|
2783
2776
|
}
|
|
2784
2777
|
catch (e) {
|
|
2785
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { failed_execution: true, message: 'Attempt storage - failed', data: { e }, status: types_1.LogEventStatus.FAIL }));
|
|
2786
2778
|
throw e;
|
|
2787
2779
|
}
|
|
2788
2780
|
}
|
|
@@ -2791,8 +2783,6 @@ class ProcessorService {
|
|
|
2791
2783
|
const input = db_action.input;
|
|
2792
2784
|
try {
|
|
2793
2785
|
//await this.intializeProduct(additional_logs);
|
|
2794
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Attempt database action - initiated', data: db_action, status: types_1.LogEventStatus.PROCESSING }));
|
|
2795
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Fetch database action - initiated', data: {}, status: types_1.LogEventStatus.PROCESSING }));
|
|
2796
2786
|
const [database_tag, action_tag] = event.split(':');
|
|
2797
2787
|
const product = this.productBuilderService.fetchProduct();
|
|
2798
2788
|
const database = await this.productBuilderService.fetchDatabase(database_tag);
|
|
@@ -2802,7 +2792,6 @@ class ProcessorService {
|
|
|
2802
2792
|
throw new Error(`Database env for ${env.slug} not found`);
|
|
2803
2793
|
}
|
|
2804
2794
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Fetch database action - success', data: databaseAction, status: types_1.LogEventStatus.SUCCESS }));
|
|
2805
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Validate database action payload - initiated', data: { payload: (0, processor_utils_1.anonymizeObject)(input.data) }, status: types_1.LogEventStatus.PROCESSING }));
|
|
2806
2795
|
input.data = await this.generatePayload(input.data, db_action, additional_logs, databaseAction.data);
|
|
2807
2796
|
if (Array.isArray(input.data)) {
|
|
2808
2797
|
await Promise.all(input.data.map(async (d) => {
|
|
@@ -2830,11 +2819,9 @@ class ProcessorService {
|
|
|
2830
2819
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Validate database action payload - success', data: { db_action, payload: (0, processor_utils_1.anonymizeObject)(input.data) }, status: types_1.LogEventStatus.SUCCESS }));
|
|
2831
2820
|
if (database.type === types_1.DatabaseTypes.MONGODB) {
|
|
2832
2821
|
if (databaseAction.type === types_1.DatabaseActionTypes.UPDATE) {
|
|
2833
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Validate database update action filter - initiated', data: { filter: (0, processor_utils_1.anonymizeObject)(input.filter) }, status: types_1.LogEventStatus.PROCESSING }));
|
|
2834
2822
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Validate database update action filter - success', data: {}, status: types_1.LogEventStatus.SUCCESS }));
|
|
2835
2823
|
}
|
|
2836
2824
|
}
|
|
2837
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Run database action query - initiated', data: { payload: (0, processor_utils_1.anonymizeObject)(input) }, status: types_1.LogEventStatus.PROCESSING }));
|
|
2838
2825
|
let result;
|
|
2839
2826
|
if (cache_tag && this.redisClient) {
|
|
2840
2827
|
const productCache = this.productBuilderService.fetchCache(cache_tag);
|
|
@@ -2847,7 +2834,7 @@ class ProcessorService {
|
|
|
2847
2834
|
input: inputString,
|
|
2848
2835
|
privateKey: product.private_key,
|
|
2849
2836
|
expiry: productCache.expiry,
|
|
2850
|
-
});
|
|
2837
|
+
}, additional_logs);
|
|
2851
2838
|
if (check) {
|
|
2852
2839
|
result = JSON.parse(check);
|
|
2853
2840
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Run database action query - return from cache', data: { result: (0, processor_utils_1.anonymizeObject)(result) }, status: types_1.LogEventStatus.SUCCESS }));
|
|
@@ -2883,7 +2870,6 @@ class ProcessorService {
|
|
|
2883
2870
|
}
|
|
2884
2871
|
//await this.logService.publish();
|
|
2885
2872
|
// const result = this.processDBRequest(db_action, input, database_tag, databaseEnv, action_tag, additional_logs);
|
|
2886
|
-
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 }));
|
|
2887
2873
|
await this.addToSuccessOutput(db_action, result, additional_logs);
|
|
2888
2874
|
if (cache_tag && this.redisClient) {
|
|
2889
2875
|
const productCache = this.productBuilderService.fetchCache(cache_tag);
|
|
@@ -2900,8 +2886,9 @@ class ProcessorService {
|
|
|
2900
2886
|
product_tag: this.productTag,
|
|
2901
2887
|
component_tag: database_tag,
|
|
2902
2888
|
component_type: types_1.ProductComponents.DATABASE_ACTION,
|
|
2903
|
-
});
|
|
2889
|
+
}, additional_logs);
|
|
2904
2890
|
}
|
|
2891
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { successful_execution: true, message: 'Attempt database action - successful', data: { result: (0, processor_utils_1.anonymizeObject)(result) }, status: types_1.LogEventStatus.SUCCESS }));
|
|
2905
2892
|
return result;
|
|
2906
2893
|
}
|
|
2907
2894
|
catch (e) {
|
|
@@ -2914,8 +2901,6 @@ class ProcessorService {
|
|
|
2914
2901
|
const input = data.input;
|
|
2915
2902
|
try {
|
|
2916
2903
|
await this.intializeProduct(additional_logs);
|
|
2917
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Attempt broker topic subscription - initiated', data: { event }, status: types_1.LogEventStatus.PROCESSING }));
|
|
2918
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Fetch broker details - initiated', data: { event }, status: types_1.LogEventStatus.PROCESSING }));
|
|
2919
2904
|
const [brokerTag, topicTag] = event.split(':');
|
|
2920
2905
|
const broker = this.productBuilderService.fetchMessageBroker(brokerTag);
|
|
2921
2906
|
if (!broker) {
|
|
@@ -2941,12 +2926,13 @@ class ProcessorService {
|
|
|
2941
2926
|
url = queueUrl.url;
|
|
2942
2927
|
}
|
|
2943
2928
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Fetch broker details - success', data: { event, broker }, status: types_1.LogEventStatus.SUCCESS }));
|
|
2944
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Subscribe to broker topic - initiated', data: {}, status: types_1.LogEventStatus.PROCESSING }));
|
|
2945
2929
|
const createBrokerService = await loadBrokerService();
|
|
2946
2930
|
if (createBrokerService) {
|
|
2947
2931
|
const brokerService = createBrokerService(brokerEnv.type, brokerEnv.config);
|
|
2948
2932
|
await brokerService.subscribe(url, input.callback);
|
|
2949
|
-
|
|
2933
|
+
if (this.feature) {
|
|
2934
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { successful_execution: true, message: 'Subscribe to broker topic - success', data: { event }, status: types_1.LogEventStatus.SUCCESS }));
|
|
2935
|
+
}
|
|
2950
2936
|
return;
|
|
2951
2937
|
}
|
|
2952
2938
|
else {
|
|
@@ -2964,8 +2950,6 @@ class ProcessorService {
|
|
|
2964
2950
|
const input = data.input;
|
|
2965
2951
|
try {
|
|
2966
2952
|
await this.intializeProduct(additional_logs);
|
|
2967
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Attempt publish to broker topic - initiated', data: { event }, status: types_1.LogEventStatus.PROCESSING }));
|
|
2968
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Fetch broker details - initiated', data: { event }, status: types_1.LogEventStatus.PROCESSING }));
|
|
2969
2953
|
const [brokerTag, topicTag] = event.split(':');
|
|
2970
2954
|
const broker = this.productBuilderService.fetchMessageBroker(brokerTag);
|
|
2971
2955
|
if (!broker) {
|
|
@@ -2991,12 +2975,13 @@ class ProcessorService {
|
|
|
2991
2975
|
url = queueUrl.url;
|
|
2992
2976
|
}
|
|
2993
2977
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Fetch broker details - success', data: { event, broker }, status: types_1.LogEventStatus.SUCCESS }));
|
|
2994
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Publish to broker topic initiated', data: {}, status: types_1.LogEventStatus.PROCESSING }));
|
|
2995
2978
|
const createBrokerService = await loadBrokerService();
|
|
2996
2979
|
if (createBrokerService) {
|
|
2997
2980
|
const brokerService = createBrokerService(brokerEnv.type, brokerEnv.config);
|
|
2998
2981
|
await brokerService.publish(url, input.message);
|
|
2999
|
-
|
|
2982
|
+
if (this.feature) {
|
|
2983
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Publish to broker topic - success', successful_execution: true, data: { event }, status: types_1.LogEventStatus.SUCCESS }));
|
|
2984
|
+
}
|
|
3000
2985
|
return;
|
|
3001
2986
|
}
|
|
3002
2987
|
else {
|
|
@@ -3041,6 +3026,7 @@ class ProcessorService {
|
|
|
3041
3026
|
url: (0, processor_utils_1.encrypt)(result.url, this.productBuilderService.fetchProduct().private_key),
|
|
3042
3027
|
provider: storageEnv.type,
|
|
3043
3028
|
product: this.productTag,
|
|
3029
|
+
process_id: this.process_id,
|
|
3044
3030
|
workspace_id: this.workspace_id,
|
|
3045
3031
|
type: input.mimeType,
|
|
3046
3032
|
event: data.event,
|
|
@@ -3091,18 +3077,19 @@ class ProcessorService {
|
|
|
3091
3077
|
return value;
|
|
3092
3078
|
}
|
|
3093
3079
|
}
|
|
3094
|
-
async writeResult(status) {
|
|
3080
|
+
async writeResult(status, retryable = true) {
|
|
3095
3081
|
this.processorApiService.saveResult({
|
|
3096
3082
|
status,
|
|
3097
3083
|
component: this.component,
|
|
3098
3084
|
start: this.start,
|
|
3099
3085
|
end: this.end,
|
|
3100
|
-
|
|
3086
|
+
retryable,
|
|
3087
|
+
result: (0, processor_utils_1.encrypt)(JSON.stringify(this.processingOutput), this.productBuilderService.fetchProduct().private_key),
|
|
3101
3088
|
process_id: this.process_id,
|
|
3102
3089
|
feature_id: this.feature ? this.feature._id : null,
|
|
3103
3090
|
product_id: this.productId,
|
|
3104
3091
|
env: this.processEnv.slug,
|
|
3105
|
-
input: this.input,
|
|
3092
|
+
input: (0, processor_utils_1.encrypt)(JSON.stringify(this.input), this.productBuilderService.fetchProduct().private_key),
|
|
3106
3093
|
}, this.getUserAccess());
|
|
3107
3094
|
}
|
|
3108
3095
|
async validateActionDataMappingInput(input, type) {
|
|
@@ -3155,7 +3142,6 @@ class ProcessorService {
|
|
|
3155
3142
|
if (!productEnv.active) {
|
|
3156
3143
|
throw new Error(`Environment ${env} is not active`);
|
|
3157
3144
|
}
|
|
3158
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Execute action initiated', status: types_1.LogEventStatus.PROCESSING }));
|
|
3159
3145
|
const result = await this.runAction({
|
|
3160
3146
|
type: types_1.FeatureEventTypes.ACTION,
|
|
3161
3147
|
event,
|
|
@@ -3210,7 +3196,6 @@ class ProcessorService {
|
|
|
3210
3196
|
if (!productEnv.active) {
|
|
3211
3197
|
throw new Error(`Environment ${env} is not active`);
|
|
3212
3198
|
}
|
|
3213
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Execute database action', data: { action: (0, processor_utils_1.anonymizeObject)(action) }, status: types_1.LogEventStatus.PROCESSING }));
|
|
3214
3199
|
const payload = {
|
|
3215
3200
|
type: types_1.FeatureEventTypes.DB_ACTION,
|
|
3216
3201
|
event,
|
|
@@ -3265,7 +3250,6 @@ class ProcessorService {
|
|
|
3265
3250
|
if (!productEnv.active) {
|
|
3266
3251
|
throw new Error(`Environment ${env} is not active`);
|
|
3267
3252
|
}
|
|
3268
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Send notification - initiated', data: { action: (0, processor_utils_1.anonymizeObject)(action) }, status: types_1.LogEventStatus.PROCESSING }));
|
|
3269
3253
|
const payload = {
|
|
3270
3254
|
type: types_1.FeatureEventTypes.NOTIFICATION,
|
|
3271
3255
|
event,
|
|
@@ -3309,7 +3293,7 @@ class ProcessorService {
|
|
|
3309
3293
|
public_key: this.public_key,
|
|
3310
3294
|
};
|
|
3311
3295
|
}
|
|
3312
|
-
async addToCache(payload) {
|
|
3296
|
+
async addToCache(payload, additional_logs) {
|
|
3313
3297
|
if (!this.redisClient) {
|
|
3314
3298
|
throw 'redis client not setup';
|
|
3315
3299
|
}
|
|
@@ -3325,13 +3309,15 @@ class ProcessorService {
|
|
|
3325
3309
|
product_tag,
|
|
3326
3310
|
component_tag,
|
|
3327
3311
|
component_type }), this.getUserAccess());
|
|
3312
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Renewing expired Cache Value', data: { key }, successful_execution: true, status: types_1.LogEventStatus.SUCCESS, cache_tag }));
|
|
3328
3313
|
await this.redisClient.hSet(key, 'data', encryptedData);
|
|
3329
3314
|
await this.redisClient.hSet(key, 'lastUpdated', timestamp);
|
|
3330
3315
|
}
|
|
3331
|
-
async fetchFromCache(payload) {
|
|
3316
|
+
async fetchFromCache(payload, additional_logs) {
|
|
3332
3317
|
var _a;
|
|
3333
3318
|
const { input, privateKey, cache_tag, expiry } = payload;
|
|
3334
3319
|
const key = `${cache_tag}-${CryptoJS.SHA512(input)}`;
|
|
3320
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Fetching from Cache', data: { key }, status: types_1.LogEventStatus.PROCESSING, cache_tag }));
|
|
3335
3321
|
if (!this.redisClient) {
|
|
3336
3322
|
return null;
|
|
3337
3323
|
}
|
|
@@ -3339,8 +3325,10 @@ class ProcessorService {
|
|
|
3339
3325
|
if (!record || !record.data || !record.lastUpdated) {
|
|
3340
3326
|
const checkRemote = await this.processorApiService.fetchRemoteCacheByKey(key, this.getUserAccess());
|
|
3341
3327
|
if (!checkRemote) {
|
|
3328
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Remote Cache Not Found', data: { key }, successful_execution: true, status: types_1.LogEventStatus.FAIL, cache_tag }));
|
|
3342
3329
|
return null;
|
|
3343
3330
|
}
|
|
3331
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Remote Cache Found', data: { key }, successful_execution: true, status: types_1.LogEventStatus.SUCCESS, cache_tag }));
|
|
3344
3332
|
record = { data: checkRemote.value, expiresAt: (_a = checkRemote.expiry) === null || _a === void 0 ? void 0 : _a.getTime().toString() };
|
|
3345
3333
|
}
|
|
3346
3334
|
if (record.lastUpdated) {
|
|
@@ -3348,11 +3336,13 @@ class ProcessorService {
|
|
|
3348
3336
|
if (expiry) {
|
|
3349
3337
|
const expiryTime = lastUpdated + expiry;
|
|
3350
3338
|
if (Date.now() > expiryTime) {
|
|
3339
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Deleting expired Cache Value', data: { key }, successful_execution: true, status: types_1.LogEventStatus.SUCCESS, cache_tag }));
|
|
3351
3340
|
await this.redisClient.del(key);
|
|
3352
3341
|
return null;
|
|
3353
3342
|
}
|
|
3354
3343
|
}
|
|
3355
3344
|
}
|
|
3345
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Cache Found', data: { key }, successful_execution: true, status: types_1.LogEventStatus.SUCCESS, cache_tag }));
|
|
3356
3346
|
return (0, processor_utils_1.decrypt)(record.data, privateKey);
|
|
3357
3347
|
}
|
|
3358
3348
|
}
|