runcheck 0.34.3 → 0.34.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/autofixable.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var u=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var h=(e,r)=>{for(var n in r)u(e,n,{get:r[n],enumerable:!0})},_=(e,r,n,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of R(r))!b.call(e,t)&&t!==n&&u(e,t,{get:()=>r[t],enumerable:!(a=p(r,t))||a.enumerable});return e};var j=e=>_(u({},"__esModule",{value:!0}),e);var C={};h(C,{rc_boolean_autofix:()=>K,rc_number_autofix:()=>I,rc_string_autofix:()=>A});module.exports=j(C);function x(e){return{...this,i:e}}function g(e,r){return r.startsWith("$[")||r.startsWith("$.")?r:`${e.path?`$${e.path}: `:""}${r}`}function y(e,r){e.warnings.push(g(e,r))}function o(e,r,n,a){if(e.c&&r===void 0)return[!0,r];if(e.u&&r==null)return[!0,r];if(e.y&&r===null)return[!0,r];let t=a();if(t&&(t===!0||!t.errors)){let i=t===!0?r:t.data;return e.t&&!e.t(i)?[!1,[`Predicate failed for type '${e.e}'`]]:[!0,i]}let c=e.i;if(c!==void 0)return y(n,`Fallback used, errors -> ${f(t,n,e,r)}`),[!0,P(c)?c():c];if(e.f&&e.s){let i=e.s(r);if(i)return e.t&&!e.t(i.fixed)?[!1,[`Predicate failed for autofix in type '${e.e}'`]]:(y(n,`Autofixed from error "${f(t,n,e,r)}"`),[!0,i.fixed])}return[!1,t?t.errors:[e.l(r)]]}function f(e,r,n,a){return e?e.errors.map(t=>t.replace(r.path,"")).join("; "):n.l(a)}function O(e){return{...this,f:!0,s:e}}function k(e){return{...this,t:e}}function m(){return{...this,c:!0}}function w(e){return`Type '${E(e,!!this.T)}' is not assignable to '${this.e}'`}function $(){return{...this,y:!0,e:`${this.e}_or_null`}}function S(){return{...this,u:!0,e:`${this.e}_or_nullish`}}var s={withFallback:x,where:k,optional:m,l:w,orNullish:S,withAutofix:O,orNull:$,i:void 0,t:void 0,c:!1,y:!1,u:!1,f:!1,T:!1,o:void 0,s:void 0,R:void 0,n:void 0,a:!1,d:!1,p:[]},
|
|
1
|
+
"use strict";var u=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var h=(e,r)=>{for(var n in r)u(e,n,{get:r[n],enumerable:!0})},_=(e,r,n,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of R(r))!b.call(e,t)&&t!==n&&u(e,t,{get:()=>r[t],enumerable:!(a=p(r,t))||a.enumerable});return e};var j=e=>_(u({},"__esModule",{value:!0}),e);var C={};h(C,{rc_boolean_autofix:()=>K,rc_number_autofix:()=>I,rc_string_autofix:()=>A});module.exports=j(C);function x(e){return{...this,i:e}}function g(e,r){return r.startsWith("$[")||r.startsWith("$.")?r:`${e.path?`$${e.path}: `:""}${r}`}function y(e,r){e.warnings.push(g(e,r))}function o(e,r,n,a){if(e.c&&r===void 0)return[!0,r];if(e.u&&r==null)return[!0,r];if(e.y&&r===null)return[!0,r];let t=a();if(t&&(t===!0||!t.errors)){let i=t===!0?r:t.data;return e.t&&!e.t(i)?[!1,[`Predicate failed for type '${e.e}'`]]:[!0,i]}let c=e.i;if(c!==void 0)return y(n,`Fallback used, errors -> ${f(t,n,e,r)}`),[!0,P(c)?c():c];if(e.f&&e.s){let i=e.s(r);if(i)return e.t&&!e.t(i.fixed)?[!1,[`Predicate failed for autofix in type '${e.e}'`]]:(y(n,`Autofixed from error "${f(t,n,e,r)}"`),[!0,i.fixed])}return[!1,t?t.errors:[e.l(r)]]}function f(e,r,n,a){return e?e.errors.map(t=>t.replace(r.path,"")).join("; "):n.l(a)}function O(e){return{...this,f:!0,s:e}}function k(e){return{...this,t:e}}function m(){return{...this,c:!0}}function w(e){return`Type '${E(e,!!this.T)}' is not assignable to '${this.e}'`}function $(){return{...this,y:!0,e:`${this.e}_or_null`}}function S(){return{...this,u:!0,e:`${this.e}_or_nullish`}}var s={withFallback:x,where:k,optional:m,l:w,orNullish:S,withAutofix:O,orNull:$,i:void 0,t:void 0,c:!1,y:!1,u:!1,f:!1,T:!1,o:void 0,s:void 0,R:void 0,n:void 0,a:!1,d:!1,p:[]},v={...s,r(e,r){return o(this,e,r,()=>e===void 0)},e:"undefined"},V={...s,r(e,r){return o(this,e,r,()=>e===null)},e:"null"},q={...s,r(e,r){return o(this,e,r,()=>!0)},e:"any"},B={...s,r(e,r){return o(this,e,r,()=>!0)},e:"unknown"},l={...s,r(e,r){return o(this,e,r,()=>typeof e=="boolean")},e:"boolean"},T={...s,r(e,r){return o(this,e,r,()=>typeof e=="string")},e:"string"},d={...s,r(e,r){return o(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},F={...s,r(e,r){return o(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function E(e,r){let n=(()=>{if(typeof e=="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return typeof e})();return r&&(n==="string"||n==="number"||n==="boolean")?`${n}(${e})`:n}function P(e){return typeof e=="function"}var K=l.withAutofix(e=>e==null||e===0||e===1?{fixed:!!e}:e==="true"||e==="false"?{fixed:e==="true"}:!1),A=T.withAutofix(e=>typeof e=="number"&&!Number.isNaN(e)?{fixed:e.toString()}:!1),I=d.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});
|
package/dist/autofixable.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as f,f as t,g as o}from"./chunk-
|
|
1
|
+
import{e as f,f as t,g as o}from"./chunk-CENEI7TU.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 q(e){return{...this,i:e}}function _(e,r){return r.startsWith("$[")||r.startsWith("$.")?r:`${e.path?`$${e.path}: `:""}${r}`}function $(e,r){e.warnings.push(_(e,r))}function A(e,r){r.forEach(n=>$(e,n))}function u(e,r,n,o){if(e.c&&r===void 0)return[!0,r];if(e.u&&r==null)return[!0,r];if(e.y&&r===null)return[!0,r];let t=o();if(t&&(t===!0||!t.errors)){let a=t===!0?r:t.data;return e.t&&!e.t(a)?[!1,[`Predicate failed for type '${e.e}'`]]:[!0,a]}let s=e.i;if(s!==void 0)return $(n,`Fallback used, errors -> ${K(t,n,e,r)}`),[!0,G(s)?s():s];if(e.f&&e.s){let a=e.s(r);if(a)return e.t&&!e.t(a.fixed)?[!1,[`Predicate failed for autofix in type '${e.e}'`]]:($(n,`Autofixed from error "${K(t,n,e,r)}"`),[!0,a.fixed])}return[!1,t?t.errors:[e.l(r)]]}function K(e,r,n,o){return e?e.errors.map(t=>t.replace(r.path,"")).join("; "):n.l(o)}function N(e){return{...this,f:!0,s:e}}function B(e){return{...this,t:e}}function F(){return{...this,c:!0}}function W(e){return`Type '${
|
|
1
|
+
function q(e){return{...this,i:e}}function _(e,r){return r.startsWith("$[")||r.startsWith("$.")?r:`${e.path?`$${e.path}: `:""}${r}`}function $(e,r){e.warnings.push(_(e,r))}function A(e,r){r.forEach(n=>$(e,n))}function u(e,r,n,o){if(e.c&&r===void 0)return[!0,r];if(e.u&&r==null)return[!0,r];if(e.y&&r===null)return[!0,r];let t=o();if(t&&(t===!0||!t.errors)){let a=t===!0?r:t.data;return e.t&&!e.t(a)?[!1,[`Predicate failed for type '${e.e}'`]]:[!0,a]}let s=e.i;if(s!==void 0)return $(n,`Fallback used, errors -> ${K(t,n,e,r)}`),[!0,G(s)?s():s];if(e.f&&e.s){let a=e.s(r);if(a)return e.t&&!e.t(a.fixed)?[!1,[`Predicate failed for autofix in type '${e.e}'`]]:($(n,`Autofixed from error "${K(t,n,e,r)}"`),[!0,a.fixed])}return[!1,t?t.errors:[e.l(r)]]}function K(e,r,n,o){return e?e.errors.map(t=>t.replace(r.path,"")).join("; "):n.l(o)}function N(e){return{...this,f:!0,s:e}}function B(e){return{...this,t:e}}function F(){return{...this,c:!0}}function W(e){return`Type '${S(e,!!this.T)}' is not assignable to '${this.e}'`}function D(){return{...this,y:!0,e:`${this.e}_or_null`}}function U(){return{...this,u:!0,e:`${this.e}_or_nullish`}}var i={withFallback:q,where:B,optional:F,l:W,orNullish:U,withAutofix:N,orNull:D,i:void 0,t:void 0,c:!1,y:!1,u:!1,f:!1,T:!1,o:void 0,s:void 0,R:void 0,n:void 0,a:!1,d:!1,p:[]},H={...i,r(e,r){return u(this,e,r,()=>e===void 0)},e:"undefined"},Q={...i,r(e,r){return u(this,e,r,()=>e===null)},e:"null"},X={...i,r(e,r){return u(this,e,r,()=>!0)},e:"any"},Y={...i,r(e,r){return u(this,e,r,()=>!0)},e:"unknown"},ee={...i,r(e,r){return u(this,e,r,()=>typeof e=="boolean")},e:"boolean"},re={...i,r(e,r){return u(this,e,r,()=>typeof e=="string")},e:"string"},ne={...i,r(e,r){return u(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},te={...i,r(e,r){return u(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function oe(e){return{...i,r(r,n){return u(this,r,n,()=>r instanceof e)},e:`instanceof_${e.name?`_${e.name}`:""}`}}function se(...e){if(e.length===0)throw new Error("rc_literal requires at least one literal");return{...i,r(r,n){return u(this,r,n,()=>{for(let o of e)if(r===o)return!0;return!1})},T:!0,e:e.length==1?S(e[0],!0):e.map(r=>S(r,!0)).join(" | ")}}var I=1;function ae(...e){if(e.length===0)throw new Error("Unions should have at least one type");return{...i,r(r,n){return u(this,r,n,()=>{let o=n.path,t=[],s=0,a=!1,y=[],f=0;for(let R of e){f+=1,R.a&&(n.path=`${o}|union ${f}|`),n.objErrShortCircuit=!0,n.objErrKeyIndex=0;let[c,T]=R.r(r,n);n.objErrShortCircuit=!1;let p=n.objErrKeyIndex;if(n.objErrKeyIndex=0,c)return!0;R.a&&p!==-1?p>0?y.push(...T):(s<I&&t.push(...T),s+=1):a=!0}return n.path=o,y.length>0||t.length>0?((s>I||a)&&t.push("not matches any other union member"),{errors:[...y,...t],data:void 0}):!1})},e:e.map(r=>r.e).join(" | ")}}function M(e,r){return{...r,o:e}}var ie=M;function z(e){return k(e)&&"_kind_"in e}function C(e){if(z(e))return e;if(k(e)){let r={};for(let[n,o]of Object.entries(e))r[n]=C(o);return j(r)}throw new Error(`invalid schema: ${e}`)}function j(e,{normalizeKeysFrom:r}={}){let n={};for(let[o,t]of Object.entries(e))n[o]=C(t);return{...i,n,e:"object",a:!0,p:Object.entries(n),r(o,t){return u(this,o,t,()=>{if(!k(o))return t.objErrKeyIndex=-1,!1;let s=this.e==="strict_obj"?new Set(Object.keys(o)):void 0,a={},y=[],f=t.path,R=-1;for(let[c,T]of this.p){let p=c;R+=1;let g=`.${c}`;t.path=`${f}${g}`;let d,b=c;if(T.o&&(d=o[T.o],b=T.o),d===void 0&&(d=o[c],b=c),d===void 0&&r==="snake_case"){let l=Z(c);d=o[l],b=l}s?.delete(b);let[O,x]=T.r(d,t);if(O)a[p]=x;else{for(let l of x)y.push(_(t,l));if(t.objErrShortCircuit){t.objErrKeyIndex=R;break}}}if(s&&s.size>0)for(let c of s)y.push(`Key '${c}' is not defined in the object shape`);return y.length>0?{errors:y,data:void 0}:this.d?{errors:!1,data:{...o,...a}}:{errors:!1,data:a}})}}}function ce(e){return{...j(e),e:"extends_object",d:!0}}function ue(e){return e.n}function ye(e){return{...j(e),e:"strict_obj"}}function fe(...e){let r={};for(let n of e)Object.assign(r,n.n);return j(r)}function le(e,r){let n={};if(!e.n)throw new Error("rc_obj_pick: obj must be an object type");for(let o of r){let t=e.n[o];t&&(n[o]=t)}return j(n)}function Te(e,r){let n={};if(!e.n)throw new Error("rc_obj_omit: obj must be an object type");for(let o of Object.keys(e.n))r.includes(o)||(n[o]=e.n[o]);return j(n)}function J(e,{checkKey:r,looseCheck:n}={}){return{...i,e:`record<string, ${e.e}>`,r(o,t){return u(this,o,t,()=>{if(!k(o))return!1;let s={},a=[],y=t.path;for(let[f,R]of Object.entries(o)){let c=`.${f}`,T=`${y}${c}`;if(t.path=T,r&&!r(f)){a.push(_(t,`Key '${f}' is not allowed`));continue}let p=o[f],[g,d]=e.r(R,t);if(g)s[f]=p;else{let b=d;for(let O of b)a.push(_(t,O));if(t.objErrShortCircuit)break}}if(a.length>0)if(n)A(t,a);else return{errors:a,data:void 0};return{errors:!1,data:s}})}}}function pe(e,{checkKey:r}={}){return J(e,{checkKey:r,looseCheck:!0})}function v(e,r){if(typeof r=="string"&&!e.n?.[r])throw new Error(`${e.e} can't be used with unique key option`)}function E(e,r,n,o=!1,t){let s=[],a=[],y=new Set,f=n.path,R=Array.isArray(r),c=-1;for(let T of e){c++;let p=R?r[c]:r,g=`[${c}]`,d=`${f}${g}`;n.path=d;let b=p.r(T,n),[O,x]=b;n.path=d;let l=t?.unique;if(O&&l){let h=x,m=typeof l=="string";m?h=x[l]:typeof l=="function"&&(h=l(x)),y.has(h)?(m&&(n.path=`${f}${g}.${l}`),b=[!1,[_(n,m?`Type '${p.n?.[l]?.e}' with value "${h}" is not unique`:typeof l=="function"?`Type '${p.e}' unique fn return with value "${h}" is not unique`:`${p.e} value is not unique`)]]):y.add(h)}let[V,w]=b;if(V)a.push(w);else if(o){s.push(w.map(h=>_(n,h)));continue}else return{errors:w.map(h=>_(n,h)),data:void 0}}if(s.length>0){if(a.length===0)return{errors:s.slice(0,5).flat(),data:void 0};A(n,s.flat())}return{errors:!1,data:a}}function de(e,r){return v(e,r?.unique),{...i,e:`${e.e}[]`,r(n,o){return u(this,n,o,()=>Array.isArray(n)?n.length===0?!0:E.call(this,n,e,o,!1,r):!1)}}}function Re(e,r){return v(e,r?.unique),{...i,e:`${e.e}[]`,r(n,o){return u(this,n,o,()=>Array.isArray(n)?n.length===0?!0:E.call(this,n,e,o,!0,r):!1)}}}function be(e){return{...i,e:`[${e.map(r=>r.e).join(", ")}]`,r(r,n){return u(this,r,n,()=>!Array.isArray(r)||r.length!==e.length?!1:E.call(this,r,e,n))}}}function P(e,r){let n={warnings:[],path:"",objErrShortCircuit:!1,objErrKeyIndex:0},[o,t]=r.r(e,n);return o?{error:!1,data:t,warnings:n.warnings.length>0?n.warnings:!1}:{error:!0,errors:t}}function he(e){return r=>P(r,e)}function _e(e,r){let n=P(e,r);return n.error?{data:null,errors:n.errors,warnings:!1}:{data:n.data,errors:!1,warnings:n.warnings}}function L(e,r){let n={warnings:[],path:"",objErrShortCircuit:!1,objErrKeyIndex:0};return!!r.r(e,n)[0]}function je(e){return r=>L(r,e)}function ge(e){return{...i,e:"recursive",r(r,n){return e().r(r,n)}}}function xe(e,r){return{...i,e:`transform_from_${e.e}`,r(n,o){let[t,s]=e.r(n,o);return t?[!0,r(s)]:[!1,s]}}}function S(e,r){let n=(()=>{if(typeof e=="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return typeof e})();return r&&(n==="string"||n==="number"||n==="boolean")?`${n}(${e})`:n}function Oe(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 Z(e){return e.replace(/\W+/g," ").split(/ |\B(?=[A-Z])/).map(r=>r.toLowerCase()).join("_")}function ke(e,r){try{let n=JSON.parse(e);return P(n,r)}catch(n){return{error:!0,errors:[`json parse error: ${k(n)?n.message:""}`]}}}function G(e){return typeof e=="function"}function we(){return e=>j(e)}export{H as a,Q as b,X as c,Y as d,ee as e,re as f,ne as g,te as h,oe as i,se as j,ae as k,M as l,ie as m,j as n,ce as o,ue as p,ye as q,fe as r,le as s,Te as t,J as u,pe as v,de as w,Re as x,be as y,P as z,he as A,_e as B,L as C,je as D,ge as E,xe as F,Oe as G,Z as H,ke as I,we as J};
|
package/dist/runcheck.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var S=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var z=(e,r)=>{for(var n in r)S(e,n,{get:r[n],enumerable:!0})},J=(e,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of U(r))!M.call(e,t)&&t!==n&&S(e,t,{get:()=>r[t],enumerable:!(o=D(r,t))||o.enumerable});return e};var L=e=>J(S({},"__esModule",{value:!0}),e);var Ae={};z(Ae,{rc_any:()=>te,rc_array:()=>ge,rc_assert_is_valid:()=>Ee,rc_boolean:()=>se,rc_date:()=>ce,rc_extends_obj:()=>pe,rc_get_obj_schema:()=>de,rc_instanceof:()=>ue,rc_is_valid:()=>B,rc_literals:()=>ye,rc_loose_array:()=>xe,rc_loose_parse:()=>we,rc_loose_record:()=>je,rc_null:()=>ne,rc_number:()=>ie,rc_obj_builder:()=>Ie,rc_obj_intersection:()=>be,rc_obj_omit:()=>_e,rc_obj_pick:()=>he,rc_object:()=>_,rc_parse:()=>w,rc_parse_json:()=>Pe,rc_parser:()=>ke,rc_record:()=>q,rc_recursive:()=>$e,rc_rename_from_key:()=>v,rc_rename_key:()=>le,rc_strict_obj:()=>Re,rc_string:()=>ae,rc_transform:()=>Se,rc_tuple:()=>Oe,rc_undefined:()=>re,rc_union:()=>fe,rc_unknown:()=>oe,rc_validator:()=>me,snakeCase:()=>F});module.exports=L(Ae);function Z(e){return{...this,i:e}}function j(e,r){return r.startsWith("$[")||r.startsWith("$.")?r:`${e.path?`$${e.path}: `:""}${r}`}function E(e,r){e.warnings.push(j(e,r))}function C(e,r){r.forEach(n=>E(e,n))}function u(e,r,n,o){if(e.c&&r===void 0)return[!0,r];if(e.u&&r==null)return[!0,r];if(e.y&&r===null)return[!0,r];let t=o();if(t&&(t===!0||!t.errors)){let a=t===!0?r:t.data;return e.t&&!e.t(a)?[!1,[`Predicate failed for type '${e.e}'`]]:[!0,a]}let s=e.i;if(s!==void 0)return E(n,`Fallback used, errors -> ${I(t,n,e,r)}`),[!0,Ke(s)?s():s];if(e.f&&e.s){let a=e.s(r);if(a)return e.t&&!e.t(a.fixed)?[!1,[`Predicate failed for autofix in type '${e.e}'`]]:(E(n,`Autofixed from error "${I(t,n,e,r)}"`),[!0,a.fixed])}return[!1,t?t.errors:[e.l(r)]]}function I(e,r,n,o){return e?e.errors.map(t=>t.replace(r.path,"")).join("; "):n.l(o)}function G(e){return{...this,f:!0,s:e}}function H(e){return{...this,t:e}}function Q(){return{...this,c:!0}}function X(e){return`Type '${P(e,!!this.T)}' is not assignable to '${this.e}'`}function Y(){return{...this,y:!0,e:`${this.e}_or_null`}}function ee(){return{...this,u:!0,e:`${this.e}_or_nullish`}}var i={withFallback:Z,where:H,optional:Q,l:X,orNullish:ee,withAutofix:G,orNull:Y,i:void 0,t:void 0,c:!1,y:!1,u:!1,f:!1,T:!1,o:void 0,s:void 0,R:void 0,n:void 0,a:!1,p:!1,d:[]},re={...i,r(e,r){return u(this,e,r,()=>e===void 0)},e:"undefined"},ne={...i,r(e,r){return u(this,e,r,()=>e===null)},e:"null"},te={...i,r(e,r){return u(this,e,r,()=>!0)},e:"any"},oe={...i,r(e,r){return u(this,e,r,()=>!0)},e:"unknown"},se={...i,r(e,r){return u(this,e,r,()=>typeof e=="boolean")},e:"boolean"},ae={...i,r(e,r){return u(this,e,r,()=>typeof e=="string")},e:"string"},ie={...i,r(e,r){return u(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},ce={...i,r(e,r){return u(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function ue(e){return{...i,r(r,n){return u(this,r,n,()=>r instanceof e)},e:`instanceof_${e.name?`_${e.name}`:""}`}}function ye(...e){if(e.length===0)throw new Error("rc_literal requires at least one literal");return{...i,r(r,n){return u(this,r,n,()=>{for(let o of e)if(r===o)return!0;return!1})},T:!0,e:e.length==1?P(e[0],!0):e.map(r=>P(r,!0)).join(" | ")}}var A=1;function fe(...e){if(e.length===0)throw new Error("Unions should have at least one type");return{...i,r(r,n){return u(this,r,n,()=>{let o=n.path,t=[],s=0,a=!1,y=[],f=0;for(let R of e){f+=1,R.a&&(n.path=`${o}|union ${f}|`),n.objErrShortCircuit=!0,n.objErrKeyIndex=0;let[c,T]=R.r(r,n);n.objErrShortCircuit=!1;let p=n.objErrKeyIndex;if(n.objErrKeyIndex=0,c)return!0;R.a&&p!==-1?p>0?y.push(...T):(s<A&&t.push(...T),s+=1):a=!0}return n.path=o,y.length>0||t.length>0?((s>A||a)&&t.push("not matches any other union member"),{errors:[...y,...t],data:void 0}):!1})},e:e.map(r=>r.e).join(" | ")}}function v(e,r){return{...r,o:e}}var le=v;function Te(e){return k(e)&&"_kind_"in e}function V(e){if(Te(e))return e;if(k(e)){let r={};for(let[n,o]of Object.entries(e))r[n]=V(o);return _(r)}throw new Error(`invalid schema: ${e}`)}function _(e,{normalizeKeysFrom:r}={}){let n={};for(let[o,t]of Object.entries(e))n[o]=V(t);return{...i,n,e:"object",a:!0,d:Object.entries(n),r(o,t){return u(this,o,t,()=>{if(!k(o))return t.objErrKeyIndex=-1,!1;let s=this.e==="strict_obj"?new Set(Object.keys(o)):void 0,a={},y=[],f=t.path,R=-1;for(let[c,T]of this.d){let p=c;R+=1;let g=`.${c}`;t.path=`${f}${g}`;let d,b=c;if(T.o&&(d=o[T.o],b=T.o),d===void 0&&(d=o[c],b=c),d===void 0&&r==="snake_case"){let l=F(c);d=o[l],b=l}s?.delete(b);let[O,x]=T.r(d,t);if(O)a[p]=x;else{for(let l of x)y.push(j(t,l));if(t.objErrShortCircuit){t.objErrKeyIndex=R;break}}}if(s&&s.size>0)for(let c of s)y.push(`Key '${c}' is not defined in the object shape`);return y.length>0?{errors:y,data:void 0}:this.p?{errors:!1,data:{...o,...a}}:{errors:!1,data:a}})}}}function pe(e){return{..._(e),e:"extends_object",p:!0}}function de(e){return e.n}function Re(e){return{..._(e),e:"strict_obj"}}function be(...e){let r={};for(let n of e)Object.assign(r,n.n);return _(r)}function he(e,r){let n={};if(!e.n)throw new Error("rc_obj_pick: obj must be an object type");for(let o of r){let t=e.n[o];t&&(n[o]=t)}return _(n)}function _e(e,r){let n={};if(!e.n)throw new Error("rc_obj_omit: obj must be an object type");for(let o of Object.keys(e.n))r.includes(o)||(n[o]=e.n[o]);return _(n)}function q(e,{checkKey:r,looseCheck:n}={}){return{...i,e:`record<string, ${e.e}>`,r(o,t){return u(this,o,t,()=>{if(!k(o))return!1;let s={},a=[],y=t.path;for(let[f,R]of Object.entries(o)){let c=`.${f}`,T=`${y}${c}`;if(t.path=T,r&&!r(f)){a.push(j(t,`Key '${f}' is not allowed`));continue}let p=o[f],[g,d]=e.r(R,t);if(g)s[f]=p;else{let b=d;for(let O of b)a.push(j(t,O));if(t.objErrShortCircuit)break}}if(a.length>0)if(n)C(t,a);else return{errors:a,data:void 0};return{errors:!1,data:s}})}}}function je(e,{checkKey:r}={}){return q(e,{checkKey:r,looseCheck:!0})}function N(e,r){if(typeof r=="string"&&!e.n?.[r])throw new Error(`${e.e} can't be used with unique key option`)}function K(e,r,n,o=!1,t){let s=[],a=[],y=new Set,f=n.path,R=Array.isArray(r),c=-1;for(let T of e){c++;let p=R?r[c]:r,g=`[${c}]`,d=`${f}${g}`;n.path=d;let b=p.r(T,n),[O,x]=b;n.path=d;let l=t?.unique;if(O&&l){let h=x,$=typeof l=="string";$?h=x[l]:typeof l=="function"&&(h=l(x)),y.has(h)?($&&(n.path=`${f}${g}.${l}`),b=[!1,[j(n,$?`Type '${p.n?.[l]?.e}' with value "${h}" is not unique`:typeof l=="function"?`Type '${p.e}' unique fn return with value "${h}" is not unique`:`${p.e} value is not unique`)]]):y.add(h)}let[W,m]=b;if(W)a.push(m);else if(o){s.push(m.map(h=>j(n,h)));continue}else return{errors:m.map(h=>j(n,h)),data:void 0}}if(s.length>0){if(a.length===0)return{errors:s.slice(0,5).flat(),data:void 0};C(n,s.flat())}return{errors:!1,data:a}}function ge(e,r){return N(e,r?.unique),{...i,e:`${e.e}[]`,r(n,o){return u(this,n,o,()=>Array.isArray(n)?n.length===0?!0:K.call(this,n,e,o,!1,r):!1)}}}function xe(e,r){return N(e,r?.unique),{...i,e:`${e.e}[]`,r(n,o){return u(this,n,o,()=>Array.isArray(n)?n.length===0?!0:K.call(this,n,e,o,!0,r):!1)}}}function Oe(e){return{...i,e:`[${e.map(r=>r.e).join(", ")}]`,r(r,n){return u(this,r,n,()=>!Array.isArray(r)||r.length!==e.length?!1:K.call(this,r,e,n))}}}function w(e,r){let n={warnings:[],path:"",objErrShortCircuit:!1,objErrKeyIndex:0},[o,t]=r.r(e,n);return o?{error:!1,data:t,warnings:n.warnings.length>0?n.warnings:!1}:{error:!0,errors:t}}function ke(e){return r=>w(r,e)}function we(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 B(e,r){let n={warnings:[],path:"",objErrShortCircuit:!1,objErrKeyIndex:0};return!!r.r(e,n)[0]}function me(e){return r=>B(r,e)}function $e(e){return{...i,e:"recursive",r(r,n){return e().r(r,n)}}}function Se(e,r){return{...i,e:`transform_from_${e.e}`,r(n,o){let[t,s]=e.r(n,o);return t?[!0,r(s)]:[!1,s]}}}function P(e,r){let n=(()=>{if(typeof e=="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return typeof e})();return r&&(n==="string"||n==="number"||n==="boolean")?`${n}(${e})`:n}function Ee(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 F(e){return e.replace(/\W+/g," ").split(/ |\B(?=[A-Z])/).map(r=>r.toLowerCase()).join("_")}function Pe(e,r){try{let n=JSON.parse(e);return w(n,r)}catch(n){return{error:!0,errors:[`json parse error: ${k(n)?n.message:""}`]}}}function Ke(e){return typeof e=="function"}function Ie(){return e=>_(e)}0&&(module.exports={rc_any,rc_array,rc_assert_is_valid,rc_boolean,rc_date,rc_extends_obj,rc_get_obj_schema,rc_instanceof,rc_is_valid,rc_literals,rc_loose_array,rc_loose_parse,rc_loose_record,rc_null,rc_number,rc_obj_builder,rc_obj_intersection,rc_obj_omit,rc_obj_pick,rc_object,rc_parse,rc_parse_json,rc_parser,rc_record,rc_recursive,rc_rename_from_key,rc_rename_key,rc_strict_obj,rc_string,rc_transform,rc_tuple,rc_undefined,rc_union,rc_unknown,rc_validator,snakeCase});
|
package/dist/runcheck.d.ts
CHANGED
|
@@ -109,9 +109,9 @@ type Prettify<T> = T extends Record<string, any> ? {
|
|
|
109
109
|
[K in keyof T]: Prettify<T[K]>;
|
|
110
110
|
} : T;
|
|
111
111
|
type RcPrettyInferType<T extends RcType<any>> = Prettify<RcInferType<T>>;
|
|
112
|
-
type
|
|
113
|
-
[K in keyof T]-?:
|
|
112
|
+
type StricTypeToRcType<T> = [T] extends [any[]] ? RcType<T> : [T] extends [Record<string, any>] ? ({
|
|
113
|
+
[K in keyof T]-?: StricTypeToRcType<T[K]>;
|
|
114
114
|
} & Partial<Record<keyof RcType<any>, never>>) | RcType<T> : RcType<T>;
|
|
115
|
-
declare function rc_obj_builder<T extends Record<string, any>>(): <S extends
|
|
115
|
+
declare function rc_obj_builder<T extends Record<string, any>>(): <S extends StricTypeToRcType<T>>(schema: { [K in keyof S]: K extends keyof T ? S[K] : never; }) => RcObjType<S extends Record<string, any> ? S : never>;
|
|
116
116
|
|
|
117
117
|
export { RcInferType, RcParseResult, RcParser, RcPrettyInferType, RcType, rc_any, rc_array, rc_assert_is_valid, rc_boolean, rc_date, rc_extends_obj, rc_get_obj_schema, rc_instanceof, rc_is_valid, rc_literals, rc_loose_array, rc_loose_parse, rc_loose_record, rc_null, rc_number, rc_obj_builder, rc_obj_intersection, rc_obj_omit, rc_obj_pick, rc_object, rc_parse, rc_parse_json, rc_parser, rc_record, rc_recursive, rc_rename_from_key, 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,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-
|
|
1
|
+
import{A,B,C,D,E,F,G,H,I,J,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-CENEI7TU.js";export{c as rc_any,w as rc_array,G as rc_assert_is_valid,e as rc_boolean,h as rc_date,o as rc_extends_obj,p as rc_get_obj_schema,i as rc_instanceof,C as rc_is_valid,j as rc_literals,x as rc_loose_array,B as rc_loose_parse,v as rc_loose_record,b as rc_null,g as rc_number,J as rc_obj_builder,r as rc_obj_intersection,t as rc_obj_omit,s as rc_obj_pick,n as rc_object,z as rc_parse,I as rc_parse_json,A as rc_parser,u as rc_record,E as rc_recursive,l as rc_rename_from_key,m as rc_rename_key,q as rc_strict_obj,f as rc_string,F as rc_transform,y as rc_tuple,a as rc_undefined,k as rc_union,d as rc_unknown,D as rc_validator,H as snakeCase};
|
package/package.json
CHANGED
|
@@ -1,22 +1,8 @@
|
|
|
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.34.
|
|
4
|
+
"version": "0.34.5",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "vitest --ui",
|
|
8
|
-
"test:run": "vitest run",
|
|
9
|
-
"lint": "pnpm tsc && pnpm eslint",
|
|
10
|
-
"tsc": "tsc -p tsconfig.prod.json",
|
|
11
|
-
"vitest-bench": "vitest bench --run",
|
|
12
|
-
"benchmark": "tsm benchmarks/benchmark.ts",
|
|
13
|
-
"benchmark:generate-profile": "tsm benchmarks/generateProfiles.ts",
|
|
14
|
-
"eslint": "CI=true eslint --color --ext .jsx,.js,.ts,.tsx src/ tests/",
|
|
15
|
-
"build": "pnpm test:run && pnpm lint && pnpm build:no-test",
|
|
16
|
-
"build:no-test": "tsup --minify --dts",
|
|
17
|
-
"build-test": "tsup --config tsup.test.config.ts",
|
|
18
|
-
"npm-publish": "./scripts/check-if-is-sync.sh && pnpm build && npm publish"
|
|
19
|
-
},
|
|
20
6
|
"files": [
|
|
21
7
|
"dist"
|
|
22
8
|
],
|
|
@@ -62,5 +48,19 @@
|
|
|
62
48
|
"vite": "^4.3.9",
|
|
63
49
|
"vitest": "^0.31.0",
|
|
64
50
|
"zod": "^3.21.4"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"test": "vitest --ui",
|
|
54
|
+
"test:run": "vitest run",
|
|
55
|
+
"lint": "pnpm tsc && pnpm eslint",
|
|
56
|
+
"tsc": "tsc -p tsconfig.prod.json",
|
|
57
|
+
"vitest-bench": "vitest bench --run",
|
|
58
|
+
"benchmark": "tsm benchmarks/benchmark.ts",
|
|
59
|
+
"benchmark:generate-profile": "tsm benchmarks/generateProfiles.ts",
|
|
60
|
+
"eslint": "CI=true eslint --color --ext .jsx,.js,.ts,.tsx src/ tests/",
|
|
61
|
+
"build": "pnpm test:run && pnpm lint && pnpm build:no-test",
|
|
62
|
+
"build:no-test": "tsup --minify --dts",
|
|
63
|
+
"build-test": "tsup --config tsup.test.config.ts",
|
|
64
|
+
"pre-publish": "./scripts/check-if-is-sync.sh && pnpm build "
|
|
65
65
|
}
|
|
66
|
-
}
|
|
66
|
+
}
|