runcheck 1.16.0 → 1.17.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 +26 -0
- package/dist/autofixable.cjs +3 -3
- package/dist/autofixable.cjs.map +1 -1
- package/dist/autofixable.js +1 -1
- package/dist/chunk-523HPU74.js +4 -0
- package/dist/{chunk-D2BONWGU.js.map → chunk-523HPU74.js.map} +1 -1
- package/dist/runcheck.cjs +3 -3
- package/dist/runcheck.cjs.map +1 -1
- package/dist/runcheck.d.cts +32 -1
- package/dist/runcheck.d.ts +32 -1
- package/dist/runcheck.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-D2BONWGU.js +0 -4
package/dist/runcheck.d.cts
CHANGED
|
@@ -731,6 +731,37 @@ declare function rc_unsafe_transform<Input, Transformed>(type: RcType<Input>, tr
|
|
|
731
731
|
ok: false;
|
|
732
732
|
errors: string | string[];
|
|
733
733
|
}, { outputSchema, disableStrictOutputSchema, }?: TransformOptions<Transformed>): RcType<Transformed>;
|
|
734
|
+
/** try to fix an invalid input and revalidate the fixed value with the same schema */
|
|
735
|
+
/**
|
|
736
|
+
* Creates a type that attempts to fix an invalid input once and revalidates
|
|
737
|
+
* the fixed value against the same schema. If the fixed value is still
|
|
738
|
+
* invalid, the original result is returned. If the fix succeeds, validation
|
|
739
|
+
* passes and the original errors are reported as warnings.
|
|
740
|
+
* @param type - The type to validate against
|
|
741
|
+
* @param tryFix - Function that receives the invalid input and the errors and
|
|
742
|
+
* warnings of the failed parse. Returns `{ fixed: value }` to revalidate the
|
|
743
|
+
* fixed value, or `false` to skip fixing
|
|
744
|
+
* @returns A runcheck type that tries to fix invalid inputs
|
|
745
|
+
* @example
|
|
746
|
+
* ```typescript
|
|
747
|
+
* const schema = rc_try_fix(
|
|
748
|
+
* rc_object({ name: rc_string, age: rc_number }),
|
|
749
|
+
* (input) => {
|
|
750
|
+
* if (typeof input === 'string') {
|
|
751
|
+
* const parsed: unknown = JSON.parse(input)
|
|
752
|
+
* return { fixed: parsed }
|
|
753
|
+
* }
|
|
754
|
+
* return false
|
|
755
|
+
* },
|
|
756
|
+
* )
|
|
757
|
+
* ```
|
|
758
|
+
*/
|
|
759
|
+
declare function rc_try_fix<T>(type: RcType<T>, tryFix: (input: unknown, failedParse: {
|
|
760
|
+
errors: string[];
|
|
761
|
+
warnings: string[];
|
|
762
|
+
}) => {
|
|
763
|
+
fixed: unknown;
|
|
764
|
+
} | false): RcType<T>;
|
|
734
765
|
declare function normalizedTypeOf(input: unknown, showValueInError: boolean): string;
|
|
735
766
|
/**
|
|
736
767
|
* Assertion function that throws if the parse result contains errors.
|
|
@@ -839,4 +870,4 @@ declare function rc_from_standard<T>(standardSchema: StandardSchemaV1<any, T>,
|
|
|
839
870
|
/** use this kind instead of the default one in error messages (standard_schema_${standard.vendor}@${standard.version}) */
|
|
840
871
|
kind?: string): RcType<T>;
|
|
841
872
|
|
|
842
|
-
export { type AutoFixResult, type Prettify, type RcBase, type RcErrorResult, type RcInferType, type RcOkResult, type RcOptionalKeyType, type RcParseResult, type RcParser, type RcPrettyInferType, type RcType, RcValidationError, defaultProps, getSchemaKind, getWarningOrErrorWithPath, isRcType, joinAsRcTypeUnion, normalizedTypeOf, parse, rc_any, rc_array, rc_array_filter_from_schema, rc_assert_is_valid, rc_boolean, rc_date, rc_default, rc_disable_loose_array, rc_discriminated_union, rc_discriminated_union_builder, rc_enable_obj_strict, rc_from_standard, rc_get_array_item_type, rc_get_from_key_as_fallback, rc_get_literal_values, rc_get_obj_shape, rc_instanceof, rc_intersection, rc_is_valid, rc_literals, rc_loose_array, rc_loose_parse, rc_loose_record, rc_narrow, rc_null, rc_nullish_default, rc_number, rc_obj_builder, rc_obj_extends, rc_obj_merge, rc_obj_omit, rc_obj_pick, rc_obj_strict, rc_object, rc_parse, rc_parse_json, rc_parser, rc_record, rc_recursive, rc_safe_fallback, rc_string, rc_string_contains, rc_string_ends_with, rc_string_starts_with, rc_to_standard, rc_transform, rc_tuple, rc_undefined, rc_union, rc_unknown, rc_unsafe_transform, rc_unwrap, rc_unwrap_or, rc_unwrap_or_null, rc_validator };
|
|
873
|
+
export { type AutoFixResult, type Prettify, type RcBase, type RcErrorResult, type RcInferType, type RcOkResult, type RcOptionalKeyType, type RcParseResult, type RcParser, type RcPrettyInferType, type RcType, RcValidationError, defaultProps, getSchemaKind, getWarningOrErrorWithPath, isRcType, joinAsRcTypeUnion, normalizedTypeOf, parse, rc_any, rc_array, rc_array_filter_from_schema, rc_assert_is_valid, rc_boolean, rc_date, rc_default, rc_disable_loose_array, rc_discriminated_union, rc_discriminated_union_builder, rc_enable_obj_strict, rc_from_standard, rc_get_array_item_type, rc_get_from_key_as_fallback, rc_get_literal_values, rc_get_obj_shape, rc_instanceof, rc_intersection, rc_is_valid, rc_literals, rc_loose_array, rc_loose_parse, rc_loose_record, rc_narrow, rc_null, rc_nullish_default, rc_number, rc_obj_builder, rc_obj_extends, rc_obj_merge, rc_obj_omit, rc_obj_pick, rc_obj_strict, rc_object, rc_parse, rc_parse_json, rc_parser, rc_record, rc_recursive, rc_safe_fallback, rc_string, rc_string_contains, rc_string_ends_with, rc_string_starts_with, rc_to_standard, rc_transform, rc_try_fix, rc_tuple, rc_undefined, rc_union, rc_unknown, rc_unsafe_transform, rc_unwrap, rc_unwrap_or, rc_unwrap_or_null, rc_validator };
|
package/dist/runcheck.d.ts
CHANGED
|
@@ -731,6 +731,37 @@ declare function rc_unsafe_transform<Input, Transformed>(type: RcType<Input>, tr
|
|
|
731
731
|
ok: false;
|
|
732
732
|
errors: string | string[];
|
|
733
733
|
}, { outputSchema, disableStrictOutputSchema, }?: TransformOptions<Transformed>): RcType<Transformed>;
|
|
734
|
+
/** try to fix an invalid input and revalidate the fixed value with the same schema */
|
|
735
|
+
/**
|
|
736
|
+
* Creates a type that attempts to fix an invalid input once and revalidates
|
|
737
|
+
* the fixed value against the same schema. If the fixed value is still
|
|
738
|
+
* invalid, the original result is returned. If the fix succeeds, validation
|
|
739
|
+
* passes and the original errors are reported as warnings.
|
|
740
|
+
* @param type - The type to validate against
|
|
741
|
+
* @param tryFix - Function that receives the invalid input and the errors and
|
|
742
|
+
* warnings of the failed parse. Returns `{ fixed: value }` to revalidate the
|
|
743
|
+
* fixed value, or `false` to skip fixing
|
|
744
|
+
* @returns A runcheck type that tries to fix invalid inputs
|
|
745
|
+
* @example
|
|
746
|
+
* ```typescript
|
|
747
|
+
* const schema = rc_try_fix(
|
|
748
|
+
* rc_object({ name: rc_string, age: rc_number }),
|
|
749
|
+
* (input) => {
|
|
750
|
+
* if (typeof input === 'string') {
|
|
751
|
+
* const parsed: unknown = JSON.parse(input)
|
|
752
|
+
* return { fixed: parsed }
|
|
753
|
+
* }
|
|
754
|
+
* return false
|
|
755
|
+
* },
|
|
756
|
+
* )
|
|
757
|
+
* ```
|
|
758
|
+
*/
|
|
759
|
+
declare function rc_try_fix<T>(type: RcType<T>, tryFix: (input: unknown, failedParse: {
|
|
760
|
+
errors: string[];
|
|
761
|
+
warnings: string[];
|
|
762
|
+
}) => {
|
|
763
|
+
fixed: unknown;
|
|
764
|
+
} | false): RcType<T>;
|
|
734
765
|
declare function normalizedTypeOf(input: unknown, showValueInError: boolean): string;
|
|
735
766
|
/**
|
|
736
767
|
* Assertion function that throws if the parse result contains errors.
|
|
@@ -839,4 +870,4 @@ declare function rc_from_standard<T>(standardSchema: StandardSchemaV1<any, T>,
|
|
|
839
870
|
/** use this kind instead of the default one in error messages (standard_schema_${standard.vendor}@${standard.version}) */
|
|
840
871
|
kind?: string): RcType<T>;
|
|
841
872
|
|
|
842
|
-
export { type AutoFixResult, type Prettify, type RcBase, type RcErrorResult, type RcInferType, type RcOkResult, type RcOptionalKeyType, type RcParseResult, type RcParser, type RcPrettyInferType, type RcType, RcValidationError, defaultProps, getSchemaKind, getWarningOrErrorWithPath, isRcType, joinAsRcTypeUnion, normalizedTypeOf, parse, rc_any, rc_array, rc_array_filter_from_schema, rc_assert_is_valid, rc_boolean, rc_date, rc_default, rc_disable_loose_array, rc_discriminated_union, rc_discriminated_union_builder, rc_enable_obj_strict, rc_from_standard, rc_get_array_item_type, rc_get_from_key_as_fallback, rc_get_literal_values, rc_get_obj_shape, rc_instanceof, rc_intersection, rc_is_valid, rc_literals, rc_loose_array, rc_loose_parse, rc_loose_record, rc_narrow, rc_null, rc_nullish_default, rc_number, rc_obj_builder, rc_obj_extends, rc_obj_merge, rc_obj_omit, rc_obj_pick, rc_obj_strict, rc_object, rc_parse, rc_parse_json, rc_parser, rc_record, rc_recursive, rc_safe_fallback, rc_string, rc_string_contains, rc_string_ends_with, rc_string_starts_with, rc_to_standard, rc_transform, rc_tuple, rc_undefined, rc_union, rc_unknown, rc_unsafe_transform, rc_unwrap, rc_unwrap_or, rc_unwrap_or_null, rc_validator };
|
|
873
|
+
export { type AutoFixResult, type Prettify, type RcBase, type RcErrorResult, type RcInferType, type RcOkResult, type RcOptionalKeyType, type RcParseResult, type RcParser, type RcPrettyInferType, type RcType, RcValidationError, defaultProps, getSchemaKind, getWarningOrErrorWithPath, isRcType, joinAsRcTypeUnion, normalizedTypeOf, parse, rc_any, rc_array, rc_array_filter_from_schema, rc_assert_is_valid, rc_boolean, rc_date, rc_default, rc_disable_loose_array, rc_discriminated_union, rc_discriminated_union_builder, rc_enable_obj_strict, rc_from_standard, rc_get_array_item_type, rc_get_from_key_as_fallback, rc_get_literal_values, rc_get_obj_shape, rc_instanceof, rc_intersection, rc_is_valid, rc_literals, rc_loose_array, rc_loose_parse, rc_loose_record, rc_narrow, rc_null, rc_nullish_default, rc_number, rc_obj_builder, rc_obj_extends, rc_obj_merge, rc_obj_omit, rc_obj_pick, rc_obj_strict, rc_object, rc_parse, rc_parse_json, rc_parser, rc_record, rc_recursive, rc_safe_fallback, rc_string, rc_string_contains, rc_string_ends_with, rc_string_starts_with, rc_to_standard, rc_transform, rc_try_fix, rc_tuple, rc_undefined, rc_union, rc_unknown, rc_unsafe_transform, rc_unwrap, rc_unwrap_or, rc_unwrap_or_null, rc_validator };
|
package/dist/runcheck.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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,_,a,aa,b,ba,c,ca,d,da,e,ea,f,fa,g,ga,h,ha,i,ia,j,ja,k,ka,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,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,_,a,aa,b,ba,c,ca,d,da,e,ea,f,fa,g,ga,h,ha,i,ia,j,ja,k,ka,l,la,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-523HPU74.js";export{V as RcValidationError,p as defaultProps,ja as getSchemaKind,n as getWarningOrErrorWithPath,ea as isObject,ha as isRcType,ia as joinAsRcTypeUnion,ca as normalizedTypeOf,o as parse,s as rc_any,K as rc_array,O as rc_array_filter_from_schema,da as rc_assert_is_valid,u as rc_boolean,x as rc_date,F as rc_default,M as rc_disable_loose_array,k as rc_discriminated_union,l as rc_discriminated_union_builder,f as rc_enable_obj_strict,la as rc_from_standard,L as rc_get_array_item_type,a as rc_get_from_key_as_fallback,A as rc_get_literal_values,d as rc_get_obj_shape,y as rc_instanceof,m as rc_intersection,X as rc_is_valid,z as rc_literals,N as rc_loose_array,S as rc_loose_parse,J as rc_loose_record,$ as rc_narrow,r as rc_null,G as rc_nullish_default,w as rc_number,j as rc_obj_builder,c as rc_obj_extends,g as rc_obj_merge,i as rc_obj_omit,h as rc_obj_pick,e as rc_obj_strict,b as rc_object,Q as rc_parse,ga as rc_parse_json,R as rc_parser,I as rc_record,Z as rc_recursive,H as rc_safe_fallback,v as rc_string,D as rc_string_contains,C as rc_string_ends_with,B as rc_string_starts_with,ka as rc_to_standard,_ as rc_transform,ba as rc_try_fix,P as rc_tuple,q as rc_undefined,E as rc_union,t as rc_unknown,aa as rc_unsafe_transform,W as rc_unwrap,U as rc_unwrap_or,T as rc_unwrap_or_null,Y as rc_validator,fa as snakeCase};
|
|
2
2
|
//# sourceMappingURL=runcheck.js.map
|
package/package.json
CHANGED
package/dist/chunk-D2BONWGU.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
function G(e,r){return{...r,u:e}}function b(e){if($(e))return e;if(w(e)){let r={};for(let[n,t]of Object.entries(e))r[n]=b(t);return x(r)}else if(Array.isArray(e)){let[r,n]=e;switch(r){case"optional":return b(n).optional();case"nullish_or":return b(n).orNullish();case"null_or":return b(n).orNull();case"array_of":return P(b(n));case"loose_array_of":return S(b(n));case"optional_array_of":return P(b(n)).optional();case"optional_loose_array_of":return S(b(n)).optional();case"null_or_array_of":return P(b(n)).orNull();case"null_or_loose_array_of":return S(b(n)).orNull();case"nullish_or_array_of":return P(b(n)).orNullish();case"nullish_or_loose_array_of":return S(b(n)).orNullish();default:return r}}throw new Error(`invalid schema: ${e}`)}function x(e,{normalizeKeysFrom:r,extends:n}={}){let t={};for(let[o,a]of Object.entries(e))t[o]=b(a);let s=Object.entries(t).map(([o,a])=>({key:o,type:a}));return{...d,t,e:n?"extends_object":"object",T:"",s:!0,b:!!n,r(o,a){return u(this,o,a,()=>{if(!w(o)){if(a.a=-1,a.o&&!this.T)return!1;if(!this.T){let y=`${this.e}{ `,f=0;for(let{key:_,type:k}of s){if(y.length>100){y+=", ...";break}f!==0&&(y+=", "),y+=`${_}: ${k.e}`,f++}y+=" }",this.T=y}return{data:void 0,errors:[p(a,`Type '${j(o,!1)}' is not assignable to '${this.T}'`)]}}let i=this.e==="strict_obj"||a.i?new Set(Object.keys(o)):void 0;if(i&&i.size>s.length){a.a=-1;let y=[];if(a.o)return{data:void 0,errors:[p(a,`Expected strict object with ${s.length} keys but got ${i.size}`)]};for(let{key:f}of s)i.has(f)?i.delete(f):y.push(p(a,`Key '${f}' is missing`));for(let f of i)y.push(p(a,`Key '${f}' is not defined in the object shape`));return{data:void 0,errors:y}}let l={},h=[],g=a.n,m=-1;for(let y of s){let f=y.key,_=y.type,k=f;m+=1;let T=f===""||f.includes(" ")?`['${f}']`:`.${f}`,R=`${g}${T}`;a.n=R;let O=o[f],D=f;if(O===void 0&&_.u&&(O=o[_.u],D=_.u),O===void 0&&r==="snake_case"){let N=V(f);O=o[N],D=N}i?.delete(D);let B=_.r(O,a);if(B.ok)l[k]=B.data;else{for(let N of B.errors)a.n=R,h.push(N);if(a.o){a.a=m;break}}}if(i&&i.size>0)for(let y of i)a.n=g,h.push(p(a,`Key '${y}' is not defined in the object shape`));return h.length>0?{errors:h,data:void 0}:(a.n=g,this.b?{errors:!1,data:{...o,...l}}:{errors:!1,data:l})})}}}function H(e,r){if($(e)){if(!e.t)throw new Error("rc_obj_extends: schema must be an object type");return{...e,e:"extends_object",b:!0}}return{...x(e,r),e:"extends_object",b:!0}}function X(e){if(!e.t)throw new Error("type does not have an object shape");return e.t}function Y(e,r){return{...x(e,r),e:"strict_obj"}}function ee(e,{nonRecursive:r}={}){if(r){if(!e.t)throw new Error("rc_enable_obj_strict: nonRecursive option can only be used on object types");return{...e,e:"strict_obj"}}return{...e,r(n,t){let s=t.i;t.i=!0;let o=e.r(n,t);return t.i=s,o}}}function re(...e){let r={};for(let n of e)Object.assign(r,n.t);return x(r)}function ne(e,r){let n={};if(!e.t)throw new Error("rc_obj_pick: obj must be an object type");for(let t of r){let s=e.t[t];s&&(n[t]=s)}return x(n)}function te(e,r){let n={};if(!e.t)throw new Error("rc_obj_omit: obj must be an object type");for(let t of Object.keys(e.t))r.includes(t)||(n[t]=e.t[t]);return x(n)}function se(){return(e,r)=>x(e,r)}function F(e,r){let n={};for(let[t,s]of Object.entries(r))n[t]=$(s)?s:x(s);return{...d,e:"discriminated_union",s:!0,r(t,s){return u(this,t,s,()=>{if(!w(t))return s.a=-1,!1;let o=t[e],a=s.n,c=n[o];if(!c){let l=j(o,!0);return{errors:[p({n:`${a}.${e}`},`Type '${l}' is not a valid discriminator`)],data:void 0}}s.n=`${a}|${e}: ${o}|`;let i=c.r(t,s);return s.n=a,i.ok?(i.data[e]=o,{errors:!1,data:i.data}):{errors:i.errors,data:void 0}})}}}function oe(e){return r=>F(e,r)}function ae(...e){let r="",n=!0;for(let t of e)r&&(r+=" & "),t.s||(n=!1),r+=t.e.includes("|")?`(${t.e})`:t.e;return{...d,e:r,s:n,r(t,s){return u(this,t,s,()=>{let o=null;for(let a of e){let c=a.r(t,s);if(c.ok)a.s&&(o={...o||{},...c.data});else return a.s?c:!1}return o?{data:o,errors:!1}:!0})}}}var ie=()=>{};function ue(e){return{...this,p:e===void 0?ie:e}}function ce(e){return be(this,e)}function le(e){return ge(this,e)}function ye(e){return _e(this,e)}function fe(e,r){return A(e,this,r)}function de(e,r){return je(e,this,r)}function p(e,r){return`${e.n?`$${e.n}: `:""}${r}`}function C(e,r){e.g.push(r.startsWith("$")?r:p(e,r))}function J(e,r){r.forEach(n=>C(e,n))}function u(e,r,n,t){if(e.c&&r===void 0)return{ok:!0,data:r,errors:void 0};if(e.l&&r==null)return{ok:!0,data:r,errors:void 0};if(e.f&&r===null)return{ok:!0,data:r,errors:void 0};let s=t();if(s&&(s===!0||!s.errors))return{ok:!0,data:s===!0?r:s.data,errors:void 0};if(!n.y){let o=e.p;if(o!==void 0)return C(n,`Fallback used, errors -> ${L(s,n,e,r)}`),{ok:!0,data:U(o)?o(r):o,errors:void 0};if(e.k&&e.d){let a=e.d(r);if(a)return a.safeFix||C(n,`Autofixed from error -> ${L(s,n,e,r)}`),a.errors?{ok:!1,data:void 0,errors:a.errors.map(c=>p(n,c))}:{ok:!0,data:a.fixed,errors:void 0}}}return{ok:!1,data:void 0,errors:s?s.errors:[p(n,Q(e,r))]}}function L(e,r,n,t){return e?e.errors.map(s=>s.replace(r.n,"")).join("; "):Q(n,t)}function Te(e){return{...this,k:!0,d:e}}function pe(e){return{...this,r:(r,n)=>u(this,r,n,()=>{let t=this.r(r,n);if(!t.ok)return{errors:t.errors,data:void 0};let s=e(t.data);return s!==!0?{errors:[p(n,`Predicate failed${s===!1?` for type '${this.e}'`:`: ${s.error}`}`)],data:void 0}:{errors:!1,data:t.data}})}}function M(){return{...this,c:!0,e:`undefined | ${this.e}`}}function Q(e,r){return`Type '${j(r,!!e.R)}' is not assignable to '${e.e}'`}function Re(){return{...this,f:!0,e:`null | ${this.e}`}}function he(){return{...this,l:!0,e:`null | undefined | ${this.e}`}}var d={__rc_type:void 0,withFallback:ue,where:pe,r:void 0,e:void 0,optional:M,optionalKey:M,orNullish:he,withAutofix:Te,orNull:Re,default:ce,nullishDefault:le,or:ye,parse:fe,parseJson:de,h:void 0,p:void 0,m:void 0,c:!1,f:!1,l:!1,k:!1,R:!1,u:void 0,d:void 0,t:void 0,T:void 0,s:!1,b:!1},ze={...d,r(e,r){return u(this,e,r,()=>e===void 0)},e:"undefined"},Je={...d,r(e,r){return u(this,e,r,()=>e===null)},e:"null"},Qe={...d,r(e){return{ok:!0,data:e,errors:void 0}},e:"any"},Ze={...d,r(e){return{ok:!0,data:e,errors:void 0}},e:"unknown"},Ge={...d,r(e,r){return u(this,e,r,()=>typeof e=="boolean")},e:"boolean"},He={...d,r(e,r){return u(this,e,r,()=>typeof e=="string")},e:"string"},Xe={...d,r(e,r){return u(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},Ye={...d,r(e,r){return u(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};function er(e){return{...d,r(r,n){return u(this,r,n,()=>r instanceof e)},e:`instanceof_${e.name||"AnonymousClass"}`}}function rr(...e){let r=Array.isArray(e[0])?e[0]:e;if(r.length===0)throw new Error("rc_literal requires at least one literal");return{...d,r(n,t){return u(this,n,t,()=>{for(let s of r)if(n===s)return!0;return!1})},R:!0,x:r,e:r.length==1?j(r[0],!0):r.map(n=>j(n,!0)).join(" | ")}}function nr(e){if(!e.x)throw new Error("Type is not a literal type");return e.x}function tr(e){return{...d,r(r,n){return u(this,r,n,()=>typeof r=="string"&&r.startsWith(e))},R:!0,e:`\`${e}\${string}\``}}function sr(e){return{...d,r(r,n){return u(this,r,n,()=>typeof r=="string"&&r.endsWith(e))},R:!0,e:`\`\${string}${e}\``}}function or(e){return{...d,r(r,n){return u(this,r,n,()=>typeof r=="string"&&r.includes(e))},R:!0,e:`\`\${string}${e}\${string}\``}}var z=1;function _e(...e){if(e.length===0)throw new Error("Unions should have at least one type");let r="",n=!1;for(let t of e)r&&(r+=" | "),r+=t.e,!n&&t.s&&(n=!0);return{...d,e:r,s:n,r(t,s){return u(this,t,s,()=>{let o=s.n,a=[],c=0,i=!1,l=[],h=0;for(let g of e){h+=1,g.s&&(s.n=`${o}|union ${h}|`);let m=s.o;s.o=!0,s.a=0;let y=g.r(t,s),f=s.a;if(s.o=m,s.a=0,y.ok)return{data:y.data,errors:!1};g.s&&f!==-1?f>0?l.push(...y.errors):(c<z&&a.push(...y.errors),c+=1):i=!0}return s.n=o,l.length>0||a.length>0?((c>z||i)&&a.push(p(s,"not matches any other union member")),{errors:[...l,...a],data:void 0}):!1})}}}function be(e,r){return{...e,c:!1,l:!1,f:!1,r(t,s){return u(this,t,s,()=>{if(t===void 0)return n();let o=e.r(t,s);return o.ok?o.data===void 0?n():{data:o.data,errors:!1}:{data:void 0,errors:o.errors}})},e:`${e.e}_default`};function n(){return{data:U(r)?r():r,errors:!1}}}function ge(e,r){return{...e,c:!1,l:!1,f:!1,r(t,s){return u(this,t,s,()=>{if(t==null)return n();let o=e.r(t,s);return o.ok?o.data===null||o.data===void 0?n():{data:o.data,errors:!1}:{data:void 0,errors:o.errors}})},e:`${e.e}_nullish_default`};function n(){return{data:U(r)?r():r,errors:!1}}}function ar(e,r){return{...e,r(n,t){return u(this,n,t,()=>{let s=e.r(n,t);return s.ok?{data:s.data,errors:!1}:{data:U(r)?r():r,errors:!1}})}}}function ke(e,{checkKey:r,looseCheck:n}={}){return{...d,e:`record<string, ${e.e}>`,s:!0,r(t,s){return u(this,t,s,()=>{if(!w(t))return!1;let o={},a=[],c=s.n;for(let[i,l]of Object.entries(t)){let h=i===""||i.includes(" ")?`['${i}']`:`.${i}`,g=`${c}${h}`;if(s.n=g,r&&!r(i)){a.push(p(s,`Key '${i}' is not allowed`));continue}let m=t[i],y=e.r(l,s);if(y.ok)o[i]=m;else{let f=y.errors;for(let _ of f)a.push(_);if(s.o)break}}if(a.length>0)if(n)J(s,a);else return{errors:a,data:void 0};return s.n=c,{errors:!1,data:o}})}}}function ir(e,{checkKey:r}={}){return ke(e,{checkKey:r,looseCheck:!0})}function E(e,r,n,t=!1,s){let o=t&&!n.y&&!n._,a=s?.unique,c=[],i=[],l=a?new Set:void 0,h=n.n,g=Array.isArray(r),m=-1;for(let y of e){m++;let f=g?r[m]:r,_=`[${m}]`,k=`${h}${_}`;if(n.n=k,s?.filter){let R=s.filter(y);if(typeof R=="boolean"){if(!R)continue}else if("errors"in R)if(o){c.push([R.errors,k]);continue}else return{errors:R.errors,data:void 0};n.n=k}let T=f.r(y,n);if(n.n=k,T.ok&&l){let R=T.data,O=typeof a=="string";O?R=T.data[a]:typeof a=="function"&&(R=a(T.data)),l.has(R)?(O&&(n.n=`${h}${_}.${a}`),T={ok:!1,data:void 0,errors:[p(n,O?`Type '${f.t?.[a]?.e}' with value "${R}" is not unique`:typeof a=="function"?`Type '${f.e}' unique fn return with value "${R}" is not unique`:`${f.e} value is not unique`)]}):l.add(R)}if(T.ok)i.push(T.data);else if(o){c.push([T.errors,k]);continue}else return{errors:T.errors,data:void 0}}if(c.length>0){let y=[];for(let[f,_]of c){for(let k of f){let T=k.slice(_.length+1);T.startsWith(": ")&&(T=T.slice(2)),(T.startsWith(".")||T.startsWith("["))&&(T=`#${T}`);let R=`$${_}: Rejected, error -> ${T}`;y.push(R)}J(n,y)}}return{errors:!1,data:i}}function P(e,r){return{...d,e:`${e.e}[]`,h:e,r(n,t){return u(this,n,t,()=>Array.isArray(n)?n.length===0?!0:E.call(this,n,e,t,!1,r):!1)}}}function ur(e){if(!e.h)throw new Error("Type does not have an item type");return e.h}function cr(e,{nonRecursive:r=!1}={}){if(r){if(!e.e.endsWith("[]"))throw new Error("rc_disable_loose_array: nonRecursive option can only be used with array types");return{...e,r(n,t){return u(this,n,t,()=>Array.isArray(n)?n.length===0?!0:E.call(this,n,e,t,!1):!1)}}}return{...e,r(n,t){let s=t._;t._=!0;let o=e.r(n,t);return t._=s,o}}}function S(e,r){return{...d,h:e,e:`${e.e}[]`,r(n,t){return u(this,n,t,()=>Array.isArray(n)?n.length===0?!0:E.call(this,n,e,t,!0,r):!1)}}}function lr(e,r,n,t){return{...d,h:n,e:`${n.e}[]`,r(s,o){return u(this,s,o,()=>Array.isArray(s)?s.length===0?!0:E.call(this,s,n,o,t?.loose,{...t,filter(a){let c=e.r(a,o);return c.ok?r(c.data):{errors:c.errors}}}):!1)}}}function yr(e){return{...d,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 q(e){e.warnings&&e.warnings.length>0&&console.warn(`Unwrap warnings: ${e.warnings.join(`
|
|
2
|
-
`)}`)}function v(){if(this.errors)throw new I(this.errors);return q(this),this.value}function K(e){return this.errors?e:(q(this),this.value)}function W(){return this.errors?null:(q(this),this.value)}function A(e,r,{noWarnings:n=!1}={}){let t={g:[],n:"",o:!1,a:0,y:n,i:!1,_:!1},s=r.r(e,t);return s.ok?{error:!1,errors:!1,ok:!0,data:s.data,value:s.data,warnings:t.g.length>0?t.g:!1,unwrap:v,unwrapOr:K,unwrapOrNull:W}:{ok:!1,error:!0,errors:s.errors,unwrap:v,unwrapOr:K,unwrapOrNull:W}}function fr(e){return r=>A(r,e)}function dr(e,r,n){let t=A(e,r,n);return t.errors?{data:null,errors:t.errors,warnings:!1}:{data:t.value,errors:!1,warnings:t.warnings}}function Tr(e){return me(e,null)}function me(e,r){return e.error?{value:r,errors:e.errors,warnings:!1}:{value:e.value,errors:!1,warnings:e.warnings}}var I=class extends Error{constructor(n){super(n.join(`
|
|
3
|
-
`));this.errors=n}name="RcValidationError"};function pr(e){if(e.errors)throw new I(e.errors);return e}function xe(e,r){let n={g:[],n:"",o:!1,a:0,y:!1,i:!1,_:!1};return r.r(e,n).ok}function Rr(e){return r=>xe(r,e)}function hr(e){let r;return{...d,e:"recursive",r(n,t){return r||(r={...e()},this.c&&(r.c=this.c),this.l&&(r.l=this.l),this.f&&(r.f=this.f),this.d&&(r.d=this.d),this.p&&(r.p=this.p),this.u&&(r.u=this.u)),r.r(n,t)}}}function Z(e,r,n,t){let s=e.n,o=e.o,a=e.i,c=e.y;e.o=!0,e.n=`${s}|output|`,t||(e.i=!0,e.y=!0);let i=r.r(n,e);return e.i=a,e.y=c,e.n=s,e.o=o,i}function Oe(e,r,{outputSchema:n,disableStrictOutputSchema:t}={}){return{...d,e:`${e.e}_transform`,r(s,o){return u(this,s,o,()=>{let a=null;if(n){let l=Z(o,n,s,t);if(l.ok)return{data:l.data,errors:!1};a=l.errors}let i={...e,e:this.e}.r(s,o);return i.ok?{errors:!1,data:r(i.data,e)}:{errors:[...a||[],...i.errors],data:void 0}})}}}function _r(e,r){return Oe(e,r)}function br(e,r,{outputSchema:n,disableStrictOutputSchema:t}={}){return{...d,e:`${e.e}_transform`,r(s,o){return u(this,s,o,()=>{let a=null;if(n){let l=Z(o,n,s,t);if(l.ok)return{errors:!1,data:l.data};a=l.errors}let i={...e,e:this.e}.r(s,o);if(i.ok){let l=r(i.data,e);return l.ok?{errors:!1,data:l.data}:{errors:typeof l.errors=="string"?[p(o,l.errors)]:l.errors.map(h=>p(o,h)),data:void 0}}return{errors:[...a||[],...i.errors],data:void 0}})}}}function j(e,r){let n=typeof e,t=(()=>{if(n==="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return typeof e=="number"&&Number.isNaN(e)?"NaN":n})();return r&&(t==="string"||t==="number"||t==="boolean")?`${t}(${e})`:t}function gr(e){if(e.errors)throw new Error(`invalid input: ${e.errors.join(", ")}`)}function w(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 je(e,r,n){try{if(typeof e!="string")return{ok:!1,error:!0,errors:[`expected a json string, got ${j(e,!0)}`],unwrap:v,unwrapOr:K,unwrapOrNull:W};let t=JSON.parse(e);return A(t,r,n)}catch(t){return{ok:!1,error:!0,errors:[`json parsing error: ${w(t)?t.message:""}`],unwrap:v,unwrapOr:K,unwrapOrNull:W}}}function U(e){return typeof e=="function"}function $(e){return w(e)&&"__rc_type"in e}function kr(e){return e}function mr(e){return e.e}function xr(e,{errorOnWarnings:r=!1,onWarnings:n}={}){return{"~standard":{validate(t){let s="ok"in e?e:A(t,e);return we(s,r,n)},vendor:"runcheck",version:1}}}function we(e,r,n){return r&&e.ok&&e.warnings?{issues:e.warnings.map(t=>({message:t}))}:e.ok?(n&&e.warnings&&n(e.warnings),{value:e.value}):{issues:e.errors.map(t=>({message:t}))}}function Or(e,r){let n=e["~standard"];return{...d,e:r||`standard_schema_${n.vendor}@${n.version}`,r(t,s){return u(this,t,s,()=>{let o=n.validate(t);return"value"in o?{data:o.value,errors:!1}:"issues"in o?{data:void 0,errors:o.issues.map(a=>p(s,a.message))}:!1})}}}export{G as a,x as b,H as c,X as d,Y as e,ee as f,re as g,ne as h,te as i,se as j,F as k,oe as l,ae as m,p as n,u as o,d as p,ze as q,Je as r,Qe as s,Ze as t,Ge as u,He as v,Xe as w,Ye as x,er as y,rr as z,nr as A,tr as B,sr as C,or as D,_e as E,be as F,ge as G,ar as H,ke as I,ir as J,P as K,ur as L,cr as M,S as N,lr as O,yr as P,A as Q,fr as R,dr as S,Tr as T,me as U,I as V,pr as W,xe as X,Rr as Y,hr as Z,Oe as _,_r as $,br as aa,j as ba,gr as ca,w as da,V as ea,je as fa,$ as ga,kr as ha,mr as ia,xr as ja,Or as ka};
|
|
4
|
-
//# sourceMappingURL=chunk-D2BONWGU.js.map
|