drapcode-utility 1.3.1 → 1.3.2
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 +1 -5
- 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 +8 -12
- package/build/utils/date-util.js +3 -3
- package/build/utils/prepare-query.js +9 -9
- package/build/utils/query-parser.js +48 -52
- package/build/utils/query-paser-new.js +43 -47
- package/build/utils/s3-util.js +19 -22
- package/build/utils/util.d.ts +1 -1
- package/build/utils/util.js +22 -26
- package/build/utils/uuid-generator.js +2 -2
- package/package.json +3 -3
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 (
|
|
28
|
+
while (_) 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]) {
|
|
@@ -76,9 +76,9 @@ exports.createS3Client = createS3Client;
|
|
|
76
76
|
var fileUploadToS3 = function (files, s3Client, s3Config, encryption, options) {
|
|
77
77
|
if (options === void 0) { options = {}; }
|
|
78
78
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
79
|
-
var awsConfig, encryptionType, dataKey, accessKeyId, secretAccessKey, region, config, plainTextData, fileOptions, s3Key, _a, _b,
|
|
80
|
-
return __generator(this, function (
|
|
81
|
-
switch (
|
|
79
|
+
var awsConfig, encryptionType, dataKey, accessKeyId, secretAccessKey, region, config, plainTextData, fileOptions, s3Key, _a, _b, _i, index, file, fileObj, fileObj;
|
|
80
|
+
return __generator(this, function (_c) {
|
|
81
|
+
switch (_c.label) {
|
|
82
82
|
case 0:
|
|
83
83
|
if (!encryption) return [3 /*break*/, 2];
|
|
84
84
|
awsConfig = encryption.awsConfig, encryptionType = encryption.encryptionType, dataKey = encryption.dataKey;
|
|
@@ -89,41 +89,38 @@ var fileUploadToS3 = function (files, s3Client, s3Config, encryption, options) {
|
|
|
89
89
|
accessKeyId: accessKeyId,
|
|
90
90
|
secretAccessKey: secretAccessKey,
|
|
91
91
|
};
|
|
92
|
-
return [4 /*yield*/,
|
|
92
|
+
return [4 /*yield*/, encryption_2.processKMSDecryption(config, dataKey, {})];
|
|
93
93
|
case 1:
|
|
94
|
-
plainTextData =
|
|
94
|
+
plainTextData = _c.sent();
|
|
95
95
|
if (plainTextData.status === "FAILED") {
|
|
96
96
|
return [2 /*return*/, plainTextData];
|
|
97
97
|
}
|
|
98
98
|
encryption.dataKey = plainTextData.data;
|
|
99
|
-
|
|
99
|
+
_c.label = 2;
|
|
100
100
|
case 2:
|
|
101
101
|
if (!Array.isArray(files)) return [3 /*break*/, 7];
|
|
102
102
|
console.log("I have multiple file");
|
|
103
103
|
fileOptions = [];
|
|
104
104
|
s3Key = s3Config.key;
|
|
105
|
-
_a =
|
|
106
|
-
_b
|
|
107
|
-
|
|
108
|
-
_b.push(_c);
|
|
105
|
+
_a = [];
|
|
106
|
+
for (_b in files)
|
|
107
|
+
_a.push(_b);
|
|
109
108
|
_i = 0;
|
|
110
|
-
|
|
109
|
+
_c.label = 3;
|
|
111
110
|
case 3:
|
|
112
|
-
if (!(_i <
|
|
113
|
-
|
|
114
|
-
if (!(_c in _a)) return [3 /*break*/, 5];
|
|
115
|
-
index = _c;
|
|
111
|
+
if (!(_i < _a.length)) return [3 /*break*/, 6];
|
|
112
|
+
index = _a[_i];
|
|
116
113
|
file = files[index];
|
|
117
114
|
if (s3Config.append) {
|
|
118
|
-
s3Config.key =
|
|
115
|
+
s3Config.key = s3Key + "/" + uuid_1.v4() + "/" + file.originalname;
|
|
119
116
|
}
|
|
120
117
|
return [4 /*yield*/, processFileUploadToS3(file, s3Client, s3Config, encryption, options, encryption ? true : false)];
|
|
121
118
|
case 4:
|
|
122
|
-
fileObj =
|
|
119
|
+
fileObj = _c.sent();
|
|
123
120
|
if (fileObj) {
|
|
124
121
|
fileOptions.push(fileObj);
|
|
125
122
|
}
|
|
126
|
-
|
|
123
|
+
_c.label = 5;
|
|
127
124
|
case 5:
|
|
128
125
|
_i++;
|
|
129
126
|
return [3 /*break*/, 3];
|
|
@@ -131,11 +128,11 @@ var fileUploadToS3 = function (files, s3Client, s3Config, encryption, options) {
|
|
|
131
128
|
case 7:
|
|
132
129
|
console.log("I have single file");
|
|
133
130
|
if (s3Config.append) {
|
|
134
|
-
s3Config.key =
|
|
131
|
+
s3Config.key = s3Config.key + "/" + uuid_1.v4() + "/" + files.originalname;
|
|
135
132
|
}
|
|
136
133
|
return [4 /*yield*/, processFileUploadToS3(files, s3Client, s3Config, encryption, options, encryption ? true : false)];
|
|
137
134
|
case 8:
|
|
138
|
-
fileObj =
|
|
135
|
+
fileObj = _c.sent();
|
|
139
136
|
return [2 /*return*/, fileObj];
|
|
140
137
|
}
|
|
141
138
|
});
|
|
@@ -159,7 +156,7 @@ var processFileUploadToS3 = function (file, s3Client, s3Config, encryption, opti
|
|
|
159
156
|
params = null;
|
|
160
157
|
encryptedFilePath = null;
|
|
161
158
|
if (!encrypt) return [3 /*break*/, 3];
|
|
162
|
-
return [4 /*yield*/,
|
|
159
|
+
return [4 /*yield*/, encryption_1.cryptFile(file.path, encryption, false)];
|
|
163
160
|
case 2:
|
|
164
161
|
encryptedFilePath = _a.sent();
|
|
165
162
|
console.log("encryptedFilePath", encryptedFilePath);
|
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) => string;
|
|
3
|
+
export declare const clearSpaceAndReformat: (text: string, separator?: string | undefined) => 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
|
@@ -21,14 +21,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
}
|
|
22
22
|
return t;
|
|
23
23
|
};
|
|
24
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
ar[i] = from[i];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
24
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
25
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
26
|
+
to[j] = from[i];
|
|
27
|
+
return to;
|
|
32
28
|
};
|
|
33
29
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
34
30
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -78,7 +74,7 @@ var validateString = function (str) {
|
|
|
78
74
|
};
|
|
79
75
|
exports.validateString = validateString;
|
|
80
76
|
var camelize = function (str) {
|
|
81
|
-
str =
|
|
77
|
+
str = exports.clearSpaceAndReformat(str);
|
|
82
78
|
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
|
|
83
79
|
return index === 0 ? word.toLowerCase() : word.toUpperCase();
|
|
84
80
|
});
|
|
@@ -205,8 +201,8 @@ var cleanCollectionAndFieldName = function (str) {
|
|
|
205
201
|
};
|
|
206
202
|
exports.cleanCollectionAndFieldName = cleanCollectionAndFieldName;
|
|
207
203
|
var formatCollectionAndFieldName = function (str) {
|
|
208
|
-
var updateString =
|
|
209
|
-
return
|
|
204
|
+
var updateString = exports.cleanCollectionAndFieldName(str);
|
|
205
|
+
return exports.clearSpaceAndReformat(updateString.trim(), "_");
|
|
210
206
|
};
|
|
211
207
|
exports.formatCollectionAndFieldName = formatCollectionAndFieldName;
|
|
212
208
|
var restructureData = function (data) {
|
|
@@ -237,7 +233,7 @@ var restructureData = function (data) {
|
|
|
237
233
|
exports.restructureData = restructureData;
|
|
238
234
|
var checkAndCompareValue = function (input1, input2) {
|
|
239
235
|
return Array.isArray(input2)
|
|
240
|
-
?
|
|
236
|
+
? exports.arraysEqual(input1, input2.map(function (key) { return key.value; }))
|
|
241
237
|
: input1 === input2.value;
|
|
242
238
|
};
|
|
243
239
|
exports.checkAndCompareValue = checkAndCompareValue;
|
|
@@ -247,7 +243,7 @@ var arraysEqual = function (array1, array2) {
|
|
|
247
243
|
return false;
|
|
248
244
|
for (var i = 0; i < array1.length; i++ // assert each element equal
|
|
249
245
|
)
|
|
250
|
-
if (!
|
|
246
|
+
if (!exports.arraysEqual(array1[i], array2[i]))
|
|
251
247
|
return false;
|
|
252
248
|
return true;
|
|
253
249
|
}
|
|
@@ -282,7 +278,7 @@ var formatCustomCSSClasses = function (customClasses) {
|
|
|
282
278
|
.replace(/"([^"]+)"/g, "$1")
|
|
283
279
|
.split(",")
|
|
284
280
|
.join(";");
|
|
285
|
-
projectCustomCSSClassesData += ""
|
|
281
|
+
projectCustomCSSClassesData += "" + (element.class.startsWith(".") ? element.class : "." + element.class) + (element.pseudoClass ? ":" + element.pseudoClass : "") + unquotedClassWithProp + " ";
|
|
286
282
|
}
|
|
287
283
|
});
|
|
288
284
|
return projectCustomCSSClassesData;
|
|
@@ -293,18 +289,18 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, s
|
|
|
293
289
|
var contentList = (_a = expression
|
|
294
290
|
.match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
|
|
295
291
|
contentList === null || contentList === void 0 ? void 0 : contentList.forEach(function (prop) {
|
|
296
|
-
var needle = "{{"
|
|
292
|
+
var needle = "{{" + prop + "}}";
|
|
297
293
|
var dataOfItem = "";
|
|
298
294
|
if (prop.includes("current_user")) {
|
|
299
295
|
prop = prop.replace("current_user.", "");
|
|
300
296
|
if (Object.keys(user).length > 0) {
|
|
301
|
-
dataOfItem =
|
|
297
|
+
dataOfItem = exports.parseValueFromData(user, prop);
|
|
302
298
|
}
|
|
303
299
|
}
|
|
304
300
|
else if (prop.includes("current_tenant")) {
|
|
305
301
|
prop = prop.replace("current_tenant.", "");
|
|
306
302
|
if (Object.keys(tenant).length > 0) {
|
|
307
|
-
dataOfItem =
|
|
303
|
+
dataOfItem = exports.parseValueFromData(tenant, prop);
|
|
308
304
|
}
|
|
309
305
|
}
|
|
310
306
|
else if (prop.includes("current_session")) {
|
|
@@ -330,7 +326,7 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, s
|
|
|
330
326
|
}
|
|
331
327
|
else {
|
|
332
328
|
if (Object.keys(data).length > 0) {
|
|
333
|
-
dataOfItem =
|
|
329
|
+
dataOfItem = exports.parseValueFromData(data, prop);
|
|
334
330
|
//TODO: Need better way
|
|
335
331
|
delete data[prop];
|
|
336
332
|
}
|
|
@@ -430,7 +426,7 @@ var replaceTransferObjectValueIntoExpression = function (expression, transferObj
|
|
|
430
426
|
var contentList = (_a = expression
|
|
431
427
|
.match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
|
|
432
428
|
contentList === null || contentList === void 0 ? void 0 : contentList.forEach(function (prop) {
|
|
433
|
-
var needle = "{{"
|
|
429
|
+
var needle = "{{" + prop + "}}";
|
|
434
430
|
var dataOfItem = "";
|
|
435
431
|
dataOfItem = transferObject[prop] ? transferObject[prop] : "";
|
|
436
432
|
expression = dataOfItem
|
|
@@ -476,8 +472,8 @@ var processFieldsInlcude = function (fieldsInclude) {
|
|
|
476
472
|
fieldsInclude = fieldsInclude.filter(function (field) { return !(field.startsWith("RF::") || field.startsWith("DF::")); });
|
|
477
473
|
var refFields = processReferenceFieldInclude(refFieldsInclude);
|
|
478
474
|
var derivedFields = processDerivedFieldInclude(derivedFieldsInclude);
|
|
479
|
-
var extraField = __spreadArray(__spreadArray([], refFields
|
|
480
|
-
result = __spreadArray(__spreadArray([], fieldsInclude
|
|
475
|
+
var extraField = __spreadArray(__spreadArray([], refFields), derivedFields).filter(function (value, index, array) { return array.indexOf(value) === index; });
|
|
476
|
+
result = __spreadArray(__spreadArray([], fieldsInclude), extraField);
|
|
481
477
|
return result;
|
|
482
478
|
};
|
|
483
479
|
exports.processFieldsInlcude = processFieldsInlcude;
|
|
@@ -502,16 +498,16 @@ var processDerivedFieldInclude = function (derivedFieldsInclude) {
|
|
|
502
498
|
if (arg.name === "expression") {
|
|
503
499
|
var needleList = (_a = arg.key
|
|
504
500
|
.match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
|
|
505
|
-
var tempFields =
|
|
506
|
-
fields = __spreadArray(__spreadArray([], fields
|
|
501
|
+
var tempFields = exports.processFieldsInlcude(needleList);
|
|
502
|
+
fields = __spreadArray(__spreadArray([], fields), tempFields);
|
|
507
503
|
}
|
|
508
504
|
else if (!derivedFieldExcludes.includes(arg.name)) {
|
|
509
505
|
var tempFields = Array.isArray(arg.key) ? arg.key : [arg.key];
|
|
510
|
-
tempFields =
|
|
511
|
-
fields = __spreadArray(__spreadArray([], fields
|
|
506
|
+
tempFields = exports.processFieldsInlcude(tempFields);
|
|
507
|
+
fields = __spreadArray(__spreadArray([], fields), tempFields);
|
|
512
508
|
}
|
|
513
509
|
});
|
|
514
|
-
derivedFields = __spreadArray(__spreadArray([], derivedFields
|
|
510
|
+
derivedFields = __spreadArray(__spreadArray([], derivedFields), fields);
|
|
515
511
|
});
|
|
516
512
|
return derivedFields;
|
|
517
513
|
};
|
|
@@ -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 = "" + prepend + finalValue;
|
|
42
42
|
}
|
|
43
43
|
if (append) {
|
|
44
|
-
finalValue = ""
|
|
44
|
+
finalValue = "" + finalValue + append;
|
|
45
45
|
}
|
|
46
46
|
return finalValue;
|
|
47
47
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drapcode-utility",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"@types/express": "^4.17.7",
|
|
34
34
|
"@types/voca": "^1.4.2",
|
|
35
35
|
"axios": "^1.1.2",
|
|
36
|
-
"drapcode-constant": "^1.3.
|
|
37
|
-
"drapcode-logger": "^1.0.
|
|
36
|
+
"drapcode-constant": "^1.3.1",
|
|
37
|
+
"drapcode-logger": "^1.0.8",
|
|
38
38
|
"drapcode-redis": "^1.0.4",
|
|
39
39
|
"express": "^4.17.1",
|
|
40
40
|
"lodash": "^4.17.21",
|