@shipstatic/types 2.15.0-beta.1 → 2.17.0-beta.1

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
@@ -518,11 +518,15 @@ export interface TokenDeleteResponse {
518
518
  * account keeps its tier through suspension and into deletion.
519
519
  *
520
520
  * - **Free** — `free`.
521
- * - **Billed** — `pro`. The one plan a customer can buy; the only plan Stripe
522
- * knows about, and the only one the platform never sets by hand — it is
523
- * derived from the Stripe subscription.
521
+ * - **Billed** — `pro`, `team`. The plans a customer buys; the only plans
522
+ * Stripe knows about, and the only ones the platform never sets by hand —
523
+ * each is derived from the Stripe Subscription, which names its plan on the
524
+ * Price it is on. They form a ladder: a dearer tier is a superset of the one
525
+ * below it, and the API says which is next in {@link Account.upgrade}.
524
526
  * - **Granted** — `scale`, `sponsored`. Paid plans the operator confers by
525
- * hand; no Stripe subscription, no Checkout, no Stripe object at all.
527
+ * hand; no Stripe subscription, no Checkout, no Stripe object at all. These
528
+ * and `free` are the only plans an operator can set; a billed plan is only
529
+ * ever Stripe's to confer.
526
530
  *
527
531
  * The numbers each plan confers — caps, sizes — are POLICY and are delivered
528
532
  * by the API (`GET /plans`, `GET /account`, `GET /limits`), never published
@@ -532,23 +536,31 @@ export interface TokenDeleteResponse {
532
536
  export declare const AccountPlan: {
533
537
  readonly FREE: "free";
534
538
  readonly PRO: "pro";
539
+ readonly TEAM: "team";
535
540
  readonly SCALE: "scale";
536
541
  readonly SPONSORED: "sponsored";
537
542
  };
538
543
  export type AccountPlanType = (typeof AccountPlan)[keyof typeof AccountPlan];
539
544
  /**
540
- * The two things an account ACCUMULATES, and therefore the two things a plan
541
- * caps. One word for the count and for the ceiling: `Account.usage` and
545
+ * The three things an account ACCUMULATES, and therefore the three things a
546
+ * plan caps. One word for the count and for the ceiling: `Account.usage` and
542
547
  * `Account.caps` are the same shape, so a surface renders "2 of 3" by
543
548
  * dividing one by the other and can never divide by a different denominator
544
549
  * than the 403 uses.
545
550
  *
546
- * Both are counts paid plans SELL. A platform subdomain (`x.shipstatic.com`)
547
- * is not among them: the platform owns the name, it costs nothing, and no
548
- * plan bounds how many an account may hold.
551
+ * All three are counts plans SELL, and every plan publishes a number for each.
552
+ * A platform subdomain (`my-app.shipstatic.com`) is among them: the namespace
553
+ * is the platform's, so every plan bounds how many names one account may take
554
+ * from it — which is not the address every deployment gets by construction
555
+ * (`happy-cat-abc1234.shipstatic.com`), one per deployment and bounded by
556
+ * `deployments` already.
549
557
  *
550
558
  * Every cap carries a number on every plan — never `null`, never
551
- * "unlimited" — so no consumer needs an "is it bounded?" branch.
559
+ * "unlimited" — so no consumer needs an "is it bounded?" branch. A cap of `0`
560
+ * means the plan does not have the feature at all; a cap of `N` bounds
561
+ * creation, and what an account already holds above a cap stays until a plan
562
+ * TRANSITION fits it (excess paused, newest first — a domain is the only kind
563
+ * that pauses).
552
564
  *
553
565
  * A count is an aggregate over a collection, so it lives on the summary
554
566
  * resource that owns the collection: `GET /account` for one caller, `GET
@@ -562,6 +574,12 @@ export interface Caps {
562
574
  * different question asked of a different resource.)
563
575
  */
564
576
  readonly deployments: number;
577
+ /**
578
+ * Names the customer chose under the platform's own suffix
579
+ * (`my-app.shipstatic.com`) — every row, paused ones included, by the same
580
+ * rule as custom domains.
581
+ */
582
+ readonly platformDomains: number;
565
583
  /**
566
584
  * Hostnames the customer owns — every row, paused ones included. A paused
567
585
  * domain still occupies its slot, so deleting one is what frees capacity.
@@ -620,6 +638,37 @@ export interface Account {
620
638
  * mirrored on the account row for the operator surface.
621
639
  */
622
640
  readonly pastDue: boolean;
641
+ /**
642
+ * Does Stripe bill this plan — is there a Subscription behind it? True for
643
+ * every billed tier, including one no longer on the menu (a grandfathered
644
+ * row keeps its subscribers), so a console cannot derive it from `/plans`.
645
+ * It is what sends the account to the Customer Portal rather than to
646
+ * Checkout, and what a granted plan (`scale`, `sponsored`) never is.
647
+ */
648
+ readonly billed: boolean;
649
+ /**
650
+ * The next plan up the ladder this account could move to, or `null` when
651
+ * there is none: the top billed tier, every granted plan, and any plan not
652
+ * on the menu answer `null`. One server-side fact so that no surface
653
+ * derives "can this account upgrade, and to what" from the menu — a
654
+ * grandfathered row has no menu price to compare, and a granted account
655
+ * must never be sent to Checkout.
656
+ */
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;
623
672
  }
624
673
  /**
625
674
  * Account as returned by `GET /account` — the entity plus how the request
@@ -1748,11 +1797,11 @@ export interface TokenResource {
1748
1797
  delete: (token: string) => Promise<TokenDeleteResponse>;
1749
1798
  }
1750
1799
  /**
1751
- * How often a subscription renews. The platform sells one plan at two
1752
- * intervals, so this is the only thing a buyer chooses at checkout.
1800
+ * How often a subscription renews. Every billed plan is sold at both
1801
+ * intervals, so a buyer chooses a plan and an interval, and nothing else.
1753
1802
  *
1754
1803
  * It never branches business logic — monthly and yearly confer identical
1755
- * caps. It exists to be displayed and to pick a price at checkout.
1804
+ * caps. It exists to be displayed and to pick a Price at checkout.
1756
1805
  */
1757
1806
  export type BillingInterval = 'month' | 'year';
1758
1807
  /**
@@ -1808,23 +1857,52 @@ export interface PlansResponse {
1808
1857
  readonly plans: readonly Plan[];
1809
1858
  }
1810
1859
  /**
1811
- * The answer of `POST /billing/checkout` — Stripe's `Checkout.Session`,
1812
- * projected to the one field a client needs.
1860
+ * The body of `POST /billing/change` — the one door for "get me onto this
1861
+ * plan". Both fields required: with more than one billed plan there is no
1862
+ * honest default, and the console always knows which card was clicked.
1813
1863
  *
1814
- * There is nothing else to return: the outcome arrives later, as a Stripe
1815
- * webhook. It is its own type rather than a shape shared with
1816
- * {@link BillingPortalSession} because Stripe has two distinct objects here,
1817
- * and naming one of them for both would be the reader's translation to make.
1864
+ * The SERVER decides what the change means — the rule is *up is now, down is
1865
+ * at period end* so the client holds no copy of the ladder: a free account
1866
+ * is sent to Stripe Checkout, a billed account moving up is sent to the
1867
+ * Portal's confirmation page (money moves now, so Stripe's page takes the
1868
+ * consent), and a billed account moving down gets a Stripe Subscription
1869
+ * Schedule that applies the change at period end. The answer says which
1870
+ * happened ({@link PlanChangeResponse}).
1818
1871
  */
1819
- export interface CheckoutSession {
1872
+ export interface PlanChangeRequest {
1873
+ readonly plan: AccountPlanType;
1874
+ readonly interval: BillingInterval;
1875
+ }
1876
+ /**
1877
+ * The pending plan change — a Stripe Subscription Schedule the platform
1878
+ * minted, mirrored onto the account. `at` is when it applies (the current
1879
+ * period's end, Unix seconds). Reversible until then: `DELETE
1880
+ * /billing/change` releases it.
1881
+ */
1882
+ export interface ScheduledChange {
1883
+ readonly plan: AccountPlanType;
1884
+ readonly interval: BillingInterval;
1885
+ readonly at: number;
1886
+ }
1887
+ /**
1888
+ * The answer of `POST /billing/change` — exactly one field is set.
1889
+ *
1890
+ * `url` means GO: a Stripe page (Checkout, or the Portal's confirmation page)
1891
+ * finishes the change and the browser must be redirected to it. `scheduled`
1892
+ * means DONE: the downgrade is booked for period end, nothing to visit, and
1893
+ * the account's `scheduled` field now carries it.
1894
+ */
1895
+ export interface PlanChangeResponse {
1820
1896
  /** Absolute URL to redirect the browser to. Single use, short-lived. */
1821
- readonly url: string;
1897
+ readonly url?: string;
1898
+ /** The pending change, when the platform scheduled it instead. */
1899
+ readonly scheduled?: ScheduledChange;
1822
1900
  }
1823
1901
  /**
1824
1902
  * The answer of `POST /billing/portal` — Stripe's `BillingPortal.Session`,
1825
- * projected the same way. Identical in shape to {@link CheckoutSession} and
1826
- * deliberately not merged with it: they are two Stripe objects, and either may
1827
- * gain a field the other never has.
1903
+ * projected to the one field a client needs. The Portal home: cards,
1904
+ * invoices, cancellation. Plan changes have their own door
1905
+ * ({@link PlanChangeRequest}).
1828
1906
  */
1829
1907
  export interface BillingPortalSession {
1830
1908
  /** Absolute URL to redirect the browser to. Single use, short-lived. */
package/dist/index.js CHANGED
@@ -177,11 +177,15 @@ export function validateIdempotencyKey(value) {
177
177
  * account keeps its tier through suspension and into deletion.
178
178
  *
179
179
  * - **Free** — `free`.
180
- * - **Billed** — `pro`. The one plan a customer can buy; the only plan Stripe
181
- * knows about, and the only one the platform never sets by hand — it is
182
- * derived from the Stripe subscription.
180
+ * - **Billed** — `pro`, `team`. The plans a customer buys; the only plans
181
+ * Stripe knows about, and the only ones the platform never sets by hand —
182
+ * each is derived from the Stripe Subscription, which names its plan on the
183
+ * Price it is on. They form a ladder: a dearer tier is a superset of the one
184
+ * below it, and the API says which is next in {@link Account.upgrade}.
183
185
  * - **Granted** — `scale`, `sponsored`. Paid plans the operator confers by
184
- * hand; no Stripe subscription, no Checkout, no Stripe object at all.
186
+ * hand; no Stripe subscription, no Checkout, no Stripe object at all. These
187
+ * and `free` are the only plans an operator can set; a billed plan is only
188
+ * ever Stripe's to confer.
185
189
  *
186
190
  * The numbers each plan confers — caps, sizes — are POLICY and are delivered
187
191
  * by the API (`GET /plans`, `GET /account`, `GET /limits`), never published
@@ -191,6 +195,7 @@ export function validateIdempotencyKey(value) {
191
195
  export const AccountPlan = {
192
196
  FREE: 'free',
193
197
  PRO: 'pro',
198
+ TEAM: 'team',
194
199
  SCALE: 'scale',
195
200
  SPONSORED: 'sponsored',
196
201
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipstatic/types",
3
- "version": "2.15.0-beta.1",
3
+ "version": "2.17.0-beta.1",
4
4
  "description": "Shared types for ShipStatic platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/index.ts CHANGED
@@ -590,11 +590,15 @@ export interface TokenDeleteResponse {
590
590
  * account keeps its tier through suspension and into deletion.
591
591
  *
592
592
  * - **Free** — `free`.
593
- * - **Billed** — `pro`. The one plan a customer can buy; the only plan Stripe
594
- * knows about, and the only one the platform never sets by hand — it is
595
- * derived from the Stripe subscription.
593
+ * - **Billed** — `pro`, `team`. The plans a customer buys; the only plans
594
+ * Stripe knows about, and the only ones the platform never sets by hand —
595
+ * each is derived from the Stripe Subscription, which names its plan on the
596
+ * Price it is on. They form a ladder: a dearer tier is a superset of the one
597
+ * below it, and the API says which is next in {@link Account.upgrade}.
596
598
  * - **Granted** — `scale`, `sponsored`. Paid plans the operator confers by
597
- * hand; no Stripe subscription, no Checkout, no Stripe object at all.
599
+ * hand; no Stripe subscription, no Checkout, no Stripe object at all. These
600
+ * and `free` are the only plans an operator can set; a billed plan is only
601
+ * ever Stripe's to confer.
598
602
  *
599
603
  * The numbers each plan confers — caps, sizes — are POLICY and are delivered
600
604
  * by the API (`GET /plans`, `GET /account`, `GET /limits`), never published
@@ -604,6 +608,7 @@ export interface TokenDeleteResponse {
604
608
  export const AccountPlan = {
605
609
  FREE: 'free',
606
610
  PRO: 'pro',
611
+ TEAM: 'team',
607
612
  SCALE: 'scale',
608
613
  SPONSORED: 'sponsored',
609
614
  } as const;
@@ -611,18 +616,25 @@ export const AccountPlan = {
611
616
  export type AccountPlanType = (typeof AccountPlan)[keyof typeof AccountPlan];
612
617
 
613
618
  /**
614
- * The two things an account ACCUMULATES, and therefore the two things a plan
615
- * caps. One word for the count and for the ceiling: `Account.usage` and
619
+ * The three things an account ACCUMULATES, and therefore the three things a
620
+ * plan caps. One word for the count and for the ceiling: `Account.usage` and
616
621
  * `Account.caps` are the same shape, so a surface renders "2 of 3" by
617
622
  * dividing one by the other and can never divide by a different denominator
618
623
  * than the 403 uses.
619
624
  *
620
- * Both are counts paid plans SELL. A platform subdomain (`x.shipstatic.com`)
621
- * is not among them: the platform owns the name, it costs nothing, and no
622
- * plan bounds how many an account may hold.
625
+ * All three are counts plans SELL, and every plan publishes a number for each.
626
+ * A platform subdomain (`my-app.shipstatic.com`) is among them: the namespace
627
+ * is the platform's, so every plan bounds how many names one account may take
628
+ * from it — which is not the address every deployment gets by construction
629
+ * (`happy-cat-abc1234.shipstatic.com`), one per deployment and bounded by
630
+ * `deployments` already.
623
631
  *
624
632
  * Every cap carries a number on every plan — never `null`, never
625
- * "unlimited" — so no consumer needs an "is it bounded?" branch.
633
+ * "unlimited" — so no consumer needs an "is it bounded?" branch. A cap of `0`
634
+ * means the plan does not have the feature at all; a cap of `N` bounds
635
+ * creation, and what an account already holds above a cap stays until a plan
636
+ * TRANSITION fits it (excess paused, newest first — a domain is the only kind
637
+ * that pauses).
626
638
  *
627
639
  * A count is an aggregate over a collection, so it lives on the summary
628
640
  * resource that owns the collection: `GET /account` for one caller, `GET
@@ -636,6 +648,12 @@ export interface Caps {
636
648
  * different question asked of a different resource.)
637
649
  */
638
650
  readonly deployments: number;
651
+ /**
652
+ * Names the customer chose under the platform's own suffix
653
+ * (`my-app.shipstatic.com`) — every row, paused ones included, by the same
654
+ * rule as custom domains.
655
+ */
656
+ readonly platformDomains: number;
639
657
  /**
640
658
  * Hostnames the customer owns — every row, paused ones included. A paused
641
659
  * domain still occupies its slot, so deleting one is what frees capacity.
@@ -695,6 +713,37 @@ export interface Account {
695
713
  * mirrored on the account row for the operator surface.
696
714
  */
697
715
  readonly pastDue: boolean;
716
+ /**
717
+ * Does Stripe bill this plan — is there a Subscription behind it? True for
718
+ * every billed tier, including one no longer on the menu (a grandfathered
719
+ * row keeps its subscribers), so a console cannot derive it from `/plans`.
720
+ * It is what sends the account to the Customer Portal rather than to
721
+ * Checkout, and what a granted plan (`scale`, `sponsored`) never is.
722
+ */
723
+ readonly billed: boolean;
724
+ /**
725
+ * The next plan up the ladder this account could move to, or `null` when
726
+ * there is none: the top billed tier, every granted plan, and any plan not
727
+ * on the menu answer `null`. One server-side fact so that no surface
728
+ * derives "can this account upgrade, and to what" from the menu — a
729
+ * grandfathered row has no menu price to compare, and a granted account
730
+ * must never be sent to Checkout.
731
+ */
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;
698
747
  }
699
748
 
700
749
  /**
@@ -2611,11 +2660,11 @@ export interface TokenResource {
2611
2660
  // =============================================================================
2612
2661
 
2613
2662
  /**
2614
- * How often a subscription renews. The platform sells one plan at two
2615
- * intervals, so this is the only thing a buyer chooses at checkout.
2663
+ * How often a subscription renews. Every billed plan is sold at both
2664
+ * intervals, so a buyer chooses a plan and an interval, and nothing else.
2616
2665
  *
2617
2666
  * It never branches business logic — monthly and yearly confer identical
2618
- * caps. It exists to be displayed and to pick a price at checkout.
2667
+ * caps. It exists to be displayed and to pick a Price at checkout.
2619
2668
  */
2620
2669
  export type BillingInterval = 'month' | 'year';
2621
2670
 
@@ -2671,24 +2720,55 @@ export interface PlansResponse {
2671
2720
  }
2672
2721
 
2673
2722
  /**
2674
- * The answer of `POST /billing/checkout` — Stripe's `Checkout.Session`,
2675
- * projected to the one field a client needs.
2723
+ * The body of `POST /billing/change` — the one door for "get me onto this
2724
+ * plan". Both fields required: with more than one billed plan there is no
2725
+ * honest default, and the console always knows which card was clicked.
2726
+ *
2727
+ * The SERVER decides what the change means — the rule is *up is now, down is
2728
+ * at period end* — so the client holds no copy of the ladder: a free account
2729
+ * is sent to Stripe Checkout, a billed account moving up is sent to the
2730
+ * Portal's confirmation page (money moves now, so Stripe's page takes the
2731
+ * consent), and a billed account moving down gets a Stripe Subscription
2732
+ * Schedule that applies the change at period end. The answer says which
2733
+ * happened ({@link PlanChangeResponse}).
2734
+ */
2735
+ export interface PlanChangeRequest {
2736
+ readonly plan: AccountPlanType;
2737
+ readonly interval: BillingInterval;
2738
+ }
2739
+
2740
+ /**
2741
+ * The pending plan change — a Stripe Subscription Schedule the platform
2742
+ * minted, mirrored onto the account. `at` is when it applies (the current
2743
+ * period's end, Unix seconds). Reversible until then: `DELETE
2744
+ * /billing/change` releases it.
2745
+ */
2746
+ export interface ScheduledChange {
2747
+ readonly plan: AccountPlanType;
2748
+ readonly interval: BillingInterval;
2749
+ readonly at: number;
2750
+ }
2751
+
2752
+ /**
2753
+ * The answer of `POST /billing/change` — exactly one field is set.
2676
2754
  *
2677
- * There is nothing else to return: the outcome arrives later, as a Stripe
2678
- * webhook. It is its own type rather than a shape shared with
2679
- * {@link BillingPortalSession} because Stripe has two distinct objects here,
2680
- * and naming one of them for both would be the reader's translation to make.
2755
+ * `url` means GO: a Stripe page (Checkout, or the Portal's confirmation page)
2756
+ * finishes the change and the browser must be redirected to it. `scheduled`
2757
+ * means DONE: the downgrade is booked for period end, nothing to visit, and
2758
+ * the account's `scheduled` field now carries it.
2681
2759
  */
2682
- export interface CheckoutSession {
2760
+ export interface PlanChangeResponse {
2683
2761
  /** Absolute URL to redirect the browser to. Single use, short-lived. */
2684
- readonly url: string;
2762
+ readonly url?: string;
2763
+ /** The pending change, when the platform scheduled it instead. */
2764
+ readonly scheduled?: ScheduledChange;
2685
2765
  }
2686
2766
 
2687
2767
  /**
2688
2768
  * The answer of `POST /billing/portal` — Stripe's `BillingPortal.Session`,
2689
- * projected the same way. Identical in shape to {@link CheckoutSession} and
2690
- * deliberately not merged with it: they are two Stripe objects, and either may
2691
- * gain a field the other never has.
2769
+ * projected to the one field a client needs. The Portal home: cards,
2770
+ * invoices, cancellation. Plan changes have their own door
2771
+ * ({@link PlanChangeRequest}).
2692
2772
  */
2693
2773
  export interface BillingPortalSession {
2694
2774
  /** Absolute URL to redirect the browser to. Single use, short-lived. */