@shipstatic/types 2.16.0-beta.1 → 2.17.0-beta.10

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
@@ -655,6 +655,30 @@ export interface Account {
655
655
  * must never be sent to Checkout.
656
656
  */
657
657
  readonly upgrade: AccountPlanType | null;
658
+ /**
659
+ * The live Subscription's billing interval — Stripe's
660
+ * `Price.recurring.interval`, mirrored — or `null` when no Subscription
661
+ * bills the account (free and granted plans). It is what lets the console
662
+ * offer the current plan's OTHER interval as a switch.
663
+ */
664
+ readonly interval: BillingInterval | null;
665
+ /**
666
+ * The pending plan change, or `null`. *Up is now, down is at period end*:
667
+ * a downgrade is a Stripe Subscription Schedule that applies at `at`, and
668
+ * until then the account keeps everything it paid for. Reversible —
669
+ * `DELETE /billing/change` releases it.
670
+ */
671
+ readonly scheduled: ScheduledChange | null;
672
+ /**
673
+ * When the Subscription is set to END — Stripe's `cancel_at`, mirrored
674
+ * (Unix seconds) — or `null` while it renews. Set by a cancellation in the
675
+ * Customer Portal; the Portal is also where it is resumed. The console
676
+ * needs it to ACT: no "cancel" offered to an account already cancelling,
677
+ * and no plan change offered until it is resumed (the API refuses one).
678
+ * Mirrored on the rule that survives: what the console must act on is
679
+ * mirrored, what it would merely display is not.
680
+ */
681
+ readonly cancelAt: number | null;
658
682
  }
659
683
  /**
660
684
  * Account as returned by `GET /account` — the entity plus how the request
@@ -1199,8 +1223,10 @@ export declare const SIGN_IN_RETURN_PARAM = "signing-in";
1199
1223
  * Client populations: `SESSION` (first-party cookie), `API_KEY` (`ship-`
1200
1224
  * key), `TOKEN` (`deploy-` deploy token), `AGENT` (anonymous public deploy —
1201
1225
  * no credential; the platform grants the public-account identity per
1202
- * request), `OAUTH` (delegated access token). Server populations: `WEBHOOK`
1203
- * (signed webhook processing), `SYSTEM` (scheduled/background jobs).
1226
+ * request), `OAUTH` (delegated access token). The one server population:
1227
+ * `SYSTEM` (scheduled/background jobs). Webhook receipt is deliberately not
1228
+ * a population: a signed delivery is verified, never authorized — it acts
1229
+ * as no one and audits as no one.
1204
1230
  */
1205
1231
  export declare const AuthMethod: {
1206
1232
  readonly SESSION: "session";
@@ -1208,7 +1234,6 @@ export declare const AuthMethod: {
1208
1234
  readonly TOKEN: "token";
1209
1235
  readonly AGENT: "agent";
1210
1236
  readonly OAUTH: "oauth";
1211
- readonly WEBHOOK: "webhook";
1212
1237
  readonly SYSTEM: "system";
1213
1238
  };
1214
1239
  export type AuthMethodType = (typeof AuthMethod)[keyof typeof AuthMethod];
@@ -1828,6 +1853,20 @@ export interface Plan {
1828
1853
  * nothing (a plan sold by conversation publishes no numbers).
1829
1854
  */
1830
1855
  readonly caps: Caps | null;
1856
+ /**
1857
+ * Why this row cannot be ordered right now — the closed door's own sentence,
1858
+ * verbatim — or absent when the way is open. A menu lists what can be
1859
+ * ordered, and a row that is sold but not yet orderable (its door is closed:
1860
+ * checkout unbuilt, a feature unfinished) SAYS SO on the menu instead of
1861
+ * only at the order.
1862
+ *
1863
+ * Clients branch on PRESENCE and render the sentence unchanged — they know
1864
+ * *that* the row is closed, never *which* door or *when it lifts*; the
1865
+ * vocabulary of doors stays server-side. The same rule the refusal follows:
1866
+ * `POST /billing/change` onto a closed row answers 400 with
1867
+ * `details.closed`, and its `message` is this sentence.
1868
+ */
1869
+ readonly closed?: string;
1831
1870
  }
1832
1871
  /**
1833
1872
  * Response for `GET /plans` — the whole public menu, in display order.
@@ -1843,46 +1882,71 @@ export interface PlansResponse {
1843
1882
  readonly plans: readonly Plan[];
1844
1883
  }
1845
1884
  /**
1846
- * The body of `POST /billing/checkout` — which plan, at which interval. Both
1847
- * required: with more than one billed plan there is no honest default, and
1848
- * the console always knows which card was clicked. Only a free account
1849
- * checks out, and only onto a plan the menu sells; a billed account changes
1850
- * plan through the Portal ({@link BillingPortalRequest}), because Stripe
1851
- * changes a Subscription in place rather than selling a second one.
1885
+ * The body of `POST /billing/change` — the one door for "get me onto this
1886
+ * plan". Both fields required: with more than one billed plan there is no
1887
+ * honest default, and the console always knows which card was clicked.
1888
+ *
1889
+ * The SERVER decides what the change means — the rule is *up is now, down is
1890
+ * at period end* so the client holds no copy of the ladder: a free account
1891
+ * is sent to Stripe Checkout, a billed account moving up is sent to the
1892
+ * Portal's confirmation page (money moves now, so Stripe's page takes the
1893
+ * consent), and a billed account moving down gets a Stripe Subscription
1894
+ * Schedule that applies the change at period end. The answer says which
1895
+ * happened ({@link PlanChangeResponse}).
1852
1896
  */
1853
- export interface CheckoutRequest {
1897
+ export interface PlanChangeRequest {
1854
1898
  readonly plan: AccountPlanType;
1855
1899
  readonly interval: BillingInterval;
1856
1900
  }
1857
1901
  /**
1858
- * The body of `POST /billing/portal` optional, and when present a
1859
- * DESTINATION: the plan and interval the account wants, which opens the
1860
- * Portal on Stripe's own confirmation page for that Price rather than on its
1861
- * home page. Absent, the Portal opens where it always did: cards, invoices,
1862
- * cancellation, and Stripe's own plan picker.
1902
+ * The pending plan changea Stripe Subscription Schedule, mirrored onto the
1903
+ * account. `at` is when it applies (the current period's end, Unix seconds).
1904
+ *
1905
+ * WHO minted the schedule is deliberately not part of this shape, and both
1906
+ * kinds mirror here identically: Stripe mints one when a customer confirms a
1907
+ * cadence downgrade on its own hosted page, and the platform mints one for a
1908
+ * cheaper TIER, the single move Stripe's Customer Portal cannot express.
1909
+ *
1910
+ * Reversible until it applies, and `DELETE /billing/change` is the only way:
1911
+ * Stripe's Portal displays a pending change but offers no control to undo it.
1863
1912
  */
1864
- export interface BillingPortalRequest {
1865
- readonly plan?: AccountPlanType;
1866
- readonly interval?: BillingInterval;
1913
+ export interface ScheduledChange {
1914
+ readonly plan: AccountPlanType;
1915
+ readonly interval: BillingInterval;
1916
+ readonly at: number;
1867
1917
  }
1868
1918
  /**
1869
- * The answer of `POST /billing/checkout` — Stripe's `Checkout.Session`,
1870
- * projected to the one field a client needs.
1919
+ * The answer of `POST /billing/change` — exactly one field is set, and the
1920
+ * UNION is what holds that: an answer carrying both, or neither, does not
1921
+ * compile, so "which door was taken" is structural rather than prose.
1871
1922
  *
1872
- * There is nothing else to return: the outcome arrives later, as a Stripe
1873
- * webhook. It is its own type rather than a shape shared with
1874
- * {@link BillingPortalSession} because Stripe has two distinct objects here,
1875
- * and naming one of them for both would be the reader's translation to make.
1923
+ * `url` means GO: a Stripe page (Checkout, or the Portal's confirmation page)
1924
+ * finishes the change and the browser must be redirected to it. A `url` does
1925
+ * NOT imply money moves on the confirmation page Stripe decides whether to
1926
+ * charge now or defer the change to period end, and says which. `scheduled`
1927
+ * means DONE: the change is booked for period end by the platform itself,
1928
+ * nothing to visit, and the account's `scheduled` field now carries it.
1929
+ *
1930
+ * A client branches on the SHAPE and holds no copy of which move takes which
1931
+ * door — which is what let the server move that boundary without a wire
1932
+ * change (2026-08-25).
1876
1933
  */
1877
- export interface CheckoutSession {
1878
- /** Absolute URL to redirect the browser to. Single use, short-lived. */
1934
+ export type PlanChangeResponse =
1935
+ /** GO: a Stripe page finishes the change. Absolute URL, single use, short-lived. */
1936
+ {
1879
1937
  readonly url: string;
1938
+ readonly scheduled?: never;
1880
1939
  }
1940
+ /** DONE: the downgrade is booked for period end; nothing to visit. */
1941
+ | {
1942
+ readonly url?: never;
1943
+ readonly scheduled: ScheduledChange;
1944
+ };
1881
1945
  /**
1882
1946
  * The answer of `POST /billing/portal` — Stripe's `BillingPortal.Session`,
1883
- * projected the same way. Identical in shape to {@link CheckoutSession} and
1884
- * deliberately not merged with it: they are two Stripe objects, and either may
1885
- * gain a field the other never has.
1947
+ * projected to the one field a client needs. The Portal home: cards,
1948
+ * invoices, cancellation. Plan changes have their own door
1949
+ * ({@link PlanChangeRequest}).
1886
1950
  */
1887
1951
  export interface BillingPortalSession {
1888
1952
  /** Absolute URL to redirect the browser to. Single use, short-lived. */
@@ -1901,12 +1965,17 @@ export interface BillingSyncResponse {
1901
1965
  /**
1902
1966
  * All activity event types logged in the system.
1903
1967
  * Uses dot notation consistently: {resource}.{action}
1968
+ *
1969
+ * Retention: activity rows are permanent — the account's own history and
1970
+ * the platform's audit ledgers are one table, kept for the life of the
1971
+ * account (deletion removes them). Only the personal payload is
1972
+ * time-bounded: past 90 days each row sheds its IP.
1904
1973
  */
1905
- export type ActivityEvent = 'account.create' | 'account.update' | 'account.delete' | 'account.key.generate' | 'account.plan.paid' | 'account.plan.transition' | 'deployment.create' | 'deployment.update' | 'deployment.delete' | 'deployment.claim' | 'deployment.flagged' | 'deployment.open' | 'domain.create' | 'domain.update' | 'domain.delete' | 'domain.verify' | 'token.create' | 'token.consume' | 'token.delete' | 'admin.account.plan.update' | 'admin.account.suspended.update' | 'admin.account.ref.update' | 'admin.account.labels.update' | 'admin.deployment.delete' | 'admin.domain.delete' | 'admin.impersonate';
1974
+ export type ActivityEvent = 'account.create' | 'account.delete' | 'account.key.generate' | 'account.plan.transition' | 'deployment.create' | 'deployment.update' | 'deployment.delete' | 'deployment.claim' | 'deployment.flagged' | 'deployment.open' | 'domain.create' | 'domain.update' | 'domain.delete' | 'domain.verify' | 'token.create' | 'token.consume' | 'token.delete' | 'admin.account.plan.update' | 'admin.account.suspended.update' | 'admin.account.ref.update' | 'admin.account.labels.update' | 'admin.deployment.delete' | 'admin.domain.delete' | 'admin.impersonate';
1906
1975
  /**
1907
1976
  * Activity events visible to users in the dashboard
1908
1977
  */
1909
- 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';
1978
+ export type UserVisibleActivityEvent = 'account.create' | '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';
1910
1979
  /**
1911
1980
  * Activity record returned from the API
1912
1981
  */
package/dist/index.js CHANGED
@@ -1150,8 +1150,10 @@ export const SIGN_IN_RETURN_PARAM = 'signing-in';
1150
1150
  * Client populations: `SESSION` (first-party cookie), `API_KEY` (`ship-`
1151
1151
  * key), `TOKEN` (`deploy-` deploy token), `AGENT` (anonymous public deploy —
1152
1152
  * no credential; the platform grants the public-account identity per
1153
- * request), `OAUTH` (delegated access token). Server populations: `WEBHOOK`
1154
- * (signed webhook processing), `SYSTEM` (scheduled/background jobs).
1153
+ * request), `OAUTH` (delegated access token). The one server population:
1154
+ * `SYSTEM` (scheduled/background jobs). Webhook receipt is deliberately not
1155
+ * a population: a signed delivery is verified, never authorized — it acts
1156
+ * as no one and audits as no one.
1155
1157
  */
1156
1158
  export const AuthMethod = {
1157
1159
  SESSION: 'session',
@@ -1159,7 +1161,6 @@ export const AuthMethod = {
1159
1161
  TOKEN: 'token',
1160
1162
  AGENT: 'agent',
1161
1163
  OAUTH: 'oauth',
1162
- WEBHOOK: 'webhook',
1163
1164
  SYSTEM: 'system',
1164
1165
  };
1165
1166
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipstatic/types",
3
- "version": "2.16.0-beta.1",
3
+ "version": "2.17.0-beta.10",
4
4
  "description": "Shared types for ShipStatic platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/index.ts CHANGED
@@ -730,6 +730,30 @@ export interface Account {
730
730
  * must never be sent to Checkout.
731
731
  */
732
732
  readonly upgrade: AccountPlanType | null;
733
+ /**
734
+ * The live Subscription's billing interval — Stripe's
735
+ * `Price.recurring.interval`, mirrored — or `null` when no Subscription
736
+ * bills the account (free and granted plans). It is what lets the console
737
+ * offer the current plan's OTHER interval as a switch.
738
+ */
739
+ readonly interval: BillingInterval | null;
740
+ /**
741
+ * The pending plan change, or `null`. *Up is now, down is at period end*:
742
+ * a downgrade is a Stripe Subscription Schedule that applies at `at`, and
743
+ * until then the account keeps everything it paid for. Reversible —
744
+ * `DELETE /billing/change` releases it.
745
+ */
746
+ readonly scheduled: ScheduledChange | null;
747
+ /**
748
+ * When the Subscription is set to END — Stripe's `cancel_at`, mirrored
749
+ * (Unix seconds) — or `null` while it renews. Set by a cancellation in the
750
+ * Customer Portal; the Portal is also where it is resumed. The console
751
+ * needs it to ACT: no "cancel" offered to an account already cancelling,
752
+ * and no plan change offered until it is resumed (the API refuses one).
753
+ * Mirrored on the rule that survives: what the console must act on is
754
+ * mirrored, what it would merely display is not.
755
+ */
756
+ readonly cancelAt: number | null;
733
757
  }
734
758
 
735
759
  /**
@@ -1874,8 +1898,10 @@ export const SIGN_IN_RETURN_PARAM = 'signing-in';
1874
1898
  * Client populations: `SESSION` (first-party cookie), `API_KEY` (`ship-`
1875
1899
  * key), `TOKEN` (`deploy-` deploy token), `AGENT` (anonymous public deploy —
1876
1900
  * no credential; the platform grants the public-account identity per
1877
- * request), `OAUTH` (delegated access token). Server populations: `WEBHOOK`
1878
- * (signed webhook processing), `SYSTEM` (scheduled/background jobs).
1901
+ * request), `OAUTH` (delegated access token). The one server population:
1902
+ * `SYSTEM` (scheduled/background jobs). Webhook receipt is deliberately not
1903
+ * a population: a signed delivery is verified, never authorized — it acts
1904
+ * as no one and audits as no one.
1879
1905
  */
1880
1906
  export const AuthMethod = {
1881
1907
  SESSION: 'session',
@@ -1883,7 +1909,6 @@ export const AuthMethod = {
1883
1909
  TOKEN: 'token',
1884
1910
  AGENT: 'agent',
1885
1911
  OAUTH: 'oauth',
1886
- WEBHOOK: 'webhook',
1887
1912
  SYSTEM: 'system',
1888
1913
  } as const;
1889
1914
 
@@ -2689,6 +2714,20 @@ export interface Plan {
2689
2714
  * nothing (a plan sold by conversation publishes no numbers).
2690
2715
  */
2691
2716
  readonly caps: Caps | null;
2717
+ /**
2718
+ * Why this row cannot be ordered right now — the closed door's own sentence,
2719
+ * verbatim — or absent when the way is open. A menu lists what can be
2720
+ * ordered, and a row that is sold but not yet orderable (its door is closed:
2721
+ * checkout unbuilt, a feature unfinished) SAYS SO on the menu instead of
2722
+ * only at the order.
2723
+ *
2724
+ * Clients branch on PRESENCE and render the sentence unchanged — they know
2725
+ * *that* the row is closed, never *which* door or *when it lifts*; the
2726
+ * vocabulary of doors stays server-side. The same rule the refusal follows:
2727
+ * `POST /billing/change` onto a closed row answers 400 with
2728
+ * `details.closed`, and its `message` is this sentence.
2729
+ */
2730
+ readonly closed?: string;
2692
2731
  }
2693
2732
 
2694
2733
  /**
@@ -2706,49 +2745,68 @@ export interface PlansResponse {
2706
2745
  }
2707
2746
 
2708
2747
  /**
2709
- * The body of `POST /billing/checkout` — which plan, at which interval. Both
2710
- * required: with more than one billed plan there is no honest default, and
2711
- * the console always knows which card was clicked. Only a free account
2712
- * checks out, and only onto a plan the menu sells; a billed account changes
2713
- * plan through the Portal ({@link BillingPortalRequest}), because Stripe
2714
- * changes a Subscription in place rather than selling a second one.
2748
+ * The body of `POST /billing/change` — the one door for "get me onto this
2749
+ * plan". Both fields required: with more than one billed plan there is no
2750
+ * honest default, and the console always knows which card was clicked.
2751
+ *
2752
+ * The SERVER decides what the change means — the rule is *up is now, down is
2753
+ * at period end* so the client holds no copy of the ladder: a free account
2754
+ * is sent to Stripe Checkout, a billed account moving up is sent to the
2755
+ * Portal's confirmation page (money moves now, so Stripe's page takes the
2756
+ * consent), and a billed account moving down gets a Stripe Subscription
2757
+ * Schedule that applies the change at period end. The answer says which
2758
+ * happened ({@link PlanChangeResponse}).
2715
2759
  */
2716
- export interface CheckoutRequest {
2760
+ export interface PlanChangeRequest {
2717
2761
  readonly plan: AccountPlanType;
2718
2762
  readonly interval: BillingInterval;
2719
2763
  }
2720
2764
 
2721
2765
  /**
2722
- * The body of `POST /billing/portal` optional, and when present a
2723
- * DESTINATION: the plan and interval the account wants, which opens the
2724
- * Portal on Stripe's own confirmation page for that Price rather than on its
2725
- * home page. Absent, the Portal opens where it always did: cards, invoices,
2726
- * cancellation, and Stripe's own plan picker.
2766
+ * The pending plan changea Stripe Subscription Schedule, mirrored onto the
2767
+ * account. `at` is when it applies (the current period's end, Unix seconds).
2768
+ *
2769
+ * WHO minted the schedule is deliberately not part of this shape, and both
2770
+ * kinds mirror here identically: Stripe mints one when a customer confirms a
2771
+ * cadence downgrade on its own hosted page, and the platform mints one for a
2772
+ * cheaper TIER, the single move Stripe's Customer Portal cannot express.
2773
+ *
2774
+ * Reversible until it applies, and `DELETE /billing/change` is the only way:
2775
+ * Stripe's Portal displays a pending change but offers no control to undo it.
2727
2776
  */
2728
- export interface BillingPortalRequest {
2729
- readonly plan?: AccountPlanType;
2730
- readonly interval?: BillingInterval;
2777
+ export interface ScheduledChange {
2778
+ readonly plan: AccountPlanType;
2779
+ readonly interval: BillingInterval;
2780
+ readonly at: number;
2731
2781
  }
2732
2782
 
2733
2783
  /**
2734
- * The answer of `POST /billing/checkout` — Stripe's `Checkout.Session`,
2735
- * projected to the one field a client needs.
2784
+ * The answer of `POST /billing/change` — exactly one field is set, and the
2785
+ * UNION is what holds that: an answer carrying both, or neither, does not
2786
+ * compile, so "which door was taken" is structural rather than prose.
2787
+ *
2788
+ * `url` means GO: a Stripe page (Checkout, or the Portal's confirmation page)
2789
+ * finishes the change and the browser must be redirected to it. A `url` does
2790
+ * NOT imply money moves — on the confirmation page Stripe decides whether to
2791
+ * charge now or defer the change to period end, and says which. `scheduled`
2792
+ * means DONE: the change is booked for period end by the platform itself,
2793
+ * nothing to visit, and the account's `scheduled` field now carries it.
2736
2794
  *
2737
- * There is nothing else to return: the outcome arrives later, as a Stripe
2738
- * webhook. It is its own type rather than a shape shared with
2739
- * {@link BillingPortalSession} because Stripe has two distinct objects here,
2740
- * and naming one of them for both would be the reader's translation to make.
2795
+ * A client branches on the SHAPE and holds no copy of which move takes which
2796
+ * door which is what let the server move that boundary without a wire
2797
+ * change (2026-08-25).
2741
2798
  */
2742
- export interface CheckoutSession {
2743
- /** Absolute URL to redirect the browser to. Single use, short-lived. */
2744
- readonly url: string;
2745
- }
2799
+ export type PlanChangeResponse =
2800
+ /** GO: a Stripe page finishes the change. Absolute URL, single use, short-lived. */
2801
+ | { readonly url: string; readonly scheduled?: never }
2802
+ /** DONE: the downgrade is booked for period end; nothing to visit. */
2803
+ | { readonly url?: never; readonly scheduled: ScheduledChange };
2746
2804
 
2747
2805
  /**
2748
2806
  * The answer of `POST /billing/portal` — Stripe's `BillingPortal.Session`,
2749
- * projected the same way. Identical in shape to {@link CheckoutSession} and
2750
- * deliberately not merged with it: they are two Stripe objects, and either may
2751
- * gain a field the other never has.
2807
+ * projected to the one field a client needs. The Portal home: cards,
2808
+ * invoices, cancellation. Plan changes have their own door
2809
+ * ({@link PlanChangeRequest}).
2752
2810
  */
2753
2811
  export interface BillingPortalSession {
2754
2812
  /** Absolute URL to redirect the browser to. Single use, short-lived. */
@@ -2773,14 +2831,17 @@ export interface BillingSyncResponse {
2773
2831
  /**
2774
2832
  * All activity event types logged in the system.
2775
2833
  * Uses dot notation consistently: {resource}.{action}
2834
+ *
2835
+ * Retention: activity rows are permanent — the account's own history and
2836
+ * the platform's audit ledgers are one table, kept for the life of the
2837
+ * account (deletion removes them). Only the personal payload is
2838
+ * time-bounded: past 90 days each row sheds its IP.
2776
2839
  */
2777
2840
  export type ActivityEvent =
2778
2841
  // Account events
2779
2842
  | 'account.create'
2780
- | 'account.update'
2781
2843
  | 'account.delete'
2782
2844
  | 'account.key.generate'
2783
- | 'account.plan.paid'
2784
2845
  | 'account.plan.transition'
2785
2846
  // Deployment events
2786
2847
  | 'deployment.create'
@@ -2817,7 +2878,6 @@ export type ActivityEvent =
2817
2878
  */
2818
2879
  export type UserVisibleActivityEvent =
2819
2880
  | 'account.create'
2820
- | 'account.update'
2821
2881
  | 'account.delete'
2822
2882
  | 'account.key.generate'
2823
2883
  | 'account.plan.transition'