@shipstatic/types 0.4.11 → 0.4.13

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
@@ -292,11 +292,10 @@ export declare class ShipError extends Error {
292
292
  static cancelled(message: string): ShipError;
293
293
  static file(message: string, filePath?: string): ShipError;
294
294
  static config(message: string, details?: any): ShipError;
295
- static api(message: string, status?: number, code?: string, data?: any): ShipError;
295
+ static api(message: string, status?: number): ShipError;
296
296
  static database(message: string, status?: number): ShipError;
297
297
  static storage(message: string, status?: number): ShipError;
298
298
  get filePath(): string | undefined;
299
- get code(): string | undefined;
300
299
  isClientError(): boolean;
301
300
  isNetworkError(): boolean;
302
301
  isAuthError(): boolean;
@@ -305,6 +304,18 @@ export declare class ShipError extends Error {
305
304
  isConfigError(): boolean;
306
305
  isType(errorType: ErrorType): boolean;
307
306
  }
307
+ /**
308
+ * Type guard to check if an unknown value is a ShipError.
309
+ *
310
+ * Uses structural checking instead of instanceof to handle module duplication
311
+ * in bundled applications where multiple copies of the ShipError class may exist.
312
+ *
313
+ * @example
314
+ * if (isShipError(error)) {
315
+ * console.log(error.status, error.message);
316
+ * }
317
+ */
318
+ export declare function isShipError(error: unknown): error is ShipError;
308
319
  /**
309
320
  * Platform configuration response from API
310
321
  */
@@ -694,13 +705,6 @@ export interface UploadedFile {
694
705
  size: number;
695
706
  validated?: boolean;
696
707
  }
697
- /**
698
- * Rate limiting data structure
699
- */
700
- export interface RateLimitData {
701
- count: number;
702
- timestamp: number;
703
- }
704
708
  /**
705
709
  * Check if a domain is a platform domain (subdomain of our platform).
706
710
  * Platform domains are free and don't require DNS verification.
package/dist/index.js CHANGED
@@ -138,8 +138,8 @@ export class ShipError extends Error {
138
138
  static config(message, details) {
139
139
  return new ShipError(ErrorType.Config, message, undefined, details);
140
140
  }
141
- static api(message, status = 500, code, data) {
142
- return new ShipError(ErrorType.Api, message, status, { code, data });
141
+ static api(message, status = 500) {
142
+ return new ShipError(ErrorType.Api, message, status);
143
143
  }
144
144
  static database(message, status = 500) {
145
145
  return new ShipError(ErrorType.Api, message, status);
@@ -147,13 +147,10 @@ export class ShipError extends Error {
147
147
  static storage(message, status = 500) {
148
148
  return new ShipError(ErrorType.Api, message, status);
149
149
  }
150
- // Helper getters for accessing common detail properties
150
+ // Helper getter for accessing file path from details
151
151
  get filePath() {
152
152
  return this.details?.filePath;
153
153
  }
154
- get code() {
155
- return this.details?.code;
156
- }
157
154
  // Helper methods for error type checking using categorization
158
155
  isClientError() {
159
156
  return ERROR_CATEGORIES.client.has(this.type);
@@ -178,6 +175,24 @@ export class ShipError extends Error {
178
175
  return this.type === errorType;
179
176
  }
180
177
  }
178
+ /**
179
+ * Type guard to check if an unknown value is a ShipError.
180
+ *
181
+ * Uses structural checking instead of instanceof to handle module duplication
182
+ * in bundled applications where multiple copies of the ShipError class may exist.
183
+ *
184
+ * @example
185
+ * if (isShipError(error)) {
186
+ * console.log(error.status, error.message);
187
+ * }
188
+ */
189
+ export function isShipError(error) {
190
+ return (error !== null &&
191
+ typeof error === 'object' &&
192
+ 'name' in error &&
193
+ error.name === 'ShipError' &&
194
+ 'status' in error);
195
+ }
181
196
  // API Key Configuration
182
197
  export const API_KEY_PREFIX = 'ship-';
183
198
  export const API_KEY_HEX_LENGTH = 64;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipstatic/types",
3
- "version": "0.4.11",
3
+ "version": "0.4.13",
4
4
  "description": "Shared types for Shipstatic platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/index.ts CHANGED
@@ -395,8 +395,8 @@ export class ShipError extends Error {
395
395
  return new ShipError(ErrorType.Config, message, undefined, details);
396
396
  }
397
397
 
398
- static api(message: string, status: number = 500, code?: string, data?: any): ShipError {
399
- return new ShipError(ErrorType.Api, message, status, { code, data });
398
+ static api(message: string, status: number = 500): ShipError {
399
+ return new ShipError(ErrorType.Api, message, status);
400
400
  }
401
401
 
402
402
  static database(message: string, status: number = 500): ShipError {
@@ -407,15 +407,11 @@ export class ShipError extends Error {
407
407
  return new ShipError(ErrorType.Api, message, status);
408
408
  }
409
409
 
410
- // Helper getters for accessing common detail properties
410
+ // Helper getter for accessing file path from details
411
411
  get filePath(): string | undefined {
412
412
  return this.details?.filePath;
413
413
  }
414
414
 
415
- get code(): string | undefined {
416
- return this.details?.code;
417
- }
418
-
419
415
  // Helper methods for error type checking using categorization
420
416
  isClientError(): boolean {
421
417
  return ERROR_CATEGORIES.client.has(this.type);
@@ -447,6 +443,27 @@ export class ShipError extends Error {
447
443
  }
448
444
  }
449
445
 
446
+ /**
447
+ * Type guard to check if an unknown value is a ShipError.
448
+ *
449
+ * Uses structural checking instead of instanceof to handle module duplication
450
+ * in bundled applications where multiple copies of the ShipError class may exist.
451
+ *
452
+ * @example
453
+ * if (isShipError(error)) {
454
+ * console.log(error.status, error.message);
455
+ * }
456
+ */
457
+ export function isShipError(error: unknown): error is ShipError {
458
+ return (
459
+ error !== null &&
460
+ typeof error === 'object' &&
461
+ 'name' in error &&
462
+ error.name === 'ShipError' &&
463
+ 'status' in error
464
+ );
465
+ }
466
+
450
467
  // =============================================================================
451
468
  // CONFIG TYPES
452
469
  // =============================================================================
@@ -1031,14 +1048,6 @@ export interface UploadedFile {
1031
1048
  validated?: boolean;
1032
1049
  }
1033
1050
 
1034
- /**
1035
- * Rate limiting data structure
1036
- */
1037
- export interface RateLimitData {
1038
- count: number;
1039
- timestamp: number;
1040
- }
1041
-
1042
1051
  // =============================================================================
1043
1052
  // DOMAIN UTILITIES
1044
1053
  // =============================================================================