UNPKG

@react-querybuilder/core

Version:

React Query Builder component for constructing queries and filters, with utilities for executing them in various database and evaluation contexts

1 lines 24 kB
{"version":3,"file":"parseSpEL.mjs","names":["returnArray: (\n | DefaultCombinatorName\n | SpELProcessedExpression\n | ('and' | SpELProcessedExpression)[]\n )[]","emptyQuery: DefaultRuleGroupTypeAny","rules","field: string","regex: string","valueSource: ValueSource | undefined","values: [any, any]","field: string | null","value: any","compiledSpEL: SpELExpressionNode"],"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 SpELNodeType,\n SpELNullLiteral,\n SpELNumericLiteral,\n SpELOpAnd,\n SpELOpMatches,\n SpELOpOr,\n SpELPrimitive,\n SpELProcessedExpression,\n SpELPropertyNode,\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';\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\nexport const processCompiledExpression = (\n ce: SpELPropertyNode | SpELExpressionNode\n): SpELProcessedExpression => {\n const type = ce.getType();\n const identifier = isSpELCompoundNode(ce)\n ? ce\n .getChildren()\n .map(p => (isSpELPropertyNode(p) ? p.getRaw() : /* istanbul ignore next */ ''))\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 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 { SpELExpressionNode, SpELProcessedExpression } from './types';\nimport {\n generateFlatAndOrList,\n generateMixedAndOrList,\n isSpELBetweenFields,\n isSpELBetweenValues,\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/**\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 } = options;\n const ic = !!independentCombinators;\n const fieldsFlat = getFieldsArray(fields);\n\n const fieldIsValid = (\n fieldName: string,\n operator: DefaultOperatorName,\n subordinateFieldName?: string\n ) =>\n fieldIsValidUtil({\n fieldName,\n fieldsFlat,\n operator,\n subordinateFieldName,\n getValueSources: options?.getValueSources,\n });\n\n const emptyQuery: DefaultRuleGroupTypeAny = {\n rules: [],\n ...(ic ? {} : { combinator: 'and' }),\n };\n\n const 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 // istanbul 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 // istanbul 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 // istanbul ignore else\n if (isSpELPrimitive(right)) {\n regex = right.value;\n }\n }\n } else {\n // istanbul ignore else\n if (isSpELIdentifier(right) && isSpELPrimitive(left)) {\n field = right.identifier;\n regex = left.value;\n }\n }\n\n if (/^(?!\\^).*?(?<!\\$)$/.test(regex)) {\n // istanbul 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 // istanbul ignore else\n if (fieldIsValid(field, 'beginsWith')) {\n return {\n field,\n operator: 'beginsWith',\n value: regex.replace(/^\\^/, ''),\n };\n }\n } else {\n // istanbul ignore else\n if (/^(?!\\^).*?\\$$/.test(regex)) {\n // istanbul 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 // istanbul 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 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 // istanbul 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":";;;;;;;AAwBA,MAAa,sBAAsB,SAA+D;AAChG,QAAO,KAAK,SAAS,KAAK,cAAc,KAAK,SAAS,KAAK;;AAE7D,MAAa,sBAAsB,SAA+D;AAChG,QAAO,KAAK,SAAS,KAAK,cAAc,KAAK,aAAa,CAAC,OAAM,MAAK,mBAAmB,EAAE,CAAC;;AAE9F,MAAa,kBAAkB,SAA2D;AACxF,QAAO,KAAK,SAAS,KAAK;;AAG5B,MAAa,eAAe,SAC1B,KAAK,SAAS;AAChB,MAAa,cAAc,SACzB,KAAK,SAAS;AAChB,MAAa,mBAAmB,SAC9B,KAAK,SAAS,cACZ,iBAAiB,KAAK,SAAS,GAAG,IAAI,oBAAoB,KAAK,SAAS,GAAG,IAC1E,iBAAiB,KAAK,SAAS,GAAG,IAAI,oBAAoB,KAAK,SAAS,GAAG,IAC3E,iBAAiB,KAAK,SAAS,GAAG,IAAI,iBAAiB,KAAK,SAAS,GAAG;AAC7E,MAAa,oBAAoB,SAC/B,KAAK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