@shipstatic/types 2.4.1-beta.0 → 2.5.0-beta.0

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
@@ -784,11 +784,28 @@ export interface DeploymentUploadOptions {
784
784
  captcha?: string;
785
785
  }
786
786
  /**
787
- * Deployment resource interface - the contract all implementations must follow
788
- */
789
- export interface DeploymentResource {
790
- upload: (input: DeployInput, options?: DeploymentUploadOptions) => Promise<DeploymentCreateResponse>;
791
- list: () => Promise<DeploymentListResponse>;
787
+ * Pagination options for the paginated list endpoints (`GET /deployments`,
788
+ * `GET /domains`). The response's `cursor` feeds the next request; a `null`
789
+ * cursor on the response means the last page. Omitting both returns the
790
+ * server's default first page.
791
+ */
792
+ export interface ListOptions {
793
+ /** Maximum number of items to return in one page. */
794
+ limit?: number;
795
+ /** Opaque cursor from the previous page's response. */
796
+ cursor?: string;
797
+ }
798
+ /**
799
+ * Deployment resource interface - the contract all implementations must follow.
800
+ *
801
+ * The interface defines the minimal wire contract; SDK implementations may
802
+ * extend the upload options with runtime concerns (timeout, signal, progress
803
+ * callbacks) by parameterizing: `DeploymentResource<MyUploadOptions>`. The
804
+ * default keeps plain `DeploymentResource` valid for wire-only consumers.
805
+ */
806
+ export interface DeploymentResource<UploadOptions extends DeploymentUploadOptions = DeploymentUploadOptions> {
807
+ upload: (input: DeployInput, options?: UploadOptions) => Promise<DeploymentCreateResponse>;
808
+ list: (options?: ListOptions) => Promise<DeploymentListResponse>;
792
809
  get: (id: string) => Promise<Deployment>;
793
810
  set: (id: string, options: {
794
811
  labels: string[];
@@ -803,7 +820,7 @@ export interface DomainResource {
803
820
  deployment?: string;
804
821
  labels?: string[];
805
822
  }) => Promise<DomainSetResult>;
806
- list: () => Promise<DomainListResponse>;
823
+ list: (options?: ListOptions) => Promise<DomainListResponse>;
807
824
  get: (name: string) => Promise<Domain>;
808
825
  remove: (name: string) => Promise<void>;
809
826
  verify: (name: string) => Promise<{
@@ -863,11 +880,11 @@ export interface CheckoutSession {
863
880
  * All activity event types logged in the system.
864
881
  * Uses dot notation consistently: {resource}.{action}
865
882
  */
866
- export type ActivityEvent = 'account.create' | 'account.update' | 'account.delete' | 'account.key.generate' | 'account.plan.paid' | 'account.plan.transition' | 'account.suspended' | 'deployment.create' | 'deployment.update' | 'deployment.delete' | 'deployment.claim' | 'deployment.flagged' | 'domain.create' | 'domain.update' | 'domain.delete' | 'domain.verify' | 'token.create' | 'token.consume' | 'admin.account.plan.update' | 'admin.account.ref.update' | 'admin.account.billing.update' | 'admin.account.labels.update' | 'admin.deployment.delete' | 'admin.domain.delete' | 'admin.billing.sync' | 'admin.billing.terminated' | 'admin.impersonate' | 'billing.active' | 'billing.canceled' | 'billing.paused' | 'billing.expired' | 'billing.paid' | 'billing.trialing' | 'billing.scheduled_cancel' | 'billing.unpaid' | 'billing.update' | 'billing.past_due' | 'refund.created' | 'dispute.created' | 'billing.sync' | 'billing.stale' | 'billing.race';
883
+ export type ActivityEvent = 'account.create' | 'account.update' | 'account.delete' | 'account.key.generate' | 'account.plan.paid' | 'account.plan.transition' | 'account.suspended' | 'deployment.create' | 'deployment.update' | 'deployment.delete' | 'deployment.claim' | 'deployment.flagged' | 'domain.create' | 'domain.update' | 'domain.delete' | 'domain.verify' | 'token.create' | 'token.consume' | 'token.delete' | 'admin.account.plan.update' | 'admin.account.ref.update' | 'admin.account.billing.update' | 'admin.account.labels.update' | 'admin.deployment.delete' | 'admin.domain.delete' | 'admin.billing.sync' | 'admin.billing.terminated' | 'admin.impersonate' | 'billing.active' | 'billing.canceled' | 'billing.paused' | 'billing.expired' | 'billing.paid' | 'billing.trialing' | 'billing.scheduled_cancel' | 'billing.unpaid' | 'billing.update' | 'billing.past_due' | 'refund.created' | 'dispute.created' | 'billing.sync' | 'billing.stale' | 'billing.race';
867
884
  /**
868
885
  * Activity events visible to users in the dashboard
869
886
  */
870
- export type UserVisibleActivityEvent = 'account.create' | 'account.update' | 'account.delete' | 'account.key.generate' | 'account.plan.transition' | 'deployment.create' | 'deployment.update' | 'deployment.delete' | 'deployment.claim' | 'domain.create' | 'domain.update' | 'domain.delete' | 'domain.verify' | 'token.create' | 'token.consume';
887
+ export type UserVisibleActivityEvent = 'account.create' | 'account.update' | 'account.delete' | 'account.key.generate' | 'account.plan.transition' | 'deployment.create' | 'deployment.update' | 'deployment.delete' | 'deployment.claim' | 'domain.create' | 'domain.update' | 'domain.delete' | 'domain.verify' | 'token.create' | 'token.consume' | 'token.delete';
871
888
  /**
872
889
  * Activity record returned from the API
873
890
  */
package/dist/index.js CHANGED
@@ -197,6 +197,23 @@ export class ShipError extends Error {
197
197
  catch {
198
198
  // Body unreadable; fall through to operationName-derived message.
199
199
  }
200
+ // Rate-limit (and 503) timing rides the `Retry-After` HEADER, which a
201
+ // body-only reader would drop. Lift it into `details` as seconds so
202
+ // consumers can back off from the typed error alone, without keeping the
203
+ // raw Response around. Body-carried fields are preserved and win.
204
+ const retryAfterHeader = response.headers.get('retry-after');
205
+ if (retryAfterHeader !== null) {
206
+ const value = retryAfterHeader.trim();
207
+ const seconds = /^\d+$/.test(value)
208
+ ? Number(value)
209
+ : Math.ceil((Date.parse(value) - Date.now()) / 1000);
210
+ if (Number.isFinite(seconds) && seconds >= 0) {
211
+ const existing = details && typeof details === 'object' ? details : {};
212
+ if (existing.retryAfter === undefined) {
213
+ details = { ...existing, retryAfter: seconds };
214
+ }
215
+ }
216
+ }
200
217
  message = message || `${operationName || 'Request'} failed with status ${response.status}`;
201
218
  const type = bodyType ??
202
219
  (response.status === 401
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipstatic/types",
3
- "version": "2.4.1-beta.0",
3
+ "version": "2.5.0-beta.0",
4
4
  "description": "Shared types for ShipStatic platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/index.ts CHANGED
@@ -512,6 +512,25 @@ export class ShipError extends Error {
512
512
  // Body unreadable; fall through to operationName-derived message.
513
513
  }
514
514
 
515
+ // Rate-limit (and 503) timing rides the `Retry-After` HEADER, which a
516
+ // body-only reader would drop. Lift it into `details` as seconds so
517
+ // consumers can back off from the typed error alone, without keeping the
518
+ // raw Response around. Body-carried fields are preserved and win.
519
+ const retryAfterHeader = response.headers.get('retry-after');
520
+ if (retryAfterHeader !== null) {
521
+ const value = retryAfterHeader.trim();
522
+ const seconds = /^\d+$/.test(value)
523
+ ? Number(value)
524
+ : Math.ceil((Date.parse(value) - Date.now()) / 1000);
525
+ if (Number.isFinite(seconds) && seconds >= 0) {
526
+ const existing =
527
+ details && typeof details === 'object' ? (details as Record<string, unknown>) : {};
528
+ if (existing.retryAfter === undefined) {
529
+ details = { ...existing, retryAfter: seconds };
530
+ }
531
+ }
532
+ }
533
+
515
534
  message = message || `${operationName || 'Request'} failed with status ${response.status}`;
516
535
 
517
536
  const type =
@@ -1233,14 +1252,31 @@ export interface DeploymentUploadOptions {
1233
1252
  }
1234
1253
 
1235
1254
  /**
1236
- * Deployment resource interface - the contract all implementations must follow
1255
+ * Pagination options for the paginated list endpoints (`GET /deployments`,
1256
+ * `GET /domains`). The response's `cursor` feeds the next request; a `null`
1257
+ * cursor on the response means the last page. Omitting both returns the
1258
+ * server's default first page.
1237
1259
  */
1238
- export interface DeploymentResource {
1239
- upload: (
1240
- input: DeployInput,
1241
- options?: DeploymentUploadOptions,
1242
- ) => Promise<DeploymentCreateResponse>;
1243
- list: () => Promise<DeploymentListResponse>;
1260
+ export interface ListOptions {
1261
+ /** Maximum number of items to return in one page. */
1262
+ limit?: number;
1263
+ /** Opaque cursor from the previous page's response. */
1264
+ cursor?: string;
1265
+ }
1266
+
1267
+ /**
1268
+ * Deployment resource interface - the contract all implementations must follow.
1269
+ *
1270
+ * The interface defines the minimal wire contract; SDK implementations may
1271
+ * extend the upload options with runtime concerns (timeout, signal, progress
1272
+ * callbacks) by parameterizing: `DeploymentResource<MyUploadOptions>`. The
1273
+ * default keeps plain `DeploymentResource` valid for wire-only consumers.
1274
+ */
1275
+ export interface DeploymentResource<
1276
+ UploadOptions extends DeploymentUploadOptions = DeploymentUploadOptions,
1277
+ > {
1278
+ upload: (input: DeployInput, options?: UploadOptions) => Promise<DeploymentCreateResponse>;
1279
+ list: (options?: ListOptions) => Promise<DeploymentListResponse>;
1244
1280
  get: (id: string) => Promise<Deployment>;
1245
1281
  set: (id: string, options: { labels: string[] }) => Promise<Deployment>;
1246
1282
  remove: (id: string) => Promise<void>;
@@ -1254,7 +1290,7 @@ export interface DomainResource {
1254
1290
  name: string,
1255
1291
  options?: { deployment?: string; labels?: string[] },
1256
1292
  ) => Promise<DomainSetResult>;
1257
- list: () => Promise<DomainListResponse>;
1293
+ list: (options?: ListOptions) => Promise<DomainListResponse>;
1258
1294
  get: (name: string) => Promise<Domain>;
1259
1295
  remove: (name: string) => Promise<void>;
1260
1296
  verify: (name: string) => Promise<{ message: string }>;
@@ -1342,6 +1378,7 @@ export type ActivityEvent =
1342
1378
  // Token events
1343
1379
  | 'token.create'
1344
1380
  | 'token.consume'
1381
+ | 'token.delete'
1345
1382
  // Admin events (not user-visible)
1346
1383
  | 'admin.account.plan.update'
1347
1384
  | 'admin.account.ref.update'
@@ -1388,7 +1425,8 @@ export type UserVisibleActivityEvent =
1388
1425
  | 'domain.delete'
1389
1426
  | 'domain.verify'
1390
1427
  | 'token.create'
1391
- | 'token.consume';
1428
+ | 'token.consume'
1429
+ | 'token.delete';
1392
1430
 
1393
1431
  /**
1394
1432
  * Activity record returned from the API