@shipstatic/ship 3.4.0-beta.1 → 3.4.0-beta.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/README.md +1 -1
- package/dist/browser.d.ts +17 -20
- package/dist/browser.js +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -20
- package/dist/index.d.ts +18 -20
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -228,7 +228,7 @@ source '${a.completionFile}'
|
|
|
228
228
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let s=a[1];if(t===a[0]){o(a);continue}if(e.external){let u=e.external.registry.get(a[0])?.id;if(t!==a[0]&&u){o(a);continue}}if(e.metadataRegistry.get(a[0])?.id){o(a);continue}if(s.cycle){o(a);continue}if(s.count>1&&e.reused==="ref"){o(a);continue}}}function Xe(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=s=>{let c=e.seen.get(s);if(c.ref===null)return;let u=c.def??c.schema,l={...u},f=c.ref;if(c.ref=null,f){i(f);let _=e.seen.get(f),b=_.schema;if(b.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(b)):Object.assign(u,b),Object.assign(u,l),s._zod.parent===f)for(let D in u)D==="$ref"||D==="allOf"||D in l||delete u[D];if(b.$ref&&_.def)for(let D in u)D==="$ref"||D==="allOf"||D in _.def&&JSON.stringify(u[D])===JSON.stringify(_.def[D])&&delete u[D]}let p=s._zod.parent;if(p&&p!==f){i(p);let _=e.seen.get(p);if(_?.schema.$ref&&(u.$ref=_.schema.$ref,_.def))for(let b in u)b==="$ref"||b==="allOf"||b in _.def&&JSON.stringify(u[b])===JSON.stringify(_.def[b])&&delete u[b]}e.override({zodSchema:s,jsonSchema:u,path:c.path??[]})};for(let s of[...e.seen.entries()].reverse())i(s[0]);let n={};if(e.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");n.$id=e.external.uri(s)}Object.assign(n,r.def??r.schema);let o=e.metadataRegistry.get(t)?.id;o!==void 0&&n.id===o&&delete n.id;let a=e.external?.defs??{};for(let s of e.seen.entries()){let c=s[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,a[c.defId]=c.def)}e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?n.$defs=a:n.definitions=a);try{let s=JSON.parse(JSON.stringify(n));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:Rt(t,"input",e.processors),output:Rt(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function ne(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return ne(i.element,r);if(i.type==="set")return ne(i.valueType,r);if(i.type==="lazy")return ne(i.getter(),r);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault")return ne(i.innerType,r);if(i.type==="intersection")return ne(i.left,r)||ne(i.right,r);if(i.type==="record"||i.type==="map")return ne(i.keyType,r)||ne(i.valueType,r);if(i.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:ne(i.in,r)||ne(i.out,r);if(i.type==="object"){for(let n in i.shape)if(ne(i.shape[n],r))return!0;return!1}if(i.type==="union"){for(let n of i.options)if(ne(n,r))return!0;return!1}if(i.type==="tuple"){for(let n of i.items)if(ne(n,r))return!0;return!!(i.rest&&ne(i.rest,r))}return!1}var tu=(e,t={})=>r=>{let i=qe({...r,processors:t});return U(e,i),Ke(i,e),Xe(i,e)},Rt=(e,t,r={})=>i=>{let{libraryOptions:n,target:o}=i??{},a=qe({...n??{},target:o,io:t,processors:r});return U(e,a),Ke(a,e),Xe(a,e)};var lx={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},nu=(e,t,r,i)=>{let n=r;n.type="string";let{minimum:o,maximum:a,format:s,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof o=="number"&&(n.minLength=o),typeof a=="number"&&(n.maxLength=a),s&&(n.format=lx[s]??s,n.format===""&&delete n.format,s==="time"&&delete n.format),u&&(n.contentEncoding=u),c&&c.size>0){let l=[...c];l.length===1?n.pattern=l[0].source:l.length>1&&(n.allOf=[...l.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},ru=(e,t,r,i)=>{let n=r,{minimum:o,maximum:a,format:s,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;typeof s=="string"&&s.includes("int")?n.type="integer":n.type="number";let f=typeof l=="number"&&l>=(o??Number.NEGATIVE_INFINITY),p=typeof u=="number"&&u<=(a??Number.POSITIVE_INFINITY),_=t.target==="draft-04"||t.target==="openapi-3.0";f?_?(n.minimum=l,n.exclusiveMinimum=!0):n.exclusiveMinimum=l:typeof o=="number"&&(n.minimum=o),p?_?(n.maximum=u,n.exclusiveMaximum=!0):n.exclusiveMaximum=u:typeof a=="number"&&(n.maximum=a),typeof c=="number"&&(n.multipleOf=c)},iu=(e,t,r,i)=>{r.type="boolean"},ou=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},au=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},su=(e,t,r,i)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},cu=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},uu=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},lu=(e,t,r,i)=>{r.not={}},du=(e,t,r,i)=>{},pu=(e,t,r,i)=>{},mu=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},fu=(e,t,r,i)=>{let n=e._zod.def,o=pn(n.entries);o.every(a=>typeof a=="number")&&(r.type="number"),o.every(a=>typeof a=="string")&&(r.type="string"),r.enum=o},hu=(e,t,r,i)=>{let n=e._zod.def,o=[];for(let a of n.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(a))}else o.push(a);if(o.length!==0)if(o.length===1){let a=o[0];r.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[a]:r.const=a}else o.every(a=>typeof a=="number")&&(r.type="number"),o.every(a=>typeof a=="string")&&(r.type="string"),o.every(a=>typeof a=="boolean")&&(r.type="boolean"),o.every(a=>a===null)&&(r.type="null"),r.enum=o},gu=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},vu=(e,t,r,i)=>{let n=r,o=e._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");n.type="string",n.pattern=o.source},_u=(e,t,r,i)=>{let n=r,o={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:s,mime:c}=e._zod.bag;a!==void 0&&(o.minLength=a),s!==void 0&&(o.maxLength=s),c?c.length===1?(o.contentMediaType=c[0],Object.assign(n,o)):(Object.assign(n,o),n.anyOf=c.map(u=>({contentMediaType:u}))):Object.assign(n,o)},yu=(e,t,r,i)=>{r.type="boolean"},$u=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},xu=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},bu=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Su=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},ku=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},wu=(e,t,r,i)=>{let n=r,o=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;typeof a=="number"&&(n.minItems=a),typeof s=="number"&&(n.maxItems=s),n.type="array",n.items=U(o.element,t,{...i,path:[...i.path,"items"]})},Iu=(e,t,r,i)=>{let n=r,o=e._zod.def;n.type="object",n.properties={};let a=o.shape;for(let u in a)n.properties[u]=U(a[u],t,{...i,path:[...i.path,"properties",u]});let s=new Set(Object.keys(a)),c=new Set([...s].filter(u=>{let l=o.shape[u]._zod;return t.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(n.required=Array.from(c)),o.catchall?._zod.def.type==="never"?n.additionalProperties=!1:o.catchall?o.catchall&&(n.additionalProperties=U(o.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):t.io==="output"&&(n.additionalProperties=!1)},di=(e,t,r,i)=>{let n=e._zod.def,o=n.inclusive===!1,a=n.options.map((s,c)=>U(s,t,{...i,path:[...i.path,o?"oneOf":"anyOf",c]}));o?r.oneOf=a:r.anyOf=a},Ou=(e,t,r,i)=>{let n=e._zod.def,o=U(n.left,t,{...i,path:[...i.path,"allOf",0]}),a=U(n.right,t,{...i,path:[...i.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1,c=[...s(o)?o.allOf:[o],...s(a)?a.allOf:[a]];r.allOf=c},zu=(e,t,r,i)=>{let n=r,o=e._zod.def;n.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=o.items.map((p,_)=>U(p,t,{...i,path:[...i.path,a,_]})),u=o.rest?U(o.rest,t,{...i,path:[...i.path,s,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null;t.target==="draft-2020-12"?(n.prefixItems=c,u&&(n.items=u)):t.target==="openapi-3.0"?(n.items={anyOf:c},u&&n.items.anyOf.push(u),n.minItems=c.length,u||(n.maxItems=c.length)):(n.items=c,u&&(n.additionalItems=u));let{minimum:l,maximum:f}=e._zod.bag;typeof l=="number"&&(n.minItems=l),typeof f=="number"&&(n.maxItems=f)},Eu=(e,t,r,i)=>{let n=r,o=e._zod.def;n.type="object";let a=o.keyType,c=a._zod.bag?.patterns;if(o.mode==="loose"&&c&&c.size>0){let l=U(o.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});n.patternProperties={};for(let f of c)n.patternProperties[f.source]=l}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(n.propertyNames=U(o.keyType,t,{...i,path:[...i.path,"propertyNames"]})),n.additionalProperties=U(o.valueType,t,{...i,path:[...i.path,"additionalProperties"]});let u=a._zod.values;if(u){let l=[...u].filter(f=>typeof f=="string"||typeof f=="number");l.length>0&&(n.required=l)}},Du=(e,t,r,i)=>{let n=e._zod.def,o=U(n.innerType,t,i),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=n.innerType,r.nullable=!0):r.anyOf=[o,{type:"null"}]},Tu=(e,t,r,i)=>{let n=e._zod.def;U(n.innerType,t,i);let o=t.seen.get(e);o.ref=n.innerType},Pu=(e,t,r,i)=>{let n=e._zod.def;U(n.innerType,t,i);let o=t.seen.get(e);o.ref=n.innerType,r.default=JSON.parse(JSON.stringify(n.defaultValue))},Au=(e,t,r,i)=>{let n=e._zod.def;U(n.innerType,t,i);let o=t.seen.get(e);o.ref=n.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(n.defaultValue)))},Cu=(e,t,r,i)=>{let n=e._zod.def;U(n.innerType,t,i);let o=t.seen.get(e);o.ref=n.innerType;let a;try{a=n.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=a},ju=(e,t,r,i)=>{let n=e._zod.def,o=n.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?o?n.out:n.in:n.out;U(a,t,i);let s=t.seen.get(e);s.ref=a},Nu=(e,t,r,i)=>{let n=e._zod.def;U(n.innerType,t,i);let o=t.seen.get(e);o.ref=n.innerType,r.readOnly=!0},Uu=(e,t,r,i)=>{let n=e._zod.def;U(n.innerType,t,i);let o=t.seen.get(e);o.ref=n.innerType},pi=(e,t,r,i)=>{let n=e._zod.def;U(n.innerType,t,i);let o=t.seen.get(e);o.ref=n.innerType},Ru=(e,t,r,i)=>{let n=e._zod.innerType;U(n,t,i);let o=t.seen.get(e);o.ref=n},li={string:nu,number:ru,boolean:iu,bigint:ou,symbol:au,null:su,undefined:cu,void:uu,never:lu,any:du,unknown:pu,date:mu,enum:fu,literal:hu,nan:gu,template_literal:vu,file:_u,success:yu,custom:$u,function:xu,transform:bu,map:Su,set:ku,array:wu,object:Iu,union:di,intersection:Ou,tuple:zu,record:Eu,nullable:Du,nonoptional:Tu,default:Pu,prefault:Au,catch:Cu,pipe:ju,readonly:Nu,promise:Uu,optional:pi,lazy:Ru};function mi(e,t){if("_idmap"in e){let i=e,n=qe({...t,processors:li}),o={};for(let c of i._idmap.entries()){let[u,l]=c;U(l,n)}let a={},s={registry:i,uri:t?.uri,defs:o};n.external=s;for(let c of i._idmap.entries()){let[u,l]=c;Ke(n,l),a[u]=Xe(n,l)}if(Object.keys(o).length>0){let c=n.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[c]:o}}return{schemas:a}}let r=qe({...t,processors:li});return U(e,r),Ke(r,e),Xe(r,e)}var fi=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=qe({processors:li,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return U(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),Ke(this.ctx,t);let i=Xe(this.ctx,t),{"~standard":n,...o}=i;return o}};var Xm={};var Dn={};pe(Dn,{ZodAny:()=>cl,ZodArray:()=>pl,ZodBase64:()=>ji,ZodBase64URL:()=>Ni,ZodBigInt:()=>Ht,ZodBigIntFormat:()=>Li,ZodBoolean:()=>Gt,ZodCIDRv4:()=>Ai,ZodCIDRv6:()=>Ci,ZodCUID:()=>Ii,ZodCUID2:()=>Oi,ZodCatch:()=>Cl,ZodCodec:()=>Mn,ZodCustom:()=>Vn,ZodCustomStringFormat:()=>Vt,ZodDate:()=>Un,ZodDefault:()=>zl,ZodDiscriminatedUnion:()=>fl,ZodE164:()=>Ui,ZodEmail:()=>Si,ZodEmoji:()=>ki,ZodEnum:()=>Zt,ZodExactOptional:()=>wl,ZodFile:()=>Sl,ZodFunction:()=>Bl,ZodGUID:()=>Pn,ZodIPv4:()=>Ti,ZodIPv6:()=>Pi,ZodIntersection:()=>hl,ZodJWT:()=>Ri,ZodKSUID:()=>Di,ZodLazy:()=>Zl,ZodLiteral:()=>bl,ZodMAC:()=>tl,ZodMap:()=>$l,ZodNaN:()=>Nl,ZodNanoID:()=>wi,ZodNever:()=>ll,ZodNonOptional:()=>Gi,ZodNull:()=>al,ZodNullable:()=>Ol,ZodNumber:()=>Bt,ZodNumberFormat:()=>ut,ZodObject:()=>Ln,ZodOptional:()=>Bi,ZodPipe:()=>Zn,ZodPrefault:()=>Dl,ZodPreprocess:()=>Ul,ZodPromise:()=>Vl,ZodReadonly:()=>Rl,ZodRecord:()=>Ft,ZodSet:()=>xl,ZodString:()=>Mt,ZodStringFormat:()=>L,ZodSuccess:()=>Al,ZodSymbol:()=>il,ZodTemplateLiteral:()=>Fl,ZodTransform:()=>kl,ZodTuple:()=>vl,ZodType:()=>C,ZodULID:()=>zi,ZodURL:()=>Nn,ZodUUID:()=>Oe,ZodUndefined:()=>ol,ZodUnion:()=>Fn,ZodUnknown:()=>ul,ZodVoid:()=>dl,ZodXID:()=>Ei,ZodXor:()=>ml,_ZodString:()=>bi,_default:()=>El,_function:()=>sh,any:()=>Rf,array:()=>Rn,base64:()=>xf,base64url:()=>bf,bigint:()=>Af,boolean:()=>rl,catch:()=>jl,check:()=>ch,cidrv4:()=>yf,cidrv6:()=>$f,codec:()=>rh,cuid:()=>df,cuid2:()=>pf,custom:()=>uh,date:()=>Ff,describe:()=>lh,discriminatedUnion:()=>Hf,e164:()=>Sf,email:()=>ef,emoji:()=>uf,enum:()=>Mi,exactOptional:()=>Il,file:()=>Qf,float32:()=>Ef,float64:()=>Df,function:()=>sh,guid:()=>tf,hash:()=>zf,hex:()=>Of,hostname:()=>If,httpUrl:()=>cf,instanceof:()=>ph,int:()=>$i,int32:()=>Tf,int64:()=>Cf,intersection:()=>gl,invertCodec:()=>ih,ipv4:()=>gf,ipv6:()=>_f,json:()=>fh,jwt:()=>kf,keyof:()=>Zf,ksuid:()=>hf,lazy:()=>Ml,literal:()=>Yf,looseObject:()=>Bf,looseRecord:()=>Wf,mac:()=>vf,map:()=>qf,meta:()=>dh,nan:()=>nh,nanoid:()=>lf,nativeEnum:()=>Xf,never:()=>Fi,nonoptional:()=>Pl,null:()=>sl,nullable:()=>Cn,nullish:()=>eh,number:()=>nl,object:()=>Mf,optional:()=>An,partialRecord:()=>Jf,pipe:()=>xi,prefault:()=>Tl,preprocess:()=>hh,promise:()=>ah,readonly:()=>Ll,record:()=>yl,refine:()=>Gl,set:()=>Kf,strictObject:()=>Vf,string:()=>Tn,stringFormat:()=>wf,stringbool:()=>mh,success:()=>th,superRefine:()=>Hl,symbol:()=>Nf,templateLiteral:()=>oh,transform:()=>Vi,tuple:()=>_l,uint32:()=>Pf,uint64:()=>jf,ulid:()=>mf,undefined:()=>Uf,union:()=>Zi,unknown:()=>ct,url:()=>sf,uuid:()=>nf,uuidv4:()=>rf,uuidv6:()=>of,uuidv7:()=>af,void:()=>Lf,xid:()=>ff,xor:()=>Gf});var hi={};pe(hi,{endsWith:()=>Dt,gt:()=>we,gte:()=>te,includes:()=>zt,length:()=>st,lowercase:()=>It,lt:()=>ke,lte:()=>le,maxLength:()=>at,maxSize:()=>We,mime:()=>Tt,minLength:()=>Ce,minSize:()=>Ie,multipleOf:()=>Je,negative:()=>ai,nonnegative:()=>ci,nonpositive:()=>si,normalize:()=>Pt,overwrite:()=>$e,positive:()=>oi,property:()=>ui,regex:()=>wt,size:()=>ot,slugify:()=>Nt,startsWith:()=>Et,toLowerCase:()=>Ct,toUpperCase:()=>jt,trim:()=>At,uppercase:()=>Ot});var Lt={};pe(Lt,{ZodISODate:()=>vi,ZodISODateTime:()=>gi,ZodISODuration:()=>yi,ZodISOTime:()=>_i,date:()=>Fu,datetime:()=>Lu,duration:()=>Mu,time:()=>Zu});var gi=v("ZodISODateTime",(e,t)=>{gs.init(e,t),L.init(e,t)});function Lu(e){return $c(gi,e)}var vi=v("ZodISODate",(e,t)=>{vs.init(e,t),L.init(e,t)});function Fu(e){return xc(vi,e)}var _i=v("ZodISOTime",(e,t)=>{_s.init(e,t),L.init(e,t)});function Zu(e){return bc(_i,e)}var yi=v("ZodISODuration",(e,t)=>{ys.init(e,t),L.init(e,t)});function Mu(e){return Sc(yi,e)}var Ym=(e,t)=>{vn.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>yn(e,r)},flatten:{value:r=>_n(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,gt,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,gt,2)}},isEmpty:{get(){return e.issues.length===0}}})},px=v("ZodError",Ym),ae=v("ZodError",Ym,{Parent:Error});var Vu=yt(ae),Bu=$t(ae),Gu=xt(ae),Hu=bt(ae),Ju=mr(ae),Wu=fr(ae),qu=hr(ae),Ku=gr(ae),Xu=vr(ae),Yu=_r(ae),Qu=yr(ae),el=$r(ae);var Qm=new WeakMap;function jn(e,t,r){let i=Object.getPrototypeOf(e),n=Qm.get(i);if(n||(n=new Set,Qm.set(i,n)),!n.has(t)){n.add(t);for(let o in r){let a=r[o];Object.defineProperty(i,o,{configurable:!0,enumerable:!1,get(){let s=a.bind(this);return Object.defineProperty(this,o,{configurable:!0,writable:!0,enumerable:!0,value:s}),s},set(s){Object.defineProperty(this,o,{configurable:!0,writable:!0,enumerable:!0,value:s})}})}}}var C=v("ZodType",(e,t)=>(A.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Rt(e,"input"),output:Rt(e,"output")}}),e.toJSONSchema=tu(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,i)=>Vu(e,r,i,{callee:e.parse}),e.safeParse=(r,i)=>Gu(e,r,i),e.parseAsync=async(r,i)=>Bu(e,r,i,{callee:e.parseAsync}),e.safeParseAsync=async(r,i)=>Hu(e,r,i),e.spa=e.safeParseAsync,e.encode=(r,i)=>Ju(e,r,i),e.decode=(r,i)=>Wu(e,r,i),e.encodeAsync=async(r,i)=>qu(e,r,i),e.decodeAsync=async(r,i)=>Ku(e,r,i),e.safeEncode=(r,i)=>Xu(e,r,i),e.safeDecode=(r,i)=>Yu(e,r,i),e.safeEncodeAsync=async(r,i)=>Qu(e,r,i),e.safeDecodeAsync=async(r,i)=>el(e,r,i),jn(e,"ZodType",{check(...r){let i=this.def;return this.clone(I.mergeDefs(i,{checks:[...i.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,i){return Q(this,r,i)},brand(){return this},register(r,i){return r.add(this,i),this},refine(r,i){return this.check(Gl(r,i))},superRefine(r,i){return this.check(Hl(r,i))},overwrite(r){return this.check($e(r))},optional(){return An(this)},exactOptional(){return Il(this)},nullable(){return Cn(this)},nullish(){return An(Cn(this))},nonoptional(r){return Pl(this,r)},array(){return Rn(this)},or(r){return Zi([this,r])},and(r){return gl(this,r)},transform(r){return xi(this,Vi(r))},default(r){return El(this,r)},prefault(r){return Tl(this,r)},catch(r){return jl(this,r)},pipe(r){return xi(this,r)},readonly(){return Ll(this)},describe(r){let i=this.clone();return K.add(i,{description:r}),i},meta(...r){if(r.length===0)return K.get(this);let i=this.clone();return K.add(i,r[0]),i},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return K.get(e)?.description},configurable:!0}),e)),bi=v("_ZodString",(e,t)=>{it.init(e,t),C.init(e,t),e._zod.processJSONSchema=(i,n,o)=>nu(e,i,n,o);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,jn(e,"_ZodString",{regex(...i){return this.check(wt(...i))},includes(...i){return this.check(zt(...i))},startsWith(...i){return this.check(Et(...i))},endsWith(...i){return this.check(Dt(...i))},min(...i){return this.check(Ce(...i))},max(...i){return this.check(at(...i))},length(...i){return this.check(st(...i))},nonempty(...i){return this.check(Ce(1,...i))},lowercase(i){return this.check(It(i))},uppercase(i){return this.check(Ot(i))},trim(){return this.check(At())},normalize(...i){return this.check(Pt(...i))},toLowerCase(){return this.check(Ct())},toUpperCase(){return this.check(jt())},slugify(){return this.check(Nt())}})}),Mt=v("ZodString",(e,t)=>{it.init(e,t),bi.init(e,t),e.email=r=>e.check(Lr(Si,r)),e.url=r=>e.check(En(Nn,r)),e.jwt=r=>e.check(ii(Ri,r)),e.emoji=r=>e.check(Br(ki,r)),e.guid=r=>e.check(zn(Pn,r)),e.uuid=r=>e.check(Fr(Oe,r)),e.uuidv4=r=>e.check(Zr(Oe,r)),e.uuidv6=r=>e.check(Mr(Oe,r)),e.uuidv7=r=>e.check(Vr(Oe,r)),e.nanoid=r=>e.check(Gr(wi,r)),e.guid=r=>e.check(zn(Pn,r)),e.cuid=r=>e.check(Hr(Ii,r)),e.cuid2=r=>e.check(Jr(Oi,r)),e.ulid=r=>e.check(Wr(zi,r)),e.base64=r=>e.check(ti(ji,r)),e.base64url=r=>e.check(ni(Ni,r)),e.xid=r=>e.check(qr(Ei,r)),e.ksuid=r=>e.check(Kr(Di,r)),e.ipv4=r=>e.check(Xr(Ti,r)),e.ipv6=r=>e.check(Yr(Pi,r)),e.cidrv4=r=>e.check(Qr(Ai,r)),e.cidrv6=r=>e.check(ei(Ci,r)),e.e164=r=>e.check(ri(Ui,r)),e.datetime=r=>e.check(Lu(r)),e.date=r=>e.check(Fu(r)),e.time=r=>e.check(Zu(r)),e.duration=r=>e.check(Mu(r))});function Tn(e){return gc(Mt,e)}var L=v("ZodStringFormat",(e,t)=>{R.init(e,t),bi.init(e,t)}),Si=v("ZodEmail",(e,t)=>{ss.init(e,t),L.init(e,t)});function ef(e){return Lr(Si,e)}var Pn=v("ZodGUID",(e,t)=>{os.init(e,t),L.init(e,t)});function tf(e){return zn(Pn,e)}var Oe=v("ZodUUID",(e,t)=>{as.init(e,t),L.init(e,t)});function nf(e){return Fr(Oe,e)}function rf(e){return Zr(Oe,e)}function of(e){return Mr(Oe,e)}function af(e){return Vr(Oe,e)}var Nn=v("ZodURL",(e,t)=>{cs.init(e,t),L.init(e,t)});function sf(e){return En(Nn,e)}function cf(e){return En(Nn,{protocol:ue.httpProtocol,hostname:ue.domain,...I.normalizeParams(e)})}var ki=v("ZodEmoji",(e,t)=>{us.init(e,t),L.init(e,t)});function uf(e){return Br(ki,e)}var wi=v("ZodNanoID",(e,t)=>{ls.init(e,t),L.init(e,t)});function lf(e){return Gr(wi,e)}var Ii=v("ZodCUID",(e,t)=>{ds.init(e,t),L.init(e,t)});function df(e){return Hr(Ii,e)}var Oi=v("ZodCUID2",(e,t)=>{ps.init(e,t),L.init(e,t)});function pf(e){return Jr(Oi,e)}var zi=v("ZodULID",(e,t)=>{ms.init(e,t),L.init(e,t)});function mf(e){return Wr(zi,e)}var Ei=v("ZodXID",(e,t)=>{fs.init(e,t),L.init(e,t)});function ff(e){return qr(Ei,e)}var Di=v("ZodKSUID",(e,t)=>{hs.init(e,t),L.init(e,t)});function hf(e){return Kr(Di,e)}var Ti=v("ZodIPv4",(e,t)=>{$s.init(e,t),L.init(e,t)});function gf(e){return Xr(Ti,e)}var tl=v("ZodMAC",(e,t)=>{bs.init(e,t),L.init(e,t)});function vf(e){return _c(tl,e)}var Pi=v("ZodIPv6",(e,t)=>{xs.init(e,t),L.init(e,t)});function _f(e){return Yr(Pi,e)}var Ai=v("ZodCIDRv4",(e,t)=>{Ss.init(e,t),L.init(e,t)});function yf(e){return Qr(Ai,e)}var Ci=v("ZodCIDRv6",(e,t)=>{ks.init(e,t),L.init(e,t)});function $f(e){return ei(Ci,e)}var ji=v("ZodBase64",(e,t)=>{Is.init(e,t),L.init(e,t)});function xf(e){return ti(ji,e)}var Ni=v("ZodBase64URL",(e,t)=>{Os.init(e,t),L.init(e,t)});function bf(e){return ni(Ni,e)}var Ui=v("ZodE164",(e,t)=>{zs.init(e,t),L.init(e,t)});function Sf(e){return ri(Ui,e)}var Ri=v("ZodJWT",(e,t)=>{Es.init(e,t),L.init(e,t)});function kf(e){return ii(Ri,e)}var Vt=v("ZodCustomStringFormat",(e,t)=>{Ds.init(e,t),L.init(e,t)});function wf(e,t,r={}){return Ut(Vt,e,t,r)}function If(e){return Ut(Vt,"hostname",ue.hostname,e)}function Of(e){return Ut(Vt,"hex",ue.hex,e)}function zf(e,t){let r=t?.enc??"hex",i=`${e}_${r}`,n=ue[i];if(!n)throw new Error(`Unrecognized hash format: ${i}`);return Ut(Vt,i,n,t)}var Bt=v("ZodNumber",(e,t)=>{Er.init(e,t),C.init(e,t),e._zod.processJSONSchema=(i,n,o)=>ru(e,i,n,o),jn(e,"ZodNumber",{gt(i,n){return this.check(we(i,n))},gte(i,n){return this.check(te(i,n))},min(i,n){return this.check(te(i,n))},lt(i,n){return this.check(ke(i,n))},lte(i,n){return this.check(le(i,n))},max(i,n){return this.check(le(i,n))},int(i){return this.check($i(i))},safe(i){return this.check($i(i))},positive(i){return this.check(we(0,i))},nonnegative(i){return this.check(te(0,i))},negative(i){return this.check(ke(0,i))},nonpositive(i){return this.check(le(0,i))},multipleOf(i,n){return this.check(Je(i,n))},step(i,n){return this.check(Je(i,n))},finite(){return this}});let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function nl(e){return kc(Bt,e)}var ut=v("ZodNumberFormat",(e,t)=>{Ts.init(e,t),Bt.init(e,t)});function $i(e){return Ic(ut,e)}function Ef(e){return Oc(ut,e)}function Df(e){return zc(ut,e)}function Tf(e){return Ec(ut,e)}function Pf(e){return Dc(ut,e)}var Gt=v("ZodBoolean",(e,t)=>{Sn.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>iu(e,r,i,n)});function rl(e){return Tc(Gt,e)}var Ht=v("ZodBigInt",(e,t)=>{Dr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(i,n,o)=>ou(e,i,n,o),e.gte=(i,n)=>e.check(te(i,n)),e.min=(i,n)=>e.check(te(i,n)),e.gt=(i,n)=>e.check(we(i,n)),e.gte=(i,n)=>e.check(te(i,n)),e.min=(i,n)=>e.check(te(i,n)),e.lt=(i,n)=>e.check(ke(i,n)),e.lte=(i,n)=>e.check(le(i,n)),e.max=(i,n)=>e.check(le(i,n)),e.positive=i=>e.check(we(BigInt(0),i)),e.negative=i=>e.check(ke(BigInt(0),i)),e.nonpositive=i=>e.check(le(BigInt(0),i)),e.nonnegative=i=>e.check(te(BigInt(0),i)),e.multipleOf=(i,n)=>e.check(Je(i,n));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});function Af(e){return Ac(Ht,e)}var Li=v("ZodBigIntFormat",(e,t)=>{Ps.init(e,t),Ht.init(e,t)});function Cf(e){return jc(Li,e)}function jf(e){return Nc(Li,e)}var il=v("ZodSymbol",(e,t)=>{As.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>au(e,r,i,n)});function Nf(e){return Uc(il,e)}var ol=v("ZodUndefined",(e,t)=>{Cs.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>cu(e,r,i,n)});function Uf(e){return Rc(ol,e)}var al=v("ZodNull",(e,t)=>{js.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>su(e,r,i,n)});function sl(e){return Lc(al,e)}var cl=v("ZodAny",(e,t)=>{Ns.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>du(e,r,i,n)});function Rf(){return Fc(cl)}var ul=v("ZodUnknown",(e,t)=>{Us.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>pu(e,r,i,n)});function ct(){return Zc(ul)}var ll=v("ZodNever",(e,t)=>{Rs.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>lu(e,r,i,n)});function Fi(e){return Mc(ll,e)}var dl=v("ZodVoid",(e,t)=>{Ls.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>uu(e,r,i,n)});function Lf(e){return Vc(dl,e)}var Un=v("ZodDate",(e,t)=>{Fs.init(e,t),C.init(e,t),e._zod.processJSONSchema=(i,n,o)=>mu(e,i,n,o),e.min=(i,n)=>e.check(te(i,n)),e.max=(i,n)=>e.check(le(i,n));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});function Ff(e){return Bc(Un,e)}var pl=v("ZodArray",(e,t)=>{Zs.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>wu(e,r,i,n),e.element=t.element,jn(e,"ZodArray",{min(r,i){return this.check(Ce(r,i))},nonempty(r){return this.check(Ce(1,r))},max(r,i){return this.check(at(r,i))},length(r,i){return this.check(st(r,i))},unwrap(){return this.element}})});function Rn(e,t){return Jc(pl,e,t)}function Zf(e){let t=e._zod.def.shape;return Mi(Object.keys(t))}var Ln=v("ZodObject",(e,t)=>{Ms.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Iu(e,r,i,n),I.defineLazy(e,"shape",()=>t.shape),jn(e,"ZodObject",{keyof(){return Mi(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:ct()})},loose(){return this.clone({...this._zod.def,catchall:ct()})},strict(){return this.clone({...this._zod.def,catchall:Fi()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return I.extend(this,r)},safeExtend(r){return I.safeExtend(this,r)},merge(r){return I.merge(this,r)},pick(r){return I.pick(this,r)},omit(r){return I.omit(this,r)},partial(...r){return I.partial(Bi,this,r[0])},required(...r){return I.required(Gi,this,r[0])}})});function Mf(e,t){let r={type:"object",shape:e??{},...I.normalizeParams(t)};return new Ln(r)}function Vf(e,t){return new Ln({type:"object",shape:e,catchall:Fi(),...I.normalizeParams(t)})}function Bf(e,t){return new Ln({type:"object",shape:e,catchall:ct(),...I.normalizeParams(t)})}var Fn=v("ZodUnion",(e,t)=>{kn.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>di(e,r,i,n),e.options=t.options});function Zi(e,t){return new Fn({type:"union",options:e,...I.normalizeParams(t)})}var ml=v("ZodXor",(e,t)=>{Fn.init(e,t),Vs.init(e,t),e._zod.processJSONSchema=(r,i,n)=>di(e,r,i,n),e.options=t.options});function Gf(e,t){return new ml({type:"union",options:e,inclusive:!1,...I.normalizeParams(t)})}var fl=v("ZodDiscriminatedUnion",(e,t)=>{Fn.init(e,t),Bs.init(e,t)});function Hf(e,t,r){return new fl({type:"union",options:t,discriminator:e,...I.normalizeParams(r)})}var hl=v("ZodIntersection",(e,t)=>{Gs.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Ou(e,r,i,n)});function gl(e,t){return new hl({type:"intersection",left:e,right:t})}var vl=v("ZodTuple",(e,t)=>{Tr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>zu(e,r,i,n),e.rest=r=>e.clone({...e._zod.def,rest:r})});function _l(e,t,r){let i=t instanceof A,n=i?r:t,o=i?t:null;return new vl({type:"tuple",items:e,rest:o,...I.normalizeParams(n)})}var Ft=v("ZodRecord",(e,t)=>{Hs.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Eu(e,r,i,n),e.keyType=t.keyType,e.valueType=t.valueType});function yl(e,t,r){return!t||!t._zod?new Ft({type:"record",keyType:Tn(),valueType:e,...I.normalizeParams(t)}):new Ft({type:"record",keyType:e,valueType:t,...I.normalizeParams(r)})}function Jf(e,t,r){let i=Q(e);return i._zod.values=void 0,new Ft({type:"record",keyType:i,valueType:t,...I.normalizeParams(r)})}function Wf(e,t,r){return new Ft({type:"record",keyType:e,valueType:t,mode:"loose",...I.normalizeParams(r)})}var $l=v("ZodMap",(e,t)=>{Js.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Su(e,r,i,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Ie(...r)),e.nonempty=r=>e.check(Ie(1,r)),e.max=(...r)=>e.check(We(...r)),e.size=(...r)=>e.check(ot(...r))});function qf(e,t,r){return new $l({type:"map",keyType:e,valueType:t,...I.normalizeParams(r)})}var xl=v("ZodSet",(e,t)=>{Ws.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>ku(e,r,i,n),e.min=(...r)=>e.check(Ie(...r)),e.nonempty=r=>e.check(Ie(1,r)),e.max=(...r)=>e.check(We(...r)),e.size=(...r)=>e.check(ot(...r))});function Kf(e,t){return new xl({type:"set",valueType:e,...I.normalizeParams(t)})}var Zt=v("ZodEnum",(e,t)=>{qs.init(e,t),C.init(e,t),e._zod.processJSONSchema=(i,n,o)=>fu(e,i,n,o),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(i,n)=>{let o={};for(let a of i)if(r.has(a))o[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Zt({...t,checks:[],...I.normalizeParams(n),entries:o})},e.exclude=(i,n)=>{let o={...t.entries};for(let a of i)if(r.has(a))delete o[a];else throw new Error(`Key ${a} not found in enum`);return new Zt({...t,checks:[],...I.normalizeParams(n),entries:o})}});function Mi(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new Zt({type:"enum",entries:r,...I.normalizeParams(t)})}function Xf(e,t){return new Zt({type:"enum",entries:e,...I.normalizeParams(t)})}var bl=v("ZodLiteral",(e,t)=>{Ks.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>hu(e,r,i,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Yf(e,t){return new bl({type:"literal",values:Array.isArray(e)?e:[e],...I.normalizeParams(t)})}var Sl=v("ZodFile",(e,t)=>{Xs.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>_u(e,r,i,n),e.min=(r,i)=>e.check(Ie(r,i)),e.max=(r,i)=>e.check(We(r,i)),e.mime=(r,i)=>e.check(Tt(Array.isArray(r)?r:[r],i))});function Qf(e){return Wc(Sl,e)}var kl=v("ZodTransform",(e,t)=>{Ys.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>bu(e,r,i,n),e._zod.parse=(r,i)=>{if(i.direction==="backward")throw new Me(e.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(I.issue(o,r.value,t));else{let a=o;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=r.value),a.inst??(a.inst=e),r.issues.push(I.issue(a))}};let n=t.transform(r.value,r);return n instanceof Promise?n.then(o=>(r.value=o,r.fallback=!0,r)):(r.value=n,r.fallback=!0,r)}});function Vi(e){return new kl({type:"transform",transform:e})}var Bi=v("ZodOptional",(e,t)=>{Pr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>pi(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function An(e){return new Bi({type:"optional",innerType:e})}var wl=v("ZodExactOptional",(e,t)=>{Qs.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>pi(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function Il(e){return new wl({type:"optional",innerType:e})}var Ol=v("ZodNullable",(e,t)=>{ec.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Du(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function Cn(e){return new Ol({type:"nullable",innerType:e})}function eh(e){return An(Cn(e))}var zl=v("ZodDefault",(e,t)=>{tc.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Pu(e,r,i,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function El(e,t){return new zl({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():I.shallowClone(t)}})}var Dl=v("ZodPrefault",(e,t)=>{nc.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Au(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function Tl(e,t){return new Dl({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():I.shallowClone(t)}})}var Gi=v("ZodNonOptional",(e,t)=>{rc.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Tu(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function Pl(e,t){return new Gi({type:"nonoptional",innerType:e,...I.normalizeParams(t)})}var Al=v("ZodSuccess",(e,t)=>{ic.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>yu(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function th(e){return new Al({type:"success",innerType:e})}var Cl=v("ZodCatch",(e,t)=>{oc.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Cu(e,r,i,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function jl(e,t){return new Cl({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var Nl=v("ZodNaN",(e,t)=>{ac.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>gu(e,r,i,n)});function nh(e){return Hc(Nl,e)}var Zn=v("ZodPipe",(e,t)=>{Ar.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>ju(e,r,i,n),e.in=t.in,e.out=t.out});function xi(e,t){return new Zn({type:"pipe",in:e,out:t})}var Mn=v("ZodCodec",(e,t)=>{Zn.init(e,t),wn.init(e,t)});function rh(e,t,r){return new Mn({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function ih(e){let t=e._zod.def;return new Mn({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var Ul=v("ZodPreprocess",(e,t)=>{Zn.init(e,t),sc.init(e,t)}),Rl=v("ZodReadonly",(e,t)=>{cc.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Nu(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function Ll(e){return new Rl({type:"readonly",innerType:e})}var Fl=v("ZodTemplateLiteral",(e,t)=>{uc.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>vu(e,r,i,n)});function oh(e,t){return new Fl({type:"template_literal",parts:e,...I.normalizeParams(t)})}var Zl=v("ZodLazy",(e,t)=>{pc.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Ru(e,r,i,n),e.unwrap=()=>e._zod.def.getter()});function Ml(e){return new Zl({type:"lazy",getter:e})}var Vl=v("ZodPromise",(e,t)=>{dc.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Uu(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function ah(e){return new Vl({type:"promise",innerType:e})}var Bl=v("ZodFunction",(e,t)=>{lc.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>xu(e,r,i,n)});function sh(e){return new Bl({type:"function",input:Array.isArray(e?.input)?_l(e?.input):e?.input??Rn(ct()),output:e?.output??ct()})}var Vn=v("ZodCustom",(e,t)=>{mc.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>$u(e,r,i,n)});function ch(e){let t=new F({check:"custom"});return t._zod.check=e,t}function uh(e,t){return qc(Vn,e??(()=>!0),t)}function Gl(e,t={}){return Kc(Vn,e,t)}function Hl(e,t){return Xc(e,t)}var lh=Yc,dh=Qc;function ph(e,t={}){let r=new Vn({type:"custom",check:"custom",fn:i=>i instanceof e,abort:!0,...I.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=i=>{i.value instanceof e||i.issues.push({code:"invalid_type",expected:e.name,input:i.value,inst:r,path:[...r._zod.def.path??[]]})},r}var mh=(...e)=>eu({Codec:Mn,Boolean:Gt,String:Mt},...e);function fh(e){let t=Ml(()=>Zi([Tn(e),nl(),rl(),sl(),Rn(t),yl(Tn(),t)]));return t}function hh(e,t){return new Ul({type:"pipe",in:Vi(e),out:t})}var fx={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function hx(e){V({customError:e})}function gx(){return V().customError}var Jl;Jl||(Jl={});var z={...Dn,...hi,iso:Lt},vx=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function _x(e,t){let r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function yx(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let i=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===i){let n=r[1];if(!n||!t.defs[n])throw new Error(`Reference not found: ${e}`);return t.defs[n]}throw new Error(`Reference not found: ${e}`)}function gh(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return z.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return z.lazy(()=>{if(!t.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let o=yx(n,t),a=X(o,t);return t.refs.set(n,a),t.processing.delete(n),a}if(e.enum!==void 0){let n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return z.null();if(n.length===0)return z.never();if(n.length===1)return z.literal(n[0]);if(n.every(a=>typeof a=="string"))return z.enum(n);let o=n.map(a=>z.literal(a));return o.length<2?o[0]:z.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return z.literal(e.const);let r=e.type;if(Array.isArray(r)){let n=r.map(o=>{let a={...e,type:o};return gh(a,t)});return n.length===0?z.never():n.length===1?n[0]:z.union(n)}if(!r)return z.any();let i;switch(r){case"string":{let n=z.string();if(e.format){let o=e.format;o==="email"?n=n.check(z.email()):o==="uri"||o==="uri-reference"?n=n.check(z.url()):o==="uuid"||o==="guid"?n=n.check(z.uuid()):o==="date-time"?n=n.check(z.iso.datetime()):o==="date"?n=n.check(z.iso.date()):o==="time"?n=n.check(z.iso.time()):o==="duration"?n=n.check(z.iso.duration()):o==="ipv4"?n=n.check(z.ipv4()):o==="ipv6"?n=n.check(z.ipv6()):o==="mac"?n=n.check(z.mac()):o==="cidr"?n=n.check(z.cidrv4()):o==="cidr-v6"?n=n.check(z.cidrv6()):o==="base64"?n=n.check(z.base64()):o==="base64url"?n=n.check(z.base64url()):o==="e164"?n=n.check(z.e164()):o==="jwt"?n=n.check(z.jwt()):o==="emoji"?n=n.check(z.emoji()):o==="nanoid"?n=n.check(z.nanoid()):o==="cuid"?n=n.check(z.cuid()):o==="cuid2"?n=n.check(z.cuid2()):o==="ulid"?n=n.check(z.ulid()):o==="xid"?n=n.check(z.xid()):o==="ksuid"&&(n=n.check(z.ksuid()))}typeof e.minLength=="number"&&(n=n.min(e.minLength)),typeof e.maxLength=="number"&&(n=n.max(e.maxLength)),e.pattern&&(n=n.regex(new RegExp(e.pattern))),i=n;break}case"number":case"integer":{let n=r==="integer"?z.number().int():z.number();typeof e.minimum=="number"&&(n=n.min(e.minimum)),typeof e.maximum=="number"&&(n=n.max(e.maximum)),typeof e.exclusiveMinimum=="number"?n=n.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(n=n.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?n=n.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(n=n.lt(e.maximum)),typeof e.multipleOf=="number"&&(n=n.multipleOf(e.multipleOf)),i=n;break}case"boolean":{i=z.boolean();break}case"null":{i=z.null();break}case"object":{let n={},o=e.properties||{},a=new Set(e.required||[]);for(let[c,u]of Object.entries(o)){let l=X(u,t);n[c]=a.has(c)?l:l.optional()}if(e.propertyNames){let c=X(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties=="object"?X(e.additionalProperties,t):z.any();if(Object.keys(n).length===0){i=z.record(c,u);break}let l=z.object(n).passthrough(),f=z.looseRecord(c,u);i=z.intersection(l,f);break}if(e.patternProperties){let c=e.patternProperties,u=Object.keys(c),l=[];for(let p of u){let _=X(c[p],t),b=z.string().regex(new RegExp(p));l.push(z.looseRecord(b,_))}let f=[];if(Object.keys(n).length>0&&f.push(z.object(n).passthrough()),f.push(...l),f.length===0)i=z.object({}).passthrough();else if(f.length===1)i=f[0];else{let p=z.intersection(f[0],f[1]);for(let _=2;_<f.length;_++)p=z.intersection(p,f[_]);i=p}break}let s=z.object(n);e.additionalProperties===!1?i=s.strict():typeof e.additionalProperties=="object"?i=s.catchall(X(e.additionalProperties,t)):i=s.passthrough();break}case"array":{let n=e.prefixItems,o=e.items;if(n&&Array.isArray(n)){let a=n.map(c=>X(c,t)),s=o&&typeof o=="object"&&!Array.isArray(o)?X(o,t):void 0;s?i=z.tuple(a).rest(s):i=z.tuple(a),typeof e.minItems=="number"&&(i=i.check(z.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(z.maxLength(e.maxItems)))}else if(Array.isArray(o)){let a=o.map(c=>X(c,t)),s=e.additionalItems&&typeof e.additionalItems=="object"?X(e.additionalItems,t):void 0;s?i=z.tuple(a).rest(s):i=z.tuple(a),typeof e.minItems=="number"&&(i=i.check(z.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(z.maxLength(e.maxItems)))}else if(o!==void 0){let a=X(o,t),s=z.array(a);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),i=s}else i=z.array(z.any());break}default:throw new Error(`Unsupported type: ${r}`)}return i}function X(e,t){if(typeof e=="boolean")return e?z.any():z.never();let r=gh(e,t),i=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(u=>X(u,t)),c=z.union(s);r=i?z.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(u=>X(u,t)),c=z.xor(s);r=i?z.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=i?r:z.any();else{let s=i?r:X(e.allOf[0],t),c=i?0:1;for(let u=c;u<e.allOf.length;u++)s=z.intersection(s,X(e.allOf[u],t));r=s}e.nullable===!0&&t.version==="openapi-3.0"&&(r=z.nullable(r)),e.readOnly===!0&&(r=z.readonly(r)),e.default!==void 0&&(r=r.default(e.default));let n={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of o)s in e&&(n[s]=e[s]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let s of a)s in e&&(n[s]=e[s]);for(let s of Object.keys(e))vx.has(s)||(n[s]=e[s]);return Object.keys(n).length>0&&t.registry.add(r,n),e.description&&(r=r.describe(e.description)),r}function vh(e,t){if(typeof e=="boolean")return e?z.any():z.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let i=_x(r,t?.defaultTarget),n=r.$defs||r.definitions||{},o={version:i,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??K};return X(r,o)}var Wl={};pe(Wl,{bigint:()=>Sx,boolean:()=>bx,date:()=>kx,number:()=>xx,string:()=>$x});function $x(e){return vc(Mt,e)}function xx(e){return wc(Bt,e)}function bx(e){return Pc(Gt,e)}function Sx(e){return Cc(Ht,e)}function kx(e){return Gc(Un,e)}V(Cr());var Jt={apiUrl:xe.string().url().optional(),token:xe.string().min(1).optional()};var Ji=require("fs"),$h=require("os"),xh=require("path");M();var wx=xe.object(Jt).strict(),Ix=()=>(0,xh.join)((0,$h.homedir)(),".shiprc"),_h=e=>e instanceof Error?e.message:String(e);function Hi(e){let t;try{t=(0,Ji.readFileSync)(e,"utf-8")}catch(i){throw k.config(`Failed to read ship config (${e}): ${_h(i)}`)}if(!t.trim())return{};let r;try{r=JSON.parse(t)}catch(i){throw k.config(`Invalid config in ${e}: ${_h(i)}`)}if(r===null||typeof r!="object"||Array.isArray(r))throw k.config(`Invalid config in ${e}: expected a JSON object`);return r}function yh(e,t){try{return wx.parse(e)}catch(r){if(r instanceof xe.ZodError){let i=r.issues[0];if(i.code==="unrecognized_keys"){let o=i.keys.filter(a=>a==="apiKey"||a==="deployToken");if(o.length>0){let a=o.map(s=>`"${s}"`).join(" and ");throw k.config(`Invalid config in ${t}: ${a} ${o.length>1?"are":"is"} no longer supported \u2014 the key is now "token". Run \`ship config\` to rewrite it.`)}}let n=i.path.length>0?` at ${i.path.join(".")}`:"";throw k.config(`Invalid config in ${t}${n}: ${i.message}`)}throw k.config(`Invalid config in ${t}`)}}function ql(e){let t=e||void 0;if(t)return yh(Hi(t),t);let r=Ix();return(0,Ji.existsSync)(r)?yh(Hi(r),r):{}}var Kl=Object.keys(Jt),Ox=()=>(0,Sh.join)((0,bh.homedir)(),".shiprc"),Xl=tn.HINT_LENGTH;function zx(e){let r=(e.startsWith(nn.PREFIX)?nn.PREFIX:tn.PREFIX).length+Xl;return e.length<r+Xl+1?"...":`${e.slice(0,r)}...${e.slice(-Xl)}`}function Ex(e){if(!(0,Wt.existsSync)(e))return{};try{return Hi(e)}catch(t){throw ce(t)?k.config(`${t.message} \u2014 the file was left unchanged`):t}}async function wh(e={}){let{noColor:t}=e,r=e.configFile||Ox(),i=p=>t?p:Le(p),n=p=>t?p:an(p),o=Ex(r),a=typeof o.token=="string"?o.token:void 0,s=Object.keys(o).filter(p=>!Kl.includes(p)),c=(0,kh.createInterface)({input:process.stdin,output:process.stdout});console.log(""),console.log(` ${i("Create a free API key at")} ${Ld}`),console.log("");let u=a?` Token (${i(zx(a))}): `:" Token: ",l;try{l=(await c.question(u)).trim()}finally{c.close()}l&&Ye(l);let f={};for(let p of Kl)o[p]!==void 0&&(f[p]=o[p]);l&&(f.token=l),s.length>0&&ft(`dropped ${s.map(p=>`"${p}"`).join(", ")} \u2014 a ship config holds only ${Kl.join(" and ")}`,!1,t),(0,Wt.writeFileSync)(r,`${JSON.stringify(f,null,2)}
|
|
229
229
|
`,{mode:384}),(0,Wt.chmodSync)(r,384),console.log(`
|
|
230
230
|
${n("saved to")} ${i(r)}
|
|
231
|
-
`)}M();M();Wi();var Tx=xe.object(Jt).strict(),Px={apiUrl:rn.API_URL,token:rn.TOKEN};function Bn(){if(qt()!=="node")return{};let e={apiUrl:process.env[rn.API_URL]||void 0,token:process.env[rn.TOKEN]||void 0};try{return Tx.parse(e)}catch(t){if(t instanceof xe.ZodError){let r=t.issues[0],i=r.path[0],n=(i&&Px[i])??"SHIP environment configuration";throw k.config(`Invalid ${n}: ${r.message}`)}throw k.config("Invalid environment configuration")}}M();M();M();var qi=class{constructor(){this.handlers=new Map}on(t,r){this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t)?.add(r)}off(t,r){let i=this.handlers.get(t);i&&(i.delete(r),i.size===0&&this.handlers.delete(t))}emit(t,...r){let i=this.handlers.get(t);if(!i)return;let n=Array.from(i);for(let o of n)try{o(...r)}catch(a){i.delete(o),t!=="error"&&setTimeout(()=>{let s=a instanceof Error?a:new Error(String(a));this.emit("error",s,String(t))},0)}}};var Ax=3e4,Cx=2,jx=300,Nx=2e3,Ux=new Set([500,502,503,504]);function Rx(e,t){return new Promise((r,i)=>{if(t?.aborted){i(t.reason);return}let n=()=>{clearTimeout(a),t?.removeEventListener("abort",o)},o=()=>{n(),i(t?.reason)},a=setTimeout(()=>{n(),r()},e);t?.addEventListener("abort",o)})}var Oh=3e5,Lx=3e5,Fx=Oh+Lx,Ki=class extends qi{constructor(r){super();this.globalHeaders={};this.apiUrl=r.apiUrl||Ud,this.getAuthHeadersCallback=r.getAuthHeaders,this.session=r.session??!1,this.caller=r.caller,this.timeout=r.timeout??Ax,this.maxRetries=Math.max(0,r.maxRetries??Cx),this.fetch=r.fetch??globalThis.fetch.bind(globalThis),this.deploy={endpoint:r.deployEndpoint||Z.DEPLOYMENTS,timeout:r.timeout??Oh,buildTimeout:r.timeout??Fx}}setGlobalHeaders(r){this.globalHeaders=r}async executeRequest(r,i,n,o=this.timeout){for(let a=0;;a++)try{return await this.attemptOnce(r,i,n,o)}catch(s){let c=k.fromFetchError(s,n);if(a>=this.maxRetries||!this.isRetryable(c,i))throw this.emit("error",c,r),c;this.emit("retry",c,r,a+1);let u=Math.min(Nx,jx*2**a);try{await Rx(Math.random()*u,i.signal)}catch(l){let f=k.fromFetchError(l,n);throw this.emit("error",f,r),f}}}isRetryable(r,i){if(i.signal?.aborted||r.isType(P.Maintenance)||r.isType(P.Cancelled)||!(r.isNetworkError()||r.status!==void 0&&Ux.has(r.status)))return!1;let o=(i.method??"GET").toUpperCase();return o==="GET"||o==="HEAD"?!0:o==="PUT"||o==="DELETE"?!1:this.hasIdempotencyKey(i.headers)}hasIdempotencyKey(r){if(!r)return!1;let i=dt.HEADER.toLowerCase();return Object.keys(r).some(n=>n.toLowerCase()===i)}async attemptOnce(r,i,n,o=this.timeout){let a=()=>{};try{let s=await this.mergeHeaders(i.headers),c=this.createTimeoutSignal(i.signal,o);a=c.cleanup;let u={...i,headers:s,credentials:this.session&&!s.Authorization?"include":void 0,signal:c.signal};this.emit("request",r,u);let l=await this.fetch(r,u);if(a(),!l.ok)throw await k.fromHttpResponse(l,n);return this.emit("response",this.safeClone(l),r),{data:await this.parseResponse(this.safeClone(l)),status:l.status}}catch(s){throw a(),k.fromFetchError(s,n)}}async request(r,i,n,o){let{data:a}=await this.executeRequest(`${this.apiUrl}${r}`,i,n,o);return a}async requestWithStatus(r,i,n){return this.executeRequest(`${this.apiUrl}${r}`,i,n)}async mergeHeaders(r={}){return{...this.globalHeaders,...this.caller?{[Yt.HEADER]:this.caller}:{},...await this.getAuthHeadersCallback(),...r}}createTimeoutSignal(r,i=this.timeout){let n=new AbortController,o=setTimeout(()=>n.abort(new DOMException(`Timed out after ${i}ms`,"TimeoutError")),i),a=r?()=>n.abort(r.reason):void 0;return r&&a&&(r.addEventListener("abort",a),r.aborted&&n.abort(r.reason)),{signal:n.signal,cleanup:()=>{clearTimeout(o),r&&a&&r.removeEventListener("abort",a)}}}safeClone(r){try{return r.clone()}catch{return r}}async parseResponse(r){if(!(r.headers.get("Content-Length")==="0"||r.status===204))return r.json()}};M();M();async function zh(e,t={}){let{labels:r,via:i,password:n,ttl:o,flags:a,captcha:s}=t,c=new FormData,u=[];for(let l of e){if(typeof l.content=="string"||l.content===null||l.content===void 0)throw k.file(`Unsupported file.content type: ${l.path}`,{filePath:l.path});if(!l.md5)throw k.file(`File missing md5 checksum: ${l.path}`,{filePath:l.path});c.append(se.FILES,new File([l.content],l.path,{type:"application/octet-stream"})),u.push(l.md5)}return c.append(se.CHECKSUMS,JSON.stringify(u)),r&&r.length>0&&c.append(se.LABELS,JSON.stringify(r)),i&&c.append(se.VIA,i),n&&c.append(se.PASSWORD,n),o!==void 0&&c.append(se.TTL,String(o)),a?.build&&c.append(se.BUILD,"true"),a?.prerender&&c.append(se.PRERENDER,"true"),a?.spa&&c.append(se.SPA,"true"),a?.buildCommand&&c.append(se.BUILD_COMMAND,a.buildCommand),a?.outputDir&&c.append(se.OUTPUT_DIR,a.outputDir),s&&c.append(se.CAPTCHA,s),c}M();Yl();async function Bx(){let e=JSON.stringify(Cd,null,2),t;typeof Buffer<"u"?t=Buffer.from(e,"utf-8"):t=new Blob([e],{type:"application/json"});let{md5:r}=await Xi(t);return{path:De,content:t,size:e.length,md5:r}}async function Gx(e,t){let r=e.find(a=>a.path===er.INDEX_FILE||a.path===`/${er.INDEX_FILE}`);if(!r||r.size>er.MAX_INDEX_BYTES)return!1;let i;if(typeof Buffer<"u"&&Buffer.isBuffer(r.content))i=r.content.toString("utf-8");else if(typeof Blob<"u"&&r.content instanceof Blob)i=await r.content.text();else if(typeof File<"u"&&r.content instanceof File)i=await r.content.text();else return!1;let n={files:e.map(a=>a.path),index:i};return(await t.request(Z.SPA_CHECK,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)},"SPA check")).isSPA}async function Ph(e,t,r){if(r.spaDetect===!1||r.spa||r.build||r.prerender||e.some(i=>i.path===De))return e;try{if(await Gx(e,t)){let n=await Bx();return[...e,n]}}catch{}return e}M();M();function Gn(e){if(e==null)return;if(e.length===0)return e;if(e.length>Re.MAX_COUNT)throw k.validation(`Maximum ${Re.MAX_COUNT} labels allowed`);let t=e.map((i,n)=>{if(typeof i!="string")throw k.validation(`Label at index ${n} must be a string`);let o=i.trim().toLowerCase();if(o.length<Re.MIN_LENGTH)throw k.validation(`Labels must be at least ${Re.MIN_LENGTH} characters long`);if(o.length>Re.MAX_LENGTH)throw k.validation(`Labels must be no more than ${Re.MAX_LENGTH} characters long`);if(!Zd.test(o))throw k.validation(`Labels must start and end with alphanumeric characters, with optional separators (${Re.SEPARATORS}) between segments`);return o}),r=[...new Set(t)];if(r.length!==t.length)throw k.validation("Duplicate labels are not allowed");return r}async function Ah(e){let t=e.find(n=>n.path===De||n.path===`/${De}`);if(!t)return;let r=t.content,i=typeof r.text=="function"?await r.text():t.content.toString("utf8");jd(i)}var Yi={"Content-Type":"application/json"},Hx="sdk";function Ql(e){let t=new URLSearchParams;e?.limit!==void 0&&t.set("limit",String(e.limit)),e?.cursor!==void 0&&t.set("cursor",e.cursor);let r=t.toString();return r?`?${r}`:""}function Ch(e){let{getApi:t,processInput:r}=e;return{upload:async(i,n={})=>{if(!r)throw k.config("processInput function is not provided.");let o=t(),a=await r(i,n),s=await Ph(a,o,n);if(!s.length)throw k.business("No files to deploy");for(let E of s)if(!E.md5)throw k.file(`MD5 checksum missing for file: ${E.path}`,{filePath:E.path});jo(n.password);let c=Co(n.ttl),u=Dd(n.idempotencyKey),l=Gn(n.labels);await Ah(s);let f=Md(n.buildCommand),p=Vd(n.outputDir),_=n.build||n.prerender||n.spa?{build:n.build,prerender:n.prerender,spa:n.spa,buildCommand:f,outputDir:p}:void 0,b=await zh(s,{labels:l,via:n.via??Hx,password:n.password,ttl:c,flags:_,captcha:n.captcha});return o.request(o.deploy.endpoint,{method:"POST",body:b,...u?{headers:{[dt.HEADER]:u}}:{},signal:n.signal||null},"Deploy",n.build||n.prerender?o.deploy.buildTimeout:o.deploy.timeout)},list:async i=>t().request(`${Z.DEPLOYMENTS}${Ql(i)}`,{method:"GET"},"List deployments"),get:async i=>t().request(Z.DEPLOYMENT(encodeURIComponent(i)),{method:"GET"},"Get deployment"),set:async(i,n)=>t().request(Z.DEPLOYMENT(encodeURIComponent(i)),{method:"PATCH",headers:Yi,body:JSON.stringify({labels:Gn(n.labels)})},"Update deployment labels"),delete:async i=>t().request(Z.DEPLOYMENT(encodeURIComponent(i)),{method:"DELETE"},"Delete deployment")}}function jh(e){let{getApi:t}=e;return{set:async(r,i={})=>{let n=Gn(i.labels),o={};i.deployment&&(o.deployment=i.deployment),n!==void 0&&(o.labels=n);let{data:a,status:s}=await t().requestWithStatus(Z.DOMAIN(encodeURIComponent(r)),{method:"PUT",headers:Yi,body:JSON.stringify(o)},"Set domain");return{...a,isCreate:s===201}},list:async r=>t().request(`${Z.DOMAINS}${Ql(r)}`,{method:"GET"},"List domains"),get:async r=>t().request(Z.DOMAIN(encodeURIComponent(r)),{method:"GET"},"Get domain"),delete:async r=>t().request(Z.DOMAIN(encodeURIComponent(r)),{method:"DELETE"},"Delete domain"),verify:async r=>t().request(Z.DOMAIN_VERIFY(encodeURIComponent(r)),{method:"POST"},"Verify domain"),validate:async r=>t().request(Z.DOMAINS_VALIDATE,{method:"POST",headers:Yi,body:JSON.stringify({domain:r})},"Validate domain"),dns:async r=>t().request(Z.DOMAIN_DNS(encodeURIComponent(r)),{method:"GET"},"Get domain DNS"),records:async r=>t().request(Z.DOMAIN_RECORDS(encodeURIComponent(r)),{method:"GET"},"Get domain records"),share:async r=>t().request(Z.DOMAIN_SHARE(encodeURIComponent(r)),{method:"GET"},"Get domain share")}}function Nh(e){let{getApi:t}=e;return{get:async()=>t().request(Z.ACCOUNT,{method:"GET"},"Get account")}}function Uh(e){let{getApi:t}=e;return{create:async(r={})=>{let i=Co(r.ttl),n=Gn(r.labels),o={};return i!==void 0&&(o.ttl=i),n!==void 0&&(o.labels=n),t().request(Z.TOKENS,{method:"POST",headers:Yi,body:JSON.stringify(o)},"Create token")},list:async r=>t().request(`${Z.TOKENS}${Ql(r)}`,{method:"GET"},"List tokens"),get:async r=>t().request(Z.TOKEN(encodeURIComponent(r)),{method:"GET"},"Get token"),delete:async r=>t().request(Z.TOKEN(encodeURIComponent(r)),{method:"DELETE"},"Delete token")}}var Qi=class{constructor(t={}){this.initPromise=null;this.platformLimits=null;this.credential=null;if(t={...t,apiUrl:t.apiUrl||void 0,token:t.token||void 0,caller:t.caller||void 0},this.clientOptions=t,t.caller!==void 0&&Nd(t.caller),t.token&&t.session)throw k.config("Provide either `token` or `session`, not both.");typeof t.token=="string"?(Ye(t.token),this.credential=t.token):t.token&&(this.credential=t.token),this.http=new Ki({...t,getAuthHeaders:()=>this.getAuthHeaders()});let r={getApi:()=>this.http};this.deployments=Ch({...r,processInput:async(i,n)=>(await this.ensureInitialized(),this.processInput(i,n))}),this.domains=jh(r),this.account=Nh(r),this.tokens=Uh(r)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.fetchPlatformLimits()),this.initPromise}async fetchPlatformLimits(){try{this.platformLimits=await this.http.request(Z.LIMITS,{method:"GET"},"Get limits")}catch(t){throw this.initPromise=null,t}}async ping(){return this.http.request(Z.PING,{method:"GET"},"Ping")}async deploy(t,r){return this.deployments.upload(t,r)}async whoami(){return this.account.get()}async getLimits(){return this.platformLimits?this.platformLimits:(await this.ensureInitialized(),this.platformLimits)}on(t,r){this.http.on(t,r)}off(t,r){this.http.off(t,r)}setHeaders(t){this.http.setGlobalHeaders(t)}clearHeaders(){this.http.setGlobalHeaders({})}setToken(t){if(this.clientOptions.session)throw k.config("Provide either `token` or `session`, not both.");if(typeof t=="string"){if(!t)throw k.business("Invalid token provided. Token must be a non-empty string.");Ye(t),this.credential=t;return}if(typeof t!="function")throw k.business("Invalid token provided. Token must be a non-empty string or a provider function.");this.credential=t}async getAuthHeaders(){if(this.credential===null)return{};let t=typeof this.credential=="function"?await this.credential():this.credential;if(!t)throw k.authentication("Token provider returned no token.");if(typeof t!="string")throw k.authentication("Token provider returned a non-string value.");return{Authorization:`Bearer ${t}`}}};Wi();var to=class extends Qi{constructor(t={}){if(qt()!=="node")throw k.business("Node.js Ship class can only be used in Node.js environment.");let r=Bn();super({...t,apiUrl:t.apiUrl||r.apiUrl,token:t.token||(t.session?void 0:r.token)})}async deploy(t,r){return super.deploy(t,r)}async processInput(t,r){let i=typeof t=="string"?[t]:t;if(!Array.isArray(i)||!i.every(o=>typeof o=="string"))throw k.business("Invalid input type for Node.js environment. Expected string or string[].");if(i.length===0)throw k.business("No files to deploy.");let{processFilesForNode:n}=await Promise.resolve().then(()=>(tg(),eg));return n(i,r,this.platformLimits??void 0)}};function ng(e,t,r){return{apiUrl:e.apiUrl||t.apiUrl||r.apiUrl,token:e.token||t.token||r.token}}function rg(e={}){let t=ng(e,Bn(),ql(e.config));return t.apiUrl&&tr(t.apiUrl),new to(t)}function no(e){let t={};try{t=ql(e.config)}catch{}let r=ng(e,Bn(),t).token;return typeof r=="string"?r:void 0}M();function ig(e){return ce(e)?e:e instanceof Error?k.business(e.message):k.business(String(e??"Unknown error"))}var ro="pass --token, set SHIP_TOKEN, or run ship config";function og(e,t){return e.isAuthError()?t?.token?"authentication failed: invalid or expired token":`authentication required: ${ro}`:e.isType(P.Timeout)?e.message:e.isNetworkError()?"network error: could not reach the API. check your internet connection":e.isType(P.Maintenance)?`${e.message.replace(/\.$/,"")} \u2014 check https://status.shipstatic.com`:e.isClientError()?e.message:`${e.message.replace(/\.$/,"")} \u2014 try again, or check https://status.shipstatic.com`}M();function rd(e,t){return e[t]}var rb={[zd.DELETING]:"served until cleanup completes"},ib={upload:"uploaded",create:"created",delete:"deleted",verify:"verification queued"};function cg(e,t){let{operation:r,resource:i}=t;if(!i||e===null||typeof e!="object")return null;let n=r==="set"?rd(e,"isCreate")?"created":"updated":ib[r];if(!n)return null;let o=rd(e,i);if(typeof o!="string")return null;let a=rd(e,"status"),s=typeof a=="string"?rb[a]:void 0;return`${o} ${i} ${s?`${a} \u2014 ${s}`:n}`}function ug(e,t,r){if(r.json||r.quiet)return;let i=cg(e,t);i&&Se(i,!1,r.noColor)}function ob(e,t){let{noColor:r}=t;if(e.deployments.length===0){console.log("no deployments found"),console.log();return}let i=["deployment","labels","files","size","created","via"];console.log(ln(e.deployments,i,r)),od(e.cursor,r)}function od(e,t){e&&_e(`more results available \u2014 rerun with --cursor ${e}`,!1,t)}function ab(e,t){let{noColor:r}=t;if(e.domains.length===0){console.log("no domains found"),console.log();return}let i=["domain","status","deployment","labels","linked","links","created"];console.log(ln(e.domains,i,r)),od(e.cursor,r)}function ag(e,t){let{noColor:r}=t,{_dnsRecords:i,_shareUrl:n,isCreate:o,...a}=e;i&&i.length>0&&(console.log(),_e("DNS records to configure:",!1,r),i.forEach(s=>{console.log(` ${s.type}: ${s.name} \u2192 ${s.value}`)})),n&&(console.log(),_e(`Setup instructions: ${n}`,!1,r)),console.log(Fe(a,r)),cb(a,r)}var sb={[en.LIVE]:()=>null,[en.UNVERIFIED]:e=>`DNS for ${e} is not pointing here yet. See the records to configure: ship domains records ${e}`,[en.UNLINKED]:e=>`Nothing is linked to ${e} yet. Point it at a deployment: ship domains set ${e} <deployment>`,[en.PAUSED]:e=>`${e} is paused: your plan has no room for it, so it serves nothing. Delete another domain, or upgrade your plan.`};function cb(e,t){let r=sb[e.status]?.(e.domain);r&&(console.log(),_e(r,!1,t))}function ub(e,t){let{noColor:r}=t;_e(`It runs in the background. Check with: ship domains get ${e.domain}`,!1,r),e._deployment===null&&(console.log(),_e(`Nothing is linked to ${e.domain} yet. Once it verifies, point it at a deployment: ship domains set ${e.domain} <deployment>`,!1,r))}function id(e,t){let{noColor:r}=t;console.log(Fe(e,r));let i=e.claim;if(i){let n=e.expires?Fd(e.expires):null;console.log(`IMPORTANT: this deployment ${n?`expires in ${n}`:"will expire"}, claim it to keep permanently:
|
|
231
|
+
`)}M();M();Wi();var Tx=xe.object(Jt).strict(),Px={apiUrl:rn.API_URL,token:rn.TOKEN};function Bn(){if(qt()!=="node")return{};let e={apiUrl:process.env[rn.API_URL]||void 0,token:process.env[rn.TOKEN]||void 0};try{return Tx.parse(e)}catch(t){if(t instanceof xe.ZodError){let r=t.issues[0],i=r.path[0],n=(i&&Px[i])??"SHIP environment configuration";throw k.config(`Invalid ${n}: ${r.message}`)}throw k.config("Invalid environment configuration")}}M();M();M();var qi=class{constructor(){this.handlers=new Map}on(t,r){this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t)?.add(r)}off(t,r){let i=this.handlers.get(t);i&&(i.delete(r),i.size===0&&this.handlers.delete(t))}emit(t,...r){let i=this.handlers.get(t);if(!i)return;let n=Array.from(i);for(let o of n)try{o(...r)}catch(a){i.delete(o),t!=="error"&&setTimeout(()=>{let s=a instanceof Error?a:new Error(String(a));this.emit("error",s,String(t))},0)}}};var Ax=3e4,Cx=2,jx=300,Nx=2e3,Ux=new Set([500,502,503,504]);function Rx(e,t){return new Promise((r,i)=>{if(t?.aborted){i(t.reason);return}let n=()=>{clearTimeout(a),t?.removeEventListener("abort",o)},o=()=>{n(),i(t?.reason)},a=setTimeout(()=>{n(),r()},e);t?.addEventListener("abort",o)})}var Oh=3e5,Lx=3e5,Fx=Oh+Lx,Ki=class extends qi{constructor(r){super();this.globalHeaders={};this.apiUrl=r.apiUrl||Ud,this.getAuthHeadersCallback=r.getAuthHeaders,this.session=r.session??!1,this.caller=r.caller,this.timeout=r.timeout??Ax,this.maxRetries=Math.max(0,r.maxRetries??Cx),this.fetch=r.fetch??globalThis.fetch.bind(globalThis),this.deploy={endpoint:r.deployEndpoint||Z.DEPLOYMENTS,timeout:r.timeout??Oh,buildTimeout:r.timeout??Fx}}setGlobalHeaders(r){this.globalHeaders=r}async executeRequest(r,i,n,o=this.timeout){for(let a=0;;a++)try{return await this.attemptOnce(r,i,n,o)}catch(s){let c=k.fromFetchError(s,n);if(a>=this.maxRetries||!this.isRetryable(c,i))throw this.emit("error",c,r),c;this.emit("retry",c,r,a+1);let u=Math.min(Nx,jx*2**a);try{await Rx(Math.random()*u,i.signal)}catch(l){let f=k.fromFetchError(l,n);throw this.emit("error",f,r),f}}}isRetryable(r,i){if(i.signal?.aborted||r.isType(P.Maintenance)||r.isType(P.Cancelled)||!(r.isNetworkError()||r.status!==void 0&&Ux.has(r.status)))return!1;let o=(i.method??"GET").toUpperCase();return o==="GET"||o==="HEAD"?!0:o==="PUT"||o==="DELETE"?!1:this.hasIdempotencyKey(i.headers)}hasIdempotencyKey(r){if(!r)return!1;let i=dt.HEADER.toLowerCase();return Object.keys(r).some(n=>n.toLowerCase()===i)}async attemptOnce(r,i,n,o=this.timeout){let a=()=>{};try{let s=await this.mergeHeaders(i.headers),c=this.createTimeoutSignal(i.signal,o);a=c.cleanup;let u={...i,headers:s,credentials:this.session&&!s.Authorization?"include":void 0,signal:c.signal};this.emit("request",r,u);let l=await this.fetch(r,u);if(a(),!l.ok)throw await k.fromHttpResponse(l,n);return this.emit("response",this.safeClone(l),r),{data:await this.parseResponse(this.safeClone(l)),status:l.status}}catch(s){throw a(),k.fromFetchError(s,n)}}async request(r,i,n,o){let{data:a}=await this.executeRequest(`${this.apiUrl}${r}`,i,n,o);return a}async requestWithStatus(r,i,n){return this.executeRequest(`${this.apiUrl}${r}`,i,n)}async mergeHeaders(r={}){return{...this.globalHeaders,...this.caller?{[Yt.HEADER]:this.caller}:{},...await this.getAuthHeadersCallback(),...r}}createTimeoutSignal(r,i=this.timeout){let n=new AbortController,o=setTimeout(()=>n.abort(new DOMException(`Timed out after ${i}ms`,"TimeoutError")),i),a=r?()=>n.abort(r.reason):void 0;return r&&a&&(r.addEventListener("abort",a),r.aborted&&n.abort(r.reason)),{signal:n.signal,cleanup:()=>{clearTimeout(o),r&&a&&r.removeEventListener("abort",a)}}}safeClone(r){try{return r.clone()}catch{return r}}async parseResponse(r){if(!(r.headers.get("Content-Length")==="0"||r.status===204))return r.json()}};M();M();async function zh(e,t={}){let{labels:r,via:i,password:n,ttl:o,flags:a,captcha:s}=t,c=new FormData,u=[];for(let l of e){if(typeof l.content=="string"||l.content===null||l.content===void 0)throw k.file(`Unsupported file.content type: ${l.path}`,{filePath:l.path});if(!l.md5)throw k.file(`File missing md5 checksum: ${l.path}`,{filePath:l.path});c.append(se.FILES,new File([l.content],l.path,{type:"application/octet-stream"})),u.push(l.md5)}return c.append(se.CHECKSUMS,JSON.stringify(u)),r&&r.length>0&&c.append(se.LABELS,JSON.stringify(r)),i&&c.append(se.VIA,i),n&&c.append(se.PASSWORD,n),o!==void 0&&c.append(se.TTL,String(o)),a?.build&&c.append(se.BUILD,"true"),a?.prerender&&c.append(se.PRERENDER,"true"),a?.spa&&c.append(se.SPA,"true"),a?.buildCommand&&c.append(se.BUILD_COMMAND,a.buildCommand),a?.outputDir&&c.append(se.OUTPUT_DIR,a.outputDir),s&&c.append(se.CAPTCHA,s),c}M();Yl();async function Bx(){let e=JSON.stringify(Cd,null,2),t;typeof Buffer<"u"?t=Buffer.from(e,"utf-8"):t=new Blob([e],{type:"application/json"});let{md5:r}=await Xi(t);return{path:De,content:t,size:e.length,md5:r}}async function Gx(e,t,r){let i=e.find(s=>s.path===er.INDEX_FILE||s.path===`/${er.INDEX_FILE}`);if(!i||i.size>er.MAX_INDEX_BYTES)return!1;let n;if(typeof Buffer<"u"&&Buffer.isBuffer(i.content))n=i.content.toString("utf-8");else if(typeof Blob<"u"&&i.content instanceof Blob)n=await i.content.text();else if(typeof File<"u"&&i.content instanceof File)n=await i.content.text();else return!1;let o={files:e.map(s=>s.path),index:n};return(await t.request(Z.SPA_CHECK,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o),signal:r??null},"SPA check")).isSPA}async function Ph(e,t,r){if(r.spaDetect===!1||r.spa||r.build||r.prerender||e.some(i=>i.path===De))return e;try{if(await Gx(e,t,r.signal)){let n=await Bx();return[...e,n]}}catch(i){if(r.signal?.aborted)throw i}return e}M();M();function Gn(e){if(e==null)return;if(e.length===0)return e;if(e.length>Re.MAX_COUNT)throw k.validation(`Maximum ${Re.MAX_COUNT} labels allowed`);let t=e.map((i,n)=>{if(typeof i!="string")throw k.validation(`Label at index ${n} must be a string`);let o=i.trim().toLowerCase();if(o.length<Re.MIN_LENGTH)throw k.validation(`Labels must be at least ${Re.MIN_LENGTH} characters long`);if(o.length>Re.MAX_LENGTH)throw k.validation(`Labels must be no more than ${Re.MAX_LENGTH} characters long`);if(!Zd.test(o))throw k.validation(`Labels must start and end with alphanumeric characters, with optional separators (${Re.SEPARATORS}) between segments`);return o}),r=[...new Set(t)];if(r.length!==t.length)throw k.validation("Duplicate labels are not allowed");return r}async function Ah(e){let t=e.find(n=>n.path===De||n.path===`/${De}`);if(!t)return;let r=t.content,i=typeof r.text=="function"?await r.text():t.content.toString("utf8");jd(i)}var Yi={"Content-Type":"application/json"},Hx="sdk";function Ql(e){let t=new URLSearchParams;e?.limit!==void 0&&t.set("limit",String(e.limit)),e?.cursor!==void 0&&t.set("cursor",e.cursor);let r=t.toString();return r?`?${r}`:""}function Ch(e){let{getApi:t,processInput:r}=e;return{upload:async(i,n={})=>{if(!r)throw k.config("processInput function is not provided.");let o=t(),a=await r(i,n),s=await Ph(a,o,n);if(!s.length)throw k.business("No files to deploy");for(let E of s)if(!E.md5)throw k.file(`MD5 checksum missing for file: ${E.path}`,{filePath:E.path});jo(n.password);let c=Co(n.ttl),u=Dd(n.idempotencyKey),l=Gn(n.labels);await Ah(s);let f=Md(n.buildCommand),p=Vd(n.outputDir),_=n.build||n.prerender||n.spa?{build:n.build,prerender:n.prerender,spa:n.spa,buildCommand:f,outputDir:p}:void 0,b=await zh(s,{labels:l,via:n.via??Hx,password:n.password,ttl:c,flags:_,captcha:n.captcha});return o.request(o.deploy.endpoint,{method:"POST",body:b,...u?{headers:{[dt.HEADER]:u}}:{},signal:n.signal||null},"Deploy",n.build||n.prerender?o.deploy.buildTimeout:o.deploy.timeout)},list:async i=>t().request(`${Z.DEPLOYMENTS}${Ql(i)}`,{method:"GET"},"List deployments"),get:async i=>t().request(Z.DEPLOYMENT(encodeURIComponent(i)),{method:"GET"},"Get deployment"),set:async(i,n)=>t().request(Z.DEPLOYMENT(encodeURIComponent(i)),{method:"PATCH",headers:Yi,body:JSON.stringify({labels:Gn(n.labels)})},"Update deployment labels"),delete:async i=>t().request(Z.DEPLOYMENT(encodeURIComponent(i)),{method:"DELETE"},"Delete deployment")}}function jh(e){let{getApi:t}=e;return{set:async(r,i={})=>{let n=Gn(i.labels),o={};i.deployment&&(o.deployment=i.deployment),n!==void 0&&(o.labels=n);let{data:a,status:s}=await t().requestWithStatus(Z.DOMAIN(encodeURIComponent(r)),{method:"PUT",headers:Yi,body:JSON.stringify(o)},"Set domain");return{...a,isCreate:s===201}},list:async r=>t().request(`${Z.DOMAINS}${Ql(r)}`,{method:"GET"},"List domains"),get:async r=>t().request(Z.DOMAIN(encodeURIComponent(r)),{method:"GET"},"Get domain"),delete:async r=>t().request(Z.DOMAIN(encodeURIComponent(r)),{method:"DELETE"},"Delete domain"),verify:async r=>t().request(Z.DOMAIN_VERIFY(encodeURIComponent(r)),{method:"POST"},"Verify domain"),validate:async r=>t().request(Z.DOMAINS_VALIDATE,{method:"POST",headers:Yi,body:JSON.stringify({domain:r})},"Validate domain"),dns:async r=>t().request(Z.DOMAIN_DNS(encodeURIComponent(r)),{method:"GET"},"Get domain DNS"),records:async r=>t().request(Z.DOMAIN_RECORDS(encodeURIComponent(r)),{method:"GET"},"Get domain records"),share:async r=>t().request(Z.DOMAIN_SHARE(encodeURIComponent(r)),{method:"GET"},"Get domain share")}}function Nh(e){let{getApi:t}=e;return{get:async()=>t().request(Z.ACCOUNT,{method:"GET"},"Get account")}}function Uh(e){let{getApi:t}=e;return{create:async(r={})=>{let i=Co(r.ttl),n=Gn(r.labels),o={};return i!==void 0&&(o.ttl=i),n!==void 0&&(o.labels=n),t().request(Z.TOKENS,{method:"POST",headers:Yi,body:JSON.stringify(o)},"Create token")},list:async r=>t().request(`${Z.TOKENS}${Ql(r)}`,{method:"GET"},"List tokens"),get:async r=>t().request(Z.TOKEN(encodeURIComponent(r)),{method:"GET"},"Get token"),delete:async r=>t().request(Z.TOKEN(encodeURIComponent(r)),{method:"DELETE"},"Delete token")}}var Qi=class{constructor(t={}){this.credential=null;if(t={...t,apiUrl:t.apiUrl||void 0,token:t.token||void 0,caller:t.caller||void 0},this.clientOptions=t,t.caller!==void 0&&Nd(t.caller),t.token&&t.session)throw k.config("Provide either `token` or `session`, not both.");typeof t.token=="string"?(Ye(t.token),this.credential=t.token):t.token&&(this.credential=t.token),this.http=new Ki({...t,getAuthHeaders:()=>this.getAuthHeaders()});let r={getApi:()=>this.http};this.deployments=Ch({...r,processInput:async(i,n)=>this.processInput(i,n,await this.getLimits({signal:n.signal}))}),this.domains=jh(r),this.account=Nh(r),this.tokens=Uh(r)}async ping(){return this.http.request(Z.PING,{method:"GET"},"Ping")}async deploy(t,r){return this.deployments.upload(t,r)}async whoami(){return this.account.get()}async getLimits(t={}){return this.http.request(Z.LIMITS,{method:"GET",signal:t.signal??null},"Get limits")}on(t,r){this.http.on(t,r)}off(t,r){this.http.off(t,r)}setHeaders(t){this.http.setGlobalHeaders(t)}clearHeaders(){this.http.setGlobalHeaders({})}setToken(t){if(this.clientOptions.session)throw k.config("Provide either `token` or `session`, not both.");if(typeof t=="string"){if(!t)throw k.business("Invalid token provided. Token must be a non-empty string.");Ye(t),this.credential=t;return}if(typeof t!="function")throw k.business("Invalid token provided. Token must be a non-empty string or a provider function.");this.credential=t}async getAuthHeaders(){if(this.credential===null)return{};let t=typeof this.credential=="function"?await this.credential():this.credential;if(!t)throw k.authentication("Token provider returned no token.");if(typeof t!="string")throw k.authentication("Token provider returned a non-string value.");return{Authorization:`Bearer ${t}`}}};Wi();var to=class extends Qi{constructor(t={}){if(qt()!=="node")throw k.business("Node.js Ship class can only be used in Node.js environment.");let r=Bn();super({...t,apiUrl:t.apiUrl||r.apiUrl,token:t.token||(t.session?void 0:r.token)})}async deploy(t,r){return super.deploy(t,r)}async processInput(t,r,i){let n=typeof t=="string"?[t]:t;if(!Array.isArray(n)||!n.every(a=>typeof a=="string"))throw k.business("Invalid input type for Node.js environment. Expected string or string[].");if(n.length===0)throw k.business("No files to deploy.");let{processFilesForNode:o}=await Promise.resolve().then(()=>(tg(),eg));return o(n,r,i)}};function ng(e,t,r){return{apiUrl:e.apiUrl||t.apiUrl||r.apiUrl,token:e.token||t.token||r.token}}function rg(e={}){let t=ng(e,Bn(),ql(e.config));return t.apiUrl&&tr(t.apiUrl),new to(t)}function no(e){let t={};try{t=ql(e.config)}catch{}let r=ng(e,Bn(),t).token;return typeof r=="string"?r:void 0}M();function ig(e){return ce(e)?e:e instanceof Error?k.business(e.message):k.business(String(e??"Unknown error"))}var ro="pass --token, set SHIP_TOKEN, or run ship config";function og(e,t){return e.isAuthError()?t?.token?"authentication failed: invalid or expired token":`authentication required: ${ro}`:e.isType(P.Timeout)?e.message:e.isNetworkError()?"network error: could not reach the API. check your internet connection":e.isType(P.Maintenance)?`${e.message.replace(/\.$/,"")} \u2014 check https://status.shipstatic.com`:e.isClientError()?e.message:`${e.message.replace(/\.$/,"")} \u2014 try again, or check https://status.shipstatic.com`}M();function rd(e,t){return e[t]}var rb={[zd.DELETING]:"served until cleanup completes"},ib={upload:"uploaded",create:"created",delete:"deleted",verify:"verification queued"};function cg(e,t){let{operation:r,resource:i}=t;if(!i||e===null||typeof e!="object")return null;let n=r==="set"?rd(e,"isCreate")?"created":"updated":ib[r];if(!n)return null;let o=rd(e,i);if(typeof o!="string")return null;let a=rd(e,"status"),s=typeof a=="string"?rb[a]:void 0;return`${o} ${i} ${s?`${a} \u2014 ${s}`:n}`}function ug(e,t,r){if(r.json||r.quiet)return;let i=cg(e,t);i&&Se(i,!1,r.noColor)}function ob(e,t){let{noColor:r}=t;if(e.deployments.length===0){console.log("no deployments found"),console.log();return}let i=["deployment","labels","files","size","created","via"];console.log(ln(e.deployments,i,r)),od(e.cursor,r)}function od(e,t){e&&_e(`more results available \u2014 rerun with --cursor ${e}`,!1,t)}function ab(e,t){let{noColor:r}=t;if(e.domains.length===0){console.log("no domains found"),console.log();return}let i=["domain","status","deployment","labels","linked","links","created"];console.log(ln(e.domains,i,r)),od(e.cursor,r)}function ag(e,t){let{noColor:r}=t,{_dnsRecords:i,_shareUrl:n,isCreate:o,...a}=e;i&&i.length>0&&(console.log(),_e("DNS records to configure:",!1,r),i.forEach(s=>{console.log(` ${s.type}: ${s.name} \u2192 ${s.value}`)})),n&&(console.log(),_e(`Setup instructions: ${n}`,!1,r)),console.log(Fe(a,r)),cb(a,r)}var sb={[en.LIVE]:()=>null,[en.UNVERIFIED]:e=>`DNS for ${e} is not pointing here yet. See the records to configure: ship domains records ${e}`,[en.UNLINKED]:e=>`Nothing is linked to ${e} yet. Point it at a deployment: ship domains set ${e} <deployment>`,[en.PAUSED]:e=>`${e} is paused: your plan has no room for it, so it serves nothing. Delete another domain, or upgrade your plan.`};function cb(e,t){let r=sb[e.status]?.(e.domain);r&&(console.log(),_e(r,!1,t))}function ub(e,t){let{noColor:r}=t;_e(`It runs in the background. Check with: ship domains get ${e.domain}`,!1,r),e._deployment===null&&(console.log(),_e(`Nothing is linked to ${e.domain} yet. Once it verifies, point it at a deployment: ship domains set ${e.domain} <deployment>`,!1,r))}function id(e,t){let{noColor:r}=t;console.log(Fe(e,r));let i=e.claim;if(i){let n=e.expires?Fd(e.expires):null;console.log(`IMPORTANT: this deployment ${n?`expires in ${n}`:"will expire"}, claim it to keep permanently:
|
|
232
232
|
${i}
|
|
233
233
|
`),_e("configure a free API key with 'ship config' to deploy to your own account",!1,r)}}function lb(e,t){let{noColor:r}=t;console.log(Fe(e,r))}function db(e,t){let{noColor:r}=t;if(e.valid){if(Se(`${e.normalized??"domain"} domain is valid`,!1,r),console.log(),e.available!==null){let i=e.reason===null?r?"available":"available \u2713":e.reason;console.log(` availability: ${i}`)}console.log()}else console.log(`${mt(e.reason??"domain is invalid")}
|
|
234
234
|
`)}function pb(e,t){let{noColor:r}=t;if(e.records.length===0){console.log("no records found"),console.log();return}let i=["type","name","value"];console.log(ln(e.records,i,r))}function mb(e,t){let{noColor:r}=t,i=e.dns?.provider?.name||null;console.log(Fe({domain:e.domain,provider:i},r))}function fb(e,t){let{noColor:r}=t;console.log(Fe(e,r))}function hb(e,t){let{noColor:r}=t;if(e.tokens.length===0){console.log("no tokens found"),console.log();return}let i=["token","labels","created","expires"];console.log(ln(e.tokens,i,r)),od(e.cursor,r)}function sg(e,t){let{noColor:r}=t;console.log(Fe(e,r))}var G=e=>e,gb=e=>e.resource?`${e.resource}.${e.operation}`:e.operation,vb={"deployment.list":G({quiet:e=>e.deployments.map(t=>t.deployment),text:ob}),"deployment.upload":G({quiet:e=>[e.deployment],text:id}),"deployment.get":G({quiet:e=>[e.deployment],text:id}),"deployment.set":G({quiet:e=>[e.deployment],text:id}),"deployment.delete":G({quiet:e=>[e.deployment],text:()=>{}}),"domain.list":G({quiet:e=>e.domains.map(t=>t.domain),text:ab}),"domain.get":G({quiet:e=>[e.domain],text:ag}),"domain.set":G({quiet:e=>[e.domain],text:ag}),"domain.validate":G({quiet:e=>e.valid&&e.normalized?[e.normalized]:[],text:db}),"domain.verify":G({quiet:e=>[e.domain],text:ub}),"domain.records":G({quiet:e=>e.records.map(t=>`${t.type} ${t.name} ${t.value}`),text:pb}),"domain.dns":G({quiet:e=>e.dns?.provider?.name?[e.dns.provider.name]:[],text:mb}),"domain.share":G({quiet:e=>[e.url],text:fb}),"domain.delete":G({quiet:e=>[e.domain],text:()=>{}}),"token.list":G({quiet:e=>e.tokens.map(t=>t.token),text:hb}),"token.create":G({quiet:e=>[e.secret],text:sg}),"token.get":G({quiet:e=>[e.token],text:sg}),"token.delete":G({quiet:e=>[e.token],text:()=>{}}),"account.get":G({quiet:e=>[e.email],text:lb}),ping:G({quiet:()=>[],text:(e,t)=>Se("api reachable",!1,t.noColor)})};function lg(e,t,r){let{json:i,quiet:n,noColor:o}=r,a=vb[gb(t)];if(n){for(let c of a?.quiet(e)??[])console.log(c);return}if(i&&e!==null&&typeof e=="object"){let c={...e};delete c._dnsRecords,delete c._shareUrl,delete c.isCreate,console.log(JSON.stringify(c,null,2)),console.log();return}let s=cg(e,t);s&&Se(s,!1,o),a?a.text(e,r):e!==null&&typeof e=="object"&&console.log(Fe(e,o))}function wb(){let e=[ld.resolve(__dirname,"../package.json"),ld.resolve(__dirname,"../../package.json")];for(let t of e)try{return JSON.parse((0,lt.readFileSync)(t,"utf-8"))}catch{}return{version:"0.0.0"}}var Ib=wb();function Ob(e){let t=o=>e?o:No(o),r=o=>e?o:Le(o),i=o=>e?"":`${o} `;return`${t("USAGE")}
|