runcheck 0.16.0 → 0.18.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
@@ -104,18 +104,6 @@ const shape = rc_record(rc_number)
104
104
  // shape type is `Record<string, number>`
105
105
  ```
106
106
 
107
- ## `rc_rename_key`
108
-
109
- Allows to rename a key in a object. Example:
110
-
111
- ```ts
112
- const shape = rc_object({
113
- name: rc_rename_key('oldName', rc_string), // oldName will be renamed to name
114
- age: rc_number,
115
- isCool: rc_boolean,
116
- })
117
- ```
118
-
119
107
  # Parsing
120
108
 
121
109
  ```ts
@@ -132,7 +120,7 @@ if (parseResult.error) {
132
120
 
133
121
  const result = parseResult.data
134
122
  // Do something with result
135
- ````
123
+ ```
136
124
 
137
125
  You can also use `rc_parser` to create a reusable parser.
138
126
 
@@ -226,6 +214,20 @@ const input = 1
226
214
  const positiveNumberType = rc_number.where((input) => input > 0)
227
215
  ```
228
216
 
217
+ # Infer types from schemas
218
+
219
+ You can use `RcInferType<typeof T>` to infer the types from a schema.
220
+
221
+ ```ts
222
+ const schema = rc_object({
223
+ name: rc_string,
224
+ age: rc_number,
225
+ isCool: rc_boolean,
226
+ })
227
+
228
+ export type Person = RcInferType<typeof schema>
229
+ ```
230
+
229
231
  # Type modifiers
230
232
 
231
233
  You can use also modiers like `rc_string.optional()` to extend or modify the rc types:
@@ -267,7 +269,53 @@ You can use `rc_transform` to validate an input and transform it to another data
267
269
  ```ts
268
270
  const input = 'hello'
269
271
 
270
- const result = rc_parse(input, rc_transform(rc_string, (input) => input.length))
272
+ const result = rc_parse(
273
+ input,
274
+ rc_transform(rc_string, (input) => input.length),
275
+ )
276
+ ```
277
+
278
+ # Advanced object types
279
+
280
+ ## `rc_rename_key`
281
+
282
+ Allows to rename a key in a object. Example:
271
283
 
284
+ ```ts
285
+ const shape = rc_object({
286
+ name: rc_rename_key('oldName', rc_string), // oldName will be renamed to name
287
+ age: rc_number,
288
+ isCool: rc_boolean,
289
+ })
290
+ ```
291
+
292
+ ## Snake case normalization
293
+
294
+ you can use `rc_object` with the `normalizeKeysFrom` option to normalize the keys of a object to snake case.
295
+
296
+ ```ts
297
+ const shape = rc_object(
298
+ {
299
+ name: rc_string,
300
+ age: rc_number,
301
+ isCool: rc_boolean,
302
+ },
303
+ { normalizeKeysFrom: 'snake_case' },
304
+ )
305
+
306
+ rc_parse({ name: 'John', age: 20, is_cool: true }, shape) // will not return an error and will normalize the response to { name: 'John', age: 20, isCool: true }
307
+ ```
308
+
309
+ ## `rc_get_obj_schema`
310
+
311
+ Allows to get a subset of a object schema. Example:
312
+
313
+ ```ts
314
+ const shape = rc_object({
315
+ name: rc_string,
316
+ age: rc_number,
317
+ isCool: rc_boolean,
318
+ })
272
319
 
320
+ const nameSchema = rc_get_obj_schema(shape).name
273
321
  ```
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var d=(e,r)=>{for(var t in r)u(e,t,{get:r[t],enumerable:!0})},R=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of T(r))!p.call(e,n)&&n!==t&&u(e,n,{get:()=>r[n],enumerable:!(i=y(r,n))||i.enumerable});return e};var h=e=>R(u({},"__esModule",{value:!0}),e);var P={};d(P,{rc_boolean_autofix:()=>k,rc_number_autofix:()=>A,rc_string_autofix:()=>O});module.exports=h(P);function _(e){return{...this,o:e}}function a(e,r,t,i){if(e.u&&r===void 0)return[!0,r];if(e.c&&r==null)return[!0,r];if(e.l&&r===null)return[!0,r];let n=i();if(n&&(n===!0||"data"in n)){let s=n===!0?r:n.data;return e.t&&!e.t(s)?[!1,[e.n(s)]]:[!0,s]}if(e.o!==void 0)return t.warnings.push(`Fallback used, ${e.n(r)}`),[!0,e.o];if(e.f&&e.i){let s=e.i(r);if(s)return e.t&&!e.t(s.fixed)?[!1,[e.n(s.fixed)]]:(t.warnings.push(`${t.path?`$${t.path}: `:""}Autofixed from error "${e.n(r)}"`),[!0,s.fixed])}return[!1,n&&"errors"in n?n.errors:[e.n(r)]]}function b(e){return{...this,f:!0,i:e}}function g(e){return{...this,t:e,e:`${this.e}_with_predicate`}}function x(){return{...this,u:!0}}function w(e){return`Type '${j(e)}' is not assignable to '${this.e}'`}function $(){return{...this,l:!0,e:`${this.e}_or_nullable`}}function m(){return{...this,c:!0,e:`${this.e}_or_nullish`}}var o={withFallback:_,where:g,optional:x,n:w,nullable:$,withAutofix:b,nullish:m},N={...o,r(e,r){return a(this,e,r,()=>e===void 0)},e:"undefined"},V={...o,r(e,r){return a(this,e,r,()=>e===null)},e:"null"},I={...o,r(e,r){return a(this,e,r,()=>!0)},e:"any"},q={...o,r(e,r){return a(this,e,r,()=>!0)},e:"unknown"},c={...o,r(e,r){return a(this,e,r,()=>typeof e=="boolean")},e:"boolean"},l={...o,r(e,r){return a(this,e,r,()=>typeof e=="string")},e:"string"},f={...o,r(e,r){return a(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},E={...o,r(e,r){return a(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=c.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=f.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 y=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var d=(e,r)=>{for(var t in r)c(e,t,{get:r[t],enumerable:!0})},R=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of T(r))!p.call(e,n)&&n!==t&&c(e,n,{get:()=>r[n],enumerable:!(i=y(r,n))||i.enumerable});return e};var h=e=>R(c({},"__esModule",{value:!0}),e);var P={};d(P,{rc_boolean_autofix:()=>k,rc_number_autofix:()=>A,rc_string_autofix:()=>O});module.exports=h(P);function _(e){return{...this,o:e}}function a(e,r,t,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 s=n===!0?r:n.data;return e.s&&!e.s(s)?[!1,[e.n(s)]]:[!0,s]}if(e.o!==void 0)return t.warnings.push(`Fallback used, ${e.n(r)}`),[!0,e.o];if(e.f&&e.i){let s=e.i(r);if(s)return e.s&&!e.s(s.fixed)?[!1,[e.n(s.fixed)]]:(t.warnings.push(`${t.path?`$${t.path}: `:""}Autofixed from error "${e.n(r)}"`),[!0,s.fixed])}return[!1,n&&"errors"in n?n.errors:[e.n(r)]]}function b(e){return{...this,f:!0,i:e}}function g(e){return{...this,s:e,e:`${this.e}_with_predicate`}}function x(){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:_,where:g,optional:x,n:w,nullable:m,withAutofix:b,nullish:$},N={...o,r(e,r){return a(this,e,r,()=>e===void 0)},e:"undefined"},V={...o,r(e,r){return a(this,e,r,()=>e===null)},e:"null"},I={...o,r(e,r){return a(this,e,r,()=>!0)},e:"any"},q={...o,r(e,r){return a(this,e,r,()=>!0)},e:"unknown"},u={...o,r(e,r){return a(this,e,r,()=>typeof e=="boolean")},e:"boolean"},l={...o,r(e,r){return a(this,e,r,()=>typeof e=="string")},e:"string"},f={...o,r(e,r){return a(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},E={...o,r(e,r){return a(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=f.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-IJ6UETTS.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-65SEYLTW.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 S(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.s&&!e.s(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.f&&e.i){let a=e.i(r);if(a)return e.s&&!e.s(a.fixed)?[!1,[e.n(a.fixed)]]:(n.warnings.push(`${n.path?`$${n.path}: `:""}Autofixed from error "${e.n(r)}"`),[!0,a.fixed])}return[!1,s&&"errors"in s?s.errors:[e.n(r)]]}function V(e){return{...this,f:!0,i:e}}function I(e){return{...this,s:e,e:`${this.e}_with_predicate`}}function q(){return{...this,c:!0}}function E(e){return`Type '${A(e)}' is not assignable to '${this.e}'`}function K(){return{...this,l:!0,e:`${this.e}_or_nullable`}}function N(){return{...this,u:!0,e:`${this.e}_or_nullish`}}var o={withFallback:S,where:I,optional:q,n:E,nullable:K,withAutofix:V,nullish:N},F={...o,r(e,r){return i(this,e,r,()=>e===void 0)},e:"undefined"},U={...o,r(e,r){return i(this,e,r,()=>e===null)},e:"null"},z={...o,r(e,r){return i(this,e,r,()=>!0)},e:"any"},B={...o,r(e,r){return i(this,e,r,()=>!0)},e:"unknown"},D={...o,r(e,r){return i(this,e,r,()=>typeof e=="boolean")},e:"boolean"},M={...o,r(e,r){return i(this,e,r,()=>typeof e=="string")},e:"string"},W={...o,r(e,r){return i(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},L={...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 G(...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?`${A(e[0])}_literal`:"literals"}}function H(...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 J(e,r){return{...r,a:e}}function g(e,r){if(!r)return e;if(e.startsWith("$[")||e.startsWith("$.")){let[n="",t]=e.split(": "),s=n.slice(1);return`$${r}${s}: ${t}`}return`$${r}: ${e}`}function k(e,{normalizeKeysFrom:r}={}){return{...o,t:e,e:"object",y:!0,r(n,t){return i(this,n,t,()=>{if(!P(n))return!1;let s=new Set(Object.keys(n)),a={},u=[],R=t.path;for(let[c,f]of Object.entries(e)){let h=c,T=`.${c}`;t.path=`${R}${T}`;let l,p=c;if(f.a&&(l=n[f.a],p=f.a),l===void 0&&(l=n[c],p=c),l===void 0&&r==="snake_case"){let y=C(c);l=n[y],p=y}s.delete(p);let[b,_]=f.r(l,t);if(b)a[h]=_;else{let y=_;for(let x of y)u.push(g(x,T))}}if(this.e==="strict_obj"&&s.size>0)for(let c of s)u.push(`Key '${c}' is not defined in the object shape`);return u.length>0?{errors:u}:{data:a}})}}}function Q(e){return e.t}function X(e){return{...k(e),e:"strict_obj"}}function Y(e,r){return k({...e.t,...r.t})}function ee(e){return{...o,e:`record<string, ${e.e}>`,r(r,n){return i(this,r,n,()=>{if(!P(r))return!1;let t={},s=[];for(let[a,u]of Object.entries(r)){let R=r[a],[c,f]=e.r(u,n);if(c)t[a]=R;else{let h=f;for(let T of h)s.push(g(T,`.${a}`))}}return s.length>0?{errors:s}:{data:t}})}}}function m(e,r){if(typeof r=="string"&&!e.t?.[r])throw new Error(`${e.e} can't be used with unique key option`)}function $(e,r,n,t=!1,s){let a=-1,u=[],R=[],c=new Set,f=n.path;for(let h of e){a++;let T=Array.isArray(r)?r[a]:r,l=`[${a}]`;n.path=`${f}${l}`;let p=T.r(h,n),[b,_]=p,y=s?.unique;if(b&&y){let d=_,j=typeof y=="string";j&&(d=_[y]),c.has(d)?p=[!1,[j?g(`Type '${T.t?.[y]?.e}' with value "${d}" is not unique`,`.${y}`):`${T.e} value is not unique`]]:c.add(d)}let[x,w]=p;if(x)R.push(w);else if(t){u.push(w.map(d=>g(d,l)));continue}else return{errors:w.map(d=>g(d,l))}}if(u.length>0){if(R.length===0)return{errors:u.slice(0,5).flat()};n.warnings.push(...u.flat())}return{data:R}}function re(e,r){return m(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 ne(e,r){return m(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 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:$.call(this,r,e,n))}}}function O(e,r){let n={warnings:[],path:""},[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=>O(r,e)}function ae(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 v(e,r){let n={warnings:[],path:""};return!!r.r(e,n)[0]}function oe(e){return r=>v(r,e)}function ie(e){return{...o,e:"recursive",r(r,n){return e().r(r,n)}}}function ce(e,r){return{...o,e:`transform_from_${e.e}`,r(n,t){let[s,a]=e.r(n,t);return s?[!0,r(a)]:[!1,a]}}}function A(e){if(typeof e=="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return typeof e}function P(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function C(e){return e.replace(/\W+/g," ").split(/ |\B(?=[A-Z])/).map(r=>r.toLowerCase()).join("_")}export{F as a,U as b,z as c,B as d,D as e,M as f,W as g,L as h,Z as i,G as j,H as k,J as l,k as m,Q as n,X as o,Y as p,ee as q,re as r,ne as s,te as t,O as u,se as v,ae as w,v as x,oe as y,ie as z,ce as A,C as B};
package/dist/runcheck.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var w=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var N=(e,r)=>{for(var n in r)w(e,n,{get:r[n],enumerable:!0})},v=(e,r,n,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of q(r))!E.call(e,t)&&t!==n&&w(e,t,{get:()=>r[t],enumerable:!(s=I(r,t))||s.enumerable});return e};var K=e=>v(w({},"__esModule",{value:!0}),e);var pe={};N(pe,{rc_any:()=>H,rc_array:()=>oe,rc_boolean:()=>L,rc_date:()=>Y,rc_instanceof:()=>Z,rc_is_valid:()=>A,rc_literals:()=>ee,rc_loose_array:()=>ie,rc_loose_parse:()=>le,rc_null:()=>G,rc_number:()=>X,rc_obj_intersection:()=>se,rc_object:()=>$,rc_parse:()=>k,rc_parser:()=>ue,rc_record:()=>ae,rc_recursive:()=>fe,rc_rename_key:()=>ne,rc_strict_obj:()=>te,rc_string:()=>Q,rc_transform:()=>Te,rc_tuple:()=>ce,rc_undefined:()=>W,rc_union:()=>re,rc_unknown:()=>J,rc_validator:()=>ye});module.exports=K(pe);function F(e){return{...this,o:e}}function i(e,r,n,s){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 t=s();if(t&&(t===!0||"data"in t)){let a=t===!0?r:t.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(`${n.path?`$${n.path}: `:""}Autofixed from error "${e.n(r)}"`),[!0,a.fixed])}return[!1,t&&"errors"in t?t.errors:[e.n(r)]]}function C(e){return{...this,y:!0,i:e}}function U(e){return{...this,t:e,e:`${this.e}_with_predicate`}}function z(){return{...this,c:!0}}function B(e){return`Type '${P(e)}' is not assignable to '${this.e}'`}function D(){return{...this,l:!0,e:`${this.e}_or_nullable`}}function M(){return{...this,u:!0,e:`${this.e}_or_nullish`}}var o={withFallback:F,where:U,optional:z,n:B,nullable:D,withAutofix:C,nullish:M},W={...o,r(e,r){return i(this,e,r,()=>e===void 0)},e:"undefined"},G={...o,r(e,r){return i(this,e,r,()=>e===null)},e:"null"},H={...o,r(e,r){return i(this,e,r,()=>!0)},e:"any"},J={...o,r(e,r){return i(this,e,r,()=>!0)},e:"unknown"},L={...o,r(e,r){return i(this,e,r,()=>typeof e=="boolean")},e:"boolean"},Q={...o,r(e,r){return i(this,e,r,()=>typeof e=="string")},e:"string"},X={...o,r(e,r){return i(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},Y={...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 ee(...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 s of e)if(r===s)return!0;return!1})},e:e.length==1?`${P(e[0])}_literal`:"literals"}}function re(...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 s of e)if(s.r(r,n)[0])return!0;return!1})},e:e.map(r=>r.e).join(" | ")}}function ne(e,r){return{...r,a:e}}function _(e,r){if(!r)return e;if(e.startsWith("$[")||e.startsWith("$.")){let[n="",s]=e.split(": "),t=n.slice(1);return`$${r}${t}: ${s}`}return`$${r}: ${e}`}function $(e){return{...o,s:e,e:"object",f:!0,r(r,n){return i(this,r,n,()=>{if(!S(r))return!1;let s=new Set(Object.keys(r)),t={},a=[],y=n.path;for(let[c,l]of Object.entries(e)){let R=c,d=`.${c}`;n.path=`${y}${d}`;let u,T=c;l.a?(u=r[l.a],T=l.a,u===void 0&&(u=r[c],T=c)):u=r[c],s.delete(T);let[h,b]=l.r(u,n);if(h)t[R]=b;else{let g=b;for(let p of g)a.push(_(p,d))}}if(this.e==="strict_obj"&&s.size>0)for(let c of s)a.push(`Key '${c}' is not defined in the object shape`);return a.length>0?{errors:a}:{data:t}})}}}function te(e){return{...$(e),e:"strict_obj"}}function se(e,r){return $({...e.s,...r.s})}function ae(e){return{...o,e:`record<string, ${e.e}>`,r(r,n){return i(this,r,n,()=>{if(!S(r))return!1;let s={},t=[];for(let[a,y]of Object.entries(r)){let c=r[a],[l,R]=e.r(y,n);if(l)s[a]=c;else{let d=R;for(let u of d)t.push(_(u,`.${a}`))}}return t.length>0?{errors:t}:{data:s}})}}}function O(e,r){if(typeof r=="string"&&!e.s?.[r])throw new Error(`${e.e} can't be used with unique key option`)}function j(e,r,n,s=!1,t){let a=-1,y=[],c=[],l=new Set,R=n.path;for(let d of e){a++;let u=Array.isArray(r)?r[a]:r,T=`[${a}]`;n.path=`${R}${T}`;let h=u.r(d,n),[b,g]=h,p=t?.unique;if(b&&p){let f=g,m=typeof p=="string";m&&(f=g[p]),l.has(f)?h=[!1,[m?_(`Type '${u.s?.[p]?.e}' with value "${f}" is not unique`,`.${p}`):`${u.e} value is not unique`]]:l.add(f)}let[V,x]=h;if(V)c.push(x);else if(s){y.push(x.map(f=>_(f,T)));continue}else return{errors:x.map(f=>_(f,T))}}if(y.length>0){if(c.length===0)return{errors:y.slice(0,5).flat()};n.warnings.push(...y.flat())}return{data:c}}function oe(e,r){return O(e,r?.unique),{...o,e:`${e.e}[]`,r(n,s){return i(this,n,s,()=>Array.isArray(n)?n.length===0?!0:j.call(this,n,e,s,!1,r):!1)}}}function ie(e,r){return O(e,r?.unique),{...o,e:`${e.e}[]`,r(n,s){return i(this,n,s,()=>Array.isArray(n)?n.length===0?!0:j.call(this,n,e,s,!0,r):!1)}}}function ce(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:j.call(this,r,e,n))}}}function k(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=>k(r,e)}function le(e,r){let n=k(e,r);return n.error?{data:null,errors:n.errors,warnings:!1}:{data:n.data,errors:!1,warnings:n.warnings}}function A(e,r){let n={warnings:[],path:""};return!!r.r(e,n)[0]}function ye(e){return r=>A(r,e)}function fe(e){return{...o,e:"recursive",r(r,n){return e().r(r,n)}}}function Te(e,r){return{...o,e:`transform_from_${e.e}`,r(n,s){let[t,a]=e.r(n,s);return t?[!0,r(a)]:[!1,a]}}}function P(e){if(typeof e=="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return typeof e}function S(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 q=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var N=(e,r)=>{for(var n in r)$(e,n,{get:r[n],enumerable:!0})},v=(e,r,n,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of E(r))!K.call(e,t)&&t!==n&&$(e,t,{get:()=>r[t],enumerable:!(s=q(r,t))||s.enumerable});return e};var C=e=>v($({},"__esModule",{value:!0}),e);var Re={};N(Re,{rc_any:()=>G,rc_array:()=>ce,rc_boolean:()=>J,rc_date:()=>Y,rc_get_obj_schema:()=>se,rc_instanceof:()=>ee,rc_is_valid:()=>P,rc_literals:()=>re,rc_loose_array:()=>ue,rc_loose_parse:()=>fe,rc_null:()=>Z,rc_number:()=>X,rc_obj_intersection:()=>oe,rc_object:()=>j,rc_parse:()=>m,rc_parser:()=>ye,rc_record:()=>ie,rc_recursive:()=>pe,rc_rename_key:()=>te,rc_strict_obj:()=>ae,rc_string:()=>Q,rc_transform:()=>de,rc_tuple:()=>le,rc_undefined:()=>L,rc_union:()=>ne,rc_unknown:()=>H,rc_validator:()=>Te,snakeCase:()=>I});module.exports=C(Re);function F(e){return{...this,o:e}}function i(e,r,n,s){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 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.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.s&&!e.s(a.fixed)?[!1,[e.n(a.fixed)]]:(n.warnings.push(`${n.path?`$${n.path}: `:""}Autofixed from error "${e.n(r)}"`),[!0,a.fixed])}return[!1,t&&"errors"in t?t.errors:[e.n(r)]]}function U(e){return{...this,y:!0,i:e}}function z(e){return{...this,s:e,e:`${this.e}_with_predicate`}}function B(){return{...this,c:!0}}function D(e){return`Type '${S(e)}' is not assignable to '${this.e}'`}function M(){return{...this,l:!0,e:`${this.e}_or_nullable`}}function W(){return{...this,u:!0,e:`${this.e}_or_nullish`}}var o={withFallback:F,where:z,optional:B,n:D,nullable:M,withAutofix:U,nullish:W},L={...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"},G={...o,r(e,r){return i(this,e,r,()=>!0)},e:"any"},H={...o,r(e,r){return i(this,e,r,()=>!0)},e:"unknown"},J={...o,r(e,r){return i(this,e,r,()=>typeof e=="boolean")},e:"boolean"},Q={...o,r(e,r){return i(this,e,r,()=>typeof e=="string")},e:"string"},X={...o,r(e,r){return i(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},Y={...o,r(e,r){return i(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function ee(e){return{...o,r(r,n){return i(this,r,n,()=>r instanceof e)},e:`instanceof_${e.name?`_${e.name}`:""}`}}function re(...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 s of e)if(r===s)return!0;return!1})},e:e.length==1?`${S(e[0])}_literal`:"literals"}}function ne(...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 s of e)if(s.r(r,n)[0])return!0;return!1})},e:e.map(r=>r.e).join(" | ")}}function te(e,r){return{...r,a:e}}function g(e,r){if(!r)return e;if(e.startsWith("$[")||e.startsWith("$.")){let[n="",s]=e.split(": "),t=n.slice(1);return`$${r}${t}: ${s}`}return`$${r}: ${e}`}function j(e,{normalizeKeysFrom:r}={}){return{...o,t:e,e:"object",f:!0,r(n,s){return i(this,n,s,()=>{if(!V(n))return!1;let t=new Set(Object.keys(n)),a={},u=[],R=s.path;for(let[c,f]of Object.entries(e)){let h=c,T=`.${c}`;s.path=`${R}${T}`;let l,p=c;if(f.a&&(l=n[f.a],p=f.a),l===void 0&&(l=n[c],p=c),l===void 0&&r==="snake_case"){let y=I(c);l=n[y],p=y}t.delete(p);let[b,_]=f.r(l,s);if(b)a[h]=_;else{let y=_;for(let x of y)u.push(g(x,T))}}if(this.e==="strict_obj"&&t.size>0)for(let c of t)u.push(`Key '${c}' is not defined in the object shape`);return u.length>0?{errors:u}:{data:a}})}}}function se(e){return e.t}function ae(e){return{...j(e),e:"strict_obj"}}function oe(e,r){return j({...e.t,...r.t})}function ie(e){return{...o,e:`record<string, ${e.e}>`,r(r,n){return i(this,r,n,()=>{if(!V(r))return!1;let s={},t=[];for(let[a,u]of Object.entries(r)){let R=r[a],[c,f]=e.r(u,n);if(c)s[a]=R;else{let h=f;for(let T of h)t.push(g(T,`.${a}`))}}return t.length>0?{errors:t}:{data:s}})}}}function A(e,r){if(typeof r=="string"&&!e.t?.[r])throw new Error(`${e.e} can't be used with unique key option`)}function k(e,r,n,s=!1,t){let a=-1,u=[],R=[],c=new Set,f=n.path;for(let h of e){a++;let T=Array.isArray(r)?r[a]:r,l=`[${a}]`;n.path=`${f}${l}`;let p=T.r(h,n),[b,_]=p,y=t?.unique;if(b&&y){let d=_,O=typeof y=="string";O&&(d=_[y]),c.has(d)?p=[!1,[O?g(`Type '${T.t?.[y]?.e}' with value "${d}" is not unique`,`.${y}`):`${T.e} value is not unique`]]:c.add(d)}let[x,w]=p;if(x)R.push(w);else if(s){u.push(w.map(d=>g(d,l)));continue}else return{errors:w.map(d=>g(d,l))}}if(u.length>0){if(R.length===0)return{errors:u.slice(0,5).flat()};n.warnings.push(...u.flat())}return{data:R}}function ce(e,r){return A(e,r?.unique),{...o,e:`${e.e}[]`,r(n,s){return i(this,n,s,()=>Array.isArray(n)?n.length===0?!0:k.call(this,n,e,s,!1,r):!1)}}}function ue(e,r){return A(e,r?.unique),{...o,e:`${e.e}[]`,r(n,s){return i(this,n,s,()=>Array.isArray(n)?n.length===0?!0:k.call(this,n,e,s,!0,r):!1)}}}function le(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:k.call(this,r,e,n))}}}function m(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 ye(e){return r=>m(r,e)}function fe(e,r){let n=m(e,r);return n.error?{data:null,errors:n.errors,warnings:!1}:{data:n.data,errors:!1,warnings:n.warnings}}function P(e,r){let n={warnings:[],path:""};return!!r.r(e,n)[0]}function Te(e){return r=>P(r,e)}function pe(e){return{...o,e:"recursive",r(r,n){return e().r(r,n)}}}function de(e,r){return{...o,e:`transform_from_${e.e}`,r(n,s){let[t,a]=e.r(n,s);return t?[!0,r(a)]:[!1,a]}}}function S(e){if(typeof e=="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return typeof e}function V(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function I(e){return e.replace(/\W+/g," ").split(/ |\B(?=[A-Z])/).map(r=>r.toLowerCase()).join("_")}0&&(module.exports={rc_any,rc_array,rc_boolean,rc_date,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_key,rc_strict_obj,rc_string,rc_transform,rc_tuple,rc_undefined,rc_union,rc_unknown,rc_validator,snakeCase});
@@ -11,8 +11,11 @@ type RcOptional<T> = RcType<T | undefined>;
11
11
  type RcType<T> = {
12
12
  readonly withFallback: (fallback: T) => RcType<T>;
13
13
  readonly where: (predicate: (input: T) => boolean) => RcType<T>;
14
+ /** RcType | undefined */
14
15
  readonly optional: () => RcOptional<T>;
16
+ /** RcType | null */
15
17
  readonly nullable: () => RcType<T | null>;
18
+ /** RcType | null | undefined */
16
19
  readonly nullish: () => RcType<T | null | undefined>;
17
20
  readonly withAutofix: (customAutofix: (input: unknown) => false | {
18
21
  fixed: T;
@@ -35,7 +38,10 @@ type TypeOfObjectType<T extends RcObject> = {
35
38
  [K in keyof T]: RcInferType<T[K]>;
36
39
  };
37
40
  type RcObjType<T extends RcObject> = RcType<TypeOfObjectType<T>>;
38
- declare function rc_object<T extends RcObject>(shape: T): RcObjType<T>;
41
+ declare function rc_object<T extends RcObject>(shape: T, { normalizeKeysFrom }?: {
42
+ normalizeKeysFrom?: 'snake_case';
43
+ }): RcObjType<T>;
44
+ declare function rc_get_obj_schema<T extends RcObject>(type: RcObjType<T>): T;
39
45
  /** return an error if the obj has more keys than the expected type */
40
46
  declare function rc_strict_obj<T extends RcObject>(shape: T): RcObjType<T>;
41
47
  declare function rc_obj_intersection<A extends RcObject, B extends RcObject>(a: RcObjType<A>, b: RcObjType<B>): RcObjType<A & B>;
@@ -78,4 +84,4 @@ declare function rc_recursive(type: () => RcType<any>): RcType<any>;
78
84
  /** validate a input or subset of input and transform the valid result */
79
85
  declare function rc_transform<Input, Transformed>(type: RcType<Input>, transform: (input: Input) => Transformed): RcType<Transformed>;
80
86
 
81
- export { RcInferType, RcParseResult, RcParser, RcType, 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 };
87
+ export { RcInferType, RcParseResult, RcParser, RcType, rc_any, rc_array, rc_boolean, rc_date, 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_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-IJ6UETTS.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,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-65SEYLTW.js";export{c as rc_any,r as rc_array,e as rc_boolean,h as rc_date,n as rc_get_obj_schema,i as rc_instanceof,x as rc_is_valid,j as rc_literals,s as rc_loose_array,w as rc_loose_parse,b as rc_null,g as rc_number,p as rc_obj_intersection,m as rc_object,u as rc_parse,v as rc_parser,q as rc_record,z as rc_recursive,l as rc_rename_key,o as rc_strict_obj,f as rc_string,A as rc_transform,t as rc_tuple,a as rc_undefined,k as rc_union,d as rc_unknown,y as rc_validator,B as snakeCase};
package/package.json CHANGED
@@ -1,14 +1,17 @@
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.16.0",
4
+ "version": "0.18.0",
5
5
  "license": "MIT",
6
6
  "scripts": {
7
7
  "test": "vitest --ui",
8
8
  "test:run": "vitest run",
9
+ "lint": "pnpm tsc && pnpm eslint",
10
+ "tsc": "tsc -p tsconfig.prod.json",
9
11
  "benchmark": "tsm benchmarks/benchmark.ts",
10
12
  "benchmark:generate-profile": "tsm benchmarks/generateProfiles.ts",
11
- "build": "pnpm test:run && pnpm build:no-test",
13
+ "eslint": "CI=true eslint --color --ext .jsx,.js,.ts,.tsx src/ tests/",
14
+ "build": "pnpm test:run && pnpm lint && pnpm build:no-test",
12
15
  "build:no-test": "tsup --minify --dts",
13
16
  "npm-publish": "./scripts/check-if-is-sync.sh && pnpm build && npm publish"
14
17
  },
@@ -1 +0,0 @@
1
- function S(e){return{...this,o:e}}function i(e,r,n,t){if(e.u&&r===void 0)return[!0,r];if(e.c&&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.f&&e.i){let a=e.i(r);if(a)return e.t&&!e.t(a.fixed)?[!1,[e.n(a.fixed)]]:(n.warnings.push(`${n.path?`$${n.path}: `:""}Autofixed from error "${e.n(r)}"`),[!0,a.fixed])}return[!1,s&&"errors"in s?s.errors:[e.n(r)]]}function V(e){return{...this,f:!0,i:e}}function I(e){return{...this,t:e,e:`${this.e}_with_predicate`}}function q(){return{...this,u:!0}}function E(e){return`Type '${O(e)}' is not assignable to '${this.e}'`}function N(){return{...this,l:!0,e:`${this.e}_or_nullable`}}function v(){return{...this,c:!0,e:`${this.e}_or_nullish`}}var o={withFallback:S,where:I,optional:q,n:E,nullable:N,withAutofix:V,nullish:v},F={...o,r(e,r){return i(this,e,r,()=>e===void 0)},e:"undefined"},C={...o,r(e,r){return i(this,e,r,()=>e===null)},e:"null"},U={...o,r(e,r){return i(this,e,r,()=>!0)},e:"any"},z={...o,r(e,r){return i(this,e,r,()=>!0)},e:"unknown"},B={...o,r(e,r){return i(this,e,r,()=>typeof e=="boolean")},e:"boolean"},D={...o,r(e,r){return i(this,e,r,()=>typeof e=="string")},e:"string"},M={...o,r(e,r){return i(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},W={...o,r(e,r){return i(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function G(e){return{...o,r(r,n){return i(this,r,n,()=>r instanceof e)},e:`instanceof_${e.name?`_${e.name}`:""}`}}function H(...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?`${O(e[0])}_literal`:"literals"}}function J(...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 L(e,r){return{...r,a:e}}function _(e,r){if(!r)return e;if(e.startsWith("$[")||e.startsWith("$.")){let[n="",t]=e.split(": "),s=n.slice(1);return`$${r}${s}: ${t}`}return`$${r}: ${e}`}function j(e){return{...o,s:e,e:"object",y:!0,r(r,n){return i(this,r,n,()=>{if(!A(r))return!1;let t=new Set(Object.keys(r)),s={},a=[],y=n.path;for(let[c,l]of Object.entries(e)){let R=c,d=`.${c}`;n.path=`${y}${d}`;let u,T=c;l.a?(u=r[l.a],T=l.a,u===void 0&&(u=r[c],T=c)):u=r[c],t.delete(T);let[h,b]=l.r(u,n);if(h)s[R]=b;else{let g=b;for(let p of g)a.push(_(p,d))}}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 Q(e){return{...j(e),e:"strict_obj"}}function X(e,r){return j({...e.s,...r.s})}function Y(e){return{...o,e:`record<string, ${e.e}>`,r(r,n){return i(this,r,n,()=>{if(!A(r))return!1;let t={},s=[];for(let[a,y]of Object.entries(r)){let c=r[a],[l,R]=e.r(y,n);if(l)t[a]=c;else{let d=R;for(let u of d)s.push(_(u,`.${a}`))}}return s.length>0?{errors:s}:{data:t}})}}}function k(e,r){if(typeof r=="string"&&!e.s?.[r])throw new Error(`${e.e} can't be used with unique key option`)}function w(e,r,n,t=!1,s){let a=-1,y=[],c=[],l=new Set,R=n.path;for(let d of e){a++;let u=Array.isArray(r)?r[a]:r,T=`[${a}]`;n.path=`${R}${T}`;let h=u.r(d,n),[b,g]=h,p=s?.unique;if(b&&p){let f=g,$=typeof p=="string";$&&(f=g[p]),l.has(f)?h=[!1,[$?_(`Type '${u.s?.[p]?.e}' with value "${f}" is not unique`,`.${p}`):`${u.e} value is not unique`]]:l.add(f)}let[P,x]=h;if(P)c.push(x);else if(t){y.push(x.map(f=>_(f,T)));continue}else return{errors:x.map(f=>_(f,T))}}if(y.length>0){if(c.length===0)return{errors:y.slice(0,5).flat()};n.warnings.push(...y.flat())}return{data:c}}function Z(e,r){return k(e,r?.unique),{...o,e:`${e.e}[]`,r(n,t){return i(this,n,t,()=>Array.isArray(n)?n.length===0?!0:w.call(this,n,e,t,!1,r):!1)}}}function ee(e,r){return k(e,r?.unique),{...o,e:`${e.e}[]`,r(n,t){return i(this,n,t,()=>Array.isArray(n)?n.length===0?!0:w.call(this,n,e,t,!0,r):!1)}}}function re(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:w.call(this,r,e,n))}}}function m(e,r){let n={warnings:[],path:""},[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 ne(e){return r=>m(r,e)}function te(e,r){let n=m(e,r);return n.error?{data:null,errors:n.errors,warnings:!1}:{data:n.data,errors:!1,warnings:n.warnings}}function K(e,r){let n={warnings:[],path:""};return!!r.r(e,n)[0]}function se(e){return r=>K(r,e)}function ae(e){return{...o,e:"recursive",r(r,n){return e().r(r,n)}}}function oe(e,r){return{...o,e:`transform_from_${e.e}`,r(n,t){let[s,a]=e.r(n,t);return s?[!0,r(a)]:[!1,a]}}}function O(e){if(typeof e=="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return typeof e}function A(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}export{F as a,C as b,U as c,z as d,B as e,D as f,M as g,W as h,G as i,H as j,J as k,L as l,j as m,Q as n,X as o,Y as p,Z as q,ee as r,re as s,m as t,ne as u,te as v,K as w,se as x,ae as y,oe as z};