runcheck 0.51.0 → 0.53.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/README.md CHANGED
@@ -235,7 +235,7 @@ const input = JSON.parse(jsonInput)
235
235
 
236
236
  const result = rc_parse(input, rc_array(rc_string))
237
237
 
238
- rc_assert_is_valid(result, rc_array(rc_string))
238
+ rc_assert_is_valid(result)
239
239
  // will throw an error if the result is invalid, otherwise will narrow the result type to a valid result
240
240
  ```
241
241
 
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var m=(e,r)=>{for(var n in r)f(e,n,{get:r[n],enumerable:!0})},w=(e,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of b(r))!g.call(e,t)&&t!==n&&f(e,t,{get:()=>r[t],enumerable:!(o=h(r,t))||o.enumerable});return e};var P=e=>w(f({},"__esModule",{value:!0}),e);var W={};m(W,{rc_boolean_autofix:()=>O,rc_number_autofix:()=>S,rc_string_autofix:()=>A});module.exports=P(W);function x(e){return{...this,g:e}}function u(e,r){return`${e.n?`$${e.n}: `:""}${r}`}function c(e,r){e.l.push(r.startsWith("$")?r:u(e,r))}function s(e,r,n,o){if(e.T&&r===void 0)return[!0,r];if(e.d&&r==null)return[!0,r];if(e.p&&r===null)return[!0,r];let t=o();if(t&&(t===!0||!t.errors)){let i=t===!0?r:t.data;return e.c&&!e.c(i)?[!1,[u(n,`Predicate failed for type '${e.e}'`)]]:[!0,i]}if(!n.i){let i=e.g;if(i!==void 0)return c(n,`Fallback used, errors -> ${y(t,n,e,r)}`),[!0,j(i)?i():i];if(e.j&&e.h){let l=e.h(r);if(l)return e.c&&!e.c(l.fixed)?[!1,[u(n,`Predicate failed for autofix in type '${e.e}'`)]]:(c(n,`Autofixed from error "${y(t,n,e,r)}"`),[!0,l.fixed])}}return[!1,t?t.errors:[u(n,T(e,r))]]}function y(e,r,n,o){return e?e.errors.map(t=>t.replace(r.n,"")).join("; "):T(n,o)}function k(e){return{...this,j:!0,h:e}}function N(e){return{...this,c:e}}function d(){return{...this,T:!0}}function T(e,r){return`Type '${I(r,!!e.k)}' is not assignable to '${e.e}'`}function $(){return{...this,p:!0,e:`${this.e}_or_null`}}function E(){return{...this,d:!0,e:`${this.e}_or_nullish`}}var a={__rc_type:void 0,withFallback:x,where:N,optional:d,optionalKey:d,orNullish:E,withAutofix:k,orNull:$,R:void 0,g:void 0,c:void 0,T:!1,p:!1,d:!1,j:!1,k:!1,y:void 0,h:void 0,t:void 0,_:!1,b:!1,u:[]},C={...a,r(e,r){return s(this,e,r,()=>e===void 0)},e:"undefined"},K={...a,r(e,r){return s(this,e,r,()=>e===null)},e:"null"},q={...a,r(e,r){return s(this,e,r,()=>!0)},e:"any"},V={...a,r(e,r){return s(this,e,r,()=>!0)},e:"unknown"},p={...a,r(e,r){return s(this,e,r,()=>typeof e=="boolean")},e:"boolean"},_={...a,r(e,r){return s(this,e,r,()=>typeof e=="string")},e:"string"},R={...a,r(e,r){return s(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},F={...a,r(e,r){return s(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function I(e,r){let n=typeof e,o=(()=>{if(n==="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return n})();return r&&(o==="string"||o==="number"||o==="boolean")?`${o}(${e})`:o}function j(e){return typeof e=="function"}var O=p.withAutofix(e=>e==null||e===0||e===1?{fixed:!!e}:e==="true"||e==="false"?{fixed:e==="true"}:!1),A=_.withAutofix(e=>typeof e=="number"&&!Number.isNaN(e)?{fixed:e.toString()}:!1),S=R.withAutofix(e=>{if(typeof e=="string"){let r=Number(e);if(!Number.isNaN(r))return{fixed:r}}return!1});0&&(module.exports={rc_boolean_autofix,rc_number_autofix,rc_string_autofix});
1
+ "use strict";var f=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var m=(e,r)=>{for(var n in r)f(e,n,{get:r[n],enumerable:!0})},w=(e,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of b(r))!g.call(e,t)&&t!==n&&f(e,t,{get:()=>r[t],enumerable:!(o=h(r,t))||o.enumerable});return e};var P=e=>w(f({},"__esModule",{value:!0}),e);var S={};m(S,{rc_boolean_autofix:()=>O,rc_number_autofix:()=>A,rc_string_autofix:()=>v});module.exports=P(S);function x(e){return{...this,g:e}}function u(e,r){return`${e.n?`$${e.n}: `:""}${r}`}function c(e,r){e.y.push(r.startsWith("$")?r:u(e,r))}function s(e,r,n,o){if(e.T&&r===void 0)return[!0,r];if(e.d&&r==null)return[!0,r];if(e.p&&r===null)return[!0,r];let t=o();if(t&&(t===!0||!t.errors)){let i=t===!0?r:t.data;return e.c&&!e.c(i)?[!1,[u(n,`Predicate failed for type '${e.e}'`)]]:[!0,i]}if(!n.i){let i=e.g;if(i!==void 0)return c(n,`Fallback used, errors -> ${y(t,n,e,r)}`),[!0,j(i)?i():i];if(e.j&&e.h){let l=e.h(r);if(l)return e.c&&!e.c(l.fixed)?[!1,[u(n,`Predicate failed for autofix in type '${e.e}'`)]]:(c(n,`Autofixed from error "${y(t,n,e,r)}"`),[!0,l.fixed])}}return[!1,t?t.errors:[u(n,T(e,r))]]}function y(e,r,n,o){return e?e.errors.map(t=>t.replace(r.n,"")).join("; "):T(n,o)}function k(e){return{...this,j:!0,h:e}}function N(e){return{...this,c:e}}function d(){return{...this,T:!0}}function T(e,r){return`Type '${I(r,!!e.k)}' is not assignable to '${e.e}'`}function $(){return{...this,p:!0,e:`${this.e}_or_null`}}function E(){return{...this,d:!0,e:`${this.e}_or_nullish`}}var a={__rc_type:void 0,withFallback:x,where:N,optional:d,optionalKey:d,orNullish:E,withAutofix:k,orNull:$,R:void 0,g:void 0,c:void 0,T:!1,p:!1,d:!1,j:!1,k:!1,l:void 0,h:void 0,t:void 0,_:!1,b:!1,u:[]},C={...a,r(e,r){return s(this,e,r,()=>e===void 0)},e:"undefined"},K={...a,r(e,r){return s(this,e,r,()=>e===null)},e:"null"},q={...a,r(e,r){return s(this,e,r,()=>!0)},e:"any"},V={...a,r(e,r){return s(this,e,r,()=>!0)},e:"unknown"},p={...a,r(e,r){return s(this,e,r,()=>typeof e=="boolean")},e:"boolean"},_={...a,r(e,r){return s(this,e,r,()=>typeof e=="string")},e:"string"},R={...a,r(e,r){return s(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},F={...a,r(e,r){return s(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function I(e,r){let n=typeof e,o=(()=>{if(n==="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return n})();return r&&(o==="string"||o==="number"||o==="boolean")?`${o}(${e})`:o}function j(e){return typeof e=="function"}var O=p.withAutofix(e=>e==null||e===0||e===1?{fixed:!!e}:e==="true"||e==="false"?{fixed:e==="true"}:!1),v=_.withAutofix(e=>typeof e=="number"&&!Number.isNaN(e)?{fixed:e.toString()}:!1),A=R.withAutofix(e=>{if(typeof e=="string"){let r=Number(e);if(!Number.isNaN(r))return{fixed:r}}return!1});0&&(module.exports={rc_boolean_autofix,rc_number_autofix,rc_string_autofix});
@@ -1 +1 @@
1
- import{r as f,s as t,t as o}from"./chunk-465GEK7B.js";var s=f.withAutofix(r=>r==null||r===0||r===1?{fixed:!!r}:r==="true"||r==="false"?{fixed:r==="true"}:!1),n=t.withAutofix(r=>typeof r=="number"&&!Number.isNaN(r)?{fixed:r.toString()}:!1),u=o.withAutofix(r=>{if(typeof r=="string"){let e=Number(r);if(!Number.isNaN(e))return{fixed:e}}return!1});export{s as rc_boolean_autofix,u as rc_number_autofix,n as rc_string_autofix};
1
+ import{r as f,s as t,t as o}from"./chunk-BBFBYV3C.js";var s=f.withAutofix(r=>r==null||r===0||r===1?{fixed:!!r}:r==="true"||r==="false"?{fixed:r==="true"}:!1),n=t.withAutofix(r=>typeof r=="number"&&!Number.isNaN(r)?{fixed:r.toString()}:!1),u=o.withAutofix(r=>{if(typeof r=="string"){let e=Number(r);if(!Number.isNaN(e))return{fixed:e}}return!1});export{s as rc_boolean_autofix,u as rc_number_autofix,n as rc_string_autofix};
@@ -0,0 +1,2 @@
1
+ function D(e,r){return{...r,l:e}}function M(e){return m(e)&&"__rc_type"in e}function N(e){if(M(e))return e;if(m(e)){let r={};for(let[n,t]of Object.entries(e))r[n]=N(t);return b(r)}throw new Error(`invalid schema: ${e}`)}function b(e,{normalizeKeysFrom:r}={}){let n={};for(let[t,o]of Object.entries(e))n[t]=N(o);return{...y,t:n,e:"object",_:!0,u:Object.entries(n),r(t,o){return l(this,t,o,()=>{if(!m(t))return o.a=-1,!1;let s=this.e==="strict_obj"||o.s?new Set(Object.keys(t)):void 0;if(s&&s.size>this.u.length){o.a=-1;let p=[];if(o.o)return{data:void 0,errors:[d(o,`Expected strict object with ${this.u.length} keys but got ${s.size}`)]};for(let[f]of this.u)s.has(f)?s.delete(f):p.push(d(o,`Key '${f}' is missing`));for(let f of s)p.push(d(o,`Key '${f}' is not defined in the object shape`));return{data:void 0,errors:p}}let c={},i=[],u=o.n,T=-1;for(let[p,f]of this.u){let _=p;T+=1;let h=`.${p}`,g=`${u}${h}`;o.n=g;let R=t[p],j=p;if(R===void 0&&f.l&&(R=t[f.l],j=f.l),R===void 0&&r==="snake_case"){let O=W(p);R=t[O],j=O}s?.delete(j);let[E,k]=f.r(R,o);if(E)c[_]=k;else{for(let O of k)o.n=g,i.push(O);if(o.o){o.a=T;break}}}if(s&&s.size>0)for(let p of s)o.n=u,i.push(d(o,`Key '${p}' is not defined in the object shape`));return i.length>0?{errors:i,data:void 0}:this.b?{errors:!1,data:{...t,...c}}:{errors:!1,data:c}})}}}function z(e,r){return{...b(e,r),e:"extends_object",b:!0}}function L(e){if(!e.t)throw new Error("type does not have an object shape");return e.t}function Q(e,r){return{...b(e,r),e:"strict_obj"}}function J(e,{nonRecursive:r}={}){if(r){if(!e.t)throw new Error("rc_enable_obj_strict: nonRecursive option can only be used on object types");return{...e,e:"strict_obj"}}return{...e,r(n,t){let o=t.s;t.s=!0;let a=e.r(n,t);return t.s=o,a}}}function Z(...e){let r={};for(let n of e)Object.assign(r,n.t);return b(r)}function G(e,r){let n={};if(!e.t)throw new Error("rc_obj_pick: obj must be an object type");for(let t of r){let o=e.t[t];o&&(n[t]=o)}return b(n)}function H(e,r){let n={};if(!e.t)throw new Error("rc_obj_omit: obj must be an object type");for(let t of Object.keys(e.t))r.includes(t)||(n[t]=e.t[t]);return b(n)}function X(){return(e,r)=>b(e,r)}function Y(e){return{...this,g:e}}function d(e,r){return`${e.n?`$${e.n}: `:""}${r}`}function S(e,r){e.y.push(r.startsWith("$")?r:d(e,r))}function F(e,r){r.forEach(n=>S(e,n))}function l(e,r,n,t){if(e.T&&r===void 0)return[!0,r];if(e.d&&r==null)return[!0,r];if(e.p&&r===null)return[!0,r];let o=t();if(o&&(o===!0||!o.errors)){let a=o===!0?r:o.data;return e.c&&!e.c(a)?[!1,[d(n,`Predicate failed for type '${e.e}'`)]]:[!0,a]}if(!n.i){let a=e.g;if(a!==void 0)return S(n,`Fallback used, errors -> ${q(o,n,e,r)}`),[!0,v(a)?a():a];if(e.j&&e.h){let s=e.h(r);if(s)return e.c&&!e.c(s.fixed)?[!1,[d(n,`Predicate failed for autofix in type '${e.e}'`)]]:(S(n,`Autofixed from error "${q(o,n,e,r)}"`),[!0,s.fixed])}}return[!1,o?o.errors:[d(n,U(e,r))]]}function q(e,r,n,t){return e?e.errors.map(o=>o.replace(r.n,"")).join("; "):U(n,t)}function ee(e){return{...this,j:!0,h:e}}function re(e){return{...this,c:e}}function C(){return{...this,T:!0}}function U(e,r){return`Type '${w(r,!!e.k)}' is not assignable to '${e.e}'`}function ne(){return{...this,p:!0,e:`${this.e}_or_null`}}function te(){return{...this,d:!0,e:`${this.e}_or_nullish`}}var y={__rc_type:void 0,withFallback:Y,where:re,optional:C,optionalKey:C,orNullish:te,withAutofix:ee,orNull:ne,R:void 0,g:void 0,c:void 0,T:!1,p:!1,d:!1,j:!1,k:!1,l:void 0,h:void 0,t:void 0,_:!1,b:!1,u:[]},de={...y,r(e,r){return l(this,e,r,()=>e===void 0)},e:"undefined"},Re={...y,r(e,r){return l(this,e,r,()=>e===null)},e:"null"},_e={...y,r(e,r){return l(this,e,r,()=>!0)},e:"any"},he={...y,r(e,r){return l(this,e,r,()=>!0)},e:"unknown"},be={...y,r(e,r){return l(this,e,r,()=>typeof e=="boolean")},e:"boolean"},ge={...y,r(e,r){return l(this,e,r,()=>typeof e=="string")},e:"string"},je={...y,r(e,r){return l(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},ke={...y,r(e,r){return l(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function Oe(e){return{...y,r(r,n){return l(this,r,n,()=>r instanceof e)},e:`instanceof_${e.name?`_${e.name}`:""}`}}function xe(...e){if(e.length===0)throw new Error("rc_literal requires at least one literal");return{...y,r(r,n){return l(this,r,n,()=>{for(let t of e)if(r===t)return!0;return!1})},k:!0,e:e.length==1?w(e[0],!0):e.map(r=>w(r,!0)).join(" | ")}}var B=1;function me(...e){if(e.length===0)throw new Error("Unions should have at least one type");return{...y,r(r,n){return l(this,r,n,()=>{let t=n.n,o=[],a=0,s=!1,c=[],i=0;for(let u of e){i+=1,u._&&(n.n=`${t}|union ${i}|`);let T=n.o;n.o=!0,n.a=0;let[p,f]=u.r(r,n),_=n.a;if(n.o=T,n.a=0,p)return!0;u._&&_!==-1?_>0?c.push(...f):(a<B&&o.push(...f),a+=1):s=!0}return n.n=t,c.length>0||o.length>0?((a>B||s)&&o.push(d(n,"not matches any other union member")),{errors:[...c,...o],data:void 0}):!1})},e:e.map(r=>r.e).join(" | ")}}function we(e,r){return{...e,T:!1,d:!1,p:!1,r(t,o){return l(this,t,o,()=>{if(t===void 0)return n();let[a,s]=e.r(t,o);return a?s===void 0?n():{data:s,errors:!1}:{data:void 0,errors:s}})},e:`${e.e}_default`};function n(){return{data:v(r)?r():r,errors:!1}}}function Pe(e,r){return{...e,T:!1,d:!1,p:!1,r(t,o){return l(this,t,o,()=>{if(t==null)return n();let[a,s]=e.r(t,o);return a?s==null?n():{data:s,errors:!1}:{data:void 0,errors:s}})},e:`${e.e}_nullish_default`};function n(){return{data:v(r)?r():r,errors:!1}}}function oe(e,{checkKey:r,looseCheck:n}={}){return{...y,e:`record<string, ${e.e}>`,r(t,o){return l(this,t,o,()=>{if(!m(t))return!1;let a={},s=[],c=o.n;for(let[i,u]of Object.entries(t)){let T=`.${i}`,p=`${c}${T}`;if(o.n=p,r&&!r(i)){s.push(d(o,`Key '${i}' is not allowed`));continue}let f=t[i],[_,h]=e.r(u,o);if(_)a[i]=f;else{let g=h;for(let R of g)s.push(R);if(o.o)break}}if(s.length>0)if(n)F(o,s);else return{errors:s,data:void 0};return{errors:!1,data:a}})}}}function Ee(e,{checkKey:r}={}){return oe(e,{checkKey:r,looseCheck:!0})}function P(e,r,n,t=!1,o){let a=t&&!n.i&&!n.f,s=o?.unique,c=[],i=[],u=s?new Set:void 0,T=n.n,p=Array.isArray(r),f=-1;for(let _ of e){f++;let h=p?r[f]:r,g=`[${f}]`,R=`${T}${g}`;n.n=R;let j=h.r(_,n),[E,k]=j;if(n.n=R,E&&u){let x=k,A=typeof s=="string";A?x=k[s]:typeof s=="function"&&(x=s(k)),u.has(x)?(A&&(n.n=`${T}${g}.${s}`),j=[!1,[d(n,A?`Type '${h.t?.[s]?.e}' with value "${x}" is not unique`:typeof s=="function"?`Type '${h.e}' unique fn return with value "${x}" is not unique`:`${h.e} value is not unique`)]]):u.add(x)}let[O,$]=j;if(O)i.push($);else if(a){c.push($);continue}else return{errors:$,data:void 0}}if(c.length>0){if(i.length===0)return{errors:c.slice(0,5).flat(),data:void 0};F(n,c.flat())}return{errors:!1,data:i}}function $e(e,r){return{...y,e:`${e.e}[]`,R:e,r(n,t){return l(this,n,t,()=>Array.isArray(n)?n.length===0?!0:P.call(this,n,e,t,!1,r):!1)}}}function Ae(e){if(!e.R)throw new Error("Type does not have an item type");return e.R}function Se(e,{nonRecursive:r=!1}={}){if(r){if(!e.e.endsWith("[]"))throw new Error("rc_disable_loose_array: nonRecursive option can only be used with array types");return{...e,r(n,t){return l(this,n,t,()=>Array.isArray(n)?n.length===0?!0:P.call(this,n,e,t,!1):!1)}}}return{...e,r(n,t){let o=t.f;t.f=!0;let a=e.r(n,t);return t.f=o,a}}}function Ke(e,r){return{...y,R:e,e:`${e.e}[]`,r(n,t){return l(this,n,t,()=>Array.isArray(n)?n.length===0?!0:P.call(this,n,e,t,!0,r):!1)}}}function Ie(e){return{...y,e:`[${e.map(r=>r.e).join(", ")}]`,r(r,n){return l(this,r,n,()=>!Array.isArray(r)||r.length!==e.length?!1:P.call(this,r,e,n))}}}function I(e,r,{noWarnings:n=!1}={}){let t={y:[],n:"",o:!1,a:0,i:n,s:!1,f:!1},[o,a]=r.r(e,t);return o?{error:!1,ok:!0,data:a,value:a,warnings:t.y.length>0?t.y:!1}:{ok:!1,error:!0,errors:a}}function ve(e){return r=>I(r,e)}function Ne(e,r,n){let t=I(e,r,n);return t.error?{data:null,errors:t.errors,warnings:!1}:{data:t.value,errors:!1,warnings:t.warnings}}function We(e){return se(e,null)}function se(e,r){return e.error?{value:r,errors:e.errors,warnings:!1}:{value:e.value,errors:!1,warnings:e.warnings}}var K=class extends Error{constructor(n){super(n.join(`
2
+ `));this.errors=n}};function qe(e){if(e.error)throw new K(e.errors);return e}function ae(e,r){let n={y:[],n:"",o:!1,a:0,i:!1,s:!1,f:!1};return!!r.r(e,n)[0]}function Ce(e){return r=>ae(r,e)}function Be(e){return{...y,e:"recursive",r(r,n){return e().r(r,n)}}}function V(e,r,n,t){let o=e.n,a=e.o,s=e.s,c=e.i;e.o=!0,e.n=`${o}|output|`,t||(e.s=!0,e.i=!0);let i=r.r(n,e);return e.s=s,e.i=c,e.n=o,e.o=a,i}function ie(e,r,{outputSchema:n,disableStrictOutputSchema:t}={}){return{...y,e:`transform_from_${e.e}`,r(o,a){let s=null;if(n){let[u,T]=V(a,n,o,t);if(u)return[!0,T];s=T}let[c,i]=e.r(o,a);return c?[!0,r(i,e)]:[!1,[...s||[],...i]]}}}function Fe(e,r){return ie(e,r)}function Ue(e,r,{outputSchema:n,disableStrictOutputSchema:t}={}){return{...y,e:`transform_from_${e.e}`,r(o,a){let s=null;if(n){let[u,T]=V(a,n,o,t);if(u)return[!0,T];s=T}let[c,i]=e.r(o,a);if(c){let u=r(i,e);return u.ok?[!0,u.data]:[!1,typeof u.errors=="string"?[d(a,u.errors)]:u.errors.map(T=>d(a,T))]}return[!1,[...s||[],...i]]}}}function w(e,r){let n=typeof e,t=(()=>{if(n==="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return n})();return r&&(t==="string"||t==="number"||t==="boolean")?`${t}(${e})`:t}function Ve(e){if(e.error)throw new Error(`invalid input: ${e.errors.join(", ")}`)}function m(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function W(e){return e.replace(/\W+/g," ").split(/ |\B(?=[A-Z])/).map(r=>r.toLowerCase()).join("_")}function De(e,r,n){try{if(typeof e!="string")return{ok:!1,error:!0,errors:[`expected a json string, got ${w(e,!0)}`]};let t=JSON.parse(e);return I(t,r,n)}catch(t){return{ok:!1,error:!0,errors:[`json parsing error: ${m(t)?t.message:""}`]}}}function v(e){return typeof e=="function"}export{D as a,b,z as c,L as d,Q as e,J as f,Z as g,G as h,H as i,X as j,d as k,l,y as m,de as n,Re as o,_e as p,he as q,be as r,ge as s,je as t,ke as u,Oe as v,xe as w,me as x,we as y,Pe as z,oe as A,Ee as B,$e as C,Ae as D,Se as E,Ke as F,Ie as G,I as H,ve as I,Ne as J,We as K,se as L,K as M,qe as N,ae as O,Ce as P,Be as Q,ie as R,Fe as S,Ue as T,Ve as U,m as V,W,De as X};
package/dist/runcheck.cjs CHANGED
@@ -1 +1,2 @@
1
- "use strict";var I=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var se=Object.prototype.hasOwnProperty;var ae=(e,r)=>{for(var n in r)I(e,n,{get:r[n],enumerable:!0})},ie=(e,r,n,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of oe(r))!se.call(e,o)&&o!==n&&I(e,o,{get:()=>r[o],enumerable:!(t=te(r,o))||t.enumerable});return e};var ue=e=>ie(I({},"__esModule",{value:!0}),e);var Me={};ae(Me,{RcValidationError:()=>w,defaultProps:()=>y,getWarningOrErrorWithPath:()=>p,isObject:()=>k,parse:()=>c,rc_any:()=>_e,rc_array:()=>$e,rc_assert_is_valid:()=>Ve,rc_boolean:()=>be,rc_date:()=>ke,rc_default:()=>we,rc_disable_loose_array:()=>Se,rc_enable_obj_strict:()=>V,rc_get_array_item_type:()=>Ae,rc_get_from_key_as_fallback:()=>q,rc_get_obj_schema:()=>F,rc_instanceof:()=>Oe,rc_is_valid:()=>ee,rc_literals:()=>xe,rc_loose_array:()=>Ke,rc_loose_parse:()=>We,rc_loose_record:()=>Ee,rc_narrow:()=>Fe,rc_null:()=>Re,rc_nullish_default:()=>Pe,rc_number:()=>je,rc_obj_builder:()=>L,rc_obj_extends:()=>B,rc_obj_merge:()=>D,rc_obj_omit:()=>z,rc_obj_pick:()=>M,rc_obj_strict:()=>U,rc_object:()=>_,rc_parse:()=>$,rc_parse_json:()=>De,rc_parser:()=>Ne,rc_record:()=>X,rc_recursive:()=>Be,rc_string:()=>ge,rc_transform:()=>ne,rc_tuple:()=>Ie,rc_undefined:()=>pe,rc_union:()=>me,rc_unknown:()=>he,rc_unsafe_transform:()=>Ue,rc_unwrap:()=>qe,rc_unwrap_or:()=>Y,rc_unwrap_or_null:()=>ve,rc_validator:()=>Ce,snakeCase:()=>N});module.exports=ue(Me);function q(e,r){return{...r,f:e}}function ce(e){return k(e)&&"__rc_type"in e}function C(e){if(ce(e))return e;if(k(e)){let r={};for(let[n,t]of Object.entries(e))r[n]=C(t);return _(r)}throw new Error(`invalid schema: ${e}`)}function _(e,{normalizeKeysFrom:r}={}){let n={};for(let[t,o]of Object.entries(e))n[t]=C(o);return{...y,t:n,e:"object",_:!0,u:Object.entries(n),r(t,o){return c(this,t,o,()=>{if(!k(t))return o.a=-1,!1;let s=this.e==="strict_obj"||o.s?new Set(Object.keys(t)):void 0;if(s&&s.size>this.u.length){o.a=-1;let d=[];if(o.o)return{data:void 0,errors:[p(o,`Expected strict object with ${this.u.length} keys but got ${s.size}`)]};for(let[l]of this.u)s.has(l)?s.delete(l):d.push(p(o,`Key '${l}' is missing`));for(let l of s)d.push(p(o,`Key '${l}' is not defined in the object shape`));return{data:void 0,errors:d}}let f={},i=[],u=o.n,T=-1;for(let[d,l]of this.u){let h=d;T+=1;let b=`.${d}`,g=`${u}${b}`;o.n=g;let R=t[d],j=d;if(R===void 0&&l.f&&(R=t[l.f],j=l.f),R===void 0&&r==="snake_case"){let x=N(d);R=t[x],j=x}s?.delete(j);let[A,O]=l.r(R,o);if(A)f[h]=O;else{for(let x of O)o.n=g,i.push(x);if(o.o){o.a=T;break}}}if(s&&s.size>0)for(let d of s)o.n=u,i.push(p(o,`Key '${d}' is not defined in the object shape`));return i.length>0?{errors:i,data:void 0}:this.b?{errors:!1,data:{...t,...f}}:{errors:!1,data:f}})}}}function B(e,r){return{..._(e,r),e:"extends_object",b:!0}}function F(e){if(!e.t)throw new Error("type does not have an object shape");return e.t}function U(e,r){return{..._(e,r),e:"strict_obj"}}function V(e,{nonRecursive:r}={}){if(r){if(!e.t)throw new Error("rc_enable_obj_strict: nonRecursive option can only be used on object types");return{...e,e:"strict_obj"}}return{...e,r(n,t){let o=t.s;t.s=!0;let a=e.r(n,t);return t.s=o,a}}}function D(...e){let r={};for(let n of e)Object.assign(r,n.t);return _(r)}function M(e,r){let n={};if(!e.t)throw new Error("rc_obj_pick: obj must be an object type");for(let t of r){let o=e.t[t];o&&(n[t]=o)}return _(n)}function z(e,r){let n={};if(!e.t)throw new Error("rc_obj_omit: obj must be an object type");for(let t of Object.keys(e.t))r.includes(t)||(n[t]=e.t[t]);return _(n)}function L(){return(e,r)=>_(e,r)}function ye(e){return{...this,g:e}}function p(e,r){return`${e.n?`$${e.n}: `:""}${r}`}function W(e,r){e.l.push(r.startsWith("$")?r:p(e,r))}function G(e,r){r.forEach(n=>W(e,n))}function c(e,r,n,t){if(e.T&&r===void 0)return[!0,r];if(e.d&&r==null)return[!0,r];if(e.p&&r===null)return[!0,r];let o=t();if(o&&(o===!0||!o.errors)){let a=o===!0?r:o.data;return e.c&&!e.c(a)?[!1,[p(n,`Predicate failed for type '${e.e}'`)]]:[!0,a]}if(!n.i){let a=e.g;if(a!==void 0)return W(n,`Fallback used, errors -> ${Q(o,n,e,r)}`),[!0,v(a)?a():a];if(e.j&&e.h){let s=e.h(r);if(s)return e.c&&!e.c(s.fixed)?[!1,[p(n,`Predicate failed for autofix in type '${e.e}'`)]]:(W(n,`Autofixed from error "${Q(o,n,e,r)}"`),[!0,s.fixed])}}return[!1,o?o.errors:[p(n,H(e,r))]]}function Q(e,r,n,t){return e?e.errors.map(o=>o.replace(r.n,"")).join("; "):H(n,t)}function fe(e){return{...this,j:!0,h:e}}function le(e){return{...this,c:e}}function J(){return{...this,T:!0}}function H(e,r){return`Type '${P(r,!!e.k)}' is not assignable to '${e.e}'`}function Te(){return{...this,p:!0,e:`${this.e}_or_null`}}function de(){return{...this,d:!0,e:`${this.e}_or_nullish`}}var y={__rc_type:void 0,withFallback:ye,where:le,optional:J,optionalKey:J,orNullish:de,withAutofix:fe,orNull:Te,R:void 0,g:void 0,c:void 0,T:!1,p:!1,d:!1,j:!1,k:!1,f:void 0,h:void 0,t:void 0,_:!1,b:!1,u:[]},pe={...y,r(e,r){return c(this,e,r,()=>e===void 0)},e:"undefined"},Re={...y,r(e,r){return c(this,e,r,()=>e===null)},e:"null"},_e={...y,r(e,r){return c(this,e,r,()=>!0)},e:"any"},he={...y,r(e,r){return c(this,e,r,()=>!0)},e:"unknown"},be={...y,r(e,r){return c(this,e,r,()=>typeof e=="boolean")},e:"boolean"},ge={...y,r(e,r){return c(this,e,r,()=>typeof e=="string")},e:"string"},je={...y,r(e,r){return c(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},ke={...y,r(e,r){return c(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function Oe(e){return{...y,r(r,n){return c(this,r,n,()=>r instanceof e)},e:`instanceof_${e.name?`_${e.name}`:""}`}}function xe(...e){if(e.length===0)throw new Error("rc_literal requires at least one literal");return{...y,r(r,n){return c(this,r,n,()=>{for(let t of e)if(r===t)return!0;return!1})},k:!0,e:e.length==1?P(e[0],!0):e.map(r=>P(r,!0)).join(" | ")}}var Z=1;function me(...e){if(e.length===0)throw new Error("Unions should have at least one type");return{...y,r(r,n){return c(this,r,n,()=>{let t=n.n,o=[],a=0,s=!1,f=[],i=0;for(let u of e){i+=1,u._&&(n.n=`${t}|union ${i}|`);let T=n.o;n.o=!0,n.a=0;let[d,l]=u.r(r,n),h=n.a;if(n.o=T,n.a=0,d)return!0;u._&&h!==-1?h>0?f.push(...l):(a<Z&&o.push(...l),a+=1):s=!0}return n.n=t,f.length>0||o.length>0?((a>Z||s)&&o.push(p(n,"not matches any other union member")),{errors:[...f,...o],data:void 0}):!1})},e:e.map(r=>r.e).join(" | ")}}function we(e,r){return{...e,T:!1,d:!1,p:!1,r(t,o){return c(this,t,o,()=>{if(t===void 0)return n();let[a,s]=e.r(t,o);return a?s===void 0?n():{data:s,errors:!1}:{data:void 0,errors:s}})},e:`${e.e}_default`};function n(){return{data:v(r)?r():r,errors:!1}}}function Pe(e,r){return{...e,T:!1,d:!1,p:!1,r(t,o){return c(this,t,o,()=>{if(t==null)return n();let[a,s]=e.r(t,o);return a?s==null?n():{data:s,errors:!1}:{data:void 0,errors:s}})},e:`${e.e}_nullish_default`};function n(){return{data:v(r)?r():r,errors:!1}}}function X(e,{checkKey:r,looseCheck:n}={}){return{...y,e:`record<string, ${e.e}>`,r(t,o){return c(this,t,o,()=>{if(!k(t))return!1;let a={},s=[],f=o.n;for(let[i,u]of Object.entries(t)){let T=`.${i}`,d=`${f}${T}`;if(o.n=d,r&&!r(i)){s.push(p(o,`Key '${i}' is not allowed`));continue}let l=t[i],[h,b]=e.r(u,o);if(h)a[i]=l;else{let g=b;for(let R of g)s.push(R);if(o.o)break}}if(s.length>0)if(n)G(o,s);else return{errors:s,data:void 0};return{errors:!1,data:a}})}}}function Ee(e,{checkKey:r}={}){return X(e,{checkKey:r,looseCheck:!0})}function E(e,r,n,t=!1,o){let a=t&&!n.i&&!n.y,s=o?.unique,f=[],i=[],u=s?new Set:void 0,T=n.n,d=Array.isArray(r),l=-1;for(let h of e){l++;let b=d?r[l]:r,g=`[${l}]`,R=`${T}${g}`;n.n=R;let j=b.r(h,n),[A,O]=j;if(n.n=R,A&&u){let m=O,K=typeof s=="string";K?m=O[s]:typeof s=="function"&&(m=s(O)),u.has(m)?(K&&(n.n=`${T}${g}.${s}`),j=[!1,[p(n,K?`Type '${b.t?.[s]?.e}' with value "${m}" is not unique`:typeof s=="function"?`Type '${b.e}' unique fn return with value "${m}" is not unique`:`${b.e} value is not unique`)]]):u.add(m)}let[x,S]=j;if(x)i.push(S);else if(a){f.push(S);continue}else return{errors:S,data:void 0}}if(f.length>0){if(i.length===0)return{errors:f.slice(0,5).flat(),data:void 0};G(n,f.flat())}return{errors:!1,data:i}}function $e(e,r){return{...y,e:`${e.e}[]`,R:e,r(n,t){return c(this,n,t,()=>Array.isArray(n)?n.length===0?!0:E.call(this,n,e,t,!1,r):!1)}}}function Ae(e){if(!e.R)throw new Error("Type does not have an item type");return e.R}function Se(e,{nonRecursive:r=!1}={}){if(r){if(!e.e.endsWith("[]"))throw new Error("rc_disable_loose_array: nonRecursive option can only be used with array types");return{...e,r(n,t){return c(this,n,t,()=>Array.isArray(n)?n.length===0?!0:E.call(this,n,e,t,!1):!1)}}}return{...e,r(n,t){let o=t.y;t.y=!0;let a=e.r(n,t);return t.y=o,a}}}function Ke(e,r){return{...y,R:e,e:`${e.e}[]`,r(n,t){return c(this,n,t,()=>Array.isArray(n)?n.length===0?!0:E.call(this,n,e,t,!0,r):!1)}}}function Ie(e){return{...y,e:`[${e.map(r=>r.e).join(", ")}]`,r(r,n){return c(this,r,n,()=>!Array.isArray(r)||r.length!==e.length?!1:E.call(this,r,e,n))}}}function $(e,r,{noWarnings:n=!1}={}){let t={l:[],n:"",o:!1,a:0,i:n,s:!1,y:!1},[o,a]=r.r(e,t);return o?{error:!1,ok:!0,data:a,warnings:t.l.length>0?t.l:!1}:{ok:!1,error:!0,errors:a}}function Ne(e){return r=>$(r,e)}function We(e,r,n){let t=$(e,r,n);return t.error?{data:null,errors:t.errors,warnings:!1}:{data:t.data,errors:!1,warnings:t.warnings}}function ve(e){return Y(e,null)}function Y(e,r){return e.error?{data:r,errors:e.errors,warnings:!1}:{data:e.data,errors:!1,warnings:e.warnings}}var w=class extends Error{constructor(n){super(n.join(", "));this.errors=n}};function qe(e){if(e.error)throw new w(e.errors);return e.data}function ee(e,r){let n={l:[],n:"",o:!1,a:0,i:!1,s:!1,y:!1};return!!r.r(e,n)[0]}function Ce(e){return r=>ee(r,e)}function Be(e){return{...y,e:"recursive",r(r,n){return e().r(r,n)}}}function re(e,r,n,t){let o=e.n,a=e.o,s=e.s,f=e.i;e.o=!0,e.n=`${o}|output|`,t||(e.s=!0,e.i=!0);let i=r.r(n,e);return e.s=s,e.i=f,e.n=o,e.o=a,i}function ne(e,r,{outputSchema:n,disableStrictOutputSchema:t}={}){return{...y,e:`transform_from_${e.e}`,r(o,a){let s=null;if(n){let[u,T]=re(a,n,o,t);if(u)return[!0,T];s=T}let[f,i]=e.r(o,a);return f?[!0,r(i,e)]:[!1,[...s||[],...i]]}}}function Fe(e,r){return ne(e,r)}function Ue(e,r,{outputSchema:n,disableStrictOutputSchema:t}={}){return{...y,e:`transform_from_${e.e}`,r(o,a){let s=null;if(n){let[u,T]=re(a,n,o,t);if(u)return[!0,T];s=T}let[f,i]=e.r(o,a);if(f){let u=r(i,e);return u.ok?[!0,u.data]:[!1,typeof u.errors=="string"?[p(a,u.errors)]:u.errors.map(T=>p(a,T))]}return[!1,[...s||[],...i]]}}}function P(e,r){let n=typeof e,t=(()=>{if(n==="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return n})();return r&&(t==="string"||t==="number"||t==="boolean")?`${t}(${e})`:t}function Ve(e){if(e.error)throw new Error(`invalid input: ${e.errors.join(", ")}`)}function k(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function N(e){return e.replace(/\W+/g," ").split(/ |\B(?=[A-Z])/).map(r=>r.toLowerCase()).join("_")}function De(e,r,n){try{if(typeof e!="string")return{ok:!1,error:!0,errors:[`expected a json string, got ${P(e,!0)}`]};let t=JSON.parse(e);return $(t,r,n)}catch(t){return{ok:!1,error:!0,errors:[`json parsing error: ${k(t)?t.message:""}`]}}}function v(e){return typeof e=="function"}0&&(module.exports={RcValidationError,defaultProps,getWarningOrErrorWithPath,isObject,parse,rc_any,rc_array,rc_assert_is_valid,rc_boolean,rc_date,rc_default,rc_disable_loose_array,rc_enable_obj_strict,rc_get_array_item_type,rc_get_from_key_as_fallback,rc_get_obj_schema,rc_instanceof,rc_is_valid,rc_literals,rc_loose_array,rc_loose_parse,rc_loose_record,rc_narrow,rc_null,rc_nullish_default,rc_number,rc_obj_builder,rc_obj_extends,rc_obj_merge,rc_obj_omit,rc_obj_pick,rc_obj_strict,rc_object,rc_parse,rc_parse_json,rc_parser,rc_record,rc_recursive,rc_string,rc_transform,rc_tuple,rc_undefined,rc_union,rc_unknown,rc_unsafe_transform,rc_unwrap,rc_unwrap_or,rc_unwrap_or_null,rc_validator,snakeCase});
1
+ "use strict";var I=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var se=Object.prototype.hasOwnProperty;var ae=(e,r)=>{for(var n in r)I(e,n,{get:r[n],enumerable:!0})},ie=(e,r,n,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of oe(r))!se.call(e,o)&&o!==n&&I(e,o,{get:()=>r[o],enumerable:!(t=te(r,o))||t.enumerable});return e};var ue=e=>ie(I({},"__esModule",{value:!0}),e);var Me={};ae(Me,{RcValidationError:()=>w,defaultProps:()=>l,getWarningOrErrorWithPath:()=>d,isObject:()=>k,parse:()=>c,rc_any:()=>_e,rc_array:()=>$e,rc_assert_is_valid:()=>Ve,rc_boolean:()=>be,rc_date:()=>ke,rc_default:()=>we,rc_disable_loose_array:()=>Se,rc_enable_obj_strict:()=>V,rc_get_array_item_type:()=>Ae,rc_get_from_key_as_fallback:()=>q,rc_get_obj_schema:()=>F,rc_instanceof:()=>Oe,rc_is_valid:()=>ee,rc_literals:()=>xe,rc_loose_array:()=>Ke,rc_loose_parse:()=>Ne,rc_loose_record:()=>Ee,rc_narrow:()=>Fe,rc_null:()=>Re,rc_nullish_default:()=>Pe,rc_number:()=>je,rc_obj_builder:()=>L,rc_obj_extends:()=>B,rc_obj_merge:()=>D,rc_obj_omit:()=>z,rc_obj_pick:()=>M,rc_obj_strict:()=>U,rc_object:()=>_,rc_parse:()=>$,rc_parse_json:()=>De,rc_parser:()=>ve,rc_record:()=>X,rc_recursive:()=>Be,rc_string:()=>ge,rc_transform:()=>ne,rc_tuple:()=>Ie,rc_undefined:()=>de,rc_union:()=>me,rc_unknown:()=>he,rc_unsafe_transform:()=>Ue,rc_unwrap:()=>qe,rc_unwrap_or:()=>Y,rc_unwrap_or_null:()=>We,rc_validator:()=>Ce,snakeCase:()=>v});module.exports=ue(Me);function q(e,r){return{...r,y:e}}function ce(e){return k(e)&&"__rc_type"in e}function C(e){if(ce(e))return e;if(k(e)){let r={};for(let[n,t]of Object.entries(e))r[n]=C(t);return _(r)}throw new Error(`invalid schema: ${e}`)}function _(e,{normalizeKeysFrom:r}={}){let n={};for(let[t,o]of Object.entries(e))n[t]=C(o);return{...l,t:n,e:"object",_:!0,u:Object.entries(n),r(t,o){return c(this,t,o,()=>{if(!k(t))return o.a=-1,!1;let s=this.e==="strict_obj"||o.s?new Set(Object.keys(t)):void 0;if(s&&s.size>this.u.length){o.a=-1;let p=[];if(o.o)return{data:void 0,errors:[d(o,`Expected strict object with ${this.u.length} keys but got ${s.size}`)]};for(let[f]of this.u)s.has(f)?s.delete(f):p.push(d(o,`Key '${f}' is missing`));for(let f of s)p.push(d(o,`Key '${f}' is not defined in the object shape`));return{data:void 0,errors:p}}let y={},i=[],u=o.n,T=-1;for(let[p,f]of this.u){let h=p;T+=1;let b=`.${p}`,g=`${u}${b}`;o.n=g;let R=t[p],j=p;if(R===void 0&&f.y&&(R=t[f.y],j=f.y),R===void 0&&r==="snake_case"){let x=v(p);R=t[x],j=x}s?.delete(j);let[A,O]=f.r(R,o);if(A)y[h]=O;else{for(let x of O)o.n=g,i.push(x);if(o.o){o.a=T;break}}}if(s&&s.size>0)for(let p of s)o.n=u,i.push(d(o,`Key '${p}' is not defined in the object shape`));return i.length>0?{errors:i,data:void 0}:this.b?{errors:!1,data:{...t,...y}}:{errors:!1,data:y}})}}}function B(e,r){return{..._(e,r),e:"extends_object",b:!0}}function F(e){if(!e.t)throw new Error("type does not have an object shape");return e.t}function U(e,r){return{..._(e,r),e:"strict_obj"}}function V(e,{nonRecursive:r}={}){if(r){if(!e.t)throw new Error("rc_enable_obj_strict: nonRecursive option can only be used on object types");return{...e,e:"strict_obj"}}return{...e,r(n,t){let o=t.s;t.s=!0;let a=e.r(n,t);return t.s=o,a}}}function D(...e){let r={};for(let n of e)Object.assign(r,n.t);return _(r)}function M(e,r){let n={};if(!e.t)throw new Error("rc_obj_pick: obj must be an object type");for(let t of r){let o=e.t[t];o&&(n[t]=o)}return _(n)}function z(e,r){let n={};if(!e.t)throw new Error("rc_obj_omit: obj must be an object type");for(let t of Object.keys(e.t))r.includes(t)||(n[t]=e.t[t]);return _(n)}function L(){return(e,r)=>_(e,r)}function le(e){return{...this,g:e}}function d(e,r){return`${e.n?`$${e.n}: `:""}${r}`}function N(e,r){e.f.push(r.startsWith("$")?r:d(e,r))}function G(e,r){r.forEach(n=>N(e,n))}function c(e,r,n,t){if(e.T&&r===void 0)return[!0,r];if(e.p&&r==null)return[!0,r];if(e.d&&r===null)return[!0,r];let o=t();if(o&&(o===!0||!o.errors)){let a=o===!0?r:o.data;return e.c&&!e.c(a)?[!1,[d(n,`Predicate failed for type '${e.e}'`)]]:[!0,a]}if(!n.i){let a=e.g;if(a!==void 0)return N(n,`Fallback used, errors -> ${Q(o,n,e,r)}`),[!0,W(a)?a():a];if(e.j&&e.h){let s=e.h(r);if(s)return e.c&&!e.c(s.fixed)?[!1,[d(n,`Predicate failed for autofix in type '${e.e}'`)]]:(N(n,`Autofixed from error "${Q(o,n,e,r)}"`),[!0,s.fixed])}}return[!1,o?o.errors:[d(n,H(e,r))]]}function Q(e,r,n,t){return e?e.errors.map(o=>o.replace(r.n,"")).join("; "):H(n,t)}function ye(e){return{...this,j:!0,h:e}}function fe(e){return{...this,c:e}}function J(){return{...this,T:!0}}function H(e,r){return`Type '${P(r,!!e.k)}' is not assignable to '${e.e}'`}function Te(){return{...this,d:!0,e:`${this.e}_or_null`}}function pe(){return{...this,p:!0,e:`${this.e}_or_nullish`}}var l={__rc_type:void 0,withFallback:le,where:fe,optional:J,optionalKey:J,orNullish:pe,withAutofix:ye,orNull:Te,R:void 0,g:void 0,c:void 0,T:!1,d:!1,p:!1,j:!1,k:!1,y:void 0,h:void 0,t:void 0,_:!1,b:!1,u:[]},de={...l,r(e,r){return c(this,e,r,()=>e===void 0)},e:"undefined"},Re={...l,r(e,r){return c(this,e,r,()=>e===null)},e:"null"},_e={...l,r(e,r){return c(this,e,r,()=>!0)},e:"any"},he={...l,r(e,r){return c(this,e,r,()=>!0)},e:"unknown"},be={...l,r(e,r){return c(this,e,r,()=>typeof e=="boolean")},e:"boolean"},ge={...l,r(e,r){return c(this,e,r,()=>typeof e=="string")},e:"string"},je={...l,r(e,r){return c(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},ke={...l,r(e,r){return c(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function Oe(e){return{...l,r(r,n){return c(this,r,n,()=>r instanceof e)},e:`instanceof_${e.name?`_${e.name}`:""}`}}function xe(...e){if(e.length===0)throw new Error("rc_literal requires at least one literal");return{...l,r(r,n){return c(this,r,n,()=>{for(let t of e)if(r===t)return!0;return!1})},k:!0,e:e.length==1?P(e[0],!0):e.map(r=>P(r,!0)).join(" | ")}}var Z=1;function me(...e){if(e.length===0)throw new Error("Unions should have at least one type");return{...l,r(r,n){return c(this,r,n,()=>{let t=n.n,o=[],a=0,s=!1,y=[],i=0;for(let u of e){i+=1,u._&&(n.n=`${t}|union ${i}|`);let T=n.o;n.o=!0,n.a=0;let[p,f]=u.r(r,n),h=n.a;if(n.o=T,n.a=0,p)return!0;u._&&h!==-1?h>0?y.push(...f):(a<Z&&o.push(...f),a+=1):s=!0}return n.n=t,y.length>0||o.length>0?((a>Z||s)&&o.push(d(n,"not matches any other union member")),{errors:[...y,...o],data:void 0}):!1})},e:e.map(r=>r.e).join(" | ")}}function we(e,r){return{...e,T:!1,p:!1,d:!1,r(t,o){return c(this,t,o,()=>{if(t===void 0)return n();let[a,s]=e.r(t,o);return a?s===void 0?n():{data:s,errors:!1}:{data:void 0,errors:s}})},e:`${e.e}_default`};function n(){return{data:W(r)?r():r,errors:!1}}}function Pe(e,r){return{...e,T:!1,p:!1,d:!1,r(t,o){return c(this,t,o,()=>{if(t==null)return n();let[a,s]=e.r(t,o);return a?s==null?n():{data:s,errors:!1}:{data:void 0,errors:s}})},e:`${e.e}_nullish_default`};function n(){return{data:W(r)?r():r,errors:!1}}}function X(e,{checkKey:r,looseCheck:n}={}){return{...l,e:`record<string, ${e.e}>`,r(t,o){return c(this,t,o,()=>{if(!k(t))return!1;let a={},s=[],y=o.n;for(let[i,u]of Object.entries(t)){let T=`.${i}`,p=`${y}${T}`;if(o.n=p,r&&!r(i)){s.push(d(o,`Key '${i}' is not allowed`));continue}let f=t[i],[h,b]=e.r(u,o);if(h)a[i]=f;else{let g=b;for(let R of g)s.push(R);if(o.o)break}}if(s.length>0)if(n)G(o,s);else return{errors:s,data:void 0};return{errors:!1,data:a}})}}}function Ee(e,{checkKey:r}={}){return X(e,{checkKey:r,looseCheck:!0})}function E(e,r,n,t=!1,o){let a=t&&!n.i&&!n.l,s=o?.unique,y=[],i=[],u=s?new Set:void 0,T=n.n,p=Array.isArray(r),f=-1;for(let h of e){f++;let b=p?r[f]:r,g=`[${f}]`,R=`${T}${g}`;n.n=R;let j=b.r(h,n),[A,O]=j;if(n.n=R,A&&u){let m=O,K=typeof s=="string";K?m=O[s]:typeof s=="function"&&(m=s(O)),u.has(m)?(K&&(n.n=`${T}${g}.${s}`),j=[!1,[d(n,K?`Type '${b.t?.[s]?.e}' with value "${m}" is not unique`:typeof s=="function"?`Type '${b.e}' unique fn return with value "${m}" is not unique`:`${b.e} value is not unique`)]]):u.add(m)}let[x,S]=j;if(x)i.push(S);else if(a){y.push(S);continue}else return{errors:S,data:void 0}}if(y.length>0){if(i.length===0)return{errors:y.slice(0,5).flat(),data:void 0};G(n,y.flat())}return{errors:!1,data:i}}function $e(e,r){return{...l,e:`${e.e}[]`,R:e,r(n,t){return c(this,n,t,()=>Array.isArray(n)?n.length===0?!0:E.call(this,n,e,t,!1,r):!1)}}}function Ae(e){if(!e.R)throw new Error("Type does not have an item type");return e.R}function Se(e,{nonRecursive:r=!1}={}){if(r){if(!e.e.endsWith("[]"))throw new Error("rc_disable_loose_array: nonRecursive option can only be used with array types");return{...e,r(n,t){return c(this,n,t,()=>Array.isArray(n)?n.length===0?!0:E.call(this,n,e,t,!1):!1)}}}return{...e,r(n,t){let o=t.l;t.l=!0;let a=e.r(n,t);return t.l=o,a}}}function Ke(e,r){return{...l,R:e,e:`${e.e}[]`,r(n,t){return c(this,n,t,()=>Array.isArray(n)?n.length===0?!0:E.call(this,n,e,t,!0,r):!1)}}}function Ie(e){return{...l,e:`[${e.map(r=>r.e).join(", ")}]`,r(r,n){return c(this,r,n,()=>!Array.isArray(r)||r.length!==e.length?!1:E.call(this,r,e,n))}}}function $(e,r,{noWarnings:n=!1}={}){let t={f:[],n:"",o:!1,a:0,i:n,s:!1,l:!1},[o,a]=r.r(e,t);return o?{error:!1,ok:!0,data:a,value:a,warnings:t.f.length>0?t.f:!1}:{ok:!1,error:!0,errors:a}}function ve(e){return r=>$(r,e)}function Ne(e,r,n){let t=$(e,r,n);return t.error?{data:null,errors:t.errors,warnings:!1}:{data:t.value,errors:!1,warnings:t.warnings}}function We(e){return Y(e,null)}function Y(e,r){return e.error?{value:r,errors:e.errors,warnings:!1}:{value:e.value,errors:!1,warnings:e.warnings}}var w=class extends Error{constructor(n){super(n.join(`
2
+ `));this.errors=n}};function qe(e){if(e.error)throw new w(e.errors);return e}function ee(e,r){let n={f:[],n:"",o:!1,a:0,i:!1,s:!1,l:!1};return!!r.r(e,n)[0]}function Ce(e){return r=>ee(r,e)}function Be(e){return{...l,e:"recursive",r(r,n){return e().r(r,n)}}}function re(e,r,n,t){let o=e.n,a=e.o,s=e.s,y=e.i;e.o=!0,e.n=`${o}|output|`,t||(e.s=!0,e.i=!0);let i=r.r(n,e);return e.s=s,e.i=y,e.n=o,e.o=a,i}function ne(e,r,{outputSchema:n,disableStrictOutputSchema:t}={}){return{...l,e:`transform_from_${e.e}`,r(o,a){let s=null;if(n){let[u,T]=re(a,n,o,t);if(u)return[!0,T];s=T}let[y,i]=e.r(o,a);return y?[!0,r(i,e)]:[!1,[...s||[],...i]]}}}function Fe(e,r){return ne(e,r)}function Ue(e,r,{outputSchema:n,disableStrictOutputSchema:t}={}){return{...l,e:`transform_from_${e.e}`,r(o,a){let s=null;if(n){let[u,T]=re(a,n,o,t);if(u)return[!0,T];s=T}let[y,i]=e.r(o,a);if(y){let u=r(i,e);return u.ok?[!0,u.data]:[!1,typeof u.errors=="string"?[d(a,u.errors)]:u.errors.map(T=>d(a,T))]}return[!1,[...s||[],...i]]}}}function P(e,r){let n=typeof e,t=(()=>{if(n==="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return n})();return r&&(t==="string"||t==="number"||t==="boolean")?`${t}(${e})`:t}function Ve(e){if(e.error)throw new Error(`invalid input: ${e.errors.join(", ")}`)}function k(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function v(e){return e.replace(/\W+/g," ").split(/ |\B(?=[A-Z])/).map(r=>r.toLowerCase()).join("_")}function De(e,r,n){try{if(typeof e!="string")return{ok:!1,error:!0,errors:[`expected a json string, got ${P(e,!0)}`]};let t=JSON.parse(e);return $(t,r,n)}catch(t){return{ok:!1,error:!0,errors:[`json parsing error: ${k(t)?t.message:""}`]}}}function W(e){return typeof e=="function"}0&&(module.exports={RcValidationError,defaultProps,getWarningOrErrorWithPath,isObject,parse,rc_any,rc_array,rc_assert_is_valid,rc_boolean,rc_date,rc_default,rc_disable_loose_array,rc_enable_obj_strict,rc_get_array_item_type,rc_get_from_key_as_fallback,rc_get_obj_schema,rc_instanceof,rc_is_valid,rc_literals,rc_loose_array,rc_loose_parse,rc_loose_record,rc_narrow,rc_null,rc_nullish_default,rc_number,rc_obj_builder,rc_obj_extends,rc_obj_merge,rc_obj_omit,rc_obj_pick,rc_obj_strict,rc_object,rc_parse,rc_parse_json,rc_parser,rc_record,rc_recursive,rc_string,rc_transform,rc_tuple,rc_undefined,rc_union,rc_unknown,rc_unsafe_transform,rc_unwrap,rc_unwrap_or,rc_unwrap_or_null,rc_validator,snakeCase});
@@ -53,7 +53,9 @@ declare function rc_obj_builder<T extends Record<string, any>>(): <S extends Str
53
53
  type RcParseResult<T> = {
54
54
  error: false;
55
55
  ok: true;
56
+ /** @deprecated use value instead */
56
57
  data: T;
58
+ value: T;
57
59
  warnings: string[] | false;
58
60
  } | {
59
61
  ok: false;
@@ -166,12 +168,12 @@ declare function rc_loose_parse<S>(input: any, type: RcType<S>, options?: ParseO
166
168
  warnings: string[] | false;
167
169
  };
168
170
  declare function rc_unwrap_or_null<R>(result: RcParseResult<R>): {
169
- data: R | null;
171
+ value: R | null;
170
172
  errors: string[] | false;
171
173
  warnings: string[] | false;
172
174
  };
173
175
  declare function rc_unwrap_or<R, F>(result: RcParseResult<R>, fallback: F): {
174
- data: R | F;
176
+ value: R | F;
175
177
  errors: string[] | false;
176
178
  warnings: string[] | false;
177
179
  };
@@ -179,7 +181,10 @@ declare class RcValidationError extends Error {
179
181
  readonly errors: string[];
180
182
  constructor(errors: string[]);
181
183
  }
182
- declare function rc_unwrap<R>(result: RcParseResult<R>): R;
184
+ declare function rc_unwrap<R>(result: RcParseResult<R>): {
185
+ value: R;
186
+ warnings: string[] | false;
187
+ };
183
188
  declare function rc_is_valid<S>(input: any, type: RcType<S>): input is S;
184
189
  declare function rc_validator<S>(type: RcType<S>): (input: any) => input is S;
185
190
  declare function rc_recursive<T>(type: () => RcType<T>): RcType<T>;
@@ -199,21 +204,17 @@ declare function rc_unsafe_transform<Input, Transformed>(type: RcType<Input>, tr
199
204
  ok: false;
200
205
  errors: string | string[];
201
206
  }, { outputSchema, disableStrictOutputSchema, }?: TransformOptions<Transformed>): RcType<Transformed>;
202
- type NonArrayObject = {
203
- [x: string]: any;
204
- [y: number]: never;
205
- };
206
207
  declare function rc_assert_is_valid<S>(result: RcParseResult<S>): asserts result is {
207
208
  ok: true;
208
209
  error: false;
209
210
  data: S;
211
+ value: S;
210
212
  warnings: string[] | false;
211
213
  };
212
- declare function isObject(value: any): value is NonArrayObject;
213
214
  declare function rc_parse_json<T>(jsonString: unknown, schema: RcType<T>, options?: ParseOptions): RcParseResult<T>;
214
215
  type Prettify<T> = T extends Record<string, any> ? {
215
216
  [K in keyof T]: Prettify<T[K]>;
216
217
  } : T;
217
218
  type RcPrettyInferType<T extends RcType<any>> = Prettify<RcInferType<T>>;
218
219
 
219
- export { RcBase, RcInferType, RcOptionalKeyType, RcParseResult, RcParser, RcPrettyInferType, RcType, RcValidationError, defaultProps, getWarningOrErrorWithPath, isObject, parse, rc_any, rc_array, rc_assert_is_valid, rc_boolean, rc_date, rc_default, rc_disable_loose_array, rc_enable_obj_strict, rc_get_array_item_type, rc_get_from_key_as_fallback, rc_get_obj_shape as rc_get_obj_schema, rc_instanceof, rc_is_valid, rc_literals, rc_loose_array, rc_loose_parse, rc_loose_record, rc_narrow, rc_null, rc_nullish_default, rc_number, rc_obj_builder, rc_obj_extends, rc_obj_merge, rc_obj_omit, rc_obj_pick, rc_obj_strict, rc_object, rc_parse, rc_parse_json, rc_parser, rc_record, rc_recursive, rc_string, rc_transform, rc_tuple, rc_undefined, rc_union, rc_unknown, rc_unsafe_transform, rc_unwrap, rc_unwrap_or, rc_unwrap_or_null, rc_validator };
220
+ export { RcBase, RcInferType, RcOptionalKeyType, RcParseResult, RcParser, RcPrettyInferType, RcType, RcValidationError, defaultProps, getWarningOrErrorWithPath, parse, rc_any, rc_array, rc_assert_is_valid, rc_boolean, rc_date, rc_default, rc_disable_loose_array, rc_enable_obj_strict, rc_get_array_item_type, rc_get_from_key_as_fallback, rc_get_obj_shape as rc_get_obj_schema, rc_instanceof, rc_is_valid, rc_literals, rc_loose_array, rc_loose_parse, rc_loose_record, rc_narrow, rc_null, rc_nullish_default, rc_number, rc_obj_builder, rc_obj_extends, rc_obj_merge, rc_obj_omit, rc_obj_pick, rc_obj_strict, rc_object, rc_parse, rc_parse_json, rc_parser, rc_record, rc_recursive, rc_string, rc_transform, rc_tuple, rc_undefined, rc_union, rc_unknown, rc_unsafe_transform, rc_unwrap, rc_unwrap_or, rc_unwrap_or_null, rc_validator };
package/dist/runcheck.js CHANGED
@@ -1 +1 @@
1
- import{A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-465GEK7B.js";export{M as RcValidationError,m as defaultProps,k as getWarningOrErrorWithPath,V as isObject,l as parse,p as rc_any,C as rc_array,U as rc_assert_is_valid,r as rc_boolean,u as rc_date,y as rc_default,E as rc_disable_loose_array,f as rc_enable_obj_strict,D as rc_get_array_item_type,a as rc_get_from_key_as_fallback,d as rc_get_obj_schema,v as rc_instanceof,O as rc_is_valid,w as rc_literals,F as rc_loose_array,J as rc_loose_parse,B as rc_loose_record,S as rc_narrow,o as rc_null,z as rc_nullish_default,t as rc_number,j as rc_obj_builder,c as rc_obj_extends,g as rc_obj_merge,i as rc_obj_omit,h as rc_obj_pick,e as rc_obj_strict,b as rc_object,H as rc_parse,X as rc_parse_json,I as rc_parser,A as rc_record,Q as rc_recursive,s as rc_string,R as rc_transform,G as rc_tuple,n as rc_undefined,x as rc_union,q as rc_unknown,T as rc_unsafe_transform,N as rc_unwrap,L as rc_unwrap_or,K as rc_unwrap_or_null,P as rc_validator,W as snakeCase};
1
+ import{A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-BBFBYV3C.js";export{M as RcValidationError,m as defaultProps,k as getWarningOrErrorWithPath,V as isObject,l as parse,p as rc_any,C as rc_array,U as rc_assert_is_valid,r as rc_boolean,u as rc_date,y as rc_default,E as rc_disable_loose_array,f as rc_enable_obj_strict,D as rc_get_array_item_type,a as rc_get_from_key_as_fallback,d as rc_get_obj_schema,v as rc_instanceof,O as rc_is_valid,w as rc_literals,F as rc_loose_array,J as rc_loose_parse,B as rc_loose_record,S as rc_narrow,o as rc_null,z as rc_nullish_default,t as rc_number,j as rc_obj_builder,c as rc_obj_extends,g as rc_obj_merge,i as rc_obj_omit,h as rc_obj_pick,e as rc_obj_strict,b as rc_object,H as rc_parse,X as rc_parse_json,I as rc_parser,A as rc_record,Q as rc_recursive,s as rc_string,R as rc_transform,G as rc_tuple,n as rc_undefined,x as rc_union,q as rc_unknown,T as rc_unsafe_transform,N as rc_unwrap,L as rc_unwrap_or,K as rc_unwrap_or_null,P as rc_validator,W as snakeCase};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "runcheck",
3
3
  "description": "A tiny (less than 2 KiB Gzipped) and treeshakable! lib for typescript runtime type checks with autofix support",
4
- "version": "0.51.0",
4
+ "version": "0.53.0",
5
5
  "license": "MIT",
6
6
  "files": [
7
7
  "dist"
@@ -1 +0,0 @@
1
- function D(e,r){return{...r,y:e}}function M(e){return m(e)&&"__rc_type"in e}function W(e){if(M(e))return e;if(m(e)){let r={};for(let[n,t]of Object.entries(e))r[n]=W(t);return b(r)}throw new Error(`invalid schema: ${e}`)}function b(e,{normalizeKeysFrom:r}={}){let n={};for(let[t,o]of Object.entries(e))n[t]=W(o);return{...f,t:n,e:"object",_:!0,u:Object.entries(n),r(t,o){return y(this,t,o,()=>{if(!m(t))return o.a=-1,!1;let s=this.e==="strict_obj"||o.s?new Set(Object.keys(t)):void 0;if(s&&s.size>this.u.length){o.a=-1;let d=[];if(o.o)return{data:void 0,errors:[p(o,`Expected strict object with ${this.u.length} keys but got ${s.size}`)]};for(let[l]of this.u)s.has(l)?s.delete(l):d.push(p(o,`Key '${l}' is missing`));for(let l of s)d.push(p(o,`Key '${l}' is not defined in the object shape`));return{data:void 0,errors:d}}let c={},i=[],u=o.n,T=-1;for(let[d,l]of this.u){let _=d;T+=1;let h=`.${d}`,g=`${u}${h}`;o.n=g;let R=t[d],j=d;if(R===void 0&&l.y&&(R=t[l.y],j=l.y),R===void 0&&r==="snake_case"){let O=v(d);R=t[O],j=O}s?.delete(j);let[E,k]=l.r(R,o);if(E)c[_]=k;else{for(let O of k)o.n=g,i.push(O);if(o.o){o.a=T;break}}}if(s&&s.size>0)for(let d of s)o.n=u,i.push(p(o,`Key '${d}' is not defined in the object shape`));return i.length>0?{errors:i,data:void 0}:this.b?{errors:!1,data:{...t,...c}}:{errors:!1,data:c}})}}}function z(e,r){return{...b(e,r),e:"extends_object",b:!0}}function L(e){if(!e.t)throw new Error("type does not have an object shape");return e.t}function Q(e,r){return{...b(e,r),e:"strict_obj"}}function J(e,{nonRecursive:r}={}){if(r){if(!e.t)throw new Error("rc_enable_obj_strict: nonRecursive option can only be used on object types");return{...e,e:"strict_obj"}}return{...e,r(n,t){let o=t.s;t.s=!0;let a=e.r(n,t);return t.s=o,a}}}function Z(...e){let r={};for(let n of e)Object.assign(r,n.t);return b(r)}function G(e,r){let n={};if(!e.t)throw new Error("rc_obj_pick: obj must be an object type");for(let t of r){let o=e.t[t];o&&(n[t]=o)}return b(n)}function H(e,r){let n={};if(!e.t)throw new Error("rc_obj_omit: obj must be an object type");for(let t of Object.keys(e.t))r.includes(t)||(n[t]=e.t[t]);return b(n)}function X(){return(e,r)=>b(e,r)}function Y(e){return{...this,g:e}}function p(e,r){return`${e.n?`$${e.n}: `:""}${r}`}function S(e,r){e.l.push(r.startsWith("$")?r:p(e,r))}function F(e,r){r.forEach(n=>S(e,n))}function y(e,r,n,t){if(e.T&&r===void 0)return[!0,r];if(e.d&&r==null)return[!0,r];if(e.p&&r===null)return[!0,r];let o=t();if(o&&(o===!0||!o.errors)){let a=o===!0?r:o.data;return e.c&&!e.c(a)?[!1,[p(n,`Predicate failed for type '${e.e}'`)]]:[!0,a]}if(!n.i){let a=e.g;if(a!==void 0)return S(n,`Fallback used, errors -> ${q(o,n,e,r)}`),[!0,N(a)?a():a];if(e.j&&e.h){let s=e.h(r);if(s)return e.c&&!e.c(s.fixed)?[!1,[p(n,`Predicate failed for autofix in type '${e.e}'`)]]:(S(n,`Autofixed from error "${q(o,n,e,r)}"`),[!0,s.fixed])}}return[!1,o?o.errors:[p(n,U(e,r))]]}function q(e,r,n,t){return e?e.errors.map(o=>o.replace(r.n,"")).join("; "):U(n,t)}function ee(e){return{...this,j:!0,h:e}}function re(e){return{...this,c:e}}function C(){return{...this,T:!0}}function U(e,r){return`Type '${w(r,!!e.k)}' is not assignable to '${e.e}'`}function ne(){return{...this,p:!0,e:`${this.e}_or_null`}}function te(){return{...this,d:!0,e:`${this.e}_or_nullish`}}var f={__rc_type:void 0,withFallback:Y,where:re,optional:C,optionalKey:C,orNullish:te,withAutofix:ee,orNull:ne,R:void 0,g:void 0,c:void 0,T:!1,p:!1,d:!1,j:!1,k:!1,y:void 0,h:void 0,t:void 0,_:!1,b:!1,u:[]},pe={...f,r(e,r){return y(this,e,r,()=>e===void 0)},e:"undefined"},Re={...f,r(e,r){return y(this,e,r,()=>e===null)},e:"null"},_e={...f,r(e,r){return y(this,e,r,()=>!0)},e:"any"},he={...f,r(e,r){return y(this,e,r,()=>!0)},e:"unknown"},be={...f,r(e,r){return y(this,e,r,()=>typeof e=="boolean")},e:"boolean"},ge={...f,r(e,r){return y(this,e,r,()=>typeof e=="string")},e:"string"},je={...f,r(e,r){return y(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},ke={...f,r(e,r){return y(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function Oe(e){return{...f,r(r,n){return y(this,r,n,()=>r instanceof e)},e:`instanceof_${e.name?`_${e.name}`:""}`}}function xe(...e){if(e.length===0)throw new Error("rc_literal requires at least one literal");return{...f,r(r,n){return y(this,r,n,()=>{for(let t of e)if(r===t)return!0;return!1})},k:!0,e:e.length==1?w(e[0],!0):e.map(r=>w(r,!0)).join(" | ")}}var B=1;function me(...e){if(e.length===0)throw new Error("Unions should have at least one type");return{...f,r(r,n){return y(this,r,n,()=>{let t=n.n,o=[],a=0,s=!1,c=[],i=0;for(let u of e){i+=1,u._&&(n.n=`${t}|union ${i}|`);let T=n.o;n.o=!0,n.a=0;let[d,l]=u.r(r,n),_=n.a;if(n.o=T,n.a=0,d)return!0;u._&&_!==-1?_>0?c.push(...l):(a<B&&o.push(...l),a+=1):s=!0}return n.n=t,c.length>0||o.length>0?((a>B||s)&&o.push(p(n,"not matches any other union member")),{errors:[...c,...o],data:void 0}):!1})},e:e.map(r=>r.e).join(" | ")}}function we(e,r){return{...e,T:!1,d:!1,p:!1,r(t,o){return y(this,t,o,()=>{if(t===void 0)return n();let[a,s]=e.r(t,o);return a?s===void 0?n():{data:s,errors:!1}:{data:void 0,errors:s}})},e:`${e.e}_default`};function n(){return{data:N(r)?r():r,errors:!1}}}function Pe(e,r){return{...e,T:!1,d:!1,p:!1,r(t,o){return y(this,t,o,()=>{if(t==null)return n();let[a,s]=e.r(t,o);return a?s==null?n():{data:s,errors:!1}:{data:void 0,errors:s}})},e:`${e.e}_nullish_default`};function n(){return{data:N(r)?r():r,errors:!1}}}function oe(e,{checkKey:r,looseCheck:n}={}){return{...f,e:`record<string, ${e.e}>`,r(t,o){return y(this,t,o,()=>{if(!m(t))return!1;let a={},s=[],c=o.n;for(let[i,u]of Object.entries(t)){let T=`.${i}`,d=`${c}${T}`;if(o.n=d,r&&!r(i)){s.push(p(o,`Key '${i}' is not allowed`));continue}let l=t[i],[_,h]=e.r(u,o);if(_)a[i]=l;else{let g=h;for(let R of g)s.push(R);if(o.o)break}}if(s.length>0)if(n)F(o,s);else return{errors:s,data:void 0};return{errors:!1,data:a}})}}}function Ee(e,{checkKey:r}={}){return oe(e,{checkKey:r,looseCheck:!0})}function P(e,r,n,t=!1,o){let a=t&&!n.i&&!n.f,s=o?.unique,c=[],i=[],u=s?new Set:void 0,T=n.n,d=Array.isArray(r),l=-1;for(let _ of e){l++;let h=d?r[l]:r,g=`[${l}]`,R=`${T}${g}`;n.n=R;let j=h.r(_,n),[E,k]=j;if(n.n=R,E&&u){let x=k,A=typeof s=="string";A?x=k[s]:typeof s=="function"&&(x=s(k)),u.has(x)?(A&&(n.n=`${T}${g}.${s}`),j=[!1,[p(n,A?`Type '${h.t?.[s]?.e}' with value "${x}" is not unique`:typeof s=="function"?`Type '${h.e}' unique fn return with value "${x}" is not unique`:`${h.e} value is not unique`)]]):u.add(x)}let[O,$]=j;if(O)i.push($);else if(a){c.push($);continue}else return{errors:$,data:void 0}}if(c.length>0){if(i.length===0)return{errors:c.slice(0,5).flat(),data:void 0};F(n,c.flat())}return{errors:!1,data:i}}function $e(e,r){return{...f,e:`${e.e}[]`,R:e,r(n,t){return y(this,n,t,()=>Array.isArray(n)?n.length===0?!0:P.call(this,n,e,t,!1,r):!1)}}}function Ae(e){if(!e.R)throw new Error("Type does not have an item type");return e.R}function Se(e,{nonRecursive:r=!1}={}){if(r){if(!e.e.endsWith("[]"))throw new Error("rc_disable_loose_array: nonRecursive option can only be used with array types");return{...e,r(n,t){return y(this,n,t,()=>Array.isArray(n)?n.length===0?!0:P.call(this,n,e,t,!1):!1)}}}return{...e,r(n,t){let o=t.f;t.f=!0;let a=e.r(n,t);return t.f=o,a}}}function Ke(e,r){return{...f,R:e,e:`${e.e}[]`,r(n,t){return y(this,n,t,()=>Array.isArray(n)?n.length===0?!0:P.call(this,n,e,t,!0,r):!1)}}}function Ie(e){return{...f,e:`[${e.map(r=>r.e).join(", ")}]`,r(r,n){return y(this,r,n,()=>!Array.isArray(r)||r.length!==e.length?!1:P.call(this,r,e,n))}}}function I(e,r,{noWarnings:n=!1}={}){let t={l:[],n:"",o:!1,a:0,i:n,s:!1,f:!1},[o,a]=r.r(e,t);return o?{error:!1,ok:!0,data:a,warnings:t.l.length>0?t.l:!1}:{ok:!1,error:!0,errors:a}}function Ne(e){return r=>I(r,e)}function We(e,r,n){let t=I(e,r,n);return t.error?{data:null,errors:t.errors,warnings:!1}:{data:t.data,errors:!1,warnings:t.warnings}}function ve(e){return se(e,null)}function se(e,r){return e.error?{data:r,errors:e.errors,warnings:!1}:{data:e.data,errors:!1,warnings:e.warnings}}var K=class extends Error{constructor(n){super(n.join(", "));this.errors=n}};function qe(e){if(e.error)throw new K(e.errors);return e.data}function ae(e,r){let n={l:[],n:"",o:!1,a:0,i:!1,s:!1,f:!1};return!!r.r(e,n)[0]}function Ce(e){return r=>ae(r,e)}function Be(e){return{...f,e:"recursive",r(r,n){return e().r(r,n)}}}function V(e,r,n,t){let o=e.n,a=e.o,s=e.s,c=e.i;e.o=!0,e.n=`${o}|output|`,t||(e.s=!0,e.i=!0);let i=r.r(n,e);return e.s=s,e.i=c,e.n=o,e.o=a,i}function ie(e,r,{outputSchema:n,disableStrictOutputSchema:t}={}){return{...f,e:`transform_from_${e.e}`,r(o,a){let s=null;if(n){let[u,T]=V(a,n,o,t);if(u)return[!0,T];s=T}let[c,i]=e.r(o,a);return c?[!0,r(i,e)]:[!1,[...s||[],...i]]}}}function Fe(e,r){return ie(e,r)}function Ue(e,r,{outputSchema:n,disableStrictOutputSchema:t}={}){return{...f,e:`transform_from_${e.e}`,r(o,a){let s=null;if(n){let[u,T]=V(a,n,o,t);if(u)return[!0,T];s=T}let[c,i]=e.r(o,a);if(c){let u=r(i,e);return u.ok?[!0,u.data]:[!1,typeof u.errors=="string"?[p(a,u.errors)]:u.errors.map(T=>p(a,T))]}return[!1,[...s||[],...i]]}}}function w(e,r){let n=typeof e,t=(()=>{if(n==="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return n})();return r&&(t==="string"||t==="number"||t==="boolean")?`${t}(${e})`:t}function Ve(e){if(e.error)throw new Error(`invalid input: ${e.errors.join(", ")}`)}function m(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function v(e){return e.replace(/\W+/g," ").split(/ |\B(?=[A-Z])/).map(r=>r.toLowerCase()).join("_")}function De(e,r,n){try{if(typeof e!="string")return{ok:!1,error:!0,errors:[`expected a json string, got ${w(e,!0)}`]};let t=JSON.parse(e);return I(t,r,n)}catch(t){return{ok:!1,error:!0,errors:[`json parsing error: ${m(t)?t.message:""}`]}}}function N(e){return typeof e=="function"}export{D as a,b,z as c,L as d,Q as e,J as f,Z as g,G as h,H as i,X as j,p as k,y as l,f as m,pe as n,Re as o,_e as p,he as q,be as r,ge as s,je as t,ke as u,Oe as v,xe as w,me as x,we as y,Pe as z,oe as A,Ee as B,$e as C,Ae as D,Se as E,Ke as F,Ie as G,I as H,Ne as I,We as J,ve as K,se as L,K as M,qe as N,ae as O,Ce as P,Be as Q,ie as R,Fe as S,Ue as T,Ve as U,m as V,v as W,De as X};