@shipstatic/types 0.2.0 → 0.2.2

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
@@ -50,8 +50,6 @@ interface Account {
50
50
  picture?: string; // Profile picture URL
51
51
  plan: 'free' | 'active' | 'suspended'; // Account plan status
52
52
  created: number; // Unix timestamp (seconds)
53
- subscribed?: number; // Unix timestamp (seconds) when plan started
54
- suspended?: number; // Unix timestamp (seconds) when suspended
55
53
  }
56
54
  ```
57
55
 
@@ -212,7 +210,7 @@ const serverConfig = {
212
210
  maxFileSize: 10 * 1024 * 1024, // 10MB
213
211
  maxFilesCount: 1000, // Files per deployment
214
212
  maxTotalSize: 100 * 1024 * 1024, // 100MB total
215
- deploymentExpiryHours: 168, // 7 days
213
+ deploymentExpiryHours: 120, // 5 days
216
214
  defaultLimit: 50, // Pagination default
217
215
  maxLimit: 100, // Pagination maximum
218
216
  } as const;
package/dist/index.d.ts CHANGED
@@ -12,8 +12,8 @@ export interface Deployment {
12
12
  files: number;
13
13
  /** Total size of all files in bytes */
14
14
  size: number;
15
- /** Current deployment status */
16
- status: 'pending' | 'success' | 'failed' | 'deleting';
15
+ /** Current deployment status - computed from verified field */
16
+ status: 'incomplete' | 'complete';
17
17
  /** Whether deployment has configuration */
18
18
  config?: boolean;
19
19
  /** The deployment URL */
@@ -91,10 +91,6 @@ export interface Account {
91
91
  plan: 'free' | 'active' | 'suspended';
92
92
  /** Unix timestamp (seconds) when account was created */
93
93
  created: number;
94
- /** Unix timestamp (seconds) when plan started */
95
- subscribed?: number;
96
- /** Unix timestamp (seconds) when account was suspended */
97
- suspended?: number;
98
94
  }
99
95
  /**
100
96
  * All possible error types in the Shipstatic platform
@@ -152,7 +148,7 @@ export declare class ShipError extends Error {
152
148
  static validation(message: string, details?: any): ShipError;
153
149
  static notFound(resource: string, id?: string): ShipError;
154
150
  static rateLimit(message?: string): ShipError;
155
- static authentication(message?: string): ShipError;
151
+ static authentication(message?: string, details?: any): ShipError;
156
152
  static business(message: string, status?: number): ShipError;
157
153
  static network(message: string, cause?: Error): ShipError;
158
154
  static cancelled(message: string): ShipError;
@@ -182,7 +178,7 @@ export declare const serverConfig: {
182
178
  /** Maximum total deployment size in bytes (100MB) */
183
179
  readonly maxTotalSize: number;
184
180
  /** Deployment expiry in hours */
185
- readonly deploymentExpiryHours: 168;
181
+ readonly deploymentExpiryHours: 120;
186
182
  /** Pagination limits */
187
183
  readonly defaultLimit: 50;
188
184
  readonly maxLimit: 100;
@@ -352,13 +348,11 @@ export interface UploadedFile {
352
348
  validated?: boolean;
353
349
  }
354
350
  /**
355
- * Upload/deployment status enum
351
+ * Deployment status - computed from verified timestamp
356
352
  */
357
- export declare enum UploadStatus {
358
- PENDING = "pending",
359
- SUCCESS = "success",
360
- FAILED = "failed",
361
- DELETING = "deleting"
353
+ export declare enum DeploymentStatus {
354
+ INCOMPLETE = "incomplete",// verified IS NULL
355
+ COMPLETE = "complete"
362
356
  }
363
357
  /**
364
358
  * Rate limiting data structure
package/dist/index.js CHANGED
@@ -58,11 +58,15 @@ export class ShipError extends Error {
58
58
  }
59
59
  /** Convert to wire format */
60
60
  toResponse() {
61
+ // For security, exclude internal details from authentication errors in API responses
62
+ const details = this.type === ErrorType.Authentication && this.details?.internal
63
+ ? undefined
64
+ : this.details;
61
65
  return {
62
66
  error: this.type,
63
67
  message: this.message,
64
68
  status: this.status,
65
- details: this.details
69
+ details
66
70
  };
67
71
  }
68
72
  /** Create from wire format */
@@ -80,8 +84,8 @@ export class ShipError extends Error {
80
84
  static rateLimit(message = "Too many requests") {
81
85
  return new ShipError(ErrorType.RateLimit, message, 429);
82
86
  }
83
- static authentication(message = "Authentication required") {
84
- return new ShipError(ErrorType.Authentication, message, 401);
87
+ static authentication(message = "Authentication required", details) {
88
+ return new ShipError(ErrorType.Authentication, message, 401, details);
85
89
  }
86
90
  static business(message, status = 400) {
87
91
  return new ShipError(ErrorType.Business, message, status);
@@ -152,7 +156,7 @@ export const serverConfig = {
152
156
  /** Maximum total deployment size in bytes (100MB) */
153
157
  maxTotalSize: 100 * 1024 * 1024,
154
158
  /** Deployment expiry in hours */
155
- deploymentExpiryHours: 168, // 7 days
159
+ deploymentExpiryHours: 120, // 5 days
156
160
  /** Pagination limits */
157
161
  defaultLimit: 50,
158
162
  maxLimit: 100,
@@ -236,15 +240,13 @@ export function validateSubdomain(input) {
236
240
  /** Default API URL if not otherwise configured. */
237
241
  export const DEFAULT_API = 'https://api.shipstatic.com';
238
242
  /**
239
- * Upload/deployment status enum
243
+ * Deployment status - computed from verified timestamp
240
244
  */
241
- export var UploadStatus;
242
- (function (UploadStatus) {
243
- UploadStatus["PENDING"] = "pending";
244
- UploadStatus["SUCCESS"] = "success";
245
- UploadStatus["FAILED"] = "failed";
246
- UploadStatus["DELETING"] = "deleting";
247
- })(UploadStatus || (UploadStatus = {}));
245
+ export var DeploymentStatus;
246
+ (function (DeploymentStatus) {
247
+ DeploymentStatus["INCOMPLETE"] = "incomplete";
248
+ DeploymentStatus["COMPLETE"] = "complete"; // verified IS NOT NULL
249
+ })(DeploymentStatus || (DeploymentStatus = {}));
248
250
  // =============================================================================
249
251
  // URL GENERATION UTILITIES
250
252
  // =============================================================================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipstatic/types",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Shared types for Shipstatic platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/index.ts CHANGED
@@ -17,8 +17,8 @@ export interface Deployment {
17
17
  files: number;
18
18
  /** Total size of all files in bytes */
19
19
  size: number;
20
- /** Current deployment status */
21
- status: 'pending' | 'success' | 'failed' | 'deleting';
20
+ /** Current deployment status - computed from verified field */
21
+ status: 'incomplete' | 'complete';
22
22
  /** Whether deployment has configuration */
23
23
  config?: boolean;
24
24
  /** The deployment URL */
@@ -110,10 +110,6 @@ export interface Account {
110
110
  plan: 'free' | 'active' | 'suspended';
111
111
  /** Unix timestamp (seconds) when account was created */
112
112
  created: number;
113
- /** Unix timestamp (seconds) when plan started */
114
- subscribed?: number;
115
- /** Unix timestamp (seconds) when account was suspended */
116
- suspended?: number;
117
113
  }
118
114
 
119
115
  // =============================================================================
@@ -189,11 +185,16 @@ export class ShipError extends Error {
189
185
 
190
186
  /** Convert to wire format */
191
187
  toResponse(): ErrorResponse {
188
+ // For security, exclude internal details from authentication errors in API responses
189
+ const details = this.type === ErrorType.Authentication && this.details?.internal
190
+ ? undefined
191
+ : this.details;
192
+
192
193
  return {
193
194
  error: this.type,
194
195
  message: this.message,
195
196
  status: this.status,
196
- details: this.details
197
+ details
197
198
  };
198
199
  }
199
200
 
@@ -216,8 +217,8 @@ export class ShipError extends Error {
216
217
  return new ShipError(ErrorType.RateLimit, message, 429);
217
218
  }
218
219
 
219
- static authentication(message: string = "Authentication required"): ShipError {
220
- return new ShipError(ErrorType.Authentication, message, 401);
220
+ static authentication(message: string = "Authentication required", details?: any): ShipError {
221
+ return new ShipError(ErrorType.Authentication, message, 401, details);
221
222
  }
222
223
 
223
224
 
@@ -308,7 +309,7 @@ export const serverConfig = {
308
309
  /** Maximum total deployment size in bytes (100MB) */
309
310
  maxTotalSize: 100 * 1024 * 1024,
310
311
  /** Deployment expiry in hours */
311
- deploymentExpiryHours: 168, // 7 days
312
+ deploymentExpiryHours: 120, // 5 days
312
313
  /** Pagination limits */
313
314
  defaultLimit: 50,
314
315
  maxLimit: 100,
@@ -588,13 +589,11 @@ export interface UploadedFile {
588
589
  }
589
590
 
590
591
  /**
591
- * Upload/deployment status enum
592
+ * Deployment status - computed from verified timestamp
592
593
  */
593
- export enum UploadStatus {
594
- PENDING = 'pending',
595
- SUCCESS = 'success',
596
- FAILED = 'failed',
597
- DELETING = 'deleting'
594
+ export enum DeploymentStatus {
595
+ INCOMPLETE = 'incomplete', // verified IS NULL
596
+ COMPLETE = 'complete' // verified IS NOT NULL
598
597
  }
599
598
 
600
599
  /**