@react-querybuilder/core 8.11.2 → 8.13.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.
- package/dist/{basic-CLG_Bmom.d.mts → basic-Cw014pDc.d.mts} +123 -98
- package/dist/{basic-BeKPP0_1.d.ts → basic-_KlsCAyT.d.ts} +123 -98
- package/dist/chunk-U64pC571.js +41 -0
- package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +215 -148
- package/dist/cjs/react-querybuilder_core.cjs.development.js +28 -37
- package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +215 -148
- package/dist/cjs/react-querybuilder_core.cjs.production.js +1 -1
- package/dist/cjs/react-querybuilder_core.cjs.production.js.map +1 -1
- package/dist/{convertQuery-Cj4t-LT4.mjs → convertQuery-DAj92cbM.mjs} +3 -3
- package/dist/{convertQuery-Cj4t-LT4.mjs.map → convertQuery-DAj92cbM.mjs.map} +1 -1
- package/dist/{convertQuery-C7NvB0XA.js → convertQuery-DRldbzhZ.js} +4 -4
- package/dist/{convertQuery-C7NvB0XA.js.map → convertQuery-DRldbzhZ.js.map} +1 -1
- package/dist/{export-B2Yw5gak.d.mts → export-CffjLxEe.d.mts} +2 -2
- package/dist/{export-CQB0nuvW.d.ts → export-DRA8O1Wz.d.ts} +2 -2
- package/dist/formatQuery.d.mts +2 -2
- package/dist/formatQuery.d.ts +2 -2
- package/dist/formatQuery.js +19 -13
- package/dist/formatQuery.js.map +1 -1
- package/dist/formatQuery.mjs +18 -12
- package/dist/formatQuery.mjs.map +1 -1
- package/dist/{import-Dvayhrgj.d.ts → import-CWYJkN_w.d.ts} +2 -2
- package/dist/{import-BtpySRSy.d.mts → import-DjHGaGhJ.d.mts} +2 -2
- package/dist/{isRuleGroup-DqAs2x4E.js → isRuleGroup-Cjk1Q2mj.js} +2 -40
- package/dist/{isRuleGroup-DqAs2x4E.js.map → isRuleGroup-Cjk1Q2mj.js.map} +1 -1
- package/dist/{isRuleGroup-BcfwGaIN.mjs → isRuleGroup-DztIOOKa.mjs} +1 -1
- package/dist/{isRuleGroup-BcfwGaIN.mjs.map → isRuleGroup-DztIOOKa.mjs.map} +1 -1
- package/dist/parseCEL.d.mts +2 -2
- package/dist/parseCEL.d.ts +2 -2
- package/dist/parseCEL.js +16 -6
- package/dist/parseCEL.js.map +1 -1
- package/dist/parseCEL.mjs +15 -4
- package/dist/parseCEL.mjs.map +1 -1
- package/dist/parseJSONata.d.mts +2 -2
- package/dist/parseJSONata.d.ts +2 -2
- package/dist/parseJSONata.js +13 -6
- package/dist/parseJSONata.js.map +1 -1
- package/dist/parseJSONata.mjs +3 -3
- package/dist/parseJsonLogic.d.mts +3 -3
- package/dist/parseJsonLogic.d.ts +3 -3
- package/dist/parseJsonLogic.js +4 -4
- package/dist/parseJsonLogic.mjs +4 -4
- package/dist/parseMongoDB.d.mts +2 -2
- package/dist/parseMongoDB.d.ts +2 -2
- package/dist/parseMongoDB.js +5 -5
- package/dist/parseMongoDB.js.map +1 -1
- package/dist/parseMongoDB.mjs +5 -5
- package/dist/parseMongoDB.mjs.map +1 -1
- package/dist/parseSQL.d.mts +2 -2
- package/dist/parseSQL.d.ts +2 -2
- package/dist/parseSQL.js +4 -5
- package/dist/parseSQL.js.map +1 -1
- package/dist/parseSQL.mjs +3 -3
- package/dist/parseSpEL.d.mts +2 -2
- package/dist/parseSpEL.d.ts +2 -2
- package/dist/parseSpEL.js +58 -6
- package/dist/parseSpEL.js.map +1 -1
- package/dist/parseSpEL.mjs +3 -3
- package/dist/{prepareQueryObjects-BfnyRV5t.mjs → prepareQueryObjects-6Bxx4Bs1.mjs} +3 -3
- package/dist/{prepareQueryObjects-BfnyRV5t.mjs.map → prepareQueryObjects-6Bxx4Bs1.mjs.map} +1 -1
- package/dist/{prepareQueryObjects-Cz_28zYz.js → prepareQueryObjects-CkN0bTKm.js} +4 -4
- package/dist/{prepareQueryObjects-Cz_28zYz.js.map → prepareQueryObjects-CkN0bTKm.js.map} +1 -1
- package/dist/react-querybuilder_core.d.mts +215 -148
- package/dist/react-querybuilder_core.legacy-esm.d.ts +215 -148
- package/dist/react-querybuilder_core.legacy-esm.js +34 -18
- package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
- package/dist/react-querybuilder_core.mjs +28 -12
- package/dist/react-querybuilder_core.mjs.map +1 -1
- package/dist/react-querybuilder_core.production.d.mts +215 -148
- package/dist/react-querybuilder_core.production.mjs +1 -1
- package/dist/react-querybuilder_core.production.mjs.map +1 -1
- package/dist/{transformQuery-B4SaTTO-.js → transformQuery-ClBRfnFg.js} +10 -3
- package/dist/{transformQuery-B4SaTTO-.js.map → transformQuery-ClBRfnFg.js.map} +1 -1
- package/dist/{transformQuery-C85j__7e.mjs → transformQuery-DUpbpqjX.mjs} +9 -2
- package/dist/{transformQuery-C85j__7e.mjs.map → transformQuery-DUpbpqjX.mjs.map} +1 -1
- package/dist/transformQuery.d.mts +1 -1
- package/dist/transformQuery.d.ts +1 -1
- package/dist/transformQuery.js +2 -2
- package/dist/transformQuery.mjs +2 -2
- package/dist/{utils-Dkz3Xn2D.js → utils-CR1ToTMW.js} +3 -4
- package/dist/utils-CR1ToTMW.js.map +1 -0
- package/dist/{utils-DxH23QtE.mjs → utils-nQU7WCM9.mjs} +2 -2
- package/dist/utils-nQU7WCM9.mjs.map +1 -0
- package/package.json +12 -11
- package/dist/utils-Dkz3Xn2D.js.map +0 -1
- package/dist/utils-DxH23QtE.mjs.map +0 -1
|
@@ -26,34 +26,6 @@ type Intersection = UnionToIntersection<Union>;
|
|
|
26
26
|
//=> {the(): void; great(arg: string): void; escape: boolean};
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
A more applicable example which could make its way into your library code follows.
|
|
30
|
-
|
|
31
|
-
@example
|
|
32
|
-
```
|
|
33
|
-
import type {UnionToIntersection} from 'type-fest';
|
|
34
|
-
|
|
35
|
-
class CommandOne {
|
|
36
|
-
commands: {
|
|
37
|
-
a1: () => undefined,
|
|
38
|
-
b1: () => undefined,
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
class CommandTwo {
|
|
43
|
-
commands: {
|
|
44
|
-
a2: (argA: string) => undefined,
|
|
45
|
-
b2: (argB: string) => undefined,
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const union = [new CommandOne(), new CommandTwo()].map(instance => instance.commands);
|
|
50
|
-
type Union = typeof union;
|
|
51
|
-
//=> {a1(): void; b1(): void} | {a2(argA: string): void; b2(argB: string): void}
|
|
52
|
-
|
|
53
|
-
type Intersection = UnionToIntersection<Union>;
|
|
54
|
-
//=> {a1(): void; b1(): void; a2(argA: string): void; b2(argB: string): void}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
29
|
@category Type
|
|
58
30
|
*/
|
|
59
31
|
type UnionToIntersection<Union> = (
|
|
@@ -129,8 +101,8 @@ import type {IsAny} from 'type-fest';
|
|
|
129
101
|
const typedObject = {a: 1, b: 2} as const;
|
|
130
102
|
const anyObject: any = {a: 1, b: 2};
|
|
131
103
|
|
|
132
|
-
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(
|
|
133
|
-
return
|
|
104
|
+
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
|
|
105
|
+
return object[key];
|
|
134
106
|
}
|
|
135
107
|
|
|
136
108
|
const typedA = get(typedObject, 'a');
|
|
@@ -143,7 +115,7 @@ const anyA = get(anyObject, 'a');
|
|
|
143
115
|
@category Type Guard
|
|
144
116
|
@category Utilities
|
|
145
117
|
*/
|
|
146
|
-
type IsAny<T
|
|
118
|
+
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
147
119
|
//#endregion
|
|
148
120
|
//#region ../../node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
149
121
|
/**
|
|
@@ -155,17 +127,17 @@ This is useful when writing utility types or schema validators that need to diff
|
|
|
155
127
|
```
|
|
156
128
|
import type {IsOptionalKeyOf} from 'type-fest';
|
|
157
129
|
|
|
158
|
-
|
|
130
|
+
type User = {
|
|
159
131
|
name: string;
|
|
160
132
|
surname: string;
|
|
161
133
|
|
|
162
134
|
luckyNumber?: number;
|
|
163
|
-
}
|
|
135
|
+
};
|
|
164
136
|
|
|
165
|
-
|
|
137
|
+
type Admin = {
|
|
166
138
|
name: string;
|
|
167
139
|
surname?: string;
|
|
168
|
-
}
|
|
140
|
+
};
|
|
169
141
|
|
|
170
142
|
type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
|
|
171
143
|
//=> true
|
|
@@ -186,7 +158,7 @@ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
|
186
158
|
@category Type Guard
|
|
187
159
|
@category Utilities
|
|
188
160
|
*/
|
|
189
|
-
type IsOptionalKeyOf<Type
|
|
161
|
+
type IsOptionalKeyOf<Type extends object, Key$1 extends keyof Type> = IsAny<Type | Key$1> extends true ? never : Key$1 extends keyof Type ? Type extends Record<Key$1, Type[Key$1]> ? false : true : false;
|
|
190
162
|
//#endregion
|
|
191
163
|
//#region ../../node_modules/type-fest/source/optional-keys-of.d.ts
|
|
192
164
|
/**
|
|
@@ -198,12 +170,12 @@ This is useful when you want to create a new type that contains different type v
|
|
|
198
170
|
```
|
|
199
171
|
import type {OptionalKeysOf, Except} from 'type-fest';
|
|
200
172
|
|
|
201
|
-
|
|
173
|
+
type User = {
|
|
202
174
|
name: string;
|
|
203
175
|
surname: string;
|
|
204
176
|
|
|
205
177
|
luckyNumber?: number;
|
|
206
|
-
}
|
|
178
|
+
};
|
|
207
179
|
|
|
208
180
|
const REMOVE_FIELD = Symbol('remove field symbol');
|
|
209
181
|
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
|
|
@@ -211,19 +183,19 @@ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKe
|
|
|
211
183
|
};
|
|
212
184
|
|
|
213
185
|
const update1: UpdateOperation<User> = {
|
|
214
|
-
name: 'Alice'
|
|
186
|
+
name: 'Alice',
|
|
215
187
|
};
|
|
216
188
|
|
|
217
189
|
const update2: UpdateOperation<User> = {
|
|
218
190
|
name: 'Bob',
|
|
219
|
-
luckyNumber: REMOVE_FIELD
|
|
191
|
+
luckyNumber: REMOVE_FIELD,
|
|
220
192
|
};
|
|
221
193
|
```
|
|
222
194
|
|
|
223
195
|
@category Utilities
|
|
224
196
|
*/
|
|
225
|
-
type OptionalKeysOf<Type
|
|
226
|
-
? (keyof { [Key in keyof Type
|
|
197
|
+
type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
198
|
+
? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
|
|
227
199
|
: never;
|
|
228
200
|
//#endregion
|
|
229
201
|
//#region ../../node_modules/type-fest/source/required-keys-of.d.ts
|
|
@@ -236,23 +208,29 @@ This is useful when you want to create a new type that contains different type v
|
|
|
236
208
|
```
|
|
237
209
|
import type {RequiredKeysOf} from 'type-fest';
|
|
238
210
|
|
|
239
|
-
declare function createValidation<
|
|
211
|
+
declare function createValidation<
|
|
212
|
+
Entity extends object,
|
|
213
|
+
Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
|
|
214
|
+
>(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
|
|
240
215
|
|
|
241
|
-
|
|
216
|
+
type User = {
|
|
242
217
|
name: string;
|
|
243
218
|
surname: string;
|
|
244
|
-
|
|
245
219
|
luckyNumber?: number;
|
|
246
|
-
}
|
|
220
|
+
};
|
|
247
221
|
|
|
248
222
|
const validator1 = createValidation<User>('name', value => value.length < 25);
|
|
249
223
|
const validator2 = createValidation<User>('surname', value => value.length < 25);
|
|
224
|
+
|
|
225
|
+
// @ts-expect-error
|
|
226
|
+
const validator3 = createValidation<User>('luckyNumber', value => value > 0);
|
|
227
|
+
// Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
|
|
250
228
|
```
|
|
251
229
|
|
|
252
230
|
@category Utilities
|
|
253
231
|
*/
|
|
254
|
-
type RequiredKeysOf<Type
|
|
255
|
-
? Exclude<keyof Type
|
|
232
|
+
type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
233
|
+
? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
|
|
256
234
|
//#endregion
|
|
257
235
|
//#region ../../node_modules/type-fest/source/is-never.d.ts
|
|
258
236
|
/**
|
|
@@ -268,35 +246,47 @@ Useful in type utilities, such as checking if something does not occur.
|
|
|
268
246
|
```
|
|
269
247
|
import type {IsNever, And} from 'type-fest';
|
|
270
248
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
And<
|
|
274
|
-
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
275
|
-
IsNever<Exclude<B, A>> extends true ? true : false
|
|
276
|
-
>;
|
|
277
|
-
|
|
278
|
-
type EndIfEqual<I extends string, O extends string> =
|
|
279
|
-
AreStringsEqual<I, O> extends true
|
|
280
|
-
? never
|
|
281
|
-
: void;
|
|
282
|
-
|
|
283
|
-
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
284
|
-
if (input === output) {
|
|
285
|
-
process.exit(0);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
249
|
+
type A = IsNever<never>;
|
|
250
|
+
//=> true
|
|
288
251
|
|
|
289
|
-
|
|
290
|
-
//=>
|
|
252
|
+
type B = IsNever<any>;
|
|
253
|
+
//=> false
|
|
254
|
+
|
|
255
|
+
type C = IsNever<unknown>;
|
|
256
|
+
//=> false
|
|
257
|
+
|
|
258
|
+
type D = IsNever<never[]>;
|
|
259
|
+
//=> false
|
|
260
|
+
|
|
261
|
+
type E = IsNever<object>;
|
|
262
|
+
//=> false
|
|
263
|
+
|
|
264
|
+
type F = IsNever<string>;
|
|
265
|
+
//=> false
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
@example
|
|
269
|
+
```
|
|
270
|
+
import type {IsNever} from 'type-fest';
|
|
271
|
+
|
|
272
|
+
type IsTrue<T> = T extends true ? true : false;
|
|
273
|
+
|
|
274
|
+
// When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
|
|
275
|
+
type A = IsTrue<never>;
|
|
276
|
+
// ^? type A = never
|
|
291
277
|
|
|
292
|
-
|
|
293
|
-
|
|
278
|
+
// If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional.
|
|
279
|
+
type IsTrueFixed<T> =
|
|
280
|
+
IsNever<T> extends true ? false : T extends true ? true : false;
|
|
281
|
+
|
|
282
|
+
type B = IsTrueFixed<never>;
|
|
283
|
+
// ^? type B = false
|
|
294
284
|
```
|
|
295
285
|
|
|
296
286
|
@category Type Guard
|
|
297
287
|
@category Utilities
|
|
298
288
|
*/
|
|
299
|
-
type IsNever<T
|
|
289
|
+
type IsNever<T> = [T] extends [never] ? true : false;
|
|
300
290
|
//#endregion
|
|
301
291
|
//#region ../../node_modules/type-fest/source/if.d.ts
|
|
302
292
|
/**
|
|
@@ -311,7 +301,7 @@ Note:
|
|
|
311
301
|
|
|
312
302
|
@example
|
|
313
303
|
```
|
|
314
|
-
import {If} from 'type-fest';
|
|
304
|
+
import type {If} from 'type-fest';
|
|
315
305
|
|
|
316
306
|
type A = If<true, 'yes', 'no'>;
|
|
317
307
|
//=> 'yes'
|
|
@@ -331,7 +321,7 @@ type E = If<never, 'yes', 'no'>;
|
|
|
331
321
|
|
|
332
322
|
@example
|
|
333
323
|
```
|
|
334
|
-
import {If, IsAny, IsNever} from 'type-fest';
|
|
324
|
+
import type {If, IsAny, IsNever} from 'type-fest';
|
|
335
325
|
|
|
336
326
|
type A = If<IsAny<unknown>, 'is any', 'not any'>;
|
|
337
327
|
//=> 'not any'
|
|
@@ -342,7 +332,7 @@ type B = If<IsNever<never>, 'is never', 'not never'>;
|
|
|
342
332
|
|
|
343
333
|
@example
|
|
344
334
|
```
|
|
345
|
-
import {If, IsEqual} from 'type-fest';
|
|
335
|
+
import type {If, IsEqual} from 'type-fest';
|
|
346
336
|
|
|
347
337
|
type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
|
|
348
338
|
|
|
@@ -353,10 +343,45 @@ type B = IfEqual<string, number, 'equal', 'not equal'>;
|
|
|
353
343
|
//=> 'not equal'
|
|
354
344
|
```
|
|
355
345
|
|
|
346
|
+
Note: Sometimes using the `If` type can make an implementation non–tail-recursive, which can impact performance. In such cases, it’s better to use a conditional directly. Refer to the following example:
|
|
347
|
+
|
|
348
|
+
@example
|
|
349
|
+
```
|
|
350
|
+
import type {If, IsEqual, StringRepeat} from 'type-fest';
|
|
351
|
+
|
|
352
|
+
type HundredZeroes = StringRepeat<'0', 100>;
|
|
353
|
+
|
|
354
|
+
// The following implementation is not tail recursive
|
|
355
|
+
type Includes<S extends string, Char extends string> =
|
|
356
|
+
S extends `${infer First}${infer Rest}`
|
|
357
|
+
? If<IsEqual<First, Char>,
|
|
358
|
+
'found',
|
|
359
|
+
Includes<Rest, Char>>
|
|
360
|
+
: 'not found';
|
|
361
|
+
|
|
362
|
+
// Hence, instantiations with long strings will fail
|
|
363
|
+
// @ts-expect-error
|
|
364
|
+
type Fails = Includes<HundredZeroes, '1'>;
|
|
365
|
+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
366
|
+
// Error: Type instantiation is excessively deep and possibly infinite.
|
|
367
|
+
|
|
368
|
+
// However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive
|
|
369
|
+
type IncludesWithoutIf<S extends string, Char extends string> =
|
|
370
|
+
S extends `${infer First}${infer Rest}`
|
|
371
|
+
? IsEqual<First, Char> extends true
|
|
372
|
+
? 'found'
|
|
373
|
+
: IncludesWithoutIf<Rest, Char>
|
|
374
|
+
: 'not found';
|
|
375
|
+
|
|
376
|
+
// Now, instantiations with long strings will work
|
|
377
|
+
type Works = IncludesWithoutIf<HundredZeroes, '1'>;
|
|
378
|
+
//=> 'not found'
|
|
379
|
+
```
|
|
380
|
+
|
|
356
381
|
@category Type Guard
|
|
357
382
|
@category Utilities
|
|
358
383
|
*/
|
|
359
|
-
type If<Type
|
|
384
|
+
type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
|
|
360
385
|
//#endregion
|
|
361
386
|
//#region ../../node_modules/type-fest/source/unknown-array.d.ts
|
|
362
387
|
/**
|
|
@@ -398,7 +423,7 @@ Needed to handle the case of a single call signature with properties.
|
|
|
398
423
|
Multiple call signatures cannot currently be supported due to a TypeScript limitation.
|
|
399
424
|
@see https://github.com/microsoft/TypeScript/issues/29732
|
|
400
425
|
*/
|
|
401
|
-
type HasMultipleCallSignatures<T
|
|
426
|
+
type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> = T extends {
|
|
402
427
|
(...arguments_: infer A): unknown;
|
|
403
428
|
(...arguments_: infer B): unknown;
|
|
404
429
|
} ? B extends A ? A extends B ? false : true : true : false;
|
|
@@ -419,14 +444,40 @@ type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
|
419
444
|
type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
420
445
|
//=> 'IS_NEVER'
|
|
421
446
|
```
|
|
447
|
+
|
|
448
|
+
Note: Wrapping a tail-recursive type with `IfNotAnyOrNever` makes the implementation non-tail-recursive. To fix this, move the recursion into a helper type. Refer to the following example:
|
|
449
|
+
|
|
450
|
+
@example
|
|
451
|
+
```ts
|
|
452
|
+
import type {StringRepeat} from 'type-fest';
|
|
453
|
+
|
|
454
|
+
type NineHundredNinetyNineSpaces = StringRepeat<' ', 999>;
|
|
455
|
+
|
|
456
|
+
// The following implementation is not tail recursive
|
|
457
|
+
type TrimLeft<S extends string> = IfNotAnyOrNever<S, S extends ` ${infer R}` ? TrimLeft<R> : S>;
|
|
458
|
+
|
|
459
|
+
// Hence, instantiations with long strings will fail
|
|
460
|
+
// @ts-expect-error
|
|
461
|
+
type T1 = TrimLeft<NineHundredNinetyNineSpaces>;
|
|
462
|
+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
463
|
+
// Error: Type instantiation is excessively deep and possibly infinite.
|
|
464
|
+
|
|
465
|
+
// To fix this, move the recursion into a helper type
|
|
466
|
+
type TrimLeftOptimised<S extends string> = IfNotAnyOrNever<S, _TrimLeftOptimised<S>>;
|
|
467
|
+
|
|
468
|
+
type _TrimLeftOptimised<S extends string> = S extends ` ${infer R}` ? _TrimLeftOptimised<R> : S;
|
|
469
|
+
|
|
470
|
+
type T2 = TrimLeftOptimised<NineHundredNinetyNineSpaces>;
|
|
471
|
+
//=> ''
|
|
472
|
+
```
|
|
422
473
|
*/
|
|
423
|
-
type IfNotAnyOrNever<T
|
|
474
|
+
type IfNotAnyOrNever<T, IfNotAnyOrNever$1, IfAny = any, IfNever = never> = If<IsAny<T>, IfAny, If<IsNever<T>, IfNever, IfNotAnyOrNever$1>>;
|
|
424
475
|
//#endregion
|
|
425
476
|
//#region ../../node_modules/type-fest/source/internal/array.d.ts
|
|
426
477
|
/**
|
|
427
478
|
Returns whether the given array `T` is readonly.
|
|
428
479
|
*/
|
|
429
|
-
type IsArrayReadonly<T
|
|
480
|
+
type IsArrayReadonly<T extends UnknownArray> = If<IsNever<T>, false, T extends unknown[] ? false : true>;
|
|
430
481
|
//#endregion
|
|
431
482
|
//#region ../../node_modules/type-fest/source/simplify.d.ts
|
|
432
483
|
/**
|
|
@@ -474,19 +525,20 @@ const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
|
474
525
|
const someType: SomeType = literal;
|
|
475
526
|
const someInterface: SomeInterface = literal;
|
|
476
527
|
|
|
477
|
-
function fn(object: Record<string, unknown>): void
|
|
528
|
+
declare function fn(object: Record<string, unknown>): void;
|
|
478
529
|
|
|
479
530
|
fn(literal); // Good: literal object type is sealed
|
|
480
531
|
fn(someType); // Good: type is sealed
|
|
532
|
+
// @ts-expect-error
|
|
481
533
|
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
482
534
|
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
483
535
|
```
|
|
484
536
|
|
|
485
537
|
@link https://github.com/microsoft/TypeScript/issues/15300
|
|
486
|
-
@see SimplifyDeep
|
|
538
|
+
@see {@link SimplifyDeep}
|
|
487
539
|
@category Object
|
|
488
540
|
*/
|
|
489
|
-
type Simplify<T
|
|
541
|
+
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
490
542
|
//#endregion
|
|
491
543
|
//#region ../../node_modules/type-fest/source/is-equal.d.ts
|
|
492
544
|
/**
|
|
@@ -515,7 +567,7 @@ type Includes<Value extends readonly any[], Item> =
|
|
|
515
567
|
@category Type Guard
|
|
516
568
|
@category Utilities
|
|
517
569
|
*/
|
|
518
|
-
type IsEqual<A$1, B$1> = [A$1
|
|
570
|
+
type IsEqual<A$1, B$1> = [A$1] extends [B$1] ? [B$1] extends [A$1] ? _IsEqual<A$1, B$1> : false : false;
|
|
519
571
|
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
520
572
|
type _IsEqual<A$1, B$1> = (<G>() => G extends A$1 & G | G ? 1 : 2) extends (<G>() => G extends B$1 & G | G ? 1 : 2) ? true : false;
|
|
521
573
|
//#endregion
|
|
@@ -537,6 +589,7 @@ It relies on the fact that an empty object (`{}`) is assignable to an object wit
|
|
|
537
589
|
```
|
|
538
590
|
const indexed: Record<string, unknown> = {}; // Allowed
|
|
539
591
|
|
|
592
|
+
// @ts-expect-error
|
|
540
593
|
const keyed: Record<'foo', unknown> = {}; // Error
|
|
541
594
|
// => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
|
542
595
|
```
|
|
@@ -550,16 +603,14 @@ type Indexed = {} extends Record<string, unknown>
|
|
|
550
603
|
// => '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
551
604
|
|
|
552
605
|
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
553
|
-
?
|
|
554
|
-
:
|
|
606
|
+
? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
|
|
607
|
+
: '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
|
|
555
608
|
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
|
|
556
609
|
```
|
|
557
610
|
|
|
558
611
|
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`...
|
|
559
612
|
|
|
560
613
|
```
|
|
561
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
562
|
-
|
|
563
614
|
type OmitIndexSignature<ObjectType> = {
|
|
564
615
|
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
565
616
|
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
@@ -569,14 +620,12 @@ type OmitIndexSignature<ObjectType> = {
|
|
|
569
620
|
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
570
621
|
|
|
571
622
|
```
|
|
572
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
573
|
-
|
|
574
623
|
type OmitIndexSignature<ObjectType> = {
|
|
575
624
|
[KeyType in keyof ObjectType
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
625
|
+
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
626
|
+
as {} extends Record<KeyType, unknown>
|
|
627
|
+
? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
628
|
+
: KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
580
629
|
]: ObjectType[KeyType];
|
|
581
630
|
};
|
|
582
631
|
```
|
|
@@ -587,27 +636,27 @@ If `{}` is assignable, it means that `KeyType` is an index signature and we want
|
|
|
587
636
|
```
|
|
588
637
|
import type {OmitIndexSignature} from 'type-fest';
|
|
589
638
|
|
|
590
|
-
|
|
639
|
+
type Example = {
|
|
591
640
|
// These index signatures will be removed.
|
|
592
|
-
[x: string]: any
|
|
593
|
-
[x: number]: any
|
|
594
|
-
[x: symbol]: any
|
|
595
|
-
[x: `head-${string}`]: string
|
|
596
|
-
[x: `${string}-tail`]: string
|
|
597
|
-
[x: `head-${string}-tail`]: string
|
|
598
|
-
[x: `${bigint}`]: string
|
|
599
|
-
[x: `embedded-${number}`]: string
|
|
641
|
+
[x: string]: any;
|
|
642
|
+
[x: number]: any;
|
|
643
|
+
[x: symbol]: any;
|
|
644
|
+
[x: `head-${string}`]: string;
|
|
645
|
+
[x: `${string}-tail`]: string;
|
|
646
|
+
[x: `head-${string}-tail`]: string;
|
|
647
|
+
[x: `${bigint}`]: string;
|
|
648
|
+
[x: `embedded-${number}`]: string;
|
|
600
649
|
|
|
601
650
|
// These explicitly defined keys will remain.
|
|
602
651
|
foo: 'bar';
|
|
603
652
|
qux?: 'baz';
|
|
604
|
-
}
|
|
653
|
+
};
|
|
605
654
|
|
|
606
655
|
type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
607
656
|
// => { foo: 'bar'; qux?: 'baz' | undefined; }
|
|
608
657
|
```
|
|
609
658
|
|
|
610
|
-
@see PickIndexSignature
|
|
659
|
+
@see {@link PickIndexSignature}
|
|
611
660
|
@category Object
|
|
612
661
|
*/
|
|
613
662
|
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
@@ -655,7 +704,7 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
655
704
|
// }
|
|
656
705
|
```
|
|
657
706
|
|
|
658
|
-
@see OmitIndexSignature
|
|
707
|
+
@see {@link OmitIndexSignature}
|
|
659
708
|
@category Object
|
|
660
709
|
*/
|
|
661
710
|
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
@@ -671,12 +720,12 @@ Merge two types into a new type. Keys of the second type overrides keys of the f
|
|
|
671
720
|
```
|
|
672
721
|
import type {Merge} from 'type-fest';
|
|
673
722
|
|
|
674
|
-
|
|
723
|
+
type Foo = {
|
|
675
724
|
[x: string]: unknown;
|
|
676
725
|
[x: number]: unknown;
|
|
677
726
|
foo: string;
|
|
678
727
|
bar: symbol;
|
|
679
|
-
}
|
|
728
|
+
};
|
|
680
729
|
|
|
681
730
|
type Bar = {
|
|
682
731
|
[x: number]: number;
|
|
@@ -738,7 +787,7 @@ type Any = HomomorphicPick<{a: 1; b: 2} | {c: 3}, any>;
|
|
|
738
787
|
type IndexSignature = HomomorphicPick<{[k: string]: unknown}, number>;
|
|
739
788
|
//=> {}
|
|
740
789
|
*/
|
|
741
|
-
type HomomorphicPick<T
|
|
790
|
+
type HomomorphicPick<T, Keys extends KeysOfUnion<T>> = { [P in keyof T as Extract<P, Keys>]: T[P] };
|
|
742
791
|
/**
|
|
743
792
|
Merges user specified options with default options.
|
|
744
793
|
|
|
@@ -855,12 +904,14 @@ type Foo = {
|
|
|
855
904
|
type FooWithoutA = Except<Foo, 'a'>;
|
|
856
905
|
//=> {b: string}
|
|
857
906
|
|
|
907
|
+
// @ts-expect-error
|
|
858
908
|
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
859
909
|
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
860
910
|
|
|
861
911
|
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
862
912
|
//=> {a: number} & Partial<Record<"b", never>>
|
|
863
913
|
|
|
914
|
+
// @ts-expect-error
|
|
864
915
|
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
865
916
|
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
866
917
|
|
|
@@ -877,12 +928,12 @@ type UserData = {
|
|
|
877
928
|
|
|
878
929
|
// `Omit` clearly doesn't behave as expected in this case:
|
|
879
930
|
type PostPayload = Omit<UserData, 'email'>;
|
|
880
|
-
//=>
|
|
931
|
+
//=> { [x: string]: string; [x: number]: string; }
|
|
881
932
|
|
|
882
933
|
// In situations like this, `Except` works better.
|
|
883
934
|
// It simply removes the `email` key while preserving all the other keys.
|
|
884
|
-
type
|
|
885
|
-
//=>
|
|
935
|
+
type PostPayloadFixed = Except<UserData, 'email'>;
|
|
936
|
+
//=> { [x: string]: string; name: string; role: 'admin' | 'user'; }
|
|
886
937
|
```
|
|
887
938
|
|
|
888
939
|
@category Object
|
|
@@ -906,7 +957,7 @@ type Responder = {
|
|
|
906
957
|
|
|
907
958
|
const responder: RequireAtLeastOne<Responder, 'text' | 'json'> = {
|
|
908
959
|
json: () => '{"message": "ok"}',
|
|
909
|
-
secure: true
|
|
960
|
+
secure: true,
|
|
910
961
|
};
|
|
911
962
|
```
|
|
912
963
|
|
|
@@ -964,7 +1015,7 @@ Note that types containing overloaded functions are not made deeply required due
|
|
|
964
1015
|
@category Set
|
|
965
1016
|
@category Map
|
|
966
1017
|
*/
|
|
967
|
-
type RequiredDeep<T
|
|
1018
|
+
type RequiredDeep<T> = T extends BuiltIns ? T : T extends Map<infer KeyType, infer ValueType> ? Map<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : T extends Set<infer ItemType> ? Set<RequiredDeep<ItemType>> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? ReadonlyMap<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : T extends ReadonlySet<infer ItemType> ? ReadonlySet<RequiredDeep<ItemType>> : T extends WeakMap<infer KeyType, infer ValueType> ? WeakMap<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : T extends WeakSet<infer ItemType> ? WeakSet<RequiredDeep<ItemType>> : T extends Promise<infer ValueType> ? Promise<RequiredDeep<ValueType>> : T extends ((...arguments_: any[]) => unknown) ? IsNever<keyof T> extends true ? T : HasMultipleCallSignatures<T> extends true ? T : ((...arguments_: Parameters<T>) => ReturnType<T>) & RequiredObjectDeep<T> : T extends object ? RequiredObjectDeep<T> : unknown;
|
|
968
1019
|
type RequiredObjectDeep<ObjectType extends object> = { [KeyType in keyof ObjectType]-?: RequiredDeep<ObjectType[KeyType]> };
|
|
969
1020
|
//#endregion
|
|
970
1021
|
//#region ../../node_modules/type-fest/source/set-optional.d.ts
|
|
@@ -981,7 +1032,7 @@ type Foo = {
|
|
|
981
1032
|
a: number;
|
|
982
1033
|
b?: string;
|
|
983
1034
|
c: boolean;
|
|
984
|
-
}
|
|
1035
|
+
};
|
|
985
1036
|
|
|
986
1037
|
type SomeOptional = SetOptional<Foo, 'b' | 'c'>;
|
|
987
1038
|
// type SomeOptional = {
|
|
@@ -1015,7 +1066,7 @@ type Foo = {
|
|
|
1015
1066
|
a?: number;
|
|
1016
1067
|
b: string;
|
|
1017
1068
|
c?: boolean;
|
|
1018
|
-
}
|
|
1069
|
+
};
|
|
1019
1070
|
|
|
1020
1071
|
type SomeRequired = SetRequired<Foo, 'b' | 'c'>;
|
|
1021
1072
|
// type SomeRequired = {
|
|
@@ -1062,7 +1113,7 @@ type StringUnionToFullOptionArray<Op extends string> = Array<Op extends unknown
|
|
|
1062
1113
|
*
|
|
1063
1114
|
* @group Option Lists
|
|
1064
1115
|
*/
|
|
1065
|
-
type GetOptionType<OL
|
|
1116
|
+
type GetOptionType<OL extends FlexibleOptionList<FullOption>> = OL extends FlexibleOptionList<infer Opt> ? Opt : never;
|
|
1066
1117
|
/**
|
|
1067
1118
|
* Extracts the type of the identifying property from a {@link Option},
|
|
1068
1119
|
* {@link ValueOption}, or {@link FullOption}.
|
|
@@ -1073,7 +1124,7 @@ type GetOptionIdentifierType<Opt$1 extends BaseOption> = Opt$1 extends Option<in
|
|
|
1073
1124
|
/**
|
|
1074
1125
|
* Adds an `unknown` index property to an interface.
|
|
1075
1126
|
*/
|
|
1076
|
-
type WithUnknownIndex<T
|
|
1127
|
+
type WithUnknownIndex<T> = T & {
|
|
1077
1128
|
[key: string]: unknown;
|
|
1078
1129
|
};
|
|
1079
1130
|
/**
|
|
@@ -1238,9 +1289,9 @@ interface CommonRuleAndGroupProperties {
|
|
|
1238
1289
|
* The main rule type. The `field`, `operator`, and `value` properties
|
|
1239
1290
|
* can be narrowed with generics.
|
|
1240
1291
|
*/
|
|
1241
|
-
interface RuleType<F
|
|
1242
|
-
field: F
|
|
1243
|
-
operator: O
|
|
1292
|
+
interface RuleType<F extends string = string, O extends string = string, V$1 = any, C extends string = string> extends CommonRuleAndGroupProperties {
|
|
1293
|
+
field: F;
|
|
1294
|
+
operator: O;
|
|
1244
1295
|
value: V$1;
|
|
1245
1296
|
valueSource?: ValueSource;
|
|
1246
1297
|
match?: MatchConfig;
|
|
@@ -1253,15 +1304,15 @@ interface RuleType<F$1 extends string = string, O$1 extends string = string, V$1
|
|
|
1253
1304
|
* The main rule group type. This type is used for query definitions as well as
|
|
1254
1305
|
* all sub-groups of queries.
|
|
1255
1306
|
*/
|
|
1256
|
-
interface RuleGroupType<R
|
|
1307
|
+
interface RuleGroupType<R extends RuleType = RuleType, C extends string = string> extends CommonRuleAndGroupProperties {
|
|
1257
1308
|
combinator: C;
|
|
1258
|
-
rules: RuleGroupArray<RuleGroupType<R
|
|
1309
|
+
rules: RuleGroupArray<RuleGroupType<R, C>, R>;
|
|
1259
1310
|
not?: boolean;
|
|
1260
1311
|
}
|
|
1261
1312
|
/**
|
|
1262
1313
|
* The type of the `rules` array in a {@link RuleGroupType}.
|
|
1263
1314
|
*/
|
|
1264
|
-
type RuleGroupArray<RG
|
|
1315
|
+
type RuleGroupArray<RG extends RuleGroupType = RuleGroupType, R extends RuleType = RuleType> = (R | RG)[];
|
|
1265
1316
|
/**
|
|
1266
1317
|
* All updateable properties of rules and groups (everything except
|
|
1267
1318
|
* `id`, `path`, and `rules`).
|
|
@@ -1270,18 +1321,18 @@ type UpdateableProperties = Exclude<keyof (RuleType & RuleGroupType), "id" | "pa
|
|
|
1270
1321
|
/**
|
|
1271
1322
|
* The type of the `rules` array in a {@link DefaultRuleGroupType}.
|
|
1272
1323
|
*/
|
|
1273
|
-
type DefaultRuleGroupArray<F
|
|
1324
|
+
type DefaultRuleGroupArray<F extends string = string> = RuleGroupArray<DefaultRuleGroupType, DefaultRuleType<F>>;
|
|
1274
1325
|
/**
|
|
1275
1326
|
* {@link RuleGroupType} with the `combinator` property limited to
|
|
1276
1327
|
* {@link DefaultCombinatorNameExtended} and `rules` limited to {@link DefaultRuleType}.
|
|
1277
1328
|
*/
|
|
1278
|
-
type DefaultRuleGroupType<F
|
|
1279
|
-
rules: DefaultRuleGroupArray<F
|
|
1329
|
+
type DefaultRuleGroupType<F extends string = string> = RuleGroupType<DefaultRuleType<F>, DefaultCombinatorNameExtended> & {
|
|
1330
|
+
rules: DefaultRuleGroupArray<F>;
|
|
1280
1331
|
};
|
|
1281
1332
|
/**
|
|
1282
1333
|
* {@link RuleType} with the `operator` property limited to {@link DefaultOperatorName}.
|
|
1283
1334
|
*/
|
|
1284
|
-
type DefaultRuleType<F
|
|
1335
|
+
type DefaultRuleType<F extends string = string> = RuleType<F, DefaultOperatorName>;
|
|
1285
1336
|
/**
|
|
1286
1337
|
* Default allowed values for the `combinator` property.
|
|
1287
1338
|
*
|
|
@@ -1328,9 +1379,9 @@ type MappedTuple<Tuple extends Array<unknown>, Result extends Array<unknown> = [
|
|
|
1328
1379
|
* The main rule group interface when using independent combinators. This type is used
|
|
1329
1380
|
* for query definitions as well as all sub-groups of queries.
|
|
1330
1381
|
*/
|
|
1331
|
-
interface RuleGroupTypeIC<R
|
|
1382
|
+
interface RuleGroupTypeIC<R extends RuleType = RuleType, C extends string = string> extends Except<RuleGroupType<R, C>, "combinator" | "rules"> {
|
|
1332
1383
|
combinator?: undefined;
|
|
1333
|
-
rules: RuleGroupICArray<RuleGroupTypeIC<R
|
|
1384
|
+
rules: RuleGroupICArray<RuleGroupTypeIC<R, C>, R, C>;
|
|
1334
1385
|
/**
|
|
1335
1386
|
* Only used when adding a rule to a query that uses independent combinators
|
|
1336
1387
|
*/
|
|
@@ -1339,11 +1390,11 @@ interface RuleGroupTypeIC<R$1 extends RuleType = RuleType, C extends string = st
|
|
|
1339
1390
|
/**
|
|
1340
1391
|
* Shorthand for "either {@link RuleGroupType} or {@link RuleGroupTypeIC}".
|
|
1341
1392
|
*/
|
|
1342
|
-
type RuleGroupTypeAny<R
|
|
1393
|
+
type RuleGroupTypeAny<R extends RuleType = RuleType, C extends string = string> = RuleGroupType<R, C> | RuleGroupTypeIC<R, C>;
|
|
1343
1394
|
/**
|
|
1344
1395
|
* The type of the `rules` array in a {@link RuleGroupTypeIC}.
|
|
1345
1396
|
*/
|
|
1346
|
-
type RuleGroupICArray<RG
|
|
1397
|
+
type RuleGroupICArray<RG extends RuleGroupTypeIC = RuleGroupTypeIC, R extends RuleType = RuleType, C extends string = string> = [R | RG] | [R | RG, ...MappedTuple<[C, R | RG]>] | ((R | RG)[] & {
|
|
1347
1398
|
length: 0;
|
|
1348
1399
|
});
|
|
1349
1400
|
/**
|
|
@@ -1353,27 +1404,27 @@ type RuleOrGroupArray = RuleGroupArray | RuleGroupICArray;
|
|
|
1353
1404
|
/**
|
|
1354
1405
|
* The type of the `rules` array in a {@link DefaultRuleGroupTypeIC}.
|
|
1355
1406
|
*/
|
|
1356
|
-
type DefaultRuleGroupICArray<F
|
|
1407
|
+
type DefaultRuleGroupICArray<F extends string = string> = RuleGroupICArray<DefaultRuleGroupTypeIC<F>, DefaultRuleType<F>, DefaultCombinatorName>;
|
|
1357
1408
|
/**
|
|
1358
1409
|
* Shorthand for "either {@link DefaultRuleGroupArray} or {@link DefaultRuleGroupICArray}".
|
|
1359
1410
|
*/
|
|
1360
|
-
type DefaultRuleOrGroupArray<F
|
|
1411
|
+
type DefaultRuleOrGroupArray<F extends string = string> = DefaultRuleGroupArray<F> | DefaultRuleGroupICArray<F>;
|
|
1361
1412
|
/**
|
|
1362
1413
|
* {@link RuleGroupTypeIC} with combinators limited to
|
|
1363
1414
|
* {@link DefaultCombinatorName} and rules limited to {@link DefaultRuleType}.
|
|
1364
1415
|
*/
|
|
1365
|
-
interface DefaultRuleGroupTypeIC<F
|
|
1366
|
-
rules: DefaultRuleGroupICArray<F
|
|
1416
|
+
interface DefaultRuleGroupTypeIC<F extends string = string> extends RuleGroupTypeIC<DefaultRuleType<F>> {
|
|
1417
|
+
rules: DefaultRuleGroupICArray<F>;
|
|
1367
1418
|
}
|
|
1368
1419
|
/**
|
|
1369
1420
|
* Shorthand for "either {@link DefaultRuleGroupType} or {@link DefaultRuleGroupTypeIC}".
|
|
1370
1421
|
*/
|
|
1371
|
-
type DefaultRuleGroupTypeAny<F
|
|
1422
|
+
type DefaultRuleGroupTypeAny<F extends string = string> = DefaultRuleGroupType<F> | DefaultRuleGroupTypeIC<F>;
|
|
1372
1423
|
/**
|
|
1373
1424
|
* Determines if a type extending {@link RuleGroupTypeAny} is actually
|
|
1374
1425
|
* {@link RuleGroupType} or {@link RuleGroupTypeIC}.
|
|
1375
1426
|
*/
|
|
1376
|
-
type GetRuleGroupType<RG
|
|
1427
|
+
type GetRuleGroupType<RG> = RG extends {
|
|
1377
1428
|
combinator: string;
|
|
1378
1429
|
} ? RuleGroupType : RuleGroupTypeIC;
|
|
1379
1430
|
/**
|
|
@@ -1384,11 +1435,11 @@ type GetRuleGroupType<RG$1> = RG$1 extends {
|
|
|
1384
1435
|
* the rule type has its field and operator types narrowed to the
|
|
1385
1436
|
* identifier types of the provided Field and Operator types.
|
|
1386
1437
|
*/
|
|
1387
|
-
type GetRuleTypeFromGroupWithFieldAndOperator<RG
|
|
1438
|
+
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;
|
|
1388
1439
|
/**
|
|
1389
1440
|
* Converts a narrowed rule group type to its most generic form.
|
|
1390
1441
|
*/
|
|
1391
|
-
type GenericizeRuleGroupType<RG
|
|
1442
|
+
type GenericizeRuleGroupType<RG> = RG extends RuleGroupType ? RuleGroupType : RuleGroupTypeIC;
|
|
1392
1443
|
//#endregion
|
|
1393
1444
|
//#region src/types/validation.d.ts
|
|
1394
1445
|
/**
|
|
@@ -1444,7 +1495,7 @@ type ToOptionArrays<Sources extends readonly string[]> = Sources extends unknown
|
|
|
1444
1495
|
label: string;
|
|
1445
1496
|
} } : never;
|
|
1446
1497
|
type ToFlexibleOptionArrays<Sources extends readonly string[]> = Sources extends unknown ? { [K in keyof Sources]: FlexibleOption<Sources[K]> } : never;
|
|
1447
|
-
type WithOptionalClassName<T
|
|
1498
|
+
type WithOptionalClassName<T> = T & {
|
|
1448
1499
|
className?: Classname;
|
|
1449
1500
|
};
|
|
1450
1501
|
/**
|
|
@@ -1528,11 +1579,11 @@ type FieldByValue<FieldName extends string = string, OperatorName extends string
|
|
|
1528
1579
|
/**
|
|
1529
1580
|
* Utility type to make one or more properties required.
|
|
1530
1581
|
*/
|
|
1531
|
-
type WithRequired<T
|
|
1582
|
+
type WithRequired<T, K$1 extends keyof T> = T & { [P in K$1]-?: T[P] };
|
|
1532
1583
|
/**
|
|
1533
1584
|
* Utility type to make all properties non-nullable.
|
|
1534
1585
|
*/
|
|
1535
|
-
type RemoveNullability<T
|
|
1586
|
+
type RemoveNullability<T extends Record<string, unknown>> = { [k in keyof T]: NonNullable<T[k]> };
|
|
1536
1587
|
/**
|
|
1537
1588
|
* Allowed values of the {@link FullOperator} property `arity`. A value of `"unary"` or
|
|
1538
1589
|
* a number less than two will cause the default {@link react-querybuilder!ValueEditor ValueEditor} to render `null`.
|
|
@@ -2288,9 +2339,13 @@ interface Classnames {
|
|
|
2288
2339
|
*/
|
|
2289
2340
|
branches: Classname;
|
|
2290
2341
|
/**
|
|
2291
|
-
* Classname(s) rules that render a subquery.
|
|
2342
|
+
* Classname(s) applied to rules that render a subquery.
|
|
2292
2343
|
*/
|
|
2293
2344
|
hasSubQuery: Classname;
|
|
2345
|
+
/**
|
|
2346
|
+
* Classname(s) applied to async components in their "loading" state.
|
|
2347
|
+
*/
|
|
2348
|
+
loading: Classname;
|
|
2294
2349
|
}
|
|
2295
2350
|
/**
|
|
2296
2351
|
* Placeholder strings for option lists.
|
|
@@ -2653,6 +2708,7 @@ declare const standardClassnames: {
|
|
|
2653
2708
|
readonly branches: "queryBuilder-branches";
|
|
2654
2709
|
readonly justified: "queryBuilder-justified";
|
|
2655
2710
|
readonly hasSubQuery: "rule-hasSubQuery";
|
|
2711
|
+
readonly loading: "queryBuilder-loading";
|
|
2656
2712
|
};
|
|
2657
2713
|
/**
|
|
2658
2714
|
* Default classnames for each component.
|
|
@@ -3642,7 +3698,7 @@ declare const nullOrUndefinedOrEmpty: (value: unknown) => value is null | undefi
|
|
|
3642
3698
|
* type ObjectKeys<T extends object> = `${Exclude<keyof T, symbol>}`;
|
|
3643
3699
|
* ```
|
|
3644
3700
|
*/
|
|
3645
|
-
type ObjectKeys<T
|
|
3701
|
+
type ObjectKeys<T extends object> = Exclude<keyof T, symbol>;
|
|
3646
3702
|
/**
|
|
3647
3703
|
* A strongly-typed version of `Object.keys()`.
|
|
3648
3704
|
*
|
|
@@ -3776,14 +3832,14 @@ declare const uniqOptGroups: <T extends BaseOption>(originalArray: FlexibleOptio
|
|
|
3776
3832
|
* @group Option Lists
|
|
3777
3833
|
*/
|
|
3778
3834
|
declare const uniqOptList: <T extends BaseOption>(originalArray: FlexibleOptionList<T>) => WithUnknownIndex<BaseOption & FullOption>[] | OptionGroup<ToFullOption<T>>[];
|
|
3779
|
-
interface PreparedOptionList<O
|
|
3835
|
+
interface PreparedOptionList<O extends FullOption> {
|
|
3780
3836
|
defaultOption: FullOption;
|
|
3781
|
-
optionList: FullOptionList<O
|
|
3837
|
+
optionList: FullOptionList<O>;
|
|
3782
3838
|
optionsMap: Partial<FullOptionRecord<FullOption>>;
|
|
3783
3839
|
}
|
|
3784
|
-
interface PrepareOptionListParams<O
|
|
3840
|
+
interface PrepareOptionListParams<O extends FullOption> {
|
|
3785
3841
|
placeholder?: Placeholder;
|
|
3786
|
-
optionList?: FlexibleOptionListProp<O
|
|
3842
|
+
optionList?: FlexibleOptionListProp<O> | BaseOptionMap<O>;
|
|
3787
3843
|
baseOption?: Record<string, unknown>;
|
|
3788
3844
|
labelMap?: Record<string, string>;
|
|
3789
3845
|
autoSelectOption?: boolean;
|
|
@@ -3856,6 +3912,17 @@ declare const getCommonAncestorPath: (path1: Path, path2: Path) => Path;
|
|
|
3856
3912
|
*/
|
|
3857
3913
|
declare const pathIsDisabled: (path: Path, query: RuleGroupTypeAny) => boolean;
|
|
3858
3914
|
//#endregion
|
|
3915
|
+
//#region ../react-querybuilder/src/redux/getRqbStore.d.ts
|
|
3916
|
+
declare global {
|
|
3917
|
+
var __RQB_DEVTOOLS__: boolean | undefined;
|
|
3918
|
+
}
|
|
3919
|
+
/**
|
|
3920
|
+
* Gets the singleton React Query Builder store instance.
|
|
3921
|
+
* DevTools are enabled if either:
|
|
3922
|
+
* - globalThis.__RQB_DEVTOOLS__ is truthy
|
|
3923
|
+
* - window.__RQB_DEVTOOLS__ is truthy
|
|
3924
|
+
*/
|
|
3925
|
+
//#endregion
|
|
3859
3926
|
//#region src/utils/preferProp.d.ts
|
|
3860
3927
|
/**
|
|
3861
3928
|
* For given default, prop, and context values, return the first provided of prop,
|
|
@@ -4136,7 +4203,7 @@ declare const regenerateIDs: <RG>(subject: RG, {
|
|
|
4136
4203
|
/**
|
|
4137
4204
|
* Options object for {@link index!transformQuery transformQuery}.
|
|
4138
4205
|
*/
|
|
4139
|
-
interface TransformQueryOptions<RG
|
|
4206
|
+
interface TransformQueryOptions<RG extends RuleGroupTypeAny = RuleGroupType> {
|
|
4140
4207
|
/**
|
|
4141
4208
|
* When a rule is encountered in the hierarchy, it will be replaced
|
|
4142
4209
|
* with the result of this function.
|
|
@@ -4150,7 +4217,7 @@ interface TransformQueryOptions<RG$1 extends RuleGroupTypeAny = RuleGroupType> {
|
|
|
4150
4217
|
*
|
|
4151
4218
|
* @defaultValue `rg => rg`
|
|
4152
4219
|
*/
|
|
4153
|
-
ruleGroupProcessor?: (ruleGroup: RG
|
|
4220
|
+
ruleGroupProcessor?: (ruleGroup: RG) => Record<string, any>;
|
|
4154
4221
|
/**
|
|
4155
4222
|
* For each rule and group in the query, any properties matching a key
|
|
4156
4223
|
* in this object will be renamed to the corresponding value. To retain both
|