@shipstatic/ship 3.4.0-beta.2 → 3.4.0-beta.4
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/THIRD-PARTY-LICENSES.md +1 -1
- package/dist/browser.d.ts +33 -10
- package/dist/browser.js +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/cli.cjs +67 -67
- 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 +33 -10
- package/dist/index.d.ts +33 -10
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -734,8 +734,9 @@ type AccountPlanType = (typeof AccountPlan)[keyof typeof AccountPlan];
|
|
|
734
734
|
* "unlimited" — so no consumer needs an "is it bounded?" branch. A cap of `0`
|
|
735
735
|
* means the plan does not have the feature at all; a cap of `N` bounds
|
|
736
736
|
* creation, and what an account already holds above a cap stays until a plan
|
|
737
|
-
* TRANSITION fits it
|
|
738
|
-
*
|
|
737
|
+
* TRANSITION fits it: excess domains are paused, newest first, and members
|
|
738
|
+
* are paused together while the account holds more than its cap. Deployments
|
|
739
|
+
* never pause; above their cap they only block creation.
|
|
739
740
|
*
|
|
740
741
|
* A count is an aggregate over a collection, so it lives on the summary
|
|
741
742
|
* resource that owns the collection: `GET /account` for one caller, `GET
|
|
@@ -941,10 +942,12 @@ interface Account {
|
|
|
941
942
|
* from where the account stands. It excludes the plan and cadence the
|
|
942
943
|
* account already holds and the one move the door refuses, a dearer tier
|
|
943
944
|
* at a shorter interval (an immediate move would mint a proration credit,
|
|
944
|
-
* a deferred one would make a customer asking for more wait a year).
|
|
945
|
-
*
|
|
946
|
-
*
|
|
947
|
-
*
|
|
945
|
+
* a deferred one would make a customer asking for more wait a year). A
|
|
946
|
+
* cheaper tier the account does not yet fit is listed with what stands in
|
|
947
|
+
* the way ({@link PlanDestination.excess}). The rule's owner is the
|
|
948
|
+
* platform's plan table; a console feeds these rows into its own move
|
|
949
|
+
* model instead of restating it. Additive: absent on responses that
|
|
950
|
+
* predate it, and a client then derives as it did.
|
|
948
951
|
*/
|
|
949
952
|
readonly destinations?: PlanDestination[];
|
|
950
953
|
}
|
|
@@ -956,6 +959,15 @@ interface Account {
|
|
|
956
959
|
interface PlanDestination {
|
|
957
960
|
readonly plan: AccountPlanType;
|
|
958
961
|
readonly intervals: BillingInterval[];
|
|
962
|
+
/**
|
|
963
|
+
* What the account holds beyond what this plan allows: per kind, how many
|
|
964
|
+
* to remove. Present only on a cheaper tier the account does not fit, and
|
|
965
|
+
* then never empty. A move down a tier pauses nothing, so the change door
|
|
966
|
+
* refuses it until the account fits: the owner removes the excess, and the
|
|
967
|
+
* field is gone from the next read. Which kinds count is the platform's to
|
|
968
|
+
* decide; a client renders the keys it is given.
|
|
969
|
+
*/
|
|
970
|
+
readonly excess?: Partial<Caps>;
|
|
959
971
|
}
|
|
960
972
|
/**
|
|
961
973
|
* Acknowledgement of `DELETE /account` (202). Termination is asynchronous —
|
|
@@ -2484,6 +2496,11 @@ interface PlansResponse {
|
|
|
2484
2496
|
* consent), and a billed account moving down gets a Stripe Subscription
|
|
2485
2497
|
* Schedule that applies the change at period end. The answer says which
|
|
2486
2498
|
* happened ({@link PlanChangeResponse}).
|
|
2499
|
+
*
|
|
2500
|
+
* A move down a tier is refused while the account holds more than the
|
|
2501
|
+
* destination allows (400, `details.excess` in {@link PlanDestination.excess}'s
|
|
2502
|
+
* shape): nothing is paused for a change the owner chose, so the account fits
|
|
2503
|
+
* first.
|
|
2487
2504
|
*/
|
|
2488
2505
|
interface PlanChangeRequest {
|
|
2489
2506
|
readonly plan: AccountPlanType;
|
|
@@ -2901,8 +2918,11 @@ declare function validatePassword(value: unknown): string | undefined;
|
|
|
2901
2918
|
interface DeploymentOptions extends DeploymentUploadOptions {
|
|
2902
2919
|
/**
|
|
2903
2920
|
* An AbortSignal to allow cancellation of the deploy operation. The one
|
|
2904
|
-
* cancellation mechanism
|
|
2905
|
-
*
|
|
2921
|
+
* cancellation mechanism: it reaches every request the deploy makes (the
|
|
2922
|
+
* limits it validates against, the SPA question and the upload itself),
|
|
2923
|
+
* and aborting it rejects the deploy with a typed `Cancelled` error
|
|
2924
|
+
* wherever it stands. A deploy the server had already committed stays
|
|
2925
|
+
* committed. Request timeouts are a client concern
|
|
2906
2926
|
* (`ShipClientOptions.timeout`), not a per-deploy one.
|
|
2907
2927
|
*/
|
|
2908
2928
|
signal?: AbortSignal;
|
|
@@ -3391,9 +3411,12 @@ declare abstract class Ship$1 {
|
|
|
3391
3411
|
/**
|
|
3392
3412
|
* Get the platform limits the server states now (max file size, file count,
|
|
3393
3413
|
* total size, and the blocked extensions). Asked every time and never held,
|
|
3394
|
-
* since a plan move or an operator's grant changes them.
|
|
3414
|
+
* since a plan move or an operator's grant changes them. A `signal` aborts
|
|
3415
|
+
* the request, rejecting with the typed `Cancelled` error.
|
|
3395
3416
|
*/
|
|
3396
|
-
getLimits(
|
|
3417
|
+
getLimits(options?: {
|
|
3418
|
+
signal?: AbortSignal;
|
|
3419
|
+
}): Promise<PlatformLimits>;
|
|
3397
3420
|
on<K extends keyof ShipEvents>(event: K, handler: (...args: ShipEvents[K]) => void): void;
|
|
3398
3421
|
off<K extends keyof ShipEvents>(event: K, handler: (...args: ShipEvents[K]) => void): void;
|
|
3399
3422
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -734,8 +734,9 @@ type AccountPlanType = (typeof AccountPlan)[keyof typeof AccountPlan];
|
|
|
734
734
|
* "unlimited" — so no consumer needs an "is it bounded?" branch. A cap of `0`
|
|
735
735
|
* means the plan does not have the feature at all; a cap of `N` bounds
|
|
736
736
|
* creation, and what an account already holds above a cap stays until a plan
|
|
737
|
-
* TRANSITION fits it
|
|
738
|
-
*
|
|
737
|
+
* TRANSITION fits it: excess domains are paused, newest first, and members
|
|
738
|
+
* are paused together while the account holds more than its cap. Deployments
|
|
739
|
+
* never pause; above their cap they only block creation.
|
|
739
740
|
*
|
|
740
741
|
* A count is an aggregate over a collection, so it lives on the summary
|
|
741
742
|
* resource that owns the collection: `GET /account` for one caller, `GET
|
|
@@ -941,10 +942,12 @@ interface Account {
|
|
|
941
942
|
* from where the account stands. It excludes the plan and cadence the
|
|
942
943
|
* account already holds and the one move the door refuses, a dearer tier
|
|
943
944
|
* at a shorter interval (an immediate move would mint a proration credit,
|
|
944
|
-
* a deferred one would make a customer asking for more wait a year).
|
|
945
|
-
*
|
|
946
|
-
*
|
|
947
|
-
*
|
|
945
|
+
* a deferred one would make a customer asking for more wait a year). A
|
|
946
|
+
* cheaper tier the account does not yet fit is listed with what stands in
|
|
947
|
+
* the way ({@link PlanDestination.excess}). The rule's owner is the
|
|
948
|
+
* platform's plan table; a console feeds these rows into its own move
|
|
949
|
+
* model instead of restating it. Additive: absent on responses that
|
|
950
|
+
* predate it, and a client then derives as it did.
|
|
948
951
|
*/
|
|
949
952
|
readonly destinations?: PlanDestination[];
|
|
950
953
|
}
|
|
@@ -956,6 +959,15 @@ interface Account {
|
|
|
956
959
|
interface PlanDestination {
|
|
957
960
|
readonly plan: AccountPlanType;
|
|
958
961
|
readonly intervals: BillingInterval[];
|
|
962
|
+
/**
|
|
963
|
+
* What the account holds beyond what this plan allows: per kind, how many
|
|
964
|
+
* to remove. Present only on a cheaper tier the account does not fit, and
|
|
965
|
+
* then never empty. A move down a tier pauses nothing, so the change door
|
|
966
|
+
* refuses it until the account fits: the owner removes the excess, and the
|
|
967
|
+
* field is gone from the next read. Which kinds count is the platform's to
|
|
968
|
+
* decide; a client renders the keys it is given.
|
|
969
|
+
*/
|
|
970
|
+
readonly excess?: Partial<Caps>;
|
|
959
971
|
}
|
|
960
972
|
/**
|
|
961
973
|
* Acknowledgement of `DELETE /account` (202). Termination is asynchronous —
|
|
@@ -2484,6 +2496,11 @@ interface PlansResponse {
|
|
|
2484
2496
|
* consent), and a billed account moving down gets a Stripe Subscription
|
|
2485
2497
|
* Schedule that applies the change at period end. The answer says which
|
|
2486
2498
|
* happened ({@link PlanChangeResponse}).
|
|
2499
|
+
*
|
|
2500
|
+
* A move down a tier is refused while the account holds more than the
|
|
2501
|
+
* destination allows (400, `details.excess` in {@link PlanDestination.excess}'s
|
|
2502
|
+
* shape): nothing is paused for a change the owner chose, so the account fits
|
|
2503
|
+
* first.
|
|
2487
2504
|
*/
|
|
2488
2505
|
interface PlanChangeRequest {
|
|
2489
2506
|
readonly plan: AccountPlanType;
|
|
@@ -2901,8 +2918,11 @@ declare function validatePassword(value: unknown): string | undefined;
|
|
|
2901
2918
|
interface DeploymentOptions extends DeploymentUploadOptions {
|
|
2902
2919
|
/**
|
|
2903
2920
|
* An AbortSignal to allow cancellation of the deploy operation. The one
|
|
2904
|
-
* cancellation mechanism
|
|
2905
|
-
*
|
|
2921
|
+
* cancellation mechanism: it reaches every request the deploy makes (the
|
|
2922
|
+
* limits it validates against, the SPA question and the upload itself),
|
|
2923
|
+
* and aborting it rejects the deploy with a typed `Cancelled` error
|
|
2924
|
+
* wherever it stands. A deploy the server had already committed stays
|
|
2925
|
+
* committed. Request timeouts are a client concern
|
|
2906
2926
|
* (`ShipClientOptions.timeout`), not a per-deploy one.
|
|
2907
2927
|
*/
|
|
2908
2928
|
signal?: AbortSignal;
|
|
@@ -3391,9 +3411,12 @@ declare abstract class Ship$1 {
|
|
|
3391
3411
|
/**
|
|
3392
3412
|
* Get the platform limits the server states now (max file size, file count,
|
|
3393
3413
|
* total size, and the blocked extensions). Asked every time and never held,
|
|
3394
|
-
* since a plan move or an operator's grant changes them.
|
|
3414
|
+
* since a plan move or an operator's grant changes them. A `signal` aborts
|
|
3415
|
+
* the request, rejecting with the typed `Cancelled` error.
|
|
3395
3416
|
*/
|
|
3396
|
-
getLimits(
|
|
3417
|
+
getLimits(options?: {
|
|
3418
|
+
signal?: AbortSignal;
|
|
3419
|
+
}): Promise<PlatformLimits>;
|
|
3397
3420
|
on<K extends keyof ShipEvents>(event: K, handler: (...args: ShipEvents[K]) => void): void;
|
|
3398
3421
|
off<K extends keyof ShipEvents>(event: K, handler: (...args: ShipEvents[K]) => void): void;
|
|
3399
3422
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var rt=Object.defineProperty;var A=(e,t)=>()=>(e&&(t=e(e=0)),t);var ot=(e,t)=>{for(var n in t)rt(e,n,{get:t[n],enumerable:!0})};function on(e){if(!e||typeof e!="string")return;let t=e.trim().toLowerCase();return Object.values(it).includes(t)?t:void 0}function Ae(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 ln(e){return e.name?.trim()||e.email}function cn(e){return e.name?.trim().split(" ")[0]||e.email}function ct(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 pt(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 Se(e,t){let n=pt(e);return n===null?!1:Array.isArray(t)?t.includes(n):t.has(n)}function De(e){return dt.test(e)}function M(e){return e.replace(/\\/g,"/").split("/").filter(Boolean).some(n=>Z.has(n))}function mt(e){return e.startsWith(Re.PREFIX)?R.API_KEY:e.startsWith(Ie.PREFIX)?R.DEPLOY_TOKEN:e.startsWith(Ne.PREFIX)?R.OAUTH:R.OPAQUE}function hn(e){return e.slice(0,J.length).toLowerCase()!==J?null:e.slice(J.length)||null}function Oe(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 ee(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 ft(e){ee(e,Re,"API key")}function ht(e){ee(e,Ie,"Deploy token")}function yt(e){ee(e,Ne,"OAuth access token")}function te(e){switch(mt(e)){case R.API_KEY:ft(e);return;case R.DEPLOY_TOKEN:ht(e);return;case R.OAUTH:yt(e);return;case R.OPAQUE:if(!e)throw s.validation("Token must be a non-empty string")}}function be(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 En(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 gn(e){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(e)}function ne(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 At(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"),settingsAfterBilling:()=>n(`/settings?${Ee("portal")}`),upgrade:r=>n(r?`/upgrade/${r}`:"/upgrade"),success:()=>n("/success"),successAfterCheckout:()=>n(`/success?${Ee("checkout")}`),apiKey:()=>n("/api-key")}}function An(e){let t=new URLSearchParams(e);for(let[n,[r,o]]of Object.entries(Pe))if(t.get(r)===o)return n;return null}function k(e){let t=e.split(/[?#]/)[0].toLowerCase(),[n="",r=""]=t.split("/").filter(Boolean);return St(n)?{kind:"door",door:n}:n===Tt?{kind:"admin"}:n===""||Te(n)?{kind:"account",account:null,section:n===""?null:n}:{kind:"account",account:n,section:Te(r)?r:null}}function Sn(e){let t=k(e);return t.kind==="account"?t.account:null}function Dn(e){return Dt(e)?"claim":Rt(e)?"invite":It(e)?"upgrade":null}function Nt(e){let t=Math.round(e/60);if(!(t>=1))return"less than a minute";if(t<120)return Q(t,"minute");let n=Math.round(e/3600);return n<48?Q(n,"hour"):Q(Math.round(e/86400),"day")}function Ln(e,t=Date.now()/1e3){let n=e-t;return n>0?Nt(n):null}function Q(e,t){return`${e} ${t}${e===1?"":"s"}`}function x(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 xe(e,t){return e.endsWith(`.${t}`)}function bn(e,t){return!xe(e,t)}function Pn(e,t){return xe(e,t)?e.slice(0,-(t.length+1)):null}function xn(e){return`https://${e}`}function _n(e){return`https://${e}`}function wn(e){return!e||e.length===0?null:JSON.stringify(e)}function Cn(e){if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function we(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>b.COMMAND_MAX_LENGTH)throw s.validation(`Build command must be between 1 and ${b.COMMAND_MAX_LENGTH} characters`);if(/[\x00-\x1f\x7f]/.test(t))throw s.validation("Build command must be a single line");return t}function Ce(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>b.OUTPUT_DIR_MAX_LENGTH)throw s.validation(`Output folder must be between 1 and ${b.OUTPUT_DIR_MAX_LENGTH} characters`);if(!b.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 oe(e){if(e==null)return;if(typeof e!="string")throw s.validation("Password must be a string");let t=e.trim();if(t.length<v.MIN_LENGTH||t.length>v.MAX_LENGTH)throw s.validation(`Password must be between ${v.MIN_LENGTH} and ${v.MAX_LENGTH} characters`);return t}var en,it,tn,nn,rn,N,sn,an,m,E,pn,d,st,Y,at,lt,s,ut,un,dt,Z,dn,mn,W,Re,Ie,Ne,O,fn,R,J,yn,S,Le,U,C,Et,gt,Tt,Pe,Ee,ge,Tn,St,Te,Dt,Rt,It,re,P,Rn,In,Nn,On,h,I,_e,b,v,f=A(()=>{"use strict";en={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},it={WEB:"web",SDK:"sdk",CLI:"cli",MCP:"mcp",GIT:"git",N8N:"n8n",GPT:"gpt",VSC:"vsc",CLD:"cld",CRS:"crs",GMN:"gmn",API:"api"},tn={LIVE:"live",UNLINKED:"unlinked",UNVERIFIED:"unverified",PAUSED:"paused"},nn={PENDING:"pending",PARTIAL:"partial",VERIFIED:"verified"},rn="troubleshooting",N={HEADER:"Idempotency-Key",MAX_LENGTH:256,WINDOW_SECONDS:1440*60};sn={FREE:"free",PRO:"pro",TEAM:"team",SCALE:"scale",SPONSORED:"sponsored"},an={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"},pn={PATH:"path",CONTENT:"content",ENCODING:"encoding",DEFAULT_ENCODING:"utf-8",ENCODINGS:["utf-8","base64"]},d={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"},st=new Set([d.Network,d.Timeout,d.Cancelled,d.File,d.Config]),Y={client:new Set([d.Build,d.Business,d.Cancelled,d.Config,d.File,d.Forbidden,d.NotFound,d.RateLimit,d.Validation]),network:new Set([d.Network,d.Timeout]),auth:new Set([d.Authentication])},at=new Set(Object.values(d).filter(e=>!st.has(e))),lt=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===d.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 u=await t.json();if(u&&typeof u=="object"){let c=u;typeof c.message=="string"?r=c.message:typeof c.error=="string"&&(r=c.error),o=c.details,typeof c.error=="string"&&at.has(c.error)&&(i=c.error)}}else{let u=(await t.text()).trim();u&&!u.startsWith("<")&&u.length<=lt&&(r=u)}}catch{}let l=t.headers.get("retry-after");if(l!==null){let a=l.trim(),u=/^\d+$/.test(a)?Number(a):Math.ceil((Date.parse(a)-Date.now())/1e3);if(Number.isFinite(u)&&u>=0){let c=o&&typeof o=="object"?o:{};c.retryAfter===void 0&&(o={...c,retryAfter:u})}}r=r||`${n||"Request"} failed with status ${t.status}`;let p=i??(t.status===401?d.Authentication:t.status===403?d.Forbidden:t.status===429?d.RateLimit:d.Api);return new e(p,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?ct(t)?e.network(`${r} failed: ${t.message}`,{cause:t}):new e(d.Api,`${r} failed: ${t.message}`):new e(d.Api,`${r} failed: Unknown error`)}static validation(t,n){return new e(d.Validation,t,400,n)}static notFound(t,n){let r=n?`${t} ${n} not found`:`${t} not found`;return new e(d.NotFound,r,404)}static forbidden(t,n){return new e(d.Forbidden,t,403,n)}static rateLimit(t="Too many requests",n){return new e(d.RateLimit,t,429,n)}static authentication(t="Authentication required",n){return new e(d.Authentication,t,401,n)}static business(t,n=400,r){return new e(d.Business,t,n,r)}static network(t,n){return new e(d.Network,t,void 0,n)}static timeout(t,n){return new e(d.Timeout,t,void 0,n)}static cancelled(t,n){return new e(d.Cancelled,t,void 0,n)}static file(t,n){return new e(d.File,t,void 0,n)}static config(t,n){return new e(d.Config,t,void 0,n)}static api(t,n=500,r){return new e(d.Api,t,n,r)}static maintenance(t,n){return new e(d.Maintenance,t,503,n)}static build(t,n){return new e(d.Build,t,422,n)}isClientError(){return Y.client.has(this.type)?!0:this.status!==void 0&&this.status>=400&&this.status<500}isNetworkError(){return Y.network.has(this.type)}isAuthError(){return Y.auth.has(this.type)}isType(t){return this.type===t}};ut=["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"],un=ut.map(e=>`.${e}`).join(","),dt=/[\x00-\x1f\x7f#?%\\<>"]/;Z=new Set(["node_modules","package.json"]);dn="/auth",mn="signing-in",W={SESSION:"session",API_KEY:"apiKey",TOKEN:"token",AGENT:"agent",OAUTH:"oauth",SYSTEM:"system"},Re={PREFIX:"ship-",HEX_LENGTH:32,TOTAL_LENGTH:37,HINT_LENGTH:4},Ie={PREFIX:"deploy-",HEX_LENGTH:32,TOTAL_LENGTH:39},Ne={PREFIX:"oauth-",HEX_LENGTH:32,TOTAL_LENGTH:38},O={HEADER:"X-Caller",MAX_LENGTH:128,PATTERN:/^[a-zA-Z0-9._-]+$/},fn="X-Account",R={API_KEY:W.API_KEY,DEPLOY_TOKEN:W.TOKEN,OAUTH:W.OAUTH,OPAQUE:"opaque"};J="bearer ";yn={ACCOUNT_READ:"account:read",DEPLOYMENTS_READ:"deployments:read",DEPLOYMENTS_WRITE:"deployments:write",DOMAINS_READ:"domains:read",DOMAINS_WRITE:"domains:write"},S="ship.json",Le={rewrites:[{source:"/(.*)",destination:"/index.html"}]},U={INDEX_FILE:"index.html",MAX_INDEX_BYTES:100*1024};C={MIN_SECONDS:1,MAX_SECONDS:365*24*60*60};Et={new:{owner:!1},deployments:{owner:!1},domains:{owner:!1},settings:{owner:!1},upgrade:{owner:!0},success:{owner:!1},"api-key":{owner:!0}},gt=["login","register","logout","invitations","claim","consent"],Tt="admin",Pe={checkout:["upgrading","true"],portal:["billing","returned"]},Ee=e=>Pe[e].join("="),ge=(e,t)=>t?`${e}?next=${encodeURIComponent(t)}`:e;Tn={login:e=>ge("/login",e),register:e=>ge("/register",e),logout:()=>"/logout",invitation:e=>`/invitations/${e}`,claim:e=>`/claim/${e}`,consent:()=>"/consent"};St=e=>gt.includes(e),Te=e=>Object.hasOwn(Et,e);Dt=e=>{let t=k(e);return t.kind==="door"&&t.door==="claim"},Rt=e=>{let t=k(e);return t.kind==="door"&&t.door==="invitations"},It=e=>{let t=k(e);return t.kind==="account"&&t.section==="upgrade"};re="https://api.shipstatic.com",P={TOKEN:"SHIP_TOKEN",API_URL:"SHIP_API_URL"},Rn="SHIP_VIA",In=`https://my.shipstatic.com${At().apiKey()}`,Nn=4320*60;On=["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:25,MAX_COUNT:10,SEPARATORS:"._-"},_e=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/;b={COMMAND_MAX_LENGTH:200,OUTPUT_DIR_MAX_LENGTH:100,OUTPUT_DIR_PATTERN:/^[A-Za-z0-9._-]+(\/[A-Za-z0-9._-]+)*$/};v={MIN_LENGTH:6,MAX_LENGTH:128}});async function vt(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 Ft(e){let{createHash:t}=await import("crypto"),n=t("md5");return n.update(e),{md5:n.digest("hex")}}async function Mt(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 G(e){if(e instanceof Blob)return vt(e);if(typeof Buffer<"u"&&Buffer.isBuffer(e))return Ft(e);if(typeof e=="string")return Mt(e);throw s.business("Invalid input for MD5 calculation")}var B=A(()=>{"use strict";f()});function or(e){se=e}function Ht(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function L(){return se||Ht()}var se,w=A(()=>{"use strict";se=null});function je(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 K(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var ae=A(()=>{"use strict"});function qe(e,t={}){if(t.flatten===!1)return e.map(r=>({path:K(r),name:le(r)}));let n=Vt(e);return e.map(r=>{let o=K(r);if(n){let i=n.endsWith("/")?n:`${n}/`;o.startsWith(i)&&(o=o.substring(i.length))}return o||(o=le(r)),{path:o,name:le(r)}})}function Vt(e){if(!e.length)return"";let n=e.map(i=>K(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 le(e){return e.split(/[/\\]/).pop()||e}var ce=A(()=>{"use strict";ae()});function j(e,t){return zt.find(n=>n.broken(e,t))}var zt,ue=A(()=>{"use strict";f();de();zt=[{name:"name",broken:({path:e})=>!pe(e).valid,sentence:({path:e})=>pe(e).reason??"Invalid file name"},{name:"extension",broken:({path:e},t)=>Se(e,t.blockedExtensions??[]),sentence:({path:e})=>`File extension not allowed: "${e}"`},{name:"fileSize",broken:({size:e},t)=>e>t.maxFileSize,sentence:({path:e},t)=>`File "${e}" too large. Maximum ${x(t.maxFileSize)} allowed`},{name:"totalSize",broken:({totalSize:e},t)=>e>t.maxTotalSize,sentence:({totalSize:e},t)=>`Total upload size too large. ${x(e)} exceeds maximum of ${x(t.maxTotalSize)}`}]});function pe(e){if(De(e))return{valid:!1,reason:"File name contains unsafe characters"};if(e.startsWith(" ")||e.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(e.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let t=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,n=e.split("/").pop()||e;return t.test(n)?{valid:!1,reason:"File name uses a reserved system name"}:e.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function Rr(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 \u2014 deploy your build output (dist/, build/, out/), not the project folder"}),{files:e.map(u=>({...u,status:h.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:n,warnings:[],canDeploy:!1};if(e.length>t.maxFilesCount){let a={file:`(${e.length} files)`,message:`File count (${e.length}) exceeds limit of ${t.maxFilesCount}`};return n.push(a),{files:e.map(u=>({...u,status:h.VALIDATION_FAILED,statusMessage:a.message})),validFiles:[],errors:n,warnings:[],canDeploy:!1}}let i=0;for(let a of e){let u=h.READY,c="Ready for upload";if(a.status===h.PROCESSING_ERROR)u=h.VALIDATION_FAILED,c=a.statusMessage||"File failed during processing",n.push({file:a.name,message:c});else if(a.size===0){u=h.EXCLUDED,c="File is empty (0 bytes) and cannot be deployed due to storage limitations",r.push({file:a.name,message:c}),o.push({...a,status:u,statusMessage:c});continue}else if(a.size<0)u=h.VALIDATION_FAILED,c="File size must be positive",n.push({file:a.name,message:c});else if(!a.name||a.name.trim().length===0)u=h.VALIDATION_FAILED,c="File name cannot be empty",n.push({file:a.name||"(empty)",message:c});else if(a.name.includes("\0"))u=h.VALIDATION_FAILED,c="File 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},D=j(y,t);D?(u=h.VALIDATION_FAILED,c=D.sentence(y,t),n.push({file:D.name==="totalSize"?`(${e.length} files)`:a.name,message:c})):i=y.totalSize}o.push({...a,status:u,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 Kt(e){return e.filter(t=>t.status===h.READY)}function Ir(e){return Kt(e).length>0}var de=A(()=>{"use strict";f();ue();f()});import{isJunk as jt}from"junk";function Xe(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(jt(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(qt.some(p=>l.toLowerCase()===p.toLowerCase()))return!1;return!0})}var qt,me=A(()=>{"use strict";f();qt=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function Ye(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 We(e,t){let n=j(e,t);if(n)throw s.business(n.sentence(e,t))}var fe=A(()=>{"use strict";f();ue()});async function Je(e,t={},n){let r=!!(t.build||t.prerender),o=qe(e.map(c=>c.path),{flatten:t.pathDetect!==!1}).map(c=>c.path),i=new Set(Xe(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:Xt(n),a=[],u=0;for(let{source:c,deployPath:y}of l){if(p&&Ye(y,c.origin),c.size===0)continue;p&&(u+=c.size,We({path:y,size:c.size,totalSize:u},p));let D=await c.read(),{md5:q}=await G(D);a.push({path:y,content:D,size:c.size,md5:q})}if(p&&a.length>p.maxFilesCount)throw s.business(`Too many files to deploy. Maximum allowed is ${p.maxFilesCount} files.`);return a}function Xt(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 Qe=A(()=>{"use strict";f();ce();me();B();fe()});var tt={};ot(tt,{processFilesForNode:()=>et});import*as T from"fs";import*as g from"path";function Ze(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(...Ze(i,t)):l.isFile()&&n.push({absPath:i,size:l.size})}return n}async function Yt(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 Wt(e){for(let t of e){let n=g.resolve(t);try{if(T.statSync(n).isDirectory()){let r=T.readdirSync(n).find(o=>Z.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 et(e,t={},n){if(L()!=="node")throw s.business("processFilesForNode can only be called in Node.js environment.");Wt(e);let r=e.flatMap(p=>{let a=g.resolve(p);try{let u=T.statSync(a);return u.isDirectory()?Ze(a):[{absPath:a,size:u.size}]}catch{throw s.file(`Path does not exist: ${p}`,{filePath:p})}}),o=new Map(r.map(p=>[p.absPath,p.size])),i=je(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:Jt(p,i),origin:p,size:a,read:()=>Yt(p)}));return Je(l,t,n)}function Jt(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 he=A(()=>{"use strict";f();Qe();w();ae()});f();f();f();var $=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 Lt=3e4,Ot=2,bt=300,Pt=2e3,xt=new Set([500,502,503,504]);function _t(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 ve=3e5,wt=3e5,Ct=ve+wt,H=class extends ${constructor(n){super();this.globalHeaders={};this.apiUrl=n.apiUrl||re,this.getAuthHeadersCallback=n.getAuthHeaders,this.session=n.session??!1,this.caller=n.caller,this.timeout=n.timeout??Lt,this.maxRetries=Math.max(0,n.maxRetries??Ot),this.fetch=n.fetch??globalThis.fetch.bind(globalThis),this.deploy={endpoint:n.deployEndpoint||m.DEPLOYMENTS,timeout:n.timeout??ve,buildTimeout:n.timeout??Ct}}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 u=Math.min(Pt,bt*2**l);try{await _t(Math.random()*u,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(d.Maintenance)||n.isType(d.Cancelled)||!(n.isNetworkError()||n.status!==void 0&&xt.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 u={...r,headers:p,credentials:this.session&&!p.Authorization?"include":void 0,signal:a.signal};this.emit("request",n,u);let c=await this.fetch(n,u);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?{[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 Fe(e,t={}){let{labels:n,via:r,password:o,ttl:i,flags:l,captcha:p}=t,a=new FormData,u=[];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"})),u.push(c.md5)}return a.append(E.CHECKSUMS,JSON.stringify(u)),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();B();async function Ut(){let e=JSON.stringify(Le,null,2),t;typeof Buffer<"u"?t=Buffer.from(e,"utf-8"):t=new Blob([e],{type:"application/json"});let{md5:n}=await G(t);return{path:S,content:t,size:e.length,md5:n}}async function kt(e,t){let n=e.find(l=>l.path===U.INDEX_FILE||l.path===`/${U.INDEX_FILE}`);if(!n||n.size>U.MAX_INDEX_BYTES)return!1;let r;if(typeof Buffer<"u"&&Buffer.isBuffer(n.content))r=n.content.toString("utf-8");else if(typeof Blob<"u"&&n.content instanceof Blob)r=await n.content.text();else if(typeof File<"u"&&n.content instanceof File)r=await n.content.text();else return!1;let o={files:e.map(l=>l.path),index:r};return(await t.request(m.SPA_CHECK,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)},"SPA check")).isSPA}async function Me(e,t,n){if(n.spaDetect===!1||n.spa||n.build||n.prerender||e.some(r=>r.path===S))return e;try{if(await kt(e,t)){let o=await Ut();return[...e,o]}}catch{}return e}f();f();function _(e){if(e==null)return;if(e.length===0)return e;if(e.length>I.MAX_COUNT)throw s.validation(`Maximum ${I.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<I.MIN_LENGTH)throw s.validation(`Labels must be at least ${I.MIN_LENGTH} characters long`);if(i.length>I.MAX_LENGTH)throw s.validation(`Labels must be no more than ${I.MAX_LENGTH} characters long`);if(!_e.test(i))throw s.validation(`Labels must start and end with alphanumeric characters, with optional separators (${I.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 Ue(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");Oe(r)}var V={"Content-Type":"application/json"},$t="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 ke(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 Me(l,i,o);if(!p.length)throw s.business("No files to deploy");for(let X of p)if(!X.md5)throw s.file(`MD5 checksum missing for file: ${X.path}`,{filePath:X.path});oe(o.password);let a=ne(o.ttl),u=Ae(o.idempotencyKey),c=_(o.labels);await Ue(p);let y=we(o.buildCommand),D=Ce(o.outputDir),q=o.build||o.prerender||o.spa?{build:o.build,prerender:o.prerender,spa:o.spa,buildCommand:y,outputDir:D}:void 0,nt=await Fe(p,{labels:c,via:o.via??$t,password:o.password,ttl:a,flags:q,captcha:o.captcha});return i.request(i.deploy.endpoint,{method:"POST",body:nt,...u?{headers:{[N.HEADER]:u}}:{},signal:o.signal||null},"Deploy",o.build||o.prerender?i.deploy.buildTimeout:i.deploy.timeout)},list:async r=>t().request(`${m.DEPLOYMENTS}${ie(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:V,body:JSON.stringify({labels:_(o.labels)})},"Update deployment labels"),delete:async r=>t().request(m.DEPLOYMENT(encodeURIComponent(r)),{method:"DELETE"},"Delete deployment")}}function $e(e){let{getApi:t}=e;return{set:async(n,r={})=>{let o=_(r.labels),i={};r.deployment&&(i.deployment=r.deployment),o!==void 0&&(i.labels=o);let{data:l,status:p}=await t().requestWithStatus(m.DOMAIN(encodeURIComponent(n)),{method:"PUT",headers:V,body:JSON.stringify(i)},"Set domain");return{...l,isCreate:p===201}},list:async n=>t().request(`${m.DOMAINS}${ie(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:V,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 He(e){let{getApi:t}=e;return{get:async()=>t().request(m.ACCOUNT,{method:"GET"},"Get account")}}function Ge(e){let{getApi:t}=e;return{create:async(n={})=>{let r=ne(n.ttl),o=_(n.labels),i={};return r!==void 0&&(i.ttl=r),o!==void 0&&(i.labels=o),t().request(m.TOKENS,{method:"POST",headers:V,body:JSON.stringify(i)},"Create token")},list:async n=>t().request(`${m.TOKENS}${ie(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&&be(t.caller),t.token&&t.session)throw s.config("Provide either `token` or `session`, not both.");typeof t.token=="string"?(te(t.token),this.credential=t.token):t.token&&(this.credential=t.token),this.http=new H({...t,getAuthHeaders:()=>this.getAuthHeaders()});let n={getApi:()=>this.http};this.deployments=ke({...n,processInput:async(r,o)=>this.processInput(r,o,await this.getLimits())}),this.domains=$e(n),this.account=He(n),this.tokens=Ge(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(){return this.http.request(m.LIMITS,{method:"GET"},"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.");te(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}`}}};w();f();import{z as ze}from"zod";import{z as Be}from"zod";var Ve={apiUrl:Be.string().url().optional(),token:Be.string().min(1).optional()};w();var Gt=ze.object(Ve).strict(),Bt={apiUrl:P.API_URL,token:P.TOKEN};function Ke(){if(L()!=="node")return{};let e={apiUrl:process.env[P.API_URL]||void 0,token:process.env[P.TOKEN]||void 0};try{return Gt.parse(e)}catch(t){if(t instanceof ze.ZodError){let n=t.issues[0],r=n.path[0],o=(r&&Bt[r])??"SHIP environment configuration";throw s.config(`Invalid ${o}: ${n.message}`)}throw s.config("Invalid environment configuration")}}f();f();ce();w();de();me();B();fe();function Cr(e,t,n,r=!0){let o=e===1?t:n;return r?`${e} ${o}`:o}he();var ye=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=Ke();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(()=>(he(),tt));return i(o,n,r)}},Qt=ye;export{fn as ACCOUNT_HEADER,Re as API_KEY,m as API_PATHS,dn as AUTH_BASE_PATH,sn as AccountPlan,an as AccountRefusal,H as ApiHttp,W as AuthMethod,b as BUILD_SETTINGS,O as CALLER,re as DEFAULT_API,S as DEPLOYMENT_CONFIG_FILENAME,E as DEPLOY_FIELDS,pn as DEPLOY_FILE_GRAMMAR,Ie as DEPLOY_TOKEN,en as DeploymentStatus,it as DeploymentVia,tn as DomainStatus,nn as DomainVerification,d as ErrorType,h as FILE_VALIDATION_STATUS,h as FileValidationStatus,N as IDEMPOTENCY_KEY_CONSTRAINTS,qt as JUNK_DIRECTORIES,I as LABEL_CONSTRAINTS,_e as LABEL_PATTERN,In as MY_API_KEY_URL,Ne as OAUTH_TOKEN,yn as OAuthScope,v as PASSWORD_CONSTRAINTS,Nn as PUBLIC_DEPLOYMENT_TTL_SECONDS,Et as SECTIONS,rn as SETUP_TROUBLESHOOTING_ANCHOR,P as SHIP_ENV,Rn as SHIP_VIA_ENV,mn as SIGN_IN_RETURN_PARAM,U as SPA_CHECK_CONSTRAINTS,Le as SPA_DEFAULT_CONFIG,ye as Ship,s as ShipError,C as TTL_CONSTRAINTS,R as TokenKind,Z as UNBUILT_PROJECT_MARKERS,dt as UNSAFE_FILENAME_CHARS,On as USER_VISIBLE_EVENTS,un as WEB_FILE_ACCEPT,or as __setTestEnvironment,Sn as accountOfPath,Ir as allValidFilesReady,Oe as assertShipJsonSyntax,An as billingReturnOf,G as calculateMD5,mt as classifyToken,At as consolePaths,He as createAccountResource,ke as createDeploymentResource,$e as createDomainResource,Ge as createTokenResource,Qt as default,Cn as deserializeLabels,Tn as doors,Dn as errandOf,Pn as extractSubdomain,Xe as filterJunk,Nt as formatDuration,x as formatFileSize,Ln as formatTimeRemaining,xn as generateDeploymentUrl,_n as generateDomainUrl,L as getENV,Kt as getValidFiles,M as hasUnbuiltMarker,De as hasUnsafeChars,Se as isBlockedExtension,Dt as isClaimPath,bn as isCustomDomain,gn as isDeployment,Rt as isInvitationPath,xe as isPlatformDomain,F as isShipError,It as isUpgradePath,on as normalizeVia,qe as optimizeDeployPaths,ln as personName,cn as personShortName,Cr as pluralize,et as processFilesForNode,hn as readBearerValue,wn as serializeLabels,ft as validateApiKey,En as validateApiUrl,we as validateBuildCommand,be as validateCaller,We as validateDeployFile,Ye as validateDeployPath,ht as validateDeployToken,pe as validateFileName,Rr as validateFiles,Ae as validateIdempotencyKey,yt as validateOAuthToken,Ce as validateOutputDir,oe as validatePassword,te as validateToken,ne as validateTtl};
|
|
1
|
+
var rt=Object.defineProperty;var A=(e,t)=>()=>(e&&(t=e(e=0)),t);var ot=(e,t)=>{for(var n in t)rt(e,n,{get:t[n],enumerable:!0})};function on(e){if(!e||typeof e!="string")return;let t=e.trim().toLowerCase();return Object.values(it).includes(t)?t:void 0}function Ae(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 ln(e){return e.name?.trim()||e.email}function cn(e){return e.name?.trim().split(" ")[0]||e.email}function ct(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 pt(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 Se(e,t){let n=pt(e);return n===null?!1:Array.isArray(t)?t.includes(n):t.has(n)}function De(e){return dt.test(e)}function M(e){return e.replace(/\\/g,"/").split("/").filter(Boolean).some(n=>Z.has(n))}function mt(e){return e.startsWith(Re.PREFIX)?R.API_KEY:e.startsWith(Ie.PREFIX)?R.DEPLOY_TOKEN:e.startsWith(Ne.PREFIX)?R.OAUTH:R.OPAQUE}function hn(e){return e.slice(0,J.length).toLowerCase()!==J?null:e.slice(J.length)||null}function be(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 ee(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 ft(e){ee(e,Re,"API key")}function ht(e){ee(e,Ie,"Deploy token")}function yt(e){ee(e,Ne,"OAuth access token")}function te(e){switch(mt(e)){case R.API_KEY:ft(e);return;case R.DEPLOY_TOKEN:ht(e);return;case R.OAUTH:yt(e);return;case R.OPAQUE:if(!e)throw s.validation("Token must be a non-empty string")}}function Oe(e){if(!e||e.length>b.MAX_LENGTH||!b.PATTERN.test(e))throw s.validation(`Caller must be 1-${b.MAX_LENGTH} characters: letters, digits, dots, underscores, or hyphens`)}function En(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 gn(e){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(e)}function ne(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 At(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"),settingsAfterBilling:()=>n(`/settings?${Ee("portal")}`),upgrade:r=>n(r?`/upgrade/${r}`:"/upgrade"),success:()=>n("/success"),successAfterCheckout:()=>n(`/success?${Ee("checkout")}`),apiKey:()=>n("/api-key")}}function An(e){let t=new URLSearchParams(e);for(let[n,[r,o]]of Object.entries(Pe))if(t.get(r)===o)return n;return null}function k(e){let t=e.split(/[?#]/)[0].toLowerCase(),[n="",r=""]=t.split("/").filter(Boolean);return St(n)?{kind:"door",door:n}:n===Tt?{kind:"admin"}:n===""||Te(n)?{kind:"account",account:null,section:n===""?null:n}:{kind:"account",account:n,section:Te(r)?r:null}}function Sn(e){let t=k(e);return t.kind==="account"?t.account:null}function Dn(e){return Dt(e)?"claim":Rt(e)?"invite":It(e)?"upgrade":null}function Nt(e){let t=Math.round(e/60);if(!(t>=1))return"less than a minute";if(t<120)return Q(t,"minute");let n=Math.round(e/3600);return n<48?Q(n,"hour"):Q(Math.round(e/86400),"day")}function Ln(e,t=Date.now()/1e3){let n=e-t;return n>0?Nt(n):null}function Q(e,t){return`${e} ${t}${e===1?"":"s"}`}function x(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 xe(e,t){return e.endsWith(`.${t}`)}function On(e,t){return!xe(e,t)}function Pn(e,t){return xe(e,t)?e.slice(0,-(t.length+1)):null}function xn(e){return`https://${e}`}function _n(e){return`https://${e}`}function wn(e){return!e||e.length===0?null:JSON.stringify(e)}function Cn(e){if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function we(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>O.COMMAND_MAX_LENGTH)throw s.validation(`Build command must be between 1 and ${O.COMMAND_MAX_LENGTH} characters`);if(/[\x00-\x1f\x7f]/.test(t))throw s.validation("Build command must be a single line");return t}function Ce(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>O.OUTPUT_DIR_MAX_LENGTH)throw s.validation(`Output folder must be between 1 and ${O.OUTPUT_DIR_MAX_LENGTH} characters`);if(!O.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 oe(e){if(e==null)return;if(typeof e!="string")throw s.validation("Password must be a string");let t=e.trim();if(t.length<v.MIN_LENGTH||t.length>v.MAX_LENGTH)throw s.validation(`Password must be between ${v.MIN_LENGTH} and ${v.MAX_LENGTH} characters`);return t}var en,it,tn,nn,rn,N,sn,an,m,E,pn,d,st,Y,at,lt,s,ut,un,dt,Z,dn,mn,W,Re,Ie,Ne,b,fn,R,J,yn,S,Le,U,C,Et,gt,Tt,Pe,Ee,ge,Tn,St,Te,Dt,Rt,It,re,P,Rn,In,Nn,bn,h,I,_e,O,v,f=A(()=>{"use strict";en={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},it={WEB:"web",SDK:"sdk",CLI:"cli",MCP:"mcp",GIT:"git",N8N:"n8n",GPT:"gpt",VSC:"vsc",CLD:"cld",CRS:"crs",GMN:"gmn",API:"api"},tn={LIVE:"live",UNLINKED:"unlinked",UNVERIFIED:"unverified",PAUSED:"paused"},nn={PENDING:"pending",PARTIAL:"partial",VERIFIED:"verified"},rn="troubleshooting",N={HEADER:"Idempotency-Key",MAX_LENGTH:256,WINDOW_SECONDS:1440*60};sn={FREE:"free",PRO:"pro",TEAM:"team",SCALE:"scale",SPONSORED:"sponsored"},an={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"},pn={PATH:"path",CONTENT:"content",ENCODING:"encoding",DEFAULT_ENCODING:"utf-8",ENCODINGS:["utf-8","base64"]},d={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"},st=new Set([d.Network,d.Timeout,d.Cancelled,d.File,d.Config]),Y={client:new Set([d.Build,d.Business,d.Cancelled,d.Config,d.File,d.Forbidden,d.NotFound,d.RateLimit,d.Validation]),network:new Set([d.Network,d.Timeout]),auth:new Set([d.Authentication])},at=new Set(Object.values(d).filter(e=>!st.has(e))),lt=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===d.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 u=await t.json();if(u&&typeof u=="object"){let c=u;typeof c.message=="string"?r=c.message:typeof c.error=="string"&&(r=c.error),o=c.details,typeof c.error=="string"&&at.has(c.error)&&(i=c.error)}}else{let u=(await t.text()).trim();u&&!u.startsWith("<")&&u.length<=lt&&(r=u)}}catch{}let l=t.headers.get("retry-after");if(l!==null){let a=l.trim(),u=/^\d+$/.test(a)?Number(a):Math.ceil((Date.parse(a)-Date.now())/1e3);if(Number.isFinite(u)&&u>=0){let c=o&&typeof o=="object"?o:{};c.retryAfter===void 0&&(o={...c,retryAfter:u})}}r=r||`${n||"Request"} failed with status ${t.status}`;let p=i??(t.status===401?d.Authentication:t.status===403?d.Forbidden:t.status===429?d.RateLimit:d.Api);return new e(p,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?ct(t)?e.network(`${r} failed: ${t.message}`,{cause:t}):new e(d.Api,`${r} failed: ${t.message}`):new e(d.Api,`${r} failed: Unknown error`)}static validation(t,n){return new e(d.Validation,t,400,n)}static notFound(t,n){let r=n?`${t} ${n} not found`:`${t} not found`;return new e(d.NotFound,r,404)}static forbidden(t,n){return new e(d.Forbidden,t,403,n)}static rateLimit(t="Too many requests",n){return new e(d.RateLimit,t,429,n)}static authentication(t="Authentication required",n){return new e(d.Authentication,t,401,n)}static business(t,n=400,r){return new e(d.Business,t,n,r)}static network(t,n){return new e(d.Network,t,void 0,n)}static timeout(t,n){return new e(d.Timeout,t,void 0,n)}static cancelled(t,n){return new e(d.Cancelled,t,void 0,n)}static file(t,n){return new e(d.File,t,void 0,n)}static config(t,n){return new e(d.Config,t,void 0,n)}static api(t,n=500,r){return new e(d.Api,t,n,r)}static maintenance(t,n){return new e(d.Maintenance,t,503,n)}static build(t,n){return new e(d.Build,t,422,n)}isClientError(){return Y.client.has(this.type)?!0:this.status!==void 0&&this.status>=400&&this.status<500}isNetworkError(){return Y.network.has(this.type)}isAuthError(){return Y.auth.has(this.type)}isType(t){return this.type===t}};ut=["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"],un=ut.map(e=>`.${e}`).join(","),dt=/[\x00-\x1f\x7f#?%\\<>"]/;Z=new Set(["node_modules","package.json"]);dn="/auth",mn="signing-in",W={SESSION:"session",API_KEY:"apiKey",TOKEN:"token",AGENT:"agent",OAUTH:"oauth",SYSTEM:"system"},Re={PREFIX:"ship-",HEX_LENGTH:32,TOTAL_LENGTH:37,HINT_LENGTH:4},Ie={PREFIX:"deploy-",HEX_LENGTH:32,TOTAL_LENGTH:39},Ne={PREFIX:"oauth-",HEX_LENGTH:32,TOTAL_LENGTH:38},b={HEADER:"X-Caller",MAX_LENGTH:128,PATTERN:/^[a-zA-Z0-9._-]+$/},fn="X-Account",R={API_KEY:W.API_KEY,DEPLOY_TOKEN:W.TOKEN,OAUTH:W.OAUTH,OPAQUE:"opaque"};J="bearer ";yn={ACCOUNT_READ:"account:read",DEPLOYMENTS_READ:"deployments:read",DEPLOYMENTS_WRITE:"deployments:write",DOMAINS_READ:"domains:read",DOMAINS_WRITE:"domains:write"},S="ship.json",Le={rewrites:[{source:"/(.*)",destination:"/index.html"}]},U={INDEX_FILE:"index.html",MAX_INDEX_BYTES:100*1024};C={MIN_SECONDS:1,MAX_SECONDS:365*24*60*60};Et={new:{owner:!1},deployments:{owner:!1},domains:{owner:!1},settings:{owner:!1},upgrade:{owner:!0},success:{owner:!1},"api-key":{owner:!0}},gt=["login","register","logout","invitations","claim","consent"],Tt="admin",Pe={checkout:["upgrading","true"],portal:["billing","returned"]},Ee=e=>Pe[e].join("="),ge=(e,t)=>t?`${e}?next=${encodeURIComponent(t)}`:e;Tn={login:e=>ge("/login",e),register:e=>ge("/register",e),logout:()=>"/logout",invitation:e=>`/invitations/${e}`,claim:e=>`/claim/${e}`,consent:()=>"/consent"};St=e=>gt.includes(e),Te=e=>Object.hasOwn(Et,e);Dt=e=>{let t=k(e);return t.kind==="door"&&t.door==="claim"},Rt=e=>{let t=k(e);return t.kind==="door"&&t.door==="invitations"},It=e=>{let t=k(e);return t.kind==="account"&&t.section==="upgrade"};re="https://api.shipstatic.com",P={TOKEN:"SHIP_TOKEN",API_URL:"SHIP_API_URL"},Rn="SHIP_VIA",In=`https://my.shipstatic.com${At().apiKey()}`,Nn=4320*60;bn=["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:25,MAX_COUNT:10,SEPARATORS:"._-"},_e=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/;O={COMMAND_MAX_LENGTH:200,OUTPUT_DIR_MAX_LENGTH:100,OUTPUT_DIR_PATTERN:/^[A-Za-z0-9._-]+(\/[A-Za-z0-9._-]+)*$/};v={MIN_LENGTH:6,MAX_LENGTH:128}});async function vt(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 Ft(e){let{createHash:t}=await import("crypto"),n=t("md5");return n.update(e),{md5:n.digest("hex")}}async function Mt(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 G(e){if(e instanceof Blob)return vt(e);if(typeof Buffer<"u"&&Buffer.isBuffer(e))return Ft(e);if(typeof e=="string")return Mt(e);throw s.business("Invalid input for MD5 calculation")}var B=A(()=>{"use strict";f()});function or(e){se=e}function Ht(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function L(){return se||Ht()}var se,w=A(()=>{"use strict";se=null});function je(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 K(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var ae=A(()=>{"use strict"});function qe(e,t={}){if(t.flatten===!1)return e.map(r=>({path:K(r),name:le(r)}));let n=Vt(e);return e.map(r=>{let o=K(r);if(n){let i=n.endsWith("/")?n:`${n}/`;o.startsWith(i)&&(o=o.substring(i.length))}return o||(o=le(r)),{path:o,name:le(r)}})}function Vt(e){if(!e.length)return"";let n=e.map(i=>K(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 le(e){return e.split(/[/\\]/).pop()||e}var ce=A(()=>{"use strict";ae()});function j(e,t){return zt.find(n=>n.broken(e,t))}var zt,ue=A(()=>{"use strict";f();de();zt=[{name:"name",broken:({path:e})=>!pe(e).valid,sentence:({path:e})=>pe(e).reason??"Invalid file name"},{name:"extension",broken:({path:e},t)=>Se(e,t.blockedExtensions??[]),sentence:({path:e})=>`File extension not allowed: "${e}"`},{name:"fileSize",broken:({size:e},t)=>e>t.maxFileSize,sentence:({path:e},t)=>`File "${e}" too large. Maximum ${x(t.maxFileSize)} allowed`},{name:"totalSize",broken:({totalSize:e},t)=>e>t.maxTotalSize,sentence:({totalSize:e},t)=>`Total upload size too large. ${x(e)} exceeds maximum of ${x(t.maxTotalSize)}`}]});function pe(e){if(De(e))return{valid:!1,reason:"File name contains unsafe characters"};if(e.startsWith(" ")||e.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(e.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let t=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,n=e.split("/").pop()||e;return t.test(n)?{valid:!1,reason:"File name uses a reserved system name"}:e.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function Rr(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 \u2014 deploy your build output (dist/, build/, out/), not the project folder"}),{files:e.map(u=>({...u,status:h.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:n,warnings:[],canDeploy:!1};if(e.length>t.maxFilesCount){let a={file:`(${e.length} files)`,message:`File count (${e.length}) exceeds limit of ${t.maxFilesCount}`};return n.push(a),{files:e.map(u=>({...u,status:h.VALIDATION_FAILED,statusMessage:a.message})),validFiles:[],errors:n,warnings:[],canDeploy:!1}}let i=0;for(let a of e){let u=h.READY,c="Ready for upload";if(a.status===h.PROCESSING_ERROR)u=h.VALIDATION_FAILED,c=a.statusMessage||"File failed during processing",n.push({file:a.name,message:c});else if(a.size===0){u=h.EXCLUDED,c="File is empty (0 bytes) and cannot be deployed due to storage limitations",r.push({file:a.name,message:c}),o.push({...a,status:u,statusMessage:c});continue}else if(a.size<0)u=h.VALIDATION_FAILED,c="File size must be positive",n.push({file:a.name,message:c});else if(!a.name||a.name.trim().length===0)u=h.VALIDATION_FAILED,c="File name cannot be empty",n.push({file:a.name||"(empty)",message:c});else if(a.name.includes("\0"))u=h.VALIDATION_FAILED,c="File 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},D=j(y,t);D?(u=h.VALIDATION_FAILED,c=D.sentence(y,t),n.push({file:D.name==="totalSize"?`(${e.length} files)`:a.name,message:c})):i=y.totalSize}o.push({...a,status:u,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 Kt(e){return e.filter(t=>t.status===h.READY)}function Ir(e){return Kt(e).length>0}var de=A(()=>{"use strict";f();ue();f()});import{isJunk as jt}from"junk";function Xe(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(jt(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(qt.some(p=>l.toLowerCase()===p.toLowerCase()))return!1;return!0})}var qt,me=A(()=>{"use strict";f();qt=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function Ye(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 We(e,t){let n=j(e,t);if(n)throw s.business(n.sentence(e,t))}var fe=A(()=>{"use strict";f();ue()});async function Je(e,t={},n){let r=!!(t.build||t.prerender),o=qe(e.map(c=>c.path),{flatten:t.pathDetect!==!1}).map(c=>c.path),i=new Set(Xe(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:Xt(n),a=[],u=0;for(let{source:c,deployPath:y}of l){if(p&&Ye(y,c.origin),c.size===0)continue;p&&(u+=c.size,We({path:y,size:c.size,totalSize:u},p));let D=await c.read(),{md5:q}=await G(D);a.push({path:y,content:D,size:c.size,md5:q})}if(p&&a.length>p.maxFilesCount)throw s.business(`Too many files to deploy. Maximum allowed is ${p.maxFilesCount} files.`);return a}function Xt(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 Qe=A(()=>{"use strict";f();ce();me();B();fe()});var tt={};ot(tt,{processFilesForNode:()=>et});import*as T from"fs";import*as g from"path";function Ze(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(...Ze(i,t)):l.isFile()&&n.push({absPath:i,size:l.size})}return n}async function Yt(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 Wt(e){for(let t of e){let n=g.resolve(t);try{if(T.statSync(n).isDirectory()){let r=T.readdirSync(n).find(o=>Z.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 et(e,t={},n){if(L()!=="node")throw s.business("processFilesForNode can only be called in Node.js environment.");Wt(e);let r=e.flatMap(p=>{let a=g.resolve(p);try{let u=T.statSync(a);return u.isDirectory()?Ze(a):[{absPath:a,size:u.size}]}catch{throw s.file(`Path does not exist: ${p}`,{filePath:p})}}),o=new Map(r.map(p=>[p.absPath,p.size])),i=je(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:Jt(p,i),origin:p,size:a,read:()=>Yt(p)}));return Je(l,t,n)}function Jt(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 he=A(()=>{"use strict";f();Qe();w();ae()});f();f();f();var $=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 Lt=3e4,bt=2,Ot=300,Pt=2e3,xt=new Set([500,502,503,504]);function _t(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 ve=3e5,wt=3e5,Ct=ve+wt,H=class extends ${constructor(n){super();this.globalHeaders={};this.apiUrl=n.apiUrl||re,this.getAuthHeadersCallback=n.getAuthHeaders,this.session=n.session??!1,this.caller=n.caller,this.timeout=n.timeout??Lt,this.maxRetries=Math.max(0,n.maxRetries??bt),this.fetch=n.fetch??globalThis.fetch.bind(globalThis),this.deploy={endpoint:n.deployEndpoint||m.DEPLOYMENTS,timeout:n.timeout??ve,buildTimeout:n.timeout??Ct}}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 u=Math.min(Pt,Ot*2**l);try{await _t(Math.random()*u,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(d.Maintenance)||n.isType(d.Cancelled)||!(n.isNetworkError()||n.status!==void 0&&xt.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 u={...r,headers:p,credentials:this.session&&!p.Authorization?"include":void 0,signal:a.signal};this.emit("request",n,u);let c=await this.fetch(n,u);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?{[b.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 Fe(e,t={}){let{labels:n,via:r,password:o,ttl:i,flags:l,captcha:p}=t,a=new FormData,u=[];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"})),u.push(c.md5)}return a.append(E.CHECKSUMS,JSON.stringify(u)),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();B();async function Ut(){let e=JSON.stringify(Le,null,2),t;typeof Buffer<"u"?t=Buffer.from(e,"utf-8"):t=new Blob([e],{type:"application/json"});let{md5:n}=await G(t);return{path:S,content:t,size:e.length,md5:n}}async function kt(e,t,n){let r=e.find(p=>p.path===U.INDEX_FILE||p.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(p=>p.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 Me(e,t,n){if(n.spaDetect===!1||n.spa||n.build||n.prerender||e.some(r=>r.path===S))return e;try{if(await kt(e,t,n.signal)){let o=await Ut();return[...e,o]}}catch(r){if(n.signal?.aborted)throw r}return e}f();f();function _(e){if(e==null)return;if(e.length===0)return e;if(e.length>I.MAX_COUNT)throw s.validation(`Maximum ${I.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<I.MIN_LENGTH)throw s.validation(`Labels must be at least ${I.MIN_LENGTH} characters long`);if(i.length>I.MAX_LENGTH)throw s.validation(`Labels must be no more than ${I.MAX_LENGTH} characters long`);if(!_e.test(i))throw s.validation(`Labels must start and end with alphanumeric characters, with optional separators (${I.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 Ue(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");be(r)}var V={"Content-Type":"application/json"},$t="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 ke(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 Me(l,i,o);if(!p.length)throw s.business("No files to deploy");for(let X of p)if(!X.md5)throw s.file(`MD5 checksum missing for file: ${X.path}`,{filePath:X.path});oe(o.password);let a=ne(o.ttl),u=Ae(o.idempotencyKey),c=_(o.labels);await Ue(p);let y=we(o.buildCommand),D=Ce(o.outputDir),q=o.build||o.prerender||o.spa?{build:o.build,prerender:o.prerender,spa:o.spa,buildCommand:y,outputDir:D}:void 0,nt=await Fe(p,{labels:c,via:o.via??$t,password:o.password,ttl:a,flags:q,captcha:o.captcha});return i.request(i.deploy.endpoint,{method:"POST",body:nt,...u?{headers:{[N.HEADER]:u}}:{},signal:o.signal||null},"Deploy",o.build||o.prerender?i.deploy.buildTimeout:i.deploy.timeout)},list:async r=>t().request(`${m.DEPLOYMENTS}${ie(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:V,body:JSON.stringify({labels:_(o.labels)})},"Update deployment labels"),delete:async r=>t().request(m.DEPLOYMENT(encodeURIComponent(r)),{method:"DELETE"},"Delete deployment")}}function $e(e){let{getApi:t}=e;return{set:async(n,r={})=>{let o=_(r.labels),i={};r.deployment&&(i.deployment=r.deployment),o!==void 0&&(i.labels=o);let{data:l,status:p}=await t().requestWithStatus(m.DOMAIN(encodeURIComponent(n)),{method:"PUT",headers:V,body:JSON.stringify(i)},"Set domain");return{...l,isCreate:p===201}},list:async n=>t().request(`${m.DOMAINS}${ie(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:V,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 He(e){let{getApi:t}=e;return{get:async()=>t().request(m.ACCOUNT,{method:"GET"},"Get account")}}function Ge(e){let{getApi:t}=e;return{create:async(n={})=>{let r=ne(n.ttl),o=_(n.labels),i={};return r!==void 0&&(i.ttl=r),o!==void 0&&(i.labels=o),t().request(m.TOKENS,{method:"POST",headers:V,body:JSON.stringify(i)},"Create token")},list:async n=>t().request(`${m.TOKENS}${ie(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&&Oe(t.caller),t.token&&t.session)throw s.config("Provide either `token` or `session`, not both.");typeof t.token=="string"?(te(t.token),this.credential=t.token):t.token&&(this.credential=t.token),this.http=new H({...t,getAuthHeaders:()=>this.getAuthHeaders()});let n={getApi:()=>this.http};this.deployments=ke({...n,processInput:async(r,o)=>this.processInput(r,o,await this.getLimits({signal:o.signal}))}),this.domains=$e(n),this.account=He(n),this.tokens=Ge(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.");te(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}`}}};w();f();import{z as ze}from"zod";import{z as Be}from"zod";var Ve={apiUrl:Be.string().url().optional(),token:Be.string().min(1).optional()};w();var Gt=ze.object(Ve).strict(),Bt={apiUrl:P.API_URL,token:P.TOKEN};function Ke(){if(L()!=="node")return{};let e={apiUrl:process.env[P.API_URL]||void 0,token:process.env[P.TOKEN]||void 0};try{return Gt.parse(e)}catch(t){if(t instanceof ze.ZodError){let n=t.issues[0],r=n.path[0],o=(r&&Bt[r])??"SHIP environment configuration";throw s.config(`Invalid ${o}: ${n.message}`)}throw s.config("Invalid environment configuration")}}f();f();ce();w();de();me();B();fe();function Cr(e,t,n,r=!0){let o=e===1?t:n;return r?`${e} ${o}`:o}he();var ye=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=Ke();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(()=>(he(),tt));return i(o,n,r)}},Qt=ye;export{fn as ACCOUNT_HEADER,Re as API_KEY,m as API_PATHS,dn as AUTH_BASE_PATH,sn as AccountPlan,an as AccountRefusal,H as ApiHttp,W as AuthMethod,O as BUILD_SETTINGS,b as CALLER,re as DEFAULT_API,S as DEPLOYMENT_CONFIG_FILENAME,E as DEPLOY_FIELDS,pn as DEPLOY_FILE_GRAMMAR,Ie as DEPLOY_TOKEN,en as DeploymentStatus,it as DeploymentVia,tn as DomainStatus,nn as DomainVerification,d as ErrorType,h as FILE_VALIDATION_STATUS,h as FileValidationStatus,N as IDEMPOTENCY_KEY_CONSTRAINTS,qt as JUNK_DIRECTORIES,I as LABEL_CONSTRAINTS,_e as LABEL_PATTERN,In as MY_API_KEY_URL,Ne as OAUTH_TOKEN,yn as OAuthScope,v as PASSWORD_CONSTRAINTS,Nn as PUBLIC_DEPLOYMENT_TTL_SECONDS,Et as SECTIONS,rn as SETUP_TROUBLESHOOTING_ANCHOR,P as SHIP_ENV,Rn as SHIP_VIA_ENV,mn as SIGN_IN_RETURN_PARAM,U as SPA_CHECK_CONSTRAINTS,Le as SPA_DEFAULT_CONFIG,ye as Ship,s as ShipError,C as TTL_CONSTRAINTS,R as TokenKind,Z as UNBUILT_PROJECT_MARKERS,dt as UNSAFE_FILENAME_CHARS,bn as USER_VISIBLE_EVENTS,un as WEB_FILE_ACCEPT,or as __setTestEnvironment,Sn as accountOfPath,Ir as allValidFilesReady,be as assertShipJsonSyntax,An as billingReturnOf,G as calculateMD5,mt as classifyToken,At as consolePaths,He as createAccountResource,ke as createDeploymentResource,$e as createDomainResource,Ge as createTokenResource,Qt as default,Cn as deserializeLabels,Tn as doors,Dn as errandOf,Pn as extractSubdomain,Xe as filterJunk,Nt as formatDuration,x as formatFileSize,Ln as formatTimeRemaining,xn as generateDeploymentUrl,_n as generateDomainUrl,L as getENV,Kt as getValidFiles,M as hasUnbuiltMarker,De as hasUnsafeChars,Se as isBlockedExtension,Dt as isClaimPath,On as isCustomDomain,gn as isDeployment,Rt as isInvitationPath,xe as isPlatformDomain,F as isShipError,It as isUpgradePath,on as normalizeVia,qe as optimizeDeployPaths,ln as personName,cn as personShortName,Cr as pluralize,et as processFilesForNode,hn as readBearerValue,wn as serializeLabels,ft as validateApiKey,En as validateApiUrl,we as validateBuildCommand,Oe as validateCaller,We as validateDeployFile,Ye as validateDeployPath,ht as validateDeployToken,pe as validateFileName,Rr as validateFiles,Ae as validateIdempotencyKey,yt as validateOAuthToken,Ce as validateOutputDir,oe as validatePassword,te as validateToken,ne as validateTtl};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|