@chaos-maker/core 0.1.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/LICENSE +0 -0
- package/README.md +176 -0
- package/dist/chaos-maker.cjs +4 -0
- package/dist/chaos-maker.js +3288 -0
- package/dist/chaos-maker.umd.js +4 -0
- package/dist/types/ChaosMaker.d.ts +18 -0
- package/dist/types/builder.d.ts +12 -0
- package/dist/types/config.d.ts +52 -0
- package/dist/types/errors.d.ts +4 -0
- package/dist/types/events.d.ts +29 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/interceptors/domAssailant.d.ts +3 -0
- package/dist/types/interceptors/networkFetch.d.ts +3 -0
- package/dist/types/interceptors/networkXHR.d.ts +4 -0
- package/dist/types/presets.d.ts +2 -0
- package/dist/types/utils.d.ts +4 -0
- package/dist/types/validation.d.ts +2 -0
- package/package.json +63 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
(function(T,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(T=typeof globalThis<"u"?globalThis:T||self,v(T.ChaosMaker={}))})(this,function(T){"use strict";var Bt=Object.defineProperty;var Ht=(T,v,q)=>v in T?Bt(T,v,{enumerable:!0,configurable:!0,writable:!0,value:q}):T[v]=q;var R=(T,v,q)=>Ht(T,typeof v!="symbol"?v+"":v,q);var v;(function(s){s.assertEqual=n=>{};function e(n){}s.assertIs=e;function t(n){throw new Error}s.assertNever=t,s.arrayToEnum=n=>{const a={};for(const o of n)a[o]=o;return a},s.getValidEnumValues=n=>{const a=s.objectKeys(n).filter(i=>typeof n[n[i]]!="number"),o={};for(const i of a)o[i]=n[i];return s.objectValues(o)},s.objectValues=n=>s.objectKeys(n).map(function(a){return n[a]}),s.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const a=[];for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&a.push(o);return a},s.find=(n,a)=>{for(const o of n)if(a(o))return o},s.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function r(n,a=" | "){return n.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}s.joinValues=r,s.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(v||(v={}));var q;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(q||(q={}));const f=v.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 Number.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<"u"&&s instanceof Map?f.map:typeof Set<"u"&&s instanceof Set?f.set:typeof Date<"u"&&s instanceof Date?f.date:f.object;default:return f.unknown}},c=v.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"]);class L extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(a){return a.message},r={_errors:[]},n=a=>{for(const o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(n);else if(o.code==="invalid_return_type")n(o.returnTypeError);else if(o.code==="invalid_arguments")n(o.argumentsError);else if(o.path.length===0)r._errors.push(t(o));else{let i=r,d=0;for(;d<o.path.length;){const l=o.path[d];d===o.path.length-1?(i[l]=i[l]||{_errors:[]},i[l]._errors.push(t(o))):i[l]=i[l]||{_errors:[]},i=i[l],d++}}};return n(this),r}static assert(e){if(!(e instanceof L))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,v.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const n of this.issues)if(n.path.length>0){const a=n.path[0];t[a]=t[a]||[],t[a].push(e(n))}else r.push(e(n));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}L.create=s=>new L(s);const fe=(s,e)=>{let t;switch(s.code){case c.invalid_type:s.received===f.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case c.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,v.jsonStringifyReplacer)}`;break;case c.unrecognized_keys:t=`Unrecognized key(s) in object: ${v.joinValues(s.keys,", ")}`;break;case c.invalid_union:t="Invalid input";break;case c.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${v.joinValues(s.options)}`;break;case c.invalid_enum_value:t=`Invalid enum value. Expected ${v.joinValues(s.options)}, received '${s.received}'`;break;case c.invalid_arguments:t="Invalid function arguments";break;case c.invalid_return_type:t="Invalid function return type";break;case c.invalid_date:t="Invalid date";break;case c.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}"`:v.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case c.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==="bigint"?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 c.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 c.custom:t="Invalid input";break;case c.invalid_intersection_types:t="Intersection results could not be merged";break;case c.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case c.not_finite:t="Number must be finite";break;default:t=e.defaultError,v.assertNever(s)}return{message:t}};let Je=fe;function Ye(){return Je}const Qe=s=>{const{data:e,path:t,errorMaps:r,issueData:n}=s,a=[...t,...n.path||[]],o={...n,path:a};if(n.message!==void 0)return{...n,path:a,message:n.message};let i="";const d=r.filter(l=>!!l).slice().reverse();for(const l of d)i=l(o,{data:e,defaultError:i}).message;return{...n,path:a,message:i}};function u(s,e){const t=Ye(),r=Qe({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,t,t===fe?void 0:fe].filter(n=>!!n)});s.common.issues.push(r)}class S{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const n of t){if(n.status==="aborted")return g;n.status==="dirty"&&e.dirty(),r.push(n.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const n of t){const a=await n.key,o=await n.value;r.push({key:a,value:o})}return S.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const n of t){const{key:a,value:o}=n;if(a.status==="aborted"||o.status==="aborted")return g;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||n.alwaysSet)&&(r[a.value]=o.value)}return{status:e.value,value:r}}}const g=Object.freeze({status:"aborted"}),K=s=>({status:"dirty",value:s}),E=s=>({status:"valid",value:s}),xe=s=>s.status==="aborted",we=s=>s.status==="dirty",H=s=>s.status==="valid",se=s=>typeof Promise<"u"&&s instanceof Promise;var h;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(h||(h={}));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||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ce=(s,e)=>{if(H(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;const t=new L(s.common.issues);return this._error=t,this._error}}};function _(s){if(!s)return{};const{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:(o,i)=>{const{message:d}=s;return o.code==="invalid_enum_value"?{message:d??i.defaultError}:typeof i.data>"u"?{message:d??r??i.defaultError}:o.code!=="invalid_type"?{message:i.defaultError}:{message:d??t??i.defaultError}},description:n}}class b{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 S,ctx:{common:e.parent.common,data:e.data,parsedType:z(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(se(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){const r={common:{issues:[],async:(t==null?void 0:t.async)??!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)},n=this._parseSync({data:e,path:r.path,parent:r});return Ce(r,n)}"~validate"(e){var r,n;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:t});return H(a)?{value:a.value}:{issues:t.common.issues}}catch(a){(n=(r=a==null?void 0:a.message)==null?void 0:r.toLowerCase())!=null&&n.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(a=>H(a)?{value:a.value}:{issues:t.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const 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=await(se(n)?n:Promise.resolve(n));return Ce(r,a)}refine(e,t){const r=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{const o=e(n),i=()=>a.addIssue({code:c.custom,...r(n)});return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(i(),!1)):o?!0:(i(),!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:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}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.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return F.create(this,this._def)}nullable(){return Y.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return I.create(this)}promise(){return oe.create(this,this._def)}or(e){return ne.create([this,e],this._def)}and(e){return ae.create(this,e,this._def)}transform(e){return new J({..._(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new me({..._(this._def),innerType:this,defaultValue:t,typeName:y.ZodDefault})}brand(){return new kt({typeName:y.ZodBranded,type:this,..._(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ye({..._(this._def),innerType:this,catchValue:t,typeName:y.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ge.create(this,e)}readonly(){return ve.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ke=/^c[^\s-]{8,}$/i,et=/^[0-9a-z]+$/,tt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,st=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,rt=/^[a-z0-9_-]{21}$/i,nt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,at=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,it=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ot="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let he;const ct=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,dt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ut=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,lt=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ft=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ht=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Te="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",pt=new RegExp(`^${Te}$`);function Oe(s){let e="[0-5]\\d";s.precision?e=`${e}\\.\\d{${s.precision}}`:s.precision==null&&(e=`${e}(\\.\\d+)?`);const t=s.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function mt(s){return new RegExp(`^${Oe(s)}$`)}function yt(s){let e=`${Te}T${Oe(s)}`;const t=[];return t.push(s.local?"Z?":"Z"),s.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function gt(s,e){return!!((e==="v4"||!e)&&ct.test(s)||(e==="v6"||!e)&&ut.test(s))}function vt(s,e){if(!nt.test(s))return!1;try{const[t]=s.split(".");if(!t)return!1;const r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),n=JSON.parse(atob(r));return!(typeof n!="object"||n===null||"typ"in n&&(n==null?void 0:n.typ)!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function _t(s,e){return!!((e==="v4"||!e)&&dt.test(s)||(e==="v6"||!e)&<.test(s))}class P extends b{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){const a=this._getOrReturnCtx(e);return u(a,{code:c.invalid_type,expected:f.string,received:a.parsedType}),g}const r=new S;let n;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.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),u(n,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const o=e.data.length>a.value,i=e.data.length<a.value;(o||i)&&(n=this._getOrReturnCtx(e,n),o?u(n,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):i&&u(n,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")it.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"email",code:c.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")he||(he=new RegExp(ot,"u")),he.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"emoji",code:c.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")st.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"uuid",code:c.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")rt.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"nanoid",code:c.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")Ke.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"cuid",code:c.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")et.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"cuid2",code:c.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")tt.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"ulid",code:c.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),u(n,{validation:"url",code:c.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),u(n,{validation:"regex",code:c.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),u(n,{code:c.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),u(n,{code:c.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?yt(a).test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?pt.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?mt(a).test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?at.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"duration",code:c.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?gt(e.data,a.version)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"ip",code:c.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?vt(e.data,a.alg)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"jwt",code:c.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?_t(e.data,a.version)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"cidr",code:c.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?ft.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"base64",code:c.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?ht.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"base64url",code:c.invalid_string,message:a.message}),r.dirty()):v.assertNever(a);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(n=>e.test(n),{validation:t,code:c.invalid_string,...h.errToObj(r)})}_addCheck(e){return new P({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...h.errToObj(e)})}url(e){return this._addCheck({kind:"url",...h.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...h.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...h.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...h.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...h.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...h.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...h.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...h.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...h.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...h.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...h.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...h.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...h.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...h.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...h.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...h.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...h.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...h.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...h.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...h.errToObj(t)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new P({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new P({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new P({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}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 isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}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 isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}P.create=s=>new P({checks:[],typeName:y.ZodString,coerce:(s==null?void 0:s.coerce)??!1,..._(s)});function bt(s,e){const t=(s.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,n=t>r?t:r,a=Number.parseInt(s.toFixed(n).replace(".","")),o=Number.parseInt(e.toFixed(n).replace(".",""));return a%o/10**n}class W extends b{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){const a=this._getOrReturnCtx(e);return u(a,{code:c.invalid_type,expected:f.number,received:a.parsedType}),g}let r;const n=new S;for(const a of this._def.checks)a.kind==="int"?v.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),u(r,{code:c.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),u(r,{code:c.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),u(r,{code:c.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?bt(e.data,a.value)!==0&&(r=this._getOrReturnCtx(e,r),u(r,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),u(r,{code:c.not_finite,message:a.message}),n.dirty()):v.assertNever(a);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,r,n){return new W({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:h.toString(n)}]})}_addCheck(e){return new W({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:h.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:h.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:h.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:h.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const 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"&&v.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const 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)}}W.create=s=>new W({checks:[],typeName:y.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1,..._(s)});class ee extends b{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==f.bigint)return this._getInvalidInput(e);let r;const n=new S;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),u(r,{code:c.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),u(r,{code:c.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),u(r,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):v.assertNever(a);return{status:n.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return u(t,{code:c.invalid_type,expected:f.bigint,received:t.parsedType}),g}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,r,n){return new ee({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:h.toString(n)}]})}_addCheck(e){return new ee({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ee.create=s=>new ee({checks:[],typeName:y.ZodBigInt,coerce:(s==null?void 0:s.coerce)??!1,..._(s)});class Se extends b{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){const r=this._getOrReturnCtx(e);return u(r,{code:c.invalid_type,expected:f.boolean,received:r.parsedType}),g}return E(e.data)}}Se.create=s=>new Se({typeName:y.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1,..._(s)});class re extends b{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){const a=this._getOrReturnCtx(e);return u(a,{code:c.invalid_type,expected:f.date,received:a.parsedType}),g}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return u(a,{code:c.invalid_date}),g}const r=new S;let n;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.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),u(n,{code:c.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):v.assertNever(a);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new re({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:h.toString(t)})}get minDate(){let e=null;for(const 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(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}re.create=s=>new re({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:y.ZodDate,..._(s)});class Ae extends b{_parse(e){if(this._getType(e)!==f.symbol){const r=this._getOrReturnCtx(e);return u(r,{code:c.invalid_type,expected:f.symbol,received:r.parsedType}),g}return E(e.data)}}Ae.create=s=>new Ae({typeName:y.ZodSymbol,..._(s)});class Ee extends b{_parse(e){if(this._getType(e)!==f.undefined){const r=this._getOrReturnCtx(e);return u(r,{code:c.invalid_type,expected:f.undefined,received:r.parsedType}),g}return E(e.data)}}Ee.create=s=>new Ee({typeName:y.ZodUndefined,..._(s)});class Ne extends b{_parse(e){if(this._getType(e)!==f.null){const r=this._getOrReturnCtx(e);return u(r,{code:c.invalid_type,expected:f.null,received:r.parsedType}),g}return E(e.data)}}Ne.create=s=>new Ne({typeName:y.ZodNull,..._(s)});class Re extends b{constructor(){super(...arguments),this._any=!0}_parse(e){return E(e.data)}}Re.create=s=>new Re({typeName:y.ZodAny,..._(s)});class Ze extends b{constructor(){super(...arguments),this._unknown=!0}_parse(e){return E(e.data)}}Ze.create=s=>new Ze({typeName:y.ZodUnknown,..._(s)});class U extends b{_parse(e){const t=this._getOrReturnCtx(e);return u(t,{code:c.invalid_type,expected:f.never,received:t.parsedType}),g}}U.create=s=>new U({typeName:y.ZodNever,..._(s)});class je extends b{_parse(e){if(this._getType(e)!==f.undefined){const r=this._getOrReturnCtx(e);return u(r,{code:c.invalid_type,expected:f.void,received:r.parsedType}),g}return E(e.data)}}je.create=s=>new je({typeName:y.ZodVoid,..._(s)});class I extends b{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==f.array)return u(t,{code:c.invalid_type,expected:f.array,received:t.parsedType}),g;if(n.exactLength!==null){const o=t.data.length>n.exactLength.value,i=t.data.length<n.exactLength.value;(o||i)&&(u(t,{code:o?c.too_big:c.too_small,minimum:i?n.exactLength.value:void 0,maximum:o?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&&(u(t,{code:c.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&&(u(t,{code:c.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((o,i)=>n.type._parseAsync(new $(t,o,t.path,i)))).then(o=>S.mergeArray(r,o));const a=[...t.data].map((o,i)=>n.type._parseSync(new $(t,o,t.path,i)));return S.mergeArray(r,a)}get element(){return this._def.type}min(e,t){return new I({...this._def,minLength:{value:e,message:h.toString(t)}})}max(e,t){return new I({...this._def,maxLength:{value:e,message:h.toString(t)}})}length(e,t){return new I({...this._def,exactLength:{value:e,message:h.toString(t)}})}nonempty(e){return this.min(1,e)}}I.create=(s,e)=>new I({type:s,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,..._(e)});function X(s){if(s instanceof k){const e={};for(const t in s.shape){const r=s.shape[t];e[t]=F.create(X(r))}return new k({...s._def,shape:()=>e})}else return s instanceof I?new I({...s._def,type:X(s.element)}):s instanceof F?F.create(X(s.unwrap())):s instanceof Y?Y.create(X(s.unwrap())):s instanceof B?B.create(s.items.map(e=>X(e))):s}class k extends b{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=v.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==f.object){const l=this._getOrReturnCtx(e);return u(l,{code:c.invalid_type,expected:f.object,received:l.parsedType}),g}const{status:r,ctx:n}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),i=[];if(!(this._def.catchall instanceof U&&this._def.unknownKeys==="strip"))for(const l in n.data)o.includes(l)||i.push(l);const d=[];for(const l of o){const m=a[l],w=n.data[l];d.push({key:{status:"valid",value:l},value:m._parse(new $(n,w,n.path,l)),alwaysSet:l in n.data})}if(this._def.catchall instanceof U){const l=this._def.unknownKeys;if(l==="passthrough")for(const m of i)d.push({key:{status:"valid",value:m},value:{status:"valid",value:n.data[m]}});else if(l==="strict")i.length>0&&(u(n,{code:c.unrecognized_keys,keys:i}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const m of i){const w=n.data[m];d.push({key:{status:"valid",value:m},value:l._parse(new $(n,w,n.path,m)),alwaysSet:m in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const l=[];for(const m of d){const w=await m.key,x=await m.value;l.push({key:w,value:x,alwaysSet:m.alwaysSet})}return l}).then(l=>S.mergeObjectSync(r,l)):S.mergeObjectSync(r,d)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new k({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var a,o;const n=((o=(a=this._def).errorMap)==null?void 0:o.call(a,t,r).message)??r.defaultError;return t.code==="unrecognized_keys"?{message:h.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new k({...this._def,unknownKeys:"strip"})}passthrough(){return new k({...this._def,unknownKeys:"passthrough"})}extend(e){return new k({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new k({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new k({...this._def,catchall:e})}pick(e){const t={};for(const r of v.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new k({...this._def,shape:()=>t})}omit(e){const t={};for(const r of v.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new k({...this._def,shape:()=>t})}deepPartial(){return X(this)}partial(e){const t={};for(const r of v.objectKeys(this.shape)){const n=this.shape[r];e&&!e[r]?t[r]=n:t[r]=n.optional()}return new k({...this._def,shape:()=>t})}required(e){const t={};for(const r of v.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof F;)a=a._def.innerType;t[r]=a}return new k({...this._def,shape:()=>t})}keyof(){return Le(v.objectKeys(this.shape))}}k.create=(s,e)=>new k({shape:()=>s,unknownKeys:"strip",catchall:U.create(),typeName:y.ZodObject,..._(e)}),k.strictCreate=(s,e)=>new k({shape:()=>s,unknownKeys:"strict",catchall:U.create(),typeName:y.ZodObject,..._(e)}),k.lazycreate=(s,e)=>new k({shape:s,unknownKeys:"strip",catchall:U.create(),typeName:y.ZodObject,..._(e)});class ne extends b{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function n(a){for(const i of a)if(i.result.status==="valid")return i.result;for(const i of a)if(i.result.status==="dirty")return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(i=>new L(i.ctx.common.issues));return u(t,{code:c.invalid_union,unionErrors:o}),g}if(t.common.async)return Promise.all(r.map(async a=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(n);{let a;const o=[];for(const d of r){const l={...t,common:{...t.common,issues:[]},parent:null},m=d._parseSync({data:t.data,path:t.path,parent:l});if(m.status==="valid")return m;m.status==="dirty"&&!a&&(a={result:m,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const i=o.map(d=>new L(d));return u(t,{code:c.invalid_union,unionErrors:i}),g}}get options(){return this._def.options}}ne.create=(s,e)=>new ne({options:s,typeName:y.ZodUnion,..._(e)});function pe(s,e){const t=z(s),r=z(e);if(s===e)return{valid:!0,data:s};if(t===f.object&&r===f.object){const n=v.objectKeys(e),a=v.objectKeys(s).filter(i=>n.indexOf(i)!==-1),o={...s,...e};for(const i of a){const d=pe(s[i],e[i]);if(!d.valid)return{valid:!1};o[i]=d.data}return{valid:!0,data:o}}else if(t===f.array&&r===f.array){if(s.length!==e.length)return{valid:!1};const n=[];for(let a=0;a<s.length;a++){const o=s[a],i=e[a],d=pe(o,i);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}}class ae extends b{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=(a,o)=>{if(xe(a)||xe(o))return g;const i=pe(a.value,o.value);return i.valid?((we(a)||we(o))&&t.dirty(),{status:t.value,value:i.data}):(u(r,{code:c.invalid_intersection_types}),g)};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,o])=>n(a,o)):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}))}}ae.create=(s,e,t)=>new ae({left:s,right:e,typeName:y.ZodIntersection,..._(t)});class B extends b{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.array)return u(r,{code:c.invalid_type,expected:f.array,received:r.parsedType}),g;if(r.data.length<this._def.items.length)return u(r,{code:c.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;!this._def.rest&&r.data.length>this._def.items.length&&(u(r,{code:c.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...r.data].map((o,i)=>{const d=this._def.items[i]||this._def.rest;return d?d._parse(new $(r,o,r.path,i)):null}).filter(o=>!!o);return r.common.async?Promise.all(a).then(o=>S.mergeArray(t,o)):S.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new B({...this._def,rest:e})}}B.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new B({items:s,typeName:y.ZodTuple,rest:null,..._(e)})};class ie extends b{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.object)return u(r,{code:c.invalid_type,expected:f.object,received:r.parsedType}),g;const n=[],a=this._def.keyType,o=this._def.valueType;for(const i in r.data)n.push({key:a._parse(new $(r,i,r.path,i)),value:o._parse(new $(r,r.data[i],r.path,i)),alwaysSet:i in r.data});return r.common.async?S.mergeObjectAsync(t,n):S.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof b?new ie({keyType:e,valueType:t,typeName:y.ZodRecord,..._(r)}):new ie({keyType:P.create(),valueType:e,typeName:y.ZodRecord,..._(t)})}}class $e extends b{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.map)return u(r,{code:c.invalid_type,expected:f.map,received:r.parsedType}),g;const n=this._def.keyType,a=this._def.valueType,o=[...r.data.entries()].map(([i,d],l)=>({key:n._parse(new $(r,i,r.path,[l,"key"])),value:a._parse(new $(r,d,r.path,[l,"value"]))}));if(r.common.async){const i=new Map;return Promise.resolve().then(async()=>{for(const d of o){const l=await d.key,m=await d.value;if(l.status==="aborted"||m.status==="aborted")return g;(l.status==="dirty"||m.status==="dirty")&&t.dirty(),i.set(l.value,m.value)}return{status:t.value,value:i}})}else{const i=new Map;for(const d of o){const l=d.key,m=d.value;if(l.status==="aborted"||m.status==="aborted")return g;(l.status==="dirty"||m.status==="dirty")&&t.dirty(),i.set(l.value,m.value)}return{status:t.value,value:i}}}}$e.create=(s,e,t)=>new $e({valueType:e,keyType:s,typeName:y.ZodMap,..._(t)});class te extends b{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.set)return u(r,{code:c.invalid_type,expected:f.set,received:r.parsedType}),g;const n=this._def;n.minSize!==null&&r.data.size<n.minSize.value&&(u(r,{code:c.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&&(u(r,{code:c.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const a=this._def.valueType;function o(d){const l=new Set;for(const m of d){if(m.status==="aborted")return g;m.status==="dirty"&&t.dirty(),l.add(m.value)}return{status:t.value,value:l}}const i=[...r.data.values()].map((d,l)=>a._parse(new $(r,d,r.path,l)));return r.common.async?Promise.all(i).then(d=>o(d)):o(i)}min(e,t){return new te({...this._def,minSize:{value:e,message:h.toString(t)}})}max(e,t){return new te({...this._def,maxSize:{value:e,message:h.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}te.create=(s,e)=>new te({valueType:s,minSize:null,maxSize:null,typeName:y.ZodSet,..._(e)});class Ie extends b{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Ie.create=(s,e)=>new Ie({getter:s,typeName:y.ZodLazy,..._(e)});class Me extends b{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return u(t,{received:t.data,code:c.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:e.data}}get value(){return this._def.value}}Me.create=(s,e)=>new Me({value:s,typeName:y.ZodLiteral,..._(e)});function Le(s,e){return new G({values:s,typeName:y.ZodEnum,..._(e)})}class G extends b{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return u(t,{expected:v.joinValues(r),received:t.parsedType,code:c.invalid_type}),g}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return u(t,{received:t.data,code:c.invalid_enum_value,options:r}),g}return E(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return G.create(e,{...this._def,...t})}exclude(e,t=this._def){return G.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}G.create=Le;class Pe extends b{_parse(e){const t=v.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==f.string&&r.parsedType!==f.number){const n=v.objectValues(t);return u(r,{expected:v.joinValues(n),received:r.parsedType,code:c.invalid_type}),g}if(this._cache||(this._cache=new Set(v.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const n=v.objectValues(t);return u(r,{received:r.data,code:c.invalid_enum_value,options:n}),g}return E(e.data)}get enum(){return this._def.values}}Pe.create=(s,e)=>new Pe({values:s,typeName:y.ZodNativeEnum,..._(e)});class oe extends b{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return u(t,{code:c.invalid_type,expected:f.promise,received:t.parsedType}),g;const r=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return E(r.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}oe.create=(s,e)=>new oe({type:s,typeName:y.ZodPromise,..._(e)});class J extends b{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:o=>{u(r,o),o.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const o=n.transform(r.data,a);if(r.common.async)return Promise.resolve(o).then(async i=>{if(t.value==="aborted")return g;const d=await this._def.schema._parseAsync({data:i,path:r.path,parent:r});return d.status==="aborted"?g:d.status==="dirty"||t.value==="dirty"?K(d.value):d});{if(t.value==="aborted")return g;const i=this._def.schema._parseSync({data:o,path:r.path,parent:r});return i.status==="aborted"?g:i.status==="dirty"||t.value==="dirty"?K(i.value):i}}if(n.type==="refinement"){const o=i=>{const d=n.refinement(i,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 i};if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?g:(i.status==="dirty"&&t.dirty(),o(i.value),{status:t.value,value:i.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>i.status==="aborted"?g:(i.status==="dirty"&&t.dirty(),o(i.value).then(()=>({status:t.value,value:i.value}))))}if(n.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!H(o))return g;const i=n.transform(o.value,a);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:i}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>H(o)?Promise.resolve(n.transform(o.value,a)).then(i=>({status:t.value,value:i})):g);v.assertNever(n)}}J.create=(s,e,t)=>new J({schema:s,typeName:y.ZodEffects,effect:e,..._(t)}),J.createWithPreprocess=(s,e,t)=>new J({schema:e,effect:{type:"preprocess",transform:s},typeName:y.ZodEffects,..._(t)});class F extends b{_parse(e){return this._getType(e)===f.undefined?E(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}F.create=(s,e)=>new F({innerType:s,typeName:y.ZodOptional,..._(e)});class Y extends b{_parse(e){return this._getType(e)===f.null?E(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Y.create=(s,e)=>new Y({innerType:s,typeName:y.ZodNullable,..._(e)});class me extends b{_parse(e){const{ctx:t}=this._processInputParams(e);let 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}}me.create=(s,e)=>new me({innerType:s,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});class ye extends b{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return se(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new L(r.common.issues)},input:r.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new L(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}ye.create=(s,e)=>new ye({innerType:s,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});class De extends b{_parse(e){if(this._getType(e)!==f.nan){const r=this._getOrReturnCtx(e);return u(r,{code:c.invalid_type,expected:f.nan,received:r.parsedType}),g}return{status:"valid",value:e.data}}}De.create=s=>new De({typeName:y.ZodNaN,..._(s)});class kt extends b{_parse(e){const{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}}class ge extends b{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?g:a.status==="dirty"?(t.dirty(),K(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{const n=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return n.status==="aborted"?g: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 ge({in:e,out:t,typeName:y.ZodPipeline})}}class ve extends b{_parse(e){const t=this._def.innerType._parse(e),r=n=>(H(n)&&(n.value=Object.freeze(n.value)),n);return se(t)?t.then(n=>r(n)):r(t)}unwrap(){return this._def.innerType}}ve.create=(s,e)=>new ve({innerType:s,typeName:y.ZodReadonly,..._(e)});var y;(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",s.ZodReadonly="ZodReadonly"})(y||(y={}));const A=P.create,ce=W.create;U.create;const Z=I.create,D=k.create;ne.create,ae.create,B.create;const xt=ie.create,Ve=G.create;oe.create,F.create,Y.create;class ze extends Error{constructor(t){const r=`Invalid ChaosConfig:
|
|
2
|
+
${t.map(n=>` - ${n}`).join(`
|
|
3
|
+
`)}`;super(r);R(this,"issues");this.name="ChaosConfigError",this.issues=t}}const Q=ce().min(0,"Probability must be >= 0").max(1,"Probability must be <= 1"),wt=D({urlPattern:A().min(1,"urlPattern must not be empty"),methods:Z(A()).optional(),statusCode:ce().int().min(100).max(599),probability:Q,body:A().optional(),statusText:A().optional(),headers:xt(A()).optional()}).strict(),Ct=D({urlPattern:A().min(1,"urlPattern must not be empty"),methods:Z(A()).optional(),delayMs:ce().min(0,"delayMs must be >= 0"),probability:Q}).strict(),Tt=D({urlPattern:A().min(1,"urlPattern must not be empty"),methods:Z(A()).optional(),probability:Q,timeout:ce().min(0,"timeout must be >= 0").optional()}).strict(),Ot=D({urlPattern:A().min(1,"urlPattern must not be empty"),methods:Z(A()).optional(),probability:Q,strategy:Ve(["truncate","malformed-json","empty","wrong-type"])}).strict(),St=D({urlPattern:A().min(1,"urlPattern must not be empty"),methods:Z(A()).optional(),probability:Q}).strict(),At=D({failures:Z(wt).optional(),latencies:Z(Ct).optional(),aborts:Z(Tt).optional(),corruptions:Z(Ot).optional(),cors:Z(St).optional()}).strict(),Et=D({selector:A().min(1,"selector must not be empty"),action:Ve(["disable","hide","remove"]),probability:Q}).strict(),Nt=D({assaults:Z(Et).optional()}).strict(),Rt=D({network:At.optional(),ui:Nt.optional()}).strict();function Ue(s){const e=Rt.safeParse(s);if(!e.success){const t=e.error.issues.map(r=>`${r.path.join(".")}: ${r.message}`);throw new ze(t)}return e.data}class Fe{constructor(e=2e3){R(this,"listeners",new Map);R(this,"log",[]);this.maxLogEntries=e}on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){var r;(r=this.listeners.get(e))==null||r.delete(t)}emit(e){this.log.push(e),this.log.length>this.maxLogEntries&&this.log.shift(),this.notify(this.listeners.get(e.type),e),this.notify(this.listeners.get("*"),e)}getLog(){return[...this.log]}clearLog(){this.log=[]}notify(e,t){if(e)for(const r of e)try{r(t)}catch{}}}function j(s){return Math.random()<s}function M(s,e){return e==="*"?!0:s.includes(e)}function qe(s,e){switch(e){case"truncate":return s.slice(0,Math.max(0,Math.floor(s.length/2)));case"malformed-json":return`${s}"}`;case"empty":return"";case"wrong-type":return"<html><body>Unexpected HTML</body></html>"}}function _e(s){return typeof Request<"u"&&s instanceof Request}function Zt(s){return _e(s)?s.url:s.toString()}function jt(s,e){return e!=null&&e.method?e.method.toUpperCase():_e(s)?s.method.toUpperCase():"GET"}function $t(s,e){if(e!=null&&e.signal)return e.signal;if(_e(s))return s.signal}function It(){if(typeof DOMException<"u")return new DOMException("The user aborted a request.","AbortError");const s=new Error("The user aborted a request.");return s.name="AbortError",s}function Mt(s,e){if(!e)return s;const t=new AbortController,r=i=>{o(),t.signal.aborted||t.abort(i.reason)},n=()=>r(s),a=()=>r(e),o=()=>{s.removeEventListener("abort",n),e.removeEventListener("abort",a)};return s.aborted?(r(s),t.signal):e.aborted?(r(e),t.signal):(s.addEventListener("abort",n,{once:!0}),e.addEventListener("abort",a,{once:!0}),t.signal)}function Lt(s,e){return e?{...s??{},signal:e}:s}function Be(s,e,t,r,n){s==null||s.emit({type:"network:abort",timestamp:Date.now(),applied:n,detail:{url:t,method:r,timeoutMs:e.timeout}})}function de(s,e,t,r,n){s==null||s.emit({type:"network:corruption",timestamp:Date.now(),applied:n,detail:{url:t,method:r,strategy:e.strategy}})}function Pt(s,e,t){return async(r,n)=>{const a=Zt(r),o=jt(r,n),i=$t(r,n);if(e.cors){for(const p of e.cors)if(M(a,p.urlPattern)&&(!p.methods||p.methods.includes(o))){const N=j(p.probability);if(t==null||t.emit({type:"network:cors",timestamp:Date.now(),applied:N,detail:{url:a,method:o}}),N){console.debug(`[chaos-maker] CORS block: ${o} ${a}`);const V=new TypeError("Failed to fetch");throw V.stack="",V}}}let d=null,l,m,w=!1;const x=p=>{!d||w||(w=!0,m&&(clearTimeout(m),m=void 0),Be(t,d,a,o,p))};if(e.aborts){for(const p of e.aborts)if(M(a,p.urlPattern)&&(!p.methods||p.methods.includes(o))){if(!j(p.probability)){Be(t,p,a,o,!1);continue}console.warn(`CHAOS: Aborting ${o} ${a} after ${p.timeout||0}ms`),d=p;const V=new AbortController;l=Mt(V.signal,i);const le=()=>{w||(x(!0),V.abort(It()))};p.timeout?m=setTimeout(le,p.timeout):le();break}}if(d)try{const p=await s(r,Lt(n,l));return x(!1),p}catch(p){throw x(!1),p}if(e.failures){for(const p of e.failures)if(M(a,p.urlPattern)&&(!p.methods||p.methods.includes(o))){const N=j(p.probability);if(t==null||t.emit({type:"network:failure",timestamp:Date.now(),applied:N,detail:{url:a,method:o,statusCode:p.statusCode}}),N){console.warn(`CHAOS: Forcing ${p.statusCode} for ${o} ${a}`);const V=p.body??JSON.stringify({error:"Chaos Maker Attack!"}),le=p.headers??{};return new Response(V,{status:p.statusCode,statusText:p.statusText??"Service Unavailable (Chaos)",headers:le})}}}if(e.latencies){for(const p of e.latencies)if(M(a,p.urlPattern)&&(!p.methods||p.methods.includes(o))){const N=j(p.probability);t==null||t.emit({type:"network:latency",timestamp:Date.now(),applied:N,detail:{url:a,method:o,delayMs:p.delayMs}}),N&&(console.warn(`CHAOS: Adding ${p.delayMs}ms latency to ${o} ${a}`),await new Promise(V=>setTimeout(V,p.delayMs)))}}let O=null;if(e.corruptions){for(const p of e.corruptions)if(M(a,p.urlPattern)&&(!p.methods||p.methods.includes(o))){if(!j(p.probability)){de(t,p,a,o,!1);continue}O=p;break}}let C;try{C=await s(r,n)}catch(p){throw O&&de(t,O,a,o,!1),p}if(!O)return C;try{console.warn(`CHAOS: Corrupting response for ${o} ${a} with strategy: ${O.strategy}`);const p=await C.text(),N=qe(p,O.strategy);return de(t,O,a,o,!0),new Response(N,{status:C.status,statusText:C.statusText,headers:C.headers})}catch(p){throw de(t,O,a,o,!1),p}}}function He(s,e,t,r,n){s==null||s.emit({type:"network:abort",timestamp:Date.now(),applied:n,detail:{url:t,method:r,timeoutMs:e.timeout}})}function We(s,e,t,r,n){s==null||s.emit({type:"network:corruption",timestamp:Date.now(),applied:n,detail:{url:t,method:r,strategy:e.strategy}})}function Dt(s,e,t){return function(r){const n=this._chaos_url,a=this._chaos_method;if(e.cors){for(const i of e.cors)if(M(n,i.urlPattern)&&(!i.methods||i.methods.includes(a))){const d=j(i.probability);if(t==null||t.emit({type:"network:cors",timestamp:Date.now(),applied:d,detail:{url:n,method:a}}),d){console.debug(`[chaos-maker] CORS block: ${a} ${n}`),Object.defineProperty(this,"status",{value:0}),Object.defineProperty(this,"statusText",{value:""}),this.dispatchEvent(new Event("error")),this.dispatchEvent(new Event("loadend"));return}}}if(e.aborts){for(const i of e.aborts)if(M(n,i.urlPattern)&&(!i.methods||i.methods.includes(a))){if(!j(i.probability)){He(t,i,n,a,!1);continue}console.warn(`CHAOS: Aborting ${a} ${n} after ${i.timeout||0}ms`);let l=!1,m;const w=()=>{m&&(clearTimeout(m),m=void 0),typeof this.removeEventListener=="function"&&this.removeEventListener("loadend",O)},x=p=>{l||(l=!0,w(),He(t,i,n,a,p))},O=()=>{x(!1)},C=()=>{l||(x(!0),this.abort())};typeof this.addEventListener=="function"&&this.addEventListener("loadend",O);try{s.call(this,r)}catch(p){throw x(!1),p}if(l)return;i.timeout?m=setTimeout(C,i.timeout):C();return}}if(e.failures){for(const i of e.failures)if(M(n,i.urlPattern)&&(!i.methods||i.methods.includes(a))){const d=j(i.probability);if(t==null||t.emit({type:"network:failure",timestamp:Date.now(),applied:d,detail:{url:n,method:a,statusCode:i.statusCode}}),d){console.warn(`CHAOS: Forcing ${i.statusCode} for ${a} ${n}`),Object.defineProperty(this,"status",{value:i.statusCode}),Object.defineProperty(this,"statusText",{value:i.statusText??"Service Unavailable (Chaos)"});const l=i.body??JSON.stringify({error:"Chaos Maker Attack!"});Object.defineProperty(this,"responseText",{value:l,configurable:!0});const m=i.headers??{};Object.defineProperty(this,"getResponseHeader",{value:w=>{const x=Object.keys(m).find(O=>O.toLowerCase()===w.toLowerCase());return x?m[x]:null},configurable:!0}),Object.defineProperty(this,"getAllResponseHeaders",{value:()=>Object.entries(m).map(([w,x])=>`${w}: ${x}`).join(`\r
|
|
4
|
+
`),configurable:!0}),this.dispatchEvent(new Event("error")),this.dispatchEvent(new Event("load")),this.dispatchEvent(new Event("loadend"));return}}}let o=null;if(e.corruptions){for(const i of e.corruptions)if(M(n,i.urlPattern)&&(!i.methods||i.methods.includes(a))){if(!j(i.probability)){We(t,i,n,a,!1);continue}o=i;break}}if(o){let i=!1,d=null;const l=()=>{typeof this.removeEventListener=="function"&&(this.removeEventListener("error",x),this.removeEventListener("abort",x),this.removeEventListener("loadend",O))},m=C=>{i||(i=!0,We(t,o,n,a,C),l())},w=()=>{if(d!==null)return d;delete this.responseText;try{const C=this.responseText;return typeof C!="string"?(Object.defineProperty(this,"responseText",{value:C,configurable:!0}),m(!1),C):(d=qe(C,o.strategy),Object.defineProperty(this,"responseText",{value:d,configurable:!0}),m(!0),d)}catch(C){throw m(!1),C}},x=()=>{m(!1)},O=()=>{if(!i)try{w()}catch{}};typeof this.addEventListener=="function"&&(this.addEventListener("error",x),this.addEventListener("abort",x),this.addEventListener("loadend",O)),Object.defineProperty(this,"responseText",{get(){return w()},configurable:!0})}if(e.latencies){for(const i of e.latencies)if(M(n,i.urlPattern)&&(!i.methods||i.methods.includes(a))){const d=j(i.probability);if(t==null||t.emit({type:"network:latency",timestamp:Date.now(),applied:d,detail:{url:n,method:a,delayMs:i.delayMs}}),d){console.warn(`CHAOS: Adding ${i.delayMs}ms latency to ${a} ${n}`),setTimeout(()=>{s.call(this,r)},i.delayMs);return}}}s.call(this,r)}}function Vt(s){return function(e,t){this._chaos_url=t.toString(),this._chaos_method=e.toUpperCase(),s.call(this,e,t)}}function be(s,e,t){const r=j(e.probability);if(t==null||t.emit({type:"ui:assault",timestamp:Date.now(),applied:r,detail:{selector:e.selector,action:e.action}}),!!r){console.warn(`CHAOS: Applying action '${e.action}' to element:`,s);try{switch(e.action){case"disable":"disabled"in s&&(s.disabled=!0);break;case"hide":s.style.display="none";break;case"remove":s.remove();break}}catch(n){console.error("Chaos Maker failed to assault element:",n,s)}}}function zt(s,e,t){if(s.nodeType!==Node.ELEMENT_NODE||!e.assaults)return;const r=s;for(const n of e.assaults){try{r.matches(n.selector)&&be(r,n,t)}catch(a){console.error(`Chaos Maker: Invalid selector '${n.selector}'`,a)}r.querySelectorAll(n.selector).forEach(a=>{be(a,n,t)})}}function Ut(s,e){if(s.assaults){console.log("CHAOS: Running initial DOM scan for existing elements...");for(const r of s.assaults)try{document.querySelectorAll(r.selector).forEach(n=>{be(n,r,e)})}catch(n){console.error(`Chaos Maker: Invalid selector in initial scan '${r.selector}'`,n)}}return new MutationObserver(r=>{for(const n of r)n.type==="childList"&&n.addedNodes.forEach(a=>zt(a,s,e))})}class ke{constructor(e){R(this,"config");R(this,"emitter");R(this,"running",!1);R(this,"originalFetch");R(this,"originalXhrSend");R(this,"originalXhrOpen");R(this,"domObserver");this.config=Ue(e),this.emitter=new Fe,console.log("Chaos Maker initialized with config:",e)}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}getLog(){return this.emitter.getLog()}clearLog(){this.emitter.clearLog()}start(){if(this.running){console.warn("Chaos Maker is already running. Call stop() first.");return}this.running=!0,console.log("🛠️ Chaos Maker ENGAGED 🛠️"),this.config.network&&(this.originalFetch=window.fetch,window.fetch=Pt(this.originalFetch.bind(window),this.config.network,this.emitter),this.originalXhrOpen=window.XMLHttpRequest.prototype.open,window.XMLHttpRequest.prototype.open=Vt(this.originalXhrOpen),this.originalXhrSend=window.XMLHttpRequest.prototype.send,window.XMLHttpRequest.prototype.send=Dt(this.originalXhrSend,this.config.network,this.emitter)),this.config.ui&&(this.domObserver=Ut(this.config.ui,this.emitter),this.domObserver.observe(document.body,{childList:!0,subtree:!0}),console.log("UI Assailant is now observing the DOM."))}stop(){this.running=!1,console.log("🛑 Chaos Maker DISENGAGED 🛑"),this.originalFetch&&(window.fetch=this.originalFetch),this.originalXhrSend&&(window.XMLHttpRequest.prototype.send=this.originalXhrSend),this.originalXhrOpen&&(window.XMLHttpRequest.prototype.open=this.originalXhrOpen),this.domObserver&&(this.domObserver.disconnect(),console.log("UI Assailant has stopped observing."))}}function Xe(s){return JSON.parse(JSON.stringify(s))}class Ft{constructor(e){R(this,"config");this.config=e?Xe(e):{network:{},ui:{}},this.config.network||(this.config.network={}),this.config.ui||(this.config.ui={})}failRequests(e,t,r,n,a,o){return this.config.network.failures||(this.config.network.failures=[]),this.config.network.failures.push({urlPattern:e,statusCode:t,probability:r,methods:n,body:a,headers:o}),this}addLatency(e,t,r,n){return this.config.network.latencies||(this.config.network.latencies=[]),this.config.network.latencies.push({urlPattern:e,delayMs:t,probability:r,methods:n}),this}abortRequests(e,t,r,n){return this.config.network.aborts||(this.config.network.aborts=[]),this.config.network.aborts.push({urlPattern:e,probability:t,timeout:r,methods:n}),this}corruptResponses(e,t,r,n){return this.config.network.corruptions||(this.config.network.corruptions=[]),this.config.network.corruptions.push({urlPattern:e,strategy:t,probability:r,methods:n}),this}simulateCors(e,t,r){return this.config.network.cors||(this.config.network.cors=[]),this.config.network.cors.push({urlPattern:e,probability:t,methods:r}),this}assaultUi(e,t,r){return this.config.ui.assaults||(this.config.ui.assaults=[]),this.config.ui.assaults.push({selector:e,action:t,probability:r}),this}build(){return Xe(this.config)}}const ue="*";function Ge(s){if(s&&typeof s=="object"&&!Object.isFrozen(s)){Object.freeze(s);for(const e of Object.values(s))Ge(e)}return s}const qt=Ge({unstableApi:{network:{failures:[{urlPattern:"/api/",statusCode:500,probability:.1}],latencies:[{urlPattern:"/api/",delayMs:1e3,probability:.2}]}},slowNetwork:{network:{latencies:[{urlPattern:ue,delayMs:2e3,probability:1}]}},offlineMode:{network:{cors:[{urlPattern:ue,probability:1}]}},flakyConnection:{network:{aborts:[{urlPattern:ue,probability:.05}],latencies:[{urlPattern:ue,delayMs:3e3,probability:.1}]}},degradedUi:{ui:{assaults:[{selector:"button",action:"disable",probability:.2},{selector:"a",action:"hide",probability:.1}]}}});if(typeof window<"u"){window.ChaosMaker=ke;const s={instance:null,start:e=>{try{return s.instance&&s.instance.stop(),s.instance=new ke(e),s.instance.start(),{success:!0,message:"Chaos started"}}catch(t){return console.error("Chaos Utils Error:",t),{success:!1,message:t.message}}},stop:()=>s.instance?(s.instance.stop(),s.instance=null,{success:!0,message:"Chaos stopped"}):{success:!1,message:"No chaos instance to stop"},getLog:()=>s.instance?s.instance.getLog():[]};if(window.chaosUtils=s,window.__CHAOS_CONFIG__)try{const e=window.__CHAOS_CONFIG__;s.start(e),delete window.__CHAOS_CONFIG__}catch(e){console.error("ChaosMaker auto-start failed:",e)}}T.ChaosConfigBuilder=Ft,T.ChaosConfigError=ze,T.ChaosEventEmitter=Fe,T.ChaosMaker=ke,T.presets=qt,T.validateConfig=Ue,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ChaosConfig } from './config';
|
|
2
|
+
import { ChaosEvent, ChaosEventType, ChaosEventListener } from './events';
|
|
3
|
+
export declare class ChaosMaker {
|
|
4
|
+
private config;
|
|
5
|
+
private emitter;
|
|
6
|
+
private running;
|
|
7
|
+
private originalFetch?;
|
|
8
|
+
private originalXhrSend?;
|
|
9
|
+
private originalXhrOpen?;
|
|
10
|
+
private domObserver?;
|
|
11
|
+
constructor(config: ChaosConfig);
|
|
12
|
+
on(type: ChaosEventType | '*', listener: ChaosEventListener): void;
|
|
13
|
+
off(type: ChaosEventType | '*', listener: ChaosEventListener): void;
|
|
14
|
+
getLog(): ChaosEvent[];
|
|
15
|
+
clearLog(): void;
|
|
16
|
+
start(): void;
|
|
17
|
+
stop(): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ChaosConfig, CorruptionStrategy } from './config';
|
|
2
|
+
export declare class ChaosConfigBuilder {
|
|
3
|
+
private config;
|
|
4
|
+
constructor(initialConfig?: ChaosConfig);
|
|
5
|
+
failRequests(urlPattern: string, statusCode: number, probability: number, methods?: string[], body?: string, headers?: Record<string, string>): this;
|
|
6
|
+
addLatency(urlPattern: string, delayMs: number, probability: number, methods?: string[]): this;
|
|
7
|
+
abortRequests(urlPattern: string, probability: number, timeout?: number, methods?: string[]): this;
|
|
8
|
+
corruptResponses(urlPattern: string, strategy: CorruptionStrategy, probability: number, methods?: string[]): this;
|
|
9
|
+
simulateCors(urlPattern: string, probability: number, methods?: string[]): this;
|
|
10
|
+
assaultUi(selector: string, action: 'disable' | 'hide' | 'remove', probability: number): this;
|
|
11
|
+
build(): ChaosConfig;
|
|
12
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export interface NetworkFailureConfig {
|
|
2
|
+
urlPattern: string;
|
|
3
|
+
methods?: string[];
|
|
4
|
+
statusCode: number;
|
|
5
|
+
probability: number;
|
|
6
|
+
body?: string;
|
|
7
|
+
statusText?: string;
|
|
8
|
+
headers?: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
export interface NetworkLatencyConfig {
|
|
11
|
+
urlPattern: string;
|
|
12
|
+
methods?: string[];
|
|
13
|
+
delayMs: number;
|
|
14
|
+
probability: number;
|
|
15
|
+
}
|
|
16
|
+
export interface NetworkAbortConfig {
|
|
17
|
+
urlPattern: string;
|
|
18
|
+
methods?: string[];
|
|
19
|
+
probability: number;
|
|
20
|
+
timeout?: number;
|
|
21
|
+
}
|
|
22
|
+
export type CorruptionStrategy = 'truncate' | 'malformed-json' | 'empty' | 'wrong-type';
|
|
23
|
+
export interface NetworkCorruptionConfig {
|
|
24
|
+
urlPattern: string;
|
|
25
|
+
methods?: string[];
|
|
26
|
+
probability: number;
|
|
27
|
+
strategy: CorruptionStrategy;
|
|
28
|
+
}
|
|
29
|
+
export interface NetworkCorsConfig {
|
|
30
|
+
urlPattern: string;
|
|
31
|
+
methods?: string[];
|
|
32
|
+
probability: number;
|
|
33
|
+
}
|
|
34
|
+
export interface NetworkConfig {
|
|
35
|
+
failures?: NetworkFailureConfig[];
|
|
36
|
+
latencies?: NetworkLatencyConfig[];
|
|
37
|
+
aborts?: NetworkAbortConfig[];
|
|
38
|
+
corruptions?: NetworkCorruptionConfig[];
|
|
39
|
+
cors?: NetworkCorsConfig[];
|
|
40
|
+
}
|
|
41
|
+
export interface UiAssaultConfig {
|
|
42
|
+
selector: string;
|
|
43
|
+
action: 'disable' | 'hide' | 'remove';
|
|
44
|
+
probability: number;
|
|
45
|
+
}
|
|
46
|
+
export interface UiConfig {
|
|
47
|
+
assaults?: UiAssaultConfig[];
|
|
48
|
+
}
|
|
49
|
+
export interface ChaosConfig {
|
|
50
|
+
network?: NetworkConfig;
|
|
51
|
+
ui?: UiConfig;
|
|
52
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type ChaosEventType = 'network:failure' | 'network:latency' | 'network:abort' | 'network:corruption' | 'network:cors' | 'ui:assault';
|
|
2
|
+
export interface ChaosEvent {
|
|
3
|
+
type: ChaosEventType;
|
|
4
|
+
timestamp: number;
|
|
5
|
+
applied: boolean;
|
|
6
|
+
detail: {
|
|
7
|
+
url?: string;
|
|
8
|
+
method?: string;
|
|
9
|
+
statusCode?: number;
|
|
10
|
+
delayMs?: number;
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
strategy?: string;
|
|
13
|
+
selector?: string;
|
|
14
|
+
action?: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export type ChaosEventListener = (event: ChaosEvent) => void;
|
|
18
|
+
export declare class ChaosEventEmitter {
|
|
19
|
+
private readonly maxLogEntries;
|
|
20
|
+
private listeners;
|
|
21
|
+
private log;
|
|
22
|
+
constructor(maxLogEntries?: number);
|
|
23
|
+
on(type: ChaosEventType | '*', listener: ChaosEventListener): void;
|
|
24
|
+
off(type: ChaosEventType | '*', listener: ChaosEventListener): void;
|
|
25
|
+
emit(event: ChaosEvent): void;
|
|
26
|
+
getLog(): ChaosEvent[];
|
|
27
|
+
clearLog(): void;
|
|
28
|
+
private notify;
|
|
29
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ChaosMaker } from './ChaosMaker';
|
|
2
|
+
import { ChaosConfig, CorruptionStrategy, NetworkFailureConfig, NetworkLatencyConfig, NetworkAbortConfig, NetworkCorruptionConfig, NetworkCorsConfig, NetworkConfig, UiAssaultConfig, UiConfig } from './config';
|
|
3
|
+
import { ChaosConfigError } from './errors';
|
|
4
|
+
import { validateConfig } from './validation';
|
|
5
|
+
import { ChaosEvent, ChaosEventType, ChaosEventListener, ChaosEventEmitter } from './events';
|
|
6
|
+
import { ChaosConfigBuilder } from './builder';
|
|
7
|
+
import { presets } from './presets';
|
|
8
|
+
export { ChaosMaker, ChaosConfigError, validateConfig, ChaosEventEmitter, ChaosConfigBuilder, presets };
|
|
9
|
+
export type { ChaosConfig, CorruptionStrategy, NetworkFailureConfig, NetworkLatencyConfig, NetworkAbortConfig, NetworkCorruptionConfig, NetworkCorsConfig, NetworkConfig, UiAssaultConfig, UiConfig, ChaosEvent, ChaosEventType, ChaosEventListener };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { NetworkConfig } from '../config';
|
|
2
|
+
import { ChaosEventEmitter } from '../events';
|
|
3
|
+
export declare function patchFetch(originalFetch: typeof window.fetch, config: NetworkConfig, emitter?: ChaosEventEmitter): (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { NetworkConfig } from '../config';
|
|
2
|
+
import { ChaosEventEmitter } from '../events';
|
|
3
|
+
export declare function patchXHR(originalXhrSend: (body?: Document | XMLHttpRequestBodyInit) => void, config: NetworkConfig, emitter?: ChaosEventEmitter): (this: XMLHttpRequest, body?: Document | XMLHttpRequestBodyInit) => void;
|
|
4
|
+
export declare function patchXHROpen(originalXhrOpen: (method: string, url: string | URL) => void): (this: XMLHttpRequest, method: string, url: string | URL) => void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CorruptionStrategy } from './config';
|
|
2
|
+
export declare function shouldApplyChaos(probability: number): boolean;
|
|
3
|
+
export declare function matchUrl(url: string, pattern: string): boolean;
|
|
4
|
+
export declare function corruptText(text: string, strategy: CorruptionStrategy): string;
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chaos-maker/core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "A lightweight, framework-agnostic toolkit for injecting chaos into web applications to test frontend resilience",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"chaos-engineering",
|
|
8
|
+
"testing",
|
|
9
|
+
"resilience",
|
|
10
|
+
"fault-injection",
|
|
11
|
+
"e2e-testing",
|
|
12
|
+
"playwright",
|
|
13
|
+
"cypress",
|
|
14
|
+
"network-chaos",
|
|
15
|
+
"ui-testing"
|
|
16
|
+
],
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/jvjithin/chaos-maker.git",
|
|
21
|
+
"directory": "packages/core"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/jvjithin/chaos-maker",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/jvjithin/chaos-maker/issues"
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18"
|
|
29
|
+
},
|
|
30
|
+
"main": "./dist/chaos-maker.cjs",
|
|
31
|
+
"module": "./dist/chaos-maker.js",
|
|
32
|
+
"types": "./dist/types/index.d.ts",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./dist/types/index.d.ts",
|
|
37
|
+
"default": "./dist/chaos-maker.js"
|
|
38
|
+
},
|
|
39
|
+
"require": {
|
|
40
|
+
"types": "./dist/types/index.d.ts",
|
|
41
|
+
"default": "./dist/chaos-maker.cjs"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"dist"
|
|
47
|
+
],
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"zod": "^3.24.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@vitejs/plugin-basic-ssl": "^1.1.0",
|
|
53
|
+
"jsdom": "^27.0.1",
|
|
54
|
+
"typescript": "^5.4.5",
|
|
55
|
+
"vite": "^5.3.1",
|
|
56
|
+
"vitest": "^1.6.0"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"dev": "vite build --watch",
|
|
60
|
+
"build": "vite build && tsc -p tsconfig.build.json",
|
|
61
|
+
"test": "vitest"
|
|
62
|
+
}
|
|
63
|
+
}
|