drapcode-utility 1.9.2 → 1.9.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.
|
@@ -128,7 +128,6 @@ var handleMultErrorConfig = function (error, result, status) {
|
|
|
128
128
|
console.log("handleMultErrorConfig result :>> ".concat(Object.keys(result)));
|
|
129
129
|
apiErrorMessage = lodash_1.default.get(result, message);
|
|
130
130
|
if (apiErrorMessage) {
|
|
131
|
-
console.log("*** utility 3 ***");
|
|
132
131
|
if (typeof apiErrorMessage == "string") {
|
|
133
132
|
console.log("It's string so leave");
|
|
134
133
|
}
|
|
@@ -145,16 +144,13 @@ var handleMultErrorConfig = function (error, result, status) {
|
|
|
145
144
|
apiErrorValue = lodash_1.default.get(result, path);
|
|
146
145
|
}
|
|
147
146
|
else {
|
|
148
|
-
console.log("*** utility 7 ***");
|
|
149
147
|
apiErrorValue = status;
|
|
150
148
|
}
|
|
151
|
-
console.log("*** utility 8 ***");
|
|
152
149
|
}
|
|
153
150
|
else {
|
|
154
151
|
console.log("result", result);
|
|
155
152
|
apiErrorValue = status;
|
|
156
153
|
}
|
|
157
|
-
console.log("apiErrorValue", apiErrorValue);
|
|
158
154
|
apiErrorValue = "".concat(apiErrorValue);
|
|
159
155
|
console.log("apiErrorMessage", apiErrorMessage);
|
|
160
156
|
console.log("apiErrorValue", apiErrorValue);
|
|
@@ -165,7 +161,6 @@ var handleMultErrorConfig = function (error, result, status) {
|
|
|
165
161
|
};
|
|
166
162
|
}
|
|
167
163
|
else if (["false", "error", "fail", "failed"].includes(apiErrorValue.toLowerCase())) {
|
|
168
|
-
console.log("*** utility 9 ***");
|
|
169
164
|
return {
|
|
170
165
|
status: 400,
|
|
171
166
|
message: apiErrorMessage,
|
|
@@ -174,8 +169,6 @@ var handleMultErrorConfig = function (error, result, status) {
|
|
|
174
169
|
else if (voca_1.default.startsWith(apiErrorValue, "3") ||
|
|
175
170
|
voca_1.default.startsWith(apiErrorValue, "4") ||
|
|
176
171
|
voca_1.default.startsWith(apiErrorValue, "5")) {
|
|
177
|
-
console.log("*** utility 10 ***");
|
|
178
|
-
console.log("Compare 4");
|
|
179
172
|
return {
|
|
180
173
|
status: apiErrorValue,
|
|
181
174
|
message: apiErrorMessage,
|
|
@@ -73,16 +73,8 @@ var queryParser = function (collectionName, query, constants, externalParams, cu
|
|
|
73
73
|
if (!query)
|
|
74
74
|
return [2 /*return*/, ""];
|
|
75
75
|
console.log("***1*** queryParser ***");
|
|
76
|
-
console.log("%%%%% refCollectionFieldsInItems", JSON.stringify(refCollectionFieldsInItems));
|
|
77
|
-
console.log("%%%% timezone", timezone);
|
|
78
|
-
console.log("collectionName", collectionName);
|
|
79
|
-
console.log("query", JSON.stringify(query));
|
|
80
|
-
console.log("constants", JSON.stringify(constants));
|
|
81
|
-
console.log("externalParams", JSON.stringify(externalParams));
|
|
82
|
-
console.log("currentUser", JSON.stringify(currentUser));
|
|
83
|
-
console.log("searchObj", JSON.stringify(searchObj));
|
|
84
|
-
console.log("searchQueryTypeObj", JSON.stringify(searchQueryTypeObj));
|
|
85
76
|
filterQuery = mongoFilterQuery(query, externalParams, constants, currentUser, currentTenant, currentUserSetting, timezone);
|
|
77
|
+
console.log("**************************");
|
|
86
78
|
console.log("filterQuery", JSON.stringify(filterQuery));
|
|
87
79
|
rlsFilterQuery = [];
|
|
88
80
|
if (rowLevelSecurityFilter && rowLevelSecurityFilter.conditions.length) {
|
|
@@ -100,13 +92,10 @@ var queryParser = function (collectionName, query, constants, externalParams, cu
|
|
|
100
92
|
if (searchObj) {
|
|
101
93
|
_a = getSearchObjQuery(searchObj, searchQueryTypeObj, timezone), searchAggregateQuery = _a.searchAggregateQuery, likeQuery = _a.likeQuery;
|
|
102
94
|
aggregateQuery = __spreadArray(__spreadArray([], aggregateQuery, true), searchAggregateQuery, true);
|
|
103
|
-
console.log("likeQuery after getSearchObjQuery", JSON.stringify(likeQuery));
|
|
104
95
|
if (likeQuery && likeQuery.length > 0) {
|
|
105
96
|
searchQueryObj = likeQuery;
|
|
106
97
|
}
|
|
107
98
|
}
|
|
108
|
-
console.log("aggregateQuery After search object condition", JSON.stringify(aggregateQuery));
|
|
109
|
-
console.log("searchQueryObj", JSON.stringify(searchQueryObj));
|
|
110
99
|
finalQuery = { $and: filterQuery };
|
|
111
100
|
if (rlsFilterQuery.length &&
|
|
112
101
|
((rlsFilterQuery[0].$or && rlsFilterQuery[0].$or.length) ||
|
|
@@ -116,18 +105,15 @@ var queryParser = function (collectionName, query, constants, externalParams, cu
|
|
|
116
105
|
if (searchQueryObj) {
|
|
117
106
|
(_d = finalQuery.$and).push.apply(_d, searchQueryObj);
|
|
118
107
|
}
|
|
119
|
-
console.log("finalQuery after", JSON.stringify(finalQuery));
|
|
120
108
|
aggregateQuery.push({ $match: finalQuery });
|
|
121
109
|
}
|
|
122
110
|
else if (searchObj) {
|
|
123
|
-
console.log("I donot have filter query");
|
|
124
111
|
_b = getSearchObjQuery(searchObj, searchQueryTypeObj, timezone), searchAggregateQuery = _b.searchAggregateQuery, likeQuery = _b.likeQuery;
|
|
125
112
|
aggregateQuery = __spreadArray(__spreadArray([], aggregateQuery, true), searchAggregateQuery, true);
|
|
126
113
|
if (likeQuery.length) {
|
|
127
114
|
aggregateQuery.push({ $match: { $and: likeQuery } });
|
|
128
115
|
}
|
|
129
116
|
}
|
|
130
|
-
console.log("aggregateQuery", JSON.stringify(aggregateQuery));
|
|
131
117
|
console.log("==> query", query);
|
|
132
118
|
console.log("lookupConfig", lookupConfig);
|
|
133
119
|
projection = mongoSelectQuery(query);
|
|
@@ -443,8 +429,9 @@ var queryToMongo = function (query, requiredExternal, externalParams, constants,
|
|
|
443
429
|
if (fieldType === "number") {
|
|
444
430
|
return _6 = {}, _6[field] = +fieldValue, _6;
|
|
445
431
|
}
|
|
446
|
-
|
|
447
|
-
|
|
432
|
+
else {
|
|
433
|
+
return _7 = {}, _7[field] = fieldValue, _7;
|
|
434
|
+
}
|
|
448
435
|
}
|
|
449
436
|
if (key === drapcode_constant_1.EQUALS_OR_IGNORE) {
|
|
450
437
|
if (fieldType === "boolean") {
|
|
@@ -202,10 +202,13 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
|
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
});
|
|
205
|
+
console.log("==> aggregateQuery", aggregateQuery);
|
|
206
|
+
console.log("==> likeQuery", likeQuery_1);
|
|
205
207
|
if (likeQuery_1.length) {
|
|
206
208
|
aggregateQuery.push({ $match: { $and: likeQuery_1 } });
|
|
207
209
|
}
|
|
208
210
|
}
|
|
211
|
+
console.log("==> query", query);
|
|
209
212
|
projection = mongoSelectQuery(query);
|
|
210
213
|
finder = query.finder, sortBy = query.sortBy, orderBy = query.orderBy, aggregateFunctionField = query.aggregateFunctionField;
|
|
211
214
|
if (!(finder != "COUNT" && refCollectionFieldsInItems)) return [3 /*break*/, 2];
|
|
@@ -501,8 +504,9 @@ var queryToMongo = function (query, requiredExternal, externalParams, constants,
|
|
|
501
504
|
if (fieldType === "number") {
|
|
502
505
|
return _8 = {}, _8[field] = +fieldValue, _8;
|
|
503
506
|
}
|
|
504
|
-
|
|
505
|
-
|
|
507
|
+
else {
|
|
508
|
+
return _9 = {}, _9[field] = fieldValue, _9;
|
|
509
|
+
}
|
|
506
510
|
}
|
|
507
511
|
if (key === drapcode_constant_1.EQUALS_OR_IGNORE) {
|
|
508
512
|
if (fieldType === "boolean") {
|
|
@@ -616,16 +620,20 @@ var replaceExternalParams = function (query, requiredExternal, externalParams, c
|
|
|
616
620
|
else
|
|
617
621
|
return "".concat(startValue_1, "---").concat(endValue_1);
|
|
618
622
|
}
|
|
623
|
+
console.log("==> value", value);
|
|
624
|
+
console.log("==> currentUser", currentUser);
|
|
619
625
|
if (value.includes(drapcode_constant_1.CURRENT_USER)) {
|
|
620
626
|
if (value === drapcode_constant_1.CURRENT_USER) {
|
|
621
627
|
return currentUser["uuid"];
|
|
622
628
|
}
|
|
623
629
|
var splitValues = value.split("::");
|
|
630
|
+
console.log("splitValues", splitValues);
|
|
624
631
|
var refCollection = splitValues[1];
|
|
625
632
|
var refCollectionField = splitValues[2];
|
|
626
633
|
if (refCollection && refCollectionField) {
|
|
627
634
|
console.log("I have refCollection and Field");
|
|
628
635
|
var refCollectionData = currentUser[refCollection];
|
|
636
|
+
console.log("refCollectionData", refCollectionData);
|
|
629
637
|
if (!refCollectionData) {
|
|
630
638
|
return "";
|
|
631
639
|
}
|
package/build/utils/util.js
CHANGED
|
@@ -298,34 +298,28 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, u
|
|
|
298
298
|
var _a;
|
|
299
299
|
var contentList = (_a = expression
|
|
300
300
|
.match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
|
|
301
|
-
console.log("1 replaceDataValueIntoExpression");
|
|
302
301
|
contentList === null || contentList === void 0 ? void 0 : contentList.forEach(function (prop) {
|
|
303
302
|
var needle = "{{".concat(prop, "}}");
|
|
304
|
-
console.log("needle :>> ", needle);
|
|
305
303
|
var dataOfItem = "";
|
|
306
304
|
if (prop.includes("current_user")) {
|
|
307
|
-
console.log("Current User");
|
|
308
305
|
prop = prop.replace("current_user.", "");
|
|
309
306
|
if (Object.keys(user).length > 0) {
|
|
310
307
|
dataOfItem = (0, exports.parseValueFromData)(user, prop);
|
|
311
308
|
}
|
|
312
309
|
}
|
|
313
310
|
else if (prop.includes("current_tenant")) {
|
|
314
|
-
console.log("Current Tenant");
|
|
315
311
|
prop = prop.replace("current_tenant.", "");
|
|
316
312
|
if (Object.keys(tenant).length > 0) {
|
|
317
313
|
dataOfItem = (0, exports.parseValueFromData)(tenant, prop);
|
|
318
314
|
}
|
|
319
315
|
}
|
|
320
316
|
else if (prop.includes("current_settings")) {
|
|
321
|
-
console.log("Current Setting");
|
|
322
317
|
prop = prop.replace("current_settings.", "");
|
|
323
318
|
if (Object.keys(userSetting).length > 0) {
|
|
324
319
|
dataOfItem = (0, exports.parseValueFromData)(userSetting, prop);
|
|
325
320
|
}
|
|
326
321
|
}
|
|
327
322
|
else if (prop.includes("current_session")) {
|
|
328
|
-
console.log("Current Session");
|
|
329
323
|
prop = prop.replace("current_session.", "");
|
|
330
324
|
if (Object.keys(sessionValue).length > 0) {
|
|
331
325
|
//Session will contain multi level data
|
|
@@ -333,7 +327,6 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, u
|
|
|
333
327
|
}
|
|
334
328
|
}
|
|
335
329
|
else if (prop.includes("form_data_session")) {
|
|
336
|
-
console.log("Form Data Session");
|
|
337
330
|
prop = prop.replace("form_data_session.", "");
|
|
338
331
|
if (Object.keys(sessionFormValue).length > 0) {
|
|
339
332
|
//Form Session will contain multi level data
|
|
@@ -341,7 +334,6 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, u
|
|
|
341
334
|
}
|
|
342
335
|
}
|
|
343
336
|
else if (prop.includes("SESSION_STORAGE")) {
|
|
344
|
-
console.log("Session Storage");
|
|
345
337
|
prop = prop.replace("SESSION_STORAGE.", "");
|
|
346
338
|
if (Object.keys(sessionValue).length > 0) {
|
|
347
339
|
//Session will contain multi level data
|
|
@@ -349,7 +341,6 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, u
|
|
|
349
341
|
}
|
|
350
342
|
}
|
|
351
343
|
else if (prop.includes("LOCAL_STORAGE")) {
|
|
352
|
-
console.log("Local Storage");
|
|
353
344
|
prop = prop.replace("LOCAL_STORAGE.", "");
|
|
354
345
|
if (Object.keys(localStorageValue).length > 0) {
|
|
355
346
|
//Session will contain multi level data
|
|
@@ -357,7 +348,6 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, u
|
|
|
357
348
|
}
|
|
358
349
|
}
|
|
359
350
|
else if (prop.includes("COOKIES")) {
|
|
360
|
-
console.log("Cookies");
|
|
361
351
|
prop = prop.replace("COOKIES.", "");
|
|
362
352
|
if (Object.keys(cookiesValue).length > 0) {
|
|
363
353
|
//Session will contain multi level data
|
|
@@ -365,7 +355,6 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, u
|
|
|
365
355
|
}
|
|
366
356
|
}
|
|
367
357
|
else if (prop.includes("environment_variable")) {
|
|
368
|
-
console.log("Environment Variable");
|
|
369
358
|
prop = prop.replace("environment_variable.", "");
|
|
370
359
|
if (Object.keys(envConstants).length > 0) {
|
|
371
360
|
var selectedConstant = envConstants.find(function (constant) { return constant.name === prop; });
|
|
@@ -373,16 +362,11 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, u
|
|
|
373
362
|
}
|
|
374
363
|
}
|
|
375
364
|
else {
|
|
376
|
-
console.log("Nothing Matches");
|
|
377
365
|
if (Object.keys(data).length > 0) {
|
|
378
366
|
dataOfItem = (0, exports.parseValueFromData)(data, prop);
|
|
379
|
-
//TODO: Need better way
|
|
380
|
-
delete data[prop];
|
|
381
367
|
}
|
|
382
368
|
}
|
|
383
|
-
console.log("dataOfItem :>> ", dataOfItem);
|
|
384
369
|
expression = replaceValueInExpression(needle, dataOfItem, expression);
|
|
385
|
-
console.log("expression :>> ", expression);
|
|
386
370
|
});
|
|
387
371
|
return expression;
|
|
388
372
|
};
|
|
@@ -441,7 +425,6 @@ var parseValueFromData = function (data, fieldName) {
|
|
|
441
425
|
else {
|
|
442
426
|
value = data ? data[fieldName] : "";
|
|
443
427
|
}
|
|
444
|
-
console.log("value :>> ", value);
|
|
445
428
|
if (value && Array.isArray(value) && typeof value[0] === "string") {
|
|
446
429
|
return value.join(", ");
|
|
447
430
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drapcode-utility",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"@types/voca": "^1.4.2",
|
|
38
38
|
"axios": "^1.1.2",
|
|
39
39
|
"dompurify": "^3.1.7",
|
|
40
|
-
"drapcode-constant": "^1.6.
|
|
41
|
-
"drapcode-logger": "^1.3.
|
|
42
|
-
"drapcode-redis": "^1.2.
|
|
40
|
+
"drapcode-constant": "^1.6.7",
|
|
41
|
+
"drapcode-logger": "^1.3.3",
|
|
42
|
+
"drapcode-redis": "^1.2.3",
|
|
43
43
|
"exiftool-vendored": "^28.2.1",
|
|
44
44
|
"express": "^4.17.1",
|
|
45
45
|
"gm": "^1.25.0",
|