@regle/core 1.3.0 → 1.3.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 +85 -128
- 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
|
|
@@ -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
|
-
// Should never happen
|
|
659
|
+
/**
|
|
660
|
+
An if-else-like type that resolves depending on whether the given type is `any` or `never`.
|
|
679
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'
|
|
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
|
/**
|
|
@@ -1886,7 +1865,6 @@ type RegleCustomStatus<T extends useRegleFn<any, any>, TState extends Record<str
|
|
|
1886
1865
|
* Extract custom rules and custom shortcuts and apply them to a RegleFieldStatus type
|
|
1887
1866
|
*/
|
|
1888
1867
|
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
1868
|
//#endregion
|
|
1891
1869
|
//#region src/types/utils/object.types.d.ts
|
|
1892
1870
|
type RemoveCommonKey<T extends readonly any[], K extends PropertyKey> = T extends [infer F, ...infer R] ? [Prettify<Omit<F, K>>, ...RemoveCommonKey<R, K>] : [];
|
|
@@ -1914,12 +1892,12 @@ type RetrieveUnionUnknownKeysOf<T extends readonly any[]> = T extends [infer F,
|
|
|
1914
1892
|
/**
|
|
1915
1893
|
* Transforms a union and apply undefined values to non-present keys to support intersection
|
|
1916
1894
|
*/
|
|
1917
|
-
type NormalizeUnion<TUnion> = RetrieveUnionUnknownValues<NonNullable<UnionToTuple
|
|
1895
|
+
type NormalizeUnion<TUnion> = RetrieveUnionUnknownValues<NonNullable<UnionToTuple<TUnion>>, RetrieveUnionUnknownKeysOf<NonNullable<UnionToTuple<TUnion>>>[number]>[number];
|
|
1918
1896
|
/**
|
|
1919
1897
|
* Combine all members of a union type, merging types for each key, and keeping loose types
|
|
1920
1898
|
*/
|
|
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
|
|
1899
|
+
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;
|
|
1900
|
+
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
1901
|
type EnumLike = {
|
|
1924
1902
|
[k: string]: string | number;
|
|
1925
1903
|
[nu: number]: string;
|
|
@@ -1927,15 +1905,13 @@ type EnumLike = {
|
|
|
1927
1905
|
type enumType<T extends Record<string, unknown>> = T[keyof T];
|
|
1928
1906
|
type UnwrapMaybeRef<T extends MaybeRef<any> | DeepReactiveState<any>> = T extends Ref<any> ? UnwrapRef<T> : UnwrapNestedRefs<T>;
|
|
1929
1907
|
type TupleToPlainObj<T> = { [I in keyof T & `${number}`]: T[I] };
|
|
1930
|
-
|
|
1931
1908
|
//#endregion
|
|
1932
1909
|
//#region src/types/utils/mismatch.types.d.ts
|
|
1933
1910
|
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
1911
|
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
1912
|
//#endregion
|
|
1937
1913
|
//#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
|
|
1914
|
+
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
1915
|
type ProcessInputChildren<TRule extends unknown, TMarkMaybe extends boolean> = TRule extends {
|
|
1940
1916
|
$each: RegleCollectionEachRules<any, any>;
|
|
1941
1917
|
} ? 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 +1921,6 @@ type ExtractTypeFromRules<TRules extends RegleRuleDecl<any, any>> = FilterRulesW
|
|
|
1945
1921
|
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
1922
|
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
1923
|
type InferTupleUnionInput<T extends any[]> = T extends [infer F extends ReglePartialRuleTree, ...infer R] ? [InferInput<F, true>, ...InferTupleUnionInput<R>] : [];
|
|
1948
|
-
|
|
1949
1924
|
//#endregion
|
|
1950
1925
|
//#region src/types/rules/rule.params.types.d.ts
|
|
1951
1926
|
type CreateFn<T extends any[]> = (...args: T) => any;
|
|
@@ -1956,7 +1931,6 @@ type CreateFn<T extends any[]> = (...args: T) => any;
|
|
|
1956
1931
|
*/
|
|
1957
1932
|
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
1933
|
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
1934
|
//#endregion
|
|
1961
1935
|
//#region src/types/rules/rule.internal.types.d.ts
|
|
1962
1936
|
/**
|
|
@@ -1979,7 +1953,6 @@ declare const InternalRuleType: {
|
|
|
1979
1953
|
readonly Async: "__async";
|
|
1980
1954
|
};
|
|
1981
1955
|
type InternalRuleType = enumType<typeof InternalRuleType>;
|
|
1982
|
-
|
|
1983
1956
|
//#endregion
|
|
1984
1957
|
//#region src/types/rules/rule.definition.type.d.ts
|
|
1985
1958
|
type IsLiteral<T> = string extends T ? false : true;
|
|
@@ -2068,7 +2041,6 @@ type RegleCollectionRuleDefinition<TValue = any[], TCustomRules extends Partial<
|
|
|
2068
2041
|
}) | ({
|
|
2069
2042
|
$each: MaybeGetter<RegleFormPropertyType<ArrayElement<NonNullable<TValue>>, TCustomRules>, ArrayElement<TValue>>;
|
|
2070
2043
|
} & CollectionRegleBehaviourOptions);
|
|
2071
|
-
|
|
2072
2044
|
//#endregion
|
|
2073
2045
|
//#region src/types/rules/rule.init.types.d.ts
|
|
2074
2046
|
type RegleInitPropertyGetter<TValue, TReturn, TParams extends [...any[]], TMetadata extends RegleRuleMetadataDefinition> = TReturn | ((metadata: RegleRuleMetadataConsumer<TValue, TParams, TMetadata>) => TReturn);
|
|
@@ -2104,7 +2076,6 @@ type RegleRuleTypeReturn<TValue, TParams extends [...any[]]> = {
|
|
|
2104
2076
|
value: TValue;
|
|
2105
2077
|
params: [...TParams];
|
|
2106
2078
|
};
|
|
2107
|
-
|
|
2108
2079
|
//#endregion
|
|
2109
2080
|
//#region src/core/defaultValidators.d.ts
|
|
2110
2081
|
interface CommonComparisonOptions {
|
|
@@ -2170,7 +2141,6 @@ type DefaultValidators = {
|
|
|
2170
2141
|
startsWith: RegleRuleWithParamsDefinition<string, [part: Maybe<string>], false, boolean>;
|
|
2171
2142
|
url: RegleRuleDefinition<string, [], false, boolean, string>;
|
|
2172
2143
|
};
|
|
2173
|
-
|
|
2174
2144
|
//#endregion
|
|
2175
2145
|
//#region src/types/rules/rule.custom.types.d.ts
|
|
2176
2146
|
type CustomRulesDeclarationTree = {
|
|
@@ -2178,7 +2148,6 @@ type CustomRulesDeclarationTree = {
|
|
|
2178
2148
|
};
|
|
2179
2149
|
type DefaultValidatorsTree = { [K in keyof DefaultValidators]: RegleRuleRawInput<any, any[], boolean, any> | undefined };
|
|
2180
2150
|
type AllRulesDeclarations = CustomRulesDeclarationTree & DefaultValidatorsTree;
|
|
2181
|
-
|
|
2182
2151
|
//#endregion
|
|
2183
2152
|
//#region src/types/rules/rule.declaration.types.d.ts
|
|
2184
2153
|
/**
|
|
@@ -2261,7 +2230,6 @@ type InlineRuleDeclaration<TValue extends any = any, TParams extends any[] = any
|
|
|
2261
2230
|
* Regroup inline and registered rules
|
|
2262
2231
|
* */
|
|
2263
2232
|
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
2233
|
//#endregion
|
|
2266
2234
|
//#region src/types/rules/rule.errors.types.d.ts
|
|
2267
2235
|
type RegleErrorTree<TState = MaybeRef<Record<string, any> | any[]>> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>]: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>[K], false> };
|
|
@@ -2287,7 +2255,6 @@ type $InternalRegleErrorTree = {
|
|
|
2287
2255
|
* @internal
|
|
2288
2256
|
*/
|
|
2289
2257
|
type $InternalRegleErrors = $InternalRegleCollectionErrors | string[] | $InternalRegleErrorTree;
|
|
2290
|
-
|
|
2291
2258
|
//#endregion
|
|
2292
2259
|
//#region src/types/rules/rule.status.types.d.ts
|
|
2293
2260
|
/**
|
|
@@ -2467,7 +2434,7 @@ type RegleRuleStatus<TValue = any, TParams extends any[] = any[], TMetadata exte
|
|
|
2467
2434
|
/** Reset the $valid, $metadata and $pending states */
|
|
2468
2435
|
$reset(): void;
|
|
2469
2436
|
/** Returns the original rule validator function. */
|
|
2470
|
-
$validator: ((value: IsUnknown
|
|
2437
|
+
$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
2438
|
} & ([TParams] extends [never[]] ? {} : [unknown[]] extends [TParams] ? {
|
|
2472
2439
|
readonly $params?: any[];
|
|
2473
2440
|
} : {
|
|
@@ -2538,7 +2505,6 @@ interface $InternalRegleCollectionStatus extends Omit<$InternalRegleStatus, '$fi
|
|
|
2538
2505
|
$extractDirtyFields: (filterNullishValues?: boolean) => any[];
|
|
2539
2506
|
$validate: () => Promise<$InternalRegleResult>;
|
|
2540
2507
|
}
|
|
2541
|
-
|
|
2542
2508
|
//#endregion
|
|
2543
2509
|
//#region src/types/rules/compatibility.rules.d.ts
|
|
2544
2510
|
interface SuperCompatibleRegle {
|
|
@@ -2586,7 +2552,6 @@ interface SuperCompatibleRegleCollectionStatus extends Omit<SuperCompatibleRegle
|
|
|
2586
2552
|
$validate?: () => Promise<SuperCompatibleRegleResult>;
|
|
2587
2553
|
}
|
|
2588
2554
|
type SuperCompatibleRegleCollectionErrors = $InternalRegleCollectionErrors;
|
|
2589
|
-
|
|
2590
2555
|
//#endregion
|
|
2591
2556
|
//#region src/core/createRule/createRule.d.ts
|
|
2592
2557
|
/**
|
|
@@ -2621,7 +2586,6 @@ type SuperCompatibleRegleCollectionErrors = $InternalRegleCollectionErrors;
|
|
|
2621
2586
|
* Docs: {@link https://reglejs.dev/core-concepts/rules/reusable-rules}
|
|
2622
2587
|
*/
|
|
2623
2588
|
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
2589
|
//#endregion
|
|
2626
2590
|
//#region src/core/createRule/unwrapRuleParameters.d.ts
|
|
2627
2591
|
/**
|
|
@@ -2629,14 +2593,13 @@ declare function createRule<TValue extends any, TParams extends any[], TReturn e
|
|
|
2629
2593
|
* Removing Ref and executing function to return the unwrapped value
|
|
2630
2594
|
*/
|
|
2631
2595
|
declare function unwrapRuleParameters<TParams extends any[]>(params: MaybeRefOrGetter[]): TParams;
|
|
2632
|
-
|
|
2633
|
-
//#endregion
|
|
2634
|
-
//#region src/core/defineRegleConfig.d.ts
|
|
2635
2596
|
/**
|
|
2636
2597
|
* Returns a clean list of parameters
|
|
2637
2598
|
* Removing Ref and executing function to return the unwrapped value
|
|
2638
2599
|
*/
|
|
2639
2600
|
|
|
2601
|
+
//#endregion
|
|
2602
|
+
//#region src/core/defineRegleConfig.d.ts
|
|
2640
2603
|
/**
|
|
2641
2604
|
* Define a global regle configuration, where you can:
|
|
2642
2605
|
* - Customize built-in rules messages
|
|
@@ -2681,7 +2644,6 @@ declare function extendRegleConfig<TRootCustomRules extends Partial<AllRulesDecl
|
|
|
2681
2644
|
useRegle: useRegleFn<Merge<TRootCustomRules, TCustomRules>, TRootShortcuts & TShortcuts>;
|
|
2682
2645
|
inferRules: inferRulesFn<Merge<TRootCustomRules, TCustomRules>>;
|
|
2683
2646
|
};
|
|
2684
|
-
|
|
2685
2647
|
//#endregion
|
|
2686
2648
|
//#region src/core/mergeRegles.d.ts
|
|
2687
2649
|
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 +2691,6 @@ type MergedReglesResult<TRegles extends Record<string, SuperCompatibleRegleRoot>
|
|
|
2729
2691
|
}>['data'] };
|
|
2730
2692
|
};
|
|
2731
2693
|
declare function mergeRegles<TRegles extends Record<string, SuperCompatibleRegleRoot>, TScoped extends boolean = false>(regles: TRegles, _scoped?: TScoped): TScoped extends false ? MergedRegles<TRegles> : MergedScopedRegles;
|
|
2732
|
-
|
|
2733
2694
|
//#endregion
|
|
2734
2695
|
//#region src/core/createScopedUseRegle/useCollectScope.d.ts
|
|
2735
2696
|
type useCollectScopeFn<TNamedScoped extends boolean = false> = TNamedScoped extends true ? <const TValue extends Record<string, Record<string, any>>>(namespace?: MaybeRefOrGetter<string>) => {
|
|
@@ -2737,7 +2698,6 @@ type useCollectScopeFn<TNamedScoped extends boolean = false> = TNamedScoped exte
|
|
|
2737
2698
|
} : <TValue extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?: MaybeRefOrGetter<string>) => {
|
|
2738
2699
|
r$: MergedScopedRegles<TValue>;
|
|
2739
2700
|
};
|
|
2740
|
-
|
|
2741
2701
|
//#endregion
|
|
2742
2702
|
//#region src/core/createScopedUseRegle/useScopedRegle.d.ts
|
|
2743
2703
|
type UseScopedRegleOptions<TAsRecord extends boolean> = {
|
|
@@ -2745,7 +2705,6 @@ type UseScopedRegleOptions<TAsRecord extends boolean> = {
|
|
|
2745
2705
|
} & (TAsRecord extends true ? {
|
|
2746
2706
|
scopeKey: string;
|
|
2747
2707
|
} : {});
|
|
2748
|
-
|
|
2749
2708
|
//#endregion
|
|
2750
2709
|
//#region src/core/createScopedUseRegle/createScopedUseRegle.d.ts
|
|
2751
2710
|
type CreateScopedUseRegleOptions<TCustomRegle extends useRegleFn<any, any>, TAsRecord extends boolean> = {
|
|
@@ -2772,13 +2731,13 @@ declare function createScopedUseRegle<TCustomRegle extends useRegleFn<any, any>
|
|
|
2772
2731
|
useScopedRegle: TReturnedRegle;
|
|
2773
2732
|
useCollectScope: useCollectScopeFn<TAsRecord>;
|
|
2774
2733
|
};
|
|
2775
|
-
declare const useCollectScope: <TValue extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?:
|
|
2734
|
+
declare const useCollectScope: <TValue extends Record<string, unknown>[] = Record<string, unknown>[]>(namespace?: vue1.MaybeRefOrGetter<string>) => {
|
|
2776
2735
|
r$: MergedScopedRegles<TValue>;
|
|
2777
2736
|
}, useScopedRegle: useRegleFn<Partial<AllRulesDeclarations>, never, {
|
|
2778
2737
|
dispose: () => void;
|
|
2779
2738
|
register: () => void;
|
|
2780
2739
|
}, {
|
|
2781
|
-
namespace?:
|
|
2740
|
+
namespace?: vue1.MaybeRefOrGetter<string>;
|
|
2782
2741
|
}>;
|
|
2783
2742
|
//#endregion
|
|
2784
2743
|
//#region src/core/createVariant.d.ts
|
|
@@ -2829,7 +2788,6 @@ declare function narrowVariant<TRoot extends {
|
|
|
2829
2788
|
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
2789
|
$value: infer V;
|
|
2831
2790
|
} ? V : unknown)>(root: MaybeRef<TRoot>, discriminantKey: TKey, discriminantValue: TValue): Ref<Extract<TRoot['$fields'], { [K in TKey]: RegleFieldStatus<TValue, any, any> }> | undefined>;
|
|
2832
|
-
|
|
2833
2791
|
//#endregion
|
|
2834
2792
|
//#region src/core/refineRules.d.ts
|
|
2835
2793
|
/**
|
|
@@ -2858,6 +2816,5 @@ declare function defineRules<TRules extends RegleUnknownRulesTree>(rules: TRules
|
|
|
2858
2816
|
* ```
|
|
2859
2817
|
*/
|
|
2860
2818
|
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
2819
|
//#endregion
|
|
2863
2820
|
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.1",
|
|
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
|
},
|