@regle/schemas 1.9.4 → 1.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/regle-schemas.d.ts +72 -56
- package/dist/regle-schemas.js +6 -5
- package/dist/regle-schemas.min.js +1 -1
- package/package.json +10 -10
package/dist/regle-schemas.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ type NoInferLegacy<A extends any> = [A][A extends any ? 0 : never];
|
|
|
24
24
|
//#region src/types/utils/Array.types.d.ts
|
|
25
25
|
type ArrayElement<T> = T extends Array<infer U> ? U : never;
|
|
26
26
|
//#endregion
|
|
27
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
27
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/primitive.d.ts
|
|
28
28
|
/**
|
|
29
29
|
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
30
30
|
|
|
@@ -32,7 +32,7 @@ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/
|
|
|
32
32
|
*/
|
|
33
33
|
type Primitive$1 = null | undefined | string | number | boolean | symbol | bigint;
|
|
34
34
|
//#endregion
|
|
35
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
35
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/union-to-intersection.d.ts
|
|
36
36
|
/**
|
|
37
37
|
Convert a union type to an intersection type using [distributive conditional types](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
38
38
|
|
|
@@ -91,10 +91,10 @@ Union extends unknown
|
|
|
91
91
|
// Infer the `Intersection` type since TypeScript represents the positional
|
|
92
92
|
// arguments of unions of functions as an intersection of the union.
|
|
93
93
|
) extends ((mergedIntersection: infer Intersection) => void)
|
|
94
|
-
// The `& Union` is to
|
|
94
|
+
// The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
|
|
95
95
|
? Intersection & Union : never;
|
|
96
96
|
//#endregion
|
|
97
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
97
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/empty-object.d.ts
|
|
98
98
|
declare const emptyObjectSymbol$1: unique symbol;
|
|
99
99
|
|
|
100
100
|
/**
|
|
@@ -143,7 +143,7 @@ type Fail = IsEmptyObject<null>; //=> false
|
|
|
143
143
|
*/
|
|
144
144
|
type IsEmptyObject<T> = T extends EmptyObject$1 ? true : false;
|
|
145
145
|
//#endregion
|
|
146
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
146
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/is-any.d.ts
|
|
147
147
|
/**
|
|
148
148
|
Returns a boolean for whether the given type is `any`.
|
|
149
149
|
|
|
@@ -174,7 +174,7 @@ const anyA = get(anyObject, 'a');
|
|
|
174
174
|
*/
|
|
175
175
|
type IsAny$1<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
176
176
|
//#endregion
|
|
177
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
177
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
178
178
|
/**
|
|
179
179
|
Returns a boolean for whether the given key is an optional key of type.
|
|
180
180
|
|
|
@@ -217,7 +217,7 @@ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
|
217
217
|
*/
|
|
218
218
|
type IsOptionalKeyOf$1<Type extends object, Key extends keyof Type> = IsAny$1<Type | Key> extends true ? never : Key extends keyof Type ? Type extends Record<Key, Type[Key]> ? false : true : false;
|
|
219
219
|
//#endregion
|
|
220
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
220
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/optional-keys-of.d.ts
|
|
221
221
|
/**
|
|
222
222
|
Extract all optional keys from the given type.
|
|
223
223
|
|
|
@@ -255,7 +255,7 @@ type OptionalKeysOf$1<Type extends object> = Type extends unknown // For distrib
|
|
|
255
255
|
? (keyof { [Key in keyof Type as IsOptionalKeyOf$1<Type, Key> extends false ? never : Key]: never }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
|
|
256
256
|
: never;
|
|
257
257
|
//#endregion
|
|
258
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
258
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/required-keys-of.d.ts
|
|
259
259
|
/**
|
|
260
260
|
Extract all required keys from the given type.
|
|
261
261
|
|
|
@@ -283,7 +283,7 @@ const validator2 = createValidation<User>('surname', value => value.length < 25)
|
|
|
283
283
|
type RequiredKeysOf$1<Type extends object> = Type extends unknown // For distributing `Type`
|
|
284
284
|
? Exclude<keyof Type, OptionalKeysOf$1<Type>> : never;
|
|
285
285
|
//#endregion
|
|
286
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
286
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/is-never.d.ts
|
|
287
287
|
/**
|
|
288
288
|
Returns a boolean for whether the given type is `never`.
|
|
289
289
|
|
|
@@ -327,7 +327,7 @@ endIfEqual('abc', '123');
|
|
|
327
327
|
*/
|
|
328
328
|
type IsNever$1<T> = [T] extends [never] ? true : false;
|
|
329
329
|
//#endregion
|
|
330
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
330
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/if.d.ts
|
|
331
331
|
/**
|
|
332
332
|
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
333
333
|
|
|
@@ -387,7 +387,7 @@ type B = IfEqual<string, number, 'equal', 'not equal'>;
|
|
|
387
387
|
*/
|
|
388
388
|
type If$1<Type extends boolean, IfBranch, ElseBranch> = IsNever$1<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
|
|
389
389
|
//#endregion
|
|
390
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
390
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/internal/type.d.ts
|
|
391
391
|
/**
|
|
392
392
|
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
393
393
|
*/
|
|
@@ -400,7 +400,10 @@ Needed to handle the case of a single call signature with properties.
|
|
|
400
400
|
Multiple call signatures cannot currently be supported due to a TypeScript limitation.
|
|
401
401
|
@see https://github.com/microsoft/TypeScript/issues/29732
|
|
402
402
|
*/
|
|
403
|
-
|
|
403
|
+
type HasMultipleCallSignatures$1<T extends (...arguments_: any[]) => unknown> = T extends {
|
|
404
|
+
(...arguments_: infer A): unknown;
|
|
405
|
+
(...arguments_: infer B): unknown;
|
|
406
|
+
} ? B extends A ? A extends B ? false : true : true : false;
|
|
404
407
|
/**
|
|
405
408
|
An if-else-like type that resolves depending on whether the given type is `any` or `never`.
|
|
406
409
|
|
|
@@ -421,7 +424,7 @@ type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
|
421
424
|
*/
|
|
422
425
|
type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> = If$1<IsAny$1<T>, IfAny, If$1<IsNever$1<T>, IfNever, IfNotAnyOrNever>>;
|
|
423
426
|
//#endregion
|
|
424
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
427
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/is-null.d.ts
|
|
425
428
|
/**
|
|
426
429
|
Returns a boolean for whether the given type is `null`.
|
|
427
430
|
|
|
@@ -443,7 +446,7 @@ type Example2 = NonNullFallback<number, string>;
|
|
|
443
446
|
*/
|
|
444
447
|
type IsNull<T> = [T] extends [null] ? true : false;
|
|
445
448
|
//#endregion
|
|
446
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
449
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/is-unknown.d.ts
|
|
447
450
|
/**
|
|
448
451
|
Returns a boolean for whether the given type is `unknown`.
|
|
449
452
|
|
|
@@ -491,7 +494,13 @@ type IsUnknown<T> = (unknown extends T // `T` can be `unknown` or `any`
|
|
|
491
494
|
? IsNull<T> extends false // `any` can be `null`, but `unknown` can't be
|
|
492
495
|
? true : false : false);
|
|
493
496
|
//#endregion
|
|
494
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
497
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/internal/keys.d.ts
|
|
498
|
+
/**
|
|
499
|
+
Disallows any of the given keys.
|
|
500
|
+
*/
|
|
501
|
+
type RequireNone<KeysType extends PropertyKey> = Partial<Record<KeysType, never>>;
|
|
502
|
+
//#endregion
|
|
503
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/simplify.d.ts
|
|
495
504
|
/**
|
|
496
505
|
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.
|
|
497
506
|
|
|
@@ -551,7 +560,7 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
|
|
|
551
560
|
*/
|
|
552
561
|
type Simplify$1<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
553
562
|
//#endregion
|
|
554
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
563
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
555
564
|
/**
|
|
556
565
|
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
557
566
|
|
|
@@ -644,7 +653,7 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
|
644
653
|
*/
|
|
645
654
|
type OmitIndexSignature$1<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
646
655
|
//#endregion
|
|
647
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
656
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/pick-index-signature.d.ts
|
|
648
657
|
/**
|
|
649
658
|
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
650
659
|
|
|
@@ -692,7 +701,7 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
692
701
|
*/
|
|
693
702
|
type PickIndexSignature$1<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
694
703
|
//#endregion
|
|
695
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
704
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/merge.d.ts
|
|
696
705
|
// Merges two objects without worrying about index signatures.
|
|
697
706
|
type SimpleMerge$1<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source;
|
|
698
707
|
|
|
@@ -732,7 +741,7 @@ export type FooBar = Merge<Foo, Bar>;
|
|
|
732
741
|
*/
|
|
733
742
|
type Merge$1<Destination, Source> = Simplify$1<SimpleMerge$1<PickIndexSignature$1<Destination>, PickIndexSignature$1<Source>> & SimpleMerge$1<OmitIndexSignature$1<Destination>, OmitIndexSignature$1<Source>>>;
|
|
734
743
|
//#endregion
|
|
735
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
744
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/internal/object.d.ts
|
|
736
745
|
/**
|
|
737
746
|
Merges user specified options with default options.
|
|
738
747
|
|
|
@@ -787,7 +796,7 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
|
|
|
787
796
|
*/
|
|
788
797
|
type ApplyDefaultOptions$1<Options extends object, Defaults extends Simplify$1<Omit<Required<Options>, RequiredKeysOf$1<Options>> & Partial<Record<RequiredKeysOf$1<Options>, never>>>, SpecifiedOptions extends Options> = If$1<IsAny$1<SpecifiedOptions>, Defaults, If$1<IsNever$1<SpecifiedOptions>, Defaults, Simplify$1<Merge$1<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf$1<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
|
|
789
798
|
//#endregion
|
|
790
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
799
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/or.d.ts
|
|
791
800
|
/**
|
|
792
801
|
Returns a boolean for whether either of two given types are true.
|
|
793
802
|
|
|
@@ -867,13 +876,7 @@ type Or<A extends boolean, B extends boolean> = _Or<If$1<IsNever$1<A>, false, A>
|
|
|
867
876
|
|
|
868
877
|
type _Or<A extends boolean, B extends boolean> = A extends true ? true : B extends true ? true : false;
|
|
869
878
|
//#endregion
|
|
870
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
871
|
-
/**
|
|
872
|
-
Disallows any of the given keys.
|
|
873
|
-
*/
|
|
874
|
-
type RequireNone<KeysType extends PropertyKey> = Partial<Record<KeysType, never>>;
|
|
875
|
-
//#endregion
|
|
876
|
-
//#region ../../node_modules/.pnpm/type-fest@5.0.0/node_modules/type-fest/source/require-exactly-one.d.ts
|
|
879
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/require-exactly-one.d.ts
|
|
877
880
|
/**
|
|
878
881
|
Create a type that requires exactly one of the given keys and disallows more. The remaining keys are kept as is.
|
|
879
882
|
|
|
@@ -906,7 +909,7 @@ const responder: RequireExactlyOne<Responder, 'text' | 'json'> = {
|
|
|
906
909
|
type RequireExactlyOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, If$1<IsNever$1<KeysType>, never, _RequireExactlyOne<ObjectType, If$1<IsAny$1<KeysType>, keyof ObjectType, KeysType>>>>;
|
|
907
910
|
type _RequireExactlyOne<ObjectType, KeysType extends keyof ObjectType> = { [Key in KeysType]: (Required<Pick<ObjectType, Key>> & Partial<Record<Exclude<KeysType, Key>, never>>) }[KeysType] & Omit<ObjectType, KeysType>;
|
|
908
911
|
//#endregion
|
|
909
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
912
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/require-one-or-none.d.ts
|
|
910
913
|
/**
|
|
911
914
|
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.
|
|
912
915
|
|
|
@@ -940,7 +943,7 @@ const responder3: Responder = {
|
|
|
940
943
|
type RequireOneOrNone<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = IfNotAnyOrNever<ObjectType, If$1<IsNever$1<KeysType>, ObjectType, _RequireOneOrNone<ObjectType, If$1<IsAny$1<KeysType>, keyof ObjectType, KeysType>>>>;
|
|
941
944
|
type _RequireOneOrNone<ObjectType, KeysType extends keyof ObjectType> = (RequireExactlyOne<ObjectType, KeysType> | RequireNone<KeysType>) & Omit<ObjectType, KeysType>; // Ignore unspecified keys.
|
|
942
945
|
//#endregion
|
|
943
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
946
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/is-union.d.ts
|
|
944
947
|
/**
|
|
945
948
|
Returns a boolean for whether the given type is a union.
|
|
946
949
|
|
|
@@ -958,7 +961,7 @@ type B = IsUnion<string>;
|
|
|
958
961
|
|
|
959
962
|
// Should never happen
|
|
960
963
|
//#endregion
|
|
961
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
964
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/partial-deep.d.ts
|
|
962
965
|
/**
|
|
963
966
|
@see {@link PartialDeep}
|
|
964
967
|
*/
|
|
@@ -1044,8 +1047,8 @@ partialShape.dimensions = [15]; // OK
|
|
|
1044
1047
|
@category Map
|
|
1045
1048
|
*/
|
|
1046
1049
|
type PartialDeep$1<T, Options extends PartialDeepOptions$1 = {}> = _PartialDeep$1<T, ApplyDefaultOptions$1<PartialDeepOptions$1, DefaultPartialDeepOptions$1, Options>>;
|
|
1047
|
-
type _PartialDeep$1<T, Options extends Required<PartialDeepOptions$1>> = T extends BuiltIns$1 | ((new (...arguments_: any[]) => unknown)) ? T : IsNever$1<keyof T> extends true // For functions with no properties
|
|
1048
|
-
|
|
1050
|
+
type _PartialDeep$1<T, Options extends Required<PartialDeepOptions$1>> = T extends BuiltIns$1 | ((new (...arguments_: any[]) => unknown)) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMapDeep$1<KeyType, ValueType, Options> : T extends Set<infer ItemType> ? PartialSetDeep$1<ItemType, Options> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMapDeep$1<KeyType, ValueType, Options> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySetDeep$1<ItemType, Options> : T extends ((...arguments_: any[]) => unknown) ? IsNever$1<keyof T> extends true ? T // For functions with no properties
|
|
1051
|
+
: HasMultipleCallSignatures$1<T> extends true ? T : ((...arguments_: Parameters<T>) => ReturnType<T>) & PartialObjectDeep$1<T, Options> : T extends object ? T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
|
|
1049
1052
|
? Options['recurseIntoArrays'] extends true ? ItemType[] extends T // Test for arrays (non-tuples) specifically
|
|
1050
1053
|
? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
|
|
1051
1054
|
? ReadonlyArray<_PartialDeep$1<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>> : Array<_PartialDeep$1<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>> : PartialObjectDeep$1<T, Options> // Tuples behave properly
|
|
@@ -1075,9 +1078,9 @@ type PartialReadonlySetDeep$1<T, Options extends Required<PartialDeepOptions$1>>
|
|
|
1075
1078
|
/**
|
|
1076
1079
|
Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
|
|
1077
1080
|
*/
|
|
1078
|
-
type PartialObjectDeep$1<ObjectType extends object, Options extends Required<PartialDeepOptions$1>> =
|
|
1081
|
+
type PartialObjectDeep$1<ObjectType extends object, Options extends Required<PartialDeepOptions$1>> = { [KeyType in keyof ObjectType]?: _PartialDeep$1<ObjectType[KeyType], Options> };
|
|
1079
1082
|
//#endregion
|
|
1080
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1083
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/required-deep.d.ts
|
|
1081
1084
|
/**
|
|
1082
1085
|
Create a type from another type with all keys and nested keys set to required.
|
|
1083
1086
|
|
|
@@ -1121,7 +1124,7 @@ Note that types containing overloaded functions are not made deeply required due
|
|
|
1121
1124
|
*/
|
|
1122
1125
|
|
|
1123
1126
|
//#endregion
|
|
1124
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1127
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/union-to-tuple.d.ts
|
|
1125
1128
|
/**
|
|
1126
1129
|
Returns the last element of a union type.
|
|
1127
1130
|
|
|
@@ -2054,7 +2057,8 @@ type RegleCollectionStatus<TState extends any[] = any[], TRules extends ReglePar
|
|
|
2054
2057
|
type RegleErrorTree<TState = MaybeRef<Record<string, any> | any[]>, TIssue extends boolean = false> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>]: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>[K], false, TIssue> };
|
|
2055
2058
|
type RegleIssuesTree<TState = MaybeRef<Record<string, any> | any[]>> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>]: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>[K], false, true> };
|
|
2056
2059
|
type RegleExternalErrorTree<TState = MaybeRef<Record<string, any> | any[]>> = { readonly [K in keyof JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>]?: RegleValidationErrors<JoinDiscriminatedUnions<UnwrapMaybeRef<TState>>[K], true> };
|
|
2057
|
-
type
|
|
2060
|
+
type ErrorMessageOrIssue<TIssue extends boolean> = TIssue extends true ? RegleFieldIssue[] : string[];
|
|
2061
|
+
type RegleValidationErrors<TState extends Record<string, any> | any[] | unknown = never, TExternal extends boolean = false, TIssue extends boolean = false> = HasNamedKeys<TState> extends true ? IsAny$1<TState> extends true ? any : NonNullable<TState> extends Array<infer U> ? U extends Record<string, any> ? TExternal extends false ? ExtendOnlyRealRecord<U> extends true ? RegleCollectionErrors<U, TIssue> : ErrorMessageOrIssue<TIssue> : RegleExternalCollectionErrors<U, TIssue> : ErrorMessageOrIssue<TIssue> : NonNullable<TState> extends Date | File ? ErrorMessageOrIssue<TIssue> : NonNullable<TState> extends Record<string, any> ? TExternal extends false ? RegleErrorTree<TState, TIssue> : RegleExternalErrorTree<TState> : ErrorMessageOrIssue<TIssue> : any;
|
|
2058
2062
|
type RegleCollectionErrors<TState extends Record<string, any>, TIssue extends boolean = false> = {
|
|
2059
2063
|
readonly $self: TIssue extends true ? RegleFieldIssue[] : string[];
|
|
2060
2064
|
readonly $each: RegleValidationErrors<TState, false, TIssue>[];
|
|
@@ -2193,7 +2197,7 @@ type CreateScopedUseRegleOptions<TCustomRegle extends useRegleFn<any, any>, TAsR
|
|
|
2193
2197
|
asRecord?: TAsRecord;
|
|
2194
2198
|
};
|
|
2195
2199
|
//#endregion
|
|
2196
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2200
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/primitive.d.ts
|
|
2197
2201
|
/**
|
|
2198
2202
|
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
2199
2203
|
|
|
@@ -2201,7 +2205,7 @@ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/
|
|
|
2201
2205
|
*/
|
|
2202
2206
|
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
2203
2207
|
//#endregion
|
|
2204
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2208
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/empty-object.d.ts
|
|
2205
2209
|
declare const emptyObjectSymbol: unique symbol;
|
|
2206
2210
|
|
|
2207
2211
|
/**
|
|
@@ -2234,7 +2238,7 @@ type EmptyObject = {
|
|
|
2234
2238
|
[emptyObjectSymbol]?: never;
|
|
2235
2239
|
};
|
|
2236
2240
|
//#endregion
|
|
2237
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2241
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/is-any.d.ts
|
|
2238
2242
|
/**
|
|
2239
2243
|
Returns a boolean for whether the given type is `any`.
|
|
2240
2244
|
|
|
@@ -2265,7 +2269,7 @@ const anyA = get(anyObject, 'a');
|
|
|
2265
2269
|
*/
|
|
2266
2270
|
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
2267
2271
|
//#endregion
|
|
2268
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2272
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
2269
2273
|
/**
|
|
2270
2274
|
Returns a boolean for whether the given key is an optional key of type.
|
|
2271
2275
|
|
|
@@ -2308,7 +2312,7 @@ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
|
2308
2312
|
*/
|
|
2309
2313
|
type IsOptionalKeyOf<Type extends object, Key extends keyof Type> = IsAny<Type | Key> extends true ? never : Key extends keyof Type ? Type extends Record<Key, Type[Key]> ? false : true : false;
|
|
2310
2314
|
//#endregion
|
|
2311
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2315
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/optional-keys-of.d.ts
|
|
2312
2316
|
/**
|
|
2313
2317
|
Extract all optional keys from the given type.
|
|
2314
2318
|
|
|
@@ -2346,7 +2350,7 @@ type OptionalKeysOf<Type extends object> = Type extends unknown // For distribut
|
|
|
2346
2350
|
? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
|
|
2347
2351
|
: never;
|
|
2348
2352
|
//#endregion
|
|
2349
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2353
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/required-keys-of.d.ts
|
|
2350
2354
|
/**
|
|
2351
2355
|
Extract all required keys from the given type.
|
|
2352
2356
|
|
|
@@ -2374,7 +2378,7 @@ const validator2 = createValidation<User>('surname', value => value.length < 25)
|
|
|
2374
2378
|
type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
2375
2379
|
? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
|
|
2376
2380
|
//#endregion
|
|
2377
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2381
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/is-never.d.ts
|
|
2378
2382
|
/**
|
|
2379
2383
|
Returns a boolean for whether the given type is `never`.
|
|
2380
2384
|
|
|
@@ -2418,7 +2422,7 @@ endIfEqual('abc', '123');
|
|
|
2418
2422
|
*/
|
|
2419
2423
|
type IsNever<T> = [T] extends [never] ? true : false;
|
|
2420
2424
|
//#endregion
|
|
2421
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2425
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/if.d.ts
|
|
2422
2426
|
/**
|
|
2423
2427
|
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
2424
2428
|
|
|
@@ -2478,13 +2482,25 @@ type B = IfEqual<string, number, 'equal', 'not equal'>;
|
|
|
2478
2482
|
*/
|
|
2479
2483
|
type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
|
|
2480
2484
|
//#endregion
|
|
2481
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2485
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/internal/type.d.ts
|
|
2482
2486
|
/**
|
|
2483
2487
|
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
2484
2488
|
*/
|
|
2485
2489
|
type BuiltIns = Primitive | void | Date | RegExp;
|
|
2490
|
+
/**
|
|
2491
|
+
Test if the given function has multiple call signatures.
|
|
2492
|
+
|
|
2493
|
+
Needed to handle the case of a single call signature with properties.
|
|
2494
|
+
|
|
2495
|
+
Multiple call signatures cannot currently be supported due to a TypeScript limitation.
|
|
2496
|
+
@see https://github.com/microsoft/TypeScript/issues/29732
|
|
2497
|
+
*/
|
|
2498
|
+
type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> = T extends {
|
|
2499
|
+
(...arguments_: infer A): unknown;
|
|
2500
|
+
(...arguments_: infer B): unknown;
|
|
2501
|
+
} ? B extends A ? A extends B ? false : true : true : false;
|
|
2486
2502
|
//#endregion
|
|
2487
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2503
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/simplify.d.ts
|
|
2488
2504
|
/**
|
|
2489
2505
|
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.
|
|
2490
2506
|
|
|
@@ -2544,7 +2560,7 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
|
|
|
2544
2560
|
*/
|
|
2545
2561
|
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
2546
2562
|
//#endregion
|
|
2547
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2563
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
2548
2564
|
/**
|
|
2549
2565
|
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
2550
2566
|
|
|
@@ -2637,7 +2653,7 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
|
2637
2653
|
*/
|
|
2638
2654
|
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
2639
2655
|
//#endregion
|
|
2640
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2656
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/pick-index-signature.d.ts
|
|
2641
2657
|
/**
|
|
2642
2658
|
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
2643
2659
|
|
|
@@ -2685,7 +2701,7 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
2685
2701
|
*/
|
|
2686
2702
|
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
2687
2703
|
//#endregion
|
|
2688
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2704
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/merge.d.ts
|
|
2689
2705
|
// Merges two objects without worrying about index signatures.
|
|
2690
2706
|
type SimpleMerge<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source;
|
|
2691
2707
|
|
|
@@ -2725,7 +2741,7 @@ export type FooBar = Merge<Foo, Bar>;
|
|
|
2725
2741
|
*/
|
|
2726
2742
|
type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
2727
2743
|
//#endregion
|
|
2728
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2744
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/internal/object.d.ts
|
|
2729
2745
|
/**
|
|
2730
2746
|
Merges user specified options with default options.
|
|
2731
2747
|
|
|
@@ -2780,7 +2796,7 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
|
|
|
2780
2796
|
*/
|
|
2781
2797
|
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
|
|
2782
2798
|
//#endregion
|
|
2783
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2799
|
+
//#region ../../node_modules/.pnpm/type-fest@5.1.0/node_modules/type-fest/source/partial-deep.d.ts
|
|
2784
2800
|
/**
|
|
2785
2801
|
@see {@link PartialDeep}
|
|
2786
2802
|
*/
|
|
@@ -2866,8 +2882,8 @@ partialShape.dimensions = [15]; // OK
|
|
|
2866
2882
|
@category Map
|
|
2867
2883
|
*/
|
|
2868
2884
|
type PartialDeep<T, Options extends PartialDeepOptions = {}> = _PartialDeep<T, ApplyDefaultOptions<PartialDeepOptions, DefaultPartialDeepOptions, Options>>;
|
|
2869
|
-
type _PartialDeep<T, Options extends Required<PartialDeepOptions>> = T extends BuiltIns | ((new (...arguments_: any[]) => unknown)) ? T : IsNever<keyof T> extends true // For functions with no properties
|
|
2870
|
-
|
|
2885
|
+
type _PartialDeep<T, Options extends Required<PartialDeepOptions>> = T extends BuiltIns | ((new (...arguments_: any[]) => unknown)) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMapDeep<KeyType, ValueType, Options> : T extends Set<infer ItemType> ? PartialSetDeep<ItemType, Options> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMapDeep<KeyType, ValueType, Options> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySetDeep<ItemType, Options> : T extends ((...arguments_: any[]) => unknown) ? IsNever<keyof T> extends true ? T // For functions with no properties
|
|
2886
|
+
: HasMultipleCallSignatures<T> extends true ? T : ((...arguments_: Parameters<T>) => ReturnType<T>) & PartialObjectDeep<T, Options> : T extends object ? T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
|
|
2871
2887
|
? Options['recurseIntoArrays'] extends true ? ItemType[] extends T // Test for arrays (non-tuples) specifically
|
|
2872
2888
|
? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
|
|
2873
2889
|
? ReadonlyArray<_PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>> : Array<_PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>> : PartialObjectDeep<T, Options> // Tuples behave properly
|
|
@@ -2897,7 +2913,7 @@ type PartialReadonlySetDeep<T, Options extends Required<PartialDeepOptions>> = {
|
|
|
2897
2913
|
/**
|
|
2898
2914
|
Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
|
|
2899
2915
|
*/
|
|
2900
|
-
type PartialObjectDeep<ObjectType extends object, Options extends Required<PartialDeepOptions>> =
|
|
2916
|
+
type PartialObjectDeep<ObjectType extends object, Options extends Required<PartialDeepOptions>> = { [KeyType in keyof ObjectType]?: _PartialDeep<ObjectType[KeyType], Options> };
|
|
2901
2917
|
//#endregion
|
|
2902
2918
|
//#region src/types/core.types.d.ts
|
|
2903
2919
|
type RegleSchema<TState extends Record<string, any>, TSchema extends Record<string, any>, TShortcuts extends RegleShortcutDefinition = {}, TAdditionalReturnProperties extends Record<string, any> = {}> = {
|
|
@@ -2956,7 +2972,7 @@ type RegleSchemaStatus<TState extends Record<string, any> = Record<string, any>,
|
|
|
2956
2972
|
/**
|
|
2957
2973
|
* @public
|
|
2958
2974
|
*/
|
|
2959
|
-
type InferRegleSchemaStatusType<TSchema extends unknown, TState extends unknown, TShortcuts extends RegleShortcutDefinition = {}> = NonNullable<TSchema> extends Array<infer A extends Record<string, any
|
|
2975
|
+
type InferRegleSchemaStatusType<TSchema extends unknown, TState extends unknown, TShortcuts extends RegleShortcutDefinition = {}> = NonNullable<TSchema> extends Array<infer A> ? A extends Record<string, any> ? RegleSchemaCollectionStatus<A, TState extends Array<any> ? TState : [], TShortcuts> : RegleSchemaFieldStatus<TSchema, TState, TShortcuts> : NonNullable<TState> extends Date | File ? RegleSchemaFieldStatus<TSchema, TState, TShortcuts> : unknown extends TState ? RegleSchemaFieldStatus<TSchema extends EmptyObject ? unknown : TSchema, TState, TShortcuts> : NonNullable<TSchema> extends Record<string, any> ? RegleSchemaStatus<NonNullable<TState> extends Record<string, any> ? NonNullable<TState> : {}, NonNullable<TSchema>, TShortcuts> : RegleSchemaFieldStatus<TSchema, TState, TShortcuts>;
|
|
2960
2976
|
/**
|
|
2961
2977
|
* @public
|
|
2962
2978
|
*/
|
|
@@ -3028,7 +3044,7 @@ type RegleSchemaBehaviourOptions = {
|
|
|
3028
3044
|
};
|
|
3029
3045
|
//#endregion
|
|
3030
3046
|
//#region src/core/useRegleSchema.d.ts
|
|
3031
|
-
type useRegleSchemaFnOptions<TAdditionalOptions extends Record<string, any>> = Omit<Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<Record<string, any>, {}, never>, 'validationGroups' | 'lazy' | 'rewardEarly'
|
|
3047
|
+
type useRegleSchemaFnOptions<TAdditionalOptions extends Record<string, any>> = Omit<Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<Record<string, any>, {}, never>, 'validationGroups' | 'lazy' | 'rewardEarly'> & RegleSchemaBehaviourOptions & TAdditionalOptions;
|
|
3032
3048
|
interface useRegleSchemaFn<TShortcuts extends RegleShortcutDefinition<any> = never, TAdditionalReturnProperties extends Record<string, any> = {}, TAdditionalOptions extends Record<string, any> = {}> {
|
|
3033
3049
|
<TSchema extends StandardSchemaV1, TState extends StandardSchemaV1.InferInput<TSchema> | undefined>(...params: [state: MaybeRef<PartialDeep<NoInferLegacy<TState>, {
|
|
3034
3050
|
recurseIntoArrays: true;
|
package/dist/regle-schemas.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createScopedUseRegle, useRootStorage } from "@regle/core";
|
|
2
|
-
import { computed, isRef, ref, unref, watch } from "vue";
|
|
2
|
+
import { computed, getCurrentScope, isRef, onScopeDispose, ref, unref, watch } from "vue";
|
|
3
3
|
|
|
4
4
|
//#region ../shared/utils/isFile.ts
|
|
5
5
|
/**
|
|
@@ -216,6 +216,9 @@ function createUseRegleSchemaComposable(options, shortcuts) {
|
|
|
216
216
|
return Promise.reject(e);
|
|
217
217
|
}
|
|
218
218
|
};
|
|
219
|
+
if (getCurrentScope()) onScopeDispose(() => {
|
|
220
|
+
unWatchState();
|
|
221
|
+
});
|
|
219
222
|
return { r$: useRootStorage({
|
|
220
223
|
scopeRules: computed(() => ({})),
|
|
221
224
|
state: processedState,
|
|
@@ -303,11 +306,9 @@ const inferSchema = createInferSchemaHelper();
|
|
|
303
306
|
* - an `inferSchema` helper that can typecheck your custom rules
|
|
304
307
|
*/
|
|
305
308
|
function defineRegleSchemaConfig({ modifiers, shortcuts }) {
|
|
306
|
-
const useRegleSchema$1 = createUseRegleSchemaComposable(modifiers, shortcuts);
|
|
307
|
-
const inferSchema$1 = createInferSchemaHelper();
|
|
308
309
|
return {
|
|
309
|
-
useRegleSchema:
|
|
310
|
-
inferSchema:
|
|
310
|
+
useRegleSchema: createUseRegleSchemaComposable(modifiers, shortcuts),
|
|
311
|
+
inferSchema: createInferSchemaHelper()
|
|
311
312
|
};
|
|
312
313
|
}
|
|
313
314
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createScopedUseRegle as e,useRootStorage as t}from"@regle/core";import{computed as n,
|
|
1
|
+
import{createScopedUseRegle as e,useRootStorage as t}from"@regle/core";import{computed as n,getCurrentScope as r,isRef as i,onScopeDispose as a,ref as o,unref as s,watch as c}from"vue";function l(e){return e?.constructor.name==`File`||e?.constructor.name==`FileList`}function u(e,t=!0){return e==null?!0:e instanceof Date?isNaN(e.getTime()):l(e)?e.size<=0:Array.isArray(e)?t?e.length===0:!1:typeof e==`object`&&e?Object.keys(e).length===0:!String(e).length}function d(e){if(typeof e.source.flags==`string`)return e.source.flags;{let t=[];return e.global&&t.push(`g`),e.ignoreCase&&t.push(`i`),e.multiline&&t.push(`m`),e.sticky&&t.push(`y`),e.unicode&&t.push(`u`),t.join(``)}}function f(e){let t=e,n={}.toString.call(e).slice(8,-1);if(n==`Set`&&(t=new Set([...e].map(e=>f(e)))),n==`Map`&&(t=new Map([...e].map(e=>[f(e[0]),f(e[1])]))),n==`Date`&&(t=new Date(e.getTime())),n==`RegExp`&&(t=RegExp(e.source,d(e))),n==`Array`||n==`Object`)for(let n in t=Array.isArray(e)?[]:{},e)t[n]=f(e[n]);return t}function p(e){return e&&(e instanceof Date||e.constructor.name==`File`||e.constructor.name==`FileList`)?!1:typeof e==`object`&&!!e&&!Array.isArray(e)}function m(e,t,n,r){var i,a;if(Array.isArray(t)&&(i=t.slice(0)),typeof t==`string`&&(i=t.split(`.`)),typeof t==`symbol`&&(i=[t]),!Array.isArray(i))throw Error(`props arg must be an array, a string or a symbol`);if(a=i.pop(),!a)return!1;g(a);for(var o;o=i.shift();)if(g(o),isNaN(parseInt(o))?(e[o]===void 0&&(e[o]={}),e=e[o]):(e.$each??=[],u(e.$each[o])&&(e.$each[o]={}),e=e.$each[o]),!e||typeof e!=`object`)return!1;return r?e[a]?e[a].$self=(e[a].$self??=[]).concat(n):e[a]={$self:n}:Array.isArray(e[a])?e[a]=e[a].concat(n):e[a]=n,!0}function h(e,t,n){if(!e)return n;var r,i;if(Array.isArray(t)&&(r=t.slice(0)),typeof t==`string`&&(r=t.split(`.`)),typeof t==`symbol`&&(r=[t]),!Array.isArray(r))throw Error(`props arg must be an array, a string or a symbol`);for(;r.length;)if(i=r.shift(),!e||!i||(e=e[i],e===void 0))return n;return e}function g(e){if(e==`__proto__`||e==`constructor`||e==`prototype`)throw Error(`setting of prototype values not supported`)}function _(e,...t){for(var n=[].slice.call(arguments),r,i=n.length;r=n[i-1],i--;)if(!r||typeof r!=`object`&&typeof r!=`function`)throw Error(`expected object, got `+r);for(var a=n[0],o=n.slice(1),s=o.length,i=0;i<s;i++){var c=o[i];for(var l in c)a[l]=c[l]}return a}function v(e,l){let u={autoDirty:e?.autoDirty,lazy:e?.lazy,rewardEarly:e?.rewardEarly,clearExternalErrorsOnChange:e?.clearExternalErrorsOnChange};function d(e,d,g){let v=n(()=>s(d)),{syncState:y={onUpdate:!1,onValidate:!1},...b}=g??{},{onUpdate:x=!1,onValidate:S=!1}=y,C={...u,...b},w=n(()=>!p(T.value)),T=i(e)?e:o(e),E=o(p(T.value)?{...f(T.value)}:f(T.value)),D=p(T.value)?{...f(T.value)}:f(T.value),O=o({}),k;if(!v.value?.[`~standard`])throw Error(`Only "standard-schema" compatible libraries are supported`);function A(e){let t={};return e.issues&&e.issues.map(e=>{let t=e.path?.map(e=>typeof e==`object`?e.key:e.toString()).join(`.`)??``,n=e.path?.[e.path.length-1],r=typeof n==`object`?n.key:n,i=(typeof n==`object`&&`value`in n?Array.isArray(n.value):!1)||(`type`in e?e.type===`array`:!1)||Array.isArray(h(T.value,t));return!i&&typeof r==`number`&&(t=e.path?.slice(0,e.path.length-1)?.map(e=>typeof e==`object`?e.key:e.toString()).join(`.`)??``),{...e,$path:t,isArray:i,$property:r,$rule:`schema`,$message:e.message}}).forEach(({isArray:e,$path:n,...r})=>{m(t,n,[r],e)}),t}async function j(e=!1){let t=v.value[`~standard`].validate(T.value);return t instanceof Promise&&(t=await t),w.value?O.value=t.issues?.map(e=>({$message:e.message,$property:e.path?.[e.path.length-1]?.toString()??`-`,$rule:`schema`,...e}))??[]:O.value=A(t),t.issues||(e&&S||!e&&x)&&(M?.(),p(T.value)?T.value=_(T.value,t.value):T.value=t.value,N()),t}let M;function N(){M=c([T,v],()=>j(),{deep:!0})}return N(),j(),k=async()=>{try{return{valid:!(await j(!0)).issues?.length,data:T.value,errors:{},issues:{}}}catch(e){return Promise.reject(e)}},r()&&a(()=>{M()}),{r$:t({scopeRules:n(()=>({})),state:T,options:C,schemaErrors:O,initialState:E,originalState:D,shortcuts:l,schemaMode:!0,onValidate:k}).regle}}return d}const y=v();function b(e,t){return e}function x(){function e(e,t){return t}return e}const S=x();function C({modifiers:e,shortcuts:t}){return{useRegleSchema:v(e,t),inferSchema:x()}}const{useCollectScope:w,useScopedRegle:T}=e({customUseRegle:y}),E=t=>{let{customStore:n,customUseRegle:r=y,asRecord:i=!1}=t??{};return e({customStore:n,customUseRegle:r,asRecord:i})};export{E as createScopedUseRegleSchema,C as defineRegleSchemaConfig,S as inferSchema,w as useCollectSchemaScope,y as useRegleSchema,T as useScopedRegleSchema,b as withDeps};
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regle/schemas",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.6",
|
|
4
4
|
"description": "Schemas adapter for Regle",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@standard-schema/spec": "1.0.0",
|
|
7
|
-
"@regle/core": "1.9.
|
|
8
|
-
"@regle/rules": "1.9.
|
|
7
|
+
"@regle/core": "1.9.6",
|
|
8
|
+
"@regle/rules": "1.9.6"
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
11
11
|
"valibot": "^1.0.0",
|
|
@@ -25,17 +25,17 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@total-typescript/ts-reset": "0.6.1",
|
|
28
|
-
"@types/node": "22.
|
|
28
|
+
"@types/node": "22.18.10",
|
|
29
29
|
"@vue/test-utils": "2.4.6",
|
|
30
30
|
"prettier": "3.6.2",
|
|
31
|
-
"tsdown": "0.15.
|
|
32
|
-
"type-fest": "5.
|
|
33
|
-
"typescript": "5.9.
|
|
31
|
+
"tsdown": "0.15.7",
|
|
32
|
+
"type-fest": "5.1.0",
|
|
33
|
+
"typescript": "5.9.3",
|
|
34
34
|
"valibot": "1.1.0",
|
|
35
35
|
"vitest": "3.2.4",
|
|
36
|
-
"vue": "3.5.
|
|
37
|
-
"vue-tsc": "3.0.
|
|
38
|
-
"zod": "4.1.
|
|
36
|
+
"vue": "3.5.22",
|
|
37
|
+
"vue-tsc": "3.0.9",
|
|
38
|
+
"zod": "4.1.12"
|
|
39
39
|
},
|
|
40
40
|
"type": "module",
|
|
41
41
|
"exports": {
|