@shipstatic/ship 3.5.0 → 3.6.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/SKILL.md +3 -3
- package/THIRD-PARTY-LICENSES.md +1 -1
- package/dist/browser.d.ts +62 -26
- package/dist/browser.js +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/cli.cjs +36 -36
- 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 +62 -26
- package/dist/index.d.ts +62 -26
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var _t=Object.create;var B=Object.defineProperty;var wt=Object.getOwnPropertyDescriptor;var vt=Object.getOwnPropertyNames;var Ct=Object.getPrototypeOf,Ft=Object.prototype.hasOwnProperty;var S=(e,t)=>()=>(e&&(t=e(e=0)),t);var Xe=(e,t)=>{for(var n in t)B(e,n,{get:t[n],enumerable:!0})},Ye=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of vt(t))!Ft.call(e,o)&&o!==n&&B(e,o,{get:()=>t[o],enumerable:!(r=wt(t,o))||r.enumerable});return e};var b=(e,t,n)=>(n=e!=null?_t(Ct(e)):{},Ye(t||!e||!e.__esModule?B(n,"default",{value:e,enumerable:!0}):n,e)),Mt=e=>Ye(B({},"__esModule",{value:!0}),e);function Gt(e){if(!e||typeof e!="string")return;let t=e.trim().toLowerCase();return Object.values(Qe).includes(t)?t:void 0}function pe(e){if(e==null)return;if(typeof e!="string")throw s.validation("Idempotency key must be a string.");let t=e.trim();if(!t)throw s.validation("Idempotency key must not be empty.");if(t.length>N.MAX_LENGTH)throw s.validation(`Idempotency key must be at most ${N.MAX_LENGTH} characters.`);return t}function Ze(e){return e.members+e.invitations}function zt(e,t){let n=Math.max(0,Ze(e)-t.members),r=Math.max(0,e.members-t.members),o={members:r,invitations:n-r,customDomains:e.customDomains-t.customDomains,platformDomains:e.platformDomains-t.platformDomains};return Object.fromEntries(Object.entries(o).filter(([,i])=>i>0))}function et(e){return nt(["members","customDomains","platformDomains"].filter(t=>(e[t]??0)>0).map(t=>tt(t,e[t]??0)))}function Vt(e){let t=et(e),n=e.invitations??0;return nt([...t?[`remove ${t}`]:[],...n>0?[`cancel ${tt("invitations",n)}`]:[]])}function jt(e){return e.name?.trim()||e.email}function qt(e){return e.name?.trim().split(" ")[0]||e.email}function Qt(e){let t=e.code;return t==="ERR_INVALID_URL"?!1:typeof t=="string"?!0:e instanceof TypeError?!/\burl\b/i.test(e.message):!1}function F(e){return e!==null&&typeof e=="object"&&"name"in e&&e.name==="ShipError"&&"status"in e}function Zt(e){let t=e.replace(/\\/g,"/").split("/").pop()??"",n=t.lastIndexOf(".");return n<=0||n===t.length-1?null:t.slice(n+1).toLowerCase()}function de(e,t){let n=Zt(e);return n===null?!1:Array.isArray(t)?t.includes(n):t.has(n)}function me(e){return rt.test(e)}function M(e){return e.replace(/\\/g,"/").split("/").filter(Boolean).some(n=>V.has(n))}function ot(e){return e.startsWith(fe.PREFIX)?A.API_KEY:e.startsWith(he.PREFIX)?A.DEPLOY_TOKEN:e.startsWith(ye.PREFIX)?A.OAUTH:A.OPAQUE}function on(e){return e.slice(0,ae.length).toLowerCase()!==ae?null:e.slice(ae.length)||null}function ge(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,n;try{n=JSON.parse(t)}catch(r){throw s.config(`invalid JSON format in config: ${r.message}`,{filePath:D})}if(n===null||typeof n!="object"||Array.isArray(n))throw s.config(`${D} must contain a JSON object`,{filePath:D})}function Te(e,t,n){if(!e.startsWith(t.PREFIX))throw s.validation(`${n} must start with "${t.PREFIX}"`);if(e.length!==t.TOTAL_LENGTH)throw s.validation(`${n} must be ${t.TOTAL_LENGTH} characters total (${t.PREFIX} + ${t.HEX_LENGTH} hex chars)`);let r=e.slice(t.PREFIX.length);if(!new RegExp(`^[a-f0-9]{${t.HEX_LENGTH}}$`,"i").test(r))throw s.validation(`${n} must contain ${t.HEX_LENGTH} hexadecimal characters after "${t.PREFIX}" prefix`)}function it(e){Te(e,fe,"API key")}function st(e){Te(e,he,"Deploy token")}function at(e){Te(e,ye,"OAuth access token")}function K(e){switch(ot(e)){case A.API_KEY:it(e);return;case A.DEPLOY_TOKEN:st(e);return;case A.OAUTH:at(e);return;case A.OPAQUE:if(!e)throw s.validation("Token must be a non-empty string")}}function Se(e){if(!e||e.length>O.MAX_LENGTH||!O.PATTERN.test(e))throw s.validation(`Caller must be 1-${O.MAX_LENGTH} characters: letters, digits, dots, underscores, or hyphens`)}function an(e){try{let t=new URL(e);if(!["http:","https:"].includes(t.protocol))throw s.validation("API URL must use http:// or https:// protocol");if(t.pathname!=="/"&&t.pathname!=="")throw s.validation("API URL must not contain a path");if(t.search||t.hash)throw s.validation("API URL must not contain query parameters or fragments")}catch(t){throw F(t)?t:s.validation("API URL must be a valid URL")}}function ln(e){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(e)}function j(e){if(e!=null){if(typeof e!="number"||!Number.isFinite(e))throw s.validation("TTL must be a number of seconds");if(!Number.isInteger(e))throw s.validation("TTL must be a whole number of seconds");if(e<v.MIN_SECONDS||e>v.MAX_SECONDS)throw s.validation(`TTL must be between ${v.MIN_SECONDS} and ${v.MAX_SECONDS} seconds`);return e}}function ut(e){let t=e?`/${e}`:"",n=r=>`${t}${r}`;return{dashboard:()=>t||"/",newSite:()=>n("/new"),deployments:Object.assign(()=>n("/deployments"),{upload:()=>n("/deployments/upload")}),domains:Object.assign(()=>n("/domains"),{connect:r=>n(`/domains/${r}/connect`),deployment:r=>n(`/domains/${r}/deployment`)}),settings:r=>n(r?`/settings#${r}`:"/settings"),claim:r=>n(`/claim/${r}`),settingsAfterBilling:()=>n(`/settings?${We("portal")}`),upgrade:r=>n(r?`/upgrade/${r}`:"/upgrade"),success:()=>n("/success"),successAfterCheckout:()=>n(`/success?${We("checkout")}`),apiKey:()=>n("/api-key")}}function dn(e){let t=new URLSearchParams(e);for(let[n,[r,o]]of Object.entries(ct))if(t.get(r)===o)return n;return null}function q(e){let t=e.split(/[?#]/)[0].toLowerCase(),[n="",r=""]=t.split("/").filter(Boolean);return mn(n)?{kind:"door",door:n}:n===un?{kind:"admin"}:n===""||Je(n)?{kind:"account",account:null,section:n===""?null:n}:{kind:"account",account:n,section:Je(r)?r:null}}function fn(e){let t=q(e);return t.kind==="account"?t.account:null}function pt(e){let t=q(e);return t.kind==="door"?t.door:null}function hn(e){return dt(e)?"claim":pt(e)==="invitation"?"invite":mt(e)?"upgrade":null}function ft(e){let t=Math.round(e/60);if(!(t>=1))return"less than a minute";if(t<120)return ce(t,"minute");let n=Math.round(e/3600);return n<48?ce(n,"hour"):ce(Math.round(e/86400),"day")}function Tn(e,t=Date.now()/1e3){let n=e-t;return n>0?ft(n):null}function ce(e,t){return`${e} ${t}${e===1?"":"s"}`}function _(e,t=1){if(e===0)return"0 Bytes";let n=1024,r=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(e)/Math.log(n));return`${Number.parseFloat((e/n**o).toFixed(t))} ${r[o]}`}function De(e,t){return e.endsWith(`.${t}`)}function Dn(e,t){return!De(e,t)}function An(e,t){return De(e,t)?e.slice(0,-(t.length+1)):null}function Rn(e){return`https://${e}`}function In(e){return`https://${e}`}function Nn(e){return!e||e.length===0?null:JSON.stringify(e)}function Ln(e){if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function Re(e){if(e==null||e==="")return;if(typeof e!="string")throw s.validation("Build command must be a string");let t=e.trim();if(t.length===0||t.length>x.COMMAND_MAX_LENGTH)throw s.validation(`Build command must be between 1 and ${x.COMMAND_MAX_LENGTH} characters`);if(/[\x00-\x1f\x7f]/.test(t))throw s.validation("Build command must be a single line");return t}function Ie(e){if(e==null||e==="")return;if(typeof e!="string")throw s.validation("Output folder must be a string");let t=e.trim().replace(/\/+$/,"");if(t.length===0||t.length>x.OUTPUT_DIR_MAX_LENGTH)throw s.validation(`Output folder must be between 1 and ${x.OUTPUT_DIR_MAX_LENGTH} characters`);if(!x.OUTPUT_DIR_PATTERN.test(t)||t.split("/").some(n=>n===".."||n==="."))throw s.validation("Output folder must be a relative path inside the project, like dist or dist/site");return t}function Y(e){if(e==null)return;if(typeof e!="string")throw s.validation("Password must be a string");let t=e.trim();if(t.length<C.MIN_LENGTH||t.length>C.MAX_LENGTH)throw s.validation(`Password must be between ${C.MIN_LENGTH} and ${C.MAX_LENGTH} characters`);return t}var Ut,Qe,kt,$t,Ht,N,Bt,ue,tt,nt,Kt,m,E,Xt,p,Yt,se,Wt,Jt,s,en,tn,rt,V,nn,z,fe,he,ye,O,rn,A,ae,sn,D,Ee,U,v,lt,cn,un,ct,We,le,pn,mn,Je,dt,mt,X,P,yn,En,gn,Sn,h,R,Ae,x,C,f=S(()=>{"use strict";Ut={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},Qe={WEB:"web",SDK:"sdk",CLI:"cli",MCP:"mcp",GIT:"git",N8N:"n8n",GPT:"gpt",VSC:"vsc",CLD:"cld",CRS:"crs",GMN:"gmn",API:"api"},kt={LIVE:"live",UNLINKED:"unlinked",UNVERIFIED:"unverified",PAUSED:"paused"},$t={PENDING:"pending",PARTIAL:"partial",VERIFIED:"verified"},Ht="troubleshooting",N={HEADER:"Idempotency-Key",MAX_LENGTH:256,WINDOW_SECONDS:1440*60};Bt={FREE:"free",PRO:"pro",TEAM:"team",SCALE:"scale",SPONSORED:"sponsored"};ue={deployments:{one:"deployment",many:"deployments"},platformDomains:{one:"ShipStatic domain",many:"ShipStatic domains"},customDomains:{one:"custom domain",many:"custom domains"},members:{one:"member",many:"members"},invitations:{one:"invitation",many:"invitations"}};tt=(e,t)=>`${t} ${t===1?ue[e].one:ue[e].many}`,nt=e=>e.length>1?`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`:e[0]??"",Kt={PAUSED:"paused",UNKNOWN:"unknown"};m={DEPLOYMENTS:"/deployments",DEPLOYMENT:e=>`/deployments/${e}`,DEPLOYMENT_CONFIG:e=>`/deployments/${e}/config`,DOMAINS:"/domains",DOMAIN:e=>`/domains/${e}`,DOMAIN_VERIFY:e=>`/domains/${e}/verify`,DOMAIN_DNS:e=>`/domains/${e}/dns`,DOMAIN_RECORDS:e=>`/domains/${e}/records`,DOMAIN_SHARE:e=>`/domains/${e}/share`,DOMAIN_PROPAGATION:e=>`/domains/${e}/propagation`,DOMAINS_VALIDATE:"/domains/validate",TOKENS:"/tokens",TOKEN:e=>`/tokens/${e}`,ACCOUNT:"/account",ACCOUNT_KEY:"/account/key",ACCOUNT_CLAIM:"/account/claim",ACTIVITIES:"/activities",LABELS:"/labels",LIMITS:"/limits",PLANS:"/plans",PING:"/ping",SETUP:"/setup",SPA_CHECK:"/spa-check",UPLOAD:"/upload"},E={FILES:"files[]",CHECKSUMS:"checksums",LABELS:"labels",VIA:"via",PASSWORD:"password",TTL:"ttl",BUILD:"build",PRERENDER:"prerender",SPA:"spa",BUILD_COMMAND:"buildCommand",OUTPUT_DIR:"outputDir",CAPTCHA:"captcha"},Xt={PATH:"path",CONTENT:"content",ENCODING:"encoding",DEFAULT_ENCODING:"utf-8",ENCODINGS:["utf-8","base64"]},p={Validation:"validation_failed",NotFound:"not_found",Forbidden:"forbidden",RateLimit:"rate_limit_exceeded",Authentication:"authentication_failed",Business:"business_logic_error",Api:"internal_server_error",Maintenance:"maintenance",Build:"build_failed",Network:"network_error",Timeout:"timeout_error",Cancelled:"operation_cancelled",File:"file_error",Config:"config_error"},Yt=new Set([p.Network,p.Timeout,p.Cancelled,p.File,p.Config]),se={client:new Set([p.Build,p.Business,p.Cancelled,p.Config,p.File,p.Forbidden,p.NotFound,p.RateLimit,p.Validation]),network:new Set([p.Network,p.Timeout]),auth:new Set([p.Authentication])},Wt=new Set(Object.values(p).filter(e=>!Yt.has(e))),Jt=200;s=class e extends Error{type;status;details;constructor(t,n,r,o){super(n),this.type=t,this.status=r,this.details=o,this.name="ShipError"}toResponse(){let t=this.details,n=this.type===p.Authentication&&t?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:n}}static async fromHttpResponse(t,n){let r,o,i;try{if(t.headers.get("content-type")?.includes("application/json")){let d=await t.json();if(d&&typeof d=="object"){let c=d;typeof c.message=="string"?r=c.message:typeof c.error=="string"&&(r=c.error),o=c.details,typeof c.error=="string"&&Wt.has(c.error)&&(i=c.error)}}else{let d=(await t.text()).trim();d&&!d.startsWith("<")&&d.length<=Jt&&(r=d)}}catch{}let l=t.headers.get("retry-after");if(l!==null){let a=l.trim(),d=/^\d+$/.test(a)?Number(a):Math.ceil((Date.parse(a)-Date.now())/1e3);if(Number.isFinite(d)&&d>=0){let c=o&&typeof o=="object"?o:{};c.retryAfter===void 0&&(o={...c,retryAfter:d})}}r=r||`${n||"Request"} failed with status ${t.status}`;let u=i??(t.status===401?p.Authentication:t.status===403?p.Forbidden:t.status===429?p.RateLimit:p.Api);return new e(u,r,t.status,o)}static fromFetchError(t,n){if(F(t))return t;let r=n||"Request",o=t?.name;return o==="AbortError"?e.cancelled(`${r} was cancelled`):o==="TimeoutError"?e.timeout(`${r} timed out`,{cause:t}):t instanceof Error?Qt(t)?e.network(`${r} failed: ${t.message}`,{cause:t}):new e(p.Api,`${r} failed: ${t.message}`):new e(p.Api,`${r} failed: Unknown error`)}static validation(t,n){return new e(p.Validation,t,400,n)}static notFound(t,n){let r=n?`${t} ${n} not found`:`${t} not found`;return new e(p.NotFound,r,404)}static forbidden(t,n){return new e(p.Forbidden,t,403,n)}static rateLimit(t="Too many requests",n){return new e(p.RateLimit,t,429,n)}static authentication(t="Authentication required",n){return new e(p.Authentication,t,401,n)}static business(t,n=400,r){return new e(p.Business,t,n,r)}static network(t,n){return new e(p.Network,t,void 0,n)}static timeout(t,n){return new e(p.Timeout,t,void 0,n)}static cancelled(t,n){return new e(p.Cancelled,t,void 0,n)}static file(t,n){return new e(p.File,t,void 0,n)}static config(t,n){return new e(p.Config,t,void 0,n)}static api(t,n=500,r){return new e(p.Api,t,n,r)}static maintenance(t,n){return new e(p.Maintenance,t,503,n)}static build(t,n){return new e(p.Build,t,422,n)}isClientError(){return se.client.has(this.type)?!0:this.status!==void 0&&this.status>=400&&this.status<500}isNetworkError(){return se.network.has(this.type)}isAuthError(){return se.auth.has(this.type)}isType(t){return this.type===t}};en=["html","htm","xhtml","xml","txt","md","markdown","pdf","csv","json","jsonc","webmanifest","map","toml","yaml","yml","rss","atom","css","scss","sass","less","js","mjs","cjs","jsx","ts","tsx","wasm","vue","svelte","png","jpg","jpeg","gif","webp","avif","svg","ico","bmp","tif","tiff","heic","heif","woff","woff2","ttf","otf","eot","mp3","wav","ogg","oga","opus","m4a","aac","flac","weba","mp4","webm","ogv","mov","m4v","avi","glb","gltf","usdz","vtt","srt","zip"],tn=en.map(e=>`.${e}`).join(","),rt=/[\x00-\x1f\x7f#?%\\<>"]/;V=new Set(["node_modules","package.json"]);nn="/auth",z={SESSION:"session",API_KEY:"apiKey",TOKEN:"token",AGENT:"agent",OAUTH:"oauth",SYSTEM:"system"},fe={PREFIX:"ship-",HEX_LENGTH:32,TOTAL_LENGTH:37,HINT_LENGTH:4},he={PREFIX:"deploy-",HEX_LENGTH:32,TOTAL_LENGTH:39},ye={PREFIX:"oauth-",HEX_LENGTH:32,TOTAL_LENGTH:38},O={HEADER:"X-Caller",MAX_LENGTH:128,PATTERN:/^[a-zA-Z0-9._-]+$/},rn="X-Account",A={API_KEY:z.API_KEY,DEPLOY_TOKEN:z.TOKEN,OAUTH:z.OAUTH,OPAQUE:"opaque"};ae="bearer ";sn={ACCOUNT_READ:"account:read",DEPLOYMENTS_READ:"deployments:read",DEPLOYMENTS_WRITE:"deployments:write",DOMAINS_READ:"domains:read",DOMAINS_WRITE:"domains:write"},D="ship.json",Ee={rewrites:[{source:"/(.*)",destination:"/index.html"}]},U={INDEX_FILE:"index.html",MAX_INDEX_BYTES:100*1024};v={MIN_SECONDS:1,MAX_SECONDS:365*24*60*60};lt={new:{owner:!1},deployments:{owner:!1},domains:{owner:!1},settings:{owner:!1},claim:{owner:!1},upgrade:{owner:!0},success:{owner:!0},"api-key":{owner:!0}},cn=["login","register","logout","invitation","consent"],un="admin",ct={checkout:["upgrading","true"],portal:["billing","returned"]},We=e=>ct[e].join("="),le=(e,t)=>t?`${e}?next=${encodeURIComponent(t)}`:e;pn={login:({token:e,next:t}={})=>le(e?`/login/${e}`:"/login",t),register:({next:e}={})=>le("/register",e),logout:({next:e}={})=>le("/logout",e),invitation:e=>`/invitation/${e}`,consent:()=>"/consent"};mn=e=>cn.includes(e),Je=e=>Object.hasOwn(lt,e);dt=e=>{let t=q(e);return t.kind==="account"&&t.section==="claim"},mt=e=>{let t=q(e);return t.kind==="account"&&t.section==="upgrade"};X="https://api.shipstatic.com",P={TOKEN:"SHIP_TOKEN",API_URL:"SHIP_API_URL"},yn="SHIP_VIA",En=`https://my.shipstatic.com${ut().apiKey()}`,gn=4320*60;Sn=["account.create","account.update","account.delete","account.key.generate","account.plan.transition","deployment.create","deployment.update","deployment.delete","deployment.claim","domain.create","domain.update","domain.delete","domain.verify","token.create","token.consume","token.delete","member.join","member.leave","consent.grant"],h={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};R={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},Ae=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/;x={COMMAND_MAX_LENGTH:200,OUTPUT_DIR_MAX_LENGTH:100,OUTPUT_DIR_PATTERN:/^[A-Za-z0-9._-]+(\/[A-Za-z0-9._-]+)*$/};C={MIN_LENGTH:6,MAX_LENGTH:128}});async function Fn(e){let t=(await import("spark-md5")).default,n=new t.ArrayBuffer,r=2097152;for(let o=0;o<e.size;o+=r){let i=Math.min(o+r,e.size);n.append(await e.slice(o,i).arrayBuffer())}return{md5:n.end()}}async function Mn(e){let{createHash:t}=await import("crypto"),n=t("md5");return n.update(e),{md5:n.digest("hex")}}async function Un(e){let{createHash:t}=await import("crypto"),{createReadStream:n}=await import("fs");return new Promise((r,o)=>{let i=t("md5"),l=n(e);l.on("error",u=>o(s.file(`Failed to read file for MD5: ${u.message}`,{filePath:e}))),l.on("data",u=>i.update(u)),l.on("end",()=>r({md5:i.digest("hex")}))})}async function $(e){if(e instanceof Blob)return Fn(e);if(typeof Buffer<"u"&&Buffer.isBuffer(e))return Mn(e);if(typeof e=="string")return Un(e);throw s.business("Invalid input for MD5 calculation")}var J=S(()=>{"use strict";f()});function Gn(e){Pe=e}function Bn(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function L(){return Pe||Bn()}var Pe,G=S(()=>{"use strict";Pe=null});function Dt(e){if(!e||e.length===0)return"";let t=e.filter(i=>i&&typeof i=="string").map(i=>i.replace(/\\/g,"/"));if(t.length===0)return"";if(t.length===1)return t[0];let n=t.map(i=>i.split("/").filter(Boolean)),r=[],o=Math.min(...n.map(i=>i.length));for(let i=0;i<o;i++){let l=n[0][i];if(n.every(u=>u[i]===l))r.push(l);else break}return r.join("/")}function ee(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var ve=S(()=>{"use strict"});function Fe(e,t={}){if(t.flatten===!1)return e.map(r=>({path:ee(r),name:Ce(r)}));let n=Kn(e);return e.map(r=>{let o=ee(r);if(n){let i=n.endsWith("/")?n:`${n}/`;o.startsWith(i)&&(o=o.substring(i.length))}return o||(o=Ce(r)),{path:o,name:Ce(r)}})}function Kn(e){if(!e.length)return"";let n=e.map(i=>ee(i)).map(i=>i.split("/")),r=[],o=Math.min(...n.map(i=>i.length));for(let i=0;i<o-1;i++){let l=n[0][i];if(n.every(u=>u[i]===l))r.push(l);else break}return r.join("/")}function Ce(e){return e.split(/[/\\]/).pop()||e}var Me=S(()=>{"use strict";ve()});function Ue(e,t,n){let r=t.suggestions?.[n];return r?`${e} ${r}`:e}function ne(e,t){return jn.find(n=>n.broken(e,t))}var jn,w,ke=S(()=>{"use strict";f();$e();jn=[{name:"name",broken:({path:e})=>!te(e).valid,sentence:({path:e})=>te(e).reason??`File name "${e}" is invalid.`},{name:"extension",broken:({path:e},t)=>de(e,t.blockedExtensions??[]),sentence:({path:e})=>`File "${e}" has an extension that is not allowed.`},{name:"fileSize",broken:({size:e},t)=>e>t.maxFileSize,sentence:({path:e},t)=>Ue(`File "${e}" is too large. Maximum ${_(t.maxFileSize)} allowed.`,t,"maxFileSize")},{name:"totalSize",broken:({totalSize:e},t)=>e>t.maxTotalSize,sentence:({totalSize:e},t)=>Ue(`Files add up to ${_(e)}. Maximum ${_(t.maxTotalSize)} allowed.`,t,"maxTotalSize")}],w={name:"filesCount",broken:(e,t)=>e>t.maxFilesCount,sentence:(e,t)=>Ue(`Too many files (${e}). Maximum ${t.maxFilesCount} files allowed.`,t,"maxFilesCount")}});function te(e){let t=o=>({valid:!1,reason:`File name "${e}" ${o}.`});if(me(e))return t("contains unsafe characters");if(e.startsWith(" ")||e.endsWith(" "))return t("cannot start or end with spaces");if(e.endsWith("."))return t("cannot end with dots");let n=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,r=e.split("/").pop()||e;return n.test(r)?t("uses a reserved system name"):e.includes("..")?t("contains a path traversal pattern"):{valid:!0}}function qn(e,t){let n=[],r=[],o=[];if(e.length===0){let a={file:"(no files)",message:"At least one file must be provided."};return n.push(a),{files:[],validFiles:[],errors:n,warnings:[],canDeploy:!1}}for(let a of e)if(M(a.name))return n.push({file:a.name,message:"Unbuilt project detected. Deploy your build output (dist/, build/, out/), not the project folder."}),{files:e.map(d=>({...d,status:h.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:n,warnings:[],canDeploy:!1};if(w.broken(e.length,t)){let a={file:`(${e.length} files)`,message:w.sentence(e.length,t)};return n.push(a),{files:e.map(d=>({...d,status:h.VALIDATION_FAILED,statusMessage:a.message})),validFiles:[],errors:n,warnings:[],canDeploy:!1}}let i=0;for(let a of e){let d=h.READY,c="Ready for upload";if(a.status===h.PROCESSING_ERROR)d=h.VALIDATION_FAILED,c=a.statusMessage||`File "${a.name}" could not be read.`,n.push({file:a.name,message:c});else if(a.size===0){d=h.EXCLUDED,c=`File "${a.name}" is empty, so it is excluded.`,r.push({file:a.name,message:c}),o.push({...a,status:d,statusMessage:c});continue}else if(a.size<0)d=h.VALIDATION_FAILED,c=`File "${a.name}" reports a negative size.`,n.push({file:a.name,message:c});else if(!a.name||a.name.trim().length===0)d=h.VALIDATION_FAILED,c="File name cannot be empty.",n.push({file:a.name||"(empty)",message:c});else if(a.name.includes("\0"))d=h.VALIDATION_FAILED,c=`File name "${a.name}" contains invalid characters (null byte).`,n.push({file:a.name,message:c});else{let y={path:a.name,size:a.size,totalSize:i+a.size},I=ne(y,t);I?(d=h.VALIDATION_FAILED,c=I.sentence(y,t),n.push({file:I.name==="totalSize"?`(${e.length} files)`:a.name,message:c})):i=y.totalSize}o.push({...a,status:d,statusMessage:c})}n.length>0&&(o=o.map(a=>a.status===h.EXCLUDED?a:{...a,status:h.VALIDATION_FAILED,statusMessage:a.status===h.VALIDATION_FAILED?a.statusMessage:"Deployment failed due to validation errors in bundle"}));let l=n.length===0?o.filter(a=>a.status===h.READY):[],u=n.length===0;return{files:o,validFiles:l,errors:n,warnings:r,canDeploy:u}}function At(e){return e.filter(t=>t.status===h.READY)}function Xn(e){return At(e).length>0}var $e=S(()=>{"use strict";f();ke();f()});function He(e,t){if(!e||e.length===0)return[];if(!t?.allowUnbuilt&&e.find(r=>r&&M(r)))throw s.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return e.filter(n=>{if(!n)return!1;let r=n.replace(/\\/g,"/").split("/").filter(Boolean);if(r.length===0)return!0;let o=r[r.length-1];if((0,Rt.isJunk)(o))return!1;for(let l of r)if(l!==".well-known"&&(l.startsWith(".")||l.length>255))return!1;let i=r.slice(0,-1);for(let l of i)if(It.some(u=>l.toLowerCase()===u.toLowerCase()))return!1;return!0})}var Rt,It,Ge=S(()=>{"use strict";f();Rt=require("junk"),It=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function Be(e,t){if(e.includes("\0")||e.includes("/../")||e.startsWith("../")||e.endsWith("/.."))throw s.business(`Security error: Unsafe file path "${e}" for file: ${t}`)}function ze(e,t){let n=ne(e,t);if(n)throw s.business(n.sentence(e,t))}function Ve(e,t){if(w.broken(e,t))throw s.business(w.sentence(e,t))}var Ke=S(()=>{"use strict";f();ke()});async function Nt(e,t={},n){let r=!!(t.build||t.prerender),o=Fe(e.map(c=>c.path),{flatten:t.pathDetect!==!1}).map(c=>c.path),i=new Set(He(o,{allowUnbuilt:r})),l=e.map((c,y)=>({source:c,deployPath:o[y]})).filter(({deployPath:c})=>i.has(c));if(l.length===0)return[];let u=r?null:Wn(n),a=[],d=0;for(let{source:c,deployPath:y}of l){if(u&&Be(y,c.origin),c.size===0)continue;u&&(d+=c.size,ze({path:y,size:c.size,totalSize:d},u));let I=await c.read(),{md5:oe}=await $(I);a.push({path:y,content:I,size:c.size,md5:oe})}return u&&Ve(a.length,u),a}function Wn(e){if(!e)throw s.config("Platform limits not provided. Deploy-mode validation requires the limits argument \u2014 pass `ship.getLimits()` result.");return e}var Lt=S(()=>{"use strict";f();Me();Ge();J();Ke()});var Ot={};Xe(Ot,{processFilesForNode:()=>je});function bt(e,t=new Set){let n=[],r=T.realpathSync(e);if(t.has(r))return n;t.add(r);for(let o of T.readdirSync(e)){let i=g.join(e,o),l=T.statSync(i);l.isDirectory()?n.push(...bt(i,t)):l.isFile()&&n.push({absPath:i,size:l.size})}return n}async function Jn(e){try{return T.readFileSync(e)}catch(t){let n=t instanceof Error?t.message:String(t);throw s.file(`Failed to read file "${e}": ${n}`,{filePath:e})}}function Qn(e){for(let t of e){let n=g.resolve(t);try{if(T.statSync(n).isDirectory()){let r=T.readdirSync(n).find(o=>V.has(o));if(r)throw s.business(`"${r}" detected \u2014 deploy your build output (dist/, build/, out/), not the project folder`)}}catch(r){if(F(r))throw r}}}async function je(e,t={},n){if(L()!=="node")throw s.business("processFilesForNode can only be called in Node.js environment.");Qn(e);let r=e.flatMap(u=>{let a=g.resolve(u);try{let d=T.statSync(a);return d.isDirectory()?bt(a):[{absPath:a,size:d.size}]}catch{throw s.file(`Path does not exist: ${u}`,{filePath:u})}}),o=new Map(r.map(u=>[u.absPath,u.size])),i=Dt(e.map(u=>g.resolve(u)).map(u=>{try{return T.statSync(u).isDirectory()?u:g.dirname(u)}catch{return g.dirname(u)}})),l=[...o].map(([u,a])=>({path:Zn(u,i),origin:u,size:a,read:()=>Jn(u)}));return Nt(l,t,n)}function Zn(e,t){if(t&&t.length>0){let n=g.relative(t,e);if(n&&typeof n=="string"&&!n.startsWith(".."))return n.replace(/\\/g,"/")}return g.basename(e)}var T,g,qe=S(()=>{"use strict";T=b(require("fs"),1),g=b(require("path"),1);f();Lt();G();ve()});var er={};Xe(er,{ACCOUNT_HEADER:()=>rn,API_KEY:()=>fe,API_PATHS:()=>m,AUTH_BASE_PATH:()=>nn,AccountPlan:()=>Bt,AccountRefusal:()=>Kt,ApiHttp:()=>k,AuthMethod:()=>z,BUILD_SETTINGS:()=>x,CALLER:()=>O,DEFAULT_API:()=>X,DEPLOYMENT_CONFIG_FILENAME:()=>D,DEPLOY_FIELDS:()=>E,DEPLOY_FILE_GRAMMAR:()=>Xt,DEPLOY_TOKEN:()=>he,DeploymentStatus:()=>Ut,DeploymentVia:()=>Qe,DomainStatus:()=>kt,DomainVerification:()=>$t,ErrorType:()=>p,FILE_VALIDATION_STATUS:()=>h,FileValidationStatus:()=>h,IDEMPOTENCY_KEY_CONSTRAINTS:()=>N,JUNK_DIRECTORIES:()=>It,LABEL_CONSTRAINTS:()=>R,LABEL_PATTERN:()=>Ae,MY_API_KEY_URL:()=>En,OAUTH_TOKEN:()=>ye,OAuthScope:()=>sn,PASSWORD_CONSTRAINTS:()=>C,PUBLIC_DEPLOYMENT_TTL_SECONDS:()=>gn,SECTIONS:()=>lt,SETUP_TROUBLESHOOTING_ANCHOR:()=>Ht,SHIP_ENV:()=>P,SHIP_VIA_ENV:()=>yn,SPA_CHECK_CONSTRAINTS:()=>U,SPA_DEFAULT_CONFIG:()=>Ee,Ship:()=>re,ShipError:()=>s,TTL_CONSTRAINTS:()=>v,TokenKind:()=>A,UNBUILT_PROJECT_MARKERS:()=>V,UNSAFE_FILENAME_CHARS:()=>rt,USAGE_KIND:()=>ue,USER_VISIBLE_EVENTS:()=>Sn,WEB_FILE_ACCEPT:()=>tn,__setTestEnvironment:()=>Gn,accountOfPath:()=>fn,allValidFilesReady:()=>Xn,assertShipJsonSyntax:()=>ge,billingReturnOf:()=>dn,calculateMD5:()=>$,classifyToken:()=>ot,consolePaths:()=>ut,countPhrase:()=>et,createAccountResource:()=>Oe,createDeploymentResource:()=>Le,createDomainResource:()=>be,createTokenResource:()=>xe,default:()=>xt,deserializeLabels:()=>Ln,doorOf:()=>pt,doors:()=>pn,errandOf:()=>hn,excessOver:()=>zt,extractSubdomain:()=>An,filterJunk:()=>He,fitPhrase:()=>Vt,formatDuration:()=>ft,formatFileSize:()=>_,formatTimeRemaining:()=>Tn,generateDeploymentUrl:()=>Rn,generateDomainUrl:()=>In,getENV:()=>L,getValidFiles:()=>At,hasUnbuiltMarker:()=>M,hasUnsafeChars:()=>me,isBlockedExtension:()=>de,isClaimPath:()=>dt,isCustomDomain:()=>Dn,isDeployment:()=>ln,isPlatformDomain:()=>De,isShipError:()=>F,isUpgradePath:()=>mt,normalizeVia:()=>Gt,optimizeDeployPaths:()=>Fe,personName:()=>jt,personShortName:()=>qt,placesTaken:()=>Ze,pluralize:()=>Yn,processFilesForNode:()=>je,readBearerValue:()=>on,serializeLabels:()=>Nn,validateApiKey:()=>it,validateApiUrl:()=>an,validateBuildCommand:()=>Re,validateCaller:()=>Se,validateDeployCount:()=>Ve,validateDeployFile:()=>ze,validateDeployPath:()=>Be,validateDeployToken:()=>st,validateFileName:()=>te,validateFiles:()=>qn,validateIdempotencyKey:()=>pe,validateOAuthToken:()=>at,validateOutputDir:()=>Ie,validatePassword:()=>Y,validateToken:()=>K,validateTtl:()=>j});module.exports=Mt(er);f();f();f();var W=class{constructor(){this.handlers=new Map}on(t,n){this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t)?.add(n)}off(t,n){let r=this.handlers.get(t);r&&(r.delete(n),r.size===0&&this.handlers.delete(t))}emit(t,...n){let r=this.handlers.get(t);if(!r)return;let o=Array.from(r);for(let i of o)try{i(...n)}catch(l){r.delete(i),t!=="error"&&setTimeout(()=>{let u=l instanceof Error?l:new Error(String(l));this.emit("error",u,String(t))},0)}}};var bn=3e4,On=2,xn=300,Pn=2e3,_n=new Set([500,502,503,504]);function wn(e,t){return new Promise((n,r)=>{if(t?.aborted){r(t.reason);return}let o=()=>{clearTimeout(l),t?.removeEventListener("abort",i)},i=()=>{o(),r(t?.reason)},l=setTimeout(()=>{o(),n()},e);t?.addEventListener("abort",i)})}var ht=3e5,vn=3e5,Cn=ht+vn,k=class extends W{constructor(n){super();this.globalHeaders={};this.apiUrl=n.apiUrl||X,this.getAuthHeadersCallback=n.getAuthHeaders,this.session=n.session??!1,this.caller=n.caller,this.timeout=n.timeout??bn,this.maxRetries=Math.max(0,n.maxRetries??On),this.fetch=n.fetch??globalThis.fetch.bind(globalThis),this.deploy={endpoint:n.deployEndpoint||m.DEPLOYMENTS,timeout:n.timeout??ht,buildTimeout:n.timeout??Cn}}setGlobalHeaders(n){this.globalHeaders=n}async executeRequest(n,r,o,i=this.timeout){for(let l=0;;l++)try{return await this.attemptOnce(n,r,o,i)}catch(u){let a=s.fromFetchError(u,o);if(l>=this.maxRetries||!this.isRetryable(a,r))throw this.emit("error",a,n),a;this.emit("retry",a,n,l+1);let d=Math.min(Pn,xn*2**l);try{await wn(Math.random()*d,r.signal)}catch(c){let y=s.fromFetchError(c,o);throw this.emit("error",y,n),y}}}isRetryable(n,r){if(r.signal?.aborted||n.isType(p.Maintenance)||n.isType(p.Cancelled)||!(n.isNetworkError()||n.status!==void 0&&_n.has(n.status)))return!1;let i=(r.method??"GET").toUpperCase();return i==="GET"||i==="HEAD"?!0:i==="PUT"||i==="DELETE"?!1:this.hasIdempotencyKey(r.headers)}hasIdempotencyKey(n){if(!n)return!1;let r=N.HEADER.toLowerCase();return Object.keys(n).some(o=>o.toLowerCase()===r)}async attemptOnce(n,r,o,i=this.timeout){let l=()=>{};try{let u=await this.mergeHeaders(r.headers),a=this.createTimeoutSignal(r.signal,i);l=a.cleanup;let d={...r,headers:u,credentials:this.session&&!u.Authorization?"include":void 0,signal:a.signal};this.emit("request",n,d);let c=await this.fetch(n,d);if(l(),!c.ok)throw await s.fromHttpResponse(c,o);return this.emit("response",this.safeClone(c),n),{data:await this.parseResponse(this.safeClone(c)),status:c.status}}catch(u){throw l(),s.fromFetchError(u,o)}}async request(n,r,o,i){let{data:l}=await this.executeRequest(`${this.apiUrl}${n}`,r,o,i);return l}async requestWithStatus(n,r,o){return this.executeRequest(`${this.apiUrl}${n}`,r,o)}async mergeHeaders(n={}){return{...this.globalHeaders,...this.caller?{[O.HEADER]:this.caller}:{},...await this.getAuthHeadersCallback(),...n}}createTimeoutSignal(n,r=this.timeout){let o=new AbortController,i=setTimeout(()=>o.abort(new DOMException(`Timed out after ${r}ms`,"TimeoutError")),r),l=n?()=>o.abort(n.reason):void 0;return n&&l&&(n.addEventListener("abort",l),n.aborted&&o.abort(n.reason)),{signal:o.signal,cleanup:()=>{clearTimeout(i),n&&l&&n.removeEventListener("abort",l)}}}safeClone(n){try{return n.clone()}catch{return n}}async parseResponse(n){if(!(n.headers.get("Content-Length")==="0"||n.status===204))return n.json()}};f();f();async function yt(e,t={}){let{labels:n,via:r,password:o,ttl:i,flags:l,captcha:u}=t,a=new FormData,d=[];for(let c of e){if(typeof c.content=="string"||c.content===null||c.content===void 0)throw s.file(`Unsupported file.content type: ${c.path}`,{filePath:c.path});if(!c.md5)throw s.file(`File missing md5 checksum: ${c.path}`,{filePath:c.path});a.append(E.FILES,new File([c.content],c.path,{type:"application/octet-stream"})),d.push(c.md5)}return a.append(E.CHECKSUMS,JSON.stringify(d)),n&&n.length>0&&a.append(E.LABELS,JSON.stringify(n)),r&&a.append(E.VIA,r),o&&a.append(E.PASSWORD,o),i!==void 0&&a.append(E.TTL,String(i)),l?.build&&a.append(E.BUILD,"true"),l?.prerender&&a.append(E.PRERENDER,"true"),l?.spa&&a.append(E.SPA,"true"),l?.buildCommand&&a.append(E.BUILD_COMMAND,l.buildCommand),l?.outputDir&&a.append(E.OUTPUT_DIR,l.outputDir),u&&a.append(E.CAPTCHA,u),a}f();J();async function kn(){let e=JSON.stringify(Ee,null,2),t;typeof Buffer<"u"?t=Buffer.from(e,"utf-8"):t=new Blob([e],{type:"application/json"});let{md5:n}=await $(t);return{path:D,content:t,size:e.length,md5:n}}async function $n(e,t,n){let r=e.find(u=>u.path===U.INDEX_FILE||u.path===`/${U.INDEX_FILE}`);if(!r||r.size>U.MAX_INDEX_BYTES)return!1;let o;if(typeof Buffer<"u"&&Buffer.isBuffer(r.content))o=r.content.toString("utf-8");else if(typeof Blob<"u"&&r.content instanceof Blob)o=await r.content.text();else if(typeof File<"u"&&r.content instanceof File)o=await r.content.text();else return!1;let i={files:e.map(u=>u.path),index:o};return(await t.request(m.SPA_CHECK,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i),signal:n??null},"SPA check")).isSPA}async function Et(e,t,n){return n.spaDetect===!1||n.spa||n.build||n.prerender||e.some(r=>r.path===D)?e:await $n(e,t,n.signal)?[...e,await kn()]:e}f();f();function H(e){if(e==null)return;if(e.length===0)return e;if(e.length>R.MAX_COUNT)throw s.validation(`Maximum ${R.MAX_COUNT} labels allowed`);let t=e.map((r,o)=>{if(typeof r!="string")throw s.validation(`Label at index ${o} must be a string`);let i=r.trim().toLowerCase();if(i.length<R.MIN_LENGTH)throw s.validation(`Labels must be at least ${R.MIN_LENGTH} characters long`);if(i.length>R.MAX_LENGTH)throw s.validation(`Labels must be no more than ${R.MAX_LENGTH} characters long`);if(!Ae.test(i))throw s.validation(`Labels must start and end with alphanumeric characters, with optional separators (${R.SEPARATORS}) between segments`);return i}),n=[...new Set(t)];if(n.length!==t.length)throw s.validation("Duplicate labels are not allowed");return n}async function gt(e){let t=e.find(o=>o.path===D||o.path===`/${D}`);if(!t)return;let n=t.content,r=typeof n.text=="function"?await n.text():t.content.toString("utf8");ge(r)}var Q={"Content-Type":"application/json"},Hn="sdk";function Ne(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 n=t.toString();return n?`?${n}`:""}function Le(e){let{getApi:t,processInput:n}=e;return{upload:async(r,o={})=>{if(!n)throw s.config("processInput function is not provided.");let i=t(),l=await n(r,o),u=await Et(l,i,o);if(!u.length)throw s.business("No files to deploy");for(let ie of u)if(!ie.md5)throw s.file(`MD5 checksum missing for file: ${ie.path}`,{filePath:ie.path});Y(o.password);let a=j(o.ttl),d=pe(o.idempotencyKey),c=H(o.labels);await gt(u);let y=Re(o.buildCommand),I=Ie(o.outputDir),oe=o.build||o.prerender||o.spa?{build:o.build,prerender:o.prerender,spa:o.spa,buildCommand:y,outputDir:I}:void 0,Pt=await yt(u,{labels:c,via:o.via??Hn,password:o.password,ttl:a,flags:oe,captcha:o.captcha});return i.request(i.deploy.endpoint,{method:"POST",body:Pt,...d?{headers:{[N.HEADER]:d}}:{},signal:o.signal||null},"Deploy",o.build||o.prerender?i.deploy.buildTimeout:i.deploy.timeout)},list:async r=>t().request(`${m.DEPLOYMENTS}${Ne(r)}`,{method:"GET"},"List deployments"),get:async r=>t().request(m.DEPLOYMENT(encodeURIComponent(r)),{method:"GET"},"Get deployment"),set:async(r,o)=>t().request(m.DEPLOYMENT(encodeURIComponent(r)),{method:"PATCH",headers:Q,body:JSON.stringify({labels:H(o.labels)})},"Update deployment labels"),delete:async r=>t().request(m.DEPLOYMENT(encodeURIComponent(r)),{method:"DELETE"},"Delete deployment")}}function be(e){let{getApi:t}=e;return{set:async(n,r={})=>{let o=H(r.labels),i={};r.deployment&&(i.deployment=r.deployment),o!==void 0&&(i.labels=o);let{data:l,status:u}=await t().requestWithStatus(m.DOMAIN(encodeURIComponent(n)),{method:"PUT",headers:Q,body:JSON.stringify(i)},"Set domain");return{...l,isCreate:u===201}},list:async n=>t().request(`${m.DOMAINS}${Ne(n)}`,{method:"GET"},"List domains"),get:async n=>t().request(m.DOMAIN(encodeURIComponent(n)),{method:"GET"},"Get domain"),delete:async n=>t().request(m.DOMAIN(encodeURIComponent(n)),{method:"DELETE"},"Delete domain"),verify:async n=>t().request(m.DOMAIN_VERIFY(encodeURIComponent(n)),{method:"POST"},"Verify domain"),validate:async n=>t().request(m.DOMAINS_VALIDATE,{method:"POST",headers:Q,body:JSON.stringify({domain:n})},"Validate domain"),dns:async n=>t().request(m.DOMAIN_DNS(encodeURIComponent(n)),{method:"GET"},"Get domain DNS"),records:async n=>t().request(m.DOMAIN_RECORDS(encodeURIComponent(n)),{method:"GET"},"Get domain records"),share:async n=>t().request(m.DOMAIN_SHARE(encodeURIComponent(n)),{method:"GET"},"Get domain share")}}function Oe(e){let{getApi:t}=e;return{get:async()=>t().request(m.ACCOUNT,{method:"GET"},"Get account")}}function xe(e){let{getApi:t}=e;return{create:async(n={})=>{let r=j(n.ttl),o=H(n.labels),i={};return r!==void 0&&(i.ttl=r),o!==void 0&&(i.labels=o),t().request(m.TOKENS,{method:"POST",headers:Q,body:JSON.stringify(i)},"Create token")},list:async n=>t().request(`${m.TOKENS}${Ne(n)}`,{method:"GET"},"List tokens"),get:async n=>t().request(m.TOKEN(encodeURIComponent(n)),{method:"GET"},"Get token"),delete:async n=>t().request(m.TOKEN(encodeURIComponent(n)),{method:"DELETE"},"Delete token")}}var Z=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&&Se(t.caller),t.token&&t.session)throw s.config("Provide either `token` or `session`, not both.");typeof t.token=="string"?(K(t.token),this.credential=t.token):t.token&&(this.credential=t.token),this.http=new k({...t,getAuthHeaders:()=>this.getAuthHeaders()});let n={getApi:()=>this.http};this.deployments=Le({...n,processInput:async(r,o)=>this.processInput(r,o,await this.getLimits({signal:o.signal}))}),this.domains=be(n),this.account=Oe(n),this.tokens=xe(n)}async ping(){return this.http.request(m.PING,{method:"GET"},"Ping")}async deploy(t,n){return this.deployments.upload(t,n)}async whoami(){return this.account.get()}async getLimits(t={}){return this.http.request(m.LIMITS,{method:"GET",signal:t.signal??null},"Get limits")}on(t,n){this.http.on(t,n)}off(t,n){this.http.off(t,n)}setHeaders(t){this.http.setGlobalHeaders(t)}clearHeaders(){this.http.setGlobalHeaders({})}setToken(t){if(this.clientOptions.session)throw s.config("Provide either `token` or `session`, not both.");if(typeof t=="string"){if(!t)throw s.business("Invalid token provided. Token must be a non-empty string.");K(t),this.credential=t;return}if(typeof t!="function")throw s.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 s.authentication("Token provider returned no token.");if(typeof t!="string")throw s.authentication("Token provider returned a non-string value.");return{Authorization:`Bearer ${t}`}}};G();f();var we=require("zod");var _e=require("zod"),Tt={apiUrl:_e.z.string().url().optional(),token:_e.z.string().min(1).optional()};G();var zn=we.z.object(Tt).strict(),Vn={apiUrl:P.API_URL,token:P.TOKEN};function St(){if(L()!=="node")return{};let e={apiUrl:process.env[P.API_URL]||void 0,token:process.env[P.TOKEN]||void 0};try{return zn.parse(e)}catch(t){if(t instanceof we.z.ZodError){let n=t.issues[0],r=n.path[0],o=(r&&Vn[r])??"SHIP environment configuration";throw s.config(`Invalid ${o}: ${n.message}`)}throw s.config("Invalid environment configuration")}}f();f();Me();G();$e();Ge();J();Ke();function Yn(e,t,n,r=!0){let o=e===1?t:n;return r?`${e} ${o}`:o}qe();var re=class extends Z{constructor(t={}){if(L()!=="node")throw s.business("Node.js Ship class can only be used in Node.js environment.");let n=St();super({...t,apiUrl:t.apiUrl||n.apiUrl,token:t.token||(t.session?void 0:n.token)})}async deploy(t,n){return super.deploy(t,n)}async processInput(t,n,r){let o=typeof t=="string"?[t]:t;if(!Array.isArray(o)||!o.every(l=>typeof l=="string"))throw s.business("Invalid input type for Node.js environment. Expected string or string[].");if(o.length===0)throw s.business("No files to deploy.");let{processFilesForNode:i}=await Promise.resolve().then(()=>(qe(),Ot));return i(o,n,r)}},xt=re;0&&(module.exports={ACCOUNT_HEADER,API_KEY,API_PATHS,AUTH_BASE_PATH,AccountPlan,AccountRefusal,ApiHttp,AuthMethod,BUILD_SETTINGS,CALLER,DEFAULT_API,DEPLOYMENT_CONFIG_FILENAME,DEPLOY_FIELDS,DEPLOY_FILE_GRAMMAR,DEPLOY_TOKEN,DeploymentStatus,DeploymentVia,DomainStatus,DomainVerification,ErrorType,FILE_VALIDATION_STATUS,FileValidationStatus,IDEMPOTENCY_KEY_CONSTRAINTS,JUNK_DIRECTORIES,LABEL_CONSTRAINTS,LABEL_PATTERN,MY_API_KEY_URL,OAUTH_TOKEN,OAuthScope,PASSWORD_CONSTRAINTS,PUBLIC_DEPLOYMENT_TTL_SECONDS,SECTIONS,SETUP_TROUBLESHOOTING_ANCHOR,SHIP_ENV,SHIP_VIA_ENV,SPA_CHECK_CONSTRAINTS,SPA_DEFAULT_CONFIG,Ship,ShipError,TTL_CONSTRAINTS,TokenKind,UNBUILT_PROJECT_MARKERS,UNSAFE_FILENAME_CHARS,USAGE_KIND,USER_VISIBLE_EVENTS,WEB_FILE_ACCEPT,__setTestEnvironment,accountOfPath,allValidFilesReady,assertShipJsonSyntax,billingReturnOf,calculateMD5,classifyToken,consolePaths,countPhrase,createAccountResource,createDeploymentResource,createDomainResource,createTokenResource,deserializeLabels,doorOf,doors,errandOf,excessOver,extractSubdomain,filterJunk,fitPhrase,formatDuration,formatFileSize,formatTimeRemaining,generateDeploymentUrl,generateDomainUrl,getENV,getValidFiles,hasUnbuiltMarker,hasUnsafeChars,isBlockedExtension,isClaimPath,isCustomDomain,isDeployment,isPlatformDomain,isShipError,isUpgradePath,normalizeVia,optimizeDeployPaths,personName,personShortName,placesTaken,pluralize,processFilesForNode,readBearerValue,serializeLabels,validateApiKey,validateApiUrl,validateBuildCommand,validateCaller,validateDeployCount,validateDeployFile,validateDeployPath,validateDeployToken,validateFileName,validateFiles,validateIdempotencyKey,validateOAuthToken,validateOutputDir,validatePassword,validateToken,validateTtl});
|
|
1
|
+
"use strict";var vt=Object.create;var B=Object.defineProperty;var Ct=Object.getOwnPropertyDescriptor;var Ft=Object.getOwnPropertyNames;var Mt=Object.getPrototypeOf,Ut=Object.prototype.hasOwnProperty;var D=(e,t)=>()=>(e&&(t=e(e=0)),t);var Xe=(e,t)=>{for(var n in t)B(e,n,{get:t[n],enumerable:!0})},qe=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ft(t))!Ut.call(e,o)&&o!==n&&B(e,o,{get:()=>t[o],enumerable:!(r=Ct(t,o))||r.enumerable});return e};var O=(e,t,n)=>(n=e!=null?vt(Mt(e)):{},qe(t||!e||!e.__esModule?B(n,"default",{value:e,enumerable:!0}):n,e)),kt=e=>qe(B({},"__esModule",{value:!0}),e);function zt(e){if(!e||typeof e!="string")return;let t=e.trim().toLowerCase();return Object.values(Qe).includes(t)?t:void 0}function ue(e){if(e==null)return;if(typeof e!="string")throw s.validation("Idempotency key must be a string.");let t=e.trim();if(!t)throw s.validation("Idempotency key must not be empty.");if(t.length>N.MAX_LENGTH)throw s.validation(`Idempotency key must be at most ${N.MAX_LENGTH} characters.`);return t}function Ze(e){return e.members+e.invitations}function Kt(e,t){let n=Math.max(0,Ze(e)-t.members),r=Math.max(0,e.members-t.members),o={members:r,invitations:n-r,customDomains:e.customDomains-t.customDomains,platformDomains:e.platformDomains-t.platformDomains};return Object.fromEntries(Object.entries(o).filter(([,i])=>i>0))}function et(e){return nt(["members","customDomains","platformDomains"].filter(t=>(e[t]??0)>0).map(t=>tt(t,e[t]??0)))}function jt(e){let t=et(e),n=e.invitations??0;return nt([...t?[`remove ${t}`]:[],...n>0?[`cancel ${tt("invitations",n)}`]:[]])}function qt(e){return e.name?.trim()||e.email}function Yt(e){return e.name?.trim().split(" ")[0]||e.email}function en(e){let t=e.code;return t==="ERR_INVALID_URL"?!1:typeof t=="string"?!0:e instanceof TypeError?!/\burl\b/i.test(e.message):!1}function M(e){return e!==null&&typeof e=="object"&&"name"in e&&e.name==="ShipError"&&"status"in e}function tn(e){let t=e.replace(/\\/g,"/").split("/").pop()??"",n=t.lastIndexOf(".");return n<=0||n===t.length-1?null:t.slice(n+1).toLowerCase()}function me(e,t){let n=tn(e);return n===null?!1:Array.isArray(t)?t.includes(n):t.has(n)}function de(e){return rt.test(e)}function U(e){return e.replace(/\\/g,"/").split("/").filter(Boolean).some(n=>V.has(n))}function ot(e){return e.startsWith(fe.PREFIX)?A.API_KEY:e.startsWith(he.PREFIX)?A.DEPLOY_TOKEN:e.startsWith(ye.PREFIX)?A.OAUTH:A.OPAQUE}function an(e){return e.slice(0,ae.length).toLowerCase()!==ae?null:e.slice(ae.length)||null}function ge(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,n;try{n=JSON.parse(t)}catch(r){throw s.config(`invalid JSON format in config: ${r.message}`,{filePath:S})}if(n===null||typeof n!="object"||Array.isArray(n))throw s.config(`${S} must contain a JSON object`,{filePath:S})}function Te(e,t,n){if(!e.startsWith(t.PREFIX))throw s.validation(`${n} must start with "${t.PREFIX}"`);if(e.length!==t.TOTAL_LENGTH)throw s.validation(`${n} must be ${t.TOTAL_LENGTH} characters total (${t.PREFIX} + ${t.HEX_LENGTH} hex chars)`);let r=e.slice(t.PREFIX.length);if(!new RegExp(`^[a-f0-9]{${t.HEX_LENGTH}}$`,"i").test(r))throw s.validation(`${n} must contain ${t.HEX_LENGTH} hexadecimal characters after "${t.PREFIX}" prefix`)}function it(e){Te(e,fe,"API key")}function st(e){Te(e,he,"Deploy token")}function at(e){Te(e,ye,"OAuth access token")}function K(e){switch(ot(e)){case A.API_KEY:it(e);return;case A.DEPLOY_TOKEN:st(e);return;case A.OAUTH:at(e);return;case A.OPAQUE:if(!e)throw s.validation("Token must be a non-empty string")}}function De(e){if(!e||e.length>x.MAX_LENGTH||!x.PATTERN.test(e))throw s.validation(`Caller must be 1-${x.MAX_LENGTH} characters: letters, digits, dots, underscores, or hyphens`)}function cn(e){try{let t=new URL(e);if(!["http:","https:"].includes(t.protocol))throw s.validation("API URL must use http:// or https:// protocol");if(t.pathname!=="/"&&t.pathname!=="")throw s.validation("API URL must not contain a path");if(t.search||t.hash)throw s.validation("API URL must not contain query parameters or fragments")}catch(t){throw M(t)?t:s.validation("API URL must be a valid URL")}}function pn(e){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(e)}function j(e){if(e!=null){if(typeof e!="number"||!Number.isFinite(e))throw s.validation("TTL must be a number of seconds");if(!Number.isInteger(e))throw s.validation("TTL must be a whole number of seconds");if(e<C.MIN_SECONDS||e>C.MAX_SECONDS)throw s.validation(`TTL must be between ${C.MIN_SECONDS} and ${C.MAX_SECONDS} seconds`);return e}}function pt(e){let t=e?`/${e}`:"",n=r=>`${t}${r}`;return{dashboard:()=>t||"/",newSite:()=>n("/new"),deployments:Object.assign(()=>n("/deployments"),{upload:()=>n("/deployments/upload")}),domains:Object.assign(()=>n("/domains"),{connect:r=>n(`/domains/${r}/connect`),deployment:r=>n(`/domains/${r}/deployment`)}),settings:r=>n(r?`/settings#${r}`:"/settings"),claim:r=>n(`/claim/${r}`),settingsAfterBilling:()=>n(`/settings?${Ye("portal")}`),upgrade:r=>n(r?`/upgrade/${r}`:"/upgrade"),success:()=>n("/success"),successAfterCheckout:()=>n(`/success?${Ye("checkout")}`),apiKey:()=>n("/api-key")}}function fn(e){let t=new URLSearchParams(e);for(let[n,[r,o]]of Object.entries(ct))if(t.get(r)===o)return n;return null}function X(e){let t=e.split(/[?#]/)[0].toLowerCase(),[n="",r=""]=t.split("/").filter(Boolean);return hn(n)?{kind:"door",door:n}:n===mn?{kind:"admin"}:n===""||We(n)?{kind:"account",account:null,section:n===""?null:n}:{kind:"account",account:n,section:We(r)?r:null}}function yn(e){let t=X(e);return t.kind==="account"?t.account:null}function ut(e){let t=X(e);return t.kind==="door"?t.door:null}function En(e){return mt(e)?"claim":ut(e)==="invitation"?"invite":dt(e)?"upgrade":null}function ft(e){let t=Math.round(e/60);if(!(t>=1))return"less than a minute";if(t<120)return ce(t,"minute");let n=Math.round(e/3600);return n<48?ce(n,"hour"):ce(Math.round(e/86400),"day")}function Sn(e,t=Date.now()/1e3){let n=e-t;return n>0?ft(n):null}function ce(e,t){return`${e} ${t}${e===1?"":"s"}`}function w(e,t=1){if(e===0)return"0 Bytes";let n=1024,r=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(e)/Math.log(n));return`${Number.parseFloat((e/n**o).toFixed(t))} ${r[o]}`}function Se(e,t){return e.endsWith(`.${t}`)}function Rn(e,t){return!Se(e,t)}function In(e,t){return Se(e,t)?e.slice(0,-(t.length+1)):null}function Nn(e){return`https://${e}`}function bn(e){return`https://${e}`}function yt(e){if(typeof e!="string")throw s.validation("Labels must be strings");let t=e.trim().toLowerCase();if(t.length<I.MIN_LENGTH)throw s.validation(`Labels must be at least ${I.MIN_LENGTH} characters long`);if(t.length>I.MAX_LENGTH)throw s.validation(`Labels must be no more than ${I.MAX_LENGTH} characters long`);if(!ht.test(t))throw s.validation("Labels use letters and numbers, with . _ or - between them, and can have one : between a key and a value, like env:production");return t}function b(e){if(e==null)return;if(!Array.isArray(e))throw s.validation("Labels must be an array");if(e.length>I.MAX_COUNT)throw s.validation(`Maximum ${I.MAX_COUNT} labels allowed`);let t=e.map(yt);if(new Set(t).size!==t.length)throw s.validation("Duplicate labels are not allowed");return t}function Ln(e){return!e||e.length===0?null:JSON.stringify(e)}function On(e){if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function Ae(e){if(e==null||e==="")return;if(typeof e!="string")throw s.validation("Build command must be a string");let t=e.trim();if(t.length===0||t.length>P.COMMAND_MAX_LENGTH)throw s.validation(`Build command must be between 1 and ${P.COMMAND_MAX_LENGTH} characters`);if(/[\x00-\x1f\x7f]/.test(t))throw s.validation("Build command must be a single line");return t}function Re(e){if(e==null||e==="")return;if(typeof e!="string")throw s.validation("Output folder must be a string");let t=e.trim().replace(/\/+$/,"");if(t.length===0||t.length>P.OUTPUT_DIR_MAX_LENGTH)throw s.validation(`Output folder must be between 1 and ${P.OUTPUT_DIR_MAX_LENGTH} characters`);if(!P.OUTPUT_DIR_PATTERN.test(t)||t.split("/").some(n=>n===".."||n==="."))throw s.validation("Output folder must be a relative path inside the project, like dist or dist/site");return t}function Y(e){if(e==null)return;if(typeof e!="string")throw s.validation("Password must be a string");let t=e.trim();if(t.length<F.MIN_LENGTH||t.length>F.MAX_LENGTH)throw s.validation(`Password must be between ${F.MIN_LENGTH} and ${F.MAX_LENGTH} characters`);return t}var $t,Qe,Ht,Gt,Bt,N,Vt,pe,tt,nt,Xt,d,E,Wt,u,Jt,se,Qt,Zt,s,nn,rn,rt,V,on,z,fe,he,ye,x,sn,A,ae,ln,S,Ee,k,C,lt,un,mn,ct,Ye,le,dn,hn,We,mt,dt,q,_,gn,Tn,Dn,An,h,I,Je,ht,P,F,f=D(()=>{"use strict";$t={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},Qe={WEB:"web",SDK:"sdk",CLI:"cli",MCP:"mcp",GIT:"git",N8N:"n8n",GPT:"gpt",VSC:"vsc",CLD:"cld",CRS:"crs",GMN:"gmn",API:"api"},Ht={LIVE:"live",UNLINKED:"unlinked",UNVERIFIED:"unverified",PAUSED:"paused"},Gt={PENDING:"pending",PARTIAL:"partial",VERIFIED:"verified"},Bt="troubleshooting",N={HEADER:"Idempotency-Key",MAX_LENGTH:256,WINDOW_SECONDS:1440*60};Vt={FREE:"free",PRO:"pro",TEAM:"team",SCALE:"scale",SPONSORED:"sponsored"};pe={deployments:{one:"deployment",many:"deployments"},platformDomains:{one:"ShipStatic domain",many:"ShipStatic domains"},customDomains:{one:"custom domain",many:"custom domains"},members:{one:"member",many:"members"},invitations:{one:"invitation",many:"invitations"}};tt=(e,t)=>`${t} ${t===1?pe[e].one:pe[e].many}`,nt=e=>e.length>1?`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`:e[0]??"",Xt={PAUSED:"paused",UNKNOWN:"unknown"};d={DEPLOYMENTS:"/deployments",DEPLOYMENT:e=>`/deployments/${e}`,DEPLOYMENT_CONFIG:e=>`/deployments/${e}/config`,DOMAINS:"/domains",DOMAIN:e=>`/domains/${e}`,DOMAIN_VERIFY:e=>`/domains/${e}/verify`,DOMAIN_DNS:e=>`/domains/${e}/dns`,DOMAIN_RECORDS:e=>`/domains/${e}/records`,DOMAIN_SHARE:e=>`/domains/${e}/share`,DOMAIN_PROPAGATION:e=>`/domains/${e}/propagation`,DOMAINS_VALIDATE:"/domains/validate",TOKENS:"/tokens",TOKEN:e=>`/tokens/${e}`,ACCOUNT:"/account",ACCOUNT_KEY:"/account/key",ACCOUNT_CLAIM:"/account/claim",ACTIVITIES:"/activities",LABELS:"/labels",LIMITS:"/limits",PLANS:"/plans",PING:"/ping",SETUP:"/setup",SPA_CHECK:"/spa-check",UPLOAD:"/upload"},E={FILES:"files[]",CHECKSUMS:"checksums",LABELS:"labels",VIA:"via",PASSWORD:"password",TTL:"ttl",BUILD:"build",PRERENDER:"prerender",SPA:"spa",BUILD_COMMAND:"buildCommand",OUTPUT_DIR:"outputDir",CAPTCHA:"captcha"},Wt={PATH:"path",CONTENT:"content",ENCODING:"encoding",DEFAULT_ENCODING:"utf-8",ENCODINGS:["utf-8","base64"]},u={Validation:"validation_failed",NotFound:"not_found",Forbidden:"forbidden",RateLimit:"rate_limit_exceeded",Authentication:"authentication_failed",Business:"business_logic_error",Api:"internal_server_error",Maintenance:"maintenance",Build:"build_failed",Network:"network_error",Timeout:"timeout_error",Cancelled:"operation_cancelled",File:"file_error",Config:"config_error"},Jt=new Set([u.Network,u.Timeout,u.Cancelled,u.File,u.Config]),se={client:new Set([u.Build,u.Business,u.Cancelled,u.Config,u.File,u.Forbidden,u.NotFound,u.RateLimit,u.Validation]),network:new Set([u.Network,u.Timeout]),auth:new Set([u.Authentication])},Qt=new Set(Object.values(u).filter(e=>!Jt.has(e))),Zt=200;s=class e extends Error{type;status;details;constructor(t,n,r,o){super(n),this.type=t,this.status=r,this.details=o,this.name="ShipError"}toResponse(){let t=this.details,n=this.type===u.Authentication&&t?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:n}}static async fromHttpResponse(t,n){let r,o,i;try{if(t.headers.get("content-type")?.includes("application/json")){let m=await t.json();if(m&&typeof m=="object"){let c=m;typeof c.message=="string"?r=c.message:typeof c.error=="string"&&(r=c.error),o=c.details,typeof c.error=="string"&&Qt.has(c.error)&&(i=c.error)}}else{let m=(await t.text()).trim();m&&!m.startsWith("<")&&m.length<=Zt&&(r=m)}}catch{}let l=t.headers.get("retry-after");if(l!==null){let a=l.trim(),m=/^\d+$/.test(a)?Number(a):Math.ceil((Date.parse(a)-Date.now())/1e3);if(Number.isFinite(m)&&m>=0){let c=o&&typeof o=="object"?o:{};c.retryAfter===void 0&&(o={...c,retryAfter:m})}}r=r||`${n||"Request"} failed with status ${t.status}`;let p=i??(t.status===401?u.Authentication:t.status===403?u.Forbidden:t.status===429?u.RateLimit:u.Api);return new e(p,r,t.status,o)}static fromFetchError(t,n){if(M(t))return t;let r=n||"Request",o=t?.name;return o==="AbortError"?e.cancelled(`${r} was cancelled`):o==="TimeoutError"?e.timeout(`${r} timed out`,{cause:t}):t instanceof Error?en(t)?e.network(`${r} failed: ${t.message}`,{cause:t}):new e(u.Api,`${r} failed: ${t.message}`):new e(u.Api,`${r} failed: Unknown error`)}static validation(t,n){return new e(u.Validation,t,400,n)}static notFound(t,n){let r=n?`${t} ${n} not found`:`${t} not found`;return new e(u.NotFound,r,404)}static forbidden(t,n){return new e(u.Forbidden,t,403,n)}static rateLimit(t="Too many requests",n){return new e(u.RateLimit,t,429,n)}static authentication(t="Authentication required",n){return new e(u.Authentication,t,401,n)}static business(t,n=400,r){return new e(u.Business,t,n,r)}static network(t,n){return new e(u.Network,t,void 0,n)}static timeout(t,n){return new e(u.Timeout,t,void 0,n)}static cancelled(t,n){return new e(u.Cancelled,t,void 0,n)}static file(t,n){return new e(u.File,t,void 0,n)}static config(t,n){return new e(u.Config,t,void 0,n)}static api(t,n=500,r){return new e(u.Api,t,n,r)}static maintenance(t,n){return new e(u.Maintenance,t,503,n)}static build(t,n){return new e(u.Build,t,422,n)}isClientError(){return se.client.has(this.type)?!0:this.status!==void 0&&this.status>=400&&this.status<500}isNetworkError(){return se.network.has(this.type)}isAuthError(){return se.auth.has(this.type)}isType(t){return this.type===t}};nn=["html","htm","xhtml","xml","txt","md","markdown","pdf","csv","json","jsonc","webmanifest","map","toml","yaml","yml","rss","atom","css","scss","sass","less","js","mjs","cjs","jsx","ts","tsx","wasm","vue","svelte","png","jpg","jpeg","gif","webp","avif","svg","ico","bmp","tif","tiff","heic","heif","woff","woff2","ttf","otf","eot","mp3","wav","ogg","oga","opus","m4a","aac","flac","weba","mp4","webm","ogv","mov","m4v","avi","glb","gltf","usdz","vtt","srt","zip"],rn=nn.map(e=>`.${e}`).join(","),rt=/[\x00-\x1f\x7f#?%\\<>"]/;V=new Set(["node_modules","package.json"]);on="/auth",z={SESSION:"session",API_KEY:"apiKey",TOKEN:"token",AGENT:"agent",OAUTH:"oauth",SYSTEM:"system"},fe={PREFIX:"ship-",HEX_LENGTH:32,TOTAL_LENGTH:37,HINT_LENGTH:4},he={PREFIX:"deploy-",HEX_LENGTH:32,TOTAL_LENGTH:39},ye={PREFIX:"oauth-",HEX_LENGTH:32,TOTAL_LENGTH:38},x={HEADER:"X-Caller",MAX_LENGTH:128,PATTERN:/^[a-zA-Z0-9._-]+$/},sn="X-Account",A={API_KEY:z.API_KEY,DEPLOY_TOKEN:z.TOKEN,OAUTH:z.OAUTH,OPAQUE:"opaque"};ae="bearer ";ln={ACCOUNT_READ:"account:read",DEPLOYMENTS_READ:"deployments:read",DEPLOYMENTS_WRITE:"deployments:write",DOMAINS_READ:"domains:read",DOMAINS_WRITE:"domains:write"},S="ship.json",Ee={rewrites:[{source:"/(.*)",destination:"/index.html"}]},k={INDEX_FILE:"index.html",MAX_INDEX_BYTES:100*1024};C={MIN_SECONDS:1,MAX_SECONDS:365*24*60*60};lt={new:{owner:!1},deployments:{owner:!1},domains:{owner:!1},settings:{owner:!1},claim:{owner:!1},upgrade:{owner:!0},success:{owner:!0},"api-key":{owner:!0}},un=["login","register","logout","invitation","consent"],mn="admin",ct={checkout:["upgrading","true"],portal:["billing","returned"]},Ye=e=>ct[e].join("="),le=(e,t)=>t?`${e}?next=${encodeURIComponent(t)}`:e;dn={login:({token:e,next:t}={})=>le(e?`/login/${e}`:"/login",t),register:({next:e}={})=>le("/register",e),logout:({next:e}={})=>le("/logout",e),invitation:e=>`/invitation/${e}`,consent:()=>"/consent"};hn=e=>un.includes(e),We=e=>Object.hasOwn(lt,e);mt=e=>{let t=X(e);return t.kind==="account"&&t.section==="claim"},dt=e=>{let t=X(e);return t.kind==="account"&&t.section==="upgrade"};q="https://api.shipstatic.com",_={TOKEN:"SHIP_TOKEN",API_URL:"SHIP_API_URL"},gn="SHIP_VIA",Tn=`https://my.shipstatic.com${pt().apiKey()}`,Dn=4320*60;An=["account.create","account.update","account.delete","account.key.generate","account.plan.transition","deployment.create","deployment.update","deployment.delete","deployment.claim","domain.create","domain.update","domain.delete","domain.verify","token.create","token.consume","token.delete","member.join","member.leave","consent.grant"],h={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};I={MIN_LENGTH:3,MAX_LENGTH:63,MAX_COUNT:10},Je="[a-z0-9]+(?:[._-][a-z0-9]+)*",ht=new RegExp(`^${Je}(?::${Je})?$`);P={COMMAND_MAX_LENGTH:200,OUTPUT_DIR_MAX_LENGTH:100,OUTPUT_DIR_PATTERN:/^[A-Za-z0-9._-]+(\/[A-Za-z0-9._-]+)*$/};F={MIN_LENGTH:6,MAX_LENGTH:128}});async function Un(e){let t=(await import("spark-md5")).default,n=new t.ArrayBuffer,r=2097152;for(let o=0;o<e.size;o+=r){let i=Math.min(o+r,e.size);n.append(await e.slice(o,i).arrayBuffer())}return{md5:n.end()}}async function kn(e){let{createHash:t}=await import("crypto"),n=t("md5");return n.update(e),{md5:n.digest("hex")}}async function $n(e){let{createHash:t}=await import("crypto"),{createReadStream:n}=await import("fs");return new Promise((r,o)=>{let i=t("md5"),l=n(e);l.on("error",p=>o(s.file(`Failed to read file for MD5: ${p.message}`,{filePath:e}))),l.on("data",p=>i.update(p)),l.on("end",()=>r({md5:i.digest("hex")}))})}async function H(e){if(e instanceof Blob)return Un(e);if(typeof Buffer<"u"&&Buffer.isBuffer(e))return kn(e);if(typeof e=="string")return $n(e);throw s.business("Invalid input for MD5 calculation")}var J=D(()=>{"use strict";f()});function zn(e){xe=e}function Vn(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function L(){return xe||Vn()}var xe,G=D(()=>{"use strict";xe=null});function Rt(e){if(!e||e.length===0)return"";let t=e.filter(i=>i&&typeof i=="string").map(i=>i.replace(/\\/g,"/"));if(t.length===0)return"";if(t.length===1)return t[0];let n=t.map(i=>i.split("/").filter(Boolean)),r=[],o=Math.min(...n.map(i=>i.length));for(let i=0;i<o;i++){let l=n[0][i];if(n.every(p=>p[i]===l))r.push(l);else break}return r.join("/")}function ee(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var we=D(()=>{"use strict"});function Ce(e,t={}){if(t.flatten===!1)return e.map(r=>({path:ee(r),name:ve(r)}));let n=Xn(e);return e.map(r=>{let o=ee(r);if(n){let i=n.endsWith("/")?n:`${n}/`;o.startsWith(i)&&(o=o.substring(i.length))}return o||(o=ve(r)),{path:o,name:ve(r)}})}function Xn(e){if(!e.length)return"";let n=e.map(i=>ee(i)).map(i=>i.split("/")),r=[],o=Math.min(...n.map(i=>i.length));for(let i=0;i<o-1;i++){let l=n[0][i];if(n.every(p=>p[i]===l))r.push(l);else break}return r.join("/")}function ve(e){return e.split(/[/\\]/).pop()||e}var Fe=D(()=>{"use strict";we()});function Me(e,t,n){let r=t.suggestions?.[n];return r?`${e} ${r}`:e}function ne(e,t){return qn.find(n=>n.broken(e,t))}var qn,v,Ue=D(()=>{"use strict";f();ke();qn=[{name:"name",broken:({path:e})=>!te(e).valid,sentence:({path:e})=>te(e).reason??`File name "${e}" is invalid.`},{name:"extension",broken:({path:e},t)=>me(e,t.blockedExtensions??[]),sentence:({path:e})=>`File "${e}" has an extension that is not allowed.`},{name:"fileSize",broken:({size:e},t)=>e>t.maxFileSize,sentence:({path:e},t)=>Me(`File "${e}" is too large. Maximum ${w(t.maxFileSize)} allowed.`,t,"maxFileSize")},{name:"totalSize",broken:({totalSize:e},t)=>e>t.maxTotalSize,sentence:({totalSize:e},t)=>Me(`Files add up to ${w(e)}. Maximum ${w(t.maxTotalSize)} allowed.`,t,"maxTotalSize")}],v={name:"filesCount",broken:(e,t)=>e>t.maxFilesCount,sentence:(e,t)=>Me(`Too many files (${e}). Maximum ${t.maxFilesCount} files allowed.`,t,"maxFilesCount")}});function te(e){let t=o=>({valid:!1,reason:`File name "${e}" ${o}.`});if(de(e))return t("contains unsafe characters");if(e.startsWith(" ")||e.endsWith(" "))return t("cannot start or end with spaces");if(e.endsWith("."))return t("cannot end with dots");let n=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,r=e.split("/").pop()||e;return n.test(r)?t("uses a reserved system name"):e.includes("..")?t("contains a path traversal pattern"):{valid:!0}}function Yn(e,t){let n=[],r=[],o=[];if(e.length===0){let a={file:"(no files)",message:"At least one file must be provided."};return n.push(a),{files:[],validFiles:[],errors:n,warnings:[],canDeploy:!1}}for(let a of e)if(U(a.name))return n.push({file:a.name,message:"Unbuilt project detected. Deploy your build output (dist/, build/, out/), not the project folder."}),{files:e.map(m=>({...m,status:h.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:n,warnings:[],canDeploy:!1};if(v.broken(e.length,t)){let a={file:`(${e.length} files)`,message:v.sentence(e.length,t)};return n.push(a),{files:e.map(m=>({...m,status:h.VALIDATION_FAILED,statusMessage:a.message})),validFiles:[],errors:n,warnings:[],canDeploy:!1}}let i=0;for(let a of e){let m=h.READY,c="Ready for upload";if(a.status===h.PROCESSING_ERROR)m=h.VALIDATION_FAILED,c=a.statusMessage||`File "${a.name}" could not be read.`,n.push({file:a.name,message:c});else if(a.size===0){m=h.EXCLUDED,c=`File "${a.name}" is empty, so it is excluded.`,r.push({file:a.name,message:c}),o.push({...a,status:m,statusMessage:c});continue}else if(a.size<0)m=h.VALIDATION_FAILED,c=`File "${a.name}" reports a negative size.`,n.push({file:a.name,message:c});else if(!a.name||a.name.trim().length===0)m=h.VALIDATION_FAILED,c="File name cannot be empty.",n.push({file:a.name||"(empty)",message:c});else if(a.name.includes("\0"))m=h.VALIDATION_FAILED,c=`File name "${a.name}" contains invalid characters (null byte).`,n.push({file:a.name,message:c});else{let y={path:a.name,size:a.size,totalSize:i+a.size},R=ne(y,t);R?(m=h.VALIDATION_FAILED,c=R.sentence(y,t),n.push({file:R.name==="totalSize"?`(${e.length} files)`:a.name,message:c})):i=y.totalSize}o.push({...a,status:m,statusMessage:c})}n.length>0&&(o=o.map(a=>a.status===h.EXCLUDED?a:{...a,status:h.VALIDATION_FAILED,statusMessage:a.status===h.VALIDATION_FAILED?a.statusMessage:"Deployment failed due to validation errors in bundle"}));let l=n.length===0?o.filter(a=>a.status===h.READY):[],p=n.length===0;return{files:o,validFiles:l,errors:n,warnings:r,canDeploy:p}}function It(e){return e.filter(t=>t.status===h.READY)}function Wn(e){return It(e).length>0}var ke=D(()=>{"use strict";f();Ue();f()});function $e(e,t){if(!e||e.length===0)return[];if(!t?.allowUnbuilt&&e.find(r=>r&&U(r)))throw s.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return e.filter(n=>{if(!n)return!1;let r=n.replace(/\\/g,"/").split("/").filter(Boolean);if(r.length===0)return!0;let o=r[r.length-1];if((0,Nt.isJunk)(o))return!1;for(let l of r)if(l!==".well-known"&&(l.startsWith(".")||l.length>255))return!1;let i=r.slice(0,-1);for(let l of i)if(bt.some(p=>l.toLowerCase()===p.toLowerCase()))return!1;return!0})}var Nt,bt,He=D(()=>{"use strict";f();Nt=require("junk"),bt=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function Ge(e,t){if(e.includes("\0")||e.includes("/../")||e.startsWith("../")||e.endsWith("/.."))throw s.business(`Security error: Unsafe file path "${e}" for file: ${t}`)}function Be(e,t){let n=ne(e,t);if(n)throw s.business(n.sentence(e,t))}function ze(e,t){if(v.broken(e,t))throw s.business(v.sentence(e,t))}var Ve=D(()=>{"use strict";f();Ue()});async function Lt(e,t={},n){let r=!!(t.build||t.prerender),o=Ce(e.map(c=>c.path),{flatten:t.pathDetect!==!1}).map(c=>c.path),i=new Set($e(o,{allowUnbuilt:r})),l=e.map((c,y)=>({source:c,deployPath:o[y]})).filter(({deployPath:c})=>i.has(c));if(l.length===0)return[];let p=r?null:Qn(n),a=[],m=0;for(let{source:c,deployPath:y}of l){if(p&&Ge(y,c.origin),c.size===0)continue;p&&(m+=c.size,Be({path:y,size:c.size,totalSize:m},p));let R=await c.read(),{md5:oe}=await H(R);a.push({path:y,content:R,size:c.size,md5:oe})}return p&&ze(a.length,p),a}function Qn(e){if(!e)throw s.config("Platform limits not provided. Deploy-mode validation requires the limits argument \u2014 pass `ship.getLimits()` result.");return e}var Ot=D(()=>{"use strict";f();Fe();He();J();Ve()});var Pt={};Xe(Pt,{processFilesForNode:()=>Ke});function xt(e,t=new Set){let n=[],r=T.realpathSync(e);if(t.has(r))return n;t.add(r);for(let o of T.readdirSync(e)){let i=g.join(e,o),l=T.statSync(i);l.isDirectory()?n.push(...xt(i,t)):l.isFile()&&n.push({absPath:i,size:l.size})}return n}async function Zn(e){try{return T.readFileSync(e)}catch(t){let n=t instanceof Error?t.message:String(t);throw s.file(`Failed to read file "${e}": ${n}`,{filePath:e})}}function er(e){for(let t of e){let n=g.resolve(t);try{if(T.statSync(n).isDirectory()){let r=T.readdirSync(n).find(o=>V.has(o));if(r)throw s.business(`"${r}" detected \u2014 deploy your build output (dist/, build/, out/), not the project folder`)}}catch(r){if(M(r))throw r}}}async function Ke(e,t={},n){if(L()!=="node")throw s.business("processFilesForNode can only be called in Node.js environment.");er(e);let r=e.flatMap(p=>{let a=g.resolve(p);try{let m=T.statSync(a);return m.isDirectory()?xt(a):[{absPath:a,size:m.size}]}catch{throw s.file(`Path does not exist: ${p}`,{filePath:p})}}),o=new Map(r.map(p=>[p.absPath,p.size])),i=Rt(e.map(p=>g.resolve(p)).map(p=>{try{return T.statSync(p).isDirectory()?p:g.dirname(p)}catch{return g.dirname(p)}})),l=[...o].map(([p,a])=>({path:tr(p,i),origin:p,size:a,read:()=>Zn(p)}));return Lt(l,t,n)}function tr(e,t){if(t&&t.length>0){let n=g.relative(t,e);if(n&&typeof n=="string"&&!n.startsWith(".."))return n.replace(/\\/g,"/")}return g.basename(e)}var T,g,je=D(()=>{"use strict";T=O(require("fs"),1),g=O(require("path"),1);f();Ot();G();we()});var nr={};Xe(nr,{ACCOUNT_HEADER:()=>sn,API_KEY:()=>fe,API_PATHS:()=>d,AUTH_BASE_PATH:()=>on,AccountPlan:()=>Vt,AccountRefusal:()=>Xt,ApiHttp:()=>$,AuthMethod:()=>z,BUILD_SETTINGS:()=>P,CALLER:()=>x,DEFAULT_API:()=>q,DEPLOYMENT_CONFIG_FILENAME:()=>S,DEPLOY_FIELDS:()=>E,DEPLOY_FILE_GRAMMAR:()=>Wt,DEPLOY_TOKEN:()=>he,DeploymentStatus:()=>$t,DeploymentVia:()=>Qe,DomainStatus:()=>Ht,DomainVerification:()=>Gt,ErrorType:()=>u,FILE_VALIDATION_STATUS:()=>h,FileValidationStatus:()=>h,IDEMPOTENCY_KEY_CONSTRAINTS:()=>N,JUNK_DIRECTORIES:()=>bt,LABEL_CONSTRAINTS:()=>I,LABEL_PATTERN:()=>ht,MY_API_KEY_URL:()=>Tn,OAUTH_TOKEN:()=>ye,OAuthScope:()=>ln,PASSWORD_CONSTRAINTS:()=>F,PUBLIC_DEPLOYMENT_TTL_SECONDS:()=>Dn,SECTIONS:()=>lt,SETUP_TROUBLESHOOTING_ANCHOR:()=>Bt,SHIP_ENV:()=>_,SHIP_VIA_ENV:()=>gn,SPA_CHECK_CONSTRAINTS:()=>k,SPA_DEFAULT_CONFIG:()=>Ee,Ship:()=>re,ShipError:()=>s,TTL_CONSTRAINTS:()=>C,TokenKind:()=>A,UNBUILT_PROJECT_MARKERS:()=>V,UNSAFE_FILENAME_CHARS:()=>rt,USAGE_KIND:()=>pe,USER_VISIBLE_EVENTS:()=>An,WEB_FILE_ACCEPT:()=>rn,__setTestEnvironment:()=>zn,accountOfPath:()=>yn,allValidFilesReady:()=>Wn,assertShipJsonSyntax:()=>ge,billingReturnOf:()=>fn,calculateMD5:()=>H,classifyToken:()=>ot,consolePaths:()=>pt,countPhrase:()=>et,createAccountResource:()=>Le,createDeploymentResource:()=>Ne,createDomainResource:()=>be,createTokenResource:()=>Oe,default:()=>_t,deserializeLabels:()=>On,doorOf:()=>ut,doors:()=>dn,errandOf:()=>En,excessOver:()=>Kt,extractSubdomain:()=>In,filterJunk:()=>$e,fitPhrase:()=>jt,formatDuration:()=>ft,formatFileSize:()=>w,formatTimeRemaining:()=>Sn,generateDeploymentUrl:()=>Nn,generateDomainUrl:()=>bn,getENV:()=>L,getValidFiles:()=>It,hasUnbuiltMarker:()=>U,hasUnsafeChars:()=>de,isBlockedExtension:()=>me,isClaimPath:()=>mt,isCustomDomain:()=>Rn,isDeployment:()=>pn,isPlatformDomain:()=>Se,isShipError:()=>M,isUpgradePath:()=>dt,normalizeVia:()=>zt,optimizeDeployPaths:()=>Ce,personName:()=>qt,personShortName:()=>Yt,placesTaken:()=>Ze,pluralize:()=>Jn,processFilesForNode:()=>Ke,readBearerValue:()=>an,serializeLabels:()=>Ln,validateApiKey:()=>it,validateApiUrl:()=>cn,validateBuildCommand:()=>Ae,validateCaller:()=>De,validateDeployCount:()=>ze,validateDeployFile:()=>Be,validateDeployPath:()=>Ge,validateDeployToken:()=>st,validateFileName:()=>te,validateFiles:()=>Yn,validateIdempotencyKey:()=>ue,validateLabel:()=>yt,validateLabels:()=>b,validateOAuthToken:()=>at,validateOutputDir:()=>Re,validatePassword:()=>Y,validateToken:()=>K,validateTtl:()=>j});module.exports=kt(nr);f();f();f();var W=class{constructor(){this.handlers=new Map}on(t,n){this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t)?.add(n)}off(t,n){let r=this.handlers.get(t);r&&(r.delete(n),r.size===0&&this.handlers.delete(t))}emit(t,...n){let r=this.handlers.get(t);if(!r)return;let o=Array.from(r);for(let i of o)try{i(...n)}catch(l){r.delete(i),t!=="error"&&setTimeout(()=>{let p=l instanceof Error?l:new Error(String(l));this.emit("error",p,String(t))},0)}}};var xn=3e4,Pn=2,_n=300,wn=2e3,vn=new Set([500,502,503,504]);function Cn(e,t){return new Promise((n,r)=>{if(t?.aborted){r(t.reason);return}let o=()=>{clearTimeout(l),t?.removeEventListener("abort",i)},i=()=>{o(),r(t?.reason)},l=setTimeout(()=>{o(),n()},e);t?.addEventListener("abort",i)})}var Et=3e5,Fn=3e5,Mn=Et+Fn,$=class extends W{constructor(n){super();this.globalHeaders={};this.apiUrl=n.apiUrl||q,this.getAuthHeadersCallback=n.getAuthHeaders,this.session=n.session??!1,this.caller=n.caller,this.timeout=n.timeout??xn,this.maxRetries=Math.max(0,n.maxRetries??Pn),this.fetch=n.fetch??globalThis.fetch.bind(globalThis),this.deploy={endpoint:n.deployEndpoint||d.DEPLOYMENTS,timeout:n.timeout??Et,buildTimeout:n.timeout??Mn}}setGlobalHeaders(n){this.globalHeaders=n}async executeRequest(n,r,o,i=this.timeout){for(let l=0;;l++)try{return await this.attemptOnce(n,r,o,i)}catch(p){let a=s.fromFetchError(p,o);if(l>=this.maxRetries||!this.isRetryable(a,r))throw this.emit("error",a,n),a;this.emit("retry",a,n,l+1);let m=Math.min(wn,_n*2**l);try{await Cn(Math.random()*m,r.signal)}catch(c){let y=s.fromFetchError(c,o);throw this.emit("error",y,n),y}}}isRetryable(n,r){if(r.signal?.aborted||n.isType(u.Maintenance)||n.isType(u.Cancelled)||!(n.isNetworkError()||n.status!==void 0&&vn.has(n.status)))return!1;let i=(r.method??"GET").toUpperCase();return i==="GET"||i==="HEAD"?!0:i==="PUT"||i==="DELETE"?!1:this.hasIdempotencyKey(r.headers)}hasIdempotencyKey(n){if(!n)return!1;let r=N.HEADER.toLowerCase();return Object.keys(n).some(o=>o.toLowerCase()===r)}async attemptOnce(n,r,o,i=this.timeout){let l=()=>{};try{let p=await this.mergeHeaders(r.headers),a=this.createTimeoutSignal(r.signal,i);l=a.cleanup;let m={...r,headers:p,credentials:this.session&&!p.Authorization?"include":void 0,signal:a.signal};this.emit("request",n,m);let c=await this.fetch(n,m);if(l(),!c.ok)throw await s.fromHttpResponse(c,o);return this.emit("response",this.safeClone(c),n),{data:await this.parseResponse(this.safeClone(c)),status:c.status}}catch(p){throw l(),s.fromFetchError(p,o)}}async request(n,r,o,i){let{data:l}=await this.executeRequest(`${this.apiUrl}${n}`,r,o,i);return l}async requestWithStatus(n,r,o){return this.executeRequest(`${this.apiUrl}${n}`,r,o)}async mergeHeaders(n={}){return{...this.globalHeaders,...this.caller?{[x.HEADER]:this.caller}:{},...await this.getAuthHeadersCallback(),...n}}createTimeoutSignal(n,r=this.timeout){let o=new AbortController,i=setTimeout(()=>o.abort(new DOMException(`Timed out after ${r}ms`,"TimeoutError")),r),l=n?()=>o.abort(n.reason):void 0;return n&&l&&(n.addEventListener("abort",l),n.aborted&&o.abort(n.reason)),{signal:o.signal,cleanup:()=>{clearTimeout(i),n&&l&&n.removeEventListener("abort",l)}}}safeClone(n){try{return n.clone()}catch{return n}}async parseResponse(n){if(!(n.headers.get("Content-Length")==="0"||n.status===204))return n.json()}};f();f();async function gt(e,t={}){let{labels:n,via:r,password:o,ttl:i,flags:l,captcha:p}=t,a=new FormData,m=[];for(let c of e){if(typeof c.content=="string"||c.content===null||c.content===void 0)throw s.file(`Unsupported file.content type: ${c.path}`,{filePath:c.path});if(!c.md5)throw s.file(`File missing md5 checksum: ${c.path}`,{filePath:c.path});a.append(E.FILES,new File([c.content],c.path,{type:"application/octet-stream"})),m.push(c.md5)}return a.append(E.CHECKSUMS,JSON.stringify(m)),n&&n.length>0&&a.append(E.LABELS,JSON.stringify(n)),r&&a.append(E.VIA,r),o&&a.append(E.PASSWORD,o),i!==void 0&&a.append(E.TTL,String(i)),l?.build&&a.append(E.BUILD,"true"),l?.prerender&&a.append(E.PRERENDER,"true"),l?.spa&&a.append(E.SPA,"true"),l?.buildCommand&&a.append(E.BUILD_COMMAND,l.buildCommand),l?.outputDir&&a.append(E.OUTPUT_DIR,l.outputDir),p&&a.append(E.CAPTCHA,p),a}f();J();async function Hn(){let e=JSON.stringify(Ee,null,2),t;typeof Buffer<"u"?t=Buffer.from(e,"utf-8"):t=new Blob([e],{type:"application/json"});let{md5:n}=await H(t);return{path:S,content:t,size:e.length,md5:n}}async function Gn(e,t,n){let r=e.find(p=>p.path===k.INDEX_FILE||p.path===`/${k.INDEX_FILE}`);if(!r||r.size>k.MAX_INDEX_BYTES)return!1;let o;if(typeof Buffer<"u"&&Buffer.isBuffer(r.content))o=r.content.toString("utf-8");else if(typeof Blob<"u"&&r.content instanceof Blob)o=await r.content.text();else if(typeof File<"u"&&r.content instanceof File)o=await r.content.text();else return!1;let i={files:e.map(p=>p.path),index:o};return(await t.request(d.SPA_CHECK,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i),signal:n??null},"SPA check")).isSPA}async function Tt(e,t,n){return n.spaDetect===!1||n.spa||n.build||n.prerender||e.some(r=>r.path===S)?e:await Gn(e,t,n.signal)?[...e,await Hn()]:e}f();f();async function Dt(e){let t=e.find(o=>o.path===S||o.path===`/${S}`);if(!t)return;let n=t.content,r=typeof n.text=="function"?await n.text():t.content.toString("utf8");ge(r)}var Q={"Content-Type":"application/json"},Bn="sdk";function Ie(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 n=t.toString();return n?`?${n}`:""}function Ne(e){let{getApi:t,processInput:n}=e;return{upload:async(r,o={})=>{if(!n)throw s.config("processInput function is not provided.");let i=t(),l=await n(r,o),p=await Tt(l,i,o);if(!p.length)throw s.business("No files to deploy");for(let ie of p)if(!ie.md5)throw s.file(`MD5 checksum missing for file: ${ie.path}`,{filePath:ie.path});Y(o.password);let a=j(o.ttl),m=ue(o.idempotencyKey),c=b(o.labels);await Dt(p);let y=Ae(o.buildCommand),R=Re(o.outputDir),oe=o.build||o.prerender||o.spa?{build:o.build,prerender:o.prerender,spa:o.spa,buildCommand:y,outputDir:R}:void 0,wt=await gt(p,{labels:c,via:o.via??Bn,password:o.password,ttl:a,flags:oe,captcha:o.captcha});return i.request(i.deploy.endpoint,{method:"POST",body:wt,...m?{headers:{[N.HEADER]:m}}:{},signal:o.signal||null},"Deploy",o.build||o.prerender?i.deploy.buildTimeout:i.deploy.timeout)},list:async r=>t().request(`${d.DEPLOYMENTS}${Ie(r)}`,{method:"GET"},"List deployments"),get:async r=>t().request(d.DEPLOYMENT(encodeURIComponent(r)),{method:"GET"},"Get deployment"),set:async(r,o)=>t().request(d.DEPLOYMENT(encodeURIComponent(r)),{method:"PATCH",headers:Q,body:JSON.stringify({labels:b(o.labels)})},"Update deployment labels"),delete:async r=>t().request(d.DEPLOYMENT(encodeURIComponent(r)),{method:"DELETE"},"Delete deployment")}}function be(e){let{getApi:t}=e;return{set:async(n,r={})=>{let o=b(r.labels),i={};r.deployment&&(i.deployment=r.deployment),o!==void 0&&(i.labels=o);let{data:l,status:p}=await t().requestWithStatus(d.DOMAIN(encodeURIComponent(n)),{method:"PUT",headers:Q,body:JSON.stringify(i)},"Set domain");return{...l,isCreate:p===201}},list:async n=>t().request(`${d.DOMAINS}${Ie(n)}`,{method:"GET"},"List domains"),get:async n=>t().request(d.DOMAIN(encodeURIComponent(n)),{method:"GET"},"Get domain"),delete:async n=>t().request(d.DOMAIN(encodeURIComponent(n)),{method:"DELETE"},"Delete domain"),verify:async n=>t().request(d.DOMAIN_VERIFY(encodeURIComponent(n)),{method:"POST"},"Verify domain"),validate:async n=>t().request(d.DOMAINS_VALIDATE,{method:"POST",headers:Q,body:JSON.stringify({domain:n})},"Validate domain"),dns:async n=>t().request(d.DOMAIN_DNS(encodeURIComponent(n)),{method:"GET"},"Get domain DNS"),records:async n=>t().request(d.DOMAIN_RECORDS(encodeURIComponent(n)),{method:"GET"},"Get domain records"),share:async n=>t().request(d.DOMAIN_SHARE(encodeURIComponent(n)),{method:"GET"},"Get domain share")}}function Le(e){let{getApi:t}=e;return{get:async()=>t().request(d.ACCOUNT,{method:"GET"},"Get account")}}function Oe(e){let{getApi:t}=e;return{create:async(n={})=>{let r=j(n.ttl),o=b(n.labels),i={};return r!==void 0&&(i.ttl=r),o!==void 0&&(i.labels=o),t().request(d.TOKENS,{method:"POST",headers:Q,body:JSON.stringify(i)},"Create token")},list:async n=>t().request(`${d.TOKENS}${Ie(n)}`,{method:"GET"},"List tokens"),get:async n=>t().request(d.TOKEN(encodeURIComponent(n)),{method:"GET"},"Get token"),delete:async n=>t().request(d.TOKEN(encodeURIComponent(n)),{method:"DELETE"},"Delete token")}}var Z=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&&De(t.caller),t.token&&t.session)throw s.config("Provide either `token` or `session`, not both.");typeof t.token=="string"?(K(t.token),this.credential=t.token):t.token&&(this.credential=t.token),this.http=new $({...t,getAuthHeaders:()=>this.getAuthHeaders()});let n={getApi:()=>this.http};this.deployments=Ne({...n,processInput:async(r,o)=>this.processInput(r,o,await this.getLimits({signal:o.signal}))}),this.domains=be(n),this.account=Le(n),this.tokens=Oe(n)}async ping(){return this.http.request(d.PING,{method:"GET"},"Ping")}async deploy(t,n){return this.deployments.upload(t,n)}async whoami(){return this.account.get()}async getLimits(t={}){return this.http.request(d.LIMITS,{method:"GET",signal:t.signal??null},"Get limits")}on(t,n){this.http.on(t,n)}off(t,n){this.http.off(t,n)}setHeaders(t){this.http.setGlobalHeaders(t)}clearHeaders(){this.http.setGlobalHeaders({})}setToken(t){if(this.clientOptions.session)throw s.config("Provide either `token` or `session`, not both.");if(typeof t=="string"){if(!t)throw s.business("Invalid token provided. Token must be a non-empty string.");K(t),this.credential=t;return}if(typeof t!="function")throw s.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 s.authentication("Token provider returned no token.");if(typeof t!="string")throw s.authentication("Token provider returned a non-string value.");return{Authorization:`Bearer ${t}`}}};G();f();var _e=require("zod");var Pe=require("zod"),St={apiUrl:Pe.z.string().url().optional(),token:Pe.z.string().min(1).optional()};G();var Kn=_e.z.object(St).strict(),jn={apiUrl:_.API_URL,token:_.TOKEN};function At(){if(L()!=="node")return{};let e={apiUrl:process.env[_.API_URL]||void 0,token:process.env[_.TOKEN]||void 0};try{return Kn.parse(e)}catch(t){if(t instanceof _e.z.ZodError){let n=t.issues[0],r=n.path[0],o=(r&&jn[r])??"SHIP environment configuration";throw s.config(`Invalid ${o}: ${n.message}`)}throw s.config("Invalid environment configuration")}}f();f();Fe();G();ke();He();J();Ve();function Jn(e,t,n,r=!0){let o=e===1?t:n;return r?`${e} ${o}`:o}je();var re=class extends Z{constructor(t={}){if(L()!=="node")throw s.business("Node.js Ship class can only be used in Node.js environment.");let n=At();super({...t,apiUrl:t.apiUrl||n.apiUrl,token:t.token||(t.session?void 0:n.token)})}async deploy(t,n){return super.deploy(t,n)}async processInput(t,n,r){let o=typeof t=="string"?[t]:t;if(!Array.isArray(o)||!o.every(l=>typeof l=="string"))throw s.business("Invalid input type for Node.js environment. Expected string or string[].");if(o.length===0)throw s.business("No files to deploy.");let{processFilesForNode:i}=await Promise.resolve().then(()=>(je(),Pt));return i(o,n,r)}},_t=re;0&&(module.exports={ACCOUNT_HEADER,API_KEY,API_PATHS,AUTH_BASE_PATH,AccountPlan,AccountRefusal,ApiHttp,AuthMethod,BUILD_SETTINGS,CALLER,DEFAULT_API,DEPLOYMENT_CONFIG_FILENAME,DEPLOY_FIELDS,DEPLOY_FILE_GRAMMAR,DEPLOY_TOKEN,DeploymentStatus,DeploymentVia,DomainStatus,DomainVerification,ErrorType,FILE_VALIDATION_STATUS,FileValidationStatus,IDEMPOTENCY_KEY_CONSTRAINTS,JUNK_DIRECTORIES,LABEL_CONSTRAINTS,LABEL_PATTERN,MY_API_KEY_URL,OAUTH_TOKEN,OAuthScope,PASSWORD_CONSTRAINTS,PUBLIC_DEPLOYMENT_TTL_SECONDS,SECTIONS,SETUP_TROUBLESHOOTING_ANCHOR,SHIP_ENV,SHIP_VIA_ENV,SPA_CHECK_CONSTRAINTS,SPA_DEFAULT_CONFIG,Ship,ShipError,TTL_CONSTRAINTS,TokenKind,UNBUILT_PROJECT_MARKERS,UNSAFE_FILENAME_CHARS,USAGE_KIND,USER_VISIBLE_EVENTS,WEB_FILE_ACCEPT,__setTestEnvironment,accountOfPath,allValidFilesReady,assertShipJsonSyntax,billingReturnOf,calculateMD5,classifyToken,consolePaths,countPhrase,createAccountResource,createDeploymentResource,createDomainResource,createTokenResource,deserializeLabels,doorOf,doors,errandOf,excessOver,extractSubdomain,filterJunk,fitPhrase,formatDuration,formatFileSize,formatTimeRemaining,generateDeploymentUrl,generateDomainUrl,getENV,getValidFiles,hasUnbuiltMarker,hasUnsafeChars,isBlockedExtension,isClaimPath,isCustomDomain,isDeployment,isPlatformDomain,isShipError,isUpgradePath,normalizeVia,optimizeDeployPaths,personName,personShortName,placesTaken,pluralize,processFilesForNode,readBearerValue,serializeLabels,validateApiKey,validateApiUrl,validateBuildCommand,validateCaller,validateDeployCount,validateDeployFile,validateDeployPath,validateDeployToken,validateFileName,validateFiles,validateIdempotencyKey,validateLabel,validateLabels,validateOAuthToken,validateOutputDir,validatePassword,validateToken,validateTtl});
|
|
2
2
|
|
|
3
3
|
// Ship SDK: Enable axios-style CommonJS imports
|
|
4
4
|
const originalExports = module.exports;
|