@shipstatic/types 2.5.0-beta.5 → 2.5.0-beta.7
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 +26 -12
- package/dist/index.js +20 -6
- package/package.json +1 -1
- package/src/index.ts +34 -18
package/dist/index.d.ts
CHANGED
|
@@ -57,8 +57,6 @@ export interface DeploymentListResponse {
|
|
|
57
57
|
deployments: Deployment[];
|
|
58
58
|
/** Cursor for pagination, null if no more pages */
|
|
59
59
|
cursor: string | null;
|
|
60
|
-
/** Total number of deployments */
|
|
61
|
-
total: number;
|
|
62
60
|
}
|
|
63
61
|
/**
|
|
64
62
|
* Domain status constants
|
|
@@ -118,8 +116,6 @@ export interface DomainListResponse {
|
|
|
118
116
|
domains: Domain[];
|
|
119
117
|
/** Cursor for pagination, null if no more pages */
|
|
120
118
|
cursor: string | null;
|
|
121
|
-
/** Total number of domains */
|
|
122
|
-
total: number;
|
|
123
119
|
}
|
|
124
120
|
/**
|
|
125
121
|
* DNS record types supported for domain configuration
|
|
@@ -203,8 +199,6 @@ export interface TokenListResponse {
|
|
|
203
199
|
tokens: TokenListItem[];
|
|
204
200
|
/** Cursor for pagination, null if no more pages */
|
|
205
201
|
cursor: string | null;
|
|
206
|
-
/** Total number of tokens */
|
|
207
|
-
total: number;
|
|
208
202
|
}
|
|
209
203
|
/**
|
|
210
204
|
* Response for token creation
|
|
@@ -423,6 +417,18 @@ export declare class ShipError extends Error {
|
|
|
423
417
|
static file(message: string, details?: unknown): ShipError;
|
|
424
418
|
static config(message: string, details?: unknown): ShipError;
|
|
425
419
|
static api(message: string, status?: number, details?: unknown): ShipError;
|
|
420
|
+
/**
|
|
421
|
+
* The caller is at fault — by HTTP's own definition of a 4xx, or by a type
|
|
422
|
+
* that is client-attributable without ever having a status (`Config`,
|
|
423
|
+
* `File`, raised locally by the SDK).
|
|
424
|
+
*
|
|
425
|
+
* Both arms are load-bearing, because type and status are independent
|
|
426
|
+
* axes. `fromHttpResponse` trusts `body.error` only when it names a
|
|
427
|
+
* server-producible type; a non-OK response without one is status-derived,
|
|
428
|
+
* so a CDN 404 or any intermediary error arrives as `Api` — a server-fault
|
|
429
|
+
* *type* carrying a client *status*. Judging by type alone would report it
|
|
430
|
+
* as a platform failure and bury the server's own message.
|
|
431
|
+
*/
|
|
426
432
|
isClientError(): boolean;
|
|
427
433
|
isNetworkError(): boolean;
|
|
428
434
|
isAuthError(): boolean;
|
|
@@ -802,10 +808,20 @@ export interface DeploymentUploadOptions {
|
|
|
802
808
|
captcha?: string;
|
|
803
809
|
}
|
|
804
810
|
/**
|
|
805
|
-
* Pagination options for
|
|
806
|
-
*
|
|
807
|
-
*
|
|
808
|
-
*
|
|
811
|
+
* Pagination options for every list endpoint. The response's `cursor` feeds
|
|
812
|
+
* the next request; a `null` cursor means the last page. Omitting both
|
|
813
|
+
* returns the server's default first page.
|
|
814
|
+
*
|
|
815
|
+
* A list answers `{ <collection>, cursor }` and nothing else — `cursor`
|
|
816
|
+
* carries the entire has-more signal, so no redundant boolean, and no
|
|
817
|
+
* `total`. **A count is an aggregate over a collection, not a property of a
|
|
818
|
+
* page:** including one makes every read pay for a full scan it did not ask
|
|
819
|
+
* for, which is precisely the cost keyset pagination exists to avoid.
|
|
820
|
+
*
|
|
821
|
+
* Counts therefore live on the summary resource that owns them —
|
|
822
|
+
* `GET /account` (`usage`) for a caller's own totals, `GET /admin/stats` for
|
|
823
|
+
* platform-wide ones. Ask for a count when you want a count; ask for a page
|
|
824
|
+
* when you want a page.
|
|
809
825
|
*/
|
|
810
826
|
export interface ListOptions {
|
|
811
827
|
/** Maximum number of items to return in one page. */
|
|
@@ -966,8 +982,6 @@ export interface ActivityListResponse {
|
|
|
966
982
|
activities: Activity[];
|
|
967
983
|
/** Cursor for pagination, null if no more pages */
|
|
968
984
|
cursor: string | null;
|
|
969
|
-
/** Total number of activities */
|
|
970
|
-
total: number;
|
|
971
985
|
}
|
|
972
986
|
/**
|
|
973
987
|
* File status constants for validation state tracking
|
package/dist/index.js
CHANGED
|
@@ -101,10 +101,10 @@ const CLIENT_ONLY_ERROR_TYPES = new Set([
|
|
|
101
101
|
*/
|
|
102
102
|
const ERROR_CATEGORIES = {
|
|
103
103
|
/**
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
104
|
+
* Client-attributable types. Exhaustive over the 4xx-carrying types, and
|
|
105
|
+
* it must include the statusless ones (`Config`, `File`) — those are
|
|
106
|
+
* raised locally by the SDK and have no status for `isClientError`'s
|
|
107
|
+
* second arm to read.
|
|
108
108
|
*/
|
|
109
109
|
client: new Set([
|
|
110
110
|
ErrorType.Business,
|
|
@@ -317,10 +317,24 @@ export class ShipError extends Error {
|
|
|
317
317
|
static api(message, status = 500, details) {
|
|
318
318
|
return new ShipError(ErrorType.Api, message, status, details);
|
|
319
319
|
}
|
|
320
|
-
// Semantic-category
|
|
320
|
+
// Semantic-category guards. For specific-type checks, use
|
|
321
321
|
// `error.type === ErrorType.X` directly or the generic `isType(t)`.
|
|
322
|
+
/**
|
|
323
|
+
* The caller is at fault — by HTTP's own definition of a 4xx, or by a type
|
|
324
|
+
* that is client-attributable without ever having a status (`Config`,
|
|
325
|
+
* `File`, raised locally by the SDK).
|
|
326
|
+
*
|
|
327
|
+
* Both arms are load-bearing, because type and status are independent
|
|
328
|
+
* axes. `fromHttpResponse` trusts `body.error` only when it names a
|
|
329
|
+
* server-producible type; a non-OK response without one is status-derived,
|
|
330
|
+
* so a CDN 404 or any intermediary error arrives as `Api` — a server-fault
|
|
331
|
+
* *type* carrying a client *status*. Judging by type alone would report it
|
|
332
|
+
* as a platform failure and bury the server's own message.
|
|
333
|
+
*/
|
|
322
334
|
isClientError() {
|
|
323
|
-
|
|
335
|
+
if (ERROR_CATEGORIES.client.has(this.type))
|
|
336
|
+
return true;
|
|
337
|
+
return this.status !== undefined && this.status >= 400 && this.status < 500;
|
|
324
338
|
}
|
|
325
339
|
isNetworkError() {
|
|
326
340
|
return ERROR_CATEGORIES.network.has(this.type);
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -66,8 +66,6 @@ export interface DeploymentListResponse {
|
|
|
66
66
|
deployments: Deployment[];
|
|
67
67
|
/** Cursor for pagination, null if no more pages */
|
|
68
68
|
cursor: string | null;
|
|
69
|
-
/** Total number of deployments */
|
|
70
|
-
total: number;
|
|
71
69
|
}
|
|
72
70
|
|
|
73
71
|
// =============================================================================
|
|
@@ -136,8 +134,6 @@ export interface DomainListResponse {
|
|
|
136
134
|
domains: Domain[];
|
|
137
135
|
/** Cursor for pagination, null if no more pages */
|
|
138
136
|
cursor: string | null;
|
|
139
|
-
/** Total number of domains */
|
|
140
|
-
total: number;
|
|
141
137
|
}
|
|
142
138
|
|
|
143
139
|
/**
|
|
@@ -231,8 +227,6 @@ export interface TokenListResponse {
|
|
|
231
227
|
tokens: TokenListItem[];
|
|
232
228
|
/** Cursor for pagination, null if no more pages */
|
|
233
229
|
cursor: string | null;
|
|
234
|
-
/** Total number of tokens */
|
|
235
|
-
total: number;
|
|
236
230
|
}
|
|
237
231
|
|
|
238
232
|
/**
|
|
@@ -400,10 +394,10 @@ const CLIENT_ONLY_ERROR_TYPES = new Set<string>([
|
|
|
400
394
|
*/
|
|
401
395
|
const ERROR_CATEGORIES = {
|
|
402
396
|
/**
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
*
|
|
397
|
+
* Client-attributable types. Exhaustive over the 4xx-carrying types, and
|
|
398
|
+
* it must include the statusless ones (`Config`, `File`) — those are
|
|
399
|
+
* raised locally by the SDK and have no status for `isClientError`'s
|
|
400
|
+
* second arm to read.
|
|
407
401
|
*/
|
|
408
402
|
client: new Set<ErrorType>([
|
|
409
403
|
ErrorType.Business,
|
|
@@ -655,10 +649,24 @@ export class ShipError extends Error {
|
|
|
655
649
|
return new ShipError(ErrorType.Api, message, status, details);
|
|
656
650
|
}
|
|
657
651
|
|
|
658
|
-
// Semantic-category
|
|
652
|
+
// Semantic-category guards. For specific-type checks, use
|
|
659
653
|
// `error.type === ErrorType.X` directly or the generic `isType(t)`.
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* The caller is at fault — by HTTP's own definition of a 4xx, or by a type
|
|
657
|
+
* that is client-attributable without ever having a status (`Config`,
|
|
658
|
+
* `File`, raised locally by the SDK).
|
|
659
|
+
*
|
|
660
|
+
* Both arms are load-bearing, because type and status are independent
|
|
661
|
+
* axes. `fromHttpResponse` trusts `body.error` only when it names a
|
|
662
|
+
* server-producible type; a non-OK response without one is status-derived,
|
|
663
|
+
* so a CDN 404 or any intermediary error arrives as `Api` — a server-fault
|
|
664
|
+
* *type* carrying a client *status*. Judging by type alone would report it
|
|
665
|
+
* as a platform failure and bury the server's own message.
|
|
666
|
+
*/
|
|
660
667
|
isClientError(): boolean {
|
|
661
|
-
|
|
668
|
+
if (ERROR_CATEGORIES.client.has(this.type)) return true;
|
|
669
|
+
return this.status !== undefined && this.status >= 400 && this.status < 500;
|
|
662
670
|
}
|
|
663
671
|
|
|
664
672
|
isNetworkError(): boolean {
|
|
@@ -1291,10 +1299,20 @@ export interface DeploymentUploadOptions {
|
|
|
1291
1299
|
}
|
|
1292
1300
|
|
|
1293
1301
|
/**
|
|
1294
|
-
* Pagination options for
|
|
1295
|
-
*
|
|
1296
|
-
*
|
|
1297
|
-
*
|
|
1302
|
+
* Pagination options for every list endpoint. The response's `cursor` feeds
|
|
1303
|
+
* the next request; a `null` cursor means the last page. Omitting both
|
|
1304
|
+
* returns the server's default first page.
|
|
1305
|
+
*
|
|
1306
|
+
* A list answers `{ <collection>, cursor }` and nothing else — `cursor`
|
|
1307
|
+
* carries the entire has-more signal, so no redundant boolean, and no
|
|
1308
|
+
* `total`. **A count is an aggregate over a collection, not a property of a
|
|
1309
|
+
* page:** including one makes every read pay for a full scan it did not ask
|
|
1310
|
+
* for, which is precisely the cost keyset pagination exists to avoid.
|
|
1311
|
+
*
|
|
1312
|
+
* Counts therefore live on the summary resource that owns them —
|
|
1313
|
+
* `GET /account` (`usage`) for a caller's own totals, `GET /admin/stats` for
|
|
1314
|
+
* platform-wide ones. Ask for a count when you want a count; ask for a page
|
|
1315
|
+
* when you want a page.
|
|
1298
1316
|
*/
|
|
1299
1317
|
export interface ListOptions {
|
|
1300
1318
|
/** Maximum number of items to return in one page. */
|
|
@@ -1540,8 +1558,6 @@ export interface ActivityListResponse {
|
|
|
1540
1558
|
activities: Activity[];
|
|
1541
1559
|
/** Cursor for pagination, null if no more pages */
|
|
1542
1560
|
cursor: string | null;
|
|
1543
|
-
/** Total number of activities */
|
|
1544
|
-
total: number;
|
|
1545
1561
|
}
|
|
1546
1562
|
|
|
1547
1563
|
// =============================================================================
|