@regle/schemas 0.7.6 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { RegleShortcutDefinition, RegleCommonStatus, JoinDiscriminatedUnions, RegleErrorTree, RegleRuleStatus, RegleCollectionErrors, MismatchInfo, DeepReactiveState, DeepMaybeRef, RegleBehaviourOptions, LocalRegleBehaviourOptions, NoInferLegacy, PrimitiveTypes } from '@regle/core';
2
2
  import { StandardSchemaV1 } from '@standard-schema/spec';
3
- import { Raw, UnwrapNestedRefs, MaybeRef, Ref } from 'vue';
3
+ import { Raw, UnwrapNestedRefs, MaybeRef } from 'vue';
4
4
 
5
5
  /**
6
6
  Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
@@ -53,38 +53,6 @@ Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<n
53
53
  */
54
54
  type EmptyObject = {[emptyObjectSymbol]?: never};
55
55
 
56
- /**
57
- Returns a boolean for whether the two given types are equal.
58
-
59
- @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
60
- @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
61
-
62
- Use-cases:
63
- - If you want to make a conditional branch based on the result of a comparison of two types.
64
-
65
- @example
66
- ```
67
- import type {IsEqual} from 'type-fest';
68
-
69
- // This type returns a boolean for whether the given array includes the given item.
70
- // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
71
- type Includes<Value extends readonly any[], Item> =
72
- Value extends readonly [Value[0], ...infer rest]
73
- ? IsEqual<Value[0], Item> extends true
74
- ? true
75
- : Includes<rest, Item>
76
- : false;
77
- ```
78
-
79
- @category Type Guard
80
- @category Utilities
81
- */
82
- type IsEqual<A, B> =
83
- (<G>() => G extends A ? 1 : 2) extends
84
- (<G>() => G extends B ? 1 : 2)
85
- ? true
86
- : false;
87
-
88
56
  /**
89
57
  Extract the element of an array that also works for array union.
90
58
 
@@ -94,30 +62,6 @@ It creates a type-safe way to access the element type of `unknown` type.
94
62
  */
95
63
  type ArrayElement<T> = T extends readonly unknown[] ? T[0] : never;
96
64
 
97
- /**
98
- Returns a boolean for whether either of two given types are true.
99
-
100
- Use-case: Constructing complex conditional types where multiple conditions must be satisfied.
101
-
102
- @example
103
- ```
104
- import type {Or} from 'type-fest';
105
-
106
- Or<true, false>;
107
- //=> true
108
-
109
- Or<false, false>;
110
- //=> false
111
- ```
112
-
113
- @see {@link And}
114
- */
115
- type Or<A extends boolean, B extends boolean> = [A, B][number] extends false
116
- ? false
117
- : true extends [IsEqual<A, true>, IsEqual<B, true>][number]
118
- ? true
119
- : never;
120
-
121
65
  /**
122
66
  Matches any primitive, `void`, `Date`, or `RegExp` value.
123
67
  */
@@ -231,19 +175,13 @@ type PartialObjectDeep<ObjectType extends object, Options extends PartialDeepOpt
231
175
  [KeyType in keyof ObjectType]?: PartialDeep<ObjectType[KeyType], Options>
232
176
  };
233
177
 
234
- type RegleSchemaMode = 'rules' | 'schema';
235
- type isModeRules<T> = T extends 'rules' ? true : false;
236
- type RegleSchemaModeOptions<T extends RegleSchemaMode = 'rules'> = {
237
- mode?: T;
238
- };
239
-
240
- interface RegleSchema<TState extends Record<string, any>, TSchema extends Record<string, any>, TMode extends RegleSchemaMode = 'rules', TShortcuts extends RegleShortcutDefinition = {}> {
178
+ interface RegleSchema<TState extends Record<string, any>, TSchema extends Record<string, any>, TShortcuts extends RegleShortcutDefinition = {}> {
241
179
  /**
242
180
  * r$ is a reactive object containing the values, errors, dirty state and all the necessary validations properties you'll need to display informations.
243
181
  *
244
182
  * To see the list of properties: {@link https://reglejs.dev/core-concepts/validation-properties}
245
183
  */
246
- r$: Raw<RegleSchemaStatus<TState, TSchema, TMode, TShortcuts, true>>;
184
+ r$: Raw<RegleSchemaStatus<TState, TSchema, TShortcuts, true>>;
247
185
  }
248
186
  type RegleSchemaResult<TSchema extends unknown> = {
249
187
  result: false;
@@ -255,12 +193,12 @@ type RegleSchemaResult<TSchema extends unknown> = {
255
193
  /**
256
194
  * @public
257
195
  */
258
- type RegleSchemaStatus<TState extends Record<string, any> = Record<string, any>, TSchema extends Record<string, any> = Record<string, any>, TMode extends RegleSchemaMode = 'rules', TShortcuts extends RegleShortcutDefinition = {}, IsRoot extends boolean = false> = Omit<RegleCommonStatus<TState>, Or<isModeRules<TMode>, IsRoot> extends false ? '$pending' : ''> & {
196
+ type RegleSchemaStatus<TState extends Record<string, any> = Record<string, any>, TSchema extends Record<string, any> = Record<string, any>, TShortcuts extends RegleShortcutDefinition = {}, IsRoot extends boolean = false> = Omit<RegleCommonStatus<TState>, IsRoot extends false ? '$pending' : ''> & {
259
197
  /** Represents all the children of your object. You can access any nested child at any depth to get the relevant data you need for your form. */
260
198
  readonly $fields: {
261
- readonly [TKey in keyof JoinDiscriminatedUnions<TState>]: TKey extends keyof JoinDiscriminatedUnions<TSchema> ? InferRegleSchemaStatusType<NonNullable<JoinDiscriminatedUnions<TSchema>[TKey]>, JoinDiscriminatedUnions<TState>[TKey], TMode, TShortcuts> : never;
199
+ readonly [TKey in keyof JoinDiscriminatedUnions<TState>]: TKey extends keyof JoinDiscriminatedUnions<TSchema> ? InferRegleSchemaStatusType<NonNullable<JoinDiscriminatedUnions<TSchema>[TKey]>, JoinDiscriminatedUnions<TState>[TKey], TShortcuts> : never;
262
200
  } & {
263
- readonly [TKey in keyof JoinDiscriminatedUnions<TState> as TKey extends keyof JoinDiscriminatedUnions<TSchema> ? JoinDiscriminatedUnions<TSchema>[TKey] extends NonNullable<JoinDiscriminatedUnions<TSchema>[TKey]> ? TKey : never : never]-?: TKey extends keyof JoinDiscriminatedUnions<TSchema> ? InferRegleSchemaStatusType<NonNullable<JoinDiscriminatedUnions<TSchema>[TKey]>, JoinDiscriminatedUnions<TState>[TKey], TMode, TShortcuts> : never;
201
+ readonly [TKey in keyof JoinDiscriminatedUnions<TState> as TKey extends keyof JoinDiscriminatedUnions<TSchema> ? JoinDiscriminatedUnions<TSchema>[TKey] extends NonNullable<JoinDiscriminatedUnions<TSchema>[TKey]> ? TKey : never : never]-?: TKey extends keyof JoinDiscriminatedUnions<TSchema> ? InferRegleSchemaStatusType<NonNullable<JoinDiscriminatedUnions<TSchema>[TKey]>, JoinDiscriminatedUnions<TState>[TKey], TShortcuts> : never;
264
202
  };
265
203
  /** Collection of all the error messages, collected for all children properties and nested forms.
266
204
  *
@@ -270,7 +208,7 @@ type RegleSchemaStatus<TState extends Record<string, any> = Record<string, any>,
270
208
  readonly $silentErrors: RegleErrorTree<TState>;
271
209
  /** Will return a copy of your state with only the fields that are dirty. By default it will filter out nullish values or objects, but you can override it with the first parameter $extractDirtyFields(false). */
272
210
  $extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep<TState>;
273
- } & (Or<isModeRules<TMode>, IsRoot> extends true ? {
211
+ } & (IsRoot extends true ? {
274
212
  /** Sets all properties as dirty, triggering all rules. It returns a promise that will either resolve to false or a type safe copy of your form state. Values that had the required rule will be transformed into a non-nullable value (type only). */
275
213
  $validate: () => Promise<RegleSchemaResult<TSchema>>;
276
214
  } : {}) & ([TShortcuts['nested']] extends [never] ? {} : {
@@ -279,11 +217,11 @@ type RegleSchemaStatus<TState extends Record<string, any> = Record<string, any>,
279
217
  /**
280
218
  * @public
281
219
  */
282
- type InferRegleSchemaStatusType<TSchema extends unknown, TState extends unknown, TMode extends RegleSchemaMode = 'rules', TShortcuts extends RegleShortcutDefinition = {}> = NonNullable<TSchema> extends Array<infer A extends Record<string, any>> ? RegleSchemaCollectionStatus<A, TState extends Array<any> ? TState : [], TMode, TShortcuts> : NonNullable<TState> extends Date | File ? RegleSchemaFieldStatus<TSchema, TState, TMode, TShortcuts> : unknown extends TState ? RegleSchemaFieldStatus<TSchema extends EmptyObject ? unknown : TSchema, TState, TMode, TShortcuts> : NonNullable<TSchema> extends Record<string, any> ? RegleSchemaStatus<NonNullable<TState> extends Record<string, any> ? NonNullable<TState> : {}, NonNullable<TSchema>, TMode, TShortcuts> : RegleSchemaFieldStatus<TSchema, TState, TMode, TShortcuts>;
220
+ type InferRegleSchemaStatusType<TSchema extends unknown, TState extends unknown, TShortcuts extends RegleShortcutDefinition = {}> = NonNullable<TSchema> extends Array<infer A extends Record<string, any>> ? RegleSchemaCollectionStatus<A, TState extends Array<any> ? 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>;
283
221
  /**
284
222
  * @public
285
223
  */
286
- type RegleSchemaFieldStatus<TSchema extends unknown, TState = any, TMode extends RegleSchemaMode = 'rules', TShortcuts extends RegleShortcutDefinition = {}> = Omit<RegleCommonStatus<TState>, isModeRules<TMode> extends false ? '$pending' : ''> & {
224
+ type RegleSchemaFieldStatus<TSchema extends unknown, TState = any, TShortcuts extends RegleShortcutDefinition = {}> = Omit<RegleCommonStatus<TState>, '$pending'> & {
287
225
  /** Collection of all the error messages, collected for all children properties and nested forms.
288
226
  *
289
227
  * Only contains errors from properties where $dirty equals true. */
@@ -300,20 +238,17 @@ type RegleSchemaFieldStatus<TSchema extends unknown, TState = any, TMode extends
300
238
  };
301
239
  /** Will return a copy of your state with only the fields that are dirty. By default it will filter out nullish values or objects, but you can override it with the first parameter $extractDirtyFields(false). */
302
240
  $extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep<TState>;
303
- } & (isModeRules<TMode> extends true ? {
304
- /** Sets the property as dirty, triggering all rules. It returns a promise that will either resolve to false or a type safe copy of your form state. Values that had the required rule will be transformed into a non-nullable value (type only). */
305
- $validate: () => Promise<RegleSchemaResult<TSchema>>;
306
- } : {}) & ([TShortcuts['fields']] extends [never] ? {} : {
241
+ } & ([TShortcuts['fields']] extends [never] ? {} : {
307
242
  [K in keyof TShortcuts['fields']]: ReturnType<NonNullable<TShortcuts['fields']>[K]>;
308
243
  });
309
244
  /**
310
245
  * @public
311
246
  */
312
- type RegleSchemaCollectionStatus<TSchema extends Record<string, any>, TState extends any[], TMode extends RegleSchemaMode = 'rules', TShortcuts extends RegleShortcutDefinition = {}> = Omit<RegleSchemaFieldStatus<TSchema, TState, TMode, TShortcuts>, '$errors' | '$silentErrors' | '$validate'> & {
247
+ type RegleSchemaCollectionStatus<TSchema extends Record<string, any>, TState extends any[], TShortcuts extends RegleShortcutDefinition = {}> = Omit<RegleSchemaFieldStatus<TSchema, TState, TShortcuts>, '$errors' | '$silentErrors' | '$validate'> & {
313
248
  /** Collection of status of every item in your collection. Each item will be a field you can access, or map on it to display your elements. */
314
- readonly $each: Array<InferRegleSchemaStatusType<NonNullable<TSchema>, ArrayElement<TState>, TMode, TShortcuts>>;
249
+ readonly $each: Array<InferRegleSchemaStatusType<NonNullable<TSchema>, ArrayElement<TState>, TShortcuts>>;
315
250
  /** Represents the status of the collection itself. You can have validation rules on the array like minLength, this field represents the isolated status of the collection. */
316
- readonly $self: RegleSchemaFieldStatus<TSchema, TState, TMode, TShortcuts>;
251
+ readonly $self: RegleSchemaFieldStatus<TSchema, TState, TShortcuts>;
317
252
  /** Collection of all the error messages, collected for all children properties and nested forms.
318
253
  *
319
254
  * Only contains errors from properties where $dirty equals true. */
@@ -322,20 +257,15 @@ type RegleSchemaCollectionStatus<TSchema extends Record<string, any>, TState ext
322
257
  readonly $silentErrors: RegleCollectionErrors<TSchema>;
323
258
  /** Will return a copy of your state with only the fields that are dirty. By default it will filter out nullish values or objects, but you can override it with the first parameter $extractDirtyFields(false). */
324
259
  $extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep<TState>;
325
- } & (isModeRules<TMode> extends true ? {
326
- /** Sets the property as dirty, triggering all rules. It returns a promise that will either resolve to false or a type safe copy of your form state. Values that had the required rule will be transformed into a non-nullable value (type only). */
327
- $validate: () => Promise<RegleSchemaResult<TSchema>>;
328
- } : {}) & ([TShortcuts['collections']] extends [never] ? {} : {
260
+ } & ([TShortcuts['collections']] extends [never] ? {} : {
329
261
  [K in keyof TShortcuts['collections']]: ReturnType<NonNullable<TShortcuts['collections']>[K]>;
330
262
  });
331
263
 
332
- type useRegleSchemaFn<TShortcuts extends RegleShortcutDefinition<any> = never> = <TState extends Record<string, any>, TSchema extends StandardSchemaV1<Record<string, any>> & TValid, TMode extends RegleSchemaMode = never, TValid = StandardSchemaV1.InferInput<TSchema> extends PartialDeep<UnwrapNestedRefs<TState>, {
264
+ type useRegleSchemaFn<TShortcuts extends RegleShortcutDefinition<any> = never> = <TState extends Record<string, any>, TSchema extends StandardSchemaV1<Record<string, any>> & TValid, TValid = StandardSchemaV1.InferInput<TSchema> extends PartialDeep<UnwrapNestedRefs<TState>, {
333
265
  recurseIntoArrays: true;
334
266
  }> ? {} : MismatchInfo<UnwrapNestedRefs<TState>, PartialDeep<StandardSchemaV1.InferInput<TSchema>, {
335
267
  recurseIntoArrays: true;
336
- }>>>(state: MaybeRef<TState> | DeepReactiveState<TState>, schema: MaybeRef<TSchema>, options?: Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<UnwrapNestedRefs<TState>, {}, never> & RegleSchemaModeOptions<TMode>) => RegleSchema<UnwrapNestedRefs<TState>, StandardSchemaV1.InferInput<TSchema>, [
337
- TMode
338
- ] extends [never] ? 'rules' : TMode, TShortcuts>;
268
+ }>>>(state: MaybeRef<TState> | DeepReactiveState<TState>, schema: MaybeRef<TSchema>, options?: Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<UnwrapNestedRefs<TState>, {}, never>) => RegleSchema<UnwrapNestedRefs<TState>, StandardSchemaV1.InferInput<TSchema>, TShortcuts>;
339
269
  /**
340
270
  * useRegle serves as the foundation for validation logic.
341
271
  *
@@ -358,23 +288,22 @@ type useRegleSchemaFn<TShortcuts extends RegleShortcutDefinition<any> = never> =
358
288
  declare const useRegleSchema: useRegleSchemaFn<RegleShortcutDefinition<any>>;
359
289
 
360
290
  /**
361
- * ⚠️ Not compatible with `schema` mode
362
291
  *
363
292
  * Force dependency on any RPC schema
364
293
  * ```ts
365
294
  * const foo = ref('');
366
295
  *
367
- * useRegleSchema({name: ''}, v.object({
296
+ * const schema = computed(() => v.object({
368
297
  * name: withDeps(
369
298
  * v.pipe(v.string(), v.check((value) => value === foo.value)),
370
- * [foo]
299
+ * [foo.value]
371
300
  * )
372
301
  * }))
302
+ *
303
+ * useRegleSchema({name: ''}, schema)
373
304
  * ```
374
305
  */
375
- declare function withDeps<TSchema extends StandardSchemaV1, TParams extends (Ref<unknown> | (() => unknown))[] = []>(schema: TSchema, depsArray: [...TParams]): TSchema & {
376
- __depsArray: TParams;
377
- };
306
+ declare function withDeps<TSchema extends StandardSchemaV1, TParams extends unknown[] = []>(schema: TSchema, depsArray: [...TParams]): TSchema;
378
307
 
379
308
  interface inferValibotSchemaFn {
380
309
  <TState extends Record<string, any>, TSchema extends StandardSchemaV1<Record<string, any>> & TValid, TValid = UnwrapNestedRefs<TState> extends PartialDeep<StandardSchemaV1.InferInput<TSchema>, {
@@ -1,6 +1,6 @@
1
1
  import { RegleShortcutDefinition, RegleCommonStatus, JoinDiscriminatedUnions, RegleErrorTree, RegleRuleStatus, RegleCollectionErrors, MismatchInfo, DeepReactiveState, DeepMaybeRef, RegleBehaviourOptions, LocalRegleBehaviourOptions, NoInferLegacy, PrimitiveTypes } from '@regle/core';
2
2
  import { StandardSchemaV1 } from '@standard-schema/spec';
3
- import { Raw, UnwrapNestedRefs, MaybeRef, Ref } from 'vue';
3
+ import { Raw, UnwrapNestedRefs, MaybeRef } from 'vue';
4
4
 
5
5
  /**
6
6
  Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
@@ -53,38 +53,6 @@ Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<n
53
53
  */
54
54
  type EmptyObject = {[emptyObjectSymbol]?: never};
55
55
 
56
- /**
57
- Returns a boolean for whether the two given types are equal.
58
-
59
- @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
60
- @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
61
-
62
- Use-cases:
63
- - If you want to make a conditional branch based on the result of a comparison of two types.
64
-
65
- @example
66
- ```
67
- import type {IsEqual} from 'type-fest';
68
-
69
- // This type returns a boolean for whether the given array includes the given item.
70
- // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
71
- type Includes<Value extends readonly any[], Item> =
72
- Value extends readonly [Value[0], ...infer rest]
73
- ? IsEqual<Value[0], Item> extends true
74
- ? true
75
- : Includes<rest, Item>
76
- : false;
77
- ```
78
-
79
- @category Type Guard
80
- @category Utilities
81
- */
82
- type IsEqual<A, B> =
83
- (<G>() => G extends A ? 1 : 2) extends
84
- (<G>() => G extends B ? 1 : 2)
85
- ? true
86
- : false;
87
-
88
56
  /**
89
57
  Extract the element of an array that also works for array union.
90
58
 
@@ -94,30 +62,6 @@ It creates a type-safe way to access the element type of `unknown` type.
94
62
  */
95
63
  type ArrayElement<T> = T extends readonly unknown[] ? T[0] : never;
96
64
 
97
- /**
98
- Returns a boolean for whether either of two given types are true.
99
-
100
- Use-case: Constructing complex conditional types where multiple conditions must be satisfied.
101
-
102
- @example
103
- ```
104
- import type {Or} from 'type-fest';
105
-
106
- Or<true, false>;
107
- //=> true
108
-
109
- Or<false, false>;
110
- //=> false
111
- ```
112
-
113
- @see {@link And}
114
- */
115
- type Or<A extends boolean, B extends boolean> = [A, B][number] extends false
116
- ? false
117
- : true extends [IsEqual<A, true>, IsEqual<B, true>][number]
118
- ? true
119
- : never;
120
-
121
65
  /**
122
66
  Matches any primitive, `void`, `Date`, or `RegExp` value.
123
67
  */
@@ -231,19 +175,13 @@ type PartialObjectDeep<ObjectType extends object, Options extends PartialDeepOpt
231
175
  [KeyType in keyof ObjectType]?: PartialDeep<ObjectType[KeyType], Options>
232
176
  };
233
177
 
234
- type RegleSchemaMode = 'rules' | 'schema';
235
- type isModeRules<T> = T extends 'rules' ? true : false;
236
- type RegleSchemaModeOptions<T extends RegleSchemaMode = 'rules'> = {
237
- mode?: T;
238
- };
239
-
240
- interface RegleSchema<TState extends Record<string, any>, TSchema extends Record<string, any>, TMode extends RegleSchemaMode = 'rules', TShortcuts extends RegleShortcutDefinition = {}> {
178
+ interface RegleSchema<TState extends Record<string, any>, TSchema extends Record<string, any>, TShortcuts extends RegleShortcutDefinition = {}> {
241
179
  /**
242
180
  * r$ is a reactive object containing the values, errors, dirty state and all the necessary validations properties you'll need to display informations.
243
181
  *
244
182
  * To see the list of properties: {@link https://reglejs.dev/core-concepts/validation-properties}
245
183
  */
246
- r$: Raw<RegleSchemaStatus<TState, TSchema, TMode, TShortcuts, true>>;
184
+ r$: Raw<RegleSchemaStatus<TState, TSchema, TShortcuts, true>>;
247
185
  }
248
186
  type RegleSchemaResult<TSchema extends unknown> = {
249
187
  result: false;
@@ -255,12 +193,12 @@ type RegleSchemaResult<TSchema extends unknown> = {
255
193
  /**
256
194
  * @public
257
195
  */
258
- type RegleSchemaStatus<TState extends Record<string, any> = Record<string, any>, TSchema extends Record<string, any> = Record<string, any>, TMode extends RegleSchemaMode = 'rules', TShortcuts extends RegleShortcutDefinition = {}, IsRoot extends boolean = false> = Omit<RegleCommonStatus<TState>, Or<isModeRules<TMode>, IsRoot> extends false ? '$pending' : ''> & {
196
+ type RegleSchemaStatus<TState extends Record<string, any> = Record<string, any>, TSchema extends Record<string, any> = Record<string, any>, TShortcuts extends RegleShortcutDefinition = {}, IsRoot extends boolean = false> = Omit<RegleCommonStatus<TState>, IsRoot extends false ? '$pending' : ''> & {
259
197
  /** Represents all the children of your object. You can access any nested child at any depth to get the relevant data you need for your form. */
260
198
  readonly $fields: {
261
- readonly [TKey in keyof JoinDiscriminatedUnions<TState>]: TKey extends keyof JoinDiscriminatedUnions<TSchema> ? InferRegleSchemaStatusType<NonNullable<JoinDiscriminatedUnions<TSchema>[TKey]>, JoinDiscriminatedUnions<TState>[TKey], TMode, TShortcuts> : never;
199
+ readonly [TKey in keyof JoinDiscriminatedUnions<TState>]: TKey extends keyof JoinDiscriminatedUnions<TSchema> ? InferRegleSchemaStatusType<NonNullable<JoinDiscriminatedUnions<TSchema>[TKey]>, JoinDiscriminatedUnions<TState>[TKey], TShortcuts> : never;
262
200
  } & {
263
- readonly [TKey in keyof JoinDiscriminatedUnions<TState> as TKey extends keyof JoinDiscriminatedUnions<TSchema> ? JoinDiscriminatedUnions<TSchema>[TKey] extends NonNullable<JoinDiscriminatedUnions<TSchema>[TKey]> ? TKey : never : never]-?: TKey extends keyof JoinDiscriminatedUnions<TSchema> ? InferRegleSchemaStatusType<NonNullable<JoinDiscriminatedUnions<TSchema>[TKey]>, JoinDiscriminatedUnions<TState>[TKey], TMode, TShortcuts> : never;
201
+ readonly [TKey in keyof JoinDiscriminatedUnions<TState> as TKey extends keyof JoinDiscriminatedUnions<TSchema> ? JoinDiscriminatedUnions<TSchema>[TKey] extends NonNullable<JoinDiscriminatedUnions<TSchema>[TKey]> ? TKey : never : never]-?: TKey extends keyof JoinDiscriminatedUnions<TSchema> ? InferRegleSchemaStatusType<NonNullable<JoinDiscriminatedUnions<TSchema>[TKey]>, JoinDiscriminatedUnions<TState>[TKey], TShortcuts> : never;
264
202
  };
265
203
  /** Collection of all the error messages, collected for all children properties and nested forms.
266
204
  *
@@ -270,7 +208,7 @@ type RegleSchemaStatus<TState extends Record<string, any> = Record<string, any>,
270
208
  readonly $silentErrors: RegleErrorTree<TState>;
271
209
  /** Will return a copy of your state with only the fields that are dirty. By default it will filter out nullish values or objects, but you can override it with the first parameter $extractDirtyFields(false). */
272
210
  $extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep<TState>;
273
- } & (Or<isModeRules<TMode>, IsRoot> extends true ? {
211
+ } & (IsRoot extends true ? {
274
212
  /** Sets all properties as dirty, triggering all rules. It returns a promise that will either resolve to false or a type safe copy of your form state. Values that had the required rule will be transformed into a non-nullable value (type only). */
275
213
  $validate: () => Promise<RegleSchemaResult<TSchema>>;
276
214
  } : {}) & ([TShortcuts['nested']] extends [never] ? {} : {
@@ -279,11 +217,11 @@ type RegleSchemaStatus<TState extends Record<string, any> = Record<string, any>,
279
217
  /**
280
218
  * @public
281
219
  */
282
- type InferRegleSchemaStatusType<TSchema extends unknown, TState extends unknown, TMode extends RegleSchemaMode = 'rules', TShortcuts extends RegleShortcutDefinition = {}> = NonNullable<TSchema> extends Array<infer A extends Record<string, any>> ? RegleSchemaCollectionStatus<A, TState extends Array<any> ? TState : [], TMode, TShortcuts> : NonNullable<TState> extends Date | File ? RegleSchemaFieldStatus<TSchema, TState, TMode, TShortcuts> : unknown extends TState ? RegleSchemaFieldStatus<TSchema extends EmptyObject ? unknown : TSchema, TState, TMode, TShortcuts> : NonNullable<TSchema> extends Record<string, any> ? RegleSchemaStatus<NonNullable<TState> extends Record<string, any> ? NonNullable<TState> : {}, NonNullable<TSchema>, TMode, TShortcuts> : RegleSchemaFieldStatus<TSchema, TState, TMode, TShortcuts>;
220
+ type InferRegleSchemaStatusType<TSchema extends unknown, TState extends unknown, TShortcuts extends RegleShortcutDefinition = {}> = NonNullable<TSchema> extends Array<infer A extends Record<string, any>> ? RegleSchemaCollectionStatus<A, TState extends Array<any> ? 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>;
283
221
  /**
284
222
  * @public
285
223
  */
286
- type RegleSchemaFieldStatus<TSchema extends unknown, TState = any, TMode extends RegleSchemaMode = 'rules', TShortcuts extends RegleShortcutDefinition = {}> = Omit<RegleCommonStatus<TState>, isModeRules<TMode> extends false ? '$pending' : ''> & {
224
+ type RegleSchemaFieldStatus<TSchema extends unknown, TState = any, TShortcuts extends RegleShortcutDefinition = {}> = Omit<RegleCommonStatus<TState>, '$pending'> & {
287
225
  /** Collection of all the error messages, collected for all children properties and nested forms.
288
226
  *
289
227
  * Only contains errors from properties where $dirty equals true. */
@@ -300,20 +238,17 @@ type RegleSchemaFieldStatus<TSchema extends unknown, TState = any, TMode extends
300
238
  };
301
239
  /** Will return a copy of your state with only the fields that are dirty. By default it will filter out nullish values or objects, but you can override it with the first parameter $extractDirtyFields(false). */
302
240
  $extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep<TState>;
303
- } & (isModeRules<TMode> extends true ? {
304
- /** Sets the property as dirty, triggering all rules. It returns a promise that will either resolve to false or a type safe copy of your form state. Values that had the required rule will be transformed into a non-nullable value (type only). */
305
- $validate: () => Promise<RegleSchemaResult<TSchema>>;
306
- } : {}) & ([TShortcuts['fields']] extends [never] ? {} : {
241
+ } & ([TShortcuts['fields']] extends [never] ? {} : {
307
242
  [K in keyof TShortcuts['fields']]: ReturnType<NonNullable<TShortcuts['fields']>[K]>;
308
243
  });
309
244
  /**
310
245
  * @public
311
246
  */
312
- type RegleSchemaCollectionStatus<TSchema extends Record<string, any>, TState extends any[], TMode extends RegleSchemaMode = 'rules', TShortcuts extends RegleShortcutDefinition = {}> = Omit<RegleSchemaFieldStatus<TSchema, TState, TMode, TShortcuts>, '$errors' | '$silentErrors' | '$validate'> & {
247
+ type RegleSchemaCollectionStatus<TSchema extends Record<string, any>, TState extends any[], TShortcuts extends RegleShortcutDefinition = {}> = Omit<RegleSchemaFieldStatus<TSchema, TState, TShortcuts>, '$errors' | '$silentErrors' | '$validate'> & {
313
248
  /** Collection of status of every item in your collection. Each item will be a field you can access, or map on it to display your elements. */
314
- readonly $each: Array<InferRegleSchemaStatusType<NonNullable<TSchema>, ArrayElement<TState>, TMode, TShortcuts>>;
249
+ readonly $each: Array<InferRegleSchemaStatusType<NonNullable<TSchema>, ArrayElement<TState>, TShortcuts>>;
315
250
  /** Represents the status of the collection itself. You can have validation rules on the array like minLength, this field represents the isolated status of the collection. */
316
- readonly $self: RegleSchemaFieldStatus<TSchema, TState, TMode, TShortcuts>;
251
+ readonly $self: RegleSchemaFieldStatus<TSchema, TState, TShortcuts>;
317
252
  /** Collection of all the error messages, collected for all children properties and nested forms.
318
253
  *
319
254
  * Only contains errors from properties where $dirty equals true. */
@@ -322,20 +257,15 @@ type RegleSchemaCollectionStatus<TSchema extends Record<string, any>, TState ext
322
257
  readonly $silentErrors: RegleCollectionErrors<TSchema>;
323
258
  /** Will return a copy of your state with only the fields that are dirty. By default it will filter out nullish values or objects, but you can override it with the first parameter $extractDirtyFields(false). */
324
259
  $extractDirtyFields: (filterNullishValues?: boolean) => PartialDeep<TState>;
325
- } & (isModeRules<TMode> extends true ? {
326
- /** Sets the property as dirty, triggering all rules. It returns a promise that will either resolve to false or a type safe copy of your form state. Values that had the required rule will be transformed into a non-nullable value (type only). */
327
- $validate: () => Promise<RegleSchemaResult<TSchema>>;
328
- } : {}) & ([TShortcuts['collections']] extends [never] ? {} : {
260
+ } & ([TShortcuts['collections']] extends [never] ? {} : {
329
261
  [K in keyof TShortcuts['collections']]: ReturnType<NonNullable<TShortcuts['collections']>[K]>;
330
262
  });
331
263
 
332
- type useRegleSchemaFn<TShortcuts extends RegleShortcutDefinition<any> = never> = <TState extends Record<string, any>, TSchema extends StandardSchemaV1<Record<string, any>> & TValid, TMode extends RegleSchemaMode = never, TValid = StandardSchemaV1.InferInput<TSchema> extends PartialDeep<UnwrapNestedRefs<TState>, {
264
+ type useRegleSchemaFn<TShortcuts extends RegleShortcutDefinition<any> = never> = <TState extends Record<string, any>, TSchema extends StandardSchemaV1<Record<string, any>> & TValid, TValid = StandardSchemaV1.InferInput<TSchema> extends PartialDeep<UnwrapNestedRefs<TState>, {
333
265
  recurseIntoArrays: true;
334
266
  }> ? {} : MismatchInfo<UnwrapNestedRefs<TState>, PartialDeep<StandardSchemaV1.InferInput<TSchema>, {
335
267
  recurseIntoArrays: true;
336
- }>>>(state: MaybeRef<TState> | DeepReactiveState<TState>, schema: MaybeRef<TSchema>, options?: Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<UnwrapNestedRefs<TState>, {}, never> & RegleSchemaModeOptions<TMode>) => RegleSchema<UnwrapNestedRefs<TState>, StandardSchemaV1.InferInput<TSchema>, [
337
- TMode
338
- ] extends [never] ? 'rules' : TMode, TShortcuts>;
268
+ }>>>(state: MaybeRef<TState> | DeepReactiveState<TState>, schema: MaybeRef<TSchema>, options?: Partial<DeepMaybeRef<RegleBehaviourOptions>> & LocalRegleBehaviourOptions<UnwrapNestedRefs<TState>, {}, never>) => RegleSchema<UnwrapNestedRefs<TState>, StandardSchemaV1.InferInput<TSchema>, TShortcuts>;
339
269
  /**
340
270
  * useRegle serves as the foundation for validation logic.
341
271
  *
@@ -358,23 +288,22 @@ type useRegleSchemaFn<TShortcuts extends RegleShortcutDefinition<any> = never> =
358
288
  declare const useRegleSchema: useRegleSchemaFn<RegleShortcutDefinition<any>>;
359
289
 
360
290
  /**
361
- * ⚠️ Not compatible with `schema` mode
362
291
  *
363
292
  * Force dependency on any RPC schema
364
293
  * ```ts
365
294
  * const foo = ref('');
366
295
  *
367
- * useRegleSchema({name: ''}, v.object({
296
+ * const schema = computed(() => v.object({
368
297
  * name: withDeps(
369
298
  * v.pipe(v.string(), v.check((value) => value === foo.value)),
370
- * [foo]
299
+ * [foo.value]
371
300
  * )
372
301
  * }))
302
+ *
303
+ * useRegleSchema({name: ''}, schema)
373
304
  * ```
374
305
  */
375
- declare function withDeps<TSchema extends StandardSchemaV1, TParams extends (Ref<unknown> | (() => unknown))[] = []>(schema: TSchema, depsArray: [...TParams]): TSchema & {
376
- __depsArray: TParams;
377
- };
306
+ declare function withDeps<TSchema extends StandardSchemaV1, TParams extends unknown[] = []>(schema: TSchema, depsArray: [...TParams]): TSchema;
378
307
 
379
308
  interface inferValibotSchemaFn {
380
309
  <TState extends Record<string, any>, TSchema extends StandardSchemaV1<Record<string, any>> & TValid, TValid = UnwrapNestedRefs<TState> extends PartialDeep<StandardSchemaV1.InferInput<TSchema>, {
@@ -1 +1 @@
1
- 'use strict';var core=require('@regle/core'),vue=require('vue'),rules=require('@regle/rules');function ye(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 b(e){let t=e,n={}.toString.call(e).slice(8,-1);if(n=="Set"&&(t=new Set([...e].map(r=>b(r)))),n=="Map"&&(t=new Map([...e].map(r=>[b(r[0]),b(r[1])]))),n=="Date"&&(t=new Date(e.getTime())),n=="RegExp"&&(t=RegExp(e.source,ye(e))),n=="Array"||n=="Object"){t=Array.isArray(e)?[]:{};for(let r in e)t[r]=b(e[r]);}return t}function l(e){return e&&(e instanceof Date||e.constructor.name=="File"||e.constructor.name=="FileList")?false:typeof e=="object"&&e!==null&&!Array.isArray(e)}function C(e,t,n,r){var a,o;if(Array.isArray(t)&&(a=t.slice(0)),typeof t=="string"&&(a=t.split(".")),typeof t=="symbol"&&(a=[t]),!Array.isArray(a))throw new Error("props arg must be an array, a string or a symbol");if(o=a.pop(),!o)return false;L(o);for(var i;i=a.shift();)if(L(i),isNaN(parseInt(i))?(typeof e[i]>"u"&&(e[i]={}),e=e[i]):((e.$each??=[])[i]={},e=e.$each[i]),!e||typeof e!="object")return false;return r?e[o]={...e[o],$self:n}:e[o]=n,true}function L(e){if(e=="__proto__"||e=="constructor"||e=="prototype")throw new Error("setting of prototype values not supported")}function W(e){let t=e.async,n=r=>{let a=Se(e,r);return a instanceof Promise?a:a.issues?{$valid:false,$issues:a.issues}:{$valid:true,$issues:[]}};return "__depsArray"in e&&Array.isArray(e.__depsArray)&&e.__depsArray.length?t?rules.withAsync(n,e.__depsArray):rules.withParams(n,e.__depsArray):t?rules.withAsync(n):n}function Se(e,t){try{return e.async?new Promise(async n=>{let r=await e["~standard"].validate(t);r.issues?n({$valid:!1,$issues:r.issues}):n({$valid:!0,$issues:[]});}):e["~standard"].validate(t)}catch{return {}}}function q(e){return e.type==="intersect"}function Z(e){return e.type==="object"}function x(e){return "wrapped"in e}function _(e){return q(e)?{entries:e.options.reduce((n,r)=>{let a=_(r);return a&&(n={...n,...a.entries}),n},{}),type:"object",kind:"schema",async:false}:Z(e)?e:x(e)?_(e.wrapped):undefined}function z(e,t){let n=_(e);return n?Object.fromEntries(Object.entries(n.entries).map(([r,a])=>{if(typeof a=="object"){let o=vue.toRef(l(t.value)?t.value:{},r);return [r,T(a,o)]}return [r,{}]})):{}}function _e(e){return e?.type==="literal"}function H(e,t){let n=vue.effectScope();return n.run(()=>{let a=vue.ref({});return vue.watch(t,()=>{if(l(t.value)&&t.value[e.key]){let o=e.options.find(i=>{let s=_(i)?.entries[e.key];return _e(s)&&l(t.value)?s.literal===t.value[e.key]:false});o&&Z(o)?a.value=Object.fromEntries(Object.entries(o.entries).map(([i,f])=>[i,T(f,vue.toRef(l(t.value)?t.value:{},i))])):a.value={};}else a.value={[e.key]:{required:rules.required}};},{deep:true,flush:"pre",immediate:true}),vue.onScopeDispose(()=>{n.stop();}),{valibotRule:a}})}function h(){return e=>{let t=e.$issues?.map(n=>n.message);return t?.length?t.length?t:"Error":[]}}function Oe(e){return e.type==="array"}function De(e){return e.type==="object"}function Ze(e){return e.type==="variant"}function K(e){return x(e)?K(e.wrapped):e}function T(e,t){let n=K(e);return Oe(n)?G(n,t):De(n)?z(n,t):Ze(n)?H(n,t).valibotRule:{[n.type]:rules.withMessage(W(n),h())}}function G(e,t){let n={};return "pipe"in e&&e.pipe.filter(r=>r.kind==="validation").forEach(r=>{n[r.type]=rules.withMessage(a=>{let o=r["~run"]({value:a,typed:true},{});return {$valid:!o.issues,$issues:o.issues}},h());}),{$each:T(e.item,t),...n}}function A(e,t){let n=w(e);function r(a){if(t?.value?.length)return {$valid:false,$issues:t.value};let o=Ie(e,a);return o instanceof Promise?o:o.success?{$valid:true,$issues:[]}:{$valid:false,$issues:o.error?.issues??[]}}return e&&"__depsArray"in e&&Array.isArray(e.__depsArray)&&e.__depsArray.length?n?rules.withAsync(r,e.__depsArray):rules.withParams(r,e.__depsArray):n?rules.withAsync(r):r}function Ie(e,t){if(e)try{return e.safeParse(t)}catch{try{return new Promise(async r=>{let a=await e.safeParseAsync(t);a.success?r({$valid:!0,$issues:[]}):r({$valid:!1,$issues:a.error?.issues});})}catch{return {}}}else return {success:true,data:{}}}function Q(e){if(typeof e!="function")return false;if(e.constructor.name==="AsyncFunction")return true;try{return e()instanceof Promise}catch{return false}}function w(e){if(e?._def){if(e._def.typeName==="ZodEffects"){let t=e._def.effect;return Q(t.refinement||t.transform)}if(e._def.typeName==="ZodObject")return Object.values(e._def.shape()).some(t=>w(t));if(e._def.typeName==="ZodUnion"||e._def.typeName==="ZodIntersection")return e._def.options.some(w);if(e._def.typeName==="ZodArray")return w(e._def.type);if(e._def.typeName==="ZodOptional"||e._def.typeName==="ZodNullable")return w(e._def.innerType);if(e._def.typeName==="ZodTuple")return e._def.items.some(w);if(e._def.typeName==="ZodString"||e._def.typeName==="ZodNumber"||e._def.typeName==="ZodDate")return e._def.checks?.some(t=>Q(t.refinement))}return false}function X(e,t,n){let r=vue.effectScope();return r.run(()=>{let o=vue.ref({});return vue.watch(t,()=>{if(l(t.value)&&t.value[e._def.discriminator]){let i=e._def.optionsMap.get(t.value[e._def.discriminator]);i?o.value=Object.fromEntries(Object.entries(i._def.shape()).map(([f,s])=>typeof s=="object"&&"_def"in s?[f,R({schema:s,state:vue.toRef(l(t.value)?t.value:{}),additionalIssues:n})]:[f,{}])):o.value={};}else o.value={[e._def.discriminator]:{required:rules.required}};},{deep:true,flush:"pre",immediate:true}),vue.onScopeDispose(()=>{r.stop();}),{zodRule:o}})}var $e=["ZodDefault","ZodCatch","ZodNullable","ZodOptional","ZodReadonly"];function Be(e){return e._def&&typeof e._def=="object"&&"typeName"in e._def?$e.includes(e._def.typeName):false}function Fe(e){return e._def&&typeof e._def=="object"&&"typeName"in e._def?"schema"in e._def:false}function k(e){if(e?._def&&typeof e._def=="object"&&"typeName"in e._def)return Be(e)?k(e._def.innerType):Fe(e)?k(e._def.schema):e}function R({schema:e,state:t,additionalIssues:n}){let r=k(e);return r?._def&&"typeName"in r._def?r._def.typeName==="ZodArray"||r._def.typeName==="ZodTuple"?ee(e,t,n).zodRule:r._def.typeName==="ZodObject"||r._def.typeName==="ZodIntersection"?I(r,t,n).zodRule:r._def.typeName==="ZodDiscriminatedUnion"?X(r,t,n).zodRule:n?{[r.constructor.name]:rules.withMessage(rules.withParams(A(e,n),[t]),h())}:{[r.constructor.name]:rules.withMessage(A(e),h())}:{}}function re(e,t=[]){return e._def&&"typeName"in e._def?e._def.typeName==="ZodEffects"?re(e._def.schema,t.concat([e._def.effect])):{nestedSchema:e,nestedEffects:t}:{nestedSchema:undefined}}function ee(e,t,n){let{nestedSchema:r,nestedEffects:a}=re(e),o=vue.ref({});if(r){let i=r._def.typeName==="ZodArray"?{...!!r._def.minLength&&{minLength:rules.minLength(r._def.minLength?.value)},...!!r._def.maxLength&&{maxLength:rules.maxLength(r._def.maxLength?.value)},...!!r._def.exactLength&&{exactLength:rules.exactLength(r._def.exactLength?.value)}}:{};if(a?.length){let f=vue.effectScope();f.run(()=>{let s=vue.ref([]),u=vue.computed(()=>s.value.concat(n?.value??[]));if(n||vue.watch(t,()=>{r&&(s.value=e.safeParse(t.value).error?.issues.filter(d=>d.code==="custom")??[]);},{deep:true,immediate:true}),r){let d=r._def.typeName==="ZodArray"?r._def.type:r._def.items,v=vue.computed(()=>u.value.filter(c=>!c.path.length));o.value={$each:(c,m)=>{let g=vue.computed(()=>u.value?.filter(p=>p.code==="custom")?.filter(p=>p.path[0]===m.toString()).map(p=>{let[le,...B]=p.path;return {...p,path:B}}));return R({schema:d,state:t,additionalIssues:g})},selfValidator:rules.withMessage(rules.withParams(A(undefined,v),[t,v]),h())};}else o.value={};vue.onScopeDispose(()=>{f.stop();});});}else {let f=r._def.typeName==="ZodArray"?r._def.type:r._def.items;o.value={$each:R({schema:f,state:t,additionalIssues:n}),...i};}}return vue.reactive({zodRule:o})}function O(e,t=[]){if(e._def&&"typeName"in e._def){if(e._def.typeName==="ZodEffects")return O(e._def.schema,t.concat([e._def.effect]));if(e._def.typeName==="ZodIntersection"){let{nestedSchema:n,nestedEffects:r=[]}=O(e._def.left),{nestedSchema:a,nestedEffects:o=[]}=O(e._def.right);return n&&a?O(n.merge(a),t.concat(r).concat(o)):{nestedSchema:undefined}}else return {nestedSchema:e,nestedEffects:t}}return {nestedSchema:undefined}}function I(e,t,n){let{nestedSchema:r,nestedEffects:a}=O(e),o=vue.ref({});if(r)if(a?.length){let i=vue.effectScope();i.run(()=>{let f=vue.ref([]),s=vue.computed(()=>f.value.concat(n?.value??[]));vue.watch(t,()=>{r?._def?.typeName==="ZodObject"&&(f.value=(n?.value??[]).concat(e.safeParse(t.value).error?.issues.filter(u=>u.code==="custom")??[]));},{deep:true,flush:"sync",immediate:true}),r?._def?.typeName==="ZodObject"?o.value=Object.fromEntries(Object.entries(r._def.shape()).map(([u,d])=>{if(d&&typeof d=="object"&&"_def"in d){let v=vue.toRef(l(t.value)?t.value:{},u),c=vue.computed(()=>s.value?.filter(m=>m.path[0]===u).map(m=>{let[g,...p]=m.path;return {...m,path:p}}));return [u,R({schema:d,state:v,additionalIssues:c}),[t]]}return [u,{}]})):o.value={},vue.onScopeDispose(()=>{i.stop();});});}else o.value=Object.fromEntries(Object.entries(r._def.shape()).map(([i,f])=>{if(f&&typeof f=="object"&&"_def"in f){let s=vue.toRef(l(t.value)?t.value:{},i);return [i,R({schema:f,state:s,additionalIssues:n})]}return [i,{}]}));return vue.reactive({zodRule:o})}function V(e,t){let n={autoDirty:e?.autoDirty,lazy:e?.lazy,rewardEarly:e?.rewardEarly,clearExternalErrorsOnChange:e?.clearExternalErrorsOnChange};function r(a,o,i){let f=vue.ref({}),s=vue.computed(()=>vue.unref(o)),{mode:u="rules",...d}=i??{},v={...n,...d},c=vue.isRef(a)?a:vue.ref(a),m=vue.ref({...b(c.value)}),g=vue.ref({}),p;if(u==="rules")vue.watch(s,()=>{if(s.value&&typeof s.value=="object")if(s.value["~standard"].vendor==="zod"){let N=I(s.value,c);f.value=N.zodRule;}else s.value["~standard"].vendor==="valibot"?f.value=vue.reactive(z(s.value,c)):s.value?.["~standard"]?.vendor?console.warn(`This RPC library "${s.value["~standard"].vendor}" is not supported yet in 'rules' mode, switch to the "schema" mode option`):console.warn('Only "standard-schema" compatible libraries are supported');},{deep:true,immediate:true,flush:"post"});else {let D=function(S){let F={};return S.issues&&S.issues.map(y=>{let pe=y.path?.map(j=>typeof j=="object"?j.key:j).join("."),P=y.path?.[y.path.length-1],de=(typeof P=="object"&&"value"in P?Array.isArray(P.value):false)||("type"in y?y.type==="array":false);return {path:pe,message:y.message,isArray:de}}).forEach(y=>{C(F,y.path,[y.message],y.isArray);}),F};if(!s.value?.["~standard"])throw new Error('Only "standard-schema" compatible libraries are supported');let N=s.value["~standard"].validate(m.value);g.value=D(N),vue.watch([c,s],async()=>{let S=await s.value["~standard"].validate(c.value);g.value=D(S);},{deep:true,immediate:true,flush:"post"}),p=async()=>{try{let S=await s.value["~standard"].validate(c.value);return g.value=D(S),{result:!S.issues?.length,data:c.value}}catch(S){return Promise.reject(S)}};}return {r$:core.useRootStorage({scopeRules:f,state:c,options:v,schemaErrors:g,initialState:m,shortcuts:t,schemaMode:u==="schema",onValidate:p}).regle}}return r}var ie=V();function fe(e,t){return Object.hasOwn(e,"__depsArray")||Object.defineProperties(e,{__depsArray:{value:t,enumerable:false,configurable:false,writable:false}}),e}function $(){function e(t,n){return n}return e}var ce=$();function ue({modifiers:e,shortcuts:t}){let n=V(e,t),r=$();return {useRegleSchema:n,inferSchema:r}}exports.defineRegleSchemaConfig=ue;exports.inferSchema=ce;exports.useRegleSchema=ie;exports.withDeps=fe;
1
+ 'use strict';var core=require('@regle/core'),vue=require('vue');function F(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 l(e){let t=e,r={}.toString.call(e).slice(8,-1);if(r=="Set"&&(t=new Set([...e].map(a=>l(a)))),r=="Map"&&(t=new Map([...e].map(a=>[l(a[0]),l(a[1])]))),r=="Date"&&(t=new Date(e.getTime())),r=="RegExp"&&(t=RegExp(e.source,F(e))),r=="Array"||r=="Object"){t=Array.isArray(e)?[]:{};for(let a in e)t[a]=l(e[a]);}return t}function w(e,t,r,a){var n,o;if(Array.isArray(t)&&(n=t.slice(0)),typeof t=="string"&&(n=t.split(".")),typeof t=="symbol"&&(n=[t]),!Array.isArray(n))throw new Error("props arg must be an array, a string or a symbol");if(o=n.pop(),!o)return false;x(o);for(var i;i=n.shift();)if(x(i),isNaN(parseInt(i))?(typeof e[i]>"u"&&(e[i]={}),e=e[i]):((e.$each??=[])[i]={},e=e.$each[i]),!e||typeof e!="object")return false;return a?e[o]?e[o].$self=(e[o].$self??=[]).concat(r):e[o]={...e[o],$self:r}:Array.isArray(e[o])?e[o]=e[o].concat(r):e[o]=r,true}function I(e,t,r){if(!e)return r;var a,n;if(Array.isArray(t)&&(a=t.slice(0)),typeof t=="string"&&(a=t.split(".")),typeof t=="symbol"&&(a=[t]),!Array.isArray(a))throw new Error("props arg must be an array, a string or a symbol");for(;a.length;)if(n=a.shift(),!e||!n||(e=e[n],e===undefined))return r;return e}function x(e){if(e=="__proto__"||e=="constructor"||e=="prototype")throw new Error("setting of prototype values not supported")}function h(e,t){let r={autoDirty:e?.autoDirty,lazy:e?.lazy,rewardEarly:e?.rewardEarly,clearExternalErrorsOnChange:e?.clearExternalErrorsOnChange};function a(n,o,i){let O=vue.ref({}),m=vue.computed(()=>vue.unref(o)),M={...r,...i},f=vue.isRef(n)?n:vue.ref(n),E=vue.ref({...l(f.value)}),d=vue.ref({}),R;if(!m.value?.["~standard"])throw new Error('Only "standard-schema" compatible libraries are supported');function N(s){let T={};return s.issues&&s.issues.map(c=>{let D=c.path?.map(y=>typeof y=="object"?y.key:y.toString()).join(".")??"",u=c.path?.[c.path.length-1],A=(typeof u=="object"&&"value"in u?Array.isArray(u.value):false)||("type"in c?c.type==="array":false)||Array.isArray(I(f.value,D));return {path:D,message:c.message,isArray:A}}).forEach(c=>{w(T,c.path,[c.message],c.isArray);}),T}async function g(){let s=m.value["~standard"].validate(f.value);return s instanceof Promise&&(s=await s),d.value=N(s),s}return vue.watch([f,m],g,{deep:true,immediate:true}),R=async()=>{try{return {result:!(await g()).issues?.length,data:f.value}}catch(s){return Promise.reject(s)}},{r$:core.useRootStorage({scopeRules:O,state:f,options:M,schemaErrors:d,initialState:E,shortcuts:t,schemaMode:true,onValidate:R}).regle}}return a}var v=h();function P(e,t){return e}function S(){function e(t,r){return r}return e}var V=S();function b({modifiers:e,shortcuts:t}){let r=h(e,t),a=S();return {useRegleSchema:r,inferSchema:a}}exports.defineRegleSchemaConfig=b;exports.inferSchema=V;exports.useRegleSchema=v;exports.withDeps=P;
@@ -1 +1 @@
1
- import {useRootStorage}from'@regle/core';import {ref,computed,unref,isRef,watch,reactive,toRef,effectScope,onScopeDispose}from'vue';import {withMessage,withAsync,withParams,required,minLength,maxLength,exactLength}from'@regle/rules';function ye(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 b(e){let t=e,n={}.toString.call(e).slice(8,-1);if(n=="Set"&&(t=new Set([...e].map(r=>b(r)))),n=="Map"&&(t=new Map([...e].map(r=>[b(r[0]),b(r[1])]))),n=="Date"&&(t=new Date(e.getTime())),n=="RegExp"&&(t=RegExp(e.source,ye(e))),n=="Array"||n=="Object"){t=Array.isArray(e)?[]:{};for(let r in e)t[r]=b(e[r]);}return t}function l(e){return e&&(e instanceof Date||e.constructor.name=="File"||e.constructor.name=="FileList")?false:typeof e=="object"&&e!==null&&!Array.isArray(e)}function C(e,t,n,r){var a,o;if(Array.isArray(t)&&(a=t.slice(0)),typeof t=="string"&&(a=t.split(".")),typeof t=="symbol"&&(a=[t]),!Array.isArray(a))throw new Error("props arg must be an array, a string or a symbol");if(o=a.pop(),!o)return false;L(o);for(var i;i=a.shift();)if(L(i),isNaN(parseInt(i))?(typeof e[i]>"u"&&(e[i]={}),e=e[i]):((e.$each??=[])[i]={},e=e.$each[i]),!e||typeof e!="object")return false;return r?e[o]={...e[o],$self:n}:e[o]=n,true}function L(e){if(e=="__proto__"||e=="constructor"||e=="prototype")throw new Error("setting of prototype values not supported")}function W(e){let t=e.async,n=r=>{let a=Se(e,r);return a instanceof Promise?a:a.issues?{$valid:false,$issues:a.issues}:{$valid:true,$issues:[]}};return "__depsArray"in e&&Array.isArray(e.__depsArray)&&e.__depsArray.length?t?withAsync(n,e.__depsArray):withParams(n,e.__depsArray):t?withAsync(n):n}function Se(e,t){try{return e.async?new Promise(async n=>{let r=await e["~standard"].validate(t);r.issues?n({$valid:!1,$issues:r.issues}):n({$valid:!0,$issues:[]});}):e["~standard"].validate(t)}catch{return {}}}function q(e){return e.type==="intersect"}function Z(e){return e.type==="object"}function x(e){return "wrapped"in e}function _(e){return q(e)?{entries:e.options.reduce((n,r)=>{let a=_(r);return a&&(n={...n,...a.entries}),n},{}),type:"object",kind:"schema",async:false}:Z(e)?e:x(e)?_(e.wrapped):undefined}function z(e,t){let n=_(e);return n?Object.fromEntries(Object.entries(n.entries).map(([r,a])=>{if(typeof a=="object"){let o=toRef(l(t.value)?t.value:{},r);return [r,T(a,o)]}return [r,{}]})):{}}function _e(e){return e?.type==="literal"}function H(e,t){let n=effectScope();return n.run(()=>{let a=ref({});return watch(t,()=>{if(l(t.value)&&t.value[e.key]){let o=e.options.find(i=>{let s=_(i)?.entries[e.key];return _e(s)&&l(t.value)?s.literal===t.value[e.key]:false});o&&Z(o)?a.value=Object.fromEntries(Object.entries(o.entries).map(([i,f])=>[i,T(f,toRef(l(t.value)?t.value:{},i))])):a.value={};}else a.value={[e.key]:{required:required}};},{deep:true,flush:"pre",immediate:true}),onScopeDispose(()=>{n.stop();}),{valibotRule:a}})}function h(){return e=>{let t=e.$issues?.map(n=>n.message);return t?.length?t.length?t:"Error":[]}}function Oe(e){return e.type==="array"}function De(e){return e.type==="object"}function Ze(e){return e.type==="variant"}function K(e){return x(e)?K(e.wrapped):e}function T(e,t){let n=K(e);return Oe(n)?G(n,t):De(n)?z(n,t):Ze(n)?H(n,t).valibotRule:{[n.type]:withMessage(W(n),h())}}function G(e,t){let n={};return "pipe"in e&&e.pipe.filter(r=>r.kind==="validation").forEach(r=>{n[r.type]=withMessage(a=>{let o=r["~run"]({value:a,typed:true},{});return {$valid:!o.issues,$issues:o.issues}},h());}),{$each:T(e.item,t),...n}}function A(e,t){let n=w(e);function r(a){if(t?.value?.length)return {$valid:false,$issues:t.value};let o=Ie(e,a);return o instanceof Promise?o:o.success?{$valid:true,$issues:[]}:{$valid:false,$issues:o.error?.issues??[]}}return e&&"__depsArray"in e&&Array.isArray(e.__depsArray)&&e.__depsArray.length?n?withAsync(r,e.__depsArray):withParams(r,e.__depsArray):n?withAsync(r):r}function Ie(e,t){if(e)try{return e.safeParse(t)}catch{try{return new Promise(async r=>{let a=await e.safeParseAsync(t);a.success?r({$valid:!0,$issues:[]}):r({$valid:!1,$issues:a.error?.issues});})}catch{return {}}}else return {success:true,data:{}}}function Q(e){if(typeof e!="function")return false;if(e.constructor.name==="AsyncFunction")return true;try{return e()instanceof Promise}catch{return false}}function w(e){if(e?._def){if(e._def.typeName==="ZodEffects"){let t=e._def.effect;return Q(t.refinement||t.transform)}if(e._def.typeName==="ZodObject")return Object.values(e._def.shape()).some(t=>w(t));if(e._def.typeName==="ZodUnion"||e._def.typeName==="ZodIntersection")return e._def.options.some(w);if(e._def.typeName==="ZodArray")return w(e._def.type);if(e._def.typeName==="ZodOptional"||e._def.typeName==="ZodNullable")return w(e._def.innerType);if(e._def.typeName==="ZodTuple")return e._def.items.some(w);if(e._def.typeName==="ZodString"||e._def.typeName==="ZodNumber"||e._def.typeName==="ZodDate")return e._def.checks?.some(t=>Q(t.refinement))}return false}function X(e,t,n){let r=effectScope();return r.run(()=>{let o=ref({});return watch(t,()=>{if(l(t.value)&&t.value[e._def.discriminator]){let i=e._def.optionsMap.get(t.value[e._def.discriminator]);i?o.value=Object.fromEntries(Object.entries(i._def.shape()).map(([f,s])=>typeof s=="object"&&"_def"in s?[f,R({schema:s,state:toRef(l(t.value)?t.value:{}),additionalIssues:n})]:[f,{}])):o.value={};}else o.value={[e._def.discriminator]:{required:required}};},{deep:true,flush:"pre",immediate:true}),onScopeDispose(()=>{r.stop();}),{zodRule:o}})}var $e=["ZodDefault","ZodCatch","ZodNullable","ZodOptional","ZodReadonly"];function Be(e){return e._def&&typeof e._def=="object"&&"typeName"in e._def?$e.includes(e._def.typeName):false}function Fe(e){return e._def&&typeof e._def=="object"&&"typeName"in e._def?"schema"in e._def:false}function k(e){if(e?._def&&typeof e._def=="object"&&"typeName"in e._def)return Be(e)?k(e._def.innerType):Fe(e)?k(e._def.schema):e}function R({schema:e,state:t,additionalIssues:n}){let r=k(e);return r?._def&&"typeName"in r._def?r._def.typeName==="ZodArray"||r._def.typeName==="ZodTuple"?ee(e,t,n).zodRule:r._def.typeName==="ZodObject"||r._def.typeName==="ZodIntersection"?I(r,t,n).zodRule:r._def.typeName==="ZodDiscriminatedUnion"?X(r,t,n).zodRule:n?{[r.constructor.name]:withMessage(withParams(A(e,n),[t]),h())}:{[r.constructor.name]:withMessage(A(e),h())}:{}}function re(e,t=[]){return e._def&&"typeName"in e._def?e._def.typeName==="ZodEffects"?re(e._def.schema,t.concat([e._def.effect])):{nestedSchema:e,nestedEffects:t}:{nestedSchema:undefined}}function ee(e,t,n){let{nestedSchema:r,nestedEffects:a}=re(e),o=ref({});if(r){let i=r._def.typeName==="ZodArray"?{...!!r._def.minLength&&{minLength:minLength(r._def.minLength?.value)},...!!r._def.maxLength&&{maxLength:maxLength(r._def.maxLength?.value)},...!!r._def.exactLength&&{exactLength:exactLength(r._def.exactLength?.value)}}:{};if(a?.length){let f=effectScope();f.run(()=>{let s=ref([]),u=computed(()=>s.value.concat(n?.value??[]));if(n||watch(t,()=>{r&&(s.value=e.safeParse(t.value).error?.issues.filter(d=>d.code==="custom")??[]);},{deep:true,immediate:true}),r){let d=r._def.typeName==="ZodArray"?r._def.type:r._def.items,v=computed(()=>u.value.filter(c=>!c.path.length));o.value={$each:(c,m)=>{let g=computed(()=>u.value?.filter(p=>p.code==="custom")?.filter(p=>p.path[0]===m.toString()).map(p=>{let[le,...B]=p.path;return {...p,path:B}}));return R({schema:d,state:t,additionalIssues:g})},selfValidator:withMessage(withParams(A(undefined,v),[t,v]),h())};}else o.value={};onScopeDispose(()=>{f.stop();});});}else {let f=r._def.typeName==="ZodArray"?r._def.type:r._def.items;o.value={$each:R({schema:f,state:t,additionalIssues:n}),...i};}}return reactive({zodRule:o})}function O(e,t=[]){if(e._def&&"typeName"in e._def){if(e._def.typeName==="ZodEffects")return O(e._def.schema,t.concat([e._def.effect]));if(e._def.typeName==="ZodIntersection"){let{nestedSchema:n,nestedEffects:r=[]}=O(e._def.left),{nestedSchema:a,nestedEffects:o=[]}=O(e._def.right);return n&&a?O(n.merge(a),t.concat(r).concat(o)):{nestedSchema:undefined}}else return {nestedSchema:e,nestedEffects:t}}return {nestedSchema:undefined}}function I(e,t,n){let{nestedSchema:r,nestedEffects:a}=O(e),o=ref({});if(r)if(a?.length){let i=effectScope();i.run(()=>{let f=ref([]),s=computed(()=>f.value.concat(n?.value??[]));watch(t,()=>{r?._def?.typeName==="ZodObject"&&(f.value=(n?.value??[]).concat(e.safeParse(t.value).error?.issues.filter(u=>u.code==="custom")??[]));},{deep:true,flush:"sync",immediate:true}),r?._def?.typeName==="ZodObject"?o.value=Object.fromEntries(Object.entries(r._def.shape()).map(([u,d])=>{if(d&&typeof d=="object"&&"_def"in d){let v=toRef(l(t.value)?t.value:{},u),c=computed(()=>s.value?.filter(m=>m.path[0]===u).map(m=>{let[g,...p]=m.path;return {...m,path:p}}));return [u,R({schema:d,state:v,additionalIssues:c}),[t]]}return [u,{}]})):o.value={},onScopeDispose(()=>{i.stop();});});}else o.value=Object.fromEntries(Object.entries(r._def.shape()).map(([i,f])=>{if(f&&typeof f=="object"&&"_def"in f){let s=toRef(l(t.value)?t.value:{},i);return [i,R({schema:f,state:s,additionalIssues:n})]}return [i,{}]}));return reactive({zodRule:o})}function V(e,t){let n={autoDirty:e?.autoDirty,lazy:e?.lazy,rewardEarly:e?.rewardEarly,clearExternalErrorsOnChange:e?.clearExternalErrorsOnChange};function r(a,o,i){let f=ref({}),s=computed(()=>unref(o)),{mode:u="rules",...d}=i??{},v={...n,...d},c=isRef(a)?a:ref(a),m=ref({...b(c.value)}),g=ref({}),p;if(u==="rules")watch(s,()=>{if(s.value&&typeof s.value=="object")if(s.value["~standard"].vendor==="zod"){let N=I(s.value,c);f.value=N.zodRule;}else s.value["~standard"].vendor==="valibot"?f.value=reactive(z(s.value,c)):s.value?.["~standard"]?.vendor?console.warn(`This RPC library "${s.value["~standard"].vendor}" is not supported yet in 'rules' mode, switch to the "schema" mode option`):console.warn('Only "standard-schema" compatible libraries are supported');},{deep:true,immediate:true,flush:"post"});else {let D=function(S){let F={};return S.issues&&S.issues.map(y=>{let pe=y.path?.map(j=>typeof j=="object"?j.key:j).join("."),P=y.path?.[y.path.length-1],de=(typeof P=="object"&&"value"in P?Array.isArray(P.value):false)||("type"in y?y.type==="array":false);return {path:pe,message:y.message,isArray:de}}).forEach(y=>{C(F,y.path,[y.message],y.isArray);}),F};if(!s.value?.["~standard"])throw new Error('Only "standard-schema" compatible libraries are supported');let N=s.value["~standard"].validate(m.value);g.value=D(N),watch([c,s],async()=>{let S=await s.value["~standard"].validate(c.value);g.value=D(S);},{deep:true,immediate:true,flush:"post"}),p=async()=>{try{let S=await s.value["~standard"].validate(c.value);return g.value=D(S),{result:!S.issues?.length,data:c.value}}catch(S){return Promise.reject(S)}};}return {r$:useRootStorage({scopeRules:f,state:c,options:v,schemaErrors:g,initialState:m,shortcuts:t,schemaMode:u==="schema",onValidate:p}).regle}}return r}var ie=V();function fe(e,t){return Object.hasOwn(e,"__depsArray")||Object.defineProperties(e,{__depsArray:{value:t,enumerable:false,configurable:false,writable:false}}),e}function $(){function e(t,n){return n}return e}var ce=$();function ue({modifiers:e,shortcuts:t}){let n=V(e,t),r=$();return {useRegleSchema:n,inferSchema:r}}export{ue as defineRegleSchemaConfig,ce as inferSchema,ie as useRegleSchema,fe as withDeps};
1
+ import {useRootStorage}from'@regle/core';import {ref,computed,unref,isRef,watch}from'vue';function F(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 l(e){let t=e,r={}.toString.call(e).slice(8,-1);if(r=="Set"&&(t=new Set([...e].map(a=>l(a)))),r=="Map"&&(t=new Map([...e].map(a=>[l(a[0]),l(a[1])]))),r=="Date"&&(t=new Date(e.getTime())),r=="RegExp"&&(t=RegExp(e.source,F(e))),r=="Array"||r=="Object"){t=Array.isArray(e)?[]:{};for(let a in e)t[a]=l(e[a]);}return t}function w(e,t,r,a){var n,o;if(Array.isArray(t)&&(n=t.slice(0)),typeof t=="string"&&(n=t.split(".")),typeof t=="symbol"&&(n=[t]),!Array.isArray(n))throw new Error("props arg must be an array, a string or a symbol");if(o=n.pop(),!o)return false;x(o);for(var i;i=n.shift();)if(x(i),isNaN(parseInt(i))?(typeof e[i]>"u"&&(e[i]={}),e=e[i]):((e.$each??=[])[i]={},e=e.$each[i]),!e||typeof e!="object")return false;return a?e[o]?e[o].$self=(e[o].$self??=[]).concat(r):e[o]={...e[o],$self:r}:Array.isArray(e[o])?e[o]=e[o].concat(r):e[o]=r,true}function I(e,t,r){if(!e)return r;var a,n;if(Array.isArray(t)&&(a=t.slice(0)),typeof t=="string"&&(a=t.split(".")),typeof t=="symbol"&&(a=[t]),!Array.isArray(a))throw new Error("props arg must be an array, a string or a symbol");for(;a.length;)if(n=a.shift(),!e||!n||(e=e[n],e===undefined))return r;return e}function x(e){if(e=="__proto__"||e=="constructor"||e=="prototype")throw new Error("setting of prototype values not supported")}function h(e,t){let r={autoDirty:e?.autoDirty,lazy:e?.lazy,rewardEarly:e?.rewardEarly,clearExternalErrorsOnChange:e?.clearExternalErrorsOnChange};function a(n,o,i){let O=ref({}),m=computed(()=>unref(o)),M={...r,...i},f=isRef(n)?n:ref(n),E=ref({...l(f.value)}),d=ref({}),R;if(!m.value?.["~standard"])throw new Error('Only "standard-schema" compatible libraries are supported');function N(s){let T={};return s.issues&&s.issues.map(c=>{let D=c.path?.map(y=>typeof y=="object"?y.key:y.toString()).join(".")??"",u=c.path?.[c.path.length-1],A=(typeof u=="object"&&"value"in u?Array.isArray(u.value):false)||("type"in c?c.type==="array":false)||Array.isArray(I(f.value,D));return {path:D,message:c.message,isArray:A}}).forEach(c=>{w(T,c.path,[c.message],c.isArray);}),T}async function g(){let s=m.value["~standard"].validate(f.value);return s instanceof Promise&&(s=await s),d.value=N(s),s}return watch([f,m],g,{deep:true,immediate:true}),R=async()=>{try{return {result:!(await g()).issues?.length,data:f.value}}catch(s){return Promise.reject(s)}},{r$:useRootStorage({scopeRules:O,state:f,options:M,schemaErrors:d,initialState:E,shortcuts:t,schemaMode:true,onValidate:R}).regle}}return a}var v=h();function P(e,t){return e}function S(){function e(t,r){return r}return e}var V=S();function b({modifiers:e,shortcuts:t}){let r=h(e,t),a=S();return {useRegleSchema:r,inferSchema:a}}export{b as defineRegleSchemaConfig,V as inferSchema,v as useRegleSchema,P as withDeps};