@regle/schemas 1.0.7 → 1.0.8

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.
@@ -226,13 +226,13 @@ var useRegleSchema = createUseRegleSchemaComposable();
226
226
  function withDeps(schema, depsArray) {
227
227
  return schema;
228
228
  }
229
- function createInferValibotSchemaHelper() {
229
+ function createInferSchemaHelper() {
230
230
  function inferRules(state, rulesFactory) {
231
231
  return rulesFactory;
232
232
  }
233
233
  return inferRules;
234
234
  }
235
- var inferSchema = createInferValibotSchemaHelper();
235
+ var inferSchema = createInferSchemaHelper();
236
236
 
237
237
  // src/core/defineRegleSchemaConfig.ts
238
238
  function defineRegleSchemaConfig({
@@ -240,7 +240,7 @@ function defineRegleSchemaConfig({
240
240
  shortcuts
241
241
  }) {
242
242
  const useRegleSchema2 = createUseRegleSchemaComposable(modifiers, shortcuts);
243
- const inferSchema2 = createInferValibotSchemaHelper();
243
+ const inferSchema2 = createInferSchemaHelper();
244
244
  return { useRegleSchema: useRegleSchema2, inferSchema: inferSchema2 };
245
245
  }
246
246
 
@@ -322,7 +322,7 @@ declare const useRegleSchema: useRegleSchemaFn<RegleShortcutDefinition<any>>;
322
322
  */
323
323
  declare function withDeps<TSchema extends StandardSchemaV1, TParams extends unknown[] = []>(schema: TSchema, depsArray: [...TParams]): TSchema;
324
324
 
325
- interface inferValibotSchemaFn {
325
+ interface inferSchemaFn {
326
326
  <TState extends Record<string, any>, TSchema extends StandardSchemaV1<Record<string, any>> & TValid, TValid = UnwrapNestedRefs<TState> extends PartialDeep<StandardSchemaV1.InferInput<TSchema>, {
327
327
  recurseIntoArrays: true;
328
328
  }> ? {} : MismatchInfo<UnwrapNestedRefs<TState>, PartialDeep<StandardSchemaV1.InferInput<TSchema>, {
@@ -335,9 +335,9 @@ interface inferValibotSchemaFn {
335
335
  * It will just return the rules without any processing.
336
336
  *
337
337
  * @param state - The state reference
338
- * @param schema - Your valibot schema
338
+ * @param schema - Your schema
339
339
  */
340
- declare const inferSchema: inferValibotSchemaFn;
340
+ declare const inferSchema: inferSchemaFn;
341
341
 
342
342
  /**
343
343
  * Define a global regle configuration, where you can:
@@ -354,7 +354,7 @@ declare function defineRegleSchemaConfig<TShortcuts extends RegleShortcutDefinit
354
354
  shortcuts?: TShortcuts;
355
355
  }): {
356
356
  useRegleSchema: useRegleSchemaFn<TShortcuts>;
357
- inferSchema: inferValibotSchemaFn;
357
+ inferSchema: inferSchemaFn;
358
358
  };
359
359
 
360
360
  export { type InferRegleSchemaStatusType, type RegleSchema, type RegleSchemaCollectionStatus, type RegleSchemaFieldStatus, type RegleSchemaResult, type RegleSchemaStatus, type RegleSingleFieldSchema, defineRegleSchemaConfig, inferSchema, useRegleSchema, withDeps };
@@ -322,7 +322,7 @@ declare const useRegleSchema: useRegleSchemaFn<RegleShortcutDefinition<any>>;
322
322
  */
323
323
  declare function withDeps<TSchema extends StandardSchemaV1, TParams extends unknown[] = []>(schema: TSchema, depsArray: [...TParams]): TSchema;
324
324
 
325
- interface inferValibotSchemaFn {
325
+ interface inferSchemaFn {
326
326
  <TState extends Record<string, any>, TSchema extends StandardSchemaV1<Record<string, any>> & TValid, TValid = UnwrapNestedRefs<TState> extends PartialDeep<StandardSchemaV1.InferInput<TSchema>, {
327
327
  recurseIntoArrays: true;
328
328
  }> ? {} : MismatchInfo<UnwrapNestedRefs<TState>, PartialDeep<StandardSchemaV1.InferInput<TSchema>, {
@@ -335,9 +335,9 @@ interface inferValibotSchemaFn {
335
335
  * It will just return the rules without any processing.
336
336
  *
337
337
  * @param state - The state reference
338
- * @param schema - Your valibot schema
338
+ * @param schema - Your schema
339
339
  */
340
- declare const inferSchema: inferValibotSchemaFn;
340
+ declare const inferSchema: inferSchemaFn;
341
341
 
342
342
  /**
343
343
  * Define a global regle configuration, where you can:
@@ -354,7 +354,7 @@ declare function defineRegleSchemaConfig<TShortcuts extends RegleShortcutDefinit
354
354
  shortcuts?: TShortcuts;
355
355
  }): {
356
356
  useRegleSchema: useRegleSchemaFn<TShortcuts>;
357
- inferSchema: inferValibotSchemaFn;
357
+ inferSchema: inferSchemaFn;
358
358
  };
359
359
 
360
360
  export { type InferRegleSchemaStatusType, type RegleSchema, type RegleSchemaCollectionStatus, type RegleSchemaFieldStatus, type RegleSchemaResult, type RegleSchemaStatus, type RegleSingleFieldSchema, defineRegleSchemaConfig, inferSchema, useRegleSchema, withDeps };
@@ -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===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
+ '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 E=vue.ref({}),p=vue.computed(()=>vue.unref(s)),V={...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 B(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],U=(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:U}}).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=B(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:E,state:l,options:V,schemaErrors:y,initialState:A,shortcuts:t,schemaMode:true,onValidate:T}).regle}}return a}var M=R();function O(e,t){return e}function g(){function e(t,r){return r}return e}var b=g();function F({modifiers:e,shortcuts:t}){let r=R(e,t),a=g();return {useRegleSchema:r,inferSchema:a}}exports.defineRegleSchemaConfig=F;exports.inferSchema=b;exports.useRegleSchema=M;exports.withDeps=O;
@@ -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===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};
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 E=ref({}),p=computed(()=>unref(s)),V={...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 B(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],U=(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:U}}).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=B(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:E,state:l,options:V,schemaErrors:y,initialState:A,shortcuts:t,schemaMode:true,onValidate:T}).regle}}return a}var M=R();function O(e,t){return e}function g(){function e(t,r){return r}return e}var b=g();function F({modifiers:e,shortcuts:t}){let r=R(e,t),a=g();return {useRegleSchema:r,inferSchema:a}}export{F as defineRegleSchemaConfig,b as inferSchema,M as useRegleSchema,O as withDeps};
@@ -224,13 +224,13 @@ var useRegleSchema = createUseRegleSchemaComposable();
224
224
  function withDeps(schema, depsArray) {
225
225
  return schema;
226
226
  }
227
- function createInferValibotSchemaHelper() {
227
+ function createInferSchemaHelper() {
228
228
  function inferRules(state, rulesFactory) {
229
229
  return rulesFactory;
230
230
  }
231
231
  return inferRules;
232
232
  }
233
- var inferSchema = createInferValibotSchemaHelper();
233
+ var inferSchema = createInferSchemaHelper();
234
234
 
235
235
  // src/core/defineRegleSchemaConfig.ts
236
236
  function defineRegleSchemaConfig({
@@ -238,7 +238,7 @@ function defineRegleSchemaConfig({
238
238
  shortcuts
239
239
  }) {
240
240
  const useRegleSchema2 = createUseRegleSchemaComposable(modifiers, shortcuts);
241
- const inferSchema2 = createInferValibotSchemaHelper();
241
+ const inferSchema2 = createInferSchemaHelper();
242
242
  return { useRegleSchema: useRegleSchema2, inferSchema: inferSchema2 };
243
243
  }
244
244
 
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@regle/schemas",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Schemas adapter for Regle",
5
5
  "dependencies": {
6
6
  "@standard-schema/spec": "1.0.0",
7
- "@regle/core": "1.0.7",
8
- "@regle/rules": "1.0.7"
7
+ "@regle/core": "1.0.8",
8
+ "@regle/rules": "1.0.8"
9
9
  },
10
10
  "peerDependencies": {
11
11
  "valibot": "^1.0.0-beta.11",
@@ -34,7 +34,7 @@
34
34
  "prettier": "3.3.3",
35
35
  "tsup": "8.4.0",
36
36
  "type-fest": "4.28.0",
37
- "typescript": "5.6.3",
37
+ "typescript": "5.8.2",
38
38
  "valibot": "1.0.0",
39
39
  "vitest": "3.0.9",
40
40
  "vue": "3.5.13",