@react-querybuilder/core 8.16.0 → 8.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +43 -4
- package/dist/cjs/react-querybuilder_core.cjs.development.js +182 -18
- package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +43 -4
- 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-BeJJH9BI.mjs.map +1 -1
- package/dist/convertQuery-Lx2HQa0m.js.map +1 -1
- package/dist/formatQuery.d.mts +42 -3
- package/dist/formatQuery.d.ts +42 -3
- package/dist/formatQuery.js +182 -18
- package/dist/formatQuery.js.map +1 -1
- package/dist/formatQuery.mjs +180 -19
- package/dist/formatQuery.mjs.map +1 -1
- package/dist/{import-BHlzBLM_.d.mts → import-BXXgiPlr.d.mts} +2 -2
- package/dist/{import-C6imciDf.d.ts → import-DqzM2MBd.d.ts} +2 -2
- package/dist/{index-D-Iej37L.d.mts → index-CR-tk4Ci.d.mts} +3 -3
- package/dist/{index-Cjapnb-H.d.ts → index-NSVgGj45.d.ts} +3 -3
- package/dist/objectUtils-Bzug_QfX.js.map +1 -1
- package/dist/objectUtils-D96eEEzL.mjs.map +1 -1
- package/dist/parseCEL.d.mts +2 -2
- package/dist/parseCEL.d.ts +2 -2
- package/dist/parseCEL.js.map +1 -1
- package/dist/parseCEL.mjs.map +1 -1
- package/dist/parseCypher.d.mts +1 -1
- package/dist/parseCypher.d.ts +1 -1
- package/dist/parseCypher.js.map +1 -1
- package/dist/parseCypher.mjs.map +1 -1
- package/dist/parseGremlin.d.mts +1 -1
- package/dist/parseGremlin.d.ts +1 -1
- package/dist/parseGremlin.js.map +1 -1
- package/dist/parseGremlin.mjs.map +1 -1
- package/dist/parseJSONata.d.mts +2 -2
- package/dist/parseJSONata.d.ts +2 -2
- package/dist/parseJSONata.js.map +1 -1
- 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.map +1 -1
- package/dist/parseJsonLogic.mjs.map +1 -1
- package/dist/parseMongoDB.d.mts +2 -2
- package/dist/parseMongoDB.d.ts +2 -2
- package/dist/parseMongoDB.js.map +1 -1
- package/dist/parseMongoDB.mjs.map +1 -1
- package/dist/parseSPARQL.d.mts +1 -1
- package/dist/parseSPARQL.d.ts +1 -1
- package/dist/parseSPARQL.js.map +1 -1
- package/dist/parseSPARQL.mjs.map +1 -1
- package/dist/parseSQL.d.mts +2 -2
- package/dist/parseSQL.d.ts +2 -2
- package/dist/parseSQL.js.map +1 -1
- 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.map +1 -1
- package/dist/parseSpEL.mjs.map +1 -1
- package/dist/prepareQueryObjects-BoG5Rt8z.js.map +1 -1
- package/dist/prepareQueryObjects-uA10ZpZX.mjs.map +1 -1
- package/dist/react-querybuilder_core.d.mts +43 -4
- package/dist/react-querybuilder_core.legacy-esm.d.ts +43 -4
- package/dist/react-querybuilder_core.legacy-esm.js +192 -31
- package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
- package/dist/react-querybuilder_core.mjs +180 -19
- package/dist/react-querybuilder_core.mjs.map +1 -1
- package/dist/react-querybuilder_core.production.d.mts +43 -4
- package/dist/react-querybuilder_core.production.mjs +1 -1
- package/dist/react-querybuilder_core.production.mjs.map +1 -1
- package/dist/transformQuery.d.mts +1 -1
- package/dist/transformQuery.d.ts +1 -1
- package/dist/transformQuery.js.map +1 -1
- package/dist/transformQuery.mjs.map +1 -1
- package/dist/utils-ChLG90DP.mjs.map +1 -1
- package/dist/utils-Qwkq2Q0F.js.map +1 -1
- package/package.json +19 -15
package/dist/parseSpEL.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as DefaultRuleGroupType, j as Except, x as DefaultRuleGroupTypeIC } from "./index-
|
|
2
|
-
import { t as ParserCommonOptions } from "./import-
|
|
1
|
+
import { E as DefaultRuleGroupType, j as Except, x as DefaultRuleGroupTypeIC } from "./index-CR-tk4Ci.mjs";
|
|
2
|
+
import { t as ParserCommonOptions } from "./import-BXXgiPlr.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/parseSpEL/parseSpEL.d.ts
|
|
5
5
|
/**
|
package/dist/parseSpEL.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as DefaultRuleGroupType, j as Except, x as DefaultRuleGroupTypeIC } from "./index-
|
|
2
|
-
import { t as ParserCommonOptions } from "./import-
|
|
1
|
+
import { E as DefaultRuleGroupType, j as Except, x as DefaultRuleGroupTypeIC } from "./index-NSVgGj45.js";
|
|
2
|
+
import { t as ParserCommonOptions } from "./import-DqzM2MBd.js";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/parseSpEL/parseSpEL.d.ts
|
|
5
5
|
/**
|
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 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() : /* 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 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 // 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 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":";;;;;;;AAwBA,MAAa,sBAAsB,SAA+D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SAAO,QAAQ;GAAE,OAAO,CAAC,OAAO;GAAE,GAAI,KAAK,EAAE,GAAG,EAAE,YAAY,OAAO;GAAG,CAAC;;AAG3E,QAAO,QAAQ,WAAW"}
|
|
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 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() : /* 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 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 // 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 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":";;;;;;;AAwBA,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,EAAE,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,SAC/B,KAAK,SAAS,cAAc,KAAK,SAAS,cAAc,KAAK,SAAS;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AAK,GAAG;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,EAAE;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"}
|
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 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() : /* 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 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 // 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 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":";;;;;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,SAAS,cAAc,KAAK,SAAS,cAAc,KAAK,SAAS;AACxE,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,KAAK,IAC1B,oBAAoB,KAAK,IACzB,qBAAqB,KAAK,IAC1B,kBAAkB,KAAK;AACzB,MAAa,uBAAuB,SAClC,KAAK,SAAS,aACd,iBAAiB,K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AM,SAAS,mBAFO,0BAA0B,aAED,CAAC;AAChD,KAAI,QAAQ;AACV,MAAI,YAAY,OAAO,CACrB,QAAO,QAAQ,OAAO;AAExB,SAAO,QAAQ;GAAE,OAAO,CAAC,OAAO;GAAE,GAAI,KAAK,EAAE,GAAG,EAAE,YAAY,OAAO;GAAG,CAAC;;AAG3E,QAAO,QAAQ,WAAW"}
|
|
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 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() : /* 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 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 // 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 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":";;;;;AAwBA,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,EAAE,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,SAC/B,KAAK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AAiB,KAAK,GAAG;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,cAAc,oBAAuB,MAAS;CAEtE,IAAI;CACJ,IAAI;EACF,eAAe,wBAAwB,QAAQ,IAAI,EAAE;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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareQueryObjects-BoG5Rt8z.js","names":["toFullOption","isFlexibleOptionGroupArray","toFullOption","isFlexibleOptionArray","toFullOptionList","lc","toFlatOptionArray","isFlexibleOptionArray","toFullOption","processMatchMode","isRuleGroup"],"sources":["../src/utils/filterFieldsByComparator.ts","../src/utils/getValueSourcesUtil.ts","../src/utils/parserUtils.ts","../src/utils/generateID.ts","../src/utils/prepareQueryObjects.ts"],"sourcesContent":["import type { FullField, OptionList, WithUnknownIndex } from '../types';\nimport { isFlexibleOptionGroupArray, toFullOption } from './optGroupUtils';\n\nconst filterByComparator = (field: FullField, operator: string, fieldToCompare: FullField) => {\n const fullField = toFullOption(field);\n const fullFieldToCompare = toFullOption(fieldToCompare);\n if (fullField.value === fullFieldToCompare.value) {\n return false;\n }\n if (typeof fullField.comparator === 'string') {\n return fullField[fullField.comparator] === fullFieldToCompare[fullField.comparator];\n }\n return (\n fullField.comparator?.(fullFieldToCompare, operator) ??\n /* v8 ignore start -- @preserve */ false /* v8 ignore stop -- @preserve */\n );\n};\n\n/**\n * For a given {@link FullField}, returns the `fields` list filtered for\n * other fields that match by `comparator`. Only fields *other than the\n * one in question* will ever be included, even if `comparator` is `null`\n * or `undefined`. If `comparator` is a string, fields with the same value\n * for that property will be included. If `comparator` is a function, each\n * field will be passed to the function along with the `operator` and fields\n * for which the function returns `true` will be included.\n *\n * @group Option Lists\n */\nexport const filterFieldsByComparator = (\n /** The field in question. */\n field: FullField,\n /** The full {@link FullField} list to be filtered. */\n fields: OptionList<FullField>,\n operator: string\n):\n | FullField[]\n | {\n options: WithUnknownIndex<FullField>[];\n label: string;\n }[] => {\n if (!field.comparator) {\n const filterOutSameField = (f: FullField) =>\n (f.value ?? /* v8 ignore start -- @preserve */ f.name) /* v8 ignore stop -- @preserve */ !==\n (field.value ??\n /* v8 ignore start -- @preserve */ field.name) /* v8 ignore stop -- @preserve */;\n if (isFlexibleOptionGroupArray(fields)) {\n return fields.map(og => ({\n ...og,\n options: og.options.filter(v => filterOutSameField(v)),\n }));\n }\n return fields.filter(v => filterOutSameField(v));\n }\n\n if (isFlexibleOptionGroupArray(fields)) {\n return fields\n .map(og => ({\n ...og,\n options: og.options.filter(f => filterByComparator(field, operator, f)),\n }))\n .filter(og => og.options.length > 0);\n }\n\n return fields.filter(f => filterByComparator(field, operator, f));\n};\n","import type {\n FullField,\n GetOptionIdentifierType,\n ValueSourceFlexibleOptions,\n ValueSourceFullOptions,\n ValueSources,\n} from '../types';\nimport { lc } from './misc';\nimport { isFlexibleOptionArray, toFullOption, toFullOptionList } from './optGroupUtils';\n\nconst defaultValueSourcesArray: ValueSourceFullOptions = [\n { name: 'value', value: 'value', label: 'value' },\n];\n\nconst dummyFD = {\n name: 'name',\n value: 'name',\n valueSources: null,\n label: 'label',\n};\n\n/**\n * Utility function to get the value sources array for the given\n * field and operator. If the field definition does not define a\n * `valueSources` property, the `getValueSources` prop is used.\n * Returns `[FullOption<\"value\">]` by default.\n */\n// oxlint-disable-next-line typescript/no-unnecessary-type-parameters\nexport const getValueSourcesUtil = <F extends FullField, O extends string>(\n fieldData: F,\n operator: string,\n getValueSources?: (\n field: GetOptionIdentifierType<F>,\n operator: O,\n misc: { fieldData: F }\n ) => ValueSources | ValueSourceFlexibleOptions\n): ValueSourceFullOptions => {\n // TypeScript doesn't allow it directly, but in practice\n // `fieldData` can end up being undefined or null. The nullish\n // coalescing assignment below avoids errors like\n // \"TypeError: Cannot read properties of undefined (reading 'name')\"\n const fd = fieldData ? toFullOption(fieldData) : dummyFD;\n\n let valueSourcesNEW:\n | false\n | ValueSources\n | ValueSourceFlexibleOptions\n | ((operator: string) => ValueSources | ValueSourceFlexibleOptions) = fd.valueSources ?? false;\n\n if (typeof valueSourcesNEW === 'function') {\n valueSourcesNEW = valueSourcesNEW(operator as O);\n }\n\n if (!valueSourcesNEW && getValueSources) {\n valueSourcesNEW = getValueSources(fd.value as GetOptionIdentifierType<F>, operator as O, {\n fieldData: fd as F,\n });\n }\n\n if (!valueSourcesNEW) {\n return defaultValueSourcesArray;\n }\n\n if (isFlexibleOptionArray(valueSourcesNEW)) {\n return toFullOptionList(valueSourcesNEW as ValueSourceFullOptions) as ValueSourceFullOptions;\n }\n\n return valueSourcesNEW.map(\n vs =>\n defaultValueSourcesArray.find(dmm => dmm.value === lc(vs)) ?? {\n name: vs,\n value: vs,\n label: vs,\n }\n ) as ValueSourceFullOptions;\n};\n","import type {\n DefaultOperatorName,\n FullField,\n FullOption,\n OptionList,\n ValueSource,\n ValueSourceFlexibleOptions,\n ValueSources,\n} from '../types';\nimport { filterFieldsByComparator } from './filterFieldsByComparator';\nimport { getValueSourcesUtil } from './getValueSourcesUtil';\nimport { isFlexibleOptionArray, toFlatOptionArray, toFullOption } from './optGroupUtils';\n\nexport const getFieldsArray = (\n fields?: OptionList<FullField> | Record<string, FullField>\n): FullOption[] => {\n const fieldsArray = fields\n ? Array.isArray(fields)\n ? fields\n : Object.keys(fields)\n .map(fld => Object.assign({}, fields[fld], { name: fld }))\n // oxlint-disable-next-line no-array-sort\n .sort((a, b) => a.label.localeCompare(b.label))\n : [];\n return toFlatOptionArray(fieldsArray);\n};\n\nexport function fieldIsValidUtil(params: {\n fieldsFlat: FullField[];\n getValueSources?: (field: string, operator: string) => ValueSources | ValueSourceFlexibleOptions;\n fieldName: string;\n operator: DefaultOperatorName;\n subordinateFieldName?: string;\n}): boolean {\n const { fieldsFlat, fieldName, operator, subordinateFieldName, getValueSources } = params;\n\n const vsIncludes = (vs: ValueSource) => {\n const vss = getValueSourcesUtil(primaryField, operator, getValueSources);\n return isFlexibleOptionArray(vss) && vss.some(vso => vso.value === vs || vso.name === vs);\n };\n\n // If fields option was an empty array or undefined, then all identifiers\n // are considered valid.\n if (fieldsFlat.length === 0) return true;\n\n let valid = false;\n\n const primaryField = toFullOption(fieldsFlat.find(ff => ff.name === fieldName)!);\n if (primaryField) {\n valid = !(\n !subordinateFieldName &&\n operator !== 'notNull' &&\n operator !== 'null' &&\n !vsIncludes('value')\n );\n\n if (valid && !!subordinateFieldName) {\n if (vsIncludes('field') && fieldName !== subordinateFieldName) {\n const validSubordinateFields = filterFieldsByComparator(\n primaryField,\n fieldsFlat,\n operator\n ) as FullField[];\n if (!validSubordinateFields.some(vsf => vsf.name === subordinateFieldName)) {\n valid = false;\n }\n } else {\n valid = false;\n }\n }\n }\n\n return valid;\n}\n","/* v8 ignore file -- this is fine */\n\ntype UUID = `${string}-${string}-${string}-${string}-${string}`;\n\nconst cryptoModule = globalThis.crypto;\n\nexport const uuidV4regex: RegExp =\n /^[\\da-f]{8}-[\\da-f]{4}-4[\\da-f]{3}-[89ab][\\da-f]{3}-[\\da-f]{12}$/i;\n\n/**\n * Default `id` generator. Generates a valid v4 UUID. Uses `crypto.randomUUID()`\n * when available, otherwise uses an alternate method based on `getRandomValues`.\n * The returned string is guaranteed to match this regex:\n * ```\n * /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i\n * ```\n * @returns Valid v4 UUID\n */\n// Default implementation adapted from https://stackoverflow.com/a/68141099/217579\n// v8 ignore next\nexport let generateID = (): UUID =>\n '00-0-4-2-000'.replaceAll(/[^-]/g, s =>\n (((Math.random() + Math.trunc(s as unknown as number)) * 0x1_00_00) >> Number.parseInt(s))\n .toString(16)\n .padStart(4, '0')\n ) as UUID;\n\n// Improve on the default implementation by using the crypto package if it's available\n// v8 ignore else\nif (cryptoModule) {\n // v8 ignore else\n if (typeof cryptoModule.randomUUID === 'function') {\n generateID = () => cryptoModule.randomUUID();\n } else if (typeof cryptoModule.getRandomValues === 'function') {\n // `randomUUID` is much simpler and faster, but it's only guaranteed to be\n // available in secure contexts (server-side, https, etc.). `generateID`\n // doesn't really need to be cryptographically secure, it only needs a\n // fairly low chance of collisions. We fall back to the always-available\n // `getRandomValues` here (while still generating a valid v4 UUID) when\n // `randomUUID` is not available.\n const position19vals = '89ab';\n const container = new Uint32Array(32);\n\n generateID = () => {\n cryptoModule.getRandomValues(container);\n let id = (container[0] % 16).toString(16);\n for (let i = 1; i < 32; i++) {\n if (i === 12) {\n id = `${id}${'4'}`;\n } else if (i === 16) {\n id = `${id}${position19vals[container[17] % 4]}`;\n } else {\n id = `${id}${(container[i] % 16).toString(16)}`;\n }\n\n if (i === 7 || i === 11 || i === 15 || i === 19) {\n id = `${id}${'-'}`;\n }\n }\n return id as UUID;\n };\n }\n}\n","import type {\n RuleGroupArray,\n RuleGroupICArray,\n RuleGroupType,\n RuleGroupTypeAny,\n RuleGroupTypeIC,\n RuleType,\n} from '../types';\nimport { processMatchMode } from './formatQuery/utils';\nimport { generateID } from './generateID';\nimport { isRuleGroup } from './isRuleGroup';\n\n/**\n * Options for {@link prepareRule}/{@link prepareRuleGroup}.\n */\nexport interface PreparerOptions {\n idGenerator?: () => string;\n}\n\n/**\n * Ensures that a rule is valid by adding an `id` property if it does not already exist.\n */\nexport const prepareRule = (\n rule: RuleType,\n { idGenerator = generateID }: PreparerOptions = {}\n): RuleType => {\n const needsId = !rule.id;\n const hasMatchMode = processMatchMode(rule);\n\n if (!needsId && !hasMatchMode) {\n return rule;\n }\n\n return {\n ...rule,\n ...(needsId && { id: idGenerator() }),\n ...(hasMatchMode && { value: prepareRuleGroup(rule.value, { idGenerator }) }),\n };\n};\n\n/**\n * Ensures that a rule group is valid by recursively adding an `id` property to the group itself\n * and all its rules and subgroups where one does not already exist.\n */\nexport const prepareRuleGroup = <RG extends RuleGroupTypeAny>(\n queryObject: RG,\n { idGenerator = generateID }: PreparerOptions = {}\n): RG => {\n const needsId = !queryObject.id;\n let rulesChanged = false;\n const newRules: (RuleGroupTypeAny | RuleType | string)[] = [];\n\n for (let i = 0; i < queryObject.rules.length; i++) {\n const r = queryObject.rules[i];\n if (typeof r === 'string') {\n newRules.push(r);\n } else {\n const prepared = isRuleGroup(r)\n ? prepareRuleGroup(r, { idGenerator })\n : prepareRule(r, { idGenerator });\n newRules.push(prepared);\n if (prepared !== r) {\n rulesChanged = true;\n }\n }\n }\n\n if (!needsId && !rulesChanged) {\n return queryObject;\n }\n\n return {\n ...queryObject,\n ...(needsId && { id: idGenerator() }),\n rules: newRules as RuleGroupArray | RuleGroupICArray,\n };\n};\n\n/**\n * Ensures that a rule or group is valid. See {@link prepareRule} and {@link prepareRuleGroup}.\n */\nexport const prepareRuleOrGroup = (\n rg: RuleGroupTypeAny | RuleType,\n { idGenerator = generateID }: PreparerOptions =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;;;;AAOH,MAAa,oBACX,aACA,EAAE,cAAc,eAAgC,EAAE,KAC3C;CACP,MAAM,UAAU,CAAC,YAAY;CAC7B,IAAI,eAAe;CACnB,MAAM,WAAqD,EAAE;AAE7D,MAAK,IAAI,IAAI,GAAG,IAAI,YAAY,MAAM,QAAQ,KAAK;EACjD,MAAM,IAAI,YAAY,MAAM;AAC5B,MAAI,OAAO,MAAM,SACf,UAAS,KAAK,EAAE;OACX;GACL,MAAM,WAAWC,oBAAAA,YAAY,EAAE,GAC3B,iBAAiB,GAAG,EAAE,aAAa,CAAC,GACpC,YAAY,GAAG,EAAE,aAAa,CAAC;AACnC,YAAS,KAAK,SAAS;AACvB,OAAI,aAAa,EACf,gBAAe;;;AAKrB,KAAI,CAAC,WAAW,CAAC,aACf,QAAO;AAGT,QAAO;EACL,GAAG;EACH,GAAI,WAAW,EAAE,IAAI,aAAa,EAAE;EACpC,OAAO;EACR"}
|
|
1
|
+
{"version":3,"file":"prepareQueryObjects-BoG5Rt8z.js","names":["toFullOption","isFlexibleOptionGroupArray","toFullOption","isFlexibleOptionArray","toFullOptionList","lc","toFlatOptionArray","isFlexibleOptionArray","toFullOption","processMatchMode","isRuleGroup"],"sources":["../src/utils/filterFieldsByComparator.ts","../src/utils/getValueSourcesUtil.ts","../src/utils/parserUtils.ts","../src/utils/generateID.ts","../src/utils/prepareQueryObjects.ts"],"sourcesContent":["import type { FullField, OptionList, WithUnknownIndex } from '../types';\nimport { isFlexibleOptionGroupArray, toFullOption } from './optGroupUtils';\n\nconst filterByComparator = (field: FullField, operator: string, fieldToCompare: FullField) => {\n const fullField = toFullOption(field);\n const fullFieldToCompare = toFullOption(fieldToCompare);\n if (fullField.value === fullFieldToCompare.value) {\n return false;\n }\n if (typeof fullField.comparator === 'string') {\n return fullField[fullField.comparator] === fullFieldToCompare[fullField.comparator];\n }\n return (\n fullField.comparator?.(fullFieldToCompare, operator) ??\n /* v8 ignore start -- @preserve */ false /* v8 ignore stop -- @preserve */\n );\n};\n\n/**\n * For a given {@link FullField}, returns the `fields` list filtered for\n * other fields that match by `comparator`. Only fields *other than the\n * one in question* will ever be included, even if `comparator` is `null`\n * or `undefined`. If `comparator` is a string, fields with the same value\n * for that property will be included. If `comparator` is a function, each\n * field will be passed to the function along with the `operator` and fields\n * for which the function returns `true` will be included.\n *\n * @group Option Lists\n */\nexport const filterFieldsByComparator = (\n /** The field in question. */\n field: FullField,\n /** The full {@link FullField} list to be filtered. */\n fields: OptionList<FullField>,\n operator: string\n):\n | FullField[]\n | {\n options: WithUnknownIndex<FullField>[];\n label: string;\n }[] => {\n if (!field.comparator) {\n const filterOutSameField = (f: FullField) =>\n (f.value ?? /* v8 ignore start -- @preserve */ f.name) /* v8 ignore stop -- @preserve */ !==\n (field.value ??\n /* v8 ignore start -- @preserve */ field.name) /* v8 ignore stop -- @preserve */;\n if (isFlexibleOptionGroupArray(fields)) {\n return fields.map(og => ({\n ...og,\n options: og.options.filter(v => filterOutSameField(v)),\n }));\n }\n return fields.filter(v => filterOutSameField(v));\n }\n\n if (isFlexibleOptionGroupArray(fields)) {\n return fields\n .map(og => ({\n ...og,\n options: og.options.filter(f => filterByComparator(field, operator, f)),\n }))\n .filter(og => og.options.length > 0);\n }\n\n return fields.filter(f => filterByComparator(field, operator, f));\n};\n","import type {\n FullField,\n GetOptionIdentifierType,\n ValueSourceFlexibleOptions,\n ValueSourceFullOptions,\n ValueSources,\n} from '../types';\nimport { lc } from './misc';\nimport { isFlexibleOptionArray, toFullOption, toFullOptionList } from './optGroupUtils';\n\nconst defaultValueSourcesArray: ValueSourceFullOptions = [\n { name: 'value', value: 'value', label: 'value' },\n];\n\nconst dummyFD = {\n name: 'name',\n value: 'name',\n valueSources: null,\n label: 'label',\n};\n\n/**\n * Utility function to get the value sources array for the given\n * field and operator. If the field definition does not define a\n * `valueSources` property, the `getValueSources` prop is used.\n * Returns `[FullOption<\"value\">]` by default.\n */\n// oxlint-disable-next-line typescript/no-unnecessary-type-parameters\nexport const getValueSourcesUtil = <F extends FullField, O extends string>(\n fieldData: F,\n operator: string,\n getValueSources?: (\n field: GetOptionIdentifierType<F>,\n operator: O,\n misc: { fieldData: F }\n ) => ValueSources | ValueSourceFlexibleOptions\n): ValueSourceFullOptions => {\n // TypeScript doesn't allow it directly, but in practice\n // `fieldData` can end up being undefined or null. The nullish\n // coalescing assignment below avoids errors like\n // \"TypeError: Cannot read properties of undefined (reading 'name')\"\n const fd = fieldData ? toFullOption(fieldData) : dummyFD;\n\n let valueSourcesNEW:\n | false\n | ValueSources\n | ValueSourceFlexibleOptions\n | ((operator: string) => ValueSources | ValueSourceFlexibleOptions) = fd.valueSources ?? false;\n\n if (typeof valueSourcesNEW === 'function') {\n valueSourcesNEW = valueSourcesNEW(operator as O);\n }\n\n if (!valueSourcesNEW && getValueSources) {\n valueSourcesNEW = getValueSources(fd.value as GetOptionIdentifierType<F>, operator as O, {\n fieldData: fd as F,\n });\n }\n\n if (!valueSourcesNEW) {\n return defaultValueSourcesArray;\n }\n\n if (isFlexibleOptionArray(valueSourcesNEW)) {\n return toFullOptionList(valueSourcesNEW as ValueSourceFullOptions) as ValueSourceFullOptions;\n }\n\n return valueSourcesNEW.map(\n vs =>\n defaultValueSourcesArray.find(dmm => dmm.value === lc(vs)) ?? {\n name: vs,\n value: vs,\n label: vs,\n }\n ) as ValueSourceFullOptions;\n};\n","import type {\n DefaultOperatorName,\n FullField,\n FullOption,\n OptionList,\n ValueSource,\n ValueSourceFlexibleOptions,\n ValueSources,\n} from '../types';\nimport { filterFieldsByComparator } from './filterFieldsByComparator';\nimport { getValueSourcesUtil } from './getValueSourcesUtil';\nimport { isFlexibleOptionArray, toFlatOptionArray, toFullOption } from './optGroupUtils';\n\nexport const getFieldsArray = (\n fields?: OptionList<FullField> | Record<string, FullField>\n): FullOption[] => {\n const fieldsArray = fields\n ? Array.isArray(fields)\n ? fields\n : Object.keys(fields)\n .map(fld => Object.assign({}, fields[fld], { name: fld }))\n // oxlint-disable-next-line no-array-sort\n .sort((a, b) => a.label.localeCompare(b.label))\n : [];\n return toFlatOptionArray(fieldsArray);\n};\n\nexport function fieldIsValidUtil(params: {\n fieldsFlat: FullField[];\n getValueSources?: (field: string, operator: string) => ValueSources | ValueSourceFlexibleOptions;\n fieldName: string;\n operator: DefaultOperatorName;\n subordinateFieldName?: string;\n}): boolean {\n const { fieldsFlat, fieldName, operator, subordinateFieldName, getValueSources } = params;\n\n const vsIncludes = (vs: ValueSource) => {\n const vss = getValueSourcesUtil(primaryField, operator, getValueSources);\n return isFlexibleOptionArray(vss) && vss.some(vso => vso.value === vs || vso.name === vs);\n };\n\n // If fields option was an empty array or undefined, then all identifiers\n // are considered valid.\n if (fieldsFlat.length === 0) return true;\n\n let valid = false;\n\n const primaryField = toFullOption(fieldsFlat.find(ff => ff.name === fieldName)!);\n if (primaryField) {\n valid = !(\n !subordinateFieldName &&\n operator !== 'notNull' &&\n operator !== 'null' &&\n !vsIncludes('value')\n );\n\n if (valid && !!subordinateFieldName) {\n if (vsIncludes('field') && fieldName !== subordinateFieldName) {\n const validSubordinateFields = filterFieldsByComparator(\n primaryField,\n fieldsFlat,\n operator\n ) as FullField[];\n if (!validSubordinateFields.some(vsf => vsf.name === subordinateFieldName)) {\n valid = false;\n }\n } else {\n valid = false;\n }\n }\n }\n\n return valid;\n}\n","/* v8 ignore file -- this is fine */\n\ntype UUID = `${string}-${string}-${string}-${string}-${string}`;\n\nconst cryptoModule = globalThis.crypto;\n\nexport const uuidV4regex: RegExp =\n /^[\\da-f]{8}-[\\da-f]{4}-4[\\da-f]{3}-[89ab][\\da-f]{3}-[\\da-f]{12}$/i;\n\n/**\n * Default `id` generator. Generates a valid v4 UUID. Uses `crypto.randomUUID()`\n * when available, otherwise uses an alternate method based on `getRandomValues`.\n * The returned string is guaranteed to match this regex:\n * ```\n * /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i\n * ```\n * @returns Valid v4 UUID\n */\n// Default implementation adapted from https://stackoverflow.com/a/68141099/217579\n// v8 ignore next\nexport let generateID = (): UUID =>\n '00-0-4-2-000'.replaceAll(/[^-]/g, s =>\n (((Math.random() + Math.trunc(s as unknown as number)) * 0x1_00_00) >> Number.parseInt(s))\n .toString(16)\n .padStart(4, '0')\n ) as UUID;\n\n// Improve on the default implementation by using the crypto package if it's available\n// v8 ignore else\nif (cryptoModule) {\n // v8 ignore else\n if (typeof cryptoModule.randomUUID === 'function') {\n generateID = () => cryptoModule.randomUUID();\n } else if (typeof cryptoModule.getRandomValues === 'function') {\n // `randomUUID` is much simpler and faster, but it's only guaranteed to be\n // available in secure contexts (server-side, https, etc.). `generateID`\n // doesn't really need to be cryptographically secure, it only needs a\n // fairly low chance of collisions. We fall back to the always-available\n // `getRandomValues` here (while still generating a valid v4 UUID) when\n // `randomUUID` is not available.\n const position19vals = '89ab';\n const container = new Uint32Array(32);\n\n generateID = () => {\n cryptoModule.getRandomValues(container);\n let id = (container[0] % 16).toString(16);\n for (let i = 1; i < 32; i++) {\n if (i === 12) {\n id = `${id}${'4'}`;\n } else if (i === 16) {\n id = `${id}${position19vals[container[17] % 4]}`;\n } else {\n id = `${id}${(container[i] % 16).toString(16)}`;\n }\n\n if (i === 7 || i === 11 || i === 15 || i === 19) {\n id = `${id}${'-'}`;\n }\n }\n return id as UUID;\n };\n }\n}\n","import type {\n RuleGroupArray,\n RuleGroupICArray,\n RuleGroupType,\n RuleGroupTypeAny,\n RuleGroupTypeIC,\n RuleType,\n} from '../types';\nimport { processMatchMode } from './formatQuery/utils';\nimport { generateID } from './generateID';\nimport { isRuleGroup } from './isRuleGroup';\n\n/**\n * Options for {@link prepareRule}/{@link prepareRuleGroup}.\n */\nexport interface PreparerOptions {\n idGenerator?: () => string;\n}\n\n/**\n * Ensures that a rule is valid by adding an `id` property if it does not already exist.\n */\nexport const prepareRule = (\n rule: RuleType,\n { idGenerator = generateID }: PreparerOptions = {}\n): RuleType => {\n const needsId = !rule.id;\n const hasMatchMode = processMatchMode(rule);\n\n if (!needsId && !hasMatchMode) {\n return rule;\n }\n\n return {\n ...rule,\n ...(needsId && { id: idGenerator() }),\n ...(hasMatchMode && { value: prepareRuleGroup(rule.value, { idGenerator }) }),\n };\n};\n\n/**\n * Ensures that a rule group is valid by recursively adding an `id` property to the group itself\n * and all its rules and subgroups where one does not already exist.\n */\nexport const prepareRuleGroup = <RG extends RuleGroupTypeAny>(\n queryObject: RG,\n { idGenerator = generateID }: PreparerOptions = {}\n): RG => {\n const needsId = !queryObject.id;\n let rulesChanged = false;\n const newRules: (RuleGroupTypeAny | RuleType | string)[] = [];\n\n for (let i = 0; i < queryObject.rules.length; i++) {\n const r = queryObject.rules[i];\n if (typeof r === 'string') {\n newRules.push(r);\n } else {\n const prepared = isRuleGroup(r)\n ? prepareRuleGroup(r, { idGenerator })\n : prepareRule(r, { idGenerator });\n newRules.push(prepared);\n if (prepared !== r) {\n rulesChanged = true;\n }\n }\n }\n\n if (!needsId && !rulesChanged) {\n return queryObject;\n }\n\n return {\n ...queryObject,\n ...(needsId && { id: idGenerator() }),\n rules: newRules as RuleGroupArray | RuleGroupICArray,\n };\n};\n\n/**\n * Ensures that a rule or group is valid. See {@link prepareRule} and {@link prepareRuleGroup}.\n */\nexport const prepareRuleOrGroup = (\n rg: RuleGroupTypeAny | RuleType,\n { idGenerator = generateID }: PreparerOptions = {}\n): RuleGroupType | RuleGroupTypeIC | RuleType =>\n isRuleGroup(rg) ? prepareRuleGroup(rg, { idGenerator }) : prepareRule(rg, { idGenerator });\n"],"mappings":";;;AAGA,MAAM,sBAAsB,OAAkB,UAAkB,mBAA8B;CAC5F,MAAM,YAAYA,cAAAA,aAAa,KAAK;CACpC,MAAM,qBAAqBA,cAAAA,aAAa,cAAc;CACtD,IAAI,UAAU,UAAU,mBAAmB,OACzC,OAAO;CAET,IAAI,OAAO,UAAU,eAAe,UAClC,OAAO,UAAU,UAAU,gBAAgB,mBAAmB,UAAU;CAE1E,OACE,UAAU,aA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B,iBAAiB,GAAG,EAAE,YAAY,CAAC,IACnC,YAAY,GAAG,EAAE,YAAY,CAAC;GAClC,SAAS,KAAK,QAAQ;GACtB,IAAI,aAAa,GACf,eAAe;EAEnB;CACF;CAEA,IAAI,CAAC,WAAW,CAAC,cACf,OAAO;CAGT,OAAO;EACL,GAAG;EACH,GAAI,WAAW,EAAE,IAAI,YAAY,EAAE;EACnC,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareQueryObjects-uA10ZpZX.mjs","names":[],"sources":["../src/utils/filterFieldsByComparator.ts","../src/utils/getValueSourcesUtil.ts","../src/utils/parserUtils.ts","../src/utils/generateID.ts","../src/utils/prepareQueryObjects.ts"],"sourcesContent":["import type { FullField, OptionList, WithUnknownIndex } from '../types';\nimport { isFlexibleOptionGroupArray, toFullOption } from './optGroupUtils';\n\nconst filterByComparator = (field: FullField, operator: string, fieldToCompare: FullField) => {\n const fullField = toFullOption(field);\n const fullFieldToCompare = toFullOption(fieldToCompare);\n if (fullField.value === fullFieldToCompare.value) {\n return false;\n }\n if (typeof fullField.comparator === 'string') {\n return fullField[fullField.comparator] === fullFieldToCompare[fullField.comparator];\n }\n return (\n fullField.comparator?.(fullFieldToCompare, operator) ??\n /* v8 ignore start -- @preserve */ false /* v8 ignore stop -- @preserve */\n );\n};\n\n/**\n * For a given {@link FullField}, returns the `fields` list filtered for\n * other fields that match by `comparator`. Only fields *other than the\n * one in question* will ever be included, even if `comparator` is `null`\n * or `undefined`. If `comparator` is a string, fields with the same value\n * for that property will be included. If `comparator` is a function, each\n * field will be passed to the function along with the `operator` and fields\n * for which the function returns `true` will be included.\n *\n * @group Option Lists\n */\nexport const filterFieldsByComparator = (\n /** The field in question. */\n field: FullField,\n /** The full {@link FullField} list to be filtered. */\n fields: OptionList<FullField>,\n operator: string\n):\n | FullField[]\n | {\n options: WithUnknownIndex<FullField>[];\n label: string;\n }[] => {\n if (!field.comparator) {\n const filterOutSameField = (f: FullField) =>\n (f.value ?? /* v8 ignore start -- @preserve */ f.name) /* v8 ignore stop -- @preserve */ !==\n (field.value ??\n /* v8 ignore start -- @preserve */ field.name) /* v8 ignore stop -- @preserve */;\n if (isFlexibleOptionGroupArray(fields)) {\n return fields.map(og => ({\n ...og,\n options: og.options.filter(v => filterOutSameField(v)),\n }));\n }\n return fields.filter(v => filterOutSameField(v));\n }\n\n if (isFlexibleOptionGroupArray(fields)) {\n return fields\n .map(og => ({\n ...og,\n options: og.options.filter(f => filterByComparator(field, operator, f)),\n }))\n .filter(og => og.options.length > 0);\n }\n\n return fields.filter(f => filterByComparator(field, operator, f));\n};\n","import type {\n FullField,\n GetOptionIdentifierType,\n ValueSourceFlexibleOptions,\n ValueSourceFullOptions,\n ValueSources,\n} from '../types';\nimport { lc } from './misc';\nimport { isFlexibleOptionArray, toFullOption, toFullOptionList } from './optGroupUtils';\n\nconst defaultValueSourcesArray: ValueSourceFullOptions = [\n { name: 'value', value: 'value', label: 'value' },\n];\n\nconst dummyFD = {\n name: 'name',\n value: 'name',\n valueSources: null,\n label: 'label',\n};\n\n/**\n * Utility function to get the value sources array for the given\n * field and operator. If the field definition does not define a\n * `valueSources` property, the `getValueSources` prop is used.\n * Returns `[FullOption<\"value\">]` by default.\n */\n// oxlint-disable-next-line typescript/no-unnecessary-type-parameters\nexport const getValueSourcesUtil = <F extends FullField, O extends string>(\n fieldData: F,\n operator: string,\n getValueSources?: (\n field: GetOptionIdentifierType<F>,\n operator: O,\n misc: { fieldData: F }\n ) => ValueSources | ValueSourceFlexibleOptions\n): ValueSourceFullOptions => {\n // TypeScript doesn't allow it directly, but in practice\n // `fieldData` can end up being undefined or null. The nullish\n // coalescing assignment below avoids errors like\n // \"TypeError: Cannot read properties of undefined (reading 'name')\"\n const fd = fieldData ? toFullOption(fieldData) : dummyFD;\n\n let valueSourcesNEW:\n | false\n | ValueSources\n | ValueSourceFlexibleOptions\n | ((operator: string) => ValueSources | ValueSourceFlexibleOptions) = fd.valueSources ?? false;\n\n if (typeof valueSourcesNEW === 'function') {\n valueSourcesNEW = valueSourcesNEW(operator as O);\n }\n\n if (!valueSourcesNEW && getValueSources) {\n valueSourcesNEW = getValueSources(fd.value as GetOptionIdentifierType<F>, operator as O, {\n fieldData: fd as F,\n });\n }\n\n if (!valueSourcesNEW) {\n return defaultValueSourcesArray;\n }\n\n if (isFlexibleOptionArray(valueSourcesNEW)) {\n return toFullOptionList(valueSourcesNEW as ValueSourceFullOptions) as ValueSourceFullOptions;\n }\n\n return valueSourcesNEW.map(\n vs =>\n defaultValueSourcesArray.find(dmm => dmm.value === lc(vs)) ?? {\n name: vs,\n value: vs,\n label: vs,\n }\n ) as ValueSourceFullOptions;\n};\n","import type {\n DefaultOperatorName,\n FullField,\n FullOption,\n OptionList,\n ValueSource,\n ValueSourceFlexibleOptions,\n ValueSources,\n} from '../types';\nimport { filterFieldsByComparator } from './filterFieldsByComparator';\nimport { getValueSourcesUtil } from './getValueSourcesUtil';\nimport { isFlexibleOptionArray, toFlatOptionArray, toFullOption } from './optGroupUtils';\n\nexport const getFieldsArray = (\n fields?: OptionList<FullField> | Record<string, FullField>\n): FullOption[] => {\n const fieldsArray = fields\n ? Array.isArray(fields)\n ? fields\n : Object.keys(fields)\n .map(fld => Object.assign({}, fields[fld], { name: fld }))\n // oxlint-disable-next-line no-array-sort\n .sort((a, b) => a.label.localeCompare(b.label))\n : [];\n return toFlatOptionArray(fieldsArray);\n};\n\nexport function fieldIsValidUtil(params: {\n fieldsFlat: FullField[];\n getValueSources?: (field: string, operator: string) => ValueSources | ValueSourceFlexibleOptions;\n fieldName: string;\n operator: DefaultOperatorName;\n subordinateFieldName?: string;\n}): boolean {\n const { fieldsFlat, fieldName, operator, subordinateFieldName, getValueSources } = params;\n\n const vsIncludes = (vs: ValueSource) => {\n const vss = getValueSourcesUtil(primaryField, operator, getValueSources);\n return isFlexibleOptionArray(vss) && vss.some(vso => vso.value === vs || vso.name === vs);\n };\n\n // If fields option was an empty array or undefined, then all identifiers\n // are considered valid.\n if (fieldsFlat.length === 0) return true;\n\n let valid = false;\n\n const primaryField = toFullOption(fieldsFlat.find(ff => ff.name === fieldName)!);\n if (primaryField) {\n valid = !(\n !subordinateFieldName &&\n operator !== 'notNull' &&\n operator !== 'null' &&\n !vsIncludes('value')\n );\n\n if (valid && !!subordinateFieldName) {\n if (vsIncludes('field') && fieldName !== subordinateFieldName) {\n const validSubordinateFields = filterFieldsByComparator(\n primaryField,\n fieldsFlat,\n operator\n ) as FullField[];\n if (!validSubordinateFields.some(vsf => vsf.name === subordinateFieldName)) {\n valid = false;\n }\n } else {\n valid = false;\n }\n }\n }\n\n return valid;\n}\n","/* v8 ignore file -- this is fine */\n\ntype UUID = `${string}-${string}-${string}-${string}-${string}`;\n\nconst cryptoModule = globalThis.crypto;\n\nexport const uuidV4regex: RegExp =\n /^[\\da-f]{8}-[\\da-f]{4}-4[\\da-f]{3}-[89ab][\\da-f]{3}-[\\da-f]{12}$/i;\n\n/**\n * Default `id` generator. Generates a valid v4 UUID. Uses `crypto.randomUUID()`\n * when available, otherwise uses an alternate method based on `getRandomValues`.\n * The returned string is guaranteed to match this regex:\n * ```\n * /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i\n * ```\n * @returns Valid v4 UUID\n */\n// Default implementation adapted from https://stackoverflow.com/a/68141099/217579\n// v8 ignore next\nexport let generateID = (): UUID =>\n '00-0-4-2-000'.replaceAll(/[^-]/g, s =>\n (((Math.random() + Math.trunc(s as unknown as number)) * 0x1_00_00) >> Number.parseInt(s))\n .toString(16)\n .padStart(4, '0')\n ) as UUID;\n\n// Improve on the default implementation by using the crypto package if it's available\n// v8 ignore else\nif (cryptoModule) {\n // v8 ignore else\n if (typeof cryptoModule.randomUUID === 'function') {\n generateID = () => cryptoModule.randomUUID();\n } else if (typeof cryptoModule.getRandomValues === 'function') {\n // `randomUUID` is much simpler and faster, but it's only guaranteed to be\n // available in secure contexts (server-side, https, etc.). `generateID`\n // doesn't really need to be cryptographically secure, it only needs a\n // fairly low chance of collisions. We fall back to the always-available\n // `getRandomValues` here (while still generating a valid v4 UUID) when\n // `randomUUID` is not available.\n const position19vals = '89ab';\n const container = new Uint32Array(32);\n\n generateID = () => {\n cryptoModule.getRandomValues(container);\n let id = (container[0] % 16).toString(16);\n for (let i = 1; i < 32; i++) {\n if (i === 12) {\n id = `${id}${'4'}`;\n } else if (i === 16) {\n id = `${id}${position19vals[container[17] % 4]}`;\n } else {\n id = `${id}${(container[i] % 16).toString(16)}`;\n }\n\n if (i === 7 || i === 11 || i === 15 || i === 19) {\n id = `${id}${'-'}`;\n }\n }\n return id as UUID;\n };\n }\n}\n","import type {\n RuleGroupArray,\n RuleGroupICArray,\n RuleGroupType,\n RuleGroupTypeAny,\n RuleGroupTypeIC,\n RuleType,\n} from '../types';\nimport { processMatchMode } from './formatQuery/utils';\nimport { generateID } from './generateID';\nimport { isRuleGroup } from './isRuleGroup';\n\n/**\n * Options for {@link prepareRule}/{@link prepareRuleGroup}.\n */\nexport interface PreparerOptions {\n idGenerator?: () => string;\n}\n\n/**\n * Ensures that a rule is valid by adding an `id` property if it does not already exist.\n */\nexport const prepareRule = (\n rule: RuleType,\n { idGenerator = generateID }: PreparerOptions = {}\n): RuleType => {\n const needsId = !rule.id;\n const hasMatchMode = processMatchMode(rule);\n\n if (!needsId && !hasMatchMode) {\n return rule;\n }\n\n return {\n ...rule,\n ...(needsId && { id: idGenerator() }),\n ...(hasMatchMode && { value: prepareRuleGroup(rule.value, { idGenerator }) }),\n };\n};\n\n/**\n * Ensures that a rule group is valid by recursively adding an `id` property to the group itself\n * and all its rules and subgroups where one does not already exist.\n */\nexport const prepareRuleGroup = <RG extends RuleGroupTypeAny>(\n queryObject: RG,\n { idGenerator = generateID }: PreparerOptions = {}\n): RG => {\n const needsId = !queryObject.id;\n let rulesChanged = false;\n const newRules: (RuleGroupTypeAny | RuleType | string)[] = [];\n\n for (let i = 0; i < queryObject.rules.length; i++) {\n const r = queryObject.rules[i];\n if (typeof r === 'string') {\n newRules.push(r);\n } else {\n const prepared = isRuleGroup(r)\n ? prepareRuleGroup(r, { idGenerator })\n : prepareRule(r, { idGenerator });\n newRules.push(prepared);\n if (prepared !== r) {\n rulesChanged = true;\n }\n }\n }\n\n if (!needsId && !rulesChanged) {\n return queryObject;\n }\n\n return {\n ...queryObject,\n ...(needsId && { id: idGenerator() }),\n rules: newRules as RuleGroupArray | RuleGroupICArray,\n };\n};\n\n/**\n * Ensures that a rule or group is valid. See {@link prepareRule} and {@link prepareRuleGroup}.\n */\nexport const prepareRuleOrGroup = (\n rg: RuleGroupTypeAny | RuleType,\n { idGenerator = generateID }: PreparerOptions = {}\n): RuleGroupType | RuleGroupTypeIC | RuleType =>\n isRuleGroup(rg) ? prepareRuleGroup(rg, { idGenerator }) : prepareRule(rg, { idGenerator });\n"],"mappings":";;;AAGA,MAAM,sBAAsB,OAAkB,UAAkB,mBAA8B;CAC5F,MAAM,YAAY,aAAa,MAAM;CACrC,MAAM,qBAAqB,aAAa,eAAe;AACvD,KAAI,UAAU,UAAU,mBAAmB,MACzC,QAAO;AAET,KAAI,OAAO,UAAU,eAAe,SAClC,QAAO,UAAU,UAAU,gBAAgB,mBAAmB,UAAU;AAE1E,QACE,UAAU,aAAa,oBAAoB,SAAS,IACjB;;;;;;;;;;;;;AAevC,MAAa,4BAEX,OAEA,QACA,aAMS;AACT,KAAI,CAAC,MAAM,YAAY;EACrB,MAAM,sBAAsB,OACzB,EAAE,SAA4C,EAAE,WAChD,MAAM,SAC8B,MAAM;AAC7C,MAAI,2BAA2B,OAAO,CACpC,QAAO,OAAO,KAAI,QAAO;GACvB,GAAG;GACH,SAAS,GAAG,QAAQ,QAAO,MAAK,mBAAmB,EAAE,CAAC;GACvD,EAAE;AAEL,SAAO,OAAO,QAAO,MAAK,mBAAmB,EAAE,CAAC;;AAGlD,KAAI,2BAA2B,OAAO,CACpC,QAAO,OACJ,KAAI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C,MAAK,GAAG,GAAA;;AAGZ,UAAO;;;;;;;;;ACrCb,MAAa,eACX,MACA,EAAE,cAAc,eAAgC,EAAE,KACrC;CACb,MAAM,UAAU,CAAC,KAAK;CACtB,MAAM,eAAe,iBAAiB,KAAK;AAE3C,KAAI,CAAC,WAAW,CAAC,aACf,QAAO;AAGT,QAAO;EACL,GAAG;EACH,GAAI,WAAW,EAAE,IAAI,aAAa,EAAE;EACpC,GAAI,gBAAgB,EAAE,OAAO,iBAAiB,KAAK,OAAO,EAAE,aAAa,CAAC,EAAE;EAC7E;;;;;;AAOH,MAAa,oBACX,aACA,EAAE,cAAc,eAAgC,EAAE,KAC3C;CACP,MAAM,UAAU,CAAC,YAAY;CAC7B,IAAI,eAAe;CACnB,MAAM,WAAqD,EAAE;AAE7D,MAAK,IAAI,IAAI,GAAG,IAAI,YAAY,MAAM,QAAQ,KAAK;EACjD,MAAM,IAAI,YAAY,MAAM;AAC5B,MAAI,OAAO,MAAM,SACf,UAAS,KAAK,EAAE;OACX;GACL,MAAM,WAAW,YAAY,EAAE,GAC3B,iBAAiB,GAAG,EAAE,aAAa,CAAC,GACpC,YAAY,GAAG,EAAE,aAAa,CAAC;AACnC,YAAS,KAAK,SAAS;AACvB,OAAI,aAAa,EACf,gBAAe;;;AAKrB,KAAI,CAAC,WAAW,CAAC,aACf,QAAO;AAGT,QAAO;EACL,GAAG;EACH,GAAI,WAAW,EAAE,IAAI,aAAa,EAAE;EACpC,OAAO;EACR"}
|
|
1
|
+
{"version":3,"file":"prepareQueryObjects-uA10ZpZX.mjs","names":[],"sources":["../src/utils/filterFieldsByComparator.ts","../src/utils/getValueSourcesUtil.ts","../src/utils/parserUtils.ts","../src/utils/generateID.ts","../src/utils/prepareQueryObjects.ts"],"sourcesContent":["import type { FullField, OptionList, WithUnknownIndex } from '../types';\nimport { isFlexibleOptionGroupArray, toFullOption } from './optGroupUtils';\n\nconst filterByComparator = (field: FullField, operator: string, fieldToCompare: FullField) => {\n const fullField = toFullOption(field);\n const fullFieldToCompare = toFullOption(fieldToCompare);\n if (fullField.value === fullFieldToCompare.value) {\n return false;\n }\n if (typeof fullField.comparator === 'string') {\n return fullField[fullField.comparator] === fullFieldToCompare[fullField.comparator];\n }\n return (\n fullField.comparator?.(fullFieldToCompare, operator) ??\n /* v8 ignore start -- @preserve */ false /* v8 ignore stop -- @preserve */\n );\n};\n\n/**\n * For a given {@link FullField}, returns the `fields` list filtered for\n * other fields that match by `comparator`. Only fields *other than the\n * one in question* will ever be included, even if `comparator` is `null`\n * or `undefined`. If `comparator` is a string, fields with the same value\n * for that property will be included. If `comparator` is a function, each\n * field will be passed to the function along with the `operator` and fields\n * for which the function returns `true` will be included.\n *\n * @group Option Lists\n */\nexport const filterFieldsByComparator = (\n /** The field in question. */\n field: FullField,\n /** The full {@link FullField} list to be filtered. */\n fields: OptionList<FullField>,\n operator: string\n):\n | FullField[]\n | {\n options: WithUnknownIndex<FullField>[];\n label: string;\n }[] => {\n if (!field.comparator) {\n const filterOutSameField = (f: FullField) =>\n (f.value ?? /* v8 ignore start -- @preserve */ f.name) /* v8 ignore stop -- @preserve */ !==\n (field.value ??\n /* v8 ignore start -- @preserve */ field.name) /* v8 ignore stop -- @preserve */;\n if (isFlexibleOptionGroupArray(fields)) {\n return fields.map(og => ({\n ...og,\n options: og.options.filter(v => filterOutSameField(v)),\n }));\n }\n return fields.filter(v => filterOutSameField(v));\n }\n\n if (isFlexibleOptionGroupArray(fields)) {\n return fields\n .map(og => ({\n ...og,\n options: og.options.filter(f => filterByComparator(field, operator, f)),\n }))\n .filter(og => og.options.length > 0);\n }\n\n return fields.filter(f => filterByComparator(field, operator, f));\n};\n","import type {\n FullField,\n GetOptionIdentifierType,\n ValueSourceFlexibleOptions,\n ValueSourceFullOptions,\n ValueSources,\n} from '../types';\nimport { lc } from './misc';\nimport { isFlexibleOptionArray, toFullOption, toFullOptionList } from './optGroupUtils';\n\nconst defaultValueSourcesArray: ValueSourceFullOptions = [\n { name: 'value', value: 'value', label: 'value' },\n];\n\nconst dummyFD = {\n name: 'name',\n value: 'name',\n valueSources: null,\n label: 'label',\n};\n\n/**\n * Utility function to get the value sources array for the given\n * field and operator. If the field definition does not define a\n * `valueSources` property, the `getValueSources` prop is used.\n * Returns `[FullOption<\"value\">]` by default.\n */\n// oxlint-disable-next-line typescript/no-unnecessary-type-parameters\nexport const getValueSourcesUtil = <F extends FullField, O extends string>(\n fieldData: F,\n operator: string,\n getValueSources?: (\n field: GetOptionIdentifierType<F>,\n operator: O,\n misc: { fieldData: F }\n ) => ValueSources | ValueSourceFlexibleOptions\n): ValueSourceFullOptions => {\n // TypeScript doesn't allow it directly, but in practice\n // `fieldData` can end up being undefined or null. The nullish\n // coalescing assignment below avoids errors like\n // \"TypeError: Cannot read properties of undefined (reading 'name')\"\n const fd = fieldData ? toFullOption(fieldData) : dummyFD;\n\n let valueSourcesNEW:\n | false\n | ValueSources\n | ValueSourceFlexibleOptions\n | ((operator: string) => ValueSources | ValueSourceFlexibleOptions) = fd.valueSources ?? false;\n\n if (typeof valueSourcesNEW === 'function') {\n valueSourcesNEW = valueSourcesNEW(operator as O);\n }\n\n if (!valueSourcesNEW && getValueSources) {\n valueSourcesNEW = getValueSources(fd.value as GetOptionIdentifierType<F>, operator as O, {\n fieldData: fd as F,\n });\n }\n\n if (!valueSourcesNEW) {\n return defaultValueSourcesArray;\n }\n\n if (isFlexibleOptionArray(valueSourcesNEW)) {\n return toFullOptionList(valueSourcesNEW as ValueSourceFullOptions) as ValueSourceFullOptions;\n }\n\n return valueSourcesNEW.map(\n vs =>\n defaultValueSourcesArray.find(dmm => dmm.value === lc(vs)) ?? {\n name: vs,\n value: vs,\n label: vs,\n }\n ) as ValueSourceFullOptions;\n};\n","import type {\n DefaultOperatorName,\n FullField,\n FullOption,\n OptionList,\n ValueSource,\n ValueSourceFlexibleOptions,\n ValueSources,\n} from '../types';\nimport { filterFieldsByComparator } from './filterFieldsByComparator';\nimport { getValueSourcesUtil } from './getValueSourcesUtil';\nimport { isFlexibleOptionArray, toFlatOptionArray, toFullOption } from './optGroupUtils';\n\nexport const getFieldsArray = (\n fields?: OptionList<FullField> | Record<string, FullField>\n): FullOption[] => {\n const fieldsArray = fields\n ? Array.isArray(fields)\n ? fields\n : Object.keys(fields)\n .map(fld => Object.assign({}, fields[fld], { name: fld }))\n // oxlint-disable-next-line no-array-sort\n .sort((a, b) => a.label.localeCompare(b.label))\n : [];\n return toFlatOptionArray(fieldsArray);\n};\n\nexport function fieldIsValidUtil(params: {\n fieldsFlat: FullField[];\n getValueSources?: (field: string, operator: string) => ValueSources | ValueSourceFlexibleOptions;\n fieldName: string;\n operator: DefaultOperatorName;\n subordinateFieldName?: string;\n}): boolean {\n const { fieldsFlat, fieldName, operator, subordinateFieldName, getValueSources } = params;\n\n const vsIncludes = (vs: ValueSource) => {\n const vss = getValueSourcesUtil(primaryField, operator, getValueSources);\n return isFlexibleOptionArray(vss) && vss.some(vso => vso.value === vs || vso.name === vs);\n };\n\n // If fields option was an empty array or undefined, then all identifiers\n // are considered valid.\n if (fieldsFlat.length === 0) return true;\n\n let valid = false;\n\n const primaryField = toFullOption(fieldsFlat.find(ff => ff.name === fieldName)!);\n if (primaryField) {\n valid = !(\n !subordinateFieldName &&\n operator !== 'notNull' &&\n operator !== 'null' &&\n !vsIncludes('value')\n );\n\n if (valid && !!subordinateFieldName) {\n if (vsIncludes('field') && fieldName !== subordinateFieldName) {\n const validSubordinateFields = filterFieldsByComparator(\n primaryField,\n fieldsFlat,\n operator\n ) as FullField[];\n if (!validSubordinateFields.some(vsf => vsf.name === subordinateFieldName)) {\n valid = false;\n }\n } else {\n valid = false;\n }\n }\n }\n\n return valid;\n}\n","/* v8 ignore file -- this is fine */\n\ntype UUID = `${string}-${string}-${string}-${string}-${string}`;\n\nconst cryptoModule = globalThis.crypto;\n\nexport const uuidV4regex: RegExp =\n /^[\\da-f]{8}-[\\da-f]{4}-4[\\da-f]{3}-[89ab][\\da-f]{3}-[\\da-f]{12}$/i;\n\n/**\n * Default `id` generator. Generates a valid v4 UUID. Uses `crypto.randomUUID()`\n * when available, otherwise uses an alternate method based on `getRandomValues`.\n * The returned string is guaranteed to match this regex:\n * ```\n * /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i\n * ```\n * @returns Valid v4 UUID\n */\n// Default implementation adapted from https://stackoverflow.com/a/68141099/217579\n// v8 ignore next\nexport let generateID = (): UUID =>\n '00-0-4-2-000'.replaceAll(/[^-]/g, s =>\n (((Math.random() + Math.trunc(s as unknown as number)) * 0x1_00_00) >> Number.parseInt(s))\n .toString(16)\n .padStart(4, '0')\n ) as UUID;\n\n// Improve on the default implementation by using the crypto package if it's available\n// v8 ignore else\nif (cryptoModule) {\n // v8 ignore else\n if (typeof cryptoModule.randomUUID === 'function') {\n generateID = () => cryptoModule.randomUUID();\n } else if (typeof cryptoModule.getRandomValues === 'function') {\n // `randomUUID` is much simpler and faster, but it's only guaranteed to be\n // available in secure contexts (server-side, https, etc.). `generateID`\n // doesn't really need to be cryptographically secure, it only needs a\n // fairly low chance of collisions. We fall back to the always-available\n // `getRandomValues` here (while still generating a valid v4 UUID) when\n // `randomUUID` is not available.\n const position19vals = '89ab';\n const container = new Uint32Array(32);\n\n generateID = () => {\n cryptoModule.getRandomValues(container);\n let id = (container[0] % 16).toString(16);\n for (let i = 1; i < 32; i++) {\n if (i === 12) {\n id = `${id}${'4'}`;\n } else if (i === 16) {\n id = `${id}${position19vals[container[17] % 4]}`;\n } else {\n id = `${id}${(container[i] % 16).toString(16)}`;\n }\n\n if (i === 7 || i === 11 || i === 15 || i === 19) {\n id = `${id}${'-'}`;\n }\n }\n return id as UUID;\n };\n }\n}\n","import type {\n RuleGroupArray,\n RuleGroupICArray,\n RuleGroupType,\n RuleGroupTypeAny,\n RuleGroupTypeIC,\n RuleType,\n} from '../types';\nimport { processMatchMode } from './formatQuery/utils';\nimport { generateID } from './generateID';\nimport { isRuleGroup } from './isRuleGroup';\n\n/**\n * Options for {@link prepareRule}/{@link prepareRuleGroup}.\n */\nexport interface PreparerOptions {\n idGenerator?: () => string;\n}\n\n/**\n * Ensures that a rule is valid by adding an `id` property if it does not already exist.\n */\nexport const prepareRule = (\n rule: RuleType,\n { idGenerator = generateID }: PreparerOptions = {}\n): RuleType => {\n const needsId = !rule.id;\n const hasMatchMode = processMatchMode(rule);\n\n if (!needsId && !hasMatchMode) {\n return rule;\n }\n\n return {\n ...rule,\n ...(needsId && { id: idGenerator() }),\n ...(hasMatchMode && { value: prepareRuleGroup(rule.value, { idGenerator }) }),\n };\n};\n\n/**\n * Ensures that a rule group is valid by recursively adding an `id` property to the group itself\n * and all its rules and subgroups where one does not already exist.\n */\nexport const prepareRuleGroup = <RG extends RuleGroupTypeAny>(\n queryObject: RG,\n { idGenerator = generateID }: PreparerOptions = {}\n): RG => {\n const needsId = !queryObject.id;\n let rulesChanged = false;\n const newRules: (RuleGroupTypeAny | RuleType | string)[] = [];\n\n for (let i = 0; i < queryObject.rules.length; i++) {\n const r = queryObject.rules[i];\n if (typeof r === 'string') {\n newRules.push(r);\n } else {\n const prepared = isRuleGroup(r)\n ? prepareRuleGroup(r, { idGenerator })\n : prepareRule(r, { idGenerator });\n newRules.push(prepared);\n if (prepared !== r) {\n rulesChanged = true;\n }\n }\n }\n\n if (!needsId && !rulesChanged) {\n return queryObject;\n }\n\n return {\n ...queryObject,\n ...(needsId && { id: idGenerator() }),\n rules: newRules as RuleGroupArray | RuleGroupICArray,\n };\n};\n\n/**\n * Ensures that a rule or group is valid. See {@link prepareRule} and {@link prepareRuleGroup}.\n */\nexport const prepareRuleOrGroup = (\n rg: RuleGroupTypeAny | RuleType,\n { idGenerator = generateID }: PreparerOptions = {}\n): RuleGroupType | RuleGroupTypeIC | RuleType =>\n isRuleGroup(rg) ? prepareRuleGroup(rg, { idGenerator }) : prepareRule(rg, { idGenerator });\n"],"mappings":";;;AAGA,MAAM,sBAAsB,OAAkB,UAAkB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K;EACjD,MAAM,IAAI,YAAY,MAAM;EAC5B,IAAI,OAAO,MAAM,UACf,SAAS,KAAK,CAAC;OACV;GACL,MAAM,WAAW,YAAY,CAAC,IAC1B,iBAAiB,GAAG,EAAE,YAAY,CAAC,IACnC,YAAY,GAAG,EAAE,YAAY,CAAC;GAClC,SAAS,KAAK,QAAQ;GACtB,IAAI,aAAa,GACf,eAAe;EAEnB;CACF;CAEA,IAAI,CAAC,WAAW,CAAC,cACf,OAAO;CAGT,OAAO;EACL,GAAG;EACH,GAAI,WAAW,EAAE,IAAI,YAAY,EAAE;EACnC,OAAO;CACT;AACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { JsonLogicAll, JsonLogicAnd, JsonLogicDoubleNegation, JsonLogicEqual, JsonLogicGreaterThan, JsonLogicGreaterThanOrEqual, JsonLogicInArray, JsonLogicInString, JsonLogicLessThan, JsonLogicLessThanOrEqual, JsonLogicNegation, JsonLogicNone, JsonLogicNotEqual, JsonLogicOr, JsonLogicSome, JsonLogicStrictEqual, JsonLogicStrictNotEqual, JsonLogicVar, ReservedOperations as JsonLogicReservedOperations, RulesLogic, RulesLogic as JsonLogicRulesLogic } from "json-logic-js";
|
|
2
2
|
import { Column, Operators, SQL, Table } from "drizzle-orm";
|
|
3
3
|
import { WhereOptions } from "sequelize";
|
|
4
|
+
import { eq } from "@tanstack/db";
|
|
4
5
|
|
|
5
6
|
//#region ../../node_modules/type-fest/source/primitive.d.ts
|
|
6
7
|
/**
|
|
@@ -1748,7 +1749,7 @@ interface DropCollection {
|
|
|
1748
1749
|
*
|
|
1749
1750
|
* @group Export
|
|
1750
1751
|
*/
|
|
1751
|
-
type ExportFormat = "json" | "sql" | "json_without_ids" | "parameterized" | "parameterized_named" | "mongodb" | "mongodb_query" | "cel" | "jsonlogic" | "spel" | "elasticsearch" | "jsonata" | "natural_language" | "ldap" | "drizzle" | "prisma" | "sequelize" | "cypher" | "gql" | "sparql" | "gremlin" | "diagnostics";
|
|
1752
|
+
type ExportFormat = "json" | "sql" | "json_without_ids" | "parameterized" | "parameterized_named" | "mongodb" | "mongodb_query" | "cel" | "jsonlogic" | "spel" | "elasticsearch" | "jsonata" | "natural_language" | "ldap" | "drizzle" | "tanstack_db" | "prisma" | "sequelize" | "cypher" | "gql" | "sparql" | "gremlin" | "diagnostics";
|
|
1752
1753
|
/**
|
|
1753
1754
|
* Export formats for {@link formatQuery} that produce objects instead of strings.
|
|
1754
1755
|
*
|
|
@@ -2334,7 +2335,7 @@ type GroupVariantCondition = "not" | "xor";
|
|
|
2334
2335
|
*
|
|
2335
2336
|
* @group Export
|
|
2336
2337
|
*/
|
|
2337
|
-
type NLTranslationKey = "and" | "or" | "true" | "false" | `groupPrefix${ZeroOrMoreGroupVariants}` | `groupSuffix${ZeroOrMoreGroupVariants}`;
|
|
2338
|
+
type NLTranslationKey = "and" | "or" | "true" | "false" | "ruleSeparator" | "betweenAnd" | "afterSubject" | "afterVerb" | "afterObject" | "listSeparator" | `groupPrefix${ZeroOrMoreGroupVariants}` | `groupSuffix${ZeroOrMoreGroupVariants}`;
|
|
2338
2339
|
/**
|
|
2339
2340
|
* `translations` config object for "natural_language" format.
|
|
2340
2341
|
*
|
|
@@ -3303,6 +3304,23 @@ declare const defaultRuleGroupProcessorSpEL: RuleGroupProcessor<string>;
|
|
|
3303
3304
|
*/
|
|
3304
3305
|
declare const defaultRuleGroupProcessorSQL: RuleGroupProcessor<string>;
|
|
3305
3306
|
//#endregion
|
|
3307
|
+
//#region src/utils/formatQuery/tanStackDbTypes.d.ts
|
|
3308
|
+
type TanStackDbWhereCallbackReturnType = ReturnType<typeof eq>;
|
|
3309
|
+
type TanStackDbWhereCallback = (refs: Record<string, unknown>) => TanStackDbWhereCallbackReturnType;
|
|
3310
|
+
//#endregion
|
|
3311
|
+
//#region src/utils/formatQuery/defaultRuleGroupProcessorTanStackDB.d.ts
|
|
3312
|
+
/**
|
|
3313
|
+
* Default rule group processor used by {@link formatQuery} for the "tanstack_db" format.
|
|
3314
|
+
* Returns a `WhereCallback` suitable for TanStack DB's `.where()` method.
|
|
3315
|
+
*
|
|
3316
|
+
* @example
|
|
3317
|
+
* const where = formatQuery(query, { format: 'tanstack_db', context: { tanstackDb: tsdb } });
|
|
3318
|
+
* const results = useLiveQuery(q => q.from({ todo: todosCollection }).where(where));
|
|
3319
|
+
*
|
|
3320
|
+
* @group Export
|
|
3321
|
+
*/
|
|
3322
|
+
declare const defaultRuleGroupProcessorTanStackDB: RuleGroupProcessor<TanStackDbWhereCallback>;
|
|
3323
|
+
//#endregion
|
|
3306
3324
|
//#region src/utils/formatQuery/defaultRuleGroupProcessorDiagnostics.d.ts
|
|
3307
3325
|
/**
|
|
3308
3326
|
* Rule group processor used by {@link formatQuery} for "diagnostics" format.
|
|
@@ -3428,6 +3446,11 @@ declare const defaultRuleProcessorPrisma: RuleProcessor;
|
|
|
3428
3446
|
declare const defaultRuleProcessorSequelize: RuleProcessor;
|
|
3429
3447
|
//#endregion
|
|
3430
3448
|
//#region src/utils/formatQuery/defaultRuleProcessorSPARQL.d.ts
|
|
3449
|
+
/** Auto-prefix a SPARQL variable name with `?` unless it's already prefixed, a URI, or a prefixed name.
|
|
3450
|
+
*
|
|
3451
|
+
* @group Export
|
|
3452
|
+
*/
|
|
3453
|
+
declare const sparqlVar: (name: string) => string;
|
|
3431
3454
|
/**
|
|
3432
3455
|
* Default rule processor used by {@link formatQuery} for "sparql" format.
|
|
3433
3456
|
*
|
|
@@ -3449,6 +3472,14 @@ declare const defaultOperatorProcessorSQL: RuleProcessor;
|
|
|
3449
3472
|
*/
|
|
3450
3473
|
declare const defaultRuleProcessorSQL: RuleProcessor;
|
|
3451
3474
|
//#endregion
|
|
3475
|
+
//#region src/utils/formatQuery/defaultRuleProcessorTanStackDB.d.ts
|
|
3476
|
+
/**
|
|
3477
|
+
* Default rule processor used by {@link formatQuery} for the "tanstack_db" format.
|
|
3478
|
+
*
|
|
3479
|
+
* @group Export
|
|
3480
|
+
*/
|
|
3481
|
+
declare const defaultRuleProcessorTanStackDB: RuleProcessor;
|
|
3482
|
+
//#endregion
|
|
3452
3483
|
//#region src/utils/formatQuery/defaultValueProcessorNL.d.ts
|
|
3453
3484
|
/**
|
|
3454
3485
|
* Default value processor used by {@link formatQuery} for "natural_language" format.
|
|
@@ -3562,7 +3593,15 @@ declare function formatQuery(ruleGroup: RuleGroupTypeAny, options: "drizzle" | (
|
|
|
3562
3593
|
format: "drizzle";
|
|
3563
3594
|
})): ReturnType<typeof defaultRuleGroupProcessorDrizzle>;
|
|
3564
3595
|
/**
|
|
3565
|
-
* Generates a
|
|
3596
|
+
* Generates a TanStack DB WhereCallback from an RQB query object. The callback can
|
|
3597
|
+
* be passed directly to TanStack DB's `.where()` method.
|
|
3598
|
+
*
|
|
3599
|
+
* @group Export
|
|
3600
|
+
*/
|
|
3601
|
+
declare function formatQuery(ruleGroup: RuleGroupTypeAny, options: "tanstack_db" | (FormatQueryOptions & {
|
|
3602
|
+
format: "tanstack_db";
|
|
3603
|
+
})): ReturnType<typeof defaultRuleGroupProcessorTanStackDB>;
|
|
3604
|
+
/**
|
|
3566
3605
|
* be assigned to the `where` property in the Sequelize query functions.
|
|
3567
3606
|
*
|
|
3568
3607
|
* @group Export
|
|
@@ -4634,5 +4673,5 @@ declare function transformQuery(query: RuleGroupType, options?: TransformQueryOp
|
|
|
4634
4673
|
*/
|
|
4635
4674
|
declare function transformQuery(query: RuleGroupTypeIC, options?: TransformQueryOptions<RuleGroupTypeIC>): any;
|
|
4636
4675
|
//#endregion
|
|
4637
|
-
export { AccessibleDescriptionGenerator, ActionElementEventHandler, AddMethod, AddOptions, Arity, BaseFullOption, BaseOption, BaseOptionMap, BaseTranslation, BaseTranslationWithLabel, BaseTranslationWithPlaceholders, BaseTranslations, BaseTranslationsFull, Classname, Classnames, Combinator, CombinatorByValue, CommonRuleAndGroupProperties, CommonRuleSubComponentProps, ConstituentWordOrder, ConstituentWordOrderString, DefaultCombinator, DefaultCombinatorExtended, DefaultCombinatorName, DefaultCombinatorNameExtended, DefaultCombinators, DefaultCombinatorsExtended, DefaultMatchModes, DefaultOperator, DefaultOperatorName, DefaultOperators, DefaultRuleGroupArray, DefaultRuleGroupICArray, DefaultRuleGroupType, DefaultRuleGroupTypeAny, DefaultRuleGroupTypeIC, DefaultRuleOrGroupArray, DefaultRuleType, DiagnosticEntry, DiagnosticsFieldSummaryEntry, DiagnosticsResult, DiagnosticsStats, DndDropTargetType, DragCollection, DraggedItem, DropCollection, DropEffect, DropResult, ExportFormat, ExportObjectFormats, ExportOperatorMap, Field, FieldByValue, FindPathReturnType, FlexibleOption, FlexibleOptionGroup, FlexibleOptionList, FlexibleOptionListProp, FormatQueryFinalOptions, FormatQueryOptions, FormatQueryValidateRule, FullCombinator, FullField, FullOperator, FullOption, FullOptionList, FullOptionMap, FullOptionRecord, GenericizeRuleGroupType, GetOptionIdentifierType, GetOptionType, GetRuleGroupType, GetRuleTypeFromGroupWithFieldAndOperator, GroupMethod, GroupOptions, GroupVariantCondition, InputType, InsertMethod, InsertOptions, type JsonLogicAll, type JsonLogicAnd, type JsonLogicDoubleNegation, type JsonLogicEqual, type JsonLogicGreaterThan, type JsonLogicGreaterThanOrEqual, type JsonLogicInArray, type JsonLogicInString, type JsonLogicLessThan, type JsonLogicLessThanOrEqual, type JsonLogicNegation, type JsonLogicNone, type JsonLogicNotEqual, type JsonLogicOr, type JsonLogicReservedOperations, type JsonLogicRulesLogic, type JsonLogicSome, type JsonLogicStrictEqual, type JsonLogicStrictNotEqual, type JsonLogicVar, LogType, MatchConfig, MatchMode, MatchModeOptions, MoveMethod, MoveOptions, NLTranslationKey, NLTranslations, NameLabelPair, Operator, OperatorByValue, Option, OptionGroup, OptionList, ParameterizedNamedSQL, ParameterizedSQL, ParseNumberMethod, ParseNumberOptions, ParseNumbersPropConfig, Path, Placeholder, PrepareOptionListParams, PreparedOptionList, PreparerOptions, QueryActions, QueryBuilderFlags, QueryValidator, RQBJsonLogic, RQBJsonLogicEndsWith, RQBJsonLogicStartsWith, RQBJsonLogicVar, RegenerateIdOptions, RemoveMethod, RemoveNullability, RuleDiagnosticsResult, RuleGroupArray, RuleGroupDiagnosticsArray, RuleGroupDiagnosticsResult, RuleGroupICArray, RuleGroupICDiagnosticsArray, RuleGroupICDiagnosticsResult, RuleGroupProcessor, RuleGroupType, RuleGroupTypeAny, RuleGroupTypeIC, RuleOrGroupArray, RuleProcessor, RuleType, RuleValidator, SQLPreset, StringUnionToFlexibleOptionArray, StringUnionToFullOptionArray, TestID, ToFlexibleOption, ToFullOption, ToRuleGroupType, ToRuleGroupTypeIC, TransformQueryOptions, UpdateMethod, UpdateOptions, UpdateableProperties, ValidationMap, ValidationResult, ValueChangeEventHandler, ValueEditorType, ValueOption, ValueProcessor, ValueProcessorByRule, ValueProcessorLegacy, ValueProcessorOptions, ValueSource, ValueSourceFlexibleOptions, ValueSourceFullOptions, ValueSources, WithRequired, WithUnknownIndex, add, addInPlace, bigIntJsonParseReviver, bigIntJsonStringifyReplacer, celCombinatorMap, clsx, convertFromIC, convertQuery, convertToIC, cypherCombinatorMap, defaultCELValueProcessor, defaultCombinatorLabelMap, defaultCombinators, defaultCombinatorsExtended, defaultControlClassnames, defaultExportOperatorMap, defaultJoinChar, defaultMatchModes, defaultMongoDBValueProcessor, defaultNLTranslations, defaultOperatorLabelMap, defaultOperatorNegationMap, defaultOperatorProcessorNL, defaultOperatorProcessorSQL, defaultOperators, defaultPlaceholderFieldGroupLabel, defaultPlaceholderFieldLabel, defaultPlaceholderFieldName, defaultPlaceholderLabel, defaultPlaceholderName, defaultPlaceholderOperatorGroupLabel, defaultPlaceholderOperatorLabel, defaultPlaceholderOperatorName, defaultPlaceholderValueGroupLabel, defaultPlaceholderValueLabel, defaultPlaceholderValueName, defaultRuleGroupProcessorCEL, defaultRuleGroupProcessorCypher, defaultRuleGroupProcessorDiagnostics, defaultRuleGroupProcessorDrizzle, defaultRuleGroupProcessorElasticSearch, defaultRuleGroupProcessorGremlin, defaultRuleGroupProcessorJSONata, defaultRuleGroupProcessorJsonLogic, defaultRuleGroupProcessorLDAP, defaultRuleGroupProcessorMongoDB, defaultRuleGroupProcessorMongoDBQuery, defaultRuleGroupProcessorNL, defaultRuleGroupProcessorParameterized, defaultRuleGroupProcessorPrisma, defaultRuleGroupProcessorSPARQL, defaultRuleGroupProcessorSQL, defaultRuleGroupProcessorSequelize, defaultRuleGroupProcessorSpEL, defaultRuleProcessorCEL, defaultRuleProcessorCypher, defaultRuleProcessorDrizzle, defaultRuleProcessorElasticSearch, defaultRuleProcessorGremlin, defaultRuleProcessorJSONata, defaultRuleProcessorJsonLogic, defaultRuleProcessorLDAP, defaultRuleProcessorMongoDB, defaultRuleProcessorMongoDBQuery, defaultRuleProcessorNL, defaultRuleProcessorParameterized, defaultRuleProcessorPrisma, defaultRuleProcessorSPARQL, defaultRuleProcessorSQL, defaultRuleProcessorSequelize, defaultRuleProcessorSpEL, defaultSpELValueProcessor, defaultTranslations, defaultValidator, defaultValueProcessor, defaultValueProcessorByRule, defaultValueProcessorCELByRule, defaultValueProcessorMongoDBByRule, defaultValueProcessorNL, defaultValueProcessorSpELByRule, filterFieldsByComparator, findID, findPath, formatQuery, formatQueryOptionPresets, generateAccessibleDescription, generateID, getCommonAncestorPath, getFirstOption, getMatchModesUtil, getNLTranslataion, getOption, getParentPath, getParseNumberMethod, getPathOfID, getQuoteFieldNamesWithArray, getQuotedFieldName, getValidationClassNames, getValueSourcesUtil, group, groupInPlace, groupInvalidReasons, insert, insertInPlace, isAncestor, isFlexibleOptionArray, isFlexibleOptionGroupArray, isFullOptionArray, isFullOptionGroupArray, isOptionGroupArray, isPojo, isRuleGroup, isRuleGroupType, isRuleGroupTypeIC, isRuleOrGroupValid, isRuleType, isUnsafeKey, isValidValue, isValidationResult, isValueProcessorLegacy, joinWith, jsonLogicAdditionalOperators, lc, mapSQLOperator, mergeAnyTranslation, mergeAnyTranslations, mergeClassnames, mongoDbFallback, mongoOperators, move, moveInPlace, normalizeConstituentWordOrder, nullFreeArray, nullOrUndefinedOrEmpty, numericRegex, numerifyValues, objectEntries, objectKeys, parseNumber, pathIsDisabled, pathsAreEqual, preferAnyProp, preferFlagProps, preferProp, prepareOptionList, prepareRule, prepareRuleGroup, prepareRuleOrGroup, prismaFallback, prismaOperators, processMatchMode, queryBuilderFlagDefaults, regenerateID, regenerateIDs, remove, removeInPlace, rootPath, shouldRenderAsNumber, splitBy, sqlDialectPresets, standardClassnames, toArray, toFlatOptionArray, toFullOption, toFullOptionList, toFullOptionMap, transformQuery, trimIfString, uniqByIdentifier, uniqByName, uniqOptGroups, uniqOptList, update, updateInPlace, uuidV4regex };
|
|
4676
|
+
export { AccessibleDescriptionGenerator, ActionElementEventHandler, AddMethod, AddOptions, Arity, BaseFullOption, BaseOption, BaseOptionMap, BaseTranslation, BaseTranslationWithLabel, BaseTranslationWithPlaceholders, BaseTranslations, BaseTranslationsFull, Classname, Classnames, Combinator, CombinatorByValue, CommonRuleAndGroupProperties, CommonRuleSubComponentProps, ConstituentWordOrder, ConstituentWordOrderString, DefaultCombinator, DefaultCombinatorExtended, DefaultCombinatorName, DefaultCombinatorNameExtended, DefaultCombinators, DefaultCombinatorsExtended, DefaultMatchModes, DefaultOperator, DefaultOperatorName, DefaultOperators, DefaultRuleGroupArray, DefaultRuleGroupICArray, DefaultRuleGroupType, DefaultRuleGroupTypeAny, DefaultRuleGroupTypeIC, DefaultRuleOrGroupArray, DefaultRuleType, DiagnosticEntry, DiagnosticsFieldSummaryEntry, DiagnosticsResult, DiagnosticsStats, DndDropTargetType, DragCollection, DraggedItem, DropCollection, DropEffect, DropResult, ExportFormat, ExportObjectFormats, ExportOperatorMap, Field, FieldByValue, FindPathReturnType, FlexibleOption, FlexibleOptionGroup, FlexibleOptionList, FlexibleOptionListProp, FormatQueryFinalOptions, FormatQueryOptions, FormatQueryValidateRule, FullCombinator, FullField, FullOperator, FullOption, FullOptionList, FullOptionMap, FullOptionRecord, GenericizeRuleGroupType, GetOptionIdentifierType, GetOptionType, GetRuleGroupType, GetRuleTypeFromGroupWithFieldAndOperator, GroupMethod, GroupOptions, GroupVariantCondition, InputType, InsertMethod, InsertOptions, type JsonLogicAll, type JsonLogicAnd, type JsonLogicDoubleNegation, type JsonLogicEqual, type JsonLogicGreaterThan, type JsonLogicGreaterThanOrEqual, type JsonLogicInArray, type JsonLogicInString, type JsonLogicLessThan, type JsonLogicLessThanOrEqual, type JsonLogicNegation, type JsonLogicNone, type JsonLogicNotEqual, type JsonLogicOr, type JsonLogicReservedOperations, type JsonLogicRulesLogic, type JsonLogicSome, type JsonLogicStrictEqual, type JsonLogicStrictNotEqual, type JsonLogicVar, LogType, MatchConfig, MatchMode, MatchModeOptions, MoveMethod, MoveOptions, NLTranslationKey, NLTranslations, NameLabelPair, Operator, OperatorByValue, Option, OptionGroup, OptionList, ParameterizedNamedSQL, ParameterizedSQL, ParseNumberMethod, ParseNumberOptions, ParseNumbersPropConfig, Path, Placeholder, PrepareOptionListParams, PreparedOptionList, PreparerOptions, QueryActions, QueryBuilderFlags, QueryValidator, RQBJsonLogic, RQBJsonLogicEndsWith, RQBJsonLogicStartsWith, RQBJsonLogicVar, RegenerateIdOptions, RemoveMethod, RemoveNullability, RuleDiagnosticsResult, RuleGroupArray, RuleGroupDiagnosticsArray, RuleGroupDiagnosticsResult, RuleGroupICArray, RuleGroupICDiagnosticsArray, RuleGroupICDiagnosticsResult, RuleGroupProcessor, RuleGroupType, RuleGroupTypeAny, RuleGroupTypeIC, RuleOrGroupArray, RuleProcessor, RuleType, RuleValidator, SQLPreset, StringUnionToFlexibleOptionArray, StringUnionToFullOptionArray, TestID, ToFlexibleOption, ToFullOption, ToRuleGroupType, ToRuleGroupTypeIC, TransformQueryOptions, UpdateMethod, UpdateOptions, UpdateableProperties, ValidationMap, ValidationResult, ValueChangeEventHandler, ValueEditorType, ValueOption, ValueProcessor, ValueProcessorByRule, ValueProcessorLegacy, ValueProcessorOptions, ValueSource, ValueSourceFlexibleOptions, ValueSourceFullOptions, ValueSources, WithRequired, WithUnknownIndex, add, addInPlace, bigIntJsonParseReviver, bigIntJsonStringifyReplacer, celCombinatorMap, clsx, convertFromIC, convertQuery, convertToIC, cypherCombinatorMap, defaultCELValueProcessor, defaultCombinatorLabelMap, defaultCombinators, defaultCombinatorsExtended, defaultControlClassnames, defaultExportOperatorMap, defaultJoinChar, defaultMatchModes, defaultMongoDBValueProcessor, defaultNLTranslations, defaultOperatorLabelMap, defaultOperatorNegationMap, defaultOperatorProcessorNL, defaultOperatorProcessorSQL, defaultOperators, defaultPlaceholderFieldGroupLabel, defaultPlaceholderFieldLabel, defaultPlaceholderFieldName, defaultPlaceholderLabel, defaultPlaceholderName, defaultPlaceholderOperatorGroupLabel, defaultPlaceholderOperatorLabel, defaultPlaceholderOperatorName, defaultPlaceholderValueGroupLabel, defaultPlaceholderValueLabel, defaultPlaceholderValueName, defaultRuleGroupProcessorCEL, defaultRuleGroupProcessorCypher, defaultRuleGroupProcessorDiagnostics, defaultRuleGroupProcessorDrizzle, defaultRuleGroupProcessorElasticSearch, defaultRuleGroupProcessorGremlin, defaultRuleGroupProcessorJSONata, defaultRuleGroupProcessorJsonLogic, defaultRuleGroupProcessorLDAP, defaultRuleGroupProcessorMongoDB, defaultRuleGroupProcessorMongoDBQuery, defaultRuleGroupProcessorNL, defaultRuleGroupProcessorParameterized, defaultRuleGroupProcessorPrisma, defaultRuleGroupProcessorSPARQL, defaultRuleGroupProcessorSQL, defaultRuleGroupProcessorSequelize, defaultRuleGroupProcessorSpEL, defaultRuleGroupProcessorTanStackDB, defaultRuleProcessorCEL, defaultRuleProcessorCypher, defaultRuleProcessorDrizzle, defaultRuleProcessorElasticSearch, defaultRuleProcessorGremlin, defaultRuleProcessorJSONata, defaultRuleProcessorJsonLogic, defaultRuleProcessorLDAP, defaultRuleProcessorMongoDB, defaultRuleProcessorMongoDBQuery, defaultRuleProcessorNL, defaultRuleProcessorParameterized, defaultRuleProcessorPrisma, defaultRuleProcessorSPARQL, defaultRuleProcessorSQL, defaultRuleProcessorSequelize, defaultRuleProcessorSpEL, defaultRuleProcessorTanStackDB, defaultSpELValueProcessor, defaultTranslations, defaultValidator, defaultValueProcessor, defaultValueProcessorByRule, defaultValueProcessorCELByRule, defaultValueProcessorMongoDBByRule, defaultValueProcessorNL, defaultValueProcessorSpELByRule, filterFieldsByComparator, findID, findPath, formatQuery, formatQueryOptionPresets, generateAccessibleDescription, generateID, getCommonAncestorPath, getFirstOption, getMatchModesUtil, getNLTranslataion, getOption, getParentPath, getParseNumberMethod, getPathOfID, getQuoteFieldNamesWithArray, getQuotedFieldName, getValidationClassNames, getValueSourcesUtil, group, groupInPlace, groupInvalidReasons, insert, insertInPlace, isAncestor, isFlexibleOptionArray, isFlexibleOptionGroupArray, isFullOptionArray, isFullOptionGroupArray, isOptionGroupArray, isPojo, isRuleGroup, isRuleGroupType, isRuleGroupTypeIC, isRuleOrGroupValid, isRuleType, isUnsafeKey, isValidValue, isValidationResult, isValueProcessorLegacy, joinWith, jsonLogicAdditionalOperators, lc, mapSQLOperator, mergeAnyTranslation, mergeAnyTranslations, mergeClassnames, mongoDbFallback, mongoOperators, move, moveInPlace, normalizeConstituentWordOrder, nullFreeArray, nullOrUndefinedOrEmpty, numericRegex, numerifyValues, objectEntries, objectKeys, parseNumber, pathIsDisabled, pathsAreEqual, preferAnyProp, preferFlagProps, preferProp, prepareOptionList, prepareRule, prepareRuleGroup, prepareRuleOrGroup, prismaFallback, prismaOperators, processMatchMode, queryBuilderFlagDefaults, regenerateID, regenerateIDs, remove, removeInPlace, rootPath, shouldRenderAsNumber, sparqlVar, splitBy, sqlDialectPresets, standardClassnames, toArray, toFlatOptionArray, toFullOption, toFullOptionList, toFullOptionMap, transformQuery, trimIfString, uniqByIdentifier, uniqByName, uniqOptGroups, uniqOptList, update, updateInPlace, uuidV4regex };
|
|
4638
4677
|
//# sourceMappingURL=react-querybuilder_core.d.mts.map
|