drapcode-utility 1.9.78 → 2.0.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/index.js +5 -2
- package/build/utils/query-utils.js +29 -12
- package/build/utils/rest-client.js +25 -7
- package/build/utils/util.js +10 -6
- package/package.json +3 -3
|
@@ -90,7 +90,9 @@ var processItemEncryptDecrypt = function (item, fields, encryption, decrypt, enc
|
|
|
90
90
|
return __generator(this, function (_b) {
|
|
91
91
|
switch (_b.label) {
|
|
92
92
|
case 0:
|
|
93
|
-
if (!
|
|
93
|
+
if (!item && typeof item !== "object") {
|
|
94
|
+
return [2 /*return*/, item];
|
|
95
|
+
}
|
|
94
96
|
_loop_1 = function (fieldName) {
|
|
95
97
|
var field, promises, _c, _d, _e, _f, refField, _g, _h;
|
|
96
98
|
return __generator(this, function (_j) {
|
|
@@ -118,7 +120,7 @@ var processItemEncryptDecrypt = function (item, fields, encryption, decrypt, enc
|
|
|
118
120
|
_j.label = 4;
|
|
119
121
|
case 4:
|
|
120
122
|
if (!decrypt) return [3 /*break*/, 6];
|
|
121
|
-
if (!drapcode_constant_1.BelongsCreatedByRefField.includes(field === null || field === void 0 ? void 0 : field.type)) return [3 /*break*/, 6];
|
|
123
|
+
if (!(decrypt && drapcode_constant_1.BelongsCreatedByRefField.includes(field === null || field === void 0 ? void 0 : field.type))) return [3 /*break*/, 6];
|
|
122
124
|
refField = field;
|
|
123
125
|
if (!refField.refCollection &&
|
|
124
126
|
[drapcode_constant_1.FieldTypes.createdBy.id, drapcode_constant_1.FieldTypes.updatedBy.id].includes(field.type)) {
|
|
@@ -163,6 +165,7 @@ var processDataEncryptionDecryption = function (data, encryption, decrypt) { ret
|
|
|
163
165
|
encryptionType = encryption.encryptionType, dataKey = encryption.dataKey;
|
|
164
166
|
if (!data)
|
|
165
167
|
return [2 /*return*/, data];
|
|
168
|
+
console.log("data :>> ", data);
|
|
166
169
|
_a = encryptionType;
|
|
167
170
|
switch (_a) {
|
|
168
171
|
case "KMS": return [3 /*break*/, 1];
|
|
@@ -17,7 +17,7 @@ var getSearchObjQuery = function (searchObj, searchQueryTypeObj, timezone) {
|
|
|
17
17
|
var searchAggregateQuery = [];
|
|
18
18
|
var likeQuery = [];
|
|
19
19
|
Object.entries(searchObj).forEach(function (_a) {
|
|
20
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
20
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
21
21
|
var key = _a[0], value = _a[1];
|
|
22
22
|
if (value) {
|
|
23
23
|
var searchQueryTypeKey = searchQueryTypeObj[key];
|
|
@@ -101,42 +101,59 @@ var getSearchObjQuery = function (searchObj, searchQueryTypeObj, timezone) {
|
|
|
101
101
|
if (key.startsWith("start_")) {
|
|
102
102
|
likeQuery.push((_o = {},
|
|
103
103
|
_o["_".concat(key)] = {
|
|
104
|
-
$gte: (0, date_util_1.timezoneDateParse)(value,
|
|
104
|
+
$gte: (0, date_util_1.timezoneDateParse)(value, false, true),
|
|
105
105
|
},
|
|
106
106
|
_o));
|
|
107
107
|
}
|
|
108
108
|
else if (key.startsWith("end_")) {
|
|
109
109
|
likeQuery.push((_p = {},
|
|
110
110
|
_p["_".concat(key)] = {
|
|
111
|
-
$lt: (0, date_util_1.timezoneDateParse)(value
|
|
111
|
+
$lt: (0, date_util_1.timezoneDateParse)(value),
|
|
112
112
|
},
|
|
113
113
|
_p));
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
+
else {
|
|
117
|
+
searchAggregateQuery.push({
|
|
118
|
+
$addFields: (_q = {},
|
|
119
|
+
_q["_".concat(key)] = { $toString: "$".concat(key) },
|
|
120
|
+
_q),
|
|
121
|
+
});
|
|
122
|
+
likeQuery.push((_r = {},
|
|
123
|
+
_r["_".concat(key)] = {
|
|
124
|
+
$gte: (0, date_util_1.timezoneDateParse)(value, false, true),
|
|
125
|
+
},
|
|
126
|
+
_r));
|
|
127
|
+
likeQuery.push((_s = {},
|
|
128
|
+
_s["_".concat(key)] = {
|
|
129
|
+
$lt: (0, date_util_1.timezoneDateParse)(value, false),
|
|
130
|
+
},
|
|
131
|
+
_s));
|
|
132
|
+
}
|
|
116
133
|
}
|
|
117
134
|
else {
|
|
118
135
|
// if input is string and db field type is number
|
|
119
136
|
// converting db field to string first
|
|
120
137
|
searchAggregateQuery.push({
|
|
121
|
-
$addFields: (
|
|
122
|
-
|
|
123
|
-
|
|
138
|
+
$addFields: (_t = {},
|
|
139
|
+
_t["_".concat(key)] = { $toString: "$".concat(key) },
|
|
140
|
+
_t),
|
|
124
141
|
});
|
|
125
|
-
likeQuery.push((
|
|
126
|
-
|
|
142
|
+
likeQuery.push((_u = {},
|
|
143
|
+
_u["_".concat(key)] = {
|
|
127
144
|
$regex: value,
|
|
128
145
|
$options: "i",
|
|
129
146
|
},
|
|
130
|
-
|
|
147
|
+
_u));
|
|
131
148
|
}
|
|
132
149
|
}
|
|
133
150
|
else {
|
|
134
|
-
likeQuery.push((
|
|
135
|
-
|
|
151
|
+
likeQuery.push((_v = {},
|
|
152
|
+
_v[key] = {
|
|
136
153
|
$regex: value,
|
|
137
154
|
$options: "i",
|
|
138
155
|
},
|
|
139
|
-
|
|
156
|
+
_v));
|
|
140
157
|
}
|
|
141
158
|
}
|
|
142
159
|
});
|
|
@@ -286,7 +286,7 @@ var prepareReturnObject = function (data, status, success, headers) {
|
|
|
286
286
|
};
|
|
287
287
|
};
|
|
288
288
|
var makeAxiosCall = function (projectId, methodType, url, axiosConfig, data, timeout, wrapJsonDataInArray, awsSignPluginConfig) { return __awaiter(void 0, void 0, void 0, function () {
|
|
289
|
-
var result, instance, dataArray_1, awsRes;
|
|
289
|
+
var result, instance, dataArray_1, payload, urlObj_1, awsRes, error_2;
|
|
290
290
|
return __generator(this, function (_a) {
|
|
291
291
|
switch (_a.label) {
|
|
292
292
|
case 0:
|
|
@@ -323,20 +323,38 @@ var makeAxiosCall = function (projectId, methodType, url, axiosConfig, data, tim
|
|
|
323
323
|
default:
|
|
324
324
|
break;
|
|
325
325
|
}
|
|
326
|
-
|
|
327
|
-
return [4 /*yield*/, (0, util_1.getAwsSignature)(axiosConfig, awsSignPluginConfig)];
|
|
326
|
+
_a.label = 1;
|
|
328
327
|
case 1:
|
|
328
|
+
_a.trys.push([1, 5, , 6]);
|
|
329
|
+
if (!awsSignPluginConfig) return [3 /*break*/, 3];
|
|
330
|
+
payload = JSON.stringify(data);
|
|
331
|
+
axiosConfig = __assign(__assign({}, axiosConfig), { data: payload });
|
|
332
|
+
if (axiosConfig.params) {
|
|
333
|
+
urlObj_1 = new URL(axiosConfig.url);
|
|
334
|
+
Object.entries(axiosConfig.params).forEach(function (_a) {
|
|
335
|
+
var key = _a[0], value = _a[1];
|
|
336
|
+
urlObj_1.searchParams.append(key, value);
|
|
337
|
+
});
|
|
338
|
+
axiosConfig.url = urlObj_1.toString();
|
|
339
|
+
}
|
|
340
|
+
return [4 /*yield*/, (0, util_1.getAwsSignature)(axiosConfig, awsSignPluginConfig)];
|
|
341
|
+
case 2:
|
|
329
342
|
awsRes = _a.sent();
|
|
330
343
|
if (awsRes.error)
|
|
331
344
|
return [2 /*return*/, awsRes.error];
|
|
332
|
-
axiosConfig = __assign(__assign({}, awsRes.data), {
|
|
333
|
-
_a.label =
|
|
334
|
-
case
|
|
345
|
+
axiosConfig = __assign(__assign({}, awsRes.data), { data: payload });
|
|
346
|
+
_a.label = 3;
|
|
347
|
+
case 3:
|
|
335
348
|
console.log("\n ==> Final axiosConfig for projectID: ".concat(projectId, ":>> "), axiosConfig);
|
|
336
349
|
return [4 /*yield*/, (0, axios_1.default)(__assign({}, axiosConfig))];
|
|
337
|
-
case
|
|
350
|
+
case 4:
|
|
338
351
|
result = _a.sent();
|
|
339
352
|
return [2 /*return*/, result];
|
|
353
|
+
case 5:
|
|
354
|
+
error_2 = _a.sent();
|
|
355
|
+
console.log("\n ===error", error_2);
|
|
356
|
+
return [2 /*return*/, error_2];
|
|
357
|
+
case 6: return [2 /*return*/];
|
|
340
358
|
}
|
|
341
359
|
});
|
|
342
360
|
}); };
|
package/build/utils/util.js
CHANGED
|
@@ -835,12 +835,16 @@ var toggleConsoleLogs = function (enable) {
|
|
|
835
835
|
exports.toggleConsoleLogs = toggleConsoleLogs;
|
|
836
836
|
// Utility function to replace '/' with '____'
|
|
837
837
|
var replaceSlashWithUnderscore = function (value) {
|
|
838
|
-
return value && value.
|
|
838
|
+
return value && typeof value === 'string' && value.includes('/')
|
|
839
|
+
? value.replace(/\//g, '____')
|
|
840
|
+
: value;
|
|
839
841
|
};
|
|
840
842
|
exports.replaceSlashWithUnderscore = replaceSlashWithUnderscore;
|
|
841
843
|
// Utility function to replace '____' with '/'
|
|
842
844
|
var replaceUnderscoreWithSlash = function (value) {
|
|
843
|
-
return value && value.
|
|
845
|
+
return value && typeof value === 'string' && value.includes('____')
|
|
846
|
+
? value.replace(/____/g, '/')
|
|
847
|
+
: value;
|
|
844
848
|
};
|
|
845
849
|
exports.replaceUnderscoreWithSlash = replaceUnderscoreWithSlash;
|
|
846
850
|
var capitalize = function (str, restToLower) {
|
|
@@ -1260,12 +1264,11 @@ var replaceValuesFromRequestMapping = function (dataArr, mappingArray) {
|
|
|
1260
1264
|
};
|
|
1261
1265
|
exports.replaceValuesFromRequestMapping = replaceValuesFromRequestMapping;
|
|
1262
1266
|
var getAwsSignature = function (axiosConfig, awsSignPluginConfig) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1263
|
-
var response, method, headers, url, data, parsedUrl,
|
|
1267
|
+
var response, method, headers, url, data, parsedUrl, accessKeyId, secretAccessKey, region, service, signedRequest;
|
|
1264
1268
|
return __generator(this, function (_a) {
|
|
1265
1269
|
response = { error: "", data: {} };
|
|
1266
1270
|
method = axiosConfig.method, headers = axiosConfig.headers, url = axiosConfig.url, data = axiosConfig.data;
|
|
1267
1271
|
parsedUrl = new URL(url);
|
|
1268
|
-
payload = JSON.stringify(data);
|
|
1269
1272
|
if (awsSignPluginConfig) {
|
|
1270
1273
|
accessKeyId = awsSignPluginConfig.accessKeyId, secretAccessKey = awsSignPluginConfig.secretAccessKey, region = awsSignPluginConfig.region, service = awsSignPluginConfig.service;
|
|
1271
1274
|
signedRequest = (0, aws4_1.sign)({
|
|
@@ -1274,9 +1277,10 @@ var getAwsSignature = function (axiosConfig, awsSignPluginConfig) { return __awa
|
|
|
1274
1277
|
region: region,
|
|
1275
1278
|
host: parsedUrl.host,
|
|
1276
1279
|
headers: headers,
|
|
1277
|
-
body:
|
|
1280
|
+
body: data,
|
|
1281
|
+
path: parsedUrl.pathname + parsedUrl.search,
|
|
1278
1282
|
}, { accessKeyId: accessKeyId, secretAccessKey: secretAccessKey });
|
|
1279
|
-
response.data = signedRequest;
|
|
1283
|
+
response.data = __assign(__assign({}, signedRequest), { url: url });
|
|
1280
1284
|
return [2 /*return*/, response];
|
|
1281
1285
|
}
|
|
1282
1286
|
else
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drapcode-utility",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"aws4": "^1.13.2",
|
|
41
41
|
"axios": "^1.1.2",
|
|
42
42
|
"dompurify": "^3.1.7",
|
|
43
|
-
"drapcode-constant": "^1.7.
|
|
43
|
+
"drapcode-constant": "^1.7.1",
|
|
44
44
|
"drapcode-logger": "^1.3.4",
|
|
45
|
-
"drapcode-redis": "^1.2.
|
|
45
|
+
"drapcode-redis": "^1.2.6",
|
|
46
46
|
"exiftool-vendored": "^28.2.1",
|
|
47
47
|
"express": "^4.17.1",
|
|
48
48
|
"gm": "^1.25.0",
|