drapcode-utility 2.6.3 → 2.6.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.
@@ -326,8 +326,12 @@ const conditionToQuery = (query, requiredExternal, externalParams, constants, ti
326
326
  const { startValue, endValue, isInteger } = (0, query_utils_1.getMinMaxValue)(fieldValue);
327
327
  return {
328
328
  [field]: {
329
- $gte: isInteger ? +startValue : startValue,
330
- $lte: isInteger ? +endValue : endValue,
329
+ $gte: isInteger
330
+ ? +startValue
331
+ : prepareBetweenValues(startValue, fieldType),
332
+ $lte: isInteger
333
+ ? +endValue
334
+ : prepareBetweenValues(endValue, fieldType),
331
335
  },
332
336
  };
333
337
  }
@@ -461,7 +465,7 @@ const changeExternalParams = (query, requiredExternal, externalParams, constants
461
465
  else {
462
466
  const resolveValue = (val) => {
463
467
  if ([drapcode_constant_1.CURRENT_USER, ...drapcode_constant_1.DateConstant].some((cnst) => val.includes?.(cnst))) {
464
- return (0, query_utils_1.getValueOfProjectConstant)(val, user, timezone);
468
+ return (0, query_utils_1.getValueOfProjectConstant)(val, user, timezone, fieldType);
465
469
  }
466
470
  else if (!isFixedValue) {
467
471
  const found = constants.find((constant) => constant.name === val);
@@ -575,3 +579,8 @@ const prepareBooleanQuery = (field, fieldValue) => {
575
579
  $or: [{ [field]: boolVal }, { [field]: { $exists: false } }],
576
580
  };
577
581
  };
582
+ const prepareBetweenValues = (value, fieldType) => {
583
+ if (["createdat", "updatedat", ...drapcode_constant_1.systemDateField].includes(fieldType))
584
+ return new Date(value);
585
+ return value;
586
+ };
@@ -23,7 +23,7 @@ export declare const DATE_REGEX: RegExp;
23
23
  export declare const createLoggerDateFormat: (timezone?: string) => string;
24
24
  export declare const createLoggerPreviousDateFormat: () => string;
25
25
  export declare const createLogsDateFormat: (timezone?: string) => string;
26
- export declare const getDateValue: (value: string, timezone?: string) => string;
26
+ export declare const getDateValue: (value: string, timezone?: string, fieldType?: string) => string;
27
27
  export declare const getDateRangeValue: (key: string, field: string, value: string) => DateRangeValue;
28
28
  export declare const nextDayDate: (date: string | Date) => string;
29
29
  export declare const timezoneDateParse: (value: string, nextDay?: boolean, prevDay?: boolean) => Date;
@@ -47,11 +47,11 @@ const createLogsDateFormat = (timezone) => {
47
47
  }
48
48
  };
49
49
  exports.createLogsDateFormat = createLogsDateFormat;
50
- const getDateValue = (value, timezone) => {
50
+ const getDateValue = (value, timezone, fieldType = "datetime-local") => {
51
51
  try {
52
52
  if (!value)
53
53
  return (0, exports.createLogsDateFormat)(timezone);
54
- const dateFormat = "YYYY-MM-DDTHH:mm:ss.SSS";
54
+ const dateFormat = fieldType === "date" ? "YYYY-MM-DD" : "YYYY-MM-DDTHH:mm:ss.SSS";
55
55
  const [type, number, unit] = value.split(":");
56
56
  if (!["ADD", "SUB"].includes(type)) {
57
57
  return (0, exports.createLogsDateFormat)(timezone);
@@ -17,4 +17,4 @@ export declare const getMinMaxValue: (value: any) => {
17
17
  isInteger?: undefined;
18
18
  };
19
19
  export declare const isFixedValueQuery: (value: any) => boolean;
20
- export declare const getValueOfProjectConstant: (value: any, currentUser: any, timezone: string) => any;
20
+ export declare const getValueOfProjectConstant: (value: any, currentUser: any, timezone: string, fieldType?: string) => any;
@@ -242,7 +242,7 @@ const isFixedValueQuery = (value) => {
242
242
  return isFixeValue;
243
243
  };
244
244
  exports.isFixedValueQuery = isFixedValueQuery;
245
- const getValueOfProjectConstant = (value, currentUser, timezone) => {
245
+ const getValueOfProjectConstant = (value, currentUser, timezone, fieldType = "datetime-local") => {
246
246
  if (!timezone)
247
247
  timezone = "(GMT+5:30)";
248
248
  timezone = timezone.substring(4, 10);
@@ -254,7 +254,7 @@ const getValueOfProjectConstant = (value, currentUser, timezone) => {
254
254
  if ([drapcode_constant_1.CURRENT_TIME, drapcode_constant_1.CURRENT_DATE_TIME].includes(value))
255
255
  result = (0, date_util_1.createLogsDateFormat)(timezone);
256
256
  if (drapcode_constant_1.DateTimeUnit.some((cnst) => value.includes(cnst)))
257
- result = (0, date_util_1.getDateValue)(value, timezone);
257
+ result = (0, date_util_1.getDateValue)(value, timezone, fieldType);
258
258
  return result;
259
259
  };
260
260
  exports.getValueOfProjectConstant = getValueOfProjectConstant;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drapcode-utility",
3
- "version": "2.6.3",
3
+ "version": "2.6.4",
4
4
  "description": "DrapCode Utility",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",