@regle/schemas 1.19.0-beta.3 → 1.19.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,5 +1,5 @@
1
1
  /**
2
- * @regle/schemas v1.19.0-beta.3
2
+ * @regle/schemas v1.19.0
3
3
  * (c) 2026 Victor Garcia
4
4
  * @license MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @regle/schemas v1.19.0-beta.3
2
+ * @regle/schemas v1.19.0
3
3
  * (c) 2026 Victor Garcia
4
4
  * @license MIT
5
5
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
- * @regle/schemas v1.19.0-beta.3
2
+ * @regle/schemas v1.19.0
3
3
  * (c) 2026 Victor Garcia
4
4
  * @license MIT
5
5
  */
6
6
 
7
- 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`}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??=[],h(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}:isNaN(parseInt(a))?Array.isArray(e[a])?e[a]=e[a].concat(n):e[a]=n:(e.$each??=[],e.$each[a]=(e.$each[a]??=[]).concat(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,t=!0,n=!0){return e==null?!0:e instanceof Date?isNaN(e.getTime()):l(e)?e.size<=0:Array.isArray(e)?t?e.length===0:!1:u(e)?e==null?!0:n?Object.keys(e).length===0:!1:!String(e).length}function g(e){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 _(e,t=0){if(t>20)return e;let n=e,r={}.toString.call(e).slice(8,-1);if(r==`Set`&&(n=new Set([...e].map(e=>_(e,t++)))),r==`Map`&&(n=new Map([...e].map(e=>[_(e[0]),_(e[1])]))),r==`Date`&&(n=new Date(e.getTime())),r==`RegExp`&&(n=RegExp(e.source,g(e))),r==`Array`||r==`Object`)for(let r in n=Array.isArray(e)?[]:{},e)n[r]=_(e[r],t++);return n}function v(e){let{options:l,shortcuts:p,overrides:h}=e??{};function g(e,g,v){let y=n(()=>s(g)),{syncState:b={onUpdate:!1,onValidate:!1},...x}=v??{},{onUpdate:S=!1,onValidate:C=!1}=b,w={...l,...x},T=n(()=>!u(E.value)),E=i(e)?e:o(e),D=o(u(E.value)?{..._(E.value)}:_(E.value)),O=u(E.value)?{..._(E.value)}:_(E.value),k=o({}),A=o([]),j;function M(e){let t=N(e),n=e.path?.[e.path.length-1],r=typeof n==`object`?n.key:n;return{isArray:(typeof n==`object`&&`value`in n?Array.isArray(n.value):!1)||(`type`in e?e.type===`array`:!1)||Array.isArray(f(E.value,t)),$path:t,lastItemKey:r,lastItem:n}}function N(e){return e.path?.map(e=>typeof e==`object`?e.key:e.toString()).join(`.`)??``}function P(e){let t=e.path?.at(-1);return typeof t==`object`?t.key:t}function F(e){let t=e.path?.at(-1),n=typeof t==`object`?typeof t.key==`string`:typeof t==`string`,r=e.path?.findLastIndex(e=>typeof e==`object`?typeof e.key==`number`:typeof e==`number`);if(!(!n&&r===-1)&&r!=null){let t=e.path?.slice(0,r+1);return{...e,path:t}}}if(!y.value?.[`~standard`])throw Error(`Only "standard-schema" compatible libraries are supported`);function I(e,t=!1){return!t&&w.rewardEarly?A.value.length?A.value.reduce((t,n)=>{if(`$currentArrayValue`in n&&u(n.$currentArrayValue)&&`$id`in n.$currentArrayValue){let r=n.$currentArrayValue.$id,i=P(n),a=e.find(e=>e?.$currentArrayValue?.$id===r&&P(e)===i);a&&t.push({...n,path:a?.path??[]})}else e.some(e=>N(e)===N(n))&&t.push(n);return t},[]):[]:e}function L(e,t=!1){let n={},r=e.issues?.map(e=>{let t=F(e);if(t){let n=f(E.value,N(t));Object.defineProperty(e,`$currentArrayValue`,{value:n,enumerable:!0,configurable:!0,writable:!0})}return e}),i=I(r??[],t);if(r?.length){let e=i.map(e=>{let{isArray:t,$path:n,lastItemKey:r}=M(e);return{...e,$path:n,isArray:t,$property:r,$rule:`schema`,$message:e.message}});e.forEach(({isArray:e,$path:t,...r})=>{d(n,t,[r],e)}),A.value=e}else A.value=[];return n}async function R(e=!1){let t=y.value[`~standard`].validate(E.value);return t instanceof Promise&&(t=await t),T.value?k.value=I(t.issues??[],e)?.map(e=>({$message:e.message,$property:e.path?.[e.path.length-1]?.toString()??`-`,$rule:`schema`,...e}))??[]:k.value=L(t,e),t.issues||(e&&C||!e&&S)&&(z?.(),u(E.value)?E.value=m(E.value,t.value):E.value=t.value,B()),t}let z;function B(){z=c([E,y],()=>{w.silent||R()},{deep:!0})}B(),R(),j=async()=>{try{let e=await R(!0);return V?.regle?.$touch(),{valid:!e.issues?.length,data:E.value,errors:V?.regle?.$errors,issues:k.value}}catch(e){return Promise.reject(e)}},r()&&a(()=>{z()});let V=t({scopeRules:n(()=>({})),state:E,options:w,schemaErrors:k,initialState:D,originalState:O,shortcuts:p,schemaMode:!0,onValidate:j,overrides:h});return{r$:V.regle}}return g}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,overrides:n}){return{useRegleSchema:v({options:e,shortcuts:t,overrides:n}),inferSchema:x()}}const w=t=>{let{customStore:n,customUseRegle:r=y,asRecord:i=!1}=t??{};return e({customStore:n,customUseRegle:r,asRecord:i})},{useCollectScope:T,useScopedRegle:E}=e({customUseRegle:y}),D=T,O=E;export{w as createScopedUseRegleSchema,C as defineRegleSchemaConfig,S as inferSchema,D as useCollectSchemaScope,y as useRegleSchema,O as useScopedRegleSchema,b as withDeps};
7
+ 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`}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??=[],h(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}:isNaN(parseInt(a))?Array.isArray(e[a])?e[a]=e[a].concat(n):e[a]=n:(e.$each??=[],e.$each[a]=(e.$each[a]??=[]).concat(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,t=!0,n=!0){return e==null?!0:e instanceof Date?isNaN(e.getTime()):l(e)?e.size<=0:Array.isArray(e)?t?e.length===0:!1:u(e)?e==null?!0:n?Object.keys(e).length===0:!1:!String(e).length}function g(e){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 _(e,t=0){if(t>20)return e;let n=e,r={}.toString.call(e).slice(8,-1);if(r==`Set`&&(n=new Set([...e].map(e=>_(e,t++)))),r==`Map`&&(n=new Map([...e].map(e=>[_(e[0]),_(e[1])]))),r==`Date`&&(n=new Date(e.getTime())),r==`RegExp`&&(n=RegExp(e.source,g(e))),r==`Array`||r==`Object`){n=Array.isArray(e)?[]:{};for(let r in e)n[r]=_(e[r],t++)}return n}function v(e){let{options:l,shortcuts:p,overrides:h}=e??{};function g(e,g,v){let y=n(()=>s(g)),{syncState:b={onUpdate:!1,onValidate:!1},...x}=v??{},{onUpdate:S=!1,onValidate:C=!1}=b,w={...l,...x},T=n(()=>!u(E.value)),E=i(e)?e:o(e),D=o(u(E.value)?{..._(E.value)}:_(E.value)),O=u(E.value)?{..._(E.value)}:_(E.value),k=o({}),A=o([]),j;function M(e){let t=N(e),n=e.path?.[e.path.length-1],r=typeof n==`object`?n.key:n;return{isArray:(typeof n==`object`&&`value`in n?Array.isArray(n.value):!1)||(`type`in e?e.type===`array`:!1)||Array.isArray(f(E.value,t)),$path:t,lastItemKey:r,lastItem:n}}function N(e){return e.path?.map(e=>typeof e==`object`?e.key:e.toString()).join(`.`)??``}function P(e){let t=e.path?.at(-1);return typeof t==`object`?t.key:t}function F(e){let t=e.path?.at(-1),n=typeof t==`object`?typeof t.key==`string`:typeof t==`string`,r=e.path?.findLastIndex(e=>typeof e==`object`?typeof e.key==`number`:typeof e==`number`);if(!(!n&&r===-1)&&r!=null){let t=e.path?.slice(0,r+1);return{...e,path:t}}}if(!y.value?.[`~standard`])throw Error(`Only "standard-schema" compatible libraries are supported`);function I(e,t=!1){return!t&&w.rewardEarly?A.value.length?A.value.reduce((t,n)=>{if(`$currentArrayValue`in n&&u(n.$currentArrayValue)&&`$id`in n.$currentArrayValue){let r=n.$currentArrayValue.$id,i=P(n),a=e.find(e=>e?.$currentArrayValue?.$id===r&&P(e)===i);a&&t.push({...n,path:a?.path??[]})}else e.some(e=>N(e)===N(n))&&t.push(n);return t},[]):[]:e}function L(e,t=!1){let n={},r=e.issues?.map(e=>{let t=F(e);if(t){let n=f(E.value,N(t));Object.defineProperty(e,`$currentArrayValue`,{value:n,enumerable:!0,configurable:!0,writable:!0})}return e}),i=I(r??[],t);if(r?.length){let e=i.map(e=>{let{isArray:t,$path:n,lastItemKey:r}=M(e);return{...e,$path:n,isArray:t,$property:r,$rule:`schema`,$message:e.message}});e.forEach(({isArray:e,$path:t,...r})=>{d(n,t,[r],e)}),A.value=e}else A.value=[];return n}async function R(e=!1){let t=y.value[`~standard`].validate(E.value);return t instanceof Promise&&(t=await t),T.value?k.value=I(t.issues??[],e)?.map(e=>({$message:e.message,$property:e.path?.[e.path.length-1]?.toString()??`-`,$rule:`schema`,...e}))??[]:k.value=L(t,e),t.issues||(e&&C||!e&&S)&&(z?.(),u(E.value)?E.value=m(E.value,t.value):E.value=t.value,B()),t}let z;function B(){z=c([E,y],()=>{w.silent||R()},{deep:!0})}B(),R(),j=async()=>{try{let e=await R(!0);return V?.regle?.$touch(),{valid:!e.issues?.length,data:E.value,errors:V?.regle?.$errors,issues:k.value}}catch(e){return Promise.reject(e)}},r()&&a(()=>{z()});let V=t({scopeRules:n(()=>({})),state:E,options:w,schemaErrors:k,initialState:D,originalState:O,shortcuts:p,schemaMode:!0,onValidate:j,overrides:h});return{r$:V.regle}}return g}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,overrides:n}){return{useRegleSchema:v({options:e,shortcuts:t,overrides:n}),inferSchema:x()}}const w=t=>{let{customStore:n,customUseRegle:r=y,asRecord:i=!1}=t??{};return e({customStore:n,customUseRegle:r,asRecord:i})},{useCollectScope:T,useScopedRegle:E}=e({customUseRegle:y}),D=T,O=E;export{w as createScopedUseRegleSchema,C as defineRegleSchemaConfig,S as inferSchema,D as useCollectSchemaScope,y as useRegleSchema,O as useScopedRegleSchema,b as withDeps};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@regle/schemas",
3
- "version": "1.19.0-beta.3",
3
+ "version": "1.19.0",
4
4
  "description": "Schemas adapter for Regle",
5
5
  "homepage": "https://reglejs.dev/",
6
6
  "license": "MIT",
@@ -36,20 +36,20 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@standard-schema/spec": "1.1.0",
39
- "type-fest": "5.4.3",
40
- "@regle/core": "1.19.0-beta.3",
41
- "@regle/rules": "1.19.0-beta.3"
39
+ "type-fest": "5.4.4",
40
+ "@regle/core": "1.19.0",
41
+ "@regle/rules": "1.19.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@total-typescript/ts-reset": "0.6.1",
45
- "@types/node": "24.10.10",
45
+ "@types/node": "24.10.13",
46
46
  "@vue/test-utils": "2.4.6",
47
- "tsdown": "0.20.1",
48
- "type-fest": "5.4.3",
47
+ "tsdown": "0.20.3",
48
+ "type-fest": "5.4.4",
49
49
  "typescript": "5.9.3",
50
50
  "valibot": "1.2.0",
51
51
  "vitest": "4.0.18",
52
- "vue": "3.5.27",
52
+ "vue": "3.5.28",
53
53
  "vue-tsc": "3.2.4",
54
54
  "zod": "4.3.6"
55
55
  },