@react-querybuilder/core 8.22.5 → 8.23.0

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.
Files changed (120) hide show
  1. package/derivations/package.json +4 -0
  2. package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +2078 -1665
  3. package/dist/cjs/react-querybuilder_core.cjs.development.js +1293 -422
  4. package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
  5. package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +2078 -1665
  6. package/dist/cjs/react-querybuilder_core.cjs.production.js +1 -1
  7. package/dist/cjs/react-querybuilder_core.cjs.production.js.map +1 -1
  8. package/dist/{convertQuery-Cw76XFIn.js → convertQuery-BLT0GIhM.js} +17 -8
  9. package/dist/{convertQuery-Cw76XFIn.js.map → convertQuery-BLT0GIhM.js.map} +1 -1
  10. package/dist/{convertQuery-D_4J7E-Z.mjs → convertQuery-DaXv3h7S.mjs} +6 -3
  11. package/dist/{convertQuery-D_4J7E-Z.mjs.map → convertQuery-DaXv3h7S.mjs.map} +1 -1
  12. package/dist/derivations.d.mts +2902 -0
  13. package/dist/derivations.d.ts +2902 -0
  14. package/dist/derivations.js +2845 -0
  15. package/dist/derivations.js.map +1 -0
  16. package/dist/derivations.mjs +2678 -0
  17. package/dist/derivations.mjs.map +1 -0
  18. package/dist/formatQuery.d.mts +2 -895
  19. package/dist/formatQuery.d.ts +2 -895
  20. package/dist/formatQuery.js +120 -140
  21. package/dist/formatQuery.js.map +1 -1
  22. package/dist/formatQuery.mjs +8 -28
  23. package/dist/formatQuery.mjs.map +1 -1
  24. package/dist/{import-DVWI7Fdh.d.mts → import-BdKPtLzo.d.mts} +2 -2
  25. package/dist/{import-6ExjhifL.d.ts → import-BfZTwhp2.d.ts} +2 -2
  26. package/dist/{index-CX9mehdL.d.mts → index-DOIE2pwx.d.mts} +274 -3
  27. package/dist/{index-CX9mehdL.d.ts → index-DOIE2pwx.d.ts} +274 -3
  28. package/dist/index-OF2Q1gTp.d.mts +895 -0
  29. package/dist/index-XueTy_XQ.d.ts +895 -0
  30. package/dist/isRuleOrGroupValid-CIMZNkt4.mjs +27 -0
  31. package/dist/isRuleOrGroupValid-CIMZNkt4.mjs.map +1 -0
  32. package/dist/isRuleOrGroupValid-CtUf4_4x.js +38 -0
  33. package/dist/isRuleOrGroupValid-CtUf4_4x.js.map +1 -0
  34. package/dist/{isRuleGroup-CqLThsbu.mjs → objectUtils-DDZ-KhV5.mjs} +25 -2
  35. package/dist/objectUtils-DDZ-KhV5.mjs.map +1 -0
  36. package/dist/{isRuleGroup-0JNiQgLg.js → objectUtils-DfnEmDSV.js} +48 -1
  37. package/dist/objectUtils-DfnEmDSV.js.map +1 -0
  38. package/dist/parseCEL.d.mts +2 -2
  39. package/dist/parseCEL.d.ts +2 -2
  40. package/dist/parseCEL.js +19 -16
  41. package/dist/parseCEL.js.map +1 -1
  42. package/dist/parseCEL.mjs +12 -9
  43. package/dist/parseCEL.mjs.map +1 -1
  44. package/dist/parseCypher.d.mts +1 -1
  45. package/dist/parseCypher.d.ts +1 -1
  46. package/dist/parseGremlin.d.mts +1 -1
  47. package/dist/parseGremlin.d.ts +1 -1
  48. package/dist/parseJSONata.d.mts +2 -2
  49. package/dist/parseJSONata.d.ts +2 -2
  50. package/dist/parseJSONata.js +17 -14
  51. package/dist/parseJSONata.js.map +1 -1
  52. package/dist/parseJSONata.mjs +11 -8
  53. package/dist/parseJSONata.mjs.map +1 -1
  54. package/dist/parseJsonLogic.d.mts +2 -2
  55. package/dist/parseJsonLogic.d.ts +2 -2
  56. package/dist/parseJsonLogic.js +38 -38
  57. package/dist/parseJsonLogic.js.map +1 -1
  58. package/dist/parseJsonLogic.mjs +5 -5
  59. package/dist/parseMongoDB.d.mts +2 -2
  60. package/dist/parseMongoDB.d.ts +2 -2
  61. package/dist/parseMongoDB.js +50 -47
  62. package/dist/parseMongoDB.js.map +1 -1
  63. package/dist/parseMongoDB.mjs +35 -32
  64. package/dist/parseMongoDB.mjs.map +1 -1
  65. package/dist/parseSPARQL.d.mts +1 -1
  66. package/dist/parseSPARQL.d.ts +1 -1
  67. package/dist/parseSQL.d.mts +2 -2
  68. package/dist/parseSQL.d.ts +2 -2
  69. package/dist/parseSQL.js +27 -23
  70. package/dist/parseSQL.js.map +1 -1
  71. package/dist/parseSQL.mjs +21 -17
  72. package/dist/parseSQL.mjs.map +1 -1
  73. package/dist/parseSpEL.d.mts +2 -2
  74. package/dist/parseSpEL.d.ts +2 -2
  75. package/dist/parseSpEL.js +16 -13
  76. package/dist/parseSpEL.js.map +1 -1
  77. package/dist/parseSpEL.mjs +12 -9
  78. package/dist/parseSpEL.mjs.map +1 -1
  79. package/dist/parserUtils-BKPstAaO.mjs +30 -0
  80. package/dist/parserUtils-BKPstAaO.mjs.map +1 -0
  81. package/dist/parserUtils-DbBXyAht.js +41 -0
  82. package/dist/parserUtils-DbBXyAht.js.map +1 -0
  83. package/dist/{prepareQueryObjects-BnGL91Tt.js → prepareQueryObjects-Dj9cTl9D.js} +90 -63
  84. package/dist/prepareQueryObjects-Dj9cTl9D.js.map +1 -0
  85. package/dist/{prepareQueryObjects-ChINDIap.mjs → prepareQueryObjects-Dmyf3Wi_.mjs} +56 -59
  86. package/dist/prepareQueryObjects-Dmyf3Wi_.mjs.map +1 -0
  87. package/dist/react-querybuilder_core.d.mts +2078 -1665
  88. package/dist/react-querybuilder_core.legacy-esm.d.ts +2078 -1665
  89. package/dist/react-querybuilder_core.legacy-esm.js +1445 -635
  90. package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
  91. package/dist/react-querybuilder_core.mjs +1288 -424
  92. package/dist/react-querybuilder_core.mjs.map +1 -1
  93. package/dist/react-querybuilder_core.production.d.mts +2078 -1665
  94. package/dist/react-querybuilder_core.production.mjs +1 -1
  95. package/dist/react-querybuilder_core.production.mjs.map +1 -1
  96. package/dist/transformQuery-B7d9AWUf.d.mts +116 -0
  97. package/dist/transformQuery-BXDiUBGB.d.ts +116 -0
  98. package/dist/transformQuery.d.mts +2 -116
  99. package/dist/transformQuery.d.ts +2 -116
  100. package/dist/transformQuery.js +3 -4
  101. package/dist/transformQuery.js.map +1 -1
  102. package/dist/transformQuery.mjs +1 -2
  103. package/dist/transformQuery.mjs.map +1 -1
  104. package/dist/utils-CP5Jqy1P.mjs +1294 -0
  105. package/dist/utils-CP5Jqy1P.mjs.map +1 -0
  106. package/dist/utils-e-7KHkjV.js +1779 -0
  107. package/dist/utils-e-7KHkjV.js.map +1 -0
  108. package/package.json +33 -22
  109. package/dist/isRuleGroup-0JNiQgLg.js.map +0 -1
  110. package/dist/isRuleGroup-CqLThsbu.mjs.map +0 -1
  111. package/dist/objectUtils-Cr02aGxb.js +0 -27
  112. package/dist/objectUtils-Cr02aGxb.js.map +0 -1
  113. package/dist/objectUtils-DBlmJgBf.mjs +0 -16
  114. package/dist/objectUtils-DBlmJgBf.mjs.map +0 -1
  115. package/dist/prepareQueryObjects-BnGL91Tt.js.map +0 -1
  116. package/dist/prepareQueryObjects-ChINDIap.mjs.map +0 -1
  117. package/dist/utils-4k-j5FBa.mjs +0 -537
  118. package/dist/utils-4k-j5FBa.mjs.map +0 -1
  119. package/dist/utils-C79dxwZb.js +0 -752
  120. package/dist/utils-C79dxwZb.js.map +0 -1
@@ -0,0 +1,27 @@
1
+ import { c as isPojo, i as isRuleGroup } from "./objectUtils-DDZ-KhV5.mjs";
2
+ //#region src/utils/isRuleOrGroupValid.ts
3
+ /**
4
+ * Determines if an object is useful as a validation result.
5
+ */
6
+ const isValidationResult = (vr) => isPojo(vr) && typeof vr.valid === "boolean";
7
+ /**
8
+ * Determines if a rule or group is valid based on a validation result (if defined)
9
+ * or a validator function. Returns `true` if neither are defined and the `muted`
10
+ * property is not `true`.
11
+ */
12
+ const isRuleOrGroupValid = (rg, validationResult, validator) => {
13
+ if (rg.muted) return false;
14
+ if (typeof validationResult === "boolean") return validationResult;
15
+ if (isValidationResult(validationResult)) return validationResult.valid;
16
+ if (typeof validator === "function" && !isRuleGroup(rg)) {
17
+ const vr = validator(rg);
18
+ if (typeof vr === "boolean") return vr;
19
+ // v8 ignore else
20
+ if (isValidationResult(vr)) return vr.valid;
21
+ }
22
+ return true;
23
+ };
24
+ //#endregion
25
+ export { isValidationResult as n, isRuleOrGroupValid as t };
26
+
27
+ //# sourceMappingURL=isRuleOrGroupValid-CIMZNkt4.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isRuleOrGroupValid-CIMZNkt4.mjs","names":[],"sources":["../src/utils/isRuleOrGroupValid.ts"],"sourcesContent":["import type { RuleGroupTypeAny, RuleType, RuleValidator, ValidationResult } from '../types';\nimport { isRuleGroup } from './isRuleGroup';\nimport { isPojo } from './misc';\n\n/**\n * Determines if an object is useful as a validation result.\n */\nexport const isValidationResult = (vr?: ValidationResult): vr is ValidationResult =>\n isPojo(vr) && typeof vr.valid === 'boolean';\n\n/**\n * Determines if a rule or group is valid based on a validation result (if defined)\n * or a validator function. Returns `true` if neither are defined and the `muted`\n * property is not `true`.\n */\nexport const isRuleOrGroupValid = (\n rg: RuleType | RuleGroupTypeAny,\n validationResult?: boolean | ValidationResult,\n validator?: RuleValidator\n): boolean => {\n if (rg.muted) {\n return false;\n }\n if (typeof validationResult === 'boolean') {\n return validationResult;\n }\n if (isValidationResult(validationResult)) {\n return validationResult.valid;\n }\n if (typeof validator === 'function' && !isRuleGroup(rg)) {\n const vr = validator(rg);\n if (typeof vr === 'boolean') {\n return vr;\n }\n // v8 ignore else\n if (isValidationResult(vr)) {\n return vr.valid;\n }\n }\n return true;\n};\n"],"mappings":";;;;;AAOA,MAAa,sBAAsB,OACjC,OAAO,EAAE,KAAK,OAAO,GAAG,UAAU;;;;;;AAOpC,MAAa,sBACX,IACA,kBACA,cACY;CACZ,IAAI,GAAG,OACL,OAAO;CAET,IAAI,OAAO,qBAAqB,WAC9B,OAAO;CAET,IAAI,mBAAmB,gBAAgB,GACrC,OAAO,iBAAiB;CAE1B,IAAI,OAAO,cAAc,cAAc,CAAC,YAAY,EAAE,GAAG;EACvD,MAAM,KAAK,UAAU,EAAE;EACvB,IAAI,OAAO,OAAO,WAChB,OAAO;;EAGT,IAAI,mBAAmB,EAAE,GACvB,OAAO,GAAG;CAEd;CACA,OAAO;AACT"}
@@ -0,0 +1,38 @@
1
+ const require_objectUtils = require("./objectUtils-DfnEmDSV.js");
2
+ //#region src/utils/isRuleOrGroupValid.ts
3
+ /**
4
+ * Determines if an object is useful as a validation result.
5
+ */
6
+ const isValidationResult = (vr) => require_objectUtils.isPojo(vr) && typeof vr.valid === "boolean";
7
+ /**
8
+ * Determines if a rule or group is valid based on a validation result (if defined)
9
+ * or a validator function. Returns `true` if neither are defined and the `muted`
10
+ * property is not `true`.
11
+ */
12
+ const isRuleOrGroupValid = (rg, validationResult, validator) => {
13
+ if (rg.muted) return false;
14
+ if (typeof validationResult === "boolean") return validationResult;
15
+ if (isValidationResult(validationResult)) return validationResult.valid;
16
+ if (typeof validator === "function" && !require_objectUtils.isRuleGroup(rg)) {
17
+ const vr = validator(rg);
18
+ if (typeof vr === "boolean") return vr;
19
+ // v8 ignore else
20
+ if (isValidationResult(vr)) return vr.valid;
21
+ }
22
+ return true;
23
+ };
24
+ //#endregion
25
+ Object.defineProperty(exports, "isRuleOrGroupValid", {
26
+ enumerable: true,
27
+ get: function() {
28
+ return isRuleOrGroupValid;
29
+ }
30
+ });
31
+ Object.defineProperty(exports, "isValidationResult", {
32
+ enumerable: true,
33
+ get: function() {
34
+ return isValidationResult;
35
+ }
36
+ });
37
+
38
+ //# sourceMappingURL=isRuleOrGroupValid-CtUf4_4x.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isRuleOrGroupValid-CtUf4_4x.js","names":["isPojo","isRuleGroup"],"sources":["../src/utils/isRuleOrGroupValid.ts"],"sourcesContent":["import type { RuleGroupTypeAny, RuleType, RuleValidator, ValidationResult } from '../types';\nimport { isRuleGroup } from './isRuleGroup';\nimport { isPojo } from './misc';\n\n/**\n * Determines if an object is useful as a validation result.\n */\nexport const isValidationResult = (vr?: ValidationResult): vr is ValidationResult =>\n isPojo(vr) && typeof vr.valid === 'boolean';\n\n/**\n * Determines if a rule or group is valid based on a validation result (if defined)\n * or a validator function. Returns `true` if neither are defined and the `muted`\n * property is not `true`.\n */\nexport const isRuleOrGroupValid = (\n rg: RuleType | RuleGroupTypeAny,\n validationResult?: boolean | ValidationResult,\n validator?: RuleValidator\n): boolean => {\n if (rg.muted) {\n return false;\n }\n if (typeof validationResult === 'boolean') {\n return validationResult;\n }\n if (isValidationResult(validationResult)) {\n return validationResult.valid;\n }\n if (typeof validator === 'function' && !isRuleGroup(rg)) {\n const vr = validator(rg);\n if (typeof vr === 'boolean') {\n return vr;\n }\n // v8 ignore else\n if (isValidationResult(vr)) {\n return vr.valid;\n }\n }\n return true;\n};\n"],"mappings":";;;;;AAOA,MAAa,sBAAsB,OACjCA,oBAAAA,OAAO,EAAE,KAAK,OAAO,GAAG,UAAU;;;;;;AAOpC,MAAa,sBACX,IACA,kBACA,cACY;CACZ,IAAI,GAAG,OACL,OAAO;CAET,IAAI,OAAO,qBAAqB,WAC9B,OAAO;CAET,IAAI,mBAAmB,gBAAgB,GACrC,OAAO,iBAAiB;CAE1B,IAAI,OAAO,cAAc,cAAc,CAACC,oBAAAA,YAAY,EAAE,GAAG;EACvD,MAAM,KAAK,UAAU,EAAE;EACvB,IAAI,OAAO,OAAO,WAChB,OAAO;;EAGT,IAAI,mBAAmB,EAAE,GACvB,OAAO,GAAG;CAEd;CACA,OAAO;AACT"}
@@ -21,6 +21,10 @@ const nullOrUndefinedOrEmpty = (value) => value === null || value === void 0 ||
21
21
  //#endregion
22
22
  //#region src/utils/isRuleGroup.ts
23
23
  /**
24
+ * Determines if an object is a {@link RuleType} (only checks for a `field` property).
25
+ */
26
+ const isRuleType = (s) => isPojo(s) && "field" in s && typeof s.field === "string";
27
+ /**
24
28
  * Determines if an object is a {@link RuleGroupType} or {@link RuleGroupTypeIC}.
25
29
  */
26
30
  const isRuleGroup = (rg) => isPojo(rg) && Array.isArray(rg.rules);
@@ -33,6 +37,25 @@ const isRuleGroupType = (rg) => isRuleGroup(rg) && typeof rg.combinator === "str
33
37
  */
34
38
  const isRuleGroupTypeIC = (rg) => isRuleGroup(rg) && rg.combinator === void 0;
35
39
  //#endregion
36
- export { lc as a, isPojo as i, isRuleGroupType as n, nullOrUndefinedOrEmpty as o, isRuleGroupTypeIC as r, numericRegex$1 as s, isRuleGroup as t };
40
+ //#region src/utils/objectUtils.ts
41
+ /**
42
+ * A strongly-typed version of `Object.keys()`.
43
+ *
44
+ * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-keys.ts)
45
+ */
46
+ const objectKeys = Object.keys;
47
+ /**
48
+ * A strongly-typed version of `Object.entries()`.
49
+ *
50
+ * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-entries.ts)
51
+ */
52
+ const objectEntries = Object.entries;
53
+ /**
54
+ * Returns `true` if the key could cause prototype pollution when used
55
+ * as a property name in bracket-notation assignment.
56
+ */
57
+ const isUnsafeKey = (key) => key === "__proto__" || key === "constructor" || key === "prototype";
58
+ //#endregion
59
+ export { isRuleGroupType as a, isPojo as c, numericRegex$1 as d, isRuleGroup as i, lc as l, objectEntries as n, isRuleGroupTypeIC as o, objectKeys as r, isRuleType as s, isUnsafeKey as t, nullOrUndefinedOrEmpty as u };
37
60
 
38
- //# sourceMappingURL=isRuleGroup-CqLThsbu.mjs.map
61
+ //# sourceMappingURL=objectUtils-DDZ-KhV5.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objectUtils-DDZ-KhV5.mjs","names":["numericRegex","numericQuantityRegex"],"sources":["../src/utils/misc.ts","../src/utils/isRuleGroup.ts","../src/utils/objectUtils.ts"],"sourcesContent":["import { numericRegex as numericQuantityRegex } from 'numeric-quantity';\n\n/**\n * Converts a value to lowercase if it's a string, otherwise returns the value as is.\n */\n// v8 ignore next\nexport const lc = <T>(v: T): T => (typeof v === 'string' ? (v.toLowerCase() as T) : v);\n\n/**\n * Regex matching numeric strings. Passes for positive/negative integers, decimals,\n * and E notation, with optional surrounding whitespace.\n */\nexport const numericRegex: RegExp = new RegExp(\n numericQuantityRegex.source.replace(/^\\^/, String.raw`^\\s*`).replace(/\\$$/, String.raw`\\s*$`)\n);\n\n/**\n * Determines if a variable is a plain old JavaScript object, aka POJO.\n */\n// oxlint-disable-next-line typescript/no-explicit-any\nexport const isPojo = (obj: unknown): obj is Record<string, any> =>\n obj !== null && typeof obj === 'object' && Object.getPrototypeOf(obj) === Object.prototype;\n\n/**\n * Simple helper to determine whether a value is null, undefined, or an empty string.\n */\nexport const nullOrUndefinedOrEmpty = (value: unknown): value is null | undefined | '' =>\n value === null || value === undefined || value === '';\n","import type { RuleGroupType, RuleGroupTypeAny, RuleGroupTypeIC, RuleType } from '../types';\nimport { isPojo } from './misc';\n\n/**\n * Determines if an object is a {@link RuleType} (only checks for a `field` property).\n */\nexport const isRuleType = (s: unknown): s is RuleType =>\n isPojo(s) && 'field' in s && typeof s.field === 'string';\n\n/**\n * Determines if an object is a {@link RuleGroupType} or {@link RuleGroupTypeIC}.\n */\nexport const isRuleGroup = (rg: unknown): rg is RuleGroupTypeAny =>\n isPojo(rg) && Array.isArray(rg.rules);\n\n/**\n * Determines if an object is a {@link RuleGroupType}.\n */\nexport const isRuleGroupType = (rg: unknown): rg is RuleGroupType =>\n isRuleGroup(rg) && typeof rg.combinator === 'string';\n\n/**\n * Determines if an object is a {@link RuleGroupTypeIC}.\n */\nexport const isRuleGroupTypeIC = (rg: unknown): rg is RuleGroupTypeIC =>\n isRuleGroup(rg) && rg.combinator === undefined;\n","// All code in this file is adapted from:\n// npm: https://www.npmjs.com/package/ts-extras\n// src: https://github.com/sindresorhus/ts-extras\n\n/**\n * Original looked like this (not sure why template string is used):\n * ```\n * type ObjectKeys<T extends object> = `${Exclude<keyof T, symbol>}`;\n * ```\n */\ntype ObjectKeys<T extends object> = Exclude<keyof T, symbol>;\n\n/**\n * A strongly-typed version of `Object.keys()`.\n *\n * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-keys.ts)\n */\nexport const objectKeys = Object.keys as <Type extends object>(\n value: Type\n) => Array<ObjectKeys<Type>>;\n\n/**\n * A strongly-typed version of `Object.entries()`.\n *\n * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-entries.ts)\n */\nexport const objectEntries = Object.entries as <Type extends Record<PropertyKey, unknown>>(\n value: Type\n) => Array<[ObjectKeys<Type>, Type[ObjectKeys<Type>]]>;\n\n/**\n * Returns `true` if the key could cause prototype pollution when used\n * as a property name in bracket-notation assignment.\n */\nexport const isUnsafeKey = (key: unknown): boolean =>\n key === '__proto__' || key === 'constructor' || key === 'prototype';\n"],"mappings":";;;;;;AAMA,MAAa,MAAS,MAAa,OAAO,MAAM,WAAY,EAAE,YAAY,IAAU;;;;;AAMpF,MAAaA,iBAAuB,IAAI,OACtCC,aAAqB,OAAO,QAAQ,OAAO,OAAO,GAAG,MAAM,CAAC,CAAC,QAAQ,OAAO,OAAO,GAAG,MAAM,CAC9F;;;;AAMA,MAAa,UAAU,QACrB,QAAQ,QAAQ,OAAO,QAAQ,YAAY,OAAO,eAAe,GAAG,MAAM,OAAO;;;;AAKnF,MAAa,0BAA0B,UACrC,UAAU,QAAQ,UAAU,KAAA,KAAa,UAAU;;;;;;ACrBrD,MAAa,cAAc,MACzB,OAAO,CAAC,KAAK,WAAW,KAAK,OAAO,EAAE,UAAU;;;;AAKlD,MAAa,eAAe,OAC1B,OAAO,EAAE,KAAK,MAAM,QAAQ,GAAG,KAAK;;;;AAKtC,MAAa,mBAAmB,OAC9B,YAAY,EAAE,KAAK,OAAO,GAAG,eAAe;;;;AAK9C,MAAa,qBAAqB,OAChC,YAAY,EAAE,KAAK,GAAG,eAAe,KAAA;;;;;;;;ACRvC,MAAa,aAAa,OAAO;;;;;;AASjC,MAAa,gBAAgB,OAAO;;;;;AAQpC,MAAa,eAAe,QAC1B,QAAQ,eAAe,QAAQ,iBAAiB,QAAQ"}
@@ -21,6 +21,10 @@ const nullOrUndefinedOrEmpty = (value) => value === null || value === void 0 ||
21
21
  //#endregion
22
22
  //#region src/utils/isRuleGroup.ts
23
23
  /**
24
+ * Determines if an object is a {@link RuleType} (only checks for a `field` property).
25
+ */
26
+ const isRuleType = (s) => isPojo(s) && "field" in s && typeof s.field === "string";
27
+ /**
24
28
  * Determines if an object is a {@link RuleGroupType} or {@link RuleGroupTypeIC}.
25
29
  */
26
30
  const isRuleGroup = (rg) => isPojo(rg) && Array.isArray(rg.rules);
@@ -33,6 +37,25 @@ const isRuleGroupType = (rg) => isRuleGroup(rg) && typeof rg.combinator === "str
33
37
  */
34
38
  const isRuleGroupTypeIC = (rg) => isRuleGroup(rg) && rg.combinator === void 0;
35
39
  //#endregion
40
+ //#region src/utils/objectUtils.ts
41
+ /**
42
+ * A strongly-typed version of `Object.keys()`.
43
+ *
44
+ * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-keys.ts)
45
+ */
46
+ const objectKeys = Object.keys;
47
+ /**
48
+ * A strongly-typed version of `Object.entries()`.
49
+ *
50
+ * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-entries.ts)
51
+ */
52
+ const objectEntries = Object.entries;
53
+ /**
54
+ * Returns `true` if the key could cause prototype pollution when used
55
+ * as a property name in bracket-notation assignment.
56
+ */
57
+ const isUnsafeKey = (key) => key === "__proto__" || key === "constructor" || key === "prototype";
58
+ //#endregion
36
59
  Object.defineProperty(exports, "isPojo", {
37
60
  enumerable: true,
38
61
  get: function() {
@@ -57,6 +80,18 @@ Object.defineProperty(exports, "isRuleGroupTypeIC", {
57
80
  return isRuleGroupTypeIC;
58
81
  }
59
82
  });
83
+ Object.defineProperty(exports, "isRuleType", {
84
+ enumerable: true,
85
+ get: function() {
86
+ return isRuleType;
87
+ }
88
+ });
89
+ Object.defineProperty(exports, "isUnsafeKey", {
90
+ enumerable: true,
91
+ get: function() {
92
+ return isUnsafeKey;
93
+ }
94
+ });
60
95
  Object.defineProperty(exports, "lc", {
61
96
  enumerable: true,
62
97
  get: function() {
@@ -75,5 +110,17 @@ Object.defineProperty(exports, "numericRegex", {
75
110
  return numericRegex;
76
111
  }
77
112
  });
113
+ Object.defineProperty(exports, "objectEntries", {
114
+ enumerable: true,
115
+ get: function() {
116
+ return objectEntries;
117
+ }
118
+ });
119
+ Object.defineProperty(exports, "objectKeys", {
120
+ enumerable: true,
121
+ get: function() {
122
+ return objectKeys;
123
+ }
124
+ });
78
125
 
79
- //# sourceMappingURL=isRuleGroup-0JNiQgLg.js.map
126
+ //# sourceMappingURL=objectUtils-DfnEmDSV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objectUtils-DfnEmDSV.js","names":["numericQuantityRegex"],"sources":["../src/utils/misc.ts","../src/utils/isRuleGroup.ts","../src/utils/objectUtils.ts"],"sourcesContent":["import { numericRegex as numericQuantityRegex } from 'numeric-quantity';\n\n/**\n * Converts a value to lowercase if it's a string, otherwise returns the value as is.\n */\n// v8 ignore next\nexport const lc = <T>(v: T): T => (typeof v === 'string' ? (v.toLowerCase() as T) : v);\n\n/**\n * Regex matching numeric strings. Passes for positive/negative integers, decimals,\n * and E notation, with optional surrounding whitespace.\n */\nexport const numericRegex: RegExp = new RegExp(\n numericQuantityRegex.source.replace(/^\\^/, String.raw`^\\s*`).replace(/\\$$/, String.raw`\\s*$`)\n);\n\n/**\n * Determines if a variable is a plain old JavaScript object, aka POJO.\n */\n// oxlint-disable-next-line typescript/no-explicit-any\nexport const isPojo = (obj: unknown): obj is Record<string, any> =>\n obj !== null && typeof obj === 'object' && Object.getPrototypeOf(obj) === Object.prototype;\n\n/**\n * Simple helper to determine whether a value is null, undefined, or an empty string.\n */\nexport const nullOrUndefinedOrEmpty = (value: unknown): value is null | undefined | '' =>\n value === null || value === undefined || value === '';\n","import type { RuleGroupType, RuleGroupTypeAny, RuleGroupTypeIC, RuleType } from '../types';\nimport { isPojo } from './misc';\n\n/**\n * Determines if an object is a {@link RuleType} (only checks for a `field` property).\n */\nexport const isRuleType = (s: unknown): s is RuleType =>\n isPojo(s) && 'field' in s && typeof s.field === 'string';\n\n/**\n * Determines if an object is a {@link RuleGroupType} or {@link RuleGroupTypeIC}.\n */\nexport const isRuleGroup = (rg: unknown): rg is RuleGroupTypeAny =>\n isPojo(rg) && Array.isArray(rg.rules);\n\n/**\n * Determines if an object is a {@link RuleGroupType}.\n */\nexport const isRuleGroupType = (rg: unknown): rg is RuleGroupType =>\n isRuleGroup(rg) && typeof rg.combinator === 'string';\n\n/**\n * Determines if an object is a {@link RuleGroupTypeIC}.\n */\nexport const isRuleGroupTypeIC = (rg: unknown): rg is RuleGroupTypeIC =>\n isRuleGroup(rg) && rg.combinator === undefined;\n","// All code in this file is adapted from:\n// npm: https://www.npmjs.com/package/ts-extras\n// src: https://github.com/sindresorhus/ts-extras\n\n/**\n * Original looked like this (not sure why template string is used):\n * ```\n * type ObjectKeys<T extends object> = `${Exclude<keyof T, symbol>}`;\n * ```\n */\ntype ObjectKeys<T extends object> = Exclude<keyof T, symbol>;\n\n/**\n * A strongly-typed version of `Object.keys()`.\n *\n * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-keys.ts)\n */\nexport const objectKeys = Object.keys as <Type extends object>(\n value: Type\n) => Array<ObjectKeys<Type>>;\n\n/**\n * A strongly-typed version of `Object.entries()`.\n *\n * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-entries.ts)\n */\nexport const objectEntries = Object.entries as <Type extends Record<PropertyKey, unknown>>(\n value: Type\n) => Array<[ObjectKeys<Type>, Type[ObjectKeys<Type>]]>;\n\n/**\n * Returns `true` if the key could cause prototype pollution when used\n * as a property name in bracket-notation assignment.\n */\nexport const isUnsafeKey = (key: unknown): boolean =>\n key === '__proto__' || key === 'constructor' || key === 'prototype';\n"],"mappings":";;;;;;AAMA,MAAa,MAAS,MAAa,OAAO,MAAM,WAAY,EAAE,YAAY,IAAU;;;;;AAMpF,MAAa,eAAuB,IAAI,OACtCA,iBAAAA,aAAqB,OAAO,QAAQ,OAAO,OAAO,GAAG,MAAM,CAAC,CAAC,QAAQ,OAAO,OAAO,GAAG,MAAM,CAC9F;;;;AAMA,MAAa,UAAU,QACrB,QAAQ,QAAQ,OAAO,QAAQ,YAAY,OAAO,eAAe,GAAG,MAAM,OAAO;;;;AAKnF,MAAa,0BAA0B,UACrC,UAAU,QAAQ,UAAU,KAAA,KAAa,UAAU;;;;;;ACrBrD,MAAa,cAAc,MACzB,OAAO,CAAC,KAAK,WAAW,KAAK,OAAO,EAAE,UAAU;;;;AAKlD,MAAa,eAAe,OAC1B,OAAO,EAAE,KAAK,MAAM,QAAQ,GAAG,KAAK;;;;AAKtC,MAAa,mBAAmB,OAC9B,YAAY,EAAE,KAAK,OAAO,GAAG,eAAe;;;;AAK9C,MAAa,qBAAqB,OAChC,YAAY,EAAE,KAAK,GAAG,eAAe,KAAA;;;;;;;;ACRvC,MAAa,aAAa,OAAO;;;;;;AASjC,MAAa,gBAAgB,OAAO;;;;;AAQpC,MAAa,eAAe,QAC1B,QAAQ,eAAe,QAAQ,iBAAiB,QAAQ"}
@@ -1,5 +1,5 @@
1
- import { A as DefaultOperatorName, D as RuleGroupTypeIC, L as Except, M as RuleGroupType, N as RuleType, O as DefaultCombinatorName, P as ExpressionNode, T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-CX9mehdL.mjs";
2
- import { t as ParserCommonOptions } from "./import-DVWI7Fdh.mjs";
1
+ import { $t as DefaultRuleGroupType, Jt as DefaultCombinatorName, Pt as DefaultRuleGroupTypeIC, Vt as RuleGroupTypeIC, Zt as DefaultOperatorName, jn as Except, nn as RuleGroupType, on as ExpressionNode, rn as RuleType } from "./index-DOIE2pwx.mjs";
2
+ import { t as ParserCommonOptions } from "./import-BdKPtLzo.mjs";
3
3
  //#region src/utils/parseCEL/types.d.ts
4
4
  type CELExpressionType = "Addition" | "BooleanLiteral" | "BytesLiteral" | "ConditionalAnd" | "ConditionalExpr" | "ConditionalOr" | "Division" | "DynamicPropertyAccessor" | "ExpressionGroup" | "ExpressionList" | "FieldInit" | "FieldInits" | "MessageInit" | "FloatLiteral" | "FunctionCall" | "Identifier" | "IntegerLiteral" | "List" | "Map" | "MapInit" | "MapInits" | "Member" | "Modulo" | "Multiplication" | "Negation" | "Negative" | "NullLiteral" | "Property" | "Relation" | "StringLiteral" | "Subtraction" | "Unary" | "UnsignedIntegerLiteral" | "LikeExpression" | "SubqueryExpression";
5
5
  type CELRelop = "==" | ">=" | ">" | "<=" | "<" | "!=" | "in";
@@ -1,5 +1,5 @@
1
- import { A as DefaultOperatorName, D as RuleGroupTypeIC, L as Except, M as RuleGroupType, N as RuleType, O as DefaultCombinatorName, P as ExpressionNode, T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-CX9mehdL.js";
2
- import { t as ParserCommonOptions } from "./import-6ExjhifL.js";
1
+ import { $t as DefaultRuleGroupType, Jt as DefaultCombinatorName, Pt as DefaultRuleGroupTypeIC, Vt as RuleGroupTypeIC, Zt as DefaultOperatorName, jn as Except, nn as RuleGroupType, on as ExpressionNode, rn as RuleType } from "./index-DOIE2pwx.js";
2
+ import { t as ParserCommonOptions } from "./import-BfZTwhp2.js";
3
3
  //#region src/utils/parseCEL/types.d.ts
4
4
  type CELExpressionType = "Addition" | "BooleanLiteral" | "BytesLiteral" | "ConditionalAnd" | "ConditionalExpr" | "ConditionalOr" | "Division" | "DynamicPropertyAccessor" | "ExpressionGroup" | "ExpressionList" | "FieldInit" | "FieldInits" | "MessageInit" | "FloatLiteral" | "FunctionCall" | "Identifier" | "IntegerLiteral" | "List" | "Map" | "MapInit" | "MapInits" | "Member" | "Modulo" | "Multiplication" | "Negation" | "Negative" | "NullLiteral" | "Property" | "Relation" | "StringLiteral" | "Subtraction" | "Unary" | "UnsignedIntegerLiteral" | "LikeExpression" | "SubqueryExpression";
5
5
  type CELRelop = "==" | ">=" | ">" | "<=" | "<" | "!=" | "in";
package/dist/parseCEL.js CHANGED
@@ -1,7 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_utils = require("./utils-C79dxwZb.js");
3
- const require_isRuleGroup = require("./isRuleGroup-0JNiQgLg.js");
4
- const require_prepareQueryObjects = require("./prepareQueryObjects-BnGL91Tt.js");
2
+ const require_utils = require("./utils-e-7KHkjV.js");
3
+ const require_objectUtils = require("./objectUtils-DfnEmDSV.js");
4
+ const require_prepareQueryObjects = require("./prepareQueryObjects-Dj9cTl9D.js");
5
+ const require_parserUtils = require("./parserUtils-DbBXyAht.js");
5
6
  let _ts_jison_parser = require("@ts-jison/parser");
6
7
  let _ts_jison_lexer = require("@ts-jison/lexer");
7
8
  //#region src/utils/parseCEL/celParser.ts
@@ -2139,12 +2140,14 @@ const celGenerateMixedAndOrList = (expr) => {
2139
2140
  const tempAndArray = arr.slice(startIndex, i + 1);
2140
2141
  returnArray.push(tempAndArray);
2141
2142
  i -= 2;
2142
- } else if (arr[i + 1] === "or") if (i === 0 || i === arr.length - 3) {
2143
- if (i === 0 || arr[i - 1] === "or") returnArray.push(arr[i]);
2144
- returnArray.push(arr[i + 1]);
2145
- if (i === arr.length - 3) returnArray.push(arr[i + 2]);
2146
- } else if (arr[i - 1] === "and") returnArray.push(arr[i + 1]);
2147
- else returnArray.push(arr[i], arr[i + 1]);
2143
+ } else if (arr[i + 1] === "or") {
2144
+ if (i === 0 || i === arr.length - 3) {
2145
+ if (i === 0 || arr[i - 1] === "or") returnArray.push(arr[i]);
2146
+ returnArray.push(arr[i + 1]);
2147
+ if (i === arr.length - 3) returnArray.push(arr[i + 2]);
2148
+ } else if (arr[i - 1] === "and") returnArray.push(arr[i + 1]);
2149
+ else returnArray.push(arr[i], arr[i + 1]);
2150
+ }
2148
2151
  if (returnArray.length === 1 && Array.isArray(returnArray[0])) return returnArray[0];
2149
2152
  return returnArray;
2150
2153
  };
@@ -2263,8 +2266,8 @@ const isCELExpressionOperand = (expr) => {
2263
2266
  function parseCEL(cel, options = {}) {
2264
2267
  const { fields, independentCombinators, listsAsArrays, customExpressionHandler, getExpression } = options;
2265
2268
  const ic = !!independentCombinators;
2266
- const fieldsFlat = require_prepareQueryObjects.getFieldsArray(fields);
2267
- const fieldIsValid = (fieldName, operator, subordinateFieldName) => require_prepareQueryObjects.fieldIsValidUtil({
2269
+ const fieldsFlat = require_parserUtils.getFieldsArray(fields);
2270
+ const fieldIsValid = (fieldName, operator, subordinateFieldName) => require_parserUtils.fieldIsValidUtil({
2268
2271
  fieldName,
2269
2272
  fieldsFlat,
2270
2273
  operator,
@@ -2293,7 +2296,7 @@ function parseCEL(cel, options = {}) {
2293
2296
  });
2294
2297
  if (negatedExpr) {
2295
2298
  if (isCELNegatedLikeExpression(expr) || isCELNegation(expr) && isCELExpressionGroup(expr.value) && isCELRelation(expr.value.value)) return negatedExpr;
2296
- else if (!negate || negate && !require_isRuleGroup.isRuleGroup(negatedExpr) && negatedExpr.operator.startsWith("doesNot")) return ic ? { rules: [negatedExpr] } : {
2299
+ else if (!negate || negate && !require_objectUtils.isRuleGroup(negatedExpr) && negatedExpr.operator.startsWith("doesNot")) return ic ? { rules: [negatedExpr] } : {
2297
2300
  combinator: "and",
2298
2301
  rules: [negatedExpr]
2299
2302
  };
@@ -2309,7 +2312,7 @@ function parseCEL(cel, options = {}) {
2309
2312
  } else if (isCELExpressionGroup(expr)) {
2310
2313
  const rule = processCELExpression(expr.value, { groupOnlyIfNecessary: true });
2311
2314
  if (rule) {
2312
- if (require_isRuleGroup.isRuleGroup(rule) || groupOnlyIfNecessary && isCELExpressionGroup(expr.value)) return rule;
2315
+ if (require_objectUtils.isRuleGroup(rule) || groupOnlyIfNecessary && isCELExpressionGroup(expr.value)) return rule;
2313
2316
  return ic ? { rules: [rule] } : {
2314
2317
  combinator: "and",
2315
2318
  rules: [rule]
@@ -2365,7 +2368,7 @@ function parseCEL(cel, options = {}) {
2365
2368
  const transformedCondition = transformAliasInExpression(condition, alias);
2366
2369
  const subqueryValue = processCELExpression(transformedCondition);
2367
2370
  if (subqueryValue && fieldIsValid(field, "=")) {
2368
- const ruleGroupValue = require_isRuleGroup.isRuleGroup(subqueryValue) ? subqueryValue : ic ? { rules: [subqueryValue] } : {
2371
+ const ruleGroupValue = require_objectUtils.isRuleGroup(subqueryValue) ? subqueryValue : ic ? { rules: [subqueryValue] } : {
2369
2372
  combinator: "and",
2370
2373
  rules: [subqueryValue]
2371
2374
  };
@@ -2386,7 +2389,7 @@ function parseCEL(cel, options = {}) {
2386
2389
  const subqueryValue = processCELExpression(transformedCondition);
2387
2390
  // v8 ignore else
2388
2391
  if (subqueryValue && fieldIsValid(field, "=")) {
2389
- const ruleGroupValue = require_isRuleGroup.isRuleGroup(subqueryValue) ? subqueryValue : ic ? { rules: [subqueryValue] } : {
2392
+ const ruleGroupValue = require_objectUtils.isRuleGroup(subqueryValue) ? subqueryValue : ic ? { rules: [subqueryValue] } : {
2390
2393
  combinator: "and",
2391
2394
  rules: [subqueryValue]
2392
2395
  };
@@ -2520,7 +2523,7 @@ function parseCEL(cel, options = {}) {
2520
2523
  }
2521
2524
  const result = processCELExpression(processedCEL);
2522
2525
  if (result) {
2523
- if (require_isRuleGroup.isRuleGroup(result)) return prepare(result);
2526
+ if (require_objectUtils.isRuleGroup(result)) return prepare(result);
2524
2527
  return prepare({
2525
2528
  rules: [result],
2526
2529
  ...ic ? {} : { combinator: "and" }