zodbus 1.1.0 → 1.1.3
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/bus.d.ts +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +4 -4
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +4 -4
- package/package.json +1 -1
package/dist/bus.d.ts
CHANGED
|
@@ -27,4 +27,6 @@ declare function create<T extends Schema>({ schema, validate }: BusOptions<T>):
|
|
|
27
27
|
export type InferBusType<T extends Schema> = ReturnType<typeof create<T>>;
|
|
28
28
|
export type InferPublishHandler<T extends Schema> = InferBusType<T>["publish"];
|
|
29
29
|
export type InferSubscribeHandler<T extends Schema> = InferBusType<T>["subscribe"];
|
|
30
|
+
export type InferSubscriptionKey<T extends Schema> = SubscriptionKey<T>;
|
|
31
|
+
export type InferPublishKey<T extends Schema> = PublishKey<T>;
|
|
30
32
|
export { create };
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var pe=Object.defineProperty,Be=Object.defineProperties,Ue=Object.getOwnPropertyDescriptor,We=Object.getOwnPropertyDescriptors,qe=Object.getOwnPropertyNames,Pe=Object.getOwnPropertySymbols;var Le=Object.prototype.hasOwnProperty,Je=Object.prototype.propertyIsEnumerable;var Re=(s,e,t)=>e in s?pe(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,c=(s,e)=>{for(var t in e||(e={}))Le.call(e,t)&&Re(s,t,e[t]);if(Pe)for(var t of Pe(e))Je.call(e,t)&&Re(s,t,e[t]);return s},v=(s,e)=>Be(s,We(e));var He=(s,e)=>{for(var t in e)pe(s,t,{get:e[t],enumerable:!0})},Ye=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of qe(e))!Le.call(s,n)&&n!==t&&pe(s,n,{get:()=>e[n],enumerable:!(r=Ue(e,n))||r.enumerable});return s};var Ge=s=>Ye(pe({},"__esModule",{value:!0}),s);var L=(s,e,t)=>new Promise((r,n)=>{var a=d=>{try{o(t.next(d))}catch(l){n(l)}},i=d=>{try{o(t.throw(d))}catch(l){n(l)}},o=d=>d.done?r(d.value):Promise.resolve(d.value).then(a,i);o((t=t.apply(s,e)).next())});var lt={};He(lt,{create:()=>dt});module.exports=Ge(lt);var k;(function(s){s.assertEqual=n=>n;function e(n){}s.assertIs=e;function t(n){throw new Error}s.assertNever=t,s.arrayToEnum=n=>{let a={};for(let i of n)a[i]=i;return a},s.getValidEnumValues=n=>{let a=s.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(let o of a)i[o]=n[o];return s.objectValues(i)},s.objectValues=n=>s.objectKeys(n).map(function(a){return n[a]}),s.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let a=[];for(let i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},s.find=(n,a)=>{for(let i of n)if(a(i))return i},s.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function r(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}s.joinValues=r,s.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(k||(k={}));var Ae;(function(s){s.mergeShapes=(e,t)=>c(c({},e),t)})(Ae||(Ae={}));var f=k.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),z=s=>{switch(typeof s){case"undefined":return f.undefined;case"string":return f.string;case"number":return isNaN(s)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(s)?f.array:s===null?f.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?f.promise:typeof Map!="undefined"&&s instanceof Map?f.map:typeof Set!="undefined"&&s instanceof Set?f.set:typeof Date!="undefined"&&s instanceof Date?f.date:f.object;default:return f.unknown}},u=k.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);var Z=class extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let t=e||function(a){return a.message},r={_errors:[]},n=a=>{for(let i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)r._errors.push(t(i));else{let o=r,d=0;for(;d<i.path.length;){let l=i.path[d];d===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],d++}}};return n(this),r}toString(){return this.message}get message(){return JSON.stringify(this.issues,k.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},r=[];for(let n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):r.push(e(n));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}};Z.create=s=>new Z(s);var ye=(s,e)=>{let t;switch(s.code){case u.invalid_type:s.received===f.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case u.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,k.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:t=`Unrecognized key(s) in object: ${k.joinValues(s.keys,", ")}`;break;case u.invalid_union:t="Invalid input";break;case u.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${k.joinValues(s.options)}`;break;case u.invalid_enum_value:t=`Invalid enum value. Expected ${k.joinValues(s.options)}, received '${s.received}'`;break;case u.invalid_arguments:t="Invalid function arguments";break;case u.invalid_return_type:t="Invalid function return type";break;case u.invalid_date:t="Invalid date";break;case u.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:k.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case u.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case u.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case u.custom:t="Invalid input";break;case u.invalid_intersection_types:t="Intersection results could not be merged";break;case u.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case u.not_finite:t="Number must be finite";break;default:t=e.defaultError,k.assertNever(s)}return{message:t}},Xe=ye;function be(){return Xe}var xe=s=>{let{data:e,path:t,errorMaps:r,issueData:n}=s,a=[...t,...n.path||[]],i=v(c({},n),{path:a}),o="",d=r.filter(l=>!!l).slice().reverse();for(let l of d)o=l(i,{data:e,defaultError:o}).message;return v(c({},n),{path:a,message:n.message||o})};function h(s,e){let t=xe({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,be(),ye].filter(r=>!!r)});s.common.issues.push(t)}var O=class s{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let r=[];for(let n of t){if(n.status==="aborted")return y;n.status==="dirty"&&e.dirty(),r.push(n.value)}return{status:e.value,value:r}}static mergeObjectAsync(e,t){return L(this,null,function*(){let r=[];for(let n of t)r.push({key:yield n.key,value:yield n.value});return s.mergeObjectSync(e,r)})}static mergeObjectSync(e,t){let r={};for(let n of t){let{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return y;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),(typeof i.value!="undefined"||n.alwaysSet)&&(r[a.value]=i.value)}return{status:e.value,value:r}}},y=Object.freeze({status:"aborted"}),Qe=s=>({status:"dirty",value:s}),N=s=>({status:"valid",value:s}),Ke=s=>s.status==="aborted",$e=s=>s.status==="dirty",ke=s=>s.status==="valid",Te=s=>typeof Promise!="undefined"&&s instanceof Promise,p;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(p||(p={}));var I=class{constructor(e,t,r,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Me=(s,e)=>{if(ke(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new Z(s.common.issues);return this._error=t,this._error}}};function g(s){if(!s)return{};let{errorMap:e,invalid_type_error:t,required_error:r,description:n}=s;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(i,o)=>i.code!=="invalid_type"?{message:o.defaultError}:typeof o.data=="undefined"?{message:r!=null?r:o.defaultError}:{message:t!=null?t:o.defaultError},description:n}}var _=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return z(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:z(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new O,ctx:{common:e.parent.common,data:e.data,parsedType:z(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Te(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;let n={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)},a=this._parseSync({data:e,path:n.path,parent:n});return Me(n,a)}parseAsync(e,t){return L(this,null,function*(){let r=yield this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error})}safeParseAsync(e,t){return L(this,null,function*(){let r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)},n=this._parse({data:e,path:r.path,parent:r}),a=yield Te(n)?n:Promise.resolve(n);return Me(r,a)})}refine(e,t){let r=n=>typeof t=="string"||typeof t=="undefined"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{let i=e(n),o=()=>a.addIssue(c({code:u.custom},r(n)));return typeof Promise!="undefined"&&i instanceof Promise?i.then(d=>d?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,n)=>e(r)?!0:(n.addIssue(typeof t=="function"?t(r,n):t),!1))}_refinement(e){return new j({schema:this,typeName:m.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return P.create(this,this._def)}nullable(){return M.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return $.create(this,this._def)}promise(){return B.create(this,this._def)}or(e){return H.create([this,e],this._def)}and(e){return Y.create(this,e,this._def)}transform(e){return new j(v(c({},g(this._def)),{schema:this,typeName:m.ZodEffects,effect:{type:"transform",transform:e}}))}default(e){let t=typeof e=="function"?e:()=>e;return new ee(v(c({},g(this._def)),{innerType:this,defaultValue:t,typeName:m.ZodDefault}))}brand(){return new Ne(c({typeName:m.ZodBranded,type:this},g(this._def)))}catch(e){let t=typeof e=="function"?e:()=>e;return new de(v(c({},g(this._def)),{innerType:this,catchValue:t,typeName:m.ZodCatch}))}describe(e){let t=this.constructor;return new t(v(c({},this._def),{description:e}))}pipe(e){return ve.create(this,e)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Fe=/^c[^\s-]{8,}$/i,et=/^[a-z][a-z0-9]*$/,tt=/[0-9A-HJKMNP-TV-Z]{26}/,st=/^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i,rt=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/,nt=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u"),at=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,it=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ot=s=>s.precision?s.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}Z$`):s.precision===0?s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function ct(s,e){return!!((e==="v4"||!e)&&at.test(s)||(e==="v6"||!e)&&it.test(s))}var W=class s extends _{constructor(){super(...arguments),this._regex=(e,t,r)=>this.refinement(n=>e.test(n),c({validation:t,code:u.invalid_string},p.errToObj(r))),this.nonempty=e=>this.min(1,p.errToObj(e)),this.trim=()=>new s(v(c({},this._def),{checks:[...this._def.checks,{kind:"trim"}]})),this.toLowerCase=()=>new s(v(c({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]})),this.toUpperCase=()=>new s(v(c({},this._def),{checks:[...this._def.checks,{kind:"toUpperCase"}]}))}_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){let a=this._getOrReturnCtx(e);return h(a,{code:u.invalid_type,expected:f.string,received:a.parsedType}),y}let r=new O,n;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),h(n,{code:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),h(n,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){let i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(n=this._getOrReturnCtx(e,n),i?h(n,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&h(n,{code:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")rt.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"email",code:u.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")nt.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"emoji",code:u.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")st.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"uuid",code:u.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")Fe.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"cuid",code:u.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")et.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"cuid2",code:u.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")tt.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"ulid",code:u.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(e.data)}catch(i){n=this._getOrReturnCtx(e,n),h(n,{validation:"url",code:u.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"regex",code:u.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),h(n,{code:u.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),h(n,{code:u.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),h(n,{code:u.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?ot(a).test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{code:u.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="ip"?ct(e.data,a.version)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"ip",code:u.invalid_string,message:a.message}),r.dirty()):k.assertNever(a);return{status:r.value,value:e.data}}_addCheck(e){return new s(v(c({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(c({kind:"email"},p.errToObj(e)))}url(e){return this._addCheck(c({kind:"url"},p.errToObj(e)))}emoji(e){return this._addCheck(c({kind:"emoji"},p.errToObj(e)))}uuid(e){return this._addCheck(c({kind:"uuid"},p.errToObj(e)))}cuid(e){return this._addCheck(c({kind:"cuid"},p.errToObj(e)))}cuid2(e){return this._addCheck(c({kind:"cuid2"},p.errToObj(e)))}ulid(e){return this._addCheck(c({kind:"ulid"},p.errToObj(e)))}ip(e){return this._addCheck(c({kind:"ip"},p.errToObj(e)))}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck(c({kind:"datetime",precision:typeof(e==null?void 0:e.precision)=="undefined"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1},p.errToObj(e==null?void 0:e.message)))}regex(e,t){return this._addCheck(c({kind:"regex",regex:e},p.errToObj(t)))}includes(e,t){return this._addCheck(c({kind:"includes",value:e,position:t==null?void 0:t.position},p.errToObj(t==null?void 0:t.message)))}startsWith(e,t){return this._addCheck(c({kind:"startsWith",value:e},p.errToObj(t)))}endsWith(e,t){return this._addCheck(c({kind:"endsWith",value:e},p.errToObj(t)))}min(e,t){return this._addCheck(c({kind:"min",value:e},p.errToObj(t)))}max(e,t){return this._addCheck(c({kind:"max",value:e},p.errToObj(t)))}length(e,t){return this._addCheck(c({kind:"length",value:e},p.errToObj(t)))}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};W.create=s=>{var e;return new W(c({checks:[],typeName:m.ZodString,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1},g(s)))};function ut(s,e){let t=(s.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,n=t>r?t:r,a=parseInt(s.toFixed(n).replace(".","")),i=parseInt(e.toFixed(n).replace(".",""));return a%i/Math.pow(10,n)}var te=class s extends _{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){let a=this._getOrReturnCtx(e);return h(a,{code:u.invalid_type,expected:f.number,received:a.parsedType}),y}let r,n=new O;for(let a of this._def.checks)a.kind==="int"?k.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:u.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:u.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:u.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?ut(e.data,a.value)!==0&&(r=this._getOrReturnCtx(e,r),h(r,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:u.not_finite,message:a.message}),n.dirty()):k.assertNever(a);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,r,n){return new s(v(c({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:p.toString(n)}]}))}_addCheck(e){return new s(v(c({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:p.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:p.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&k.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}};te.create=s=>new te(c({checks:[],typeName:m.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1},g(s)));var se=class s extends _{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==f.bigint){let a=this._getOrReturnCtx(e);return h(a,{code:u.invalid_type,expected:f.bigint,received:a.parsedType}),y}let r,n=new O;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:u.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:u.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),h(r,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):k.assertNever(a);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,r,n){return new s(v(c({},this._def),{checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:p.toString(n)}]}))}_addCheck(e){return new s(v(c({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};se.create=s=>{var e;return new se(c({checks:[],typeName:m.ZodBigInt,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1},g(s)))};var re=class extends _{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){let r=this._getOrReturnCtx(e);return h(r,{code:u.invalid_type,expected:f.boolean,received:r.parsedType}),y}return N(e.data)}};re.create=s=>new re(c({typeName:m.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1},g(s)));var ne=class s extends _{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){let a=this._getOrReturnCtx(e);return h(a,{code:u.invalid_type,expected:f.date,received:a.parsedType}),y}if(isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return h(a,{code:u.invalid_date}),y}let r=new O,n;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),h(n,{code:u.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(n=this._getOrReturnCtx(e,n),h(n,{code:u.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):k.assertNever(a);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new s(v(c({},this._def),{checks:[...this._def.checks,e]}))}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:p.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:p.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};ne.create=s=>new ne(c({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:m.ZodDate},g(s)));var ae=class extends _{_parse(e){if(this._getType(e)!==f.symbol){let r=this._getOrReturnCtx(e);return h(r,{code:u.invalid_type,expected:f.symbol,received:r.parsedType}),y}return N(e.data)}};ae.create=s=>new ae(c({typeName:m.ZodSymbol},g(s)));var q=class extends _{_parse(e){if(this._getType(e)!==f.undefined){let r=this._getOrReturnCtx(e);return h(r,{code:u.invalid_type,expected:f.undefined,received:r.parsedType}),y}return N(e.data)}};q.create=s=>new q(c({typeName:m.ZodUndefined},g(s)));var J=class extends _{_parse(e){if(this._getType(e)!==f.null){let r=this._getOrReturnCtx(e);return h(r,{code:u.invalid_type,expected:f.null,received:r.parsedType}),y}return N(e.data)}};J.create=s=>new J(c({typeName:m.ZodNull},g(s)));var ie=class extends _{constructor(){super(...arguments),this._any=!0}_parse(e){return N(e.data)}};ie.create=s=>new ie(c({typeName:m.ZodAny},g(s)));var K=class extends _{constructor(){super(...arguments),this._unknown=!0}_parse(e){return N(e.data)}};K.create=s=>new K(c({typeName:m.ZodUnknown},g(s)));var R=class extends _{_parse(e){let t=this._getOrReturnCtx(e);return h(t,{code:u.invalid_type,expected:f.never,received:t.parsedType}),y}};R.create=s=>new R(c({typeName:m.ZodNever},g(s)));var oe=class extends _{_parse(e){if(this._getType(e)!==f.undefined){let r=this._getOrReturnCtx(e);return h(r,{code:u.invalid_type,expected:f.void,received:r.parsedType}),y}return N(e.data)}};oe.create=s=>new oe(c({typeName:m.ZodVoid},g(s)));var $=class s extends _{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==f.array)return h(t,{code:u.invalid_type,expected:f.array,received:t.parsedType}),y;if(n.exactLength!==null){let i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&(h(t,{code:i?u.too_big:u.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(h(t,{code:u.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),r.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(h(t,{code:u.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new I(t,i,t.path,o)))).then(i=>O.mergeArray(r,i));let a=[...t.data].map((i,o)=>n.type._parseSync(new I(t,i,t.path,o)));return O.mergeArray(r,a)}get element(){return this._def.type}min(e,t){return new s(v(c({},this._def),{minLength:{value:e,message:p.toString(t)}}))}max(e,t){return new s(v(c({},this._def),{maxLength:{value:e,message:p.toString(t)}}))}length(e,t){return new s(v(c({},this._def),{exactLength:{value:e,message:p.toString(t)}}))}nonempty(e){return this.min(1,e)}};$.create=(s,e)=>new $(c({type:s,minLength:null,maxLength:null,exactLength:null,typeName:m.ZodArray},g(e)));function U(s){if(s instanceof C){let e={};for(let t in s.shape){let r=s.shape[t];e[t]=P.create(U(r))}return new C(v(c({},s._def),{shape:()=>e}))}else return s instanceof $?new $(v(c({},s._def),{type:U(s.element)})):s instanceof P?P.create(U(s.unwrap())):s instanceof M?M.create(U(s.unwrap())):s instanceof A?A.create(s.items.map(e=>U(e))):s}var C=class s extends _{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=k.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==f.object){let l=this._getOrReturnCtx(e);return h(l,{code:u.invalid_type,expected:f.object,received:l.parsedType}),y}let{status:r,ctx:n}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof R&&this._def.unknownKeys==="strip"))for(let l in n.data)i.includes(l)||o.push(l);let d=[];for(let l of i){let b=a[l],D=n.data[l];d.push({key:{status:"valid",value:l},value:b._parse(new I(n,D,n.path,l)),alwaysSet:l in n.data})}if(this._def.catchall instanceof R){let l=this._def.unknownKeys;if(l==="passthrough")for(let b of o)d.push({key:{status:"valid",value:b},value:{status:"valid",value:n.data[b]}});else if(l==="strict")o.length>0&&(h(n,{code:u.unrecognized_keys,keys:o}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let b of o){let D=n.data[b];d.push({key:{status:"valid",value:b},value:l._parse(new I(n,D,n.path,b)),alwaysSet:b in n.data})}}return n.common.async?Promise.resolve().then(()=>L(this,null,function*(){let l=[];for(let b of d){let D=yield b.key;l.push({key:D,value:yield b.value,alwaysSet:b.alwaysSet})}return l})).then(l=>O.mergeObjectSync(r,l)):O.mergeObjectSync(r,d)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new s(c(v(c({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:(t,r)=>{var n,a,i,o;let d=(i=(a=(n=this._def).errorMap)===null||a===void 0?void 0:a.call(n,t,r).message)!==null&&i!==void 0?i:r.defaultError;return t.code==="unrecognized_keys"?{message:(o=p.errToObj(e).message)!==null&&o!==void 0?o:d}:{message:d}}}:{}))}strip(){return new s(v(c({},this._def),{unknownKeys:"strip"}))}passthrough(){return new s(v(c({},this._def),{unknownKeys:"passthrough"}))}extend(e){return new s(v(c({},this._def),{shape:()=>c(c({},this._def.shape()),e)}))}merge(e){return new s({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>c(c({},this._def.shape()),e._def.shape()),typeName:m.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new s(v(c({},this._def),{catchall:e}))}pick(e){let t={};return k.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new s(v(c({},this._def),{shape:()=>t}))}omit(e){let t={};return k.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new s(v(c({},this._def),{shape:()=>t}))}deepPartial(){return U(this)}partial(e){let t={};return k.objectKeys(this.shape).forEach(r=>{let n=this.shape[r];e&&!e[r]?t[r]=n:t[r]=n.optional()}),new s(v(c({},this._def),{shape:()=>t}))}required(e){let t={};return k.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof P;)a=a._def.innerType;t[r]=a}}),new s(v(c({},this._def),{shape:()=>t}))}keyof(){return Ve(k.objectKeys(this.shape))}};C.create=(s,e)=>new C(c({shape:()=>s,unknownKeys:"strip",catchall:R.create(),typeName:m.ZodObject},g(e)));C.strictCreate=(s,e)=>new C(c({shape:()=>s,unknownKeys:"strict",catchall:R.create(),typeName:m.ZodObject},g(e)));C.lazycreate=(s,e)=>new C(c({shape:s,unknownKeys:"strip",catchall:R.create(),typeName:m.ZodObject},g(e)));var H=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;function n(a){for(let o of a)if(o.result.status==="valid")return o.result;for(let o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;let i=a.map(o=>new Z(o.ctx.common.issues));return h(t,{code:u.invalid_union,unionErrors:i}),y}if(t.common.async)return Promise.all(r.map(a=>L(this,null,function*(){let i=v(c({},t),{common:v(c({},t.common),{issues:[]}),parent:null});return{result:yield a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}}))).then(n);{let a,i=[];for(let d of r){let l=v(c({},t),{common:v(c({},t.common),{issues:[]}),parent:null}),b=d._parseSync({data:t.data,path:t.path,parent:l});if(b.status==="valid")return b;b.status==="dirty"&&!a&&(a={result:b,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(d=>new Z(d));return h(t,{code:u.invalid_union,unionErrors:o}),y}}get options(){return this._def.options}};H.create=(s,e)=>new H(c({options:s,typeName:m.ZodUnion},g(e)));var me=s=>s instanceof G?me(s.schema):s instanceof j?me(s.innerType()):s instanceof X?[s.value]:s instanceof Q?s.options:s instanceof F?Object.keys(s.enum):s instanceof ee?me(s._def.innerType):s instanceof q?[void 0]:s instanceof J?[null]:null,we=class s extends _{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return h(t,{code:u.invalid_type,expected:f.object,received:t.parsedType}),y;let r=this.discriminator,n=t.data[r],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(h(t,{code:u.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let n=new Map;for(let a of t){let i=me(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,a)}}return new s(c({typeName:m.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n},g(r)))}};function Se(s,e){let t=z(s),r=z(e);if(s===e)return{valid:!0,data:s};if(t===f.object&&r===f.object){let n=k.objectKeys(e),a=k.objectKeys(s).filter(o=>n.indexOf(o)!==-1),i=c(c({},s),e);for(let o of a){let d=Se(s[o],e[o]);if(!d.valid)return{valid:!1};i[o]=d.data}return{valid:!0,data:i}}else if(t===f.array&&r===f.array){if(s.length!==e.length)return{valid:!1};let n=[];for(let a=0;a<s.length;a++){let i=s[a],o=e[a],d=Se(i,o);if(!d.valid)return{valid:!1};n.push(d.data)}return{valid:!0,data:n}}else return t===f.date&&r===f.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}var Y=class extends _{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=(a,i)=>{if(Ke(a)||Ke(i))return y;let o=Se(a.value,i.value);return o.valid?(($e(a)||$e(i))&&t.dirty(),{status:t.value,value:o.data}):(h(r,{code:u.invalid_intersection_types}),y)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};Y.create=(s,e,t)=>new Y(c({left:s,right:e,typeName:m.ZodIntersection},g(t)));var A=class s extends _{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.array)return h(r,{code:u.invalid_type,expected:f.array,received:r.parsedType}),y;if(r.data.length<this._def.items.length)return h(r,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&r.data.length>this._def.items.length&&(h(r,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let a=[...r.data].map((i,o)=>{let d=this._def.items[o]||this._def.rest;return d?d._parse(new I(r,i,r.path,o)):null}).filter(i=>!!i);return r.common.async?Promise.all(a).then(i=>O.mergeArray(t,i)):O.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new s(v(c({},this._def),{rest:e}))}};A.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new A(c({items:s,typeName:m.ZodTuple,rest:null},g(e)))};var Oe=class s extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.object)return h(r,{code:u.invalid_type,expected:f.object,received:r.parsedType}),y;let n=[],a=this._def.keyType,i=this._def.valueType;for(let o in r.data)n.push({key:a._parse(new I(r,o,r.path,o)),value:i._parse(new I(r,r.data[o],r.path,o))});return r.common.async?O.mergeObjectAsync(t,n):O.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof _?new s(c({keyType:e,valueType:t,typeName:m.ZodRecord},g(r))):new s(c({keyType:W.create(),valueType:e,typeName:m.ZodRecord},g(t)))}},ce=class extends _{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.map)return h(r,{code:u.invalid_type,expected:f.map,received:r.parsedType}),y;let n=this._def.keyType,a=this._def.valueType,i=[...r.data.entries()].map(([o,d],l)=>({key:n._parse(new I(r,o,r.path,[l,"key"])),value:a._parse(new I(r,d,r.path,[l,"value"]))}));if(r.common.async){let o=new Map;return Promise.resolve().then(()=>L(this,null,function*(){for(let d of i){let l=yield d.key,b=yield d.value;if(l.status==="aborted"||b.status==="aborted")return y;(l.status==="dirty"||b.status==="dirty")&&t.dirty(),o.set(l.value,b.value)}return{status:t.value,value:o}}))}else{let o=new Map;for(let d of i){let l=d.key,b=d.value;if(l.status==="aborted"||b.status==="aborted")return y;(l.status==="dirty"||b.status==="dirty")&&t.dirty(),o.set(l.value,b.value)}return{status:t.value,value:o}}}};ce.create=(s,e,t)=>new ce(c({valueType:e,keyType:s,typeName:m.ZodMap},g(t)));var ue=class s extends _{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.set)return h(r,{code:u.invalid_type,expected:f.set,received:r.parsedType}),y;let n=this._def;n.minSize!==null&&r.data.size<n.minSize.value&&(h(r,{code:u.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&r.data.size>n.maxSize.value&&(h(r,{code:u.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());let a=this._def.valueType;function i(d){let l=new Set;for(let b of d){if(b.status==="aborted")return y;b.status==="dirty"&&t.dirty(),l.add(b.value)}return{status:t.value,value:l}}let o=[...r.data.values()].map((d,l)=>a._parse(new I(r,d,r.path,l)));return r.common.async?Promise.all(o).then(d=>i(d)):i(o)}min(e,t){return new s(v(c({},this._def),{minSize:{value:e,message:p.toString(t)}}))}max(e,t){return new s(v(c({},this._def),{maxSize:{value:e,message:p.toString(t)}}))}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};ue.create=(s,e)=>new ue(c({valueType:s,minSize:null,maxSize:null,typeName:m.ZodSet},g(e)));var Ee=class s extends _{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return h(t,{code:u.invalid_type,expected:f.function,received:t.parsedType}),y;function r(o,d){return xe({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,be(),ye].filter(l=>!!l),issueData:{code:u.invalid_arguments,argumentsError:d}})}function n(o,d){return xe({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,be(),ye].filter(l=>!!l),issueData:{code:u.invalid_return_type,returnTypeError:d}})}let a={errorMap:t.common.contextualErrorMap},i=t.data;return this._def.returns instanceof B?N((...o)=>L(this,null,function*(){let d=new Z([]),l=yield this._def.args.parseAsync(o,a).catch(fe=>{throw d.addIssue(r(o,fe)),d}),b=yield i(...l);return yield this._def.returns._def.type.parseAsync(b,a).catch(fe=>{throw d.addIssue(n(b,fe)),d})})):N((...o)=>{let d=this._def.args.safeParse(o,a);if(!d.success)throw new Z([r(o,d.error)]);let l=i(...d.data),b=this._def.returns.safeParse(l,a);if(!b.success)throw new Z([n(l,b.error)]);return b.data})}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new s(v(c({},this._def),{args:A.create(e).rest(K.create())}))}returns(e){return new s(v(c({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new s(c({args:e||A.create([]).rest(K.create()),returns:t||K.create(),typeName:m.ZodFunction},g(r)))}},G=class extends _{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};G.create=(s,e)=>new G(c({getter:s,typeName:m.ZodLazy},g(e)));var X=class extends _{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return h(t,{received:t.data,code:u.invalid_literal,expected:this._def.value}),y}return{status:"valid",value:e.data}}get value(){return this._def.value}};X.create=(s,e)=>new X(c({value:s,typeName:m.ZodLiteral},g(e)));function Ve(s,e){return new Q(c({values:s,typeName:m.ZodEnum},g(e)))}var Q=class s extends _{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),r=this._def.values;return h(t,{expected:k.joinValues(r),received:t.parsedType,code:u.invalid_type}),y}if(this._def.values.indexOf(e.data)===-1){let t=this._getOrReturnCtx(e),r=this._def.values;return h(t,{received:t.data,code:u.invalid_enum_value,options:r}),y}return N(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e){return s.create(e)}exclude(e){return s.create(this.options.filter(t=>!e.includes(t)))}};Q.create=Ve;var F=class extends _{_parse(e){let t=k.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==f.string&&r.parsedType!==f.number){let n=k.objectValues(t);return h(r,{expected:k.joinValues(n),received:r.parsedType,code:u.invalid_type}),y}if(t.indexOf(e.data)===-1){let n=k.objectValues(t);return h(r,{received:r.data,code:u.invalid_enum_value,options:n}),y}return N(e.data)}get enum(){return this._def.values}};F.create=(s,e)=>new F(c({values:s,typeName:m.ZodNativeEnum},g(e)));var B=class extends _{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return h(t,{code:u.invalid_type,expected:f.promise,received:t.parsedType}),y;let r=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return N(r.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}};B.create=(s,e)=>new B(c({type:s,typeName:m.ZodPromise},g(e)));var j=class extends _{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===m.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null;if(n.type==="preprocess"){let i=n.transform(r.data);return r.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:r.path,parent:r})):this._def.schema._parseSync({data:i,path:r.path,parent:r})}let a={addIssue:i=>{h(r,i),i.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="refinement"){let i=o=>{let d=n.refinement(o,a);if(r.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?y:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?y:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(r.common.async===!1){let i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!ke(i))return i;let o=n.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>ke(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);k.assertNever(n)}};j.create=(s,e,t)=>new j(c({schema:s,typeName:m.ZodEffects,effect:e},g(t)));j.createWithPreprocess=(s,e,t)=>new j(c({schema:e,effect:{type:"preprocess",transform:s},typeName:m.ZodEffects},g(t)));var P=class extends _{_parse(e){return this._getType(e)===f.undefined?N(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};P.create=(s,e)=>new P(c({innerType:s,typeName:m.ZodOptional},g(e)));var M=class extends _{_parse(e){return this._getType(e)===f.null?N(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};M.create=(s,e)=>new M(c({innerType:s,typeName:m.ZodNullable},g(e)));var ee=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return t.parsedType===f.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};ee.create=(s,e)=>new ee(c({innerType:s,typeName:m.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default},g(e)));var de=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),r=v(c({},t),{common:v(c({},t.common),{issues:[]})}),n=this._def.innerType._parse({data:r.data,path:r.path,parent:c({},r)});return Te(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Z(r.common.issues)},input:r.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Z(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};de.create=(s,e)=>new de(c({innerType:s,typeName:m.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},g(e)));var le=class extends _{_parse(e){if(this._getType(e)!==f.nan){let r=this._getOrReturnCtx(e);return h(r,{code:u.invalid_type,expected:f.nan,received:r.parsedType}),y}return{status:"valid",value:e.data}}};le.create=s=>new le(c({typeName:m.ZodNaN},g(s)));var pt=Symbol("zod_brand"),Ne=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}},ve=class s extends _{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return L(this,null,function*(){let a=yield this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?y:a.status==="dirty"?(t.dirty(),Qe(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})});{let n=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return n.status==="aborted"?y:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:r.path,parent:r})}}static create(e,t){return new s({in:e,out:t,typeName:m.ZodPipeline})}};var mt={object:C.lazycreate},m;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline"})(m||(m={}));var yt=W.create,vt=te.create,gt=le.create,_t=se.create,bt=re.create,xt=ne.create,kt=ae.create,Tt=q.create,wt=J.create,St=ie.create,Ot=K.create,Et=R.create,Nt=oe.create,Ct=$.create,Zt=C.create,It=C.strictCreate,jt=H.create,Pt=we.create,Rt=Y.create,Lt=A.create,At=Oe.create,Kt=ce.create,$t=ue.create,Mt=Ee.create,Vt=G.create,Dt=X.create,zt=Q.create,Bt=F.create,Ut=B.create,Wt=j.create,qt=P.create,Jt=M.create,Ht=j.createWithPreprocess,Yt=ve.create;var Ce="[zodbus] ";var V=class extends Error{constructor(e){super(`${Ce}${e}`),this.name="ValidationError"}},ge=class extends Error{constructor(e){super(`${Ce}${e}`),this.name="RuntimeError"}};var De=(s,e="")=>{let t=[];for(let[r,n]of Object.entries(s)){let a=e?`${e}.${r}`:r;typeof n.parse=="function"?t.push(a):t.push(...De(n,a))}return t},Ze=(s,e="")=>{let t=[];for(let[r,n]of Object.entries(s)){let a=e?`${e}.${r}`:r,i=e?`${e}.*`:"*";typeof n.parse=="function"?t.push(a,i):t.push(...Ze(n,a),...Ze(n,i))}return t},ze=s=>{let e={},t=De(s),r=Ze(s);for(let n of r){let a=n.split(".");e[n]=t.filter(i=>{let o=i.split(".");if(o.length!==a.length)return!1;for(let[d,l]of o.entries())if(a[d]!=="*"&&l!==a[d])return!1;return!0})}return e};function dt({schema:s,validate:e=!0}){let t=ze(s),r=Array.from(new Set(Object.values(t).flat())),n=new Map,a=x=>{if(x==="*")return Array.from(n.values());let T=[],S=t[x];if(!S)throw new V(`Invalid event: "${x}"`);for(let w of S){let E=n.get(w);E&&T.push(E)}return T},i=(x,T)=>{let S=x.split("."),w=s;for(let E of S)if(w=w[E],!w)throw new V(`Invalid event: "${x}". Could not resolve "${E}" fragment.`);if(w instanceof _)w.parse(T);else throw new V(`Reached invalid payload schema for: "${x}"`)},o=(x,T)=>{let S=a(x);for(let w of S)T===void 0?w.clear():w.delete(T)},d=(x,T)=>{var w;if(typeof T!="function")throw new V(`Invalid listener for event: "${x}". Expected function, got ${typeof T}`);let S=x==="*"?r:t[x];if(!S)throw new V(`Invalid event: "${x}"`);for(let E of S){let he=(w=n.get(E))!=null?w:new Set;he.add(T),n.set(E,he)}return{event:x,listener:T,unsubscribe:()=>o(x,T)}};return{publish:(x,T)=>{if(e&&i(x,T),!!n.has(x))for(let S of n.get(x))S(T,x)},subscribe:d,subscribeOnce:(x,T)=>{let S=(w,E)=>{T(w,E),o(x,S)};return d(x,S)},unsubscribe:o,getEventNames:()=>r,getListeners:x=>{let T=[],S=x?a(x):Array.from(n.values());for(let w of S)for(let E of w)T.push(E);return T},waitFor:(x,T={})=>{let{timeout:S=5e3,filter:w}=T;return new Promise((E,he)=>{let Ie,_e=je=>{w&&!w(je)||(o(x,_e),E(je),clearTimeout(Ie))};d(x,_e),S&&(Ie=setTimeout(()=>{o(x,_e),he(new ge(`Timeout waiting for event: "${x}"`))},S))})}}}
|
|
1
|
+
"use strict";var h=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var O=(i,s)=>{for(var u in s)h(i,u,{get:s[u],enumerable:!0})},E=(i,s,u,a)=>{if(s&&typeof s=="object"||typeof s=="function")for(let t of k(s))!I.call(i,t)&&t!==u&&h(i,t,{get:()=>s[t],enumerable:!(a=$(s,t))||a.enumerable});return i};var R=i=>E(h({},"__esModule",{value:!0}),i);var N={};O(N,{create:()=>B});module.exports=R(N);var v=require("zod");var y="[zodbus] ";var l=class extends Error{constructor(s){super(`${y}${s}`),this.name="ValidationError"}},K=class extends Error{constructor(s){super(`${y}${s}`),this.name="RuntimeError"}};var L=(i,s="")=>{let u=[];for(let[a,t]of Object.entries(i)){let p=s?`${s}.${a}`:a;typeof t.parse=="function"?u.push(p):u.push(...L(t,p))}return u},m=(i,s="")=>{let u=[];for(let[a,t]of Object.entries(i)){let p=s?`${s}.${a}`:a,d=s?`${s}.*`:"*";typeof t.parse=="function"?u.push(p,d):u.push(...m(t,p),...m(t,d))}return u},w=i=>{let s={},u=L(i),a=m(i);for(let t of a){let p=t.split(".");s[t]=u.filter(d=>{let b=d.split(".");if(b.length!==p.length)return!1;for(let[f,P]of b.entries())if(p[f]!=="*"&&P!==p[f])return!1;return!0})}return s};function B({schema:i,validate:s=!0}){let u=w(i),a=Array.from(new Set(Object.values(u).flat())),t=new Map,p=e=>{if(e==="*")return Array.from(t.values());let n=[],o=u[e];if(!o)throw new l(`Invalid event: "${e}"`);for(let r of o){let c=t.get(r);c&&n.push(c)}return n},d=(e,n)=>{let o=e.split("."),r=i;for(let c of o)if(r=r[c],!r)throw new l(`Invalid event: "${e}". Could not resolve "${c}" fragment.`);if(r instanceof v.ZodType)r.parse(n);else throw new l(`Reached invalid payload schema for: "${e}"`)},b=(e,n)=>{let o=p(e);for(let r of o)n===void 0?r.clear():r.delete(n)},f=(e,n)=>{var r;if(typeof n!="function")throw new l(`Invalid listener for event: "${e}". Expected function, got ${typeof n}`);let o=e==="*"?a:u[e];if(!o)throw new l(`Invalid event: "${e}"`);for(let c of o){let T=(r=t.get(c))!=null?r:new Set;T.add(n),t.set(c,T)}return{event:e,listener:n,unsubscribe:()=>b(e,n)}};return{publish:(e,n)=>{if(s&&d(e,n),!!t.has(e))for(let o of t.get(e))o(n,e)},subscribe:f,subscribeOnce:(e,n)=>{let o=(r,c)=>{n(r,c),b(e,o)};return f(e,o)},unsubscribe:b,getEventNames:()=>a,getListeners:e=>{let n=[],o=e?p(e):Array.from(t.values());for(let r of o)for(let c of r)n.push(c);return n},waitFor:(e,n={})=>{let{timeout:o=5e3,filter:r}=n;return new Promise((c,T)=>{let g,S=x=>{r&&!r(x)||(b(e,S),c(x),clearTimeout(g))};f(e,S),o&&(g=setTimeout(()=>{b(e,S),T(new K(`Timeout waiting for event: "${e}"`))},o))})}}}
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|