@gloom-sh/terminal 0.20.18 → 0.20.19
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 +1 -1
- package/src/api-client/cot.ts +5 -6
- package/src/api-client/data.ts +11 -1
- package/src/api-client/index.ts +1 -0
- package/src/api-client/request.ts +162 -40
- package/src/api-client/types/news.ts +45 -0
- package/src/api-client/types/world-venues.ts +9 -0
- package/src/app.tsx +4 -2
- package/src/architecture/floating-promise-allowlist.json +1 -1
- package/src/cli/commands/market.ts +53 -17
- package/src/cli/commands/ticker.ts +13 -6
- package/src/cli/context.ts +8 -0
- package/src/cli/desktop-pane-shot-browser.ts +3 -1
- package/src/cli/desktop-pane-shot-view.ts +0 -1
- package/src/cli/desktop-pane-shot.ts +204 -43
- package/src/cli/errors.ts +3 -9
- package/src/cli/exit-codes.ts +1 -1
- package/src/cli/glossary.ts +1 -1
- package/src/cli/help.ts +1 -1
- package/src/cli/history-rows.ts +2 -2
- package/src/cli/index.ts +1 -1
- package/src/cli/listing-arg.ts +87 -23
- package/src/cli/pane-functions/catalog-snapshot.json +17 -6
- package/src/cli/pane-functions/dom.ts +30 -2
- package/src/cli/pane-functions/freshness.ts +23 -4
- package/src/cli/pane-functions/function-help.ts +3 -3
- package/src/cli/pane-functions/headless.ts +9 -1
- package/src/cli/pane-functions/index.ts +77 -10
- package/src/cli/pane-functions/report-notices.ts +10 -0
- package/src/cli/pane-functions/resolver.ts +3 -2
- package/src/cli/pane-functions/screenshot-assessment.ts +10 -5
- package/src/cli/pane-functions/screenshot-data-evidence.ts +7 -15
- package/src/cli/pane-functions/screenshot-payload.ts +24 -10
- package/src/cli/pane-functions/screenshot-render.ts +21 -8
- package/src/cli/pane-functions/screenshot-types.ts +9 -0
- package/src/cli/quote-answer.ts +1 -1
- package/src/cli/result.ts +17 -0
- package/src/cli/scroll-truncation.ts +7 -2
- package/src/cli/ticker-resolution.ts +1 -1
- package/src/cli/unreachable.ts +21 -0
- package/src/components/chart/composite/drawing-store.ts +11 -7
- package/src/components/chart/composite/format.ts +1 -0
- package/src/components/chart/composite/legend.tsx +5 -2
- package/src/components/chart/composite/panel-surface/plot-gestures.ts +9 -2
- package/src/components/chart/composite/panel-surface.tsx +1 -1
- package/src/components/chart/composite/tools.ts +164 -39
- package/src/components/chart-table/header.tsx +2 -2
- package/src/components/chart-table/layout.ts +5 -6
- package/src/components/command-bar/routes/root/runtime.ts +11 -3
- package/src/components/command-bar/routes/ticker-search/results.ts +5 -0
- package/src/components/command-bar/selection-runtime.ts +29 -5
- package/src/components/command-bar/surface/index.tsx +4 -1
- package/src/components/command-bar/workflow/alert.ts +13 -5
- package/src/components/layout/pane/footer/model.ts +10 -2
- package/src/components/layout/pane/status-footer.ts +24 -0
- package/src/components/price-performance.tsx +26 -8
- package/src/components/reader/article-reader.tsx +12 -5
- package/src/components/ui/data-table/opentui/index.tsx +7 -0
- package/src/components/ui/table-layout.ts +32 -1
- package/src/market-data/ah-pair.ts +19 -0
- package/src/market-data/coordinator/entries.ts +6 -4
- package/src/market-data/coordinator/index.ts +14 -3
- package/src/market-data/futures-board.ts +36 -29
- package/src/market-data/futures-contract.ts +37 -1
- package/src/market-data/market/change-basis.ts +9 -0
- package/src/market-data/market/status.ts +40 -4
- package/src/market-data/performance.ts +127 -32
- package/src/market-data/quotes/time.ts +5 -2
- package/src/news/types.ts +28 -0
- package/src/notifications/app-badge.ts +2 -3
- package/src/notifications/app-notifier.ts +5 -0
- package/src/plugins/builtin/alerts/cli.ts +65 -18
- package/src/plugins/builtin/alerts/command.ts +39 -9
- package/src/plugins/builtin/alerts/event-rows.ts +9 -3
- package/src/plugins/builtin/alerts/events-pane.tsx +16 -10
- package/src/plugins/builtin/alerts/headless.ts +12 -6
- package/src/plugins/builtin/alerts/index.tsx +60 -8
- package/src/plugins/builtin/alerts/option-contract.ts +197 -0
- package/src/plugins/builtin/alerts/price.ts +30 -5
- package/src/plugins/builtin/alerts/pro-rules.ts +62 -0
- package/src/plugins/builtin/alerts/research-builder.ts +5 -10
- package/src/plugins/builtin/analytics/account-returns.ts +1 -1
- package/src/plugins/builtin/analytics/pane-model.ts +2 -2
- package/src/plugins/builtin/analytics/risk-client.ts +1 -1
- package/src/plugins/builtin/buildout/company/pane.tsx +4 -14
- package/src/plugins/builtin/catalysts/model.ts +2 -1
- package/src/plugins/builtin/chart-composer/chart-spec.ts +5 -0
- package/src/plugins/builtin/chart-composer/cli-options.ts +5 -3
- package/src/plugins/builtin/chart-composer/headless-schema.ts +14 -10
- package/src/plugins/builtin/chart-composer/headless.ts +2 -0
- package/src/plugins/builtin/chart-composer/index.tsx +17 -5
- package/src/plugins/builtin/chart-composer/pane.tsx +14 -4
- package/src/plugins/builtin/chart-composer/viewport-labels.ts +2 -17
- package/src/plugins/builtin/chat/controller/notifications.ts +1 -0
- package/src/plugins/builtin/chat/index.tsx +0 -1
- package/src/plugins/builtin/commodities-energy/index.tsx +1 -1
- package/src/plugins/builtin/company-kpis/headless.ts +1 -1
- package/src/plugins/builtin/company-kpis/model.ts +21 -9
- package/src/plugins/builtin/congress-trades/model.ts +9 -5
- package/src/plugins/builtin/cot/client.ts +2 -3
- package/src/plugins/builtin/cot/headless.ts +16 -16
- package/src/plugins/builtin/cot/index.tsx +6 -6
- package/src/plugins/builtin/cot/model.ts +25 -5
- package/src/plugins/builtin/cot/pane.tsx +11 -6
- package/src/plugins/builtin/cot/series.ts +11 -8
- package/src/plugins/builtin/cpi/model.ts +15 -4
- package/src/plugins/builtin/cpi/pane.tsx +29 -7
- package/src/plugins/builtin/doe/model.ts +30 -0
- package/src/plugins/builtin/doe/pane.tsx +8 -2
- package/src/plugins/builtin/earnings/board-table.ts +9 -4
- package/src/plugins/builtin/earnings/headless.ts +10 -3
- package/src/plugins/builtin/earnings/history-table.ts +4 -2
- package/src/plugins/builtin/earnings-calls/calendar.tsx +4 -3
- package/src/plugins/builtin/earnings-ripple/pane.tsx +2 -2
- package/src/plugins/builtin/econ/index.tsx +4 -2
- package/src/plugins/builtin/futures/model.ts +14 -1
- package/src/plugins/builtin/futures/series.ts +1 -8
- package/src/plugins/builtin/fx-matrix/index.tsx +2 -2
- package/src/plugins/builtin/insider/detail.tsx +36 -7
- package/src/plugins/builtin/insider/filing-stories.ts +110 -0
- package/src/plugins/builtin/insider/headless.ts +37 -2
- package/src/plugins/builtin/insider/index.tsx +79 -10
- package/src/plugins/builtin/insider/model.ts +43 -5
- package/src/plugins/builtin/ipo-calendar/client.ts +11 -1
- package/src/plugins/builtin/ipo-calendar/model.ts +3 -7
- package/src/plugins/builtin/jobs/headless.ts +2 -1
- package/src/plugins/builtin/jobs/model.ts +6 -0
- package/src/plugins/builtin/jobs/pane.tsx +8 -3
- package/src/plugins/builtin/news/wire/news/detail-view.tsx +118 -10
- package/src/plugins/builtin/news/wire/news/story-evidence.ts +178 -0
- package/src/plugins/builtin/options/analytics.ts +1 -1
- package/src/plugins/builtin/options/view.tsx +18 -11
- package/src/plugins/builtin/options-positioning/model.ts +11 -0
- package/src/plugins/builtin/options-positioning/pane.tsx +22 -1
- package/src/plugins/builtin/options-scenario/client.ts +49 -8
- package/src/plugins/builtin/options-scenario/headless.ts +7 -3
- package/src/plugins/builtin/options-scenario/model.ts +33 -2
- package/src/plugins/builtin/options-scenario/pane.tsx +3 -4
- package/src/plugins/builtin/perps/cascade.ts +4 -3
- package/src/plugins/builtin/perps/markets-section.tsx +5 -2
- package/src/plugins/builtin/perps/model.ts +4 -3
- package/src/plugins/builtin/portfolio-list/table.tsx +3 -2
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +29 -14
- package/src/plugins/builtin/research/event-model.ts +12 -6
- package/src/plugins/builtin/research-search/index.tsx +3 -1
- package/src/plugins/builtin/scanner/denied.tsx +16 -4
- package/src/plugins/builtin/scanner/flow-pane.tsx +1 -1
- package/src/plugins/builtin/scanner/hilo-pane.tsx +1 -1
- package/src/plugins/builtin/sec/filing-display.tsx +14 -2
- package/src/plugins/builtin/sec/headless.ts +42 -4
- package/src/plugins/builtin/sec/index.tsx +21 -1
- package/src/plugins/builtin/sectors/sector-model.ts +1 -1
- package/src/plugins/builtin/shared/earnings-report.ts +32 -3
- package/src/plugins/builtin/shared/options-pro-copy.ts +34 -0
- package/src/plugins/builtin/shared/statement-currency.ts +23 -0
- package/src/plugins/builtin/shared/ticker-surface.ts +1 -1
- package/src/plugins/builtin/supply-chain/pane.tsx +4 -3
- package/src/plugins/builtin/themes/headless.ts +4 -4
- package/src/plugins/builtin/themes/model.ts +11 -8
- package/src/plugins/builtin/themes/pane.tsx +2 -2
- package/src/plugins/builtin/ticker-detail/financials/model.ts +22 -32
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +7 -9
- package/src/plugins/builtin/ticker-detail/headless-schema.ts +2 -0
- package/src/plugins/builtin/ticker-detail/headless.ts +28 -12
- package/src/plugins/builtin/ticker-detail/overview/board-lot.ts +21 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +11 -1
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +4 -0
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +61 -13
- package/src/plugins/builtin/volatility/pane.tsx +3 -3
- package/src/plugins/builtin/world-venue-map/headless.ts +4 -2
- package/src/plugins/builtin/world-venue-map/model.ts +6 -1
- package/src/plugins/builtin/world-venue-map/venue-header.tsx +5 -3
- package/src/plugins/catalog-browser.ts +10 -1
- package/src/renderers/browser/activity.ts +16 -0
- package/src/renderers/browser/app-badge-host.ts +14 -0
- package/src/renderers/browser/main.tsx +5 -0
- package/src/renderers/browser/notifications.ts +103 -0
- package/src/renderers/browser/ui-host.tsx +4 -0
- package/src/renderers/dom/data-table/index.tsx +27 -4
- package/src/renderers/electrobun/view/http-fetch.ts +3 -2
- package/src/sources/gloomberb-cloud/index.ts +8 -6
- package/src/sources/gloomberb-cloud/news.ts +35 -0
- package/src/sources/provider-errors.ts +34 -7
- package/src/sources/provider-router/history.ts +32 -6
- package/src/time-series/base-series.ts +39 -6
- package/src/time-series/chart-seed.ts +2 -2
- package/src/time-series/history-quality.ts +4 -1
- package/src/time-series/hooks.ts +2 -0
- package/src/time-series/price-comparison.ts +17 -23
- package/src/time-series/reporting.ts +1 -1
- package/src/time-series/resolution.ts +13 -0
- package/src/time-series/resolve-context.ts +6 -0
- package/src/time-series/resolve.ts +39 -2
- package/src/time-series/types.ts +2 -1
- package/src/types/financials.ts +9 -1
- package/src/types/headless.ts +1 -0
- package/src/types/issuer-listings.ts +2 -0
- package/src/types/plugin-notifications.ts +3 -0
- package/src/types/price-history.ts +6 -4
- package/src/ui/host.tsx +2 -0
- package/src/utils/exchange-announcements.ts +7 -2
- package/src/utils/fundamentals.ts +40 -0
- package/src/utils/network-failure.ts +2 -0
- package/src/utils/price-history-integrity.ts +9 -1
|
@@ -28,6 +28,12 @@ const LISTING_NUMBER_QUERY = /^\d{3,6}$/;
|
|
|
28
28
|
/** Written the way Singapore codes them, letters and digits in capitals: D05, C6L, A17U. */
|
|
29
29
|
const LISTING_CODE_QUERY = /^(?=[A-Z0-9]*\d)(?=[A-Z0-9]*[A-Z])[A-Z0-9]{3,4}$/;
|
|
30
30
|
|
|
31
|
+
/** A ticker written as one, in capitals (BA, BRK.B, 0700, D05, GC=F, ^GSPC): what the resolver reads as typed. */
|
|
32
|
+
export function writtenAsSymbol(text: string): boolean {
|
|
33
|
+
const trimmed = text.trim();
|
|
34
|
+
return trimmed === trimmed.toUpperCase() && /^\^?[A-Z0-9][A-Z0-9=.\-/]*$/.test(trimmed);
|
|
35
|
+
}
|
|
36
|
+
|
|
31
37
|
/**
|
|
32
38
|
* Text that asks for a symbol rather than a local row: symbol-shaped, and in
|
|
33
39
|
* capitals or in no row's name, or a listing's number or code. `nvda` matches
|
|
@@ -355,9 +361,11 @@ export function useCommandBarRootRuntime({
|
|
|
355
361
|
// letters match locally (a pane whose example names AAPL), not the symbol,
|
|
356
362
|
// so none of them is highlighted and Enter waits for the answer, as it would
|
|
357
363
|
// get had the symbol been typed slowly. Lower case found in a row's name
|
|
358
|
-
// (`upd`, `list`) is that row and runs at once.
|
|
359
|
-
|
|
360
|
-
|
|
364
|
+
// (`upd`, `list`) is that row and runs at once. DES's rows before its answer
|
|
365
|
+
// are saved tickers the letters match (`DES BA:LSE` finds Berkshire's BRK.B),
|
|
366
|
+
// never the listing typed: none is highlighted, and Enter runs the text.
|
|
367
|
+
const rootSymbolAnswerPending = !rootResultsCurrent && (rootSecurityDescriptionArg !== null || (rootPlainTickerSearchArg !== null
|
|
368
|
+
&& (rootTickerReading !== null || rootListingChoice !== null || readsAsSymbol(rootPlainTickerSearchArg, answeredRootResults))));
|
|
361
369
|
// Nor does the AI hold a place for itself meanwhile: its Thinking row would
|
|
362
370
|
// lead the list until the symbol's rows came in above it.
|
|
363
371
|
const orderedRootResults = useMemo(
|
|
@@ -436,6 +436,11 @@ function venueMatchesSuffix(item: ResultItem, suffix: string): boolean {
|
|
|
436
436
|
return targets.some((value) => venues.includes(canonicalExchange(value)));
|
|
437
437
|
}
|
|
438
438
|
|
|
439
|
+
/** Whether a row is the listing typed with its venue: BAE Systems' BA on LSE for `BA:LSE`, never Boeing's BA on NYSE. */
|
|
440
|
+
export function isNamedListingRow(item: ResultItem, listing: { symbol: string; suffix: string }): boolean {
|
|
441
|
+
return isExactTickerResultMatch(item, listing.symbol) && venueMatchesSuffix(item, listing.suffix);
|
|
442
|
+
}
|
|
443
|
+
|
|
439
444
|
/** On the currency venue a pair's code is the pair: EURUSD's CCY row is EURUSD=X. */
|
|
440
445
|
function isCurrencyVenuePair(item: ResultItem, symbol: string): boolean {
|
|
441
446
|
const pair = currencyPairCode(symbol, "CCY");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { useCallback, useEffect, useRef, type MutableRefObject } from "react";
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, type MutableRefObject } from "react";
|
|
2
2
|
import type { AppState } from "../../state/app/context";
|
|
3
3
|
import type { TickerRecord } from "../../types/ticker";
|
|
4
4
|
import { t } from "../../i18n";
|
|
5
|
-
import { listingChoiceQuery } from "../../tickers/search";
|
|
5
|
+
import { listingChoiceQuery, normalizeTickerInput } from "../../tickers/search";
|
|
6
6
|
import { isKnownExchangeCode } from "../../utils/exchanges";
|
|
7
7
|
import type { PluginRegistry } from "../../plugins/registry";
|
|
8
8
|
import type { Command } from "./commands/registry";
|
|
@@ -24,6 +24,8 @@ import type { OpenInlineConfirm } from "./routing/confirm";
|
|
|
24
24
|
import { activatePickerSelectionAction } from "./picker-activation";
|
|
25
25
|
import type { RunRootRow } from "./routes/root/search-report";
|
|
26
26
|
import type { ShortcutIntent } from "./routes/root/shortcuts";
|
|
27
|
+
import { isNamedListingRow } from "./routes/ticker-search/results";
|
|
28
|
+
import { writtenAsSymbol } from "./routes/root/runtime";
|
|
27
29
|
|
|
28
30
|
type OpenModeRouteFn = (
|
|
29
31
|
screen: "ticker-search" | "layout",
|
|
@@ -180,6 +182,15 @@ export function useCommandBarSelectionRuntime({
|
|
|
180
182
|
startThemePicker,
|
|
181
183
|
]);
|
|
182
184
|
|
|
185
|
+
/**
|
|
186
|
+
* The typed ticker command Enter runs while no row is highlighted (DES
|
|
187
|
+
* before its search answers), so the prompt names its keys as a ticker row's.
|
|
188
|
+
*/
|
|
189
|
+
const typedTickerRow = useMemo(() => (
|
|
190
|
+
!currentRoute && rootShortcutIntent.kind !== "none" && rootShortcutIntent.argKind === "ticker"
|
|
191
|
+
? resolveImmediateRootSelection(rootQuery) : null
|
|
192
|
+
), [currentRoute, resolveImmediateRootSelection, rootQuery, rootShortcutIntent]);
|
|
193
|
+
|
|
183
194
|
/**
|
|
184
195
|
* Tab on a typed shortcut: it completes the prefix, or opens what the
|
|
185
196
|
* shortcut starts (a ticker search in the bar, a pane form in the form
|
|
@@ -301,13 +312,25 @@ export function useCommandBarSelectionRuntime({
|
|
|
301
312
|
const queryChanged = rootQueryRef.current !== rootQuery;
|
|
302
313
|
const tickerArgument = rootShortcutIntent.kind !== "none" && rootShortcutIntent.argKind === "ticker"
|
|
303
314
|
? rootShortcutIntent.argText : null;
|
|
304
|
-
|
|
315
|
+
// `DES BA LN` names its listing as `DES BA:LSE` does.
|
|
316
|
+
const listingQuery = listingChoiceQuery((tickerArgument === null ? null : normalizeTickerInput(null, tickerArgument)) ?? rootQueryRef.current);
|
|
305
317
|
const choosingVenue = listingQuery && !isKnownExchangeCode(listingQuery.suffix);
|
|
306
318
|
const highlighted = listState.results[listState.selectedIdx];
|
|
307
|
-
|
|
319
|
+
// A function given a listing with its venue opens that listing: a row the
|
|
320
|
+
// user did not pick (a saved BRK.B the letters match, Boeing's BA on NYSE)
|
|
321
|
+
// runs only when it is that listing, and the typed text runs otherwise.
|
|
322
|
+
const namedListing = tickerArgument !== null && listingQuery && !choosingVenue ? listingQuery : null;
|
|
323
|
+
const otherListingHighlighted = !!namedListing && !!highlighted && !rootSelectionNavigatedRef.current
|
|
324
|
+
&& !isNamedListingRow(highlighted, namedListing);
|
|
325
|
+
const listingHighlighted = !queryChanged && !otherListingHighlighted
|
|
326
|
+
&& (highlighted?.kind === "ticker" || highlighted?.kind === "search");
|
|
308
327
|
const submitTyped = !options?.item && !currentRoute && !listingHighlighted
|
|
309
328
|
&& (queryChanged || (!rootSelectionNavigatedRef.current && !choosingVenue));
|
|
310
|
-
|
|
329
|
+
// A name (`DES Microsoft`, `DES nvda`) is search's to read, not the
|
|
330
|
+
// resolver's: before the answer, Enter waits for it.
|
|
331
|
+
const nameAwaitingAnswer = searchPending && !queryChanged && tickerArgument !== null && !namedListing
|
|
332
|
+
&& !writtenAsSymbol(tickerArgument);
|
|
333
|
+
const typed = submitTyped && !nameAwaitingAnswer && (queryChanged || tickerArgument !== null)
|
|
311
334
|
? resolveImmediateRootSelection(rootQueryRef.current) : null;
|
|
312
335
|
const selected = options?.item ?? typed ?? listState.results[listState.selectedIdx];
|
|
313
336
|
if (!selected) {
|
|
@@ -439,5 +462,6 @@ export function useCommandBarSelectionRuntime({
|
|
|
439
462
|
activateListSelection,
|
|
440
463
|
runRootQuery,
|
|
441
464
|
setActiveListQuery,
|
|
465
|
+
typedTickerRow,
|
|
442
466
|
};
|
|
443
467
|
}
|
|
@@ -531,6 +531,7 @@ export function CommandBar({
|
|
|
531
531
|
activateListSelection,
|
|
532
532
|
runRootQuery,
|
|
533
533
|
setActiveListQuery,
|
|
534
|
+
typedTickerRow,
|
|
534
535
|
} = useCommandBarSelectionRuntime({
|
|
535
536
|
activeTickerSymbol,
|
|
536
537
|
promptTickerSymbol,
|
|
@@ -682,7 +683,9 @@ export function CommandBar({
|
|
|
682
683
|
const addingListing = !currentRoute && state.commandBarLaunchRequest?.kind === "add-listing" && !!listingChoiceQuery(rootQuery);
|
|
683
684
|
const plainTickerSearch = currentRoute?.kind === "mode" && currentRoute.screen === "ticker-search" && !currentRoute.payload?.action;
|
|
684
685
|
const enterChangesFocusedPane = !!resolveTickerEnterTarget(state.config.layout, state.focusedPaneId, pluginRegistry.panes, "des");
|
|
685
|
-
|
|
686
|
+
// Nothing is highlighted while DES's search is out, and Enter runs the ticker typed.
|
|
687
|
+
const selectedRow = visibleListState?.results[visibleListState.selectedIdx]
|
|
688
|
+
?? (visibleListState?.kind === "root" ? typedTickerRow : null);
|
|
686
689
|
const selectionKeyHints = themePickerActive || addingListing || plainTickerSearch
|
|
687
690
|
? null
|
|
688
691
|
: resolveSelectionKeyHints(selectedRow, enterChangesFocusedPane);
|
|
@@ -54,13 +54,21 @@ function summarizeAlertWorkflowQuoteError(symbol: string, error: unknown): strin
|
|
|
54
54
|
/** How long typing rests before the symbol is read: a company's name is a search, not one quote. */
|
|
55
55
|
const ALERT_WORKFLOW_READ_DELAY_MS = 250;
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* The fields with their lines under Symbol and Target Price. A pane that fills
|
|
59
|
+
* the form in can add its own line under Target Price (`priceNote` in its
|
|
60
|
+
* values: GEX's flip alert says the level is fixed), kept below the price's.
|
|
61
|
+
*/
|
|
57
62
|
function updateAlertWorkflowFieldDescriptions(
|
|
58
63
|
fields: CommandBarWorkflowField[],
|
|
59
64
|
descriptions: Partial<Record<"symbol" | "price", string | undefined>>,
|
|
65
|
+
values: Record<string, CommandBarFieldValue>,
|
|
60
66
|
): CommandBarWorkflowField[] {
|
|
67
|
+
const priceNote = coerceFieldString(values.priceNote).trim();
|
|
61
68
|
return fields.map((field) => {
|
|
62
69
|
if (field.id !== "symbol" && field.id !== "price") return field;
|
|
63
|
-
const
|
|
70
|
+
const own = descriptions[field.id];
|
|
71
|
+
const description = field.id === "price" && priceNote ? [own, priceNote].filter(Boolean).join("\n") : own;
|
|
64
72
|
return field.description === description ? field : { ...field, description };
|
|
65
73
|
});
|
|
66
74
|
}
|
|
@@ -102,7 +110,7 @@ export function useAlertWorkflowQuoteSync({
|
|
|
102
110
|
fields: updateAlertWorkflowFieldDescriptions(route.fields, {
|
|
103
111
|
symbol: "Enter a symbol to validate it.",
|
|
104
112
|
price: "Target fills from the current price after the symbol resolves.",
|
|
105
|
-
}),
|
|
113
|
+
}, route.values),
|
|
106
114
|
payloadMeta: {
|
|
107
115
|
...(route.payloadMeta ?? {}),
|
|
108
116
|
alertQuoteSymbol: "",
|
|
@@ -121,7 +129,7 @@ export function useAlertWorkflowQuoteSync({
|
|
|
121
129
|
fields: updateAlertWorkflowFieldDescriptions(route.fields, {
|
|
122
130
|
symbol: tf("Checking {symbol}...", { symbol: alertWorkflowSymbol }),
|
|
123
131
|
price: "Target fills from the current price after the symbol resolves.",
|
|
124
|
-
}),
|
|
132
|
+
}, route.values),
|
|
125
133
|
payloadMeta: {
|
|
126
134
|
...(route.payloadMeta ?? {}),
|
|
127
135
|
alertQuoteSymbol: alertWorkflowSymbol,
|
|
@@ -158,7 +166,7 @@ export function useAlertWorkflowQuoteSync({
|
|
|
158
166
|
// What became of the symbol goes under its quote, which names the listing: FB is a fund now, and Meta trades as META.
|
|
159
167
|
symbol: [formatAlertWorkflowQuote(quote, print), ...fate].join("\n"),
|
|
160
168
|
price: tf("Current price {price}; edit to set the target.", { price: formatAlertWorkflowCurrentPrice(print) }),
|
|
161
|
-
}),
|
|
169
|
+
}, nextValues),
|
|
162
170
|
payloadMeta: {
|
|
163
171
|
...(route.payloadMeta ?? {}),
|
|
164
172
|
alertQuoteSymbol: alertWorkflowSymbol,
|
|
@@ -179,7 +187,7 @@ export function useAlertWorkflowQuoteSync({
|
|
|
179
187
|
fields: updateAlertWorkflowFieldDescriptions(route.fields, {
|
|
180
188
|
symbol: message,
|
|
181
189
|
price: undefined,
|
|
182
|
-
}),
|
|
190
|
+
}, route.values),
|
|
183
191
|
payloadMeta: {
|
|
184
192
|
...(route.payloadMeta ?? {}),
|
|
185
193
|
alertQuoteSymbol: alertWorkflowSymbol,
|
|
@@ -53,6 +53,13 @@ export interface PaneFooterSegment {
|
|
|
53
53
|
* warning.
|
|
54
54
|
*/
|
|
55
55
|
capture?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The pane's figures cannot be read without the segment: the session OMON's
|
|
58
|
+
* open interest counts are from. A row too narrow shortens it to its last
|
|
59
|
+
* variant and leaves out the segments around it first, as it does beside a
|
|
60
|
+
* warning, so it never goes while those figures show.
|
|
61
|
+
*/
|
|
62
|
+
holdsPlace?: boolean;
|
|
56
63
|
/**
|
|
57
64
|
* The notes behind a warning icon (usePaneNoticeFooter), each in full. The
|
|
58
65
|
* icon opens them in the app. A picture of the pane cannot, so it draws a
|
|
@@ -386,9 +393,9 @@ function stepDownTogether(info: PaneFooterSegment[], width: number): PaneFooterS
|
|
|
386
393
|
return fitted;
|
|
387
394
|
}
|
|
388
395
|
|
|
389
|
-
/** A warning, an icon
|
|
396
|
+
/** A warning, an icon, a pressable segment or one marked `holdsPlace`, which a row too narrow never cuts or leaves out. */
|
|
390
397
|
function holdsItsPlace(segment: PaneFooterSegment): boolean {
|
|
391
|
-
return !!segment.icon || !!segment.onPress || segment.parts.some((part) => part.tone === "warning" || part.tone === "negative");
|
|
398
|
+
return !!segment.icon || !!segment.onPress || !!segment.holdsPlace || segment.parts.some((part) => part.tone === "warning" || part.tone === "negative");
|
|
392
399
|
}
|
|
393
400
|
|
|
394
401
|
/**
|
|
@@ -778,6 +785,7 @@ export function samePaneFooterRegistration(
|
|
|
778
785
|
&& segment.disabled === other.disabled
|
|
779
786
|
&& segment.savedCopyAt === other.savedCopyAt
|
|
780
787
|
&& segment.age === other.age
|
|
788
|
+
&& !!segment.capture === !!other.capture && !!segment.holdsPlace === !!other.holdsPlace
|
|
781
789
|
// The icon reads the same whatever its notes say; a picture of the pane prints them.
|
|
782
790
|
&& (segment.notes ?? []).length === (other.notes ?? []).length
|
|
783
791
|
&& (segment.notes ?? []).every((note, noteIndex) => note === other.notes![noteIndex])
|
|
@@ -4,6 +4,7 @@ import type { CompanyFrom } from "../../../types/company-from";
|
|
|
4
4
|
import { useAppLanguage } from "../../../i18n/react";
|
|
5
5
|
import { useExternalLinkFooter } from "../../use-external-link-footer";
|
|
6
6
|
import { loadingErrorFooterInfo } from "../../data-table/table-pane";
|
|
7
|
+
import { useRemoteUiNode } from "../../../remote/semantic-tree";
|
|
7
8
|
|
|
8
9
|
const EMPTY_STATUS_INFO: PaneFooterSegment[] = [];
|
|
9
10
|
|
|
@@ -64,16 +65,33 @@ export function useCompanyDataFooter(companyFrom: CompanyFrom | null | undefined
|
|
|
64
65
|
);
|
|
65
66
|
}
|
|
66
67
|
|
|
68
|
+
/**
|
|
69
|
+
* A load that failed, published for the pane's report (`gloom fn`): the
|
|
70
|
+
* footer says it in the app, and a report of a pane with nothing else to
|
|
71
|
+
* show fails with it, as the plain commands do, instead of reading back the
|
|
72
|
+
* empty body ("No events") as the data and dating it (`pane-load-error`).
|
|
73
|
+
*/
|
|
74
|
+
function usePaneLoadErrorNode(loading: boolean, error: string | null | undefined, enabled = true) {
|
|
75
|
+
const message = !loading && enabled ? error?.trim() ?? "" : "";
|
|
76
|
+
useRemoteUiNode(message ? {
|
|
77
|
+
role: "pane-load-error",
|
|
78
|
+
label: "Load failed",
|
|
79
|
+
getMetadata: () => ({ message }),
|
|
80
|
+
} : null);
|
|
81
|
+
}
|
|
82
|
+
|
|
67
83
|
export function usePaneStatusFooter({
|
|
68
84
|
registrationId,
|
|
69
85
|
loading = false,
|
|
70
86
|
error,
|
|
87
|
+
emptyResult = false,
|
|
71
88
|
stale = false,
|
|
72
89
|
info = EMPTY_STATUS_INFO,
|
|
73
90
|
hints,
|
|
74
91
|
enabled = true,
|
|
75
92
|
}: PaneStatusInfoOptions & {
|
|
76
93
|
registrationId: string;
|
|
94
|
+
emptyResult?: boolean;
|
|
77
95
|
hints?: PaneHint[];
|
|
78
96
|
enabled?: boolean;
|
|
79
97
|
}) {
|
|
@@ -81,6 +99,11 @@ export function usePaneStatusFooter({
|
|
|
81
99
|
() => buildPaneStatusInfo({ loading, error, stale, info }),
|
|
82
100
|
[error, info, loading, stale],
|
|
83
101
|
);
|
|
102
|
+
usePaneLoadErrorNode(loading, error, enabled);
|
|
103
|
+
useRemoteUiNode(enabled && emptyResult && !loading && !error ? {
|
|
104
|
+
role: "pane-empty-result",
|
|
105
|
+
label: "No results",
|
|
106
|
+
} : null);
|
|
84
107
|
usePaneFooter(
|
|
85
108
|
registrationId,
|
|
86
109
|
() => enabled && (statusInfo.length > 0 || (hints?.length ?? 0) > 0)
|
|
@@ -115,6 +138,7 @@ export function usePaneStatusLinkFooter({
|
|
|
115
138
|
() => buildPaneStatusInfo({ loading, error, stale, info }),
|
|
116
139
|
[error, info, loading, stale],
|
|
117
140
|
);
|
|
141
|
+
usePaneLoadErrorNode(loading, error);
|
|
118
142
|
return useExternalLinkFooter({
|
|
119
143
|
registrationId,
|
|
120
144
|
focused,
|
|
@@ -21,6 +21,22 @@ function hasAnyReturn(fields: readonly PriceReturnField[]): boolean {
|
|
|
21
21
|
interface ReturnPair {
|
|
22
22
|
field: PriceReturnField;
|
|
23
23
|
value: string;
|
|
24
|
+
/** `from 17 Oct`: the day of the close the return is measured from. */
|
|
25
|
+
base: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] as const;
|
|
29
|
+
|
|
30
|
+
/** `from 17 Oct`, with the year when it is not this one's: `from 17 Nov 2025`. Empty without a base. */
|
|
31
|
+
function priceReturnBaseText(day: string | undefined, now = Date.now()): string {
|
|
32
|
+
const date = day ? new Date(`${day.slice(0, 10)}T00:00:00Z`) : null;
|
|
33
|
+
if (!date || !Number.isFinite(date.getTime())) return "";
|
|
34
|
+
const year = date.getUTCFullYear() === new Date(now).getUTCFullYear() ? "" : ` ${date.getUTCFullYear()}`;
|
|
35
|
+
return `from ${date.getUTCDate()} ${MONTHS[date.getUTCMonth()]}${year}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function pairWidth(pair: ReturnPair): number {
|
|
39
|
+
return displayWidth(pair.field.label) + 1 + displayWidth(pair.value) + (pair.base ? 1 + displayWidth(pair.base) : 0);
|
|
24
40
|
}
|
|
25
41
|
|
|
26
42
|
/** Pairs fill a row left to right and wrap whole, never splitting a label from its value. */
|
|
@@ -28,20 +44,20 @@ function packPairs(pairs: readonly ReturnPair[], width: number): ReturnPair[][]
|
|
|
28
44
|
const rows: ReturnPair[][] = [];
|
|
29
45
|
let rowWidth = 0;
|
|
30
46
|
for (const pair of pairs) {
|
|
31
|
-
const
|
|
47
|
+
const cells = pairWidth(pair);
|
|
32
48
|
const row = rows.at(-1);
|
|
33
|
-
if (row && rowWidth + PAIR_GAP +
|
|
49
|
+
if (row && rowWidth + PAIR_GAP + cells <= width) {
|
|
34
50
|
row.push(pair);
|
|
35
|
-
rowWidth += PAIR_GAP +
|
|
51
|
+
rowWidth += PAIR_GAP + cells;
|
|
36
52
|
} else {
|
|
37
53
|
rows.push([pair]);
|
|
38
|
-
rowWidth =
|
|
54
|
+
rowWidth = cells;
|
|
39
55
|
}
|
|
40
56
|
}
|
|
41
57
|
return rows;
|
|
42
58
|
}
|
|
43
59
|
|
|
44
|
-
/** Each horizon's label with its return beside it: `1M +3.29% 3M +6.99
|
|
60
|
+
/** Each horizon's label with its return and the close it runs from beside it: `1M +3.29% from 17 Oct 3M +6.99% from 17 Aug`. */
|
|
45
61
|
export function PriceReturnStrip({
|
|
46
62
|
fields,
|
|
47
63
|
width,
|
|
@@ -51,16 +67,17 @@ export function PriceReturnStrip({
|
|
|
51
67
|
}) {
|
|
52
68
|
const { nativePaneChrome } = useUiCapabilities();
|
|
53
69
|
if (!hasAnyReturn(fields)) return null;
|
|
54
|
-
const pairs = fields.map((field) => ({ field, value: formatReturnValue(field.value) }));
|
|
70
|
+
const pairs = fields.map((field) => ({ field, value: formatReturnValue(field.value), base: field.value == null ? "" : priceReturnBaseText(field.baseDay) }));
|
|
55
71
|
if (nativePaneChrome) {
|
|
56
72
|
// The desktop and the web wrap the pairs where the pane's own edge is, whole, so a resize re-wraps them
|
|
57
73
|
// on every frame instead of in the steps of the cells the terminal counts.
|
|
58
74
|
return (
|
|
59
75
|
<Box flexDirection="row" flexWrap="wrap" columnGap={PAIR_GAP} data-gloom-role="price-return-strip">
|
|
60
|
-
{pairs.map(({ field, value }) => (
|
|
76
|
+
{pairs.map(({ field, value, base }) => (
|
|
61
77
|
<Box key={field.id} flexDirection="row" gap={1} flexShrink={0}>
|
|
62
78
|
<Text fg={colors.textDim}>{field.label}</Text>
|
|
63
79
|
<Text fg={returnValueColor(field.value)}>{value}</Text>
|
|
80
|
+
{base ? <Text fg={colors.textMuted}>{base}</Text> : null}
|
|
64
81
|
</Box>
|
|
65
82
|
))}
|
|
66
83
|
</Box>
|
|
@@ -72,10 +89,11 @@ export function PriceReturnStrip({
|
|
|
72
89
|
<Box flexDirection="column" width={width}>
|
|
73
90
|
{rows.map((row, rowIndex) => (
|
|
74
91
|
<Box key={rowIndex} flexDirection="row" height={1} gap={PAIR_GAP} overflow="hidden">
|
|
75
|
-
{row.map(({ field, value }) => (
|
|
92
|
+
{row.map(({ field, value, base }) => (
|
|
76
93
|
<Box key={field.id} flexDirection="row" gap={1} flexShrink={0}>
|
|
77
94
|
<Text fg={colors.textDim}>{field.label}</Text>
|
|
78
95
|
<Text fg={returnValueColor(field.value)}>{value}</Text>
|
|
96
|
+
{base ? <Text fg={colors.textMuted}>{base}</Text> : null}
|
|
79
97
|
</Box>
|
|
80
98
|
))}
|
|
81
99
|
</Box>
|
|
@@ -65,6 +65,12 @@ export interface ArticleReaderProps {
|
|
|
65
65
|
height: number;
|
|
66
66
|
onNext?: (() => void) | null;
|
|
67
67
|
onPrevious?: (() => void) | null;
|
|
68
|
+
/**
|
|
69
|
+
* Labelled parts after the text and before `children`, each under its own
|
|
70
|
+
* label as `children` is under `childrenLabel`: a story's filings before its
|
|
71
|
+
* coverage. Empty parts are left out.
|
|
72
|
+
*/
|
|
73
|
+
sections?: ReadonlyArray<{ label: string; content: ReactNode }>;
|
|
68
74
|
/** After the text, such as a story's coverage by other outlets, under `childrenLabel`. */
|
|
69
75
|
children?: ReactNode;
|
|
70
76
|
childrenLabel?: string;
|
|
@@ -192,6 +198,7 @@ function ArticleReaderView({
|
|
|
192
198
|
height,
|
|
193
199
|
onNext,
|
|
194
200
|
onPrevious,
|
|
201
|
+
sections = [],
|
|
195
202
|
children,
|
|
196
203
|
childrenLabel,
|
|
197
204
|
}: ArticleReaderProps) {
|
|
@@ -402,14 +409,14 @@ function ArticleReaderView({
|
|
|
402
409
|
</ActionRow>
|
|
403
410
|
</Box>
|
|
404
411
|
) : null}
|
|
405
|
-
{children ? (
|
|
406
|
-
<Box flexDirection="column" style={desktop ? { marginTop: !
|
|
407
|
-
{
|
|
412
|
+
{[...sections.filter((section) => section.content), ...(children ? [{ label: childrenLabel, content: children }] : [])].map((section, index) => (
|
|
413
|
+
<Box key={`${section.label ?? ""}:${index}`} flexDirection="column" style={desktop ? { marginTop: !section.label && (lead || blocks.length > 0) ? "0.8em" : 0 } : undefined}>
|
|
414
|
+
{section.label ? <ReaderText text={readerLabel(section.label)} geometry={geometry} color={labelColor} variant="label" /> : null}
|
|
408
415
|
<Box flexDirection="column" style={desktop ? { fontSize: READER_APP_FONT, lineHeight: "normal" } : undefined}>
|
|
409
|
-
{
|
|
416
|
+
{section.content}
|
|
410
417
|
</Box>
|
|
411
418
|
</Box>
|
|
412
|
-
)
|
|
419
|
+
))}
|
|
413
420
|
</Box>
|
|
414
421
|
);
|
|
415
422
|
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
tableColumnWidth,
|
|
21
21
|
fitTableHeaderText,
|
|
22
22
|
getTableWidth,
|
|
23
|
+
hiddenTableColumnText,
|
|
23
24
|
hasMeaningfulTableHorizontalOverflow,
|
|
24
25
|
tableColumnLeadGap,
|
|
25
26
|
tableColumnStarts,
|
|
@@ -647,6 +648,7 @@ export function OpenTuiDataTable<T, C extends DataTableColumn = DataTableColumn>
|
|
|
647
648
|
viewportWidth: measuredViewportWidth,
|
|
648
649
|
}) : null;
|
|
649
650
|
const moreColumnsReserve = moreColumns?.reserve ?? 0;
|
|
651
|
+
const hiddenColumns = items.length ? hiddenTableColumnText(columns) : null;
|
|
650
652
|
// A scroll step that cuts the columns as the last one did keeps the same
|
|
651
653
|
// array, so the memoized rows skip the render.
|
|
652
654
|
const columnClipsRef = useRef<readonly (DataTableColumnClip | null)[] | null>(null);
|
|
@@ -984,6 +986,11 @@ export function OpenTuiDataTable<T, C extends DataTableColumn = DataTableColumn>
|
|
|
984
986
|
<Text fg={colors.textDim}>{moreColumns.text}</Text>
|
|
985
987
|
</Box>
|
|
986
988
|
) : null}
|
|
989
|
+
{hiddenColumns ? (
|
|
990
|
+
<Box height={1} paddingX={horizontalPadding} backgroundColor={colors.panel}>
|
|
991
|
+
<Text fg={colors.textDim}>{hiddenColumns}</Text>
|
|
992
|
+
</Box>
|
|
993
|
+
) : null}
|
|
987
994
|
|
|
988
995
|
<ScrollBox
|
|
989
996
|
id={bodyScrollId}
|
|
@@ -10,6 +10,37 @@ export interface TableWidthColumn {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const TRAILING_COLUMN_GUTTER_WIDTH = 1;
|
|
13
|
+
const HIDDEN_COLUMNS = Symbol("hidden table columns");
|
|
14
|
+
type HiddenColumn = { id: string; label: string };
|
|
15
|
+
type WithHiddenColumns = { [HIDDEN_COLUMNS]?: readonly HiddenColumn[] };
|
|
16
|
+
|
|
17
|
+
function hiddenColumnEntries(columns: readonly TableWidthColumn[]): HiddenColumn[] {
|
|
18
|
+
return [...new Map(columns.flatMap((column: TableWidthColumn & WithHiddenColumns) => column[HIDDEN_COLUMNS] ?? [])
|
|
19
|
+
.map((column) => [column.id, column])).values()];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function hiddenTableColumns(columns: readonly TableWidthColumn[]): string[] {
|
|
23
|
+
return hiddenColumnEntries(columns).map(({ label }) => label);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function hiddenTableColumnRows(columns: readonly TableWidthColumn[], itemCount: number): number {
|
|
27
|
+
return itemCount > 0 && columns.some((column: TableWidthColumn & WithHiddenColumns) => column[HIDDEN_COLUMNS]?.length) ? 1 : 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function hiddenTableColumnText(columns: readonly TableWidthColumn[]): string | null {
|
|
31
|
+
const hidden = hiddenTableColumns(columns);
|
|
32
|
+
if (!hidden.length) return null;
|
|
33
|
+
const labels = new Map<string, number>();
|
|
34
|
+
for (const label of hidden) labels.set(label, (labels.get(label) ?? 0) + 1);
|
|
35
|
+
return `${hidden.length} hidden · ${[...labels].map(([label, count]) => count > 1 ? `${label} ×${count}` : label).join(", ")}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function markHiddenTableColumns<C extends TableWidthColumn & { id: string }>(original: readonly C[], shown: C[]): C[] {
|
|
39
|
+
const hidden = [...hiddenColumnEntries(original), ...original.filter(({ id }) => !shown.some((column) => column.id === id))
|
|
40
|
+
.map(({ id, label }) => ({ id, label: label?.trim() || id }))];
|
|
41
|
+
if (!shown[0] || !hidden.length) return shown;
|
|
42
|
+
return [Object.assign({ ...shown[0] }, { [HIDDEN_COLUMNS]: hidden }), ...shown.slice(1)];
|
|
43
|
+
}
|
|
13
44
|
const WEB_CELL_UNIT = "var(--cell-w)";
|
|
14
45
|
|
|
15
46
|
/** Space the sort indicator (" \u25b2") needs on top of the header label. */
|
|
@@ -136,7 +167,7 @@ export function dropColumnsToFit<C extends TableWidthColumn & { id: string }>(
|
|
|
136
167
|
const ids = typeof step === "string" ? [step] : step;
|
|
137
168
|
shown = shown.filter((column) => !ids.includes(column.id));
|
|
138
169
|
}
|
|
139
|
-
return shown;
|
|
170
|
+
return markHiddenTableColumns(columns, shown);
|
|
140
171
|
}
|
|
141
172
|
|
|
142
173
|
/**
|
|
@@ -51,6 +51,25 @@ export function ahListingKey(symbol: string, exchange?: string | null): string {
|
|
|
51
51
|
return listingKey({ symbol: suffixed?.symbol ?? parsed.symbol, exchange: canonicalExchange(parsed.exchange ?? suffixed?.exchange ?? exchange ?? "") });
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/** Venues whose own lists state a line's board lot, which the company universe serves with its listings. */
|
|
55
|
+
const BOARD_LOT_VENUES: ReadonlySet<string> = new Set(["HKEX", "SGX"]);
|
|
56
|
+
|
|
57
|
+
/** Whether a listing trades on a venue that states its board lot (`BOARD_LOT_VENUES`), so its company's listings are worth reading for it. */
|
|
58
|
+
export function statesBoardLot(symbol: string | null | undefined, exchange?: string | null): boolean {
|
|
59
|
+
return !!symbol && BOARD_LOT_VENUES.has(parsePublicTickerKey(ahListingKey(symbol, exchange)).exchange ?? "");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The shares one lot of a listing trades in, as its company's listings carry
|
|
64
|
+
* it: 500 for Zijin Mining's 2899:HKEX, 400 for HSBC's 0005:HKEX. Null where
|
|
65
|
+
* the listing is not among them or its lot is not a positive whole number.
|
|
66
|
+
*/
|
|
67
|
+
export function listingBoardLot(issuer: Pick<IssuerListings, "listings"> | null | undefined, symbol: string, exchange?: string | null): number | null {
|
|
68
|
+
const key = ahListingKey(symbol, exchange);
|
|
69
|
+
const lot = issuer?.listings.find((line) => listingKey(line) === key)?.boardLot;
|
|
70
|
+
return typeof lot === "number" && Number.isSafeInteger(lot) && lot > 0 ? lot : null;
|
|
71
|
+
}
|
|
72
|
+
|
|
54
73
|
/** Which line of the pair a listing is (`ahListingKey`); null for neither. */
|
|
55
74
|
export function ahPairSide(pair: AhPair, symbol: string, exchange?: string | null): "h" | "a" | null {
|
|
56
75
|
const key = ahListingKey(symbol, exchange);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { hasUsablePriceHistory } from "../../utils/price-history";
|
|
2
2
|
import { isTransientFailure } from "../../api-client/errors";
|
|
3
|
+
import { isTransientSourceFailure } from "../../sources/provider-errors";
|
|
3
4
|
import type { PricePoint, Quote, TickerFinancials } from "../../types/financials";
|
|
4
5
|
import { hasFreshQuoteForCurrentSession, isQuoteStaleForCurrentSession } from "../quotes/freshness";
|
|
5
6
|
import type { InstrumentRef } from "../request-types";
|
|
@@ -20,7 +21,7 @@ export const FX_CACHE_TTL_MS = 30 * 60_000;
|
|
|
20
21
|
|
|
21
22
|
export function classifyError(error: unknown): { reasonCode: ProviderReasonCode; message: string } {
|
|
22
23
|
const message = error instanceof Error ? error.message : String(error ?? "");
|
|
23
|
-
if (/timeout/i.test(message)) return { reasonCode: "TIMEOUT", message };
|
|
24
|
+
if (/timeout|timed out/i.test(message)) return { reasonCode: "TIMEOUT", message };
|
|
24
25
|
if (/unsupported/i.test(message)) return { reasonCode: "UNSUPPORTED_RANGE", message };
|
|
25
26
|
if (/mapping|symbol/i.test(message)) return { reasonCode: "BAD_MAPPING", message };
|
|
26
27
|
if (/not found|no data|unavailable|delisted/i.test(message)) return { reasonCode: "NOT_FOUND", message };
|
|
@@ -30,11 +31,12 @@ export function classifyError(error: unknown): { reasonCode: ProviderReasonCode;
|
|
|
30
31
|
/**
|
|
31
32
|
* How a load that threw is recorded: `retryable_error` for a failure asking
|
|
32
33
|
* again may get past (no connection, a timeout, 429, a 5xx:
|
|
33
|
-
* `isTransientFailure`),
|
|
34
|
-
* (`
|
|
34
|
+
* `isTransientFailure`), including the router's answer that no source served
|
|
35
|
+
* it because one timed out (`isTransientSourceFailure`), whose kept data is
|
|
36
|
+
* then a saved copy (`savedCopyEntryAt`), and `fatal_error` for any other.
|
|
35
37
|
*/
|
|
36
38
|
export function errorStatus(error: unknown): "retryable_error" | "fatal_error" {
|
|
37
|
-
return isTransientFailure(error) ? "retryable_error" : "fatal_error";
|
|
39
|
+
return isTransientFailure(error) || isTransientSourceFailure(error) ? "retryable_error" : "fatal_error";
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
/**
|
|
@@ -861,7 +861,9 @@ export class MarketDataCoordinator {
|
|
|
861
861
|
delayMinutes: result?.delayMinutes,
|
|
862
862
|
staleAt: result?.staleAt ?? null,
|
|
863
863
|
error: classified ?? (!loading && empty ? { reasonCode: "NO_DATA", message: "No data available" } : null),
|
|
864
|
-
|
|
864
|
+
// A read that failed with nothing to show records the failure too, so its entry says whether asking again may answer.
|
|
865
|
+
attempts: result ? [createAttempt(result.source, result.fetchedAt, error ? errorStatus(error) : empty ? "empty" : "success", classified?.reasonCode, classified?.message)]
|
|
866
|
+
: error ? [createAttempt(this.dataProvider.id, Date.now(), errorStatus(error), classified?.reasonCode, classified?.message)] : [],
|
|
865
867
|
});
|
|
866
868
|
};
|
|
867
869
|
const existing = this.cachedQueries.get(key);
|
|
@@ -1125,8 +1127,17 @@ export function resolveEntryValue<T>(entry: QueryEntry<T>): T | null {
|
|
|
1125
1127
|
*/
|
|
1126
1128
|
export function savedCopyEntryAt<T>(entry: QueryEntry<T> | null | undefined): number | null {
|
|
1127
1129
|
if (!entry?.error || entry.fetchedAt == null || !resolveEntryData(entry)) return null;
|
|
1130
|
+
return entryFailedTransiently(entry) ? entry.fetchedAt : null;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
/**
|
|
1134
|
+
* Whether `entry`'s last load failed for a reason asking again may get past:
|
|
1135
|
+
* no connection, a timeout, 429 or a 5xx (a `retryable_error` attempt), as
|
|
1136
|
+
* opposed to an answer that there is nothing or a refusal.
|
|
1137
|
+
*/
|
|
1138
|
+
export function entryFailedTransiently<T>(entry: QueryEntry<T> | null | undefined): boolean {
|
|
1139
|
+
if (!entry?.error) return false;
|
|
1128
1140
|
const { reasonCode, message } = entry.error;
|
|
1129
|
-
|
|
1141
|
+
return entry.attempts.at(-1)?.status === "retryable_error"
|
|
1130
1142
|
|| reasonCode === "TIMEOUT" || message === DATA_SERVICE_UNREACHABLE_MESSAGE || isNetworkFailure(message);
|
|
1131
|
-
return transient ? entry.fetchedAt : null;
|
|
1132
1143
|
}
|