drapcode-utility 1.0.2 → 1.0.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/utils/query-parser.js +41 -35
- package/package.json +1 -1
|
@@ -324,7 +324,7 @@ var modifyQuery = function (obj, hasAndQueryConjunction) {
|
|
|
324
324
|
return arr;
|
|
325
325
|
};
|
|
326
326
|
var queryToMongo = function (query, requiredExternal, externalParams, constants, currentUser, currentTenant, timezone) {
|
|
327
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y
|
|
327
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
328
328
|
if (currentUser === void 0) { currentUser = {}; }
|
|
329
329
|
if (currentTenant === void 0) { currentTenant = {}; }
|
|
330
330
|
var fieldValue = replaceExternalParams(query, requiredExternal, externalParams, constants, currentUser, currentTenant, timezone);
|
|
@@ -393,66 +393,72 @@ var queryToMongo = function (query, requiredExternal, externalParams, constants,
|
|
|
393
393
|
return _o = {}, _o[field] = { $nin: fieldValue || [] }, _o;
|
|
394
394
|
}
|
|
395
395
|
if (key === drapcode_constant_1.EQUALS && isDate) {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
396
|
+
return _p = {},
|
|
397
|
+
_p[field] = {
|
|
398
|
+
$gte: fieldValue,
|
|
399
|
+
$lt: date_util_1.nextDayDate(fieldValue),
|
|
400
|
+
},
|
|
401
|
+
_p;
|
|
402
|
+
// Todo: Remove this if works properly
|
|
403
|
+
// if (DateConstant.some((cnst) => value.includes(cnst))) {
|
|
404
|
+
// return {
|
|
405
|
+
// [field]: {
|
|
406
|
+
// $gte: fieldValue,
|
|
407
|
+
// },
|
|
408
|
+
// };
|
|
409
|
+
// } else {
|
|
410
|
+
// //TODO: Handle timezone here
|
|
411
|
+
// return {
|
|
412
|
+
// [field]: {
|
|
413
|
+
// $gte: fieldValue,
|
|
414
|
+
// $lt: new Date(nextDayDate(fieldValue)),
|
|
415
|
+
// },
|
|
416
|
+
// };
|
|
417
|
+
// }
|
|
412
418
|
}
|
|
413
419
|
if (key == drapcode_constant_1.EQUALS && field === "createdBy")
|
|
414
420
|
return {
|
|
415
421
|
$and: [
|
|
416
|
-
(
|
|
417
|
-
(
|
|
418
|
-
(
|
|
422
|
+
(_q = {}, _q[field] = { $ne: null }, _q),
|
|
423
|
+
(_r = {}, _r[field] = { $ne: "" }, _r),
|
|
424
|
+
(_s = {}, _s[field] = { $eq: fieldValue }, _s),
|
|
419
425
|
],
|
|
420
426
|
};
|
|
421
427
|
if (key == drapcode_constant_1.EQUALS && fieldType === "boolean" && fieldValue)
|
|
422
428
|
return JSON.parse(fieldValue)
|
|
423
|
-
? (
|
|
424
|
-
|
|
425
|
-
|
|
429
|
+
? (_t = {},
|
|
430
|
+
_t[field] = JSON.parse(fieldValue),
|
|
431
|
+
_t) : {
|
|
426
432
|
$or: [
|
|
427
|
-
(
|
|
428
|
-
(
|
|
433
|
+
(_u = {}, _u[field] = JSON.parse(fieldValue), _u),
|
|
434
|
+
(_v = {}, _v[field] = { $exists: false }, _v),
|
|
429
435
|
],
|
|
430
436
|
};
|
|
431
437
|
if (key == drapcode_constant_1.EQUALS) {
|
|
432
|
-
return
|
|
433
|
-
|
|
438
|
+
return _w = {},
|
|
439
|
+
_w[field] = fieldType === "boolean" && fieldValue
|
|
434
440
|
? JSON.parse(fieldValue)
|
|
435
441
|
: !isNaN(fieldValue)
|
|
436
442
|
? +fieldValue
|
|
437
443
|
: fieldValue,
|
|
438
|
-
|
|
444
|
+
_w;
|
|
439
445
|
}
|
|
440
446
|
if (key == drapcode_constant_1.NOT_EQUAL)
|
|
441
|
-
return
|
|
442
|
-
|
|
447
|
+
return _x = {},
|
|
448
|
+
_x[field] = {
|
|
443
449
|
$ne: fieldType === "boolean" && fieldValue
|
|
444
450
|
? JSON.parse(fieldValue)
|
|
445
451
|
: fieldValue,
|
|
446
452
|
},
|
|
447
|
-
|
|
453
|
+
_x;
|
|
448
454
|
if (key == drapcode_constant_1.BETWEEN) {
|
|
449
|
-
var
|
|
450
|
-
return
|
|
451
|
-
|
|
455
|
+
var _z = exports.getMinMaxValue(fieldValue), startValue = _z.startValue, endValue = _z.endValue, isInteger = _z.isInteger;
|
|
456
|
+
return _y = {},
|
|
457
|
+
_y[field] = {
|
|
452
458
|
$gte: isInteger ? +startValue : startValue,
|
|
453
459
|
$lte: isInteger ? +endValue : endValue,
|
|
454
460
|
},
|
|
455
|
-
|
|
461
|
+
_y;
|
|
456
462
|
}
|
|
457
463
|
};
|
|
458
464
|
var isEntityInCondition = function (value) {
|