@shipstatic/ship 0.3.14 → 0.3.16

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, ShipError } 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
  */
@@ -199,9 +213,10 @@ declare class ApiHttp extends SimpleEvents {
199
213
  removeDeployment(id: string): Promise<void>;
200
214
  setDomain(name: string, deployment?: string, tags?: string[]): Promise<Domain>;
201
215
  getDomain(name: string): Promise<Domain>;
216
+ updateDomainTags(name: string, tags: string[]): Promise<Domain>;
202
217
  listDomains(): Promise<DomainListResponse>;
203
218
  removeDomain(name: string): Promise<void>;
204
- confirmDomain(name: string): Promise<{
219
+ verifyDomain(name: string): Promise<{
205
220
  message: string;
206
221
  }>;
207
222
  getDomainDns(name: string): Promise<DomainDnsResponse>;
@@ -215,11 +230,6 @@ declare class ApiHttp extends SimpleEvents {
215
230
  listTokens(): Promise<TokenListResponse>;
216
231
  removeToken(token: string): Promise<void>;
217
232
  checkSPA(files: StaticFile[]): Promise<boolean>;
218
- private validateFiles;
219
- private prepareRequestPayload;
220
- private createBrowserBody;
221
- private createNodeBody;
222
- private getBrowserContentType;
223
233
  }
224
234
 
225
235
  /**
@@ -234,8 +244,10 @@ declare class ApiHttp extends SimpleEvents {
234
244
  * This means CLI flags always win, followed by env vars, then config files.
235
245
  */
236
246
 
237
- type Config = PlatformConfig;
238
-
247
+ /**
248
+ * Cross-environment config loader that dispatches to appropriate implementation.
249
+ */
250
+ declare function loadConfig(configFile?: string): Promise<PlatformConfig>;
239
251
  /**
240
252
  * Universal configuration resolver for all environments.
241
253
  * This is the single source of truth for config resolution.
@@ -248,13 +260,28 @@ declare function resolveConfig(userOptions?: ShipClientOptions, loadedConfig?: P
248
260
  declare function mergeDeployOptions(options: DeploymentOptions, clientDefaults: ShipClientOptions): DeploymentOptions;
249
261
 
250
262
  /**
251
- * @file Ship SDK resource implementations for deployments, domains, and accounts.
263
+ * Ship SDK resource factory functions.
252
264
  */
253
265
 
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;
266
+ /**
267
+ * Shared context for all resource factories.
268
+ */
269
+ interface ResourceContext {
270
+ getApi: () => ApiHttp;
271
+ ensureInit: () => Promise<void>;
272
+ }
273
+ /**
274
+ * Extended context for deployment resource.
275
+ */
276
+ interface DeploymentResourceContext extends ResourceContext {
277
+ processInput: (input: DeployInput, options: DeploymentOptions) => Promise<StaticFile[]>;
278
+ clientDefaults?: ShipClientOptions;
279
+ hasAuth?: () => boolean;
280
+ }
281
+ declare function createDeploymentResource(ctx: DeploymentResourceContext): DeploymentResource;
282
+ declare function createDomainResource(ctx: ResourceContext): DomainResource;
283
+ declare function createAccountResource(ctx: ResourceContext): AccountResource;
284
+ declare function createTokenResource(ctx: ResourceContext): TokenResource;
258
285
 
259
286
  /**
260
287
  * Abstract base class for Ship SDK implementations.
@@ -277,6 +304,7 @@ declare abstract class Ship$1 {
277
304
  protected abstract resolveInitialConfig(options: ShipClientOptions): ResolvedConfig;
278
305
  protected abstract loadFullConfig(): Promise<void>;
279
306
  protected abstract processInput(input: DeployInput, options: DeploymentOptions): Promise<StaticFile[]>;
307
+ protected abstract getDeployBodyCreator(): DeployBodyCreator;
280
308
  /**
281
309
  * Ensure full initialization is complete - called lazily by resources
282
310
  */
@@ -555,17 +583,6 @@ declare function allValidFilesReady<T extends ValidatableFile>(files: T[]): bool
555
583
  */
556
584
  declare function ensureShipError(err: unknown): ShipError;
557
585
 
558
- /**
559
- * @file Browser configuration implementation - no file system access.
560
- * Browser environment receives all config through constructor options.
561
- */
562
-
563
- /**
564
- * Browser config loading - always returns empty (no file system access).
565
- * All configuration must be provided through Ship constructor options.
566
- */
567
- declare function loadConfig(configFile?: string): Promise<Config>;
568
-
569
586
  /**
570
587
  * @file Platform configuration management for the Ship SDK.
571
588
  * Implements fail-fast dynamic configuration with mandatory API fetch.
@@ -621,11 +638,11 @@ declare function processFilesForBrowser(browserFiles: File[], options?: Deployme
621
638
  * ```
622
639
  */
623
640
  declare class Ship extends Ship$1 {
624
- #private;
625
641
  constructor(options?: ShipClientOptions);
626
642
  protected resolveInitialConfig(options: ShipClientOptions): ResolvedConfig;
627
643
  protected loadFullConfig(): Promise<void>;
628
644
  protected processInput(input: DeployInput, options: DeploymentOptions): Promise<StaticFile[]>;
645
+ protected getDeployBodyCreator(): DeployBodyCreator;
629
646
  }
630
647
 
631
- 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, ensureShipError, filterJunk, formatFileSize, getCurrentConfig, getENV, getValidFiles, loadConfig, mergeDeployOptions, optimizeDeployPaths, pluralize, processFilesForBrowser, resolveConfig, setConfig as setPlatformConfig, validateFiles };
648
+ 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 };