drapcode-utility 1.0.2 → 1.0.4

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.
@@ -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, _z;
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
- if (drapcode_constant_1.DateConstant.some(function (cnst) { return value.includes(cnst); })) {
397
- return _p = {},
398
- _p[field] = {
399
- $gte: fieldValue,
400
- },
401
- _p;
402
- }
403
- else {
404
- //TODO: Handle timezone here
405
- return _q = {},
406
- _q[field] = {
407
- $gte: fieldValue,
408
- $lt: new Date(date_util_1.nextDayDate(fieldValue)),
409
- },
410
- _q;
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
- (_r = {}, _r[field] = { $ne: null }, _r),
417
- (_s = {}, _s[field] = { $ne: "" }, _s),
418
- (_t = {}, _t[field] = { $eq: fieldValue }, _t),
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
- ? (_u = {},
424
- _u[field] = JSON.parse(fieldValue),
425
- _u) : {
429
+ ? (_t = {},
430
+ _t[field] = JSON.parse(fieldValue),
431
+ _t) : {
426
432
  $or: [
427
- (_v = {}, _v[field] = JSON.parse(fieldValue), _v),
428
- (_w = {}, _w[field] = { $exists: false }, _w),
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 _x = {},
433
- _x[field] = fieldType === "boolean" && fieldValue
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
- _x;
444
+ _w;
439
445
  }
440
446
  if (key == drapcode_constant_1.NOT_EQUAL)
441
- return _y = {},
442
- _y[field] = {
447
+ return _x = {},
448
+ _x[field] = {
443
449
  $ne: fieldType === "boolean" && fieldValue
444
450
  ? JSON.parse(fieldValue)
445
451
  : fieldValue,
446
452
  },
447
- _y;
453
+ _x;
448
454
  if (key == drapcode_constant_1.BETWEEN) {
449
- var _0 = exports.getMinMaxValue(fieldValue), startValue = _0.startValue, endValue = _0.endValue, isInteger = _0.isInteger;
450
- return _z = {},
451
- _z[field] = {
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
- _z;
461
+ _y;
456
462
  }
457
463
  };
458
464
  var isEntityInCondition = function (value) {
@@ -738,7 +744,7 @@ var getSearchObjQuery = function (searchObj, searchQueryTypeObj, timezone) {
738
744
  },
739
745
  _j));
740
746
  }
741
- else if (["date", "createdAt"].includes(searchQueryTypeKey)) {
747
+ else if (["date", "createdAt", "time_slot"].includes(searchQueryTypeKey)) {
742
748
  if (key.startsWith("start_") || key.startsWith("end_")) {
743
749
  var fieldKey = key.replace("start_", "");
744
750
  fieldKey = fieldKey.replace("end_", "");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drapcode-utility",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",