@shipstatic/ship 0.3.13 → 0.3.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -105,7 +105,7 @@ ship domains list # List domains
105
105
  ship domains set staging abc123 # Set domain to deployment
106
106
  ship domains set prod abc123 --tag production # Set domain with tag
107
107
  ship domains set prod abc123 --tag prod --tag v1 # Set domain with multiple tags
108
- ship domains confirm www.example.com # Trigger DNS confirmation
108
+ ship domains verify www.example.com # Trigger DNS verification
109
109
  ship domains remove staging # Remove domain
110
110
 
111
111
  # Account
@@ -202,6 +202,7 @@ interface ShipOptions {
202
202
  deployToken?: string; // Deploy token: token- prefix + 64-char hex (70 chars total)
203
203
  timeout?: number; // Request timeout (ms)
204
204
  useCredentials?: boolean; // Use HTTP-only cookies for auth (skips token check)
205
+ caller?: string; // Identifier for multi-tenant deployments (e.g., CI system name)
205
206
  }
206
207
  ```
207
208
 
@@ -264,6 +265,8 @@ interface DeployOptions {
264
265
  maxConcurrency?: number;
265
266
  timeout?: number;
266
267
  stripCommonPrefix?: boolean; // Remove common path prefix
268
+ via?: string; // Client identifier (auto-set: 'sdk' for SDK, 'cli' for CLI)
269
+ caller?: string; // Multi-tenant identifier (e.g., 'github-actions', 'jenkins')
267
270
  }
268
271
  ```
269
272
 
@@ -282,8 +285,8 @@ await ship.domains.list()
282
285
  // Remove domain
283
286
  await ship.domains.remove(domainName)
284
287
 
285
- // Trigger DNS confirmation for external domain
286
- await ship.domains.confirm(domainName)
288
+ // Trigger DNS verification for external domain
289
+ await ship.domains.verify(domainName)
287
290
  ```
288
291
 
289
292
  **Examples:**
@@ -294,8 +297,8 @@ await ship.domains.set('staging', 'dep_abc123');
294
297
  // Set domain with tags
295
298
  await ship.domains.set('production', 'dep_xyz789', ['prod', 'v1.0.0']);
296
299
 
297
- // Confirm DNS for external domain
298
- await ship.domains.confirm('www.example.com');
300
+ // Verify DNS for external domain
301
+ await ship.domains.verify('www.example.com');
299
302
  ```
300
303
 
301
304
  ### Environment-Specific Examples
@@ -798,7 +801,7 @@ pnpm build && pnpm test --run
798
801
  - **Node.js tests**: Filesystem and path manipulation
799
802
  - **Error tests**: Unified error handling patterns
800
803
 
801
- **Current Status:** 614 tests passing (614 total) ✅
804
+ **Current Status:** 1006 tests passing (1006 total) ✅
802
805
 
803
806
  ## Contributing
804
807
 
package/dist/browser.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _shipstatic_types from '@shipstatic/types';
2
- import { ProgressInfo, PingResponse, ConfigResponse, StaticFile, Deployment, DeploymentListResponse, Domain, DomainListResponse, DomainDnsResponse, DomainRecordsResponse, Account, TokenCreateResponse, TokenListResponse, PlatformConfig, ResolvedConfig, DeployInput, DeploymentResource, DomainResource, AccountResource, TokenResource, ValidatableFile, FileValidationResult } from '@shipstatic/types';
2
+ import { ProgressInfo, StaticFile, PingResponse, ConfigResponse, Deployment, DeploymentListResponse, Domain, DomainListResponse, DomainDnsResponse, DomainRecordsResponse, Account, TokenCreateResponse, TokenListResponse, PlatformConfig, ResolvedConfig, DeployInput, DeploymentResource, DomainResource, AccountResource, TokenResource, ValidatableFile, FileValidationResult, ShipError } 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
 
@@ -37,12 +37,25 @@ interface DeploymentOptions {
37
37
  tags?: string[];
38
38
  /** Callback for deploy progress with detailed statistics. */
39
39
  onProgress?: (info: ProgressInfo) => void;
40
+ /** Client/tool identifier for this deployment (e.g., 'sdk', 'cli', 'web'). Alphanumeric only. */
41
+ via?: string;
42
+ /** Caller identifier for multi-tenant deployments (alphanumeric, dot, underscore, hyphen). */
43
+ caller?: string;
40
44
  }
45
+ type ApiDeployOptions = Omit<DeploymentOptions, 'pathDetect'>;
41
46
  /**
42
- * Options for configuring an deploy operation via `apiClient.deployFiles`.
43
- * Derived from DeploymentOptions but excludes client-side only options.
47
+ * Prepared request body for deployment.
48
+ * Created by platform-specific code, consumed by HTTP client.
44
49
  */
45
- type ApiDeployOptions = Omit<DeploymentOptions, 'pathDetect'>;
50
+ interface DeployBody {
51
+ body: FormData | ArrayBuffer;
52
+ headers: Record<string, string>;
53
+ }
54
+ /**
55
+ * Function that creates a deploy request body from files.
56
+ * Implemented differently for Node.js and Browser.
57
+ */
58
+ type DeployBodyCreator = (files: StaticFile[], tags?: string[], via?: string) => Promise<DeployBody>;
46
59
  /**
47
60
  * Options for configuring a `Ship` instance.
48
61
  * Sets default API host, authentication credentials, progress callbacks, concurrency, and timeouts for the client.
@@ -81,6 +94,11 @@ interface ShipClientOptions {
81
94
  * to proceed with cookie-based credentials.
82
95
  */
83
96
  useCredentials?: boolean | undefined;
97
+ /**
98
+ * Default caller identifier for multi-tenant deployments.
99
+ * Alphanumeric characters, dots, underscores, and hyphens allowed (max 128 chars).
100
+ */
101
+ caller?: string | undefined;
84
102
  }
85
103
  /**
86
104
  * Event map for Ship SDK events
@@ -136,23 +154,19 @@ declare class SimpleEvents {
136
154
  }
137
155
 
138
156
  /**
139
- * @file HTTP client with integrated event system
140
- * Clean, direct implementation with reliable error handling
157
+ * @file HTTP client for Ship API.
141
158
  */
142
159
 
143
- /**
144
- * HTTP client with integrated event system
145
- * - Direct event integration
146
- * - Clean inheritance from SimpleEvents
147
- * - Reliable error handling
148
- */
160
+ interface ApiHttpOptions extends ShipClientOptions {
161
+ getAuthHeaders: () => Record<string, string>;
162
+ createDeployBody: DeployBodyCreator;
163
+ }
149
164
  declare class ApiHttp extends SimpleEvents {
150
165
  private readonly apiUrl;
151
166
  private readonly getAuthHeadersCallback;
152
167
  private readonly timeout;
153
- constructor(options: ShipClientOptions & {
154
- getAuthHeaders: () => Record<string, string>;
155
- });
168
+ private readonly createDeployBody;
169
+ constructor(options: ApiHttpOptions);
156
170
  /**
157
171
  * Transfer events to another client (clean intentional API)
158
172
  */
@@ -201,7 +215,7 @@ declare class ApiHttp extends SimpleEvents {
201
215
  getDomain(name: string): Promise<Domain>;
202
216
  listDomains(): Promise<DomainListResponse>;
203
217
  removeDomain(name: string): Promise<void>;
204
- confirmDomain(name: string): Promise<{
218
+ verifyDomain(name: string): Promise<{
205
219
  message: string;
206
220
  }>;
207
221
  getDomainDns(name: string): Promise<DomainDnsResponse>;
@@ -215,11 +229,6 @@ declare class ApiHttp extends SimpleEvents {
215
229
  listTokens(): Promise<TokenListResponse>;
216
230
  removeToken(token: string): Promise<void>;
217
231
  checkSPA(files: StaticFile[]): Promise<boolean>;
218
- private validateFiles;
219
- private prepareRequestPayload;
220
- private createBrowserBody;
221
- private createNodeBody;
222
- private getBrowserContentType;
223
232
  }
224
233
 
225
234
  /**
@@ -234,8 +243,10 @@ declare class ApiHttp extends SimpleEvents {
234
243
  * This means CLI flags always win, followed by env vars, then config files.
235
244
  */
236
245
 
237
- type Config = PlatformConfig;
238
-
246
+ /**
247
+ * Cross-environment config loader that dispatches to appropriate implementation.
248
+ */
249
+ declare function loadConfig(configFile?: string): Promise<PlatformConfig>;
239
250
  /**
240
251
  * Universal configuration resolver for all environments.
241
252
  * This is the single source of truth for config resolution.
@@ -248,13 +259,28 @@ declare function resolveConfig(userOptions?: ShipClientOptions, loadedConfig?: P
248
259
  declare function mergeDeployOptions(options: DeploymentOptions, clientDefaults: ShipClientOptions): DeploymentOptions;
249
260
 
250
261
  /**
251
- * @file Ship SDK resource implementations for deployments, domains, and accounts.
262
+ * Ship SDK resource factory functions.
252
263
  */
253
264
 
254
- declare function createDeploymentResource(getApi: () => ApiHttp, clientDefaults?: ShipClientOptions, ensureInit?: () => Promise<void>, processInput?: (input: DeployInput, options: DeploymentOptions) => Promise<StaticFile[]>, hasAuth?: () => boolean): DeploymentResource;
255
- declare function createDomainResource(getApi: () => ApiHttp, ensureInit?: () => Promise<void>): DomainResource;
256
- declare function createAccountResource(getApi: () => ApiHttp, ensureInit?: () => Promise<void>): AccountResource;
257
- declare function createTokenResource(getApi: () => ApiHttp, ensureInit?: () => Promise<void>): TokenResource;
265
+ /**
266
+ * Shared context for all resource factories.
267
+ */
268
+ interface ResourceContext {
269
+ getApi: () => ApiHttp;
270
+ ensureInit: () => Promise<void>;
271
+ }
272
+ /**
273
+ * Extended context for deployment resource.
274
+ */
275
+ interface DeploymentResourceContext extends ResourceContext {
276
+ processInput: (input: DeployInput, options: DeploymentOptions) => Promise<StaticFile[]>;
277
+ clientDefaults?: ShipClientOptions;
278
+ hasAuth?: () => boolean;
279
+ }
280
+ declare function createDeploymentResource(ctx: DeploymentResourceContext): DeploymentResource;
281
+ declare function createDomainResource(ctx: ResourceContext): DomainResource;
282
+ declare function createAccountResource(ctx: ResourceContext): AccountResource;
283
+ declare function createTokenResource(ctx: ResourceContext): TokenResource;
258
284
 
259
285
  /**
260
286
  * Abstract base class for Ship SDK implementations.
@@ -277,6 +303,7 @@ declare abstract class Ship$1 {
277
303
  protected abstract resolveInitialConfig(options: ShipClientOptions): ResolvedConfig;
278
304
  protected abstract loadFullConfig(): Promise<void>;
279
305
  protected abstract processInput(input: DeployInput, options: DeploymentOptions): Promise<StaticFile[]>;
306
+ protected abstract getDeployBodyCreator(): DeployBodyCreator;
280
307
  /**
281
308
  * Ensure full initialization is complete - called lazily by resources
282
309
  */
@@ -536,15 +563,24 @@ declare function getValidFiles<T extends ValidatableFile>(files: T[]): T[];
536
563
  declare function allValidFilesReady<T extends ValidatableFile>(files: T[]): boolean;
537
564
 
538
565
  /**
539
- * @file Browser configuration implementation - no file system access.
540
- * Browser environment receives all config through constructor options.
566
+ * @file Error utilities for consistent error handling across SDK consumers.
541
567
  */
542
568
 
543
569
  /**
544
- * Browser config loading - always returns empty (no file system access).
545
- * All configuration must be provided through Ship constructor options.
570
+ * Ensure any error is wrapped as a ShipError.
571
+ * Useful for catch blocks where the error type is unknown.
572
+ *
573
+ * @example
574
+ * ```ts
575
+ * try {
576
+ * await someOperation();
577
+ * } catch (err) {
578
+ * const shipError = ensureShipError(err);
579
+ * // Now you can safely use shipError.message, shipError.type, etc.
580
+ * }
581
+ * ```
546
582
  */
547
- declare function loadConfig(configFile?: string): Promise<Config>;
583
+ declare function ensureShipError(err: unknown): ShipError;
548
584
 
549
585
  /**
550
586
  * @file Platform configuration management for the Ship SDK.
@@ -601,11 +637,11 @@ declare function processFilesForBrowser(browserFiles: File[], options?: Deployme
601
637
  * ```
602
638
  */
603
639
  declare class Ship extends Ship$1 {
604
- #private;
605
640
  constructor(options?: ShipClientOptions);
606
641
  protected resolveInitialConfig(options: ShipClientOptions): ResolvedConfig;
607
642
  protected loadFullConfig(): Promise<void>;
608
643
  protected processInput(input: DeployInput, options: DeploymentOptions): Promise<StaticFile[]>;
644
+ protected getDeployBodyCreator(): DeployBodyCreator;
609
645
  }
610
646
 
611
- export { type ApiDeployOptions, ApiHttp, type Config, type DeployFile, type DeploymentOptions, type ExecutionEnvironment, JUNK_DIRECTORIES, type MD5Result, Ship, type ShipClientOptions, type ShipEvents, __setTestEnvironment, allValidFilesReady, calculateMD5, createAccountResource, createDeploymentResource, createDomainResource, createTokenResource, Ship as default, filterJunk, formatFileSize, getCurrentConfig, getENV, getValidFiles, loadConfig, mergeDeployOptions, optimizeDeployPaths, pluralize, processFilesForBrowser, resolveConfig, setConfig as setPlatformConfig, validateFiles };
647
+ export { type ApiDeployOptions, ApiHttp, type ApiHttpOptions, type DeployBody, 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, ensureShipError, filterJunk, formatFileSize, getCurrentConfig, getENV, getValidFiles, loadConfig, mergeDeployOptions, optimizeDeployPaths, pluralize, processFilesForBrowser, resolveConfig, setConfig as setPlatformConfig, validateFiles };