@shipstatic/types 0.2.2 → 0.2.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 +48 -38
- package/dist/index.js +35 -27
- package/package.json +1 -1
- package/src/index.ts +58 -43
package/dist/index.d.ts
CHANGED
|
@@ -2,28 +2,40 @@
|
|
|
2
2
|
* @file Shared TypeScript types, constants, and utilities for the Shipstatic platform.
|
|
3
3
|
* This package is the single source of truth for all shared data structures.
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* Deployment status constants
|
|
7
|
+
*/
|
|
8
|
+
export declare const DeploymentStatus: {
|
|
9
|
+
readonly PENDING: "pending";
|
|
10
|
+
readonly SUCCESS: "success";
|
|
11
|
+
readonly FAILED: "failed";
|
|
12
|
+
readonly DELETING: "deleting";
|
|
13
|
+
};
|
|
14
|
+
export type DeploymentStatusType = typeof DeploymentStatus[keyof typeof DeploymentStatus];
|
|
5
15
|
/**
|
|
6
16
|
* Core deployment object - used in both API responses and SDK
|
|
7
17
|
*/
|
|
8
18
|
export interface Deployment {
|
|
9
19
|
/** The deployment ID */
|
|
10
|
-
deployment: string;
|
|
20
|
+
readonly deployment: string;
|
|
11
21
|
/** Number of files in this deployment */
|
|
12
|
-
files: number;
|
|
22
|
+
readonly files: number;
|
|
13
23
|
/** Total size of all files in bytes */
|
|
14
|
-
size: number;
|
|
15
|
-
/** Current deployment status
|
|
16
|
-
status:
|
|
24
|
+
readonly size: number;
|
|
25
|
+
/** Current deployment status */
|
|
26
|
+
status: DeploymentStatusType;
|
|
17
27
|
/** Whether deployment has configuration */
|
|
18
|
-
config?: boolean;
|
|
28
|
+
readonly config?: boolean;
|
|
19
29
|
/** The deployment URL */
|
|
20
|
-
url: string;
|
|
30
|
+
readonly url: string;
|
|
21
31
|
/** Unix timestamp (seconds) when deployment was created */
|
|
22
|
-
created: number;
|
|
32
|
+
readonly created: number;
|
|
23
33
|
/** Unix timestamp (seconds) when deployment expires */
|
|
24
34
|
expires?: number;
|
|
25
35
|
/** Unix timestamp (seconds) when deployment was verified and ready */
|
|
26
36
|
verified?: number;
|
|
37
|
+
/** Short-lived JWT token for claiming this deployment (only present for public deployments) */
|
|
38
|
+
claimToken?: string;
|
|
27
39
|
}
|
|
28
40
|
/**
|
|
29
41
|
* Response for listing deployments
|
|
@@ -36,24 +48,33 @@ export interface DeploymentListResponse {
|
|
|
36
48
|
/** Total number of deployments if available */
|
|
37
49
|
total?: number;
|
|
38
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Alias status constants
|
|
53
|
+
*/
|
|
54
|
+
export declare const AliasStatus: {
|
|
55
|
+
readonly PENDING: "pending";
|
|
56
|
+
readonly SUCCESS: "success";
|
|
57
|
+
readonly FAILED: "failed";
|
|
58
|
+
};
|
|
59
|
+
export type AliasStatusType = typeof AliasStatus[keyof typeof AliasStatus];
|
|
39
60
|
/**
|
|
40
61
|
* Core alias object - used in both API responses and SDK
|
|
41
62
|
*/
|
|
42
63
|
export interface Alias {
|
|
43
64
|
/** The alias name */
|
|
44
|
-
alias: string;
|
|
65
|
+
readonly alias: string;
|
|
45
66
|
/** The deployment name this alias points to */
|
|
46
67
|
deployment: string;
|
|
47
68
|
/** Current alias status */
|
|
48
|
-
status:
|
|
69
|
+
status: AliasStatusType;
|
|
49
70
|
/** The alias URL - internal (subdomain) or external (custom domain) */
|
|
50
|
-
url: string;
|
|
71
|
+
readonly url: string;
|
|
51
72
|
/** Unix timestamp (seconds) when alias was created */
|
|
52
|
-
created: number;
|
|
73
|
+
readonly created: number;
|
|
74
|
+
/** Whether this was a create (201) or update (200) operation */
|
|
75
|
+
readonly isCreate?: boolean;
|
|
53
76
|
/** Unix timestamp (seconds) when alias was confirmed */
|
|
54
77
|
confirmed?: number;
|
|
55
|
-
/** Whether this was a create operation (true) or update operation (false). Optional - only present in set operations */
|
|
56
|
-
isCreate?: boolean;
|
|
57
78
|
}
|
|
58
79
|
/**
|
|
59
80
|
* Response for listing aliases
|
|
@@ -77,6 +98,16 @@ export interface DeploymentRemoveResponse {
|
|
|
77
98
|
/** Human-readable message */
|
|
78
99
|
message?: string;
|
|
79
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Account plan constants
|
|
103
|
+
*/
|
|
104
|
+
export declare const AccountPlan: {
|
|
105
|
+
readonly FREE: "free";
|
|
106
|
+
readonly PAID: "paid";
|
|
107
|
+
readonly PARTNER: "partner";
|
|
108
|
+
readonly BLOCKED: "blocked";
|
|
109
|
+
};
|
|
110
|
+
export type AccountPlanType = typeof AccountPlan[keyof typeof AccountPlan];
|
|
80
111
|
/**
|
|
81
112
|
* Core account object - used in both API responses and SDK
|
|
82
113
|
*/
|
|
@@ -88,9 +119,11 @@ export interface Account {
|
|
|
88
119
|
/** User profile picture URL */
|
|
89
120
|
picture?: string;
|
|
90
121
|
/** Account plan status */
|
|
91
|
-
plan:
|
|
122
|
+
plan: AccountPlanType;
|
|
92
123
|
/** Unix timestamp (seconds) when account was created */
|
|
93
124
|
created: number;
|
|
125
|
+
/** Unix timestamp (seconds) when account was activated (first deployment) */
|
|
126
|
+
activated?: number;
|
|
94
127
|
}
|
|
95
128
|
/**
|
|
96
129
|
* All possible error types in the Shipstatic platform
|
|
@@ -167,22 +200,6 @@ export declare class ShipError extends Error {
|
|
|
167
200
|
isConfigError(): boolean;
|
|
168
201
|
isType(errorType: ErrorType): boolean;
|
|
169
202
|
}
|
|
170
|
-
/**
|
|
171
|
-
* Server-side platform configuration - enforced limits on the platform
|
|
172
|
-
*/
|
|
173
|
-
export declare const serverConfig: {
|
|
174
|
-
/** Maximum individual file size in bytes (10MB) */
|
|
175
|
-
readonly maxFileSize: number;
|
|
176
|
-
/** Maximum number of files per deployment */
|
|
177
|
-
readonly maxFilesCount: 1000;
|
|
178
|
-
/** Maximum total deployment size in bytes (100MB) */
|
|
179
|
-
readonly maxTotalSize: number;
|
|
180
|
-
/** Deployment expiry in hours */
|
|
181
|
-
readonly deploymentExpiryHours: 120;
|
|
182
|
-
/** Pagination limits */
|
|
183
|
-
readonly defaultLimit: 50;
|
|
184
|
-
readonly maxLimit: 100;
|
|
185
|
-
};
|
|
186
203
|
/**
|
|
187
204
|
* Platform configuration response from API
|
|
188
205
|
*/
|
|
@@ -347,13 +364,6 @@ export interface UploadedFile {
|
|
|
347
364
|
size: number;
|
|
348
365
|
validated?: boolean;
|
|
349
366
|
}
|
|
350
|
-
/**
|
|
351
|
-
* Deployment status - computed from verified timestamp
|
|
352
|
-
*/
|
|
353
|
-
export declare enum DeploymentStatus {
|
|
354
|
-
INCOMPLETE = "incomplete",// verified IS NULL
|
|
355
|
-
COMPLETE = "complete"
|
|
356
|
-
}
|
|
357
367
|
/**
|
|
358
368
|
* Rate limiting data structure
|
|
359
369
|
*/
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,41 @@
|
|
|
3
3
|
* This package is the single source of truth for all shared data structures.
|
|
4
4
|
*/
|
|
5
5
|
// =============================================================================
|
|
6
|
+
// I. CORE ENTITIES
|
|
7
|
+
// =============================================================================
|
|
8
|
+
/**
|
|
9
|
+
* Deployment status constants
|
|
10
|
+
*/
|
|
11
|
+
export const DeploymentStatus = {
|
|
12
|
+
PENDING: 'pending',
|
|
13
|
+
SUCCESS: 'success',
|
|
14
|
+
FAILED: 'failed',
|
|
15
|
+
DELETING: 'deleting'
|
|
16
|
+
};
|
|
17
|
+
// =============================================================================
|
|
18
|
+
// ALIAS TYPES
|
|
19
|
+
// =============================================================================
|
|
20
|
+
/**
|
|
21
|
+
* Alias status constants
|
|
22
|
+
*/
|
|
23
|
+
export const AliasStatus = {
|
|
24
|
+
PENDING: 'pending',
|
|
25
|
+
SUCCESS: 'success',
|
|
26
|
+
FAILED: 'failed'
|
|
27
|
+
};
|
|
28
|
+
// =============================================================================
|
|
29
|
+
// ACCOUNT TYPES
|
|
30
|
+
// =============================================================================
|
|
31
|
+
/**
|
|
32
|
+
* Account plan constants
|
|
33
|
+
*/
|
|
34
|
+
export const AccountPlan = {
|
|
35
|
+
FREE: 'free',
|
|
36
|
+
PAID: 'paid',
|
|
37
|
+
PARTNER: 'partner',
|
|
38
|
+
BLOCKED: 'blocked'
|
|
39
|
+
};
|
|
40
|
+
// =============================================================================
|
|
6
41
|
// ERROR SYSTEM
|
|
7
42
|
// =============================================================================
|
|
8
43
|
/**
|
|
@@ -142,25 +177,6 @@ export class ShipError extends Error {
|
|
|
142
177
|
return this.type === errorType;
|
|
143
178
|
}
|
|
144
179
|
}
|
|
145
|
-
// =============================================================================
|
|
146
|
-
// CONFIGURATION CONSTANTS
|
|
147
|
-
// =============================================================================
|
|
148
|
-
/**
|
|
149
|
-
* Server-side platform configuration - enforced limits on the platform
|
|
150
|
-
*/
|
|
151
|
-
export const serverConfig = {
|
|
152
|
-
/** Maximum individual file size in bytes (10MB) */
|
|
153
|
-
maxFileSize: 10 * 1024 * 1024,
|
|
154
|
-
/** Maximum number of files per deployment */
|
|
155
|
-
maxFilesCount: 1000,
|
|
156
|
-
/** Maximum total deployment size in bytes (100MB) */
|
|
157
|
-
maxTotalSize: 100 * 1024 * 1024,
|
|
158
|
-
/** Deployment expiry in hours */
|
|
159
|
-
deploymentExpiryHours: 120, // 5 days
|
|
160
|
-
/** Pagination limits */
|
|
161
|
-
defaultLimit: 50,
|
|
162
|
-
maxLimit: 100,
|
|
163
|
-
};
|
|
164
180
|
// API Key Configuration
|
|
165
181
|
export const API_KEY_PREFIX = 'ship-';
|
|
166
182
|
export const API_KEY_HEX_LENGTH = 64;
|
|
@@ -239,14 +255,6 @@ export function validateSubdomain(input) {
|
|
|
239
255
|
// =============================================================================
|
|
240
256
|
/** Default API URL if not otherwise configured. */
|
|
241
257
|
export const DEFAULT_API = 'https://api.shipstatic.com';
|
|
242
|
-
/**
|
|
243
|
-
* Deployment status - computed from verified timestamp
|
|
244
|
-
*/
|
|
245
|
-
export var DeploymentStatus;
|
|
246
|
-
(function (DeploymentStatus) {
|
|
247
|
-
DeploymentStatus["INCOMPLETE"] = "incomplete";
|
|
248
|
-
DeploymentStatus["COMPLETE"] = "complete"; // verified IS NOT NULL
|
|
249
|
-
})(DeploymentStatus || (DeploymentStatus = {}));
|
|
250
258
|
// =============================================================================
|
|
251
259
|
// URL GENERATION UTILITIES
|
|
252
260
|
// =============================================================================
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -7,28 +7,42 @@
|
|
|
7
7
|
// I. CORE ENTITIES
|
|
8
8
|
// =============================================================================
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Deployment status constants
|
|
12
|
+
*/
|
|
13
|
+
export const DeploymentStatus = {
|
|
14
|
+
PENDING: 'pending',
|
|
15
|
+
SUCCESS: 'success',
|
|
16
|
+
FAILED: 'failed',
|
|
17
|
+
DELETING: 'deleting'
|
|
18
|
+
} as const;
|
|
19
|
+
|
|
20
|
+
export type DeploymentStatusType = typeof DeploymentStatus[keyof typeof DeploymentStatus];
|
|
21
|
+
|
|
10
22
|
/**
|
|
11
23
|
* Core deployment object - used in both API responses and SDK
|
|
12
24
|
*/
|
|
13
25
|
export interface Deployment {
|
|
14
26
|
/** The deployment ID */
|
|
15
|
-
deployment: string;
|
|
27
|
+
readonly deployment: string;
|
|
16
28
|
/** Number of files in this deployment */
|
|
17
|
-
files: number;
|
|
29
|
+
readonly files: number;
|
|
18
30
|
/** Total size of all files in bytes */
|
|
19
|
-
size: number;
|
|
20
|
-
/** Current deployment status
|
|
21
|
-
status:
|
|
31
|
+
readonly size: number;
|
|
32
|
+
/** Current deployment status */
|
|
33
|
+
status: DeploymentStatusType; // Mutable - can be updated
|
|
22
34
|
/** Whether deployment has configuration */
|
|
23
|
-
config?: boolean;
|
|
35
|
+
readonly config?: boolean;
|
|
24
36
|
/** The deployment URL */
|
|
25
|
-
url: string;
|
|
37
|
+
readonly url: string;
|
|
26
38
|
/** Unix timestamp (seconds) when deployment was created */
|
|
27
|
-
created: number;
|
|
39
|
+
readonly created: number;
|
|
28
40
|
/** Unix timestamp (seconds) when deployment expires */
|
|
29
|
-
expires?: number;
|
|
41
|
+
expires?: number; // Mutable - can be updated
|
|
30
42
|
/** Unix timestamp (seconds) when deployment was verified and ready */
|
|
31
|
-
verified?: number;
|
|
43
|
+
verified?: number; // Mutable - can be updated
|
|
44
|
+
/** Short-lived JWT token for claiming this deployment (only present for public deployments) */
|
|
45
|
+
claimToken?: string; // Mutable - can be updated
|
|
32
46
|
}
|
|
33
47
|
|
|
34
48
|
|
|
@@ -48,24 +62,35 @@ export interface DeploymentListResponse {
|
|
|
48
62
|
// ALIAS TYPES
|
|
49
63
|
// =============================================================================
|
|
50
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Alias status constants
|
|
67
|
+
*/
|
|
68
|
+
export const AliasStatus = {
|
|
69
|
+
PENDING: 'pending',
|
|
70
|
+
SUCCESS: 'success',
|
|
71
|
+
FAILED: 'failed'
|
|
72
|
+
} as const;
|
|
73
|
+
|
|
74
|
+
export type AliasStatusType = typeof AliasStatus[keyof typeof AliasStatus];
|
|
75
|
+
|
|
51
76
|
/**
|
|
52
77
|
* Core alias object - used in both API responses and SDK
|
|
53
78
|
*/
|
|
54
79
|
export interface Alias {
|
|
55
80
|
/** The alias name */
|
|
56
|
-
alias: string;
|
|
81
|
+
readonly alias: string;
|
|
57
82
|
/** The deployment name this alias points to */
|
|
58
|
-
deployment: string;
|
|
83
|
+
deployment: string; // Mutable - can be updated to point to different deployment
|
|
59
84
|
/** Current alias status */
|
|
60
|
-
status:
|
|
85
|
+
status: AliasStatusType; // Mutable - can be updated
|
|
61
86
|
/** The alias URL - internal (subdomain) or external (custom domain) */
|
|
62
|
-
url: string;
|
|
87
|
+
readonly url: string;
|
|
63
88
|
/** Unix timestamp (seconds) when alias was created */
|
|
64
|
-
created: number;
|
|
89
|
+
readonly created: number;
|
|
90
|
+
/** Whether this was a create (201) or update (200) operation */
|
|
91
|
+
readonly isCreate?: boolean;
|
|
65
92
|
/** Unix timestamp (seconds) when alias was confirmed */
|
|
66
|
-
confirmed?: number;
|
|
67
|
-
/** Whether this was a create operation (true) or update operation (false). Optional - only present in set operations */
|
|
68
|
-
isCreate?: boolean;
|
|
93
|
+
confirmed?: number; // Mutable - can be updated
|
|
69
94
|
}
|
|
70
95
|
|
|
71
96
|
/**
|
|
@@ -96,6 +121,18 @@ export interface DeploymentRemoveResponse {
|
|
|
96
121
|
// ACCOUNT TYPES
|
|
97
122
|
// =============================================================================
|
|
98
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Account plan constants
|
|
126
|
+
*/
|
|
127
|
+
export const AccountPlan = {
|
|
128
|
+
FREE: 'free',
|
|
129
|
+
PAID: 'paid',
|
|
130
|
+
PARTNER: 'partner',
|
|
131
|
+
BLOCKED: 'blocked'
|
|
132
|
+
} as const;
|
|
133
|
+
|
|
134
|
+
export type AccountPlanType = typeof AccountPlan[keyof typeof AccountPlan];
|
|
135
|
+
|
|
99
136
|
/**
|
|
100
137
|
* Core account object - used in both API responses and SDK
|
|
101
138
|
*/
|
|
@@ -107,9 +144,11 @@ export interface Account {
|
|
|
107
144
|
/** User profile picture URL */
|
|
108
145
|
picture?: string;
|
|
109
146
|
/** Account plan status */
|
|
110
|
-
plan:
|
|
147
|
+
plan: AccountPlanType;
|
|
111
148
|
/** Unix timestamp (seconds) when account was created */
|
|
112
149
|
created: number;
|
|
150
|
+
/** Unix timestamp (seconds) when account was activated (first deployment) */
|
|
151
|
+
activated?: number;
|
|
113
152
|
}
|
|
114
153
|
|
|
115
154
|
// =============================================================================
|
|
@@ -298,22 +337,6 @@ export class ShipError extends Error {
|
|
|
298
337
|
// CONFIGURATION CONSTANTS
|
|
299
338
|
// =============================================================================
|
|
300
339
|
|
|
301
|
-
/**
|
|
302
|
-
* Server-side platform configuration - enforced limits on the platform
|
|
303
|
-
*/
|
|
304
|
-
export const serverConfig = {
|
|
305
|
-
/** Maximum individual file size in bytes (10MB) */
|
|
306
|
-
maxFileSize: 10 * 1024 * 1024,
|
|
307
|
-
/** Maximum number of files per deployment */
|
|
308
|
-
maxFilesCount: 1000,
|
|
309
|
-
/** Maximum total deployment size in bytes (100MB) */
|
|
310
|
-
maxTotalSize: 100 * 1024 * 1024,
|
|
311
|
-
/** Deployment expiry in hours */
|
|
312
|
-
deploymentExpiryHours: 120, // 5 days
|
|
313
|
-
/** Pagination limits */
|
|
314
|
-
defaultLimit: 50,
|
|
315
|
-
maxLimit: 100,
|
|
316
|
-
} as const;
|
|
317
340
|
|
|
318
341
|
|
|
319
342
|
|
|
@@ -588,14 +611,6 @@ export interface UploadedFile {
|
|
|
588
611
|
validated?: boolean;
|
|
589
612
|
}
|
|
590
613
|
|
|
591
|
-
/**
|
|
592
|
-
* Deployment status - computed from verified timestamp
|
|
593
|
-
*/
|
|
594
|
-
export enum DeploymentStatus {
|
|
595
|
-
INCOMPLETE = 'incomplete', // verified IS NULL
|
|
596
|
-
COMPLETE = 'complete' // verified IS NOT NULL
|
|
597
|
-
}
|
|
598
|
-
|
|
599
614
|
/**
|
|
600
615
|
* Rate limiting data structure
|
|
601
616
|
*/
|