@regle/schemas 0.10.4 → 1.0.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
|
@@ -126,7 +126,7 @@ function getDotPath(obj, propsArg, defaultValue) {
|
|
|
126
126
|
return defaultValue;
|
|
127
127
|
}
|
|
128
128
|
obj = obj[prop];
|
|
129
|
-
if (obj ===
|
|
129
|
+
if (obj === void 0) {
|
|
130
130
|
return defaultValue;
|
|
131
131
|
}
|
|
132
132
|
}
|
|
@@ -159,7 +159,7 @@ function createUseRegleSchemaComposable(options, shortcuts) {
|
|
|
159
159
|
isObject(processedState.value) ? { ...cloneDeep(processedState.value) } : cloneDeep(processedState.value)
|
|
160
160
|
);
|
|
161
161
|
const customErrors = vue.ref({});
|
|
162
|
-
let onValidate =
|
|
162
|
+
let onValidate = void 0;
|
|
163
163
|
if (!computedSchema.value?.["~standard"]) {
|
|
164
164
|
throw new Error(`Only "standard-schema" compatible libraries are supported`);
|
|
165
165
|
}
|
package/dist/regle-schemas.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Maybe, PrimitiveTypes, RegleShortcutDefinition, RegleFieldStatus, RegleCommonStatus, JoinDiscriminatedUnions, RegleRuleStatus, RegleCollectionErrors, RegleErrorTree, DeepMaybeRef, RegleBehaviourOptions, MismatchInfo, DeepReactiveState, LocalRegleBehaviourOptions, NoInferLegacy } from '@regle/core';
|
|
2
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
3
|
import { Raw, MaybeRef, MaybeRefOrGetter, UnwrapNestedRefs } from 'vue';
|
|
4
4
|
|
package/dist/regle-schemas.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Maybe, PrimitiveTypes, RegleShortcutDefinition, RegleFieldStatus, RegleCommonStatus, JoinDiscriminatedUnions, RegleRuleStatus, RegleCollectionErrors, RegleErrorTree, DeepMaybeRef, RegleBehaviourOptions, MismatchInfo, DeepReactiveState, LocalRegleBehaviourOptions, NoInferLegacy } from '@regle/core';
|
|
2
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
3
|
import { Raw, MaybeRef, MaybeRefOrGetter, UnwrapNestedRefs } from 'vue';
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var core=require('@regle/core'),vue=require('vue');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 f(e){let t=e,r={}.toString.call(e).slice(8,-1);if(r=="Set"&&(t=new Set([...e].map(a=>f(a)))),r=="Map"&&(t=new Map([...e].map(a=>[f(a[0]),f(a[1])]))),r=="Date"&&(t=new Date(e.getTime())),r=="RegExp"&&(t=RegExp(e.source,C(e))),r=="Array"||r=="Object"){t=Array.isArray(e)?[]:{};for(let a in e)t[a]=f(e[a]);}return t}function S(e){return e&&(e instanceof Date||e.constructor.name=="File"||e.constructor.name=="FileList")?false:typeof e=="object"&&e!==null&&!Array.isArray(e)}function v(e,t,r,a){var n,s;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(s=n.pop(),!s)return false;w(s);for(var o;o=n.shift();)if(w(o),isNaN(parseInt(o))?(typeof e[o]>"u"&&(e[o]={}),e=e[o]):((e.$each??=[])[o]={},e=e.$each[o]),!e||typeof e!="object")return false;return a?e[s]?e[s].$self=(e[s].$self??=[]).concat(r):e[s]={...e[s],$self:r}:Array.isArray(e[s])?e[s]=e[s].concat(r):e[s]=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===
|
|
1
|
+
'use strict';var core=require('@regle/core'),vue=require('vue');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 f(e){let t=e,r={}.toString.call(e).slice(8,-1);if(r=="Set"&&(t=new Set([...e].map(a=>f(a)))),r=="Map"&&(t=new Map([...e].map(a=>[f(a[0]),f(a[1])]))),r=="Date"&&(t=new Date(e.getTime())),r=="RegExp"&&(t=RegExp(e.source,C(e))),r=="Array"||r=="Object"){t=Array.isArray(e)?[]:{};for(let a in e)t[a]=f(e[a]);}return t}function S(e){return e&&(e instanceof Date||e.constructor.name=="File"||e.constructor.name=="FileList")?false:typeof e=="object"&&e!==null&&!Array.isArray(e)}function v(e,t,r,a){var n,s;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(s=n.pop(),!s)return false;w(s);for(var o;o=n.shift();)if(w(o),isNaN(parseInt(o))?(typeof e[o]>"u"&&(e[o]={}),e=e[o]):((e.$each??=[])[o]={},e=e.$each[o]),!e||typeof e!="object")return false;return a?e[s]?e[s].$self=(e[s].$self??=[]).concat(r):e[s]={...e[s],$self:r}:Array.isArray(e[s])?e[s]=e[s].concat(r):e[s]=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===void 0))return r;return e}function w(e){if(e=="__proto__"||e=="constructor"||e=="prototype")throw new Error("setting of prototype values not supported")}function R(e,t){let r={autoDirty:e?.autoDirty,lazy:e?.lazy,rewardEarly:e?.rewardEarly,clearExternalErrorsOnChange:e?.clearExternalErrorsOnChange};function a(n,s,o){let F=vue.ref({}),p=vue.computed(()=>vue.unref(s)),E={...r,...o},N=vue.computed(()=>!S(l.value)),l=vue.isRef(n)?n:vue.ref(n),A=vue.ref(S(l.value)?{...f(l.value)}:f(l.value)),y=vue.ref({}),T;if(!p.value?.["~standard"])throw new Error('Only "standard-schema" compatible libraries are supported');function U(i){let m={};return i.issues&&i.issues.map(c=>{let x=c.path?.map(d=>typeof d=="object"?d.key:d.toString()).join(".")??"",h=c.path?.[c.path.length-1],B=(typeof h=="object"&&"value"in h?Array.isArray(h.value):false)||("type"in c?c.type==="array":false)||Array.isArray(I(l.value,x));return {path:x,message:c.message,isArray:B}}).forEach(c=>{v(m,c.path,[c.message],c.isArray);}),m}async function D(){let i=p.value["~standard"].validate(l.value);return i instanceof Promise&&(i=await i),N.value?y.value=i.issues?.map(m=>m.message)??[]:y.value=U(i),i}return vue.watch([l,p],D,{deep:true,immediate:true}),T=async()=>{try{return {valid:!(await D()).issues?.length,data:l.value}}catch(i){return Promise.reject(i)}},{r$:core.useRootStorage({scopeRules:F,state:l,options:E,schemaErrors:y,initialState:A,shortcuts:t,schemaMode:true,onValidate:T}).regle}}return a}var P=R();function M(e,t){return e}function g(){function e(t,r){return r}return e}var O=g();function V({modifiers:e,shortcuts:t}){let r=R(e,t),a=g();return {useRegleSchema:r,inferSchema:a}}exports.defineRegleSchemaConfig=V;exports.inferSchema=O;exports.useRegleSchema=P;exports.withDeps=M;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {useRootStorage}from'@regle/core';import {ref,computed,unref,isRef,watch}from'vue';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 f(e){let t=e,r={}.toString.call(e).slice(8,-1);if(r=="Set"&&(t=new Set([...e].map(a=>f(a)))),r=="Map"&&(t=new Map([...e].map(a=>[f(a[0]),f(a[1])]))),r=="Date"&&(t=new Date(e.getTime())),r=="RegExp"&&(t=RegExp(e.source,C(e))),r=="Array"||r=="Object"){t=Array.isArray(e)?[]:{};for(let a in e)t[a]=f(e[a]);}return t}function S(e){return e&&(e instanceof Date||e.constructor.name=="File"||e.constructor.name=="FileList")?false:typeof e=="object"&&e!==null&&!Array.isArray(e)}function v(e,t,r,a){var n,s;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(s=n.pop(),!s)return false;w(s);for(var o;o=n.shift();)if(w(o),isNaN(parseInt(o))?(typeof e[o]>"u"&&(e[o]={}),e=e[o]):((e.$each??=[])[o]={},e=e.$each[o]),!e||typeof e!="object")return false;return a?e[s]?e[s].$self=(e[s].$self??=[]).concat(r):e[s]={...e[s],$self:r}:Array.isArray(e[s])?e[s]=e[s].concat(r):e[s]=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===
|
|
1
|
+
import {useRootStorage}from'@regle/core';import {ref,computed,unref,isRef,watch}from'vue';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 f(e){let t=e,r={}.toString.call(e).slice(8,-1);if(r=="Set"&&(t=new Set([...e].map(a=>f(a)))),r=="Map"&&(t=new Map([...e].map(a=>[f(a[0]),f(a[1])]))),r=="Date"&&(t=new Date(e.getTime())),r=="RegExp"&&(t=RegExp(e.source,C(e))),r=="Array"||r=="Object"){t=Array.isArray(e)?[]:{};for(let a in e)t[a]=f(e[a]);}return t}function S(e){return e&&(e instanceof Date||e.constructor.name=="File"||e.constructor.name=="FileList")?false:typeof e=="object"&&e!==null&&!Array.isArray(e)}function v(e,t,r,a){var n,s;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(s=n.pop(),!s)return false;w(s);for(var o;o=n.shift();)if(w(o),isNaN(parseInt(o))?(typeof e[o]>"u"&&(e[o]={}),e=e[o]):((e.$each??=[])[o]={},e=e.$each[o]),!e||typeof e!="object")return false;return a?e[s]?e[s].$self=(e[s].$self??=[]).concat(r):e[s]={...e[s],$self:r}:Array.isArray(e[s])?e[s]=e[s].concat(r):e[s]=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===void 0))return r;return e}function w(e){if(e=="__proto__"||e=="constructor"||e=="prototype")throw new Error("setting of prototype values not supported")}function R(e,t){let r={autoDirty:e?.autoDirty,lazy:e?.lazy,rewardEarly:e?.rewardEarly,clearExternalErrorsOnChange:e?.clearExternalErrorsOnChange};function a(n,s,o){let F=ref({}),p=computed(()=>unref(s)),E={...r,...o},N=computed(()=>!S(l.value)),l=isRef(n)?n:ref(n),A=ref(S(l.value)?{...f(l.value)}:f(l.value)),y=ref({}),T;if(!p.value?.["~standard"])throw new Error('Only "standard-schema" compatible libraries are supported');function U(i){let m={};return i.issues&&i.issues.map(c=>{let x=c.path?.map(d=>typeof d=="object"?d.key:d.toString()).join(".")??"",h=c.path?.[c.path.length-1],B=(typeof h=="object"&&"value"in h?Array.isArray(h.value):false)||("type"in c?c.type==="array":false)||Array.isArray(I(l.value,x));return {path:x,message:c.message,isArray:B}}).forEach(c=>{v(m,c.path,[c.message],c.isArray);}),m}async function D(){let i=p.value["~standard"].validate(l.value);return i instanceof Promise&&(i=await i),N.value?y.value=i.issues?.map(m=>m.message)??[]:y.value=U(i),i}return watch([l,p],D,{deep:true,immediate:true}),T=async()=>{try{return {valid:!(await D()).issues?.length,data:l.value}}catch(i){return Promise.reject(i)}},{r$:useRootStorage({scopeRules:F,state:l,options:E,schemaErrors:y,initialState:A,shortcuts:t,schemaMode:true,onValidate:T}).regle}}return a}var P=R();function M(e,t){return e}function g(){function e(t,r){return r}return e}var O=g();function V({modifiers:e,shortcuts:t}){let r=R(e,t),a=g();return {useRegleSchema:r,inferSchema:a}}export{V as defineRegleSchemaConfig,O as inferSchema,P as useRegleSchema,M as withDeps};
|
package/dist/regle-schemas.mjs
CHANGED
|
@@ -124,7 +124,7 @@ function getDotPath(obj, propsArg, defaultValue) {
|
|
|
124
124
|
return defaultValue;
|
|
125
125
|
}
|
|
126
126
|
obj = obj[prop];
|
|
127
|
-
if (obj ===
|
|
127
|
+
if (obj === void 0) {
|
|
128
128
|
return defaultValue;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
@@ -157,7 +157,7 @@ function createUseRegleSchemaComposable(options, shortcuts) {
|
|
|
157
157
|
isObject(processedState.value) ? { ...cloneDeep(processedState.value) } : cloneDeep(processedState.value)
|
|
158
158
|
);
|
|
159
159
|
const customErrors = ref({});
|
|
160
|
-
let onValidate =
|
|
160
|
+
let onValidate = void 0;
|
|
161
161
|
if (!computedSchema.value?.["~standard"]) {
|
|
162
162
|
throw new Error(`Only "standard-schema" compatible libraries are supported`);
|
|
163
163
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regle/schemas",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.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": "1.0.0",
|
|
8
|
+
"@regle/rules": "1.0.0"
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
11
11
|
"valibot": "^1.0.0-beta.11",
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@total-typescript/ts-reset": "0.6.1",
|
|
24
|
-
"@types/node": "22.10
|
|
25
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
26
|
-
"@typescript-eslint/parser": "8.
|
|
24
|
+
"@types/node": "22.13.10",
|
|
25
|
+
"@typescript-eslint/eslint-plugin": "8.26.1",
|
|
26
|
+
"@typescript-eslint/parser": "8.26.1",
|
|
27
27
|
"@vue/test-utils": "2.4.6",
|
|
28
|
-
"bumpp": "
|
|
29
|
-
"changelogithub": "13.
|
|
28
|
+
"bumpp": "10.1.0",
|
|
29
|
+
"changelogithub": "13.13.0",
|
|
30
30
|
"cross-env": "7.0.3",
|
|
31
31
|
"eslint": "9.15.0",
|
|
32
32
|
"eslint-config-prettier": "9.1.0",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"tsup": "8.3.5",
|
|
36
36
|
"type-fest": "4.28.0",
|
|
37
37
|
"typescript": "5.6.3",
|
|
38
|
-
"valibot": "1.0.0
|
|
39
|
-
"vitest": "
|
|
38
|
+
"valibot": "1.0.0",
|
|
39
|
+
"vitest": "3.0.9",
|
|
40
40
|
"vue": "3.5.13",
|
|
41
41
|
"vue-eslint-parser": "9.4.3",
|
|
42
42
|
"vue-tsc": "2.1.10",
|
|
43
|
-
"zod": "3.24.
|
|
43
|
+
"zod": "3.24.2"
|
|
44
44
|
},
|
|
45
45
|
"type": "module",
|
|
46
46
|
"exports": {
|