@regle/schemas 1.8.4 → 1.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/regle-schemas.d.ts +536 -471
- package/dist/regle-schemas.js +22 -28
- package/dist/regle-schemas.min.js +1 -1
- package/package.json +9 -17
package/dist/regle-schemas.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as vue0 from "vue";
|
|
1
2
|
import { MaybeRef, MaybeRefOrGetter, Raw, Ref, UnwrapNestedRefs, UnwrapRef } from "vue";
|
|
2
3
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
4
|
|
|
@@ -21,9 +22,9 @@ type isRecordLiteral<T extends unknown> = NonNullable<T> extends Date | File ? f
|
|
|
21
22
|
type NoInferLegacy<A extends any> = [A][A extends any ? 0 : never];
|
|
22
23
|
//#endregion
|
|
23
24
|
//#region src/types/utils/Array.types.d.ts
|
|
24
|
-
type ArrayElement
|
|
25
|
+
type ArrayElement<T> = T extends Array<infer U> ? U : never;
|
|
25
26
|
//#endregion
|
|
26
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
27
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/primitive.d.ts
|
|
27
28
|
/**
|
|
28
29
|
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
29
30
|
|
|
@@ -31,27 +32,7 @@ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/
|
|
|
31
32
|
*/
|
|
32
33
|
type Primitive$1 = null | undefined | string | number | boolean | symbol | bigint;
|
|
33
34
|
//#endregion
|
|
34
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
35
|
-
declare global {
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
37
|
-
interface SymbolConstructor {
|
|
38
|
-
readonly observable: symbol;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
@remarks
|
|
44
|
-
The TC39 observable proposal defines a `closed` property, but some implementations (such as xstream) do not as of 10/08/2021.
|
|
45
|
-
As well, some guidance on making an `Observable` to not include `closed` property.
|
|
46
|
-
@see https://github.com/tc39/proposal-observable/blob/master/src/Observable.js#L129-L130
|
|
47
|
-
@see https://github.com/staltz/xstream/blob/6c22580c1d84d69773ee4b0905df44ad464955b3/src/index.ts#L79-L85
|
|
48
|
-
@see https://github.com/benlesh/symbol-observable#making-an-object-observable
|
|
49
|
-
|
|
50
|
-
@category Observable
|
|
51
|
-
*/
|
|
52
|
-
|
|
53
|
-
//#endregion
|
|
54
|
-
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/union-to-intersection.d.ts
|
|
35
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/union-to-intersection.d.ts
|
|
55
36
|
/**
|
|
56
37
|
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).
|
|
57
38
|
|
|
@@ -113,7 +94,7 @@ Union extends unknown
|
|
|
113
94
|
// The `& Union` is to allow indexing by the resulting type
|
|
114
95
|
? Intersection & Union : never;
|
|
115
96
|
//#endregion
|
|
116
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
97
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/empty-object.d.ts
|
|
117
98
|
declare const emptyObjectSymbol$1: unique symbol;
|
|
118
99
|
|
|
119
100
|
/**
|
|
@@ -145,7 +126,6 @@ Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<n
|
|
|
145
126
|
type EmptyObject$1 = {
|
|
146
127
|
[emptyObjectSymbol$1]?: never;
|
|
147
128
|
};
|
|
148
|
-
|
|
149
129
|
/**
|
|
150
130
|
Returns a `boolean` for whether the type is strictly equal to an empty plain object, the `{}` value.
|
|
151
131
|
|
|
@@ -161,9 +141,83 @@ type Fail = IsEmptyObject<null>; //=> false
|
|
|
161
141
|
@see EmptyObject
|
|
162
142
|
@category Object
|
|
163
143
|
*/
|
|
164
|
-
type IsEmptyObject
|
|
144
|
+
type IsEmptyObject<T> = T extends EmptyObject$1 ? true : false;
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/is-any.d.ts
|
|
147
|
+
/**
|
|
148
|
+
Returns a boolean for whether the given type is `any`.
|
|
149
|
+
|
|
150
|
+
@link https://stackoverflow.com/a/49928360/1490091
|
|
151
|
+
|
|
152
|
+
Useful in type utilities, such as disallowing `any`s to be passed to a function.
|
|
153
|
+
|
|
154
|
+
@example
|
|
155
|
+
```
|
|
156
|
+
import type {IsAny} from 'type-fest';
|
|
157
|
+
|
|
158
|
+
const typedObject = {a: 1, b: 2} as const;
|
|
159
|
+
const anyObject: any = {a: 1, b: 2};
|
|
160
|
+
|
|
161
|
+
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(obj: O, key: K) {
|
|
162
|
+
return obj[key];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const typedA = get(typedObject, 'a');
|
|
166
|
+
//=> 1
|
|
167
|
+
|
|
168
|
+
const anyA = get(anyObject, 'a');
|
|
169
|
+
//=> any
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
@category Type Guard
|
|
173
|
+
@category Utilities
|
|
174
|
+
*/
|
|
175
|
+
type IsAny$1<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
178
|
+
/**
|
|
179
|
+
Returns a boolean for whether the given key is an optional key of type.
|
|
180
|
+
|
|
181
|
+
This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
|
|
182
|
+
|
|
183
|
+
@example
|
|
184
|
+
```
|
|
185
|
+
import type {IsOptionalKeyOf} from 'type-fest';
|
|
186
|
+
|
|
187
|
+
interface User {
|
|
188
|
+
name: string;
|
|
189
|
+
surname: string;
|
|
190
|
+
|
|
191
|
+
luckyNumber?: number;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
interface Admin {
|
|
195
|
+
name: string;
|
|
196
|
+
surname?: string;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
|
|
200
|
+
//=> true
|
|
201
|
+
|
|
202
|
+
type T2 = IsOptionalKeyOf<User, 'name'>;
|
|
203
|
+
//=> false
|
|
204
|
+
|
|
205
|
+
type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
|
|
206
|
+
//=> boolean
|
|
207
|
+
|
|
208
|
+
type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
|
|
209
|
+
//=> false
|
|
210
|
+
|
|
211
|
+
type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
212
|
+
//=> boolean
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
@category Type Guard
|
|
216
|
+
@category Utilities
|
|
217
|
+
*/
|
|
218
|
+
type IsOptionalKeyOf$1<Type extends object, Key extends keyof Type> = IsAny$1<Type | Key> extends true ? never : Key extends keyof Type ? Type extends Record<Key, Type[Key]> ? false : true : false;
|
|
165
219
|
//#endregion
|
|
166
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
220
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/optional-keys-of.d.ts
|
|
167
221
|
/**
|
|
168
222
|
Extract all optional keys from the given type.
|
|
169
223
|
|
|
@@ -197,11 +251,11 @@ const update2: UpdateOperation<User> = {
|
|
|
197
251
|
|
|
198
252
|
@category Utilities
|
|
199
253
|
*/
|
|
200
|
-
type OptionalKeysOf$1<
|
|
201
|
-
? (keyof { [Key in keyof
|
|
202
|
-
: never;
|
|
254
|
+
type OptionalKeysOf$1<Type extends object> = Type extends unknown // For distributing `Type`
|
|
255
|
+
? (keyof { [Key in keyof Type as IsOptionalKeyOf$1<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`
|
|
256
|
+
: never;
|
|
203
257
|
//#endregion
|
|
204
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
258
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/required-keys-of.d.ts
|
|
205
259
|
/**
|
|
206
260
|
Extract all required keys from the given type.
|
|
207
261
|
|
|
@@ -226,11 +280,10 @@ const validator2 = createValidation<User>('surname', value => value.length < 25)
|
|
|
226
280
|
|
|
227
281
|
@category Utilities
|
|
228
282
|
*/
|
|
229
|
-
type RequiredKeysOf$1<
|
|
230
|
-
? Exclude<keyof
|
|
231
|
-
|
|
283
|
+
type RequiredKeysOf$1<Type extends object> = Type extends unknown // For distributing `Type`
|
|
284
|
+
? Exclude<keyof Type, OptionalKeysOf$1<Type>> : never;
|
|
232
285
|
//#endregion
|
|
233
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
286
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/is-never.d.ts
|
|
234
287
|
/**
|
|
235
288
|
Returns a boolean for whether the given type is `never`.
|
|
236
289
|
|
|
@@ -274,124 +327,171 @@ endIfEqual('abc', '123');
|
|
|
274
327
|
*/
|
|
275
328
|
type IsNever$1<T> = [T] extends [never] ? true : false;
|
|
276
329
|
//#endregion
|
|
277
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
330
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/if.d.ts
|
|
278
331
|
/**
|
|
279
|
-
An if-else-like type that resolves depending on whether the given type is `
|
|
332
|
+
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
333
|
+
|
|
334
|
+
Use-cases:
|
|
335
|
+
- You can use this in combination with `Is*` types to create an if-else-like experience. For example, `If<IsAny<any>, 'is any', 'not any'>`.
|
|
280
336
|
|
|
281
|
-
|
|
337
|
+
Note:
|
|
338
|
+
- Returns a union of if branch and else branch if the given type is `boolean` or `any`. For example, `If<boolean, 'Y', 'N'>` will return `'Y' | 'N'`.
|
|
339
|
+
- Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
|
|
282
340
|
|
|
283
341
|
@example
|
|
284
342
|
```
|
|
285
|
-
import
|
|
343
|
+
import {If} from 'type-fest';
|
|
286
344
|
|
|
287
|
-
type
|
|
288
|
-
//=>
|
|
345
|
+
type A = If<true, 'yes', 'no'>;
|
|
346
|
+
//=> 'yes'
|
|
289
347
|
|
|
290
|
-
type
|
|
291
|
-
//=> '
|
|
292
|
-
```
|
|
348
|
+
type B = If<false, 'yes', 'no'>;
|
|
349
|
+
//=> 'no'
|
|
293
350
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
*/
|
|
297
|
-
type IfNever$1$1<T, TypeIfNever = true, TypeIfNotNever = false> = (IsNever$1<T> extends true ? TypeIfNever : TypeIfNotNever);
|
|
298
|
-
//#endregion
|
|
299
|
-
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/is-any.d.ts
|
|
300
|
-
// Can eventually be replaced with the built-in once this library supports
|
|
301
|
-
// TS5.4+ only. Tracked in https://github.com/sindresorhus/type-fest/issues/848
|
|
302
|
-
type NoInfer$1<T> = T extends infer U ? U : never;
|
|
351
|
+
type C = If<boolean, 'yes', 'no'>;
|
|
352
|
+
//=> 'yes' | 'no'
|
|
303
353
|
|
|
304
|
-
|
|
305
|
-
|
|
354
|
+
type D = If<any, 'yes', 'no'>;
|
|
355
|
+
//=> 'yes' | 'no'
|
|
306
356
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
357
|
+
type E = If<never, 'yes', 'no'>;
|
|
358
|
+
//=> 'no'
|
|
359
|
+
```
|
|
310
360
|
|
|
311
361
|
@example
|
|
312
362
|
```
|
|
313
|
-
import
|
|
363
|
+
import {If, IsAny, IsNever} from 'type-fest';
|
|
314
364
|
|
|
315
|
-
|
|
316
|
-
|
|
365
|
+
type A = If<IsAny<unknown>, 'is any', 'not any'>;
|
|
366
|
+
//=> 'not any'
|
|
317
367
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
368
|
+
type B = If<IsNever<never>, 'is never', 'not never'>;
|
|
369
|
+
//=> 'is never'
|
|
370
|
+
```
|
|
321
371
|
|
|
322
|
-
|
|
323
|
-
|
|
372
|
+
@example
|
|
373
|
+
```
|
|
374
|
+
import {If, IsEqual} from 'type-fest';
|
|
324
375
|
|
|
325
|
-
|
|
326
|
-
|
|
376
|
+
type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
|
|
377
|
+
|
|
378
|
+
type A = IfEqual<string, string, 'equal', 'not equal'>;
|
|
379
|
+
//=> 'equal'
|
|
380
|
+
|
|
381
|
+
type B = IfEqual<string, number, 'equal', 'not equal'>;
|
|
382
|
+
//=> 'not equal'
|
|
327
383
|
```
|
|
328
384
|
|
|
329
385
|
@category Type Guard
|
|
330
386
|
@category Utilities
|
|
331
387
|
*/
|
|
332
|
-
type
|
|
388
|
+
type If$1<Type extends boolean, IfBranch, ElseBranch> = IsNever$1<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
|
|
333
389
|
//#endregion
|
|
334
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
390
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/internal/type.d.ts
|
|
335
391
|
/**
|
|
336
|
-
|
|
392
|
+
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
393
|
+
*/
|
|
394
|
+
type BuiltIns$1 = Primitive$1 | void | Date | RegExp;
|
|
395
|
+
/**
|
|
396
|
+
Test if the given function has multiple call signatures.
|
|
337
397
|
|
|
338
|
-
|
|
339
|
-
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
398
|
+
Needed to handle the case of a single call signature with properties.
|
|
340
399
|
|
|
341
|
-
|
|
342
|
-
|
|
400
|
+
Multiple call signatures cannot currently be supported due to a TypeScript limitation.
|
|
401
|
+
@see https://github.com/microsoft/TypeScript/issues/29732
|
|
402
|
+
*/
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
An if-else-like type that resolves depending on whether the given type is `any` or `never`.
|
|
343
406
|
|
|
344
407
|
@example
|
|
345
408
|
```
|
|
346
|
-
|
|
409
|
+
// When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
|
|
410
|
+
type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
411
|
+
//=> 'VALID'
|
|
347
412
|
|
|
348
|
-
//
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
Value extends readonly [Value[0], ...infer rest]
|
|
352
|
-
? IsEqual<Value[0], Item> extends true
|
|
353
|
-
? true
|
|
354
|
-
: Includes<rest, Item>
|
|
355
|
-
: false;
|
|
356
|
-
```
|
|
413
|
+
// When `T` is `any` => Returns `IfAny` branch
|
|
414
|
+
type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
415
|
+
//=> 'IS_ANY'
|
|
357
416
|
|
|
358
|
-
|
|
359
|
-
|
|
417
|
+
// When `T` is `never` => Returns `IfNever` branch
|
|
418
|
+
type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
419
|
+
//=> 'IS_NEVER'
|
|
420
|
+
```
|
|
360
421
|
*/
|
|
361
|
-
type
|
|
422
|
+
type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> = If$1<IsAny$1<T>, IfAny, If$1<IsNever$1<T>, IfNever, IfNotAnyOrNever>>;
|
|
362
423
|
//#endregion
|
|
363
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
424
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/is-null.d.ts
|
|
364
425
|
/**
|
|
365
|
-
Returns a boolean for whether
|
|
366
|
-
|
|
367
|
-
Use-case: Constructing complex conditional types where multiple conditions must be satisfied.
|
|
426
|
+
Returns a boolean for whether the given type is `null`.
|
|
368
427
|
|
|
369
428
|
@example
|
|
370
429
|
```
|
|
371
|
-
import type {
|
|
430
|
+
import type {IsNull} from 'type-fest';
|
|
372
431
|
|
|
373
|
-
|
|
374
|
-
//=> true
|
|
432
|
+
type NonNullFallback<T, Fallback> = IsNull<T> extends true ? Fallback : T;
|
|
375
433
|
|
|
376
|
-
|
|
377
|
-
//=>
|
|
434
|
+
type Example1 = NonNullFallback<null, string>;
|
|
435
|
+
//=> string
|
|
436
|
+
|
|
437
|
+
type Example2 = NonNullFallback<number, string>;
|
|
438
|
+
//=? number
|
|
378
439
|
```
|
|
379
440
|
|
|
380
|
-
@
|
|
441
|
+
@category Type Guard
|
|
442
|
+
@category Utilities
|
|
381
443
|
*/
|
|
382
|
-
type
|
|
444
|
+
type IsNull<T> = [T] extends [null] ? true : false;
|
|
383
445
|
//#endregion
|
|
384
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
446
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/is-unknown.d.ts
|
|
385
447
|
/**
|
|
386
|
-
|
|
387
|
-
*/
|
|
388
|
-
type RequireNone<KeysType extends PropertyKey> = Partial<Record<KeysType, never>>;
|
|
448
|
+
Returns a boolean for whether the given type is `unknown`.
|
|
389
449
|
|
|
390
|
-
|
|
391
|
-
|
|
450
|
+
@link https://github.com/dsherret/conditional-type-checks/pull/16
|
|
451
|
+
|
|
452
|
+
Useful in type utilities, such as when dealing with unknown data from API calls.
|
|
453
|
+
|
|
454
|
+
@example
|
|
455
|
+
```
|
|
456
|
+
import type {IsUnknown} from 'type-fest';
|
|
457
|
+
|
|
458
|
+
// https://github.com/pajecawav/tiny-global-store/blob/master/src/index.ts
|
|
459
|
+
type Action<TState, TPayload = void> =
|
|
460
|
+
IsUnknown<TPayload> extends true
|
|
461
|
+
? (state: TState) => TState,
|
|
462
|
+
: (state: TState, payload: TPayload) => TState;
|
|
463
|
+
|
|
464
|
+
class Store<TState> {
|
|
465
|
+
constructor(private state: TState) {}
|
|
466
|
+
|
|
467
|
+
execute<TPayload = void>(action: Action<TState, TPayload>, payload?: TPayload): TState {
|
|
468
|
+
this.state = action(this.state, payload);
|
|
469
|
+
return this.state;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
// ... other methods
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
const store = new Store({value: 1});
|
|
476
|
+
declare const someExternalData: unknown;
|
|
477
|
+
|
|
478
|
+
store.execute(state => ({value: state.value + 1}));
|
|
479
|
+
//=> `TPayload` is `void`
|
|
480
|
+
|
|
481
|
+
store.execute((state, payload) => ({value: state.value + payload}), 5);
|
|
482
|
+
//=> `TPayload` is `5`
|
|
483
|
+
|
|
484
|
+
store.execute((state, payload) => ({value: state.value + payload}), someExternalData);
|
|
485
|
+
//=> Errors: `action` is `(state: TState) => TState`
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
@category Utilities
|
|
392
489
|
*/
|
|
490
|
+
type IsUnknown<T> = (unknown extends T // `T` can be `unknown` or `any`
|
|
491
|
+
? IsNull<T> extends false // `any` can be `null`, but `unknown` can't be
|
|
492
|
+
? true : false : false);
|
|
393
493
|
//#endregion
|
|
394
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
494
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/simplify.d.ts
|
|
395
495
|
/**
|
|
396
496
|
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.
|
|
397
497
|
|
|
@@ -451,7 +551,7 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
|
|
|
451
551
|
*/
|
|
452
552
|
type Simplify$1<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
453
553
|
//#endregion
|
|
454
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
554
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
455
555
|
/**
|
|
456
556
|
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
457
557
|
|
|
@@ -544,7 +644,7 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
|
544
644
|
*/
|
|
545
645
|
type OmitIndexSignature$1<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
546
646
|
//#endregion
|
|
547
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
647
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/pick-index-signature.d.ts
|
|
548
648
|
/**
|
|
549
649
|
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
550
650
|
|
|
@@ -592,7 +692,7 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
592
692
|
*/
|
|
593
693
|
type PickIndexSignature$1<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
594
694
|
//#endregion
|
|
595
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
695
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/merge.d.ts
|
|
596
696
|
// Merges two objects without worrying about index signatures.
|
|
597
697
|
type SimpleMerge$1<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source;
|
|
598
698
|
|
|
@@ -632,70 +732,7 @@ export type FooBar = Merge<Foo, Bar>;
|
|
|
632
732
|
*/
|
|
633
733
|
type Merge$1<Destination, Source> = Simplify$1<SimpleMerge$1<PickIndexSignature$1<Destination>, PickIndexSignature$1<Source>> & SimpleMerge$1<OmitIndexSignature$1<Destination>, OmitIndexSignature$1<Source>>>;
|
|
634
734
|
//#endregion
|
|
635
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
636
|
-
/**
|
|
637
|
-
An if-else-like type that resolves depending on whether the given type is `any`.
|
|
638
|
-
|
|
639
|
-
@see {@link IsAny}
|
|
640
|
-
|
|
641
|
-
@example
|
|
642
|
-
```
|
|
643
|
-
import type {IfAny} from 'type-fest';
|
|
644
|
-
|
|
645
|
-
type ShouldBeTrue = IfAny<any>;
|
|
646
|
-
//=> true
|
|
647
|
-
|
|
648
|
-
type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
|
|
649
|
-
//=> 'bar'
|
|
650
|
-
```
|
|
651
|
-
|
|
652
|
-
@category Type Guard
|
|
653
|
-
@category Utilities
|
|
654
|
-
*/
|
|
655
|
-
type IfAny$1$1<T, TypeIfAny = true, TypeIfNotAny = false> = (IsAny$1<T> extends true ? TypeIfAny : TypeIfNotAny);
|
|
656
|
-
//#endregion
|
|
657
|
-
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/internal/type.d.ts
|
|
658
|
-
/**
|
|
659
|
-
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
660
|
-
*/
|
|
661
|
-
type BuiltIns$1 = Primitive$1 | void | Date | RegExp;
|
|
662
|
-
|
|
663
|
-
/**
|
|
664
|
-
Matches non-recursive types.
|
|
665
|
-
*/
|
|
666
|
-
|
|
667
|
-
/**
|
|
668
|
-
Test if the given function has multiple call signatures.
|
|
669
|
-
|
|
670
|
-
Needed to handle the case of a single call signature with properties.
|
|
671
|
-
|
|
672
|
-
Multiple call signatures cannot currently be supported due to a TypeScript limitation.
|
|
673
|
-
@see https://github.com/microsoft/TypeScript/issues/29732
|
|
674
|
-
*/
|
|
675
|
-
|
|
676
|
-
// Should never happen
|
|
677
|
-
|
|
678
|
-
/**
|
|
679
|
-
An if-else-like type that resolves depending on whether the given type is `any` or `never`.
|
|
680
|
-
|
|
681
|
-
@example
|
|
682
|
-
```
|
|
683
|
-
// When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
|
|
684
|
-
type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
685
|
-
//=> 'VALID'
|
|
686
|
-
|
|
687
|
-
// When `T` is `any` => Returns `IfAny` branch
|
|
688
|
-
type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
689
|
-
//=> 'IS_ANY'
|
|
690
|
-
|
|
691
|
-
// When `T` is `never` => Returns `IfNever` branch
|
|
692
|
-
type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
693
|
-
//=> 'IS_NEVER'
|
|
694
|
-
```
|
|
695
|
-
*/
|
|
696
|
-
type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> = IsAny$1<T> extends true ? IfAny : IsNever$1<T> extends true ? IfNever : IfNotAnyOrNever;
|
|
697
|
-
//#endregion
|
|
698
|
-
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/internal/object.d.ts
|
|
735
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/internal/object.d.ts
|
|
699
736
|
/**
|
|
700
737
|
Merges user specified options with default options.
|
|
701
738
|
|
|
@@ -748,10 +785,95 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
|
|
|
748
785
|
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
749
786
|
```
|
|
750
787
|
*/
|
|
751
|
-
type ApplyDefaultOptions$1<Options extends object, Defaults extends Simplify$1<Omit<Required<Options>, RequiredKeysOf$1<Options>> & Partial<Record<RequiredKeysOf$1<Options>, never>>>, SpecifiedOptions extends Options> =
|
|
752
|
-
>>;
|
|
788
|
+
type ApplyDefaultOptions$1<Options extends object, Defaults extends Simplify$1<Omit<Required<Options>, RequiredKeysOf$1<Options>> & Partial<Record<RequiredKeysOf$1<Options>, never>>>, SpecifiedOptions extends Options> = If$1<IsAny$1<SpecifiedOptions>, Defaults, If$1<IsNever$1<SpecifiedOptions>, Defaults, Simplify$1<Merge$1<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf$1<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
|
|
753
789
|
//#endregion
|
|
754
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
790
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/or.d.ts
|
|
791
|
+
/**
|
|
792
|
+
Returns a boolean for whether either of two given types are true.
|
|
793
|
+
|
|
794
|
+
Use-case: Constructing complex conditional types where multiple conditions must be satisfied.
|
|
795
|
+
|
|
796
|
+
@example
|
|
797
|
+
```
|
|
798
|
+
import type {Or} from 'type-fest';
|
|
799
|
+
|
|
800
|
+
type TT = Or<true, false>;
|
|
801
|
+
//=> true
|
|
802
|
+
|
|
803
|
+
type TF = Or<true, false>;
|
|
804
|
+
//=> true
|
|
805
|
+
|
|
806
|
+
type FT = Or<false, true>;
|
|
807
|
+
//=> true
|
|
808
|
+
|
|
809
|
+
type FF = Or<false, false>;
|
|
810
|
+
//=> false
|
|
811
|
+
```
|
|
812
|
+
|
|
813
|
+
Note: When `boolean` is passed as an argument, it is distributed into separate cases, and the final result is a union of those cases.
|
|
814
|
+
For example, `And<false, boolean>` expands to `And<false, true> | And<false, false>`, which simplifies to `true | false` (i.e., `boolean`).
|
|
815
|
+
@example
|
|
816
|
+
```
|
|
817
|
+
import type {And} from 'type-fest';
|
|
818
|
+
|
|
819
|
+
type A = Or<false, boolean>;
|
|
820
|
+
//=> boolean
|
|
821
|
+
|
|
822
|
+
type B = Or<boolean, false>;
|
|
823
|
+
//=> boolean
|
|
824
|
+
|
|
825
|
+
type C = Or<true, boolean>;
|
|
826
|
+
//=> true
|
|
827
|
+
|
|
828
|
+
type D = Or<boolean, true>;
|
|
829
|
+
//=> true
|
|
830
|
+
|
|
831
|
+
type E = Or<boolean, boolean>;
|
|
832
|
+
//=> boolean
|
|
833
|
+
```
|
|
834
|
+
|
|
835
|
+
Note: If `never` is passed as an argument, it is treated as `false` and the result is computed accordingly.
|
|
836
|
+
|
|
837
|
+
@example
|
|
838
|
+
```
|
|
839
|
+
import type {Or} from 'type-fest';
|
|
840
|
+
|
|
841
|
+
type A = Or<true, never>;
|
|
842
|
+
//=> true
|
|
843
|
+
|
|
844
|
+
type B = Or<never, true>;
|
|
845
|
+
//=> true
|
|
846
|
+
|
|
847
|
+
type C = Or<false, never>;
|
|
848
|
+
//=> false
|
|
849
|
+
|
|
850
|
+
type D = Or<never, false>;
|
|
851
|
+
//=> false
|
|
852
|
+
|
|
853
|
+
type E = Or<boolean, never>;
|
|
854
|
+
//=> boolean
|
|
855
|
+
|
|
856
|
+
type F = Or<never, boolean>;
|
|
857
|
+
//=> boolean
|
|
858
|
+
|
|
859
|
+
type G = Or<never, never>;
|
|
860
|
+
//=> false
|
|
861
|
+
```
|
|
862
|
+
|
|
863
|
+
@see {@link And}
|
|
864
|
+
*/
|
|
865
|
+
type Or<A extends boolean, B extends boolean> = _Or<If$1<IsNever$1<A>, false, A>, If$1<IsNever$1<B>, false, B>>;
|
|
866
|
+
// `never` is treated as `false`
|
|
867
|
+
|
|
868
|
+
type _Or<A extends boolean, B extends boolean> = A extends true ? true : B extends true ? true : false;
|
|
869
|
+
//#endregion
|
|
870
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/internal/keys.d.ts
|
|
871
|
+
/**
|
|
872
|
+
Disallows any of the given keys.
|
|
873
|
+
*/
|
|
874
|
+
type RequireNone<KeysType extends PropertyKey> = Partial<Record<KeysType, never>>;
|
|
875
|
+
//#endregion
|
|
876
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/require-exactly-one.d.ts
|
|
755
877
|
/**
|
|
756
878
|
Create a type that requires exactly one of the given keys and disallows more. The remaining keys are kept as is.
|
|
757
879
|
|
|
@@ -781,10 +903,10 @@ const responder: RequireExactlyOne<Responder, 'text' | 'json'> = {
|
|
|
781
903
|
|
|
782
904
|
@category Object
|
|
783
905
|
*/
|
|
784
|
-
type RequireExactlyOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType,
|
|
906
|
+
type RequireExactlyOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, If$1<IsNever$1<KeysType>, never, _RequireExactlyOne<ObjectType, If$1<IsAny$1<KeysType>, keyof ObjectType, KeysType>>>>;
|
|
785
907
|
type _RequireExactlyOne<ObjectType, KeysType extends keyof ObjectType> = { [Key in KeysType]: (Required<Pick<ObjectType, Key>> & Partial<Record<Exclude<KeysType, Key>, never>>) }[KeysType] & Omit<ObjectType, KeysType>;
|
|
786
908
|
//#endregion
|
|
787
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
909
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/require-one-or-none.d.ts
|
|
788
910
|
/**
|
|
789
911
|
Create a type that requires exactly one of the given keys and disallows more, or none of the given keys. The remaining keys are kept as is.
|
|
790
912
|
|
|
@@ -815,10 +937,28 @@ const responder3: Responder = {
|
|
|
815
937
|
|
|
816
938
|
@category Object
|
|
817
939
|
*/
|
|
818
|
-
type RequireOneOrNone<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType,
|
|
940
|
+
type RequireOneOrNone<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, If$1<IsNever$1<KeysType>, ObjectType, _RequireOneOrNone<ObjectType, If$1<IsAny$1<KeysType>, keyof ObjectType, KeysType>>>>;
|
|
819
941
|
type _RequireOneOrNone<ObjectType, KeysType extends keyof ObjectType> = (RequireExactlyOne<ObjectType, KeysType> | RequireNone<KeysType>) & Omit<ObjectType, KeysType>; // Ignore unspecified keys.
|
|
820
942
|
//#endregion
|
|
821
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
943
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/is-union.d.ts
|
|
944
|
+
/**
|
|
945
|
+
Returns a boolean for whether the given type is a union.
|
|
946
|
+
|
|
947
|
+
@example
|
|
948
|
+
```
|
|
949
|
+
import type {IsUnion} from 'type-fest';
|
|
950
|
+
|
|
951
|
+
type A = IsUnion<string | number>;
|
|
952
|
+
//=> true
|
|
953
|
+
|
|
954
|
+
type B = IsUnion<string>;
|
|
955
|
+
//=> false
|
|
956
|
+
```
|
|
957
|
+
*/
|
|
958
|
+
|
|
959
|
+
// Should never happen
|
|
960
|
+
//#endregion
|
|
961
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/partial-deep.d.ts
|
|
822
962
|
/**
|
|
823
963
|
@see {@link PartialDeep}
|
|
824
964
|
*/
|
|
@@ -833,24 +973,23 @@ type PartialDeepOptions$1 = {
|
|
|
833
973
|
Allows `undefined` values in non-tuple arrays.
|
|
834
974
|
- When set to `true`, elements of non-tuple arrays can be `undefined`.
|
|
835
975
|
- When set to `false`, only explicitly defined elements are allowed in non-tuple arrays, ensuring stricter type checking.
|
|
836
|
-
@default
|
|
976
|
+
@default false
|
|
837
977
|
@example
|
|
838
|
-
You can
|
|
978
|
+
You can allow `undefined` values in non-tuple arrays by passing `{recurseIntoArrays: true; allowUndefinedInNonTupleArrays: true}` as the second type argument:
|
|
839
979
|
```
|
|
840
980
|
import type {PartialDeep} from 'type-fest';
|
|
841
981
|
type Settings = {
|
|
842
982
|
languages: string[];
|
|
843
983
|
};
|
|
844
|
-
declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays:
|
|
845
|
-
partialSettings.languages = [undefined]; //
|
|
846
|
-
partialSettings.languages = []; // Ok
|
|
984
|
+
declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays: true}>;
|
|
985
|
+
partialSettings.languages = [undefined]; // OK
|
|
847
986
|
```
|
|
848
987
|
*/
|
|
849
988
|
readonly allowUndefinedInNonTupleArrays?: boolean;
|
|
850
989
|
};
|
|
851
990
|
type DefaultPartialDeepOptions$1 = {
|
|
852
991
|
recurseIntoArrays: false;
|
|
853
|
-
allowUndefinedInNonTupleArrays:
|
|
992
|
+
allowUndefinedInNonTupleArrays: false;
|
|
854
993
|
};
|
|
855
994
|
|
|
856
995
|
/**
|
|
@@ -864,19 +1003,19 @@ Use-cases:
|
|
|
864
1003
|
```
|
|
865
1004
|
import type {PartialDeep} from 'type-fest';
|
|
866
1005
|
|
|
867
|
-
|
|
1006
|
+
let settings = {
|
|
868
1007
|
textEditor: {
|
|
869
1008
|
fontSize: 14,
|
|
870
1009
|
fontColor: '#000000',
|
|
871
|
-
fontWeight: 400
|
|
1010
|
+
fontWeight: 400,
|
|
872
1011
|
},
|
|
873
1012
|
autocomplete: false,
|
|
874
|
-
autosave: true
|
|
1013
|
+
autosave: true,
|
|
875
1014
|
};
|
|
876
1015
|
|
|
877
|
-
const applySavedSettings = (savedSettings: PartialDeep<
|
|
878
|
-
|
|
879
|
-
|
|
1016
|
+
const applySavedSettings = (savedSettings: PartialDeep<typeof settings>) => (
|
|
1017
|
+
{...settings, ...savedSettings, textEditor: {...settings.textEditor, ...savedSettings.textEditor}}
|
|
1018
|
+
);
|
|
880
1019
|
|
|
881
1020
|
settings = applySavedSettings({textEditor: {fontWeight: 500}});
|
|
882
1021
|
```
|
|
@@ -886,13 +1025,15 @@ By default, this does not affect elements in array and tuple types. You can chan
|
|
|
886
1025
|
```
|
|
887
1026
|
import type {PartialDeep} from 'type-fest';
|
|
888
1027
|
|
|
889
|
-
type
|
|
890
|
-
|
|
891
|
-
}
|
|
1028
|
+
type Shape = {
|
|
1029
|
+
dimensions: [number, number];
|
|
1030
|
+
};
|
|
892
1031
|
|
|
893
|
-
const
|
|
894
|
-
|
|
1032
|
+
const partialShape: PartialDeep<Shape, {recurseIntoArrays: true}> = {
|
|
1033
|
+
dimensions: [], // OK
|
|
895
1034
|
};
|
|
1035
|
+
|
|
1036
|
+
partialShape.dimensions = [15]; // OK
|
|
896
1037
|
```
|
|
897
1038
|
|
|
898
1039
|
@see {@link PartialDeepOptions}
|
|
@@ -936,10 +1077,51 @@ Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for
|
|
|
936
1077
|
*/
|
|
937
1078
|
type PartialObjectDeep$1<ObjectType extends object, Options extends Required<PartialDeepOptions$1>> = (ObjectType extends ((...arguments_: any) => unknown) ? (...arguments_: Parameters<ObjectType>) => ReturnType<ObjectType> : {}) & ({ [KeyType in keyof ObjectType]?: _PartialDeep$1<ObjectType[KeyType], Options> });
|
|
938
1079
|
//#endregion
|
|
939
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
1080
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/required-deep.d.ts
|
|
1081
|
+
/**
|
|
1082
|
+
Create a type from another type with all keys and nested keys set to required.
|
|
1083
|
+
|
|
1084
|
+
Use-cases:
|
|
1085
|
+
- Creating optional configuration interfaces where the underlying implementation still requires all options to be fully specified.
|
|
1086
|
+
- Modeling the resulting type after a deep merge with a set of defaults.
|
|
1087
|
+
|
|
1088
|
+
@example
|
|
1089
|
+
```
|
|
1090
|
+
import type {RequiredDeep} from 'type-fest';
|
|
1091
|
+
|
|
1092
|
+
type Settings = {
|
|
1093
|
+
textEditor?: {
|
|
1094
|
+
fontSize?: number;
|
|
1095
|
+
fontColor?: string;
|
|
1096
|
+
fontWeight?: number | undefined;
|
|
1097
|
+
};
|
|
1098
|
+
autocomplete?: boolean;
|
|
1099
|
+
autosave?: boolean | undefined;
|
|
1100
|
+
};
|
|
1101
|
+
|
|
1102
|
+
type RequiredSettings = RequiredDeep<Settings>;
|
|
1103
|
+
//=> {
|
|
1104
|
+
// textEditor: {
|
|
1105
|
+
// fontSize: number;
|
|
1106
|
+
// fontColor: string;
|
|
1107
|
+
// fontWeight: number | undefined;
|
|
1108
|
+
// };
|
|
1109
|
+
// autocomplete: boolean;
|
|
1110
|
+
// autosave: boolean | undefined;
|
|
1111
|
+
// }
|
|
1112
|
+
```
|
|
1113
|
+
|
|
1114
|
+
Note that types containing overloaded functions are not made deeply required due to a [TypeScript limitation](https://github.com/microsoft/TypeScript/issues/29732).
|
|
1115
|
+
|
|
1116
|
+
@category Utilities
|
|
1117
|
+
@category Object
|
|
1118
|
+
@category Array
|
|
1119
|
+
@category Set
|
|
1120
|
+
@category Map
|
|
1121
|
+
*/
|
|
940
1122
|
|
|
941
1123
|
//#endregion
|
|
942
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
1124
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/union-to-tuple.d.ts
|
|
943
1125
|
/**
|
|
944
1126
|
Returns the last element of a union type.
|
|
945
1127
|
|
|
@@ -988,76 +1170,6 @@ const petList = Object.keys(pets) as UnionToTuple<Pet>;
|
|
|
988
1170
|
*/
|
|
989
1171
|
type UnionToTuple<T, L = LastOfUnion<T>> = IsNever$1<T> extends false ? [...UnionToTuple<Exclude<T, L>>, L] : [];
|
|
990
1172
|
//#endregion
|
|
991
|
-
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/is-null.d.ts
|
|
992
|
-
/**
|
|
993
|
-
Returns a boolean for whether the given type is `null`.
|
|
994
|
-
|
|
995
|
-
@example
|
|
996
|
-
```
|
|
997
|
-
import type {IsNull} from 'type-fest';
|
|
998
|
-
|
|
999
|
-
type NonNullFallback<T, Fallback> = IsNull<T> extends true ? Fallback : T;
|
|
1000
|
-
|
|
1001
|
-
type Example1 = NonNullFallback<null, string>;
|
|
1002
|
-
//=> string
|
|
1003
|
-
|
|
1004
|
-
type Example2 = NonNullFallback<number, string>;
|
|
1005
|
-
//=? number
|
|
1006
|
-
```
|
|
1007
|
-
|
|
1008
|
-
@category Type Guard
|
|
1009
|
-
@category Utilities
|
|
1010
|
-
*/
|
|
1011
|
-
type IsNull<T> = [T] extends [null] ? true : false;
|
|
1012
|
-
//#endregion
|
|
1013
|
-
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/is-unknown.d.ts
|
|
1014
|
-
/**
|
|
1015
|
-
Returns a boolean for whether the given type is `unknown`.
|
|
1016
|
-
|
|
1017
|
-
@link https://github.com/dsherret/conditional-type-checks/pull/16
|
|
1018
|
-
|
|
1019
|
-
Useful in type utilities, such as when dealing with unknown data from API calls.
|
|
1020
|
-
|
|
1021
|
-
@example
|
|
1022
|
-
```
|
|
1023
|
-
import type {IsUnknown} from 'type-fest';
|
|
1024
|
-
|
|
1025
|
-
// https://github.com/pajecawav/tiny-global-store/blob/master/src/index.ts
|
|
1026
|
-
type Action<TState, TPayload = void> =
|
|
1027
|
-
IsUnknown<TPayload> extends true
|
|
1028
|
-
? (state: TState) => TState,
|
|
1029
|
-
: (state: TState, payload: TPayload) => TState;
|
|
1030
|
-
|
|
1031
|
-
class Store<TState> {
|
|
1032
|
-
constructor(private state: TState) {}
|
|
1033
|
-
|
|
1034
|
-
execute<TPayload = void>(action: Action<TState, TPayload>, payload?: TPayload): TState {
|
|
1035
|
-
this.state = action(this.state, payload);
|
|
1036
|
-
return this.state;
|
|
1037
|
-
}
|
|
1038
|
-
|
|
1039
|
-
// ... other methods
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
const store = new Store({value: 1});
|
|
1043
|
-
declare const someExternalData: unknown;
|
|
1044
|
-
|
|
1045
|
-
store.execute(state => ({value: state.value + 1}));
|
|
1046
|
-
//=> `TPayload` is `void`
|
|
1047
|
-
|
|
1048
|
-
store.execute((state, payload) => ({value: state.value + payload}), 5);
|
|
1049
|
-
//=> `TPayload` is `5`
|
|
1050
|
-
|
|
1051
|
-
store.execute((state, payload) => ({value: state.value + payload}), someExternalData);
|
|
1052
|
-
//=> Errors: `action` is `(state: TState) => TState`
|
|
1053
|
-
```
|
|
1054
|
-
|
|
1055
|
-
@category Utilities
|
|
1056
|
-
*/
|
|
1057
|
-
type IsUnknown<T> = (unknown extends T // `T` can be `unknown` or `any`
|
|
1058
|
-
? IsNull<T> extends false // `any` can be `null`, but `unknown` can't be
|
|
1059
|
-
? true : false : false);
|
|
1060
|
-
//#endregion
|
|
1061
1173
|
//#region src/types/core/modifiers.types.d.ts
|
|
1062
1174
|
interface RegleBehaviourOptions {
|
|
1063
1175
|
/**
|
|
@@ -1241,7 +1353,7 @@ type $InternalRegleResult = {
|
|
|
1241
1353
|
type DeepSafeFormState<TState extends Record<string, any>, TRules extends ReglePartialRuleTree<Record<string, any>, CustomRulesDeclarationTree> | RegleFormPropertyType<any, any> | undefined> = [unknown] extends [TState] ? {} : TRules extends undefined ? TState : TRules extends ReglePartialRuleTree<TState, CustomRulesDeclarationTree> ? Prettify<{ [K in keyof TState as IsPropertyOutputRequired<TState[K], TRules[K]> extends false ? K : never]?: SafeProperty<TState[K], TRules[K]> extends MaybeInput<infer M> ? MaybeOutput<M> : SafeProperty<TState[K], TRules[K]> } & { [K in keyof TState as IsPropertyOutputRequired<TState[K], TRules[K]> extends false ? never : K]-?: unknown extends SafeProperty<TState[K], TRules[K]> ? unknown : NonNullable<SafeProperty<TState[K], TRules[K]>> }> : TState;
|
|
1242
1354
|
type FieldHaveRequiredRule<TRule extends RegleFormPropertyType<any, any> | undefined = never> = TRule extends MaybeRef<RegleRuleDecl<any, any>> ? [unknown] extends UnwrapRef<TRule>['required'] ? NonNullable<UnwrapRef<TRule>['literal']> extends RegleRuleDefinition<any, any[], any, any, any, any> ? true : false : NonNullable<UnwrapRef<TRule>['required']> extends UnwrapRef<TRule>['required'] ? UnwrapRef<TRule>['required'] extends RegleRuleDefinition<any, infer Params, any, any, any, any> ? Params extends never[] ? true : false : false : false : false;
|
|
1243
1355
|
type ObjectHaveAtLeastOneRequiredField<TState extends Record<string, any>, TRule extends ReglePartialRuleTree<TState, any>> = TState extends Maybe<TState> ? { [K in keyof NonNullable<TState>]-?: IsPropertyOutputRequired<NonNullable<TState>[K], TRule[K]> }[keyof TState] extends false ? false : true : true;
|
|
1244
|
-
type ArrayHaveAtLeastOneRequiredField<TState extends Maybe<any[]>, TRule extends RegleCollectionRuleDecl<TState>> = TState extends Maybe<TState> ? FieldHaveRequiredRule<Omit<TRule, '$each'> extends MaybeRef<RegleRuleDecl> ? Omit<UnwrapRef<TRule>, '$each'> : {}> | ObjectHaveAtLeastOneRequiredField<ArrayElement
|
|
1356
|
+
type ArrayHaveAtLeastOneRequiredField<TState extends Maybe<any[]>, TRule extends RegleCollectionRuleDecl<TState>> = TState extends Maybe<TState> ? FieldHaveRequiredRule<Omit<TRule, '$each'> extends MaybeRef<RegleRuleDecl> ? Omit<UnwrapRef<TRule>, '$each'> : {}> | ObjectHaveAtLeastOneRequiredField<ArrayElement<NonNullable<TState>>, ExtractFromGetter<TRule['$each']> extends undefined ? {} : NonNullable<ExtractFromGetter<TRule['$each']>>> extends false ? false : true : true;
|
|
1245
1357
|
type SafeProperty<TState, TRule extends RegleFormPropertyType<any, any> | undefined> = unknown extends TState ? unknown : TRule extends RegleCollectionRuleDecl<any, any> ? TState extends Array<infer U extends Record<string, any>> ? DeepSafeFormState<U, ExtractFromGetter<TRule['$each']>>[] : TState : TRule extends ReglePartialRuleTree<any, any> ? ExtendOnlyRealRecord<TState> extends true ? DeepSafeFormState<NonNullable<TState> extends Record<string, any> ? JoinDiscriminatedUnions<NonNullable<TState>> : {}, TRule> : TRule extends MaybeRef<RegleRuleDecl<any, any>> ? FieldHaveRequiredRule<UnwrapRef<TRule>> extends true ? TState : MaybeOutput<TState> : TState : TState;
|
|
1246
1358
|
type IsPropertyOutputRequired<TState, TRule extends RegleFormPropertyType<any, any> | undefined> = [unknown] extends [TState] ? unknown : NonNullable<TState> extends Array<any> ? TRule extends RegleCollectionRuleDecl<any, any> ? ArrayHaveAtLeastOneRequiredField<NonNullable<TState>, TRule> extends false ? false : true : false : TRule extends ReglePartialRuleTree<any, any> ? ExtendOnlyRealRecord<TState> extends true ? ObjectHaveAtLeastOneRequiredField<NonNullable<TState> extends Record<string, any> ? NonNullable<TState> : {}, TRule> extends false ? false : true : TRule extends MaybeRef<RegleRuleDecl<any, any>> ? FieldHaveRequiredRule<UnwrapRef<TRule>> extends false ? false : true : false : false;
|
|
1247
1359
|
type SafeFieldProperty<TState, TRule extends RegleFormPropertyType<any, any> | undefined = never> = FieldHaveRequiredRule<TRule> extends true ? NonNullable<TState> : MaybeOutput<TState>;
|
|
@@ -1251,30 +1363,16 @@ type SafeFieldProperty<TState, TRule extends RegleFormPropertyType<any, any> | u
|
|
|
1251
1363
|
* Negates a boolean type.
|
|
1252
1364
|
*/
|
|
1253
1365
|
type Not<T extends boolean> = T extends true ? false : true;
|
|
1254
|
-
/**
|
|
1255
|
-
* Returns `true` if at least one of the types in the
|
|
1256
|
-
* {@linkcode Types} array is `true`, otherwise returns `false`.
|
|
1257
|
-
*/
|
|
1258
|
-
|
|
1259
1366
|
/**
|
|
1260
1367
|
* Checks if the given type is `never`.
|
|
1261
1368
|
*/
|
|
1262
1369
|
type IsNever$2<T> = [T] extends [never] ? true : false;
|
|
1263
|
-
/**
|
|
1264
|
-
* Checks if the given type is `any`.
|
|
1265
|
-
*/
|
|
1266
|
-
|
|
1267
1370
|
/**
|
|
1268
1371
|
* Checks if one type extends another. Note: this is not quite the same as `Left extends Right` because:
|
|
1269
1372
|
* 1. If either type is `never`, the result is `true` iff the other type is also `never`.
|
|
1270
1373
|
* 2. Types are wrapped in a 1-tuple so that union types are not distributed - instead we consider `string | number` to _not_ extend `number`. If we used `Left extends Right` directly you would get `Extends<string | number, number>` => `false | true` => `boolean`.
|
|
1271
1374
|
*/
|
|
1272
1375
|
type Extends<Left, Right> = IsNever$2<Left> extends true ? IsNever$2<Right> : [Left] extends [Right] ? true : false;
|
|
1273
|
-
/**
|
|
1274
|
-
* Checks if the {@linkcode Left} type extends the {@linkcode Right} type,
|
|
1275
|
-
* excluding `any` or `never`.
|
|
1276
|
-
*/
|
|
1277
|
-
|
|
1278
1376
|
/**
|
|
1279
1377
|
* Convert a union to an intersection.
|
|
1280
1378
|
* `A | B | C` -\> `A & B & C`
|
|
@@ -1297,24 +1395,13 @@ type TuplifyUnion<Union, LastElement = LastOf<Union>> = IsNever$2<Union> extends
|
|
|
1297
1395
|
*/
|
|
1298
1396
|
type UnionToTuple$1<Union> = TuplifyUnion<Union>;
|
|
1299
1397
|
type IsUnion<T> = Not<Extends<UnionToTuple$1<T>['length'], 1>>;
|
|
1300
|
-
/**
|
|
1301
|
-
* A recursive version of `Pick` that selects properties from the left type that are present in the right type.
|
|
1302
|
-
* The "leaf" types from `Left` are used - only the keys of `Right` are considered.
|
|
1303
|
-
*
|
|
1304
|
-
* @example
|
|
1305
|
-
* ```ts
|
|
1306
|
-
* const user = {email: 'a@b.com', name: 'John Doe', address: {street: '123 2nd St', city: 'New York', zip: '10001', state: 'NY', country: 'USA'}}
|
|
1307
|
-
*
|
|
1308
|
-
* type Result = DeepPickMatchingProps<typeof user, {name: unknown; address: {city: unknown}}> // {name: string, address: {city: string}}
|
|
1309
|
-
* ```
|
|
1310
|
-
*/
|
|
1311
1398
|
//#endregion
|
|
1312
1399
|
//#region src/types/core/variants.types.d.ts
|
|
1313
1400
|
|
|
1314
1401
|
type MaybeVariantStatus<TState extends Record<string, any> | undefined = Record<string, any>, TRules extends ReglePartialRuleTree<NonNullable<TState>> = Record<string, any>, TShortcuts extends RegleShortcutDefinition = {}> = IsUnion<NonNullable<TState>> extends true ? Omit<RegleStatus<TState, TRules, TShortcuts>, '$fields' | keyof RegleStatus<TState, TRules, TShortcuts>['$fields']> & {
|
|
1315
1402
|
$fields: ProcessChildrenFields<TState, TRules, TShortcuts>[keyof ProcessChildrenFields<TState, TRules, TShortcuts>];
|
|
1316
1403
|
} & (HasNamedKeys<TState> extends true ? ProcessChildrenFields<TState, TRules, TShortcuts>[keyof ProcessChildrenFields<TState, TRules, TShortcuts>] : {}) : RegleStatus<TState, TRules, TShortcuts>;
|
|
1317
|
-
type ProcessChildrenFields<TState extends Record<string, any> | undefined, TRules extends ReglePartialRuleTree<NonNullable<TState>>, TShortcuts extends RegleShortcutDefinition = {}> = { [TIndex in keyof TupleToPlainObj<UnionToTuple<TState>>]: TIndex extends `${infer TIndexInt extends number}` ? { [TKey in keyof UnionToTuple<TState>[TIndexInt] as IsEmptyObject
|
|
1404
|
+
type ProcessChildrenFields<TState extends Record<string, any> | undefined, TRules extends ReglePartialRuleTree<NonNullable<TState>>, TShortcuts extends RegleShortcutDefinition = {}> = { [TIndex in keyof TupleToPlainObj<UnionToTuple<TState>>]: TIndex extends `${infer TIndexInt extends number}` ? { [TKey in keyof UnionToTuple<TState>[TIndexInt] as IsEmptyObject<FindCorrespondingVariant<UnionToTuple<TState>[TIndexInt] extends Record<string, any> ? UnionToTuple<TState>[TIndexInt] : never, UnionToTuple<TRules>> extends [infer U] ? TKey extends keyof U ? U[TKey] : EmptyObject$1 : EmptyObject$1> extends true ? TKey extends keyof TState ? TState[TKey] extends NonNullable<TState[TKey]> ? TKey : never : never : TKey]-?: InferRegleStatusType<FindCorrespondingVariant<UnionToTuple<TState>[TIndexInt] extends Record<string, any> ? UnionToTuple<TState>[TIndexInt] : never, UnionToTuple<TRules>> extends [infer U] ? TKey extends keyof U ? U[TKey] : EmptyObject$1 : EmptyObject$1, NonNullable<UnionToTuple<TState>[TIndexInt]>, TKey, TShortcuts> } & { [TKey in keyof UnionToTuple<TState>[TIndexInt] as IsEmptyObject<FindCorrespondingVariant<UnionToTuple<TState>[TIndexInt] extends Record<string, any> ? UnionToTuple<TState>[TIndexInt] : never, UnionToTuple<TRules>> extends [infer U] ? TKey extends keyof U ? U[TKey] : EmptyObject$1 : EmptyObject$1> extends true ? TKey extends keyof TState ? TState[TKey] extends NonNullable<TState[TKey]> ? never : TKey : TKey : never]?: InferRegleStatusType<FindCorrespondingVariant<UnionToTuple<TState>[TIndexInt] extends Record<string, any> ? UnionToTuple<TState>[TIndexInt] : never, UnionToTuple<TRules>> extends [infer U] ? TKey extends keyof U ? U[TKey] : EmptyObject$1 : EmptyObject$1, NonNullable<UnionToTuple<TState>[TIndexInt]>, TKey, TShortcuts> } : {} };
|
|
1318
1405
|
type FindCorrespondingVariant<TState extends Record<string, any>, TRules extends any[]> = TRules extends [infer F, ...infer R] ? F extends ReglePartialRuleTree<TState> ? [F] : FindCorrespondingVariant<TState, R> : [];
|
|
1319
1406
|
//#endregion
|
|
1320
1407
|
//#region src/core/useRegle/useRegle.d.ts
|
|
@@ -1439,7 +1526,7 @@ type IsLiteral<T> = string extends T ? false : true;
|
|
|
1439
1526
|
/**
|
|
1440
1527
|
* Returned typed of rules created with `createRule`
|
|
1441
1528
|
* */
|
|
1442
|
-
interface RegleRuleDefinition<TValue extends unknown = unknown, TParams extends any[] = [], TAsync extends boolean = boolean, TMetaData extends RegleRuleMetadataDefinition = RegleRuleMetadataDefinition,
|
|
1529
|
+
interface RegleRuleDefinition<TValue extends unknown = unknown, TParams extends any[] = [], TAsync extends boolean = boolean, TMetaData extends RegleRuleMetadataDefinition = RegleRuleMetadataDefinition, _TInput = unknown, TFilteredValue extends any = (TValue extends Date & File & infer M ? M : TValue)> extends RegleInternalRuleDefs<TFilteredValue, TParams, TAsync, TMetaData> {
|
|
1443
1530
|
validator: RegleRuleDefinitionProcessor<TFilteredValue, TParams, TAsync extends false ? TMetaData : Promise<TMetaData>>;
|
|
1444
1531
|
message: (metadata: PossibleRegleRuleMetadataConsumer<TFilteredValue>) => string | string[];
|
|
1445
1532
|
active: (metadata: PossibleRegleRuleMetadataConsumer<TFilteredValue>) => boolean;
|
|
@@ -1448,10 +1535,6 @@ interface RegleRuleDefinition<TValue extends unknown = unknown, TParams extends
|
|
|
1448
1535
|
_value?: IsLiteral<TValue> extends true ? TValue : any;
|
|
1449
1536
|
exec: (value: Maybe<TFilteredValue>) => TAsync extends false ? TMetaData : Promise<TMetaData>;
|
|
1450
1537
|
}
|
|
1451
|
-
/**
|
|
1452
|
-
* @internal
|
|
1453
|
-
* */
|
|
1454
|
-
|
|
1455
1538
|
/**
|
|
1456
1539
|
* Rules with params created with `createRules` are callable while being customizable
|
|
1457
1540
|
*/
|
|
@@ -1491,10 +1574,6 @@ type PossibleRegleRuleMetadataConsumer<TValue> = {
|
|
|
1491
1574
|
} & DefaultMetadataProperties & {
|
|
1492
1575
|
$params?: [...any[]];
|
|
1493
1576
|
};
|
|
1494
|
-
/**
|
|
1495
|
-
* @internal
|
|
1496
|
-
*/
|
|
1497
|
-
|
|
1498
1577
|
/**
|
|
1499
1578
|
* Generic types for a created RegleRule
|
|
1500
1579
|
*/
|
|
@@ -1512,9 +1591,9 @@ type RegleRuleRawInput<TValue extends any = any, TParams extends [...any[]] = [.
|
|
|
1512
1591
|
|
|
1513
1592
|
type RegleRuleDefinitionProcessor<TValue extends any = any, TParams extends any[] = [], TReturn = any> = (value: Maybe<TValue>, ...params: TParams) => TReturn;
|
|
1514
1593
|
type RegleCollectionRuleDefinition<TValue = any[], TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = (RegleRuleDecl<NonNullable<TValue>, TCustomRules, CollectionRegleBehaviourOptions> & {
|
|
1515
|
-
$each: MaybeGetter<RegleFormPropertyType<ArrayElement
|
|
1594
|
+
$each: MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue>>, TCustomRules>, ArrayElement<TValue>>;
|
|
1516
1595
|
}) | ({
|
|
1517
|
-
$each: MaybeGetter<RegleFormPropertyType<ArrayElement
|
|
1596
|
+
$each: MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue>>, TCustomRules>, ArrayElement<TValue>>;
|
|
1518
1597
|
} & CollectionRegleBehaviourOptions);
|
|
1519
1598
|
//#endregion
|
|
1520
1599
|
//#region src/types/rules/rule.init.types.d.ts
|
|
@@ -1536,11 +1615,6 @@ interface RegleRuleCore<TValue extends any, TParams extends any[] = [], TAsync e
|
|
|
1536
1615
|
type?: string;
|
|
1537
1616
|
async?: boolean;
|
|
1538
1617
|
}
|
|
1539
|
-
/**
|
|
1540
|
-
* @internal
|
|
1541
|
-
* createRule arguments options
|
|
1542
|
-
*/
|
|
1543
|
-
|
|
1544
1618
|
//#endregion
|
|
1545
1619
|
//#region src/core/defaultValidators.d.ts
|
|
1546
1620
|
interface CommonComparisonOptions {
|
|
@@ -1657,7 +1731,7 @@ type RegleCollectionRuleDecl<TValue = any[], TCustomRules extends Partial<AllRul
|
|
|
1657
1731
|
$each?: RegleCollectionEachRules<TValue, TCustomRules>;
|
|
1658
1732
|
} & CollectionRegleBehaviourOptions);
|
|
1659
1733
|
/** @public */
|
|
1660
|
-
type RegleCollectionEachRules<TValue = any[], TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = MaybeGetter<RegleFormPropertyType<ArrayElement
|
|
1734
|
+
type RegleCollectionEachRules<TValue = any[], TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue>>, TCustomRules>, ArrayElement<TValue>, RegleCollectionRuleDeclKeyProperty>;
|
|
1661
1735
|
/**
|
|
1662
1736
|
* @internal
|
|
1663
1737
|
* @reference {@link RegleCollectionRuleDecl}
|
|
@@ -1667,10 +1741,6 @@ type RegleCollectionEachRules<TValue = any[], TCustomRules extends Partial<AllRu
|
|
|
1667
1741
|
* @public
|
|
1668
1742
|
*/
|
|
1669
1743
|
type InlineRuleDeclaration<TValue extends any = any, TParams extends any[] = any[], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition> = boolean> = (value: Maybe<TValue>, ...args: UnwrapRegleUniversalParams<TParams>) => TReturn;
|
|
1670
|
-
/**
|
|
1671
|
-
* @internal
|
|
1672
|
-
*/
|
|
1673
|
-
|
|
1674
1744
|
/**
|
|
1675
1745
|
* @public
|
|
1676
1746
|
* Regroup inline and registered rules
|
|
@@ -1687,7 +1757,7 @@ type RegleRoot<TState extends Record<string, unknown> = {}, TRules extends Regle
|
|
|
1687
1757
|
*/
|
|
1688
1758
|
$groups: { readonly [TKey in keyof TValidationGroups]: RegleValidationGroupOutput };
|
|
1689
1759
|
});
|
|
1690
|
-
type ProcessNestedFields$1<TState extends Record<string, any> | undefined, TRules extends ReglePartialRuleTree<NonNullable<TState>>, TShortcuts extends RegleShortcutDefinition = {}, TIsFields extends boolean = false> = Or<HasNamedKeys<TState>, TIsFields> extends true ? { readonly [TKey in keyof TState as TRules[TKey] extends NonNullable<TRules[TKey]> ? NonNullable<TRules[TKey]> extends MaybeRef<RegleRuleDecl> ? IsEmptyObject
|
|
1760
|
+
type ProcessNestedFields$1<TState extends Record<string, any> | undefined, TRules extends ReglePartialRuleTree<NonNullable<TState>>, TShortcuts extends RegleShortcutDefinition = {}, TIsFields extends boolean = false> = Or<HasNamedKeys<TState>, TIsFields> extends true ? { readonly [TKey in keyof TState as TRules[TKey] extends NonNullable<TRules[TKey]> ? NonNullable<TRules[TKey]> extends MaybeRef<RegleRuleDecl> ? IsEmptyObject<TRules[TKey]> extends true ? TKey : never : never : TKey]: IsUnion<NonNullable<TRules[TKey]>> extends true ? ExtendOnlyRealRecord<TState[TKey]> extends true ? MaybeVariantStatus<NonNullable<TState>[TKey], NonNullable<TRules[TKey]>, TShortcuts> : InferRegleStatusType<NonNullable<TRules[TKey]>, NonNullable<TState>, TKey, TShortcuts> : InferRegleStatusType<NonNullable<TRules[TKey]>, NonNullable<TState>, TKey, TShortcuts> } & { readonly [TKey in keyof TState as TRules[TKey] extends NonNullable<TRules[TKey]> ? NonNullable<TRules[TKey]> extends MaybeRef<RegleRuleDecl> ? IsEmptyObject<TRules[TKey]> extends true ? never : TKey : TKey : never]-?: IsUnion<NonNullable<TRules[TKey]>> extends true ? ExtendOnlyRealRecord<TState[TKey]> extends true ? MaybeVariantStatus<NonNullable<TState>[TKey], NonNullable<TRules[TKey]>, TShortcuts> : InferRegleStatusType<NonNullable<TRules[TKey]>, NonNullable<TState>, TKey, TShortcuts> : InferRegleStatusType<NonNullable<TRules[TKey]>, NonNullable<TState>, TKey, TShortcuts> } : {};
|
|
1691
1761
|
/**
|
|
1692
1762
|
* @public
|
|
1693
1763
|
*/
|
|
@@ -1731,7 +1801,7 @@ type RegleFieldIssue<TRules extends RegleFormPropertyType<any, Partial<AllRulesD
|
|
|
1731
1801
|
readonly $property: string;
|
|
1732
1802
|
readonly $type?: string;
|
|
1733
1803
|
readonly $message: string;
|
|
1734
|
-
} & (IsEmptyObject
|
|
1804
|
+
} & (IsEmptyObject<TRules> extends true ? {
|
|
1735
1805
|
readonly $rule: string;
|
|
1736
1806
|
} : { [K in keyof ComputeFieldRules<any, TRules>]: ComputeFieldRules<any, TRules>[K] extends {
|
|
1737
1807
|
$metadata: infer TMetadata;
|
|
@@ -1744,7 +1814,7 @@ type RegleFieldIssue<TRules extends RegleFormPropertyType<any, Partial<AllRulesD
|
|
|
1744
1814
|
} : {
|
|
1745
1815
|
readonly $rule: string;
|
|
1746
1816
|
} }[keyof ComputeFieldRules<any, TRules>]);
|
|
1747
|
-
type ComputeFieldRules<TState extends any, TRules extends RegleFormPropertyType<any, Partial<AllRulesDeclarations>>> = IsEmptyObject
|
|
1817
|
+
type ComputeFieldRules<TState extends any, TRules extends RegleFormPropertyType<any, Partial<AllRulesDeclarations>>> = IsEmptyObject<TRules> extends true ? {
|
|
1748
1818
|
readonly [x: string]: RegleRuleStatus<TState, any[], any>;
|
|
1749
1819
|
} : { readonly [TRuleKey in keyof Omit<TRules, '$each' | keyof FieldRegleBehaviourOptions>]: RegleRuleStatus<TState, TRules[TRuleKey] extends RegleRuleDefinition<any, infer TParams, any> ? TParams : [], TRules[TRuleKey] extends RegleRuleDefinition<any, any, any, infer TMetadata> ? TMetadata : TRules[TRuleKey] extends InlineRuleDeclaration<any, any[], infer TMetadata> ? TMetadata extends Promise<infer P> ? P : TMetadata : boolean> };
|
|
1750
1820
|
/**
|
|
@@ -1915,7 +1985,7 @@ interface $InternalRegleRuleStatus {
|
|
|
1915
1985
|
/**
|
|
1916
1986
|
* @public
|
|
1917
1987
|
*/
|
|
1918
|
-
type RegleCollectionStatus<TState extends any[] = any[], TRules extends ReglePartialRuleTree<ArrayElement
|
|
1988
|
+
type RegleCollectionStatus<TState extends any[] = any[], TRules extends ReglePartialRuleTree<ArrayElement<TState>> = Record<string, any>, TFieldRule extends RegleCollectionRuleDecl<any, any> = never, TShortcuts extends RegleShortcutDefinition = {}> = Omit<RegleCommonStatus<TState>, '$value'> & {
|
|
1919
1989
|
/** A reference to the original validated model. It can be used to bind your form with v-model.*/
|
|
1920
1990
|
$value: MaybeOutput<TState>;
|
|
1921
1991
|
/** $value variant that will not "touch" the field and update the value silently, running only the rules, so you can easily swap values without impacting user interaction. */
|
|
@@ -2053,12 +2123,14 @@ type CreateScopedUseRegleOptions<TCustomRegle extends useRegleFn<any, any>, TAsR
|
|
|
2053
2123
|
*/
|
|
2054
2124
|
customStore?: Ref<ScopedInstancesRecordLike>;
|
|
2055
2125
|
/**
|
|
2056
|
-
*
|
|
2126
|
+
* Collect instances in a Record instead of an array
|
|
2127
|
+
*
|
|
2128
|
+
* ⚠️ Each nested `useScopedRegle` must provide a parameter `scopeKey` to be collected.
|
|
2057
2129
|
*/
|
|
2058
2130
|
asRecord?: TAsRecord;
|
|
2059
2131
|
};
|
|
2060
2132
|
//#endregion
|
|
2061
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
2133
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/primitive.d.ts
|
|
2062
2134
|
/**
|
|
2063
2135
|
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
2064
2136
|
|
|
@@ -2066,26 +2138,7 @@ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/
|
|
|
2066
2138
|
*/
|
|
2067
2139
|
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
2068
2140
|
//#endregion
|
|
2069
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
2070
|
-
declare global {
|
|
2071
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
2072
|
-
interface SymbolConstructor {
|
|
2073
|
-
readonly observable: symbol;
|
|
2074
|
-
}
|
|
2075
|
-
}
|
|
2076
|
-
|
|
2077
|
-
/**
|
|
2078
|
-
@remarks
|
|
2079
|
-
The TC39 observable proposal defines a `closed` property, but some implementations (such as xstream) do not as of 10/08/2021.
|
|
2080
|
-
As well, some guidance on making an `Observable` to not include `closed` property.
|
|
2081
|
-
@see https://github.com/tc39/proposal-observable/blob/master/src/Observable.js#L129-L130
|
|
2082
|
-
@see https://github.com/staltz/xstream/blob/6c22580c1d84d69773ee4b0905df44ad464955b3/src/index.ts#L79-L85
|
|
2083
|
-
@see https://github.com/benlesh/symbol-observable#making-an-object-observable
|
|
2084
|
-
|
|
2085
|
-
@category Observable
|
|
2086
|
-
*/
|
|
2087
|
-
//#endregion
|
|
2088
|
-
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/empty-object.d.ts
|
|
2141
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/empty-object.d.ts
|
|
2089
2142
|
declare const emptyObjectSymbol: unique symbol;
|
|
2090
2143
|
|
|
2091
2144
|
/**
|
|
@@ -2117,24 +2170,82 @@ Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<n
|
|
|
2117
2170
|
type EmptyObject = {
|
|
2118
2171
|
[emptyObjectSymbol]?: never;
|
|
2119
2172
|
};
|
|
2173
|
+
//#endregion
|
|
2174
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/is-any.d.ts
|
|
2175
|
+
/**
|
|
2176
|
+
Returns a boolean for whether the given type is `any`.
|
|
2177
|
+
|
|
2178
|
+
@link https://stackoverflow.com/a/49928360/1490091
|
|
2179
|
+
|
|
2180
|
+
Useful in type utilities, such as disallowing `any`s to be passed to a function.
|
|
2181
|
+
|
|
2182
|
+
@example
|
|
2183
|
+
```
|
|
2184
|
+
import type {IsAny} from 'type-fest';
|
|
2185
|
+
|
|
2186
|
+
const typedObject = {a: 1, b: 2} as const;
|
|
2187
|
+
const anyObject: any = {a: 1, b: 2};
|
|
2120
2188
|
|
|
2189
|
+
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(obj: O, key: K) {
|
|
2190
|
+
return obj[key];
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
const typedA = get(typedObject, 'a');
|
|
2194
|
+
//=> 1
|
|
2195
|
+
|
|
2196
|
+
const anyA = get(anyObject, 'a');
|
|
2197
|
+
//=> any
|
|
2198
|
+
```
|
|
2199
|
+
|
|
2200
|
+
@category Type Guard
|
|
2201
|
+
@category Utilities
|
|
2202
|
+
*/
|
|
2203
|
+
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
2204
|
+
//#endregion
|
|
2205
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
2121
2206
|
/**
|
|
2122
|
-
Returns a
|
|
2207
|
+
Returns a boolean for whether the given key is an optional key of type.
|
|
2208
|
+
|
|
2209
|
+
This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
|
|
2123
2210
|
|
|
2124
2211
|
@example
|
|
2125
2212
|
```
|
|
2126
|
-
import type {
|
|
2213
|
+
import type {IsOptionalKeyOf} from 'type-fest';
|
|
2127
2214
|
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2215
|
+
interface User {
|
|
2216
|
+
name: string;
|
|
2217
|
+
surname: string;
|
|
2218
|
+
|
|
2219
|
+
luckyNumber?: number;
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
interface Admin {
|
|
2223
|
+
name: string;
|
|
2224
|
+
surname?: string;
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
|
|
2228
|
+
//=> true
|
|
2229
|
+
|
|
2230
|
+
type T2 = IsOptionalKeyOf<User, 'name'>;
|
|
2231
|
+
//=> false
|
|
2232
|
+
|
|
2233
|
+
type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
|
|
2234
|
+
//=> boolean
|
|
2235
|
+
|
|
2236
|
+
type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
|
|
2237
|
+
//=> false
|
|
2238
|
+
|
|
2239
|
+
type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
2240
|
+
//=> boolean
|
|
2131
2241
|
```
|
|
2132
2242
|
|
|
2133
|
-
@
|
|
2134
|
-
@category
|
|
2243
|
+
@category Type Guard
|
|
2244
|
+
@category Utilities
|
|
2135
2245
|
*/
|
|
2246
|
+
type IsOptionalKeyOf<Type extends object, Key extends keyof Type> = IsAny<Type | Key> extends true ? never : Key extends keyof Type ? Type extends Record<Key, Type[Key]> ? false : true : false;
|
|
2136
2247
|
//#endregion
|
|
2137
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
2248
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/optional-keys-of.d.ts
|
|
2138
2249
|
/**
|
|
2139
2250
|
Extract all optional keys from the given type.
|
|
2140
2251
|
|
|
@@ -2168,11 +2279,11 @@ const update2: UpdateOperation<User> = {
|
|
|
2168
2279
|
|
|
2169
2280
|
@category Utilities
|
|
2170
2281
|
*/
|
|
2171
|
-
type OptionalKeysOf<
|
|
2172
|
-
? (keyof { [Key in keyof
|
|
2173
|
-
: never;
|
|
2282
|
+
type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
2283
|
+
? (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`
|
|
2284
|
+
: never;
|
|
2174
2285
|
//#endregion
|
|
2175
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
2286
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/required-keys-of.d.ts
|
|
2176
2287
|
/**
|
|
2177
2288
|
Extract all required keys from the given type.
|
|
2178
2289
|
|
|
@@ -2197,11 +2308,10 @@ const validator2 = createValidation<User>('surname', value => value.length < 25)
|
|
|
2197
2308
|
|
|
2198
2309
|
@category Utilities
|
|
2199
2310
|
*/
|
|
2200
|
-
type RequiredKeysOf<
|
|
2201
|
-
? Exclude<keyof
|
|
2202
|
-
|
|
2311
|
+
type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
2312
|
+
? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
|
|
2203
2313
|
//#endregion
|
|
2204
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
2314
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/is-never.d.ts
|
|
2205
2315
|
/**
|
|
2206
2316
|
Returns a boolean for whether the given type is `never`.
|
|
2207
2317
|
|
|
@@ -2245,85 +2355,73 @@ endIfEqual('abc', '123');
|
|
|
2245
2355
|
*/
|
|
2246
2356
|
type IsNever<T> = [T] extends [never] ? true : false;
|
|
2247
2357
|
//#endregion
|
|
2248
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
2358
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/if.d.ts
|
|
2249
2359
|
/**
|
|
2250
|
-
An if-else-like type that resolves depending on whether the given type is `
|
|
2360
|
+
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
2251
2361
|
|
|
2252
|
-
|
|
2362
|
+
Use-cases:
|
|
2363
|
+
- You can use this in combination with `Is*` types to create an if-else-like experience. For example, `If<IsAny<any>, 'is any', 'not any'>`.
|
|
2364
|
+
|
|
2365
|
+
Note:
|
|
2366
|
+
- Returns a union of if branch and else branch if the given type is `boolean` or `any`. For example, `If<boolean, 'Y', 'N'>` will return `'Y' | 'N'`.
|
|
2367
|
+
- Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
|
|
2253
2368
|
|
|
2254
2369
|
@example
|
|
2255
2370
|
```
|
|
2256
|
-
import
|
|
2257
|
-
|
|
2258
|
-
type ShouldBeTrue = IfNever<never>;
|
|
2259
|
-
//=> true
|
|
2371
|
+
import {If} from 'type-fest';
|
|
2260
2372
|
|
|
2261
|
-
type
|
|
2262
|
-
//=> '
|
|
2263
|
-
```
|
|
2373
|
+
type A = If<true, 'yes', 'no'>;
|
|
2374
|
+
//=> 'yes'
|
|
2264
2375
|
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
*/
|
|
2268
|
-
type IfNever$1<T, TypeIfNever = true, TypeIfNotNever = false> = (IsNever<T> extends true ? TypeIfNever : TypeIfNotNever);
|
|
2269
|
-
//#endregion
|
|
2270
|
-
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/internal/array.d.ts
|
|
2271
|
-
/**
|
|
2272
|
-
Extract the element of an array that also works for array union.
|
|
2376
|
+
type B = If<false, 'yes', 'no'>;
|
|
2377
|
+
//=> 'no'
|
|
2273
2378
|
|
|
2274
|
-
|
|
2379
|
+
type C = If<boolean, 'yes', 'no'>;
|
|
2380
|
+
//=> 'yes' | 'no'
|
|
2275
2381
|
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
type ArrayElement<T> = T extends readonly unknown[] ? T[0] : never;
|
|
2382
|
+
type D = If<any, 'yes', 'no'>;
|
|
2383
|
+
//=> 'yes' | 'no'
|
|
2279
2384
|
|
|
2280
|
-
|
|
2281
|
-
|
|
2385
|
+
type E = If<never, 'yes', 'no'>;
|
|
2386
|
+
//=> 'no'
|
|
2387
|
+
```
|
|
2282
2388
|
|
|
2283
2389
|
@example
|
|
2284
2390
|
```
|
|
2285
|
-
|
|
2286
|
-
type B = StaticPartOfArray<A>;
|
|
2287
|
-
//=> [string, number, boolean]
|
|
2288
|
-
```
|
|
2289
|
-
*/
|
|
2290
|
-
//#endregion
|
|
2291
|
-
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/is-any.d.ts
|
|
2292
|
-
// Can eventually be replaced with the built-in once this library supports
|
|
2293
|
-
// TS5.4+ only. Tracked in https://github.com/sindresorhus/type-fest/issues/848
|
|
2294
|
-
type NoInfer<T> = T extends infer U ? U : never;
|
|
2391
|
+
import {If, IsAny, IsNever} from 'type-fest';
|
|
2295
2392
|
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
@link https://stackoverflow.com/a/49928360/1490091
|
|
2393
|
+
type A = If<IsAny<unknown>, 'is any', 'not any'>;
|
|
2394
|
+
//=> 'not any'
|
|
2300
2395
|
|
|
2301
|
-
|
|
2396
|
+
type B = If<IsNever<never>, 'is never', 'not never'>;
|
|
2397
|
+
//=> 'is never'
|
|
2398
|
+
```
|
|
2302
2399
|
|
|
2303
2400
|
@example
|
|
2304
2401
|
```
|
|
2305
|
-
import
|
|
2306
|
-
|
|
2307
|
-
const typedObject = {a: 1, b: 2} as const;
|
|
2308
|
-
const anyObject: any = {a: 1, b: 2};
|
|
2402
|
+
import {If, IsEqual} from 'type-fest';
|
|
2309
2403
|
|
|
2310
|
-
|
|
2311
|
-
return obj[key];
|
|
2312
|
-
}
|
|
2404
|
+
type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
|
|
2313
2405
|
|
|
2314
|
-
|
|
2315
|
-
//=>
|
|
2406
|
+
type A = IfEqual<string, string, 'equal', 'not equal'>;
|
|
2407
|
+
//=> 'equal'
|
|
2316
2408
|
|
|
2317
|
-
|
|
2318
|
-
//=>
|
|
2409
|
+
type B = IfEqual<string, number, 'equal', 'not equal'>;
|
|
2410
|
+
//=> 'not equal'
|
|
2319
2411
|
```
|
|
2320
2412
|
|
|
2321
2413
|
@category Type Guard
|
|
2322
2414
|
@category Utilities
|
|
2323
2415
|
*/
|
|
2324
|
-
type
|
|
2416
|
+
type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
|
|
2417
|
+
//#endregion
|
|
2418
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/internal/type.d.ts
|
|
2419
|
+
/**
|
|
2420
|
+
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
2421
|
+
*/
|
|
2422
|
+
type BuiltIns = Primitive | void | Date | RegExp;
|
|
2325
2423
|
//#endregion
|
|
2326
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
2424
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/simplify.d.ts
|
|
2327
2425
|
/**
|
|
2328
2426
|
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.
|
|
2329
2427
|
|
|
@@ -2383,7 +2481,7 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
|
|
|
2383
2481
|
*/
|
|
2384
2482
|
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
2385
2483
|
//#endregion
|
|
2386
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
2484
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
2387
2485
|
/**
|
|
2388
2486
|
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
2389
2487
|
|
|
@@ -2476,7 +2574,7 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
|
2476
2574
|
*/
|
|
2477
2575
|
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
2478
2576
|
//#endregion
|
|
2479
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
2577
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/pick-index-signature.d.ts
|
|
2480
2578
|
/**
|
|
2481
2579
|
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
2482
2580
|
|
|
@@ -2524,7 +2622,7 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
2524
2622
|
*/
|
|
2525
2623
|
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
2526
2624
|
//#endregion
|
|
2527
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
2625
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/merge.d.ts
|
|
2528
2626
|
// Merges two objects without worrying about index signatures.
|
|
2529
2627
|
type SimpleMerge<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source;
|
|
2530
2628
|
|
|
@@ -2564,40 +2662,7 @@ export type FooBar = Merge<Foo, Bar>;
|
|
|
2564
2662
|
*/
|
|
2565
2663
|
type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
2566
2664
|
//#endregion
|
|
2567
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
2568
|
-
/**
|
|
2569
|
-
An if-else-like type that resolves depending on whether the given type is `any`.
|
|
2570
|
-
|
|
2571
|
-
@see {@link IsAny}
|
|
2572
|
-
|
|
2573
|
-
@example
|
|
2574
|
-
```
|
|
2575
|
-
import type {IfAny} from 'type-fest';
|
|
2576
|
-
|
|
2577
|
-
type ShouldBeTrue = IfAny<any>;
|
|
2578
|
-
//=> true
|
|
2579
|
-
|
|
2580
|
-
type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
|
|
2581
|
-
//=> 'bar'
|
|
2582
|
-
```
|
|
2583
|
-
|
|
2584
|
-
@category Type Guard
|
|
2585
|
-
@category Utilities
|
|
2586
|
-
*/
|
|
2587
|
-
type IfAny$1<T, TypeIfAny = true, TypeIfNotAny = false> = (IsAny<T> extends true ? TypeIfAny : TypeIfNotAny);
|
|
2588
|
-
//#endregion
|
|
2589
|
-
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/internal/type.d.ts
|
|
2590
|
-
/**
|
|
2591
|
-
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
2592
|
-
*/
|
|
2593
|
-
type BuiltIns = Primitive | void | Date | RegExp;
|
|
2594
|
-
|
|
2595
|
-
/**
|
|
2596
|
-
Matches non-recursive types.
|
|
2597
|
-
*/
|
|
2598
|
-
|
|
2599
|
-
//#endregion
|
|
2600
|
-
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/internal/object.d.ts
|
|
2665
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/internal/object.d.ts
|
|
2601
2666
|
/**
|
|
2602
2667
|
Merges user specified options with default options.
|
|
2603
2668
|
|
|
@@ -2650,10 +2715,9 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
|
|
|
2650
2715
|
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
2651
2716
|
```
|
|
2652
2717
|
*/
|
|
2653
|
-
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> =
|
|
2654
|
-
>>;
|
|
2718
|
+
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
|
|
2655
2719
|
//#endregion
|
|
2656
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
2720
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/partial-deep.d.ts
|
|
2657
2721
|
/**
|
|
2658
2722
|
@see {@link PartialDeep}
|
|
2659
2723
|
*/
|
|
@@ -2668,24 +2732,23 @@ type PartialDeepOptions = {
|
|
|
2668
2732
|
Allows `undefined` values in non-tuple arrays.
|
|
2669
2733
|
- When set to `true`, elements of non-tuple arrays can be `undefined`.
|
|
2670
2734
|
- When set to `false`, only explicitly defined elements are allowed in non-tuple arrays, ensuring stricter type checking.
|
|
2671
|
-
@default
|
|
2735
|
+
@default false
|
|
2672
2736
|
@example
|
|
2673
|
-
You can
|
|
2737
|
+
You can allow `undefined` values in non-tuple arrays by passing `{recurseIntoArrays: true; allowUndefinedInNonTupleArrays: true}` as the second type argument:
|
|
2674
2738
|
```
|
|
2675
2739
|
import type {PartialDeep} from 'type-fest';
|
|
2676
2740
|
type Settings = {
|
|
2677
2741
|
languages: string[];
|
|
2678
2742
|
};
|
|
2679
|
-
declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays:
|
|
2680
|
-
partialSettings.languages = [undefined]; //
|
|
2681
|
-
partialSettings.languages = []; // Ok
|
|
2743
|
+
declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays: true}>;
|
|
2744
|
+
partialSettings.languages = [undefined]; // OK
|
|
2682
2745
|
```
|
|
2683
2746
|
*/
|
|
2684
2747
|
readonly allowUndefinedInNonTupleArrays?: boolean;
|
|
2685
2748
|
};
|
|
2686
2749
|
type DefaultPartialDeepOptions = {
|
|
2687
2750
|
recurseIntoArrays: false;
|
|
2688
|
-
allowUndefinedInNonTupleArrays:
|
|
2751
|
+
allowUndefinedInNonTupleArrays: false;
|
|
2689
2752
|
};
|
|
2690
2753
|
|
|
2691
2754
|
/**
|
|
@@ -2699,19 +2762,19 @@ Use-cases:
|
|
|
2699
2762
|
```
|
|
2700
2763
|
import type {PartialDeep} from 'type-fest';
|
|
2701
2764
|
|
|
2702
|
-
|
|
2765
|
+
let settings = {
|
|
2703
2766
|
textEditor: {
|
|
2704
2767
|
fontSize: 14,
|
|
2705
2768
|
fontColor: '#000000',
|
|
2706
|
-
fontWeight: 400
|
|
2769
|
+
fontWeight: 400,
|
|
2707
2770
|
},
|
|
2708
2771
|
autocomplete: false,
|
|
2709
|
-
autosave: true
|
|
2772
|
+
autosave: true,
|
|
2710
2773
|
};
|
|
2711
2774
|
|
|
2712
|
-
const applySavedSettings = (savedSettings: PartialDeep<
|
|
2713
|
-
|
|
2714
|
-
|
|
2775
|
+
const applySavedSettings = (savedSettings: PartialDeep<typeof settings>) => (
|
|
2776
|
+
{...settings, ...savedSettings, textEditor: {...settings.textEditor, ...savedSettings.textEditor}}
|
|
2777
|
+
);
|
|
2715
2778
|
|
|
2716
2779
|
settings = applySavedSettings({textEditor: {fontWeight: 500}});
|
|
2717
2780
|
```
|
|
@@ -2721,13 +2784,15 @@ By default, this does not affect elements in array and tuple types. You can chan
|
|
|
2721
2784
|
```
|
|
2722
2785
|
import type {PartialDeep} from 'type-fest';
|
|
2723
2786
|
|
|
2724
|
-
type
|
|
2725
|
-
|
|
2726
|
-
}
|
|
2787
|
+
type Shape = {
|
|
2788
|
+
dimensions: [number, number];
|
|
2789
|
+
};
|
|
2727
2790
|
|
|
2728
|
-
const
|
|
2729
|
-
|
|
2791
|
+
const partialShape: PartialDeep<Shape, {recurseIntoArrays: true}> = {
|
|
2792
|
+
dimensions: [], // OK
|
|
2730
2793
|
};
|
|
2794
|
+
|
|
2795
|
+
partialShape.dimensions = [15]; // OK
|
|
2731
2796
|
```
|
|
2732
2797
|
|
|
2733
2798
|
@see {@link PartialDeepOptions}
|
|
@@ -2828,7 +2893,7 @@ type InferRegleSchemaStatusType<TSchema extends unknown, TState extends unknown,
|
|
|
2828
2893
|
/**
|
|
2829
2894
|
* @public
|
|
2830
2895
|
*/
|
|
2831
|
-
type RegleSchemaFieldStatus<
|
|
2896
|
+
type RegleSchemaFieldStatus<_TSchema extends unknown, TState = any, TShortcuts extends RegleShortcutDefinition = {}> = Omit<RegleCommonStatus<TState>, '$pending'> & {
|
|
2832
2897
|
/** Collection of all the error messages, collected for all children properties and nested forms.
|
|
2833
2898
|
*
|
|
2834
2899
|
* Only contains errors from properties where $dirty equals true. */
|
|
@@ -2942,7 +3007,7 @@ declare const useRegleSchema: useRegleSchemaFn<RegleShortcutDefinition<any>, {},
|
|
|
2942
3007
|
* useRegleSchema({name: ''}, schema)
|
|
2943
3008
|
* ```
|
|
2944
3009
|
*/
|
|
2945
|
-
declare function withDeps<TSchema extends StandardSchemaV1, TParams extends unknown[] = []>(schema: TSchema,
|
|
3010
|
+
declare function withDeps<TSchema extends StandardSchemaV1, TParams extends unknown[] = []>(schema: TSchema, _depsArray: [...TParams]): TSchema;
|
|
2946
3011
|
//#endregion
|
|
2947
3012
|
//#region src/core/inferSchema.d.ts
|
|
2948
3013
|
interface inferSchemaFn {
|
|
@@ -2990,7 +3055,7 @@ type CreateScopedUseRegleSchemaOptions<TCustomRegle extends useRegleSchemaFn<any
|
|
|
2990
3055
|
*/
|
|
2991
3056
|
customUseRegle?: TCustomRegle;
|
|
2992
3057
|
};
|
|
2993
|
-
declare const useCollectSchemaScope: <TValue extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?: MaybeRefOrGetter<string>) => {
|
|
3058
|
+
declare const useCollectSchemaScope: <TValue extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?: vue0.MaybeRefOrGetter<string>) => {
|
|
2994
3059
|
r$: MergedScopedRegles<TValue>;
|
|
2995
3060
|
}, useScopedRegleSchema: useRegleSchemaFn<RegleShortcutDefinition<any>, {}, {}>;
|
|
2996
3061
|
declare const createScopedUseRegleSchema: <TCustomRegle extends useRegleSchemaFn = useRegleSchemaFn, TAsRecord extends boolean = false, TReturnedRegle extends useRegleSchemaFn<any, any, any> = (TCustomRegle extends useRegleSchemaFn<infer S> ? useRegleSchemaFn<S, {
|