@react-querybuilder/core 8.11.1 → 8.11.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/{basic-B4vXboTG.d.mts → basic-CLG_Bmom.d.mts} +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +14 -2
- package/dist/cjs/react-querybuilder_core.cjs.development.js +23 -11
- package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +14 -2
- 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-DAqoID3O.js → convertQuery-C7NvB0XA.js} +1 -1
- package/dist/{convertQuery-DAqoID3O.js.map → convertQuery-C7NvB0XA.js.map} +1 -1
- package/dist/{convertQuery-CqX3rPvj.mjs → convertQuery-Cj4t-LT4.mjs} +2 -2
- package/dist/{convertQuery-CqX3rPvj.mjs.map → convertQuery-Cj4t-LT4.mjs.map} +1 -1
- package/dist/{export-BjRt-qrK.d.mts → export-B2Yw5gak.d.mts} +2 -2
- package/dist/formatQuery.d.mts +15 -3
- package/dist/formatQuery.d.ts +13 -1
- package/dist/formatQuery.js +170 -423
- package/dist/formatQuery.js.map +1 -1
- package/dist/formatQuery.mjs +4 -257
- package/dist/formatQuery.mjs.map +1 -1
- package/dist/{import-Bc_p8ls9.d.mts → import-BtpySRSy.d.mts} +2 -2
- package/dist/{isRuleGroup-CYcfPgbg.mjs → isRuleGroup-BcfwGaIN.mjs} +1 -1
- package/dist/{isRuleGroup-CYcfPgbg.mjs.map → isRuleGroup-BcfwGaIN.mjs.map} +1 -1
- package/dist/parseCEL.d.mts +32 -7
- package/dist/parseCEL.d.ts +30 -5
- package/dist/parseCEL.js +168 -9
- package/dist/parseCEL.js.map +1 -1
- package/dist/parseCEL.mjs +163 -8
- package/dist/parseCEL.mjs.map +1 -1
- package/dist/parseJSONata.d.mts +2 -2
- package/dist/parseJSONata.js +2 -2
- package/dist/parseJSONata.mjs +3 -3
- package/dist/parseJsonLogic.d.mts +3 -3
- package/dist/parseJsonLogic.js +9 -10
- package/dist/parseJsonLogic.js.map +1 -1
- package/dist/parseJsonLogic.mjs +4 -5
- package/dist/parseJsonLogic.mjs.map +1 -1
- package/dist/parseMongoDB.d.mts +2 -2
- package/dist/parseMongoDB.js +19 -20
- package/dist/parseMongoDB.js.map +1 -1
- package/dist/parseMongoDB.mjs +4 -5
- package/dist/parseMongoDB.mjs.map +1 -1
- package/dist/parseSQL.d.mts +2 -2
- package/dist/parseSQL.js +8 -10
- package/dist/parseSQL.js.map +1 -1
- package/dist/parseSQL.mjs +3 -5
- package/dist/parseSQL.mjs.map +1 -1
- package/dist/parseSpEL.d.mts +2 -2
- package/dist/parseSpEL.js +3 -4
- package/dist/parseSpEL.js.map +1 -1
- package/dist/parseSpEL.mjs +3 -4
- package/dist/parseSpEL.mjs.map +1 -1
- package/dist/{prepareQueryObjects-DPCC-iHp.mjs → prepareQueryObjects-BfnyRV5t.mjs} +4 -3
- package/dist/{prepareQueryObjects-DPCC-iHp.mjs.map → prepareQueryObjects-BfnyRV5t.mjs.map} +1 -1
- package/dist/{prepareQueryObjects-BOUWfel5.js → prepareQueryObjects-Cz_28zYz.js} +12 -11
- package/dist/prepareQueryObjects-Cz_28zYz.js.map +1 -0
- package/dist/react-querybuilder_core.d.mts +14 -2
- package/dist/react-querybuilder_core.legacy-esm.d.ts +14 -2
- package/dist/react-querybuilder_core.legacy-esm.js +23 -11
- package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
- package/dist/react-querybuilder_core.mjs +23 -11
- package/dist/react-querybuilder_core.mjs.map +1 -1
- package/dist/react-querybuilder_core.production.d.mts +14 -2
- package/dist/react-querybuilder_core.production.mjs +1 -1
- package/dist/react-querybuilder_core.production.mjs.map +1 -1
- package/dist/{transformQuery-CWDPogO5.js → transformQuery-B4SaTTO-.js} +1 -1
- package/dist/{transformQuery-CWDPogO5.js.map → transformQuery-B4SaTTO-.js.map} +1 -1
- package/dist/{transformQuery-DCCpjtyq.mjs → transformQuery-C85j__7e.mjs} +2 -2
- package/dist/{transformQuery-DCCpjtyq.mjs.map → transformQuery-C85j__7e.mjs.map} +1 -1
- package/dist/transformQuery.d.mts +1 -1
- package/dist/transformQuery.js +1 -1
- package/dist/transformQuery.mjs +2 -2
- package/dist/utils-Dkz3Xn2D.js +707 -0
- package/dist/utils-Dkz3Xn2D.js.map +1 -0
- package/dist/utils-DxH23QtE.mjs +514 -0
- package/dist/utils-DxH23QtE.mjs.map +1 -0
- package/package.json +8 -8
- package/dist/arrayUtils-A_OXU9W1.mjs +0 -50
- package/dist/arrayUtils-A_OXU9W1.mjs.map +0 -1
- package/dist/arrayUtils-QxZOZTf6.js +0 -73
- package/dist/arrayUtils-QxZOZTf6.js.map +0 -1
- package/dist/optGroupUtils-B0hTpodo.js +0 -251
- package/dist/optGroupUtils-B0hTpodo.js.map +0 -1
- package/dist/optGroupUtils-VeZ3k7-1.mjs +0 -185
- package/dist/optGroupUtils-VeZ3k7-1.mjs.map +0 -1
- package/dist/parseNumber-CXdMVNFx.mjs +0 -24
- package/dist/parseNumber-CXdMVNFx.mjs.map +0 -1
- package/dist/parseNumber-D4iQDxK-.js +0 -31
- package/dist/parseNumber-D4iQDxK-.js.map +0 -1
- package/dist/prepareQueryObjects-BOUWfel5.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as ValueSources, t as FullField, x as OptionList } from "./basic-
|
|
1
|
+
import { o as ValueSources, t as FullField, x as OptionList } from "./basic-CLG_Bmom.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/types/import.d.ts
|
|
4
4
|
|
|
@@ -25,4 +25,4 @@ interface ParserCommonOptions {
|
|
|
25
25
|
}
|
|
26
26
|
//#endregion
|
|
27
27
|
export { ParserCommonOptions as t };
|
|
28
|
-
//# sourceMappingURL=import-
|
|
28
|
+
//# sourceMappingURL=import-BtpySRSy.d.mts.map
|
|
@@ -37,4 +37,4 @@ const isRuleGroupTypeIC = (rg) => isRuleGroup(rg) && rg.combinator === void 0;
|
|
|
37
37
|
|
|
38
38
|
//#endregion
|
|
39
39
|
export { lc as a, isPojo as i, isRuleGroupType as n, nullOrUndefinedOrEmpty as o, isRuleGroupTypeIC as r, numericRegex$1 as s, isRuleGroup as t };
|
|
40
|
-
//# sourceMappingURL=isRuleGroup-
|
|
40
|
+
//# sourceMappingURL=isRuleGroup-BcfwGaIN.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isRuleGroup-
|
|
1
|
+
{"version":3,"file":"isRuleGroup-BcfwGaIN.mjs","names":["numericRegex: RegExp","numericQuantityRegex"],"sources":["../src/utils/misc.ts","../src/utils/isRuleGroup.ts"],"sourcesContent":["import { numericRegex as numericQuantityRegex } from 'numeric-quantity';\n\n/**\n * Converts a value to lowercase if it's a string, otherwise returns the value as is.\n */\n// istanbul ignore next\nexport const lc = <T>(v: T): T => (typeof v === 'string' ? (v.toLowerCase() as T) : v);\n\n/**\n * Regex matching numeric strings. Passes for positive/negative integers, decimals,\n * and E notation, with optional surrounding whitespace.\n */\nexport const numericRegex: RegExp = new RegExp(\n numericQuantityRegex.source.replace(/^\\^/, String.raw`^\\s*`).replace(/\\$$/, String.raw`\\s*$`)\n);\n\n/**\n * Determines if a variable is a plain old JavaScript object, aka POJO.\n */\n// oxlint-disable-next-line typescript/no-explicit-any\nexport const isPojo = (obj: any): obj is Record<string, any> =>\n obj === null || typeof obj !== 'object' ? false : Object.getPrototypeOf(obj) === Object.prototype;\n\n/**\n * Simple helper to determine whether a value is null, undefined, or an empty string.\n */\nexport const nullOrUndefinedOrEmpty = (value: unknown): value is null | undefined | '' =>\n value === null || value === undefined || value === '';\n","import type { RuleGroupType, RuleGroupTypeAny, RuleGroupTypeIC, RuleType } from '../types';\nimport { isPojo } from './misc';\n\n/**\n * Determines if an object is a {@link RuleType} (only checks for a `field` property).\n */\nexport const isRuleType = (s: unknown): s is RuleType =>\n isPojo(s) && 'field' in s && typeof s.field === 'string';\n\n/**\n * Determines if an object is a {@link RuleGroupType} or {@link RuleGroupTypeIC}.\n */\nexport const isRuleGroup = (rg: unknown): rg is RuleGroupTypeAny =>\n isPojo(rg) && Array.isArray(rg.rules);\n\n/**\n * Determines if an object is a {@link RuleGroupType}.\n */\nexport const isRuleGroupType = (rg: unknown): rg is RuleGroupType =>\n isRuleGroup(rg) && typeof rg.combinator === 'string';\n\n/**\n * Determines if an object is a {@link RuleGroupTypeIC}.\n */\nexport const isRuleGroupTypeIC = (rg: unknown): rg is RuleGroupTypeIC =>\n isRuleGroup(rg) && rg.combinator === undefined;\n"],"mappings":";;;;;;;AAMA,MAAa,MAAS,MAAa,OAAO,MAAM,WAAY,EAAE,aAAa,GAAS;;;;;AAMpF,MAAaA,iBAAuB,IAAI,OACtCC,aAAqB,OAAO,QAAQ,OAAO,OAAO,GAAG,OAAO,CAAC,QAAQ,OAAO,OAAO,GAAG,OAAO,CAC9F;;;;AAMD,MAAa,UAAU,QACrB,QAAQ,QAAQ,OAAO,QAAQ,WAAW,QAAQ,OAAO,eAAe,IAAI,KAAK,OAAO;;;;AAK1F,MAAa,0BAA0B,UACrC,UAAU,QAAQ,UAAU,UAAa,UAAU;;;;;;;ACfrD,MAAa,eAAe,OAC1B,OAAO,GAAG,IAAI,MAAM,QAAQ,GAAG,MAAM;;;;AAKvC,MAAa,mBAAmB,OAC9B,YAAY,GAAG,IAAI,OAAO,GAAG,eAAe;;;;AAK9C,MAAa,qBAAqB,OAChC,YAAY,GAAG,IAAI,GAAG,eAAe"}
|
package/dist/parseCEL.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as Except, _ as RuleGroupType, d as DefaultRuleGroupTypeIC, g as DefaultRuleGroupType, h as DefaultOperatorName, m as DefaultCombinatorName, p as RuleGroupTypeIC, v as RuleType } from "./basic-
|
|
2
|
-
import { t as ParserCommonOptions } from "./import-
|
|
1
|
+
import { C as Except, _ as RuleGroupType, d as DefaultRuleGroupTypeIC, g as DefaultRuleGroupType, h as DefaultOperatorName, m as DefaultCombinatorName, p as RuleGroupTypeIC, v as RuleType } from "./basic-CLG_Bmom.mjs";
|
|
2
|
+
import { t as ParserCommonOptions } from "./import-BtpySRSy.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/parseCEL/types.d.ts
|
|
5
|
-
type CELExpressionType = "Addition" | "BooleanLiteral" | "BytesLiteral" | "ConditionalAnd" | "ConditionalExpr" | "ConditionalOr" | "Division" | "DynamicPropertyAccessor" | "ExpressionGroup" | "ExpressionList" | "FieldInit" | "FieldInits" | "FieldsObject" | "FloatLiteral" | "FunctionCall" | "Identifier" | "IntegerLiteral" | "List" | "Map" | "MapInit" | "MapInits" | "Member" | "Modulo" | "Multiplication" | "Negation" | "Negative" | "NullLiteral" | "Property" | "Relation" | "StringLiteral" | "Subtraction" | "Unary" | "UnsignedIntegerLiteral" | "LikeExpression";
|
|
5
|
+
type CELExpressionType = "Addition" | "BooleanLiteral" | "BytesLiteral" | "ConditionalAnd" | "ConditionalExpr" | "ConditionalOr" | "Division" | "DynamicPropertyAccessor" | "ExpressionGroup" | "ExpressionList" | "FieldInit" | "FieldInits" | "FieldsObject" | "FloatLiteral" | "FunctionCall" | "Identifier" | "IntegerLiteral" | "List" | "Map" | "MapInit" | "MapInits" | "Member" | "Modulo" | "Multiplication" | "Negation" | "Negative" | "NullLiteral" | "Property" | "Relation" | "StringLiteral" | "Subtraction" | "Unary" | "UnsignedIntegerLiteral" | "LikeExpression" | "SubqueryExpression";
|
|
6
6
|
type CELRelop = "==" | ">=" | ">" | "<=" | "<" | "!=" | "in";
|
|
7
7
|
interface CELExpression {
|
|
8
8
|
type: CELExpressionType;
|
|
@@ -64,7 +64,7 @@ interface CELNegative extends CELExpression {
|
|
|
64
64
|
interface CELMember extends CELExpression {
|
|
65
65
|
type: "Member";
|
|
66
66
|
value?: CELPrimary;
|
|
67
|
-
left?: CELPrimary | CELMember;
|
|
67
|
+
left?: CELPrimary | CELMember | CELNegation;
|
|
68
68
|
right?: CELIdentifier;
|
|
69
69
|
list?: CELExpressionList;
|
|
70
70
|
}
|
|
@@ -194,6 +194,22 @@ interface CELNegatedLikeExpression extends CELExpression {
|
|
|
194
194
|
value: [CELStringLiteral | CELIdentifier];
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
|
+
interface CELSubqueryExpression extends CELExpression {
|
|
198
|
+
type: "Member";
|
|
199
|
+
left: CELIdentifier | CELMemberIdentifierChain;
|
|
200
|
+
right: CELIdentifier<"all" | "exists">;
|
|
201
|
+
list: CELExpressionList & {
|
|
202
|
+
value: [CELIdentifier, CELExpression];
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
interface CELNegatedSubqueryExpression extends CELExpression {
|
|
206
|
+
type: "Member";
|
|
207
|
+
left: CELMemberNegatedIdentifier | CELMemberNegatedIdentifierChain;
|
|
208
|
+
right: CELIdentifier<"all" | "exists">;
|
|
209
|
+
list: CELExpressionList & {
|
|
210
|
+
value: [CELIdentifier, CELExpression];
|
|
211
|
+
};
|
|
212
|
+
}
|
|
197
213
|
type CELNumericLiteral = CELIntegerLiteral | CELUnsignedIntegerLiteral | CELFloatLiteral;
|
|
198
214
|
type CELLiteral = CELStringLiteral | CELBytesLiteral | CELNumericLiteral | CELBooleanLiteral | CELNullLiteral;
|
|
199
215
|
type CELPrimary = CELProperty | CELIdentifier | CELExpressionGroup | CELFunctionCall | CELLiteral | CELList | CELMap;
|
|
@@ -292,12 +308,20 @@ declare const isCELNullLiteral: (expr: CELExpression) => expr is CELNullLiteral;
|
|
|
292
308
|
declare const isCELProperty: (expr: CELExpression) => expr is CELProperty;
|
|
293
309
|
declare const isCELSubtraction: (expr: CELExpression) => expr is CELSubtraction;
|
|
294
310
|
declare const isCELUnsignedIntegerLiteral: (expr: CELExpression) => expr is CELUnsignedIntegerLiteral;
|
|
295
|
-
declare const isCELIdentifierOrChain: (expr: CELExpression) => expr is CELMemberIdentifierChain | CELIdentifier;
|
|
311
|
+
declare const isCELIdentifierOrChain: (expr: CELExpression) => expr is CELMemberIdentifierChain | CELIdentifier | CELDynamicPropertyAccessor;
|
|
296
312
|
declare const isCELNegatedIdentifier: (expr: CELExpression) => expr is CELMemberNegatedIdentifier;
|
|
297
313
|
declare const isCELNegatedIdentifierOrChain: (expr: CELExpression) => expr is CELMemberNegatedIdentifierChain | CELMemberNegatedIdentifier;
|
|
298
314
|
declare const isCELLikeExpression: (expr: CELExpression) => expr is CELLikeExpression;
|
|
299
315
|
declare const isCELNegatedLikeExpression: (expr: CELExpression) => expr is CELNegatedLikeExpression;
|
|
300
|
-
declare const
|
|
316
|
+
declare const isCELSubqueryExpression: (expr: CELExpression) => expr is CELSubqueryExpression;
|
|
317
|
+
declare const isCELNegatedSubqueryExpression: (expr: CELExpression) => expr is CELNegatedSubqueryExpression;
|
|
318
|
+
declare const extractSubqueryComponents: (expr: CELMember) => {
|
|
319
|
+
field: string;
|
|
320
|
+
method: "all" | "exists";
|
|
321
|
+
alias: string | null;
|
|
322
|
+
condition: CELExpression;
|
|
323
|
+
} | null;
|
|
324
|
+
declare const getCELIdentifierFromChain: (expr: CELIdentifier | CELMemberIdentifierChain | CELDynamicPropertyAccessor | CELMember) => string;
|
|
301
325
|
declare const getCELIdentifierFromNegatedChain: (expr: CELMemberNegatedIdentifier | CELMemberNegatedIdentifierChain) => string;
|
|
302
326
|
declare function evalCELLiteralValue(literal: CELStringLiteral): string;
|
|
303
327
|
declare function evalCELLiteralValue(literal: CELBooleanLiteral): boolean;
|
|
@@ -309,6 +333,7 @@ declare const celNormalizeCombinator: (c: "&&" | "||") => DefaultCombinatorName;
|
|
|
309
333
|
declare const celNormalizeOperator: (op: CELRelop, flip?: boolean) => DefaultOperatorName;
|
|
310
334
|
declare const celGenerateFlatAndOrList: (expr: CELConditionalAnd | CELConditionalOr) => (DefaultCombinatorName | CELExpression)[];
|
|
311
335
|
declare const celGenerateMixedAndOrList: (expr: CELConditionalAnd | CELConditionalOr) => (DefaultCombinatorName | CELExpression | ("and" | CELExpression)[])[];
|
|
336
|
+
declare const transformAliasInExpression: (expr: CELExpression, alias: string | null) => CELExpression;
|
|
312
337
|
//#endregion
|
|
313
|
-
export { CELAddition, CELBooleanLiteral, CELBytesLiteral, CELConditionalAnd, CELConditionalExpr, CELConditionalOr, CELDivision, CELDynamicPropertyAccessor, CELExpression, CELExpressionGroup, CELExpressionList, CELExpressionType, CELFieldInit, CELFieldInits, CELFieldsObject, CELFloatLiteral, CELFunctionCall, CELIdentifier, CELIntegerLiteral, CELLikeExpression, CELList, CELLiteral, CELMap, CELMapInit, CELMapInits, CELMathOperation, CELMember, CELMemberIdentifierChain, CELMemberNegatedIdentifier, CELMemberNegatedIdentifierChain, CELModulo, CELMultiplication, CELNegatedLikeExpression, CELNegation, CELNegative, CELNullLiteral, CELNumericLiteral, CELPrimary, CELProperty, CELRelation, CELRelop, CELStringLiteral, CELSubtraction, CELUnsignedIntegerLiteral, ParseCELOptions, ParseCELOptionsIC, ParseCELOptionsStandard, ParsedCEL, celGenerateFlatAndOrList, celGenerateMixedAndOrList, celNormalizeCombinator, celNormalizeOperator, evalCELLiteralValue, getCELIdentifierFromChain, getCELIdentifierFromNegatedChain, isCELAddition, isCELBooleanLiteral, isCELBytesLiteral, isCELConditionalAnd, isCELConditionalExpr, isCELConditionalOr, isCELDivision, isCELDynamicPropertyAccessor, isCELExpressionGroup, isCELExpressionList, isCELFieldInit, isCELFieldInits, isCELFieldsObject, isCELFloatLiteral, isCELFunctionCall, isCELIdentifier, isCELIdentifierOrChain, isCELIntegerLiteral, isCELLikeExpression, isCELList, isCELLiteral, isCELMap, isCELMapInit, isCELMapInits, isCELMember, isCELModulo, isCELMultiplication, isCELNegatedIdentifier, isCELNegatedIdentifierOrChain, isCELNegatedLikeExpression, isCELNegation, isCELNegative, isCELNullLiteral, isCELNumericLiteral, isCELProperty, isCELRelation, isCELStringLiteral, isCELSubtraction, isCELUnsignedIntegerLiteral, parseCEL };
|
|
338
|
+
export { CELAddition, CELBooleanLiteral, CELBytesLiteral, CELConditionalAnd, CELConditionalExpr, CELConditionalOr, CELDivision, CELDynamicPropertyAccessor, CELExpression, CELExpressionGroup, CELExpressionList, CELExpressionType, CELFieldInit, CELFieldInits, CELFieldsObject, CELFloatLiteral, CELFunctionCall, CELIdentifier, CELIntegerLiteral, CELLikeExpression, CELList, CELLiteral, CELMap, CELMapInit, CELMapInits, CELMathOperation, CELMember, CELMemberIdentifierChain, CELMemberNegatedIdentifier, CELMemberNegatedIdentifierChain, CELModulo, CELMultiplication, CELNegatedLikeExpression, CELNegatedSubqueryExpression, CELNegation, CELNegative, CELNullLiteral, CELNumericLiteral, CELPrimary, CELProperty, CELRelation, CELRelop, CELStringLiteral, CELSubqueryExpression, CELSubtraction, CELUnsignedIntegerLiteral, ParseCELOptions, ParseCELOptionsIC, ParseCELOptionsStandard, ParsedCEL, celGenerateFlatAndOrList, celGenerateMixedAndOrList, celNormalizeCombinator, celNormalizeOperator, evalCELLiteralValue, extractSubqueryComponents, getCELIdentifierFromChain, getCELIdentifierFromNegatedChain, isCELAddition, isCELBooleanLiteral, isCELBytesLiteral, isCELConditionalAnd, isCELConditionalExpr, isCELConditionalOr, isCELDivision, isCELDynamicPropertyAccessor, isCELExpressionGroup, isCELExpressionList, isCELFieldInit, isCELFieldInits, isCELFieldsObject, isCELFloatLiteral, isCELFunctionCall, isCELIdentifier, isCELIdentifierOrChain, isCELIntegerLiteral, isCELLikeExpression, isCELList, isCELLiteral, isCELMap, isCELMapInit, isCELMapInits, isCELMember, isCELModulo, isCELMultiplication, isCELNegatedIdentifier, isCELNegatedIdentifierOrChain, isCELNegatedLikeExpression, isCELNegatedSubqueryExpression, isCELNegation, isCELNegative, isCELNullLiteral, isCELNumericLiteral, isCELProperty, isCELRelation, isCELStringLiteral, isCELSubqueryExpression, isCELSubtraction, isCELUnsignedIntegerLiteral, parseCEL, transformAliasInExpression };
|
|
314
339
|
//# sourceMappingURL=parseCEL.d.mts.map
|
package/dist/parseCEL.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { C as Except, _ as RuleGroupType, d as DefaultRuleGroupTypeIC, g as Defa
|
|
|
2
2
|
import { t as ParserCommonOptions } from "./import-Dvayhrgj.js";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/parseCEL/types.d.ts
|
|
5
|
-
type CELExpressionType = "Addition" | "BooleanLiteral" | "BytesLiteral" | "ConditionalAnd" | "ConditionalExpr" | "ConditionalOr" | "Division" | "DynamicPropertyAccessor" | "ExpressionGroup" | "ExpressionList" | "FieldInit" | "FieldInits" | "FieldsObject" | "FloatLiteral" | "FunctionCall" | "Identifier" | "IntegerLiteral" | "List" | "Map" | "MapInit" | "MapInits" | "Member" | "Modulo" | "Multiplication" | "Negation" | "Negative" | "NullLiteral" | "Property" | "Relation" | "StringLiteral" | "Subtraction" | "Unary" | "UnsignedIntegerLiteral" | "LikeExpression";
|
|
5
|
+
type CELExpressionType = "Addition" | "BooleanLiteral" | "BytesLiteral" | "ConditionalAnd" | "ConditionalExpr" | "ConditionalOr" | "Division" | "DynamicPropertyAccessor" | "ExpressionGroup" | "ExpressionList" | "FieldInit" | "FieldInits" | "FieldsObject" | "FloatLiteral" | "FunctionCall" | "Identifier" | "IntegerLiteral" | "List" | "Map" | "MapInit" | "MapInits" | "Member" | "Modulo" | "Multiplication" | "Negation" | "Negative" | "NullLiteral" | "Property" | "Relation" | "StringLiteral" | "Subtraction" | "Unary" | "UnsignedIntegerLiteral" | "LikeExpression" | "SubqueryExpression";
|
|
6
6
|
type CELRelop = "==" | ">=" | ">" | "<=" | "<" | "!=" | "in";
|
|
7
7
|
interface CELExpression {
|
|
8
8
|
type: CELExpressionType;
|
|
@@ -64,7 +64,7 @@ interface CELNegative extends CELExpression {
|
|
|
64
64
|
interface CELMember extends CELExpression {
|
|
65
65
|
type: "Member";
|
|
66
66
|
value?: CELPrimary;
|
|
67
|
-
left?: CELPrimary | CELMember;
|
|
67
|
+
left?: CELPrimary | CELMember | CELNegation;
|
|
68
68
|
right?: CELIdentifier;
|
|
69
69
|
list?: CELExpressionList;
|
|
70
70
|
}
|
|
@@ -194,6 +194,22 @@ interface CELNegatedLikeExpression extends CELExpression {
|
|
|
194
194
|
value: [CELStringLiteral | CELIdentifier];
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
|
+
interface CELSubqueryExpression extends CELExpression {
|
|
198
|
+
type: "Member";
|
|
199
|
+
left: CELIdentifier | CELMemberIdentifierChain;
|
|
200
|
+
right: CELIdentifier<"all" | "exists">;
|
|
201
|
+
list: CELExpressionList & {
|
|
202
|
+
value: [CELIdentifier, CELExpression];
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
interface CELNegatedSubqueryExpression extends CELExpression {
|
|
206
|
+
type: "Member";
|
|
207
|
+
left: CELMemberNegatedIdentifier | CELMemberNegatedIdentifierChain;
|
|
208
|
+
right: CELIdentifier<"all" | "exists">;
|
|
209
|
+
list: CELExpressionList & {
|
|
210
|
+
value: [CELIdentifier, CELExpression];
|
|
211
|
+
};
|
|
212
|
+
}
|
|
197
213
|
type CELNumericLiteral = CELIntegerLiteral | CELUnsignedIntegerLiteral | CELFloatLiteral;
|
|
198
214
|
type CELLiteral = CELStringLiteral | CELBytesLiteral | CELNumericLiteral | CELBooleanLiteral | CELNullLiteral;
|
|
199
215
|
type CELPrimary = CELProperty | CELIdentifier | CELExpressionGroup | CELFunctionCall | CELLiteral | CELList | CELMap;
|
|
@@ -292,12 +308,20 @@ declare const isCELNullLiteral: (expr: CELExpression) => expr is CELNullLiteral;
|
|
|
292
308
|
declare const isCELProperty: (expr: CELExpression) => expr is CELProperty;
|
|
293
309
|
declare const isCELSubtraction: (expr: CELExpression) => expr is CELSubtraction;
|
|
294
310
|
declare const isCELUnsignedIntegerLiteral: (expr: CELExpression) => expr is CELUnsignedIntegerLiteral;
|
|
295
|
-
declare const isCELIdentifierOrChain: (expr: CELExpression) => expr is CELMemberIdentifierChain | CELIdentifier;
|
|
311
|
+
declare const isCELIdentifierOrChain: (expr: CELExpression) => expr is CELMemberIdentifierChain | CELIdentifier | CELDynamicPropertyAccessor;
|
|
296
312
|
declare const isCELNegatedIdentifier: (expr: CELExpression) => expr is CELMemberNegatedIdentifier;
|
|
297
313
|
declare const isCELNegatedIdentifierOrChain: (expr: CELExpression) => expr is CELMemberNegatedIdentifierChain | CELMemberNegatedIdentifier;
|
|
298
314
|
declare const isCELLikeExpression: (expr: CELExpression) => expr is CELLikeExpression;
|
|
299
315
|
declare const isCELNegatedLikeExpression: (expr: CELExpression) => expr is CELNegatedLikeExpression;
|
|
300
|
-
declare const
|
|
316
|
+
declare const isCELSubqueryExpression: (expr: CELExpression) => expr is CELSubqueryExpression;
|
|
317
|
+
declare const isCELNegatedSubqueryExpression: (expr: CELExpression) => expr is CELNegatedSubqueryExpression;
|
|
318
|
+
declare const extractSubqueryComponents: (expr: CELMember) => {
|
|
319
|
+
field: string;
|
|
320
|
+
method: "all" | "exists";
|
|
321
|
+
alias: string | null;
|
|
322
|
+
condition: CELExpression;
|
|
323
|
+
} | null;
|
|
324
|
+
declare const getCELIdentifierFromChain: (expr: CELIdentifier | CELMemberIdentifierChain | CELDynamicPropertyAccessor | CELMember) => string;
|
|
301
325
|
declare const getCELIdentifierFromNegatedChain: (expr: CELMemberNegatedIdentifier | CELMemberNegatedIdentifierChain) => string;
|
|
302
326
|
declare function evalCELLiteralValue(literal: CELStringLiteral): string;
|
|
303
327
|
declare function evalCELLiteralValue(literal: CELBooleanLiteral): boolean;
|
|
@@ -309,6 +333,7 @@ declare const celNormalizeCombinator: (c: "&&" | "||") => DefaultCombinatorName;
|
|
|
309
333
|
declare const celNormalizeOperator: (op: CELRelop, flip?: boolean) => DefaultOperatorName;
|
|
310
334
|
declare const celGenerateFlatAndOrList: (expr: CELConditionalAnd | CELConditionalOr) => (DefaultCombinatorName | CELExpression)[];
|
|
311
335
|
declare const celGenerateMixedAndOrList: (expr: CELConditionalAnd | CELConditionalOr) => (DefaultCombinatorName | CELExpression | ("and" | CELExpression)[])[];
|
|
336
|
+
declare const transformAliasInExpression: (expr: CELExpression, alias: string | null) => CELExpression;
|
|
312
337
|
//#endregion
|
|
313
|
-
export { CELAddition, CELBooleanLiteral, CELBytesLiteral, CELConditionalAnd, CELConditionalExpr, CELConditionalOr, CELDivision, CELDynamicPropertyAccessor, CELExpression, CELExpressionGroup, CELExpressionList, CELExpressionType, CELFieldInit, CELFieldInits, CELFieldsObject, CELFloatLiteral, CELFunctionCall, CELIdentifier, CELIntegerLiteral, CELLikeExpression, CELList, CELLiteral, CELMap, CELMapInit, CELMapInits, CELMathOperation, CELMember, CELMemberIdentifierChain, CELMemberNegatedIdentifier, CELMemberNegatedIdentifierChain, CELModulo, CELMultiplication, CELNegatedLikeExpression, CELNegation, CELNegative, CELNullLiteral, CELNumericLiteral, CELPrimary, CELProperty, CELRelation, CELRelop, CELStringLiteral, CELSubtraction, CELUnsignedIntegerLiteral, ParseCELOptions, ParseCELOptionsIC, ParseCELOptionsStandard, ParsedCEL, celGenerateFlatAndOrList, celGenerateMixedAndOrList, celNormalizeCombinator, celNormalizeOperator, evalCELLiteralValue, getCELIdentifierFromChain, getCELIdentifierFromNegatedChain, isCELAddition, isCELBooleanLiteral, isCELBytesLiteral, isCELConditionalAnd, isCELConditionalExpr, isCELConditionalOr, isCELDivision, isCELDynamicPropertyAccessor, isCELExpressionGroup, isCELExpressionList, isCELFieldInit, isCELFieldInits, isCELFieldsObject, isCELFloatLiteral, isCELFunctionCall, isCELIdentifier, isCELIdentifierOrChain, isCELIntegerLiteral, isCELLikeExpression, isCELList, isCELLiteral, isCELMap, isCELMapInit, isCELMapInits, isCELMember, isCELModulo, isCELMultiplication, isCELNegatedIdentifier, isCELNegatedIdentifierOrChain, isCELNegatedLikeExpression, isCELNegation, isCELNegative, isCELNullLiteral, isCELNumericLiteral, isCELProperty, isCELRelation, isCELStringLiteral, isCELSubtraction, isCELUnsignedIntegerLiteral, parseCEL };
|
|
338
|
+
export { CELAddition, CELBooleanLiteral, CELBytesLiteral, CELConditionalAnd, CELConditionalExpr, CELConditionalOr, CELDivision, CELDynamicPropertyAccessor, CELExpression, CELExpressionGroup, CELExpressionList, CELExpressionType, CELFieldInit, CELFieldInits, CELFieldsObject, CELFloatLiteral, CELFunctionCall, CELIdentifier, CELIntegerLiteral, CELLikeExpression, CELList, CELLiteral, CELMap, CELMapInit, CELMapInits, CELMathOperation, CELMember, CELMemberIdentifierChain, CELMemberNegatedIdentifier, CELMemberNegatedIdentifierChain, CELModulo, CELMultiplication, CELNegatedLikeExpression, CELNegatedSubqueryExpression, CELNegation, CELNegative, CELNullLiteral, CELNumericLiteral, CELPrimary, CELProperty, CELRelation, CELRelop, CELStringLiteral, CELSubqueryExpression, CELSubtraction, CELUnsignedIntegerLiteral, ParseCELOptions, ParseCELOptionsIC, ParseCELOptionsStandard, ParsedCEL, celGenerateFlatAndOrList, celGenerateMixedAndOrList, celNormalizeCombinator, celNormalizeOperator, evalCELLiteralValue, extractSubqueryComponents, getCELIdentifierFromChain, getCELIdentifierFromNegatedChain, isCELAddition, isCELBooleanLiteral, isCELBytesLiteral, isCELConditionalAnd, isCELConditionalExpr, isCELConditionalOr, isCELDivision, isCELDynamicPropertyAccessor, isCELExpressionGroup, isCELExpressionList, isCELFieldInit, isCELFieldInits, isCELFieldsObject, isCELFloatLiteral, isCELFunctionCall, isCELIdentifier, isCELIdentifierOrChain, isCELIntegerLiteral, isCELLikeExpression, isCELList, isCELLiteral, isCELMap, isCELMapInit, isCELMapInits, isCELMember, isCELModulo, isCELMultiplication, isCELNegatedIdentifier, isCELNegatedIdentifierOrChain, isCELNegatedLikeExpression, isCELNegatedSubqueryExpression, isCELNegation, isCELNegative, isCELNullLiteral, isCELNumericLiteral, isCELProperty, isCELRelation, isCELStringLiteral, isCELSubqueryExpression, isCELSubtraction, isCELUnsignedIntegerLiteral, parseCEL, transformAliasInExpression };
|
|
314
339
|
//# sourceMappingURL=parseCEL.d.ts.map
|
package/dist/parseCEL.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const require_isRuleGroup = require('./isRuleGroup-DqAs2x4E.js');
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const require_prepareQueryObjects = require('./prepareQueryObjects-BOUWfel5.js');
|
|
2
|
+
const require_utils = require('./utils-Dkz3Xn2D.js');
|
|
3
|
+
const require_prepareQueryObjects = require('./prepareQueryObjects-Cz_28zYz.js');
|
|
5
4
|
let __ts_jison_parser = require("@ts-jison/parser");
|
|
6
5
|
__ts_jison_parser = require_isRuleGroup.__toESM(__ts_jison_parser);
|
|
7
6
|
let __ts_jison_lexer = require("@ts-jison/lexer");
|
|
@@ -2060,14 +2059,39 @@ const isCELProperty = (expr) => expr.type === "Property";
|
|
|
2060
2059
|
// istanbul ignore next
|
|
2061
2060
|
const isCELSubtraction = (expr) => expr.type === "Subtraction";
|
|
2062
2061
|
const isCELUnsignedIntegerLiteral = (expr) => expr.type === "UnsignedIntegerLiteral";
|
|
2063
|
-
const isCELIdentifierOrChain = (expr) => isCELIdentifier(expr) || isCELMember(expr) && !!expr.left && !!expr.right && !expr.list && !expr.value && isCELIdentifierOrChain(expr.left) && isCELIdentifier(expr.right);
|
|
2062
|
+
const isCELIdentifierOrChain = (expr) => isCELIdentifier(expr) || isCELDynamicPropertyAccessor(expr) || isCELMember(expr) && !!expr.left && !!expr.right && !expr.list && !expr.value && isCELIdentifierOrChain(expr.left) && isCELIdentifier(expr.right);
|
|
2064
2063
|
const isCELNegatedIdentifier = (expr) => isCELNegation(expr) && isCELIdentifier(expr.value);
|
|
2065
2064
|
const isCELNegatedIdentifierOrChain = (expr) => isCELNegatedIdentifier(expr) || isCELMember(expr) && !!expr.left && !!expr.right && !expr.list && !expr.value && isCELIdentifierOrChain(expr.right) && isCELNegatedIdentifier(expr.left);
|
|
2066
2065
|
const isCELLikeExpression = (expr) => isCELMember(expr) && !!expr.left && !!expr.right && !!expr.list && isCELIdentifierOrChain(expr.left) && isCELIdentifier(expr.right) && (expr.right.value === "contains" || expr.right.value === "startsWith" || expr.right.value === "endsWith") && expr.list.value.length === 1 && (isCELStringLiteral(expr.list.value[0]) || isCELIdentifier(expr.list.value[0]));
|
|
2067
2066
|
const isCELNegatedLikeExpression = (expr) => isCELMember(expr) && !!expr.left && !!expr.right && !!expr.list && isCELNegatedIdentifierOrChain(expr.left) && isCELIdentifier(expr.right) && (expr.right.value === "contains" || expr.right.value === "startsWith" || expr.right.value === "endsWith") && expr.list.value.length === 1 && (isCELStringLiteral(expr.list.value[0]) || isCELIdentifier(expr.list.value[0]));
|
|
2067
|
+
const isCELSubqueryExpression = (expr) => isCELMember(expr) && !!expr.left && !!expr.right && !!expr.list && isCELIdentifierOrChain(expr.left) && isCELIdentifier(expr.right) && (expr.right.value === "all" || expr.right.value === "exists") && expr.list.value.length >= 2;
|
|
2068
|
+
const isCELNegatedSubqueryExpression = (expr) => isCELMember(expr) && !!expr.left && !!expr.right && !!expr.list && isCELNegatedIdentifierOrChain(expr.left) && isCELIdentifier(expr.right) && (expr.right.value === "all" || expr.right.value === "exists") && expr.list.value.length >= 2;
|
|
2069
|
+
const extractSubqueryComponents = (expr) => {
|
|
2070
|
+
// istanbul ignore next
|
|
2071
|
+
if (!isCELSubqueryExpression(expr)) return null;
|
|
2072
|
+
const field = getCELIdentifierFromChain(expr.left);
|
|
2073
|
+
const method = expr.right.value;
|
|
2074
|
+
const [aliasExpr, conditionExpr] = expr.list.value;
|
|
2075
|
+
return {
|
|
2076
|
+
field,
|
|
2077
|
+
method,
|
|
2078
|
+
alias: isCELIdentifier(aliasExpr) ? aliasExpr.value : null,
|
|
2079
|
+
condition: conditionExpr
|
|
2080
|
+
};
|
|
2081
|
+
};
|
|
2068
2082
|
const getCELIdentifierFromChain = (expr) => {
|
|
2069
2083
|
if (isCELIdentifier(expr)) return expr.value;
|
|
2070
|
-
|
|
2084
|
+
if (isCELDynamicPropertyAccessor(expr)) {
|
|
2085
|
+
const leftField = getCELIdentifierFromChain(expr.left);
|
|
2086
|
+
// istanbul ignore else
|
|
2087
|
+
if (isCELStringLiteral(expr.right)) return `${leftField}["${evalCELLiteralValue(expr.right)}"]`;
|
|
2088
|
+
// istanbul ignore next
|
|
2089
|
+
return `${leftField}[${expr.right.type}]`;
|
|
2090
|
+
}
|
|
2091
|
+
// istanbul ignore else
|
|
2092
|
+
if (expr.left && expr.right && isCELIdentifier(expr.right) && (isCELIdentifier(expr.left) || isCELMember(expr.left) || isCELDynamicPropertyAccessor(expr.left))) return `${getCELIdentifierFromChain(expr.left)}.${expr.right.value}`;
|
|
2093
|
+
// istanbul ignore next
|
|
2094
|
+
return expr.type;
|
|
2071
2095
|
};
|
|
2072
2096
|
const getCELIdentifierFromNegatedChain = (expr) => {
|
|
2073
2097
|
if (isCELNegatedIdentifier(expr)) return `${``.padStart(expr.negations, `!`)}${expr.value.value}`;
|
|
@@ -2130,6 +2154,91 @@ const celGenerateMixedAndOrList = (expr) => {
|
|
|
2130
2154
|
if (returnArray.length === 1 && Array.isArray(returnArray[0])) return returnArray[0];
|
|
2131
2155
|
return returnArray;
|
|
2132
2156
|
};
|
|
2157
|
+
const isPrimitiveArrayUsage = (expr, alias) => {
|
|
2158
|
+
// istanbul ignore next
|
|
2159
|
+
if (!alias) return false;
|
|
2160
|
+
if (isCELIdentifier(expr) && expr.value === alias) return true;
|
|
2161
|
+
if (isCELLikeExpression(expr) && isCELIdentifier(expr.left) && expr.left.value === alias) return true;
|
|
2162
|
+
if (isCELRelation(expr) || isCELConditionalAnd(expr) || isCELConditionalOr(expr)) return isPrimitiveArrayUsage(expr.left, alias) || isPrimitiveArrayUsage(expr.right, alias);
|
|
2163
|
+
// istanbul ignore next
|
|
2164
|
+
if (isCELExpressionGroup(expr) || isCELNegation(expr)) return isPrimitiveArrayUsage(expr.value, alias);
|
|
2165
|
+
return false;
|
|
2166
|
+
};
|
|
2167
|
+
const transformAliasInExpressionInternal = (expr, alias, isPrimitive) => {
|
|
2168
|
+
// istanbul ignore next
|
|
2169
|
+
if (!alias) return expr;
|
|
2170
|
+
if (isCELIdentifier(expr) && expr.value === alias) return {
|
|
2171
|
+
type: "Identifier",
|
|
2172
|
+
value: ""
|
|
2173
|
+
};
|
|
2174
|
+
if (isCELMember(expr) && expr.left && isCELIdentifier(expr.left) && expr.left.value === alias) {
|
|
2175
|
+
if (expr.right && isCELIdentifier(expr.right) && !isPrimitive) return expr.right;
|
|
2176
|
+
}
|
|
2177
|
+
if (isCELLikeExpression(expr) && isCELIdentifier(expr.left) && expr.left.value === alias) return {
|
|
2178
|
+
type: "Member",
|
|
2179
|
+
left: {
|
|
2180
|
+
type: "Identifier",
|
|
2181
|
+
value: ""
|
|
2182
|
+
},
|
|
2183
|
+
right: expr.right,
|
|
2184
|
+
list: expr.list
|
|
2185
|
+
};
|
|
2186
|
+
if (isCELNegatedLikeExpression(expr) && expr.left && isCELNegatedIdentifier(expr.left) && expr.left.value.value === alias) return {
|
|
2187
|
+
type: "Member",
|
|
2188
|
+
left: {
|
|
2189
|
+
type: "Negation",
|
|
2190
|
+
negations: expr.left.negations,
|
|
2191
|
+
value: {
|
|
2192
|
+
type: "Identifier",
|
|
2193
|
+
value: ""
|
|
2194
|
+
}
|
|
2195
|
+
},
|
|
2196
|
+
right: expr.right,
|
|
2197
|
+
list: expr.list
|
|
2198
|
+
};
|
|
2199
|
+
if (isCELMember(expr) && expr.left && expr.right) {
|
|
2200
|
+
const transformedLeft = transformAliasInExpressionInternal(expr.left, alias, isPrimitive);
|
|
2201
|
+
// istanbul ignore else
|
|
2202
|
+
if (transformedLeft !== expr.left) return {
|
|
2203
|
+
type: "Member",
|
|
2204
|
+
left: transformedLeft,
|
|
2205
|
+
right: expr.right,
|
|
2206
|
+
list: expr.list,
|
|
2207
|
+
value: expr.value
|
|
2208
|
+
};
|
|
2209
|
+
}
|
|
2210
|
+
if (isCELRelation(expr)) return {
|
|
2211
|
+
type: "Relation",
|
|
2212
|
+
left: transformAliasInExpressionInternal(expr.left, alias, isPrimitive),
|
|
2213
|
+
right: transformAliasInExpressionInternal(expr.right, alias, isPrimitive),
|
|
2214
|
+
operator: expr.operator
|
|
2215
|
+
};
|
|
2216
|
+
if (isCELConditionalAnd(expr)) return {
|
|
2217
|
+
type: "ConditionalAnd",
|
|
2218
|
+
left: transformAliasInExpressionInternal(expr.left, alias, isPrimitive),
|
|
2219
|
+
right: transformAliasInExpressionInternal(expr.right, alias, isPrimitive)
|
|
2220
|
+
};
|
|
2221
|
+
if (isCELConditionalOr(expr)) return {
|
|
2222
|
+
type: "ConditionalOr",
|
|
2223
|
+
left: transformAliasInExpressionInternal(expr.left, alias, isPrimitive),
|
|
2224
|
+
right: transformAliasInExpressionInternal(expr.right, alias, isPrimitive)
|
|
2225
|
+
};
|
|
2226
|
+
if (isCELExpressionGroup(expr)) return {
|
|
2227
|
+
type: "ExpressionGroup",
|
|
2228
|
+
value: transformAliasInExpressionInternal(expr.value, alias, isPrimitive)
|
|
2229
|
+
};
|
|
2230
|
+
if (isCELNegation(expr)) return {
|
|
2231
|
+
type: "Negation",
|
|
2232
|
+
negations: expr.negations,
|
|
2233
|
+
value: transformAliasInExpressionInternal(expr.value, alias, isPrimitive)
|
|
2234
|
+
};
|
|
2235
|
+
return expr;
|
|
2236
|
+
};
|
|
2237
|
+
const transformAliasInExpression = (expr, alias) => {
|
|
2238
|
+
// istanbul ignore next
|
|
2239
|
+
if (!alias) return expr;
|
|
2240
|
+
return transformAliasInExpressionInternal(expr, alias, isPrimitiveArrayUsage(expr, alias));
|
|
2241
|
+
};
|
|
2133
2242
|
|
|
2134
2243
|
//#endregion
|
|
2135
2244
|
//#region src/utils/parseCEL/parseCEL.ts
|
|
@@ -2228,6 +2337,52 @@ function parseCEL(cel, options = {}) {
|
|
|
2228
2337
|
operator,
|
|
2229
2338
|
value
|
|
2230
2339
|
};
|
|
2340
|
+
} else if (isCELSubqueryExpression(expr)) {
|
|
2341
|
+
const components = extractSubqueryComponents(expr);
|
|
2342
|
+
// istanbul ignore else
|
|
2343
|
+
if (components) {
|
|
2344
|
+
const { field, method, alias, condition } = components;
|
|
2345
|
+
const matchMode = method === "all" ? "all" : "some";
|
|
2346
|
+
const subqueryValue = processCELExpression(transformAliasInExpression(condition, alias));
|
|
2347
|
+
if (subqueryValue && fieldIsValid(field, "=")) {
|
|
2348
|
+
const ruleGroupValue = require_isRuleGroup.isRuleGroup(subqueryValue) ? subqueryValue : ic ? { rules: [subqueryValue] } : {
|
|
2349
|
+
combinator: "and",
|
|
2350
|
+
rules: [subqueryValue]
|
|
2351
|
+
};
|
|
2352
|
+
return {
|
|
2353
|
+
field,
|
|
2354
|
+
operator: "=",
|
|
2355
|
+
match: { mode: matchMode },
|
|
2356
|
+
value: ruleGroupValue
|
|
2357
|
+
};
|
|
2358
|
+
}
|
|
2359
|
+
}
|
|
2360
|
+
} else if (isCELNegatedSubqueryExpression(expr)) {
|
|
2361
|
+
const field = getCELIdentifierFromNegatedChain(expr.left).replace(/^!+/, "");
|
|
2362
|
+
const method = expr.right.value;
|
|
2363
|
+
const [aliasExpr, conditionExpr] = expr.list.value;
|
|
2364
|
+
const subqueryValue = processCELExpression(transformAliasInExpression(conditionExpr, isCELIdentifier(aliasExpr) ? aliasExpr.value : null));
|
|
2365
|
+
// istanbul ignore else
|
|
2366
|
+
if (subqueryValue && fieldIsValid(field, "=")) {
|
|
2367
|
+
const ruleGroupValue = require_isRuleGroup.isRuleGroup(subqueryValue) ? subqueryValue : ic ? { rules: [subqueryValue] } : {
|
|
2368
|
+
combinator: "and",
|
|
2369
|
+
rules: [subqueryValue]
|
|
2370
|
+
};
|
|
2371
|
+
const subqueryRule = {
|
|
2372
|
+
field,
|
|
2373
|
+
operator: "=",
|
|
2374
|
+
match: { mode: method === "all" ? "all" : "some" },
|
|
2375
|
+
value: ruleGroupValue
|
|
2376
|
+
};
|
|
2377
|
+
return ic ? {
|
|
2378
|
+
not: true,
|
|
2379
|
+
rules: [subqueryRule]
|
|
2380
|
+
} : {
|
|
2381
|
+
combinator: "and",
|
|
2382
|
+
not: true,
|
|
2383
|
+
rules: [subqueryRule]
|
|
2384
|
+
};
|
|
2385
|
+
}
|
|
2231
2386
|
} else if (isCELRelation(expr)) {
|
|
2232
2387
|
let field = null;
|
|
2233
2388
|
let value = void 0;
|
|
@@ -2246,7 +2401,7 @@ function parseCEL(cel, options = {}) {
|
|
|
2246
2401
|
value = evalCELLiteralValue(left);
|
|
2247
2402
|
}
|
|
2248
2403
|
let operator = celNormalizeOperator(expr.operator, flip);
|
|
2249
|
-
if (forwardedNegation) operator =
|
|
2404
|
+
if (forwardedNegation) operator = require_utils.defaultOperatorNegationMap[operator];
|
|
2250
2405
|
if (value === null && (operator === "=" || operator === "!=")) operator = operator === "=" ? "null" : "notNull";
|
|
2251
2406
|
else if ((operator === "in" || operator === "notIn") && isCELList(right)) {
|
|
2252
2407
|
if (right.value.value.every((v) => isCELLiteral(v))) value = right.value.value.map((v) => evalCELLiteralValue(v));
|
|
@@ -2254,13 +2409,13 @@ function parseCEL(cel, options = {}) {
|
|
|
2254
2409
|
valueSource = "field";
|
|
2255
2410
|
value = right.value.value.map((id) => getCELIdentifierFromChain(id));
|
|
2256
2411
|
}
|
|
2257
|
-
if (value && !listsAsArrays) value =
|
|
2412
|
+
if (value && !listsAsArrays) value = require_utils.joinWith(value.map((v) => `${v}`), ",");
|
|
2258
2413
|
} else if ((operator === "in" || operator === "notIn") && isCELMap(right)) {
|
|
2259
2414
|
const keys = right.value.value.map((v) => v.left);
|
|
2260
2415
|
if (keys.every((k) => isCELLiteral(k) || isCELIdentifierOrChain(k))) value = keys.map((k) => isCELLiteral(k) ? evalCELLiteralValue(k) : getCELIdentifierFromChain(k));
|
|
2261
|
-
if (value && !listsAsArrays) value =
|
|
2416
|
+
if (value && !listsAsArrays) value = require_utils.joinWith(value.map((v) => `${v}`), ",");
|
|
2262
2417
|
}
|
|
2263
|
-
if (field && fieldIsValid(field, operator, valueSource === "field" ? value : void 0) && value !== void 0) return valueSource ? {
|
|
2418
|
+
if (field !== null && fieldIsValid(field, operator, valueSource === "field" ? value : void 0) && value !== void 0) return valueSource ? {
|
|
2264
2419
|
field,
|
|
2265
2420
|
operator,
|
|
2266
2421
|
value,
|
|
@@ -2298,6 +2453,7 @@ exports.celGenerateMixedAndOrList = celGenerateMixedAndOrList;
|
|
|
2298
2453
|
exports.celNormalizeCombinator = celNormalizeCombinator;
|
|
2299
2454
|
exports.celNormalizeOperator = celNormalizeOperator;
|
|
2300
2455
|
exports.evalCELLiteralValue = evalCELLiteralValue;
|
|
2456
|
+
exports.extractSubqueryComponents = extractSubqueryComponents;
|
|
2301
2457
|
exports.getCELIdentifierFromChain = getCELIdentifierFromChain;
|
|
2302
2458
|
exports.getCELIdentifierFromNegatedChain = getCELIdentifierFromNegatedChain;
|
|
2303
2459
|
exports.isCELAddition = isCELAddition;
|
|
@@ -2330,6 +2486,7 @@ exports.isCELMultiplication = isCELMultiplication;
|
|
|
2330
2486
|
exports.isCELNegatedIdentifier = isCELNegatedIdentifier;
|
|
2331
2487
|
exports.isCELNegatedIdentifierOrChain = isCELNegatedIdentifierOrChain;
|
|
2332
2488
|
exports.isCELNegatedLikeExpression = isCELNegatedLikeExpression;
|
|
2489
|
+
exports.isCELNegatedSubqueryExpression = isCELNegatedSubqueryExpression;
|
|
2333
2490
|
exports.isCELNegation = isCELNegation;
|
|
2334
2491
|
exports.isCELNegative = isCELNegative;
|
|
2335
2492
|
exports.isCELNullLiteral = isCELNullLiteral;
|
|
@@ -2337,7 +2494,9 @@ exports.isCELNumericLiteral = isCELNumericLiteral;
|
|
|
2337
2494
|
exports.isCELProperty = isCELProperty;
|
|
2338
2495
|
exports.isCELRelation = isCELRelation;
|
|
2339
2496
|
exports.isCELStringLiteral = isCELStringLiteral;
|
|
2497
|
+
exports.isCELSubqueryExpression = isCELSubqueryExpression;
|
|
2340
2498
|
exports.isCELSubtraction = isCELSubtraction;
|
|
2341
2499
|
exports.isCELUnsignedIntegerLiteral = isCELUnsignedIntegerLiteral;
|
|
2342
2500
|
exports.parseCEL = parseCEL;
|
|
2501
|
+
exports.transformAliasInExpression = transformAliasInExpression;
|
|
2343
2502
|
//# sourceMappingURL=parseCEL.js.map
|