@shipstatic/ship 0.3.12 → 0.3.14

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/browser.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _shipstatic_types from '@shipstatic/types';
2
- import { PingResponse, ConfigResponse, StaticFile, Deployment, DeploymentListResponse, Domain, DomainListResponse, Account, TokenCreateResponse, TokenListResponse, DeployInput, DeploymentResource, DomainResource, AccountResource, TokenResource, PlatformConfig, ValidatableFile, FileValidationResult } 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';
3
3
  export * from '@shipstatic/types';
4
- export { Account, AccountResource, DEFAULT_API, DeployInput, Deployment, DeploymentResource, Domain, DomainResource, FileValidationStatus as FILE_VALIDATION_STATUS, PingResponse, ShipError, ShipErrorType, StaticFile, TokenResource } from '@shipstatic/types';
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
 
6
6
  /**
7
7
  * @file SDK-specific type definitions
@@ -43,20 +43,6 @@ interface DeploymentOptions {
43
43
  * Derived from DeploymentOptions but excludes client-side only options.
44
44
  */
45
45
  type ApiDeployOptions = Omit<DeploymentOptions, 'pathDetect'>;
46
- /**
47
- * Progress information for deploy operations.
48
- * Provides consistent percentage-based progress with byte-level details.
49
- */
50
- interface ProgressInfo {
51
- /** Progress percentage (0-100). */
52
- percent: number;
53
- /** Number of bytes loaded so far. */
54
- loaded: number;
55
- /** Total number of bytes to be loaded. May be 0 if unknown initially. */
56
- total: number;
57
- /** Current file being processed (optional). */
58
- file?: string;
59
- }
60
46
  /**
61
47
  * Options for configuring a `Ship` instance.
62
48
  * Sets default API host, authentication credentials, progress callbacks, concurrency, and timeouts for the client.
@@ -163,6 +149,7 @@ declare class SimpleEvents {
163
149
  declare class ApiHttp extends SimpleEvents {
164
150
  private readonly apiUrl;
165
151
  private readonly getAuthHeadersCallback;
152
+ private readonly timeout;
166
153
  constructor(options: ShipClientOptions & {
167
154
  getAuthHeaders: () => Record<string, string>;
168
155
  });
@@ -171,9 +158,18 @@ declare class ApiHttp extends SimpleEvents {
171
158
  */
172
159
  transferEventsTo(target: ApiHttp): void;
173
160
  /**
174
- * Make authenticated HTTP request with events
161
+ * Make authenticated HTTP request with events and timeout
175
162
  */
176
163
  private request;
164
+ /**
165
+ * Combine multiple AbortSignals into one
166
+ */
167
+ private combineSignals;
168
+ /**
169
+ * Make request and return both data and HTTP status code
170
+ * Used when the caller needs to inspect the status (e.g., 201 vs 200)
171
+ */
172
+ private requestWithStatus;
177
173
  /**
178
174
  * Generate auth headers from Ship instance callback
179
175
  */
@@ -208,14 +204,8 @@ declare class ApiHttp extends SimpleEvents {
208
204
  confirmDomain(name: string): Promise<{
209
205
  message: string;
210
206
  }>;
211
- getDomainDns(name: string): Promise<{
212
- domain: string;
213
- dns: any;
214
- }>;
215
- getDomainRecords(name: string): Promise<{
216
- domain: string;
217
- records: any[];
218
- }>;
207
+ getDomainDns(name: string): Promise<DomainDnsResponse>;
208
+ getDomainRecords(name: string): Promise<DomainRecordsResponse>;
219
209
  getDomainShare(name: string): Promise<{
220
210
  domain: string;
221
211
  hash: string;
@@ -232,6 +222,31 @@ declare class ApiHttp extends SimpleEvents {
232
222
  private getBrowserContentType;
233
223
  }
234
224
 
225
+ /**
226
+ * @file Shared configuration logic for both environments.
227
+ *
228
+ * CONFIGURATION PRECEDENCE (highest to lowest):
229
+ * 1. Constructor options / CLI flags (passed directly to Ship())
230
+ * 2. Environment variables (SHIP_API_KEY, SHIP_DEPLOY_TOKEN, SHIP_API_URL)
231
+ * 3. Config file (.shiprc or package.json "ship" key)
232
+ * 4. Default values (DEFAULT_API)
233
+ *
234
+ * This means CLI flags always win, followed by env vars, then config files.
235
+ */
236
+
237
+ type Config = PlatformConfig;
238
+
239
+ /**
240
+ * Universal configuration resolver for all environments.
241
+ * This is the single source of truth for config resolution.
242
+ */
243
+ declare function resolveConfig(userOptions?: ShipClientOptions, loadedConfig?: Partial<ShipClientOptions>): ResolvedConfig;
244
+ /**
245
+ * Merge deployment options with client defaults.
246
+ * This is shared logic used by both environments.
247
+ */
248
+ declare function mergeDeployOptions(options: DeploymentOptions, clientDefaults: ShipClientOptions): DeploymentOptions;
249
+
235
250
  /**
236
251
  * @file Ship SDK resource implementations for deployments, domains, and accounts.
237
252
  */
@@ -253,13 +268,13 @@ declare abstract class Ship$1 {
253
268
  protected initPromise: Promise<void> | null;
254
269
  protected _config: ConfigResponse | null;
255
270
  private auth;
256
- private readonly authHeadersCallback;
271
+ protected readonly authHeadersCallback: () => Record<string, string>;
257
272
  protected _deployments: DeploymentResource;
258
273
  protected _domains: DomainResource;
259
274
  protected _account: AccountResource;
260
275
  protected _tokens: TokenResource;
261
276
  constructor(options?: ShipClientOptions);
262
- protected abstract resolveInitialConfig(options: ShipClientOptions): any;
277
+ protected abstract resolveInitialConfig(options: ShipClientOptions): ResolvedConfig;
263
278
  protected abstract loadFullConfig(): Promise<void>;
264
279
  protected abstract processInput(input: DeployInput, options: DeploymentOptions): Promise<StaticFile[]>;
265
280
  /**
@@ -343,26 +358,6 @@ declare abstract class Ship$1 {
343
358
  private hasAuth;
344
359
  }
345
360
 
346
- /**
347
- * @file Shared configuration logic for both environments.
348
- */
349
-
350
- type Config = PlatformConfig;
351
- /**
352
- * Universal configuration resolver for all environments.
353
- * This is the single source of truth for config resolution.
354
- */
355
- declare function resolveConfig(userOptions?: ShipClientOptions, loadedConfig?: Partial<ShipClientOptions>): {
356
- apiUrl: string;
357
- apiKey?: string;
358
- deployToken?: string;
359
- };
360
- /**
361
- * Merge deployment options with client defaults.
362
- * This is shared logic used by both environments.
363
- */
364
- declare function mergeDeployOptions(options: DeploymentOptions, clientDefaults: ShipClientOptions): DeploymentOptions;
365
-
366
361
  interface MD5Result {
367
362
  md5: string;
368
363
  }
@@ -540,6 +535,26 @@ declare function getValidFiles<T extends ValidatableFile>(files: T[]): T[];
540
535
  */
541
536
  declare function allValidFilesReady<T extends ValidatableFile>(files: T[]): boolean;
542
537
 
538
+ /**
539
+ * @file Error utilities for consistent error handling across SDK consumers.
540
+ */
541
+
542
+ /**
543
+ * Ensure any error is wrapped as a ShipError.
544
+ * Useful for catch blocks where the error type is unknown.
545
+ *
546
+ * @example
547
+ * ```ts
548
+ * try {
549
+ * await someOperation();
550
+ * } catch (err) {
551
+ * const shipError = ensureShipError(err);
552
+ * // Now you can safely use shipError.message, shipError.type, etc.
553
+ * }
554
+ * ```
555
+ */
556
+ declare function ensureShipError(err: unknown): ShipError;
557
+
543
558
  /**
544
559
  * @file Browser configuration implementation - no file system access.
545
560
  * Browser environment receives all config through constructor options.
@@ -608,9 +623,9 @@ declare function processFilesForBrowser(browserFiles: File[], options?: Deployme
608
623
  declare class Ship extends Ship$1 {
609
624
  #private;
610
625
  constructor(options?: ShipClientOptions);
611
- protected resolveInitialConfig(options: ShipClientOptions): any;
626
+ protected resolveInitialConfig(options: ShipClientOptions): ResolvedConfig;
612
627
  protected loadFullConfig(): Promise<void>;
613
628
  protected processInput(input: DeployInput, options: DeploymentOptions): Promise<StaticFile[]>;
614
629
  }
615
630
 
616
- export { type ApiDeployOptions, ApiHttp, type Config, type DeployFile, type DeploymentOptions, type ExecutionEnvironment, JUNK_DIRECTORIES, type MD5Result, type ProgressInfo, 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 };
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 };