@regle/schemas 1.5.3 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1096,7 +1096,7 @@ interface RegleBehaviourOptions {
1096
1096
  clearExternalErrorsOnChange?: boolean | undefined;
1097
1097
  }
1098
1098
  interface LocalRegleBehaviourOptions<TState extends Record<string, any>, TRules extends ReglePartialRuleTree<TState, CustomRulesDeclarationTree>, TValidationGroups extends Record<string, RegleValidationGroupEntry[]> = {}> {
1099
- externalErrors?: Ref<RegleExternalErrorTree<Unwrap<TState>>>;
1099
+ externalErrors?: Ref<RegleExternalErrorTree<Unwrap<TState>> | Record<string, string[]>>;
1100
1100
  validationGroups?: (fields: RegleStatus<TState, TRules>['$fields']) => TValidationGroups;
1101
1101
  }
1102
1102
  type RegleValidationGroupEntry = RegleFieldStatus<any, any>;
@@ -1236,7 +1236,7 @@ type SafeProperty<TState, TRule extends RegleFormPropertyType<any, any> | undefi
1236
1236
  type IsPropertyOutputRequired<TState, TRule extends RegleFormPropertyType<any, any> | undefined> = [unknown] extends [TState] ? unknown : NonNullable<TState> extends Array<any> ? TRule extends RegleCollectionRuleDecl<any, any> ? ArrayHaveAtLeastOneRequiredField<NonNullable<TState>, TRule> extends false ? false : true : false : TRule extends ReglePartialRuleTree<any, any> ? ExtendOnlyRealRecord<TState> extends true ? ObjectHaveAtLeastOneRequiredField<NonNullable<TState> extends Record<string, any> ? NonNullable<TState> : {}, TRule> extends false ? false : true : TRule extends RegleRuleDecl<any, any> ? FieldHaveRequiredRule<TRule> extends false ? false : true : false : false;
1237
1237
  type SafeFieldProperty<TState, TRule extends RegleFormPropertyType<any, any> | undefined = never> = FieldHaveRequiredRule<TRule> extends true ? NonNullable<TState> : MaybeOutput<TState>;
1238
1238
  //#endregion
1239
- //#region ../../node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/utils.d.ts
1239
+ //#region ../../node_modules/.pnpm/expect-type@1.2.2/node_modules/expect-type/dist/utils.d.ts
1240
1240
  /**
1241
1241
  * Negates a boolean type.
1242
1242
  */
@@ -1375,7 +1375,7 @@ type IsUnion<T> = Not<Extends<UnionToTuple$1<T>['length'], 1>>;
1375
1375
  * ```
1376
1376
  */
1377
1377
  //#endregion
1378
- //#region ../../node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/overloads.d.ts
1378
+ //#region ../../node_modules/.pnpm/expect-type@1.2.2/node_modules/expect-type/dist/overloads.d.ts
1379
1379
  /**
1380
1380
  * The simple(ish) way to get overload info from a function
1381
1381
  * {@linkcode FunctionType}. Recent versions of TypeScript will match any
@@ -1642,7 +1642,7 @@ type ConstructorOverloadParameters<ConstructorType> = ConstructorOverloadsUnion<
1642
1642
  */
1643
1643
  type NumOverloads<FunctionType> = UnionToTuple$1<OverloadsInfoUnion<FunctionType>>['length'];
1644
1644
  //#endregion
1645
- //#region ../../node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/branding.d.ts
1645
+ //#region ../../node_modules/.pnpm/expect-type@1.2.2/node_modules/expect-type/dist/branding.d.ts
1646
1646
  /**
1647
1647
  * Represents a deeply branded type.
1648
1648
  *
@@ -1697,7 +1697,7 @@ type DeepBrand<T> = IsNever$2<T> extends true ? {
1697
1697
  */
1698
1698
  type StrictEqualUsingBranding<Left, Right> = MutuallyExtends<DeepBrand<Left>, DeepBrand<Right>>;
1699
1699
  //#endregion
1700
- //#region ../../node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/messages.d.ts
1700
+ //#region ../../node_modules/.pnpm/expect-type@1.2.2/node_modules/expect-type/dist/messages.d.ts
1701
1701
  /**
1702
1702
  * Determines the printable type representation for a given type.
1703
1703
  */
@@ -1783,13 +1783,15 @@ type NormalizeUnion<TUnion> = RetrieveUnionUnknownValues<NonNullable<UnionToTupl
1783
1783
  * Combine all members of a union type, merging types for each key, and keeping loose types
1784
1784
  */
1785
1785
  type JoinDiscriminatedUnions<TUnion extends unknown> = HasNamedKeys<TUnion> extends true ? isRecordLiteral<TUnion> extends true ? Prettify<Partial<UnionToIntersection<RemoveCommonKey<UnionToTuple<NonNullable<TUnion>>, keyof NormalizeUnion<NonNullable<TUnion>>>[number]>> & Pick<NormalizeUnion<NonNullable<TUnion>>, keyof NormalizeUnion<NonNullable<TUnion>>>> : TUnion : TUnion;
1786
+ type LazyJoinDiscriminatedUnions<TUnion extends unknown> = isRecordLiteral<TUnion> extends true ? Prettify<Partial<UnionToIntersection<RemoveCommonKey<UnionToTuple<TUnion>, keyof NonNullable<TUnion>>[number]>> & Pick<NonNullable<TUnion>, keyof NonNullable<TUnion>>> : TUnion;
1786
1787
  type EnumLike = {
1787
1788
  [k: string]: string | number;
1788
1789
  [nu: number]: string;
1789
1790
  };
1790
1791
  type UnwrapMaybeRef<T extends MaybeRef<any> | DeepReactiveState<any>> = T extends Ref<any> ? UnwrapRef<T> : UnwrapNestedRefs<T>;
1791
1792
  type TupleToPlainObj<T> = { [I in keyof T & `${number}`]: T[I] };
1792
- type HasNamedKeys<T> = { [K in keyof NonNullable<T>]: K extends string ? (string extends K ? never : K) : never }[keyof NonNullable<T>] extends never ? false : true;
1793
+ type HasNamedKeys<T> = IsUnion<T> extends true ? ProcessHasNamedKeys<LazyJoinDiscriminatedUnions<T>> : ProcessHasNamedKeys<T>;
1794
+ type ProcessHasNamedKeys<T> = { [K in keyof NonNullable<T>]: K extends string ? (string extends K ? never : K) : never }[keyof NonNullable<T>] extends never ? false : true;
1793
1795
  //#endregion
1794
1796
  //#region src/types/utils/mismatch.types.d.ts
1795
1797
  type isDeepExact<TRules, TTree> = { [K in keyof TRules]-?: CheckDeepExact<NonNullable<TRules[K]>, K extends keyof JoinDiscriminatedUnions<TTree> ? NonNullable<JoinDiscriminatedUnions<TTree>[K]> : never> }[keyof TRules] extends true ? true : false;
@@ -3392,4 +3394,4 @@ declare const createScopedUseRegleSchema: <TCustomRegle extends useRegleSchemaFn
3392
3394
  useCollectScope: useCollectScopeFn<TAsRecord>;
3393
3395
  };
3394
3396
  //#endregion
3395
- export { InferRegleSchemaStatusType, RegleSchema, RegleSchemaBehaviourOptions, RegleSchemaCollectionStatus, RegleSchemaFieldStatus, RegleSchemaResult, RegleSchemaStatus, RegleSingleFieldSchema, createScopedUseRegleSchema, defineRegleSchemaConfig, inferSchema, useCollectSchemaScope, useRegleSchema, useScopedRegleSchema, withDeps };
3397
+ export { type InferRegleSchemaStatusType, type RegleSchema, type RegleSchemaBehaviourOptions, type RegleSchemaCollectionStatus, type RegleSchemaFieldStatus, type RegleSchemaResult, type RegleSchemaStatus, type RegleSingleFieldSchema, createScopedUseRegleSchema, defineRegleSchemaConfig, inferSchema, useCollectSchemaScope, useRegleSchema, useScopedRegleSchema, withDeps };
@@ -1 +1 @@
1
- import{createScopedUseRegle as e,useRootStorage as t}from"@regle/core";import{computed as n,isRef as r,ref as i,unref as a,watch as o}from"vue";const s=Symbol(`regle-rule`);function c(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,n={}.toString.call(e).slice(8,-1);if(n==`Set`&&(t=new Set([...e].map(e=>l(e)))),n==`Map`&&(t=new Map([...e].map(e=>[l(e[0]),l(e[1])]))),n==`Date`&&(t=new Date(e.getTime())),n==`RegExp`&&(t=RegExp(e.source,c(e))),n==`Array`||n==`Object`)for(let n in t=Array.isArray(e)?[]:{},e)t[n]=l(e[n]);return t}function u(e){return e&&(e instanceof Date||e.constructor.name==`File`||e.constructor.name==`FileList`)?!1:typeof e==`object`&&!!e&&!Array.isArray(e)}function d(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;p(a);for(var o;o=i.shift();)if(p(o),isNaN(parseInt(o))?(e[o]===void 0&&(e[o]={}),e=e[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]={...e[a],$self:n}:Array.isArray(e[a])?e[a]=e[a].concat(n):e[a]=n,!0}function f(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 p(e){if(e==`__proto__`||e==`constructor`||e==`prototype`)throw Error(`setting of prototype values not supported`)}function m(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 h(e,s){let c={autoDirty:e?.autoDirty,lazy:e?.lazy,rewardEarly:e?.rewardEarly,clearExternalErrorsOnChange:e?.clearExternalErrorsOnChange};function p(e,p,h){let g=n(()=>a(p)),{syncState:_={onUpdate:!1,onValidate:!1},...v}=h??{},{onUpdate:y=!1,onValidate:b=!1}=_,x={...c,...v},S=n(()=>!u(C.value)),C=r(e)?e:i(e),w=i(u(C.value)?{...l(C.value)}:l(C.value)),T=i({}),E;if(!g.value?.[`~standard`])throw Error(`Only "standard-schema" compatible libraries are supported`);function D(e){let t={};if(e.issues){let n=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(f(C.value,t)),a=!i&&typeof r==`number`;return a&&(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}});n.forEach(({isArray:e,$path:n,...r})=>{d(t,n,[r],e)})}return t}async function O(e=!1){let t=g.value[`~standard`].validate(C.value);return t instanceof Promise&&(t=await t),S.value?T.value=t.issues?.map(e=>({$message:e.message,$property:e.path?.[e.path.length-1]?.toString()??`-`,$rule:`schema`,...e}))??[]:T.value=D(t),t.issues||(e&&b||!e&&y)&&(k?.(),u(C.value)?C.value=m(C.value,t.value):C.value=t.value,A()),t}let k;function A(){k=o([C,g],()=>O(),{deep:!0})}A(),O(),E=async()=>{try{let e=await O(!0);return{valid:!e.issues?.length,data:C.value}}catch(e){return Promise.reject(e)}};let j=t({scopeRules:n(()=>({})),state:C,options:x,schemaErrors:T,initialState:w,shortcuts:s,schemaMode:!0,onValidate:E});return{r$:j.regle}}return p}const g=h();function _(e,t){return e}function v(){function e(e,t){return t}return e}const y=v();function b({modifiers:e,shortcuts:t}){let n=h(e,t),r=v();return{useRegleSchema:n,inferSchema:r}}const{useCollectScope:x,useScopedRegle:S}=e({customUseRegle:g}),C=t=>{let{customStore:n,customUseRegle:r=g,asRecord:i=!1}=t??{};return e({customStore:n,customUseRegle:r,asRecord:i})};export{C as createScopedUseRegleSchema,b as defineRegleSchemaConfig,y as inferSchema,x as useCollectSchemaScope,g as useRegleSchema,S as useScopedRegleSchema,_ as withDeps};
1
+ import{createScopedUseRegle as e,useRootStorage as t}from"@regle/core";import{computed as n,isRef as r,ref as i,unref as a,watch as o}from"vue";Symbol(`regle-rule`);function s(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 c(e){let t=e,n={}.toString.call(e).slice(8,-1);if(n==`Set`&&(t=new Set([...e].map(e=>c(e)))),n==`Map`&&(t=new Map([...e].map(e=>[c(e[0]),c(e[1])]))),n==`Date`&&(t=new Date(e.getTime())),n==`RegExp`&&(t=RegExp(e.source,s(e))),n==`Array`||n==`Object`)for(let n in t=Array.isArray(e)?[]:{},e)t[n]=c(e[n]);return t}function l(e){return e&&(e instanceof Date||e.constructor.name==`File`||e.constructor.name==`FileList`)?!1:typeof e==`object`&&!!e&&!Array.isArray(e)}function u(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;f(a);for(var o;o=i.shift();)if(f(o),isNaN(parseInt(o))?(e[o]===void 0&&(e[o]={}),e=e[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]={...e[a],$self:n}:Array.isArray(e[a])?e[a]=e[a].concat(n):e[a]=n,!0}function d(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 f(e){if(e==`__proto__`||e==`constructor`||e==`prototype`)throw Error(`setting of prototype values not supported`)}function p(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 m(e,s){let f={autoDirty:e?.autoDirty,lazy:e?.lazy,rewardEarly:e?.rewardEarly,clearExternalErrorsOnChange:e?.clearExternalErrorsOnChange};function m(e,m,h){let g=n(()=>a(m)),{syncState:_={onUpdate:!1,onValidate:!1},...v}=h??{},{onUpdate:y=!1,onValidate:b=!1}=_,x={...f,...v},S=n(()=>!l(C.value)),C=r(e)?e:i(e),w=i(l(C.value)?{...c(C.value)}:c(C.value)),T=i({}),E;if(!g.value?.[`~standard`])throw Error(`Only "standard-schema" compatible libraries are supported`);function D(e){let t={};if(e.issues){let n=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(d(C.value,t)),a=!i&&typeof r==`number`;return a&&(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}});n.forEach(({isArray:e,$path:n,...r})=>{u(t,n,[r],e)})}return t}async function O(e=!1){let t=g.value[`~standard`].validate(C.value);return t instanceof Promise&&(t=await t),S.value?T.value=t.issues?.map(e=>({$message:e.message,$property:e.path?.[e.path.length-1]?.toString()??`-`,$rule:`schema`,...e}))??[]:T.value=D(t),t.issues||(e&&b||!e&&y)&&(k?.(),l(C.value)?C.value=p(C.value,t.value):C.value=t.value,A()),t}let k;function A(){k=o([C,g],()=>O(),{deep:!0})}A(),O(),E=async()=>{try{let e=await O(!0);return{valid:!e.issues?.length,data:C.value}}catch(e){return Promise.reject(e)}};let j=t({scopeRules:n(()=>({})),state:C,options:x,schemaErrors:T,initialState:w,shortcuts:s,schemaMode:!0,onValidate:E});return{r$:j.regle}}return m}const h=m();function g(e,t){return e}function _(){function e(e,t){return t}return e}const v=_();function y({modifiers:e,shortcuts:t}){let n=m(e,t),r=_();return{useRegleSchema:n,inferSchema:r}}const{useCollectScope:b,useScopedRegle:x}=e({customUseRegle:h}),S=t=>{let{customStore:n,customUseRegle:r=h,asRecord:i=!1}=t??{};return e({customStore:n,customUseRegle:r,asRecord:i})};export{S as createScopedUseRegleSchema,y as defineRegleSchemaConfig,v as inferSchema,b as useCollectSchemaScope,h as useRegleSchema,x as useScopedRegleSchema,g as withDeps};
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@regle/schemas",
3
- "version": "1.5.3",
3
+ "version": "1.6.1",
4
4
  "description": "Schemas adapter for Regle",
5
5
  "dependencies": {
6
6
  "@standard-schema/spec": "1.0.0",
7
- "@regle/core": "1.5.3",
8
- "@regle/rules": "1.5.3"
7
+ "@regle/core": "1.6.1",
8
+ "@regle/rules": "1.6.1"
9
9
  },
10
10
  "peerDependencies": {
11
11
  "valibot": "^1.0.0",
@@ -25,23 +25,23 @@
25
25
  },
26
26
  "devDependencies": {
27
27
  "@total-typescript/ts-reset": "0.6.1",
28
- "@types/node": "22.15.33",
29
- "@typescript-eslint/eslint-plugin": "8.37.0",
30
- "@typescript-eslint/parser": "8.37.0",
28
+ "@types/node": "22.16.5",
29
+ "@typescript-eslint/eslint-plugin": "8.38.0",
30
+ "@typescript-eslint/parser": "8.38.0",
31
31
  "@vue/test-utils": "2.4.6",
32
- "eslint": "9.29.0",
33
- "eslint-config-prettier": "10.1.5",
34
- "eslint-plugin-vue": "10.2.0",
35
- "prettier": "3.6.1",
36
- "tsdown": "0.12.9",
32
+ "eslint": "9.31.0",
33
+ "eslint-config-prettier": "10.1.8",
34
+ "eslint-plugin-vue": "10.3.0",
35
+ "prettier": "3.6.2",
36
+ "tsdown": "0.13.0",
37
37
  "type-fest": "4.41.0",
38
38
  "typescript": "5.8.3",
39
39
  "valibot": "1.1.0",
40
40
  "vitest": "3.2.4",
41
41
  "vue": "3.5.17",
42
- "vue-eslint-parser": "10.1.4",
43
- "vue-tsc": "2.2.10",
44
- "zod": "3.25.67"
42
+ "vue-eslint-parser": "10.2.0",
43
+ "vue-tsc": "3.0.3",
44
+ "zod": "4.0.5"
45
45
  },
46
46
  "type": "module",
47
47
  "exports": {