@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
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { shellWord } from "../../utils/shell-word";
|
|
2
|
+
import type { CatalogSeriesFact } from "../series-search";
|
|
3
|
+
import type { PaneCatalogEntry } from "./catalog";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* What `catalog` lists for the built-in plugins, written down by `bun run catalog:snapshot`, so that a command which
|
|
7
|
+
* only lists functions reads one file instead of loading every plugin's code to ask each what it is. It holds
|
|
8
|
+
* the catalog as it reads on a fresh profile, and what a reader's own lists change in it is put back by
|
|
9
|
+
* `snapshotEntries`. The file is not in git: the release builds write it (`scripts/build.ts` for a binary, the
|
|
10
|
+
* build workflow for the npm package), and where it is absent the plugins are asked. `catalog-snapshot.test.ts`
|
|
11
|
+
* fails when what the generator writes no longer matches the plugins.
|
|
12
|
+
*/
|
|
13
|
+
export interface CatalogSnapshotEntry extends Omit<PaneCatalogEntry, "argExamples"> {
|
|
14
|
+
/** The built-in plugin that holds the function. */
|
|
15
|
+
pluginId: string;
|
|
16
|
+
/** The examples the function's own definition gives, past its placeholder. */
|
|
17
|
+
examples?: string[];
|
|
18
|
+
/** The function takes a list of symbols, so the reader's first list is one more example. */
|
|
19
|
+
listArgument?: true;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface CatalogSnapshot {
|
|
23
|
+
entries: CatalogSnapshotEntry[];
|
|
24
|
+
series: CatalogSeriesFact[];
|
|
25
|
+
/**
|
|
26
|
+
* The built-in plugins a function that reports data (`fn`) is among, in catalog order (its template's, and its
|
|
27
|
+
* pane's when another plugin holds that), by every word that names it (its code, an alias, its id), as the whole
|
|
28
|
+
* catalog settles them. A word that only matches a keyword is not here.
|
|
29
|
+
*/
|
|
30
|
+
functions: Record<string, string[]>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The catalog entries as the app builds them for a reader whose first list is `listName`. */
|
|
34
|
+
export function snapshotEntries(snapshot: CatalogSnapshot, listName: string | null): PaneCatalogEntry[] {
|
|
35
|
+
return snapshot.entries.map(({ pluginId: _pluginId, examples, listArgument, ...entry }) => {
|
|
36
|
+
const shown = listArgument && listName ? [...examples ?? [], shellWord(listName)] : examples ?? [];
|
|
37
|
+
if (shown.length === 0) return entry;
|
|
38
|
+
// The examples sit before the keywords and the shot argument in the entry, as the app builds it.
|
|
39
|
+
const ordered: Record<string, unknown> = {};
|
|
40
|
+
for (const [key, value] of Object.entries(entry)) {
|
|
41
|
+
if (key === "shotArgument" || key === "keywords") ordered.argExamples ??= shown;
|
|
42
|
+
ordered[key] = value;
|
|
43
|
+
}
|
|
44
|
+
return ordered as unknown as PaneCatalogEntry;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let read: CatalogSnapshot | null | undefined;
|
|
49
|
+
|
|
50
|
+
/** The snapshot file, read when first asked for; null where the build did not write one, and the plugins are asked. */
|
|
51
|
+
export function readCatalogSnapshot(): CatalogSnapshot | null {
|
|
52
|
+
if (read !== undefined) return read;
|
|
53
|
+
try {
|
|
54
|
+
read = require("./catalog-snapshot.json") as CatalogSnapshot;
|
|
55
|
+
} catch (error) {
|
|
56
|
+
// Bun says "Cannot find module" from source and "Cannot require module" from a compiled binary; a file that is
|
|
57
|
+
// there and fails to read is not an absent one.
|
|
58
|
+
if (!/Cannot (find|require) module/.test(String((error as { message?: unknown } | null)?.message ?? error))) throw error;
|
|
59
|
+
read = null;
|
|
60
|
+
}
|
|
61
|
+
return read;
|
|
62
|
+
}
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
wrapText,
|
|
33
33
|
type CliStatEntry,
|
|
34
34
|
} from "../../utils/cli-output";
|
|
35
|
-
import { renderGlossaryEntries, type GlossaryLookup } from "../glossary";
|
|
35
|
+
import { glossaryFunctionsNamed, glossaryNamesFunction, renderGlossaryEntries, type GlossaryLookup } from "../glossary";
|
|
36
36
|
import { renderSeriesMatches, type SeriesMatch } from "../series-search";
|
|
37
37
|
import { typoDistance } from "../../utils/typo-distance";
|
|
38
38
|
import { FUNCTION_HELP } from "./function-help";
|
|
@@ -263,17 +263,23 @@ export function nearFunctionCodes(
|
|
|
263
263
|
|
|
264
264
|
/**
|
|
265
265
|
* The functions a word that is no code asks for (`IVOL`, `IV`: HIVG and
|
|
266
|
-
* OVDV), as their `discovery.suggestFor` lists it,
|
|
266
|
+
* OVDV), as their `discovery.suggestFor` lists it, or the glossary term it
|
|
267
|
+
* names is shown by (`VAR`, `drawdown`: MARS and PORT), each by its code.
|
|
267
268
|
*/
|
|
268
269
|
export function suggestedFunctionCodes(registry: PaneFunctionCatalog, name: string): NearFunctionCode[] {
|
|
269
270
|
const wanted = normalizeLookupToken(name);
|
|
270
271
|
if (!wanted) return [];
|
|
272
|
+
// A term many functions show (a percentile) names none of them in particular: the catalog search lists those.
|
|
273
|
+
const named = glossaryFunctionsNamed(name);
|
|
274
|
+
const showing = new Set(named.length <= NEAR_CODE_LIMIT ? named : []);
|
|
271
275
|
return [...registry.paneTemplates.values()].flatMap((template) => {
|
|
272
276
|
if (template.listed === false) return [];
|
|
273
277
|
const pane = registry.panes.get(template.paneId);
|
|
274
278
|
const words = pane ? getHeadlessPaneDefinition(template, pane)?.discovery?.suggestFor ?? [] : [];
|
|
275
279
|
const code = template.shortcut?.prefix;
|
|
276
|
-
|
|
280
|
+
const shows = [code, ...template.shortcut?.aliases ?? []].some((candidate) => !!candidate && showing.has(candidate.toUpperCase()));
|
|
281
|
+
return code && (shows || words.some((word) => normalizeLookupToken(word) === wanted))
|
|
282
|
+
? [{ code: code.toUpperCase(), label: template.label }] : [];
|
|
277
283
|
}).sort((left, right) => left.code.localeCompare(right.code));
|
|
278
284
|
}
|
|
279
285
|
|
|
@@ -360,7 +366,7 @@ function argExamples(
|
|
|
360
366
|
}
|
|
361
367
|
|
|
362
368
|
/** The first watchlist, else portfolio, that holds a symbol: the list a function's example names. Null when none does. */
|
|
363
|
-
async function exampleListName(context: MarketContext): Promise<string | null> {
|
|
369
|
+
export async function exampleListName(context: Pick<MarketContext, "config" | "store">): Promise<string | null> {
|
|
364
370
|
const tickers = await Promise.resolve().then(() => context.store.loadAllTickers())
|
|
365
371
|
.catch(logFailure("cli-catalog", "Read the lists for an example failed", [] as TickerRecord[]));
|
|
366
372
|
const watchlist = context.config.watchlists.find((list) => tickers.some((ticker) => ticker.metadata.watchlists.includes(list.id)));
|
|
@@ -426,6 +432,11 @@ export async function buildPaneCatalogEntries(
|
|
|
426
432
|
return entries.sort((left, right) => left.token.localeCompare(right.token));
|
|
427
433
|
}
|
|
428
434
|
|
|
435
|
+
/** Whether the whole query names a glossary term the function shows (`VaR` for MARS), by its code or an alias (DES for T). */
|
|
436
|
+
function namesShownTerm(entry: Pick<PaneCatalogEntry, "token" | "shortcut" | "aliases">, query: string): boolean {
|
|
437
|
+
return [entry.token, entry.shortcut, ...entry.aliases].some((code) => !!code && glossaryNamesFunction(code, query));
|
|
438
|
+
}
|
|
439
|
+
|
|
429
440
|
/** The phrase starting a word of the text, so "funding rate" finds "funding rates" but "rate" is not found in "separate". */
|
|
430
441
|
function containsPhrase(text: string, phrase: string): boolean {
|
|
431
442
|
for (let at = text.indexOf(phrase); at >= 0; at = text.indexOf(phrase, at + 1)) {
|
|
@@ -524,7 +535,15 @@ interface CatalogMatchScore {
|
|
|
524
535
|
called: number;
|
|
525
536
|
}
|
|
526
537
|
|
|
527
|
-
|
|
538
|
+
/** How catalog matches are scored; `glossary: false` leaves out the glossary terms a function shows, as search did before them. */
|
|
539
|
+
interface CatalogScoring {
|
|
540
|
+
glossary?: boolean;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/** A query that is, whole, a term a function shows (`VaR`) outweighs it starting a word of a description (`variance`). */
|
|
544
|
+
const SHOWN_TERM_SCORE = 20;
|
|
545
|
+
|
|
546
|
+
function scorePaneCatalogEntry(entry: PaneCatalogEntry, query: string, { glossary = true }: CatalogScoring = {}): CatalogMatchScore {
|
|
528
547
|
const terms = queryTerms(query);
|
|
529
548
|
if (terms.length === 0) return { score: 1, terms: 0, named: 0, called: 0 };
|
|
530
549
|
const none = { score: 0, terms: terms.length, named: 0, called: 0 };
|
|
@@ -590,6 +609,14 @@ function scorePaneCatalogEntry(entry: PaneCatalogEntry, query: string): CatalogM
|
|
|
590
609
|
matchedTerms += 1;
|
|
591
610
|
}
|
|
592
611
|
|
|
612
|
+
// The whole query naming a term the function shows (`VaR`, `value at risk`, `expected shortfall` for MARS and PORT)
|
|
613
|
+
// names the function, every word of it found, where its own words do not already (`beta` is in PORT's keywords,
|
|
614
|
+
// `trade` in PF's description: those rank as they did). A word of a longer query, or a loose alias, names nothing.
|
|
615
|
+
if (glossary && matchedNamed < terms.length && namesShownTerm(entry, query)) {
|
|
616
|
+
score += SHOWN_TERM_SCORE;
|
|
617
|
+
matchedTerms = terms.length;
|
|
618
|
+
matchedNamed = terms.length;
|
|
619
|
+
}
|
|
593
620
|
if (matchedTerms === 0) return none;
|
|
594
621
|
// The whole query a value an option takes (GF's `operating margin` metric) is a name the function answers to.
|
|
595
622
|
const valueNamed = terms.length > 1 && flagValues.has(normalizeLookupToken(wholeQuery));
|
|
@@ -624,9 +651,9 @@ function isClosestCatalogMatch(entry: PaneCatalogEntry, query: string): boolean
|
|
|
624
651
|
return scorePaneCatalogEntry(entry, query).called === 0;
|
|
625
652
|
}
|
|
626
653
|
|
|
627
|
-
function rankPaneCatalogEntries(entries: PaneCatalogEntry[], query: string): PaneCatalogEntry[] {
|
|
654
|
+
function rankPaneCatalogEntries(entries: PaneCatalogEntry[], query: string, scoring: CatalogScoring = {}): PaneCatalogEntry[] {
|
|
628
655
|
return entries
|
|
629
|
-
.map((entry) => ({ entry, score: scorePaneCatalogEntry(entry, query).score }))
|
|
656
|
+
.map((entry) => ({ entry, score: scorePaneCatalogEntry(entry, query, scoring).score }))
|
|
630
657
|
.filter(({ score }) => score > 0)
|
|
631
658
|
.sort((left, right) => right.score - left.score || left.entry.token.localeCompare(right.entry.token))
|
|
632
659
|
.map(({ entry }) => entry);
|
|
@@ -651,23 +678,23 @@ function hasConsecutiveWordStarts(entry: PaneCatalogEntry, head: string, tail: s
|
|
|
651
678
|
* Two words typed as one ("volsurf" for Volatility Surface) match the functions that carry both
|
|
652
679
|
* words in a row, found by cutting the query into two word starts.
|
|
653
680
|
*/
|
|
654
|
-
function fusedQueryMatches(entries: PaneCatalogEntry[], query: string): PaneCatalogEntry[] {
|
|
681
|
+
function fusedQueryMatches(entries: PaneCatalogEntry[], query: string, scoring: CatalogScoring): PaneCatalogEntry[] {
|
|
655
682
|
const word = query.trim().toLowerCase();
|
|
656
683
|
if (/\s/.test(word)) return [];
|
|
657
684
|
for (let cut = FUSED_PART_MIN; cut <= word.length - FUSED_PART_MIN; cut += 1) {
|
|
658
685
|
const [head, tail] = [word.slice(0, cut), word.slice(cut)];
|
|
659
686
|
const split = `${head} ${tail}`;
|
|
660
|
-
const ranked = rankPaneCatalogEntries(entries, split);
|
|
661
|
-
const { shown, loose } = selectPaneCatalogMatches(ranked, split, ranked.length);
|
|
687
|
+
const ranked = rankPaneCatalogEntries(entries, split, scoring);
|
|
688
|
+
const { shown, loose } = selectPaneCatalogMatches(ranked, split, ranked.length, scoring);
|
|
662
689
|
const written = loose ? [] : shown.filter((entry) => hasConsecutiveWordStarts(entry, head, tail));
|
|
663
690
|
if (written.length > 0) return written;
|
|
664
691
|
}
|
|
665
692
|
return [];
|
|
666
693
|
}
|
|
667
694
|
|
|
668
|
-
export function filterPaneCatalogEntries(entries: PaneCatalogEntry[], query: string): PaneCatalogEntry[] {
|
|
669
|
-
const ranked = rankPaneCatalogEntries(entries, query);
|
|
670
|
-
return ranked.length > 0 ? ranked : fusedQueryMatches(entries, query);
|
|
695
|
+
export function filterPaneCatalogEntries(entries: PaneCatalogEntry[], query: string, scoring: CatalogScoring = {}): PaneCatalogEntry[] {
|
|
696
|
+
const ranked = rankPaneCatalogEntries(entries, query, scoring);
|
|
697
|
+
return ranked.length > 0 ? ranked : fusedQueryMatches(entries, query, scoring);
|
|
671
698
|
}
|
|
672
699
|
|
|
673
700
|
/** Whether two words differ by one letter: one added, dropped, changed, or two neighbours swapped. */
|
|
@@ -721,8 +748,13 @@ interface PaneCatalogSelection {
|
|
|
721
748
|
* name or description; when none does, the few closest, so "year to date" does not list a hundred functions
|
|
722
749
|
* that each have a date somewhere. `--all` (an infinite limit) lists every match.
|
|
723
750
|
*/
|
|
724
|
-
export function selectPaneCatalogMatches(
|
|
725
|
-
|
|
751
|
+
export function selectPaneCatalogMatches(
|
|
752
|
+
ranked: PaneCatalogEntry[],
|
|
753
|
+
query: string,
|
|
754
|
+
limit: number,
|
|
755
|
+
scoring: CatalogScoring = {},
|
|
756
|
+
): PaneCatalogSelection {
|
|
757
|
+
const scored = ranked.map((entry) => ({ entry, ...scorePaneCatalogEntry(entry, query, scoring) }));
|
|
726
758
|
const every = (items: typeof scored) => items.map(({ entry }) => entry);
|
|
727
759
|
const widened = !Number.isFinite(limit);
|
|
728
760
|
const multiWord = (scored[0]?.terms ?? 0) > 1;
|
|
@@ -824,7 +856,9 @@ function readinessCell(readiness: PaneFunctionReadiness): string {
|
|
|
824
856
|
*/
|
|
825
857
|
function reportCell(entry: PaneCatalogEntry): string {
|
|
826
858
|
const readiness = readinessCell(entry.capability.reportReadiness);
|
|
827
|
-
|
|
859
|
+
if (FUNCTION_HELP[entry.token]?.access === "pro") return `${readiness} · ${cliStyles.warning("Pro")}`;
|
|
860
|
+
return entry.capability.dataRequirements.some((requirement) => /\bsign-in\b/i.test(requirement))
|
|
861
|
+
? `${readiness} · ${cliStyles.warning("Sign-in")}` : readiness;
|
|
828
862
|
}
|
|
829
863
|
|
|
830
864
|
function optionDescription(option: PaneFunctionOptionDef): string {
|
|
@@ -7,7 +7,7 @@ import { parseChartSpec } from "../../plugins/builtin/chart-composer/chart-spec"
|
|
|
7
7
|
import { normalizeTickerInput } from "../../tickers/search";
|
|
8
8
|
import type { MarketContext } from "../types";
|
|
9
9
|
import { argumentNamesTicker, cleanTickerInput } from "./options";
|
|
10
|
-
import { parsePublicTickerKey, publicTickerKey } from "../../utils/exchanges";
|
|
10
|
+
import { canonicalExchange, parsePublicTickerKey, publicTickerKey } from "../../utils/exchanges";
|
|
11
11
|
import type { ResolvedPaneFunction } from "./resolver";
|
|
12
12
|
import { toMarketDataContext } from "../../market-data/selectors";
|
|
13
13
|
import { quoteMetadataFromQuote } from "../../market-data/quotes/metadata";
|
|
@@ -27,11 +27,23 @@ const SHOT_PRICE_HISTORY_RANGE = "5Y" as const;
|
|
|
27
27
|
const FINANCIAL_ANALYSIS_PANE_ID = "financial-analysis";
|
|
28
28
|
const FINANCIAL_ANALYSIS_TEMPLATE_ID = "financial-analysis-pane";
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* The saved row of the listing a pane function was given. A listing named by
|
|
32
|
+
* its venue (0700:HKEX, or Z74 with --exchange SGX) that was saved under its
|
|
33
|
+
* bare symbol on that venue is that row, keyed as named: the pane looks its
|
|
34
|
+
* ticker up by the key it is bound to, and a row keyed 0700 would leave it
|
|
35
|
+
* with no ticker at all. A bare row saved on another venue is another listing.
|
|
36
|
+
*/
|
|
30
37
|
export async function loadStoredShotTicker(context: MarketContext, symbol: string): Promise<TickerRecord | null> {
|
|
31
38
|
const normalized = cleanTickerInput(symbol);
|
|
32
|
-
const { symbol: bare } = parsePublicTickerKey(normalized);
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
const { symbol: bare, exchange } = parsePublicTickerKey(normalized);
|
|
40
|
+
const named = await context.store.loadTicker(normalized);
|
|
41
|
+
if (named || bare === normalized) return named;
|
|
42
|
+
const saved = await context.store.loadTicker(bare);
|
|
43
|
+
if (!saved) return null;
|
|
44
|
+
if (!exchange) return saved;
|
|
45
|
+
if (canonicalExchange(saved.metadata.exchange) !== canonicalExchange(exchange)) return null;
|
|
46
|
+
return { ...saved, metadata: { ...saved.metadata, ticker: normalized } };
|
|
35
47
|
}
|
|
36
48
|
|
|
37
49
|
/**
|
|
@@ -28,7 +28,7 @@ const DOM_EVERY_ROW =
|
|
|
28
28
|
const DOM_WHOLE_PANE =
|
|
29
29
|
"The pane was grown to fit the page it has open, so all of its text is returned.";
|
|
30
30
|
|
|
31
|
-
/** The sign-in wall's buttons, which a rendered view reads as words, with the key that presses one: `
|
|
31
|
+
/** The sign-in wall's buttons, which a rendered view reads as words, with the key that presses one: `Sign up free ↩ Log in`. */
|
|
32
32
|
const SIGN_IN_WALL_BUTTONS = /\s*\b(?:Log in|Sign up free|Resend Verification Email)(?:\s*[\u21A9\u21B5])?(?=\s|$)/g;
|
|
33
33
|
|
|
34
34
|
/** Whether the wall asks for the account's email to be verified, not for a sign-in. */
|
|
@@ -103,6 +103,23 @@ function cellText(cell: DesktopPaneShotRenderedRow["cells"][number]): string {
|
|
|
103
103
|
return formatUtcTime(cell.instant) || cell.text;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
/** A zone named at the end of a column header: `TIME HKT`, `TIME GMT+8`, `DATE ET`, `TIME UTC`. */
|
|
107
|
+
const HEADER_ZONE = /^(.*\S)\s+(?:UTC|GMT(?:[+-]\d{1,2}(?::?\d{2})?)?|[A-Z]{1,4}T)$/;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* A column the report prints from the instants behind its cells (cellText:
|
|
111
|
+
* UTC, the reader's zone beside it when set; the CSV and JSON the instant
|
|
112
|
+
* itself) is headed in UTC. The pane's header names the clock it drew the
|
|
113
|
+
* times on, the host's (`TIME HKT` over Top News); over the report's UTC
|
|
114
|
+
* times it named the wrong zone. Any other header stays as the pane drew it.
|
|
115
|
+
*/
|
|
116
|
+
function reportedHeader(header: string, cells: ReadonlyArray<DesktopPaneShotRenderedRow["cells"][number] | undefined>): string {
|
|
117
|
+
const filled = cells.filter((cell) => cell !== undefined);
|
|
118
|
+
if (filled.length === 0 || !filled.every((cell) => cell.instant)) return header;
|
|
119
|
+
const zoned = HEADER_ZONE.exec(header);
|
|
120
|
+
return zoned ? `${zoned[1]} UTC` : header;
|
|
121
|
+
}
|
|
122
|
+
|
|
106
123
|
interface DomTable {
|
|
107
124
|
tableIndex: number;
|
|
108
125
|
columns: Array<{ key: string; header: string }>;
|
|
@@ -133,13 +150,14 @@ function domTables(rows: DesktopPaneShotRenderedRow[]): DomTable[] {
|
|
|
133
150
|
previous = position;
|
|
134
151
|
}
|
|
135
152
|
}
|
|
153
|
+
const cellRows = tableRows.map((row) => {
|
|
154
|
+
const keys = domCellKeys(row);
|
|
155
|
+
return new Map(row.cells.map((cell, cellIndex) => [keys[cellIndex]!, cell]));
|
|
156
|
+
});
|
|
136
157
|
return {
|
|
137
158
|
tableIndex,
|
|
138
|
-
columns,
|
|
139
|
-
rows:
|
|
140
|
-
const keys = domCellKeys(row);
|
|
141
|
-
return new Map(row.cells.map((cell, cellIndex) => [keys[cellIndex]!, cell]));
|
|
142
|
-
}),
|
|
159
|
+
columns: columns.map((column) => ({ ...column, header: reportedHeader(column.header, cellRows.map((cells) => cells.get(column.key))) })),
|
|
160
|
+
rows: cellRows,
|
|
143
161
|
};
|
|
144
162
|
});
|
|
145
163
|
}
|
|
@@ -8,7 +8,7 @@ import type {
|
|
|
8
8
|
HeadlessSeriesResult,
|
|
9
9
|
HeadlessSnapshotResult,
|
|
10
10
|
} from "../../types/plugin";
|
|
11
|
-
import { localTimeSuffix, parseReportTime, type ReportTime } from "../../utils/utc-time";
|
|
11
|
+
import { formatUtcTime, localTimeSuffix, parseReportTime, type ReportTime } from "../../utils/utc-time";
|
|
12
12
|
import { timeZoneLabel, zonedDateTimeParts } from "../../utils/zoned-date-time";
|
|
13
13
|
import { isRecord } from "../../utils/guards";
|
|
14
14
|
import { latestRegularSessionClose, readIndexSession } from "../../market-data/market/freshness";
|
|
@@ -1361,6 +1361,9 @@ export function statusLineVariants(freshness: ReportFreshness, { source = false
|
|
|
1361
1361
|
? [{}, ...details.map((detail) => ({ ...detail, date: "none" as const })), { ...shortest, date: "none", note: "none" }]
|
|
1362
1362
|
: [...details, ...trailing];
|
|
1363
1363
|
const lines = [...new Set(variants.map((detail) => capitalize(statusLineParts(freshness, detail).join(" · "))))];
|
|
1364
|
+
if (freshness.status === "not-a-feed" && freshness.asOf?.includes("T") && !freshness.sources?.length && !freshness.oldest && !freshness.staleCount) {
|
|
1365
|
+
lines.push(formatUtcTime(freshness.asOf));
|
|
1366
|
+
}
|
|
1364
1367
|
// A line that dates each source names them already.
|
|
1365
1368
|
if (!source || freshness.sources?.length) return lines;
|
|
1366
1369
|
const sourced = [...new Set(variants.map((detail) => [`Source: ${freshness.source}`, ...statusLineParts(freshness, detail)].join(" · ")))];
|
|
@@ -1368,6 +1371,19 @@ export function statusLineVariants(freshness: ReportFreshness, { source = false
|
|
|
1368
1371
|
return [...sourced, ...lines.filter((line) => line.length < floor)];
|
|
1369
1372
|
}
|
|
1370
1373
|
|
|
1374
|
+
export function statusDateEvidence(freshness: ReportFreshness): string[][] {
|
|
1375
|
+
if (!freshness.asOf) return [];
|
|
1376
|
+
if (freshness.sources?.length) return [
|
|
1377
|
+
sourcesAsOfParts(freshness, freshness.sources, false),
|
|
1378
|
+
sourcesAsOfParts(freshness, freshness.sources, true),
|
|
1379
|
+
];
|
|
1380
|
+
return [
|
|
1381
|
+
[asOfText(freshness, true, false)],
|
|
1382
|
+
[asOfText(freshness, true, false, true)],
|
|
1383
|
+
[formatUtcTime(freshness.asOf)],
|
|
1384
|
+
];
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1371
1387
|
/** A capture's status line: the facts it states (its `freshness` in JSON) and its text, longest first. */
|
|
1372
1388
|
export interface CaptureStatusLine {
|
|
1373
1389
|
freshness: ReportFreshness;
|
|
@@ -891,6 +891,9 @@ export function headlessReportTables(
|
|
|
891
891
|
// A section of one name or one date says so for every line it exports.
|
|
892
892
|
const named = {
|
|
893
893
|
...(section.symbol?.trim() ? { symbolOrSeries: section.symbol.trim() } : {}),
|
|
894
|
+
...(section.unit?.trim() ? { currencyOrUnit: section.unit.trim() } : {}),
|
|
895
|
+
...(section.interval?.trim() ? { interval: section.interval.trim() } : {}),
|
|
896
|
+
...("source" in section && section.source?.trim() ? { source: section.source.trim() } : {}),
|
|
894
897
|
...(section.asOf === null ? { asOf: null } : section.asOf?.trim() ? { asOf: section.asOf.trim() } : {}),
|
|
895
898
|
...(section.period?.trim() ? { period: section.period.trim() } : {}),
|
|
896
899
|
...(section.released?.trim() ? { released: section.released.trim() } : {}),
|
|
@@ -913,14 +916,16 @@ export function headlessReportTables(
|
|
|
913
916
|
const rowIdentities = section.entries.some((entry) => own(entry)) ? section.entries.map(own) : undefined;
|
|
914
917
|
return { ...entries, ...(Object.keys(named).length > 0 ? { identity: named } : {}), ...(rowIdentities ? { rowIdentities } : {}) };
|
|
915
918
|
}
|
|
916
|
-
const table = exportRowsTable(section.title, displayedColumns(columnsFor(section.rows, section.columns, definition.columns)), section.rows,
|
|
919
|
+
const table = exportRowsTable(section.title, displayedColumns(columnsFor(section.rows, section.columns, definition.columns)), section.rows,
|
|
920
|
+
{ status: true, appendedColumns: section.appendedColumns });
|
|
917
921
|
const identity = {
|
|
918
922
|
...named,
|
|
919
923
|
...(section.unit?.trim() ? { currencyOrUnit: section.unit.trim() } : {}),
|
|
920
924
|
...(section.interval?.trim() ? { interval: section.interval.trim() } : {}),
|
|
921
925
|
};
|
|
922
926
|
const rowIdentities = rowIdentitiesOf(section.rows, section);
|
|
923
|
-
return { ...table, ...(
|
|
927
|
+
return { ...table, ...(section.appendedColumns ? { appendedColumns: section.appendedColumns } : {}),
|
|
928
|
+
...(Object.keys(identity).length > 0 ? { identity } : {}), ...(rowIdentities ? { rowIdentities } : {}) };
|
|
924
929
|
});
|
|
925
930
|
break;
|
|
926
931
|
case "series": {
|
|
@@ -2,7 +2,7 @@ import { logFailure } from "../../utils/log-failure";
|
|
|
2
2
|
import { extname, isAbsolute, relative, resolve } from "path";
|
|
3
3
|
import type { CliCommandContext, GloomPlugin, HeadlessArgumentExpansion } from "../../types/plugin";
|
|
4
4
|
import type { MarketContext } from "../types";
|
|
5
|
-
import { withMarketData } from "../context";
|
|
5
|
+
import { withConfigData, withMarketData } from "../context";
|
|
6
6
|
import { buildForFile, cliStyles, renderForFile, renderStats, type CliStatEntry } from "../../utils/cli-output";
|
|
7
7
|
import {
|
|
8
8
|
correctCatalogQuery,
|
|
@@ -17,8 +17,9 @@ import {
|
|
|
17
17
|
} from "./catalog";
|
|
18
18
|
import { createPaneCatalog } from "./discovery";
|
|
19
19
|
import { getHeadlessPaneDefinition } from "./capabilities";
|
|
20
|
-
import { catalogFredSeriesIds, findCatalogSeries } from "../series-search";
|
|
20
|
+
import { catalogFredSeriesIds, findCatalogSeries, findSeriesFacts, type SeriesMatch } from "../series-search";
|
|
21
21
|
import {
|
|
22
|
+
normalizeLookupToken,
|
|
22
23
|
parsePaneCatalogArgs,
|
|
23
24
|
parsePaneFunctionArgs,
|
|
24
25
|
type ParsedPaneFunctionArgs,
|
|
@@ -27,7 +28,7 @@ import {
|
|
|
27
28
|
applyListingArgument, findPaneFunction, parsePaneFunctionArgsFor, resolvePaneFunction, UnknownPaneFunctionError,
|
|
28
29
|
type PluginCodeStopFinder, type ResolvedPaneFunction,
|
|
29
30
|
} from "./resolver";
|
|
30
|
-
import { idleCliPlugins } from "../registry";
|
|
31
|
+
import { idleCliPlugins, installedPluginCount } from "../registry";
|
|
31
32
|
import { pluginSupportsTarget } from "../../plugins/plugin-export";
|
|
32
33
|
import type { RegistryPlugin } from "../../plugins/marketplace/model";
|
|
33
34
|
import type { AppResourceStorePort } from "../../core/app-service-ports";
|
|
@@ -38,7 +39,11 @@ import { renderDesktopShot } from "./screenshot-render";
|
|
|
38
39
|
import { shotCutColumnsWarning, shotStatusIssues } from "./screenshot-assessment";
|
|
39
40
|
import {
|
|
40
41
|
buildPaneCatalogEntries,
|
|
42
|
+
exampleListName,
|
|
43
|
+
type PaneCatalogEntry,
|
|
41
44
|
} from "./catalog";
|
|
45
|
+
import { readCatalogSnapshot, snapshotEntries } from "./catalog-snapshot";
|
|
46
|
+
import { loadBuiltinPlugin } from "../../plugins/catalog-lazy";
|
|
42
47
|
import { incompleteReportGateMessage } from "./access-gate";
|
|
43
48
|
import { withPersistedCloudSession } from "./cloud-session";
|
|
44
49
|
import {
|
|
@@ -48,8 +53,9 @@ import { notATickerStop } from "../company-name-hint";
|
|
|
48
53
|
import { CLI_ERROR_CODE, failUnreachable, failWithError, isCliFailure, isSourceUnavailableAnswer, unreachableError } from "../errors";
|
|
49
54
|
import { DATA_SERVICE_UNREACHABLE_MESSAGE, isNetworkFailure } from "../../utils/network-failure";
|
|
50
55
|
import { isTickerLinkPeer } from "../../layout/ticker-navigation";
|
|
51
|
-
import { knownGapMessage, commandPointer, commandPointerLeads, topicPointer } from "../known-gaps";
|
|
56
|
+
import { appCommandPointer, knownGapMessage, commandPointer, commandPointerLeads, topicPointer } from "../known-gaps";
|
|
52
57
|
import { selectReportTables, splitCsvFooter, withRefusedRows, type CliReportTables } from "../report-tables";
|
|
58
|
+
import { portableCsv } from "../csv-export";
|
|
53
59
|
import { cliOutputWritten, printCliResult, serializeCliResult, type CliErrorObject } from "../result";
|
|
54
60
|
import { checkOutputPath, resolveOutputPath, writeOutputFile } from "../output-file";
|
|
55
61
|
import type { CatalogCommandHit } from "../unknown-command";
|
|
@@ -80,11 +86,11 @@ async function withPaneRuntime<T>(
|
|
|
80
86
|
return withMarketData(ctx, async (market) => {
|
|
81
87
|
const context: MarketContext = ctx.cliOptions.refresh ? { ...market, refresh: true } : market;
|
|
82
88
|
// `shot` draws a pane as the desktop app does, so it also opens the panes of plugins only the desktop app runs (Gloom Social).
|
|
83
|
-
const plugins = settings.command === "shot" ? [...ctx.plugins, ...desktopOnlyPlugins(ctx)] : ctx
|
|
89
|
+
const plugins = settings.command === "shot" ? [...ctx.plugins, ...desktopOnlyPlugins(ctx)] : await pluginsOfFunction(ctx, context, args);
|
|
84
90
|
const registry = await createPaneCatalog(context, plugins);
|
|
85
91
|
try {
|
|
86
92
|
let parsed = await applyListingArgument(registry, context, parsePaneFunctionArgsFor(registry, args, ctx.cliOptions), settings.command);
|
|
87
|
-
const resolution = { ...settings, seriesSources: ctx.plugins, pluginStop: pluginStopFor(ctx, context) };
|
|
93
|
+
const resolution = { ...settings, seriesSources: () => ctx.plugins, pluginStop: pluginStopFor(ctx, context) };
|
|
88
94
|
let resolved = await resolvePaneFunction(registry, context, parsed, resolution);
|
|
89
95
|
// A function that widens its argument (RV's --peers) runs, reports and captures the widened one.
|
|
90
96
|
const expansion = await withPersistedCloudSession(context, () => expandResolvedArgument(resolved, context, parsed.arg));
|
|
@@ -99,6 +105,26 @@ async function withPaneRuntime<T>(
|
|
|
99
105
|
});
|
|
100
106
|
}
|
|
101
107
|
|
|
108
|
+
/**
|
|
109
|
+
* The plugins `fn` resolves a function among. A coded function that reports data, of a built-in plugin, is
|
|
110
|
+
* opened by that plugin and the one that holds its pane (`catalog-snapshot.json`, where a build wrote it, says
|
|
111
|
+
* which), so the other plugins' code is not loaded to run it. Any other word, a source checkout without that
|
|
112
|
+
* file, and any command line with an installed or switched-off plugin, asks them all.
|
|
113
|
+
*/
|
|
114
|
+
async function pluginsOfFunction(ctx: CliCommandContext, context: MarketContext, args: string[]): Promise<GloomPlugin[]> {
|
|
115
|
+
if ((context.config.disabledPlugins ?? []).length > 0 || await installedPluginCount(ctx) > 0) return ctx.plugins;
|
|
116
|
+
let target: string;
|
|
117
|
+
try {
|
|
118
|
+
target = parsePaneFunctionArgs(args, ctx.cliOptions).target;
|
|
119
|
+
} catch {
|
|
120
|
+
// Intentional ignore: arguments that do not parse fail where they are parsed for the function.
|
|
121
|
+
return ctx.plugins;
|
|
122
|
+
}
|
|
123
|
+
const holders = target ? readCatalogSnapshot()?.functions[normalizeLookupToken(target)] : undefined;
|
|
124
|
+
const found = holders?.flatMap((id) => loadBuiltinPlugin(id) ?? []);
|
|
125
|
+
return found?.length ? found : ctx.plugins;
|
|
126
|
+
}
|
|
127
|
+
|
|
102
128
|
/** Installed plugins the command line does not run but the desktop app does, which `shot` draws as it does. */
|
|
103
129
|
function desktopOnlyPlugins(ctx: CliCommandContext): GloomPlugin[] {
|
|
104
130
|
return idleCliPlugins(ctx)
|
|
@@ -471,10 +497,9 @@ export async function runPaneFunction(args: string[], ctx: CliCommandContext) {
|
|
|
471
497
|
// A report with no data writes no file: a header alone would read as a screen that matched nothing. It fails
|
|
472
498
|
// as plain --json fails, with its code and whether to retry.
|
|
473
499
|
if (failure) failWithError({ ...failure, details: `Nothing was written to ${outputPath}.` });
|
|
474
|
-
// A CSV file holds its rows alone; its closing source and note lines go to stderr, as printed CSV's do.
|
|
475
500
|
const written = renderForFile(() => serializeCliResult(result, ctx.cliOptions, render));
|
|
476
501
|
const { csv, footer } = ctx.cliOptions.format === "csv" ? splitCsvFooter(written) : { csv: written, footer: [] };
|
|
477
|
-
await writeOutputFile(outputPath, `${csv}\n`);
|
|
502
|
+
await writeOutputFile(outputPath, `${ctx.cliOptions.format === "csv" ? portableCsv(written, warnings) : csv}\n`);
|
|
478
503
|
if (!ctx.cliOptions.quiet) for (const line of footer) console.error(line);
|
|
479
504
|
// What was written and where; warnings go to stderr as they would beside printed rows, and JSON keeps its envelope.
|
|
480
505
|
const saved = { output: outputPath, format: ctx.cliOptions.format, rows: report.data.rowCount, replaced: replacing };
|
|
@@ -640,8 +665,10 @@ async function capturePaneScreenshot(args: string[], ctx: CliCommandContext, onS
|
|
|
640
665
|
return [`Saved ${displayPath(data.outputPath)}`, renderStats(stats)].join("\n");
|
|
641
666
|
},
|
|
642
667
|
});
|
|
643
|
-
// The image is saved and the reason printed; --strict tells a script it should not be used.
|
|
668
|
+
// The image is saved and the reason printed; --strict tells a script it should not be used. A pane that drew
|
|
669
|
+
// nothing but its empty state ("No ticker selected.") failed either way, as `fn` does for an empty report.
|
|
644
670
|
if (parsed.strict && !result.usable) process.exitCode = CLI_EXIT_CODES.unusableShot;
|
|
671
|
+
else if (!result.usable && result.render.emptyStateDetected && result.rowCount === 0) process.exitCode = CLI_EXIT_CODES.error;
|
|
645
672
|
}, { command: "shot" });
|
|
646
673
|
});
|
|
647
674
|
}
|
|
@@ -718,46 +745,13 @@ export async function runPaneCatalog(args: string[], ctx: CliCommandContext) {
|
|
|
718
745
|
...parsed,
|
|
719
746
|
limit: ctx.cliOptions.limit ?? parsed.limit,
|
|
720
747
|
};
|
|
748
|
+
if (await listFromSnapshot(ctx, parsed, effectiveParsed)) return;
|
|
721
749
|
await withMarketData(ctx, async (context) => {
|
|
722
750
|
const registry = await createPaneCatalog(context, ctx.plugins);
|
|
723
751
|
try {
|
|
724
752
|
// The UI audits picture every pane the app opens, those the command line has nothing to show for too.
|
|
725
753
|
const entries = await buildPaneCatalogEntries(registry, context, { appPanes: process.env[CATALOG_APP_PANES_ENV] === "1" });
|
|
726
|
-
|
|
727
|
-
? entries.filter((entry) => entry.capability.botSafe)
|
|
728
|
-
: entries;
|
|
729
|
-
// A topic no function covers is answered by its pointer, not by the loose matches its words find.
|
|
730
|
-
const pointer = topicPointer(parsed.query);
|
|
731
|
-
const typed = pointer ? [] : filterPaneCatalogEntries(botSafeEntries, parsed.query);
|
|
732
|
-
// Data no source carries yet is said once: in the text, else as the envelope's warning.
|
|
733
|
-
const gap = knownGapMessage(parsed.query);
|
|
734
|
-
// A word one letter off every function's ("fundng") is read as the one it is near, and the report says so; a
|
|
735
|
-
// word the catalog has its own answer for ("libor") is not a typo.
|
|
736
|
-
const corrected = pointer || gap || typed.length ? null : correctCatalogQuery(botSafeEntries, parsed.query);
|
|
737
|
-
const correctedMatches = corrected ? filterPaneCatalogEntries(botSafeEntries, corrected) : [];
|
|
738
|
-
const readAs = corrected && correctedMatches.length ? corrected : null;
|
|
739
|
-
const filtered = readAs ? correctedMatches : typed;
|
|
740
|
-
const query = readAs ?? parsed.query;
|
|
741
|
-
// A search also finds the terms it names; text only, the JSON stays a list of functions.
|
|
742
|
-
const glossary = lookupGlossary(parsed.query);
|
|
743
|
-
// A setting or a report can be a command, not a function: "light theme" names `config themes` beside THEM,
|
|
744
|
-
// "drip" names `portfolio show --drip` beside DVD.
|
|
745
|
-
const setting = commandPointer(parsed.query);
|
|
746
|
-
const settingLeads = commandPointerLeads(parsed.query);
|
|
747
|
-
// The data catalog series the query names, which `fn G` charts.
|
|
748
|
-
const series = findCatalogSeries(ctx.plugins, parsed.query);
|
|
749
|
-
const listed = pointer
|
|
750
|
-
? pointer.codes.flatMap((code) => entries.filter((entry) => entry.token === code))
|
|
751
|
-
: selectPaneCatalogMatches(filtered, query, effectiveParsed.limit).shown;
|
|
752
|
-
const readNote = readAs ? `No functions match "${parsed.query}"; showing "${readAs}".` : null;
|
|
753
|
-
ctx.printResult({
|
|
754
|
-
data: listed,
|
|
755
|
-
...series.length || readAs ? { metadata: { ...series.length ? { series } : {}, ...readAs ? { query: readAs } : {} } } : {},
|
|
756
|
-
...(gap || setting) && ctx.cliOptions.format !== "text" ? { warnings: [gap, setting].filter((note): note is string => !!note) } : {},
|
|
757
|
-
}, {
|
|
758
|
-
text: () => [readNote ? cliStyles.muted(readNote) : "", renderPaneCatalogReport(filtered, { ...effectiveParsed, query }, glossary, gap, series, setting, settingLeads)]
|
|
759
|
-
.filter(Boolean).join("\n\n"),
|
|
760
|
-
});
|
|
754
|
+
printCatalog(ctx, parsed, effectiveParsed, entries, findCatalogSeries(ctx.plugins, parsed.query));
|
|
761
755
|
} finally {
|
|
762
756
|
registry.destroy();
|
|
763
757
|
}
|
|
@@ -765,6 +759,70 @@ export async function runPaneCatalog(args: string[], ctx: CliCommandContext) {
|
|
|
765
759
|
});
|
|
766
760
|
}
|
|
767
761
|
|
|
762
|
+
/**
|
|
763
|
+
* The catalog read from what the built-in plugins declare (`catalog-snapshot.json`, which a release build writes),
|
|
764
|
+
* where nothing else is installed, switched off or asked for: the plugins' code is not loaded to say what they
|
|
765
|
+
* are. False when it could not answer, with no snapshot among the reasons, and the plugins are asked instead.
|
|
766
|
+
*/
|
|
767
|
+
async function listFromSnapshot(
|
|
768
|
+
ctx: CliCommandContext,
|
|
769
|
+
parsed: ReturnType<typeof parsePaneCatalogArgs>,
|
|
770
|
+
effectiveParsed: ReturnType<typeof parsePaneCatalogArgs>,
|
|
771
|
+
): Promise<boolean> {
|
|
772
|
+
const snapshot = readCatalogSnapshot();
|
|
773
|
+
if (!snapshot || process.env[CATALOG_APP_PANES_ENV] === "1" || await installedPluginCount(ctx) > 0) return false;
|
|
774
|
+
return withConfigData(ctx, async (context) => {
|
|
775
|
+
if ((context.config.disabledPlugins ?? []).length > 0) return false;
|
|
776
|
+
printCatalog(ctx, parsed, effectiveParsed, snapshotEntries(snapshot, await exampleListName(context)), findSeriesFacts(snapshot.series, parsed.query));
|
|
777
|
+
return true;
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
/** The report of the functions and series a `catalog` query finds. */
|
|
782
|
+
function printCatalog(
|
|
783
|
+
ctx: CliCommandContext,
|
|
784
|
+
parsed: ReturnType<typeof parsePaneCatalogArgs>,
|
|
785
|
+
effectiveParsed: ReturnType<typeof parsePaneCatalogArgs>,
|
|
786
|
+
entries: PaneCatalogEntry[],
|
|
787
|
+
series: SeriesMatch[],
|
|
788
|
+
): void {
|
|
789
|
+
const botSafeEntries = effectiveParsed.botSafeOnly
|
|
790
|
+
? entries.filter((entry) => entry.capability.botSafe)
|
|
791
|
+
: entries;
|
|
792
|
+
// A topic no function covers is answered by its pointer, not by the loose matches its words find; so is a
|
|
793
|
+
// command of the app's own that no function is (FB, Send Feedback).
|
|
794
|
+
const pointer = topicPointer(parsed.query);
|
|
795
|
+
const appCommand = pointer || commandPointer(parsed.query) ? null : appCommandPointer(parsed.query);
|
|
796
|
+
const typed = pointer || appCommand ? [] : filterPaneCatalogEntries(botSafeEntries, parsed.query);
|
|
797
|
+
// Data no source carries yet is said once: in the text, else as the envelope's warning.
|
|
798
|
+
const gap = knownGapMessage(parsed.query);
|
|
799
|
+
// A word one letter off every function's ("fundng") is read as the one it is near, and the report says so; a
|
|
800
|
+
// word the catalog has its own answer for ("libor") is not a typo.
|
|
801
|
+
const corrected = pointer || gap || appCommand || typed.length ? null : correctCatalogQuery(botSafeEntries, parsed.query);
|
|
802
|
+
const correctedMatches = corrected ? filterPaneCatalogEntries(botSafeEntries, corrected) : [];
|
|
803
|
+
const readAs = corrected && correctedMatches.length ? corrected : null;
|
|
804
|
+
const filtered = readAs ? correctedMatches : typed;
|
|
805
|
+
const query = readAs ?? parsed.query;
|
|
806
|
+
// A search also finds the terms it names; text only, the JSON stays a list of functions.
|
|
807
|
+
const glossary = lookupGlossary(parsed.query);
|
|
808
|
+
// A setting or a report can be a command, not a function: "light theme" names `config themes` beside THEM,
|
|
809
|
+
// "drip" names `portfolio show --drip` beside DVD.
|
|
810
|
+
const setting = commandPointer(parsed.query) ?? appCommand;
|
|
811
|
+
const settingLeads = commandPointerLeads(parsed.query) || !!appCommand;
|
|
812
|
+
const listed = pointer
|
|
813
|
+
? pointer.codes.flatMap((code) => entries.filter((entry) => entry.token === code))
|
|
814
|
+
: selectPaneCatalogMatches(filtered, query, effectiveParsed.limit).shown;
|
|
815
|
+
const readNote = readAs ? `No functions match "${parsed.query}"; showing "${readAs}".` : null;
|
|
816
|
+
ctx.printResult({
|
|
817
|
+
data: listed,
|
|
818
|
+
...series.length || readAs ? { metadata: { ...series.length ? { series } : {}, ...readAs ? { query: readAs } : {} } } : {},
|
|
819
|
+
...(gap || setting) && ctx.cliOptions.format !== "text" ? { warnings: [gap, setting].filter((note): note is string => !!note) } : {},
|
|
820
|
+
}, {
|
|
821
|
+
text: () => [readNote ? cliStyles.muted(readNote) : "", renderPaneCatalogReport(filtered, { ...effectiveParsed, query }, glossary, gap, series, setting, settingLeads)]
|
|
822
|
+
.filter(Boolean).join("\n\n"),
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
|
|
768
826
|
async function runPaneCliCommand(ctx: CliCommandContext, run: () => Promise<void>) {
|
|
769
827
|
try {
|
|
770
828
|
await run();
|