@react-querybuilder/core 8.13.0 → 8.14.1

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 (100) hide show
  1. package/dist/{basic-Cw014pDc.d.mts → basic-BXJVfD0P.d.ts} +77 -59
  2. package/dist/{basic-_KlsCAyT.d.ts → basic-CNIjb6rI.d.mts} +77 -59
  3. package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +201 -150
  4. package/dist/cjs/react-querybuilder_core.cjs.development.js +323 -252
  5. package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
  6. package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +201 -150
  7. package/dist/cjs/react-querybuilder_core.cjs.production.js +1 -1
  8. package/dist/cjs/react-querybuilder_core.cjs.production.js.map +1 -1
  9. package/dist/{convertQuery-DAj92cbM.mjs → convertQuery-B5Qm_6ut.mjs} +30 -22
  10. package/dist/convertQuery-B5Qm_6ut.mjs.map +1 -0
  11. package/dist/convertQuery-DfZehtnd.js +94 -0
  12. package/dist/convertQuery-DfZehtnd.js.map +1 -0
  13. package/dist/{export-CffjLxEe.d.mts → export-6x7MilFR.d.mts} +2 -3
  14. package/dist/{export-DRA8O1Wz.d.ts → export-CpJOQuZv.d.ts} +2 -3
  15. package/dist/formatQuery.d.mts +4 -3
  16. package/dist/formatQuery.d.ts +4 -3
  17. package/dist/formatQuery.js +42 -51
  18. package/dist/formatQuery.js.map +1 -1
  19. package/dist/formatQuery.mjs +41 -50
  20. package/dist/formatQuery.mjs.map +1 -1
  21. package/dist/{import-CWYJkN_w.d.ts → import-B5Iq8XmL.d.ts} +2 -3
  22. package/dist/{import-DjHGaGhJ.d.mts → import-Bltb2mT4.d.mts} +2 -3
  23. package/dist/{isRuleGroup-Cjk1Q2mj.js → isRuleGroup-BCwaLzDj.js} +38 -40
  24. package/dist/isRuleGroup-BCwaLzDj.js.map +1 -0
  25. package/dist/{isRuleGroup-DztIOOKa.mjs → isRuleGroup-LzP0HCKh.mjs} +2 -4
  26. package/dist/isRuleGroup-LzP0HCKh.mjs.map +1 -0
  27. package/dist/parseCEL.d.mts +2 -2
  28. package/dist/parseCEL.d.ts +2 -2
  29. package/dist/parseCEL.js +14 -16
  30. package/dist/parseCEL.js.map +1 -1
  31. package/dist/parseCEL.mjs +7 -10
  32. package/dist/parseCEL.mjs.map +1 -1
  33. package/dist/parseJSONata.d.mts +2 -3
  34. package/dist/parseJSONata.d.ts +2 -3
  35. package/dist/parseJSONata.js +37 -5611
  36. package/dist/parseJSONata.js.map +1 -1
  37. package/dist/parseJSONata.mjs +11 -14
  38. package/dist/parseJSONata.mjs.map +1 -1
  39. package/dist/parseJsonLogic.d.mts +3 -4
  40. package/dist/parseJsonLogic.d.ts +3 -4
  41. package/dist/parseJsonLogic.js +20 -21
  42. package/dist/parseJsonLogic.js.map +1 -1
  43. package/dist/parseJsonLogic.mjs +19 -21
  44. package/dist/parseJsonLogic.mjs.map +1 -1
  45. package/dist/parseMongoDB.d.mts +2 -3
  46. package/dist/parseMongoDB.d.ts +2 -3
  47. package/dist/parseMongoDB.js +7 -8
  48. package/dist/parseMongoDB.js.map +1 -1
  49. package/dist/parseMongoDB.mjs +6 -8
  50. package/dist/parseMongoDB.mjs.map +1 -1
  51. package/dist/parseSQL.d.mts +2 -3
  52. package/dist/parseSQL.d.ts +2 -3
  53. package/dist/parseSQL.js +14 -16
  54. package/dist/parseSQL.js.map +1 -1
  55. package/dist/parseSQL.mjs +7 -10
  56. package/dist/parseSQL.mjs.map +1 -1
  57. package/dist/parseSpEL.d.mts +2 -3
  58. package/dist/parseSpEL.d.ts +2 -3
  59. package/dist/parseSpEL.js +11 -2700
  60. package/dist/parseSpEL.js.map +1 -1
  61. package/dist/parseSpEL.mjs +7 -9
  62. package/dist/parseSpEL.mjs.map +1 -1
  63. package/dist/{prepareQueryObjects-CkN0bTKm.js → prepareQueryObjects-Dc8rqsYM.js} +50 -38
  64. package/dist/prepareQueryObjects-Dc8rqsYM.js.map +1 -0
  65. package/dist/{prepareQueryObjects-6Bxx4Bs1.mjs → prepareQueryObjects-tMukQHT9.mjs} +35 -22
  66. package/dist/prepareQueryObjects-tMukQHT9.mjs.map +1 -0
  67. package/dist/react-querybuilder_core.d.mts +201 -150
  68. package/dist/react-querybuilder_core.legacy-esm.d.ts +201 -150
  69. package/dist/react-querybuilder_core.legacy-esm.js +317 -280
  70. package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
  71. package/dist/react-querybuilder_core.mjs +312 -248
  72. package/dist/react-querybuilder_core.mjs.map +1 -1
  73. package/dist/react-querybuilder_core.production.d.mts +201 -150
  74. package/dist/react-querybuilder_core.production.mjs +1 -1
  75. package/dist/react-querybuilder_core.production.mjs.map +1 -1
  76. package/dist/transformQuery.d.mts +1 -2
  77. package/dist/transformQuery.d.ts +1 -2
  78. package/dist/transformQuery.js +44 -3
  79. package/dist/transformQuery.js.map +1 -0
  80. package/dist/transformQuery.mjs +43 -3
  81. package/dist/transformQuery.mjs.map +1 -0
  82. package/dist/{utils-nQU7WCM9.mjs → utils-DQoYnxpa.mjs} +32 -84
  83. package/dist/utils-DQoYnxpa.mjs.map +1 -0
  84. package/dist/{utils-CR1ToTMW.js → utils-EsYRkPtf.js} +182 -246
  85. package/dist/utils-EsYRkPtf.js.map +1 -0
  86. package/package.json +29 -21
  87. package/dist/chunk-U64pC571.js +0 -41
  88. package/dist/convertQuery-DAj92cbM.mjs.map +0 -1
  89. package/dist/convertQuery-DRldbzhZ.js +0 -87
  90. package/dist/convertQuery-DRldbzhZ.js.map +0 -1
  91. package/dist/isRuleGroup-Cjk1Q2mj.js.map +0 -1
  92. package/dist/isRuleGroup-DztIOOKa.mjs.map +0 -1
  93. package/dist/prepareQueryObjects-6Bxx4Bs1.mjs.map +0 -1
  94. package/dist/prepareQueryObjects-CkN0bTKm.js.map +0 -1
  95. package/dist/transformQuery-ClBRfnFg.js +0 -54
  96. package/dist/transformQuery-ClBRfnFg.js.map +0 -1
  97. package/dist/transformQuery-DUpbpqjX.mjs +0 -48
  98. package/dist/transformQuery-DUpbpqjX.mjs.map +0 -1
  99. package/dist/utils-CR1ToTMW.js.map +0 -1
  100. package/dist/utils-nQU7WCM9.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-EsYRkPtf.js","names":["isPojo","lc","isRuleGroup","numericRegex","isPojo"],"sources":["../src/defaults.ts","../src/utils/arrayUtils.ts","../src/utils/parseNumber.ts","../src/utils/objectUtils.ts","../src/utils/optGroupUtils.ts","../src/utils/getParseNumberMethod.ts","../src/utils/formatQuery/utils.ts"],"sourcesContent":["import type {\n BaseTranslationsFull,\n Classnames,\n DefaultCombinatorName,\n DefaultCombinatorNameExtended,\n DefaultOperatorName,\n MatchMode,\n Path,\n QueryBuilderFlags,\n StringUnionToFullOptionArray,\n} from './types';\n\n// DO NOT ALTER OR REMOVE REGION NAMES. Some of them are used\n// to generate code snippets in the documentation.\n\n/**\n * @group Defaults\n */\nexport const defaultPlaceholderName = '~';\n/**\n * @group Defaults\n */\nexport const defaultPlaceholderLabel = '------';\n/**\n * Default `name` for placeholder option in the `fields` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderFieldName: typeof defaultPlaceholderName = defaultPlaceholderName;\n/**\n * Default `label` for placeholder option in the `fields` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderFieldLabel: typeof defaultPlaceholderLabel = defaultPlaceholderLabel;\n/**\n * Default `label` for placeholder option group in the `fields` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderFieldGroupLabel: typeof defaultPlaceholderLabel =\n defaultPlaceholderLabel;\n/**\n * Default `name` for placeholder option in the `operators` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderOperatorName: typeof defaultPlaceholderName = defaultPlaceholderName;\n/**\n * Default `label` for placeholder option in the `operators` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderOperatorLabel: typeof defaultPlaceholderLabel =\n defaultPlaceholderLabel;\n/**\n * Default `label` for placeholder option group in the `operators` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderOperatorGroupLabel: typeof defaultPlaceholderLabel =\n defaultPlaceholderLabel;\n/**\n * Default `name` for placeholder option in the `values` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderValueName: typeof defaultPlaceholderName = defaultPlaceholderName;\n/**\n * Default `label` for placeholder option in the `values` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderValueLabel: typeof defaultPlaceholderLabel = defaultPlaceholderLabel;\n/**\n * Default `label` for placeholder option group in the `values` array.\n *\n * @group Defaults\n */\nexport const defaultPlaceholderValueGroupLabel: typeof defaultPlaceholderLabel =\n defaultPlaceholderLabel;\n\n/**\n * Default configuration of translatable strings.\n *\n * @group Defaults\n */\n// #region docs-translations\nexport const defaultTranslations: BaseTranslationsFull = {\n fields: {\n title: 'Field',\n placeholderName: defaultPlaceholderFieldName,\n placeholderLabel: defaultPlaceholderFieldLabel,\n placeholderGroupLabel: defaultPlaceholderFieldGroupLabel,\n } as const,\n operators: {\n title: 'Operator',\n placeholderName: defaultPlaceholderOperatorName,\n placeholderLabel: defaultPlaceholderOperatorLabel,\n placeholderGroupLabel: defaultPlaceholderOperatorGroupLabel,\n } as const,\n values: {\n title: 'Values',\n placeholderName: defaultPlaceholderValueName,\n placeholderLabel: defaultPlaceholderValueLabel,\n placeholderGroupLabel: defaultPlaceholderValueGroupLabel,\n } as const,\n matchMode: { title: 'Match mode' } as const,\n matchThreshold: { title: 'Match threshold' } as const,\n value: { title: 'Value' } as const,\n removeRule: { label: '⨯', title: 'Remove rule' } as const,\n removeGroup: { label: '⨯', title: 'Remove group' } as const,\n addRule: { label: '+ Rule', title: 'Add rule' } as const,\n addGroup: { label: '+ Group', title: 'Add group' } as const,\n combinators: { title: 'Combinator' } as const,\n notToggle: { label: 'Not', title: 'Invert this group' } as const,\n cloneRule: { label: '⧉', title: 'Clone rule' } as const,\n cloneRuleGroup: { label: '⧉', title: 'Clone group' } as const,\n shiftActionUp: { label: '˄', title: 'Shift up' } as const,\n shiftActionDown: { label: '˅', title: 'Shift down' } as const,\n dragHandle: { label: '⁞⁞', title: 'Drag handle' } as const,\n lockRule: { label: '🔓', title: 'Lock rule' } as const,\n lockGroup: { label: '🔓', title: 'Lock group' } as const,\n lockRuleDisabled: { label: '🔒', title: 'Unlock rule' } as const,\n lockGroupDisabled: { label: '🔒', title: 'Unlock group' } as const,\n muteRule: { label: '🔊', title: 'Mute rule' } as const,\n muteGroup: { label: '🔊', title: 'Mute group' } as const,\n unmuteRule: { label: '🔇', title: 'Unmute rule' } as const,\n unmuteGroup: { label: '🔇', title: 'Unmute group' } as const,\n valueSourceSelector: { title: 'Value source' } as const,\n} satisfies BaseTranslationsFull;\n// #endregion\n\n/**\n * Default character used to `.join` and `.split` arrays.\n *\n * @group Defaults\n */\nexport const defaultJoinChar = ',';\n\nexport type DefaultOperators = StringUnionToFullOptionArray<DefaultOperatorName>;\n\nexport const defaultOperatorLabelMap: Record<DefaultOperatorName, string> = {\n '=': '=',\n '!=': '!=',\n '<': '<',\n '>': '>',\n '<=': '<=',\n '>=': '>=',\n contains: 'contains',\n beginsWith: 'begins with',\n endsWith: 'ends with',\n doesNotContain: 'does not contain',\n doesNotBeginWith: 'does not begin with',\n doesNotEndWith: 'does not end with',\n null: 'is null',\n notNull: 'is not null',\n in: 'in',\n notIn: 'not in',\n between: 'between',\n notBetween: 'not between',\n};\n\nexport const defaultCombinatorLabelMap: Record<DefaultCombinatorNameExtended, string> = {\n and: 'AND',\n or: 'OR',\n xor: 'XOR',\n};\n\n/**\n * Default operator list.\n *\n * @group Defaults\n */\n// #region docs-operators\nexport const defaultOperators: DefaultOperators = [\n { name: '=', value: '=', label: '=' },\n { name: '!=', value: '!=', label: '!=' },\n { name: '<', value: '<', label: '<' },\n { name: '>', value: '>', label: '>' },\n { name: '<=', value: '<=', label: '<=' },\n { name: '>=', value: '>=', label: '>=' },\n { name: 'contains', value: 'contains', label: 'contains' },\n { name: 'beginsWith', value: 'beginsWith', label: 'begins with' },\n { name: 'endsWith', value: 'endsWith', label: 'ends with' },\n { name: 'doesNotContain', value: 'doesNotContain', label: 'does not contain' },\n { name: 'doesNotBeginWith', value: 'doesNotBeginWith', label: 'does not begin with' },\n { name: 'doesNotEndWith', value: 'doesNotEndWith', label: 'does not end with' },\n { name: 'null', value: 'null', label: 'is null' },\n { name: 'notNull', value: 'notNull', label: 'is not null' },\n { name: 'in', value: 'in', label: 'in' },\n { name: 'notIn', value: 'notIn', label: 'not in' },\n { name: 'between', value: 'between', label: 'between' },\n { name: 'notBetween', value: 'notBetween', label: 'not between' },\n];\n// #endregion\n\n/**\n * Map of default operators to their respective opposite/negating operators.\n *\n * @group Defaults\n */\nexport const defaultOperatorNegationMap: Record<DefaultOperatorName, DefaultOperatorName> = {\n '=': '!=',\n '!=': '=',\n '<': '>=',\n '<=': '>',\n '>': '<=',\n '>=': '<',\n beginsWith: 'doesNotBeginWith',\n doesNotBeginWith: 'beginsWith',\n endsWith: 'doesNotEndWith',\n doesNotEndWith: 'endsWith',\n contains: 'doesNotContain',\n doesNotContain: 'contains',\n between: 'notBetween',\n notBetween: 'between',\n in: 'notIn',\n notIn: 'in',\n notNull: 'null',\n null: 'notNull',\n} satisfies Record<DefaultOperatorName, DefaultOperatorName>;\n\nexport type DefaultCombinators = StringUnionToFullOptionArray<DefaultCombinatorName>;\n\n/**\n * Default combinator list.\n *\n * @group Defaults\n */\n// #region docs-combinators\nexport const defaultCombinators: DefaultCombinators = [\n { name: 'and', value: 'and', label: 'AND' } as const,\n { name: 'or', value: 'or', label: 'OR' } as const,\n];\n// #endregion\n\nexport type DefaultCombinatorsExtended =\n StringUnionToFullOptionArray<DefaultCombinatorNameExtended>;\n\n/**\n * Default combinator list, with `XOR` added.\n *\n * @group Defaults\n */\nexport const defaultCombinatorsExtended: DefaultCombinatorsExtended = [\n ...defaultCombinators,\n { name: 'xor', value: 'xor', label: 'XOR' } as const,\n];\n\nexport type DefaultMatchModes = StringUnionToFullOptionArray<MatchMode>;\n\n/**\n * Default match modes.\n *\n * @group Defaults\n */\n// #region docs-matchmodes\nexport const defaultMatchModes: DefaultMatchModes = [\n { name: 'all', value: 'all', label: 'all' },\n { name: 'some', value: 'some', label: 'some' },\n { name: 'none', value: 'none', label: 'none' },\n { name: 'atLeast', value: 'atLeast', label: 'at least' },\n { name: 'atMost', value: 'atMost', label: 'at most' },\n { name: 'exactly', value: 'exactly', label: 'exactly' },\n];\n// #endregion\n\n/**\n * Standard classnames applied to each component.\n *\n * @group Defaults\n */\n// #region docs-standardclassnames\nexport const standardClassnames = {\n queryBuilder: 'queryBuilder',\n ruleGroup: 'ruleGroup',\n header: 'ruleGroup-header',\n body: 'ruleGroup-body',\n combinators: 'ruleGroup-combinators',\n addRule: 'ruleGroup-addRule',\n addGroup: 'ruleGroup-addGroup',\n cloneRule: 'rule-cloneRule',\n cloneGroup: 'ruleGroup-cloneGroup',\n removeGroup: 'ruleGroup-remove',\n notToggle: 'ruleGroup-notToggle',\n rule: 'rule',\n fields: 'rule-fields',\n matchMode: 'rule-matchMode',\n matchThreshold: 'rule-matchThreshold',\n operators: 'rule-operators',\n value: 'rule-value',\n removeRule: 'rule-remove',\n betweenRules: 'betweenRules',\n valid: 'queryBuilder-valid',\n invalid: 'queryBuilder-invalid',\n shiftActions: 'shiftActions',\n dndDragging: 'dndDragging',\n dndOver: 'dndOver',\n dndCopy: 'dndCopy',\n dndGroup: 'dndGroup',\n dndDropNotAllowed: 'dndDropNotAllowed',\n dragHandle: 'queryBuilder-dragHandle',\n disabled: 'queryBuilder-disabled',\n muted: 'queryBuilder-muted',\n lockRule: 'rule-lock',\n lockGroup: 'ruleGroup-lock',\n muteRule: 'rule-mute',\n muteGroup: 'ruleGroup-mute',\n valueSource: 'rule-valueSource',\n valueListItem: 'rule-value-list-item',\n branches: 'queryBuilder-branches',\n justified: 'queryBuilder-justified',\n hasSubQuery: 'rule-hasSubQuery',\n loading: 'queryBuilder-loading',\n} as const;\n// #endregion\n\n/**\n * Default classnames for each component.\n *\n * @group Defaults\n */\nexport const defaultControlClassnames: Classnames = {\n queryBuilder: '',\n ruleGroup: '',\n header: '',\n body: '',\n combinators: '',\n addRule: '',\n addGroup: '',\n cloneRule: '',\n cloneGroup: '',\n removeGroup: '',\n notToggle: '',\n rule: '',\n fields: '',\n matchMode: '',\n matchThreshold: '',\n operators: '',\n value: '',\n removeRule: '',\n shiftActions: '',\n dragHandle: '',\n lockRule: '',\n lockGroup: '',\n muteRule: '',\n muteGroup: '',\n muted: '',\n valueSource: '',\n actionElement: '',\n valueSelector: '',\n betweenRules: '',\n valid: '',\n invalid: '',\n dndDragging: '',\n dndOver: '',\n dndGroup: '',\n dndCopy: '',\n dndDropNotAllowed: '',\n disabled: '',\n valueListItem: '',\n branches: '',\n hasSubQuery: '',\n loading: '',\n} satisfies Classnames;\n\n/**\n * Default reason codes for a group being invalid.\n *\n * @group Defaults\n */\nexport const groupInvalidReasons = {\n empty: 'empty',\n invalidCombinator: 'invalid combinator',\n invalidIndependentCombinators: 'invalid independent combinators',\n} as const;\n\n/**\n * Component identifiers for testing.\n *\n * @group Defaults\n */\nexport const TestID = {\n rule: 'rule',\n ruleGroup: 'rule-group',\n inlineCombinator: 'inline-combinator',\n addGroup: 'add-group',\n removeGroup: 'remove-group',\n cloneGroup: 'clone-group',\n cloneRule: 'clone-rule',\n addRule: 'add-rule',\n removeRule: 'remove-rule',\n combinators: 'combinators',\n fields: 'fields',\n operators: 'operators',\n valueEditor: 'value-editor',\n notToggle: 'not-toggle',\n shiftActions: 'shift-actions',\n dragHandle: 'drag-handle',\n lockRule: 'lock-rule',\n lockGroup: 'lock-group',\n muteRule: 'mute-rule',\n muteGroup: 'mute-group',\n valueSourceSelector: 'value-source-selector',\n matchModeEditor: 'match-mode-editor',\n} as const;\n\nexport const LogType = {\n parentPathDisabled: 'action aborted: parent path disabled',\n pathDisabled: 'action aborted: path is disabled',\n queryUpdate: 'query updated',\n onAddRuleFalse: 'onAddRule callback returned false',\n onAddGroupFalse: 'onAddGroup callback returned false',\n onGroupRuleFalse: 'onGroupRule callback returned false',\n onGroupGroupFalse: 'onGroupGroup callback returned false',\n onMoveRuleFalse: 'onMoveRule callback returned false',\n onMoveGroupFalse: 'onMoveGroup callback returned false',\n onRemoveFalse: 'onRemove callback returned false',\n add: 'rule or group added',\n remove: 'rule or group removed',\n update: 'rule or group updated',\n move: 'rule or group moved',\n group: 'rule or group grouped with another',\n} as const;\n\n/**\n * The {@link Path} of the root group.\n *\n * @group Defaults\n */\nexport const rootPath: Path = [] satisfies Path;\n\n/**\n * Default values for all `boolean`\n * {@link react-querybuilder!QueryBuilder QueryBuilder} options.\n *\n * @group Defaults\n */\nexport const queryBuilderFlagDefaults: Required<QueryBuilderFlags> = {\n addRuleToNewGroups: false,\n autoSelectField: true,\n autoSelectOperator: true,\n autoSelectValue: false,\n debugMode: false,\n enableDragAndDrop: false,\n enableMountQueryChange: true,\n listsAsArrays: false,\n resetOnFieldChange: true,\n resetOnOperatorChange: false,\n showCloneButtons: false,\n showCombinatorsBetweenRules: false,\n showLockButtons: false,\n showMuteButtons: false,\n showNotToggle: false,\n showShiftActions: false,\n suppressStandardClassnames: false,\n};\n","import { defaultJoinChar } from '../defaults';\n\n/**\n * Splits a string by a given character (see {@link defaultJoinChar}). Escaped characters\n * (characters preceded by a backslash) will not apply to the split, and the backslash will\n * be removed in the array element. Inverse of {@link joinWith}.\n *\n * @example\n * splitBy('this\\\\,\\\\,that,,the other,,,\\\\,')\n * // or\n * splitBy('this\\\\,\\\\,that,,the other,,,\\\\,', ',')\n * // would return\n * ['this,,that', '', 'the other', '', '', ',']\n */\nexport const splitBy = (str?: string, splitChar: string = defaultJoinChar): string[] =>\n typeof str === 'string'\n ? str\n .split(`\\\\${splitChar}`)\n .map(c => c.split(splitChar))\n .reduce((prev, curr, idx) => {\n if (idx === 0) {\n return curr;\n }\n return [...prev.slice(0, -1), `${prev.at(-1)}${splitChar}${curr[0]}`, ...curr.slice(1)];\n }, [])\n : [];\n\n/**\n * Joins an array of strings using the given character (see {@link defaultJoinChar}). When\n * the given character appears in an array element, a backslash will be added just before it\n * to distinguish it from the join character. Effectively the inverse of {@link splitBy}.\n *\n * TIP: The join character can actually be a string of any length. Only the first character\n * will be searched for in the array elements and preceded by a backslash.\n *\n * @example\n * joinWith(['this,,that', '', 'the other', '', '', ','], ', ')\n * // would return\n * 'this\\\\,\\\\,that, , the other, , , \\\\,'\n */\n// oxlint-disable-next-line typescript/no-explicit-any\nexport const joinWith = (strArr: any[], joinChar: string = defaultJoinChar): string =>\n strArr.map(str => `${str ?? ''}`.replaceAll(joinChar[0], `\\\\${joinChar[0]}`)).join(joinChar);\n\n/**\n * Trims the value if it is a string. Otherwise returns the value as is.\n */\n// oxlint-disable-next-line typescript/no-explicit-any\nexport const trimIfString = (val: any): any => (typeof val === 'string' ? val.trim() : val);\n\n/**\n * Splits a string by comma then trims each element. Arrays are returned as is except\n * any string elements are trimmed.\n */\nexport const toArray = (\n // oxlint-disable-next-line typescript/no-explicit-any\n a: any,\n { retainEmptyStrings }: { retainEmptyStrings?: boolean } = {}\n // oxlint-disable-next-line typescript/no-explicit-any\n): any[] =>\n Array.isArray(a)\n ? a.map(v => trimIfString(v))\n : typeof a === 'string'\n ? splitBy(a, defaultJoinChar)\n .filter(retainEmptyStrings ? () => true : s => !/^\\s*$/.test(s))\n .map(s => s.trim())\n : typeof a === 'number'\n ? [a]\n : [];\n\n/**\n * Determines if an array is free of `null`/`undefined`.\n */\nexport const nullFreeArray = <T>(arr: T[]): arr is Exclude<T, null>[] =>\n arr.every(el => el === false || (el ?? false) !== false);\n","import { numericQuantity } from 'numeric-quantity';\nimport type { ParseNumberMethod } from '../types';\n\n/**\n * Options object for {@link parseNumber}.\n */\nexport interface ParseNumberOptions {\n parseNumbers?: ParseNumberMethod;\n /**\n * Generates a `bigint` value if the string represents a valid integer\n * outside the safe boundaries of the `number` type.\n */\n bigIntOnOverflow?: boolean;\n}\n\n/**\n * Converts a string to a number. Uses native `parseFloat` if `parseNumbers` is \"native\",\n * otherwise uses [`numeric-quantity`](https://jakeboone02.github.io/numeric-quantity/).\n * If that returns `NaN`, the string is returned unchanged. Numeric values are returned\n * as-is regardless of the `parseNumbers` option.\n */\nexport const parseNumber = (\n // oxlint-disable-next-line typescript/no-explicit-any\n val: any,\n { parseNumbers, bigIntOnOverflow }: ParseNumberOptions = {}\n // oxlint-disable-next-line typescript/no-explicit-any\n): any => {\n if (!parseNumbers || typeof val === 'bigint' || typeof val === 'number') {\n return val;\n }\n\n if (parseNumbers === 'native') {\n return Number.parseFloat(val);\n }\n\n const valAsNum: number | bigint =\n // TODO: Should these options be configurable?\n numericQuantity(val, {\n allowTrailingInvalid: parseNumbers === 'enhanced',\n bigIntOnOverflow,\n romanNumerals: false,\n round: false,\n });\n\n return typeof valAsNum === 'bigint' || !Number.isNaN(valAsNum) ? valAsNum : val;\n};\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","import type { RequireAtLeastOne } from 'type-fest';\nimport { defaultPlaceholderLabel, defaultPlaceholderName } from '../defaults';\nimport type {\n BaseOption,\n BaseOptionMap,\n FlexibleOption,\n FlexibleOptionGroup,\n FlexibleOptionList,\n FlexibleOptionListProp,\n FullOption,\n FullOptionList,\n FullOptionMap,\n FullOptionRecord,\n GetOptionIdentifierType,\n Option,\n OptionGroup,\n Placeholder,\n ToFullOption,\n ValueOption,\n WithUnknownIndex,\n} from '../types';\nimport { isPojo } from './misc';\nimport { objectKeys } from './objectUtils';\n\nconst isOptionWithName = (opt: BaseOption): opt is Option =>\n isPojo(opt) && 'name' in opt && typeof opt.name === 'string';\nconst isOptionWithValue = (opt: BaseOption): opt is ValueOption =>\n isPojo(opt) && 'value' in opt && typeof opt.value === 'string';\n\n/**\n * Converts an {@link Option} or {@link ValueOption} (i.e., {@link BaseOption})\n * into a {@link FullOption}. Full options are left unchanged.\n *\n * @group Option Lists\n */\nexport function toFullOption<Opt extends BaseOption>(\n opt: Opt | string,\n baseProperties?: Record<string, unknown>,\n labelMap?: Record<string, unknown>\n): ToFullOption<Opt> {\n if (typeof opt === 'string') {\n return {\n ...baseProperties,\n name: opt,\n value: opt,\n label: labelMap?.[opt] ?? opt,\n } as ToFullOption<Opt>;\n }\n\n const idObj: { name?: string; value?: string } = {};\n let needsUpdating = !!baseProperties;\n\n if (isOptionWithName(opt) && !isOptionWithValue(opt)) {\n idObj.value = opt.name;\n needsUpdating = true;\n } else if (!isOptionWithName(opt) && isOptionWithValue(opt)) {\n idObj.name = opt.value;\n needsUpdating = true;\n }\n\n if (needsUpdating) {\n return Object.assign({}, baseProperties, opt, idObj) as ToFullOption<Opt>;\n }\n\n return opt as ToFullOption<Opt>;\n}\n\n/**\n * Converts an {@link OptionList} or {@link FlexibleOptionList} into a {@link FullOptionList}.\n * Lists of full options are left unchanged.\n *\n * @group Option Lists\n */\nexport function toFullOptionList<Opt extends BaseOption>(\n optList: unknown[],\n baseProperties?: Record<string, unknown>,\n labelMap?: Record<string, unknown>\n): FullOptionList<Opt> {\n if (!Array.isArray(optList)) {\n return [] as unknown as FullOptionList<Opt>;\n }\n\n const list = optList as FlexibleOptionList<Opt>;\n\n if (isFlexibleOptionGroupArray(list)) {\n return list.map(optGroup => ({\n ...optGroup,\n options: optGroup.options.map(opt => toFullOption(opt, baseProperties, labelMap)),\n })) as unknown as FullOptionList<Opt>;\n }\n\n return (list as Opt[]).map(opt =>\n toFullOption(opt, baseProperties, labelMap)\n ) as FullOptionList<Opt>;\n}\n\n/**\n * Converts a {@link FlexibleOptionList} into a {@link FullOptionList}.\n * Lists of full options are left unchanged.\n *\n * @group Option Lists\n */\nexport function toFullOptionMap<OptMap extends BaseOptionMap>(\n optMap: OptMap,\n baseProperties?: Record<string, unknown>\n): OptMap extends BaseOptionMap<infer V, infer K> ? Partial<Record<K, ToFullOption<V>>> : never {\n type FullOptMapType =\n OptMap extends BaseOptionMap<infer VT, infer KT>\n ? Partial<Record<KT, ToFullOption<VT>>>\n : never;\n\n return Object.fromEntries(\n (Object.entries(optMap) as [string, FlexibleOption][]).map(([k, v]) => [\n k,\n toFullOption(v, baseProperties),\n ])\n ) as FullOptMapType;\n}\n\n/**\n * @deprecated Renamed to {@link uniqByIdentifier}.\n *\n * @group Option Lists\n */\nexport const uniqByName = <\n T extends { name: string; value?: string } | { name?: string; value: string },\n>(\n originalArray: T[]\n): T[] => uniqByIdentifier(originalArray);\n\n/**\n * Generates a new array of objects with duplicates removed based\n * on the identifying property (`value` or `name`)\n *\n * @group Option Lists\n */\nexport const uniqByIdentifier = <\n T extends RequireAtLeastOne<{ name: string; value: string }, 'name' | 'value'>,\n>(\n originalArray: T[]\n): T[] => {\n const names = new Set<string>();\n const newArray: T[] = [];\n for (const el of originalArray) {\n if (!names.has((el.value ?? el.name)!)) {\n names.add((el.value ?? el.name)!);\n newArray.push(el);\n }\n }\n return originalArray.length === newArray.length ? originalArray : newArray;\n};\n\n/**\n * Determines if an {@link OptionList} is an {@link OptionGroup} array.\n *\n * @group Option Lists\n */\n// oxlint-disable-next-line typescript/no-explicit-any\nexport const isOptionGroupArray = (arr: any): arr is OptionGroup<BaseOption>[] =>\n Array.isArray(arr) &&\n arr.length > 0 &&\n isPojo(arr[0]) &&\n 'options' in arr[0] &&\n Array.isArray(arr[0].options);\n\n/**\n * Determines if an array is a flat array of {@link FlexibleOption}.\n *\n * @group Option Lists\n */\n// oxlint-disable-next-line typescript/no-explicit-any\nexport const isFlexibleOptionArray = (arr: any): arr is FlexibleOption[] => {\n let isFOA = false;\n if (Array.isArray(arr)) {\n for (const o of arr) {\n if (isOptionWithName(o) || isOptionWithValue(o)) {\n isFOA = true;\n } else {\n return false;\n }\n }\n }\n return isFOA;\n};\n\n/**\n * Determines if an array is a flat array of {@link FullOption}.\n *\n * @group Option Lists\n */\n// oxlint-disable-next-line typescript/no-explicit-any\nexport const isFullOptionArray = (arr: any): arr is FullOption[] => {\n let isFOA = false;\n if (Array.isArray(arr)) {\n for (const o of arr) {\n if (isOptionWithName(o) && isOptionWithValue(o)) {\n isFOA = true;\n } else {\n return false;\n }\n }\n }\n return isFOA;\n};\n\n/**\n * Determines if a {@link FlexibleOptionList} is a {@link FlexibleOptionGroup} array.\n *\n * @group Option Lists\n */\nexport const isFlexibleOptionGroupArray = (\n // oxlint-disable-next-line typescript/no-explicit-any\n arr: any,\n { allowEmpty = false }: { allowEmpty?: boolean } = {}\n): arr is FlexibleOptionGroup[] => {\n let isFOGA = false;\n if (Array.isArray(arr)) {\n for (const og of arr) {\n if (\n isPojo(og) &&\n 'options' in og &&\n (isFlexibleOptionArray(og.options) ||\n (allowEmpty && Array.isArray(og.options) && og.options.length === 0))\n ) {\n isFOGA = true;\n } else {\n return false;\n }\n }\n }\n return isFOGA;\n};\n\n/**\n * Determines if a {@link FlexibleOptionList} is a {@link OptionGroup} array of {@link FullOption}.\n *\n * @group Option Lists\n */\nexport const isFullOptionGroupArray = (\n // oxlint-disable-next-line typescript/no-explicit-any\n arr: any,\n { allowEmpty = false }: { allowEmpty?: boolean } = {}\n): arr is OptionGroup<FullOption>[] => {\n let isFOGA = false;\n if (Array.isArray(arr)) {\n for (const og of arr) {\n if (\n isPojo(og) &&\n 'options' in og &&\n (isFullOptionArray(og.options) ||\n (allowEmpty && Array.isArray(og.options) && og.options.length === 0))\n ) {\n isFOGA = true;\n } else {\n return false;\n }\n }\n }\n return isFOGA;\n};\n\n/**\n * Gets the option from an {@link OptionList} with the given `name`. Handles\n * {@link Option} arrays as well as {@link OptionGroup} arrays.\n *\n * @group Option Lists\n */\nexport function getOption<OptType extends FullOption>(\n arr: FullOptionList<OptType>,\n name: string\n): OptType | undefined;\nexport function getOption<OptType extends ValueOption>(\n arr: FlexibleOptionList<OptType>,\n name: string\n): OptType | undefined;\nexport function getOption<OptType extends Option>(\n arr: FlexibleOptionList<OptType>,\n name: string\n): OptType | undefined;\nexport function getOption<OptType extends BaseOption>(\n arr: FlexibleOptionList<OptType>,\n name: string\n): OptType | undefined {\n const options = isFlexibleOptionGroupArray(arr, { allowEmpty: true })\n ? arr.flatMap(og => og.options)\n : arr;\n return options.find(op => op.value === name || op.name === name) as OptType | undefined;\n}\n\n/**\n * Gets the first option from an {@link OptionList}.\n *\n * @group Option Lists\n */\nexport function getFirstOption<Opt extends FullOption>(\n arr?: OptionGroup<Opt>[] | Opt[]\n): GetOptionIdentifierType<Opt> | null;\nexport function getFirstOption<Opt extends ValueOption>(\n arr?: OptionGroup<Opt>[] | Opt[]\n): GetOptionIdentifierType<Opt> | null;\nexport function getFirstOption<Opt extends Option>(\n arr?: OptionGroup<Opt>[] | Opt[]\n): GetOptionIdentifierType<Opt> | null;\nexport function getFirstOption<Opt extends BaseOption>(\n arr?: FlexibleOptionGroup<Opt>[] | Opt[]\n): GetOptionIdentifierType<Opt> | null {\n if (!Array.isArray(arr) || arr.length === 0) {\n return null;\n } else if (isFlexibleOptionGroupArray(arr, { allowEmpty: true })) {\n for (const og of arr) {\n if (og.options.length > 0) {\n return (og.options[0].value ?? og.options[0].name) as GetOptionIdentifierType<Opt>;\n }\n }\n // istanbul ignore next\n return null;\n }\n\n return (arr[0].value ?? arr[0].name) as GetOptionIdentifierType<Opt>;\n}\n\n/**\n * Flattens {@link FlexibleOptionGroup} arrays into {@link BaseOption} arrays.\n * If the array is already flat, it is returned as is.\n *\n * @group Option Lists\n */\nexport const toFlatOptionArray = <T extends FullOption, OL extends FullOptionList<T>>(arr: OL) =>\n uniqByIdentifier(isOptionGroupArray(arr) ? arr.flatMap(og => og.options) : arr) as T[];\n\n/**\n * Generates a new {@link OptionGroup} array with duplicates\n * removed based on the identifying property (`value` or `name`).\n *\n * @group Option Lists\n */\nexport const uniqOptGroups = <T extends BaseOption>(\n originalArray: FlexibleOptionGroup<T>[]\n): OptionGroup<ToFullOption<T>>[] => {\n type K = T extends BaseOption<infer KT> ? KT : never;\n const labels = new Set<string>();\n const names = new Set<K>();\n const newArray: OptionGroup<ToFullOption<T>>[] = [];\n for (const el of originalArray) {\n if (!labels.has(el.label)) {\n labels.add(el.label);\n const optionsForThisGroup: WithUnknownIndex<ToFullOption<T>>[] = [];\n for (const opt of el.options) {\n if (!names.has((opt.value ?? opt.name) as K)) {\n names.add((opt.value ?? opt.name) as K);\n optionsForThisGroup.push(toFullOption(opt) as WithUnknownIndex<ToFullOption<T>>);\n }\n }\n newArray.push({ ...el, options: optionsForThisGroup });\n }\n }\n return newArray;\n};\n\n/**\n * Generates a new {@link Option} or {@link OptionGroup} array with duplicates\n * removed based on the identifier property (`value` or `name`).\n *\n * @group Option Lists\n */\nexport const uniqOptList = <T extends BaseOption>(\n originalArray: FlexibleOptionList<T>\n): WithUnknownIndex<BaseOption & FullOption>[] | OptionGroup<ToFullOption<T>>[] => {\n if (isFlexibleOptionGroupArray(originalArray)) {\n return uniqOptGroups(originalArray) as OptionGroup<ToFullOption<T>>[];\n }\n return uniqByIdentifier((originalArray as BaseOption[]).map(o => toFullOption(o)));\n};\n\nexport interface PreparedOptionList<O extends FullOption> {\n defaultOption: FullOption;\n optionList: FullOptionList<O>;\n optionsMap: Partial<FullOptionRecord<FullOption>>;\n}\n\nexport interface PrepareOptionListParams<O extends FullOption> {\n placeholder?: Placeholder;\n optionList?: FlexibleOptionListProp<O> | BaseOptionMap<O>;\n baseOption?: Record<string, unknown>;\n labelMap?: Record<string, string>;\n autoSelectOption?: boolean;\n}\n\nexport const prepareOptionList = <O extends FullOption>(\n props: PrepareOptionListParams<O>\n): PreparedOptionList<O> => {\n type OptionIdentifier = GetOptionIdentifierType<O>;\n\n // istanbul ignore next\n const {\n optionList: optionListPropOriginal,\n baseOption = {},\n labelMap = {},\n placeholder: {\n placeholderName = defaultPlaceholderName,\n placeholderLabel = defaultPlaceholderLabel,\n placeholderGroupLabel = defaultPlaceholderLabel,\n } = {},\n autoSelectOption = true,\n } = props;\n\n const defaultOption = {\n id: placeholderName,\n name: placeholderName,\n value: placeholderName,\n label: placeholderLabel,\n } as FullOption;\n\n const optionsProp = optionListPropOriginal ?? ([defaultOption] as FlexibleOptionList<O>);\n\n let optionList: FullOptionList<O>;\n const opts = (\n Array.isArray(optionsProp)\n ? toFullOptionList(optionsProp, baseOption, labelMap)\n : (objectKeys(toFullOptionMap(optionsProp, baseOption)) as unknown as OptionIdentifier[])\n // oxlint-disable-next-line no-map-spread\n .map<FullOption<OptionIdentifier>>(opt => ({\n ...optionsProp[opt]!,\n name: opt,\n value: opt,\n }))\n // oxlint-disable-next-line no-array-sort\n .sort((a, b) => a.label.localeCompare(b.label))\n ) as FullOptionList<O>;\n if (isFlexibleOptionGroupArray(opts)) {\n optionList = autoSelectOption\n ? (uniqOptGroups(opts) as FullOptionList<O>)\n : (uniqOptGroups([\n {\n label: placeholderGroupLabel,\n options: [defaultOption],\n },\n ...opts,\n ]) as FullOptionList<O>);\n } else {\n optionList = autoSelectOption\n ? (uniqByIdentifier(opts as O[]) as FullOptionList<O>)\n : (uniqByIdentifier([defaultOption, ...(opts as O[])]) as FullOptionList<O>);\n }\n\n let optionsMap: Partial<FullOptionRecord<FullOption>> = {};\n if (!Array.isArray(optionsProp)) {\n const op = toFullOptionMap(optionsProp, baseOption) as FullOptionMap<\n FullOption,\n OptionIdentifier\n >;\n optionsMap = autoSelectOption ? op : { ...op, [placeholderName]: defaultOption };\n } else {\n if (isFlexibleOptionGroupArray(optionList)) {\n for (const og of optionList as OptionGroup<ToFullOption<O>>[]) {\n for (const opt of og.options) {\n optionsMap[(opt.value ?? /* istanbul ignore next */ opt.name) as OptionIdentifier] =\n toFullOption(opt, baseOption) as FullOption;\n }\n }\n } else {\n for (const opt of optionList as ToFullOption<O>[]) {\n optionsMap[(opt.value ?? /* istanbul ignore next */ opt.name) as OptionIdentifier] =\n toFullOption(opt, baseOption) as FullOption;\n }\n }\n }\n\n return { defaultOption, optionList, optionsMap };\n};\n","import type { InputType, ParseNumberMethod, ParseNumbersPropConfig } from '../types';\n\nexport const getParseNumberMethod = ({\n parseNumbers,\n inputType,\n}: {\n parseNumbers?: ParseNumbersPropConfig;\n inputType?: InputType | null;\n}): ParseNumberMethod => {\n if (typeof parseNumbers === 'string') {\n const [method, level] = parseNumbers.split('-') as\n | [ParseNumberMethod, 'limited']\n | [ParseNumberMethod];\n if (level === 'limited') {\n return inputType === 'number' ? method : false;\n }\n\n return method;\n }\n\n return parseNumbers ? 'strict' : false;\n};\n","import type { SetRequired } from 'type-fest';\nimport type {\n ConstituentWordOrder,\n DefaultCombinatorName,\n FormatQueryOptions,\n FullField,\n GroupVariantCondition,\n MatchMode,\n NLTranslationKey,\n NLTranslations,\n OptionList,\n RuleGroupTypeAny,\n RuleType,\n ValueProcessorByRule,\n ValueProcessorLegacy,\n ValueProcessorOptions,\n} from '../../types';\nimport { joinWith, splitBy, toArray } from '../arrayUtils';\nimport { getParseNumberMethod } from '../getParseNumberMethod';\nimport { isRuleGroup } from '../isRuleGroup';\nimport { isPojo, lc, numericRegex } from '../misc';\nimport { getOption } from '../optGroupUtils';\nimport { parseNumber } from '../parseNumber';\n\n/**\n * Maps a {@link DefaultOperatorName} to a SQL operator.\n *\n * @group Export\n */\nexport const mapSQLOperator = (rqbOperator: string): string => {\n switch (lc(rqbOperator)) {\n case 'null':\n return 'is null';\n case 'notnull':\n return 'is not null';\n case 'notin':\n return 'not in';\n case 'notbetween':\n return 'not between';\n case 'contains':\n case 'beginswith':\n case 'endswith':\n return 'like';\n case 'doesnotcontain':\n case 'doesnotbeginwith':\n case 'doesnotendwith':\n return 'not like';\n default:\n return rqbOperator;\n }\n};\n\n/**\n * Maps a (lowercase) {@link DefaultOperatorName} to a MongoDB operator.\n *\n * @group Export\n */\nexport const mongoOperators = {\n '=': '$eq',\n '!=': '$ne',\n '<': '$lt',\n '<=': '$lte',\n '>': '$gt',\n '>=': '$gte',\n in: '$in',\n notin: '$nin',\n notIn: '$nin', // only here for backwards compatibility\n};\n\n/**\n * Maps a (lowercase) {@link DefaultOperatorName} to a Prisma ORM operator.\n *\n * @group Export\n */\nexport const prismaOperators = {\n '=': 'equals',\n '!=': 'not',\n '<': 'lt',\n '<=': 'lte',\n '>': 'gt',\n '>=': 'gte',\n in: 'in',\n notin: 'notIn',\n};\n\n/**\n * Maps a {@link DefaultCombinatorName} to a CEL combinator.\n *\n * @group Export\n */\nexport const celCombinatorMap: {\n and: '&&';\n or: '||';\n} = {\n and: '&&',\n or: '||',\n} satisfies Record<DefaultCombinatorName, '&&' | '||'>;\n\n/**\n * Register these operators with `jsonLogic` before applying the result\n * of `formatQuery(query, 'jsonlogic')`.\n *\n * @example\n * ```\n * for (const [op, func] of Object.entries(jsonLogicAdditionalOperators)) {\n * jsonLogic.add_operation(op, func);\n * }\n * jsonLogic.apply({ \"startsWith\": [{ \"var\": \"firstName\" }, \"Stev\"] }, data);\n * ```\n *\n * @group Export\n */\nexport const jsonLogicAdditionalOperators: Record<\n 'startsWith' | 'endsWith',\n (a: string, b: string) => boolean\n> = {\n startsWith: (a: string, b: string) => typeof a === 'string' && a.startsWith(b),\n endsWith: (a: string, b: string) => typeof a === 'string' && a.endsWith(b),\n};\n\n/**\n * Returns a new query object with all `string`-type `value` properties converted\n * to `number` where appropriate.\n *\n * Used by {@link formatQuery} for the `json*` formats when `parseNumbers` is `true`.\n *\n * @group Export\n */\nexport const numerifyValues = (\n rg: RuleGroupTypeAny,\n options: SetRequired<FormatQueryOptions, 'fields'>\n): RuleGroupTypeAny => ({\n ...rg,\n // @ts-expect-error TS doesn't keep track of odd/even indexes here\n rules: rg.rules.map(r => {\n if (typeof r === 'string') {\n return r;\n }\n\n if (isRuleGroup(r)) {\n return numerifyValues(r, options);\n }\n\n const fieldData = getOption(options.fields as OptionList<FullField>, r.field);\n const parseNumbers = getParseNumberMethod({\n parseNumbers: options.parseNumbers,\n inputType: fieldData?.inputType,\n });\n\n if (Array.isArray(r.value)) {\n return { ...r, value: r.value.map(v => parseNumber(v, { parseNumbers })) };\n }\n\n const valAsArray = toArray(r.value, { retainEmptyStrings: true }).map(v =>\n parseNumber(v, { parseNumbers })\n );\n if (valAsArray.every(v => typeof v === 'number')) {\n // istanbul ignore else\n if (valAsArray.length > 1) {\n return { ...r, value: valAsArray };\n } else if (valAsArray.length === 1) {\n return { ...r, value: valAsArray[0] };\n }\n }\n\n return r;\n }),\n});\n\n/**\n * Determines whether a value is _anything_ except an empty `string` or `NaN`.\n *\n * @group Export\n */\n// oxlint-disable-next-line typescript/no-explicit-any\nexport const isValidValue = (value: any): boolean =>\n (typeof value === 'string' && value.length > 0) ||\n (typeof value === 'number' && !Number.isNaN(value)) ||\n (typeof value !== 'string' && typeof value !== 'number');\n\n/**\n * Determines whether {@link formatQuery} should render the given value as a number.\n * As long as `parseNumbers` is `true`, `number` and `bigint` values will return `true` and\n * `string` values will return `true` if they test positive against {@link numericRegex}.\n *\n * @group Export\n */\n// oxlint-disable-next-line typescript/no-explicit-any\nexport const shouldRenderAsNumber = (value: any, parseNumbers?: boolean): boolean =>\n !!parseNumbers &&\n (typeof value === 'number' ||\n typeof value === 'bigint' ||\n (typeof value === 'string' && numericRegex.test(value)));\n\n/**\n * Used by {@link formatQuery} to determine whether the given value processor is a\n * \"legacy\" value processor by counting the number of arguments. Legacy value\n * processors take 3 arguments (not counting any arguments with default values), while\n * rule-based value processors take no more than 2 arguments.\n *\n * @group Export\n */\nexport const isValueProcessorLegacy = (\n valueProcessor: ValueProcessorLegacy | ValueProcessorByRule\n): valueProcessor is ValueProcessorLegacy => valueProcessor.length >= 3;\n\n/**\n * Converts the `quoteFieldNamesWith` option into an array of two strings.\n * If the option is a string, the array elements are both that string.\n *\n * @default\n * ['', '']\n *\n * @group Export\n */\nexport const getQuoteFieldNamesWithArray = (\n // istanbul ignore next\n quoteFieldNamesWith: null | string | [string, string] = ['', '']\n): [string, string] =>\n Array.isArray(quoteFieldNamesWith)\n ? quoteFieldNamesWith\n : typeof quoteFieldNamesWith === 'string'\n ? [quoteFieldNamesWith, quoteFieldNamesWith]\n : (quoteFieldNamesWith ?? ['', '']);\n\n/**\n * Given a field name and relevant {@link ValueProcessorOptions}, returns the field name\n * wrapped in the configured quote character(s).\n *\n * @group Export\n */\nexport const getQuotedFieldName = (\n fieldName: string,\n { quoteFieldNamesWith, fieldIdentifierSeparator }: ValueProcessorOptions\n): string => {\n const [qPre, qPost] = getQuoteFieldNamesWithArray(quoteFieldNamesWith);\n return typeof fieldIdentifierSeparator === 'string' && fieldIdentifierSeparator.length > 0\n ? joinWith(\n splitBy(fieldName, fieldIdentifierSeparator).map(part => `${qPre}${part}${qPost}`),\n fieldIdentifierSeparator\n )\n : `${qPre}${fieldName}${qPost}`;\n};\n\nconst defaultWordOrder = ['S', 'V', 'O'];\n\n/**\n * Given a [Constituent word order](https://en.wikipedia.org/wiki/Word_order#Constituent_word_orders)\n * like \"svo\" or \"sov\", returns a permutation of `[\"S\", \"V\", \"O\"]` based on the first occurrence of\n * each letter in the input string (case insensitive). This widens the valid input from abbreviations\n * like \"svo\" to more expressive strings like \"subject-verb-object\" or \"sub ver obj\". Any missing\n * letters are appended in the default order \"SVO\" (e.g., \"object\" would yield `[\"O\", \"S\", \"V\"]`).\n *\n * @group Export\n */\nexport const normalizeConstituentWordOrder = (input: string): ConstituentWordOrder => {\n const result: string[] = [];\n const letterSet = new Set(defaultWordOrder);\n\n for (const char of input.toUpperCase()) {\n if (letterSet.has(char)) {\n result.push(char);\n letterSet.delete(char);\n if (letterSet.size === 0) break;\n }\n }\n\n // Add any missing letters in default order\n for (const letter of defaultWordOrder) {\n if (letterSet.has(letter)) {\n result.push(letter);\n }\n }\n\n return result as ConstituentWordOrder;\n};\n\n/**\n * Default translations used by {@link formatQuery} for \"natural_language\" format.\n *\n * @group Export\n */\n// The ones commented below are unnecessary for the default implementation,\n// but they can be overridden for customized implementations.\nexport const defaultNLTranslations: NLTranslations = {\n // and: 'and',\n // or: 'or',\n // true: 'true',\n // false: 'false',\n groupPrefix: '',\n // groupPrefix_not: '',\n groupPrefix_not_xor: 'either zero or more than one of',\n groupPrefix_xor: 'exactly one of',\n groupSuffix: 'is true',\n groupSuffix_not: 'is not true',\n // groupSuffix_not_xor: 'is true',\n // groupSuffix_xor: 'is true',\n};\n\n/**\n * Note: This function assumes `conditions.length > 0`\n */\nconst translationMatchFilter = (\n key: NLTranslationKey,\n keyToTest: string,\n conditions: GroupVariantCondition[]\n) =>\n // The translation matches the base key\n keyToTest.startsWith(key) &&\n // The translation specifies all conditions\n conditions.every(\n c =>\n // This translation specifies _this_ condition\n keyToTest.includes(`_${c}`) &&\n // This translation specifies the same _total number_ of conditions\n keyToTest.match(/_/g)?.length === conditions.length\n );\n\n/**\n * Used by {@link formatQuery} to get a translation based on certain conditions\n * for the \"natural_language\" format.\n *\n * @group Export\n */\nexport const getNLTranslataion = (\n key: NLTranslationKey,\n translations: NLTranslations,\n conditions: GroupVariantCondition[] = []\n): string =>\n conditions.length === 0\n ? (translations[key] ?? defaultNLTranslations[key] ?? /* istanbul ignore next */ '')\n : (Object.entries(translations).find(([keyToTest]) =>\n translationMatchFilter(key, keyToTest, conditions)\n )?.[1] ??\n Object.entries(defaultNLTranslations).find(([keyToTest]) =>\n translationMatchFilter(key, keyToTest, conditions)\n )?.[1] ??\n defaultNLTranslations[key] ??\n /* istanbul ignore next */ '');\n\ntype ProcessedMatchMode =\n | { mode: 'all'; threshold?: number | null | undefined }\n | { mode: 'none'; threshold?: number | null | undefined }\n | { mode: 'some'; threshold?: number | null | undefined }\n | { mode: 'atleast'; threshold: number }\n | { mode: 'atmost'; threshold: number }\n | { mode: 'exactly'; threshold: number };\n\n/**\n * Transforms\n * - `match: { mode: \"atLeast\", threshold: 1 }` to `match: { mode: \"some\" }`\n * - `match: { mode: \"atMost\", threshold: 0 }` to `match: { mode: \"none\" }`.\n *\n * Returns:\n * - Processed `{ mode, threshold }` object for valid subqueries\n * - `null` if match mode is not applicable for the rule\n * - `false` if match mode is valid, but either\n * 1. `threshold` is required and invalid, or\n * 2. `value` is not a valid rule group.\n */\nexport const processMatchMode = (rule: RuleType): null | false | ProcessedMatchMode => {\n const { mode, threshold } = rule.match ?? {};\n\n if (!mode) return null;\n\n if (!isRuleGroup(rule.value)) return false;\n\n const matchModeLC = lc(mode) as Lowercase<MatchMode>;\n\n const matchModeCoerced =\n matchModeLC === 'atleast' && threshold === 1\n ? 'some'\n : matchModeLC === 'atmost' && threshold === 0\n ? 'none'\n : matchModeLC;\n\n if (\n (matchModeCoerced === 'atleast' ||\n matchModeCoerced === 'atmost' ||\n matchModeCoerced === 'exactly') &&\n (typeof threshold !== 'number' || threshold < 0)\n ) {\n return false;\n }\n\n return { mode: matchModeCoerced, threshold: threshold! };\n};\n\n/**\n * \"Replacer\" method for JSON.stringify's second argument. Converts `bigint` values to\n * objects with a `$bigint` property having a value of a string representation of\n * the actual `bigint`-type value.\n *\n * Inverse of {@link bigIntJsonParseReviver}.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#use_within_json\n */\nexport const bigIntJsonStringifyReplacer = (_key: string, value: unknown): unknown =>\n typeof value === 'bigint' ? { $bigint: value.toString() } : value;\n\n/**\n * \"Reviver\" method for JSON.parse's second argument. Converts objects having a single\n * `$bigint: string` property to an actual `bigint` value.\n *\n * Inverse of {@link bigIntJsonStringifyReplacer}.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#use_within_json\n */\nexport const bigIntJsonParseReviver = (_key: string, value: unknown): unknown =>\n isPojo(value) && Object.keys(value).length === 1 && typeof value.$bigint === 'string'\n ? BigInt(value.$bigint)\n : value;\n"],"mappings":";;;;;;;;;AA0MA,MAAa,6BAA+E;CAC1F,KAAK;CACL,MAAM;CACN,KAAK;CACL,MAAM;CACN,KAAK;CACL,MAAM;CACN,YAAY;CACZ,kBAAkB;CAClB,UAAU;CACV,gBAAgB;CAChB,UAAU;CACV,gBAAgB;CAChB,SAAS;CACT,YAAY;CACZ,IAAI;CACJ,OAAO;CACP,SAAS;CACT,MAAM;CACP;;;;;;;;;;;;;;;AC/MD,MAAa,WAAW,KAAc,YAAA,QACpC,OAAO,QAAQ,WACX,IACG,MAAM,KAAK,YAAY,CACvB,KAAI,MAAK,EAAE,MAAM,UAAU,CAAC,CAC5B,QAAQ,MAAM,MAAM,QAAQ;AAC3B,KAAI,QAAQ,EACV,QAAO;AAET,QAAO;EAAC,GAAG,KAAK,MAAM,GAAG,GAAG;EAAE,GAAG,KAAK,GAAG,GAAG,GAAG,YAAY,KAAK;EAAM,GAAG,KAAK,MAAM,EAAE;EAAC;GACtF,EAAE,CAAC,GACR,EAAE;;;;;;;;;;;;;;AAgBR,MAAa,YAAY,QAAe,WAAA,QACtC,OAAO,KAAI,QAAO,GAAG,OAAO,KAAK,WAAW,SAAS,IAAI,KAAK,SAAS,KAAK,CAAC,CAAC,KAAK,SAAS;;;;AAM9F,MAAa,gBAAgB,QAAmB,OAAO,QAAQ,WAAW,IAAI,MAAM,GAAG;;;;;AAMvF,MAAa,WAEX,GACA,EAAE,uBAAyD,EAAE,KAG7D,MAAM,QAAQ,EAAE,GACZ,EAAE,KAAI,MAAK,aAAa,EAAE,CAAC,GAC3B,OAAO,MAAM,WACX,QAAQ,GAAA,IAAmB,CACxB,OA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CAAC,eAC3C,uBAAuB,KAAK,WAAW,WAAW,CACnD,GAAG,MACJ,sBAAsB,QACK;;;;;;;;;;;;;AAsBjC,MAAa,oBAAoB,SAAsD;CACrF,MAAM,EAAE,MAAM,cAAc,KAAK,SAAS,EAAE;AAE5C,KAAI,CAAC,KAAM,QAAO;AAElB,KAAI,CAACD,oBAAAA,YAAY,KAAK,MAAM,CAAE,QAAO;CAErC,MAAM,cAAcD,oBAAAA,GAAG,KAAK;CAE5B,MAAM,mBACJ,gBAAgB,aAAa,cAAc,IACvC,SACA,gBAAgB,YAAY,cAAc,IACxC,SACA;AAER,MACG,qBAAqB,aACpB,qBAAqB,YACrB,qBAAqB,eACtB,OAAO,cAAc,YAAY,YAAY,GAE9C,QAAO;AAGT,QAAO;EAAE,MAAM;EAA6B;EAAY;;;;;;;;;;;AAY1D,MAAa,+BAA+B,MAAc,UACxD,OAAO,UAAU,WAAW,EAAE,SAAS,MAAM,UAAU,EAAE,GAAG;;;;;;;;;AAU9D,MAAa,0BAA0B,MAAc,UACnDG,oBAAAA,OAAO,MAAM,IAAI,OAAO,KAAK,MAAM,CAAC,WAAW,KAAK,OAAO,MAAM,YAAY,WACzE,OAAO,MAAM,QAAQ,GACrB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-querybuilder/core",
3
- "version": "8.13.0",
3
+ "version": "8.14.1",
4
4
  "description": "React Query Builder component for constructing queries and filters, with utilities for executing them in various database and evaluation contexts",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -142,59 +142,67 @@
142
142
  "homepage": "https://react-querybuilder.js.org/",
143
143
  "devDependencies": {
144
144
  "@babel/core": "^7.28.5",
145
- "@babel/preset-env": "^7.28.5",
145
+ "@babel/preset-env": "^7.29.2",
146
146
  "@babel/preset-typescript": "^7.28.5",
147
- "@electric-sql/pglite": "^0.3.14",
148
- "@prisma/client": "^6.19.0",
147
+ "@electric-sql/pglite": "^0.4.1",
148
+ "@prisma/client": "^7.5.0",
149
149
  "@types/json-logic-js": "^2.0.8",
150
- "@types/node": "^24.10.1",
150
+ "@types/node": "^25.5.0",
151
151
  "babel-plugin-istanbul": "^7.0.1",
152
- "drizzle-orm": "^0.44.7",
152
+ "drizzle-orm": "^0.45.1",
153
153
  "json-logic-js": "^2.0.5",
154
154
  "jsonata": "^2.1.0",
155
- "mongodb-memory-server-core": "^10.3.0",
156
- "mongoose": "^9.0.0",
157
- "pglite-prisma-adapter": "^0.6.1",
158
- "prisma": "^6.19.0",
155
+ "mongodb-memory-server-core": "^11.0.1",
156
+ "mongoose": "^9.3.2",
157
+ "pglite-prisma-adapter": "^0.7.2",
158
+ "prisma": "^7.5.0",
159
159
  "query-string": "^9.3.1",
160
160
  "regenerator-runtime": "^0.14.1",
161
- "rollup-plugin-visualizer": "^6.0.5",
162
- "sass": "^1.94.2",
163
- "sequelize": "^6.37.7",
161
+ "rollup-plugin-visualizer": "^7.0.1",
162
+ "sass": "^1.98.0",
163
+ "sequelize": "^6.37.8",
164
164
  "spel2js": "^0.2.9",
165
- "type-fest": "^5.3.0",
166
- "typescript": "^5.9.3",
167
- "vite": "^7.2.6"
165
+ "type-fest": "^5.5.0",
166
+ "typescript": "^6.0.2",
167
+ "vite": "^8.0.2"
168
168
  },
169
169
  "dependencies": {
170
170
  "@ts-jison/lexer": "0.4.1-alpha.1",
171
171
  "@ts-jison/parser": "0.4.1-alpha.1",
172
- "immer": "^11.0.1",
173
- "numeric-quantity": "^2.1.0"
172
+ "immer": "^11.1.3",
173
+ "numeric-quantity": "^3.0.0"
174
174
  },
175
175
  "peerDependencies": {
176
176
  "drizzle-orm": ">=0.38.0",
177
177
  "json-logic-js": ">=2",
178
- "sequelize": ">=6"
178
+ "jsonata": ">=2",
179
+ "sequelize": ">=6",
180
+ "spel2js": ">=0.2.0"
179
181
  },
180
182
  "peerDependenciesMeta": {
181
183
  "drizzle-orm": {
182
184
  "optional": true
183
185
  },
186
+ "jsonata": {
187
+ "optional": true
188
+ },
184
189
  "json-logic-js": {
185
190
  "optional": true
186
191
  },
187
192
  "sequelize": {
188
193
  "optional": true
194
+ },
195
+ "spel2js": {
196
+ "optional": true
189
197
  }
190
198
  },
191
199
  "browserslist": "> 0.25%, not dead",
192
200
  "scripts": {
193
201
  "build": "bun run build:main && bun run build:css",
194
202
  "build:main": "bun --bun tsdown",
195
- "build:css": "mkdir -p dist/styles && cp src/*.scss dist && cp src/styles/*.scss dist/styles && bun sass --style=compressed dist:dist",
203
+ "build:css": "mkdir -p dist/styles && cp src/*.scss dist && cp src/styles/*.scss dist/styles && bun sass --style=compressed --silence-deprecation=if-function dist",
196
204
  "typecheck": "tsc --noEmit",
197
205
  "typecheck:watch": "tsc --noEmit --watch"
198
206
  },
199
- "gitHead": "96a494f99af53de9de8c647d1895e9d05f3f74a9"
207
+ "gitHead": "f0189159c62b9f183137ea1a5254824ea0b6b034"
200
208
  }
@@ -1,41 +0,0 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
- key = keys[i];
13
- if (!__hasOwnProp.call(to, key) && key !== except) {
14
- __defProp(to, key, {
15
- get: ((k) => from[k]).bind(null, key),
16
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
- });
18
- }
19
- }
20
- }
21
- return to;
22
- };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
- value: mod,
25
- enumerable: true
26
- }) : target, mod));
27
-
28
- //#endregion
29
-
30
- Object.defineProperty(exports, '__commonJSMin', {
31
- enumerable: true,
32
- get: function () {
33
- return __commonJSMin;
34
- }
35
- });
36
- Object.defineProperty(exports, '__toESM', {
37
- enumerable: true,
38
- get: function () {
39
- return __toESM;
40
- }
41
- });
@@ -1 +0,0 @@
1
- {"version":3,"file":"convertQuery-DAj92cbM.mjs","names":["rules: (RuleGroupTypeIC | RuleType | string)[]"],"sources":["../src/utils/convertQuery.ts"],"sourcesContent":["import { produce } from 'immer';\nimport type {\n RuleGroupArray,\n RuleGroupType,\n RuleGroupTypeAny,\n RuleGroupTypeIC,\n RuleType,\n} from '../types';\nimport { isRuleGroup, isRuleGroupType, isRuleGroupTypeIC } from './isRuleGroup';\nimport { lc } from './misc';\n\nconst combinatorLevels = ['or', 'xor', 'and'] as const;\n\nconst isSameString = (a: unknown, b: string) => lc(a) === b;\n\nconst generateRuleGroupICWithConsistentCombinators = (\n rg: RuleGroupTypeIC,\n baseCombinatorLevel: number = 0\n): RuleGroupTypeIC => {\n const baseCombinator = combinatorLevels[baseCombinatorLevel];\n\n // oxlint-disable-next-line typescript/no-explicit-any\n if (!rg.rules.includes(baseCombinator as any)) {\n // No instances of this combinator, so group based on the next\n // combinator level if at least two levels remain\n return baseCombinatorLevel < combinatorLevels.length - 2\n ? generateRuleGroupICWithConsistentCombinators(rg, baseCombinatorLevel + 1)\n : rg;\n }\n\n return produce(rg, draft => {\n let cursor = 0;\n\n // Group all chains of combinators in the rule array that are not the base combinator\n while (cursor < draft.rules.length - 2) {\n if (isSameString(draft.rules[cursor + 1], baseCombinator)) {\n cursor += 2;\n continue;\n }\n\n const nextBaseCombinatorIndex = draft.rules.findIndex(\n (r, i) => i > cursor && typeof r === 'string' && lc(r) === baseCombinator\n );\n\n if (nextBaseCombinatorIndex === -1) {\n // No more instances of this combinator, so group all remaining rules and exit the loop\n draft.rules.splice(\n cursor,\n draft.rules.length,\n generateRuleGroupICWithConsistentCombinators(\n // oxlint-disable-next-line typescript/no-explicit-any\n { rules: draft.rules.slice(cursor) as any },\n baseCombinatorLevel + 1\n )\n );\n break;\n } else {\n // Group all rules between the current cursor and the next instance of the base combinator\n draft.rules.splice(\n cursor,\n nextBaseCombinatorIndex - cursor,\n generateRuleGroupICWithConsistentCombinators(\n // oxlint-disable-next-line typescript/no-explicit-any\n { rules: draft.rules.slice(cursor, nextBaseCombinatorIndex) as any },\n baseCombinatorLevel + 1\n )\n );\n }\n }\n });\n};\n\n/**\n * Converts a {@link RuleGroupTypeIC} to {@link RuleGroupType}.\n *\n * This function is idempotent: {@link RuleGroupType} queries will be\n * returned as-is.\n *\n * @group Query Tools\n */\nexport const convertFromIC = <RG extends RuleGroupType = RuleGroupType>(\n rg: RuleGroupTypeAny\n): RG => {\n if (isRuleGroupType(rg)) {\n return rg as RG;\n }\n const processedRG = generateRuleGroupICWithConsistentCombinators(rg);\n const rulesAsMixedList = processedRG.rules.map(r =>\n typeof r === 'string' || !isRuleGroup(r) ? r : convertFromIC(r)\n );\n const combinator = rulesAsMixedList.length < 2 ? 'and' : (rulesAsMixedList[1] as string);\n const rules = rulesAsMixedList.filter(r => typeof r !== 'string') as RuleGroupArray;\n return { ...processedRG, combinator, rules } as RG;\n};\n\n/**\n * Converts a {@link RuleGroupType} to {@link RuleGroupTypeIC}.\n *\n * This function is idempotent: {@link RuleGroupTypeIC} queries will be\n * returned as-is.\n *\n * @group Query Tools\n */\nexport const convertToIC = <RGIC extends RuleGroupTypeIC = RuleGroupTypeIC>(\n rg: RuleGroupTypeAny\n): RGIC => {\n if (isRuleGroupTypeIC(rg)) {\n return rg as RGIC;\n }\n const { combinator, ...queryWithoutCombinator } = rg;\n const rules: (RuleGroupTypeIC | RuleType | string)[] = [];\n const { length } = rg.rules;\n for (const [idx, r] of rg.rules.entries()) {\n if (isRuleGroup(r)) {\n rules.push(convertToIC(r));\n } else {\n rules.push(r);\n }\n if (combinator && idx < length - 1) {\n rules.push(combinator);\n }\n }\n return { ...queryWithoutCombinator, rules } as RGIC;\n};\n\n/**\n * Converts a {@link RuleGroupType} to {@link RuleGroupTypeIC}. For a more explicit\n * operation, use {@link convertToIC}.\n *\n * @group Query Tools\n */\nfunction convertQuery(query: RuleGroupType): RuleGroupTypeIC;\n/**\n * Converts a {@link RuleGroupTypeIC} to {@link RuleGroupType}. For a more explicit\n * operation, use {@link convertFromIC}.\n *\n * @group Query Tools\n */\nfunction convertQuery(query: RuleGroupTypeIC): RuleGroupType;\nfunction convertQuery(query: RuleGroupType | RuleGroupTypeIC): RuleGroupType | RuleGroupTypeIC {\n return isRuleGroupTypeIC(query) ? convertFromIC(query) : convertToIC(query);\n}\n\nexport { convertQuery };\n"],"mappings":";;;;AAWA,MAAM,mBAAmB;CAAC;CAAM;CAAO;CAAM;AAE7C,MAAM,gBAAgB,GAAY,MAAc,GAAG,EAAE,KAAK;AAE1D,MAAM,gDACJ,IACA,sBAA8B,MACV;CACpB,MAAM,iBAAiB,iBAAiB;AAGxC,KAAI,CAAC,GAAG,MAAM,SAAS,eAAsB,CAG3C,QAAO,sBAAsB,iBAAiB,SAAS,IACnD,6CAA6C,IAAI,sBAAsB,EAAE,GACzE;AAGN,QAAO,QAAQ,KAAI,UAAS;EAC1B,IAAI,SAAS;AAGb,SAAO,SAAS,MAAM,MAAM,SAAS,GAAG;AACtC,OAAI,aAAa,MAAM,MAAM,SAAS,IAAI,eAAe,EAAE;AACzD,cAAU;AACV;;GAGF,MAAM,0BAA0B,MAAM,MAAM,WACzC,GAAG,MAAM,IAAI,UAAU,OAAO,MAAM,YAAY,GAAG,EAAE,KAAK,eAC5D;AAED,OAAI,4BAA4B,IAAI;AAElC,UAAM,MAAM,OACV,QACA,MAAM,MAAM,QACZ,6CAEE,EAAE,OAAO,MAAM,MAAM,MAAM,OAAO,EAAS,EAC3C,sBAAsB,EACvB,CACF;AACD;SAGA,OAAM,MAAM,OACV,QACA,0BAA0B,QAC1B,6CAEE,EAAE,OAAO,MAAM,MAAM,MAAM,QAAQ,wBAAwB,EAAS,EACpE,sBAAsB,EACvB,CACF;;GAGL;;;;;;;;;;AAWJ,MAAa,iBACX,OACO;AACP,KAAI,gBAAgB,GAAG,CACrB,QAAO;CAET,MAAM,cAAc,6CAA6C,GAAG;CACpE,MAAM,mBAAmB,YAAY,MAAM,KAAI,MAC7C,OAAO,MAAM,YAAY,CAAC,YAAY,EAAE,GAAG,IAAI,cAAc,EAAE,CAChE;CACD,MAAM,aAAa,iBAAiB,SAAS,IAAI,QAAS,iBAAiB;CAC3E,MAAM,QAAQ,iBAAiB,QAAO,MAAK,OAAO,MAAM,SAAS;AACjE,QAAO;EAAE,GAAG;EAAa;EAAY;EAAO;;;;;;;;;;AAW9C,MAAa,eACX,OACS;AACT,KAAI,kBAAkB,GAAG,CACvB,QAAO;CAET,MAAM,EAAE,YAAY,GAAG,2BAA2B;CAClD,MAAMA,QAAiD,EAAE;CACzD,MAAM,EAAE,WAAW,GAAG;AACtB,MAAK,MAAM,CAAC,KAAK,MAAM,GAAG,MAAM,SAAS,EAAE;AACzC,MAAI,YAAY,EAAE,CAChB,OAAM,KAAK,YAAY,EAAE,CAAC;MAE1B,OAAM,KAAK,EAAE;AAEf,MAAI,cAAc,MAAM,SAAS,EAC/B,OAAM,KAAK,WAAW;;AAG1B,QAAO;EAAE,GAAG;EAAwB;EAAO"}
@@ -1,87 +0,0 @@
1
- const require_chunk = require('./chunk-U64pC571.js');
2
- const require_isRuleGroup = require('./isRuleGroup-Cjk1Q2mj.js');
3
- let immer = require("immer");
4
-
5
- //#region src/utils/convertQuery.ts
6
- const combinatorLevels = [
7
- "or",
8
- "xor",
9
- "and"
10
- ];
11
- const isSameString = (a, b) => require_isRuleGroup.lc(a) === b;
12
- const generateRuleGroupICWithConsistentCombinators = (rg, baseCombinatorLevel = 0) => {
13
- const baseCombinator = combinatorLevels[baseCombinatorLevel];
14
- if (!rg.rules.includes(baseCombinator)) return baseCombinatorLevel < combinatorLevels.length - 2 ? generateRuleGroupICWithConsistentCombinators(rg, baseCombinatorLevel + 1) : rg;
15
- return (0, immer.produce)(rg, (draft) => {
16
- let cursor = 0;
17
- while (cursor < draft.rules.length - 2) {
18
- if (isSameString(draft.rules[cursor + 1], baseCombinator)) {
19
- cursor += 2;
20
- continue;
21
- }
22
- const nextBaseCombinatorIndex = draft.rules.findIndex((r, i) => i > cursor && typeof r === "string" && require_isRuleGroup.lc(r) === baseCombinator);
23
- if (nextBaseCombinatorIndex === -1) {
24
- draft.rules.splice(cursor, draft.rules.length, generateRuleGroupICWithConsistentCombinators({ rules: draft.rules.slice(cursor) }, baseCombinatorLevel + 1));
25
- break;
26
- } else draft.rules.splice(cursor, nextBaseCombinatorIndex - cursor, generateRuleGroupICWithConsistentCombinators({ rules: draft.rules.slice(cursor, nextBaseCombinatorIndex) }, baseCombinatorLevel + 1));
27
- }
28
- });
29
- };
30
- /**
31
- * Converts a {@link RuleGroupTypeIC} to {@link RuleGroupType}.
32
- *
33
- * This function is idempotent: {@link RuleGroupType} queries will be
34
- * returned as-is.
35
- *
36
- * @group Query Tools
37
- */
38
- const convertFromIC = (rg) => {
39
- if (require_isRuleGroup.isRuleGroupType(rg)) return rg;
40
- const processedRG = generateRuleGroupICWithConsistentCombinators(rg);
41
- const rulesAsMixedList = processedRG.rules.map((r) => typeof r === "string" || !require_isRuleGroup.isRuleGroup(r) ? r : convertFromIC(r));
42
- const combinator = rulesAsMixedList.length < 2 ? "and" : rulesAsMixedList[1];
43
- const rules = rulesAsMixedList.filter((r) => typeof r !== "string");
44
- return {
45
- ...processedRG,
46
- combinator,
47
- rules
48
- };
49
- };
50
- /**
51
- * Converts a {@link RuleGroupType} to {@link RuleGroupTypeIC}.
52
- *
53
- * This function is idempotent: {@link RuleGroupTypeIC} queries will be
54
- * returned as-is.
55
- *
56
- * @group Query Tools
57
- */
58
- const convertToIC = (rg) => {
59
- if (require_isRuleGroup.isRuleGroupTypeIC(rg)) return rg;
60
- const { combinator, ...queryWithoutCombinator } = rg;
61
- const rules = [];
62
- const { length } = rg.rules;
63
- for (const [idx, r] of rg.rules.entries()) {
64
- if (require_isRuleGroup.isRuleGroup(r)) rules.push(convertToIC(r));
65
- else rules.push(r);
66
- if (combinator && idx < length - 1) rules.push(combinator);
67
- }
68
- return {
69
- ...queryWithoutCombinator,
70
- rules
71
- };
72
- };
73
-
74
- //#endregion
75
- Object.defineProperty(exports, 'convertFromIC', {
76
- enumerable: true,
77
- get: function () {
78
- return convertFromIC;
79
- }
80
- });
81
- Object.defineProperty(exports, 'convertToIC', {
82
- enumerable: true,
83
- get: function () {
84
- return convertToIC;
85
- }
86
- });
87
- //# sourceMappingURL=convertQuery-DRldbzhZ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convertQuery-DRldbzhZ.js","names":["lc","isRuleGroupType","isRuleGroup","isRuleGroupTypeIC","rules: (RuleGroupTypeIC | RuleType | string)[]"],"sources":["../src/utils/convertQuery.ts"],"sourcesContent":["import { produce } from 'immer';\nimport type {\n RuleGroupArray,\n RuleGroupType,\n RuleGroupTypeAny,\n RuleGroupTypeIC,\n RuleType,\n} from '../types';\nimport { isRuleGroup, isRuleGroupType, isRuleGroupTypeIC } from './isRuleGroup';\nimport { lc } from './misc';\n\nconst combinatorLevels = ['or', 'xor', 'and'] as const;\n\nconst isSameString = (a: unknown, b: string) => lc(a) === b;\n\nconst generateRuleGroupICWithConsistentCombinators = (\n rg: RuleGroupTypeIC,\n baseCombinatorLevel: number = 0\n): RuleGroupTypeIC => {\n const baseCombinator = combinatorLevels[baseCombinatorLevel];\n\n // oxlint-disable-next-line typescript/no-explicit-any\n if (!rg.rules.includes(baseCombinator as any)) {\n // No instances of this combinator, so group based on the next\n // combinator level if at least two levels remain\n return baseCombinatorLevel < combinatorLevels.length - 2\n ? generateRuleGroupICWithConsistentCombinators(rg, baseCombinatorLevel + 1)\n : rg;\n }\n\n return produce(rg, draft => {\n let cursor = 0;\n\n // Group all chains of combinators in the rule array that are not the base combinator\n while (cursor < draft.rules.length - 2) {\n if (isSameString(draft.rules[cursor + 1], baseCombinator)) {\n cursor += 2;\n continue;\n }\n\n const nextBaseCombinatorIndex = draft.rules.findIndex(\n (r, i) => i > cursor && typeof r === 'string' && lc(r) === baseCombinator\n );\n\n if (nextBaseCombinatorIndex === -1) {\n // No more instances of this combinator, so group all remaining rules and exit the loop\n draft.rules.splice(\n cursor,\n draft.rules.length,\n generateRuleGroupICWithConsistentCombinators(\n // oxlint-disable-next-line typescript/no-explicit-any\n { rules: draft.rules.slice(cursor) as any },\n baseCombinatorLevel + 1\n )\n );\n break;\n } else {\n // Group all rules between the current cursor and the next instance of the base combinator\n draft.rules.splice(\n cursor,\n nextBaseCombinatorIndex - cursor,\n generateRuleGroupICWithConsistentCombinators(\n // oxlint-disable-next-line typescript/no-explicit-any\n { rules: draft.rules.slice(cursor, nextBaseCombinatorIndex) as any },\n baseCombinatorLevel + 1\n )\n );\n }\n }\n });\n};\n\n/**\n * Converts a {@link RuleGroupTypeIC} to {@link RuleGroupType}.\n *\n * This function is idempotent: {@link RuleGroupType} queries will be\n * returned as-is.\n *\n * @group Query Tools\n */\nexport const convertFromIC = <RG extends RuleGroupType = RuleGroupType>(\n rg: RuleGroupTypeAny\n): RG => {\n if (isRuleGroupType(rg)) {\n return rg as RG;\n }\n const processedRG = generateRuleGroupICWithConsistentCombinators(rg);\n const rulesAsMixedList = processedRG.rules.map(r =>\n typeof r === 'string' || !isRuleGroup(r) ? r : convertFromIC(r)\n );\n const combinator = rulesAsMixedList.length < 2 ? 'and' : (rulesAsMixedList[1] as string);\n const rules = rulesAsMixedList.filter(r => typeof r !== 'string') as RuleGroupArray;\n return { ...processedRG, combinator, rules } as RG;\n};\n\n/**\n * Converts a {@link RuleGroupType} to {@link RuleGroupTypeIC}.\n *\n * This function is idempotent: {@link RuleGroupTypeIC} queries will be\n * returned as-is.\n *\n * @group Query Tools\n */\nexport const convertToIC = <RGIC extends RuleGroupTypeIC = RuleGroupTypeIC>(\n rg: RuleGroupTypeAny\n): RGIC => {\n if (isRuleGroupTypeIC(rg)) {\n return rg as RGIC;\n }\n const { combinator, ...queryWithoutCombinator } = rg;\n const rules: (RuleGroupTypeIC | RuleType | string)[] = [];\n const { length } = rg.rules;\n for (const [idx, r] of rg.rules.entries()) {\n if (isRuleGroup(r)) {\n rules.push(convertToIC(r));\n } else {\n rules.push(r);\n }\n if (combinator && idx < length - 1) {\n rules.push(combinator);\n }\n }\n return { ...queryWithoutCombinator, rules } as RGIC;\n};\n\n/**\n * Converts a {@link RuleGroupType} to {@link RuleGroupTypeIC}. For a more explicit\n * operation, use {@link convertToIC}.\n *\n * @group Query Tools\n */\nfunction convertQuery(query: RuleGroupType): RuleGroupTypeIC;\n/**\n * Converts a {@link RuleGroupTypeIC} to {@link RuleGroupType}. For a more explicit\n * operation, use {@link convertFromIC}.\n *\n * @group Query Tools\n */\nfunction convertQuery(query: RuleGroupTypeIC): RuleGroupType;\nfunction convertQuery(query: RuleGroupType | RuleGroupTypeIC): RuleGroupType | RuleGroupTypeIC {\n return isRuleGroupTypeIC(query) ? convertFromIC(query) : convertToIC(query);\n}\n\nexport { convertQuery };\n"],"mappings":";;;;;AAWA,MAAM,mBAAmB;CAAC;CAAM;CAAO;CAAM;AAE7C,MAAM,gBAAgB,GAAY,MAAcA,uBAAG,EAAE,KAAK;AAE1D,MAAM,gDACJ,IACA,sBAA8B,MACV;CACpB,MAAM,iBAAiB,iBAAiB;AAGxC,KAAI,CAAC,GAAG,MAAM,SAAS,eAAsB,CAG3C,QAAO,sBAAsB,iBAAiB,SAAS,IACnD,6CAA6C,IAAI,sBAAsB,EAAE,GACzE;AAGN,2BAAe,KAAI,UAAS;EAC1B,IAAI,SAAS;AAGb,SAAO,SAAS,MAAM,MAAM,SAAS,GAAG;AACtC,OAAI,aAAa,MAAM,MAAM,SAAS,IAAI,eAAe,EAAE;AACzD,cAAU;AACV;;GAGF,MAAM,0BAA0B,MAAM,MAAM,WACzC,GAAG,MAAM,IAAI,U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ils/isRuleGroup.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// istanbul 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: any): obj is Record<string, any> =>\n obj === null || typeof obj !== 'object' ? false : 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"],"mappings":";;;;;;;;AAMA,MAAa,MAAS,MAAa,OAAO,MAAM,WAAY,EAAE,aAAa,GAAS;;;;;AAMpF,MAAaA,eAAuB,IAAI,OACtCC,8BAAqB,OAAO,QAAQ,OAAO,OAAO,GAAG,OAAO,CAAC,QAAQ,OAAO,OAAO,GAAG,OAAO,CAC9F;;;;AAMD,MAAa,UAAU,QACrB,QAAQ,QAAQ,OAAO,QAAQ,WAAW,QAAQ,OAAO,eAAe,IAAI,KAAK,OAAO;;;;AAK1F,MAAa,0BAA0B,UACrC,UAAU,QAAQ,UAAU,UAAa,UAAU;;;;;;;ACfrD,MAAa,eAAe,OAC1B,OAAO,GAAG,IAAI,MAAM,QAAQ,GAAG,MAAM;;;;AAKvC,MAAa,mBAAmB,OAC9B,YAAY,GAAG,IAAI,OAAO,GAAG,eAAe;;;;AAK9C,MAAa,qBAAqB,OAChC,YAAY,GAAG,IAAI,GAAG,eAAe"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"isRuleGroup-DztIOOKa.mjs","names":["numericRegex: RegExp","numericQuantityRegex"],"sources":["../src/utils/misc.ts","../src/utils/isRuleGroup.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// istanbul 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: any): obj is Record<string, any> =>\n obj === null || typeof obj !== 'object' ? false : 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"],"mappings":";;;;;;;AAMA,MAAa,MAAS,MAAa,OAAO,MAAM,WAAY,EAAE,aAAa,GAAS;;;;;AAMpF,MAAaA,iBAAuB,IAAI,OACtCC,aAAqB,OAAO,QAAQ,OAAO,OAAO,GAAG,OAAO,CAAC,QAAQ,OAAO,OAAO,GAAG,OAAO,CAC9F;;;;AAMD,MAAa,UAAU,QACrB,QAAQ,QAAQ,OAAO,QAAQ,WAAW,QAAQ,OAAO,eAAe,IAAI,KAAK,OAAO;;;;AAK1F,MAAa,0BAA0B,UACrC,UAAU,QAAQ,UAAU,UAAa,UAAU;;;;;;;ACfrD,MAAa,eAAe,OAC1B,OAAO,GAAG,IAAI,MAAM,QAAQ,GAAG,MAAM;;;;AAKvC,MAAa,mBAAmB,OAC9B,YAAY,GAAG,IAAI,OAAO,GAAG,eAAe;;;;AAK9C,MAAa,qBAAqB,OAChC,YAAY,GAAG,IAAI,GAAG,eAAe"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"prepareQueryObjects-6Bxx4Bs1.mjs","names":["defaultValueSourcesArray: ValueSourceFullOptions","valueSourcesNEW:\n | false\n | ValueSources\n | ValueSourceFlexibleOptions\n | ((operator: string) => ValueSources | ValueSourceFlexibleOptions)"],"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 fullField.comparator?.(fullFieldToCompare, operator) ?? /* istanbul ignore next */ false;\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 ?? /* istanbul ignore next */ f.name) !==\n (field.value ?? /* istanbul ignore next */ field.name);\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 */\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 as O);\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 => ({ ...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","// import type { UUID } from 'node:crypto';\ntype UUID = `${string}-${string}-${string}-${string}-${string}`;\n\nconst cryptoModule = globalThis.crypto;\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// istanbul 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// istanbul ignore else\nif (cryptoModule) {\n // istanbul 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 { produce } from 'immer';\nimport 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 produce(rule, draft => {\n if (!draft.id) {\n draft.id = idGenerator();\n }\n if (processMatchMode(draft)) {\n draft.value = prepareRuleGroup(draft.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 produce(queryObject, draft => {\n if (!draft.id) {\n draft.id = idGenerator();\n }\n draft.rules = draft.rules.map(r =>\n typeof r === 'string'\n ? r\n : isRuleGroup(r)\n ? prepareRuleGroup(r, { idGenerator })\n : prepareRule(r, { idGenerator })\n ) as RuleGroupArray | RuleGroupICArray;\n });\n\n/**\n * Ensures that a rule or group is valid. See {@link prepareRule} and {@link prepareRuleGroup}.\n */\nexport const prepareRuleOrGroup = <RG extends RuleGroupTypeAny>(\n rg: RG | 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,MAAM;CACrC,MAAM,qBAAqB,aAAa,eAAe;AACvD,KAAI,UAAU,UAAU,mBAAmB,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AI,CACpB;;AAIH,IAAI,cAEF;;KAAI,OAAO,aAAa,eAAe,WACrC,oBAAmB,aAAa,YAAY;UACnC,OAAO,aAAa,oBAAoB,YAAY;EAO7D,MAAM,iBAAiB;EACvB,MAAM,YAAY,IAAI,YAAY,GAAG;AAErC,qBAAmB;AACjB,gBAAa,gBAAgB,UAAU;GACvC,IAAI,MAAM,UAAU,KAAK,IAAI,SAAS,GAAG;AACzC,QAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK;AAC3B,QAAI,MAAM,GACR,MAAK,GAAG;aACC,MAAM,GACf,MAAK,GAAG,KAAK,eAAe,UAAU,MAAM;QAE5C,MAAK,GAAG,MAAM,UAAU,KAAK,IAAI,SAAS,GAAG;AAG/C,QAAI,MAAM,KAAK,MAAM,MAAM,MAAM,MAAM,MAAM,GAC3C,MAAK,GAAG;;AAGZ,UAAO;;;;;;;;;;AChCb,MAAa,eACX,MACA,EAAE,cAAc,eAAgC,EAAE,KAElD,QAAQ,OAAM,UAAS;AACrB,KAAI,CAAC,MAAM,GACT,OAAM,KAAK,aAAa;AAE1B,KAAI,iBAAiB,MAAM,CACzB,OAAM,QAAQ,iBAAiB,MAAM,OAAO,EAAE,aAAa,CAAC;EAE9D;;;;;AAMJ,MAAa,oBACX,aACA,EAAE,cAAc,eAAgC,EAAE,KAElD,QAAQ,cAAa,UAAS;AAC5B,KAAI,CAAC,MAAM,GACT,OAAM,KAAK,aAAa;AAE1B,OAAM,QAAQ,MAAM,MAAM,KAAI,MAC5B,OAAO,MAAM,WACT,IACA,YAAY,EAAE,GACZ,iBAAiB,GAAG,EAAE,aAAa,CAAC,GACpC,YAAY,GAAG,EAAE,aAAa,CAAC,CACtC;EACD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"prepareQueryObjects-CkN0bTKm.js","names":["toFullOption","isFlexibleOptionGroupArray","defaultValueSourcesArray: ValueSourceFullOptions","toFullOption","valueSourcesNEW:\n | false\n | ValueSources\n | ValueSourceFlexibleOptions\n | ((operator: string) => ValueSources | ValueSourceFlexibleOptions)","isFlexibleOptionArray","toFullOptionList","lc","toFlatOptionArray","isFlexibleOptionArray","toFullOption","processMatchMode","isRuleGroup"],"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 fullField.comparator?.(fullFieldToCompare, operator) ?? /* istanbul ignore next */ false;\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 ?? /* istanbul ignore next */ f.name) !==\n (field.value ?? /* istanbul ignore next */ field.name);\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 */\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 as O);\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 => ({ ...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","// import type { UUID } from 'node:crypto';\ntype UUID = `${string}-${string}-${string}-${string}-${string}`;\n\nconst cryptoModule = globalThis.crypto;\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// istanbul 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// istanbul ignore else\nif (cryptoModule) {\n // istanbul 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 { produce } from 'immer';\nimport 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 produce(rule, draft => {\n if (!draft.id) {\n draft.id = idGenerator();\n }\n if (processMatchMode(draft)) {\n draft.value = prepareRuleGroup(draft.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 produce(queryObject, draft => {\n if (!draft.id) {\n draft.id = idGenerator();\n }\n draft.rules = draft.rules.map(r =>\n typeof r === 'string'\n ? r\n : isRuleGroup(r)\n ? prepareRuleGroup(r, { idGenerator })\n : prepareRule(r, { idGenerator })\n ) as RuleGroupArray | RuleGroupICArray;\n });\n\n/**\n * Ensures that a rule or group is valid. See {@link prepareRule} and {@link prepareRuleGroup}.\n */\nexport const prepareRuleOrGroup = <RG extends RuleGroupTypeAny>(\n rg: RG | 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,YAAYA,2BAAa,MAAM;CACrC,MAAM,qBAAqBA,2BAAa,eAAe;AACvD,KAAI,UAAU,UAAU,mBA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ACZ,SAAS,GAAG,IAAI,CACpB;;AAIH,IAAI,cAEF;;KAAI,OAAO,aAAa,eAAe,WACrC,oBAAmB,aAAa,YAAY;UACnC,OAAO,aAAa,oBAAoB,YAAY;EAO7D,MAAM,iBAAiB;EACvB,MAAM,YAAY,IAAI,YAAY,GAAG;AAErC,qBAAmB;AACjB,gBAAa,gBAAgB,UAAU;GACvC,IAAI,MAAM,UAAU,KAAK,IAAI,SAAS,GAAG;AACzC,QAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK;AAC3B,QAAI,MAAM,GACR,MAAK,GAAG;aACC,MAAM,GACf,MAAK,GAAG,KAAK,eAAe,UAAU,MAAM;QAE5C,MAAK,GAAG,MAAM,UAAU,KAAK,IAAI,SAAS,GAAG;AAG/C,QAAI,MAAM,KAAK,MAAM,MAAM,MAAM,MAAM,MAAM,GAC3C,MAAK,GAAG;;AAGZ,UAAO;;;;;;;;;;AChCb,MAAa,eACX,MACA,EAAE,cAAc,eAAgC,EAAE,wBAE1C,OAAM,UAAS;AACrB,KAAI,CAAC,MAAM,GACT,OAAM,KAAK,aAAa;AAE1B,KAAIC,+BAAiB,MAAM,CACzB,OAAM,QAAQ,iBAAiB,MAAM,OAAO,EAAE,aAAa,CAAC;EAE9D;;;;;AAMJ,MAAa,oBACX,aACA,EAAE,cAAc,eAAgC,EAAE,wBAE1C,cAAa,UAAS;AAC5B,KAAI,CAAC,MAAM,GACT,OAAM,KAAK,aAAa;AAE1B,OAAM,QAAQ,MAAM,MAAM,KAAI,MAC5B,OAAO,MAAM,WACT,IACAC,gCAAY,EAAE,GACZ,iBAAiB,GAAG,EAAE,aAAa,CAAC,GACpC,YAAY,GAAG,EAAE,aAAa,CAAC,CACtC;EACD"}
@@ -1,54 +0,0 @@
1
- const require_chunk = require('./chunk-U64pC571.js');
2
- const require_isRuleGroup = require('./isRuleGroup-Cjk1Q2mj.js');
3
- let immer = require("immer");
4
-
5
- //#region src/utils/transformQuery.ts
6
- /**
7
- * Recursively steps through a query object ({@link index!RuleGroupType RuleGroupType} or {@link index!RuleGroupTypeIC RuleGroupTypeIC}),
8
- * passing each {@link index!RuleType RuleType} object to a provided `ruleProcessor` function and returning a
9
- * new query object if there were any referential changes.
10
- *
11
- * @module transformQuery
12
- */
13
- const remapProperties = (obj, propertyMap, deleteRemappedProperties) => (0, immer.produce)(obj, (draft) => {
14
- for (const [k, v] of Object.entries(propertyMap)) if (v === false) delete draft[k];
15
- else if (!!v && k !== v && k in draft) {
16
- draft[v] = draft[k];
17
- if (deleteRemappedProperties) delete draft[k];
18
- }
19
- });
20
- function transformQuery(query, options = {}) {
21
- const { ruleProcessor = (r) => r, ruleGroupProcessor = (rg) => rg, propertyMap = {}, combinatorMap = {}, operatorMap = {}, omitPath = false, deleteRemappedProperties = true } = options;
22
- const processGroup = (rg) => ({
23
- ...ruleGroupProcessor(remapProperties({
24
- ...rg,
25
- ...require_isRuleGroup.isRuleGroupType(rg) ? { combinator: combinatorMap[rg.combinator] ?? rg.combinator } : {}
26
- }, propertyMap, deleteRemappedProperties)),
27
- ...propertyMap["rules"] === false ? null : { [propertyMap["rules"] ?? "rules"]: rg.rules.map((r, idx) => {
28
- const pathObject = omitPath ? null : { path: [...rg.path, idx] };
29
- if (typeof r === "string") return combinatorMap[r] ?? r;
30
- else if (require_isRuleGroup.isRuleGroup(r)) return processGroup({
31
- ...r,
32
- ...pathObject
33
- });
34
- return ruleProcessor(remapProperties({
35
- ...r,
36
- ...pathObject,
37
- ..."operator" in r ? { operator: operatorMap[r.operator] ?? r.operator } : {}
38
- }, propertyMap, deleteRemappedProperties));
39
- }) }
40
- });
41
- return processGroup({
42
- ...query,
43
- ...omitPath ? null : { path: [] }
44
- });
45
- }
46
-
47
- //#endregion
48
- Object.defineProperty(exports, 'transformQuery', {
49
- enumerable: true,
50
- get: function () {
51
- return transformQuery;
52
- }
53
- });
54
- //# sourceMappingURL=transformQuery-ClBRfnFg.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transformQuery-ClBRfnFg.js","names":["isRuleGroupType","isRuleGroup"],"sources":["../src/utils/transformQuery.ts"],"sourcesContent":["/**\n * Recursively steps through a query object ({@link index!RuleGroupType RuleGroupType} or {@link index!RuleGroupTypeIC RuleGroupTypeIC}),\n * passing each {@link index!RuleType RuleType} object to a provided `ruleProcessor` function and returning a\n * new query object if there were any referential changes.\n *\n * @module transformQuery\n */\n\nimport { produce } from 'immer';\nimport type { RuleGroupType, RuleGroupTypeAny, RuleGroupTypeIC, RuleType } from '../types';\nimport { isRuleGroup, isRuleGroupType } from './isRuleGroup';\n\nconst remapProperties = (\n // oxlint-disable-next-line typescript/no-explicit-any\n obj: Record<string, any>,\n propertyMap: Record<string, string | false>,\n deleteRemappedProperties: boolean\n) =>\n produce(obj, draft => {\n for (const [k, v] of Object.entries(propertyMap)) {\n if (v === false) {\n delete draft[k];\n } else if (!!v && k !== v && k in draft) {\n draft[v] = draft[k];\n if (deleteRemappedProperties) {\n delete draft[k];\n }\n }\n }\n });\n\n/**\n * Options object for {@link index!transformQuery transformQuery}.\n */\nexport interface TransformQueryOptions<RG extends RuleGroupTypeAny = RuleGroupType> {\n /**\n * When a rule is encountered in the hierarchy, it will be replaced\n * with the result of this function.\n *\n * @defaultValue `r => r`\n */\n // oxlint-disable-next-line typescript/no-explicit-any\n ruleProcessor?: (rule: RuleType) => any;\n /**\n * When a group is encountered in the hierarchy (including the root group, the\n * query itself), it will be replaced with the result of this function.\n *\n * @defaultValue `rg => rg`\n */\n // oxlint-disable-next-line typescript/no-explicit-any\n ruleGroupProcessor?: (ruleGroup: RG) => Record<string, any>;\n /**\n * For each rule and group in the query, any properties matching a key\n * in this object will be renamed to the corresponding value. To retain both\n * the new _and_ the original properties, set `deleteRemappedProperties`\n * to `false`.\n *\n * If a key has a value of `false`, the corresponding property will be removed\n * without being copied to a new property name. (Warning: `{ rules: false }`\n * will prevent recursion and only return the processed root group.)\n *\n * @defaultValue `{}`\n *\n * @example\n * ```\n * transformQuery(\n * { combinator: 'and', not: true, rules: [] },\n * { propertyMap: { combinator: 'AndOr', not: false } }\n * )\n * // Returns: { AndOr: 'and', rules: [] }\n * ```\n */\n propertyMap?: Record<string, string | false>;\n /**\n * Any combinator values (including independent combinators) will be translated\n * from the key in this object to the value.\n *\n * @defaultValue `{}`\n *\n * @example\n * ```\n * transformQuery(\n * { combinator: 'and', rules: [] },\n * { combinatorMap: { and: '&&', or: '||' } }\n * )\n * // Returns: { combinator: '&&', rules: [] }\n * ```\n */\n combinatorMap?: Record<string, string>;\n /**\n * Any operator values will be translated from the key in this object to the value.\n *\n * @defaultValue `{}`\n *\n * @example\n * ```\n * transformQuery(\n * { combinator: 'and', rules: [{ field: 'name', operator: '=', value: 'Steve Vai' }] },\n * { operatorMap: { '=': 'is' } }\n * )\n * // Returns:\n * // {\n * // combinator: 'and',\n * // rules: [{ field: 'name', operator: 'is', value: 'Steve Vai' }]\n * // }\n * ```\n */\n operatorMap?: Record<string, string>;\n /**\n * Prevents the `path` property (see {@link index!Path Path}) from being added to each\n * rule and group in the hierarchy.\n *\n * @defaultValue `false`\n */\n omitPath?: boolean;\n /**\n * Original properties remapped according to the `propertyMap` option will be removed.\n *\n * @defaultValue `true`\n *\n * @example\n * ```\n * transformQuery(\n * { combinator: 'and', rules: [] },\n * { propertyMap: { combinator: 'AndOr' }, deleteRemappedProperties: false }\n * )\n * // Returns: { combinator: 'and', AndOr: 'and', rules: [] }\n * ```\n */\n deleteRemappedProperties?: boolean;\n}\n\n/**\n * Recursively process a query heirarchy using this versatile utility function.\n *\n * [Documentation](https://react-querybuilder.js.org/docs/utils/misc#transformquery)\n */\nexport function transformQuery(\n query: RuleGroupType,\n options?: TransformQueryOptions\n // oxlint-disable-next-line typescript/no-explicit-any\n): any;\n/**\n * Recursively process a query heirarchy with independent combinators using this\n * versatile utility function.\n *\n * [Documentation](https://react-querybuilder.js.org/docs/utils/misc#transformquery)\n */\nexport function transformQuery(\n query: RuleGroupTypeIC,\n options?: TransformQueryOptions<RuleGroupTypeIC>\n // oxlint-disable-next-line typescript/no-explicit-any\n): any;\nexport function transformQuery<RG extends RuleGroupTypeAny>(\n query: RG,\n options: TransformQueryOptions<RG> = {}\n) {\n const {\n ruleProcessor = r => r,\n ruleGroupProcessor = rg => rg,\n propertyMap = {},\n combinatorMap = {},\n operatorMap = {},\n omitPath = false,\n deleteRemappedProperties = true,\n } = options;\n\n // oxlint-disable-next-line typescript/no-explicit-any\n const processGroup = (rg: RuleGroupTypeAny): any => ({\n ...ruleGroupProcessor(\n remapProperties(\n {\n ...rg,\n ...(isRuleGroupType(rg)\n ? { combinator: combinatorMap[rg.combinator] ?? rg.combinator }\n : {}),\n },\n propertyMap,\n deleteRemappedProperties\n ) as RG\n ),\n ...(propertyMap['rules'] === false\n ? null\n : {\n // oxlint-disable-next-line typescript/no-explicit-any\n [propertyMap['rules'] ?? 'rules']: rg.rules.map((r: any, idx) => {\n const pathObject = omitPath ? null : { path: [...rg.path!, idx] };\n if (typeof r === 'string') {\n // independent combinators\n return combinatorMap[r] ?? r;\n } else if (isRuleGroup(r)) {\n // sub-groups\n return processGroup({ ...r, ...pathObject });\n }\n // rules\n return ruleProcessor(\n remapProperties(\n {\n ...r,\n ...pathObject,\n ...('operator' in r ? { operator: operatorMap[r.operator] ?? r.operator } : {}),\n },\n propertyMap,\n deleteRemappedProperties\n ) as RuleType\n );\n }),\n }),\n });\n\n return processGroup({ ...query, ...(omitPath ? null : { path: [] }) });\n}\n"],"mappings":";;;;;;;;;;;;AAYA,MAAM,mBAEJ,KACA,aACA,gDAEQ,MAAK,UAAS;AACpB,MAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,YAAY,CAC9C,KAAI,MAAM,MACR,QAAO,MAAM;UACJ,CAAC,CAAC,KAAK,MAAM,KAAK,KAAK,OAAO;AACvC,QAAM,KAAK,MAAM;AACjB,MAAI,yBACF,QAAO,MAAM;;EAInB;AA4HJ,SAAgB,eACd,OACA,UAAqC,EAAE,EACvC;CACA,MAAM,EACJ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