@farthershore/farthershore-js 0.21.1 → 0.23.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/CHANGELOG.md +88 -0
- package/README.md +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +7 -0
- package/dist/bootstrap.js.map +1 -1
- package/dist/cache.d.ts +32 -1
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js +42 -2
- package/dist/cache.js.map +1 -1
- package/dist/catalog.d.ts +36 -3
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +69 -7
- package/dist/catalog.js.map +1 -1
- package/dist/client.d.ts +16 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +24 -5
- package/dist/client.js.map +1 -1
- package/dist/components/_internal.d.ts +4 -4
- package/dist/components/_internal.d.ts.map +1 -1
- package/dist/components/access-control.d.ts +7 -7
- package/dist/components/access-control.d.ts.map +1 -1
- package/dist/components/access-denied.d.ts +1 -1
- package/dist/components/access-denied.d.ts.map +1 -1
- package/dist/components/app-shell.d.ts +1 -1
- package/dist/components/app-shell.d.ts.map +1 -1
- package/dist/components/app.d.ts +2 -2
- package/dist/components/app.d.ts.map +1 -1
- package/dist/components/audit-log-table.d.ts +9 -1
- package/dist/components/audit-log-table.d.ts.map +1 -1
- package/dist/components/audit-log-table.js +9 -1
- package/dist/components/audit-log-table.js.map +1 -1
- package/dist/components/auth-guard.d.ts +1 -1
- package/dist/components/auth-guard.d.ts.map +1 -1
- package/dist/components/auth.d.ts +12 -57
- package/dist/components/auth.d.ts.map +1 -1
- package/dist/components/auth.js +10 -22
- package/dist/components/auth.js.map +1 -1
- package/dist/components/auto-key-banner.d.ts +1 -1
- package/dist/components/auto-key-banner.d.ts.map +1 -1
- package/dist/components/bill-estimator.d.ts +9 -1
- package/dist/components/bill-estimator.d.ts.map +1 -1
- package/dist/components/bill-estimator.js +9 -1
- package/dist/components/bill-estimator.js.map +1 -1
- package/dist/components/billing.d.ts +9 -1
- package/dist/components/billing.d.ts.map +1 -1
- package/dist/components/billing.js +9 -1
- package/dist/components/billing.js.map +1 -1
- package/dist/components/cancel-subscription.d.ts +9 -1
- package/dist/components/cancel-subscription.d.ts.map +1 -1
- package/dist/components/cancel-subscription.js +9 -1
- package/dist/components/cancel-subscription.js.map +1 -1
- package/dist/components/chrome.d.ts +3 -3
- package/dist/components/chrome.d.ts.map +1 -1
- package/dist/components/code-sample.d.ts +1 -1
- package/dist/components/code-sample.d.ts.map +1 -1
- package/dist/components/credit.d.ts +9 -1
- package/dist/components/credit.d.ts.map +1 -1
- package/dist/components/credit.js +15 -3
- package/dist/components/credit.js.map +1 -1
- package/dist/components/docs-chrome/language-context.d.ts +2 -2
- package/dist/components/docs-chrome/language-context.d.ts.map +1 -1
- package/dist/components/docs.d.ts +1 -1
- package/dist/components/docs.d.ts.map +1 -1
- package/dist/components/env-badge.d.ts +1 -1
- package/dist/components/env-badge.d.ts.map +1 -1
- package/dist/components/index.d.ts +2 -4
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +5 -3
- package/dist/components/index.js.map +1 -1
- package/dist/components/keys.d.ts +9 -1
- package/dist/components/keys.d.ts.map +1 -1
- package/dist/components/keys.js +9 -1
- package/dist/components/keys.js.map +1 -1
- package/dist/components/legal-consent-gate.d.ts +1 -1
- package/dist/components/legal-consent-gate.d.ts.map +1 -1
- package/dist/components/legal-document.d.ts +3 -3
- package/dist/components/legal-document.d.ts.map +1 -1
- package/dist/components/limit-boundary.d.ts +1 -1
- package/dist/components/limit-boundary.d.ts.map +1 -1
- package/dist/components/limit-notice.d.ts +9 -1
- package/dist/components/limit-notice.d.ts.map +1 -1
- package/dist/components/limit-notice.js +9 -1
- package/dist/components/limit-notice.js.map +1 -1
- package/dist/components/move-to-latest.d.ts +9 -1
- package/dist/components/move-to-latest.d.ts.map +1 -1
- package/dist/components/move-to-latest.js +9 -1
- package/dist/components/move-to-latest.js.map +1 -1
- package/dist/components/onboarding-view.d.ts +1 -1
- package/dist/components/onboarding-view.d.ts.map +1 -1
- package/dist/components/onboarding-view.js +26 -2
- package/dist/components/onboarding-view.js.map +1 -1
- package/dist/components/org-switcher.d.ts +9 -1
- package/dist/components/org-switcher.d.ts.map +1 -1
- package/dist/components/org-switcher.js +9 -1
- package/dist/components/org-switcher.js.map +1 -1
- package/dist/components/payment-required-gate.d.ts +11 -0
- package/dist/components/payment-required-gate.d.ts.map +1 -0
- package/dist/components/payment-required-gate.js +125 -0
- package/dist/components/payment-required-gate.js.map +1 -0
- package/dist/components/permission-gate.d.ts +1 -1
- package/dist/components/permission-gate.d.ts.map +1 -1
- package/dist/components/plans-table.d.ts +9 -1
- package/dist/components/plans-table.d.ts.map +1 -1
- package/dist/components/plans-table.js +25 -5
- package/dist/components/plans-table.js.map +1 -1
- package/dist/components/product-docs/api-reference.d.ts +1 -1
- package/dist/components/product-docs/api-reference.d.ts.map +1 -1
- package/dist/components/product-docs/api-reference.js.map +1 -1
- package/dist/components/product-docs/fetch-product-docs.d.ts +11 -0
- package/dist/components/product-docs/fetch-product-docs.d.ts.map +1 -1
- package/dist/components/product-docs/fetch-product-docs.js +16 -2
- package/dist/components/product-docs/fetch-product-docs.js.map +1 -1
- package/dist/components/product-docs/icons.d.ts +21 -21
- package/dist/components/product-docs/icons.d.ts.map +1 -1
- package/dist/components/product-docs/markdown.d.ts +3 -3
- package/dist/components/product-docs/markdown.d.ts.map +1 -1
- package/dist/components/product-docs/product-docs-customize.d.ts +1 -1
- package/dist/components/product-docs/product-docs-customize.d.ts.map +1 -1
- package/dist/components/product-docs/product-docs-index.d.ts +4 -0
- package/dist/components/product-docs/product-docs-index.d.ts.map +1 -1
- package/dist/components/product-docs/product-docs-index.js +11 -0
- package/dist/components/product-docs/product-docs-index.js.map +1 -1
- package/dist/components/product-docs/product-docs-shell.d.ts +9 -9
- package/dist/components/product-docs/product-docs-shell.d.ts.map +1 -1
- package/dist/components/product-docs/product-docs-view.d.ts +2 -2
- package/dist/components/product-docs/product-docs-view.d.ts.map +1 -1
- package/dist/components/product-docs/product-docs.d.ts +3 -3
- package/dist/components/product-docs/product-docs.d.ts.map +1 -1
- package/dist/components/product-docs/product-docs.js +13 -5
- package/dist/components/product-docs/product-docs.js.map +1 -1
- package/dist/components/rate-limit-display.d.ts +9 -1
- package/dist/components/rate-limit-display.d.ts.map +1 -1
- package/dist/components/rate-limit-display.js +9 -1
- package/dist/components/rate-limit-display.js.map +1 -1
- package/dist/components/resource-limit-usage-card.d.ts +9 -1
- package/dist/components/resource-limit-usage-card.d.ts.map +1 -1
- package/dist/components/resource-limit-usage-card.js +18 -2
- package/dist/components/resource-limit-usage-card.js.map +1 -1
- package/dist/components/resources-panel.d.ts +9 -1
- package/dist/components/resources-panel.d.ts.map +1 -1
- package/dist/components/resources-panel.js +9 -1
- package/dist/components/resources-panel.js.map +1 -1
- package/dist/components/root.d.ts +5 -4
- package/dist/components/root.d.ts.map +1 -1
- package/dist/components/root.js +23 -11
- package/dist/components/root.js.map +1 -1
- package/dist/components/route-panel.d.ts +1 -1
- package/dist/components/route-panel.d.ts.map +1 -1
- package/dist/components/safe.d.ts +9 -0
- package/dist/components/safe.d.ts.map +1 -0
- package/dist/components/safe.js +31 -0
- package/dist/components/safe.js.map +1 -0
- package/dist/components/sign-in.d.ts +1 -1
- package/dist/components/sign-in.d.ts.map +1 -1
- package/dist/components/spend-cap-control.d.ts +9 -1
- package/dist/components/spend-cap-control.d.ts.map +1 -1
- package/dist/components/spend-cap-control.js +9 -1
- package/dist/components/spend-cap-control.js.map +1 -1
- package/dist/components/splash.d.ts +1 -1
- package/dist/components/splash.d.ts.map +1 -1
- package/dist/components/team-panel.d.ts +9 -1
- package/dist/components/team-panel.d.ts.map +1 -1
- package/dist/components/team-panel.js +9 -1
- package/dist/components/team-panel.js.map +1 -1
- package/dist/components/top-up-prompt.d.ts +9 -1
- package/dist/components/top-up-prompt.d.ts.map +1 -1
- package/dist/components/top-up-prompt.js +9 -1
- package/dist/components/top-up-prompt.js.map +1 -1
- package/dist/components/trial-banner.d.ts +9 -1
- package/dist/components/trial-banner.d.ts.map +1 -1
- package/dist/components/trial-banner.js +9 -1
- package/dist/components/trial-banner.js.map +1 -1
- package/dist/components/upgrade-prompt.d.ts +9 -1
- package/dist/components/upgrade-prompt.d.ts.map +1 -1
- package/dist/components/upgrade-prompt.js +9 -1
- package/dist/components/upgrade-prompt.js.map +1 -1
- package/dist/components/usage.d.ts +9 -1
- package/dist/components/usage.d.ts.map +1 -1
- package/dist/components/usage.js +9 -1
- package/dist/components/usage.js.map +1 -1
- package/dist/config.d.ts +30 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +19 -2
- package/dist/config.js.map +1 -1
- package/dist/format/index.d.ts +1 -1
- package/dist/format/index.d.ts.map +1 -1
- package/dist/format/index.js +5 -1
- package/dist/format/index.js.map +1 -1
- package/dist/generated/catalog-types.d.ts +8 -0
- package/dist/generated/catalog-types.d.ts.map +1 -1
- package/dist/generated/version.d.ts +2 -2
- package/dist/generated/version.js +2 -2
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +7 -1
- package/dist/http.js.map +1 -1
- package/dist/react/client-context.d.ts +15 -0
- package/dist/react/client-context.d.ts.map +1 -0
- package/dist/react/client-context.js +26 -0
- package/dist/react/client-context.js.map +1 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +5 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/mounted-context.d.ts +14 -0
- package/dist/react/mounted-context.d.ts.map +1 -0
- package/dist/react/mounted-context.js +42 -0
- package/dist/react/mounted-context.js.map +1 -0
- package/dist/react/mounted-types.d.ts +47 -0
- package/dist/react/mounted-types.d.ts.map +1 -0
- package/dist/react/mounted-types.js +9 -0
- package/dist/react/mounted-types.js.map +1 -0
- package/dist/react/organization-context.d.ts +1 -1
- package/dist/react/organization-context.d.ts.map +1 -1
- package/dist/react/provider.d.ts +2 -1
- package/dist/react/provider.d.ts.map +1 -1
- package/dist/react/provider.js +3 -2
- package/dist/react/provider.js.map +1 -1
- package/dist/react/use-async.d.ts.map +1 -1
- package/dist/react/use-async.js +24 -0
- package/dist/react/use-async.js.map +1 -1
- package/dist/resources/auth.js +5 -5
- package/dist/resources/auth.js.map +1 -1
- package/dist/test-utils/mock-client.d.ts.map +1 -1
- package/dist/test-utils/mock-client.js +16 -1
- package/dist/test-utils/mock-client.js.map +1 -1
- package/dist/test-utils/test-provider.d.ts +1 -1
- package/dist/test-utils/test-provider.d.ts.map +1 -1
- package/dist/types.d.ts +19 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +5 -5
- package/dist/components/payment-health-banner.d.ts +0 -8
- package/dist/components/payment-health-banner.d.ts.map +0 -1
- package/dist/components/payment-health-banner.js +0 -42
- package/dist/components/payment-health-banner.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,94 @@
|
|
|
3
3
|
All notable changes to `@farthershore/farthershore-js` are documented here.
|
|
4
4
|
This project adheres to Semantic Versioning (pre-1.0: minors may break).
|
|
5
5
|
|
|
6
|
+
## [0.23.0] - 2026-07-29
|
|
7
|
+
|
|
8
|
+
Cache invalidation reaches the screen. **Behavior change, no API break.**
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **Data hooks now refetch when the session identity changes.** Busting the
|
|
13
|
+
read cache only cleared the map, so reads ALREADY on screen never re-ran —
|
|
14
|
+
a surface kept rendering pre-bust data until something happened to remount
|
|
15
|
+
it. Two consequences, both fixed:
|
|
16
|
+
- A host resolving its own token (`skipAuth` / BYO-auth) issues the first
|
|
17
|
+
`/me` read before the token exists. It 401s; `setSessionToken()` lands
|
|
18
|
+
moments later and busts — but nothing re-read, so `PaymentRequiredGate`
|
|
19
|
+
stayed on its signed-out result and let unpaid traffic through for the
|
|
20
|
+
rest of the session.
|
|
21
|
+
- After `migrateToLatest()` (or cancel / restore / top-up), sibling billing
|
|
22
|
+
surfaces kept showing the OLD plan. Only the hook that performed the
|
|
23
|
+
mutation refreshed.
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
- **Custom hooks built on `useAsync` now refetch on a session or entitlement
|
|
28
|
+
change.** This is the fix above, and it is the one thing to know when
|
|
29
|
+
upgrading: your `fn` runs at moments it previously did not. It must be safe
|
|
30
|
+
to re-run at any time — which it already had to be, since `deps` changes and
|
|
31
|
+
`refetch()` could always re-run it.
|
|
32
|
+
- The wake is **selective by design**, so ordinary writes stay quiet: an
|
|
33
|
+
identity change or an entitlement move wakes every mounted reader; a
|
|
34
|
+
resource mutation (keys, team, account) does not, because the hook that
|
|
35
|
+
performed it refetches itself; an org switch does not, because org-scoped
|
|
36
|
+
hooks already carry `organizationId` in their deps.
|
|
37
|
+
|
|
38
|
+
### Added
|
|
39
|
+
|
|
40
|
+
- **`fs.readCache.subscribe(listener)`** — read-cache invalidation as an
|
|
41
|
+
external store, alongside the existing `fs.rateLimit` / `fs.limitState`
|
|
42
|
+
stores. Every `useAsync`-backed hook subscribes automatically; reach for
|
|
43
|
+
this only for state held OUTSIDE a hook (your own store or imperative
|
|
44
|
+
cache) that must invalidate in step with ours.
|
|
45
|
+
|
|
46
|
+
## [0.22.0] - 2026-07-28
|
|
47
|
+
|
|
48
|
+
The free tier becomes a floor, and the control plane goes same-origin.
|
|
49
|
+
**Breaking.**
|
|
50
|
+
|
|
51
|
+
### Breaking
|
|
52
|
+
|
|
53
|
+
- **`<PaymentHealthBanner>` removed.** `<FartherShoreRoot>` now mounts
|
|
54
|
+
`PaymentRequiredGate` itself, so a host wires nothing. A subscriber whose
|
|
55
|
+
payment failed and whose plan declares no grace has had access CUT — the
|
|
56
|
+
edge refuses every call — so a banner in the corner of a still-rendered app
|
|
57
|
+
was the wrong shape twice over: it assumed the app still worked, and it only
|
|
58
|
+
appeared if the host had remembered to mount it on the screen the subscriber
|
|
59
|
+
happened to be on. The gate replaces the app entirely and sends them straight
|
|
60
|
+
to Stripe's billing portal, auto-redirecting at most once per tab so a
|
|
61
|
+
subscriber who backs out without paying is never trapped in a bounce loop.
|
|
62
|
+
- **`paymentHealth()` now reads core's real vocabulary** and gained a
|
|
63
|
+
`blocked` state. It previously tested for `past_due` / `incomplete`,
|
|
64
|
+
strings core never sends (the wire is `CURRENT` | `GRACE_PERIOD` |
|
|
65
|
+
`OVERDUE`), so a subscriber in grace — or cut off outright — read as
|
|
66
|
+
perfectly healthy and every payment-status surface showed nothing.
|
|
67
|
+
|
|
68
|
+
- **`useBoot`, `useFsAuth`, and `useOptionalFsAuth` ship from
|
|
69
|
+
`@farthershore/farthershore-js/react`,** not `/components`. They are data
|
|
70
|
+
bindings, not UI, and the `/react` subpath is where a host without the
|
|
71
|
+
managed components can still reach them. Update imports; the hooks
|
|
72
|
+
themselves are unchanged.
|
|
73
|
+
|
|
74
|
+
### Changed
|
|
75
|
+
|
|
76
|
+
- **The declared free tier is hidden from `<PlansTable>` / `<FsPricing>`.**
|
|
77
|
+
A plan built with `fs.free()` is the auto-enrolment floor, not a choice —
|
|
78
|
+
new subscribers land on it at first sign-in, and a cancelled paid plan
|
|
79
|
+
lands back on it at period end (when the business declares one). Plan
|
|
80
|
+
cards therefore show only the plans a subscriber can actually choose.
|
|
81
|
+
- **Cancelled subscribers can buy again.** `<OnboardingView>` routes a
|
|
82
|
+
CANCELLED subscription to the plan picker (`signedOut`) instead of a dead
|
|
83
|
+
app whose every call the gateway denies, and checkout components support
|
|
84
|
+
the resubscribe path end to end.
|
|
85
|
+
- **Same-origin control plane.** On a platform-served portal the client
|
|
86
|
+
resolves core through the host's own `/_fs/api` proxy when the runtime
|
|
87
|
+
config says so (`window.__FS_CONFIG__.coreProxy`) — no CORS preflight, no
|
|
88
|
+
third-party cookies, no platform hostname in DevTools. Zero host-app
|
|
89
|
+
change; direct `coreUrl` configs behave exactly as before.
|
|
90
|
+
- **A managed component's failure stays in its own box.** Every managed
|
|
91
|
+
component renders inside its own error boundary, so one component
|
|
92
|
+
crashing (or one denied call) degrades that card, not the page.
|
|
93
|
+
|
|
6
94
|
## [0.21.1]
|
|
7
95
|
|
|
8
96
|
### Changed
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
The **Farther Shore Frontend SDK** — the browser + React integration layer for
|
|
4
4
|
your product's subscriber portal.
|
|
5
5
|
|
|
6
|
-
> **Status: `0.
|
|
6
|
+
> **Status: `0.23.0`.** Pre-1.0 (`0.x`): a minor bump (e.g. `0.9.x` → `0.10.0`)
|
|
7
7
|
> may include breaking changes, so a caret range is unsafe — **pin this package
|
|
8
8
|
> exactly** (`0.9.0`) or use a patch-only tilde (`~0.9.0`). Changes are recorded
|
|
9
9
|
> in [`CHANGELOG.md`](./CHANGELOG.md).
|
package/dist/bootstrap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,KAAK,EAEV,SAAS,EAKT,IAAI,EAIL,MAAM,YAAY,CAAC;AAMpB,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,aAAa,EACd,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,KAAK,EAEV,SAAS,EAKT,IAAI,EAIL,MAAM,YAAY,CAAC;AAMpB,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,aAAa,EACd,MAAM,8BAA8B,CAAC;AAmDtC,KAAK,YAAY,GAAG,aAAa,CAAC;AAClC,KAAK,YAAY,GAAG,aAAa,CAAC;AAQlC,MAAM,MAAM,aAAa,GAAG,IAAI,CAC9B,cAAc,EACZ,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,aAAa,GACb,iBAAiB,GACjB,yBAAyB,GACzB,yBAAyB,CAC5B,GAAG;IACF,MAAM,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IAC/B,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAChD,uBAAuB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,uBAAuB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzC,CAAC;AA+FF;;uEAEuE;AACvE,wBAAgB,OAAO,CAAC,CAAC,EAAE,aAAa,GAAG,IAAI,CA4B9C;AAsED;kDACkD;AAClD,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,SAAS,CAAC,CA6C7E"}
|
package/dist/bootstrap.js
CHANGED
|
@@ -48,6 +48,8 @@ function mapBusiness(p) {
|
|
|
48
48
|
...(p.legal ? { legal: p.legal } : {}),
|
|
49
49
|
// Absent on older Core payloads — default true (backward-compatible).
|
|
50
50
|
docsEnabled: p.docsEnabled ?? true,
|
|
51
|
+
// Closed by default — an older Core omits it and history stays hidden.
|
|
52
|
+
docsHistoryEnabled: p.docsHistoryEnabled === true,
|
|
51
53
|
featuredCompiledPlanId: p.featuredCompiledPlanId ?? null,
|
|
52
54
|
meters,
|
|
53
55
|
};
|
|
@@ -96,6 +98,11 @@ export function mapPlan(p) {
|
|
|
96
98
|
key: p.key,
|
|
97
99
|
name: p.name,
|
|
98
100
|
description: p.description ?? null,
|
|
101
|
+
// The declaration. Defaulted defensively rather than trusted: a core that
|
|
102
|
+
// predates the field would otherwise yield `undefined`, and an undefined
|
|
103
|
+
// free tier reads as "no free plan" — which is the safe direction (show
|
|
104
|
+
// the picker) rather than auto-enrolling someone onto a billable plan.
|
|
105
|
+
free: p.free === true,
|
|
99
106
|
recurringFeeCents: p.recurring_fee_cents,
|
|
100
107
|
// The platform omits `billing_interval` for monthly plans (the default);
|
|
101
108
|
// default a missing/absent value to "month" so the UI always has a cadence.
|
package/dist/bootstrap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,iFAAiF;AACjF,iFAAiF;AACjF,sCAAsC;AACtC,EAAE;AACF,+EAA+E;AAC/E,uEAAuE;AACvE,iFAAiF;AACjF,6EAA6E;AAC7E,2EAA2E;AAC3E,kDAAkD;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,iFAAiF;AACjF,iFAAiF;AACjF,sCAAsC;AACtC,EAAE;AACF,+EAA+E;AAC/E,uEAAuE;AACvE,iFAAiF;AACjF,6EAA6E;AAC7E,2EAA2E;AAC3E,kDAAkD;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AA8G9D,6EAA6E;AAE7E,SAAS,QAAQ,CAAC,CAAqB;IACrC,MAAM,GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,SAAS,CAAC;IACjC,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,C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|
}
|
|
6
6
|
export declare function cachedRead<T>(ctx: ClientContext, parts: ReadonlyArray<string | null | undefined>, fn: () => Promise<T>): Promise<T>;
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Drop every cached read — after any mutation, auth change, or org switch.
|
|
9
|
+
*
|
|
10
|
+
* Clearing ONLY. Mounted readers keep their current data until something else
|
|
11
|
+
* re-runs them, which is correct for a resource mutation: the hook that
|
|
12
|
+
* performed it refetches itself, and the rest of the screen did not change.
|
|
13
|
+
* When the change is one no reader can see coming — a new identity, a moved
|
|
14
|
+
* entitlement — use {@link bustReadCacheAndWake} instead.
|
|
15
|
+
*/
|
|
8
16
|
export declare function bustReadCache(ctx: ClientContext): void;
|
|
17
|
+
/**
|
|
18
|
+
* Drop every cached read AND wake every mounted reader so it refetches.
|
|
19
|
+
*
|
|
20
|
+
* For changes that invalidate what is ALREADY on screen rather than merely what
|
|
21
|
+
* would be read next — a new session/identity, or a moved entitlement. Nothing
|
|
22
|
+
* else re-runs those reads: the surfaces showing them did not initiate the
|
|
23
|
+
* change and have no dep that moved, so without a wake they render pre-change
|
|
24
|
+
* data for the rest of the session. Two shipped bugs came from exactly that: a
|
|
25
|
+
* `setSessionToken()` landing after a 401 left the payment gate open (its `/me`
|
|
26
|
+
* read had FAILED, and failures evict rather than cache — so there was no entry
|
|
27
|
+
* to drop, only a live reader to poke), and sibling billing surfaces kept the
|
|
28
|
+
* old plan after `migrateToLatest()`.
|
|
29
|
+
*
|
|
30
|
+
* Listeners are woken unconditionally, never gated on the cache being
|
|
31
|
+
* non-empty, precisely because the failed-read case leaves nothing cached.
|
|
32
|
+
*
|
|
33
|
+
* NOT for resource mutations. Waking every reader on a key/team/plan write also
|
|
34
|
+
* re-runs unrelated reads, and a refetch that resolves the active org can
|
|
35
|
+
* REMOUNT the subtree — which destroys component state a user still needs, e.g.
|
|
36
|
+
* the one-time API-key secret held in `<ApiKeysPanel>`. Mutations bust and
|
|
37
|
+
* refetch their own hook; that is enough.
|
|
38
|
+
*/
|
|
39
|
+
export declare function bustReadCacheAndWake(ctx: ClientContext): void;
|
|
9
40
|
/**
|
|
10
41
|
* Reset everything an ENTITLEMENT-MUTATING action invalidates (W6.3): the read
|
|
11
42
|
* cache AND the cached short-lived gateway context token. A plan change /
|
package/dist/cache.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;CAC3B;AAED,wBAAgB,UAAU,CAAC,CAAC,EAC1B,GAAG,EAAE,aAAa,EAClB,KAAK,EAAE,aAAa,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAC/C,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAaZ;AAED
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;CAC3B;AAED,wBAAgB,UAAU,CAAC,CAAC,EAC1B,GAAG,EAAE,aAAa,EAClB,KAAK,EAAE,aAAa,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAC/C,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAaZ;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAEtD;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAG7D;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAQ9D"}
|
package/dist/cache.js
CHANGED
|
@@ -27,10 +27,45 @@ export function cachedRead(ctx, parts, fn) {
|
|
|
27
27
|
});
|
|
28
28
|
return promise;
|
|
29
29
|
}
|
|
30
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Drop every cached read — after any mutation, auth change, or org switch.
|
|
32
|
+
*
|
|
33
|
+
* Clearing ONLY. Mounted readers keep their current data until something else
|
|
34
|
+
* re-runs them, which is correct for a resource mutation: the hook that
|
|
35
|
+
* performed it refetches itself, and the rest of the screen did not change.
|
|
36
|
+
* When the change is one no reader can see coming — a new identity, a moved
|
|
37
|
+
* entitlement — use {@link bustReadCacheAndWake} instead.
|
|
38
|
+
*/
|
|
31
39
|
export function bustReadCache(ctx) {
|
|
32
40
|
ctx.readCache.clear();
|
|
33
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Drop every cached read AND wake every mounted reader so it refetches.
|
|
44
|
+
*
|
|
45
|
+
* For changes that invalidate what is ALREADY on screen rather than merely what
|
|
46
|
+
* would be read next — a new session/identity, or a moved entitlement. Nothing
|
|
47
|
+
* else re-runs those reads: the surfaces showing them did not initiate the
|
|
48
|
+
* change and have no dep that moved, so without a wake they render pre-change
|
|
49
|
+
* data for the rest of the session. Two shipped bugs came from exactly that: a
|
|
50
|
+
* `setSessionToken()` landing after a 401 left the payment gate open (its `/me`
|
|
51
|
+
* read had FAILED, and failures evict rather than cache — so there was no entry
|
|
52
|
+
* to drop, only a live reader to poke), and sibling billing surfaces kept the
|
|
53
|
+
* old plan after `migrateToLatest()`.
|
|
54
|
+
*
|
|
55
|
+
* Listeners are woken unconditionally, never gated on the cache being
|
|
56
|
+
* non-empty, precisely because the failed-read case leaves nothing cached.
|
|
57
|
+
*
|
|
58
|
+
* NOT for resource mutations. Waking every reader on a key/team/plan write also
|
|
59
|
+
* re-runs unrelated reads, and a refetch that resolves the active org can
|
|
60
|
+
* REMOUNT the subtree — which destroys component state a user still needs, e.g.
|
|
61
|
+
* the one-time API-key secret held in `<ApiKeysPanel>`. Mutations bust and
|
|
62
|
+
* refetch their own hook; that is enough.
|
|
63
|
+
*/
|
|
64
|
+
export function bustReadCacheAndWake(ctx) {
|
|
65
|
+
bustReadCache(ctx);
|
|
66
|
+
for (const listener of ctx.readCacheListeners)
|
|
67
|
+
listener();
|
|
68
|
+
}
|
|
34
69
|
/**
|
|
35
70
|
* Reset everything an ENTITLEMENT-MUTATING action invalidates (W6.3): the read
|
|
36
71
|
* cache AND the cached short-lived gateway context token. A plan change /
|
|
@@ -40,7 +75,12 @@ export function bustReadCache(ctx) {
|
|
|
40
75
|
* mutation that can move the subscriber's entitlement.
|
|
41
76
|
*/
|
|
42
77
|
export function bustEntitlementCaches(ctx) {
|
|
43
|
-
|
|
78
|
+
// Token first, THEN clear+wake: the wake re-runs mounted reads, and one that
|
|
79
|
+
// raced ahead of this line would ride the very entitlement token it was just
|
|
80
|
+
// invalidated for.
|
|
44
81
|
ctx.gatewayContextToken = null;
|
|
82
|
+
// Woken, not merely cleared: an entitlement move changes what surfaces the
|
|
83
|
+
// caller never touched are showing (the stale-plan-after-migrate bug).
|
|
84
|
+
bustReadCacheAndWake(ctx);
|
|
45
85
|
}
|
|
46
86
|
//# sourceMappingURL=cache.js.map
|
package/dist/cache.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,EAAE;AACF,uEAAuE;AACvE,6EAA6E;AAC7E,0EAA0E;AAC1E,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAC3E,yEAAyE;AACzE,EAAE;AACF,qEAAqE;AACrE,yEAAyE;AACzE,sCAAsC;AAItC,M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B,GAAG,IAAI,CAAC;IAC/B,2EAA2E;IAC3E,uEAAuE;IACvE,oBAAoB,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC"}
|
package/dist/catalog.d.ts
CHANGED
|
@@ -16,8 +16,34 @@ export declare function getRecurringGrantCents(plan: Pick<Plan, "grants">): numb
|
|
|
16
16
|
*/
|
|
17
17
|
export declare function classifyPlan(plan: Plan): PlanKind;
|
|
18
18
|
/** True iff the plan charges nothing at all (no fee, no meters, no prepaid, no
|
|
19
|
-
* trial). Free plans skip Stripe — `subscribe()` activates them directly.
|
|
19
|
+
* trial). Free plans skip Stripe — `subscribe()` activates them directly.
|
|
20
|
+
*
|
|
21
|
+
* A STRUCTURAL test, and deliberately not the same question as
|
|
22
|
+
* {@link isDeclaredFreePlan}. This one asks "can this ever charge?", which is
|
|
23
|
+
* what decides whether checkout is needed. Whether a plan is *the free tier*
|
|
24
|
+
* is a declaration and cannot be re-derived here. */
|
|
20
25
|
export declare function isFreePlan(plan: Plan): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* True iff the builder declared this plan the free tier with `fs.free()`.
|
|
28
|
+
*
|
|
29
|
+
* The free tier is a FLOOR, not an option among options: new accounts are
|
|
30
|
+
* auto-enrolled on it, and a cancelled paid plan falls back to it at the end
|
|
31
|
+
* of the period. Plan-card surfaces therefore hide it instead of offering it.
|
|
32
|
+
*
|
|
33
|
+
* Read the declaration; never infer it. `recurringFeeCents === 0` is also true
|
|
34
|
+
* of pay-as-you-go, and enrolling someone there hands out billable usage with
|
|
35
|
+
* no payment method attached.
|
|
36
|
+
*/
|
|
37
|
+
export declare function isDeclaredFreePlan(plan: Plan): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* The plan a new account should land on automatically, or `null` when the
|
|
40
|
+
* business offers no free tier.
|
|
41
|
+
*
|
|
42
|
+
* `null` is a normal outcome, not a failure: when every plan is paid there is
|
|
43
|
+
* no floor, so the subscriber must choose one and pay. Callers must treat
|
|
44
|
+
* `null` as "show the plan picker".
|
|
45
|
+
*/
|
|
46
|
+
export declare function selectAutoEnrollPlan(plans: readonly Plan[]): Plan | null;
|
|
21
47
|
/** True iff the plan is purely usage-based (no recurring fee, ≥1 meter). */
|
|
22
48
|
export declare function isPayAsYouGoPlan(plan: Plan): boolean;
|
|
23
49
|
/** "$X/month with $Y included" recurring-grant shape detector. */
|
|
@@ -357,7 +383,14 @@ export declare function formatPlanLimitWindow(window: PlanLimit["window"]): stri
|
|
|
357
383
|
* "600 requests / minute") — the rate-limit row display for W10. */
|
|
358
384
|
export declare function describePlanLimit(limit: PlanLimit): string;
|
|
359
385
|
/** Derived payment-health state for a subscription. */
|
|
360
|
-
|
|
386
|
+
/**
|
|
387
|
+
* `blocked` is the one that gates access: the subscriber's plan declared no
|
|
388
|
+
* dunning grace (or the grace ran out), so the edge is refusing every call.
|
|
389
|
+
* `past_due` means a payment failed but a declared grace window is still
|
|
390
|
+
* serving them — degraded, not cut off. The distinction decides whether the
|
|
391
|
+
* host app is usable at all, so it is a separate state rather than a tone.
|
|
392
|
+
*/
|
|
393
|
+
export type PaymentHealthState = "ok" | "past_due" | "incomplete" | "blocked";
|
|
361
394
|
export interface PaymentHealth {
|
|
362
395
|
state: PaymentHealthState;
|
|
363
396
|
/** A suggested call-to-action when the subscription needs attention, or null
|
|
@@ -368,7 +401,7 @@ export interface PaymentHealth {
|
|
|
368
401
|
* Derive a coarse payment-health state + a remediation CTA from the
|
|
369
402
|
* subscription's `paymentHealth` / `status`. `past_due` and `incomplete` both
|
|
370
403
|
* point the subscriber at the billing portal to fix a payment; `ok` carries no
|
|
371
|
-
* CTA.
|
|
404
|
+
* CTA. `<PaymentRequiredGate>` (mounted by the Root) renders this.
|
|
372
405
|
*/
|
|
373
406
|
export declare function paymentHealth(sub: {
|
|
374
407
|
status?: string | null;
|
package/dist/catalog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[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BAAgB,aAAa,CAAC,GAAG,EAAE;IACjC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,GAAG,aAAa,CAsDhB;AAED,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAExD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,aAAa,GAAG,WAAW,GAAG,IAAI,CAAC;CAC7C,CAAC;AAIF,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,gBAAgB,CAAC,EAClC,KAAK,EAAE,kBAAkB,GACxB,gBAAgB,EAAE,CA4BpB"}
|
package/dist/catalog.js
CHANGED
|
@@ -54,13 +54,46 @@ export function classifyPlan(plan) {
|
|
|
54
54
|
return "free";
|
|
55
55
|
}
|
|
56
56
|
/** True iff the plan charges nothing at all (no fee, no meters, no prepaid, no
|
|
57
|
-
* trial). Free plans skip Stripe — `subscribe()` activates them directly.
|
|
57
|
+
* trial). Free plans skip Stripe — `subscribe()` activates them directly.
|
|
58
|
+
*
|
|
59
|
+
* A STRUCTURAL test, and deliberately not the same question as
|
|
60
|
+
* {@link isDeclaredFreePlan}. This one asks "can this ever charge?", which is
|
|
61
|
+
* what decides whether checkout is needed. Whether a plan is *the free tier*
|
|
62
|
+
* is a declaration and cannot be re-derived here. */
|
|
58
63
|
export function isFreePlan(plan) {
|
|
59
64
|
return (plan.recurringFeeCents === 0 &&
|
|
60
65
|
plan.meters.length === 0 &&
|
|
61
66
|
getOneTimeGrantCents(plan) === 0 &&
|
|
62
67
|
plan.trialDays === 0);
|
|
63
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* True iff the builder declared this plan the free tier with `fs.free()`.
|
|
71
|
+
*
|
|
72
|
+
* The free tier is a FLOOR, not an option among options: new accounts are
|
|
73
|
+
* auto-enrolled on it, and a cancelled paid plan falls back to it at the end
|
|
74
|
+
* of the period. Plan-card surfaces therefore hide it instead of offering it.
|
|
75
|
+
*
|
|
76
|
+
* Read the declaration; never infer it. `recurringFeeCents === 0` is also true
|
|
77
|
+
* of pay-as-you-go, and enrolling someone there hands out billable usage with
|
|
78
|
+
* no payment method attached.
|
|
79
|
+
*/
|
|
80
|
+
export function isDeclaredFreePlan(plan) {
|
|
81
|
+
return plan.free === true;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The plan a new account should land on automatically, or `null` when the
|
|
85
|
+
* business offers no free tier.
|
|
86
|
+
*
|
|
87
|
+
* `null` is a normal outcome, not a failure: when every plan is paid there is
|
|
88
|
+
* no floor, so the subscriber must choose one and pay. Callers must treat
|
|
89
|
+
* `null` as "show the plan picker".
|
|
90
|
+
*/
|
|
91
|
+
export function selectAutoEnrollPlan(plans) {
|
|
92
|
+
const free = plans.filter(isDeclaredFreePlan);
|
|
93
|
+
// Uniqueness is a compile-time guarantee; >1 means data that predates it.
|
|
94
|
+
// Enrolling nobody beats silently picking one.
|
|
95
|
+
return free.length === 1 ? (free[0] ?? null) : null;
|
|
96
|
+
}
|
|
64
97
|
/** True iff the plan is purely usage-based (no recurring fee, ≥1 meter). */
|
|
65
98
|
export function isPayAsYouGoPlan(plan) {
|
|
66
99
|
return plan.recurringFeeCents === 0 && plan.meters.length > 0;
|
|
@@ -1043,19 +1076,48 @@ export function describePlanLimit(limit) {
|
|
|
1043
1076
|
* Derive a coarse payment-health state + a remediation CTA from the
|
|
1044
1077
|
* subscription's `paymentHealth` / `status`. `past_due` and `incomplete` both
|
|
1045
1078
|
* point the subscriber at the billing portal to fix a payment; `ok` carries no
|
|
1046
|
-
* CTA.
|
|
1079
|
+
* CTA. `<PaymentRequiredGate>` (mounted by the Root) renders this.
|
|
1047
1080
|
*/
|
|
1048
1081
|
export function paymentHealth(sub) {
|
|
1049
|
-
|
|
1082
|
+
// Core's wire vocabulary, verbatim: paymentHealth is CURRENT | GRACE_PERIOD
|
|
1083
|
+
// | OVERDUE (services/portal-customer/subscription-shared.ts), and `status`
|
|
1084
|
+
// falls back to the subscription lifecycle. This helper previously tested
|
|
1085
|
+
// for "past_due"/"incomplete" — values core never emits — so a subscriber in
|
|
1086
|
+
// grace or cut off read as perfectly healthy.
|
|
1087
|
+
const health = (sub.paymentHealth ?? "").toUpperCase();
|
|
1050
1088
|
const status = (sub.status ?? "").toUpperCase();
|
|
1051
|
-
|
|
1052
|
-
|
|
1089
|
+
// ACCESS IS GONE — mirror the states the EDGE actually refuses, nothing
|
|
1090
|
+
// wider. `lifecycle_block` (entitlement-compiler.ts) hard-403s on SUSPENDED,
|
|
1091
|
+
// and a CANCELLED subscription has had its gateway overlay deleted outright
|
|
1092
|
+
// (subscription-state-publisher.ts), so every call fails.
|
|
1093
|
+
//
|
|
1094
|
+
// CANCELLED is listed explicitly because it arrives with paymentHealth
|
|
1095
|
+
// CURRENT — nothing is owed, the subscription simply ended. Without this
|
|
1096
|
+
// branch it fell through to `ok` and the Root rendered a fully interactive
|
|
1097
|
+
// app whose every request 403s.
|
|
1098
|
+
if (status === "SUSPENDED" || status === "UNPAID" || status === "CANCELLED") {
|
|
1099
|
+
return {
|
|
1100
|
+
state: "blocked",
|
|
1101
|
+
cta: "Your access is paused because a payment failed. Update your payment method to restore it.",
|
|
1102
|
+
};
|
|
1103
|
+
}
|
|
1104
|
+
// Payment failed, but access CONTINUES — show the CTA, do not gate the app.
|
|
1105
|
+
//
|
|
1106
|
+
// OVERDUE belongs here, not above. Core maps it to TRACK_ONLY on purpose
|
|
1107
|
+
// ("dunning: serve-and-track; lifecycle is still ACTIVE so lifecycle_block
|
|
1108
|
+
// does not fire" — services/edge/enforcement-mode.ts) and reaches it on a
|
|
1109
|
+
// funds-withdrawn dispute that deliberately does NOT cancel. Treating it as
|
|
1110
|
+
// blocked locked a subscriber out of an application the platform was still
|
|
1111
|
+
// serving them.
|
|
1112
|
+
if (health === "OVERDUE" ||
|
|
1113
|
+
health === "GRACE_PERIOD" ||
|
|
1114
|
+
status === "PAST_DUE") {
|
|
1053
1115
|
return {
|
|
1054
1116
|
state: "past_due",
|
|
1055
|
-
cta: "Your payment
|
|
1117
|
+
cta: "Your payment failed — update your payment method to keep access.",
|
|
1056
1118
|
};
|
|
1057
1119
|
}
|
|
1058
|
-
const incomplete = health === "
|
|
1120
|
+
const incomplete = health === "INCOMPLETE" ||
|
|
1059
1121
|
status === "INCOMPLETE" ||
|
|
1060
1122
|
status === "INCOMPLETE_EXPIRED";
|
|
1061
1123
|
if (incomplete) {
|