@react-querybuilder/core 8.9.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 (80) hide show
  1. package/README.md +84 -0
  2. package/dist/arrayUtils-D5EoIsKP.js +164 -0
  3. package/dist/arrayUtils-D5EoIsKP.js.map +1 -0
  4. package/dist/basic-C8xXKHIA.d.ts +1235 -0
  5. package/dist/cjs/index.d.ts +1 -0
  6. package/dist/cjs/index.js +6 -0
  7. package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +4786 -0
  8. package/dist/cjs/react-querybuilder_core.cjs.development.js +4033 -0
  9. package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -0
  10. package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +4786 -0
  11. package/dist/cjs/react-querybuilder_core.cjs.production.js +2 -0
  12. package/dist/cjs/react-querybuilder_core.cjs.production.js.map +1 -0
  13. package/dist/convertQuery-DAqoID3O.js +87 -0
  14. package/dist/convertQuery-DAqoID3O.js.map +1 -0
  15. package/dist/export-DyrnTh6K.d.ts +452 -0
  16. package/dist/formatQuery.d.ts +667 -0
  17. package/dist/formatQuery.js +2428 -0
  18. package/dist/formatQuery.js.map +1 -0
  19. package/dist/import-Cksobmln.d.ts +28 -0
  20. package/dist/isRuleGroup-DqAs2x4E.js +120 -0
  21. package/dist/isRuleGroup-DqAs2x4E.js.map +1 -0
  22. package/dist/objectUtils-BBZSfZJz.js +17 -0
  23. package/dist/objectUtils-BBZSfZJz.js.map +1 -0
  24. package/dist/optGroupUtils-CXLgyg2i.js +138 -0
  25. package/dist/optGroupUtils-CXLgyg2i.js.map +1 -0
  26. package/dist/parseCEL.d.ts +34 -0
  27. package/dist/parseCEL.js +2593 -0
  28. package/dist/parseCEL.js.map +1 -0
  29. package/dist/parseJSONata.d.ts +36 -0
  30. package/dist/parseJSONata.js +5884 -0
  31. package/dist/parseJSONata.js.map +1 -0
  32. package/dist/parseJsonLogic.d.ts +36 -0
  33. package/dist/parseJsonLogic.js +191 -0
  34. package/dist/parseJsonLogic.js.map +1 -0
  35. package/dist/parseMongoDB.d.ts +79 -0
  36. package/dist/parseMongoDB.js +267 -0
  37. package/dist/parseMongoDB.js.map +1 -0
  38. package/dist/parseNumber-Bcys1kOH.js +31 -0
  39. package/dist/parseNumber-Bcys1kOH.js.map +1 -0
  40. package/dist/parseSQL.d.ts +37 -0
  41. package/dist/parseSQL.js +6626 -0
  42. package/dist/parseSQL.js.map +1 -0
  43. package/dist/parseSpEL.d.ts +34 -0
  44. package/dist/parseSpEL.js +2911 -0
  45. package/dist/parseSpEL.js.map +1 -0
  46. package/dist/prepareQueryObjects-BqFEs4eV.js +172 -0
  47. package/dist/prepareQueryObjects-BqFEs4eV.js.map +1 -0
  48. package/dist/query-builder-layout.css +1 -0
  49. package/dist/query-builder-layout.css.map +1 -0
  50. package/dist/query-builder-layout.scss +4 -0
  51. package/dist/query-builder.css +1 -0
  52. package/dist/query-builder.css.map +1 -0
  53. package/dist/query-builder.scss +2 -0
  54. package/dist/react-querybuilder_core.d.mts +4786 -0
  55. package/dist/react-querybuilder_core.legacy-esm.d.ts +4786 -0
  56. package/dist/react-querybuilder_core.legacy-esm.js +3916 -0
  57. package/dist/react-querybuilder_core.legacy-esm.js.map +1 -0
  58. package/dist/react-querybuilder_core.mjs +3852 -0
  59. package/dist/react-querybuilder_core.mjs.map +1 -0
  60. package/dist/react-querybuilder_core.production.d.mts +4786 -0
  61. package/dist/react-querybuilder_core.production.mjs +2 -0
  62. package/dist/react-querybuilder_core.production.mjs.map +1 -0
  63. package/dist/styles/_functions.scss +14 -0
  64. package/dist/styles/_layout.scss +201 -0
  65. package/dist/styles/_main.scss +114 -0
  66. package/dist/styles/_root.scss +66 -0
  67. package/dist/styles/_variables.scss +66 -0
  68. package/dist/transformQuery-FL_nlpp5.js +47 -0
  69. package/dist/transformQuery-FL_nlpp5.js.map +1 -0
  70. package/dist/transformQuery.d.ts +118 -0
  71. package/dist/transformQuery.js +4 -0
  72. package/formatQuery/package.json +4 -0
  73. package/package.json +146 -0
  74. package/parseCEL/package.json +4 -0
  75. package/parseJSONata/package.json +4 -0
  76. package/parseJsonLogic/package.json +4 -0
  77. package/parseMongoDB/package.json +4 -0
  78. package/parseSQL/package.json +4 -0
  79. package/parseSpEL/package.json +4 -0
  80. package/transformQuery/package.json +4 -0
@@ -0,0 +1,4786 @@
1
+ import { JsonLogicAll, JsonLogicAnd, JsonLogicDoubleNegation, JsonLogicEqual, JsonLogicGreaterThan, JsonLogicGreaterThanOrEqual, JsonLogicInArray, JsonLogicInString, JsonLogicLessThan, JsonLogicLessThanOrEqual, JsonLogicNegation, JsonLogicNone, JsonLogicNotEqual, JsonLogicOr, JsonLogicSome, JsonLogicStrictEqual, JsonLogicStrictNotEqual, JsonLogicVar, ReservedOperations as JsonLogicReservedOperations, RulesLogic, RulesLogic as JsonLogicRulesLogic } from "json-logic-js";
2
+ import { Column, Operators, SQL, Table } from "drizzle-orm";
3
+ import { WhereOptions } from "sequelize";
4
+
5
+ //#region src/types/type-fest/is-equal.d.ts
6
+
7
+ /**
8
+ Returns a boolean for whether the two given types are equal.
9
+
10
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
11
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
12
+
13
+ Use-cases:
14
+ - If you want to make a conditional branch based on the result of a comparison of two types.
15
+
16
+ @example
17
+ ```
18
+ import type {IsEqual} from 'type-fest';
19
+
20
+ // This type returns a boolean for whether the given array includes the given item.
21
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
22
+ type Includes<Value extends readonly any[], Item> =
23
+ Value extends readonly [Value[0], ...infer rest]
24
+ ? IsEqual<Value[0], Item> extends true
25
+ ? true
26
+ : Includes<rest, Item>
27
+ : false;
28
+ ```
29
+
30
+ @group type-fest
31
+ */
32
+ type IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
33
+ //#endregion
34
+ //#region src/types/type-fest/and.d.ts
35
+ /**
36
+ Returns a boolean for whether two given types are both true.
37
+
38
+ Use-case: Constructing complex conditional types where multiple conditions must be satisfied.
39
+
40
+ @example
41
+ ```
42
+ import type {And} from 'type-fest';
43
+
44
+ And<true, true>;
45
+ //=> true
46
+
47
+ And<true, false>;
48
+ //=> false
49
+ ```
50
+
51
+ @see {@link Or}
52
+
53
+ @group type-fest
54
+ */
55
+ type And<A extends boolean, B extends boolean> = [A, B][number] extends true ? true : true extends [IsEqual<A, false>, IsEqual<B, false>][number] ? false : never;
56
+ //#endregion
57
+ //#region src/types/type-fest/is-never.d.ts
58
+ /**
59
+ Returns a boolean for whether the given type is `never`.
60
+
61
+ @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
62
+ @link https://stackoverflow.com/a/53984913/10292952
63
+ @link https://www.zhenghao.io/posts/ts-never
64
+
65
+ Useful in type utilities, such as checking if something does not occur.
66
+
67
+ @example
68
+ ```
69
+ import type {IsNever, And} from 'type-fest';
70
+
71
+ // https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
72
+ type AreStringsEqual<A extends string, B extends string> =
73
+ And<
74
+ IsNever<Exclude<A, B>> extends true ? true : false,
75
+ IsNever<Exclude<B, A>> extends true ? true : false
76
+ >;
77
+
78
+ type EndIfEqual<I extends string, O extends string> =
79
+ AreStringsEqual<I, O> extends true
80
+ ? never
81
+ : void;
82
+
83
+ function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
84
+ if (input === output) {
85
+ process.exit(0);
86
+ }
87
+ }
88
+
89
+ endIfEqual('abc', 'abc');
90
+ //=> never
91
+
92
+ endIfEqual('abc', '123');
93
+ //=> void
94
+ ```
95
+
96
+ @group type-fest
97
+ */
98
+ type IsNever<T> = [T] extends [never] ? true : false;
99
+ //#endregion
100
+ //#region src/types/type-fest/if-never.d.ts
101
+ /**
102
+ An if-else-like type that resolves depending on whether the given type is `never`.
103
+
104
+ @see {@link IsNever}
105
+
106
+ @example
107
+ ```
108
+ import type {IfNever} from 'type-fest';
109
+
110
+ type ShouldBeTrue = IfNever<never>;
111
+ //=> true
112
+
113
+ type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
114
+ //=> 'bar'
115
+ ```
116
+
117
+ @group type-fest
118
+ */
119
+ type IfNever$1<T, TypeIfNever = true, TypeIfNotNever = false> = (IsNever<T> extends true ? TypeIfNever : TypeIfNotNever);
120
+ //#endregion
121
+ //#region src/types/type-fest/unknown-array.d.ts
122
+ /**
123
+ Represents an array with `unknown` value.
124
+
125
+ Use case: You want a type that all arrays can be assigned to, but you don't care about the value.
126
+
127
+ @example
128
+ ```
129
+ import type {UnknownArray} from 'type-fest';
130
+
131
+ type IsArray<T> = T extends UnknownArray ? true : false;
132
+
133
+ type A = IsArray<['foo']>;
134
+ //=> true
135
+
136
+ type B = IsArray<readonly number[]>;
137
+ //=> true
138
+
139
+ type C = IsArray<string>;
140
+ //=> false
141
+ ```
142
+
143
+ @group type-fest
144
+ */
145
+ type UnknownArray = readonly unknown[];
146
+ //#endregion
147
+ //#region src/types/type-fest/internal/array.d.ts
148
+
149
+ /**
150
+ Returns whether the given array `T` is readonly.
151
+
152
+ @group type-fest
153
+ */
154
+ type IsArrayReadonly<T extends UnknownArray> = IfNever$1<T, false, T extends unknown[] ? false : true>;
155
+ /**
156
+ An if-else-like type that resolves depending on whether the given array is readonly.
157
+
158
+ @see {@link IsArrayReadonly}
159
+
160
+ @example
161
+ ```
162
+ import type {ArrayTail} from 'type-fest';
163
+
164
+ type ReadonlyPreservingArrayTail<TArray extends readonly unknown[]> =
165
+ ArrayTail<TArray> extends infer Tail
166
+ ? IfArrayReadonly<TArray, Readonly<Tail>, Tail>
167
+ : never;
168
+
169
+ type ReadonlyTail = ReadonlyPreservingArrayTail<readonly [string, number, boolean]>;
170
+ //=> readonly [number, boolean]
171
+
172
+ type NonReadonlyTail = ReadonlyPreservingArrayTail<[string, number, boolean]>;
173
+ //=> [number, boolean]
174
+
175
+ type ShouldBeTrue = IfArrayReadonly<readonly unknown[]>;
176
+ //=> true
177
+
178
+ type ShouldBeBar = IfArrayReadonly<unknown[], 'foo', 'bar'>;
179
+ //=> 'bar'
180
+ ```
181
+
182
+ @group type-fest
183
+ */
184
+ type IfArrayReadonly<T extends UnknownArray, TypeIfArrayReadonly = true, TypeIfNotArrayReadonly = false> = IsArrayReadonly<T> extends infer Result ? Result extends true ? TypeIfArrayReadonly : TypeIfNotArrayReadonly : never;
185
+ //#endregion
186
+ //#region src/types/type-fest/internal/characters.d.ts
187
+ /**
188
+ @group type-fest
189
+ */
190
+ type Whitespace = " " | "\n" | "\v" | "\f" | "\r" | " " | "…" | "\xA0" | " " | " " | " " | " " | " " | " " | " " | " " | " " | " " | " " | " " | "\u2028" | "\u2029" | " " | " " | " " | "";
191
+ //#endregion
192
+ //#region src/types/type-fest/is-any.d.ts
193
+ type NoInfer<T> = T extends infer U ? U : never;
194
+ /**
195
+ Returns a boolean for whether the given type is `any`.
196
+
197
+ @link https://stackoverflow.com/a/49928360/1490091
198
+
199
+ Useful in type utilities, such as disallowing `any`s to be passed to a function.
200
+
201
+ @example
202
+ ```
203
+ import type {IsAny} from 'type-fest';
204
+
205
+ const typedObject = {a: 1, b: 2} as const;
206
+ const anyObject: any = {a: 1, b: 2};
207
+
208
+ function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(obj: O, key: K) {
209
+ return obj[key];
210
+ }
211
+
212
+ const typedA = get(typedObject, 'a');
213
+ //=> 1
214
+
215
+ const anyA = get(anyObject, 'a');
216
+ //=> any
217
+ ```
218
+
219
+ @group type-fest
220
+ */
221
+ type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
222
+ //#endregion
223
+ //#region src/types/type-fest/primitive.d.ts
224
+ /**
225
+ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
226
+
227
+ @group type-fest
228
+ */
229
+ type Primitive = null | undefined | string | number | boolean | symbol | bigint;
230
+ //#endregion
231
+ //#region src/types/type-fest/is-float.d.ts
232
+ /**
233
+ Returns a boolean for whether the given number is a float, like `1.5` or `-1.5`.
234
+
235
+ Use-case:
236
+ - If you want to make a conditional branch based on the result of whether a number is a float or not.
237
+
238
+ @example
239
+ ```
240
+ import type {IsFloat, PositiveInfinity} from "type-fest";
241
+
242
+ type A = IsFloat<1.5>;
243
+ //=> true
244
+
245
+ type B = IsFloat<-1.5>;
246
+ //=> true
247
+
248
+ type C = IsFloat<1e-7>;
249
+ //=> true
250
+
251
+ type D = IsFloat<1.0>;
252
+ //=> false
253
+
254
+ type E = IsFloat<PositiveInfinity>;
255
+ //=> false
256
+
257
+ type F = IsFloat<1.23e+21>;
258
+ //=> false
259
+ ```
260
+
261
+ @group type-fest
262
+ */
263
+ type IsFloat<T> = T extends number ? `${T}` extends `${number}e${infer E extends "-" | "+"}${number}` ? E extends "-" ? true : false : `${T}` extends `${number}.${number}` ? true : false : false;
264
+ //#endregion
265
+ //#region src/types/type-fest/is-integer.d.ts
266
+ /**
267
+ Returns a boolean for whether the given number is an integer, like `-5`, `1.0`, or `100`.
268
+
269
+ Use-case:
270
+ - If you want to make a conditional branch based on the result of whether a number is an integer or not.
271
+
272
+ @example
273
+ ```
274
+ import type {IsInteger, PositiveInfinity} from "type-fest";
275
+
276
+ type A = IsInteger<1>;
277
+ //=> true
278
+
279
+ type B = IsInteger<1.0>;
280
+ //=> true
281
+
282
+ type C = IsInteger<-1>;
283
+ //=> true
284
+
285
+ type D = IsInteger<0b10>;
286
+ //=> true
287
+
288
+ type E = IsInteger<0o10>;
289
+ //=> true
290
+
291
+ type F = IsInteger<0x10>;
292
+ //=> true
293
+
294
+ type G = IsInteger<1.23+21>;
295
+ //=> true
296
+
297
+ type H = IsInteger<1.5>;
298
+ //=> false
299
+
300
+ type I = IsInteger<PositiveInfinity>;
301
+ //=> false
302
+
303
+ type J = IsInteger<1e-7>;
304
+ //=> false
305
+ ```
306
+
307
+ @group type-fest
308
+ */
309
+ type IsInteger<T> = T extends bigint ? true : T extends number ? number extends T ? false : T extends PositiveInfinity | NegativeInfinity ? false : Not<IsFloat<T>> : false;
310
+ //#endregion
311
+ //#region src/types/type-fest/numeric.d.ts
312
+ /**
313
+ @group type-fest
314
+ */
315
+ type Numeric = number | bigint;
316
+ /**
317
+ @group type-fest
318
+ */
319
+ type Zero = 0 | 0n;
320
+ /**
321
+ Matches the hidden `Infinity` type.
322
+
323
+ Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277) if you want to have this type as a built-in in TypeScript.
324
+
325
+ @see NegativeInfinity
326
+
327
+ @group type-fest
328
+ */
329
+ type PositiveInfinity = 1e999;
330
+ /**
331
+ Matches the hidden `-Infinity` type.
332
+
333
+ Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277) if you want to have this type as a built-in in TypeScript.
334
+
335
+ @see PositiveInfinity
336
+
337
+ @group type-fest
338
+ */
339
+ type NegativeInfinity = -1e999;
340
+ /**
341
+ A finite `number`.
342
+ You can't pass a `bigint` as they are already guaranteed to be finite.
343
+
344
+ Use-case: Validating and documenting parameters.
345
+
346
+ Note: This can't detect `NaN`, please upvote [this issue](https://github.com/microsoft/TypeScript/issues/28682) if you want to have this type as a built-in in TypeScript.
347
+
348
+ @example
349
+ ```
350
+ import type {Finite} from 'type-fest';
351
+
352
+ declare function setScore<T extends number>(length: Finite<T>): void;
353
+ ```
354
+
355
+ @group type-fest
356
+ */
357
+ type Finite<T extends number> = T extends PositiveInfinity | NegativeInfinity ? never : T;
358
+ /**
359
+ A `number` that is an integer.
360
+
361
+ Use-case: Validating and documenting parameters.
362
+
363
+ @example
364
+ ```
365
+ type Integer = Integer<1>;
366
+ //=> 1
367
+
368
+ type IntegerWithDecimal = Integer<1.0>;
369
+ //=> 1
370
+
371
+ type NegativeInteger = Integer<-1>;
372
+ //=> -1
373
+
374
+ type Float = Integer<1.5>;
375
+ //=> never
376
+
377
+ // Supports non-decimal numbers
378
+
379
+ type OctalInteger: Integer<0o10>;
380
+ //=> 0o10
381
+
382
+ type BinaryInteger: Integer<0b10>;
383
+ //=> 0b10
384
+
385
+ type HexadecimalInteger: Integer<0x10>;
386
+ //=> 0x10
387
+ ```
388
+
389
+ @example
390
+ ```
391
+ import type {Integer} from 'type-fest';
392
+
393
+ declare function setYear<T extends number>(length: Integer<T>): void;
394
+ ```
395
+
396
+ @see NegativeInteger
397
+ @see NonNegativeInteger
398
+
399
+ @group type-fest
400
+ */
401
+ type Integer<T> = T extends unknown ? IsInteger<T> extends true ? T : never : never;
402
+ /**
403
+ A `number` that is not an integer.
404
+
405
+ Use-case: Validating and documenting parameters.
406
+
407
+ It does not accept `Infinity`.
408
+
409
+ @example
410
+ ```
411
+ import type {Float} from 'type-fest';
412
+
413
+ declare function setPercentage<T extends number>(length: Float<T>): void;
414
+ ```
415
+
416
+ @see Integer
417
+
418
+ @group type-fest
419
+ */
420
+ type Float<T> = T extends unknown ? IsFloat<T> extends true ? T : never : never;
421
+ /**
422
+ A negative (`-∞ < x < 0`) `number` that is not an integer.
423
+ Equivalent to `Negative<Float<T>>`.
424
+
425
+ Use-case: Validating and documenting parameters.
426
+
427
+ @see Negative
428
+ @see Float
429
+
430
+ @group type-fest
431
+ */
432
+ type NegativeFloat<T extends number> = Negative<Float<T>>;
433
+ /**
434
+ A negative `number`/`bigint` (`-∞ < x < 0`)
435
+
436
+ Use-case: Validating and documenting parameters.
437
+
438
+ @see NegativeInteger
439
+ @see NonNegative
440
+
441
+ @group type-fest
442
+ */
443
+ type Negative<T extends Numeric> = T extends Zero ? never : `${T}` extends `-${string}` ? T : never;
444
+ /**
445
+ A negative (`-∞ < x < 0`) `number` that is an integer.
446
+ Equivalent to `Negative<Integer<T>>`.
447
+
448
+ You can't pass a `bigint` as they are already guaranteed to be integers, instead use `Negative<T>`.
449
+
450
+ Use-case: Validating and documenting parameters.
451
+
452
+ @see Negative
453
+ @see Integer
454
+
455
+ @group type-fest
456
+ */
457
+ type NegativeInteger<T extends number> = Negative<Integer<T>>;
458
+ /**
459
+ A non-negative `number`/`bigint` (`0 <= x < ∞`).
460
+
461
+ Use-case: Validating and documenting parameters.
462
+
463
+ @see NonNegativeInteger
464
+ @see Negative
465
+
466
+ @example
467
+ ```
468
+ import type {NonNegative} from 'type-fest';
469
+
470
+ declare function setLength<T extends number>(length: NonNegative<T>): void;
471
+ ```
472
+
473
+ @group type-fest
474
+ */
475
+ type NonNegative<T extends Numeric> = T extends Zero ? T : Negative<T> extends never ? T : never;
476
+ /**
477
+ A non-negative (`0 <= x < ∞`) `number` that is an integer.
478
+ Equivalent to `NonNegative<Integer<T>>`.
479
+
480
+ You can't pass a `bigint` as they are already guaranteed to be integers, instead use `NonNegative<T>`.
481
+
482
+ Use-case: Validating and documenting parameters.
483
+
484
+ @see NonNegative
485
+ @see Integer
486
+
487
+ @example
488
+ ```
489
+ import type {NonNegativeInteger} from 'type-fest';
490
+
491
+ declare function setLength<T extends number>(length: NonNegativeInteger<T>): void;
492
+ ```
493
+
494
+ @group type-fest
495
+ */
496
+ type NonNegativeInteger<T extends number> = NonNegative<Integer<T>>;
497
+ /**
498
+ Returns a boolean for whether the given number is a negative number.
499
+
500
+ @see Negative
501
+
502
+ @example
503
+ ```
504
+ import type {IsNegative} from 'type-fest';
505
+
506
+ type ShouldBeFalse = IsNegative<1>;
507
+ type ShouldBeTrue = IsNegative<-1>;
508
+ ```
509
+
510
+ @group type-fest
511
+ */
512
+ type IsNegative<T extends Numeric> = T extends Negative<T> ? true : false;
513
+ //#endregion
514
+ //#region src/types/type-fest/is-literal.d.ts
515
+ /**
516
+ Returns a boolean for whether the given type `T` is the specified `LiteralType`.
517
+
518
+ @link https://stackoverflow.com/a/52806744/10292952
519
+
520
+ @example
521
+ ```
522
+ LiteralCheck<1, number>
523
+ //=> true
524
+
525
+ LiteralCheck<number, number>
526
+ //=> false
527
+
528
+ LiteralCheck<1, string>
529
+ //=> false
530
+ ```
531
+ */
532
+ type LiteralCheck<T, LiteralType extends Primitive> = (IsNever<T> extends false ? [T] extends [LiteralType & infer U] ? [U] extends [LiteralType] ? [LiteralType] extends [U] ? false : true : false : false : false);
533
+ /**
534
+ Returns a boolean for whether the given type `T` is one of the specified literal types in `LiteralUnionType`.
535
+
536
+ @example
537
+ ```
538
+ LiteralChecks<1, Numeric>
539
+ //=> true
540
+
541
+ LiteralChecks<1n, Numeric>
542
+ //=> true
543
+
544
+ LiteralChecks<bigint, Numeric>
545
+ //=> false
546
+ ```
547
+ */
548
+ type LiteralChecks<T, LiteralUnionType> = (IsNotFalse<LiteralUnionType extends Primitive ? LiteralCheck<T, LiteralUnionType> : never>);
549
+ /**
550
+ Returns a boolean for whether the given type is a `string` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
551
+
552
+ Useful for:
553
+ - providing strongly-typed string manipulation functions
554
+ - constraining strings to be a string literal
555
+ - type utilities, such as when constructing parsers and ASTs
556
+
557
+ The implementation of this type is inspired by the trick mentioned in this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
558
+
559
+ @example
560
+ ```
561
+ import type {IsStringLiteral} from 'type-fest';
562
+
563
+ type CapitalizedString<T extends string> = IsStringLiteral<T> extends true ? Capitalize<T> : string;
564
+
565
+ // https://github.com/yankeeinlondon/native-dash/blob/master/src/capitalize.ts
566
+ function capitalize<T extends Readonly<string>>(input: T): CapitalizedString<T> {
567
+ return (input.slice(0, 1).toUpperCase() + input.slice(1)) as CapitalizedString<T>;
568
+ }
569
+
570
+ const output = capitalize('hello, world!');
571
+ //=> 'Hello, world!'
572
+ ```
573
+
574
+ @example
575
+ ```
576
+ // String types with infinite set of possible values return `false`.
577
+
578
+ import type {IsStringLiteral} from 'type-fest';
579
+
580
+ type AllUppercaseStrings = IsStringLiteral<Uppercase<string>>;
581
+ //=> false
582
+
583
+ type StringsStartingWithOn = IsStringLiteral<`on${string}`>;
584
+ //=> false
585
+
586
+ // This behaviour is particularly useful in string manipulation utilities, as infinite string types often require separate handling.
587
+
588
+ type Length<S extends string, Counter extends never[] = []> =
589
+ IsStringLiteral<S> extends false
590
+ ? number // return `number` for infinite string types
591
+ : S extends `${string}${infer Tail}`
592
+ ? Length<Tail, [...Counter, never]>
593
+ : Counter['length'];
594
+
595
+ type L1 = Length<Lowercase<string>>;
596
+ //=> number
597
+
598
+ type L2 = Length<`${number}`>;
599
+ //=> number
600
+ ```
601
+
602
+ @group type-fest
603
+ */
604
+ type IsStringLiteral<T> = IfNever$1<T, false, T extends string ? {} extends Record<T, never> ? false : true : false>;
605
+ /**
606
+ Returns a boolean for whether the given type is a `number` or `bigint` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
607
+
608
+ Useful for:
609
+ - providing strongly-typed functions when given literal arguments
610
+ - type utilities, such as when constructing parsers and ASTs
611
+
612
+ @example
613
+ ```
614
+ import type {IsNumericLiteral} from 'type-fest';
615
+
616
+ // https://github.com/inocan-group/inferred-types/blob/master/src/types/boolean-logic/EndsWith.ts
617
+ type EndsWith<TValue, TEndsWith extends string> =
618
+ TValue extends string
619
+ ? IsStringLiteral<TEndsWith> extends true
620
+ ? IsStringLiteral<TValue> extends true
621
+ ? TValue extends `${string}${TEndsWith}`
622
+ ? true
623
+ : false
624
+ : boolean
625
+ : boolean
626
+ : TValue extends number
627
+ ? IsNumericLiteral<TValue> extends true
628
+ ? EndsWith<`${TValue}`, TEndsWith>
629
+ : false
630
+ : false;
631
+
632
+ function endsWith<Input extends string | number, End extends string>(input: Input, end: End) {
633
+ return `${input}`.endsWith(end) as EndsWith<Input, End>;
634
+ }
635
+
636
+ endsWith('abc', 'c');
637
+ //=> true
638
+
639
+ endsWith(123456, '456');
640
+ //=> true
641
+
642
+ const end = '123' as string;
643
+
644
+ endsWith('abc123', end);
645
+ //=> boolean
646
+ ```
647
+
648
+ @group type-fest
649
+ */
650
+ type IsNumericLiteral<T> = LiteralChecks<T, Numeric>;
651
+ /**
652
+ Returns a boolean for whether the given type is a `true` or `false` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
653
+
654
+ Useful for:
655
+ - providing strongly-typed functions when given literal arguments
656
+ - type utilities, such as when constructing parsers and ASTs
657
+
658
+ @example
659
+ ```
660
+ import type {IsBooleanLiteral} from 'type-fest';
661
+
662
+ const id = 123;
663
+
664
+ type GetId<AsString extends boolean> =
665
+ IsBooleanLiteral<AsString> extends true
666
+ ? AsString extends true
667
+ ? `${typeof id}`
668
+ : typeof id
669
+ : number | string;
670
+
671
+ function getId<AsString extends boolean = false>(options?: {asString: AsString}) {
672
+ return (options?.asString ? `${id}` : id) as GetId<AsString>;
673
+ }
674
+
675
+ const numberId = getId();
676
+ //=> 123
677
+
678
+ const stringId = getId({asString: true});
679
+ //=> '123'
680
+
681
+ declare const runtimeBoolean: boolean;
682
+ const eitherId = getId({asString: runtimeBoolean});
683
+ //=> number | string
684
+ ```
685
+
686
+ @group type-fest
687
+ */
688
+ type IsBooleanLiteral<T> = LiteralCheck<T, boolean>;
689
+ /**
690
+ Returns a boolean for whether the given type is a `symbol` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
691
+
692
+ Useful for:
693
+ - providing strongly-typed functions when given literal arguments
694
+ - type utilities, such as when constructing parsers and ASTs
695
+
696
+ @example
697
+ ```
698
+ import type {IsSymbolLiteral} from 'type-fest';
699
+
700
+ type Get<Obj extends Record<symbol, number>, Key extends keyof Obj> =
701
+ IsSymbolLiteral<Key> extends true
702
+ ? Obj[Key]
703
+ : number;
704
+
705
+ function get<Obj extends Record<symbol, number>, Key extends keyof Obj>(o: Obj, key: Key) {
706
+ return o[key] as Get<Obj, Key>;
707
+ }
708
+
709
+ const symbolLiteral = Symbol('literal');
710
+ const symbolValue: symbol = Symbol('value');
711
+
712
+ get({[symbolLiteral]: 1} as const, symbolLiteral);
713
+ //=> 1
714
+
715
+ get({[symbolValue]: 1} as const, symbolValue);
716
+ //=> number
717
+ ```
718
+
719
+ @group type-fest
720
+ */
721
+ type IsSymbolLiteral<T> = LiteralCheck<T, symbol>;
722
+ /** Helper type for `IsLiteral`. */
723
+ type IsLiteralUnion<T> = IsStringLiteral<T> | IsNumericLiteral<T> | IsBooleanLiteral<T> | IsSymbolLiteral<T>;
724
+ /**
725
+ Returns a boolean for whether the given type is a [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
726
+
727
+ Useful for:
728
+ - providing strongly-typed functions when given literal arguments
729
+ - type utilities, such as when constructing parsers and ASTs
730
+
731
+ @example
732
+ ```
733
+ import type {IsLiteral} from 'type-fest';
734
+
735
+ // https://github.com/inocan-group/inferred-types/blob/master/src/types/string-literals/StripLeading.ts
736
+ export type StripLeading<A, B> =
737
+ A extends string
738
+ ? B extends string
739
+ ? IsLiteral<A> extends true
740
+ ? string extends B ? never : A extends `${B & string}${infer After}` ? After : A
741
+ : string
742
+ : A
743
+ : A;
744
+
745
+ function stripLeading<Input extends string, Strip extends string>(input: Input, strip: Strip) {
746
+ return input.replace(`^${strip}`, '') as StripLeading<Input, Strip>;
747
+ }
748
+
749
+ stripLeading('abc123', 'abc');
750
+ //=> '123'
751
+
752
+ const str = 'abc123' as string;
753
+
754
+ stripLeading(str, 'abc');
755
+ //=> string
756
+ ```
757
+
758
+ @group type-fest
759
+ */
760
+ type IsLiteral<T> = IsPrimitive<T> extends true ? IsNotFalse<IsLiteralUnion<T>> : false;
761
+ //#endregion
762
+ //#region src/types/type-fest/trim.d.ts
763
+ /**
764
+ Remove spaces from the left side.
765
+ */
766
+ type TrimLeft<V extends string> = V extends `${Whitespace}${infer R}` ? TrimLeft<R> : V;
767
+ /**
768
+ Remove spaces from the right side.
769
+ */
770
+ type TrimRight<V extends string> = V extends `${infer R}${Whitespace}` ? TrimRight<R> : V;
771
+ /**
772
+ Remove leading and trailing spaces from a string.
773
+
774
+ @example
775
+ ```
776
+ import type {Trim} from 'type-fest';
777
+
778
+ Trim<' foo '>
779
+ //=> 'foo'
780
+ ```
781
+
782
+ @group type-fest
783
+ */
784
+ type Trim<V extends string> = TrimLeft<TrimRight<V>>;
785
+ //#endregion
786
+ //#region src/types/type-fest/or.d.ts
787
+ /**
788
+ Returns a boolean for whether either of two given types are true.
789
+
790
+ Use-case: Constructing complex conditional types where multiple conditions must be satisfied.
791
+
792
+ @example
793
+ ```
794
+ import type {Or} from 'type-fest';
795
+
796
+ Or<true, false>;
797
+ //=> true
798
+
799
+ Or<false, false>;
800
+ //=> false
801
+ ```
802
+
803
+ @see {@link And}
804
+
805
+ @group type-fest
806
+ */
807
+ type Or<A extends boolean, B extends boolean> = [A, B][number] extends false ? false : true extends [IsEqual<A, true>, IsEqual<B, true>][number] ? true : never;
808
+ //#endregion
809
+ //#region src/types/type-fest/greater-than.d.ts
810
+ /**
811
+ Returns a boolean for whether a given number is greater than another number.
812
+
813
+ @example
814
+ ```
815
+ import type {GreaterThan} from 'type-fest';
816
+
817
+ GreaterThan<1, -5>;
818
+ //=> true
819
+
820
+ GreaterThan<1, 1>;
821
+ //=> false
822
+
823
+ GreaterThan<1, 5>;
824
+ //=> false
825
+ ```
826
+
827
+ @group type-fest
828
+ */
829
+ type GreaterThan<A extends number, B extends number> = A extends number ? B extends number ? number extends A | B ? never : [IsEqual<A, PositiveInfinity>, IsEqual<A, NegativeInfinity>, IsEqual<B, PositiveInfinity>, IsEqual<B, NegativeInfinity>] extends infer R extends [boolean, boolean, boolean, boolean] ? Or<And<IsEqual<R[0], true>, IsEqual<R[2], false>>, And<IsEqual<R[3], true>, IsEqual<R[1], false>>> extends true ? true : Or<And<IsEqual<R[1], true>, IsEqual<R[3], false>>, And<IsEqual<R[2], true>, IsEqual<R[0], false>>> extends true ? false : true extends R[number] ? false : [IsNegative<A>, IsNegative<B>] extends infer R extends [boolean, boolean] ? [true, false] extends R ? false : [false, true] extends R ? true : [false, false] extends R ? PositiveNumericStringGt<`${A}`, `${B}`> : PositiveNumericStringGt<`${NumberAbsolute<B>}`, `${NumberAbsolute<A>}`> : never : never : never : never;
830
+ //#endregion
831
+ //#region src/types/type-fest/greater-than-or-equal.d.ts
832
+ /**
833
+ Returns a boolean for whether a given number is greater than or equal to another number.
834
+
835
+ @example
836
+ ```
837
+ import type {GreaterThanOrEqual} from 'type-fest';
838
+
839
+ GreaterThanOrEqual<1, -5>;
840
+ //=> true
841
+
842
+ GreaterThanOrEqual<1, 1>;
843
+ //=> true
844
+
845
+ GreaterThanOrEqual<1, 5>;
846
+ //=> false
847
+ ```
848
+
849
+ @group type-fest
850
+ */
851
+ type GreaterThanOrEqual<A extends number, B extends number> = number extends A | B ? never : A extends B ? true : GreaterThan<A, B>;
852
+ //#endregion
853
+ //#region src/types/type-fest/less-than.d.ts
854
+ /**
855
+ Returns a boolean for whether a given number is less than another number.
856
+
857
+ @example
858
+ ```
859
+ import type {LessThan} from 'type-fest';
860
+
861
+ LessThan<1, -5>;
862
+ //=> false
863
+
864
+ LessThan<1, 1>;
865
+ //=> false
866
+
867
+ LessThan<1, 5>;
868
+ //=> true
869
+ ```
870
+
871
+ @group type-fest
872
+ */
873
+ type LessThan<A extends number, B extends number> = number extends A | B ? never : GreaterThanOrEqual<A, B> extends infer Result ? Result extends true ? false : true : never;
874
+ //#endregion
875
+ //#region src/types/type-fest/internal/tuple.d.ts
876
+ /**
877
+ Create a tuple type of the given length `<L>` and fill it with the given type `<Fill>`.
878
+
879
+ If `<Fill>` is not provided, it will default to `unknown`.
880
+
881
+ @link https://itnext.io/implementing-arithmetic-within-typescripts-type-system-a1ef140a6f6f
882
+
883
+ @group type-fest
884
+ */
885
+ type BuildTuple<L extends number, Fill = unknown, T extends readonly unknown[] = []> = number extends L ? Fill[] : L extends T["length"] ? T : BuildTuple<L, Fill, [...T, Fill]>;
886
+ //#endregion
887
+ //#region src/types/type-fest/internal/string.d.ts
888
+ /**
889
+ Converts a numeric string to a number.
890
+
891
+ @example
892
+ ```
893
+ type PositiveInt = StringToNumber<'1234'>;
894
+ //=> 1234
895
+
896
+ type NegativeInt = StringToNumber<'-1234'>;
897
+ //=> -1234
898
+
899
+ type PositiveFloat = StringToNumber<'1234.56'>;
900
+ //=> 1234.56
901
+
902
+ type NegativeFloat = StringToNumber<'-1234.56'>;
903
+ //=> -1234.56
904
+
905
+ type PositiveInfinity = StringToNumber<'Infinity'>;
906
+ //=> Infinity
907
+
908
+ type NegativeInfinity = StringToNumber<'-Infinity'>;
909
+ //=> -Infinity
910
+ ```
911
+
912
+ @group type-fest
913
+ */
914
+ type StringToNumber<S extends string> = S extends `${infer N extends number}` ? N : S extends "Infinity" ? PositiveInfinity : S extends "-Infinity" ? NegativeInfinity : never;
915
+ /**
916
+ Returns an array of the characters of the string.
917
+
918
+ @example
919
+ ```
920
+ StringToArray<'abcde'>;
921
+ //=> ['a', 'b', 'c', 'd', 'e']
922
+
923
+ StringToArray<string>;
924
+ //=> never
925
+ ```
926
+
927
+ @group type-fest
928
+ */
929
+ type StringToArray<S extends string, Result extends string[] = []> = string extends S ? never : S extends `${infer F}${infer R}` ? StringToArray<R, [...Result, F]> : Result;
930
+ /**
931
+ Returns the length of the given string.
932
+
933
+ @example
934
+ ```
935
+ StringLength<'abcde'>;
936
+ //=> 5
937
+
938
+ StringLength<string>;
939
+ //=> never
940
+ ```
941
+
942
+ @group type-fest
943
+ */
944
+ type StringLength<S extends string> = string extends S ? never : StringToArray<S>["length"];
945
+ /**
946
+ Returns a boolean for whether `A` represents a number greater than `B`, where `A` and `B` are both numeric strings and have the same length.
947
+
948
+ @example
949
+ ```
950
+ SameLengthPositiveNumericStringGt<'50', '10'>;
951
+ //=> true
952
+
953
+ SameLengthPositiveNumericStringGt<'10', '10'>;
954
+ //=> false
955
+ ```
956
+ */
957
+ type SameLengthPositiveNumericStringGt<A extends string, B extends string> = A extends `${infer FirstA}${infer RestA}` ? B extends `${infer FirstB}${infer RestB}` ? FirstA extends FirstB ? SameLengthPositiveNumericStringGt<RestA, RestB> : PositiveNumericCharacterGt<FirstA, FirstB> : never : false;
958
+ type NumericString = "0123456789";
959
+ /**
960
+ Returns a boolean for whether `A` is greater than `B`, where `A` and `B` are both positive numeric strings.
961
+
962
+ @example
963
+ ```
964
+ PositiveNumericStringGt<'500', '1'>;
965
+ //=> true
966
+
967
+ PositiveNumericStringGt<'1', '1'>;
968
+ //=> false
969
+
970
+ PositiveNumericStringGt<'1', '500'>;
971
+ //=> false
972
+ ```
973
+
974
+ @group type-fest
975
+ */
976
+ type PositiveNumericStringGt<A extends string, B extends string> = A extends B ? false : [BuildTuple<StringLength<A>, 0>, BuildTuple<StringLength<B>, 0>] extends infer R extends [readonly unknown[], readonly unknown[]] ? R[0] extends [...R[1], ...infer Remain extends readonly unknown[]] ? 0 extends Remain["length"] ? SameLengthPositiveNumericStringGt<A, B> : true : false : never;
977
+ /**
978
+ Returns a boolean for whether `A` represents a number greater than `B`, where `A` and `B` are both positive numeric characters.
979
+
980
+ @example
981
+ ```
982
+ PositiveNumericCharacterGt<'5', '1'>;
983
+ //=> true
984
+
985
+ PositiveNumericCharacterGt<'1', '1'>;
986
+ //=> false
987
+ ```
988
+ */
989
+ type PositiveNumericCharacterGt<A extends string, B extends string> = NumericString extends `${infer HeadA}${A}${infer TailA}` ? NumericString extends `${infer HeadB}${B}${infer TailB}` ? HeadA extends `${HeadB}${infer _}${infer __}` ? true : false : never : never;
990
+ //#endregion
991
+ //#region src/types/type-fest/internal/numeric.d.ts
992
+ /**
993
+ Returns the absolute value of a given value.
994
+
995
+ @example
996
+ ```
997
+ NumberAbsolute<-1>;
998
+ //=> 1
999
+
1000
+ NumberAbsolute<1>;
1001
+ //=> 1
1002
+
1003
+ NumberAbsolute<NegativeInfinity>
1004
+ //=> PositiveInfinity
1005
+ ```
1006
+
1007
+ @group type-fest
1008
+ */
1009
+ type NumberAbsolute<N extends number> = `${N}` extends `-${infer StringPositiveN}` ? StringToNumber<StringPositiveN> : N;
1010
+ //#endregion
1011
+ //#region src/types/type-fest/simplify.d.ts
1012
+ /**
1013
+ Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
1014
+
1015
+ @example
1016
+ ```
1017
+ import type {Simplify} from 'type-fest';
1018
+
1019
+ type PositionProps = {
1020
+ top: number;
1021
+ left: number;
1022
+ };
1023
+
1024
+ type SizeProps = {
1025
+ width: number;
1026
+ height: number;
1027
+ };
1028
+
1029
+ // In your editor, hovering over `Props` will show a flattened object with all the properties.
1030
+ type Props = Simplify<PositionProps & SizeProps>;
1031
+ ```
1032
+
1033
+ Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
1034
+
1035
+ If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
1036
+
1037
+ @example
1038
+ ```
1039
+ import type {Simplify} from 'type-fest';
1040
+
1041
+ interface SomeInterface {
1042
+ foo: number;
1043
+ bar?: string;
1044
+ baz: number | undefined;
1045
+ }
1046
+
1047
+ type SomeType = {
1048
+ foo: number;
1049
+ bar?: string;
1050
+ baz: number | undefined;
1051
+ };
1052
+
1053
+ const literal = {foo: 123, bar: 'hello', baz: 456};
1054
+ const someType: SomeType = literal;
1055
+ const someInterface: SomeInterface = literal;
1056
+
1057
+ function fn(object: Record<string, unknown>): void {}
1058
+
1059
+ fn(literal); // Good: literal object type is sealed
1060
+ fn(someType); // Good: type is sealed
1061
+ fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
1062
+ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
1063
+ ```
1064
+
1065
+ @link https://github.com/microsoft/TypeScript/issues/15300
1066
+ @see SimplifyDeep
1067
+
1068
+ @group type-fest
1069
+ */
1070
+ type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
1071
+ //#endregion
1072
+ //#region src/types/type-fest/union-to-intersection.d.ts
1073
+ /**
1074
+ Convert a union type to an intersection type using [distributive conditional types](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
1075
+
1076
+ Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
1077
+
1078
+ @example
1079
+ ```
1080
+ import type {UnionToIntersection} from 'type-fest';
1081
+
1082
+ type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
1083
+
1084
+ type Intersection = UnionToIntersection<Union>;
1085
+ //=> {the(): void; great(arg: string): void; escape: boolean};
1086
+ ```
1087
+
1088
+ A more applicable example which could make its way into your library code follows.
1089
+
1090
+ @example
1091
+ ```
1092
+ import type {UnionToIntersection} from 'type-fest';
1093
+
1094
+ class CommandOne {
1095
+ commands: {
1096
+ a1: () => undefined,
1097
+ b1: () => undefined,
1098
+ }
1099
+ }
1100
+
1101
+ class CommandTwo {
1102
+ commands: {
1103
+ a2: (argA: string) => undefined,
1104
+ b2: (argB: string) => undefined,
1105
+ }
1106
+ }
1107
+
1108
+ const union = [new CommandOne(), new CommandTwo()].map(instance => instance.commands);
1109
+ type Union = typeof union;
1110
+ //=> {a1(): void; b1(): void} | {a2(argA: string): void; b2(argB: string): void}
1111
+
1112
+ type Intersection = UnionToIntersection<Union>;
1113
+ //=> {a1(): void; b1(): void; a2(argA: string): void; b2(argB: string): void}
1114
+ ```
1115
+
1116
+ @group type-fest
1117
+ */
1118
+ type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends ((mergedIntersection: infer Intersection) => void) ? Intersection & Union : never;
1119
+ //#endregion
1120
+ //#region src/types/type-fest/keys-of-union.d.ts
1121
+ /**
1122
+ Create a union of all keys from a given type, even those exclusive to specific union members.
1123
+
1124
+ Unlike the native `keyof` keyword, which returns keys present in **all** union members, this type returns keys from **any** member.
1125
+
1126
+ @link https://stackoverflow.com/a/49402091
1127
+
1128
+ @example
1129
+ ```
1130
+ import type {KeysOfUnion} from 'type-fest';
1131
+
1132
+ type A = {
1133
+ common: string;
1134
+ a: number;
1135
+ };
1136
+
1137
+ type B = {
1138
+ common: string;
1139
+ b: string;
1140
+ };
1141
+
1142
+ type C = {
1143
+ common: string;
1144
+ c: boolean;
1145
+ };
1146
+
1147
+ type Union = A | B | C;
1148
+
1149
+ type CommonKeys = keyof Union;
1150
+ //=> 'common'
1151
+
1152
+ type AllKeys = KeysOfUnion<Union>;
1153
+ //=> 'common' | 'a' | 'b' | 'c'
1154
+ ```
1155
+
1156
+ @group type-fest
1157
+ */
1158
+ type KeysOfUnion<ObjectType> = keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
1159
+ //#endregion
1160
+ //#region src/types/type-fest/optional-keys-of.d.ts
1161
+ /**
1162
+ Extract all optional keys from the given type.
1163
+
1164
+ This is useful when you want to create a new type that contains different type values for the optional keys only.
1165
+
1166
+ @example
1167
+ ```
1168
+ import type {OptionalKeysOf, Except} from 'type-fest';
1169
+
1170
+ interface User {
1171
+ name: string;
1172
+ surname: string;
1173
+
1174
+ luckyNumber?: number;
1175
+ }
1176
+
1177
+ const REMOVE_FIELD = Symbol('remove field symbol');
1178
+ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
1179
+ [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
1180
+ };
1181
+
1182
+ const update1: UpdateOperation<User> = {
1183
+ name: 'Alice'
1184
+ };
1185
+
1186
+ const update2: UpdateOperation<User> = {
1187
+ name: 'Bob',
1188
+ luckyNumber: REMOVE_FIELD
1189
+ };
1190
+ ```
1191
+
1192
+ @group type-fest
1193
+ */
1194
+ type OptionalKeysOf<BaseType extends object> = BaseType extends unknown ? (keyof { [Key in keyof BaseType as BaseType extends Record<Key, BaseType[Key]> ? never : Key]: never }) & (keyof BaseType) : never;
1195
+ //#endregion
1196
+ //#region src/types/type-fest/required-keys-of.d.ts
1197
+ /**
1198
+ Extract all required keys from the given type.
1199
+
1200
+ This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...
1201
+
1202
+ @example
1203
+ ```
1204
+ import type {RequiredKeysOf} from 'type-fest';
1205
+
1206
+ declare function createValidation<Entity extends object, Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>>(field: Key, validator: (value: Entity[Key]) => boolean): ValidatorFn;
1207
+
1208
+ interface User {
1209
+ name: string;
1210
+ surname: string;
1211
+
1212
+ luckyNumber?: number;
1213
+ }
1214
+
1215
+ const validator1 = createValidation<User>('name', value => value.length < 25);
1216
+ const validator2 = createValidation<User>('surname', value => value.length < 25);
1217
+ ```
1218
+
1219
+ @group type-fest
1220
+ */
1221
+ type RequiredKeysOf<BaseType extends object> = BaseType extends unknown ? Exclude<keyof BaseType, OptionalKeysOf<BaseType>> : never;
1222
+ //#endregion
1223
+ //#region src/types/type-fest/omit-index-signature.d.ts
1224
+ /**
1225
+ Omit any index signatures from the given object type, leaving only explicitly defined properties.
1226
+
1227
+ This is the counterpart of `PickIndexSignature`.
1228
+
1229
+ Use-cases:
1230
+ - Remove overly permissive signatures from third-party types.
1231
+
1232
+ This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
1233
+
1234
+ It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
1235
+
1236
+ (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
1237
+
1238
+ ```
1239
+ const indexed: Record<string, unknown> = {}; // Allowed
1240
+
1241
+ const keyed: Record<'foo', unknown> = {}; // Error
1242
+ // => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
1243
+ ```
1244
+
1245
+ Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
1246
+
1247
+ ```
1248
+ type Indexed = {} extends Record<string, unknown>
1249
+ ? '✅ `{}` is assignable to `Record<string, unknown>`'
1250
+ : '❌ `{}` is NOT assignable to `Record<string, unknown>`';
1251
+ // => '✅ `{}` is assignable to `Record<string, unknown>`'
1252
+
1253
+ type Keyed = {} extends Record<'foo' | 'bar', unknown>
1254
+ ? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
1255
+ : "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
1256
+ // => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
1257
+ ```
1258
+
1259
+ Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
1260
+
1261
+ ```
1262
+ import type {OmitIndexSignature} from 'type-fest';
1263
+
1264
+ type OmitIndexSignature<ObjectType> = {
1265
+ [KeyType in keyof ObjectType // Map each key of `ObjectType`...
1266
+ ]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
1267
+ };
1268
+ ```
1269
+
1270
+ ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
1271
+
1272
+ ```
1273
+ import type {OmitIndexSignature} from 'type-fest';
1274
+
1275
+ type OmitIndexSignature<ObjectType> = {
1276
+ [KeyType in keyof ObjectType
1277
+ // Is `{}` assignable to `Record<KeyType, unknown>`?
1278
+ as {} extends Record<KeyType, unknown>
1279
+ ? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
1280
+ : ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
1281
+ ]: ObjectType[KeyType];
1282
+ };
1283
+ ```
1284
+
1285
+ If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
1286
+
1287
+ @example
1288
+ ```
1289
+ import type {OmitIndexSignature} from 'type-fest';
1290
+
1291
+ interface Example {
1292
+ // These index signatures will be removed.
1293
+ [x: string]: any
1294
+ [x: number]: any
1295
+ [x: symbol]: any
1296
+ [x: `head-${string}`]: string
1297
+ [x: `${string}-tail`]: string
1298
+ [x: `head-${string}-tail`]: string
1299
+ [x: `${bigint}`]: string
1300
+ [x: `embedded-${number}`]: string
1301
+
1302
+ // These explicitly defined keys will remain.
1303
+ foo: 'bar';
1304
+ qux?: 'baz';
1305
+ }
1306
+
1307
+ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
1308
+ // => { foo: 'bar'; qux?: 'baz' | undefined; }
1309
+ ```
1310
+
1311
+ @see PickIndexSignature
1312
+
1313
+ @group type-fest
1314
+ */
1315
+ type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
1316
+ //#endregion
1317
+ //#region src/types/type-fest/pick-index-signature.d.ts
1318
+ /**
1319
+ Pick only index signatures from the given object type, leaving out all explicitly defined properties.
1320
+
1321
+ This is the counterpart of `OmitIndexSignature`.
1322
+
1323
+ @example
1324
+ ```
1325
+ import type {PickIndexSignature} from 'type-fest';
1326
+
1327
+ declare const symbolKey: unique symbol;
1328
+
1329
+ type Example = {
1330
+ // These index signatures will remain.
1331
+ [x: string]: unknown;
1332
+ [x: number]: unknown;
1333
+ [x: symbol]: unknown;
1334
+ [x: `head-${string}`]: string;
1335
+ [x: `${string}-tail`]: string;
1336
+ [x: `head-${string}-tail`]: string;
1337
+ [x: `${bigint}`]: string;
1338
+ [x: `embedded-${number}`]: string;
1339
+
1340
+ // These explicitly defined keys will be removed.
1341
+ ['kebab-case-key']: string;
1342
+ [symbolKey]: string;
1343
+ foo: 'bar';
1344
+ qux?: 'baz';
1345
+ };
1346
+
1347
+ type ExampleIndexSignature = PickIndexSignature<Example>;
1348
+ // {
1349
+ // [x: string]: unknown;
1350
+ // [x: number]: unknown;
1351
+ // [x: symbol]: unknown;
1352
+ // [x: `head-${string}`]: string;
1353
+ // [x: `${string}-tail`]: string;
1354
+ // [x: `head-${string}-tail`]: string;
1355
+ // [x: `${bigint}`]: string;
1356
+ // [x: `embedded-${number}`]: string;
1357
+ // }
1358
+ ```
1359
+
1360
+ @see OmitIndexSignature
1361
+
1362
+ @group type-fest
1363
+ */
1364
+ type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
1365
+ //#endregion
1366
+ //#region src/types/type-fest/merge.d.ts
1367
+ type SimpleMerge<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source;
1368
+ /**
1369
+ Merge two types into a new type. Keys of the second type overrides keys of the first type.
1370
+
1371
+ @example
1372
+ ```
1373
+ import type {Merge} from 'type-fest';
1374
+
1375
+ interface Foo {
1376
+ [x: string]: unknown;
1377
+ [x: number]: unknown;
1378
+ foo: string;
1379
+ bar: symbol;
1380
+ }
1381
+
1382
+ type Bar = {
1383
+ [x: number]: number;
1384
+ [x: symbol]: unknown;
1385
+ bar: Date;
1386
+ baz: boolean;
1387
+ };
1388
+
1389
+ export type FooBar = Merge<Foo, Bar>;
1390
+ // => {
1391
+ // [x: string]: unknown;
1392
+ // [x: number]: number;
1393
+ // [x: symbol]: unknown;
1394
+ // foo: string;
1395
+ // bar: Date;
1396
+ // baz: boolean;
1397
+ // }
1398
+ ```
1399
+
1400
+ @group type-fest
1401
+ */
1402
+ type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
1403
+ //#endregion
1404
+ //#region src/types/type-fest/if-any.d.ts
1405
+ /**
1406
+ An if-else-like type that resolves depending on whether the given type is `any`.
1407
+
1408
+ @see {@link IsAny}
1409
+
1410
+ @example
1411
+ ```
1412
+ import type {IfAny} from 'type-fest';
1413
+
1414
+ type ShouldBeTrue = IfAny<any>;
1415
+ //=> true
1416
+
1417
+ type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
1418
+ //=> 'bar'
1419
+ ```
1420
+
1421
+ @group type-fest
1422
+ */
1423
+ type IfAny$1<T, TypeIfAny = true, TypeIfNotAny = false> = (IsAny<T> extends true ? TypeIfAny : TypeIfNotAny);
1424
+ //#endregion
1425
+ //#region src/types/type-fest/internal/type.d.ts
1426
+ /**
1427
+ Returns a boolean for whether the given `boolean` is not `false`.
1428
+
1429
+ @group type-fest
1430
+ */
1431
+ type IsNotFalse<T extends boolean> = [T] extends [false] ? false : true;
1432
+ /**
1433
+ Returns a boolean for whether the given type is primitive value or primitive type.
1434
+
1435
+ @example
1436
+ ```
1437
+ IsPrimitive<'string'>
1438
+ //=> true
1439
+
1440
+ IsPrimitive<string>
1441
+ //=> true
1442
+
1443
+ IsPrimitive<Object>
1444
+ //=> false
1445
+ ```
1446
+
1447
+ @group type-fest
1448
+ */
1449
+ type IsPrimitive<T> = [T] extends [Primitive] ? true : false;
1450
+ /**
1451
+ Returns a boolean for whether A is false.
1452
+
1453
+ @example
1454
+ ```
1455
+ Not<true>;
1456
+ //=> false
1457
+
1458
+ Not<false>;
1459
+ //=> true
1460
+ ```
1461
+
1462
+ @group type-fest
1463
+ */
1464
+ type Not<A extends boolean> = A extends true ? false : A extends false ? true : never;
1465
+ /**
1466
+ An if-else-like type that resolves depending on whether the given type is `any` or `never`.
1467
+
1468
+ @example
1469
+ ```
1470
+ // When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
1471
+ type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
1472
+ //=> 'VALID'
1473
+
1474
+ // When `T` is `any` => Returns `IfAny` branch
1475
+ type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
1476
+ //=> 'IS_ANY'
1477
+
1478
+ // When `T` is `never` => Returns `IfNever` branch
1479
+ type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
1480
+ //=> 'IS_NEVER'
1481
+ ```
1482
+
1483
+ @group type-fest
1484
+ */
1485
+ type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> = IsAny<T> extends true ? IfAny : IsNever<T> extends true ? IfNever : IfNotAnyOrNever;
1486
+ //#endregion
1487
+ //#region src/types/type-fest/internal/object.d.ts
1488
+ /**
1489
+ Works similar to the built-in `Pick` utility type, except for the following differences:
1490
+ - Distributes over union types and allows picking keys from any member of the union type.
1491
+ - Primitives types are returned as-is.
1492
+ - Picks all keys if `Keys` is `any`.
1493
+ - Doesn't pick `number` from a `string` index signature.
1494
+
1495
+ @example
1496
+ ```
1497
+ type ImageUpload = {
1498
+ url: string;
1499
+ size: number;
1500
+ thumbnailUrl: string;
1501
+ };
1502
+
1503
+ type VideoUpload = {
1504
+ url: string;
1505
+ duration: number;
1506
+ encodingFormat: string;
1507
+ };
1508
+
1509
+ // Distributes over union types and allows picking keys from any member of the union type
1510
+ type MediaDisplay = HomomorphicPick<ImageUpload | VideoUpload, "url" | "size" | "duration">;
1511
+ //=> {url: string; size: number} | {url: string; duration: number}
1512
+
1513
+ // Primitive types are returned as-is
1514
+ type Primitive = HomomorphicPick<string | number, 'toUpperCase' | 'toString'>;
1515
+ //=> string | number
1516
+
1517
+ // Picks all keys if `Keys` is `any`
1518
+ type Any = HomomorphicPick<{a: 1; b: 2} | {c: 3}, any>;
1519
+ //=> {a: 1; b: 2} | {c: 3}
1520
+
1521
+ // Doesn't pick `number` from a `string` index signature
1522
+ type IndexSignature = HomomorphicPick<{[k: string]: unknown}, number>;
1523
+ //=> {}
1524
+
1525
+ @group type-fest
1526
+ */
1527
+ type HomomorphicPick<T, Keys extends KeysOfUnion<T>> = { [P in keyof T as Extract<P, Keys>]: T[P] };
1528
+ /**
1529
+ Merges user specified options with default options.
1530
+
1531
+ @example
1532
+ ```
1533
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
1534
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
1535
+ type SpecifiedOptions = {leavesOnly: true};
1536
+
1537
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
1538
+ //=> {maxRecursionDepth: 10; leavesOnly: true}
1539
+ ```
1540
+
1541
+ @example
1542
+ ```
1543
+ // Complains if default values are not provided for optional options
1544
+
1545
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
1546
+ type DefaultPathsOptions = {maxRecursionDepth: 10};
1547
+ type SpecifiedOptions = {};
1548
+
1549
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
1550
+ // ~~~~~~~~~~~~~~~~~~~
1551
+ // Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
1552
+ ```
1553
+
1554
+ @example
1555
+ ```
1556
+ // Complains if an option's default type does not conform to the expected type
1557
+
1558
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
1559
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
1560
+ type SpecifiedOptions = {};
1561
+
1562
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
1563
+ // ~~~~~~~~~~~~~~~~~~~
1564
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
1565
+ ```
1566
+
1567
+ @example
1568
+ ```
1569
+ // Complains if an option's specified type does not conform to the expected type
1570
+
1571
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
1572
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
1573
+ type SpecifiedOptions = {leavesOnly: 'yes'};
1574
+
1575
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
1576
+ // ~~~~~~~~~~~~~~~~
1577
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
1578
+ ```
1579
+
1580
+ @group type-fest
1581
+ */
1582
+ type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = IfAny$1<SpecifiedOptions, Defaults, IfNever$1<SpecifiedOptions, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? Extract<SpecifiedOptions[Key], undefined> extends never ? Key : never : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
1583
+ //#endregion
1584
+ //#region src/types/type-fest/except.d.ts
1585
+ /**
1586
+ Filter out keys from an object.
1587
+
1588
+ Returns `never` if `Exclude` is strictly equal to `Key`.
1589
+ Returns `never` if `Key` extends `Exclude`.
1590
+ Returns `Key` otherwise.
1591
+
1592
+ @example
1593
+ ```
1594
+ type Filtered = Filter<'foo', 'foo'>;
1595
+ //=> never
1596
+ ```
1597
+
1598
+ @example
1599
+ ```
1600
+ type Filtered = Filter<'bar', string>;
1601
+ //=> never
1602
+ ```
1603
+
1604
+ @example
1605
+ ```
1606
+ type Filtered = Filter<'bar', 'foo'>;
1607
+ //=> 'bar'
1608
+ ```
1609
+
1610
+ @see {Except}
1611
+ */
1612
+ type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
1613
+ type ExceptOptions = {
1614
+ /**
1615
+ Disallow assigning non-specified properties.
1616
+
1617
+ Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
1618
+
1619
+ @default false
1620
+ */
1621
+ requireExactProps?: boolean;
1622
+ };
1623
+ type DefaultExceptOptions = {
1624
+ requireExactProps: false;
1625
+ };
1626
+ /**
1627
+ Create a type from an object type without certain keys.
1628
+
1629
+ We recommend setting the `requireExactProps` option to `true`.
1630
+
1631
+ This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
1632
+
1633
+ This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
1634
+
1635
+ @example
1636
+ ```
1637
+ import type {Except} from 'type-fest';
1638
+
1639
+ type Foo = {
1640
+ a: number;
1641
+ b: string;
1642
+ };
1643
+
1644
+ type FooWithoutA = Except<Foo, 'a'>;
1645
+ //=> {b: string}
1646
+
1647
+ const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
1648
+ //=> errors: 'a' does not exist in type '{ b: string; }'
1649
+
1650
+ type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
1651
+ //=> {a: number} & Partial<Record<"b", never>>
1652
+
1653
+ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
1654
+ //=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
1655
+
1656
+ // The `Omit` utility type doesn't work when omitting specific keys from objects containing index signatures.
1657
+
1658
+ // Consider the following example:
1659
+
1660
+ type UserData = {
1661
+ [metadata: string]: string;
1662
+ email: string;
1663
+ name: string;
1664
+ role: 'admin' | 'user';
1665
+ };
1666
+
1667
+ // `Omit` clearly doesn't behave as expected in this case:
1668
+ type PostPayload = Omit<UserData, 'email'>;
1669
+ //=> type PostPayload = { [x: string]: string; [x: number]: string; }
1670
+
1671
+ // In situations like this, `Except` works better.
1672
+ // It simply removes the `email` key while preserving all the other keys.
1673
+ type PostPayload = Except<UserData, 'email'>;
1674
+ //=> type PostPayload = { [x: string]: string; name: string; role: 'admin' | 'user'; }
1675
+ ```
1676
+
1677
+ @group type-fest
1678
+ */
1679
+ type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
1680
+ type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = { [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType] } & (Options["requireExactProps"] extends true ? Partial<Record<KeysType, never>> : {});
1681
+ //#endregion
1682
+ //#region src/types/type-fest/override-properties.d.ts
1683
+ /**
1684
+ Override existing properties of the given type. Similar to `Merge`, but enforces that the original type has the properties you want to override.
1685
+
1686
+ This is useful when you want to override existing properties with a different type and make sure that these properties really exist in the original.
1687
+
1688
+ @example
1689
+ ```
1690
+ type Foo = {
1691
+ a: string
1692
+ b: string
1693
+ }
1694
+ type Bar = OverrideProperties<Foo, {b: number}>
1695
+ //=> {a: string, b: number}
1696
+
1697
+ type Baz = OverrideProperties<Foo, {c: number}>
1698
+ // Error, type '{ c: number; }' does not satisfy the constraint '{ c: never; }'
1699
+
1700
+ type Fizz = OverrideProperties<Foo, {b: number; c: number}>
1701
+ // Error, type '{ b: number; c: number; }' does not satisfy the constraint '{ b: number; c: never; }'
1702
+ ```
1703
+
1704
+ @group type-fest
1705
+ */
1706
+ type OverrideProperties<TOriginal, TOverride extends Partial<Record<keyof TOriginal, unknown>> & { [Key in keyof TOverride]: Key extends keyof TOriginal ? TOverride[Key] : never }> = Merge<TOriginal, TOverride>;
1707
+ //#endregion
1708
+ //#region src/types/type-fest/require-at-least-one.d.ts
1709
+ /**
1710
+ Create a type that requires at least one of the given keys. The remaining keys are kept as is.
1711
+
1712
+ @example
1713
+ ```
1714
+ import type {RequireAtLeastOne} from 'type-fest';
1715
+
1716
+ type Responder = {
1717
+ text?: () => string;
1718
+ json?: () => string;
1719
+ secure?: boolean;
1720
+ };
1721
+
1722
+ const responder: RequireAtLeastOne<Responder, 'text' | 'json'> = {
1723
+ json: () => '{"message": "ok"}',
1724
+ secure: true
1725
+ };
1726
+ ```
1727
+
1728
+ @group type-fest
1729
+ */
1730
+ type RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, IfNever$1<KeysType, never, _RequireAtLeastOne<ObjectType, IfAny$1<KeysType, keyof ObjectType, KeysType>>>>;
1731
+ type _RequireAtLeastOne<ObjectType, KeysType extends keyof ObjectType> = { [Key in KeysType]-?: Required<Pick<ObjectType, Key>> & Partial<Pick<ObjectType, Exclude<KeysType, Key>>> }[KeysType] & Except<ObjectType, KeysType>;
1732
+ //#endregion
1733
+ //#region src/types/type-fest/set-non-nullable.d.ts
1734
+ /**
1735
+ Create a type that makes the given keys non-nullable, where the remaining keys are kept as is.
1736
+
1737
+ If no keys are given, all keys will be made non-nullable.
1738
+
1739
+ Use-case: You want to define a single model where the only thing that changes is whether or not some or all of the keys are non-nullable.
1740
+
1741
+ @example
1742
+ ```
1743
+ import type {SetNonNullable} from 'type-fest';
1744
+
1745
+ type Foo = {
1746
+ a: number | null;
1747
+ b: string | undefined;
1748
+ c?: boolean | null;
1749
+ }
1750
+
1751
+ type SomeNonNullable = SetNonNullable<Foo, 'b' | 'c'>;
1752
+ // type SomeNonNullable = {
1753
+ // a: number | null;
1754
+ // b: string; // Can no longer be undefined.
1755
+ // c?: boolean; // Can no longer be null, but is still optional.
1756
+ // }
1757
+
1758
+ type AllNonNullable = SetNonNullable<Foo>;
1759
+ // type AllNonNullable = {
1760
+ // a: number; // Can no longer be null.
1761
+ // b: string; // Can no longer be undefined.
1762
+ // c?: boolean; // Can no longer be null, but is still optional.
1763
+ // }
1764
+ ```
1765
+
1766
+ @group type-fest
1767
+ */
1768
+ type SetNonNullable<BaseType, Keys extends keyof BaseType = keyof BaseType> = { [Key in keyof BaseType]: Key extends Keys ? NonNullable<BaseType[Key]> : BaseType[Key] };
1769
+ //#endregion
1770
+ //#region src/types/type-fest/set-optional.d.ts
1771
+ /**
1772
+ Create a type that makes the given keys optional. The remaining keys are kept as is. The sister of the `SetRequired` type.
1773
+
1774
+ Use-case: You want to define a single model where the only thing that changes is whether or not some of the keys are optional.
1775
+
1776
+ @example
1777
+ ```
1778
+ import type {SetOptional} from 'type-fest';
1779
+
1780
+ type Foo = {
1781
+ a: number;
1782
+ b?: string;
1783
+ c: boolean;
1784
+ }
1785
+
1786
+ type SomeOptional = SetOptional<Foo, 'b' | 'c'>;
1787
+ // type SomeOptional = {
1788
+ // a: number;
1789
+ // b?: string; // Was already optional and still is.
1790
+ // c?: boolean; // Is now optional.
1791
+ // }
1792
+ ```
1793
+
1794
+ @group type-fest
1795
+ */
1796
+ type SetOptional<BaseType, Keys extends keyof BaseType> = BaseType extends unknown ? Simplify<Except<BaseType, Keys> & Partial<HomomorphicPick<BaseType, Keys>>> : never;
1797
+ //#endregion
1798
+ //#region src/types/type-fest/set-required.d.ts
1799
+ /**
1800
+ Create a type that makes the given keys required. The remaining keys are kept as is. The sister of the `SetOptional` type.
1801
+
1802
+ Use-case: You want to define a single model where the only thing that changes is whether or not some of the keys are required.
1803
+
1804
+ @example
1805
+ ```
1806
+ import type {SetRequired} from 'type-fest';
1807
+
1808
+ type Foo = {
1809
+ a?: number;
1810
+ b: string;
1811
+ c?: boolean;
1812
+ }
1813
+
1814
+ type SomeRequired = SetRequired<Foo, 'b' | 'c'>;
1815
+ // type SomeRequired = {
1816
+ // a?: number;
1817
+ // b: string; // Was already required and still is.
1818
+ // c: boolean; // Is now required.
1819
+ // }
1820
+
1821
+ // Set specific indices in an array to be required.
1822
+ type ArrayExample = SetRequired<[number?, number?, number?], 0 | 1>;
1823
+ //=> [number, number, number?]
1824
+ ```
1825
+
1826
+ @group type-fest
1827
+ */
1828
+ type SetRequired<BaseType, Keys extends keyof BaseType> = BaseType extends UnknownArray ? SetArrayRequired<BaseType, Keys> extends infer ResultantArray ? IfArrayReadonly<BaseType, Readonly<ResultantArray>, ResultantArray> : never : Simplify<Except<BaseType, Keys> & Required<HomomorphicPick<BaseType, Keys>>>;
1829
+ /**
1830
+ Remove the optional modifier from the specified keys in an array.
1831
+ */
1832
+ type SetArrayRequired<TArray extends UnknownArray, Keys, Counter extends any[] = [], Accumulator extends UnknownArray = []> = TArray extends unknown ? keyof TArray & `${number}` extends never ? [...Accumulator, ...TArray] : TArray extends readonly [(infer First)?, ...infer Rest] ? "0" extends OptionalKeysOf<TArray> ? `${Counter["length"]}` extends `${Keys & (string | number)}` ? SetArrayRequired<Rest, Keys, [...Counter, any], [...Accumulator, First]> : [...Accumulator, ...TArray] : SetArrayRequired<Rest, Keys, [...Counter, any], [...Accumulator, TArray[0]]> : never : never;
1833
+ //#endregion
1834
+ //#region src/types/type-fest/writable.d.ts
1835
+ /**
1836
+ Create a writable version of the given array type.
1837
+ */
1838
+ type WritableArray<ArrayType extends readonly unknown[]> = ArrayType extends readonly [] ? [] : ArrayType extends readonly [...infer U, infer V] ? [...U, V] : ArrayType extends readonly [infer U, ...infer V] ? [U, ...V] : ArrayType extends ReadonlyArray<infer U> ? U[] : ArrayType;
1839
+ /**
1840
+ Create a type that strips `readonly` from the given type. Inverse of `Readonly<T>`.
1841
+
1842
+ The 2nd argument will be ignored if the input type is not an object.
1843
+
1844
+ Note: This type can make readonly `Set` and `Map` writable. This behavior is different from `Readonly<T>` (as of TypeScript 5.2.2). See: https://github.com/microsoft/TypeScript/issues/29655
1845
+
1846
+ This can be used to [store and mutate options within a class](https://github.com/sindresorhus/pageres/blob/4a5d05fca19a5fbd2f53842cbf3eb7b1b63bddd2/source/index.ts#L72), [edit `readonly` objects within tests](https://stackoverflow.com/questions/50703834), [construct a `readonly` object within a function](https://github.com/Microsoft/TypeScript/issues/24509), or to define a single model where the only thing that changes is whether or not some of the keys are writable.
1847
+
1848
+ @example
1849
+ ```
1850
+ import type {Writable} from 'type-fest';
1851
+
1852
+ type Foo = {
1853
+ readonly a: number;
1854
+ readonly b: readonly string[]; // To show that only the mutability status of the properties, not their values, are affected.
1855
+ readonly c: boolean;
1856
+ };
1857
+
1858
+ const writableFoo: Writable<Foo> = {a: 1, b: ['2'], c: true};
1859
+ writableFoo.a = 3;
1860
+ writableFoo.b[0] = 'new value'; // Will still fail as the value of property "b" is still a readonly type.
1861
+ writableFoo.b = ['something']; // Will work as the "b" property itself is no longer readonly.
1862
+
1863
+ type SomeWritable = Writable<Foo, 'b' | 'c'>;
1864
+ // type SomeWritable = {
1865
+ // readonly a: number;
1866
+ // b: readonly string[]; // It's now writable. The type of the property remains unaffected.
1867
+ // c: boolean; // It's now writable.
1868
+ // }
1869
+
1870
+ // Also supports array
1871
+ const readonlyArray: readonly number[] = [1, 2, 3];
1872
+ readonlyArray.push(4); // Will fail as the array itself is readonly.
1873
+ const writableArray: Writable<typeof readonlyArray> = readonlyArray as Writable<typeof readonlyArray>;
1874
+ writableArray.push(4); // Will work as the array itself is now writable.
1875
+ ```
1876
+
1877
+ @group type-fest
1878
+ */
1879
+ type Writable<BaseType, Keys extends keyof BaseType = keyof BaseType> = BaseType extends ReadonlyMap<infer KeyType, infer ValueType> ? Map<KeyType, ValueType> : BaseType extends ReadonlySet<infer ItemType> ? Set<ItemType> : BaseType extends readonly unknown[] ? WritableArray<BaseType> : Simplify<Except<BaseType, Keys> & { -readonly [KeyType in keyof Pick<BaseType, Keys>]: Pick<BaseType, Keys>[KeyType] }>;
1880
+ //#endregion
1881
+ //#region src/types/options.d.ts
1882
+ type StringUnionToFlexibleOptionArray<Op extends string> = Array<Op extends unknown ? FlexibleOption<Op> : never>;
1883
+ type StringUnionToFullOptionArray<Op extends string> = Array<Op extends unknown ? FullOption<Op> : never>;
1884
+ /**
1885
+ * Extracts the {@link Option} type from a {@link FlexibleOptionList}.
1886
+ *
1887
+ * @group Option Lists
1888
+ */
1889
+ type GetOptionType<OL extends FlexibleOptionList<FullOption>> = OL extends FlexibleOptionList<infer Opt> ? Opt : never;
1890
+ /**
1891
+ * Extracts the type of the identifying property from a {@link Option},
1892
+ * {@link ValueOption}, or {@link FullOption}.
1893
+ *
1894
+ * @group Option Lists
1895
+ */
1896
+ type GetOptionIdentifierType<Opt extends BaseOption> = Opt extends Option<infer NameType> | ValueOption<infer NameType> ? NameType : string;
1897
+ /**
1898
+ * Adds an `unknown` index property to an interface.
1899
+ */
1900
+ type WithUnknownIndex<T> = T & {
1901
+ [key: string]: unknown;
1902
+ };
1903
+ /**
1904
+ * Do not use this type directly; use {@link Option}, {@link ValueOption},
1905
+ * or {@link FullOption} instead. For specific option types, you can use
1906
+ * {@link FullField}, {@link FullOperator}, or {@link FullCombinator},
1907
+ * all of which extend {@link FullOption}.
1908
+ *
1909
+ * @group Option Lists
1910
+ */
1911
+ interface BaseOption<N extends string = string> {
1912
+ name?: N;
1913
+ value?: N;
1914
+ label: string;
1915
+ disabled?: boolean;
1916
+ }
1917
+ /**
1918
+ * A generic option. Used directly in {@link OptionList} or
1919
+ * as the child element of an {@link OptionGroup}.
1920
+ *
1921
+ * @group Option Lists
1922
+ */
1923
+ type Option<N extends string = string> = Simplify<WithUnknownIndex<SetRequired<BaseOption<N>, "name">>>;
1924
+ /**
1925
+ * Like {@link Option} but requiring `value` instead of `name`.
1926
+ *
1927
+ * @group Option Lists
1928
+ */
1929
+ type ValueOption<N extends string = string> = Simplify<WithUnknownIndex<SetRequired<BaseOption<N>, "value">>>;
1930
+ /**
1931
+ * A generic {@link Option} with either a `name` or `value` as its primary identifier.
1932
+ * {@link OptionList}-type props on the {@link QueryBuilder} component accept this type,
1933
+ * but corresponding props passed down to subcomponents will always be translated
1934
+ * to {@link FullOption} first.
1935
+ *
1936
+ * @group Option Lists
1937
+ */
1938
+ type FlexibleOption<N extends string = string> = Simplify<WithUnknownIndex<RequireAtLeastOne<BaseOption<N>, "name" | "value">>>;
1939
+ /**
1940
+ * Utility type to turn an {@link Option}, {@link ValueOption}, or {@link BaseOption}
1941
+ * into a {@link FlexibleOption}.
1942
+ *
1943
+ * @group Option Lists
1944
+ */
1945
+ type ToFlexibleOption<Opt extends BaseOption | string> = WithUnknownIndex<RequireAtLeastOne<Opt extends string ? FlexibleOption<Opt> : Opt, "name" | "value">>;
1946
+ /**
1947
+ * A generic {@link Option} requiring both `name` _and_ `value` properties.
1948
+ * Props that extend {@link OptionList} accept {@link BaseOption}, but
1949
+ * corresponding props sent to subcomponents will always be translated to this
1950
+ * type first to ensure both `name` and `value` are available.
1951
+ *
1952
+ * NOTE: Do not extend from this type directly. Use {@link BaseFullOption}
1953
+ * (optionally wrapped in {@link WithUnknownIndex}) instead, otherwise
1954
+ * the `unknown` index property will cause issues. See {@link Option} and
1955
+ * {@link ValueOption} for examples.
1956
+ *
1957
+ * @group Option Lists
1958
+ */
1959
+ type FullOption<N extends string = string> = Simplify<WithUnknownIndex<SetRequired<BaseOption<N>, "name" | "value">>>;
1960
+ /**
1961
+ * This type is identical to {@link FullOption} but without the `unknown` index
1962
+ * property. Extend from this type instead of {@link FullOption} directly.
1963
+ *
1964
+ * @group Option Lists
1965
+ */
1966
+ type BaseFullOption<N extends string = string> = Simplify<SetRequired<BaseOption<N>, "name" | "value">>;
1967
+ /**
1968
+ * Utility type to turn an {@link Option}, {@link ValueOption} or
1969
+ * {@link BaseOption} into a {@link FullOption}.
1970
+ *
1971
+ * @group Option Lists
1972
+ */
1973
+ type ToFullOption<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt : Opt extends BaseOption<infer IdentifierType> ? WithUnknownIndex<Opt & FullOption<IdentifierType>> : never;
1974
+ /**
1975
+ * @deprecated Renamed to {@link Option}.
1976
+ *
1977
+ * @group Option Lists
1978
+ */
1979
+ type NameLabelPair<N extends string = string> = Option<N>;
1980
+ /**
1981
+ * A group of {@link Option}s, usually within an {@link OptionList}.
1982
+ *
1983
+ * @group Option Lists
1984
+ */
1985
+ interface OptionGroup<Opt extends BaseOption = FlexibleOption> {
1986
+ label: string;
1987
+ options: WithUnknownIndex<Opt>[];
1988
+ }
1989
+ /**
1990
+ * A group of {@link BaseOption}s, usually within a {@link FlexibleOptionList}.
1991
+ *
1992
+ * @group Option Lists
1993
+ */
1994
+ type FlexibleOptionGroup<Opt extends BaseOption | string = BaseOption> = {
1995
+ label: string;
1996
+ options: (Opt extends BaseFullOption ? Opt : ToFlexibleOption<Opt>)[];
1997
+ };
1998
+ /**
1999
+ * Either an array of {@link Option}s or an array of {@link OptionGroup}s.
2000
+ *
2001
+ * @group Option Lists
2002
+ */
2003
+ type OptionList<Opt extends Option = Option> = Opt[] | OptionGroup<Opt>[];
2004
+ /**
2005
+ * An array of options or option groups, like {@link OptionList} but the option type
2006
+ * may use either `name` or `value` as the primary identifier.
2007
+ *
2008
+ * @group Option Lists
2009
+ */
2010
+ type FlexibleOptionList<Opt extends BaseOption> = ToFlexibleOption<Opt>[] | FlexibleOptionGroup<ToFlexibleOption<Opt>>[];
2011
+ /**
2012
+ * An array of options or option groups, like {@link OptionList} but the option type
2013
+ * may use either `name` or `value` as the primary identifier.
2014
+ *
2015
+ * @group Option Lists
2016
+ */
2017
+ type FlexibleOptionListProp<Opt extends BaseOption> = (ToFlexibleOption<Opt> | GetOptionIdentifierType<Opt>)[] | FlexibleOptionGroup<ToFlexibleOption<Opt> | GetOptionIdentifierType<Opt>>[];
2018
+ /**
2019
+ * An array of options or option groups, like {@link OptionList}, but using
2020
+ * {@link FullOption} instead of {@link Option}. This means that every member is
2021
+ * guaranteed to have both `name` and `value`.
2022
+ *
2023
+ * @group Option Lists
2024
+ */
2025
+ type FullOptionList<Opt extends BaseOption> = Opt extends BaseFullOption ? Opt[] | OptionGroup<Opt>[] : ToFullOption<Opt>[] | OptionGroup<ToFullOption<Opt>>[];
2026
+ /**
2027
+ * Map of option identifiers to their respective {@link Option}.
2028
+ *
2029
+ * @group Option Lists
2030
+ */
2031
+ type BaseOptionMap<V extends BaseOption = BaseOption, K extends string = GetOptionIdentifierType<V>> = { [k in K]?: ToFlexibleOption<V> };
2032
+ /**
2033
+ * Map of option identifiers to their respective {@link FullOption}.
2034
+ *
2035
+ * @group Option Lists
2036
+ */
2037
+ type FullOptionMap<V extends BaseFullOption, K extends string = GetOptionIdentifierType<V>> = { [k in K]?: V };
2038
+ /**
2039
+ * Map of option identifiers to their respective {@link FullOption}.
2040
+ * Must include all possible strings from the identifier type.
2041
+ *
2042
+ * @group Option Lists
2043
+ */
2044
+ type FullOptionRecord<V extends BaseFullOption, K extends string = GetOptionIdentifierType<V>> = Record<K, V>;
2045
+ //#endregion
2046
+ //#region src/types/ruleGroups.d.ts
2047
+ /**
2048
+ * Properties common to both rules and groups.
2049
+ */
2050
+ interface CommonRuleAndGroupProperties {
2051
+ path?: Path;
2052
+ id?: string;
2053
+ disabled?: boolean;
2054
+ }
2055
+ /**
2056
+ * The main rule type. The `field`, `operator`, and `value` properties
2057
+ * can be narrowed with generics.
2058
+ */
2059
+ interface RuleType<F extends string = string, O extends string = string, V = any, C extends string = string> extends CommonRuleAndGroupProperties {
2060
+ field: F;
2061
+ operator: O;
2062
+ value: V;
2063
+ valueSource?: ValueSource;
2064
+ match?: MatchConfig;
2065
+ /**
2066
+ * Only used when adding a rule to a query that uses independent combinators.
2067
+ */
2068
+ combinatorPreceding?: C;
2069
+ }
2070
+ /**
2071
+ * The main rule group type. This type is used for query definitions as well as
2072
+ * all sub-groups of queries.
2073
+ */
2074
+ interface RuleGroupType<R extends RuleType = RuleType, C extends string = string> extends CommonRuleAndGroupProperties {
2075
+ combinator: C;
2076
+ rules: RuleGroupArray<RuleGroupType<R, C>, R>;
2077
+ not?: boolean;
2078
+ }
2079
+ /**
2080
+ * The type of the `rules` array in a {@link RuleGroupType}.
2081
+ */
2082
+ type RuleGroupArray<RG extends RuleGroupType = RuleGroupType, R extends RuleType = RuleType> = (R | RG)[];
2083
+ /**
2084
+ * All updateable properties of rules and groups (everything except
2085
+ * `id`, `path`, and `rules`).
2086
+ */
2087
+ type UpdateableProperties = Exclude<keyof (RuleType & RuleGroupType), "id" | "path" | "rules">;
2088
+ /**
2089
+ * The type of the `rules` array in a {@link DefaultRuleGroupType}.
2090
+ */
2091
+ type DefaultRuleGroupArray<F extends string = string> = RuleGroupArray<DefaultRuleGroupType, DefaultRuleType<F>>;
2092
+ /**
2093
+ * {@link RuleGroupType} with the `combinator` property limited to
2094
+ * {@link DefaultCombinatorNameExtended} and `rules` limited to {@link DefaultRuleType}.
2095
+ */
2096
+ type DefaultRuleGroupType<F extends string = string> = RuleGroupType<DefaultRuleType<F>, DefaultCombinatorNameExtended> & {
2097
+ rules: DefaultRuleGroupArray<F>;
2098
+ };
2099
+ /**
2100
+ * {@link RuleType} with the `operator` property limited to {@link DefaultOperatorName}.
2101
+ */
2102
+ type DefaultRuleType<F extends string = string> = RuleType<F, DefaultOperatorName>;
2103
+ /**
2104
+ * Default allowed values for the `combinator` property.
2105
+ *
2106
+ * @group Option Lists
2107
+ */
2108
+ type DefaultCombinatorName = "and" | "or";
2109
+ /**
2110
+ * Default allowed values for the `combinator` property, plus `"xor"`.
2111
+ *
2112
+ * @group Option Lists
2113
+ */
2114
+ type DefaultCombinatorNameExtended = DefaultCombinatorName | "xor";
2115
+ /**
2116
+ * Default values for the `operator` property.
2117
+ *
2118
+ * @group Option Lists
2119
+ */
2120
+ type DefaultOperatorName = "=" | "!=" | "<" | ">" | "<=" | ">=" | "contains" | "beginsWith" | "endsWith" | "doesNotContain" | "doesNotBeginWith" | "doesNotEndWith" | "null" | "notNull" | "in" | "notIn" | "between" | "notBetween";
2121
+ /**
2122
+ * A {@link FullCombinator} definition with a {@link DefaultCombinatorName} `name` property.
2123
+ *
2124
+ * @group Option Lists
2125
+ */
2126
+ type DefaultCombinator = FullCombinator<DefaultCombinatorName>;
2127
+ /**
2128
+ * A {@link FullCombinator} definition with a {@link DefaultCombinatorNameExtended} `name` property.
2129
+ *
2130
+ * @group Option Lists
2131
+ */
2132
+ type DefaultCombinatorExtended = FullCombinator<DefaultCombinatorNameExtended>;
2133
+ /**
2134
+ * An {@link FullOperator} definition with a {@link DefaultOperatorName} `name` property.
2135
+ *
2136
+ * @group Option Lists
2137
+ */
2138
+ type DefaultOperator = FullOperator<DefaultOperatorName>;
2139
+ //#endregion
2140
+ //#region src/types/ruleGroupsIC.utils.d.ts
2141
+ type MAXIMUM_ALLOWED_BOUNDARY = 80;
2142
+ type MappedTuple<Tuple extends Array<unknown>, Result extends Array<unknown> = [], Count extends ReadonlyArray<number> = []> = Count["length"] extends MAXIMUM_ALLOWED_BOUNDARY ? Result : Tuple extends [] ? [] : Result extends [] ? MappedTuple<Tuple, Tuple, [...Count, 1]> : MappedTuple<Tuple, Result | [...Result, ...Tuple], [...Count, 1]>;
2143
+ //#endregion
2144
+ //#region src/types/ruleGroupsIC.d.ts
2145
+ /**
2146
+ * The main rule group interface when using independent combinators. This type is used
2147
+ * for query definitions as well as all sub-groups of queries.
2148
+ */
2149
+ interface RuleGroupTypeIC<R extends RuleType = RuleType, C extends string = string> extends Except<RuleGroupType<R, C>, "combinator" | "rules"> {
2150
+ combinator?: undefined;
2151
+ rules: RuleGroupICArray<RuleGroupTypeIC<R, C>, R, C>;
2152
+ /**
2153
+ * Only used when adding a rule to a query that uses independent combinators
2154
+ */
2155
+ combinatorPreceding?: C;
2156
+ }
2157
+ /**
2158
+ * Shorthand for "either {@link RuleGroupType} or {@link RuleGroupTypeIC}".
2159
+ */
2160
+ type RuleGroupTypeAny<R extends RuleType = RuleType, C extends string = string> = RuleGroupType<R, C> | RuleGroupTypeIC<R, C>;
2161
+ /**
2162
+ * The type of the `rules` array in a {@link RuleGroupTypeIC}.
2163
+ */
2164
+ type RuleGroupICArray<RG extends RuleGroupTypeIC = RuleGroupTypeIC, R extends RuleType = RuleType, C extends string = string> = [R | RG] | [R | RG, ...MappedTuple<[C, R | RG]>] | ((R | RG)[] & {
2165
+ length: 0;
2166
+ });
2167
+ /**
2168
+ * Shorthand for "either {@link RuleGroupArray} or {@link RuleGroupICArray}".
2169
+ */
2170
+ type RuleOrGroupArray = RuleGroupArray | RuleGroupICArray;
2171
+ /**
2172
+ * The type of the `rules` array in a {@link DefaultRuleGroupTypeIC}.
2173
+ */
2174
+ type DefaultRuleGroupICArray<F extends string = string> = RuleGroupICArray<DefaultRuleGroupTypeIC<F>, DefaultRuleType<F>, DefaultCombinatorName>;
2175
+ /**
2176
+ * Shorthand for "either {@link DefaultRuleGroupArray} or {@link DefaultRuleGroupICArray}".
2177
+ */
2178
+ type DefaultRuleOrGroupArray<F extends string = string> = DefaultRuleGroupArray<F> | DefaultRuleGroupICArray<F>;
2179
+ /**
2180
+ * {@link RuleGroupTypeIC} with combinators limited to
2181
+ * {@link DefaultCombinatorName} and rules limited to {@link DefaultRuleType}.
2182
+ */
2183
+ interface DefaultRuleGroupTypeIC<F extends string = string> extends RuleGroupTypeIC<DefaultRuleType<F>> {
2184
+ rules: DefaultRuleGroupICArray<F>;
2185
+ }
2186
+ /**
2187
+ * Shorthand for "either {@link DefaultRuleGroupType} or {@link DefaultRuleGroupTypeIC}".
2188
+ */
2189
+ type DefaultRuleGroupTypeAny<F extends string = string> = DefaultRuleGroupType<F> | DefaultRuleGroupTypeIC<F>;
2190
+ /**
2191
+ * Determines if a type extending {@link RuleGroupTypeAny} is actually
2192
+ * {@link RuleGroupType} or {@link RuleGroupTypeIC}.
2193
+ */
2194
+ type GetRuleGroupType<RG> = RG extends {
2195
+ combinator: string;
2196
+ } ? RuleGroupType : RuleGroupTypeIC;
2197
+ /**
2198
+ * Determines the {@link RuleType} of a given {@link RuleGroupType}
2199
+ * or {@link RuleGroupTypeIC}. If the field and operator name types of
2200
+ * the rule type extend the identifier types of the provided Field and
2201
+ * Operator types, the given rule type is returned as is. Otherwise,
2202
+ * the rule type has its field and operator types narrowed to the
2203
+ * identifier types of the provided Field and Operator types.
2204
+ */
2205
+ type GetRuleTypeFromGroupWithFieldAndOperator<RG extends RuleGroupTypeAny, F extends BaseOption, O extends BaseOption> = RG extends RuleGroupType<infer RT> | RuleGroupTypeIC<infer RT> ? RT extends RuleType<infer RuleFieldName, infer RuleOperatorName, infer RuleValueName, infer RuleCombinatorName> ? RuleFieldName extends GetOptionIdentifierType<F> ? RuleOperatorName extends GetOptionIdentifierType<O> ? RuleType<RuleFieldName, RuleOperatorName, RuleValueName, RuleCombinatorName> : RuleType<RuleFieldName, GetOptionIdentifierType<O>, RuleValueName, RuleCombinatorName> : RuleOperatorName extends GetOptionIdentifierType<O> ? RuleType<GetOptionIdentifierType<F>, RuleOperatorName, RuleValueName, RuleCombinatorName> : RuleType<GetOptionIdentifierType<F>, GetOptionIdentifierType<O>, RuleValueName, RuleCombinatorName> : never : never;
2206
+ /**
2207
+ * Converts a narrowed rule group type to its most generic form.
2208
+ */
2209
+ type GenericizeRuleGroupType<RG> = RG extends RuleGroupType ? RuleGroupType : RuleGroupTypeIC;
2210
+ //#endregion
2211
+ //#region src/types/validation.d.ts
2212
+ /**
2213
+ * Object with a `valid` boolean value and optional `reasons`.
2214
+ */
2215
+ interface ValidationResult {
2216
+ valid: boolean;
2217
+ reasons?: any[];
2218
+ }
2219
+ /**
2220
+ * Map of rule/group `id` to its respective {@link ValidationResult}.
2221
+ */
2222
+ type ValidationMap = Record<string, boolean | ValidationResult>;
2223
+ /**
2224
+ * Function that validates a query.
2225
+ */
2226
+ type QueryValidator = (query: RuleGroupTypeAny) => boolean | ValidationMap;
2227
+ /**
2228
+ * Function that validates a rule.
2229
+ */
2230
+ type RuleValidator = (rule: RuleType) => boolean | ValidationResult;
2231
+ //#endregion
2232
+ //#region src/types/basic.d.ts
2233
+ /**
2234
+ * @see https://react-querybuilder.js.org/docs/tips/path
2235
+ */
2236
+ type Path = number[];
2237
+ /**
2238
+ * String of classnames, array of classname strings, or object where the
2239
+ * keys are classnames and those with truthy values will be included.
2240
+ * Suitable for passing to the `clsx` package.
2241
+ */
2242
+ type Classname = string | string[] | Record<string, any>;
2243
+ /**
2244
+ * A source for the `value` property of a rule.
2245
+ */
2246
+ type ValueSource = "value" | "field";
2247
+ /**
2248
+ * Type of {@link ValueEditor} that will be displayed.
2249
+ */
2250
+ type ValueEditorType = "text" | "select" | "checkbox" | "radio" | "textarea" | "switch" | "multiselect" | null;
2251
+ /**
2252
+ * A valid array of potential value sources.
2253
+ *
2254
+ * @see {@link ValueSource}
2255
+ */
2256
+ type ValueSources = ["value"] | ["value", "field"] | ["field", "value"] | ["field"];
2257
+ type ValueSourceFlexibleOptions = ToFlexibleOptionArrays<ValueSources>;
2258
+ type ValueSourceFullOptions = ToOptionArrays<ValueSources>;
2259
+ type ToOptionArrays<Sources extends readonly string[]> = Sources extends unknown ? { [K in keyof Sources]: {
2260
+ name: Sources[K];
2261
+ value: Sources[K];
2262
+ label: string;
2263
+ } } : never;
2264
+ type ToFlexibleOptionArrays<Sources extends readonly string[]> = Sources extends unknown ? { [K in keyof Sources]: FlexibleOption<Sources[K]> } : never;
2265
+ type WithOptionalClassName<T> = T & {
2266
+ className?: Classname;
2267
+ };
2268
+ /**
2269
+ * HTML5 input types
2270
+ */
2271
+ type InputType = "button" | "checkbox" | "color" | "date" | "datetime-local" | "email" | "file" | "hidden" | "image" | "month" | "number" | "password" | "radio" | "range" | "reset" | "search" | "submit" | "tel" | "text" | "time" | "url" | "week" | "bigint" | (string & {});
2272
+ /**
2273
+ * Quantification mode describing how many elements of the value array must pass
2274
+ * the filter for the rule itself to pass.
2275
+ *
2276
+ * For "atLeast", "atMost", and "exactly", the threshold value will be converted to
2277
+ * a percentage if the number is less than 1. Non-numeric values and numbers less
2278
+ * than 0 will be ignored.
2279
+ */
2280
+ interface MatchConfig {
2281
+ mode: MatchMode;
2282
+ threshold?: number | null | undefined;
2283
+ }
2284
+ type MatchMode = "all" | "some" | "none" | "atLeast" | "atMost" | "exactly";
2285
+ type MatchModeOptions = StringUnionToFullOptionArray<MatchMode>;
2286
+ type ActionElementEventHandler = (event?: any, context?: any) => void;
2287
+ type ValueChangeEventHandler = (value?: any, context?: any) => void;
2288
+ /**
2289
+ * Base for all Field types/interfaces.
2290
+ */
2291
+ interface BaseFullField<FieldName extends string = string, OperatorName extends string = string, ValueName extends string = string, OperatorObj extends FullOption = FullOption<OperatorName>, ValueObj extends FullOption = FullOption<ValueName>> extends WithOptionalClassName<BaseFullOption<FieldName>> {
2292
+ id?: string;
2293
+ operators?: FlexibleOptionList<OperatorObj> | OperatorName[] | FlexibleOption<OperatorName>[] | (OperatorName | FlexibleOption<OperatorName>)[];
2294
+ valueEditorType?: ValueEditorType | ((operator: OperatorName) => ValueEditorType);
2295
+ valueSources?: ValueSources | ValueSourceFlexibleOptions | ((operator: OperatorName) => ValueSources | ValueSourceFlexibleOptions);
2296
+ inputType?: InputType | null;
2297
+ values?: FlexibleOptionList<ValueObj>;
2298
+ matchModes?: boolean | MatchMode[] | FlexibleOption<MatchMode>[];
2299
+ /** Properties of items in the value. */
2300
+ subproperties?: FlexibleOptionList<FullField>;
2301
+ defaultOperator?: OperatorName;
2302
+ defaultValue?: any;
2303
+ placeholder?: string;
2304
+ validator?: RuleValidator;
2305
+ comparator?: string | ((f: FullField, operator: string) => boolean);
2306
+ }
2307
+ /**
2308
+ * Full field definition used in the `fields` prop of {@link QueryBuilder}.
2309
+ * This type requires both `name` and `value`, but the `fields` prop itself
2310
+ * can use a {@link FlexibleOption} where only one of `name` or `value` is
2311
+ * required (along with `label`), or {@link Field} where only `name` and
2312
+ * `label` are required.
2313
+ *
2314
+ * The `name`/`value`, `operators`, and `values` properties of this interface
2315
+ * can be narrowed with generics.
2316
+ *
2317
+ * @group Option Lists
2318
+ */
2319
+ type FullField<FieldName extends string = string, OperatorName extends string = string, ValueName extends string = string, OperatorObj extends FullOption = FullOption<OperatorName>, ValueObj extends FullOption = FullOption<ValueName>> = Simplify<FullOption<FieldName> & BaseFullField<FieldName, OperatorName, ValueName, OperatorObj, ValueObj>>;
2320
+ /**
2321
+ * Field definition used in the `fields` prop of {@link QueryBuilder}.
2322
+ * This type is an extension of {@link FullField} where only `name` and
2323
+ * `label` are required.
2324
+ *
2325
+ * The `name`/`value`, `operators`, and `values` properties of this interface
2326
+ * can be narrowed with generics.
2327
+ *
2328
+ * @group Option Lists
2329
+ */
2330
+ type Field<FieldName extends string = string, OperatorName extends string = string, ValueName extends string = string, OperatorObj extends FullOption = FullOption<OperatorName>> = WithUnknownIndex<{
2331
+ value?: FieldName;
2332
+ } & Pick<BaseFullField<FieldName, OperatorName, ValueName, OperatorObj>, Exclude<keyof BaseFullField, "value">>>;
2333
+ /**
2334
+ * Field definition used in the `fields` prop of {@link QueryBuilder}.
2335
+ * This type is an extension of {@link FullField} where only `value` and
2336
+ * `label` are required.
2337
+ *
2338
+ * The `name`/`value`, `operators`, and `values` properties of this interface
2339
+ * can be narrowed with generics.
2340
+ *
2341
+ * @group Option Lists
2342
+ */
2343
+ type FieldByValue<FieldName extends string = string, OperatorName extends string = string, ValueName extends string = string, OperatorObj extends FullOption = FullOption<OperatorName>> = WithUnknownIndex<{
2344
+ name?: FieldName;
2345
+ } & Pick<BaseFullField<FieldName, OperatorName, ValueName, OperatorObj>, Exclude<keyof BaseFullField, "name">>>;
2346
+ /**
2347
+ * Utility type to make one or more properties required.
2348
+ */
2349
+ type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
2350
+ /**
2351
+ * Utility type to make all properties non-nullable.
2352
+ */
2353
+ type RemoveNullability<T extends Record<string, unknown>> = { [k in keyof T]: NonNullable<T[k]> };
2354
+ /**
2355
+ * Allowed values of the {@link FullOperator} property `arity`. A value of `"unary"` or
2356
+ * a number less than two will cause the default {@link ValueEditor} to render `null`.
2357
+ */
2358
+ type Arity = number | "unary" | "binary" | "ternary";
2359
+ /**
2360
+ * Full operator definition used in the `operators`/`getOperators` props of
2361
+ * {@link QueryBuilder}. This type requires both `name` and `value`, but the
2362
+ * `operators`/`getOperators` props themselves can use a {@link FlexibleOption}
2363
+ * where only one of `name` or `value` is required, or {@link FullOperator} where
2364
+ * only `name` is required.
2365
+ *
2366
+ * The `name`/`value` properties of this interface can be narrowed with generics.
2367
+ *
2368
+ * @group Option Lists
2369
+ */
2370
+ interface FullOperator<N extends string = string> extends WithOptionalClassName<FullOption<N>> {
2371
+ arity?: Arity;
2372
+ }
2373
+ /**
2374
+ * Operator definition used in the `operators`/`getOperators` props of
2375
+ * {@link QueryBuilder}. This type is an extension of {@link FullOperator}
2376
+ * where only `name` and `label` are required.
2377
+ *
2378
+ * The `name`/`value` properties of this interface can be narrowed with generics.
2379
+ *
2380
+ * @group Option Lists
2381
+ */
2382
+ type Operator<N extends string = string> = WithUnknownIndex<SetOptional<BaseFullOption<N>, "value"> & WithOptionalClassName<{
2383
+ arity?: Arity;
2384
+ }>>;
2385
+ /**
2386
+ * Operator definition used in the `operators`/`getOperators` props of
2387
+ * {@link QueryBuilder}. This type is an extension of {@link FullOperator}
2388
+ * where only `value` and `label` are required.
2389
+ *
2390
+ * The `name`/`value` properties of this interface can be narrowed with generics.
2391
+ *
2392
+ * @group Option Lists
2393
+ */
2394
+ type OperatorByValue<N extends string = string> = WithUnknownIndex<SetOptional<BaseFullOption<N>, "name"> & WithOptionalClassName<{
2395
+ arity?: Arity;
2396
+ }>>;
2397
+ /**
2398
+ * Full combinator definition used in the `combinators` prop of {@link QueryBuilder}.
2399
+ * This type requires both `name` and `value`, but the `combinators` prop itself
2400
+ * can use a {@link FlexibleOption} where only one of `name` or `value` is required,
2401
+ * or {@link Combinator} where only `name` is required.
2402
+ *
2403
+ * The `name`/`value` properties of this interface can be narrowed with generics.
2404
+ *
2405
+ * @group Option Lists
2406
+ */
2407
+ type FullCombinator<N extends string = string> = WithOptionalClassName<FullOption<N>>;
2408
+ /**
2409
+ * Combinator definition used in the `combinators` prop of {@link QueryBuilder}.
2410
+ * This type is an extension of {@link FullCombinator} where only `name` and
2411
+ * `label` are required.
2412
+ *
2413
+ * The `name`/`value` properties of this interface can be narrowed with generics.
2414
+ *
2415
+ * @group Option Lists
2416
+ */
2417
+ type Combinator<N extends string = string> = WithUnknownIndex<WithOptionalClassName<SetOptional<BaseFullOption<N>, "value">>>;
2418
+ /**
2419
+ * Combinator definition used in the `combinators` prop of {@link QueryBuilder}.
2420
+ * This type is an extension of {@link FullCombinator} where only `value` and
2421
+ * `label` are required.
2422
+ *
2423
+ * The `name`/`value` properties of this interface can be narrowed with generics.
2424
+ *
2425
+ * @group Option Lists
2426
+ */
2427
+ type CombinatorByValue<N extends string = string> = WithUnknownIndex<WithOptionalClassName<SetOptional<BaseFullOption<N>, "name">>>;
2428
+ type ParseNumberMethodName = "enhanced" | "native" | "strict";
2429
+ /**
2430
+ * Parsing algorithms used by {@link parseNumber}.
2431
+ */
2432
+ type ParseNumberMethod = boolean | ParseNumberMethodName;
2433
+ type ParseNumbersModerationLevel = "-limited" | "";
2434
+ /**
2435
+ * Options for the `parseNumbers` prop of {@link QueryBuilder}.
2436
+ */
2437
+ type ParseNumbersPropConfig = boolean | `${ParseNumberMethodName}${ParseNumbersModerationLevel}`;
2438
+ /**
2439
+ * Signature of `accessibleDescriptionGenerator` prop, used by {@link QueryBuilder} to generate
2440
+ * accessible descriptions for each {@link RuleGroup}.
2441
+ */
2442
+ type AccessibleDescriptionGenerator = (props: {
2443
+ path: Path;
2444
+ qbId: string;
2445
+ }) => string;
2446
+ //#endregion
2447
+ //#region src/types/dnd.d.ts
2448
+ type DndDropTargetType = "rule" | "ruleGroup" | "inlineCombinator";
2449
+ type DraggedItem = (RuleType & {
2450
+ path: Path;
2451
+ qbId: string;
2452
+ }) | (RuleGroupTypeAny & {
2453
+ path: Path;
2454
+ qbId: string;
2455
+ });
2456
+ type DropEffect = "move" | "copy";
2457
+ interface DropResult {
2458
+ path: Path;
2459
+ type: DndDropTargetType;
2460
+ dropEffect?: DropEffect;
2461
+ groupItems?: boolean;
2462
+ qbId: string;
2463
+ getQuery: () => RuleGroupTypeAny;
2464
+ dispatchQuery: (query: RuleGroupTypeAny) => void;
2465
+ }
2466
+ interface DragCollection {
2467
+ isDragging: boolean;
2468
+ dragMonitorId: string | symbol;
2469
+ }
2470
+ interface DropCollection {
2471
+ dropNotAllowed: boolean;
2472
+ isOver: boolean;
2473
+ dropMonitorId: string | symbol;
2474
+ dropEffect?: DropEffect;
2475
+ groupItems?: boolean;
2476
+ }
2477
+ //#endregion
2478
+ //#region src/types/export.d.ts
2479
+ /**
2480
+ * Available export formats for {@link formatQuery}.
2481
+ *
2482
+ * @group Export
2483
+ */
2484
+ type ExportFormat = "json" | "sql" | "json_without_ids" | "parameterized" | "parameterized_named" | "mongodb" | "mongodb_query" | "cel" | "jsonlogic" | "spel" | "elasticsearch" | "jsonata" | "natural_language" | "ldap" | "drizzle" | "prisma" | "sequelize";
2485
+ /**
2486
+ * Export formats for {@link formatQuery} that produce objects instead of strings.
2487
+ *
2488
+ * @group Export
2489
+ */
2490
+ type ExportObjectFormats = "parameterized" | "parameterized_named" | "jsonlogic" | "elasticsearch" | "jsonata" | "mongodb_query";
2491
+ /**
2492
+ * Available presets for the "sql" export format.
2493
+ *
2494
+ * @group Export
2495
+ */
2496
+ type SQLPreset = "ansi" | "sqlite" | "postgresql" | "mysql" | "mssql" | "oracle";
2497
+ /**
2498
+ * A map of operators to strings to be used in the output of {@link formatQuery}. If the
2499
+ * result can differ based on the `valueSource`, the key should map to an array where the
2500
+ * second element represents the string to be used when `valueSource` is "field". The first
2501
+ * element will be used in all other cases.
2502
+ *
2503
+ * @group Export
2504
+ */
2505
+ type ExportOperatorMap = Partial<Record<Lowercase<DefaultOperatorName> | DefaultOperatorName, string | [string, string]>>;
2506
+ /**
2507
+ * Options object shape for {@link formatQuery}.
2508
+ *
2509
+ * @group Export
2510
+ */
2511
+ interface FormatQueryOptions {
2512
+ /**
2513
+ * The {@link ExportFormat}.
2514
+ */
2515
+ format?: ExportFormat;
2516
+ /**
2517
+ * This function will be used to process the `operator` from each rule
2518
+ * for query language formats. If not defined, the appropriate
2519
+ * `defaultOperatorProcessor*` for the format will be used.
2520
+ */
2521
+ operatorProcessor?: RuleProcessor;
2522
+ /**
2523
+ * This function will be used to process the `value` from each rule
2524
+ * for query language formats. If not defined, the appropriate
2525
+ * `defaultValueProcessor*` for the format will be used.
2526
+ */
2527
+ valueProcessor?: ValueProcessorLegacy | ValueProcessorByRule;
2528
+ /**
2529
+ * This function will be used to process each rule. If not defined, the appropriate
2530
+ * `defaultRuleProcessor*` for the given format will be used.
2531
+ */
2532
+ ruleProcessor?: RuleProcessor;
2533
+ /**
2534
+ * This function will be used to process each rule group. If not defined, the appropriate
2535
+ * `defaultRuleGroupProcessor*` for the format will be used.
2536
+ *
2537
+ * If this function is defined, it will override the `format` option. This also allows
2538
+ * `formatQuery` to produce completely custom output formats.
2539
+ */
2540
+ ruleGroupProcessor?: RuleGroupProcessor;
2541
+ /**
2542
+ * In the "sql", "parameterized", "parameterized_named", and "jsonata" export
2543
+ * formats, field names will be bracketed by this string. If an array of strings
2544
+ * is passed, field names will be preceded by the first element and
2545
+ * succeeded by the second element.
2546
+ *
2547
+ * Tip: Use `fieldIdentifierSeparator` to bracket identifiers individually within field names.
2548
+ *
2549
+ * @default '' // the empty string
2550
+ *
2551
+ * @example
2552
+ * formatQuery(query, { format: 'sql', quoteFieldNamesWith: '"' })
2553
+ * // `"First name" = 'Steve'`
2554
+ *
2555
+ * @example
2556
+ * formatQuery(query, { format: 'sql', quoteFieldNamesWith: ['[', ']'] })
2557
+ * // "[First name] = 'Steve'"
2558
+ */
2559
+ quoteFieldNamesWith?: string | [string, string];
2560
+ /**
2561
+ * When used in conjunction with the `quoteFieldNamesWith` option, field names will
2562
+ * be split by this string, each part being individually processed as per the rules
2563
+ * of the `quoteFieldNamesWith` configuration. The parts will then be re-joined
2564
+ * by the same string.
2565
+ *
2566
+ * A common value for this option is `'.'`.
2567
+ *
2568
+ * A value of `''` (the empty string) will disable splitting/rejoining.
2569
+ *
2570
+ * @default ''
2571
+ *
2572
+ * @example
2573
+ * formatQuery(query, {
2574
+ * format: 'sql',
2575
+ * quoteFieldNamesWith: ['[', ']'],
2576
+ * fieldIdentifierSeparator: '.',
2577
+ * })
2578
+ * // "[dbo].[Musicians].[First name] = 'Steve'"
2579
+ */
2580
+ fieldIdentifierSeparator?: string;
2581
+ /**
2582
+ * Character to use for quoting string values in the SQL format.
2583
+ * @default `'`
2584
+ */
2585
+ quoteValuesWith?: string;
2586
+ /**
2587
+ * Validator function for the entire query. Can be the same function passed
2588
+ * as `validator` prop to {@link QueryBuilder}.
2589
+ */
2590
+ validator?: QueryValidator;
2591
+ /**
2592
+ * This can be the same {@link FullField} array passed to {@link QueryBuilder}, but
2593
+ * really all you need to provide is the `name` and `validator` for each field.
2594
+ *
2595
+ * The full field object from this array, where the field's identifying property
2596
+ * matches the rule's `field`, will be passed to the rule processor.
2597
+ */
2598
+ fields?: FlexibleOptionList<FullField>;
2599
+ /**
2600
+ * This can be the same `getOperators` function passed to {@link QueryBuilder}.
2601
+ *
2602
+ * The full operator object from this array, where the operator's identifying property
2603
+ * matches the rule's `operator`, will be passed to the rule processor.
2604
+ */
2605
+ getOperators?(field: string, misc: {
2606
+ fieldData: FullField;
2607
+ }): FlexibleOptionList<FullOperator> | null;
2608
+ /**
2609
+ * This string will be inserted in place of invalid groups for non-JSON formats.
2610
+ * Defaults to `'(1 = 1)'` for "sql"/"parameterized"/"parameterized_named" and
2611
+ * `'$and:[{$expr:true}]'` for "mongodb".
2612
+ */
2613
+ fallbackExpression?: string;
2614
+ /**
2615
+ * This string will be placed in front of named parameters (aka bind variables)
2616
+ * when using the "parameterized_named" export format.
2617
+ *
2618
+ * @default ":"
2619
+ */
2620
+ paramPrefix?: string;
2621
+ /**
2622
+ * Maintains the parameter prefix in the `params` object keys when using the
2623
+ * "parameterized_named" export format. Recommended when using SQLite.
2624
+ *
2625
+ * @default false
2626
+ *
2627
+ * @example
2628
+ * console.log(formatQuery(query, {
2629
+ * format: "parameterized_named",
2630
+ * paramPrefix: "$",
2631
+ * paramsKeepPrefix: true
2632
+ * }).params)
2633
+ * // { $firstName: "Stev" }
2634
+ * // Default (`paramsKeepPrefix` is `false`):
2635
+ * // { firstName: "Stev" }
2636
+ */
2637
+ paramsKeepPrefix?: boolean;
2638
+ /**
2639
+ * Renders parameter placeholders as a series of sequential numbers
2640
+ * instead of '?' like the default. This option will respect the
2641
+ * `paramPrefix` option like the 'parameterized_named' format.
2642
+ *
2643
+ * @default false
2644
+ */
2645
+ numberedParams?: boolean;
2646
+ /**
2647
+ * Preserves the order of values for "between" and "notBetween" rules, even if a larger
2648
+ * value comes before a smaller value (which will always evaluate to false).
2649
+ */
2650
+ preserveValueOrder?: boolean;
2651
+ /**
2652
+ * Renders values as either `number`-types or unquoted strings, as
2653
+ * appropriate and when possible. Each `string`-type value is evaluated
2654
+ * against {@link numericRegex} to determine if it can be represented as a
2655
+ * plain numeric value. If so, `parseFloat` is used to convert it to a number.
2656
+ */
2657
+ parseNumbers?: ParseNumbersPropConfig;
2658
+ /**
2659
+ * Any rules where the field is equal to this value will be ignored.
2660
+ *
2661
+ * @default '~'
2662
+ */
2663
+ placeholderFieldName?: string;
2664
+ /**
2665
+ * Any rules where the operator is equal to this value will be ignored.
2666
+ *
2667
+ * @default '~'
2668
+ */
2669
+ placeholderOperatorName?: string;
2670
+ /**
2671
+ * Any rules where the value is equal to this value will be ignored.
2672
+ *
2673
+ * @default '~'
2674
+ */
2675
+ placeholderValueName?: string;
2676
+ /**
2677
+ * Operator to use when concatenating wildcard characters and field names in "sql" format.
2678
+ * The ANSI standard is `||`, while SQL Server uses `+`. MySQL does not implement a concatenation
2679
+ * operator by default, and therefore requires use of the `CONCAT` function.
2680
+ *
2681
+ * If `concatOperator` is set to `"CONCAT"` (case-insensitive), the `CONCAT` function will be
2682
+ * used. Note that Oracle SQL does not support more than two values in the `CONCAT` function,
2683
+ * so this option should not be used in that context. The default setting (`"||"`) is already
2684
+ * compatible with Oracle SQL.
2685
+ *
2686
+ * @default '||'
2687
+ */
2688
+ concatOperator?: "||" | "+" | "CONCAT" | (string & {});
2689
+ /**
2690
+ * Option presets to maximize compatibility with various SQL dialects.
2691
+ */
2692
+ preset?: SQLPreset;
2693
+ /**
2694
+ * Map of operators to their translations for the "natural_language" format. If the
2695
+ * result can differ based on the `valueSource`, the key should map to an array where the
2696
+ * second element represents the string to be used when `valueSource` is "field". The first
2697
+ * element will be used in all other cases.
2698
+ */
2699
+ operatorMap?: ExportOperatorMap;
2700
+ /**
2701
+ * [Constituent word order](https://en.wikipedia.org/wiki/Word_order#Constituent_word_orders)
2702
+ * for the "natural_language" format. Can be abbreviated like "SVO" or spelled out like
2703
+ * "subject-verb-object".
2704
+ *
2705
+ * - Subject = field
2706
+ * - Verb = operator
2707
+ * - Object = value
2708
+ */
2709
+ wordOrder?: ConstituentWordOrderString | Lowercase<ConstituentWordOrderString> | ({} & string);
2710
+ /**
2711
+ * Translatable strings used by the "natural_language" format.
2712
+ */
2713
+ translations?: Partial<Record<NLTranslationKey, string>>;
2714
+ context?: Record<string, any>;
2715
+ }
2716
+ /**
2717
+ * Options object for {@link ValueProcessorByRule} functions.
2718
+ *
2719
+ * @group Export
2720
+ */
2721
+ interface ValueProcessorOptions extends FormatQueryOptions {
2722
+ valueProcessor?: ValueProcessorByRule;
2723
+ escapeQuotes?: boolean;
2724
+ /**
2725
+ * The full field object, if `fields` was provided in the
2726
+ * {@link formatQuery} options parameter.
2727
+ */
2728
+ fieldData?: FullField;
2729
+ /**
2730
+ * Included for the "parameterized_named" format only. Keys of this object represent
2731
+ * field names and values represent the current list of parameter names for that
2732
+ * field based on the query rules processed up to that point. Use this list to
2733
+ * ensure that parameter names generated by the custom rule processor are unique.
2734
+ */
2735
+ fieldParamNames?: Record<string, string[]>;
2736
+ /**
2737
+ * Included for the "parameterized_named" format only. Call this function with a
2738
+ * field name to get a unique parameter name, as yet unused during query processing.
2739
+ */
2740
+ getNextNamedParam?: (field: string) => string;
2741
+ /**
2742
+ * Additional prefix and suffix characters to wrap the value in. Useful for augmenting
2743
+ * the default value processor results with special syntax (e.g., for dates or function
2744
+ * calls).
2745
+ */
2746
+ wrapValueWith?: [string, string];
2747
+ /**
2748
+ * Parse numbers in the rule value.
2749
+ *
2750
+ * @default false
2751
+ */
2752
+ parseNumbers?: boolean;
2753
+ }
2754
+ /**
2755
+ * Options object curated by {@link formatQuery} and passed to a {@link RuleGroupProcessor}.
2756
+ *
2757
+ * @group Export
2758
+ */
2759
+ interface FormatQueryFinalOptions extends Required<Except<FormatQueryOptions, "context" | "valueProcessor" | "validator" | "placeholderValueName" | "ruleGroupProcessor" | "parseNumbers">> {
2760
+ fields: FullOptionList<FullField>;
2761
+ getParseNumberBoolean: (inputType?: InputType | null) => boolean | undefined;
2762
+ parseNumbers?: ParseNumbersPropConfig | undefined;
2763
+ placeholderValueName?: string | undefined;
2764
+ valueProcessor: ValueProcessorByRule;
2765
+ validator?: QueryValidator;
2766
+ validateRule: FormatQueryValidateRule;
2767
+ validationMap: ValidationMap;
2768
+ context?: Record<string, unknown>;
2769
+ }
2770
+ /**
2771
+ * Function that produces a processed value for a given {@link RuleType}.
2772
+ *
2773
+ * @group Export
2774
+ */
2775
+ type ValueProcessorByRule = (rule: RuleType, options?: ValueProcessorOptions) => string;
2776
+ /**
2777
+ * Function that produces a processed value for a given `field`, `operator`, `value`,
2778
+ * and `valueSource`.
2779
+ *
2780
+ * @group Export
2781
+ */
2782
+ type ValueProcessorLegacy = (field: string, operator: string, value: any, valueSource?: ValueSource) => string;
2783
+ /**
2784
+ * @group Export
2785
+ */
2786
+ type ValueProcessor = ValueProcessorLegacy;
2787
+ /**
2788
+ * Function to produce a result that {@link formatQuery} uses when processing a
2789
+ * {@link RuleType} object.
2790
+ *
2791
+ * See the default rule processor for each format to know what type to return.
2792
+ * | Format | Default rule processor |
2793
+ * | ------------------------ | ----------------------------------------- |
2794
+ * | `sql` | {@link defaultRuleProcessorSQL} |
2795
+ * | `parameterized` | {@link defaultRuleProcessorParameterized} |
2796
+ * | `parameterized_named` | {@link defaultRuleProcessorParameterized} |
2797
+ * | `mongodb` _(deprecated)_ | {@link defaultRuleProcessorMongoDB} |
2798
+ * | `mongodb_query` | {@link defaultRuleProcessorMongoDBQuery} |
2799
+ * | `cel` | {@link defaultRuleProcessorCEL} |
2800
+ * | `spel` | {@link defaultRuleProcessorSpEL} |
2801
+ * | `jsonlogic` | {@link defaultRuleProcessorJsonLogic} |
2802
+ * | `elasticsearch` | {@link defaultRuleProcessorElasticSearch} |
2803
+ * | `jsonata` | {@link defaultRuleProcessorJSONata} |
2804
+ *
2805
+ * @group Export
2806
+ */
2807
+ type RuleProcessor = (rule: RuleType, options?: ValueProcessorOptions, meta?: {
2808
+ processedParams?: Record<string, any> | any[];
2809
+ context?: Record<string, any>;
2810
+ }) => any;
2811
+ /**
2812
+ * Function to produce a result that {@link formatQuery} uses when processing a
2813
+ * {@link RuleGroupType} or {@link RuleGroupTypeIC} object.
2814
+ *
2815
+ * See the default rule group processor for each format to know what type to return.
2816
+ * | Format | Default rule group processor |
2817
+ * | ------------------------ | ---------------------------------------------- |
2818
+ * | `sql` | {@link defaultRuleGroupProcessorSQL} |
2819
+ * | `parameterized` | {@link defaultRuleGroupProcessorParameterized} |
2820
+ * | `parameterized_named` | {@link defaultRuleGroupProcessorParameterized} |
2821
+ * | `mongodb` _(deprecated)_ | {@link defaultRuleGroupProcessorMongoDB} |
2822
+ * | `mongodb_query` | {@link defaultRuleGroupProcessorMongoDBQuery} |
2823
+ * | `cel` | {@link defaultRuleGroupProcessorCEL} |
2824
+ * | `spel` | {@link defaultRuleGroupProcessorSpEL} |
2825
+ * | `jsonlogic` | {@link defaultRuleGroupProcessorJsonLogic} |
2826
+ * | `elasticsearch` | {@link defaultRuleGroupProcessorElasticSearch} |
2827
+ * | `jsonata` | {@link defaultRuleGroupProcessorJSONata} |
2828
+ *
2829
+ * @group Export
2830
+ */
2831
+ type RuleGroupProcessor<TResult = unknown> = (ruleGroup: RuleGroupTypeAny, options: FormatQueryFinalOptions, meta?: {
2832
+ processedParams?: Record<string, any> | any[];
2833
+ context?: Record<string, any>;
2834
+ }) => TResult;
2835
+ /**
2836
+ * Rule validator for {@link formatQuery}.
2837
+ *
2838
+ * @group Export
2839
+ */
2840
+ type FormatQueryValidateRule = (rule: RuleType) => readonly [boolean | ValidationResult | undefined, RuleValidator | undefined];
2841
+ /**
2842
+ * Object produced by {@link formatQuery} for the `"parameterized"` format.
2843
+ *
2844
+ * @group Export
2845
+ */
2846
+ interface ParameterizedSQL {
2847
+ /** The SQL `WHERE` clause fragment with `?` placeholders for each value. */
2848
+ sql: string;
2849
+ /**
2850
+ * Parameter values in the same order their respective placeholders
2851
+ * appear in the `sql` string.
2852
+ */
2853
+ params: any[];
2854
+ }
2855
+ /**
2856
+ * Object produced by {@link formatQuery} for the `"parameterized_named"` format.
2857
+ *
2858
+ * @group Export
2859
+ */
2860
+ interface ParameterizedNamedSQL {
2861
+ /** The SQL `WHERE` clause fragment with bind variable placeholders for each value. */
2862
+ sql: string;
2863
+ /**
2864
+ * Map of bind variable names from the `sql` string to the associated values.
2865
+ */
2866
+ params: Record<string, any>;
2867
+ }
2868
+ /**
2869
+ * @group Export
2870
+ */
2871
+ interface RQBJsonLogicStartsWith {
2872
+ startsWith: [RQBJsonLogic, RQBJsonLogic, ...RQBJsonLogic[]];
2873
+ }
2874
+ /**
2875
+ * @group Export
2876
+ */
2877
+ interface RQBJsonLogicEndsWith {
2878
+ endsWith: [RQBJsonLogic, RQBJsonLogic, ...RQBJsonLogic[]];
2879
+ }
2880
+ /**
2881
+ * @group Export
2882
+ */
2883
+ interface RQBJsonLogicVar {
2884
+ var: string;
2885
+ }
2886
+ /**
2887
+ * JsonLogic rule object with additional operators generated by {@link formatQuery}
2888
+ * and accepted by {@link parseJsonLogic!parseJsonLogic}.
2889
+ *
2890
+ * @group Export
2891
+ */
2892
+ type RQBJsonLogic = RulesLogic<RQBJsonLogicStartsWith | RQBJsonLogicEndsWith>;
2893
+ /**
2894
+ * Constituent word order (as array) for the "natural_language" format.
2895
+ *
2896
+ * - S (subject) = field
2897
+ * - V (verb) = operator
2898
+ * - O (object) = value
2899
+ *
2900
+ * @group Export
2901
+ */
2902
+ type ConstituentWordOrder = ["S", "V", "O"] | ["S", "O", "V"] | ["O", "S", "V"] | ["O", "V", "S"] | ["V", "S", "O"] | ["V", "O", "S"];
2903
+ /**
2904
+ * Constituent word order (as string) for the "natural_language" format.
2905
+ *
2906
+ * - S (subject) = field
2907
+ * - V (verb) = operator
2908
+ * - O (object) = value
2909
+ *
2910
+ * @group Export
2911
+ */
2912
+ type ConstituentWordOrderString = "SVO" | "SOV" | "OSV" | "OVS" | "VSO" | "VOS";
2913
+ type RepeatStrings<S extends string[], Depth extends number[] = []> = Depth["length"] extends 2 ? "" : "" | `_${S[number]}${RepeatStrings<S, [...Depth, 1]>}`;
2914
+ type ZeroOrMoreGroupVariants = RepeatStrings<["xor", "not"]>;
2915
+ /**
2916
+ * Rule group condition identifier for the "natural_language" format.
2917
+ *
2918
+ * @group Export
2919
+ */
2920
+ type GroupVariantCondition = "not" | "xor";
2921
+ /**
2922
+ * Keys for the `translations` config object used by the "natural_language" format.
2923
+ *
2924
+ * @group Export
2925
+ */
2926
+ type NLTranslationKey = "and" | "or" | "true" | "false" | `groupPrefix${ZeroOrMoreGroupVariants}` | `groupSuffix${ZeroOrMoreGroupVariants}`;
2927
+ /**
2928
+ * `translations` config object for "natural_language" format.
2929
+ *
2930
+ * @group Export
2931
+ */
2932
+ type NLTranslations = Partial<Record<NLTranslationKey, string>>;
2933
+ //#endregion
2934
+ //#region src/types/props.d.ts
2935
+ /**
2936
+ * Base interface for all rule subcomponents.
2937
+ *
2938
+ * @group Props
2939
+ */
2940
+ interface CommonRuleSubComponentProps {
2941
+ rule: RuleType;
2942
+ }
2943
+ /**
2944
+ * Classnames applied to each component.
2945
+ *
2946
+ * @group Props
2947
+ */
2948
+ interface Classnames {
2949
+ /**
2950
+ * Classnames applied to the root `<div>` element.
2951
+ */
2952
+ queryBuilder: Classname;
2953
+ /**
2954
+ * Classnames applied to the `<div>` containing the RuleGroup.
2955
+ */
2956
+ ruleGroup: Classname;
2957
+ /**
2958
+ * Classnames applied to the `<div>` containing the RuleGroup header controls.
2959
+ */
2960
+ header: Classname;
2961
+ /**
2962
+ * Classnames applied to the `<div>` containing the RuleGroup child rules/groups.
2963
+ */
2964
+ body: Classname;
2965
+ /**
2966
+ * Classnames applied to the `<select>` control for combinators.
2967
+ */
2968
+ combinators: Classname;
2969
+ /**
2970
+ * Classnames applied to the `<button>` to add a Rule.
2971
+ */
2972
+ addRule: Classname;
2973
+ /**
2974
+ * Classnames applied to the `<button>` to add a RuleGroup.
2975
+ */
2976
+ addGroup: Classname;
2977
+ /**
2978
+ * Classnames applied to the `<button>` to clone a Rule.
2979
+ */
2980
+ cloneRule: Classname;
2981
+ /**
2982
+ * Classnames applied to the `<button>` to clone a RuleGroup.
2983
+ */
2984
+ cloneGroup: Classname;
2985
+ /**
2986
+ * Classnames applied to the `<button>` to remove a RuleGroup.
2987
+ */
2988
+ removeGroup: Classname;
2989
+ /**
2990
+ * Classnames applied to the `<div>` containing the Rule.
2991
+ */
2992
+ rule: Classname;
2993
+ /**
2994
+ * Classnames applied to the `<select>` control for fields.
2995
+ */
2996
+ fields: Classname;
2997
+ /**
2998
+ * Classnames applied to the `<select>` control for match modes.
2999
+ */
3000
+ matchMode: Classname;
3001
+ /**
3002
+ * Classnames applied to the `<input>` for match thresholds.
3003
+ */
3004
+ matchThreshold: Classname;
3005
+ /**
3006
+ * Classnames applied to the `<select>` control for operators.
3007
+ */
3008
+ operators: Classname;
3009
+ /**
3010
+ * Classnames applied to the `<input>` for the rule value.
3011
+ */
3012
+ value: Classname;
3013
+ /**
3014
+ * Classnames applied to the `<button>` to remove a Rule.
3015
+ */
3016
+ removeRule: Classname;
3017
+ /**
3018
+ * Classnames applied to the `<label>` on the "not" toggle.
3019
+ */
3020
+ notToggle: Classname;
3021
+ /**
3022
+ * Classnames applied to the `<span>` handle for dragging rules/groups.
3023
+ */
3024
+ shiftActions: Classname;
3025
+ /**
3026
+ * Classnames applied to the `<span>` handle for dragging rules/groups.
3027
+ */
3028
+ dragHandle: Classname;
3029
+ /**
3030
+ * Classnames applied to the `<button>` to lock/disable a Rule.
3031
+ */
3032
+ lockRule: Classname;
3033
+ /**
3034
+ * Classnames applied to the `<button>` to lock/disable a RuleGroup.
3035
+ */
3036
+ lockGroup: Classname;
3037
+ /**
3038
+ * Classnames applied to the `<select>` control for value sources.
3039
+ */
3040
+ valueSource: Classname;
3041
+ /**
3042
+ * Classnames applied to all action elements.
3043
+ */
3044
+ actionElement: Classname;
3045
+ /**
3046
+ * Classnames applied to all select elements.
3047
+ */
3048
+ valueSelector: Classname;
3049
+ /**
3050
+ * Classname(s) applied to inline combinator elements.
3051
+ */
3052
+ betweenRules: Classname;
3053
+ /**
3054
+ * Classname(s) applied to valid rules and groups.
3055
+ */
3056
+ valid: Classname;
3057
+ /**
3058
+ * Classname(s) applied to invalid rules and groups.
3059
+ */
3060
+ invalid: Classname;
3061
+ /**
3062
+ * Classname(s) applied to rules and groups while being dragged.
3063
+ */
3064
+ dndDragging: Classname;
3065
+ /**
3066
+ * Classname(s) applied to rules and groups hovered over by a dragged element.
3067
+ */
3068
+ dndOver: Classname;
3069
+ /**
3070
+ * Classname(s) applied to rules and groups hovered over by a dragged element
3071
+ * when the drop effect is "copy" (modifier key is pressed).
3072
+ */
3073
+ dndCopy: Classname;
3074
+ /**
3075
+ * Classname(s) applied to rules and groups hovered over by a dragged element
3076
+ * when the Ctrl key is pressed, indicating the items will form a new group.
3077
+ */
3078
+ dndGroup: Classname;
3079
+ /**
3080
+ * Classname(s) applied to rules and groups that cannot accept a drop from
3081
+ * the dragged element hovering over it.
3082
+ */
3083
+ dndDropNotAllowed: Classname;
3084
+ /**
3085
+ * Classname(s) applied to disabled elements.
3086
+ */
3087
+ disabled: Classname;
3088
+ /**
3089
+ * Classname(s) applied to each element in a series of value editors.
3090
+ */
3091
+ valueListItem: Classname;
3092
+ /**
3093
+ * Not applied, but see CSS styles.
3094
+ */
3095
+ branches: Classname;
3096
+ /**
3097
+ * Classname(s) rules that render a subquery.
3098
+ */
3099
+ hasSubQuery: Classname;
3100
+ }
3101
+ /**
3102
+ * Functions included in the `actions` prop passed to every subcomponent.
3103
+ *
3104
+ * @group Props
3105
+ */
3106
+ interface QueryActions {
3107
+ onGroupAdd(group: RuleGroupTypeAny, parentPath: Path, context?: any): void;
3108
+ onGroupRemove(path: Path): void;
3109
+ onPropChange(prop: Exclude<keyof RuleType | keyof RuleGroupType, "id" | "path">, value: any, path: Path, context?: any): void;
3110
+ onRuleAdd(rule: RuleType, parentPath: Path, context?: any): void;
3111
+ onRuleRemove(path: Path): void;
3112
+ moveRule(oldPath: Path, newPath: Path | "up" | "down", clone?: boolean, context?: any): void;
3113
+ groupRule(sourcePath: Path, targetPath: Path, clone?: boolean, context?: any): void;
3114
+ }
3115
+ //#endregion
3116
+ //#region src/defaults.d.ts
3117
+ /**
3118
+ * @group Defaults
3119
+ */
3120
+ declare const defaultPlaceholderName = "~";
3121
+ /**
3122
+ * @group Defaults
3123
+ */
3124
+ declare const defaultPlaceholderLabel = "------";
3125
+ /**
3126
+ * Default `name` for placeholder option in the `fields` array.
3127
+ *
3128
+ * @group Defaults
3129
+ */
3130
+ declare const defaultPlaceholderFieldName: typeof defaultPlaceholderName;
3131
+ /**
3132
+ * Default `label` for placeholder option in the `fields` array.
3133
+ *
3134
+ * @group Defaults
3135
+ */
3136
+ declare const defaultPlaceholderFieldLabel: typeof defaultPlaceholderLabel;
3137
+ /**
3138
+ * Default `label` for placeholder option group in the `fields` array.
3139
+ *
3140
+ * @group Defaults
3141
+ */
3142
+ declare const defaultPlaceholderFieldGroupLabel: typeof defaultPlaceholderLabel;
3143
+ /**
3144
+ * Default `name` for placeholder option in the `operators` array.
3145
+ *
3146
+ * @group Defaults
3147
+ */
3148
+ declare const defaultPlaceholderOperatorName: typeof defaultPlaceholderName;
3149
+ /**
3150
+ * Default `label` for placeholder option in the `operators` array.
3151
+ *
3152
+ * @group Defaults
3153
+ */
3154
+ declare const defaultPlaceholderOperatorLabel: typeof defaultPlaceholderLabel;
3155
+ /**
3156
+ * Default `label` for placeholder option group in the `operators` array.
3157
+ *
3158
+ * @group Defaults
3159
+ */
3160
+ declare const defaultPlaceholderOperatorGroupLabel: typeof defaultPlaceholderLabel;
3161
+ /**
3162
+ * Default `name` for placeholder option in the `values` array.
3163
+ *
3164
+ * @group Defaults
3165
+ */
3166
+ declare const defaultPlaceholderValueName: typeof defaultPlaceholderName;
3167
+ /**
3168
+ * Default `label` for placeholder option in the `values` array.
3169
+ *
3170
+ * @group Defaults
3171
+ */
3172
+ declare const defaultPlaceholderValueLabel: typeof defaultPlaceholderLabel;
3173
+ /**
3174
+ * Default `label` for placeholder option group in the `values` array.
3175
+ *
3176
+ * @group Defaults
3177
+ */
3178
+ declare const defaultPlaceholderValueGroupLabel: typeof defaultPlaceholderLabel;
3179
+ /**
3180
+ * Default character used to `.join` and `.split` arrays.
3181
+ *
3182
+ * @group Defaults
3183
+ */
3184
+ declare const defaultJoinChar = ",";
3185
+ type DefaultOperators = StringUnionToFullOptionArray<DefaultOperatorName>;
3186
+ declare const defaultOperatorLabelMap: Record<DefaultOperatorName, string>;
3187
+ declare const defaultCombinatorLabelMap: Record<DefaultCombinatorNameExtended, string>;
3188
+ /**
3189
+ * Default operator list.
3190
+ *
3191
+ * @group Defaults
3192
+ */
3193
+ declare const defaultOperators: DefaultOperators;
3194
+ /**
3195
+ * Map of default operators to their respective opposite/negating operators.
3196
+ *
3197
+ * @group Defaults
3198
+ */
3199
+ declare const defaultOperatorNegationMap: Record<DefaultOperatorName, DefaultOperatorName>;
3200
+ type DefaultCombinators = StringUnionToFullOptionArray<DefaultCombinatorName>;
3201
+ /**
3202
+ * Default combinator list.
3203
+ *
3204
+ * @group Defaults
3205
+ */
3206
+ declare const defaultCombinators: DefaultCombinators;
3207
+ type DefaultCombinatorsExtended = StringUnionToFullOptionArray<DefaultCombinatorNameExtended>;
3208
+ /**
3209
+ * Default combinator list, with `XOR` added.
3210
+ *
3211
+ * @group Defaults
3212
+ */
3213
+ declare const defaultCombinatorsExtended: DefaultCombinatorsExtended;
3214
+ type DefaultMatchModes = StringUnionToFullOptionArray<MatchMode>;
3215
+ /**
3216
+ * Default match modes.
3217
+ *
3218
+ * @group Defaults
3219
+ */
3220
+ declare const defaultMatchModes: DefaultMatchModes;
3221
+ /**
3222
+ * Standard classnames applied to each component.
3223
+ *
3224
+ * @group Defaults
3225
+ */
3226
+ declare const standardClassnames: {
3227
+ readonly queryBuilder: "queryBuilder";
3228
+ readonly ruleGroup: "ruleGroup";
3229
+ readonly header: "ruleGroup-header";
3230
+ readonly body: "ruleGroup-body";
3231
+ readonly combinators: "ruleGroup-combinators";
3232
+ readonly addRule: "ruleGroup-addRule";
3233
+ readonly addGroup: "ruleGroup-addGroup";
3234
+ readonly cloneRule: "rule-cloneRule";
3235
+ readonly cloneGroup: "ruleGroup-cloneGroup";
3236
+ readonly removeGroup: "ruleGroup-remove";
3237
+ readonly notToggle: "ruleGroup-notToggle";
3238
+ readonly rule: "rule";
3239
+ readonly fields: "rule-fields";
3240
+ readonly matchMode: "rule-matchMode";
3241
+ readonly matchThreshold: "rule-matchThreshold";
3242
+ readonly operators: "rule-operators";
3243
+ readonly value: "rule-value";
3244
+ readonly removeRule: "rule-remove";
3245
+ readonly betweenRules: "betweenRules";
3246
+ readonly valid: "queryBuilder-valid";
3247
+ readonly invalid: "queryBuilder-invalid";
3248
+ readonly shiftActions: "shiftActions";
3249
+ readonly dndDragging: "dndDragging";
3250
+ readonly dndOver: "dndOver";
3251
+ readonly dndCopy: "dndCopy";
3252
+ readonly dndGroup: "dndGroup";
3253
+ readonly dndDropNotAllowed: "dndDropNotAllowed";
3254
+ readonly dragHandle: "queryBuilder-dragHandle";
3255
+ readonly disabled: "queryBuilder-disabled";
3256
+ readonly lockRule: "rule-lock";
3257
+ readonly lockGroup: "ruleGroup-lock";
3258
+ readonly valueSource: "rule-valueSource";
3259
+ readonly valueListItem: "rule-value-list-item";
3260
+ readonly branches: "queryBuilder-branches";
3261
+ readonly justified: "queryBuilder-justified";
3262
+ readonly hasSubQuery: "rule-hasSubQuery";
3263
+ };
3264
+ /**
3265
+ * Default classnames for each component.
3266
+ *
3267
+ * @group Defaults
3268
+ */
3269
+ declare const defaultControlClassnames: Classnames;
3270
+ /**
3271
+ * Default reason codes for a group being invalid.
3272
+ *
3273
+ * @group Defaults
3274
+ */
3275
+ declare const groupInvalidReasons: {
3276
+ readonly empty: "empty";
3277
+ readonly invalidCombinator: "invalid combinator";
3278
+ readonly invalidIndependentCombinators: "invalid independent combinators";
3279
+ };
3280
+ /**
3281
+ * Component identifiers for testing.
3282
+ *
3283
+ * @group Defaults
3284
+ */
3285
+ declare const TestID: {
3286
+ readonly rule: "rule";
3287
+ readonly ruleGroup: "rule-group";
3288
+ readonly inlineCombinator: "inline-combinator";
3289
+ readonly addGroup: "add-group";
3290
+ readonly removeGroup: "remove-group";
3291
+ readonly cloneGroup: "clone-group";
3292
+ readonly cloneRule: "clone-rule";
3293
+ readonly addRule: "add-rule";
3294
+ readonly removeRule: "remove-rule";
3295
+ readonly combinators: "combinators";
3296
+ readonly fields: "fields";
3297
+ readonly operators: "operators";
3298
+ readonly valueEditor: "value-editor";
3299
+ readonly notToggle: "not-toggle";
3300
+ readonly shiftActions: "shift-actions";
3301
+ readonly dragHandle: "drag-handle";
3302
+ readonly lockRule: "lock-rule";
3303
+ readonly lockGroup: "lock-group";
3304
+ readonly valueSourceSelector: "value-source-selector";
3305
+ readonly matchModeEditor: "match-mode-editor";
3306
+ };
3307
+ declare const LogType: {
3308
+ readonly parentPathDisabled: "action aborted: parent path disabled";
3309
+ readonly pathDisabled: "action aborted: path is disabled";
3310
+ readonly queryUpdate: "query updated";
3311
+ readonly onAddRuleFalse: "onAddRule callback returned false";
3312
+ readonly onAddGroupFalse: "onAddGroup callback returned false";
3313
+ readonly onGroupRuleFalse: "onGroupRule callback returned false";
3314
+ readonly onGroupGroupFalse: "onGroupGroup callback returned false";
3315
+ readonly onMoveRuleFalse: "onMoveRule callback returned false";
3316
+ readonly onMoveGroupFalse: "onMoveGroup callback returned false";
3317
+ readonly onRemoveFalse: "onRemove callback returned false";
3318
+ readonly add: "rule or group added";
3319
+ readonly remove: "rule or group removed";
3320
+ readonly update: "rule or group updated";
3321
+ readonly move: "rule or group moved";
3322
+ readonly group: "rule or group grouped with another";
3323
+ };
3324
+ /**
3325
+ * The {@link Path} of the root group.
3326
+ *
3327
+ * @group Defaults
3328
+ */
3329
+ declare const rootPath: Path;
3330
+ //#endregion
3331
+ //#region src/utils/arrayUtils.d.ts
3332
+ /**
3333
+ * Splits a string by a given character (see {@link defaultJoinChar}). Escaped characters
3334
+ * (characters preceded by a backslash) will not apply to the split, and the backslash will
3335
+ * be removed in the array element. Inverse of {@link joinWith}.
3336
+ *
3337
+ * @example
3338
+ * splitBy('this\\,\\,that,,the other,,,\\,')
3339
+ * // or
3340
+ * splitBy('this\\,\\,that,,the other,,,\\,', ',')
3341
+ * // would return
3342
+ * ['this,,that', '', 'the other', '', '', ',']
3343
+ */
3344
+ declare const splitBy: (str?: string, splitChar?: string) => string[];
3345
+ /**
3346
+ * Joins an array of strings using the given character (see {@link defaultJoinChar}). When
3347
+ * the given character appears in an array element, a backslash will be added just before it
3348
+ * to distinguish it from the join character. Effectively the inverse of {@link splitBy}.
3349
+ *
3350
+ * TIP: The join character can actually be a string of any length. Only the first character
3351
+ * will be searched for in the array elements and preceded by a backslash.
3352
+ *
3353
+ * @example
3354
+ * joinWith(['this,,that', '', 'the other', '', '', ','], ', ')
3355
+ * // would return
3356
+ * 'this\\,\\,that, , the other, , , \\,'
3357
+ */
3358
+ declare const joinWith: (strArr: any[], joinChar?: string) => string;
3359
+ /**
3360
+ * Trims the value if it is a string. Otherwise returns the value as is.
3361
+ */
3362
+ declare const trimIfString: (val: any) => any;
3363
+ /**
3364
+ * Splits a string by comma then trims each element. Arrays are returned as is except
3365
+ * any string elements are trimmed.
3366
+ */
3367
+ declare const toArray: (v: any, {
3368
+ retainEmptyStrings
3369
+ }?: {
3370
+ retainEmptyStrings?: boolean;
3371
+ }) => any[];
3372
+ /**
3373
+ * Determines if an array is free of `null`/`undefined`.
3374
+ */
3375
+ declare const nullFreeArray: <T>(arr: T[]) => arr is Exclude<T, null>[];
3376
+ //#endregion
3377
+ //#region src/utils/clsx.d.ts
3378
+ type ClassDictionary = Record<string, any>;
3379
+ type ClassValue = ClassArray | ClassDictionary | string | number | bigint | null | boolean | undefined;
3380
+ type ClassArray = ClassValue[];
3381
+ declare function clsx(...args: ClassValue[]): string;
3382
+ //#endregion
3383
+ //#region src/utils/convertQuery.d.ts
3384
+ /**
3385
+ * Converts a {@link RuleGroupTypeIC} to {@link RuleGroupType}.
3386
+ *
3387
+ * This function is idempotent: {@link RuleGroupType} queries will be
3388
+ * returned as-is.
3389
+ *
3390
+ * @group Query Tools
3391
+ */
3392
+ declare const convertFromIC: <RG extends RuleGroupType = RuleGroupType>(rg: RuleGroupTypeAny) => RG;
3393
+ /**
3394
+ * Converts a {@link RuleGroupType} to {@link RuleGroupTypeIC}.
3395
+ *
3396
+ * This function is idempotent: {@link RuleGroupTypeIC} queries will be
3397
+ * returned as-is.
3398
+ *
3399
+ * @group Query Tools
3400
+ */
3401
+ declare const convertToIC: <RGIC extends RuleGroupTypeIC = RuleGroupTypeIC>(rg: RuleGroupTypeAny) => RGIC;
3402
+ /**
3403
+ * Converts a {@link RuleGroupType} to {@link RuleGroupTypeIC}. For a more explicit
3404
+ * operation, use {@link convertToIC}.
3405
+ *
3406
+ * @group Query Tools
3407
+ */
3408
+ declare function convertQuery(query: RuleGroupType): RuleGroupTypeIC;
3409
+ /**
3410
+ * Converts a {@link RuleGroupTypeIC} to {@link RuleGroupType}. For a more explicit
3411
+ * operation, use {@link convertFromIC}.
3412
+ *
3413
+ * @group Query Tools
3414
+ */
3415
+ declare function convertQuery(query: RuleGroupTypeIC): RuleGroupType;
3416
+ //#endregion
3417
+ //#region src/utils/defaultValidator.d.ts
3418
+ /**
3419
+ * This is an example validation function you can pass to {@link QueryBuilder} in the
3420
+ * `validator` prop. It assumes that you want to validate groups, and has a no-op
3421
+ * for validating rules which you can replace with your own implementation.
3422
+ */
3423
+ declare const defaultValidator: QueryValidator;
3424
+ //#endregion
3425
+ //#region src/utils/filterFieldsByComparator.d.ts
3426
+ /**
3427
+ * For a given {@link FullField}, returns the `fields` list filtered for
3428
+ * other fields that match by `comparator`. Only fields *other than the
3429
+ * one in question* will ever be included, even if `comparator` is `null`
3430
+ * or `undefined`. If `comparator` is a string, fields with the same value
3431
+ * for that property will be included. If `comparator` is a function, each
3432
+ * field will be passed to the function along with the `operator` and fields
3433
+ * for which the function returns `true` will be included.
3434
+ *
3435
+ * @group Option Lists
3436
+ */
3437
+ declare const filterFieldsByComparator: (field: FullField, fields: OptionList<FullField>, operator: string) => FullField[] | {
3438
+ options: WithUnknownIndex<FullField>[];
3439
+ label: string;
3440
+ }[];
3441
+ //#endregion
3442
+ //#region src/utils/formatQuery/defaultRuleProcessorCEL.d.ts
3443
+ /**
3444
+ * Default rule processor used by {@link formatQuery} for "cel" format.
3445
+ *
3446
+ * @group Export
3447
+ */
3448
+ declare const defaultRuleProcessorCEL: RuleProcessor;
3449
+ //#endregion
3450
+ //#region src/utils/formatQuery/defaultRuleProcessorMongoDB.d.ts
3451
+ /**
3452
+ * Default rule processor used by {@link formatQuery} for "mongodb" format.
3453
+ *
3454
+ * Note that the "mongodb" format is deprecated in favor of the "mongodb_query" format.
3455
+ *
3456
+ * @group Export
3457
+ */
3458
+ declare const defaultRuleProcessorMongoDB: RuleProcessor;
3459
+ //#endregion
3460
+ //#region src/utils/formatQuery/defaultRuleProcessorSpEL.d.ts
3461
+ /**
3462
+ * Default rule processor used by {@link formatQuery} for "spel" format.
3463
+ *
3464
+ * @group Export
3465
+ */
3466
+ declare const defaultRuleProcessorSpEL: RuleProcessor;
3467
+ //#endregion
3468
+ //#region src/utils/formatQuery/defaultValueProcessorByRule.d.ts
3469
+ /**
3470
+ * Default value processor used by {@link formatQuery} for "sql" format.
3471
+ *
3472
+ * @group Export
3473
+ */
3474
+ declare const defaultValueProcessorByRule: ValueProcessorByRule;
3475
+ //#endregion
3476
+ //#region src/utils/formatQuery/defaultRuleGroupProcessorCEL.d.ts
3477
+ /**
3478
+ * Rule group processor used by {@link formatQuery} for "cel" format.
3479
+ *
3480
+ * @group Export
3481
+ */
3482
+ declare const defaultRuleGroupProcessorCEL: RuleGroupProcessor<string>;
3483
+ //#endregion
3484
+ //#region src/utils/formatQuery/defaultRuleGroupProcessorDrizzle.d.ts
3485
+ /**
3486
+ * Default rule group processor used by {@link formatQuery} for the "drizzle" format. The returned
3487
+ * function can be assigned to the `where` property in the Drizzle relational queries API.
3488
+ *
3489
+ * @example
3490
+ * const where = formatQuery(query, 'drizzle');
3491
+ * const results = db.query.users.findMany({ where });
3492
+ *
3493
+ * @returns Function that takes a Drizzle table config and an object of Drizzle operators.
3494
+ *
3495
+ * @group Export
3496
+ */
3497
+ declare const defaultRuleGroupProcessorDrizzle: RuleGroupProcessor<(columns: Record<string, Column> | Table, drizzleOperators: Operators) => SQL | undefined>;
3498
+ //#endregion
3499
+ //#region src/utils/formatQuery/defaultRuleGroupProcessorElasticSearch.d.ts
3500
+ /**
3501
+ * Rule group processor used by {@link formatQuery} for "elasticsearch" format.
3502
+ *
3503
+ * @group Export
3504
+ */
3505
+ declare const defaultRuleGroupProcessorElasticSearch: RuleGroupProcessor<Record<string, unknown>>;
3506
+ //#endregion
3507
+ //#region src/utils/formatQuery/defaultRuleGroupProcessorJSONata.d.ts
3508
+ /**
3509
+ * Rule group processor used by {@link formatQuery} for "jsonata" format.
3510
+ *
3511
+ * @group Export
3512
+ */
3513
+ declare const defaultRuleGroupProcessorJSONata: RuleGroupProcessor<string>;
3514
+ //#endregion
3515
+ //#region src/utils/formatQuery/defaultRuleGroupProcessorJsonLogic.d.ts
3516
+ /**
3517
+ * Rule group processor used by {@link formatQuery} for "jsonlogic" format.
3518
+ *
3519
+ * @group Export
3520
+ */
3521
+ declare const defaultRuleGroupProcessorJsonLogic: RuleGroupProcessor<RQBJsonLogic>;
3522
+ //#endregion
3523
+ //#region src/utils/formatQuery/defaultRuleGroupProcessorLDAP.d.ts
3524
+ /**
3525
+ * Rule group processor used by {@link formatQuery} for "ldap" format.
3526
+ *
3527
+ * @group Export
3528
+ */
3529
+ declare const defaultRuleGroupProcessorLDAP: RuleGroupProcessor<string>;
3530
+ //#endregion
3531
+ //#region src/utils/formatQuery/defaultRuleGroupProcessorMongoDB.d.ts
3532
+ /**
3533
+ * Rule group processor used by {@link formatQuery} for "mongodb" format.
3534
+ *
3535
+ * Note that the "mongodb" format is deprecated in favor of the "mongodb_query" format.
3536
+ *
3537
+ * @group Export
3538
+ */
3539
+ declare const defaultRuleGroupProcessorMongoDB: RuleGroupProcessor<string>;
3540
+ //#endregion
3541
+ //#region src/utils/formatQuery/defaultRuleGroupProcessorMongoDBQuery.d.ts
3542
+ /**
3543
+ * Default fallback object used by {@link formatQuery} for "mongodb_query" format.
3544
+ *
3545
+ * @group Export
3546
+ */
3547
+ declare const mongoDbFallback: {
3548
+ readonly $and: readonly [{
3549
+ readonly $expr: true;
3550
+ }];
3551
+ };
3552
+ /**
3553
+ * Rule group processor used by {@link formatQuery} for "mongodb_query" format.
3554
+ *
3555
+ * @group Export
3556
+ */
3557
+ declare const defaultRuleGroupProcessorMongoDBQuery: RuleGroupProcessor;
3558
+ //#endregion
3559
+ //#region src/utils/formatQuery/defaultRuleGroupProcessorNL.d.ts
3560
+ /**
3561
+ * Rule group processor used by {@link formatQuery} for "natural_language" format.
3562
+ *
3563
+ * @group Export
3564
+ */
3565
+ declare const defaultRuleGroupProcessorNL: RuleGroupProcessor<string>;
3566
+ //#endregion
3567
+ //#region src/utils/formatQuery/defaultRuleGroupProcessorParameterized.d.ts
3568
+ /**
3569
+ * Rule group processor used by {@link formatQuery} for "parameterized" and
3570
+ * "parameterized_named" formats.
3571
+ *
3572
+ * @group Export
3573
+ */
3574
+ declare const defaultRuleGroupProcessorParameterized: RuleGroupProcessor<ParameterizedSQL | ParameterizedNamedSQL>;
3575
+ //#endregion
3576
+ //#region src/utils/formatQuery/defaultRuleGroupProcessorPrisma.d.ts
3577
+ /**
3578
+ * Default fallback object used by {@link formatQuery} for "prisma" format.
3579
+ *
3580
+ * @group Export
3581
+ */
3582
+ declare const prismaFallback: {};
3583
+ /**
3584
+ * Rule group processor used by {@link formatQuery} for "prisma" format.
3585
+ *
3586
+ * @group Export
3587
+ */
3588
+ declare const defaultRuleGroupProcessorPrisma: RuleGroupProcessor<Record<string, unknown> | undefined>;
3589
+ //#endregion
3590
+ //#region src/utils/formatQuery/defaultRuleGroupProcessorSequelize.d.ts
3591
+ /**
3592
+ * Rule group processor used by {@link formatQuery} for "sequelize" format.
3593
+ *
3594
+ * @group Export
3595
+ */
3596
+ declare const defaultRuleGroupProcessorSequelize: RuleGroupProcessor<WhereOptions | undefined>;
3597
+ //#endregion
3598
+ //#region src/utils/formatQuery/defaultRuleGroupProcessorSpEL.d.ts
3599
+ /**
3600
+ * Default rule processor used by {@link formatQuery} for "spel" format.
3601
+ *
3602
+ * @group Export
3603
+ */
3604
+ declare const defaultRuleGroupProcessorSpEL: RuleGroupProcessor<string>;
3605
+ //#endregion
3606
+ //#region src/utils/formatQuery/defaultRuleGroupProcessorSQL.d.ts
3607
+ /**
3608
+ * Default rule processor used by {@link formatQuery} for "sql" format.
3609
+ *
3610
+ * @group Export
3611
+ */
3612
+ declare const defaultRuleGroupProcessorSQL: RuleGroupProcessor<string>;
3613
+ //#endregion
3614
+ //#region src/utils/formatQuery/defaultRuleProcessorDrizzle.d.ts
3615
+ /**
3616
+ * Default rule processor used by {@link formatQuery} for the "drizzle" format.
3617
+ *
3618
+ * @group Export
3619
+ */
3620
+ declare const defaultRuleProcessorDrizzle: RuleProcessor;
3621
+ //#endregion
3622
+ //#region src/utils/formatQuery/defaultRuleProcessorElasticSearch.d.ts
3623
+ /**
3624
+ * Default rule processor used by {@link formatQuery} for "elasticsearch" format.
3625
+ *
3626
+ * @group Export
3627
+ */
3628
+ declare const defaultRuleProcessorElasticSearch: RuleProcessor;
3629
+ //#endregion
3630
+ //#region src/utils/formatQuery/defaultRuleProcessorJSONata.d.ts
3631
+ /**
3632
+ * Default rule processor used by {@link formatQuery} for "jsonata" format.
3633
+ *
3634
+ * @group Export
3635
+ */
3636
+ declare const defaultRuleProcessorJSONata: RuleProcessor;
3637
+ //#endregion
3638
+ //#region src/utils/formatQuery/defaultRuleProcessorJsonLogic.d.ts
3639
+ /**
3640
+ * Default rule processor used by {@link formatQuery} for "jsonlogic" format.
3641
+ *
3642
+ * @group Export
3643
+ */
3644
+ declare const defaultRuleProcessorJsonLogic: RuleProcessor;
3645
+ //#endregion
3646
+ //#region src/utils/formatQuery/defaultRuleProcessorLDAP.d.ts
3647
+ /**
3648
+ * Default rule processor used by {@link formatQuery} for "ldap" format.
3649
+ *
3650
+ * @group Export
3651
+ */
3652
+ declare const defaultRuleProcessorLDAP: RuleProcessor;
3653
+ //#endregion
3654
+ //#region src/utils/formatQuery/defaultRuleProcessorMongoDBQuery.d.ts
3655
+ /**
3656
+ * Default rule processor used by {@link formatQuery} for "mongodb_query" format.
3657
+ *
3658
+ * @group Export
3659
+ */
3660
+ declare const defaultRuleProcessorMongoDBQuery: RuleProcessor;
3661
+ //#endregion
3662
+ //#region src/utils/formatQuery/defaultRuleProcessorNL.d.ts
3663
+ /**
3664
+ * Default operator map used by {@link formatQuery} for "natural_language" format.
3665
+ *
3666
+ * @group Export
3667
+ */
3668
+ declare const defaultExportOperatorMap: ExportOperatorMap;
3669
+ /**
3670
+ * Default operator processor used by {@link formatQuery} for "natural_language" format.
3671
+ *
3672
+ * @group Export
3673
+ */
3674
+ declare const defaultOperatorProcessorNL: RuleProcessor;
3675
+ /**
3676
+ * Default rule processor used by {@link formatQuery} for "natural_language" format.
3677
+ *
3678
+ * @group Export
3679
+ */
3680
+ declare const defaultRuleProcessorNL: RuleProcessor;
3681
+ //#endregion
3682
+ //#region src/utils/formatQuery/defaultRuleProcessorParameterized.d.ts
3683
+ /**
3684
+ * Default rule processor used by {@link formatQuery} for "parameterized" and
3685
+ * "parameterized_named" formats.
3686
+ *
3687
+ * @group Export
3688
+ */
3689
+ declare const defaultRuleProcessorParameterized: RuleProcessor;
3690
+ //#endregion
3691
+ //#region src/utils/formatQuery/defaultRuleProcessorPrisma.d.ts
3692
+ /**
3693
+ * Default rule processor used by {@link formatQuery} for "prisma" format.
3694
+ *
3695
+ * @group Export
3696
+ */
3697
+ declare const defaultRuleProcessorPrisma: RuleProcessor;
3698
+ //#endregion
3699
+ //#region src/utils/formatQuery/defaultRuleProcessorSequelize.d.ts
3700
+ /**
3701
+ * Default rule processor used by {@link formatQuery} for the "sequelize" format.
3702
+ *
3703
+ * @group Export
3704
+ */
3705
+ declare const defaultRuleProcessorSequelize: RuleProcessor;
3706
+ //#endregion
3707
+ //#region src/utils/formatQuery/defaultRuleProcessorSQL.d.ts
3708
+ /**
3709
+ * Default operator processor used by {@link formatQuery} for "sql" and "parameterized*" formats.
3710
+ *
3711
+ * @group Export
3712
+ */
3713
+ declare const defaultOperatorProcessorSQL: RuleProcessor;
3714
+ /**
3715
+ * Default rule processor used by {@link formatQuery} for "sql" format.
3716
+ *
3717
+ * @group Export
3718
+ */
3719
+ declare const defaultRuleProcessorSQL: RuleProcessor;
3720
+ //#endregion
3721
+ //#region src/utils/formatQuery/defaultValueProcessorNL.d.ts
3722
+ /**
3723
+ * Default value processor used by {@link formatQuery} for "natural_language" format.
3724
+ *
3725
+ * @group Export
3726
+ */
3727
+ declare const defaultValueProcessorNL: ValueProcessorByRule;
3728
+ //#endregion
3729
+ //#region src/utils/formatQuery/formatQuery.d.ts
3730
+ /**
3731
+ * A collection of option presets for {@link formatQuery}, specifically for SQL-based formats.
3732
+ *
3733
+ * @group Export
3734
+ */
3735
+ declare const sqlDialectPresets: Record<SQLPreset, FormatQueryOptions>;
3736
+ /**
3737
+ * A collection of option presets for {@link formatQuery}.
3738
+ *
3739
+ * @group Export
3740
+ */
3741
+ declare const formatQueryOptionPresets: Record<string, FormatQueryOptions>;
3742
+ /**
3743
+ * Generates a formatted (indented two spaces) JSON string from a query object.
3744
+ *
3745
+ * @group Export
3746
+ */
3747
+ declare function formatQuery(ruleGroup: RuleGroupTypeAny): string;
3748
+ /**
3749
+ * Generates a result based on the provided rule group processor.
3750
+ *
3751
+ * @group Export
3752
+ */
3753
+ declare function formatQuery<TResult = unknown>(ruleGroup: RuleGroupTypeAny, options: FormatQueryOptions & {
3754
+ ruleGroupProcessor: RuleGroupProcessor<TResult>;
3755
+ }): TResult;
3756
+ /**
3757
+ * Generates a {@link index!ParameterizedSQL ParameterizedSQL} object from a query object.
3758
+ *
3759
+ * @group Export
3760
+ */
3761
+ declare function formatQuery(ruleGroup: RuleGroupTypeAny, options: "parameterized" | (FormatQueryOptions & {
3762
+ format: "parameterized";
3763
+ })): ParameterizedSQL;
3764
+ /**
3765
+ * Generates a {@link index!ParameterizedNamedSQL ParameterizedNamedSQL} object from a query object.
3766
+ *
3767
+ * @group Export
3768
+ */
3769
+ declare function formatQuery(ruleGroup: RuleGroupTypeAny, options: "parameterized_named" | (FormatQueryOptions & {
3770
+ format: "parameterized_named";
3771
+ })): ParameterizedNamedSQL;
3772
+ /**
3773
+ * Generates a {@link index!RQBJsonLogic JsonLogic} object from a query object.
3774
+ *
3775
+ * @group Export
3776
+ */
3777
+ declare function formatQuery(ruleGroup: RuleGroupTypeAny, options: "jsonlogic" | (FormatQueryOptions & {
3778
+ format: "jsonlogic";
3779
+ })): RQBJsonLogic;
3780
+ /**
3781
+ * Generates an ElasticSearch query object from an RQB query object.
3782
+ *
3783
+ * NOTE: Support for the ElasticSearch format is experimental.
3784
+ * You may have better results exporting "sql" format then using
3785
+ * [ElasticSearch SQL](https://www.elastic.co/guide/en/elasticsearch/reference/current/xpack-sql.html).
3786
+ *
3787
+ * @group Export
3788
+ */
3789
+ declare function formatQuery(ruleGroup: RuleGroupTypeAny, options: "elasticsearch" | (FormatQueryOptions & {
3790
+ format: "elasticsearch";
3791
+ })): Record<string, any>;
3792
+ /**
3793
+ * Generates a MongoDB query object from an RQB query object.
3794
+ *
3795
+ * This is equivalent to the "mongodb" format, but returns a JSON object
3796
+ * instead of a string.
3797
+ *
3798
+ * @group Export
3799
+ */
3800
+ declare function formatQuery(ruleGroup: RuleGroupTypeAny, options: "mongodb_query" | (FormatQueryOptions & {
3801
+ format: "mongodb_query";
3802
+ })): Record<string, any>;
3803
+ /**
3804
+ * Generates a JSON.stringify'd MongoDB query object from an RQB query object.
3805
+ *
3806
+ * This is equivalent to the "mongodb_query" format, but returns a string
3807
+ * instead of a JSON object.
3808
+ *
3809
+ * @deprecated Use the "mongodb_query" format for greater flexibility.
3810
+ *
3811
+ * @group Export
3812
+ */
3813
+ declare function formatQuery(ruleGroup: RuleGroupTypeAny, options: "mongodb" | (FormatQueryOptions & {
3814
+ format: "mongodb";
3815
+ })): string;
3816
+ /**
3817
+ * Generates a Prisma ORM query object from an RQB query object.
3818
+ *
3819
+ * @group Export
3820
+ */
3821
+ declare function formatQuery(ruleGroup: RuleGroupTypeAny, options: "prisma" | (FormatQueryOptions & {
3822
+ format: "prisma";
3823
+ })): Record<string, any>;
3824
+ /**
3825
+ * Generates a Drizzle ORM query function from an RQB query object. The function can
3826
+ * be assigned to the `where` property in the Drizzle relational queries API.
3827
+ *
3828
+ * @group Export
3829
+ */
3830
+ declare function formatQuery(ruleGroup: RuleGroupTypeAny, options: "drizzle" | (FormatQueryOptions & {
3831
+ format: "drizzle";
3832
+ })): ReturnType<typeof defaultRuleGroupProcessorDrizzle>;
3833
+ /**
3834
+ * Generates a Sequelize query object from an RQB query object. The object can
3835
+ * be assigned to the `where` property in the Sequelize query functions.
3836
+ *
3837
+ * @group Export
3838
+ */
3839
+ declare function formatQuery(ruleGroup: RuleGroupTypeAny, options: "sequelize" | (FormatQueryOptions & {
3840
+ format: "sequelize";
3841
+ })): ReturnType<typeof defaultRuleGroupProcessorSequelize>;
3842
+ /**
3843
+ * Generates a JSONata query string from an RQB query object.
3844
+ *
3845
+ * NOTE: Either `parseNumbers: "strict-limited"` or `parseNumbers: true`
3846
+ * are recommended for this format.
3847
+ *
3848
+ * @group Export
3849
+ */
3850
+ declare function formatQuery(ruleGroup: RuleGroupTypeAny, options: "jsonata" | (FormatQueryOptions & {
3851
+ format: "jsonata";
3852
+ })): string;
3853
+ /**
3854
+ * Generates an LDAP query string from an RQB query object.
3855
+ *
3856
+ * @group Export
3857
+ */
3858
+ declare function formatQuery(ruleGroup: RuleGroupTypeAny, options: "ldap" | (FormatQueryOptions & {
3859
+ format: "ldap";
3860
+ })): string;
3861
+ /**
3862
+ * Generates a formatted (indented two spaces) JSON string from a query object.
3863
+ *
3864
+ * @group Export
3865
+ */
3866
+ declare function formatQuery(ruleGroup: RuleGroupTypeAny, options: FormatQueryOptions): string;
3867
+ /**
3868
+ * Generates a query string in the requested format.
3869
+ *
3870
+ * @group Export
3871
+ */
3872
+ declare function formatQuery(ruleGroup: RuleGroupTypeAny, options: Exclude<ExportFormat, ExportObjectFormats>): string;
3873
+ /**
3874
+ * Generates a query string in the requested format.
3875
+ *
3876
+ * @group Export
3877
+ */
3878
+ declare function formatQuery(ruleGroup: RuleGroupTypeAny, options: FormatQueryOptions & {
3879
+ format: Exclude<ExportFormat, ExportObjectFormats>;
3880
+ }): string;
3881
+ //#endregion
3882
+ //#region src/utils/formatQuery/utils.d.ts
3883
+ /**
3884
+ * Maps a {@link DefaultOperatorName} to a SQL operator.
3885
+ *
3886
+ * @group Export
3887
+ */
3888
+ declare const mapSQLOperator: (rqbOperator: string) => string;
3889
+ /**
3890
+ * Maps a (lowercase) {@link DefaultOperatorName} to a MongoDB operator.
3891
+ *
3892
+ * @group Export
3893
+ */
3894
+ declare const mongoOperators: {
3895
+ "=": string;
3896
+ "!=": string;
3897
+ "<": string;
3898
+ "<=": string;
3899
+ ">": string;
3900
+ ">=": string;
3901
+ in: string;
3902
+ notin: string;
3903
+ notIn: string;
3904
+ };
3905
+ /**
3906
+ * Maps a (lowercase) {@link DefaultOperatorName} to a Prisma ORM operator.
3907
+ *
3908
+ * @group Export
3909
+ */
3910
+ declare const prismaOperators: {
3911
+ "=": string;
3912
+ "!=": string;
3913
+ "<": string;
3914
+ "<=": string;
3915
+ ">": string;
3916
+ ">=": string;
3917
+ in: string;
3918
+ notin: string;
3919
+ };
3920
+ /**
3921
+ * Maps a {@link DefaultCombinatorName} to a CEL combinator.
3922
+ *
3923
+ * @group Export
3924
+ */
3925
+ declare const celCombinatorMap: {
3926
+ and: "&&";
3927
+ or: "||";
3928
+ };
3929
+ /**
3930
+ * Register these operators with `jsonLogic` before applying the result
3931
+ * of `formatQuery(query, 'jsonlogic')`.
3932
+ *
3933
+ * @example
3934
+ * ```
3935
+ * for (const [op, func] of Object.entries(jsonLogicAdditionalOperators)) {
3936
+ * jsonLogic.add_operation(op, func);
3937
+ * }
3938
+ * jsonLogic.apply({ "startsWith": [{ "var": "firstName" }, "Stev"] }, data);
3939
+ * ```
3940
+ *
3941
+ * @group Export
3942
+ */
3943
+ declare const jsonLogicAdditionalOperators: Record<"startsWith" | "endsWith", (a: string, b: string) => boolean>;
3944
+ /**
3945
+ * Converts all `string`-type `value` properties of a query object into `number` where appropriate.
3946
+ *
3947
+ * Used by {@link formatQuery} for the `json*` formats when `parseNumbers` is `true`.
3948
+ *
3949
+ * @group Export
3950
+ */
3951
+ declare const numerifyValues: (rg: RuleGroupTypeAny, options: SetRequired<FormatQueryOptions, "fields">) => RuleGroupTypeAny;
3952
+ /**
3953
+ * Determines whether a value is _anything_ except an empty `string` or `NaN`.
3954
+ *
3955
+ * @group Export
3956
+ */
3957
+ declare const isValidValue: (value: any) => boolean;
3958
+ /**
3959
+ * Determines whether {@link formatQuery} should render the given value as a number.
3960
+ * As long as `parseNumbers` is `true`, `number` and `bigint` values will return `true` and
3961
+ * `string` values will return `true` if they test positive against {@link numericRegex}.
3962
+ *
3963
+ * @group Export
3964
+ */
3965
+ declare const shouldRenderAsNumber: (value: any, parseNumbers?: boolean) => boolean;
3966
+ /**
3967
+ * Used by {@link formatQuery} to determine whether the given value processor is a
3968
+ * "legacy" value processor by counting the number of arguments. Legacy value
3969
+ * processors take 3 arguments (not counting any arguments with default values), while
3970
+ * rule-based value processors take no more than 2 arguments.
3971
+ *
3972
+ * @group Export
3973
+ */
3974
+ declare const isValueProcessorLegacy: (valueProcessor: ValueProcessorLegacy | ValueProcessorByRule) => valueProcessor is ValueProcessorLegacy;
3975
+ /**
3976
+ * Converts the `quoteFieldNamesWith` option into an array of two strings.
3977
+ * If the option is a string, the array elements are both that string.
3978
+ *
3979
+ * @default
3980
+ * ['', '']
3981
+ *
3982
+ * @group Export
3983
+ */
3984
+ declare const getQuoteFieldNamesWithArray: (quoteFieldNamesWith?: null | string | [string, string]) => [string, string];
3985
+ /**
3986
+ * Given a field name and relevant {@link ValueProcessorOptions}, returns the field name
3987
+ * wrapped in the configured quote character(s).
3988
+ *
3989
+ * @group Export
3990
+ */
3991
+ declare const getQuotedFieldName: (fieldName: string, {
3992
+ quoteFieldNamesWith,
3993
+ fieldIdentifierSeparator
3994
+ }: ValueProcessorOptions) => string;
3995
+ /**
3996
+ * Given a [Constituent word order](https://en.wikipedia.org/wiki/Word_order#Constituent_word_orders)
3997
+ * like "svo" or "sov", returns a permutation of `["S", "V", "O"]` based on the first occurrence of
3998
+ * each letter in the input string (case insensitive). This widens the valid input from abbreviations
3999
+ * like "svo" to more expressive strings like "subject-verb-object" or "sub ver obj". Any missing
4000
+ * letters are appended in the default order "SVO" (e.g., "object" would yield `["O", "S", "V"]`).
4001
+ *
4002
+ * @group Export
4003
+ */
4004
+ declare const normalizeConstituentWordOrder: (input: string) => ConstituentWordOrder;
4005
+ /**
4006
+ * Default translations used by {@link formatQuery} for "natural_language" format.
4007
+ *
4008
+ * @group Export
4009
+ */
4010
+ declare const defaultNLTranslations: NLTranslations;
4011
+ /**
4012
+ * Used by {@link formatQuery} to get a translation based on certain conditions
4013
+ * for the "natural_language" format.
4014
+ *
4015
+ * @group Export
4016
+ */
4017
+ declare const getNLTranslataion: (key: NLTranslationKey, translations: NLTranslations, conditions?: GroupVariantCondition[]) => string;
4018
+ type ProcessedMatchMode = {
4019
+ mode: "all";
4020
+ threshold?: number | null | undefined;
4021
+ } | {
4022
+ mode: "none";
4023
+ threshold?: number | null | undefined;
4024
+ } | {
4025
+ mode: "some";
4026
+ threshold?: number | null | undefined;
4027
+ } | {
4028
+ mode: "atleast";
4029
+ threshold: number;
4030
+ } | {
4031
+ mode: "atmost";
4032
+ threshold: number;
4033
+ } | {
4034
+ mode: "exactly";
4035
+ threshold: number;
4036
+ };
4037
+ declare const processMatchMode: (rule: RuleType) => void | false | ProcessedMatchMode;
4038
+ /**
4039
+ * "Replacer" method for JSON.stringify's second argument. Converts `bigint` values to
4040
+ * objects with a `$bigint` property having a value of a string representation of
4041
+ * the actual `bigint`-type value.
4042
+ *
4043
+ * Inverse of {@link bigIntJsonParseReviver}.
4044
+ *
4045
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#use_within_json
4046
+ */
4047
+ declare const bigIntJsonStringifyReplacer: (_key: string, value: unknown) => unknown;
4048
+ /**
4049
+ * "Reviver" method for JSON.parse's second argument. Converts objects having a single
4050
+ * `$bigint: string` property to an actual `bigint` value.
4051
+ *
4052
+ * Inverse of {@link bigIntJsonStringifyReplacer}.
4053
+ *
4054
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#use_within_json
4055
+ */
4056
+ declare const bigIntJsonParseReviver: (_key: string, value: unknown) => unknown;
4057
+ //#endregion
4058
+ //#region src/utils/formatQuery/index.d.ts
4059
+ /**
4060
+ * Default value processor used by {@link formatQuery} for "sql" format.
4061
+ *
4062
+ * @group Export
4063
+ */
4064
+ declare const defaultValueProcessor: ValueProcessorLegacy;
4065
+ /**
4066
+ * @deprecated Prefer {@link defaultRuleProcessorMongoDB}.
4067
+ *
4068
+ * @group Export
4069
+ */
4070
+ declare const defaultMongoDBValueProcessor: ValueProcessorLegacy;
4071
+ /**
4072
+ * @deprecated Prefer {@link defaultRuleProcessorCEL}.
4073
+ *
4074
+ * @group Export
4075
+ */
4076
+ declare const defaultCELValueProcessor: ValueProcessorLegacy;
4077
+ /**
4078
+ * @deprecated Prefer {@link defaultRuleProcessorSpEL}.
4079
+ *
4080
+ * @group Export
4081
+ */
4082
+ declare const defaultSpELValueProcessor: ValueProcessorLegacy;
4083
+ /**
4084
+ * @deprecated Renamed to {@link defaultRuleProcessorCEL}.
4085
+ *
4086
+ * @group Export
4087
+ */
4088
+ declare const defaultValueProcessorCELByRule: RuleProcessor;
4089
+ /**
4090
+ * @deprecated Renamed to {@link defaultRuleProcessorMongoDB}.
4091
+ *
4092
+ * @group Export
4093
+ */
4094
+ declare const defaultValueProcessorMongoDBByRule: RuleProcessor;
4095
+ /**
4096
+ * @deprecated Renamed to {@link defaultRuleProcessorSpEL}.
4097
+ *
4098
+ * @group Export
4099
+ */
4100
+ declare const defaultValueProcessorSpELByRule: RuleProcessor;
4101
+ //#endregion
4102
+ //#region src/utils/generateAccessibleDescription.d.ts
4103
+ declare const generateAccessibleDescription: AccessibleDescriptionGenerator;
4104
+ //#endregion
4105
+ //#region src/utils/generateID.d.ts
4106
+ type UUID = `${string}-${string}-${string}-${string}-${string}`;
4107
+ /**
4108
+ * Default `id` generator. Generates a valid v4 UUID. Uses `crypto.randomUUID()`
4109
+ * when available, otherwise uses an alternate method based on `getRandomValues`.
4110
+ * The returned string is guaranteed to match this regex:
4111
+ * ```
4112
+ * /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i
4113
+ * ```
4114
+ * @returns Valid v4 UUID
4115
+ */
4116
+ declare let generateID: () => UUID;
4117
+ //#endregion
4118
+ //#region src/utils/getMatchModesUtil.d.ts
4119
+ /**
4120
+ * Utility function to get the match modes array for the given
4121
+ * field. If the field definition does not define a `matchModes`
4122
+ * property, the `getMatchModes` prop is used. Returns
4123
+ * `FullOption<MatchMode>[]` of all match modes by default.
4124
+ */
4125
+ declare const getMatchModesUtil: <F extends FullField>(fieldData: F, getMatchModes?: (field: GetOptionIdentifierType<F>, misc: {
4126
+ fieldData: F;
4127
+ }) => boolean | MatchMode[] | FlexibleOption<MatchMode>[]) => MatchModeOptions;
4128
+ //#endregion
4129
+ //#region src/utils/getParseNumberMethod.d.ts
4130
+ declare const getParseNumberMethod: ({
4131
+ parseNumbers,
4132
+ inputType
4133
+ }: {
4134
+ parseNumbers?: ParseNumbersPropConfig;
4135
+ inputType?: InputType | null;
4136
+ }) => ParseNumberMethod;
4137
+ //#endregion
4138
+ //#region src/utils/getValidationClassNames.d.ts
4139
+ /**
4140
+ * Gets the standard classname for valid or invalid components
4141
+ * based on the given validation result.
4142
+ */
4143
+ declare const getValidationClassNames: (validationResult: boolean | ValidationResult) => "" | (typeof standardClassnames)["valid"] | (typeof standardClassnames)["invalid"];
4144
+ //#endregion
4145
+ //#region src/utils/getValueSourcesUtil.d.ts
4146
+ /**
4147
+ * Utility function to get the value sources array for the given
4148
+ * field and operator. If the field definition does not define a
4149
+ * `valueSources` property, the `getValueSources` prop is used.
4150
+ * Returns `[FullOption<"value">]` by default.
4151
+ */
4152
+ declare const getValueSourcesUtil: <F extends FullField, O extends string>(fieldData: F, operator: string, getValueSources?: (field: GetOptionIdentifierType<F>, operator: O, misc: {
4153
+ fieldData: F;
4154
+ }) => ValueSources | ValueSourceFlexibleOptions) => ValueSourceFullOptions;
4155
+ //#endregion
4156
+ //#region src/utils/isRuleGroup.d.ts
4157
+ /**
4158
+ * Determines if an object is a {@link RuleGroupType} or {@link RuleGroupTypeIC}.
4159
+ */
4160
+ declare const isRuleGroup: (rg: any) => rg is RuleGroupTypeAny;
4161
+ /**
4162
+ * Determines if an object is a {@link RuleGroupType}.
4163
+ */
4164
+ declare const isRuleGroupType: (rg: any) => rg is RuleGroupType;
4165
+ /**
4166
+ * Determines if an object is a {@link RuleGroupTypeIC}.
4167
+ */
4168
+ declare const isRuleGroupTypeIC: (rg: any) => rg is RuleGroupTypeIC;
4169
+ //#endregion
4170
+ //#region src/utils/isRuleOrGroupValid.d.ts
4171
+ /**
4172
+ * Determines if an object is useful as a validation result.
4173
+ */
4174
+ declare const isValidationResult: (vr?: ValidationResult) => vr is ValidationResult;
4175
+ /**
4176
+ * Determines if a rule or group is valid based on a validation result (if defined)
4177
+ * or a validator function. Returns `true` if neither are defined.
4178
+ */
4179
+ declare const isRuleOrGroupValid: (rg: RuleType | RuleGroupTypeAny, validationResult?: boolean | ValidationResult, validator?: RuleValidator) => boolean;
4180
+ //#endregion
4181
+ //#region src/utils/mergeClassnames.d.ts
4182
+ type MergeClassnamesParams = (Partial<Classnames> | undefined)[];
4183
+ /**
4184
+ * Merges a list of partial {@link Classnames} definitions into a single definition.
4185
+ */
4186
+ declare const mergeClassnames: (...args: MergeClassnamesParams) => Classnames;
4187
+ //#endregion
4188
+ //#region src/utils/misc.d.ts
4189
+ /**
4190
+ * Converts a value to lowercase if it's a string, otherwise returns the value as is.
4191
+ */
4192
+ declare const lc: <T>(v: T) => T;
4193
+ /**
4194
+ * Regex matching numeric strings. Passes for positive/negative integers, decimals,
4195
+ * and E notation, with optional surrounding whitespace.
4196
+ */
4197
+ declare const numericRegex: RegExp;
4198
+ /**
4199
+ * Determines if a variable is a plain old JavaScript object, aka POJO.
4200
+ */
4201
+ declare const isPojo: (obj: any) => obj is Record<string, any>;
4202
+ /**
4203
+ * Simple helper to determine whether a value is null, undefined, or an empty string.
4204
+ */
4205
+ declare const nullOrUndefinedOrEmpty: (value: any) => value is null | undefined | "";
4206
+ //#endregion
4207
+ //#region src/utils/objectUtils.d.ts
4208
+ /**
4209
+ * Original looked like this (not sure why template string is used):
4210
+ * ```
4211
+ * type ObjectKeys<T extends object> = `${Exclude<keyof T, symbol>}`;
4212
+ * ```
4213
+ */
4214
+ type ObjectKeys<T extends object> = Exclude<keyof T, symbol>;
4215
+ /**
4216
+ * A strongly-typed version of `Object.keys()`.
4217
+ *
4218
+ * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-keys.ts)
4219
+ */
4220
+ declare const objectKeys: <Type extends object>(value: Type) => Array<ObjectKeys<Type>>;
4221
+ /**
4222
+ * A strongly-typed version of `Object.entries()`.
4223
+ *
4224
+ * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-entries.ts)
4225
+ */
4226
+ declare const objectEntries: <Type extends Record<PropertyKey, unknown>>(value: Type) => Array<[ObjectKeys<Type>, Type[ObjectKeys<Type>]]>;
4227
+ //#endregion
4228
+ //#region src/utils/optGroupUtils.d.ts
4229
+ /**
4230
+ * Converts an {@link Option} or {@link ValueOption} (i.e., {@link BaseOption})
4231
+ * into a {@link FullOption}. Full options are left unchanged.
4232
+ *
4233
+ * @group Option Lists
4234
+ */
4235
+ declare function toFullOption<Opt extends BaseOption>(opt: Opt | string, baseProperties?: Record<string, unknown>, labelMap?: Record<string, unknown>): ToFullOption<Opt>;
4236
+ /**
4237
+ * Converts an {@link OptionList} or {@link FlexibleOptionList} into a {@link FullOptionList}.
4238
+ * Lists of full options are left unchanged.
4239
+ *
4240
+ * @group Option Lists
4241
+ */
4242
+ declare function toFullOptionList<Opt extends BaseOption>(optList: unknown[], baseProperties?: Record<string, unknown>, labelMap?: Record<string, unknown>): FullOptionList<Opt>;
4243
+ /**
4244
+ * Converts a {@link FlexibleOptionList} into a {@link FullOptionList}.
4245
+ * Lists of full options are left unchanged.
4246
+ *
4247
+ * @group Option Lists
4248
+ */
4249
+ declare function toFullOptionMap<OptMap extends BaseOptionMap>(optMap: OptMap, baseProperties?: Record<string, unknown>): OptMap extends BaseOptionMap<infer V, infer K> ? Partial<Record<K, ToFullOption<V>>> : never;
4250
+ /**
4251
+ * @deprecated Renamed to {@link uniqByIdentifier}.
4252
+ *
4253
+ * @group Option Lists
4254
+ */
4255
+ declare const uniqByName: <T extends {
4256
+ name: string;
4257
+ value?: string;
4258
+ } | {
4259
+ name?: string;
4260
+ value: string;
4261
+ }>(originalArray: T[]) => T[];
4262
+ /**
4263
+ * Generates a new array of objects with duplicates removed based
4264
+ * on the identifying property (`value` or `name`)
4265
+ *
4266
+ * @group Option Lists
4267
+ */
4268
+ declare const uniqByIdentifier: <T extends RequireAtLeastOne<{
4269
+ name: string;
4270
+ value: string;
4271
+ }, "name" | "value">>(originalArray: T[]) => T[];
4272
+ /**
4273
+ * Determines if an {@link OptionList} is an {@link OptionGroup} array.
4274
+ *
4275
+ * @group Option Lists
4276
+ */
4277
+ declare const isOptionGroupArray: (arr: any) => arr is OptionGroup<BaseOption>[];
4278
+ /**
4279
+ * Determines if an array is a flat array of {@link FlexibleOption}.
4280
+ *
4281
+ * @group Option Lists
4282
+ */
4283
+ declare const isFlexibleOptionArray: (arr: any) => arr is FlexibleOption[];
4284
+ /**
4285
+ * Determines if an array is a flat array of {@link FullOption}.
4286
+ *
4287
+ * @group Option Lists
4288
+ */
4289
+ declare const isFullOptionArray: (arr: any) => arr is FullOption[];
4290
+ /**
4291
+ * Determines if a {@link FlexibleOptionList} is a {@link FlexibleOptionGroup} array.
4292
+ *
4293
+ * @group Option Lists
4294
+ */
4295
+ declare const isFlexibleOptionGroupArray: (arr: any, {
4296
+ allowEmpty
4297
+ }?: {
4298
+ allowEmpty?: boolean;
4299
+ }) => arr is FlexibleOptionGroup[];
4300
+ /**
4301
+ * Determines if a {@link FlexibleOptionList} is a {@link OptionGroup} array of {@link FullOption}.
4302
+ *
4303
+ * @group Option Lists
4304
+ */
4305
+ declare const isFullOptionGroupArray: (arr: any, {
4306
+ allowEmpty
4307
+ }?: {
4308
+ allowEmpty?: boolean;
4309
+ }) => arr is OptionGroup<FullOption>[];
4310
+ /**
4311
+ * Gets the option from an {@link OptionList} with the given `name`. Handles
4312
+ * {@link Option} arrays as well as {@link OptionGroup} arrays.
4313
+ *
4314
+ * @group Option Lists
4315
+ */
4316
+ declare function getOption<OptType extends FullOption>(arr: FullOptionList<OptType>, name: string): OptType | undefined;
4317
+ declare function getOption<OptType extends ValueOption>(arr: FlexibleOptionList<OptType>, name: string): OptType | undefined;
4318
+ declare function getOption<OptType extends Option>(arr: FlexibleOptionList<OptType>, name: string): OptType | undefined;
4319
+ /**
4320
+ * Gets the first option from an {@link OptionList}.
4321
+ *
4322
+ * @group Option Lists
4323
+ */
4324
+ declare function getFirstOption<Opt extends FullOption>(arr?: OptionGroup<Opt>[] | Opt[]): GetOptionIdentifierType<Opt> | null;
4325
+ declare function getFirstOption<Opt extends ValueOption>(arr?: OptionGroup<Opt>[] | Opt[]): GetOptionIdentifierType<Opt> | null;
4326
+ declare function getFirstOption<Opt extends Option>(arr?: OptionGroup<Opt>[] | Opt[]): GetOptionIdentifierType<Opt> | null;
4327
+ /**
4328
+ * Flattens {@link FlexibleOptionGroup} arrays into {@link BaseOption} arrays.
4329
+ * If the array is already flat, it is returned as is.
4330
+ *
4331
+ * @group Option Lists
4332
+ */
4333
+ declare const toFlatOptionArray: <T extends FullOption, OL extends FullOptionList<T>>(arr: OL) => T[];
4334
+ /**
4335
+ * Generates a new {@link OptionGroup} array with duplicates
4336
+ * removed based on the identifying property (`value` or `name`).
4337
+ *
4338
+ * @group Option Lists
4339
+ */
4340
+ declare const uniqOptGroups: <T extends BaseOption>(originalArray: FlexibleOptionGroup<T>[]) => OptionGroup<ToFullOption<T>>[];
4341
+ /**
4342
+ * Generates a new {@link Option} or {@link OptionGroup} array with duplicates
4343
+ * removed based on the identifier property (`value` or `name`).
4344
+ *
4345
+ * @group Option Lists
4346
+ */
4347
+ declare const uniqOptList: <T extends BaseOption>(originalArray: FlexibleOptionList<T>) => WithUnknownIndex<BaseOption & FullOption>[] | OptionGroup<ToFullOption<T>>[];
4348
+ //#endregion
4349
+ //#region src/utils/parseNumber.d.ts
4350
+ /**
4351
+ * Options object for {@link parseNumber}.
4352
+ */
4353
+ interface ParseNumberOptions {
4354
+ parseNumbers?: ParseNumberMethod;
4355
+ /**
4356
+ * Generates a `bigint` value if the string represents a valid integer
4357
+ * outside the safe boundaries of the `number` type.
4358
+ */
4359
+ bigIntOnOverflow?: boolean;
4360
+ }
4361
+ /**
4362
+ * Converts a string to a number. Uses native `parseFloat` if `parseNumbers` is "native",
4363
+ * otherwise uses [`numeric-quantity`](https://jakeboone02.github.io/numeric-quantity/).
4364
+ * If that returns `NaN`, the string is returned unchanged. Numeric values are returned
4365
+ * as-is regardless of the `parseNumbers` option.
4366
+ */
4367
+ declare const parseNumber: (val: any, {
4368
+ parseNumbers,
4369
+ bigIntOnOverflow
4370
+ }?: ParseNumberOptions) => any;
4371
+ //#endregion
4372
+ //#region src/utils/pathUtils.d.ts
4373
+ /**
4374
+ * Return type for {@link findPath}.
4375
+ */
4376
+ type FindPathReturnType = RuleGroupTypeAny | RuleType | null;
4377
+ /**
4378
+ * Returns the {@link RuleType} or {@link RuleGroupType}/{@link RuleGroupTypeIC}
4379
+ * at the given path within a query.
4380
+ */
4381
+ declare const findPath: (path: Path, query: RuleGroupTypeAny) => FindPathReturnType;
4382
+ /**
4383
+ * Returns the {@link RuleType} or {@link RuleGroupType}/{@link RuleGroupTypeIC}
4384
+ * with the given `id` within a query.
4385
+ */
4386
+ declare const findID: (id: string, query: RuleGroupTypeAny) => FindPathReturnType;
4387
+ /**
4388
+ * Returns the {@link Path} of the {@link RuleType} or {@link RuleGroupType}/{@link RuleGroupTypeIC}
4389
+ * with the given `id` within a query.
4390
+ */
4391
+ declare const getPathOfID: (id: string, query: RuleGroupTypeAny) => Path | null;
4392
+ /**
4393
+ * Truncates the last element of an array and returns the result as a new array.
4394
+ */
4395
+ declare const getParentPath: (path: Path) => Path;
4396
+ /**
4397
+ * Determines if two paths (each `Path`) are equivalent.
4398
+ */
4399
+ declare const pathsAreEqual: (path1: Path, path2: Path) => boolean;
4400
+ /**
4401
+ * Determines if the first path is an ancestor of the second path. The first path must
4402
+ * be shorter and exactly match the second path up through the length of the first path.
4403
+ */
4404
+ declare const isAncestor: (maybeAncestor: Path, path: Path) => boolean;
4405
+ /**
4406
+ * Finds the deepest/longest path that two paths have in common.
4407
+ */
4408
+ declare const getCommonAncestorPath: (path1: Path, path2: Path) => Path;
4409
+ /**
4410
+ * Determines if the rule or group at the specified path is either disabled itself
4411
+ * or disabled by an ancestor group.
4412
+ */
4413
+ declare const pathIsDisabled: (path: Path, query: RuleGroupTypeAny) => boolean;
4414
+ //#endregion
4415
+ //#region src/utils/prepareQueryObjects.d.ts
4416
+ /**
4417
+ * Options for {@link prepareRule}/{@link prepareRuleGroup}.
4418
+ */
4419
+ interface PreparerOptions {
4420
+ idGenerator?: () => string;
4421
+ }
4422
+ /**
4423
+ * Ensures that a rule is valid by adding an `id` property if it does not already exist.
4424
+ */
4425
+ declare const prepareRule: (rule: RuleType, {
4426
+ idGenerator
4427
+ }?: PreparerOptions) => RuleType;
4428
+ /**
4429
+ * Ensures that a rule group is valid by recursively adding an `id` property to the group itself
4430
+ * and all its rules and subgroups where one does not already exist.
4431
+ */
4432
+ declare const prepareRuleGroup: <RG extends RuleGroupTypeAny>(queryObject: RG, {
4433
+ idGenerator
4434
+ }?: PreparerOptions) => RG;
4435
+ /**
4436
+ * Ensures that a rule or group is valid. See {@link prepareRule} and {@link prepareRuleGroup}.
4437
+ */
4438
+ declare const prepareRuleOrGroup: <RG extends RuleGroupTypeAny>(rg: RG | RuleType, {
4439
+ idGenerator
4440
+ }?: PreparerOptions) => RuleGroupType | RuleGroupTypeIC | RuleType;
4441
+ //#endregion
4442
+ //#region src/utils/queryTools.d.ts
4443
+ /**
4444
+ * Options for {@link add}.
4445
+ *
4446
+ * @group Query Tools
4447
+ */
4448
+ interface AddOptions {
4449
+ /**
4450
+ * If the query extends `RuleGroupTypeIC` (i.e. the query has independent
4451
+ * combinators), then the first combinator in this list will be inserted
4452
+ * before the new rule/group if the parent group is not empty. This option
4453
+ * is overridden by `combinatorPreceding`.
4454
+ */
4455
+ combinators?: OptionList;
4456
+ /**
4457
+ * If the query extends `RuleGroupTypeIC` (i.e. the query has independent
4458
+ * combinators), then this combinator will be inserted before the new rule/group
4459
+ * if the parent group is not empty. This option will supersede `combinators`.
4460
+ */
4461
+ combinatorPreceding?: string;
4462
+ /**
4463
+ * ID generator.
4464
+ */
4465
+ idGenerator?: () => string;
4466
+ }
4467
+ /**
4468
+ * Adds a rule or group to a query.
4469
+ * @returns The new query with the rule or group added.
4470
+ *
4471
+ * @group Query Tools
4472
+ */
4473
+ declare const add: <RG extends RuleGroupTypeAny>(query: RG, ruleOrGroup: RG | RuleType, parentPathOrID: Path | string, {
4474
+ combinators,
4475
+ combinatorPreceding,
4476
+ idGenerator
4477
+ }?: AddOptions) => RG;
4478
+ /**
4479
+ * Options for {@link update}.
4480
+ *
4481
+ * @group Query Tools
4482
+ */
4483
+ interface UpdateOptions {
4484
+ /**
4485
+ * When updating the `field` of a rule, the rule's `operator`, `value`, and `valueSource`
4486
+ * will be reset to their respective defaults. Defaults to `true`.
4487
+ */
4488
+ resetOnFieldChange?: boolean;
4489
+ /**
4490
+ * When updating the `operator` of a rule, the rule's `value` and `valueSource`
4491
+ * will be reset to their respective defaults. Defaults to `false`.
4492
+ */
4493
+ resetOnOperatorChange?: boolean;
4494
+ /**
4495
+ * Determines the default operator name for a given field.
4496
+ */
4497
+ getRuleDefaultOperator?: (field: string) => string;
4498
+ /**
4499
+ * Determines the valid value sources for a given field and operator.
4500
+ */
4501
+ getValueSources?: (field: string, operator: string) => ValueSources | ValueSourceFlexibleOptions;
4502
+ /**
4503
+ * Gets the default value for a given rule, in case the value needs to be reset.
4504
+ */
4505
+ getRuleDefaultValue?: (rule: RuleType) => any;
4506
+ /**
4507
+ * Determines the valid match modes for a given field.
4508
+ */
4509
+ getMatchModes?: (field: string) => MatchModeOptions;
4510
+ }
4511
+ /**
4512
+ * Updates a property of a rule or group within a query.
4513
+ * @returns The new query with the rule or group property updated.
4514
+ *
4515
+ * @group Query Tools
4516
+ */
4517
+ declare const update: <RG extends RuleGroupTypeAny>(query: RG, prop: UpdateableProperties, value: any, pathOrID: Path | string, {
4518
+ resetOnFieldChange,
4519
+ resetOnOperatorChange,
4520
+ getRuleDefaultOperator,
4521
+ getValueSources,
4522
+ getRuleDefaultValue,
4523
+ getMatchModes
4524
+ }?: UpdateOptions) => RG;
4525
+ /**
4526
+ * Removes a rule or group from a query.
4527
+ * @returns The new query with the rule or group removed.
4528
+ *
4529
+ * @group Query Tools
4530
+ */
4531
+ declare const remove: <RG extends RuleGroupTypeAny>(query: RG, pathOrID: Path | string) => RG;
4532
+ /**
4533
+ * Options for {@link move}.
4534
+ *
4535
+ * @group Query Tools
4536
+ */
4537
+ interface MoveOptions {
4538
+ /**
4539
+ * When `true`, the source rule/group will not be removed from its original path.
4540
+ */
4541
+ clone?: boolean;
4542
+ /**
4543
+ * If the query extends `RuleGroupTypeIC` (i.e. the query is using independent
4544
+ * combinators), then the first combinator in this list will be inserted before
4545
+ * the rule/group if necessary.
4546
+ */
4547
+ combinators?: OptionList;
4548
+ /**
4549
+ * ID generator.
4550
+ */
4551
+ idGenerator?: () => string;
4552
+ }
4553
+ /**
4554
+ * Moves a rule or group from one path to another. In the options parameter, pass
4555
+ * `{ clone: true }` to copy instead of move.
4556
+ * @returns The new query with the rule or group moved or cloned.
4557
+ *
4558
+ * @group Query Tools
4559
+ */
4560
+ declare const move: <RG extends RuleGroupTypeAny>(query: RG, oldPathOrID: Path | string, newPath: Path | "up" | "down", {
4561
+ clone,
4562
+ combinators,
4563
+ idGenerator
4564
+ }?: MoveOptions) => RG;
4565
+ /**
4566
+ * Options for {@link insert}.
4567
+ *
4568
+ * @group Query Tools
4569
+ */
4570
+ interface InsertOptions {
4571
+ /**
4572
+ * If the query extends `RuleGroupTypeIC` (i.e. the query has independent
4573
+ * combinators), then the first combinator in this list will be inserted
4574
+ * before the new rule/group if the parent group is not empty. This option
4575
+ * is overridden by `combinatorPreceding`.
4576
+ */
4577
+ combinators?: OptionList;
4578
+ /**
4579
+ * If the query extends `RuleGroupTypeIC` (i.e. the query has independent
4580
+ * combinators), then this combinator will be inserted before the new rule/group
4581
+ * if the parent group is not empty and the new rule/group is not the first in the
4582
+ * group (`path.at(-1) > 0`). This option will supersede `combinators`.
4583
+ */
4584
+ combinatorPreceding?: string;
4585
+ /**
4586
+ * If the query extends `RuleGroupTypeIC` (i.e. the query has independent
4587
+ * combinators), then this combinator will be inserted after the new rule/group
4588
+ * if the parent group is not empty and the new rule/group is the first in the
4589
+ * group (`path.at(-1) === 0`). This option will supersede `combinators`.
4590
+ */
4591
+ combinatorSucceeding?: string;
4592
+ /**
4593
+ * ID generator.
4594
+ *
4595
+ * @default generateID
4596
+ */
4597
+ idGenerator?: () => string;
4598
+ /**
4599
+ * When `true`, the new rule/group will replace the rule/group at `path`.
4600
+ */
4601
+ replace?: boolean;
4602
+ }
4603
+ /**
4604
+ * Inserts a rule or group into a query.
4605
+ * @returns The new query with the rule or group inserted.
4606
+ *
4607
+ * @group Query Tools
4608
+ */
4609
+ declare const insert: <RG extends RuleGroupTypeAny>(query: RG, ruleOrGroup: RG | RuleType, path: number[], {
4610
+ combinators,
4611
+ combinatorPreceding,
4612
+ combinatorSucceeding,
4613
+ idGenerator,
4614
+ replace
4615
+ }?: InsertOptions) => RG;
4616
+ /**
4617
+ * Options for {@link group}.
4618
+ *
4619
+ * @group Query Tools
4620
+ */
4621
+ interface GroupOptions {
4622
+ /**
4623
+ * When `true`, the source rule/group will not be removed from its original path.
4624
+ */
4625
+ clone?: boolean;
4626
+ /**
4627
+ * If the query extends `RuleGroupTypeIC` (i.e. the query is using independent
4628
+ * combinators), then the first combinator in this list will be inserted between
4629
+ * the two rules/groups.
4630
+ */
4631
+ combinators?: OptionList;
4632
+ /**
4633
+ * ID generator.
4634
+ */
4635
+ idGenerator?: () => string;
4636
+ }
4637
+ /**
4638
+ * Creates a new group at a target path with its `rules` array containing the current
4639
+ * objects at the target path and the source path. In the options parameter, pass
4640
+ * `{ clone: true }` to copy the source rule/group instead of move.
4641
+ *
4642
+ * @returns The new query with the rules or groups grouped.
4643
+ *
4644
+ * @group Query Tools
4645
+ */
4646
+ declare const group: <RG extends RuleGroupTypeAny>(query: RG, sourcePathOrID: Path | string, targetPathOrID: Path | string, {
4647
+ clone,
4648
+ combinators,
4649
+ idGenerator
4650
+ }?: GroupOptions) => RG;
4651
+ //#endregion
4652
+ //#region src/utils/regenerateIDs.d.ts
4653
+ /**
4654
+ * Options object for {@link regenerateID}/{@link regenerateIDs}.
4655
+ */
4656
+ interface RegenerateIdOptions {
4657
+ idGenerator?: () => string;
4658
+ }
4659
+ /**
4660
+ * Generates a new `id` property for a rule.
4661
+ */
4662
+ declare const regenerateID: (rule: RuleType, {
4663
+ idGenerator
4664
+ }?: RegenerateIdOptions) => RuleType;
4665
+ /**
4666
+ * Recursively generates new `id` properties for a group and all its rules and subgroups.
4667
+ */
4668
+ declare const regenerateIDs: (ruleOrGroup: RuleGroupType | RuleGroupTypeIC, {
4669
+ idGenerator
4670
+ }?: RegenerateIdOptions) => RuleGroupType | RuleGroupTypeIC;
4671
+ //#endregion
4672
+ //#region src/utils/transformQuery.d.ts
4673
+ /**
4674
+ * Options object for {@link index!transformQuery transformQuery}.
4675
+ */
4676
+ interface TransformQueryOptions<RG extends RuleGroupTypeAny = RuleGroupType> {
4677
+ /**
4678
+ * When a rule is encountered in the hierarchy, it will be replaced
4679
+ * with the result of this function.
4680
+ *
4681
+ * @defaultValue `r => r`
4682
+ */
4683
+ ruleProcessor?: (rule: RuleType) => any;
4684
+ /**
4685
+ * When a group is encountered in the hierarchy (including the root group, the
4686
+ * query itself), it will be replaced with the result of this function.
4687
+ *
4688
+ * @defaultValue `rg => rg`
4689
+ */
4690
+ ruleGroupProcessor?: (ruleGroup: RG) => Record<string, any>;
4691
+ /**
4692
+ * For each rule and group in the query, any properties matching a key
4693
+ * in this object will be renamed to the corresponding value. To retain both
4694
+ * the new _and_ the original properties, set `deleteRemappedProperties`
4695
+ * to `false`.
4696
+ *
4697
+ * If a key has a value of `false`, the corresponding property will be removed
4698
+ * without being copied to a new property name. (Warning: `{ rules: false }`
4699
+ * will prevent recursion and only return the processed root group.)
4700
+ *
4701
+ * @defaultValue `{}`
4702
+ *
4703
+ * @example
4704
+ * ```
4705
+ * transformQuery(
4706
+ * { combinator: 'and', not: true, rules: [] },
4707
+ * { propertyMap: { combinator: 'AndOr', not: false } }
4708
+ * )
4709
+ * // Returns: { AndOr: 'and', rules: [] }
4710
+ * ```
4711
+ */
4712
+ propertyMap?: Record<string, string | false>;
4713
+ /**
4714
+ * Any combinator values (including independent combinators) will be translated
4715
+ * from the key in this object to the value.
4716
+ *
4717
+ * @defaultValue `{}`
4718
+ *
4719
+ * @example
4720
+ * ```
4721
+ * transformQuery(
4722
+ * { combinator: 'and', rules: [] },
4723
+ * { combinatorMap: { and: '&&', or: '||' } }
4724
+ * )
4725
+ * // Returns: { combinator: '&&', rules: [] }
4726
+ * ```
4727
+ */
4728
+ combinatorMap?: Record<string, string>;
4729
+ /**
4730
+ * Any operator values will be translated from the key in this object to the value.
4731
+ *
4732
+ * @defaultValue `{}`
4733
+ *
4734
+ * @example
4735
+ * ```
4736
+ * transformQuery(
4737
+ * { combinator: 'and', rules: [{ field: 'name', operator: '=', value: 'Steve Vai' }] },
4738
+ * { operatorMap: { '=': 'is' } }
4739
+ * )
4740
+ * // Returns:
4741
+ * // {
4742
+ * // combinator: 'and',
4743
+ * // rules: [{ field: 'name', operator: 'is', value: 'Steve Vai' }]
4744
+ * // }
4745
+ * ```
4746
+ */
4747
+ operatorMap?: Record<string, string>;
4748
+ /**
4749
+ * Prevents the `path` property (see {@link index!Path Path}) from being added to each
4750
+ * rule and group in the hierarchy.
4751
+ *
4752
+ * @defaultValue `false`
4753
+ */
4754
+ omitPath?: boolean;
4755
+ /**
4756
+ * Original properties remapped according to the `propertyMap` option will be removed.
4757
+ *
4758
+ * @defaultValue `true`
4759
+ *
4760
+ * @example
4761
+ * ```
4762
+ * transformQuery(
4763
+ * { combinator: 'and', rules: [] },
4764
+ * { propertyMap: { combinator: 'AndOr' }, deleteRemappedProperties: false }
4765
+ * )
4766
+ * // Returns: { combinator: 'and', AndOr: 'and', rules: [] }
4767
+ * ```
4768
+ */
4769
+ deleteRemappedProperties?: boolean;
4770
+ }
4771
+ /**
4772
+ * Recursively process a query heirarchy using this versatile utility function.
4773
+ *
4774
+ * [Documentation](https://react-querybuilder.js.org/docs/utils/misc#transformquery)
4775
+ */
4776
+ declare function transformQuery(query: RuleGroupType, options?: TransformQueryOptions): any;
4777
+ /**
4778
+ * Recursively process a query heirarchy with independent combinators using this
4779
+ * versatile utility function.
4780
+ *
4781
+ * [Documentation](https://react-querybuilder.js.org/docs/utils/misc#transformquery)
4782
+ */
4783
+ declare function transformQuery(query: RuleGroupTypeIC, options?: TransformQueryOptions<RuleGroupTypeIC>): any;
4784
+ //#endregion
4785
+ export { AccessibleDescriptionGenerator, ActionElementEventHandler, AddOptions, And, Arity, BaseFullOption, BaseOption, BaseOptionMap, Classname, Classnames, Combinator, CombinatorByValue, CommonRuleAndGroupProperties, CommonRuleSubComponentProps, ConstituentWordOrder, ConstituentWordOrderString, DefaultCombinator, DefaultCombinatorExtended, DefaultCombinatorName, DefaultCombinatorNameExtended, DefaultCombinators, DefaultCombinatorsExtended, DefaultMatchModes, DefaultOperator, DefaultOperatorName, DefaultOperators, DefaultRuleGroupArray, DefaultRuleGroupICArray, DefaultRuleGroupType, DefaultRuleGroupTypeAny, DefaultRuleGroupTypeIC, DefaultRuleOrGroupArray, DefaultRuleType, DndDropTargetType, DragCollection, DraggedItem, DropCollection, DropEffect, DropResult, Except, ExportFormat, ExportObjectFormats, ExportOperatorMap, Field, FieldByValue, FindPathReturnType, Finite, FlexibleOption, FlexibleOptionGroup, FlexibleOptionList, FlexibleOptionListProp, Float, FormatQueryFinalOptions, FormatQueryOptions, FormatQueryValidateRule, FullCombinator, FullField, FullOperator, FullOption, FullOptionList, FullOptionMap, FullOptionRecord, GenericizeRuleGroupType, GetOptionIdentifierType, GetOptionType, GetRuleGroupType, GetRuleTypeFromGroupWithFieldAndOperator, GreaterThan, GreaterThanOrEqual, GroupOptions, GroupVariantCondition, IfAny$1 as IfAny, IfNever$1 as IfNever, InputType, InsertOptions, Integer, IsAny, IsBooleanLiteral, IsEqual, IsFloat, IsInteger, IsLiteral, IsNegative, IsNever, IsNumericLiteral, IsStringLiteral, IsSymbolLiteral, type JsonLogicAll, type JsonLogicAnd, type JsonLogicDoubleNegation, type JsonLogicEqual, type JsonLogicGreaterThan, type JsonLogicGreaterThanOrEqual, type JsonLogicInArray, type JsonLogicInString, type JsonLogicLessThan, type JsonLogicLessThanOrEqual, type JsonLogicNegation, type JsonLogicNone, type JsonLogicNotEqual, type JsonLogicOr, type JsonLogicReservedOperations, type JsonLogicRulesLogic, type JsonLogicSome, type JsonLogicStrictEqual, type JsonLogicStrictNotEqual, type JsonLogicVar, KeysOfUnion, LessThan, LogType, MatchConfig, MatchMode, MatchModeOptions, Merge, MoveOptions, NLTranslationKey, NLTranslations, NameLabelPair, Negative, NegativeFloat, NegativeInfinity, NegativeInteger, NonNegative, NonNegativeInteger, Numeric, OmitIndexSignature, Operator, OperatorByValue, Option, OptionGroup, OptionList, OptionalKeysOf, Or, OverrideProperties, ParameterizedNamedSQL, ParameterizedSQL, ParseNumberMethod, ParseNumberOptions, ParseNumbersPropConfig, Path, PickIndexSignature, PositiveInfinity, PreparerOptions, Primitive, QueryActions, QueryValidator, RQBJsonLogic, RQBJsonLogicEndsWith, RQBJsonLogicStartsWith, RQBJsonLogicVar, RegenerateIdOptions, RemoveNullability, RequireAtLeastOne, RequiredKeysOf, RuleGroupArray, RuleGroupICArray, RuleGroupProcessor, RuleGroupType, RuleGroupTypeAny, RuleGroupTypeIC, RuleOrGroupArray, RuleProcessor, RuleType, RuleValidator, SQLPreset, SetNonNullable, SetOptional, SetRequired, Simplify, StringUnionToFlexibleOptionArray, StringUnionToFullOptionArray, TestID, ToFlexibleOption, ToFullOption, TransformQueryOptions, Trim, UnionToIntersection, UnknownArray, UpdateOptions, UpdateableProperties, ValidationMap, ValidationResult, ValueChangeEventHandler, ValueEditorType, ValueOption, ValueProcessor, ValueProcessorByRule, ValueProcessorLegacy, ValueProcessorOptions, ValueSource, ValueSourceFlexibleOptions, ValueSourceFullOptions, ValueSources, WithRequired, WithUnknownIndex, Writable, Zero, add, bigIntJsonParseReviver, bigIntJsonStringifyReplacer, celCombinatorMap, clsx, convertFromIC, convertQuery, convertToIC, defaultCELValueProcessor, defaultCombinatorLabelMap, defaultCombinators, defaultCombinatorsExtended, defaultControlClassnames, defaultExportOperatorMap, defaultJoinChar, defaultMatchModes, defaultMongoDBValueProcessor, defaultNLTranslations, defaultOperatorLabelMap, defaultOperatorNegationMap, defaultOperatorProcessorNL, defaultOperatorProcessorSQL, defaultOperators, defaultPlaceholderFieldGroupLabel, defaultPlaceholderFieldLabel, defaultPlaceholderFieldName, defaultPlaceholderLabel, defaultPlaceholderName, defaultPlaceholderOperatorGroupLabel, defaultPlaceholderOperatorLabel, defaultPlaceholderOperatorName, defaultPlaceholderValueGroupLabel, defaultPlaceholderValueLabel, defaultPlaceholderValueName, defaultRuleGroupProcessorCEL, defaultRuleGroupProcessorDrizzle, defaultRuleGroupProcessorElasticSearch, defaultRuleGroupProcessorJSONata, defaultRuleGroupProcessorJsonLogic, defaultRuleGroupProcessorLDAP, defaultRuleGroupProcessorMongoDB, defaultRuleGroupProcessorMongoDBQuery, defaultRuleGroupProcessorNL, defaultRuleGroupProcessorParameterized, defaultRuleGroupProcessorPrisma, defaultRuleGroupProcessorSQL, defaultRuleGroupProcessorSequelize, defaultRuleGroupProcessorSpEL, defaultRuleProcessorCEL, defaultRuleProcessorDrizzle, defaultRuleProcessorElasticSearch, defaultRuleProcessorJSONata, defaultRuleProcessorJsonLogic, defaultRuleProcessorLDAP, defaultRuleProcessorMongoDB, defaultRuleProcessorMongoDBQuery, defaultRuleProcessorNL, defaultRuleProcessorParameterized, defaultRuleProcessorPrisma, defaultRuleProcessorSQL, defaultRuleProcessorSequelize, defaultRuleProcessorSpEL, defaultSpELValueProcessor, defaultValidator, defaultValueProcessor, defaultValueProcessorByRule, defaultValueProcessorCELByRule, defaultValueProcessorMongoDBByRule, defaultValueProcessorNL, defaultValueProcessorSpELByRule, filterFieldsByComparator, findID, findPath, formatQuery, formatQueryOptionPresets, generateAccessibleDescription, generateID, getCommonAncestorPath, getFirstOption, getMatchModesUtil, getNLTranslataion, getOption, getParentPath, getParseNumberMethod, getPathOfID, getQuoteFieldNamesWithArray, getQuotedFieldName, getValidationClassNames, getValueSourcesUtil, group, groupInvalidReasons, insert, isAncestor, isFlexibleOptionArray, isFlexibleOptionGroupArray, isFullOptionArray, isFullOptionGroupArray, isOptionGroupArray, isPojo, isRuleGroup, isRuleGroupType, isRuleGroupTypeIC, isRuleOrGroupValid, isValidValue, isValidationResult, isValueProcessorLegacy, joinWith, jsonLogicAdditionalOperators, lc, mapSQLOperator, mergeClassnames, mongoDbFallback, mongoOperators, move, normalizeConstituentWordOrder, nullFreeArray, nullOrUndefinedOrEmpty, numericRegex, numerifyValues, objectEntries, objectKeys, parseNumber, pathIsDisabled, pathsAreEqual, prepareRule, prepareRuleGroup, prepareRuleOrGroup, prismaFallback, prismaOperators, processMatchMode, regenerateID, regenerateIDs, remove, rootPath, shouldRenderAsNumber, splitBy, sqlDialectPresets, standardClassnames, toArray, toFlatOptionArray, toFullOption, toFullOptionList, toFullOptionMap, transformQuery, trimIfString, uniqByIdentifier, uniqByName, uniqOptGroups, uniqOptList, update };
4786
+ //# sourceMappingURL=react-querybuilder_core.cjs.production.d.ts.map