gloomberb 0.7.4 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -6
- package/package.json +2 -3
- package/src/api-client/auth.ts +167 -0
- package/src/api-client/chat.ts +116 -0
- package/src/api-client/data.ts +177 -0
- package/src/api-client/errors.ts +28 -0
- package/src/api-client/index.test.ts +675 -0
- package/src/api-client/index.ts +384 -0
- package/src/api-client/normalizers.ts +61 -0
- package/src/api-client/paths.ts +173 -0
- package/src/api-client/request.ts +124 -0
- package/src/api-client/socket.ts +483 -0
- package/src/api-client/types.ts +490 -0
- package/src/app/app-bootstrap-state.test.ts +157 -0
- package/src/app/app-bootstrap-state.ts +134 -0
- package/src/app/global-shortcuts.test.tsx +166 -0
- package/src/app/global-shortcuts.ts +126 -0
- package/src/app/pane-runtime/index.tsx +297 -0
- package/src/app/pane-runtime/layout-placement.ts +73 -0
- package/src/app/pane-runtime/pane-settings-runtime.tsx +67 -0
- package/src/app/pane-runtime/pane-template-runtime.ts +110 -0
- package/src/app/pane-runtime/plugin-bindings.ts +231 -0
- package/src/app/pane-runtime/ticker-inspector-runtime.ts +167 -0
- package/src/app/pane-runtime/ticker-open-runtime.ts +144 -0
- package/src/app/pane-template-dialog-wizard.tsx +52 -0
- package/src/app/runtime/broker-import.ts +109 -0
- package/src/app/runtime/desktop-menu.ts +74 -0
- package/src/app/runtime/plugin-bindings.ts +246 -0
- package/src/app/runtime/startup.ts +126 -0
- package/src/app/runtime/ticker-refresh.ts +249 -0
- package/src/app/runtime/update.ts +86 -0
- package/src/app.tsx +110 -1461
- package/src/brokers/broker-portfolio-sync.ts +186 -0
- package/src/brokers/broker-ticker-sync.ts +141 -0
- package/src/brokers/profile-form.ts +2 -2
- package/src/brokers/remote-broker-adapter.ts +3 -2
- package/src/brokers/sync-broker-instance.test.ts +140 -0
- package/src/brokers/sync-broker-instance.ts +60 -181
- package/src/capabilities/types.ts +4 -4
- package/src/cli/commands/search.ts +1 -1
- package/src/cli/commands/ticker.ts +3 -3
- package/src/cli/context.ts +1 -1
- package/src/cli/desktop-pane-shot.ts +305 -0
- package/src/cli/helpers.ts +1 -1
- package/src/cli/index.ts +34 -0
- package/src/cli/pane-functions/catalog.ts +243 -0
- package/src/cli/pane-functions/data.ts +78 -0
- package/src/cli/pane-functions/discovery.ts +113 -0
- package/src/cli/pane-functions/index.test.ts +114 -0
- package/src/cli/pane-functions/index.ts +112 -0
- package/src/cli/pane-functions/options.ts +249 -0
- package/src/cli/pane-functions/report.ts +180 -0
- package/src/cli/pane-functions/resolver.ts +96 -0
- package/src/cli/pane-functions/screenshot.ts +113 -0
- package/src/cli/registry.ts +3 -2
- package/src/cli/ticker-resolution.ts +1 -1
- package/src/cli.test.ts +1 -1
- package/src/components/chart/bar-chart-renderer.test.ts +53 -0
- package/src/components/chart/bar-chart-renderer.ts +190 -0
- package/src/components/chart/comparison/data.test.ts +105 -0
- package/src/components/chart/comparison/data.ts +279 -0
- package/src/components/chart/comparison/renderer.test.ts +187 -0
- package/src/components/chart/comparison/renderer.ts +283 -0
- package/src/components/chart/comparison/scene.ts +178 -0
- package/src/components/chart/comparison-stock-chart/axis-width.ts +99 -0
- package/src/components/chart/comparison-stock-chart/canvas.ts +148 -0
- package/src/components/chart/comparison-stock-chart/controls.ts +252 -0
- package/src/components/chart/comparison-stock-chart/helpers.ts +133 -0
- package/src/components/chart/comparison-stock-chart/interactions.ts +202 -0
- package/src/components/chart/comparison-stock-chart/layout-metrics.ts +62 -0
- package/src/components/chart/comparison-stock-chart/layout.tsx +155 -0
- package/src/components/chart/comparison-stock-chart/legend.tsx +73 -0
- package/src/components/chart/comparison-stock-chart/native-surfaces.ts +89 -0
- package/src/components/chart/comparison-stock-chart/render-data.ts +198 -0
- package/src/components/chart/comparison-stock-chart/render-output.ts +145 -0
- package/src/components/chart/comparison-stock-chart/selection-runtime.ts +111 -0
- package/src/components/chart/comparison-stock-chart/sources.ts +47 -0
- package/src/components/chart/comparison-stock-chart/surface-runtime.ts +159 -0
- package/src/components/chart/comparison-stock-chart/toolbar.tsx +107 -0
- package/src/components/chart/comparison-stock-chart/types.ts +22 -0
- package/src/components/chart/comparison-stock-chart/view.tsx +524 -0
- package/src/components/chart/comparison-stock-chart/viewport-runtime.ts +239 -0
- package/src/components/chart/comparison-stock-chart.tsx +12 -2028
- package/src/components/chart/core/axis-format.ts +147 -0
- package/src/components/chart/core/axis-measure.ts +33 -0
- package/src/components/chart/core/controller.test.ts +157 -0
- package/src/components/chart/core/controller.ts +349 -0
- package/src/components/chart/core/data.ts +94 -0
- package/src/components/chart/core/date-window.ts +392 -0
- package/src/components/chart/core/index.test.ts +1007 -0
- package/src/components/chart/core/indicator-selector.tsx +75 -0
- package/src/components/chart/core/keyboard.ts +15 -0
- package/src/components/chart/core/palette.ts +60 -0
- package/src/components/chart/core/pane-settings.test.ts +25 -0
- package/src/components/chart/core/pane-settings.ts +82 -0
- package/src/components/chart/core/pointer.ts +292 -0
- package/src/components/chart/core/projection.ts +333 -0
- package/src/components/chart/core/render-utils.ts +4 -0
- package/src/components/chart/core/renderer.ts +249 -0
- package/src/components/chart/core/resolution.test.ts +99 -0
- package/src/components/chart/core/resolution.ts +380 -0
- package/src/components/chart/core/scene.ts +180 -0
- package/src/components/chart/core/scroll.test.ts +70 -0
- package/src/components/chart/core/scroll.ts +104 -0
- package/src/components/chart/core/time-axis.ts +330 -0
- package/src/components/chart/core/types.ts +124 -0
- package/src/components/chart/core/viewport.test.ts +29 -0
- package/src/components/chart/core/viewport.ts +51 -0
- package/src/components/chart/core/window-viewport.test.ts +69 -0
- package/src/components/chart/core/window-viewport.ts +162 -0
- package/src/components/chart/display-cursor.ts +153 -0
- package/src/components/chart/market-session.ts +1 -1
- package/src/components/chart/multi-line/renderer.test.ts +83 -0
- package/src/components/chart/multi-line/renderer.ts +160 -0
- package/src/components/chart/multi-line/scene.ts +188 -0
- package/src/components/chart/native/canvas-bitmaps.ts +140 -0
- package/src/components/chart/native/chart-rasterizer.ts +18 -865
- package/src/components/chart/native/kitty/adapter.ts +9 -0
- package/src/components/chart/native/kitty/index.test.ts +752 -0
- package/src/components/chart/native/kitty/manager.ts +142 -0
- package/src/components/chart/native/kitty/support.ts +70 -0
- package/src/components/chart/native/raster/comparison-chart.ts +162 -0
- package/src/components/chart/native/raster/crosshair.ts +51 -0
- package/src/components/chart/native/raster/layout.ts +136 -0
- package/src/components/chart/native/raster/placement.ts +132 -0
- package/src/components/chart/native/raster/price-chart.ts +244 -0
- package/src/components/chart/native/raster/primitives.ts +154 -0
- package/src/components/chart/native/raster/types.ts +41 -0
- package/src/components/chart/native/renderer-selection.ts +81 -1
- package/src/components/chart/native/surface/hooks.ts +137 -0
- package/src/components/chart/native/surface/manager.ts +225 -0
- package/src/components/chart/native/surface/rendering.ts +211 -0
- package/src/components/chart/native/surface/sync.ts +34 -0
- package/src/components/chart/native/surface/visibility.ts +48 -0
- package/src/components/chart/price-axis-labels.tsx +4 -4
- package/src/components/chart/rendering/chart-draw.ts +270 -0
- package/src/components/chart/rendering/geometry.ts +95 -0
- package/src/components/chart/rendering/pixel-buffer.ts +267 -0
- package/src/components/chart/scatter-chart-renderer.test.ts +31 -0
- package/src/components/chart/scatter-chart-renderer.ts +223 -0
- package/src/components/chart/static/bar-chart-surface.tsx +85 -0
- package/src/components/chart/static/chart/bitmap.ts +50 -0
- package/src/components/chart/static/chart/surface.test.tsx +51 -0
- package/src/components/chart/static/chart/surface.tsx +181 -0
- package/src/components/chart/static/multi-line-chart-surface.tsx +180 -0
- package/src/components/chart/static/scatter-chart-surface.tsx +83 -0
- package/src/components/chart/stock-chart/auto.ts +216 -0
- package/src/components/chart/stock-chart/axis-width.ts +146 -0
- package/src/components/chart/stock-chart/bitmaps.ts +22 -0
- package/src/components/chart/stock-chart/canvas.ts +202 -0
- package/src/components/chart/stock-chart/controls.tsx +149 -0
- package/src/components/chart/stock-chart/cursor.ts +60 -0
- package/src/components/chart/stock-chart/data-runtime.ts +129 -0
- package/src/components/chart/stock-chart/footer.ts +248 -0
- package/src/components/chart/stock-chart/geometry.ts +160 -0
- package/src/components/chart/stock-chart/index.test.ts +500 -0
- package/src/components/chart/stock-chart/index.tsx +29 -0
- package/src/components/chart/stock-chart/indicators.ts +226 -0
- package/src/components/chart/stock-chart/interaction-runtime.ts +44 -0
- package/src/components/chart/stock-chart/interactions.ts +300 -0
- package/src/components/chart/stock-chart/keyboard.ts +373 -0
- package/src/components/chart/stock-chart/layout-metrics.ts +62 -0
- package/src/components/chart/stock-chart/layout.tsx +177 -0
- package/src/components/chart/stock-chart/native-surfaces.ts +121 -0
- package/src/components/chart/stock-chart/presentation.ts +67 -0
- package/src/components/chart/stock-chart/renderer-switch.test.tsx +263 -0
- package/src/components/chart/stock-chart/rendering/bounds.ts +116 -0
- package/src/components/chart/stock-chart/rendering/candidates.ts +145 -0
- package/src/components/chart/stock-chart/rendering/data.ts +370 -0
- package/src/components/chart/stock-chart/rendering/invalidation.ts +68 -0
- package/src/components/chart/stock-chart/rendering/output.ts +304 -0
- package/src/components/chart/stock-chart/rendering/planning.ts +122 -0
- package/src/components/chart/stock-chart/rendering/projection.test.tsx +98 -0
- package/src/components/chart/stock-chart/rendering/projection.ts +112 -0
- package/src/components/chart/stock-chart/rendering/state.test.ts +70 -0
- package/src/components/chart/stock-chart/rendering/state.ts +283 -0
- package/src/components/chart/stock-chart/requests.ts +337 -0
- package/src/components/chart/stock-chart/resolution-support.ts +96 -0
- package/src/components/chart/stock-chart/resolved/runtime.ts +289 -0
- package/src/components/chart/stock-chart/resolved.tsx +345 -0
- package/src/components/chart/stock-chart/settings.ts +77 -0
- package/src/components/chart/stock-chart/surface-runtime.ts +62 -0
- package/src/components/chart/stock-chart/types.ts +25 -0
- package/src/components/chart/stock-chart/view.tsx +155 -0
- package/src/components/chart/stock-chart/viewport/effects.ts +296 -0
- package/src/components/chart/stock-chart/viewport/index.ts +144 -0
- package/src/components/chart/stock-chart/viewport/runtime.ts +375 -0
- package/src/components/chart/time-axis-label.tsx +4 -3
- package/src/components/command-bar/action-runtime.ts +326 -0
- package/src/components/command-bar/commands/collection.ts +214 -0
- package/src/components/command-bar/commands/direct/index.ts +266 -0
- package/src/components/command-bar/commands/direct/runtime.ts +168 -0
- package/src/components/command-bar/commands/plugin/actions.ts +171 -0
- package/src/components/command-bar/commands/plugin/items.ts +166 -0
- package/src/components/command-bar/commands/registry.ts +263 -0
- package/src/components/command-bar/helpers.test.ts +13 -21
- package/src/components/command-bar/helpers.ts +51 -272
- package/src/components/command-bar/keyboard-handlers.ts +306 -0
- package/src/components/command-bar/keyboard-shortcuts.ts +204 -0
- package/src/components/command-bar/layout-items/current-layout.ts +120 -0
- package/src/components/command-bar/layout-items/focused-pane.ts +143 -0
- package/src/components/command-bar/layout-items/types.ts +25 -0
- package/src/components/command-bar/layout-items/window-mode.ts +72 -0
- package/src/components/command-bar/layout-items.ts +93 -0
- package/src/components/command-bar/list/model.ts +81 -0
- package/src/components/command-bar/list/navigation.ts +125 -0
- package/src/components/command-bar/list/view.tsx +316 -0
- package/src/components/command-bar/multi-select-picker.tsx +219 -0
- package/src/components/command-bar/multi-select-runtime.ts +91 -0
- package/src/components/command-bar/pane-actions.ts +124 -0
- package/src/components/command-bar/pane-settings.ts +227 -0
- package/src/components/command-bar/pane-templates/items.ts +203 -0
- package/src/components/command-bar/pane-templates/workflow-route.ts +81 -0
- package/src/components/command-bar/pane-templates/workflow.ts +282 -0
- package/src/components/command-bar/panel/body.tsx +311 -0
- package/src/components/command-bar/panel/index.tsx +196 -0
- package/src/components/command-bar/panel/layout.ts +117 -0
- package/src/components/command-bar/panel/runtime.ts +280 -0
- package/src/components/command-bar/panel/state.ts +138 -0
- package/src/components/command-bar/panel/types.ts +78 -0
- package/src/components/command-bar/picker-activation.ts +126 -0
- package/src/components/command-bar/routes/root/command-items.ts +176 -0
- package/src/components/command-bar/routes/root/provider-search.ts +200 -0
- package/src/components/command-bar/routes/root/results.ts +233 -0
- package/src/components/command-bar/routes/root/runtime.ts +315 -0
- package/src/components/command-bar/routes/root/selection.ts +228 -0
- package/src/components/command-bar/routes/root/shortcut-feedback.ts +108 -0
- package/src/components/command-bar/routes/root/shortcut-items.ts +159 -0
- package/src/components/command-bar/routes/root/shortcuts.test.ts +151 -0
- package/src/components/command-bar/routes/root/shortcuts.ts +188 -0
- package/src/components/command-bar/routes/ticker-search/actions.ts +142 -0
- package/src/components/command-bar/routes/ticker-search/results.ts +94 -0
- package/src/components/command-bar/routes/ticker-search/route.ts +151 -0
- package/src/components/command-bar/routing/actions.ts +299 -0
- package/src/components/command-bar/routing/confirm.ts +91 -0
- package/src/components/command-bar/routing/effects.ts +82 -0
- package/src/components/command-bar/routing/launch-request.ts +59 -0
- package/src/components/command-bar/routing/list-state.ts +242 -0
- package/src/components/command-bar/routing/navigation-state.ts +147 -0
- package/src/components/command-bar/selection-runtime.ts +291 -0
- package/src/components/command-bar/surface/environment.ts +124 -0
- package/src/components/command-bar/surface/index.test.tsx +864 -0
- package/src/components/command-bar/surface/index.tsx +344 -0
- package/src/components/command-bar/surface/pane.test.tsx +703 -0
- package/src/components/command-bar/surface/portfolio.test.tsx +452 -0
- package/src/components/command-bar/surface/test-harness.tsx +403 -0
- package/src/components/command-bar/theme-preview.ts +84 -0
- package/src/components/command-bar/view-model.test.ts +3 -3
- package/src/components/command-bar/view-model.ts +7 -6
- package/src/components/command-bar/workflow/alert.ts +164 -0
- package/src/components/command-bar/workflow/body.tsx +179 -0
- package/src/components/command-bar/workflow/broker.ts +158 -0
- package/src/components/command-bar/workflow/builtin.ts +134 -0
- package/src/components/command-bar/workflow/collection-actions.ts +257 -0
- package/src/components/command-bar/workflow/coordinator.ts +193 -0
- package/src/components/command-bar/workflow/field-row.tsx +214 -0
- package/src/components/command-bar/workflow/fields.ts +230 -0
- package/src/components/command-bar/workflow/ops.test.ts +197 -0
- package/src/components/command-bar/workflow/ops.ts +268 -0
- package/src/components/command-bar/workflow/route-actions.ts +232 -0
- package/src/components/command-bar/workflow/route-builder.ts +56 -0
- package/src/components/command-bar/workflow/runtime.ts +234 -0
- package/src/components/command-bar/workflow/submit.ts +213 -0
- package/src/components/command-bar/workflow/tickers.ts +214 -0
- package/src/components/command-bar/workflow/types.ts +127 -0
- package/src/components/data-table/stack-view.test.tsx +218 -0
- package/src/components/data-table/stack-view.tsx +59 -0
- package/src/components/data-table/view.test.tsx +254 -0
- package/src/components/data-table/view.tsx +306 -0
- package/src/components/feed-data-table/stack-view.test.tsx +148 -0
- package/src/components/feed-data-table/stack-view.tsx +359 -0
- package/src/components/index.ts +14 -14
- package/src/components/input-search-bar.tsx +94 -0
- package/src/components/layout/detached-pane-shell.tsx +22 -16
- package/src/components/layout/floating-pane.tsx +19 -24
- package/src/components/layout/header.tsx +9 -21
- package/src/components/layout/pane/content.test.tsx +64 -0
- package/src/components/layout/pane/content.tsx +44 -0
- package/src/components/layout/pane/cycle-order.test.ts +30 -0
- package/src/components/layout/pane/cycle-order.ts +32 -0
- package/src/components/layout/pane/footer/index.test.tsx +131 -0
- package/src/components/layout/pane/footer/index.tsx +246 -0
- package/src/components/layout/pane/footer/model.ts +99 -0
- package/src/components/layout/pane/footer/registration.tsx +114 -0
- package/src/components/layout/pane/frame.tsx +55 -0
- package/src/components/layout/pane/header.test.tsx +39 -0
- package/src/components/layout/pane/header.tsx +252 -0
- package/src/components/layout/pane/index.tsx +105 -0
- package/src/components/layout/pane/keyboard-scroll.test.tsx +146 -0
- package/src/components/layout/pane/sizing.ts +66 -0
- package/src/components/layout/pane/title.ts +38 -0
- package/src/components/layout/shell/action-menu-overlay.tsx +72 -0
- package/src/components/layout/shell/active-drag.ts +221 -0
- package/src/components/layout/shell/chrome.ts +8 -0
- package/src/components/layout/shell/drag/index.ts +432 -0
- package/src/components/layout/shell/drag/overlays.tsx +78 -0
- package/src/components/layout/shell/drag/runtime.ts +264 -0
- package/src/components/layout/shell/index.test.tsx +788 -0
- package/src/components/layout/shell/index.tsx +451 -0
- package/src/components/layout/shell/layout-state.ts +97 -0
- package/src/components/layout/shell/menu.ts +152 -0
- package/src/components/layout/shell/native/pointer-runtime.ts +184 -0
- package/src/components/layout/shell/native/surfaces.ts +127 -0
- package/src/components/layout/shell/native/window-state.ts +208 -0
- package/src/components/layout/shell/pane/actions.ts +129 -0
- package/src/components/layout/shell/pane/layers.tsx +234 -0
- package/src/components/layout/shell/pane/management-shortcuts.ts +114 -0
- package/src/components/layout/shell/shortcuts.ts +47 -0
- package/src/components/layout/shell/terminal-pointer-runtime.ts +326 -0
- package/src/components/layout/shell/window-mode/index.ts +253 -0
- package/src/components/layout/shell/window-mode/overlays.tsx +208 -0
- package/src/components/layout/status-bar.test.tsx +1 -101
- package/src/components/layout/status-bar.tsx +1 -1
- package/src/components/layout/window-edit/mode.test.ts +55 -0
- package/src/components/layout/window-edit/mode.ts +422 -0
- package/src/components/layout/window-edit/presentation.ts +123 -0
- package/src/components/layout/window-edit/status.tsx +101 -0
- package/src/components/markdown-text.tsx +3 -3
- package/src/components/onboarding/onboarding-steps.tsx +248 -0
- package/src/components/onboarding/onboarding-wizard.tsx +97 -1035
- package/src/components/onboarding/portfolio-step/broker-fields-panel.tsx +144 -0
- package/src/components/onboarding/portfolio-step/broker-setup-panel.tsx +97 -0
- package/src/components/onboarding/portfolio-step/broker-sync-panel.tsx +42 -0
- package/src/components/onboarding/portfolio-step/choose-panel.tsx +42 -0
- package/src/components/onboarding/portfolio-step/index.tsx +70 -0
- package/src/components/onboarding/portfolio-step/manual-name-panel.tsx +62 -0
- package/src/components/onboarding/portfolio-step/types.ts +25 -0
- package/src/components/onboarding/portfolio-step/utils.ts +15 -0
- package/src/components/onboarding/wizard-broker-sync.ts +230 -0
- package/src/components/onboarding/wizard-keyboard.ts +264 -0
- package/src/components/onboarding/wizard-model.ts +21 -0
- package/src/components/pane-settings-dialog/desktop.tsx +315 -0
- package/src/components/pane-settings-dialog/field-dialogs.tsx +213 -0
- package/src/components/pane-settings-dialog/tui.tsx +73 -0
- package/src/components/pane-settings-dialog/value.ts +36 -0
- package/src/components/pane-settings-dialog.tsx +18 -622
- package/src/components/pane-template-wizard.tsx +1 -1
- package/src/components/price-selector-dialog.tsx +2 -2
- package/src/components/price-sparkline/bitmap.ts +150 -0
- package/src/components/price-sparkline/index.ts +46 -0
- package/src/components/price-sparkline/model.ts +119 -0
- package/src/components/price-sparkline/view.tsx +214 -0
- package/src/components/quote-flash.ts +103 -0
- package/src/components/speedometer-gauge/desktop.tsx +151 -0
- package/src/components/speedometer-gauge/index.tsx +44 -0
- package/src/components/speedometer-gauge/model.ts +60 -0
- package/src/components/speedometer-gauge/terminal.tsx +261 -0
- package/src/components/ticker/badge/format.ts +42 -0
- package/src/components/ticker/badge/index.tsx +100 -0
- package/src/components/ticker/badge/list.tsx +57 -0
- package/src/components/ticker/badge/text.test.tsx +223 -0
- package/src/components/ticker/badge/text.tsx +156 -0
- package/src/components/ticker/list-table-view.tsx +297 -0
- package/src/components/ticker/list-table.test.tsx +177 -0
- package/src/components/toggle-list.tsx +1 -1
- package/src/components/ui/data-table/index.tsx +26 -0
- package/src/components/ui/data-table/opentui/index.tsx +467 -0
- package/src/components/ui/data-table/opentui/model.test.ts +47 -0
- package/src/components/ui/data-table/opentui/model.ts +66 -0
- package/src/components/ui/data-table/types.ts +81 -0
- package/src/components/ui/index.ts +1 -3
- package/src/components/ui/multi-select/dialog.tsx +336 -0
- package/src/components/ui/native-select.tsx +1 -1
- package/src/components/ui/shortcut-hint.tsx +1 -1
- package/src/components/ui/tabs.tsx +11 -5
- package/src/components/ui/toggle.tsx +1 -1
- package/src/components/ui/ui.test.tsx +3 -75
- package/src/components/use-external-link-footer.ts +1 -1
- package/src/core/app-services.ts +3 -0
- package/src/core/state/app/layout-reducer.ts +196 -0
- package/src/core/state/app/layout.ts +406 -0
- package/src/core/state/app/state.ts +340 -0
- package/src/core/state/app/types.ts +116 -0
- package/src/core/state/session-persistence.ts +1 -1
- package/src/data/app-persistence.ts +1 -1
- package/src/data/config/layout.ts +227 -0
- package/src/data/config/store/index.test.ts +500 -0
- package/src/data/config/store/index.ts +64 -0
- package/src/data/config/store/node.ts +101 -0
- package/src/data/config/store/normalize.ts +403 -0
- package/src/data/plugin-state-store.ts +3 -3
- package/src/data/resource-store.ts +3 -3
- package/src/data/session-store.ts +3 -3
- package/src/data/sqlite/cache.test.ts +151 -0
- package/src/data/sqlite/database.ts +68 -0
- package/src/data/sqlite/json.ts +16 -0
- package/src/data/sqlite/retry.test.ts +63 -0
- package/src/data/ticker-repository.ts +1 -1
- package/src/data/ticker-store.ts +2 -2
- package/src/market-data/coordinator/auxiliary.ts +252 -0
- package/src/market-data/coordinator/chart.ts +141 -0
- package/src/market-data/coordinator/entries.ts +129 -0
- package/src/market-data/coordinator/events.ts +74 -0
- package/src/market-data/coordinator/financials.ts +281 -0
- package/src/market-data/coordinator/index.test.ts +840 -0
- package/src/market-data/coordinator/index.ts +388 -0
- package/src/market-data/coordinator/quotes.ts +329 -0
- package/src/market-data/coordinator/subscriptions.test.ts +209 -0
- package/src/market-data/hooks.test.tsx +42 -1
- package/src/market-data/hooks.tsx +83 -18
- package/src/market-data/market/format.test.ts +109 -0
- package/src/market-data/market/format.ts +293 -0
- package/src/market-data/market/freshness.ts +140 -0
- package/src/market-data/market/status.ts +112 -0
- package/src/market-data/quotes/contributions.ts +194 -0
- package/src/market-data/quotes/freshness.test.ts +150 -0
- package/src/market-data/quotes/freshness.ts +36 -0
- package/src/market-data/quotes/resolution.test.ts +277 -0
- package/src/market-data/quotes/resolution.ts +468 -0
- package/src/market-data/quotes/time.test.ts +34 -0
- package/src/market-data/quotes/time.ts +59 -0
- package/src/market-data/request-types.ts +10 -3
- package/src/market-data/result-types.ts +3 -3
- package/src/market-data/selectors.ts +2 -2
- package/src/news/aggregator.ts +29 -219
- package/src/news/news-model.ts +208 -0
- package/src/news/ticker-symbols.ts +1 -1
- package/src/news/types.ts +3 -3
- package/src/plugins/builtin/account-management/footer.ts +39 -0
- package/src/plugins/builtin/account-management/form-components.tsx +162 -0
- package/src/plugins/builtin/account-management/keyboard.ts +90 -0
- package/src/plugins/builtin/account-management/model.ts +97 -0
- package/src/plugins/builtin/account-management/pane.tsx +389 -0
- package/src/plugins/builtin/account-management/password-dialog.tsx +125 -0
- package/src/plugins/builtin/ai/ask-ai-detail-tab.tsx +6 -6
- package/src/plugins/builtin/ai/ask-ai.test.tsx +305 -0
- package/src/plugins/builtin/ai/index.tsx +4 -4
- package/src/plugins/builtin/ai/providers.ts +1 -1
- package/src/plugins/builtin/ai/runner.ts +1 -0
- package/src/plugins/builtin/ai/screener/action-bar.tsx +58 -0
- package/src/plugins/builtin/ai/screener/contract.test.ts +117 -0
- package/src/plugins/builtin/ai/screener/contract.ts +174 -0
- package/src/plugins/builtin/ai/screener/editor-runtime.ts +110 -0
- package/src/plugins/builtin/ai/screener/editor.tsx +125 -0
- package/src/plugins/builtin/ai/screener/footer.ts +93 -0
- package/src/plugins/builtin/ai/screener/keyboard.ts +90 -0
- package/src/plugins/builtin/ai/screener/market-runtime.ts +99 -0
- package/src/plugins/builtin/ai/screener/model.ts +107 -0
- package/src/plugins/builtin/ai/screener/pane.test.tsx +348 -0
- package/src/plugins/builtin/ai/screener/pane.tsx +412 -0
- package/src/plugins/builtin/ai/screener/results-view.tsx +169 -0
- package/src/plugins/builtin/ai/screener/results.ts +139 -0
- package/src/plugins/builtin/ai/screener/runner.ts +144 -0
- package/src/plugins/builtin/ai/screener/tabs-bar.tsx +65 -0
- package/src/plugins/builtin/ai/settings.ts +3 -3
- package/src/plugins/builtin/ai/ticker-context.ts +1 -1
- package/src/plugins/builtin/alerts/command.ts +86 -0
- package/src/plugins/builtin/alerts/constants.ts +3 -0
- package/src/plugins/builtin/alerts/format.ts +68 -0
- package/src/plugins/builtin/alerts/index.test.tsx +5 -4
- package/src/plugins/builtin/alerts/index.tsx +18 -473
- package/src/plugins/builtin/alerts/pane.tsx +304 -0
- package/src/plugins/builtin/alerts/quotes.ts +57 -0
- package/src/plugins/builtin/alerts/storage.ts +20 -0
- package/src/plugins/builtin/analytics/broker-performance.ts +142 -0
- package/src/plugins/builtin/analytics/display.ts +44 -0
- package/src/plugins/builtin/analytics/index.test.tsx +144 -5
- package/src/plugins/builtin/analytics/index.tsx +108 -468
- package/src/plugins/builtin/analytics/metrics.ts +1 -1
- package/src/plugins/builtin/analytics/pane-model.ts +297 -0
- package/src/plugins/builtin/analytics/portfolio-selection.ts +10 -0
- package/src/plugins/builtin/analytics/sector-model.ts +172 -0
- package/src/plugins/builtin/analytics/view.tsx +207 -0
- package/src/plugins/builtin/broker-manager/detail.tsx +232 -0
- package/src/plugins/builtin/broker-manager/footer.ts +62 -0
- package/src/plugins/builtin/broker-manager/index.test.tsx +3 -3
- package/src/plugins/builtin/broker-manager/index.tsx +125 -527
- package/src/plugins/builtin/broker-manager/keyboard.ts +104 -0
- package/src/plugins/builtin/broker-manager/model.test.ts +39 -1
- package/src/plugins/builtin/broker-manager/model.ts +14 -8
- package/src/plugins/builtin/broker-manager/pane-actions.tsx +181 -0
- package/src/plugins/builtin/broker-manager/table.ts +86 -0
- package/src/plugins/builtin/buildout/cells.tsx +203 -0
- package/src/plugins/builtin/buildout/data-runtime.ts +238 -0
- package/src/plugins/builtin/buildout/detail/company.tsx +219 -0
- package/src/plugins/builtin/buildout/detail/index.tsx +105 -0
- package/src/plugins/builtin/buildout/detail/intel.tsx +61 -0
- package/src/plugins/builtin/buildout/detail/satellite-images.tsx +80 -0
- package/src/plugins/builtin/buildout/detail/site.tsx +142 -0
- package/src/plugins/builtin/buildout/detail/ui.tsx +355 -0
- package/src/plugins/builtin/buildout/detail/values.ts +67 -0
- package/src/plugins/builtin/buildout/format.ts +163 -0
- package/src/plugins/builtin/buildout/model/index.ts +135 -0
- package/src/plugins/builtin/buildout/model/normalizers.ts +396 -0
- package/src/plugins/builtin/buildout/model/types.ts +318 -0
- package/src/plugins/builtin/buildout/pane/header.tsx +55 -0
- package/src/plugins/builtin/buildout/pane/index.tsx +405 -0
- package/src/plugins/builtin/buildout/pane/status.tsx +84 -0
- package/src/plugins/builtin/buildout/table-model.ts +367 -0
- package/src/plugins/builtin/changelog/index.tsx +370 -0
- package/src/plugins/builtin/chat/channels.ts +157 -0
- package/src/plugins/builtin/chat/chat.test.tsx +1048 -0
- package/src/plugins/builtin/chat/composer-commands.test.ts +30 -0
- package/src/plugins/builtin/chat/composer-commands.ts +34 -0
- package/src/plugins/builtin/chat/content/channel-navigation.ts +157 -0
- package/src/plugins/builtin/chat/content/composer-runtime.ts +251 -0
- package/src/plugins/builtin/chat/content/composer.tsx +148 -0
- package/src/plugins/builtin/chat/content/index.tsx +407 -0
- package/src/plugins/builtin/chat/content/layout-metrics.ts +72 -0
- package/src/plugins/builtin/chat/content/scroll.ts +278 -0
- package/src/plugins/builtin/chat/content/selection-runtime.ts +66 -0
- package/src/plugins/builtin/chat/content/shortcuts.ts +212 -0
- package/src/plugins/builtin/chat/content/snapshot.ts +154 -0
- package/src/plugins/builtin/chat/content/transcript.tsx +155 -0
- package/src/plugins/builtin/chat/content/types.ts +26 -0
- package/src/plugins/builtin/chat/content/user-map.ts +21 -0
- package/src/plugins/builtin/chat/controller/channel-actions.ts +87 -0
- package/src/plugins/builtin/chat/controller/channels.ts +159 -0
- package/src/plugins/builtin/chat/controller/connections.ts +90 -0
- package/src/plugins/builtin/chat/controller/draft-sync.ts +41 -0
- package/src/plugins/builtin/chat/controller/fetch.ts +83 -0
- package/src/plugins/builtin/chat/controller/index.ts +488 -0
- package/src/plugins/builtin/chat/controller/lifecycle.ts +141 -0
- package/src/plugins/builtin/chat/controller/message-loading.ts +97 -0
- package/src/plugins/builtin/chat/controller/messages.ts +173 -0
- package/src/plugins/builtin/chat/controller/notifications.ts +56 -0
- package/src/plugins/builtin/chat/controller/persistence.ts +166 -0
- package/src/plugins/builtin/chat/controller/realtime.ts +91 -0
- package/src/plugins/builtin/chat/controller/send.ts +89 -0
- package/src/plugins/builtin/chat/controller/session-runtime.ts +156 -0
- package/src/plugins/builtin/chat/controller/session.ts +39 -0
- package/src/plugins/builtin/chat/controller/state.ts +162 -0
- package/src/plugins/builtin/chat/controller/storage.ts +136 -0
- package/src/plugins/builtin/chat/controller/utils.ts +75 -0
- package/src/plugins/builtin/chat/controller/view.ts +96 -0
- package/src/plugins/builtin/chat/controller.test.ts +1302 -0
- package/src/plugins/builtin/chat/index.tsx +4 -0
- package/src/plugins/builtin/chat/layout.ts +330 -0
- package/src/plugins/builtin/chat/message/action-chip.tsx +38 -0
- package/src/plugins/builtin/chat/message/desktop.tsx +158 -0
- package/src/plugins/builtin/chat/message/inline-tokens.tsx +118 -0
- package/src/plugins/builtin/chat/message/profile-popover.tsx +72 -0
- package/src/plugins/builtin/chat/message/render-state.ts +67 -0
- package/src/plugins/builtin/chat/message/terminal.tsx +132 -0
- package/src/plugins/builtin/chat/message/types.ts +18 -0
- package/src/plugins/builtin/chat/pane.tsx +100 -0
- package/src/plugins/builtin/chat/profile-popover.ts +49 -0
- package/src/plugins/builtin/chat/sidebar.test.tsx +455 -0
- package/src/plugins/builtin/chat/sidebar.tsx +296 -0
- package/src/plugins/builtin/chat/status-widget.tsx +103 -0
- package/src/plugins/builtin/chat/test-harness.tsx +212 -0
- package/src/plugins/builtin/cloud/auth-actions.tsx +72 -0
- package/src/plugins/builtin/cloud/auth-commands.ts +115 -0
- package/src/plugins/builtin/cloud/index.tsx +11 -0
- package/src/plugins/builtin/cloud/plugin.tsx +185 -0
- package/src/plugins/builtin/cloud-tweets/footer.ts +40 -0
- package/src/plugins/builtin/cloud-tweets/index.ts +1 -0
- package/src/plugins/builtin/cloud-tweets/keyboard.ts +65 -0
- package/src/plugins/builtin/cloud-tweets/model.ts +257 -0
- package/src/plugins/builtin/cloud-tweets/pane.tsx +318 -0
- package/src/plugins/builtin/cloud-tweets/registration.ts +87 -0
- package/src/plugins/builtin/cloud-tweets/search-bar.tsx +49 -0
- package/src/plugins/builtin/cloud-tweets/table.tsx +331 -0
- package/src/plugins/builtin/comparison-chart/index.test.tsx +645 -0
- package/src/plugins/builtin/comparison-chart/index.tsx +194 -0
- package/src/plugins/builtin/congress-trades/detail.tsx +154 -0
- package/src/plugins/builtin/congress-trades/footer.ts +67 -0
- package/src/plugins/builtin/congress-trades/keyboard.ts +112 -0
- package/src/plugins/builtin/congress-trades/model.ts +224 -0
- package/src/plugins/builtin/congress-trades/pane.tsx +331 -0
- package/src/plugins/builtin/congress-trades/table.tsx +84 -0
- package/src/plugins/builtin/correlation/compute.ts +0 -7
- package/src/plugins/builtin/correlation/index.test.tsx +5 -5
- package/src/plugins/builtin/correlation/index.tsx +36 -208
- package/src/plugins/builtin/correlation/matrix/model.ts +155 -0
- package/src/plugins/builtin/correlation/matrix/symbol-cell.tsx +56 -0
- package/src/plugins/builtin/correlation/relationship/controls.tsx +53 -0
- package/src/plugins/builtin/correlation/relationship/history.ts +72 -0
- package/src/plugins/builtin/correlation/relationship/model.ts +279 -0
- package/src/plugins/builtin/correlation/relationship/pane.tsx +359 -0
- package/src/plugins/builtin/correlation/relationship/view-model.ts +120 -0
- package/src/plugins/builtin/correlation/settings.ts +6 -6
- package/src/plugins/builtin/debug/index.tsx +365 -0
- package/src/plugins/builtin/earnings/data/cache.test.ts +94 -0
- package/src/plugins/builtin/earnings/data/cache.ts +145 -0
- package/src/plugins/builtin/earnings/data/data.test.ts +90 -0
- package/src/plugins/builtin/earnings/data/data.ts +115 -0
- package/src/plugins/builtin/earnings/index.test.ts +12 -0
- package/src/plugins/builtin/earnings/index.tsx +74 -266
- package/src/plugins/builtin/earnings/model.ts +82 -0
- package/src/plugins/builtin/earnings/table.ts +206 -0
- package/src/plugins/builtin/econ/calendar-model.test.ts +48 -0
- package/src/plugins/builtin/econ/calendar-model.ts +217 -0
- package/src/plugins/builtin/econ/calendar-source.ts +1 -1
- package/src/plugins/builtin/econ/detail-view.tsx +319 -0
- package/src/plugins/builtin/econ/fred-cache.test.ts +58 -0
- package/src/plugins/builtin/econ/fred-cache.ts +106 -0
- package/src/plugins/builtin/econ/fred-series-map.ts +0 -4
- package/src/plugins/builtin/econ/index.tsx +46 -474
- package/src/plugins/builtin/fear-greed/cache.test.ts +75 -0
- package/src/plugins/builtin/fear-greed/cache.ts +142 -0
- package/src/plugins/builtin/fear-greed/charts.tsx +305 -0
- package/src/plugins/builtin/fear-greed/data.test.ts +72 -0
- package/src/plugins/builtin/fear-greed/data.ts +370 -0
- package/src/plugins/builtin/fear-greed/format.ts +96 -0
- package/src/plugins/builtin/fear-greed/index.tsx +13 -555
- package/src/plugins/builtin/fear-greed/pane.tsx +169 -0
- package/src/plugins/builtin/fx-matrix/index.tsx +1 -1
- package/src/plugins/builtin/fx-matrix/pairs.ts +0 -22
- package/src/plugins/builtin/help/components.tsx +92 -0
- package/src/plugins/builtin/help/index.test.tsx +167 -0
- package/src/plugins/builtin/help/index.tsx +256 -0
- package/src/plugins/builtin/help/shortcut-model.ts +145 -0
- package/src/plugins/builtin/holders/format.ts +44 -0
- package/src/plugins/builtin/holders/index.test.ts +1 -46
- package/src/plugins/builtin/holders/index.tsx +3 -955
- package/src/plugins/builtin/holders/pane.tsx +331 -0
- package/src/plugins/builtin/holders/table-model.ts +84 -0
- package/src/plugins/builtin/holders/thirteenf-match.ts +76 -0
- package/src/plugins/builtin/holders/treemap-layout.ts +231 -0
- package/src/plugins/builtin/holders/treemap.tsx +318 -0
- package/src/plugins/builtin/holders/types.ts +51 -0
- package/src/plugins/builtin/insider/index.tsx +5 -5
- package/src/plugins/builtin/layout-manager/index.tsx +247 -0
- package/src/plugins/builtin/market-movers/index.tsx +44 -282
- package/src/plugins/builtin/market-movers/model.ts +146 -0
- package/src/plugins/builtin/market-movers/screener.test.ts +31 -1
- package/src/plugins/builtin/market-movers/screener.ts +106 -12
- package/src/plugins/builtin/market-movers/table.ts +95 -0
- package/src/plugins/builtin/news/index.tsx +194 -0
- package/src/plugins/builtin/news/wire/breaking/notifications.test.ts +98 -0
- package/src/plugins/builtin/news/wire/breaking/notifications.ts +110 -0
- package/src/plugins/builtin/news/wire/breaking/pane.test.tsx +156 -0
- package/src/plugins/builtin/news/wire/breaking/pane.tsx +68 -0
- package/src/plugins/builtin/news/wire/categories.ts +114 -0
- package/src/plugins/builtin/news/wire/default-feeds.ts +3 -0
- package/src/plugins/builtin/news/wire/feed-config.test.ts +90 -0
- package/src/plugins/builtin/news/wire/feed-config.ts +216 -0
- package/src/plugins/builtin/news/wire/index.tsx +129 -0
- package/src/plugins/builtin/news/wire/industry-pane.tsx +126 -0
- package/src/plugins/builtin/news/wire/news/detail-view.tsx +306 -0
- package/src/plugins/builtin/news/wire/news/footer.ts +77 -0
- package/src/plugins/builtin/news/wire/news/preset-pane.tsx +98 -0
- package/src/plugins/builtin/news/wire/news/query-presets.ts +40 -0
- package/src/plugins/builtin/news/wire/news/table.test.tsx +157 -0
- package/src/plugins/builtin/news/wire/news/table.tsx +270 -0
- package/src/plugins/builtin/news/wire/persisted-articles.ts +98 -0
- package/src/plugins/builtin/news/wire/read-state.ts +76 -0
- package/src/plugins/builtin/news/wire/rss/parser.test.ts +116 -0
- package/src/plugins/builtin/news/wire/rss/parser.ts +213 -0
- package/src/plugins/builtin/news/wire/rss/source.test.ts +104 -0
- package/src/plugins/builtin/news/wire/rss/source.ts +181 -0
- package/src/plugins/builtin/notes/index.tsx +49 -0
- package/src/plugins/builtin/notes/markdown-note-preview.tsx +39 -0
- package/src/plugins/builtin/notes/model.ts +36 -0
- package/src/plugins/builtin/notes/quick-notes-pane.tsx +334 -0
- package/src/plugins/builtin/notes/text-state.ts +11 -0
- package/src/plugins/builtin/notes/ticker-notes-tab.tsx +112 -0
- package/src/plugins/builtin/options/index.tsx +44 -0
- package/src/plugins/builtin/options/table.ts +209 -0
- package/src/plugins/builtin/options/types.ts +33 -0
- package/src/plugins/builtin/options/view.test.tsx +185 -0
- package/src/plugins/builtin/options/view.tsx +264 -0
- package/src/plugins/builtin/plugin-groups.ts +25 -5
- package/src/plugins/builtin/portfolio-list/account-metrics.test.ts +50 -0
- package/src/plugins/builtin/portfolio-list/account-metrics.ts +46 -0
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +224 -0
- package/src/plugins/builtin/portfolio-list/cli/render.ts +203 -0
- package/src/plugins/builtin/portfolio-list/cli/shared.ts +21 -0
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +224 -0
- package/src/plugins/builtin/portfolio-list/column-values.ts +284 -0
- package/src/plugins/builtin/portfolio-list/command-bar.ts +1 -1
- package/src/plugins/builtin/portfolio-list/header.tsx +7 -98
- package/src/plugins/builtin/portfolio-list/index.test.ts +133 -0
- package/src/plugins/builtin/portfolio-list/index.tsx +2 -1
- package/src/plugins/builtin/portfolio-list/metrics.test.ts +242 -0
- package/src/plugins/builtin/portfolio-list/metrics.ts +5 -462
- package/src/plugins/builtin/portfolio-list/pane/data.ts +171 -0
- package/src/plugins/builtin/portfolio-list/pane/index.test.tsx +1267 -0
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +385 -0
- package/src/plugins/builtin/portfolio-list/pane/streaming.ts +159 -0
- package/src/plugins/builtin/portfolio-list/position-metrics.ts +123 -0
- package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +326 -0
- package/src/plugins/builtin/portfolio-list/quick-add/resolution.ts +135 -0
- package/src/plugins/builtin/portfolio-list/settings.ts +5 -3
- package/src/plugins/builtin/portfolio-list/summary/index.test.ts +126 -0
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +392 -0
- package/src/plugins/builtin/portfolio-list/summary/totals.ts +86 -0
- package/src/plugins/builtin/portfolio-list/table.tsx +1 -1
- package/src/plugins/builtin/portfolio-list/use-throttled-cursor-symbol.ts +1 -1
- package/src/plugins/builtin/research/analyst-pane.tsx +383 -0
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +413 -0
- package/src/plugins/builtin/research/index.test.ts +248 -2
- package/src/plugins/builtin/research/index.tsx +30 -760
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +189 -0
- package/src/plugins/builtin/sec/filing-display.tsx +84 -0
- package/src/plugins/builtin/sec/index.tsx +342 -0
- package/src/plugins/builtin/sectors/index.tsx +27 -234
- package/src/plugins/builtin/sectors/sector-data.ts +0 -2
- package/src/plugins/builtin/sectors/sector-model.ts +221 -0
- package/src/plugins/builtin/shared/table-pane.ts +31 -0
- package/src/plugins/builtin/shared/ticker-request.ts +70 -0
- package/src/plugins/builtin/shared/ticker-surface.test.ts +57 -0
- package/src/plugins/builtin/shared/ticker-surface.ts +113 -0
- package/src/plugins/builtin/thirteenf/api.test.ts +58 -0
- package/src/plugins/builtin/thirteenf/api.ts +375 -0
- package/src/plugins/builtin/thirteenf/data.test.ts +95 -0
- package/src/plugins/builtin/thirteenf/data.ts +210 -0
- package/src/plugins/builtin/thirteenf/format.ts +55 -0
- package/src/plugins/builtin/thirteenf/index.tsx +80 -0
- package/src/plugins/builtin/thirteenf/model.test.ts +156 -0
- package/src/plugins/builtin/thirteenf/model.ts +618 -0
- package/src/plugins/builtin/thirteenf/pane.test.tsx +328 -0
- package/src/plugins/builtin/thirteenf/pane.tsx +826 -0
- package/src/plugins/builtin/thirteenf/table.ts +212 -0
- package/src/plugins/builtin/thirteenf/types.ts +187 -0
- package/src/plugins/builtin/ticker-detail/chart-pane.tsx +91 -0
- package/src/plugins/builtin/ticker-detail/chart-tab-switch.test.tsx +282 -0
- package/src/plugins/builtin/ticker-detail/chart-tab.tsx +3 -5
- package/src/plugins/builtin/ticker-detail/data-panes/fundamental-graph/content.tsx +158 -0
- package/src/plugins/builtin/ticker-detail/data-panes/fundamental-graph/data.ts +62 -0
- package/src/plugins/builtin/ticker-detail/data-panes/fundamental-graph/model.ts +234 -0
- package/src/plugins/builtin/ticker-detail/data-panes/fundamental-graph/settings.ts +44 -0
- package/src/plugins/builtin/ticker-detail/data-panes/fundamental-graph/types.ts +51 -0
- package/src/plugins/builtin/ticker-detail/data-panes/fundamental-graph.tsx +135 -0
- package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +192 -0
- package/src/plugins/builtin/ticker-detail/data-panes/provider-search.tsx +172 -0
- package/src/plugins/builtin/ticker-detail/data-panes.test.ts +110 -0
- package/src/plugins/builtin/ticker-detail/financials/aggregation.ts +203 -0
- package/src/plugins/builtin/ticker-detail/financials/model.test.ts +84 -0
- package/src/plugins/builtin/ticker-detail/financials/model.ts +364 -0
- package/src/plugins/builtin/ticker-detail/financials/pane.tsx +27 -0
- package/src/plugins/builtin/ticker-detail/financials/schema.ts +392 -0
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +438 -0
- package/src/plugins/builtin/ticker-detail/index.test.tsx +780 -0
- package/src/plugins/builtin/ticker-detail/index.tsx +174 -17
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +240 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +168 -0
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +14 -0
- package/src/plugins/builtin/ticker-detail/overview/types.ts +17 -0
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +27 -392
- package/src/plugins/builtin/ticker-detail/pane.tsx +24 -136
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +330 -0
- package/src/plugins/builtin/ticker-detail/quote-monitor/index.test.tsx +292 -0
- package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +180 -0
- package/src/plugins/builtin/ticker-detail/settings.ts +39 -33
- package/src/plugins/builtin/world-indices/footer.ts +28 -0
- package/src/plugins/builtin/world-indices/index.tsx +25 -218
- package/src/plugins/builtin/world-indices/model.ts +120 -0
- package/src/plugins/builtin/world-indices/table.tsx +96 -0
- package/src/plugins/builtin/yahoo/index.ts +72 -0
- package/src/plugins/builtin/yield-curve/index.tsx +5 -5
- package/src/plugins/builtin/yield-curve/treasury-data.ts +1 -1
- package/src/plugins/catalog-ui.ts +7 -9
- package/src/plugins/catalog.ts +1 -1
- package/src/plugins/ibkr/account-cache.ts +2 -10
- package/src/plugins/ibkr/broker-adapter.ts +10 -4
- package/src/plugins/ibkr/config.ts +5 -24
- package/src/plugins/ibkr/dialogs.tsx +0 -1
- package/src/plugins/ibkr/flex/index.test.ts +236 -0
- package/src/plugins/ibkr/flex/index.ts +337 -0
- package/src/plugins/ibkr/flex/statement-client.ts +181 -0
- package/src/plugins/ibkr/gateway/account-loaders.ts +266 -0
- package/src/plugins/ibkr/gateway/account-summary.ts +163 -0
- package/src/plugins/ibkr/gateway/client-lock.ts +154 -0
- package/src/plugins/ibkr/gateway/connection-events.ts +114 -0
- package/src/plugins/ibkr/gateway/connection.ts +152 -0
- package/src/plugins/ibkr/gateway/contracts.ts +132 -0
- package/src/plugins/ibkr/gateway/fundamentals.ts +83 -0
- package/src/plugins/ibkr/gateway/helpers.ts +33 -0
- package/src/plugins/ibkr/gateway/history-requests.ts +158 -0
- package/src/plugins/ibkr/gateway/history.ts +120 -0
- package/src/plugins/ibkr/gateway/instrument-lookup.ts +117 -0
- package/src/plugins/ibkr/gateway/market-data.ts +338 -0
- package/src/plugins/ibkr/gateway/order-execution.ts +218 -0
- package/src/plugins/ibkr/gateway/orders.ts +63 -0
- package/src/plugins/ibkr/gateway/price-normalization.test.ts +44 -0
- package/src/plugins/ibkr/gateway/price-normalization.ts +50 -0
- package/src/plugins/ibkr/gateway/quote-stream-controller.ts +203 -0
- package/src/plugins/ibkr/gateway/quote-stream.ts +171 -0
- package/src/plugins/ibkr/gateway/selection.ts +51 -0
- package/src/plugins/ibkr/gateway/service/index.test.ts +614 -0
- package/src/plugins/ibkr/gateway/service/index.ts +432 -0
- package/src/plugins/ibkr/gateway/service/lifecycle.ts +191 -0
- package/src/plugins/ibkr/gateway/service/manager.ts +52 -0
- package/src/plugins/ibkr/gateway/service/market-data.ts +48 -0
- package/src/plugins/ibkr/gateway/service/native.ts +543 -0
- package/src/plugins/ibkr/gateway/timeouts.ts +13 -0
- package/src/plugins/ibkr/gateway/types.ts +27 -0
- package/src/plugins/ibkr/hash.ts +8 -0
- package/src/plugins/ibkr/index.test.tsx +1 -12
- package/src/plugins/ibkr/index.tsx +8 -9
- package/src/plugins/ibkr/instance-selection.test.ts +2 -2
- package/src/plugins/ibkr/instance-selection.ts +1 -1
- package/src/plugins/ibkr/portfolio-performance.test.ts +32 -0
- package/src/plugins/ibkr/portfolio-performance.ts +129 -0
- package/src/plugins/ibkr/trade/badge.tsx +28 -0
- package/src/plugins/ibkr/trade/dialogs.tsx +44 -0
- package/src/plugins/ibkr/trade/preview-panel.tsx +130 -0
- package/src/plugins/ibkr/trade/tab/actions.tsx +443 -0
- package/src/plugins/ibkr/trade/tab/field-editors.tsx +79 -0
- package/src/plugins/ibkr/trade/tab/footer.ts +67 -0
- package/src/plugins/ibkr/trade/tab/header.tsx +167 -0
- package/src/plugins/ibkr/trade/tab/index.test.tsx +178 -0
- package/src/plugins/ibkr/trade/tab/index.tsx +302 -0
- package/src/plugins/ibkr/trade/tab/model.ts +159 -0
- package/src/plugins/ibkr/trade/tab/order-request.ts +64 -0
- package/src/plugins/ibkr/trade/tab/shortcuts.ts +89 -0
- package/src/plugins/ibkr/trade/tab/state-sync.ts +86 -0
- package/src/plugins/ibkr/trade/ticket-panel.tsx +301 -0
- package/src/plugins/ibkr/trade/utils.test.ts +175 -0
- package/src/plugins/ibkr/trade/utils.ts +150 -0
- package/src/plugins/ibkr/trading/pane-view.tsx +175 -0
- package/src/plugins/ibkr/trading/pane.tsx +332 -0
- package/src/plugins/ibkr/trading/state.test.ts +109 -0
- package/src/plugins/ibkr/trading/state.ts +335 -0
- package/src/plugins/pane-manager/dock-tree.ts +282 -0
- package/src/plugins/pane-manager/docking.ts +202 -0
- package/src/plugins/pane-manager/floating-actions.ts +158 -0
- package/src/plugins/pane-manager/floating.ts +76 -0
- package/src/plugins/pane-manager/gridlock-inference.ts +126 -0
- package/src/plugins/pane-manager/gridlock.ts +34 -0
- package/src/plugins/pane-manager/layout-state.ts +160 -0
- package/src/plugins/pane-manager/queries.ts +75 -0
- package/src/plugins/pane-manager/types.ts +24 -0
- package/src/plugins/pane-manager.test.ts +110 -4
- package/src/plugins/pane-manager.ts +57 -1035
- package/src/plugins/prediction-markets/chart.test.tsx +2 -2
- package/src/plugins/prediction-markets/controller/catalog.ts +317 -0
- package/src/plugins/prediction-markets/controller/data.ts +171 -0
- package/src/plugins/prediction-markets/controller/detail.ts +243 -0
- package/src/plugins/prediction-markets/controller/effects.ts +253 -0
- package/src/plugins/prediction-markets/controller/index.ts +374 -0
- package/src/plugins/prediction-markets/controller/keyboard.ts +220 -0
- package/src/plugins/prediction-markets/controller/live-updates.ts +85 -0
- package/src/plugins/prediction-markets/controller/selection.ts +59 -0
- package/src/plugins/prediction-markets/controller/status.ts +104 -0
- package/src/plugins/prediction-markets/detail/outcomes.tsx +1 -1
- package/src/plugins/prediction-markets/metrics.ts +4 -14
- package/src/plugins/prediction-markets/navigation.ts +0 -13
- package/src/plugins/prediction-markets/pane.test.tsx +2 -198
- package/src/plugins/prediction-markets/plugin.test.tsx +2 -2
- package/src/plugins/prediction-markets/services/fetch.ts +1 -5
- package/src/plugins/prediction-markets/services/kalshi/adapter.ts +299 -0
- package/src/plugins/prediction-markets/services/kalshi/normalize.ts +209 -0
- package/src/plugins/prediction-markets/services/kalshi/types.ts +89 -0
- package/src/plugins/prediction-markets/services/polymarket/adapter.ts +134 -0
- package/src/plugins/prediction-markets/services/polymarket/detail.ts +307 -0
- package/src/plugins/prediction-markets/services/polymarket/normalize.ts +239 -0
- package/src/plugins/prediction-markets/services/polymarket/types.ts +66 -0
- package/src/plugins/prediction-markets/services/polymarket/ws.ts +128 -0
- package/src/plugins/prediction-markets/test-helpers.tsx +12 -76
- package/src/plugins/prediction-markets/types.ts +2 -2
- package/src/plugins/registry/context-menu.ts +36 -0
- package/src/plugins/registry/context.ts +196 -0
- package/src/plugins/registry/contributions.ts +174 -0
- package/src/plugins/registry/index.test.ts +362 -0
- package/src/plugins/registry/index.ts +474 -0
- package/src/plugins/registry/pane-settings.ts +105 -0
- package/src/plugins/registry/plugin-state.ts +123 -0
- package/src/plugins/registry/shared.ts +34 -0
- package/src/plugins/registry/slots.ts +70 -0
- package/src/plugins/runtime/context.tsx +115 -0
- package/src/plugins/runtime/index.test.tsx +328 -0
- package/src/plugins/runtime/index.tsx +111 -0
- package/src/plugins/runtime/state.ts +275 -0
- package/src/plugins/ticker-navigation.test.ts +23 -2
- package/src/plugins/ticker-navigation.ts +9 -3
- package/src/react/input.test.ts +29 -0
- package/src/react/input.ts +9 -0
- package/src/renderers/electrobun/bun/application-menu/click.test.ts +50 -0
- package/src/renderers/electrobun/bun/application-menu/click.ts +58 -0
- package/src/renderers/electrobun/bun/application-menu/index.ts +123 -0
- package/src/renderers/electrobun/bun/context-menu/click.test.ts +67 -0
- package/src/renderers/electrobun/bun/context-menu/normalize.test.ts +52 -0
- package/src/renderers/electrobun/bun/context-menu/normalize.ts +67 -0
- package/src/renderers/electrobun/bun/core-capabilities.ts +3 -0
- package/src/renderers/electrobun/bun/desktop/backend-requests.ts +163 -0
- package/src/renderers/electrobun/bun/desktop/capability-bridge.ts +93 -0
- package/src/renderers/electrobun/bun/desktop/detached-windows.ts +263 -0
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +114 -0
- package/src/renderers/electrobun/bun/desktop/http-fetch.ts +56 -0
- package/src/renderers/electrobun/bun/desktop/initialization.ts +139 -0
- package/src/renderers/electrobun/bun/desktop/plugin-state.ts +92 -0
- package/src/renderers/electrobun/bun/desktop/relaunch.ts +48 -0
- package/src/renderers/electrobun/bun/desktop/rpc-registry.ts +43 -0
- package/src/renderers/electrobun/bun/desktop/state-broadcaster.ts +76 -0
- package/src/renderers/electrobun/bun/desktop/update.ts +162 -0
- package/src/renderers/electrobun/bun/desktop/window-events.ts +49 -0
- package/src/renderers/electrobun/bun/desktop/workspace/index.test.ts +63 -0
- package/src/renderers/electrobun/bun/desktop/workspace/index.ts +180 -0
- package/src/renderers/electrobun/bun/desktop/workspace/requests.ts +97 -0
- package/src/renderers/electrobun/bun/index.ts +191 -947
- package/src/renderers/electrobun/bun/tui-entry.ts +6 -0
- package/src/renderers/electrobun/bun/window/focus.ts +37 -0
- package/src/renderers/electrobun/bun/window/frame.test.ts +40 -0
- package/src/renderers/electrobun/shared/protocol.ts +9 -2
- package/src/renderers/electrobun/view/app-services.ts +4 -375
- package/src/renderers/electrobun/view/backend-rpc.ts +5 -0
- package/src/renderers/electrobun/view/build-assets.ts +117 -0
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +398 -0
- package/src/renderers/electrobun/view/config-host.ts +1 -1
- package/src/renderers/electrobun/view/context-menu.test.ts +10 -4
- package/src/renderers/electrobun/view/context-menu.ts +1 -1
- package/src/renderers/electrobun/view/data-table/dom.ts +211 -0
- package/src/renderers/electrobun/view/data-table/index.tsx +358 -0
- package/src/renderers/electrobun/view/data-table/row.tsx +335 -0
- package/src/renderers/electrobun/view/desktop/control-styles.ts +77 -0
- package/src/renderers/electrobun/view/desktop/controls.tsx +421 -0
- package/src/renderers/electrobun/view/desktop/list-view.tsx +200 -0
- package/src/renderers/electrobun/view/desktop/window/bridge.ts +70 -0
- package/src/renderers/electrobun/view/desktop/window/snapshot.test.ts +57 -0
- package/src/renderers/electrobun/view/desktop/window/snapshot.ts +41 -0
- package/src/renderers/electrobun/view/fatal-screen.tsx +118 -0
- package/src/renderers/electrobun/view/host/box.tsx +160 -0
- package/src/renderers/electrobun/view/host/chart-surface.tsx +142 -0
- package/src/renderers/electrobun/view/host/input.tsx +294 -0
- package/src/renderers/electrobun/view/host/mouse.ts +139 -0
- package/src/renderers/electrobun/view/host/native.ts +49 -0
- package/src/renderers/electrobun/view/host/scroll-box.tsx +276 -0
- package/src/renderers/electrobun/view/host/style.ts +124 -0
- package/src/renderers/electrobun/view/host/tabs.tsx +255 -0
- package/src/renderers/electrobun/view/host/text.tsx +121 -0
- package/src/renderers/electrobun/view/http-fetch.ts +1 -1
- package/src/renderers/electrobun/view/input-host.tsx +12 -1
- package/src/renderers/electrobun/view/main.tsx +45 -26
- package/src/renderers/electrobun/view/native-stubs/backend-rpc.ts +59 -0
- package/src/renderers/electrobun/view/native-stubs/chart/kitty-support.ts +9 -0
- package/src/renderers/electrobun/view/remote/asset-data-client.ts +201 -0
- package/src/renderers/electrobun/view/remote/persistence.ts +158 -0
- package/src/renderers/electrobun/view/remote/ticker-repository.ts +26 -0
- package/src/renderers/electrobun/view/styles.css +91 -4
- package/src/renderers/electrobun/view/ui-host.tsx +22 -1469
- package/src/renderers/opentui/chart-surface.tsx +4 -5
- package/src/renderers/opentui/host.tsx +30 -4
- package/src/renderers/opentui/image/loader.test.ts +25 -0
- package/src/renderers/opentui/image/loader.ts +105 -0
- package/src/renderers/opentui/image/surface.tsx +266 -0
- package/src/renderers/opentui/input-host.tsx +12 -1
- package/src/renderers/opentui/start.tsx +2 -2
- package/src/renderers/opentui/test-utils.tsx +2 -2
- package/src/renderers/opentui/ui-host.tsx +1 -1
- package/src/sources/gloomberb-cloud/index.test.ts +660 -0
- package/src/sources/gloomberb-cloud/index.ts +444 -0
- package/src/sources/gloomberb-cloud/news.ts +127 -0
- package/src/sources/gloomberb-cloud/normalizers.ts +354 -0
- package/src/sources/provider-errors.ts +8 -2
- package/src/sources/provider-router/batches.ts +170 -0
- package/src/sources/provider-router/brokers.ts +114 -0
- package/src/sources/provider-router/cache.ts +171 -0
- package/src/sources/provider-router/cached-financials.test.ts +498 -0
- package/src/sources/provider-router/document-routes.ts +153 -0
- package/src/sources/provider-router/financial-routes.ts +225 -0
- package/src/sources/provider-router/financials.ts +259 -0
- package/src/sources/provider-router/history.test.ts +383 -0
- package/src/sources/provider-router/history.ts +448 -0
- package/src/sources/provider-router/index.test.ts +1438 -0
- package/src/sources/provider-router/index.ts +389 -0
- package/src/sources/provider-router/news.ts +36 -0
- package/src/sources/provider-router/primary.ts +164 -0
- package/src/sources/provider-router/route-types.ts +34 -0
- package/src/sources/provider-router/routing.ts +58 -0
- package/src/sources/provider-router/search.ts +183 -0
- package/src/sources/provider-router/sources.ts +55 -0
- package/src/sources/provider-router/streaming.ts +92 -0
- package/src/sources/provider-router/supplemental.ts +373 -0
- package/src/sources/provider-router/test-support.ts +136 -0
- package/src/sources/sec-edgar/content.ts +211 -0
- package/src/sources/sec-edgar.ts +9 -217
- package/src/sources/yahoo-finance/financials.ts +339 -0
- package/src/sources/yahoo-finance/history.ts +106 -0
- package/src/sources/yahoo-finance/http.ts +100 -0
- package/src/sources/yahoo-finance/mappers.ts +409 -0
- package/src/sources/yahoo-finance/options.ts +134 -0
- package/src/sources/yahoo-finance/quote-summary.ts +210 -0
- package/src/sources/yahoo-finance/requests.ts +192 -0
- package/src/sources/yahoo-finance/snapshots.ts +236 -0
- package/src/sources/yahoo-finance/symbols.ts +102 -0
- package/src/sources/yahoo-finance/types.ts +167 -0
- package/src/sources/yahoo-finance.test.ts +116 -12
- package/src/sources/yahoo-finance.ts +115 -1408
- package/src/state/app/activity.test.ts +41 -0
- package/src/state/app/activity.ts +106 -0
- package/src/state/app/bootstrap.test.ts +498 -0
- package/src/state/app/bootstrap.ts +412 -0
- package/src/state/app/context/index.test.ts +564 -0
- package/src/state/app/context/index.test.tsx +193 -0
- package/src/state/app/context/index.tsx +476 -0
- package/src/state/app/context/selector.test.tsx +291 -0
- package/src/state/config-save-scheduler.ts +2 -6
- package/src/state/hooks/inline-tickers.test.tsx +123 -0
- package/src/state/hooks/inline-tickers.ts +212 -0
- package/src/state/hooks/quote-streaming.test.ts +31 -0
- package/src/state/hooks/quote-streaming.test.tsx +70 -0
- package/src/state/hooks/quote-streaming.ts +92 -0
- package/src/state/hooks/session-snapshot.ts +99 -0
- package/src/state/pane-scroll-registry.tsx +1 -1
- package/src/state/selectors-ui.ts +1 -1
- package/src/state/selectors.ts +1 -1
- package/src/test-support/plugin-persistence.ts +112 -0
- package/src/test-support/plugin-runtime.ts +2 -1
- package/src/theme/colors.ts +23 -9
- package/src/theme/themes.test.ts +15 -0
- package/src/tickers/list.test.ts +16 -0
- package/src/tickers/open-target.ts +77 -0
- package/src/tickers/search/index.test.ts +252 -0
- package/src/tickers/search/index.ts +367 -0
- package/src/tickers/search/ranking.ts +387 -0
- package/src/tickers/search/result.ts +27 -0
- package/src/tickers/search/types.ts +41 -0
- package/src/tickers/search/upsert.ts +91 -0
- package/src/tickers/tokenizer.test.ts +31 -0
- package/src/tickers/tokenizer.ts +37 -0
- package/src/types/broker.ts +12 -4
- package/src/types/config.ts +42 -23
- package/src/types/context-menu.ts +1 -1
- package/src/types/data-provider.ts +2 -2
- package/src/types/desktop-window.ts +1 -1
- package/src/types/financials.ts +109 -4
- package/src/types/news-source.ts +0 -1
- package/src/types/persistence.ts +1 -1
- package/src/types/plugin.ts +37 -21
- package/src/types/ticker.ts +1 -0
- package/src/types/trading.ts +23 -1
- package/src/ui/context-menu.tsx +6 -5
- package/src/ui/dialog.tsx +6 -3
- package/src/ui/host.tsx +10 -10
- package/src/ui/index.tsx +14 -33
- package/src/updater/github-releases.test.ts +41 -0
- package/src/updater/github-releases.ts +73 -0
- package/src/updater.test.ts +21 -0
- package/src/updater.ts +10 -3
- package/src/utils/back-navigation.ts +2 -2
- package/src/utils/cli-output.ts +4 -4
- package/src/utils/currency-units.test.ts +23 -1
- package/src/utils/currency-units.ts +56 -0
- package/src/utils/datetime-format.ts +40 -0
- package/src/utils/dom-screenshot.ts +2 -2
- package/src/utils/double-escape-close.ts +1 -1
- package/src/utils/exchanges.ts +2 -2
- package/src/utils/format.ts +0 -7
- package/src/utils/fuzzy-search.ts +1 -1
- package/src/utils/inline-content-tokenizer.test.ts +11 -2
- package/src/utils/inline-content-tokenizer.ts +33 -12
- package/src/utils/keyboard.ts +1 -1
- package/src/utils/link-tokenizer.ts +2 -2
- package/src/utils/options.ts +1 -1
- package/src/utils/price-history.test.ts +20 -0
- package/src/utils/price-history.ts +24 -2
- package/src/utils/relative-time.ts +8 -0
- package/src/utils/selection-clipboard.ts +1 -1
- package/src/utils/shortcut-labels.ts +2 -2
- package/src/utils/sort-values.ts +17 -0
- package/src/utils/terminal-input-reset.ts +1 -1
- package/src/utils/text-wrap.ts +20 -0
- package/src/version.ts +1 -1
- package/src/components/chart/chart-controller.test.ts +0 -110
- package/src/components/chart/chart-controller.ts +0 -650
- package/src/components/chart/chart-data.ts +0 -350
- package/src/components/chart/chart-indicator-selector.tsx +0 -75
- package/src/components/chart/chart-pane-settings.ts +0 -37
- package/src/components/chart/chart-renderer.ts +0 -1562
- package/src/components/chart/chart-resolution.test.ts +0 -87
- package/src/components/chart/chart-resolution.ts +0 -405
- package/src/components/chart/chart-scroll.test.ts +0 -70
- package/src/components/chart/chart-scroll.ts +0 -104
- package/src/components/chart/chart-types.ts +0 -119
- package/src/components/chart/chart-viewport.test.ts +0 -29
- package/src/components/chart/chart-viewport.ts +0 -50
- package/src/components/chart/chart.test.ts +0 -922
- package/src/components/chart/comparison-chart-data.test.ts +0 -105
- package/src/components/chart/comparison-chart-data.ts +0 -292
- package/src/components/chart/comparison-chart-renderer.test.ts +0 -187
- package/src/components/chart/comparison-chart-renderer.ts +0 -437
- package/src/components/chart/native/kitty-adapter.ts +0 -9
- package/src/components/chart/native/kitty-manager.ts +0 -142
- package/src/components/chart/native/kitty-support.ts +0 -71
- package/src/components/chart/native/kitty.test.ts +0 -728
- package/src/components/chart/native/surface-manager.ts +0 -225
- package/src/components/chart/native/surface-sync.ts +0 -34
- package/src/components/chart/native/surface-visibility.ts +0 -48
- package/src/components/chart/static-chart-surface.test.tsx +0 -51
- package/src/components/chart/static-chart-surface.tsx +0 -217
- package/src/components/chart/stock-chart-renderer-switch.test.tsx +0 -1323
- package/src/components/chart/stock-chart.test.ts +0 -330
- package/src/components/chart/stock-chart.tsx +0 -4148
- package/src/components/command-bar/__snapshots__/command-bar.test.tsx.snap +0 -109
- package/src/components/command-bar/command-bar.test.tsx +0 -3244
- package/src/components/command-bar/command-bar.tsx +0 -5868
- package/src/components/command-bar/command-registry.ts +0 -267
- package/src/components/command-bar/confirm-body.tsx +0 -51
- package/src/components/command-bar/list-model.ts +0 -80
- package/src/components/command-bar/pane-template-display.ts +0 -8
- package/src/components/command-bar/root-shortcuts.ts +0 -188
- package/src/components/command-bar/workflow-ops.test.ts +0 -144
- package/src/components/command-bar/workflow-ops.ts +0 -459
- package/src/components/command-bar/workflow-types.ts +0 -127
- package/src/components/data-table-stack-view.test.tsx +0 -241
- package/src/components/data-table-stack-view.tsx +0 -59
- package/src/components/data-table-view.test.tsx +0 -211
- package/src/components/data-table-view.tsx +0 -244
- package/src/components/feed-data-table-stack-view.test.tsx +0 -225
- package/src/components/feed-data-table-stack-view.tsx +0 -359
- package/src/components/layout/pane-content.test.tsx +0 -64
- package/src/components/layout/pane-content.tsx +0 -44
- package/src/components/layout/pane-cycle-order.test.ts +0 -30
- package/src/components/layout/pane-cycle-order.ts +0 -32
- package/src/components/layout/pane-footer.test.tsx +0 -195
- package/src/components/layout/pane-footer.tsx +0 -432
- package/src/components/layout/pane-header.test.tsx +0 -39
- package/src/components/layout/pane-header.tsx +0 -248
- package/src/components/layout/pane-keyboard-scroll.test.tsx +0 -226
- package/src/components/layout/pane-sizing.ts +0 -34
- package/src/components/layout/pane-title.ts +0 -38
- package/src/components/layout/pane.tsx +0 -129
- package/src/components/layout/shell.test.tsx +0 -1427
- package/src/components/layout/shell.tsx +0 -1912
- package/src/components/price-sparkline-view.tsx +0 -463
- package/src/components/price-sparkline.ts +0 -46
- package/src/components/speedometer-gauge.test.tsx +0 -45
- package/src/components/speedometer-gauge.tsx +0 -562
- package/src/components/ticker-badge-list.tsx +0 -53
- package/src/components/ticker-badge-text.test.tsx +0 -253
- package/src/components/ticker-badge-text.tsx +0 -113
- package/src/components/ticker-badge.tsx +0 -109
- package/src/components/ticker-list-table-view.tsx +0 -233
- package/src/components/ticker-list-table.test.tsx +0 -210
- package/src/components/ticker-list-table.tsx +0 -458
- package/src/components/ui/data-table.tsx +0 -522
- package/src/components/ui/multi-select-dialog.tsx +0 -336
- package/src/core/state/app-state.ts +0 -1009
- package/src/data/config-layout.ts +0 -225
- package/src/data/config-store-node.ts +0 -478
- package/src/data/config-store.test.ts +0 -481
- package/src/data/config-store.ts +0 -64
- package/src/data/sqlite-cache.test.ts +0 -151
- package/src/data/sqlite-database.ts +0 -68
- package/src/data/sqlite-json.ts +0 -16
- package/src/data/sqlite-retry.test.ts +0 -63
- package/src/market-data/coordinator-subscriptions.test.ts +0 -209
- package/src/market-data/coordinator.test.ts +0 -830
- package/src/market-data/coordinator.ts +0 -1155
- package/src/plugins/builtin/ai/screener-contract.test.ts +0 -117
- package/src/plugins/builtin/ai/screener-contract.ts +0 -174
- package/src/plugins/builtin/ai/screener-pane.test.tsx +0 -348
- package/src/plugins/builtin/ai/screener-pane.tsx +0 -1118
- package/src/plugins/builtin/ai/utils.ts +0 -1
- package/src/plugins/builtin/ask-ai.test.tsx +0 -348
- package/src/plugins/builtin/chat-controller.test.ts +0 -1376
- package/src/plugins/builtin/chat-controller.ts +0 -1248
- package/src/plugins/builtin/chat.test.tsx +0 -2245
- package/src/plugins/builtin/chat.tsx +0 -2267
- package/src/plugins/builtin/cloud-auth-actions.tsx +0 -72
- package/src/plugins/builtin/cloud-tweets.tsx +0 -896
- package/src/plugins/builtin/comparison-chart.test.tsx +0 -532
- package/src/plugins/builtin/comparison-chart.tsx +0 -194
- package/src/plugins/builtin/debug.tsx +0 -365
- package/src/plugins/builtin/earnings/earnings-cache.test.ts +0 -181
- package/src/plugins/builtin/earnings/earnings-cache.ts +0 -145
- package/src/plugins/builtin/earnings/earnings-data.test.ts +0 -90
- package/src/plugins/builtin/earnings/earnings-data.ts +0 -115
- package/src/plugins/builtin/fear-greed/fear-greed-data.test.ts +0 -72
- package/src/plugins/builtin/fear-greed/fear-greed-data.ts +0 -366
- package/src/plugins/builtin/help.test.tsx +0 -166
- package/src/plugins/builtin/help.tsx +0 -450
- package/src/plugins/builtin/layout-manager.tsx +0 -247
- package/src/plugins/builtin/manual-entry.tsx +0 -25
- package/src/plugins/builtin/news-wire/breaking-notifications.test.ts +0 -98
- package/src/plugins/builtin/news-wire/breaking-notifications.ts +0 -110
- package/src/plugins/builtin/news-wire/breaking-pane.test.tsx +0 -156
- package/src/plugins/builtin/news-wire/breaking-pane.tsx +0 -68
- package/src/plugins/builtin/news-wire/categories.ts +0 -114
- package/src/plugins/builtin/news-wire/default-feeds.ts +0 -3
- package/src/plugins/builtin/news-wire/feed-config.test.ts +0 -90
- package/src/plugins/builtin/news-wire/feed-config.ts +0 -216
- package/src/plugins/builtin/news-wire/index.tsx +0 -129
- package/src/plugins/builtin/news-wire/industry-pane.tsx +0 -126
- package/src/plugins/builtin/news-wire/news-detail-view.tsx +0 -299
- package/src/plugins/builtin/news-wire/news-footer.ts +0 -28
- package/src/plugins/builtin/news-wire/news-preset-pane.tsx +0 -98
- package/src/plugins/builtin/news-wire/news-query-presets.ts +0 -40
- package/src/plugins/builtin/news-wire/news-table.test.tsx +0 -206
- package/src/plugins/builtin/news-wire/news-table.tsx +0 -296
- package/src/plugins/builtin/news-wire/persisted-articles.ts +0 -98
- package/src/plugins/builtin/news-wire/read-state.ts +0 -76
- package/src/plugins/builtin/news-wire/rss-parser.test.ts +0 -184
- package/src/plugins/builtin/news-wire/rss-parser.ts +0 -213
- package/src/plugins/builtin/news-wire/rss-source.test.ts +0 -159
- package/src/plugins/builtin/news-wire/rss-source.ts +0 -181
- package/src/plugins/builtin/news.tsx +0 -194
- package/src/plugins/builtin/notes.tsx +0 -561
- package/src/plugins/builtin/options.test.tsx +0 -241
- package/src/plugins/builtin/options.tsx +0 -542
- package/src/plugins/builtin/portfolio-list/cli/commands.ts +0 -657
- package/src/plugins/builtin/portfolio-list/pane.tsx +0 -724
- package/src/plugins/builtin/portfolio-list/quick-add.tsx +0 -422
- package/src/plugins/builtin/portfolio-list/summary.tsx +0 -275
- package/src/plugins/builtin/portfolio-list.test.ts +0 -133
- package/src/plugins/builtin/portfolio-list.test.tsx +0 -1535
- package/src/plugins/builtin/portfolio-metrics.test.ts +0 -236
- package/src/plugins/builtin/quote-monitor.test.tsx +0 -222
- package/src/plugins/builtin/sec-filing-display.tsx +0 -84
- package/src/plugins/builtin/sec.tsx +0 -342
- package/src/plugins/builtin/ticker-detail/financials-tab.tsx +0 -461
- package/src/plugins/builtin/ticker-detail/quote-monitor.tsx +0 -479
- package/src/plugins/builtin/ticker-detail-chart-tab-switch.test.tsx +0 -269
- package/src/plugins/builtin/ticker-detail.test.tsx +0 -888
- package/src/plugins/builtin/ticker-surface.ts +0 -68
- package/src/plugins/builtin/yahoo.ts +0 -72
- package/src/plugins/catalog-ui.test.ts +0 -24
- package/src/plugins/ibkr/__snapshots__/trade-tab.test.tsx.snap +0 -35
- package/src/plugins/ibkr/flex.test.ts +0 -162
- package/src/plugins/ibkr/flex.ts +0 -371
- package/src/plugins/ibkr/gateway-helpers.ts +0 -33
- package/src/plugins/ibkr/gateway-selection.ts +0 -51
- package/src/plugins/ibkr/gateway-service-native.ts +0 -2377
- package/src/plugins/ibkr/gateway-service.test.ts +0 -584
- package/src/plugins/ibkr/gateway-service.ts +0 -433
- package/src/plugins/ibkr/gateway-types.ts +0 -27
- package/src/plugins/ibkr/price-normalization.test.ts +0 -33
- package/src/plugins/ibkr/price-normalization.ts +0 -60
- package/src/plugins/ibkr/trade-badge.tsx +0 -28
- package/src/plugins/ibkr/trade-tab.test.tsx +0 -276
- package/src/plugins/ibkr/trade-tab.tsx +0 -1117
- package/src/plugins/ibkr/trade-utils.test.ts +0 -175
- package/src/plugins/ibkr/trade-utils.ts +0 -150
- package/src/plugins/ibkr/trading-pane.tsx +0 -474
- package/src/plugins/ibkr/trading-state.test.ts +0 -109
- package/src/plugins/ibkr/trading-state.ts +0 -339
- package/src/plugins/plugin-runtime.test.tsx +0 -323
- package/src/plugins/plugin-runtime.tsx +0 -433
- package/src/plugins/prediction-markets/controller-data.ts +0 -785
- package/src/plugins/prediction-markets/controller.ts +0 -659
- package/src/plugins/prediction-markets/services/kalshi-adapter.ts +0 -572
- package/src/plugins/prediction-markets/services/polymarket-adapter.ts +0 -696
- package/src/plugins/prediction-markets/services/polymarket-ws.ts +0 -128
- package/src/plugins/registry.test.ts +0 -362
- package/src/plugins/registry.ts +0 -854
- package/src/renderers/electrobun/bun/application-menu-click.test.ts +0 -50
- package/src/renderers/electrobun/bun/application-menu-click.ts +0 -58
- package/src/renderers/electrobun/bun/application-menu.ts +0 -123
- package/src/renderers/electrobun/bun/context-menu-click.test.ts +0 -67
- package/src/renderers/electrobun/bun/context-menu-normalize.test.ts +0 -52
- package/src/renderers/electrobun/bun/context-menu-normalize.ts +0 -67
- package/src/renderers/electrobun/bun/desktop-workspace.test.ts +0 -63
- package/src/renderers/electrobun/bun/desktop-workspace.ts +0 -180
- package/src/renderers/electrobun/bun/window-focus.ts +0 -37
- package/src/renderers/electrobun/bun/window-frame.test.ts +0 -40
- package/src/renderers/electrobun/view/data-table.tsx +0 -810
- package/src/renderers/electrobun/view/desktop-controls.tsx +0 -673
- package/src/renderers/electrobun/view/desktop-window-bridge.ts +0 -70
- package/src/renderers/electrobun/view/desktop-window-snapshot.test.ts +0 -57
- package/src/renderers/electrobun/view/desktop-window-snapshot.ts +0 -41
- package/src/renderers/electrobun/view/native-stubs/chart-kitty-support.ts +0 -9
- package/src/renderers/opentui/image-loader.test.ts +0 -25
- package/src/renderers/opentui/image-loader.ts +0 -105
- package/src/renderers/opentui/image-surface.tsx +0 -266
- package/src/sources/gloomberb-cloud.test.ts +0 -637
- package/src/sources/gloomberb-cloud.ts +0 -828
- package/src/sources/provider-router.test.ts +0 -2600
- package/src/sources/provider-router.ts +0 -2231
- package/src/state/app-activity.test.ts +0 -41
- package/src/state/app-activity.ts +0 -106
- package/src/state/app-bootstrap.test.ts +0 -498
- package/src/state/app-bootstrap.ts +0 -411
- package/src/state/app-context-selector.test.tsx +0 -369
- package/src/state/app-context.test.ts +0 -670
- package/src/state/app-context.test.tsx +0 -193
- package/src/state/app-context.tsx +0 -485
- package/src/state/use-inline-tickers.test.tsx +0 -73
- package/src/state/use-inline-tickers.ts +0 -188
- package/src/state/use-quote-streaming.test.ts +0 -31
- package/src/state/use-quote-streaming.test.tsx +0 -70
- package/src/state/use-quote-streaming.ts +0 -92
- package/src/state/use-session-snapshot.ts +0 -99
- package/src/utils/api-client.test.ts +0 -603
- package/src/utils/api-client.ts +0 -1379
- package/src/utils/market-format.test.ts +0 -109
- package/src/utils/market-format.ts +0 -299
- package/src/utils/market-status.ts +0 -141
- package/src/utils/quote-freshness.test.ts +0 -150
- package/src/utils/quote-freshness.ts +0 -145
- package/src/utils/quote-resolution.test.ts +0 -277
- package/src/utils/quote-resolution.ts +0 -642
- package/src/utils/quote-time.test.ts +0 -34
- package/src/utils/quote-time.ts +0 -59
- package/src/utils/ticker-list.test.ts +0 -16
- package/src/utils/ticker-search.test.ts +0 -227
- package/src/utils/ticker-search.ts +0 -855
- package/src/utils/ticker-tokenizer.test.ts +0 -31
- package/src/utils/ticker-tokenizer.ts +0 -37
- /package/src/components/chart/native/{kitty-protocol.ts → kitty/protocol.ts} +0 -0
- /package/src/components/ui/{multi-select.ts → multi-select/index.ts} +0 -0
- /package/src/data/{sqlite-retry.ts → sqlite/retry.ts} +0 -0
- /package/src/plugins/builtin/{news-wire → news/wire}/hash.ts +0 -0
- /package/src/plugins/builtin/{news-wire → news/wire}/read-state.test.ts +0 -0
- /package/src/plugins/builtin/{notes-files.ts → notes/files.ts} +0 -0
- /package/src/renderers/electrobun/bun/{context-menu-click.ts → context-menu/click.ts} +0 -0
- /package/src/renderers/electrobun/bun/{window-frame.ts → window/frame.ts} +0 -0
- /package/src/renderers/electrobun/view/native-stubs/{chart-surface-manager.ts → chart/surface-manager.ts} +0 -0
- /package/src/renderers/electrobun/view/native-stubs/{chart-surface-sync.ts → chart/surface-sync.ts} +0 -0
- /package/src/{utils/ticker-list.ts → tickers/list.ts} +0 -0
- /package/src/{utils/ticker-metadata.ts → tickers/metadata.ts} +0 -0
package/src/utils/api-client.ts
DELETED
|
@@ -1,1379 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AnalystResearchData,
|
|
3
|
-
CompanyProfile,
|
|
4
|
-
CorporateActionsData,
|
|
5
|
-
Fundamentals,
|
|
6
|
-
HolderData,
|
|
7
|
-
HolderRecord,
|
|
8
|
-
OptionsChain,
|
|
9
|
-
PricePoint,
|
|
10
|
-
Quote,
|
|
11
|
-
TickerFinancials,
|
|
12
|
-
} from "../types/financials";
|
|
13
|
-
import type { InstrumentSearchResult } from "../types/instrument";
|
|
14
|
-
import { debugLog } from "./debug-log";
|
|
15
|
-
import { canonicalExchange, normalizeSymbol, publicTickerKey } from "./exchanges";
|
|
16
|
-
import { httpFetch } from "./http-transport";
|
|
17
|
-
import { normalizeTimestamp } from "./timestamp";
|
|
18
|
-
|
|
19
|
-
const DEFAULT_API_URL = "https://api.gloom.sh";
|
|
20
|
-
const SESSION_COOKIE_NAMES = ["__Secure-gloomberb.session_token", "gloomberb.session_token"] as const;
|
|
21
|
-
const QUOTE_SUBSCRIPTION_FLUSH_MS = 25;
|
|
22
|
-
const cloudApiLog = debugLog.createLogger("cloud-api");
|
|
23
|
-
const HARD_SESSION_INVALID_PATTERNS = [
|
|
24
|
-
/\b(user|account)\b.*\b(not found|deleted|removed|disabled|deactivated|suspended)\b/i,
|
|
25
|
-
/\b(user|account)\b.*\bdoes(?:\s+not|n't)\s+exist\b/i,
|
|
26
|
-
/\b(no|unknown|missing)\s+(user|account)\b/i,
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
type CloudApiResponse = Pick<Response, "ok" | "status" | "headers" | "text">;
|
|
30
|
-
type CloudApiFetchTransport = (url: string, init?: RequestInit) => Promise<CloudApiResponse>;
|
|
31
|
-
|
|
32
|
-
let cloudApiFetchTransport: CloudApiFetchTransport = httpFetch;
|
|
33
|
-
|
|
34
|
-
export function setCloudApiFetchTransport(transport: CloudApiFetchTransport | null): void {
|
|
35
|
-
cloudApiFetchTransport = transport ?? httpFetch;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function getCloudApiBaseUrl(): string {
|
|
39
|
-
if (typeof process === "undefined") {
|
|
40
|
-
return DEFAULT_API_URL;
|
|
41
|
-
}
|
|
42
|
-
return process.env.GLOOMBERB_API_URL ?? DEFAULT_API_URL;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface ChatMessage {
|
|
46
|
-
id: string;
|
|
47
|
-
channelId: string;
|
|
48
|
-
content: string;
|
|
49
|
-
replyToId: string | null;
|
|
50
|
-
createdAt: string;
|
|
51
|
-
user: { id: string; username: string; displayName: string };
|
|
52
|
-
replyTo?: { content: string; user: { id?: string; username: string } } | null;
|
|
53
|
-
clientStatus?: "sending" | "failed";
|
|
54
|
-
clientError?: string | null;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface ChatChannel {
|
|
58
|
-
id: string;
|
|
59
|
-
name: string;
|
|
60
|
-
created_at: string;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export interface ChatChannelState {
|
|
64
|
-
channelId: string;
|
|
65
|
-
notificationsEnabled: boolean;
|
|
66
|
-
lastReadMessageId: string | null;
|
|
67
|
-
unreadCount: number;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface ChatNotification {
|
|
71
|
-
id: string;
|
|
72
|
-
type: "reply" | "mention" | "channel";
|
|
73
|
-
channelId: string;
|
|
74
|
-
messageId: string;
|
|
75
|
-
createdAt: string;
|
|
76
|
-
message: ChatMessage;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export interface ChatStateResponse {
|
|
80
|
-
channels: ChatChannel[];
|
|
81
|
-
onlineCount: number;
|
|
82
|
-
channelStates: ChatChannelState[];
|
|
83
|
-
notifications: ChatNotification[];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export interface AuthUser {
|
|
87
|
-
id: string;
|
|
88
|
-
name: string;
|
|
89
|
-
email: string;
|
|
90
|
-
username: string | null;
|
|
91
|
-
emailVerified: boolean;
|
|
92
|
-
image: string | null;
|
|
93
|
-
createdAt: string;
|
|
94
|
-
updatedAt: string;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export type PersistedAuthUser = Pick<AuthUser, "id" | "emailVerified"> & Partial<AuthUser>;
|
|
98
|
-
|
|
99
|
-
export interface CloudQuotePayload extends Quote {
|
|
100
|
-
providerId: "gloomberb-cloud";
|
|
101
|
-
dataSource: "live" | "delayed";
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export interface CloudOptionsChainPayload extends OptionsChain {
|
|
105
|
-
providerId: "gloomberb-cloud";
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export interface CloudCompanyProfile extends CompanyProfile {}
|
|
109
|
-
|
|
110
|
-
export interface CloudFundamentals extends Fundamentals {}
|
|
111
|
-
|
|
112
|
-
export interface CloudHolderPayload extends HolderRecord {
|
|
113
|
-
providerId: "gloomberb-cloud";
|
|
114
|
-
ownerType: "institution";
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export interface CloudHoldersPayload extends HolderData {
|
|
118
|
-
providerId: "gloomberb-cloud";
|
|
119
|
-
holders: CloudHolderPayload[];
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export interface CloudAnalystResearchPayload extends AnalystResearchData {
|
|
123
|
-
providerId: "gloomberb-cloud";
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export interface CloudCorporateActionsPayload extends CorporateActionsData {
|
|
127
|
-
providerId: "gloomberb-cloud";
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export interface CloudPricePointPayload {
|
|
131
|
-
date: string;
|
|
132
|
-
open?: number;
|
|
133
|
-
high?: number;
|
|
134
|
-
low?: number;
|
|
135
|
-
close: number;
|
|
136
|
-
volume?: number;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export type CloudEconImpact = "high" | "medium" | "low";
|
|
140
|
-
|
|
141
|
-
export interface CloudEconEventPayload {
|
|
142
|
-
id: string;
|
|
143
|
-
date: string;
|
|
144
|
-
time: string;
|
|
145
|
-
country: string;
|
|
146
|
-
event: string;
|
|
147
|
-
actual: string | null;
|
|
148
|
-
forecast: string | null;
|
|
149
|
-
prior: string | null;
|
|
150
|
-
impact: CloudEconImpact;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export interface CloudFredObservationPayload {
|
|
154
|
-
date: string;
|
|
155
|
-
value: number | null;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export interface CloudFredSeriesInfoPayload {
|
|
159
|
-
id: string;
|
|
160
|
-
title: string;
|
|
161
|
-
units: string;
|
|
162
|
-
frequency: string;
|
|
163
|
-
seasonalAdjustment: string;
|
|
164
|
-
source: string;
|
|
165
|
-
notes: string;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export interface CloudFredSeriesPayload {
|
|
169
|
-
observations: CloudFredObservationPayload[];
|
|
170
|
-
info: CloudFredSeriesInfoPayload | null;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export interface CloudYieldPointPayload {
|
|
174
|
-
maturity: string;
|
|
175
|
-
maturityYears: number;
|
|
176
|
-
yield: number | null;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export interface CloudNewsEntityPayload {
|
|
180
|
-
id: string;
|
|
181
|
-
entityType: string;
|
|
182
|
-
name: string;
|
|
183
|
-
symbol: string | null;
|
|
184
|
-
exchange: string | null;
|
|
185
|
-
canonicalTicker: string | null;
|
|
186
|
-
role: string | null;
|
|
187
|
-
confidence: number | null;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export interface CloudNewsTickerLinkPayload {
|
|
191
|
-
symbol: string;
|
|
192
|
-
exchange: string;
|
|
193
|
-
canonicalTicker: string;
|
|
194
|
-
relationType: string;
|
|
195
|
-
displayTier: "primary" | "related";
|
|
196
|
-
confidence: number;
|
|
197
|
-
relevanceScore: number;
|
|
198
|
-
impactScore?: number;
|
|
199
|
-
sentiment?: "positive" | "neutral" | "negative" | null;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export interface CloudNewsStoryItemPayload {
|
|
203
|
-
id: string;
|
|
204
|
-
sourceKey: string;
|
|
205
|
-
sourceName: string;
|
|
206
|
-
title: string;
|
|
207
|
-
summary?: string;
|
|
208
|
-
url: string;
|
|
209
|
-
publishedAt: string;
|
|
210
|
-
hasArticleText?: boolean;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
export interface CloudNewsPayload {
|
|
214
|
-
id: string;
|
|
215
|
-
headline: string;
|
|
216
|
-
summary: string;
|
|
217
|
-
topic?: string;
|
|
218
|
-
topics?: string[];
|
|
219
|
-
category: string;
|
|
220
|
-
sentiment: "positive" | "neutral" | "negative";
|
|
221
|
-
sectors: string[];
|
|
222
|
-
scope?: string;
|
|
223
|
-
firstPublishedAt: string;
|
|
224
|
-
lastPublishedAt: string;
|
|
225
|
-
firstSeenAt: string;
|
|
226
|
-
lastSeenAt: string;
|
|
227
|
-
primaryUrl: string;
|
|
228
|
-
primarySource: string;
|
|
229
|
-
scores?: {
|
|
230
|
-
importance?: number;
|
|
231
|
-
urgency?: number;
|
|
232
|
-
marketImpact?: number;
|
|
233
|
-
novelty?: number;
|
|
234
|
-
confidence?: number;
|
|
235
|
-
};
|
|
236
|
-
flags?: {
|
|
237
|
-
breaking?: boolean;
|
|
238
|
-
developing?: boolean;
|
|
239
|
-
stale?: boolean;
|
|
240
|
-
};
|
|
241
|
-
variantCount: number;
|
|
242
|
-
sourceCount: number;
|
|
243
|
-
sources: string[];
|
|
244
|
-
entities: CloudNewsEntityPayload[];
|
|
245
|
-
tickerLinks: CloudNewsTickerLinkPayload[];
|
|
246
|
-
items?: CloudNewsStoryItemPayload[];
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
export interface CloudNewsListResponse {
|
|
250
|
-
items: CloudNewsPayload[];
|
|
251
|
-
nextCursor: string | null;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
export interface CloudTweetUserPayload {
|
|
255
|
-
id: string;
|
|
256
|
-
userName: string;
|
|
257
|
-
name: string;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
export interface CloudTweetMetricsPayload {
|
|
261
|
-
retweets: number | null;
|
|
262
|
-
replies: number | null;
|
|
263
|
-
likes: number | null;
|
|
264
|
-
quotes: number | null;
|
|
265
|
-
views: number | null;
|
|
266
|
-
bookmarks: number | null;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
export interface CloudTweetMediaPayload {
|
|
270
|
-
type?: string;
|
|
271
|
-
url?: string;
|
|
272
|
-
mediaUrl?: string;
|
|
273
|
-
media_url?: string;
|
|
274
|
-
media_url_https?: string;
|
|
275
|
-
previewImageUrl?: string;
|
|
276
|
-
preview_image_url?: string;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
export interface CloudTweetPayload {
|
|
280
|
-
id: string;
|
|
281
|
-
url: string;
|
|
282
|
-
text: string;
|
|
283
|
-
createdAt: string;
|
|
284
|
-
lang: string;
|
|
285
|
-
isReply: boolean;
|
|
286
|
-
author: CloudTweetUserPayload;
|
|
287
|
-
metrics: CloudTweetMetricsPayload;
|
|
288
|
-
media?: CloudTweetMediaPayload[];
|
|
289
|
-
photos?: CloudTweetMediaPayload[];
|
|
290
|
-
images?: CloudTweetMediaPayload[];
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
export type CloudTweetQueryType = "Latest" | "Top";
|
|
294
|
-
|
|
295
|
-
export interface CloudTweetSearchResponse {
|
|
296
|
-
ticker?: string;
|
|
297
|
-
cashtag?: string;
|
|
298
|
-
query: string;
|
|
299
|
-
queryType: CloudTweetQueryType;
|
|
300
|
-
since: string;
|
|
301
|
-
until: string;
|
|
302
|
-
limit: number;
|
|
303
|
-
hours: number;
|
|
304
|
-
includeReplies?: boolean;
|
|
305
|
-
cached: boolean;
|
|
306
|
-
cacheTtlMs: number;
|
|
307
|
-
asOf: string;
|
|
308
|
-
tweets: CloudTweetPayload[];
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
export type CloudMarketStatus =
|
|
312
|
-
| "success"
|
|
313
|
-
| "partial"
|
|
314
|
-
| "empty"
|
|
315
|
-
| "unsupported"
|
|
316
|
-
| "retryable_error"
|
|
317
|
-
| "fatal_error";
|
|
318
|
-
|
|
319
|
-
export interface CloudMarketResponse<T> {
|
|
320
|
-
status: CloudMarketStatus;
|
|
321
|
-
data: T | null;
|
|
322
|
-
reasonCode?: string;
|
|
323
|
-
asOf?: string;
|
|
324
|
-
staleAt?: string;
|
|
325
|
-
stale?: boolean;
|
|
326
|
-
currency?: string;
|
|
327
|
-
providerMeta?: {
|
|
328
|
-
provider?: string;
|
|
329
|
-
upstream?: string;
|
|
330
|
-
status?: CloudMarketStatus;
|
|
331
|
-
reasonCode?: string;
|
|
332
|
-
normalizedSymbol?: string;
|
|
333
|
-
normalizedExchange?: string;
|
|
334
|
-
stale?: boolean;
|
|
335
|
-
fallbackReason?: string;
|
|
336
|
-
requestedResolution?: string;
|
|
337
|
-
servedResolution?: string;
|
|
338
|
-
latencyMs?: number;
|
|
339
|
-
range?: string;
|
|
340
|
-
granularity?: string;
|
|
341
|
-
timezone?: string;
|
|
342
|
-
currency?: string;
|
|
343
|
-
barCount?: number;
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
export interface CloudMarketBatchTarget {
|
|
348
|
-
symbol: string;
|
|
349
|
-
exchange?: string;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
export interface CloudMarketBatchItem<T> {
|
|
353
|
-
symbol: string;
|
|
354
|
-
exchange: string;
|
|
355
|
-
status: CloudMarketStatus;
|
|
356
|
-
data: T | null;
|
|
357
|
-
reasonCode?: string;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
export interface CloudMarketBatchPayload<T> {
|
|
361
|
-
items: Array<CloudMarketBatchItem<T>>;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
export interface CloudVerificationResponse {
|
|
365
|
-
sent: boolean;
|
|
366
|
-
email?: string;
|
|
367
|
-
alreadyVerified?: boolean;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
export interface QuoteStreamTarget {
|
|
371
|
-
symbol: string;
|
|
372
|
-
exchange?: string;
|
|
373
|
-
surface?: "portfolio" | "watchlist" | "detail" | "monitor" | "inline" | "screener" | "unknown";
|
|
374
|
-
visible?: boolean;
|
|
375
|
-
selected?: boolean;
|
|
376
|
-
weight?: number;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
function marketKey(symbol: string, exchange?: string): string {
|
|
380
|
-
const normalizedSymbolValue = normalizeSymbol(symbol);
|
|
381
|
-
const normalizedExchangeValue = canonicalExchange(exchange);
|
|
382
|
-
return normalizedExchangeValue ? `${normalizedSymbolValue}:${normalizedExchangeValue}` : normalizedSymbolValue;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
function normalizeChatMessage(message: ChatMessage): ChatMessage {
|
|
386
|
-
return {
|
|
387
|
-
...message,
|
|
388
|
-
createdAt: normalizeTimestamp(message.createdAt),
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
function normalizeChatMessages(messages: ChatMessage[]): ChatMessage[] {
|
|
393
|
-
return messages.map((message) => normalizeChatMessage(message));
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
function normalizeChatNotification(notification: ChatNotification): ChatNotification {
|
|
397
|
-
return {
|
|
398
|
-
...notification,
|
|
399
|
-
createdAt: normalizeTimestamp(notification.createdAt),
|
|
400
|
-
message: normalizeChatMessage(notification.message),
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
function normalizeChatState(response: ChatStateResponse): ChatStateResponse {
|
|
405
|
-
return {
|
|
406
|
-
...response,
|
|
407
|
-
notifications: response.notifications.map(normalizeChatNotification),
|
|
408
|
-
};
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
function normalizeTweet(tweet: CloudTweetPayload): CloudTweetPayload {
|
|
412
|
-
return {
|
|
413
|
-
...tweet,
|
|
414
|
-
createdAt: normalizeTimestamp(tweet.createdAt),
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
function normalizeTweetSearchResponse(response: CloudTweetSearchResponse): CloudTweetSearchResponse {
|
|
419
|
-
return {
|
|
420
|
-
...response,
|
|
421
|
-
since: normalizeTimestamp(response.since),
|
|
422
|
-
until: normalizeTimestamp(response.until),
|
|
423
|
-
asOf: normalizeTimestamp(response.asOf),
|
|
424
|
-
tweets: response.tweets.map(normalizeTweet),
|
|
425
|
-
};
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
type ChannelListener = (message: ChatMessage) => void;
|
|
429
|
-
type ChatNotificationListener = (notification: ChatNotification) => void;
|
|
430
|
-
type ChatPresenceListener = (onlineCount: number) => void;
|
|
431
|
-
type QuoteListener = (target: QuoteStreamTarget, quote: CloudQuotePayload) => void;
|
|
432
|
-
type SessionCookieName = (typeof SESSION_COOKIE_NAMES)[number];
|
|
433
|
-
|
|
434
|
-
class ApiRequestError extends Error {
|
|
435
|
-
constructor(message: string, readonly status?: number) {
|
|
436
|
-
super(message);
|
|
437
|
-
this.name = "ApiRequestError";
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
function parseApiErrorMessage(body: string): string {
|
|
442
|
-
try {
|
|
443
|
-
const parsed = JSON.parse(body) as Record<string, unknown>;
|
|
444
|
-
const parts = [parsed.message, parsed.error, parsed.code, parsed.reason]
|
|
445
|
-
.filter((value): value is string => typeof value === "string" && value.trim().length > 0);
|
|
446
|
-
return parts.join(" ") || body;
|
|
447
|
-
} catch {
|
|
448
|
-
return body;
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
function isHardSessionInvalidMessage(message: string): boolean {
|
|
453
|
-
const normalized = message.replace(/[_-]+/g, " ");
|
|
454
|
-
return HARD_SESSION_INVALID_PATTERNS.some((pattern) => pattern.test(normalized));
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
class GloomApiClient {
|
|
458
|
-
private sessionToken: string | null = null;
|
|
459
|
-
private sessionCookieName: SessionCookieName | null = null;
|
|
460
|
-
private websocketToken: string | null = null;
|
|
461
|
-
private currentUser: AuthUser | null = null;
|
|
462
|
-
private readonly baseUrl: string;
|
|
463
|
-
|
|
464
|
-
private ws: WebSocket | null = null;
|
|
465
|
-
private reconnectTimer: ReturnType<typeof setTimeout> | null = null;
|
|
466
|
-
private reconnectDelayMs = 1000;
|
|
467
|
-
|
|
468
|
-
private readonly channelListeners = new Map<string, Set<ChannelListener>>();
|
|
469
|
-
private readonly chatNotificationListeners = new Set<ChatNotificationListener>();
|
|
470
|
-
private readonly chatPresenceListeners = new Set<ChatPresenceListener>();
|
|
471
|
-
private readonly quoteListeners = new Map<string, Set<QuoteListener>>();
|
|
472
|
-
private readonly quoteTargets = new Map<string, QuoteStreamTarget>();
|
|
473
|
-
private readonly pendingQuoteSubscribes = new Map<string, QuoteStreamTarget>();
|
|
474
|
-
private readonly pendingQuoteUnsubscribes = new Map<string, QuoteStreamTarget>();
|
|
475
|
-
private quoteSubscriptionFlushTimer: ReturnType<typeof setTimeout> | null = null;
|
|
476
|
-
|
|
477
|
-
constructor() {
|
|
478
|
-
this.baseUrl = getCloudApiBaseUrl();
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
getSessionToken(): string | null {
|
|
482
|
-
return this.sessionToken;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
getWebSocketToken(): string | null {
|
|
486
|
-
return this.websocketToken;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
setSessionToken(token: string | null): void {
|
|
490
|
-
if (this.sessionToken !== token) {
|
|
491
|
-
this.sessionCookieName = null;
|
|
492
|
-
}
|
|
493
|
-
this.sessionToken = token;
|
|
494
|
-
if (!token) {
|
|
495
|
-
this.websocketToken = null;
|
|
496
|
-
this.currentUser = null;
|
|
497
|
-
this.teardownSocket();
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
setWebSocketToken(token: string | null): void {
|
|
502
|
-
this.websocketToken = token;
|
|
503
|
-
if (!token) {
|
|
504
|
-
this.teardownSocket();
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
getCurrentUser(): AuthUser | null {
|
|
509
|
-
return this.currentUser;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
restoreCachedUser(user: PersistedAuthUser | null): void {
|
|
513
|
-
if (!this.sessionToken || !user?.id) {
|
|
514
|
-
this.setCurrentUser(null);
|
|
515
|
-
return;
|
|
516
|
-
}
|
|
517
|
-
this.setCurrentUser({
|
|
518
|
-
id: user.id,
|
|
519
|
-
name: typeof user.name === "string" && user.name.length > 0
|
|
520
|
-
? user.name
|
|
521
|
-
: user.username ?? "User",
|
|
522
|
-
email: typeof user.email === "string" ? user.email : "",
|
|
523
|
-
username: typeof user.username === "string" ? user.username : null,
|
|
524
|
-
emailVerified: user.emailVerified === true,
|
|
525
|
-
image: typeof user.image === "string" ? user.image : null,
|
|
526
|
-
createdAt: typeof user.createdAt === "string" ? user.createdAt : "",
|
|
527
|
-
updatedAt: typeof user.updatedAt === "string" ? user.updatedAt : "",
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
isVerified(): boolean {
|
|
532
|
-
return !!this.sessionToken && !!this.currentUser?.emailVerified;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
private setCurrentUser(user: AuthUser | null): void {
|
|
536
|
-
this.currentUser = user;
|
|
537
|
-
if (!this.shouldKeepSocketOpen()) {
|
|
538
|
-
this.teardownSocket();
|
|
539
|
-
return;
|
|
540
|
-
}
|
|
541
|
-
this.ensureSocket();
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
private requireCapturedSession(message: string): void {
|
|
545
|
-
if (this.sessionToken) return;
|
|
546
|
-
this.websocketToken = null;
|
|
547
|
-
this.setCurrentUser(null);
|
|
548
|
-
throw new Error(message);
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
private extractSessionCookie(res: CloudApiResponse): void {
|
|
552
|
-
const setCookie = res.headers.getSetCookie?.() ?? [];
|
|
553
|
-
const fallbackHeader = res.headers.get("set-cookie");
|
|
554
|
-
if (fallbackHeader) {
|
|
555
|
-
setCookie.push(fallbackHeader);
|
|
556
|
-
}
|
|
557
|
-
for (const cookie of setCookie) {
|
|
558
|
-
for (const cookieName of SESSION_COOKIE_NAMES) {
|
|
559
|
-
const escapedCookieName = cookieName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
560
|
-
const match = cookie.match(new RegExp(`${escapedCookieName}=([^;]+)`));
|
|
561
|
-
if (!match) continue;
|
|
562
|
-
this.sessionToken = match[1] ?? null;
|
|
563
|
-
this.sessionCookieName = cookieName;
|
|
564
|
-
return;
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
private buildSessionCookieHeader(): string | null {
|
|
570
|
-
if (!this.sessionToken) return null;
|
|
571
|
-
const cookieNames = this.sessionCookieName ? [this.sessionCookieName] : SESSION_COOKIE_NAMES;
|
|
572
|
-
return cookieNames.map((cookieName) => `${cookieName}=${this.sessionToken}`).join("; ");
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
private setSessionCookieHeader(headers: Headers): void {
|
|
576
|
-
const cookieHeader = this.buildSessionCookieHeader();
|
|
577
|
-
if (cookieHeader) {
|
|
578
|
-
headers.set("Cookie", cookieHeader);
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
private async request<T>(path: string, options?: RequestInit): Promise<T> {
|
|
583
|
-
const headers = new Headers(options?.headers);
|
|
584
|
-
if (!headers.has("Content-Type") && options?.method && options.method !== "GET") {
|
|
585
|
-
headers.set("Content-Type", "application/json");
|
|
586
|
-
}
|
|
587
|
-
this.setSessionCookieHeader(headers);
|
|
588
|
-
headers.set("Origin", this.baseUrl);
|
|
589
|
-
|
|
590
|
-
const res = await cloudApiFetchTransport(`${this.baseUrl}${path}`, {
|
|
591
|
-
...options,
|
|
592
|
-
headers,
|
|
593
|
-
credentials: "include",
|
|
594
|
-
});
|
|
595
|
-
|
|
596
|
-
this.extractSessionCookie(res);
|
|
597
|
-
|
|
598
|
-
if (!res.ok) {
|
|
599
|
-
const body = await res.text();
|
|
600
|
-
const msg = parseApiErrorMessage(body);
|
|
601
|
-
throw new ApiRequestError(msg, res.status);
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
const text = await res.text();
|
|
605
|
-
if (!text) return undefined as T;
|
|
606
|
-
const parsed = JSON.parse(text) as T & { token?: string };
|
|
607
|
-
if (typeof parsed?.token === "string" && parsed.token.length > 0) {
|
|
608
|
-
this.websocketToken = parsed.token;
|
|
609
|
-
}
|
|
610
|
-
return parsed as T;
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
private getWebSocketBaseUrl(): string {
|
|
614
|
-
const wsProtocol = this.baseUrl.startsWith("https") ? "wss" : "ws";
|
|
615
|
-
return this.baseUrl.replace(/^https?/, wsProtocol);
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
private getSocketAuthToken(): string | null {
|
|
619
|
-
return this.websocketToken || this.sessionToken;
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
private shouldKeepSocketOpen(): boolean {
|
|
623
|
-
if (this.quoteTargets.size > 0) return true;
|
|
624
|
-
return !!this.getSocketAuthToken()
|
|
625
|
-
&& !!this.currentUser?.emailVerified
|
|
626
|
-
&& this.channelListeners.size > 0;
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
private ensureSocket(): void {
|
|
630
|
-
if (!this.shouldKeepSocketOpen() || this.ws || this.reconnectTimer) return;
|
|
631
|
-
|
|
632
|
-
const socketToken = this.getSocketAuthToken();
|
|
633
|
-
const usingWebSocketToken = !!this.websocketToken;
|
|
634
|
-
const url = socketToken
|
|
635
|
-
? `${this.getWebSocketBaseUrl()}/cloud/ws?token=${encodeURIComponent(socketToken)}`
|
|
636
|
-
: `${this.getWebSocketBaseUrl()}/cloud/ws`;
|
|
637
|
-
cloudApiLog.info("open websocket", {
|
|
638
|
-
hasToken: !!socketToken,
|
|
639
|
-
tokenSource: usingWebSocketToken ? "websocket" : "session",
|
|
640
|
-
quoteTargets: this.quoteTargets.size,
|
|
641
|
-
channelTargets: this.channelListeners.size,
|
|
642
|
-
});
|
|
643
|
-
const ws = new WebSocket(url);
|
|
644
|
-
this.ws = ws;
|
|
645
|
-
|
|
646
|
-
ws.onopen = () => {
|
|
647
|
-
if (this.ws !== ws) return;
|
|
648
|
-
cloudApiLog.info("websocket open");
|
|
649
|
-
this.reconnectDelayMs = 1000;
|
|
650
|
-
this.flushSubscriptions();
|
|
651
|
-
};
|
|
652
|
-
|
|
653
|
-
ws.onmessage = (event) => {
|
|
654
|
-
void this.handleSocketMessage(String(event.data));
|
|
655
|
-
};
|
|
656
|
-
|
|
657
|
-
ws.onclose = (event) => {
|
|
658
|
-
const activeSocket = this.ws === ws;
|
|
659
|
-
if (this.ws === ws) {
|
|
660
|
-
this.ws = null;
|
|
661
|
-
}
|
|
662
|
-
const closeEvent = event as CloseEvent | undefined;
|
|
663
|
-
cloudApiLog.warn("websocket closed", {
|
|
664
|
-
quoteTargets: this.quoteTargets.size,
|
|
665
|
-
channelTargets: this.channelListeners.size,
|
|
666
|
-
code: closeEvent?.code,
|
|
667
|
-
reason: closeEvent?.reason,
|
|
668
|
-
tokenSource: usingWebSocketToken ? "websocket" : "session",
|
|
669
|
-
});
|
|
670
|
-
if (activeSocket && usingWebSocketToken && this.sessionToken) {
|
|
671
|
-
this.websocketToken = null;
|
|
672
|
-
this.reconnectDelayMs = 1000;
|
|
673
|
-
cloudApiLog.warn("cleared websocket token after socket close; falling back to session token");
|
|
674
|
-
}
|
|
675
|
-
if (!this.shouldKeepSocketOpen()) return;
|
|
676
|
-
this.scheduleReconnect();
|
|
677
|
-
};
|
|
678
|
-
|
|
679
|
-
ws.onerror = () => {
|
|
680
|
-
// reconnect is handled by onclose
|
|
681
|
-
};
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
private teardownSocket(): void {
|
|
685
|
-
if (this.reconnectTimer) {
|
|
686
|
-
clearTimeout(this.reconnectTimer);
|
|
687
|
-
this.reconnectTimer = null;
|
|
688
|
-
}
|
|
689
|
-
const ws = this.ws;
|
|
690
|
-
this.ws = null;
|
|
691
|
-
if (ws) {
|
|
692
|
-
cloudApiLog.info("teardown websocket");
|
|
693
|
-
}
|
|
694
|
-
try {
|
|
695
|
-
ws?.close();
|
|
696
|
-
} catch {
|
|
697
|
-
// ignore closed sockets
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
private scheduleReconnect(): void {
|
|
702
|
-
if (this.reconnectTimer || !this.shouldKeepSocketOpen()) return;
|
|
703
|
-
const delay = this.reconnectDelayMs;
|
|
704
|
-
this.reconnectTimer = setTimeout(() => {
|
|
705
|
-
this.reconnectTimer = null;
|
|
706
|
-
this.reconnectDelayMs = Math.min(this.reconnectDelayMs * 2, 10_000);
|
|
707
|
-
this.ensureSocket();
|
|
708
|
-
}, delay);
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
private sendSocketMessage(payload: unknown): void {
|
|
712
|
-
if (this.ws?.readyState !== WebSocket.OPEN) return;
|
|
713
|
-
if (payload && typeof payload === "object" && "type" in (payload as Record<string, unknown>)) {
|
|
714
|
-
const type = (payload as Record<string, unknown>).type;
|
|
715
|
-
if (
|
|
716
|
-
type === "market.subscribe"
|
|
717
|
-
|| type === "market.unsubscribe"
|
|
718
|
-
|| type === "chat.subscribe"
|
|
719
|
-
|| type === "chat.unsubscribe"
|
|
720
|
-
) {
|
|
721
|
-
cloudApiLog.info("send websocket message", payload);
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
this.ws.send(JSON.stringify(payload));
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
private flushSubscriptions(): void {
|
|
728
|
-
if (this.ws?.readyState !== WebSocket.OPEN) return;
|
|
729
|
-
|
|
730
|
-
for (const channelId of this.channelListeners.keys()) {
|
|
731
|
-
this.sendSocketMessage({ type: "chat.subscribe", channelId });
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
if (this.quoteTargets.size > 0) {
|
|
735
|
-
this.sendSocketMessage({
|
|
736
|
-
type: "market.subscribe",
|
|
737
|
-
symbols: [...this.quoteTargets.values()].map((target) => this.serializeQuoteStreamTarget(target)),
|
|
738
|
-
});
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
private scheduleQuoteSubscriptionFlush(): void {
|
|
743
|
-
if (this.quoteSubscriptionFlushTimer) return;
|
|
744
|
-
this.quoteSubscriptionFlushTimer = setTimeout(() => {
|
|
745
|
-
this.quoteSubscriptionFlushTimer = null;
|
|
746
|
-
this.flushQueuedQuoteSubscriptions();
|
|
747
|
-
}, QUOTE_SUBSCRIPTION_FLUSH_MS);
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
private queueQuoteSubscribes(targets: QuoteStreamTarget[]): void {
|
|
751
|
-
for (const target of targets) {
|
|
752
|
-
const key = marketKey(target.symbol, target.exchange);
|
|
753
|
-
this.pendingQuoteUnsubscribes.delete(key);
|
|
754
|
-
this.pendingQuoteSubscribes.set(key, target);
|
|
755
|
-
}
|
|
756
|
-
this.scheduleQuoteSubscriptionFlush();
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
private queueQuoteUnsubscribes(targets: QuoteStreamTarget[]): void {
|
|
760
|
-
for (const target of targets) {
|
|
761
|
-
const key = marketKey(target.symbol, target.exchange);
|
|
762
|
-
if (this.pendingQuoteSubscribes.delete(key)) continue;
|
|
763
|
-
this.pendingQuoteUnsubscribes.set(key, target);
|
|
764
|
-
}
|
|
765
|
-
this.scheduleQuoteSubscriptionFlush();
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
private flushQueuedQuoteSubscriptions(): void {
|
|
769
|
-
if (this.ws?.readyState !== WebSocket.OPEN) {
|
|
770
|
-
this.pendingQuoteSubscribes.clear();
|
|
771
|
-
this.pendingQuoteUnsubscribes.clear();
|
|
772
|
-
return;
|
|
773
|
-
}
|
|
774
|
-
const subscribes = [...this.pendingQuoteSubscribes.values()];
|
|
775
|
-
const unsubscribes = [...this.pendingQuoteUnsubscribes.values()];
|
|
776
|
-
this.pendingQuoteSubscribes.clear();
|
|
777
|
-
this.pendingQuoteUnsubscribes.clear();
|
|
778
|
-
if (subscribes.length > 0) {
|
|
779
|
-
this.sendSocketMessage({
|
|
780
|
-
type: "market.subscribe",
|
|
781
|
-
symbols: subscribes.map((target) => this.serializeQuoteStreamTarget(target)),
|
|
782
|
-
});
|
|
783
|
-
}
|
|
784
|
-
if (unsubscribes.length > 0) {
|
|
785
|
-
this.sendSocketMessage({
|
|
786
|
-
type: "market.unsubscribe",
|
|
787
|
-
symbols: unsubscribes.map((target) => this.serializeQuoteStreamTarget(target)),
|
|
788
|
-
});
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
private serializeQuoteStreamTarget(target: QuoteStreamTarget): QuoteStreamTarget {
|
|
793
|
-
return {
|
|
794
|
-
symbol: target.symbol,
|
|
795
|
-
exchange: target.exchange ?? "",
|
|
796
|
-
...(target.surface ? { surface: target.surface } : {}),
|
|
797
|
-
...(target.visible ? { visible: true } : {}),
|
|
798
|
-
...(target.selected ? { selected: true } : {}),
|
|
799
|
-
...(Number.isFinite(target.weight) ? { weight: target.weight } : {}),
|
|
800
|
-
};
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
private async handleSocketMessage(raw: string): Promise<void> {
|
|
804
|
-
let parsed: any;
|
|
805
|
-
try {
|
|
806
|
-
parsed = JSON.parse(raw);
|
|
807
|
-
} catch {
|
|
808
|
-
return;
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
if (parsed?.type === "ready" && parsed.user) {
|
|
812
|
-
cloudApiLog.info("websocket ready", { emailVerified: parsed.user.emailVerified === true });
|
|
813
|
-
this.currentUser = {
|
|
814
|
-
...(this.currentUser ?? {}),
|
|
815
|
-
...parsed.user,
|
|
816
|
-
};
|
|
817
|
-
return;
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
if (parsed?.type === "auth.unverified") {
|
|
821
|
-
cloudApiLog.warn("websocket marked unverified");
|
|
822
|
-
if (this.websocketToken && this.sessionToken) {
|
|
823
|
-
this.websocketToken = null;
|
|
824
|
-
this.reconnectDelayMs = 1000;
|
|
825
|
-
cloudApiLog.warn("cleared websocket token after auth rejection; falling back to session token");
|
|
826
|
-
this.teardownSocket();
|
|
827
|
-
this.scheduleReconnect();
|
|
828
|
-
return;
|
|
829
|
-
}
|
|
830
|
-
if (this.currentUser) {
|
|
831
|
-
this.currentUser = { ...this.currentUser, emailVerified: false };
|
|
832
|
-
}
|
|
833
|
-
if (this.quoteTargets.size > 0) {
|
|
834
|
-
return;
|
|
835
|
-
}
|
|
836
|
-
this.teardownSocket();
|
|
837
|
-
return;
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
if (parsed?.type === "chat.message" && typeof parsed.channelId === "string" && parsed.data) {
|
|
841
|
-
const message = normalizeChatMessage(parsed.data as ChatMessage);
|
|
842
|
-
for (const listener of this.channelListeners.get(parsed.channelId) ?? []) {
|
|
843
|
-
listener(message);
|
|
844
|
-
}
|
|
845
|
-
return;
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
if (parsed?.type === "chat.notification" && parsed.data) {
|
|
849
|
-
const notification = normalizeChatNotification(parsed.data as ChatNotification);
|
|
850
|
-
for (const listener of this.chatNotificationListeners) {
|
|
851
|
-
listener(notification);
|
|
852
|
-
}
|
|
853
|
-
return;
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
if (parsed?.type === "chat.presence" && typeof parsed.onlineCount === "number") {
|
|
857
|
-
for (const listener of this.chatPresenceListeners) {
|
|
858
|
-
listener(parsed.onlineCount);
|
|
859
|
-
}
|
|
860
|
-
return;
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
if (parsed?.type === "market.quote" && parsed.quote && typeof parsed.symbol === "string") {
|
|
864
|
-
const key = marketKey(parsed.symbol, parsed.exchange);
|
|
865
|
-
const target = this.quoteTargets.get(key) ?? {
|
|
866
|
-
symbol: normalizeSymbol(parsed.symbol),
|
|
867
|
-
exchange: canonicalExchange(parsed.exchange),
|
|
868
|
-
};
|
|
869
|
-
for (const listener of this.quoteListeners.get(key) ?? []) {
|
|
870
|
-
listener(target, parsed.quote as CloudQuotePayload);
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
async ensureVerifiedSession(): Promise<AuthUser | null> {
|
|
876
|
-
if (!this.sessionToken) return null;
|
|
877
|
-
if (!this.currentUser) {
|
|
878
|
-
await this.getSession();
|
|
879
|
-
}
|
|
880
|
-
return this.currentUser?.emailVerified ? this.currentUser : null;
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
async signUp(email: string, username: string, name: string, password: string): Promise<AuthUser> {
|
|
884
|
-
const result = await this.request<{ user: AuthUser }>("/auth/sign-up/email", {
|
|
885
|
-
method: "POST",
|
|
886
|
-
body: JSON.stringify({ email, username, name, password }),
|
|
887
|
-
});
|
|
888
|
-
this.requireCapturedSession(
|
|
889
|
-
"Account created, but Gloomberb could not save the login session. Please try logging in again.",
|
|
890
|
-
);
|
|
891
|
-
this.setCurrentUser(result.user);
|
|
892
|
-
return result.user;
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
async signIn(email: string, password: string): Promise<AuthUser> {
|
|
896
|
-
const result = await this.request<{ user: AuthUser }>("/auth/sign-in/email", {
|
|
897
|
-
method: "POST",
|
|
898
|
-
body: JSON.stringify({ email, password }),
|
|
899
|
-
});
|
|
900
|
-
this.requireCapturedSession(
|
|
901
|
-
"Logged in, but Gloomberb could not save the login session. Please try again.",
|
|
902
|
-
);
|
|
903
|
-
this.setCurrentUser(result.user);
|
|
904
|
-
return result.user;
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
async signOut(): Promise<void> {
|
|
908
|
-
try {
|
|
909
|
-
await this.request("/auth/sign-out", { method: "POST" });
|
|
910
|
-
} finally {
|
|
911
|
-
this.setSessionToken(null);
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
|
|
915
|
-
async getSession(): Promise<AuthUser | null> {
|
|
916
|
-
try {
|
|
917
|
-
const result = await this.request<{ user: AuthUser }>("/auth/get-session", {
|
|
918
|
-
method: "GET",
|
|
919
|
-
});
|
|
920
|
-
const user = result?.user ?? null;
|
|
921
|
-
this.setCurrentUser(user);
|
|
922
|
-
return user;
|
|
923
|
-
} catch (error) {
|
|
924
|
-
if (error instanceof ApiRequestError && isHardSessionInvalidMessage(error.message)) {
|
|
925
|
-
this.setSessionToken(null);
|
|
926
|
-
return null;
|
|
927
|
-
}
|
|
928
|
-
throw error;
|
|
929
|
-
}
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
async sendVerification(): Promise<CloudVerificationResponse> {
|
|
933
|
-
return this.request<CloudVerificationResponse>("/cloud/auth/send-verification", {
|
|
934
|
-
method: "POST",
|
|
935
|
-
body: JSON.stringify({}),
|
|
936
|
-
});
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
async getChannels(): Promise<ChatChannel[]> {
|
|
940
|
-
return this.request<ChatChannel[]>("/chat/channels");
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
async getChatPresence(): Promise<{ onlineCount: number }> {
|
|
944
|
-
return this.request<{ onlineCount: number }>("/chat/presence");
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
async getChatState(): Promise<ChatStateResponse> {
|
|
948
|
-
const state = await this.request<ChatStateResponse>("/chat/state");
|
|
949
|
-
return normalizeChatState(state);
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
async updateChatChannelState(
|
|
953
|
-
channelId: string,
|
|
954
|
-
body: { notificationsEnabled?: boolean; readThroughMessageId?: string },
|
|
955
|
-
): Promise<ChatChannelState> {
|
|
956
|
-
return this.request<ChatChannelState>(`/chat/channels/${channelId}/state`, {
|
|
957
|
-
method: "PATCH",
|
|
958
|
-
body: JSON.stringify(body),
|
|
959
|
-
});
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
async markChatNotificationsDelivered(notificationIds: string[]): Promise<{ delivered: number }> {
|
|
963
|
-
return this.request<{ delivered: number }>("/chat/notifications/delivered", {
|
|
964
|
-
method: "POST",
|
|
965
|
-
body: JSON.stringify({ notificationIds }),
|
|
966
|
-
});
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
async getMessages(
|
|
970
|
-
channelId: string,
|
|
971
|
-
opts?: { after?: string; before?: string; limit?: number },
|
|
972
|
-
): Promise<ChatMessage[]> {
|
|
973
|
-
const params = new URLSearchParams();
|
|
974
|
-
if (opts?.after) params.set("after", opts.after);
|
|
975
|
-
if (opts?.before) params.set("before", opts.before);
|
|
976
|
-
if (opts?.limit) params.set("limit", String(opts.limit));
|
|
977
|
-
const qs = params.toString();
|
|
978
|
-
const messages = await this.request<ChatMessage[]>(`/chat/channels/${channelId}/messages${qs ? `?${qs}` : ""}`);
|
|
979
|
-
return normalizeChatMessages(messages);
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
async sendMessage(channelId: string, content: string, replyToId?: string, clientMessageId?: string): Promise<ChatMessage> {
|
|
983
|
-
const message = await this.request<ChatMessage>(`/chat/channels/${channelId}/messages`, {
|
|
984
|
-
method: "POST",
|
|
985
|
-
body: JSON.stringify({ content, replyToId, clientMessageId }),
|
|
986
|
-
});
|
|
987
|
-
return normalizeChatMessage(message);
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
connectChannel(
|
|
991
|
-
channelId: string,
|
|
992
|
-
onMessage: (msg: ChatMessage) => void,
|
|
993
|
-
onError?: (err: string) => void,
|
|
994
|
-
): { send: (content: string, replyToId?: string, clientMessageId?: string) => Promise<ChatMessage>; close: () => void } {
|
|
995
|
-
if (!channelId) {
|
|
996
|
-
return {
|
|
997
|
-
send: async () => {
|
|
998
|
-
throw new Error("Channel id is required");
|
|
999
|
-
},
|
|
1000
|
-
close: () => {},
|
|
1001
|
-
};
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
const listeners = this.channelListeners.get(channelId) ?? new Set<ChannelListener>();
|
|
1005
|
-
const firstListener = listeners.size === 0;
|
|
1006
|
-
listeners.add(onMessage);
|
|
1007
|
-
this.channelListeners.set(channelId, listeners);
|
|
1008
|
-
this.ensureSocket();
|
|
1009
|
-
if (firstListener) {
|
|
1010
|
-
this.sendSocketMessage({ type: "chat.subscribe", channelId });
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
return {
|
|
1014
|
-
send: async (content: string, replyToId?: string, clientMessageId?: string) => {
|
|
1015
|
-
try {
|
|
1016
|
-
const message = await this.sendMessage(channelId, content, replyToId, clientMessageId);
|
|
1017
|
-
onMessage(message);
|
|
1018
|
-
return message;
|
|
1019
|
-
} catch (error) {
|
|
1020
|
-
onError?.(error instanceof Error ? error.message : String(error));
|
|
1021
|
-
throw error;
|
|
1022
|
-
}
|
|
1023
|
-
},
|
|
1024
|
-
close: () => {
|
|
1025
|
-
const current = this.channelListeners.get(channelId);
|
|
1026
|
-
if (!current) return;
|
|
1027
|
-
current.delete(onMessage);
|
|
1028
|
-
if (current.size === 0) {
|
|
1029
|
-
this.channelListeners.delete(channelId);
|
|
1030
|
-
this.sendSocketMessage({ type: "chat.unsubscribe", channelId });
|
|
1031
|
-
}
|
|
1032
|
-
if (!this.shouldKeepSocketOpen()) {
|
|
1033
|
-
this.teardownSocket();
|
|
1034
|
-
}
|
|
1035
|
-
},
|
|
1036
|
-
};
|
|
1037
|
-
}
|
|
1038
|
-
|
|
1039
|
-
subscribeChatNotifications(listener: ChatNotificationListener): () => void {
|
|
1040
|
-
this.chatNotificationListeners.add(listener);
|
|
1041
|
-
return () => {
|
|
1042
|
-
this.chatNotificationListeners.delete(listener);
|
|
1043
|
-
};
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
|
-
subscribeChatPresence(listener: ChatPresenceListener): () => void {
|
|
1047
|
-
this.chatPresenceListeners.add(listener);
|
|
1048
|
-
return () => {
|
|
1049
|
-
this.chatPresenceListeners.delete(listener);
|
|
1050
|
-
};
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
subscribeQuotes(
|
|
1054
|
-
targets: QuoteStreamTarget[],
|
|
1055
|
-
onQuote: (target: QuoteStreamTarget, quote: CloudQuotePayload) => void,
|
|
1056
|
-
): () => void {
|
|
1057
|
-
const uniqueTargets = [...new Map(
|
|
1058
|
-
targets
|
|
1059
|
-
.filter((target) => typeof target.symbol === "string" && target.symbol.trim().length > 0)
|
|
1060
|
-
.map((target) => {
|
|
1061
|
-
const normalized = {
|
|
1062
|
-
symbol: normalizeSymbol(target.symbol),
|
|
1063
|
-
exchange: canonicalExchange(target.exchange),
|
|
1064
|
-
surface: target.surface,
|
|
1065
|
-
visible: target.visible,
|
|
1066
|
-
selected: target.selected,
|
|
1067
|
-
weight: target.weight,
|
|
1068
|
-
} satisfies QuoteStreamTarget;
|
|
1069
|
-
return [marketKey(normalized.symbol, normalized.exchange), normalized] as const;
|
|
1070
|
-
}),
|
|
1071
|
-
).values()];
|
|
1072
|
-
|
|
1073
|
-
const newSubscriptions: QuoteStreamTarget[] = [];
|
|
1074
|
-
const updatedSubscriptions: QuoteStreamTarget[] = [];
|
|
1075
|
-
for (const target of uniqueTargets) {
|
|
1076
|
-
const key = marketKey(target.symbol, target.exchange);
|
|
1077
|
-
const listeners = this.quoteListeners.get(key) ?? new Set<QuoteListener>();
|
|
1078
|
-
if (listeners.size === 0) {
|
|
1079
|
-
newSubscriptions.push(target);
|
|
1080
|
-
} else {
|
|
1081
|
-
const existing = this.quoteTargets.get(key);
|
|
1082
|
-
if (JSON.stringify(this.serializeQuoteStreamTarget(existing ?? target)) !== JSON.stringify(this.serializeQuoteStreamTarget(target))) {
|
|
1083
|
-
updatedSubscriptions.push(target);
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
listeners.add(onQuote);
|
|
1087
|
-
this.quoteListeners.set(key, listeners);
|
|
1088
|
-
this.quoteTargets.set(key, target);
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
this.ensureSocket();
|
|
1092
|
-
const subscriptionsToSend = [...newSubscriptions, ...updatedSubscriptions];
|
|
1093
|
-
if (subscriptionsToSend.length > 0) {
|
|
1094
|
-
cloudApiLog.info("register quote listeners", {
|
|
1095
|
-
count: subscriptionsToSend.length,
|
|
1096
|
-
symbols: subscriptionsToSend.map((target) => marketKey(target.symbol, target.exchange)),
|
|
1097
|
-
});
|
|
1098
|
-
this.queueQuoteSubscribes(subscriptionsToSend);
|
|
1099
|
-
}
|
|
1100
|
-
|
|
1101
|
-
return () => {
|
|
1102
|
-
const removedTargets: QuoteStreamTarget[] = [];
|
|
1103
|
-
|
|
1104
|
-
for (const target of uniqueTargets) {
|
|
1105
|
-
const key = marketKey(target.symbol, target.exchange);
|
|
1106
|
-
const listeners = this.quoteListeners.get(key);
|
|
1107
|
-
if (!listeners) continue;
|
|
1108
|
-
listeners.delete(onQuote);
|
|
1109
|
-
if (listeners.size === 0) {
|
|
1110
|
-
this.quoteListeners.delete(key);
|
|
1111
|
-
const storedTarget = this.quoteTargets.get(key);
|
|
1112
|
-
if (storedTarget) {
|
|
1113
|
-
removedTargets.push(storedTarget);
|
|
1114
|
-
}
|
|
1115
|
-
this.quoteTargets.delete(key);
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
if (removedTargets.length > 0) {
|
|
1120
|
-
cloudApiLog.info("remove quote listeners", {
|
|
1121
|
-
count: removedTargets.length,
|
|
1122
|
-
symbols: removedTargets.map((target) => marketKey(target.symbol, target.exchange)),
|
|
1123
|
-
});
|
|
1124
|
-
this.queueQuoteUnsubscribes(removedTargets);
|
|
1125
|
-
}
|
|
1126
|
-
|
|
1127
|
-
if (!this.shouldKeepSocketOpen()) {
|
|
1128
|
-
this.teardownSocket();
|
|
1129
|
-
}
|
|
1130
|
-
};
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
dispose(): void {
|
|
1134
|
-
cloudApiLog.info("dispose api client", {
|
|
1135
|
-
quoteTargets: this.quoteTargets.size,
|
|
1136
|
-
channelTargets: this.channelListeners.size,
|
|
1137
|
-
});
|
|
1138
|
-
this.channelListeners.clear();
|
|
1139
|
-
this.chatNotificationListeners.clear();
|
|
1140
|
-
this.chatPresenceListeners.clear();
|
|
1141
|
-
this.quoteListeners.clear();
|
|
1142
|
-
this.quoteTargets.clear();
|
|
1143
|
-
this.pendingQuoteSubscribes.clear();
|
|
1144
|
-
this.pendingQuoteUnsubscribes.clear();
|
|
1145
|
-
if (this.quoteSubscriptionFlushTimer) {
|
|
1146
|
-
clearTimeout(this.quoteSubscriptionFlushTimer);
|
|
1147
|
-
this.quoteSubscriptionFlushTimer = null;
|
|
1148
|
-
}
|
|
1149
|
-
this.reconnectDelayMs = 1000;
|
|
1150
|
-
this.teardownSocket();
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
|
-
async searchInstruments(query: string, limit = 10): Promise<InstrumentSearchResult[]> {
|
|
1154
|
-
const params = new URLSearchParams({
|
|
1155
|
-
q: query,
|
|
1156
|
-
limit: String(limit),
|
|
1157
|
-
});
|
|
1158
|
-
const response = await this.request<CloudMarketResponse<InstrumentSearchResult[]>>(`/market/search?${params.toString()}`);
|
|
1159
|
-
return response.data ?? [];
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
async getCloudQuote(symbol: string, exchange?: string): Promise<CloudMarketResponse<CloudQuotePayload>> {
|
|
1163
|
-
const params = new URLSearchParams({ symbol });
|
|
1164
|
-
if (exchange) params.set("exchange", exchange);
|
|
1165
|
-
return this.request<CloudMarketResponse<CloudQuotePayload>>(`/market/quote?${params.toString()}`);
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
async getCloudQuotesBatch(
|
|
1169
|
-
targets: CloudMarketBatchTarget[],
|
|
1170
|
-
mode: "cache-first" | "refresh" = "cache-first",
|
|
1171
|
-
): Promise<CloudMarketResponse<CloudMarketBatchPayload<CloudQuotePayload>>> {
|
|
1172
|
-
return this.request<CloudMarketResponse<CloudMarketBatchPayload<CloudQuotePayload>>>("/market/quotes/batch", {
|
|
1173
|
-
method: "POST",
|
|
1174
|
-
body: JSON.stringify({ targets, mode }),
|
|
1175
|
-
});
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
async getCloudOptionsChain(
|
|
1179
|
-
symbol: string,
|
|
1180
|
-
exchange?: string,
|
|
1181
|
-
expirationDate?: number,
|
|
1182
|
-
): Promise<CloudMarketResponse<CloudOptionsChainPayload>> {
|
|
1183
|
-
const params = new URLSearchParams({ symbol });
|
|
1184
|
-
if (exchange) params.set("exchange", exchange);
|
|
1185
|
-
if (expirationDate != null) params.set("expirationDate", String(expirationDate));
|
|
1186
|
-
return this.request<CloudMarketResponse<CloudOptionsChainPayload>>(`/market/options?${params.toString()}`);
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
|
-
async getCloudProfile(symbol: string, exchange?: string): Promise<CloudMarketResponse<CloudCompanyProfile>> {
|
|
1190
|
-
const params = new URLSearchParams({ symbol });
|
|
1191
|
-
if (exchange) params.set("exchange", exchange);
|
|
1192
|
-
return this.request<CloudMarketResponse<CloudCompanyProfile>>(`/market/profile?${params.toString()}`);
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
async getCloudFundamentals(symbol: string, exchange?: string): Promise<CloudMarketResponse<CloudFundamentals>> {
|
|
1196
|
-
const params = new URLSearchParams({ symbol });
|
|
1197
|
-
if (exchange) params.set("exchange", exchange);
|
|
1198
|
-
return this.request<CloudMarketResponse<CloudFundamentals>>(`/market/fundamentals?${params.toString()}`);
|
|
1199
|
-
}
|
|
1200
|
-
|
|
1201
|
-
async getCloudFinancials(symbol: string, exchange?: string): Promise<CloudMarketResponse<TickerFinancials>> {
|
|
1202
|
-
const params = new URLSearchParams({ symbol });
|
|
1203
|
-
if (exchange) params.set("exchange", exchange);
|
|
1204
|
-
return this.request<CloudMarketResponse<TickerFinancials>>(`/market/financials?${params.toString()}`);
|
|
1205
|
-
}
|
|
1206
|
-
|
|
1207
|
-
async getCloudFinancialsBatch(
|
|
1208
|
-
targets: CloudMarketBatchTarget[],
|
|
1209
|
-
mode: "cache-first" | "refresh" = "cache-first",
|
|
1210
|
-
): Promise<CloudMarketResponse<CloudMarketBatchPayload<TickerFinancials>>> {
|
|
1211
|
-
return this.request<CloudMarketResponse<CloudMarketBatchPayload<TickerFinancials>>>("/market/financials/batch", {
|
|
1212
|
-
method: "POST",
|
|
1213
|
-
body: JSON.stringify({ targets, mode }),
|
|
1214
|
-
});
|
|
1215
|
-
}
|
|
1216
|
-
|
|
1217
|
-
async getCloudHolders(symbol: string, exchange?: string): Promise<CloudMarketResponse<CloudHoldersPayload>> {
|
|
1218
|
-
const params = new URLSearchParams({ symbol });
|
|
1219
|
-
if (exchange) params.set("exchange", exchange);
|
|
1220
|
-
return this.request<CloudMarketResponse<CloudHoldersPayload>>(`/market/holders?${params.toString()}`);
|
|
1221
|
-
}
|
|
1222
|
-
|
|
1223
|
-
async getCloudAnalystResearch(symbol: string, exchange?: string): Promise<CloudMarketResponse<CloudAnalystResearchPayload>> {
|
|
1224
|
-
const params = new URLSearchParams({ symbol });
|
|
1225
|
-
if (exchange) params.set("exchange", exchange);
|
|
1226
|
-
return this.request<CloudMarketResponse<CloudAnalystResearchPayload>>(`/market/analyst?${params.toString()}`);
|
|
1227
|
-
}
|
|
1228
|
-
|
|
1229
|
-
async getCloudCorporateActions(symbol: string, exchange?: string): Promise<CloudMarketResponse<CloudCorporateActionsPayload>> {
|
|
1230
|
-
const params = new URLSearchParams({ symbol });
|
|
1231
|
-
if (exchange) params.set("exchange", exchange);
|
|
1232
|
-
return this.request<CloudMarketResponse<CloudCorporateActionsPayload>>(`/market/corporate-actions?${params.toString()}`);
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
|
-
async getCloudStatements(
|
|
1236
|
-
symbol: string,
|
|
1237
|
-
exchange?: string,
|
|
1238
|
-
period: "annual" | "quarterly" | "both" = "both",
|
|
1239
|
-
): Promise<CloudMarketResponse<Pick<TickerFinancials, "annualStatements" | "quarterlyStatements">>> {
|
|
1240
|
-
const params = new URLSearchParams({ symbol, period });
|
|
1241
|
-
if (exchange) params.set("exchange", exchange);
|
|
1242
|
-
return this.request<CloudMarketResponse<Pick<TickerFinancials, "annualStatements" | "quarterlyStatements">>>(`/market/statements?${params.toString()}`);
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
|
-
async getCloudHistory(
|
|
1246
|
-
symbol: string,
|
|
1247
|
-
exchange: string,
|
|
1248
|
-
params: {
|
|
1249
|
-
interval?: string;
|
|
1250
|
-
outputsize?: number;
|
|
1251
|
-
startDate?: string;
|
|
1252
|
-
endDate?: string;
|
|
1253
|
-
rangeKey?: string;
|
|
1254
|
-
} = {},
|
|
1255
|
-
): Promise<CloudMarketResponse<CloudPricePointPayload[]>> {
|
|
1256
|
-
const search = new URLSearchParams({ symbol, exchange });
|
|
1257
|
-
if (params.interval) search.set("interval", params.interval);
|
|
1258
|
-
if (params.outputsize != null) search.set("outputsize", String(params.outputsize));
|
|
1259
|
-
if (params.startDate) search.set("startDate", params.startDate);
|
|
1260
|
-
if (params.endDate) search.set("endDate", params.endDate);
|
|
1261
|
-
if (params.rangeKey) search.set("rangeKey", params.rangeKey);
|
|
1262
|
-
return this.request<CloudMarketResponse<CloudPricePointPayload[]>>(`/market/history?${search.toString()}`);
|
|
1263
|
-
}
|
|
1264
|
-
|
|
1265
|
-
async getCloudExchangeRate(fromCurrency: string): Promise<CloudMarketResponse<{ rate: number }>> {
|
|
1266
|
-
const params = new URLSearchParams({ fromCurrency });
|
|
1267
|
-
return this.request<CloudMarketResponse<{ rate: number }>>(`/market/exchange-rate?${params.toString()}`);
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
|
-
async getCloudEconomicCalendar(): Promise<CloudEconEventPayload[]> {
|
|
1271
|
-
return this.request<CloudEconEventPayload[]>("/cloud/econ/calendar");
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
async getCloudFredSeries(
|
|
1275
|
-
seriesId: string,
|
|
1276
|
-
params: {
|
|
1277
|
-
startDate?: string;
|
|
1278
|
-
endDate?: string;
|
|
1279
|
-
limit?: number;
|
|
1280
|
-
sortOrder?: "asc" | "desc";
|
|
1281
|
-
} = {},
|
|
1282
|
-
): Promise<CloudFredSeriesPayload> {
|
|
1283
|
-
const search = new URLSearchParams();
|
|
1284
|
-
if (params.startDate) search.set("startDate", params.startDate);
|
|
1285
|
-
if (params.endDate) search.set("endDate", params.endDate);
|
|
1286
|
-
if (params.limit != null) search.set("limit", String(params.limit));
|
|
1287
|
-
if (params.sortOrder) search.set("sortOrder", params.sortOrder);
|
|
1288
|
-
const qs = search.toString();
|
|
1289
|
-
return this.request<CloudFredSeriesPayload>(`/cloud/econ/series/${encodeURIComponent(seriesId)}${qs ? `?${qs}` : ""}`);
|
|
1290
|
-
}
|
|
1291
|
-
|
|
1292
|
-
async getCloudYieldCurve(): Promise<CloudYieldPointPayload[]> {
|
|
1293
|
-
return this.request<CloudYieldPointPayload[]>("/cloud/econ/yield-curve");
|
|
1294
|
-
}
|
|
1295
|
-
|
|
1296
|
-
async getCloudNews(params: {
|
|
1297
|
-
feed?: "latest" | "top" | "breaking" | "ticker" | "sector" | "topic";
|
|
1298
|
-
ticker?: string;
|
|
1299
|
-
exchange?: string;
|
|
1300
|
-
tickerTier?: "primary" | "related" | "any";
|
|
1301
|
-
tickerRelations?: string[];
|
|
1302
|
-
limit?: number;
|
|
1303
|
-
topics?: string[];
|
|
1304
|
-
categories?: string[];
|
|
1305
|
-
sectors?: string[];
|
|
1306
|
-
sources?: string[];
|
|
1307
|
-
excludeSources?: string[];
|
|
1308
|
-
sentiment?: "positive" | "neutral" | "negative";
|
|
1309
|
-
minImportance?: number;
|
|
1310
|
-
minUrgency?: number;
|
|
1311
|
-
breaking?: boolean;
|
|
1312
|
-
since?: Date;
|
|
1313
|
-
until?: Date;
|
|
1314
|
-
cursor?: string;
|
|
1315
|
-
} = {}): Promise<CloudNewsListResponse> {
|
|
1316
|
-
const search = new URLSearchParams();
|
|
1317
|
-
if (params.feed) search.set("feed", params.feed);
|
|
1318
|
-
if (params.ticker) {
|
|
1319
|
-
const tickerFilter = params.exchange
|
|
1320
|
-
? publicTickerKey(params.ticker, params.exchange)
|
|
1321
|
-
: normalizeSymbol(params.ticker);
|
|
1322
|
-
search.set("tickers", tickerFilter);
|
|
1323
|
-
}
|
|
1324
|
-
if (params.tickerTier) search.set("tickerTier", params.tickerTier);
|
|
1325
|
-
if (params.tickerRelations?.length) search.set("tickerRelations", params.tickerRelations.join(","));
|
|
1326
|
-
if (params.limit != null) search.set("limit", String(params.limit));
|
|
1327
|
-
if (params.topics?.length) search.set("topics", params.topics.join(","));
|
|
1328
|
-
if (params.categories?.length) {
|
|
1329
|
-
search.set("categories", params.categories.join(","));
|
|
1330
|
-
}
|
|
1331
|
-
if (params.sectors?.length) search.set("sectors", params.sectors.join(","));
|
|
1332
|
-
if (params.sources?.length) search.set("sources", params.sources.join(","));
|
|
1333
|
-
if (params.excludeSources?.length) search.set("excludeSources", params.excludeSources.join(","));
|
|
1334
|
-
if (params.sentiment) search.set("sentiment", params.sentiment);
|
|
1335
|
-
if (params.minImportance != null) search.set("minImportance", String(params.minImportance));
|
|
1336
|
-
if (params.minUrgency != null) search.set("minUrgency", String(params.minUrgency));
|
|
1337
|
-
if (params.breaking != null) search.set("breaking", String(params.breaking));
|
|
1338
|
-
if (params.since) search.set("since", params.since.toISOString());
|
|
1339
|
-
if (params.until) search.set("until", params.until.toISOString());
|
|
1340
|
-
if (params.cursor) search.set("cursor", params.cursor);
|
|
1341
|
-
const query = search.toString();
|
|
1342
|
-
return this.request<CloudNewsListResponse>(`/news${query ? `?${query}` : ""}`);
|
|
1343
|
-
}
|
|
1344
|
-
|
|
1345
|
-
async getCloudNewsStory(storyId: string): Promise<CloudNewsPayload> {
|
|
1346
|
-
return this.request<CloudNewsPayload>(`/news/${encodeURIComponent(storyId)}`);
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
|
-
async getCloudTickerTweets(params: {
|
|
1350
|
-
ticker: string;
|
|
1351
|
-
limit?: number;
|
|
1352
|
-
hours?: number;
|
|
1353
|
-
includeReplies?: boolean;
|
|
1354
|
-
}): Promise<CloudTweetSearchResponse> {
|
|
1355
|
-
const search = new URLSearchParams({ ticker: params.ticker });
|
|
1356
|
-
if (params.limit != null) search.set("limit", String(params.limit));
|
|
1357
|
-
if (params.hours != null) search.set("hours", String(params.hours));
|
|
1358
|
-
if (params.includeReplies != null) search.set("includeReplies", String(params.includeReplies));
|
|
1359
|
-
const response = await this.request<CloudTweetSearchResponse>(`/news/tweets?${search.toString()}`);
|
|
1360
|
-
return normalizeTweetSearchResponse(response);
|
|
1361
|
-
}
|
|
1362
|
-
|
|
1363
|
-
async searchCloudTweets(params: {
|
|
1364
|
-
query: string;
|
|
1365
|
-
queryType?: CloudTweetQueryType;
|
|
1366
|
-
limit?: number;
|
|
1367
|
-
hours?: number;
|
|
1368
|
-
}): Promise<CloudTweetSearchResponse> {
|
|
1369
|
-
const search = new URLSearchParams({ query: params.query });
|
|
1370
|
-
if (params.queryType) search.set("queryType", params.queryType);
|
|
1371
|
-
if (params.limit != null) search.set("limit", String(params.limit));
|
|
1372
|
-
if (params.hours != null) search.set("hours", String(params.hours));
|
|
1373
|
-
const response = await this.request<CloudTweetSearchResponse>(`/news/tweets/search?${search.toString()}`);
|
|
1374
|
-
return normalizeTweetSearchResponse(response);
|
|
1375
|
-
}
|
|
1376
|
-
}
|
|
1377
|
-
|
|
1378
|
-
export const apiClient = new GloomApiClient();
|
|
1379
|
-
export type { PricePoint };
|