@konplit-services/common 1.7.4 → 1.8.0
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/build/app.configs.d.ts
CHANGED
|
@@ -310,6 +310,16 @@ declare class AppConfigs {
|
|
|
310
310
|
secretKey: string;
|
|
311
311
|
sender: string;
|
|
312
312
|
};
|
|
313
|
+
ebulk: {
|
|
314
|
+
apiKey: string;
|
|
315
|
+
sender: string;
|
|
316
|
+
username: string;
|
|
317
|
+
};
|
|
318
|
+
};
|
|
319
|
+
getEbulkSMSKey(): {
|
|
320
|
+
apiKey: string;
|
|
321
|
+
sender: string;
|
|
322
|
+
username: string;
|
|
313
323
|
};
|
|
314
324
|
getTermiiSMSKey(): {
|
|
315
325
|
apiKey: string;
|
package/build/app.configs.js
CHANGED
|
@@ -457,7 +457,24 @@ class AppConfigs {
|
|
|
457
457
|
}
|
|
458
458
|
return {
|
|
459
459
|
vendor: this.env.SMS_VENDOR,
|
|
460
|
-
termii: this.getTermiiSMSKey()
|
|
460
|
+
termii: this.getTermiiSMSKey(),
|
|
461
|
+
ebulk: this.getEbulkSMSKey()
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
getEbulkSMSKey() {
|
|
465
|
+
if (!this.env.EBULK_API_KEY) {
|
|
466
|
+
throw new Error("EBULK_API_KEY is required");
|
|
467
|
+
}
|
|
468
|
+
if (!this.env.EBULK_SENDER_ID) {
|
|
469
|
+
throw new Error("EBULK_SENDER_ID is required");
|
|
470
|
+
}
|
|
471
|
+
if (!this.env.EBULK_USERNAME) {
|
|
472
|
+
throw new Error("EBULK_USERNAME is required");
|
|
473
|
+
}
|
|
474
|
+
return {
|
|
475
|
+
apiKey: this.env.EBULK_API_KEY,
|
|
476
|
+
sender: this.env.EBULK_SENDER_ID,
|
|
477
|
+
username: this.env.EBULK_USERNAME,
|
|
461
478
|
};
|
|
462
479
|
}
|
|
463
480
|
getTermiiSMSKey() {
|
|
@@ -30,6 +30,9 @@ export interface FilterOptions {
|
|
|
30
30
|
merchantId?: string;
|
|
31
31
|
accountId?: string;
|
|
32
32
|
dateField?: string;
|
|
33
|
+
amountField?: string;
|
|
34
|
+
min_amount?: string;
|
|
35
|
+
max_amount?: string;
|
|
33
36
|
[key: string]: any;
|
|
34
37
|
}
|
|
35
38
|
export declare const generateQueryObject: (filters: FilterOptions, searchesFieldNames?: string[], select?: string | Record<string, any>, populate?: (string | PopulateOptions)[]) => {
|
|
@@ -50,4 +53,6 @@ export interface DefaultFilterOptions {
|
|
|
50
53
|
order?: "asc" | "desc";
|
|
51
54
|
from?: string;
|
|
52
55
|
to?: string;
|
|
56
|
+
min_amount?: string;
|
|
57
|
+
max_amount?: string;
|
|
53
58
|
}
|
|
@@ -55,7 +55,7 @@ function paginate(model_1) {
|
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
const generateQueryObject = (filters, searchesFieldNames = [], select = "", populate = []) => {
|
|
58
|
-
const { status, limit, page, sort_by = "createdAt", order = "desc", merchantId, accountId, dateField, } = filters;
|
|
58
|
+
const { status, limit, page, sort_by = "createdAt", order = "desc", merchantId, accountId, dateField, amountField, } = filters;
|
|
59
59
|
const excludes = [
|
|
60
60
|
"status",
|
|
61
61
|
"from",
|
|
@@ -67,7 +67,10 @@ const generateQueryObject = (filters, searchesFieldNames = [], select = "", popu
|
|
|
67
67
|
"accountId",
|
|
68
68
|
"merchantId",
|
|
69
69
|
"order",
|
|
70
|
-
"dateField"
|
|
70
|
+
"dateField",
|
|
71
|
+
"amountField",
|
|
72
|
+
"min_amount",
|
|
73
|
+
"max_amount",
|
|
71
74
|
];
|
|
72
75
|
const query = {};
|
|
73
76
|
let sort = {};
|
|
@@ -110,6 +113,17 @@ const generateQueryObject = (filters, searchesFieldNames = [], select = "", popu
|
|
|
110
113
|
$gte: (0, date_processing_1.convertDateToUTC)(filters.from),
|
|
111
114
|
};
|
|
112
115
|
}
|
|
116
|
+
// for dynamic amount range filter
|
|
117
|
+
const fieldAmountFilter = amountField || "amount";
|
|
118
|
+
const min = Number(filters.min_amount);
|
|
119
|
+
const max = Number(filters.max_amount);
|
|
120
|
+
if (!isNaN(min) || !isNaN(max)) {
|
|
121
|
+
query[fieldAmountFilter] = {};
|
|
122
|
+
if (!isNaN(min))
|
|
123
|
+
query[fieldAmountFilter]["$gte"] = min;
|
|
124
|
+
if (!isNaN(max))
|
|
125
|
+
query[fieldAmountFilter]["$lte"] = max;
|
|
126
|
+
}
|
|
113
127
|
if (filters.sort_by && filters.order) {
|
|
114
128
|
const newSory = {
|
|
115
129
|
[sort_by]: order === "asc" ? "asc" : "desc",
|