@shipstatic/ship 0.8.17 → 0.9.2

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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _shipstatic_types from '@shipstatic/types';
2
- import { DeploymentUploadOptions, ProgressInfo, StaticFile, Domain, DeploymentCreateResponse, DeploymentListResponse, Deployment, DomainListResponse, DomainDnsResponse, DomainRecordsResponse, DomainValidateResponse, TokenCreateResponse, TokenListResponse, Account, ConfigResponse, ResolvedConfig, DeployInput, AccountResource, DeploymentResource, DomainResource, TokenResource, ValidatableFile, FileValidationResult } from '@shipstatic/types';
2
+ import { DeploymentUploadOptions, ProgressInfo, StaticFile, DeploymentCreateResponse, DeploymentListResponse, Deployment, DomainSetResult, DomainListResponse, Domain, DomainDnsResponse, DomainRecordsResponse, DomainValidateResponse, TokenCreateResponse, TokenListResponse, Account, PlatformLimits, DeployInput, AccountResource, DeploymentResource, DomainResource, TokenResource, ResolvedConfig, ValidatableFile, FileValidationResult } from '@shipstatic/types';
3
3
  export * from '@shipstatic/types';
4
4
  export { Account, AccountResource, DEFAULT_API, DeployInput, Deployment, DeploymentResource, Domain, DomainResource, ErrorType, FileValidationStatus as FILE_VALIDATION_STATUS, PingResponse, ResolvedConfig, ShipError, StaticFile, TokenResource } from '@shipstatic/types';
5
5
 
@@ -9,14 +9,6 @@ export { Account, AccountResource, DEFAULT_API, DeployInput, Deployment, Deploym
9
9
  * Core types come from @shipstatic/types, while SDK-specific types are defined here.
10
10
  */
11
11
 
12
- /**
13
- * Domain set result with SDK-injected isCreate flag.
14
- * isCreate is derived from HTTP status code (201 = create, 200 = update)
15
- * and is not part of the Domain entity contract.
16
- */
17
- type DomainSetResult = Domain & {
18
- isCreate: boolean;
19
- };
20
12
  /**
21
13
  * Universal deploy options for both Node.js and Browser environments.
22
14
  * Extends the API contract (DeploymentUploadOptions) with SDK-specific options.
@@ -95,8 +87,6 @@ interface ShipClientOptions {
95
87
  apiKey?: string | undefined;
96
88
  /** Deploy token for single-use deployments (format: token-<64-char-hex>, total 70 chars). */
97
89
  deployToken?: string | undefined;
98
- /** Path to custom config file. */
99
- configFile?: string | undefined;
100
90
  /**
101
91
  * Default callback for deploy progress for deploys made with this client.
102
92
  * @param info - Progress information including percentage and byte counts.
@@ -125,11 +115,23 @@ interface ShipClientOptions {
125
115
  /**
126
116
  * Default caller identifier for multi-tenant deployments.
127
117
  * Alphanumeric characters, dots, underscores, and hyphens allowed (max 128 chars).
118
+ *
119
+ * Used by orchestrators (e.g. n8n nodes processing many tenants from one
120
+ * worker) so the API's rate-limit bucket keys per caller rather than per
121
+ * shared IP. **Programmatic-only by design** — there is no `--caller`
122
+ * CLI flag because the CLI is a single-user tool (`via: 'cli'` is hardcoded
123
+ * in `performDeploy`); every CLI invocation belongs to one human, and
124
+ * a per-tenant rate-limit bucket would defeat the purpose.
128
125
  */
129
126
  caller?: string | undefined;
130
127
  /**
131
- * Override the deploy endpoint path. Defaults to '/deployments'.
132
- * Used by first-party clients to target alternative upload routes (e.g., '/upload').
128
+ * Override the deploy endpoint path. Defaults to `/deployments`.
129
+ *
130
+ * @internal First-party hook used by `web/my` and `web/www` to target the
131
+ * `/upload` route (which runs server-side build / SPA detection). External
132
+ * SDK consumers must not set this — the `/deployments` endpoint is the
133
+ * stable public contract. See `cloudflare/api/CLAUDE.md` for why the two
134
+ * endpoints exist and what `/upload` does that `/deployments` doesn't.
133
135
  */
134
136
  deployEndpoint?: string | undefined;
135
137
  }
@@ -152,12 +154,11 @@ interface ShipEvents {
152
154
  */
153
155
 
154
156
  /**
155
- * Lightweight event system
156
- * - Add handler: on()
157
- * - Remove handler: off()
158
- * - Emit events: emit() [internal]
159
- * - Transfer events: transfer() [internal]
160
- * - Reliable error handling and cleanup
157
+ * Lightweight typed event emitter.
158
+ *
159
+ * Public API: `on()` / `off()`. `emit()` is internal — only the SDK
160
+ * publishes events. Throwing handlers are evicted automatically and
161
+ * surfaced as `error` events on the next tick.
161
162
  */
162
163
  declare class SimpleEvents {
163
164
  private handlers;
@@ -174,16 +175,6 @@ declare class SimpleEvents {
174
175
  * @internal
175
176
  */
176
177
  emit<K extends keyof ShipEvents>(event: K, ...args: ShipEvents[K]): void;
177
- /**
178
- * Transfer all handlers to another events instance
179
- * @internal
180
- */
181
- transfer(target: SimpleEvents): void;
182
- /**
183
- * Clear all handlers (for cleanup)
184
- * @internal
185
- */
186
- clear(): void;
187
178
  }
188
179
 
189
180
  /**
@@ -208,10 +199,6 @@ declare class ApiHttp extends SimpleEvents {
208
199
  * Priority: globalHeaders (lowest) < instance auth < per-request headers (highest)
209
200
  */
210
201
  setGlobalHeaders(headers: Record<string, string>): void;
211
- /**
212
- * Transfer events to another client
213
- */
214
- transferEventsTo(target: ApiHttp): void;
215
202
  /**
216
203
  * Execute HTTP request with timeout, events, and error handling
217
204
  */
@@ -254,34 +241,11 @@ declare class ApiHttp extends SimpleEvents {
254
241
  removeToken(token: string): Promise<void>;
255
242
  fetchAgentToken(): Promise<TokenCreateResponse>;
256
243
  getAccount(): Promise<Account>;
257
- getConfig(): Promise<ConfigResponse>;
244
+ getLimits(): Promise<PlatformLimits>;
258
245
  ping(): Promise<boolean>;
259
246
  checkSPA(files: StaticFile[], options?: ApiDeployOptions): Promise<boolean>;
260
247
  }
261
248
 
262
- /**
263
- * @file Shared configuration logic for both environments.
264
- *
265
- * CONFIGURATION PRECEDENCE (highest to lowest):
266
- * 1. Constructor options / CLI flags (passed directly to Ship())
267
- * 2. Environment variables (SHIP_API_KEY, SHIP_DEPLOY_TOKEN, SHIP_API_URL)
268
- * 3. Config file (.shiprc or package.json "ship" key)
269
- * 4. Default values (DEFAULT_API)
270
- *
271
- * This means CLI flags always win, followed by env vars, then config files.
272
- */
273
-
274
- /**
275
- * Universal configuration resolver for all environments.
276
- * This is the single source of truth for config resolution.
277
- */
278
- declare function resolveConfig(userOptions?: ShipClientOptions, loadedConfig?: Partial<ShipClientOptions>): ResolvedConfig;
279
- /**
280
- * Merge deployment options with client defaults.
281
- * This is shared logic used by both environments.
282
- */
283
- declare function mergeDeployOptions(options: DeploymentOptions, clientDefaults: ShipClientOptions): DeploymentOptions;
284
-
285
249
  /**
286
250
  * Ship SDK resource factory functions.
287
251
  */
@@ -324,75 +288,45 @@ declare function createTokenResource(ctx: ResourceContext): TokenResource;
324
288
 
325
289
  /**
326
290
  * Abstract base class for Ship SDK implementations.
327
- *
328
- * Provides shared functionality while allowing environment-specific
329
- * implementations to handle configuration loading and deployment processing.
330
291
  */
331
292
  declare abstract class Ship$1 {
332
- protected http: ApiHttp;
333
- protected readonly clientOptions: ShipClientOptions;
334
- protected initPromise: Promise<void> | null;
335
- protected _config: ConfigResponse | null;
293
+ readonly deployments: DeploymentResource;
294
+ readonly domains: DomainResource;
295
+ readonly account: AccountResource;
296
+ readonly tokens: TokenResource;
297
+ private readonly http;
298
+ private readonly clientOptions;
299
+ private initPromise;
300
+ protected platformLimits: PlatformLimits | null;
336
301
  private auth;
337
- private customHeaders;
338
- protected readonly authHeadersCallback: () => Record<string, string>;
339
- protected _deployments: DeploymentResource;
340
- protected _domains: DomainResource;
341
- protected _account: AccountResource;
342
- protected _tokens: TokenResource;
343
302
  constructor(options?: ShipClientOptions);
344
- protected abstract resolveInitialConfig(options: ShipClientOptions): ResolvedConfig;
345
- protected abstract loadFullConfig(): Promise<void>;
346
303
  protected abstract processInput(input: DeployInput, options: DeploymentOptions): Promise<StaticFile[]>;
347
304
  protected abstract getDeployBodyCreator(): DeployBodyCreator;
348
305
  /**
349
- * Ensure full initialization is complete - called lazily by resources
306
+ * Lazy initialization fetches platform limits (file size / count caps) once,
307
+ * on the first API call. Subsequent calls reuse the resolved promise.
350
308
  */
351
309
  protected ensureInitialized(): Promise<void>;
310
+ private fetchPlatformLimits;
352
311
  /**
353
- * Ping the API server to check connectivity
312
+ * Ping the API server to check connectivity.
354
313
  */
355
314
  ping(): Promise<boolean>;
356
315
  /**
357
- * Deploy project (convenience shortcut to ship.deployments.upload())
316
+ * Deploy project (convenience shortcut to `ship.deployments.upload()`).
358
317
  */
359
318
  deploy(input: DeployInput, options?: DeploymentOptions): Promise<Deployment>;
360
319
  /**
361
- * Get current account information (convenience shortcut to ship.account.get())
320
+ * Get current account information (convenience shortcut to `ship.account.get()`).
362
321
  */
363
322
  whoami(): Promise<_shipstatic_types.Account>;
364
323
  /**
365
- * Get deployments resource (environment-specific)
366
- */
367
- get deployments(): DeploymentResource;
368
- /**
369
- * Get domains resource
370
- */
371
- get domains(): DomainResource;
372
- /**
373
- * Get account resource
374
- */
375
- get account(): AccountResource;
376
- /**
377
- * Get tokens resource
378
- */
379
- get tokens(): TokenResource;
380
- /**
381
- * Get API configuration (file upload limits, etc.)
382
- * Reuses platform config fetched during initialization, then caches the result
383
- */
384
- getConfig(): Promise<ConfigResponse>;
385
- /**
386
- * Add event listener
387
- * @param event - Event name
388
- * @param handler - Event handler function
324
+ * Get platform limits (max file size, file count, total size).
325
+ * Reuses the response fetched during initialization. Per-instance state —
326
+ * does not leak between concurrent Ships against different API URLs.
389
327
  */
328
+ getLimits(): Promise<PlatformLimits>;
390
329
  on<K extends keyof ShipEvents>(event: K, handler: (...args: ShipEvents[K]) => void): void;
391
- /**
392
- * Remove event listener
393
- * @param event - Event name
394
- * @param handler - Event handler function
395
- */
396
330
  off<K extends keyof ShipEvents>(event: K, handler: (...args: ShipEvents[K]) => void): void;
397
331
  /**
398
332
  * Set global headers included in every request.
@@ -403,38 +337,60 @@ declare abstract class Ship$1 {
403
337
  * Clear all custom global headers.
404
338
  */
405
339
  clearHeaders(): void;
406
- /**
407
- * Replace HTTP client while preserving event listeners
408
- * Used during initialization to maintain user event subscriptions
409
- * @protected
410
- */
411
- protected replaceHttpClient(newClient: ApiHttp): void;
412
340
  /**
413
341
  * Sets the deploy token for authentication.
414
- * This will override any previously set API key or deploy token.
415
- * @param token The deploy token (format: token-<64-char-hex>)
342
+ * Overrides any previously set API key or deploy token.
343
+ * @param token Deploy token (format: `token-<64-char-hex>`)
416
344
  */
417
345
  setDeployToken(token: string): void;
418
346
  /**
419
347
  * Sets the API key for authentication.
420
- * This will override any previously set API key or deploy token.
421
- * @param key The API key (format: ship-<64-char-hex>)
348
+ * Overrides any previously set API key or deploy token.
349
+ * @param key API key (format: `ship-<64-char-hex>`)
422
350
  */
423
351
  setApiKey(key: string): void;
424
- /**
425
- * Generate authorization headers based on current auth state
426
- * Called dynamically on each request to ensure latest credentials are used
427
- * @private
428
- */
429
352
  private getAuthHeaders;
430
353
  /**
431
- * Check if authentication credentials are configured
432
- * Used by resources to fail fast if auth is required
433
- * @private
354
+ * Check whether authentication credentials are configured.
355
+ * Used by resources to fail fast (or trigger the agent-token fallback) when
356
+ * auth is required.
434
357
  */
435
358
  private hasAuth;
436
359
  }
437
360
 
361
+ /**
362
+ * @file Cross-platform configuration helpers.
363
+ *
364
+ * Two pure helpers used by both Node and Browser:
365
+ *
366
+ * - `resolveConfig(options)` — applies the API-URL default. The Node Ship
367
+ * calls this after merging env vars under the user's options; the Browser
368
+ * Ship calls it directly (no ambient sources).
369
+ * - `mergeDeployOptions(perCallOptions, clientDefaults)` — overlays
370
+ * instance-level defaults under per-call overrides for a single deploy.
371
+ *
372
+ * Credential precedence is owned by callers, not this file:
373
+ *
374
+ * - SDK (Node): constructor args > `SHIP_*` env vars (see `node/index.ts`)
375
+ * - SDK (Browser): constructor args only
376
+ * - CLI: `--flag` > env > `.shiprc` / `package.json` (see `cli/create-client.ts`)
377
+ */
378
+
379
+ /**
380
+ * Apply the API-URL default and project the credential triplet into a
381
+ * `ResolvedConfig` shape. Optional fields are omitted (rather than set to
382
+ * `undefined`) so spread merges downstream behave predictably.
383
+ */
384
+ declare function resolveConfig(options?: ShipClientOptions): ResolvedConfig;
385
+ /**
386
+ * Overlay client-level defaults under per-call deploy options.
387
+ *
388
+ * Per-call options always win — they're the explicit override for a single
389
+ * `deployments.upload()`. Defaults fill in only when the per-call option is
390
+ * `undefined` (an explicit `null` / empty value passes through).
391
+ */
392
+ declare function mergeDeployOptions(options: DeploymentOptions, clientDefaults: ShipClientOptions): DeploymentOptions;
393
+
438
394
  interface MD5Result {
439
395
  md5: string;
440
396
  }
@@ -615,12 +571,12 @@ declare function validateFileName(filename: string): {
615
571
  * - **Warnings**: Exclude files but allow deployment (empty files, etc.)
616
572
  *
617
573
  * @param files - Array of files to validate
618
- * @param config - Validation configuration from ship.getConfig()
574
+ * @param config - Validation configuration from ship.getLimits()
619
575
  * @returns Validation result with errors and warnings
620
576
  *
621
577
  * @example
622
578
  * ```typescript
623
- * const config = await ship.getConfig();
579
+ * const config = await ship.getLimits();
624
580
  * const result = validateFiles(files, config);
625
581
  *
626
582
  * if (!result.canDeploy) {
@@ -636,7 +592,7 @@ declare function validateFileName(filename: string): {
636
592
  * }
637
593
  * ```
638
594
  */
639
- declare function validateFiles<T extends ValidatableFile>(files: T[], config: ConfigResponse): FileValidationResult<T>;
595
+ declare function validateFiles<T extends ValidatableFile>(files: T[], config: PlatformLimits): FileValidationResult<T>;
640
596
  /**
641
597
  * Get only the valid files from validation results
642
598
  */
@@ -675,39 +631,6 @@ declare function validateDeployPath(deployPath: string, sourceIdentifier: string
675
631
  */
676
632
  declare function validateDeployFile(deployPath: string, sourceIdentifier: string): void;
677
633
 
678
- /**
679
- * @file Manages loading and validation of client configuration.
680
- * This module uses `cosmiconfig` to find and load configuration from various
681
- * file sources (e.g., `.shiprc`, `package.json`) and environment variables.
682
- * Configuration values are validated using Zod schemas.
683
- */
684
-
685
- /**
686
- * Simplified configuration loading prioritizing environment variables.
687
- * Only loads file config if environment variables are not set.
688
- * Only available in Node.js environments.
689
- *
690
- * @param configFile - Optional specific config file path to load
691
- * @returns Configuration object with loaded values
692
- * @throws {ShipInvalidConfigError} If the configuration is invalid.
693
- */
694
- declare function loadConfig(configFile?: string): Promise<Partial<ShipClientOptions>>;
695
-
696
- /**
697
- * @file Platform configuration management for the Ship SDK.
698
- * Implements fail-fast dynamic configuration with mandatory API fetch.
699
- */
700
-
701
- /**
702
- * Set the current config (called after fetching from API)
703
- */
704
- declare function setConfig(config: ConfigResponse): void;
705
- /**
706
- * Get current config - throws if not initialized (fail-fast approach)
707
- * @throws {ShipError.config} If configuration hasn't been fetched from API
708
- */
709
- declare function getCurrentConfig(): ConfigResponse;
710
-
711
634
  /**
712
635
  * Processes Node.js file and directory paths into an array of StaticFile objects ready for deploy.
713
636
  * Computes content paths relative to the upload root before filtering, so only the deployed
@@ -715,39 +638,62 @@ declare function getCurrentConfig(): ConfigResponse;
715
638
  *
716
639
  * @param paths - File or directory paths to scan and process.
717
640
  * @param options - Processing options (pathDetect, etc.).
641
+ * @param platformLimits - Per-instance platform limits (file-size / count /
642
+ * total-size caps) from the originating Ship's `GET /config` fetch. Passed
643
+ * in rather than read from a module global so concurrent Ships against
644
+ * different API URLs cannot clobber each other's caps.
718
645
  * @returns Promise resolving to an array of StaticFile objects.
719
646
  * @throws {ShipClientError} If called outside Node.js or if fs/path modules fail.
720
647
  */
721
- declare function processFilesForNode(paths: string[], options?: DeploymentOptions): Promise<StaticFile[]>;
648
+ declare function processFilesForNode(paths: string[], options?: DeploymentOptions, platformLimits?: PlatformLimits): Promise<StaticFile[]>;
722
649
 
723
650
  /**
724
- * @file Ship SDK for Node.js environments with full file system support.
651
+ * @file Ship SDK for Node.js environments.
652
+ *
653
+ * The Node-side `Ship` adds two things on top of the base class:
654
+ * 1. Environment detection — refuses to construct outside Node.
655
+ * 2. `SHIP_*` env-var resolution as the universal "process boundary" credential
656
+ * source, mirroring the OpenAI / Anthropic SDK convention. Constructor
657
+ * arguments win over env vars.
658
+ *
659
+ * The SDK does NOT read `~/.shiprc` or `package.json` `"ship"` keys — that's
660
+ * the CLI's job (see `cli/shiprc.ts`). Keeping file resolution out of the SDK
661
+ * is what lets embedded consumers (MCP, n8n, GitHub Action) safely write
662
+ * `new Ship({})` for anonymous public deployments without inheriting the host
663
+ * developer's personal credentials.
725
664
  */
726
665
 
727
666
  /**
728
667
  * Ship SDK Client for Node.js environments.
729
668
  *
730
- * Provides full file system access, configuration file loading,
731
- * and environment variable support.
732
- *
733
669
  * @example
734
670
  * ```typescript
735
- * // Authenticated deployments with API key
736
- * const ship = new Ship({ apiKey: "ship-xxxx" });
671
+ * // Authenticated explicit API key
672
+ * const ship = new Ship({ apiKey: 'ship-xxxx' });
737
673
  *
738
- * // Single-use deployments with deploy token
739
- * const ship = new Ship({ deployToken: "token-xxxx" });
674
+ * // Authenticated picks up SHIP_API_KEY from env
675
+ * const ship = new Ship({});
740
676
  *
741
- * // Deploy a directory
677
+ * // Anonymous public deploy — works when neither constructor nor env provides creds
678
+ * const ship = new Ship({});
742
679
  * await ship.deploy('./dist');
743
680
  * ```
744
681
  */
745
682
  declare class Ship extends Ship$1 {
746
683
  constructor(options?: ShipClientOptions);
747
- protected resolveInitialConfig(options: ShipClientOptions): ResolvedConfig;
748
- protected loadFullConfig(): Promise<void>;
684
+ /**
685
+ * Deploy file or directory paths to ShipStatic. Convenience shortcut for
686
+ * `ship.deployments.upload()`.
687
+ *
688
+ * Wrong-platform inputs (e.g. `File[]`) fail at compile time. For
689
+ * platform-neutral code, use `ship.deployments.upload()`, which accepts
690
+ * the wider `DeployInput` and validates at runtime — that asymmetry is
691
+ * intentional: the convenience shortcut narrows; the resource-layer
692
+ * contract stays platform-neutral.
693
+ */
694
+ deploy(input: string | string[], options?: DeploymentOptions): Promise<Deployment>;
749
695
  protected processInput(input: DeployInput, options: DeploymentOptions): Promise<StaticFile[]>;
750
696
  protected getDeployBodyCreator(): DeployBodyCreator;
751
697
  }
752
698
 
753
- export { type ApiDeployOptions, ApiHttp, type ApiHttpOptions, type DeployBody, type DeployBodyContext, type DeployBodyCreator, type DeployFile, type DeploymentOptions, type DeploymentResourceContext, type DomainSetResult, type ExecutionEnvironment, JUNK_DIRECTORIES, type MD5Result, type ResourceContext, Ship, type ShipClientOptions, type ShipEvents, __setTestEnvironment, allValidFilesReady, calculateMD5, createAccountResource, createDeploymentResource, createDomainResource, createTokenResource, Ship as default, filterJunk, formatFileSize, getCurrentConfig, getENV, getValidFiles, loadConfig, mergeDeployOptions, optimizeDeployPaths, pluralize, processFilesForNode, resolveConfig, setConfig as setPlatformConfig, validateDeployFile, validateDeployPath, validateFileName, validateFiles };
699
+ export { type ApiDeployOptions, ApiHttp, type ApiHttpOptions, type DeployBody, type DeployBodyContext, type DeployBodyCreator, type DeployFile, type DeploymentOptions, type DeploymentResourceContext, type ExecutionEnvironment, JUNK_DIRECTORIES, type MD5Result, type ResourceContext, Ship, type ShipClientOptions, type ShipEvents, __setTestEnvironment, allValidFilesReady, calculateMD5, createAccountResource, createDeploymentResource, createDomainResource, createTokenResource, Ship as default, filterJunk, formatFileSize, getENV, getValidFiles, mergeDeployOptions, optimizeDeployPaths, pluralize, processFilesForNode, resolveConfig, validateDeployFile, validateDeployPath, validateFileName, validateFiles };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var Me=Object.defineProperty;var v=(n,t)=>()=>(n&&(t=n(n=0)),t);var Be=(n,t)=>{for(var e in t)Me(n,e,{get:t[e],enumerable:!0})};function C(n){return n!==null&&typeof n=="object"&&"name"in n&&n.name==="ShipError"&&"status"in n}function B(n){let t=n.lastIndexOf(".");if(t===-1||t===n.length-1)return!1;let e=n.slice(t+1).toLowerCase();return He.has(e)}function ge(n){return Ke.test(n)}function H(n){return n.replace(/\\/g,"/").split("/").filter(Boolean).some(e=>J.has(e))}function at(n){if(!n.startsWith(P))throw a.validation(`API key must start with "${P}"`);if(n.length!==he)throw a.validation(`API key must be ${he} characters total (${P} + ${W} hex chars)`);let t=n.slice(P.length);if(!/^[a-f0-9]{64}$/i.test(t))throw a.validation(`API key must contain ${W} hexadecimal characters after "${P}" prefix`)}function lt(n){if(!n.startsWith(O))throw a.validation(`Deploy token must start with "${O}"`);if(n.length!==ye)throw a.validation(`Deploy token must be ${ye} characters total (${O} + ${X} hex chars)`);let t=n.slice(O.length);if(!/^[a-f0-9]{64}$/i.test(t))throw a.validation(`Deploy token must contain ${X} hexadecimal characters after "${O}" prefix`)}function pt(n){try{let t=new URL(n);if(!["http:","https:"].includes(t.protocol))throw a.validation("API URL must use http:// or https:// protocol");if(t.pathname!=="/"&&t.pathname!=="")throw a.validation("API URL must not contain a path");if(t.search||t.hash)throw a.validation("API URL must not contain query parameters or fragments")}catch(t){throw C(t)?t:a.validation("API URL must be a valid URL")}}function ct(n){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(n)}function Se(n,t){return n.endsWith(`.${t}`)}function ut(n,t){return!Se(n,t)}function dt(n,t){return Se(n,t)?n.slice(0,-(t.length+1)):null}function ft(n){return`https://${n}`}function mt(n){return`https://${n}`}function ht(n){return!n||n.length===0?null:JSON.stringify(n)}function yt(n){if(!n)return[];try{let t=JSON.parse(n);return Array.isArray(t)?t:[]}catch{return[]}}var nt,it,ot,f,Y,a,He,Ke,J,P,W,he,rt,O,X,ye,st,Q,De,K,D,I,Ee,L,S=v(()=>{"use strict";nt={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},it={PENDING:"pending",PARTIAL:"partial",SUCCESS:"success",PAUSED:"paused"},ot={FREE:"free",STANDARD:"standard",SPONSORED:"sponsored",ENTERPRISE:"enterprise",SUSPENDED:"suspended",TERMINATING:"terminating",TERMINATED:"terminated"};(function(n){n.Validation="validation_failed",n.NotFound="not_found",n.RateLimit="rate_limit_exceeded",n.Authentication="authentication_failed",n.Business="business_logic_error",n.Api="internal_server_error",n.Network="network_error",n.Cancelled="operation_cancelled",n.File="file_error",n.Config="config_error"})(f||(f={}));Y={client:new Set([f.Business,f.Config,f.File,f.Validation]),network:new Set([f.Network]),auth:new Set([f.Authentication])},a=class n extends Error{type;status;details;constructor(t,e,i,o){super(e),this.type=t,this.status=i,this.details=o,this.name="ShipError"}toResponse(){let t=this.type===f.Authentication&&this.details?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:t}}static fromResponse(t){return new n(t.error,t.message,t.status,t.details)}static validation(t,e){return new n(f.Validation,t,400,e)}static notFound(t,e){let i=e?`${t} ${e} not found`:`${t} not found`;return new n(f.NotFound,i,404)}static rateLimit(t="Too many requests"){return new n(f.RateLimit,t,429)}static authentication(t="Authentication required",e){return new n(f.Authentication,t,401,e)}static business(t,e=400){return new n(f.Business,t,e)}static network(t,e){return new n(f.Network,t,void 0,{cause:e})}static cancelled(t){return new n(f.Cancelled,t)}static file(t,e){return new n(f.File,t,void 0,{filePath:e})}static config(t,e){return new n(f.Config,t,void 0,e)}static api(t,e=500){return new n(f.Api,t,e)}static database(t,e=500){return new n(f.Api,t,e)}static storage(t,e=500){return new n(f.Api,t,e)}get filePath(){return this.details?.filePath}isClientError(){return Y.client.has(this.type)}isNetworkError(){return Y.network.has(this.type)}isAuthError(){return Y.auth.has(this.type)}isValidationError(){return this.type===f.Validation}isFileError(){return this.type===f.File}isConfigError(){return this.type===f.Config}isType(t){return this.type===t}};He=new Set(["exe","msi","dll","scr","bat","cmd","com","pif","app","deb","rpm","pkg","mpkg","dmg","iso","img","cab","cpl","chm","ps1","vbs","vbe","ws","wsf","wsc","wsh","reg","jar","jnlp","apk","crx","lnk","inf","hta"]);Ke=/[\x00-\x1f\x7f#?%\\<>"]/;J=new Set(["node_modules","package.json"]);P="ship-",W=64,he=P.length+W,rt=4,O="token-",X=64,ye=O.length+X,st={JWT:"jwt",API_KEY:"apiKey",TOKEN:"token",WEBHOOK:"webhook",SYSTEM:"system"},Q="ship.json",De={rewrites:[{source:"/(.*)",destination:"/index.html"}]};K="https://api.shipstatic.com",D={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:"._-"},Ee=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/;L={MIN_LENGTH:6,MAX_LENGTH:128}});function ee(n){Z=n}function _(){if(Z===null)throw a.config("Platform configuration not initialized. The SDK must fetch configuration from the API before performing operations.");return Z}var Z,U=v(()=>{"use strict";S();Z=null});function It(n){ne=n}function Ge(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function R(){return ne||Ge()}var ne,F=v(()=>{"use strict";ne=null});async function je(n){let t=(await import("spark-md5")).default;return new Promise((e,i)=>{let r=Math.ceil(n.size/2097152),l=0,c=new t.ArrayBuffer,s=new FileReader,p=()=>{let u=l*2097152,y=Math.min(u+2097152,n.size);s.readAsArrayBuffer(n.slice(u,y))};s.onload=u=>{let y=u.target?.result;if(!y){i(a.business("Failed to read file chunk"));return}c.append(y),l++,l<r?p():e({md5:c.end()})},s.onerror=()=>{i(a.business("Failed to calculate MD5: FileReader error"))},p()})}async function Ve(n){let t=await import("crypto");if(Buffer.isBuffer(n)){let i=t.createHash("md5");return i.update(n),{md5:i.digest("hex")}}let e=await import("fs");return new Promise((i,o)=>{let r=t.createHash("md5"),l=e.createReadStream(n);l.on("error",c=>o(a.business(`Failed to read file for MD5: ${c.message}`))),l.on("data",c=>r.update(c)),l.on("end",()=>i({md5:r.digest("hex")}))})}async function G(n){let t=R();if(t==="browser"){if(!(n instanceof Blob))throw a.business("Invalid input for browser MD5 calculation: Expected Blob or File.");return je(n)}if(t==="node"){if(!(Buffer.isBuffer(n)||typeof n=="string"))throw a.business("Invalid input for Node.js MD5 calculation: Expected Buffer or file path string.");return Ve(n)}throw a.business("Unknown or unsupported execution environment for MD5 calculation.")}var j=v(()=>{"use strict";F();S()});import{isJunk as Xe}from"junk";function Pe(n,t){if(!n||n.length===0)return[];if(!t?.allowUnbuilt&&n.find(i=>i&&H(i)))throw a.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return n.filter(e=>{if(!e)return!1;let i=e.replace(/\\/g,"/").split("/").filter(Boolean);if(i.length===0)return!0;let o=i[i.length-1];if(Xe(o))return!1;for(let l of i)if(l!==".well-known"&&(l.startsWith(".")||l.length>255))return!1;let r=i.slice(0,-1);for(let l of r)if(Je.some(c=>l.toLowerCase()===c.toLowerCase()))return!1;return!0})}var Je,re=v(()=>{"use strict";S();Je=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function Oe(n){if(!n||n.length===0)return"";let t=n.filter(r=>r&&typeof r=="string").map(r=>r.replace(/\\/g,"/"));if(t.length===0)return"";if(t.length===1)return t[0];let e=t.map(r=>r.split("/").filter(Boolean)),i=[],o=Math.min(...e.map(r=>r.length));for(let r=0;r<o;r++){let l=e[0][r];if(e.every(c=>c[r]===l))i.push(l);else break}return i.join("/")}function q(n){return n.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var se=v(()=>{"use strict"});function Ne(n,t={}){if(t.flatten===!1)return n.map(i=>({path:q(i),name:ae(i)}));let e=Qe(n);return n.map(i=>{let o=q(i);if(e){let r=e.endsWith("/")?e:`${e}/`;o.startsWith(r)&&(o=o.substring(r.length))}return o||(o=ae(i)),{path:o,name:ae(i)}})}function Qe(n){if(!n.length)return"";let e=n.map(r=>q(r)).map(r=>r.split("/")),i=[],o=Math.min(...e.map(r=>r.length));for(let r=0;r<o-1;r++){let l=e[0][r];if(e.every(c=>c[r]===l))i.push(l);else break}return i.join("/")}function ae(n){return n.split(/[/\\]/).pop()||n}var le=v(()=>{"use strict";se()});function pe(n,t=1){if(n===0)return"0 Bytes";let e=1024,i=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(n)/Math.log(e));return parseFloat((n/Math.pow(e,o)).toFixed(t))+" "+i[o]}function ce(n){if(ge(n))return{valid:!1,reason:"File name contains unsafe characters"};if(n.startsWith(" ")||n.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(n.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let t=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,e=n.split("/").pop()||n;return t.test(e)?{valid:!1,reason:"File name uses a reserved system name"}:n.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function ln(n,t){let e=[],i=[],o=[];if(n.length===0){let s={file:"(no files)",message:"At least one file must be provided"};return e.push(s),{files:[],validFiles:[],errors:e,warnings:[],canDeploy:!1}}for(let s of n)if(H(s.name))return e.push({file:s.name,message:"Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder"}),{files:n.map(p=>({...p,status:D.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:e,warnings:[],canDeploy:!1};if(n.length>t.maxFilesCount){let s={file:`(${n.length} files)`,message:`File count (${n.length}) exceeds limit of ${t.maxFilesCount}`};return e.push(s),{files:n.map(p=>({...p,status:D.VALIDATION_FAILED,statusMessage:s.message})),validFiles:[],errors:e,warnings:[],canDeploy:!1}}let r=0;for(let s of n){let p=D.READY,u="Ready for upload",y=s.name?ce(s.name):{valid:!1,reason:"File name cannot be empty"};if(s.status===D.PROCESSING_ERROR)p=D.VALIDATION_FAILED,u=s.statusMessage||"File failed during processing",e.push({file:s.name,message:u});else if(s.size===0){p=D.EXCLUDED,u="File is empty (0 bytes) and cannot be deployed due to storage limitations",i.push({file:s.name,message:u}),o.push({...s,status:p,statusMessage:u});continue}else s.size<0?(p=D.VALIDATION_FAILED,u="File size must be positive",e.push({file:s.name,message:u})):!s.name||s.name.trim().length===0?(p=D.VALIDATION_FAILED,u="File name cannot be empty",e.push({file:s.name||"(empty)",message:u})):s.name.includes("\0")?(p=D.VALIDATION_FAILED,u="File name contains invalid characters (null byte)",e.push({file:s.name,message:u})):y.valid?B(s.name)?(p=D.VALIDATION_FAILED,u=`File extension not allowed: "${s.name}"`,e.push({file:s.name,message:u})):s.size>t.maxFileSize?(p=D.VALIDATION_FAILED,u=`File size (${pe(s.size)}) exceeds limit of ${pe(t.maxFileSize)}`,e.push({file:s.name,message:u})):(r+=s.size,r>t.maxTotalSize&&(p=D.VALIDATION_FAILED,u=`Total size would exceed limit of ${pe(t.maxTotalSize)}`,e.push({file:s.name,message:u}))):(p=D.VALIDATION_FAILED,u=y.reason||"Invalid file name",e.push({file:s.name,message:u}));o.push({...s,status:p,statusMessage:u})}e.length>0&&(o=o.map(s=>s.status===D.EXCLUDED?s:{...s,status:D.VALIDATION_FAILED,statusMessage:s.status===D.VALIDATION_FAILED?s.statusMessage:"Deployment failed due to validation errors in bundle"}));let l=e.length===0?o.filter(s=>s.status===D.READY):[],c=e.length===0;return{files:o,validFiles:l,errors:e,warnings:i,canDeploy:c}}function Ze(n){return n.filter(t=>t.status===D.READY)}function pn(n){return Ze(n).length>0}var ue=v(()=>{"use strict";S()});function Fe(n,t){if(n.includes("\0")||n.includes("/../")||n.startsWith("../")||n.endsWith("/.."))throw a.business(`Security error: Unsafe file path "${n}" for file: ${t}`)}function ke(n,t){let e=ce(n);if(!e.valid)throw a.business(e.reason||"Invalid file name");if(B(n))throw a.business(`File extension not allowed: "${t}"`)}var de=v(()=>{"use strict";S();ue()});var _e={};Be(_e,{processFilesForNode:()=>$e});import*as E from"fs";import*as A from"path";function Le(n,t=new Set){let e=[],i=E.realpathSync(n);if(t.has(i))return e;t.add(i);let o=E.readdirSync(n);for(let r of o){let l=A.join(n,r),c=E.statSync(l);if(c.isDirectory()){let s=Le(l,t);e.push(...s)}else c.isFile()&&e.push(l)}return e}async function $e(n,t={}){if(R()!=="node")throw a.business("processFilesForNode can only be called in Node.js environment.");for(let d of n){let h=A.resolve(d);try{if(E.statSync(h).isDirectory()){let w=E.readdirSync(h).find(T=>J.has(T));if(w)throw a.business(`"${w}" detected \u2014 deploy your build output (dist/, build/, out/), not the project folder`)}}catch(w){if(C(w))throw w}}let e=n.flatMap(d=>{let h=A.resolve(d);try{return E.statSync(h).isDirectory()?Le(h):[h]}catch{throw a.file(`Path does not exist: ${d}`,d)}}),i=[...new Set(e)],o=n.map(d=>A.resolve(d)),r=Oe(o.map(d=>{try{return E.statSync(d).isDirectory()?d:A.dirname(d)}catch{return A.dirname(d)}})),l=i.map(d=>{if(r&&r.length>0){let h=A.relative(r,d);if(h&&typeof h=="string"&&!h.startsWith(".."))return h.replace(/\\/g,"/")}return A.basename(d)}),s=Ne(l,{flatten:t.pathDetect!==!1}).map(d=>d.path),p=new Set(Pe(s));if(p.size===0)return[];let u=[],y=[];for(let d=0;d<i.length;d++)p.has(s[d])&&(u.push(i[d]),y.push(s[d]));let x=[],b=0,g=_();for(let d=0;d<u.length;d++){let h=u[d],w=y[d];try{Fe(w,h);let T=E.statSync(h);if(T.size===0)continue;if(ke(w,h),T.size>g.maxFileSize)throw a.business(`File ${h} is too large. Maximum allowed size is ${g.maxFileSize/(1024*1024)}MB.`);if(b+=T.size,b>g.maxTotalSize)throw a.business(`Total deploy size is too large. Maximum allowed is ${g.maxTotalSize/(1024*1024)}MB.`);let k=E.readFileSync(h),{md5:Ue}=await G(k);x.push({path:w,content:k,size:k.length,md5:Ue})}catch(T){if(C(T))throw T;let k=T instanceof Error?T.message:String(T);throw a.file(`Failed to read file "${h}": ${k}`,h)}}if(x.length>g.maxFilesCount)throw a.business(`Too many files to deploy. Maximum allowed is ${g.maxFilesCount} files.`);return x}var fe=v(()=>{"use strict";F();j();re();de();S();U();le();se()});S();var z=class{constructor(){this.handlers=new Map}on(t,e){this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(e)}off(t,e){let i=this.handlers.get(t);i&&(i.delete(e),i.size===0&&this.handlers.delete(t))}emit(t,...e){let i=this.handlers.get(t);if(!i)return;let o=Array.from(i);for(let r of o)try{r(...e)}catch(l){i.delete(r),t!=="error"&&setTimeout(()=>{l instanceof Error?this.emit("error",l,String(t)):this.emit("error",new Error(String(l)),String(t))},0)}}transfer(t){this.handlers.forEach((e,i)=>{e.forEach(o=>{t.on(i,o)})})}clear(){this.handlers.clear()}};S();function Ae(n){if(n!=null){if(typeof n!="string")throw a.validation("Password must be a string");if(n.length<L.MIN_LENGTH||n.length>L.MAX_LENGTH)throw a.validation(`Password must be between ${L.MIN_LENGTH} and ${L.MAX_LENGTH} characters`)}}function $(n){if(n==null)return;if(n.length===0)return n;if(n.length>I.MAX_COUNT)throw a.validation(`Maximum ${I.MAX_COUNT} labels allowed`);let t=n.map((i,o)=>{if(typeof i!="string")throw a.validation(`Label at index ${o} must be a string`);let r=i.trim().toLowerCase();if(r.length<I.MIN_LENGTH)throw a.validation(`Labels must be at least ${I.MIN_LENGTH} characters long`);if(r.length>I.MAX_LENGTH)throw a.validation(`Labels must be no more than ${I.MAX_LENGTH} characters long`);if(!Ee.test(r))throw a.validation(`Labels must start and end with alphanumeric characters, with optional separators (${I.SEPARATORS}) between segments`);return r}),e=[...new Set(t)];if(e.length!==t.length)throw a.validation("Duplicate labels are not allowed");return e}var m={DEPLOYMENTS:"/deployments",DOMAINS:"/domains",TOKENS:"/tokens",ACCOUNT:"/account",CONFIG:"/config",PING:"/ping",SPA_CHECK:"/spa-check"},ze=3e4,N=class extends z{constructor(e){super();this.globalHeaders={};this.apiUrl=e.apiUrl||K,this.getAuthHeadersCallback=e.getAuthHeaders,this.useCredentials=e.useCredentials??!1,this.timeout=e.timeout??ze,this.createDeployBody=e.createDeployBody,this.deployEndpoint=e.deployEndpoint||m.DEPLOYMENTS}setGlobalHeaders(e){this.globalHeaders=e}transferEventsTo(e){this.transfer(e)}async executeRequest(e,i,o){let r=this.mergeHeaders(i.headers),{signal:l,cleanup:c}=this.createTimeoutSignal(i.signal),s={...i,headers:r,credentials:this.useCredentials&&!r.Authorization?"include":void 0,signal:l};this.emit("request",e,s);try{let p=await fetch(e,s);return c(),p.ok||await this.handleResponseError(p,o),this.emit("response",this.safeClone(p),e),{data:await this.parseResponse(this.safeClone(p)),status:p.status}}catch(p){c();let u=p instanceof Error?p:new Error(String(p));this.emit("error",u,e),this.handleFetchError(p,o)}}async request(e,i,o){let{data:r}=await this.executeRequest(e,i,o);return r}async requestWithStatus(e,i,o){return this.executeRequest(e,i,o)}mergeHeaders(e={}){return{...this.globalHeaders,...this.getAuthHeadersCallback(),...e}}createTimeoutSignal(e){let i=new AbortController,o=setTimeout(()=>i.abort(),this.timeout);if(e){let r=()=>i.abort();e.addEventListener("abort",r),e.aborted&&i.abort()}return{signal:i.signal,cleanup:()=>clearTimeout(o)}}safeClone(e){try{return e.clone()}catch{return e}}async parseResponse(e){if(!(e.headers.get("Content-Length")==="0"||e.status===204))return e.json()}async handleResponseError(e,i){let o={};try{if(e.headers.get("content-type")?.includes("application/json")){let c=await e.json();if(c&&typeof c=="object"){let s=c;typeof s.message=="string"&&(o.message=s.message),typeof s.error=="string"&&(o.error=s.error)}}else o={message:await e.text()}}catch{o={message:"Failed to parse error response"}}let r=o.message||o.error||`${i} failed`;throw e.status===401?a.authentication(r):e.status===429?a.rateLimit(r):a.api(r,e.status)}handleFetchError(e,i){throw C(e)?e:e instanceof Error&&e.name==="AbortError"?a.cancelled(`${i} was cancelled`):e instanceof TypeError&&e.message.includes("fetch")?a.network(`${i} failed: ${e.message}`,e):e instanceof Error?a.business(`${i} failed: ${e.message}`):a.business(`${i} failed: Unknown error`)}async deploy(e,i={}){if(!e.length)throw a.business("No files to deploy");for(let p of e)if(!p.md5)throw a.file(`MD5 checksum missing for file: ${p.path}`,p.path);Ae(i.password);let o=$(i.labels),r=i.build||i.prerender||i.spa?{build:i.build,prerender:i.prerender,spa:i.spa}:void 0,{body:l,headers:c}=await this.createDeployBody(e,{labels:o,via:i.via,password:i.password,flags:r}),s={};return i.deployToken?s.Authorization=`Bearer ${i.deployToken}`:i.apiKey&&(s.Authorization=`Bearer ${i.apiKey}`),i.caller&&(s["X-Caller"]=i.caller),this.request(`${i.apiUrl||this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:l,headers:{...c,...s},signal:i.signal||null},"Deploy")}async listDeployments(){return this.request(`${this.apiUrl}${m.DEPLOYMENTS}`,{method:"GET"},"List deployments")}async getDeployment(e){return this.request(`${this.apiUrl}${m.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"GET"},"Get deployment")}async updateDeploymentLabels(e,i){let o=$(i);return this.request(`${this.apiUrl}${m.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:o})},"Update deployment labels")}async removeDeployment(e){await this.request(`${this.apiUrl}${m.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove deployment")}async setDomain(e,i,o){let r=$(o),l={};i&&(l.deployment=i),r!==void 0&&(l.labels=r);let{data:c,status:s}=await this.requestWithStatus(`${this.apiUrl}${m.DOMAINS}/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)},"Set domain");return{...c,isCreate:s===201}}async listDomains(){return this.request(`${this.apiUrl}${m.DOMAINS}`,{method:"GET"},"List domains")}async getDomain(e){return this.request(`${this.apiUrl}${m.DOMAINS}/${encodeURIComponent(e)}`,{method:"GET"},"Get domain")}async removeDomain(e){await this.request(`${this.apiUrl}${m.DOMAINS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove domain")}async verifyDomain(e){return this.request(`${this.apiUrl}${m.DOMAINS}/${encodeURIComponent(e)}/verify`,{method:"POST"},"Verify domain")}async getDomainDns(e){return this.request(`${this.apiUrl}${m.DOMAINS}/${encodeURIComponent(e)}/dns`,{method:"GET"},"Get domain DNS")}async getDomainRecords(e){return this.request(`${this.apiUrl}${m.DOMAINS}/${encodeURIComponent(e)}/records`,{method:"GET"},"Get domain records")}async getDomainShare(e){return this.request(`${this.apiUrl}${m.DOMAINS}/${encodeURIComponent(e)}/share`,{method:"GET"},"Get domain share")}async validateDomain(e){return this.request(`${this.apiUrl}${m.DOMAINS}/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:e})},"Validate domain")}async createToken(e,i){let o=$(i),r={};return e!==void 0&&(r.ttl=e),o!==void 0&&(r.labels=o),this.request(`${this.apiUrl}${m.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)},"Create token")}async listTokens(){return this.request(`${this.apiUrl}${m.TOKENS}`,{method:"GET"},"List tokens")}async removeToken(e){await this.request(`${this.apiUrl}${m.TOKENS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove token")}async fetchAgentToken(){return this.request(`${this.apiUrl}${m.TOKENS}/agent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})},"Fetch agent token")}async getAccount(){return this.request(`${this.apiUrl}${m.ACCOUNT}`,{method:"GET"},"Get account")}async getConfig(){return this.request(`${this.apiUrl}${m.CONFIG}`,{method:"GET"},"Get config")}async ping(){return(await this.request(`${this.apiUrl}${m.PING}`,{method:"GET"},"Ping"))?.success||!1}async checkSPA(e,i={}){let o=e.find(p=>p.path==="index.html"||p.path==="/index.html");if(!o||o.size>100*1024)return!1;let r;if(typeof Buffer<"u"&&Buffer.isBuffer(o.content))r=o.content.toString("utf-8");else if(typeof Blob<"u"&&o.content instanceof Blob)r=await o.content.text();else if(typeof File<"u"&&o.content instanceof File)r=await o.content.text();else return!1;let l={"Content-Type":"application/json"};i.deployToken?l.Authorization=`Bearer ${i.deployToken}`:i.apiKey&&(l.Authorization=`Bearer ${i.apiKey}`);let c={files:e.map(p=>p.path),index:r};return(await this.request(`${this.apiUrl}${m.SPA_CHECK}`,{method:"POST",headers:l,body:JSON.stringify(c)},"SPA check")).isSPA}};S();U();S();S();function te(n={},t={}){let e={apiUrl:n.apiUrl||t.apiUrl||K,apiKey:n.apiKey!==void 0?n.apiKey:t.apiKey,deployToken:n.deployToken!==void 0?n.deployToken:t.deployToken},i={apiUrl:e.apiUrl};return e.apiKey!==void 0&&(i.apiKey=e.apiKey),e.deployToken!==void 0&&(i.deployToken=e.deployToken),i}function we(n,t){let e={...n};return e.apiUrl===void 0&&t.apiUrl!==void 0&&(e.apiUrl=t.apiUrl),e.apiKey===void 0&&t.apiKey!==void 0&&(e.apiKey=t.apiKey),e.deployToken===void 0&&t.deployToken!==void 0&&(e.deployToken=t.deployToken),e.timeout===void 0&&t.timeout!==void 0&&(e.timeout=t.timeout),e.maxConcurrency===void 0&&t.maxConcurrency!==void 0&&(e.maxConcurrency=t.maxConcurrency),e.onProgress===void 0&&t.onProgress!==void 0&&(e.onProgress=t.onProgress),e.caller===void 0&&t.caller!==void 0&&(e.caller=t.caller),e}S();j();async function qe(){let n=JSON.stringify(De,null,2),t;typeof Buffer<"u"?t=Buffer.from(n,"utf-8"):t=new Blob([n],{type:"application/json"});let{md5:e}=await G(t);return{path:Q,content:t,size:n.length,md5:e}}async function Te(n,t,e){if(e.spaDetect===!1||e.spa||e.build||e.prerender||n.some(i=>i.path===Q))return n;try{if(await t.checkSPA(n,e)){let o=await qe();return[...n,o]}}catch{}return n}function ve(n){let{getApi:t,ensureInit:e,processInput:i,clientDefaults:o,hasAuth:r}=n;return{upload:async(l,c={})=>{await e();let s=o?we(c,o):c;if(r&&!r()&&!s.deployToken&&!s.apiKey)try{let y=t(),{secret:x}=await y.fetchAgentToken();s.deployToken=x}catch(y){throw C(y)&&y.type===f.RateLimit?a.rateLimit("public deploy rate limit exceeded, try again later or run 'ship config' for a free account with higher limits"):y}if(!i)throw a.config("processInput function is not provided.");let p=t(),u=await i(l,s);return u=await Te(u,p,s),p.deploy(u,s)},list:async()=>(await e(),t().listDeployments()),get:async l=>(await e(),t().getDeployment(l)),set:async(l,c)=>(await e(),t().updateDeploymentLabels(l,c.labels)),remove:async l=>{await e(),await t().removeDeployment(l)}}}function Ce(n){let{getApi:t,ensureInit:e}=n;return{set:async(i,o={})=>(await e(),t().setDomain(i,o.deployment,o.labels)),list:async()=>(await e(),t().listDomains()),get:async i=>(await e(),t().getDomain(i)),remove:async i=>{await e(),await t().removeDomain(i)},verify:async i=>(await e(),t().verifyDomain(i)),validate:async i=>(await e(),t().validateDomain(i)),dns:async i=>(await e(),t().getDomainDns(i)),records:async i=>(await e(),t().getDomainRecords(i)),share:async i=>(await e(),t().getDomainShare(i))}}function Re(n){let{getApi:t,ensureInit:e}=n;return{get:async()=>(await e(),t().getAccount())}}function xe(n){let{getApi:t,ensureInit:e}=n;return{create:async(i={})=>(await e(),t().createToken(i.ttl,i.labels)),list:async()=>(await e(),t().listTokens()),remove:async i=>{await e(),await t().removeToken(i)}}}var V=class{constructor(t={}){this.initPromise=null;this._config=null;this.auth=null;this.customHeaders={};this.clientOptions=t,t.deployToken?this.auth={type:"token",value:t.deployToken}:t.apiKey&&(this.auth={type:"apiKey",value:t.apiKey}),this.authHeadersCallback=()=>this.getAuthHeaders();let e=this.resolveInitialConfig(t);this.http=new N({...t,...e,getAuthHeaders:this.authHeadersCallback,createDeployBody:this.getDeployBodyCreator()});let i={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this._deployments=ve({...i,processInput:(o,r)=>this.processInput(o,r),clientDefaults:this.clientOptions,hasAuth:()=>this.hasAuth()}),this._domains=Ce(i),this._account=Re(i),this._tokens=xe(i)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.loadFullConfig()),this.initPromise}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(t,e){return this.deployments.upload(t,e)}async whoami(){return this.account.get()}get deployments(){return this._deployments}get domains(){return this._domains}get account(){return this._account}get tokens(){return this._tokens}async getConfig(){return this._config?this._config:(await this.ensureInitialized(),this._config=_(),this._config)}on(t,e){this.http.on(t,e)}off(t,e){this.http.off(t,e)}setHeaders(t){this.customHeaders=t,this.http.setGlobalHeaders(t)}clearHeaders(){this.customHeaders={},this.http.setGlobalHeaders({})}replaceHttpClient(t){if(this.http?.transferEventsTo)try{this.http.transferEventsTo(t)}catch(e){console.warn("Event transfer failed during client replacement:",e)}this.http=t,Object.keys(this.customHeaders).length>0&&this.http.setGlobalHeaders(this.customHeaders)}setDeployToken(t){if(!t||typeof t!="string")throw a.business("Invalid deploy token provided. Deploy token must be a non-empty string.");this.auth={type:"token",value:t}}setApiKey(t){if(!t||typeof t!="string")throw a.business("Invalid API key provided. API key must be a non-empty string.");this.auth={type:"apiKey",value:t}}getAuthHeaders(){return this.auth?{Authorization:`Bearer ${this.auth.value}`}:{}}hasAuth(){return this.clientOptions.useCredentials?!0:this.auth!==null}};S();F();S();F();import{z as M}from"zod";var ie="ship",Ye=M.object({apiUrl:M.string().url().optional(),apiKey:M.string().min(1).optional(),deployToken:M.string().min(1).optional()}).strict();function be(n){try{return Ye.parse(n)}catch(t){if(t instanceof M.ZodError){let e=t.issues[0],i=e.path.length>0?` at ${e.path.join(".")}`:"";throw a.config(`Configuration validation failed${i}: ${e.message}`)}throw a.config("Configuration validation failed")}}async function We(n){try{if(R()!=="node")return{};let{cosmiconfigSync:t}=await import("cosmiconfig"),e=await import("os"),i=t(ie,{searchPlaces:[`.${ie}rc`,"package.json",`${e.homedir()}/.${ie}rc`],stopDir:e.homedir()}),o;if(n?o=i.load(n):o=i.search(),o&&o.config)return be(o.config)}catch(t){if(C(t))throw t}return{}}async function oe(n){if(R()!=="node")return{};let t={apiUrl:process.env.SHIP_API_URL||void 0,apiKey:process.env.SHIP_API_KEY||void 0,deployToken:process.env.SHIP_DEPLOY_TOKEN||void 0},e=await We(n),i={apiUrl:t.apiUrl??e.apiUrl,apiKey:t.apiKey??e.apiKey,deployToken:t.deployToken??e.deployToken};return be(i)}U();S();async function Ie(n,t={}){let{FormData:e,File:i}=await import("formdata-node"),{FormDataEncoder:o}=await import("form-data-encoder"),{labels:r,via:l,password:c,flags:s}=t,p=new e,u=[];for(let g of n){if(!Buffer.isBuffer(g.content)&&!(typeof Blob<"u"&&g.content instanceof Blob))throw a.file(`Unsupported file.content type for Node.js: ${g.path}`,g.path);if(!g.md5)throw a.file(`File missing md5 checksum: ${g.path}`,g.path);let d=new i([g.content],g.path,{type:"application/octet-stream"});p.append("files[]",d),u.push(g.md5)}p.append("checksums",JSON.stringify(u)),r&&r.length>0&&p.append("labels",JSON.stringify(r)),l&&p.append("via",l),c&&p.append("password",c),s?.build&&p.append("build","true"),s?.prerender&&p.append("prerender","true"),s?.spa&&p.append("spa","true");let y=new o(p),x=[];for await(let g of y.encode())x.push(Buffer.from(g));let b=Buffer.concat(x);return{body:b.buffer.slice(b.byteOffset,b.byteOffset+b.byteLength),headers:{"Content-Type":y.contentType,"Content-Length":Buffer.byteLength(b).toString()}}}j();function Qt(n,t,e,i=!0){let o=n===1?t:e;return i?`${n} ${o}`:o}re();le();F();ue();de();S();U();fe();var me=class extends V{constructor(t={}){if(R()!=="node")throw a.business("Node.js Ship class can only be used in Node.js environment.");super(t)}resolveInitialConfig(t){return te(t,{})}async loadFullConfig(){try{let t=await oe(this.clientOptions.configFile),e=te(this.clientOptions,t);e.deployToken&&!this.clientOptions.deployToken?this.setDeployToken(e.deployToken):e.apiKey&&!this.clientOptions.apiKey&&this.setApiKey(e.apiKey);let i=new N({...this.clientOptions,...e,getAuthHeaders:this.authHeadersCallback,createDeployBody:this.getDeployBodyCreator()});this.replaceHttpClient(i);let o=await this.http.getConfig();ee(o)}catch(t){throw this.initPromise=null,t}}async processInput(t,e){let i=typeof t=="string"?[t]:t;if(!Array.isArray(i)||!i.every(r=>typeof r=="string"))throw a.business("Invalid input type for Node.js environment. Expected string or string[].");if(i.length===0)throw a.business("No files to deploy.");let{processFilesForNode:o}=await Promise.resolve().then(()=>(fe(),_e));return o(i,e)}getDeployBodyCreator(){return Ie}},et=me;export{W as API_KEY_HEX_LENGTH,rt as API_KEY_HINT_LENGTH,P as API_KEY_PREFIX,he as API_KEY_TOTAL_LENGTH,ot as AccountPlan,N as ApiHttp,st as AuthMethod,He as BLOCKED_EXTENSIONS,K as DEFAULT_API,Q as DEPLOYMENT_CONFIG_FILENAME,X as DEPLOY_TOKEN_HEX_LENGTH,O as DEPLOY_TOKEN_PREFIX,ye as DEPLOY_TOKEN_TOTAL_LENGTH,nt as DeploymentStatus,it as DomainStatus,f as ErrorType,D as FILE_VALIDATION_STATUS,D as FileValidationStatus,Je as JUNK_DIRECTORIES,I as LABEL_CONSTRAINTS,Ee as LABEL_PATTERN,L as PASSWORD_CONSTRAINTS,De as SPA_DEFAULT_CONFIG,me as Ship,a as ShipError,J as UNBUILT_PROJECT_MARKERS,Ke as UNSAFE_FILENAME_CHARS,It as __setTestEnvironment,pn as allValidFilesReady,G as calculateMD5,Re as createAccountResource,ve as createDeploymentResource,Ce as createDomainResource,xe as createTokenResource,et as default,yt as deserializeLabels,dt as extractSubdomain,Pe as filterJunk,pe as formatFileSize,ft as generateDeploymentUrl,mt as generateDomainUrl,_ as getCurrentConfig,R as getENV,Ze as getValidFiles,H as hasUnbuiltMarker,ge as hasUnsafeChars,B as isBlockedExtension,ut as isCustomDomain,ct as isDeployment,Se as isPlatformDomain,C as isShipError,oe as loadConfig,we as mergeDeployOptions,Ne as optimizeDeployPaths,Qt as pluralize,$e as processFilesForNode,te as resolveConfig,ht as serializeLabels,ee as setPlatformConfig,at as validateApiKey,pt as validateApiUrl,ke as validateDeployFile,Fe as validateDeployPath,lt as validateDeployToken,ce as validateFileName,ln as validateFiles};
1
+ var Ne=Object.defineProperty;var R=(n,t)=>()=>(n&&(t=n(n=0)),t);var Ce=(n,t)=>{for(var e in t)Ne(n,e,{get:t[e],enumerable:!0})};function b(n){return n!==null&&typeof n=="object"&&"name"in n&&n.name==="ShipError"&&"status"in n}function $(n){let t=n.lastIndexOf(".");if(t===-1||t===n.length-1)return!1;let e=n.slice(t+1).toLowerCase();return Fe.has(e)}function oe(n){return Oe.test(n)}function U(n){return n.replace(/\\/g,"/").split("/").filter(Boolean).some(e=>j.has(e))}function Qe(n){if(!n.startsWith(x.PREFIX))throw a.validation(`API key must start with "${x.PREFIX}"`);if(n.length!==x.TOTAL_LENGTH)throw a.validation(`API key must be ${x.TOTAL_LENGTH} characters total (${x.PREFIX} + ${x.HEX_LENGTH} hex chars)`);let t=n.slice(x.PREFIX.length);if(!/^[a-f0-9]{64}$/i.test(t))throw a.validation(`API key must contain ${x.HEX_LENGTH} hexadecimal characters after "${x.PREFIX}" prefix`)}function Ze(n){if(!n.startsWith(I.PREFIX))throw a.validation(`Deploy token must start with "${I.PREFIX}"`);if(n.length!==I.TOTAL_LENGTH)throw a.validation(`Deploy token must be ${I.TOTAL_LENGTH} characters total (${I.PREFIX} + ${I.HEX_LENGTH} hex chars)`);let t=n.slice(I.PREFIX.length);if(!/^[a-f0-9]{64}$/i.test(t))throw a.validation(`Deploy token must contain ${I.HEX_LENGTH} hexadecimal characters after "${I.PREFIX}" prefix`)}function et(n){try{let t=new URL(n);if(!["http:","https:"].includes(t.protocol))throw a.validation("API URL must use http:// or https:// protocol");if(t.pathname!=="/"&&t.pathname!=="")throw a.validation("API URL must not contain a path");if(t.search||t.hash)throw a.validation("API URL must not contain query parameters or fragments")}catch(t){throw b(t)?t:a.validation("API URL must be a valid URL")}}function tt(n){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(n)}function le(n,t){return n.endsWith(`.${t}`)}function nt(n,t){return!le(n,t)}function it(n,t){return le(n,t)?n.slice(0,-(t.length+1)):null}function rt(n){return`https://${n}`}function st(n){return`https://${n}`}function ot(n){return!n||n.length===0?null:JSON.stringify(n)}function at(n){if(!n)return[];try{let t=JSON.parse(n);return Array.isArray(t)?t:[]}catch{return[]}}var Xe,We,Ye,m,V,a,Fe,Oe,j,x,I,Je,q,ae,_,g,P,pe,O,E=R(()=>{"use strict";Xe={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},We={PENDING:"pending",PARTIAL:"partial",SUCCESS:"success",PAUSED:"paused"},Ye={FREE:"free",STANDARD:"standard",SPONSORED:"sponsored",ENTERPRISE:"enterprise",SUSPENDED:"suspended",TERMINATING:"terminating",TERMINATED:"terminated"},m={Validation:"validation_failed",NotFound:"not_found",RateLimit:"rate_limit_exceeded",Authentication:"authentication_failed",Business:"business_logic_error",Api:"internal_server_error",Network:"network_error",Cancelled:"operation_cancelled",File:"file_error",Config:"config_error"},V={client:new Set([m.Business,m.Config,m.File,m.Validation]),network:new Set([m.Network]),auth:new Set([m.Authentication])},a=class n extends Error{type;status;details;constructor(t,e,i,r){super(e),this.type=t,this.status=i,this.details=r,this.name="ShipError"}toResponse(){let t=this.type===m.Authentication&&this.details?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:t}}static async fromHttpResponse(t,e){let i,r;try{if(t.headers.get("content-type")?.includes("application/json")){let c=await t.json();if(c&&typeof c=="object"){let o=c;typeof o.message=="string"?i=o.message:typeof o.error=="string"&&(i=o.error),r=o.details}}else{let c=await t.text();c&&(i=c)}}catch{}i=i||e||`Request failed with status ${t.status}`;let s=t.status===401?m.Authentication:t.status===429?m.RateLimit:m.Api;return new n(s,i,t.status,r)}static validation(t,e){return new n(m.Validation,t,400,e)}static notFound(t,e){let i=e?`${t} ${e} not found`:`${t} not found`;return new n(m.NotFound,i,404)}static rateLimit(t="Too many requests"){return new n(m.RateLimit,t,429)}static authentication(t="Authentication required",e){return new n(m.Authentication,t,401,e)}static business(t,e=400){return new n(m.Business,t,e)}static network(t,e){return new n(m.Network,t,void 0,{cause:e})}static cancelled(t){return new n(m.Cancelled,t)}static file(t,e){return new n(m.File,t,void 0,{filePath:e})}static config(t,e){return new n(m.Config,t,void 0,e)}static api(t,e=500){return new n(m.Api,t,e)}static database(t,e=500){return new n(m.Api,t,e)}static storage(t,e=500){return new n(m.Api,t,e)}get filePath(){return this.details?.filePath}isClientError(){return V.client.has(this.type)}isNetworkError(){return V.network.has(this.type)}isAuthError(){return V.auth.has(this.type)}isValidationError(){return this.type===m.Validation}isFileError(){return this.type===m.File}isConfigError(){return this.type===m.Config}isType(t){return this.type===t}};Fe=new Set(["exe","msi","dll","scr","bat","cmd","com","pif","app","deb","rpm","pkg","mpkg","dmg","iso","img","cab","cpl","chm","ps1","vbs","vbe","ws","wsf","wsc","wsh","reg","jar","jnlp","apk","crx","lnk","inf","hta"]);Oe=/[\x00-\x1f\x7f#?%\\<>"]/;j=new Set(["node_modules","package.json"]);x={PREFIX:"ship-",HEX_LENGTH:64,TOTAL_LENGTH:69,HINT_LENGTH:4},I={PREFIX:"token-",HEX_LENGTH:64,TOTAL_LENGTH:70},Je={JWT:"jwt",API_KEY:"apiKey",TOKEN:"token",WEBHOOK:"webhook",SYSTEM:"system"},q="ship.json",ae={rewrites:[{source:"/(.*)",destination:"/index.html"}]};_="https://api.shipstatic.com",g={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};P={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},pe=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/;O={MIN_LENGTH:6,MAX_LENGTH:128}});function Et(n){X=n}function $e(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function L(){return X||$e()}var X,C=R(()=>{"use strict";X=null});async function Ue(n){let t=(await import("spark-md5")).default;return new Promise((e,i)=>{let s=Math.ceil(n.size/2097152),l=0,c=new t.ArrayBuffer,o=new FileReader,p=()=>{let u=l*2097152,h=Math.min(u+2097152,n.size);o.readAsArrayBuffer(n.slice(u,h))};o.onload=u=>{let h=u.target?.result;if(!h){i(a.business("Failed to read file chunk"));return}c.append(h),l++,l<s?p():e({md5:c.end()})},o.onerror=()=>{i(a.business("Failed to calculate MD5: FileReader error"))},p()})}async function _e(n){let t=await import("crypto");if(Buffer.isBuffer(n)){let i=t.createHash("md5");return i.update(n),{md5:i.digest("hex")}}let e=await import("fs");return new Promise((i,r)=>{let s=t.createHash("md5"),l=e.createReadStream(n);l.on("error",c=>r(a.business(`Failed to read file for MD5: ${c.message}`))),l.on("data",c=>s.update(c)),l.on("end",()=>i({md5:s.digest("hex")}))})}async function H(n){let t=L();if(t==="browser"){if(!(n instanceof Blob))throw a.business("Invalid input for browser MD5 calculation: Expected Blob or File.");return Ue(n)}if(t==="node"){if(!(Buffer.isBuffer(n)||typeof n=="string"))throw a.business("Invalid input for Node.js MD5 calculation: Expected Buffer or file path string.");return _e(n)}throw a.business("Unknown or unsupported execution environment for MD5 calculation.")}var z=R(()=>{"use strict";C();E()});import{isJunk as ze}from"junk";function Ae(n,t){if(!n||n.length===0)return[];if(!t?.allowUnbuilt&&n.find(i=>i&&U(i)))throw a.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return n.filter(e=>{if(!e)return!1;let i=e.replace(/\\/g,"/").split("/").filter(Boolean);if(i.length===0)return!0;let r=i[i.length-1];if(ze(r))return!1;for(let l of i)if(l!==".well-known"&&(l.startsWith(".")||l.length>255))return!1;let s=i.slice(0,-1);for(let l of s)if(Ke.some(c=>l.toLowerCase()===c.toLowerCase()))return!1;return!0})}var Ke,Y=R(()=>{"use strict";E();Ke=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function we(n){if(!n||n.length===0)return"";let t=n.filter(s=>s&&typeof s=="string").map(s=>s.replace(/\\/g,"/"));if(t.length===0)return"";if(t.length===1)return t[0];let e=t.map(s=>s.split("/").filter(Boolean)),i=[],r=Math.min(...e.map(s=>s.length));for(let s=0;s<r;s++){let l=e[0][s];if(e.every(c=>c[s]===l))i.push(l);else break}return i.join("/")}function G(n){return n.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var J=R(()=>{"use strict"});function ve(n,t={}){if(t.flatten===!1)return n.map(i=>({path:G(i),name:Q(i)}));let e=Ge(n);return n.map(i=>{let r=G(i);if(e){let s=e.endsWith("/")?e:`${e}/`;r.startsWith(s)&&(r=r.substring(s.length))}return r||(r=Q(i)),{path:r,name:Q(i)}})}function Ge(n){if(!n.length)return"";let e=n.map(s=>G(s)).map(s=>s.split("/")),i=[],r=Math.min(...e.map(s=>s.length));for(let s=0;s<r-1;s++){let l=e[0][s];if(e.every(c=>c[s]===l))i.push(l);else break}return i.join("/")}function Q(n){return n.split(/[/\\]/).pop()||n}var Z=R(()=>{"use strict";J()});function ee(n,t=1){if(n===0)return"0 Bytes";let e=1024,i=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(n)/Math.log(e));return parseFloat((n/Math.pow(e,r)).toFixed(t))+" "+i[r]}function te(n){if(oe(n))return{valid:!1,reason:"File name contains unsafe characters"};if(n.startsWith(" ")||n.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(n.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let t=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,e=n.split("/").pop()||n;return t.test(e)?{valid:!1,reason:"File name uses a reserved system name"}:n.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function Zt(n,t){let e=[],i=[],r=[];if(n.length===0){let o={file:"(no files)",message:"At least one file must be provided"};return e.push(o),{files:[],validFiles:[],errors:e,warnings:[],canDeploy:!1}}for(let o of n)if(U(o.name))return e.push({file:o.name,message:"Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder"}),{files:n.map(p=>({...p,status:g.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:e,warnings:[],canDeploy:!1};if(n.length>t.maxFilesCount){let o={file:`(${n.length} files)`,message:`File count (${n.length}) exceeds limit of ${t.maxFilesCount}`};return e.push(o),{files:n.map(p=>({...p,status:g.VALIDATION_FAILED,statusMessage:o.message})),validFiles:[],errors:e,warnings:[],canDeploy:!1}}let s=0;for(let o of n){let p=g.READY,u="Ready for upload",h=o.name?te(o.name):{valid:!1,reason:"File name cannot be empty"};if(o.status===g.PROCESSING_ERROR)p=g.VALIDATION_FAILED,u=o.statusMessage||"File failed during processing",e.push({file:o.name,message:u});else if(o.size===0){p=g.EXCLUDED,u="File is empty (0 bytes) and cannot be deployed due to storage limitations",i.push({file:o.name,message:u}),r.push({...o,status:p,statusMessage:u});continue}else o.size<0?(p=g.VALIDATION_FAILED,u="File size must be positive",e.push({file:o.name,message:u})):!o.name||o.name.trim().length===0?(p=g.VALIDATION_FAILED,u="File name cannot be empty",e.push({file:o.name||"(empty)",message:u})):o.name.includes("\0")?(p=g.VALIDATION_FAILED,u="File name contains invalid characters (null byte)",e.push({file:o.name,message:u})):h.valid?$(o.name)?(p=g.VALIDATION_FAILED,u=`File extension not allowed: "${o.name}"`,e.push({file:o.name,message:u})):o.size>t.maxFileSize?(p=g.VALIDATION_FAILED,u=`File size (${ee(o.size)}) exceeds limit of ${ee(t.maxFileSize)}`,e.push({file:o.name,message:u})):(s+=o.size,s>t.maxTotalSize&&(p=g.VALIDATION_FAILED,u=`Total size would exceed limit of ${ee(t.maxTotalSize)}`,e.push({file:o.name,message:u}))):(p=g.VALIDATION_FAILED,u=h.reason||"Invalid file name",e.push({file:o.name,message:u}));r.push({...o,status:p,statusMessage:u})}e.length>0&&(r=r.map(o=>o.status===g.EXCLUDED?o:{...o,status:g.VALIDATION_FAILED,statusMessage:o.status===g.VALIDATION_FAILED?o.statusMessage:"Deployment failed due to validation errors in bundle"}));let l=e.length===0?r.filter(o=>o.status===g.READY):[],c=e.length===0;return{files:r,validFiles:l,errors:e,warnings:i,canDeploy:c}}function Ve(n){return n.filter(t=>t.status===g.READY)}function en(n){return Ve(n).length>0}var ne=R(()=>{"use strict";E()});function Re(n,t){if(n.includes("\0")||n.includes("/../")||n.startsWith("../")||n.endsWith("/.."))throw a.business(`Security error: Unsafe file path "${n}" for file: ${t}`)}function xe(n,t){let e=te(n);if(!e.valid)throw a.business(e.reason||"Invalid file name");if($(n))throw a.business(`File extension not allowed: "${t}"`)}var ie=R(()=>{"use strict";E();ne()});var Pe={};Ce(Pe,{processFilesForNode:()=>be});import*as S from"fs";import*as T from"path";function Ie(n,t=new Set){let e=[],i=S.realpathSync(n);if(t.has(i))return e;t.add(i);let r=S.readdirSync(n);for(let s of r){let l=T.join(n,s),c=S.statSync(l);if(c.isDirectory()){let o=Ie(l,t);e.push(...o)}else c.isFile()&&e.push(l)}return e}async function be(n,t={},e){if(L()!=="node")throw a.business("processFilesForNode can only be called in Node.js environment.");for(let d of n){let y=T.resolve(d);try{if(S.statSync(y).isDirectory()){let A=S.readdirSync(y).find(w=>j.has(w));if(A)throw a.business(`"${A}" detected \u2014 deploy your build output (dist/, build/, out/), not the project folder`)}}catch(A){if(b(A))throw A}}let i=n.flatMap(d=>{let y=T.resolve(d);try{return S.statSync(y).isDirectory()?Ie(y):[y]}catch{throw a.file(`Path does not exist: ${d}`,d)}}),r=[...new Set(i)],s=n.map(d=>T.resolve(d)),l=we(s.map(d=>{try{return S.statSync(d).isDirectory()?d:T.dirname(d)}catch{return T.dirname(d)}})),c=r.map(d=>{if(l&&l.length>0){let y=T.relative(l,d);if(y&&typeof y=="string"&&!y.startsWith(".."))return y.replace(/\\/g,"/")}return T.basename(d)}),p=ve(c,{flatten:t.pathDetect!==!1}).map(d=>d.path),u=new Set(Ae(p));if(u.size===0)return[];let h=[],N=[];for(let d=0;d<r.length;d++)u.has(p[d])&&(h.push(r[d]),N.push(p[d]));let v=[],D=0;if(!e)throw a.config("Platform limits not provided. processFilesForNode requires the limits argument \u2014 pass `ship.getLimits()` result.");for(let d=0;d<h.length;d++){let y=h[d],A=N[d];try{Re(A,y);let w=S.statSync(y);if(w.size===0)continue;if(xe(A,y),w.size>e.maxFileSize)throw a.business(`File ${y} is too large. Maximum allowed size is ${e.maxFileSize/(1024*1024)}MB.`);if(D+=w.size,D>e.maxTotalSize)throw a.business(`Total deploy size is too large. Maximum allowed is ${e.maxTotalSize/(1024*1024)}MB.`);let F=S.readFileSync(y),{md5:Le}=await H(F);v.push({path:A,content:F,size:F.length,md5:Le})}catch(w){if(b(w))throw w;let F=w instanceof Error?w.message:String(w);throw a.file(`Failed to read file "${y}": ${F}`,y)}}if(v.length>e.maxFilesCount)throw a.business(`Too many files to deploy. Maximum allowed is ${e.maxFilesCount} files.`);return v}var re=R(()=>{"use strict";C();z();Y();ie();E();Z();J()});E();E();var M=class{constructor(){this.handlers=new Map}on(t,e){this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(e)}off(t,e){let i=this.handlers.get(t);i&&(i.delete(e),i.size===0&&this.handlers.delete(t))}emit(t,...e){let i=this.handlers.get(t);if(!i)return;let r=Array.from(i);for(let s of r)try{s(...e)}catch(l){i.delete(s),t!=="error"&&setTimeout(()=>{let c=l instanceof Error?l:new Error(String(l));this.emit("error",c,String(t))},0)}}};E();function ce(n){if(n!=null){if(typeof n!="string")throw a.validation("Password must be a string");if(n.length<O.MIN_LENGTH||n.length>O.MAX_LENGTH)throw a.validation(`Password must be between ${O.MIN_LENGTH} and ${O.MAX_LENGTH} characters`)}}function k(n){if(n==null)return;if(n.length===0)return n;if(n.length>P.MAX_COUNT)throw a.validation(`Maximum ${P.MAX_COUNT} labels allowed`);let t=n.map((i,r)=>{if(typeof i!="string")throw a.validation(`Label at index ${r} must be a string`);let s=i.trim().toLowerCase();if(s.length<P.MIN_LENGTH)throw a.validation(`Labels must be at least ${P.MIN_LENGTH} characters long`);if(s.length>P.MAX_LENGTH)throw a.validation(`Labels must be no more than ${P.MAX_LENGTH} characters long`);if(!pe.test(s))throw a.validation(`Labels must start and end with alphanumeric characters, with optional separators (${P.SEPARATORS}) between segments`);return s}),e=[...new Set(t)];if(e.length!==t.length)throw a.validation("Duplicate labels are not allowed");return e}var f={DEPLOYMENTS:"/deployments",DOMAINS:"/domains",TOKENS:"/tokens",ACCOUNT:"/account",LIMITS:"/limits",PING:"/ping",SPA_CHECK:"/spa-check"},ke=3e4,B=class extends M{constructor(e){super();this.globalHeaders={};this.apiUrl=e.apiUrl||_,this.getAuthHeadersCallback=e.getAuthHeaders,this.useCredentials=e.useCredentials??!1,this.timeout=e.timeout??ke,this.createDeployBody=e.createDeployBody,this.deployEndpoint=e.deployEndpoint||f.DEPLOYMENTS}setGlobalHeaders(e){this.globalHeaders=e}async executeRequest(e,i,r){let s=this.mergeHeaders(i.headers),{signal:l,cleanup:c}=this.createTimeoutSignal(i.signal),o={...i,headers:s,credentials:this.useCredentials&&!s.Authorization?"include":void 0,signal:l};this.emit("request",e,o);try{let p=await fetch(e,o);return c(),p.ok||await this.handleResponseError(p,r),this.emit("response",this.safeClone(p),e),{data:await this.parseResponse(this.safeClone(p)),status:p.status}}catch(p){c();let u=p instanceof Error?p:new Error(String(p));this.emit("error",u,e),this.handleFetchError(p,r)}}async request(e,i,r){let{data:s}=await this.executeRequest(e,i,r);return s}async requestWithStatus(e,i,r){return this.executeRequest(e,i,r)}mergeHeaders(e={}){return{...this.globalHeaders,...this.getAuthHeadersCallback(),...e}}createTimeoutSignal(e){let i=new AbortController,r=setTimeout(()=>i.abort(),this.timeout);if(e){let s=()=>i.abort();e.addEventListener("abort",s),e.aborted&&i.abort()}return{signal:i.signal,cleanup:()=>clearTimeout(r)}}safeClone(e){try{return e.clone()}catch{return e}}async parseResponse(e){if(!(e.headers.get("Content-Length")==="0"||e.status===204))return e.json()}async handleResponseError(e,i){throw await a.fromHttpResponse(e,`${i} failed`)}handleFetchError(e,i){throw b(e)?e:e instanceof Error&&e.name==="AbortError"?a.cancelled(`${i} was cancelled`):e instanceof TypeError&&e.message.includes("fetch")?a.network(`${i} failed: ${e.message}`,e):e instanceof Error?a.business(`${i} failed: ${e.message}`):a.business(`${i} failed: Unknown error`)}async deploy(e,i={}){if(!e.length)throw a.business("No files to deploy");for(let p of e)if(!p.md5)throw a.file(`MD5 checksum missing for file: ${p.path}`,p.path);ce(i.password);let r=k(i.labels),s=i.build||i.prerender||i.spa?{build:i.build,prerender:i.prerender,spa:i.spa}:void 0,{body:l,headers:c}=await this.createDeployBody(e,{labels:r,via:i.via,password:i.password,flags:s}),o={};return i.deployToken?o.Authorization=`Bearer ${i.deployToken}`:i.apiKey&&(o.Authorization=`Bearer ${i.apiKey}`),i.caller&&(o["X-Caller"]=i.caller),this.request(`${i.apiUrl||this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:l,headers:{...c,...o},signal:i.signal||null},"Deploy")}async listDeployments(){return this.request(`${this.apiUrl}${f.DEPLOYMENTS}`,{method:"GET"},"List deployments")}async getDeployment(e){return this.request(`${this.apiUrl}${f.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"GET"},"Get deployment")}async updateDeploymentLabels(e,i){let r=k(i);return this.request(`${this.apiUrl}${f.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:r})},"Update deployment labels")}async removeDeployment(e){await this.request(`${this.apiUrl}${f.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove deployment")}async setDomain(e,i,r){let s=k(r),l={};i&&(l.deployment=i),s!==void 0&&(l.labels=s);let{data:c,status:o}=await this.requestWithStatus(`${this.apiUrl}${f.DOMAINS}/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)},"Set domain");return{...c,isCreate:o===201}}async listDomains(){return this.request(`${this.apiUrl}${f.DOMAINS}`,{method:"GET"},"List domains")}async getDomain(e){return this.request(`${this.apiUrl}${f.DOMAINS}/${encodeURIComponent(e)}`,{method:"GET"},"Get domain")}async removeDomain(e){await this.request(`${this.apiUrl}${f.DOMAINS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove domain")}async verifyDomain(e){return this.request(`${this.apiUrl}${f.DOMAINS}/${encodeURIComponent(e)}/verify`,{method:"POST"},"Verify domain")}async getDomainDns(e){return this.request(`${this.apiUrl}${f.DOMAINS}/${encodeURIComponent(e)}/dns`,{method:"GET"},"Get domain DNS")}async getDomainRecords(e){return this.request(`${this.apiUrl}${f.DOMAINS}/${encodeURIComponent(e)}/records`,{method:"GET"},"Get domain records")}async getDomainShare(e){return this.request(`${this.apiUrl}${f.DOMAINS}/${encodeURIComponent(e)}/share`,{method:"GET"},"Get domain share")}async validateDomain(e){return this.request(`${this.apiUrl}${f.DOMAINS}/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:e})},"Validate domain")}async createToken(e,i){let r=k(i),s={};return e!==void 0&&(s.ttl=e),r!==void 0&&(s.labels=r),this.request(`${this.apiUrl}${f.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)},"Create token")}async listTokens(){return this.request(`${this.apiUrl}${f.TOKENS}`,{method:"GET"},"List tokens")}async removeToken(e){await this.request(`${this.apiUrl}${f.TOKENS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove token")}async fetchAgentToken(){return this.request(`${this.apiUrl}${f.TOKENS}/agent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})},"Fetch agent token")}async getAccount(){return this.request(`${this.apiUrl}${f.ACCOUNT}`,{method:"GET"},"Get account")}async getLimits(){return this.request(`${this.apiUrl}${f.LIMITS}`,{method:"GET"},"Get limits")}async ping(){return(await this.request(`${this.apiUrl}${f.PING}`,{method:"GET"},"Ping"))?.success||!1}async checkSPA(e,i={}){let r=e.find(p=>p.path==="index.html"||p.path==="/index.html");if(!r||r.size>100*1024)return!1;let s;if(typeof Buffer<"u"&&Buffer.isBuffer(r.content))s=r.content.toString("utf-8");else if(typeof Blob<"u"&&r.content instanceof Blob)s=await r.content.text();else if(typeof File<"u"&&r.content instanceof File)s=await r.content.text();else return!1;let l={"Content-Type":"application/json"};i.deployToken?l.Authorization=`Bearer ${i.deployToken}`:i.apiKey&&(l.Authorization=`Bearer ${i.apiKey}`);let c={files:e.map(p=>p.path),index:s};return(await this.request(`${this.apiUrl}${f.SPA_CHECK}`,{method:"POST",headers:l,body:JSON.stringify(c)},"SPA check")).isSPA}};E();function ue(n={}){let t={apiUrl:n.apiUrl||_};return n.apiKey!==void 0&&(t.apiKey=n.apiKey),n.deployToken!==void 0&&(t.deployToken=n.deployToken),t}function de(n,t){let e={...n};return e.apiUrl===void 0&&t.apiUrl!==void 0&&(e.apiUrl=t.apiUrl),e.apiKey===void 0&&t.apiKey!==void 0&&(e.apiKey=t.apiKey),e.deployToken===void 0&&t.deployToken!==void 0&&(e.deployToken=t.deployToken),e.timeout===void 0&&t.timeout!==void 0&&(e.timeout=t.timeout),e.maxConcurrency===void 0&&t.maxConcurrency!==void 0&&(e.maxConcurrency=t.maxConcurrency),e.onProgress===void 0&&t.onProgress!==void 0&&(e.onProgress=t.onProgress),e.caller===void 0&&t.caller!==void 0&&(e.caller=t.caller),e}E();E();z();async function Me(){let n=JSON.stringify(ae,null,2),t;typeof Buffer<"u"?t=Buffer.from(n,"utf-8"):t=new Blob([n],{type:"application/json"});let{md5:e}=await H(t);return{path:q,content:t,size:n.length,md5:e}}async function me(n,t,e){if(e.spaDetect===!1||e.spa||e.build||e.prerender||n.some(i=>i.path===q))return n;try{if(await t.checkSPA(n,e)){let r=await Me();return[...n,r]}}catch{}return n}function fe(n){let{getApi:t,ensureInit:e,processInput:i,clientDefaults:r,hasAuth:s}=n;return{upload:async(l,c={})=>{await e();let o=r?de(c,r):c;if(s&&!s()&&!o.deployToken&&!o.apiKey)try{let h=t(),{secret:N}=await h.fetchAgentToken();o.deployToken=N}catch(h){throw b(h)&&h.type===m.RateLimit?a.rateLimit("public deploy rate limit exceeded, try again later or run 'ship config' for a free account with higher limits"):h}if(!i)throw a.config("processInput function is not provided.");let p=t(),u=await i(l,o);return u=await me(u,p,o),p.deploy(u,o)},list:async()=>(await e(),t().listDeployments()),get:async l=>(await e(),t().getDeployment(l)),set:async(l,c)=>(await e(),t().updateDeploymentLabels(l,c.labels)),remove:async l=>{await e(),await t().removeDeployment(l)}}}function he(n){let{getApi:t,ensureInit:e}=n;return{set:async(i,r={})=>(await e(),t().setDomain(i,r.deployment,r.labels)),list:async()=>(await e(),t().listDomains()),get:async i=>(await e(),t().getDomain(i)),remove:async i=>{await e(),await t().removeDomain(i)},verify:async i=>(await e(),t().verifyDomain(i)),validate:async i=>(await e(),t().validateDomain(i)),dns:async i=>(await e(),t().getDomainDns(i)),records:async i=>(await e(),t().getDomainRecords(i)),share:async i=>(await e(),t().getDomainShare(i))}}function ye(n){let{getApi:t,ensureInit:e}=n;return{get:async()=>(await e(),t().getAccount())}}function ge(n){let{getApi:t,ensureInit:e}=n;return{create:async(i={})=>(await e(),t().createToken(i.ttl,i.labels)),list:async()=>(await e(),t().listTokens()),remove:async i=>{await e(),await t().removeToken(i)}}}var K=class{constructor(t={}){this.initPromise=null;this.platformLimits=null;this.auth=null;t={...t,apiUrl:t.apiUrl||void 0,apiKey:t.apiKey||void 0,deployToken:t.deployToken||void 0},this.clientOptions=t,t.deployToken?this.auth={type:"token",value:t.deployToken}:t.apiKey&&(this.auth={type:"apiKey",value:t.apiKey}),this.http=new B({...t,...ue(t),getAuthHeaders:()=>this.getAuthHeaders(),createDeployBody:this.getDeployBodyCreator()});let e={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this.deployments=fe({...e,processInput:(i,r)=>this.processInput(i,r),clientDefaults:this.clientOptions,hasAuth:()=>this.hasAuth()}),this.domains=he(e),this.account=ye(e),this.tokens=ge(e)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.fetchPlatformLimits()),this.initPromise}async fetchPlatformLimits(){try{this.platformLimits=await this.http.getLimits()}catch(t){throw this.initPromise=null,t}}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(t,e){return this.deployments.upload(t,e)}async whoami(){return this.account.get()}async getLimits(){return this.platformLimits?this.platformLimits:(await this.ensureInitialized(),this.platformLimits)}on(t,e){this.http.on(t,e)}off(t,e){this.http.off(t,e)}setHeaders(t){this.http.setGlobalHeaders(t)}clearHeaders(){this.http.setGlobalHeaders({})}setDeployToken(t){if(!t||typeof t!="string")throw a.business("Invalid deploy token provided. Deploy token must be a non-empty string.");this.auth={type:"token",value:t}}setApiKey(t){if(!t||typeof t!="string")throw a.business("Invalid API key provided. API key must be a non-empty string.");this.auth={type:"apiKey",value:t}}getAuthHeaders(){return this.auth?{Authorization:`Bearer ${this.auth.value}`}:{}}hasAuth(){return this.clientOptions.useCredentials?!0:this.auth!==null}};E();C();E();C();import{z as De}from"zod";import{z as W}from"zod";var Ee={apiUrl:W.string().url().optional(),apiKey:W.string().min(1).optional(),deployToken:W.string().min(1).optional()};var Be=De.object(Ee).strict(),He={apiUrl:"SHIP_API_URL",apiKey:"SHIP_API_KEY",deployToken:"SHIP_DEPLOY_TOKEN"};function Se(){if(L()!=="node")return{};let n={apiUrl:process.env.SHIP_API_URL||void 0,apiKey:process.env.SHIP_API_KEY||void 0,deployToken:process.env.SHIP_DEPLOY_TOKEN||void 0};try{return Be.parse(n)}catch(t){if(t instanceof De.ZodError){let e=t.issues[0],i=e.path[0],r=(i&&He[i])??"SHIP environment configuration";throw a.config(`Invalid ${r}: ${e.message}`)}throw a.config("Invalid environment configuration")}}E();async function Te(n,t={}){let{FormData:e,File:i}=await import("formdata-node"),{FormDataEncoder:r}=await import("form-data-encoder"),{labels:s,via:l,password:c,flags:o}=t,p=new e,u=[];for(let D of n){if(!Buffer.isBuffer(D.content)&&!(typeof Blob<"u"&&D.content instanceof Blob))throw a.file(`Unsupported file.content type for Node.js: ${D.path}`,D.path);if(!D.md5)throw a.file(`File missing md5 checksum: ${D.path}`,D.path);let d=new i([D.content],D.path,{type:"application/octet-stream"});p.append("files[]",d),u.push(D.md5)}p.append("checksums",JSON.stringify(u)),s&&s.length>0&&p.append("labels",JSON.stringify(s)),l&&p.append("via",l),c&&p.append("password",c),o?.build&&p.append("build","true"),o?.prerender&&p.append("prerender","true"),o?.spa&&p.append("spa","true");let h=new r(p),N=[];for await(let D of h.encode())N.push(Buffer.from(D));let v=Buffer.concat(N);return{body:v.buffer.slice(v.byteOffset,v.byteOffset+v.byteLength),headers:{"Content-Type":h.contentType,"Content-Length":Buffer.byteLength(v).toString()}}}z();function Gt(n,t,e,i=!0){let r=n===1?t:e;return i?`${n} ${r}`:r}Y();Z();C();ne();ie();E();re();var se=class extends K{constructor(t={}){if(L()!=="node")throw a.business("Node.js Ship class can only be used in Node.js environment.");let e=Se();super({...t,apiUrl:t.apiUrl||e.apiUrl,apiKey:t.apiKey||e.apiKey,deployToken:t.deployToken||e.deployToken})}async deploy(t,e){return super.deploy(t,e)}async processInput(t,e){let i=typeof t=="string"?[t]:t;if(!Array.isArray(i)||!i.every(s=>typeof s=="string"))throw a.business("Invalid input type for Node.js environment. Expected string or string[].");if(i.length===0)throw a.business("No files to deploy.");let{processFilesForNode:r}=await Promise.resolve().then(()=>(re(),Pe));return r(i,e,this.platformLimits??void 0)}getDeployBodyCreator(){return Te}},je=se;export{x as API_KEY,Ye as AccountPlan,B as ApiHttp,Je as AuthMethod,Fe as BLOCKED_EXTENSIONS,_ as DEFAULT_API,q as DEPLOYMENT_CONFIG_FILENAME,I as DEPLOY_TOKEN,Xe as DeploymentStatus,We as DomainStatus,m as ErrorType,g as FILE_VALIDATION_STATUS,g as FileValidationStatus,Ke as JUNK_DIRECTORIES,P as LABEL_CONSTRAINTS,pe as LABEL_PATTERN,O as PASSWORD_CONSTRAINTS,ae as SPA_DEFAULT_CONFIG,se as Ship,a as ShipError,j as UNBUILT_PROJECT_MARKERS,Oe as UNSAFE_FILENAME_CHARS,Et as __setTestEnvironment,en as allValidFilesReady,H as calculateMD5,ye as createAccountResource,fe as createDeploymentResource,he as createDomainResource,ge as createTokenResource,je as default,at as deserializeLabels,it as extractSubdomain,Ae as filterJunk,ee as formatFileSize,rt as generateDeploymentUrl,st as generateDomainUrl,L as getENV,Ve as getValidFiles,U as hasUnbuiltMarker,oe as hasUnsafeChars,$ as isBlockedExtension,nt as isCustomDomain,tt as isDeployment,le as isPlatformDomain,b as isShipError,de as mergeDeployOptions,ve as optimizeDeployPaths,Gt as pluralize,be as processFilesForNode,ue as resolveConfig,ot as serializeLabels,Qe as validateApiKey,et as validateApiUrl,xe as validateDeployFile,Re as validateDeployPath,Ze as validateDeployToken,te as validateFileName,Zt as validateFiles};
2
2
  //# sourceMappingURL=index.js.map