drapcode-utility 1.2.2-beta → 1.2.3
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.js +1 -1
- package/build/encryption/crypt.js +2 -2
- package/build/encryption/file.js +4 -4
- package/build/encryption/index.js +14 -14
- 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 +124 -121
- package/build/utils/query-paser-new.js +119 -116
- package/build/utils/s3-util.js +22 -19
- package/build/utils/util.d.ts +2 -1
- package/build/utils/util.js +100 -12
- package/build/utils/uuid-generator.js +2 -2
- package/package.json +3 -3
|
@@ -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
|
},
|
|
@@ -205,21 +209,21 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
|
|
|
205
209
|
finder = query.finder, sortBy = query.sortBy, orderBy = query.orderBy, aggregateFunctionField = query.aggregateFunctionField;
|
|
206
210
|
if (!(finder != "COUNT" && refCollectionFieldsInItems)) return [3 /*break*/, 2];
|
|
207
211
|
return [4 /*yield*/, Promise.all(refCollectionFieldsInItems.map(function (field) {
|
|
208
|
-
var _a;
|
|
212
|
+
var _a, _b, _c;
|
|
209
213
|
if (["reference", "multi_reference", "belongsTo"].includes(field.type)) {
|
|
210
214
|
var collectionName_1 = field.refCollection
|
|
211
215
|
? field.refCollection["collectionName"]
|
|
212
216
|
: null;
|
|
213
217
|
if (collectionName_1) {
|
|
214
218
|
if (field.type === "belongsTo") {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
219
|
+
aggregateQuery.push({
|
|
220
|
+
$lookup: {
|
|
221
|
+
from: "".concat(collectionName_1),
|
|
222
|
+
localField: field.fieldName,
|
|
223
|
+
foreignField: "uuid",
|
|
224
|
+
as: field.fieldName,
|
|
225
|
+
},
|
|
226
|
+
});
|
|
223
227
|
aggregateQuery.push({
|
|
224
228
|
$addFields: (_a = {},
|
|
225
229
|
_a["_$belongsToMetaData"] = field,
|
|
@@ -227,73 +231,72 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
|
|
|
227
231
|
});
|
|
228
232
|
}
|
|
229
233
|
else {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
234
|
+
aggregateQuery.push({
|
|
235
|
+
$lookup: {
|
|
236
|
+
from: "".concat(collectionName_1),
|
|
237
|
+
let: (_b = {}, _b["".concat(field.fieldName)] = "$".concat(field.fieldName), _b),
|
|
238
|
+
pipeline: [
|
|
239
|
+
{
|
|
240
|
+
$match: {
|
|
241
|
+
$expr: {
|
|
242
|
+
$in: [
|
|
243
|
+
"$uuid",
|
|
244
|
+
{
|
|
245
|
+
$cond: {
|
|
246
|
+
if: {
|
|
247
|
+
$in: ["$$".concat(field.fieldName), ["", null]],
|
|
248
|
+
},
|
|
249
|
+
then: [],
|
|
250
|
+
else: { $ifNull: ["$$".concat(field.fieldName), []] },
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
$lookup: {
|
|
259
|
+
from: "user",
|
|
260
|
+
let: { createdBy: "$createdBy" },
|
|
261
|
+
pipeline: [
|
|
262
|
+
{
|
|
263
|
+
$match: {
|
|
264
|
+
$expr: { $eq: ["$uuid", "$$createdBy"] },
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
{ $project: { _id: 0, password: 0 } },
|
|
268
|
+
],
|
|
269
|
+
as: "createdBy",
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
],
|
|
273
|
+
as: field.fieldName,
|
|
274
|
+
},
|
|
275
|
+
});
|
|
272
276
|
}
|
|
273
277
|
}
|
|
274
278
|
}
|
|
275
|
-
if (field.type === "createdBy")
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
// });
|
|
279
|
+
if (field.type === "createdBy")
|
|
280
|
+
aggregateQuery.push({
|
|
281
|
+
$lookup: {
|
|
282
|
+
from: "user",
|
|
283
|
+
let: (_c = {}, _c["".concat(field.fieldName)] = "$".concat(field.fieldName), _c),
|
|
284
|
+
pipeline: [
|
|
285
|
+
{
|
|
286
|
+
$match: { $expr: { $eq: ["$uuid", "$$".concat(field.fieldName)] } },
|
|
287
|
+
},
|
|
288
|
+
{ $project: { _id: 0, password: 0 } },
|
|
289
|
+
],
|
|
290
|
+
as: field.fieldName,
|
|
291
|
+
},
|
|
292
|
+
});
|
|
290
293
|
}))];
|
|
291
294
|
case 1:
|
|
292
295
|
_b.sent();
|
|
293
296
|
_b.label = 2;
|
|
294
297
|
case 2:
|
|
295
298
|
if (!["COUNT", "SUM", "AVG", "MIN", "MAX"].includes(finder) &&
|
|
296
|
-
!util_1.isEmpty(projection)) {
|
|
299
|
+
!(0, util_1.isEmpty)(projection)) {
|
|
297
300
|
aggregateQuery.push({ $project: projection });
|
|
298
301
|
}
|
|
299
302
|
if (finder === "COUNT") {
|
|
@@ -301,22 +304,22 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
|
|
|
301
304
|
}
|
|
302
305
|
else if (finder === "SUM") {
|
|
303
306
|
aggregateQuery.push({
|
|
304
|
-
$group: { _id: null, total: { $sum: "$"
|
|
307
|
+
$group: { _id: null, total: { $sum: "$".concat(aggregateFunctionField) } },
|
|
305
308
|
});
|
|
306
309
|
}
|
|
307
310
|
else if (finder === "AVG") {
|
|
308
311
|
aggregateQuery.push({
|
|
309
|
-
$group: { _id: null, average: { $avg: "$"
|
|
312
|
+
$group: { _id: null, average: { $avg: "$".concat(aggregateFunctionField) } },
|
|
310
313
|
});
|
|
311
314
|
}
|
|
312
315
|
else if (finder === "MIN") {
|
|
313
316
|
aggregateQuery.push({
|
|
314
|
-
$group: { _id: null, minimum: { $min: "$"
|
|
317
|
+
$group: { _id: null, minimum: { $min: "$".concat(aggregateFunctionField) } },
|
|
315
318
|
});
|
|
316
319
|
}
|
|
317
320
|
else if (finder === "MAX") {
|
|
318
321
|
aggregateQuery.push({
|
|
319
|
-
$group: { _id: null, maximum: { $max: "$"
|
|
322
|
+
$group: { _id: null, maximum: { $max: "$".concat(aggregateFunctionField) } },
|
|
320
323
|
});
|
|
321
324
|
}
|
|
322
325
|
offset = externalParams.offset || 0;
|
|
@@ -332,8 +335,8 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
|
|
|
332
335
|
if (finder != "COUNT" && limit) {
|
|
333
336
|
aggregateQuery.push({ $skip: +offset }, { $limit: +limit });
|
|
334
337
|
}
|
|
335
|
-
queryStr = ".aggregate("
|
|
336
|
-
str = "req.db.collection('"
|
|
338
|
+
queryStr = ".aggregate(".concat(JSON.stringify(aggregateQuery), ", { collation: { locale: \"en\" } })");
|
|
339
|
+
str = "req.db.collection('".concat(collectionName, "')").concat(queryStr);
|
|
337
340
|
str += ".toArray()";
|
|
338
341
|
return [2 /*return*/, str];
|
|
339
342
|
}
|
|
@@ -370,7 +373,7 @@ var mongoFilterQuery = function (query, externalParams, constants, currentUser)
|
|
|
370
373
|
filterQuery[lastKey].push(mongoQuery);
|
|
371
374
|
}
|
|
372
375
|
else {
|
|
373
|
-
filterQuery["$or"
|
|
376
|
+
filterQuery["$or".concat(index)] = [mongoQuery];
|
|
374
377
|
}
|
|
375
378
|
}
|
|
376
379
|
else if (queryObj.conjunctionType == "AND") {
|
|
@@ -379,11 +382,11 @@ var mongoFilterQuery = function (query, externalParams, constants, currentUser)
|
|
|
379
382
|
filterQuery[lastKey].push(mongoQuery);
|
|
380
383
|
}
|
|
381
384
|
else {
|
|
382
|
-
filterQuery["$and"
|
|
385
|
+
filterQuery["$and".concat(index)] = [mongoQuery];
|
|
383
386
|
}
|
|
384
387
|
}
|
|
385
388
|
else {
|
|
386
|
-
filterQuery["$or"
|
|
389
|
+
filterQuery["$or".concat(index)] = [mongoQuery];
|
|
387
390
|
}
|
|
388
391
|
});
|
|
389
392
|
console.log("==> *** filterQuery #2 :>> ", filterQuery);
|
|
@@ -393,19 +396,21 @@ var mongoFilterQuery = function (query, externalParams, constants, currentUser)
|
|
|
393
396
|
var mongoSelectQuery = function (query) {
|
|
394
397
|
if (query === void 0) { query = {}; }
|
|
395
398
|
var projection = {};
|
|
396
|
-
var fieldsInclude = query.fieldsInclude, fieldsExclude = query.fieldsExclude;
|
|
399
|
+
var fieldsInclude = query.fieldsInclude, fieldsExclude = query.fieldsExclude, finder = query.finder;
|
|
397
400
|
if (!fieldsExclude)
|
|
398
401
|
fieldsExclude = [];
|
|
399
402
|
if (fieldsInclude[0] === "*") {
|
|
400
403
|
fieldsExclude.map(function (field) {
|
|
401
404
|
if (field)
|
|
402
|
-
return (projection[""
|
|
405
|
+
return (projection["".concat(field)] = 0);
|
|
403
406
|
});
|
|
404
407
|
}
|
|
405
408
|
else {
|
|
409
|
+
if (["FIND_ALL", "FIND"].includes(finder))
|
|
410
|
+
fieldsInclude = (0, util_1.processFieldsInlcude)(fieldsInclude);
|
|
406
411
|
fieldsInclude.map(function (field) {
|
|
407
412
|
if (field)
|
|
408
|
-
return (projection[""
|
|
413
|
+
return (projection["".concat(field)] = 1);
|
|
409
414
|
});
|
|
410
415
|
}
|
|
411
416
|
return projection;
|
|
@@ -496,7 +501,7 @@ var queryToMongo = function (query, requiredExternal, externalParams, constants,
|
|
|
496
501
|
return _r = {},
|
|
497
502
|
_r[field] = {
|
|
498
503
|
$gte: fieldValue,
|
|
499
|
-
$lt: new Date(date_util_1.nextDayDate(fieldValue)),
|
|
504
|
+
$lt: new Date((0, date_util_1.nextDayDate)(fieldValue)),
|
|
500
505
|
},
|
|
501
506
|
_r;
|
|
502
507
|
}
|
|
@@ -520,12 +525,11 @@ var queryToMongo = function (query, requiredExternal, externalParams, constants,
|
|
|
520
525
|
};
|
|
521
526
|
if (key == drapcode_constant_1.EQUALS)
|
|
522
527
|
return _y = {},
|
|
523
|
-
// TODO:Handle Based of Field Type
|
|
524
528
|
_y[field] = fieldType === "boolean" && fieldValue
|
|
525
529
|
? JSON.parse(fieldValue)
|
|
526
|
-
:
|
|
527
|
-
|
|
528
|
-
fieldValue,
|
|
530
|
+
: !isNaN(fieldValue)
|
|
531
|
+
? +fieldValue
|
|
532
|
+
: fieldValue,
|
|
529
533
|
_y;
|
|
530
534
|
if (key == drapcode_constant_1.NOT_EQUAL)
|
|
531
535
|
return _z = {},
|
|
@@ -575,11 +579,11 @@ var replaceExternalParams = function (query, requiredExternal, externalParams, c
|
|
|
575
579
|
if (key === drapcode_constant_1.BETWEEN) {
|
|
576
580
|
var _a = getMinMaxValue(value), startValue_1 = _a.startValue, endValue_1 = _a.endValue, isInteger = _a.isInteger;
|
|
577
581
|
if (requiredExternal) {
|
|
578
|
-
startValue_1 = ""
|
|
579
|
-
endValue_1 = ""
|
|
582
|
+
startValue_1 = "".concat(externalParams[startValue_1]);
|
|
583
|
+
endValue_1 = "".concat(externalParams[endValue_1]);
|
|
580
584
|
}
|
|
581
585
|
else {
|
|
582
|
-
if (__spreadArray([drapcode_constant_1.CURRENT_USER], drapcode_constant_1.DateConstant).some(function (cnst) {
|
|
586
|
+
if (__spreadArray([drapcode_constant_1.CURRENT_USER], drapcode_constant_1.DateConstant, true).some(function (cnst) {
|
|
583
587
|
return startValue_1.includes(cnst);
|
|
584
588
|
})) {
|
|
585
589
|
startValue_1 = getValueOfProjectConstant(startValue_1, currentUser);
|
|
@@ -587,7 +591,7 @@ var replaceExternalParams = function (query, requiredExternal, externalParams, c
|
|
|
587
591
|
else {
|
|
588
592
|
startValue_1 = constants.filter(function (constant) { return constant.name == startValue_1; });
|
|
589
593
|
}
|
|
590
|
-
if (__spreadArray([drapcode_constant_1.CURRENT_USER], drapcode_constant_1.DateConstant).some(function (cnst) { return endValue_1.includes(cnst); })) {
|
|
594
|
+
if (__spreadArray([drapcode_constant_1.CURRENT_USER], drapcode_constant_1.DateConstant, true).some(function (cnst) { return endValue_1.includes(cnst); })) {
|
|
591
595
|
endValue_1 = getValueOfProjectConstant(endValue_1, currentUser);
|
|
592
596
|
}
|
|
593
597
|
else {
|
|
@@ -604,10 +608,10 @@ var replaceExternalParams = function (query, requiredExternal, externalParams, c
|
|
|
604
608
|
//TODO: Need to figure out the params should be treated as number/string
|
|
605
609
|
if (!isNaN(startValue_1)) {
|
|
606
610
|
console.log("I am Number");
|
|
607
|
-
return startValue_1
|
|
611
|
+
return "".concat(startValue_1, "---").concat(endValue_1, "^");
|
|
608
612
|
}
|
|
609
613
|
else
|
|
610
|
-
return startValue_1
|
|
614
|
+
return "".concat(startValue_1, "---").concat(endValue_1);
|
|
611
615
|
}
|
|
612
616
|
if (value.includes(drapcode_constant_1.CURRENT_USER)) {
|
|
613
617
|
if (value === drapcode_constant_1.CURRENT_USER) {
|
|
@@ -645,12 +649,11 @@ var replaceExternalParams = function (query, requiredExternal, externalParams, c
|
|
|
645
649
|
//TODO: This is just to confirm if external then it should be get from externalParams
|
|
646
650
|
if (requiredExternal) {
|
|
647
651
|
//TODO: Value returns from here undefined.
|
|
648
|
-
var externalParamValue = externalParams[""
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
return externalParams["" + value];
|
|
652
|
+
var externalParamValue = externalParams["".concat(value)];
|
|
653
|
+
if (!isNaN(externalParamValue)) {
|
|
654
|
+
return +externalParamValue;
|
|
655
|
+
}
|
|
656
|
+
return externalParams["".concat(value)];
|
|
654
657
|
}
|
|
655
658
|
var constantArr = constants.filter(function (constant) { return constant.name == value; });
|
|
656
659
|
return constantArr.length ? "" + constantArr[0].value : "";
|
|
@@ -677,9 +680,9 @@ var getValueOfProjectConstant = function (value, currentUser) {
|
|
|
677
680
|
if (value === drapcode_constant_1.CURRENT_USER)
|
|
678
681
|
return currentUser["uuid"];
|
|
679
682
|
if (value === drapcode_constant_1.CURRENT_DATE)
|
|
680
|
-
return date_util_1.createLoggerDateFormat();
|
|
683
|
+
return (0, date_util_1.createLoggerDateFormat)();
|
|
681
684
|
if ([drapcode_constant_1.CURRENT_TIME, drapcode_constant_1.CURRENT_DATE_TIME].includes(value))
|
|
682
|
-
return date_util_1.createLogsDateFormat();
|
|
685
|
+
return (0, date_util_1.createLogsDateFormat)();
|
|
683
686
|
if (drapcode_constant_1.DateTimeUnit.some(function (cnst) { return value.includes(cnst); }))
|
|
684
|
-
return date_util_1.getDateValue(value);
|
|
687
|
+
return (0, date_util_1.getDateValue)(value);
|
|
685
688
|
};
|
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]) {
|
|
@@ -75,9 +75,9 @@ exports.createS3Client = createS3Client;
|
|
|
75
75
|
var fileUploadToS3 = function (files, s3Client, s3Config, encryption, options) {
|
|
76
76
|
if (options === void 0) { options = {}; }
|
|
77
77
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
78
|
-
var awsConfig, encryptionType, dataKey, accessKeyId, secretAccessKey, region, config, plainTextData, fileOptions, s3Key, _a, _b, _i, index, file, fileObj, fileObj;
|
|
79
|
-
return __generator(this, function (
|
|
80
|
-
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) {
|
|
81
81
|
case 0:
|
|
82
82
|
if (!encryption) return [3 /*break*/, 2];
|
|
83
83
|
awsConfig = encryption.awsConfig, encryptionType = encryption.encryptionType, dataKey = encryption.dataKey;
|
|
@@ -88,38 +88,41 @@ var fileUploadToS3 = function (files, s3Client, s3Config, encryption, options) {
|
|
|
88
88
|
accessKeyId: accessKeyId,
|
|
89
89
|
secretAccessKey: secretAccessKey,
|
|
90
90
|
};
|
|
91
|
-
return [4 /*yield*/, encryption_2.processKMSDecryption(config, dataKey, {})];
|
|
91
|
+
return [4 /*yield*/, (0, encryption_2.processKMSDecryption)(config, dataKey, {})];
|
|
92
92
|
case 1:
|
|
93
|
-
plainTextData =
|
|
93
|
+
plainTextData = _d.sent();
|
|
94
94
|
if (plainTextData.status === "FAILED") {
|
|
95
95
|
return [2 /*return*/, plainTextData];
|
|
96
96
|
}
|
|
97
97
|
encryption.dataKey = plainTextData.data;
|
|
98
|
-
|
|
98
|
+
_d.label = 2;
|
|
99
99
|
case 2:
|
|
100
100
|
if (!Array.isArray(files)) return [3 /*break*/, 7];
|
|
101
101
|
console.log("I have multiple file");
|
|
102
102
|
fileOptions = [];
|
|
103
103
|
s3Key = s3Config.key;
|
|
104
|
-
_a =
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
_a = files;
|
|
105
|
+
_b = [];
|
|
106
|
+
for (_c in _a)
|
|
107
|
+
_b.push(_c);
|
|
107
108
|
_i = 0;
|
|
108
|
-
|
|
109
|
+
_d.label = 3;
|
|
109
110
|
case 3:
|
|
110
|
-
if (!(_i <
|
|
111
|
-
|
|
111
|
+
if (!(_i < _b.length)) return [3 /*break*/, 6];
|
|
112
|
+
_c = _b[_i];
|
|
113
|
+
if (!(_c in _a)) return [3 /*break*/, 5];
|
|
114
|
+
index = _c;
|
|
112
115
|
file = files[index];
|
|
113
116
|
if (s3Config.append) {
|
|
114
|
-
s3Config.key = s3Key
|
|
117
|
+
s3Config.key = "".concat(s3Key, "/").concat(file.originalname);
|
|
115
118
|
}
|
|
116
119
|
return [4 /*yield*/, processFileUploadToS3(file, s3Client, s3Config, encryption, options, encryption ? true : false)];
|
|
117
120
|
case 4:
|
|
118
|
-
fileObj =
|
|
121
|
+
fileObj = _d.sent();
|
|
119
122
|
if (fileObj) {
|
|
120
123
|
fileOptions.push(fileObj);
|
|
121
124
|
}
|
|
122
|
-
|
|
125
|
+
_d.label = 5;
|
|
123
126
|
case 5:
|
|
124
127
|
_i++;
|
|
125
128
|
return [3 /*break*/, 3];
|
|
@@ -127,11 +130,11 @@ var fileUploadToS3 = function (files, s3Client, s3Config, encryption, options) {
|
|
|
127
130
|
case 7:
|
|
128
131
|
console.log("I have single file");
|
|
129
132
|
if (s3Config.append) {
|
|
130
|
-
s3Config.key = s3Config.key
|
|
133
|
+
s3Config.key = "".concat(s3Config.key, "/").concat(files.originalname);
|
|
131
134
|
}
|
|
132
135
|
return [4 /*yield*/, processFileUploadToS3(files, s3Client, s3Config, encryption, options, encryption ? true : false)];
|
|
133
136
|
case 8:
|
|
134
|
-
fileObj =
|
|
137
|
+
fileObj = _d.sent();
|
|
135
138
|
return [2 /*return*/, fileObj];
|
|
136
139
|
}
|
|
137
140
|
});
|
|
@@ -151,7 +154,7 @@ var processFileUploadToS3 = function (file, s3Client, s3Config, encryption, opti
|
|
|
151
154
|
acl = s3Config.acl, key = s3Config.key, bucket = s3Config.bucket;
|
|
152
155
|
params = null;
|
|
153
156
|
if (!encrypt) return [3 /*break*/, 2];
|
|
154
|
-
return [4 /*yield*/, encryption_1.cryptFile(file.path, encryption, false)];
|
|
157
|
+
return [4 /*yield*/, (0, encryption_1.cryptFile)(file.path, encryption, false)];
|
|
155
158
|
case 1:
|
|
156
159
|
encryptedBody = _a.sent();
|
|
157
160
|
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;
|
|
@@ -26,3 +26,4 @@ export declare const parseValueFromData: (data: any, fieldName: string) => any;
|
|
|
26
26
|
export declare const unflattenObject: (obj: any) => {};
|
|
27
27
|
export declare const replaceTransferObjectValueIntoExpression: (expression: string, transferObject: any) => string;
|
|
28
28
|
export declare const removeMongoDbId: (result: any[]) => any[];
|
|
29
|
+
export declare const processFieldsInlcude: (fieldsInclude: any) => any;
|