@litepos/autoquery 5.0.6 → 5.0.8

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/dist/index.d.ts CHANGED
@@ -95,6 +95,7 @@ declare enum StringOperators {
95
95
  StartsWith = 2,
96
96
  EndsWith = 3,
97
97
  Like = 4,
98
+ EqualTo = 5,
98
99
  }
99
100
  declare enum ArrayOperators {
100
101
  In = 0,
package/dist/index.js CHANGED
@@ -44,6 +44,7 @@ let StringOperators = /* @__PURE__ */ function(StringOperators$1) {
44
44
  StringOperators$1[StringOperators$1["StartsWith"] = 2] = "StartsWith";
45
45
  StringOperators$1[StringOperators$1["EndsWith"] = 3] = "EndsWith";
46
46
  StringOperators$1[StringOperators$1["Like"] = 4] = "Like";
47
+ StringOperators$1[StringOperators$1["EqualTo"] = 5] = "EqualTo";
47
48
  return StringOperators$1;
48
49
  }({});
49
50
  let ArrayOperators = /* @__PURE__ */ function(ArrayOperators$1) {
@@ -89,12 +90,20 @@ let MonthValues = /* @__PURE__ */ function(MonthValues$1) {
89
90
  MonthValues$1["Dec"] = "-12-";
90
91
  return MonthValues$1;
91
92
  }({});
93
+ const DATE_OPERATORS = [
94
+ "GreaterThan",
95
+ "GreaterThanOrEqualTo",
96
+ "LessThan",
97
+ "LessThanOrEqualTo"
98
+ ];
99
+ const DATE_REGEX = /^\d{4}-\d{2}-\d{2}(?:[ T]\d{2}:\d{2}:\d{2})?$/;
92
100
  var QueryBuilder = class {
93
101
  params = {};
94
102
  addParam(property, operator, value) {
95
103
  const operatorStr = operator === "EqualTo" ? "" : operator;
96
104
  const key = `${property.toString()}${operatorStr}`;
97
105
  if (operator === "IsNull" || operator === "IsNotNull") this.params[key] = "";
106
+ else if (DATE_OPERATORS.includes(operator) && typeof value === "string" && DATE_REGEX.test(value)) this.params[key] = new Date(value).toISOString();
98
107
  else this.params[key] = `${value}`;
99
108
  return this;
100
109
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@litepos/autoquery",
3
3
  "type": "module",
4
- "version": "5.0.6",
4
+ "version": "5.0.8",
5
5
  "description": "AutoQuery is a library for building queries for LitePOS.",
6
6
  "author": "LitePOS <info@litepos.ai>",
7
7
  "license": "MIT",