@react-querybuilder/core 8.20.2 → 8.21.0

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.
Files changed (108) hide show
  1. package/README.md +4 -0
  2. package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +2261 -2113
  3. package/dist/cjs/react-querybuilder_core.cjs.development.js +319 -22
  4. package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
  5. package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +2261 -2113
  6. package/dist/cjs/react-querybuilder_core.cjs.production.js +1 -1
  7. package/dist/cjs/react-querybuilder_core.cjs.production.js.map +1 -1
  8. package/dist/{convertQuery-BJKNgecE.js → convertQuery-Cw76XFIn.js} +8 -8
  9. package/dist/{convertQuery-BJKNgecE.js.map → convertQuery-Cw76XFIn.js.map} +1 -1
  10. package/dist/{convertQuery-J1CaoDxe.mjs → convertQuery-D_4J7E-Z.mjs} +2 -2
  11. package/dist/{convertQuery-J1CaoDxe.mjs.map → convertQuery-D_4J7E-Z.mjs.map} +1 -1
  12. package/dist/formatQuery.d.mts +499 -459
  13. package/dist/formatQuery.d.ts +499 -459
  14. package/dist/formatQuery.js +170 -88
  15. package/dist/formatQuery.js.map +1 -1
  16. package/dist/formatQuery.mjs +97 -20
  17. package/dist/formatQuery.mjs.map +1 -1
  18. package/dist/import-BVdxeIBO.d.mts +26 -0
  19. package/dist/import-Ddc3d_8q.d.ts +26 -0
  20. package/dist/{index-DlVg-QXo.d.mts → index-BSwFvkeI.d.mts} +679 -648
  21. package/dist/{index-DlVg-QXo.d.ts → index-BSwFvkeI.d.ts} +679 -648
  22. package/dist/{objectUtils-DBJI82bl.js → isRuleGroup-0JNiQgLg.js} +1 -26
  23. package/dist/isRuleGroup-0JNiQgLg.js.map +1 -0
  24. package/dist/{objectUtils-ZvPkF6u6.mjs → isRuleGroup-CqLThsbu.mjs} +2 -15
  25. package/dist/isRuleGroup-CqLThsbu.mjs.map +1 -0
  26. package/dist/objectUtils-Cr02aGxb.js +27 -0
  27. package/dist/objectUtils-Cr02aGxb.js.map +1 -0
  28. package/dist/objectUtils-DBlmJgBf.mjs +16 -0
  29. package/dist/objectUtils-DBlmJgBf.mjs.map +1 -0
  30. package/dist/parseCEL.d.mts +64 -30
  31. package/dist/parseCEL.d.ts +64 -30
  32. package/dist/parseCEL.js +91 -12
  33. package/dist/parseCEL.js.map +1 -1
  34. package/dist/parseCEL.mjs +85 -8
  35. package/dist/parseCEL.mjs.map +1 -1
  36. package/dist/parseCypher.d.mts +24 -25
  37. package/dist/parseCypher.d.ts +24 -25
  38. package/dist/parseGremlin.d.mts +18 -19
  39. package/dist/parseGremlin.d.ts +18 -19
  40. package/dist/parseJSONata.d.mts +207 -20
  41. package/dist/parseJSONata.d.ts +207 -20
  42. package/dist/parseJSONata.js +92 -7
  43. package/dist/parseJSONata.js.map +1 -1
  44. package/dist/parseJSONata.mjs +80 -4
  45. package/dist/parseJSONata.mjs.map +1 -1
  46. package/dist/parseJsonLogic.d.mts +51 -18
  47. package/dist/parseJsonLogic.d.ts +51 -18
  48. package/dist/parseJsonLogic.js +95 -34
  49. package/dist/parseJsonLogic.js.map +1 -1
  50. package/dist/parseJsonLogic.mjs +65 -6
  51. package/dist/parseJsonLogic.mjs.map +1 -1
  52. package/dist/parseMongoDB.d.mts +89 -58
  53. package/dist/parseMongoDB.d.ts +89 -58
  54. package/dist/parseMongoDB.js +140 -15
  55. package/dist/parseMongoDB.js.map +1 -1
  56. package/dist/parseMongoDB.mjs +128 -5
  57. package/dist/parseMongoDB.mjs.map +1 -1
  58. package/dist/parseSPARQL.d.mts +17 -18
  59. package/dist/parseSPARQL.d.ts +17 -18
  60. package/dist/parseSPARQL.js.map +1 -1
  61. package/dist/parseSPARQL.mjs.map +1 -1
  62. package/dist/parseSQL.d.mts +266 -18
  63. package/dist/parseSQL.d.ts +266 -18
  64. package/dist/parseSQL.js +163 -10
  65. package/dist/parseSQL.js.map +1 -1
  66. package/dist/parseSQL.mjs +149 -7
  67. package/dist/parseSQL.mjs.map +1 -1
  68. package/dist/parseSpEL.d.mts +193 -19
  69. package/dist/parseSpEL.d.ts +193 -19
  70. package/dist/parseSpEL.js +166 -7
  71. package/dist/parseSpEL.js.map +1 -1
  72. package/dist/parseSpEL.mjs +142 -6
  73. package/dist/parseSpEL.mjs.map +1 -1
  74. package/dist/{prepareQueryObjects-Bni5VgYM.js → prepareQueryObjects-C2-kTZvR.js} +5 -5
  75. package/dist/prepareQueryObjects-C2-kTZvR.js.map +1 -0
  76. package/dist/{prepareQueryObjects-BCLU20Cg.mjs → prepareQueryObjects-Q18lHCKl.mjs} +3 -3
  77. package/dist/prepareQueryObjects-Q18lHCKl.mjs.map +1 -0
  78. package/dist/query-builder-layout.css.map +1 -1
  79. package/dist/query-builder.css.map +1 -1
  80. package/dist/react-querybuilder_core.d.mts +2261 -2113
  81. package/dist/react-querybuilder_core.legacy-esm.d.ts +2261 -2113
  82. package/dist/react-querybuilder_core.legacy-esm.js +335 -40
  83. package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
  84. package/dist/react-querybuilder_core.mjs +309 -23
  85. package/dist/react-querybuilder_core.mjs.map +1 -1
  86. package/dist/react-querybuilder_core.production.d.mts +2261 -2113
  87. package/dist/react-querybuilder_core.production.mjs +1 -1
  88. package/dist/react-querybuilder_core.production.mjs.map +1 -1
  89. package/dist/styles/_layout.scss +4 -10
  90. package/dist/transformQuery.d.mts +91 -92
  91. package/dist/transformQuery.d.ts +91 -92
  92. package/dist/transformQuery.js +4 -3
  93. package/dist/transformQuery.js.map +1 -1
  94. package/dist/transformQuery.mjs +2 -1
  95. package/dist/transformQuery.mjs.map +1 -1
  96. package/dist/{utils-BpaOtylk.js → utils-DEwV7F6B.js} +108 -12
  97. package/dist/utils-DEwV7F6B.js.map +1 -0
  98. package/dist/{utils-CJRGiPb-.mjs → utils-Dt0D_DMV.mjs} +69 -3
  99. package/dist/utils-Dt0D_DMV.mjs.map +1 -0
  100. package/package.json +14 -14
  101. package/dist/import-Qs1-kgv5.d.ts +0 -27
  102. package/dist/import-ShTj5IdB.d.mts +0 -27
  103. package/dist/objectUtils-DBJI82bl.js.map +0 -1
  104. package/dist/objectUtils-ZvPkF6u6.mjs.map +0 -1
  105. package/dist/prepareQueryObjects-BCLU20Cg.mjs.map +0 -1
  106. package/dist/prepareQueryObjects-Bni5VgYM.js.map +0 -1
  107. package/dist/utils-BpaOtylk.js.map +0 -1
  108. package/dist/utils-CJRGiPb-.mjs.map +0 -1
@@ -1,36 +1,284 @@
1
- import { E as DefaultRuleGroupType, j as Except, x as DefaultRuleGroupTypeIC } from "./index-DlVg-QXo.mjs";
2
- import { t as ParserCommonOptions } from "./import-ShTj5IdB.mjs";
3
-
1
+ import { A as DefaultOperatorName, L as Except, P as ExpressionNode, T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType, k as DefaultCombinatorNameExtended } from "./index-BSwFvkeI.mjs";
2
+ import { t as ParserCommonOptions } from "./import-BVdxeIBO.mjs";
3
+ //#region src/utils/parseSQL/types.d.ts
4
+ type AnyCase<T extends string> = string extends T ? string : T extends `${infer F1}${infer F2}${infer R}` ? `${Uppercase<F1> | Lowercase<F1>}${Uppercase<F2> | Lowercase<F2>}${AnyCase<R>}` : T extends `${infer F}${infer R}` ? `${Uppercase<F> | Lowercase<F>}${AnyCase<R>}` : "";
5
+ type TokenType = "AndExpression" | "BetweenPredicate" | "BitExpression" | "Boolean" | "BooleanExtra" | "CaseWhen" | "ComparisonBooleanPrimary" | "ComparisonSubQueryBooleanPrimary" | "ContainsExpr" | "EndsWithExpr" | "ExpressionList" | "ForceIndexHint" | "ForOptIndexHint" | "FunctionCall" | "FunctionCallParam" | "GroupBy" | "GroupByOrderByItem" | "Identifier" | "IdentifierExpr" | "IdentifierList" | "IgnoreIndexHint" | "IndexHintList" | "InExpressionListPredicate" | "InnerCrossJoinTable" | "InSubQueryPredicate" | "IsExpression" | "IsNullBooleanPrimary" | "LeftRightJoinTable" | "LikePredicate" | "Limit" | "Main" | "NaturalJoinTable" | "NotExpression" | "Null" | "Number" | "OnJoinCondition" | "OrderBy" | "OrExpression" | "Partitions" | "PlaceHolder" | "Prefix" | "RegexpPredicate" | "Select" | "SelectExpr" | "SelectParenthesized" | "SimpleExprParentheses" | "SoundsLikePredicate" | "StartsWithExpr" | "StraightJoinTable" | "String" | "SubQuery" | "TableFactor" | "TableReference" | "TableReferences" | "Union" | "UseIndexHint" | "UsingJoinCondition" | "WhenThenList" | "XorExpression";
6
+ type ComparisonOperator = "=" | ">=" | ">" | "<=" | "<" | "<>" | "!=";
7
+ type NotOpt = AnyCase<"NOT"> | null;
8
+ type AndOperator = AnyCase<"AND">;
9
+ type OrOperator = AnyCase<"OR">;
10
+ type XorOperator = AnyCase<"XOR">;
11
+ interface SQLWhereObject {
12
+ type: TokenType;
13
+ }
14
+ interface SQLIdentifier extends SQLWhereObject {
15
+ type: "Identifier";
16
+ value: string;
17
+ }
18
+ interface SQLWhereObjectAny extends SQLWhereObject {
19
+ [k: string]: any;
20
+ }
21
+ interface SQLStringValue extends SQLWhereObject {
22
+ type: "String";
23
+ value: string;
24
+ }
25
+ interface SQLNumberValue extends SQLWhereObject {
26
+ type: "Number";
27
+ value: string;
28
+ }
29
+ interface SQLSignedNumberValue extends SQLWhereObject {
30
+ type: "Prefix";
31
+ prefix: "+" | "-";
32
+ value: SQLNumberValue;
33
+ }
34
+ interface SQLBooleanValue extends SQLWhereObject {
35
+ type: "Boolean";
36
+ value: AnyCase<"TRUE"> | AnyCase<"FALSE">;
37
+ }
38
+ interface SQLBooleanExtra extends SQLWhereObject {
39
+ type: "BooleanExtra";
40
+ value: AnyCase<"UNKNOWN">;
41
+ }
42
+ interface SQLSimpleExprParentheses extends SQLWhereObject {
43
+ type: "SimpleExprParentheses";
44
+ value: SQLExpressionList;
45
+ }
46
+ interface SQLExpressionList extends SQLWhereObject {
47
+ type: "ExpressionList";
48
+ value: SQLExpression[];
49
+ }
50
+ interface SQLInExpressionListPredicate extends SQLWhereObject {
51
+ type: "InExpressionListPredicate";
52
+ hasNot: NotOpt;
53
+ left: SQLSimpleExpression;
54
+ right: SQLExpressionList;
55
+ }
56
+ interface SQLBetweenPredicate extends SQLWhereObject {
57
+ type: "BetweenPredicate";
58
+ hasNot: NotOpt;
59
+ left: SQLSimpleExpression;
60
+ right: {
61
+ left: SQLSimpleExpression;
62
+ right: SQLPredicate;
63
+ };
64
+ }
65
+ interface SQLLikePredicate extends SQLWhereObject {
66
+ type: "LikePredicate";
67
+ hasNot: NotOpt;
68
+ left: SQLSimpleExpression;
69
+ right: SQLSimpleExpression | SQLStartsWithExpr | SQLEndsWithExpr | SQLContainsExpr;
70
+ escape: SQLStringValue | null;
71
+ }
72
+ interface SQLStartsWithExpr extends SQLWhereObject {
73
+ type: "StartsWithExpr";
74
+ value: SQLStringValue | SQLIdentifier;
75
+ }
76
+ interface SQLEndsWithExpr extends SQLWhereObject {
77
+ type: "EndsWithExpr";
78
+ value: SQLStringValue | SQLIdentifier;
79
+ }
80
+ interface SQLContainsExpr extends SQLWhereObject {
81
+ type: "ContainsExpr";
82
+ value: SQLStringValue | SQLIdentifier;
83
+ }
84
+ interface SQLIsNullBooleanPrimary extends SQLWhereObject {
85
+ type: "IsNullBooleanPrimary";
86
+ hasNot: NotOpt;
87
+ value: SQLBooleanPrimary;
88
+ }
89
+ interface SQLComparisonBooleanPrimary extends SQLWhereObject {
90
+ type: "ComparisonBooleanPrimary";
91
+ left: SQLBooleanPrimary;
92
+ operator: ComparisonOperator;
93
+ right: SQLPredicate;
94
+ }
95
+ interface SQLIsExpression extends SQLWhereObject {
96
+ type: "IsExpression";
97
+ hasNot: NotOpt;
98
+ left: SQLBooleanPrimary;
99
+ right: SQLBooleanExtra;
100
+ }
101
+ interface SQLNotExpression extends SQLWhereObject {
102
+ type: "NotExpression";
103
+ value: SQLExpression;
104
+ }
105
+ interface SQLAndExpression extends SQLWhereObject {
106
+ type: "AndExpression";
107
+ operator: AndOperator;
108
+ left: SQLExpression;
109
+ right: SQLExpression;
110
+ }
111
+ interface SQLOrExpression extends SQLWhereObject {
112
+ type: "OrExpression";
113
+ operator: OrOperator;
114
+ left: SQLExpression;
115
+ right: SQLExpression;
116
+ }
117
+ interface SQLXorExpression extends SQLWhereObject {
118
+ type: "XorExpression";
119
+ operator: XorOperator;
120
+ left: SQLExpression;
121
+ right: SQLExpression;
122
+ }
123
+ interface SQLPlaceHolder extends SQLWhereObject {
124
+ type: "PlaceHolder";
125
+ /** Raw token, e.g. `${p1}`. */
126
+ value: string;
127
+ /** Prefix-free placeholder name, e.g. `p1`. */
128
+ param: string;
129
+ }
130
+ interface SQLFunctionCall extends SQLWhereObjectAny {
131
+ type: "FunctionCall";
132
+ name: string;
133
+ params: SQLExpressionOperand[];
134
+ }
135
+ interface SQLCaseWhen extends SQLWhereObjectAny {
136
+ type: "CaseWhen";
137
+ }
138
+ interface SQLPrefix extends SQLWhereObjectAny {
139
+ type: "Prefix";
140
+ }
141
+ interface SQLSubQuery extends SQLWhereObjectAny {
142
+ type: "SubQuery";
143
+ }
144
+ interface SQLIdentifierExpr extends SQLWhereObjectAny {
145
+ type: "IdentifierExpr";
146
+ }
147
+ interface SQLBitExpression extends SQLWhereObjectAny {
148
+ type: "BitExpression";
149
+ operator: string;
150
+ left: SQLExpressionOperand;
151
+ right: SQLExpressionOperand;
152
+ }
153
+ interface SQLInSubQueryPredicate extends SQLWhereObjectAny {
154
+ type: "InSubQueryPredicate";
155
+ }
156
+ interface SQLSoundsLikePredicate extends SQLWhereObjectAny {
157
+ type: "SoundsLikePredicate";
158
+ }
159
+ interface SQLRegexpPredicate extends SQLWhereObjectAny {
160
+ type: "RegexpPredicate";
161
+ }
162
+ interface SQLComparisonSubQueryBooleanPrimary extends SQLWhereObjectAny {
163
+ type: "ComparisonSubQueryBooleanPrimary";
164
+ }
165
+ type SQLLiteralValue = SQLStringValue | SQLNumberValue | SQLBooleanValue;
166
+ type SQLSimpleExpression = SQLLiteralValue | SQLIdentifier | SQLFunctionCall | SQLCaseWhen | SQLPrefix | SQLSubQuery | SQLIdentifierExpr | SQLBitExpression | SQLPlaceHolder | SQLSimpleExprParentheses;
167
+ type SQLPredicate = SQLSimpleExpression | SQLInExpressionListPredicate | SQLBetweenPredicate | SQLLikePredicate | SQLInSubQueryPredicate | SQLSoundsLikePredicate | SQLRegexpPredicate;
168
+ type SQLBooleanPrimary = SQLPredicate | SQLIsNullBooleanPrimary | SQLComparisonBooleanPrimary | SQLComparisonSubQueryBooleanPrimary;
169
+ type SQLExpression = SQLBooleanPrimary | SQLIsExpression | SQLNotExpression | SQLAndExpression | SQLOrExpression | SQLXorExpression;
170
+ interface ParsedSQL {
171
+ nodeType: "Main";
172
+ value: {
173
+ type: "Select";
174
+ distinctOpt: string | null;
175
+ highPriorityOpt: unknown;
176
+ maxStateMentTimeOpt: unknown;
177
+ straightJoinOpt: unknown;
178
+ sqlSmallResultOpt: unknown;
179
+ sqlBigResultOpt: unknown;
180
+ sqlBufferResultOpt: unknown;
181
+ sqlCacheOpt: unknown;
182
+ sqlCalcFoundRowsOpt: unknown;
183
+ selectItems: SQLWhereObjectAny;
184
+ from: SQLWhereObjectAny;
185
+ partition: unknown;
186
+ where: SQLExpression;
187
+ groupBy: SQLWhereObjectAny | null;
188
+ having: SQLWhereObjectAny | null;
189
+ orderBy: SQLWhereObjectAny | null;
190
+ limit: SQLWhereObjectAny | null;
191
+ procedure: SQLWhereObjectAny | null;
192
+ updateLockMode: unknown;
193
+ };
194
+ hasSemicolon: boolean;
195
+ }
196
+ type MixedAndXorOrList = {
197
+ combinator: DefaultCombinatorNameExtended;
198
+ expressions: (MixedAndXorOrList | SQLExpression)[];
199
+ };
200
+ /**
201
+ * A SQL operand subtree that a {@link ParseSQLOptions.getExpression} handler may receive: a
202
+ * bare identifier, a (signed) literal, a placeholder, an arithmetic {@link SQLBitExpression},
203
+ * a {@link SQLFunctionCall}, or a parenthesized wrapper (unwrapped by the handler).
204
+ */
205
+ type SQLExpressionOperand = SQLIdentifier | SQLLiteralValue | SQLSignedNumberValue | SQLPlaceHolder | SQLBitExpression | SQLFunctionCall | SQLSimpleExprParentheses;
206
+ /**
207
+ * Context passed to a {@link ParseSQLOptions.getExpression} handler alongside the operand
208
+ * node. Carries the same number-parsing option as the rest of `parseSQL` plus a predicate
209
+ * for validating that `field` leaves inside an expression exist in the configured fields.
210
+ */
211
+ interface ParseSQLExpressionContext {
212
+ bigIntOnOverflow?: boolean;
213
+ /** `true` when the field exists in the configured fields (or no fields were configured). */
214
+ fieldExists: (fieldName: string) => boolean;
215
+ }
216
+ //#endregion
4
217
  //#region src/utils/parseSQL/parseSQL.d.ts
5
218
  /**
6
- * Options object for {@link parseSQL}.
7
- */
219
+ * Options object for {@link parseSQL}.
220
+ */
8
221
  interface ParseSQLOptions extends ParserCommonOptions {
9
222
  paramPrefix?: string;
10
223
  params?: any[] | Record<string, any>;
224
+ /**
225
+ * Handler that converts a non-identifier/non-literal SQL operand subtree (arithmetic
226
+ * {@link SQLExpressionOperand BitExpression} / FunctionCall / parenthesized) into an
227
+ * {@link ExpressionNode}. Return `null` to reject (the rule is dropped). Supplied by
228
+ * `@react-querybuilder/expr` (`expressionParserSQL`). When omitted, expression operands
229
+ * are ignored (current behavior — rule dropped).
230
+ */
231
+ getExpression?: (node: SQLExpressionOperand, ctx: ParseSQLExpressionContext) => ExpressionNode | null;
232
+ /**
233
+ * When set, parameter placeholders are retained as `valueSource: 'parameter'` rules
234
+ * (value = placeholder name) instead of being dropped. Placeholders whose name is
235
+ * supplied via {@link ParseSQLOptions.params} are still substituted to literals first.
236
+ *
237
+ * - `true` — accept the default named prefix `':'` and positional `'?'`.
238
+ * - `{ prefix }` — one or more named prefixes to accept (e.g. `':'`, `'@'`, `'$'`).
239
+ * - `{ positional }` — enable/disable positional `?` (default enabled).
240
+ */
241
+ parseParameters?: boolean | {
242
+ prefix?: string | string[];
243
+ positional?: boolean;
244
+ };
11
245
  }
12
246
  /**
13
- * Converts a SQL `SELECT` statement into a query suitable for the
14
- * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
15
- * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
16
- */
247
+ * Converts a SQL `SELECT` statement into a query suitable for the
248
+ * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
249
+ * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
250
+ */
17
251
  declare function parseSQL(sql: string): DefaultRuleGroupType;
18
252
  /**
19
- * Converts a SQL `SELECT` statement into a query suitable for the
20
- * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
21
- * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
22
- */
253
+ * Converts a SQL `SELECT` statement into a query suitable for the
254
+ * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
255
+ * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
256
+ */
23
257
  declare function parseSQL(sql: string, options: Except<ParseSQLOptions, "independentCombinators"> & {
24
258
  independentCombinators?: false;
25
259
  }): DefaultRuleGroupType;
26
260
  /**
27
- * Converts a SQL `SELECT` statement into a query suitable for the
28
- * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
29
- * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
30
- */
261
+ * Converts a SQL `SELECT` statement into a query suitable for the
262
+ * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
263
+ * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
264
+ */
31
265
  declare function parseSQL(sql: string, options: Except<ParseSQLOptions, "independentCombinators"> & {
32
266
  independentCombinators: true;
33
267
  }): DefaultRuleGroupTypeIC;
34
268
  //#endregion
35
- export { ParseSQLOptions, parseSQL };
269
+ //#region src/utils/parseSQL/utils.d.ts
270
+ declare const isSQLLiteralValue: (v?: SQLWhereObjectAny) => v is SQLLiteralValue;
271
+ declare const isSQLSignedNumber: (v?: SQLWhereObjectAny) => v is SQLSignedNumberValue;
272
+ declare const isSQLLiteralOrSignedNumberValue: (v?: SQLWhereObjectAny) => v is SQLLiteralValue | SQLSignedNumberValue;
273
+ declare const isSQLIdentifier: (v?: SQLWhereObjectAny) => v is SQLIdentifier;
274
+ declare const isSQLBitExpression: (v?: SQLWhereObjectAny) => v is SQLBitExpression;
275
+ declare const isSQLFunctionCall: (v?: SQLWhereObjectAny) => v is SQLFunctionCall;
276
+ declare const isSQLPlaceHolder: (v?: SQLWhereObjectAny) => v is SQLPlaceHolder;
277
+ /** An operand that is neither a bare identifier nor a (signed) literal nor a placeholder. */
278
+ declare const isSQLExpressionOperand: (v?: SQLWhereObjectAny) => boolean;
279
+ declare const getFieldName: (f: string | SQLIdentifier) => string;
280
+ declare const normalizeOperator: (op: ComparisonOperator, flip?: boolean) => DefaultOperatorName;
281
+ declare const evalSQLLiteralValue: (valueObj: SQLLiteralValue | SQLSignedNumberValue, { bigIntOnOverflow }?: ParseSQLOptions) => any;
282
+ //#endregion
283
+ export { AndOperator, ComparisonOperator, MixedAndXorOrList, NotOpt, OrOperator, ParseSQLExpressionContext, ParseSQLOptions, ParsedSQL, SQLAndExpression, SQLBetweenPredicate, SQLBitExpression, SQLBooleanExtra, SQLBooleanPrimary, SQLBooleanValue, SQLCaseWhen, SQLComparisonBooleanPrimary, SQLComparisonSubQueryBooleanPrimary, SQLContainsExpr, SQLEndsWithExpr, SQLExpression, SQLExpressionList, SQLExpressionOperand, SQLFunctionCall, SQLIdentifier, SQLIdentifierExpr, SQLInExpressionListPredicate, SQLInSubQueryPredicate, SQLIsExpression, SQLIsNullBooleanPrimary, SQLLikePredicate, SQLLiteralValue, SQLNotExpression, SQLNumberValue, SQLOrExpression, SQLPlaceHolder, SQLPredicate, SQLPrefix, SQLRegexpPredicate, SQLSignedNumberValue, SQLSimpleExprParentheses, SQLSimpleExpression, SQLSoundsLikePredicate, SQLStartsWithExpr, SQLStringValue, SQLSubQuery, SQLWhereObject, SQLWhereObjectAny, SQLXorExpression, XorOperator, evalSQLLiteralValue, getFieldName, isSQLBitExpression, isSQLExpressionOperand, isSQLFunctionCall, isSQLIdentifier, isSQLLiteralOrSignedNumberValue, isSQLLiteralValue, isSQLPlaceHolder, isSQLSignedNumber, normalizeOperator, parseSQL };
36
284
  //# sourceMappingURL=parseSQL.d.mts.map
@@ -1,36 +1,284 @@
1
- import { E as DefaultRuleGroupType, j as Except, x as DefaultRuleGroupTypeIC } from "./index-DlVg-QXo.js";
2
- import { t as ParserCommonOptions } from "./import-Qs1-kgv5.js";
3
-
1
+ import { A as DefaultOperatorName, L as Except, P as ExpressionNode, T as DefaultRuleGroupTypeIC, j as DefaultRuleGroupType, k as DefaultCombinatorNameExtended } from "./index-BSwFvkeI.js";
2
+ import { t as ParserCommonOptions } from "./import-Ddc3d_8q.js";
3
+ //#region src/utils/parseSQL/types.d.ts
4
+ type AnyCase<T extends string> = string extends T ? string : T extends `${infer F1}${infer F2}${infer R}` ? `${Uppercase<F1> | Lowercase<F1>}${Uppercase<F2> | Lowercase<F2>}${AnyCase<R>}` : T extends `${infer F}${infer R}` ? `${Uppercase<F> | Lowercase<F>}${AnyCase<R>}` : "";
5
+ type TokenType = "AndExpression" | "BetweenPredicate" | "BitExpression" | "Boolean" | "BooleanExtra" | "CaseWhen" | "ComparisonBooleanPrimary" | "ComparisonSubQueryBooleanPrimary" | "ContainsExpr" | "EndsWithExpr" | "ExpressionList" | "ForceIndexHint" | "ForOptIndexHint" | "FunctionCall" | "FunctionCallParam" | "GroupBy" | "GroupByOrderByItem" | "Identifier" | "IdentifierExpr" | "IdentifierList" | "IgnoreIndexHint" | "IndexHintList" | "InExpressionListPredicate" | "InnerCrossJoinTable" | "InSubQueryPredicate" | "IsExpression" | "IsNullBooleanPrimary" | "LeftRightJoinTable" | "LikePredicate" | "Limit" | "Main" | "NaturalJoinTable" | "NotExpression" | "Null" | "Number" | "OnJoinCondition" | "OrderBy" | "OrExpression" | "Partitions" | "PlaceHolder" | "Prefix" | "RegexpPredicate" | "Select" | "SelectExpr" | "SelectParenthesized" | "SimpleExprParentheses" | "SoundsLikePredicate" | "StartsWithExpr" | "StraightJoinTable" | "String" | "SubQuery" | "TableFactor" | "TableReference" | "TableReferences" | "Union" | "UseIndexHint" | "UsingJoinCondition" | "WhenThenList" | "XorExpression";
6
+ type ComparisonOperator = "=" | ">=" | ">" | "<=" | "<" | "<>" | "!=";
7
+ type NotOpt = AnyCase<"NOT"> | null;
8
+ type AndOperator = AnyCase<"AND">;
9
+ type OrOperator = AnyCase<"OR">;
10
+ type XorOperator = AnyCase<"XOR">;
11
+ interface SQLWhereObject {
12
+ type: TokenType;
13
+ }
14
+ interface SQLIdentifier extends SQLWhereObject {
15
+ type: "Identifier";
16
+ value: string;
17
+ }
18
+ interface SQLWhereObjectAny extends SQLWhereObject {
19
+ [k: string]: any;
20
+ }
21
+ interface SQLStringValue extends SQLWhereObject {
22
+ type: "String";
23
+ value: string;
24
+ }
25
+ interface SQLNumberValue extends SQLWhereObject {
26
+ type: "Number";
27
+ value: string;
28
+ }
29
+ interface SQLSignedNumberValue extends SQLWhereObject {
30
+ type: "Prefix";
31
+ prefix: "+" | "-";
32
+ value: SQLNumberValue;
33
+ }
34
+ interface SQLBooleanValue extends SQLWhereObject {
35
+ type: "Boolean";
36
+ value: AnyCase<"TRUE"> | AnyCase<"FALSE">;
37
+ }
38
+ interface SQLBooleanExtra extends SQLWhereObject {
39
+ type: "BooleanExtra";
40
+ value: AnyCase<"UNKNOWN">;
41
+ }
42
+ interface SQLSimpleExprParentheses extends SQLWhereObject {
43
+ type: "SimpleExprParentheses";
44
+ value: SQLExpressionList;
45
+ }
46
+ interface SQLExpressionList extends SQLWhereObject {
47
+ type: "ExpressionList";
48
+ value: SQLExpression[];
49
+ }
50
+ interface SQLInExpressionListPredicate extends SQLWhereObject {
51
+ type: "InExpressionListPredicate";
52
+ hasNot: NotOpt;
53
+ left: SQLSimpleExpression;
54
+ right: SQLExpressionList;
55
+ }
56
+ interface SQLBetweenPredicate extends SQLWhereObject {
57
+ type: "BetweenPredicate";
58
+ hasNot: NotOpt;
59
+ left: SQLSimpleExpression;
60
+ right: {
61
+ left: SQLSimpleExpression;
62
+ right: SQLPredicate;
63
+ };
64
+ }
65
+ interface SQLLikePredicate extends SQLWhereObject {
66
+ type: "LikePredicate";
67
+ hasNot: NotOpt;
68
+ left: SQLSimpleExpression;
69
+ right: SQLSimpleExpression | SQLStartsWithExpr | SQLEndsWithExpr | SQLContainsExpr;
70
+ escape: SQLStringValue | null;
71
+ }
72
+ interface SQLStartsWithExpr extends SQLWhereObject {
73
+ type: "StartsWithExpr";
74
+ value: SQLStringValue | SQLIdentifier;
75
+ }
76
+ interface SQLEndsWithExpr extends SQLWhereObject {
77
+ type: "EndsWithExpr";
78
+ value: SQLStringValue | SQLIdentifier;
79
+ }
80
+ interface SQLContainsExpr extends SQLWhereObject {
81
+ type: "ContainsExpr";
82
+ value: SQLStringValue | SQLIdentifier;
83
+ }
84
+ interface SQLIsNullBooleanPrimary extends SQLWhereObject {
85
+ type: "IsNullBooleanPrimary";
86
+ hasNot: NotOpt;
87
+ value: SQLBooleanPrimary;
88
+ }
89
+ interface SQLComparisonBooleanPrimary extends SQLWhereObject {
90
+ type: "ComparisonBooleanPrimary";
91
+ left: SQLBooleanPrimary;
92
+ operator: ComparisonOperator;
93
+ right: SQLPredicate;
94
+ }
95
+ interface SQLIsExpression extends SQLWhereObject {
96
+ type: "IsExpression";
97
+ hasNot: NotOpt;
98
+ left: SQLBooleanPrimary;
99
+ right: SQLBooleanExtra;
100
+ }
101
+ interface SQLNotExpression extends SQLWhereObject {
102
+ type: "NotExpression";
103
+ value: SQLExpression;
104
+ }
105
+ interface SQLAndExpression extends SQLWhereObject {
106
+ type: "AndExpression";
107
+ operator: AndOperator;
108
+ left: SQLExpression;
109
+ right: SQLExpression;
110
+ }
111
+ interface SQLOrExpression extends SQLWhereObject {
112
+ type: "OrExpression";
113
+ operator: OrOperator;
114
+ left: SQLExpression;
115
+ right: SQLExpression;
116
+ }
117
+ interface SQLXorExpression extends SQLWhereObject {
118
+ type: "XorExpression";
119
+ operator: XorOperator;
120
+ left: SQLExpression;
121
+ right: SQLExpression;
122
+ }
123
+ interface SQLPlaceHolder extends SQLWhereObject {
124
+ type: "PlaceHolder";
125
+ /** Raw token, e.g. `${p1}`. */
126
+ value: string;
127
+ /** Prefix-free placeholder name, e.g. `p1`. */
128
+ param: string;
129
+ }
130
+ interface SQLFunctionCall extends SQLWhereObjectAny {
131
+ type: "FunctionCall";
132
+ name: string;
133
+ params: SQLExpressionOperand[];
134
+ }
135
+ interface SQLCaseWhen extends SQLWhereObjectAny {
136
+ type: "CaseWhen";
137
+ }
138
+ interface SQLPrefix extends SQLWhereObjectAny {
139
+ type: "Prefix";
140
+ }
141
+ interface SQLSubQuery extends SQLWhereObjectAny {
142
+ type: "SubQuery";
143
+ }
144
+ interface SQLIdentifierExpr extends SQLWhereObjectAny {
145
+ type: "IdentifierExpr";
146
+ }
147
+ interface SQLBitExpression extends SQLWhereObjectAny {
148
+ type: "BitExpression";
149
+ operator: string;
150
+ left: SQLExpressionOperand;
151
+ right: SQLExpressionOperand;
152
+ }
153
+ interface SQLInSubQueryPredicate extends SQLWhereObjectAny {
154
+ type: "InSubQueryPredicate";
155
+ }
156
+ interface SQLSoundsLikePredicate extends SQLWhereObjectAny {
157
+ type: "SoundsLikePredicate";
158
+ }
159
+ interface SQLRegexpPredicate extends SQLWhereObjectAny {
160
+ type: "RegexpPredicate";
161
+ }
162
+ interface SQLComparisonSubQueryBooleanPrimary extends SQLWhereObjectAny {
163
+ type: "ComparisonSubQueryBooleanPrimary";
164
+ }
165
+ type SQLLiteralValue = SQLStringValue | SQLNumberValue | SQLBooleanValue;
166
+ type SQLSimpleExpression = SQLLiteralValue | SQLIdentifier | SQLFunctionCall | SQLCaseWhen | SQLPrefix | SQLSubQuery | SQLIdentifierExpr | SQLBitExpression | SQLPlaceHolder | SQLSimpleExprParentheses;
167
+ type SQLPredicate = SQLSimpleExpression | SQLInExpressionListPredicate | SQLBetweenPredicate | SQLLikePredicate | SQLInSubQueryPredicate | SQLSoundsLikePredicate | SQLRegexpPredicate;
168
+ type SQLBooleanPrimary = SQLPredicate | SQLIsNullBooleanPrimary | SQLComparisonBooleanPrimary | SQLComparisonSubQueryBooleanPrimary;
169
+ type SQLExpression = SQLBooleanPrimary | SQLIsExpression | SQLNotExpression | SQLAndExpression | SQLOrExpression | SQLXorExpression;
170
+ interface ParsedSQL {
171
+ nodeType: "Main";
172
+ value: {
173
+ type: "Select";
174
+ distinctOpt: string | null;
175
+ highPriorityOpt: unknown;
176
+ maxStateMentTimeOpt: unknown;
177
+ straightJoinOpt: unknown;
178
+ sqlSmallResultOpt: unknown;
179
+ sqlBigResultOpt: unknown;
180
+ sqlBufferResultOpt: unknown;
181
+ sqlCacheOpt: unknown;
182
+ sqlCalcFoundRowsOpt: unknown;
183
+ selectItems: SQLWhereObjectAny;
184
+ from: SQLWhereObjectAny;
185
+ partition: unknown;
186
+ where: SQLExpression;
187
+ groupBy: SQLWhereObjectAny | null;
188
+ having: SQLWhereObjectAny | null;
189
+ orderBy: SQLWhereObjectAny | null;
190
+ limit: SQLWhereObjectAny | null;
191
+ procedure: SQLWhereObjectAny | null;
192
+ updateLockMode: unknown;
193
+ };
194
+ hasSemicolon: boolean;
195
+ }
196
+ type MixedAndXorOrList = {
197
+ combinator: DefaultCombinatorNameExtended;
198
+ expressions: (MixedAndXorOrList | SQLExpression)[];
199
+ };
200
+ /**
201
+ * A SQL operand subtree that a {@link ParseSQLOptions.getExpression} handler may receive: a
202
+ * bare identifier, a (signed) literal, a placeholder, an arithmetic {@link SQLBitExpression},
203
+ * a {@link SQLFunctionCall}, or a parenthesized wrapper (unwrapped by the handler).
204
+ */
205
+ type SQLExpressionOperand = SQLIdentifier | SQLLiteralValue | SQLSignedNumberValue | SQLPlaceHolder | SQLBitExpression | SQLFunctionCall | SQLSimpleExprParentheses;
206
+ /**
207
+ * Context passed to a {@link ParseSQLOptions.getExpression} handler alongside the operand
208
+ * node. Carries the same number-parsing option as the rest of `parseSQL` plus a predicate
209
+ * for validating that `field` leaves inside an expression exist in the configured fields.
210
+ */
211
+ interface ParseSQLExpressionContext {
212
+ bigIntOnOverflow?: boolean;
213
+ /** `true` when the field exists in the configured fields (or no fields were configured). */
214
+ fieldExists: (fieldName: string) => boolean;
215
+ }
216
+ //#endregion
4
217
  //#region src/utils/parseSQL/parseSQL.d.ts
5
218
  /**
6
- * Options object for {@link parseSQL}.
7
- */
219
+ * Options object for {@link parseSQL}.
220
+ */
8
221
  interface ParseSQLOptions extends ParserCommonOptions {
9
222
  paramPrefix?: string;
10
223
  params?: any[] | Record<string, any>;
224
+ /**
225
+ * Handler that converts a non-identifier/non-literal SQL operand subtree (arithmetic
226
+ * {@link SQLExpressionOperand BitExpression} / FunctionCall / parenthesized) into an
227
+ * {@link ExpressionNode}. Return `null` to reject (the rule is dropped). Supplied by
228
+ * `@react-querybuilder/expr` (`expressionParserSQL`). When omitted, expression operands
229
+ * are ignored (current behavior — rule dropped).
230
+ */
231
+ getExpression?: (node: SQLExpressionOperand, ctx: ParseSQLExpressionContext) => ExpressionNode | null;
232
+ /**
233
+ * When set, parameter placeholders are retained as `valueSource: 'parameter'` rules
234
+ * (value = placeholder name) instead of being dropped. Placeholders whose name is
235
+ * supplied via {@link ParseSQLOptions.params} are still substituted to literals first.
236
+ *
237
+ * - `true` — accept the default named prefix `':'` and positional `'?'`.
238
+ * - `{ prefix }` — one or more named prefixes to accept (e.g. `':'`, `'@'`, `'$'`).
239
+ * - `{ positional }` — enable/disable positional `?` (default enabled).
240
+ */
241
+ parseParameters?: boolean | {
242
+ prefix?: string | string[];
243
+ positional?: boolean;
244
+ };
11
245
  }
12
246
  /**
13
- * Converts a SQL `SELECT` statement into a query suitable for the
14
- * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
15
- * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
16
- */
247
+ * Converts a SQL `SELECT` statement into a query suitable for the
248
+ * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
249
+ * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
250
+ */
17
251
  declare function parseSQL(sql: string): DefaultRuleGroupType;
18
252
  /**
19
- * Converts a SQL `SELECT` statement into a query suitable for the
20
- * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
21
- * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
22
- */
253
+ * Converts a SQL `SELECT` statement into a query suitable for the
254
+ * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
255
+ * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
256
+ */
23
257
  declare function parseSQL(sql: string, options: Except<ParseSQLOptions, "independentCombinators"> & {
24
258
  independentCombinators?: false;
25
259
  }): DefaultRuleGroupType;
26
260
  /**
27
- * Converts a SQL `SELECT` statement into a query suitable for the
28
- * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
29
- * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
30
- */
261
+ * Converts a SQL `SELECT` statement into a query suitable for the
262
+ * {@link index!QueryBuilder QueryBuilder} component's `query` or `defaultQuery` props
263
+ * ({@link index!DefaultRuleGroupType DefaultRuleGroupType}).
264
+ */
31
265
  declare function parseSQL(sql: string, options: Except<ParseSQLOptions, "independentCombinators"> & {
32
266
  independentCombinators: true;
33
267
  }): DefaultRuleGroupTypeIC;
34
268
  //#endregion
35
- export { ParseSQLOptions, parseSQL };
269
+ //#region src/utils/parseSQL/utils.d.ts
270
+ declare const isSQLLiteralValue: (v?: SQLWhereObjectAny) => v is SQLLiteralValue;
271
+ declare const isSQLSignedNumber: (v?: SQLWhereObjectAny) => v is SQLSignedNumberValue;
272
+ declare const isSQLLiteralOrSignedNumberValue: (v?: SQLWhereObjectAny) => v is SQLLiteralValue | SQLSignedNumberValue;
273
+ declare const isSQLIdentifier: (v?: SQLWhereObjectAny) => v is SQLIdentifier;
274
+ declare const isSQLBitExpression: (v?: SQLWhereObjectAny) => v is SQLBitExpression;
275
+ declare const isSQLFunctionCall: (v?: SQLWhereObjectAny) => v is SQLFunctionCall;
276
+ declare const isSQLPlaceHolder: (v?: SQLWhereObjectAny) => v is SQLPlaceHolder;
277
+ /** An operand that is neither a bare identifier nor a (signed) literal nor a placeholder. */
278
+ declare const isSQLExpressionOperand: (v?: SQLWhereObjectAny) => boolean;
279
+ declare const getFieldName: (f: string | SQLIdentifier) => string;
280
+ declare const normalizeOperator: (op: ComparisonOperator, flip?: boolean) => DefaultOperatorName;
281
+ declare const evalSQLLiteralValue: (valueObj: SQLLiteralValue | SQLSignedNumberValue, { bigIntOnOverflow }?: ParseSQLOptions) => any;
282
+ //#endregion
283
+ export { AndOperator, ComparisonOperator, MixedAndXorOrList, NotOpt, OrOperator, ParseSQLExpressionContext, ParseSQLOptions, ParsedSQL, SQLAndExpression, SQLBetweenPredicate, SQLBitExpression, SQLBooleanExtra, SQLBooleanPrimary, SQLBooleanValue, SQLCaseWhen, SQLComparisonBooleanPrimary, SQLComparisonSubQueryBooleanPrimary, SQLContainsExpr, SQLEndsWithExpr, SQLExpression, SQLExpressionList, SQLExpressionOperand, SQLFunctionCall, SQLIdentifier, SQLIdentifierExpr, SQLInExpressionListPredicate, SQLInSubQueryPredicate, SQLIsExpression, SQLIsNullBooleanPrimary, SQLLikePredicate, SQLLiteralValue, SQLNotExpression, SQLNumberValue, SQLOrExpression, SQLPlaceHolder, SQLPredicate, SQLPrefix, SQLRegexpPredicate, SQLSignedNumberValue, SQLSimpleExprParentheses, SQLSimpleExpression, SQLSoundsLikePredicate, SQLStartsWithExpr, SQLStringValue, SQLSubQuery, SQLWhereObject, SQLWhereObjectAny, SQLXorExpression, XorOperator, evalSQLLiteralValue, getFieldName, isSQLBitExpression, isSQLExpressionOperand, isSQLFunctionCall, isSQLIdentifier, isSQLLiteralOrSignedNumberValue, isSQLLiteralValue, isSQLPlaceHolder, isSQLSignedNumber, normalizeOperator, parseSQL };
36
284
  //# sourceMappingURL=parseSQL.d.ts.map