@gloom-sh/terminal 0.20.16 → 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 +16 -5
- 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/api-client/types/econ.ts +3 -0
- 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/fred-series.ts +3 -1
- package/src/cli/commands/market.ts +138 -22
- package/src/cli/commands/overview.ts +72 -14
- 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 +74 -0
- package/src/cli/desktop-pane-shot.ts +75 -11
- package/src/cli/glossary.ts +64 -10
- package/src/cli/help.ts +4 -2
- 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/headless.ts +7 -2
- package/src/cli/pane-functions/index.ts +102 -44
- 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-bridge.ts +4 -2
- 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/report-tables.ts +17 -3
- package/src/cli/result.ts +8 -10
- package/src/cli/series-search.ts +45 -6
- package/src/cli/shot-temp-dir.ts +4 -9
- package/src/components/chart/composite/legend.tsx +80 -25
- 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/display-columns.ts +4 -1
- package/src/components/ui/data-table/hooks.ts +2 -3
- package/src/components/ui/data-table/index.tsx +4 -1
- package/src/components/ui/data-table/types.ts +19 -4
- package/src/components/ui/data-table/visible-range.ts +11 -1
- 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 +7 -3
- 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 +9 -3
- 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/credit-conditions/series.ts +2 -2
- 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/board-model.ts +12 -0
- package/src/plugins/builtin/earnings/board-table.ts +7 -4
- package/src/plugins/builtin/earnings/board.tsx +2 -2
- package/src/plugins/builtin/earnings/fiscal-quarter.ts +39 -0
- package/src/plugins/builtin/earnings/headless.ts +7 -4
- package/src/plugins/builtin/earnings/highlight.ts +1 -1
- 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 +18 -0
- package/src/plugins/builtin/econ/fred-catalog.ts +1 -256
- package/src/plugins/builtin/econ/index.tsx +3 -0
- package/src/plugins/builtin/econ-statistics/cache.ts +1 -1
- package/src/plugins/builtin/econ-statistics/client.ts +11 -10
- package/src/plugins/builtin/econ-statistics/detail.tsx +1 -0
- package/src/plugins/builtin/econ-statistics/headless.ts +42 -6
- package/src/plugins/builtin/econ-statistics/index.tsx +1 -0
- package/src/plugins/builtin/econ-statistics/pane.tsx +7 -2
- package/src/plugins/builtin/econ-statistics/stats.ts +2 -1
- package/src/plugins/builtin/econ-statistics/view.ts +9 -3
- 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/fred-catalog.ts +256 -0
- package/src/plugins/builtin/shared/report-freshness.ts +2 -3
- package/src/plugins/builtin/shared/series-cache.ts +3 -0
- package/src/plugins/builtin/shared/series-detail-chart.tsx +3 -0
- package/src/plugins/builtin/short-interest/watch-pane.tsx +7 -7
- 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 +67 -1
- package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +31 -16
- 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/time-sales/headless.ts +4 -1
- package/src/plugins/builtin/time-sales/pane.tsx +2 -0
- package/src/plugins/builtin/time-sales/window.ts +12 -0
- package/src/plugins/builtin/treasury-auctions/client.ts +4 -0
- package/src/plugins/builtin/treasury-auctions/treasury-direct.ts +2 -0
- package/src/plugins/builtin/treasury-daily/client.ts +23 -11
- 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-entry.tsx +2 -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/fred-publisher.ts +25 -0
- package/src/sources/gloomberb-cloud/fred-series.ts +1 -1
- 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/base-series.ts +3 -0
- package/src/time-series/ice-credit.ts +1 -0
- package/src/time-series/resolve.ts +3 -1
- package/src/time-series/spec.ts +2 -2
- package/src/time-series/types.ts +2 -1
- package/src/types/data-provider.ts +11 -0
- package/src/types/financials.ts +39 -3
- package/src/types/headless.ts +4 -2
- 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/throttled-fetch.ts +15 -1
- package/src/utils/trailing-dividend.ts +1 -1
- package/src/plugins/builtin/composite-plugins.ts +0 -285
|
@@ -67,6 +67,9 @@ import {
|
|
|
67
67
|
type PaneFunctionCapability,
|
|
68
68
|
} from "./capabilities";
|
|
69
69
|
|
|
70
|
+
/** Plugins whose series a name that opens nothing is pointed at, or a function that gives them when that name is met. */
|
|
71
|
+
type SeriesSources = readonly SeriesSource[] | (() => readonly SeriesSource[]);
|
|
72
|
+
|
|
70
73
|
export interface ResolvedPaneFunction {
|
|
71
74
|
token: string;
|
|
72
75
|
label: string;
|
|
@@ -207,7 +210,7 @@ function withKeywordNote(registry: PaneFunctionCatalog, parsed: ParsedPaneFuncti
|
|
|
207
210
|
}
|
|
208
211
|
|
|
209
212
|
/** Whether a word is the function's code, an alias or a name, rather than one of its keywords. */
|
|
210
|
-
function namesFunction(template: PaneTemplateDef | undefined, pane: PaneDef, word: string): boolean {
|
|
213
|
+
export function namesFunction(template: PaneTemplateDef | undefined, pane: PaneDef, word: string): boolean {
|
|
211
214
|
const wanted = normalizeLookupToken(word);
|
|
212
215
|
const headless = getHeadlessPaneDefinition(template, pane);
|
|
213
216
|
const names = [template?.shortcut?.prefix, ...template?.shortcut?.aliases ?? [], template?.id, template?.label, pane.id, pane.name,
|
|
@@ -468,7 +471,7 @@ async function unknownPaneFunctionError(
|
|
|
468
471
|
name: string,
|
|
469
472
|
arg: string,
|
|
470
473
|
command: "fn" | "shot",
|
|
471
|
-
seriesSources:
|
|
474
|
+
seriesSources: SeriesSources = [],
|
|
472
475
|
pluginStop?: PluginCodeStopFinder,
|
|
473
476
|
): Promise<UnknownPaneFunctionError> {
|
|
474
477
|
// NIM is one slip from NI, but a bank figure is in `fundamentals`, not in a function's statement lines.
|
|
@@ -494,7 +497,7 @@ async function unknownPaneFunctionError(
|
|
|
494
497
|
// One code is run on the argument; the functions a word asks for are each.
|
|
495
498
|
const runs = suggested.length > 0 ? suggested : near.length === 1 ? near : [];
|
|
496
499
|
// A word no function is near that names data ("nikkei") points at the series `catalog` finds for it.
|
|
497
|
-
const series = closest.length === 0 && near.length === 0 ? findCatalogSeries(seriesSources, name).slice(0, UNKNOWN_NAME_SERIES_LIMIT) : [];
|
|
500
|
+
const series = closest.length === 0 && near.length === 0 ? findCatalogSeries(typeof seriesSources === "function" ? seriesSources() : seriesSources, name).slice(0, UNKNOWN_NAME_SERIES_LIMIT) : [];
|
|
498
501
|
const seriesWidth = Math.max(0, ...series.map((match) => match.expression.length));
|
|
499
502
|
return new UnknownPaneFunctionError(name, [
|
|
500
503
|
// A function a word asks for, typed with no argument, shows the one it takes (`<ticker>`).
|
|
@@ -519,8 +522,8 @@ export async function resolvePaneFunction(
|
|
|
519
522
|
/** `fn`: a `--limit` or `--tail` the function takes no option for picks the report's rows (`rowWindow`). */
|
|
520
523
|
rowWindow?: boolean;
|
|
521
524
|
command?: "fn" | "shot";
|
|
522
|
-
/** The plugins whose catalog series a name that opens nothing is pointed at. */
|
|
523
|
-
seriesSources?:
|
|
525
|
+
/** The plugins whose catalog series a name that opens nothing is pointed at; a function, to ask for them only then. */
|
|
526
|
+
seriesSources?: SeriesSources;
|
|
524
527
|
/** Why a name that opens nothing is a plugin's code (`pluginCodeStop`). */
|
|
525
528
|
pluginStop?: PluginCodeStopFinder;
|
|
526
529
|
} = {},
|
|
@@ -139,7 +139,8 @@ export function assessPaneScreenshot(
|
|
|
139
139
|
const unavailableSymbols = usesLiveDomEvidence
|
|
140
140
|
? []
|
|
141
141
|
: shotUnavailableSymbols(resolved, payload, render.semanticUi);
|
|
142
|
-
const
|
|
142
|
+
const figureGaps = essentialFigureMismatches(render);
|
|
143
|
+
const complete = unavailableSymbols.length === 0 && figureGaps.length === 0 && !render.statusLineClipped;
|
|
143
144
|
const expectedText = shotExpectedText(resolved, symbols, payload);
|
|
144
145
|
const normalizedVisibleText = render.visibleText.toLowerCase();
|
|
145
146
|
const missingExpectedText = expectedText.filter((value) => !shotShowsText(normalizedVisibleText, value));
|
|
@@ -156,6 +157,8 @@ export function assessPaneScreenshot(
|
|
|
156
157
|
...paneEvidenceMismatches(resolved, payload, render),
|
|
157
158
|
...financialRatioRenderMismatches(resolved, payload, render),
|
|
158
159
|
...surfaceNotDrawnMismatches(render),
|
|
160
|
+
...figureGaps,
|
|
161
|
+
...(render.statusLineClipped ? ["The as-of status line is clipped."] : []),
|
|
159
162
|
];
|
|
160
163
|
const semanticMismatch = missingExpectedText.length > 0
|
|
161
164
|
|| missingExpectedSelections.length > 0
|
|
@@ -309,7 +312,10 @@ const BLANK_COLUMN_MIN_ROWS = 3;
|
|
|
309
312
|
* and V/AVG did before the open. A column some rows leave empty is a sparse
|
|
310
313
|
* marker (an event column), not a blank one, and neither is a column the pane
|
|
311
314
|
* says can be blank (`mayBeBlank`: a value that comes after an event, such as
|
|
312
|
-
* an upcoming report's move)
|
|
315
|
+
* an upcoming report's move). A row the pane says is still waiting on the
|
|
316
|
+
* value (a cell's `mayBeBlank`: ECO's ACTUAL before the release) is left out:
|
|
317
|
+
* the column is blank when every other row is, and there are at least
|
|
318
|
+
* BLANK_COLUMN_MIN_ROWS of them. Section headers and tables of fewer than
|
|
313
319
|
* BLANK_COLUMN_MIN_ROWS rows are not read.
|
|
314
320
|
*/
|
|
315
321
|
function shotBlankColumns(rows: readonly Pick<DesktopPaneShotRenderedRow, "tableIndex" | "cells" | "section">[]): string[] {
|
|
@@ -322,18 +328,22 @@ function shotBlankColumns(rows: readonly Pick<DesktopPaneShotRenderedRow, "table
|
|
|
322
328
|
const blank: string[] = [];
|
|
323
329
|
for (const tableRows of tables.values()) {
|
|
324
330
|
if (tableRows.length < BLANK_COLUMN_MIN_ROWS) continue;
|
|
325
|
-
const columns = new Map<string, { label: string; placeholders: number; filled: boolean }>();
|
|
331
|
+
const columns = new Map<string, { label: string; placeholders: number; waiting: number; filled: boolean }>();
|
|
326
332
|
for (const row of tableRows) {
|
|
327
333
|
for (const cell of row.cells) {
|
|
328
334
|
const key = cell.columnId ?? cell.columnLabel;
|
|
329
|
-
const column = columns.get(key) ?? { label: cell.columnLabel, placeholders: 0, filled: false };
|
|
330
|
-
|
|
335
|
+
const column = columns.get(key) ?? { label: cell.columnLabel, placeholders: 0, waiting: 0, filled: false };
|
|
336
|
+
// A row still waiting on the value (an upcoming release's ACTUAL) is neither a gap nor a value.
|
|
337
|
+
if (cell.mayBeBlank && PLACEHOLDER_VALUE.test(cell.text.trim())) column.waiting += 1;
|
|
338
|
+
else if (PLACEHOLDER_VALUE.test(cell.text.trim())) column.placeholders += 1;
|
|
331
339
|
else column.filled = true;
|
|
332
340
|
columns.set(key, column);
|
|
333
341
|
}
|
|
334
342
|
}
|
|
335
|
-
for (const { label, placeholders, filled } of columns.values()) {
|
|
336
|
-
|
|
343
|
+
for (const { label, placeholders, waiting, filled } of columns.values()) {
|
|
344
|
+
// Blank in every row that should have the value, and in enough of them to be no short list's gaps.
|
|
345
|
+
const owed = tableRows.length - waiting;
|
|
346
|
+
if (!filled && owed >= BLANK_COLUMN_MIN_ROWS && placeholders === owed && !blank.includes(label)) blank.push(label);
|
|
337
347
|
}
|
|
338
348
|
}
|
|
339
349
|
return blank;
|
|
@@ -434,6 +444,19 @@ function plotsData(node: RemoteUiNodeSnapshot): boolean {
|
|
|
434
444
|
return lists.some((list) => list.some((series) => isRecord(series) && typeof series.pointCount === "number" && series.pointCount > 0));
|
|
435
445
|
}
|
|
436
446
|
|
|
447
|
+
export function essentialFigureMismatches(render: Pick<DesktopPaneShotRenderResult, "semanticUi" | "visibleText">): string[] {
|
|
448
|
+
return render.semanticUi.filter((node) => node.role === "figure-layout").flatMap((node) => {
|
|
449
|
+
const metadata = node.metadata;
|
|
450
|
+
if (!isRecord(metadata) || !Array.isArray(metadata.figures) || !Array.isArray(metadata.omitted)) return ["Essential figure evidence is unavailable."];
|
|
451
|
+
const omitted = metadata.omitted;
|
|
452
|
+
return metadata.figures.flatMap((figure) => {
|
|
453
|
+
if (!isRecord(figure) || typeof figure.label !== "string" || typeof figure.value !== "string") return ["Essential figure evidence is invalid."];
|
|
454
|
+
return omitted.includes(figure.label) || !shotShowsText(render.visibleText, figure.label) || !shotShowsText(render.visibleText, figure.value)
|
|
455
|
+
? [`Essential figure is missing or clipped: ${figure.label}.`] : [];
|
|
456
|
+
});
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
|
|
437
460
|
/**
|
|
438
461
|
* A 3D surface that is not the real drawing: the frame has no mesh, or the 2D
|
|
439
462
|
* grid stands in for it. Both are fine for a person using the pane and wrong
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
type HttpProxyRequestEnvelope,
|
|
9
9
|
type HttpProxyResponseEnvelope,
|
|
10
10
|
} from "../../utils/http-proxy-response";
|
|
11
|
+
import { signalWithTimeout } from "../../utils/async-deadline";
|
|
11
12
|
import { fetchCheckingRedirects, readBytesWithin } from "../../utils/http-proxy-upstream";
|
|
12
13
|
import { isPublicAddress } from "../../utils/public-address";
|
|
13
14
|
import type { DesktopPaneShotApiProxy, DesktopPaneShotBridge } from "../desktop-pane-shot";
|
|
@@ -146,7 +147,7 @@ export function createDesktopShotBridge(
|
|
|
146
147
|
args,
|
|
147
148
|
);
|
|
148
149
|
},
|
|
149
|
-
httpFetch: (request) => runDesktopShotHttpFetch(request, httpOptions),
|
|
150
|
+
httpFetch: (request, signal) => runDesktopShotHttpFetch(request, httpOptions, signal),
|
|
150
151
|
};
|
|
151
152
|
}
|
|
152
153
|
|
|
@@ -196,6 +197,7 @@ async function checkShotHttpTarget(
|
|
|
196
197
|
async function runDesktopShotHttpFetch(
|
|
197
198
|
request: HttpProxyRequestEnvelope,
|
|
198
199
|
options: ShotHttpOptions,
|
|
200
|
+
signal?: AbortSignal,
|
|
199
201
|
): Promise<HttpProxyResponseEnvelope> {
|
|
200
202
|
const resolve = options.resolveHost ?? resolveHost;
|
|
201
203
|
const addresses = new Map<string, string>();
|
|
@@ -218,7 +220,7 @@ async function runDesktopShotHttpFetch(
|
|
|
218
220
|
return fetchShotHttpAddress(url, init ?? {}, address);
|
|
219
221
|
}) as typeof fetch,
|
|
220
222
|
check: checkTarget,
|
|
221
|
-
signal:
|
|
223
|
+
signal: signalWithTimeout(signal, SHOT_BRIDGE_HTTP_TIMEOUT_MS),
|
|
222
224
|
});
|
|
223
225
|
if ("error" in result) throw new Error(result.error);
|
|
224
226
|
const { response } = result;
|
|
@@ -165,6 +165,25 @@ interface ShotSymbolCapture {
|
|
|
165
165
|
unread?: { symbol: string; reason: string };
|
|
166
166
|
tape?: TapeCapture;
|
|
167
167
|
chain?: [string, OptionsChain];
|
|
168
|
+
/** More than one cadence the pane reads for the row, each answering only its own requests. */
|
|
169
|
+
historyVariants?: NonNullable<SnapshotMarketData["historyVariants"]>;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* PEB reads every week on record and, for the years they are served, the
|
|
174
|
+
* daily closes that price each figure on its day. Captured history answers
|
|
175
|
+
* every request, so the weekly bars would stand in for the daily ones and
|
|
176
|
+
* the capture read the week around each figure's day: each cadence is its
|
|
177
|
+
* own, under the listing the pane asks for. Without daily closes the weekly
|
|
178
|
+
* bars stand alone, as in the app.
|
|
179
|
+
*/
|
|
180
|
+
async function peBandHistoryVariants(
|
|
181
|
+
context: MarketContext, ticker: TickerRecord, exchange: string, weekly: TickerFinancials["priceHistory"],
|
|
182
|
+
): Promise<NonNullable<SnapshotMarketData["historyVariants"]>> {
|
|
183
|
+
const target = { symbol: ticker.metadata.ticker, exchange: ticker.metadata.exchange ?? "" };
|
|
184
|
+
const daily = await (context.dataProvider.getPriceHistoryForResolution?.(target.symbol, exchange, "5Y", "1d", toMarketDataContext(target))
|
|
185
|
+
?? Promise.resolve([])).catch(logFailure("cli.pane-functions.screenshot-payload", "Read PEB daily closes for a capture failed", []));
|
|
186
|
+
return [{ target, resolution: "1wk", points: weekly ?? [] }, ...(daily.length ? [{ target, resolution: "1d" as const, points: daily }] : [])];
|
|
168
187
|
}
|
|
169
188
|
|
|
170
189
|
export async function buildDesktopShotPayload(
|
|
@@ -348,6 +367,7 @@ export async function buildDesktopShotPayload(
|
|
|
348
367
|
if (resolved.pane.id === "time-sales") {
|
|
349
368
|
capture.tape = [entry.instrument.symbol, exchange, await fetchTape(entry.instrument.symbol, exchange)];
|
|
350
369
|
}
|
|
370
|
+
if (resolved.pane.id === "pe-band") capture.historyVariants = await peBandHistoryVariants(context, capture.ticker, exchange, data.priceHistory);
|
|
351
371
|
if (includeOptionsChains && context.dataProvider.getOptionsChain) {
|
|
352
372
|
// A future with no chain of its own is the pane's to explain (the listed alternative), not a failed shot.
|
|
353
373
|
const chain = await context.dataProvider.getOptionsChain(entry.instrument.symbol, exchange, undefined,
|
|
@@ -425,6 +445,7 @@ export async function buildDesktopShotPayload(
|
|
|
425
445
|
}
|
|
426
446
|
if (capture.tape) tapeSnapshots.push(capture.tape);
|
|
427
447
|
if (capture.chain) optionsChains.push(capture.chain);
|
|
448
|
+
if (capture.historyVariants?.length) historyVariants = [...historyVariants ?? [], ...capture.historyVariants];
|
|
428
449
|
}
|
|
429
450
|
}
|
|
430
451
|
// PF over a period draws the report's P&L between the two closes: the page reads no history of its own.
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
deriveCaptureReport,
|
|
21
21
|
deriveHeadlessFreshness,
|
|
22
22
|
deriveRenderedFreshness,
|
|
23
|
+
statusDateEvidence,
|
|
23
24
|
type CaptureReport,
|
|
24
25
|
type CaptureStatusLine,
|
|
25
26
|
type ReportFreshness,
|
|
@@ -323,7 +324,8 @@ export async function renderDesktopShot({
|
|
|
323
324
|
freshness = line.freshness;
|
|
324
325
|
// A row whose read failed is marked on the picture, where its figures are missing.
|
|
325
326
|
const unread = unreadRowsNote(shotPayload.unreadRows);
|
|
326
|
-
return { variants: unread ? line.variants.map((variant) => `${variant} · ${unread}`) : line.variants, dates: line.dates
|
|
327
|
+
return { variants: unread ? line.variants.map((variant) => `${variant} · ${unread}`) : line.variants, dates: line.dates,
|
|
328
|
+
dateEvidence: statusDateEvidence(line.freshness) };
|
|
327
329
|
},
|
|
328
330
|
});
|
|
329
331
|
covered = coverage && await settledWithin(coverage, SHOT_REPORT_WAIT_MS);
|
package/src/cli/quote-answer.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { QuoteBatchResult } from "../types/data-provider";
|
|
1
|
+
import type { QuoteBatchOptions, QuoteBatchResult } from "../types/data-provider";
|
|
2
2
|
import type { Quote } from "../types/financials";
|
|
3
3
|
import { bareListingNote } from "../tickers/listing-fate";
|
|
4
4
|
import { isRateLimited, isTransientServiceFailure, notATickerSymbol, rateLimitedError } from "../sources/provider-errors";
|
|
@@ -35,13 +35,13 @@ import {
|
|
|
35
35
|
tradingBoardNote,
|
|
36
36
|
type CliListing,
|
|
37
37
|
type ListingDataRequest,
|
|
38
|
+
type ListingDeps,
|
|
38
39
|
type ListingVenue,
|
|
39
40
|
} from "./listing-arg";
|
|
40
41
|
import { isNotATickerMessage, withListingSuggestion } from "./not-a-ticker";
|
|
41
42
|
import { notATickerWords } from "./company-name-hint";
|
|
42
43
|
import { isNetworkFailure } from "../utils/network-failure";
|
|
43
44
|
import { logFailure } from "../utils/log-failure";
|
|
44
|
-
import type { MarketContext } from "./types";
|
|
45
45
|
|
|
46
46
|
/** The text of an error, or null for none. */
|
|
47
47
|
export function errorMessage(error: unknown): string | null {
|
|
@@ -96,7 +96,7 @@ export interface QuoteAnswer {
|
|
|
96
96
|
export async function answerQuote(
|
|
97
97
|
result: QuoteBatchResult,
|
|
98
98
|
listing: CliListing,
|
|
99
|
-
market:
|
|
99
|
+
market: ListingDeps,
|
|
100
100
|
request: ListingDataRequest,
|
|
101
101
|
refresh: boolean,
|
|
102
102
|
venues: Promise<ListingVenue[]> | null,
|
|
@@ -209,7 +209,7 @@ export async function answerQuote(
|
|
|
209
209
|
* (`.IS`, `.JO`): another one-letter suffix is as likely a US share class
|
|
210
210
|
* (MKC.V, BRK.B) and keeps its own answer. Null otherwise.
|
|
211
211
|
*/
|
|
212
|
-
async function notTradedOnSuffixVenue(listing: CliListing, market:
|
|
212
|
+
async function notTradedOnSuffixVenue(listing: CliListing, market: ListingDeps): Promise<string | null> {
|
|
213
213
|
if (listing.exchange) return null;
|
|
214
214
|
const suffix = listing.symbol.slice(listing.symbol.lastIndexOf(".") + 1);
|
|
215
215
|
if (!listing.symbol.includes(".") || (suffix.length < 2 && suffix.toUpperCase() !== "L")) return null;
|
|
@@ -231,7 +231,7 @@ async function notTradedOnSuffixVenue(listing: CliListing, market: MarketContext
|
|
|
231
231
|
async function answerCompanyName(
|
|
232
232
|
result: QuoteBatchResult,
|
|
233
233
|
listing: CliListing,
|
|
234
|
-
market:
|
|
234
|
+
market: ListingDeps,
|
|
235
235
|
request: ListingDataRequest,
|
|
236
236
|
refresh: boolean,
|
|
237
237
|
datesChangeBasis: boolean,
|
|
@@ -261,7 +261,7 @@ async function answerCompanyName(
|
|
|
261
261
|
export async function withJoinedCompanyNames(
|
|
262
262
|
answers: readonly QuoteAnswer[],
|
|
263
263
|
asked: readonly CliListing[],
|
|
264
|
-
market:
|
|
264
|
+
market: ListingDeps,
|
|
265
265
|
request: ListingDataRequest,
|
|
266
266
|
refresh: boolean,
|
|
267
267
|
datesChangeBasis: boolean,
|
|
@@ -281,7 +281,7 @@ export async function withJoinedCompanyNames(
|
|
|
281
281
|
async function abroadShareClass(
|
|
282
282
|
listing: CliListing,
|
|
283
283
|
quote: Quote,
|
|
284
|
-
market:
|
|
284
|
+
market: ListingDeps,
|
|
285
285
|
request: ListingDataRequest,
|
|
286
286
|
refresh: boolean,
|
|
287
287
|
datesChangeBasis: boolean,
|
|
@@ -297,7 +297,7 @@ async function abroadShareClass(
|
|
|
297
297
|
*/
|
|
298
298
|
async function answerNamedListing(
|
|
299
299
|
named: ListingArg,
|
|
300
|
-
market:
|
|
300
|
+
market: ListingDeps,
|
|
301
301
|
request: ListingDataRequest,
|
|
302
302
|
refresh: boolean,
|
|
303
303
|
datesChangeBasis: boolean,
|
|
@@ -309,12 +309,28 @@ async function answerNamedListing(
|
|
|
309
309
|
});
|
|
310
310
|
const found = resolved ? { ...resolved, readAs: named.readAs, ...named.meant ? { meant: named.meant } : {}, ...named.readFromName ? { readFromName: named.readFromName } : {},
|
|
311
311
|
...named.wordAsName ? { wordAsName: named.wordAsName } : {} } : null;
|
|
312
|
-
const
|
|
312
|
+
const quoted = found ? await quoteOne(market, found.request, { forceRefresh: refresh, revalidate: true, datesChangeBasis }) : null;
|
|
313
313
|
return found && quoted?.quote ? answerQuote(quoted, found, market, request, refresh, null, { datesChangeBasis }) : null;
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
+
/**
|
|
317
|
+
* One listing's quote as `quote` asks for it: the service's quote of the
|
|
318
|
+
* moment, through the batch request where the provider has one (the app's
|
|
319
|
+
* own provider may not), with why there is none.
|
|
320
|
+
*/
|
|
321
|
+
async function quoteOne(deps: ListingDeps, target: { symbol: string; exchange: string }, options: QuoteBatchOptions): Promise<QuoteBatchResult> {
|
|
322
|
+
if (deps.dataProvider.getQuotesBatch) {
|
|
323
|
+
const [result] = await deps.dataProvider.getQuotesBatch([target], options);
|
|
324
|
+
return result ?? { target, quote: null };
|
|
325
|
+
}
|
|
326
|
+
return deps.dataProvider.getQuote(target.symbol, target.exchange, {
|
|
327
|
+
cacheMode: options.forceRefresh ? "refresh" : "default",
|
|
328
|
+
...(options.datesChangeBasis ? { datesChangeBasis: true } : {}),
|
|
329
|
+
}).then((quote) => ({ target, quote }), (error: unknown) => ({ target, quote: null, error }));
|
|
330
|
+
}
|
|
331
|
+
|
|
316
332
|
/** A listing a command found a quote for, with what `quote` says beside it. */
|
|
317
|
-
interface QuotedListing {
|
|
333
|
+
export interface QuotedListing {
|
|
318
334
|
/** The listing the quote is of: the one typed, or the venue a bare symbol was quoted on. */
|
|
319
335
|
listing: CliListing;
|
|
320
336
|
quote: Quote;
|
|
@@ -334,15 +350,15 @@ interface QuotedListing {
|
|
|
334
350
|
export async function requireQuotedListing(
|
|
335
351
|
raw: string,
|
|
336
352
|
exchange: string | null | undefined,
|
|
337
|
-
market:
|
|
353
|
+
market: ListingDeps,
|
|
338
354
|
ctx: Pick<Parameters<CliCommandDef["execute"]>[1], "fail">,
|
|
339
355
|
command: string,
|
|
340
356
|
): Promise<QuotedListing> {
|
|
341
357
|
// A word that names a company is read after the quote, as `quote` reads it.
|
|
342
358
|
const listing = await requireCliListing(raw, exchange, market, ctx, { companyWord: false });
|
|
343
359
|
const venues = loadBareVenues(listing, market);
|
|
344
|
-
const
|
|
345
|
-
const answer = await answerQuote(result
|
|
360
|
+
const result = await quoteOne(market, listing.request, { revalidate: true });
|
|
361
|
+
const answer = await answerQuote(result, listing, market, { command, noun: "quote" }, false, venues);
|
|
346
362
|
const quote = answer.result.quote;
|
|
347
363
|
if (!quote) {
|
|
348
364
|
if (answer.failure) ctx.fail(answer.failure.message, answer.failure.details);
|
|
@@ -375,7 +391,7 @@ export type IndexFormRead = () => Promise<Quote | null>;
|
|
|
375
391
|
* goes beside the quote the service has not answered yet instead of after it. A symbol some venue lists asks only
|
|
376
392
|
* when its answer needs it.
|
|
377
393
|
*/
|
|
378
|
-
export function indexFormRead(listing: CliListing, market:
|
|
394
|
+
export function indexFormRead(listing: CliListing, market: ListingDeps, venues: Promise<ListingVenue[]> | null): IndexFormRead | null {
|
|
379
395
|
if (listing.exchange || listing.saved || !CARETLESS_INDEX.test(listing.symbol) || indexRootFor(listing.symbol)) return null;
|
|
380
396
|
let read: Promise<Quote | null> | null = null;
|
|
381
397
|
const start: IndexFormRead = () => read ??= Promise.resolve().then(() => market.dataProvider.getQuote(`^${listing.symbol}`, ""))
|
|
@@ -412,7 +428,7 @@ const FIVE_DIGIT_CODE = /^0\d{4}$/;
|
|
|
412
428
|
* (Tencent Holdings Limited)". Null for any other symbol, a named or saved
|
|
413
429
|
* listing, and a code HKEX does not list.
|
|
414
430
|
*/
|
|
415
|
-
async function hongKongCodeNote(listing: CliListing, quote: Quote, market:
|
|
431
|
+
async function hongKongCodeNote(listing: CliListing, quote: Quote, market: ListingDeps): Promise<string | null> {
|
|
416
432
|
if (listing.exchange || listing.saved || !FIVE_DIGIT_CODE.test(listing.symbol)) return null;
|
|
417
433
|
if (canonicalExchange(quote.listingExchangeName || quote.exchangeName) === "HKEX") return null;
|
|
418
434
|
const code = String(Number(listing.symbol));
|
|
@@ -429,7 +445,7 @@ async function hongKongCodeNote(listing: CliListing, quote: Quote, market: Marke
|
|
|
429
445
|
* Naira)?". When search finds nothing near, the row keeps its own error and its
|
|
430
446
|
* search hint.
|
|
431
447
|
*/
|
|
432
|
-
async function withCurrencyPairHint(result: QuoteBatchResult, market:
|
|
448
|
+
async function withCurrencyPairHint(result: QuoteBatchResult, market: ListingDeps): Promise<QuoteBatchResult> {
|
|
433
449
|
const message = errorMessage(result.error);
|
|
434
450
|
const symbol = message ? notATickerSymbol(message) : null;
|
|
435
451
|
if (!message || !symbol || !looksLikeCurrencyPair(symbol)) return result;
|
package/src/cli/registry.ts
CHANGED
|
@@ -52,6 +52,8 @@ export interface CliCommandRegistry {
|
|
|
52
52
|
config: AppConfig | null;
|
|
53
53
|
/** The plugins that run here: loaded, switched on, and declaring the command line among their targets. */
|
|
54
54
|
plugins: GloomPlugin[];
|
|
55
|
+
/** The ones of those that contribute data capabilities, which a command reading market data needs without the rest. */
|
|
56
|
+
readonly dataPlugins: GloomPlugin[];
|
|
55
57
|
readonly idlePlugins: IdleCliPlugin[];
|
|
56
58
|
externalPlugins: LoadedExternalPlugin[];
|
|
57
59
|
/** Loads installed contributions when dispatch or application services need them. */
|
|
@@ -170,6 +172,10 @@ export function buildCliCommandRegistry({
|
|
|
170
172
|
.filter((entry) => !entry.error && !entry.unsupportedTarget && !disabledPlugins.has(entry.plugin.id))
|
|
171
173
|
.map((entry) => entry.plugin);
|
|
172
174
|
},
|
|
175
|
+
get dataPlugins() {
|
|
176
|
+
const { getLoadableDataPlugins } = require("../plugins/catalog-data") as typeof import("../plugins/catalog-data");
|
|
177
|
+
return getLoadableDataPlugins(registry.externalPlugins).filter((plugin) => !disabledPlugins.has(plugin.id));
|
|
178
|
+
},
|
|
173
179
|
get idlePlugins() {
|
|
174
180
|
const { getPluginCatalog } = require("../plugins/catalog") as typeof import("../plugins/catalog");
|
|
175
181
|
return getPluginCatalog(registry.externalPlugins).flatMap((entry): IdleCliPlugin[] => {
|
|
@@ -196,13 +202,23 @@ export function buildCliCommandRegistry({
|
|
|
196
202
|
|
|
197
203
|
/** The idle plugins of each command's context, kept off the plugin API's context type. */
|
|
198
204
|
const idlePluginsByContext = new WeakMap<CliCommandContext, () => IdleCliPlugin[]>();
|
|
205
|
+
/** How many installed plugins a command's context found, loading them first, kept off the plugin API's context type too. */
|
|
206
|
+
const installedPluginCountByContext = new WeakMap<CliCommandContext, () => Promise<number>>();
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* How many installed plugins (loaded, failed or switched to other targets) a command has beside the built-in ones.
|
|
210
|
+
* A command that answers from what the built-in plugins declare may do so only when this is none.
|
|
211
|
+
*/
|
|
212
|
+
export async function installedPluginCount(ctx: CliCommandContext): Promise<number> {
|
|
213
|
+
return (await installedPluginCountByContext.get(ctx)?.()) ?? 0;
|
|
214
|
+
}
|
|
199
215
|
|
|
200
216
|
/** The installed plugins a command's context does not run (`IdleCliPlugin`); none for a context built without a registry. */
|
|
201
217
|
export function idleCliPlugins(ctx: CliCommandContext): IdleCliPlugin[] {
|
|
202
218
|
return idlePluginsByContext.get(ctx)?.() ?? [];
|
|
203
219
|
}
|
|
204
220
|
|
|
205
|
-
type ContextRegistry = Pick<CliCommandRegistry, "plugins" | "externalPlugins" | "ensureExternalPlugins"> & Partial<Pick<CliCommandRegistry, "idlePlugins">>;
|
|
221
|
+
type ContextRegistry = Pick<CliCommandRegistry, "plugins" | "externalPlugins" | "ensureExternalPlugins"> & Partial<Pick<CliCommandRegistry, "idlePlugins" | "dataPlugins">>;
|
|
206
222
|
|
|
207
223
|
export function createCliCommandContext(
|
|
208
224
|
ownerId: string,
|
|
@@ -217,7 +233,7 @@ export function createCliCommandContext(
|
|
|
217
233
|
initConfigData,
|
|
218
234
|
initMarketData: async () => {
|
|
219
235
|
await registry.ensureExternalPlugins?.();
|
|
220
|
-
return initMarketData({ plugins: registry.plugins });
|
|
236
|
+
return initMarketData({ plugins: () => registry.plugins, ...registry.dataPlugins ? { dataPlugins: registry.dataPlugins } : {} });
|
|
221
237
|
},
|
|
222
238
|
initServices: async () => {
|
|
223
239
|
await registry.ensureExternalPlugins?.();
|
|
@@ -240,5 +256,9 @@ export function createCliCommandContext(
|
|
|
240
256
|
log: debugLog.createLogger(ownerId === "core" ? "cli" : ownerId),
|
|
241
257
|
};
|
|
242
258
|
idlePluginsByContext.set(ctx, () => registry.idlePlugins ?? []);
|
|
259
|
+
installedPluginCountByContext.set(ctx, async () => {
|
|
260
|
+
await registry.ensureExternalPlugins?.();
|
|
261
|
+
return registry.externalPlugins.length;
|
|
262
|
+
});
|
|
243
263
|
return ctx;
|
|
244
264
|
}
|
package/src/cli/report-tables.ts
CHANGED
|
@@ -539,7 +539,7 @@ export function exportRowsTable<Row extends Record<string, unknown>>(
|
|
|
539
539
|
title: string,
|
|
540
540
|
columns: readonly CliReportColumn<Row>[],
|
|
541
541
|
rows: readonly Row[],
|
|
542
|
-
{ status = false, rowUnitKey }: { status?: boolean; rowUnitKey?: string } = {},
|
|
542
|
+
{ status = false, rowUnitKey, appendedColumns = 0 }: { status?: boolean; rowUnitKey?: string; appendedColumns?: number } = {},
|
|
543
543
|
): CliReportTable {
|
|
544
544
|
const reasons = rows.map((): Array<{ header: string; text: string }> => []);
|
|
545
545
|
const units = columns.map(columnUnit);
|
|
@@ -587,7 +587,14 @@ export function exportRowsTable<Row extends Record<string, unknown>>(
|
|
|
587
587
|
header: columns.some((column) => column.header.trim().toLowerCase() === "status") ? "value_status" : "status",
|
|
588
588
|
values: reasons.map(statusText),
|
|
589
589
|
} : undefined;
|
|
590
|
-
|
|
590
|
+
const table = assembleTable(title, resolved, rows.length, statusColumn);
|
|
591
|
+
if (appendedColumns && statusColumn) {
|
|
592
|
+
const before = table.columns.length - 1 - appendedColumns;
|
|
593
|
+
const reorder = <Value,>(values: Value[]) => [...values.slice(0, before), values.at(-1)!, ...values.slice(before, -1)];
|
|
594
|
+
table.columns = reorder(table.columns);
|
|
595
|
+
table.rows = table.rows.map(reorder);
|
|
596
|
+
}
|
|
597
|
+
return appendedColumns ? { ...table, appendedColumns } : table;
|
|
591
598
|
}
|
|
592
599
|
|
|
593
600
|
/** Label/value lines as `Metric,Value`; a number's unit moves into its label. */
|
|
@@ -787,7 +794,14 @@ export function splitCsvFooter(text: string): { csv: string; footer: string[] }
|
|
|
787
794
|
const last = blocks.at(-1) ?? "";
|
|
788
795
|
const lines = last.split("\n");
|
|
789
796
|
if (!last || !lines.every(isComment) || lines.some((line) => line.startsWith("# section: "))) return { csv: text, footer: [] };
|
|
790
|
-
|
|
797
|
+
const csv = blocks.slice(0, -1).join("\n\n");
|
|
798
|
+
let quoted = false;
|
|
799
|
+
for (let index = 0; index < csv.length; index++) {
|
|
800
|
+
if (csv[index] !== '"') continue;
|
|
801
|
+
if (quoted && csv[index + 1] === '"') index++;
|
|
802
|
+
else quoted = !quoted;
|
|
803
|
+
}
|
|
804
|
+
return quoted ? { csv: text, footer: [] } : { csv, footer: lines.map((line) => line.slice(2)) };
|
|
791
805
|
}
|
|
792
806
|
|
|
793
807
|
/** CSV with its closing `#` lines after a blank line. */
|
package/src/cli/result.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { CliGlobalOptions } from "./options";
|
|
|
3
3
|
import {
|
|
4
4
|
cliPlainEnabled,
|
|
5
5
|
cliStyles,
|
|
6
|
+
cliText,
|
|
6
7
|
cliTerminalWidth,
|
|
7
8
|
renderForFile,
|
|
8
9
|
renderStats,
|
|
@@ -15,6 +16,7 @@ import {
|
|
|
15
16
|
type CliTableColumn,
|
|
16
17
|
} from "../utils/cli-output";
|
|
17
18
|
import { serializeCsv } from "../utils/csv";
|
|
19
|
+
import { portableCsv } from "./csv-export";
|
|
18
20
|
import { logFailure } from "../utils/log-failure";
|
|
19
21
|
import { formatUtcTime, isEpochMilliseconds, isZonedIsoDateTime } from "../utils/utc-time";
|
|
20
22
|
import { formatFreshnessLine, withSavedCopy, type ReportFreshness } from "./pane-functions/freshness";
|
|
@@ -623,7 +625,7 @@ function serializeCliRows<T, Row extends Record<string, unknown>>(
|
|
|
623
625
|
return withCsvFooter(csv, [...exportSourceLines(cited), ...cutNote, ...(renderOptions.exportNotes ?? []).map((note) => `note: ${note}`)]);
|
|
624
626
|
}
|
|
625
627
|
if (renderOptions.text) {
|
|
626
|
-
return renderOptions.text(result.data);
|
|
628
|
+
return cliText(renderOptions.text(result.data));
|
|
627
629
|
}
|
|
628
630
|
// The heading's lines, the summary and the notes are prose: each wraps to a narrow --width, as the source line does.
|
|
629
631
|
const summary = wrapToTerminal(renderOptions.summary?.(result.data) ?? "");
|
|
@@ -732,28 +734,24 @@ export function printCliResult<T, Row extends Record<string, unknown> = Record<s
|
|
|
732
734
|
const serialized = hinted(toFile
|
|
733
735
|
? renderForFile(() => serializeCliResult(cells, options, renderOptions))
|
|
734
736
|
: serializeCliResult(cells, options, renderOptions));
|
|
735
|
-
// A CSV's closing source and note lines go to stderr with the warnings: in the file they are rows of junk to a spreadsheet.
|
|
736
737
|
const { csv, footer } = options.format === "csv" ? splitCsvFooter(serialized) : { csv: serialized, footer: [] };
|
|
737
|
-
const output = csv
|
|
738
|
+
const output = options.format === "csv" ? portableCsv(serialized, result.warnings,
|
|
739
|
+
[...renderOptions.exportNotes ?? [], ...renderOptions.footnote ? [renderOptions.footnote] : []]) : csv;
|
|
738
740
|
if (toFile) fileExport.push(output);
|
|
739
741
|
// Bun's console writer can truncate a large pipe write after stdout has been
|
|
740
742
|
// initialized. The stream queues the remaining bytes until the reader drains.
|
|
741
743
|
else if (output && !process.stdout.write(`${output}\n`)) {
|
|
742
744
|
stdoutWritten = new Promise((resolve) => process.stdout.once("drain", () => resolve()));
|
|
743
745
|
}
|
|
744
|
-
// JSON carries warnings in its envelope. Text, CSV and NDJSON are only the
|
|
745
|
-
// rows, so a warning goes to stderr, out of a file the rows are piped into.
|
|
746
746
|
if (options.format !== "json" && !options.quiet) {
|
|
747
747
|
// Each wraps to a narrow --width, as a note does.
|
|
748
748
|
for (const warning of result.warnings ?? []) {
|
|
749
|
-
console.error(wrapToTerminal(`${cliStyles.warning("warning:")} ${hinted(warning)}`));
|
|
749
|
+
console.error(wrapToTerminal(`${cliStyles.warning("warning:")} ${hinted(cliText(warning))}`));
|
|
750
750
|
}
|
|
751
751
|
}
|
|
752
|
-
if (!options.quiet) for (const line of footer) console.error(line);
|
|
753
|
-
// CSV says what its rows do not in closing `note:` lines, on stderr; NDJSON has no place for one among its rows,
|
|
754
|
-
// so the same notes go to stderr, where the warnings are.
|
|
752
|
+
if (!options.quiet) for (const line of footer) console.error(cliText(line));
|
|
755
753
|
if (options.format === "ndjson" && !options.quiet) {
|
|
756
|
-
for (const note of exportNdjsonNotes(result, options, renderOptions)) console.error(`note: ${note}`);
|
|
754
|
+
for (const note of exportNdjsonNotes(result, options, renderOptions)) console.error(cliText(`note: ${note}`));
|
|
757
755
|
}
|
|
758
756
|
}
|
|
759
757
|
|
package/src/cli/series-search.ts
CHANGED
|
@@ -41,11 +41,43 @@ const isWord = (text: string, word: string) => new RegExp(`(^|[^a-z0-9])${escape
|
|
|
41
41
|
/** A series whose name, tags and group have every word whole outranks any that has one only as the start of a longer word. */
|
|
42
42
|
const WHOLE_WORDS_SCORE = 10;
|
|
43
43
|
|
|
44
|
+
/** What a catalog search reads of a series: enough to rank and list it, none of the code that loads it. */
|
|
45
|
+
export interface CatalogSeriesFact {
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
unit: string;
|
|
49
|
+
frequency: string;
|
|
50
|
+
publisher?: string;
|
|
51
|
+
tags?: readonly string[];
|
|
52
|
+
group?: string;
|
|
53
|
+
description?: string;
|
|
54
|
+
/** What `fn G` charts. */
|
|
55
|
+
expression: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The catalog series the plugins declare, as a search reads them. Series that ask for a ticker are left out; a
|
|
60
|
+
* search names data, not a field of every stock. A formula priced in one delivery month (a crack) charts by its
|
|
61
|
+
* id: its expression alone would mix months.
|
|
62
|
+
*/
|
|
63
|
+
export function catalogSeriesFacts(plugins: readonly SeriesSource[]): CatalogSeriesFact[] {
|
|
64
|
+
return plugins.flatMap((plugin) => plugin.series ?? []).flatMap((definition) => definition.input ? [] : [{
|
|
65
|
+
id: definition.id,
|
|
66
|
+
name: definition.name,
|
|
67
|
+
unit: definition.unit,
|
|
68
|
+
frequency: definition.frequency,
|
|
69
|
+
...definition.publisher ? { publisher: definition.publisher } : {},
|
|
70
|
+
...definition.tags ? { tags: definition.tags } : {},
|
|
71
|
+
...definition.group ? { group: definition.group } : {},
|
|
72
|
+
...definition.description ? { description: definition.description } : {},
|
|
73
|
+
expression: "rollsWith" in definition && definition.rollsWith ? definition.id : seriesExpression(definition),
|
|
74
|
+
}]);
|
|
75
|
+
}
|
|
76
|
+
|
|
44
77
|
/**
|
|
45
78
|
* The plugins' catalog series whose words cover every word of the query: in
|
|
46
79
|
* the name and tags only for `search`, also the description and publisher for
|
|
47
|
-
* `catalog`.
|
|
48
|
-
* not a field of every stock. A query that is a series' id (`policy-rate:ch`),
|
|
80
|
+
* `catalog`. A query that is a series' id (`policy-rate:ch`),
|
|
49
81
|
* what `fn G` charts (`CAP:policy-rate:ch`, `FRED:DFEDTARU`) or a FRED series
|
|
50
82
|
* id (`DFEDTARU`) ranks it first, then one whose name, tags and group have
|
|
51
83
|
* each word whole (`defi` is Total DeFi TVL's tag, before the "deficit" of the
|
|
@@ -57,15 +89,22 @@ export function findCatalogSeries(
|
|
|
57
89
|
plugins: readonly SeriesSource[],
|
|
58
90
|
query: string,
|
|
59
91
|
scope: "names" | "all" = "all",
|
|
92
|
+
): SeriesMatch[] {
|
|
93
|
+
return findSeriesFacts(catalogSeriesFacts(plugins), query, scope);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** `findCatalogSeries` over series already read as facts. */
|
|
97
|
+
export function findSeriesFacts(
|
|
98
|
+
facts: readonly CatalogSeriesFact[],
|
|
99
|
+
query: string,
|
|
100
|
+
scope: "names" | "all" = "all",
|
|
60
101
|
): SeriesMatch[] {
|
|
61
102
|
const words = query.toLowerCase().replace(/["']/g, "").split(/\s+/).filter(Boolean);
|
|
62
103
|
if (words.length === 0 || words.join("").length < 3) return [];
|
|
63
104
|
const phrase = words.join(" ");
|
|
64
105
|
const ranked: Array<{ match: SeriesMatch; score: number; order: number }> = [];
|
|
65
|
-
for (const definition of
|
|
66
|
-
|
|
67
|
-
// A formula priced in one delivery month (a crack) charts by its id: its expression alone would mix months.
|
|
68
|
-
const expression = "rollsWith" in definition && definition.rollsWith ? definition.id : seriesExpression(definition);
|
|
106
|
+
for (const definition of facts) {
|
|
107
|
+
const expression = definition.expression;
|
|
69
108
|
const byId = words.length === 1
|
|
70
109
|
&& [definition.id, expression, fredSeriesIdOf(expression) ?? ""].some((id) => id.toLowerCase() === phrase);
|
|
71
110
|
const name = definition.name.toLowerCase();
|
package/src/cli/shot-temp-dir.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { mkdtemp
|
|
1
|
+
import { mkdtemp } from "fs/promises";
|
|
2
2
|
import { tmpdir } from "os";
|
|
3
3
|
import { join } from "path";
|
|
4
4
|
import { logFailure } from "../utils/log-failure";
|
|
5
|
-
|
|
6
|
-
type RemoveFolder = (
|
|
7
|
-
path: string,
|
|
8
|
-
options: { recursive: true; force: true; maxRetries: number; retryDelay: number },
|
|
9
|
-
) => Promise<void>;
|
|
5
|
+
import { removeFolder, type RemoveFolderOptions } from "../utils/remove-folder";
|
|
10
6
|
|
|
11
7
|
/**
|
|
12
8
|
* Hands `use` a fresh folder under the system temp folder and removes it
|
|
@@ -18,13 +14,12 @@ type RemoveFolder = (
|
|
|
18
14
|
export async function withShotTempDir<T>(
|
|
19
15
|
prefix: string,
|
|
20
16
|
use: (dir: string) => Promise<T>,
|
|
21
|
-
|
|
17
|
+
removal: RemoveFolderOptions = {},
|
|
22
18
|
): Promise<T> {
|
|
23
19
|
const dir = await mkdtemp(join(tmpdir(), prefix));
|
|
24
20
|
try {
|
|
25
21
|
return await use(dir);
|
|
26
22
|
} finally {
|
|
27
|
-
await
|
|
28
|
-
.catch(logFailure("cli.screenshot", "Could not remove a capture's temporary folder"));
|
|
23
|
+
if (await removeFolder(dir, removal) !== null) logFailure("cli.screenshot", "Could not remove a capture's temporary folder")(null);
|
|
29
24
|
}
|
|
30
25
|
}
|