@regle/core 1.3.0 → 1.4.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.
- package/dist/regle-core.d.ts +127 -168
- package/dist/regle-core.js +51 -24
- package/dist/regle-core.min.js +1 -1
- package/package.json +9 -9
package/dist/regle-core.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as vue1 from "vue";
|
|
2
2
|
import { MaybeRef, MaybeRefOrGetter, Raw, Ref, UnwrapNestedRefs, UnwrapRef } from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/types/utils/misc.types.d.ts
|
|
@@ -19,22 +19,19 @@ type ExcludeByType<T, U> = { [K in keyof T as T[K] extends U ? never : K]: T[K]
|
|
|
19
19
|
type PrimitiveTypes = string | number | boolean | bigint | Date | File;
|
|
20
20
|
type isRecordLiteral<T extends unknown> = NonNullable<T> extends Date | File ? false : NonNullable<T> extends Record<string, any> ? true : false;
|
|
21
21
|
type NoInferLegacy<A extends any> = [A][A extends any ? 0 : never];
|
|
22
|
-
|
|
23
22
|
//#endregion
|
|
24
23
|
//#region src/types/utils/Array.types.d.ts
|
|
25
24
|
type ArrayElement<T> = T extends Array<infer U> ? U : never;
|
|
26
|
-
|
|
27
25
|
//#endregion
|
|
28
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
26
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/primitive.d.ts
|
|
29
27
|
/**
|
|
30
28
|
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
31
29
|
|
|
32
30
|
@category Type
|
|
33
31
|
*/
|
|
34
32
|
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
35
|
-
|
|
36
33
|
//#endregion
|
|
37
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
34
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/observable-like.d.ts
|
|
38
35
|
declare global {
|
|
39
36
|
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
40
37
|
interface SymbolConstructor {
|
|
@@ -42,8 +39,6 @@ declare global {
|
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
41
|
|
|
45
|
-
//#endregion
|
|
46
|
-
//#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/union-to-intersection.d.ts
|
|
47
42
|
/**
|
|
48
43
|
@remarks
|
|
49
44
|
The TC39 observable proposal defines a `closed` property, but some implementations (such as xstream) do not as of 10/08/2021.
|
|
@@ -55,6 +50,8 @@ As well, some guidance on making an `Observable` to not include `closed` propert
|
|
|
55
50
|
@category Observable
|
|
56
51
|
*/
|
|
57
52
|
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/union-to-intersection.d.ts
|
|
58
55
|
/**
|
|
59
56
|
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).
|
|
60
57
|
|
|
@@ -100,7 +97,7 @@ type Intersection = UnionToIntersection<Union>;
|
|
|
100
97
|
|
|
101
98
|
@category Type
|
|
102
99
|
*/
|
|
103
|
-
type UnionToIntersection
|
|
100
|
+
type UnionToIntersection<Union> = (
|
|
104
101
|
// `extends unknown` is always going to be the case and is used to convert the
|
|
105
102
|
// `Union` into a [distributive conditional
|
|
106
103
|
// type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
@@ -115,9 +112,8 @@ Union extends unknown
|
|
|
115
112
|
) extends ((mergedIntersection: infer Intersection) => void)
|
|
116
113
|
// The `& Union` is to allow indexing by the resulting type
|
|
117
114
|
? Intersection & Union : never;
|
|
118
|
-
|
|
119
115
|
//#endregion
|
|
120
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
116
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/empty-object.d.ts
|
|
121
117
|
declare const emptyObjectSymbol: unique symbol;
|
|
122
118
|
|
|
123
119
|
/**
|
|
@@ -166,9 +162,8 @@ type Fail = IsEmptyObject<null>; //=> false
|
|
|
166
162
|
@category Object
|
|
167
163
|
*/
|
|
168
164
|
type IsEmptyObject<T> = T extends EmptyObject ? true : false;
|
|
169
|
-
|
|
170
165
|
//#endregion
|
|
171
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
166
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/optional-keys-of.d.ts
|
|
172
167
|
/**
|
|
173
168
|
Extract all optional keys from the given type.
|
|
174
169
|
|
|
@@ -204,11 +199,9 @@ const update2: UpdateOperation<User> = {
|
|
|
204
199
|
*/
|
|
205
200
|
type OptionalKeysOf<BaseType extends object> = BaseType extends unknown // For distributing `BaseType`
|
|
206
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`
|
|
207
|
-
: never;
|
|
208
|
-
|
|
202
|
+
: never; // Should never happen
|
|
209
203
|
//#endregion
|
|
210
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
211
|
-
// Should never happen
|
|
204
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/required-keys-of.d.ts
|
|
212
205
|
/**
|
|
213
206
|
Extract all required keys from the given type.
|
|
214
207
|
|
|
@@ -234,12 +227,10 @@ const validator2 = createValidation<User>('surname', value => value.length < 25)
|
|
|
234
227
|
@category Utilities
|
|
235
228
|
*/
|
|
236
229
|
type RequiredKeysOf<BaseType extends object> = BaseType extends unknown // For distributing `BaseType`
|
|
237
|
-
? Exclude<keyof BaseType, OptionalKeysOf<BaseType>> : never;
|
|
230
|
+
? Exclude<keyof BaseType, OptionalKeysOf<BaseType>> : never; // Should never happen
|
|
238
231
|
|
|
239
232
|
//#endregion
|
|
240
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
241
|
-
// Should never happen
|
|
242
|
-
|
|
233
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/is-never.d.ts
|
|
243
234
|
/**
|
|
244
235
|
Returns a boolean for whether the given type is `never`.
|
|
245
236
|
|
|
@@ -282,9 +273,8 @@ endIfEqual('abc', '123');
|
|
|
282
273
|
@category Utilities
|
|
283
274
|
*/
|
|
284
275
|
type IsNever$1<T> = [T] extends [never] ? true : false;
|
|
285
|
-
|
|
286
276
|
//#endregion
|
|
287
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
277
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/if-never.d.ts
|
|
288
278
|
/**
|
|
289
279
|
An if-else-like type that resolves depending on whether the given type is `never`.
|
|
290
280
|
|
|
@@ -304,10 +294,9 @@ type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
|
|
|
304
294
|
@category Type Guard
|
|
305
295
|
@category Utilities
|
|
306
296
|
*/
|
|
307
|
-
type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = (IsNever$1<T> extends true ? TypeIfNever : TypeIfNotNever);
|
|
308
|
-
|
|
297
|
+
type IfNever$1<T, TypeIfNever = true, TypeIfNotNever = false> = (IsNever$1<T> extends true ? TypeIfNever : TypeIfNotNever);
|
|
309
298
|
//#endregion
|
|
310
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
299
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/is-any.d.ts
|
|
311
300
|
// Can eventually be replaced with the built-in once this library supports
|
|
312
301
|
// TS5.4+ only. Tracked in https://github.com/sindresorhus/type-fest/issues/848
|
|
313
302
|
type NoInfer<T> = T extends infer U ? U : never;
|
|
@@ -341,19 +330,18 @@ const anyA = get(anyObject, 'a');
|
|
|
341
330
|
@category Utilities
|
|
342
331
|
*/
|
|
343
332
|
type IsAny$1<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
344
|
-
|
|
345
333
|
//#endregion
|
|
346
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
334
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/internal/keys.d.ts
|
|
347
335
|
/**
|
|
348
336
|
Disallows any of the given keys.
|
|
349
337
|
*/
|
|
350
338
|
type RequireNone<KeysType extends PropertyKey> = Partial<Record<KeysType, never>>;
|
|
351
339
|
|
|
352
|
-
//#endregion
|
|
353
|
-
//#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/simplify.d.ts
|
|
354
340
|
/**
|
|
355
341
|
Utility type to retrieve only literal keys from type.
|
|
356
342
|
*/
|
|
343
|
+
//#endregion
|
|
344
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/simplify.d.ts
|
|
357
345
|
/**
|
|
358
346
|
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.
|
|
359
347
|
|
|
@@ -412,9 +400,8 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
|
|
|
412
400
|
@category Object
|
|
413
401
|
*/
|
|
414
402
|
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
415
|
-
|
|
416
403
|
//#endregion
|
|
417
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
404
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
418
405
|
/**
|
|
419
406
|
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
420
407
|
|
|
@@ -506,9 +493,8 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
|
506
493
|
@category Object
|
|
507
494
|
*/
|
|
508
495
|
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
509
|
-
|
|
510
496
|
//#endregion
|
|
511
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
497
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/pick-index-signature.d.ts
|
|
512
498
|
/**
|
|
513
499
|
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
514
500
|
|
|
@@ -555,9 +541,8 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
555
541
|
@category Object
|
|
556
542
|
*/
|
|
557
543
|
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
558
|
-
|
|
559
544
|
//#endregion
|
|
560
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
545
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/merge.d.ts
|
|
561
546
|
// Merges two objects without worrying about index signatures.
|
|
562
547
|
type SimpleMerge<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source;
|
|
563
548
|
|
|
@@ -596,9 +581,8 @@ export type FooBar = Merge<Foo, Bar>;
|
|
|
596
581
|
@category Object
|
|
597
582
|
*/
|
|
598
583
|
type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
599
|
-
|
|
600
584
|
//#endregion
|
|
601
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
585
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/if-any.d.ts
|
|
602
586
|
/**
|
|
603
587
|
An if-else-like type that resolves depending on whether the given type is `any`.
|
|
604
588
|
|
|
@@ -618,10 +602,9 @@ type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
|
|
|
618
602
|
@category Type Guard
|
|
619
603
|
@category Utilities
|
|
620
604
|
*/
|
|
621
|
-
type IfAny<T, TypeIfAny = true, TypeIfNotAny = false> = (IsAny$1<T> extends true ? TypeIfAny : TypeIfNotAny);
|
|
622
|
-
|
|
605
|
+
type IfAny$1<T, TypeIfAny = true, TypeIfNotAny = false> = (IsAny$1<T> extends true ? TypeIfAny : TypeIfNotAny);
|
|
623
606
|
//#endregion
|
|
624
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
607
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/internal/type.d.ts
|
|
625
608
|
/**
|
|
626
609
|
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
627
610
|
*/
|
|
@@ -671,12 +654,29 @@ IsNever$1<T> extends true ? false : T extends any ? [U] extends [T] ? false : tr
|
|
|
671
654
|
// In some cases `Result` will return `false | true` which is `boolean`,
|
|
672
655
|
// that means `T` has at least two types and it's a union type,
|
|
673
656
|
// so we will return `true` instead of `boolean`.
|
|
674
|
-
? boolean extends Result ? true : Result : never;
|
|
657
|
+
? boolean extends Result ? true : Result : never; // Should never happen
|
|
675
658
|
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
659
|
+
/**
|
|
660
|
+
An if-else-like type that resolves depending on whether the given type is `any` or `never`.
|
|
661
|
+
|
|
662
|
+
@example
|
|
663
|
+
```
|
|
664
|
+
// When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
|
|
665
|
+
type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
666
|
+
//=> 'VALID'
|
|
667
|
+
|
|
668
|
+
// When `T` is `any` => Returns `IfAny` branch
|
|
669
|
+
type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
670
|
+
//=> 'IS_ANY'
|
|
679
671
|
|
|
672
|
+
// When `T` is `never` => Returns `IfNever` branch
|
|
673
|
+
type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
674
|
+
//=> 'IS_NEVER'
|
|
675
|
+
```
|
|
676
|
+
*/
|
|
677
|
+
type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> = IsAny$1<T> extends true ? IfAny : IsNever$1<T> extends true ? IfNever : IfNotAnyOrNever;
|
|
678
|
+
//#endregion
|
|
679
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/internal/object.d.ts
|
|
680
680
|
/**
|
|
681
681
|
Merges user specified options with default options.
|
|
682
682
|
|
|
@@ -729,11 +729,10 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
|
|
|
729
729
|
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
730
730
|
```
|
|
731
731
|
*/
|
|
732
|
-
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = IfAny<SpecifiedOptions, Defaults, IfNever<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>`
|
|
732
|
+
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>`
|
|
733
733
|
>>;
|
|
734
|
-
|
|
735
734
|
//#endregion
|
|
736
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
735
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/require-exactly-one.d.ts
|
|
737
736
|
/**
|
|
738
737
|
Create a type that requires exactly one of the given keys and disallows more. The remaining keys are kept as is.
|
|
739
738
|
|
|
@@ -763,10 +762,10 @@ const responder: RequireExactlyOne<Responder, 'text' | 'json'> = {
|
|
|
763
762
|
|
|
764
763
|
@category Object
|
|
765
764
|
*/
|
|
766
|
-
type RequireExactlyOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> =
|
|
767
|
-
|
|
765
|
+
type RequireExactlyOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, IfNever$1<KeysType, never, _RequireExactlyOne<ObjectType, IfAny$1<KeysType, keyof ObjectType, KeysType>>>>;
|
|
766
|
+
type _RequireExactlyOne<ObjectType, KeysType extends keyof ObjectType> = { [Key in KeysType]: (Required<Pick<ObjectType, Key>> & Partial<Record<Exclude<KeysType, Key>, never>>) }[KeysType] & Omit<ObjectType, KeysType>;
|
|
768
767
|
//#endregion
|
|
769
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
768
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/require-one-or-none.d.ts
|
|
770
769
|
/**
|
|
771
770
|
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.
|
|
772
771
|
|
|
@@ -797,11 +796,10 @@ const responder3: Responder = {
|
|
|
797
796
|
|
|
798
797
|
@category Object
|
|
799
798
|
*/
|
|
800
|
-
type RequireOneOrNone<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> =
|
|
801
|
-
|
|
799
|
+
type RequireOneOrNone<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, IfNever$1<KeysType, ObjectType, _RequireOneOrNone<ObjectType, IfAny$1<KeysType, keyof ObjectType, KeysType>>>>;
|
|
800
|
+
type _RequireOneOrNone<ObjectType, KeysType extends keyof ObjectType> = (RequireExactlyOne<ObjectType, KeysType> | RequireNone<KeysType>) & Omit<ObjectType, KeysType>; // Ignore unspecified keys.
|
|
802
801
|
//#endregion
|
|
803
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
804
|
-
// Ignore unspecified keys.
|
|
802
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/partial-deep.d.ts
|
|
805
803
|
/**
|
|
806
804
|
@see {@link PartialDeep}
|
|
807
805
|
*/
|
|
@@ -918,9 +916,8 @@ type PartialReadonlySetDeep<T, Options extends Required<PartialDeepOptions>> = {
|
|
|
918
916
|
Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
|
|
919
917
|
*/
|
|
920
918
|
type PartialObjectDeep<ObjectType extends object, Options extends Required<PartialDeepOptions>> = (ObjectType extends ((...arguments_: any) => unknown) ? (...arguments_: Parameters<ObjectType>) => ReturnType<ObjectType> : {}) & ({ [KeyType in keyof ObjectType]?: _PartialDeep<ObjectType[KeyType], Options> });
|
|
921
|
-
|
|
922
919
|
//#endregion
|
|
923
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
920
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/required-deep.d.ts
|
|
924
921
|
type ExcludeUndefined<T> = Exclude<T, undefined>;
|
|
925
922
|
|
|
926
923
|
/**
|
|
@@ -970,9 +967,8 @@ type RequiredDeep<T, E extends ExcludeUndefined<T> = ExcludeUndefined<T>> = E ex
|
|
|
970
967
|
: RequiredObjectDeep<E> // Tuples behave properly
|
|
971
968
|
: RequiredObjectDeep<E> : unknown;
|
|
972
969
|
type RequiredObjectDeep<ObjectType extends object> = { [KeyType in keyof ObjectType]-?: RequiredDeep<ObjectType[KeyType]> };
|
|
973
|
-
|
|
974
970
|
//#endregion
|
|
975
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
971
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/union-to-tuple.d.ts
|
|
976
972
|
/**
|
|
977
973
|
Returns the last element of a union type.
|
|
978
974
|
|
|
@@ -982,7 +978,7 @@ type Last = LastOfUnion<1 | 2 | 3>;
|
|
|
982
978
|
//=> 3
|
|
983
979
|
```
|
|
984
980
|
*/
|
|
985
|
-
type LastOfUnion<T> = UnionToIntersection
|
|
981
|
+
type LastOfUnion<T> = UnionToIntersection<T extends any ? () => T : never> extends (() => (infer R)) ? R : never;
|
|
986
982
|
|
|
987
983
|
/**
|
|
988
984
|
Convert a union type into an unordered tuple type of its elements.
|
|
@@ -1019,10 +1015,9 @@ const petList = Object.keys(pets) as UnionToTuple<Pet>;
|
|
|
1019
1015
|
|
|
1020
1016
|
@category Array
|
|
1021
1017
|
*/
|
|
1022
|
-
type UnionToTuple
|
|
1023
|
-
|
|
1018
|
+
type UnionToTuple<T, L = LastOfUnion<T>> = IsNever$1<T> extends false ? [...UnionToTuple<Exclude<T, L>>, L] : [];
|
|
1024
1019
|
//#endregion
|
|
1025
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
1020
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/is-null.d.ts
|
|
1026
1021
|
/**
|
|
1027
1022
|
Returns a boolean for whether the given type is `null`.
|
|
1028
1023
|
|
|
@@ -1043,9 +1038,8 @@ type Example2 = NonNullFallback<number, string>;
|
|
|
1043
1038
|
@category Utilities
|
|
1044
1039
|
*/
|
|
1045
1040
|
type IsNull<T> = [T] extends [null] ? true : false;
|
|
1046
|
-
|
|
1047
1041
|
//#endregion
|
|
1048
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
1042
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/is-unknown.d.ts
|
|
1049
1043
|
/**
|
|
1050
1044
|
Returns a boolean for whether the given type is `unknown`.
|
|
1051
1045
|
|
|
@@ -1089,10 +1083,9 @@ store.execute((state, payload) => ({value: state.value + payload}), someExternal
|
|
|
1089
1083
|
|
|
1090
1084
|
@category Utilities
|
|
1091
1085
|
*/
|
|
1092
|
-
type IsUnknown
|
|
1086
|
+
type IsUnknown<T> = (unknown extends T // `T` can be `unknown` or `any`
|
|
1093
1087
|
? IsNull<T> extends false // `any` can be `null`, but `unknown` can't be
|
|
1094
1088
|
? true : false : false);
|
|
1095
|
-
|
|
1096
1089
|
//#endregion
|
|
1097
1090
|
//#region src/types/core/modifiers.types.d.ts
|
|
1098
1091
|
interface RegleBehaviourOptions {
|
|
@@ -1180,7 +1173,6 @@ type RegleShortcutDefinition<TCustomRules extends Record<string, any> = {}> = {
|
|
|
1180
1173
|
collections?: ShortcutCommonFn<RegleCollectionStatus<any[], Partial<TCustomRules> & Partial<DefaultValidators>>>;
|
|
1181
1174
|
};
|
|
1182
1175
|
type AddDollarToOptions<T extends Record<string, any>> = { [K in keyof T as `$${string & K}`]: T[K] };
|
|
1183
|
-
|
|
1184
1176
|
//#endregion
|
|
1185
1177
|
//#region src/types/core/useRegle.types.d.ts
|
|
1186
1178
|
type Regle<TState extends Record<string, any> = EmptyObject, TRules extends ReglePartialRuleTree<TState, CustomRulesDeclarationTree> = EmptyObject, TValidationGroups extends Record<string, RegleValidationGroupEntry[]> = {}, TShortcuts extends RegleShortcutDefinition = {}, TAdditionalReturnProperties extends Record<string, any> = {}> = {
|
|
@@ -1201,7 +1193,6 @@ type RegleSingleField<TState extends Maybe<PrimitiveTypes> = any, TRules extends
|
|
|
1201
1193
|
} & TAdditionalReturnProperties;
|
|
1202
1194
|
type DeepReactiveState<T extends Record<string, any> | unknown | undefined> = ExtendOnlyRealRecord<T> extends true ? { [K in keyof T]: InferDeepReactiveState<T[K]> } : never;
|
|
1203
1195
|
type InferDeepReactiveState<TState> = NonNullable<TState> extends Array<infer U extends Record<string, any>> ? DeepReactiveState<U[]> : NonNullable<TState> extends Date | File ? MaybeRef<TState> : NonNullable<TState> extends Record<string, any> ? DeepReactiveState<TState> : MaybeRef<TState>;
|
|
1204
|
-
|
|
1205
1196
|
//#endregion
|
|
1206
1197
|
//#region src/types/core/reset.types.d.ts
|
|
1207
1198
|
type ResetOptions<TState extends unknown> = RequireOneOrNone<{
|
|
@@ -1221,23 +1212,21 @@ type ResetOptions<TState extends unknown> = RequireOneOrNone<{
|
|
|
1221
1212
|
*/
|
|
1222
1213
|
clearExternalErrors?: boolean;
|
|
1223
1214
|
}, 'toInitialState' | 'toState'>;
|
|
1224
|
-
|
|
1225
1215
|
//#endregion
|
|
1226
1216
|
//#region src/types/core/scopedRegle.types.d.ts
|
|
1227
1217
|
type ScopedInstancesRecord = Record<string, Record<string, SuperCompatibleRegleRoot>> & {
|
|
1228
1218
|
'~~global': Record<string, SuperCompatibleRegleRoot>;
|
|
1229
1219
|
};
|
|
1230
1220
|
type ScopedInstancesRecordLike = Partial<ScopedInstancesRecord>;
|
|
1231
|
-
|
|
1232
1221
|
//#endregion
|
|
1233
1222
|
//#region src/types/core/results.types.d.ts
|
|
1234
1223
|
type PartialFormState<TState extends Record<string, any>> = [unknown] extends [TState] ? {} : Prettify<{ [K in keyof TState as ExtendOnlyRealRecord<TState[K]> extends true ? never : TState[K] extends Array<any> ? never : K]?: MaybeOutput<TState[K]> } & { [K in keyof TState as ExtendOnlyRealRecord<TState[K]> extends true ? K : TState[K] extends Array<any> ? K : never]: NonNullable<TState[K]> extends Array<infer U extends Record<string, any>> ? PartialFormState<U>[] : PartialFormState<TState[K]> }>;
|
|
1235
1224
|
type RegleResult<Data extends Record<string, any> | any[] | unknown, TRules extends ReglePartialRuleTree<any>> = {
|
|
1236
1225
|
valid: false;
|
|
1237
|
-
data: IsUnknown
|
|
1226
|
+
data: IsUnknown<Data> extends true ? unknown : NonNullable<Data> extends Date | File ? MaybeOutput<Data> : NonNullable<Data> extends Array<infer U extends Record<string, any>> ? PartialFormState<U>[] : NonNullable<Data> extends Record<string, any> ? PartialFormState<NonNullable<Data>> : MaybeOutput<Data>;
|
|
1238
1227
|
} | {
|
|
1239
1228
|
valid: true;
|
|
1240
|
-
data: IsUnknown
|
|
1229
|
+
data: IsUnknown<Data> extends true ? unknown : 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>;
|
|
1241
1230
|
};
|
|
1242
1231
|
/**
|
|
1243
1232
|
* Infer safe output from any `r$` instance
|
|
@@ -1258,7 +1247,6 @@ type ArrayHaveAtLeastOneRequiredField<TState extends Maybe<any[]>, TRule extends
|
|
|
1258
1247
|
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 RegleRuleDecl<any, any> ? FieldHaveRequiredRule<TRule> extends true ? TState : MaybeOutput<TState> : TState : TState;
|
|
1259
1248
|
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 RegleRuleDecl<any, any> ? FieldHaveRequiredRule<TRule> extends false ? false : true : false : false;
|
|
1260
1249
|
type SafeFieldProperty<TState, TRule extends RegleFormPropertyType<any, any> | undefined = never> = FieldHaveRequiredRule<TRule> extends true ? NonNullable<TState> : MaybeOutput<TState>;
|
|
1261
|
-
|
|
1262
1250
|
//#endregion
|
|
1263
1251
|
//#region ../../node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/utils.d.ts
|
|
1264
1252
|
/**
|
|
@@ -1299,7 +1287,7 @@ type IsAny<T> = [T] extends [Secret] ? Not<IsNever<T>> : false;
|
|
|
1299
1287
|
/**
|
|
1300
1288
|
* Determines if the given type is `unknown`.
|
|
1301
1289
|
*/
|
|
1302
|
-
type IsUnknown<T> = [unknown] extends [T] ? Not<IsAny<T>> : false;
|
|
1290
|
+
type IsUnknown$1<T> = [unknown] extends [T] ? Not<IsAny<T>> : false;
|
|
1303
1291
|
/**
|
|
1304
1292
|
* Determines if a type is either `never` or `any`.
|
|
1305
1293
|
*/
|
|
@@ -1369,13 +1357,13 @@ type MutuallyExtends<Left, Right> = And<[Extends<Left, Right>, Extends<Right, Le
|
|
|
1369
1357
|
* Convert a union to an intersection.
|
|
1370
1358
|
* `A | B | C` -\> `A & B & C`
|
|
1371
1359
|
*/
|
|
1372
|
-
type UnionToIntersection<Union> = (Union extends any ? (distributedUnion: Union) => void : never) extends ((mergedIntersection: infer Intersection) => void) ? Intersection : never;
|
|
1360
|
+
type UnionToIntersection$1<Union> = (Union extends any ? (distributedUnion: Union) => void : never) extends ((mergedIntersection: infer Intersection) => void) ? Intersection : never;
|
|
1373
1361
|
/**
|
|
1374
1362
|
* Get the last element of a union.
|
|
1375
1363
|
* First, converts to a union of `() => T` functions,
|
|
1376
1364
|
* then uses {@linkcode UnionToIntersection} to get the last one.
|
|
1377
1365
|
*/
|
|
1378
|
-
type LastOf<Union> = UnionToIntersection<Union extends any ? () => Union : never> extends (() => infer R) ? R : never;
|
|
1366
|
+
type LastOf<Union> = UnionToIntersection$1<Union extends any ? () => Union : never> extends (() => infer R) ? R : never;
|
|
1379
1367
|
/**
|
|
1380
1368
|
* Intermediate type for {@linkcode UnionToTuple} which pushes the
|
|
1381
1369
|
* "last" union member to the end of a tuple, and recursively prepends
|
|
@@ -1385,11 +1373,8 @@ type TuplifyUnion<Union, LastElement = LastOf<Union>> = IsNever<Union> extends t
|
|
|
1385
1373
|
/**
|
|
1386
1374
|
* Convert a union like `1 | 2 | 3` to a tuple like `[1, 2, 3]`.
|
|
1387
1375
|
*/
|
|
1388
|
-
type UnionToTuple<Union> = TuplifyUnion<Union>;
|
|
1389
|
-
type IsUnion<T> = Not<Extends<UnionToTuple<T>['length'], 1>>;
|
|
1390
|
-
|
|
1391
|
-
//#endregion
|
|
1392
|
-
//#region ../../node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/overloads.d.ts
|
|
1376
|
+
type UnionToTuple$1<Union> = TuplifyUnion<Union>;
|
|
1377
|
+
type IsUnion<T> = Not<Extends<UnionToTuple$1<T>['length'], 1>>;
|
|
1393
1378
|
/**
|
|
1394
1379
|
* A recursive version of `Pick` that selects properties from the left type that are present in the right type.
|
|
1395
1380
|
* The "leaf" types from `Left` are used - only the keys of `Right` are considered.
|
|
@@ -1401,6 +1386,8 @@ type IsUnion<T> = Not<Extends<UnionToTuple<T>['length'], 1>>;
|
|
|
1401
1386
|
* type Result = DeepPickMatchingProps<typeof user, {name: unknown; address: {city: unknown}}> // {name: string, address: {city: string}}
|
|
1402
1387
|
* ```
|
|
1403
1388
|
*/
|
|
1389
|
+
//#endregion
|
|
1390
|
+
//#region ../../node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/overloads.d.ts
|
|
1404
1391
|
/**
|
|
1405
1392
|
* The simple(ish) way to get overload info from a function
|
|
1406
1393
|
* {@linkcode FunctionType}. Recent versions of TypeScript will match any
|
|
@@ -1665,8 +1652,7 @@ type ConstructorOverloadParameters<ConstructorType> = ConstructorOverloadsUnion<
|
|
|
1665
1652
|
/**
|
|
1666
1653
|
* Calculates the number of overloads for a given function type.
|
|
1667
1654
|
*/
|
|
1668
|
-
type NumOverloads<FunctionType> = UnionToTuple<OverloadsInfoUnion<FunctionType>>['length'];
|
|
1669
|
-
|
|
1655
|
+
type NumOverloads<FunctionType> = UnionToTuple$1<OverloadsInfoUnion<FunctionType>>['length'];
|
|
1670
1656
|
//#endregion
|
|
1671
1657
|
//#region ../../node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/branding.d.ts
|
|
1672
1658
|
/**
|
|
@@ -1689,7 +1675,7 @@ type DeepBrand<T> = IsNever<T> extends true ? {
|
|
|
1689
1675
|
type: 'never';
|
|
1690
1676
|
} : IsAny<T> extends true ? {
|
|
1691
1677
|
type: 'any';
|
|
1692
|
-
} : IsUnknown<T> extends true ? {
|
|
1678
|
+
} : IsUnknown$1<T> extends true ? {
|
|
1693
1679
|
type: 'unknown';
|
|
1694
1680
|
} : T extends string | number | boolean | symbol | bigint | null | undefined | void ? {
|
|
1695
1681
|
type: 'primitive';
|
|
@@ -1704,7 +1690,7 @@ type DeepBrand<T> = IsNever<T> extends true ? {
|
|
|
1704
1690
|
return: DeepBrand<R>;
|
|
1705
1691
|
this: DeepBrand<ThisParameterType<T>>;
|
|
1706
1692
|
props: DeepBrand<Omit<T, keyof Function>>;
|
|
1707
|
-
} : UnionToTuple<OverloadsInfoUnion<T>> extends infer OverloadsTuple ? {
|
|
1693
|
+
} : UnionToTuple$1<OverloadsInfoUnion<T>> extends infer OverloadsTuple ? {
|
|
1708
1694
|
type: 'overloads';
|
|
1709
1695
|
overloads: { [K in keyof OverloadsTuple]: DeepBrand<OverloadsTuple[K]> };
|
|
1710
1696
|
} : never : T extends any[] ? {
|
|
@@ -1722,13 +1708,12 @@ type DeepBrand<T> = IsNever<T> extends true ? {
|
|
|
1722
1708
|
* Checks if two types are strictly equal using branding.
|
|
1723
1709
|
*/
|
|
1724
1710
|
type StrictEqualUsingBranding<Left, Right> = MutuallyExtends<DeepBrand<Left>, DeepBrand<Right>>;
|
|
1725
|
-
|
|
1726
1711
|
//#endregion
|
|
1727
1712
|
//#region ../../node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/messages.d.ts
|
|
1728
1713
|
/**
|
|
1729
1714
|
* Determines the printable type representation for a given type.
|
|
1730
1715
|
*/
|
|
1731
|
-
type PrintType<T> = IsUnknown<T> extends true ? 'unknown' : IsNever<T> extends true ? 'never' : IsAny<T> extends true ? never : boolean extends T ? 'boolean' : T extends boolean ? `literal boolean: ${T}` : string extends T ? 'string' : T extends string ? `literal string: ${T}` : number extends T ? 'number' : T extends number ? `literal number: ${T}` : bigint extends T ? 'bigint' : T extends bigint ? `literal bigint: ${T}` : T extends null ? 'null' : T extends undefined ? 'undefined' : T extends ((...args: any[]) => any) ? 'function' : '...';
|
|
1716
|
+
type PrintType<T> = IsUnknown$1<T> extends true ? 'unknown' : IsNever<T> extends true ? 'never' : IsAny<T> extends true ? never : boolean extends T ? 'boolean' : T extends boolean ? `literal boolean: ${T}` : string extends T ? 'string' : T extends string ? `literal string: ${T}` : number extends T ? 'number' : T extends number ? `literal number: ${T}` : bigint extends T ? 'bigint' : T extends bigint ? `literal bigint: ${T}` : T extends null ? 'null' : T extends undefined ? 'undefined' : T extends ((...args: any[]) => any) ? 'function' : '...';
|
|
1732
1717
|
/**
|
|
1733
1718
|
* Helper for showing end-user a hint why their type assertion is failing.
|
|
1734
1719
|
* This swaps "leaf" types with a literal message about what the actual and
|
|
@@ -1736,12 +1721,11 @@ type PrintType<T> = IsUnknown<T> extends true ? 'unknown' : IsNever<T> extends t
|
|
|
1736
1721
|
* otherwise `LeafTypeOf<Actual>` returns `never`, which extends everything 🤔
|
|
1737
1722
|
*/
|
|
1738
1723
|
type MismatchInfo<Actual, Expected> = And<[Extends<PrintType<Actual>, '...'>, Not<IsAny<Actual>>]> extends true ? And<[Extends<any[], Actual>, Extends<any[], Expected>]> extends true ? Array<MismatchInfo<Extract<Actual, any[]>[number], Extract<Expected, any[]>[number]>> : { [K in UsefulKeys<Actual> | UsefulKeys<Expected>]: MismatchInfo<K extends keyof Actual ? Actual[K] : never, K extends keyof Expected ? Expected[K] : never> } : StrictEqualUsingBranding<Actual, Expected> extends true ? Actual : `Expected: ${PrintType<Expected>}, Actual: ${PrintType<Exclude<Actual, Expected>>}`;
|
|
1739
|
-
|
|
1740
|
-
//#endregion
|
|
1741
|
-
//#region src/types/core/variants.types.d.ts
|
|
1742
1724
|
/**
|
|
1743
1725
|
* @internal
|
|
1744
1726
|
*/
|
|
1727
|
+
//#endregion
|
|
1728
|
+
//#region src/types/core/variants.types.d.ts
|
|
1745
1729
|
type NarrowVariant<TRoot extends {
|
|
1746
1730
|
[x: string]: unknown;
|
|
1747
1731
|
}, TKey extends keyof TRoot, TValue extends (LazyJoinDiscriminatedUnions<Exclude<TRoot[TKey], RegleCollectionStatus<any, any, any> | RegleStatus<any, any, any>>> extends {
|
|
@@ -1750,7 +1734,7 @@ type NarrowVariant<TRoot extends {
|
|
|
1750
1734
|
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'> & {
|
|
1751
1735
|
$fields: ProcessChildrenFields<TState, TRules, TShortcuts>[keyof ProcessChildrenFields<TState, TRules, TShortcuts>];
|
|
1752
1736
|
} : RegleStatus<TState, TRules, TShortcuts>;
|
|
1753
|
-
type ProcessChildrenFields<TState extends Record<string, any> | undefined, TRules extends ReglePartialRuleTree<NonNullable<TState>>, TShortcuts extends RegleShortcutDefinition = {}> = { [TIndex in keyof TupleToPlainObj<UnionToTuple
|
|
1737
|
+
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 : EmptyObject> 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 : EmptyObject, 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 : EmptyObject> 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 : EmptyObject, NonNullable<UnionToTuple<TState>[TIndexInt]>, TKey, TShortcuts> } : {} };
|
|
1754
1738
|
type FindCorrespondingVariant<TState extends Record<string, any>, TRules extends any[]> = TRules extends [infer F, ...infer R] ? F extends ReglePartialRuleTree<TState> ? [F] : FindCorrespondingVariant<TState, R> : [];
|
|
1755
1739
|
type PossibleLiteralTypes<T extends Record<string, any>, TKey extends keyof T> = unknown extends T[TKey] ? {
|
|
1756
1740
|
[x: string]: { [K in TKey]-?: Omit<RegleRuleDecl<any, Partial<AllRulesDeclarations>>, 'literal'> & {
|
|
@@ -1761,7 +1745,6 @@ type PossibleLiteralTypes<T extends Record<string, any>, TKey extends keyof T> =
|
|
|
1761
1745
|
} } };
|
|
1762
1746
|
type RequiredForm<T extends Record<string, any>, TKey extends keyof T> = Omit<ReglePartialRuleTree<T>, TKey> & PossibleLiteralTypes<T, TKey>[keyof PossibleLiteralTypes<T, TKey>];
|
|
1763
1747
|
type VariantTuple<T extends Record<string, any>, TKey extends keyof T> = [RequiredForm<T, TKey>, ...RequiredForm<T, TKey>[]];
|
|
1764
|
-
|
|
1765
1748
|
//#endregion
|
|
1766
1749
|
//#region src/core/useRegle/useRegle.d.ts
|
|
1767
1750
|
type useRegleFnOptions<TState extends Record<string, any> | MaybeInput<PrimitiveTypes>, TRules extends ReglePartialRuleTree<Unwrap<TState extends Record<string, any> ? TState : {}>, Partial<AllRulesDeclarations>>, TAdditionalOptions extends Record<string, any>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]>> = TState extends MaybeInput<PrimitiveTypes> ? Partial<DeepMaybeRef<RegleBehaviourOptions>> & TAdditionalOptions : Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<JoinDiscriminatedUnions<TState extends Record<string, any> ? Unwrap<TState> : {}>, TState extends Record<string, any> ? TRules : {}, TValidationGroups> & TAdditionalOptions;
|
|
@@ -1793,7 +1776,6 @@ interface useRegleFn<TCustomRules extends Partial<AllRulesDeclarations>, TShortc
|
|
|
1793
1776
|
* Docs: {@link https://reglejs.dev/core-concepts/}
|
|
1794
1777
|
*/
|
|
1795
1778
|
declare const useRegle: useRegleFn<Partial<AllRulesDeclarations>, RegleShortcutDefinition<any>, {}, {}>;
|
|
1796
|
-
|
|
1797
1779
|
//#endregion
|
|
1798
1780
|
//#region src/core/useRegle/inferRules.d.ts
|
|
1799
1781
|
interface inferRulesFn<TCustomRules extends Partial<AllRulesDeclarations>> {
|
|
@@ -1807,7 +1789,6 @@ interface inferRulesFn<TCustomRules extends Partial<AllRulesDeclarations>> {
|
|
|
1807
1789
|
* @param rules - Your rule tree
|
|
1808
1790
|
*/
|
|
1809
1791
|
declare const inferRules: inferRulesFn<Partial<AllRulesDeclarations>>;
|
|
1810
|
-
|
|
1811
1792
|
//#endregion
|
|
1812
1793
|
//#region src/core/useRegle/root/useRootStorage.d.ts
|
|
1813
1794
|
declare function useRootStorage({
|
|
@@ -1833,7 +1814,6 @@ declare function useRootStorage({
|
|
|
1833
1814
|
}): {
|
|
1834
1815
|
regle: $InternalRegleStatusType | undefined;
|
|
1835
1816
|
};
|
|
1836
|
-
|
|
1837
1817
|
//#endregion
|
|
1838
1818
|
//#region src/core/useRegle/useErrors.d.ts
|
|
1839
1819
|
/**
|
|
@@ -1850,7 +1830,6 @@ declare function flatErrors(errors: $InternalRegleErrors, options: {
|
|
|
1850
1830
|
declare function flatErrors(errors: $InternalRegleErrors, options?: {
|
|
1851
1831
|
includePath?: false;
|
|
1852
1832
|
}): string[];
|
|
1853
|
-
|
|
1854
1833
|
//#endregion
|
|
1855
1834
|
//#region src/types/utils/props.types.d.ts
|
|
1856
1835
|
/**
|
|
@@ -1860,7 +1839,7 @@ type InferRegleRoot<T extends (...args: any[]) => SuperCompatibleRegle> = T exte
|
|
|
1860
1839
|
/**
|
|
1861
1840
|
* Infer custom rules declared in a global configuration
|
|
1862
1841
|
*/
|
|
1863
|
-
type InferRegleRules<T extends useRegleFn<any, any>> = T extends useRegleFn<infer U, any> ? UnwrapRuleTree<Partial<
|
|
1842
|
+
type InferRegleRules<T extends useRegleFn<any, any>> = T extends useRegleFn<infer U, any> ? UnwrapRuleTree<Partial<DefaultValidators>> & UnwrapRuleTree<Partial<U>> : {};
|
|
1864
1843
|
/**
|
|
1865
1844
|
* Infer custom shortcuts declared in a global configuration
|
|
1866
1845
|
*/
|
|
@@ -1873,20 +1852,11 @@ type RegleEnforceRequiredRules<TRules extends keyof DefaultValidators> = Omit<Pa
|
|
|
1873
1852
|
* Extract a set of custom rules from a global configuration and setting them as required
|
|
1874
1853
|
|
|
1875
1854
|
*/
|
|
1876
|
-
type RegleEnforceCustomRequiredRules<T extends
|
|
1855
|
+
type RegleEnforceCustomRequiredRules<T extends useRegleFn<any, any>, TRules extends keyof InferRegleRules<T>> = Omit<Partial<DefaultValidatorsTree>, TRules> & { [K in TRules]-?: T extends useRegleFn<any, any> ? K extends keyof InferRegleRules<T> ? NonNullable<UnwrapRuleWithParams<InferRegleRules<T>[K]>> : never : K extends keyof T ? NonNullable<T[K]> : never };
|
|
1877
1856
|
/**
|
|
1878
1857
|
* Extract custom rules and custom shortcuts and apply them to a RegleFieldStatus type
|
|
1879
1858
|
*/
|
|
1880
|
-
type RegleCustomFieldStatus<T extends useRegleFn<any, any>, TState extends unknown = any, TRules extends
|
|
1881
|
-
/**
|
|
1882
|
-
* Extract custom rules and custom shortcuts and apply them to a RegleFieldStatus type
|
|
1883
|
-
*/
|
|
1884
|
-
type RegleCustomStatus<T extends useRegleFn<any, any>, TState extends Record<string, any> | undefined = Record<string, any>, TRules extends ReglePartialRuleTree<NonNullable<TState>> = InferRegleRules<T>> = RegleStatus<TState, TRules, InferRegleShortcuts<T>>;
|
|
1885
|
-
/**
|
|
1886
|
-
* Extract custom rules and custom shortcuts and apply them to a RegleFieldStatus type
|
|
1887
|
-
*/
|
|
1888
|
-
type RegleCustomCollectionStatus<T extends useRegleFn<any, any>, TState extends any[] = any[], TRules extends ReglePartialRuleTree<ArrayElement<TState>> = InferRegleRules<T>> = RegleCollectionStatus<TState, TRules, InferRegleShortcuts<T>>;
|
|
1889
|
-
|
|
1859
|
+
type RegleCustomFieldStatus<T extends useRegleFn<any, any>, TState extends unknown = any, TRules extends keyof InferRegleRules<T> = never> = RegleFieldStatus<TState, [TRules] extends [never] ? Partial<InferRegleRules<T>> : RegleEnforceCustomRequiredRules<T, TRules>, InferRegleShortcuts<T>>;
|
|
1890
1860
|
//#endregion
|
|
1891
1861
|
//#region src/types/utils/object.types.d.ts
|
|
1892
1862
|
type RemoveCommonKey<T extends readonly any[], K extends PropertyKey> = T extends [infer F, ...infer R] ? [Prettify<Omit<F, K>>, ...RemoveCommonKey<R, K>] : [];
|
|
@@ -1914,12 +1884,12 @@ type RetrieveUnionUnknownKeysOf<T extends readonly any[]> = T extends [infer F,
|
|
|
1914
1884
|
/**
|
|
1915
1885
|
* Transforms a union and apply undefined values to non-present keys to support intersection
|
|
1916
1886
|
*/
|
|
1917
|
-
type NormalizeUnion<TUnion> = RetrieveUnionUnknownValues<NonNullable<UnionToTuple
|
|
1887
|
+
type NormalizeUnion<TUnion> = RetrieveUnionUnknownValues<NonNullable<UnionToTuple<TUnion>>, RetrieveUnionUnknownKeysOf<NonNullable<UnionToTuple<TUnion>>>[number]>[number];
|
|
1918
1888
|
/**
|
|
1919
1889
|
* Combine all members of a union type, merging types for each key, and keeping loose types
|
|
1920
1890
|
*/
|
|
1921
|
-
type JoinDiscriminatedUnions<TUnion extends unknown> = isRecordLiteral<TUnion> extends true ? Prettify<Partial<UnionToIntersection
|
|
1922
|
-
type LazyJoinDiscriminatedUnions<TUnion extends unknown> = isRecordLiteral<TUnion> extends true ? Prettify<Partial<UnionToIntersection
|
|
1891
|
+
type JoinDiscriminatedUnions<TUnion extends unknown> = isRecordLiteral<TUnion> extends true ? Prettify<Partial<UnionToIntersection<RemoveCommonKey<UnionToTuple<NonNullable<TUnion>>, keyof NormalizeUnion<NonNullable<TUnion>>>[number]>> & Pick<NormalizeUnion<NonNullable<TUnion>>, keyof NormalizeUnion<NonNullable<TUnion>>>> : TUnion;
|
|
1892
|
+
type LazyJoinDiscriminatedUnions<TUnion extends unknown> = isRecordLiteral<TUnion> extends true ? Prettify<Partial<UnionToIntersection<RemoveCommonKey<UnionToTuple<TUnion>, keyof NonNullable<TUnion>>[number]>> & Pick<NonNullable<TUnion>, keyof NonNullable<TUnion>>> : TUnion;
|
|
1923
1893
|
type EnumLike = {
|
|
1924
1894
|
[k: string]: string | number;
|
|
1925
1895
|
[nu: number]: string;
|
|
@@ -1927,15 +1897,13 @@ type EnumLike = {
|
|
|
1927
1897
|
type enumType<T extends Record<string, unknown>> = T[keyof T];
|
|
1928
1898
|
type UnwrapMaybeRef<T extends MaybeRef<any> | DeepReactiveState<any>> = T extends Ref<any> ? UnwrapRef<T> : UnwrapNestedRefs<T>;
|
|
1929
1899
|
type TupleToPlainObj<T> = { [I in keyof T & `${number}`]: T[I] };
|
|
1930
|
-
|
|
1931
1900
|
//#endregion
|
|
1932
1901
|
//#region src/types/utils/mismatch.types.d.ts
|
|
1933
1902
|
type isDeepExact<TRules, TTree> = { [K in keyof TRules]-?: CheckDeepExact<NonNullable<TRules[K]>, K extends keyof JoinDiscriminatedUnions<TTree> ? NonNullable<JoinDiscriminatedUnions<TTree>[K]> : never> }[keyof TRules] extends true ? true : false;
|
|
1934
1903
|
type CheckDeepExact<TRules, TTree> = [TTree] extends [never] ? false : TRules extends RegleCollectionRuleDecl ? TTree extends Array<any> ? isDeepExact<NonNullable<TRules['$each']>, JoinDiscriminatedUnions<NonNullable<ArrayElement<TTree>>>> : TRules extends RegleRuleDecl ? true : TRules extends ReglePartialRuleTree<any> ? isDeepExact<TRules, TTree> : false : TRules extends RegleRuleDecl ? true : TRules extends ReglePartialRuleTree<any> ? isDeepExact<TRules, TTree> : false;
|
|
1935
|
-
|
|
1936
1904
|
//#endregion
|
|
1937
1905
|
//#region src/types/utils/infer.types.d.ts
|
|
1938
|
-
type InferInput<TRules extends MaybeRef<ReglePartialRuleTree<Record<string, any>, any>> | ((state: any) => ReglePartialRuleTree<Record<string, any>, any>), TMarkMaybe extends boolean = true> = IsUnion$1<UnwrapSimple<TRules>> extends true ? InferTupleUnionInput<UnionToTuple
|
|
1906
|
+
type InferInput<TRules extends MaybeRef<ReglePartialRuleTree<Record<string, any>, any>> | ((state: any) => ReglePartialRuleTree<Record<string, any>, any>), TMarkMaybe extends boolean = true> = IsUnion$1<UnwrapSimple<TRules>> extends true ? InferTupleUnionInput<UnionToTuple<UnwrapSimple<TRules>>>[number] : TMarkMaybe extends true ? Prettify<{ [K in keyof UnwrapSimple<TRules>]?: ProcessInputChildren<UnwrapSimple<TRules>[K], TMarkMaybe> }> : Prettify<{ [K in keyof UnwrapSimple<TRules>]: ProcessInputChildren<UnwrapSimple<TRules>[K], TMarkMaybe> }>;
|
|
1939
1907
|
type ProcessInputChildren<TRule extends unknown, TMarkMaybe extends boolean> = TRule extends {
|
|
1940
1908
|
$each: RegleCollectionEachRules<any, any>;
|
|
1941
1909
|
} ? ExtractFromGetter<TRule['$each']> extends ReglePartialRuleTree<any, any> ? InferInput<ExtractFromGetter<TRule['$each']>, TMarkMaybe>[] : any[] : TRule extends RegleRuleDecl<any, any> ? [ExtractTypeFromRules<TRule>] extends [never] ? unknown : ExtractTypeFromRules<TRule> : TRule extends ReglePartialRuleTree<any, any> ? InferInput<TRule, TMarkMaybe> : string;
|
|
@@ -1945,7 +1913,6 @@ type ExtractTypeFromRules<TRules extends RegleRuleDecl<any, any>> = FilterRulesW
|
|
|
1945
1913
|
type FilterRulesWithInput<TRules extends RegleRuleDecl<any, any>> = { [K in keyof TRules as TRules[K] extends RegleRuleDefinition<any, any, any, any, infer Input> ? unknown extends Input ? never : K : never]: TRules[K] extends RegleRuleDefinition<any, any, any, any, infer Input> ? Input : unknown };
|
|
1946
1914
|
type FilterRulesWithSingleType<TRules extends RegleRuleDecl<any, any>> = { [K in keyof TRules as TRules[K] extends RegleRuleDefinition<any, any, any, any, infer Input> ? unknown extends Input ? never : IsUnion$1<NonNullable<Input>> extends true ? never : K : never]: TRules[K] extends RegleRuleDefinition<any, any, any, any, infer Input> ? IsUnion$1<NonNullable<Input>> extends true ? unknown : Input : unknown };
|
|
1947
1915
|
type InferTupleUnionInput<T extends any[]> = T extends [infer F extends ReglePartialRuleTree, ...infer R] ? [InferInput<F, true>, ...InferTupleUnionInput<R>] : [];
|
|
1948
|
-
|
|
1949
1916
|
//#endregion
|
|
1950
1917
|
//#region src/types/rules/rule.params.types.d.ts
|
|
1951
1918
|
type CreateFn<T extends any[]> = (...args: T) => any;
|
|
@@ -1956,7 +1923,6 @@ type CreateFn<T extends any[]> = (...args: T) => any;
|
|
|
1956
1923
|
*/
|
|
1957
1924
|
type RegleUniversalParams<T extends any[] = [], F = CreateFn<T>> = [T] extends [[]] ? [] : Parameters<F extends ((...args: infer Args) => any) ? (...args: { [K in keyof Args]: MaybeRefOrGetter<Maybe<Args[K]>> }) => any : never>;
|
|
1958
1925
|
type UnwrapRegleUniversalParams<T extends MaybeRefOrGetter[] = [], F = CreateFn<T>> = [T] extends [[]] ? [] : Parameters<F extends ((...args: infer Args) => any) ? (...args: { [K in keyof Args]: Args[K] extends MaybeRefOrGetter<Maybe<infer U>> ? U : Args[K] }) => any : never>;
|
|
1959
|
-
|
|
1960
1926
|
//#endregion
|
|
1961
1927
|
//#region src/types/rules/rule.internal.types.d.ts
|
|
1962
1928
|
/**
|
|
@@ -1979,7 +1945,6 @@ declare const InternalRuleType: {
|
|
|
1979
1945
|
readonly Async: "__async";
|
|
1980
1946
|
};
|
|
1981
1947
|
type InternalRuleType = enumType<typeof InternalRuleType>;
|
|
1982
|
-
|
|
1983
1948
|
//#endregion
|
|
1984
1949
|
//#region src/types/rules/rule.definition.type.d.ts
|
|
1985
1950
|
type IsLiteral<T> = string extends T ? false : true;
|
|
@@ -2068,7 +2033,6 @@ type RegleCollectionRuleDefinition<TValue = any[], TCustomRules extends Partial<
|
|
|
2068
2033
|
}) | ({
|
|
2069
2034
|
$each: MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue>>, TCustomRules>, ArrayElement<TValue>>;
|
|
2070
2035
|
} & CollectionRegleBehaviourOptions);
|
|
2071
|
-
|
|
2072
2036
|
//#endregion
|
|
2073
2037
|
//#region src/types/rules/rule.init.types.d.ts
|
|
2074
2038
|
type RegleInitPropertyGetter<TValue, TReturn, TParams extends [...any[]], TMetadata extends RegleRuleMetadataDefinition> = TReturn | ((metadata: RegleRuleMetadataConsumer<TValue, TParams, TMetadata>) => TReturn);
|
|
@@ -2104,7 +2068,6 @@ type RegleRuleTypeReturn<TValue, TParams extends [...any[]]> = {
|
|
|
2104
2068
|
value: TValue;
|
|
2105
2069
|
params: [...TParams];
|
|
2106
2070
|
};
|
|
2107
|
-
|
|
2108
2071
|
//#endregion
|
|
2109
2072
|
//#region src/core/defaultValidators.d.ts
|
|
2110
2073
|
interface CommonComparisonOptions {
|
|
@@ -2163,14 +2126,13 @@ type DefaultValidators = {
|
|
|
2163
2126
|
numeric: RegleRuleDefinition<string | number, [], false, boolean, string | number>;
|
|
2164
2127
|
oneOf: RegleRuleDefinition<string | number, [options: (string | number)[]], false, boolean, string | number>;
|
|
2165
2128
|
regex: RegleRuleWithParamsDefinition<string, [regexp: RegExp], false, boolean>;
|
|
2166
|
-
required: RegleRuleDefinition<unknown, []>;
|
|
2129
|
+
required: RegleRuleDefinition<unknown, [], false, boolean, unknown>;
|
|
2167
2130
|
sameAs: RegleRuleWithParamsDefinition<unknown, [target: unknown, otherName?: string], false, boolean>;
|
|
2168
2131
|
string: RegleRuleDefinition<unknown, [], false, boolean, any, unknown>;
|
|
2169
2132
|
type: RegleRuleDefinition<unknown, [], false, boolean, unknown, unknown>;
|
|
2170
2133
|
startsWith: RegleRuleWithParamsDefinition<string, [part: Maybe<string>], false, boolean>;
|
|
2171
2134
|
url: RegleRuleDefinition<string, [], false, boolean, string>;
|
|
2172
2135
|
};
|
|
2173
|
-
|
|
2174
2136
|
//#endregion
|
|
2175
2137
|
//#region src/types/rules/rule.custom.types.d.ts
|
|
2176
2138
|
type CustomRulesDeclarationTree = {
|
|
@@ -2178,7 +2140,6 @@ type CustomRulesDeclarationTree = {
|
|
|
2178
2140
|
};
|
|
2179
2141
|
type DefaultValidatorsTree = { [K in keyof DefaultValidators]: RegleRuleRawInput<any, any[], boolean, any> | undefined };
|
|
2180
2142
|
type AllRulesDeclarations = CustomRulesDeclarationTree & DefaultValidatorsTree;
|
|
2181
|
-
|
|
2182
2143
|
//#endregion
|
|
2183
2144
|
//#region src/types/rules/rule.declaration.types.d.ts
|
|
2184
2145
|
/**
|
|
@@ -2261,33 +2222,6 @@ type InlineRuleDeclaration<TValue extends any = any, TParams extends any[] = any
|
|
|
2261
2222
|
* Regroup inline and registered rules
|
|
2262
2223
|
* */
|
|
2263
2224
|
type FormRuleDeclaration<TValue extends any = unknown, TParams extends any[] = any[], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition> = RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>, TMetadata extends RegleRuleMetadataDefinition = (TReturn extends Promise<infer M> ? M : TReturn), TAsync extends boolean = boolean> = InlineRuleDeclaration<TValue, TParams, TReturn> | RegleRuleDefinition<TValue, TParams, TAsync, TMetadata> | RegleRuleWithParamsDefinitionInput<TValue, [param?: any], TAsync, TMetadata> | RegleRuleWithParamsDefinitionInput<TValue, [param?: any, ...any[]], TAsync, TMetadata>;
|
|
2264
|
-
|
|
2265
|
-
//#endregion
|
|
2266
|
-
//#region src/types/rules/rule.errors.types.d.ts
|
|
2267
|
-
type RegleErrorTree<TState = MaybeRef<Record<string, any> | any[]>> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>]: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>[K], false> };
|
|
2268
|
-
type RegleExternalErrorTree<TState = MaybeRef<Record<string, any> | any[]>> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>]?: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>[K], true> };
|
|
2269
|
-
type RegleValidationErrors<TState extends Record<string, any> | any[] | unknown = never, TExternal extends boolean = false> = NonNullable<TState> extends Array<infer U extends Record<string, any>> ? ExtendOnlyRealRecord<U> extends true ? TExternal extends false ? RegleCollectionErrors<U> : RegleExternalCollectionErrors<U> : string[] : NonNullable<TState> extends Date | File ? string[] : NonNullable<TState> extends Record<string, any> ? TExternal extends false ? RegleErrorTree<TState> : RegleExternalErrorTree<TState> : string[];
|
|
2270
|
-
type RegleCollectionErrors<TState extends Record<string, any>> = {
|
|
2271
|
-
readonly $self: string[];
|
|
2272
|
-
readonly $each: RegleValidationErrors<TState, false>[];
|
|
2273
|
-
};
|
|
2274
|
-
type RegleExternalCollectionErrors<TState extends Record<string, any>> = {
|
|
2275
|
-
readonly $self?: string[];
|
|
2276
|
-
readonly $each?: RegleValidationErrors<TState, true>[];
|
|
2277
|
-
};
|
|
2278
|
-
/** @internal */
|
|
2279
|
-
type $InternalRegleCollectionErrors = {
|
|
2280
|
-
readonly $self?: string[];
|
|
2281
|
-
readonly $each?: $InternalRegleErrors[];
|
|
2282
|
-
};
|
|
2283
|
-
type $InternalRegleErrorTree = {
|
|
2284
|
-
[x: string]: $InternalRegleErrors;
|
|
2285
|
-
};
|
|
2286
|
-
/**
|
|
2287
|
-
* @internal
|
|
2288
|
-
*/
|
|
2289
|
-
type $InternalRegleErrors = $InternalRegleCollectionErrors | string[] | $InternalRegleErrorTree;
|
|
2290
|
-
|
|
2291
2225
|
//#endregion
|
|
2292
2226
|
//#region src/types/rules/rule.status.types.d.ts
|
|
2293
2227
|
/**
|
|
@@ -2339,6 +2273,13 @@ type InferRegleStatusType<TRule extends RegleCollectionRuleDecl | RegleRuleDecl
|
|
|
2339
2273
|
* @reference {@link InferRegleStatusType}
|
|
2340
2274
|
*/
|
|
2341
2275
|
type $InternalRegleStatusType = $InternalRegleCollectionStatus | $InternalRegleStatus | $InternalRegleFieldStatus;
|
|
2276
|
+
interface RegleFieldIssue {
|
|
2277
|
+
$property: string;
|
|
2278
|
+
$rule: string;
|
|
2279
|
+
$type?: string;
|
|
2280
|
+
$message: string;
|
|
2281
|
+
[x: string]: unknown;
|
|
2282
|
+
}
|
|
2342
2283
|
/**
|
|
2343
2284
|
* @public
|
|
2344
2285
|
*/
|
|
@@ -2353,6 +2294,10 @@ type RegleFieldStatus<TState extends any = any, TRules extends RegleFormProperty
|
|
|
2353
2294
|
readonly $errors: string[];
|
|
2354
2295
|
/** Collection of all the error messages, collected for all children properties and nested forms. */
|
|
2355
2296
|
readonly $silentErrors: string[];
|
|
2297
|
+
/**
|
|
2298
|
+
* Collect all metadata of validators, including the error message
|
|
2299
|
+
*/
|
|
2300
|
+
readonly $issues: RegleFieldIssue[];
|
|
2356
2301
|
/** Stores external errors of the current field */
|
|
2357
2302
|
readonly $externalErrors: string[];
|
|
2358
2303
|
/** Stores active tooltips messages of the current field */
|
|
@@ -2366,7 +2311,7 @@ type RegleFieldStatus<TState extends any = any, TRules extends RegleFormProperty
|
|
|
2366
2311
|
/** This is reactive tree containing all the declared rules of your field. To know more about the rule properties check the rules properties section */
|
|
2367
2312
|
readonly $rules: IsEmptyObject<TRules> extends true ? {
|
|
2368
2313
|
readonly [x: string]: RegleRuleStatus<TState, any[], any>;
|
|
2369
|
-
} : { 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 :
|
|
2314
|
+
} : { 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> };
|
|
2370
2315
|
} & ([TShortcuts['fields']] extends [never] ? {} : { [K in keyof TShortcuts['fields']]: ReturnType<NonNullable<TShortcuts['fields']>[K]> });
|
|
2371
2316
|
/**
|
|
2372
2317
|
* @internal
|
|
@@ -2381,6 +2326,7 @@ interface $InternalRegleFieldStatus extends $InternalRegleCommonStatus {
|
|
|
2381
2326
|
readonly $tooltips: string[];
|
|
2382
2327
|
readonly $inactive: boolean;
|
|
2383
2328
|
readonly $silentErrors: string[];
|
|
2329
|
+
readonly $issues: RegleFieldIssue[];
|
|
2384
2330
|
$extractDirtyFields: (filterNullishValues?: boolean) => any;
|
|
2385
2331
|
$validate: () => Promise<$InternalRegleResult>;
|
|
2386
2332
|
}
|
|
@@ -2467,7 +2413,7 @@ type RegleRuleStatus<TValue = any, TParams extends any[] = any[], TMetadata exte
|
|
|
2467
2413
|
/** Reset the $valid, $metadata and $pending states */
|
|
2468
2414
|
$reset(): void;
|
|
2469
2415
|
/** Returns the original rule validator function. */
|
|
2470
|
-
$validator: ((value: IsUnknown
|
|
2416
|
+
$validator: ((value: IsUnknown<TValue> extends true ? any : MaybeInput<TValue>, ...args: any[]) => RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>) & ((value: IsUnknown<TValue> extends true ? any : TValue, ...args: [TParams] extends [never[]] ? [] : [unknown[]] extends [TParams] ? any[] : TParams) => RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>);
|
|
2471
2417
|
} & ([TParams] extends [never[]] ? {} : [unknown[]] extends [TParams] ? {
|
|
2472
2418
|
readonly $params?: any[];
|
|
2473
2419
|
} : {
|
|
@@ -2478,7 +2424,7 @@ type RegleRuleStatus<TValue = any, TParams extends any[] = any[], TMetadata exte
|
|
|
2478
2424
|
* @reference {@link RegleRuleStatus}
|
|
2479
2425
|
*/
|
|
2480
2426
|
interface $InternalRegleRuleStatus {
|
|
2481
|
-
$type
|
|
2427
|
+
$type?: string;
|
|
2482
2428
|
$message: string | string[];
|
|
2483
2429
|
$tooltip: string | string[];
|
|
2484
2430
|
$active: boolean;
|
|
@@ -2538,7 +2484,29 @@ interface $InternalRegleCollectionStatus extends Omit<$InternalRegleStatus, '$fi
|
|
|
2538
2484
|
$extractDirtyFields: (filterNullishValues?: boolean) => any[];
|
|
2539
2485
|
$validate: () => Promise<$InternalRegleResult>;
|
|
2540
2486
|
}
|
|
2541
|
-
|
|
2487
|
+
//#endregion
|
|
2488
|
+
//#region src/types/rules/rule.errors.types.d.ts
|
|
2489
|
+
type RegleErrorTree<TState = MaybeRef<Record<string, any> | any[]>> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>]: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>[K], false> };
|
|
2490
|
+
type RegleExternalErrorTree<TState = MaybeRef<Record<string, any> | any[]>> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>]?: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>[K], true> };
|
|
2491
|
+
type RegleExternalSchemaErrorTree<TState = MaybeRef<Record<string, any> | any[]>> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>]?: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>[K], true, true> };
|
|
2492
|
+
type RegleValidationErrors<TState extends Record<string, any> | any[] | unknown = never, TExternal extends boolean = false, TIssue extends boolean = false> = NonNullable<TState> extends Array<infer U extends Record<string, any>> ? ExtendOnlyRealRecord<U> extends true ? TExternal extends false ? RegleCollectionErrors<U> : RegleExternalCollectionErrors<U> : TIssue extends true ? RegleFieldIssue[] : string[] : NonNullable<TState> extends Date | File ? TIssue extends true ? RegleFieldIssue[] : string[] : NonNullable<TState> extends Record<string, any> ? TExternal extends false ? RegleErrorTree<TState> : RegleExternalErrorTree<TState> : TIssue extends true ? RegleFieldIssue[] : string[];
|
|
2493
|
+
type RegleCollectionErrors<TState extends Record<string, any>, TIssue extends boolean = false> = {
|
|
2494
|
+
readonly $self: string[];
|
|
2495
|
+
readonly $each: RegleValidationErrors<TState, false, TIssue>[];
|
|
2496
|
+
};
|
|
2497
|
+
type RegleExternalCollectionErrors<TState extends Record<string, any>, TIssue extends boolean = false> = {
|
|
2498
|
+
readonly $self?: string[];
|
|
2499
|
+
readonly $each?: RegleValidationErrors<TState, true, TIssue>[];
|
|
2500
|
+
};
|
|
2501
|
+
/** @internal */
|
|
2502
|
+
type $InternalRegleCollectionErrors = {
|
|
2503
|
+
readonly $self?: string[];
|
|
2504
|
+
readonly $each?: $InternalRegleErrors[];
|
|
2505
|
+
};
|
|
2506
|
+
type $InternalRegleErrorTree = {
|
|
2507
|
+
[x: string]: $InternalRegleErrors;
|
|
2508
|
+
};
|
|
2509
|
+
type $InternalRegleErrors = $InternalRegleCollectionErrors | string[] | $InternalRegleErrorTree;
|
|
2542
2510
|
//#endregion
|
|
2543
2511
|
//#region src/types/rules/compatibility.rules.d.ts
|
|
2544
2512
|
interface SuperCompatibleRegle {
|
|
@@ -2586,7 +2554,6 @@ interface SuperCompatibleRegleCollectionStatus extends Omit<SuperCompatibleRegle
|
|
|
2586
2554
|
$validate?: () => Promise<SuperCompatibleRegleResult>;
|
|
2587
2555
|
}
|
|
2588
2556
|
type SuperCompatibleRegleCollectionErrors = $InternalRegleCollectionErrors;
|
|
2589
|
-
|
|
2590
2557
|
//#endregion
|
|
2591
2558
|
//#region src/core/createRule/createRule.d.ts
|
|
2592
2559
|
/**
|
|
@@ -2621,7 +2588,6 @@ type SuperCompatibleRegleCollectionErrors = $InternalRegleCollectionErrors;
|
|
|
2621
2588
|
* Docs: {@link https://reglejs.dev/core-concepts/rules/reusable-rules}
|
|
2622
2589
|
*/
|
|
2623
2590
|
declare function createRule<TValue extends any, TParams extends any[], TReturn extends RegleRuleMetadataDefinition | Promise<RegleRuleMetadataDefinition>, TMetadata extends RegleRuleMetadataDefinition = (TReturn extends Promise<infer M> ? M : TReturn), TAsync extends boolean = (TReturn extends Promise<any> ? true : false)>(definition: RegleRuleInit<TValue, TParams, TReturn, TMetadata, TAsync>): InferRegleRule<TValue, TParams, TAsync, TMetadata>;
|
|
2624
|
-
|
|
2625
2591
|
//#endregion
|
|
2626
2592
|
//#region src/core/createRule/unwrapRuleParameters.d.ts
|
|
2627
2593
|
/**
|
|
@@ -2629,14 +2595,13 @@ declare function createRule<TValue extends any, TParams extends any[], TReturn e
|
|
|
2629
2595
|
* Removing Ref and executing function to return the unwrapped value
|
|
2630
2596
|
*/
|
|
2631
2597
|
declare function unwrapRuleParameters<TParams extends any[]>(params: MaybeRefOrGetter[]): TParams;
|
|
2632
|
-
|
|
2633
|
-
//#endregion
|
|
2634
|
-
//#region src/core/defineRegleConfig.d.ts
|
|
2635
2598
|
/**
|
|
2636
2599
|
* Returns a clean list of parameters
|
|
2637
2600
|
* Removing Ref and executing function to return the unwrapped value
|
|
2638
2601
|
*/
|
|
2639
2602
|
|
|
2603
|
+
//#endregion
|
|
2604
|
+
//#region src/core/defineRegleConfig.d.ts
|
|
2640
2605
|
/**
|
|
2641
2606
|
* Define a global regle configuration, where you can:
|
|
2642
2607
|
* - Customize built-in rules messages
|
|
@@ -2681,7 +2646,6 @@ declare function extendRegleConfig<TRootCustomRules extends Partial<AllRulesDecl
|
|
|
2681
2646
|
useRegle: useRegleFn<Merge<TRootCustomRules, TCustomRules>, TRootShortcuts & TShortcuts>;
|
|
2682
2647
|
inferRules: inferRulesFn<Merge<TRootCustomRules, TCustomRules>>;
|
|
2683
2648
|
};
|
|
2684
|
-
|
|
2685
2649
|
//#endregion
|
|
2686
2650
|
//#region src/core/mergeRegles.d.ts
|
|
2687
2651
|
type MergedRegles<TRegles extends Record<string, SuperCompatibleRegleRoot>, TValue = { [K in keyof TRegles]: TRegles[K]['$value'] }> = Omit<RegleCommonStatus, '$value' | '$silentValue' | '$errors' | '$silentErrors' | '$name' | '$unwatch' | '$watch'> & {
|
|
@@ -2729,7 +2693,6 @@ type MergedReglesResult<TRegles extends Record<string, SuperCompatibleRegleRoot>
|
|
|
2729
2693
|
}>['data'] };
|
|
2730
2694
|
};
|
|
2731
2695
|
declare function mergeRegles<TRegles extends Record<string, SuperCompatibleRegleRoot>, TScoped extends boolean = false>(regles: TRegles, _scoped?: TScoped): TScoped extends false ? MergedRegles<TRegles> : MergedScopedRegles;
|
|
2732
|
-
|
|
2733
2696
|
//#endregion
|
|
2734
2697
|
//#region src/core/createScopedUseRegle/useCollectScope.d.ts
|
|
2735
2698
|
type useCollectScopeFn<TNamedScoped extends boolean = false> = TNamedScoped extends true ? <const TValue extends Record<string, Record<string, any>>>(namespace?: MaybeRefOrGetter<string>) => {
|
|
@@ -2737,7 +2700,6 @@ type useCollectScopeFn<TNamedScoped extends boolean = false> = TNamedScoped exte
|
|
|
2737
2700
|
} : <TValue extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?: MaybeRefOrGetter<string>) => {
|
|
2738
2701
|
r$: MergedScopedRegles<TValue>;
|
|
2739
2702
|
};
|
|
2740
|
-
|
|
2741
2703
|
//#endregion
|
|
2742
2704
|
//#region src/core/createScopedUseRegle/useScopedRegle.d.ts
|
|
2743
2705
|
type UseScopedRegleOptions<TAsRecord extends boolean> = {
|
|
@@ -2745,7 +2707,6 @@ type UseScopedRegleOptions<TAsRecord extends boolean> = {
|
|
|
2745
2707
|
} & (TAsRecord extends true ? {
|
|
2746
2708
|
scopeKey: string;
|
|
2747
2709
|
} : {});
|
|
2748
|
-
|
|
2749
2710
|
//#endregion
|
|
2750
2711
|
//#region src/core/createScopedUseRegle/createScopedUseRegle.d.ts
|
|
2751
2712
|
type CreateScopedUseRegleOptions<TCustomRegle extends useRegleFn<any, any>, TAsRecord extends boolean> = {
|
|
@@ -2772,13 +2733,13 @@ declare function createScopedUseRegle<TCustomRegle extends useRegleFn<any, any>
|
|
|
2772
2733
|
useScopedRegle: TReturnedRegle;
|
|
2773
2734
|
useCollectScope: useCollectScopeFn<TAsRecord>;
|
|
2774
2735
|
};
|
|
2775
|
-
declare const useCollectScope: <TValue extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?:
|
|
2736
|
+
declare const useCollectScope: <TValue extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?: vue1.MaybeRefOrGetter<string>) => {
|
|
2776
2737
|
r$: MergedScopedRegles<TValue>;
|
|
2777
2738
|
}, useScopedRegle: useRegleFn<Partial<AllRulesDeclarations>, never, {
|
|
2778
2739
|
dispose: () => void;
|
|
2779
2740
|
register: () => void;
|
|
2780
2741
|
}, {
|
|
2781
|
-
namespace?:
|
|
2742
|
+
namespace?: vue1.MaybeRefOrGetter<string>;
|
|
2782
2743
|
}>;
|
|
2783
2744
|
//#endregion
|
|
2784
2745
|
//#region src/core/createVariant.d.ts
|
|
@@ -2829,7 +2790,6 @@ declare function narrowVariant<TRoot extends {
|
|
|
2829
2790
|
declare function variantToRef<TRoot extends RegleStatus<{}, any, any>, const TKey extends keyof TRoot['$fields'], const TValue extends (LazyJoinDiscriminatedUnions<Exclude<TRoot['$fields'][TKey], RegleCollectionStatus<any, any, any> | RegleStatus<any, any, any>>> extends {
|
|
2830
2791
|
$value: infer V;
|
|
2831
2792
|
} ? V : unknown)>(root: MaybeRef<TRoot>, discriminantKey: TKey, discriminantValue: TValue): Ref<Extract<TRoot['$fields'], { [K in TKey]: RegleFieldStatus<TValue, any, any> }> | undefined>;
|
|
2832
|
-
|
|
2833
2793
|
//#endregion
|
|
2834
2794
|
//#region src/core/refineRules.d.ts
|
|
2835
2795
|
/**
|
|
@@ -2858,6 +2818,5 @@ declare function defineRules<TRules extends RegleUnknownRulesTree>(rules: TRules
|
|
|
2858
2818
|
* ```
|
|
2859
2819
|
*/
|
|
2860
2820
|
declare function refineRules<TRules extends RegleUnknownRulesTree, TRefinement extends ReglePartialRuleTree<InferInput<TRules>> & RegleUnknownRulesTree>(rules: TRules, refinement: (state: Ref<InferInput<TRules>>) => TRefinement): (state: Ref<InferInput<TRules>>) => Merge<TRules, TRefinement>;
|
|
2861
|
-
|
|
2862
2821
|
//#endregion
|
|
2863
|
-
export { $InternalRegleStatus, AllRulesDeclarations, CommonAlphaOptions, CommonComparisonOptions, CreateScopedUseRegleOptions, DeepMaybeRef, DeepReactiveState, DefaultValidatorsTree, FormRuleDeclaration, HaveAnyRequiredProps, InferInput, InferRegleRoot, InferRegleRule, InferRegleRules, InferRegleShortcuts, InferRegleStatusType, InferSafeOutput, InlineRuleDeclaration, InternalRuleType, JoinDiscriminatedUnions, LocalRegleBehaviourOptions, Maybe, MaybeInput, MaybeOutput, MaybeReadonly, MaybeVariantStatus, MergedRegles, MergedScopedRegles, NarrowVariant, NoInferLegacy, PrimitiveTypes, Regle, RegleBehaviourOptions, RegleCollectionErrors, RegleCollectionRuleDecl, RegleCollectionRuleDefinition, RegleCollectionStatus, RegleCommonStatus, RegleComputedRules,
|
|
2822
|
+
export { $InternalRegleStatus, AllRulesDeclarations, CommonAlphaOptions, CommonComparisonOptions, CreateScopedUseRegleOptions, DeepMaybeRef, DeepReactiveState, DefaultValidatorsTree, FormRuleDeclaration, HaveAnyRequiredProps, InferInput, InferRegleRoot, InferRegleRule, InferRegleRules, InferRegleShortcuts, InferRegleStatusType, InferSafeOutput, InlineRuleDeclaration, InternalRuleType, JoinDiscriminatedUnions, LocalRegleBehaviourOptions, Maybe, MaybeInput, MaybeOutput, MaybeReadonly, MaybeVariantStatus, MergedRegles, MergedScopedRegles, NarrowVariant, NoInferLegacy, PrimitiveTypes, Regle, RegleBehaviourOptions, RegleCollectionErrors, RegleCollectionRuleDecl, RegleCollectionRuleDefinition, RegleCollectionStatus, RegleCommonStatus, RegleComputedRules, RegleCustomFieldStatus, RegleEnforceCustomRequiredRules, RegleEnforceRequiredRules, RegleErrorTree, RegleExternalCollectionErrors, RegleExternalErrorTree, RegleExternalSchemaErrorTree, RegleFieldIssue, RegleFieldStatus, RegleFormPropertyType, RegleInternalRuleDefs, ReglePartialRuleTree, RegleResult, RegleRoot, RegleRuleCore, RegleRuleDecl, RegleRuleDefinition, RegleRuleDefinitionProcessor, RegleRuleDefinitionWithMetadataProcessor, RegleRuleInit, RegleRuleMetadataConsumer, RegleRuleMetadataDefinition, RegleRuleMetadataExtended, RegleRuleRaw, RegleRuleStatus, RegleRuleTypeReturn, RegleRuleWithParamsDefinition, RegleShortcutDefinition, RegleSingleField, RegleStatus, RegleUniversalParams, RegleUnknownRulesTree, RegleValidationErrors, RegleValidationGroupEntry, RegleValidationGroupOutput, RegleRuleTree as RegleValidationTree, ResolvedRegleBehaviourOptions, ScopedInstancesRecord, ScopedInstancesRecordLike, SuperCompatibleRegle, SuperCompatibleRegleCollectionErrors, SuperCompatibleRegleCollectionStatus, SuperCompatibleRegleFieldStatus, SuperCompatibleRegleResult, SuperCompatibleRegleRoot, SuperCompatibleRegleRuleStatus, SuperCompatibleRegleStatus, Unwrap, UnwrapRegleUniversalParams, UnwrapRuleWithParams, UseScopedRegleOptions, createRule, createScopedUseRegle, createVariant, defineRegleConfig, defineRules, extendRegleConfig, flatErrors, inferRules, inferRulesFn, mergeRegles, narrowVariant, refineRules, unwrapRuleParameters, useCollectScope, useCollectScopeFn, useRegle, useRegleFn, useRootStorage, useScopedRegle, variantToRef };
|