gloomberb 0.20.17 → 0.20.18

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.
Files changed (304) hide show
  1. package/package.json +3 -1
  2. package/src/account/auth-dialog.tsx +19 -1
  3. package/src/account/billing.ts +2 -1
  4. package/src/account/heard-from-question.tsx +235 -0
  5. package/src/account/heard-from.ts +97 -0
  6. package/src/api-client/data.ts +3 -2
  7. package/src/api-client/heard-from.ts +72 -0
  8. package/src/api-client/index.ts +63 -6
  9. package/src/api-client/mna.ts +18 -0
  10. package/src/api-client/supply-chain.ts +9 -0
  11. package/src/api-client/types/billing.ts +35 -1
  12. package/src/app/global-shortcuts.ts +5 -3
  13. package/src/app/pro-welcome/keys.ts +27 -0
  14. package/src/app/pro-welcome/model.ts +158 -0
  15. package/src/app/pro-welcome/row.tsx +176 -0
  16. package/src/app/pro-welcome/use-pro-welcome.ts +156 -0
  17. package/src/app/runtime/external-profile-changes.ts +135 -0
  18. package/src/app.tsx +33 -2
  19. package/src/architecture/core-builtin-allowlist.json +1 -1
  20. package/src/architecture/floating-promise-allowlist.json +0 -1
  21. package/src/architecture/shortcut-labels-allowlist.json +1 -0
  22. package/src/cli/alert-listing.ts +98 -0
  23. package/src/cli/commands/market.ts +138 -22
  24. package/src/cli/commands/overview.ts +7 -1
  25. package/src/cli/commands/plugins.ts +3 -2
  26. package/src/cli/commands/search.ts +30 -6
  27. package/src/cli/context.ts +16 -5
  28. package/src/cli/csv-export.ts +2 -1
  29. package/src/cli/desktop-pane-shot.ts +72 -9
  30. package/src/cli/glossary.ts +64 -10
  31. package/src/cli/history-demergers.ts +117 -0
  32. package/src/cli/history-rows.ts +6 -2
  33. package/src/cli/index.ts +1 -0
  34. package/src/cli/known-gaps.ts +16 -0
  35. package/src/cli/known-us-stocks.ts +18 -0
  36. package/src/cli/listing-arg.ts +105 -15
  37. package/src/cli/pane-functions/catalog-snapshot-build.ts +83 -0
  38. package/src/cli/pane-functions/catalog-snapshot.json +866 -0
  39. package/src/cli/pane-functions/catalog-snapshot.ts +62 -0
  40. package/src/cli/pane-functions/catalog.ts +50 -16
  41. package/src/cli/pane-functions/data.ts +16 -4
  42. package/src/cli/pane-functions/dom.ts +24 -6
  43. package/src/cli/pane-functions/freshness.ts +17 -1
  44. package/src/cli/pane-functions/index.ts +100 -42
  45. package/src/cli/pane-functions/resolver.ts +8 -5
  46. package/src/cli/pane-functions/screenshot-assessment.ts +30 -7
  47. package/src/cli/pane-functions/screenshot-payload.ts +21 -0
  48. package/src/cli/pane-functions/screenshot-render.ts +3 -1
  49. package/src/cli/quote-answer.ts +32 -16
  50. package/src/cli/registry.ts +22 -2
  51. package/src/cli/result.ts +5 -4
  52. package/src/cli/series-search.ts +45 -6
  53. package/src/cli/shot-temp-dir.ts +4 -9
  54. package/src/components/chart/composite/legend.tsx +43 -18
  55. package/src/components/chart/composite/panel-surface/panel-cursor.tsx +3 -3
  56. package/src/components/chart/composite/price-axis-labels.tsx +7 -5
  57. package/src/components/chart-table/header.tsx +9 -0
  58. package/src/components/chart-table/layout.ts +11 -11
  59. package/src/components/command-bar/pane-templates/items.ts +17 -1
  60. package/src/components/command-bar/routes/root/provider-search.ts +10 -1
  61. package/src/components/command-bar/routes/root/results.ts +34 -2
  62. package/src/components/command-bar/routes/root/runtime.ts +8 -1
  63. package/src/components/command-bar/routes/ticker-search/route.ts +5 -0
  64. package/src/components/command-bar/workflow/alert.ts +19 -8
  65. package/src/components/data-table/view.tsx +15 -2
  66. package/src/components/form-modal/content.tsx +9 -4
  67. package/src/components/index.ts +1 -1
  68. package/src/components/layout/header.tsx +9 -5
  69. package/src/components/layout/pane/capture-status.ts +6 -0
  70. package/src/components/layout/pane/footer/index.tsx +2 -0
  71. package/src/components/layout/pane/footer/model.ts +113 -15
  72. package/src/components/layout/pane/header.tsx +16 -2
  73. package/src/components/market-board/index.tsx +4 -2
  74. package/src/components/onboarding/onboarding-frame.tsx +6 -2
  75. package/src/components/onboarding/onboarding-keyboard.ts +7 -1
  76. package/src/components/onboarding/onboarding-wizard.tsx +3 -1
  77. package/src/components/onboarding/portfolio-step/positions-panel.tsx +24 -15
  78. package/src/components/onboarding/setup-cards.ts +36 -0
  79. package/src/components/onboarding/use-onboarding-progress.ts +22 -1
  80. package/src/components/onboarding/wizard-account.ts +6 -1
  81. package/src/components/onboarding/wizard-model.ts +32 -6
  82. package/src/components/onboarding/wizard-positions.ts +1 -1
  83. package/src/components/sign-in-gate.tsx +3 -1
  84. package/src/components/toggle-list.tsx +6 -8
  85. package/src/components/ui/confirm-dialog.tsx +47 -7
  86. package/src/components/ui/data-table/types.ts +8 -0
  87. package/src/components/ui/display.tsx +17 -2
  88. package/src/components/ui/index.ts +1 -1
  89. package/src/components/ui/stat-grid.tsx +4 -0
  90. package/src/components/ui/status.tsx +13 -1
  91. package/src/components/ui/table-layout.ts +2 -1
  92. package/src/components/use-pane-notice-footer.tsx +16 -3
  93. package/src/data/config/store/index.ts +31 -0
  94. package/src/data/config/store/node.ts +61 -11
  95. package/src/data/config/store/normalize.ts +4 -6
  96. package/src/data/config/store/shared-file.ts +309 -0
  97. package/src/data/profile-merge.ts +299 -0
  98. package/src/data/sqlite/checkpointer.ts +11 -1
  99. package/src/data/sqlite/database.ts +1 -1
  100. package/src/data/ticker-repository.ts +134 -10
  101. package/src/data/ticker-store.ts +67 -0
  102. package/src/data/ticker-writes.ts +5 -0
  103. package/src/i18n/es.ts +27 -0
  104. package/src/i18n/ja.ts +27 -0
  105. package/src/i18n/ko.ts +27 -0
  106. package/src/i18n/zh-cn.ts +27 -0
  107. package/src/i18n/zh-tw.ts +27 -0
  108. package/src/layout-marketplace/gallery-desktop.tsx +2 -2
  109. package/src/market-data/ah-pair.ts +103 -0
  110. package/src/market-data/depositary-pair.ts +6 -2
  111. package/src/market-data/hooks.tsx +33 -2
  112. package/src/market-data/market/change-basis.ts +2 -1
  113. package/src/market-data/market/header-market.ts +11 -0
  114. package/src/market-data/split-terms.ts +28 -0
  115. package/src/plugins/builtin/account-management/footer.ts +1 -1
  116. package/src/plugins/builtin/account-management/keyboard.ts +4 -0
  117. package/src/plugins/builtin/account-management/model.ts +1 -0
  118. package/src/plugins/builtin/account-management/pane.tsx +75 -7
  119. package/src/plugins/builtin/account-management/payment-recovery-row.tsx +12 -5
  120. package/src/plugins/builtin/account-management/pro-cancel.tsx +197 -0
  121. package/src/plugins/builtin/account-management/trial-cancel.ts +1 -1
  122. package/src/plugins/builtin/alerts/cli-move.ts +2 -2
  123. package/src/plugins/builtin/alerts/cli.ts +36 -30
  124. package/src/plugins/builtin/alerts/constants.ts +10 -0
  125. package/src/plugins/builtin/alerts/earnings-listing.ts +20 -0
  126. package/src/plugins/builtin/alerts/format.ts +24 -8
  127. package/src/plugins/builtin/alerts/index.tsx +38 -9
  128. package/src/plugins/builtin/alerts/move-checks.ts +7 -0
  129. package/src/plugins/builtin/alerts/pane.tsx +1 -1
  130. package/src/plugins/builtin/alerts/quotes.ts +26 -2
  131. package/src/plugins/builtin/alerts/scheduled.ts +6 -1
  132. package/src/plugins/builtin/alerts/types.ts +7 -0
  133. package/src/plugins/builtin/analytics/manual-value.ts +61 -0
  134. package/src/plugins/builtin/analytics/risk-book.ts +7 -7
  135. package/src/plugins/builtin/analytics/risk-client.ts +26 -13
  136. package/src/plugins/builtin/analytics/risk-headless.ts +13 -8
  137. package/src/plugins/builtin/analytics/risk-model.ts +92 -4
  138. package/src/plugins/builtin/analytics/risk-pane.tsx +85 -38
  139. package/src/plugins/builtin/awards/pane.tsx +1 -1
  140. package/src/plugins/builtin/broker-trading/orders.tsx +2 -2
  141. package/src/plugins/builtin/central-bank-rates/model.ts +8 -2
  142. package/src/plugins/builtin/central-bank-rates/pane.tsx +5 -3
  143. package/src/plugins/builtin/chart-composer/cli-options.ts +4 -2
  144. package/src/plugins/builtin/chart-composer/data-catalog-pane.tsx +2 -6
  145. package/src/plugins/builtin/chart-composer/pane.tsx +5 -2
  146. package/src/plugins/builtin/cloud/auth-actions.tsx +11 -6
  147. package/src/plugins/builtin/cloud/company-picker.tsx +5 -3
  148. package/src/plugins/builtin/cloud/upgrade-command.ts +1 -1
  149. package/src/plugins/builtin/company-kpis/headless.ts +9 -4
  150. package/src/plugins/builtin/company-kpis/latest.ts +45 -0
  151. package/src/plugins/builtin/company-kpis/model.ts +38 -8
  152. package/src/plugins/builtin/company-kpis/pane.tsx +22 -8
  153. package/src/plugins/builtin/composite/alt-data.ts +20 -0
  154. package/src/plugins/builtin/composite/application.ts +14 -0
  155. package/src/plugins/builtin/composite/broker.ts +12 -0
  156. package/src/plugins/builtin/composite/credit.ts +33 -0
  157. package/src/plugins/builtin/composite/crypto.ts +10 -0
  158. package/src/plugins/builtin/composite/earnings.ts +12 -0
  159. package/src/plugins/builtin/composite/filings.ts +13 -0
  160. package/src/plugins/builtin/composite/futures-commodities.ts +23 -0
  161. package/src/plugins/builtin/composite/global-markets.ts +12 -0
  162. package/src/plugins/builtin/composite/options-volatility.ts +23 -0
  163. package/src/plugins/builtin/composite/ownership.ts +23 -0
  164. package/src/plugins/builtin/composite/portfolio.ts +10 -0
  165. package/src/plugins/builtin/composite/quant.ts +15 -0
  166. package/src/plugins/builtin/composite/rates-macro.ts +30 -0
  167. package/src/plugins/builtin/composite/screeners.ts +11 -0
  168. package/src/plugins/builtin/composite/shared.ts +11 -0
  169. package/src/plugins/builtin/composite/ticker-core.ts +36 -0
  170. package/src/plugins/builtin/congress-trades/headless.ts +31 -3
  171. package/src/plugins/builtin/correlation/index.tsx +13 -17
  172. package/src/plugins/builtin/correlation/matrix/model.ts +18 -0
  173. package/src/plugins/builtin/dividend-yield/client.ts +57 -16
  174. package/src/plugins/builtin/dividend-yield/headless.ts +17 -11
  175. package/src/plugins/builtin/dividend-yield/model.ts +4 -3
  176. package/src/plugins/builtin/dividend-yield/pane.tsx +22 -18
  177. package/src/plugins/builtin/dividend-yield/ranking.ts +1 -1
  178. package/src/plugins/builtin/dividend-yield/types.ts +4 -0
  179. package/src/plugins/builtin/dividend-yield/view.ts +23 -12
  180. package/src/plugins/builtin/earnings/fiscal-quarter.ts +39 -0
  181. package/src/plugins/builtin/earnings/headless.ts +7 -4
  182. package/src/plugins/builtin/earnings/history-model.ts +6 -4
  183. package/src/plugins/builtin/earnings/history-table.ts +4 -3
  184. package/src/plugins/builtin/earnings-calls/pane.tsx +8 -2
  185. package/src/plugins/builtin/econ/calendar-model.ts +16 -0
  186. package/src/plugins/builtin/econ/index.tsx +3 -0
  187. package/src/plugins/builtin/equity-screener/headless.ts +4 -1
  188. package/src/plugins/builtin/equity-screener/model.ts +7 -6
  189. package/src/plugins/builtin/estimate-revisions/headless.ts +1 -1
  190. package/src/plugins/builtin/exposure/model.ts +10 -0
  191. package/src/plugins/builtin/exposure/pane.tsx +10 -3
  192. package/src/plugins/builtin/fx-matrix/amount.ts +15 -1
  193. package/src/plugins/builtin/fx-matrix/headless.ts +12 -6
  194. package/src/plugins/builtin/fx-matrix/index.tsx +23 -5
  195. package/src/plugins/builtin/fx-matrix/settings.ts +9 -4
  196. package/src/plugins/builtin/kelly-sizer/pane.tsx +9 -4
  197. package/src/plugins/builtin/market-valuation/pane.tsx +22 -10
  198. package/src/plugins/builtin/mna/detail.tsx +67 -6
  199. package/src/plugins/builtin/mna/headless.ts +128 -13
  200. package/src/plugins/builtin/mna/model.ts +219 -16
  201. package/src/plugins/builtin/mna/pane.tsx +34 -6
  202. package/src/plugins/builtin/money-markets/model.ts +14 -5
  203. package/src/plugins/builtin/money-markets/pane.tsx +4 -3
  204. package/src/plugins/builtin/news/wire/news/footer.ts +3 -8
  205. package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +22 -6
  206. package/src/plugins/builtin/options-scenario/csp-screen.ts +39 -12
  207. package/src/plugins/builtin/options-scenario/strategy-screen.ts +7 -5
  208. package/src/plugins/builtin/pe-band/client.ts +13 -1
  209. package/src/plugins/builtin/pe-band/headless.ts +2 -2
  210. package/src/plugins/builtin/pe-band/model.ts +63 -10
  211. package/src/plugins/builtin/pe-band/pane.tsx +5 -5
  212. package/src/plugins/builtin/portfolio-list/allocation-rows.ts +26 -7
  213. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +66 -13
  214. package/src/plugins/builtin/portfolio-list/cli/render.ts +76 -33
  215. package/src/plugins/builtin/portfolio-list/headless.ts +69 -22
  216. package/src/plugins/builtin/portfolio-list/pane/data.ts +3 -3
  217. package/src/plugins/builtin/portfolio-list/pane/index.tsx +29 -14
  218. package/src/plugins/builtin/portfolio-list/summary/index.tsx +2 -2
  219. package/src/plugins/builtin/relative-rotation/pane.tsx +2 -3
  220. package/src/plugins/builtin/research/corporate-actions-pane.tsx +5 -1
  221. package/src/plugins/builtin/research/event-model.ts +31 -13
  222. package/src/plugins/builtin/research/headless.ts +8 -1
  223. package/src/plugins/builtin/research/relative-valuation-pane.tsx +19 -17
  224. package/src/plugins/builtin/sectors/index.tsx +6 -9
  225. package/src/plugins/builtin/shared/cloud-upgrade.ts +1 -1
  226. package/src/plugins/builtin/shared/earnings-report.ts +19 -4
  227. package/src/plugins/builtin/shared/report-freshness.ts +2 -3
  228. package/src/plugins/builtin/supply-chain/client.ts +34 -9
  229. package/src/plugins/builtin/supply-chain/evidence.ts +3 -2
  230. package/src/plugins/builtin/supply-chain/flow.tsx +4 -3
  231. package/src/plugins/builtin/supply-chain/graph-model.ts +14 -7
  232. package/src/plugins/builtin/supply-chain/graph-pane.tsx +3 -1
  233. package/src/plugins/builtin/supply-chain/graph.tsx +6 -3
  234. package/src/plugins/builtin/supply-chain/headless.ts +19 -4
  235. package/src/plugins/builtin/supply-chain/model.ts +50 -6
  236. package/src/plugins/builtin/supply-chain/pane.tsx +76 -16
  237. package/src/plugins/builtin/ticker-detail/adr-pair/ah.ts +62 -0
  238. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +119 -20
  239. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +51 -1
  240. package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +25 -14
  241. package/src/plugins/builtin/ticker-detail/overview/model.ts +17 -1
  242. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -0
  243. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +9 -2
  244. package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +9 -2
  245. package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +5 -2
  246. package/src/plugins/builtin/volatility/model.ts +17 -0
  247. package/src/plugins/builtin/volatility/pane.tsx +13 -4
  248. package/src/plugins/builtin/world-indices/index.tsx +2 -0
  249. package/src/plugins/builtin/world-indices/table.tsx +15 -0
  250. package/src/plugins/builtin/world-venue-map/evidence.ts +3 -2
  251. package/src/plugins/builtin/world-venue-map/headless.ts +28 -16
  252. package/src/plugins/builtin/world-venue-map/index.ts +19 -6
  253. package/src/plugins/builtin/world-venue-map/layered-pane.tsx +9 -5
  254. package/src/plugins/builtin/world-venue-map/layers.ts +33 -11
  255. package/src/plugins/builtin/world-venue-map/map.tsx +12 -0
  256. package/src/plugins/builtin/world-venue-map/pane.tsx +35 -6
  257. package/src/plugins/builtin/world-venue-map/place.ts +119 -0
  258. package/src/plugins/catalog-data.ts +20 -0
  259. package/src/plugins/catalog-lazy.ts +51 -0
  260. package/src/plugins/catalog-ui.ts +16 -18
  261. package/src/plugins/host-smoke.ts +5 -2
  262. package/src/portfolio/allocation.ts +79 -19
  263. package/src/portfolio/cash-balances.ts +76 -0
  264. package/src/portfolio/mutations.ts +43 -8
  265. package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
  266. package/src/renderers/desktop/window-layouts.ts +14 -0
  267. package/src/renderers/dom/data-table/row.tsx +2 -0
  268. package/src/renderers/dom/host/tabs.tsx +57 -8
  269. package/src/renderers/dom/styles.css +13 -5
  270. package/src/renderers/electrobun/bun/desktop/backend-requests.ts +4 -0
  271. package/src/renderers/electrobun/bun/desktop/backend.ts +22 -1
  272. package/src/renderers/electrobun/bun/window/native-min-size.ts +6 -1
  273. package/src/renderers/electrobun/shared/protocol.ts +4 -0
  274. package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +50 -12
  275. package/src/renderers/electrobun/view/remote/ticker-repository.ts +10 -0
  276. package/src/series/standalone-catalog.ts +5 -4
  277. package/src/series/standalone.ts +13 -7
  278. package/src/sources/gloomberb-cloud/index.ts +14 -3
  279. package/src/sources/gloomberb-cloud/perpetuals.ts +60 -3
  280. package/src/sources/provider-router/financials.ts +20 -13
  281. package/src/sources/provider-router/index.ts +4 -0
  282. package/src/sources/provider-router/search.ts +1 -0
  283. package/src/sync/collections-contributor.ts +3 -1
  284. package/src/sync/config-merge.ts +10 -1
  285. package/src/sync/sanitize.ts +26 -2
  286. package/src/tickers/company-name-listing.ts +16 -2
  287. package/src/tickers/listing-fate.ts +12 -8
  288. package/src/tickers/renamed-listings.ts +43 -10
  289. package/src/tickers/search/home-listing.ts +28 -0
  290. package/src/tickers/search/index.ts +19 -7
  291. package/src/tickers/terminal-codes.ts +11 -1
  292. package/src/time-series/resolve.ts +3 -1
  293. package/src/time-series/spec.ts +2 -2
  294. package/src/time-series/types.ts +1 -1
  295. package/src/types/data-provider.ts +11 -0
  296. package/src/types/financials.ts +39 -3
  297. package/src/types/ticker.ts +10 -2
  298. package/src/utils/cli-output.ts +1 -1
  299. package/src/utils/declared-dividends.ts +13 -1
  300. package/src/utils/dividend-cash.ts +5 -1
  301. package/src/utils/forward-dividend.ts +4 -3
  302. package/src/utils/remove-folder.ts +37 -0
  303. package/src/utils/trailing-dividend.ts +1 -1
  304. package/src/plugins/builtin/composite-plugins.ts +0 -285
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gloomberb",
3
- "version": "0.20.17",
3
+ "version": "0.20.18",
4
4
  "packageManager": "bun@1.3.14",
5
5
  "description": "Market research and portfolio tracker for the terminal",
6
6
  "module": "src/public/index.ts",
@@ -68,6 +68,7 @@
68
68
  "docs:snapshot": "bun run scripts/update-docs-snapshot.ts",
69
69
  "listings:snapshot": "bun run scripts/update-major-listings.ts",
70
70
  "japanese-names:snapshot": "bun run scripts/update-japanese-names.ts",
71
+ "catalog:snapshot": "bun run scripts/update-cli-catalog-snapshot.ts",
71
72
  "plugins:manifest": "bun run scripts/generate-plugin-manifest.ts",
72
73
  "plugins:manifest:check": "bun run scripts/generate-plugin-manifest.ts --check",
73
74
  "plugins:registry:check": "bun run scripts/check-registry-plugins.ts",
@@ -104,6 +105,7 @@
104
105
  "check:call-player": "bun run scripts/pane-chrome/call-player.ts",
105
106
  "check:chart-axis-zoom": "bun run scripts/pane-chrome/chart-axis-zoom.ts",
106
107
  "check:chart-panel-layout": "bun run scripts/pane-chrome/chart-panel-layout.ts",
108
+ "check:title-tabs-webkit": "bun run scripts/pane-chrome/title-tab-webkit.ts",
107
109
  "kit:page": "bun run scripts/pane-chrome/kit-page.ts",
108
110
  "audit:ui:compare": "bun run scripts/pane-chrome/ui-audit-compare.ts",
109
111
  "benchmark:pane-drag:compare": "bun run scripts/pane-chrome/frame-budget.ts",
@@ -14,6 +14,7 @@ import { clickOutsideWhileClean } from "../ui/dialog-stack";
14
14
  import { AuthForm, authFormTitle } from "./auth-form";
15
15
  import type { AccountMode } from "./auth-model";
16
16
  import { CloudVerificationPanel } from "./verification-panel";
17
+ import { markHeardFromDue } from "./heard-from";
17
18
 
18
19
  function AuthDialog({
19
20
  initialMode,
@@ -21,10 +22,13 @@ function AuthDialog({
21
22
  resolve,
22
23
  dismiss,
23
24
  onCleanChange,
25
+ onAccount,
24
26
  }: PromptContext<AuthUser | undefined> & {
25
27
  initialMode: AccountMode;
26
28
  reason?: string;
27
29
  onCleanChange: (clean: boolean) => void;
30
+ /** The account the form signed in or up, before its email is confirmed too. */
31
+ onAccount: (user: AuthUser) => void;
28
32
  }) {
29
33
  useAppLanguage();
30
34
  const [mode, setMode] = useState<AccountMode>(initialMode);
@@ -44,7 +48,11 @@ function AuthDialog({
44
48
  <AuthForm
45
49
  initialMode={initialMode}
46
50
  onModeChange={setMode}
47
- onSignedIn={(user) => user.emailVerified ? resolve(user) : setVerifyingUser(user)}
51
+ onSignedIn={(user) => {
52
+ onAccount(user);
53
+ if (user.emailVerified) resolve(user);
54
+ else setVerifyingUser(user);
55
+ }}
48
56
  onEscape={dismiss}
49
57
  onTypedChange={setTyped}
50
58
  />
@@ -57,6 +65,8 @@ export interface AuthDialogRequest {
57
65
  /** What asked for it, under the title: the delayed mark says what is delayed and by how much. */
58
66
  reason?: string;
59
67
  onSignedIn?: (user: AuthUser) => void;
68
+ /** The sign-in goes on to a checkout: nothing else is asked before it. */
69
+ checkout?: boolean;
60
70
  }
61
71
 
62
72
  const authDialogListeners = new Set<(request: AuthDialogRequest) => void>();
@@ -93,6 +103,8 @@ export function AuthDialogHost() {
93
103
  openRef.current = true;
94
104
  openAuthDialogs += 1;
95
105
  const { closeOnClickOutside, setClean } = clickOutsideWhileClean();
106
+ // Signed up, even when the dialog then closes before the email is confirmed.
107
+ let account: AuthUser | null = null;
96
108
  void dialog
97
109
  .prompt<AuthUser | undefined>({
98
110
  closeOnClickOutside,
@@ -102,11 +114,17 @@ export function AuthDialogHost() {
102
114
  initialMode={request.mode ?? "login"}
103
115
  reason={request.reason}
104
116
  onCleanChange={setClean}
117
+ onAccount={(user) => {
118
+ account = user;
119
+ }}
105
120
  />
106
121
  ),
107
122
  })
108
123
  .then((user) => {
109
124
  if (user) request.onSignedIn?.(user);
125
+ // Where it heard about Gloom, once the dialog and what follows it have closed.
126
+ const signedIn = user ?? account;
127
+ if (signedIn && !request.checkout) markHeardFromDue(signedIn.id);
110
128
  })
111
129
  .finally(() => {
112
130
  openRef.current = false;
@@ -4,7 +4,8 @@ import { t, tf } from "../i18n";
4
4
 
5
5
  const DEFAULT_TRIAL_DAYS = 7;
6
6
 
7
- function formatUsdCents(cents: number): string {
7
+ /** Whole dollars when exact, else cents: $70, $56.50. */
8
+ export function formatUsdCents(cents: number): string {
8
9
  const dollars = cents / 100;
9
10
  return Number.isInteger(dollars) ? `$${dollars}` : `$${dollars.toFixed(2)}`;
10
11
  }
@@ -0,0 +1,235 @@
1
+ import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from "react";
2
+ import { apiClient } from "../api-client";
3
+ import { HEARD_FROM_ANSWERS, type HeardFromAnswer } from "../api-client/heard-from";
4
+ import { useKeybindings } from "../app/keybindings";
5
+ import {
6
+ OnboardingActions,
7
+ OnboardingButton,
8
+ OnboardingChoiceList,
9
+ OnboardingModal,
10
+ OnboardingTitle,
11
+ } from "../components/onboarding/onboarding-frame";
12
+ import { keyReachesPastOnboardingModal } from "../components/onboarding/onboarding-keyboard";
13
+ import { setupCardOpen, subscribeSetupCards } from "../components/onboarding/setup-cards";
14
+ import { TextField } from "../components/ui/fields";
15
+ import { t } from "../i18n";
16
+ import { useAppLanguage } from "../i18n/react";
17
+ import { useShortcut } from "../react/input";
18
+ import { Box, useUiCapabilities, type InputRenderable } from "../ui";
19
+ import { useDialogState } from "../ui/dialog";
20
+ import { useOptionalAppSelector } from "../state/app/context";
21
+ import { isPlainKey } from "../utils/keyboard";
22
+ import {
23
+ type HeardFromChoice,
24
+ heardFromDueAccount,
25
+ runHeardFromQuestion,
26
+ subscribeHeardFromDue,
27
+ takeHeardFromDue,
28
+ } from "./heard-from";
29
+
30
+ /** The services keep their own names in every language. */
31
+ const LABELS: Record<HeardFromAnswer, string> = {
32
+ search: "Search",
33
+ youtube: "YouTube",
34
+ tiktok: "TikTok",
35
+ instagram: "Instagram",
36
+ x: "X",
37
+ reddit: "Reddit",
38
+ ai_assistant: "AI assistant",
39
+ friend: "Friend or colleague",
40
+ article: "Article or newsletter",
41
+ other: "Other",
42
+ };
43
+ const UNTRANSLATED: ReadonlySet<HeardFromAnswer> = new Set(["youtube", "tiktok", "instagram", "x", "reddit"]);
44
+ const OTHER_INDEX = HEARD_FROM_ANSWERS.indexOf("other");
45
+ const NOTE_MAX_LENGTH = 120;
46
+ const CARD_WIDTH = 56;
47
+
48
+ function choiceLabel(answer: HeardFromAnswer): string {
49
+ return UNTRANSLATED.has(answer) ? LABELS[answer] : t(LABELS[answer]);
50
+ }
51
+
52
+ /**
53
+ * "Where did you hear about Gloom?" on the card the app's other one-question
54
+ * steps use. One row is one answer: a click, or Enter on the highlighted
55
+ * row. Other opens a short note under the list, sent with Enter (empty is
56
+ * fine). Esc, or Skip, skips; from the note, Esc (Back) goes back to the
57
+ * list. The card holds the keyboard while it is up, as setup does.
58
+ */
59
+ function HeardFromCard({ onShown, onDone }: {
60
+ onShown: () => void;
61
+ onDone: (choice: HeardFromChoice) => void;
62
+ }) {
63
+ useAppLanguage();
64
+ const desktop = useUiCapabilities().nativePaneChrome === true;
65
+ const keybindings = useKeybindings();
66
+ const [cursor, setCursor] = useState(0);
67
+ const [noteOpen, setNoteOpen] = useState(false);
68
+ const [note, setNote] = useState("");
69
+ const noteRef = useRef<InputRenderable>(null);
70
+ // Enter can arrive with the typing, ahead of the render that holds it.
71
+ const noteValue = useRef("");
72
+ const cursorRef = useRef(0);
73
+ const closed = useRef(false);
74
+
75
+ const moveCursor = useCallback((next: number) => {
76
+ cursorRef.current = next;
77
+ setCursor(next);
78
+ }, []);
79
+
80
+ const done = useCallback((choice: HeardFromChoice) => {
81
+ if (closed.current) return;
82
+ closed.current = true;
83
+ onDone(choice);
84
+ }, [onDone]);
85
+
86
+ const choose = useCallback((index: number) => {
87
+ const answer = HEARD_FROM_ANSWERS[index];
88
+ if (!answer) return;
89
+ moveCursor(index);
90
+ if (answer === "other") {
91
+ setNoteOpen(true);
92
+ return;
93
+ }
94
+ done({ answer });
95
+ }, [done, moveCursor]);
96
+
97
+ const sendNote = useCallback(() => {
98
+ const text = noteValue.current.trim();
99
+ done(text ? { answer: "other", note: text } : { answer: "other" });
100
+ }, [done]);
101
+
102
+ const shownRef = useRef(onShown);
103
+ useEffect(() => shownRef.current(), []);
104
+
105
+ useEffect(() => {
106
+ if (!noteOpen) return;
107
+ const timer = setTimeout(() => noteRef.current?.focus?.(), 10);
108
+ return () => clearTimeout(timer);
109
+ }, [noteOpen]);
110
+
111
+ useShortcut((event) => {
112
+ const handled = ((): boolean => {
113
+ if (noteOpen) {
114
+ if (isPlainKey(event, "enter", "return")) { sendNote(); return true; }
115
+ if (isPlainKey(event, "escape")) { setNoteOpen(false); return true; }
116
+ return false;
117
+ }
118
+ const last = HEARD_FROM_ANSWERS.length - 1;
119
+ if (isPlainKey(event, "down")) { moveCursor(Math.min(last, cursorRef.current + 1)); return true; }
120
+ if (isPlainKey(event, "up")) { moveCursor(Math.max(0, cursorRef.current - 1)); return true; }
121
+ if (isPlainKey(event, "enter", "return")) { choose(cursorRef.current); return true; }
122
+ if (isPlainKey(event, "escape")) { done(null); return true; }
123
+ return false;
124
+ })();
125
+ if (handled) {
126
+ event.preventDefault();
127
+ event.stopPropagation();
128
+ return;
129
+ }
130
+ if (keyReachesPastOnboardingModal(event, keybindings)) return;
131
+ event.stopPropagation();
132
+ }, { phase: "before", allowEditable: true, scope: "heard-from" });
133
+
134
+ const items = HEARD_FROM_ANSWERS.map((answer) => ({ id: answer, label: choiceLabel(answer) }));
135
+ return (
136
+ <OnboardingModal width={CARD_WIDTH} height={18 + (noteOpen ? 2 : 0)} desktopWidth="min(440px, 100%)">
137
+ <OnboardingTitle standalone title={t("Where did you hear about Gloom?")} />
138
+ <Box flexDirection="column" style={desktop ? { marginTop: 14 } : undefined} paddingTop={desktop ? undefined : 1}>
139
+ <OnboardingChoiceList
140
+ items={items}
141
+ selectedIndex={noteOpen ? OTHER_INDEX : cursor}
142
+ onSelect={moveCursor}
143
+ onActivate={choose}
144
+ />
145
+ </Box>
146
+ {noteOpen ? (
147
+ <Box flexDirection="column" style={desktop ? { marginTop: 10 } : undefined} paddingTop={desktop ? undefined : 1}>
148
+ <TextField
149
+ inputRef={noteRef}
150
+ value={note}
151
+ placeholder={t("Where?")}
152
+ maxLength={NOTE_MAX_LENGTH}
153
+ focused
154
+ width={desktop ? undefined : CARD_WIDTH - 6}
155
+ onChange={(value) => {
156
+ noteValue.current = value;
157
+ setNote(value);
158
+ }}
159
+ />
160
+ </Box>
161
+ ) : null}
162
+ {desktop ? null : <Box height={1} />}
163
+ <OnboardingActions>
164
+ {/* From the note, Esc goes back to the list; from the list, it skips. */}
165
+ <OnboardingButton
166
+ label={noteOpen ? "Back" : "Skip"}
167
+ variant="ghost"
168
+ shortcut="Esc"
169
+ onPress={() => (noteOpen ? setNoteOpen(false) : done(null))}
170
+ />
171
+ <OnboardingButton
172
+ label={noteOpen ? "Send" : "Continue"}
173
+ variant="primary"
174
+ shortcut="Enter"
175
+ onPress={() => (noteOpen ? sendNote() : choose(cursorRef.current))}
176
+ />
177
+ </OnboardingActions>
178
+ </OnboardingModal>
179
+ );
180
+ }
181
+
182
+ function currentAccountId(): string | null {
183
+ return apiClient.getCurrentUser()?.id ?? null;
184
+ }
185
+
186
+ /**
187
+ * Asks the account marked due (account/heard-from.ts) once nothing else is
188
+ * up: no dialog, no setup card ("Which companies do you follow?" goes
189
+ * first) and no open command bar, whose typing the card would take. Mounted
190
+ * by the app only while setup and the sign-in gate are closed, so the first
191
+ * run never shows it.
192
+ */
193
+ export function HeardFromQuestionHost() {
194
+ const dialogOpen = useDialogState((state) => state.isOpen);
195
+ const commandBarOpen = useOptionalAppSelector((state) => state.commandBarOpen, false);
196
+ const cardOpen = useSyncExternalStore(subscribeSetupCards, setupCardOpen, setupCardOpen);
197
+ const due = useSyncExternalStore(subscribeHeardFromDue, heardFromDueAccount, heardFromDueAccount);
198
+ const account = useSyncExternalStore(
199
+ (onChange) => apiClient.subscribeCurrentUser(onChange),
200
+ currentAccountId,
201
+ currentAccountId,
202
+ );
203
+ const [asking, setAsking] = useState<{ shown: () => void; resolve: (choice: HeardFromChoice) => void } | null>(null);
204
+ // Drawn once nothing else is up, and kept up from then on (it is a setup card itself).
205
+ const [drawn, setDrawn] = useState(false);
206
+ const busy = useRef(false);
207
+
208
+ useEffect(() => {
209
+ // Signed out, or another account since: the mark waits for its own account.
210
+ if (!due || due !== account || dialogOpen || cardOpen || commandBarOpen || busy.current) return;
211
+ if (!takeHeardFromDue(due)) return;
212
+ busy.current = true;
213
+ const finished = () => {
214
+ busy.current = false;
215
+ setAsking(null);
216
+ setDrawn(false);
217
+ };
218
+ runHeardFromQuestion({
219
+ getState: () => apiClient.getHeardFrom(),
220
+ reportShown: () => apiClient.reportHeardFromShown(),
221
+ answer: (answer, note) => apiClient.answerHeardFrom(answer, note),
222
+ skip: () => apiClient.skipHeardFrom(),
223
+ ask: (shown) => new Promise<HeardFromChoice>((resolve) => setAsking({ shown, resolve })),
224
+ }).then(finished, finished);
225
+ }, [account, cardOpen, commandBarOpen, dialogOpen, due]);
226
+
227
+ // The read takes a moment: a card, dialog or command bar that opened
228
+ // meanwhile (the companies to follow, after a sign-up) goes first.
229
+ useEffect(() => {
230
+ if (asking && !drawn && !dialogOpen && !cardOpen && !commandBarOpen) setDrawn(true);
231
+ }, [asking, cardOpen, commandBarOpen, dialogOpen, drawn]);
232
+
233
+ if (!asking || !drawn) return null;
234
+ return <HeardFromCard onShown={asking.shown} onDone={asking.resolve} />;
235
+ }
@@ -0,0 +1,97 @@
1
+ /**
2
+ * "Where did you hear about Gloom?", asked once in the app right after an
3
+ * account signs up (or in) on the first run's account step or in the sign-in
4
+ * dialog. The account is marked due there; the question itself waits until
5
+ * nothing else is on screen: setup has closed (so nothing is added inside the
6
+ * first run) and no dialog is open. A sign-in on its way to a checkout never
7
+ * marks it, so the question is never shown before or over one.
8
+ *
9
+ * The service decides whether the account is asked and settles it for good on
10
+ * the first answer or skip. Every call here fails silently: an error, or a
11
+ * service too old to know the question, just means it is not asked.
12
+ */
13
+ import type { HeardFromAnswer, HeardFromState } from "../api-client/heard-from";
14
+ import { logFailure } from "../utils/log-failure";
15
+
16
+ let dueAccount: string | null = null;
17
+ const listeners = new Set<() => void>();
18
+
19
+ function changed() {
20
+ for (const listener of listeners) listener();
21
+ }
22
+
23
+ /** An account just signed up or in here: ask it once nothing else is on screen. */
24
+ export function markHeardFromDue(accountId: string): void {
25
+ if (!accountId || dueAccount === accountId) return;
26
+ dueAccount = accountId;
27
+ changed();
28
+ }
29
+
30
+ /** The account the question is due for, if any. */
31
+ export function heardFromDueAccount(): string | null {
32
+ return dueAccount;
33
+ }
34
+
35
+ /** Takes the due mark: the question is asked at most once per sign-in. */
36
+ export function takeHeardFromDue(accountId: string): boolean {
37
+ if (dueAccount !== accountId) return false;
38
+ dueAccount = null;
39
+ changed();
40
+ return true;
41
+ }
42
+
43
+ export function subscribeHeardFromDue(listener: () => void): () => void {
44
+ listeners.add(listener);
45
+ return () => {
46
+ listeners.delete(listener);
47
+ };
48
+ }
49
+
50
+ /** What the person picked: an answer (Other with its note), or null for Skip. */
51
+ export type HeardFromChoice = { answer: HeardFromAnswer; note?: string } | null;
52
+
53
+ export interface HeardFromQuestionDeps {
54
+ getState(): Promise<HeardFromState>;
55
+ reportShown(): Promise<void>;
56
+ answer(answer: HeardFromAnswer, note?: string): Promise<void>;
57
+ skip(): Promise<void>;
58
+ /** Shows the question and resolves with the choice; `shown` is called once it is on screen. */
59
+ ask(shown: () => void): Promise<HeardFromChoice>;
60
+ }
61
+
62
+ export type HeardFromOutcome = "not-asked" | "answered" | "skipped";
63
+
64
+ /**
65
+ * Asks when the service says to, and keeps the answer. Never throws: a
66
+ * failed read, an older service (its 404) or invalid data ask nothing, and a
67
+ * failed write is only logged, as the question has already closed.
68
+ */
69
+ export async function runHeardFromQuestion(deps: HeardFromQuestionDeps): Promise<HeardFromOutcome> {
70
+ let state: HeardFromState;
71
+ try {
72
+ state = await deps.getState();
73
+ } catch (error) {
74
+ logFailure("heard-from", "Reading whether to ask failed")(error);
75
+ return "not-asked";
76
+ }
77
+ if (!state.ask) return "not-asked";
78
+ let reported = false;
79
+ const shown = () => {
80
+ if (reported) return;
81
+ reported = true;
82
+ deps.reportShown().catch(logFailure("heard-from", "Reporting the question shown failed"));
83
+ };
84
+ let choice: HeardFromChoice;
85
+ try {
86
+ choice = await deps.ask(shown);
87
+ } catch (error) {
88
+ logFailure("heard-from", "Showing the question failed")(error);
89
+ return "not-asked";
90
+ }
91
+ if (!choice) {
92
+ deps.skip().catch(logFailure("heard-from", "Saving the skip failed"));
93
+ return "skipped";
94
+ }
95
+ deps.answer(choice.answer, choice.note).catch(logFailure("heard-from", "Saving the answer failed"));
96
+ return "answered";
97
+ }
@@ -9,7 +9,7 @@ import type { PowerBoard, PowerDetail, PowerFilter, PowerHistory } from "./power
9
9
  import type { PerpBoardPayload, PerpEquitiesPayload, PerpEquityListing, PerpHistoryPayload, PerpRankingsPayload, PerpBoardQuery, PerpHistoryQuery,
10
10
  PerpMarketPayload, PerpLiquidationsPayload, PerpDepthPayload } from "./perps";
11
11
  import type { ExposureRequest, ExposurePayload, ExposureScenario } from "./exposure";
12
- import type { SupplyChainPayload, SupplyOptions } from "./supply-chain";
12
+ import type { SupplyChainPayload, SupplyOptions, SupplyRead } from "./supply-chain";
13
13
  import { createReadCoalescer } from "./coalesce";
14
14
  import { supplyGraphQuery, type GraphOptions, type GraphPayload } from "./supply-chain-graph";
15
15
  import type { AwardDetailPayload, AwardFilter, AwardsPayload } from "./awards";
@@ -1056,10 +1056,11 @@ export class CloudDataApi {
1056
1056
  return this.request<{ scenarios: ExposureScenario[] }>("/cloud/exposure/scenarios");
1057
1057
  }
1058
1058
 
1059
- async getCloudSupplyChain(symbol: string, options: SupplyOptions = {}): Promise<SupplyChainPayload> {
1059
+ async getCloudSupplyChain(symbol: string, options: SupplyRead = {}): Promise<SupplyChainPayload> {
1060
1060
  const query = new URLSearchParams();
1061
1061
  if (options.tiers?.length) query.set("tiers", options.tiers.join(","));
1062
1062
  if (options.includeLeads) query.set("includeLeads", "1");
1063
+ if (options.asOf) query.set("asOf", options.asOf);
1063
1064
  return this.request<SupplyChainPayload>(`/cloud/supply-chain/${encodeURIComponent(symbol)}${query.size ? `?${query}` : ""}`);
1064
1065
  }
1065
1066
 
@@ -0,0 +1,72 @@
1
+ import type { CloudApiRequest } from "./request";
2
+
3
+ /**
4
+ * "Where did you hear about Gloom?": one optional question a new account is
5
+ * asked once, kept on the account. The service decides whether to ask and
6
+ * settles it for good on the first answer or skip; the account comes from
7
+ * the session alone. The app asks before the email is confirmed
8
+ * (`unconfirmed=1`), since confirming holds nothing up here.
9
+ */
10
+ export const HEARD_FROM_ANSWERS = [
11
+ "search",
12
+ "youtube",
13
+ "tiktok",
14
+ "instagram",
15
+ "x",
16
+ "reddit",
17
+ "ai_assistant",
18
+ "friend",
19
+ "article",
20
+ "other",
21
+ ] as const;
22
+
23
+ export type HeardFromAnswer = (typeof HEARD_FROM_ANSWERS)[number];
24
+
25
+ /** The longest "Other" note the service keeps, in characters. */
26
+ const HEARD_FROM_NOTE_MAX_LENGTH = 120;
27
+
28
+ export interface HeardFromState {
29
+ /** Show the question now. */
30
+ ask: boolean;
31
+ /** The answer is final: it will never be asked again. */
32
+ settled: boolean;
33
+ }
34
+
35
+ function parseHeardFromState(value: unknown): HeardFromState {
36
+ const record = typeof value === "object" && value !== null ? value as Record<string, unknown> : null;
37
+ if (!record || typeof record.ask !== "boolean" || typeof record.settled !== "boolean") {
38
+ throw new Error("The account service returned invalid data.");
39
+ }
40
+ return { ask: record.ask, settled: record.settled };
41
+ }
42
+
43
+ /** One line, trimmed, cut to what the service keeps (counted in characters, not UTF-16 units). */
44
+ function heardFromNote(text: string): string {
45
+ return [...text.replace(/\s+/g, " ").trim()].slice(0, HEARD_FROM_NOTE_MAX_LENGTH).join("").trim();
46
+ }
47
+
48
+ export class CloudHeardFromApi {
49
+ constructor(private readonly request: CloudApiRequest) {}
50
+
51
+ async getHeardFrom(signal?: AbortSignal): Promise<HeardFromState> {
52
+ return parseHeardFromState(await this.request<unknown>("/account/heard-from?unconfirmed=1", { signal }));
53
+ }
54
+
55
+ /** The question is on screen. */
56
+ async reportHeardFromShown(): Promise<void> {
57
+ await this.request<unknown>("/account/heard-from/shown?unconfirmed=1", { method: "POST" });
58
+ }
59
+
60
+ /** An answer; the note only goes with Other. A repeat or a later answer changes nothing. */
61
+ async answerHeardFrom(answer: HeardFromAnswer, note?: string): Promise<void> {
62
+ const other = answer === "other" && note ? heardFromNote(note) : "";
63
+ await this.request<unknown>("/account/heard-from", {
64
+ method: "POST",
65
+ body: JSON.stringify(other ? { answer, other } : { answer }),
66
+ });
67
+ }
68
+
69
+ async skipHeardFrom(): Promise<void> {
70
+ await this.request<unknown>("/account/heard-from", { method: "POST", body: JSON.stringify({ skip: true }) });
71
+ }
72
+ }
@@ -28,6 +28,7 @@ import { CloudCollectionsApi } from "./collections";
28
28
  import { CloudFeedbackApi } from "./feedback";
29
29
  import { CloudRoadmapApi } from "./roadmap";
30
30
  import { CloudWaitlistApi } from "./product-waitlist";
31
+ import { CloudHeardFromApi } from "./heard-from";
31
32
  import { CloudNotesApi } from "./notes";
32
33
  import { CloudTeamsApi } from "./teams";
33
34
  import { CloudTelemetryApi } from "./telemetry";
@@ -40,6 +41,8 @@ import type {
40
41
  AssistCommandResponse,
41
42
  AuthUser,
42
43
  CloudCancelFeedback,
44
+ CloudRetentionOffer,
45
+ CloudRetentionOfferAnswer,
43
46
  CloudSyncPushResponse,
44
47
  CloudYearlyPlanStatus,
45
48
  CloudYearlyResult,
@@ -78,6 +81,15 @@ const ASSIST_COMMAND_LIMIT = 150;
78
81
  export const ASSIST_ARG_OPTION_LIMIT = 128;
79
82
  /** The longest cancel note the server keeps, in UTF-16 units as its schema counts them. */
80
83
  export const CLOUD_CANCEL_COMMENT_MAX = 500;
84
+
85
+ /** The reason and note a cancel step sends, the note trimmed to what the server keeps. */
86
+ function cancelFeedbackBody(feedback: CloudCancelFeedback): CloudCancelFeedback {
87
+ const comment = feedback.comment === undefined ? undefined : sliceWholeCharacters(feedback.comment.trim(), CLOUD_CANCEL_COMMENT_MAX);
88
+ return {
89
+ ...(feedback.reason ? { reason: feedback.reason } : {}),
90
+ ...(comment ? { comment } : {}),
91
+ };
92
+ }
81
93
  const ASSIST_ARG_OPTION_VALUE_MAX_LENGTH = 40;
82
94
  const ASSIST_ARG_OPTION_LABEL_MAX_LENGTH = 60;
83
95
  const ASSIST_REQUEST_TIMEOUT_MS = 6_000;
@@ -190,6 +202,7 @@ class GloomApiClient {
190
202
  private readonly feedback: CloudFeedbackApi = new CloudFeedbackApi((path, options) => this.request(path, options));
191
203
  private readonly roadmap: CloudRoadmapApi = new CloudRoadmapApi((path, options) => this.request(path, options));
192
204
  private readonly waitlist: CloudWaitlistApi = new CloudWaitlistApi((path, options) => this.request(path, options));
205
+ private readonly heardFrom: CloudHeardFromApi = new CloudHeardFromApi((path, options) => this.request(path, options));
193
206
  private readonly telemetry: CloudTelemetryApi = new CloudTelemetryApi((path, options) => this.request(path, options));
194
207
  private readonly theses: CloudThesesApi = new CloudThesesApi((path, options) => this.request(path, options));
195
208
  private readonly collections: CloudCollectionsApi = new CloudCollectionsApi((path, options) => this.request(path, options));
@@ -688,15 +701,55 @@ class GloomApiClient {
688
701
  * reason and note, when given, go to the billing provider with the cancel.
689
702
  */
690
703
  async endCloudTrial(feedback: CloudCancelFeedback = {}): Promise<{ canceled: boolean; endedNow?: boolean }> {
691
- const comment = feedback.comment === undefined ? undefined : sliceWholeCharacters(feedback.comment.trim(), CLOUD_CANCEL_COMMENT_MAX);
692
704
  return this.request<{ canceled: boolean; endedNow?: boolean }>("/stripe/subscription/cancel", {
693
705
  method: "POST",
694
- body: JSON.stringify({
695
- ...(feedback.reason ? { reason: feedback.reason } : {}),
696
- ...(comment ? { comment } : {}),
697
- endTrialNow: true,
698
- }),
706
+ body: JSON.stringify({ ...cancelFeedbackBody(feedback), endTrialNow: true }),
707
+ });
708
+ }
709
+
710
+ /**
711
+ * Stops a paid Pro plan from renewing: it keeps Pro to the end of the period
712
+ * it paid for. The same request gloom.sh's cancel window sends, the reason
713
+ * and note with it when given. Call it only once the person confirmed.
714
+ */
715
+ async cancelCloudSubscription(feedback: CloudCancelFeedback = {}): Promise<{ canceled: boolean; endedNow?: boolean }> {
716
+ return this.request<{ canceled: boolean; endedNow?: boolean }>("/stripe/subscription/cancel", {
717
+ method: "POST",
718
+ body: JSON.stringify(cancelFeedbackBody(feedback)),
719
+ });
720
+ }
721
+
722
+ /**
723
+ * The save offer and the kept price the cancel flow shows, read as it opens.
724
+ * The server counts this as the cancel flow starting.
725
+ */
726
+ async getCloudRetentionOffer(options?: { signal?: AbortSignal }): Promise<CloudRetentionOfferAnswer> {
727
+ const body = await this.request<Partial<CloudRetentionOfferAnswer> | null>("/stripe/subscription/retention-offer", {
728
+ method: "GET",
729
+ ...(options?.signal ? { signal: options.signal } : {}),
699
730
  });
731
+ const offer = body?.offer === "discount" || body?.offer === "trial_extension" ? body.offer : null;
732
+ const kept = body?.keptPrice;
733
+ return {
734
+ offer,
735
+ extendedTrialEndsAt: typeof body?.extendedTrialEndsAt === "string" ? body.extendedTrialEndsAt : null,
736
+ keptPrice: kept && Number.isFinite(kept.amount) && Number.isFinite(kept.listAmount)
737
+ && (kept.interval === "month" || kept.interval === "year")
738
+ ? { amount: kept.amount, listAmount: kept.listAmount, interval: kept.interval }
739
+ : null,
740
+ };
741
+ }
742
+
743
+ /** Takes the save offer the cancel flow showed, with the reason and note picked. */
744
+ async acceptCloudRetentionOffer(feedback: CloudCancelFeedback = {}): Promise<{ offer: CloudRetentionOffer | null; extendedTrialEndsAt: string | null }> {
745
+ const body = await this.request<{ offer?: unknown; extendedTrialEndsAt?: unknown } | null>("/stripe/subscription/retention-offer", {
746
+ method: "POST",
747
+ body: JSON.stringify(cancelFeedbackBody(feedback)),
748
+ });
749
+ return {
750
+ offer: body?.offer === "discount" || body?.offer === "trial_extension" ? body.offer : null,
751
+ extendedTrialEndsAt: typeof body?.extendedTrialEndsAt === "string" ? body.extendedTrialEndsAt : null,
752
+ };
700
753
  }
701
754
 
702
755
  /**
@@ -985,6 +1038,10 @@ class GloomApiClient {
985
1038
  getWaitlist = this.waitlist.getWaitlist.bind(this.waitlist);
986
1039
  joinWaitlist = this.waitlist.joinWaitlist.bind(this.waitlist);
987
1040
  leaveWaitlist = this.waitlist.leaveWaitlist.bind(this.waitlist);
1041
+ getHeardFrom = this.heardFrom.getHeardFrom.bind(this.heardFrom);
1042
+ reportHeardFromShown = this.heardFrom.reportHeardFromShown.bind(this.heardFrom);
1043
+ answerHeardFrom = this.heardFrom.answerHeardFrom.bind(this.heardFrom);
1044
+ skipHeardFrom = this.heardFrom.skipHeardFrom.bind(this.heardFrom);
988
1045
  reportCrashErrors = this.telemetry.reportCrashErrors.bind(this.telemetry);
989
1046
  reportUsageCounts = this.telemetry.reportUsageCounts.bind(this.telemetry);
990
1047
  reportInstallExperiment = this.telemetry.reportInstallExperiment.bind(this.telemetry);
@@ -58,6 +58,8 @@ export interface MnaDeal {
58
58
  announced: string;
59
59
  /** Expected close as the parties state it, e.g. "2026-12-31" or "Q1 2027". */
60
60
  expectedClose: string | null;
61
+ /** The merger agreement's outside date, as a filing states it; null or left out (older servers) when none was read. */
62
+ outsideDate?: MnaOutsideDate | null;
61
63
  closed: string | null;
62
64
  /** One line on the latest development. */
63
65
  headline: string;
@@ -68,6 +70,22 @@ export interface MnaDeal {
68
70
  stale: boolean;
69
71
  }
70
72
 
73
+ /**
74
+ * The day after which either side may end the merger agreement if the deal
75
+ * has not closed: a deadline, not an expected close. Some agreements move it
76
+ * later on their own on a stated condition (regulatory approvals still
77
+ * pending); `extendedTo` is that day and `extension` the condition, briefly.
78
+ */
79
+ export interface MnaOutsideDate {
80
+ /** `YYYY-MM-DD`. */
81
+ date: string;
82
+ extendedTo: string | null;
83
+ /** What moves it, e.g. "if only antitrust approvals and the Nasdaq listing remain". */
84
+ extension: string | null;
85
+ /** The filing it is read from. */
86
+ source: { form: string; filed: string; url: string | null };
87
+ }
88
+
71
89
  export type MnaStatusFilter = MnaStatus | "all";
72
90
  export type MnaTargetFilter = "all" | "public" | "private";
73
91
  export type MnaRegionFilter = "all" | "us" | "intl";