runcheck 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";var c=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var p=(e,r)=>{for(var a in r)c(e,a,{get:r[a],enumerable:!0})},R=(e,r,a,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of T(r))!d.call(e,n)&&n!==a&&c(e,n,{get:()=>r[n],enumerable:!(i=f(r,n))||i.enumerable});return e};var _=e=>R(c({},"__esModule",{value:!0}),e);var S={};p(S,{rc_boolean_autofix:()=>k,rc_number_autofix:()=>A,rc_string_autofix:()=>O});module.exports=_(S);function h(e){return{...this,a:e}}function s(e,r,a,i){if(e.c&&r===void 0)return[!0,r];if(e.u&&r==null)return[!0,r];if(e.l&&r===null)return[!0,r];let n=i();if(n&&(n===!0||"data"in n)){let t=n===!0?r:n.data;return e.t&&!e.t(t)?[!1,[e.n(t)]]:[!0,t]}if(e.a!==void 0)return a.warnings.push(`Fallback used, ${e.n(r)}`),[!0,e.a];if(e.y&&e.i){let t=e.i(r);if(t)return e.t&&!e.t(t.fixed)?[!1,[e.n(t.fixed)]]:(a.warnings.push(`Autofixed from, ${e.n(r)}`),[!0,t.fixed])}return[!1,n&&"errors"in n?n.errors:[e.n(r)]]}function x(e){return{...this,y:!0,i:e}}function b(e){return{...this,t:e,e:`${this.e}_with_predicate`}}function g(){return{...this,c:!0}}function w(e){return`Type '${$(e)}' is not assignable to '${this.e}'`}function m(){return{...this,l:!0,e:`${this.e}_or_nullable`}}function j(){return{...this,u:!0,e:`${this.e}_or_nullish`}}var o={withFallback:h,where:b,optional:g,n:w,nullable:m,withAutofix:x,nullish:j},P={...o,r(e,r){return s(this,e,r,()=>e===void 0)},e:"undefined"},V={...o,r(e,r){return s(this,e,r,()=>e===null)},e:"null"},q={...o,r(e,r){return s(this,e,r,()=>!0)},e:"any"},E={...o,r(e,r){return s(this,e,r,()=>!0)},e:"unknown"},u={...o,r(e,r){return s(this,e,r,()=>typeof e=="boolean")},e:"boolean"},l={...o,r(e,r){return s(this,e,r,()=>typeof e=="string")},e:"string"},y={...o,r(e,r){return s(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},I={...o,r(e,r){return s(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function $(e){if(typeof e=="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return typeof e}var k=u.withAutofix(e=>e==null||e===0||e===1?{fixed:!!e}:e==="true"||e==="false"?{fixed:e==="true"}:!1),O=l.withAutofix(e=>typeof e=="number"&&!Number.isNaN(e)?{fixed:e.toString()}:!1),A=y.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 c=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var p=(e,r)=>{for(var a in r)c(e,a,{get:r[a],enumerable:!0})},R=(e,r,a,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of T(r))!d.call(e,n)&&n!==a&&c(e,n,{get:()=>r[n],enumerable:!(i=f(r,n))||i.enumerable});return e};var _=e=>R(c({},"__esModule",{value:!0}),e);var S={};p(S,{rc_boolean_autofix:()=>k,rc_number_autofix:()=>A,rc_string_autofix:()=>O});module.exports=_(S);function h(e){return{...this,a:e}}function s(e,r,a,i){if(e.c&&r===void 0)return[!0,r];if(e.u&&r==null)return[!0,r];if(e.l&&r===null)return[!0,r];let n=i();if(n&&(n===!0||"data"in n)){let t=n===!0?r:n.data;return e.t&&!e.t(t)?[!1,[e.n(t)]]:[!0,t]}if(e.a!==void 0)return a.warnings.push(`Fallback used, ${e.n(r)}`),[!0,e.a];if(e.y&&e.i){let t=e.i(r);if(t)return e.t&&!e.t(t.fixed)?[!1,[e.n(t.fixed)]]:(a.warnings.push(`Autofixed from, ${e.n(r)}`),[!0,t.fixed])}return[!1,n&&"errors"in n?n.errors:[e.n(r)]]}function x(e){return{...this,y:!0,i:e}}function b(e){return{...this,t:e,e:`${this.e}_with_predicate`}}function g(){return{...this,c:!0}}function w(e){return`Type '${j(e)}' is not assignable to '${this.e}'`}function m(){return{...this,l:!0,e:`${this.e}_or_nullable`}}function $(){return{...this,u:!0,e:`${this.e}_or_nullish`}}var o={withFallback:h,where:b,optional:g,n:w,nullable:m,withAutofix:x,nullish:$},P={...o,r(e,r){return s(this,e,r,()=>e===void 0)},e:"undefined"},V={...o,r(e,r){return s(this,e,r,()=>e===null)},e:"null"},q={...o,r(e,r){return s(this,e,r,()=>!0)},e:"any"},E={...o,r(e,r){return s(this,e,r,()=>!0)},e:"unknown"},u={...o,r(e,r){return s(this,e,r,()=>typeof e=="boolean")},e:"boolean"},l={...o,r(e,r){return s(this,e,r,()=>typeof e=="string")},e:"string"},y={...o,r(e,r){return s(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},I={...o,r(e,r){return s(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function j(e){if(typeof e=="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return typeof e}var k=u.withAutofix(e=>e==null||e===0||e===1?{fixed:!!e}:e==="true"||e==="false"?{fixed:e==="true"}:!1),O=l.withAutofix(e=>typeof e=="number"&&!Number.isNaN(e)?{fixed:e.toString()}:!1),A=y.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{e as f,f as t,g as o}from"./chunk-FAF7WEYO.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{e as f,f as t,g as o}from"./chunk-SYJIFZCW.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 +1 @@
1
- function k(e){return{...this,a:e}}function i(e,r,n,t){if(e.c&&r===void 0)return[!0,r];if(e.u&&r==null)return[!0,r];if(e.l&&r===null)return[!0,r];let a=t();if(a&&(a===!0||"data"in a)){let s=a===!0?r:a.data;return e.t&&!e.t(s)?[!1,[e.n(s)]]:[!0,s]}if(e.a!==void 0)return n.warnings.push(`Fallback used, ${e.n(r)}`),[!0,e.a];if(e.y&&e.i){let s=e.i(r);if(s)return e.t&&!e.t(s.fixed)?[!1,[e.n(s.fixed)]]:(n.warnings.push(`Autofixed from, ${e.n(r)}`),[!0,s.fixed])}return[!1,a&&"errors"in a?a.errors:[e.n(r)]]}function O(e){return{...this,y:!0,i:e}}function m(e){return{...this,t:e,e:`${this.e}_with_predicate`}}function A(){return{...this,c:!0}}function S(e){return`Type '${j(e)}' is not assignable to '${this.e}'`}function P(){return{...this,l:!0,e:`${this.e}_or_nullable`}}function V(){return{...this,u:!0,e:`${this.e}_or_nullish`}}var o={withFallback:k,where:m,optional:A,n:S,nullable:P,withAutofix:O,nullish:V},E={...o,r(e,r){return i(this,e,r,()=>e===void 0)},e:"undefined"},I={...o,r(e,r){return i(this,e,r,()=>e===null)},e:"null"},N={...o,r(e,r){return i(this,e,r,()=>!0)},e:"any"},v={...o,r(e,r){return i(this,e,r,()=>!0)},e:"unknown"},K={...o,r(e,r){return i(this,e,r,()=>typeof e=="boolean")},e:"boolean"},F={...o,r(e,r){return i(this,e,r,()=>typeof e=="string")},e:"string"},C={...o,r(e,r){return i(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},U={...o,r(e,r){return i(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function z(e){return{...o,r(r,n){return i(this,r,n,()=>r instanceof e)},e:`instanceof_${e.name?`_${e.name}`:""}`}}function B(...e){if(e.length===0)throw new Error("rc_literal requires at least one literal");return{...o,r(r,n){return i(this,r,n,()=>{for(let t of e)if(r===t)return!0;return!1})},e:e.length==1?`${j(e[0])}_literal`:"literals"}}function D(...e){if(e.length===0)throw new Error("Unions should have at least one type");return{...o,r(r,n){return i(this,r,n,()=>{for(let t of e)if(t.r(r,n)[0])return!0;return!1})},e:e.map(r=>r.e).join(" | ")}}function M(e,r){return{...r,o:e}}function p(e,r){if(e.startsWith("$[")||e.startsWith("$.")){let[n="",t]=e.split(": "),a=n.slice(1);return`$${r}${a}: ${t}`}return`$${r}: ${e}`}function g(e){return{...o,s:e,e:"object",f:!0,r(r,n){return i(this,r,n,()=>{if(!$(r))return!1;let t=new Set(Object.keys(r)),a={},s=[];for(let[c,l]of Object.entries(e)){let d=c,u,y=c;l.o?(u=r[l.o],y=l.o,u===void 0&&(u=r[c],y=c)):u=r[c],t.delete(y);let[f,R]=l.r(u,n);if(f)a[d]=R;else{let h=R;for(let T of h)s.push(p(T,`.${c}`))}}if(this.e==="strict_obj"&&t.size>0)for(let c of t)s.push(`Key '${c}' is not defined in the object shape`);return s.length>0?{errors:s}:{data:a}})}}}function W(e){return{...g(e),e:"strict_obj"}}function G(e,r){return g({...e.s,...r.s})}function H(e){return{...o,e:`record<string, ${e.e}>`,r(r,n){return i(this,r,n,()=>{if(!$(r))return!1;let t={},a=[];for(let[s,c]of Object.entries(r)){let l=r[s],[d,u]=e.r(c,n);if(d)t[s]=l;else{let y=u;for(let f of y)a.push(p(f,`.${s}`))}}return a.length>0?{errors:a}:{data:t}})}}}function x(e,r){if(typeof r=="string"&&!e.s?.[r])throw new Error(`${e.e} can't be used with unique key option`)}function _(e,r,n,t=!1,a){let s=-1,c=[],l=new Set;for(let d of e){s++;let u=Array.isArray(r)?r[s]:r,y=u.r(d,n),f=a?.unique;if(y[0]&&f){let T=d,b=typeof f=="string";b&&(T=d[f]),l.has(T)?y=[!1,[b?p(`${u.s?.[f]?.e} value is not unique`,`.${f}`):`${u.e} value is not unique`]]:l.add(T)}let[R,h]=y;if(R)t&&c.push(d);else if(t){n.warnings.push(...h.map(T=>p(T,`[${s}]`)));continue}else return{errors:h.map(T=>p(T,`[${s}]`))}}return t?{data:c}:!0}function J(e,r){return x(e,r?.unique),{...o,e:`${e.e}[]`,r(n,t){return i(this,n,t,()=>Array.isArray(n)?n.length===0?!0:_.call(this,n,e,t,!1,r):!1)}}}function L(e,r){return x(e,r?.unique),{...o,e:`${e.e}[]`,r(n,t){return i(this,n,t,()=>Array.isArray(n)?n.length===0?!0:_.call(this,n,e,t,!0,r):!1)}}}function Q(e){return{...o,e:`[${e.map(r=>r.e).join(", ")}]`,r(r,n){return i(this,r,n,()=>!Array.isArray(r)||r.length!==e.length?!1:_.call(this,r,e,n))}}}function w(e,r){let n={warnings:[]},[t,a]=r.r(e,n);return t?{error:!1,data:a,warnings:n.warnings.length>0?n.warnings:!1}:{error:!0,errors:a}}function X(e){return r=>w(r,e)}function Y(e,r){let n=w(e,r);return n.error?{data:null,errors:n.errors,warnings:!1}:{data:n.data,errors:!1,warnings:n.warnings}}function q(e,r){let n={warnings:[]};return!!r.r(e,n)[0]}function Z(e){return r=>q(r,e)}function ee(e){return{...o,e:"recursive",r(r,n){return e().r(r,n)}}}function re(e,r){return{...o,e:e.e,r(n,t){let[a,s]=e.r(n,t);return a?[!0,r(s)]:[!1,s]}}}function j(e){if(typeof e=="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return typeof e}function $(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}export{E as a,I as b,N as c,v as d,K as e,F as f,C as g,U as h,z as i,B as j,D as k,M as l,g as m,W as n,G as o,H as p,J as q,L as r,Q as s,w as t,X as u,Y as v,q as w,Z as x,ee as y,re as z};
1
+ function k(e){return{...this,a:e}}function i(e,r,n,t){if(e.c&&r===void 0)return[!0,r];if(e.u&&r==null)return[!0,r];if(e.l&&r===null)return[!0,r];let a=t();if(a&&(a===!0||"data"in a)){let s=a===!0?r:a.data;return e.t&&!e.t(s)?[!1,[e.n(s)]]:[!0,s]}if(e.a!==void 0)return n.warnings.push(`Fallback used, ${e.n(r)}`),[!0,e.a];if(e.y&&e.i){let s=e.i(r);if(s)return e.t&&!e.t(s.fixed)?[!1,[e.n(s.fixed)]]:(n.warnings.push(`Autofixed from, ${e.n(r)}`),[!0,s.fixed])}return[!1,a&&"errors"in a?a.errors:[e.n(r)]]}function O(e){return{...this,y:!0,i:e}}function m(e){return{...this,t:e,e:`${this.e}_with_predicate`}}function A(){return{...this,c:!0}}function S(e){return`Type '${$(e)}' is not assignable to '${this.e}'`}function P(){return{...this,l:!0,e:`${this.e}_or_nullable`}}function V(){return{...this,u:!0,e:`${this.e}_or_nullish`}}var o={withFallback:k,where:m,optional:A,n:S,nullable:P,withAutofix:O,nullish:V},E={...o,r(e,r){return i(this,e,r,()=>e===void 0)},e:"undefined"},I={...o,r(e,r){return i(this,e,r,()=>e===null)},e:"null"},N={...o,r(e,r){return i(this,e,r,()=>!0)},e:"any"},v={...o,r(e,r){return i(this,e,r,()=>!0)},e:"unknown"},K={...o,r(e,r){return i(this,e,r,()=>typeof e=="boolean")},e:"boolean"},F={...o,r(e,r){return i(this,e,r,()=>typeof e=="string")},e:"string"},C={...o,r(e,r){return i(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},U={...o,r(e,r){return i(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function z(e){return{...o,r(r,n){return i(this,r,n,()=>r instanceof e)},e:`instanceof_${e.name?`_${e.name}`:""}`}}function B(...e){if(e.length===0)throw new Error("rc_literal requires at least one literal");return{...o,r(r,n){return i(this,r,n,()=>{for(let t of e)if(r===t)return!0;return!1})},e:e.length==1?`${$(e[0])}_literal`:"literals"}}function D(...e){if(e.length===0)throw new Error("Unions should have at least one type");return{...o,r(r,n){return i(this,r,n,()=>{for(let t of e)if(t.r(r,n)[0])return!0;return!1})},e:e.map(r=>r.e).join(" | ")}}function M(e,r){return{...r,o:e}}function p(e,r){if(e.startsWith("$[")||e.startsWith("$.")){let[n="",t]=e.split(": "),a=n.slice(1);return`$${r}${a}: ${t}`}return`$${r}: ${e}`}function g(e){return{...o,s:e,e:"object",f:!0,r(r,n){return i(this,r,n,()=>{if(!j(r))return!1;let t=new Set(Object.keys(r)),a={},s=[];for(let[c,y]of Object.entries(e)){let d=c,u,f=c;y.o?(u=r[y.o],f=y.o,u===void 0&&(u=r[c],f=c)):u=r[c],t.delete(f);let[T,R]=y.r(u,n);if(T)a[d]=R;else{let h=R;for(let l of h)s.push(p(l,`.${c}`))}}if(this.e==="strict_obj"&&t.size>0)for(let c of t)s.push(`Key '${c}' is not defined in the object shape`);return s.length>0?{errors:s}:{data:a}})}}}function W(e){return{...g(e),e:"strict_obj"}}function G(e,r){return g({...e.s,...r.s})}function H(e){return{...o,e:`record<string, ${e.e}>`,r(r,n){return i(this,r,n,()=>{if(!j(r))return!1;let t={},a=[];for(let[s,c]of Object.entries(r)){let y=r[s],[d,u]=e.r(c,n);if(d)t[s]=y;else{let f=u;for(let T of f)a.push(p(T,`.${s}`))}}return a.length>0?{errors:a}:{data:t}})}}}function x(e,r){if(typeof r=="string"&&!e.s?.[r])throw new Error(`${e.e} can't be used with unique key option`)}function _(e,r,n,t=!1,a){let s=-1,c=[],y=new Set;for(let d of e){s++;let u=Array.isArray(r)?r[s]:r,f=u.r(d,n),T=a?.unique;if(f[0]&&T){let l=d,b=typeof T=="string";b&&(l=d[T]),y.has(l)?f=[!1,[b?p(`Type '${u.s?.[T]?.e}' with value "${l}" is not unique`,`.${T}`):`${u.e} value is not unique`]]:y.add(l)}let[R,h]=f;if(R)t&&c.push(d);else if(t){n.warnings.push(...h.map(l=>p(l,`[${s}]`)));continue}else return{errors:h.map(l=>p(l,`[${s}]`))}}return t?{data:c}:!0}function J(e,r){return x(e,r?.unique),{...o,e:`${e.e}[]`,r(n,t){return i(this,n,t,()=>Array.isArray(n)?n.length===0?!0:_.call(this,n,e,t,!1,r):!1)}}}function L(e,r){return x(e,r?.unique),{...o,e:`${e.e}[]`,r(n,t){return i(this,n,t,()=>Array.isArray(n)?n.length===0?!0:_.call(this,n,e,t,!0,r):!1)}}}function Q(e){return{...o,e:`[${e.map(r=>r.e).join(", ")}]`,r(r,n){return i(this,r,n,()=>!Array.isArray(r)||r.length!==e.length?!1:_.call(this,r,e,n))}}}function w(e,r){let n={warnings:[]},[t,a]=r.r(e,n);return t?{error:!1,data:a,warnings:n.warnings.length>0?n.warnings:!1}:{error:!0,errors:a}}function X(e){return r=>w(r,e)}function Y(e,r){let n=w(e,r);return n.error?{data:null,errors:n.errors,warnings:!1}:{data:n.data,errors:!1,warnings:n.warnings}}function q(e,r){let n={warnings:[]};return!!r.r(e,n)[0]}function Z(e){return r=>q(r,e)}function ee(e){return{...o,e:"recursive",r(r,n){return e().r(r,n)}}}function re(e,r){return{...o,e:e.e,r(n,t){let[a,s]=e.r(n,t);return a?[!0,r(s)]:[!1,s]}}}function $(e){if(typeof e=="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return typeof e}function j(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}export{E as a,I as b,N as c,v as d,K as e,F as f,C as g,U as h,z as i,B as j,D as k,M as l,g as m,W as n,G as o,H as p,J as q,L as r,Q as s,w as t,X as u,Y as v,q as w,Z as x,ee as y,re as z};
package/dist/runcheck.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var _=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var P=(e,r)=>{for(var n in r)_(e,n,{get:r[n],enumerable:!0})},V=(e,r,n,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of A(r))!S.call(e,s)&&s!==n&&_(e,s,{get:()=>r[s],enumerable:!(t=m(r,s))||t.enumerable});return e};var q=e=>V(_({},"__esModule",{value:!0}),e);var ue={};P(ue,{rc_any:()=>B,rc_array:()=>re,rc_boolean:()=>M,rc_date:()=>H,rc_instanceof:()=>J,rc_is_valid:()=>$,rc_literals:()=>L,rc_loose_array:()=>ne,rc_loose_parse:()=>ae,rc_null:()=>z,rc_number:()=>G,rc_obj_intersection:()=>Z,rc_object:()=>b,rc_parse:()=>x,rc_parser:()=>se,rc_record:()=>ee,rc_recursive:()=>ie,rc_rename_key:()=>X,rc_strict_obj:()=>Y,rc_string:()=>W,rc_transform:()=>ce,rc_tuple:()=>te,rc_undefined:()=>U,rc_union:()=>Q,rc_unknown:()=>D,rc_validator:()=>oe});module.exports=q(ue);function E(e){return{...this,o:e}}function i(e,r,n,t){if(e.c&&r===void 0)return[!0,r];if(e.u&&r==null)return[!0,r];if(e.l&&r===null)return[!0,r];let s=t();if(s&&(s===!0||"data"in s)){let a=s===!0?r:s.data;return e.t&&!e.t(a)?[!1,[e.n(a)]]:[!0,a]}if(e.o!==void 0)return n.warnings.push(`Fallback used, ${e.n(r)}`),[!0,e.o];if(e.y&&e.i){let a=e.i(r);if(a)return e.t&&!e.t(a.fixed)?[!1,[e.n(a.fixed)]]:(n.warnings.push(`Autofixed from, ${e.n(r)}`),[!0,a.fixed])}return[!1,s&&"errors"in s?s.errors:[e.n(r)]]}function I(e){return{...this,y:!0,i:e}}function N(e){return{...this,t:e,e:`${this.e}_with_predicate`}}function v(){return{...this,c:!0}}function K(e){return`Type '${k(e)}' is not assignable to '${this.e}'`}function F(){return{...this,l:!0,e:`${this.e}_or_nullable`}}function C(){return{...this,u:!0,e:`${this.e}_or_nullish`}}var o={withFallback:E,where:N,optional:v,n:K,nullable:F,withAutofix:I,nullish:C},U={...o,r(e,r){return i(this,e,r,()=>e===void 0)},e:"undefined"},z={...o,r(e,r){return i(this,e,r,()=>e===null)},e:"null"},B={...o,r(e,r){return i(this,e,r,()=>!0)},e:"any"},D={...o,r(e,r){return i(this,e,r,()=>!0)},e:"unknown"},M={...o,r(e,r){return i(this,e,r,()=>typeof e=="boolean")},e:"boolean"},W={...o,r(e,r){return i(this,e,r,()=>typeof e=="string")},e:"string"},G={...o,r(e,r){return i(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},H={...o,r(e,r){return i(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function J(e){return{...o,r(r,n){return i(this,r,n,()=>r instanceof e)},e:`instanceof_${e.name?`_${e.name}`:""}`}}function L(...e){if(e.length===0)throw new Error("rc_literal requires at least one literal");return{...o,r(r,n){return i(this,r,n,()=>{for(let t of e)if(r===t)return!0;return!1})},e:e.length==1?`${k(e[0])}_literal`:"literals"}}function Q(...e){if(e.length===0)throw new Error("Unions should have at least one type");return{...o,r(r,n){return i(this,r,n,()=>{for(let t of e)if(t.r(r,n)[0])return!0;return!1})},e:e.map(r=>r.e).join(" | ")}}function X(e,r){return{...r,a:e}}function p(e,r){if(e.startsWith("$[")||e.startsWith("$.")){let[n="",t]=e.split(": "),s=n.slice(1);return`$${r}${s}: ${t}`}return`$${r}: ${e}`}function b(e){return{...o,s:e,e:"object",f:!0,r(r,n){return i(this,r,n,()=>{if(!O(r))return!1;let t=new Set(Object.keys(r)),s={},a=[];for(let[c,l]of Object.entries(e)){let d=c,u,y=c;l.a?(u=r[l.a],y=l.a,u===void 0&&(u=r[c],y=c)):u=r[c],t.delete(y);let[f,R]=l.r(u,n);if(f)s[d]=R;else{let h=R;for(let T of h)a.push(p(T,`.${c}`))}}if(this.e==="strict_obj"&&t.size>0)for(let c of t)a.push(`Key '${c}' is not defined in the object shape`);return a.length>0?{errors:a}:{data:s}})}}}function Y(e){return{...b(e),e:"strict_obj"}}function Z(e,r){return b({...e.s,...r.s})}function ee(e){return{...o,e:`record<string, ${e.e}>`,r(r,n){return i(this,r,n,()=>{if(!O(r))return!1;let t={},s=[];for(let[a,c]of Object.entries(r)){let l=r[a],[d,u]=e.r(c,n);if(d)t[a]=l;else{let y=u;for(let f of y)s.push(p(f,`.${a}`))}}return s.length>0?{errors:s}:{data:t}})}}}function j(e,r){if(typeof r=="string"&&!e.s?.[r])throw new Error(`${e.e} can't be used with unique key option`)}function g(e,r,n,t=!1,s){let a=-1,c=[],l=new Set;for(let d of e){a++;let u=Array.isArray(r)?r[a]:r,y=u.r(d,n),f=s?.unique;if(y[0]&&f){let T=d,w=typeof f=="string";w&&(T=d[f]),l.has(T)?y=[!1,[w?p(`${u.s?.[f]?.e} value is not unique`,`.${f}`):`${u.e} value is not unique`]]:l.add(T)}let[R,h]=y;if(R)t&&c.push(d);else if(t){n.warnings.push(...h.map(T=>p(T,`[${a}]`)));continue}else return{errors:h.map(T=>p(T,`[${a}]`))}}return t?{data:c}:!0}function re(e,r){return j(e,r?.unique),{...o,e:`${e.e}[]`,r(n,t){return i(this,n,t,()=>Array.isArray(n)?n.length===0?!0:g.call(this,n,e,t,!1,r):!1)}}}function ne(e,r){return j(e,r?.unique),{...o,e:`${e.e}[]`,r(n,t){return i(this,n,t,()=>Array.isArray(n)?n.length===0?!0:g.call(this,n,e,t,!0,r):!1)}}}function te(e){return{...o,e:`[${e.map(r=>r.e).join(", ")}]`,r(r,n){return i(this,r,n,()=>!Array.isArray(r)||r.length!==e.length?!1:g.call(this,r,e,n))}}}function x(e,r){let n={warnings:[]},[t,s]=r.r(e,n);return t?{error:!1,data:s,warnings:n.warnings.length>0?n.warnings:!1}:{error:!0,errors:s}}function se(e){return r=>x(r,e)}function ae(e,r){let n=x(e,r);return n.error?{data:null,errors:n.errors,warnings:!1}:{data:n.data,errors:!1,warnings:n.warnings}}function $(e,r){let n={warnings:[]};return!!r.r(e,n)[0]}function oe(e){return r=>$(r,e)}function ie(e){return{...o,e:"recursive",r(r,n){return e().r(r,n)}}}function ce(e,r){return{...o,e:e.e,r(n,t){let[s,a]=e.r(n,t);return s?[!0,r(a)]:[!1,a]}}}function k(e){if(typeof e=="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return typeof e}function O(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}0&&(module.exports={rc_any,rc_array,rc_boolean,rc_date,rc_instanceof,rc_is_valid,rc_literals,rc_loose_array,rc_loose_parse,rc_null,rc_number,rc_obj_intersection,rc_object,rc_parse,rc_parser,rc_record,rc_recursive,rc_rename_key,rc_strict_obj,rc_string,rc_transform,rc_tuple,rc_undefined,rc_union,rc_unknown,rc_validator});
1
+ "use strict";var _=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var P=(e,r)=>{for(var n in r)_(e,n,{get:r[n],enumerable:!0})},V=(e,r,n,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of A(r))!S.call(e,s)&&s!==n&&_(e,s,{get:()=>r[s],enumerable:!(t=m(r,s))||t.enumerable});return e};var q=e=>V(_({},"__esModule",{value:!0}),e);var ue={};P(ue,{rc_any:()=>B,rc_array:()=>re,rc_boolean:()=>M,rc_date:()=>H,rc_instanceof:()=>J,rc_is_valid:()=>j,rc_literals:()=>L,rc_loose_array:()=>ne,rc_loose_parse:()=>ae,rc_null:()=>z,rc_number:()=>G,rc_obj_intersection:()=>Z,rc_object:()=>b,rc_parse:()=>x,rc_parser:()=>se,rc_record:()=>ee,rc_recursive:()=>ie,rc_rename_key:()=>X,rc_strict_obj:()=>Y,rc_string:()=>W,rc_transform:()=>ce,rc_tuple:()=>te,rc_undefined:()=>U,rc_union:()=>Q,rc_unknown:()=>D,rc_validator:()=>oe});module.exports=q(ue);function E(e){return{...this,o:e}}function i(e,r,n,t){if(e.c&&r===void 0)return[!0,r];if(e.u&&r==null)return[!0,r];if(e.l&&r===null)return[!0,r];let s=t();if(s&&(s===!0||"data"in s)){let a=s===!0?r:s.data;return e.t&&!e.t(a)?[!1,[e.n(a)]]:[!0,a]}if(e.o!==void 0)return n.warnings.push(`Fallback used, ${e.n(r)}`),[!0,e.o];if(e.y&&e.i){let a=e.i(r);if(a)return e.t&&!e.t(a.fixed)?[!1,[e.n(a.fixed)]]:(n.warnings.push(`Autofixed from, ${e.n(r)}`),[!0,a.fixed])}return[!1,s&&"errors"in s?s.errors:[e.n(r)]]}function I(e){return{...this,y:!0,i:e}}function N(e){return{...this,t:e,e:`${this.e}_with_predicate`}}function v(){return{...this,c:!0}}function K(e){return`Type '${k(e)}' is not assignable to '${this.e}'`}function F(){return{...this,l:!0,e:`${this.e}_or_nullable`}}function C(){return{...this,u:!0,e:`${this.e}_or_nullish`}}var o={withFallback:E,where:N,optional:v,n:K,nullable:F,withAutofix:I,nullish:C},U={...o,r(e,r){return i(this,e,r,()=>e===void 0)},e:"undefined"},z={...o,r(e,r){return i(this,e,r,()=>e===null)},e:"null"},B={...o,r(e,r){return i(this,e,r,()=>!0)},e:"any"},D={...o,r(e,r){return i(this,e,r,()=>!0)},e:"unknown"},M={...o,r(e,r){return i(this,e,r,()=>typeof e=="boolean")},e:"boolean"},W={...o,r(e,r){return i(this,e,r,()=>typeof e=="string")},e:"string"},G={...o,r(e,r){return i(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},H={...o,r(e,r){return i(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function J(e){return{...o,r(r,n){return i(this,r,n,()=>r instanceof e)},e:`instanceof_${e.name?`_${e.name}`:""}`}}function L(...e){if(e.length===0)throw new Error("rc_literal requires at least one literal");return{...o,r(r,n){return i(this,r,n,()=>{for(let t of e)if(r===t)return!0;return!1})},e:e.length==1?`${k(e[0])}_literal`:"literals"}}function Q(...e){if(e.length===0)throw new Error("Unions should have at least one type");return{...o,r(r,n){return i(this,r,n,()=>{for(let t of e)if(t.r(r,n)[0])return!0;return!1})},e:e.map(r=>r.e).join(" | ")}}function X(e,r){return{...r,a:e}}function p(e,r){if(e.startsWith("$[")||e.startsWith("$.")){let[n="",t]=e.split(": "),s=n.slice(1);return`$${r}${s}: ${t}`}return`$${r}: ${e}`}function b(e){return{...o,s:e,e:"object",f:!0,r(r,n){return i(this,r,n,()=>{if(!O(r))return!1;let t=new Set(Object.keys(r)),s={},a=[];for(let[c,y]of Object.entries(e)){let d=c,u,f=c;y.a?(u=r[y.a],f=y.a,u===void 0&&(u=r[c],f=c)):u=r[c],t.delete(f);let[T,R]=y.r(u,n);if(T)s[d]=R;else{let h=R;for(let l of h)a.push(p(l,`.${c}`))}}if(this.e==="strict_obj"&&t.size>0)for(let c of t)a.push(`Key '${c}' is not defined in the object shape`);return a.length>0?{errors:a}:{data:s}})}}}function Y(e){return{...b(e),e:"strict_obj"}}function Z(e,r){return b({...e.s,...r.s})}function ee(e){return{...o,e:`record<string, ${e.e}>`,r(r,n){return i(this,r,n,()=>{if(!O(r))return!1;let t={},s=[];for(let[a,c]of Object.entries(r)){let y=r[a],[d,u]=e.r(c,n);if(d)t[a]=y;else{let f=u;for(let T of f)s.push(p(T,`.${a}`))}}return s.length>0?{errors:s}:{data:t}})}}}function $(e,r){if(typeof r=="string"&&!e.s?.[r])throw new Error(`${e.e} can't be used with unique key option`)}function g(e,r,n,t=!1,s){let a=-1,c=[],y=new Set;for(let d of e){a++;let u=Array.isArray(r)?r[a]:r,f=u.r(d,n),T=s?.unique;if(f[0]&&T){let l=d,w=typeof T=="string";w&&(l=d[T]),y.has(l)?f=[!1,[w?p(`Type '${u.s?.[T]?.e}' with value "${l}" is not unique`,`.${T}`):`${u.e} value is not unique`]]:y.add(l)}let[R,h]=f;if(R)t&&c.push(d);else if(t){n.warnings.push(...h.map(l=>p(l,`[${a}]`)));continue}else return{errors:h.map(l=>p(l,`[${a}]`))}}return t?{data:c}:!0}function re(e,r){return $(e,r?.unique),{...o,e:`${e.e}[]`,r(n,t){return i(this,n,t,()=>Array.isArray(n)?n.length===0?!0:g.call(this,n,e,t,!1,r):!1)}}}function ne(e,r){return $(e,r?.unique),{...o,e:`${e.e}[]`,r(n,t){return i(this,n,t,()=>Array.isArray(n)?n.length===0?!0:g.call(this,n,e,t,!0,r):!1)}}}function te(e){return{...o,e:`[${e.map(r=>r.e).join(", ")}]`,r(r,n){return i(this,r,n,()=>!Array.isArray(r)||r.length!==e.length?!1:g.call(this,r,e,n))}}}function x(e,r){let n={warnings:[]},[t,s]=r.r(e,n);return t?{error:!1,data:s,warnings:n.warnings.length>0?n.warnings:!1}:{error:!0,errors:s}}function se(e){return r=>x(r,e)}function ae(e,r){let n=x(e,r);return n.error?{data:null,errors:n.errors,warnings:!1}:{data:n.data,errors:!1,warnings:n.warnings}}function j(e,r){let n={warnings:[]};return!!r.r(e,n)[0]}function oe(e){return r=>j(r,e)}function ie(e){return{...o,e:"recursive",r(r,n){return e().r(r,n)}}}function ce(e,r){return{...o,e:e.e,r(n,t){let[s,a]=e.r(n,t);return s?[!0,r(a)]:[!1,a]}}}function k(e){if(typeof e=="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return typeof e}function O(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}0&&(module.exports={rc_any,rc_array,rc_boolean,rc_date,rc_instanceof,rc_is_valid,rc_literals,rc_loose_array,rc_loose_parse,rc_null,rc_number,rc_obj_intersection,rc_object,rc_parse,rc_parser,rc_record,rc_recursive,rc_rename_key,rc_strict_obj,rc_string,rc_transform,rc_tuple,rc_undefined,rc_union,rc_unknown,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,y,z}from"./chunk-FAF7WEYO.js";export{c as rc_any,q as rc_array,e as rc_boolean,h as rc_date,i as rc_instanceof,w as rc_is_valid,j as rc_literals,r as rc_loose_array,v as rc_loose_parse,b as rc_null,g as rc_number,o as rc_obj_intersection,m as rc_object,t as rc_parse,u as rc_parser,p as rc_record,y as rc_recursive,l as rc_rename_key,n as rc_strict_obj,f as rc_string,z as rc_transform,s as rc_tuple,a as rc_undefined,k as rc_union,d as rc_unknown,x as rc_validator};
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,y,z}from"./chunk-SYJIFZCW.js";export{c as rc_any,q as rc_array,e as rc_boolean,h as rc_date,i as rc_instanceof,w as rc_is_valid,j as rc_literals,r as rc_loose_array,v as rc_loose_parse,b as rc_null,g as rc_number,o as rc_obj_intersection,m as rc_object,t as rc_parse,u as rc_parser,p as rc_record,y as rc_recursive,l as rc_rename_key,n as rc_strict_obj,f as rc_string,z as rc_transform,s as rc_tuple,a as rc_undefined,k as rc_union,d as rc_unknown,x as rc_validator};
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.13.0",
4
+ "version": "0.14.0",
5
5
  "license": "MIT",
6
6
  "scripts": {
7
7
  "test": "vitest --ui",