@react-querybuilder/core 8.14.0 → 8.14.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-Dxm6jWFu.d.ts → basic-BXJVfD0P.d.ts} +68 -50
- package/dist/{basic-GFsWfi0Z.d.mts → basic-CNIjb6rI.d.mts} +68 -50
- package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +183 -127
- package/dist/cjs/react-querybuilder_core.cjs.development.js +311 -252
- package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +183 -127
- 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-DAj92cbM.mjs → convertQuery-CeJSNn37.mjs} +30 -22
- package/dist/convertQuery-CeJSNn37.mjs.map +1 -0
- package/dist/convertQuery-J8LpTG-7.js +94 -0
- package/dist/convertQuery-J8LpTG-7.js.map +1 -0
- package/dist/{export-_wipiqJZ.d.mts → export-6x7MilFR.d.mts} +2 -3
- package/dist/{export-6VbkhCrf.d.ts → export-CpJOQuZv.d.ts} +2 -3
- package/dist/formatQuery.d.mts +4 -3
- package/dist/formatQuery.d.ts +4 -3
- package/dist/formatQuery.js +75 -107
- package/dist/formatQuery.js.map +1 -1
- package/dist/formatQuery.mjs +17 -49
- package/dist/formatQuery.mjs.map +1 -1
- package/dist/{import-D8M7awTx.d.ts → import-B5Iq8XmL.d.ts} +2 -3
- package/dist/{import-DRmutNSr.d.mts → import-Bltb2mT4.d.mts} +2 -3
- package/dist/objectUtils-ButT0Mng.js +105 -0
- package/dist/objectUtils-ButT0Mng.js.map +1 -0
- package/dist/{isRuleGroup-DztIOOKa.mjs → objectUtils-C0WB-8ex.mjs} +16 -5
- package/dist/objectUtils-C0WB-8ex.mjs.map +1 -0
- package/dist/parseCEL.d.mts +2 -2
- package/dist/parseCEL.d.ts +2 -2
- package/dist/parseCEL.js +14 -16
- package/dist/parseCEL.js.map +1 -1
- package/dist/parseCEL.mjs +7 -10
- package/dist/parseCEL.mjs.map +1 -1
- package/dist/parseJSONata.d.mts +2 -3
- package/dist/parseJSONata.d.ts +2 -3
- package/dist/parseJSONata.js +40 -5614
- package/dist/parseJSONata.js.map +1 -1
- package/dist/parseJSONata.mjs +11 -13
- package/dist/parseJSONata.mjs.map +1 -1
- package/dist/parseJsonLogic.d.mts +3 -4
- package/dist/parseJsonLogic.d.ts +3 -4
- package/dist/parseJsonLogic.js +47 -48
- package/dist/parseJsonLogic.js.map +1 -1
- package/dist/parseJsonLogic.mjs +19 -21
- package/dist/parseJsonLogic.mjs.map +1 -1
- package/dist/parseMongoDB.d.mts +2 -3
- package/dist/parseMongoDB.d.ts +2 -3
- package/dist/parseMongoDB.js +26 -27
- package/dist/parseMongoDB.js.map +1 -1
- package/dist/parseMongoDB.mjs +6 -8
- package/dist/parseMongoDB.mjs.map +1 -1
- package/dist/parseSQL.d.mts +2 -3
- package/dist/parseSQL.d.ts +2 -3
- package/dist/parseSQL.js +13 -15
- package/dist/parseSQL.js.map +1 -1
- package/dist/parseSQL.mjs +7 -10
- package/dist/parseSQL.mjs.map +1 -1
- package/dist/parseSpEL.d.mts +2 -3
- package/dist/parseSpEL.d.ts +2 -3
- package/dist/parseSpEL.js +13 -2702
- package/dist/parseSpEL.js.map +1 -1
- package/dist/parseSpEL.mjs +7 -9
- package/dist/parseSpEL.mjs.map +1 -1
- package/dist/{prepareQueryObjects-BBayjIn2.mjs → prepareQueryObjects-BfMlS4ql.mjs} +34 -18
- package/dist/prepareQueryObjects-BfMlS4ql.mjs.map +1 -0
- package/dist/{prepareQueryObjects-BxWvIPI4.js → prepareQueryObjects-DO3qXriW.js} +50 -35
- package/dist/prepareQueryObjects-DO3qXriW.js.map +1 -0
- package/dist/react-querybuilder_core.d.mts +183 -127
- package/dist/react-querybuilder_core.legacy-esm.d.ts +183 -127
- package/dist/react-querybuilder_core.legacy-esm.js +307 -280
- package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
- package/dist/react-querybuilder_core.mjs +299 -248
- package/dist/react-querybuilder_core.mjs.map +1 -1
- package/dist/react-querybuilder_core.production.d.mts +183 -127
- package/dist/react-querybuilder_core.production.mjs +1 -1
- package/dist/react-querybuilder_core.production.mjs.map +1 -1
- package/dist/transformQuery.d.mts +1 -2
- package/dist/transformQuery.d.ts +1 -2
- package/dist/transformQuery.js +45 -2
- package/dist/transformQuery.js.map +1 -0
- package/dist/transformQuery.mjs +44 -2
- package/dist/transformQuery.mjs.map +1 -0
- package/dist/{utils-nQU7WCM9.mjs → utils-BlMGIhvx.mjs} +32 -92
- package/dist/utils-BlMGIhvx.mjs.map +1 -0
- package/dist/{utils-CR1ToTMW.js → utils-CZRhzje-.js} +187 -265
- package/dist/utils-CZRhzje-.js.map +1 -0
- package/package.json +25 -17
- package/dist/chunk-U64pC571.js +0 -41
- package/dist/convertQuery-DAj92cbM.mjs.map +0 -1
- package/dist/convertQuery-DRldbzhZ.js +0 -87
- package/dist/convertQuery-DRldbzhZ.js.map +0 -1
- package/dist/isRuleGroup-Cjk1Q2mj.js +0 -82
- package/dist/isRuleGroup-Cjk1Q2mj.js.map +0 -1
- package/dist/isRuleGroup-DztIOOKa.mjs.map +0 -1
- package/dist/prepareQueryObjects-BBayjIn2.mjs.map +0 -1
- package/dist/prepareQueryObjects-BxWvIPI4.js.map +0 -1
- package/dist/transformQuery-ClBRfnFg.js +0 -54
- package/dist/transformQuery-ClBRfnFg.js.map +0 -1
- package/dist/transformQuery-DUpbpqjX.mjs +0 -48
- package/dist/transformQuery-DUpbpqjX.mjs.map +0 -1
- package/dist/utils-CR1ToTMW.js.map +0 -1
- package/dist/utils-nQU7WCM9.mjs.map +0 -1
|
@@ -1,7 +1,6 @@
|
|
|
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-BXJVfD0P.js";
|
|
2
2
|
|
|
3
3
|
//#region src/types/import.d.ts
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* Options common to all parsers.
|
|
7
6
|
*/
|
|
@@ -25,4 +24,4 @@ interface ParserCommonOptions {
|
|
|
25
24
|
}
|
|
26
25
|
//#endregion
|
|
27
26
|
export { ParserCommonOptions as t };
|
|
28
|
-
//# sourceMappingURL=import-
|
|
27
|
+
//# sourceMappingURL=import-B5Iq8XmL.d.ts.map
|
|
@@ -1,7 +1,6 @@
|
|
|
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-CNIjb6rI.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/types/import.d.ts
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* Options common to all parsers.
|
|
7
6
|
*/
|
|
@@ -25,4 +24,4 @@ interface ParserCommonOptions {
|
|
|
25
24
|
}
|
|
26
25
|
//#endregion
|
|
27
26
|
export { ParserCommonOptions as t };
|
|
28
|
-
//# sourceMappingURL=import-
|
|
27
|
+
//# sourceMappingURL=import-Bltb2mT4.d.mts.map
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
require("./parseJSONata.js");
|
|
2
|
+
let numeric_quantity = require("numeric-quantity");
|
|
3
|
+
//#region src/utils/misc.ts
|
|
4
|
+
/**
|
|
5
|
+
* Converts a value to lowercase if it's a string, otherwise returns the value as is.
|
|
6
|
+
*/
|
|
7
|
+
// istanbul ignore next
|
|
8
|
+
const lc = (v) => typeof v === "string" ? v.toLowerCase() : v;
|
|
9
|
+
/**
|
|
10
|
+
* Regex matching numeric strings. Passes for positive/negative integers, decimals,
|
|
11
|
+
* and E notation, with optional surrounding whitespace.
|
|
12
|
+
*/
|
|
13
|
+
const numericRegex = new RegExp(numeric_quantity.numericRegex.source.replace(/^\^/, String.raw`^\s*`).replace(/\$$/, String.raw`\s*$`));
|
|
14
|
+
/**
|
|
15
|
+
* Determines if a variable is a plain old JavaScript object, aka POJO.
|
|
16
|
+
*/
|
|
17
|
+
const isPojo = (obj) => obj === null || typeof obj !== "object" ? false : Object.getPrototypeOf(obj) === Object.prototype;
|
|
18
|
+
/**
|
|
19
|
+
* Simple helper to determine whether a value is null, undefined, or an empty string.
|
|
20
|
+
*/
|
|
21
|
+
const nullOrUndefinedOrEmpty = (value) => value === null || value === void 0 || value === "";
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/utils/isRuleGroup.ts
|
|
24
|
+
/**
|
|
25
|
+
* Determines if an object is a {@link RuleGroupType} or {@link RuleGroupTypeIC}.
|
|
26
|
+
*/
|
|
27
|
+
const isRuleGroup = (rg) => isPojo(rg) && Array.isArray(rg.rules);
|
|
28
|
+
/**
|
|
29
|
+
* Determines if an object is a {@link RuleGroupType}.
|
|
30
|
+
*/
|
|
31
|
+
const isRuleGroupType = (rg) => isRuleGroup(rg) && typeof rg.combinator === "string";
|
|
32
|
+
/**
|
|
33
|
+
* Determines if an object is a {@link RuleGroupTypeIC}.
|
|
34
|
+
*/
|
|
35
|
+
const isRuleGroupTypeIC = (rg) => isRuleGroup(rg) && rg.combinator === void 0;
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/utils/objectUtils.ts
|
|
38
|
+
/**
|
|
39
|
+
* A strongly-typed version of `Object.keys()`.
|
|
40
|
+
*
|
|
41
|
+
* [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-keys.ts)
|
|
42
|
+
*/
|
|
43
|
+
const objectKeys = Object.keys;
|
|
44
|
+
/**
|
|
45
|
+
* Returns `true` if the key could cause prototype pollution when used
|
|
46
|
+
* as a property name in bracket-notation assignment.
|
|
47
|
+
*/
|
|
48
|
+
const isUnsafeKey = (key) => key === "__proto__" || key === "constructor" || key === "prototype";
|
|
49
|
+
//#endregion
|
|
50
|
+
Object.defineProperty(exports, "isPojo", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: function() {
|
|
53
|
+
return isPojo;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(exports, "isRuleGroup", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function() {
|
|
59
|
+
return isRuleGroup;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(exports, "isRuleGroupType", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
get: function() {
|
|
65
|
+
return isRuleGroupType;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(exports, "isRuleGroupTypeIC", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function() {
|
|
71
|
+
return isRuleGroupTypeIC;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
Object.defineProperty(exports, "isUnsafeKey", {
|
|
75
|
+
enumerable: true,
|
|
76
|
+
get: function() {
|
|
77
|
+
return isUnsafeKey;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(exports, "lc", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
get: function() {
|
|
83
|
+
return lc;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
Object.defineProperty(exports, "nullOrUndefinedOrEmpty", {
|
|
87
|
+
enumerable: true,
|
|
88
|
+
get: function() {
|
|
89
|
+
return nullOrUndefinedOrEmpty;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
Object.defineProperty(exports, "numericRegex", {
|
|
93
|
+
enumerable: true,
|
|
94
|
+
get: function() {
|
|
95
|
+
return numericRegex;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(exports, "objectKeys", {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function() {
|
|
101
|
+
return objectKeys;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
//# sourceMappingURL=objectUtils-ButT0Mng.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectUtils-ButT0Mng.js","names":["numericQuantityRegex"],"sources":["../src/utils/misc.ts","../src/utils/isRuleGroup.ts","../src/utils/objectUtils.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","// 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":";;;;;;;AAMA,MAAa,MAAS,MAAa,OAAO,MAAM,WAAY,EAAE,aAAa,GAAS;;;;;AAMpF,MAAa,eAAuB,IAAI,OACtCA,iBAAAA,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,KAAA,KAAa,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,KAAA;;;;;;;;ACRvC,MAAa,aAAa,OAAO;;;;;AAiBjC,MAAa,eAAe,QAC1B,QAAQ,eAAe,QAAQ,iBAAiB,QAAQ"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { numericRegex } from "numeric-quantity";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/misc.ts
|
|
4
3
|
/**
|
|
5
4
|
* Converts a value to lowercase if it's a string, otherwise returns the value as is.
|
|
@@ -19,7 +18,6 @@ const isPojo = (obj) => obj === null || typeof obj !== "object" ? false : Object
|
|
|
19
18
|
* Simple helper to determine whether a value is null, undefined, or an empty string.
|
|
20
19
|
*/
|
|
21
20
|
const nullOrUndefinedOrEmpty = (value) => value === null || value === void 0 || value === "";
|
|
22
|
-
|
|
23
21
|
//#endregion
|
|
24
22
|
//#region src/utils/isRuleGroup.ts
|
|
25
23
|
/**
|
|
@@ -34,7 +32,20 @@ const isRuleGroupType = (rg) => isRuleGroup(rg) && typeof rg.combinator === "str
|
|
|
34
32
|
* Determines if an object is a {@link RuleGroupTypeIC}.
|
|
35
33
|
*/
|
|
36
34
|
const isRuleGroupTypeIC = (rg) => isRuleGroup(rg) && rg.combinator === void 0;
|
|
37
|
-
|
|
38
35
|
//#endregion
|
|
39
|
-
|
|
40
|
-
|
|
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
|
+
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 };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=objectUtils-C0WB-8ex.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectUtils-C0WB-8ex.mjs","names":["numericRegex","numericQuantityRegex"],"sources":["../src/utils/misc.ts","../src/utils/isRuleGroup.ts","../src/utils/objectUtils.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","// 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":";;;;;;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,KAAA,KAAa,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,KAAA;;;;;;;;ACRvC,MAAa,aAAa,OAAO;;;;;AAiBjC,MAAa,eAAe,QAC1B,QAAQ,eAAe,QAAQ,iBAAiB,QAAQ"}
|
package/dist/parseCEL.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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-CNIjb6rI.mjs";
|
|
2
|
+
import { t as ParserCommonOptions } from "./import-Bltb2mT4.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/parseCEL/types.d.ts
|
|
5
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";
|
package/dist/parseCEL.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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-BXJVfD0P.js";
|
|
2
|
+
import { t as ParserCommonOptions } from "./import-B5Iq8XmL.js";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/parseCEL/types.d.ts
|
|
5
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";
|
package/dist/parseCEL.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
const require_utils = require(
|
|
3
|
-
const
|
|
4
|
-
const require_prepareQueryObjects = require(
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_utils = require("./utils-CZRhzje-.js");
|
|
3
|
+
const require_objectUtils = require("./objectUtils-ButT0Mng.js");
|
|
4
|
+
const require_prepareQueryObjects = require("./prepareQueryObjects-DO3qXriW.js");
|
|
5
|
+
require("./parseJSONata.js");
|
|
5
6
|
let _ts_jison_parser = require("@ts-jison/parser");
|
|
6
7
|
let _ts_jison_lexer = require("@ts-jison/lexer");
|
|
7
|
-
|
|
8
8
|
//#region src/utils/parseCEL/celParser.ts
|
|
9
9
|
/**
|
|
10
10
|
* parser generated by @ts-jison/parser-generator 0.4.1-alpha.2
|
|
@@ -2005,7 +2005,6 @@ var CELLexer = class extends _ts_jison_lexer.JisonLexer {
|
|
|
2005
2005
|
}
|
|
2006
2006
|
}
|
|
2007
2007
|
};
|
|
2008
|
-
|
|
2009
2008
|
//#endregion
|
|
2010
2009
|
//#region src/utils/parseCEL/utils.ts
|
|
2011
2010
|
const isCELExpressionGroup = (expr) => expr.type === "ExpressionGroup";
|
|
@@ -2249,7 +2248,6 @@ const transformAliasInExpression = (expr, alias) => {
|
|
|
2249
2248
|
if (!alias) return expr;
|
|
2250
2249
|
return transformAliasInExpressionInternal(expr, alias, isPrimitiveArrayUsage(expr, alias));
|
|
2251
2250
|
};
|
|
2252
|
-
|
|
2253
2251
|
//#endregion
|
|
2254
2252
|
//#region src/utils/parseCEL/parseCEL.ts
|
|
2255
2253
|
function parseCEL(cel, options = {}) {
|
|
@@ -2284,7 +2282,7 @@ function parseCEL(cel, options = {}) {
|
|
|
2284
2282
|
});
|
|
2285
2283
|
if (negatedExpr) {
|
|
2286
2284
|
if (isCELNegatedLikeExpression(expr) || isCELNegation(expr) && isCELExpressionGroup(expr.value) && isCELRelation(expr.value.value)) return negatedExpr;
|
|
2287
|
-
else if (!negate || negate && !
|
|
2285
|
+
else if (!negate || negate && !require_objectUtils.isRuleGroup(negatedExpr) && negatedExpr.operator.startsWith("doesNot")) return ic ? { rules: [negatedExpr] } : {
|
|
2288
2286
|
combinator: "and",
|
|
2289
2287
|
rules: [negatedExpr]
|
|
2290
2288
|
};
|
|
@@ -2300,7 +2298,7 @@ function parseCEL(cel, options = {}) {
|
|
|
2300
2298
|
} else if (isCELExpressionGroup(expr)) {
|
|
2301
2299
|
const rule = processCELExpression(expr.value, { groupOnlyIfNecessary: true });
|
|
2302
2300
|
if (rule) {
|
|
2303
|
-
if (
|
|
2301
|
+
if (require_objectUtils.isRuleGroup(rule) || groupOnlyIfNecessary && isCELExpressionGroup(expr.value)) return rule;
|
|
2304
2302
|
return ic ? { rules: [rule] } : {
|
|
2305
2303
|
combinator: "and",
|
|
2306
2304
|
rules: [rule]
|
|
@@ -2308,12 +2306,12 @@ function parseCEL(cel, options = {}) {
|
|
|
2308
2306
|
}
|
|
2309
2307
|
} else if (isCELConditionalAnd(expr) || isCELConditionalOr(expr)) {
|
|
2310
2308
|
if (ic) {
|
|
2311
|
-
const rules
|
|
2309
|
+
const rules = celGenerateFlatAndOrList(expr).map((v) => {
|
|
2312
2310
|
if (typeof v === "string") return v;
|
|
2313
2311
|
return processCELExpression(v);
|
|
2314
2312
|
});
|
|
2315
|
-
if (!rules
|
|
2316
|
-
return { rules
|
|
2313
|
+
if (!rules.every(Boolean)) return null;
|
|
2314
|
+
return { rules };
|
|
2317
2315
|
}
|
|
2318
2316
|
const andOrList = celGenerateMixedAndOrList(expr);
|
|
2319
2317
|
const combinator = andOrList[1];
|
|
@@ -2355,7 +2353,7 @@ function parseCEL(cel, options = {}) {
|
|
|
2355
2353
|
const matchMode = method === "all" ? "all" : "some";
|
|
2356
2354
|
const subqueryValue = processCELExpression(transformAliasInExpression(condition, alias));
|
|
2357
2355
|
if (subqueryValue && fieldIsValid(field, "=")) {
|
|
2358
|
-
const ruleGroupValue =
|
|
2356
|
+
const ruleGroupValue = require_objectUtils.isRuleGroup(subqueryValue) ? subqueryValue : ic ? { rules: [subqueryValue] } : {
|
|
2359
2357
|
combinator: "and",
|
|
2360
2358
|
rules: [subqueryValue]
|
|
2361
2359
|
};
|
|
@@ -2374,7 +2372,7 @@ function parseCEL(cel, options = {}) {
|
|
|
2374
2372
|
const subqueryValue = processCELExpression(transformAliasInExpression(conditionExpr, isCELIdentifier(aliasExpr) ? aliasExpr.value : null));
|
|
2375
2373
|
// istanbul ignore else
|
|
2376
2374
|
if (subqueryValue && fieldIsValid(field, "=")) {
|
|
2377
|
-
const ruleGroupValue =
|
|
2375
|
+
const ruleGroupValue = require_objectUtils.isRuleGroup(subqueryValue) ? subqueryValue : ic ? { rules: [subqueryValue] } : {
|
|
2378
2376
|
combinator: "and",
|
|
2379
2377
|
rules: [subqueryValue]
|
|
2380
2378
|
};
|
|
@@ -2448,7 +2446,7 @@ function parseCEL(cel, options = {}) {
|
|
|
2448
2446
|
}
|
|
2449
2447
|
const result = processCELExpression(processedCEL);
|
|
2450
2448
|
if (result) {
|
|
2451
|
-
if (
|
|
2449
|
+
if (require_objectUtils.isRuleGroup(result)) return prepare(result);
|
|
2452
2450
|
return prepare({
|
|
2453
2451
|
rules: [result],
|
|
2454
2452
|
...ic ? {} : { combinator: "and" }
|
|
@@ -2456,7 +2454,6 @@ function parseCEL(cel, options = {}) {
|
|
|
2456
2454
|
}
|
|
2457
2455
|
return prepare(emptyQuery);
|
|
2458
2456
|
}
|
|
2459
|
-
|
|
2460
2457
|
//#endregion
|
|
2461
2458
|
exports.celGenerateFlatAndOrList = celGenerateFlatAndOrList;
|
|
2462
2459
|
exports.celGenerateMixedAndOrList = celGenerateMixedAndOrList;
|
|
@@ -2509,4 +2506,5 @@ exports.isCELSubtraction = isCELSubtraction;
|
|
|
2509
2506
|
exports.isCELUnsignedIntegerLiteral = isCELUnsignedIntegerLiteral;
|
|
2510
2507
|
exports.parseCEL = parseCEL;
|
|
2511
2508
|
exports.transformAliasInExpression = transformAliasInExpression;
|
|
2509
|
+
|
|
2512
2510
|
//# sourceMappingURL=parseCEL.js.map
|