@react-querybuilder/core 8.22.5 → 8.23.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.
- package/derivations/package.json +4 -0
- package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +2078 -1665
- package/dist/cjs/react-querybuilder_core.cjs.development.js +1293 -422
- package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +2078 -1665
- package/dist/cjs/react-querybuilder_core.cjs.production.js +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.js.map +1 -1
- package/dist/{convertQuery-Cw76XFIn.js → convertQuery-BLT0GIhM.js} +17 -8
- package/dist/{convertQuery-Cw76XFIn.js.map → convertQuery-BLT0GIhM.js.map} +1 -1
- package/dist/{convertQuery-D_4J7E-Z.mjs → convertQuery-DaXv3h7S.mjs} +6 -3
- package/dist/{convertQuery-D_4J7E-Z.mjs.map → convertQuery-DaXv3h7S.mjs.map} +1 -1
- package/dist/derivations.d.mts +2902 -0
- package/dist/derivations.d.ts +2902 -0
- package/dist/derivations.js +2845 -0
- package/dist/derivations.js.map +1 -0
- package/dist/derivations.mjs +2678 -0
- package/dist/derivations.mjs.map +1 -0
- package/dist/formatQuery.d.mts +2 -895
- package/dist/formatQuery.d.ts +2 -895
- package/dist/formatQuery.js +120 -140
- package/dist/formatQuery.js.map +1 -1
- package/dist/formatQuery.mjs +8 -28
- package/dist/formatQuery.mjs.map +1 -1
- package/dist/{import-DVWI7Fdh.d.mts → import-BdKPtLzo.d.mts} +2 -2
- package/dist/{import-6ExjhifL.d.ts → import-BfZTwhp2.d.ts} +2 -2
- package/dist/{index-CX9mehdL.d.mts → index-DOIE2pwx.d.mts} +274 -3
- package/dist/{index-CX9mehdL.d.ts → index-DOIE2pwx.d.ts} +274 -3
- package/dist/index-OF2Q1gTp.d.mts +895 -0
- package/dist/index-XueTy_XQ.d.ts +895 -0
- package/dist/isRuleOrGroupValid-CIMZNkt4.mjs +27 -0
- package/dist/isRuleOrGroupValid-CIMZNkt4.mjs.map +1 -0
- package/dist/isRuleOrGroupValid-CtUf4_4x.js +38 -0
- package/dist/isRuleOrGroupValid-CtUf4_4x.js.map +1 -0
- package/dist/{isRuleGroup-CqLThsbu.mjs → objectUtils-DDZ-KhV5.mjs} +25 -2
- package/dist/objectUtils-DDZ-KhV5.mjs.map +1 -0
- package/dist/{isRuleGroup-0JNiQgLg.js → objectUtils-DfnEmDSV.js} +48 -1
- package/dist/objectUtils-DfnEmDSV.js.map +1 -0
- package/dist/parseCEL.d.mts +2 -2
- package/dist/parseCEL.d.ts +2 -2
- package/dist/parseCEL.js +19 -16
- package/dist/parseCEL.js.map +1 -1
- package/dist/parseCEL.mjs +12 -9
- package/dist/parseCEL.mjs.map +1 -1
- package/dist/parseCypher.d.mts +1 -1
- package/dist/parseCypher.d.ts +1 -1
- package/dist/parseGremlin.d.mts +1 -1
- package/dist/parseGremlin.d.ts +1 -1
- package/dist/parseJSONata.d.mts +2 -2
- package/dist/parseJSONata.d.ts +2 -2
- package/dist/parseJSONata.js +17 -14
- package/dist/parseJSONata.js.map +1 -1
- package/dist/parseJSONata.mjs +11 -8
- package/dist/parseJSONata.mjs.map +1 -1
- package/dist/parseJsonLogic.d.mts +2 -2
- package/dist/parseJsonLogic.d.ts +2 -2
- package/dist/parseJsonLogic.js +38 -38
- package/dist/parseJsonLogic.js.map +1 -1
- package/dist/parseJsonLogic.mjs +5 -5
- package/dist/parseMongoDB.d.mts +2 -2
- package/dist/parseMongoDB.d.ts +2 -2
- package/dist/parseMongoDB.js +50 -47
- package/dist/parseMongoDB.js.map +1 -1
- package/dist/parseMongoDB.mjs +35 -32
- package/dist/parseMongoDB.mjs.map +1 -1
- package/dist/parseSPARQL.d.mts +1 -1
- package/dist/parseSPARQL.d.ts +1 -1
- package/dist/parseSQL.d.mts +2 -2
- package/dist/parseSQL.d.ts +2 -2
- package/dist/parseSQL.js +27 -23
- package/dist/parseSQL.js.map +1 -1
- package/dist/parseSQL.mjs +21 -17
- package/dist/parseSQL.mjs.map +1 -1
- package/dist/parseSpEL.d.mts +2 -2
- package/dist/parseSpEL.d.ts +2 -2
- package/dist/parseSpEL.js +17 -14
- package/dist/parseSpEL.js.map +1 -1
- package/dist/parseSpEL.mjs +13 -10
- package/dist/parseSpEL.mjs.map +1 -1
- package/dist/parserUtils-BKPstAaO.mjs +30 -0
- package/dist/parserUtils-BKPstAaO.mjs.map +1 -0
- package/dist/parserUtils-DbBXyAht.js +41 -0
- package/dist/parserUtils-DbBXyAht.js.map +1 -0
- package/dist/{prepareQueryObjects-BnGL91Tt.js → prepareQueryObjects-Dj9cTl9D.js} +90 -63
- package/dist/prepareQueryObjects-Dj9cTl9D.js.map +1 -0
- package/dist/{prepareQueryObjects-ChINDIap.mjs → prepareQueryObjects-Dmyf3Wi_.mjs} +56 -59
- package/dist/prepareQueryObjects-Dmyf3Wi_.mjs.map +1 -0
- package/dist/react-querybuilder_core.d.mts +2078 -1665
- package/dist/react-querybuilder_core.legacy-esm.d.ts +2078 -1665
- package/dist/react-querybuilder_core.legacy-esm.js +1445 -635
- package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
- package/dist/react-querybuilder_core.mjs +1288 -424
- package/dist/react-querybuilder_core.mjs.map +1 -1
- package/dist/react-querybuilder_core.production.d.mts +2078 -1665
- package/dist/react-querybuilder_core.production.mjs +1 -1
- package/dist/react-querybuilder_core.production.mjs.map +1 -1
- package/dist/transformQuery-B7d9AWUf.d.mts +116 -0
- package/dist/transformQuery-BXDiUBGB.d.ts +116 -0
- package/dist/transformQuery.d.mts +2 -116
- package/dist/transformQuery.d.ts +2 -116
- package/dist/transformQuery.js +3 -4
- package/dist/transformQuery.js.map +1 -1
- package/dist/transformQuery.mjs +1 -2
- package/dist/transformQuery.mjs.map +1 -1
- package/dist/utils-CP5Jqy1P.mjs +1294 -0
- package/dist/utils-CP5Jqy1P.mjs.map +1 -0
- package/dist/utils-e-7KHkjV.js +1779 -0
- package/dist/utils-e-7KHkjV.js.map +1 -0
- package/package.json +33 -22
- package/dist/isRuleGroup-0JNiQgLg.js.map +0 -1
- package/dist/isRuleGroup-CqLThsbu.mjs.map +0 -1
- package/dist/objectUtils-Cr02aGxb.js +0 -27
- package/dist/objectUtils-Cr02aGxb.js.map +0 -1
- package/dist/objectUtils-DBlmJgBf.mjs +0 -16
- package/dist/objectUtils-DBlmJgBf.mjs.map +0 -1
- package/dist/prepareQueryObjects-BnGL91Tt.js.map +0 -1
- package/dist/prepareQueryObjects-ChINDIap.mjs.map +0 -1
- package/dist/utils-4k-j5FBa.mjs +0 -537
- package/dist/utils-4k-j5FBa.mjs.map +0 -1
- package/dist/utils-C79dxwZb.js +0 -752
- package/dist/utils-C79dxwZb.js.map +0 -1
package/dist/parseSpEL.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as ParserCommonOptions } from "./import-
|
|
1
|
+
import { $t as DefaultRuleGroupType, Jt as DefaultCombinatorName, Pt as DefaultRuleGroupTypeIC, Zt as DefaultOperatorName, jn as Except, on as ExpressionNode } from "./index-DOIE2pwx.mjs";
|
|
2
|
+
import { t as ParserCommonOptions } from "./import-BdKPtLzo.mjs";
|
|
3
3
|
//#region src/utils/parseSpEL/types.d.ts
|
|
4
4
|
type SpELNodeType = "invalid" | SpELOperationType | SpELPrimitiveType | SpELRelOp | SpELIdentifierType | "assign" | "beanref" | "constructorref" | "elvis" | "function" | "identifier" | "indexer" | "list" | "map" | "method" | "between" | "instanceof" | "matches" | "projection" | "qualifiedidentifier" | "selection" | "ternary" | "typeref";
|
|
5
5
|
type SpELOperationType = "op-and" | "op-dec" | "op-divide" | "op-eq" | "op-ge" | "op-gt" | "op-inc" | "op-le" | "op-lt" | "op-minus" | "op-modulus" | "op-multiply" | "op-ne" | "op-not" | "op-or" | "op-plus" | "op-power";
|
package/dist/parseSpEL.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as ParserCommonOptions } from "./import-
|
|
1
|
+
import { $t as DefaultRuleGroupType, Jt as DefaultCombinatorName, Pt as DefaultRuleGroupTypeIC, Zt as DefaultOperatorName, jn as Except, on as ExpressionNode } from "./index-DOIE2pwx.js";
|
|
2
|
+
import { t as ParserCommonOptions } from "./import-BfZTwhp2.js";
|
|
3
3
|
//#region src/utils/parseSpEL/types.d.ts
|
|
4
4
|
type SpELNodeType = "invalid" | SpELOperationType | SpELPrimitiveType | SpELRelOp | SpELIdentifierType | "assign" | "beanref" | "constructorref" | "elvis" | "function" | "identifier" | "indexer" | "list" | "map" | "method" | "between" | "instanceof" | "matches" | "projection" | "qualifiedidentifier" | "selection" | "ternary" | "typeref";
|
|
5
5
|
type SpELOperationType = "op-and" | "op-dec" | "op-divide" | "op-eq" | "op-ge" | "op-gt" | "op-inc" | "op-le" | "op-lt" | "op-minus" | "op-modulus" | "op-multiply" | "op-ne" | "op-not" | "op-or" | "op-plus" | "op-power";
|
package/dist/parseSpEL.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_utils = require("./utils-
|
|
3
|
-
const
|
|
4
|
-
const require_prepareQueryObjects = require("./prepareQueryObjects-
|
|
2
|
+
const require_utils = require("./utils-e-7KHkjV.js");
|
|
3
|
+
const require_objectUtils = require("./objectUtils-DfnEmDSV.js");
|
|
4
|
+
const require_prepareQueryObjects = require("./prepareQueryObjects-Dj9cTl9D.js");
|
|
5
|
+
const require_parserUtils = require("./parserUtils-DbBXyAht.js");
|
|
5
6
|
let spel2js = require("spel2js");
|
|
6
7
|
//#region src/utils/parseSpEL/utils.ts
|
|
7
8
|
const isSpELPropertyNode = (expr) => {
|
|
@@ -137,7 +138,7 @@ const normalizeOperator = (opType, flip) => {
|
|
|
137
138
|
const generateFlatAndOrList = (expr) => {
|
|
138
139
|
const combinator = expr.type.slice(3);
|
|
139
140
|
const [left, right] = expr.children;
|
|
140
|
-
if (left.type === "op-and" || left.type === "op-or") return [
|
|
141
|
+
if (!(expr.type === "op-and" && left.type === "op-or") && (left.type === "op-and" || left.type === "op-or")) return [
|
|
141
142
|
...generateFlatAndOrList(left),
|
|
142
143
|
combinator,
|
|
143
144
|
right
|
|
@@ -162,12 +163,14 @@ const generateMixedAndOrList = (expr) => {
|
|
|
162
163
|
const tempAndArray = arr.slice(startIndex, i + 1);
|
|
163
164
|
returnArray.push(tempAndArray);
|
|
164
165
|
i -= 2;
|
|
165
|
-
} else if (arr[i + 1] === "or")
|
|
166
|
-
if (i === 0 ||
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
166
|
+
} else if (arr[i + 1] === "or") {
|
|
167
|
+
if (i === 0 || i === arr.length - 3) {
|
|
168
|
+
if (i === 0 || arr[i - 1] === "or") returnArray.push(arr[i]);
|
|
169
|
+
returnArray.push(arr[i + 1]);
|
|
170
|
+
if (i === arr.length - 3) returnArray.push(arr[i + 2]);
|
|
171
|
+
} else if (arr[i - 1] === "and") returnArray.push(arr[i + 1]);
|
|
172
|
+
else returnArray.push(arr[i], arr[i + 1]);
|
|
173
|
+
}
|
|
171
174
|
if (returnArray.length === 1 && Array.isArray(returnArray[0])) return returnArray[0];
|
|
172
175
|
return returnArray;
|
|
173
176
|
};
|
|
@@ -176,8 +179,8 @@ const generateMixedAndOrList = (expr) => {
|
|
|
176
179
|
function parseSpEL(spel, options = {}) {
|
|
177
180
|
const { fields, independentCombinators, listsAsArrays, getExpression } = options;
|
|
178
181
|
const ic = !!independentCombinators;
|
|
179
|
-
const fieldsFlat =
|
|
180
|
-
const fieldIsValid = (fieldName, operator, subordinateFieldName) =>
|
|
182
|
+
const fieldsFlat = require_parserUtils.getFieldsArray(fields);
|
|
183
|
+
const fieldIsValid = (fieldName, operator, subordinateFieldName) => require_parserUtils.fieldIsValidUtil({
|
|
181
184
|
fieldName,
|
|
182
185
|
fieldsFlat,
|
|
183
186
|
operator,
|
|
@@ -195,7 +198,7 @@ function parseSpEL(spel, options = {}) {
|
|
|
195
198
|
const negatedExpr = parseProcessedSpEL(expr.children[0]);
|
|
196
199
|
// v8 ignore else
|
|
197
200
|
if (negatedExpr) {
|
|
198
|
-
if (!
|
|
201
|
+
if (!require_objectUtils.isRuleGroup(negatedExpr) && (negatedExpr.operator === "contains" || negatedExpr.operator === "beginsWith" || negatedExpr.operator === "endsWith")) return {
|
|
199
202
|
...negatedExpr,
|
|
200
203
|
operator: `doesNot${negatedExpr.operator[0].toUpperCase()}${negatedExpr.operator.slice(1).replace("s", "")}`
|
|
201
204
|
};
|
|
@@ -392,7 +395,7 @@ function parseSpEL(spel, options = {}) {
|
|
|
392
395
|
}
|
|
393
396
|
const result = parseProcessedSpEL(processCompiledExpression(compiledSpEL));
|
|
394
397
|
if (result) {
|
|
395
|
-
if (
|
|
398
|
+
if (require_objectUtils.isRuleGroup(result)) return prepare(result);
|
|
396
399
|
return prepare({
|
|
397
400
|
rules: [result],
|
|
398
401
|
...ic ? {} : { combinator: "and" }
|
package/dist/parseSpEL.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseSpEL.js","names":["getFieldsArray","fieldIsValidUtil","isRuleGroup","joinWith","prepareRuleGroup","SpelExpressionEvaluator"],"sources":["../src/utils/parseSpEL/utils.ts","../src/utils/parseSpEL/parseSpEL.ts"],"sourcesContent":["import type { DefaultCombinatorName, DefaultOperatorName } from '../../types';\nimport type {\n SpELBaseNode,\n SpELBetweenFields,\n SpELBetweenValues,\n SpELBooleanLiteral,\n SpELCompoundNode,\n SpELExpressionNode,\n SpELIdentifier,\n SpELListNode,\n SpELMethodCall,\n SpELMethodNode,\n SpELNodeType,\n SpELNullLiteral,\n SpELNumericLiteral,\n SpELOpAnd,\n SpELOpMatches,\n SpELOpOr,\n SpELPrimitive,\n SpELProcessedExpression,\n SpELPropertyNode,\n SpELQualifiedIdentifierNode,\n SpELRelOpType,\n SpELRelation as SpELRelationOp,\n SpELStringLiteral,\n} from './types';\n\nexport const isSpELPropertyNode = (expr: SpELBaseNode<SpELNodeType>): expr is SpELPropertyNode => {\n return expr.getType() === 'property' || expr.getType() === 'variable';\n};\nexport const isSpELCompoundNode = (expr: SpELBaseNode<SpELNodeType>): expr is SpELCompoundNode => {\n return expr.getType() === 'compound' && expr.getChildren().every(c => isSpELPropertyNode(c));\n};\nexport const isSpELListNode = (expr: SpELBaseNode<SpELNodeType>): expr is SpELListNode => {\n return expr.getType() === 'list';\n};\n\nexport const isSpELOpAnd = (expr: SpELProcessedExpression): expr is SpELOpAnd =>\n expr.type === 'op-and';\nexport const isSpELOpOr = (expr: SpELProcessedExpression): expr is SpELOpOr =>\n expr.type === 'op-or';\nexport const isSpELOpMatches = (expr: SpELProcessedExpression): expr is SpELOpMatches =>\n expr.type === 'matches' &&\n ((isSpELIdentifier(expr.children[0]) && isSpELStringLiteral(expr.children[1])) ||\n (isSpELIdentifier(expr.children[1]) && isSpELStringLiteral(expr.children[0])) ||\n (isSpELIdentifier(expr.children[0]) && isSpELIdentifier(expr.children[1])));\nexport const isSpELIdentifier = (expr: SpELProcessedExpression): expr is SpELIdentifier =>\n (expr.type === 'property' || expr.type === 'variable' || expr.type === 'compound') &&\n expr.identifier !== null;\nexport const isSpELStringLiteral = (expr: SpELProcessedExpression): expr is SpELStringLiteral =>\n expr.type === 'string';\nexport const isSpELNumericLiteral = (expr: SpELProcessedExpression): expr is SpELNumericLiteral =>\n expr.type === 'number';\nexport const isSpELBooleanLiteral = (expr: SpELProcessedExpression): expr is SpELBooleanLiteral =>\n expr.type === 'boolean';\nexport const isSpELNullLiteral = (expr: SpELProcessedExpression): expr is SpELNullLiteral =>\n expr.type === 'null';\nexport const isSpELRelationOp = (expr: SpELProcessedExpression): expr is SpELRelationOp =>\n expr.type === 'op-eq' ||\n expr.type === 'op-ne' ||\n expr.type === 'op-gt' ||\n expr.type === 'op-ge' ||\n expr.type === 'op-lt' ||\n expr.type === 'op-le';\nexport const isSpELPrimitive = (expr: SpELProcessedExpression): expr is SpELPrimitive =>\n isSpELNumericLiteral(expr) ||\n isSpELStringLiteral(expr) ||\n isSpELBooleanLiteral(expr) ||\n isSpELNullLiteral(expr);\nexport const isSpELBetweenValues = (expr: SpELProcessedExpression): expr is SpELBetweenValues =>\n expr.type === 'between' &&\n isSpELIdentifier(expr.children[0]) &&\n expr.children[1].type === 'list' &&\n expr.children[1].children.length >= 2 &&\n expr.children[1].children.every(c => isSpELPrimitive(c));\nexport const isSpELBetweenFields = (expr: SpELProcessedExpression): expr is SpELBetweenFields =>\n expr.type === 'between' &&\n isSpELIdentifier(expr.children[0]) &&\n expr.children[1].type === 'list' &&\n expr.children[1].children.length >= 2 &&\n expr.children[1].children.every(c => isSpELIdentifier(c));\n\n/** A SpEL arithmetic infix node (`op-plus`/`op-minus`/`op-multiply`/`op-divide`/`op-modulus`). */\nexport const isSpELMathOperation = (expr: SpELProcessedExpression): boolean =>\n expr.type === 'op-plus' ||\n expr.type === 'op-minus' ||\n expr.type === 'op-multiply' ||\n expr.type === 'op-divide' ||\n expr.type === 'op-modulus';\n\n/** A method/function invocation node (`.toUpperCase()`, `T(java.lang.Math).abs(x)`, `myFunc(a)`). */\nexport const isSpELMethodCall = (expr: SpELProcessedExpression): expr is SpELMethodCall =>\n expr.type === 'method' && typeof expr.methodName === 'string';\n\n/**\n * Whether a relation operand should be routed to `getExpression`: an arithmetic infix node or a\n * method/function invocation. Bare identifiers, chains, and literals are not expression operands\n * (they retain their normal handling).\n */\nexport const isSpELExpressionOperand = (expr: SpELProcessedExpression): boolean =>\n isSpELMathOperation(expr) || isSpELMethodCall(expr);\n\nexport const isSpELMethodNode = (expr: SpELBaseNode<SpELNodeType>): expr is SpELMethodNode =>\n expr.getType() === 'method';\n\n/**\n * Builds a {@link SpELMethodCall} from a SpEL `method` node. Arguments are stored on the\n * compiled node's `getRaw()` payload (not as children), so they are processed from there.\n */\nconst processMethodNode = (\n mn: SpELMethodNode,\n target: SpELProcessedExpression | null,\n typeRef: string | null\n): SpELMethodCall => {\n const { methodName, args } = mn.getRaw();\n return {\n type: 'method',\n children: args.map(a => processCompiledExpression(a)),\n startPosition: mn.getStartPosition(),\n endPosition: mn.getEndPosition(),\n value: 'N/A',\n identifier: null,\n methodName,\n target,\n typeRef,\n };\n};\n\n/**\n * Processes a SpEL `compound` node that invokes one or more methods, e.g. `name.toUpperCase()`,\n * `a.b.toLowerCase()`, `(a + b).toUpperCase()`, or `T(java.lang.Math).abs(cost)`. Leading\n * property/variable children are collapsed into a dotted receiver identifier, a leading `typeref`\n * becomes the `typeRef` of the first call, and each subsequent `method` child wraps the previous\n * result as its `target`. Returns `null` for chain shapes that can't be represented.\n */\nconst processMethodChain = (ce: SpELExpressionNode): SpELMethodCall | null => {\n const children = ce.getChildren();\n if (!children.some(c => isSpELMethodNode(c))) {\n return null;\n }\n\n let index = 0;\n let target: SpELProcessedExpression | null = null;\n let typeRef: string | null = null;\n const first = children[0];\n\n if (first.getType() === 'typeref') {\n const qualifiedIdentifier = first.getChildren()[0] as unknown as SpELQualifiedIdentifierNode;\n typeRef = qualifiedIdentifier.getRaw().join('.');\n index = 1;\n } else if (isSpELPropertyNode(first)) {\n const parts: string[] = [];\n while (index < children.length && isSpELPropertyNode(children[index])) {\n parts.push((children[index] as unknown as SpELPropertyNode).getRaw());\n ++index;\n }\n target = {\n type: parts.length > 1 ? 'compound' : first.getType(),\n children: [],\n startPosition: first.getStartPosition(),\n endPosition: children[index - 1].getEndPosition(),\n value: 'N/A',\n identifier: parts.join('.'),\n };\n } else {\n // Arbitrary receiver subtree, e.g. `(a + b).toUpperCase()`\n target = processCompiledExpression(first);\n index = 1;\n }\n\n let result: SpELMethodCall | null = null;\n for (; index < children.length; ++index) {\n const child = children[index];\n if (!isSpELMethodNode(child)) {\n return null;\n }\n result = processMethodNode(child, result ?? target, result ? null : typeRef);\n }\n return result;\n};\n\nexport const processCompiledExpression = (\n ce: SpELPropertyNode | SpELExpressionNode\n): SpELProcessedExpression => {\n const type = ce.getType();\n\n // Bare function calls, e.g. `myFunc(a, b)`\n if (isSpELMethodNode(ce)) {\n return processMethodNode(ce, null, null);\n }\n\n // Method chains, e.g. `name.toUpperCase()` or `T(java.lang.Math).abs(cost)`\n if (type === 'compound' && !isSpELCompoundNode(ce)) {\n const methodChain = processMethodChain(ce);\n if (methodChain) {\n return methodChain;\n }\n }\n\n const identifier = isSpELCompoundNode(ce)\n ? ce\n .getChildren()\n .map(p => (isSpELPropertyNode(p) ? p.getRaw() : /* v8 ignore next -- @preserve */ ''))\n .join('.')\n : isSpELPropertyNode(ce)\n ? ce.getRaw()\n : null;\n const children =\n type === 'compound'\n ? []\n : (isSpELListNode(ce) ? ce.getRaw : ce.getChildren)().map(c => processCompiledExpression(c));\n const startPosition = ce.getStartPosition();\n const endPosition = ce.getEndPosition();\n const value = ce.getValue.length === 0 ? ce.getValue() : 'N/A';\n\n return {\n type: type === 'compound' && !identifier ? 'invalid' : type,\n children,\n startPosition,\n endPosition,\n value,\n identifier,\n };\n};\n\nexport const normalizeOperator = (opType: SpELRelOpType, flip?: boolean): DefaultOperatorName => {\n if (flip) {\n if (opType === 'op-lt') return '>';\n if (opType === 'op-le') return '>=';\n if (opType === 'op-gt') return '<';\n if (opType === 'op-ge') return '<=';\n }\n return (\n {\n 'op-eq': '=',\n 'op-ge': '>=',\n 'op-gt': '>',\n 'op-le': '<=',\n 'op-lt': '<',\n 'op-ne': '!=',\n } as const\n )[opType];\n};\n\nexport const generateFlatAndOrList = (\n expr: SpELProcessedExpression\n): (DefaultCombinatorName | SpELProcessedExpression)[] => {\n const combinator = expr.type.slice(3) as DefaultCombinatorName;\n const [left, right] = expr.children;\n if (left.type === 'op-and' || left.type === 'op-or') {\n return [...generateFlatAndOrList(left), combinator, right];\n }\n return [left, combinator, right];\n};\n\nexport const generateMixedAndOrList = (\n expr: SpELOpAnd | SpELOpOr\n): (DefaultCombinatorName | SpELProcessedExpression | ('and' | SpELProcessedExpression)[])[] => {\n const arr = generateFlatAndOrList(expr);\n const returnArray: (\n | DefaultCombinatorName\n | SpELProcessedExpression\n | ('and' | SpELProcessedExpression)[]\n )[] = [];\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' | SpELProcessedExpression)[];\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 { SpelExpressionEvaluator } from 'spel2js';\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 { joinWith } from '../arrayUtils';\nimport { isRuleGroup } from '../isRuleGroup';\nimport { fieldIsValidUtil, getFieldsArray } from '../parserUtils';\nimport { prepareRuleGroup } from '../prepareQueryObjects';\nimport type {\n ParseSpELExpressionContext,\n SpELExpressionNode,\n SpELExpressionOperand,\n SpELProcessedExpression,\n} from './types';\nimport {\n generateFlatAndOrList,\n generateMixedAndOrList,\n isSpELBetweenFields,\n isSpELBetweenValues,\n isSpELExpressionOperand,\n isSpELIdentifier,\n isSpELOpAnd,\n isSpELOpMatches,\n isSpELOpOr,\n isSpELPrimitive,\n isSpELRelationOp,\n normalizeOperator,\n processCompiledExpression,\n} from './utils';\n\n/**\n * Options object for {@link parseSpEL!parseSpEL}.\n */\nexport interface ParseSpELOptions extends ParserCommonOptions {\n /**\n * Handler that converts a SpEL expression operand subtree into an {@link ExpressionNode}.\n * Return `null` to reject (the rule is dropped). Supplied by `@react-querybuilder/expr`\n * (`expressionParserSpEL`). When omitted, expression operands are ignored (rule dropped).\n *\n * Arithmetic infix operands and method/function invocations\n * (`T(java.lang.Math).abs/min/max(...)`, `.toUpperCase()`/`.toLowerCase()`, and custom calls)\n * are both supported. See {@link SpELExpressionOperand}.\n */\n getExpression?: (\n node: SpELExpressionOperand,\n ctx: ParseSpELExpressionContext\n ) => ExpressionNode | null;\n}\n\n/**\n * Converts a SpEL 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 parseSpEL(spel: string): DefaultRuleGroupType;\n/**\n * Converts a SpEL 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 parseSpEL(\n spel: string,\n options: Except<ParseSpELOptions, 'independentCombinators'> & {\n independentCombinators?: false;\n }\n): DefaultRuleGroupType;\n/**\n * Converts a SpEL 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 parseSpEL(\n spel: string,\n options: Except<ParseSpELOptions, 'independentCombinators'> & {\n independentCombinators: true;\n }\n): DefaultRuleGroupTypeIC;\nfunction parseSpEL(spel: string, options: ParseSpELOptions = {}): DefaultRuleGroupTypeAny {\n const { fields, independentCombinators, listsAsArrays, 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 exprCtx: ParseSpELExpressionContext = {\n fieldExists: fieldName => fieldsFlat.length === 0 || fieldsFlat.some(f => f.name === fieldName),\n };\n\n const emptyQuery: DefaultRuleGroupTypeAny = {\n rules: [],\n ...(ic ? {} : { combinator: 'and' }),\n };\n\n const parseProcessedSpEL = (\n expr: SpELProcessedExpression,\n processOpts: {\n groupOnlyIfNecessary?: boolean;\n forwardNegation?: boolean;\n } = {}\n ): DefaultRuleType | DefaultRuleGroupTypeAny | null => {\n const { forwardNegation: _forwardedNegation, groupOnlyIfNecessary: _g } = processOpts;\n if (expr.type === 'op-not') {\n const negatedExpr = parseProcessedSpEL(expr.children[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: `doesNot${negatedExpr.operator[0].toUpperCase()}${negatedExpr.operator\n .slice(1)\n .replace('s', '')}` as DefaultOperatorName,\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 (isSpELOpAnd(expr) || isSpELOpOr(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 parseProcessedSpEL(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 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 (SpELProcessedExpression | SpELProcessedExpression[])[];\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 => parseProcessedSpEL(e)).filter(Boolean) as DefaultRuleGroupArray,\n };\n }\n return parseProcessedSpEL(exp) as DefaultRuleType | DefaultRuleGroupType | null;\n })\n .filter(Boolean) as DefaultRuleGroupArray;\n // v8 ignore else\n if (rules.length > 0) {\n return { combinator, rules };\n }\n } else if (isSpELOpMatches(expr)) {\n const [left, right] = expr.children;\n let field: string = '';\n let regex: string = '';\n let valueSource: ValueSource | undefined = undefined;\n if (isSpELIdentifier(left)) {\n field = left.identifier;\n if (isSpELIdentifier(right)) {\n regex = right.identifier;\n valueSource = 'field';\n } else {\n // v8 ignore else\n if (isSpELPrimitive(right)) {\n regex = right.value;\n }\n }\n } else {\n // v8 ignore else\n if (isSpELIdentifier(right) && isSpELPrimitive(left)) {\n field = right.identifier;\n regex = left.value;\n }\n }\n\n if (/^(?!\\^).*?(?<!\\$)$/.test(regex)) {\n // v8 ignore else\n if (fieldIsValid(field, 'contains')) {\n return {\n field,\n operator: 'contains',\n value: regex,\n ...(valueSource ? { valueSource } : {}),\n };\n }\n } else {\n if (/^\\^.*?(?<!\\$)$/.test(regex)) {\n // v8 ignore else\n if (fieldIsValid(field, 'beginsWith')) {\n return {\n field,\n operator: 'beginsWith',\n value: regex.replace(/^\\^/, ''),\n };\n }\n } else {\n // v8 ignore else\n if (/^(?!\\^).*?\\$$/.test(regex)) {\n // v8 ignore else\n if (fieldIsValid(field, 'endsWith')) {\n return {\n field,\n operator: 'endsWith',\n value: regex.replace(/\\$$/, ''),\n };\n }\n }\n }\n }\n } else if (isSpELBetweenValues(expr) || isSpELBetweenFields(expr)) {\n // oxlint-disable-next-line typescript/no-explicit-any\n let values: [any, any] = [null, null];\n let valueSource: ValueSource | undefined = undefined;\n const [\n { identifier: field },\n {\n children: [left, right],\n },\n ] = expr.children;\n\n if (isSpELBetweenValues(expr)) {\n values = [left.value, right.value];\n } else {\n values = [left.identifier, right.identifier];\n valueSource = 'field';\n }\n // v8 ignore else\n if (\n field &&\n values.every(v => fieldIsValid(field, 'between', valueSource === 'field' ? v : undefined))\n ) {\n const valueArray =\n values[0] < values[1] || valueSource === 'field' ? values : [values[1], values[0]];\n const value = listsAsArrays ? valueArray : joinWith(valueArray, ',');\n return valueSource\n ? { field, operator: 'between', value, valueSource }\n : { field, operator: 'between', value };\n }\n } else if (isSpELRelationOp(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 [left, right] = expr.children;\n\n // Arithmetic and method/function expression operands (from `@react-querybuilder/expr`)\n if (getExpression) {\n const leftIsExpr = isSpELExpressionOperand(left);\n const rightIsExpr = isSpELExpressionOperand(right);\n if (leftIsExpr || rightIsExpr) {\n const op = (flipOp: boolean) => normalizeOperator(expr.type, flipOp);\n if (leftIsExpr && rightIsExpr) {\n // expression <op> expression → both sides on lhs/value\n const l = getExpression(left, exprCtx);\n const r = getExpression(right, exprCtx);\n return l && r\n ? { field: '', operator: op(false), lhs: l, value: r, valueSource: 'expression' }\n : null;\n }\n if (isSpELIdentifier(left) && rightIsExpr) {\n // field <op> expression → rhs expression\n const node = getExpression(right, exprCtx);\n const f = left.identifier;\n const operator = op(false);\n return node && fieldIsValid(f, operator)\n ? { field: f, operator, value: node, valueSource: 'expression' }\n : null;\n }\n if (leftIsExpr && isSpELIdentifier(right)) {\n // expression <op> field → flip to field <op> expression\n const node = getExpression(left, exprCtx);\n const f = right.identifier;\n const operator = op(true);\n return node && fieldIsValid(f, operator)\n ? { field: f, operator, value: node, valueSource: 'expression' }\n : null;\n }\n if (leftIsExpr && isSpELPrimitive(right)) {\n // expression <op> literal → lhs = expression, literal value\n const l = getExpression(left, exprCtx);\n return l ? { field: '', operator: op(false), lhs: l, value: right.value } : null;\n }\n if (isSpELPrimitive(left)) {\n // literal <op> expression → lhs = expression, flip operator\n const r = getExpression(right, exprCtx);\n return r ? { field: '', operator: op(true), lhs: r, value: left.value } : null;\n }\n }\n }\n\n if (isSpELIdentifier(left)) {\n field = left.identifier;\n if (isSpELIdentifier(right)) {\n value = right.identifier;\n valueSource = 'field';\n } else if (isSpELPrimitive(right)) {\n value = right.value;\n }\n } else {\n // v8 ignore else\n if (isSpELIdentifier(right) && isSpELPrimitive(left)) {\n flip = true;\n field = right.identifier;\n value = left.value;\n }\n }\n let operator = normalizeOperator(expr.type, 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 compiledSpEL: SpELExpressionNode;\n try {\n compiledSpEL = SpelExpressionEvaluator.compile(spel)._compiledExpression;\n } catch {\n return prepare(emptyQuery);\n }\n\n const processedSpEL = processCompiledExpression(compiledSpEL);\n\n const result = parseProcessedSpEL(processedSpEL);\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 { parseSpEL };\n"],"mappings":";;;;;;AA2BA,MAAa,sBAAsB,SAA+D;CAChG,OAAO,KAAK,QAAQ,MAAM,cAAc,KAAK,QAAQ,MAAM;AAC7D;AACA,MAAa,sBAAsB,SAA+D;CAChG,OAAO,KAAK,QAAQ,MAAM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G;KAC3B,QAAQ,MAAM;KACd,cAAc;IAChB,OAAO,IAAI,gBAAgB,KAAK,GAC9B,QAAQ,MAAM;GAElB,OAEE,IAAI,iBAAiB,KAAK,KAAK,gBAAgB,IAAI,GAAG;IACpD,OAAO;IACP,QAAQ,MAAM;IACd,QAAQ,KAAK;GACf;GAEF,IAAI,WAAW,kBAAkB,KAAK,MAAM,IAAI;GAChD,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,cAAcC,4BAAAA,oBAAuB,MAAS;CAEtE,IAAI;CACJ,IAAI;EACF,eAAeC,QAAAA,wBAAwB,QAAQ,IAAI,CAAC,CAAC;CACvD,QAAQ;EACN,OAAO,QAAQ,UAAU;CAC3B;CAIA,MAAM,SAAS,mBAFO,0BAA0B,YAEF,CAAC;CAC/C,IAAI,QAAQ;EACV,IAAIH,oBAAAA,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":"parseSpEL.js","names":["getFieldsArray","fieldIsValidUtil","isRuleGroup","joinWith","prepareRuleGroup","SpelExpressionEvaluator"],"sources":["../src/utils/parseSpEL/utils.ts","../src/utils/parseSpEL/parseSpEL.ts"],"sourcesContent":["import type { DefaultCombinatorName, DefaultOperatorName } from '../../types';\nimport type {\n SpELBaseNode,\n SpELBetweenFields,\n SpELBetweenValues,\n SpELBooleanLiteral,\n SpELCompoundNode,\n SpELExpressionNode,\n SpELIdentifier,\n SpELListNode,\n SpELMethodCall,\n SpELMethodNode,\n SpELNodeType,\n SpELNullLiteral,\n SpELNumericLiteral,\n SpELOpAnd,\n SpELOpMatches,\n SpELOpOr,\n SpELPrimitive,\n SpELProcessedExpression,\n SpELPropertyNode,\n SpELQualifiedIdentifierNode,\n SpELRelOpType,\n SpELRelation as SpELRelationOp,\n SpELStringLiteral,\n} from './types';\n\nexport const isSpELPropertyNode = (expr: SpELBaseNode<SpELNodeType>): expr is SpELPropertyNode => {\n return expr.getType() === 'property' || expr.getType() === 'variable';\n};\nexport const isSpELCompoundNode = (expr: SpELBaseNode<SpELNodeType>): expr is SpELCompoundNode => {\n return expr.getType() === 'compound' && expr.getChildren().every(c => isSpELPropertyNode(c));\n};\nexport const isSpELListNode = (expr: SpELBaseNode<SpELNodeType>): expr is SpELListNode => {\n return expr.getType() === 'list';\n};\n\nexport const isSpELOpAnd = (expr: SpELProcessedExpression): expr is SpELOpAnd =>\n expr.type === 'op-and';\nexport const isSpELOpOr = (expr: SpELProcessedExpression): expr is SpELOpOr =>\n expr.type === 'op-or';\nexport const isSpELOpMatches = (expr: SpELProcessedExpression): expr is SpELOpMatches =>\n expr.type === 'matches' &&\n ((isSpELIdentifier(expr.children[0]) && isSpELStringLiteral(expr.children[1])) ||\n (isSpELIdentifier(expr.children[1]) && isSpELStringLiteral(expr.children[0])) ||\n (isSpELIdentifier(expr.children[0]) && isSpELIdentifier(expr.children[1])));\nexport const isSpELIdentifier = (expr: SpELProcessedExpression): expr is SpELIdentifier =>\n (expr.type === 'property' || expr.type === 'variable' || expr.type === 'compound') &&\n expr.identifier !== null;\nexport const isSpELStringLiteral = (expr: SpELProcessedExpression): expr is SpELStringLiteral =>\n expr.type === 'string';\nexport const isSpELNumericLiteral = (expr: SpELProcessedExpression): expr is SpELNumericLiteral =>\n expr.type === 'number';\nexport const isSpELBooleanLiteral = (expr: SpELProcessedExpression): expr is SpELBooleanLiteral =>\n expr.type === 'boolean';\nexport const isSpELNullLiteral = (expr: SpELProcessedExpression): expr is SpELNullLiteral =>\n expr.type === 'null';\nexport const isSpELRelationOp = (expr: SpELProcessedExpression): expr is SpELRelationOp =>\n expr.type === 'op-eq' ||\n expr.type === 'op-ne' ||\n expr.type === 'op-gt' ||\n expr.type === 'op-ge' ||\n expr.type === 'op-lt' ||\n expr.type === 'op-le';\nexport const isSpELPrimitive = (expr: SpELProcessedExpression): expr is SpELPrimitive =>\n isSpELNumericLiteral(expr) ||\n isSpELStringLiteral(expr) ||\n isSpELBooleanLiteral(expr) ||\n isSpELNullLiteral(expr);\nexport const isSpELBetweenValues = (expr: SpELProcessedExpression): expr is SpELBetweenValues =>\n expr.type === 'between' &&\n isSpELIdentifier(expr.children[0]) &&\n expr.children[1].type === 'list' &&\n expr.children[1].children.length >= 2 &&\n expr.children[1].children.every(c => isSpELPrimitive(c));\nexport const isSpELBetweenFields = (expr: SpELProcessedExpression): expr is SpELBetweenFields =>\n expr.type === 'between' &&\n isSpELIdentifier(expr.children[0]) &&\n expr.children[1].type === 'list' &&\n expr.children[1].children.length >= 2 &&\n expr.children[1].children.every(c => isSpELIdentifier(c));\n\n/** A SpEL arithmetic infix node (`op-plus`/`op-minus`/`op-multiply`/`op-divide`/`op-modulus`). */\nexport const isSpELMathOperation = (expr: SpELProcessedExpression): boolean =>\n expr.type === 'op-plus' ||\n expr.type === 'op-minus' ||\n expr.type === 'op-multiply' ||\n expr.type === 'op-divide' ||\n expr.type === 'op-modulus';\n\n/** A method/function invocation node (`.toUpperCase()`, `T(java.lang.Math).abs(x)`, `myFunc(a)`). */\nexport const isSpELMethodCall = (expr: SpELProcessedExpression): expr is SpELMethodCall =>\n expr.type === 'method' && typeof expr.methodName === 'string';\n\n/**\n * Whether a relation operand should be routed to `getExpression`: an arithmetic infix node or a\n * method/function invocation. Bare identifiers, chains, and literals are not expression operands\n * (they retain their normal handling).\n */\nexport const isSpELExpressionOperand = (expr: SpELProcessedExpression): boolean =>\n isSpELMathOperation(expr) || isSpELMethodCall(expr);\n\nexport const isSpELMethodNode = (expr: SpELBaseNode<SpELNodeType>): expr is SpELMethodNode =>\n expr.getType() === 'method';\n\n/**\n * Builds a {@link SpELMethodCall} from a SpEL `method` node. Arguments are stored on the\n * compiled node's `getRaw()` payload (not as children), so they are processed from there.\n */\nconst processMethodNode = (\n mn: SpELMethodNode,\n target: SpELProcessedExpression | null,\n typeRef: string | null\n): SpELMethodCall => {\n const { methodName, args } = mn.getRaw();\n return {\n type: 'method',\n children: args.map(a => processCompiledExpression(a)),\n startPosition: mn.getStartPosition(),\n endPosition: mn.getEndPosition(),\n value: 'N/A',\n identifier: null,\n methodName,\n target,\n typeRef,\n };\n};\n\n/**\n * Processes a SpEL `compound` node that invokes one or more methods, e.g. `name.toUpperCase()`,\n * `a.b.toLowerCase()`, `(a + b).toUpperCase()`, or `T(java.lang.Math).abs(cost)`. Leading\n * property/variable children are collapsed into a dotted receiver identifier, a leading `typeref`\n * becomes the `typeRef` of the first call, and each subsequent `method` child wraps the previous\n * result as its `target`. Returns `null` for chain shapes that can't be represented.\n */\nconst processMethodChain = (ce: SpELExpressionNode): SpELMethodCall | null => {\n const children = ce.getChildren();\n if (!children.some(c => isSpELMethodNode(c))) {\n return null;\n }\n\n let index = 0;\n let target: SpELProcessedExpression | null = null;\n let typeRef: string | null = null;\n const first = children[0];\n\n if (first.getType() === 'typeref') {\n const qualifiedIdentifier = first.getChildren()[0] as unknown as SpELQualifiedIdentifierNode;\n typeRef = qualifiedIdentifier.getRaw().join('.');\n index = 1;\n } else if (isSpELPropertyNode(first)) {\n const parts: string[] = [];\n while (index < children.length && isSpELPropertyNode(children[index])) {\n parts.push((children[index] as unknown as SpELPropertyNode).getRaw());\n ++index;\n }\n target = {\n type: parts.length > 1 ? 'compound' : first.getType(),\n children: [],\n startPosition: first.getStartPosition(),\n endPosition: children[index - 1].getEndPosition(),\n value: 'N/A',\n identifier: parts.join('.'),\n };\n } else {\n // Arbitrary receiver subtree, e.g. `(a + b).toUpperCase()`\n target = processCompiledExpression(first);\n index = 1;\n }\n\n let result: SpELMethodCall | null = null;\n for (; index < children.length; ++index) {\n const child = children[index];\n if (!isSpELMethodNode(child)) {\n return null;\n }\n result = processMethodNode(child, result ?? target, result ? null : typeRef);\n }\n return result;\n};\n\nexport const processCompiledExpression = (\n ce: SpELPropertyNode | SpELExpressionNode\n): SpELProcessedExpression => {\n const type = ce.getType();\n\n // Bare function calls, e.g. `myFunc(a, b)`\n if (isSpELMethodNode(ce)) {\n return processMethodNode(ce, null, null);\n }\n\n // Method chains, e.g. `name.toUpperCase()` or `T(java.lang.Math).abs(cost)`\n if (type === 'compound' && !isSpELCompoundNode(ce)) {\n const methodChain = processMethodChain(ce);\n if (methodChain) {\n return methodChain;\n }\n }\n\n const identifier = isSpELCompoundNode(ce)\n ? ce\n .getChildren()\n .map(p => (isSpELPropertyNode(p) ? p.getRaw() : /* v8 ignore next -- @preserve */ ''))\n .join('.')\n : isSpELPropertyNode(ce)\n ? ce.getRaw()\n : null;\n const children =\n type === 'compound'\n ? []\n : (isSpELListNode(ce) ? ce.getRaw : ce.getChildren)().map(c => processCompiledExpression(c));\n const startPosition = ce.getStartPosition();\n const endPosition = ce.getEndPosition();\n const value = ce.getValue.length === 0 ? ce.getValue() : 'N/A';\n\n return {\n type: type === 'compound' && !identifier ? 'invalid' : type,\n children,\n startPosition,\n endPosition,\n value,\n identifier,\n };\n};\n\nexport const normalizeOperator = (opType: SpELRelOpType, flip?: boolean): DefaultOperatorName => {\n if (flip) {\n if (opType === 'op-lt') return '>';\n if (opType === 'op-le') return '>=';\n if (opType === 'op-gt') return '<';\n if (opType === 'op-ge') return '<=';\n }\n return (\n {\n 'op-eq': '=',\n 'op-ge': '>=',\n 'op-gt': '>',\n 'op-le': '<=',\n 'op-lt': '<',\n 'op-ne': '!=',\n } as const\n )[opType];\n};\n\nexport const generateFlatAndOrList = (\n expr: SpELProcessedExpression\n): (DefaultCombinatorName | SpELProcessedExpression)[] => {\n const combinator = expr.type.slice(3) as DefaultCombinatorName;\n const [left, right] = expr.children;\n // SpEL AST has no parenthesis node, so `or` under `and` can only come from an explicit group\n // (`and` binds tighter). Flattening it would lose the grouping.\n const leftWasParenthesized = expr.type === 'op-and' && left.type === 'op-or';\n if (!leftWasParenthesized && (left.type === 'op-and' || left.type === 'op-or')) {\n return [...generateFlatAndOrList(left), combinator, right];\n }\n return [left, combinator, right];\n};\n\nexport const generateMixedAndOrList = (\n expr: SpELOpAnd | SpELOpOr\n): (DefaultCombinatorName | SpELProcessedExpression | ('and' | SpELProcessedExpression)[])[] => {\n const arr = generateFlatAndOrList(expr);\n const returnArray: (\n | DefaultCombinatorName\n | SpELProcessedExpression\n | ('and' | SpELProcessedExpression)[]\n )[] = [];\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' | SpELProcessedExpression)[];\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 { SpelExpressionEvaluator } from 'spel2js';\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 { joinWith } from '../arrayUtils';\nimport { isRuleGroup } from '../isRuleGroup';\nimport { fieldIsValidUtil, getFieldsArray } from '../parserUtils';\nimport { prepareRuleGroup } from '../prepareQueryObjects';\nimport type {\n ParseSpELExpressionContext,\n SpELExpressionNode,\n SpELExpressionOperand,\n SpELProcessedExpression,\n} from './types';\nimport {\n generateFlatAndOrList,\n generateMixedAndOrList,\n isSpELBetweenFields,\n isSpELBetweenValues,\n isSpELExpressionOperand,\n isSpELIdentifier,\n isSpELOpAnd,\n isSpELOpMatches,\n isSpELOpOr,\n isSpELPrimitive,\n isSpELRelationOp,\n normalizeOperator,\n processCompiledExpression,\n} from './utils';\n\n/**\n * Options object for {@link parseSpEL!parseSpEL}.\n */\nexport interface ParseSpELOptions extends ParserCommonOptions {\n /**\n * Handler that converts a SpEL expression operand subtree into an {@link ExpressionNode}.\n * Return `null` to reject (the rule is dropped). Supplied by `@react-querybuilder/expr`\n * (`expressionParserSpEL`). When omitted, expression operands are ignored (rule dropped).\n *\n * Arithmetic infix operands and method/function invocations\n * (`T(java.lang.Math).abs/min/max(...)`, `.toUpperCase()`/`.toLowerCase()`, and custom calls)\n * are both supported. See {@link SpELExpressionOperand}.\n */\n getExpression?: (\n node: SpELExpressionOperand,\n ctx: ParseSpELExpressionContext\n ) => ExpressionNode | null;\n}\n\n/**\n * Converts a SpEL 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 parseSpEL(spel: string): DefaultRuleGroupType;\n/**\n * Converts a SpEL 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 parseSpEL(\n spel: string,\n options: Except<ParseSpELOptions, 'independentCombinators'> & {\n independentCombinators?: false;\n }\n): DefaultRuleGroupType;\n/**\n * Converts a SpEL 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 parseSpEL(\n spel: string,\n options: Except<ParseSpELOptions, 'independentCombinators'> & {\n independentCombinators: true;\n }\n): DefaultRuleGroupTypeIC;\nfunction parseSpEL(spel: string, options: ParseSpELOptions = {}): DefaultRuleGroupTypeAny {\n const { fields, independentCombinators, listsAsArrays, 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 exprCtx: ParseSpELExpressionContext = {\n fieldExists: fieldName => fieldsFlat.length === 0 || fieldsFlat.some(f => f.name === fieldName),\n };\n\n const emptyQuery: DefaultRuleGroupTypeAny = {\n rules: [],\n ...(ic ? {} : { combinator: 'and' }),\n };\n\n const parseProcessedSpEL = (\n expr: SpELProcessedExpression,\n processOpts: {\n groupOnlyIfNecessary?: boolean;\n forwardNegation?: boolean;\n } = {}\n ): DefaultRuleType | DefaultRuleGroupTypeAny | null => {\n const { forwardNegation: _forwardedNegation, groupOnlyIfNecessary: _g } = processOpts;\n if (expr.type === 'op-not') {\n const negatedExpr = parseProcessedSpEL(expr.children[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: `doesNot${negatedExpr.operator[0].toUpperCase()}${negatedExpr.operator\n .slice(1)\n .replace('s', '')}` as DefaultOperatorName,\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 (isSpELOpAnd(expr) || isSpELOpOr(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 parseProcessedSpEL(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 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 (SpELProcessedExpression | SpELProcessedExpression[])[];\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 => parseProcessedSpEL(e)).filter(Boolean) as DefaultRuleGroupArray,\n };\n }\n return parseProcessedSpEL(exp) as DefaultRuleType | DefaultRuleGroupType | null;\n })\n .filter(Boolean) as DefaultRuleGroupArray;\n // v8 ignore else\n if (rules.length > 0) {\n return { combinator, rules };\n }\n } else if (isSpELOpMatches(expr)) {\n const [left, right] = expr.children;\n let field: string = '';\n let regex: string = '';\n let valueSource: ValueSource | undefined = undefined;\n if (isSpELIdentifier(left)) {\n field = left.identifier;\n if (isSpELIdentifier(right)) {\n regex = right.identifier;\n valueSource = 'field';\n } else {\n // v8 ignore else\n if (isSpELPrimitive(right)) {\n regex = right.value;\n }\n }\n } else {\n // v8 ignore else\n if (isSpELIdentifier(right) && isSpELPrimitive(left)) {\n field = right.identifier;\n regex = left.value;\n }\n }\n\n if (/^(?!\\^).*?(?<!\\$)$/.test(regex)) {\n // v8 ignore else\n if (fieldIsValid(field, 'contains')) {\n return {\n field,\n operator: 'contains',\n value: regex,\n ...(valueSource ? { valueSource } : {}),\n };\n }\n } else {\n if (/^\\^.*?(?<!\\$)$/.test(regex)) {\n // v8 ignore else\n if (fieldIsValid(field, 'beginsWith')) {\n return {\n field,\n operator: 'beginsWith',\n value: regex.replace(/^\\^/, ''),\n };\n }\n } else {\n // v8 ignore else\n if (/^(?!\\^).*?\\$$/.test(regex)) {\n // v8 ignore else\n if (fieldIsValid(field, 'endsWith')) {\n return {\n field,\n operator: 'endsWith',\n value: regex.replace(/\\$$/, ''),\n };\n }\n }\n }\n }\n } else if (isSpELBetweenValues(expr) || isSpELBetweenFields(expr)) {\n // oxlint-disable-next-line typescript/no-explicit-any\n let values: [any, any] = [null, null];\n let valueSource: ValueSource | undefined = undefined;\n const [\n { identifier: field },\n {\n children: [left, right],\n },\n ] = expr.children;\n\n if (isSpELBetweenValues(expr)) {\n values = [left.value, right.value];\n } else {\n values = [left.identifier, right.identifier];\n valueSource = 'field';\n }\n // v8 ignore else\n if (\n field &&\n values.every(v => fieldIsValid(field, 'between', valueSource === 'field' ? v : undefined))\n ) {\n const valueArray =\n values[0] < values[1] || valueSource === 'field' ? values : [values[1], values[0]];\n const value = listsAsArrays ? valueArray : joinWith(valueArray, ',');\n return valueSource\n ? { field, operator: 'between', value, valueSource }\n : { field, operator: 'between', value };\n }\n } else if (isSpELRelationOp(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 [left, right] = expr.children;\n\n // Arithmetic and method/function expression operands (from `@react-querybuilder/expr`)\n if (getExpression) {\n const leftIsExpr = isSpELExpressionOperand(left);\n const rightIsExpr = isSpELExpressionOperand(right);\n if (leftIsExpr || rightIsExpr) {\n const op = (flipOp: boolean) => normalizeOperator(expr.type, flipOp);\n if (leftIsExpr && rightIsExpr) {\n // expression <op> expression → both sides on lhs/value\n const l = getExpression(left, exprCtx);\n const r = getExpression(right, exprCtx);\n return l && r\n ? { field: '', operator: op(false), lhs: l, value: r, valueSource: 'expression' }\n : null;\n }\n if (isSpELIdentifier(left) && rightIsExpr) {\n // field <op> expression → rhs expression\n const node = getExpression(right, exprCtx);\n const f = left.identifier;\n const operator = op(false);\n return node && fieldIsValid(f, operator)\n ? { field: f, operator, value: node, valueSource: 'expression' }\n : null;\n }\n if (leftIsExpr && isSpELIdentifier(right)) {\n // expression <op> field → flip to field <op> expression\n const node = getExpression(left, exprCtx);\n const f = right.identifier;\n const operator = op(true);\n return node && fieldIsValid(f, operator)\n ? { field: f, operator, value: node, valueSource: 'expression' }\n : null;\n }\n if (leftIsExpr && isSpELPrimitive(right)) {\n // expression <op> literal → lhs = expression, literal value\n const l = getExpression(left, exprCtx);\n return l ? { field: '', operator: op(false), lhs: l, value: right.value } : null;\n }\n if (isSpELPrimitive(left)) {\n // literal <op> expression → lhs = expression, flip operator\n const r = getExpression(right, exprCtx);\n return r ? { field: '', operator: op(true), lhs: r, value: left.value } : null;\n }\n }\n }\n\n if (isSpELIdentifier(left)) {\n field = left.identifier;\n if (isSpELIdentifier(right)) {\n value = right.identifier;\n valueSource = 'field';\n } else if (isSpELPrimitive(right)) {\n value = right.value;\n }\n } else {\n // v8 ignore else\n if (isSpELIdentifier(right) && isSpELPrimitive(left)) {\n flip = true;\n field = right.identifier;\n value = left.value;\n }\n }\n let operator = normalizeOperator(expr.type, 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 compiledSpEL: SpELExpressionNode;\n try {\n compiledSpEL = SpelExpressionEvaluator.compile(spel)._compiledExpression;\n } catch {\n return prepare(emptyQuery);\n }\n\n const processedSpEL = processCompiledExpression(compiledSpEL);\n\n const result = parseProcessedSpEL(processedSpEL);\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 { parseSpEL };\n"],"mappings":";;;;;;;AA2BA,MAAa,sBAAsB,SAA+D;CAChG,OAAO,KAAK,QAAQ,MAAM,cAAc,KAAK,QAAQ,MAAM;AAC7D;AACA,MAAa,sBAAsB,SAA+D;CAChG,OAAO,KAAK,QAAQ,MAAM,cAAc,KAAK,YAAY,CAAC,CAAC,OAAM,MAAK,mBAAmB,CAAC,CAAC;AAC7F;AACA,MAAa,kBAAkB,SAA2D;CACxF,OAAO,KAAK,QAAQ,MAAM;AAC5B;AAEA,MAAa,eAAe,SAC1B,KAAK,SAAS;AAChB,MAAa,cAAc,SACzB,KAAK,SAAS;AAChB,MAAa,mBAAmB,SAC9B,KAAK,SAAS,cACZ,iBAAiB,KAAK,SAAS,EAAE,KAAK,oBAAoB,KAAK,SAAS,EAAE,KACzE,iBAAiB,KAAK,SAAS,EAAE,KAAK,oBAAoB,KAAK,SAAS,EAAE,KAC1E,iBAAiB,KAAK,SAAS,EAAE,KAAK,iBAAiB,KAAK,SAAS,EAAE;AAC5E,MAAa,oBAAoB,UAC9B,KAAK,SAAS,cAAc,KAAK,SAAS,cAAc,KAAK,SAAS,eACvE,KAAK,eAAe;AACtB,MAAa,uBAAuB,SAClC,KAAK,SAAS;AAChB,MAAa,wBAAwB,SACnC,KAAK,SAAS;AAChB,MAAa,wBAAwB,SACnC,KAAK,SAAS;AAChB,MAAa,qBAAqB,SAChC,KAAK,SAAS;AAChB,MAAa,oBAAoB,SAC/B,KAAK,SAAS,WACd,KAAK,SAAS,WACd,KAAK,SAAS,WACd,KAAK,SAAS,WACd,KAAK,SAAS,WACd,KAAK,SAAS;AAChB,MAAa,mBAAmB,SAC9B,qBAAqB,IAAI,KACzB,oBAAo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QAAQ;GAAE,OAAO,CAAC,MAAM;GAAG,GAAI,KAAK,CAAC,IAAI,EAAE,YAAY,MAAM;EAAG,CAAC;CAC1E;CAEA,OAAO,QAAQ,UAAU;AAC3B"}
|
package/dist/parseSpEL.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { n as
|
|
1
|
+
import { U as joinWith } from "./utils-CP5Jqy1P.mjs";
|
|
2
|
+
import { i as isRuleGroup } from "./objectUtils-DDZ-KhV5.mjs";
|
|
3
|
+
import { n as prepareRuleGroup } from "./prepareQueryObjects-Dmyf3Wi_.mjs";
|
|
4
|
+
import { n as getFieldsArray, t as fieldIsValidUtil } from "./parserUtils-BKPstAaO.mjs";
|
|
4
5
|
import { SpelExpressionEvaluator } from "spel2js";
|
|
5
6
|
//#region src/utils/parseSpEL/utils.ts
|
|
6
7
|
const isSpELPropertyNode = (expr) => {
|
|
@@ -136,7 +137,7 @@ const normalizeOperator = (opType, flip) => {
|
|
|
136
137
|
const generateFlatAndOrList = (expr) => {
|
|
137
138
|
const combinator = expr.type.slice(3);
|
|
138
139
|
const [left, right] = expr.children;
|
|
139
|
-
if (left.type === "op-and" || left.type === "op-or") return [
|
|
140
|
+
if (!(expr.type === "op-and" && left.type === "op-or") && (left.type === "op-and" || left.type === "op-or")) return [
|
|
140
141
|
...generateFlatAndOrList(left),
|
|
141
142
|
combinator,
|
|
142
143
|
right
|
|
@@ -161,12 +162,14 @@ const generateMixedAndOrList = (expr) => {
|
|
|
161
162
|
const tempAndArray = arr.slice(startIndex, i + 1);
|
|
162
163
|
returnArray.push(tempAndArray);
|
|
163
164
|
i -= 2;
|
|
164
|
-
} else if (arr[i + 1] === "or")
|
|
165
|
-
if (i === 0 ||
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
165
|
+
} else if (arr[i + 1] === "or") {
|
|
166
|
+
if (i === 0 || i === arr.length - 3) {
|
|
167
|
+
if (i === 0 || arr[i - 1] === "or") returnArray.push(arr[i]);
|
|
168
|
+
returnArray.push(arr[i + 1]);
|
|
169
|
+
if (i === arr.length - 3) returnArray.push(arr[i + 2]);
|
|
170
|
+
} else if (arr[i - 1] === "and") returnArray.push(arr[i + 1]);
|
|
171
|
+
else returnArray.push(arr[i], arr[i + 1]);
|
|
172
|
+
}
|
|
170
173
|
if (returnArray.length === 1 && Array.isArray(returnArray[0])) return returnArray[0];
|
|
171
174
|
return returnArray;
|
|
172
175
|
};
|
package/dist/parseSpEL.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseSpEL.mjs","names":[],"sources":["../src/utils/parseSpEL/utils.ts","../src/utils/parseSpEL/parseSpEL.ts"],"sourcesContent":["import type { DefaultCombinatorName, DefaultOperatorName } from '../../types';\nimport type {\n SpELBaseNode,\n SpELBetweenFields,\n SpELBetweenValues,\n SpELBooleanLiteral,\n SpELCompoundNode,\n SpELExpressionNode,\n SpELIdentifier,\n SpELListNode,\n SpELMethodCall,\n SpELMethodNode,\n SpELNodeType,\n SpELNullLiteral,\n SpELNumericLiteral,\n SpELOpAnd,\n SpELOpMatches,\n SpELOpOr,\n SpELPrimitive,\n SpELProcessedExpression,\n SpELPropertyNode,\n SpELQualifiedIdentifierNode,\n SpELRelOpType,\n SpELRelation as SpELRelationOp,\n SpELStringLiteral,\n} from './types';\n\nexport const isSpELPropertyNode = (expr: SpELBaseNode<SpELNodeType>): expr is SpELPropertyNode => {\n return expr.getType() === 'property' || expr.getType() === 'variable';\n};\nexport const isSpELCompoundNode = (expr: SpELBaseNode<SpELNodeType>): expr is SpELCompoundNode => {\n return expr.getType() === 'compound' && expr.getChildren().every(c => isSpELPropertyNode(c));\n};\nexport const isSpELListNode = (expr: SpELBaseNode<SpELNodeType>): expr is SpELListNode => {\n return expr.getType() === 'list';\n};\n\nexport const isSpELOpAnd = (expr: SpELProcessedExpression): expr is SpELOpAnd =>\n expr.type === 'op-and';\nexport const isSpELOpOr = (expr: SpELProcessedExpression): expr is SpELOpOr =>\n expr.type === 'op-or';\nexport const isSpELOpMatches = (expr: SpELProcessedExpression): expr is SpELOpMatches =>\n expr.type === 'matches' &&\n ((isSpELIdentifier(expr.children[0]) && isSpELStringLiteral(expr.children[1])) ||\n (isSpELIdentifier(expr.children[1]) && isSpELStringLiteral(expr.children[0])) ||\n (isSpELIdentifier(expr.children[0]) && isSpELIdentifier(expr.children[1])));\nexport const isSpELIdentifier = (expr: SpELProcessedExpression): expr is SpELIdentifier =>\n (expr.type === 'property' || expr.type === 'variable' || expr.type === 'compound') &&\n expr.identifier !== null;\nexport const isSpELStringLiteral = (expr: SpELProcessedExpression): expr is SpELStringLiteral =>\n expr.type === 'string';\nexport const isSpELNumericLiteral = (expr: SpELProcessedExpression): expr is SpELNumericLiteral =>\n expr.type === 'number';\nexport const isSpELBooleanLiteral = (expr: SpELProcessedExpression): expr is SpELBooleanLiteral =>\n expr.type === 'boolean';\nexport const isSpELNullLiteral = (expr: SpELProcessedExpression): expr is SpELNullLiteral =>\n expr.type === 'null';\nexport const isSpELRelationOp = (expr: SpELProcessedExpression): expr is SpELRelationOp =>\n expr.type === 'op-eq' ||\n expr.type === 'op-ne' ||\n expr.type === 'op-gt' ||\n expr.type === 'op-ge' ||\n expr.type === 'op-lt' ||\n expr.type === 'op-le';\nexport const isSpELPrimitive = (expr: SpELProcessedExpression): expr is SpELPrimitive =>\n isSpELNumericLiteral(expr) ||\n isSpELStringLiteral(expr) ||\n isSpELBooleanLiteral(expr) ||\n isSpELNullLiteral(expr);\nexport const isSpELBetweenValues = (expr: SpELProcessedExpression): expr is SpELBetweenValues =>\n expr.type === 'between' &&\n isSpELIdentifier(expr.children[0]) &&\n expr.children[1].type === 'list' &&\n expr.children[1].children.length >= 2 &&\n expr.children[1].children.every(c => isSpELPrimitive(c));\nexport const isSpELBetweenFields = (expr: SpELProcessedExpression): expr is SpELBetweenFields =>\n expr.type === 'between' &&\n isSpELIdentifier(expr.children[0]) &&\n expr.children[1].type === 'list' &&\n expr.children[1].children.length >= 2 &&\n expr.children[1].children.every(c => isSpELIdentifier(c));\n\n/** A SpEL arithmetic infix node (`op-plus`/`op-minus`/`op-multiply`/`op-divide`/`op-modulus`). */\nexport const isSpELMathOperation = (expr: SpELProcessedExpression): boolean =>\n expr.type === 'op-plus' ||\n expr.type === 'op-minus' ||\n expr.type === 'op-multiply' ||\n expr.type === 'op-divide' ||\n expr.type === 'op-modulus';\n\n/** A method/function invocation node (`.toUpperCase()`, `T(java.lang.Math).abs(x)`, `myFunc(a)`). */\nexport const isSpELMethodCall = (expr: SpELProcessedExpression): expr is SpELMethodCall =>\n expr.type === 'method' && typeof expr.methodName === 'string';\n\n/**\n * Whether a relation operand should be routed to `getExpression`: an arithmetic infix node or a\n * method/function invocation. Bare identifiers, chains, and literals are not expression operands\n * (they retain their normal handling).\n */\nexport const isSpELExpressionOperand = (expr: SpELProcessedExpression): boolean =>\n isSpELMathOperation(expr) || isSpELMethodCall(expr);\n\nexport const isSpELMethodNode = (expr: SpELBaseNode<SpELNodeType>): expr is SpELMethodNode =>\n expr.getType() === 'method';\n\n/**\n * Builds a {@link SpELMethodCall} from a SpEL `method` node. Arguments are stored on the\n * compiled node's `getRaw()` payload (not as children), so they are processed from there.\n */\nconst processMethodNode = (\n mn: SpELMethodNode,\n target: SpELProcessedExpression | null,\n typeRef: string | null\n): SpELMethodCall => {\n const { methodName, args } = mn.getRaw();\n return {\n type: 'method',\n children: args.map(a => processCompiledExpression(a)),\n startPosition: mn.getStartPosition(),\n endPosition: mn.getEndPosition(),\n value: 'N/A',\n identifier: null,\n methodName,\n target,\n typeRef,\n };\n};\n\n/**\n * Processes a SpEL `compound` node that invokes one or more methods, e.g. `name.toUpperCase()`,\n * `a.b.toLowerCase()`, `(a + b).toUpperCase()`, or `T(java.lang.Math).abs(cost)`. Leading\n * property/variable children are collapsed into a dotted receiver identifier, a leading `typeref`\n * becomes the `typeRef` of the first call, and each subsequent `method` child wraps the previous\n * result as its `target`. Returns `null` for chain shapes that can't be represented.\n */\nconst processMethodChain = (ce: SpELExpressionNode): SpELMethodCall | null => {\n const children = ce.getChildren();\n if (!children.some(c => isSpELMethodNode(c))) {\n return null;\n }\n\n let index = 0;\n let target: SpELProcessedExpression | null = null;\n let typeRef: string | null = null;\n const first = children[0];\n\n if (first.getType() === 'typeref') {\n const qualifiedIdentifier = first.getChildren()[0] as unknown as SpELQualifiedIdentifierNode;\n typeRef = qualifiedIdentifier.getRaw().join('.');\n index = 1;\n } else if (isSpELPropertyNode(first)) {\n const parts: string[] = [];\n while (index < children.length && isSpELPropertyNode(children[index])) {\n parts.push((children[index] as unknown as SpELPropertyNode).getRaw());\n ++index;\n }\n target = {\n type: parts.length > 1 ? 'compound' : first.getType(),\n children: [],\n startPosition: first.getStartPosition(),\n endPosition: children[index - 1].getEndPosition(),\n value: 'N/A',\n identifier: parts.join('.'),\n };\n } else {\n // Arbitrary receiver subtree, e.g. `(a + b).toUpperCase()`\n target = processCompiledExpression(first);\n index = 1;\n }\n\n let result: SpELMethodCall | null = null;\n for (; index < children.length; ++index) {\n const child = children[index];\n if (!isSpELMethodNode(child)) {\n return null;\n }\n result = processMethodNode(child, result ?? target, result ? null : typeRef);\n }\n return result;\n};\n\nexport const processCompiledExpression = (\n ce: SpELPropertyNode | SpELExpressionNode\n): SpELProcessedExpression => {\n const type = ce.getType();\n\n // Bare function calls, e.g. `myFunc(a, b)`\n if (isSpELMethodNode(ce)) {\n return processMethodNode(ce, null, null);\n }\n\n // Method chains, e.g. `name.toUpperCase()` or `T(java.lang.Math).abs(cost)`\n if (type === 'compound' && !isSpELCompoundNode(ce)) {\n const methodChain = processMethodChain(ce);\n if (methodChain) {\n return methodChain;\n }\n }\n\n const identifier = isSpELCompoundNode(ce)\n ? ce\n .getChildren()\n .map(p => (isSpELPropertyNode(p) ? p.getRaw() : /* v8 ignore next -- @preserve */ ''))\n .join('.')\n : isSpELPropertyNode(ce)\n ? ce.getRaw()\n : null;\n const children =\n type === 'compound'\n ? []\n : (isSpELListNode(ce) ? ce.getRaw : ce.getChildren)().map(c => processCompiledExpression(c));\n const startPosition = ce.getStartPosition();\n const endPosition = ce.getEndPosition();\n const value = ce.getValue.length === 0 ? ce.getValue() : 'N/A';\n\n return {\n type: type === 'compound' && !identifier ? 'invalid' : type,\n children,\n startPosition,\n endPosition,\n value,\n identifier,\n };\n};\n\nexport const normalizeOperator = (opType: SpELRelOpType, flip?: boolean): DefaultOperatorName => {\n if (flip) {\n if (opType === 'op-lt') return '>';\n if (opType === 'op-le') return '>=';\n if (opType === 'op-gt') return '<';\n if (opType === 'op-ge') return '<=';\n }\n return (\n {\n 'op-eq': '=',\n 'op-ge': '>=',\n 'op-gt': '>',\n 'op-le': '<=',\n 'op-lt': '<',\n 'op-ne': '!=',\n } as const\n )[opType];\n};\n\nexport const generateFlatAndOrList = (\n expr: SpELProcessedExpression\n): (DefaultCombinatorName | SpELProcessedExpression)[] => {\n const combinator = expr.type.slice(3) as DefaultCombinatorName;\n const [left, right] = expr.children;\n if (left.type === 'op-and' || left.type === 'op-or') {\n return [...generateFlatAndOrList(left), combinator, right];\n }\n return [left, combinator, right];\n};\n\nexport const generateMixedAndOrList = (\n expr: SpELOpAnd | SpELOpOr\n): (DefaultCombinatorName | SpELProcessedExpression | ('and' | SpELProcessedExpression)[])[] => {\n const arr = generateFlatAndOrList(expr);\n const returnArray: (\n | DefaultCombinatorName\n | SpELProcessedExpression\n | ('and' | SpELProcessedExpression)[]\n )[] = [];\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' | SpELProcessedExpression)[];\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 { SpelExpressionEvaluator } from 'spel2js';\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 { joinWith } from '../arrayUtils';\nimport { isRuleGroup } from '../isRuleGroup';\nimport { fieldIsValidUtil, getFieldsArray } from '../parserUtils';\nimport { prepareRuleGroup } from '../prepareQueryObjects';\nimport type {\n ParseSpELExpressionContext,\n SpELExpressionNode,\n SpELExpressionOperand,\n SpELProcessedExpression,\n} from './types';\nimport {\n generateFlatAndOrList,\n generateMixedAndOrList,\n isSpELBetweenFields,\n isSpELBetweenValues,\n isSpELExpressionOperand,\n isSpELIdentifier,\n isSpELOpAnd,\n isSpELOpMatches,\n isSpELOpOr,\n isSpELPrimitive,\n isSpELRelationOp,\n normalizeOperator,\n processCompiledExpression,\n} from './utils';\n\n/**\n * Options object for {@link parseSpEL!parseSpEL}.\n */\nexport interface ParseSpELOptions extends ParserCommonOptions {\n /**\n * Handler that converts a SpEL expression operand subtree into an {@link ExpressionNode}.\n * Return `null` to reject (the rule is dropped). Supplied by `@react-querybuilder/expr`\n * (`expressionParserSpEL`). When omitted, expression operands are ignored (rule dropped).\n *\n * Arithmetic infix operands and method/function invocations\n * (`T(java.lang.Math).abs/min/max(...)`, `.toUpperCase()`/`.toLowerCase()`, and custom calls)\n * are both supported. See {@link SpELExpressionOperand}.\n */\n getExpression?: (\n node: SpELExpressionOperand,\n ctx: ParseSpELExpressionContext\n ) => ExpressionNode | null;\n}\n\n/**\n * Converts a SpEL 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 parseSpEL(spel: string): DefaultRuleGroupType;\n/**\n * Converts a SpEL 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 parseSpEL(\n spel: string,\n options: Except<ParseSpELOptions, 'independentCombinators'> & {\n independentCombinators?: false;\n }\n): DefaultRuleGroupType;\n/**\n * Converts a SpEL 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 parseSpEL(\n spel: string,\n options: Except<ParseSpELOptions, 'independentCombinators'> & {\n independentCombinators: true;\n }\n): DefaultRuleGroupTypeIC;\nfunction parseSpEL(spel: string, options: ParseSpELOptions = {}): DefaultRuleGroupTypeAny {\n const { fields, independentCombinators, listsAsArrays, 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 exprCtx: ParseSpELExpressionContext = {\n fieldExists: fieldName => fieldsFlat.length === 0 || fieldsFlat.some(f => f.name === fieldName),\n };\n\n const emptyQuery: DefaultRuleGroupTypeAny = {\n rules: [],\n ...(ic ? {} : { combinator: 'and' }),\n };\n\n const parseProcessedSpEL = (\n expr: SpELProcessedExpression,\n processOpts: {\n groupOnlyIfNecessary?: boolean;\n forwardNegation?: boolean;\n } = {}\n ): DefaultRuleType | DefaultRuleGroupTypeAny | null => {\n const { forwardNegation: _forwardedNegation, groupOnlyIfNecessary: _g } = processOpts;\n if (expr.type === 'op-not') {\n const negatedExpr = parseProcessedSpEL(expr.children[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: `doesNot${negatedExpr.operator[0].toUpperCase()}${negatedExpr.operator\n .slice(1)\n .replace('s', '')}` as DefaultOperatorName,\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 (isSpELOpAnd(expr) || isSpELOpOr(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 parseProcessedSpEL(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 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 (SpELProcessedExpression | SpELProcessedExpression[])[];\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 => parseProcessedSpEL(e)).filter(Boolean) as DefaultRuleGroupArray,\n };\n }\n return parseProcessedSpEL(exp) as DefaultRuleType | DefaultRuleGroupType | null;\n })\n .filter(Boolean) as DefaultRuleGroupArray;\n // v8 ignore else\n if (rules.length > 0) {\n return { combinator, rules };\n }\n } else if (isSpELOpMatches(expr)) {\n const [left, right] = expr.children;\n let field: string = '';\n let regex: string = '';\n let valueSource: ValueSource | undefined = undefined;\n if (isSpELIdentifier(left)) {\n field = left.identifier;\n if (isSpELIdentifier(right)) {\n regex = right.identifier;\n valueSource = 'field';\n } else {\n // v8 ignore else\n if (isSpELPrimitive(right)) {\n regex = right.value;\n }\n }\n } else {\n // v8 ignore else\n if (isSpELIdentifier(right) && isSpELPrimitive(left)) {\n field = right.identifier;\n regex = left.value;\n }\n }\n\n if (/^(?!\\^).*?(?<!\\$)$/.test(regex)) {\n // v8 ignore else\n if (fieldIsValid(field, 'contains')) {\n return {\n field,\n operator: 'contains',\n value: regex,\n ...(valueSource ? { valueSource } : {}),\n };\n }\n } else {\n if (/^\\^.*?(?<!\\$)$/.test(regex)) {\n // v8 ignore else\n if (fieldIsValid(field, 'beginsWith')) {\n return {\n field,\n operator: 'beginsWith',\n value: regex.replace(/^\\^/, ''),\n };\n }\n } else {\n // v8 ignore else\n if (/^(?!\\^).*?\\$$/.test(regex)) {\n // v8 ignore else\n if (fieldIsValid(field, 'endsWith')) {\n return {\n field,\n operator: 'endsWith',\n value: regex.replace(/\\$$/, ''),\n };\n }\n }\n }\n }\n } else if (isSpELBetweenValues(expr) || isSpELBetweenFields(expr)) {\n // oxlint-disable-next-line typescript/no-explicit-any\n let values: [any, any] = [null, null];\n let valueSource: ValueSource | undefined = undefined;\n const [\n { identifier: field },\n {\n children: [left, right],\n },\n ] = expr.children;\n\n if (isSpELBetweenValues(expr)) {\n values = [left.value, right.value];\n } else {\n values = [left.identifier, right.identifier];\n valueSource = 'field';\n }\n // v8 ignore else\n if (\n field &&\n values.every(v => fieldIsValid(field, 'between', valueSource === 'field' ? v : undefined))\n ) {\n const valueArray =\n values[0] < values[1] || valueSource === 'field' ? values : [values[1], values[0]];\n const value = listsAsArrays ? valueArray : joinWith(valueArray, ',');\n return valueSource\n ? { field, operator: 'between', value, valueSource }\n : { field, operator: 'between', value };\n }\n } else if (isSpELRelationOp(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 [left, right] = expr.children;\n\n // Arithmetic and method/function expression operands (from `@react-querybuilder/expr`)\n if (getExpression) {\n const leftIsExpr = isSpELExpressionOperand(left);\n const rightIsExpr = isSpELExpressionOperand(right);\n if (leftIsExpr || rightIsExpr) {\n const op = (flipOp: boolean) => normalizeOperator(expr.type, flipOp);\n if (leftIsExpr && rightIsExpr) {\n // expression <op> expression → both sides on lhs/value\n const l = getExpression(left, exprCtx);\n const r = getExpression(right, exprCtx);\n return l && r\n ? { field: '', operator: op(false), lhs: l, value: r, valueSource: 'expression' }\n : null;\n }\n if (isSpELIdentifier(left) && rightIsExpr) {\n // field <op> expression → rhs expression\n const node = getExpression(right, exprCtx);\n const f = left.identifier;\n const operator = op(false);\n return node && fieldIsValid(f, operator)\n ? { field: f, operator, value: node, valueSource: 'expression' }\n : null;\n }\n if (leftIsExpr && isSpELIdentifier(right)) {\n // expression <op> field → flip to field <op> expression\n const node = getExpression(left, exprCtx);\n const f = right.identifier;\n const operator = op(true);\n return node && fieldIsValid(f, operator)\n ? { field: f, operator, value: node, valueSource: 'expression' }\n : null;\n }\n if (leftIsExpr && isSpELPrimitive(right)) {\n // expression <op> literal → lhs = expression, literal value\n const l = getExpression(left, exprCtx);\n return l ? { field: '', operator: op(false), lhs: l, value: right.value } : null;\n }\n if (isSpELPrimitive(left)) {\n // literal <op> expression → lhs = expression, flip operator\n const r = getExpression(right, exprCtx);\n return r ? { field: '', operator: op(true), lhs: r, value: left.value } : null;\n }\n }\n }\n\n if (isSpELIdentifier(left)) {\n field = left.identifier;\n if (isSpELIdentifier(right)) {\n value = right.identifier;\n valueSource = 'field';\n } else if (isSpELPrimitive(right)) {\n value = right.value;\n }\n } else {\n // v8 ignore else\n if (isSpELIdentifier(right) && isSpELPrimitive(left)) {\n flip = true;\n field = right.identifier;\n value = left.value;\n }\n }\n let operator = normalizeOperator(expr.type, 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 compiledSpEL: SpELExpressionNode;\n try {\n compiledSpEL = SpelExpressionEvaluator.compile(spel)._compiledExpression;\n } catch {\n return prepare(emptyQuery);\n }\n\n const processedSpEL = processCompiledExpression(compiledSpEL);\n\n const result = parseProcessedSpEL(processedSpEL);\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 { parseSpEL };\n"],"mappings":";;;;;AA2BA,MAAa,sBAAsB,SAA+D;CAChG,OAAO,KAAK,QAAQ,MAAM,cAAc,KAAK,QAAQ,MAAM;AAC7D;AACA,MAAa,sBAAsB,SAA+D;CAChG,OAAO,KAAK,QAAQ,MAAM,cAAc,KAAK,YAAY,CAAC,CAAC,OAAM,MAAK,mBAAmB,CAAC,CAAC;AAC7F;AACA,MAAa,kBAAkB,SAA2D;CACxF,OAAO,KAAK,QAAQ,MAAM;AAC5B;AAEA,MAAa,eAAe,SAC1B,KAAK,SAAS;AAChB,MAAa,cAAc,SACzB,KAAK,SAAS;AAChB,MAAa,mBAAmB,SAC9B,KAAK,SAAS,cACZ,iBAAiB,KAAK,SAAS,EAAE,KAAK,oBAAoB,KAAK,SAAS,EAAE,KACzE,iBAAiB,KAAK,SAAS,EAAE,KAAK,oBAAoB,KAAK,SAAS,EAAE,KAC1E,iBAAiB,KAAK,SAAS,EAAE,KAAK,iBAA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E;IAAO;IAAU;GAAM;EAE5F;EACA,OAAO;CACT;CAEA,MAAM,UAAU,QAAQ,cAAc,oBAAuB,MAAS;CAEtE,IAAI;CACJ,IAAI;EACF,eAAe,wBAAwB,QAAQ,IAAI,CAAC,CAAC;CACvD,QAAQ;EACN,OAAO,QAAQ,UAAU;CAC3B;CAIA,MAAM,SAAS,mBAFO,0BAA0B,YAEF,CAAC;CAC/C,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":"parseSpEL.mjs","names":[],"sources":["../src/utils/parseSpEL/utils.ts","../src/utils/parseSpEL/parseSpEL.ts"],"sourcesContent":["import type { DefaultCombinatorName, DefaultOperatorName } from '../../types';\nimport type {\n SpELBaseNode,\n SpELBetweenFields,\n SpELBetweenValues,\n SpELBooleanLiteral,\n SpELCompoundNode,\n SpELExpressionNode,\n SpELIdentifier,\n SpELListNode,\n SpELMethodCall,\n SpELMethodNode,\n SpELNodeType,\n SpELNullLiteral,\n SpELNumericLiteral,\n SpELOpAnd,\n SpELOpMatches,\n SpELOpOr,\n SpELPrimitive,\n SpELProcessedExpression,\n SpELPropertyNode,\n SpELQualifiedIdentifierNode,\n SpELRelOpType,\n SpELRelation as SpELRelationOp,\n SpELStringLiteral,\n} from './types';\n\nexport const isSpELPropertyNode = (expr: SpELBaseNode<SpELNodeType>): expr is SpELPropertyNode => {\n return expr.getType() === 'property' || expr.getType() === 'variable';\n};\nexport const isSpELCompoundNode = (expr: SpELBaseNode<SpELNodeType>): expr is SpELCompoundNode => {\n return expr.getType() === 'compound' && expr.getChildren().every(c => isSpELPropertyNode(c));\n};\nexport const isSpELListNode = (expr: SpELBaseNode<SpELNodeType>): expr is SpELListNode => {\n return expr.getType() === 'list';\n};\n\nexport const isSpELOpAnd = (expr: SpELProcessedExpression): expr is SpELOpAnd =>\n expr.type === 'op-and';\nexport const isSpELOpOr = (expr: SpELProcessedExpression): expr is SpELOpOr =>\n expr.type === 'op-or';\nexport const isSpELOpMatches = (expr: SpELProcessedExpression): expr is SpELOpMatches =>\n expr.type === 'matches' &&\n ((isSpELIdentifier(expr.children[0]) && isSpELStringLiteral(expr.children[1])) ||\n (isSpELIdentifier(expr.children[1]) && isSpELStringLiteral(expr.children[0])) ||\n (isSpELIdentifier(expr.children[0]) && isSpELIdentifier(expr.children[1])));\nexport const isSpELIdentifier = (expr: SpELProcessedExpression): expr is SpELIdentifier =>\n (expr.type === 'property' || expr.type === 'variable' || expr.type === 'compound') &&\n expr.identifier !== null;\nexport const isSpELStringLiteral = (expr: SpELProcessedExpression): expr is SpELStringLiteral =>\n expr.type === 'string';\nexport const isSpELNumericLiteral = (expr: SpELProcessedExpression): expr is SpELNumericLiteral =>\n expr.type === 'number';\nexport const isSpELBooleanLiteral = (expr: SpELProcessedExpression): expr is SpELBooleanLiteral =>\n expr.type === 'boolean';\nexport const isSpELNullLiteral = (expr: SpELProcessedExpression): expr is SpELNullLiteral =>\n expr.type === 'null';\nexport const isSpELRelationOp = (expr: SpELProcessedExpression): expr is SpELRelationOp =>\n expr.type === 'op-eq' ||\n expr.type === 'op-ne' ||\n expr.type === 'op-gt' ||\n expr.type === 'op-ge' ||\n expr.type === 'op-lt' ||\n expr.type === 'op-le';\nexport const isSpELPrimitive = (expr: SpELProcessedExpression): expr is SpELPrimitive =>\n isSpELNumericLiteral(expr) ||\n isSpELStringLiteral(expr) ||\n isSpELBooleanLiteral(expr) ||\n isSpELNullLiteral(expr);\nexport const isSpELBetweenValues = (expr: SpELProcessedExpression): expr is SpELBetweenValues =>\n expr.type === 'between' &&\n isSpELIdentifier(expr.children[0]) &&\n expr.children[1].type === 'list' &&\n expr.children[1].children.length >= 2 &&\n expr.children[1].children.every(c => isSpELPrimitive(c));\nexport const isSpELBetweenFields = (expr: SpELProcessedExpression): expr is SpELBetweenFields =>\n expr.type === 'between' &&\n isSpELIdentifier(expr.children[0]) &&\n expr.children[1].type === 'list' &&\n expr.children[1].children.length >= 2 &&\n expr.children[1].children.every(c => isSpELIdentifier(c));\n\n/** A SpEL arithmetic infix node (`op-plus`/`op-minus`/`op-multiply`/`op-divide`/`op-modulus`). */\nexport const isSpELMathOperation = (expr: SpELProcessedExpression): boolean =>\n expr.type === 'op-plus' ||\n expr.type === 'op-minus' ||\n expr.type === 'op-multiply' ||\n expr.type === 'op-divide' ||\n expr.type === 'op-modulus';\n\n/** A method/function invocation node (`.toUpperCase()`, `T(java.lang.Math).abs(x)`, `myFunc(a)`). */\nexport const isSpELMethodCall = (expr: SpELProcessedExpression): expr is SpELMethodCall =>\n expr.type === 'method' && typeof expr.methodName === 'string';\n\n/**\n * Whether a relation operand should be routed to `getExpression`: an arithmetic infix node or a\n * method/function invocation. Bare identifiers, chains, and literals are not expression operands\n * (they retain their normal handling).\n */\nexport const isSpELExpressionOperand = (expr: SpELProcessedExpression): boolean =>\n isSpELMathOperation(expr) || isSpELMethodCall(expr);\n\nexport const isSpELMethodNode = (expr: SpELBaseNode<SpELNodeType>): expr is SpELMethodNode =>\n expr.getType() === 'method';\n\n/**\n * Builds a {@link SpELMethodCall} from a SpEL `method` node. Arguments are stored on the\n * compiled node's `getRaw()` payload (not as children), so they are processed from there.\n */\nconst processMethodNode = (\n mn: SpELMethodNode,\n target: SpELProcessedExpression | null,\n typeRef: string | null\n): SpELMethodCall => {\n const { methodName, args } = mn.getRaw();\n return {\n type: 'method',\n children: args.map(a => processCompiledExpression(a)),\n startPosition: mn.getStartPosition(),\n endPosition: mn.getEndPosition(),\n value: 'N/A',\n identifier: null,\n methodName,\n target,\n typeRef,\n };\n};\n\n/**\n * Processes a SpEL `compound` node that invokes one or more methods, e.g. `name.toUpperCase()`,\n * `a.b.toLowerCase()`, `(a + b).toUpperCase()`, or `T(java.lang.Math).abs(cost)`. Leading\n * property/variable children are collapsed into a dotted receiver identifier, a leading `typeref`\n * becomes the `typeRef` of the first call, and each subsequent `method` child wraps the previous\n * result as its `target`. Returns `null` for chain shapes that can't be represented.\n */\nconst processMethodChain = (ce: SpELExpressionNode): SpELMethodCall | null => {\n const children = ce.getChildren();\n if (!children.some(c => isSpELMethodNode(c))) {\n return null;\n }\n\n let index = 0;\n let target: SpELProcessedExpression | null = null;\n let typeRef: string | null = null;\n const first = children[0];\n\n if (first.getType() === 'typeref') {\n const qualifiedIdentifier = first.getChildren()[0] as unknown as SpELQualifiedIdentifierNode;\n typeRef = qualifiedIdentifier.getRaw().join('.');\n index = 1;\n } else if (isSpELPropertyNode(first)) {\n const parts: string[] = [];\n while (index < children.length && isSpELPropertyNode(children[index])) {\n parts.push((children[index] as unknown as SpELPropertyNode).getRaw());\n ++index;\n }\n target = {\n type: parts.length > 1 ? 'compound' : first.getType(),\n children: [],\n startPosition: first.getStartPosition(),\n endPosition: children[index - 1].getEndPosition(),\n value: 'N/A',\n identifier: parts.join('.'),\n };\n } else {\n // Arbitrary receiver subtree, e.g. `(a + b).toUpperCase()`\n target = processCompiledExpression(first);\n index = 1;\n }\n\n let result: SpELMethodCall | null = null;\n for (; index < children.length; ++index) {\n const child = children[index];\n if (!isSpELMethodNode(child)) {\n return null;\n }\n result = processMethodNode(child, result ?? target, result ? null : typeRef);\n }\n return result;\n};\n\nexport const processCompiledExpression = (\n ce: SpELPropertyNode | SpELExpressionNode\n): SpELProcessedExpression => {\n const type = ce.getType();\n\n // Bare function calls, e.g. `myFunc(a, b)`\n if (isSpELMethodNode(ce)) {\n return processMethodNode(ce, null, null);\n }\n\n // Method chains, e.g. `name.toUpperCase()` or `T(java.lang.Math).abs(cost)`\n if (type === 'compound' && !isSpELCompoundNode(ce)) {\n const methodChain = processMethodChain(ce);\n if (methodChain) {\n return methodChain;\n }\n }\n\n const identifier = isSpELCompoundNode(ce)\n ? ce\n .getChildren()\n .map(p => (isSpELPropertyNode(p) ? p.getRaw() : /* v8 ignore next -- @preserve */ ''))\n .join('.')\n : isSpELPropertyNode(ce)\n ? ce.getRaw()\n : null;\n const children =\n type === 'compound'\n ? []\n : (isSpELListNode(ce) ? ce.getRaw : ce.getChildren)().map(c => processCompiledExpression(c));\n const startPosition = ce.getStartPosition();\n const endPosition = ce.getEndPosition();\n const value = ce.getValue.length === 0 ? ce.getValue() : 'N/A';\n\n return {\n type: type === 'compound' && !identifier ? 'invalid' : type,\n children,\n startPosition,\n endPosition,\n value,\n identifier,\n };\n};\n\nexport const normalizeOperator = (opType: SpELRelOpType, flip?: boolean): DefaultOperatorName => {\n if (flip) {\n if (opType === 'op-lt') return '>';\n if (opType === 'op-le') return '>=';\n if (opType === 'op-gt') return '<';\n if (opType === 'op-ge') return '<=';\n }\n return (\n {\n 'op-eq': '=',\n 'op-ge': '>=',\n 'op-gt': '>',\n 'op-le': '<=',\n 'op-lt': '<',\n 'op-ne': '!=',\n } as const\n )[opType];\n};\n\nexport const generateFlatAndOrList = (\n expr: SpELProcessedExpression\n): (DefaultCombinatorName | SpELProcessedExpression)[] => {\n const combinator = expr.type.slice(3) as DefaultCombinatorName;\n const [left, right] = expr.children;\n // SpEL AST has no parenthesis node, so `or` under `and` can only come from an explicit group\n // (`and` binds tighter). Flattening it would lose the grouping.\n const leftWasParenthesized = expr.type === 'op-and' && left.type === 'op-or';\n if (!leftWasParenthesized && (left.type === 'op-and' || left.type === 'op-or')) {\n return [...generateFlatAndOrList(left), combinator, right];\n }\n return [left, combinator, right];\n};\n\nexport const generateMixedAndOrList = (\n expr: SpELOpAnd | SpELOpOr\n): (DefaultCombinatorName | SpELProcessedExpression | ('and' | SpELProcessedExpression)[])[] => {\n const arr = generateFlatAndOrList(expr);\n const returnArray: (\n | DefaultCombinatorName\n | SpELProcessedExpression\n | ('and' | SpELProcessedExpression)[]\n )[] = [];\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' | SpELProcessedExpression)[];\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 { SpelExpressionEvaluator } from 'spel2js';\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 { joinWith } from '../arrayUtils';\nimport { isRuleGroup } from '../isRuleGroup';\nimport { fieldIsValidUtil, getFieldsArray } from '../parserUtils';\nimport { prepareRuleGroup } from '../prepareQueryObjects';\nimport type {\n ParseSpELExpressionContext,\n SpELExpressionNode,\n SpELExpressionOperand,\n SpELProcessedExpression,\n} from './types';\nimport {\n generateFlatAndOrList,\n generateMixedAndOrList,\n isSpELBetweenFields,\n isSpELBetweenValues,\n isSpELExpressionOperand,\n isSpELIdentifier,\n isSpELOpAnd,\n isSpELOpMatches,\n isSpELOpOr,\n isSpELPrimitive,\n isSpELRelationOp,\n normalizeOperator,\n processCompiledExpression,\n} from './utils';\n\n/**\n * Options object for {@link parseSpEL!parseSpEL}.\n */\nexport interface ParseSpELOptions extends ParserCommonOptions {\n /**\n * Handler that converts a SpEL expression operand subtree into an {@link ExpressionNode}.\n * Return `null` to reject (the rule is dropped). Supplied by `@react-querybuilder/expr`\n * (`expressionParserSpEL`). When omitted, expression operands are ignored (rule dropped).\n *\n * Arithmetic infix operands and method/function invocations\n * (`T(java.lang.Math).abs/min/max(...)`, `.toUpperCase()`/`.toLowerCase()`, and custom calls)\n * are both supported. See {@link SpELExpressionOperand}.\n */\n getExpression?: (\n node: SpELExpressionOperand,\n ctx: ParseSpELExpressionContext\n ) => ExpressionNode | null;\n}\n\n/**\n * Converts a SpEL 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 parseSpEL(spel: string): DefaultRuleGroupType;\n/**\n * Converts a SpEL 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 parseSpEL(\n spel: string,\n options: Except<ParseSpELOptions, 'independentCombinators'> & {\n independentCombinators?: false;\n }\n): DefaultRuleGroupType;\n/**\n * Converts a SpEL 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 parseSpEL(\n spel: string,\n options: Except<ParseSpELOptions, 'independentCombinators'> & {\n independentCombinators: true;\n }\n): DefaultRuleGroupTypeIC;\nfunction parseSpEL(spel: string, options: ParseSpELOptions = {}): DefaultRuleGroupTypeAny {\n const { fields, independentCombinators, listsAsArrays, 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 exprCtx: ParseSpELExpressionContext = {\n fieldExists: fieldName => fieldsFlat.length === 0 || fieldsFlat.some(f => f.name === fieldName),\n };\n\n const emptyQuery: DefaultRuleGroupTypeAny = {\n rules: [],\n ...(ic ? {} : { combinator: 'and' }),\n };\n\n const parseProcessedSpEL = (\n expr: SpELProcessedExpression,\n processOpts: {\n groupOnlyIfNecessary?: boolean;\n forwardNegation?: boolean;\n } = {}\n ): DefaultRuleType | DefaultRuleGroupTypeAny | null => {\n const { forwardNegation: _forwardedNegation, groupOnlyIfNecessary: _g } = processOpts;\n if (expr.type === 'op-not') {\n const negatedExpr = parseProcessedSpEL(expr.children[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: `doesNot${negatedExpr.operator[0].toUpperCase()}${negatedExpr.operator\n .slice(1)\n .replace('s', '')}` as DefaultOperatorName,\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 (isSpELOpAnd(expr) || isSpELOpOr(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 parseProcessedSpEL(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 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 (SpELProcessedExpression | SpELProcessedExpression[])[];\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 => parseProcessedSpEL(e)).filter(Boolean) as DefaultRuleGroupArray,\n };\n }\n return parseProcessedSpEL(exp) as DefaultRuleType | DefaultRuleGroupType | null;\n })\n .filter(Boolean) as DefaultRuleGroupArray;\n // v8 ignore else\n if (rules.length > 0) {\n return { combinator, rules };\n }\n } else if (isSpELOpMatches(expr)) {\n const [left, right] = expr.children;\n let field: string = '';\n let regex: string = '';\n let valueSource: ValueSource | undefined = undefined;\n if (isSpELIdentifier(left)) {\n field = left.identifier;\n if (isSpELIdentifier(right)) {\n regex = right.identifier;\n valueSource = 'field';\n } else {\n // v8 ignore else\n if (isSpELPrimitive(right)) {\n regex = right.value;\n }\n }\n } else {\n // v8 ignore else\n if (isSpELIdentifier(right) && isSpELPrimitive(left)) {\n field = right.identifier;\n regex = left.value;\n }\n }\n\n if (/^(?!\\^).*?(?<!\\$)$/.test(regex)) {\n // v8 ignore else\n if (fieldIsValid(field, 'contains')) {\n return {\n field,\n operator: 'contains',\n value: regex,\n ...(valueSource ? { valueSource } : {}),\n };\n }\n } else {\n if (/^\\^.*?(?<!\\$)$/.test(regex)) {\n // v8 ignore else\n if (fieldIsValid(field, 'beginsWith')) {\n return {\n field,\n operator: 'beginsWith',\n value: regex.replace(/^\\^/, ''),\n };\n }\n } else {\n // v8 ignore else\n if (/^(?!\\^).*?\\$$/.test(regex)) {\n // v8 ignore else\n if (fieldIsValid(field, 'endsWith')) {\n return {\n field,\n operator: 'endsWith',\n value: regex.replace(/\\$$/, ''),\n };\n }\n }\n }\n }\n } else if (isSpELBetweenValues(expr) || isSpELBetweenFields(expr)) {\n // oxlint-disable-next-line typescript/no-explicit-any\n let values: [any, any] = [null, null];\n let valueSource: ValueSource | undefined = undefined;\n const [\n { identifier: field },\n {\n children: [left, right],\n },\n ] = expr.children;\n\n if (isSpELBetweenValues(expr)) {\n values = [left.value, right.value];\n } else {\n values = [left.identifier, right.identifier];\n valueSource = 'field';\n }\n // v8 ignore else\n if (\n field &&\n values.every(v => fieldIsValid(field, 'between', valueSource === 'field' ? v : undefined))\n ) {\n const valueArray =\n values[0] < values[1] || valueSource === 'field' ? values : [values[1], values[0]];\n const value = listsAsArrays ? valueArray : joinWith(valueArray, ',');\n return valueSource\n ? { field, operator: 'between', value, valueSource }\n : { field, operator: 'between', value };\n }\n } else if (isSpELRelationOp(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 [left, right] = expr.children;\n\n // Arithmetic and method/function expression operands (from `@react-querybuilder/expr`)\n if (getExpression) {\n const leftIsExpr = isSpELExpressionOperand(left);\n const rightIsExpr = isSpELExpressionOperand(right);\n if (leftIsExpr || rightIsExpr) {\n const op = (flipOp: boolean) => normalizeOperator(expr.type, flipOp);\n if (leftIsExpr && rightIsExpr) {\n // expression <op> expression → both sides on lhs/value\n const l = getExpression(left, exprCtx);\n const r = getExpression(right, exprCtx);\n return l && r\n ? { field: '', operator: op(false), lhs: l, value: r, valueSource: 'expression' }\n : null;\n }\n if (isSpELIdentifier(left) && rightIsExpr) {\n // field <op> expression → rhs expression\n const node = getExpression(right, exprCtx);\n const f = left.identifier;\n const operator = op(false);\n return node && fieldIsValid(f, operator)\n ? { field: f, operator, value: node, valueSource: 'expression' }\n : null;\n }\n if (leftIsExpr && isSpELIdentifier(right)) {\n // expression <op> field → flip to field <op> expression\n const node = getExpression(left, exprCtx);\n const f = right.identifier;\n const operator = op(true);\n return node && fieldIsValid(f, operator)\n ? { field: f, operator, value: node, valueSource: 'expression' }\n : null;\n }\n if (leftIsExpr && isSpELPrimitive(right)) {\n // expression <op> literal → lhs = expression, literal value\n const l = getExpression(left, exprCtx);\n return l ? { field: '', operator: op(false), lhs: l, value: right.value } : null;\n }\n if (isSpELPrimitive(left)) {\n // literal <op> expression → lhs = expression, flip operator\n const r = getExpression(right, exprCtx);\n return r ? { field: '', operator: op(true), lhs: r, value: left.value } : null;\n }\n }\n }\n\n if (isSpELIdentifier(left)) {\n field = left.identifier;\n if (isSpELIdentifier(right)) {\n value = right.identifier;\n valueSource = 'field';\n } else if (isSpELPrimitive(right)) {\n value = right.value;\n }\n } else {\n // v8 ignore else\n if (isSpELIdentifier(right) && isSpELPrimitive(left)) {\n flip = true;\n field = right.identifier;\n value = left.value;\n }\n }\n let operator = normalizeOperator(expr.type, 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 compiledSpEL: SpELExpressionNode;\n try {\n compiledSpEL = SpelExpressionEvaluator.compile(spel)._compiledExpression;\n } catch {\n return prepare(emptyQuery);\n }\n\n const processedSpEL = processCompiledExpression(compiledSpEL);\n\n const result = parseProcessedSpEL(processedSpEL);\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 { parseSpEL };\n"],"mappings":";;;;;;AA2BA,MAAa,sBAAsB,SAA+D;CAChG,OAAO,KAAK,QAAQ,MAAM,cAAc,KAAK,QAAQ,MAAM;AAC7D;AACA,MAAa,sBAAsB,SAA+D;CAChG,OAAO,KAAK,QAAQ,MAAM,cAAc,KAAK,YAAY,CAAC,CAAC,OAAM,MAAK,mBAAmB,CAAC,CAAC;AAC7F;AACA,MAAa,kBAAkB,SAA2D;CACxF,OAAO,KAAK,QAAQ,MAAM;AAC5B;AAEA,MAAa,eAAe,SAC1B,KAAK,SAAS;AAChB,MAAa,cAAc,S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;IACd,QAAQ,KAAK;GACf;GAEF,IAAI,WAAW,kBAAkB,KAAK,MAAM,IAAI;GAChD,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,eAAe,wBAAwB,QAAQ,IAAI,CAAC,CAAC;CACvD,QAAQ;EACN,OAAO,QAAQ,UAAU;CAC3B;CAIA,MAAM,SAAS,mBAFO,0BAA0B,YAEF,CAAC;CAC/C,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"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { F as toFlatOptionArray, I as toFullOption, k as isFlexibleOptionArray } from "./utils-CP5Jqy1P.mjs";
|
|
2
|
+
import { a as getValueSourcesUtil, c as filterFieldsByComparator } from "./prepareQueryObjects-Dmyf3Wi_.mjs";
|
|
3
|
+
//#region src/utils/parserUtils.ts
|
|
4
|
+
const getFieldsArray = (fields) => {
|
|
5
|
+
const fieldsArray = fields ? Array.isArray(fields) ? fields : Object.keys(fields).map((fld) => Object.assign({}, fields[fld], { name: fld })).sort((a, b) => a.label.localeCompare(b.label)) : [];
|
|
6
|
+
return toFlatOptionArray(fieldsArray);
|
|
7
|
+
};
|
|
8
|
+
function fieldIsValidUtil(params) {
|
|
9
|
+
const { fieldsFlat, fieldName, operator, subordinateFieldName, getValueSources } = params;
|
|
10
|
+
const vsIncludes = (vs) => {
|
|
11
|
+
const vss = getValueSourcesUtil(primaryField, operator, getValueSources);
|
|
12
|
+
return isFlexibleOptionArray(vss) && vss.some((vso) => vso.value === vs || vso.name === vs);
|
|
13
|
+
};
|
|
14
|
+
if (fieldsFlat.length === 0) return true;
|
|
15
|
+
let valid = false;
|
|
16
|
+
const primaryField = toFullOption(fieldsFlat.find((ff) => ff.name === fieldName));
|
|
17
|
+
if (primaryField) {
|
|
18
|
+
valid = !(!subordinateFieldName && operator !== "notNull" && operator !== "null" && !vsIncludes("value"));
|
|
19
|
+
if (valid && !!subordinateFieldName) {
|
|
20
|
+
if (vsIncludes("field") && fieldName !== subordinateFieldName) {
|
|
21
|
+
if (!filterFieldsByComparator(primaryField, fieldsFlat, operator).some((vsf) => vsf.name === subordinateFieldName)) valid = false;
|
|
22
|
+
} else valid = false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return valid;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { getFieldsArray as n, fieldIsValidUtil as t };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=parserUtils-BKPstAaO.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parserUtils-BKPstAaO.mjs","names":[],"sources":["../src/utils/parserUtils.ts"],"sourcesContent":["import type {\n DefaultOperatorName,\n FullField,\n FullOption,\n OptionList,\n ValueSource,\n ValueSourceFlexibleOptions,\n ValueSources,\n} from '../types';\nimport { filterFieldsByComparator } from './filterFieldsByComparator';\nimport { getValueSourcesUtil } from './getValueSourcesUtil';\nimport { isFlexibleOptionArray, toFlatOptionArray, toFullOption } from './optGroupUtils';\n\nexport const getFieldsArray = (\n fields?: OptionList<FullField> | Record<string, FullField>\n): FullOption[] => {\n const fieldsArray = fields\n ? Array.isArray(fields)\n ? fields\n : Object.keys(fields)\n .map(fld => Object.assign({}, fields[fld], { name: fld }))\n // oxlint-disable-next-line no-array-sort\n .sort((a, b) => a.label.localeCompare(b.label))\n : [];\n return toFlatOptionArray(fieldsArray);\n};\n\nexport function fieldIsValidUtil(params: {\n fieldsFlat: FullField[];\n getValueSources?: (field: string, operator: string) => ValueSources | ValueSourceFlexibleOptions;\n fieldName: string;\n operator: DefaultOperatorName;\n subordinateFieldName?: string;\n}): boolean {\n const { fieldsFlat, fieldName, operator, subordinateFieldName, getValueSources } = params;\n\n const vsIncludes = (vs: ValueSource) => {\n const vss = getValueSourcesUtil(primaryField, operator, getValueSources);\n return isFlexibleOptionArray(vss) && vss.some(vso => vso.value === vs || vso.name === vs);\n };\n\n // If fields option was an empty array or undefined, then all identifiers\n // are considered valid.\n if (fieldsFlat.length === 0) return true;\n\n let valid = false;\n\n const primaryField = toFullOption(fieldsFlat.find(ff => ff.name === fieldName)!);\n if (primaryField) {\n valid = !(\n !subordinateFieldName &&\n operator !== 'notNull' &&\n operator !== 'null' &&\n !vsIncludes('value')\n );\n\n if (valid && !!subordinateFieldName) {\n if (vsIncludes('field') && fieldName !== subordinateFieldName) {\n const validSubordinateFields = filterFieldsByComparator(\n primaryField,\n fieldsFlat,\n operator\n ) as FullField[];\n if (!validSubordinateFields.some(vsf => vsf.name === subordinateFieldName)) {\n valid = false;\n }\n } else {\n valid = false;\n }\n }\n }\n\n return valid;\n}\n"],"mappings":";;;AAaA,MAAa,kBACX,WACiB;CACjB,MAAM,cAAc,SAChB,MAAM,QAAQ,MAAM,IAClB,SACA,OAAO,KAAK,MAAM,CAAC,CAChB,KAAI,QAAO,OAAO,OAAO,CAAC,GAAG,OAAO,MAAM,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC,CAEzD,MAAM,GAAG,MAAM,EAAE,MAAM,cAAc,EAAE,KAAK,CAAC,IAClD,CAAC;CACL,OAAO,kBAAkB,WAAW;AACtC;AAEA,SAAgB,iBAAiB,QAMrB;CACV,MAAM,EAAE,YAAY,WAAW,UAAU,sBAAsB,oBAAoB;CAEnF,MAAM,cAAc,OAAoB;EACtC,MAAM,MAAM,oBAAoB,cAAc,UAAU,eAAe;EACvE,OAAO,sBAAsB,GAAG,KAAK,IAAI,MAAK,QAAO,IAAI,UAAU,MAAM,IAAI,SAAS,EAAE;CAC1F;CAIA,IAAI,WAAW,WAAW,GAAG,OAAO;CAEpC,IAAI,QAAQ;CAEZ,MAAM,eAAe,aAAa,WAAW,MAAK,OAAM,GAAG,SAAS,SAAS,CAAE;CAC/E,IAAI,cAAc;EAChB,QAAQ,EACN,CAAC,wBACD,aAAa,aACb,aAAa,UACb,CAAC,WAAW,OAAO;EAGrB,IAAI,SAAS,CAAC,CAAC,sBAAsB;GACnC,IAAI,WAAW,OAAO,KAAK,cAAc,sBAMnC;QAAA,CAL2B,yBAC7B,cACA,YACA,QAEwB,CAAC,CAAC,MAAK,QAAO,IAAI,SAAS,oBAAoB,GACvE,QAAQ;GAAA,OAGV,QAAQ;EAEZ;CACF;CAEA,OAAO;AACT"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const require_utils = require("./utils-e-7KHkjV.js");
|
|
2
|
+
const require_prepareQueryObjects = require("./prepareQueryObjects-Dj9cTl9D.js");
|
|
3
|
+
//#region src/utils/parserUtils.ts
|
|
4
|
+
const getFieldsArray = (fields) => {
|
|
5
|
+
const fieldsArray = fields ? Array.isArray(fields) ? fields : Object.keys(fields).map((fld) => Object.assign({}, fields[fld], { name: fld })).sort((a, b) => a.label.localeCompare(b.label)) : [];
|
|
6
|
+
return require_utils.toFlatOptionArray(fieldsArray);
|
|
7
|
+
};
|
|
8
|
+
function fieldIsValidUtil(params) {
|
|
9
|
+
const { fieldsFlat, fieldName, operator, subordinateFieldName, getValueSources } = params;
|
|
10
|
+
const vsIncludes = (vs) => {
|
|
11
|
+
const vss = require_prepareQueryObjects.getValueSourcesUtil(primaryField, operator, getValueSources);
|
|
12
|
+
return require_utils.isFlexibleOptionArray(vss) && vss.some((vso) => vso.value === vs || vso.name === vs);
|
|
13
|
+
};
|
|
14
|
+
if (fieldsFlat.length === 0) return true;
|
|
15
|
+
let valid = false;
|
|
16
|
+
const primaryField = require_utils.toFullOption(fieldsFlat.find((ff) => ff.name === fieldName));
|
|
17
|
+
if (primaryField) {
|
|
18
|
+
valid = !(!subordinateFieldName && operator !== "notNull" && operator !== "null" && !vsIncludes("value"));
|
|
19
|
+
if (valid && !!subordinateFieldName) {
|
|
20
|
+
if (vsIncludes("field") && fieldName !== subordinateFieldName) {
|
|
21
|
+
if (!require_prepareQueryObjects.filterFieldsByComparator(primaryField, fieldsFlat, operator).some((vsf) => vsf.name === subordinateFieldName)) valid = false;
|
|
22
|
+
} else valid = false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return valid;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
Object.defineProperty(exports, "fieldIsValidUtil", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function() {
|
|
31
|
+
return fieldIsValidUtil;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(exports, "getFieldsArray", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function() {
|
|
37
|
+
return getFieldsArray;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=parserUtils-DbBXyAht.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parserUtils-DbBXyAht.js","names":["toFlatOptionArray","getValueSourcesUtil","isFlexibleOptionArray","toFullOption","filterFieldsByComparator"],"sources":["../src/utils/parserUtils.ts"],"sourcesContent":["import type {\n DefaultOperatorName,\n FullField,\n FullOption,\n OptionList,\n ValueSource,\n ValueSourceFlexibleOptions,\n ValueSources,\n} from '../types';\nimport { filterFieldsByComparator } from './filterFieldsByComparator';\nimport { getValueSourcesUtil } from './getValueSourcesUtil';\nimport { isFlexibleOptionArray, toFlatOptionArray, toFullOption } from './optGroupUtils';\n\nexport const getFieldsArray = (\n fields?: OptionList<FullField> | Record<string, FullField>\n): FullOption[] => {\n const fieldsArray = fields\n ? Array.isArray(fields)\n ? fields\n : Object.keys(fields)\n .map(fld => Object.assign({}, fields[fld], { name: fld }))\n // oxlint-disable-next-line no-array-sort\n .sort((a, b) => a.label.localeCompare(b.label))\n : [];\n return toFlatOptionArray(fieldsArray);\n};\n\nexport function fieldIsValidUtil(params: {\n fieldsFlat: FullField[];\n getValueSources?: (field: string, operator: string) => ValueSources | ValueSourceFlexibleOptions;\n fieldName: string;\n operator: DefaultOperatorName;\n subordinateFieldName?: string;\n}): boolean {\n const { fieldsFlat, fieldName, operator, subordinateFieldName, getValueSources } = params;\n\n const vsIncludes = (vs: ValueSource) => {\n const vss = getValueSourcesUtil(primaryField, operator, getValueSources);\n return isFlexibleOptionArray(vss) && vss.some(vso => vso.value === vs || vso.name === vs);\n };\n\n // If fields option was an empty array or undefined, then all identifiers\n // are considered valid.\n if (fieldsFlat.length === 0) return true;\n\n let valid = false;\n\n const primaryField = toFullOption(fieldsFlat.find(ff => ff.name === fieldName)!);\n if (primaryField) {\n valid = !(\n !subordinateFieldName &&\n operator !== 'notNull' &&\n operator !== 'null' &&\n !vsIncludes('value')\n );\n\n if (valid && !!subordinateFieldName) {\n if (vsIncludes('field') && fieldName !== subordinateFieldName) {\n const validSubordinateFields = filterFieldsByComparator(\n primaryField,\n fieldsFlat,\n operator\n ) as FullField[];\n if (!validSubordinateFields.some(vsf => vsf.name === subordinateFieldName)) {\n valid = false;\n }\n } else {\n valid = false;\n }\n }\n }\n\n return valid;\n}\n"],"mappings":";;;AAaA,MAAa,kBACX,WACiB;CACjB,MAAM,cAAc,SAChB,MAAM,QAAQ,MAAM,IAClB,SACA,OAAO,KAAK,MAAM,CAAC,CAChB,KAAI,QAAO,OAAO,OAAO,CAAC,GAAG,OAAO,MAAM,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC,CAEzD,MAAM,GAAG,MAAM,EAAE,MAAM,cAAc,EAAE,KAAK,CAAC,IAClD,CAAC;CACL,OAAOA,cAAAA,kBAAkB,WAAW;AACtC;AAEA,SAAgB,iBAAiB,QAMrB;CACV,MAAM,EAAE,YAAY,WAAW,UAAU,sBAAsB,oBAAoB;CAEnF,MAAM,cAAc,OAAoB;EACtC,MAAM,MAAMC,4BAAAA,oBAAoB,cAAc,UAAU,eAAe;EACvE,OAAOC,cAAAA,sBAAsB,GAAG,KAAK,IAAI,MAAK,QAAO,IAAI,UAAU,MAAM,IAAI,SAAS,EAAE;CAC1F;CAIA,IAAI,WAAW,WAAW,GAAG,OAAO;CAEpC,IAAI,QAAQ;CAEZ,MAAM,eAAeC,cAAAA,aAAa,WAAW,MAAK,OAAM,GAAG,SAAS,SAAS,CAAE;CAC/E,IAAI,cAAc;EAChB,QAAQ,EACN,CAAC,wBACD,aAAa,aACb,aAAa,UACb,CAAC,WAAW,OAAO;EAGrB,IAAI,SAAS,CAAC,CAAC,sBAAsB;GACnC,IAAI,WAAW,OAAO,KAAK,cAAc,sBAMnC;QAAA,CAL2BC,4BAAAA,yBAC7B,cACA,YACA,QAEwB,CAAC,CAAC,MAAK,QAAO,IAAI,SAAS,oBAAoB,GACvE,QAAQ;GAAA,OAGV,QAAQ;EAEZ;CACF;CAEA,OAAO;AACT"}
|