@orangecharts/wrun-chart-host 0.2.0 → 0.4.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 +22 -8
- package/dist/constants/common.constants.d.ts +15 -0
- package/dist/constants/common.constants.js +23 -0
- package/dist/constants/data-source.constants.d.ts +1 -0
- package/dist/constants/data-source.constants.js +1 -0
- package/dist/constants/economic.constants.d.ts +39 -0
- package/dist/constants/economic.constants.js +77 -0
- package/dist/constants/etf-covered-coins.constants.d.ts +1 -0
- package/dist/constants/etf-covered-coins.constants.js +9 -0
- package/dist/constants/feature-flags.constants.d.ts +60 -0
- package/dist/constants/feature-flags.constants.js +308 -0
- package/dist/constants/feature-limits.constants.d.ts +134 -0
- package/dist/constants/feature-limits.constants.js +155 -0
- package/dist/constants/marketCapabilities.constants.d.ts +87 -0
- package/dist/constants/marketCapabilities.constants.js +213 -0
- package/dist/constants/option-venues.constants.d.ts +100 -0
- package/dist/constants/option-venues.constants.js +167 -0
- package/dist/constants/overlay-data.constants.d.ts +53 -0
- package/dist/constants/overlay-data.constants.js +80 -0
- package/dist/constants/pane-grid.constants.d.ts +15 -0
- package/dist/constants/pane-grid.constants.js +17 -0
- package/dist/constants/scriptEditor/builtin-script-snippets.d.ts +133 -0
- package/dist/constants/scriptEditor/builtin-script-snippets.js +451 -0
- package/dist/constants/venue-presets.constants.d.ts +10 -0
- package/dist/constants/venue-presets.constants.js +22 -0
- package/dist/enums/chart.enum.d.ts +68 -0
- package/dist/enums/chart.enum.js +70 -0
- package/dist/helpers/data.helpers.d.ts +2 -0
- package/dist/helpers/data.helpers.js +14 -0
- package/dist/host-env.d.ts +163 -5
- package/dist/host-ports.types.d.ts +431 -0
- package/dist/host-ports.types.js +1 -0
- package/dist/index.d.ts +138 -0
- package/dist/index.js +138 -0
- package/dist/indicators/controls/technical-script/technical-script-input-rendering.d.ts +86 -0
- package/dist/indicators/controls/technical-script/technical-script-input-rendering.js +179 -0
- package/dist/interfaces/asset-venue.interface.d.ts +91 -0
- package/dist/interfaces/asset-venue.interface.js +1 -0
- package/dist/interfaces/cancel-reason.interface.d.ts +24 -0
- package/dist/interfaces/cancel-reason.interface.js +2 -0
- package/dist/interfaces/catalog-display.interface.d.ts +3 -0
- package/dist/interfaces/catalog-display.interface.js +1 -0
- package/dist/interfaces/cme-realtime.interface.d.ts +251 -0
- package/dist/interfaces/cme-realtime.interface.js +46 -0
- package/dist/interfaces/feed.interface.d.ts +80 -0
- package/dist/interfaces/feed.interface.js +7 -0
- package/dist/interfaces/market-kind.interface.d.ts +8 -0
- package/dist/interfaces/market-kind.interface.js +1 -0
- package/dist/interfaces/opra-realtime.interface.d.ts +224 -0
- package/dist/interfaces/opra-realtime.interface.js +105 -0
- package/dist/interfaces/option-instrument.interface.d.ts +32 -0
- package/dist/interfaces/option-instrument.interface.js +1 -0
- package/dist/interfaces/options-chain-scope.interface.d.ts +29 -0
- package/dist/interfaces/options-chain-scope.interface.js +7 -0
- package/dist/interfaces/prediction-market.interface.d.ts +88 -0
- package/dist/interfaces/prediction-market.interface.js +8 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +5 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +185 -0
- package/dist/kscript-data/controls/live-trades-merge.util.js +357 -0
- package/dist/settings-templates/frvp-fields.d.ts +27 -0
- package/dist/settings-templates/frvp-fields.js +108 -0
- package/dist/settings-templates/index.d.ts +119 -0
- package/dist/settings-templates/index.js +442 -0
- package/dist/settings-templates/indicator-fields.d.ts +56 -0
- package/dist/settings-templates/indicator-fields.js +793 -0
- package/dist/settings-templates/tool-rules.d.ts +59 -0
- package/dist/settings-templates/tool-rules.js +49 -0
- package/dist/settings-templates/tool-tables.generated.d.ts +2 -0
- package/dist/settings-templates/tool-tables.generated.js +1668 -0
- package/dist/utility/blk-market.util.d.ts +5 -0
- package/dist/utility/blk-market.util.js +12 -0
- package/dist/utility/chart/chart-load-phase.util.d.ts +32 -0
- package/dist/utility/chart/chart-load-phase.util.js +78 -0
- package/dist/utility/chart/cme-cache-context.util.d.ts +108 -0
- package/dist/utility/chart/cme-cache-context.util.js +166 -0
- package/dist/utility/chart/cme-session-bucket.util.d.ts +82 -0
- package/dist/utility/chart/cme-session-bucket.util.js +343 -0
- package/dist/utility/chart/cme-trade-calendar.util.d.ts +26 -0
- package/dist/utility/chart/cme-trade-calendar.util.js +147 -0
- package/dist/utility/chart/continuous-contracts.util.d.ts +138 -0
- package/dist/utility/chart/continuous-contracts.util.js +374 -0
- package/dist/utility/chart/date-labelled-interval.leaf.d.ts +15 -0
- package/dist/utility/chart/date-labelled-interval.leaf.js +19 -0
- package/dist/utility/chart/feed-interval.util.d.ts +119 -0
- package/dist/utility/chart/feed-interval.util.js +321 -0
- package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +110 -0
- package/dist/utility/chart/fetch-dedupe-policy.util.js +407 -0
- package/dist/utility/chart/footprint-band.util.d.ts +76 -0
- package/dist/utility/chart/footprint-band.util.js +205 -0
- package/dist/utility/chart/footprint-cell-identity.util.d.ts +82 -0
- package/dist/utility/chart/footprint-cell-identity.util.js +346 -0
- package/dist/utility/chart/formula-calendar.util.d.ts +27 -0
- package/dist/utility/chart/formula-calendar.util.js +59 -0
- package/dist/utility/chart/history-wall.util.d.ts +67 -0
- package/dist/utility/chart/history-wall.util.js +87 -0
- package/dist/utility/chart/index-mode.util.d.ts +66 -0
- package/dist/utility/chart/index-mode.util.js +360 -0
- package/dist/utility/chart/indicator-coverage-planner.util.d.ts +217 -0
- package/dist/utility/chart/indicator-coverage-planner.util.js +443 -0
- package/dist/utility/chart/indicator-coverage-state.util.d.ts +33 -0
- package/dist/utility/chart/indicator-coverage-state.util.js +110 -0
- package/dist/utility/chart/indicator-gap-detector.util.d.ts +127 -0
- package/dist/utility/chart/indicator-gap-detector.util.js +260 -0
- package/dist/utility/chart/indicator-gap-repair.util.d.ts +88 -0
- package/dist/utility/chart/indicator-gap-repair.util.js +177 -0
- package/dist/utility/chart/indicator-inflight-registry.util.d.ts +26 -0
- package/dist/utility/chart/indicator-inflight-registry.util.js +254 -0
- package/dist/utility/chart/indicator-run-interval.util.d.ts +130 -0
- package/dist/utility/chart/indicator-run-interval.util.js +268 -0
- package/dist/utility/chart/interval-registry.util.d.ts +23 -0
- package/dist/utility/chart/interval-registry.util.js +83 -0
- package/dist/utility/chart/kscript-main-grid-stages.util.d.ts +21 -0
- package/dist/utility/chart/kscript-main-grid-stages.util.js +332 -0
- package/dist/utility/chart/legacy-exchange.leaf.d.ts +11 -0
- package/dist/utility/chart/legacy-exchange.leaf.js +43 -0
- package/dist/utility/chart/live-bucket.util.d.ts +66 -0
- package/dist/utility/chart/live-bucket.util.js +165 -0
- package/dist/utility/chart/market-session-schedule.util.d.ts +91 -0
- package/dist/utility/chart/market-session-schedule.util.js +337 -0
- package/dist/utility/chart/marketKind.util.d.ts +181 -0
- package/dist/utility/chart/marketKind.util.js +371 -0
- package/dist/utility/chart/opra-read-access.leaf.d.ts +26 -0
- package/dist/utility/chart/opra-read-access.leaf.js +25 -0
- package/dist/utility/chart/prediction-identity.util.d.ts +159 -0
- package/dist/utility/chart/prediction-identity.util.js +236 -0
- package/dist/utility/chart/rth-session.util.d.ts +352 -0
- package/dist/utility/chart/rth-session.util.js +926 -0
- package/dist/utility/chart/titan-constants.pin.d.ts +43 -0
- package/dist/utility/chart/titan-constants.pin.js +50 -0
- package/dist/utility/chart/us-equities-session.util.d.ts +127 -0
- package/dist/utility/chart/us-equities-session.util.js +251 -0
- package/dist/utility/chart/window-geometry.leaf.d.ts +119 -0
- package/dist/utility/chart/window-geometry.leaf.js +391 -0
- package/dist/utility/chart/window-owner.leaf.d.ts +19 -0
- package/dist/utility/chart/window-owner.leaf.js +24 -0
- package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +100 -0
- package/dist/utility/chart/wrun-bar-session-facts.util.js +354 -0
- package/dist/utility/chart/wrun-wire-ref.util.d.ts +23 -0
- package/dist/utility/chart/wrun-wire-ref.util.js +16 -0
- package/dist/utility/common/safe-math-eval.d.ts +18 -0
- package/dist/utility/common/safe-math-eval.js +160 -0
- package/dist/utility/common/time.util.d.ts +134 -0
- package/dist/utility/common/time.util.js +428 -0
- package/dist/utility/common/transformations.util.d.ts +126 -0
- package/dist/utility/common/transformations.util.js +711 -0
- package/dist/utility/common/visible-timeout.util.d.ts +17 -0
- package/dist/utility/common/visible-timeout.util.js +75 -0
- package/dist/utility/exchange-normalization.util.d.ts +8 -0
- package/dist/utility/exchange-normalization.util.js +32 -0
- package/dist/utility/html-escape.leaf.d.ts +11 -0
- package/dist/utility/html-escape.leaf.js +20 -0
- package/dist/utility/intl-locale.util.d.ts +2 -0
- package/dist/utility/intl-locale.util.js +28 -0
- package/dist/utility/number-format.util.d.ts +14 -1
- package/dist/utility/number-format.util.js +50 -19
- package/dist/utility/options/option-symbol.util.d.ts +28 -0
- package/dist/utility/options/option-symbol.util.js +176 -0
- package/dist/utility/options/option-trade-units.util.d.ts +190 -0
- package/dist/utility/options/option-trade-units.util.js +283 -0
- package/dist/utility/options/option-venue.util.d.ts +75 -0
- package/dist/utility/options/option-venue.util.js +85 -0
- package/dist/utility/pool-symbol.leaf.d.ts +34 -0
- package/dist/utility/pool-symbol.leaf.js +95 -0
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +109 -0
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +302 -0
- package/dist/utility/symbol-selection/contract-expiry.util.d.ts +39 -0
- package/dist/utility/symbol-selection/contract-expiry.util.js +111 -0
- package/dist/utility/v2/gate-plane.util.d.ts +58 -0
- package/dist/utility/v2/gate-plane.util.js +99 -0
- package/dist/utility/v2/gate-session-latch.util.d.ts +22 -0
- package/dist/utility/v2/gate-session-latch.util.js +34 -0
- package/dist/utility/watchlist/import/tradingview-symbols.leaf.d.ts +76 -0
- package/dist/utility/watchlist/import/tradingview-symbols.leaf.js +221 -0
- package/dist/utility/wrun/sources/host-grid-landing.d.ts +15 -0
- package/dist/utility/wrun/sources/host-grid-landing.js +26 -0
- package/dist/utility/wrun/sources/lanes/bitfinex_funding.d.ts +27 -0
- package/dist/utility/wrun/sources/lanes/bitfinex_funding.js +85 -0
- package/dist/utility/wrun/sources/lanes/economic.d.ts +27 -0
- package/dist/utility/wrun/sources/lanes/economic.js +79 -0
- package/dist/utility/wrun/sources/lanes/etf_holdings.d.ts +35 -0
- package/dist/utility/wrun/sources/lanes/etf_holdings.js +165 -0
- package/dist/utility/wrun/sources/lanes/etf_premium.d.ts +19 -0
- package/dist/utility/wrun/sources/lanes/etf_premium.js +114 -0
- package/dist/utility/wrun/sources/lanes/ethena_positions.d.ts +30 -0
- package/dist/utility/wrun/sources/lanes/ethena_positions.js +51 -0
- package/dist/utility/wrun/sources/lanes/index.d.ts +2 -0
- package/dist/utility/wrun/sources/lanes/index.js +32 -0
- package/dist/utility/wrun/sources/lanes/long_short_ratio.d.ts +17 -0
- package/dist/utility/wrun/sources/lanes/long_short_ratio.js +47 -0
- package/dist/utility/wrun/sources/lanes/option_daily.d.ts +58 -0
- package/dist/utility/wrun/sources/lanes/option_daily.js +111 -0
- package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +27 -0
- package/dist/utility/wrun/sources/lanes/option_stats_10m.js +21 -0
- package/dist/utility/wrun/sources/lanes/options_flow.d.ts +50 -0
- package/dist/utility/wrun/sources/lanes/options_flow.js +155 -0
- package/dist/utility/wrun/sources/lanes/options_oi.d.ts +29 -0
- package/dist/utility/wrun/sources/lanes/options_oi.js +59 -0
- package/dist/utility/wrun/sources/lanes/options_volume.d.ts +38 -0
- package/dist/utility/wrun/sources/lanes/options_volume.js +63 -0
- package/dist/utility/wrun/sources/lanes/series.d.ts +67 -0
- package/dist/utility/wrun/sources/lanes/series.js +321 -0
- package/dist/utility/wrun/sources/lanes/token_supply.d.ts +30 -0
- package/dist/utility/wrun/sources/lanes/token_supply.js +145 -0
- package/dist/utility/wrun/sources/lanes/treasury_balance.d.ts +25 -0
- package/dist/utility/wrun/sources/lanes/treasury_balance.js +47 -0
- package/dist/utility/wrun/sources/lanes/volatility_index.d.ts +21 -0
- package/dist/utility/wrun/sources/lanes/volatility_index.js +11 -0
- package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +215 -0
- package/dist/utility/wrun/sources/opra-option-lanes.util.js +477 -0
- package/dist/utility/wrun/sources/registry.d.ts +21 -0
- package/dist/utility/wrun/sources/registry.js +237 -0
- package/dist/utility/wrun/sources/row-lane-registry.d.ts +28 -0
- package/dist/utility/wrun/sources/row-lane-registry.js +230 -0
- package/dist/utility/wrun/sources/row-lanes/index.d.ts +2 -0
- package/dist/utility/wrun/sources/row-lanes/index.js +12 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +2 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +38 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +55 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +126 -0
- package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +4 -0
- package/dist/utility/wrun/sources/row-lanes/option_prints.js +191 -0
- package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +62 -0
- package/dist/utility/wrun/sources/row-lanes/option_strikes.js +147 -0
- package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +70 -0
- package/dist/utility/wrun/sources/row-lanes/option_surface.js +144 -0
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +309 -0
- package/dist/utility/wrun/sources/wrun-poll-lane.types.js +26 -0
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +350 -0
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +576 -0
- package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +275 -0
- package/dist/utility/wrun/sources/wrun-row-lane.types.js +16 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +207 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +450 -0
- package/dist/utility/wrun/wrun-browser-sources.leaf.d.ts +28 -0
- package/dist/utility/wrun/wrun-browser-sources.leaf.js +66 -0
- package/dist/utility/wrun/wrun-cloud-record.util.d.ts +65 -0
- package/dist/utility/wrun/wrun-cloud-record.util.js +121 -0
- package/dist/utility/wrun/wrun-daily-lane.util.d.ts +95 -0
- package/dist/utility/wrun/wrun-daily-lane.util.js +297 -0
- package/dist/utility/wrun/wrun-deadline.util.d.ts +52 -0
- package/dist/utility/wrun/wrun-deadline.util.js +82 -0
- package/dist/utility/wrun/wrun-etf-flow-lane.util.d.ts +94 -0
- package/dist/utility/wrun/wrun-etf-flow-lane.util.js +224 -0
- package/dist/utility/wrun/wrun-etf-funds.util.d.ts +82 -0
- package/dist/utility/wrun/wrun-etf-funds.util.js +242 -0
- package/dist/utility/wrun/wrun-frames.d.ts +20 -1
- package/dist/utility/wrun/wrun-frames.js +103 -49
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +2 -2
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +27 -0
- package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +22 -0
- package/dist/utility/wrun/wrun-lane-refusal.leaf.js +32 -0
- package/dist/utility/wrun/wrun-lane-warmup.util.d.ts +18 -0
- package/dist/utility/wrun/wrun-lane-warmup.util.js +112 -0
- package/dist/utility/wrun/wrun-leg-close.util.d.ts +57 -0
- package/dist/utility/wrun/wrun-leg-close.util.js +187 -0
- package/dist/utility/wrun/wrun-leg-fetch.util.d.ts +144 -0
- package/dist/utility/wrun/wrun-leg-fetch.util.js +212 -0
- package/dist/utility/wrun/wrun-leg-stream-classes.d.ts +73 -0
- package/dist/utility/wrun/wrun-leg-stream-classes.js +86 -0
- package/dist/utility/wrun/wrun-levels-child.util.d.ts +101 -6
- package/dist/utility/wrun/wrun-levels-child.util.js +335 -157
- package/dist/utility/wrun/wrun-memory-clamp.util.d.ts +33 -0
- package/dist/utility/wrun/wrun-memory-clamp.util.js +146 -0
- package/dist/utility/wrun/wrun-odds-template-market.util.d.ts +51 -0
- package/dist/utility/wrun/wrun-odds-template-market.util.js +251 -0
- package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +65 -0
- package/dist/utility/wrun/wrun-opra-flow.leaf.js +94 -0
- package/dist/utility/wrun/wrun-opra-lane.util.d.ts +47 -0
- package/dist/utility/wrun/wrun-opra-lane.util.js +58 -0
- package/dist/utility/wrun/wrun-opra-stats.leaf.d.ts +49 -0
- package/dist/utility/wrun/wrun-opra-stats.leaf.js +115 -0
- package/dist/utility/wrun/wrun-opra-underlying.util.d.ts +12 -0
- package/dist/utility/wrun/wrun-opra-underlying.util.js +1 -0
- package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +142 -0
- package/dist/utility/wrun/wrun-option-contract-flow.util.js +451 -0
- package/dist/utility/wrun/wrun-option-knobs.util.d.ts +43 -0
- package/dist/utility/wrun/wrun-option-knobs.util.js +81 -0
- package/dist/utility/wrun/wrun-option-prints.util.d.ts +144 -0
- package/dist/utility/wrun/wrun-option-prints.util.js +356 -0
- package/dist/utility/wrun/wrun-option-summary-lane.util.d.ts +102 -0
- package/dist/utility/wrun/wrun-option-summary-lane.util.js +143 -0
- package/dist/utility/wrun/wrun-options-chain.util.d.ts +308 -0
- package/dist/utility/wrun/wrun-options-chain.util.js +502 -0
- package/dist/utility/wrun/wrun-overlay-identity.util.d.ts +9 -4
- package/dist/utility/wrun/wrun-overlay-identity.util.js +16 -6
- package/dist/utility/wrun/wrun-panel-mount.lazy.d.ts +10 -0
- package/dist/utility/wrun/wrun-panel-mount.lazy.js +68 -0
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +377 -0
- package/dist/utility/wrun/wrun-panel-mount.util.js +2251 -0
- package/dist/utility/wrun/wrun-param-map.util.d.ts +298 -0
- package/dist/utility/wrun/wrun-param-map.util.js +581 -0
- package/dist/utility/wrun/wrun-pause-dim.util.d.ts +52 -0
- package/dist/utility/wrun/wrun-pause-dim.util.js +153 -0
- package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +149 -0
- package/dist/utility/wrun/wrun-pin-spelling.util.js +523 -0
- package/dist/utility/wrun/wrun-pin-venues.util.d.ts +116 -0
- package/dist/utility/wrun/wrun-pin-venues.util.js +320 -0
- package/dist/utility/wrun/wrun-pinned-interval.util.d.ts +20 -0
- package/dist/utility/wrun/wrun-pinned-interval.util.js +47 -0
- package/dist/utility/wrun/wrun-plot-gate.types.d.ts +23 -0
- package/dist/utility/wrun/wrun-plot-gate.types.js +7 -0
- package/dist/utility/wrun/wrun-present-bits.util.d.ts +37 -0
- package/dist/utility/wrun/wrun-present-bits.util.js +73 -0
- package/dist/utility/wrun/wrun-protocol-pending.util.d.ts +33 -0
- package/dist/utility/wrun/wrun-protocol-pending.util.js +57 -0
- package/dist/utility/wrun/wrun-refusal.util.d.ts +41 -1
- package/dist/utility/wrun/wrun-refusal.util.js +69 -2
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +1 -14
- package/dist/utility/wrun/wrun-registry-errors.util.js +0 -16
- package/dist/utility/wrun/wrun-row-source.d.ts +158 -0
- package/dist/utility/wrun/wrun-row-source.js +75 -0
- package/dist/utility/wrun/wrun-run-health.util.d.ts +155 -0
- package/dist/utility/wrun/wrun-run-health.util.js +273 -0
- package/dist/utility/wrun/wrun-run-interval-projection.types.d.ts +14 -0
- package/dist/utility/wrun/wrun-run-interval-projection.types.js +1 -0
- package/dist/utility/wrun/wrun-socket-row-source.d.ts +439 -0
- package/dist/utility/wrun/wrun-socket-row-source.js +1689 -0
- package/dist/utility/wrun/wrun-socket-session-losses.util.d.ts +18 -0
- package/dist/utility/wrun/wrun-socket-session-losses.util.js +25 -0
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +911 -0
- package/dist/utility/wrun/wrun-source-rows.util.js +2597 -0
- package/dist/utility/wrun/wrun-tape-source.util.d.ts +82 -0
- package/dist/utility/wrun/wrun-tape-source.util.js +151 -0
- package/dist/utility/wrun/wrun-tier-grid.util.d.ts +137 -0
- package/dist/utility/wrun/wrun-tier-grid.util.js +279 -0
- package/dist/utility/wrun/wrun-trades-lane.util.d.ts +52 -0
- package/dist/utility/wrun/wrun-trades-lane.util.js +58 -0
- package/dist/utility/wrun/wrun-volume-profile-lane.util.d.ts +41 -0
- package/dist/utility/wrun/wrun-volume-profile-lane.util.js +66 -0
- package/dist/utility/wrun-display-name.util.d.ts +33 -0
- package/dist/utility/wrun-display-name.util.js +64 -0
- package/dist/workers/constants/kscript-transport-codes.d.ts +15 -0
- package/dist/workers/constants/kscript-transport-codes.js +15 -0
- package/dist/workers/constants/socket-slots.d.ts +574 -0
- package/dist/workers/constants/socket-slots.js +539 -0
- package/dist/workers/utils/number.worker.util.d.ts +5 -0
- package/dist/workers/utils/number.worker.util.js +10 -0
- package/dist/workers/utils/time.worker.util.d.ts +12 -0
- package/dist/workers/utils/time.worker.util.js +24 -0
- package/dist/workers/utils/volume-profile.worker.util.d.ts +200 -0
- package/dist/workers/utils/volume-profile.worker.util.js +631 -0
- package/package.json +10 -4
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The settings templates contract (TEMPLATES-PLAN, the frozen API): one declared field table per indicator and drawing
|
|
3
|
+
* type, shipped to web and the phone in this package, and the capture, patch and stored-shape rules every template door
|
|
4
|
+
* runs. A template door reads the engine's settings at the click (never a UI copy), captures them here, stores
|
|
5
|
+
* toStoredEntry's envelope, reads a stored entry back through migrateTemplate, and applies templatePatch's groups to
|
|
6
|
+
* the destination, each through the owner's own write.
|
|
7
|
+
*
|
|
8
|
+
* Lanes (a field is saved in each lane it names):
|
|
9
|
+
* - `row`: an indicator's workspace row (the persistence list; fieldKeys('indicator', type, 'row') equals the list it
|
|
10
|
+
* replaced, settingsToSave and its type lists).
|
|
11
|
+
* - `template`: a named template.
|
|
12
|
+
* - `default`: Save as default and its restore (a drawing's style memory, an indicator's saved defaults).
|
|
13
|
+
* - `mirror`: the FRVP box's copy of its companion profile.
|
|
14
|
+
* Owners: `settings` (the settings bag), `meta` (the bag's `meta` object), `box` and `profile` (the FRVP's drawing and
|
|
15
|
+
* its companion overlay). fieldKeys names a meta field `meta.<key>`, every other field by its key.
|
|
16
|
+
*
|
|
17
|
+
* Rules every kind follows:
|
|
18
|
+
* - Instance state (`instance`) is never written by a patch: which instance this is stays the destination's.
|
|
19
|
+
* - A market-bound field is written only when the template's market and the destination's (`ctx.market`) are both
|
|
20
|
+
* named and equal; on another market it is skipped, not dropped.
|
|
21
|
+
* - "Show on" (`visibleIntervalsMs`): absent keeps the destination, `[]` is All intervals, a list is that list; a
|
|
22
|
+
* legacy clear (`null`, or a key held as undefined) is written as `[]`. A capture writes `[]` where the engine holds
|
|
23
|
+
* none, so a saved template always states it (an interval-bound drawing keeps its own, as instance state). A
|
|
24
|
+
* version 1 template (saved before captures stated it) stored All intervals as no key at all, so one that holds none
|
|
25
|
+
* writes `[]` onto a restricted destination of every indicator and drawing but the FRVP (which keeps its own since
|
|
26
|
+
* 2026-10-17) and an interval-bound drawing: the rule web applied to it, read at patch time so the stored entry stays
|
|
27
|
+
* as it was.
|
|
28
|
+
* - Any other key a template lacks keeps the destination's value: a template saved before a field existed applies.
|
|
29
|
+
* - `dropped` names every key the template holds that its type does not take from a template (undeclared, or declared
|
|
30
|
+
* outside the template lane: a lock, a name, a row-only key), so a door can record what a template could not set. A
|
|
31
|
+
* market-bound field skipped on another market, and the venue choice (captured for the host's venue adapter, which
|
|
32
|
+
* writes it), are no loss and are not named.
|
|
33
|
+
*
|
|
34
|
+
* Stored shape: the user service keeps a template entry's `settings` bag, `market` and `schemaVersion` and strips any
|
|
35
|
+
* other top-level field, so toStoredEntry folds the meta group into `settings.meta` and the FRVP profile group into
|
|
36
|
+
* the flat bag, the shape every client reads; migrateTemplate splits them out again. An entry without a schemaVersion
|
|
37
|
+
* is version 1 (a save from before this contract, read with the same rules); one above TEMPLATE_SCHEMA_VERSION throws
|
|
38
|
+
* TemplateSchemaVersionError, so a door refuses to apply or overwrite what a newer client wrote.
|
|
39
|
+
*
|
|
40
|
+
* Steps that stay in a host's door, around these calls: a multi-venue indicator's venue choice (the template's
|
|
41
|
+
* `meta.venueChoice`, written through the control's venue adapter), the template of a script filed under the bare
|
|
42
|
+
* TECHNICAL_SCRIPT type (its values checked against the live script's declared input kinds), a built-in's template on
|
|
43
|
+
* its proven twin (mapped onto the twin's rows), and the colour ownership of an unflagged palette.
|
|
44
|
+
*/
|
|
45
|
+
import cloneDeep from 'lodash-es/cloneDeep.js';
|
|
46
|
+
import { isWrunViewerRowKey } from '../utility/wrun/wrun-color-facts.util.js';
|
|
47
|
+
import { FRVP_FIELD_ROWS, FRVP_TOOL_TYPE } from './frvp-fields.js';
|
|
48
|
+
import { INDICATOR_COMMON_FIELDS, INDICATOR_TYPE_FIELDS, RESERVED_SCRIPT_INPUT_NAMES, SCRIPT_INDICATOR_TYPE, SCRIPT_INPUT_FIELD, VIEWER_ROW_FIELD, } from './indicator-fields.js';
|
|
49
|
+
import { TOOL_TEMPLATE_RULES } from './tool-rules.js';
|
|
50
|
+
import { TOOL_DEFAULT_STYLE, TOOL_TEMPLATE_KEYS } from './tool-tables.generated.js';
|
|
51
|
+
export { TOOL_DEFAULT_STYLE, TOOL_TEMPLATE_KEYS };
|
|
52
|
+
/** The schema version a capture stamps on the template envelope (never inside the settings bag). */
|
|
53
|
+
export const TEMPLATE_SCHEMA_VERSION = 2;
|
|
54
|
+
/**
|
|
55
|
+
* A stored template a door must not read: its schemaVersion is above this client's (a newer client wrote it) or is
|
|
56
|
+
* no version at all. The door refuses to apply it and refuses to overwrite it.
|
|
57
|
+
*/
|
|
58
|
+
export class TemplateSchemaVersionError extends Error {
|
|
59
|
+
code = 'settings_template_schema_unsupported';
|
|
60
|
+
schemaVersion;
|
|
61
|
+
supported;
|
|
62
|
+
constructor(schemaVersion) {
|
|
63
|
+
super(`settings_template_schema_unsupported: a template stored with schemaVersion ${String(schemaVersion)} ` +
|
|
64
|
+
`needs a client that reads it (this one reads 1 to ${TEMPLATE_SCHEMA_VERSION})`);
|
|
65
|
+
this.name = 'TemplateSchemaVersionError';
|
|
66
|
+
this.schemaVersion = schemaVersion;
|
|
67
|
+
this.supported = TEMPLATE_SCHEMA_VERSION;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const VISIBLE_INTERVALS_KEY = 'visibleIntervalsMs';
|
|
71
|
+
const VENUE_CHOICE_META_KEY = 'venueChoice';
|
|
72
|
+
const RESERVED_INPUT_NAMES = new Set(RESERVED_SCRIPT_INPUT_NAMES);
|
|
73
|
+
/** Names an object prototype reserves: never a field, whatever a script declares (a write would reach the prototype). */
|
|
74
|
+
const PROTOTYPE_NAMES = new Set(['__proto__', 'constructor', 'prototype']);
|
|
75
|
+
const TOOL_INSTANCE_KEYS = TOOL_TEMPLATE_RULES.instanceKeys;
|
|
76
|
+
const INTERVAL_BOUND_TYPES = new Set(TOOL_TEMPLATE_RULES.intervalBoundTypes);
|
|
77
|
+
const DEFAULT_EXCLUDED_KEYS = new Set(TOOL_TEMPLATE_RULES.defaultExcludedKeys);
|
|
78
|
+
const DEFAULT_EXCLUDED_TYPES = new Set(TOOL_TEMPLATE_RULES.defaultExcludedTypes);
|
|
79
|
+
const isRecord = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
|
|
80
|
+
const nonEmpty = (value) => typeof value === 'string' && value !== '' ? value : undefined;
|
|
81
|
+
const ownRecord = (record, key) => Object.hasOwn(record, key) ? record[key] : undefined;
|
|
82
|
+
/** The indicator type a type key names: a script's filing key (`TECHNICAL_SCRIPT:script:RSI`) is its script type. */
|
|
83
|
+
const indicatorBaseType = (type) => type.startsWith(`${SCRIPT_INDICATOR_TYPE}:`) ? SCRIPT_INDICATOR_TYPE : type;
|
|
84
|
+
const isScript = (kind, type) => kind === 'indicator' && indicatorBaseType(type) === SCRIPT_INDICATOR_TYPE;
|
|
85
|
+
const isFrvp = (kind, type) => kind === 'tool' && type === FRVP_TOOL_TYPE;
|
|
86
|
+
const isFrvpOwner = (owner) => owner === 'box' || owner === 'profile';
|
|
87
|
+
/** Whether a drawing type keeps the "Show on" intervals it was drawn with, whatever a template holds. */
|
|
88
|
+
export function isIntervalBoundTool(type) {
|
|
89
|
+
return INTERVAL_BOUND_TYPES.has(type);
|
|
90
|
+
}
|
|
91
|
+
function specOf(key, field) {
|
|
92
|
+
const spec = { key, owner: field.owner ?? 'settings', lanes: Object.freeze([...field.lanes]) };
|
|
93
|
+
if (field.instance)
|
|
94
|
+
spec.instance = true;
|
|
95
|
+
if (field.marketBound)
|
|
96
|
+
spec.marketBound = true;
|
|
97
|
+
if (field.unset !== undefined)
|
|
98
|
+
spec.unset = field.unset;
|
|
99
|
+
return Object.freeze(spec);
|
|
100
|
+
}
|
|
101
|
+
/** An indicator type's fields: the shared rows, then its own (a row of the same owner and key replaces in place). */
|
|
102
|
+
function indicatorSpecs(type) {
|
|
103
|
+
const own = Object.hasOwn(INDICATOR_TYPE_FIELDS, type) ? INDICATOR_TYPE_FIELDS[type] : [];
|
|
104
|
+
const specs = new Map();
|
|
105
|
+
for (const [key, field] of [...INDICATOR_COMMON_FIELDS, ...own]) {
|
|
106
|
+
const spec = specOf(key, field);
|
|
107
|
+
specs.set(`${spec.owner}:${key}`, spec);
|
|
108
|
+
}
|
|
109
|
+
return [...specs.values()];
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* A drawing type's fields, from the generated tables: its style (registry defaultStyle and held extras) and "Show on"
|
|
113
|
+
* in the template lane, its style minus the geometry and financial inputs in the default lane, and the per-drawing
|
|
114
|
+
* instance keys. The FRVP's are its own table (box and profile). A type the registry does not know declares only the
|
|
115
|
+
* instance keys: nothing of it is taken from a template.
|
|
116
|
+
*/
|
|
117
|
+
function toolSpecs(type) {
|
|
118
|
+
if (type === FRVP_TOOL_TYPE)
|
|
119
|
+
return FRVP_FIELD_ROWS.map(([key, field]) => specOf(key, field));
|
|
120
|
+
const style = ownRecord(TOOL_DEFAULT_STYLE, type);
|
|
121
|
+
const templateKeys = new Set(ownRecord(TOOL_TEMPLATE_KEYS, type) ?? []);
|
|
122
|
+
const keepsDefaults = !DEFAULT_EXCLUDED_TYPES.has(type);
|
|
123
|
+
const specs = [];
|
|
124
|
+
for (const key of new Set([...Object.keys(style ?? {}), ...templateKeys])) {
|
|
125
|
+
if (key === VISIBLE_INTERVALS_KEY || TOOL_INSTANCE_KEYS.includes(key))
|
|
126
|
+
continue;
|
|
127
|
+
const lanes = [];
|
|
128
|
+
if (templateKeys.has(key))
|
|
129
|
+
lanes.push('template');
|
|
130
|
+
if (keepsDefaults && !!style && Object.hasOwn(style, key) && !DEFAULT_EXCLUDED_KEYS.has(key))
|
|
131
|
+
lanes.push('default');
|
|
132
|
+
specs.push(specOf(key, { lanes }));
|
|
133
|
+
}
|
|
134
|
+
if (isIntervalBoundTool(type))
|
|
135
|
+
specs.push(specOf(VISIBLE_INTERVALS_KEY, { lanes: [], instance: true }));
|
|
136
|
+
else if (templateKeys.has(VISIBLE_INTERVALS_KEY)) {
|
|
137
|
+
specs.push(specOf(VISIBLE_INTERVALS_KEY, { lanes: ['template'], unset: Object.freeze([]) }));
|
|
138
|
+
}
|
|
139
|
+
for (const key of TOOL_INSTANCE_KEYS)
|
|
140
|
+
specs.push(specOf(key, { lanes: [], instance: true }));
|
|
141
|
+
return specs;
|
|
142
|
+
}
|
|
143
|
+
const BASE_SPECS = new Map();
|
|
144
|
+
function baseSpecs(kind, type) {
|
|
145
|
+
const base = kind === 'tool' ? type : indicatorBaseType(type);
|
|
146
|
+
const cacheKey = `${kind}:${base}`;
|
|
147
|
+
let specs = BASE_SPECS.get(cacheKey);
|
|
148
|
+
if (!specs) {
|
|
149
|
+
specs = Object.freeze(kind === 'tool' ? toolSpecs(base) : indicatorSpecs(base));
|
|
150
|
+
BASE_SPECS.set(cacheKey, specs);
|
|
151
|
+
}
|
|
152
|
+
return specs;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* A technical script's instance fields: its declared inputs, then its viewer rows (a key `isWrunViewerRowKey` reads as
|
|
156
|
+
* one). A declared input is the script's own field in the row, template and default lanes, in the order declared. A
|
|
157
|
+
* reserved name or an object prototype's adds none, and neither does a name a shared row the row keeps already declares
|
|
158
|
+
* (that row stands). A name a shared row the row does not keep declares (the host's runtime or identity keys: `tf`,
|
|
159
|
+
* `data`, `id`) is the script's input: the shared row is `replaced` by it.
|
|
160
|
+
*/
|
|
161
|
+
function contextSpecs(base, ctx) {
|
|
162
|
+
const shared = new Map(base.filter((spec) => spec.owner !== 'meta').map((spec) => [spec.key, spec]));
|
|
163
|
+
const taken = new Set();
|
|
164
|
+
const replaced = new Set();
|
|
165
|
+
const specs = [];
|
|
166
|
+
const add = (key, field) => {
|
|
167
|
+
taken.add(key);
|
|
168
|
+
specs.push(specOf(key, field));
|
|
169
|
+
};
|
|
170
|
+
for (const name of ctx.declaredInputs ?? []) {
|
|
171
|
+
if (typeof name !== 'string' || name === '' || taken.has(name))
|
|
172
|
+
continue;
|
|
173
|
+
if (RESERVED_INPUT_NAMES.has(name) || PROTOTYPE_NAMES.has(name))
|
|
174
|
+
continue;
|
|
175
|
+
const sharedSpec = shared.get(name);
|
|
176
|
+
// A shared row the row keeps (a preference, the instance's market or name) stands for the input of that name.
|
|
177
|
+
if (sharedSpec?.lanes.includes('row'))
|
|
178
|
+
continue;
|
|
179
|
+
// A runtime or identity row of the host (`tf`, `data`, `id`): the script declares the name, so it is the script's
|
|
180
|
+
// own input, persisted and carried under its name, never the host's key.
|
|
181
|
+
if (sharedSpec)
|
|
182
|
+
replaced.add(name);
|
|
183
|
+
add(name, SCRIPT_INPUT_FIELD);
|
|
184
|
+
}
|
|
185
|
+
for (const key of ctx.viewerKeys ?? []) {
|
|
186
|
+
if (typeof key === 'string' && !taken.has(key) && !shared.has(key) && isWrunViewerRowKey(key)) {
|
|
187
|
+
add(key, VIEWER_ROW_FIELD);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return { specs, replaced };
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Every field a type declares, with what each lane keeps. For a technical script `ctx` adds its declared inputs and
|
|
194
|
+
* viewer rows (a script's filing key, `TECHNICAL_SCRIPT:<identity>`, reads as its type). The specs are frozen.
|
|
195
|
+
*/
|
|
196
|
+
export function fieldSpecs(kind, type, ctx) {
|
|
197
|
+
const base = baseSpecs(kind, type);
|
|
198
|
+
if (!ctx || !isScript(kind, type))
|
|
199
|
+
return base;
|
|
200
|
+
const { specs: extra, replaced } = contextSpecs(base, ctx);
|
|
201
|
+
if (!extra.length)
|
|
202
|
+
return base;
|
|
203
|
+
const kept = replaced.size ? base.filter((spec) => spec.owner === 'meta' || !replaced.has(spec.key)) : base;
|
|
204
|
+
return Object.freeze([...kept, ...extra]);
|
|
205
|
+
}
|
|
206
|
+
/** The keys one lane keeps, in table order: a meta field as `meta.<key>`, every other field by its key. */
|
|
207
|
+
export function fieldKeys(kind, type, lane, ctx) {
|
|
208
|
+
return fieldSpecs(kind, type, ctx)
|
|
209
|
+
.filter((spec) => spec.lanes.includes(lane))
|
|
210
|
+
.map((spec) => (spec.owner === 'meta' ? `meta.${spec.key}` : spec.key));
|
|
211
|
+
}
|
|
212
|
+
/** A script's declared input names, read off its settings (`scriptInputs`). */
|
|
213
|
+
function inputNamesOf(settings) {
|
|
214
|
+
const inputs = settings.scriptInputs;
|
|
215
|
+
if (!Array.isArray(inputs))
|
|
216
|
+
return [];
|
|
217
|
+
return inputs.flatMap((input) => {
|
|
218
|
+
const name = isRecord(input) ? nonEmpty(input.name) : undefined;
|
|
219
|
+
return name ? [name] : [];
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
const viewerKeysOf = (settings) => Object.keys(settings).filter(isWrunViewerRowKey);
|
|
223
|
+
/**
|
|
224
|
+
* A multi-venue indicator's venue choice as a template carries it: a catalog group or venues by name, in canonical
|
|
225
|
+
* form (the stored legs signature left out); any other value (no pick, the chart's own market) carries nothing.
|
|
226
|
+
*/
|
|
227
|
+
function carriedVenueChoice(value) {
|
|
228
|
+
if (!isRecord(value))
|
|
229
|
+
return undefined;
|
|
230
|
+
if (value.kind === 'preset') {
|
|
231
|
+
return value.preset === 'SPOT' || value.preset === 'PERP' ? { kind: 'preset', preset: value.preset } : undefined;
|
|
232
|
+
}
|
|
233
|
+
if (value.kind !== 'names' || !Array.isArray(value.exchanges))
|
|
234
|
+
return undefined;
|
|
235
|
+
const names = value.exchanges.filter((name) => typeof name === 'string' && name.length > 0);
|
|
236
|
+
const exchanges = [...new Set(names)];
|
|
237
|
+
return exchanges.length ? { kind: 'names', exchanges } : undefined;
|
|
238
|
+
}
|
|
239
|
+
/** The value a capture keeps of one field: the engine's (an FRVP's null reads as none), else the declared unset. */
|
|
240
|
+
function capturedValue(spec, source) {
|
|
241
|
+
let value = ownRecord(source, spec.key);
|
|
242
|
+
if (spec.owner === 'meta' && spec.key === VENUE_CHOICE_META_KEY)
|
|
243
|
+
value = carriedVenueChoice(value);
|
|
244
|
+
else if (value === null && (isFrvpOwner(spec.owner) || spec.key === VISIBLE_INTERVALS_KEY))
|
|
245
|
+
value = undefined;
|
|
246
|
+
if (value === undefined)
|
|
247
|
+
return spec.unset === undefined ? undefined : cloneDeep(spec.unset);
|
|
248
|
+
return cloneDeep(value);
|
|
249
|
+
}
|
|
250
|
+
const groupOf = (groups, owner) => owner === 'meta' ? groups.meta : owner === 'profile' ? groups.profile : groups.settings;
|
|
251
|
+
/**
|
|
252
|
+
* A template of one instance, from the engine's current settings: every template-lane field the engine holds, and the
|
|
253
|
+
* declared unset value of each one it holds none of (All intervals as `[]`, all naked levels as 0). An indicator's
|
|
254
|
+
* meta preferences are read off `engineSettings.meta`; an FRVP's settings are one bag, the box's keys over the
|
|
255
|
+
* profile's (the companion's own, not the box's mirror of them). `ctx.market` is the market it is saved on.
|
|
256
|
+
*/
|
|
257
|
+
export function captureTemplate(kind, type, engineSettings, ctx) {
|
|
258
|
+
const bag = isRecord(engineSettings) ? engineSettings : {};
|
|
259
|
+
const specs = fieldSpecs(kind, type, isScript(kind, type)
|
|
260
|
+
? {
|
|
261
|
+
...ctx,
|
|
262
|
+
declaredInputs: ctx?.declaredInputs ?? inputNamesOf(bag),
|
|
263
|
+
viewerKeys: ctx?.viewerKeys ?? viewerKeysOf(bag),
|
|
264
|
+
}
|
|
265
|
+
: ctx);
|
|
266
|
+
const engineMeta = isRecord(bag.meta) ? bag.meta : {};
|
|
267
|
+
const groups = { settings: {}, meta: {}, profile: {} };
|
|
268
|
+
for (const spec of specs) {
|
|
269
|
+
if (!spec.lanes.includes('template'))
|
|
270
|
+
continue;
|
|
271
|
+
const value = capturedValue(spec, spec.owner === 'meta' ? engineMeta : bag);
|
|
272
|
+
if (value !== undefined)
|
|
273
|
+
groupOf(groups, spec.owner)[spec.key] = value;
|
|
274
|
+
}
|
|
275
|
+
const doc = { schemaVersion: TEMPLATE_SCHEMA_VERSION, kind, type, settings: groups.settings };
|
|
276
|
+
const market = kind === 'indicator' ? nonEmpty(ctx?.market) : undefined;
|
|
277
|
+
if (market)
|
|
278
|
+
doc.market = market;
|
|
279
|
+
if (Object.keys(groups.meta).length)
|
|
280
|
+
doc.meta = groups.meta;
|
|
281
|
+
if (isFrvp(kind, type))
|
|
282
|
+
doc.profile = groups.profile;
|
|
283
|
+
return doc;
|
|
284
|
+
}
|
|
285
|
+
/** A value the patch refuses for its field: recorded in `dropped`, never written. */
|
|
286
|
+
const INVALID = Symbol('invalid template value');
|
|
287
|
+
/** The value a patch writes for one template field: a detached copy, an interval clear as `[]`, or nothing. */
|
|
288
|
+
function patchedValue(spec, value) {
|
|
289
|
+
if (spec.key === VISIBLE_INTERVALS_KEY) {
|
|
290
|
+
if (value === undefined || value === null)
|
|
291
|
+
return [];
|
|
292
|
+
return Array.isArray(value) ? cloneDeep(value) : INVALID;
|
|
293
|
+
}
|
|
294
|
+
if (value === undefined || (value === null && isFrvpOwner(spec.owner)))
|
|
295
|
+
return undefined;
|
|
296
|
+
return cloneDeep(value);
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* What one template writes onto one live instance of `type`: every template-lane field the template holds, by owner,
|
|
300
|
+
* never instance state, a market-bound field only when the template's market and `ctx.market` are both named and
|
|
301
|
+
* equal, and "Show on" by the interval table (absent keeps the destination, `[]` is All intervals, a legacy clear is
|
|
302
|
+
* `[]`, and a version 1 template that holds none clears a restricted destination but an FRVP or an interval-bound one). A
|
|
303
|
+
* script's fields are the destination's declared inputs (`ctx.declaredInputs`, else the live `scriptInputs`)
|
|
304
|
+
* and viewer rows (the live ones and the template's own). The template is a captured or migrated document; an older
|
|
305
|
+
* in-memory shape with its meta in `settings.meta` or an FRVP's profile keys in the flat bag reads the same.
|
|
306
|
+
*/
|
|
307
|
+
export function templatePatch(kind, type, live, template, ctx) {
|
|
308
|
+
const liveBag = isRecord(live) ? live : {};
|
|
309
|
+
const saved = isRecord(template?.settings) ? template.settings : {};
|
|
310
|
+
const nestedMeta = kind === 'indicator' && isRecord(saved.meta) ? saved.meta : undefined;
|
|
311
|
+
const savedMeta = { ...nestedMeta, ...(isRecord(template?.meta) ? template.meta : {}) };
|
|
312
|
+
const savedProfile = isRecord(template?.profile) ? template.profile : {};
|
|
313
|
+
const specs = fieldSpecs(kind, type, isScript(kind, type)
|
|
314
|
+
? {
|
|
315
|
+
...ctx,
|
|
316
|
+
declaredInputs: ctx?.declaredInputs ?? inputNamesOf(liveBag),
|
|
317
|
+
viewerKeys: [...(ctx?.viewerKeys ?? viewerKeysOf(liveBag)), ...viewerKeysOf(saved)],
|
|
318
|
+
}
|
|
319
|
+
: ctx);
|
|
320
|
+
const bagSpecs = new Map(specs.filter((spec) => spec.owner !== 'meta').map((spec) => [spec.key, spec]));
|
|
321
|
+
const metaSpecs = new Map(specs.filter((spec) => spec.owner === 'meta').map((spec) => [spec.key, spec]));
|
|
322
|
+
const templateMarket = nonEmpty(template?.market);
|
|
323
|
+
const sameMarket = !!templateMarket && templateMarket === nonEmpty(ctx?.market);
|
|
324
|
+
const groups = { settings: {}, meta: {}, profile: {} };
|
|
325
|
+
const dropped = new Set();
|
|
326
|
+
const take = (spec, value, name) => {
|
|
327
|
+
if (!spec || !spec.lanes.includes('template')) {
|
|
328
|
+
dropped.add(name);
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
// A template-lane field that is instance state (the venue choice) is the host's own writer's: never patched,
|
|
332
|
+
// and no loss either.
|
|
333
|
+
if (spec.instance || (spec.marketBound && !sameMarket))
|
|
334
|
+
return;
|
|
335
|
+
const written = patchedValue(spec, value);
|
|
336
|
+
if (written === INVALID)
|
|
337
|
+
dropped.add(name);
|
|
338
|
+
else if (written !== undefined)
|
|
339
|
+
groupOf(groups, spec.owner)[spec.key] = written;
|
|
340
|
+
};
|
|
341
|
+
for (const [key, value] of Object.entries(saved)) {
|
|
342
|
+
if (key !== 'meta' || value !== nestedMeta)
|
|
343
|
+
take(bagSpecs.get(key), value, key);
|
|
344
|
+
}
|
|
345
|
+
for (const [key, value] of Object.entries(savedProfile))
|
|
346
|
+
take(bagSpecs.get(key), value, key);
|
|
347
|
+
for (const [key, value] of Object.entries(savedMeta))
|
|
348
|
+
take(metaSpecs.get(key), value, `meta.${key}`);
|
|
349
|
+
// A version 1 template that holds no "Show on" was saved on All intervals: it clears a restricted destination, as web
|
|
350
|
+
// applied it (one already on all intervals is left as it is), on every type but the FRVP and an interval-bound one.
|
|
351
|
+
const intervals = bagSpecs.get(VISIBLE_INTERVALS_KEY);
|
|
352
|
+
const restricted = liveBag[VISIBLE_INTERVALS_KEY];
|
|
353
|
+
if (template?.schemaVersion === 1 &&
|
|
354
|
+
!Object.hasOwn(saved, VISIBLE_INTERVALS_KEY) &&
|
|
355
|
+
Array.isArray(restricted) &&
|
|
356
|
+
restricted.length > 0 &&
|
|
357
|
+
intervals &&
|
|
358
|
+
!intervals.instance &&
|
|
359
|
+
intervals.lanes.includes('template') &&
|
|
360
|
+
!isFrvp(kind, type)) {
|
|
361
|
+
groups.settings[VISIBLE_INTERVALS_KEY] = [];
|
|
362
|
+
}
|
|
363
|
+
const result = { patch: groups.settings, metaPatch: groups.meta, dropped: [...dropped] };
|
|
364
|
+
if (isFrvp(kind, type))
|
|
365
|
+
result.profilePatch = groups.profile;
|
|
366
|
+
return result;
|
|
367
|
+
}
|
|
368
|
+
/** A stored entry's schema version: none is version 1; one this client cannot read throws. */
|
|
369
|
+
function storedSchemaVersion(value) {
|
|
370
|
+
if (value === undefined || value === null)
|
|
371
|
+
return 1;
|
|
372
|
+
if (typeof value === 'number' && Number.isInteger(value) && value >= 1 && value <= TEMPLATE_SCHEMA_VERSION) {
|
|
373
|
+
return value;
|
|
374
|
+
}
|
|
375
|
+
throw new TemplateSchemaVersionError(value);
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* A stored template entry read back as a document of `kind` and `type`: the complete entry (its settings bag, meta,
|
|
379
|
+
* market and schemaVersion), a missing schemaVersion read as version 1 and one above TEMPLATE_SCHEMA_VERSION refused
|
|
380
|
+
* (TemplateSchemaVersionError). The groups are split out of the stored bag (an indicator's `settings.meta`, an FRVP's
|
|
381
|
+
* profile keys), a legacy "Show on" clear is normalised to `[]`, and the market is carried through. Nothing is
|
|
382
|
+
* dropped here: a key the type does not take stays in the document, and templatePatch records it in `dropped`. Nor is
|
|
383
|
+
* anything added: a version 1 template's absent "Show on" stays absent (templatePatch reads it as All intervals), so
|
|
384
|
+
* an entry read back through toStoredEntry is the entry as stored.
|
|
385
|
+
*/
|
|
386
|
+
export function migrateTemplate(entry, kind, type,
|
|
387
|
+
// Read by no rule yet: migration splits by owner and keeps every key, so the patch's `dropped` is its record.
|
|
388
|
+
_ctx) {
|
|
389
|
+
const source = isRecord(entry) ? entry : {};
|
|
390
|
+
const schemaVersion = storedSchemaVersion(source.schemaVersion);
|
|
391
|
+
const settings = isRecord(source.settings) ? cloneDeep(source.settings) : {};
|
|
392
|
+
const doc = { schemaVersion, kind, type, settings };
|
|
393
|
+
if (kind === 'indicator') {
|
|
394
|
+
const meta = {
|
|
395
|
+
...(isRecord(settings.meta) ? settings.meta : {}),
|
|
396
|
+
...(isRecord(source.meta) ? cloneDeep(source.meta) : {}),
|
|
397
|
+
};
|
|
398
|
+
if (isRecord(settings.meta))
|
|
399
|
+
delete settings.meta;
|
|
400
|
+
if (Object.keys(meta).length)
|
|
401
|
+
doc.meta = meta;
|
|
402
|
+
}
|
|
403
|
+
if (isFrvp(kind, type)) {
|
|
404
|
+
const profile = isRecord(source.profile) ? cloneDeep(source.profile) : {};
|
|
405
|
+
for (const [key, field] of FRVP_FIELD_ROWS) {
|
|
406
|
+
if (field.owner !== 'profile' || !Object.hasOwn(settings, key))
|
|
407
|
+
continue;
|
|
408
|
+
profile[key] = settings[key];
|
|
409
|
+
delete settings[key];
|
|
410
|
+
}
|
|
411
|
+
doc.profile = profile;
|
|
412
|
+
}
|
|
413
|
+
if (Object.hasOwn(settings, VISIBLE_INTERVALS_KEY) && settings[VISIBLE_INTERVALS_KEY] == null) {
|
|
414
|
+
settings[VISIBLE_INTERVALS_KEY] = [];
|
|
415
|
+
}
|
|
416
|
+
const market = nonEmpty(source.market);
|
|
417
|
+
if (market)
|
|
418
|
+
doc.market = market;
|
|
419
|
+
return doc;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* The envelope the user service keeps for a document (and a layout slot keeps): `settings`, `market` and
|
|
423
|
+
* `schemaVersion`, no other top-level field (the service strips one). The groups ride inside `settings` exactly as web
|
|
424
|
+
* stores them today: the meta group at `settings.meta`, an FRVP's profile preferences each under its own key in the
|
|
425
|
+
* flat bag beside the box's keys. migrateTemplate reads them back out into the document's `meta` and `profile`.
|
|
426
|
+
*/
|
|
427
|
+
export function toStoredEntry(doc) {
|
|
428
|
+
const settings = {
|
|
429
|
+
...cloneDeep(isRecord(doc.settings) ? doc.settings : {}),
|
|
430
|
+
...cloneDeep(isRecord(doc.profile) ? doc.profile : {}),
|
|
431
|
+
};
|
|
432
|
+
if (isRecord(doc.meta) && Object.keys(doc.meta).length)
|
|
433
|
+
settings.meta = cloneDeep(doc.meta);
|
|
434
|
+
const entry = {
|
|
435
|
+
settings,
|
|
436
|
+
schemaVersion: doc.schemaVersion,
|
|
437
|
+
};
|
|
438
|
+
const market = nonEmpty(doc.market);
|
|
439
|
+
if (market)
|
|
440
|
+
entry.market = market;
|
|
441
|
+
return entry;
|
|
442
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The indicator field tables (TEMPLATES-PLAN decision 1): every key an indicator's settings hold that a lane reads,
|
|
3
|
+
* declared once with the lanes that keep it. Workspace persistence (`row`), named templates (`template`) and Save as
|
|
4
|
+
* default with its restore (`default`) all read these rows through fieldSpecs and fieldKeys (./index.ts); no other
|
|
5
|
+
* list of indicator keys is kept by hand, on web or on the phone.
|
|
6
|
+
*
|
|
7
|
+
* Moved here from the web app, content unchanged: the persistence list settingsToSave and its type lists
|
|
8
|
+
* (src/constants/indicator.constants.ts), the instance keys and the template meta allowlists
|
|
9
|
+
* (src/utility/chart/indicator-defaults-apply.util.ts), the volatile keys (src/utility/chart/settings-templates.util.ts).
|
|
10
|
+
* Three changes are decisions of the plan, not drift: `runMode` is row-only instance state (A11); seven meta
|
|
11
|
+
* preferences a settings dialog writes are template-lane (decision 6: the Bitfinex position side, the Put/Call mode,
|
|
12
|
+
* the Turnover sides and period, the Aggregated Volume margin category, the Sector Volume asset type and the Insurance
|
|
13
|
+
* fund group), the ETF pick stays identity; and "all" is a declared value (`visibleIntervalsMs: []` is All intervals,
|
|
14
|
+
* `maxNakedLevels: 0` is all levels, decision 3), which a capture writes where the engine holds none.
|
|
15
|
+
*
|
|
16
|
+
* A row is `[key, field]`: the field's owner (the settings bag when it names none, else `meta`, the bag's `meta`
|
|
17
|
+
* object), its lanes, whether it is instance state (which instance this is: never written by a template or a saved
|
|
18
|
+
* default, kept by a reset) and whether it is bound to the market it was saved on. Imports nothing, so the tool
|
|
19
|
+
* tables' generator can read the FRVP table beside it without the package graph.
|
|
20
|
+
*/
|
|
21
|
+
/** A field as a table declares it: its owner (the settings bag when none is named), lanes, flags and unset value. */
|
|
22
|
+
export interface DeclaredField {
|
|
23
|
+
readonly owner?: 'settings' | 'meta' | 'box' | 'profile';
|
|
24
|
+
readonly lanes: readonly ('row' | 'template' | 'default' | 'mirror')[];
|
|
25
|
+
readonly instance?: true;
|
|
26
|
+
readonly marketBound?: true;
|
|
27
|
+
/** The value a capture writes where the engine holds none (a serialisable value: "all", never "absent"). */
|
|
28
|
+
readonly unset?: unknown;
|
|
29
|
+
}
|
|
30
|
+
/** One table row: a key and its declared field. */
|
|
31
|
+
export type DeclaredFieldRow = readonly [key: string, field: DeclaredField];
|
|
32
|
+
/** The type every technical script runs as: its declared inputs and viewer rows are fields of the instance. */
|
|
33
|
+
export declare const SCRIPT_INDICATOR_TYPE = "TECHNICAL_SCRIPT";
|
|
34
|
+
/** A technical script's declared input: a preference, filed with the script it belongs to. */
|
|
35
|
+
export declare const SCRIPT_INPUT_FIELD: DeclaredField;
|
|
36
|
+
/**
|
|
37
|
+
* A browser-run Indicator's viewer row (a HUD's Look pick and place, a heatmap's Sensitivity, a child the reader hid:
|
|
38
|
+
* `isWrunViewerRowKey`): the row keeps it and a template carries it, by key; Save as default does not.
|
|
39
|
+
*/
|
|
40
|
+
export declare const VIEWER_ROW_FIELD: DeclaredField;
|
|
41
|
+
/**
|
|
42
|
+
* Names a script input may declare that never become a field of the instance: the legend's error payload, rebuilt
|
|
43
|
+
* from live diagnostics every run (web HOST_TRANSIENT_SETTINGS_KEYS), and the doc-row source keys a doc row never
|
|
44
|
+
* carries out of the browser (web DOC_ROW_SOURCE_KEYS: the source, the doc rider, an editor cloud run's draft).
|
|
45
|
+
*/
|
|
46
|
+
export declare const RESERVED_SCRIPT_INPUT_NAMES: readonly string[];
|
|
47
|
+
/**
|
|
48
|
+
* Every indicator's fields, in the order of the persistence list they replace (settingsToSave, one row per key),
|
|
49
|
+
* then the instance and runtime keys the row never keeps, then the meta fields.
|
|
50
|
+
*/
|
|
51
|
+
export declare const INDICATOR_COMMON_FIELDS: readonly DeclaredFieldRow[];
|
|
52
|
+
/**
|
|
53
|
+
* The fields one indicator type declares beyond INDICATOR_COMMON_FIELDS: a row here adds a key, or replaces the shared
|
|
54
|
+
* row of the same owner and key.
|
|
55
|
+
*/
|
|
56
|
+
export declare const INDICATOR_TYPE_FIELDS: Readonly<Record<string, readonly DeclaredFieldRow[]>>;
|