runcheck 0.23.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/autofixable.cjs +1 -1
- package/dist/autofixable.js +1 -1
- package/dist/chunk-USNZM5S6.js +1 -0
- package/dist/runcheck.cjs +1 -1
- package/dist/runcheck.d.ts +2 -1
- package/dist/runcheck.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-D2IBPFZA.js +0 -1
package/dist/autofixable.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var u=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var R=(e,r)=>{for(var t in r)u(e,t,{get:r[t],enumerable:!0})},h=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of p(r))!d.call(e,n)&&n!==t&&u(e,n,{get:()=>r[n],enumerable:!(i=T(r,n))||i.enumerable});return e};var _=e=>h(u({},"__esModule",{value:!0}),e);var
|
|
1
|
+
"use strict";var u=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var R=(e,r)=>{for(var t in r)u(e,t,{get:r[t],enumerable:!0})},h=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of p(r))!d.call(e,n)&&n!==t&&u(e,n,{get:()=>r[n],enumerable:!(i=T(r,n))||i.enumerable});return e};var _=e=>h(u({},"__esModule",{value:!0}),e);var E={};R(E,{rc_boolean_autofix:()=>A,rc_number_autofix:()=>S,rc_string_autofix:()=>P});module.exports=_(E);function b(e){return{...this,a:e}}function g(e,r){return r.startsWith("$[")||r.startsWith("$.")?r:`${e.path?`$${e.path}: `:""}${r}`}function c(e,r){e.warnings.push(g(e,r))}function o(e,r,t,i){if(e.c&&r===void 0)return[!0,r];if(e.l&&r==null)return[!0,r];if(e.f&&r===null)return[!0,r];let n=i();if(n&&(n===!0||"data"in n)){let s=n===!0?r:n.data;return e.s&&!e.s(s)?[!1,[e.n(s)]]:[!0,s]}if(e.a!==void 0)return c(t,`Fallback used, ${e.n(r)}`),[!0,e.a];if(e.y&&e.i){let s=e.i(r);if(s)return e.s&&!e.s(s.fixed)?[!1,[e.n(s.fixed)]]:(c(t,`Autofixed from error "${e.n(r)}"`),[!0,s.fixed])}return[!1,n&&"errors"in n?n.errors:[e.n(r)]]}function x(e){return{...this,y:!0,i:e}}function j(e){return{...this,s:e,e:`${this.e}_with_predicate`}}function m(){return{...this,c:!0}}function w(e){return`Type '${O(e,!!this.T)}' is not assignable to '${this.e}'`}function $(){return{...this,f:!0,e:`${this.e}_or_null`}}function k(){return{...this,l:!0,e:`${this.e}_or_nullish`}}var a={withFallback:b,where:j,optional:m,n:w,orNullish:k,withAutofix:x,orNull:$},C={...a,r(e,r){return o(this,e,r,()=>e===void 0)},e:"undefined"},I={...a,r(e,r){return o(this,e,r,()=>e===null)},e:"null"},q={...a,r(e,r){return o(this,e,r,()=>!0)},e:"any"},V={...a,r(e,r){return o(this,e,r,()=>!0)},e:"unknown"},l={...a,r(e,r){return o(this,e,r,()=>typeof e=="boolean")},e:"boolean"},f={...a,r(e,r){return o(this,e,r,()=>typeof e=="string")},e:"string"},y={...a,r(e,r){return o(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},v={...a,r(e,r){return o(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function O(e,r){let t=(()=>{if(typeof e=="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return typeof e})();return r&&(t==="string"||t==="number"||t==="boolean")?`${t}(${e})`:t}var A=l.withAutofix(e=>e==null||e===0||e===1?{fixed:!!e}:e==="true"||e==="false"?{fixed:e==="true"}:!1),P=f.withAutofix(e=>typeof e=="number"&&!Number.isNaN(e)?{fixed:e.toString()}:!1),S=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});
|
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-USNZM5S6.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 @@
|
|
|
1
|
+
function C(e){return{...this,a:e}}function _(e,r){return r.startsWith("$[")||r.startsWith("$.")?r:`${e.path?`$${e.path}: `:""}${r}`}function w(e,r){e.warnings.push(_(e,r))}function A(e,r){r.forEach(n=>w(e,n))}function c(e,r,n,s){if(e.c&&r===void 0)return[!0,r];if(e.l&&r==null)return[!0,r];if(e.f&&r===null)return[!0,r];let t=s();if(t&&(t===!0||"data"in t)){let o=t===!0?r:t.data;return e.s&&!e.s(o)?[!1,[e.n(o)]]:[!0,o]}if(e.a!==void 0)return w(n,`Fallback used, ${e.n(r)}`),[!0,e.a];if(e.y&&e.i){let o=e.i(r);if(o)return e.s&&!e.s(o.fixed)?[!1,[e.n(o.fixed)]]:(w(n,`Autofixed from error "${e.n(r)}"`),[!0,o.fixed])}return[!1,t&&"errors"in t?t.errors:[e.n(r)]]}function I(e){return{...this,y:!0,i:e}}function q(e){return{...this,s:e,e:`${this.e}_with_predicate`}}function V(){return{...this,c:!0}}function N(e){return`Type '${E(e,!!this.T)}' is not assignable to '${this.e}'`}function v(){return{...this,f:!0,e:`${this.e}_or_null`}}function K(){return{...this,l:!0,e:`${this.e}_or_nullish`}}var u={withFallback:C,where:q,optional:V,n:N,orNullish:K,withAutofix:I,orNull:v},B={...u,r(e,r){return c(this,e,r,()=>e===void 0)},e:"undefined"},z={...u,r(e,r){return c(this,e,r,()=>e===null)},e:"null"},D={...u,r(e,r){return c(this,e,r,()=>!0)},e:"any"},M={...u,r(e,r){return c(this,e,r,()=>!0)},e:"unknown"},J={...u,r(e,r){return c(this,e,r,()=>typeof e=="boolean")},e:"boolean"},L={...u,r(e,r){return c(this,e,r,()=>typeof e=="string")},e:"string"},Z={...u,r(e,r){return c(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},G={...u,r(e,r){return c(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function H(e){return{...u,r(r,n){return c(this,r,n,()=>r instanceof e)},e:`instanceof_${e.name?`_${e.name}`:""}`}}function Q(...e){if(e.length===0)throw new Error("rc_literal requires at least one literal");return{...u,r(r,n){return c(this,r,n,()=>{for(let s of e)if(r===s)return!0;return!1})},T:!0,e:e.length==1?`${E(e[0],!1)}_literal`:"literals"}}function X(...e){if(e.length===0)throw new Error("Unions should have at least one type");return{...u,r(r,n){return c(this,r,n,()=>{let s=n.path,t=[],o=0,i=0;for(let y of e){i+=1,y.u&&(n.path=`${s}|union ${i}|`),n.objErrShortCircuit=!0;let[a,f]=y.r(r,n);if(n.objErrShortCircuit=!1,a)return!0;y.u&&o<=2&&(o+=1,t.push(...f))}return n.path=s,t.length>0?{errors:t}:!1})},e:e.map(r=>r.e).join(" | ")}}function W(e,r){return{...r,o:e}}var Y=W;function k(e,{normalizeKeysFrom:r}={}){return{...u,t:e,e:"object",u:!0,r(n,s){return c(this,n,s,()=>{if(!P(n))return!1;let t=this.e==="strict_obj"?new Set(Object.keys(n)):void 0,o={},i=[],y=s.path;for(let[a,f]of Object.entries(e)){let b=a,R=`.${a}`;s.path=`${y}${R}`;let T,p=a;if(f.o&&(T=n[f.o],p=f.o),T===void 0&&(T=n[a],p=a),T===void 0&&r==="snake_case"){let l=U(a);T=n[l],p=l}t?.delete(p);let[g,h]=f.r(T,s);if(g)o[b]=h;else{let l=h;for(let x of l)i.push(_(s,x));if(s.objErrShortCircuit)break}}if(t&&t.size>0)for(let a of t)i.push(`Key '${a}' is not defined in the object shape`);return i.length>0?{errors:i}:this.e.startsWith("extends_object")?{data:{...n,...o}}:{data:o}})}}}function ee(e){return{...k(e),e:"extends_object"}}function re(e){return e.t}function ne(e){return{...k(e),e:"strict_obj"}}function te(e,r){return k({...e.t,...r.t})}function se(e,{checkKey:r,looseCheck:n}={}){return{...u,e:`record<string, ${e.e}>`,r(s,t){return c(this,s,t,()=>{if(!P(s))return!1;let o={},i=[],y=t.path;for(let[a,f]of Object.entries(s)){let b=`.${a}`,R=`${y}${b}`;if(t.path=R,r&&!r(a)){i.push(_(t,`Key '${a}' is not allowed`));continue}let T=s[a],[p,g]=e.r(f,t);if(p)o[a]=T;else{let h=g;for(let l of h)i.push(_(t,l));if(t.objErrShortCircuit)break}}if(i.length>0)if(n)A(t,i);else return{errors:i};return{data:o}})}}}function S(e,r){if(typeof r=="string"&&!e.t?.[r])throw new Error(`${e.e} can't be used with unique key option`)}function m(e,r,n,s=!1,t){let o=-1,i=[],y=[],a=new Set,f=n.path;for(let b of e){o++;let R=Array.isArray(r)?r[o]:r,T=`[${o}]`;n.path=`${f}${T}`;let p=R.r(b,n),[g,h]=p,l=t?.unique;if(g&&l){let d=h,$=typeof l=="string";$?d=h[l]:typeof l=="function"&&(d=l(h)),a.has(d)?($&&(n.path=`${f}${T}.${l}`),p=[!1,[_(n,$?`Type '${R.t?.[l]?.e}' with value "${d}" is not unique`:typeof l=="function"?`Type '${R.e}' unique fn return with value "${d}" is not unique`:`${R.e} value is not unique`)]]):a.add(d)}let[x,j]=p;if(x)y.push(j);else if(s){i.push(j.map(d=>_(n,d)));continue}else return{errors:j.map(d=>_(n,d))}}if(i.length>0){if(y.length===0)return{errors:i.slice(0,5).flat()};A(n,i.flat())}return{data:y}}function oe(e,r){return S(e,r?.unique),{...u,e:`${e.e}[]`,r(n,s){return c(this,n,s,()=>Array.isArray(n)?n.length===0?!0:m.call(this,n,e,s,!1,r):!1)}}}function ae(e,r){return S(e,r?.unique),{...u,e:`${e.e}[]`,r(n,s){return c(this,n,s,()=>Array.isArray(n)?n.length===0?!0:m.call(this,n,e,s,!0,r):!1)}}}function ie(e){return{...u,e:`[${e.map(r=>r.e).join(", ")}]`,r(r,n){return c(this,r,n,()=>!Array.isArray(r)||r.length!==e.length?!1:m.call(this,r,e,n))}}}function O(e,r){let n={warnings:[],path:"",objErrShortCircuit:!1},[s,t]=r.r(e,n);return s?{error:!1,data:t,warnings:n.warnings.length>0?n.warnings:!1}:{error:!0,errors:t}}function ue(e){return r=>O(r,e)}function ce(e,r){let n=O(e,r);return n.error?{data:null,errors:n.errors,warnings:!1}:{data:n.data,errors:!1,warnings:n.warnings}}function F(e,r){let n={warnings:[],path:"",objErrShortCircuit:!1};return!!r.r(e,n)[0]}function le(e){return r=>F(r,e)}function ye(e){return{...u,e:"recursive",r(r,n){return e().r(r,n)}}}function fe(e,r){return{...u,e:`transform_from_${e.e}`,r(n,s){let[t,o]=e.r(n,s);return t?[!0,r(o)]:[!1,o]}}}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=="object"&&e!==null&&!Array.isArray(e)}function U(e){return e.replace(/\W+/g," ").split(/ |\B(?=[A-Z])/).map(r=>r.toLowerCase()).join("_")}function Te(e,r){try{let n=JSON.parse(e);return O(n,r)}catch(n){return{error:!0,errors:[`json parse error: ${P(n)?n.message:""}`]}}}export{B as a,z as b,D as c,M as d,J as e,L as f,Z as g,G as h,H as i,Q as j,X as k,W as l,Y as m,k as n,ee as o,re as p,ne as q,te as r,se as s,oe as t,ae as u,ie as v,O as w,ue as x,ce as y,F as z,le as A,ye as B,fe as C,U as D,Te as E};
|
package/dist/runcheck.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var W=(e,r)=>{for(var n in r)m(e,n,{get:r[n],enumerable:!0})},F=(e,r,n,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of v(r))!K.call(e,t)&&t!==n&&m(e,t,{get:()=>r[t],enumerable:!(s=N(r,t))||s.enumerable});return e};var U=e=>F(m({},"__esModule",{value:!0}),e);var xe={};W(xe,{rc_any:()=>Q,rc_array:()=>fe,rc_boolean:()=>Y,rc_date:()=>ne,rc_extends_obj:()=>ie,rc_get_obj_schema:()=>ue,rc_instanceof:()=>te,rc_is_valid:()=>I,rc_literals:()=>se,rc_loose_array:()=>Te,rc_loose_parse:()=>Re,rc_null:()=>H,rc_number:()=>re,rc_obj_intersection:()=>le,rc_object:()=>x,rc_parse:()=>j,rc_parse_json:()=>ge,rc_parser:()=>de,rc_record:()=>ye,rc_recursive:()=>_e,rc_rename_from_key:()=>E,rc_rename_key:()=>ae,rc_strict_obj:()=>ce,rc_string:()=>ee,rc_transform:()=>be,rc_tuple:()=>pe,rc_undefined:()=>G,rc_union:()=>oe,rc_unknown:()=>X,rc_validator:()=>he,snakeCase:()=>V});module.exports=U(xe);function B(e){return{...this,a:e}}function _(e,r){return r.startsWith("$[")||r.startsWith("$.")?r:`${e.path?`$${e.path}: `:""}${r}`}function O(e,r){e.warnings.push(_(e,r))}function S(e,r){r.forEach(n=>O(e,n))}function c(e,r,n,s){if(e.c&&r===void 0)return[!0,r];if(e.l&&r==null)return[!0,r];if(e.y&&r===null)return[!0,r];let t=s();if(t&&(t===!0||"data"in t)){let o=t===!0?r:t.data;return e.s&&!e.s(o)?[!1,[e.n(o)]]:[!0,o]}if(e.a!==void 0)return O(n,`Fallback used, ${e.n(r)}`),[!0,e.a];if(e.f&&e.i){let o=e.i(r);if(o)return e.s&&!e.s(o.fixed)?[!1,[e.n(o.fixed)]]:(O(n,`Autofixed from error "${e.n(r)}"`),[!0,o.fixed])}return[!1,t&&"errors"in t?t.errors:[e.n(r)]]}function z(e){return{...this,f:!0,i:e}}function D(e){return{...this,s:e,e:`${this.e}_with_predicate`}}function M(){return{...this,c:!0}}function J(e){return`Type '${q(e,!!this.T)}' is not assignable to '${this.e}'`}function L(){return{...this,y:!0,e:`${this.e}_or_null`}}function Z(){return{...this,l:!0,e:`${this.e}_or_nullish`}}var u={withFallback:B,where:D,optional:M,n:J,orNullish:Z,withAutofix:z,orNull:L},G={...u,r(e,r){return c(this,e,r,()=>e===void 0)},e:"undefined"},H={...u,r(e,r){return c(this,e,r,()=>e===null)},e:"null"},Q={...u,r(e,r){return c(this,e,r,()=>!0)},e:"any"},X={...u,r(e,r){return c(this,e,r,()=>!0)},e:"unknown"},Y={...u,r(e,r){return c(this,e,r,()=>typeof e=="boolean")},e:"boolean"},ee={...u,r(e,r){return c(this,e,r,()=>typeof e=="string")},e:"string"},re={...u,r(e,r){return c(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},ne={...u,r(e,r){return c(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function te(e){return{...u,r(r,n){return c(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{...u,r(r,n){return c(this,r,n,()=>{for(let s of e)if(r===s)return!0;return!1})},T:!0,e:e.length==1?`${q(e[0],!1)}_literal`:"literals"}}function oe(...e){if(e.length===0)throw new Error("Unions should have at least one type");return{...u,r(r,n){return c(this,r,n,()=>{let s=n.path,t=[],o=0,i=0;for(let y of e){i+=1,y.u&&(n.path=`${s}|union ${i}|`),n.objErrShortCircuit=!0;let[a,f]=y.r(r,n);if(n.objErrShortCircuit=!1,a)return!0;y.u&&o<=2&&(o+=1,t.push(...f))}return n.path=s,t.length>0?{errors:t}:!1})},e:e.map(r=>r.e).join(" | ")}}function E(e,r){return{...r,o:e}}var ae=E;function x(e,{normalizeKeysFrom:r}={}){return{...u,t:e,e:"object",u:!0,r(n,s){return c(this,n,s,()=>{if(!A(n))return!1;let t=this.e==="strict_obj"?new Set(Object.keys(n)):void 0,o={},i=[],y=s.path;for(let[a,f]of Object.entries(e)){let b=a,R=`.${a}`;s.path=`${y}${R}`;let T,p=a;if(f.o&&(T=n[f.o],p=f.o),T===void 0&&(T=n[a],p=a),T===void 0&&r==="snake_case"){let l=V(a);T=n[l],p=l}t?.delete(p);let[g,h]=f.r(T,s);if(g)o[b]=h;else{let l=h;for(let $ of l)i.push(_(s,$));if(s.objErrShortCircuit)break}}if(t&&t.size>0)for(let a of t)i.push(`Key '${a}' is not defined in the object shape`);return i.length>0?{errors:i}:this.e.startsWith("extends_object")?{data:{...n,...o}}:{data:o}})}}}function ie(e){return{...x(e),e:"extends_object"}}function ue(e){return e.t}function ce(e){return{...x(e),e:"strict_obj"}}function le(e,r){return x({...e.t,...r.t})}function ye(e,{checkKey:r,looseCheck:n}={}){return{...u,e:`record<string, ${e.e}>`,r(s,t){return c(this,s,t,()=>{if(!A(s))return!1;let o={},i=[],y=t.path;for(let[a,f]of Object.entries(s)){let b=`.${a}`,R=`${y}${b}`;if(t.path=R,r&&!r(a)){i.push(_(t,`Key '${a}' is not allowed`));continue}let T=s[a],[p,g]=e.r(f,t);if(p)o[a]=T;else{let h=g;for(let l of h)i.push(_(t,l));if(t.objErrShortCircuit)break}}if(i.length>0)if(n)S(t,i);else return{errors:i};return{data:o}})}}}function C(e,r){if(typeof r=="string"&&!e.t?.[r])throw new Error(`${e.e} can't be used with unique key option`)}function P(e,r,n,s=!1,t){let o=-1,i=[],y=[],a=new Set,f=n.path;for(let b of e){o++;let R=Array.isArray(r)?r[o]:r,T=`[${o}]`;n.path=`${f}${T}`;let p=R.r(b,n),[g,h]=p,l=t?.unique;if(g&&l){let d=h,k=typeof l=="string";k?d=h[l]:typeof l=="function"&&(d=l(h)),a.has(d)?(k&&(n.path=`${f}${T}.${l}`),p=[!1,[_(n,k?`Type '${R.t?.[l]?.e}' with value "${d}" is not unique`:typeof l=="function"?`Type '${R.e}' unique fn return with value "${d}" is not unique`:`${R.e} value is not unique`)]]):a.add(d)}let[$,w]=p;if($)y.push(w);else if(s){i.push(w.map(d=>_(n,d)));continue}else return{errors:w.map(d=>_(n,d))}}if(i.length>0){if(y.length===0)return{errors:i.slice(0,5).flat()};S(n,i.flat())}return{data:y}}function fe(e,r){return C(e,r?.unique),{...u,e:`${e.e}[]`,r(n,s){return c(this,n,s,()=>Array.isArray(n)?n.length===0?!0:P.call(this,n,e,s,!1,r):!1)}}}function Te(e,r){return C(e,r?.unique),{...u,e:`${e.e}[]`,r(n,s){return c(this,n,s,()=>Array.isArray(n)?n.length===0?!0:P.call(this,n,e,s,!0,r):!1)}}}function pe(e){return{...u,e:`[${e.map(r=>r.e).join(", ")}]`,r(r,n){return c(this,r,n,()=>!Array.isArray(r)||r.length!==e.length?!1:P.call(this,r,e,n))}}}function j(e,r){let n={warnings:[],path:"",objErrShortCircuit:!1},[s,t]=r.r(e,n);return s?{error:!1,data:t,warnings:n.warnings.length>0?n.warnings:!1}:{error:!0,errors:t}}function de(e){return r=>j(r,e)}function Re(e,r){let n=j(e,r);return n.error?{data:null,errors:n.errors,warnings:!1}:{data:n.data,errors:!1,warnings:n.warnings}}function I(e,r){let n={warnings:[],path:"",objErrShortCircuit:!1};return!!r.r(e,n)[0]}function he(e){return r=>I(r,e)}function _e(e){return{...u,e:"recursive",r(r,n){return e().r(r,n)}}}function be(e,r){return{...u,e:`transform_from_${e.e}`,r(n,s){let[t,o]=e.r(n,s);return t?[!0,r(o)]:[!1,o]}}}function q(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 A(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 ge(e,r){try{let n=JSON.parse(e);return j(n,r)}catch(n){return{error:!0,errors:[`json parse error: ${A(n)?n.message:""}`]}}}0&&(module.exports={rc_any,rc_array,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_null,rc_number,rc_obj_intersection,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
|
@@ -89,5 +89,6 @@ declare function rc_validator<S>(type: RcType<S>): (input: any) => input is S;
|
|
|
89
89
|
declare function rc_recursive(type: () => RcType<any>): RcType<any>;
|
|
90
90
|
/** validate a input or subset of input and transform the valid result */
|
|
91
91
|
declare function rc_transform<Input, Transformed>(type: RcType<Input>, transform: (input: Input) => Transformed): RcType<Transformed>;
|
|
92
|
+
declare function rc_parse_json<T>(jsonString: string, schema: RcType<T>): RcParseResult<T>;
|
|
92
93
|
|
|
93
|
-
export { RcInferType, RcParseResult, RcParser, RcType, rc_any, rc_array, 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_null, rc_number, rc_obj_intersection, rc_object, rc_parse, 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 };
|
|
94
|
+
export { RcInferType, RcParseResult, RcParser, RcType, rc_any, rc_array, 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_null, rc_number, rc_obj_intersection, 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,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,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-USNZM5S6.js";export{c as rc_any,t as rc_array,e as rc_boolean,h as rc_date,o as rc_extends_obj,p as rc_get_obj_schema,i as rc_instanceof,z as rc_is_valid,j as rc_literals,u as rc_loose_array,y as rc_loose_parse,b as rc_null,g as rc_number,r as rc_obj_intersection,n as rc_object,w as rc_parse,E as rc_parse_json,x as rc_parser,s as rc_record,B as rc_recursive,l as rc_rename_from_key,m as rc_rename_key,q as rc_strict_obj,f as rc_string,C as rc_transform,v as rc_tuple,a as rc_undefined,k as rc_union,d as rc_unknown,A as rc_validator,D as snakeCase};
|
package/package.json
CHANGED
package/dist/chunk-D2IBPFZA.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function q(e){return{...this,a:e}}function _(e,r){return r.startsWith("$[")||r.startsWith("$.")?r:`${e.path?`$${e.path}: `:""}${r}`}function j(e,r){e.warnings.push(_(e,r))}function O(e,r){r.forEach(n=>j(e,n))}function c(e,r,n,s){if(e.c&&r===void 0)return[!0,r];if(e.l&&r==null)return[!0,r];if(e.f&&r===null)return[!0,r];let t=s();if(t&&(t===!0||"data"in t)){let a=t===!0?r:t.data;return e.s&&!e.s(a)?[!1,[e.n(a)]]:[!0,a]}if(e.a!==void 0)return j(n,`Fallback used, ${e.n(r)}`),[!0,e.a];if(e.y&&e.i){let a=e.i(r);if(a)return e.s&&!e.s(a.fixed)?[!1,[e.n(a.fixed)]]:(j(n,`Autofixed from error "${e.n(r)}"`),[!0,a.fixed])}return[!1,t&&"errors"in t?t.errors:[e.n(r)]]}function V(e){return{...this,y:!0,i:e}}function E(e){return{...this,s:e,e:`${this.e}_with_predicate`}}function N(){return{...this,c:!0}}function C(e){return`Type '${I(e,!!this.T)}' is not assignable to '${this.e}'`}function v(){return{...this,f:!0,e:`${this.e}_or_null`}}function K(){return{...this,l:!0,e:`${this.e}_or_nullish`}}var u={withFallback:q,where:E,optional:N,n:C,orNullish:K,withAutofix:V,orNull:v},B={...u,r(e,r){return c(this,e,r,()=>e===void 0)},e:"undefined"},z={...u,r(e,r){return c(this,e,r,()=>e===null)},e:"null"},D={...u,r(e,r){return c(this,e,r,()=>!0)},e:"any"},M={...u,r(e,r){return c(this,e,r,()=>!0)},e:"unknown"},L={...u,r(e,r){return c(this,e,r,()=>typeof e=="boolean")},e:"boolean"},Z={...u,r(e,r){return c(this,e,r,()=>typeof e=="string")},e:"string"},G={...u,r(e,r){return c(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},H={...u,r(e,r){return c(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function J(e){return{...u,r(r,n){return c(this,r,n,()=>r instanceof e)},e:`instanceof_${e.name?`_${e.name}`:""}`}}function Q(...e){if(e.length===0)throw new Error("rc_literal requires at least one literal");return{...u,r(r,n){return c(this,r,n,()=>{for(let s of e)if(r===s)return!0;return!1})},T:!0,e:e.length==1?`${I(e[0],!1)}_literal`:"literals"}}function X(...e){if(e.length===0)throw new Error("Unions should have at least one type");return{...u,r(r,n){return c(this,r,n,()=>{let s=n.path,t=[],a=0;for(let o of e){a+=1,o.u&&(n.path=`${s}|union ${a}|`);let[p,i]=o.r(r,n);if(p)return!0;o.u&&t.push(...i)}return n.path=s,t.length>0?{errors:t}:!1})},e:e.map(r=>r.e).join(" | ")}}function F(e,r){return{...r,o:e}}var Y=F;function k(e,{normalizeKeysFrom:r}={}){return{...u,t:e,e:"object",u:!0,r(n,s){return c(this,n,s,()=>{if(!S(n))return!1;let t=this.e==="strict_obj"?new Set(Object.keys(n)):void 0,a={},o=[],p=s.path;for(let[i,d]of Object.entries(e)){let b=i,R=`.${i}`;s.path=`${p}${R}`;let y,f=i;if(d.o&&(y=n[d.o],f=d.o),y===void 0&&(y=n[i],f=i),y===void 0&&r==="snake_case"){let l=U(i);y=n[l],f=l}t?.delete(f);let[g,h]=d.r(y,s);if(g)a[b]=h;else{let l=h;for(let x of l)o.push(_(s,x))}}if(t&&t.size>0)for(let i of t)o.push(`Key '${i}' is not defined in the object shape`);return o.length>0?{errors:o}:this.e.startsWith("extends_object")?{data:{...n,...a}}:{data:a}})}}}function ee(e){return{...k(e),e:"extends_object"}}function re(e){return e.t}function ne(e){return{...k(e),e:"strict_obj"}}function te(e,r){return k({...e.t,...r.t})}function se(e,{checkKey:r,looseCheck:n}={}){return{...u,e:`record<string, ${e.e}>`,r(s,t){return c(this,s,t,()=>{if(!S(s))return!1;let a={},o=[],p=t.path;for(let[i,d]of Object.entries(s)){let b=`.${i}`,R=`${p}${b}`;if(t.path=R,r&&!r(i)){o.push(_(t,`Key '${i}' is not allowed`));continue}let y=s[i],[f,g]=e.r(d,t);if(f)a[i]=y;else{let h=g;for(let l of h)o.push(_(t,l))}}if(o.length>0)if(n)O(t,o);else return{errors:o};return{data:a}})}}}function P(e,r){if(typeof r=="string"&&!e.t?.[r])throw new Error(`${e.e} can't be used with unique key option`)}function m(e,r,n,s=!1,t){let a=-1,o=[],p=[],i=new Set,d=n.path;for(let b of e){a++;let R=Array.isArray(r)?r[a]:r,y=`[${a}]`;n.path=`${d}${y}`;let f=R.r(b,n),[g,h]=f,l=t?.unique;if(g&&l){let T=h,w=typeof l=="string";w?T=h[l]:typeof l=="function"&&(T=l(h)),i.has(T)?(w&&(n.path=`${d}${y}.${l}`),f=[!1,[_(n,w?`Type '${R.t?.[l]?.e}' with value "${T}" is not unique`:typeof l=="function"?`Type '${R.e}' unique fn return with value "${T}" is not unique`:`${R.e} value is not unique`)]]):i.add(T)}let[x,$]=f;if(x)p.push($);else if(s){o.push($.map(T=>_(n,T)));continue}else return{errors:$.map(T=>_(n,T))}}if(o.length>0){if(p.length===0)return{errors:o.slice(0,5).flat()};O(n,o.flat())}return{data:p}}function ae(e,r){return P(e,r?.unique),{...u,e:`${e.e}[]`,r(n,s){return c(this,n,s,()=>Array.isArray(n)?n.length===0?!0:m.call(this,n,e,s,!1,r):!1)}}}function oe(e,r){return P(e,r?.unique),{...u,e:`${e.e}[]`,r(n,s){return c(this,n,s,()=>Array.isArray(n)?n.length===0?!0:m.call(this,n,e,s,!0,r):!1)}}}function ie(e){return{...u,e:`[${e.map(r=>r.e).join(", ")}]`,r(r,n){return c(this,r,n,()=>!Array.isArray(r)||r.length!==e.length?!1:m.call(this,r,e,n))}}}function A(e,r){let n={warnings:[],path:""},[s,t]=r.r(e,n);return s?{error:!1,data:t,warnings:n.warnings.length>0?n.warnings:!1}:{error:!0,errors:t}}function ue(e){return r=>A(r,e)}function ce(e,r){let n=A(e,r);return n.error?{data:null,errors:n.errors,warnings:!1}:{data:n.data,errors:!1,warnings:n.warnings}}function W(e,r){let n={warnings:[],path:""};return!!r.r(e,n)[0]}function le(e){return r=>W(r,e)}function ye(e){return{...u,e:"recursive",r(r,n){return e().r(r,n)}}}function fe(e,r){return{...u,e:`transform_from_${e.e}`,r(n,s){let[t,a]=e.r(n,s);return t?[!0,r(a)]:[!1,a]}}}function I(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 S(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function U(e){return e.replace(/\W+/g," ").split(/ |\B(?=[A-Z])/).map(r=>r.toLowerCase()).join("_")}export{B as a,z as b,D as c,M as d,L as e,Z as f,G as g,H as h,J as i,Q as j,X as k,F as l,Y as m,k as n,ee as o,re as p,ne as q,te as r,se as s,ae as t,oe as u,ie as v,A as w,ue as x,ce as y,W as z,le as A,ye as B,fe as C,U as D};
|