UNPKG

eve

Version:

Filesystem-first framework for durable backend AI agents that run anywhere.

1 lines 10.5 kB
import{_i as e}from"../_chunks/client/core-Bm8azZA6.js";function t(e){return e instanceof Object&&`name`in e&&(e.name===`ZodError`||e.name===`$ZodError`)&&`issues`in e&&Array.isArray(e.issues)}var n=`ZodValidationError`,r=class extends Error{name;details;constructor(e,t){super(e,t),this.name=n,this.details=i(t)}toString(){return this.message}};function i(e){if(e){let n=e.cause;if(t(n))return n.issues}return[]}function a(e){return e instanceof r}function o(e){return e instanceof Error&&e.name===n}function s(e){return{type:e.code,path:e.path,message:e.message??`Invalid input`}}function c(e){return{type:e.code,path:e.path,message:`unexpected element in ${e.origin}`}}function l(e){return{type:e.code,path:e.path,message:`unexpected key in ${e.origin}`}}var u=new Set([`a`,`e`,`i`,`o`,`u`,`h`]);function d(e){let t=e.charAt(0).toLowerCase();return[u.has(t)?`an`:`a`,e].join(` `)}function f(e){return e.description??``}function p(e,t={}){switch(typeof e){case`symbol`:return f(e);case`bigint`:case`number`:switch(t.localization){case!0:return e.toLocaleString();case!1:return e.toString();default:return e.toLocaleString(t.localization)}case`string`:return t.wrapStringValueInQuote?`"${e}"`:e;default:if(e instanceof Date)switch(t.localization){case!0:return e.toLocaleString();case!1:return e.toISOString();default:return e.toLocaleString(t.localization)}return String(e)}}function m(e,t){let n=``;switch(e.format){case`lowercase`:case`uppercase`:n+=`expected ${e.format} string`;break;case`starts_with`:n+=`expected string to start with "${e.prefix}"`;break;case`ends_with`:n+=`expected string to end with "${e.suffix}"`;break;case`includes`:n+=`expected string to include "${e.includes}"`;break;case`regex`:n+=`expected string to match pattern`,t.displayInvalidFormatDetails&&(n+=` "${e.pattern}"`);break;case`jwt`:n+=`expected a jwt`,t.displayInvalidFormatDetails&&e.inst&&`alg`in e.inst._zod.def&&(n+=`/${e.inst._zod.def.alg}`),n+=` token`;break;case`email`:n+=`expected an email address`;break;case`url`:case`uuid`:case`guid`:case`cuid`:case`cuid2`:case`ulid`:case`xid`:case`ksuid`:n+=`expected a ${e.format.toUpperCase()}`,e.inst&&`version`in e.inst._zod.def&&(n+=` ${e.inst._zod.def.version}`);break;case`date`:case`datetime`:case`time`:case`duration`:n+=`expected an ISO ${e.format}`;break;case`ipv4`:case`ipv6`:n+=`expected an ${e.format.slice(0,2).toUpperCase()}${e.format.slice(2)} address`;break;case`cidrv4`:case`cidrv6`:n+=`expected a ${e.format.slice(0,4).toUpperCase()}${e.format.slice(4)} address range`;break;case`base64`:case`base64url`:n+=`expected a ${e.format} encoded string`;break;case`e164`:n+=`expected an E.164 formatted phone number`;break;default:if(e.format.startsWith(`sha`)||e.format.startsWith(`md5`)){let[t,r]=e.format.split(`_`);n+=`expected a ${t.toUpperCase()}`,r&&(n+=` ${r}-encoded`),n+=` hash`;break}n+=`expected ${d(e.format)}`}if(`input`in e&&t.reportInput===`typeAndValue`){let r=p(e.input,{wrapStringValueInQuote:!0,localization:t.numberLocalization});n+=`, received ${r}`}return{type:e.code,path:e.path,message:n}}function h(e){if(e===null)return!0;switch(typeof e){case`string`:case`number`:case`bigint`:case`boolean`:case`symbol`:case`undefined`:return!0;default:return!1}}function g(e,t){let n=`expected ${e.expected}`;if(`input`in e&&t.reportInput!==!1){let r=e.input;if(n+=`, received ${_(r)}`,t.reportInput===`typeAndValue`){if(h(r)){let e=p(r,{wrapStringValueInQuote:!0,localization:t.numberLocalization});n+=` (${e})`}else if(r instanceof Date){let e=p(r,{localization:t.dateLocalization});n+=` (${e})`}}}return{type:e.code,path:e.path,message:n}}function _(e){return typeof e==`object`?e===null?`null`:e===void 0?`undefined`:Array.isArray(e)?`array`:e instanceof Date?`date`:e instanceof RegExp?`regexp`:e instanceof Map?`map`:e instanceof Set?`set`:e instanceof Error?`error`:e instanceof Function?`function`:`object`:typeof e}function v(e){return{type:e.code,path:e.path,message:e.message??`Invalid input`}}function y(e,t){let n=(t.maxValuesToDisplay?e.slice(0,t.maxValuesToDisplay):e).map(e=>p(e,{wrapStringValueInQuote:t.wrapStringValuesInQuote}));return n.length<e.length&&n.push(`${e.length-n.length} more value(s)`),n.reduce((e,r,i)=>(i>0&&(i===n.length-1&&t.lastSeparator?e+=t.lastSeparator:e+=t.separator),e+=r,e),``)}function b(e,t){let n;if(n=e.expected===`stringbool`?`expected boolean as string`:e.values.length===0?`invalid value`:e.values.length===1?`expected value to be ${p(e.values[0],{wrapStringValueInQuote:!0})}`:`expected value to be one of ${y(e.values,{separator:t.allowedValuesSeparator,lastSeparator:t.allowedValuesLastSeparator,wrapStringValuesInQuote:t.wrapAllowedValuesInQuote,maxValuesToDisplay:t.maxAllowedValuesToDisplay})}`,`input`in e&&t.reportInput===`typeAndValue`){if(h(e.input)){let r=p(e.input,{wrapStringValueInQuote:!0,localization:t.numberLocalization});n+=`, received ${r}`}else if(e.input instanceof Date){let r=p(e.input,{localization:t.dateLocalization});n+=`, received ${r}`}}return{type:e.code,path:e.path,message:n}}function x(e,t){let n=`expected multiple of ${e.divisor}`;if(`input`in e&&t.reportInput===`typeAndValue`){let r=p(e.input,{wrapStringValueInQuote:!0,localization:t.numberLocalization});n+=`, received ${r}`}return{type:e.code,path:e.path,message:n}}function S(e,t){let n=e.origin===`date`?p(new Date(e.maximum),{localization:t.dateLocalization}):p(e.maximum,{localization:t.numberLocalization}),r=``;switch(e.origin){case`number`:case`int`:case`bigint`:r+=`expected number to be less than${e.inclusive?` or equal to`:``} ${n}`;break;case`string`:r+=`expected string to contain at most ${n} character(s)`;break;case`date`:r+=`expected date to be prior ${e.inclusive?`or equal to`:`to`} "${n}"`;break;case`array`:r+=`expected array to contain at most ${n} item(s)`;break;case`set`:r+=`expected set to contain at most ${n} item(s)`;break;case`file`:r+=`expected file to not exceed ${n} byte(s) in size`;break;default:r+=`expected value to be less than${e.inclusive?` or equal to`:``} ${n}`}if(`input`in e&&t.reportInput===`typeAndValue`){let n=e.input;if(h(n)){let e=p(n,{wrapStringValueInQuote:!0,localization:t.numberLocalization});r+=`, received ${e}`}else if(n instanceof Date){let e=p(n,{localization:t.dateLocalization});r+=`, received ${e}`}}return{type:e.code,path:e.path,message:r}}function C(e,t){let n=e.origin===`date`?p(new Date(e.minimum),{localization:t.dateLocalization}):p(e.minimum,{localization:t.numberLocalization}),r=``;switch(e.origin){case`number`:case`int`:case`bigint`:r+=`expected number to be greater than${e.inclusive?` or equal to`:``} ${n}`;break;case`date`:r+=`expected date to be ${e.inclusive?`later or equal to`:`later to`} "${n}"`;break;case`string`:r+=`expected string to contain at least ${n} character(s)`;break;case`array`:r+=`expected array to contain at least ${n} item(s)`;break;case`set`:r+=`expected set to contain at least ${n} item(s)`;break;case`file`:r+=`expected file to be at least ${n} byte(s) in size`;break;default:r+=`expected value to be greater than${e.inclusive?` or equal to`:``} ${n}`}if(`input`in e&&t.reportInput===`typeAndValue`){let n=e.input;if(h(n)){let e=p(n,{wrapStringValueInQuote:!0,localization:t.numberLocalization});r+=`, received ${e}`}else if(n instanceof Date){let e=p(n,{localization:t.dateLocalization});r+=`, received ${e}`}}return{type:e.code,path:e.path,message:r}}function w(e,t){let n=y(e.keys,{separator:t.unrecognizedKeysSeparator,lastSeparator:t.unrecognizedKeysLastSeparator,wrapStringValuesInQuote:t.wrapUnrecognizedKeysInQuote,maxValuesToDisplay:t.maxUnrecognizedKeysToDisplay});return{type:e.code,path:e.path,message:`unrecognized key(s) ${n} in object`}}var T={invalid_type:g,too_big:S,too_small:C,invalid_format:m,invalid_value:b,invalid_element:c,not_multiple_of:x,unrecognized_keys:w,invalid_key:l,custom:s,invalid_union:v},E={reportInput:`type`,displayInvalidFormatDetails:!1,allowedValuesSeparator:`, `,allowedValuesLastSeparator:` or `,wrapAllowedValuesInQuote:!0,maxAllowedValuesToDisplay:10,unrecognizedKeysSeparator:`, `,unrecognizedKeysLastSeparator:` and `,wrapUnrecognizedKeysInQuote:!0,maxUnrecognizedKeysToDisplay:5,dateLocalization:!0,numberLocalization:!0};function D(e={}){let t={...E,...e};return e=>{if(e.code===void 0)return`Not supported issue type`;let n=T[e.code];return n(e,t).message}}function O(e){return e.length!==0}var k=/[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*/u;function A(e){if(e.length===1){let t=e[0];return typeof t==`symbol`&&(t=f(t)),t.toString()||`""`}return e.reduce((e,t)=>typeof t==`number`?e+`[`+t.toString()+`]`:(typeof t==`symbol`&&(t=f(t)),t.includes(`"`)?e+`["`+j(t)+`"]`:k.test(t)?e+(e.length===0?``:`.`)+t:e+`["`+t+`"]`),``)}function j(e){return e.replace(/"/g,`\\"`)}function M(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}var N={prefix:`Validation error`,prefixSeparator:`: `,maxIssuesInMessage:99,unionSeparator:` or `,issueSeparator:`; `,includePath:!0,forceTitleCase:!0};function P(e={}){let t={...N,...e};return function(e){return I(e.slice(0,t.maxIssuesInMessage).map(e=>F(e,t)).join(t.issueSeparator),t)}}function F(e,t){if(e.code===`invalid_union`&&O(e.errors)){let n=e.errors.map(n=>n.map(n=>F({...n,path:e.path.concat(n.path)},t)).join(t.issueSeparator));return Array.from(new Set(n)).join(t.unionSeparator)}let n=[];t.forceTitleCase?n.push(M(e.message)):n.push(e.message);pathCondition:if(t.includePath&&e.path!==void 0&&O(e.path)){if(e.path.length===1){let t=e.path[0];if(typeof t==`number`){n.push(` at index ${t}`);break pathCondition}}n.push(` at "${A(e.path)}"`)}return n.join(``)}function I(e,t){return t.prefix==null?e.length>0?e:N.prefix:e.length>0?[t.prefix,e].join(t.prefixSeparator):t.prefix}function L(e,n={}){if(!t(e))throw TypeError(`Invalid zodError param; expected instance of ZodError. Did you mean to use the "${V.name}" method instead?`);return R(e,n)}function R(e,t={}){let n=e.issues,i;return i=O(n)?z(t)(n):e.message,new r(i,{cause:e})}function z(e){return`messageBuilder`in e?e.messageBuilder:P(e)}var B=(e={})=>n=>t(n)?R(n,e):n instanceof Error?new r(n.message,{cause:n}):new r(`Unknown error`);function V(e,t={}){return B(t)(e)}function H(t,n={}){return new r(U(n)([t]),{cause:new e([t])})}function U(e){return`messageBuilder`in e?e.messageBuilder:P(e)}export{r as ValidationError,D as createErrorMap,P as createMessageBuilder,V as fromError,L as fromZodError,H as fromZodIssue,a as isValidationError,o as isValidationErrorLike,t as isZodErrorLike,B as toValidationError};