@regle/schemas 1.8.5 → 1.9.0-beta.1

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.
@@ -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$1<T> = T extends Array<infer U> ? U : never;
25
+ type ArrayElement<T> = T extends Array<infer U> ? U : never;
25
26
  //#endregion
26
- //#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/primitive.d.ts
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@4.41.0/node_modules/type-fest/source/observable-like.d.ts
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@4.41.0/node_modules/type-fest/source/empty-object.d.ts
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$1<T> = T extends EmptyObject$1 ? true : false;
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;
165
176
  //#endregion
166
- //#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/optional-keys-of.d.ts
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<BaseType extends object> = BaseType extends unknown // For distributing `BaseType`
201
- ? (keyof { [Key in keyof BaseType as BaseType extends Record<Key, BaseType[Key]> ? never : Key]: never }) & (keyof BaseType) // Intersect with `keyof BaseType` to ensure result of `OptionalKeysOf<BaseType>` is always assignable to `keyof BaseType`
202
- : never; // Should never happen
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@4.41.0/node_modules/type-fest/source/required-keys-of.d.ts
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<BaseType extends object> = BaseType extends unknown // For distributing `BaseType`
230
- ? Exclude<keyof BaseType, OptionalKeysOf$1<BaseType>> : never; // Should never happen
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@4.41.0/node_modules/type-fest/source/is-never.d.ts
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@4.41.0/node_modules/type-fest/source/if-never.d.ts
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 `never`.
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
- @see {@link IsNever}
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 type {IfNever} from 'type-fest';
343
+ import {If} from 'type-fest';
286
344
 
287
- type ShouldBeTrue = IfNever<never>;
288
- //=> true
345
+ type A = If<true, 'yes', 'no'>;
346
+ //=> 'yes'
289
347
 
290
- type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
291
- //=> 'bar'
292
- ```
348
+ type B = If<false, 'yes', 'no'>;
349
+ //=> 'no'
293
350
 
294
- @category Type Guard
295
- @category Utilities
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
- @link https://stackoverflow.com/a/49928360/1490091
354
+ type D = If<any, 'yes', 'no'>;
355
+ //=> 'yes' | 'no'
308
356
 
309
- Useful in type utilities, such as disallowing `any`s to be passed to a function.
357
+ type E = If<never, 'yes', 'no'>;
358
+ //=> 'no'
359
+ ```
310
360
 
311
361
  @example
312
362
  ```
313
- import type {IsAny} from 'type-fest';
363
+ import {If, IsAny, IsNever} from 'type-fest';
314
364
 
315
- const typedObject = {a: 1, b: 2} as const;
316
- const anyObject: any = {a: 1, b: 2};
365
+ type A = If<IsAny<unknown>, 'is any', 'not any'>;
366
+ //=> 'not any'
317
367
 
318
- function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(obj: O, key: K) {
319
- return obj[key];
320
- }
368
+ type B = If<IsNever<never>, 'is never', 'not never'>;
369
+ //=> 'is never'
370
+ ```
321
371
 
322
- const typedA = get(typedObject, 'a');
323
- //=> 1
372
+ @example
373
+ ```
374
+ import {If, IsEqual} from 'type-fest';
324
375
 
325
- const anyA = get(anyObject, 'a');
326
- //=> any
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 IsAny$1<T> = 0 extends 1 & NoInfer$1<T> ? true : false;
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@4.41.0/node_modules/type-fest/source/is-equal.d.ts
390
+ //#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/internal/type.d.ts
391
+ /**
392
+ Matches any primitive, `void`, `Date`, or `RegExp` value.
393
+ */
394
+ type BuiltIns$1 = Primitive$1 | void | Date | RegExp;
335
395
  /**
336
- Returns a boolean for whether the two given types are equal.
396
+ Test if the given function has multiple call signatures.
337
397
 
338
- @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
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
- Use-cases:
342
- - If you want to make a conditional branch based on the result of a comparison of two types.
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
- import type {IsEqual} from 'type-fest';
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
- // This type returns a boolean for whether the given array includes the given item.
349
- // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
350
- type Includes<Value extends readonly any[], Item> =
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
- @category Type Guard
359
- @category Utilities
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 IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
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@4.41.0/node_modules/type-fest/source/or.d.ts
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 either of two given types are true.
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 {Or} from 'type-fest';
430
+ import type {IsNull} from 'type-fest';
372
431
 
373
- Or<true, false>;
374
- //=> true
432
+ type NonNullFallback<T, Fallback> = IsNull<T> extends true ? Fallback : T;
375
433
 
376
- Or<false, false>;
377
- //=> false
434
+ type Example1 = NonNullFallback<null, string>;
435
+ //=> string
436
+
437
+ type Example2 = NonNullFallback<number, string>;
438
+ //=? number
378
439
  ```
379
440
 
380
- @see {@link And}
441
+ @category Type Guard
442
+ @category Utilities
381
443
  */
382
- type Or<A extends boolean, B extends boolean> = [A, B][number] extends false ? false : true extends [IsEqual<A, true>, IsEqual<B, true>][number] ? true : never;
444
+ type IsNull<T> = [T] extends [null] ? true : false;
383
445
  //#endregion
384
- //#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/internal/keys.d.ts
446
+ //#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/is-unknown.d.ts
385
447
  /**
386
- Disallows any of the given keys.
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
- Utility type to retrieve only literal keys from type.
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@4.41.0/node_modules/type-fest/source/simplify.d.ts
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@4.41.0/node_modules/type-fest/source/omit-index-signature.d.ts
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@4.41.0/node_modules/type-fest/source/pick-index-signature.d.ts
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@4.41.0/node_modules/type-fest/source/merge.d.ts
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@4.41.0/node_modules/type-fest/source/if-any.d.ts
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> = IfAny$1$1<SpecifiedOptions, Defaults, IfNever$1$1<SpecifiedOptions, Defaults, Simplify$1<Merge$1<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf$1<Options> ? Extract<SpecifiedOptions[Key], undefined> extends never ? Key : never : Key]: SpecifiedOptions[Key] }> & Required<Options>> // `& Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
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>>>>;
789
+ //#endregion
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>>;
753
875
  //#endregion
754
- //#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/require-exactly-one.d.ts
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, IfNever$1$1<KeysType, never, _RequireExactlyOne<ObjectType, IfAny$1$1<KeysType, keyof ObjectType, KeysType>>>>;
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@4.41.0/node_modules/type-fest/source/require-one-or-none.d.ts
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, IfNever$1$1<KeysType, ObjectType, _RequireOneOrNone<ObjectType, IfAny$1$1<KeysType, keyof ObjectType, KeysType>>>>;
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@4.41.0/node_modules/type-fest/source/partial-deep.d.ts
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 true
976
+ @default false
837
977
  @example
838
- You can prevent `undefined` values in non-tuple arrays by passing `{recurseIntoArrays: true; allowUndefinedInNonTupleArrays: false}` as the second type argument:
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: false}>;
845
- partialSettings.languages = [undefined]; // Error
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: true;
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
- const settings: Settings = {
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<Settings>) => {
878
- return {...settings, ...savedSettings};
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 Settings = {
890
- languages: string[];
891
- }
1028
+ type Shape = {
1029
+ dimensions: [number, number];
1030
+ };
892
1031
 
893
- const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true}> = {
894
- languages: [undefined]
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,127 +1077,98 @@ 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@4.41.0/node_modules/type-fest/source/required-deep.d.ts
940
-
941
- //#endregion
942
- //#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/union-to-tuple.d.ts
943
- /**
944
- Returns the last element of a union type.
945
-
946
- @example
947
- ```
948
- type Last = LastOfUnion<1 | 2 | 3>;
949
- //=> 3
950
- ```
951
- */
952
- type LastOfUnion<T> = UnionToIntersection<T extends any ? () => T : never> extends (() => (infer R)) ? R : never;
953
-
1080
+ //#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/required-deep.d.ts
954
1081
  /**
955
- Convert a union type into an unordered tuple type of its elements.
956
-
957
- "Unordered" means the elements of the tuple are not guaranteed to be in the same order as in the union type. The arrangement can appear random and may change at any time.
1082
+ Create a type from another type with all keys and nested keys set to required.
958
1083
 
959
- This can be useful when you have objects with a finite set of keys and want a type defining only the allowed keys, but do not want to repeat yourself.
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.
960
1087
 
961
1088
  @example
962
1089
  ```
963
- import type {UnionToTuple} from 'type-fest';
964
-
965
- type Numbers = 1 | 2 | 3;
966
- type NumbersTuple = UnionToTuple<Numbers>;
967
- //=> [1, 2, 3]
968
- ```
1090
+ import type {RequiredDeep} from 'type-fest';
969
1091
 
970
- @example
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
+ // }
971
1112
  ```
972
- import type {UnionToTuple} from 'type-fest';
973
-
974
- const pets = {
975
- dog: '🐶',
976
- cat: '🐱',
977
- snake: '🐍',
978
- };
979
-
980
- type Pet = keyof typeof pets;
981
- //=> 'dog' | 'cat' | 'snake'
982
1113
 
983
- const petList = Object.keys(pets) as UnionToTuple<Pet>;
984
- //=> ['dog', 'cat', 'snake']
985
- ```
1114
+ Note that types containing overloaded functions are not made deeply required due to a [TypeScript limitation](https://github.com/microsoft/TypeScript/issues/29732).
986
1115
 
1116
+ @category Utilities
1117
+ @category Object
987
1118
  @category Array
1119
+ @category Set
1120
+ @category Map
988
1121
  */
989
- type UnionToTuple<T, L = LastOfUnion<T>> = IsNever$1<T> extends false ? [...UnionToTuple<Exclude<T, L>>, L] : [];
990
- //#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
1122
 
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
1123
  //#endregion
1013
- //#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/is-unknown.d.ts
1124
+ //#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/union-to-tuple.d.ts
1014
1125
  /**
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.
1126
+ Returns the last element of a union type.
1020
1127
 
1021
1128
  @example
1022
1129
  ```
1023
- import type {IsUnknown} from 'type-fest';
1130
+ type Last = LastOfUnion<1 | 2 | 3>;
1131
+ //=> 3
1132
+ ```
1133
+ */
1134
+ type LastOfUnion<T> = UnionToIntersection<T extends any ? () => T : never> extends (() => (infer R)) ? R : never;
1024
1135
 
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;
1136
+ /**
1137
+ Convert a union type into an unordered tuple type of its elements.
1030
1138
 
1031
- class Store<TState> {
1032
- constructor(private state: TState) {}
1139
+ "Unordered" means the elements of the tuple are not guaranteed to be in the same order as in the union type. The arrangement can appear random and may change at any time.
1033
1140
 
1034
- execute<TPayload = void>(action: Action<TState, TPayload>, payload?: TPayload): TState {
1035
- this.state = action(this.state, payload);
1036
- return this.state;
1037
- }
1141
+ This can be useful when you have objects with a finite set of keys and want a type defining only the allowed keys, but do not want to repeat yourself.
1038
1142
 
1039
- // ... other methods
1040
- }
1143
+ @example
1144
+ ```
1145
+ import type {UnionToTuple} from 'type-fest';
1041
1146
 
1042
- const store = new Store({value: 1});
1043
- declare const someExternalData: unknown;
1147
+ type Numbers = 1 | 2 | 3;
1148
+ type NumbersTuple = UnionToTuple<Numbers>;
1149
+ //=> [1, 2, 3]
1150
+ ```
1044
1151
 
1045
- store.execute(state => ({value: state.value + 1}));
1046
- //=> `TPayload` is `void`
1152
+ @example
1153
+ ```
1154
+ import type {UnionToTuple} from 'type-fest';
1047
1155
 
1048
- store.execute((state, payload) => ({value: state.value + payload}), 5);
1049
- //=> `TPayload` is `5`
1156
+ const pets = {
1157
+ dog: '🐶',
1158
+ cat: '🐱',
1159
+ snake: '🐍',
1160
+ };
1050
1161
 
1051
- store.execute((state, payload) => ({value: state.value + payload}), someExternalData);
1052
- //=> Errors: `action` is `(state: TState) => TState`
1162
+ type Pet = keyof typeof pets;
1163
+ //=> 'dog' | 'cat' | 'snake'
1164
+
1165
+ const petList = Object.keys(pets) as UnionToTuple<Pet>;
1166
+ //=> ['dog', 'cat', 'snake']
1053
1167
  ```
1054
1168
 
1055
- @category Utilities
1169
+ @category Array
1056
1170
  */
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);
1171
+ type UnionToTuple<T, L = LastOfUnion<T>> = IsNever$1<T> extends false ? [...UnionToTuple<Exclude<T, L>>, L] : [];
1060
1172
  //#endregion
1061
1173
  //#region src/types/core/modifiers.types.d.ts
1062
1174
  interface RegleBehaviourOptions {
@@ -1126,7 +1238,7 @@ type CollectionRegleBehaviourOptions = FieldRegleBehaviourOptions & {
1126
1238
  $deepCompare?: boolean;
1127
1239
  };
1128
1240
  type ShortcutCommonFn<T extends Record<string, any>> = {
1129
- [x: string]: (element: OmitByType<T, Function>) => unknown;
1241
+ [x: string]: (element: Omit<OmitByType<T, Function>, '~standard'>) => unknown;
1130
1242
  };
1131
1243
  type RegleShortcutDefinition<TCustomRules extends Record<string, any> = {}> = {
1132
1244
  /**
@@ -1226,6 +1338,28 @@ type RegleResult<Data extends Record<string, any> | any[] | unknown, TRules exte
1226
1338
  valid: true;
1227
1339
  data: IsUnknown<Data> extends true ? unknown : IsAny$1<Data> extends true ? unknown : HasNamedKeys<Data> extends true ? Data extends Array<infer U extends Record<string, any>> ? DeepSafeFormState<U, TRules>[] : Data extends Date | File ? SafeFieldProperty<Data, TRules> : Data extends Record<string, any> ? DeepSafeFormState<Data, TRules> : SafeFieldProperty<Data, TRules> : unknown;
1228
1340
  };
1341
+ type RegleNestedResult<Data extends Record<string, any> | unknown, TRules extends ReglePartialRuleTree<any> | RegleFormPropertyType<any>> = RegleResult<Data, TRules> & ({
1342
+ valid: false;
1343
+ issues: RegleIssuesTree<Data>;
1344
+ errors: RegleErrorTree<Data>;
1345
+ } | {
1346
+ valid: true;
1347
+ issues: EmptyObject$1;
1348
+ errors: EmptyObject$1;
1349
+ });
1350
+ type RegleCollectionResult<Data extends any[], TRules extends ReglePartialRuleTree<any> | RegleFormPropertyType<any>> = RegleResult<Data, TRules> & ({
1351
+ valid: false;
1352
+ issues: RegleCollectionErrors<Data, true>;
1353
+ errors: RegleCollectionErrors<Data>;
1354
+ } | {
1355
+ valid: true;
1356
+ issues: EmptyObject$1;
1357
+ errors: EmptyObject$1;
1358
+ });
1359
+ type RegleFieldResult<Data extends any, TRules extends ReglePartialRuleTree<any> | RegleFormPropertyType<any>> = RegleResult<Data, TRules> & {
1360
+ issues: RegleFieldIssue<TRules>[];
1361
+ errors: string[];
1362
+ };
1229
1363
  /**
1230
1364
  * Infer safe output from any `r$` instance
1231
1365
  *
@@ -1237,11 +1371,13 @@ type RegleResult<Data extends Record<string, any> | any[] | unknown, TRules exte
1237
1371
  type $InternalRegleResult = {
1238
1372
  valid: boolean;
1239
1373
  data: any;
1374
+ errors: $InternalRegleErrorTree | $InternalRegleCollectionErrors | string[];
1375
+ issues: $InternalRegleIssuesTree | $InternalRegleCollectionIssues | RegleFieldIssue[];
1240
1376
  };
1241
1377
  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
1378
  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
1379
  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$1<NonNullable<TState>>, ExtractFromGetter<TRule['$each']> extends undefined ? {} : NonNullable<ExtractFromGetter<TRule['$each']>>> extends false ? false : true : true;
1380
+ 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
1381
  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
1382
  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
1383
  type SafeFieldProperty<TState, TRule extends RegleFormPropertyType<any, any> | undefined = never> = FieldHaveRequiredRule<TRule> extends true ? NonNullable<TState> : MaybeOutput<TState>;
@@ -1251,30 +1387,16 @@ type SafeFieldProperty<TState, TRule extends RegleFormPropertyType<any, any> | u
1251
1387
  * Negates a boolean type.
1252
1388
  */
1253
1389
  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
1390
  /**
1260
1391
  * Checks if the given type is `never`.
1261
1392
  */
1262
1393
  type IsNever$2<T> = [T] extends [never] ? true : false;
1263
- /**
1264
- * Checks if the given type is `any`.
1265
- */
1266
-
1267
1394
  /**
1268
1395
  * Checks if one type extends another. Note: this is not quite the same as `Left extends Right` because:
1269
1396
  * 1. If either type is `never`, the result is `true` iff the other type is also `never`.
1270
1397
  * 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
1398
  */
1272
1399
  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
1400
  /**
1279
1401
  * Convert a union to an intersection.
1280
1402
  * `A | B | C` -\> `A & B & C`
@@ -1297,24 +1419,13 @@ type TuplifyUnion<Union, LastElement = LastOf<Union>> = IsNever$2<Union> extends
1297
1419
  */
1298
1420
  type UnionToTuple$1<Union> = TuplifyUnion<Union>;
1299
1421
  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
1422
  //#endregion
1312
1423
  //#region src/types/core/variants.types.d.ts
1313
1424
 
1314
1425
  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
1426
  $fields: ProcessChildrenFields<TState, TRules, TShortcuts>[keyof ProcessChildrenFields<TState, TRules, TShortcuts>];
1316
1427
  } & (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$1<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$1<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> } : {} };
1428
+ 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
1429
  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
1430
  //#endregion
1320
1431
  //#region src/core/useRegle/useRegle.d.ts
@@ -1347,6 +1458,72 @@ interface useRegleFn<TCustomRules extends Partial<AllRulesDeclarations>, TShortc
1347
1458
  * Docs: {@link https://reglejs.dev/core-concepts/}
1348
1459
  */
1349
1460
 
1461
+ //#endregion
1462
+ //#region ../../node_modules/.pnpm/@standard-schema+spec@1.0.0/node_modules/@standard-schema/spec/dist/index.d.ts
1463
+ /** The Standard Schema interface. */
1464
+ interface StandardSchemaV1$1<Input = unknown, Output = Input> {
1465
+ /** The Standard Schema properties. */
1466
+ readonly "~standard": StandardSchemaV1$1.Props<Input, Output>;
1467
+ }
1468
+ declare namespace StandardSchemaV1$1 {
1469
+ /** The Standard Schema properties interface. */
1470
+ export interface Props<Input = unknown, Output = Input> {
1471
+ /** The version number of the standard. */
1472
+ readonly version: 1;
1473
+ /** The vendor name of the schema library. */
1474
+ readonly vendor: string;
1475
+ /** Validates unknown input values. */
1476
+ readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
1477
+ /** Inferred types associated with the schema. */
1478
+ readonly types?: Types<Input, Output> | undefined;
1479
+ }
1480
+ /** The result interface of the validate function. */
1481
+ export type Result<Output> = SuccessResult<Output> | FailureResult;
1482
+ /** The result interface if validation succeeds. */
1483
+ export interface SuccessResult<Output> {
1484
+ /** The typed output value. */
1485
+ readonly value: Output;
1486
+ /** The non-existent issues. */
1487
+ readonly issues?: undefined;
1488
+ }
1489
+ /** The result interface if validation fails. */
1490
+ export interface FailureResult {
1491
+ /** The issues of failed validation. */
1492
+ readonly issues: ReadonlyArray<Issue>;
1493
+ }
1494
+ /** The issue interface of the failure output. */
1495
+ export interface Issue {
1496
+ /** The error message of the issue. */
1497
+ readonly message: string;
1498
+ /** The path of the issue, if any. */
1499
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
1500
+ }
1501
+ /** The path segment interface of the issue. */
1502
+ export interface PathSegment {
1503
+ /** The key representing a path segment. */
1504
+ readonly key: PropertyKey;
1505
+ }
1506
+ /** The Standard Schema types interface. */
1507
+ export interface Types<Input = unknown, Output = Input> {
1508
+ /** The input type of the schema. */
1509
+ readonly input: Input;
1510
+ /** The output type of the schema. */
1511
+ readonly output: Output;
1512
+ }
1513
+ /** Infers the input type of a Standard Schema. */
1514
+ export type InferInput<Schema extends StandardSchemaV1$1> = NonNullable<Schema["~standard"]["types"]>["input"];
1515
+ /** Infers the output type of a Standard Schema. */
1516
+ export type InferOutput<Schema extends StandardSchemaV1$1> = NonNullable<Schema["~standard"]["types"]>["output"];
1517
+ export {};
1518
+ }
1519
+ //#endregion
1520
+ //#region src/core/useRegle/useErrors.d.ts
1521
+ /**
1522
+ * Converts a nested $errors object to a flat array of string errors
1523
+ *
1524
+ * Can also flatten to an array containing the path of each error with the options.includePath
1525
+ */
1526
+
1350
1527
  //#endregion
1351
1528
  //#region src/types/utils/mismatch.types.d.ts
1352
1529
  /**
@@ -1439,7 +1616,7 @@ type IsLiteral<T> = string extends T ? false : true;
1439
1616
  /**
1440
1617
  * Returned typed of rules created with `createRule`
1441
1618
  * */
1442
- 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> {
1619
+ 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
1620
  validator: RegleRuleDefinitionProcessor<TFilteredValue, TParams, TAsync extends false ? TMetaData : Promise<TMetaData>>;
1444
1621
  message: (metadata: PossibleRegleRuleMetadataConsumer<TFilteredValue>) => string | string[];
1445
1622
  active: (metadata: PossibleRegleRuleMetadataConsumer<TFilteredValue>) => boolean;
@@ -1448,10 +1625,6 @@ interface RegleRuleDefinition<TValue extends unknown = unknown, TParams extends
1448
1625
  _value?: IsLiteral<TValue> extends true ? TValue : any;
1449
1626
  exec: (value: Maybe<TFilteredValue>) => TAsync extends false ? TMetaData : Promise<TMetaData>;
1450
1627
  }
1451
- /**
1452
- * @internal
1453
- * */
1454
-
1455
1628
  /**
1456
1629
  * Rules with params created with `createRules` are callable while being customizable
1457
1630
  */
@@ -1491,10 +1664,6 @@ type PossibleRegleRuleMetadataConsumer<TValue> = {
1491
1664
  } & DefaultMetadataProperties & {
1492
1665
  $params?: [...any[]];
1493
1666
  };
1494
- /**
1495
- * @internal
1496
- */
1497
-
1498
1667
  /**
1499
1668
  * Generic types for a created RegleRule
1500
1669
  */
@@ -1512,9 +1681,9 @@ type RegleRuleRawInput<TValue extends any = any, TParams extends [...any[]] = [.
1512
1681
 
1513
1682
  type RegleRuleDefinitionProcessor<TValue extends any = any, TParams extends any[] = [], TReturn = any> = (value: Maybe<TValue>, ...params: TParams) => TReturn;
1514
1683
  type RegleCollectionRuleDefinition<TValue = any[], TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = (RegleRuleDecl<NonNullable<TValue>, TCustomRules, CollectionRegleBehaviourOptions> & {
1515
- $each: MaybeGetter<RegleFormPropertyType<ArrayElement$1<NonNullable<TValue>>, TCustomRules>, ArrayElement$1<TValue>>;
1684
+ $each: MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue>>, TCustomRules>, ArrayElement<TValue>>;
1516
1685
  }) | ({
1517
- $each: MaybeGetter<RegleFormPropertyType<ArrayElement$1<NonNullable<TValue>>, TCustomRules>, ArrayElement$1<TValue>>;
1686
+ $each: MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue>>, TCustomRules>, ArrayElement<TValue>>;
1518
1687
  } & CollectionRegleBehaviourOptions);
1519
1688
  //#endregion
1520
1689
  //#region src/types/rules/rule.init.types.d.ts
@@ -1536,11 +1705,6 @@ interface RegleRuleCore<TValue extends any, TParams extends any[] = [], TAsync e
1536
1705
  type?: string;
1537
1706
  async?: boolean;
1538
1707
  }
1539
- /**
1540
- * @internal
1541
- * createRule arguments options
1542
- */
1543
-
1544
1708
  //#endregion
1545
1709
  //#region src/core/defaultValidators.d.ts
1546
1710
  interface CommonComparisonOptions {
@@ -1657,7 +1821,7 @@ type RegleCollectionRuleDecl<TValue = any[], TCustomRules extends Partial<AllRul
1657
1821
  $each?: RegleCollectionEachRules<TValue, TCustomRules>;
1658
1822
  } & CollectionRegleBehaviourOptions);
1659
1823
  /** @public */
1660
- type RegleCollectionEachRules<TValue = any[], TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = MaybeGetter<RegleFormPropertyType<ArrayElement$1<NonNullable<TValue>>, TCustomRules>, ArrayElement$1<TValue>, RegleCollectionRuleDeclKeyProperty>;
1824
+ type RegleCollectionEachRules<TValue = any[], TCustomRules extends Partial<AllRulesDeclarations> = Partial<AllRulesDeclarations>> = MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue>>, TCustomRules>, ArrayElement<TValue>, RegleCollectionRuleDeclKeyProperty>;
1661
1825
  /**
1662
1826
  * @internal
1663
1827
  * @reference {@link RegleCollectionRuleDecl}
@@ -1667,10 +1831,6 @@ type RegleCollectionEachRules<TValue = any[], TCustomRules extends Partial<AllRu
1667
1831
  * @public
1668
1832
  */
1669
1833
  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
1834
  /**
1675
1835
  * @public
1676
1836
  * Regroup inline and registered rules
@@ -1687,7 +1847,7 @@ type RegleRoot<TState extends Record<string, unknown> = {}, TRules extends Regle
1687
1847
  */
1688
1848
  $groups: { readonly [TKey in keyof TValidationGroups]: RegleValidationGroupOutput };
1689
1849
  });
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$1<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$1<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> } : {};
1850
+ 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
1851
  /**
1692
1852
  * @public
1693
1853
  */
@@ -1711,7 +1871,7 @@ type RegleStatus<TState extends Record<string, any> | undefined = Record<string,
1711
1871
  /** Will return a copy of your state with only the fields that are dirty. By default it will filter out nullish values or objects, but you can override it with the first parameter $extractDirtyFields(false). */
1712
1872
  $extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep$1<TState>;
1713
1873
  /** Sets all properties as dirty, triggering all rules. It returns a promise that will either resolve to false or a type safe copy of your form state. Values that had the required rule will be transformed into a non-nullable value (type only). */
1714
- $validate: () => Promise<RegleResult<JoinDiscriminatedUnions<TState>, TRules>>;
1874
+ $validate: (forceValues?: JoinDiscriminatedUnions<TState> extends EmptyObject$1 ? any : HasNamedKeys<JoinDiscriminatedUnions<TState>> extends true ? IsUnknown<JoinDiscriminatedUnions<TState>> extends true ? any : JoinDiscriminatedUnions<TState> : any) => Promise<RegleNestedResult<JoinDiscriminatedUnions<TState>, TRules>>;
1715
1875
  } & ProcessNestedFields$1<TState, TRules, TShortcuts> & ([TShortcuts['nested']] extends [never] ? {} : { [K in keyof TShortcuts['nested']]: ReturnType<NonNullable<TShortcuts['nested']>[K]> });
1716
1876
  /**
1717
1877
  * @internal
@@ -1731,7 +1891,7 @@ type RegleFieldIssue<TRules extends RegleFormPropertyType<any, Partial<AllRulesD
1731
1891
  readonly $property: string;
1732
1892
  readonly $type?: string;
1733
1893
  readonly $message: string;
1734
- } & (IsEmptyObject$1<TRules> extends true ? {
1894
+ } & (IsEmptyObject<TRules> extends true ? {
1735
1895
  readonly $rule: string;
1736
1896
  } : { [K in keyof ComputeFieldRules<any, TRules>]: ComputeFieldRules<any, TRules>[K] extends {
1737
1897
  $metadata: infer TMetadata;
@@ -1744,7 +1904,7 @@ type RegleFieldIssue<TRules extends RegleFormPropertyType<any, Partial<AllRulesD
1744
1904
  } : {
1745
1905
  readonly $rule: string;
1746
1906
  } }[keyof ComputeFieldRules<any, TRules>]);
1747
- type ComputeFieldRules<TState extends any, TRules extends RegleFormPropertyType<any, Partial<AllRulesDeclarations>>> = IsEmptyObject$1<TRules> extends true ? {
1907
+ type ComputeFieldRules<TState extends any, TRules extends RegleFormPropertyType<any, Partial<AllRulesDeclarations>>> = IsEmptyObject<TRules> extends true ? {
1748
1908
  readonly [x: string]: RegleRuleStatus<TState, any[], any>;
1749
1909
  } : { 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
1910
  /**
@@ -1778,7 +1938,7 @@ type RegleFieldStatus<TState extends any = any, TRules extends RegleFormProperty
1778
1938
  /** Will return a copy of your state with only the fields that are dirty. By default it will filter out nullish values or objects, but you can override it with the first parameter $extractDirtyFields(false). */
1779
1939
  $extractDirtyFields: (filterNullishValues?: boolean) => MaybeOutput<TState>;
1780
1940
  /** Sets all properties as dirty, triggering all rules. It returns a promise that will either resolve to false or a type safe copy of your form state. Values that had the required rule will be transformed into a non-nullable value (type only). */
1781
- $validate: () => Promise<RegleResult<TState, TRules>>;
1941
+ $validate: (forceValues?: IsUnknown<TState> extends true ? any : TState) => Promise<RegleFieldResult<TState, TRules>>;
1782
1942
  /** This is reactive tree containing all the declared rules of your field. To know more about the rule properties check the rules properties section */
1783
1943
  readonly $rules: ComputeFieldRules<TState, TRules>;
1784
1944
  } & ([TShortcuts['fields']] extends [never] ? {} : { [K in keyof TShortcuts['fields']]: ReturnType<NonNullable<TShortcuts['fields']>[K]> });
@@ -1790,7 +1950,7 @@ type RegleFieldStatus<TState extends any = any, TRules extends RegleFormProperty
1790
1950
  /**
1791
1951
  * @public
1792
1952
  */
1793
- interface RegleCommonStatus<TValue = any> {
1953
+ interface RegleCommonStatus<TValue = any> extends StandardSchemaV1$1<TValue> {
1794
1954
  /** Indicates whether the field is invalid. It becomes true if any associated rules return false. */
1795
1955
  readonly $invalid: boolean;
1796
1956
  /**
@@ -1915,7 +2075,7 @@ interface $InternalRegleRuleStatus {
1915
2075
  /**
1916
2076
  * @public
1917
2077
  */
1918
- type RegleCollectionStatus<TState extends any[] = any[], TRules extends ReglePartialRuleTree<ArrayElement$1<TState>> = Record<string, any>, TFieldRule extends RegleCollectionRuleDecl<any, any> = never, TShortcuts extends RegleShortcutDefinition = {}> = Omit<RegleCommonStatus<TState>, '$value'> & {
2078
+ 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
2079
  /** A reference to the original validated model. It can be used to bind your form with v-model.*/
1920
2080
  $value: MaybeOutput<TState>;
1921
2081
  /** $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. */
@@ -1939,7 +2099,7 @@ type RegleCollectionStatus<TState extends any[] = any[], TRules extends ReglePar
1939
2099
  /** Will return a copy of your state with only the fields that are dirty. By default it will filter out nullish values or objects, but you can override it with the first parameter $extractDirtyFields(false). */
1940
2100
  $extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep$1<TState>;
1941
2101
  /** Sets all properties as dirty, triggering all rules. It returns a promise that will either resolve to false or a type safe copy of your form state. Values that had the required rule will be transformed into a non-nullable value (type only). */
1942
- $validate: () => Promise<RegleResult<JoinDiscriminatedUnions<TState>, JoinDiscriminatedUnions<TRules>>>;
2102
+ $validate: (value?: JoinDiscriminatedUnions<TState>) => Promise<RegleCollectionResult<TState, JoinDiscriminatedUnions<TRules>>>;
1943
2103
  } & ([TShortcuts['collections']] extends [never] ? {} : { [K in keyof TShortcuts['collections']]: ReturnType<NonNullable<TShortcuts['collections']>[K]> });
1944
2104
  /**
1945
2105
  * @internal
@@ -1961,13 +2121,31 @@ type RegleExternalCollectionErrors<TState extends Record<string, any>, TIssue ex
1961
2121
  readonly $each?: RegleValidationErrors<TState, true, TIssue>[];
1962
2122
  };
1963
2123
  /** @internal */
2124
+ type $InternalRegleCollectionErrors = {
2125
+ readonly $self?: string[];
2126
+ readonly $each?: $InternalRegleErrors[];
2127
+ };
2128
+ type $InternalRegleErrorTree = {
2129
+ [x: string]: $InternalRegleErrors;
2130
+ };
2131
+ type $InternalRegleErrors = $InternalRegleCollectionErrors | string[] | $InternalRegleErrorTree;
2132
+ type $InternalRegleIssuesTree = {
2133
+ [x: string]: $InternalRegleIssues;
2134
+ };
2135
+ type $InternalRegleIssues = $InternalRegleCollectionIssues | RegleFieldIssue[] | $InternalRegleIssuesTree;
2136
+ type $InternalRegleCollectionIssues = {
2137
+ readonly $self?: RegleFieldIssue[];
2138
+ readonly $each?: $InternalRegleIssues[];
2139
+ };
2140
+ //#endregion
2141
+ //#region src/types/rules/compatibility.rules.d.ts
1964
2142
 
1965
2143
  /** Supports both core Regle and schemas Regle for Zod/Valibot */
1966
2144
  type SuperCompatibleRegleRoot = SuperCompatibleRegleStatus & {
1967
2145
  $groups?: {
1968
2146
  [x: string]: RegleValidationGroupOutput;
1969
2147
  };
1970
- $validate: () => Promise<SuperCompatibleRegleResult>;
2148
+ $validate: (...args: any[]) => Promise<SuperCompatibleRegleResult>;
1971
2149
  };
1972
2150
  type SuperCompatibleRegleResult = $InternalRegleResult;
1973
2151
  type SuperCompatibleRegleStatus = {
@@ -1996,10 +2174,12 @@ type MergedRegles<TRegles extends Record<string, SuperCompatibleRegleRoot>, TVal
1996
2174
  readonly $errors: { [K in keyof TRegles]: TRegles[K]['$errors'] };
1997
2175
  /** Collection of all the error messages, collected for all children properties. */
1998
2176
  readonly $silentErrors: { [K in keyof TRegles]: TRegles[K]['$silentErrors'] };
2177
+ readonly $issues: { [K in keyof TRegles]: TRegles[K]['$issues'] };
2178
+ readonly $silentIssues: { [K in keyof TRegles]: TRegles[K]['$silentIssues'] };
1999
2179
  /** Will return a copy of your state with only the fields that are dirty. By default it will filter out nullish values or objects, but you can override it with the first parameter $extractDirtyFields(false). */
2000
2180
  $extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep$1<TValue>;
2001
2181
  /** Sets all properties as dirty, triggering all rules. It returns a promise that will either resolve to false or a type safe copy of your form state. Values that had the required rule will be transformed into a non-nullable value (type only). */
2002
- $validate: () => Promise<MergedReglesResult<TRegles>>;
2182
+ $validate: (forceValues?: TRegles['$value']) => Promise<MergedReglesResult<TRegles>>;
2003
2183
  };
2004
2184
  type MergedScopedRegles<TValue extends Record<string, unknown>[] = Record<string, unknown>[]> = Omit<MergedRegles<Record<string, SuperCompatibleRegleRoot>, TValue>, '$instances' | '$errors' | '$silentErrors' | '$value' | '$silentValue' | '$validate'> & {
2005
2185
  /** Array of scoped Regles instances */
@@ -2010,10 +2190,16 @@ type MergedScopedRegles<TValue extends Record<string, unknown>[] = Record<string
2010
2190
  readonly $errors: RegleValidationErrors<Record<string, unknown>>[];
2011
2191
  /** Collection of all registered Regles instances silent errors */
2012
2192
  readonly $silentErrors: RegleValidationErrors<Record<string, unknown>>[];
2193
+ /** Collection of all registered Regles instances issues */
2194
+ readonly $issues: RegleValidationErrors<Record<string, unknown>, false, true>[];
2195
+ /** Collection of all registered Regles instances silent issues */
2196
+ readonly $silentIssues: RegleValidationErrors<Record<string, unknown>, false, true>[];
2013
2197
  /** Sets all properties as dirty, triggering all rules. It returns a promise that will either resolve to false or a type safe copy of your form state. Values that had the required rule will be transformed into a non-nullable value (type only). */
2014
- $validate: () => Promise<{
2198
+ $validate: (forceValues?: TValue) => Promise<{
2015
2199
  valid: boolean;
2016
2200
  data: TValue;
2201
+ errors: RegleValidationErrors<Record<string, unknown>>[];
2202
+ issues: RegleValidationErrors<Record<string, unknown>>[];
2017
2203
  }>;
2018
2204
  };
2019
2205
  type MergedReglesResult<TRegles extends Record<string, SuperCompatibleRegleRoot>> = {
@@ -2021,11 +2207,15 @@ type MergedReglesResult<TRegles extends Record<string, SuperCompatibleRegleRoot>
2021
2207
  data: { [K in keyof TRegles]: Extract<PromiseReturn<ReturnType<TRegles[K]['$validate']>>, {
2022
2208
  valid: false;
2023
2209
  }>['data'] };
2210
+ errors: { [K in keyof TRegles]: TRegles[K]['$errors'] };
2211
+ issues: { [K in keyof TRegles]: TRegles[K]['$issues'] };
2024
2212
  } | {
2025
2213
  valid: true;
2026
2214
  data: { [K in keyof TRegles]: Extract<PromiseReturn<ReturnType<TRegles[K]['$validate']>>, {
2027
2215
  valid: true;
2028
2216
  }>['data'] };
2217
+ errors: EmptyObject$1;
2218
+ issues: EmptyObject$1;
2029
2219
  };
2030
2220
  //#endregion
2031
2221
  //#region src/core/createScopedUseRegle/useCollectScope.d.ts
@@ -2060,7 +2250,7 @@ type CreateScopedUseRegleOptions<TCustomRegle extends useRegleFn<any, any>, TAsR
2060
2250
  asRecord?: TAsRecord;
2061
2251
  };
2062
2252
  //#endregion
2063
- //#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/primitive.d.ts
2253
+ //#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/primitive.d.ts
2064
2254
  /**
2065
2255
  Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
2066
2256
 
@@ -2068,26 +2258,7 @@ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/
2068
2258
  */
2069
2259
  type Primitive = null | undefined | string | number | boolean | symbol | bigint;
2070
2260
  //#endregion
2071
- //#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/observable-like.d.ts
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
2261
+ //#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/empty-object.d.ts
2091
2262
  declare const emptyObjectSymbol: unique symbol;
2092
2263
 
2093
2264
  /**
@@ -2119,24 +2290,82 @@ Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<n
2119
2290
  type EmptyObject = {
2120
2291
  [emptyObjectSymbol]?: never;
2121
2292
  };
2293
+ //#endregion
2294
+ //#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/is-any.d.ts
2295
+ /**
2296
+ Returns a boolean for whether the given type is `any`.
2297
+
2298
+ @link https://stackoverflow.com/a/49928360/1490091
2299
+
2300
+ Useful in type utilities, such as disallowing `any`s to be passed to a function.
2301
+
2302
+ @example
2303
+ ```
2304
+ import type {IsAny} from 'type-fest';
2305
+
2306
+ const typedObject = {a: 1, b: 2} as const;
2307
+ const anyObject: any = {a: 1, b: 2};
2122
2308
 
2309
+ function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(obj: O, key: K) {
2310
+ return obj[key];
2311
+ }
2312
+
2313
+ const typedA = get(typedObject, 'a');
2314
+ //=> 1
2315
+
2316
+ const anyA = get(anyObject, 'a');
2317
+ //=> any
2318
+ ```
2319
+
2320
+ @category Type Guard
2321
+ @category Utilities
2322
+ */
2323
+ type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
2324
+ //#endregion
2325
+ //#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/is-optional-key-of.d.ts
2123
2326
  /**
2124
- Returns a `boolean` for whether the type is strictly equal to an empty plain object, the `{}` value.
2327
+ Returns a boolean for whether the given key is an optional key of type.
2328
+
2329
+ This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
2125
2330
 
2126
2331
  @example
2127
2332
  ```
2128
- import type {IsEmptyObject} from 'type-fest';
2333
+ import type {IsOptionalKeyOf} from 'type-fest';
2129
2334
 
2130
- type Pass = IsEmptyObject<{}>; //=> true
2131
- type Fail = IsEmptyObject<[]>; //=> false
2132
- type Fail = IsEmptyObject<null>; //=> false
2335
+ interface User {
2336
+ name: string;
2337
+ surname: string;
2338
+
2339
+ luckyNumber?: number;
2340
+ }
2341
+
2342
+ interface Admin {
2343
+ name: string;
2344
+ surname?: string;
2345
+ }
2346
+
2347
+ type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
2348
+ //=> true
2349
+
2350
+ type T2 = IsOptionalKeyOf<User, 'name'>;
2351
+ //=> false
2352
+
2353
+ type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
2354
+ //=> boolean
2355
+
2356
+ type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
2357
+ //=> false
2358
+
2359
+ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
2360
+ //=> boolean
2133
2361
  ```
2134
2362
 
2135
- @see EmptyObject
2136
- @category Object
2363
+ @category Type Guard
2364
+ @category Utilities
2137
2365
  */
2366
+ 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
2367
  //#endregion
2139
- //#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/optional-keys-of.d.ts
2368
+ //#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/optional-keys-of.d.ts
2140
2369
  /**
2141
2370
  Extract all optional keys from the given type.
2142
2371
 
@@ -2170,11 +2399,11 @@ const update2: UpdateOperation<User> = {
2170
2399
 
2171
2400
  @category Utilities
2172
2401
  */
2173
- type OptionalKeysOf<BaseType extends object> = BaseType extends unknown // For distributing `BaseType`
2174
- ? (keyof { [Key in keyof BaseType as BaseType extends Record<Key, BaseType[Key]> ? never : Key]: never }) & (keyof BaseType) // Intersect with `keyof BaseType` to ensure result of `OptionalKeysOf<BaseType>` is always assignable to `keyof BaseType`
2175
- : never; // Should never happen
2402
+ type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
2403
+ ? (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`
2404
+ : never;
2176
2405
  //#endregion
2177
- //#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/required-keys-of.d.ts
2406
+ //#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/required-keys-of.d.ts
2178
2407
  /**
2179
2408
  Extract all required keys from the given type.
2180
2409
 
@@ -2199,11 +2428,10 @@ const validator2 = createValidation<User>('surname', value => value.length < 25)
2199
2428
 
2200
2429
  @category Utilities
2201
2430
  */
2202
- type RequiredKeysOf<BaseType extends object> = BaseType extends unknown // For distributing `BaseType`
2203
- ? Exclude<keyof BaseType, OptionalKeysOf<BaseType>> : never; // Should never happen
2204
-
2431
+ type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
2432
+ ? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
2205
2433
  //#endregion
2206
- //#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/is-never.d.ts
2434
+ //#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/is-never.d.ts
2207
2435
  /**
2208
2436
  Returns a boolean for whether the given type is `never`.
2209
2437
 
@@ -2247,85 +2475,73 @@ endIfEqual('abc', '123');
2247
2475
  */
2248
2476
  type IsNever<T> = [T] extends [never] ? true : false;
2249
2477
  //#endregion
2250
- //#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/if-never.d.ts
2478
+ //#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/if.d.ts
2251
2479
  /**
2252
- An if-else-like type that resolves depending on whether the given type is `never`.
2480
+ An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
2253
2481
 
2254
- @see {@link IsNever}
2482
+ Use-cases:
2483
+ - 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'>`.
2484
+
2485
+ Note:
2486
+ - 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'`.
2487
+ - Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
2255
2488
 
2256
2489
  @example
2257
2490
  ```
2258
- import type {IfNever} from 'type-fest';
2259
-
2260
- type ShouldBeTrue = IfNever<never>;
2261
- //=> true
2491
+ import {If} from 'type-fest';
2262
2492
 
2263
- type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
2264
- //=> 'bar'
2265
- ```
2493
+ type A = If<true, 'yes', 'no'>;
2494
+ //=> 'yes'
2266
2495
 
2267
- @category Type Guard
2268
- @category Utilities
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.
2496
+ type B = If<false, 'yes', 'no'>;
2497
+ //=> 'no'
2275
2498
 
2276
- Returns `never` if T is not an array.
2499
+ type C = If<boolean, 'yes', 'no'>;
2500
+ //=> 'yes' | 'no'
2277
2501
 
2278
- It creates a type-safe way to access the element type of `unknown` type.
2279
- */
2280
- type ArrayElement<T> = T extends readonly unknown[] ? T[0] : never;
2502
+ type D = If<any, 'yes', 'no'>;
2503
+ //=> 'yes' | 'no'
2281
2504
 
2282
- /**
2283
- Returns the static, fixed-length portion of the given array, excluding variable-length parts.
2505
+ type E = If<never, 'yes', 'no'>;
2506
+ //=> 'no'
2507
+ ```
2284
2508
 
2285
2509
  @example
2286
2510
  ```
2287
- type A = [string, number, boolean, ...string[]];
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;
2511
+ import {If, IsAny, IsNever} from 'type-fest';
2297
2512
 
2298
- /**
2299
- Returns a boolean for whether the given type is `any`.
2300
-
2301
- @link https://stackoverflow.com/a/49928360/1490091
2513
+ type A = If<IsAny<unknown>, 'is any', 'not any'>;
2514
+ //=> 'not any'
2302
2515
 
2303
- Useful in type utilities, such as disallowing `any`s to be passed to a function.
2516
+ type B = If<IsNever<never>, 'is never', 'not never'>;
2517
+ //=> 'is never'
2518
+ ```
2304
2519
 
2305
2520
  @example
2306
2521
  ```
2307
- import type {IsAny} from 'type-fest';
2308
-
2309
- const typedObject = {a: 1, b: 2} as const;
2310
- const anyObject: any = {a: 1, b: 2};
2522
+ import {If, IsEqual} from 'type-fest';
2311
2523
 
2312
- function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(obj: O, key: K) {
2313
- return obj[key];
2314
- }
2524
+ type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
2315
2525
 
2316
- const typedA = get(typedObject, 'a');
2317
- //=> 1
2526
+ type A = IfEqual<string, string, 'equal', 'not equal'>;
2527
+ //=> 'equal'
2318
2528
 
2319
- const anyA = get(anyObject, 'a');
2320
- //=> any
2529
+ type B = IfEqual<string, number, 'equal', 'not equal'>;
2530
+ //=> 'not equal'
2321
2531
  ```
2322
2532
 
2323
2533
  @category Type Guard
2324
2534
  @category Utilities
2325
2535
  */
2326
- type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
2536
+ type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
2537
+ //#endregion
2538
+ //#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/internal/type.d.ts
2539
+ /**
2540
+ Matches any primitive, `void`, `Date`, or `RegExp` value.
2541
+ */
2542
+ type BuiltIns = Primitive | void | Date | RegExp;
2327
2543
  //#endregion
2328
- //#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/simplify.d.ts
2544
+ //#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/simplify.d.ts
2329
2545
  /**
2330
2546
  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
2547
 
@@ -2385,7 +2601,7 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
2385
2601
  */
2386
2602
  type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
2387
2603
  //#endregion
2388
- //#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/omit-index-signature.d.ts
2604
+ //#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/omit-index-signature.d.ts
2389
2605
  /**
2390
2606
  Omit any index signatures from the given object type, leaving only explicitly defined properties.
2391
2607
 
@@ -2478,7 +2694,7 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
2478
2694
  */
2479
2695
  type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
2480
2696
  //#endregion
2481
- //#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/pick-index-signature.d.ts
2697
+ //#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/pick-index-signature.d.ts
2482
2698
  /**
2483
2699
  Pick only index signatures from the given object type, leaving out all explicitly defined properties.
2484
2700
 
@@ -2526,7 +2742,7 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
2526
2742
  */
2527
2743
  type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
2528
2744
  //#endregion
2529
- //#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/merge.d.ts
2745
+ //#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/merge.d.ts
2530
2746
  // Merges two objects without worrying about index signatures.
2531
2747
  type SimpleMerge<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source;
2532
2748
 
@@ -2566,40 +2782,7 @@ export type FooBar = Merge<Foo, Bar>;
2566
2782
  */
2567
2783
  type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
2568
2784
  //#endregion
2569
- //#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/if-any.d.ts
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
2785
+ //#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/internal/object.d.ts
2603
2786
  /**
2604
2787
  Merges user specified options with default options.
2605
2788
 
@@ -2652,10 +2835,9 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
2652
2835
  // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
2653
2836
  ```
2654
2837
  */
2655
- type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = IfAny$1<SpecifiedOptions, Defaults, IfNever$1<SpecifiedOptions, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? Extract<SpecifiedOptions[Key], undefined> extends never ? Key : never : Key]: SpecifiedOptions[Key] }> & Required<Options>> // `& Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
2656
- >>;
2838
+ 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
2839
  //#endregion
2658
- //#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/partial-deep.d.ts
2840
+ //#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/partial-deep.d.ts
2659
2841
  /**
2660
2842
  @see {@link PartialDeep}
2661
2843
  */
@@ -2670,24 +2852,23 @@ type PartialDeepOptions = {
2670
2852
  Allows `undefined` values in non-tuple arrays.
2671
2853
  - When set to `true`, elements of non-tuple arrays can be `undefined`.
2672
2854
  - When set to `false`, only explicitly defined elements are allowed in non-tuple arrays, ensuring stricter type checking.
2673
- @default true
2855
+ @default false
2674
2856
  @example
2675
- You can prevent `undefined` values in non-tuple arrays by passing `{recurseIntoArrays: true; allowUndefinedInNonTupleArrays: false}` as the second type argument:
2857
+ You can allow `undefined` values in non-tuple arrays by passing `{recurseIntoArrays: true; allowUndefinedInNonTupleArrays: true}` as the second type argument:
2676
2858
  ```
2677
2859
  import type {PartialDeep} from 'type-fest';
2678
2860
  type Settings = {
2679
2861
  languages: string[];
2680
2862
  };
2681
- declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays: false}>;
2682
- partialSettings.languages = [undefined]; // Error
2683
- partialSettings.languages = []; // Ok
2863
+ declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays: true}>;
2864
+ partialSettings.languages = [undefined]; // OK
2684
2865
  ```
2685
2866
  */
2686
2867
  readonly allowUndefinedInNonTupleArrays?: boolean;
2687
2868
  };
2688
2869
  type DefaultPartialDeepOptions = {
2689
2870
  recurseIntoArrays: false;
2690
- allowUndefinedInNonTupleArrays: true;
2871
+ allowUndefinedInNonTupleArrays: false;
2691
2872
  };
2692
2873
 
2693
2874
  /**
@@ -2701,19 +2882,19 @@ Use-cases:
2701
2882
  ```
2702
2883
  import type {PartialDeep} from 'type-fest';
2703
2884
 
2704
- const settings: Settings = {
2885
+ let settings = {
2705
2886
  textEditor: {
2706
2887
  fontSize: 14,
2707
2888
  fontColor: '#000000',
2708
- fontWeight: 400
2889
+ fontWeight: 400,
2709
2890
  },
2710
2891
  autocomplete: false,
2711
- autosave: true
2892
+ autosave: true,
2712
2893
  };
2713
2894
 
2714
- const applySavedSettings = (savedSettings: PartialDeep<Settings>) => {
2715
- return {...settings, ...savedSettings};
2716
- }
2895
+ const applySavedSettings = (savedSettings: PartialDeep<typeof settings>) => (
2896
+ {...settings, ...savedSettings, textEditor: {...settings.textEditor, ...savedSettings.textEditor}}
2897
+ );
2717
2898
 
2718
2899
  settings = applySavedSettings({textEditor: {fontWeight: 500}});
2719
2900
  ```
@@ -2723,13 +2904,15 @@ By default, this does not affect elements in array and tuple types. You can chan
2723
2904
  ```
2724
2905
  import type {PartialDeep} from 'type-fest';
2725
2906
 
2726
- type Settings = {
2727
- languages: string[];
2728
- }
2907
+ type Shape = {
2908
+ dimensions: [number, number];
2909
+ };
2729
2910
 
2730
- const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true}> = {
2731
- languages: [undefined]
2911
+ const partialShape: PartialDeep<Shape, {recurseIntoArrays: true}> = {
2912
+ dimensions: [], // OK
2732
2913
  };
2914
+
2915
+ partialShape.dimensions = [15]; // OK
2733
2916
  ```
2734
2917
 
2735
2918
  @see {@link PartialDeepOptions}
@@ -2790,15 +2973,19 @@ type RegleSingleFieldSchema<TState extends Maybe<PrimitiveTypes>, TSchema extend
2790
2973
  */
2791
2974
  r$: Raw<RegleSchemaFieldStatus<TState, TSchema, TShortcuts> & {
2792
2975
  /** Sets all properties as dirty, triggering all rules. It returns a promise that will either resolve to false or a type safe copy of your form state. Values that had the required rule will be transformed into a non-nullable value (type only). */
2793
- $validate: () => Promise<RegleSchemaResult<TSchema>>;
2976
+ $validate: (forceValues?: TSchema extends EmptyObject ? any : HasNamedKeys<TSchema> extends true ? TSchema : any) => Promise<RegleSchemaResult<TSchema>>;
2794
2977
  }>;
2795
2978
  } & TAdditionalReturnProperties;
2796
2979
  type RegleSchemaResult<TSchema extends unknown> = {
2797
2980
  valid: false;
2798
2981
  data: PartialDeep<TSchema>;
2982
+ issues: RegleIssuesTree<TSchema>;
2983
+ errors: RegleErrorTree<TSchema>;
2799
2984
  } | {
2800
2985
  valid: true;
2801
2986
  data: TSchema;
2987
+ issues: EmptyObject;
2988
+ errors: EmptyObject;
2802
2989
  };
2803
2990
  type ProcessNestedFields<TState extends Record<string, any>, TSchema extends Record<string, any>, TShortcuts extends RegleShortcutDefinition> = HasNamedKeys<TState> extends true ? { readonly [TKey in keyof JoinDiscriminatedUnions<TState>]: TKey extends keyof JoinDiscriminatedUnions<TSchema> ? InferRegleSchemaStatusType<NonNullable<JoinDiscriminatedUnions<TSchema>[TKey]>, JoinDiscriminatedUnions<TState>[TKey], TShortcuts> : never } & { readonly [TKey in keyof JoinDiscriminatedUnions<TState> as TKey extends keyof JoinDiscriminatedUnions<TSchema> ? JoinDiscriminatedUnions<TSchema>[TKey] extends NonNullable<JoinDiscriminatedUnions<TSchema>[TKey]> ? TKey : never : never]-?: TKey extends keyof JoinDiscriminatedUnions<TSchema> ? InferRegleSchemaStatusType<NonNullable<JoinDiscriminatedUnions<TSchema>[TKey]>, JoinDiscriminatedUnions<TState>[TKey], TShortcuts> : never } : {};
2804
2991
  /**
@@ -2821,7 +3008,7 @@ type RegleSchemaStatus<TState extends Record<string, any> = Record<string, any>,
2821
3008
  $extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep<TState>;
2822
3009
  } & ProcessNestedFields<TState, TSchema, TShortcuts> & (IsRoot extends true ? {
2823
3010
  /** Sets all properties as dirty, triggering all rules. It returns a promise that will either resolve to false or a type safe copy of your form state. Values that had the required rule will be transformed into a non-nullable value (type only). */
2824
- $validate: () => Promise<RegleSchemaResult<TSchema>>;
3011
+ $validate: (forceValues?: TSchema extends EmptyObject ? (HasNamedKeys<TSchema> extends true ? TSchema : any) : TSchema) => Promise<RegleSchemaResult<TSchema>>;
2825
3012
  } : {}) & ([TShortcuts['nested']] extends [never] ? {} : { [K in keyof TShortcuts['nested']]: ReturnType<NonNullable<TShortcuts['nested']>[K]> });
2826
3013
  /**
2827
3014
  * @public
@@ -2830,7 +3017,7 @@ type InferRegleSchemaStatusType<TSchema extends unknown, TState extends unknown,
2830
3017
  /**
2831
3018
  * @public
2832
3019
  */
2833
- type RegleSchemaFieldStatus<TSchema extends unknown, TState = any, TShortcuts extends RegleShortcutDefinition = {}> = Omit<RegleCommonStatus<TState>, '$pending'> & {
3020
+ type RegleSchemaFieldStatus<_TSchema extends unknown, TState = any, TShortcuts extends RegleShortcutDefinition = {}> = Omit<RegleCommonStatus<TState>, '$pending'> & {
2834
3021
  /** Collection of all the error messages, collected for all children properties and nested forms.
2835
3022
  *
2836
3023
  * Only contains errors from properties where $dirty equals true. */
@@ -2944,7 +3131,7 @@ declare const useRegleSchema: useRegleSchemaFn<RegleShortcutDefinition<any>, {},
2944
3131
  * useRegleSchema({name: ''}, schema)
2945
3132
  * ```
2946
3133
  */
2947
- declare function withDeps<TSchema extends StandardSchemaV1, TParams extends unknown[] = []>(schema: TSchema, depsArray: [...TParams]): TSchema;
3134
+ declare function withDeps<TSchema extends StandardSchemaV1, TParams extends unknown[] = []>(schema: TSchema, _depsArray: [...TParams]): TSchema;
2948
3135
  //#endregion
2949
3136
  //#region src/core/inferSchema.d.ts
2950
3137
  interface inferSchemaFn {
@@ -2992,7 +3179,7 @@ type CreateScopedUseRegleSchemaOptions<TCustomRegle extends useRegleSchemaFn<any
2992
3179
  */
2993
3180
  customUseRegle?: TCustomRegle;
2994
3181
  };
2995
- declare const useCollectSchemaScope: <TValue extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?: MaybeRefOrGetter<string>) => {
3182
+ declare const useCollectSchemaScope: <TValue extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?: vue0.MaybeRefOrGetter<string>) => {
2996
3183
  r$: MergedScopedRegles<TValue>;
2997
3184
  }, useScopedRegleSchema: useRegleSchemaFn<RegleShortcutDefinition<any>, {}, {}>;
2998
3185
  declare const createScopedUseRegleSchema: <TCustomRegle extends useRegleSchemaFn = useRegleSchemaFn, TAsRecord extends boolean = false, TReturnedRegle extends useRegleSchemaFn<any, any, any> = (TCustomRegle extends useRegleSchemaFn<infer S> ? useRegleSchemaFn<S, {