@shipstatic/types 0.3.2 → 0.3.4

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
@@ -148,7 +148,8 @@ export interface TokenCreateResponse {
148
148
  export declare const AccountPlan: {
149
149
  readonly FREE: "free";
150
150
  readonly PAID: "paid";
151
- readonly PARTNER: "partner";
151
+ readonly SPONSORED: "sponsored";
152
+ readonly ENTERPRISE: "enterprise";
152
153
  readonly SUSPENDED: "suspended";
153
154
  readonly TERMINATING: "terminating";
154
155
  readonly TERMINATED: "terminated";
@@ -369,11 +370,12 @@ export interface PlatformConfig {
369
370
  /** Default API URL if not otherwise configured. */
370
371
  export declare const DEFAULT_API = "https://api.shipstatic.com";
371
372
  /**
372
- * Universal deploy input type for all environments.
373
- * - File[] | FileList: Browser environments (file upload)
374
- * - string: Node.js environments (file/directory path)
373
+ * Deploy input type - environment-specific
374
+ *
375
+ * Browser: File[] - array of File objects
376
+ * Node.js: string | string[] - file/directory paths
375
377
  */
376
- export type DeployInput = File[] | FileList | string;
378
+ export type DeployInput = File[] | string | string[];
377
379
  /**
378
380
  * Deployment resource interface - the contract all implementations must follow
379
381
  */
@@ -429,6 +431,50 @@ export interface KeysResource {
429
431
  apiKey: string;
430
432
  }>;
431
433
  }
434
+ /**
435
+ * File status constants for validation state tracking
436
+ */
437
+ export declare const FileValidationStatus: {
438
+ readonly PENDING: "pending";
439
+ readonly PROCESSING_ERROR: "processing_error";
440
+ readonly EMPTY_FILE: "empty_file";
441
+ readonly VALIDATION_FAILED: "validation_failed";
442
+ readonly READY: "ready";
443
+ };
444
+ export type FileValidationStatusType = typeof FileValidationStatus[keyof typeof FileValidationStatus];
445
+ /**
446
+ * Client-side validation error structure
447
+ */
448
+ export interface ValidationError {
449
+ error: string;
450
+ details: string;
451
+ errors: string[];
452
+ isClientError: true;
453
+ }
454
+ /**
455
+ * Minimal file interface required for validation
456
+ */
457
+ export interface ValidatableFile {
458
+ name: string;
459
+ size: number;
460
+ type: string;
461
+ status?: string;
462
+ statusMessage?: string;
463
+ }
464
+ /**
465
+ * File validation result
466
+ *
467
+ * NOTE: Validation is ATOMIC - if any file fails validation, ALL files are rejected.
468
+ * This ensures deployments are all-or-nothing for data integrity.
469
+ */
470
+ export interface FileValidationResult<T extends ValidatableFile> {
471
+ /** All files with updated status */
472
+ files: T[];
473
+ /** Files that passed validation (empty if ANY file failed - atomic validation) */
474
+ validFiles: T[];
475
+ /** Validation error if any files failed */
476
+ error: ValidationError | null;
477
+ }
432
478
  /**
433
479
  * Represents a file that has been uploaded and stored
434
480
  */
package/dist/index.js CHANGED
@@ -35,7 +35,8 @@ export const DomainStatus = {
35
35
  export const AccountPlan = {
36
36
  FREE: 'free',
37
37
  PAID: 'paid',
38
- PARTNER: 'partner',
38
+ SPONSORED: 'sponsored',
39
+ ENTERPRISE: 'enterprise',
39
40
  SUSPENDED: 'suspended',
40
41
  TERMINATING: 'terminating',
41
42
  TERMINATED: 'terminated'
@@ -265,6 +266,19 @@ export function validateSubdomain(input) {
265
266
  /** Default API URL if not otherwise configured. */
266
267
  export const DEFAULT_API = 'https://api.shipstatic.com';
267
268
  // =============================================================================
269
+ // FILE UPLOAD TYPES
270
+ // =============================================================================
271
+ /**
272
+ * File status constants for validation state tracking
273
+ */
274
+ export const FileValidationStatus = {
275
+ PENDING: 'pending',
276
+ PROCESSING_ERROR: 'processing_error',
277
+ EMPTY_FILE: 'empty_file',
278
+ VALIDATION_FAILED: 'validation_failed',
279
+ READY: 'ready',
280
+ };
281
+ // =============================================================================
268
282
  // URL GENERATION UTILITIES
269
283
  // =============================================================================
270
284
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipstatic/types",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Shared types for Shipstatic platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -33,8 +33,8 @@
33
33
  "node": ">=20.0.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@types/node": "^24.3.0",
37
- "typescript": "^5.9.2"
36
+ "@types/node": "^24.10.4",
37
+ "typescript": "^5.9.3"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "tsc",
package/src/index.ts CHANGED
@@ -178,7 +178,8 @@ export interface TokenCreateResponse {
178
178
  export const AccountPlan = {
179
179
  FREE: 'free',
180
180
  PAID: 'paid',
181
- PARTNER: 'partner',
181
+ SPONSORED: 'sponsored',
182
+ ENTERPRISE: 'enterprise',
182
183
  SUSPENDED: 'suspended',
183
184
  TERMINATING: 'terminating',
184
185
  TERMINATED: 'terminated'
@@ -216,7 +217,7 @@ export enum ErrorType {
216
217
  /** Validation failed (400) */
217
218
  Validation = "validation_failed",
218
219
  /** Resource not found (404) */
219
- NotFound = "not_found",
220
+ NotFound = "not_found",
220
221
  /** Rate limit exceeded (429) */
221
222
  RateLimit = "rate_limit_exceeded",
222
223
  /** Authentication required (401) */
@@ -278,10 +279,10 @@ export class ShipError extends Error {
278
279
  /** Convert to wire format */
279
280
  toResponse(): ErrorResponse {
280
281
  // For security, exclude internal details from authentication errors in API responses
281
- const details = this.type === ErrorType.Authentication && this.details?.internal
282
- ? undefined
282
+ const details = this.type === ErrorType.Authentication && this.details?.internal
283
+ ? undefined
283
284
  : this.details;
284
-
285
+
285
286
  return {
286
287
  error: this.type,
287
288
  message: this.message,
@@ -449,7 +450,7 @@ export const DEPLOY_TOKEN_TOTAL_LENGTH = DEPLOY_TOKEN_PREFIX.length + DEPLOY_TOK
449
450
  // Authentication Method Constants
450
451
  export const AuthMethod = {
451
452
  JWT: 'jwt',
452
- API_KEY: 'apiKey',
453
+ API_KEY: 'apiKey',
453
454
  TOKEN: 'token'
454
455
  } as const;
455
456
 
@@ -469,11 +470,11 @@ export function validateApiKey(apiKey: string): void {
469
470
  if (!apiKey.startsWith(API_KEY_PREFIX)) {
470
471
  throw ShipError.validation(`API key must start with "${API_KEY_PREFIX}"`);
471
472
  }
472
-
473
+
473
474
  if (apiKey.length !== API_KEY_TOTAL_LENGTH) {
474
475
  throw ShipError.validation(`API key must be ${API_KEY_TOTAL_LENGTH} characters total (${API_KEY_PREFIX} + ${API_KEY_HEX_LENGTH} hex chars)`);
475
476
  }
476
-
477
+
477
478
  const hexPart = apiKey.slice(API_KEY_PREFIX.length);
478
479
  if (!/^[a-f0-9]{64}$/i.test(hexPart)) {
479
480
  throw ShipError.validation(`API key must contain ${API_KEY_HEX_LENGTH} hexadecimal characters after "${API_KEY_PREFIX}" prefix`);
@@ -487,11 +488,11 @@ export function validateDeployToken(deployToken: string): void {
487
488
  if (!deployToken.startsWith(DEPLOY_TOKEN_PREFIX)) {
488
489
  throw ShipError.validation(`Deploy token must start with "${DEPLOY_TOKEN_PREFIX}"`);
489
490
  }
490
-
491
+
491
492
  if (deployToken.length !== DEPLOY_TOKEN_TOTAL_LENGTH) {
492
493
  throw ShipError.validation(`Deploy token must be ${DEPLOY_TOKEN_TOTAL_LENGTH} characters total (${DEPLOY_TOKEN_PREFIX} + ${DEPLOY_TOKEN_HEX_LENGTH} hex chars)`);
493
494
  }
494
-
495
+
495
496
  const hexPart = deployToken.slice(DEPLOY_TOKEN_PREFIX.length);
496
497
  if (!/^[a-f0-9]{64}$/i.test(hexPart)) {
497
498
  throw ShipError.validation(`Deploy token must contain ${DEPLOY_TOKEN_HEX_LENGTH} hexadecimal characters after "${DEPLOY_TOKEN_PREFIX}" prefix`);
@@ -504,15 +505,15 @@ export function validateDeployToken(deployToken: string): void {
504
505
  export function validateApiUrl(apiUrl: string): void {
505
506
  try {
506
507
  const url = new URL(apiUrl);
507
-
508
+
508
509
  if (!['http:', 'https:'].includes(url.protocol)) {
509
510
  throw ShipError.validation('API URL must use http:// or https:// protocol');
510
511
  }
511
-
512
+
512
513
  if (url.pathname !== '/' && url.pathname !== '') {
513
514
  throw ShipError.validation('API URL must not contain a path');
514
515
  }
515
-
516
+
516
517
  if (url.search || url.hash) {
517
518
  throw ShipError.validation('API URL must not contain query parameters or fragments');
518
519
  }
@@ -620,11 +621,12 @@ export const DEFAULT_API = 'https://api.shipstatic.com';
620
621
  // =============================================================================
621
622
 
622
623
  /**
623
- * Universal deploy input type for all environments.
624
- * - File[] | FileList: Browser environments (file upload)
625
- * - string: Node.js environments (file/directory path)
624
+ * Deploy input type - environment-specific
625
+ *
626
+ * Browser: File[] - array of File objects
627
+ * Node.js: string | string[] - file/directory paths
626
628
  */
627
- export type DeployInput = File[] | FileList | string;
629
+ export type DeployInput = File[] | string | string[];
628
630
 
629
631
  /**
630
632
  * Deployment resource interface - the contract all implementations must follow
@@ -677,6 +679,55 @@ export interface KeysResource {
677
679
  // FILE UPLOAD TYPES
678
680
  // =============================================================================
679
681
 
682
+ /**
683
+ * File status constants for validation state tracking
684
+ */
685
+ export const FileValidationStatus = {
686
+ PENDING: 'pending',
687
+ PROCESSING_ERROR: 'processing_error',
688
+ EMPTY_FILE: 'empty_file',
689
+ VALIDATION_FAILED: 'validation_failed',
690
+ READY: 'ready',
691
+ } as const;
692
+
693
+ export type FileValidationStatusType = typeof FileValidationStatus[keyof typeof FileValidationStatus];
694
+
695
+ /**
696
+ * Client-side validation error structure
697
+ */
698
+ export interface ValidationError {
699
+ error: string;
700
+ details: string;
701
+ errors: string[];
702
+ isClientError: true;
703
+ }
704
+
705
+ /**
706
+ * Minimal file interface required for validation
707
+ */
708
+ export interface ValidatableFile {
709
+ name: string;
710
+ size: number;
711
+ type: string;
712
+ status?: string;
713
+ statusMessage?: string;
714
+ }
715
+
716
+ /**
717
+ * File validation result
718
+ *
719
+ * NOTE: Validation is ATOMIC - if any file fails validation, ALL files are rejected.
720
+ * This ensures deployments are all-or-nothing for data integrity.
721
+ */
722
+ export interface FileValidationResult<T extends ValidatableFile> {
723
+ /** All files with updated status */
724
+ files: T[];
725
+ /** Files that passed validation (empty if ANY file failed - atomic validation) */
726
+ validFiles: T[];
727
+ /** Validation error if any files failed */
728
+ error: ValidationError | null;
729
+ }
730
+
680
731
  /**
681
732
  * Represents a file that has been uploaded and stored
682
733
  */