@react-querybuilder/core 8.20.2 → 8.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +4 -0
  2. package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +2261 -2113
  3. package/dist/cjs/react-querybuilder_core.cjs.development.js +319 -22
  4. package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
  5. package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +2261 -2113
  6. package/dist/cjs/react-querybuilder_core.cjs.production.js +1 -1
  7. package/dist/cjs/react-querybuilder_core.cjs.production.js.map +1 -1
  8. package/dist/{convertQuery-BJKNgecE.js → convertQuery-Cw76XFIn.js} +8 -8
  9. package/dist/{convertQuery-BJKNgecE.js.map → convertQuery-Cw76XFIn.js.map} +1 -1
  10. package/dist/{convertQuery-J1CaoDxe.mjs → convertQuery-D_4J7E-Z.mjs} +2 -2
  11. package/dist/{convertQuery-J1CaoDxe.mjs.map → convertQuery-D_4J7E-Z.mjs.map} +1 -1
  12. package/dist/formatQuery.d.mts +499 -459
  13. package/dist/formatQuery.d.ts +499 -459
  14. package/dist/formatQuery.js +170 -88
  15. package/dist/formatQuery.js.map +1 -1
  16. package/dist/formatQuery.mjs +97 -20
  17. package/dist/formatQuery.mjs.map +1 -1
  18. package/dist/import-BVdxeIBO.d.mts +26 -0
  19. package/dist/import-Ddc3d_8q.d.ts +26 -0
  20. package/dist/{index-DlVg-QXo.d.mts → index-BSwFvkeI.d.mts} +679 -648
  21. package/dist/{index-DlVg-QXo.d.ts → index-BSwFvkeI.d.ts} +679 -648
  22. package/dist/{objectUtils-DBJI82bl.js → isRuleGroup-0JNiQgLg.js} +1 -26
  23. package/dist/isRuleGroup-0JNiQgLg.js.map +1 -0
  24. package/dist/{objectUtils-ZvPkF6u6.mjs → isRuleGroup-CqLThsbu.mjs} +2 -15
  25. package/dist/isRuleGroup-CqLThsbu.mjs.map +1 -0
  26. package/dist/objectUtils-Cr02aGxb.js +27 -0
  27. package/dist/objectUtils-Cr02aGxb.js.map +1 -0
  28. package/dist/objectUtils-DBlmJgBf.mjs +16 -0
  29. package/dist/objectUtils-DBlmJgBf.mjs.map +1 -0
  30. package/dist/parseCEL.d.mts +64 -30
  31. package/dist/parseCEL.d.ts +64 -30
  32. package/dist/parseCEL.js +91 -12
  33. package/dist/parseCEL.js.map +1 -1
  34. package/dist/parseCEL.mjs +85 -8
  35. package/dist/parseCEL.mjs.map +1 -1
  36. package/dist/parseCypher.d.mts +24 -25
  37. package/dist/parseCypher.d.ts +24 -25
  38. package/dist/parseGremlin.d.mts +18 -19
  39. package/dist/parseGremlin.d.ts +18 -19
  40. package/dist/parseJSONata.d.mts +207 -20
  41. package/dist/parseJSONata.d.ts +207 -20
  42. package/dist/parseJSONata.js +92 -7
  43. package/dist/parseJSONata.js.map +1 -1
  44. package/dist/parseJSONata.mjs +80 -4
  45. package/dist/parseJSONata.mjs.map +1 -1
  46. package/dist/parseJsonLogic.d.mts +51 -18
  47. package/dist/parseJsonLogic.d.ts +51 -18
  48. package/dist/parseJsonLogic.js +95 -34
  49. package/dist/parseJsonLogic.js.map +1 -1
  50. package/dist/parseJsonLogic.mjs +65 -6
  51. package/dist/parseJsonLogic.mjs.map +1 -1
  52. package/dist/parseMongoDB.d.mts +89 -58
  53. package/dist/parseMongoDB.d.ts +89 -58
  54. package/dist/parseMongoDB.js +140 -15
  55. package/dist/parseMongoDB.js.map +1 -1
  56. package/dist/parseMongoDB.mjs +128 -5
  57. package/dist/parseMongoDB.mjs.map +1 -1
  58. package/dist/parseSPARQL.d.mts +17 -18
  59. package/dist/parseSPARQL.d.ts +17 -18
  60. package/dist/parseSPARQL.js.map +1 -1
  61. package/dist/parseSPARQL.mjs.map +1 -1
  62. package/dist/parseSQL.d.mts +266 -18
  63. package/dist/parseSQL.d.ts +266 -18
  64. package/dist/parseSQL.js +163 -10
  65. package/dist/parseSQL.js.map +1 -1
  66. package/dist/parseSQL.mjs +149 -7
  67. package/dist/parseSQL.mjs.map +1 -1
  68. package/dist/parseSpEL.d.mts +193 -19
  69. package/dist/parseSpEL.d.ts +193 -19
  70. package/dist/parseSpEL.js +166 -7
  71. package/dist/parseSpEL.js.map +1 -1
  72. package/dist/parseSpEL.mjs +142 -6
  73. package/dist/parseSpEL.mjs.map +1 -1
  74. package/dist/{prepareQueryObjects-Bni5VgYM.js → prepareQueryObjects-C2-kTZvR.js} +5 -5
  75. package/dist/prepareQueryObjects-C2-kTZvR.js.map +1 -0
  76. package/dist/{prepareQueryObjects-BCLU20Cg.mjs → prepareQueryObjects-Q18lHCKl.mjs} +3 -3
  77. package/dist/prepareQueryObjects-Q18lHCKl.mjs.map +1 -0
  78. package/dist/query-builder-layout.css.map +1 -1
  79. package/dist/query-builder.css.map +1 -1
  80. package/dist/react-querybuilder_core.d.mts +2261 -2113
  81. package/dist/react-querybuilder_core.legacy-esm.d.ts +2261 -2113
  82. package/dist/react-querybuilder_core.legacy-esm.js +335 -40
  83. package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
  84. package/dist/react-querybuilder_core.mjs +309 -23
  85. package/dist/react-querybuilder_core.mjs.map +1 -1
  86. package/dist/react-querybuilder_core.production.d.mts +2261 -2113
  87. package/dist/react-querybuilder_core.production.mjs +1 -1
  88. package/dist/react-querybuilder_core.production.mjs.map +1 -1
  89. package/dist/styles/_layout.scss +4 -10
  90. package/dist/transformQuery.d.mts +91 -92
  91. package/dist/transformQuery.d.ts +91 -92
  92. package/dist/transformQuery.js +4 -3
  93. package/dist/transformQuery.js.map +1 -1
  94. package/dist/transformQuery.mjs +2 -1
  95. package/dist/transformQuery.mjs.map +1 -1
  96. package/dist/{utils-BpaOtylk.js → utils-DEwV7F6B.js} +108 -12
  97. package/dist/utils-DEwV7F6B.js.map +1 -0
  98. package/dist/{utils-CJRGiPb-.mjs → utils-Dt0D_DMV.mjs} +69 -3
  99. package/dist/utils-Dt0D_DMV.mjs.map +1 -0
  100. package/package.json +14 -14
  101. package/dist/import-Qs1-kgv5.d.ts +0 -27
  102. package/dist/import-ShTj5IdB.d.mts +0 -27
  103. package/dist/objectUtils-DBJI82bl.js.map +0 -1
  104. package/dist/objectUtils-ZvPkF6u6.mjs.map +0 -1
  105. package/dist/prepareQueryObjects-BCLU20Cg.mjs.map +0 -1
  106. package/dist/prepareQueryObjects-Bni5VgYM.js.map +0 -1
  107. package/dist/utils-BpaOtylk.js.map +0 -1
  108. package/dist/utils-CJRGiPb-.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"parseJSONata.mjs","names":[],"sources":["../src/utils/parseJSONata/utils.ts","../src/utils/parseJSONata/parseJSONata.ts"],"sourcesContent":["import type { DefaultCombinatorName, DefaultOperatorName } from '../../types';\nimport type {\n JSONataAnd,\n JSONataBinaryNode,\n JSONataBlock,\n JSONataBoolean,\n JSONataContains,\n JSONataEqual,\n JSONataExprNode,\n JSONataGreaterThan,\n JSONataGreaterThanOrEqual,\n JSONataIdentifier,\n JSONataIn,\n JSONataLessThan,\n JSONataLessThanOrEqual,\n JSONataList,\n JSONataName,\n JSONataNot,\n JSONataNotEqual,\n JSONataNull,\n JSONataNumber,\n JSONataOr,\n JSONataPath,\n JSONataRegex,\n JSONataString,\n JSONataToMillis,\n} from './types';\n\n// oxlint-disable-next-line typescript/no-explicit-any\ntype Any = any;\n\nexport const isJSONataExprNode = (expr: Any): expr is JSONataExprNode => {\n return expr && typeof expr === 'object' && typeof expr.type === 'string';\n};\nconst isJSONataBinaryNode = (expr: Any): expr is JSONataBinaryNode =>\n isJSONataExprNode(expr) && expr.type === 'binary';\n\n// Identifiers\nexport const isJSONataPath = (expr: Any): expr is JSONataPath =>\n isJSONataExprNode(expr) &&\n expr.type === 'path' &&\n Array.isArray(expr.steps) &&\n expr.steps.length > 0 &&\n isJSONataExprNode(expr.steps[0]);\nexport const isJSONataName = (expr: Any): expr is JSONataName =>\n isJSONataExprNode(expr) &&\n expr.type === 'name' &&\n typeof expr.value === 'string' &&\n expr.value.length > 0;\nexport const isJSONataIdentifier = (expr: Any): expr is JSONataIdentifier =>\n isJSONataPath(expr) && expr.steps.every(v => isJSONataName(v));\n\n// Groups\nexport const isJSONataBlock = (expr: Any): expr is JSONataBlock =>\n isJSONataExprNode(expr) &&\n expr.type === 'block' &&\n Array.isArray(expr.expressions) &&\n expr.expressions.length > 0 &&\n isJSONataExprNode(expr.expressions[0]);\n\n// Values\nexport const isJSONataString = (expr: Any): expr is JSONataString =>\n isJSONataExprNode(expr) && expr.type === 'string' && typeof expr.value === 'string';\nexport const isJSONataNumber = (expr: Any): expr is JSONataNumber =>\n isJSONataExprNode(expr) && expr.type === 'number' && typeof expr.value === 'number';\nexport const isJSONataBoolean = (expr: Any): expr is JSONataBoolean =>\n isJSONataExprNode(expr) && expr.type === 'value' && typeof expr.value === 'boolean';\nexport const isJSONataNull = (expr: Any): expr is JSONataNull =>\n isJSONataExprNode(expr) && expr.type === 'value' && expr.value === null;\nexport const isJSONataRegex = (expr: Any): expr is JSONataRegex =>\n isJSONataExprNode(expr) && expr.type === 'regex' && expr.value instanceof RegExp;\n\n// Combinators\nexport const isJSONataAnd = (expr: Any): expr is JSONataAnd =>\n isJSONataBinaryNode(expr) && expr.value === 'and';\nexport const isJSONataOr = (expr: Any): expr is JSONataOr =>\n isJSONataBinaryNode(expr) && expr.value === 'or';\n\n// Operators\nexport const isJSONataEqual = (expr: Any): expr is JSONataEqual =>\n isJSONataBinaryNode(expr) && expr.value === '=';\nexport const isJSONataNotEqual = (expr: Any): expr is JSONataNotEqual =>\n isJSONataBinaryNode(expr) && expr.value === '!=';\nexport const isJSONataGreaterThan = (expr: Any): expr is JSONataGreaterThan =>\n isJSONataBinaryNode(expr) && expr.value === '>';\nexport const isJSONataGreaterThanOrEqual = (expr: Any): expr is JSONataGreaterThanOrEqual =>\n isJSONataBinaryNode(expr) && expr.value === '>=';\nexport const isJSONataLessThan = (expr: Any): expr is JSONataLessThan =>\n isJSONataBinaryNode(expr) && expr.value === '<';\nexport const isJSONataLessThanOrEqual = (expr: Any): expr is JSONataLessThanOrEqual =>\n isJSONataBinaryNode(expr) && expr.value === '<=';\nexport const isJSONataIn = (expr: Any): expr is JSONataIn =>\n isJSONataBinaryNode(expr) &&\n expr.value === 'in' &&\n isJSONataPath(expr.lhs) &&\n isJSONataList(expr.rhs);\n\n// Functions\nexport const isJSONataNot = (expr: Any): expr is JSONataNot =>\n isJSONataExprNode(expr) &&\n expr.type === 'function' &&\n expr.value === '(' &&\n Array.isArray(expr.arguments) &&\n isJSONataExprNode(expr.arguments[0]) &&\n isJSONataExprNode(expr.procedure) &&\n expr.procedure.value === 'not' &&\n expr.procedure.type === 'variable';\nexport const isJSONataContains = (expr: Any): expr is JSONataContains =>\n isJSONataExprNode(expr) &&\n expr.type === 'function' &&\n expr.value === '(' &&\n Array.isArray(expr.arguments) &&\n expr.arguments.length >= 2 &&\n isJSONataExprNode(expr.arguments[0]) &&\n isJSONataExprNode(expr.procedure) &&\n expr.procedure.value === 'contains' &&\n expr.procedure.type === 'variable';\nexport const isJSONataToMillis = (expr: Any): expr is JSONataToMillis =>\n isJSONataExprNode(expr) &&\n expr.type === 'function' &&\n expr.value === '(' &&\n Array.isArray(expr.arguments) &&\n expr.arguments.length > 0 &&\n isJSONataString(expr.arguments[0]) &&\n isJSONataExprNode(expr.procedure) &&\n expr.procedure.value === 'toMillis' &&\n expr.procedure.type === 'variable';\n\n// Miscellaneous\nexport const isJSONataList = (expr: Any): expr is JSONataList =>\n isJSONataExprNode(expr) &&\n expr.type === 'unary' &&\n expr.value === '[' &&\n Array.isArray(expr.expressions);\nexport const isJSONataPrimitive = (expr: Any): boolean => {\n return (\n isJSONataString(expr) ||\n isJSONataNumber(expr) ||\n isJSONataBoolean(expr) ||\n isJSONataNull(expr) ||\n isJSONataToMillis(expr)\n );\n};\nexport const isJSONataPrimitiveList = (expr: Any): boolean =>\n isJSONataList(expr) && expr.expressions.every(v => isJSONataPrimitive(v));\nexport const isJSONataIdentifierList = (expr: Any): boolean =>\n isJSONataList(expr) && expr.expressions.every(v => isJSONataIdentifier(v));\nexport const isJSONataValidValue = (expr: Any): boolean =>\n isJSONataPrimitive(expr) ||\n isJSONataRegex(expr) ||\n isJSONataIdentifier(expr) ||\n isJSONataPrimitiveList(expr) ||\n isJSONataIdentifierList(expr) ||\n isJSONataToMillis(expr);\nexport const isJSONataComparison = (\n expr: Any\n): expr is\n | JSONataEqual\n | JSONataNotEqual\n | JSONataGreaterThan\n | JSONataGreaterThanOrEqual\n | JSONataLessThan\n | JSONataLessThanOrEqual =>\n isJSONataEqual(expr) ||\n isJSONataNotEqual(expr) ||\n isJSONataGreaterThan(expr) ||\n isJSONataGreaterThanOrEqual(expr) ||\n isJSONataLessThan(expr) ||\n isJSONataLessThanOrEqual(expr);\n\nexport const getValidValue = (expr: Any): Any => {\n if (isJSONataToMillis(expr)) {\n return getValidValue(expr.arguments[0]);\n } else if (isJSONataIdentifier(expr)) {\n return getFieldFromPath(expr);\n } else if (isJSONataPrimitiveList(expr)) {\n return expr.expressions.map((v: Any) => getValidValue(v));\n } else if (isJSONataIdentifierList(expr)) {\n return expr.expressions.map((v: Any) => getFieldFromPath(v));\n }\n return expr.value;\n};\n\nexport const getFieldFromPath = (path: JSONataPath): string =>\n isJSONataIdentifier(path)\n ? path.steps.map(s => s.value).join('.')\n : /* v8 ignore next -- @preserve */ '';\n\nexport const normalizeOperator = (\n opType: DefaultOperatorName,\n flip?: boolean\n): DefaultOperatorName => {\n if (flip) {\n if (opType === '<') return '>';\n if (opType === '<=') return '>=';\n if (opType === '>') return '<';\n if (opType === '>=') return '<=';\n }\n return opType;\n};\n\nexport const negatedLikeOperators: Record<\n Extract<DefaultOperatorName, 'beginsWith' | 'contains' | 'endsWith'>,\n DefaultOperatorName\n> = {\n contains: 'doesNotContain',\n beginsWith: 'doesNotBeginWith',\n endsWith: 'doesNotEndWith',\n} satisfies Record<\n Extract<DefaultOperatorName, 'beginsWith' | 'contains' | 'endsWith'>,\n DefaultOperatorName\n>;\n\nexport const generateFlatAndOrList = (\n expr: JSONataExprNode\n): (DefaultCombinatorName | JSONataExprNode)[] => {\n // v8 ignore else\n if (isJSONataAnd(expr) || isJSONataOr(expr)) {\n const { lhs, rhs, value: combinator } = expr;\n if (isJSONataAnd(lhs) || isJSONataOr(lhs)) {\n return [...generateFlatAndOrList(lhs), combinator, rhs];\n }\n return [lhs, combinator, rhs];\n }\n // v8 ignore next\n return [];\n};\n\nexport const generateMixedAndOrList = (\n expr: JSONataAnd | JSONataOr\n): (JSONataExprNode | DefaultCombinatorName | (JSONataExprNode | 'and')[])[] => {\n const arr = generateFlatAndOrList(expr);\n const returnArray: (DefaultCombinatorName | JSONataExprNode | ('and' | JSONataExprNode)[])[] = [];\n let startIndex = 0;\n for (let i = 0; i < arr.length; i += 2) {\n if (arr[i + 1] === 'and') {\n startIndex = i;\n let j = 1;\n while (arr[startIndex + j] === 'and') {\n i += 2;\n j += 2;\n }\n const tempAndArray = arr.slice(startIndex, i + 1) as ('and' | JSONataExprNode)[];\n returnArray.push(tempAndArray);\n i -= 2;\n } else if (arr[i + 1] === 'or') {\n if (i === 0 || i === arr.length - 3) {\n if (i === 0 || arr[i - 1] === 'or') {\n returnArray.push(arr[i]);\n }\n returnArray.push(arr[i + 1]);\n if (i === arr.length - 3) {\n returnArray.push(arr[i + 2]);\n }\n } else {\n if (arr[i - 1] === 'and') {\n returnArray.push(arr[i + 1]);\n } else {\n returnArray.push(arr[i], arr[i + 1]);\n }\n }\n }\n }\n if (returnArray.length === 1 && Array.isArray(returnArray[0])) {\n // If length is 1, then the only element is an AND array so just return that\n return returnArray[0];\n }\n return returnArray;\n};\n","import jsonata from 'jsonata';\nimport type { Except } from 'type-fest';\nimport type {\n DefaultCombinatorName,\n DefaultOperatorName,\n DefaultRuleGroupArray,\n DefaultRuleGroupICArray,\n DefaultRuleGroupType,\n DefaultRuleGroupTypeAny,\n DefaultRuleGroupTypeIC,\n DefaultRuleType,\n ValueSource,\n} from '../../types';\nimport type { ParserCommonOptions } from '../../types/import';\nimport { isRuleGroup } from '../isRuleGroup';\nimport { fieldIsValidUtil, getFieldsArray } from '../parserUtils';\nimport { prepareRuleGroup } from '../prepareQueryObjects';\nimport type { JSONataExprNode } from './types';\nimport {\n generateFlatAndOrList,\n generateMixedAndOrList,\n getFieldFromPath,\n getValidValue,\n isJSONataAnd,\n isJSONataBlock,\n isJSONataComparison,\n isJSONataContains,\n isJSONataIdentifier,\n isJSONataIdentifierList,\n isJSONataIn,\n isJSONataNot,\n isJSONataOr,\n isJSONataRegex,\n isJSONataString,\n isJSONataValidValue,\n negatedLikeOperators,\n normalizeOperator,\n} from './utils';\n\n/**\n * Options object for {@link parseJSONata}.\n *\n * Note: `listsAsArrays` is ignored by `parseJSONata`; lists are _always_ arrays.\n */\nexport interface ParseJSONataOptions extends ParserCommonOptions {}\n\n/**\n * Converts a JSONata string expression into a query suitable for the\n * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props\n * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).\n */\nfunction parseJSONata(jsonataInput: string): DefaultRuleGroupType;\n/**\n * Converts a JSONata string expression into a query suitable for the\n * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props\n * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).\n */\nfunction parseJSONata(\n jsonataInput: string,\n options: Except<ParseJSONataOptions, 'independentCombinators'> & {\n independentCombinators?: false;\n }\n): DefaultRuleGroupType;\n/**\n * Converts a JSONata string expression into a query suitable for the\n * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props\n * ({@link index!DefaultRuleGroupTypeIC DefaultRuleGroupTypeIC}).\n */\nfunction parseJSONata(\n jsonataInput: string,\n options: Except<ParseJSONataOptions, 'independentCombinators'> & {\n independentCombinators: true;\n }\n): DefaultRuleGroupTypeIC;\nfunction parseJSONata(\n jsonataInput: string,\n options: ParseJSONataOptions = {}\n): DefaultRuleGroupTypeAny {\n const { fields, independentCombinators, listsAsArrays: _laa } = options;\n const ic = !!independentCombinators;\n const fieldsFlat = getFieldsArray(fields);\n\n const fieldIsValid = (\n fieldName: string,\n operator: DefaultOperatorName,\n subordinateFieldName?: string\n ) =>\n fieldIsValidUtil({\n fieldName,\n fieldsFlat,\n operator,\n subordinateFieldName,\n getValueSources: options?.getValueSources,\n });\n\n const emptyQuery: DefaultRuleGroupTypeAny = {\n rules: [],\n ...(ic ? {} : { combinator: 'and' }),\n };\n\n const parseJSONataAST = (\n expr: JSONataExprNode,\n processOpts: {\n groupOnlyIfNecessary?: boolean;\n forwardNegation?: boolean;\n } = {}\n ): DefaultRuleType | DefaultRuleGroupTypeAny | null => {\n const { forwardNegation: _forwardedNegation, groupOnlyIfNecessary: _g } = processOpts;\n if (isJSONataBlock(expr)) {\n if (\n isJSONataAnd(expr.expressions[0]) ||\n isJSONataOr(expr.expressions[0]) ||\n isJSONataBlock(expr.expressions[0])\n ) {\n return parseJSONataAST(expr.expressions[0]);\n }\n const blockOfExpr = parseJSONataAST(expr.expressions[0]);\n // v8 ignore else\n if (blockOfExpr) {\n return ic\n ? ({ rules: [blockOfExpr] } as DefaultRuleGroupTypeIC)\n : ({\n combinator: 'and',\n rules: [blockOfExpr],\n } as DefaultRuleGroupType);\n }\n } else if (isJSONataAnd(expr) || isJSONataOr(expr)) {\n if (ic) {\n const andOrList = generateFlatAndOrList(expr);\n const rules = andOrList.map(v => {\n if (typeof v === 'string') {\n return v;\n }\n return parseJSONataAST(v);\n });\n // Bail out completely if any rules in the list were invalid\n // so as not to return an incorrect and/or sequence\n if (!rules.every(Boolean)) {\n return null;\n }\n\n // Reduce this group to a single between/notBetween rule if possible\n if (\n ((rs: unknown[]): rs is [DefaultRuleType, DefaultCombinatorName, DefaultRuleType] =>\n rs.length === 3 &&\n (rs[1] === 'and' || rs[1] === 'or') &&\n !isRuleGroup(rs[0]) &&\n !isRuleGroup(rs[2]))(rules) &&\n rules[0].field === rules[2].field &&\n (rules[0].valueSource ?? 'value') === (rules[2].valueSource ?? 'value') &&\n ((rules[1] === 'and' &&\n ((rules[0].operator === '>=' && rules[2].operator === '<=') ||\n (rules[0].operator === '<=' && rules[2].operator === '>='))) ||\n (rules[1] === 'or' &&\n ((rules[0].operator === '>' && rules[2].operator === '<') ||\n (rules[0].operator === '<' && rules[2].operator === '>'))))\n ) {\n return {\n field: rules[0].field,\n operator: rules[1] === 'and' ? 'between' : 'notBetween',\n value:\n (rules[1] === 'and' && rules[0].operator === '<=') ||\n (rules[1] === 'or' && rules[0].operator === '>')\n ? [rules[2].value, rules[0].value]\n : [rules[0].value, rules[2].value],\n ...(rules[0].valueSource ? { valueSource: rules[0].valueSource } : null),\n };\n }\n\n return {\n rules: rules as DefaultRuleGroupICArray,\n };\n }\n const andOrList = generateMixedAndOrList(expr);\n const combinator = andOrList[1] as DefaultCombinatorName;\n const filteredList = andOrList\n .filter(v => Array.isArray(v) || (!!v && typeof v !== 'string' && 'type' in v))\n .map(v =>\n Array.isArray(v) ? v.filter(vf => !!v && typeof vf !== 'string' && 'type' in vf) : v\n ) as (JSONataExprNode | JSONataExprNode[])[];\n const rules = filteredList\n .map((exp): DefaultRuleGroupType | DefaultRuleType | null => {\n if (Array.isArray(exp)) {\n return {\n combinator: 'and',\n rules: exp.map(e => parseJSONataAST(e)).filter(Boolean) as DefaultRuleGroupArray,\n };\n }\n return parseJSONataAST(exp) as DefaultRuleType | DefaultRuleGroupType | null;\n })\n .filter(Boolean) as DefaultRuleGroupArray;\n\n // Reduce this group to a single between/notBetween rule if possible\n if (\n ((rs: unknown[]): rs is [DefaultRuleType, DefaultRuleType] =>\n rs.length === 2 && !isRuleGroup(rs[0]) && !isRuleGroup(rs[1]))(rules) &&\n rules[0].field === rules[1].field &&\n (rules[0].valueSource ?? 'value') === (rules[1].valueSource ?? 'value') &&\n ((combinator === 'and' &&\n ((rules[0].operator === '>=' && rules[1].operator === '<=') ||\n (rules[0].operator === '<=' && rules[1].operator === '>='))) ||\n (combinator === 'or' &&\n ((rules[0].operator === '>' && rules[1].operator === '<') ||\n (rules[0].operator === '<' && rules[1].operator === '>'))))\n ) {\n return {\n field: rules[0].field,\n operator: combinator === 'and' ? 'between' : 'notBetween',\n value:\n (combinator === 'and' && rules[0].operator === '<=') ||\n (combinator === 'or' && rules[0].operator === '>')\n ? [rules[1].value, rules[0].value]\n : [rules[0].value, rules[1].value],\n ...(rules[0].valueSource ? { valueSource: rules[0].valueSource } : null),\n };\n }\n\n // v8 ignore else\n if (rules.length > 0) {\n return { combinator, rules };\n }\n } else if (isJSONataNot(expr)) {\n const negatedExpr = parseJSONataAST(expr.arguments[0]);\n // v8 ignore else\n if (negatedExpr) {\n if (\n !isRuleGroup(negatedExpr) &&\n (negatedExpr.operator === 'contains' ||\n negatedExpr.operator === 'beginsWith' ||\n negatedExpr.operator === 'endsWith')\n ) {\n return {\n ...negatedExpr,\n operator: negatedLikeOperators[negatedExpr.operator],\n };\n }\n return ic\n ? ({ rules: [negatedExpr], not: true } as DefaultRuleGroupTypeIC)\n : ({\n combinator: 'and',\n rules: [negatedExpr],\n not: true,\n } as DefaultRuleGroupType);\n }\n } else if (isJSONataContains(expr)) {\n const [arg1, arg2] = expr.arguments;\n let field: string = '';\n let regex: string | RegExp = '';\n let valueSource: ValueSource | undefined = undefined;\n // v8 ignore else\n if (isJSONataIdentifier(arg1)) {\n field = getFieldFromPath(arg1);\n if (isJSONataIdentifier(arg2)) {\n regex = getFieldFromPath(arg2);\n valueSource = 'field';\n } else {\n // v8 ignore else\n if (isJSONataString(arg2) || isJSONataRegex(arg2)) {\n regex = getValidValue(arg2);\n }\n }\n }\n\n // v8 ignore else\n if (\n valueSource === 'field'\n ? fieldIsValid(field, 'contains', regex as string)\n : fieldIsValid(field, 'contains')\n ) {\n return {\n field,\n operator: 'contains',\n value: regex,\n ...(valueSource ? { valueSource } : {}),\n };\n }\n } else if (isJSONataIn(expr)) {\n const field = getFieldFromPath(expr.lhs);\n let valueSource: ValueSource | undefined = undefined;\n if (isJSONataIdentifierList(expr.rhs)) {\n valueSource = 'field';\n }\n if (isJSONataValidValue(expr.rhs)) {\n // oxlint-disable-next-line typescript/no-explicit-any\n const value: any[] = getValidValue(expr.rhs);\n // v8 ignore else\n if (\n field &&\n value.every(v => fieldIsValid(field, 'in', valueSource === 'field' ? v : undefined))\n ) {\n return { field, operator: 'in', value, ...(valueSource ? { valueSource } : {}) };\n }\n }\n } else if (isJSONataComparison(expr)) {\n let field: string | null = null;\n // oxlint-disable-next-line typescript/no-explicit-any\n let value: any = undefined;\n let valueSource: ValueSource | undefined = undefined;\n let flip = false;\n const { lhs, rhs } = expr;\n\n if (isJSONataIdentifier(lhs) && isJSONataValidValue(rhs)) {\n field = getFieldFromPath(lhs);\n value = getValidValue(rhs);\n if (isJSONataIdentifier(rhs)) {\n valueSource = 'field';\n }\n } else {\n // v8 ignore else\n if (isJSONataIdentifier(rhs) && isJSONataValidValue(lhs)) {\n flip = true;\n field = getFieldFromPath(rhs);\n value = getValidValue(lhs);\n }\n }\n let operator = normalizeOperator(expr.value, flip);\n if (value === null && (operator === '=' || operator === '!=')) {\n operator = operator === '=' ? 'null' : 'notNull';\n }\n if (\n field &&\n fieldIsValid(field, operator, valueSource === 'field' ? value : undefined) &&\n value !== undefined\n ) {\n return valueSource ? { field, operator, value, valueSource } : { field, operator, value };\n }\n }\n return null;\n };\n\n const prepare = options.generateIDs ? prepareRuleGroup : <T>(g: T) => g;\n\n let jsonataExpr: jsonata.Expression;\n try {\n jsonataExpr = jsonata(jsonataInput);\n } catch {\n return prepare(emptyQuery);\n }\n const jsonataAST = jsonataExpr.ast() as JSONataExprNode;\n\n const result = parseJSONataAST(jsonataAST);\n if (result) {\n if (isRuleGroup(result)) {\n return prepare(result);\n }\n return prepare({ rules: [result], ...(ic ? {} : { combinator: 'and' }) });\n }\n\n return prepare(emptyQuery);\n}\n\nexport { parseJSONata };\n"],"mappings":";;;;AA+BA,MAAa,qBAAqB,SAAuC;CACvE,OAAO,QAAQ,O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GAAG;IACxD,OAAO;IACP,QAAQ,iBAAiB,GAAG;IAC5B,QAAQ,cAAc,GAAG;GAC3B;GAEF,IAAI,WAAW,kBAAkB,KAAK,OAAO,IAAI;GACjD,IAAI,UAAU,SAAS,aAAa,OAAO,aAAa,OACtD,WAAW,aAAa,MAAM,SAAS;GAEzC,IACE,SACA,aAAa,OAAO,UAAU,gBAAgB,UAAU,QAAQ,KAAA,CAAS,KACzE,UAAU,KAAA,GAEV,OAAO,cAAc;IAAE;IAAO;IAAU;IAAO;GAAY,IAAI;IAAE;IAAO;IAAU;GAAM;EAE5F;EACA,OAAO;CACT;CAEA,MAAM,UAAU,QAAQ,cAAc,oBAAuB,MAAS;CAEtE,IAAI;CACJ,IAAI;EACF,cAAc,QAAQ,YAAY;CACpC,QAAQ;EACN,OAAO,QAAQ,UAAU;CAC3B;CAGA,MAAM,SAAS,gBAFI,YAAY,IAES,CAAC;CACzC,IAAI,QAAQ;EACV,IAAI,YAAY,MAAM,GACpB,OAAO,QAAQ,MAAM;EAEvB,OAAO,QAAQ;GAAE,OAAO,CAAC,MAAM;GAAG,GAAI,KAAK,CAAC,IAAI,EAAE,YAAY,MAAM;EAAG,CAAC;CAC1E;CAEA,OAAO,QAAQ,UAAU;AAC3B"}
1
+ {"version":3,"file":"parseJSONata.mjs","names":[],"sources":["../src/utils/parseJSONata/utils.ts","../src/utils/parseJSONata/parseJSONata.ts"],"sourcesContent":["import type { DefaultCombinatorName, DefaultOperatorName } from '../../types';\nimport type {\n JSONataAnd,\n JSONataBinaryNode,\n JSONataBlock,\n JSONataBoolean,\n JSONataContains,\n JSONataEqual,\n JSONataExprNode,\n JSONataGreaterThan,\n JSONataGreaterThanOrEqual,\n JSONataIdentifier,\n JSONataIn,\n JSONataLessThan,\n JSONataLessThanOrEqual,\n JSONataList,\n JSONataName,\n JSONataNot,\n JSONataNotEqual,\n JSONataNull,\n JSONataNumber,\n JSONataOr,\n JSONataPath,\n JSONataRegex,\n JSONataString,\n JSONataToMillis,\n} from './types';\n\n// oxlint-disable-next-line typescript/no-explicit-any\ntype Any = any;\n\nexport const isJSONataExprNode = (expr: Any): expr is JSONataExprNode => {\n return expr && typeof expr === 'object' && typeof expr.type === 'string';\n};\nconst isJSONataBinaryNode = (expr: Any): expr is JSONataBinaryNode =>\n isJSONataExprNode(expr) && expr.type === 'binary';\n\n// Identifiers\nexport const isJSONataPath = (expr: Any): expr is JSONataPath =>\n isJSONataExprNode(expr) &&\n expr.type === 'path' &&\n Array.isArray(expr.steps) &&\n expr.steps.length > 0 &&\n isJSONataExprNode(expr.steps[0]);\nexport const isJSONataName = (expr: Any): expr is JSONataName =>\n isJSONataExprNode(expr) &&\n expr.type === 'name' &&\n typeof expr.value === 'string' &&\n expr.value.length > 0;\nexport const isJSONataIdentifier = (expr: Any): expr is JSONataIdentifier =>\n isJSONataPath(expr) && expr.steps.every(v => isJSONataName(v));\n\n// Groups\nexport const isJSONataBlock = (expr: Any): expr is JSONataBlock =>\n isJSONataExprNode(expr) &&\n expr.type === 'block' &&\n Array.isArray(expr.expressions) &&\n expr.expressions.length > 0 &&\n isJSONataExprNode(expr.expressions[0]);\n\n// Values\nexport const isJSONataString = (expr: Any): expr is JSONataString =>\n isJSONataExprNode(expr) && expr.type === 'string' && typeof expr.value === 'string';\nexport const isJSONataNumber = (expr: Any): expr is JSONataNumber =>\n isJSONataExprNode(expr) && expr.type === 'number' && typeof expr.value === 'number';\nexport const isJSONataBoolean = (expr: Any): expr is JSONataBoolean =>\n isJSONataExprNode(expr) && expr.type === 'value' && typeof expr.value === 'boolean';\nexport const isJSONataNull = (expr: Any): expr is JSONataNull =>\n isJSONataExprNode(expr) && expr.type === 'value' && expr.value === null;\nexport const isJSONataRegex = (expr: Any): expr is JSONataRegex =>\n isJSONataExprNode(expr) && expr.type === 'regex' && expr.value instanceof RegExp;\n\n// Combinators\nexport const isJSONataAnd = (expr: Any): expr is JSONataAnd =>\n isJSONataBinaryNode(expr) && expr.value === 'and';\nexport const isJSONataOr = (expr: Any): expr is JSONataOr =>\n isJSONataBinaryNode(expr) && expr.value === 'or';\n\n// Operators\nexport const isJSONataEqual = (expr: Any): expr is JSONataEqual =>\n isJSONataBinaryNode(expr) && expr.value === '=';\nexport const isJSONataNotEqual = (expr: Any): expr is JSONataNotEqual =>\n isJSONataBinaryNode(expr) && expr.value === '!=';\nexport const isJSONataGreaterThan = (expr: Any): expr is JSONataGreaterThan =>\n isJSONataBinaryNode(expr) && expr.value === '>';\nexport const isJSONataGreaterThanOrEqual = (expr: Any): expr is JSONataGreaterThanOrEqual =>\n isJSONataBinaryNode(expr) && expr.value === '>=';\nexport const isJSONataLessThan = (expr: Any): expr is JSONataLessThan =>\n isJSONataBinaryNode(expr) && expr.value === '<';\nexport const isJSONataLessThanOrEqual = (expr: Any): expr is JSONataLessThanOrEqual =>\n isJSONataBinaryNode(expr) && expr.value === '<=';\nexport const isJSONataIn = (expr: Any): expr is JSONataIn =>\n isJSONataBinaryNode(expr) &&\n expr.value === 'in' &&\n isJSONataPath(expr.lhs) &&\n isJSONataList(expr.rhs);\n\n// Functions\nexport const isJSONataNot = (expr: Any): expr is JSONataNot =>\n isJSONataExprNode(expr) &&\n expr.type === 'function' &&\n expr.value === '(' &&\n Array.isArray(expr.arguments) &&\n isJSONataExprNode(expr.arguments[0]) &&\n isJSONataExprNode(expr.procedure) &&\n expr.procedure.value === 'not' &&\n expr.procedure.type === 'variable';\nexport const isJSONataContains = (expr: Any): expr is JSONataContains =>\n isJSONataExprNode(expr) &&\n expr.type === 'function' &&\n expr.value === '(' &&\n Array.isArray(expr.arguments) &&\n expr.arguments.length >= 2 &&\n isJSONataExprNode(expr.arguments[0]) &&\n isJSONataExprNode(expr.procedure) &&\n expr.procedure.value === 'contains' &&\n expr.procedure.type === 'variable';\nexport const isJSONataToMillis = (expr: Any): expr is JSONataToMillis =>\n isJSONataExprNode(expr) &&\n expr.type === 'function' &&\n expr.value === '(' &&\n Array.isArray(expr.arguments) &&\n expr.arguments.length > 0 &&\n isJSONataString(expr.arguments[0]) &&\n isJSONataExprNode(expr.procedure) &&\n expr.procedure.value === 'toMillis' &&\n expr.procedure.type === 'variable';\n\n// Miscellaneous\nexport const isJSONataList = (expr: Any): expr is JSONataList =>\n isJSONataExprNode(expr) &&\n expr.type === 'unary' &&\n expr.value === '[' &&\n Array.isArray(expr.expressions);\nexport const isJSONataPrimitive = (expr: Any): boolean => {\n return (\n isJSONataString(expr) ||\n isJSONataNumber(expr) ||\n isJSONataBoolean(expr) ||\n isJSONataNull(expr) ||\n isJSONataToMillis(expr)\n );\n};\nexport const isJSONataPrimitiveList = (expr: Any): boolean =>\n isJSONataList(expr) && expr.expressions.every(v => isJSONataPrimitive(v));\nexport const isJSONataIdentifierList = (expr: Any): boolean =>\n isJSONataList(expr) && expr.expressions.every(v => isJSONataIdentifier(v));\nexport const isJSONataValidValue = (expr: Any): boolean =>\n isJSONataPrimitive(expr) ||\n isJSONataRegex(expr) ||\n isJSONataIdentifier(expr) ||\n isJSONataPrimitiveList(expr) ||\n isJSONataIdentifierList(expr) ||\n isJSONataToMillis(expr);\nexport const isJSONataComparison = (\n expr: Any\n): expr is\n | JSONataEqual\n | JSONataNotEqual\n | JSONataGreaterThan\n | JSONataGreaterThanOrEqual\n | JSONataLessThan\n | JSONataLessThanOrEqual =>\n isJSONataEqual(expr) ||\n isJSONataNotEqual(expr) ||\n isJSONataGreaterThan(expr) ||\n isJSONataGreaterThanOrEqual(expr) ||\n isJSONataLessThan(expr) ||\n isJSONataLessThanOrEqual(expr);\n\n// Arithmetic infix operators eligible as expression operands\nconst jsonataArithmeticOperators = new Set(['+', '-', '*', '/', '%']);\n\n/**\n * A JSONata comparison operand that is a candidate expression subtree: an arithmetic infix node\n * (`+ - * / %`) or a function-call node (excluding the `not`/`contains` predicates handled\n * elsewhere). The expr-supplied `getExpression` handler decides whether it maps to a known\n * function.\n */\nexport const isJSONataExpressionOperand = (expr: Any): expr is JSONataExprNode => {\n if (!isJSONataExprNode(expr)) return false;\n // Unwrap parenthesized single-expression blocks (e.g. `(cost * 2)`)\n if (isJSONataBlock(expr) && expr.expressions.length === 1)\n return isJSONataExpressionOperand(expr.expressions[0]);\n if (isJSONataBinaryNode(expr) && jsonataArithmeticOperators.has(expr.value)) return true;\n return (\n expr.type === 'function' &&\n expr.value === '(' &&\n isJSONataExprNode(expr.procedure) &&\n expr.procedure.type === 'variable' &&\n typeof expr.procedure.value === 'string' &&\n expr.procedure.value !== 'not' &&\n expr.procedure.value !== 'contains'\n );\n};\n\nexport const getValidValue = (expr: Any): Any => {\n if (isJSONataToMillis(expr)) {\n return getValidValue(expr.arguments[0]);\n } else if (isJSONataIdentifier(expr)) {\n return getFieldFromPath(expr);\n } else if (isJSONataPrimitiveList(expr)) {\n return expr.expressions.map((v: Any) => getValidValue(v));\n } else if (isJSONataIdentifierList(expr)) {\n return expr.expressions.map((v: Any) => getFieldFromPath(v));\n }\n return expr.value;\n};\n\nexport const getFieldFromPath = (path: JSONataPath): string =>\n isJSONataIdentifier(path)\n ? path.steps.map(s => s.value).join('.')\n : /* v8 ignore next -- @preserve */ '';\n\nexport const normalizeOperator = (\n opType: DefaultOperatorName,\n flip?: boolean\n): DefaultOperatorName => {\n if (flip) {\n if (opType === '<') return '>';\n if (opType === '<=') return '>=';\n if (opType === '>') return '<';\n if (opType === '>=') return '<=';\n }\n return opType;\n};\n\nexport const negatedLikeOperators: Record<\n Extract<DefaultOperatorName, 'beginsWith' | 'contains' | 'endsWith'>,\n DefaultOperatorName\n> = {\n contains: 'doesNotContain',\n beginsWith: 'doesNotBeginWith',\n endsWith: 'doesNotEndWith',\n} satisfies Record<\n Extract<DefaultOperatorName, 'beginsWith' | 'contains' | 'endsWith'>,\n DefaultOperatorName\n>;\n\nexport const generateFlatAndOrList = (\n expr: JSONataExprNode\n): (DefaultCombinatorName | JSONataExprNode)[] => {\n // v8 ignore else\n if (isJSONataAnd(expr) || isJSONataOr(expr)) {\n const { lhs, rhs, value: combinator } = expr;\n if (isJSONataAnd(lhs) || isJSONataOr(lhs)) {\n return [...generateFlatAndOrList(lhs), combinator, rhs];\n }\n return [lhs, combinator, rhs];\n }\n // v8 ignore next\n return [];\n};\n\nexport const generateMixedAndOrList = (\n expr: JSONataAnd | JSONataOr\n): (JSONataExprNode | DefaultCombinatorName | (JSONataExprNode | 'and')[])[] => {\n const arr = generateFlatAndOrList(expr);\n const returnArray: (DefaultCombinatorName | JSONataExprNode | ('and' | JSONataExprNode)[])[] = [];\n let startIndex = 0;\n for (let i = 0; i < arr.length; i += 2) {\n if (arr[i + 1] === 'and') {\n startIndex = i;\n let j = 1;\n while (arr[startIndex + j] === 'and') {\n i += 2;\n j += 2;\n }\n const tempAndArray = arr.slice(startIndex, i + 1) as ('and' | JSONataExprNode)[];\n returnArray.push(tempAndArray);\n i -= 2;\n } else if (arr[i + 1] === 'or') {\n if (i === 0 || i === arr.length - 3) {\n if (i === 0 || arr[i - 1] === 'or') {\n returnArray.push(arr[i]);\n }\n returnArray.push(arr[i + 1]);\n if (i === arr.length - 3) {\n returnArray.push(arr[i + 2]);\n }\n } else {\n if (arr[i - 1] === 'and') {\n returnArray.push(arr[i + 1]);\n } else {\n returnArray.push(arr[i], arr[i + 1]);\n }\n }\n }\n }\n if (returnArray.length === 1 && Array.isArray(returnArray[0])) {\n // If length is 1, then the only element is an AND array so just return that\n return returnArray[0];\n }\n return returnArray;\n};\n","import jsonata from 'jsonata';\nimport type { Except } from 'type-fest';\nimport type {\n DefaultCombinatorName,\n DefaultOperatorName,\n DefaultRuleGroupArray,\n DefaultRuleGroupICArray,\n DefaultRuleGroupType,\n DefaultRuleGroupTypeAny,\n DefaultRuleGroupTypeIC,\n DefaultRuleType,\n ExpressionNode,\n ValueSource,\n} from '../../types';\nimport type { ParserCommonOptions } from '../../types/import';\nimport { isRuleGroup } from '../isRuleGroup';\nimport { fieldIsValidUtil, getFieldsArray } from '../parserUtils';\nimport { prepareRuleGroup } from '../prepareQueryObjects';\nimport type {\n JSONataExprNode,\n JSONataExpressionOperand,\n ParseJSONataExpressionContext,\n} from './types';\nimport {\n generateFlatAndOrList,\n generateMixedAndOrList,\n getFieldFromPath,\n getValidValue,\n isJSONataAnd,\n isJSONataBlock,\n isJSONataComparison,\n isJSONataContains,\n isJSONataExpressionOperand,\n isJSONataIdentifier,\n isJSONataIdentifierList,\n isJSONataIn,\n isJSONataNot,\n isJSONataOr,\n isJSONataRegex,\n isJSONataString,\n isJSONataValidValue,\n negatedLikeOperators,\n normalizeOperator,\n} from './utils';\n\n/**\n * Options object for {@link parseJSONata}.\n *\n * Note: `listsAsArrays` is ignored by `parseJSONata`; lists are _always_ arrays.\n */\nexport interface ParseJSONataOptions extends ParserCommonOptions {\n /**\n * Handler that converts a JSONata arithmetic/function operand subtree into an\n * {@link ExpressionNode}. Return `null` to reject (the rule is dropped). Supplied by\n * `@react-querybuilder/expr` (`expressionParserJSONata`). When omitted, expression\n * operands are ignored (rule dropped).\n */\n getExpression?: (\n node: JSONataExpressionOperand,\n ctx: ParseJSONataExpressionContext\n ) => ExpressionNode | null;\n}\n\n/**\n * Converts a JSONata string expression into a query suitable for the\n * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props\n * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).\n */\nfunction parseJSONata(jsonataInput: string): DefaultRuleGroupType;\n/**\n * Converts a JSONata string expression into a query suitable for the\n * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props\n * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).\n */\nfunction parseJSONata(\n jsonataInput: string,\n options: Except<ParseJSONataOptions, 'independentCombinators'> & {\n independentCombinators?: false;\n }\n): DefaultRuleGroupType;\n/**\n * Converts a JSONata string expression into a query suitable for the\n * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props\n * ({@link index!DefaultRuleGroupTypeIC DefaultRuleGroupTypeIC}).\n */\nfunction parseJSONata(\n jsonataInput: string,\n options: Except<ParseJSONataOptions, 'independentCombinators'> & {\n independentCombinators: true;\n }\n): DefaultRuleGroupTypeIC;\nfunction parseJSONata(\n jsonataInput: string,\n options: ParseJSONataOptions = {}\n): DefaultRuleGroupTypeAny {\n const { fields, independentCombinators, listsAsArrays: _laa, getExpression } = options;\n const ic = !!independentCombinators;\n const fieldsFlat = getFieldsArray(fields);\n\n const fieldIsValid = (\n fieldName: string,\n operator: DefaultOperatorName,\n subordinateFieldName?: string\n ) =>\n fieldIsValidUtil({\n fieldName,\n fieldsFlat,\n operator,\n subordinateFieldName,\n getValueSources: options?.getValueSources,\n });\n\n const emptyQuery: DefaultRuleGroupTypeAny = {\n rules: [],\n ...(ic ? {} : { combinator: 'and' }),\n };\n\n const exprCtx: ParseJSONataExpressionContext = {\n fieldExists: fieldName => fieldsFlat.length === 0 || fieldsFlat.some(f => f.name === fieldName),\n };\n\n const parseJSONataAST = (\n expr: JSONataExprNode,\n processOpts: {\n groupOnlyIfNecessary?: boolean;\n forwardNegation?: boolean;\n } = {}\n ): DefaultRuleType | DefaultRuleGroupTypeAny | null => {\n const { forwardNegation: _forwardedNegation, groupOnlyIfNecessary: _g } = processOpts;\n if (isJSONataBlock(expr)) {\n if (\n isJSONataAnd(expr.expressions[0]) ||\n isJSONataOr(expr.expressions[0]) ||\n isJSONataBlock(expr.expressions[0])\n ) {\n return parseJSONataAST(expr.expressions[0]);\n }\n const blockOfExpr = parseJSONataAST(expr.expressions[0]);\n // v8 ignore else\n if (blockOfExpr) {\n return ic\n ? ({ rules: [blockOfExpr] } as DefaultRuleGroupTypeIC)\n : ({\n combinator: 'and',\n rules: [blockOfExpr],\n } as DefaultRuleGroupType);\n }\n } else if (isJSONataAnd(expr) || isJSONataOr(expr)) {\n if (ic) {\n const andOrList = generateFlatAndOrList(expr);\n const rules = andOrList.map(v => {\n if (typeof v === 'string') {\n return v;\n }\n return parseJSONataAST(v);\n });\n // Bail out completely if any rules in the list were invalid\n // so as not to return an incorrect and/or sequence\n if (!rules.every(Boolean)) {\n return null;\n }\n\n // Reduce this group to a single between/notBetween rule if possible\n if (\n ((rs: unknown[]): rs is [DefaultRuleType, DefaultCombinatorName, DefaultRuleType] =>\n rs.length === 3 &&\n (rs[1] === 'and' || rs[1] === 'or') &&\n !isRuleGroup(rs[0]) &&\n !isRuleGroup(rs[2]))(rules) &&\n rules[0].field === rules[2].field &&\n (rules[0].valueSource ?? 'value') === (rules[2].valueSource ?? 'value') &&\n ((rules[1] === 'and' &&\n ((rules[0].operator === '>=' && rules[2].operator === '<=') ||\n (rules[0].operator === '<=' && rules[2].operator === '>='))) ||\n (rules[1] === 'or' &&\n ((rules[0].operator === '>' && rules[2].operator === '<') ||\n (rules[0].operator === '<' && rules[2].operator === '>'))))\n ) {\n return {\n field: rules[0].field,\n operator: rules[1] === 'and' ? 'between' : 'notBetween',\n value:\n (rules[1] === 'and' && rules[0].operator === '<=') ||\n (rules[1] === 'or' && rules[0].operator === '>')\n ? [rules[2].value, rules[0].value]\n : [rules[0].value, rules[2].value],\n ...(rules[0].valueSource ? { valueSource: rules[0].valueSource } : null),\n };\n }\n\n return {\n rules: rules as DefaultRuleGroupICArray,\n };\n }\n const andOrList = generateMixedAndOrList(expr);\n const combinator = andOrList[1] as DefaultCombinatorName;\n const filteredList = andOrList\n .filter(v => Array.isArray(v) || (!!v && typeof v !== 'string' && 'type' in v))\n .map(v =>\n Array.isArray(v) ? v.filter(vf => !!v && typeof vf !== 'string' && 'type' in vf) : v\n ) as (JSONataExprNode | JSONataExprNode[])[];\n const rules = filteredList\n .map((exp): DefaultRuleGroupType | DefaultRuleType | null => {\n if (Array.isArray(exp)) {\n return {\n combinator: 'and',\n rules: exp.map(e => parseJSONataAST(e)).filter(Boolean) as DefaultRuleGroupArray,\n };\n }\n return parseJSONataAST(exp) as DefaultRuleType | DefaultRuleGroupType | null;\n })\n .filter(Boolean) as DefaultRuleGroupArray;\n\n // Reduce this group to a single between/notBetween rule if possible\n if (\n ((rs: unknown[]): rs is [DefaultRuleType, DefaultRuleType] =>\n rs.length === 2 && !isRuleGroup(rs[0]) && !isRuleGroup(rs[1]))(rules) &&\n rules[0].field === rules[1].field &&\n (rules[0].valueSource ?? 'value') === (rules[1].valueSource ?? 'value') &&\n ((combinator === 'and' &&\n ((rules[0].operator === '>=' && rules[1].operator === '<=') ||\n (rules[0].operator === '<=' && rules[1].operator === '>='))) ||\n (combinator === 'or' &&\n ((rules[0].operator === '>' && rules[1].operator === '<') ||\n (rules[0].operator === '<' && rules[1].operator === '>'))))\n ) {\n return {\n field: rules[0].field,\n operator: combinator === 'and' ? 'between' : 'notBetween',\n value:\n (combinator === 'and' && rules[0].operator === '<=') ||\n (combinator === 'or' && rules[0].operator === '>')\n ? [rules[1].value, rules[0].value]\n : [rules[0].value, rules[1].value],\n ...(rules[0].valueSource ? { valueSource: rules[0].valueSource } : null),\n };\n }\n\n // v8 ignore else\n if (rules.length > 0) {\n return { combinator, rules };\n }\n } else if (isJSONataNot(expr)) {\n const negatedExpr = parseJSONataAST(expr.arguments[0]);\n // v8 ignore else\n if (negatedExpr) {\n if (\n !isRuleGroup(negatedExpr) &&\n (negatedExpr.operator === 'contains' ||\n negatedExpr.operator === 'beginsWith' ||\n negatedExpr.operator === 'endsWith')\n ) {\n return {\n ...negatedExpr,\n operator: negatedLikeOperators[negatedExpr.operator],\n };\n }\n return ic\n ? ({ rules: [negatedExpr], not: true } as DefaultRuleGroupTypeIC)\n : ({\n combinator: 'and',\n rules: [negatedExpr],\n not: true,\n } as DefaultRuleGroupType);\n }\n } else if (isJSONataContains(expr)) {\n const [arg1, arg2] = expr.arguments;\n let field: string = '';\n let regex: string | RegExp = '';\n let valueSource: ValueSource | undefined = undefined;\n // v8 ignore else\n if (isJSONataIdentifier(arg1)) {\n field = getFieldFromPath(arg1);\n if (isJSONataIdentifier(arg2)) {\n regex = getFieldFromPath(arg2);\n valueSource = 'field';\n } else {\n // v8 ignore else\n if (isJSONataString(arg2) || isJSONataRegex(arg2)) {\n regex = getValidValue(arg2);\n }\n }\n }\n\n // v8 ignore else\n if (\n valueSource === 'field'\n ? fieldIsValid(field, 'contains', regex as string)\n : fieldIsValid(field, 'contains')\n ) {\n return {\n field,\n operator: 'contains',\n value: regex,\n ...(valueSource ? { valueSource } : {}),\n };\n }\n } else if (isJSONataIn(expr)) {\n const field = getFieldFromPath(expr.lhs);\n let valueSource: ValueSource | undefined = undefined;\n if (isJSONataIdentifierList(expr.rhs)) {\n valueSource = 'field';\n }\n if (isJSONataValidValue(expr.rhs)) {\n // oxlint-disable-next-line typescript/no-explicit-any\n const value: any[] = getValidValue(expr.rhs);\n // v8 ignore else\n if (\n field &&\n value.every(v => fieldIsValid(field, 'in', valueSource === 'field' ? v : undefined))\n ) {\n return { field, operator: 'in', value, ...(valueSource ? { valueSource } : {}) };\n }\n }\n } else if (isJSONataComparison(expr)) {\n let field: string | null = null;\n // oxlint-disable-next-line typescript/no-explicit-any\n let value: any = undefined;\n let valueSource: ValueSource | undefined = undefined;\n let flip = false;\n const { lhs, rhs } = expr;\n\n // Arithmetic/function expression operands (from `@react-querybuilder/expr`)\n if (getExpression) {\n const lhsIsExpr = isJSONataExpressionOperand(lhs);\n const rhsIsExpr = isJSONataExpressionOperand(rhs);\n if (lhsIsExpr && rhsIsExpr) {\n // expression <op> expression → both sides on lhs/value\n const l = getExpression(lhs, exprCtx);\n const r = getExpression(rhs, exprCtx);\n if (l && r) {\n return {\n field: '',\n operator: normalizeOperator(expr.value),\n lhs: l,\n value: r,\n valueSource: 'expression',\n };\n }\n return null;\n } else if (isJSONataIdentifier(lhs) && rhsIsExpr) {\n // field <op> expression → rhs expression\n const node = getExpression(rhs, exprCtx);\n const f = getFieldFromPath(lhs);\n const op = normalizeOperator(expr.value);\n if (node && fieldIsValid(f, op)) {\n return { field: f, operator: op, value: node, valueSource: 'expression' };\n }\n return null;\n } else if (lhsIsExpr && isJSONataIdentifier(rhs)) {\n // expression <op> field → flip to field <op> expression\n const node = getExpression(lhs, exprCtx);\n const f = getFieldFromPath(rhs);\n const op = normalizeOperator(expr.value, true);\n if (node && fieldIsValid(f, op)) {\n return { field: f, operator: op, value: node, valueSource: 'expression' };\n }\n return null;\n } else if (lhsIsExpr && isJSONataValidValue(rhs)) {\n // expression <op> literal → lhs = expression, literal value\n const l = getExpression(lhs, exprCtx);\n if (l) {\n return {\n field: '',\n operator: normalizeOperator(expr.value),\n lhs: l,\n value: getValidValue(rhs),\n };\n }\n return null;\n } else if (isJSONataValidValue(lhs) && rhsIsExpr) {\n // literal <op> expression → lhs = expression, flip operator\n const l = getExpression(rhs, exprCtx);\n if (l) {\n return {\n field: '',\n operator: normalizeOperator(expr.value, true),\n lhs: l,\n value: getValidValue(lhs),\n };\n }\n return null;\n }\n }\n\n if (isJSONataIdentifier(lhs) && isJSONataValidValue(rhs)) {\n field = getFieldFromPath(lhs);\n value = getValidValue(rhs);\n if (isJSONataIdentifier(rhs)) {\n valueSource = 'field';\n }\n } else {\n // v8 ignore else\n if (isJSONataIdentifier(rhs) && isJSONataValidValue(lhs)) {\n flip = true;\n field = getFieldFromPath(rhs);\n value = getValidValue(lhs);\n }\n }\n let operator = normalizeOperator(expr.value, flip);\n if (value === null && (operator === '=' || operator === '!=')) {\n operator = operator === '=' ? 'null' : 'notNull';\n }\n if (\n field &&\n fieldIsValid(field, operator, valueSource === 'field' ? value : undefined) &&\n value !== undefined\n ) {\n return valueSource ? { field, operator, value, valueSource } : { field, operator, value };\n }\n }\n return null;\n };\n\n const prepare = options.generateIDs ? prepareRuleGroup : <T>(g: T) => g;\n\n let jsonataExpr: jsonata.Expression;\n try {\n jsonataExpr = jsonata(jsonataInput);\n } catch {\n return prepare(emptyQuery);\n }\n const jsonataAST = jsonataExpr.ast() as JSONataExprNode;\n\n const result = parseJSONataAST(jsonataAST);\n if (result) {\n if (isRuleGroup(result)) {\n return prepare(result);\n }\n return prepare({ rules: [result], ...(ic ? {} : { combinator: 'and' }) });\n }\n\n return prepare(emptyQuery);\n}\n\nexport { parseJSONata };\n"],"mappings":";;;;AA+BA,MAAa,qBAAqB,SAA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,QAAQ;EACV,IAAI,YAAY,MAAM,GACpB,OAAO,QAAQ,MAAM;EAEvB,OAAO,QAAQ;GAAE,OAAO,CAAC,MAAM;GAAG,GAAI,KAAK,CAAC,IAAI,EAAE,YAAY,MAAM;EAAG,CAAC;CAC1E;CAEA,OAAO,QAAQ,UAAU;AAC3B"}
@@ -1,35 +1,68 @@
1
- import { E as DefaultRuleGroupType, O as RuleType, S as RuleGroupTypeAny, f as RQBJsonLogic, j as Except, x as DefaultRuleGroupTypeIC } from "./index-DlVg-QXo.mjs";
2
- import { t as ParserCommonOptions } from "./import-ShTj5IdB.mjs";
3
-
1
+ import { E as RuleGroupTypeAny, L as Except, N as RuleType, P as ExpressionNode, T as DefaultRuleGroupTypeIC, g as RQBJsonLogicVar, h as RQBJsonLogic, j as DefaultRuleGroupType, n as JsonLogicLessThanOrEqual, r as JsonLogicRulesLogic, t as JsonLogicLessThan } from "./index-BSwFvkeI.mjs";
2
+ import { t as ParserCommonOptions } from "./import-BVdxeIBO.mjs";
3
+ //#region src/utils/parseJsonLogic/types.d.ts
4
+ interface JsonLogicBetweenExclusive extends JsonLogicLessThan {
5
+ "<": [JsonLogicRulesLogic, JsonLogicRulesLogic, JsonLogicRulesLogic];
6
+ }
7
+ interface JsonLogicBetweenInclusive extends JsonLogicLessThanOrEqual {
8
+ "<=": [JsonLogicRulesLogic, JsonLogicRulesLogic, JsonLogicRulesLogic];
9
+ }
10
+ /**
11
+ * A JsonLogic operand subtree that {@link ParseJsonLogicOptions.getExpression} may receive —
12
+ * an arithmetic/function operation object, a variable reference, or a literal.
13
+ */
14
+ type JsonLogicExpressionOperand = RQBJsonLogic;
15
+ /** Context passed to {@link ParseJsonLogicOptions.getExpression}. */
16
+ interface ParseJsonLogicExpressionContext {
17
+ /** Returns `true` if the field is configured (or if no `fields` were supplied). */
18
+ fieldExists: (fieldName: string) => boolean;
19
+ }
20
+ //#endregion
4
21
  //#region src/utils/parseJsonLogic/parseJsonLogic.d.ts
5
22
  /**
6
- * Options object for {@link parseJsonLogic}.
7
- */
23
+ * Options object for {@link parseJsonLogic}.
24
+ */
8
25
  interface ParseJsonLogicOptions extends ParserCommonOptions {
9
26
  jsonLogicOperations?: Record<string, (value: any) => RuleType | RuleGroupTypeAny | false>;
27
+ /**
28
+ * Handler that converts a JsonLogic arithmetic/function operation object into an
29
+ * {@link ExpressionNode}. Return `null` to reject (the rule is dropped). Supplied by
30
+ * `@react-querybuilder/expr` (`expressionParserJsonLogic`). When omitted, expression
31
+ * operands are ignored (rule dropped).
32
+ */
33
+ getExpression?: (node: JsonLogicExpressionOperand, ctx: ParseJsonLogicExpressionContext) => ExpressionNode | null;
10
34
  }
11
35
  /**
12
- * Converts a JsonLogic object into a query suitable for the
13
- * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
14
- * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
15
- */
36
+ * Converts a JsonLogic object into a query suitable for the
37
+ * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
38
+ * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
39
+ */
16
40
  declare function parseJsonLogic(rqbJsonLogic: string | RQBJsonLogic): DefaultRuleGroupType;
17
41
  /**
18
- * Converts a JsonLogic object into a query suitable for the
19
- * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
20
- * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
21
- */
42
+ * Converts a JsonLogic object into a query suitable for the
43
+ * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
44
+ * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
45
+ */
22
46
  declare function parseJsonLogic(rqbJsonLogic: string | RQBJsonLogic, options: Except<ParseJsonLogicOptions, "independentCombinators"> & {
23
47
  independentCombinators?: false;
24
48
  }): DefaultRuleGroupType;
25
49
  /**
26
- * Converts a JsonLogic object into a query suitable for the
27
- * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
28
- * ({@link index!DefaultRuleGroupTypeIC DefaultRuleGroupTypeIC}).
29
- */
50
+ * Converts a JsonLogic object into a query suitable for the
51
+ * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
52
+ * ({@link index!DefaultRuleGroupTypeIC DefaultRuleGroupTypeIC}).
53
+ */
30
54
  declare function parseJsonLogic(rqbJsonLogic: string | RQBJsonLogic, options: Except<ParseJsonLogicOptions, "independentCombinators"> & {
31
55
  independentCombinators: true;
32
56
  }): DefaultRuleGroupTypeIC;
33
57
  //#endregion
34
- export { ParseJsonLogicOptions, parseJsonLogic };
58
+ //#region src/utils/parseJsonLogic/utils.d.ts
59
+ declare const isRQBJsonLogicVar: (logic: unknown) => logic is RQBJsonLogicVar;
60
+ /**
61
+ * A JsonLogic comparison operand that is a candidate expression subtree: a plain object that
62
+ * is not a variable reference (i.e. an arithmetic/function operation object). The
63
+ * expr-supplied `getExpression` handler decides whether it maps to a known function.
64
+ */
65
+ declare const isJsonLogicExpressionOperand: (logic: unknown) => logic is JsonLogicExpressionOperand;
66
+ //#endregion
67
+ export { JsonLogicBetweenExclusive, JsonLogicBetweenInclusive, JsonLogicExpressionOperand, ParseJsonLogicExpressionContext, ParseJsonLogicOptions, isJsonLogicExpressionOperand, isRQBJsonLogicVar, parseJsonLogic };
35
68
  //# sourceMappingURL=parseJsonLogic.d.mts.map
@@ -1,35 +1,68 @@
1
- import { E as DefaultRuleGroupType, O as RuleType, S as RuleGroupTypeAny, f as RQBJsonLogic, j as Except, x as DefaultRuleGroupTypeIC } from "./index-DlVg-QXo.js";
2
- import { t as ParserCommonOptions } from "./import-Qs1-kgv5.js";
3
-
1
+ import { E as RuleGroupTypeAny, L as Except, N as RuleType, P as ExpressionNode, T as DefaultRuleGroupTypeIC, g as RQBJsonLogicVar, h as RQBJsonLogic, j as DefaultRuleGroupType, n as JsonLogicLessThanOrEqual, r as JsonLogicRulesLogic, t as JsonLogicLessThan } from "./index-BSwFvkeI.js";
2
+ import { t as ParserCommonOptions } from "./import-Ddc3d_8q.js";
3
+ //#region src/utils/parseJsonLogic/types.d.ts
4
+ interface JsonLogicBetweenExclusive extends JsonLogicLessThan {
5
+ "<": [JsonLogicRulesLogic, JsonLogicRulesLogic, JsonLogicRulesLogic];
6
+ }
7
+ interface JsonLogicBetweenInclusive extends JsonLogicLessThanOrEqual {
8
+ "<=": [JsonLogicRulesLogic, JsonLogicRulesLogic, JsonLogicRulesLogic];
9
+ }
10
+ /**
11
+ * A JsonLogic operand subtree that {@link ParseJsonLogicOptions.getExpression} may receive —
12
+ * an arithmetic/function operation object, a variable reference, or a literal.
13
+ */
14
+ type JsonLogicExpressionOperand = RQBJsonLogic;
15
+ /** Context passed to {@link ParseJsonLogicOptions.getExpression}. */
16
+ interface ParseJsonLogicExpressionContext {
17
+ /** Returns `true` if the field is configured (or if no `fields` were supplied). */
18
+ fieldExists: (fieldName: string) => boolean;
19
+ }
20
+ //#endregion
4
21
  //#region src/utils/parseJsonLogic/parseJsonLogic.d.ts
5
22
  /**
6
- * Options object for {@link parseJsonLogic}.
7
- */
23
+ * Options object for {@link parseJsonLogic}.
24
+ */
8
25
  interface ParseJsonLogicOptions extends ParserCommonOptions {
9
26
  jsonLogicOperations?: Record<string, (value: any) => RuleType | RuleGroupTypeAny | false>;
27
+ /**
28
+ * Handler that converts a JsonLogic arithmetic/function operation object into an
29
+ * {@link ExpressionNode}. Return `null` to reject (the rule is dropped). Supplied by
30
+ * `@react-querybuilder/expr` (`expressionParserJsonLogic`). When omitted, expression
31
+ * operands are ignored (rule dropped).
32
+ */
33
+ getExpression?: (node: JsonLogicExpressionOperand, ctx: ParseJsonLogicExpressionContext) => ExpressionNode | null;
10
34
  }
11
35
  /**
12
- * Converts a JsonLogic object into a query suitable for the
13
- * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
14
- * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
15
- */
36
+ * Converts a JsonLogic object into a query suitable for the
37
+ * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
38
+ * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
39
+ */
16
40
  declare function parseJsonLogic(rqbJsonLogic: string | RQBJsonLogic): DefaultRuleGroupType;
17
41
  /**
18
- * Converts a JsonLogic object into a query suitable for the
19
- * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
20
- * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
21
- */
42
+ * Converts a JsonLogic object into a query suitable for the
43
+ * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
44
+ * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
45
+ */
22
46
  declare function parseJsonLogic(rqbJsonLogic: string | RQBJsonLogic, options: Except<ParseJsonLogicOptions, "independentCombinators"> & {
23
47
  independentCombinators?: false;
24
48
  }): DefaultRuleGroupType;
25
49
  /**
26
- * Converts a JsonLogic object into a query suitable for the
27
- * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
28
- * ({@link index!DefaultRuleGroupTypeIC DefaultRuleGroupTypeIC}).
29
- */
50
+ * Converts a JsonLogic object into a query suitable for the
51
+ * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
52
+ * ({@link index!DefaultRuleGroupTypeIC DefaultRuleGroupTypeIC}).
53
+ */
30
54
  declare function parseJsonLogic(rqbJsonLogic: string | RQBJsonLogic, options: Except<ParseJsonLogicOptions, "independentCombinators"> & {
31
55
  independentCombinators: true;
32
56
  }): DefaultRuleGroupTypeIC;
33
57
  //#endregion
34
- export { ParseJsonLogicOptions, parseJsonLogic };
58
+ //#region src/utils/parseJsonLogic/utils.d.ts
59
+ declare const isRQBJsonLogicVar: (logic: unknown) => logic is RQBJsonLogicVar;
60
+ /**
61
+ * A JsonLogic comparison operand that is a candidate expression subtree: a plain object that
62
+ * is not a variable reference (i.e. an arithmetic/function operation object). The
63
+ * expr-supplied `getExpression` handler decides whether it maps to a known function.
64
+ */
65
+ declare const isJsonLogicExpressionOperand: (logic: unknown) => logic is JsonLogicExpressionOperand;
66
+ //#endregion
67
+ export { JsonLogicBetweenExclusive, JsonLogicBetweenInclusive, JsonLogicExpressionOperand, ParseJsonLogicExpressionContext, ParseJsonLogicOptions, isJsonLogicExpressionOperand, isRQBJsonLogicVar, parseJsonLogic };
35
68
  //# sourceMappingURL=parseJsonLogic.d.ts.map
@@ -1,32 +1,39 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_utils = require("./utils-BpaOtylk.js");
3
- const require_objectUtils = require("./objectUtils-DBJI82bl.js");
4
- const require_convertQuery = require("./convertQuery-BJKNgecE.js");
5
- const require_prepareQueryObjects = require("./prepareQueryObjects-Bni5VgYM.js");
2
+ const require_utils = require("./utils-DEwV7F6B.js");
3
+ const require_isRuleGroup = require("./isRuleGroup-0JNiQgLg.js");
4
+ const require_objectUtils = require("./objectUtils-Cr02aGxb.js");
5
+ const require_convertQuery = require("./convertQuery-Cw76XFIn.js");
6
+ const require_prepareQueryObjects = require("./prepareQueryObjects-C2-kTZvR.js");
6
7
  //#region src/utils/parseJsonLogic/utils.ts
7
- const isJsonLogicVar = (logic) => require_objectUtils.isPojo(logic) && "var" in logic;
8
+ const isJsonLogicVar = (logic) => require_isRuleGroup.isPojo(logic) && "var" in logic;
8
9
  const isRQBJsonLogicVar = (logic) => isJsonLogicVar(logic) && typeof logic.var === "string";
9
- const isJsonLogicEqual = (logic) => require_objectUtils.isPojo(logic) && "==" in logic;
10
- const isJsonLogicStrictEqual = (logic) => require_objectUtils.isPojo(logic) && "===" in logic;
11
- const isJsonLogicNotEqual = (logic) => require_objectUtils.isPojo(logic) && "!=" in logic;
12
- const isJsonLogicStrictNotEqual = (logic) => require_objectUtils.isPojo(logic) && "!==" in logic;
13
- const isJsonLogicNegation = (logic) => require_objectUtils.isPojo(logic) && "!" in logic;
14
- const isJsonLogicDoubleNegation = (logic) => require_objectUtils.isPojo(logic) && "!!" in logic;
15
- const isJsonLogicOr = (logic) => require_objectUtils.isPojo(logic) && "or" in logic;
16
- const isJsonLogicAnd = (logic) => require_objectUtils.isPojo(logic) && "and" in logic;
17
- const isJsonLogicGreaterThan = (logic) => require_objectUtils.isPojo(logic) && ">" in logic;
18
- const isJsonLogicGreaterThanOrEqual = (logic) => require_objectUtils.isPojo(logic) && ">=" in logic;
19
- const isJsonLogicLessThan = (logic) => require_objectUtils.isPojo(logic) && "<" in logic && logic["<"].length === 2;
20
- const isJsonLogicLessThanOrEqual = (logic) => require_objectUtils.isPojo(logic) && "<=" in logic && logic["<="].length === 2;
21
- const isJsonLogicInArray = (logic) => require_objectUtils.isPojo(logic) && "in" in logic && Array.isArray(logic.in[1]);
22
- const isJsonLogicInString = (logic) => require_objectUtils.isPojo(logic) && "in" in logic && !Array.isArray(logic.in[1]);
23
- const isJsonLogicAll = (logic) => require_objectUtils.isPojo(logic) && "all" in logic;
24
- const isJsonLogicNone = (logic) => require_objectUtils.isPojo(logic) && "none" in logic;
25
- const isJsonLogicSome = (logic) => require_objectUtils.isPojo(logic) && "some" in logic;
26
- const isJsonLogicBetweenExclusive = (logic) => require_objectUtils.isPojo(logic) && "<" in logic && Array.isArray(logic["<"]) && logic["<"].length === 3;
27
- const isJsonLogicBetweenInclusive = (logic) => require_objectUtils.isPojo(logic) && "<=" in logic && Array.isArray(logic["<="]) && logic["<="].length === 3;
28
- const isRQBJsonLogicStartsWith = (logic) => require_objectUtils.isPojo(logic) && "startsWith" in logic;
29
- const isRQBJsonLogicEndsWith = (logic) => require_objectUtils.isPojo(logic) && "endsWith" in logic;
10
+ const isJsonLogicEqual = (logic) => require_isRuleGroup.isPojo(logic) && "==" in logic;
11
+ const isJsonLogicStrictEqual = (logic) => require_isRuleGroup.isPojo(logic) && "===" in logic;
12
+ const isJsonLogicNotEqual = (logic) => require_isRuleGroup.isPojo(logic) && "!=" in logic;
13
+ const isJsonLogicStrictNotEqual = (logic) => require_isRuleGroup.isPojo(logic) && "!==" in logic;
14
+ const isJsonLogicNegation = (logic) => require_isRuleGroup.isPojo(logic) && "!" in logic;
15
+ const isJsonLogicDoubleNegation = (logic) => require_isRuleGroup.isPojo(logic) && "!!" in logic;
16
+ const isJsonLogicOr = (logic) => require_isRuleGroup.isPojo(logic) && "or" in logic;
17
+ const isJsonLogicAnd = (logic) => require_isRuleGroup.isPojo(logic) && "and" in logic;
18
+ const isJsonLogicGreaterThan = (logic) => require_isRuleGroup.isPojo(logic) && ">" in logic;
19
+ const isJsonLogicGreaterThanOrEqual = (logic) => require_isRuleGroup.isPojo(logic) && ">=" in logic;
20
+ const isJsonLogicLessThan = (logic) => require_isRuleGroup.isPojo(logic) && "<" in logic && logic["<"].length === 2;
21
+ const isJsonLogicLessThanOrEqual = (logic) => require_isRuleGroup.isPojo(logic) && "<=" in logic && logic["<="].length === 2;
22
+ const isJsonLogicInArray = (logic) => require_isRuleGroup.isPojo(logic) && "in" in logic && Array.isArray(logic.in[1]);
23
+ const isJsonLogicInString = (logic) => require_isRuleGroup.isPojo(logic) && "in" in logic && !Array.isArray(logic.in[1]);
24
+ const isJsonLogicAll = (logic) => require_isRuleGroup.isPojo(logic) && "all" in logic;
25
+ const isJsonLogicNone = (logic) => require_isRuleGroup.isPojo(logic) && "none" in logic;
26
+ const isJsonLogicSome = (logic) => require_isRuleGroup.isPojo(logic) && "some" in logic;
27
+ const isJsonLogicBetweenExclusive = (logic) => require_isRuleGroup.isPojo(logic) && "<" in logic && Array.isArray(logic["<"]) && logic["<"].length === 3;
28
+ const isJsonLogicBetweenInclusive = (logic) => require_isRuleGroup.isPojo(logic) && "<=" in logic && Array.isArray(logic["<="]) && logic["<="].length === 3;
29
+ const isRQBJsonLogicStartsWith = (logic) => require_isRuleGroup.isPojo(logic) && "startsWith" in logic;
30
+ const isRQBJsonLogicEndsWith = (logic) => require_isRuleGroup.isPojo(logic) && "endsWith" in logic;
31
+ /**
32
+ * A JsonLogic comparison operand that is a candidate expression subtree: a plain object that
33
+ * is not a variable reference (i.e. an arithmetic/function operation object). The
34
+ * expr-supplied `getExpression` handler decides whether it maps to a known function.
35
+ */
36
+ const isJsonLogicExpressionOperand = (logic) => require_isRuleGroup.isPojo(logic) && !isRQBJsonLogicVar(logic);
30
37
  //#endregion
31
38
  //#region src/utils/parseJsonLogic/parseJsonLogic.ts
32
39
  const emptyRuleGroup = {
@@ -35,7 +42,7 @@ const emptyRuleGroup = {
35
42
  };
36
43
  function parseJsonLogic(rqbJsonLogic, options = {}) {
37
44
  const fieldsFlat = require_prepareQueryObjects.getFieldsArray(options.fields);
38
- const { getValueSources, listsAsArrays, jsonLogicOperations } = options;
45
+ const { getValueSources, listsAsArrays, jsonLogicOperations, getExpression } = options;
39
46
  const fieldIsValid = (fieldName, operator, subordinateFieldName) => require_prepareQueryObjects.fieldIsValidUtil({
40
47
  fieldName,
41
48
  fieldsFlat,
@@ -43,12 +50,13 @@ function parseJsonLogic(rqbJsonLogic, options = {}) {
43
50
  subordinateFieldName,
44
51
  getValueSources
45
52
  });
53
+ const exprCtx = { fieldExists: (fieldName) => fieldsFlat.length === 0 || fieldsFlat.some((f) => f.name === fieldName) };
46
54
  function processLogic(logic, outermost, inSubquery) {
47
- if (outermost && !require_objectUtils.isPojo(logic)) return false;
55
+ if (outermost && !require_isRuleGroup.isPojo(logic)) return false;
48
56
  const [key, keyValue] = Object.entries(logic || {})?.[0] ?? [];
49
57
  if (jsonLogicOperations && require_objectUtils.objectKeys(jsonLogicOperations).includes(key)) {
50
58
  const rule = jsonLogicOperations[key](keyValue);
51
- return rule ? outermost && !require_objectUtils.isRuleGroup(rule) ? {
59
+ return rule ? outermost && !require_isRuleGroup.isRuleGroup(rule) ? {
52
60
  combinator: "and",
53
61
  rules: [rule]
54
62
  } : rule : false;
@@ -64,7 +72,7 @@ function parseJsonLogic(rqbJsonLogic, options = {}) {
64
72
  else if (isJsonLogicNegation(logic)) {
65
73
  const rule = processLogic(logic["!"], false, inSubquery);
66
74
  if (rule) {
67
- if (!require_objectUtils.isRuleGroupType(rule) && (rule.operator === "between" || rule.operator === "in" || rule.operator === "contains" || rule.operator === "beginsWith" || rule.operator === "endsWith")) {
75
+ if (!require_isRuleGroup.isRuleGroupType(rule) && (rule.operator === "between" || rule.operator === "in" || rule.operator === "contains" || rule.operator === "beginsWith" || rule.operator === "endsWith")) {
68
76
  const newRule = {
69
77
  ...rule,
70
78
  operator: require_utils.defaultOperatorNegationMap[rule.operator]
@@ -74,7 +82,7 @@ function parseJsonLogic(rqbJsonLogic, options = {}) {
74
82
  rules: [newRule]
75
83
  };
76
84
  return newRule;
77
- } else if (isJsonLogicBetweenExclusive(logic["!"]) || require_objectUtils.isRuleGroupType(rule)) return {
85
+ } else if (isJsonLogicBetweenExclusive(logic["!"]) || require_isRuleGroup.isRuleGroupType(rule)) return {
78
86
  ...rule,
79
87
  not: true
80
88
  };
@@ -93,10 +101,47 @@ function parseJsonLogic(rqbJsonLogic, options = {}) {
93
101
  let valueSource = void 0;
94
102
  if (isJsonLogicEqual(logic) || isJsonLogicStrictEqual(logic) || isJsonLogicNotEqual(logic) || isJsonLogicStrictNotEqual(logic) || isJsonLogicGreaterThan(logic) || isJsonLogicGreaterThanOrEqual(logic) || isJsonLogicLessThan(logic) || isJsonLogicLessThanOrEqual(logic) || isJsonLogicInString(logic) || isRQBJsonLogicStartsWith(logic) || isRQBJsonLogicEndsWith(logic)) {
95
103
  const [first, second] = keyValue;
96
- if (isRQBJsonLogicVar(first) && !require_objectUtils.isPojo(second)) {
104
+ const scalarComparison = isJsonLogicEqual(logic) || isJsonLogicStrictEqual(logic) || isJsonLogicNotEqual(logic) || isJsonLogicStrictNotEqual(logic) || isJsonLogicGreaterThan(logic) || isJsonLogicGreaterThanOrEqual(logic) || isJsonLogicLessThan(logic) || isJsonLogicLessThanOrEqual(logic);
105
+ const firstIsExpr = isJsonLogicExpressionOperand(first);
106
+ const secondIsExpr = isJsonLogicExpressionOperand(second);
107
+ if (getExpression && scalarComparison && (firstIsExpr || secondIsExpr)) {
108
+ const exprOperator = isJsonLogicEqual(logic) || isJsonLogicStrictEqual(logic) ? "=" : isJsonLogicNotEqual(logic) || isJsonLogicStrictNotEqual(logic) ? "!=" : key;
109
+ if (firstIsExpr && secondIsExpr) {
110
+ const lhs = getExpression(first, exprCtx);
111
+ const rhs = getExpression(second, exprCtx);
112
+ if (lhs && rhs) rule = {
113
+ field: "",
114
+ operator: exprOperator,
115
+ lhs,
116
+ value: rhs,
117
+ valueSource: "expression"
118
+ };
119
+ } else if (firstIsExpr && !require_isRuleGroup.isPojo(second)) {
120
+ const lhs = getExpression(first, exprCtx);
121
+ if (lhs) rule = {
122
+ field: "",
123
+ operator: exprOperator,
124
+ lhs,
125
+ value: second
126
+ };
127
+ } else if (isRQBJsonLogicVar(first) && secondIsExpr) {
128
+ const node = getExpression(second, exprCtx);
129
+ if (node && (inSubquery || fieldIsValid(first.var, exprOperator))) rule = {
130
+ field: first.var,
131
+ operator: exprOperator,
132
+ value: node,
133
+ valueSource: "expression"
134
+ };
135
+ }
136
+ return rule ? outermost ? {
137
+ combinator: "and",
138
+ rules: [rule]
139
+ } : rule : false;
140
+ }
141
+ if (isRQBJsonLogicVar(first) && !require_isRuleGroup.isPojo(second)) {
97
142
  field = first.var;
98
143
  value = second;
99
- } else if (!require_objectUtils.isPojo(first) && isRQBJsonLogicVar(second)) {
144
+ } else if (!require_isRuleGroup.isPojo(first) && isRQBJsonLogicVar(second)) {
100
145
  field = second.var;
101
146
  value = first;
102
147
  } else if (isRQBJsonLogicVar(first) && isRQBJsonLogicVar(second)) {
@@ -125,7 +170,7 @@ function parseJsonLogic(rqbJsonLogic, options = {}) {
125
170
  field: fld,
126
171
  operator: "=",
127
172
  match,
128
- value: require_objectUtils.isRuleGroup(matcher) ? matcher : {
173
+ value: require_isRuleGroup.isRuleGroup(matcher) ? matcher : {
129
174
  combinator: "and",
130
175
  rules: [matcher]
131
176
  }
@@ -139,6 +184,20 @@ function parseJsonLogic(rqbJsonLogic, options = {}) {
139
184
  field = logic["<="][1].var;
140
185
  operator = "between";
141
186
  const values = [logic["<="][0], logic["<="][2]];
187
+ if (getExpression && (isJsonLogicExpressionOperand(values[0]) || isJsonLogicExpressionOperand(values[1]))) {
188
+ const from = getExpression(values[0], exprCtx);
189
+ const to = getExpression(values[1], exprCtx);
190
+ if (from && to && fieldIsValid(field, operator)) rule = {
191
+ field,
192
+ operator,
193
+ value: [from, to],
194
+ valueSource: "expression"
195
+ };
196
+ return rule ? outermost ? {
197
+ combinator: "and",
198
+ rules: [rule]
199
+ } : rule : false;
200
+ }
142
201
  if (logic["<="].every((v) => isRQBJsonLogicVar(v))) {
143
202
  const vars = values;
144
203
  valueSource = "field";
@@ -183,6 +242,8 @@ function parseJsonLogic(rqbJsonLogic, options = {}) {
183
242
  return prepare(options.independentCombinators ? require_convertQuery.convertToIC(finalQuery) : finalQuery);
184
243
  }
185
244
  //#endregion
245
+ exports.isJsonLogicExpressionOperand = isJsonLogicExpressionOperand;
246
+ exports.isRQBJsonLogicVar = isRQBJsonLogicVar;
186
247
  exports.parseJsonLogic = parseJsonLogic;
187
248
 
188
249
  //# sourceMappingURL=parseJsonLogic.js.map