gloomberb 0.20.14 → 0.20.17

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 (186) hide show
  1. package/package.json +1 -1
  2. package/src/api-client/data.ts +13 -3
  3. package/src/api-client/index.ts +54 -0
  4. package/src/api-client/install-experiments.ts +8 -7
  5. package/src/api-client/paths.ts +2 -1
  6. package/src/api-client/product-waitlist.ts +63 -0
  7. package/src/api-client/request.ts +4 -2
  8. package/src/api-client/types/billing.ts +45 -0
  9. package/src/api-client/types/econ.ts +3 -0
  10. package/src/api-client/yearly-plan.ts +132 -0
  11. package/src/app/global-shortcuts.ts +5 -3
  12. package/src/app/pane-runtime/index.tsx +2 -2
  13. package/src/app/pane-runtime/plugin-bindings.ts +3 -1
  14. package/src/app/pane-runtime/ticker-open-runtime.ts +6 -1
  15. package/src/app/since-last-visit/keys.ts +26 -0
  16. package/src/app/since-last-visit/model.ts +266 -0
  17. package/src/app/since-last-visit/strip.tsx +193 -0
  18. package/src/app/since-last-visit/use-since-last-visit.ts +289 -0
  19. package/src/app/since-last-visit/visit-tracker.ts +191 -0
  20. package/src/app.tsx +15 -0
  21. package/src/cli/commands/fred-series.ts +3 -1
  22. package/src/cli/commands/market.ts +8 -4
  23. package/src/cli/commands/overview.ts +65 -13
  24. package/src/cli/commands/system.ts +29 -1
  25. package/src/cli/commands/ticker.ts +12 -5
  26. package/src/cli/csv-export.ts +73 -0
  27. package/src/cli/desktop-pane-shot-api-policy.ts +4 -1
  28. package/src/cli/desktop-pane-shot-browser.ts +2 -1
  29. package/src/cli/desktop-pane-shot-view.ts +3 -7
  30. package/src/cli/desktop-pane-shot.ts +29 -30
  31. package/src/cli/help.ts +5 -2
  32. package/src/cli/history-rows.ts +24 -0
  33. package/src/cli/index.ts +4 -0
  34. package/src/cli/options.ts +29 -1
  35. package/src/cli/pane-functions/catalog.ts +41 -4
  36. package/src/cli/pane-functions/function-help.ts +1 -1
  37. package/src/cli/pane-functions/headless.ts +70 -3
  38. package/src/cli/pane-functions/index.ts +4 -4
  39. package/src/cli/pane-functions/resolver.ts +43 -0
  40. package/src/cli/pane-functions/screenshot-bridge.ts +4 -2
  41. package/src/cli/pane-functions/screenshot-payload.ts +3 -0
  42. package/src/cli/report-tables.ts +37 -8
  43. package/src/cli/result.ts +3 -6
  44. package/src/cli/shot-temp-dir.ts +30 -0
  45. package/src/cli/suffixed-listing-rows.ts +11 -0
  46. package/src/components/chart/composite/composite-chart.tsx +3 -3
  47. package/src/components/chart/composite/legend.tsx +37 -7
  48. package/src/components/command-bar/commands/direct/index.ts +31 -8
  49. package/src/components/command-bar/commands/registry.ts +7 -0
  50. package/src/components/command-bar/routes/root/command-items.ts +8 -0
  51. package/src/components/command-bar/routes/root/results.ts +16 -0
  52. package/src/components/company-logo.tsx +10 -3
  53. package/src/components/data-table/sections.ts +6 -1
  54. package/src/components/layout/pane/title.ts +6 -2
  55. package/src/components/layout/shell/index.tsx +5 -1
  56. package/src/components/layout/shell/ticker-link-menu.ts +12 -9
  57. package/src/components/ticker/badge/format.ts +12 -3
  58. package/src/components/ticker/badge/index.tsx +9 -3
  59. package/src/components/ticker/list-table-view.tsx +119 -17
  60. package/src/components/ui/data-table/display-columns.ts +19 -0
  61. package/src/components/ui/data-table/hooks.ts +2 -3
  62. package/src/components/ui/data-table/index.tsx +43 -9
  63. package/src/components/ui/data-table/types.ts +21 -0
  64. package/src/components/ui/data-table/visible-range.ts +11 -1
  65. package/src/core/state/app/layout-reducer.ts +3 -1
  66. package/src/core/state/app/layout.ts +2 -2
  67. package/src/data/config/layout.ts +14 -0
  68. package/src/data/config/store/normalize.ts +11 -1
  69. package/src/i18n/es.ts +38 -0
  70. package/src/i18n/ja.ts +38 -0
  71. package/src/i18n/ko.ts +38 -0
  72. package/src/i18n/zh-cn.ts +38 -0
  73. package/src/i18n/zh-tw.ts +38 -0
  74. package/src/layout/pane-follow.ts +141 -4
  75. package/src/layout/pane-layout-move.ts +10 -7
  76. package/src/layout/ticker-navigation.ts +13 -19
  77. package/src/layout/ticker-retarget.ts +3 -2
  78. package/src/market-data/market/index-level.ts +19 -0
  79. package/src/plugins/builtin/account-management/keyboard.ts +14 -0
  80. package/src/plugins/builtin/account-management/model.ts +2 -0
  81. package/src/plugins/builtin/account-management/pane.tsx +79 -7
  82. package/src/plugins/builtin/account-management/payment-recovery-row.tsx +97 -0
  83. package/src/plugins/builtin/account-management/yearly-plan-row.tsx +359 -0
  84. package/src/plugins/builtin/awards/pane.tsx +12 -10
  85. package/src/plugins/builtin/changelog/index.tsx +6 -44
  86. package/src/plugins/builtin/changelog/versions.ts +17 -68
  87. package/src/plugins/builtin/chart-composer/pane.tsx +4 -1
  88. package/src/plugins/builtin/cloud/askg/executor.ts +2 -1
  89. package/src/plugins/builtin/cloud/askg/sources.ts +2 -1
  90. package/src/plugins/builtin/cpi/pane.tsx +1 -1
  91. package/src/plugins/builtin/credit-conditions/series.ts +2 -2
  92. package/src/plugins/builtin/debt-maturities/model.ts +1 -1
  93. package/src/plugins/builtin/earnings/board-model.ts +12 -0
  94. package/src/plugins/builtin/earnings/board-table.ts +8 -5
  95. package/src/plugins/builtin/earnings/board.tsx +38 -18
  96. package/src/plugins/builtin/earnings/highlight.ts +47 -0
  97. package/src/plugins/builtin/earnings/history-table.ts +1 -1
  98. package/src/plugins/builtin/earnings/index.tsx +1 -1
  99. package/src/plugins/builtin/earnings-calls/pane.tsx +2 -2
  100. package/src/plugins/builtin/econ/calendar-model.ts +2 -0
  101. package/src/plugins/builtin/econ/fred-catalog.ts +1 -256
  102. package/src/plugins/builtin/econ-statistics/cache.ts +1 -1
  103. package/src/plugins/builtin/econ-statistics/client.ts +11 -10
  104. package/src/plugins/builtin/econ-statistics/detail.tsx +1 -0
  105. package/src/plugins/builtin/econ-statistics/headless.ts +42 -6
  106. package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
  107. package/src/plugins/builtin/econ-statistics/pane.tsx +7 -2
  108. package/src/plugins/builtin/econ-statistics/stats.ts +2 -1
  109. package/src/plugins/builtin/econ-statistics/view.ts +9 -3
  110. package/src/plugins/builtin/estimate-revisions/model.ts +1 -1
  111. package/src/plugins/builtin/exposure/index.tsx +1 -1
  112. package/src/plugins/builtin/macro-day/model.ts +6 -4
  113. package/src/plugins/builtin/market-valuation/detail.tsx +3 -3
  114. package/src/plugins/builtin/market-valuation/headless.ts +11 -4
  115. package/src/plugins/builtin/market-valuation/pane.tsx +3 -1
  116. package/src/plugins/builtin/market-valuation/view.ts +14 -0
  117. package/src/plugins/builtin/news/wire/news/detail-view.tsx +20 -8
  118. package/src/plugins/builtin/pe-band/pane.tsx +1 -1
  119. package/src/plugins/builtin/portfolio-list/cli/render.ts +8 -1
  120. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +176 -17
  121. package/src/plugins/builtin/portfolio-list/pane/groups.tsx +220 -0
  122. package/src/plugins/builtin/portfolio-list/pane/index.tsx +90 -15
  123. package/src/plugins/builtin/portfolio-list/table.tsx +13 -1
  124. package/src/plugins/builtin/research/corporate-actions-pane.tsx +4 -2
  125. package/src/plugins/builtin/research/relative-valuation-headless.ts +15 -5
  126. package/src/plugins/builtin/research/relative-valuation-model.ts +7 -1
  127. package/src/plugins/builtin/research/relative-valuation-pane.tsx +7 -4
  128. package/src/plugins/builtin/shared/fred-catalog.ts +256 -0
  129. package/src/plugins/builtin/shared/headless-options.ts +1 -1
  130. package/src/plugins/builtin/shared/series-cache.ts +3 -0
  131. package/src/plugins/builtin/shared/series-detail-chart.tsx +3 -0
  132. package/src/plugins/builtin/short-interest/watch-pane.tsx +7 -7
  133. package/src/plugins/builtin/social-mentions/model.ts +2 -2
  134. package/src/plugins/builtin/thirteenf/pane.tsx +1 -1
  135. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +16 -0
  136. package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +8 -4
  137. package/src/plugins/builtin/ticker-detail/financials/model.ts +51 -16
  138. package/src/plugins/builtin/ticker-detail/financials/nopat.ts +16 -0
  139. package/src/plugins/builtin/ticker-detail/financials/ratios.ts +44 -13
  140. package/src/plugins/builtin/ticker-detail/financials/schema.ts +33 -2
  141. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +4 -2
  142. package/src/plugins/builtin/ticker-detail/headless-schema.ts +30 -4
  143. package/src/plugins/builtin/ticker-detail/headless.ts +254 -34
  144. package/src/plugins/builtin/ticker-detail/overview/model.ts +7 -3
  145. package/src/plugins/builtin/ticker-detail/pharma-signals/eligibility.ts +32 -0
  146. package/src/plugins/builtin/ticker-detail/pharma-signals/tab.tsx +162 -0
  147. package/src/plugins/builtin/ticker-detail/pharma-signals/waitlist.ts +126 -0
  148. package/src/plugins/builtin/ticker-detail/research-groups.ts +6 -4
  149. package/src/plugins/builtin/ticker-detail/research-tabs.ts +11 -0
  150. package/src/plugins/builtin/time-sales/headless.ts +4 -1
  151. package/src/plugins/builtin/time-sales/pane.tsx +2 -0
  152. package/src/plugins/builtin/time-sales/window.ts +12 -0
  153. package/src/plugins/builtin/treasury-auctions/client.ts +4 -0
  154. package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +2 -0
  155. package/src/plugins/builtin/treasury-daily/client.ts +23 -11
  156. package/src/portfolio/column-values.ts +20 -8
  157. package/src/portfolio/suffixed-listings.ts +3 -1
  158. package/src/portfolio/watchlist-groups.ts +212 -0
  159. package/src/react/ticker-source.ts +3 -1
  160. package/src/renderers/dom/styles.css +7 -0
  161. package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +2 -0
  162. package/src/sources/gloomberb-cloud/fred-publisher.ts +25 -0
  163. package/src/sources/gloomberb-cloud/fred-series.ts +1 -1
  164. package/src/state/app/bootstrap.ts +11 -0
  165. package/src/state/app/context/index.tsx +6 -0
  166. package/src/sync/collections-contributor.ts +5 -2
  167. package/src/sync/config-merge.ts +10 -2
  168. package/src/sync/sanitize.ts +28 -0
  169. package/src/telemetry/usage-counts.ts +17 -0
  170. package/src/time-series/base-series.ts +3 -0
  171. package/src/time-series/chart-seed.ts +1 -1
  172. package/src/time-series/financial-period-coverage.ts +4 -12
  173. package/src/time-series/ice-credit.ts +1 -0
  174. package/src/time-series/parsed-history-cache.ts +1 -1
  175. package/src/time-series/resolve.ts +1 -1
  176. package/src/time-series/types.ts +1 -0
  177. package/src/time-series/use-chart-resolution.ts +6 -1
  178. package/src/types/config.ts +32 -0
  179. package/src/types/headless.ts +9 -2
  180. package/src/types/plugin-context.ts +5 -0
  181. package/src/types/ticker.ts +14 -0
  182. package/src/ui/ascii-font.ts +1 -4
  183. package/src/utils/async-deadline.ts +2 -2
  184. package/src/utils/csv.ts +44 -5
  185. package/src/utils/futures-generic.ts +3 -0
  186. package/src/utils/throttled-fetch.ts +15 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gloomberb",
3
- "version": "0.20.14",
3
+ "version": "0.20.17",
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",
@@ -56,7 +56,7 @@ import type { GpuBoardPayload, GpuEventsPayload, GpuHistoryPayload, GpuHistoryQu
56
56
  import type { CpiBoardPayload } from "./cpi";
57
57
  import type { TapeRange, TapeSnapshot } from "./tape";
58
58
  import { LIVE_SCAN_PATH, type LiveScanPayload, type LiveScanWireDefinition } from "./live-scan";
59
- import { abortable, signalWithTimeout } from "../utils/async-deadline";
59
+ import { abortable, signalWithTimeout, withDeadline } from "../utils/async-deadline";
60
60
  import { ApiRequestError, isRetryableApiError, markAskedTwice } from "./errors";
61
61
  import type { ExchangeRateSnapshot } from "../types/exchange-rate";
62
62
  import type { RatePathPayload } from "./rates";
@@ -211,6 +211,12 @@ function batchAnswers<K extends string, T>(response: CloudMarketResponse<CloudBa
211
211
 
212
212
  /** How long a listing read waits before asking again after the service said its source failed. */
213
213
  const LISTING_RETRY_DELAY_MS = 400;
214
+ /**
215
+ * A company never looked at is searched while it is asked about, for a few
216
+ * seconds at most (the search goes on and the list says pending): a list
217
+ * that has not come in this long is a failure the pane says, not a minute's wait.
218
+ */
219
+ const EARNINGS_CALLS_LIST_TIMEOUT_MS = 20_000;
214
220
 
215
221
  /**
216
222
  * How long the service's answer that it has no quote for a listing stands.
@@ -1506,8 +1512,12 @@ export class CloudDataApi {
1506
1512
  async getCloudEarningsCalls(
1507
1513
  params: CloudEarningsCallsParams = {},
1508
1514
  ): Promise<CloudEarningsCallListPayload> {
1509
- return this.request<CloudEarningsCallListPayload>(
1510
- cloudEarningsCallsPath(params),
1515
+ const abandon = new AbortController();
1516
+ return withDeadline(
1517
+ this.request<CloudEarningsCallListPayload>(cloudEarningsCallsPath(params), { signal: abandon.signal }),
1518
+ EARNINGS_CALLS_LIST_TIMEOUT_MS,
1519
+ `No answer within ${EARNINGS_CALLS_LIST_TIMEOUT_MS / 1000} s.`,
1520
+ () => abandon.abort(),
1511
1521
  );
1512
1522
  }
1513
1523
 
@@ -27,11 +27,13 @@ import { CloudApiSocket } from "./socket";
27
27
  import { CloudCollectionsApi } from "./collections";
28
28
  import { CloudFeedbackApi } from "./feedback";
29
29
  import { CloudRoadmapApi } from "./roadmap";
30
+ import { CloudWaitlistApi } from "./product-waitlist";
30
31
  import { CloudNotesApi } from "./notes";
31
32
  import { CloudTeamsApi } from "./teams";
32
33
  import { CloudTelemetryApi } from "./telemetry";
33
34
  import { CloudThesesApi } from "./theses";
34
35
  import { CloudViewsApi } from "./views";
36
+ import { readYearlyPlanStatus, readYearlyResult, readYearlyReview } from "./yearly-plan";
35
37
  import type { CommandSearchReport } from "./telemetry";
36
38
  import type {
37
39
  AssistCommandDescriptor,
@@ -39,6 +41,9 @@ import type {
39
41
  AuthUser,
40
42
  CloudCancelFeedback,
41
43
  CloudSyncPushResponse,
44
+ CloudYearlyPlanStatus,
45
+ CloudYearlyResult,
46
+ CloudYearlyReview,
42
47
  CloudSyncSnapshotResponse,
43
48
  PersistedAuthUser
44
49
  } from "./types";
@@ -49,6 +54,7 @@ export type { ChatPaneLink } from "./chat-pane-link";
49
54
  export { NoteConflictError } from "./notes";
50
55
  export { ThesisConflictError, ThesisGoalpostError } from "./theses";
51
56
  export { TeamRevisionConflictError } from "./views";
57
+ export { yearlyRefusalCode } from "./yearly-plan";
52
58
  export type * from "./types";
53
59
  export type {
54
60
  CommandSearchChoice,
@@ -183,6 +189,7 @@ class GloomApiClient {
183
189
  private readonly notes: CloudNotesApi = new CloudNotesApi((path, options) => this.request(path, options));
184
190
  private readonly feedback: CloudFeedbackApi = new CloudFeedbackApi((path, options) => this.request(path, options));
185
191
  private readonly roadmap: CloudRoadmapApi = new CloudRoadmapApi((path, options) => this.request(path, options));
192
+ private readonly waitlist: CloudWaitlistApi = new CloudWaitlistApi((path, options) => this.request(path, options));
186
193
  private readonly telemetry: CloudTelemetryApi = new CloudTelemetryApi((path, options) => this.request(path, options));
187
194
  private readonly theses: CloudThesesApi = new CloudThesesApi((path, options) => this.request(path, options));
188
195
  private readonly collections: CloudCollectionsApi = new CloudCollectionsApi((path, options) => this.request(path, options));
@@ -629,6 +636,50 @@ class GloomApiClient {
629
636
  return this.request<{ url: string }>("/stripe/portal", { method: "POST", body: JSON.stringify({}) });
630
637
  }
631
638
 
639
+ async createInvoicePayment(): Promise<{ url: string }> {
640
+ const result = await this.request<{ url: string }>("/stripe/pay-invoice", {
641
+ method: "POST",
642
+ body: JSON.stringify({}),
643
+ });
644
+ const url = new URL(result.url);
645
+ if (url.origin !== "https://invoice.stripe.com" || url.username || url.password) {
646
+ throw new Error("Could not open invoice payment.");
647
+ }
648
+ return { url: url.href };
649
+ }
650
+
651
+ /** Whether this account's monthly Pro can move to yearly billing; reads only. */
652
+ async getCloudYearlyPlan(): Promise<CloudYearlyPlanStatus> {
653
+ return readYearlyPlanStatus(await this.request<unknown>("/stripe/subscription/yearly", { method: "GET" }));
654
+ }
655
+
656
+ /** The exact charge of switching to yearly now. Charges nothing. */
657
+ async previewCloudYearlyPlan(): Promise<CloudYearlyReview> {
658
+ const body = await this.request<{ review?: unknown }>("/stripe/subscription/yearly/preview", {
659
+ method: "POST",
660
+ body: JSON.stringify({}),
661
+ });
662
+ const review = readYearlyReview(body?.review);
663
+ if (!review) throw new Error("Couldn't work out the yearly total. Try again in a minute.");
664
+ return review;
665
+ }
666
+
667
+ /**
668
+ * Switches to yearly billing for exactly what `token`'s review showed. Call it
669
+ * only after the person confirmed that review. Refusals (a total that moved,
670
+ * a switch already going through) are ApiRequestErrors; `yearlyRefusalCode`
671
+ * names them.
672
+ */
673
+ async confirmCloudYearlyPlan(token: string): Promise<CloudYearlyResult> {
674
+ const body = await this.request<unknown>("/stripe/subscription/yearly/confirm", {
675
+ method: "POST",
676
+ body: JSON.stringify({ token }),
677
+ });
678
+ const result = readYearlyResult(body);
679
+ if (!result) throw new Error("We couldn't confirm the switch. Refresh your account before trying again.");
680
+ return result;
681
+ }
682
+
632
683
  /**
633
684
  * Ends the Pro trial and Pro now, unbilled. Call it only once the person
634
685
  * confirmed a warning that says so. `endedNow` is false when the server
@@ -931,6 +982,9 @@ class GloomApiClient {
931
982
  listFeedback = this.feedback.listFeedback.bind(this.feedback);
932
983
  getRoadmap = this.roadmap.getRoadmap.bind(this.roadmap);
933
984
  setRoadmapVote = this.roadmap.setRoadmapVote.bind(this.roadmap);
985
+ getWaitlist = this.waitlist.getWaitlist.bind(this.waitlist);
986
+ joinWaitlist = this.waitlist.joinWaitlist.bind(this.waitlist);
987
+ leaveWaitlist = this.waitlist.leaveWaitlist.bind(this.waitlist);
934
988
  reportCrashErrors = this.telemetry.reportCrashErrors.bind(this.telemetry);
935
989
  reportUsageCounts = this.telemetry.reportUsageCounts.bind(this.telemetry);
936
990
  reportInstallExperiment = this.telemetry.reportInstallExperiment.bind(this.telemetry);
@@ -5,18 +5,19 @@
5
5
  * The registry and the bucketing live with the Gloom Cloud API, as they do for
6
6
  * the web terminal's experiments (web-experiments.ts). The app asks for its
7
7
  * arm at the moment an experiment's change would show, in every arm
8
- * (`experiment_assign`, which the API records nothing for), and once it has
9
- * gone on with that arm it confirms it (`experiment_exposed`). The
10
- * confirmation is the exposure, counted under `install:<id>`, the id its
11
- * usage counts already go under, so what the install does on later days
12
- * reads against the arm it saw. Turning an experiment off there takes effect
13
- * here without a release.
8
+ * (`experiment_assign`), and once it has gone on with that arm it confirms
9
+ * it (`experiment_exposed`). The API records the assignment as
10
+ * `experiment_assigned` and the confirmation as `experiment_exposed`, both
11
+ * under `install:<id>`, the id its usage counts already go under. Later usage
12
+ * can read against the assigned arm or the arm it saw. Turning an experiment
13
+ * off there takes effect here without a release.
14
14
  *
15
15
  * It is covered by the Usage setting and sends nothing with it off, under
16
16
  * Do Not Track or Global Privacy Control, or in an automated browser: those
17
17
  * installs get the control and are not counted. An answer that fails or
18
18
  * comes too late gets the control too, so the change never holds anything
19
- * up, and confirms nothing: an install never counts in an arm it did not see.
19
+ * up, and confirms nothing: an install never confirms an exposure to an arm
20
+ * it did not see.
20
21
  */
21
22
  import { apiClient, type InstallExperimentAnswer, type InstallExperimentReport } from "./index";
22
23
  import { VERSION } from "../version";
@@ -125,7 +125,8 @@ function normalizeCloudLogoSymbol(
125
125
  symbol: string,
126
126
  ): string | null {
127
127
  let normalized = symbol.trim().toUpperCase();
128
- if (kind === "crypto") normalized = normalized.replace(CRYPTO_QUOTE, "");
128
+ // A coin is its code alone: BTC-USD:CCC and BTC/USDT are both BTC.
129
+ if (kind === "crypto") normalized = parsePublicTickerKey(normalized).symbol.replace(CRYPTO_QUOTE, "");
129
130
  return LOGO_SYMBOL_RE.test(normalized) ? normalized : null;
130
131
  }
131
132
 
@@ -0,0 +1,63 @@
1
+ import { ApiRequestError } from "./errors";
2
+ import type { CloudApiRequest } from "./request";
3
+
4
+ /**
5
+ * The no-charge waitlist for an add-on that is not built yet. The signed-in
6
+ * account reads its place on the list, joins it (agreeing to one email if the
7
+ * add-on launches) and leaves it. The service takes the account and its
8
+ * address from the session: nothing here sends either. The address must be
9
+ * verified, since joining consents to email it: the service refuses every
10
+ * call of an unverified account with a 403.
11
+ */
12
+ export type WaitlistProduct = "pharma-signals";
13
+
14
+ /** The service's 403 for an account whose address is not verified. */
15
+ const EMAIL_VERIFICATION_REQUIRED = "Email verification required";
16
+
17
+ /** Whether the waitlist refused a call because the account's address is not verified yet. */
18
+ export function isEmailVerificationRequired(error: unknown): boolean {
19
+ return error instanceof ApiRequestError && error.status === 403 && error.message === EMAIL_VERIFICATION_REQUIRED;
20
+ }
21
+
22
+ export interface WaitlistState {
23
+ product: WaitlistProduct;
24
+ joined: boolean;
25
+ /** ISO time of the latest join while on the list; null off it. */
26
+ joinedAt: string | null;
27
+ }
28
+
29
+ function isRecord(value: unknown): value is Record<string, unknown> {
30
+ return typeof value === "object" && value !== null && !Array.isArray(value);
31
+ }
32
+
33
+ function parseWaitlistState(value: unknown, product: WaitlistProduct): WaitlistState {
34
+ if (!isRecord(value) || value.product !== product || typeof value.joined !== "boolean") {
35
+ throw new Error("The waitlist service returned invalid data.");
36
+ }
37
+ return {
38
+ product,
39
+ joined: value.joined,
40
+ joinedAt: value.joined && typeof value.joinedAt === "string" ? value.joinedAt : null,
41
+ };
42
+ }
43
+
44
+ export class CloudWaitlistApi {
45
+ constructor(private readonly request: CloudApiRequest) {}
46
+
47
+ async getWaitlist(product: WaitlistProduct, signal?: AbortSignal): Promise<WaitlistState> {
48
+ return parseWaitlistState(await this.request<unknown>(`/account/waitlist/${product}`, { signal }), product);
49
+ }
50
+
51
+ /** Joins, or changes nothing when already on the list. The body is the consent: one email at launch. */
52
+ async joinWaitlist(product: WaitlistProduct): Promise<WaitlistState> {
53
+ return parseWaitlistState(await this.request<unknown>(`/account/waitlist/${product}`, {
54
+ method: "PUT",
55
+ body: JSON.stringify({ launchEmail: true }),
56
+ }), product);
57
+ }
58
+
59
+ /** Leaves the list, which takes the launch email back; leaving when off it changes nothing. */
60
+ async leaveWaitlist(product: WaitlistProduct): Promise<WaitlistState> {
61
+ return parseWaitlistState(await this.request<unknown>(`/account/waitlist/${product}`, { method: "DELETE" }), product);
62
+ }
63
+ }
@@ -307,7 +307,8 @@ export async function putWithRevision<T, Current extends { revision: number }>(
307
307
  * beside a list check that still answers for the listing itself. Nor the
308
308
  * batched searches and ticker changes a list of symbols starts with: a service
309
309
  * without them answers 404, and whatever they leave unanswered is looked up
310
- * one symbol at a time, which is tracked.
310
+ * one symbol at a time, which is tracked. Nor the Pro tab's yearly billing
311
+ * status: a server without it answers 404 and the tab shows no yearly row.
311
312
  */
312
313
  function isBackgroundRequest(path: string): boolean {
313
314
  return path.startsWith("/telemetry/")
@@ -318,7 +319,8 @@ function isBackgroundRequest(path: string): boolean {
318
319
  || path.startsWith("/market/issuer-listings?")
319
320
  || path === "/market/ticker-changes/batch"
320
321
  || path === "/market/search/batch"
321
- || path === "/market/organization-tickers";
322
+ || path === "/market/organization-tickers"
323
+ || path === "/stripe/subscription/yearly";
322
324
  }
323
325
 
324
326
  function throwIfRequestAborted(signal: AbortSignal | null | undefined): void {
@@ -38,6 +38,7 @@ interface CloudPricingTier {
38
38
 
39
39
  /** `/account/cloud`, reduced to the plan fields the apps read. */
40
40
  export interface CloudAccountPlan {
41
+ subscription?: { status: string | null };
41
42
  effectivePlan?: "free" | "pro";
42
43
  /** Whether a checkout started now comes with the free trial attached. */
43
44
  trialAvailable?: boolean;
@@ -45,6 +46,50 @@ export interface CloudAccountPlan {
45
46
  paymentFailed?: boolean;
46
47
  }
47
48
 
49
+ /** Moving a monthly Pro subscription to yearly billing, in integer cents. */
50
+ export interface CloudYearlyOffer {
51
+ currency: "usd";
52
+ monthlyAmount: number;
53
+ yearlyAmount: number;
54
+ /** Twelve monthly payments, and what the yearly price saves on them. */
55
+ twelveMonthlyAmount: number;
56
+ savingsAmount: number;
57
+ }
58
+
59
+ /** Whether this account can switch to yearly billing now. */
60
+ export type CloudYearlyPlanStatus =
61
+ | { state: "unavailable" }
62
+ | { state: "available"; offer: CloudYearlyOffer }
63
+ /** A switch waiting for its payment; `invoiceUrl` is Stripe's hosted invoice. */
64
+ | { state: "pending"; invoiceUrl: string | null; expiresAt: string | null };
65
+
66
+ /** The exact charge of a switch made now, from the billing provider's own preview. */
67
+ export interface CloudYearlyReview {
68
+ /** Confirms this review, and only this one, for a few minutes. */
69
+ token: string;
70
+ expiresAt: string;
71
+ currency: "usd";
72
+ /** Charged today, after any account credit. */
73
+ amountDue: number;
74
+ /** The yearly price from today to the first yearly billing date. */
75
+ yearlyAmount: number;
76
+ /** Credit for the unused part of the month already paid. */
77
+ credit: number;
78
+ tax: number;
79
+ /** Account credit the charge uses up. */
80
+ balanceApplied: number;
81
+ renewalAmount: number;
82
+ renewsAt: string;
83
+ renewalTaxed: boolean;
84
+ offer: CloudYearlyOffer;
85
+ }
86
+
87
+ /** What a confirmed switch came to. Only `switched` is a completed, paid switch. */
88
+ export type CloudYearlyResult =
89
+ | { state: "switched"; amountPaid: number | null; renewalAmount: number; renewsAt: string | null }
90
+ | { state: "payment_required"; invoiceUrl: string | null; expiresAt: string | null }
91
+ | { state: "processing" };
92
+
48
93
  /** Public `/pricing` payload; no session required. */
49
94
  export interface CloudPricing {
50
95
  currency: "usd";
@@ -147,6 +147,9 @@ export interface CloudFredObservationPayload {
147
147
  * 1 Sep and were released 20 Oct. Absent on daily series and older points.
148
148
  */
149
149
  releasedOn?: string;
150
+ firstReleased?: string;
151
+ revisedOn?: string;
152
+ firstReleaseValue?: number;
150
153
  }
151
154
 
152
155
  export interface CloudFredSeriesInfoPayload {
@@ -0,0 +1,132 @@
1
+ import { ApiRequestError } from "./errors";
2
+ import type {
3
+ CloudYearlyOffer,
4
+ CloudYearlyPlanStatus,
5
+ CloudYearlyResult,
6
+ CloudYearlyReview,
7
+ } from "./types/billing";
8
+
9
+ /**
10
+ * The yearly billing switch's answers, checked before anything is shown: an
11
+ * offer whose figures disagree, a review whose lines do not add up to its
12
+ * total, or a link that is not Stripe's own hosted invoice is never shown
13
+ * as it came.
14
+ */
15
+
16
+ function isCents(value: unknown): value is number {
17
+ return typeof value === "number" && Number.isInteger(value) && value >= 0;
18
+ }
19
+
20
+ function record(value: unknown): Record<string, unknown> {
21
+ return value && typeof value === "object" && !Array.isArray(value) ? value as Record<string, unknown> : {};
22
+ }
23
+
24
+ function optionalString(value: unknown): string | null {
25
+ return typeof value === "string" ? value : null;
26
+ }
27
+
28
+ /** Stripe's hosted invoice page, else null. */
29
+ export function hostedInvoiceUrl(value: unknown): string | null {
30
+ if (typeof value !== "string") return null;
31
+ try {
32
+ const url = new URL(value);
33
+ if (url.origin !== "https://invoice.stripe.com" || url.username || url.password) return null;
34
+ return url.href;
35
+ } catch {
36
+ // Intentional ignore: a link that does not parse is never opened.
37
+ return null;
38
+ }
39
+ }
40
+
41
+ export function readYearlyOffer(value: unknown): CloudYearlyOffer | null {
42
+ const offer = record(value);
43
+ if (
44
+ offer.currency !== "usd"
45
+ || !isCents(offer.monthlyAmount)
46
+ || !isCents(offer.yearlyAmount)
47
+ || !isCents(offer.twelveMonthlyAmount)
48
+ || !isCents(offer.savingsAmount)
49
+ || offer.twelveMonthlyAmount !== offer.monthlyAmount * 12
50
+ || offer.savingsAmount !== offer.twelveMonthlyAmount - offer.yearlyAmount
51
+ || offer.savingsAmount <= 0
52
+ ) return null;
53
+ return {
54
+ currency: "usd",
55
+ monthlyAmount: offer.monthlyAmount,
56
+ yearlyAmount: offer.yearlyAmount,
57
+ twelveMonthlyAmount: offer.twelveMonthlyAmount,
58
+ savingsAmount: offer.savingsAmount,
59
+ };
60
+ }
61
+
62
+ export function readYearlyPlanStatus(value: unknown): CloudYearlyPlanStatus {
63
+ const body = record(value);
64
+ if (body.state === "available") {
65
+ const offer = readYearlyOffer(body.offer);
66
+ return offer ? { state: "available", offer } : { state: "unavailable" };
67
+ }
68
+ if (body.state === "pending") {
69
+ return { state: "pending", invoiceUrl: hostedInvoiceUrl(body.invoiceUrl), expiresAt: optionalString(body.expiresAt) };
70
+ }
71
+ return { state: "unavailable" };
72
+ }
73
+
74
+ export function readYearlyReview(value: unknown): CloudYearlyReview | null {
75
+ const review = record(value);
76
+ const offer = readYearlyOffer(review.offer);
77
+ const { amountDue, yearlyAmount, credit, tax, balanceApplied, renewalAmount } = review;
78
+ if (
79
+ !offer
80
+ || typeof review.token !== "string"
81
+ || !review.token
82
+ || typeof review.expiresAt !== "string"
83
+ || typeof review.renewsAt !== "string"
84
+ || !isCents(amountDue)
85
+ || !isCents(yearlyAmount)
86
+ || !isCents(credit)
87
+ || !isCents(tax)
88
+ || !isCents(balanceApplied)
89
+ || !isCents(renewalAmount)
90
+ ) return null;
91
+ // The lines must add up to the total shown, or nothing is shown.
92
+ if (yearlyAmount - credit + tax - balanceApplied !== amountDue) return null;
93
+ return {
94
+ token: review.token,
95
+ expiresAt: review.expiresAt,
96
+ currency: "usd",
97
+ amountDue,
98
+ yearlyAmount,
99
+ credit,
100
+ tax,
101
+ balanceApplied,
102
+ renewalAmount,
103
+ renewsAt: review.renewsAt,
104
+ renewalTaxed: review.renewalTaxed === true,
105
+ offer,
106
+ };
107
+ }
108
+
109
+ /** An answer this app does not know is never read as a switch. */
110
+ export function readYearlyResult(value: unknown): CloudYearlyResult | null {
111
+ const body = record(value);
112
+ if (body.state === "switched") {
113
+ return {
114
+ state: "switched",
115
+ amountPaid: isCents(body.amountPaid) ? body.amountPaid : null,
116
+ renewalAmount: isCents(body.renewalAmount) ? body.renewalAmount : 0,
117
+ renewsAt: optionalString(body.renewsAt),
118
+ };
119
+ }
120
+ if (body.state === "payment_required") {
121
+ return { state: "payment_required", invoiceUrl: hostedInvoiceUrl(body.invoiceUrl), expiresAt: optionalString(body.expiresAt) };
122
+ }
123
+ if (body.state === "processing") return { state: "processing" };
124
+ return null;
125
+ }
126
+
127
+ /** The refusal a switch request came back with (`review_changed`, `busy`, ...), if any. */
128
+ export function yearlyRefusalCode(error: unknown): string | null {
129
+ if (!(error instanceof ApiRequestError)) return null;
130
+ const code = error.details?.code;
131
+ return typeof code === "string" ? code : null;
132
+ }
@@ -18,6 +18,7 @@ import { DOCS_PANE_TEMPLATE_ID } from "../docs/content";
18
18
  import { registerPaneDocsHandler } from "../docs/requests";
19
19
  import { isMoveDownShortcut, isMoveUpShortcut } from "../components/command-bar/keyboard-handlers";
20
20
  import { pressStarPromptKey } from "./star-prompt/runtime";
21
+ import { pressSinceLastVisitKey } from "./since-last-visit/keys";
21
22
  import {
22
23
  copyActiveSelection,
23
24
  isCopyShortcut,
@@ -176,19 +177,20 @@ export function useAppGlobalShortcuts({
176
177
  }
177
178
 
178
179
  // Toasts float above everything, so their keys work over a dialog too.
179
- // The status bar's star line answers the same keys once no toast does,
180
- // but only over the workspace itself.
180
+ // The since-last-visit strip, then the status bar's star line, answer
181
+ // the same keys once no toast does, but only over the workspace itself.
181
182
  if (action === "notification-action" || action === "notification-dismiss") {
182
183
  if (ranAlready(action)) return;
183
184
  const toastHandled = action === "notification-action"
184
185
  ? toastHost.activateNewest?.() === true
185
186
  : toastHost.dismissNewest?.() === true;
187
+ const kind = action === "notification-action" ? "open" : "dismiss";
186
188
  const handled = toastHandled || (
187
189
  !dialogOpen
188
190
  && !state.commandBarOpen
189
191
  && !state.inputCaptured
190
192
  && !isDetachedWindow
191
- && pressStarPromptKey(action === "notification-action" ? "open" : "dismiss")
193
+ && (pressSinceLastVisitKey(kind) || pressStarPromptKey(kind))
192
194
  );
193
195
  if (handled) {
194
196
  event.preventDefault();
@@ -21,7 +21,7 @@ import {
21
21
  type AppState,
22
22
  } from "../../state/app/context";
23
23
  import { scheduleConfigSave } from "../../state/config-save-scheduler";
24
- import { pinFollowingPane } from "../../layout/pane-follow";
24
+ import { pinOrphanedFollower } from "../../layout/pane-follow";
25
25
  import {
26
26
  createPaneInstance,
27
27
  isTickerPaneId,
@@ -91,7 +91,7 @@ export function useAppPaneRuntime({
91
91
  const currentState = stateRef.current;
92
92
  const normalizedLayout = normalizePaneLayout(layout, {
93
93
  resolveOrphanSymbol: (instanceId) => resolveTickerForPane(currentState, instanceId),
94
- pinOrphan: pinFollowingPane,
94
+ pinOrphan: pinOrphanedFollower(currentState.config.layout),
95
95
  externalSourceIds: linkedSourceIds(currentState),
96
96
  });
97
97
  if (options?.pushHistory !== false) {
@@ -42,6 +42,7 @@ import {
42
42
  resolveTickerNavigationReplacementPane,
43
43
  shouldFocusTickerNavigationTarget,
44
44
  } from "../../layout/ticker-navigation";
45
+ import { userUnlinkedFrom } from "../../layout/pane-follow";
45
46
  import {
46
47
  resolveTickerForPane,
47
48
  type AppAction,
@@ -367,11 +368,12 @@ export function bindAppPanePluginRegistry({
367
368
  ...(instrument !== undefined ? { instrument } : {}),
368
369
  ...(target.listing ? { listing: target.listing } : {}),
369
370
  };
371
+ const unlinkedFrom = userUnlinkedFrom(detailPane, currentLayout);
370
372
  const nextLayout = {
371
373
  ...currentLayout,
372
374
  instances: currentLayout.instances.map((instance) => (
373
375
  instance.instanceId === detailPane.instanceId
374
- ? { ...instance, title: tickerInstrumentLabel(symbol, instrument), binding }
376
+ ? { ...instance, title: tickerInstrumentLabel(symbol, instrument), binding, ...(unlinkedFrom ? { unlinkedFrom } : {}) }
375
377
  : instance
376
378
  )),
377
379
  };
@@ -132,6 +132,11 @@ function findTargetPane(
132
132
  ], symbol);
133
133
  }) ?? null;
134
134
  }
135
+ // Enter on a list row with no research pane of its own shows the ticker in a pinned one.
136
+ if (!existing && options?.reusePaneId) {
137
+ const reuse = findPaneInstance(layout, options.reusePaneId);
138
+ if (reuse?.paneId === paneType && reuse.binding?.kind === "fixed" && isPaneInLayout(layout, reuse.instanceId)) existing = reuse;
139
+ }
135
140
  return { existing, keepBinding };
136
141
  }
137
142
 
@@ -300,7 +305,7 @@ export function useAppTickerOpenRuntime({
300
305
  const paneType = normalizePaneId(options?.paneType ?? TICKER_RESEARCH_PANE_ID);
301
306
  const paneDef = pluginRegistry.panes.get(paneType);
302
307
  const symbol = normalizeTickerInput(null, rawSymbol);
303
- if (paneType !== TICKER_RESEARCH_PANE_ID || !paneDef || !symbol || options?.instrument) return null;
308
+ if (paneType !== TICKER_RESEARCH_PANE_ID || !paneDef || !symbol || options?.instrument || options?.reusePaneId) return null;
304
309
  const state = stateRef.current;
305
310
  const layout = state.config.layout;
306
311
  if (savedTickerForQuery(rawSymbol, state.tickers)) return null;
@@ -0,0 +1,26 @@
1
+ interface SinceLastVisitKeyHandlers {
2
+ open(): void;
3
+ dismiss(): void;
4
+ }
5
+
6
+ /** What the notification keys do while the strip shows; null otherwise. */
7
+ let keyHandlers: SinceLastVisitKeyHandlers | null = null;
8
+
9
+ /** Hands the notification keys to the strip while it shows; returns the release. */
10
+ export function bindSinceLastVisitKeys(handlers: SinceLastVisitKeyHandlers): () => void {
11
+ keyHandlers = handlers;
12
+ return () => {
13
+ if (keyHandlers === handlers) keyHandlers = null;
14
+ };
15
+ }
16
+
17
+ /**
18
+ * Runs the strip's open (its biggest move) or hide for the notification keys.
19
+ * False when the strip is not showing, so the key goes on to whatever else wants it.
20
+ */
21
+ export function pressSinceLastVisitKey(kind: "open" | "dismiss"): boolean {
22
+ if (!keyHandlers) return false;
23
+ if (kind === "open") keyHandlers.open();
24
+ else keyHandlers.dismiss();
25
+ return true;
26
+ }