@ductape/sdk 0.0.3-beta1 → 0.0.3-beta10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/services/appApi.service.js +2 -2
- package/dist/api/services/appApi.service.js.map +1 -1
- package/dist/api/services/processorApi.service.d.ts +3 -1
- package/dist/api/services/processorApi.service.js +9 -0
- package/dist/api/services/processorApi.service.js.map +1 -1
- package/dist/api/services/productsApi.service.js +1 -1
- package/dist/api/services/productsApi.service.js.map +1 -1
- package/dist/api/urls.d.ts +1 -0
- package/dist/api/urls.js +2 -1
- package/dist/api/urls.js.map +1 -1
- package/dist/apps/services/app.service.d.ts +3 -3
- package/dist/apps/services/app.service.js +84 -50
- package/dist/apps/services/app.service.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appAction.validator.d.ts +2 -2
- package/dist/apps/validators/joi-validators/update.appAction.validator.js +11 -11
- package/dist/apps/validators/joi-validators/update.appAction.validator.js.map +1 -1
- package/dist/imports/repos/postmanV21.repo.js +1 -1
- package/dist/imports/repos/postmanV21.repo.js.map +1 -1
- package/dist/index.d.ts +14 -2
- package/dist/index.js +47 -4
- package/dist/index.js.map +1 -1
- package/dist/inputs/validators/inputs.validator.parse.js +1 -0
- package/dist/inputs/validators/inputs.validator.parse.js.map +1 -1
- package/dist/logs/logs.service.js +1 -1
- 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/services/fallback.service.d.ts +2 -2
- package/dist/processor/services/fallback.service.js +11 -10
- package/dist/processor/services/fallback.service.js.map +1 -1
- package/dist/processor/services/processor.service.d.ts +4 -1
- package/dist/processor/services/processor.service.js +86 -19
- package/dist/processor/services/processor.service.js.map +1 -1
- package/dist/processor/services/quota.service.d.ts +4 -13
- package/dist/processor/services/quota.service.js +11 -2
- package/dist/processor/services/quota.service.js.map +1 -1
- package/dist/processor/utils/storage.util.js +1 -0
- package/dist/processor/utils/storage.util.js.map +1 -1
- package/dist/products/services/products.service.d.ts +40 -32
- package/dist/products/services/products.service.js +236 -141
- package/dist/products/services/products.service.js.map +1 -1
- package/dist/products/utils/string.utils.js +1 -0
- package/dist/products/utils/string.utils.js.map +1 -1
- package/dist/products/validators/index.d.ts +3 -1
- package/dist/products/validators/index.js +5 -1
- package/dist/products/validators/index.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js +25 -18
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productFeature.validator.js +2 -0
- package/dist/products/validators/joi-validators/create.productFeature.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productNotificationMessage.validator.js +1 -1
- package/dist/products/validators/joi-validators/create.productQuota.validator.js +2 -0
- package/dist/products/validators/joi-validators/create.productQuota.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.userAuth.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/create.userAuth.validator.js +47 -0
- package/dist/products/validators/joi-validators/create.userAuth.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/update.dataValue.validator.d.ts +1 -1
- package/dist/products/validators/joi-validators/update.dataValue.validator.js +3 -2
- package/dist/products/validators/joi-validators/update.dataValue.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productFeature.validator.js +2 -0
- package/dist/products/validators/joi-validators/update.productFeature.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productNotificationMessage.validator.js +2 -1
- package/dist/products/validators/joi-validators/update.productNotificationMessage.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productQuota.validator.js +8 -7
- package/dist/products/validators/joi-validators/update.productQuota.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.userAuth.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/update.userAuth.validator.js +47 -0
- package/dist/products/validators/joi-validators/update.userAuth.validator.js.map +1 -0
- package/dist/test/test.logs.js +6 -6
- package/dist/test/test.logs.js.map +1 -1
- package/dist/types/appBuilder.types.d.ts +16 -0
- package/dist/types/enums.d.ts +5 -0
- package/dist/types/enums.js +7 -1
- package/dist/types/enums.js.map +1 -1
- package/dist/types/inputs.types.d.ts +2 -0
- package/dist/types/inputs.types.js.map +1 -1
- package/dist/types/processor.types.d.ts +15 -0
- package/dist/types/processor.types.js.map +1 -1
- package/dist/types/productsBuilder.types.d.ts +14 -1
- package/dist/types/productsBuilder.types.js.map +1 -1
- package/package.json +2 -1
|
@@ -48,6 +48,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
48
48
|
};
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
50
|
const products_service_1 = __importDefault(require("../../products/services/products.service"));
|
|
51
|
+
const JWT = __importStar(require("jsonwebtoken"));
|
|
51
52
|
const types_1 = require("../../types");
|
|
52
53
|
const logs_service_1 = __importDefault(require("../../logs/logs.service"));
|
|
53
54
|
const inputs_service_1 = __importDefault(require("../../inputs/inputs.service"));
|
|
@@ -67,6 +68,9 @@ const mongo_repo_1 = require("../repos/mongo.repo");
|
|
|
67
68
|
const postgres_repo_1 = require("../repos/postgres.repo");
|
|
68
69
|
const storage_util_1 = require("../utils/storage.util");
|
|
69
70
|
const sms_repo_1 = require("../repos/sms.repo");
|
|
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");
|
|
70
74
|
async function loadBrokerService() {
|
|
71
75
|
if (typeof window === 'undefined') {
|
|
72
76
|
const { createBrokerService } = await Promise.resolve().then(() => __importStar(require('./messagebrokers')));
|
|
@@ -100,6 +104,39 @@ class ProcessorService {
|
|
|
100
104
|
if (redis_client) {
|
|
101
105
|
this.redisClient = redis_client;
|
|
102
106
|
}
|
|
107
|
+
this.productApi = new productsApi_service_1.ProductsApiService(env_type);
|
|
108
|
+
}
|
|
109
|
+
async generateSession(payload) {
|
|
110
|
+
try {
|
|
111
|
+
const { product: product_tag, env: slug, tag, data } = payload;
|
|
112
|
+
const input = await this.inputService.parseJson({
|
|
113
|
+
data,
|
|
114
|
+
expected: types_1.ExpectedValues.PARSEINPUT,
|
|
115
|
+
});
|
|
116
|
+
await this.productBuilderService.initializeProductByTag(product_tag);
|
|
117
|
+
// const product = this.productBuilderService.fetchProduct();
|
|
118
|
+
const session = this.productBuilderService.fetchSession(tag);
|
|
119
|
+
if (!session) {
|
|
120
|
+
throw new Error(`Session with tag ${tag} does not exist`);
|
|
121
|
+
}
|
|
122
|
+
const env = this.productBuilderService.fetchEnv(slug);
|
|
123
|
+
if (!env) {
|
|
124
|
+
throw new Error(`Env with slug ${slug} does not exist`);
|
|
125
|
+
}
|
|
126
|
+
await this.inputService.validateInput(input, session.schema_data);
|
|
127
|
+
const expiry = (0, processor_utils_1.calculateExpiry)(session.expiry, session.period);
|
|
128
|
+
const token = JWT.sign(JSON.stringify(Object.assign({ type: "token" }, data)), this.productBuilderService.fetchProduct().private_key, { expiresIn: expiry });
|
|
129
|
+
const refreshToken = (0, processor_utils_1.encrypt)(JSON.stringify(data), this.productBuilderService.fetchProduct().private_key);
|
|
130
|
+
// WRITE REFRESH TOKEN TO DATABASE... TO INVALIDATE DELETE FROM DATABASE
|
|
131
|
+
await this.processorApiService.createRefreshToken({ product_tag, env: slug, refreshToken }, this.getUserAccess());
|
|
132
|
+
return {
|
|
133
|
+
token,
|
|
134
|
+
refreshToken,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
catch (e) {
|
|
138
|
+
throw e;
|
|
139
|
+
}
|
|
103
140
|
}
|
|
104
141
|
async registerWebhook(data) {
|
|
105
142
|
const { product: product_tag, access_tag, webhook_tag, envs } = data;
|
|
@@ -266,8 +303,21 @@ class ProcessorService {
|
|
|
266
303
|
throw e;
|
|
267
304
|
}
|
|
268
305
|
}
|
|
269
|
-
async runQuotaOptions(options, additional_logs) {
|
|
270
|
-
|
|
306
|
+
async runQuotaOptions(options, additional_logs) {
|
|
307
|
+
const quotaManager = new quota_service_1.default(options);
|
|
308
|
+
const getNextProvider = quotaManager.getNextProvider();
|
|
309
|
+
await this.processEvent({
|
|
310
|
+
type: getNextProvider.type,
|
|
311
|
+
event: getNextProvider.event,
|
|
312
|
+
input: getNextProvider.input,
|
|
313
|
+
retries: getNextProvider.retries,
|
|
314
|
+
allow_fail: false
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
async runFallbackOptions(options, additional_logs) {
|
|
318
|
+
const fallbackManager = new fallback_service_1.default(options);
|
|
319
|
+
await fallbackManager.executeActionWithFallback(this.processEvent);
|
|
320
|
+
}
|
|
271
321
|
async processFallback(data) {
|
|
272
322
|
this.start = Date.now();
|
|
273
323
|
this.input = data;
|
|
@@ -322,12 +372,13 @@ class ProcessorService {
|
|
|
322
372
|
additional_logs = {
|
|
323
373
|
name: 'Process feature',
|
|
324
374
|
type: types_1.LogEventTypes.FEATURE,
|
|
325
|
-
parent_tag: feature_tag,
|
|
326
375
|
};
|
|
376
|
+
console.log(additional_logs);
|
|
327
377
|
await this.intializeProduct(additional_logs);
|
|
328
378
|
this.component = types_1.LogEventTypes.FEATURE;
|
|
329
379
|
const process_id = this.process_id || (0, processor_utils_1.generateObjectId)();
|
|
330
380
|
this.process_id = process_id;
|
|
381
|
+
this.feature = this.fetchFeature(feature_tag, additional_logs);
|
|
331
382
|
this.baseLogs = {
|
|
332
383
|
product_tag: this.productTag,
|
|
333
384
|
product_id: this.productId,
|
|
@@ -336,8 +387,9 @@ class ProcessorService {
|
|
|
336
387
|
type: types_1.LogEventTypes.FEATURE,
|
|
337
388
|
process_id,
|
|
338
389
|
data: input,
|
|
390
|
+
feature_tag: feature_tag,
|
|
391
|
+
feature_id: this.feature._id,
|
|
339
392
|
};
|
|
340
|
-
this.feature = this.fetchFeature(feature_tag, additional_logs);
|
|
341
393
|
this.logService.setFeatureId(this.feature._id);
|
|
342
394
|
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 }));
|
|
343
395
|
this.processEnv = this.fetchEnv(env, additional_logs);
|
|
@@ -394,6 +446,7 @@ class ProcessorService {
|
|
|
394
446
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Product initialize - success', data: { product_id: this.productId }, status: types_1.LogEventStatus.SUCCESS }));
|
|
395
447
|
}
|
|
396
448
|
catch (e) {
|
|
449
|
+
console.log(e);
|
|
397
450
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Product initialize - failed', data: e, status: types_1.LogEventStatus.FAIL }));
|
|
398
451
|
throw e;
|
|
399
452
|
}
|
|
@@ -1625,11 +1678,13 @@ class ProcessorService {
|
|
|
1625
1678
|
}
|
|
1626
1679
|
async runAction(event, additional_logs, returnValue = false) {
|
|
1627
1680
|
try {
|
|
1681
|
+
console.log("RUNNING ACTION!!!!!");
|
|
1628
1682
|
const { event: action_tag, app: access_tag, condition, cache: cache_tag } = event;
|
|
1629
1683
|
let indexes = [];
|
|
1630
1684
|
if (condition &&
|
|
1631
1685
|
condition.type === types_1.Conditions.CHECK &&
|
|
1632
1686
|
(await this.processConditionalCheck(event, additional_logs))) {
|
|
1687
|
+
console.log("RUNNING ACTION SKIPPED!!!!!");
|
|
1633
1688
|
// if it fails, it would add to skipped queue
|
|
1634
1689
|
return;
|
|
1635
1690
|
}
|
|
@@ -1724,8 +1779,8 @@ class ProcessorService {
|
|
|
1724
1779
|
}
|
|
1725
1780
|
}
|
|
1726
1781
|
catch (e) {
|
|
1727
|
-
|
|
1728
|
-
|
|
1782
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { failed_execution: true, message: 'Run Action - failed', data: { e }, status: types_1.LogEventStatus.FAIL }));
|
|
1783
|
+
throw e;
|
|
1729
1784
|
}
|
|
1730
1785
|
}
|
|
1731
1786
|
async processRequest(payload, event, retries, additional_logs, returnValue = false) {
|
|
@@ -1948,7 +2003,7 @@ class ProcessorService {
|
|
|
1948
2003
|
};
|
|
1949
2004
|
try {
|
|
1950
2005
|
this.validateActionDataMappingInput(input, types_1.FeatureEventTypes.STORAGE);
|
|
1951
|
-
this.input =
|
|
2006
|
+
this.input = input;
|
|
1952
2007
|
this.start = Date.now();
|
|
1953
2008
|
this.component = types_1.LogEventTypes.STORAGE;
|
|
1954
2009
|
// clone
|
|
@@ -2166,6 +2221,9 @@ class ProcessorService {
|
|
|
2166
2221
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Fetching notification details', data: { notification }, status: types_1.LogEventStatus.PROCESSING }));
|
|
2167
2222
|
const notificationEvent = this.productBuilderService.fetchNotification(event.split(":")[0]);
|
|
2168
2223
|
const message = this.productBuilderService.fetchNotificationMessage(event);
|
|
2224
|
+
if (!message) {
|
|
2225
|
+
throw new Error(`Message ${event} not found`);
|
|
2226
|
+
}
|
|
2169
2227
|
const { envs } = notificationEvent;
|
|
2170
2228
|
const { push_notifications: notifications, emails, callbacks, sms: smses } = envs.find((data) => data.slug === notification.env.slug);
|
|
2171
2229
|
const { push_notification: push, email, callback, sms } = message;
|
|
@@ -2281,8 +2339,9 @@ class ProcessorService {
|
|
|
2281
2339
|
}
|
|
2282
2340
|
catch (e) {
|
|
2283
2341
|
console.log(e);
|
|
2284
|
-
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { failed_execution: true, message: 'Attempt notification - failed', data: { e }, status: types_1.LogEventStatus.FAIL }));
|
|
2285
|
-
this.logService.publish();
|
|
2342
|
+
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 }));
|
|
2343
|
+
//this.logService.publish();
|
|
2344
|
+
throw e;
|
|
2286
2345
|
}
|
|
2287
2346
|
}
|
|
2288
2347
|
async runMigration(product_tag, tag, env, type) {
|
|
@@ -2492,10 +2551,10 @@ class ProcessorService {
|
|
|
2492
2551
|
}
|
|
2493
2552
|
}
|
|
2494
2553
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Store file - initiated', data: {}, status: types_1.LogEventStatus.PROCESSING }));
|
|
2495
|
-
|
|
2496
|
-
input.
|
|
2497
|
-
input.
|
|
2498
|
-
input.
|
|
2554
|
+
input.buffer = input.buffer ? await this.generateStringValues(input.buffer, '', additional_logs, []) : undefined;
|
|
2555
|
+
input.fileName = input.fileName ? await this.generateStringValues(input.fileName, '', additional_logs, []) : undefined;
|
|
2556
|
+
input.mimeType = input.mimeType ? await this.generateStringValues(input.mimeType, '', additional_logs, []) : undefined;
|
|
2557
|
+
console.log("CHINYERE", input.buffer, input.fileName);
|
|
2499
2558
|
result = await this.processStorageRequest(data, input, storageEnv, additional_logs);
|
|
2500
2559
|
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 }));
|
|
2501
2560
|
if (cache_tag && this.redisClient) {
|
|
@@ -2555,12 +2614,14 @@ class ProcessorService {
|
|
|
2555
2614
|
data: input.data,
|
|
2556
2615
|
expected: types_1.ExpectedValues.PARSEINPUT,
|
|
2557
2616
|
}));
|
|
2558
|
-
const filterValidationPayload = (await this.inputService.parseJson({
|
|
2559
|
-
data: input.filter,
|
|
2560
|
-
expected: types_1.ExpectedValues.PARSEINPUT,
|
|
2561
|
-
}));
|
|
2562
2617
|
this.inputService.validateInput(dataValidationPayload, databaseAction.data);
|
|
2563
|
-
|
|
2618
|
+
if (input.filter) {
|
|
2619
|
+
const filterValidationPayload = (await this.inputService.parseJson({
|
|
2620
|
+
data: input.filter,
|
|
2621
|
+
expected: types_1.ExpectedValues.PARSEINPUT,
|
|
2622
|
+
}));
|
|
2623
|
+
this.inputService.validateInput(filterValidationPayload, databaseAction.filterData);
|
|
2624
|
+
}
|
|
2564
2625
|
}
|
|
2565
2626
|
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 }));
|
|
2566
2627
|
if (database.type === types_1.DatabaseTypes.MONGODB) {
|
|
@@ -2595,6 +2656,8 @@ class ProcessorService {
|
|
|
2595
2656
|
if (!MongoDBHandler) {
|
|
2596
2657
|
throw new Error(`Running in browser, mongo handler not loaded.`);
|
|
2597
2658
|
}
|
|
2659
|
+
console.log("PRIVATE KEY!!!", this.productBuilderService.fetchProduct().private_key);
|
|
2660
|
+
console.log("AMAZONS", (0, processor_utils_1.decrypt)(databaseEnv.connection_url, this.productBuilderService.fetchProduct().private_key));
|
|
2598
2661
|
const mongoHandler = new MongoDBHandler((0, processor_utils_1.decrypt)(databaseEnv.connection_url, this.productBuilderService.fetchProduct().private_key));
|
|
2599
2662
|
if (databaseAction.type === types_1.DatabaseActionTypes.UPDATE) {
|
|
2600
2663
|
const filterTemplate = typeof databaseAction.filterTemplate === 'string'
|
|
@@ -2640,7 +2703,9 @@ class ProcessorService {
|
|
|
2640
2703
|
return result;
|
|
2641
2704
|
}
|
|
2642
2705
|
catch (e) {
|
|
2643
|
-
|
|
2706
|
+
console.log(e);
|
|
2707
|
+
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { failed_execution: true, message: 'Attempt database action - failed', data: { e: e.toString() }, status: types_1.LogEventStatus.FAIL }));
|
|
2708
|
+
throw e;
|
|
2644
2709
|
}
|
|
2645
2710
|
}
|
|
2646
2711
|
async runBrokerSubscribe(data, additional_logs = {}) {
|
|
@@ -2885,6 +2950,7 @@ class ProcessorService {
|
|
|
2885
2950
|
retries: retries || 0,
|
|
2886
2951
|
allow_fail: false,
|
|
2887
2952
|
}, additional_logs, true);
|
|
2953
|
+
console.log("RESULT ===>>>>", result);
|
|
2888
2954
|
this.end = Date.now();
|
|
2889
2955
|
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 }));
|
|
2890
2956
|
this.writeResult(types_1.LogEventStatus.SUCCESS);
|
|
@@ -2892,6 +2958,7 @@ class ProcessorService {
|
|
|
2892
2958
|
return result;
|
|
2893
2959
|
}
|
|
2894
2960
|
catch (e) {
|
|
2961
|
+
console.log(e);
|
|
2895
2962
|
this.logService.add(Object.assign(Object.assign(Object.assign({}, this.baseLogs), additional_logs), { message: 'Execute action - failed', data: { e }, status: types_1.LogEventStatus.FAIL }));
|
|
2896
2963
|
this.end = Date.now();
|
|
2897
2964
|
this.logService.publish();
|