@gloom-sh/terminal 0.20.10 → 0.20.12
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/package.json +2 -1
- package/patches/@opentui%2Fcore@0.3.2.patch +16 -0
- package/src/api-client/awards.ts +16 -0
- package/src/api-client/central-bank-rates.ts +5 -0
- package/src/api-client/data.ts +55 -2
- package/src/api-client/index.ts +18 -1
- package/src/api-client/request.ts +86 -3
- package/src/api-client/socket-connection.ts +366 -0
- package/src/api-client/socket-features.ts +75 -0
- package/src/api-client/socket-frames.ts +161 -0
- package/src/api-client/socket-listeners.ts +207 -0
- package/src/api-client/socket-quotes.ts +332 -0
- package/src/api-client/socket.ts +168 -983
- package/src/api-client/supply-chain-graph.ts +4 -2
- package/src/api-client/supply-chain.ts +8 -0
- package/src/api-client/types/econ.ts +10 -7
- package/src/api-client/types/filings-and-calls.ts +8 -0
- package/src/app/global-shortcuts.ts +2 -1
- package/src/app/keybindings/actions.ts +19 -0
- package/src/app/pane-runtime/index.tsx +18 -3
- package/src/app/pane-runtime/layout-placement.ts +63 -0
- package/src/app/pane-runtime/ticker-open-runtime.ts +10 -2
- package/src/brokers/signed-in/adapter.ts +19 -5
- package/src/brokers/signed-in/client.ts +13 -1
- package/src/brokers/signed-in/sign-in-dialog.tsx +33 -9
- package/src/capabilities/chart-series.ts +4 -1
- package/src/cli/board-coins.ts +10 -1
- package/src/cli/commands/crypto-hints.ts +3 -2
- package/src/cli/commands/fred-series.ts +0 -54
- package/src/cli/commands/market.ts +209 -31
- package/src/cli/commands/overview.ts +47 -14
- package/src/cli/commands/search.ts +37 -8
- package/src/cli/commands/ticker.ts +15 -4
- package/src/cli/desktop-pane-shot.ts +27 -2
- package/src/cli/fx-quote-rate.ts +1 -1
- package/src/cli/glossary.ts +14 -5
- package/src/cli/history-catalog-series.ts +85 -0
- package/src/cli/index.ts +1 -1
- package/src/cli/list-progress.ts +45 -0
- package/src/cli/listing-arg.ts +71 -7
- package/src/cli/name-entries.ts +8 -4
- package/src/cli/not-a-ticker.ts +2 -2
- package/src/cli/pane-functions/freshness.ts +50 -3
- package/src/cli/pane-functions/index.ts +7 -4
- package/src/cli/pane-functions/market-session.ts +66 -14
- package/src/cli/pane-functions/options.ts +5 -0
- package/src/cli/pane-functions/resolver.ts +9 -2
- package/src/cli/pane-functions/screenshot-assessment.ts +28 -3
- package/src/cli/pane-functions/screenshot-types.ts +6 -0
- package/src/cli/quote-answer.ts +49 -10
- package/src/cli/quote-list-reads.ts +87 -0
- package/src/cli/report-tables.ts +70 -13
- package/src/cli/result.ts +24 -2
- package/src/cli/symbol-list.ts +31 -4
- package/src/cli/terminal-code-hints.ts +83 -0
- package/src/cli/ticker-resolution.ts +2 -1
- package/src/cli/treasury-yields.ts +5 -0
- package/src/components/chart/native/kitty/manager.ts +2 -0
- package/src/components/chart/native/surface/manager.ts +211 -11
- package/src/components/command-bar/action-runtime.ts +2 -0
- package/src/components/command-bar/panel/index.tsx +2 -13
- package/src/components/command-bar/panel/layout.ts +1 -7
- package/src/components/command-bar/panel/runtime.ts +0 -1
- package/src/components/command-bar/panel/types.ts +0 -2
- package/src/components/command-bar/routing/launch-request.ts +2 -1
- package/src/components/command-bar/routing/navigation-state.ts +4 -2
- package/src/components/command-bar/workflow/types.ts +6 -0
- package/src/components/data-table/column-menu.tsx +89 -0
- package/src/components/data-table/sort-menu.tsx +9 -2
- package/src/components/data-table/view.tsx +33 -6
- package/src/components/form-modal/content.tsx +10 -0
- package/src/components/index.ts +1 -1
- package/src/components/layout/detached-pane-shell.tsx +3 -0
- package/src/components/layout/double-escape-close.ts +34 -3
- package/src/components/layout/floating-pane.tsx +10 -4
- package/src/components/layout/pane/cycle-order.ts +66 -2
- package/src/components/layout/pane/footer/index.tsx +25 -11
- package/src/components/layout/pane/footer/model.ts +62 -20
- package/src/components/layout/pane/header.tsx +140 -31
- package/src/components/layout/pane/sidebar.tsx +138 -20
- package/src/components/layout/pane/status-footer.ts +3 -1
- package/src/components/layout/shell/active-drag.ts +18 -13
- package/src/components/layout/shell/drag/magnets.ts +34 -18
- package/src/components/layout/shell/drag/runtime.ts +5 -0
- package/src/components/layout/shell/index.tsx +25 -0
- package/src/components/layout/shell/menu.ts +9 -0
- package/src/components/layout/shell/pane/actions.ts +36 -0
- package/src/components/layout/shell/pane/management-shortcuts.ts +27 -3
- package/src/components/layout/shell/pane-occlusion.ts +40 -0
- package/src/components/layout/shell/shortcuts.ts +17 -1
- package/src/components/layout/shell/terminal-pointer-runtime.ts +39 -6
- package/src/components/layout/shell/window-mode/index.ts +5 -16
- package/src/components/layout/shell/window-mode/overlays.tsx +3 -1
- package/src/components/market-board/index.tsx +14 -5
- package/src/components/metric-treemap/index.tsx +3 -1
- package/src/components/ticker/list-table-view.tsx +5 -0
- package/src/components/ui/button.tsx +48 -4
- package/src/components/ui/data-table/column-order.ts +180 -0
- package/src/components/ui/data-table/index.tsx +12 -1
- package/src/components/ui/data-table/opentui/index.tsx +291 -32
- package/src/components/ui/data-table/opentui/model.ts +43 -4
- package/src/components/ui/data-table/types.ts +56 -0
- package/src/components/ui/data-table/use-column-order.ts +135 -0
- package/src/components/ui/index.ts +1 -1
- package/src/components/ui/inline-quick-add.tsx +19 -3
- package/src/components/ui/list-view.tsx +11 -5
- package/src/components/ui/query-bar.tsx +16 -1
- package/src/components/ui/selection-fill.ts +39 -0
- package/src/components/ui/table-layout.ts +120 -0
- package/src/core/state/app/layout-reducer.ts +2 -1
- package/src/core/state/app/pane-choices.ts +68 -0
- package/src/core/state/app/state.ts +14 -6
- package/src/core/state/app/types.ts +8 -0
- package/src/docs/snapshot.json +3 -2
- package/src/i18n/es.ts +2 -0
- package/src/i18n/ja.ts +2 -0
- package/src/i18n/ko.ts +2 -0
- package/src/i18n/zh-cn.ts +2 -0
- package/src/i18n/zh-tw.ts +2 -0
- package/src/layout/pane-manager/dock-tree.ts +19 -0
- package/src/layout/pane-manager/index.ts +3 -0
- package/src/market-data/coordinator/index.ts +4 -3
- package/src/market-data/coordinator/quotes.ts +12 -4
- package/src/market-data/market/freshness.ts +33 -0
- package/src/market-data/market/status.ts +5 -1
- package/src/market-data/quotes/contributions.ts +10 -0
- package/src/market-data/quotes/freshness.ts +31 -0
- package/src/market-data/quotes/live-valuation.ts +32 -5
- package/src/market-data/quotes/regular-session-valuation.ts +1 -1
- package/src/market-data/quotes/resolution.ts +4 -0
- package/src/market-data/quotes/time.ts +0 -14
- package/src/plugins/builtin/account-management/index.tsx +1 -0
- package/src/plugins/builtin/awards/detail.tsx +12 -4
- package/src/plugins/builtin/awards/headless.ts +29 -8
- package/src/plugins/builtin/awards/model.ts +36 -2
- package/src/plugins/builtin/awards/pane.tsx +7 -4
- package/src/plugins/builtin/broker-manager/detail.tsx +5 -3
- package/src/plugins/builtin/broker-manager/index.tsx +7 -6
- package/src/plugins/builtin/broker-manager/model.ts +15 -6
- package/src/plugins/builtin/broker-manager/pane-actions.tsx +11 -4
- package/src/plugins/builtin/broker-manager/sign-in-end.ts +50 -19
- package/src/plugins/builtin/broker-manager/table.ts +10 -4
- package/src/plugins/builtin/broker-trading/index.tsx +1 -1
- package/src/plugins/builtin/central-bank-rates/headless.ts +6 -6
- package/src/plugins/builtin/central-bank-rates/index.tsx +1 -1
- package/src/plugins/builtin/central-bank-rates/model.ts +21 -3
- package/src/plugins/builtin/central-bank-rates/pane.tsx +15 -5
- package/src/plugins/builtin/chart-composer/headless.ts +5 -1
- package/src/plugins/builtin/chart-composer/pane.tsx +1 -0
- package/src/plugins/builtin/chat/content/handle-prompt.tsx +4 -0
- package/src/plugins/builtin/chat/controller/realtime.ts +17 -1
- package/src/plugins/builtin/chat/message/terminal.tsx +4 -1
- package/src/plugins/builtin/chat/sidebar.tsx +35 -19
- package/src/plugins/builtin/cloud/askg/pane.tsx +4 -0
- package/src/plugins/builtin/cloud/askg/tool-timeline.tsx +2 -0
- package/src/plugins/builtin/cloud/plugin.tsx +1 -0
- package/src/plugins/builtin/cloud/team/module.tsx +1 -0
- package/src/plugins/builtin/cloud/thesis/detail.tsx +9 -4
- package/src/plugins/builtin/commodity-balances/pane.tsx +13 -5
- package/src/plugins/builtin/company-kpis/model.ts +3 -3
- package/src/plugins/builtin/connections/index.ts +1 -0
- package/src/plugins/builtin/credit-boards/cdx-pane.tsx +9 -5
- package/src/plugins/builtin/credit-boards/client.ts +5 -0
- package/src/plugins/builtin/credit-boards/headless.ts +1 -6
- package/src/plugins/builtin/credit-boards/model.ts +0 -6
- package/src/plugins/builtin/credit-boards/series.ts +19 -8
- package/src/plugins/builtin/credit-boards/sovr-pane.tsx +9 -5
- package/src/plugins/builtin/crypto-etf-flows/headless.ts +23 -13
- package/src/plugins/builtin/crypto-etf-flows/pane.tsx +8 -3
- package/src/plugins/builtin/debt-maturities/headless.ts +16 -7
- package/src/plugins/builtin/debt-maturities/model.ts +9 -15
- package/src/plugins/builtin/debt-maturities/pane.tsx +9 -10
- package/src/plugins/builtin/earnings/board-model.ts +33 -4
- package/src/plugins/builtin/earnings/board.tsx +15 -3
- package/src/plugins/builtin/earnings/calendar.tsx +10 -6
- package/src/plugins/builtin/earnings/client.ts +0 -9
- package/src/plugins/builtin/earnings/headless.ts +10 -7
- package/src/plugins/builtin/earnings/history.tsx +21 -14
- package/src/plugins/builtin/earnings-calls/data.ts +24 -4
- package/src/plugins/builtin/earnings-calls/format.ts +23 -5
- package/src/plugins/builtin/earnings-calls/headless.ts +23 -3
- package/src/plugins/builtin/earnings-calls/index.tsx +1 -0
- package/src/plugins/builtin/earnings-calls/model.ts +11 -1
- package/src/plugins/builtin/earnings-calls/pane.tsx +2 -5
- package/src/plugins/builtin/econ/calendar-model.ts +27 -0
- package/src/plugins/builtin/econ/fred-catalog.ts +3 -0
- package/src/plugins/builtin/econ/index.tsx +9 -2
- package/src/plugins/builtin/econ-statistics/headless.ts +3 -1
- package/src/plugins/builtin/econ-statistics/index.tsx +1 -1
- package/src/plugins/builtin/equity-screener/live.ts +74 -18
- package/src/plugins/builtin/equity-screener/model.ts +19 -4
- package/src/plugins/builtin/equity-screener/pane.tsx +19 -14
- package/src/plugins/builtin/equity-screener/refresh-anchor.ts +45 -0
- package/src/plugins/builtin/equity-screener/results.ts +22 -2
- package/src/plugins/builtin/equity-screener/screen-check.ts +9 -3
- package/src/plugins/builtin/fear-greed/headless.ts +16 -13
- package/src/plugins/builtin/fear-greed/pane.tsx +12 -4
- package/src/plugins/builtin/filing-events/index.tsx +1 -0
- package/src/plugins/builtin/futures/index.tsx +15 -1
- package/src/plugins/builtin/futures/table.tsx +1 -1
- package/src/plugins/builtin/fx-matrix/index.tsx +32 -19
- package/src/plugins/builtin/holders/pane.tsx +30 -20
- package/src/plugins/builtin/insider/table.tsx +10 -7
- package/src/plugins/builtin/insider/tickers.tsx +1 -1
- package/src/plugins/builtin/iv-history/events.ts +5 -0
- package/src/plugins/builtin/iv-history/headless.ts +15 -9
- package/src/plugins/builtin/jobs/index.tsx +1 -0
- package/src/plugins/builtin/kelly-sizer/sections.tsx +2 -0
- package/src/plugins/builtin/macro-day/headless.ts +15 -6
- package/src/plugins/builtin/macro-day/model.ts +1 -1
- package/src/plugins/builtin/macro-day/releases.ts +25 -16
- package/src/plugins/builtin/market-movers/index.tsx +20 -8
- package/src/plugins/builtin/market-movers/model.ts +5 -0
- package/src/plugins/builtin/market-movers/session-body.tsx +2 -1
- package/src/plugins/builtin/money-markets/headless.ts +12 -2
- package/src/plugins/builtin/money-markets/pane.tsx +10 -1
- package/src/plugins/builtin/options/view.tsx +3 -0
- package/src/plugins/builtin/options-positioning/pane.tsx +1 -1
- package/src/plugins/builtin/options-scenario/pane.tsx +2 -1
- package/src/plugins/builtin/perps/cascade-tabs.tsx +2 -1
- package/src/plugins/builtin/portfolio-list/cli/bulk-symbols.ts +4 -31
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +19 -1
- package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +22 -8
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +6 -8
- package/src/plugins/builtin/portfolio-list/table.tsx +15 -1
- package/src/plugins/builtin/rate-path/pane.tsx +2 -0
- package/src/plugins/builtin/realized-vol/headless.ts +28 -2
- package/src/plugins/builtin/revenue-breakdown/pane.tsx +2 -0
- package/src/plugins/builtin/reverse-dcf/pane.tsx +2 -1
- package/src/plugins/builtin/risk-factors/index.tsx +1 -0
- package/src/plugins/builtin/seasonality/pane.tsx +2 -1
- package/src/plugins/builtin/shared/source-footer.ts +70 -0
- package/src/plugins/builtin/short-interest/publications-pane.tsx +5 -1
- package/src/plugins/builtin/short-volume/pane.tsx +5 -1
- package/src/plugins/builtin/social-mentions/outliers.tsx +10 -1
- package/src/plugins/builtin/social-mentions/pane.tsx +7 -0
- package/src/plugins/builtin/supply-chain/client.ts +3 -1
- package/src/plugins/builtin/supply-chain/flow.tsx +25 -8
- package/src/plugins/builtin/supply-chain/graph-client.ts +1 -1
- package/src/plugins/builtin/supply-chain/graph-evidence.ts +1 -1
- package/src/plugins/builtin/supply-chain/graph-model.ts +12 -1
- package/src/plugins/builtin/supply-chain/graph-pane.tsx +9 -8
- package/src/plugins/builtin/supply-chain/graph.tsx +12 -6
- package/src/plugins/builtin/supply-chain/headless.ts +13 -7
- package/src/plugins/builtin/supply-chain/model.ts +68 -11
- package/src/plugins/builtin/supply-chain/pane.tsx +9 -6
- package/src/plugins/builtin/supply-chain/row-evidence.tsx +5 -5
- package/src/plugins/builtin/thirteenf/pane.tsx +2 -0
- package/src/plugins/builtin/ticker-detail/financials/model.ts +28 -6
- package/src/plugins/builtin/ticker-detail/financials/ratio-table.tsx +26 -9
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +58 -35
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +14 -1
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +2 -0
- package/src/plugins/builtin/ticker-detail/pane.tsx +48 -24
- package/src/plugins/builtin/ticker-detail/quote-footer.ts +5 -0
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +6 -3
- package/src/plugins/builtin/treasury-auctions/after.ts +50 -23
- package/src/plugins/builtin/treasury-auctions/cache.ts +23 -5
- package/src/plugins/builtin/treasury-auctions/headless.ts +226 -37
- package/src/plugins/builtin/treasury-auctions/hk-headless.ts +11 -5
- package/src/plugins/builtin/treasury-auctions/hk-view.tsx +27 -25
- package/src/plugins/builtin/treasury-auctions/hk.ts +60 -8
- package/src/plugins/builtin/treasury-auctions/index.tsx +3 -0
- package/src/plugins/builtin/treasury-auctions/keys.ts +27 -0
- package/src/plugins/builtin/treasury-auctions/like.ts +137 -0
- package/src/plugins/builtin/treasury-auctions/model.ts +100 -22
- package/src/plugins/builtin/treasury-auctions/pane.tsx +39 -11
- package/src/plugins/builtin/vol-surface/heat-grid.tsx +6 -3
- package/src/plugins/builtin/vol-surface/pane.tsx +7 -3
- package/src/plugins/builtin/world-indices/index.tsx +5 -1
- package/src/plugins/builtin/yield-curve/index.tsx +2 -1
- package/src/plugins/runtime/index.tsx +1 -0
- package/src/plugins/runtime/state.ts +20 -0
- package/src/portfolio/column-values.ts +8 -2
- package/src/public/__snapshots__/public-api.test.ts.snap +5 -0
- package/src/public/react.ts +7 -0
- package/src/react/auto-refresh.ts +29 -0
- package/src/renderers/browser/deeplink-bridge.ts +24 -3
- package/src/renderers/dom/data-table/column-drag.ts +147 -0
- package/src/renderers/dom/data-table/index.tsx +22 -0
- package/src/renderers/dom/data-table/row.tsx +27 -5
- package/src/renderers/dom/desktop/query-bar.tsx +229 -60
- package/src/renderers/dom/host/overflow-fade-px.ts +2 -0
- package/src/renderers/dom/host/overflow-fade.ts +1 -2
- package/src/renderers/dom/styles.css +47 -5
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +2 -1
- package/src/renderers/opentui/chart-surface.tsx +1 -0
- package/src/renderers/opentui/frame-hits.ts +33 -0
- package/src/renderers/opentui/host.tsx +2 -0
- package/src/renderers/opentui/native-surface.ts +14 -21
- package/src/renderers/opentui/test-utils.tsx +3 -0
- package/src/series/types.ts +2 -0
- package/src/sources/gloomberb-cloud/fred-attribution.ts +86 -0
- package/src/sources/gloomberb-cloud/index.ts +25 -1
- package/src/sources/gloomberb-cloud/normalizers.ts +22 -3
- package/src/sources/provider-errors.ts +64 -1
- package/src/sources/provider-router/batches.ts +19 -0
- package/src/sources/provider-router/index.ts +7 -1
- package/src/state/app/context/index.tsx +46 -1
- package/src/state/pane-unsent-work.ts +47 -0
- package/src/test-support/app-store.ts +24 -1
- package/src/test-support/shell-pane-keys.tsx +5 -0
- package/src/test-support/telemetry-guard.ts +83 -0
- package/src/test-support/test-env.ts +12 -0
- package/src/theme/colors.ts +17 -1
- package/src/theme/ui-tokens.ts +50 -1
- package/src/tickers/listing-venues.ts +11 -1
- package/src/tickers/search/japanese-names.json +1 -0
- package/src/tickers/search/japanese-names.ts +152 -0
- package/src/tickers/terminal-codes.ts +55 -6
- package/src/time-series/base-series.ts +3 -0
- package/src/time-series/live-quotes.ts +3 -9
- package/src/types/data-provider.ts +6 -0
- package/src/types/financials.ts +11 -0
- package/src/types/plugin-contributions.ts +7 -0
- package/src/types/plugin-panes.ts +7 -0
- package/src/ui/host.tsx +24 -0
- package/src/ui/pointer-drag.ts +11 -2
- package/src/utils/double-escape-close.ts +42 -0
- package/src/utils/fundamentals.ts +14 -3
- package/src/utils/fx-status.ts +30 -7
- package/src/utils/network-failure.ts +23 -0
- package/src/utils/share-multiples.cases.json +780 -2
- package/src/utils/share-multiples.ts +154 -24
|
@@ -4,7 +4,8 @@ import type { HeadlessBundleSection, HeadlessPaneColumn, HeadlessPaneContext, He
|
|
|
4
4
|
import { DATE_OPTION_EXAMPLES, isoDateOption } from "../../../utils/calendar-date";
|
|
5
5
|
import { resolveHeadlessInstrument } from "../shared/headless-market-data";
|
|
6
6
|
import { fetchAward, fetchAwards } from "./client";
|
|
7
|
-
import { AWARD_TABS, awardsAttributions, awardScope, awardsCoverageNotes, awardsEmptyReason, awardsPreviewNote, awardTypeLabel,
|
|
7
|
+
import { AWARD_TABS, amountWithheld, awardsAmountNotices, awardsAttributions, awardScope, awardsCoverageNotes, awardsEmptyReason, awardsPreviewNote, awardTypeLabel,
|
|
8
|
+
futureAwardDatesNote, money, statementText, WITHHELD_AMOUNT } from "./model";
|
|
8
9
|
import { REPORT_PAGE, REPORT_ROWS } from "../shared/headless-options";
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -23,7 +24,15 @@ async function notATicker(ticker: string, ctx: HeadlessPaneContext): Promise<str
|
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
/** Marks a value its source withholds (GeBIZ's "under S$6,000"), with why; never an unreported one. */
|
|
28
|
+
const withheldFields = (row: Pick<AwardRow, "awardAmount" | "amountWithheld">) => {
|
|
29
|
+
const why = amountWithheld(row);
|
|
30
|
+
return why ? { valueWithheld: true, amountWithheld: why } : {};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** An award as a report row; `valueWithheld` marks a value its source withholds (GeBIZ), never an unreported one. */
|
|
26
34
|
const awardRecord = (row: AwardRow) => ({ id: row.id, date: row.awardDate, dateBasis: row.dateBasis ?? "award", dataBasis: row.dataBasis ?? null,
|
|
35
|
+
...withheldFields(row),
|
|
27
36
|
fieldAsOf: row.fieldAsOf ?? null, fieldSourceUrls: row.fieldSourceUrls ?? null, recipient: row.recipient.name, ticker: row.entity?.ticker ?? null,
|
|
28
37
|
classifications: row.classifications ?? [],
|
|
29
38
|
agency: row.agency.name, jurisdiction: row.jurisdiction, type: row.awardType, currency: row.currency,
|
|
@@ -52,7 +61,7 @@ const dateBasis = (value: unknown) => value === "period-start" ? "Period start"
|
|
|
52
61
|
const comparison = (row: HeadlessPaneRow) => row.revenueComparison as { awardAmount?: string; annualRevenue?: string; basis?: string; periodEnd?: string } | null;
|
|
53
62
|
const FEED_COLUMNS: HeadlessPaneColumn[] = [
|
|
54
63
|
{ key: "date", header: "Date" }, { key: "recipient", header: "Awardee" }, { key: "ticker", header: "Ticker" }, { key: "currency", header: "CCY" },
|
|
55
|
-
amount("value", "Value"), amount("obligated", "Obligated"), amount("ceiling", "Ceiling"), { key: "agency", header: "Agency" }, { key: "jurisdiction", header: "Country" },
|
|
64
|
+
{ ...amount("value", "Value"), textFormat: (value, row) => value == null && row.valueWithheld ? WITHHELD_AMOUNT : money(value as string | null) }, amount("obligated", "Obligated"), amount("ceiling", "Ceiling"), { key: "agency", header: "Agency" }, { key: "jurisdiction", header: "Country" },
|
|
56
65
|
{ key: "performancePeriod", header: "Performance period", format: period }, { key: "title", header: "Contract" }, { key: "dateBasis", header: "Date basis", format: dateBasis },
|
|
57
66
|
];
|
|
58
67
|
const EVENT_COLUMNS: HeadlessPaneColumn[] = [
|
|
@@ -71,7 +80,9 @@ const aggregateColumns = (label: string): HeadlessPaneColumn[] => [{ key: "label
|
|
|
71
80
|
const LEADER_COLUMNS: HeadlessPaneColumn[] = [{ key: "label", header: "Company" }, { key: "ticker", header: "Ticker" }, { key: "currency", header: "CCY" }, share,
|
|
72
81
|
amount("awardAmount", "Value"), amount("obligatedAmount", "Obligated"), count, { key: "sector", header: "Sector" }, amount("ceilingAmount", "Ceiling"), scope];
|
|
73
82
|
const REVISION_COLUMNS: HeadlessPaneColumn[] = [{ key: "observedAt", header: "Observed" }, { key: "sourceUpdatedAt", header: "Source updated" }, { key: "supersedes", header: "Supersedes" },
|
|
74
|
-
nested((row) => (row.award as AwardRow | undefined)?.awardAmount, "awardAmount", "Value"),
|
|
83
|
+
{ ...nested((row) => (row.award as AwardRow | undefined)?.awardAmount, "awardAmount", "Value"),
|
|
84
|
+
textFormat: (_value, row) => row.valueWithheld ? WITHHELD_AMOUNT : money((row.award as AwardRow | undefined)?.awardAmount ?? null) },
|
|
85
|
+
nested((row) => (row.award as AwardRow | undefined)?.obligatedAmount, "obligatedAmount", "Obligated"),
|
|
75
86
|
{ key: "award", header: "Contract", format: (value) => text((value as AwardRow | undefined)?.title) }];
|
|
76
87
|
const EDGE_COLUMNS: HeadlessPaneColumn[] = [{ key: "kind", header: "Kind" }, { key: "from", header: "From", format: (value) => text((value as { name?: string } | null)?.name) },
|
|
77
88
|
{ key: "to", header: "To", format: (value) => text((value as { name?: string } | null)?.name) }, { key: "currency", header: "CCY" }, amount("amount", "Amount"), { key: "awardId", header: "Award" }];
|
|
@@ -101,10 +112,15 @@ export const awardsHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
101
112
|
async load(args, ctx) {
|
|
102
113
|
if (args.options.award) {
|
|
103
114
|
const detail = await fetchAward(String(args.options.award), ctx.apiClient, ctx.signal, args.options.revisionsCursor ? String(args.options.revisionsCursor) : undefined);
|
|
115
|
+
// The award's source's statements: its licence's, and how its amounts read when one it prints is withheld.
|
|
116
|
+
const withheld = [detail.row, ...detail.revisions.map((revision) => revision.award), ...detail.subawards, ...detail.modifications]
|
|
117
|
+
.some((row) => row && amountWithheld(row));
|
|
118
|
+
const notes = [statementText(detail.attribution), withheld ? statementText(detail.amountNotice) : ""].filter(Boolean);
|
|
104
119
|
return { complete: !detail.locked && !detail.nextRevisionsCursor && !Object.values(detail.truncated ?? {}).some(Boolean), sections: [{ title: "Award", columns: FEED_COLUMNS, rows: detail.row ? [awardRecord(detail.row)] : [] },
|
|
105
|
-
{ title: "Revisions", columns: REVISION_COLUMNS, rows: detail.revisions.map((row) => ({ ...row })) },
|
|
120
|
+
{ title: "Revisions", columns: REVISION_COLUMNS, rows: detail.revisions.map((row) => ({ ...row, ...withheldFields(row.award) })) },
|
|
106
121
|
{ title: "Subawards", columns: FEED_COLUMNS, rows: detail.subawards.map(awardRecord) }, { title: "Modifications", columns: FEED_COLUMNS, rows: detail.modifications.map(awardRecord) },
|
|
107
|
-
{ title: "Relationships", columns: EDGE_COLUMNS, rows: detail.edges.map((row) => ({ ...row })) }],
|
|
122
|
+
{ title: "Relationships", columns: EDGE_COLUMNS, rows: detail.edges.map((row) => ({ ...row })) }], ...(notes.length ? { notes } : {}),
|
|
123
|
+
metadata: { access: detail.access, locked: detail.locked, nextRevisionsCursor: detail.nextRevisionsCursor, truncated: detail.truncated } };
|
|
108
124
|
}
|
|
109
125
|
const filter: AwardFilter = { ticker: args.rawArgument.trim().toUpperCase() || undefined, awardType: args.options.type as AwardFilter["awardType"], limit: Number(args.options.limit ?? 100) };
|
|
110
126
|
for (const key of [...FILTER_KEYS, "cursor"] as const) if (args.options[key]) filter[key] = String(args.options[key]);
|
|
@@ -118,15 +134,20 @@ export const awardsHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
118
134
|
const printed = [...(["feed", "company", "all"].includes(tab) ? data.rows : []), ...(["company", "all"].includes(tab) ? data.history : []),
|
|
119
135
|
...(["agencies", "all"].includes(tab) ? data.agencies : []), ...(["sectors", "all"].includes(tab) ? [...(data.leaders ?? []), ...data.sectors] : []),
|
|
120
136
|
...(["events", "all"].includes(tab) ? data.alerts : [])];
|
|
121
|
-
const
|
|
137
|
+
const record = awardRecord;
|
|
138
|
+
// How a withheld value reads, under the awards that print one.
|
|
139
|
+
const withheld = [...(["feed", "company", "all"].includes(tab) ? data.rows : []), ...(["events", "all"].includes(tab) ? data.alerts : [])]
|
|
140
|
+
.filter((row) => amountWithheld(row)).map((row) => row.source);
|
|
141
|
+
const notes = [...awardsCoverageNotes(data), ...(futureDates ? [futureDates] : []), ...awardsAttributions(data, printed.map((row) => row.source)),
|
|
142
|
+
...awardsAmountNotices(data, withheld)];
|
|
122
143
|
const empty = awardsEmptyReason(data);
|
|
123
144
|
const sections: HeadlessBundleSection[] = [];
|
|
124
|
-
if (tab === "feed" || tab === "company" || tab === "all") sections.push({ title: "Awards", columns: FEED_COLUMNS, rows: data.rows.map(
|
|
145
|
+
if (tab === "feed" || tab === "company" || tab === "all") sections.push({ title: "Awards", columns: FEED_COLUMNS, rows: data.rows.map(record) });
|
|
125
146
|
if (tab === "company" || tab === "all") sections.push({ title: "Award cohorts by month and currency", columns: COHORT_COLUMNS, rows: data.history.map((row) => ({ ...row })) });
|
|
126
147
|
if (tab === "agencies" || tab === "all") sections.push({ title: "Agency concentration", columns: aggregateColumns("Agency"), rows: data.agencies.map((row) => ({ ...row })) });
|
|
127
148
|
if (tab === "sectors" || tab === "all") sections.push({ title: "Sector company leaders", columns: LEADER_COLUMNS, rows: (data.leaders ?? []).map((row) => ({ ...row })) },
|
|
128
149
|
{ title: "Sector totals", columns: aggregateColumns("Sector"), rows: data.sectors.map((row) => ({ ...row })) });
|
|
129
|
-
if (tab === "events" || tab === "all") sections.push({ title: "Awards relative to annual revenue", columns: EVENT_COLUMNS, rows: data.alerts.map(
|
|
150
|
+
if (tab === "events" || tab === "all") sections.push({ title: "Awards relative to annual revenue", columns: EVENT_COLUMNS, rows: data.alerts.map(record) });
|
|
130
151
|
return { complete: !data.locked && !data.nextCursor && data.status === "available" && !Object.values(data.truncated ?? {}).some(Boolean), sections,
|
|
131
152
|
// Collection health is what the awards may be missing, a coverage note; only a failure is an error.
|
|
132
153
|
...(notes.length ? { notes } : {}),
|
|
@@ -91,9 +91,43 @@ export function awardsCoverageNotes(data: Pick<AwardsPayload, "gaps">): string[]
|
|
|
91
91
|
* award's detail and `fn AWARDS` print them under the awards they cover.
|
|
92
92
|
*/
|
|
93
93
|
export function awardsAttributions(data: Pick<AwardsPayload, "sources"> | undefined, shown: Iterable<string>): string[] {
|
|
94
|
+
return sourceStatements(data, shown, "attribution");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* How the amounts of the sources shown read, each once: GeBIZ's says it
|
|
99
|
+
* withholds an amount under S$6,000 or one that several suppliers of a tender
|
|
100
|
+
* print alike. The award's detail and `fn AWARDS` print them beside a
|
|
101
|
+
* withheld value.
|
|
102
|
+
*/
|
|
103
|
+
export function awardsAmountNotices(data: Pick<AwardsPayload, "sources"> | undefined, shown: Iterable<string>): string[] {
|
|
104
|
+
return sourceStatements(data, shown, "amountNotice");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function sourceStatements(data: Pick<AwardsPayload, "sources"> | undefined, shown: Iterable<string>, key: "attribution" | "amountNotice"): string[] {
|
|
94
108
|
const sources = new Set(shown);
|
|
95
|
-
return [...new Set((data?.sources ?? []).flatMap((source) =>
|
|
96
|
-
|
|
109
|
+
return [...new Set((data?.sources ?? []).flatMap((source) => {
|
|
110
|
+
const statement = source[key];
|
|
111
|
+
return sources.has(source.source) && typeof statement === "string" && statement.trim() ? [statement.trim()] : [];
|
|
112
|
+
}))];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** What an award's value reads when its source withholds it, never 0 and never the unreported mark. */
|
|
116
|
+
export const WITHHELD_AMOUNT = "withheld";
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Why an award's value is withheld by its source rather than unreported, or
|
|
120
|
+
* null: the award's own reason (GeBIZ's "under S$6,000"), never its source's,
|
|
121
|
+
* so an amount the source never printed still reads unreported.
|
|
122
|
+
*/
|
|
123
|
+
export function amountWithheld(row: Pick<AwardRow, "awardAmount" | "amountWithheld">): string | null {
|
|
124
|
+
const why = row.amountWithheld;
|
|
125
|
+
return row.awardAmount == null && typeof why === "string" && why.trim() ? why.trim() : null;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** A source's statement as served, or nothing: an older or malformed answer's non-string is never read as one. */
|
|
129
|
+
export function statementText(value: unknown): string {
|
|
130
|
+
return typeof value === "string" ? value.trim() : "";
|
|
97
131
|
}
|
|
98
132
|
|
|
99
133
|
/** Award dates after the response's own date are the source's, not a mapping slip; they say so instead of passing as past awards. */
|
|
@@ -25,8 +25,8 @@ import { AwardDetail } from "./detail";
|
|
|
25
25
|
import { useAwardAlerts } from "./alerts";
|
|
26
26
|
import { AWARDS_UNAVAILABLE, fetchAwards, loadAward, loadAwards, validateAwards } from "./client";
|
|
27
27
|
import { useAwardsEvidence } from "./evidence";
|
|
28
|
-
import { AWARD_TABS, aggregateId, awardHistorySeries, awardPercent, awardPeriod, awardsAttributions, awardScope, awardsCoverageNotes, awardsPreviewNote,
|
|
29
|
-
futureAwardDatesNote, money, rankedAggregates } from "./model";
|
|
28
|
+
import { AWARD_TABS, aggregateId, amountWithheld, awardHistorySeries, awardPercent, awardPeriod, awardsAmountNotices, awardsAttributions, awardScope, awardsCoverageNotes, awardsPreviewNote,
|
|
29
|
+
awardTab, awardTypeLabel, futureAwardDatesNote, money, rankedAggregates, WITHHELD_AMOUNT } from "./model";
|
|
30
30
|
import { logFailure } from "../../../utils/log-failure";
|
|
31
31
|
|
|
32
32
|
type Item = { kind: "award"; row: AwardRow } | { kind: "aggregate"; row: AwardAggregate } | { kind: "leader"; row: AwardCompanyLeader } | { kind: "locked"; id: string }
|
|
@@ -202,6 +202,7 @@ function AwardsView({ width, height, focused, symbol }: PaneProps & { symbol: st
|
|
|
202
202
|
const attribution = awardsAttributions(data, shown.flatMap((item) => item.kind === "award" || item.kind === "aggregate" || item.kind === "leader" ? [item.row.source] : [])).join(" ");
|
|
203
203
|
const attributionRows = attribution ? wrapTextLines(attribution, Math.max(1, width - 2)).length : 0;
|
|
204
204
|
const openAttribution = openRow ? awardsAttributions(data, [openRow.source]).join(" ") : "";
|
|
205
|
+
const openAmountNotice = openRow ? awardsAmountNotices(data, [openRow.source]).join(" ") : "";
|
|
205
206
|
const { strip, rows: tabRows } = usePaneTabs(!denied ? { tabs: [...AWARD_TABS], activeValue: tab, onSelect: (value) => { setTab(value); setOpen(null); }, focused, dense: true } : null);
|
|
206
207
|
const bodyHeight = Math.max(3, height - tabRows);
|
|
207
208
|
const filters: QueryBarFilter[] = [
|
|
@@ -231,7 +232,7 @@ function AwardsView({ width, height, focused, symbol }: PaneProps & { symbol: st
|
|
|
231
232
|
return <Box width={width} height={height} flexDirection="column">
|
|
232
233
|
{strip}
|
|
233
234
|
<PageStackView focused={focused} detailOpen={!!openId} onBack={() => setOpen(null)} detailTitle={openRow ? truncateToDisplayWidth(openRow.title, Math.max(20, width - 16)) : "Award evidence"}
|
|
234
|
-
detailContent={openRow ? <AwardDetail key={openRow.id} row={openRow} accessKey={accessKey} width={width} height={bodyHeight - 1} focused={focused} openAward={setOpen} openUpgrade={openUpgrade} attribution={openAttribution}
|
|
235
|
+
detailContent={openRow ? <AwardDetail key={openRow.id} row={openRow} accessKey={accessKey} width={width} height={bodyHeight - 1} focused={focused} openAward={setOpen} openUpgrade={openUpgrade} attribution={openAttribution} amountNotice={openAmountNotice}
|
|
235
236
|
openChildren={(type) => { setParentId(openRow.id); setTicker(""); setSource(""); setQuery(""); setAgency(""); setSector(""); setCurrency(""); setJurisdiction(""); setRange("all"); setType(type); setOpen(null); setTab("feed"); }} />
|
|
236
237
|
: <PaneStatusBody loading={detail.loading} error={detail.error} empty={!detail.loading && !detail.error} emptyTitle="Award no longer available." subject="award evidence" />}
|
|
237
238
|
rootContent={<DataTableView<Item> columns={columns} items={tab === "company" && !ticker ? [] : items} rootWidth={width} rootHeight={bodyHeight}
|
|
@@ -261,7 +262,9 @@ function AwardsView({ width, height, focused, symbol }: PaneProps & { symbol: st
|
|
|
261
262
|
if (column.id === "currency") return { text: row.currency, color: colors.textDim };
|
|
262
263
|
if (["value", "obligated", "ceiling"].includes(column.id)) {
|
|
263
264
|
const value = column.id === "value" ? tab === "events" && item.kind === "award" ? item.row.revenueComparison?.awardAmount : row.awardAmount : column.id === "obligated" ? row.obligatedAmount : row.ceilingAmount;
|
|
264
|
-
|
|
265
|
+
if (value == null) return column.id === "value" && item.kind === "award" && tab !== "events" && amountWithheld(item.row)
|
|
266
|
+
? { text: WITHHELD_AMOUNT, value: null, color: colors.textMuted } : missingCell(colors);
|
|
267
|
+
return { text: money(value), value, color: column.id === "obligated" || column.id === "value" ? colors.textBright : colors.text };
|
|
265
268
|
}
|
|
266
269
|
if (item.kind === "aggregate" || item.kind === "leader") {
|
|
267
270
|
if (column.id === "label") return { text: item.row.label, color: colors.textBright };
|
|
@@ -317,7 +317,7 @@ export function BrokerDetailContent({
|
|
|
317
317
|
// The row's STATUS, and in full what the last action on the profile came to,
|
|
318
318
|
// which outranks the profile's own status message until it is news no more.
|
|
319
319
|
// The sign-in's end has a line of its own below.
|
|
320
|
-
const status = brokerRowStatus({ ...row,
|
|
320
|
+
const status = brokerRowStatus({ ...row, signInEnd: null }, activity);
|
|
321
321
|
const note = activity.note ?? null;
|
|
322
322
|
const detailStatusMessage = note?.text ?? (row.message || t("No status message."));
|
|
323
323
|
const statusMessageColor = note
|
|
@@ -340,8 +340,10 @@ export function BrokerDetailContent({
|
|
|
340
340
|
<Text fg={statusMessageColor} width={width} wrapText>
|
|
341
341
|
{detailStatusMessage}
|
|
342
342
|
</Text>
|
|
343
|
-
{row.
|
|
344
|
-
<Text fg={colors.warning} width={width} wrapText>
|
|
343
|
+
{row.signInEnd !== null && (
|
|
344
|
+
<Text fg={row.signInEnd.soon ? colors.warning : colors.textDim} width={width} wrapText>
|
|
345
|
+
{signInEndNote(row.signInEnd.endsAt)}
|
|
346
|
+
</Text>
|
|
345
347
|
)}
|
|
346
348
|
<Text fg={colors.textMuted}>{tf("Last sync {time}", { time: formatRelativeAge(row.lastSyncedAt) })}</Text>
|
|
347
349
|
{row.instance.localOnly ? <Text fg={colors.textMuted}>{t("Account data stays on this device, out of Gloom Cloud")}</Text> : null}
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
type BrokerProfileRow,
|
|
38
38
|
} from "./model";
|
|
39
39
|
import { useBrokerManagerActions } from "./pane-actions";
|
|
40
|
-
import {
|
|
40
|
+
import { useSignInReads } from "./sign-in-end";
|
|
41
41
|
import {
|
|
42
42
|
buildBrokerColumns,
|
|
43
43
|
renderBrokerCell,
|
|
@@ -82,10 +82,10 @@ export function BrokersPane({ focused, width, height }: PaneProps) {
|
|
|
82
82
|
|
|
83
83
|
// Signed-in profiles take their broker's name from the connector list.
|
|
84
84
|
const signedInBrokers = useSyncExternalStore(subscribeSignedInBrokers, getSignedInBrokers, getSignedInBrokers);
|
|
85
|
-
const {
|
|
85
|
+
const { reads: signInReads, reload: reloadSignInReads } = useSignInReads(config.brokerInstances);
|
|
86
86
|
const rows = useMemo(
|
|
87
|
-
() => buildBrokerProfileRows(config, adapters, brokerAccounts,
|
|
88
|
-
[adapters, brokerAccounts, brokerSyncErrors, config, getBrokerLogo, language,
|
|
87
|
+
() => buildBrokerProfileRows(config, adapters, brokerAccounts, signInReads, getBrokerLogo, brokerSyncErrors),
|
|
88
|
+
[adapters, brokerAccounts, brokerSyncErrors, config, getBrokerLogo, language, signInReads, signedInBrokers, statusVersion],
|
|
89
89
|
);
|
|
90
90
|
const selectedIndex = Math.max(0, rows.findIndex((row) => row.id === selectedId));
|
|
91
91
|
const selectedRow = rows[selectedIndex] ?? null;
|
|
@@ -115,8 +115,8 @@ export function BrokersPane({ focused, width, height }: PaneProps) {
|
|
|
115
115
|
// After a connect or sync, which can renew a sign-in or find it ended.
|
|
116
116
|
const refreshStatuses = useCallback(() => {
|
|
117
117
|
setStatusVersion((version) => version + 1);
|
|
118
|
-
|
|
119
|
-
}, [
|
|
118
|
+
reloadSignInReads();
|
|
119
|
+
}, [reloadSignInReads]);
|
|
120
120
|
|
|
121
121
|
const {
|
|
122
122
|
busy,
|
|
@@ -369,6 +369,7 @@ export const brokerManagerModule: PluginModule = {
|
|
|
369
369
|
reportFreshness: { status: "not-a-feed", basis: "broker connections", local: true },
|
|
370
370
|
defaultPosition: "right",
|
|
371
371
|
defaultMode: "floating",
|
|
372
|
+
utilityWindow: true,
|
|
372
373
|
defaultFloatingSize: { width: 92, height: 24 },
|
|
373
374
|
portableShare: {
|
|
374
375
|
private: { title: true, params: true, settings: true, state: true },
|
|
@@ -4,7 +4,8 @@ import type { AppConfig, BrokerInstanceConfig } from "../../../types/config";
|
|
|
4
4
|
import type { BrokerAccount } from "../../../types/trading";
|
|
5
5
|
import { formatCurrency } from "../../../utils/format";
|
|
6
6
|
import { t } from "../../../i18n";
|
|
7
|
-
import type {
|
|
7
|
+
import type { BrokerReplacePrompt } from "../../../brokers/signed-in/client";
|
|
8
|
+
import type { SignInEnd, SignInReads } from "./sign-in-end";
|
|
8
9
|
|
|
9
10
|
export type BrokerDisplayState =
|
|
10
11
|
| "disabled"
|
|
@@ -28,8 +29,14 @@ export interface BrokerProfileRow {
|
|
|
28
29
|
accountCount: number;
|
|
29
30
|
accountSummary: string;
|
|
30
31
|
accountIds: string[];
|
|
31
|
-
/** When the broker ends this profile's sign-in,
|
|
32
|
-
|
|
32
|
+
/** When the broker ends this profile's live sign-in, for a broker that ends it on a clock. */
|
|
33
|
+
signInEnd: SignInEnd | null;
|
|
34
|
+
/**
|
|
35
|
+
* Whether the broker will or may ask to replace the Gloom connection it
|
|
36
|
+
* lists when this profile signs in again, as Gloom says; undefined when
|
|
37
|
+
* Gloom has not said (a server that predates it, or no read yet).
|
|
38
|
+
*/
|
|
39
|
+
replacePrompt?: BrokerReplacePrompt | null;
|
|
33
40
|
/** The broker's logo for the desktop and the web (brokers/logos.ts); null draws its initial. */
|
|
34
41
|
logo: string | null;
|
|
35
42
|
instance: BrokerInstanceConfig;
|
|
@@ -123,7 +130,7 @@ export function buildBrokerProfileRows(
|
|
|
123
130
|
config: AppConfig,
|
|
124
131
|
adapters: ReadonlyMap<string, BrokerAdapter | null>,
|
|
125
132
|
brokerAccounts: Record<string, BrokerAccount[]>,
|
|
126
|
-
|
|
133
|
+
signInReads: SignInReads = new Map(),
|
|
127
134
|
pluginLogo: BrokerPluginLogo = () => null,
|
|
128
135
|
syncErrors: Readonly<Record<string, string>> = {},
|
|
129
136
|
): BrokerProfileRow[] {
|
|
@@ -163,9 +170,11 @@ export function buildBrokerProfileRows(
|
|
|
163
170
|
accountSummary: summarizeBrokerAccounts(accounts),
|
|
164
171
|
accountIds: accounts.map((account) => account.accountId),
|
|
165
172
|
// Say nothing next to a failure or a profile that does not connect.
|
|
166
|
-
|
|
173
|
+
signInEnd: state.state === "error" || state.state === "sign-in" || state.state === "disabled" || state.state === "unavailable"
|
|
167
174
|
? null
|
|
168
|
-
:
|
|
175
|
+
: signInReads.get(instance.id)?.end ?? null,
|
|
176
|
+
// Said for an ended sign-in too: it is the next sign-in the broker asks about.
|
|
177
|
+
replacePrompt: signInReads.get(instance.id)?.replacePrompt,
|
|
169
178
|
logo: brokerProfileLogo(instance, adapter, pluginLogo),
|
|
170
179
|
instance,
|
|
171
180
|
adapter,
|
|
@@ -182,12 +182,19 @@ export function useBrokerManagerActions({
|
|
|
182
182
|
const { id, label } = selectedRow;
|
|
183
183
|
startRowAction(id, t("Connecting…"));
|
|
184
184
|
try {
|
|
185
|
-
// A connected broker is connected again only by a new sign-in: this renews it before the broker ends it
|
|
186
|
-
// A row that says when the sign-in ends is renewable before this
|
|
187
|
-
|
|
185
|
+
// A connected broker is connected again only by a new sign-in: this renews it before the broker ends it,
|
|
186
|
+
// at any time, for a new full lifetime. A row that says when the sign-in ends is renewable before this
|
|
187
|
+
// session's first sync too.
|
|
188
|
+
const renew = selectedRow.state === "connected" || selectedRow.signInEnd !== null;
|
|
189
|
+
// What the broker will ask about the Gloom connection it lists, as Gloom says: also after the broker ended
|
|
190
|
+
// the sign-in on its clock, and not after another app took the account. A Gloom server that predates it
|
|
191
|
+
// says nothing; then a renewal of a single-connection broker is the one case known to ask.
|
|
192
|
+
const replace = selectedRow.replacePrompt !== undefined
|
|
193
|
+
? selectedRow.replacePrompt
|
|
194
|
+
: renew && broker.capabilities.singleConnection ? "will" : null;
|
|
188
195
|
let signedIn: boolean;
|
|
189
196
|
try {
|
|
190
|
-
signedIn = await requestBrokerSignIn(broker, { renew });
|
|
197
|
+
signedIn = await requestBrokerSignIn(broker, { renew, replace });
|
|
191
198
|
} catch (error) {
|
|
192
199
|
setRowNote(id, {
|
|
193
200
|
tone: "error",
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { useCallback, useMemo, useSyncExternalStore } from "react";
|
|
2
2
|
import { apiClient } from "../../../api-client";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
type BrokerReplacePrompt,
|
|
5
|
+
fetchSignedInBrokerConnection,
|
|
6
|
+
type SignedInBrokerConnection,
|
|
7
|
+
} from "../../../brokers/signed-in/client";
|
|
4
8
|
import { isSignedInBrokerProfile, signedInBrokerId } from "../../../brokers/signed-in/profile";
|
|
5
9
|
import { tf } from "../../../i18n";
|
|
6
10
|
import { useAsyncResource } from "../../../react/async-resource";
|
|
@@ -9,16 +13,41 @@ import { formatDetailDate, formatShortDate } from "../../../utils/datetime-forma
|
|
|
9
13
|
|
|
10
14
|
/**
|
|
11
15
|
* Some brokers end a sign-in on their own clock, however often it was
|
|
12
|
-
* refreshed
|
|
13
|
-
*
|
|
16
|
+
* refreshed (IBKR: seven days after consent). While such a sign-in is live the
|
|
17
|
+
* pane always says when it ends, and Connect renews it early; Gloom flags the
|
|
18
|
+
* last stretch (`soon`), when it is time to renew. A broker with no such
|
|
19
|
+
* clock, or a sign-in that is not live, has no end to show.
|
|
14
20
|
*/
|
|
15
|
-
export
|
|
21
|
+
export interface SignInEnd {
|
|
22
|
+
endsAt: number;
|
|
23
|
+
/** Gloom says it is time to renew: within its warning window, or past the end. */
|
|
24
|
+
soon: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** What Gloom says about a profile's sign-in: when it ends, and what the broker asks on the next one. */
|
|
28
|
+
export interface SignInRead {
|
|
29
|
+
end: SignInEnd | null;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the broker will or may ask to replace the Gloom connection it
|
|
32
|
+
* lists when the user signs in again; undefined from a Gloom server that
|
|
33
|
+
* predates it.
|
|
34
|
+
*/
|
|
35
|
+
replacePrompt?: BrokerReplacePrompt | null;
|
|
36
|
+
}
|
|
16
37
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
38
|
+
export type SignInReads = ReadonlyMap<string, SignInRead>;
|
|
39
|
+
|
|
40
|
+
/** When the broker ends the live sign-in, and whether Gloom says to renew it now. */
|
|
41
|
+
export function signInEndOf(connection: Pick<SignedInBrokerConnection, "expiresAt" | "expiresSoon">): SignInEnd | null {
|
|
42
|
+
if (!connection.expiresAt) return null;
|
|
20
43
|
const endsAt = Date.parse(connection.expiresAt);
|
|
21
|
-
return Number.isFinite(endsAt) ? endsAt : null;
|
|
44
|
+
return Number.isFinite(endsAt) ? { endsAt, soon: connection.expiresSoon === true } : null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** What Gloom says about the account's connection to a broker. */
|
|
48
|
+
export function signInReadOf(connection: SignedInBrokerConnection): SignInRead {
|
|
49
|
+
const end = signInEndOf(connection);
|
|
50
|
+
return "replacePrompt" in connection ? { end, replacePrompt: connection.replacePrompt ?? null } : { end };
|
|
22
51
|
}
|
|
23
52
|
|
|
24
53
|
/** The profile row's status, in the place of "Connected": "Ends Oct 10". */
|
|
@@ -34,13 +63,15 @@ export function signInEndNote(endsAt: number, now = Date.now()): string {
|
|
|
34
63
|
}
|
|
35
64
|
|
|
36
65
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
66
|
+
* What Gloom says about each signed-in profile's sign-in, by instance id: when
|
|
67
|
+
* it ends, for a broker that ends it on a clock, and whether the broker will
|
|
68
|
+
* ask to replace Gloom's connection on the next one. Read from Gloom when the
|
|
69
|
+
* pane opens and after a connect or sync; a failed read is the same as
|
|
70
|
+
* nothing to say.
|
|
40
71
|
*/
|
|
41
|
-
export function
|
|
72
|
+
export function useSignInReads(
|
|
42
73
|
instances: readonly BrokerInstanceConfig[],
|
|
43
|
-
): {
|
|
74
|
+
): { reads: SignInReads; reload: () => void } {
|
|
44
75
|
const profiles = useMemo(
|
|
45
76
|
() => instances.flatMap((instance) => isSignedInBrokerProfile(instance) && instance.enabled !== false
|
|
46
77
|
? [{ id: instance.id, broker: signedInBrokerId(instance) }]
|
|
@@ -59,7 +90,7 @@ export function useSignInEnds(
|
|
|
59
90
|
? async () => {
|
|
60
91
|
const reads = await Promise.all(brokerKey.split(",").map(async (broker) => {
|
|
61
92
|
try {
|
|
62
|
-
return [broker,
|
|
93
|
+
return [broker, signInReadOf(await fetchSignedInBrokerConnection(broker))] as const;
|
|
63
94
|
} catch {
|
|
64
95
|
return [broker, null] as const;
|
|
65
96
|
}
|
|
@@ -69,14 +100,14 @@ export function useSignInEnds(
|
|
|
69
100
|
: null, [brokerKey, signedIn]);
|
|
70
101
|
const { data, reload } = useAsyncResource(loader, { keepPreviousData: true });
|
|
71
102
|
|
|
72
|
-
const
|
|
73
|
-
const byInstance = new Map<string,
|
|
103
|
+
const reads = useMemo<SignInReads>(() => {
|
|
104
|
+
const byInstance = new Map<string, SignInRead>();
|
|
74
105
|
for (const profile of profiles) {
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
106
|
+
const read = data?.get(profile.broker);
|
|
107
|
+
if (read) byInstance.set(profile.id, read);
|
|
77
108
|
}
|
|
78
109
|
return byInstance;
|
|
79
110
|
}, [data, profiles]);
|
|
80
111
|
const refresh = useCallback(() => { reload(); }, [reload]);
|
|
81
|
-
return {
|
|
112
|
+
return { reads, reload: refresh };
|
|
82
113
|
}
|
|
@@ -45,15 +45,21 @@ export function buildBrokerColumns(width: number): BrokerColumn[] {
|
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* What a profile's STATUS says, in the table and atop its detail: the action
|
|
48
|
-
* running on it, then the one that just failed on it, then
|
|
49
|
-
*
|
|
48
|
+
* running on it, then the one that just failed on it, then when the broker
|
|
49
|
+
* ends its sign-in, then its own state ("Disabled", "Sign-in needed").
|
|
50
50
|
*/
|
|
51
51
|
export function brokerRowStatus(row: BrokerProfileRow, activity: BrokerRowActivity = {}): { text: string; color: string } {
|
|
52
52
|
if (activity.busy) return { text: activity.busy, color: colors.warning };
|
|
53
53
|
// A sign-in the broker wants says more than which step ran into it.
|
|
54
54
|
if (activity.note?.status && row.state !== "sign-in") return { text: activity.note.status, color: colors.negative };
|
|
55
|
-
// A sign-in the broker
|
|
56
|
-
|
|
55
|
+
// A sign-in the broker ends on its clock says when, in place of "Connected";
|
|
56
|
+
// in the profile's state colour until it is time to renew.
|
|
57
|
+
if (row.signInEnd !== null) {
|
|
58
|
+
return {
|
|
59
|
+
text: signInEndStatus(row.signInEnd.endsAt),
|
|
60
|
+
color: row.signInEnd.soon ? colors.warning : stateColor(row.state),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
57
63
|
return { text: row.stateLabel, color: stateColor(row.state) };
|
|
58
64
|
}
|
|
59
65
|
|
|
@@ -19,7 +19,7 @@ const INSTRUMENT_CATEGORY: Record<string, string> = { option: "OPT", future: "FU
|
|
|
19
19
|
export const brokerTradingModule: PluginModule = {
|
|
20
20
|
panes: [{
|
|
21
21
|
id: "broker-orders", name: "Orders", personalData: "account", icon: "O", component: BrokerOrdersPane,
|
|
22
|
-
defaultPosition: "right", defaultMode: "floating",
|
|
22
|
+
defaultPosition: "right", defaultMode: "floating", utilityWindow: true,
|
|
23
23
|
defaultFloatingSize: { width: 100, height: 30 }, headless: brokerOrdersHeadless,
|
|
24
24
|
portableShare: { private: { title: true, params: true, settings: true, state: true } },
|
|
25
25
|
}],
|
|
@@ -2,7 +2,8 @@ import type { HeadlessPaneColumn, HeadlessPaneDefinition } from "../../../types/
|
|
|
2
2
|
import { CENTRAL_BANKS, centralBankNames } from "../../../utils/central-banks";
|
|
3
3
|
import { fetchCentralBankRates } from "./client";
|
|
4
4
|
import {
|
|
5
|
-
hasNoPolicyRate, policyExportRow, policyLastDecisionText, policyNextMeetingText, policyNotices,
|
|
5
|
+
hasNoPolicyRate, policyExportRow, policyLastDecisionText, policyNextMeetingText, policyNotices, policyObservations, policyRate,
|
|
6
|
+
policyUnlistedNote,
|
|
6
7
|
} from "./model";
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -43,17 +44,16 @@ export const centralBankRatesHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
43
44
|
"Next meetings come from each bank's published calendar; SAMA publishes none, and China's date is the monthly LPR fixing."] },
|
|
44
45
|
shape: "bundle",
|
|
45
46
|
options: [{ key: "history", shot: { reportOnly: "adds each row's one-year history to the JSON report" }, type: "boolean", defaultValue: false, description: "Add each row's one-year daily history to the JSON metadata." }],
|
|
46
|
-
argument: { kind: "none" }, describe: "Policy rates of the G20, SNB, Norges Bank, Riksbank and
|
|
47
|
+
argument: { kind: "none" }, describe: "Policy rates of the G20, SNB, Norges Bank, Riksbank, RBNZ, Egypt and Nigeria",
|
|
47
48
|
// Each row is dated apart (BIS reports weekly, some banks weeks late), so exports cite the oldest as well.
|
|
48
|
-
freshness: { source: "BIS and
|
|
49
|
+
freshness: { source: "BIS, FRED and central banks", publisher: "each row's central_bank, via BIS, FRED or its own published decisions", status: "not-a-feed",
|
|
49
50
|
basis: "published policy rates", citeOldest: true },
|
|
50
51
|
async load(args, ctx) {
|
|
51
52
|
const data = await fetchCentralBankRates(ctx.apiClient);
|
|
52
53
|
const errors = policyNotices(data);
|
|
53
54
|
const complete = data.status === "available" && errors.length === 0;
|
|
54
|
-
//
|
|
55
|
-
const observations = data
|
|
56
|
-
.map((row) => ({ asOf: row.asOf, stale: row.status === "stale" }));
|
|
55
|
+
// Hand the report its rows' staleness so its status line and a capture count them.
|
|
56
|
+
const observations = policyObservations(data);
|
|
57
57
|
// Members with no policy rate stay off the board, as the pane keeps them, so every output counts the same rows; a note says why.
|
|
58
58
|
const listed = data.rows.filter((row) => !hasNoPolicyRate(row));
|
|
59
59
|
const exported = listed.map(policyExportRow);
|
|
@@ -10,7 +10,7 @@ export const centralBankRatesModule: PluginModule = {
|
|
|
10
10
|
tableExport: true, headless: centralBankRatesHeadless }],
|
|
11
11
|
paneTemplates: [{
|
|
12
12
|
id: "central-bank-rates-cbr", paneId: "central-bank-rates", label: "Central Bank Rates",
|
|
13
|
-
description: "Policy rates of the G20, SNB, Norges Bank, Riksbank and
|
|
13
|
+
description: "Policy rates of the G20, SNB, Norges Bank, Riksbank, RBNZ, Egypt and Nigeria, last observed changes and dated historical context.",
|
|
14
14
|
keywords: ["central", "bank", "policy", "rates", "g20", "cbr", "cbrt"], shortcut: { prefix: "CBR", aliases: ["CBRT"] },
|
|
15
15
|
headless: centralBankRatesHeadless,
|
|
16
16
|
}],
|
|
@@ -16,6 +16,14 @@ export const policyChangeDate = (row: CentralBankRow) => row.lastDecision?.date
|
|
|
16
16
|
/** Members with no policy rate to publish, kept out of the board and the notices; docs/research-data.md explains them. */
|
|
17
17
|
export const hasNoPolicyRate = (row: CentralBankRow) => row.status === "unavailable"
|
|
18
18
|
&& (row.unavailableReason === "no-policy-rate" || row.unavailableReason === "no-unified-rate");
|
|
19
|
+
/**
|
|
20
|
+
* Each listed row's date, and whether it is stale, as the report and the pane's footer date the board: a row says
|
|
21
|
+
* "stale" in its status, not in a `stale` flag.
|
|
22
|
+
*/
|
|
23
|
+
export function policyObservations(data: CentralBankRatesPayload): { asOf: string | null; stale: boolean }[] {
|
|
24
|
+
return data.rows.filter((row) => row.status !== "unavailable").map((row) => ({ asOf: row.asOf, stale: row.status === "stale" }));
|
|
25
|
+
}
|
|
26
|
+
|
|
19
27
|
export function policyNotices(data: CentralBankRatesPayload): string[] {
|
|
20
28
|
return data.rows.filter((row) => !hasNoPolicyRate(row)).flatMap((row) => row.status === "stale" ? [`${row.label}: stale, latest observation ${row.asOf ?? "unknown"}${row.lagDays == null ? "" : ` (${row.lagDays} days old)`}.`]
|
|
21
29
|
: row.status === "unavailable" ? [`${row.label}: ${(row.unavailableReason ?? "unavailable").replaceAll("-", " ")}.`] : []);
|
|
@@ -36,8 +44,14 @@ export function policyBoardRow(row: CentralBankRow): PolicyBoardRow {
|
|
|
36
44
|
|
|
37
45
|
const SOURCE_LABELS = { bis: "BIS", fred: "FRED" } as const;
|
|
38
46
|
|
|
39
|
-
/**
|
|
40
|
-
|
|
47
|
+
/**
|
|
48
|
+
* A bank neither BIS nor FRED reports (Egypt's, Nigeria's): its level is read
|
|
49
|
+
* from its own published decisions, on the page `sourceUrl` names.
|
|
50
|
+
*/
|
|
51
|
+
const ownPublication = (row: CentralBankRow) => row.source == null && row.sourceUrl != null && row.centralBank != null;
|
|
52
|
+
|
|
53
|
+
/** Where the row's series is read from: `BIS`, `FRED`, or the bank itself. */
|
|
54
|
+
export const policySource = (row: CentralBankRow) => row.source ? SOURCE_LABELS[row.source] : ownPublication(row) ? row.centralBank : null;
|
|
41
55
|
|
|
42
56
|
/** Each series' own page: one per FRED series (both bounds of the US range), the country's for BIS. */
|
|
43
57
|
function policySeriesUrls(row: CentralBankRow): string[] {
|
|
@@ -47,6 +61,7 @@ function policySeriesUrls(row: CentralBankRow): string[] {
|
|
|
47
61
|
|
|
48
62
|
/** `BIS series D.GB (url)`; a two-series range cites each bound: `FRED series DFEDTARL (lower bound, url) and DFEDTARU (upper bound, url)`. */
|
|
49
63
|
function seriesCitation(row: CentralBankRow): string | null {
|
|
64
|
+
if (ownPublication(row)) return `${row.centralBank}'s published decisions (${row.sourceUrl})`;
|
|
50
65
|
const source = policySource(row);
|
|
51
66
|
const ids = row.sourceSeriesIds;
|
|
52
67
|
const urls = policySeriesUrls(row);
|
|
@@ -67,7 +82,9 @@ export function policyCitation(row: CentralBankRow): string {
|
|
|
67
82
|
: `${row.instrument}: no current observation (${(row.unavailableReason ?? "unavailable").replaceAll("-", " ")})`;
|
|
68
83
|
return series ? `${missing}, ${series}` : missing;
|
|
69
84
|
}
|
|
70
|
-
|
|
85
|
+
// A bank's own page is its source; it is not cited again as confirming itself.
|
|
86
|
+
const confirmed = row.confirmedAt && row.confirmationSourceUrl && row.confirmationSourceUrl !== row.sourceUrl
|
|
87
|
+
? `; confirmed at ${row.confirmationSourceUrl} on ${row.confirmedAt.slice(0, 10)}` : "";
|
|
71
88
|
return `${row.instrument} ${policyLevel(row)}${series ? `, ${series}` : ""}, as of ${row.asOf}${confirmed}`;
|
|
72
89
|
}
|
|
73
90
|
|
|
@@ -155,6 +172,7 @@ export function policyUnlistedNote(row: CentralBankRow): string {
|
|
|
155
172
|
|
|
156
173
|
/** Who a chart of the row's series cites: `FRED series ECBDFR`, published by the European Central Bank. */
|
|
157
174
|
export function policySeriesAttribution(row: CentralBankRow): { source: string; publisher?: string } | null {
|
|
175
|
+
if (ownPublication(row)) return { source: `${row.centralBank}'s published decisions`, publisher: row.centralBank! };
|
|
158
176
|
const source = policySource(row);
|
|
159
177
|
if (!source || row.sourceSeriesIds.length === 0) return null;
|
|
160
178
|
return { source: `${source} series ${row.sourceSeriesIds.join(" and ")}`, ...(row.centralBank ? { publisher: row.centralBank } : {}) };
|