@regle/core 1.3.0 → 1.3.2
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 +87 -129
- package/dist/regle-core.js +8 -8
- 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
|
|
@@ -7,6 +7,7 @@ type Maybe<T = any> = T | null | undefined;
|
|
|
7
7
|
type MaybeInput<T = any> = T | null | undefined;
|
|
8
8
|
type MaybeOutput<T = any> = T | undefined;
|
|
9
9
|
type MaybeReadonly<T> = T | Readonly<T>;
|
|
10
|
+
type NonUndefined<T> = Exclude<T, undefined>;
|
|
10
11
|
type PromiseReturn<T> = T extends Promise<infer U> ? U : T;
|
|
11
12
|
type MaybeGetter<T, V = any, TAdd extends Record<string, any> = {}> = T | ((value: Ref<V>, index: number) => T & TAdd);
|
|
12
13
|
type Unwrap<T extends MaybeRef<Record<string, any>>> = T extends Ref ? UnwrapRef<T> : UnwrapNestedRefs<T>;
|
|
@@ -19,22 +20,19 @@ type ExcludeByType<T, U> = { [K in keyof T as T[K] extends U ? never : K]: T[K]
|
|
|
19
20
|
type PrimitiveTypes = string | number | boolean | bigint | Date | File;
|
|
20
21
|
type isRecordLiteral<T extends unknown> = NonNullable<T> extends Date | File ? false : NonNullable<T> extends Record<string, any> ? true : false;
|
|
21
22
|
type NoInferLegacy<A extends any> = [A][A extends any ? 0 : never];
|
|
22
|
-
|
|
23
23
|
//#endregion
|
|
24
24
|
//#region src/types/utils/Array.types.d.ts
|
|
25
25
|
type ArrayElement<T> = T extends Array<infer U> ? U : never;
|
|
26
|
-
|
|
27
26
|
//#endregion
|
|
28
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
27
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/primitive.d.ts
|
|
29
28
|
/**
|
|
30
29
|
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
31
30
|
|
|
32
31
|
@category Type
|
|
33
32
|
*/
|
|
34
33
|
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
35
|
-
|
|
36
34
|
//#endregion
|
|
37
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
35
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/observable-like.d.ts
|
|
38
36
|
declare global {
|
|
39
37
|
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
40
38
|
interface SymbolConstructor {
|
|
@@ -42,8 +40,6 @@ declare global {
|
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
42
|
|
|
45
|
-
//#endregion
|
|
46
|
-
//#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/union-to-intersection.d.ts
|
|
47
43
|
/**
|
|
48
44
|
@remarks
|
|
49
45
|
The TC39 observable proposal defines a `closed` property, but some implementations (such as xstream) do not as of 10/08/2021.
|
|
@@ -55,6 +51,8 @@ As well, some guidance on making an `Observable` to not include `closed` propert
|
|
|
55
51
|
@category Observable
|
|
56
52
|
*/
|
|
57
53
|
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/union-to-intersection.d.ts
|
|
58
56
|
/**
|
|
59
57
|
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
58
|
|
|
@@ -100,7 +98,7 @@ type Intersection = UnionToIntersection<Union>;
|
|
|
100
98
|
|
|
101
99
|
@category Type
|
|
102
100
|
*/
|
|
103
|
-
type UnionToIntersection
|
|
101
|
+
type UnionToIntersection<Union> = (
|
|
104
102
|
// `extends unknown` is always going to be the case and is used to convert the
|
|
105
103
|
// `Union` into a [distributive conditional
|
|
106
104
|
// type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
@@ -115,9 +113,8 @@ Union extends unknown
|
|
|
115
113
|
) extends ((mergedIntersection: infer Intersection) => void)
|
|
116
114
|
// The `& Union` is to allow indexing by the resulting type
|
|
117
115
|
? Intersection & Union : never;
|
|
118
|
-
|
|
119
116
|
//#endregion
|
|
120
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
117
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/empty-object.d.ts
|
|
121
118
|
declare const emptyObjectSymbol: unique symbol;
|
|
122
119
|
|
|
123
120
|
/**
|
|
@@ -166,9 +163,8 @@ type Fail = IsEmptyObject<null>; //=> false
|
|
|
166
163
|
@category Object
|
|
167
164
|
*/
|
|
168
165
|
type IsEmptyObject<T> = T extends EmptyObject ? true : false;
|
|
169
|
-
|
|
170
166
|
//#endregion
|
|
171
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
167
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/optional-keys-of.d.ts
|
|
172
168
|
/**
|
|
173
169
|
Extract all optional keys from the given type.
|
|
174
170
|
|
|
@@ -204,11 +200,9 @@ const update2: UpdateOperation<User> = {
|
|
|
204
200
|
*/
|
|
205
201
|
type OptionalKeysOf<BaseType extends object> = BaseType extends unknown // For distributing `BaseType`
|
|
206
202
|
? (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
|
-
|
|
203
|
+
: never; // Should never happen
|
|
209
204
|
//#endregion
|
|
210
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
211
|
-
// Should never happen
|
|
205
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/required-keys-of.d.ts
|
|
212
206
|
/**
|
|
213
207
|
Extract all required keys from the given type.
|
|
214
208
|
|
|
@@ -234,12 +228,10 @@ const validator2 = createValidation<User>('surname', value => value.length < 25)
|
|
|
234
228
|
@category Utilities
|
|
235
229
|
*/
|
|
236
230
|
type RequiredKeysOf<BaseType extends object> = BaseType extends unknown // For distributing `BaseType`
|
|
237
|
-
? Exclude<keyof BaseType, OptionalKeysOf<BaseType>> : never;
|
|
231
|
+
? Exclude<keyof BaseType, OptionalKeysOf<BaseType>> : never; // Should never happen
|
|
238
232
|
|
|
239
233
|
//#endregion
|
|
240
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
241
|
-
// Should never happen
|
|
242
|
-
|
|
234
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/is-never.d.ts
|
|
243
235
|
/**
|
|
244
236
|
Returns a boolean for whether the given type is `never`.
|
|
245
237
|
|
|
@@ -282,9 +274,8 @@ endIfEqual('abc', '123');
|
|
|
282
274
|
@category Utilities
|
|
283
275
|
*/
|
|
284
276
|
type IsNever$1<T> = [T] extends [never] ? true : false;
|
|
285
|
-
|
|
286
277
|
//#endregion
|
|
287
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
278
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/if-never.d.ts
|
|
288
279
|
/**
|
|
289
280
|
An if-else-like type that resolves depending on whether the given type is `never`.
|
|
290
281
|
|
|
@@ -304,10 +295,9 @@ type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
|
|
|
304
295
|
@category Type Guard
|
|
305
296
|
@category Utilities
|
|
306
297
|
*/
|
|
307
|
-
type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = (IsNever$1<T> extends true ? TypeIfNever : TypeIfNotNever);
|
|
308
|
-
|
|
298
|
+
type IfNever$1<T, TypeIfNever = true, TypeIfNotNever = false> = (IsNever$1<T> extends true ? TypeIfNever : TypeIfNotNever);
|
|
309
299
|
//#endregion
|
|
310
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
300
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/is-any.d.ts
|
|
311
301
|
// Can eventually be replaced with the built-in once this library supports
|
|
312
302
|
// TS5.4+ only. Tracked in https://github.com/sindresorhus/type-fest/issues/848
|
|
313
303
|
type NoInfer<T> = T extends infer U ? U : never;
|
|
@@ -341,19 +331,18 @@ const anyA = get(anyObject, 'a');
|
|
|
341
331
|
@category Utilities
|
|
342
332
|
*/
|
|
343
333
|
type IsAny$1<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
344
|
-
|
|
345
334
|
//#endregion
|
|
346
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
335
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/internal/keys.d.ts
|
|
347
336
|
/**
|
|
348
337
|
Disallows any of the given keys.
|
|
349
338
|
*/
|
|
350
339
|
type RequireNone<KeysType extends PropertyKey> = Partial<Record<KeysType, never>>;
|
|
351
340
|
|
|
352
|
-
//#endregion
|
|
353
|
-
//#region ../../node_modules/.pnpm/type-fest@4.40.1/node_modules/type-fest/source/simplify.d.ts
|
|
354
341
|
/**
|
|
355
342
|
Utility type to retrieve only literal keys from type.
|
|
356
343
|
*/
|
|
344
|
+
//#endregion
|
|
345
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/simplify.d.ts
|
|
357
346
|
/**
|
|
358
347
|
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
348
|
|
|
@@ -412,9 +401,8 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
|
|
|
412
401
|
@category Object
|
|
413
402
|
*/
|
|
414
403
|
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
415
|
-
|
|
416
404
|
//#endregion
|
|
417
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
405
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
418
406
|
/**
|
|
419
407
|
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
420
408
|
|
|
@@ -506,9 +494,8 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
|
506
494
|
@category Object
|
|
507
495
|
*/
|
|
508
496
|
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
509
|
-
|
|
510
497
|
//#endregion
|
|
511
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
498
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/pick-index-signature.d.ts
|
|
512
499
|
/**
|
|
513
500
|
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
514
501
|
|
|
@@ -555,9 +542,8 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
555
542
|
@category Object
|
|
556
543
|
*/
|
|
557
544
|
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
558
|
-
|
|
559
545
|
//#endregion
|
|
560
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
546
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/merge.d.ts
|
|
561
547
|
// Merges two objects without worrying about index signatures.
|
|
562
548
|
type SimpleMerge<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source;
|
|
563
549
|
|
|
@@ -596,9 +582,8 @@ export type FooBar = Merge<Foo, Bar>;
|
|
|
596
582
|
@category Object
|
|
597
583
|
*/
|
|
598
584
|
type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
599
|
-
|
|
600
585
|
//#endregion
|
|
601
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
586
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/if-any.d.ts
|
|
602
587
|
/**
|
|
603
588
|
An if-else-like type that resolves depending on whether the given type is `any`.
|
|
604
589
|
|
|
@@ -618,10 +603,9 @@ type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
|
|
|
618
603
|
@category Type Guard
|
|
619
604
|
@category Utilities
|
|
620
605
|
*/
|
|
621
|
-
type IfAny<T, TypeIfAny = true, TypeIfNotAny = false> = (IsAny$1<T> extends true ? TypeIfAny : TypeIfNotAny);
|
|
622
|
-
|
|
606
|
+
type IfAny$1<T, TypeIfAny = true, TypeIfNotAny = false> = (IsAny$1<T> extends true ? TypeIfAny : TypeIfNotAny);
|
|
623
607
|
//#endregion
|
|
624
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
608
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/internal/type.d.ts
|
|
625
609
|
/**
|
|
626
610
|
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
627
611
|
*/
|
|
@@ -671,12 +655,29 @@ IsNever$1<T> extends true ? false : T extends any ? [U] extends [T] ? false : tr
|
|
|
671
655
|
// In some cases `Result` will return `false | true` which is `boolean`,
|
|
672
656
|
// that means `T` has at least two types and it's a union type,
|
|
673
657
|
// so we will return `true` instead of `boolean`.
|
|
674
|
-
? boolean extends Result ? true : Result : never;
|
|
658
|
+
? boolean extends Result ? true : Result : never; // Should never happen
|
|
675
659
|
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
// Should never happen
|
|
660
|
+
/**
|
|
661
|
+
An if-else-like type that resolves depending on whether the given type is `any` or `never`.
|
|
679
662
|
|
|
663
|
+
@example
|
|
664
|
+
```
|
|
665
|
+
// When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
|
|
666
|
+
type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
667
|
+
//=> 'VALID'
|
|
668
|
+
|
|
669
|
+
// When `T` is `any` => Returns `IfAny` branch
|
|
670
|
+
type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
671
|
+
//=> 'IS_ANY'
|
|
672
|
+
|
|
673
|
+
// When `T` is `never` => Returns `IfNever` branch
|
|
674
|
+
type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
675
|
+
//=> 'IS_NEVER'
|
|
676
|
+
```
|
|
677
|
+
*/
|
|
678
|
+
type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> = IsAny$1<T> extends true ? IfAny : IsNever$1<T> extends true ? IfNever : IfNotAnyOrNever;
|
|
679
|
+
//#endregion
|
|
680
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/internal/object.d.ts
|
|
680
681
|
/**
|
|
681
682
|
Merges user specified options with default options.
|
|
682
683
|
|
|
@@ -729,11 +730,10 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
|
|
|
729
730
|
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
730
731
|
```
|
|
731
732
|
*/
|
|
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>`
|
|
733
|
+
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
734
|
>>;
|
|
734
|
-
|
|
735
735
|
//#endregion
|
|
736
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
736
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/require-exactly-one.d.ts
|
|
737
737
|
/**
|
|
738
738
|
Create a type that requires exactly one of the given keys and disallows more. The remaining keys are kept as is.
|
|
739
739
|
|
|
@@ -763,10 +763,10 @@ const responder: RequireExactlyOne<Responder, 'text' | 'json'> = {
|
|
|
763
763
|
|
|
764
764
|
@category Object
|
|
765
765
|
*/
|
|
766
|
-
type RequireExactlyOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> =
|
|
767
|
-
|
|
766
|
+
type RequireExactlyOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, IfNever$1<KeysType, never, _RequireExactlyOne<ObjectType, IfAny$1<KeysType, keyof ObjectType, KeysType>>>>;
|
|
767
|
+
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
768
|
//#endregion
|
|
769
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
769
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/require-one-or-none.d.ts
|
|
770
770
|
/**
|
|
771
771
|
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
772
|
|
|
@@ -797,11 +797,10 @@ const responder3: Responder = {
|
|
|
797
797
|
|
|
798
798
|
@category Object
|
|
799
799
|
*/
|
|
800
|
-
type RequireOneOrNone<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> =
|
|
801
|
-
|
|
800
|
+
type RequireOneOrNone<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, IfNever$1<KeysType, ObjectType, _RequireOneOrNone<ObjectType, IfAny$1<KeysType, keyof ObjectType, KeysType>>>>;
|
|
801
|
+
type _RequireOneOrNone<ObjectType, KeysType extends keyof ObjectType> = (RequireExactlyOne<ObjectType, KeysType> | RequireNone<KeysType>) & Omit<ObjectType, KeysType>; // Ignore unspecified keys.
|
|
802
802
|
//#endregion
|
|
803
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
804
|
-
// Ignore unspecified keys.
|
|
803
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/partial-deep.d.ts
|
|
805
804
|
/**
|
|
806
805
|
@see {@link PartialDeep}
|
|
807
806
|
*/
|
|
@@ -918,9 +917,8 @@ type PartialReadonlySetDeep<T, Options extends Required<PartialDeepOptions>> = {
|
|
|
918
917
|
Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
|
|
919
918
|
*/
|
|
920
919
|
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
920
|
//#endregion
|
|
923
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
921
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/required-deep.d.ts
|
|
924
922
|
type ExcludeUndefined<T> = Exclude<T, undefined>;
|
|
925
923
|
|
|
926
924
|
/**
|
|
@@ -970,9 +968,8 @@ type RequiredDeep<T, E extends ExcludeUndefined<T> = ExcludeUndefined<T>> = E ex
|
|
|
970
968
|
: RequiredObjectDeep<E> // Tuples behave properly
|
|
971
969
|
: RequiredObjectDeep<E> : unknown;
|
|
972
970
|
type RequiredObjectDeep<ObjectType extends object> = { [KeyType in keyof ObjectType]-?: RequiredDeep<ObjectType[KeyType]> };
|
|
973
|
-
|
|
974
971
|
//#endregion
|
|
975
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
972
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/union-to-tuple.d.ts
|
|
976
973
|
/**
|
|
977
974
|
Returns the last element of a union type.
|
|
978
975
|
|
|
@@ -982,7 +979,7 @@ type Last = LastOfUnion<1 | 2 | 3>;
|
|
|
982
979
|
//=> 3
|
|
983
980
|
```
|
|
984
981
|
*/
|
|
985
|
-
type LastOfUnion<T> = UnionToIntersection
|
|
982
|
+
type LastOfUnion<T> = UnionToIntersection<T extends any ? () => T : never> extends (() => (infer R)) ? R : never;
|
|
986
983
|
|
|
987
984
|
/**
|
|
988
985
|
Convert a union type into an unordered tuple type of its elements.
|
|
@@ -1019,10 +1016,9 @@ const petList = Object.keys(pets) as UnionToTuple<Pet>;
|
|
|
1019
1016
|
|
|
1020
1017
|
@category Array
|
|
1021
1018
|
*/
|
|
1022
|
-
type UnionToTuple
|
|
1023
|
-
|
|
1019
|
+
type UnionToTuple<T, L = LastOfUnion<T>> = IsNever$1<T> extends false ? [...UnionToTuple<Exclude<T, L>>, L] : [];
|
|
1024
1020
|
//#endregion
|
|
1025
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
1021
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/is-null.d.ts
|
|
1026
1022
|
/**
|
|
1027
1023
|
Returns a boolean for whether the given type is `null`.
|
|
1028
1024
|
|
|
@@ -1043,9 +1039,8 @@ type Example2 = NonNullFallback<number, string>;
|
|
|
1043
1039
|
@category Utilities
|
|
1044
1040
|
*/
|
|
1045
1041
|
type IsNull<T> = [T] extends [null] ? true : false;
|
|
1046
|
-
|
|
1047
1042
|
//#endregion
|
|
1048
|
-
//#region ../../node_modules/.pnpm/type-fest@4.
|
|
1043
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/is-unknown.d.ts
|
|
1049
1044
|
/**
|
|
1050
1045
|
Returns a boolean for whether the given type is `unknown`.
|
|
1051
1046
|
|
|
@@ -1089,10 +1084,9 @@ store.execute((state, payload) => ({value: state.value + payload}), someExternal
|
|
|
1089
1084
|
|
|
1090
1085
|
@category Utilities
|
|
1091
1086
|
*/
|
|
1092
|
-
type IsUnknown
|
|
1087
|
+
type IsUnknown<T> = (unknown extends T // `T` can be `unknown` or `any`
|
|
1093
1088
|
? IsNull<T> extends false // `any` can be `null`, but `unknown` can't be
|
|
1094
1089
|
? true : false : false);
|
|
1095
|
-
|
|
1096
1090
|
//#endregion
|
|
1097
1091
|
//#region src/types/core/modifiers.types.d.ts
|
|
1098
1092
|
interface RegleBehaviourOptions {
|
|
@@ -1180,7 +1174,6 @@ type RegleShortcutDefinition<TCustomRules extends Record<string, any> = {}> = {
|
|
|
1180
1174
|
collections?: ShortcutCommonFn<RegleCollectionStatus<any[], Partial<TCustomRules> & Partial<DefaultValidators>>>;
|
|
1181
1175
|
};
|
|
1182
1176
|
type AddDollarToOptions<T extends Record<string, any>> = { [K in keyof T as `$${string & K}`]: T[K] };
|
|
1183
|
-
|
|
1184
1177
|
//#endregion
|
|
1185
1178
|
//#region src/types/core/useRegle.types.d.ts
|
|
1186
1179
|
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 +1194,6 @@ type RegleSingleField<TState extends Maybe<PrimitiveTypes> = any, TRules extends
|
|
|
1201
1194
|
} & TAdditionalReturnProperties;
|
|
1202
1195
|
type DeepReactiveState<T extends Record<string, any> | unknown | undefined> = ExtendOnlyRealRecord<T> extends true ? { [K in keyof T]: InferDeepReactiveState<T[K]> } : never;
|
|
1203
1196
|
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
1197
|
//#endregion
|
|
1206
1198
|
//#region src/types/core/reset.types.d.ts
|
|
1207
1199
|
type ResetOptions<TState extends unknown> = RequireOneOrNone<{
|
|
@@ -1221,23 +1213,21 @@ type ResetOptions<TState extends unknown> = RequireOneOrNone<{
|
|
|
1221
1213
|
*/
|
|
1222
1214
|
clearExternalErrors?: boolean;
|
|
1223
1215
|
}, 'toInitialState' | 'toState'>;
|
|
1224
|
-
|
|
1225
1216
|
//#endregion
|
|
1226
1217
|
//#region src/types/core/scopedRegle.types.d.ts
|
|
1227
1218
|
type ScopedInstancesRecord = Record<string, Record<string, SuperCompatibleRegleRoot>> & {
|
|
1228
1219
|
'~~global': Record<string, SuperCompatibleRegleRoot>;
|
|
1229
1220
|
};
|
|
1230
1221
|
type ScopedInstancesRecordLike = Partial<ScopedInstancesRecord>;
|
|
1231
|
-
|
|
1232
1222
|
//#endregion
|
|
1233
1223
|
//#region src/types/core/results.types.d.ts
|
|
1234
1224
|
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
1225
|
type RegleResult<Data extends Record<string, any> | any[] | unknown, TRules extends ReglePartialRuleTree<any>> = {
|
|
1236
1226
|
valid: false;
|
|
1237
|
-
data: IsUnknown
|
|
1227
|
+
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
1228
|
} | {
|
|
1239
1229
|
valid: true;
|
|
1240
|
-
data: IsUnknown
|
|
1230
|
+
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
1231
|
};
|
|
1242
1232
|
/**
|
|
1243
1233
|
* Infer safe output from any `r$` instance
|
|
@@ -1258,7 +1248,6 @@ type ArrayHaveAtLeastOneRequiredField<TState extends Maybe<any[]>, TRule extends
|
|
|
1258
1248
|
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
1249
|
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
1250
|
type SafeFieldProperty<TState, TRule extends RegleFormPropertyType<any, any> | undefined = never> = FieldHaveRequiredRule<TRule> extends true ? NonNullable<TState> : MaybeOutput<TState>;
|
|
1261
|
-
|
|
1262
1251
|
//#endregion
|
|
1263
1252
|
//#region ../../node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/utils.d.ts
|
|
1264
1253
|
/**
|
|
@@ -1299,7 +1288,7 @@ type IsAny<T> = [T] extends [Secret] ? Not<IsNever<T>> : false;
|
|
|
1299
1288
|
/**
|
|
1300
1289
|
* Determines if the given type is `unknown`.
|
|
1301
1290
|
*/
|
|
1302
|
-
type IsUnknown<T> = [unknown] extends [T] ? Not<IsAny<T>> : false;
|
|
1291
|
+
type IsUnknown$1<T> = [unknown] extends [T] ? Not<IsAny<T>> : false;
|
|
1303
1292
|
/**
|
|
1304
1293
|
* Determines if a type is either `never` or `any`.
|
|
1305
1294
|
*/
|
|
@@ -1369,13 +1358,13 @@ type MutuallyExtends<Left, Right> = And<[Extends<Left, Right>, Extends<Right, Le
|
|
|
1369
1358
|
* Convert a union to an intersection.
|
|
1370
1359
|
* `A | B | C` -\> `A & B & C`
|
|
1371
1360
|
*/
|
|
1372
|
-
type UnionToIntersection<Union> = (Union extends any ? (distributedUnion: Union) => void : never) extends ((mergedIntersection: infer Intersection) => void) ? Intersection : never;
|
|
1361
|
+
type UnionToIntersection$1<Union> = (Union extends any ? (distributedUnion: Union) => void : never) extends ((mergedIntersection: infer Intersection) => void) ? Intersection : never;
|
|
1373
1362
|
/**
|
|
1374
1363
|
* Get the last element of a union.
|
|
1375
1364
|
* First, converts to a union of `() => T` functions,
|
|
1376
1365
|
* then uses {@linkcode UnionToIntersection} to get the last one.
|
|
1377
1366
|
*/
|
|
1378
|
-
type LastOf<Union> = UnionToIntersection<Union extends any ? () => Union : never> extends (() => infer R) ? R : never;
|
|
1367
|
+
type LastOf<Union> = UnionToIntersection$1<Union extends any ? () => Union : never> extends (() => infer R) ? R : never;
|
|
1379
1368
|
/**
|
|
1380
1369
|
* Intermediate type for {@linkcode UnionToTuple} which pushes the
|
|
1381
1370
|
* "last" union member to the end of a tuple, and recursively prepends
|
|
@@ -1385,11 +1374,8 @@ type TuplifyUnion<Union, LastElement = LastOf<Union>> = IsNever<Union> extends t
|
|
|
1385
1374
|
/**
|
|
1386
1375
|
* Convert a union like `1 | 2 | 3` to a tuple like `[1, 2, 3]`.
|
|
1387
1376
|
*/
|
|
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
|
|
1377
|
+
type UnionToTuple$1<Union> = TuplifyUnion<Union>;
|
|
1378
|
+
type IsUnion<T> = Not<Extends<UnionToTuple$1<T>['length'], 1>>;
|
|
1393
1379
|
/**
|
|
1394
1380
|
* A recursive version of `Pick` that selects properties from the left type that are present in the right type.
|
|
1395
1381
|
* The "leaf" types from `Left` are used - only the keys of `Right` are considered.
|
|
@@ -1401,6 +1387,8 @@ type IsUnion<T> = Not<Extends<UnionToTuple<T>['length'], 1>>;
|
|
|
1401
1387
|
* type Result = DeepPickMatchingProps<typeof user, {name: unknown; address: {city: unknown}}> // {name: string, address: {city: string}}
|
|
1402
1388
|
* ```
|
|
1403
1389
|
*/
|
|
1390
|
+
//#endregion
|
|
1391
|
+
//#region ../../node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/overloads.d.ts
|
|
1404
1392
|
/**
|
|
1405
1393
|
* The simple(ish) way to get overload info from a function
|
|
1406
1394
|
* {@linkcode FunctionType}. Recent versions of TypeScript will match any
|
|
@@ -1665,8 +1653,7 @@ type ConstructorOverloadParameters<ConstructorType> = ConstructorOverloadsUnion<
|
|
|
1665
1653
|
/**
|
|
1666
1654
|
* Calculates the number of overloads for a given function type.
|
|
1667
1655
|
*/
|
|
1668
|
-
type NumOverloads<FunctionType> = UnionToTuple<OverloadsInfoUnion<FunctionType>>['length'];
|
|
1669
|
-
|
|
1656
|
+
type NumOverloads<FunctionType> = UnionToTuple$1<OverloadsInfoUnion<FunctionType>>['length'];
|
|
1670
1657
|
//#endregion
|
|
1671
1658
|
//#region ../../node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/branding.d.ts
|
|
1672
1659
|
/**
|
|
@@ -1689,7 +1676,7 @@ type DeepBrand<T> = IsNever<T> extends true ? {
|
|
|
1689
1676
|
type: 'never';
|
|
1690
1677
|
} : IsAny<T> extends true ? {
|
|
1691
1678
|
type: 'any';
|
|
1692
|
-
} : IsUnknown<T> extends true ? {
|
|
1679
|
+
} : IsUnknown$1<T> extends true ? {
|
|
1693
1680
|
type: 'unknown';
|
|
1694
1681
|
} : T extends string | number | boolean | symbol | bigint | null | undefined | void ? {
|
|
1695
1682
|
type: 'primitive';
|
|
@@ -1704,7 +1691,7 @@ type DeepBrand<T> = IsNever<T> extends true ? {
|
|
|
1704
1691
|
return: DeepBrand<R>;
|
|
1705
1692
|
this: DeepBrand<ThisParameterType<T>>;
|
|
1706
1693
|
props: DeepBrand<Omit<T, keyof Function>>;
|
|
1707
|
-
} : UnionToTuple<OverloadsInfoUnion<T>> extends infer OverloadsTuple ? {
|
|
1694
|
+
} : UnionToTuple$1<OverloadsInfoUnion<T>> extends infer OverloadsTuple ? {
|
|
1708
1695
|
type: 'overloads';
|
|
1709
1696
|
overloads: { [K in keyof OverloadsTuple]: DeepBrand<OverloadsTuple[K]> };
|
|
1710
1697
|
} : never : T extends any[] ? {
|
|
@@ -1722,13 +1709,12 @@ type DeepBrand<T> = IsNever<T> extends true ? {
|
|
|
1722
1709
|
* Checks if two types are strictly equal using branding.
|
|
1723
1710
|
*/
|
|
1724
1711
|
type StrictEqualUsingBranding<Left, Right> = MutuallyExtends<DeepBrand<Left>, DeepBrand<Right>>;
|
|
1725
|
-
|
|
1726
1712
|
//#endregion
|
|
1727
1713
|
//#region ../../node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/messages.d.ts
|
|
1728
1714
|
/**
|
|
1729
1715
|
* Determines the printable type representation for a given type.
|
|
1730
1716
|
*/
|
|
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' : '...';
|
|
1717
|
+
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
1718
|
/**
|
|
1733
1719
|
* Helper for showing end-user a hint why their type assertion is failing.
|
|
1734
1720
|
* This swaps "leaf" types with a literal message about what the actual and
|
|
@@ -1736,12 +1722,11 @@ type PrintType<T> = IsUnknown<T> extends true ? 'unknown' : IsNever<T> extends t
|
|
|
1736
1722
|
* otherwise `LeafTypeOf<Actual>` returns `never`, which extends everything 🤔
|
|
1737
1723
|
*/
|
|
1738
1724
|
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
1725
|
/**
|
|
1743
1726
|
* @internal
|
|
1744
1727
|
*/
|
|
1728
|
+
//#endregion
|
|
1729
|
+
//#region src/types/core/variants.types.d.ts
|
|
1745
1730
|
type NarrowVariant<TRoot extends {
|
|
1746
1731
|
[x: string]: unknown;
|
|
1747
1732
|
}, TKey extends keyof TRoot, TValue extends (LazyJoinDiscriminatedUnions<Exclude<TRoot[TKey], RegleCollectionStatus<any, any, any> | RegleStatus<any, any, any>>> extends {
|
|
@@ -1750,7 +1735,7 @@ type NarrowVariant<TRoot extends {
|
|
|
1750
1735
|
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
1736
|
$fields: ProcessChildrenFields<TState, TRules, TShortcuts>[keyof ProcessChildrenFields<TState, TRules, TShortcuts>];
|
|
1752
1737
|
} : 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
|
|
1738
|
+
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
1739
|
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
1740
|
type PossibleLiteralTypes<T extends Record<string, any>, TKey extends keyof T> = unknown extends T[TKey] ? {
|
|
1756
1741
|
[x: string]: { [K in TKey]-?: Omit<RegleRuleDecl<any, Partial<AllRulesDeclarations>>, 'literal'> & {
|
|
@@ -1761,7 +1746,6 @@ type PossibleLiteralTypes<T extends Record<string, any>, TKey extends keyof T> =
|
|
|
1761
1746
|
} } };
|
|
1762
1747
|
type RequiredForm<T extends Record<string, any>, TKey extends keyof T> = Omit<ReglePartialRuleTree<T>, TKey> & PossibleLiteralTypes<T, TKey>[keyof PossibleLiteralTypes<T, TKey>];
|
|
1763
1748
|
type VariantTuple<T extends Record<string, any>, TKey extends keyof T> = [RequiredForm<T, TKey>, ...RequiredForm<T, TKey>[]];
|
|
1764
|
-
|
|
1765
1749
|
//#endregion
|
|
1766
1750
|
//#region src/core/useRegle/useRegle.d.ts
|
|
1767
1751
|
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 +1777,6 @@ interface useRegleFn<TCustomRules extends Partial<AllRulesDeclarations>, TShortc
|
|
|
1793
1777
|
* Docs: {@link https://reglejs.dev/core-concepts/}
|
|
1794
1778
|
*/
|
|
1795
1779
|
declare const useRegle: useRegleFn<Partial<AllRulesDeclarations>, RegleShortcutDefinition<any>, {}, {}>;
|
|
1796
|
-
|
|
1797
1780
|
//#endregion
|
|
1798
1781
|
//#region src/core/useRegle/inferRules.d.ts
|
|
1799
1782
|
interface inferRulesFn<TCustomRules extends Partial<AllRulesDeclarations>> {
|
|
@@ -1807,7 +1790,6 @@ interface inferRulesFn<TCustomRules extends Partial<AllRulesDeclarations>> {
|
|
|
1807
1790
|
* @param rules - Your rule tree
|
|
1808
1791
|
*/
|
|
1809
1792
|
declare const inferRules: inferRulesFn<Partial<AllRulesDeclarations>>;
|
|
1810
|
-
|
|
1811
1793
|
//#endregion
|
|
1812
1794
|
//#region src/core/useRegle/root/useRootStorage.d.ts
|
|
1813
1795
|
declare function useRootStorage({
|
|
@@ -1833,7 +1815,6 @@ declare function useRootStorage({
|
|
|
1833
1815
|
}): {
|
|
1834
1816
|
regle: $InternalRegleStatusType | undefined;
|
|
1835
1817
|
};
|
|
1836
|
-
|
|
1837
1818
|
//#endregion
|
|
1838
1819
|
//#region src/core/useRegle/useErrors.d.ts
|
|
1839
1820
|
/**
|
|
@@ -1850,7 +1831,6 @@ declare function flatErrors(errors: $InternalRegleErrors, options: {
|
|
|
1850
1831
|
declare function flatErrors(errors: $InternalRegleErrors, options?: {
|
|
1851
1832
|
includePath?: false;
|
|
1852
1833
|
}): string[];
|
|
1853
|
-
|
|
1854
1834
|
//#endregion
|
|
1855
1835
|
//#region src/types/utils/props.types.d.ts
|
|
1856
1836
|
/**
|
|
@@ -1886,7 +1866,6 @@ type RegleCustomStatus<T extends useRegleFn<any, any>, TState extends Record<str
|
|
|
1886
1866
|
* Extract custom rules and custom shortcuts and apply them to a RegleFieldStatus type
|
|
1887
1867
|
*/
|
|
1888
1868
|
type RegleCustomCollectionStatus<T extends useRegleFn<any, any>, TState extends any[] = any[], TRules extends ReglePartialRuleTree<ArrayElement<TState>> = InferRegleRules<T>> = RegleCollectionStatus<TState, TRules, InferRegleShortcuts<T>>;
|
|
1889
|
-
|
|
1890
1869
|
//#endregion
|
|
1891
1870
|
//#region src/types/utils/object.types.d.ts
|
|
1892
1871
|
type RemoveCommonKey<T extends readonly any[], K extends PropertyKey> = T extends [infer F, ...infer R] ? [Prettify<Omit<F, K>>, ...RemoveCommonKey<R, K>] : [];
|
|
@@ -1906,7 +1885,7 @@ type GetMaybeObjectValue<O extends Record<string, any>, K extends string> = K ex
|
|
|
1906
1885
|
/**
|
|
1907
1886
|
* Combine all union values to be able to get even the normally "never" values, act as an intersection type
|
|
1908
1887
|
*/
|
|
1909
|
-
type RetrieveUnionUnknownValues<T extends readonly any[], TKeys extends string> = T extends [infer F extends Record<string, any>, ...infer R] ? [{ [K in TKeys as GetMaybeObjectValue<F, K> extends
|
|
1888
|
+
type RetrieveUnionUnknownValues<T extends readonly any[], TKeys extends string> = T extends [infer F extends Record<string, any>, ...infer R] ? [{ [K in TKeys as GetMaybeObjectValue<F, K> extends NonUndefined<GetMaybeObjectValue<F, K>> ? never : K]?: GetMaybeObjectValue<F, K> } & { [K in TKeys as GetMaybeObjectValue<F, K> extends NonUndefined<GetMaybeObjectValue<F, K>> ? K : never]: GetMaybeObjectValue<F, K> }, ...RetrieveUnionUnknownValues<R, TKeys>] : [];
|
|
1910
1889
|
/**
|
|
1911
1890
|
* Get all possible keys from a union, even the ones present only on one union
|
|
1912
1891
|
*/
|
|
@@ -1914,12 +1893,12 @@ type RetrieveUnionUnknownKeysOf<T extends readonly any[]> = T extends [infer F,
|
|
|
1914
1893
|
/**
|
|
1915
1894
|
* Transforms a union and apply undefined values to non-present keys to support intersection
|
|
1916
1895
|
*/
|
|
1917
|
-
type NormalizeUnion<TUnion> = RetrieveUnionUnknownValues<NonNullable<UnionToTuple
|
|
1896
|
+
type NormalizeUnion<TUnion> = RetrieveUnionUnknownValues<NonNullable<UnionToTuple<TUnion>>, RetrieveUnionUnknownKeysOf<NonNullable<UnionToTuple<TUnion>>>[number]>[number];
|
|
1918
1897
|
/**
|
|
1919
1898
|
* Combine all members of a union type, merging types for each key, and keeping loose types
|
|
1920
1899
|
*/
|
|
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
|
|
1900
|
+
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;
|
|
1901
|
+
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
1902
|
type EnumLike = {
|
|
1924
1903
|
[k: string]: string | number;
|
|
1925
1904
|
[nu: number]: string;
|
|
@@ -1927,15 +1906,13 @@ type EnumLike = {
|
|
|
1927
1906
|
type enumType<T extends Record<string, unknown>> = T[keyof T];
|
|
1928
1907
|
type UnwrapMaybeRef<T extends MaybeRef<any> | DeepReactiveState<any>> = T extends Ref<any> ? UnwrapRef<T> : UnwrapNestedRefs<T>;
|
|
1929
1908
|
type TupleToPlainObj<T> = { [I in keyof T & `${number}`]: T[I] };
|
|
1930
|
-
|
|
1931
1909
|
//#endregion
|
|
1932
1910
|
//#region src/types/utils/mismatch.types.d.ts
|
|
1933
1911
|
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
1912
|
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
1913
|
//#endregion
|
|
1937
1914
|
//#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
|
|
1915
|
+
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
1916
|
type ProcessInputChildren<TRule extends unknown, TMarkMaybe extends boolean> = TRule extends {
|
|
1940
1917
|
$each: RegleCollectionEachRules<any, any>;
|
|
1941
1918
|
} ? 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 +1922,6 @@ type ExtractTypeFromRules<TRules extends RegleRuleDecl<any, any>> = FilterRulesW
|
|
|
1945
1922
|
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
1923
|
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
1924
|
type InferTupleUnionInput<T extends any[]> = T extends [infer F extends ReglePartialRuleTree, ...infer R] ? [InferInput<F, true>, ...InferTupleUnionInput<R>] : [];
|
|
1948
|
-
|
|
1949
1925
|
//#endregion
|
|
1950
1926
|
//#region src/types/rules/rule.params.types.d.ts
|
|
1951
1927
|
type CreateFn<T extends any[]> = (...args: T) => any;
|
|
@@ -1956,7 +1932,6 @@ type CreateFn<T extends any[]> = (...args: T) => any;
|
|
|
1956
1932
|
*/
|
|
1957
1933
|
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
1934
|
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
1935
|
//#endregion
|
|
1961
1936
|
//#region src/types/rules/rule.internal.types.d.ts
|
|
1962
1937
|
/**
|
|
@@ -1979,7 +1954,6 @@ declare const InternalRuleType: {
|
|
|
1979
1954
|
readonly Async: "__async";
|
|
1980
1955
|
};
|
|
1981
1956
|
type InternalRuleType = enumType<typeof InternalRuleType>;
|
|
1982
|
-
|
|
1983
1957
|
//#endregion
|
|
1984
1958
|
//#region src/types/rules/rule.definition.type.d.ts
|
|
1985
1959
|
type IsLiteral<T> = string extends T ? false : true;
|
|
@@ -2068,7 +2042,6 @@ type RegleCollectionRuleDefinition<TValue = any[], TCustomRules extends Partial<
|
|
|
2068
2042
|
}) | ({
|
|
2069
2043
|
$each: MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue>>, TCustomRules>, ArrayElement<TValue>>;
|
|
2070
2044
|
} & CollectionRegleBehaviourOptions);
|
|
2071
|
-
|
|
2072
2045
|
//#endregion
|
|
2073
2046
|
//#region src/types/rules/rule.init.types.d.ts
|
|
2074
2047
|
type RegleInitPropertyGetter<TValue, TReturn, TParams extends [...any[]], TMetadata extends RegleRuleMetadataDefinition> = TReturn | ((metadata: RegleRuleMetadataConsumer<TValue, TParams, TMetadata>) => TReturn);
|
|
@@ -2104,7 +2077,6 @@ type RegleRuleTypeReturn<TValue, TParams extends [...any[]]> = {
|
|
|
2104
2077
|
value: TValue;
|
|
2105
2078
|
params: [...TParams];
|
|
2106
2079
|
};
|
|
2107
|
-
|
|
2108
2080
|
//#endregion
|
|
2109
2081
|
//#region src/core/defaultValidators.d.ts
|
|
2110
2082
|
interface CommonComparisonOptions {
|
|
@@ -2170,7 +2142,6 @@ type DefaultValidators = {
|
|
|
2170
2142
|
startsWith: RegleRuleWithParamsDefinition<string, [part: Maybe<string>], false, boolean>;
|
|
2171
2143
|
url: RegleRuleDefinition<string, [], false, boolean, string>;
|
|
2172
2144
|
};
|
|
2173
|
-
|
|
2174
2145
|
//#endregion
|
|
2175
2146
|
//#region src/types/rules/rule.custom.types.d.ts
|
|
2176
2147
|
type CustomRulesDeclarationTree = {
|
|
@@ -2178,7 +2149,6 @@ type CustomRulesDeclarationTree = {
|
|
|
2178
2149
|
};
|
|
2179
2150
|
type DefaultValidatorsTree = { [K in keyof DefaultValidators]: RegleRuleRawInput<any, any[], boolean, any> | undefined };
|
|
2180
2151
|
type AllRulesDeclarations = CustomRulesDeclarationTree & DefaultValidatorsTree;
|
|
2181
|
-
|
|
2182
2152
|
//#endregion
|
|
2183
2153
|
//#region src/types/rules/rule.declaration.types.d.ts
|
|
2184
2154
|
/**
|
|
@@ -2261,7 +2231,6 @@ type InlineRuleDeclaration<TValue extends any = any, TParams extends any[] = any
|
|
|
2261
2231
|
* Regroup inline and registered rules
|
|
2262
2232
|
* */
|
|
2263
2233
|
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
2234
|
//#endregion
|
|
2266
2235
|
//#region src/types/rules/rule.errors.types.d.ts
|
|
2267
2236
|
type RegleErrorTree<TState = MaybeRef<Record<string, any> | any[]>> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>]: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>[K], false> };
|
|
@@ -2287,7 +2256,6 @@ type $InternalRegleErrorTree = {
|
|
|
2287
2256
|
* @internal
|
|
2288
2257
|
*/
|
|
2289
2258
|
type $InternalRegleErrors = $InternalRegleCollectionErrors | string[] | $InternalRegleErrorTree;
|
|
2290
|
-
|
|
2291
2259
|
//#endregion
|
|
2292
2260
|
//#region src/types/rules/rule.status.types.d.ts
|
|
2293
2261
|
/**
|
|
@@ -2467,7 +2435,7 @@ type RegleRuleStatus<TValue = any, TParams extends any[] = any[], TMetadata exte
|
|
|
2467
2435
|
/** Reset the $valid, $metadata and $pending states */
|
|
2468
2436
|
$reset(): void;
|
|
2469
2437
|
/** Returns the original rule validator function. */
|
|
2470
|
-
$validator: ((value: IsUnknown
|
|
2438
|
+
$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
2439
|
} & ([TParams] extends [never[]] ? {} : [unknown[]] extends [TParams] ? {
|
|
2472
2440
|
readonly $params?: any[];
|
|
2473
2441
|
} : {
|
|
@@ -2538,7 +2506,6 @@ interface $InternalRegleCollectionStatus extends Omit<$InternalRegleStatus, '$fi
|
|
|
2538
2506
|
$extractDirtyFields: (filterNullishValues?: boolean) => any[];
|
|
2539
2507
|
$validate: () => Promise<$InternalRegleResult>;
|
|
2540
2508
|
}
|
|
2541
|
-
|
|
2542
2509
|
//#endregion
|
|
2543
2510
|
//#region src/types/rules/compatibility.rules.d.ts
|
|
2544
2511
|
interface SuperCompatibleRegle {
|
|
@@ -2586,7 +2553,6 @@ interface SuperCompatibleRegleCollectionStatus extends Omit<SuperCompatibleRegle
|
|
|
2586
2553
|
$validate?: () => Promise<SuperCompatibleRegleResult>;
|
|
2587
2554
|
}
|
|
2588
2555
|
type SuperCompatibleRegleCollectionErrors = $InternalRegleCollectionErrors;
|
|
2589
|
-
|
|
2590
2556
|
//#endregion
|
|
2591
2557
|
//#region src/core/createRule/createRule.d.ts
|
|
2592
2558
|
/**
|
|
@@ -2621,7 +2587,6 @@ type SuperCompatibleRegleCollectionErrors = $InternalRegleCollectionErrors;
|
|
|
2621
2587
|
* Docs: {@link https://reglejs.dev/core-concepts/rules/reusable-rules}
|
|
2622
2588
|
*/
|
|
2623
2589
|
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
2590
|
//#endregion
|
|
2626
2591
|
//#region src/core/createRule/unwrapRuleParameters.d.ts
|
|
2627
2592
|
/**
|
|
@@ -2629,14 +2594,13 @@ declare function createRule<TValue extends any, TParams extends any[], TReturn e
|
|
|
2629
2594
|
* Removing Ref and executing function to return the unwrapped value
|
|
2630
2595
|
*/
|
|
2631
2596
|
declare function unwrapRuleParameters<TParams extends any[]>(params: MaybeRefOrGetter[]): TParams;
|
|
2632
|
-
|
|
2633
|
-
//#endregion
|
|
2634
|
-
//#region src/core/defineRegleConfig.d.ts
|
|
2635
2597
|
/**
|
|
2636
2598
|
* Returns a clean list of parameters
|
|
2637
2599
|
* Removing Ref and executing function to return the unwrapped value
|
|
2638
2600
|
*/
|
|
2639
2601
|
|
|
2602
|
+
//#endregion
|
|
2603
|
+
//#region src/core/defineRegleConfig.d.ts
|
|
2640
2604
|
/**
|
|
2641
2605
|
* Define a global regle configuration, where you can:
|
|
2642
2606
|
* - Customize built-in rules messages
|
|
@@ -2681,7 +2645,6 @@ declare function extendRegleConfig<TRootCustomRules extends Partial<AllRulesDecl
|
|
|
2681
2645
|
useRegle: useRegleFn<Merge<TRootCustomRules, TCustomRules>, TRootShortcuts & TShortcuts>;
|
|
2682
2646
|
inferRules: inferRulesFn<Merge<TRootCustomRules, TCustomRules>>;
|
|
2683
2647
|
};
|
|
2684
|
-
|
|
2685
2648
|
//#endregion
|
|
2686
2649
|
//#region src/core/mergeRegles.d.ts
|
|
2687
2650
|
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 +2692,6 @@ type MergedReglesResult<TRegles extends Record<string, SuperCompatibleRegleRoot>
|
|
|
2729
2692
|
}>['data'] };
|
|
2730
2693
|
};
|
|
2731
2694
|
declare function mergeRegles<TRegles extends Record<string, SuperCompatibleRegleRoot>, TScoped extends boolean = false>(regles: TRegles, _scoped?: TScoped): TScoped extends false ? MergedRegles<TRegles> : MergedScopedRegles;
|
|
2732
|
-
|
|
2733
2695
|
//#endregion
|
|
2734
2696
|
//#region src/core/createScopedUseRegle/useCollectScope.d.ts
|
|
2735
2697
|
type useCollectScopeFn<TNamedScoped extends boolean = false> = TNamedScoped extends true ? <const TValue extends Record<string, Record<string, any>>>(namespace?: MaybeRefOrGetter<string>) => {
|
|
@@ -2737,7 +2699,6 @@ type useCollectScopeFn<TNamedScoped extends boolean = false> = TNamedScoped exte
|
|
|
2737
2699
|
} : <TValue extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?: MaybeRefOrGetter<string>) => {
|
|
2738
2700
|
r$: MergedScopedRegles<TValue>;
|
|
2739
2701
|
};
|
|
2740
|
-
|
|
2741
2702
|
//#endregion
|
|
2742
2703
|
//#region src/core/createScopedUseRegle/useScopedRegle.d.ts
|
|
2743
2704
|
type UseScopedRegleOptions<TAsRecord extends boolean> = {
|
|
@@ -2745,7 +2706,6 @@ type UseScopedRegleOptions<TAsRecord extends boolean> = {
|
|
|
2745
2706
|
} & (TAsRecord extends true ? {
|
|
2746
2707
|
scopeKey: string;
|
|
2747
2708
|
} : {});
|
|
2748
|
-
|
|
2749
2709
|
//#endregion
|
|
2750
2710
|
//#region src/core/createScopedUseRegle/createScopedUseRegle.d.ts
|
|
2751
2711
|
type CreateScopedUseRegleOptions<TCustomRegle extends useRegleFn<any, any>, TAsRecord extends boolean> = {
|
|
@@ -2772,13 +2732,13 @@ declare function createScopedUseRegle<TCustomRegle extends useRegleFn<any, any>
|
|
|
2772
2732
|
useScopedRegle: TReturnedRegle;
|
|
2773
2733
|
useCollectScope: useCollectScopeFn<TAsRecord>;
|
|
2774
2734
|
};
|
|
2775
|
-
declare const useCollectScope: <TValue extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?:
|
|
2735
|
+
declare const useCollectScope: <TValue extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?: vue1.MaybeRefOrGetter<string>) => {
|
|
2776
2736
|
r$: MergedScopedRegles<TValue>;
|
|
2777
2737
|
}, useScopedRegle: useRegleFn<Partial<AllRulesDeclarations>, never, {
|
|
2778
2738
|
dispose: () => void;
|
|
2779
2739
|
register: () => void;
|
|
2780
2740
|
}, {
|
|
2781
|
-
namespace?:
|
|
2741
|
+
namespace?: vue1.MaybeRefOrGetter<string>;
|
|
2782
2742
|
}>;
|
|
2783
2743
|
//#endregion
|
|
2784
2744
|
//#region src/core/createVariant.d.ts
|
|
@@ -2829,7 +2789,6 @@ declare function narrowVariant<TRoot extends {
|
|
|
2829
2789
|
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
2790
|
$value: infer V;
|
|
2831
2791
|
} ? V : unknown)>(root: MaybeRef<TRoot>, discriminantKey: TKey, discriminantValue: TValue): Ref<Extract<TRoot['$fields'], { [K in TKey]: RegleFieldStatus<TValue, any, any> }> | undefined>;
|
|
2832
|
-
|
|
2833
2792
|
//#endregion
|
|
2834
2793
|
//#region src/core/refineRules.d.ts
|
|
2835
2794
|
/**
|
|
@@ -2858,6 +2817,5 @@ declare function defineRules<TRules extends RegleUnknownRulesTree>(rules: TRules
|
|
|
2858
2817
|
* ```
|
|
2859
2818
|
*/
|
|
2860
2819
|
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
2820
|
//#endregion
|
|
2863
2821
|
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, RegleCustomCollectionStatus, RegleCustomFieldStatus, RegleCustomStatus, RegleEnforceCustomRequiredRules, RegleEnforceRequiredRules, RegleErrorTree, RegleExternalCollectionErrors, RegleExternalErrorTree, 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 };
|
package/dist/regle-core.js
CHANGED
|
@@ -89,11 +89,11 @@ function merge(obj1, ...objs) {
|
|
|
89
89
|
*/
|
|
90
90
|
function toDate(argument) {
|
|
91
91
|
const argStr = Object.prototype.toString.call(argument);
|
|
92
|
-
if (argument == null) return new Date(NaN);
|
|
92
|
+
if (argument == null) return /* @__PURE__ */ new Date(NaN);
|
|
93
93
|
else if (argument instanceof Date || typeof argument === "object" && argStr === "[object Date]") return new Date(argument.getTime());
|
|
94
94
|
else if (typeof argument === "number" || argStr === "[object Number]") return new Date(argument);
|
|
95
95
|
else if (typeof argument === "string" || argStr === "[object String]") return new Date(argument);
|
|
96
|
-
else return new Date(NaN);
|
|
96
|
+
else return /* @__PURE__ */ new Date(NaN);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
//#endregion
|
|
@@ -337,12 +337,12 @@ function createRule(definition) {
|
|
|
337
337
|
* Inspired by Vuelidate storage
|
|
338
338
|
*/
|
|
339
339
|
function useStorage() {
|
|
340
|
-
const ruleDeclStorage = shallowRef(new Map());
|
|
341
|
-
const fieldsStorage = shallowRef(new Map());
|
|
342
|
-
const collectionsStorage = shallowRef(new Map());
|
|
343
|
-
const dirtyStorage = shallowRef(new Map());
|
|
344
|
-
const ruleStatusStorage = shallowRef(new Map());
|
|
345
|
-
const arrayStatusStorage = shallowRef(new Map());
|
|
340
|
+
const ruleDeclStorage = shallowRef(/* @__PURE__ */ new Map());
|
|
341
|
+
const fieldsStorage = shallowRef(/* @__PURE__ */ new Map());
|
|
342
|
+
const collectionsStorage = shallowRef(/* @__PURE__ */ new Map());
|
|
343
|
+
const dirtyStorage = shallowRef(/* @__PURE__ */ new Map());
|
|
344
|
+
const ruleStatusStorage = shallowRef(/* @__PURE__ */ new Map());
|
|
345
|
+
const arrayStatusStorage = shallowRef(/* @__PURE__ */ new Map());
|
|
346
346
|
function getFieldsEntry($path) {
|
|
347
347
|
const existingFields = fieldsStorage.value.get($path);
|
|
348
348
|
if (existingFields) return existingFields;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regle/core",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Headless form validation library for Vue 3",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"pinia": ">=2.2.5",
|
|
@@ -13,20 +13,20 @@
|
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@total-typescript/ts-reset": "0.6.1",
|
|
16
|
-
"@types/node": "22.15.
|
|
16
|
+
"@types/node": "22.15.29",
|
|
17
17
|
"@typescript-eslint/eslint-plugin": "8.28.0",
|
|
18
18
|
"@typescript-eslint/parser": "8.28.0",
|
|
19
19
|
"@vue/test-utils": "2.4.6",
|
|
20
|
-
"eslint": "9.
|
|
21
|
-
"eslint-config-prettier": "
|
|
22
|
-
"eslint-plugin-vue": "
|
|
20
|
+
"eslint": "9.28.0",
|
|
21
|
+
"eslint-config-prettier": "10.1.5",
|
|
22
|
+
"eslint-plugin-vue": "10.1.0",
|
|
23
23
|
"expect-type": "1.2.1",
|
|
24
24
|
"prettier": "3.5.3",
|
|
25
|
-
"tsdown": "0.12.
|
|
26
|
-
"type-fest": "4.
|
|
25
|
+
"tsdown": "0.12.7",
|
|
26
|
+
"type-fest": "4.41.0",
|
|
27
27
|
"typescript": "5.8.3",
|
|
28
|
-
"vitest": "3.
|
|
29
|
-
"vue": "3.5.
|
|
28
|
+
"vitest": "3.2.2",
|
|
29
|
+
"vue": "3.5.16",
|
|
30
30
|
"vue-eslint-parser": "10.1.3",
|
|
31
31
|
"vue-tsc": "2.2.10"
|
|
32
32
|
},
|