@gloom-sh/terminal 0.20.17 → 0.20.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -1
- package/src/account/auth-dialog.tsx +19 -1
- package/src/account/billing.ts +2 -1
- package/src/account/heard-from-question.tsx +235 -0
- package/src/account/heard-from.ts +97 -0
- package/src/api-client/data.ts +3 -2
- package/src/api-client/heard-from.ts +72 -0
- package/src/api-client/index.ts +63 -6
- package/src/api-client/mna.ts +18 -0
- package/src/api-client/supply-chain.ts +9 -0
- package/src/api-client/types/billing.ts +35 -1
- package/src/app/global-shortcuts.ts +5 -3
- package/src/app/pro-welcome/keys.ts +27 -0
- package/src/app/pro-welcome/model.ts +158 -0
- package/src/app/pro-welcome/row.tsx +176 -0
- package/src/app/pro-welcome/use-pro-welcome.ts +156 -0
- package/src/app/runtime/external-profile-changes.ts +135 -0
- package/src/app.tsx +33 -2
- package/src/architecture/core-builtin-allowlist.json +1 -1
- package/src/architecture/floating-promise-allowlist.json +0 -1
- package/src/architecture/shortcut-labels-allowlist.json +1 -0
- package/src/cli/alert-listing.ts +98 -0
- package/src/cli/commands/market.ts +138 -22
- package/src/cli/commands/overview.ts +7 -1
- package/src/cli/commands/plugins.ts +3 -2
- package/src/cli/commands/search.ts +30 -6
- package/src/cli/context.ts +16 -5
- package/src/cli/csv-export.ts +2 -1
- package/src/cli/desktop-pane-shot.ts +72 -9
- package/src/cli/glossary.ts +64 -10
- package/src/cli/history-demergers.ts +117 -0
- package/src/cli/history-rows.ts +6 -2
- package/src/cli/index.ts +1 -0
- package/src/cli/known-gaps.ts +16 -0
- package/src/cli/known-us-stocks.ts +18 -0
- package/src/cli/listing-arg.ts +105 -15
- package/src/cli/pane-functions/catalog-snapshot-build.ts +83 -0
- package/src/cli/pane-functions/catalog-snapshot.json +866 -0
- package/src/cli/pane-functions/catalog-snapshot.ts +62 -0
- package/src/cli/pane-functions/catalog.ts +50 -16
- package/src/cli/pane-functions/data.ts +16 -4
- package/src/cli/pane-functions/dom.ts +24 -6
- package/src/cli/pane-functions/freshness.ts +17 -1
- package/src/cli/pane-functions/index.ts +100 -42
- package/src/cli/pane-functions/resolver.ts +8 -5
- package/src/cli/pane-functions/screenshot-assessment.ts +30 -7
- package/src/cli/pane-functions/screenshot-payload.ts +21 -0
- package/src/cli/pane-functions/screenshot-render.ts +3 -1
- package/src/cli/quote-answer.ts +32 -16
- package/src/cli/registry.ts +22 -2
- package/src/cli/result.ts +5 -4
- package/src/cli/series-search.ts +45 -6
- package/src/cli/shot-temp-dir.ts +4 -9
- package/src/components/chart/composite/legend.tsx +43 -18
- package/src/components/chart/composite/panel-surface/panel-cursor.tsx +3 -3
- package/src/components/chart/composite/price-axis-labels.tsx +7 -5
- package/src/components/chart-table/header.tsx +9 -0
- package/src/components/chart-table/layout.ts +11 -11
- package/src/components/command-bar/pane-templates/items.ts +17 -1
- package/src/components/command-bar/routes/root/provider-search.ts +10 -1
- package/src/components/command-bar/routes/root/results.ts +34 -2
- package/src/components/command-bar/routes/root/runtime.ts +8 -1
- package/src/components/command-bar/routes/ticker-search/route.ts +5 -0
- package/src/components/command-bar/workflow/alert.ts +19 -8
- package/src/components/data-table/view.tsx +15 -2
- package/src/components/form-modal/content.tsx +9 -4
- package/src/components/index.ts +1 -1
- package/src/components/layout/header.tsx +9 -5
- package/src/components/layout/pane/capture-status.ts +6 -0
- package/src/components/layout/pane/footer/index.tsx +2 -0
- package/src/components/layout/pane/footer/model.ts +113 -15
- package/src/components/layout/pane/header.tsx +16 -2
- package/src/components/market-board/index.tsx +4 -2
- package/src/components/onboarding/onboarding-frame.tsx +6 -2
- package/src/components/onboarding/onboarding-keyboard.ts +7 -1
- package/src/components/onboarding/onboarding-wizard.tsx +3 -1
- package/src/components/onboarding/portfolio-step/positions-panel.tsx +24 -15
- package/src/components/onboarding/setup-cards.ts +36 -0
- package/src/components/onboarding/use-onboarding-progress.ts +22 -1
- package/src/components/onboarding/wizard-account.ts +6 -1
- package/src/components/onboarding/wizard-model.ts +32 -6
- package/src/components/onboarding/wizard-positions.ts +1 -1
- package/src/components/sign-in-gate.tsx +3 -1
- package/src/components/toggle-list.tsx +6 -8
- package/src/components/ui/confirm-dialog.tsx +47 -7
- package/src/components/ui/data-table/types.ts +8 -0
- package/src/components/ui/display.tsx +17 -2
- package/src/components/ui/index.ts +1 -1
- package/src/components/ui/stat-grid.tsx +4 -0
- package/src/components/ui/status.tsx +13 -1
- package/src/components/ui/table-layout.ts +2 -1
- package/src/components/use-pane-notice-footer.tsx +16 -3
- package/src/data/config/store/index.ts +31 -0
- package/src/data/config/store/node.ts +61 -11
- package/src/data/config/store/normalize.ts +4 -6
- package/src/data/config/store/shared-file.ts +309 -0
- package/src/data/profile-merge.ts +299 -0
- package/src/data/sqlite/checkpointer.ts +11 -1
- package/src/data/sqlite/database.ts +1 -1
- package/src/data/ticker-repository.ts +134 -10
- package/src/data/ticker-store.ts +67 -0
- package/src/data/ticker-writes.ts +5 -0
- package/src/i18n/es.ts +27 -0
- package/src/i18n/ja.ts +27 -0
- package/src/i18n/ko.ts +27 -0
- package/src/i18n/zh-cn.ts +27 -0
- package/src/i18n/zh-tw.ts +27 -0
- package/src/layout-marketplace/gallery-desktop.tsx +2 -2
- package/src/market-data/ah-pair.ts +103 -0
- package/src/market-data/depositary-pair.ts +6 -2
- package/src/market-data/hooks.tsx +33 -2
- package/src/market-data/market/change-basis.ts +2 -1
- package/src/market-data/market/header-market.ts +11 -0
- package/src/market-data/split-terms.ts +28 -0
- package/src/plugins/builtin/account-management/footer.ts +1 -1
- package/src/plugins/builtin/account-management/keyboard.ts +4 -0
- package/src/plugins/builtin/account-management/model.ts +1 -0
- package/src/plugins/builtin/account-management/pane.tsx +75 -7
- package/src/plugins/builtin/account-management/payment-recovery-row.tsx +12 -5
- package/src/plugins/builtin/account-management/pro-cancel.tsx +197 -0
- package/src/plugins/builtin/account-management/trial-cancel.ts +1 -1
- package/src/plugins/builtin/alerts/cli-move.ts +2 -2
- package/src/plugins/builtin/alerts/cli.ts +36 -30
- package/src/plugins/builtin/alerts/constants.ts +10 -0
- package/src/plugins/builtin/alerts/earnings-listing.ts +20 -0
- package/src/plugins/builtin/alerts/format.ts +24 -8
- package/src/plugins/builtin/alerts/index.tsx +38 -9
- package/src/plugins/builtin/alerts/move-checks.ts +7 -0
- package/src/plugins/builtin/alerts/pane.tsx +1 -1
- package/src/plugins/builtin/alerts/quotes.ts +26 -2
- package/src/plugins/builtin/alerts/scheduled.ts +6 -1
- package/src/plugins/builtin/alerts/types.ts +7 -0
- package/src/plugins/builtin/analytics/manual-value.ts +61 -0
- package/src/plugins/builtin/analytics/risk-book.ts +7 -7
- package/src/plugins/builtin/analytics/risk-client.ts +26 -13
- package/src/plugins/builtin/analytics/risk-headless.ts +13 -8
- package/src/plugins/builtin/analytics/risk-model.ts +92 -4
- package/src/plugins/builtin/analytics/risk-pane.tsx +85 -38
- package/src/plugins/builtin/awards/pane.tsx +1 -1
- package/src/plugins/builtin/broker-trading/orders.tsx +2 -2
- package/src/plugins/builtin/central-bank-rates/model.ts +8 -2
- package/src/plugins/builtin/central-bank-rates/pane.tsx +5 -3
- package/src/plugins/builtin/chart-composer/cli-options.ts +4 -2
- package/src/plugins/builtin/chart-composer/data-catalog-pane.tsx +2 -6
- package/src/plugins/builtin/chart-composer/pane.tsx +5 -2
- package/src/plugins/builtin/cloud/auth-actions.tsx +11 -6
- package/src/plugins/builtin/cloud/company-picker.tsx +5 -3
- package/src/plugins/builtin/cloud/upgrade-command.ts +1 -1
- package/src/plugins/builtin/company-kpis/headless.ts +9 -4
- package/src/plugins/builtin/company-kpis/latest.ts +45 -0
- package/src/plugins/builtin/company-kpis/model.ts +38 -8
- package/src/plugins/builtin/company-kpis/pane.tsx +22 -8
- package/src/plugins/builtin/composite/alt-data.ts +20 -0
- package/src/plugins/builtin/composite/application.ts +14 -0
- package/src/plugins/builtin/composite/broker.ts +12 -0
- package/src/plugins/builtin/composite/credit.ts +33 -0
- package/src/plugins/builtin/composite/crypto.ts +10 -0
- package/src/plugins/builtin/composite/earnings.ts +12 -0
- package/src/plugins/builtin/composite/filings.ts +13 -0
- package/src/plugins/builtin/composite/futures-commodities.ts +23 -0
- package/src/plugins/builtin/composite/global-markets.ts +12 -0
- package/src/plugins/builtin/composite/options-volatility.ts +23 -0
- package/src/plugins/builtin/composite/ownership.ts +23 -0
- package/src/plugins/builtin/composite/portfolio.ts +10 -0
- package/src/plugins/builtin/composite/quant.ts +15 -0
- package/src/plugins/builtin/composite/rates-macro.ts +30 -0
- package/src/plugins/builtin/composite/screeners.ts +11 -0
- package/src/plugins/builtin/composite/shared.ts +11 -0
- package/src/plugins/builtin/composite/ticker-core.ts +36 -0
- package/src/plugins/builtin/congress-trades/headless.ts +31 -3
- package/src/plugins/builtin/correlation/index.tsx +13 -17
- package/src/plugins/builtin/correlation/matrix/model.ts +18 -0
- package/src/plugins/builtin/dividend-yield/client.ts +57 -16
- package/src/plugins/builtin/dividend-yield/headless.ts +17 -11
- package/src/plugins/builtin/dividend-yield/model.ts +4 -3
- package/src/plugins/builtin/dividend-yield/pane.tsx +22 -18
- package/src/plugins/builtin/dividend-yield/ranking.ts +1 -1
- package/src/plugins/builtin/dividend-yield/types.ts +4 -0
- package/src/plugins/builtin/dividend-yield/view.ts +23 -12
- package/src/plugins/builtin/earnings/fiscal-quarter.ts +39 -0
- package/src/plugins/builtin/earnings/headless.ts +7 -4
- package/src/plugins/builtin/earnings/history-model.ts +6 -4
- package/src/plugins/builtin/earnings/history-table.ts +4 -3
- package/src/plugins/builtin/earnings-calls/pane.tsx +8 -2
- package/src/plugins/builtin/econ/calendar-model.ts +16 -0
- package/src/plugins/builtin/econ/index.tsx +3 -0
- package/src/plugins/builtin/equity-screener/headless.ts +4 -1
- package/src/plugins/builtin/equity-screener/model.ts +7 -6
- package/src/plugins/builtin/estimate-revisions/headless.ts +1 -1
- package/src/plugins/builtin/exposure/model.ts +10 -0
- package/src/plugins/builtin/exposure/pane.tsx +10 -3
- package/src/plugins/builtin/fx-matrix/amount.ts +15 -1
- package/src/plugins/builtin/fx-matrix/headless.ts +12 -6
- package/src/plugins/builtin/fx-matrix/index.tsx +23 -5
- package/src/plugins/builtin/fx-matrix/settings.ts +9 -4
- package/src/plugins/builtin/kelly-sizer/pane.tsx +9 -4
- package/src/plugins/builtin/market-valuation/pane.tsx +22 -10
- package/src/plugins/builtin/mna/detail.tsx +67 -6
- package/src/plugins/builtin/mna/headless.ts +128 -13
- package/src/plugins/builtin/mna/model.ts +219 -16
- package/src/plugins/builtin/mna/pane.tsx +34 -6
- package/src/plugins/builtin/money-markets/model.ts +14 -5
- package/src/plugins/builtin/money-markets/pane.tsx +4 -3
- package/src/plugins/builtin/news/wire/news/footer.ts +3 -8
- package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +22 -6
- package/src/plugins/builtin/options-scenario/csp-screen.ts +39 -12
- package/src/plugins/builtin/options-scenario/strategy-screen.ts +7 -5
- package/src/plugins/builtin/pe-band/client.ts +13 -1
- package/src/plugins/builtin/pe-band/headless.ts +2 -2
- package/src/plugins/builtin/pe-band/model.ts +63 -10
- package/src/plugins/builtin/pe-band/pane.tsx +5 -5
- package/src/plugins/builtin/portfolio-list/allocation-rows.ts +26 -7
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +66 -13
- package/src/plugins/builtin/portfolio-list/cli/render.ts +76 -33
- package/src/plugins/builtin/portfolio-list/headless.ts +69 -22
- package/src/plugins/builtin/portfolio-list/pane/data.ts +3 -3
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +29 -14
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +2 -2
- package/src/plugins/builtin/relative-rotation/pane.tsx +2 -3
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +5 -1
- package/src/plugins/builtin/research/event-model.ts +31 -13
- package/src/plugins/builtin/research/headless.ts +8 -1
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +19 -17
- package/src/plugins/builtin/sectors/index.tsx +6 -9
- package/src/plugins/builtin/shared/cloud-upgrade.ts +1 -1
- package/src/plugins/builtin/shared/earnings-report.ts +19 -4
- package/src/plugins/builtin/shared/report-freshness.ts +2 -3
- package/src/plugins/builtin/supply-chain/client.ts +34 -9
- package/src/plugins/builtin/supply-chain/evidence.ts +3 -2
- package/src/plugins/builtin/supply-chain/flow.tsx +4 -3
- package/src/plugins/builtin/supply-chain/graph-model.ts +14 -7
- package/src/plugins/builtin/supply-chain/graph-pane.tsx +3 -1
- package/src/plugins/builtin/supply-chain/graph.tsx +6 -3
- package/src/plugins/builtin/supply-chain/headless.ts +19 -4
- package/src/plugins/builtin/supply-chain/model.ts +50 -6
- package/src/plugins/builtin/supply-chain/pane.tsx +76 -16
- package/src/plugins/builtin/ticker-detail/adr-pair/ah.ts +62 -0
- package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +119 -20
- package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +51 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +25 -14
- package/src/plugins/builtin/ticker-detail/overview/model.ts +17 -1
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -0
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +9 -2
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +9 -2
- package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +5 -2
- package/src/plugins/builtin/volatility/model.ts +17 -0
- package/src/plugins/builtin/volatility/pane.tsx +13 -4
- package/src/plugins/builtin/world-indices/index.tsx +2 -0
- package/src/plugins/builtin/world-indices/table.tsx +15 -0
- package/src/plugins/builtin/world-venue-map/evidence.ts +3 -2
- package/src/plugins/builtin/world-venue-map/headless.ts +28 -16
- package/src/plugins/builtin/world-venue-map/index.ts +19 -6
- package/src/plugins/builtin/world-venue-map/layered-pane.tsx +9 -5
- package/src/plugins/builtin/world-venue-map/layers.ts +33 -11
- package/src/plugins/builtin/world-venue-map/map.tsx +12 -0
- package/src/plugins/builtin/world-venue-map/pane.tsx +35 -6
- package/src/plugins/builtin/world-venue-map/place.ts +119 -0
- package/src/plugins/catalog-data.ts +20 -0
- package/src/plugins/catalog-lazy.ts +51 -0
- package/src/plugins/catalog-ui.ts +16 -18
- package/src/plugins/host-smoke.ts +5 -2
- package/src/portfolio/allocation.ts +79 -19
- package/src/portfolio/cash-balances.ts +76 -0
- package/src/portfolio/mutations.ts +43 -8
- package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
- package/src/renderers/desktop/window-layouts.ts +14 -0
- package/src/renderers/dom/data-table/row.tsx +2 -0
- package/src/renderers/dom/host/tabs.tsx +57 -8
- package/src/renderers/dom/styles.css +13 -5
- package/src/renderers/electrobun/bun/desktop/backend-requests.ts +4 -0
- package/src/renderers/electrobun/bun/desktop/backend.ts +22 -1
- package/src/renderers/electrobun/bun/window/native-min-size.ts +6 -1
- package/src/renderers/electrobun/shared/protocol.ts +4 -0
- package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +50 -12
- package/src/renderers/electrobun/view/remote/ticker-repository.ts +10 -0
- package/src/series/standalone-catalog.ts +5 -4
- package/src/series/standalone.ts +13 -7
- package/src/sources/gloomberb-cloud/index.ts +14 -3
- package/src/sources/gloomberb-cloud/perpetuals.ts +60 -3
- package/src/sources/provider-router/financials.ts +20 -13
- package/src/sources/provider-router/index.ts +4 -0
- package/src/sources/provider-router/search.ts +1 -0
- package/src/sync/collections-contributor.ts +3 -1
- package/src/sync/config-merge.ts +10 -1
- package/src/sync/sanitize.ts +26 -2
- package/src/tickers/company-name-listing.ts +16 -2
- package/src/tickers/listing-fate.ts +12 -8
- package/src/tickers/renamed-listings.ts +43 -10
- package/src/tickers/search/home-listing.ts +28 -0
- package/src/tickers/search/index.ts +19 -7
- package/src/tickers/terminal-codes.ts +11 -1
- package/src/time-series/resolve.ts +3 -1
- package/src/time-series/spec.ts +2 -2
- package/src/time-series/types.ts +1 -1
- package/src/types/data-provider.ts +11 -0
- package/src/types/financials.ts +39 -3
- package/src/types/ticker.ts +10 -2
- package/src/utils/cli-output.ts +1 -1
- package/src/utils/declared-dividends.ts +13 -1
- package/src/utils/dividend-cash.ts +5 -1
- package/src/utils/forward-dividend.ts +4 -3
- package/src/utils/remove-folder.ts +37 -0
- package/src/utils/trailing-dividend.ts +1 -1
- package/src/plugins/builtin/composite-plugins.ts +0 -285
|
@@ -20,16 +20,23 @@ export const ROLE_COLORS: Readonly<Record<SupplyRole, string>> = currentThemeCol
|
|
|
20
20
|
|
|
21
21
|
/** A company, a customer the filer does not name, or a geographic or channel cohort that is not one company. */
|
|
22
22
|
export type CounterpartyKind = "company" | "undisclosed" | "group";
|
|
23
|
-
export const counterpartyKind = (row: SupplyRow): CounterpartyKind =>
|
|
23
|
+
export const counterpartyKind = (row: Pick<SupplyRow, "counterparty">): CounterpartyKind =>
|
|
24
24
|
row.counterparty.aggregate ? "group" : row.counterparty.anonymous ? "undisclosed" : "company";
|
|
25
25
|
|
|
26
26
|
const GENERIC_WORDS = /\b(And|Of|The|Based|End|Customers?|Suppliers?|Vendors?|Channel|Partners?|Undisclosed|Other|Carriers?|Networks?|Cellular|Distributors?|Retailers?)\b/g;
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* The measure a filer spells into an undisclosed customer's member ("Revenue Customer 1", "A/R Customer A"), which
|
|
30
|
+
* the share beside it already names: the label keeps what tells the customers apart.
|
|
31
|
+
*/
|
|
32
|
+
const MEASURE_PREFIX = /^(?:revenues?|net sales|sales|a\/r|ar|accounts receivables?|receivables?|trade receivables?)\s+(?=(?:customer|client|supplier|vendor)\b)/i;
|
|
33
|
+
|
|
28
34
|
/** The counterparty's name without the kind spelled into it; the kind travels as its own label. */
|
|
29
|
-
export function counterpartyLabel(row: SupplyRow): string {
|
|
35
|
+
export function counterpartyLabel(row: Pick<SupplyRow, "counterparty" | "pctBasis">): string {
|
|
30
36
|
const kind = counterpartyKind(row);
|
|
31
37
|
if (kind === "company") return row.counterparty.name;
|
|
32
|
-
const name = counterpartyName(row).replace(/^Group: /, "").replace(/\s*\(undisclosed\)$/i, "")
|
|
38
|
+
const name = counterpartyName(row).replace(/^Group: /, "").replace(/\s*\(undisclosed\)$/i, "")
|
|
39
|
+
.replace(row.pctBasis ? MEASURE_PREFIX : /^$/, "");
|
|
33
40
|
// Cohort labels arrive in title case from XBRL member names; generic words read lower case, names keep theirs.
|
|
34
41
|
return name.replace(GENERIC_WORDS, (word) => word.toLowerCase()).replace(/^./, (first) => first.toUpperCase());
|
|
35
42
|
}
|
|
@@ -54,8 +61,26 @@ export const counterpartyKindLabel = (row: SupplyRow, short = false) => {
|
|
|
54
61
|
if (isRelatedParty(row)) return namedGroup(row) ? short ? "related group" : "related-party group" : "related party";
|
|
55
62
|
return namedGroup(row) ? short ? "group" : "corporate group" : null;
|
|
56
63
|
};
|
|
64
|
+
/**
|
|
65
|
+
* A row's role as the company it is read for sees it. An investee row runs
|
|
66
|
+
* from the holder to the company held, so read inbound its counterparty is
|
|
67
|
+
* the holder: Sinopec, whose interim report holds CATL shares, is CATL's
|
|
68
|
+
* investor, not its investee.
|
|
69
|
+
*/
|
|
70
|
+
export const rowRoleLabel = (row: Pick<SupplyRow, "role"> & { direction?: SupplyRow["direction"] }) =>
|
|
71
|
+
row.role === "investee" && row.direction === "in" ? "Investor" : roleLabel(row.role);
|
|
57
72
|
/** The relationship in words: "Related-party supplier" for a related-party trade, else the role. */
|
|
58
|
-
export const relationshipLabel = (row: Pick<SupplyRow, "role" | "relatedParty">
|
|
73
|
+
export const relationshipLabel = (row: Pick<SupplyRow, "role" | "relatedParty"> & { direction?: SupplyRow["direction"] }) =>
|
|
74
|
+
isRelatedParty(row) ? `Related-party ${rowRoleLabel(row).toLowerCase()}` : rowRoleLabel(row);
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The end of a counterparty's label that tells it apart, which a narrow column keeps whole while it cuts what comes
|
|
78
|
+
* before: the letter or number of an undisclosed customer ("Customer 1", "Customer A"). Null for a company's name.
|
|
79
|
+
*/
|
|
80
|
+
export function counterpartyLabelEnd(row: Pick<SupplyRow, "counterparty" | "pctBasis">): string | null {
|
|
81
|
+
if (counterpartyKind(row) !== "undisclosed") return null;
|
|
82
|
+
return / (?:\d{1,3}|[A-Z]|One|Two|Three|Four|Five|Six)$/i.exec(counterpartyLabel(row))?.[0] ?? null;
|
|
83
|
+
}
|
|
59
84
|
|
|
60
85
|
/** A filer's segment or product scope in plain words: "Compute And Networking Segment" reads "Compute & Networking". */
|
|
61
86
|
export function scopeWords(scope: string): string {
|
|
@@ -107,6 +132,15 @@ export function shareParts(row: SupplyRow, focusId?: string | null, { includeRep
|
|
|
107
132
|
if (row.sourceKind === "xbrl" && scope) {
|
|
108
133
|
if (taggedDimension(row, "ProductOrService"))
|
|
109
134
|
return shareWords(value, [`of ${reporter}total ${basis} (${lowerFirst(scope)} sales)${owed}`, `of ${reporter}total ${basis}`, `${reporter}${basis}`]);
|
|
135
|
+
// A segment tag says where the revenue comes from or whose revenue it is a share of; the filing's sentence says
|
|
136
|
+
// which (`pctScopeBasis`): NVDA's 16% is of total revenue, from Compute & Networking; RPM's 24% of Consumer's own.
|
|
137
|
+
if (row.pctScopeBasis === "total")
|
|
138
|
+
return shareWords(value, [`of ${reporter}total ${basis}, from ${scope}${owed}`, `of ${reporter}total ${basis}`, `${reporter}${basis}`]);
|
|
139
|
+
if (row.pctScopeBasis === "segment")
|
|
140
|
+
return shareWords(value, [`of ${reporter}${scope} ${basis}${owed}`, `of ${reporter}segment ${basis}`, `${reporter}segment ${basis}`]);
|
|
141
|
+
// A segment tag not yet read is said as a tag, never as the share's base.
|
|
142
|
+
if (taggedDimension(row, "BusinessSegments") || /segment/i.test(row.pctScope ?? ""))
|
|
143
|
+
return shareWords(value, [`of ${reporter}${basis}, tagged ${scope}${owed}`, `of ${reporter}${basis}`, `${reporter}${basis}`]);
|
|
110
144
|
return shareWords(value, [`of ${reporter}${basis} (${scope})${owed}`, `${reporter}${basis}`]);
|
|
111
145
|
}
|
|
112
146
|
const scoped = `${scope ? `${scope} ` : ""}${basis}`;
|
|
@@ -151,7 +185,7 @@ export function disclosureText(row: SupplyRow): string {
|
|
|
151
185
|
.filter((part): part is string => !!part).join(", ") || "Tagged in the filing";
|
|
152
186
|
}
|
|
153
187
|
|
|
154
|
-
export function counterpartyName(row: SupplyRow): string {
|
|
188
|
+
export function counterpartyName(row: Pick<SupplyRow, "counterparty">): string {
|
|
155
189
|
if (row.counterparty.aggregate) return `Group: ${row.counterparty.name.replace(/^Undisclosed customer \((.+)\)$/i, "$1")}`;
|
|
156
190
|
if (!row.counterparty.anonymous) return row.counterparty.name;
|
|
157
191
|
const name = row.counterparty.name;
|
|
@@ -220,6 +254,16 @@ export function supplyRoleCounts(data: Pick<SupplyChainPayload, "says" | "names"
|
|
|
220
254
|
*/
|
|
221
255
|
export const earlierRows = (data: Pick<SupplyChainPayload, "earlier">, view: "says" | "names"): SupplyRow[] => data.earlier?.[view] ?? [];
|
|
222
256
|
|
|
257
|
+
/**
|
|
258
|
+
* The direction a table opens on before one is chosen: what the company says,
|
|
259
|
+
* unless its own reports name no one and others' name it (CATL: none of its
|
|
260
|
+
* own, ten from customers, competitors and a holder), not an empty table.
|
|
261
|
+
*/
|
|
262
|
+
export function openingSupplyView(data: Pick<SupplyChainPayload, "says" | "names" | "earlier">, options: Required<SupplyOptions>): "says" | "names" {
|
|
263
|
+
const shown = (rows: SupplyRow[]) => rows.some((row) => matchesSupplyOptions(row, options));
|
|
264
|
+
return !shown(data.says) && !shown(earlierRows(data, "says")) && shown(data.names) ? "names" : "says";
|
|
265
|
+
}
|
|
266
|
+
|
|
223
267
|
/** Disclosures a free preview withholds from these views: the server's counts less the rows it sent. */
|
|
224
268
|
export function lockedDisclosures(data: Pick<SupplyChainPayload, "says" | "names" | "counts" | "earlier" | "earlierCounts">, views: readonly ("says" | "names")[]): number {
|
|
225
269
|
const total = (counts: Record<SupplyRole, number> | undefined) => Object.values(counts ?? {}).reduce((a, b) => a + b, 0);
|
|
@@ -347,7 +391,7 @@ export const periodText = (row: Pick<SupplyRow, "period" | "periodMonths">) => {
|
|
|
347
391
|
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";
|
|
348
392
|
export function cellText(row: SupplyRow, column: string): string {
|
|
349
393
|
return column === "name" ? counterpartyName(row) : column === "ticker" ? entityTicker(row.counterparty) ?? MISSING_VALUE
|
|
350
|
-
: column === "role" ?
|
|
394
|
+
: column === "role" ? rowRoleLabel(row) : column === "direction" ? row.direction === "in" ? "In" : row.direction === "out" ? "Out" : "Both"
|
|
351
395
|
: column === "pct" ? percentage(row) : column === "usd" ? disclosedValue(row) : column === "fy" ? periodText(row)
|
|
352
396
|
: column === "publisher" ? row.evidence?.find((item) => item.status === "active")?.publisher ?? row.reportingEntity.name
|
|
353
397
|
: column === "corroboration" ? corroborationLabel(row)
|
|
@@ -31,11 +31,12 @@ import { SupplyFlow } from "./flow";
|
|
|
31
31
|
import { SupplyGraphPane } from "./graph-pane";
|
|
32
32
|
import { entityTicker } from "./graph-model";
|
|
33
33
|
import {
|
|
34
|
-
cellText, counterpartyKind, counterpartyKindLabel, counterpartyLabel, counterpartyName, disclosedValue, earlierRows, fitShareBasis, focusCompanyLabel, focusCompanyName, receivablesConcentration, lockedDisclosures, nativeValue, percentage, relationshipLabel, ROLE_COLORS,
|
|
34
|
+
cellText, counterpartyKind, disclosureText, isTaggedFact, counterpartyKindLabel, counterpartyLabel, counterpartyLabelEnd, counterpartyName, disclosedValue, earlierRows, fitShareBasis, focusCompanyLabel, focusCompanyName, receivablesConcentration, lockedDisclosures, nativeValue, percentage, relationshipLabel, ROLE_COLORS, openingSupplyView, rowRoleLabel,
|
|
35
35
|
periodDate, shareParts, sortRows, supplyEmptyText, supplyPreviewNote, supplyRoleCounts, type SupplySort,
|
|
36
36
|
} from "./model";
|
|
37
37
|
import { RowEvidence } from "./row-evidence";
|
|
38
|
-
import {
|
|
38
|
+
import { DisclosureQuote } from "./disclosure-quote";
|
|
39
|
+
import { canShowQuote, evidenceDate, evidenceLabel, isUnconfirmed, matchesSupplyOptions, supplyOptions, TIER_OPTIONS } from "./trust";
|
|
39
40
|
import { logFailure } from "../../../utils/log-failure";
|
|
40
41
|
|
|
41
42
|
type Item = { kind: "edge"; row: SupplyRow } | { kind: "locked"; id: string };
|
|
@@ -79,6 +80,8 @@ function shareLayout(width: number, bases: BasisForms): ShareLayout {
|
|
|
79
80
|
return { bar: 0, basis: Math.max(0, width - SHARE_FIGURE_CELLS - 1) };
|
|
80
81
|
}
|
|
81
82
|
|
|
83
|
+
/** The most a name column widens to keep its longest name whole. */
|
|
84
|
+
const NAME_KEEP_MAX_CELLS = 34;
|
|
82
85
|
/** A period end date ("31 Dec 2025"); its length, when the source states it, reads with it in a wider column. */
|
|
83
86
|
const PERIOD_DATE_CELLS = 11;
|
|
84
87
|
/**
|
|
@@ -91,7 +94,7 @@ const PERIOD_DATE_CELLS = 11;
|
|
|
91
94
|
* Value shows only when some row discloses a value, retaining its original
|
|
92
95
|
* currency and units.
|
|
93
96
|
*/
|
|
94
|
-
function tableColumns(width: number, desktop: boolean, locked: boolean, valueWidth: number | null, bases: BasisForms, periodWidth = PERIOD_DATE_CELLS): DataTableColumn[] {
|
|
97
|
+
export function tableColumns(width: number, desktop: boolean, locked: boolean, valueWidth: number | null, bases: BasisForms, periodWidth = PERIOD_DATE_CELLS, nameCells = 0): DataTableColumn[] {
|
|
95
98
|
const wide = width >= 150, medium = width >= 110;
|
|
96
99
|
const name: DataTableColumn = { id: "name", label: "Counterparty", width: Math.max(locked && !desktop ? 34 : 0, wide ? 30 : medium ? 26 : 20), flexGrow: 1, align: "left" };
|
|
97
100
|
// Wide enough for the longest whole wording beside its bar and figure ("27% of total revenue (gold sales)"), within a cap;
|
|
@@ -104,7 +107,8 @@ function tableColumns(width: number, desktop: boolean, locked: boolean, valueWid
|
|
|
104
107
|
let columns: DataTableColumn[] = [
|
|
105
108
|
name,
|
|
106
109
|
{ id: "evidence", label: "Evidence", width: 12, align: "left" },
|
|
107
|
-
|
|
110
|
+
// A listing as every function writes it: 000063:SZSE whole.
|
|
111
|
+
...(medium ? [{ id: "ticker", label: "Ticker", width: 11, align: "left" as const }] : []),
|
|
108
112
|
{ id: "role", label: "Role", width: 11, align: "left" },
|
|
109
113
|
share,
|
|
110
114
|
...(valueWidth !== null ? [{ id: "usd", label: "Value", width: Math.max(medium ? 10 : 8, valueWidth), align: "right" as const }] : []),
|
|
@@ -128,7 +132,16 @@ function tableColumns(width: number, desktop: boolean, locked: boolean, valueWid
|
|
|
128
132
|
share.width = Math.max(shareMin, share.width - Math.max(0, overflow()));
|
|
129
133
|
name.width = Math.max(nameMin, name.width - Math.max(0, overflow()));
|
|
130
134
|
};
|
|
131
|
-
|
|
135
|
+
// A name keeps what tells it apart before a share keeps the words after its basis: "Hon Hai Precision Industry" whole
|
|
136
|
+
// beside "16% of total revenue", not "Hon Hai Precision In…" beside "…, from Compute & Networking", which the
|
|
137
|
+
// selected row's own words and its evidence still say. Within a cap, so one long name never takes the table.
|
|
138
|
+
const nameKeep = Math.min(NAME_KEEP_MAX_CELLS, Math.max(preferred.name, nameCells));
|
|
139
|
+
const shareShort = withBar + (valueWidth !== null ? bare : Math.max(bare, ...bases.map((forms) => forms[Math.min(1, forms.length - 1)]!)));
|
|
140
|
+
preferred.name = nameKeep;
|
|
141
|
+
fit(shareFloor, nameKeep);
|
|
142
|
+
if (overflow() > 0) fit(Math.min(shareFloor, shareShort), nameKeep);
|
|
143
|
+
// A pane too narrow for both gives way as before: the name, then the columns, then the share's shorter forms.
|
|
144
|
+
if (overflow() > 0) fit(shareFloor);
|
|
132
145
|
for (const id of ["ticker", "fy"]) {
|
|
133
146
|
if (overflow() <= 0) break;
|
|
134
147
|
if (!columns.some((column) => column.id === id)) continue;
|
|
@@ -149,9 +162,13 @@ function tableColumns(width: number, desktop: boolean, locked: boolean, valueWid
|
|
|
149
162
|
* disclosures a free preview locks: the strip that heads the table and the flow.
|
|
150
163
|
*/
|
|
151
164
|
function supplyFigures(data: SupplyChainPayload, views: readonly ("says" | "names")[], options: Required<SupplyOptions>, company: string | null): StatItem[] {
|
|
165
|
+
// Investee rows that all run into the company are its investors (rowRoleLabel).
|
|
166
|
+
const stakes = views.flatMap((view) => data[view].filter((row) => row.role === "investee"));
|
|
167
|
+
const investors = stakes.length > 0 && stakes.every((row) => row.direction === "in");
|
|
152
168
|
return [
|
|
153
169
|
...(data.entity && company ? [{ id: "company", label: "Company", value: company }] : []),
|
|
154
|
-
...supplyRoleCounts(data, views, options).map(({ role, counterparties, locked }) => ({ id: role,
|
|
170
|
+
...supplyRoleCounts(data, views, options).map(({ role, counterparties, locked }) => ({ id: role,
|
|
171
|
+
label: role === "investee" && investors ? "Investors" : ROLE_PLURALS[role], value: String(counterparties),
|
|
155
172
|
color: ROLE_COLORS[role], detail: locked ? `+${locked} locked` : undefined })),
|
|
156
173
|
];
|
|
157
174
|
}
|
|
@@ -175,6 +192,27 @@ function ShareCell({ row, focusId, width, layout, selected }: { row: SupplyRow;
|
|
|
175
192
|
</Box>;
|
|
176
193
|
}
|
|
177
194
|
|
|
195
|
+
/** Rows a table must leave free before the selected relationship's own words take them: a heading and a few lines of quote. */
|
|
196
|
+
const DISCLOSURE_BAND_MIN_ROWS = 8;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* The selected relationship's own words, in the rows a short table leaves
|
|
200
|
+
* free, as a chart takes a short table's spare rows: the quote the row rests
|
|
201
|
+
* on, or a tagged fact read out. Who said it and when are the row's own
|
|
202
|
+
* columns; `e` opens the whole evidence.
|
|
203
|
+
*/
|
|
204
|
+
function SelectedDisclosure({ row, width, height }: { row: SupplyRow; width: number; height: number }) {
|
|
205
|
+
const desktop = !!useUiCapabilities().nativePaneChrome;
|
|
206
|
+
const item = row.evidence?.find((entry) => entry.status === "active" && canShowQuote(entry) && entry.quote);
|
|
207
|
+
const tagged = !item && isTaggedFact(row);
|
|
208
|
+
// The terminal gives it the rows the table leaves; the desktop sets it under the last row at its own height.
|
|
209
|
+
return <Box flexDirection="column" width={width} height={desktop ? undefined : height} flexShrink={desktop ? 0 : 1} minHeight={0} overflow="hidden" paddingX={desktop ? 0 : 1}
|
|
210
|
+
data-gloom-role="supply-selected-disclosure">
|
|
211
|
+
<DisclosureQuote role={row.role} quote={item?.quote ?? disclosureText(row)} quoteLanguage={item?.quoteLanguage ?? row.quoteLanguage}
|
|
212
|
+
width={Math.max(1, width - (desktop ? 0 : 2))} label={tagged ? "Tagged in the filing" : undefined} />
|
|
213
|
+
</Box>;
|
|
214
|
+
}
|
|
215
|
+
|
|
178
216
|
export function SupplyChainPane({ width, height, focused }: PaneProps) {
|
|
179
217
|
const { symbol, ticker } = usePaneTickerIdentity();
|
|
180
218
|
return <SupplyView key={symbol ?? "empty"} symbol={symbol} listingName={ticker?.metadata.name ?? null} width={width} height={height} focused={focused} />;
|
|
@@ -198,14 +236,17 @@ function SupplyView({ symbol, listingName, width, height, focused }: Pick<PanePr
|
|
|
198
236
|
const initialTiers = useMemo(() => supplyOptions(openingTab === "graph" || openingTab === "path" ? undefined : openingTiers).tiers, [openingTiers, openingTab]);
|
|
199
237
|
const [savedTiers, setTiers] = usePluginPaneState<SupplyTierFilter[]>("supply:tiers", initialTiers);
|
|
200
238
|
const options = useMemo(() => supplyOptions(savedTiers), [savedTiers]);
|
|
201
|
-
|
|
239
|
+
// `--as-of`: the disclosures known by that day, read by the server and never shown past it.
|
|
240
|
+
const [asOfSetting] = usePaneSettingValue<string>("asOf", "");
|
|
241
|
+
const read = useMemo(() => ({ ...options, ...asOfSetting ? { asOf: asOfSetting } : {} }), [options, asOfSetting]);
|
|
242
|
+
const loader = useCallback((force: boolean) => snapshot ? Promise.resolve({ payload: snapshot, stale: false, refreshError: null }) : loadSupplyChain(symbol!, accessKey, force, read), [symbol, accessKey, snapshot, read]);
|
|
202
243
|
const resource = useAsyncResource(symbol && !graphTab ? loader : null, {
|
|
203
|
-
initialData: () => symbol ? cachedSupplyChain(symbol, accessKey,
|
|
244
|
+
initialData: () => symbol ? cachedSupplyChain(symbol, accessKey, read) : null, clearOnError: isAccessDenied,
|
|
204
245
|
});
|
|
205
246
|
const data = resource.data?.payload ?? null;
|
|
206
|
-
const [openingView] = usePaneSettingValue("view", "
|
|
247
|
+
const [openingView] = usePaneSettingValue("view", "");
|
|
207
248
|
const [savedView, setView] = usePluginPaneState<string>("supply:view", openingView);
|
|
208
|
-
const view = savedView === "names"
|
|
249
|
+
const view = savedView === "names" || savedView === "says" ? savedView : data ? openingSupplyView(data, options) : "says";
|
|
209
250
|
const tooSmall = width < 70 || height < 13;
|
|
210
251
|
const tab = graphTab ? savedTab : savedTab === "flow" && !tooSmall ? "flow" : "table";
|
|
211
252
|
const [sort, setSort] = usePluginPaneState<SupplySort>("supply:sort", { column: "pct", direction: "desc" });
|
|
@@ -253,8 +294,10 @@ function SupplyView({ symbol, listingName, width, height, focused }: Pick<PanePr
|
|
|
253
294
|
] : []),
|
|
254
295
|
...(data?.truncated ? [{ id: "upgrade", key: CLOUD_PLAN_KEY, label: "upgrade", title: "Upgrade to Pro", onPress: openUpgrade }] : []),
|
|
255
296
|
];
|
|
297
|
+
// Dated by the newest disclosure the reader can see, as its Published column says, never by the latest period one covers.
|
|
298
|
+
const published = useMemo(() => allRows.map(evidenceDate).sort().at(-1) ?? null, [allRows]);
|
|
256
299
|
usePaneStatusFooter({ registrationId: "supply-chain", enabled: !graphTab, loading: resource.loading, error: data ? resource.error : null, stale: resource.data?.stale,
|
|
257
|
-
info:
|
|
300
|
+
info: published ? [{ id: "as-of", parts: [{ text: asOfSetting ? `known by ${asOfSetting}` : `as of ${published}`, tone: "muted" as const }] }] : [], hints });
|
|
258
301
|
usePaneNoticeFooter({ registrationId: "supply-chain:notices", focused, enabled: !graphTab, notices: [
|
|
259
302
|
...(resource.data?.refreshError ? [resource.data.refreshError] : []),
|
|
260
303
|
...(savedTab === "flow" && tooSmall ? ["Flow needs a wider pane. Showing the table."] : []),
|
|
@@ -276,8 +319,13 @@ function SupplyView({ symbol, listingName, width, height, focused }: Pick<PanePr
|
|
|
276
319
|
// no column; laid out a cell narrower, the table also clears its own scrollbar. Otherwise the
|
|
277
320
|
// evidence view says it.
|
|
278
321
|
const periodWidth = Math.max(PERIOD_DATE_CELLS, ...tableRows.map((row) => displayWidth(cellText(row, "fy"))));
|
|
279
|
-
|
|
280
|
-
const
|
|
322
|
+
// What the longest name needs with its kind beside it ("Customer 1" and "undisclosed"), so the column can keep it whole.
|
|
323
|
+
const nameCells = Math.max(0, ...tableRows.map((row) => {
|
|
324
|
+
const kind = counterpartyKindLabel(row, true);
|
|
325
|
+
return displayWidth(counterpartyLabel(row)) + (kind ? displayWidth(kind) + 4 : 0);
|
|
326
|
+
}));
|
|
327
|
+
const dated = tableColumns(width, desktop, locked > 0, valueWidth, bases, PERIOD_DATE_CELLS, nameCells);
|
|
328
|
+
const lengths = periodWidth > PERIOD_DATE_CELLS ? tableColumns(width - 1, desktop, locked > 0, valueWidth, bases, periodWidth, nameCells) : null;
|
|
281
329
|
const columns = lengths?.some((column) => column.id === "fy") && lengths.map((column) => column.id).join() === dated.map((column) => column.id).join() ? lengths : dated;
|
|
282
330
|
const shareColumn = shareLayout(columns.find((column) => column.id === "pct")?.width ?? 0, bases);
|
|
283
331
|
const renderCell = (entry: SectionedRow<Item>, column: DataTableColumn, _index: number, state: { selected: boolean }): DataTableCell => {
|
|
@@ -308,7 +356,8 @@ function SupplyView({ symbol, listingName, width, height, focused }: Pick<PanePr
|
|
|
308
356
|
const room = Math.max(8, column.width - (kind ? displayWidth(kind) + 4 : 0) - (ticker ? displayWidth(ticker) + 1 : 0));
|
|
309
357
|
// On the desktop the name gives way at the column's edge by CSS and the ticker and kind keep their room.
|
|
310
358
|
return { text: cellText(row, "name"), content: <Box flexDirection="row" height={1} gap={ticker ? 1 : 2} overflow="hidden" {...(desktop ? { flexShrink: 1, minWidth: 0 } : {})}>
|
|
311
|
-
|
|
359
|
+
{/* A name cut short keeps the letter or number that tells two undisclosed customers apart ("Cu… 1"), in both renderers. */}
|
|
360
|
+
<ClippedText fg={ink ?? (company ? colors.textBright : colors.textDim)} text={counterpartyLabel(row)} width={room} keepEnd={counterpartyLabelEnd(row)} />
|
|
312
361
|
{ticker ? <Text fg={ink ?? colors.textDim} style={desktop ? { flex: "0 0 auto" } : undefined}>{ticker}</Text> : null}
|
|
313
362
|
{kind ? desktop ? <Badge label={kind} /> : <Text fg={ink ?? colors.textMuted}>{kind}</Text> : null}
|
|
314
363
|
</Box> };
|
|
@@ -321,7 +370,7 @@ function SupplyView({ symbol, listingName, width, height, focused }: Pick<PanePr
|
|
|
321
370
|
// The text a copy or export reads names a related party; the cell draws the role beside the name's chip.
|
|
322
371
|
case "role": return { text: relationshipLabel(row), content: <Box flexDirection="row" height={1} overflow="hidden">
|
|
323
372
|
<Text fg={ROLE_COLORS[row.role]}>●</Text>
|
|
324
|
-
<Text fg={ink ?? ROLE_COLORS[row.role]}>{` ${
|
|
373
|
+
<Text fg={ink ?? ROLE_COLORS[row.role]}>{` ${rowRoleLabel(row)}`}</Text>
|
|
325
374
|
</Box> };
|
|
326
375
|
case "pct": return { text: percentage(row) === MISSING_VALUE ? "" : `${shareParts(row, focusId)?.value ?? ""} ${shareParts(row, focusId)?.basis ?? ""}`.trim(), value: row.pctOfRevenue,
|
|
327
376
|
content: <ShareCell row={row} focusId={focusId} width={column.width} layout={shareColumn} selected={state.selected} /> };
|
|
@@ -347,6 +396,11 @@ function SupplyView({ symbol, listingName, width, height, focused }: Pick<PanePr
|
|
|
347
396
|
const header = concentrationChart
|
|
348
397
|
? <ChartTableHeader width={width} height={bodyHeight} tableRows={items.length} tableColumns={columns} figures={figures} chart={concentrationChart} query={query} />
|
|
349
398
|
: <Box flexDirection="column" flexShrink={0}>{query}<StatGrid items={figures} width={width} /></Box>;
|
|
399
|
+
// The rows the table leaves free under its last row: the query bar, the figures, the column header and the rows,
|
|
400
|
+
// and a scrollbar row a wide table may draw.
|
|
401
|
+
const spareRows = bodyHeight - 1 - statGridRows(figures, width) - 1 - items.length - 1;
|
|
402
|
+
const disclosureBand = tab === "table" && !concentrationChart && !openRow && selected && spareRows >= DISCLOSURE_BAND_MIN_ROWS
|
|
403
|
+
? <SelectedDisclosure row={selected} width={width} height={spareRows} /> : null;
|
|
350
404
|
const flowFigureColumns = Math.min(Math.max(1, figures.length), Math.max(1, Math.floor(width / 24)));
|
|
351
405
|
// A short flow keeps one row of figures, dropping the last roles, so the cards keep their room.
|
|
352
406
|
const flowFigures = bodyHeight < 26 ? figures.slice(0, flowFigureColumns) : figures;
|
|
@@ -368,6 +422,9 @@ function SupplyView({ symbol, listingName, width, height, focused }: Pick<PanePr
|
|
|
368
422
|
{data.truncated ? <Box paddingX={1}><UpgradeLabel text="Upgrade to see every relationship" onPress={openUpgrade} role="supply-upgrade" /></Box> : null}
|
|
369
423
|
</Box> : <DataTableView<SectionedRow<Item>> columns={columns}
|
|
370
424
|
items={items} focused={focused && !openRow} rootWidth={width} rootHeight={bodyHeight} rootBefore={header}
|
|
425
|
+
// The selected row's words follow the table in the terminal's spare rows; on the desktop they follow its last row,
|
|
426
|
+
// after the locked preview, and the table runs on to the footer below them.
|
|
427
|
+
{...disclosureBand && !desktop ? { rootAfter: disclosureBand, fitRows: true, virtualize: false } : {}}
|
|
371
428
|
selection={{ kind: "id", selectedId: selected?.id ?? null, getId: (entry) => entry.key, onChange: (id) => setSelected(id) }} getItemKey={(entry) => entry.key}
|
|
372
429
|
isNavigable={isSectionedItemRow}
|
|
373
430
|
// The placeholders stand for every locked disclosure; the header says what free shows and counts those, as the figures do.
|
|
@@ -377,7 +434,10 @@ function SupplyView({ symbol, listingName, width, height, focused }: Pick<PanePr
|
|
|
377
434
|
onHeaderClick={(column) => setSort((old) => ({ column, direction: old.column === column && old.direction === "desc" ? "asc" : "desc" }))}
|
|
378
435
|
selectedTextOverridesCellColor showHorizontalScrollbar resetScrollKey={`${symbol}:${view}:${options.tiers.join(",")}`}
|
|
379
436
|
emptyStateTitle={supplyEmptyText(data) ?? "No relationships for the selected evidence tiers."}
|
|
380
|
-
bodyAfter={
|
|
437
|
+
bodyAfter={desktop && (locked > 0 || disclosureBand) ? <>
|
|
438
|
+
{locked > 0 ? <LockedOverlay rows={Math.min(3, locked)} text="Upgrade to see every relationship" onPress={openUpgrade} role="supply-upgrade" /> : null}
|
|
439
|
+
{disclosureBand}
|
|
440
|
+
</> : undefined} />}
|
|
381
441
|
/> : null}
|
|
382
442
|
</PaneStatusBody>
|
|
383
443
|
</Box>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { useAsyncResource } from "../../../../react/async-resource";
|
|
3
|
+
import { useFxRateObservations, useQuoteEntry } from "../../../../market-data/hooks";
|
|
4
|
+
import { resolveEntryData } from "../../../../market-data/selectors";
|
|
5
|
+
import { pairPriceInput } from "../../../../market-data/depositary-pair";
|
|
6
|
+
import {
|
|
7
|
+
ahListingKey, ahPairOf, ahPairSide, ahSpotFromUsdValues, compareAhPair, type AhComparison, type AhPair,
|
|
8
|
+
} from "../../../../market-data/ah-pair";
|
|
9
|
+
import type { Quote } from "../../../../types/financials";
|
|
10
|
+
import { canonicalExchange, parsePublicTickerKey } from "../../../../utils/exchanges";
|
|
11
|
+
import { useAssetData } from "../../../runtime";
|
|
12
|
+
|
|
13
|
+
/** Venues an A+H company's lines trade on. */
|
|
14
|
+
const AH_VENUES = new Set(["HKEX", "SSE", "SZSE"]);
|
|
15
|
+
|
|
16
|
+
/** Whether a listing is on a venue an A+H company's line trades on, so its company's lines are worth reading. */
|
|
17
|
+
export function mayBeAhLine(symbol: string | null | undefined, exchange?: string | null): boolean {
|
|
18
|
+
if (!symbol) return false;
|
|
19
|
+
const venue = parsePublicTickerKey(ahListingKey(symbol, exchange)).exchange;
|
|
20
|
+
return AH_VENUES.has(canonicalExchange(venue ?? ""));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The listing's A+H pair and how its two prices compare, as the ADR tab and DES read it. */
|
|
24
|
+
export interface AhPairState {
|
|
25
|
+
pair: AhPair;
|
|
26
|
+
/** Which line the listing is. */
|
|
27
|
+
side: "h" | "a";
|
|
28
|
+
quotes: { h: Quote | null; a: Quote | null };
|
|
29
|
+
/** Null while a price is missing. */
|
|
30
|
+
comparison: AhComparison | null;
|
|
31
|
+
/** The other line's price is still being read. */
|
|
32
|
+
loading: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The A+H pair of the listing `symbol` (on `exchange`), from the company's
|
|
37
|
+
* lines Gloom Cloud holds (`getIssuerListings`), with the other line's price
|
|
38
|
+
* read through the quote path, both dollar rates, and the comparison. Null for
|
|
39
|
+
* a listing off those venues or of a company that is no A+H pair. `ownQuote`
|
|
40
|
+
* is the listing's own price as the pane already shows it.
|
|
41
|
+
*/
|
|
42
|
+
export function useAhPair(symbol: string | null | undefined, exchange: string | null | undefined, ownQuote: Quote | null | undefined): AhPairState | null {
|
|
43
|
+
const dataProvider = useAssetData();
|
|
44
|
+
const reads = mayBeAhLine(symbol, exchange) && !!dataProvider?.getIssuerListings;
|
|
45
|
+
const loader = useCallback(
|
|
46
|
+
() => dataProvider!.getIssuerListings!(symbol!, exchange ?? undefined),
|
|
47
|
+
[dataProvider, exchange, symbol],
|
|
48
|
+
);
|
|
49
|
+
const issuer = useAsyncResource(reads ? loader : null);
|
|
50
|
+
const pair = reads ? ahPairOf(issuer.data) : null;
|
|
51
|
+
const side = pair && symbol ? ahPairSide(pair, symbol, exchange) : null;
|
|
52
|
+
const other = pair && side ? (side === "h" ? pair.a : pair.h) : null;
|
|
53
|
+
const otherEntry = useQuoteEntry(other, null);
|
|
54
|
+
const rates = useFxRateObservations(other ? ["CNY", "HKD"] : []);
|
|
55
|
+
if (!pair || !side) return null;
|
|
56
|
+
const otherQuote = resolveEntryData(otherEntry) ?? null;
|
|
57
|
+
const quotes = side === "h" ? { h: ownQuote ?? null, a: otherQuote } : { h: otherQuote, a: ownQuote ?? null };
|
|
58
|
+
const spot = ahSpotFromUsdValues(rates.get("CNY") ?? null, rates.get("HKD") ?? null);
|
|
59
|
+
const comparison = compareAhPair(pairPriceInput(pair.h, quotes.h), pairPriceInput(pair.a, quotes.a), spot);
|
|
60
|
+
const loading = !otherQuote && (!otherEntry || otherEntry.phase === "loading" || otherEntry.phase === "idle");
|
|
61
|
+
return { pair, side, quotes, comparison, loading };
|
|
62
|
+
}
|
|
@@ -8,13 +8,17 @@ import { canonicalExchange, displayTickerKey, isUsListingExchange, parsePublicTi
|
|
|
8
8
|
import { listingSuffixCandidate } from "../../../../sources/listing-symbols";
|
|
9
9
|
import { companyLinesName } from "../../../../tickers/company-name";
|
|
10
10
|
import { logFailure } from "../../../../utils/log-failure";
|
|
11
|
-
import { adrPairComparison, adrPairFigures, adrPairInputRows, adrPairLegs, ADR_PAIR_TEMPLATE_ID } from "./model";
|
|
11
|
+
import { adrPairComparison, adrPairFigures, adrPairInputRows, adrPairLegs, ahPairFigures, ahPairInputRows, ADR_PAIR_TEMPLATE_ID } from "./model";
|
|
12
|
+
import { ahPairOf, ahPairSide, compareAhPair, type AhComparison, type AhPair, type AhSpot } from "../../../../market-data/ah-pair";
|
|
13
|
+
import { pairPriceInput } from "../../../../market-data/depositary-pair";
|
|
14
|
+
import { mayBeAhLine } from "./ah";
|
|
12
15
|
|
|
13
16
|
/** Words that ask for this report's figures without being its code: `fn CCL` answers with ADR. */
|
|
14
17
|
export const ADR_PAIR_KEYWORDS = [
|
|
15
18
|
"adr", "adrs", "adr vs home", "adr ratio", "adr premium", "adr discount", "depositary receipt", "depositary receipts",
|
|
16
19
|
"home listing", "home line", "implied fx", "implied exchange rate", "implied dollar", "ccl", "contado con liquidacion",
|
|
17
20
|
"dolar ccl", "mep", "dolar mep", "dolar bolsa", "blue chip swap", "cross listing", "dual listing",
|
|
21
|
+
"a/h premium", "ah premium", "a+h premium",
|
|
18
22
|
];
|
|
19
23
|
|
|
20
24
|
type LoadContext = Parameters<HeadlessPaneDefinition["load"]>[1];
|
|
@@ -73,41 +77,137 @@ function otherLinesNote(other: { issuer: string; lines: string[] } | null, home:
|
|
|
73
77
|
return `${companyLinesName(home?.name, other.issuer)} also lists ${list}.`;
|
|
74
78
|
}
|
|
75
79
|
|
|
80
|
+
/** An A+H pair's comparison, with the quotes it read; null for a listing of no such pair. */
|
|
81
|
+
interface AhRead {
|
|
82
|
+
pair: AhPair;
|
|
83
|
+
quotes: { h: Quote | null; a: Quote | null };
|
|
84
|
+
comparison: AhComparison | null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The A+H pair of the listing `key`, from the company's lines Gloom Cloud
|
|
89
|
+
* holds, both lines read through the quote path and the yuan's Hong Kong
|
|
90
|
+
* dollar rate from both dollar rates (as `fx` dates them). Null for a listing
|
|
91
|
+
* off HKEX, SSE and SZSE, or of a company that is no such pair.
|
|
92
|
+
*/
|
|
93
|
+
async function readAhPair(key: string, ctx: LoadContext, failed: (label: string) => (error: unknown) => null): Promise<AhRead | null> {
|
|
94
|
+
const { getIssuerListings } = ctx.marketData;
|
|
95
|
+
const instrument = await resolveHeadlessInstrument(ctx, key);
|
|
96
|
+
if (!getIssuerListings || !mayBeAhLine(instrument.symbol, instrument.exchange)) return null;
|
|
97
|
+
const issuer = await Promise.resolve().then(() => getIssuerListings.call(ctx.marketData, instrument.symbol, instrument.exchange || undefined))
|
|
98
|
+
.catch(logFailure("plugins.adr-pair", "Reading the company's listings failed", null));
|
|
99
|
+
const pair = ahPairOf(issuer);
|
|
100
|
+
if (!pair || !ahPairSide(pair, instrument.symbol, instrument.exchange)) return null;
|
|
101
|
+
const [h, a, cny, hkd] = await Promise.all([
|
|
102
|
+
readQuote(pair.h, ctx, failed(pair.h)),
|
|
103
|
+
readQuote(pair.a, ctx, failed(pair.a)),
|
|
104
|
+
readSpot("CNY", ctx).catch(failed(dollarPairLabel("CNY"))),
|
|
105
|
+
readSpot("HKD", ctx).catch(failed(dollarPairLabel("HKD"))),
|
|
106
|
+
]);
|
|
107
|
+
// Units a dollar, so Hong Kong dollars a yuan is the one over the other.
|
|
108
|
+
const spot: AhSpot | null = cny && hkd ? {
|
|
109
|
+
rate: hkd.rate / cny.rate,
|
|
110
|
+
observedAt: cny.observedAt != null && hkd.observedAt != null ? Math.min(cny.observedAt, hkd.observedAt) : null,
|
|
111
|
+
} : null;
|
|
112
|
+
return { pair, quotes: { h, a }, comparison: compareAhPair(pairPriceInput(pair.h, h), pairPriceInput(pair.a, a), spot) };
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const INPUT_COLUMNS = [
|
|
116
|
+
{ key: "listing", header: "Listing" },
|
|
117
|
+
{ key: "role", header: "Role" },
|
|
118
|
+
{ key: "price", header: "Price", align: "right" as const },
|
|
119
|
+
{ key: "asOf", header: "As of (UTC)" },
|
|
120
|
+
{ key: "session", header: "Session" },
|
|
121
|
+
];
|
|
122
|
+
|
|
123
|
+
/** The A+H pair's figures and inputs as report sections, leaving out an input line `listed` already holds. */
|
|
124
|
+
function ahSections(read: AhRead & { comparison: AhComparison }, listed: readonly string[] = []) {
|
|
125
|
+
const { comparison } = read;
|
|
126
|
+
return [
|
|
127
|
+
{
|
|
128
|
+
title: `${read.pair.h} vs ${read.pair.a}`,
|
|
129
|
+
entries: ahPairFigures(comparison, read.quotes.h).map((figure) => ({
|
|
130
|
+
key: figure.id, label: figure.label,
|
|
131
|
+
value: figure.id === "ah-premium" ? comparison.premiumPercent
|
|
132
|
+
: figure.id === "ah-a-in-hkd" ? comparison.aInHkd
|
|
133
|
+
: comparison.spot?.rate ?? null,
|
|
134
|
+
formatted: figure.detail ? `${figure.value} (${figure.detail})` : figure.value,
|
|
135
|
+
})),
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
title: "A+H inputs",
|
|
139
|
+
columns: INPUT_COLUMNS,
|
|
140
|
+
rows: ahPairInputRows(comparison, read.quotes, listed).map(({ opens: _opens, ...row }) => row),
|
|
141
|
+
},
|
|
142
|
+
];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** What the report's metadata says of an A+H pair. */
|
|
146
|
+
function ahMetadata(read: AhRead & { comparison: AhComparison }) {
|
|
147
|
+
const { comparison } = read;
|
|
148
|
+
return {
|
|
149
|
+
hShare: read.pair.h, aShare: read.pair.a, ahPremiumPercent: comparison.premiumPercent, aInHkd: comparison.aInHkd,
|
|
150
|
+
hPrice: comparison.h.price, hObservedAt: comparison.h.observedAt, aPrice: comparison.a.price, aObservedAt: comparison.a.observedAt,
|
|
151
|
+
cnyHkd: comparison.spot?.rate ?? null, cnyHkdObservedAt: comparison.spot?.observedAt ?? null,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const hasComparison = (read: AhRead | null): read is AhRead & { comparison: AhComparison } => !!read?.comparison;
|
|
156
|
+
|
|
76
157
|
export const adrPairHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
77
158
|
shape: "bundle",
|
|
78
|
-
argument: { kind: "ticker", description: "A depositary receipt (GGAL, TSM)
|
|
159
|
+
argument: { kind: "ticker", description: "A depositary receipt (GGAL, TSM), its home listing (GGAL.BA, 2330.TW), or a line of an A+H company (1088:HKEX, 601088:SSE)" },
|
|
79
160
|
options: [],
|
|
80
161
|
discovery: {
|
|
81
162
|
// CCL is also a ticker (Carnival), so neither word opens ADR: `fn CCL` and `catalog ccl` point to it.
|
|
82
163
|
suggestFor: ["CCL", "MEP"],
|
|
83
164
|
screenshotReadiness: "ready",
|
|
84
165
|
limitations: [
|
|
85
|
-
"Listings Gloom Cloud pairs with a receipt only; the ratio is the depositary's, checked against both lines' prices.",
|
|
166
|
+
"Listings Gloom Cloud pairs with a receipt, or whose company it holds as an A+H pair, only; the ratio is the depositary's, checked against both lines' prices.",
|
|
86
167
|
],
|
|
87
168
|
},
|
|
88
|
-
description: "A depositary receipt beside its home listing: the ratio, both regular-session prices with when each was set, the dollar rate they imply (home × ratio / ADR, the CCL rate for an Argentine pair), spot, and the receipt's premium or discount at spot.",
|
|
169
|
+
description: "A depositary receipt beside its home listing: the ratio, both regular-session prices with when each was set, the dollar rate they imply (home × ratio / ADR, the CCL rate for an Argentine pair), spot, and the receipt's premium or discount at spot. A line of an A+H company adds its other line: the H price over the A price at the yuan's spot rate, each price in its own currency with when it was set.",
|
|
89
170
|
describe: ({ symbols }) => `ADR vs Home | ${symbols[0] ?? ""}`,
|
|
90
171
|
async load({ symbols }, ctx) {
|
|
91
172
|
const key = symbols[0]!;
|
|
92
173
|
const financials = await loadHeadlessFinancials(ctx, key);
|
|
93
174
|
ctx.signal.throwIfAborted();
|
|
94
175
|
const legs = adrPairLegs(financials, null, key);
|
|
176
|
+
const errors: string[] = [];
|
|
177
|
+
const failed = (label: string) => (error: unknown) => {
|
|
178
|
+
errors.push(`${label}: ${error instanceof Error ? error.message : String(error)}`);
|
|
179
|
+
return null;
|
|
180
|
+
};
|
|
95
181
|
if (!legs) {
|
|
182
|
+
// A line of an A+H company with no receipt: its two lines alone.
|
|
183
|
+
const ah = await readAhPair(key, ctx, failed);
|
|
184
|
+
ctx.signal.throwIfAborted();
|
|
185
|
+
if (hasComparison(ah)) {
|
|
186
|
+
return {
|
|
187
|
+
sections: ahSections(ah),
|
|
188
|
+
...(ah.comparison.timingNote ? { notes: [ah.comparison.timingNote] } : {}),
|
|
189
|
+
...(errors.length > 0 ? { errors } : {}),
|
|
190
|
+
freshness: {
|
|
191
|
+
observations: [ah.quotes.h, ah.quotes.a].filter((quote): quote is Quote => !!quote).map((quote) => ({ ...quoteObservation(quote) })),
|
|
192
|
+
},
|
|
193
|
+
metadata: { ...ahMetadata(ah), template: ADR_PAIR_TEMPLATE_ID },
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
if (ah) {
|
|
197
|
+
const missing = !ah.quotes.h ? ah.pair.h : ah.pair.a;
|
|
198
|
+
return { sections: [], empty: `No price for ${missing}, so the pair cannot be compared.`, unavailableSymbols: [missing], errors };
|
|
199
|
+
}
|
|
96
200
|
return {
|
|
97
201
|
sections: [],
|
|
98
|
-
empty: `${key} has no depositary receipt pair on record. ADR takes a receipt (GGAL, TSM)
|
|
202
|
+
empty: `${key} has no depositary receipt or A+H pair on record. ADR takes a receipt (GGAL, TSM), its home listing (GGAL.BA, 2330.TW) or a line of an A+H company (1088:HKEX, 601088:SSE).`,
|
|
99
203
|
unavailableSymbols: [key],
|
|
100
204
|
};
|
|
101
205
|
}
|
|
102
|
-
const
|
|
103
|
-
const failed = (label: string) => (error: unknown) => {
|
|
104
|
-
errors.push(`${label}: ${error instanceof Error ? error.message : String(error)}`);
|
|
105
|
-
return null;
|
|
106
|
-
};
|
|
107
|
-
const [receipt, home, other] = await Promise.all([
|
|
206
|
+
const [receipt, home, other, ah] = await Promise.all([
|
|
108
207
|
readQuote(legs.receiptKey, ctx, failed(legs.receiptKey)),
|
|
109
208
|
readQuote(legs.homeKey, ctx, failed(legs.homeKey)),
|
|
110
209
|
otherLines(legs.receiptKey, legs.homeKey, ctx),
|
|
210
|
+
readAhPair(key, ctx, failed),
|
|
111
211
|
]);
|
|
112
212
|
ctx.signal.throwIfAborted();
|
|
113
213
|
const quotes = { receipt, home };
|
|
@@ -123,6 +223,8 @@ export const adrPairHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
123
223
|
const figures = adrPairFigures(comparison);
|
|
124
224
|
const rows = adrPairInputRows(comparison, quotes);
|
|
125
225
|
const kind = spotRateKind(homeCurrency);
|
|
226
|
+
const pairNotes = [comparison.timingNote, ...hasComparison(ah) ? [ah.comparison.timingNote] : [], otherLinesText]
|
|
227
|
+
.filter((note): note is string => !!note);
|
|
126
228
|
return {
|
|
127
229
|
sections: [
|
|
128
230
|
{
|
|
@@ -138,20 +240,16 @@ export const adrPairHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
138
240
|
},
|
|
139
241
|
{
|
|
140
242
|
title: "Inputs",
|
|
141
|
-
columns:
|
|
142
|
-
{ key: "listing", header: "Listing" },
|
|
143
|
-
{ key: "role", header: "Role" },
|
|
144
|
-
{ key: "price", header: "Price", align: "right" },
|
|
145
|
-
{ key: "asOf", header: "As of (UTC)" },
|
|
146
|
-
{ key: "session", header: "Session" },
|
|
147
|
-
],
|
|
243
|
+
columns: INPUT_COLUMNS,
|
|
148
244
|
rows: rows.map(({ opens: _opens, ...row }) => row),
|
|
149
245
|
},
|
|
246
|
+
...hasComparison(ah) ? ahSections(ah, rows.map((row) => row.listing)) : [],
|
|
150
247
|
],
|
|
151
|
-
...(
|
|
248
|
+
...(pairNotes.length > 0 ? { notes: pairNotes } : {}),
|
|
152
249
|
...(errors.length > 0 ? { errors } : {}),
|
|
153
250
|
freshness: {
|
|
154
|
-
observations: [quotes.receipt, quotes.home
|
|
251
|
+
observations: [quotes.receipt, quotes.home, ...hasComparison(ah) ? [ah.quotes.a] : []]
|
|
252
|
+
.filter((quote): quote is Quote => !!quote).map((quote) => ({ ...quoteObservation(quote) })),
|
|
155
253
|
},
|
|
156
254
|
metadata: {
|
|
157
255
|
receipt: legs.receiptKey, home: legs.homeKey, ratio: comparison.ratio, currency: homeCurrency,
|
|
@@ -160,6 +258,7 @@ export const adrPairHeadless: HeadlessPaneDefinition<"bundle"> = {
|
|
|
160
258
|
receiptPrice: comparison.receipt.price, receiptObservedAt: comparison.receipt.observedAt,
|
|
161
259
|
homePrice: comparison.home.price, homeObservedAt: comparison.home.observedAt,
|
|
162
260
|
spotObservedAt: comparison.spot?.observedAt ?? null, template: ADR_PAIR_TEMPLATE_ID,
|
|
261
|
+
...hasComparison(ah) ? ahMetadata(ah) : {},
|
|
163
262
|
},
|
|
164
263
|
};
|
|
165
264
|
},
|