@shipstatic/ship 0.2.4 → 0.2.6

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
@@ -1,11 +1,12 @@
1
1
  # 🚢 Ship CLI & SDK
2
2
 
3
- A modern, lightweight SDK and CLI for deploying static files, designed for both **Node.js** and **Browser** environments with a clean resource-based API.
3
+ A modern, lightweight SDK and CLI for deploying static files, designed for both **Node.js** and **Browser** environments with a clean resource-based API and comprehensive event system for observability.
4
4
 
5
5
  ## Features
6
6
 
7
7
  - **🚀 Modern Resource API**: Clean `ship.deployments.create()` interface - no legacy wrappers
8
8
  - **🌍 Universal**: Automatic environment detection (Node.js/Browser) with optimized implementations
9
+ - **📡 Event System**: Complete observability with request, response, and error events
9
10
  - **🔧 Dynamic Configuration**: Automatically fetches platform limits from API
10
11
  - **📁 Flexible Input**: File paths (Node.js) or File objects (Browser/drag-drop)
11
12
  - **🔐 Secure**: MD5 checksums and data integrity validation
@@ -89,6 +90,9 @@ ship ./dist
89
90
  # Or deploy current directory
90
91
  ship
91
92
 
93
+ # Deploy with tags
94
+ ship deployments create ./dist --tag production --tag v1.0.0
95
+
92
96
  # Explicit commands
93
97
  ship deploy ./build # Deploy project from path
94
98
  ship list # List deployments
@@ -96,8 +100,12 @@ ship get abc123 # Get deployment details
96
100
  ship remove abc123 # Remove deployment
97
101
 
98
102
  # Manage aliases
99
- ship aliases # List aliases
100
- ship alias staging abc123 # Set alias to deployment
103
+ ship aliases list # List aliases
104
+ ship aliases set staging abc123 # Set alias to deployment
105
+ ship aliases set prod abc123 --tag production # Set alias with tag
106
+ ship aliases set prod abc123 --tag prod --tag v1 # Set alias with multiple tags
107
+ ship aliases confirm www.example.com # Trigger DNS confirmation
108
+ ship aliases remove staging # Remove alias
101
109
 
102
110
  # Account
103
111
  ship account # Get account details
@@ -114,7 +122,7 @@ Ship SDK automatically fetches platform configuration from the API on initializa
114
122
  // SDK automatically calls GET /config and applies limits
115
123
  const ship = new Ship({ apiKey: 'ship-your-key' });
116
124
 
117
- // Platform limits are now available for validation:
125
+ // Platform limits are available for validation:
118
126
  // - maxFileSize: Dynamic file size limit
119
127
  // - maxFilesCount: Dynamic file count limit
120
128
  // - maxTotalSize: Dynamic total size limit
@@ -122,7 +130,7 @@ const ship = new Ship({ apiKey: 'ship-your-key' });
122
130
 
123
131
  **Benefits:**
124
132
  - **Single source of truth** - Limits only need to be changed on the API side
125
- - **Automatic updates** - SDK always uses current platform limits
133
+ - **Always current** - SDK always uses current platform limits
126
134
  - **Fail fast** - SDK fails if unable to fetch valid configuration
127
135
 
128
136
  ## API Reference
@@ -151,6 +159,8 @@ interface ShipOptions {
151
159
  - `ship.deployments` - Access deployment resource
152
160
  - `ship.aliases` - Access alias resource
153
161
  - `ship.account` - Access account resource
162
+ - `ship.on(event, handler)` - Add event listener for API observability
163
+ - `ship.off(event, handler)` - Remove event listener
154
164
 
155
165
  ### Deployments Resource
156
166
 
@@ -187,17 +197,49 @@ interface DeployOptions {
187
197
  apiUrl?: string;
188
198
  apiKey?: string; // API key: ship- prefix + 64-char hex (69 chars total)
189
199
  deployToken?: string; // Deploy token: token- prefix + 64-char hex (70 chars total)
190
- signal?: AbortSignal; // Cancellation
191
- subdomain?: string; // Custom subdomain
200
+ tags?: string[]; // Optional array of tags for categorization
201
+ signal?: AbortSignal; // Cancellation
202
+ subdomain?: string; // Custom subdomain
192
203
  onCancel?: () => void;
193
204
  onProgress?: (progress: number) => void;
194
205
  progress?: (stats: ProgressStats) => void;
195
206
  maxConcurrency?: number;
196
207
  timeout?: number;
197
- stripCommonPrefix?: boolean; // Remove common path prefix
208
+ stripCommonPrefix?: boolean; // Remove common path prefix
198
209
  }
199
210
  ```
200
211
 
212
+ ### Aliases Resource
213
+
214
+ ```typescript
215
+ // Set or update an alias (with optional tags)
216
+ await ship.aliases.set(aliasName, deploymentId, tags?)
217
+
218
+ // Get alias details
219
+ await ship.aliases.get(aliasName)
220
+
221
+ // List all aliases
222
+ await ship.aliases.list()
223
+
224
+ // Remove alias
225
+ await ship.aliases.remove(aliasName)
226
+
227
+ // Trigger DNS confirmation for external alias
228
+ await ship.aliases.confirm(aliasName)
229
+ ```
230
+
231
+ **Examples:**
232
+ ```javascript
233
+ // Set alias without tags
234
+ await ship.aliases.set('staging', 'dep_abc123');
235
+
236
+ // Set alias with tags
237
+ await ship.aliases.set('production', 'dep_xyz789', ['prod', 'v1.0.0']);
238
+
239
+ // Confirm DNS for external alias
240
+ await ship.aliases.confirm('www.example.com');
241
+ ```
242
+
201
243
  ### Environment-Specific Examples
202
244
 
203
245
  #### Node.js File Deployment
@@ -255,6 +297,161 @@ const files: File[] = Array.from(fileInput.files || []);
255
297
  const result2 = await ship.deployments.create(files);
256
298
  ```
257
299
 
300
+ ## Event System
301
+
302
+ Ship SDK provides a comprehensive event system for complete observability of all API operations. The event system is lightweight, reliable, and provides detailed insights into requests, responses, and errors.
303
+
304
+ ### Event Types
305
+
306
+ The SDK emits three core events:
307
+
308
+ - **`request`** - Emitted before each API request
309
+ - **`response`** - Emitted after successful API responses
310
+ - **`error`** - Emitted when API requests fail
311
+
312
+ ### Basic Event Usage
313
+
314
+ ```javascript
315
+ import Ship from '@shipstatic/ship';
316
+
317
+ const ship = new Ship({ apiKey: 'ship-your-api-key' });
318
+
319
+ // Listen to all API requests
320
+ ship.on('request', (url, requestInit) => {
321
+ console.log(`→ ${requestInit.method} ${url}`);
322
+ });
323
+
324
+ // Listen to all API responses
325
+ ship.on('response', (response, url) => {
326
+ console.log(`← ${response.status} ${url}`);
327
+ });
328
+
329
+ // Listen to all API errors
330
+ ship.on('error', (error, url) => {
331
+ console.error(`✗ Error at ${url}:`, error.message);
332
+ });
333
+
334
+ // Deploy with events
335
+ const result = await ship.deployments.create('./dist');
336
+ ```
337
+
338
+ ### Advanced Event Patterns
339
+
340
+ #### Request/Response Logging
341
+ ```javascript
342
+ // Log all API traffic
343
+ ship.on('request', (url, init) => {
344
+ console.log(`[${new Date().toISOString()}] → ${init.method} ${url}`);
345
+ if (init.body) {
346
+ console.log(` Body: ${init.body instanceof FormData ? '[FormData]' : init.body}`);
347
+ }
348
+ });
349
+
350
+ ship.on('response', (response, url) => {
351
+ console.log(`[${new Date().toISOString()}] ← ${response.status} ${response.statusText} ${url}`);
352
+ });
353
+ ```
354
+
355
+ #### Error Monitoring
356
+ ```javascript
357
+ // Comprehensive error tracking
358
+ ship.on('error', (error, url) => {
359
+ // Send to monitoring service
360
+ analytics.track('ship_api_error', {
361
+ url,
362
+ error: error.message,
363
+ type: error.constructor.name,
364
+ timestamp: Date.now()
365
+ });
366
+ });
367
+ ```
368
+
369
+ #### Performance Monitoring
370
+ ```javascript
371
+ const requestTimes = new Map();
372
+
373
+ ship.on('request', (url, init) => {
374
+ requestTimes.set(url, Date.now());
375
+ });
376
+
377
+ ship.on('response', (response, url) => {
378
+ const startTime = requestTimes.get(url);
379
+ if (startTime) {
380
+ const duration = Date.now() - startTime;
381
+ console.log(`${url} took ${duration}ms`);
382
+ requestTimes.delete(url);
383
+ }
384
+ });
385
+ ```
386
+
387
+ #### Custom Analytics Integration
388
+ ```javascript
389
+ // Google Analytics integration
390
+ ship.on('request', (url, init) => {
391
+ gtag('event', 'api_request', {
392
+ 'custom_url': url,
393
+ 'method': init.method
394
+ });
395
+ });
396
+
397
+ ship.on('response', (response, url) => {
398
+ gtag('event', 'api_response', {
399
+ 'custom_url': url,
400
+ 'status_code': response.status
401
+ });
402
+ });
403
+ ```
404
+
405
+ ### Event Handler Management
406
+
407
+ ```javascript
408
+ // Add event handlers
409
+ const requestHandler = (url, init) => console.log(`Request: ${url}`);
410
+ ship.on('request', requestHandler);
411
+
412
+ // Remove specific handlers
413
+ ship.off('request', requestHandler);
414
+
415
+ // Event handlers are automatically cleaned up when ship instance is garbage collected
416
+ ```
417
+
418
+ ### Event System Features
419
+
420
+ - **Reliable**: Handlers that throw errors are automatically removed to prevent cascading failures
421
+ - **Safe**: Response objects are safely cloned for event handlers to prevent body consumption conflicts
422
+ - **Lightweight**: Minimal overhead - only 70 lines of code
423
+ - **Type Safe**: Full TypeScript support with proper event argument typing
424
+ - **Clean**: Automatic cleanup prevents memory leaks
425
+
426
+ ### TypeScript Event Types
427
+
428
+ ```typescript
429
+ import Ship from '@shipstatic/ship';
430
+
431
+ const ship = new Ship({ apiKey: 'ship-your-api-key' });
432
+
433
+ // Fully typed event handlers
434
+ ship.on('request', (url: string, init: RequestInit) => {
435
+ console.log(`Request to ${url}`);
436
+ });
437
+
438
+ ship.on('response', (response: Response, url: string) => {
439
+ console.log(`Response from ${url}: ${response.status}`);
440
+ });
441
+
442
+ ship.on('error', (error: Error, url: string) => {
443
+ console.error(`Error at ${url}:`, error);
444
+ });
445
+ ```
446
+
447
+ ### Event System Architecture
448
+
449
+ The event system is built directly into the HTTP client with:
450
+ - **Direct Integration**: Events are emitted from the core HTTP operations
451
+ - **Error Boundaries**: Failed event handlers don't crash API operations
452
+ - **Response Cloning**: Dedicated response clones for events and parsing
453
+ - **Graceful Degradation**: Event system failures don't affect core functionality
454
+
258
455
  ## Unified Error Handling
259
456
 
260
457
  The Ship SDK uses a unified error system with a single `ShipError` class:
@@ -418,7 +615,7 @@ ship account # Get account details
418
615
  - **Browser**: 185KB (ESM with dependencies)
419
616
  - **CLI**: 38KB (CJS)
420
617
 
421
- **Recent Optimizations:**
618
+ **Key Optimizations:**
422
619
  - ✅ **Unified error system** - Single `ShipError` class for all components
423
620
  - ✅ **Dynamic platform configuration** - Fetches limits from API
424
621
  - ✅ **Replaced axios with native fetch** - Bundle size reduction
@@ -434,6 +631,7 @@ Full TypeScript support with exported types from shared `@shipstatic/types`:
434
631
  // TypeScript - works with both import styles
435
632
  import type {
436
633
  ShipOptions,
634
+ ShipEvents,
437
635
  NodeDeployInput,
438
636
  BrowserDeployInput,
439
637
  DeployOptions,
@@ -451,6 +649,7 @@ import type {
451
649
  - **Class-based API**: `new Ship()` with resource properties
452
650
  - **Environment detection**: Automatic Node.js/Browser optimizations
453
651
  - **Native dependencies**: Uses built-in `fetch`, `crypto`, and `fs` APIs
652
+ - **Event system**: Comprehensive observability with lightweight, reliable events
454
653
  - **Type safety**: Strict TypeScript with comprehensive error types
455
654
  - **Dynamic configuration**: Platform limits fetched from API
456
655
  - **Unified DTOs**: Shared type definitions from `@shipstatic/types`
@@ -471,6 +670,7 @@ src/
471
670
  │ ├── api/ # HTTP client and API communication
472
671
  │ ├── base-ship.ts # Base Ship class implementation
473
672
  │ ├── core/ # Configuration and constants
673
+ │ ├── events.ts # Event system implementation
474
674
  │ ├── lib/ # Utility libraries
475
675
  │ ├── resources.ts # Resource implementations
476
676
  │ └── types.ts # Shared type definitions
@@ -500,24 +700,24 @@ File Objects → Path Extraction → Junk Filtering → Content Processing → S
500
700
  - **Wire format support**: Automatic serialization/deserialization
501
701
  - **Helper methods**: Easy type checking with `is*Error()` methods
502
702
 
503
- ## Development Status
504
-
505
- This is an **unlaunched project** optimized for modern development:
506
-
507
- - **Deployment Resource**: Full implementation (create, list, get, remove)
508
- - **Alias Resource**: Full implementation (set, get, list, remove)
509
- - **Account Resource**: Full implementation (get account details)
510
- - **Unified Error System**: Single `ShipError` class with factory methods
511
- - **Dynamic Platform Config**: Automatic limit fetching from API
512
- - **Ultra-Simple CLI**: Deploy shortcut + explicit commands
513
- - **Streamlined Multipart**: `files[]` array + JSON checksums format
514
- - **Direct Validation**: Functions throw errors instead of returning results
515
- - **Shared DTOs**: All types from `@shipstatic/types` package
516
- - **Tree-shakeable**: `"sideEffects": false` for optimal bundling
517
- - **Impossible Simplicity**: Maximum functionality with minimal complexity
518
- - 🎯 No legacy compatibility constraints
519
- - 🔧 Native fetch API for optimal performance
520
- - Modern ESM modules with TypeScript
703
+ ## Features & Capabilities
704
+
705
+ Ship SDK provides comprehensive deployment functionality:
706
+
707
+ - **Deployment Resource**: Complete operations (create, list, get, remove)
708
+ - **Alias Resource**: Complete operations (set, get, list, remove)
709
+ - **Account Resource**: Account information retrieval
710
+ - **Event System**: Comprehensive observability with request, response, error events
711
+ - **Unified Error System**: Single `ShipError` class with factory methods
712
+ - **Dynamic Platform Config**: Automatic limit fetching from API
713
+ - **Simple CLI**: Deploy shortcut + explicit commands
714
+ - **Streamlined Multipart**: `files[]` array + JSON checksums format
715
+ - **Direct Validation**: Functions throw errors for immediate feedback
716
+ - **Shared DTOs**: All types from `@shipstatic/types` package
717
+ - **Tree-shakeable**: `"sideEffects": false` for optimal bundling
718
+ - **Production Ready**: Clean, reliable implementation with comprehensive test coverage
719
+ - **Native APIs**: Built on `fetch`, `crypto`, and `fs` for optimal performance
720
+ - **Modern TypeScript**: Full type safety with ESM modules
521
721
 
522
722
  ## Testing
523
723
 
@@ -543,7 +743,7 @@ pnpm build && pnpm test --run
543
743
  - **Node.js tests**: Filesystem and path manipulation
544
744
  - **Error tests**: Unified error handling patterns
545
745
 
546
- **Current Status:** 566 tests passing (596 total) ✅
746
+ **Current Status:** 614 tests passing (614 total) ✅
547
747
 
548
748
  ## Contributing
549
749
 
package/dist/browser.d.ts CHANGED
@@ -25,14 +25,16 @@ interface DeploymentOptions {
25
25
  maxConcurrency?: number;
26
26
  /** Timeout in milliseconds for the deploy request. */
27
27
  timeout?: number;
28
- /** API key for this specific deploy. Overrides client's default. */
28
+ /** API key for this specific deploy. Overrides client's default (format: ship-<64-char-hex>, total 69 chars). */
29
29
  apiKey?: string;
30
- /** Deploy token for this specific deploy. Overrides client's default. */
30
+ /** Deploy token for this specific deploy. Overrides client's default (format: token-<64-char-hex>, total 70 chars). */
31
31
  deployToken?: string;
32
32
  /** Whether to auto-detect and optimize file paths by flattening common directories. Defaults to true. */
33
33
  pathDetect?: boolean;
34
34
  /** Whether to auto-detect SPAs and generate ship.json configuration. Defaults to true. */
35
35
  spaDetect?: boolean;
36
+ /** Optional array of tags for categorization and filtering (lowercase, alphanumeric with separators). */
37
+ tags?: string[];
36
38
  /** Callback for overall deploy progress (0-100). */
37
39
  onProgress?: (progress: number) => void;
38
40
  /** Callback for detailed progress statistics. */
@@ -63,9 +65,9 @@ interface ProgressStats {
63
65
  interface ShipClientOptions {
64
66
  /** Default API URL for the client instance. */
65
67
  apiUrl?: string | undefined;
66
- /** API key for authenticated deployments. */
68
+ /** API key for authenticated deployments (format: ship-<64-char-hex>, total 69 chars). */
67
69
  apiKey?: string | undefined;
68
- /** Deploy token for single-use deployments. */
70
+ /** Deploy token for single-use deployments (format: token-<64-char-hex>, total 70 chars). */
69
71
  deployToken?: string | undefined;
70
72
  /** Path to custom config file. */
71
73
  configFile?: string | undefined;
@@ -91,118 +93,144 @@ interface ShipClientOptions {
91
93
  */
92
94
  timeout?: number | undefined;
93
95
  }
96
+ /**
97
+ * Event map for Ship SDK events
98
+ * Core events for observability: request, response, error
99
+ */
100
+ interface ShipEvents extends Record<string, any[]> {
101
+ /** Emitted before each API request */
102
+ request: [url: string, init: RequestInit];
103
+ /** Emitted after successful API response */
104
+ response: [response: Response, url: string];
105
+ /** Emitted when API request fails */
106
+ error: [error: Error, url: string];
107
+ }
94
108
 
95
109
  /**
96
- * Handles direct HTTP communication with the Ship API, including deploys and health checks.
97
- * Responsible for constructing requests, managing authentication, and error translation.
98
- * @internal
110
+ * Event system for Ship SDK
111
+ * Lightweight, reliable event handling with proper error boundaries
99
112
  */
100
- declare class ApiHttp {
101
- #private;
102
- private readonly apiUrl;
103
- private readonly apiKey;
104
- private readonly deployToken;
113
+
114
+ /**
115
+ * Lightweight event system
116
+ * - Add handler: on()
117
+ * - Remove handler: off()
118
+ * - Emit events: emit() [internal]
119
+ * - Transfer events: transfer() [internal]
120
+ * - Reliable error handling and cleanup
121
+ */
122
+ declare class SimpleEvents {
123
+ private handlers;
105
124
  /**
106
- * Constructs a new ApiHttp instance with the provided client options.
107
- * @param options - Client options including API host, authentication credentials, and timeout settings.
125
+ * Add event handler
108
126
  */
109
- constructor(options: ShipClientOptions);
127
+ on<K extends keyof ShipEvents>(event: K, handler: (...args: ShipEvents[K]) => void): void;
110
128
  /**
111
- * Sends a ping request to the Ship API server to verify connectivity and authentication.
112
- * @returns Promise resolving to `true` if the ping is successful, `false` otherwise.
113
- * @throws {ShipApiError} If the API returns an error response (4xx, 5xx).
114
- * @throws {ShipNetworkError} If a network error occurs (e.g., DNS failure, connection refused).
129
+ * Remove event handler
115
130
  */
116
- ping(): Promise<boolean>;
131
+ off<K extends keyof ShipEvents>(event: K, handler: (...args: ShipEvents[K]) => void): void;
117
132
  /**
118
- * Get full ping response from the API server
119
- * @returns Promise resolving to the full PingResponse object.
133
+ * Emit event (internal use only)
134
+ * @internal
120
135
  */
121
- getPingResponse(): Promise<PingResponse>;
136
+ emit<K extends keyof ShipEvents>(event: K, ...args: ShipEvents[K]): void;
122
137
  /**
123
- * Fetches platform configuration from the API.
124
- * @returns Promise resolving to the config response.
125
- * @throws {ShipError} If the config request fails.
138
+ * Transfer all handlers to another events instance
139
+ * @internal
126
140
  */
127
- getConfig(): Promise<ConfigResponse>;
141
+ transfer(target: SimpleEvents): void;
128
142
  /**
129
- * Deploys an array of StaticFile objects to the Ship API.
130
- * Constructs and sends a multipart/form-data POST request, handling both browser and Node.js environments.
131
- * Validates files and manages deploy progress and error translation.
132
- * @param files - Array of StaticFile objects to deploy (must include MD5 checksums).
133
- * @param options - Optional per-deploy configuration (overrides instance defaults).
134
- * @returns Promise resolving to a full Deployment object on success.
135
- * @throws {ShipFileError} If a file is missing an MD5 checksum or content type is unsupported.
136
- * @throws {ShipClientError} If no files are provided or if environment is unknown.
137
- * @throws {ShipNetworkError} If a network error occurs during deploy.
138
- * @throws {ShipApiError} If the API returns an error response.
139
- * @throws {ShipCancelledError} If the deploy is cancelled via an AbortSignal.
143
+ * Clear all handlers (for cleanup)
144
+ * @internal
140
145
  */
141
- deploy(files: StaticFile[], options?: ApiDeployOptions): Promise<Deployment>;
146
+ clear(): void;
147
+ }
148
+
149
+ /**
150
+ * @file HTTP client with integrated event system
151
+ * Clean, direct implementation with reliable error handling
152
+ */
153
+
154
+ /**
155
+ * HTTP client with integrated event system
156
+ * - Direct event integration
157
+ * - Clean inheritance from SimpleEvents
158
+ * - Reliable error handling
159
+ */
160
+ declare class ApiHttp extends SimpleEvents {
161
+ private readonly apiUrl;
162
+ private readonly apiKey;
163
+ private readonly deployToken;
164
+ constructor(options: ShipClientOptions);
142
165
  /**
143
- * Lists all deployments for the authenticated account
144
- * @returns Promise resolving to deployment list response
166
+ * Transfer events to another client (clean intentional API)
145
167
  */
146
- listDeployments(): Promise<DeploymentListResponse>;
168
+ transferEventsTo(target: ApiHttp): void;
147
169
  /**
148
- * Gets a specific deployment by ID
149
- * @param id - Deployment ID to retrieve
150
- * @returns Promise resolving to deployment details
170
+ * Make authenticated HTTP request with events
151
171
  */
152
- getDeployment(id: string): Promise<Deployment>;
172
+ private request;
153
173
  /**
154
- * Removes a deployment by ID
155
- * @param id - Deployment ID to remove
156
- * @returns Promise resolving when removal is complete
174
+ * Generate auth headers
157
175
  */
158
- removeDeployment(id: string): Promise<void>;
176
+ private getAuthHeaders;
159
177
  /**
160
- * Sets an alias (create or update)
161
- * @param name - Alias name
162
- * @param deployment - Deployment name to point to
163
- * @returns Promise resolving to the created/updated alias with operation context
178
+ * Check if credentials are needed
164
179
  */
165
- setAlias(name: string, deployment: string): Promise<_shipstatic_types.Alias>;
180
+ private needsCredentials;
166
181
  /**
167
- * Gets a specific alias by name
168
- * @param name - Alias name to retrieve
169
- * @returns Promise resolving to alias details
182
+ * Safely clone response for events
170
183
  */
171
- getAlias(name: string): Promise<Alias>;
184
+ private safeClone;
172
185
  /**
173
- * Lists all aliases for the authenticated account
174
- * @returns Promise resolving to alias list response
186
+ * Parse JSON response
175
187
  */
176
- listAliases(): Promise<AliasListResponse>;
188
+ private parseResponse;
177
189
  /**
178
- * Removes an alias by name
179
- * @param name - Alias name to remove
180
- * @returns Promise resolving to removal confirmation
190
+ * Handle response errors
181
191
  */
182
- removeAlias(name: string): Promise<void>;
192
+ private handleResponseError;
183
193
  /**
184
- * Triggers a manual DNS check for an external alias
185
- * @param name - Alias name to check DNS for
186
- * @returns Promise resolving to confirmation message
194
+ * Handle fetch errors
187
195
  */
188
- checkAlias(name: string): Promise<{
196
+ private handleFetchError;
197
+ ping(): Promise<boolean>;
198
+ getPingResponse(): Promise<PingResponse>;
199
+ getConfig(): Promise<ConfigResponse>;
200
+ deploy(files: StaticFile[], options?: ApiDeployOptions): Promise<Deployment>;
201
+ listDeployments(): Promise<DeploymentListResponse>;
202
+ getDeployment(id: string): Promise<Deployment>;
203
+ removeDeployment(id: string): Promise<void>;
204
+ setAlias(name: string, deployment: string, tags?: string[]): Promise<Alias>;
205
+ getAlias(name: string): Promise<Alias>;
206
+ listAliases(): Promise<AliasListResponse>;
207
+ removeAlias(name: string): Promise<void>;
208
+ confirmAlias(name: string): Promise<{
189
209
  message: string;
190
210
  }>;
191
- /**
192
- * Gets account details for the authenticated user
193
- * @returns Promise resolving to account details
194
- */
211
+ getAliasDns(name: string): Promise<{
212
+ alias: string;
213
+ dns: any;
214
+ }>;
215
+ getAliasRecords(name: string): Promise<{
216
+ alias: string;
217
+ records: any[];
218
+ }>;
219
+ getAliasShare(name: string): Promise<{
220
+ alias: string;
221
+ hash: string;
222
+ }>;
195
223
  getAccount(): Promise<Account>;
196
- /**
197
- * Checks if files represent a SPA structure using AI analysis
198
- * @param files - Array of StaticFile objects to analyze
199
- * @returns Promise resolving to boolean indicating if it's a SPA
200
- */
201
224
  checkSPA(files: StaticFile[]): Promise<boolean>;
225
+ private validateFiles;
226
+ private prepareRequestPayload;
227
+ private createBrowserBody;
228
+ private createNodeBody;
229
+ private getBrowserContentType;
202
230
  }
203
231
 
204
232
  /**
205
- * @file All Ship SDK resources in one place - impossibly simple.
233
+ * @file Ship SDK resource implementations for deployments, aliases, and accounts.
206
234
  */
207
235
 
208
236
  declare function createDeploymentResource(getApi: () => ApiHttp, clientDefaults?: ShipClientOptions, ensureInit?: () => Promise<void>, processInput?: (input: DeployInput, options: DeploymentOptions) => Promise<StaticFile[]>): DeploymentResource;
@@ -254,6 +282,24 @@ declare abstract class Ship$1 {
254
282
  * Get account resource
255
283
  */
256
284
  get account(): AccountResource;
285
+ /**
286
+ * Add event listener
287
+ * @param event - Event name
288
+ * @param handler - Event handler function
289
+ */
290
+ on<K extends keyof ShipEvents>(event: K, handler: (...args: ShipEvents[K]) => void): void;
291
+ /**
292
+ * Remove event listener
293
+ * @param event - Event name
294
+ * @param handler - Event handler function
295
+ */
296
+ off<K extends keyof ShipEvents>(event: K, handler: (...args: ShipEvents[K]) => void): void;
297
+ /**
298
+ * Replace HTTP client while preserving event listeners
299
+ * Used during initialization to maintain user event subscriptions
300
+ * @protected
301
+ */
302
+ protected replaceHttpClient(newClient: ApiHttp): void;
257
303
  }
258
304
 
259
305
  /**
@@ -380,16 +426,29 @@ declare function getENV(): ExecutionEnvironment;
380
426
 
381
427
  /**
382
428
  * @file Browser configuration implementation - no file system access.
429
+ * Browser environment receives all config through constructor options.
383
430
  */
384
431
 
385
432
  /**
386
- * Browser config loading - only uses provided options.
433
+ * Browser config loading - always returns empty (no file system access).
434
+ * All configuration must be provided through Ship constructor options.
387
435
  */
388
436
  declare function loadConfig(configFile?: string): Promise<Config>;
437
+
438
+ /**
439
+ * @file Platform configuration management for the Ship SDK.
440
+ * Implements fail-fast dynamic configuration with mandatory API fetch.
441
+ */
442
+
443
+ /**
444
+ * Set the current config (called after fetching from API)
445
+ */
446
+ declare function setConfig(config: ConfigResponse): void;
389
447
  /**
390
- * Set platform config in browser.
448
+ * Get current config - throws if not initialized (fail-fast approach)
449
+ * @throws {ShipError.config} If configuration hasn't been fetched from API
391
450
  */
392
- declare function setConfig(config: any): void;
451
+ declare function getCurrentConfig(): ConfigResponse;
393
452
 
394
453
  /**
395
454
  * @file Browser-specific file utilities for the Ship SDK.
@@ -438,4 +497,4 @@ declare class Ship extends Ship$1 {
438
497
  protected processInput(input: DeployInput, options: DeploymentOptions): Promise<StaticFile[]>;
439
498
  }
440
499
 
441
- export { type ApiDeployOptions, ApiHttp, type Config, type DeployFile, type DeploymentOptions, type ExecutionEnvironment, JUNK_DIRECTORIES, type MD5Result, type ProgressStats, Ship, type ShipClientOptions, __setTestEnvironment, calculateMD5, createAccountResource, createAliasResource, createDeploymentResource, Ship as default, filterJunk, getENV, loadConfig, mergeDeployOptions, optimizeDeployPaths, pluralize, processFilesForBrowser, resolveConfig, setConfig };
500
+ export { type ApiDeployOptions, ApiHttp, type Config, type DeployFile, type DeploymentOptions, type ExecutionEnvironment, JUNK_DIRECTORIES, type MD5Result, type ProgressStats, Ship, type ShipClientOptions, type ShipEvents, __setTestEnvironment, calculateMD5, createAccountResource, createAliasResource, createDeploymentResource, Ship as default, filterJunk, getCurrentConfig, getENV, loadConfig, mergeDeployOptions, optimizeDeployPaths, pluralize, processFilesForBrowser, resolveConfig, setConfig as setPlatformConfig };