@react-querybuilder/core 8.21.0 → 8.21.2

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 (72) hide show
  1. package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +30 -1
  2. package/dist/cjs/react-querybuilder_core.cjs.development.js +37 -8
  3. package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
  4. package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +30 -1
  5. package/dist/cjs/react-querybuilder_core.cjs.production.js +1 -1
  6. package/dist/cjs/react-querybuilder_core.cjs.production.js.map +1 -1
  7. package/dist/formatQuery.d.mts +17 -2
  8. package/dist/formatQuery.d.ts +17 -2
  9. package/dist/formatQuery.js +23 -9
  10. package/dist/formatQuery.js.map +1 -1
  11. package/dist/formatQuery.mjs +22 -10
  12. package/dist/formatQuery.mjs.map +1 -1
  13. package/dist/{import-Ddc3d_8q.d.ts → import-6ExjhifL.d.ts} +2 -2
  14. package/dist/{import-BVdxeIBO.d.mts → import-DVWI7Fdh.d.mts} +2 -2
  15. package/dist/{index-BSwFvkeI.d.mts → index-CX9mehdL.d.mts} +15 -1
  16. package/dist/{index-BSwFvkeI.d.ts → index-CX9mehdL.d.ts} +15 -1
  17. package/dist/parseCEL.d.mts +2 -2
  18. package/dist/parseCEL.d.ts +2 -2
  19. package/dist/parseCEL.js +2 -2
  20. package/dist/parseCEL.mjs +2 -2
  21. package/dist/parseCypher.d.mts +1 -1
  22. package/dist/parseCypher.d.ts +1 -1
  23. package/dist/parseGremlin.d.mts +1 -1
  24. package/dist/parseGremlin.d.ts +1 -1
  25. package/dist/parseJSONata.d.mts +2 -2
  26. package/dist/parseJSONata.d.ts +2 -2
  27. package/dist/parseJSONata.js +1 -1
  28. package/dist/parseJSONata.mjs +1 -1
  29. package/dist/parseJsonLogic.d.mts +2 -2
  30. package/dist/parseJsonLogic.d.ts +2 -2
  31. package/dist/parseJsonLogic.js +2 -2
  32. package/dist/parseJsonLogic.mjs +2 -2
  33. package/dist/parseMongoDB.d.mts +2 -2
  34. package/dist/parseMongoDB.d.ts +2 -2
  35. package/dist/parseMongoDB.js +2 -2
  36. package/dist/parseMongoDB.mjs +2 -2
  37. package/dist/parseSPARQL.d.mts +1 -1
  38. package/dist/parseSPARQL.d.ts +1 -1
  39. package/dist/parseSQL.d.mts +2 -2
  40. package/dist/parseSQL.d.ts +2 -2
  41. package/dist/parseSQL.js +2 -2
  42. package/dist/parseSQL.mjs +2 -2
  43. package/dist/parseSpEL.d.mts +2 -2
  44. package/dist/parseSpEL.d.ts +2 -2
  45. package/dist/parseSpEL.js +2 -2
  46. package/dist/parseSpEL.mjs +2 -2
  47. package/dist/{prepareQueryObjects-Q18lHCKl.mjs → prepareQueryObjects-9emVAGYG.mjs} +2 -2
  48. package/dist/{prepareQueryObjects-Q18lHCKl.mjs.map → prepareQueryObjects-9emVAGYG.mjs.map} +1 -1
  49. package/dist/{prepareQueryObjects-C2-kTZvR.js → prepareQueryObjects-C5dHLhnC.js} +2 -2
  50. package/dist/{prepareQueryObjects-C2-kTZvR.js.map → prepareQueryObjects-C5dHLhnC.js.map} +1 -1
  51. package/dist/query-builder-layout.css.map +1 -1
  52. package/dist/query-builder.css.map +1 -1
  53. package/dist/react-querybuilder_core.d.mts +30 -1
  54. package/dist/react-querybuilder_core.legacy-esm.d.ts +30 -1
  55. package/dist/react-querybuilder_core.legacy-esm.js +38 -9
  56. package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
  57. package/dist/react-querybuilder_core.mjs +36 -9
  58. package/dist/react-querybuilder_core.mjs.map +1 -1
  59. package/dist/react-querybuilder_core.production.d.mts +30 -1
  60. package/dist/react-querybuilder_core.production.mjs +1 -1
  61. package/dist/react-querybuilder_core.production.mjs.map +1 -1
  62. package/dist/styles/_layout.scss +14 -4
  63. package/dist/styles/_main.scss +7 -2
  64. package/dist/transformQuery.d.mts +1 -1
  65. package/dist/transformQuery.d.ts +1 -1
  66. package/dist/{utils-Dt0D_DMV.mjs → utils-CxWs-N47.mjs} +17 -2
  67. package/dist/utils-CxWs-N47.mjs.map +1 -0
  68. package/dist/{utils-DEwV7F6B.js → utils-SchkzSCN.js} +28 -1
  69. package/dist/utils-SchkzSCN.js.map +1 -0
  70. package/package.json +8 -8
  71. package/dist/utils-DEwV7F6B.js.map +0 -1
  72. package/dist/utils-Dt0D_DMV.mjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { C as FullField, F as OptionList, w as ValueSources } from "./index-BSwFvkeI.js";
1
+ import { C as FullField, F as OptionList, w as ValueSources } from "./index-CX9mehdL.js";
2
2
  //#region src/types/import.d.ts
3
3
  /**
4
4
  * Options common to all parsers.
@@ -23,4 +23,4 @@ interface ParserCommonOptions {
23
23
  }
24
24
  //#endregion
25
25
  export { ParserCommonOptions as t };
26
- //# sourceMappingURL=import-Ddc3d_8q.d.ts.map
26
+ //# sourceMappingURL=import-6ExjhifL.d.ts.map
@@ -1,4 +1,4 @@
1
- import { C as FullField, F as OptionList, w as ValueSources } from "./index-BSwFvkeI.mjs";
1
+ import { C as FullField, F as OptionList, w as ValueSources } from "./index-CX9mehdL.mjs";
2
2
  //#region src/types/import.d.ts
3
3
  /**
4
4
  * Options common to all parsers.
@@ -23,4 +23,4 @@ interface ParserCommonOptions {
23
23
  }
24
24
  //#endregion
25
25
  export { ParserCommonOptions as t };
26
- //# sourceMappingURL=import-BVdxeIBO.d.mts.map
26
+ //# sourceMappingURL=import-DVWI7Fdh.d.mts.map
@@ -1628,6 +1628,14 @@ interface ValueProcessorOptions extends FormatQueryOptions {
1628
1628
  * @default false
1629
1629
  */
1630
1630
  parseNumbers?: boolean;
1631
+ /**
1632
+ * Nesting level of the subquery currently being processed. Incremented each time a rule
1633
+ * processor recurses into a rule group stored in a rule's `value` (see `match` modes).
1634
+ * Used to generate collision-free element aliases.
1635
+ *
1636
+ * @default 0
1637
+ */
1638
+ subqueryDepth?: number;
1631
1639
  }
1632
1640
  /**
1633
1641
  * Options object curated by {@link formatQuery} and passed to a {@link RuleGroupProcessor}.
@@ -1645,6 +1653,12 @@ interface FormatQueryFinalOptions extends Required<Except<FormatQueryOptions, "c
1645
1653
  validateRule: FormatQueryValidateRule;
1646
1654
  validationMap: ValidationMap;
1647
1655
  context?: Record<string, unknown>;
1656
+ /**
1657
+ * @see {@link ValueProcessorOptions.subqueryDepth}
1658
+ *
1659
+ * @default 0
1660
+ */
1661
+ subqueryDepth?: number;
1648
1662
  }
1649
1663
  /**
1650
1664
  * Function that produces a processed value for a given {@link RuleType}.
@@ -1973,4 +1987,4 @@ type NLTranslationKey = "and" | "or" | "true" | "false" | "ruleSeparator" | "bet
1973
1987
  type NLTranslations = Partial<Record<NLTranslationKey, string>>;
1974
1988
  //#endregion
1975
1989
  export { DefaultOperatorName as A, FullField as C, RuleGroupTypeIC as D, RuleGroupTypeAny as E, OptionList as F, SetRequired as I, Except as L, RuleGroupType as M, RuleType as N, DefaultCombinatorName as O, ExpressionNode as P, Merge as R, ValueProcessorOptions as S, DefaultRuleGroupTypeIC as T, RuleGroupProcessor as _, DiagnosticsResult as a, ValueProcessorByRule as b, ExportOperatorMap as c, NLTranslationKey as d, NLTranslations as f, RQBJsonLogicVar as g, RQBJsonLogic as h, ConstituentWordOrder as i, DefaultRuleGroupType as j, DefaultCombinatorNameExtended as k, FormatQueryOptions as l, ParameterizedSQL as m, JsonLogicLessThanOrEqual as n, ExportFormat as o, ParameterizedNamedSQL as p, JsonLogicRulesLogic as r, ExportObjectFormats as s, JsonLogicLessThan as t, GroupVariantCondition as u, RuleProcessor as v, ValueSources as w, ValueProcessorLegacy as x, SQLPreset as y };
1976
- //# sourceMappingURL=index-BSwFvkeI.d.mts.map
1990
+ //# sourceMappingURL=index-CX9mehdL.d.mts.map
@@ -1628,6 +1628,14 @@ interface ValueProcessorOptions extends FormatQueryOptions {
1628
1628
  * @default false
1629
1629
  */
1630
1630
  parseNumbers?: boolean;
1631
+ /**
1632
+ * Nesting level of the subquery currently being processed. Incremented each time a rule
1633
+ * processor recurses into a rule group stored in a rule's `value` (see `match` modes).
1634
+ * Used to generate collision-free element aliases.
1635
+ *
1636
+ * @default 0
1637
+ */
1638
+ subqueryDepth?: number;
1631
1639
  }
1632
1640
  /**
1633
1641
  * Options object curated by {@link formatQuery} and passed to a {@link RuleGroupProcessor}.
@@ -1645,6 +1653,12 @@ interface FormatQueryFinalOptions extends Required<Except<FormatQueryOptions, "c
1645
1653
  validateRule: FormatQueryValidateRule;
1646
1654
  validationMap: ValidationMap;
1647
1655
  context?: Record<string, unknown>;
1656
+ /**
1657
+ * @see {@link ValueProcessorOptions.subqueryDepth}
1658
+ *
1659
+ * @default 0
1660
+ */
1661
+ subqueryDepth?: number;
1648
1662
  }
1649
1663
  /**
1650
1664
  * Function that produces a processed value for a given {@link RuleType}.
@@ -1973,4 +1987,4 @@ type NLTranslationKey = "and" | "or" | "true" | "false" | "ruleSeparator" | "bet
1973
1987
  type NLTranslations = Partial<Record<NLTranslationKey, string>>;
1974
1988
  //#endregion
1975
1989
  export { DefaultOperatorName as A, FullField as C, RuleGroupTypeIC as D, RuleGroupTypeAny as E, OptionList as F, SetRequired as I, Except as L, RuleGroupType as M, RuleType as N, DefaultCombinatorName as O, ExpressionNode as P, Merge as R, ValueProcessorOptions as S, DefaultRuleGroupTypeIC as T, RuleGroupProcessor as _, DiagnosticsResult as a, ValueProcessorByRule as b, ExportOperatorMap as c, NLTranslationKey as d, NLTranslations as f, RQBJsonLogicVar as g, RQBJsonLogic as h, ConstituentWordOrder as i, DefaultRuleGroupType as j, DefaultCombinatorNameExtended as k, FormatQueryOptions as l, ParameterizedSQL as m, JsonLogicLessThanOrEqual as n, ExportFormat as o, ParameterizedNamedSQL as p, JsonLogicRulesLogic as r, ExportObjectFormats as s, JsonLogicLessThan as t, GroupVariantCondition as u, RuleProcessor as v, ValueSources as w, ValueProcessorLegacy as x, SQLPreset as y };
1976
- //# sourceMappingURL=index-BSwFvkeI.d.ts.map
1990
+ //# sourceMappingURL=index-CX9mehdL.d.ts.map
@@ -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-BSwFvkeI.mjs";
2
- import { t as ParserCommonOptions } from "./import-BVdxeIBO.mjs";
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";
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-BSwFvkeI.js";
2
- import { t as ParserCommonOptions } from "./import-Ddc3d_8q.js";
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";
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,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_utils = require("./utils-DEwV7F6B.js");
2
+ const require_utils = require("./utils-SchkzSCN.js");
3
3
  const require_isRuleGroup = require("./isRuleGroup-0JNiQgLg.js");
4
- const require_prepareQueryObjects = require("./prepareQueryObjects-C2-kTZvR.js");
4
+ const require_prepareQueryObjects = require("./prepareQueryObjects-C5dHLhnC.js");
5
5
  let _ts_jison_parser = require("@ts-jison/parser");
6
6
  let _ts_jison_lexer = require("@ts-jison/lexer");
7
7
  //#region src/utils/parseCEL/celParser.ts
package/dist/parseCEL.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { P as defaultOperatorNegationMap, j as joinWith } from "./utils-Dt0D_DMV.mjs";
1
+ import { I as defaultOperatorNegationMap, N as joinWith } from "./utils-CxWs-N47.mjs";
2
2
  import { t as isRuleGroup } from "./isRuleGroup-CqLThsbu.mjs";
3
- import { n as fieldIsValidUtil, r as getFieldsArray, t as prepareRuleGroup } from "./prepareQueryObjects-Q18lHCKl.mjs";
3
+ import { n as fieldIsValidUtil, r as getFieldsArray, t as prepareRuleGroup } from "./prepareQueryObjects-9emVAGYG.mjs";
4
4
  import { JisonParser } from "@ts-jison/parser";
5
5
  import { JisonLexer } from "@ts-jison/lexer";
6
6
  //#region src/utils/parseCEL/celParser.ts
@@ -1,4 +1,4 @@
1
- import { T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-BSwFvkeI.mjs";
1
+ import { T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-CX9mehdL.mjs";
2
2
  //#region src/utils/parseCypher/parseCypher.d.ts
3
3
  /**
4
4
  * Options for {@link parseCypher}.
@@ -1,4 +1,4 @@
1
- import { T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-BSwFvkeI.js";
1
+ import { T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-CX9mehdL.js";
2
2
  //#region src/utils/parseCypher/parseCypher.d.ts
3
3
  /**
4
4
  * Options for {@link parseCypher}.
@@ -1,4 +1,4 @@
1
- import { T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-BSwFvkeI.mjs";
1
+ import { T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-CX9mehdL.mjs";
2
2
  //#region src/utils/parseGremlin/parseGremlin.d.ts
3
3
  /**
4
4
  * Options for {@link parseGremlin}.
@@ -1,4 +1,4 @@
1
- import { T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-BSwFvkeI.js";
1
+ import { T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-CX9mehdL.js";
2
2
  //#region src/utils/parseGremlin/parseGremlin.d.ts
3
3
  /**
4
4
  * Options for {@link parseGremlin}.
@@ -1,5 +1,5 @@
1
- import { L as Except, P as ExpressionNode, R as Merge, T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-BSwFvkeI.mjs";
2
- import { t as ParserCommonOptions } from "./import-BVdxeIBO.mjs";
1
+ import { L as Except, P as ExpressionNode, R as Merge, T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-CX9mehdL.mjs";
2
+ import { t as ParserCommonOptions } from "./import-DVWI7Fdh.mjs";
3
3
  //#region ../../node_modules/type-fest/source/override-properties.d.ts
4
4
  /**
5
5
  Override existing properties of the given type. Similar to `Merge`, but enforces that the original type has the properties you want to override.
@@ -1,5 +1,5 @@
1
- import { L as Except, P as ExpressionNode, R as Merge, T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-BSwFvkeI.js";
2
- import { t as ParserCommonOptions } from "./import-Ddc3d_8q.js";
1
+ import { L as Except, P as ExpressionNode, R as Merge, T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-CX9mehdL.js";
2
+ import { t as ParserCommonOptions } from "./import-6ExjhifL.js";
3
3
  //#region ../../node_modules/type-fest/source/override-properties.d.ts
4
4
  /**
5
5
  Override existing properties of the given type. Similar to `Merge`, but enforces that the original type has the properties you want to override.
@@ -22,7 +22,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  }) : target, mod));
23
23
  //#endregion
24
24
  const require_isRuleGroup = require("./isRuleGroup-0JNiQgLg.js");
25
- const require_prepareQueryObjects = require("./prepareQueryObjects-C2-kTZvR.js");
25
+ const require_prepareQueryObjects = require("./prepareQueryObjects-C5dHLhnC.js");
26
26
  let jsonata = require("jsonata");
27
27
  jsonata = __toESM(jsonata);
28
28
  //#region src/utils/parseJSONata/utils.ts
@@ -1,5 +1,5 @@
1
1
  import { t as isRuleGroup } from "./isRuleGroup-CqLThsbu.mjs";
2
- import { n as fieldIsValidUtil, r as getFieldsArray, t as prepareRuleGroup } from "./prepareQueryObjects-Q18lHCKl.mjs";
2
+ import { n as fieldIsValidUtil, r as getFieldsArray, t as prepareRuleGroup } from "./prepareQueryObjects-9emVAGYG.mjs";
3
3
  import jsonata from "jsonata";
4
4
  //#region src/utils/parseJSONata/utils.ts
5
5
  const isJSONataExprNode = (expr) => {
@@ -1,5 +1,5 @@
1
- import { E as RuleGroupTypeAny, L as Except, N as RuleType, P as ExpressionNode, T as DefaultRuleGroupTypeIC, g as RQBJsonLogicVar, h as RQBJsonLogic, j as DefaultRuleGroupType, n as JsonLogicLessThanOrEqual, r as JsonLogicRulesLogic, t as JsonLogicLessThan } from "./index-BSwFvkeI.mjs";
2
- import { t as ParserCommonOptions } from "./import-BVdxeIBO.mjs";
1
+ import { E as RuleGroupTypeAny, L as Except, N as RuleType, P as ExpressionNode, T as DefaultRuleGroupTypeIC, g as RQBJsonLogicVar, h as RQBJsonLogic, j as DefaultRuleGroupType, n as JsonLogicLessThanOrEqual, r as JsonLogicRulesLogic, t as JsonLogicLessThan } from "./index-CX9mehdL.mjs";
2
+ import { t as ParserCommonOptions } from "./import-DVWI7Fdh.mjs";
3
3
  //#region src/utils/parseJsonLogic/types.d.ts
4
4
  interface JsonLogicBetweenExclusive extends JsonLogicLessThan {
5
5
  "<": [JsonLogicRulesLogic, JsonLogicRulesLogic, JsonLogicRulesLogic];
@@ -1,5 +1,5 @@
1
- import { E as RuleGroupTypeAny, L as Except, N as RuleType, P as ExpressionNode, T as DefaultRuleGroupTypeIC, g as RQBJsonLogicVar, h as RQBJsonLogic, j as DefaultRuleGroupType, n as JsonLogicLessThanOrEqual, r as JsonLogicRulesLogic, t as JsonLogicLessThan } from "./index-BSwFvkeI.js";
2
- import { t as ParserCommonOptions } from "./import-Ddc3d_8q.js";
1
+ import { E as RuleGroupTypeAny, L as Except, N as RuleType, P as ExpressionNode, T as DefaultRuleGroupTypeIC, g as RQBJsonLogicVar, h as RQBJsonLogic, j as DefaultRuleGroupType, n as JsonLogicLessThanOrEqual, r as JsonLogicRulesLogic, t as JsonLogicLessThan } from "./index-CX9mehdL.js";
2
+ import { t as ParserCommonOptions } from "./import-6ExjhifL.js";
3
3
  //#region src/utils/parseJsonLogic/types.d.ts
4
4
  interface JsonLogicBetweenExclusive extends JsonLogicLessThan {
5
5
  "<": [JsonLogicRulesLogic, JsonLogicRulesLogic, JsonLogicRulesLogic];
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_utils = require("./utils-DEwV7F6B.js");
2
+ const require_utils = require("./utils-SchkzSCN.js");
3
3
  const require_isRuleGroup = require("./isRuleGroup-0JNiQgLg.js");
4
4
  const require_objectUtils = require("./objectUtils-Cr02aGxb.js");
5
5
  const require_convertQuery = require("./convertQuery-Cw76XFIn.js");
6
- const require_prepareQueryObjects = require("./prepareQueryObjects-C2-kTZvR.js");
6
+ const require_prepareQueryObjects = require("./prepareQueryObjects-C5dHLhnC.js");
7
7
  //#region src/utils/parseJsonLogic/utils.ts
8
8
  const isJsonLogicVar = (logic) => require_isRuleGroup.isPojo(logic) && "var" in logic;
9
9
  const isRQBJsonLogicVar = (logic) => isJsonLogicVar(logic) && typeof logic.var === "string";
@@ -1,8 +1,8 @@
1
- import { P as defaultOperatorNegationMap, j as joinWith } from "./utils-Dt0D_DMV.mjs";
1
+ import { I as defaultOperatorNegationMap, N as joinWith } from "./utils-CxWs-N47.mjs";
2
2
  import { i as isPojo, n as isRuleGroupType, t as isRuleGroup } from "./isRuleGroup-CqLThsbu.mjs";
3
3
  import { n as objectKeys } from "./objectUtils-DBlmJgBf.mjs";
4
4
  import { n as convertToIC } from "./convertQuery-D_4J7E-Z.mjs";
5
- import { n as fieldIsValidUtil, r as getFieldsArray, t as prepareRuleGroup } from "./prepareQueryObjects-Q18lHCKl.mjs";
5
+ import { n as fieldIsValidUtil, r as getFieldsArray, t as prepareRuleGroup } from "./prepareQueryObjects-9emVAGYG.mjs";
6
6
  //#region src/utils/parseJsonLogic/utils.ts
7
7
  const isJsonLogicVar = (logic) => isPojo(logic) && "var" in logic;
8
8
  const isRQBJsonLogicVar = (logic) => isJsonLogicVar(logic) && typeof logic.var === "string";
@@ -1,5 +1,5 @@
1
- import { L as Except, M as RuleGroupType, N as RuleType, P as ExpressionNode, T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-BSwFvkeI.mjs";
2
- import { t as ParserCommonOptions } from "./import-BVdxeIBO.mjs";
1
+ import { L as Except, M as RuleGroupType, N as RuleType, P as ExpressionNode, T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-CX9mehdL.mjs";
2
+ import { t as ParserCommonOptions } from "./import-DVWI7Fdh.mjs";
3
3
  //#region src/utils/parseMongoDB/types.d.ts
4
4
  type MongoDbSupportedOperators = "$and" | "$or" | "$not" | "$eq" | "$gt" | "$gte" | "$in" | "$lt" | "$lte" | "$ne" | "$nin" | "$regex" | "$expr";
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { L as Except, M as RuleGroupType, N as RuleType, P as ExpressionNode, T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-BSwFvkeI.js";
2
- import { t as ParserCommonOptions } from "./import-Ddc3d_8q.js";
1
+ import { L as Except, M as RuleGroupType, N as RuleType, P as ExpressionNode, T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-CX9mehdL.js";
2
+ import { t as ParserCommonOptions } from "./import-6ExjhifL.js";
3
3
  //#region src/utils/parseMongoDB/types.d.ts
4
4
  type MongoDbSupportedOperators = "$and" | "$or" | "$not" | "$eq" | "$gt" | "$gte" | "$in" | "$lt" | "$lte" | "$ne" | "$nin" | "$regex" | "$expr";
5
5
  /**
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_utils = require("./utils-DEwV7F6B.js");
2
+ const require_utils = require("./utils-SchkzSCN.js");
3
3
  const require_isRuleGroup = require("./isRuleGroup-0JNiQgLg.js");
4
4
  const require_objectUtils = require("./objectUtils-Cr02aGxb.js");
5
5
  const require_convertQuery = require("./convertQuery-Cw76XFIn.js");
6
- const require_prepareQueryObjects = require("./prepareQueryObjects-C2-kTZvR.js");
6
+ const require_prepareQueryObjects = require("./prepareQueryObjects-C5dHLhnC.js");
7
7
  //#region src/utils/parseMongoDB/utils.ts
8
8
  const getRegExStr = (re) => typeof re === "string" ? re : re.source;
9
9
  const isPrimitive = (v) => typeof v === "string" || typeof v === "number" || typeof v === "boolean";
@@ -1,8 +1,8 @@
1
- import { P as defaultOperatorNegationMap, j as joinWith } from "./utils-Dt0D_DMV.mjs";
1
+ import { I as defaultOperatorNegationMap, N as joinWith } from "./utils-CxWs-N47.mjs";
2
2
  import { i as isPojo, n as isRuleGroupType } from "./isRuleGroup-CqLThsbu.mjs";
3
3
  import { n as objectKeys } from "./objectUtils-DBlmJgBf.mjs";
4
4
  import { n as convertToIC } from "./convertQuery-D_4J7E-Z.mjs";
5
- import { n as fieldIsValidUtil, r as getFieldsArray, t as prepareRuleGroup } from "./prepareQueryObjects-Q18lHCKl.mjs";
5
+ import { n as fieldIsValidUtil, r as getFieldsArray, t as prepareRuleGroup } from "./prepareQueryObjects-9emVAGYG.mjs";
6
6
  //#region src/utils/parseMongoDB/utils.ts
7
7
  const getRegExStr = (re) => typeof re === "string" ? re : re.source;
8
8
  const isPrimitive = (v) => typeof v === "string" || typeof v === "number" || typeof v === "boolean";
@@ -1,4 +1,4 @@
1
- import { T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-BSwFvkeI.mjs";
1
+ import { T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-CX9mehdL.mjs";
2
2
  //#region src/utils/parseSPARQL/parseSPARQL.d.ts
3
3
  /**
4
4
  * Options for {@link parseSPARQL}.
@@ -1,4 +1,4 @@
1
- import { T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-BSwFvkeI.js";
1
+ import { T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-CX9mehdL.js";
2
2
  //#region src/utils/parseSPARQL/parseSPARQL.d.ts
3
3
  /**
4
4
  * Options for {@link parseSPARQL}.
@@ -1,5 +1,5 @@
1
- import { A as DefaultOperatorName, L as Except, P as ExpressionNode, T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType, k as DefaultCombinatorNameExtended } from "./index-BSwFvkeI.mjs";
2
- import { t as ParserCommonOptions } from "./import-BVdxeIBO.mjs";
1
+ import { A as DefaultOperatorName, L as Except, P as ExpressionNode, T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType, k as DefaultCombinatorNameExtended } from "./index-CX9mehdL.mjs";
2
+ import { t as ParserCommonOptions } from "./import-DVWI7Fdh.mjs";
3
3
  //#region src/utils/parseSQL/types.d.ts
4
4
  type AnyCase<T extends string> = string extends T ? string : T extends `${infer F1}${infer F2}${infer R}` ? `${Uppercase<F1> | Lowercase<F1>}${Uppercase<F2> | Lowercase<F2>}${AnyCase<R>}` : T extends `${infer F}${infer R}` ? `${Uppercase<F> | Lowercase<F>}${AnyCase<R>}` : "";
5
5
  type TokenType = "AndExpression" | "BetweenPredicate" | "BitExpression" | "Boolean" | "BooleanExtra" | "CaseWhen" | "ComparisonBooleanPrimary" | "ComparisonSubQueryBooleanPrimary" | "ContainsExpr" | "EndsWithExpr" | "ExpressionList" | "ForceIndexHint" | "ForOptIndexHint" | "FunctionCall" | "FunctionCallParam" | "GroupBy" | "GroupByOrderByItem" | "Identifier" | "IdentifierExpr" | "IdentifierList" | "IgnoreIndexHint" | "IndexHintList" | "InExpressionListPredicate" | "InnerCrossJoinTable" | "InSubQueryPredicate" | "IsExpression" | "IsNullBooleanPrimary" | "LeftRightJoinTable" | "LikePredicate" | "Limit" | "Main" | "NaturalJoinTable" | "NotExpression" | "Null" | "Number" | "OnJoinCondition" | "OrderBy" | "OrExpression" | "Partitions" | "PlaceHolder" | "Prefix" | "RegexpPredicate" | "Select" | "SelectExpr" | "SelectParenthesized" | "SimpleExprParentheses" | "SoundsLikePredicate" | "StartsWithExpr" | "StraightJoinTable" | "String" | "SubQuery" | "TableFactor" | "TableReference" | "TableReferences" | "Union" | "UseIndexHint" | "UsingJoinCondition" | "WhenThenList" | "XorExpression";
@@ -1,5 +1,5 @@
1
- import { A as DefaultOperatorName, L as Except, P as ExpressionNode, T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType, k as DefaultCombinatorNameExtended } from "./index-BSwFvkeI.js";
2
- import { t as ParserCommonOptions } from "./import-Ddc3d_8q.js";
1
+ import { A as DefaultOperatorName, L as Except, P as ExpressionNode, T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType, k as DefaultCombinatorNameExtended } from "./index-CX9mehdL.js";
2
+ import { t as ParserCommonOptions } from "./import-6ExjhifL.js";
3
3
  //#region src/utils/parseSQL/types.d.ts
4
4
  type AnyCase<T extends string> = string extends T ? string : T extends `${infer F1}${infer F2}${infer R}` ? `${Uppercase<F1> | Lowercase<F1>}${Uppercase<F2> | Lowercase<F2>}${AnyCase<R>}` : T extends `${infer F}${infer R}` ? `${Uppercase<F> | Lowercase<F>}${AnyCase<R>}` : "";
5
5
  type TokenType = "AndExpression" | "BetweenPredicate" | "BitExpression" | "Boolean" | "BooleanExtra" | "CaseWhen" | "ComparisonBooleanPrimary" | "ComparisonSubQueryBooleanPrimary" | "ContainsExpr" | "EndsWithExpr" | "ExpressionList" | "ForceIndexHint" | "ForOptIndexHint" | "FunctionCall" | "FunctionCallParam" | "GroupBy" | "GroupByOrderByItem" | "Identifier" | "IdentifierExpr" | "IdentifierList" | "IgnoreIndexHint" | "IndexHintList" | "InExpressionListPredicate" | "InnerCrossJoinTable" | "InSubQueryPredicate" | "IsExpression" | "IsNullBooleanPrimary" | "LeftRightJoinTable" | "LikePredicate" | "Limit" | "Main" | "NaturalJoinTable" | "NotExpression" | "Null" | "Number" | "OnJoinCondition" | "OrderBy" | "OrExpression" | "Partitions" | "PlaceHolder" | "Prefix" | "RegexpPredicate" | "Select" | "SelectExpr" | "SelectParenthesized" | "SimpleExprParentheses" | "SoundsLikePredicate" | "StartsWithExpr" | "StraightJoinTable" | "String" | "SubQuery" | "TableFactor" | "TableReference" | "TableReferences" | "Union" | "UseIndexHint" | "UsingJoinCondition" | "WhenThenList" | "XorExpression";
package/dist/parseSQL.js CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_utils = require("./utils-DEwV7F6B.js");
2
+ const require_utils = require("./utils-SchkzSCN.js");
3
3
  const require_isRuleGroup = require("./isRuleGroup-0JNiQgLg.js");
4
- const require_prepareQueryObjects = require("./prepareQueryObjects-C2-kTZvR.js");
4
+ const require_prepareQueryObjects = require("./prepareQueryObjects-C5dHLhnC.js");
5
5
  let _ts_jison_parser = require("@ts-jison/parser");
6
6
  let _ts_jison_lexer = require("@ts-jison/lexer");
7
7
  //#region src/utils/parseSQL/sqlParser.ts
package/dist/parseSQL.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { A as parseNumber, j as joinWith } from "./utils-Dt0D_DMV.mjs";
1
+ import { M as parseNumber, N as joinWith } from "./utils-CxWs-N47.mjs";
2
2
  import { a as lc, t as isRuleGroup } from "./isRuleGroup-CqLThsbu.mjs";
3
- import { n as fieldIsValidUtil, r as getFieldsArray, t as prepareRuleGroup } from "./prepareQueryObjects-Q18lHCKl.mjs";
3
+ import { n as fieldIsValidUtil, r as getFieldsArray, t as prepareRuleGroup } from "./prepareQueryObjects-9emVAGYG.mjs";
4
4
  import { JisonParser } from "@ts-jison/parser";
5
5
  import { JisonLexer } from "@ts-jison/lexer";
6
6
  //#region src/utils/parseSQL/sqlParser.ts
@@ -1,5 +1,5 @@
1
- import { A as DefaultOperatorName, L as Except, O as DefaultCombinatorName, P as ExpressionNode, T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-BSwFvkeI.mjs";
2
- import { t as ParserCommonOptions } from "./import-BVdxeIBO.mjs";
1
+ import { A as DefaultOperatorName, L as Except, 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";
3
3
  //#region src/utils/parseSpEL/types.d.ts
4
4
  type SpELNodeType = "invalid" | SpELOperationType | SpELPrimitiveType | SpELRelOp | SpELIdentifierType | "assign" | "beanref" | "constructorref" | "elvis" | "function" | "identifier" | "indexer" | "list" | "map" | "method" | "between" | "instanceof" | "matches" | "projection" | "qualifiedidentifier" | "selection" | "ternary" | "typeref";
5
5
  type SpELOperationType = "op-and" | "op-dec" | "op-divide" | "op-eq" | "op-ge" | "op-gt" | "op-inc" | "op-le" | "op-lt" | "op-minus" | "op-modulus" | "op-multiply" | "op-ne" | "op-not" | "op-or" | "op-plus" | "op-power";
@@ -1,5 +1,5 @@
1
- import { A as DefaultOperatorName, L as Except, O as DefaultCombinatorName, P as ExpressionNode, T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-BSwFvkeI.js";
2
- import { t as ParserCommonOptions } from "./import-Ddc3d_8q.js";
1
+ import { A as DefaultOperatorName, L as Except, 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";
3
3
  //#region src/utils/parseSpEL/types.d.ts
4
4
  type SpELNodeType = "invalid" | SpELOperationType | SpELPrimitiveType | SpELRelOp | SpELIdentifierType | "assign" | "beanref" | "constructorref" | "elvis" | "function" | "identifier" | "indexer" | "list" | "map" | "method" | "between" | "instanceof" | "matches" | "projection" | "qualifiedidentifier" | "selection" | "ternary" | "typeref";
5
5
  type SpELOperationType = "op-and" | "op-dec" | "op-divide" | "op-eq" | "op-ge" | "op-gt" | "op-inc" | "op-le" | "op-lt" | "op-minus" | "op-modulus" | "op-multiply" | "op-ne" | "op-not" | "op-or" | "op-plus" | "op-power";
package/dist/parseSpEL.js CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_utils = require("./utils-DEwV7F6B.js");
2
+ const require_utils = require("./utils-SchkzSCN.js");
3
3
  const require_isRuleGroup = require("./isRuleGroup-0JNiQgLg.js");
4
- const require_prepareQueryObjects = require("./prepareQueryObjects-C2-kTZvR.js");
4
+ const require_prepareQueryObjects = require("./prepareQueryObjects-C5dHLhnC.js");
5
5
  let spel2js = require("spel2js");
6
6
  //#region src/utils/parseSpEL/utils.ts
7
7
  const isSpELPropertyNode = (expr) => {
@@ -1,6 +1,6 @@
1
- import { j as joinWith } from "./utils-Dt0D_DMV.mjs";
1
+ import { N as joinWith } from "./utils-CxWs-N47.mjs";
2
2
  import { t as isRuleGroup } from "./isRuleGroup-CqLThsbu.mjs";
3
- import { n as fieldIsValidUtil, r as getFieldsArray, t as prepareRuleGroup } from "./prepareQueryObjects-Q18lHCKl.mjs";
3
+ import { n as fieldIsValidUtil, r as getFieldsArray, t as prepareRuleGroup } from "./prepareQueryObjects-9emVAGYG.mjs";
4
4
  import { SpelExpressionEvaluator } from "spel2js";
5
5
  //#region src/utils/parseSpEL/utils.ts
6
6
  const isSpELPropertyNode = (expr) => {
@@ -1,4 +1,4 @@
1
- import { D as toFlatOptionArray, E as isFlexibleOptionGroupArray, O as toFullOption, T as isFlexibleOptionArray, k as toFullOptionList, v as processMatchMode } from "./utils-Dt0D_DMV.mjs";
1
+ import { A as toFullOption, D as isFlexibleOptionArray, O as isFlexibleOptionGroupArray, j as toFullOptionList, k as toFlatOptionArray, y as processMatchMode } from "./utils-CxWs-N47.mjs";
2
2
  import { a as lc, t as isRuleGroup } from "./isRuleGroup-CqLThsbu.mjs";
3
3
  //#region src/utils/filterFieldsByComparator.ts
4
4
  const filterByComparator = (field, operator, fieldToCompare) => {
@@ -164,4 +164,4 @@ const prepareRuleGroup = (queryObject, { idGenerator = generateID } = {}) => {
164
164
  //#endregion
165
165
  export { fieldIsValidUtil as n, getFieldsArray as r, prepareRuleGroup as t };
166
166
 
167
- //# sourceMappingURL=prepareQueryObjects-Q18lHCKl.mjs.map
167
+ //# sourceMappingURL=prepareQueryObjects-9emVAGYG.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"prepareQueryObjects-Q18lHCKl.mjs","names":[],"sources":["../src/utils/filterFieldsByComparator.ts","../src/utils/getValueSourcesUtil.ts","../src/utils/parserUtils.ts","../src/utils/generateID.ts","../src/utils/prepareQueryObjects.ts"],"sourcesContent":["import type { FullField, OptionList, WithUnknownIndex } from '../types';\nimport { isFlexibleOptionGroupArray, toFullOption } from './optGroupUtils';\n\nconst filterByComparator = (field: FullField, operator: string, fieldToCompare: FullField) => {\n const fullField = toFullOption(field);\n const fullFieldToCompare = toFullOption(fieldToCompare);\n if (fullField.value === fullFieldToCompare.value) {\n return false;\n }\n if (typeof fullField.comparator === 'string') {\n return fullField[fullField.comparator] === fullFieldToCompare[fullField.comparator];\n }\n return (\n fullField.comparator?.(fullFieldToCompare, operator) ??\n /* v8 ignore start -- @preserve */ false /* v8 ignore stop -- @preserve */\n );\n};\n\n/**\n * For a given {@link FullField}, returns the `fields` list filtered for\n * other fields that match by `comparator`. Only fields *other than the\n * one in question* will ever be included, even if `comparator` is `null`\n * or `undefined`. If `comparator` is a string, fields with the same value\n * for that property will be included. If `comparator` is a function, each\n * field will be passed to the function along with the `operator` and fields\n * for which the function returns `true` will be included.\n *\n * @group Option Lists\n */\nexport const filterFieldsByComparator = (\n /** The field in question. */\n field: FullField,\n /** The full {@link FullField} list to be filtered. */\n fields: OptionList<FullField>,\n operator: string\n):\n | FullField[]\n | {\n options: WithUnknownIndex<FullField>[];\n label: string;\n }[] => {\n if (!field.comparator) {\n const filterOutSameField = (f: FullField) =>\n (f.value ?? /* v8 ignore start -- @preserve */ f.name) /* v8 ignore stop -- @preserve */ !==\n (field.value ??\n /* v8 ignore start -- @preserve */ field.name); /* v8 ignore stop -- @preserve */\n if (isFlexibleOptionGroupArray(fields)) {\n return fields.map(og => ({\n ...og,\n options: og.options.filter(v => filterOutSameField(v)),\n }));\n }\n return fields.filter(v => filterOutSameField(v));\n }\n\n if (isFlexibleOptionGroupArray(fields)) {\n return fields\n .map(og => ({\n ...og,\n options: og.options.filter(f => filterByComparator(field, operator, f)),\n }))\n .filter(og => og.options.length > 0);\n }\n\n return fields.filter(f => filterByComparator(field, operator, f));\n};\n","import type {\n FullField,\n GetOptionIdentifierType,\n ValueSourceFlexibleOptions,\n ValueSourceFullOptions,\n ValueSources,\n} from '../types';\nimport { lc } from './misc';\nimport { isFlexibleOptionArray, toFullOption, toFullOptionList } from './optGroupUtils';\n\nconst defaultValueSourcesArray: ValueSourceFullOptions = [\n { name: 'value', value: 'value', label: 'value' },\n];\n\nconst dummyFD = {\n name: 'name',\n value: 'name',\n valueSources: null,\n label: 'label',\n};\n\n/**\n * Utility function to get the value sources array for the given\n * field and operator. If the field definition does not define a\n * `valueSources` property, the `getValueSources` prop is used.\n * Returns `[FullOption<\"value\">]` by default.\n */\n// oxlint-disable-next-line typescript/no-unnecessary-type-parameters\nexport const getValueSourcesUtil = <F extends FullField, O extends string>(\n fieldData: F,\n operator: string,\n getValueSources?: (\n field: GetOptionIdentifierType<F>,\n operator: O,\n misc: { fieldData: F }\n ) => ValueSources | ValueSourceFlexibleOptions\n): ValueSourceFullOptions => {\n // TypeScript doesn't allow it directly, but in practice\n // `fieldData` can end up being undefined or null. The nullish\n // coalescing assignment below avoids errors like\n // \"TypeError: Cannot read properties of undefined (reading 'name')\"\n const fd = fieldData ? toFullOption(fieldData) : dummyFD;\n\n let valueSourcesNEW:\n | false\n | ValueSources\n | ValueSourceFlexibleOptions\n | ((operator: string) => ValueSources | ValueSourceFlexibleOptions) = fd.valueSources ?? false;\n\n if (typeof valueSourcesNEW === 'function') {\n valueSourcesNEW = valueSourcesNEW(operator);\n }\n\n if (!valueSourcesNEW && getValueSources) {\n valueSourcesNEW = getValueSources(fd.value as GetOptionIdentifierType<F>, operator as O, {\n fieldData: fd as F,\n });\n }\n\n if (!valueSourcesNEW) {\n return defaultValueSourcesArray;\n }\n\n if (isFlexibleOptionArray(valueSourcesNEW)) {\n return toFullOptionList(valueSourcesNEW as ValueSourceFullOptions) as ValueSourceFullOptions;\n }\n\n return valueSourcesNEW.map(\n vs =>\n defaultValueSourcesArray.find(dmm => dmm.value === lc(vs)) ?? {\n name: vs,\n value: vs,\n label: vs,\n }\n ) as ValueSourceFullOptions;\n};\n","import type {\n DefaultOperatorName,\n FullField,\n FullOption,\n OptionList,\n ValueSource,\n ValueSourceFlexibleOptions,\n ValueSources,\n} from '../types';\nimport { filterFieldsByComparator } from './filterFieldsByComparator';\nimport { getValueSourcesUtil } from './getValueSourcesUtil';\nimport { isFlexibleOptionArray, toFlatOptionArray, toFullOption } from './optGroupUtils';\n\nexport const getFieldsArray = (\n fields?: OptionList<FullField> | Record<string, FullField>\n): FullOption[] => {\n const fieldsArray = fields\n ? Array.isArray(fields)\n ? fields\n : Object.keys(fields)\n .map(fld => Object.assign({}, fields[fld], { name: fld }))\n // oxlint-disable-next-line no-array-sort\n .sort((a, b) => a.label.localeCompare(b.label))\n : [];\n return toFlatOptionArray(fieldsArray);\n};\n\nexport function fieldIsValidUtil(params: {\n fieldsFlat: FullField[];\n getValueSources?: (field: string, operator: string) => ValueSources | ValueSourceFlexibleOptions;\n fieldName: string;\n operator: DefaultOperatorName;\n subordinateFieldName?: string;\n}): boolean {\n const { fieldsFlat, fieldName, operator, subordinateFieldName, getValueSources } = params;\n\n const vsIncludes = (vs: ValueSource) => {\n const vss = getValueSourcesUtil(primaryField, operator, getValueSources);\n return isFlexibleOptionArray(vss) && vss.some(vso => vso.value === vs || vso.name === vs);\n };\n\n // If fields option was an empty array or undefined, then all identifiers\n // are considered valid.\n if (fieldsFlat.length === 0) return true;\n\n let valid = false;\n\n const primaryField = toFullOption(fieldsFlat.find(ff => ff.name === fieldName)!);\n if (primaryField) {\n valid = !(\n !subordinateFieldName &&\n operator !== 'notNull' &&\n operator !== 'null' &&\n !vsIncludes('value')\n );\n\n if (valid && !!subordinateFieldName) {\n if (vsIncludes('field') && fieldName !== subordinateFieldName) {\n const validSubordinateFields = filterFieldsByComparator(\n primaryField,\n fieldsFlat,\n operator\n ) as FullField[];\n if (!validSubordinateFields.some(vsf => vsf.name === subordinateFieldName)) {\n valid = false;\n }\n } else {\n valid = false;\n }\n }\n }\n\n return valid;\n}\n","/* v8 ignore file -- this is fine */\n\ntype UUID = `${string}-${string}-${string}-${string}-${string}`;\n\nconst cryptoModule = globalThis.crypto;\n\nexport const uuidV4regex: RegExp =\n /^[\\da-f]{8}-[\\da-f]{4}-4[\\da-f]{3}-[89ab][\\da-f]{3}-[\\da-f]{12}$/i;\n\n/**\n * Default `id` generator. Generates a valid v4 UUID. Uses `crypto.randomUUID()`\n * when available, otherwise uses an alternate method based on `getRandomValues`.\n * The returned string is guaranteed to match this regex:\n * ```\n * /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i\n * ```\n * @returns Valid v4 UUID\n */\n// Default implementation adapted from https://stackoverflow.com/a/68141099/217579\n// v8 ignore next\nexport let generateID = (): UUID =>\n '00-0-4-2-000'.replaceAll(/[^-]/g, s =>\n (((Math.random() + Math.trunc(s as unknown as number)) * 0x1_00_00) >> Number.parseInt(s))\n .toString(16)\n .padStart(4, '0')\n ) as UUID;\n\n// Improve on the default implementation by using the crypto package if it's available\n// v8 ignore else\nif (cryptoModule) {\n // v8 ignore else\n if (typeof cryptoModule.randomUUID === 'function') {\n generateID = () => cryptoModule.randomUUID();\n } else if (typeof cryptoModule.getRandomValues === 'function') {\n // `randomUUID` is much simpler and faster, but it's only guaranteed to be\n // available in secure contexts (server-side, https, etc.). `generateID`\n // doesn't really need to be cryptographically secure, it only needs a\n // fairly low chance of collisions. We fall back to the always-available\n // `getRandomValues` here (while still generating a valid v4 UUID) when\n // `randomUUID` is not available.\n const position19vals = '89ab';\n const container = new Uint32Array(32);\n\n generateID = () => {\n cryptoModule.getRandomValues(container);\n let id = (container[0] % 16).toString(16);\n for (let i = 1; i < 32; i++) {\n if (i === 12) {\n id = `${id}${'4'}`;\n } else if (i === 16) {\n id = `${id}${position19vals[container[17] % 4]}`;\n } else {\n id = `${id}${(container[i] % 16).toString(16)}`;\n }\n\n if (i === 7 || i === 11 || i === 15 || i === 19) {\n id = `${id}${'-'}`;\n }\n }\n return id as UUID;\n };\n }\n}\n","import type {\n RuleGroupArray,\n RuleGroupICArray,\n RuleGroupType,\n RuleGroupTypeAny,\n RuleGroupTypeIC,\n RuleType,\n} from '../types';\nimport { processMatchMode } from './formatQuery/utils';\nimport { generateID } from './generateID';\nimport { isRuleGroup } from './isRuleGroup';\n\n/**\n * Options for {@link prepareRule}/{@link prepareRuleGroup}.\n */\nexport interface PreparerOptions {\n idGenerator?: () => string;\n}\n\n/**\n * Ensures that a rule is valid by adding an `id` property if it does not already exist.\n */\nexport const prepareRule = (\n rule: RuleType,\n { idGenerator = generateID }: PreparerOptions = {}\n): RuleType => {\n const needsId = !rule.id;\n const hasMatchMode = processMatchMode(rule);\n\n if (!needsId && !hasMatchMode) {\n return rule;\n }\n\n return {\n ...rule,\n ...(needsId && { id: idGenerator() }),\n ...(hasMatchMode && { value: prepareRuleGroup(rule.value, { idGenerator }) }),\n };\n};\n\n/**\n * Ensures that a rule group is valid by recursively adding an `id` property to the group itself\n * and all its rules and subgroups where one does not already exist.\n */\nexport const prepareRuleGroup = <RG extends RuleGroupTypeAny>(\n queryObject: RG,\n { idGenerator = generateID }: PreparerOptions = {}\n): RG => {\n const needsId = !queryObject.id;\n let rulesChanged = false;\n const newRules: (RuleGroupTypeAny | RuleType | string)[] = [];\n\n for (let i = 0; i < queryObject.rules.length; i++) {\n const r = queryObject.rules[i];\n if (typeof r === 'string') {\n newRules.push(r);\n } else {\n const prepared = isRuleGroup(r)\n ? prepareRuleGroup(r, { idGenerator })\n : prepareRule(r, { idGenerator });\n newRules.push(prepared);\n if (prepared !== r) {\n rulesChanged = true;\n }\n }\n }\n\n if (!needsId && !rulesChanged) {\n return queryObject;\n }\n\n return {\n ...queryObject,\n ...(needsId && { id: idGenerator() }),\n rules: newRules as RuleGroupArray | RuleGroupICArray,\n };\n};\n\n/**\n * Ensures that a rule or group is valid. See {@link prepareRule} and {@link prepareRuleGroup}.\n */\nexport const prepareRuleOrGroup = (\n rg: RuleGroupTypeAny | RuleType,\n { idGenerator = generateID }: PreparerOptions = {}\n): RuleGroupType | RuleGroupTypeIC | RuleType =>\n isRuleGroup(rg) ? prepareRuleGroup(rg, { idGenerator }) : prepareRule(rg, { idGenerator });\n"],"mappings":";;;AAGA,MAAM,sBAAsB,OAAkB,UAAkB,mBAA8B;CAC5F,MAAM,YAAY,aAAa,KAAK;CACpC,MAAM,qBAAqB,aAAa,cAAc;CACtD,IAAI,UAAU,UAAU,mBAAmB,OACzC,OAAO;CAET,IAAI,OAAO,UAAU,eAAe,UAClC,OAAO,UAAU,UAAU,gBAAgB,mBAAmB,UAAU;CAE1E,OACE,UAAU,aAAa,oBAAoB,QAAQ,KAChB;AAEvC;;;;;;;;;;;;AAaA,MAAa,4BAEX,OAEA,QACA,aAMS;CACT,IAAI,CAAC,MAAM,YAAY;EACrB,MAAM,sBAAsB,OACzB,EAAE,SAA4C,EAAE,WAChD,MAAM,SAC8B,MAAM;EAC7C,IAAI,2BAA2B,MAAM,GACnC,OAAO,OAAO,KAAI,QAAO;GACvB,GAAG;GACH,SAAS,GAAG,QAAQ,QAAO,MAAK,mBAAmB,CAAC,CAAC;EACvD,EAAE;EAEJ,OAAO,OAAO,QAAO,MAAK,mBAAmB,CAAC,CAAC;CACjD;CAEA,IAAI,2BAA2B,MAAM,GACnC,OAAO,OACJ,KAAI,QAAO;EACV,GAAG;EACH,SAAS,GAAG,QAAQ,QAAO,MAAK,mBAAmB,OAAO,UAAU,CAAC,CAAC;CACxE,EAAE,CAAC,CACF,QAAO,OAAM,GAAG,QAAQ,SAAS,CAAC;CAGvC,OAAO,OAAO,QAAO,MAAK,mBAAmB,OAAO,UAAU,CAAC,CAAC;AAClE;;;ACvDA,MAAM,2BAAmD,CACvD;CAAE,MAAM;CAAS,OAAO;CAAS,OAAO;AAAQ,CAClD;AAEA,MAAM,UAAU;CACd,MAAM;CACN,OAAO;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ACH,GAAI,WAAW,EAAE,IAAI,YAAY,EAAE;EACnC,GAAI,gBAAgB,EAAE,OAAO,iBAAiB,KAAK,OAAO,EAAE,YAAY,CAAC,EAAE;CAC7E;AACF;;;;;AAMA,MAAa,oBACX,aACA,EAAE,cAAc,eAAgC,CAAC,MAC1C;CACP,MAAM,UAAU,CAAC,YAAY;CAC7B,IAAI,eAAe;CACnB,MAAM,WAAqD,CAAC;CAE5D,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,MAAM,QAAQ,KAAK;EACjD,MAAM,IAAI,YAAY,MAAM;EAC5B,IAAI,OAAO,MAAM,UACf,SAAS,KAAK,CAAC;OACV;GACL,MAAM,WAAW,YAAY,CAAC,IAC1B,iBAAiB,GAAG,EAAE,YAAY,CAAC,IACnC,YAAY,GAAG,EAAE,YAAY,CAAC;GAClC,SAAS,KAAK,QAAQ;GACtB,IAAI,aAAa,GACf,eAAe;EAEnB;CACF;CAEA,IAAI,CAAC,WAAW,CAAC,cACf,OAAO;CAGT,OAAO;EACL,GAAG;EACH,GAAI,WAAW,EAAE,IAAI,YAAY,EAAE;EACnC,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"prepareQueryObjects-9emVAGYG.mjs","names":[],"sources":["../src/utils/filterFieldsByComparator.ts","../src/utils/getValueSourcesUtil.ts","../src/utils/parserUtils.ts","../src/utils/generateID.ts","../src/utils/prepareQueryObjects.ts"],"sourcesContent":["import type { FullField, OptionList, WithUnknownIndex } from '../types';\nimport { isFlexibleOptionGroupArray, toFullOption } from './optGroupUtils';\n\nconst filterByComparator = (field: FullField, operator: string, fieldToCompare: FullField) => {\n const fullField = toFullOption(field);\n const fullFieldToCompare = toFullOption(fieldToCompare);\n if (fullField.value === fullFieldToCompare.value) {\n return false;\n }\n if (typeof fullField.comparator === 'string') {\n return fullField[fullField.comparator] === fullFieldToCompare[fullField.comparator];\n }\n return (\n fullField.comparator?.(fullFieldToCompare, operator) ??\n /* v8 ignore start -- @preserve */ false /* v8 ignore stop -- @preserve */\n );\n};\n\n/**\n * For a given {@link FullField}, returns the `fields` list filtered for\n * other fields that match by `comparator`. Only fields *other than the\n * one in question* will ever be included, even if `comparator` is `null`\n * or `undefined`. If `comparator` is a string, fields with the same value\n * for that property will be included. If `comparator` is a function, each\n * field will be passed to the function along with the `operator` and fields\n * for which the function returns `true` will be included.\n *\n * @group Option Lists\n */\nexport const filterFieldsByComparator = (\n /** The field in question. */\n field: FullField,\n /** The full {@link FullField} list to be filtered. */\n fields: OptionList<FullField>,\n operator: string\n):\n | FullField[]\n | {\n options: WithUnknownIndex<FullField>[];\n label: string;\n }[] => {\n if (!field.comparator) {\n const filterOutSameField = (f: FullField) =>\n (f.value ?? /* v8 ignore start -- @preserve */ f.name) /* v8 ignore stop -- @preserve */ !==\n (field.value ??\n /* v8 ignore start -- @preserve */ field.name); /* v8 ignore stop -- @preserve */\n if (isFlexibleOptionGroupArray(fields)) {\n return fields.map(og => ({\n ...og,\n options: og.options.filter(v => filterOutSameField(v)),\n }));\n }\n return fields.filter(v => filterOutSameField(v));\n }\n\n if (isFlexibleOptionGroupArray(fields)) {\n return fields\n .map(og => ({\n ...og,\n options: og.options.filter(f => filterByComparator(field, operator, f)),\n }))\n .filter(og => og.options.length > 0);\n }\n\n return fields.filter(f => filterByComparator(field, operator, f));\n};\n","import type {\n FullField,\n GetOptionIdentifierType,\n ValueSourceFlexibleOptions,\n ValueSourceFullOptions,\n ValueSources,\n} from '../types';\nimport { lc } from './misc';\nimport { isFlexibleOptionArray, toFullOption, toFullOptionList } from './optGroupUtils';\n\nconst defaultValueSourcesArray: ValueSourceFullOptions = [\n { name: 'value', value: 'value', label: 'value' },\n];\n\nconst dummyFD = {\n name: 'name',\n value: 'name',\n valueSources: null,\n label: 'label',\n};\n\n/**\n * Utility function to get the value sources array for the given\n * field and operator. If the field definition does not define a\n * `valueSources` property, the `getValueSources` prop is used.\n * Returns `[FullOption<\"value\">]` by default.\n */\n// oxlint-disable-next-line typescript/no-unnecessary-type-parameters\nexport const getValueSourcesUtil = <F extends FullField, O extends string>(\n fieldData: F,\n operator: string,\n getValueSources?: (\n field: GetOptionIdentifierType<F>,\n operator: O,\n misc: { fieldData: F }\n ) => ValueSources | ValueSourceFlexibleOptions\n): ValueSourceFullOptions => {\n // TypeScript doesn't allow it directly, but in practice\n // `fieldData` can end up being undefined or null. The nullish\n // coalescing assignment below avoids errors like\n // \"TypeError: Cannot read properties of undefined (reading 'name')\"\n const fd = fieldData ? toFullOption(fieldData) : dummyFD;\n\n let valueSourcesNEW:\n | false\n | ValueSources\n | ValueSourceFlexibleOptions\n | ((operator: string) => ValueSources | ValueSourceFlexibleOptions) = fd.valueSources ?? false;\n\n if (typeof valueSourcesNEW === 'function') {\n valueSourcesNEW = valueSourcesNEW(operator);\n }\n\n if (!valueSourcesNEW && getValueSources) {\n valueSourcesNEW = getValueSources(fd.value as GetOptionIdentifierType<F>, operator as O, {\n fieldData: fd as F,\n });\n }\n\n if (!valueSourcesNEW) {\n return defaultValueSourcesArray;\n }\n\n if (isFlexibleOptionArray(valueSourcesNEW)) {\n return toFullOptionList(valueSourcesNEW as ValueSourceFullOptions) as ValueSourceFullOptions;\n }\n\n return valueSourcesNEW.map(\n vs =>\n defaultValueSourcesArray.find(dmm => dmm.value === lc(vs)) ?? {\n name: vs,\n value: vs,\n label: vs,\n }\n ) as ValueSourceFullOptions;\n};\n","import type {\n DefaultOperatorName,\n FullField,\n FullOption,\n OptionList,\n ValueSource,\n ValueSourceFlexibleOptions,\n ValueSources,\n} from '../types';\nimport { filterFieldsByComparator } from './filterFieldsByComparator';\nimport { getValueSourcesUtil } from './getValueSourcesUtil';\nimport { isFlexibleOptionArray, toFlatOptionArray, toFullOption } from './optGroupUtils';\n\nexport const getFieldsArray = (\n fields?: OptionList<FullField> | Record<string, FullField>\n): FullOption[] => {\n const fieldsArray = fields\n ? Array.isArray(fields)\n ? fields\n : Object.keys(fields)\n .map(fld => Object.assign({}, fields[fld], { name: fld }))\n // oxlint-disable-next-line no-array-sort\n .sort((a, b) => a.label.localeCompare(b.label))\n : [];\n return toFlatOptionArray(fieldsArray);\n};\n\nexport function fieldIsValidUtil(params: {\n fieldsFlat: FullField[];\n getValueSources?: (field: string, operator: string) => ValueSources | ValueSourceFlexibleOptions;\n fieldName: string;\n operator: DefaultOperatorName;\n subordinateFieldName?: string;\n}): boolean {\n const { fieldsFlat, fieldName, operator, subordinateFieldName, getValueSources } = params;\n\n const vsIncludes = (vs: ValueSource) => {\n const vss = getValueSourcesUtil(primaryField, operator, getValueSources);\n return isFlexibleOptionArray(vss) && vss.some(vso => vso.value === vs || vso.name === vs);\n };\n\n // If fields option was an empty array or undefined, then all identifiers\n // are considered valid.\n if (fieldsFlat.length === 0) return true;\n\n let valid = false;\n\n const primaryField = toFullOption(fieldsFlat.find(ff => ff.name === fieldName)!);\n if (primaryField) {\n valid = !(\n !subordinateFieldName &&\n operator !== 'notNull' &&\n operator !== 'null' &&\n !vsIncludes('value')\n );\n\n if (valid && !!subordinateFieldName) {\n if (vsIncludes('field') && fieldName !== subordinateFieldName) {\n const validSubordinateFields = filterFieldsByComparator(\n primaryField,\n fieldsFlat,\n operator\n ) as FullField[];\n if (!validSubordinateFields.some(vsf => vsf.name === subordinateFieldName)) {\n valid = false;\n }\n } else {\n valid = false;\n }\n }\n }\n\n return valid;\n}\n","/* v8 ignore file -- this is fine */\n\ntype UUID = `${string}-${string}-${string}-${string}-${string}`;\n\nconst cryptoModule = globalThis.crypto;\n\nexport const uuidV4regex: RegExp =\n /^[\\da-f]{8}-[\\da-f]{4}-4[\\da-f]{3}-[89ab][\\da-f]{3}-[\\da-f]{12}$/i;\n\n/**\n * Default `id` generator. Generates a valid v4 UUID. Uses `crypto.randomUUID()`\n * when available, otherwise uses an alternate method based on `getRandomValues`.\n * The returned string is guaranteed to match this regex:\n * ```\n * /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i\n * ```\n * @returns Valid v4 UUID\n */\n// Default implementation adapted from https://stackoverflow.com/a/68141099/217579\n// v8 ignore next\nexport let generateID = (): UUID =>\n '00-0-4-2-000'.replaceAll(/[^-]/g, s =>\n (((Math.random() + Math.trunc(s as unknown as number)) * 0x1_00_00) >> Number.parseInt(s))\n .toString(16)\n .padStart(4, '0')\n ) as UUID;\n\n// Improve on the default implementation by using the crypto package if it's available\n// v8 ignore else\nif (cryptoModule) {\n // v8 ignore else\n if (typeof cryptoModule.randomUUID === 'function') {\n generateID = () => cryptoModule.randomUUID();\n } else if (typeof cryptoModule.getRandomValues === 'function') {\n // `randomUUID` is much simpler and faster, but it's only guaranteed to be\n // available in secure contexts (server-side, https, etc.). `generateID`\n // doesn't really need to be cryptographically secure, it only needs a\n // fairly low chance of collisions. We fall back to the always-available\n // `getRandomValues` here (while still generating a valid v4 UUID) when\n // `randomUUID` is not available.\n const position19vals = '89ab';\n const container = new Uint32Array(32);\n\n generateID = () => {\n cryptoModule.getRandomValues(container);\n let id = (container[0] % 16).toString(16);\n for (let i = 1; i < 32; i++) {\n if (i === 12) {\n id = `${id}${'4'}`;\n } else if (i === 16) {\n id = `${id}${position19vals[container[17] % 4]}`;\n } else {\n id = `${id}${(container[i] % 16).toString(16)}`;\n }\n\n if (i === 7 || i === 11 || i === 15 || i === 19) {\n id = `${id}${'-'}`;\n }\n }\n return id as UUID;\n };\n }\n}\n","import type {\n RuleGroupArray,\n RuleGroupICArray,\n RuleGroupType,\n RuleGroupTypeAny,\n RuleGroupTypeIC,\n RuleType,\n} from '../types';\nimport { processMatchMode } from './formatQuery/utils';\nimport { generateID } from './generateID';\nimport { isRuleGroup } from './isRuleGroup';\n\n/**\n * Options for {@link prepareRule}/{@link prepareRuleGroup}.\n */\nexport interface PreparerOptions {\n idGenerator?: () => string;\n}\n\n/**\n * Ensures that a rule is valid by adding an `id` property if it does not already exist.\n */\nexport const prepareRule = (\n rule: RuleType,\n { idGenerator = generateID }: PreparerOptions = {}\n): RuleType => {\n const needsId = !rule.id;\n const hasMatchMode = processMatchMode(rule);\n\n if (!needsId && !hasMatchMode) {\n return rule;\n }\n\n return {\n ...rule,\n ...(needsId && { id: idGenerator() }),\n ...(hasMatchMode && { value: prepareRuleGroup(rule.value, { idGenerator }) }),\n };\n};\n\n/**\n * Ensures that a rule group is valid by recursively adding an `id` property to the group itself\n * and all its rules and subgroups where one does not already exist.\n */\nexport const prepareRuleGroup = <RG extends RuleGroupTypeAny>(\n queryObject: RG,\n { idGenerator = generateID }: PreparerOptions = {}\n): RG => {\n const needsId = !queryObject.id;\n let rulesChanged = false;\n const newRules: (RuleGroupTypeAny | RuleType | string)[] = [];\n\n for (let i = 0; i < queryObject.rules.length; i++) {\n const r = queryObject.rules[i];\n if (typeof r === 'string') {\n newRules.push(r);\n } else {\n const prepared = isRuleGroup(r)\n ? prepareRuleGroup(r, { idGenerator })\n : prepareRule(r, { idGenerator });\n newRules.push(prepared);\n if (prepared !== r) {\n rulesChanged = true;\n }\n }\n }\n\n if (!needsId && !rulesChanged) {\n return queryObject;\n }\n\n return {\n ...queryObject,\n ...(needsId && { id: idGenerator() }),\n rules: newRules as RuleGroupArray | RuleGroupICArray,\n };\n};\n\n/**\n * Ensures that a rule or group is valid. See {@link prepareRule} and {@link prepareRuleGroup}.\n */\nexport const prepareRuleOrGroup = (\n rg: RuleGroupTypeAny | RuleType,\n { idGenerator = generateID }: PreparerOptions = {}\n): RuleGroupType | RuleGroupTypeIC | RuleType =>\n isRuleGroup(rg) ? prepareRuleGroup(rg, { idGenerator }) : prepareRule(rg, { idGenerator });\n"],"mappings":";;;AAGA,MAAM,sBAAsB,OAAkB,UAAkB,mBAA8B;CAC5F,MAAM,YAAY,aAAa,KAAK;CACpC,MAAM,qBAAqB,aAAa,cAAc;CACtD,IAAI,UAAU,UAAU,mBAAmB,OACzC,OAAO;CAET,IAAI,OAAO,UAAU,eAAe,UAClC,OAAO,UAAU,UAAU,gBAAgB,mBAAmB,UAAU;CAE1E,OACE,UAAU,aAAa,oBA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IACnC,YAAY,GAAG,EAAE,YAAY,CAAC;GAClC,SAAS,KAAK,QAAQ;GACtB,IAAI,aAAa,GACf,eAAe;EAEnB;CACF;CAEA,IAAI,CAAC,WAAW,CAAC,cACf,OAAO;CAGT,OAAO;EACL,GAAG;EACH,GAAI,WAAW,EAAE,IAAI,YAAY,EAAE;EACnC,OAAO;CACT;AACF"}
@@ -1,4 +1,4 @@
1
- const require_utils = require("./utils-DEwV7F6B.js");
1
+ const require_utils = require("./utils-SchkzSCN.js");
2
2
  const require_isRuleGroup = require("./isRuleGroup-0JNiQgLg.js");
3
3
  //#region src/utils/filterFieldsByComparator.ts
4
4
  const filterByComparator = (field, operator, fieldToCompare) => {
@@ -181,4 +181,4 @@ Object.defineProperty(exports, "prepareRuleGroup", {
181
181
  }
182
182
  });
183
183
 
184
- //# sourceMappingURL=prepareQueryObjects-C2-kTZvR.js.map
184
+ //# sourceMappingURL=prepareQueryObjects-C5dHLhnC.js.map