drapcode-utility 1.8.5 → 1.8.7
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.
|
@@ -54,6 +54,7 @@ var voca_1 = __importDefault(require("voca"));
|
|
|
54
54
|
var checkForError = function (result, errors, mapping, status) { return __awaiter(void 0, void 0, void 0, function () {
|
|
55
55
|
var finalErrors, errorMsgPath, errorValue, fError, finalFinalStatus_1, finalMessage, finalMessages_1;
|
|
56
56
|
return __generator(this, function (_a) {
|
|
57
|
+
console.log("\n ==result", result);
|
|
57
58
|
finalErrors = [];
|
|
58
59
|
console.log("errors", errors);
|
|
59
60
|
if (errors && errors.length > 0) {
|
|
@@ -79,10 +80,7 @@ var checkForError = function (result, errors, mapping, status) { return __awaite
|
|
|
79
80
|
}
|
|
80
81
|
console.log("finalErrors", finalErrors);
|
|
81
82
|
if (finalErrors.length > 0) {
|
|
82
|
-
finalErrors =
|
|
83
|
-
"".concat(Number(err.status), "|").concat(err.message),
|
|
84
|
-
{ status: Number(err.status), message: err.message },
|
|
85
|
-
]; })).values());
|
|
83
|
+
finalErrors = removeDuplicateError(finalErrors);
|
|
86
84
|
finalFinalStatus_1 = 400;
|
|
87
85
|
finalMessage = "";
|
|
88
86
|
console.log("finalMessage", finalMessage);
|
|
@@ -111,6 +109,11 @@ var checkForError = function (result, errors, mapping, status) { return __awaite
|
|
|
111
109
|
});
|
|
112
110
|
}); };
|
|
113
111
|
exports.checkForError = checkForError;
|
|
112
|
+
var removeDuplicateError = function (finalErrors) {
|
|
113
|
+
// Remove duplicates based only on the message
|
|
114
|
+
var uniqueErrors = Array.from(new Map(finalErrors.map(function (err) { return [err.message.trim(), err]; })).values());
|
|
115
|
+
return uniqueErrors;
|
|
116
|
+
};
|
|
114
117
|
var handleMultErrorConfig = function (error, result, status) {
|
|
115
118
|
if (!error || Object.keys(error).length === 0) {
|
|
116
119
|
return null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const queryParser: (collectionName: string, query: any, constants: any[], externalParams: any, currentUser: any, timezone: string, searchObj: any, refCollectionFieldsInItems: any, searchQueryTypeObj: any, currentTenant: any, currentUserSetting: any, lookupConfig: any, rowLevelSecurityFilter: any) => Promise<
|
|
1
|
+
export declare const queryParser: (collectionName: string, query: any, constants: any[], externalParams: any, currentUser: any, timezone: string, searchObj: any, refCollectionFieldsInItems: any, searchQueryTypeObj: any, currentTenant: any, currentUserSetting: any, lookupConfig: any, rowLevelSecurityFilter: any) => Promise<any>;
|
|
2
2
|
export declare const isEntityInCondition: (value: any) => boolean;
|
|
3
3
|
export declare const isFixedValueQuery: (value: any) => boolean;
|
|
4
4
|
export declare const getMinMaxValue: (value: any) => {
|
|
@@ -63,7 +63,7 @@ var queryParser = function (collectionName, query, constants, externalParams, cu
|
|
|
63
63
|
if (currentUserSetting === void 0) { currentUserSetting = {}; }
|
|
64
64
|
if (lookupConfig === void 0) { lookupConfig = []; }
|
|
65
65
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
66
|
-
var filterQuery, rlsFilterQuery, aggregateQuery, queryStr, searchQueryObj, _a, searchAggregateQuery, likeQuery, finalQuery, _b, searchAggregateQuery, likeQuery, projection, finder, sortBy, orderBy, offset, limit, resetLimit, direction
|
|
66
|
+
var filterQuery, rlsFilterQuery, aggregateQuery, queryStr, searchQueryObj, _a, searchAggregateQuery, likeQuery, finalQuery, _b, searchAggregateQuery, likeQuery, projection, finder, sortBy, orderBy, offset, limit, resetLimit, direction;
|
|
67
67
|
var _c, _d, _e;
|
|
68
68
|
return __generator(this, function (_f) {
|
|
69
69
|
switch (_f.label) {
|
|
@@ -166,11 +166,7 @@ var queryParser = function (collectionName, query, constants, externalParams, cu
|
|
|
166
166
|
aggregateQuery.push({ $skip: +offset }, { $limit: +limit });
|
|
167
167
|
}
|
|
168
168
|
console.log("==> aggregateQuery", aggregateQuery);
|
|
169
|
-
|
|
170
|
-
queryStr = ".aggregate(".concat(JSON.stringify(aggregateQuery), ", { collation: { locale: \"en\" }, allowDiskUse: true })");
|
|
171
|
-
str = "req.db.collection('".concat(collectionName, "')").concat(queryStr);
|
|
172
|
-
str += ".toArray()";
|
|
173
|
-
return [2 /*return*/, str];
|
|
169
|
+
return [2 /*return*/, aggregateQuery];
|
|
174
170
|
}
|
|
175
171
|
});
|
|
176
172
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const queryParserNew: (collectionName: string, query: any, constants: any[], externalParams: any, currentUser: any, timezone: string, searchObj?: any, refCollectionFieldsInItems?: any, searchQueryTypeObj?: any, lookupConfig?: any) => Promise<
|
|
1
|
+
export declare const queryParserNew: (collectionName: string, query: any, constants: any[], externalParams: any, currentUser: any, timezone: string, searchObj?: any, refCollectionFieldsInItems?: any, searchQueryTypeObj?: any, lookupConfig?: any) => Promise<any>;
|
|
@@ -57,7 +57,7 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
|
|
|
57
57
|
if (searchQueryTypeObj === void 0) { searchQueryTypeObj = {}; }
|
|
58
58
|
if (lookupConfig === void 0) { lookupConfig = []; }
|
|
59
59
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
60
|
-
var filterQuery, aggregateQuery, queryStr, searchQueryObj_1, finalQuery, likeQuery_1, projection, finder, sortBy, orderBy, aggregateFunctionField, offset, limit, direction
|
|
60
|
+
var filterQuery, aggregateQuery, queryStr, searchQueryObj_1, finalQuery, likeQuery_1, projection, finder, sortBy, orderBy, aggregateFunctionField, offset, limit, direction;
|
|
61
61
|
var _a;
|
|
62
62
|
return __generator(this, function (_b) {
|
|
63
63
|
switch (_b.label) {
|
|
@@ -256,10 +256,8 @@ var queryParserNew = function (collectionName, query, constants, externalParams,
|
|
|
256
256
|
if (finder != "COUNT" && limit) {
|
|
257
257
|
aggregateQuery.push({ $skip: +offset }, { $limit: +limit });
|
|
258
258
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
str += ".toArray()";
|
|
262
|
-
return [2 /*return*/, str];
|
|
259
|
+
console.log("==> aggregateQuery", JSON.stringify(aggregateQuery, null, 2));
|
|
260
|
+
return [2 /*return*/, aggregateQuery];
|
|
263
261
|
}
|
|
264
262
|
});
|
|
265
263
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drapcode-utility",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.7",
|
|
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.
|
|
40
|
+
"drapcode-constant": "^1.6.5",
|
|
41
|
+
"drapcode-logger": "^1.3.1",
|
|
42
|
+
"drapcode-redis": "^1.2.0",
|
|
43
43
|
"exiftool-vendored": "^28.2.1",
|
|
44
44
|
"express": "^4.17.1",
|
|
45
45
|
"gm": "^1.25.0",
|