gloomberb 0.15.7 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -2
- package/package.json +1 -1
- package/src/api-client/app-attention.ts +147 -0
- package/src/api-client/attention.ts +26 -0
- package/src/api-client/awards.ts +215 -0
- package/src/api-client/catalysts.ts +160 -0
- package/src/api-client/chat.ts +137 -14
- package/src/api-client/company-kpis.ts +153 -0
- package/src/api-client/cpi.ts +52 -0
- package/src/api-client/credit-documents.ts +107 -0
- package/src/api-client/data.ts +192 -3
- package/src/api-client/distress.ts +164 -0
- package/src/api-client/doe.ts +75 -0
- package/src/api-client/equity-screener.ts +11 -0
- package/src/api-client/exposure.ts +202 -0
- package/src/api-client/gpu.ts +93 -0
- package/src/api-client/hiring.ts +110 -0
- package/src/api-client/index.ts +78 -3
- package/src/api-client/normalizers.ts +31 -1
- package/src/api-client/paths.ts +3 -0
- package/src/api-client/perps.ts +127 -0
- package/src/api-client/power.ts +148 -0
- package/src/api-client/request.ts +58 -1
- package/src/api-client/research-activity.ts +172 -13
- package/src/api-client/socket.ts +75 -27
- package/src/api-client/supply-chain-graph.ts +40 -0
- package/src/api-client/supply-chain.ts +98 -0
- package/src/api-client/telemetry.ts +29 -0
- package/src/api-client/themes.ts +28 -0
- package/src/api-client/types.ts +33 -1
- package/src/api-client/wall-experiments.ts +100 -0
- package/src/api-client/wall-summary.ts +49 -0
- package/src/api-client/web-experiments.ts +136 -0
- package/src/app/pane-runtime/plugin-bindings.ts +5 -0
- package/src/app/pane-runtime/ticker-open-runtime.ts +8 -2
- package/src/app/runtime/update.ts +13 -1
- package/src/cli/commands/system.ts +2 -0
- package/src/cli/desktop-pane-shot.ts +3 -4
- package/src/cli/pane-functions/data.ts +78 -0
- package/src/cli/pane-functions/financial-ratio-shot.ts +160 -0
- package/src/cli/pane-functions/function-help.ts +220 -8
- package/src/cli/pane-functions/headless.ts +4 -0
- package/src/cli/pane-functions/screenshot-evidence.ts +21 -0
- package/src/cli/pane-functions/screenshot.ts +49 -5
- package/src/components/chart/composite/composite-chart.tsx +15 -2
- package/src/components/chart/composite/format.ts +24 -11
- package/src/components/chart/composite/rasterizer.ts +67 -16
- package/src/components/chart/composite/scene.ts +53 -2
- package/src/components/chart/composite/session-shading.ts +3 -2
- package/src/components/chart/composite/text-renderer.ts +52 -1
- package/src/components/chart/composite/time-axis.ts +100 -30
- package/src/components/chart/composite/tools.ts +2 -1
- package/src/components/chart/composite/types.ts +4 -0
- package/src/components/chart-table/index.ts +1 -0
- package/src/components/chart-table/layout.ts +15 -0
- package/src/components/command-bar/action-runtime.ts +1 -0
- package/src/components/command-bar/commands/direct/index.ts +32 -0
- package/src/components/command-bar/commands/registry.ts +7 -0
- package/src/components/command-bar/pane-templates/items.ts +11 -0
- package/src/components/command-bar/pane-templates/workflow.ts +19 -4
- package/src/components/command-bar/routes/root/command-items.ts +6 -0
- package/src/components/command-bar/routes/root/provider-search.ts +2 -0
- package/src/components/command-bar/routes/root/results.ts +64 -0
- package/src/components/command-bar/routes/root/runtime.ts +8 -0
- package/src/components/command-bar/routes/ticker-search/results.ts +89 -24
- package/src/components/command-bar/routes/ticker-search/route.ts +2 -0
- package/src/components/command-bar/surface/index.tsx +15 -0
- package/src/components/command-bar/view-model.ts +3 -0
- package/src/components/command-bar/workflow/collection-actions.ts +9 -7
- package/src/components/command-bar/workflow/ops.ts +19 -0
- package/src/components/command-bar/workflow/tickers.ts +5 -0
- package/src/components/company-logo.tsx +15 -2
- package/src/components/data-table/table-pane.ts +2 -1
- package/src/components/index.ts +1 -0
- package/src/components/layout/detached-pane-shell.tsx +12 -1
- package/src/components/layout/missing-pane.tsx +87 -23
- package/src/components/layout/pane/footer/index.tsx +64 -18
- package/src/components/layout/pane/footer/model.ts +85 -0
- package/src/components/layout/pane/sidebar.tsx +19 -1
- package/src/components/layout/shell/index.tsx +38 -28
- package/src/components/layout/shell/pane/management-shortcuts.ts +13 -1
- package/src/components/layout/status-bar.tsx +93 -28
- package/src/components/layout/status-widget-space.ts +72 -0
- package/src/components/onboarding/first-run-workspace.ts +8 -2
- package/src/components/onboarding/onboarding-wizard.tsx +35 -16
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +14 -5
- package/src/components/onboarding/wizard-model.ts +13 -5
- package/src/components/onboarding/wizard-positions.ts +56 -7
- package/src/components/price-performance.tsx +31 -34
- package/src/components/ui/data-table/index.tsx +11 -8
- package/src/components/ui/display.tsx +15 -6
- package/src/components/ui/fields.tsx +5 -0
- package/src/components/ui/figure.tsx +94 -0
- package/src/components/ui/header-case.ts +25 -3
- package/src/components/ui/icon.tsx +3 -1
- package/src/components/ui/message-composer.tsx +8 -1
- package/src/components/ui/query-bar.tsx +8 -1
- package/src/components/ui/ratio-bar.tsx +84 -0
- package/src/components/ui/toggle.tsx +3 -1
- package/src/components/use-scrollbox-layout.ts +17 -0
- package/src/core/state/app/layout.ts +35 -1
- package/src/core/state/app/state.ts +15 -0
- package/src/core/state/app/types.ts +1 -0
- package/src/data/config/store/normalize.ts +24 -0
- 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-marketplace/pane-imagery.ts +1 -0
- package/src/market-data/coordinator/entries.ts +13 -0
- package/src/market-data/coordinator/financials.ts +33 -8
- package/src/market-data/market/freshness.ts +16 -5
- package/src/market-data/market/trading-sessions.ts +65 -1
- package/src/market-data/published-cn-sessions.ts +25 -0
- package/src/market-data/published-nse-sessions.ts +20 -0
- package/src/news/aggregator.ts +4 -0
- package/src/plugins/builtin/account-management/model.ts +6 -1
- package/src/plugins/builtin/account-management/pane.tsx +36 -25
- package/src/plugins/builtin/alerts/catalysts.ts +77 -0
- package/src/plugins/builtin/alerts/events-pane.tsx +3 -0
- package/src/plugins/builtin/alerts/events.ts +10 -4
- package/src/plugins/builtin/alerts/history-pane.tsx +1 -1
- package/src/plugins/builtin/alerts/history.ts +1 -0
- package/src/plugins/builtin/alerts/index.tsx +6 -0
- package/src/plugins/builtin/alerts/research-builder.ts +10 -3
- package/src/plugins/builtin/alerts/research-rules.ts +15 -1
- package/src/plugins/builtin/analytics/risk-client.ts +15 -3
- package/src/plugins/builtin/analytics/risk-headless.ts +123 -18
- package/src/plugins/builtin/attention/client.ts +80 -0
- package/src/plugins/builtin/attention/evidence.ts +30 -0
- package/src/plugins/builtin/attention/headless.ts +33 -0
- package/src/plugins/builtin/attention/index.tsx +18 -0
- package/src/plugins/builtin/attention/model.ts +59 -0
- package/src/plugins/builtin/attention/pane.tsx +211 -0
- package/src/plugins/builtin/attention/trending.tsx +59 -0
- package/src/plugins/builtin/awards/alerts.ts +32 -0
- package/src/plugins/builtin/awards/client.ts +82 -0
- package/src/plugins/builtin/awards/detail.tsx +107 -0
- package/src/plugins/builtin/awards/evidence.ts +36 -0
- package/src/plugins/builtin/awards/headless.ts +55 -0
- package/src/plugins/builtin/awards/index.tsx +20 -0
- package/src/plugins/builtin/awards/model.ts +42 -0
- package/src/plugins/builtin/awards/pane.tsx +263 -0
- package/src/plugins/builtin/catalysts/client.ts +28 -0
- package/src/plugins/builtin/catalysts/detail.tsx +88 -0
- package/src/plugins/builtin/catalysts/evidence.ts +47 -0
- package/src/plugins/builtin/catalysts/headless.ts +42 -0
- package/src/plugins/builtin/catalysts/history.ts +26 -0
- package/src/plugins/builtin/catalysts/index.tsx +29 -0
- package/src/plugins/builtin/catalysts/model.ts +135 -0
- package/src/plugins/builtin/catalysts/pane.tsx +159 -0
- package/src/plugins/builtin/chart-composer/cli-options.ts +4 -0
- package/src/plugins/builtin/chart-composer/headless-schema.ts +6 -0
- package/src/plugins/builtin/chart-composer/index.tsx +8 -1
- package/src/plugins/builtin/chart-composer/pane.tsx +28 -1
- package/src/plugins/builtin/chat/attachments/desktop.tsx +610 -0
- package/src/plugins/builtin/chat/attachments/files.ts +45 -0
- package/src/plugins/builtin/chat/attachments/model.ts +164 -0
- package/src/plugins/builtin/chat/attachments/terminal.tsx +72 -0
- package/src/plugins/builtin/chat/attachments/transfer.ts +165 -0
- package/src/plugins/builtin/chat/content/channel-navigation.ts +13 -12
- package/src/plugins/builtin/chat/content/composer-runtime.ts +25 -4
- package/src/plugins/builtin/chat/content/composer.tsx +46 -4
- package/src/plugins/builtin/chat/content/footer.tsx +46 -8
- package/src/plugins/builtin/chat/content/index.tsx +263 -62
- package/src/plugins/builtin/chat/content/layout-metrics.ts +10 -2
- package/src/plugins/builtin/chat/content/open-targets.ts +17 -3
- package/src/plugins/builtin/chat/content/scroll.ts +7 -1
- package/src/plugins/builtin/chat/content/shortcuts.ts +36 -11
- package/src/plugins/builtin/chat/content/snapshot.ts +3 -0
- package/src/plugins/builtin/chat/content/transcript.tsx +17 -1
- package/src/plugins/builtin/chat/content/types.ts +7 -0
- package/src/plugins/builtin/chat/controller/attachments.ts +213 -0
- package/src/plugins/builtin/chat/controller/connections.ts +3 -1
- package/src/plugins/builtin/chat/controller/index.ts +114 -2
- package/src/plugins/builtin/chat/controller/lifecycle.ts +9 -0
- package/src/plugins/builtin/chat/controller/messages.ts +35 -2
- package/src/plugins/builtin/chat/controller/send.ts +128 -25
- package/src/plugins/builtin/chat/controller/state.ts +12 -1
- package/src/plugins/builtin/chat/controller/utils.ts +7 -5
- package/src/plugins/builtin/chat/controller/view.ts +2 -0
- package/src/plugins/builtin/chat/index.tsx +21 -0
- package/src/plugins/builtin/chat/layout.ts +9 -4
- package/src/plugins/builtin/chat/message/desktop.tsx +55 -20
- package/src/plugins/builtin/chat/message/header.tsx +30 -5
- package/src/plugins/builtin/chat/message/inline-tokens.tsx +9 -0
- package/src/plugins/builtin/chat/message/pending-send.ts +35 -0
- package/src/plugins/builtin/chat/message/profile-popover.tsx +5 -1
- package/src/plugins/builtin/chat/message/render-state.ts +12 -2
- package/src/plugins/builtin/chat/message/terminal.tsx +51 -4
- package/src/plugins/builtin/chat/message/types.ts +6 -1
- package/src/plugins/builtin/chat/pane-state.ts +59 -1
- package/src/plugins/builtin/chat/profile-popover.ts +50 -1
- package/src/plugins/builtin/chat/sidebar.tsx +8 -3
- package/src/plugins/builtin/chat/status-widget.tsx +29 -12
- package/src/plugins/builtin/chat/unread-inbox-pane.tsx +143 -0
- package/src/plugins/builtin/chat/unread-inbox.ts +91 -0
- package/src/plugins/builtin/clinical-trials/client.ts +237 -0
- package/src/plugins/builtin/clinical-trials/index.tsx +74 -0
- package/src/plugins/builtin/clinical-trials/pane.tsx +225 -0
- package/src/plugins/builtin/clinical-trials/types.ts +2 -0
- package/src/plugins/builtin/cloud/askg/controller.ts +37 -6
- package/src/plugins/builtin/cloud/askg/executor.ts +59 -44
- package/src/plugins/builtin/cloud/askg/host.ts +8 -1
- package/src/plugins/builtin/cloud/askg/manifest.ts +29 -2
- package/src/plugins/builtin/cloud/askg/model.ts +47 -13
- package/src/plugins/builtin/cloud/askg/notes.ts +100 -0
- package/src/plugins/builtin/cloud/askg/pane.tsx +50 -14
- package/src/plugins/builtin/cloud/askg/protocol.ts +39 -1
- package/src/plugins/builtin/cloud/askg/result-budget.ts +156 -0
- package/src/plugins/builtin/cloud/askg/user-data.ts +89 -0
- package/src/plugins/builtin/cloud/auth-actions.tsx +55 -31
- package/src/plugins/builtin/cloud/plugin.tsx +4 -1
- package/src/plugins/builtin/cloud/team/pane-sections.tsx +10 -1
- package/src/plugins/builtin/cloud/team/pane.tsx +3 -2
- package/src/plugins/builtin/cloud/thesis/board-pane.tsx +2 -2
- package/src/plugins/builtin/cloud/thesis/detail.tsx +1 -1
- package/src/plugins/builtin/cloud/thesis/ticker-tab.tsx +2 -2
- package/src/plugins/builtin/cloud/trial-offer-status-widget.tsx +202 -0
- package/src/plugins/builtin/cloud/upgrade-command.ts +1 -1
- package/src/plugins/builtin/cloud/upgrade-dialog.tsx +29 -3
- package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +1 -1
- package/src/plugins/builtin/cloud-tweets/table.tsx +1 -1
- package/src/plugins/builtin/comment-letters/client.ts +342 -0
- package/src/plugins/builtin/comment-letters/index.tsx +74 -0
- package/src/plugins/builtin/comment-letters/pane.tsx +295 -0
- package/src/plugins/builtin/comment-letters/types.ts +43 -0
- package/src/plugins/builtin/company-attention/app-rank.tsx +79 -0
- package/src/plugins/builtin/company-attention/client.ts +69 -0
- package/src/plugins/builtin/company-attention/evidence.ts +45 -0
- package/src/plugins/builtin/company-attention/headless.ts +47 -0
- package/src/plugins/builtin/company-attention/index.tsx +30 -0
- package/src/plugins/builtin/company-attention/model.ts +129 -0
- package/src/plugins/builtin/company-attention/pane.tsx +183 -0
- package/src/plugins/builtin/company-kpis/client.ts +92 -0
- package/src/plugins/builtin/company-kpis/headless.ts +32 -0
- package/src/plugins/builtin/company-kpis/index.tsx +26 -0
- package/src/plugins/builtin/company-kpis/model.ts +124 -0
- package/src/plugins/builtin/company-kpis/pane.tsx +226 -0
- package/src/plugins/builtin/company-kpis/related.ts +11 -0
- package/src/plugins/builtin/company-kpis/screenshot-evidence.ts +44 -0
- package/src/plugins/builtin/composite-plugins.ts +34 -0
- package/src/plugins/builtin/correlation/history.ts +4 -1
- package/src/plugins/builtin/correlation/index.tsx +139 -80
- package/src/plugins/builtin/correlation/matrix/pair-chart.tsx +48 -0
- package/src/plugins/builtin/correlation/matrix/selection.ts +77 -0
- package/src/plugins/builtin/correlation/relationship/model.ts +2 -2
- package/src/plugins/builtin/cpi/client.ts +66 -0
- package/src/plugins/builtin/cpi/headless.ts +78 -0
- package/src/plugins/builtin/cpi/index.tsx +31 -0
- package/src/plugins/builtin/cpi/model.ts +198 -0
- package/src/plugins/builtin/cpi/pane.tsx +157 -0
- package/src/plugins/builtin/credit-documents/client.ts +99 -0
- package/src/plugins/builtin/credit-documents/detail.tsx +109 -0
- package/src/plugins/builtin/credit-documents/evidence.ts +64 -0
- package/src/plugins/builtin/credit-documents/gauge.tsx +55 -0
- package/src/plugins/builtin/credit-documents/headless.ts +40 -0
- package/src/plugins/builtin/credit-documents/index.tsx +19 -0
- package/src/plugins/builtin/credit-documents/model.ts +336 -0
- package/src/plugins/builtin/credit-documents/pane.tsx +185 -0
- package/src/plugins/builtin/custom-view/view-spec.ts +14 -2
- package/src/plugins/builtin/debt-maturities/pane.tsx +1 -0
- package/src/plugins/builtin/dividend-yield/pane.tsx +1 -1
- package/src/plugins/builtin/doe/client.ts +73 -0
- package/src/plugins/builtin/doe/headless.ts +93 -0
- package/src/plugins/builtin/doe/index.tsx +41 -0
- package/src/plugins/builtin/doe/model.ts +215 -0
- package/src/plugins/builtin/doe/pane.tsx +148 -0
- package/src/plugins/builtin/doe/range-bar.tsx +45 -0
- package/src/plugins/builtin/earnings/board.tsx +3 -0
- package/src/plugins/builtin/earnings/index.tsx +2 -0
- package/src/plugins/builtin/earnings-calls/pane.tsx +7 -1
- package/src/plugins/builtin/earnings-calls/transcript-view.tsx +7 -7
- package/src/plugins/builtin/earnings-ripple/client.ts +60 -0
- package/src/plugins/builtin/earnings-ripple/headless.ts +35 -0
- package/src/plugins/builtin/earnings-ripple/index.tsx +35 -0
- package/src/plugins/builtin/earnings-ripple/model.ts +98 -0
- package/src/plugins/builtin/earnings-ripple/pane.tsx +103 -0
- package/src/plugins/builtin/equity-screener/client.ts +1 -1
- package/src/plugins/builtin/equity-screener/criterion-editor.tsx +1 -1
- package/src/plugins/builtin/equity-screener/model.ts +74 -9
- package/src/plugins/builtin/equity-screener/pane.tsx +2 -0
- package/src/plugins/builtin/estimate-revisions/pane.tsx +3 -0
- package/src/plugins/builtin/executives/pane.tsx +7 -5
- package/src/plugins/builtin/exposure/charts.tsx +66 -0
- package/src/plugins/builtin/exposure/client.ts +53 -0
- package/src/plugins/builtin/exposure/drivers.ts +29 -0
- package/src/plugins/builtin/exposure/editor.tsx +61 -0
- package/src/plugins/builtin/exposure/evidence.ts +39 -0
- package/src/plugins/builtin/exposure/headless.ts +51 -0
- package/src/plugins/builtin/exposure/holdings.ts +56 -0
- package/src/plugins/builtin/exposure/index.tsx +13 -0
- package/src/plugins/builtin/exposure/model.ts +104 -0
- package/src/plugins/builtin/exposure/pane.tsx +247 -0
- package/src/plugins/builtin/fear-greed/charts.tsx +1 -1
- package/src/plugins/builtin/fear-greed/pane.tsx +2 -9
- package/src/plugins/builtin/filing-events/pane.tsx +2 -1
- package/src/plugins/builtin/gpu/board.tsx +163 -0
- package/src/plugins/builtin/gpu/changes.tsx +94 -0
- package/src/plugins/builtin/gpu/client.ts +130 -0
- package/src/plugins/builtin/gpu/equities.tsx +112 -0
- package/src/plugins/builtin/gpu/headless.ts +67 -0
- package/src/plugins/builtin/gpu/history.tsx +140 -0
- package/src/plugins/builtin/gpu/index.tsx +18 -0
- package/src/plugins/builtin/gpu/ladder.tsx +127 -0
- package/src/plugins/builtin/gpu/model.ts +317 -0
- package/src/plugins/builtin/gpu/pane.tsx +63 -0
- package/src/plugins/builtin/help/index.tsx +19 -2
- package/src/plugins/builtin/holders/pane.tsx +5 -9
- package/src/plugins/builtin/insider/detail.tsx +119 -0
- package/src/plugins/builtin/insider/display.ts +221 -0
- package/src/plugins/builtin/insider/headless.ts +24 -3
- package/src/plugins/builtin/insider/index.tsx +206 -108
- package/src/plugins/builtin/insider/insider-data.ts +31 -3
- package/src/plugins/builtin/insider/model.ts +53 -4
- package/src/plugins/builtin/insider/table-model.ts +226 -0
- package/src/plugins/builtin/insider/table.tsx +79 -0
- package/src/plugins/builtin/iv-history/screen-pane.tsx +1 -1
- package/src/plugins/builtin/jobs/pane.tsx +14 -7
- package/src/plugins/builtin/kelly-sizer/pane.tsx +1 -1
- package/src/plugins/builtin/macro-day/client.ts +50 -0
- package/src/plugins/builtin/macro-day/headless.ts +51 -0
- package/src/plugins/builtin/macro-day/index.tsx +21 -0
- package/src/plugins/builtin/macro-day/model.ts +137 -0
- package/src/plugins/builtin/macro-day/pane.tsx +118 -0
- package/src/plugins/builtin/macro-day/releases.ts +58 -0
- package/src/plugins/builtin/market-halts/model.ts +30 -17
- package/src/plugins/builtin/market-halts/pane.tsx +15 -21
- package/src/plugins/builtin/market-heatmap/data.ts +1 -1
- package/src/plugins/builtin/market-heatmap/index.tsx +198 -50
- package/src/plugins/builtin/market-heatmap/portfolio.ts +220 -0
- package/src/plugins/builtin/market-movers/index.tsx +1 -0
- package/src/plugins/builtin/market-movers/session-body.tsx +5 -2
- package/src/plugins/builtin/mna/distress/client.ts +326 -0
- package/src/plugins/builtin/mna/distress/detail.tsx +247 -0
- package/src/plugins/builtin/mna/distress/headless.ts +257 -0
- package/src/plugins/builtin/mna/distress/model.ts +427 -0
- package/src/plugins/builtin/mna/distress/pane.tsx +606 -0
- package/src/plugins/builtin/mna/index.tsx +15 -0
- package/src/plugins/builtin/mna/pane.tsx +42 -1
- package/src/plugins/builtin/news/index.tsx +62 -16
- package/src/plugins/builtin/news/wire/filter-articles.ts +54 -0
- package/src/plugins/builtin/news/wire/index.tsx +37 -3
- package/src/plugins/builtin/news/wire/industry-pane.tsx +29 -13
- package/src/plugins/builtin/news/wire/mutes.ts +253 -0
- package/src/plugins/builtin/news/wire/news/command-bar-search.ts +117 -0
- package/src/plugins/builtin/news/wire/news/footer.ts +4 -0
- package/src/plugins/builtin/news/wire/news/list-search.ts +34 -0
- package/src/plugins/builtin/news/wire/news/pop-out.tsx +158 -0
- package/src/plugins/builtin/news/wire/news/preset-pane.tsx +64 -19
- package/src/plugins/builtin/openfda/client.ts +300 -0
- package/src/plugins/builtin/openfda/index.tsx +71 -0
- package/src/plugins/builtin/openfda/pane.tsx +382 -0
- package/src/plugins/builtin/openfda/types.ts +76 -0
- package/src/plugins/builtin/options/footer.ts +1 -0
- package/src/plugins/builtin/options/view.tsx +1 -1
- package/src/plugins/builtin/options-calculator/pane.tsx +0 -1
- package/src/plugins/builtin/options-positioning/index.tsx +4 -2
- package/src/plugins/builtin/options-positioning/pane.tsx +1 -1
- package/src/plugins/builtin/pe-band/client.ts +61 -0
- package/src/plugins/builtin/pe-band/headless.ts +51 -0
- package/src/plugins/builtin/pe-band/index.tsx +20 -0
- package/src/plugins/builtin/pe-band/model.ts +267 -0
- package/src/plugins/builtin/pe-band/pane.tsx +159 -0
- package/src/plugins/builtin/perps/client.ts +66 -0
- package/src/plugins/builtin/perps/equity-row.tsx +28 -0
- package/src/plugins/builtin/perps/headless.ts +34 -0
- package/src/plugins/builtin/perps/index.tsx +14 -0
- package/src/plugins/builtin/perps/model.ts +58 -0
- package/src/plugins/builtin/perps/pane.tsx +185 -0
- package/src/plugins/builtin/plugin-marketplace/pane.tsx +0 -1
- package/src/plugins/builtin/portfolio-list/cli/render.ts +177 -87
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +6 -20
- package/src/plugins/builtin/portfolio-list/command-bar.ts +6 -2
- package/src/plugins/builtin/portfolio-list/headless.ts +237 -0
- package/src/plugins/builtin/portfolio-list/index.tsx +2 -0
- package/src/plugins/builtin/portfolio-list/mutations.ts +70 -1
- package/src/plugins/builtin/portfolio-list/pane/data.ts +17 -0
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +88 -5
- package/src/plugins/builtin/portfolio-list/pane/remove-ticker.ts +85 -0
- package/src/plugins/builtin/portfolio-list/pane/streaming.ts +18 -12
- package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +6 -0
- package/src/plugins/builtin/power/client.ts +100 -0
- package/src/plugins/builtin/power/detail.tsx +82 -0
- package/src/plugins/builtin/power/evidence.ts +56 -0
- package/src/plugins/builtin/power/generation.tsx +37 -0
- package/src/plugins/builtin/power/headless.ts +43 -0
- package/src/plugins/builtin/power/index.tsx +16 -0
- package/src/plugins/builtin/power/model.ts +89 -0
- package/src/plugins/builtin/power/pane.tsx +209 -0
- package/src/plugins/builtin/power/query.ts +25 -0
- package/src/plugins/builtin/relative-rotation/pane.tsx +3 -3
- package/src/plugins/builtin/research/analyst-pane.tsx +1 -1
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +13 -4
- package/src/plugins/builtin/research/equity-diagnostic-pane.tsx +11 -9
- package/src/plugins/builtin/research-search/pane.tsx +21 -7
- package/src/plugins/builtin/revenue-breakdown/pane.tsx +1 -1
- package/src/plugins/builtin/reverse-dcf/client.ts +35 -0
- package/src/plugins/builtin/reverse-dcf/headless.ts +44 -0
- package/src/plugins/builtin/reverse-dcf/index.tsx +20 -0
- package/src/plugins/builtin/reverse-dcf/model.ts +87 -0
- package/src/plugins/builtin/reverse-dcf/pane.tsx +107 -0
- package/src/plugins/builtin/risk-factors/pane.tsx +6 -5
- package/src/plugins/builtin/scanner/denied.tsx +4 -2
- package/src/plugins/builtin/scanner/feed.ts +1 -0
- package/src/plugins/builtin/scanner/flow-pane.tsx +3 -2
- package/src/plugins/builtin/scanner/hilo-pane.tsx +1 -1
- package/src/plugins/builtin/seasonality/client.ts +4 -1
- package/src/plugins/builtin/sec/command-bar-search.ts +217 -0
- package/src/plugins/builtin/sec/forms.ts +54 -0
- package/src/plugins/builtin/sec/headless.ts +31 -5
- package/src/plugins/builtin/sec/index.tsx +67 -11
- package/src/plugins/builtin/sec/model.ts +35 -5
- package/src/plugins/builtin/sectors/headless.ts +1 -0
- package/src/plugins/builtin/sectors/index.tsx +72 -26
- package/src/plugins/builtin/shared/cloud-upgrade.ts +143 -39
- package/src/plugins/builtin/shared/pro-feature-wall.tsx +8 -4
- package/src/plugins/builtin/shared/research-cells.tsx +107 -0
- package/src/plugins/builtin/shared/series-list-detail.tsx +5 -1
- package/src/plugins/builtin/shared/ticker-request.ts +1 -1
- package/src/plugins/builtin/shared/wall-teaser-catalog.ts +80 -0
- package/src/plugins/builtin/shared/wall-teaser.tsx +192 -0
- package/src/plugins/builtin/shared/wall-view-lifecycle.ts +43 -0
- package/src/plugins/builtin/short-interest/index.tsx +31 -0
- package/src/plugins/builtin/short-interest/watch-client.ts +70 -0
- package/src/plugins/builtin/short-interest/watch-headless.ts +49 -0
- package/src/plugins/builtin/short-interest/watch-model.ts +185 -0
- package/src/plugins/builtin/short-interest/watch-pane.tsx +169 -0
- package/src/plugins/builtin/short-volume/pane.tsx +1 -1
- package/src/plugins/builtin/social-mentions/pane.tsx +1 -1
- package/src/plugins/builtin/supply-chain/client.ts +104 -0
- package/src/plugins/builtin/supply-chain/disclosure-quote.tsx +17 -0
- package/src/plugins/builtin/supply-chain/evidence.ts +88 -0
- package/src/plugins/builtin/supply-chain/flow-layout.ts +133 -0
- package/src/plugins/builtin/supply-chain/flow.tsx +323 -0
- package/src/plugins/builtin/supply-chain/graph-client.ts +83 -0
- package/src/plugins/builtin/supply-chain/graph-evidence.ts +25 -0
- package/src/plugins/builtin/supply-chain/graph-model.ts +45 -0
- package/src/plugins/builtin/supply-chain/graph-pane.tsx +218 -0
- package/src/plugins/builtin/supply-chain/graph.tsx +163 -0
- package/src/plugins/builtin/supply-chain/headless.ts +105 -0
- package/src/plugins/builtin/supply-chain/index.tsx +17 -0
- package/src/plugins/builtin/supply-chain/model.ts +145 -0
- package/src/plugins/builtin/supply-chain/pane.tsx +276 -0
- package/src/plugins/builtin/supply-chain/row-evidence.tsx +96 -0
- package/src/plugins/builtin/supply-chain/trust.ts +34 -0
- package/src/plugins/builtin/themes/client.ts +39 -0
- package/src/plugins/builtin/themes/headless.ts +38 -0
- package/src/plugins/builtin/themes/model.ts +92 -0
- package/src/plugins/builtin/themes/pane.tsx +125 -0
- package/src/plugins/builtin/thirteenf/pane.tsx +6 -15
- package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +5 -6
- package/src/plugins/builtin/ticker-detail/data-panes/returns-model.ts +201 -0
- package/src/plugins/builtin/ticker-detail/data-panes/returns-pane.tsx +327 -0
- package/src/plugins/builtin/ticker-detail/financials/period-end-history.ts +5 -2
- package/src/plugins/builtin/ticker-detail/financials/ratios.ts +60 -12
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +2 -1
- package/src/plugins/builtin/ticker-detail/headless.ts +7 -2
- package/src/plugins/builtin/ticker-detail/index.tsx +22 -0
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +53 -30
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +2 -0
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +112 -47
- package/src/plugins/builtin/ticker-detail/pane.tsx +50 -6
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +21 -42
- package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +3 -0
- package/src/plugins/builtin/time-sales/pane.tsx +1 -1
- package/src/plugins/builtin/world-indices/indices.ts +1 -0
- package/src/plugins/catalog-browser.ts +40 -0
- package/src/plugins/catalog-manifest.ts +3 -0
- package/src/plugins/catalog-ui.ts +6 -0
- package/src/plugins/current-target.ts +0 -9
- package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
- package/src/renderers/browser/cloud-transport.ts +66 -1
- package/src/renderers/browser/main.tsx +2 -0
- package/src/renderers/dom/data-table/row.tsx +2 -0
- package/src/renderers/dom/desktop/controls.tsx +38 -25
- package/src/renderers/dom/desktop/icons.tsx +8 -0
- package/src/renderers/dom/host/chart-surface.tsx +36 -2
- package/src/renderers/dom/host/focus-scope.ts +11 -1
- package/src/renderers/dom/styles.css +28 -0
- package/src/renderers/electrobun/view/backend-rpc.ts +3 -2
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +1 -1
- package/src/renderers/electrobun/view/http-fetch.ts +2 -0
- package/src/renderers/electrobun/view/main.tsx +3 -1
- package/src/renderers/electrobun/view/rpc-timeout.ts +59 -0
- package/src/renderers/opentui/start.tsx +3 -0
- package/src/shares/api.ts +3 -1
- package/src/sources/gloomberb-cloud/index.ts +47 -13
- package/src/sources/history-result.ts +1 -0
- package/src/sources/history-retention.ts +16 -0
- package/src/sources/provider-router/history.ts +4 -2
- package/src/sources/sec-edgar/identity.ts +36 -0
- package/src/sources/sec-edgar.ts +1 -34
- package/src/state/app/context/index.tsx +8 -0
- package/src/sync/core-contributors.ts +20 -2
- package/src/telemetry/attention-counts.ts +164 -0
- package/src/telemetry/live-config.ts +7 -0
- package/src/test-support/rpc-loopback.ts +7 -3
- package/src/test-support/shell-pane-keys.tsx +34 -0
- package/src/tickers/instrument-kind.ts +12 -6
- package/src/tickers/open-target.ts +1 -1
- package/src/tickers/search/asset-classes.ts +91 -0
- package/src/tickers/search/index.ts +62 -15
- package/src/tickers/search/ranking.ts +22 -3
- package/src/tickers/search/upsert.ts +4 -1
- package/src/time-series/live-bars.ts +8 -3
- package/src/time-series/resolve.ts +224 -17
- package/src/time-series/spec.ts +1 -0
- package/src/time-series/types.ts +9 -1
- package/src/types/config.ts +23 -1
- package/src/types/data-provider.ts +2 -0
- package/src/types/headless.ts +17 -0
- package/src/types/price-history.ts +2 -0
- package/src/ui/host.tsx +6 -0
- package/src/utils/double-escape-close.ts +20 -0
- package/src/utils/exchanges.ts +1 -0
- package/src/utils/html-entities.ts +15 -0
- package/src/utils/http-proxy-response.ts +44 -7
- package/src/utils/plugin-proxy-hosts.json +3 -0
- package/src/utils/price-history.ts +35 -1
- package/src/utils/sec.ts +21 -2
- package/src/utils/text-wrap.ts +13 -8
- package/src/utils/zoned-date-time.ts +67 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { SupplyRole, SupplyRow } from "../../../api-client/supply-chain";
|
|
2
|
+
import { SERIES_COLORS } from "../../../time-series/resolve";
|
|
3
|
+
import { revenueAmount } from "../revenue-breakdown/model";
|
|
4
|
+
import { activeRelationship, corroborationLabel, evidenceDate, evidenceLabel, isUnconfirmed, trustTier } from "./trust";
|
|
5
|
+
|
|
6
|
+
/** One colour per role from the shared series palette, the same in the table, the flow and the evidence. */
|
|
7
|
+
export const ROLE_COLORS: Record<SupplyRole, string> = {
|
|
8
|
+
supplier: SERIES_COLORS[0], customer: SERIES_COLORS[1], partner: SERIES_COLORS[3], competitor: SERIES_COLORS[5], investee: SERIES_COLORS[7],
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/** A company, a customer the filer does not name, or a geographic or channel cohort that is not one company. */
|
|
12
|
+
export type CounterpartyKind = "company" | "undisclosed" | "group";
|
|
13
|
+
export const counterpartyKind = (row: SupplyRow): CounterpartyKind =>
|
|
14
|
+
row.counterparty.aggregate ? "group" : row.counterparty.anonymous ? "undisclosed" : "company";
|
|
15
|
+
|
|
16
|
+
const GENERIC_WORDS = /\b(And|Of|The|Based|End|Customers?|Suppliers?|Vendors?|Channel|Partners?|Undisclosed|Other|Carriers?|Networks?|Cellular|Distributors?|Retailers?)\b/g;
|
|
17
|
+
|
|
18
|
+
/** The counterparty's name without the kind spelled into it; the kind travels as its own label. */
|
|
19
|
+
export function counterpartyLabel(row: SupplyRow): string {
|
|
20
|
+
const kind = counterpartyKind(row);
|
|
21
|
+
if (kind === "company") return row.counterparty.name;
|
|
22
|
+
const name = counterpartyName(row).replace(/^Group: /, "").replace(/\s*\(undisclosed\)$/i, "");
|
|
23
|
+
// Cohort labels arrive in title case from XBRL member names; generic words read lower case, names keep theirs.
|
|
24
|
+
return name.replace(GENERIC_WORDS, (word) => word.toLowerCase()).replace(/^./, (first) => first.toUpperCase());
|
|
25
|
+
}
|
|
26
|
+
export const counterpartyKindLabel = (row: SupplyRow, short = false) => {
|
|
27
|
+
const kind = counterpartyKind(row);
|
|
28
|
+
if (short) return kind === "group" ? "group" : kind === "undisclosed" ? "undisclosed" : null;
|
|
29
|
+
return kind === "group" ? `${row.role} group` : kind === "undisclosed" ? `undisclosed ${row.role}` : null;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** A filer's segment or product scope in plain words: "Compute And Networking Segment" reads "Compute & Networking". */
|
|
33
|
+
export function scopeWords(scope: string): string {
|
|
34
|
+
return scope.replace(/^Business segments?:\s*/i, "").replace(/\s+segment$/i, "").replace(/\s+and\s+/gi, " & ")
|
|
35
|
+
.replace(/^non[\s-]?us$/i, "non-US").trim();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A disclosed share and what it is a share of, in words. The denominator is
|
|
40
|
+
* always the reporting company's: a supplier saying the focus company is 91%
|
|
41
|
+
* of its revenue reads "of CRUS revenue", never as the focus company's.
|
|
42
|
+
*/
|
|
43
|
+
export function shareParts(row: SupplyRow, focusId?: string | null, { includeReporter = false }: { includeReporter?: boolean } = {}): { value: string; basis: string } | null {
|
|
44
|
+
if (row.pctOfRevenue === null || row.pctBasis === null || trustTier(row) !== 1 || isUnconfirmed(row) || !activeRelationship(row)) return null;
|
|
45
|
+
const reporter = includeReporter || (focusId && row.reportingEntity.id !== focusId) ? `${row.reportingEntity.ticker ?? row.reportingEntity.name} ` : "";
|
|
46
|
+
const scope = row.pctScope ? scopeWords(row.pctScope) : "";
|
|
47
|
+
const basis = row.pctBasis === "cost" ? "cost of sales" : row.pctBasis;
|
|
48
|
+
// XBRL dimensions can qualify the numerator, denominator, or both. NVDA's
|
|
49
|
+
// NonUs fact is a share of total revenue, while TW omits a Data Center qualifier.
|
|
50
|
+
// Neither supports turning its dimensional member into an "of ..." claim.
|
|
51
|
+
if (row.sourceKind === "xbrl" && scope) return { value: `${Number(row.pctOfRevenue.toFixed(1))}%`, basis: `${reporter}${basis} · context: ${scope}` };
|
|
52
|
+
// A scope that names its own denominator ("Vendor non-trade receivables") is a description, read in lower case.
|
|
53
|
+
const scoped = scope && scope.toLowerCase().includes(basis) ? scope.replace(/^[A-Z](?=[a-z])/, (first) => first.toLowerCase()) : `${scope ? `${scope} ` : ""}${basis}`;
|
|
54
|
+
// Form alone does not identify a metric's duration: a 10-Q includes YTD facts.
|
|
55
|
+
return { value: `${Number(row.pctOfRevenue.toFixed(1))}%`, basis: `of ${reporter}${scoped}` };
|
|
56
|
+
}
|
|
57
|
+
export function counterpartyName(row: SupplyRow): string {
|
|
58
|
+
if (row.counterparty.aggregate) return `Group: ${row.counterparty.name.replace(/^Undisclosed customer \((.+)\)$/i, "$1")}`;
|
|
59
|
+
if (!row.counterparty.anonymous) return row.counterparty.name;
|
|
60
|
+
const name = row.counterparty.name;
|
|
61
|
+
const member = name.match(/^Undisclosed [^(]+\((.+)\)$/i)?.[1]
|
|
62
|
+
?? (name.toLowerCase().startsWith("undisclosed") ? null : name);
|
|
63
|
+
if (/^undisclosed/i.test(member ?? "")) return member!;
|
|
64
|
+
return member ? `${member.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\s*\(undisclosed\)/gi, "")} (undisclosed)` : name;
|
|
65
|
+
}
|
|
66
|
+
export const roleLabel = (role: SupplyRole) => role[0]!.toUpperCase() + role.slice(1);
|
|
67
|
+
export const percentage = (row: SupplyRow) => row.pctOfRevenue === null || trustTier(row) !== 1 || isUnconfirmed(row) || !activeRelationship(row) ? "--" : `${Number(row.pctOfRevenue.toFixed(2))}% ${row.pctScope ? "scoped " : ""}${row.pctBasis ?? ""}`;
|
|
68
|
+
export const dollars = (row: SupplyRow) => row.usd === null ? "--" : `${row.usdBasis === "derived" ? "≈ " : ""}$${revenueAmount(row.usd)} ${row.usdBasis}`;
|
|
69
|
+
const scaleLabel = (scale: number) => scale === 1 ? "" : scale === 1_000 ? " thousand" : scale === 1_000_000 ? " million" : scale === 1_000_000_000 ? " billion" : ` ×${scale.toLocaleString("en-US")}`;
|
|
70
|
+
/** Retain the original currency and disclosed scale; never imply an FX conversion. */
|
|
71
|
+
export const nativeValue = (row: SupplyRow) => row.nativeAmount == null || !row.nativeCurrency || !row.nativeScale ? null
|
|
72
|
+
: `${row.nativeAmount.toLocaleString("en-US", { maximumFractionDigits: 12 })} ${row.nativeCurrency}${scaleLabel(row.nativeScale)}`;
|
|
73
|
+
export const disclosedValue = (row: SupplyRow) => nativeValue(row) ?? dollars(row);
|
|
74
|
+
const QUOTE_LANGUAGES: Record<string, string> = { ko: "Korean", ja: "Japanese", zh: "Chinese", "zh-TW": "Chinese", "zh-Hant": "Chinese", "zh-Hans": "Chinese", en: "English" };
|
|
75
|
+
export const quoteLanguageLabel = (row: Pick<SupplyRow, "quoteLanguage">) => QUOTE_LANGUAGES[row.quoteLanguage ?? ""] ?? row.quoteLanguage ?? "original language";
|
|
76
|
+
export const sourceLabel = (row: SupplyRow) => row.sourceKind === "xbrl" ? "XBRL" : row.sourceKind === "filing_text" ? row.form ?? "Filing" : row.sourceKind === "call" ? "Call" : row.sourceKind === "news" ? "News" : row.sourceKind === "press_release" ? "Release" : row.sourceKind === "web" ? "Web" : "Disclosure";
|
|
77
|
+
export function cellText(row: SupplyRow, column: string): string {
|
|
78
|
+
return column === "name" ? counterpartyName(row) : column === "ticker" ? row.counterparty.ticker ?? "--"
|
|
79
|
+
: column === "role" ? roleLabel(row.role) : column === "direction" ? row.direction === "in" ? "In" : row.direction === "out" ? "Out" : "Both"
|
|
80
|
+
: column === "pct" ? percentage(row) : column === "usd" ? disclosedValue(row) : column === "fy" ? row.period
|
|
81
|
+
: column === "publisher" ? row.evidence?.find((item) => item.status === "active")?.publisher ?? row.reportingEntity.name
|
|
82
|
+
: column === "corroboration" ? corroborationLabel(row)
|
|
83
|
+
: column === "evidence" ? evidenceLabel(row) : column === "source" ? sourceLabel(row) : column === "filed" ? evidenceDate(row) : `${Math.round(row.confidence * 100)}%`;
|
|
84
|
+
}
|
|
85
|
+
export type SupplySort = { column: string; direction: "asc" | "desc" };
|
|
86
|
+
export function sortRows(rows: SupplyRow[], sort: SupplySort): SupplyRow[] {
|
|
87
|
+
const value = (row: SupplyRow): string | number | null => sort.column === "pct" ? row.pctOfRevenue : sort.column === "usd" ? row.nativeAmount != null ? row.nativeAmount * (row.nativeScale ?? 1) : row.usd
|
|
88
|
+
: sort.column === "confidence" ? row.confidence : sort.column === "evidence" ? trustTier(row) : cellText(row, sort.column).toLowerCase();
|
|
89
|
+
return [...rows].sort((a, b) => { const x = value(a), y = value(b);
|
|
90
|
+
// Group currencies before comparing amounts. JPY and KRW have no common numeric scale.
|
|
91
|
+
if (sort.column === "usd" && x !== null && y !== null) {
|
|
92
|
+
const currency = (row: SupplyRow) => row.nativeAmount != null ? row.nativeCurrency! : "USD";
|
|
93
|
+
const difference = currency(a).localeCompare(currency(b));
|
|
94
|
+
if (difference) return difference;
|
|
95
|
+
}
|
|
96
|
+
return x === null || y === null ? x === y ? 0 : x === null ? 1 : -1
|
|
97
|
+
: x === y ? a.id.localeCompare(b.id) : (x < y ? -1 : 1) * (sort.direction === "asc" ? 1 : -1); });
|
|
98
|
+
}
|
|
99
|
+
/** Cohort concentrations beside the flow: never nodes or ribbons, one latest disclosure per group and role. */
|
|
100
|
+
export function flowGroups(rows: readonly SupplyRow[]): SupplyRow[] {
|
|
101
|
+
const seen = new Set<string>();
|
|
102
|
+
return [...rows].filter((row) => row.counterparty.aggregate && !isUnconfirmed(row) && activeRelationship(row)).sort((a, b) => b.asOf.localeCompare(a.asOf) || (b.pctOfRevenue ?? -1) - (a.pctOfRevenue ?? -1))
|
|
103
|
+
.filter((row) => { const key = `${row.counterparty.id}:${row.role}`; if (seen.has(key)) return false; seen.add(key); return true; })
|
|
104
|
+
.sort((a, b) => (b.pctOfRevenue ?? -1) - (a.pctOfRevenue ?? -1));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export type FlowBand = "suppliers" | "customers" | "related";
|
|
108
|
+
export interface FlowNode { id: string; label: string; row: SupplyRow | null; band: FlowBand; more: number; weight: number | null; weightScope: string | null; weightBasis: "revenue" | "usd" | null; }
|
|
109
|
+
const revenueKey = (row: SupplyRow) => JSON.stringify([row.reportingEntity.id, row.period, row.pctScope]);
|
|
110
|
+
/** Percentages from different filers and denominators are never summed. One latest edge per counterparty/role is drawn. */
|
|
111
|
+
export function flowBands(rows: SupplyRow[], limit: number, pages: Partial<Record<FlowBand, number>> = {}, focusId?: string): Record<FlowBand, FlowNode[]> {
|
|
112
|
+
const grouped: Record<FlowBand, SupplyRow[]> = { suppliers: [], customers: [], related: [] };
|
|
113
|
+
const seen = new Set<string>();
|
|
114
|
+
for (const row of [...rows].sort((a, b) => trustTier(a) - trustTier(b) || b.asOf.localeCompare(a.asOf) || Number(b.pctOfRevenue !== null || b.usd !== null) - Number(a.pctOfRevenue !== null || a.usd !== null) || b.confidence - a.confidence)) {
|
|
115
|
+
if (row.counterparty.aggregate || isUnconfirmed(row) || !activeRelationship(row)) continue;
|
|
116
|
+
const key = `${row.counterparty.id}:${row.role}`;
|
|
117
|
+
if (seen.has(key)) continue;
|
|
118
|
+
seen.add(key);
|
|
119
|
+
grouped[row.role === "supplier" ? "suppliers" : row.role === "customer" ? "customers" : "related"].push(row);
|
|
120
|
+
}
|
|
121
|
+
return Object.fromEntries((Object.keys(grouped) as FlowBand[]).map((band) => {
|
|
122
|
+
const values = sortRows(grouped[band], { column: "pct", direction: "desc" });
|
|
123
|
+
// One reporter, period and revenue scope form a compatible percentage scale.
|
|
124
|
+
// Prefer the largest compatible group, then whole-company revenue on a tie.
|
|
125
|
+
const revenueGroups = new Map<string, SupplyRow[]>();
|
|
126
|
+
for (const row of values) if (trustTier(row) === 1 && band === "customers" && row.pctBasis === "revenue" && !(row.sourceKind === "xbrl" && row.pctScope) && (row.pctOfRevenue ?? 0) > 0 && (!focusId || row.reportingEntity.id === focusId)) {
|
|
127
|
+
const key = revenueKey(row);
|
|
128
|
+
revenueGroups.set(key, [...(revenueGroups.get(key) ?? []), row]);
|
|
129
|
+
}
|
|
130
|
+
const revenueGroup = [...revenueGroups.values()].sort((a, b) => b.length - a.length || Number(a[0]!.pctScope !== null) - Number(b[0]!.pctScope !== null))[0];
|
|
131
|
+
const scaleKey = revenueGroup ? revenueKey(revenueGroup[0]!) : null;
|
|
132
|
+
const value = (row: SupplyRow) => trustTier(row) !== 1 ? 0 : scaleKey === null ? row.usd ?? 0
|
|
133
|
+
: row.pctBasis === "revenue" && !(row.sourceKind === "xbrl" && row.pctScope) && revenueKey(row) === scaleKey ? row.pctOfRevenue ?? 0 : 0;
|
|
134
|
+
// Use the entire band: paging must not change an existing ribbon's width.
|
|
135
|
+
const max = Math.max(0, ...values.map(value));
|
|
136
|
+
const ordered = [...values].sort((a, b) => value(b) - value(a));
|
|
137
|
+
const pageSize = Math.max(1, limit - 1), paged = values.length > limit;
|
|
138
|
+
const start = paged ? ((pages[band] ?? 0) % Math.ceil(values.length / pageSize)) * pageSize : 0;
|
|
139
|
+
const visible = ordered.slice(start, start + (paged ? pageSize : limit));
|
|
140
|
+
const nodes: FlowNode[] = visible.map((row) => ({ id: row.id, label: counterpartyName(row), row, band, more: 0,
|
|
141
|
+
weight: value(row) > 0 ? value(row) / max : null, weightScope: revenueGroup?.[0]?.pctScope ?? null, weightBasis: scaleKey ? "revenue" : max > 0 ? "usd" : null }));
|
|
142
|
+
if (paged) nodes.push({ id: `more:${band}`, label: `+${values.length - visible.length} more`, row: null, band, more: values.length - visible.length, weight: null, weightScope: null, weightBasis: null });
|
|
143
|
+
return [band, nodes];
|
|
144
|
+
})) as Record<FlowBand, FlowNode[]>;
|
|
145
|
+
}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { publicTickerKey } from "../../../utils/exchanges";
|
|
2
|
+
import { getSharedRegistry } from "../../registry/shared";
|
|
3
|
+
import { useCallback, useMemo, useState } from "react";
|
|
4
|
+
import { isAccessDenied } from "../../../api-client/errors";
|
|
5
|
+
import { usePlanAccess } from "../../../api-client/plan-access";
|
|
6
|
+
import type { SupplyChainPayload, SupplyOptions, SupplyRole, SupplyRow, SupplyTierFilter } from "../../../api-client/supply-chain";
|
|
7
|
+
import {
|
|
8
|
+
Badge, buildSectionedRows, DataTableView, EmptyState, isSectionedItemRow, PageStackView, renderSectionedRowHeader, PaneStatusBody, QueryBar, StatGrid, statGridRows, usePaneNoticeFooter,
|
|
9
|
+
usePaneStatusFooter, usePaneTabs, type DataTableCell, type DataTableColumn, type PaneHint, type SectionedRow, type StatItem,
|
|
10
|
+
} from "../../../components";
|
|
11
|
+
import { RatioBar } from "../../../components/ui/ratio-bar";
|
|
12
|
+
import { getTableWidth } from "../../../components/ui/table-layout";
|
|
13
|
+
import { usePaneRefreshKey } from "../../../components/data-table/table-pane";
|
|
14
|
+
import { useAsyncResource, useAutoRefresh, usePaneSettingValue, usePluginAppActions, usePluginPaneState } from "../../../public/react";
|
|
15
|
+
import { usePaneTickerIdentity } from "../../../state/hooks/pane-ticker";
|
|
16
|
+
import { useThemeColors } from "../../../theme/theme-context";
|
|
17
|
+
import type { PaneProps } from "../../../types/plugin";
|
|
18
|
+
import { Box, Text, TextAttributes, useRendererHost, useUiCapabilities } from "../../../ui";
|
|
19
|
+
import { displayWidth, truncateToDisplayWidth } from "../../../utils/format";
|
|
20
|
+
import { SignInWall } from "../cloud/auth-actions";
|
|
21
|
+
import { CLOUD_PLAN_KEY, useCloudUpgradeAction } from "../shared/cloud-upgrade";
|
|
22
|
+
import { Blurred, LockedOverlay, UpgradeLabel } from "../shared/locked-rows";
|
|
23
|
+
import { isCloudSessionRequired, useResearchCloudSession } from "../shared/research-cloud-session";
|
|
24
|
+
import { cachedSupplyChain, loadSupplyChain, SUPPLY_UNAVAILABLE, validateSupplyChain } from "./client";
|
|
25
|
+
import { useSupplyEvidence } from "./evidence";
|
|
26
|
+
import { SupplyFlow } from "./flow";
|
|
27
|
+
import { SupplyGraphPane } from "./graph-pane";
|
|
28
|
+
import {
|
|
29
|
+
cellText, counterpartyKind, counterpartyKindLabel, counterpartyLabel, counterpartyName, disclosedValue, nativeValue, percentage, ROLE_COLORS, roleLabel,
|
|
30
|
+
shareParts, sortRows, type SupplySort,
|
|
31
|
+
} from "./model";
|
|
32
|
+
import { RowEvidence } from "./row-evidence";
|
|
33
|
+
import { evidenceDate, evidenceLabel, isUnconfirmed, matchesSupplyOptions, supplyOptions, TIER_OPTIONS } from "./trust";
|
|
34
|
+
|
|
35
|
+
type Item = { kind: "edge"; row: SupplyRow } | { kind: "locked"; id: string };
|
|
36
|
+
const itemId = (item: Item) => item.kind === "edge" ? item.row.id : item.id;
|
|
37
|
+
const ROLE_ORDER: SupplyRole[] = ["customer", "supplier", "partner", "competitor", "investee"];
|
|
38
|
+
const ROLE_PLURALS: Record<SupplyRole, string> = { customer: "Customers", supplier: "Suppliers", partner: "Partners", competitor: "Competitors", investee: "Investees" };
|
|
39
|
+
const BAR_CELLS = 8;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A narrow pane folds the ticker into the name and leaves the filing to the
|
|
43
|
+
* evidence view before anything scrolls sideways. Value shows only when some
|
|
44
|
+
* row discloses a value, retaining its original currency and units.
|
|
45
|
+
*/
|
|
46
|
+
function tableColumns(width: number, desktop: boolean, locked: boolean, valueWidth: number | null): DataTableColumn[] {
|
|
47
|
+
const wide = width >= 150, medium = width >= 110;
|
|
48
|
+
const name: DataTableColumn = { id: "name", label: "Counterparty", width: Math.max(locked && !desktop ? 34 : 0, wide ? 30 : medium ? 26 : 20), flexGrow: 1, align: "left" };
|
|
49
|
+
const share: DataTableColumn = { id: "pct", label: "Share", width: wide ? 34 : medium ? 30 : 26, align: "left" };
|
|
50
|
+
const columns: DataTableColumn[] = [
|
|
51
|
+
name,
|
|
52
|
+
{ id: "evidence", label: "Evidence", width: 12, align: "left" },
|
|
53
|
+
...(medium ? [{ id: "ticker", label: "Ticker", width: 8, align: "left" as const }] : []),
|
|
54
|
+
{ id: "role", label: "Role", width: 11, align: "left" },
|
|
55
|
+
share,
|
|
56
|
+
...(valueWidth !== null ? [{ id: "usd", label: "Value", width: Math.max(medium ? 10 : 8, valueWidth), align: "right" as const }] : []),
|
|
57
|
+
{ id: "fy", label: "Period", width: 10, align: "left" },
|
|
58
|
+
...(wide ? [
|
|
59
|
+
{ id: "filed", label: "Published", width: 10, align: "left" as const },
|
|
60
|
+
{ id: "publisher", label: "Publisher", width: 16, align: "left" as const },
|
|
61
|
+
{ id: "corroboration", label: "Origins", width: 8, align: "right" as const },
|
|
62
|
+
] : []),
|
|
63
|
+
];
|
|
64
|
+
// Preserve trust labels, native units and final columns before expanding the share and name.
|
|
65
|
+
// The table ignores its last trailing gutter when deciding whether it fits.
|
|
66
|
+
if (valueWidth !== null || width >= 80) {
|
|
67
|
+
share.width = Math.max(valueWidth !== null ? 10 : 14, share.width - Math.max(0, getTableWidth(columns) - width - 1));
|
|
68
|
+
name.width = Math.max(18, name.width - Math.max(0, getTableWidth(columns) - width - 1));
|
|
69
|
+
}
|
|
70
|
+
return columns;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Company, then disclosed counterparties per role: the strip that heads both tabs. */
|
|
74
|
+
function supplyFigures(data: SupplyChainPayload, views: readonly ("says" | "names")[], options: Required<SupplyOptions>, flow: boolean): StatItem[] {
|
|
75
|
+
const shown = views.flatMap((view) => data[view]).filter((row) => matchesSupplyOptions(row, options) && !isUnconfirmed(row));
|
|
76
|
+
return [
|
|
77
|
+
...(data.entity ? [{ id: "company", label: "Company", value: data.entity.name }] : []),
|
|
78
|
+
...ROLE_ORDER.flatMap((role) => {
|
|
79
|
+
const visible = shown.filter((row) => row.role === role).length;
|
|
80
|
+
const count = data.truncated && !flow && !options.includeLeads ? views.reduce((total, view) => total + data.counts[view][role], 0) : visible;
|
|
81
|
+
return count ? [{ id: role, label: ROLE_PLURALS[role], value: String(count), color: ROLE_COLORS[role],
|
|
82
|
+
detail: visible < count ? `${visible} shown` : undefined }] : [];
|
|
83
|
+
}),
|
|
84
|
+
];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The share as a bar on a 0 to 100% scale, the figure, and what it is a share of. */
|
|
88
|
+
function ShareCell({ row, focusId, width, selected }: { row: SupplyRow; focusId?: string; width: number; selected: boolean }) {
|
|
89
|
+
const colors = useThemeColors();
|
|
90
|
+
const share = shareParts(row, focusId);
|
|
91
|
+
if (!share) return <Text fg={colors.textMuted}>{""}</Text>;
|
|
92
|
+
if (width < 14) return <Text fg={selected ? colors.selectedText : colors.textBright} attributes={TextAttributes.BOLD}>{share.value}</Text>;
|
|
93
|
+
const barWidth = width >= 36 ? BAR_CELLS : Math.min(5, Math.max(3, width - 11));
|
|
94
|
+
return <Box flexDirection="row" width={width} height={1} gap={1} overflow="hidden">
|
|
95
|
+
<RatioBar ratio={row.pctOfRevenue! / 100} width={barWidth} color={ROLE_COLORS[row.role]} track />
|
|
96
|
+
<Text fg={selected ? colors.selectedText : colors.textBright} attributes={TextAttributes.BOLD}>{share.value.padStart(5)}</Text>
|
|
97
|
+
<Text fg={selected ? colors.selectedText : colors.textDim}>{truncateToDisplayWidth(share.basis, Math.max(4, width - barWidth - 7))}</Text>
|
|
98
|
+
</Box>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function SupplyChainPane({ width, height, focused }: PaneProps) {
|
|
102
|
+
const { symbol } = usePaneTickerIdentity();
|
|
103
|
+
return <SupplyView key={symbol ?? "empty"} symbol={symbol} width={width} height={height} focused={focused} />;
|
|
104
|
+
}
|
|
105
|
+
function SupplyView({ symbol, width, height, focused }: Pick<PaneProps, "width" | "height" | "focused"> & { symbol: string | null }) {
|
|
106
|
+
const colors = useThemeColors();
|
|
107
|
+
const host = useRendererHost();
|
|
108
|
+
const desktop = !!useUiCapabilities().nativePaneChrome;
|
|
109
|
+
const { createPaneFromTemplate } = usePluginAppActions();
|
|
110
|
+
const session = useResearchCloudSession();
|
|
111
|
+
const access = usePlanAccess();
|
|
112
|
+
const accessKey = `${session.requestKey}:${access.hasProAccess ? "full" : "preview"}`;
|
|
113
|
+
const openUpgrade = useCloudUpgradeAction("splc");
|
|
114
|
+
const [snapshotSetting] = usePaneSettingValue<SupplyChainPayload | null>("supplySnapshot", null);
|
|
115
|
+
const snapshot = useMemo(() => { try { return snapshotSetting ? validateSupplyChain(snapshotSetting) : null; } catch { return null; } }, [snapshotSetting]);
|
|
116
|
+
const [openingTab] = usePaneSettingValue("tab", "table");
|
|
117
|
+
const [savedTab, setTab] = usePluginPaneState<string>("supply:tab", openingTab);
|
|
118
|
+
const graphTab = savedTab === "graph" || savedTab === "path";
|
|
119
|
+
const [openingTiers] = usePaneSettingValue("tiers", "sec,company,call");
|
|
120
|
+
const initialTiers = useMemo(() => supplyOptions(openingTab === "graph" || openingTab === "path" ? undefined : openingTiers).tiers, [openingTiers, openingTab]);
|
|
121
|
+
const [savedTiers, setTiers] = usePluginPaneState<SupplyTierFilter[]>("supply:tiers", initialTiers);
|
|
122
|
+
const options = useMemo(() => supplyOptions(savedTiers), [savedTiers]);
|
|
123
|
+
const loader = useCallback((force: boolean) => snapshot ? Promise.resolve({ payload: snapshot, stale: false, refreshError: null }) : loadSupplyChain(symbol!, accessKey, force, options), [symbol, accessKey, snapshot, options]);
|
|
124
|
+
const resource = useAsyncResource(symbol && !graphTab ? loader : null, {
|
|
125
|
+
initialData: () => symbol ? cachedSupplyChain(symbol, accessKey, options) : null, clearOnError: isAccessDenied,
|
|
126
|
+
});
|
|
127
|
+
const data = resource.data?.payload ?? null;
|
|
128
|
+
const [openingView] = usePaneSettingValue("view", "says");
|
|
129
|
+
const [savedView, setView] = usePluginPaneState<string>("supply:view", openingView);
|
|
130
|
+
const view = savedView === "names" ? "names" : "says";
|
|
131
|
+
const tooSmall = width < 70 || height < 13;
|
|
132
|
+
const tab = graphTab ? savedTab : savedTab === "flow" && !tooSmall ? "flow" : "table";
|
|
133
|
+
const [sort, setSort] = usePluginPaneState<SupplySort>("supply:sort", { column: "pct", direction: "desc" });
|
|
134
|
+
const [selectedId, setSelected] = usePluginPaneState<string | null>(`supply:selected:${view}`, null);
|
|
135
|
+
const [openingEvidence] = usePaneSettingValue("evidence", false);
|
|
136
|
+
const [openId, setOpen] = usePluginPaneState<string | null>("supply:evidence", null);
|
|
137
|
+
const allRows = useMemo(() => data ? [...data.says, ...data.names].filter((row) => matchesSupplyOptions(row, options)) : [], [data, options]);
|
|
138
|
+
const [flowIds, setFlowIds] = useState<string[]>([]);
|
|
139
|
+
const rows = useMemo(() => data ? sortRows(data[view].filter((row) => matchesSupplyOptions(row, options)), sort) : [], [data, view, sort, options]);
|
|
140
|
+
const selectionRows = tab === "flow" ? allRows.filter((row) => flowIds.includes(row.id)) : rows;
|
|
141
|
+
const selected = tab === "flow" && selectedId?.startsWith("more:") ? null
|
|
142
|
+
: selectionRows.find((row) => row.id === selectedId) ?? (tab === "flow" ? allRows.find((row) => row.id === flowIds[0]) : rows[0]) ?? null;
|
|
143
|
+
const openRow = allRows.find((row) => row.id === openId) ?? (openingEvidence && openId === null ? rows[0] : null) ?? null;
|
|
144
|
+
useSupplyEvidence(graphTab ? null : data, tab, view, tab === "flow" ? flowIds : rows.map((row) => row.id), openRow?.id ?? null, options.tiers);
|
|
145
|
+
const locked = data?.truncated ? Math.max(0, Object.values(data.counts[view]).reduce((a, b) => a + b, 0) - data[view].length) : 0;
|
|
146
|
+
const items = useMemo<SectionedRow<Item>[]>(() => buildSectionedRows<Item>([
|
|
147
|
+
{ label: "Relationships", items: rows.filter((row) => !isUnconfirmed(row)).map((row) => ({ kind: "edge", row })) },
|
|
148
|
+
{ label: "Unconfirmed", items: rows.filter(isUnconfirmed).map((row) => ({ kind: "edge", row })) },
|
|
149
|
+
{ label: "Pro", items: Array.from({ length: Math.min(3, locked) }, (_, i) => ({ kind: "locked", id: `locked:${i}` })) },
|
|
150
|
+
], itemId), [rows, locked]);
|
|
151
|
+
const { strip, rows: tabRows } = usePaneTabs(symbol ? { tabs: [{ value: "table", label: "Table" }, { value: "flow", label: "Flow", disabled: tooSmall }, { value: "graph", label: "Graph" }, { value: "path", label: "Path" }], activeValue: tab, onSelect: setTab, focused, dense: true } : null);
|
|
152
|
+
useAutoRefresh(resource.updatedAt, resource.load);
|
|
153
|
+
usePaneRefreshKey(() => void resource.reload(), { focused: focused && !graphTab });
|
|
154
|
+
const navigate = (row: SupplyRow, template = "supply-chain-pane") => {
|
|
155
|
+
if (row.counterparty.ticker) createPaneFromTemplate(template, { symbol: publicTickerKey(row.counterparty.ticker, row.counterparty.exchange ?? undefined) });
|
|
156
|
+
else setOpen(row.id);
|
|
157
|
+
};
|
|
158
|
+
const evidence = () => {
|
|
159
|
+
if (!selected) return;
|
|
160
|
+
setOpen(selected.id);
|
|
161
|
+
};
|
|
162
|
+
const current = openRow ?? selected;
|
|
163
|
+
const hints: PaneHint[] = [
|
|
164
|
+
...(current ? [{ id: "source", key: "o", label: "pen source", onPress: () => void host.openExternal(current.filingUrl) }] : []),
|
|
165
|
+
...(!openRow && selected ? [{ id: "evidence", key: "e", label: "vidence", onPress: evidence }] : []),
|
|
166
|
+
...(selected?.counterparty.ticker ? [
|
|
167
|
+
{ id: "description", key: "d", label: "es", onPress: () => navigate(selected, "new-ticker-detail-pane") },
|
|
168
|
+
{ id: "financials", key: "f", label: "a", onPress: () => navigate(selected, "financial-analysis-pane") },
|
|
169
|
+
{ id: "chart", key: "g", label: "raph", onPress: () => createPaneFromTemplate("chart-composer-pane", { arg: publicTickerKey(selected.counterparty.ticker!, selected.counterparty.exchange ?? undefined) }) },
|
|
170
|
+
...(getSharedRegistry()?.paneTemplates.has("buildout-pane") ? [{ id: "buildout", key: "t", label: "bo", onPress: () => createPaneFromTemplate("buildout-pane") }] : []),
|
|
171
|
+
] : []),
|
|
172
|
+
...(data?.truncated ? [{ id: "upgrade", key: CLOUD_PLAN_KEY, label: "upgrade", title: "Upgrade to Pro", onPress: openUpgrade }] : []),
|
|
173
|
+
];
|
|
174
|
+
usePaneStatusFooter({ registrationId: "supply-chain", enabled: !graphTab, loading: resource.loading, error: data ? resource.error : null, stale: resource.data?.stale,
|
|
175
|
+
info: data?.asOf ? [{ id: "as-of", parts: [{ text: `as of ${data.asOf}`, tone: "muted" as const }] }] : [], hints });
|
|
176
|
+
usePaneNoticeFooter({ registrationId: "supply-chain:notices", focused, enabled: !graphTab, notices: [
|
|
177
|
+
...(resource.data?.refreshError ? [resource.data.refreshError] : []),
|
|
178
|
+
...(savedTab === "flow" && tooSmall ? ["Flow needs a wider pane. Showing the table."] : []),
|
|
179
|
+
] });
|
|
180
|
+
const focusId = data?.entity?.id;
|
|
181
|
+
const values = rows.filter((row) => nativeValue(row) !== null || row.usd !== null);
|
|
182
|
+
const valueWidth = values.length ? Math.min(28, Math.max(...values.map((row) => displayWidth(disclosedValue(row).replace(/ (disclosed|derived)$/, ""))))) : null;
|
|
183
|
+
const columns = tableColumns(width, desktop, locked > 0, valueWidth);
|
|
184
|
+
const renderCell = (entry: SectionedRow<Item>, column: DataTableColumn, _index: number, state: { selected: boolean }): DataTableCell => {
|
|
185
|
+
if (!isSectionedItemRow(entry)) return { text: "" };
|
|
186
|
+
const item = entry.item;
|
|
187
|
+
if (item.kind === "locked") {
|
|
188
|
+
if (!desktop && column.id === "name" && item.id === "locked:0") {
|
|
189
|
+
const label = column.width >= 34 ? "Upgrade to see every relationship" : "Upgrade to Pro";
|
|
190
|
+
return { text: label, content: <UpgradeLabel text={label} onPress={openUpgrade} role="supply-upgrade" />, onMouseDown: openUpgrade };
|
|
191
|
+
}
|
|
192
|
+
return desktop ? { text: "", content: <Blurred><Text fg={colors.textDim}>{column.id === "name" ? "Additional relationship" : "Hidden"}</Text></Blurred> }
|
|
193
|
+
: { text: "░".repeat(Math.min(8, column.width - 1)), color: colors.textDim };
|
|
194
|
+
}
|
|
195
|
+
const row = item.row;
|
|
196
|
+
const ink = state.selected ? colors.selectedText : isUnconfirmed(row) ? colors.textDim : undefined;
|
|
197
|
+
switch (column.id) {
|
|
198
|
+
case "evidence": return { text: evidenceLabel(row), content: <Badge label={evidenceLabel(row)} tone={isUnconfirmed(row) ? "neutral" : "accent"} /> };
|
|
199
|
+
case "filed": return { text: evidenceDate(row), color: colors.textDim };
|
|
200
|
+
case "publisher": return { text: cellText(row, "publisher"), color: colors.textDim };
|
|
201
|
+
case "corroboration": return { text: String(row.corroboration ?? 1), value: row.corroboration ?? 1, color: colors.textDim, content: <Text fg={colors.textDim}>{row.corroboration ?? 1}</Text> };
|
|
202
|
+
case "name": {
|
|
203
|
+
const company = counterpartyKind(row) === "company";
|
|
204
|
+
// The kind label never gives way to a long cohort name; a column too narrow for the name says it in one word.
|
|
205
|
+
const full = counterpartyKindLabel(row);
|
|
206
|
+
const kind = full && displayWidth(counterpartyLabel(row)) + displayWidth(full) + 4 <= column.width ? full : counterpartyKindLabel(row, true);
|
|
207
|
+
const ticker = !columns.some((entry) => entry.id === "ticker") ? row.counterparty.ticker : null;
|
|
208
|
+
const room = Math.max(8, column.width - (kind ? displayWidth(kind) + 4 : 0) - (ticker ? displayWidth(ticker) + 1 : 0));
|
|
209
|
+
return { text: cellText(row, "name"), content: <Box flexDirection="row" height={1} gap={ticker ? 1 : 2} overflow="hidden">
|
|
210
|
+
<Text fg={ink ?? (company ? colors.textBright : colors.textDim)}>{truncateToDisplayWidth(counterpartyLabel(row), room)}</Text>
|
|
211
|
+
{ticker ? <Text fg={ink ?? colors.textDim}>{ticker}</Text> : null}
|
|
212
|
+
{kind ? desktop ? <Badge label={kind} /> : <Text fg={ink ?? colors.textMuted}>{kind}</Text> : null}
|
|
213
|
+
</Box> };
|
|
214
|
+
}
|
|
215
|
+
case "ticker": {
|
|
216
|
+
const ticker = row.counterparty.ticker;
|
|
217
|
+
if (!ticker) return { text: "", value: null };
|
|
218
|
+
return { text: ticker, color: colors.textBright, content: desktop ? <Badge label={ticker} tone="accent" /> : undefined };
|
|
219
|
+
}
|
|
220
|
+
case "role": return { text: roleLabel(row.role), content: <Box flexDirection="row" height={1} overflow="hidden">
|
|
221
|
+
<Text fg={ROLE_COLORS[row.role]}>●</Text>
|
|
222
|
+
<Text fg={ink ?? ROLE_COLORS[row.role]}>{` ${roleLabel(row.role)}`}</Text>
|
|
223
|
+
</Box> };
|
|
224
|
+
case "pct": return { text: percentage(row) === "--" ? "" : `${shareParts(row, focusId)?.value ?? ""} ${shareParts(row, focusId)?.basis ?? ""}`.trim(), value: row.pctOfRevenue,
|
|
225
|
+
content: <ShareCell row={row} focusId={focusId} width={column.width} selected={state.selected} /> };
|
|
226
|
+
case "usd": return nativeValue(row) === null && row.usd === null ? { text: "", value: null }
|
|
227
|
+
: { text: disclosedValue(row).replace(/ (disclosed|derived)$/, ""), value: row.nativeAmount != null ? row.nativeAmount * (row.nativeScale ?? 1) : row.usd, color: colors.text };
|
|
228
|
+
case "fy": return { text: row.period, color: colors.textDim };
|
|
229
|
+
default: return { text: cellText(row, column.id) };
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
if (!symbol) return <EmptyState title="Select a ticker." />;
|
|
233
|
+
if (graphTab) return <Box width={width} height={height} flexDirection="column">{strip}<SupplyGraphPane symbol={symbol} tab={savedTab as "graph" | "path"} width={width} height={Math.max(3, height - tabRows)} focused={focused} /></Box>;
|
|
234
|
+
if (!data && isCloudSessionRequired(resource.error)) return <SignInWall placement="supply-chain-signin" action="view supply chain disclosures" needsVerification={session.needsVerification} />;
|
|
235
|
+
const bodyHeight = Math.max(3, height - tabRows);
|
|
236
|
+
const figures = data ? supplyFigures(data, tab === "flow" ? ["says", "names"] : [view], options, tab === "flow") : [];
|
|
237
|
+
const tierFilter = { id: "tiers", label: "Evidence", kind: "multi" as const, emptyLabel: "Primary", values: options.tiers, options: TIER_OPTIONS, onChange: (value: string[]) => { setTiers(supplyOptions(value).tiers); setSelected(null); setOpen(null); } };
|
|
238
|
+
const header = <Box flexDirection="column" flexShrink={0}>
|
|
239
|
+
<QueryBar width={width} filters={[{ id: "direction", label: "Direction", inline: true, value: view,
|
|
240
|
+
options: [{ value: "says", label: `${symbol} says` }, { value: "names", label: `Names ${symbol}` }], onChange: (value: string) => { setView(value); setSelected(null); setOpen(null); } }, tierFilter]}
|
|
241
|
+
meta={view === "names" ? "% of reporting company's basis" : undefined} />
|
|
242
|
+
<StatGrid items={figures} width={width} />
|
|
243
|
+
</Box>;
|
|
244
|
+
const flowFigureColumns = Math.min(Math.max(1, figures.length), Math.max(1, Math.floor(width / 24)));
|
|
245
|
+
// A short flow keeps one row of figures, dropping the last roles, so the cards keep their room.
|
|
246
|
+
const flowFigures = bodyHeight < 26 ? figures.slice(0, flowFigureColumns) : figures;
|
|
247
|
+
const selectedShare = selected ? shareParts(selected, focusId) : null;
|
|
248
|
+
const flowMeta = selected ? `${selected.reportingEntity.ticker ?? selected.reportingEntity.name} ${evidenceLabel(selected)} · ${selectedShare ? `${selectedShare.value} ${selectedShare.basis}`
|
|
249
|
+
: nativeValue(selected) !== null || selected.usd !== null ? disclosedValue(selected) : `${roleLabel(selected.role)}, no figure disclosed`}` : undefined;
|
|
250
|
+
return <Box width={width} height={height} flexDirection="column">
|
|
251
|
+
{strip}
|
|
252
|
+
<PaneStatusBody loading={!data && resource.loading} error={!data && resource.error !== SUPPLY_UNAVAILABLE ? resource.error : null}
|
|
253
|
+
empty={!data && resource.error === SUPPLY_UNAVAILABLE} emptyTitle={SUPPLY_UNAVAILABLE} subject="supply chain disclosures">
|
|
254
|
+
{data ? <PageStackView focused={focused} detailOpen={!!openRow} onBack={() => setOpen("")} detailTitle={openRow ? counterpartyName(openRow) : undefined}
|
|
255
|
+
detailContent={openRow ? <RowEvidence row={openRow} focusId={focusId} width={width} height={bodyHeight - 1} focused={focused} /> : null}
|
|
256
|
+
rootContent={tab === "flow" ? <Box flexDirection="column" flexGrow={1} flexBasis={0} minHeight={0}>
|
|
257
|
+
<QueryBar width={width} filters={[tierFilter]} meta={flowMeta} />
|
|
258
|
+
<StatGrid items={flowFigures} width={width} columns={flowFigureColumns} />
|
|
259
|
+
<SupplyFlow rows={allRows} symbol={symbol} focusName={data.entity?.name ?? null} focusId={focusId} width={width}
|
|
260
|
+
height={Math.max(10, bodyHeight - 1 - statGridRows(flowFigures, width, flowFigureColumns) - (data.truncated ? 1 : 0))} focused={focused && !openRow} selectedId={selectedId}
|
|
261
|
+
onSelect={setSelected} onOpen={navigate} onVisible={setFlowIds} />
|
|
262
|
+
{data.truncated ? <Box paddingX={1}><UpgradeLabel text="Upgrade to see every relationship" onPress={openUpgrade} role="supply-upgrade" /></Box> : null}
|
|
263
|
+
</Box> : <DataTableView<SectionedRow<Item>> columns={columns}
|
|
264
|
+
items={items} focused={focused && !openRow} rootWidth={width} rootHeight={bodyHeight} rootBefore={header}
|
|
265
|
+
selection={{ kind: "id", selectedId: selected?.id ?? null, getId: (entry) => entry.key, onChange: (id) => setSelected(id) }} getItemKey={(entry) => entry.key}
|
|
266
|
+
isNavigable={isSectionedItemRow} renderSectionHeader={renderSectionedRowHeader}
|
|
267
|
+
onActivate={(entry) => { if (isSectionedItemRow(entry)) entry.item.kind === "edge" ? navigate(entry.item.row) : openUpgrade(); }}
|
|
268
|
+
renderCell={renderCell} sortColumnId={sort.column} sortDirection={sort.direction}
|
|
269
|
+
onHeaderClick={(column) => setSort((old) => ({ column, direction: old.column === column && old.direction === "desc" ? "asc" : "desc" }))}
|
|
270
|
+
selectedTextOverridesCellColor showHorizontalScrollbar resetScrollKey={`${symbol}:${view}:${options.tiers.join(",")}`}
|
|
271
|
+
emptyStateTitle="No relationships for the selected evidence tiers."
|
|
272
|
+
bodyAfter={locked > 0 && desktop ? <LockedOverlay rows={Math.min(3, locked)} text="Upgrade to see every relationship" onPress={openUpgrade} role="supply-upgrade" /> : undefined} />}
|
|
273
|
+
/> : null}
|
|
274
|
+
</PaneStatusBody>
|
|
275
|
+
</Box>;
|
|
276
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { useRef } from "react";
|
|
2
|
+
import type { SupplyRow } from "../../../api-client/supply-chain";
|
|
3
|
+
import { Badge, Button, DetailScrollBody, ExternalLink, KeyValueRow, Prose, Section, StatGrid, type StatItem } from "../../../components";
|
|
4
|
+
import { useShortcut } from "../../../react/input";
|
|
5
|
+
import { scrollByLines } from "../../../state/pane-scroll-registry";
|
|
6
|
+
import { useThemeColors } from "../../../theme/theme-context";
|
|
7
|
+
import { Box, Text, useUiCapabilities, type ScrollBoxRenderable } from "../../../ui";
|
|
8
|
+
import { isPlainKey } from "../../../utils/keyboard";
|
|
9
|
+
import { counterpartyKind, counterpartyKindLabel, disclosedValue, dollars, nativeValue, ROLE_COLORS, roleLabel, shareParts, sourceLabel } from "./model";
|
|
10
|
+
import { canShowQuote, corroborationLabel, evidenceDate, evidenceLabel, isUnconfirmed, tierLabel } from "./trust";
|
|
11
|
+
import { DisclosureQuote } from "./disclosure-quote";
|
|
12
|
+
|
|
13
|
+
function SourceGloss({ text, width }: { text: string; width: number }) {
|
|
14
|
+
const colors = useThemeColors();
|
|
15
|
+
return <Box flexDirection="column" marginBottom={1}>
|
|
16
|
+
<Text fg={colors.textDim}>English gloss · machine translation</Text>
|
|
17
|
+
<Prose text={text} width={Math.max(1, width - 3)} figures={false} />
|
|
18
|
+
</Box>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Verification and discovery dates follow the same rules in direct and multi-hop evidence. */
|
|
22
|
+
export function SupplyVerification({ row }: { row: SupplyRow }) {
|
|
23
|
+
return <>
|
|
24
|
+
{isUnconfirmed(row) ? <KeyValueRow label="Why unconfirmed" value={row.whyUnconfirmed ?? "Awaiting independent confirmation"} labelWidth={20} /> : null}
|
|
25
|
+
<KeyValueRow label="Corroboration" value={corroborationLabel(row)} labelWidth={20} />
|
|
26
|
+
{row.pctScope ? <KeyValueRow label={row.sourceKind === "xbrl" ? "Tagged context" : "Percentage scope"} value={row.pctScope} labelWidth={20} /> : null}
|
|
27
|
+
{row.sectionRef ? <KeyValueRow label="Section" value={row.sectionRef} labelWidth={20} /> : null}
|
|
28
|
+
{row.jurisdiction ? <KeyValueRow label="Jurisdiction" value={row.jurisdiction} labelWidth={20} /> : null}
|
|
29
|
+
{row.firstSeenAt ? <KeyValueRow label="First seen" value={row.firstSeenAt.slice(0, 10)} detail={row.lastSeenAt ? `last seen ${row.lastSeenAt.slice(0, 10)}` : undefined} labelWidth={20} /> : null}
|
|
30
|
+
{!isUnconfirmed(row) && row.lastConfirmedAt ? <KeyValueRow label="Last confirmed" value={row.lastConfirmedAt.slice(0, 10)} labelWidth={20} /> : null}
|
|
31
|
+
</>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Source history shares quoting rights and native values; Path supplies its scoped keyboard action. */
|
|
35
|
+
export function SupplySources({ row, width, onOpenSource }: { row: SupplyRow; width: number; onOpenSource?: (url: string) => void }) {
|
|
36
|
+
const sourceLink = (url: string, label: string, compactLabel = label) => onOpenSource
|
|
37
|
+
? <Box flexDirection="row"><Button variant="plain" compact flush label={compactLabel} onPress={() => onOpenSource(url)} /></Box>
|
|
38
|
+
: <ExternalLink url={url} label={label} />;
|
|
39
|
+
return <>
|
|
40
|
+
{row.evidence?.length ? [...row.evidence].sort((a, b) => Number(b.status === "active") - Number(a.status === "active") || a.tier - b.tier || b.publishedAt.localeCompare(a.publishedAt)).map((item) =>
|
|
41
|
+
<Section key={item.id} title={item.title || item.publisher} width={Math.max(1, width - 2)}>
|
|
42
|
+
<KeyValueRow label="Publisher" value={item.publisher} detail={item.publishedAt.slice(0, 10)} labelWidth={20} />
|
|
43
|
+
<KeyValueRow label="Evidence" value={tierLabel(item.tier)} detail={item.status !== "active" ? item.status : item.textOrigin === "asr" ? "Speech transcript" : undefined} labelWidth={20} />
|
|
44
|
+
{item.verificationStatus === "lead" ? <KeyValueRow label="Verification" value="Unconfirmed supporting item" labelWidth={20} /> : null}
|
|
45
|
+
{item.value !== null ? <KeyValueRow label={item.valueKind ?? "Source value"} value={`${item.value.toLocaleString("en-US")} ${[item.currency, item.valueUnit].filter(Boolean).join(" ")}`} labelWidth={20} /> : null}
|
|
46
|
+
{canShowQuote(item) && item.quote ? <DisclosureQuote role={row.role} quote={item.quote} quoteLanguage={item.quoteLanguage} width={width} /> : <KeyValueRow label="Quotation" value={item.textOrigin === "snippet" ? "Original text not verified" : "Link only"} labelWidth={20} />}
|
|
47
|
+
{canShowQuote(item) && item.englishGloss ? <SourceGloss text={item.englishGloss} width={width} /> : null}
|
|
48
|
+
{sourceLink(item.url, "Open source")}
|
|
49
|
+
</Section>) : <>
|
|
50
|
+
<KeyValueRow label="Disclosure" value={`${sourceLabel(row)} · filed ${row.filedDate ?? "--"}`} labelWidth={20} />
|
|
51
|
+
{row.quoteMatchMode ? <KeyValueRow label="Evidence match" value={row.quoteMatchMode === "exact" ? "Exact text" : row.quoteMatchMode === "whitespace" ? "Whitespace normalized" : "Unicode and whitespace normalized"} labelWidth={20} /> : null}
|
|
52
|
+
<DisclosureQuote role={row.role} quote={row.quote} quoteLanguage={row.quoteLanguage} width={width} />
|
|
53
|
+
{row.quoteGloss ? <SourceGloss text={row.quoteGloss} width={width} /> : null}
|
|
54
|
+
{sourceLink(row.filingUrl, `Open ${row.form ?? "filing"}${row.filedDate ? ` filed ${row.filedDate}` : ""}`, `Open ${row.form ?? "source"} filing`)}
|
|
55
|
+
</>}
|
|
56
|
+
{row.sourceAttribution ? <Prose text={row.sourceAttribution} width={Math.max(1, width - 3)} figures={false} /> : null}
|
|
57
|
+
</>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function RowEvidence({ row, focusId, width, height, focused }: { row: SupplyRow; focusId?: string; width: number; height: number; focused: boolean }) {
|
|
61
|
+
const desktop = !!useUiCapabilities().nativePaneChrome;
|
|
62
|
+
const scrollRef = useRef<ScrollBoxRenderable>(null);
|
|
63
|
+
useShortcut((event) => {
|
|
64
|
+
if (!focused || !scrollRef.current || event.defaultPrevented) return;
|
|
65
|
+
const delta = isPlainKey(event, "j", "down") ? 1 : isPlainKey(event, "k", "up") ? -1 : 0;
|
|
66
|
+
if (!delta) return;
|
|
67
|
+
event.preventDefault(); event.stopPropagation();
|
|
68
|
+
scrollByLines(scrollRef.current, delta);
|
|
69
|
+
});
|
|
70
|
+
const share = shareParts(row, focusId);
|
|
71
|
+
const native = nativeValue(row);
|
|
72
|
+
const figures: StatItem[] = [
|
|
73
|
+
...(share ? [{ id: "share", label: "Share", value: share.value, detail: share.basis }] : []),
|
|
74
|
+
...(native || row.usd !== null ? [{ id: "value", label: "Value", value: disclosedValue(row) }] : []),
|
|
75
|
+
{ id: "period", label: "Period", value: row.period, detail: row.fiscalYear ? `Fiscal year ${row.fiscalYear}` : undefined },
|
|
76
|
+
{ id: "published", label: "Published", value: evidenceDate(row), detail: evidenceLabel(row) },
|
|
77
|
+
{ id: "confidence", label: "Confidence", value: `${Math.round(row.confidence * 100)}%` },
|
|
78
|
+
];
|
|
79
|
+
const kind = counterpartyKindLabel(row);
|
|
80
|
+
return <Box width={width} height={desktop ? undefined : height} flexGrow={1} flexBasis={0} minHeight={0}>
|
|
81
|
+
<DetailScrollBody ref={scrollRef} resetScrollKey={row.id}>
|
|
82
|
+
<StatGrid items={figures} width={width} />
|
|
83
|
+
<Box flexDirection="column" paddingX={1} paddingTop={1}>
|
|
84
|
+
<Box flexDirection="row" gap={1}><Badge tone={isUnconfirmed(row) ? "neutral" : "accent"} label={evidenceLabel(row)} />
|
|
85
|
+
{row.leadStatus === "verified" ? <Badge tone="positive" label="Verified" /> : null}</Box>
|
|
86
|
+
<KeyValueRow label="Reporting company" value={row.reportingEntity.name} labelWidth={20} />
|
|
87
|
+
<KeyValueRow label="Relationship" value={`${roleLabel(row.role)} · ${row.direction === "in" ? "inbound" : row.direction === "out" ? "outbound" : "mutual"}`} color={ROLE_COLORS[row.role]} labelWidth={20} />
|
|
88
|
+
{kind ? <KeyValueRow label="Counterparty type" value={counterpartyKind(row) === "group" ? row.entityScope === "group" ? "Named corporate group" : "Aggregate concentration group" : "Undisclosed by the filer"} labelWidth={20} /> : null}
|
|
89
|
+
{row.entityScope === "group" && !row.counterparty.aggregate ? <KeyValueRow label="Metric scope" value="Corporate group" labelWidth={20} /> : null}
|
|
90
|
+
{native && row.usd !== null ? <KeyValueRow label="USD amount" value={dollars(row)} labelWidth={20} /> : null}
|
|
91
|
+
<SupplyVerification row={row} />
|
|
92
|
+
<SupplySources row={row} width={width} />
|
|
93
|
+
</Box>
|
|
94
|
+
</DetailScrollBody>
|
|
95
|
+
</Box>;
|
|
96
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { SupplyEvidenceItem, SupplyOptions, SupplyRow, SupplyTier, SupplyTierFilter } from "../../../api-client/supply-chain";
|
|
2
|
+
|
|
3
|
+
export const TIER_OPTIONS: { value: SupplyTierFilter; label: string }[] = [
|
|
4
|
+
{ value: "sec", label: "Filings" }, { value: "company", label: "Company" }, { value: "call", label: "Call" },
|
|
5
|
+
{ value: "reported", label: "Reported" }, { value: "unconfirmed", label: "Unconfirmed" },
|
|
6
|
+
];
|
|
7
|
+
const DEFAULT_TIERS: SupplyTierFilter[] = ["sec", "company", "call"];
|
|
8
|
+
export function supplyOptions(tiers: unknown = DEFAULT_TIERS): Required<SupplyOptions> {
|
|
9
|
+
const values = typeof tiers === "string" ? tiers.split(",").map((value) => value.trim().toLowerCase()).filter(Boolean) : tiers;
|
|
10
|
+
if (!Array.isArray(values) || values.some((value) => !TIER_OPTIONS.some((option) => option.value === value))) {
|
|
11
|
+
throw new Error("Evidence tiers must be sec, company, call, reported or unconfirmed.");
|
|
12
|
+
}
|
|
13
|
+
// Clearing the filter returns to primary evidence; leads always need an explicit opt-in.
|
|
14
|
+
const selected = TIER_OPTIONS.filter((option) => (values.length ? values : DEFAULT_TIERS).includes(option.value)).map((option) => option.value);
|
|
15
|
+
return { tiers: selected, includeLeads: selected.includes("unconfirmed") };
|
|
16
|
+
}
|
|
17
|
+
export const trustTier = (row: SupplyRow): SupplyTier => row.tier ?? (row.sourceKind === "xbrl" || row.sourceKind === "filing_text" ? 1
|
|
18
|
+
: row.sourceKind === "press_release" ? 2 : row.sourceKind === "call" ? 3 : row.sourceKind === "news" ? 4 : 6);
|
|
19
|
+
export const isUnconfirmed = (row: SupplyRow) => row.leadStatus === "lead" || row.claimType === "rumored" || trustTier(row) === 6;
|
|
20
|
+
export const tierLabel = (tier: SupplyTier) => tier === 1 ? "Filing" : tier === 2 ? "Company" : tier === 3 ? "Call" : tier === 5 ? "Reported (trade)" : tier === 4 ? "Reported" : "Unconfirmed";
|
|
21
|
+
export const evidenceLabel = (row: SupplyRow) => isUnconfirmed(row) ? "Unconfirmed" : tierLabel(trustTier(row));
|
|
22
|
+
export const activeRelationship = (row: SupplyRow) => row.leadStatus !== "rejected" && row.leadStatus !== "stale";
|
|
23
|
+
export function matchesSupplyOptions(row: SupplyRow, options: Required<SupplyOptions>): boolean {
|
|
24
|
+
if (!activeRelationship(row)) return false;
|
|
25
|
+
if (isUnconfirmed(row)) return options.includeLeads && options.tiers.includes("unconfirmed");
|
|
26
|
+
const tier = trustTier(row);
|
|
27
|
+
return options.tiers.includes(tier === 1 ? "sec" : tier === 2 ? "company" : tier === 3 ? "call" : "reported");
|
|
28
|
+
}
|
|
29
|
+
export const canShowQuote = (item: SupplyEvidenceItem) => item.quoteRights !== "link_only" && item.textOrigin !== "snippet";
|
|
30
|
+
export function publicEvidence(item: SupplyEvidenceItem): SupplyEvidenceItem {
|
|
31
|
+
return canShowQuote(item) ? item : { ...item, quote: null, englishGloss: null };
|
|
32
|
+
}
|
|
33
|
+
export const corroborationLabel = (row: SupplyRow) => (row.corroboration ?? 1) <= 1 ? "Single source" : `${row.corroboration} independent origins`;
|
|
34
|
+
export const evidenceDate = (row: SupplyRow) => row.evidence?.find((item) => item.status === "active")?.publishedAt.slice(0, 10) ?? row.filedDate ?? row.asOf;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { apiClient } from "../../../api-client";
|
|
2
|
+
import { THEME_PERIODS, type ThemeAggregate, type ThemeMembersPayload, type ThemeSummary, type ThemesPayload } from "../../../api-client/themes";
|
|
3
|
+
import { createPluginCache } from "../../../data/plugin-cache";
|
|
4
|
+
import { cachedCloudResource, loadCloudResource, unavailableOnServer } from "../shared/cloud-resource";
|
|
5
|
+
|
|
6
|
+
const policy = { staleMs: 60_000, expireMs: 2 * 60 * 60_000 };
|
|
7
|
+
export const themesCache = createPluginCache<ThemesPayload>({ kind: "themes", source: "gloom-cloud", schemaVersion: 1, policy });
|
|
8
|
+
export const membersCache = createPluginCache<ThemeMembersPayload>({ kind: "theme-members", source: "gloom-cloud", schemaVersion: 1, policy });
|
|
9
|
+
type Client = Pick<typeof apiClient, "getCloudThemes" | "getCloudThemeMembers">;
|
|
10
|
+
const numberOrNull = (value: unknown) => value === null || typeof value === "number" && Number.isFinite(value);
|
|
11
|
+
const aggregate = (value: ThemeAggregate) => value && numberOrNull(value.value) && Number.isInteger(value.covered)
|
|
12
|
+
&& Number.isInteger(value.total) && value.covered >= 0 && value.covered <= value.total;
|
|
13
|
+
const summary = (row: ThemeSummary) => row && typeof row.id === "string" && typeof row.name === "string"
|
|
14
|
+
&& typeof row.description === "string" && Array.isArray(row.keywords) && row.keywords.every((word) => typeof word === "string")
|
|
15
|
+
&& Number.isInteger(row.memberCount) && row.memberCount > 0 && aggregate(row.breadth)
|
|
16
|
+
&& THEME_PERIODS.every((period) => aggregate(row.returns?.[period]));
|
|
17
|
+
const metadata = (payload: ThemesPayload | ThemeMembersPayload) => payload && Number.isFinite(Date.parse(payload.asOf))
|
|
18
|
+
&& typeof payload.snapshotId === "string" && typeof payload.stale === "boolean";
|
|
19
|
+
function validateThemes(payload: ThemesPayload): ThemesPayload {
|
|
20
|
+
if (!metadata(payload) || !Array.isArray(payload.themes) || !payload.themes.every(summary)) throw new Error("The server returned unreadable thematic baskets");
|
|
21
|
+
return payload;
|
|
22
|
+
}
|
|
23
|
+
function validateMembers(payload: ThemeMembersPayload): ThemeMembersPayload {
|
|
24
|
+
if (!metadata(payload) || !summary(payload.theme) || !Array.isArray(payload.members)
|
|
25
|
+
|| !payload.members.every((row) => row && typeof row.symbol === "string" && (row.name === null || typeof row.name === "string")
|
|
26
|
+
&& ["price", ...THEME_PERIODS].every((field) => numberOrNull(row[field as "price"])))) throw new Error("The server returned unreadable theme members");
|
|
27
|
+
return payload;
|
|
28
|
+
}
|
|
29
|
+
async function fetchPayload<T>(request: () => Promise<T>, validate: (value: T) => T): Promise<T> {
|
|
30
|
+
try { return validate(await request()); } catch (error) {
|
|
31
|
+
throw unavailableOnServer(error, "Thematic baskets are not available on this server yet.");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export const fetchThemes = (client: Client = apiClient) => fetchPayload(() => client.getCloudThemes(), validateThemes);
|
|
35
|
+
export const fetchThemeMembers = (id: string, client: Client = apiClient) => fetchPayload(() => client.getCloudThemeMembers(id), validateMembers);
|
|
36
|
+
export const cachedThemes = () => cachedCloudResource(themesCache, "list", validateThemes);
|
|
37
|
+
export const loadThemes = (force = false) => loadCloudResource(themesCache, "list", () => fetchThemes(), { force, validate: validateThemes });
|
|
38
|
+
export const cachedMembers = (id: string) => cachedCloudResource(membersCache, id, validateMembers);
|
|
39
|
+
export const loadMembers = (id: string, force = false) => loadCloudResource(membersCache, id, () => fetchThemeMembers(id), { force, validate: validateMembers });
|