@regle/schemas 1.8.5 → 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/dist/regle-schemas.d.ts +533 -470
- 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;
|
|
165
145
|
//#endregion
|
|
166
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
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;
|
|
219
|
+
//#endregion
|
|
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`.
|
|
280
333
|
|
|
281
|
-
|
|
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'>`.
|
|
336
|
+
|
|
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;
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
Returns a boolean for whether the given type is `any`.
|
|
351
|
+
type C = If<boolean, 'yes', 'no'>;
|
|
352
|
+
//=> 'yes' | 'no'
|
|
306
353
|
|
|
307
|
-
|
|
354
|
+
type D = If<any, 'yes', 'no'>;
|
|
355
|
+
//=> 'yes' | 'no'
|
|
308
356
|
|
|
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. */
|
|
@@ -2060,7 +2130,7 @@ type CreateScopedUseRegleOptions<TCustomRegle extends useRegleFn<any, any>, TAsR
|
|
|
2060
2130
|
asRecord?: TAsRecord;
|
|
2061
2131
|
};
|
|
2062
2132
|
//#endregion
|
|
2063
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
2133
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/primitive.d.ts
|
|
2064
2134
|
/**
|
|
2065
2135
|
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
2066
2136
|
|
|
@@ -2068,26 +2138,7 @@ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/
|
|
|
2068
2138
|
*/
|
|
2069
2139
|
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
2070
2140
|
//#endregion
|
|
2071
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
2072
|
-
declare global {
|
|
2073
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
2074
|
-
interface SymbolConstructor {
|
|
2075
|
-
readonly observable: symbol;
|
|
2076
|
-
}
|
|
2077
|
-
}
|
|
2078
|
-
|
|
2079
|
-
/**
|
|
2080
|
-
@remarks
|
|
2081
|
-
The TC39 observable proposal defines a `closed` property, but some implementations (such as xstream) do not as of 10/08/2021.
|
|
2082
|
-
As well, some guidance on making an `Observable` to not include `closed` property.
|
|
2083
|
-
@see https://github.com/tc39/proposal-observable/blob/master/src/Observable.js#L129-L130
|
|
2084
|
-
@see https://github.com/staltz/xstream/blob/6c22580c1d84d69773ee4b0905df44ad464955b3/src/index.ts#L79-L85
|
|
2085
|
-
@see https://github.com/benlesh/symbol-observable#making-an-object-observable
|
|
2086
|
-
|
|
2087
|
-
@category Observable
|
|
2088
|
-
*/
|
|
2089
|
-
//#endregion
|
|
2090
|
-
//#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
|
|
2091
2142
|
declare const emptyObjectSymbol: unique symbol;
|
|
2092
2143
|
|
|
2093
2144
|
/**
|
|
@@ -2119,24 +2170,82 @@ Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<n
|
|
|
2119
2170
|
type EmptyObject = {
|
|
2120
2171
|
[emptyObjectSymbol]?: never;
|
|
2121
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};
|
|
2122
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
|
|
2123
2206
|
/**
|
|
2124
|
-
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.
|
|
2125
2210
|
|
|
2126
2211
|
@example
|
|
2127
2212
|
```
|
|
2128
|
-
import type {
|
|
2213
|
+
import type {IsOptionalKeyOf} from 'type-fest';
|
|
2129
2214
|
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
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
|
|
2133
2241
|
```
|
|
2134
2242
|
|
|
2135
|
-
@
|
|
2136
|
-
@category
|
|
2243
|
+
@category Type Guard
|
|
2244
|
+
@category Utilities
|
|
2137
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;
|
|
2138
2247
|
//#endregion
|
|
2139
|
-
//#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
|
|
2140
2249
|
/**
|
|
2141
2250
|
Extract all optional keys from the given type.
|
|
2142
2251
|
|
|
@@ -2170,11 +2279,11 @@ const update2: UpdateOperation<User> = {
|
|
|
2170
2279
|
|
|
2171
2280
|
@category Utilities
|
|
2172
2281
|
*/
|
|
2173
|
-
type OptionalKeysOf<
|
|
2174
|
-
? (keyof { [Key in keyof
|
|
2175
|
-
: 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;
|
|
2176
2285
|
//#endregion
|
|
2177
|
-
//#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
|
|
2178
2287
|
/**
|
|
2179
2288
|
Extract all required keys from the given type.
|
|
2180
2289
|
|
|
@@ -2199,11 +2308,10 @@ const validator2 = createValidation<User>('surname', value => value.length < 25)
|
|
|
2199
2308
|
|
|
2200
2309
|
@category Utilities
|
|
2201
2310
|
*/
|
|
2202
|
-
type RequiredKeysOf<
|
|
2203
|
-
? Exclude<keyof
|
|
2204
|
-
|
|
2311
|
+
type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
2312
|
+
? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
|
|
2205
2313
|
//#endregion
|
|
2206
|
-
//#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
|
|
2207
2315
|
/**
|
|
2208
2316
|
Returns a boolean for whether the given type is `never`.
|
|
2209
2317
|
|
|
@@ -2247,85 +2355,73 @@ endIfEqual('abc', '123');
|
|
|
2247
2355
|
*/
|
|
2248
2356
|
type IsNever<T> = [T] extends [never] ? true : false;
|
|
2249
2357
|
//#endregion
|
|
2250
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
2358
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/if.d.ts
|
|
2251
2359
|
/**
|
|
2252
|
-
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`.
|
|
2253
2361
|
|
|
2254
|
-
|
|
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'`.
|
|
2255
2368
|
|
|
2256
2369
|
@example
|
|
2257
2370
|
```
|
|
2258
|
-
import
|
|
2259
|
-
|
|
2260
|
-
type ShouldBeTrue = IfNever<never>;
|
|
2261
|
-
//=> true
|
|
2371
|
+
import {If} from 'type-fest';
|
|
2262
2372
|
|
|
2263
|
-
type
|
|
2264
|
-
//=> '
|
|
2265
|
-
```
|
|
2373
|
+
type A = If<true, 'yes', 'no'>;
|
|
2374
|
+
//=> 'yes'
|
|
2266
2375
|
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
*/
|
|
2270
|
-
type IfNever$1<T, TypeIfNever = true, TypeIfNotNever = false> = (IsNever<T> extends true ? TypeIfNever : TypeIfNotNever);
|
|
2271
|
-
//#endregion
|
|
2272
|
-
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/internal/array.d.ts
|
|
2273
|
-
/**
|
|
2274
|
-
Extract the element of an array that also works for array union.
|
|
2376
|
+
type B = If<false, 'yes', 'no'>;
|
|
2377
|
+
//=> 'no'
|
|
2275
2378
|
|
|
2276
|
-
|
|
2379
|
+
type C = If<boolean, 'yes', 'no'>;
|
|
2380
|
+
//=> 'yes' | 'no'
|
|
2277
2381
|
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
type ArrayElement<T> = T extends readonly unknown[] ? T[0] : never;
|
|
2382
|
+
type D = If<any, 'yes', 'no'>;
|
|
2383
|
+
//=> 'yes' | 'no'
|
|
2281
2384
|
|
|
2282
|
-
|
|
2283
|
-
|
|
2385
|
+
type E = If<never, 'yes', 'no'>;
|
|
2386
|
+
//=> 'no'
|
|
2387
|
+
```
|
|
2284
2388
|
|
|
2285
2389
|
@example
|
|
2286
2390
|
```
|
|
2287
|
-
|
|
2288
|
-
type B = StaticPartOfArray<A>;
|
|
2289
|
-
//=> [string, number, boolean]
|
|
2290
|
-
```
|
|
2291
|
-
*/
|
|
2292
|
-
//#endregion
|
|
2293
|
-
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/is-any.d.ts
|
|
2294
|
-
// Can eventually be replaced with the built-in once this library supports
|
|
2295
|
-
// TS5.4+ only. Tracked in https://github.com/sindresorhus/type-fest/issues/848
|
|
2296
|
-
type NoInfer<T> = T extends infer U ? U : never;
|
|
2391
|
+
import {If, IsAny, IsNever} from 'type-fest';
|
|
2297
2392
|
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
@link https://stackoverflow.com/a/49928360/1490091
|
|
2393
|
+
type A = If<IsAny<unknown>, 'is any', 'not any'>;
|
|
2394
|
+
//=> 'not any'
|
|
2302
2395
|
|
|
2303
|
-
|
|
2396
|
+
type B = If<IsNever<never>, 'is never', 'not never'>;
|
|
2397
|
+
//=> 'is never'
|
|
2398
|
+
```
|
|
2304
2399
|
|
|
2305
2400
|
@example
|
|
2306
2401
|
```
|
|
2307
|
-
import
|
|
2308
|
-
|
|
2309
|
-
const typedObject = {a: 1, b: 2} as const;
|
|
2310
|
-
const anyObject: any = {a: 1, b: 2};
|
|
2402
|
+
import {If, IsEqual} from 'type-fest';
|
|
2311
2403
|
|
|
2312
|
-
|
|
2313
|
-
return obj[key];
|
|
2314
|
-
}
|
|
2404
|
+
type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
|
|
2315
2405
|
|
|
2316
|
-
|
|
2317
|
-
//=>
|
|
2406
|
+
type A = IfEqual<string, string, 'equal', 'not equal'>;
|
|
2407
|
+
//=> 'equal'
|
|
2318
2408
|
|
|
2319
|
-
|
|
2320
|
-
//=>
|
|
2409
|
+
type B = IfEqual<string, number, 'equal', 'not equal'>;
|
|
2410
|
+
//=> 'not equal'
|
|
2321
2411
|
```
|
|
2322
2412
|
|
|
2323
2413
|
@category Type Guard
|
|
2324
2414
|
@category Utilities
|
|
2325
2415
|
*/
|
|
2326
|
-
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;
|
|
2327
2423
|
//#endregion
|
|
2328
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
2424
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/simplify.d.ts
|
|
2329
2425
|
/**
|
|
2330
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.
|
|
2331
2427
|
|
|
@@ -2385,7 +2481,7 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
|
|
|
2385
2481
|
*/
|
|
2386
2482
|
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
2387
2483
|
//#endregion
|
|
2388
|
-
//#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
|
|
2389
2485
|
/**
|
|
2390
2486
|
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
2391
2487
|
|
|
@@ -2478,7 +2574,7 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
|
2478
2574
|
*/
|
|
2479
2575
|
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
2480
2576
|
//#endregion
|
|
2481
|
-
//#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
|
|
2482
2578
|
/**
|
|
2483
2579
|
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
2484
2580
|
|
|
@@ -2526,7 +2622,7 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
2526
2622
|
*/
|
|
2527
2623
|
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
2528
2624
|
//#endregion
|
|
2529
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
2625
|
+
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/merge.d.ts
|
|
2530
2626
|
// Merges two objects without worrying about index signatures.
|
|
2531
2627
|
type SimpleMerge<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source;
|
|
2532
2628
|
|
|
@@ -2566,40 +2662,7 @@ export type FooBar = Merge<Foo, Bar>;
|
|
|
2566
2662
|
*/
|
|
2567
2663
|
type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
2568
2664
|
//#endregion
|
|
2569
|
-
//#region ../../node_modules/.pnpm/type-fest@
|
|
2570
|
-
/**
|
|
2571
|
-
An if-else-like type that resolves depending on whether the given type is `any`.
|
|
2572
|
-
|
|
2573
|
-
@see {@link IsAny}
|
|
2574
|
-
|
|
2575
|
-
@example
|
|
2576
|
-
```
|
|
2577
|
-
import type {IfAny} from 'type-fest';
|
|
2578
|
-
|
|
2579
|
-
type ShouldBeTrue = IfAny<any>;
|
|
2580
|
-
//=> true
|
|
2581
|
-
|
|
2582
|
-
type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
|
|
2583
|
-
//=> 'bar'
|
|
2584
|
-
```
|
|
2585
|
-
|
|
2586
|
-
@category Type Guard
|
|
2587
|
-
@category Utilities
|
|
2588
|
-
*/
|
|
2589
|
-
type IfAny$1<T, TypeIfAny = true, TypeIfNotAny = false> = (IsAny<T> extends true ? TypeIfAny : TypeIfNotAny);
|
|
2590
|
-
//#endregion
|
|
2591
|
-
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/internal/type.d.ts
|
|
2592
|
-
/**
|
|
2593
|
-
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
2594
|
-
*/
|
|
2595
|
-
type BuiltIns = Primitive | void | Date | RegExp;
|
|
2596
|
-
|
|
2597
|
-
/**
|
|
2598
|
-
Matches non-recursive types.
|
|
2599
|
-
*/
|
|
2600
|
-
|
|
2601
|
-
//#endregion
|
|
2602
|
-
//#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
|
|
2603
2666
|
/**
|
|
2604
2667
|
Merges user specified options with default options.
|
|
2605
2668
|
|
|
@@ -2652,10 +2715,9 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
|
|
|
2652
2715
|
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
2653
2716
|
```
|
|
2654
2717
|
*/
|
|
2655
|
-
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> =
|
|
2656
|
-
>>;
|
|
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>>>>;
|
|
2657
2719
|
//#endregion
|
|
2658
|
-
//#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
|
|
2659
2721
|
/**
|
|
2660
2722
|
@see {@link PartialDeep}
|
|
2661
2723
|
*/
|
|
@@ -2670,24 +2732,23 @@ type PartialDeepOptions = {
|
|
|
2670
2732
|
Allows `undefined` values in non-tuple arrays.
|
|
2671
2733
|
- When set to `true`, elements of non-tuple arrays can be `undefined`.
|
|
2672
2734
|
- When set to `false`, only explicitly defined elements are allowed in non-tuple arrays, ensuring stricter type checking.
|
|
2673
|
-
@default
|
|
2735
|
+
@default false
|
|
2674
2736
|
@example
|
|
2675
|
-
You can
|
|
2737
|
+
You can allow `undefined` values in non-tuple arrays by passing `{recurseIntoArrays: true; allowUndefinedInNonTupleArrays: true}` as the second type argument:
|
|
2676
2738
|
```
|
|
2677
2739
|
import type {PartialDeep} from 'type-fest';
|
|
2678
2740
|
type Settings = {
|
|
2679
2741
|
languages: string[];
|
|
2680
2742
|
};
|
|
2681
|
-
declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays:
|
|
2682
|
-
partialSettings.languages = [undefined]; //
|
|
2683
|
-
partialSettings.languages = []; // Ok
|
|
2743
|
+
declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays: true}>;
|
|
2744
|
+
partialSettings.languages = [undefined]; // OK
|
|
2684
2745
|
```
|
|
2685
2746
|
*/
|
|
2686
2747
|
readonly allowUndefinedInNonTupleArrays?: boolean;
|
|
2687
2748
|
};
|
|
2688
2749
|
type DefaultPartialDeepOptions = {
|
|
2689
2750
|
recurseIntoArrays: false;
|
|
2690
|
-
allowUndefinedInNonTupleArrays:
|
|
2751
|
+
allowUndefinedInNonTupleArrays: false;
|
|
2691
2752
|
};
|
|
2692
2753
|
|
|
2693
2754
|
/**
|
|
@@ -2701,19 +2762,19 @@ Use-cases:
|
|
|
2701
2762
|
```
|
|
2702
2763
|
import type {PartialDeep} from 'type-fest';
|
|
2703
2764
|
|
|
2704
|
-
|
|
2765
|
+
let settings = {
|
|
2705
2766
|
textEditor: {
|
|
2706
2767
|
fontSize: 14,
|
|
2707
2768
|
fontColor: '#000000',
|
|
2708
|
-
fontWeight: 400
|
|
2769
|
+
fontWeight: 400,
|
|
2709
2770
|
},
|
|
2710
2771
|
autocomplete: false,
|
|
2711
|
-
autosave: true
|
|
2772
|
+
autosave: true,
|
|
2712
2773
|
};
|
|
2713
2774
|
|
|
2714
|
-
const applySavedSettings = (savedSettings: PartialDeep<
|
|
2715
|
-
|
|
2716
|
-
|
|
2775
|
+
const applySavedSettings = (savedSettings: PartialDeep<typeof settings>) => (
|
|
2776
|
+
{...settings, ...savedSettings, textEditor: {...settings.textEditor, ...savedSettings.textEditor}}
|
|
2777
|
+
);
|
|
2717
2778
|
|
|
2718
2779
|
settings = applySavedSettings({textEditor: {fontWeight: 500}});
|
|
2719
2780
|
```
|
|
@@ -2723,13 +2784,15 @@ By default, this does not affect elements in array and tuple types. You can chan
|
|
|
2723
2784
|
```
|
|
2724
2785
|
import type {PartialDeep} from 'type-fest';
|
|
2725
2786
|
|
|
2726
|
-
type
|
|
2727
|
-
|
|
2728
|
-
}
|
|
2787
|
+
type Shape = {
|
|
2788
|
+
dimensions: [number, number];
|
|
2789
|
+
};
|
|
2729
2790
|
|
|
2730
|
-
const
|
|
2731
|
-
|
|
2791
|
+
const partialShape: PartialDeep<Shape, {recurseIntoArrays: true}> = {
|
|
2792
|
+
dimensions: [], // OK
|
|
2732
2793
|
};
|
|
2794
|
+
|
|
2795
|
+
partialShape.dimensions = [15]; // OK
|
|
2733
2796
|
```
|
|
2734
2797
|
|
|
2735
2798
|
@see {@link PartialDeepOptions}
|
|
@@ -2830,7 +2893,7 @@ type InferRegleSchemaStatusType<TSchema extends unknown, TState extends unknown,
|
|
|
2830
2893
|
/**
|
|
2831
2894
|
* @public
|
|
2832
2895
|
*/
|
|
2833
|
-
type RegleSchemaFieldStatus<
|
|
2896
|
+
type RegleSchemaFieldStatus<_TSchema extends unknown, TState = any, TShortcuts extends RegleShortcutDefinition = {}> = Omit<RegleCommonStatus<TState>, '$pending'> & {
|
|
2834
2897
|
/** Collection of all the error messages, collected for all children properties and nested forms.
|
|
2835
2898
|
*
|
|
2836
2899
|
* Only contains errors from properties where $dirty equals true. */
|
|
@@ -2944,7 +3007,7 @@ declare const useRegleSchema: useRegleSchemaFn<RegleShortcutDefinition<any>, {},
|
|
|
2944
3007
|
* useRegleSchema({name: ''}, schema)
|
|
2945
3008
|
* ```
|
|
2946
3009
|
*/
|
|
2947
|
-
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;
|
|
2948
3011
|
//#endregion
|
|
2949
3012
|
//#region src/core/inferSchema.d.ts
|
|
2950
3013
|
interface inferSchemaFn {
|
|
@@ -2992,7 +3055,7 @@ type CreateScopedUseRegleSchemaOptions<TCustomRegle extends useRegleSchemaFn<any
|
|
|
2992
3055
|
*/
|
|
2993
3056
|
customUseRegle?: TCustomRegle;
|
|
2994
3057
|
};
|
|
2995
|
-
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>) => {
|
|
2996
3059
|
r$: MergedScopedRegles<TValue>;
|
|
2997
3060
|
}, useScopedRegleSchema: useRegleSchemaFn<RegleShortcutDefinition<any>, {}, {}>;
|
|
2998
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, {
|