drapcode-utility 1.1.9 → 1.2.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/encryption/KMS.d.ts +0 -5
- package/build/encryption/KMS.js +5 -35
- package/build/encryption/crypt.js +2 -2
- package/build/encryption/file.js +4 -4
- package/build/encryption/index.d.ts +2 -1
- package/build/encryption/index.js +47 -33
- package/build/encryption/model.d.ts +2 -2
- package/build/index.js +5 -1
- package/build/middlewares/error-logger.js +6 -6
- package/build/middlewares/interceptor-logger-new.js +6 -6
- package/build/middlewares/interceptor-logger.js +3 -3
- package/build/middlewares/redis/request-log.js +4 -4
- package/build/utils/check-error.js +12 -8
- package/build/utils/date-util.js +3 -3
- package/build/utils/query-parser.js +57 -53
- package/build/utils/query-paser-new.js +52 -48
- package/build/utils/s3-util.d.ts +4 -0
- package/build/utils/s3-util.js +45 -24
- package/build/utils/util.d.ts +1 -1
- package/build/utils/util.js +11 -11
- package/build/utils/uuid-generator.js +2 -2
- package/package.json +1 -1
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -35,10 +35,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
39
|
-
for (var i = 0,
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
+
if (ar || !(i in from)) {
|
|
41
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
+
ar[i] = from[i];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
42
46
|
};
|
|
43
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
48
|
exports.queryParserNew = void 0;
|
|
@@ -81,11 +85,11 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
|
|
|
81
85
|
if (searchQueryTypeObj[key]) {
|
|
82
86
|
aggregateQuery.push({
|
|
83
87
|
$addFields: (_b = {},
|
|
84
|
-
_b["_"
|
|
88
|
+
_b["_".concat(key)] = { $toString: "$".concat(key) },
|
|
85
89
|
_b),
|
|
86
90
|
});
|
|
87
91
|
searchQueryObj_1.push((_c = {},
|
|
88
|
-
_c["_"
|
|
92
|
+
_c["_".concat(key)] = {
|
|
89
93
|
$regex: value,
|
|
90
94
|
$options: "i",
|
|
91
95
|
},
|
|
@@ -119,11 +123,11 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
|
|
|
119
123
|
// if input is string and db field type is boolean
|
|
120
124
|
aggregateQuery.push({
|
|
121
125
|
$addFields: (_b = {},
|
|
122
|
-
_b["_"
|
|
126
|
+
_b["_".concat(key)] = "$".concat(key),
|
|
123
127
|
_b),
|
|
124
128
|
});
|
|
125
129
|
likeQuery_1.push((_c = {},
|
|
126
|
-
_c["_"
|
|
130
|
+
_c["_".concat(key)] = toBoolean(value),
|
|
127
131
|
_c));
|
|
128
132
|
}
|
|
129
133
|
else if ([
|
|
@@ -135,22 +139,22 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
|
|
|
135
139
|
// if input is string and db field type is array
|
|
136
140
|
aggregateQuery.push({
|
|
137
141
|
$addFields: (_d = {},
|
|
138
|
-
_d["_"
|
|
142
|
+
_d["_".concat(key)] = "$".concat(key),
|
|
139
143
|
_d),
|
|
140
144
|
});
|
|
141
145
|
likeQuery_1.push((_e = {},
|
|
142
|
-
_e["_"
|
|
146
|
+
_e["_".concat(key)] = { $all: [value] },
|
|
143
147
|
_e));
|
|
144
148
|
}
|
|
145
149
|
else if (searchQueryTypeObj[key] === "tel") {
|
|
146
150
|
// handling value when db field type is tel
|
|
147
151
|
aggregateQuery.push({
|
|
148
152
|
$addFields: (_f = {},
|
|
149
|
-
_f["_"
|
|
153
|
+
_f["_".concat(key)] = { $toString: "$".concat(key) },
|
|
150
154
|
_f),
|
|
151
155
|
});
|
|
152
156
|
likeQuery_1.push((_g = {},
|
|
153
|
-
_g["_"
|
|
157
|
+
_g["_".concat(key)] = {
|
|
154
158
|
$regex: value.startsWith("+") ? value.replace("+", "") : value,
|
|
155
159
|
$options: "i",
|
|
156
160
|
},
|
|
@@ -160,11 +164,11 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
|
|
|
160
164
|
// handling value when db field type is Double/Int
|
|
161
165
|
aggregateQuery.push({
|
|
162
166
|
$addFields: (_h = {},
|
|
163
|
-
_h["_"
|
|
167
|
+
_h["_".concat(key)] = { $toString: { $toLong: "$".concat(key) } },
|
|
164
168
|
_h),
|
|
165
169
|
});
|
|
166
170
|
likeQuery_1.push((_j = {},
|
|
167
|
-
_j["_"
|
|
171
|
+
_j["_".concat(key)] = {
|
|
168
172
|
$regex: value,
|
|
169
173
|
$options: "i",
|
|
170
174
|
},
|
|
@@ -175,11 +179,11 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
|
|
|
175
179
|
// converting db field to string first
|
|
176
180
|
aggregateQuery.push({
|
|
177
181
|
$addFields: (_k = {},
|
|
178
|
-
_k["_"
|
|
182
|
+
_k["_".concat(key)] = { $toString: "$".concat(key) },
|
|
179
183
|
_k),
|
|
180
184
|
});
|
|
181
185
|
likeQuery_1.push((_l = {},
|
|
182
|
-
_l["_"
|
|
186
|
+
_l["_".concat(key)] = {
|
|
183
187
|
$regex: value,
|
|
184
188
|
$options: "i",
|
|
185
189
|
},
|
|
@@ -214,7 +218,7 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
|
|
|
214
218
|
if (field.type === "belongsTo") {
|
|
215
219
|
aggregateQuery.push({
|
|
216
220
|
$lookup: {
|
|
217
|
-
from: ""
|
|
221
|
+
from: "".concat(collectionName_1),
|
|
218
222
|
localField: field.fieldName,
|
|
219
223
|
foreignField: "uuid",
|
|
220
224
|
as: field.fieldName,
|
|
@@ -229,8 +233,8 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
|
|
|
229
233
|
else {
|
|
230
234
|
aggregateQuery.push({
|
|
231
235
|
$lookup: {
|
|
232
|
-
from: ""
|
|
233
|
-
let: (_b = {}, _b[""
|
|
236
|
+
from: "".concat(collectionName_1),
|
|
237
|
+
let: (_b = {}, _b["".concat(field.fieldName)] = "$".concat(field.fieldName), _b),
|
|
234
238
|
pipeline: [
|
|
235
239
|
{
|
|
236
240
|
$match: {
|
|
@@ -240,10 +244,10 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
|
|
|
240
244
|
{
|
|
241
245
|
$cond: {
|
|
242
246
|
if: {
|
|
243
|
-
$in: ["$$"
|
|
247
|
+
$in: ["$$".concat(field.fieldName), ["", null]],
|
|
244
248
|
},
|
|
245
249
|
then: [],
|
|
246
|
-
else: { $ifNull: ["$$"
|
|
250
|
+
else: { $ifNull: ["$$".concat(field.fieldName), []] },
|
|
247
251
|
},
|
|
248
252
|
},
|
|
249
253
|
],
|
|
@@ -276,10 +280,10 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
|
|
|
276
280
|
aggregateQuery.push({
|
|
277
281
|
$lookup: {
|
|
278
282
|
from: "user",
|
|
279
|
-
let: (_c = {}, _c[""
|
|
283
|
+
let: (_c = {}, _c["".concat(field.fieldName)] = "$".concat(field.fieldName), _c),
|
|
280
284
|
pipeline: [
|
|
281
285
|
{
|
|
282
|
-
$match: { $expr: { $eq: ["$uuid", "$$"
|
|
286
|
+
$match: { $expr: { $eq: ["$uuid", "$$".concat(field.fieldName)] } },
|
|
283
287
|
},
|
|
284
288
|
{ $project: { _id: 0, password: 0 } },
|
|
285
289
|
],
|
|
@@ -292,7 +296,7 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
|
|
|
292
296
|
_b.label = 2;
|
|
293
297
|
case 2:
|
|
294
298
|
if (!["COUNT", "SUM", "AVG", "MIN", "MAX"].includes(finder) &&
|
|
295
|
-
!util_1.isEmpty(projection)) {
|
|
299
|
+
!(0, util_1.isEmpty)(projection)) {
|
|
296
300
|
aggregateQuery.push({ $project: projection });
|
|
297
301
|
}
|
|
298
302
|
if (finder === "COUNT") {
|
|
@@ -300,22 +304,22 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
|
|
|
300
304
|
}
|
|
301
305
|
else if (finder === "SUM") {
|
|
302
306
|
aggregateQuery.push({
|
|
303
|
-
$group: { _id: null, total: { $sum: "$"
|
|
307
|
+
$group: { _id: null, total: { $sum: "$".concat(aggregateFunctionField) } },
|
|
304
308
|
});
|
|
305
309
|
}
|
|
306
310
|
else if (finder === "AVG") {
|
|
307
311
|
aggregateQuery.push({
|
|
308
|
-
$group: { _id: null, average: { $avg: "$"
|
|
312
|
+
$group: { _id: null, average: { $avg: "$".concat(aggregateFunctionField) } },
|
|
309
313
|
});
|
|
310
314
|
}
|
|
311
315
|
else if (finder === "MIN") {
|
|
312
316
|
aggregateQuery.push({
|
|
313
|
-
$group: { _id: null, minimum: { $min: "$"
|
|
317
|
+
$group: { _id: null, minimum: { $min: "$".concat(aggregateFunctionField) } },
|
|
314
318
|
});
|
|
315
319
|
}
|
|
316
320
|
else if (finder === "MAX") {
|
|
317
321
|
aggregateQuery.push({
|
|
318
|
-
$group: { _id: null, maximum: { $max: "$"
|
|
322
|
+
$group: { _id: null, maximum: { $max: "$".concat(aggregateFunctionField) } },
|
|
319
323
|
});
|
|
320
324
|
}
|
|
321
325
|
offset = externalParams.offset || 0;
|
|
@@ -331,8 +335,8 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
|
|
|
331
335
|
if (finder != "COUNT" && limit) {
|
|
332
336
|
aggregateQuery.push({ $skip: +offset }, { $limit: +limit });
|
|
333
337
|
}
|
|
334
|
-
queryStr = ".aggregate("
|
|
335
|
-
str = "req.db.collection('"
|
|
338
|
+
queryStr = ".aggregate(".concat(JSON.stringify(aggregateQuery), ", { collation: { locale: \"en\" } })");
|
|
339
|
+
str = "req.db.collection('".concat(collectionName, "')").concat(queryStr);
|
|
336
340
|
str += ".toArray()";
|
|
337
341
|
return [2 /*return*/, str];
|
|
338
342
|
}
|
|
@@ -369,7 +373,7 @@ var mongoFilterQuery = function (query, externalParams, constants, currentUser)
|
|
|
369
373
|
filterQuery[lastKey].push(mongoQuery);
|
|
370
374
|
}
|
|
371
375
|
else {
|
|
372
|
-
filterQuery["$or"
|
|
376
|
+
filterQuery["$or".concat(index)] = [mongoQuery];
|
|
373
377
|
}
|
|
374
378
|
}
|
|
375
379
|
else if (queryObj.conjunctionType == "AND") {
|
|
@@ -378,11 +382,11 @@ var mongoFilterQuery = function (query, externalParams, constants, currentUser)
|
|
|
378
382
|
filterQuery[lastKey].push(mongoQuery);
|
|
379
383
|
}
|
|
380
384
|
else {
|
|
381
|
-
filterQuery["$and"
|
|
385
|
+
filterQuery["$and".concat(index)] = [mongoQuery];
|
|
382
386
|
}
|
|
383
387
|
}
|
|
384
388
|
else {
|
|
385
|
-
filterQuery["$or"
|
|
389
|
+
filterQuery["$or".concat(index)] = [mongoQuery];
|
|
386
390
|
}
|
|
387
391
|
});
|
|
388
392
|
console.log("==> *** filterQuery #2 :>> ", filterQuery);
|
|
@@ -398,13 +402,13 @@ var mongoSelectQuery = function (query) {
|
|
|
398
402
|
if (fieldsInclude[0] === "*") {
|
|
399
403
|
fieldsExclude.map(function (field) {
|
|
400
404
|
if (field)
|
|
401
|
-
return (projection[""
|
|
405
|
+
return (projection["".concat(field)] = 0);
|
|
402
406
|
});
|
|
403
407
|
}
|
|
404
408
|
else {
|
|
405
409
|
fieldsInclude.map(function (field) {
|
|
406
410
|
if (field)
|
|
407
|
-
return (projection[""
|
|
411
|
+
return (projection["".concat(field)] = 1);
|
|
408
412
|
});
|
|
409
413
|
}
|
|
410
414
|
return projection;
|
|
@@ -495,7 +499,7 @@ var queryToMongo = function (query, requiredExternal, externalParams, constants,
|
|
|
495
499
|
return _r = {},
|
|
496
500
|
_r[field] = {
|
|
497
501
|
$gte: fieldValue,
|
|
498
|
-
$lt: new Date(date_util_1.nextDayDate(fieldValue)),
|
|
502
|
+
$lt: new Date((0, date_util_1.nextDayDate)(fieldValue)),
|
|
499
503
|
},
|
|
500
504
|
_r;
|
|
501
505
|
}
|
|
@@ -573,11 +577,11 @@ var replaceExternalParams = function (query, requiredExternal, externalParams, c
|
|
|
573
577
|
if (key === drapcode_constant_1.BETWEEN) {
|
|
574
578
|
var _a = getMinMaxValue(value), startValue_1 = _a.startValue, endValue_1 = _a.endValue, isInteger = _a.isInteger;
|
|
575
579
|
if (requiredExternal) {
|
|
576
|
-
startValue_1 = ""
|
|
577
|
-
endValue_1 = ""
|
|
580
|
+
startValue_1 = "".concat(externalParams[startValue_1]);
|
|
581
|
+
endValue_1 = "".concat(externalParams[endValue_1]);
|
|
578
582
|
}
|
|
579
583
|
else {
|
|
580
|
-
if (__spreadArray([drapcode_constant_1.CURRENT_USER], drapcode_constant_1.DateConstant).some(function (cnst) {
|
|
584
|
+
if (__spreadArray([drapcode_constant_1.CURRENT_USER], drapcode_constant_1.DateConstant, true).some(function (cnst) {
|
|
581
585
|
return startValue_1.includes(cnst);
|
|
582
586
|
})) {
|
|
583
587
|
startValue_1 = getValueOfProjectConstant(startValue_1, currentUser);
|
|
@@ -585,7 +589,7 @@ var replaceExternalParams = function (query, requiredExternal, externalParams, c
|
|
|
585
589
|
else {
|
|
586
590
|
startValue_1 = constants.filter(function (constant) { return constant.name == startValue_1; });
|
|
587
591
|
}
|
|
588
|
-
if (__spreadArray([drapcode_constant_1.CURRENT_USER], drapcode_constant_1.DateConstant).some(function (cnst) { return endValue_1.includes(cnst); })) {
|
|
592
|
+
if (__spreadArray([drapcode_constant_1.CURRENT_USER], drapcode_constant_1.DateConstant, true).some(function (cnst) { return endValue_1.includes(cnst); })) {
|
|
589
593
|
endValue_1 = getValueOfProjectConstant(endValue_1, currentUser);
|
|
590
594
|
}
|
|
591
595
|
else {
|
|
@@ -602,10 +606,10 @@ var replaceExternalParams = function (query, requiredExternal, externalParams, c
|
|
|
602
606
|
//TODO: Need to figure out the params should be treated as number/string
|
|
603
607
|
if (!isNaN(startValue_1)) {
|
|
604
608
|
console.log("I am Number");
|
|
605
|
-
return startValue_1
|
|
609
|
+
return "".concat(startValue_1, "---").concat(endValue_1, "^");
|
|
606
610
|
}
|
|
607
611
|
else
|
|
608
|
-
return startValue_1
|
|
612
|
+
return "".concat(startValue_1, "---").concat(endValue_1);
|
|
609
613
|
}
|
|
610
614
|
if (value.includes(drapcode_constant_1.CURRENT_USER)) {
|
|
611
615
|
if (value === drapcode_constant_1.CURRENT_USER) {
|
|
@@ -643,11 +647,11 @@ var replaceExternalParams = function (query, requiredExternal, externalParams, c
|
|
|
643
647
|
//TODO: This is just to confirm if external then it should be get from externalParams
|
|
644
648
|
if (requiredExternal) {
|
|
645
649
|
//TODO: Value returns from here undefined.
|
|
646
|
-
var externalParamValue = externalParams[""
|
|
650
|
+
var externalParamValue = externalParams["".concat(value)];
|
|
647
651
|
if (!isNaN(externalParamValue)) {
|
|
648
652
|
return +externalParamValue;
|
|
649
653
|
}
|
|
650
|
-
return externalParams[""
|
|
654
|
+
return externalParams["".concat(value)];
|
|
651
655
|
}
|
|
652
656
|
var constantArr = constants.filter(function (constant) { return constant.name == value; });
|
|
653
657
|
return constantArr.length ? "" + constantArr[0].value : "";
|
|
@@ -674,9 +678,9 @@ var getValueOfProjectConstant = function (value, currentUser) {
|
|
|
674
678
|
if (value === drapcode_constant_1.CURRENT_USER)
|
|
675
679
|
return currentUser["uuid"];
|
|
676
680
|
if (value === drapcode_constant_1.CURRENT_DATE)
|
|
677
|
-
return date_util_1.createLoggerDateFormat();
|
|
681
|
+
return (0, date_util_1.createLoggerDateFormat)();
|
|
678
682
|
if ([drapcode_constant_1.CURRENT_TIME, drapcode_constant_1.CURRENT_DATE_TIME].includes(value))
|
|
679
|
-
return date_util_1.createLogsDateFormat();
|
|
683
|
+
return (0, date_util_1.createLogsDateFormat)();
|
|
680
684
|
if (drapcode_constant_1.DateTimeUnit.some(function (cnst) { return value.includes(cnst); }))
|
|
681
|
-
return date_util_1.getDateValue(value);
|
|
685
|
+
return (0, date_util_1.getDateValue)(value);
|
|
682
686
|
};
|
package/build/utils/s3-util.d.ts
CHANGED
|
@@ -13,6 +13,10 @@ interface S3Config {
|
|
|
13
13
|
}
|
|
14
14
|
export declare const createS3Client: (awsConfig: AWSConfig) => S3Client | null;
|
|
15
15
|
export declare const fileUploadToS3: (files: any, s3Client: S3Client, s3Config: S3Config, encryption: Encryption, options?: {}) => Promise<{
|
|
16
|
+
status: string;
|
|
17
|
+
data: string;
|
|
18
|
+
message: string;
|
|
19
|
+
} | {
|
|
16
20
|
originalname: any;
|
|
17
21
|
mimetype: any;
|
|
18
22
|
size: any;
|
package/build/utils/s3-util.js
CHANGED
|
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
26
|
function step(op) {
|
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
29
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
30
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
31
|
switch (op[0]) {
|
|
@@ -56,6 +56,7 @@ var fs_1 = __importDefault(require("fs"));
|
|
|
56
56
|
var mime_types_1 = __importDefault(require("mime-types"));
|
|
57
57
|
var lib_storage_1 = require("@aws-sdk/lib-storage");
|
|
58
58
|
var encryption_1 = require("../encryption");
|
|
59
|
+
var encryption_2 = require("../encryption");
|
|
59
60
|
var createS3Client = function (awsConfig) {
|
|
60
61
|
if (!awsConfig) {
|
|
61
62
|
return null;
|
|
@@ -74,45 +75,65 @@ exports.createS3Client = createS3Client;
|
|
|
74
75
|
var fileUploadToS3 = function (files, s3Client, s3Config, encryption, options) {
|
|
75
76
|
if (options === void 0) { options = {}; }
|
|
76
77
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
77
|
-
var fileOptions, s3Key, _a, _b, _i, index, file, fileObj, fileObj;
|
|
78
|
-
return __generator(this, function (
|
|
79
|
-
switch (
|
|
78
|
+
var awsConfig, encryptionType, dataKey, accessKeyId, secretAccessKey, region, config, plainTextData, fileOptions, s3Key, _a, _b, _c, _i, index, file, fileObj, fileObj;
|
|
79
|
+
return __generator(this, function (_d) {
|
|
80
|
+
switch (_d.label) {
|
|
80
81
|
case 0:
|
|
81
|
-
|
|
82
|
+
awsConfig = encryption.awsConfig, encryptionType = encryption.encryptionType, dataKey = encryption.dataKey;
|
|
83
|
+
if (!(encryptionType === "KMS")) return [3 /*break*/, 2];
|
|
84
|
+
accessKeyId = awsConfig.accessKeyId, secretAccessKey = awsConfig.secretAccessKey, region = awsConfig.region;
|
|
85
|
+
config = {
|
|
86
|
+
region: region,
|
|
87
|
+
accessKeyId: accessKeyId,
|
|
88
|
+
secretAccessKey: secretAccessKey,
|
|
89
|
+
};
|
|
90
|
+
return [4 /*yield*/, (0, encryption_2.processKMSDecryption)(config, dataKey, {})];
|
|
91
|
+
case 1:
|
|
92
|
+
plainTextData = _d.sent();
|
|
93
|
+
if (plainTextData.status === "FAILED") {
|
|
94
|
+
return [2 /*return*/, plainTextData];
|
|
95
|
+
}
|
|
96
|
+
encryption.dataKey = plainTextData.data;
|
|
97
|
+
_d.label = 2;
|
|
98
|
+
case 2:
|
|
99
|
+
if (!Array.isArray(files)) return [3 /*break*/, 7];
|
|
82
100
|
console.log("I have multiple file");
|
|
83
101
|
fileOptions = [];
|
|
84
102
|
s3Key = s3Config.key;
|
|
85
|
-
_a =
|
|
86
|
-
|
|
87
|
-
|
|
103
|
+
_a = files;
|
|
104
|
+
_b = [];
|
|
105
|
+
for (_c in _a)
|
|
106
|
+
_b.push(_c);
|
|
88
107
|
_i = 0;
|
|
89
|
-
|
|
90
|
-
case
|
|
91
|
-
if (!(_i <
|
|
92
|
-
|
|
108
|
+
_d.label = 3;
|
|
109
|
+
case 3:
|
|
110
|
+
if (!(_i < _b.length)) return [3 /*break*/, 6];
|
|
111
|
+
_c = _b[_i];
|
|
112
|
+
if (!(_c in _a)) return [3 /*break*/, 5];
|
|
113
|
+
index = _c;
|
|
93
114
|
file = files[index];
|
|
94
115
|
if (s3Config.append) {
|
|
95
|
-
s3Config.key = s3Key
|
|
116
|
+
s3Config.key = "".concat(s3Key, "/").concat(file.originalname);
|
|
96
117
|
}
|
|
97
118
|
return [4 /*yield*/, processFileUploadToS3(file, s3Client, s3Config, encryption, options, encryption ? true : false)];
|
|
98
|
-
case
|
|
99
|
-
fileObj =
|
|
119
|
+
case 4:
|
|
120
|
+
fileObj = _d.sent();
|
|
100
121
|
if (fileObj) {
|
|
101
122
|
fileOptions.push(fileObj);
|
|
102
123
|
}
|
|
103
|
-
|
|
104
|
-
case 3:
|
|
105
|
-
_i++;
|
|
106
|
-
return [3 /*break*/, 1];
|
|
107
|
-
case 4: return [2 /*return*/, fileOptions];
|
|
124
|
+
_d.label = 5;
|
|
108
125
|
case 5:
|
|
126
|
+
_i++;
|
|
127
|
+
return [3 /*break*/, 3];
|
|
128
|
+
case 6: return [2 /*return*/, fileOptions];
|
|
129
|
+
case 7:
|
|
109
130
|
console.log("I have single file");
|
|
110
131
|
if (s3Config.append) {
|
|
111
|
-
s3Config.key = s3Config.key
|
|
132
|
+
s3Config.key = "".concat(s3Config.key, "/").concat(files.originalname);
|
|
112
133
|
}
|
|
113
134
|
return [4 /*yield*/, processFileUploadToS3(files, s3Client, s3Config, encryption, options, encryption ? true : false)];
|
|
114
|
-
case
|
|
115
|
-
fileObj =
|
|
135
|
+
case 8:
|
|
136
|
+
fileObj = _d.sent();
|
|
116
137
|
return [2 /*return*/, fileObj];
|
|
117
138
|
}
|
|
118
139
|
});
|
|
@@ -132,7 +153,7 @@ var processFileUploadToS3 = function (file, s3Client, s3Config, encryption, opti
|
|
|
132
153
|
acl = s3Config.acl, key = s3Config.key, bucket = s3Config.bucket;
|
|
133
154
|
params = null;
|
|
134
155
|
if (!encrypt) return [3 /*break*/, 2];
|
|
135
|
-
return [4 /*yield*/, encryption_1.cryptFile(file.path, encryption, false)];
|
|
156
|
+
return [4 /*yield*/, (0, encryption_1.cryptFile)(file.path, encryption, false)];
|
|
136
157
|
case 1:
|
|
137
158
|
encryptedBody = _a.sent();
|
|
138
159
|
params = __assign({ Bucket: bucket, ACL: acl, Key: key,
|
package/build/utils/util.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const validateString: (str: string) => false | "String should not contain special characters" | "String should not contain any number";
|
|
2
2
|
export declare const camelize: (str: string) => string;
|
|
3
|
-
export declare const clearSpaceAndReformat: (text: string, separator?: string
|
|
3
|
+
export declare const clearSpaceAndReformat: (text: string, separator?: string) => string;
|
|
4
4
|
export declare const isEmpty: (obj: any) => boolean;
|
|
5
5
|
export declare const isEmptyObject: (object: any) => boolean;
|
|
6
6
|
export declare const isObject: (item: any) => any;
|
package/build/utils/util.js
CHANGED
|
@@ -38,7 +38,7 @@ var validateString = function (str) {
|
|
|
38
38
|
};
|
|
39
39
|
exports.validateString = validateString;
|
|
40
40
|
var camelize = function (str) {
|
|
41
|
-
str = exports.clearSpaceAndReformat(str);
|
|
41
|
+
str = (0, exports.clearSpaceAndReformat)(str);
|
|
42
42
|
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
|
|
43
43
|
return index === 0 ? word.toLowerCase() : word.toUpperCase();
|
|
44
44
|
});
|
|
@@ -165,8 +165,8 @@ var cleanCollectionAndFieldName = function (str) {
|
|
|
165
165
|
};
|
|
166
166
|
exports.cleanCollectionAndFieldName = cleanCollectionAndFieldName;
|
|
167
167
|
var formatCollectionAndFieldName = function (str) {
|
|
168
|
-
var updateString = exports.cleanCollectionAndFieldName(str);
|
|
169
|
-
return exports.clearSpaceAndReformat(updateString.trim(), "_");
|
|
168
|
+
var updateString = (0, exports.cleanCollectionAndFieldName)(str);
|
|
169
|
+
return (0, exports.clearSpaceAndReformat)(updateString.trim(), "_");
|
|
170
170
|
};
|
|
171
171
|
exports.formatCollectionAndFieldName = formatCollectionAndFieldName;
|
|
172
172
|
var restructureData = function (data) {
|
|
@@ -197,7 +197,7 @@ var restructureData = function (data) {
|
|
|
197
197
|
exports.restructureData = restructureData;
|
|
198
198
|
var checkAndCompareValue = function (input1, input2) {
|
|
199
199
|
return Array.isArray(input2)
|
|
200
|
-
? exports.arraysEqual(input1, input2.map(function (key) { return key.value; }))
|
|
200
|
+
? (0, exports.arraysEqual)(input1, input2.map(function (key) { return key.value; }))
|
|
201
201
|
: input1 === input2.value;
|
|
202
202
|
};
|
|
203
203
|
exports.checkAndCompareValue = checkAndCompareValue;
|
|
@@ -207,7 +207,7 @@ var arraysEqual = function (array1, array2) {
|
|
|
207
207
|
return false;
|
|
208
208
|
for (var i = 0; i < array1.length; i++ // assert each element equal
|
|
209
209
|
)
|
|
210
|
-
if (!exports.arraysEqual(array1[i], array2[i]))
|
|
210
|
+
if (!(0, exports.arraysEqual)(array1[i], array2[i]))
|
|
211
211
|
return false;
|
|
212
212
|
return true;
|
|
213
213
|
}
|
|
@@ -242,7 +242,7 @@ var formatCustomCSSClasses = function (projectCustomCSSClasses) {
|
|
|
242
242
|
.replace(/"([^"]+)"/g, "$1")
|
|
243
243
|
.split(",")
|
|
244
244
|
.join(";");
|
|
245
|
-
projectCustomCSSClassesData += ""
|
|
245
|
+
projectCustomCSSClassesData += "".concat(element.class.startsWith(".") ? element.class : "." + element.class).concat(element.pseudoClass ? ":" + element.pseudoClass : "").concat(unquotedClassWithProp, " ");
|
|
246
246
|
}
|
|
247
247
|
});
|
|
248
248
|
return projectCustomCSSClassesData;
|
|
@@ -253,18 +253,18 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, s
|
|
|
253
253
|
var contentList = (_a = expression
|
|
254
254
|
.match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
|
|
255
255
|
contentList === null || contentList === void 0 ? void 0 : contentList.forEach(function (prop) {
|
|
256
|
-
var needle = "{{"
|
|
256
|
+
var needle = "{{".concat(prop, "}}");
|
|
257
257
|
var dataOfItem = "";
|
|
258
258
|
if (prop.includes("current_user")) {
|
|
259
259
|
prop = prop.replace("current_user.", "");
|
|
260
260
|
if (Object.keys(user).length > 0) {
|
|
261
|
-
dataOfItem = exports.parseValueFromData(user, prop);
|
|
261
|
+
dataOfItem = (0, exports.parseValueFromData)(user, prop);
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
264
|
else if (prop.includes("current_tenant")) {
|
|
265
265
|
prop = prop.replace("current_tenant.", "");
|
|
266
266
|
if (Object.keys(tenant).length > 0) {
|
|
267
|
-
dataOfItem = exports.parseValueFromData(tenant, prop);
|
|
267
|
+
dataOfItem = (0, exports.parseValueFromData)(tenant, prop);
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
270
|
else if (prop.includes("current_session")) {
|
|
@@ -290,7 +290,7 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, s
|
|
|
290
290
|
}
|
|
291
291
|
else {
|
|
292
292
|
if (Object.keys(data).length > 0) {
|
|
293
|
-
dataOfItem = exports.parseValueFromData(data, prop);
|
|
293
|
+
dataOfItem = (0, exports.parseValueFromData)(data, prop);
|
|
294
294
|
//TODO: Need better way
|
|
295
295
|
delete data[prop];
|
|
296
296
|
}
|
|
@@ -390,7 +390,7 @@ var replaceTransferObjectValueIntoExpression = function (expression, transferObj
|
|
|
390
390
|
var contentList = (_a = expression
|
|
391
391
|
.match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
|
|
392
392
|
contentList === null || contentList === void 0 ? void 0 : contentList.forEach(function (prop) {
|
|
393
|
-
var needle = "{{"
|
|
393
|
+
var needle = "{{".concat(prop, "}}");
|
|
394
394
|
var dataOfItem = "";
|
|
395
395
|
dataOfItem = transferObject[prop] ? transferObject[prop] : "";
|
|
396
396
|
expression = dataOfItem
|
|
@@ -38,10 +38,10 @@ var nextGeneratedString = function (str, prepend, minLength, append, algorithm)
|
|
|
38
38
|
finalValue = voca_1.default.padLeft(finalValue, minLength, "0");
|
|
39
39
|
}
|
|
40
40
|
if (prepend) {
|
|
41
|
-
finalValue = ""
|
|
41
|
+
finalValue = "".concat(prepend).concat(finalValue);
|
|
42
42
|
}
|
|
43
43
|
if (append) {
|
|
44
|
-
finalValue = ""
|
|
44
|
+
finalValue = "".concat(finalValue).concat(append);
|
|
45
45
|
}
|
|
46
46
|
return finalValue;
|
|
47
47
|
};
|