@react-querybuilder/core 8.20.2 → 8.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +2261 -2113
- package/dist/cjs/react-querybuilder_core.cjs.development.js +319 -22
- package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +2261 -2113
- 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-BJKNgecE.js → convertQuery-Cw76XFIn.js} +8 -8
- package/dist/{convertQuery-BJKNgecE.js.map → convertQuery-Cw76XFIn.js.map} +1 -1
- package/dist/{convertQuery-J1CaoDxe.mjs → convertQuery-D_4J7E-Z.mjs} +2 -2
- package/dist/{convertQuery-J1CaoDxe.mjs.map → convertQuery-D_4J7E-Z.mjs.map} +1 -1
- package/dist/formatQuery.d.mts +499 -459
- package/dist/formatQuery.d.ts +499 -459
- package/dist/formatQuery.js +170 -88
- package/dist/formatQuery.js.map +1 -1
- package/dist/formatQuery.mjs +97 -20
- package/dist/formatQuery.mjs.map +1 -1
- package/dist/import-BVdxeIBO.d.mts +26 -0
- package/dist/import-Ddc3d_8q.d.ts +26 -0
- package/dist/{index-DlVg-QXo.d.mts → index-BSwFvkeI.d.mts} +679 -648
- package/dist/{index-DlVg-QXo.d.ts → index-BSwFvkeI.d.ts} +679 -648
- package/dist/{objectUtils-DBJI82bl.js → isRuleGroup-0JNiQgLg.js} +1 -26
- package/dist/isRuleGroup-0JNiQgLg.js.map +1 -0
- package/dist/{objectUtils-ZvPkF6u6.mjs → isRuleGroup-CqLThsbu.mjs} +2 -15
- package/dist/isRuleGroup-CqLThsbu.mjs.map +1 -0
- package/dist/objectUtils-Cr02aGxb.js +27 -0
- package/dist/objectUtils-Cr02aGxb.js.map +1 -0
- package/dist/objectUtils-DBlmJgBf.mjs +16 -0
- package/dist/objectUtils-DBlmJgBf.mjs.map +1 -0
- package/dist/parseCEL.d.mts +64 -30
- package/dist/parseCEL.d.ts +64 -30
- package/dist/parseCEL.js +91 -12
- package/dist/parseCEL.js.map +1 -1
- package/dist/parseCEL.mjs +85 -8
- package/dist/parseCEL.mjs.map +1 -1
- package/dist/parseCypher.d.mts +24 -25
- package/dist/parseCypher.d.ts +24 -25
- package/dist/parseGremlin.d.mts +18 -19
- package/dist/parseGremlin.d.ts +18 -19
- package/dist/parseJSONata.d.mts +207 -20
- package/dist/parseJSONata.d.ts +207 -20
- package/dist/parseJSONata.js +92 -7
- package/dist/parseJSONata.js.map +1 -1
- package/dist/parseJSONata.mjs +80 -4
- package/dist/parseJSONata.mjs.map +1 -1
- package/dist/parseJsonLogic.d.mts +51 -18
- package/dist/parseJsonLogic.d.ts +51 -18
- package/dist/parseJsonLogic.js +95 -34
- package/dist/parseJsonLogic.js.map +1 -1
- package/dist/parseJsonLogic.mjs +65 -6
- package/dist/parseJsonLogic.mjs.map +1 -1
- package/dist/parseMongoDB.d.mts +89 -58
- package/dist/parseMongoDB.d.ts +89 -58
- package/dist/parseMongoDB.js +140 -15
- package/dist/parseMongoDB.js.map +1 -1
- package/dist/parseMongoDB.mjs +128 -5
- package/dist/parseMongoDB.mjs.map +1 -1
- package/dist/parseSPARQL.d.mts +17 -18
- package/dist/parseSPARQL.d.ts +17 -18
- package/dist/parseSPARQL.js.map +1 -1
- package/dist/parseSPARQL.mjs.map +1 -1
- package/dist/parseSQL.d.mts +266 -18
- package/dist/parseSQL.d.ts +266 -18
- package/dist/parseSQL.js +163 -10
- package/dist/parseSQL.js.map +1 -1
- package/dist/parseSQL.mjs +149 -7
- package/dist/parseSQL.mjs.map +1 -1
- package/dist/parseSpEL.d.mts +193 -19
- package/dist/parseSpEL.d.ts +193 -19
- package/dist/parseSpEL.js +166 -7
- package/dist/parseSpEL.js.map +1 -1
- package/dist/parseSpEL.mjs +142 -6
- package/dist/parseSpEL.mjs.map +1 -1
- package/dist/{prepareQueryObjects-Bni5VgYM.js → prepareQueryObjects-C2-kTZvR.js} +5 -5
- package/dist/prepareQueryObjects-C2-kTZvR.js.map +1 -0
- package/dist/{prepareQueryObjects-BCLU20Cg.mjs → prepareQueryObjects-Q18lHCKl.mjs} +3 -3
- package/dist/prepareQueryObjects-Q18lHCKl.mjs.map +1 -0
- package/dist/query-builder-layout.css.map +1 -1
- package/dist/query-builder.css.map +1 -1
- package/dist/react-querybuilder_core.d.mts +2261 -2113
- package/dist/react-querybuilder_core.legacy-esm.d.ts +2261 -2113
- package/dist/react-querybuilder_core.legacy-esm.js +335 -40
- package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
- package/dist/react-querybuilder_core.mjs +309 -23
- package/dist/react-querybuilder_core.mjs.map +1 -1
- package/dist/react-querybuilder_core.production.d.mts +2261 -2113
- package/dist/react-querybuilder_core.production.mjs +1 -1
- package/dist/react-querybuilder_core.production.mjs.map +1 -1
- package/dist/styles/_layout.scss +18 -14
- package/dist/styles/_main.scss +7 -2
- package/dist/transformQuery.d.mts +91 -92
- package/dist/transformQuery.d.ts +91 -92
- package/dist/transformQuery.js +4 -3
- package/dist/transformQuery.js.map +1 -1
- package/dist/transformQuery.mjs +2 -1
- package/dist/transformQuery.mjs.map +1 -1
- package/dist/{utils-BpaOtylk.js → utils-DEwV7F6B.js} +108 -12
- package/dist/utils-DEwV7F6B.js.map +1 -0
- package/dist/{utils-CJRGiPb-.mjs → utils-Dt0D_DMV.mjs} +69 -3
- package/dist/utils-Dt0D_DMV.mjs.map +1 -0
- package/package.json +16 -16
- package/dist/import-Qs1-kgv5.d.ts +0 -27
- package/dist/import-ShTj5IdB.d.mts +0 -27
- package/dist/objectUtils-DBJI82bl.js.map +0 -1
- package/dist/objectUtils-ZvPkF6u6.mjs.map +0 -1
- package/dist/prepareQueryObjects-BCLU20Cg.mjs.map +0 -1
- package/dist/prepareQueryObjects-Bni5VgYM.js.map +0 -1
- package/dist/utils-BpaOtylk.js.map +0 -1
- package/dist/utils-CJRGiPb-.mjs.map +0 -1
|
@@ -33,19 +33,6 @@ const isRuleGroupType = (rg) => isRuleGroup(rg) && typeof rg.combinator === "str
|
|
|
33
33
|
*/
|
|
34
34
|
const isRuleGroupTypeIC = (rg) => isRuleGroup(rg) && rg.combinator === void 0;
|
|
35
35
|
//#endregion
|
|
36
|
-
//#region src/utils/objectUtils.ts
|
|
37
|
-
/**
|
|
38
|
-
* A strongly-typed version of `Object.keys()`.
|
|
39
|
-
*
|
|
40
|
-
* [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-keys.ts)
|
|
41
|
-
*/
|
|
42
|
-
const objectKeys = Object.keys;
|
|
43
|
-
/**
|
|
44
|
-
* Returns `true` if the key could cause prototype pollution when used
|
|
45
|
-
* as a property name in bracket-notation assignment.
|
|
46
|
-
*/
|
|
47
|
-
const isUnsafeKey = (key) => key === "__proto__" || key === "constructor" || key === "prototype";
|
|
48
|
-
//#endregion
|
|
49
36
|
Object.defineProperty(exports, "isPojo", {
|
|
50
37
|
enumerable: true,
|
|
51
38
|
get: function() {
|
|
@@ -70,12 +57,6 @@ Object.defineProperty(exports, "isRuleGroupTypeIC", {
|
|
|
70
57
|
return isRuleGroupTypeIC;
|
|
71
58
|
}
|
|
72
59
|
});
|
|
73
|
-
Object.defineProperty(exports, "isUnsafeKey", {
|
|
74
|
-
enumerable: true,
|
|
75
|
-
get: function() {
|
|
76
|
-
return isUnsafeKey;
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
60
|
Object.defineProperty(exports, "lc", {
|
|
80
61
|
enumerable: true,
|
|
81
62
|
get: function() {
|
|
@@ -94,11 +75,5 @@ Object.defineProperty(exports, "numericRegex", {
|
|
|
94
75
|
return numericRegex;
|
|
95
76
|
}
|
|
96
77
|
});
|
|
97
|
-
Object.defineProperty(exports, "objectKeys", {
|
|
98
|
-
enumerable: true,
|
|
99
|
-
get: function() {
|
|
100
|
-
return objectKeys;
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
78
|
|
|
104
|
-
//# sourceMappingURL=
|
|
79
|
+
//# sourceMappingURL=isRuleGroup-0JNiQgLg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isRuleGroup-0JNiQgLg.js","names":["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// v8 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: unknown): obj is Record<string, any> =>\n obj !== null && typeof obj === 'object' && 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,YAAY,IAAU;;;;;AAMpF,MAAa,eAAuB,IAAI,OACtCA,iBAAAA,aAAqB,OAAO,QAAQ,OAAO,OAAO,GAAG,MAAM,CAAC,CAAC,QAAQ,OAAO,OAAO,GAAG,MAAM,CAC9F;;;;AAMA,MAAa,UAAU,QACrB,QAAQ,QAAQ,OAAO,QAAQ,YAAY,OAAO,eAAe,GAAG,MAAM,OAAO;;;;AAKnF,MAAa,0BAA0B,UACrC,UAAU,QAAQ,UAAU,KAAA,KAAa,UAAU;;;;;;ACfrD,MAAa,eAAe,OAC1B,OAAO,EAAE,KAAK,MAAM,QAAQ,GAAG,KAAK;;;;AAKtC,MAAa,mBAAmB,OAC9B,YAAY,EAAE,KAAK,OAAO,GAAG,eAAe;;;;AAK9C,MAAa,qBAAqB,OAChC,YAAY,EAAE,KAAK,GAAG,eAAe,KAAA"}
|
|
@@ -33,19 +33,6 @@ const isRuleGroupType = (rg) => isRuleGroup(rg) && typeof rg.combinator === "str
|
|
|
33
33
|
*/
|
|
34
34
|
const isRuleGroupTypeIC = (rg) => isRuleGroup(rg) && rg.combinator === void 0;
|
|
35
35
|
//#endregion
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* A strongly-typed version of `Object.keys()`.
|
|
39
|
-
*
|
|
40
|
-
* [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-keys.ts)
|
|
41
|
-
*/
|
|
42
|
-
const objectKeys = Object.keys;
|
|
43
|
-
/**
|
|
44
|
-
* Returns `true` if the key could cause prototype pollution when used
|
|
45
|
-
* as a property name in bracket-notation assignment.
|
|
46
|
-
*/
|
|
47
|
-
const isUnsafeKey = (key) => key === "__proto__" || key === "constructor" || key === "prototype";
|
|
48
|
-
//#endregion
|
|
49
|
-
export { isRuleGroupTypeIC as a, nullOrUndefinedOrEmpty as c, isRuleGroupType as i, numericRegex$1 as l, objectKeys as n, isPojo as o, isRuleGroup as r, lc as s, isUnsafeKey as t };
|
|
36
|
+
export { lc as a, isPojo as i, isRuleGroupType as n, nullOrUndefinedOrEmpty as o, isRuleGroupTypeIC as r, numericRegex$1 as s, isRuleGroup as t };
|
|
50
37
|
|
|
51
|
-
//# sourceMappingURL=
|
|
38
|
+
//# sourceMappingURL=isRuleGroup-CqLThsbu.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isRuleGroup-CqLThsbu.mjs","names":["numericRegex","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// v8 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: unknown): obj is Record<string, any> =>\n obj !== null && typeof obj === 'object' && 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,YAAY,IAAU;;;;;AAMpF,MAAaA,iBAAuB,IAAI,OACtCC,aAAqB,OAAO,QAAQ,OAAO,OAAO,GAAG,MAAM,CAAC,CAAC,QAAQ,OAAO,OAAO,GAAG,MAAM,CAC9F;;;;AAMA,MAAa,UAAU,QACrB,QAAQ,QAAQ,OAAO,QAAQ,YAAY,OAAO,eAAe,GAAG,MAAM,OAAO;;;;AAKnF,MAAa,0BAA0B,UACrC,UAAU,QAAQ,UAAU,KAAA,KAAa,UAAU;;;;;;ACfrD,MAAa,eAAe,OAC1B,OAAO,EAAE,KAAK,MAAM,QAAQ,GAAG,KAAK;;;;AAKtC,MAAa,mBAAmB,OAC9B,YAAY,EAAE,KAAK,OAAO,GAAG,eAAe;;;;AAK9C,MAAa,qBAAqB,OAChC,YAAY,EAAE,KAAK,GAAG,eAAe,KAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/utils/objectUtils.ts
|
|
2
|
+
/**
|
|
3
|
+
* A strongly-typed version of `Object.keys()`.
|
|
4
|
+
*
|
|
5
|
+
* [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-keys.ts)
|
|
6
|
+
*/
|
|
7
|
+
const objectKeys = Object.keys;
|
|
8
|
+
/**
|
|
9
|
+
* Returns `true` if the key could cause prototype pollution when used
|
|
10
|
+
* as a property name in bracket-notation assignment.
|
|
11
|
+
*/
|
|
12
|
+
const isUnsafeKey = (key) => key === "__proto__" || key === "constructor" || key === "prototype";
|
|
13
|
+
//#endregion
|
|
14
|
+
Object.defineProperty(exports, "isUnsafeKey", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function() {
|
|
17
|
+
return isUnsafeKey;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "objectKeys", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function() {
|
|
23
|
+
return objectKeys;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=objectUtils-Cr02aGxb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectUtils-Cr02aGxb.js","names":[],"sources":["../src/utils/objectUtils.ts"],"sourcesContent":["// All code in this file is adapted from:\n// npm: https://www.npmjs.com/package/ts-extras\n// src: https://github.com/sindresorhus/ts-extras\n\n/**\n * Original looked like this (not sure why template string is used):\n * ```\n * type ObjectKeys<T extends object> = `${Exclude<keyof T, symbol>}`;\n * ```\n */\ntype ObjectKeys<T extends object> = Exclude<keyof T, symbol>;\n\n/**\n * A strongly-typed version of `Object.keys()`.\n *\n * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-keys.ts)\n */\nexport const objectKeys = Object.keys as <Type extends object>(\n value: Type\n) => Array<ObjectKeys<Type>>;\n\n/**\n * A strongly-typed version of `Object.entries()`.\n *\n * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-entries.ts)\n */\nexport const objectEntries = Object.entries as <Type extends Record<PropertyKey, unknown>>(\n value: Type\n) => Array<[ObjectKeys<Type>, Type[ObjectKeys<Type>]]>;\n\n/**\n * Returns `true` if the key could cause prototype pollution when used\n * as a property name in bracket-notation assignment.\n */\nexport const isUnsafeKey = (key: unknown): boolean =>\n key === '__proto__' || key === 'constructor' || key === 'prototype';\n"],"mappings":";;;;;;AAiBA,MAAa,aAAa,OAAO;;;;;AAiBjC,MAAa,eAAe,QAC1B,QAAQ,eAAe,QAAQ,iBAAiB,QAAQ"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/utils/objectUtils.ts
|
|
2
|
+
/**
|
|
3
|
+
* A strongly-typed version of `Object.keys()`.
|
|
4
|
+
*
|
|
5
|
+
* [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-keys.ts)
|
|
6
|
+
*/
|
|
7
|
+
const objectKeys = Object.keys;
|
|
8
|
+
/**
|
|
9
|
+
* Returns `true` if the key could cause prototype pollution when used
|
|
10
|
+
* as a property name in bracket-notation assignment.
|
|
11
|
+
*/
|
|
12
|
+
const isUnsafeKey = (key) => key === "__proto__" || key === "constructor" || key === "prototype";
|
|
13
|
+
//#endregion
|
|
14
|
+
export { objectKeys as n, isUnsafeKey as t };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=objectUtils-DBlmJgBf.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectUtils-DBlmJgBf.mjs","names":[],"sources":["../src/utils/objectUtils.ts"],"sourcesContent":["// All code in this file is adapted from:\n// npm: https://www.npmjs.com/package/ts-extras\n// src: https://github.com/sindresorhus/ts-extras\n\n/**\n * Original looked like this (not sure why template string is used):\n * ```\n * type ObjectKeys<T extends object> = `${Exclude<keyof T, symbol>}`;\n * ```\n */\ntype ObjectKeys<T extends object> = Exclude<keyof T, symbol>;\n\n/**\n * A strongly-typed version of `Object.keys()`.\n *\n * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-keys.ts)\n */\nexport const objectKeys = Object.keys as <Type extends object>(\n value: Type\n) => Array<ObjectKeys<Type>>;\n\n/**\n * A strongly-typed version of `Object.entries()`.\n *\n * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-entries.ts)\n */\nexport const objectEntries = Object.entries as <Type extends Record<PropertyKey, unknown>>(\n value: Type\n) => Array<[ObjectKeys<Type>, Type[ObjectKeys<Type>]]>;\n\n/**\n * Returns `true` if the key could cause prototype pollution when used\n * as a property name in bracket-notation assignment.\n */\nexport const isUnsafeKey = (key: unknown): boolean =>\n key === '__proto__' || key === 'constructor' || key === 'prototype';\n"],"mappings":";;;;;;AAiBA,MAAa,aAAa,OAAO;;;;;AAiBjC,MAAa,eAAe,QAC1B,QAAQ,eAAe,QAAQ,iBAAiB,QAAQ"}
|
package/dist/parseCEL.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as ParserCommonOptions } from "./import-
|
|
3
|
-
|
|
1
|
+
import { A as DefaultOperatorName, D as RuleGroupTypeIC, L as Except, M as RuleGroupType, N as RuleType, O as DefaultCombinatorName, P as ExpressionNode, T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-BSwFvkeI.mjs";
|
|
2
|
+
import { t as ParserCommonOptions } from "./import-BVdxeIBO.mjs";
|
|
4
3
|
//#region src/utils/parseCEL/types.d.ts
|
|
5
4
|
type CELExpressionType = "Addition" | "BooleanLiteral" | "BytesLiteral" | "ConditionalAnd" | "ConditionalExpr" | "ConditionalOr" | "Division" | "DynamicPropertyAccessor" | "ExpressionGroup" | "ExpressionList" | "FieldInit" | "FieldInits" | "MessageInit" | "FloatLiteral" | "FunctionCall" | "Identifier" | "IntegerLiteral" | "List" | "Map" | "MapInit" | "MapInits" | "Member" | "Modulo" | "Multiplication" | "Negation" | "Negative" | "NullLiteral" | "Property" | "Relation" | "StringLiteral" | "Subtraction" | "Unary" | "UnsignedIntegerLiteral" | "LikeExpression" | "SubqueryExpression";
|
|
6
5
|
type CELRelop = "==" | ">=" | ">" | "<=" | "<" | "!=" | "in";
|
|
@@ -218,59 +217,85 @@ interface ParsedCEL {
|
|
|
218
217
|
nodeType: "Main";
|
|
219
218
|
value: CELExpression;
|
|
220
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* A CEL operand subtree that {@link parseCEL!ParseCELOptions.getExpression} may receive — an
|
|
222
|
+
* arithmetic infix node (`Addition`/`Subtraction`/`Multiplication`/`Division`/`Modulo`,
|
|
223
|
+
* optionally wrapped in an `ExpressionGroup`), a `FunctionCall`, or a `ConditionalExpr` (the
|
|
224
|
+
* `min`/`max` emulated template).
|
|
225
|
+
*/
|
|
226
|
+
type CELExpressionOperand = CELExpression;
|
|
227
|
+
/** Context passed to {@link parseCEL!ParseCELOptions.getExpression}. */
|
|
228
|
+
interface ParseCELExpressionContext {
|
|
229
|
+
/** Returns `true` if the field is configured (or if no `fields` were supplied). */
|
|
230
|
+
fieldExists: (fieldName: string) => boolean;
|
|
231
|
+
}
|
|
221
232
|
//#endregion
|
|
222
233
|
//#region src/utils/parseCEL/parseCEL.d.ts
|
|
223
234
|
interface ParseCELOptionsStandard extends Except<ParserCommonOptions, "independentCombinators"> {
|
|
224
235
|
independentCombinators?: false;
|
|
225
236
|
/**
|
|
226
|
-
|
|
227
|
-
|
|
237
|
+
* Handler for custom CEL expressions.
|
|
238
|
+
*/
|
|
228
239
|
customExpressionHandler?: (expr: CELExpression) => RuleType | RuleGroupType | null;
|
|
240
|
+
/**
|
|
241
|
+
* Handler that converts a CEL arithmetic/function operand subtree into an
|
|
242
|
+
* {@link ExpressionNode}. Return `null` to reject (the rule is dropped). Supplied by
|
|
243
|
+
* `@react-querybuilder/expr` (`expressionParserCEL`). When omitted, expression operands
|
|
244
|
+
* are ignored (rule dropped).
|
|
245
|
+
*/
|
|
246
|
+
getExpression?: (node: CELExpressionOperand, ctx: ParseCELExpressionContext) => ExpressionNode | null;
|
|
229
247
|
}
|
|
230
248
|
interface ParseCELOptionsIC extends Except<ParserCommonOptions, "independentCombinators"> {
|
|
231
249
|
independentCombinators: true;
|
|
232
250
|
/**
|
|
233
|
-
|
|
234
|
-
|
|
251
|
+
* Handler for custom CEL expressions.
|
|
252
|
+
*/
|
|
235
253
|
customExpressionHandler?: (expr: CELExpression) => RuleType | RuleGroupTypeIC | null;
|
|
254
|
+
/**
|
|
255
|
+
* Handler that converts a CEL arithmetic/function operand subtree into an
|
|
256
|
+
* {@link ExpressionNode}. Return `null` to reject (the rule is dropped). Supplied by
|
|
257
|
+
* `@react-querybuilder/expr` (`expressionParserCEL`). When omitted, expression operands
|
|
258
|
+
* are ignored (rule dropped).
|
|
259
|
+
*/
|
|
260
|
+
getExpression?: (node: CELExpressionOperand, ctx: ParseCELExpressionContext) => ExpressionNode | null;
|
|
236
261
|
}
|
|
237
262
|
/**
|
|
238
|
-
* Options object for {@link parseCEL}.
|
|
239
|
-
*/
|
|
263
|
+
* Options object for {@link parseCEL}.
|
|
264
|
+
*/
|
|
240
265
|
type ParseCELOptions = ParseCELOptionsStandard | ParseCELOptionsIC;
|
|
241
266
|
/**
|
|
242
|
-
* Converts a CEL string expression into a query suitable for the
|
|
243
|
-
* {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
|
|
244
|
-
* ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
|
|
245
|
-
*/
|
|
267
|
+
* Converts a CEL string expression into a query suitable for the
|
|
268
|
+
* {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
|
|
269
|
+
* ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
|
|
270
|
+
*/
|
|
246
271
|
declare function parseCEL(cel: string): DefaultRuleGroupType;
|
|
247
272
|
/**
|
|
248
|
-
* Converts a CEL string expression into a query suitable for the
|
|
249
|
-
* {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
|
|
250
|
-
* ({@link index!RuleGroupType RuleGroupType}).
|
|
251
|
-
*/
|
|
273
|
+
* Converts a CEL string expression into a query suitable for the
|
|
274
|
+
* {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
|
|
275
|
+
* ({@link index!RuleGroupType RuleGroupType}).
|
|
276
|
+
*/
|
|
252
277
|
declare function parseCEL(cel: string, options: ParseCELOptionsStandard & {
|
|
253
278
|
customExpressionHandler: (expr: CELExpression) => RuleType | RuleGroupType | null;
|
|
254
279
|
}): RuleGroupType;
|
|
255
280
|
/**
|
|
256
|
-
* Converts a CEL string expression into a query suitable for the
|
|
257
|
-
* {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
|
|
258
|
-
* ({@link index!RuleGroupTypeIC RuleGroupTypeIC}).
|
|
259
|
-
*/
|
|
281
|
+
* Converts a CEL string expression into a query suitable for the
|
|
282
|
+
* {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
|
|
283
|
+
* ({@link index!RuleGroupTypeIC RuleGroupTypeIC}).
|
|
284
|
+
*/
|
|
260
285
|
declare function parseCEL(cel: string, options: ParseCELOptionsIC & {
|
|
261
286
|
customExpressionHandler: (expr: CELExpression) => RuleType | RuleGroupTypeIC | null;
|
|
262
287
|
}): RuleGroupTypeIC;
|
|
263
288
|
/**
|
|
264
|
-
* Converts a CEL string expression into a query suitable for the
|
|
265
|
-
* {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
|
|
266
|
-
* ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
|
|
267
|
-
*/
|
|
289
|
+
* Converts a CEL string expression into a query suitable for the
|
|
290
|
+
* {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
|
|
291
|
+
* ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
|
|
292
|
+
*/
|
|
268
293
|
declare function parseCEL(cel: string, options?: ParseCELOptionsStandard): DefaultRuleGroupType;
|
|
269
294
|
/**
|
|
270
|
-
* Converts a CEL string expression into a query suitable for the
|
|
271
|
-
* {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
|
|
272
|
-
* ({@link index!DefaultRuleGroupTypeIC DefaultRuleGroupTypeIC}).
|
|
273
|
-
*/
|
|
295
|
+
* Converts a CEL string expression into a query suitable for the
|
|
296
|
+
* {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
|
|
297
|
+
* ({@link index!DefaultRuleGroupTypeIC DefaultRuleGroupTypeIC}).
|
|
298
|
+
*/
|
|
274
299
|
declare function parseCEL(cel: string, options: ParseCELOptionsIC): DefaultRuleGroupTypeIC;
|
|
275
300
|
//#endregion
|
|
276
301
|
//#region src/utils/parseCEL/utils.d.ts
|
|
@@ -334,6 +359,15 @@ declare const celNormalizeOperator: (op: CELRelop, flip?: boolean) => DefaultOpe
|
|
|
334
359
|
declare const celGenerateFlatAndOrList: (expr: CELConditionalAnd | CELConditionalOr) => (DefaultCombinatorName | CELExpression)[];
|
|
335
360
|
declare const celGenerateMixedAndOrList: (expr: CELConditionalAnd | CELConditionalOr) => (DefaultCombinatorName | CELExpression | ("and" | CELExpression)[])[];
|
|
336
361
|
declare const transformAliasInExpression: (expr: CELExpression, alias: string | null) => CELExpression;
|
|
362
|
+
/** A CEL arithmetic infix node (`Addition`/`Subtraction`/`Multiplication`/`Division`/`Modulo`). */
|
|
363
|
+
declare const isCELMathOperation: (expr: CELExpression) => boolean;
|
|
364
|
+
/**
|
|
365
|
+
* Whether a relation operand should be routed to `getExpression`: an arithmetic infix node, a
|
|
366
|
+
* `FunctionCall`, or a `ConditionalExpr` (`min`/`max` template) — optionally wrapped in one or
|
|
367
|
+
* more `ExpressionGroup`s. Bare identifiers, chains, and literals are not expression operands
|
|
368
|
+
* (they retain their normal handling).
|
|
369
|
+
*/
|
|
370
|
+
declare const isCELExpressionOperand: (expr: CELExpression) => boolean;
|
|
337
371
|
//#endregion
|
|
338
|
-
export { CELAddition, CELBooleanLiteral, CELBytesLiteral, CELConditionalAnd, CELConditionalExpr, CELConditionalOr, CELDivision, CELDynamicPropertyAccessor, CELExpression, CELExpressionGroup, CELExpressionList, CELExpressionType, CELFieldInit, CELFieldInits, CELFloatLiteral, CELFunctionCall, CELIdentifier, CELIntegerLiteral, CELLikeExpression, CELList, CELLiteral, CELMap, CELMapInit, CELMapInits, CELMathOperation, CELMember, CELMemberIdentifierChain, CELMemberNegatedIdentifier, CELMemberNegatedIdentifierChain, CELMessageInit, 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, isCELFloatLiteral, isCELFunctionCall, isCELIdentifier, isCELIdentifierOrChain, isCELIntegerLiteral, isCELLikeExpression, isCELList, isCELLiteral, isCELMap, isCELMapInit, isCELMapInits, isCELMember, isCELMessageInit, isCELModulo, isCELMultiplication, isCELNegatedIdentifier, isCELNegatedIdentifierOrChain, isCELNegatedLikeExpression, isCELNegatedSubqueryExpression, isCELNegation, isCELNegative, isCELNullLiteral, isCELNumericLiteral, isCELProperty, isCELRelation, isCELStringLiteral, isCELSubqueryExpression, isCELSubtraction, isCELUnsignedIntegerLiteral, parseCEL, transformAliasInExpression };
|
|
372
|
+
export { CELAddition, CELBooleanLiteral, CELBytesLiteral, CELConditionalAnd, CELConditionalExpr, CELConditionalOr, CELDivision, CELDynamicPropertyAccessor, CELExpression, CELExpressionGroup, CELExpressionList, CELExpressionOperand, CELExpressionType, CELFieldInit, CELFieldInits, CELFloatLiteral, CELFunctionCall, CELIdentifier, CELIntegerLiteral, CELLikeExpression, CELList, CELLiteral, CELMap, CELMapInit, CELMapInits, CELMathOperation, CELMember, CELMemberIdentifierChain, CELMemberNegatedIdentifier, CELMemberNegatedIdentifierChain, CELMessageInit, CELModulo, CELMultiplication, CELNegatedLikeExpression, CELNegatedSubqueryExpression, CELNegation, CELNegative, CELNullLiteral, CELNumericLiteral, CELPrimary, CELProperty, CELRelation, CELRelop, CELStringLiteral, CELSubqueryExpression, CELSubtraction, CELUnsignedIntegerLiteral, ParseCELExpressionContext, ParseCELOptions, ParseCELOptionsIC, ParseCELOptionsStandard, ParsedCEL, celGenerateFlatAndOrList, celGenerateMixedAndOrList, celNormalizeCombinator, celNormalizeOperator, evalCELLiteralValue, extractSubqueryComponents, getCELIdentifierFromChain, getCELIdentifierFromNegatedChain, isCELAddition, isCELBooleanLiteral, isCELBytesLiteral, isCELConditionalAnd, isCELConditionalExpr, isCELConditionalOr, isCELDivision, isCELDynamicPropertyAccessor, isCELExpressionGroup, isCELExpressionList, isCELExpressionOperand, isCELFieldInit, isCELFieldInits, isCELFloatLiteral, isCELFunctionCall, isCELIdentifier, isCELIdentifierOrChain, isCELIntegerLiteral, isCELLikeExpression, isCELList, isCELLiteral, isCELMap, isCELMapInit, isCELMapInits, isCELMathOperation, isCELMember, isCELMessageInit, isCELModulo, isCELMultiplication, isCELNegatedIdentifier, isCELNegatedIdentifierOrChain, isCELNegatedLikeExpression, isCELNegatedSubqueryExpression, isCELNegation, isCELNegative, isCELNullLiteral, isCELNumericLiteral, isCELProperty, isCELRelation, isCELStringLiteral, isCELSubqueryExpression, isCELSubtraction, isCELUnsignedIntegerLiteral, parseCEL, transformAliasInExpression };
|
|
339
373
|
//# sourceMappingURL=parseCEL.d.mts.map
|
package/dist/parseCEL.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as ParserCommonOptions } from "./import-
|
|
3
|
-
|
|
1
|
+
import { A as DefaultOperatorName, D as RuleGroupTypeIC, L as Except, M as RuleGroupType, N as RuleType, O as DefaultCombinatorName, P as ExpressionNode, T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType } from "./index-BSwFvkeI.js";
|
|
2
|
+
import { t as ParserCommonOptions } from "./import-Ddc3d_8q.js";
|
|
4
3
|
//#region src/utils/parseCEL/types.d.ts
|
|
5
4
|
type CELExpressionType = "Addition" | "BooleanLiteral" | "BytesLiteral" | "ConditionalAnd" | "ConditionalExpr" | "ConditionalOr" | "Division" | "DynamicPropertyAccessor" | "ExpressionGroup" | "ExpressionList" | "FieldInit" | "FieldInits" | "MessageInit" | "FloatLiteral" | "FunctionCall" | "Identifier" | "IntegerLiteral" | "List" | "Map" | "MapInit" | "MapInits" | "Member" | "Modulo" | "Multiplication" | "Negation" | "Negative" | "NullLiteral" | "Property" | "Relation" | "StringLiteral" | "Subtraction" | "Unary" | "UnsignedIntegerLiteral" | "LikeExpression" | "SubqueryExpression";
|
|
6
5
|
type CELRelop = "==" | ">=" | ">" | "<=" | "<" | "!=" | "in";
|
|
@@ -218,59 +217,85 @@ interface ParsedCEL {
|
|
|
218
217
|
nodeType: "Main";
|
|
219
218
|
value: CELExpression;
|
|
220
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* A CEL operand subtree that {@link parseCEL!ParseCELOptions.getExpression} may receive — an
|
|
222
|
+
* arithmetic infix node (`Addition`/`Subtraction`/`Multiplication`/`Division`/`Modulo`,
|
|
223
|
+
* optionally wrapped in an `ExpressionGroup`), a `FunctionCall`, or a `ConditionalExpr` (the
|
|
224
|
+
* `min`/`max` emulated template).
|
|
225
|
+
*/
|
|
226
|
+
type CELExpressionOperand = CELExpression;
|
|
227
|
+
/** Context passed to {@link parseCEL!ParseCELOptions.getExpression}. */
|
|
228
|
+
interface ParseCELExpressionContext {
|
|
229
|
+
/** Returns `true` if the field is configured (or if no `fields` were supplied). */
|
|
230
|
+
fieldExists: (fieldName: string) => boolean;
|
|
231
|
+
}
|
|
221
232
|
//#endregion
|
|
222
233
|
//#region src/utils/parseCEL/parseCEL.d.ts
|
|
223
234
|
interface ParseCELOptionsStandard extends Except<ParserCommonOptions, "independentCombinators"> {
|
|
224
235
|
independentCombinators?: false;
|
|
225
236
|
/**
|
|
226
|
-
|
|
227
|
-
|
|
237
|
+
* Handler for custom CEL expressions.
|
|
238
|
+
*/
|
|
228
239
|
customExpressionHandler?: (expr: CELExpression) => RuleType | RuleGroupType | null;
|
|
240
|
+
/**
|
|
241
|
+
* Handler that converts a CEL arithmetic/function operand subtree into an
|
|
242
|
+
* {@link ExpressionNode}. Return `null` to reject (the rule is dropped). Supplied by
|
|
243
|
+
* `@react-querybuilder/expr` (`expressionParserCEL`). When omitted, expression operands
|
|
244
|
+
* are ignored (rule dropped).
|
|
245
|
+
*/
|
|
246
|
+
getExpression?: (node: CELExpressionOperand, ctx: ParseCELExpressionContext) => ExpressionNode | null;
|
|
229
247
|
}
|
|
230
248
|
interface ParseCELOptionsIC extends Except<ParserCommonOptions, "independentCombinators"> {
|
|
231
249
|
independentCombinators: true;
|
|
232
250
|
/**
|
|
233
|
-
|
|
234
|
-
|
|
251
|
+
* Handler for custom CEL expressions.
|
|
252
|
+
*/
|
|
235
253
|
customExpressionHandler?: (expr: CELExpression) => RuleType | RuleGroupTypeIC | null;
|
|
254
|
+
/**
|
|
255
|
+
* Handler that converts a CEL arithmetic/function operand subtree into an
|
|
256
|
+
* {@link ExpressionNode}. Return `null` to reject (the rule is dropped). Supplied by
|
|
257
|
+
* `@react-querybuilder/expr` (`expressionParserCEL`). When omitted, expression operands
|
|
258
|
+
* are ignored (rule dropped).
|
|
259
|
+
*/
|
|
260
|
+
getExpression?: (node: CELExpressionOperand, ctx: ParseCELExpressionContext) => ExpressionNode | null;
|
|
236
261
|
}
|
|
237
262
|
/**
|
|
238
|
-
* Options object for {@link parseCEL}.
|
|
239
|
-
*/
|
|
263
|
+
* Options object for {@link parseCEL}.
|
|
264
|
+
*/
|
|
240
265
|
type ParseCELOptions = ParseCELOptionsStandard | ParseCELOptionsIC;
|
|
241
266
|
/**
|
|
242
|
-
* Converts a CEL string expression into a query suitable for the
|
|
243
|
-
* {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
|
|
244
|
-
* ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
|
|
245
|
-
*/
|
|
267
|
+
* Converts a CEL string expression into a query suitable for the
|
|
268
|
+
* {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
|
|
269
|
+
* ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
|
|
270
|
+
*/
|
|
246
271
|
declare function parseCEL(cel: string): DefaultRuleGroupType;
|
|
247
272
|
/**
|
|
248
|
-
* Converts a CEL string expression into a query suitable for the
|
|
249
|
-
* {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
|
|
250
|
-
* ({@link index!RuleGroupType RuleGroupType}).
|
|
251
|
-
*/
|
|
273
|
+
* Converts a CEL string expression into a query suitable for the
|
|
274
|
+
* {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
|
|
275
|
+
* ({@link index!RuleGroupType RuleGroupType}).
|
|
276
|
+
*/
|
|
252
277
|
declare function parseCEL(cel: string, options: ParseCELOptionsStandard & {
|
|
253
278
|
customExpressionHandler: (expr: CELExpression) => RuleType | RuleGroupType | null;
|
|
254
279
|
}): RuleGroupType;
|
|
255
280
|
/**
|
|
256
|
-
* Converts a CEL string expression into a query suitable for the
|
|
257
|
-
* {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
|
|
258
|
-
* ({@link index!RuleGroupTypeIC RuleGroupTypeIC}).
|
|
259
|
-
*/
|
|
281
|
+
* Converts a CEL string expression into a query suitable for the
|
|
282
|
+
* {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
|
|
283
|
+
* ({@link index!RuleGroupTypeIC RuleGroupTypeIC}).
|
|
284
|
+
*/
|
|
260
285
|
declare function parseCEL(cel: string, options: ParseCELOptionsIC & {
|
|
261
286
|
customExpressionHandler: (expr: CELExpression) => RuleType | RuleGroupTypeIC | null;
|
|
262
287
|
}): RuleGroupTypeIC;
|
|
263
288
|
/**
|
|
264
|
-
* Converts a CEL string expression into a query suitable for the
|
|
265
|
-
* {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
|
|
266
|
-
* ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
|
|
267
|
-
*/
|
|
289
|
+
* Converts a CEL string expression into a query suitable for the
|
|
290
|
+
* {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
|
|
291
|
+
* ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
|
|
292
|
+
*/
|
|
268
293
|
declare function parseCEL(cel: string, options?: ParseCELOptionsStandard): DefaultRuleGroupType;
|
|
269
294
|
/**
|
|
270
|
-
* Converts a CEL string expression into a query suitable for the
|
|
271
|
-
* {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
|
|
272
|
-
* ({@link index!DefaultRuleGroupTypeIC DefaultRuleGroupTypeIC}).
|
|
273
|
-
*/
|
|
295
|
+
* Converts a CEL string expression into a query suitable for the
|
|
296
|
+
* {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
|
|
297
|
+
* ({@link index!DefaultRuleGroupTypeIC DefaultRuleGroupTypeIC}).
|
|
298
|
+
*/
|
|
274
299
|
declare function parseCEL(cel: string, options: ParseCELOptionsIC): DefaultRuleGroupTypeIC;
|
|
275
300
|
//#endregion
|
|
276
301
|
//#region src/utils/parseCEL/utils.d.ts
|
|
@@ -334,6 +359,15 @@ declare const celNormalizeOperator: (op: CELRelop, flip?: boolean) => DefaultOpe
|
|
|
334
359
|
declare const celGenerateFlatAndOrList: (expr: CELConditionalAnd | CELConditionalOr) => (DefaultCombinatorName | CELExpression)[];
|
|
335
360
|
declare const celGenerateMixedAndOrList: (expr: CELConditionalAnd | CELConditionalOr) => (DefaultCombinatorName | CELExpression | ("and" | CELExpression)[])[];
|
|
336
361
|
declare const transformAliasInExpression: (expr: CELExpression, alias: string | null) => CELExpression;
|
|
362
|
+
/** A CEL arithmetic infix node (`Addition`/`Subtraction`/`Multiplication`/`Division`/`Modulo`). */
|
|
363
|
+
declare const isCELMathOperation: (expr: CELExpression) => boolean;
|
|
364
|
+
/**
|
|
365
|
+
* Whether a relation operand should be routed to `getExpression`: an arithmetic infix node, a
|
|
366
|
+
* `FunctionCall`, or a `ConditionalExpr` (`min`/`max` template) — optionally wrapped in one or
|
|
367
|
+
* more `ExpressionGroup`s. Bare identifiers, chains, and literals are not expression operands
|
|
368
|
+
* (they retain their normal handling).
|
|
369
|
+
*/
|
|
370
|
+
declare const isCELExpressionOperand: (expr: CELExpression) => boolean;
|
|
337
371
|
//#endregion
|
|
338
|
-
export { CELAddition, CELBooleanLiteral, CELBytesLiteral, CELConditionalAnd, CELConditionalExpr, CELConditionalOr, CELDivision, CELDynamicPropertyAccessor, CELExpression, CELExpressionGroup, CELExpressionList, CELExpressionType, CELFieldInit, CELFieldInits, CELFloatLiteral, CELFunctionCall, CELIdentifier, CELIntegerLiteral, CELLikeExpression, CELList, CELLiteral, CELMap, CELMapInit, CELMapInits, CELMathOperation, CELMember, CELMemberIdentifierChain, CELMemberNegatedIdentifier, CELMemberNegatedIdentifierChain, CELMessageInit, 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, isCELFloatLiteral, isCELFunctionCall, isCELIdentifier, isCELIdentifierOrChain, isCELIntegerLiteral, isCELLikeExpression, isCELList, isCELLiteral, isCELMap, isCELMapInit, isCELMapInits, isCELMember, isCELMessageInit, isCELModulo, isCELMultiplication, isCELNegatedIdentifier, isCELNegatedIdentifierOrChain, isCELNegatedLikeExpression, isCELNegatedSubqueryExpression, isCELNegation, isCELNegative, isCELNullLiteral, isCELNumericLiteral, isCELProperty, isCELRelation, isCELStringLiteral, isCELSubqueryExpression, isCELSubtraction, isCELUnsignedIntegerLiteral, parseCEL, transformAliasInExpression };
|
|
372
|
+
export { CELAddition, CELBooleanLiteral, CELBytesLiteral, CELConditionalAnd, CELConditionalExpr, CELConditionalOr, CELDivision, CELDynamicPropertyAccessor, CELExpression, CELExpressionGroup, CELExpressionList, CELExpressionOperand, CELExpressionType, CELFieldInit, CELFieldInits, CELFloatLiteral, CELFunctionCall, CELIdentifier, CELIntegerLiteral, CELLikeExpression, CELList, CELLiteral, CELMap, CELMapInit, CELMapInits, CELMathOperation, CELMember, CELMemberIdentifierChain, CELMemberNegatedIdentifier, CELMemberNegatedIdentifierChain, CELMessageInit, CELModulo, CELMultiplication, CELNegatedLikeExpression, CELNegatedSubqueryExpression, CELNegation, CELNegative, CELNullLiteral, CELNumericLiteral, CELPrimary, CELProperty, CELRelation, CELRelop, CELStringLiteral, CELSubqueryExpression, CELSubtraction, CELUnsignedIntegerLiteral, ParseCELExpressionContext, ParseCELOptions, ParseCELOptionsIC, ParseCELOptionsStandard, ParsedCEL, celGenerateFlatAndOrList, celGenerateMixedAndOrList, celNormalizeCombinator, celNormalizeOperator, evalCELLiteralValue, extractSubqueryComponents, getCELIdentifierFromChain, getCELIdentifierFromNegatedChain, isCELAddition, isCELBooleanLiteral, isCELBytesLiteral, isCELConditionalAnd, isCELConditionalExpr, isCELConditionalOr, isCELDivision, isCELDynamicPropertyAccessor, isCELExpressionGroup, isCELExpressionList, isCELExpressionOperand, isCELFieldInit, isCELFieldInits, isCELFloatLiteral, isCELFunctionCall, isCELIdentifier, isCELIdentifierOrChain, isCELIntegerLiteral, isCELLikeExpression, isCELList, isCELLiteral, isCELMap, isCELMapInit, isCELMapInits, isCELMathOperation, isCELMember, isCELMessageInit, isCELModulo, isCELMultiplication, isCELNegatedIdentifier, isCELNegatedIdentifierOrChain, isCELNegatedLikeExpression, isCELNegatedSubqueryExpression, isCELNegation, isCELNegative, isCELNullLiteral, isCELNumericLiteral, isCELProperty, isCELRelation, isCELStringLiteral, isCELSubqueryExpression, isCELSubtraction, isCELUnsignedIntegerLiteral, parseCEL, transformAliasInExpression };
|
|
339
373
|
//# sourceMappingURL=parseCEL.d.ts.map
|
package/dist/parseCEL.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_utils = require("./utils-
|
|
3
|
-
const
|
|
4
|
-
const require_prepareQueryObjects = require("./prepareQueryObjects-
|
|
2
|
+
const require_utils = require("./utils-DEwV7F6B.js");
|
|
3
|
+
const require_isRuleGroup = require("./isRuleGroup-0JNiQgLg.js");
|
|
4
|
+
const require_prepareQueryObjects = require("./prepareQueryObjects-C2-kTZvR.js");
|
|
5
5
|
let _ts_jison_parser = require("@ts-jison/parser");
|
|
6
6
|
let _ts_jison_lexer = require("@ts-jison/lexer");
|
|
7
7
|
//#region src/utils/parseCEL/celParser.ts
|
|
@@ -2245,12 +2245,26 @@ const transformAliasInExpressionInternal = (expr, alias, isPrimitive) => {
|
|
|
2245
2245
|
const transformAliasInExpression = (expr, alias) => {
|
|
2246
2246
|
// v8 ignore next
|
|
2247
2247
|
if (!alias) return expr;
|
|
2248
|
-
|
|
2248
|
+
const isPrimitive = isPrimitiveArrayUsage(expr, alias);
|
|
2249
|
+
return transformAliasInExpressionInternal(expr, alias, isPrimitive);
|
|
2250
|
+
};
|
|
2251
|
+
/** A CEL arithmetic infix node (`Addition`/`Subtraction`/`Multiplication`/`Division`/`Modulo`). */
|
|
2252
|
+
const isCELMathOperation = (expr) => expr.type === "Addition" || expr.type === "Subtraction" || expr.type === "Multiplication" || expr.type === "Division" || expr.type === "Modulo";
|
|
2253
|
+
/**
|
|
2254
|
+
* Whether a relation operand should be routed to `getExpression`: an arithmetic infix node, a
|
|
2255
|
+
* `FunctionCall`, or a `ConditionalExpr` (`min`/`max` template) — optionally wrapped in one or
|
|
2256
|
+
* more `ExpressionGroup`s. Bare identifiers, chains, and literals are not expression operands
|
|
2257
|
+
* (they retain their normal handling).
|
|
2258
|
+
*/
|
|
2259
|
+
const isCELExpressionOperand = (expr) => {
|
|
2260
|
+
const inner = isCELExpressionGroup(expr) ? expr.value : expr;
|
|
2261
|
+
if (isCELExpressionGroup(inner)) return isCELExpressionOperand(inner);
|
|
2262
|
+
return isCELMathOperation(inner) || inner.type === "FunctionCall" || inner.type === "ConditionalExpr";
|
|
2249
2263
|
};
|
|
2250
2264
|
//#endregion
|
|
2251
2265
|
//#region src/utils/parseCEL/parseCEL.ts
|
|
2252
2266
|
function parseCEL(cel, options = {}) {
|
|
2253
|
-
const { fields, independentCombinators, listsAsArrays, customExpressionHandler } = options;
|
|
2267
|
+
const { fields, independentCombinators, listsAsArrays, customExpressionHandler, getExpression } = options;
|
|
2254
2268
|
const ic = !!independentCombinators;
|
|
2255
2269
|
const fieldsFlat = require_prepareQueryObjects.getFieldsArray(fields);
|
|
2256
2270
|
const fieldIsValid = (fieldName, operator, subordinateFieldName) => require_prepareQueryObjects.fieldIsValidUtil({
|
|
@@ -2264,6 +2278,7 @@ function parseCEL(cel, options = {}) {
|
|
|
2264
2278
|
rules: [],
|
|
2265
2279
|
...ic ? {} : { combinator: "and" }
|
|
2266
2280
|
};
|
|
2281
|
+
const exprCtx = { fieldExists: (fieldName) => fieldsFlat.length === 0 || fieldsFlat.some((f) => f.name === fieldName) };
|
|
2267
2282
|
const processCELExpression = (expr, processOpts = {}) => {
|
|
2268
2283
|
const { forwardNegation: forwardedNegation, groupOnlyIfNecessary } = processOpts;
|
|
2269
2284
|
/* v8 ignore if -- @preserve */
|
|
@@ -2281,7 +2296,7 @@ function parseCEL(cel, options = {}) {
|
|
|
2281
2296
|
});
|
|
2282
2297
|
if (negatedExpr) {
|
|
2283
2298
|
if (isCELNegatedLikeExpression(expr) || isCELNegation(expr) && isCELExpressionGroup(expr.value) && isCELRelation(expr.value.value)) return negatedExpr;
|
|
2284
|
-
else if (!negate || negate && !
|
|
2299
|
+
else if (!negate || negate && !require_isRuleGroup.isRuleGroup(negatedExpr) && negatedExpr.operator.startsWith("doesNot")) return ic ? { rules: [negatedExpr] } : {
|
|
2285
2300
|
combinator: "and",
|
|
2286
2301
|
rules: [negatedExpr]
|
|
2287
2302
|
};
|
|
@@ -2297,7 +2312,7 @@ function parseCEL(cel, options = {}) {
|
|
|
2297
2312
|
} else if (isCELExpressionGroup(expr)) {
|
|
2298
2313
|
const rule = processCELExpression(expr.value, { groupOnlyIfNecessary: true });
|
|
2299
2314
|
if (rule) {
|
|
2300
|
-
if (
|
|
2315
|
+
if (require_isRuleGroup.isRuleGroup(rule) || groupOnlyIfNecessary && isCELExpressionGroup(expr.value)) return rule;
|
|
2301
2316
|
return ic ? { rules: [rule] } : {
|
|
2302
2317
|
combinator: "and",
|
|
2303
2318
|
rules: [rule]
|
|
@@ -2350,9 +2365,10 @@ function parseCEL(cel, options = {}) {
|
|
|
2350
2365
|
if (components) {
|
|
2351
2366
|
const { field, method, alias, condition } = components;
|
|
2352
2367
|
const matchMode = method === "all" ? "all" : "some";
|
|
2353
|
-
const
|
|
2368
|
+
const transformedCondition = transformAliasInExpression(condition, alias);
|
|
2369
|
+
const subqueryValue = processCELExpression(transformedCondition);
|
|
2354
2370
|
if (subqueryValue && fieldIsValid(field, "=")) {
|
|
2355
|
-
const ruleGroupValue =
|
|
2371
|
+
const ruleGroupValue = require_isRuleGroup.isRuleGroup(subqueryValue) ? subqueryValue : ic ? { rules: [subqueryValue] } : {
|
|
2356
2372
|
combinator: "and",
|
|
2357
2373
|
rules: [subqueryValue]
|
|
2358
2374
|
};
|
|
@@ -2368,10 +2384,11 @@ function parseCEL(cel, options = {}) {
|
|
|
2368
2384
|
const field = getCELIdentifierFromNegatedChain(expr.left).replace(/^!+/, "");
|
|
2369
2385
|
const method = expr.right.value;
|
|
2370
2386
|
const [aliasExpr, conditionExpr] = expr.list.value;
|
|
2371
|
-
const
|
|
2387
|
+
const transformedCondition = transformAliasInExpression(conditionExpr, isCELIdentifier(aliasExpr) ? aliasExpr.value : /* v8 ignore next -- @preserve */ null);
|
|
2388
|
+
const subqueryValue = processCELExpression(transformedCondition);
|
|
2372
2389
|
// v8 ignore else
|
|
2373
2390
|
if (subqueryValue && fieldIsValid(field, "=")) {
|
|
2374
|
-
const ruleGroupValue =
|
|
2391
|
+
const ruleGroupValue = require_isRuleGroup.isRuleGroup(subqueryValue) ? subqueryValue : ic ? { rules: [subqueryValue] } : {
|
|
2375
2392
|
combinator: "and",
|
|
2376
2393
|
rules: [subqueryValue]
|
|
2377
2394
|
};
|
|
@@ -2396,6 +2413,66 @@ function parseCEL(cel, options = {}) {
|
|
|
2396
2413
|
let valueSource = void 0;
|
|
2397
2414
|
let flip = false;
|
|
2398
2415
|
const { left, right } = expr;
|
|
2416
|
+
if (getExpression) {
|
|
2417
|
+
const leftIsExpr = isCELExpressionOperand(left);
|
|
2418
|
+
const rightIsExpr = isCELExpressionOperand(right);
|
|
2419
|
+
const normOp = (flipOp) => {
|
|
2420
|
+
const o = celNormalizeOperator(expr.operator, flipOp);
|
|
2421
|
+
return forwardedNegation ? require_utils.defaultOperatorNegationMap[o] : o;
|
|
2422
|
+
};
|
|
2423
|
+
if (leftIsExpr && rightIsExpr) {
|
|
2424
|
+
const l = getExpression(left, exprCtx);
|
|
2425
|
+
const r = getExpression(right, exprCtx);
|
|
2426
|
+
if (l && r) return {
|
|
2427
|
+
field: "",
|
|
2428
|
+
operator: normOp(false),
|
|
2429
|
+
lhs: l,
|
|
2430
|
+
value: r,
|
|
2431
|
+
valueSource: "expression"
|
|
2432
|
+
};
|
|
2433
|
+
return null;
|
|
2434
|
+
} else if (isCELIdentifierOrChain(left) && rightIsExpr) {
|
|
2435
|
+
const node = getExpression(right, exprCtx);
|
|
2436
|
+
const f = getCELIdentifierFromChain(left);
|
|
2437
|
+
const op = normOp(false);
|
|
2438
|
+
if (node && fieldIsValid(f, op)) return {
|
|
2439
|
+
field: f,
|
|
2440
|
+
operator: op,
|
|
2441
|
+
value: node,
|
|
2442
|
+
valueSource: "expression"
|
|
2443
|
+
};
|
|
2444
|
+
return null;
|
|
2445
|
+
} else if (leftIsExpr && isCELIdentifierOrChain(right)) {
|
|
2446
|
+
const node = getExpression(left, exprCtx);
|
|
2447
|
+
const f = getCELIdentifierFromChain(right);
|
|
2448
|
+
const op = normOp(true);
|
|
2449
|
+
if (node && fieldIsValid(f, op)) return {
|
|
2450
|
+
field: f,
|
|
2451
|
+
operator: op,
|
|
2452
|
+
value: node,
|
|
2453
|
+
valueSource: "expression"
|
|
2454
|
+
};
|
|
2455
|
+
return null;
|
|
2456
|
+
} else if (leftIsExpr && isCELLiteral(right)) {
|
|
2457
|
+
const l = getExpression(left, exprCtx);
|
|
2458
|
+
if (l) return {
|
|
2459
|
+
field: "",
|
|
2460
|
+
operator: normOp(false),
|
|
2461
|
+
lhs: l,
|
|
2462
|
+
value: evalCELLiteralValue(right)
|
|
2463
|
+
};
|
|
2464
|
+
return null;
|
|
2465
|
+
} else if (isCELLiteral(left) && rightIsExpr) {
|
|
2466
|
+
const r = getExpression(right, exprCtx);
|
|
2467
|
+
if (r) return {
|
|
2468
|
+
field: "",
|
|
2469
|
+
operator: normOp(true),
|
|
2470
|
+
lhs: r,
|
|
2471
|
+
value: evalCELLiteralValue(left)
|
|
2472
|
+
};
|
|
2473
|
+
return null;
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2399
2476
|
if (isCELIdentifierOrChain(left)) {
|
|
2400
2477
|
field = getCELIdentifierFromChain(left);
|
|
2401
2478
|
if (isCELIdentifierOrChain(right)) {
|
|
@@ -2445,7 +2522,7 @@ function parseCEL(cel, options = {}) {
|
|
|
2445
2522
|
}
|
|
2446
2523
|
const result = processCELExpression(processedCEL);
|
|
2447
2524
|
if (result) {
|
|
2448
|
-
if (
|
|
2525
|
+
if (require_isRuleGroup.isRuleGroup(result)) return prepare(result);
|
|
2449
2526
|
return prepare({
|
|
2450
2527
|
rules: [result],
|
|
2451
2528
|
...ic ? {} : { combinator: "and" }
|
|
@@ -2472,6 +2549,7 @@ exports.isCELDivision = isCELDivision;
|
|
|
2472
2549
|
exports.isCELDynamicPropertyAccessor = isCELDynamicPropertyAccessor;
|
|
2473
2550
|
exports.isCELExpressionGroup = isCELExpressionGroup;
|
|
2474
2551
|
exports.isCELExpressionList = isCELExpressionList;
|
|
2552
|
+
exports.isCELExpressionOperand = isCELExpressionOperand;
|
|
2475
2553
|
exports.isCELFieldInit = isCELFieldInit;
|
|
2476
2554
|
exports.isCELFieldInits = isCELFieldInits;
|
|
2477
2555
|
exports.isCELFloatLiteral = isCELFloatLiteral;
|
|
@@ -2485,6 +2563,7 @@ exports.isCELLiteral = isCELLiteral;
|
|
|
2485
2563
|
exports.isCELMap = isCELMap;
|
|
2486
2564
|
exports.isCELMapInit = isCELMapInit;
|
|
2487
2565
|
exports.isCELMapInits = isCELMapInits;
|
|
2566
|
+
exports.isCELMathOperation = isCELMathOperation;
|
|
2488
2567
|
exports.isCELMember = isCELMember;
|
|
2489
2568
|
exports.isCELMessageInit = isCELMessageInit;
|
|
2490
2569
|
exports.isCELModulo = isCELModulo;
|