@regle/schemas 0.9.0 → 0.10.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.
package/dist/regle-schemas.cjs
CHANGED
|
@@ -186,7 +186,7 @@ function createUseRegleSchemaComposable(options, shortcuts) {
|
|
|
186
186
|
try {
|
|
187
187
|
const result = await computeErrors();
|
|
188
188
|
return {
|
|
189
|
-
|
|
189
|
+
valid: !result.issues?.length,
|
|
190
190
|
data: processedState.value
|
|
191
191
|
};
|
|
192
192
|
} catch (e) {
|
package/dist/regle-schemas.d.cts
CHANGED
|
@@ -184,10 +184,10 @@ interface RegleSchema<TState extends Record<string, any>, TSchema extends Record
|
|
|
184
184
|
r$: Raw<RegleSchemaStatus<TState, TSchema, TShortcuts, true>>;
|
|
185
185
|
}
|
|
186
186
|
type RegleSchemaResult<TSchema extends unknown> = {
|
|
187
|
-
|
|
187
|
+
valid: false;
|
|
188
188
|
data: PartialDeep<TSchema>;
|
|
189
189
|
} | {
|
|
190
|
-
|
|
190
|
+
valid: true;
|
|
191
191
|
data: TSchema;
|
|
192
192
|
};
|
|
193
193
|
/**
|
package/dist/regle-schemas.d.ts
CHANGED
|
@@ -184,10 +184,10 @@ interface RegleSchema<TState extends Record<string, any>, TSchema extends Record
|
|
|
184
184
|
r$: Raw<RegleSchemaStatus<TState, TSchema, TShortcuts, true>>;
|
|
185
185
|
}
|
|
186
186
|
type RegleSchemaResult<TSchema extends unknown> = {
|
|
187
|
-
|
|
187
|
+
valid: false;
|
|
188
188
|
data: PartialDeep<TSchema>;
|
|
189
189
|
} | {
|
|
190
|
-
|
|
190
|
+
valid: true;
|
|
191
191
|
data: TSchema;
|
|
192
192
|
};
|
|
193
193
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var core=require('@regle/core'),vue=require('vue');function A(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,A(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({}),p=vue.computed(()=>vue.unref(o)),M={...r,...i},f=vue.isRef(n)?n:vue.ref(n),E=vue.ref({...l(f.value)}),
|
|
1
|
+
'use strict';var core=require('@regle/core'),vue=require('vue');function A(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,A(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({}),p=vue.computed(()=>vue.unref(o)),M={...r,...i},f=vue.isRef(n)?n:vue.ref(n),E=vue.ref({...l(f.value)}),S=vue.ref({}),R;if(!p.value?.["~standard"])throw new Error('Only "standard-schema" compatible libraries are supported');function F(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],N=(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:N}}).forEach(c=>{w(T,c.path,[c.message],c.isArray);}),T}async function g(){let s=p.value["~standard"].validate(f.value);return s instanceof Promise&&(s=await s),S.value=F(s),s}return vue.watch([f,p],g,{deep:true,immediate:true}),R=async()=>{try{return {valid:!(await g()).issues?.length,data:f.value}}catch(s){return Promise.reject(s)}},{r$:core.useRootStorage({scopeRules:O,state:f,options:M,schemaErrors:S,initialState:E,shortcuts:t,schemaMode:true,onValidate:R}).regle}}return a}var P=h();function v(e,t){return e}function d(){function e(t,r){return r}return e}var V=d();function b({modifiers:e,shortcuts:t}){let r=h(e,t),a=d();return {useRegleSchema:r,inferSchema:a}}exports.defineRegleSchemaConfig=b;exports.inferSchema=V;exports.useRegleSchema=P;exports.withDeps=v;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {useRootStorage}from'@regle/core';import {ref,computed,unref,isRef,watch}from'vue';function A(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,A(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({}),p=computed(()=>unref(o)),M={...r,...i},f=isRef(n)?n:ref(n),E=ref({...l(f.value)}),
|
|
1
|
+
import {useRootStorage}from'@regle/core';import {ref,computed,unref,isRef,watch}from'vue';function A(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,A(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({}),p=computed(()=>unref(o)),M={...r,...i},f=isRef(n)?n:ref(n),E=ref({...l(f.value)}),S=ref({}),R;if(!p.value?.["~standard"])throw new Error('Only "standard-schema" compatible libraries are supported');function F(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],N=(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:N}}).forEach(c=>{w(T,c.path,[c.message],c.isArray);}),T}async function g(){let s=p.value["~standard"].validate(f.value);return s instanceof Promise&&(s=await s),S.value=F(s),s}return watch([f,p],g,{deep:true,immediate:true}),R=async()=>{try{return {valid:!(await g()).issues?.length,data:f.value}}catch(s){return Promise.reject(s)}},{r$:useRootStorage({scopeRules:O,state:f,options:M,schemaErrors:S,initialState:E,shortcuts:t,schemaMode:true,onValidate:R}).regle}}return a}var P=h();function v(e,t){return e}function d(){function e(t,r){return r}return e}var V=d();function b({modifiers:e,shortcuts:t}){let r=h(e,t),a=d();return {useRegleSchema:r,inferSchema:a}}export{b as defineRegleSchemaConfig,V as inferSchema,P as useRegleSchema,v as withDeps};
|
package/dist/regle-schemas.mjs
CHANGED
|
@@ -184,7 +184,7 @@ function createUseRegleSchemaComposable(options, shortcuts) {
|
|
|
184
184
|
try {
|
|
185
185
|
const result = await computeErrors();
|
|
186
186
|
return {
|
|
187
|
-
|
|
187
|
+
valid: !result.issues?.length,
|
|
188
188
|
data: processedState.value
|
|
189
189
|
};
|
|
190
190
|
} catch (e) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regle/schemas",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Schemas adapter for Regle",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@standard-schema/spec": "1.0.0",
|
|
7
|
-
"@regle/core": "0.
|
|
8
|
-
"@regle/rules": "0.
|
|
7
|
+
"@regle/core": "0.10.0",
|
|
8
|
+
"@regle/rules": "0.10.0"
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
11
11
|
"valibot": "^1.0.0-beta.11",
|