@orangecharts/wrun-chart-host 0.15.0 → 0.16.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 +1 -0
- package/dist/constants/economic.constants.d.ts +2 -0
- package/dist/constants/economic.constants.js +2 -0
- package/dist/constants/feature-flags.constants.d.ts +10 -0
- package/dist/constants/feature-flags.constants.js +52 -4
- package/dist/constants/feature-limits.constants.d.ts +72 -4
- package/dist/constants/feature-limits.constants.js +98 -20
- package/dist/constants/interval.constants.js +5 -0
- package/dist/constants/kscript-data-interval-restrictions.constants.d.ts +12 -0
- package/dist/constants/kscript-data-interval-restrictions.constants.js +14 -0
- package/dist/constants/typed-width-fold.leaf.d.ts +50 -0
- package/dist/constants/typed-width-fold.leaf.js +99 -0
- package/dist/constants/typed-width-source.leaf.d.ts +24 -0
- package/dist/constants/typed-width-source.leaf.js +126 -0
- package/dist/constants/typed-width.leaf.d.ts +57 -0
- package/dist/constants/typed-width.leaf.js +78 -0
- package/dist/host-env.d.ts +10 -0
- package/dist/host-env.js +7 -0
- package/dist/host-ports.types.d.ts +11 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/interfaces/kscript-diagnostics.interface.d.ts +28 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +63 -3
- package/dist/interfaces/wrun-runtime.interface.js +11 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +13 -0
- package/dist/kscript-data/controls/live-trades-merge.util.js +16 -1
- package/dist/market-data/billing.interface.d.ts +12 -45
- package/dist/market-data/billing.interface.js +2 -2
- package/dist/replay/replayLadder.js +7 -4
- package/dist/settings-templates/footprint-rows.d.ts +6 -0
- package/dist/settings-templates/footprint-rows.js +6 -0
- package/dist/settings-templates/frvp-fields.js +14 -0
- package/dist/settings-templates/indicator-fields.js +31 -0
- package/dist/settings-templates/tool-tables.generated.js +19 -1
- package/dist/utility/chart/__fixtures__/live-bucket-regular-golden.json +1706 -0
- package/dist/utility/chart/cache-alignment.util.d.ts +42 -0
- package/dist/utility/chart/cache-alignment.util.js +88 -18
- package/dist/utility/chart/calendar-interval.util.d.ts +83 -1
- package/dist/utility/chart/calendar-interval.util.js +152 -4
- package/dist/utility/chart/candle-bar-end.util.d.ts +11 -4
- package/dist/utility/chart/candle-bar-end.util.js +17 -6
- package/dist/utility/chart/chart-time-domain.util.d.ts +3 -0
- package/dist/utility/chart/chart-time-domain.util.js +13 -4
- package/dist/utility/chart/feed-interval.util.d.ts +4 -2
- package/dist/utility/chart/feed-interval.util.js +5 -2
- package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +3 -1
- package/dist/utility/chart/fetch-dedupe-policy.util.js +19 -1
- package/dist/utility/chart/footprint-display-mode.util.d.ts +2 -0
- package/dist/utility/chart/footprint-display-mode.util.js +5 -0
- package/dist/utility/chart/governed-lanes-gate.util.d.ts +46 -0
- package/dist/utility/chart/governed-lanes-gate.util.js +71 -0
- package/dist/utility/chart/governed-lanes-reader-seat.d.ts +14 -0
- package/dist/utility/chart/governed-lanes-reader-seat.js +14 -0
- package/dist/utility/chart/history-wall.util.d.ts +13 -2
- package/dist/utility/chart/history-wall.util.js +11 -4
- package/dist/utility/chart/interval-ladder.util.d.ts +5 -2
- package/dist/utility/chart/interval-ladder.util.js +44 -4
- package/dist/utility/chart/interval-registry.util.d.ts +22 -1
- package/dist/utility/chart/interval-registry.util.js +50 -2
- package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +32 -4
- package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +22 -5
- package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +10 -0
- package/dist/utility/chart/kscript-drawing-safe-area.util.js +30 -3
- package/dist/utility/chart/kscript-legend-entries.util.d.ts +21 -4
- package/dist/utility/chart/kscript-legend-entries.util.js +27 -5
- package/dist/utility/chart/kscript-main-grid-stages.util.js +74 -24
- package/dist/utility/chart/kscript-row-name.leaf.d.ts +13 -0
- package/dist/utility/chart/kscript-row-name.leaf.js +18 -0
- package/dist/utility/chart/kscript-venue-policy.util.d.ts +61 -26
- package/dist/utility/chart/kscript-venue-policy.util.js +138 -37
- package/dist/utility/chart/live-bucket.util.d.ts +29 -4
- package/dist/utility/chart/live-bucket.util.js +45 -12
- package/dist/utility/chart/market-session.util.d.ts +62 -10
- package/dist/utility/chart/market-session.util.js +93 -13
- package/dist/utility/chart/marketKind.util.d.ts +1 -7
- package/dist/utility/chart/marketKind.util.js +6 -8
- package/dist/utility/chart/mixed-mode.util.d.ts +17 -0
- package/dist/utility/chart/om-target.util.js +6 -4
- package/dist/utility/chart/price-precision.util.d.ts +20 -6
- package/dist/utility/chart/price-precision.util.js +34 -7
- package/dist/utility/chart/profile-frame-window.util.d.ts +15 -0
- package/dist/utility/chart/profile-frame-window.util.js +12 -0
- package/dist/utility/chart/rth-session.util.d.ts +3 -1
- package/dist/utility/chart/rth-session.util.js +3 -1
- package/dist/utility/chart/script-source-session.util.d.ts +43 -0
- package/dist/utility/chart/script-source-session.util.js +61 -0
- package/dist/utility/chart/typed-width-grid.util.d.ts +23 -0
- package/dist/utility/chart/typed-width-grid.util.js +203 -0
- package/dist/utility/common/transformations.util.d.ts +6 -0
- package/dist/utility/common/transformations.util.js +28 -4
- package/dist/utility/number-format.util.d.ts +14 -1
- package/dist/utility/number-format.util.js +22 -4
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +24 -1
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +113 -0
- package/dist/utility/v2/v2-enums.leaf.js +3 -0
- package/dist/utility/wrun/wrun-batched-marks.util.d.ts +9 -3
- package/dist/utility/wrun/wrun-batched-marks.util.js +65 -17
- package/dist/utility/wrun/wrun-canvases.util.d.ts +4 -2
- package/dist/utility/wrun/wrun-canvases.util.js +7 -12
- package/dist/utility/wrun/wrun-cap-notice.util.d.ts +5 -0
- package/dist/utility/wrun/wrun-cap-notice.util.js +23 -0
- package/dist/utility/wrun/wrun-card-style.util.d.ts +1 -1
- package/dist/utility/wrun/wrun-card-style.util.js +2 -2
- package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +8 -0
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +13 -1
- package/dist/utility/wrun/wrun-child-overlay-id.util.d.ts +10 -0
- package/dist/utility/wrun/wrun-child-overlay-id.util.js +24 -0
- package/dist/utility/wrun/wrun-cloud-cme-stamp.util.d.ts +72 -0
- package/dist/utility/wrun/wrun-cloud-cme-stamp.util.js +151 -0
- package/dist/utility/wrun/wrun-color-facts.util.d.ts +3 -3
- package/dist/utility/wrun/wrun-color-facts.util.js +8 -5
- package/dist/utility/wrun/wrun-colour-tone.lazy.d.ts +20 -0
- package/dist/utility/wrun/wrun-colour-tone.lazy.js +23 -0
- package/dist/utility/wrun/wrun-colour-tone.util.d.ts +14 -0
- package/dist/utility/wrun/wrun-colour-tone.util.js +119 -0
- package/dist/utility/wrun/wrun-dark-pool.util.d.ts +3 -2
- package/dist/utility/wrun/wrun-dark-pool.util.js +5 -4
- package/dist/utility/wrun/wrun-frames.d.ts +1 -1
- package/dist/utility/wrun/wrun-frames.js +2 -2
- package/dist/utility/wrun/wrun-handles.util.d.ts +1 -1
- package/dist/utility/wrun/wrun-handles.util.js +1 -1
- package/dist/utility/wrun/wrun-host.service.d.ts +32 -2
- package/dist/utility/wrun/wrun-host.service.js +44 -2
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +20 -0
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +85 -2
- package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +37 -0
- package/dist/utility/wrun/wrun-hosted-wire.util.js +54 -0
- package/dist/utility/wrun/wrun-hud-looks.util.d.ts +1 -0
- package/dist/utility/wrun/wrun-hud-looks.util.js +6 -11
- package/dist/utility/wrun/wrun-integration-route.util.d.ts +24 -0
- package/dist/utility/wrun/wrun-integration-route.util.js +19 -0
- package/dist/utility/wrun/wrun-live-intake.util.js +17 -1
- package/dist/utility/wrun/wrun-live-patch.util.d.ts +6 -1
- package/dist/utility/wrun/wrun-live-patch.util.js +10 -4
- package/dist/utility/wrun/wrun-live-tick.util.js +59 -4
- package/dist/utility/wrun/wrun-overlay-drivers.util.js +3 -0
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +15 -0
- package/dist/utility/wrun/wrun-overlay-run.util.js +274 -47
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +1 -1
- package/dist/utility/wrun/wrun-panel-mount.util.js +42 -13
- package/dist/utility/wrun/wrun-pin-venues.util.js +5 -1
- package/dist/utility/wrun/wrun-refusal.util.d.ts +4 -0
- package/dist/utility/wrun/wrun-refusal.util.js +102 -13
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +5 -3
- package/dist/utility/wrun/wrun-registry-errors.util.js +5 -3
- package/dist/utility/wrun/wrun-row-source-factory.js +17 -1
- package/dist/utility/wrun/wrun-row-source.d.ts +8 -1
- package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +1 -1
- package/dist/utility/wrun/wrun-sandbox-row-source.js +9 -0
- package/dist/utility/wrun/wrun-setting-words.util.d.ts +12 -5
- package/dist/utility/wrun/wrun-setting-words.util.js +25 -8
- package/dist/utility/wrun/wrun-socket-row-source.d.ts +26 -1
- package/dist/utility/wrun/wrun-socket-row-source.js +125 -12
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +3 -3
- package/dist/utility/wrun/wrun-source-rows.util.js +8 -7
- package/dist/utility/wrun/wrun-style-words.util.d.ts +31 -9
- package/dist/utility/wrun/wrun-style-words.util.js +46 -15
- package/dist/utility/wrun/wrun-trades-lane.util.js +2 -1
- package/dist/utility/wrun/wrun-trap-replay.util.d.ts +42 -0
- package/dist/utility/wrun/wrun-trap-replay.util.js +63 -0
- package/dist/utility/wrun/wrun-volume-profile.util.js +6 -5
- package/dist/utility/wrun-display-name.util.d.ts +10 -0
- package/dist/utility/wrun-display-name.util.js +21 -0
- package/dist/utils/replay/replay-buffer-math.d.ts +2 -0
- package/dist/utils/replay/replay-buffer-math.js +2 -0
- package/dist/workers/constants/socket-slots.d.ts +1 -1
- package/dist/workers/utils/time.worker.util.js +2 -2
- package/dist/workers/utils/volume-profile.worker.util.d.ts +9 -0
- package/dist/workers/utils/volume-profile.worker.util.js +20 -0
- package/dist/workers/wrun/wrun-abi-host.d.ts +3 -0
- package/dist/workers/wrun/wrun-abi-host.js +82 -5
- package/dist/workers/wrun/wrun-engine-handler.js +53 -4
- package/dist/workers/wrun/wrun-trap-frames.leaf.d.ts +28 -0
- package/dist/workers/wrun/wrun-trap-frames.leaf.js +108 -0
- package/package.json +11 -11
|
@@ -5,7 +5,7 @@ export declare const FEED_BAR_INTERVALS_S: readonly [60, 300, 900, 1800, 3600, 1
|
|
|
5
5
|
export declare const FEED_POLL_FLOOR_S = 10;
|
|
6
6
|
/** Bars of history a first read reaches back when the chart's candles have not landed yet. */
|
|
7
7
|
export declare const FEED_DEFAULT_LOOKBACK_BARS = 1000;
|
|
8
|
-
export type FeedPlot = 'line' | 'candles';
|
|
8
|
+
export type FeedPlot = 'line' | 'bars' | 'candles';
|
|
9
9
|
export type FeedRequest = {
|
|
10
10
|
kind: 'rows';
|
|
11
11
|
} | {
|
|
@@ -22,6 +22,8 @@ export declare function feedPollPeriodMs(cadenceS: number): number;
|
|
|
22
22
|
/**
|
|
23
23
|
* The UTC bucket a timestamp falls in, seconds: the relay's regroup, `floor(ts / interval_s)`,
|
|
24
24
|
* except that weeks start Monday 00:00 UTC as the relay's (and the chart's weekly candles) do.
|
|
25
|
+
* The relay owns this grid: `interval_s` is always one of `FEED_BAR_INTERVALS_S` (1w at most),
|
|
26
|
+
* so a typed day or week chart regroups on the relay's 1d or 1w and never on its own grid.
|
|
25
27
|
*/
|
|
26
28
|
export declare function feedBucketStartSec(tsSec: number, intervalS: number): number;
|
|
27
29
|
/** An exact-interval feed on a chart of another interval: it draws nothing there. */
|
|
@@ -36,7 +38,7 @@ export declare function chooseFeedPlan(cadenceS: number, chartIntervalMs: number
|
|
|
36
38
|
export declare function feedCadenceHintApplies(cadenceS: number, chartIntervalMs: number, exactInterval?: boolean | null): boolean;
|
|
37
39
|
/** A span of seconds as a chart interval label: `1m`, `15m`, `1h`, `4h`, `1d`, `1w`; whole seconds otherwise. */
|
|
38
40
|
export declare function feedIntervalLabel(seconds: number): string;
|
|
39
|
-
/** The chart interval a cadence switches to (a
|
|
41
|
+
/** The chart interval a cadence switches to (a fixed rung with its wire interval: never a typed width), or null. */
|
|
40
42
|
export declare function feedChartIntervalFor(cadenceS: number): string | null;
|
|
41
43
|
/** The chart's own interval as a label (`1m`, `4h`, `1d`), from its milliseconds. */
|
|
42
44
|
export declare function feedChartIntervalLabel(chartIntervalMs: number): string;
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
* reading folds into a bar only for a value combining by `last`.
|
|
34
34
|
*/
|
|
35
35
|
import { Intervals } from '../../constants/interval.constants.js';
|
|
36
|
+
import { lookupGrpcInterval } from './interval-registry.util.js';
|
|
36
37
|
/** C2: the intervals the relay regroups bars on, ascending. */
|
|
37
38
|
export const FEED_BAR_INTERVALS_S = [60, 300, 900, 1_800, 3_600, 14_400, 86_400, 604_800];
|
|
38
39
|
/** C4 poll: never more often than this. */
|
|
@@ -76,6 +77,8 @@ const FIRST_MONDAY_S = 4 * 86_400;
|
|
|
76
77
|
/**
|
|
77
78
|
* The UTC bucket a timestamp falls in, seconds: the relay's regroup, `floor(ts / interval_s)`,
|
|
78
79
|
* except that weeks start Monday 00:00 UTC as the relay's (and the chart's weekly candles) do.
|
|
80
|
+
* The relay owns this grid: `interval_s` is always one of `FEED_BAR_INTERVALS_S` (1w at most),
|
|
81
|
+
* so a typed day or week chart regroups on the relay's 1d or 1w and never on its own grid.
|
|
79
82
|
*/
|
|
80
83
|
export function feedBucketStartSec(tsSec, intervalS) {
|
|
81
84
|
if (intervalS > 0 && intervalS % WEEK_S === 0) {
|
|
@@ -113,13 +116,13 @@ export function feedIntervalLabel(seconds) {
|
|
|
113
116
|
return `${span / 60}m`;
|
|
114
117
|
return `${span}s`;
|
|
115
118
|
}
|
|
116
|
-
/** The chart interval a cadence switches to (a
|
|
119
|
+
/** The chart interval a cadence switches to (a fixed rung with its wire interval: never a typed width), or null. */
|
|
117
120
|
export function feedChartIntervalFor(cadenceS) {
|
|
118
121
|
if (!(cadenceS > 0))
|
|
119
122
|
return null;
|
|
120
123
|
const label = feedIntervalLabel(cadenceS);
|
|
121
124
|
const units = Intervals.map_unit;
|
|
122
|
-
return units[label] === cadenceS * 1_000 ? label : null;
|
|
125
|
+
return units[label] === cadenceS * 1_000 && lookupGrpcInterval(label) !== undefined ? label : null;
|
|
123
126
|
}
|
|
124
127
|
/** The chart's own interval as a label (`1m`, `4h`, `1d`), from its milliseconds. */
|
|
125
128
|
export function feedChartIntervalLabel(chartIntervalMs) {
|
|
@@ -101,10 +101,12 @@ export interface FetchDedupeIntent {
|
|
|
101
101
|
isTapeSvpSeed?: boolean;
|
|
102
102
|
/** The Footprint panel's own lane (footprint-panel-lane.service.ts): snapshot windows into the panel's store. */
|
|
103
103
|
isFootprintPanel?: boolean;
|
|
104
|
+
/** The footprint pieces lane (footprint-row-pieces-lane.service.ts): piece reads into the engine's side table. */
|
|
105
|
+
isFootprintRowPieces?: boolean;
|
|
104
106
|
/** A split-family child whose span IS the parent's registered pre-split span (the owner span). */
|
|
105
107
|
isSplitFamilyOwnerChild?: boolean;
|
|
106
108
|
}
|
|
107
|
-
export type FetchDedupePolicyName = 'MAIN_COALESCE' | 'MAIN_POLL_BYPASS' | 'MAIN_HISTORICAL_BYPASS' | 'MAIN_RETRY_BYPASS' | 'IND_SKIP_DUPLICATE' | 'IND_REPAIR_REFRESH' | 'IND_LAZY_PAGE' | 'IND_POLL_BYPASS' | 'HEATMAP_CACHE_ONLY_BYPASS' | 'IND_RETRY_BYPASS' | 'IND_SPLIT_FAMILY_OWNER_CHILD' | 'IND_REPLAY_LANE_BYPASS' | 'IND_SEAM_TOPUP' | 'KSCRIPT_SOURCE_DEDUPE' | 'DOM_REPLAY_WINDOW' | 'TAPE_SVP_SEED' | 'FOOTPRINT_PANEL';
|
|
109
|
+
export type FetchDedupePolicyName = 'MAIN_COALESCE' | 'MAIN_POLL_BYPASS' | 'MAIN_HISTORICAL_BYPASS' | 'MAIN_RETRY_BYPASS' | 'IND_SKIP_DUPLICATE' | 'IND_REPAIR_REFRESH' | 'IND_LAZY_PAGE' | 'IND_POLL_BYPASS' | 'HEATMAP_CACHE_ONLY_BYPASS' | 'IND_RETRY_BYPASS' | 'IND_SPLIT_FAMILY_OWNER_CHILD' | 'IND_REPLAY_LANE_BYPASS' | 'IND_SEAM_TOPUP' | 'KSCRIPT_SOURCE_DEDUPE' | 'DOM_REPLAY_WINDOW' | 'TAPE_SVP_SEED' | 'FOOTPRINT_PANEL' | 'FOOTPRINT_ROW_PIECES';
|
|
108
110
|
export interface FetchDedupePolicy {
|
|
109
111
|
name: FetchDedupePolicyName;
|
|
110
112
|
onPendingTwin: 'await' | 'skip' | 'ignore';
|
|
@@ -317,6 +317,21 @@ const POLICIES = {
|
|
|
317
317
|
'laundered completion never records an empty; the known-empty and doomed-range guard classes never gate it ' +
|
|
318
318
|
'because the lane owns emptiness itself.',
|
|
319
319
|
},
|
|
320
|
+
FOOTPRINT_ROW_PIECES: {
|
|
321
|
+
name: 'FOOTPRINT_ROW_PIECES',
|
|
322
|
+
onPendingTwin: 'ignore',
|
|
323
|
+
onRecentCompletion: 'ignore',
|
|
324
|
+
registersPending: false,
|
|
325
|
+
onDeliveredAnswer: 'send',
|
|
326
|
+
why: 'Footprint pieces lane fetches (footprint-row-pieces-lane.service.ts, FOOTPRINT-ROW-SPLIT) run only the ' +
|
|
327
|
+
'"Split rows by" piece reads (a finer interval, or one read per listing) under a fresh synthetic ovId per ' +
|
|
328
|
+
"request and deliver side table entries into the engine's pieces table, never an overlay's rows, so like the " +
|
|
329
|
+
'footprint panel lane they neither consult nor write the production ledger. Duplicate control is the lane: ' +
|
|
330
|
+
'one read at a time per overlay, a queue of merged candle ranges (tail, visible, rest), a 20 s tail tick, and ' +
|
|
331
|
+
'a generation that drops every answer for a superseded split, market, row setting or mount; idle with no ' +
|
|
332
|
+
'split. Every request reads its transport outcome, so a laundered completion never commits an empty, and the ' +
|
|
333
|
+
'known-empty and doomed-range guard classes never gate it because the lane owns its served range itself.',
|
|
334
|
+
},
|
|
320
335
|
};
|
|
321
336
|
/** Branch precedence mirrors the historical guard-site code order exactly. */
|
|
322
337
|
export function resolveFetchDedupePolicy(intent) {
|
|
@@ -340,6 +355,8 @@ export function resolveFetchDedupePolicy(intent) {
|
|
|
340
355
|
return POLICIES.TAPE_SVP_SEED;
|
|
341
356
|
if (intent.isFootprintPanel)
|
|
342
357
|
return POLICIES.FOOTPRINT_PANEL;
|
|
358
|
+
if (intent.isFootprintRowPieces)
|
|
359
|
+
return POLICIES.FOOTPRINT_ROW_PIECES;
|
|
343
360
|
if (intent.isPolling)
|
|
344
361
|
return POLICIES.IND_POLL_BYPASS;
|
|
345
362
|
if (intent.heatmapCacheOnly)
|
|
@@ -439,7 +456,7 @@ export function isEngineQueueHoldEnabled(readExplicitlyOff) {
|
|
|
439
456
|
* to: a hedge or blank-boot retry exists to escape a possibly wedged twin
|
|
440
457
|
* (MAIN_RETRY_BYPASS, IND_RETRY_BYPASS), a historical-mode fetch replaces
|
|
441
458
|
* the dataset under explicit identity stamps, and the replay, DOM-replay,
|
|
442
|
-
* tape-seed, footprint-panel and cache-only lanes deliver through collectors
|
|
459
|
+
* tape-seed, footprint-panel, footprint-pieces and cache-only lanes deliver through collectors
|
|
443
460
|
* that never paint the chart. Everything else (coalesce, polls, repair, split
|
|
444
461
|
* children, the seam top-up, engine sources) may share one wire request
|
|
445
462
|
* across panes.
|
|
@@ -453,6 +470,7 @@ const UNSHAREABLE_FETCH_DEDUPE_POLICIES = new Set([
|
|
|
453
470
|
'DOM_REPLAY_WINDOW',
|
|
454
471
|
'TAPE_SVP_SEED',
|
|
455
472
|
'FOOTPRINT_PANEL',
|
|
473
|
+
'FOOTPRINT_ROW_PIECES',
|
|
456
474
|
]);
|
|
457
475
|
export function isShareableFetchDedupePolicy(policy) {
|
|
458
476
|
const name = typeof policy === 'string' ? policy : policy.name;
|
|
@@ -24,6 +24,7 @@ type DisplayModeModel = {
|
|
|
24
24
|
barWidth?: unknown;
|
|
25
25
|
stickToLeft?: unknown;
|
|
26
26
|
clusterCellMetric?: unknown;
|
|
27
|
+
rowSplit?: unknown;
|
|
27
28
|
};
|
|
28
29
|
/**
|
|
29
30
|
* The display mode a form shows for a model, as the Volume Footprint dialog reads it: a cell-grid mode as it is, and the
|
|
@@ -35,6 +36,7 @@ export declare function footprintDisplayModeShown(model: DisplayModeModel): stri
|
|
|
35
36
|
* The model on `displayMode`, as both footprint dialogs write a display mode pick: the legacy delta flag only for the
|
|
36
37
|
* stacked delta mode, the bar width of the mode's family, the cells anchored left, and on a cell grid the cluster cell
|
|
37
38
|
* metric's default (the columns layout is one of titan's cluster-grid family: its bid x ask column reads the metric).
|
|
39
|
+
* A mode other than Total sets a saved Split rows by (`rowSplit`) back to none, as web's dialogs do.
|
|
38
40
|
*/
|
|
39
41
|
export declare function withFootprintDisplayMode<T extends DisplayModeModel>(model: T, displayMode: string): T;
|
|
40
42
|
export {};
|
|
@@ -45,6 +45,7 @@ export function footprintDisplayModeShown(model) {
|
|
|
45
45
|
* The model on `displayMode`, as both footprint dialogs write a display mode pick: the legacy delta flag only for the
|
|
46
46
|
* stacked delta mode, the bar width of the mode's family, the cells anchored left, and on a cell grid the cluster cell
|
|
47
47
|
* metric's default (the columns layout is one of titan's cluster-grid family: its bid x ask column reads the metric).
|
|
48
|
+
* A mode other than Total sets a saved Split rows by (`rowSplit`) back to none, as web's dialogs do.
|
|
48
49
|
*/
|
|
49
50
|
export function withFootprintDisplayMode(model, displayMode) {
|
|
50
51
|
const cellGrid = isClusterGridProfileDisplayMode(displayMode) || displayMode === FOOTPRINT_COLUMNS_DISPLAY_MODE;
|
|
@@ -58,5 +59,9 @@ export function withFootprintDisplayMode(model, displayMode) {
|
|
|
58
59
|
};
|
|
59
60
|
if (cellGrid && !next.clusterCellMetric)
|
|
60
61
|
next.clusterCellMetric = 'delta';
|
|
62
|
+
// Split rows by draws under Total alone: any other mode sets a saved split back to none, so a workspace shared with
|
|
63
|
+
// web never holds a split under another mode. The row itself is web-only for now (footprint-rows.ts).
|
|
64
|
+
if (displayMode !== 'stacked-bar' && model.rowSplit !== undefined)
|
|
65
|
+
next.rowSplit = 'none';
|
|
61
66
|
return next;
|
|
62
67
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The governed-lanes cutover switch as the venue policy reads it (kscript-venue-policy.util, the one decider of the
|
|
3
|
+
* governed walls). One runtime flag per licensed plane (`cme-lanes`, `opra-lanes`, `stocks-lanes`); while a plane's
|
|
4
|
+
* flag is lit, that plane opens to the server lanes too: the hosted (Cloud) runs, the protected scripts, strategy
|
|
5
|
+
* testing and every alert kind. While it is dark (the default), the plane reads exactly as it did before the cutover.
|
|
6
|
+
*
|
|
7
|
+
* Store-free on purpose, the shape of the `cme-user-scripts` gate leaf (cme-user-scripts-gate.util): the venue policy
|
|
8
|
+
* stays worker-safe, so the main thread hands it a reader instead. Its one import is the fallback reader's seat
|
|
9
|
+
* (governed-lanes-reader-seat, itself dependency-free), which the flags store fills with its override-aware `isOn`
|
|
10
|
+
* when it is evaluated, so the dev and internal `kiyo.flag-overrides` lens reaches the walls exactly as it reaches
|
|
11
|
+
* every surface reading `isOn`. A published reader (a spec's, or a host that hands one) answers over the seat's.
|
|
12
|
+
*
|
|
13
|
+
* Fail closed everywhere: no reader (a worker, a spec without a store), a reader that throws, a reader that answers
|
|
14
|
+
* anything but `true`, an unloaded or guest map (the store's `isOn` reads those false) and a plane this module does
|
|
15
|
+
* not name all read dark. The flags never open a lane on their own: each plane's own decision still holds (the CME
|
|
16
|
+
* plane keeps the `cme-user-scripts` gate: the flag, sign-in and the CME data terms).
|
|
17
|
+
*/
|
|
18
|
+
/** A licensed plane the cutover opens to the server lanes. */
|
|
19
|
+
export type GovernedLanePlane = 'cme' | 'opra' | 'stocks';
|
|
20
|
+
/** Every governed lane plane, in the order the planes shipped. */
|
|
21
|
+
export declare const GOVERNED_LANE_PLANES: readonly GovernedLanePlane[];
|
|
22
|
+
/** Reads one plane's lanes flag: `true` only when that plane's cutover flag is lit. */
|
|
23
|
+
export type GovernedLanesFlagReader = (plane: GovernedLanePlane) => boolean;
|
|
24
|
+
/** A reader that answers over the fallback seat's (a spec's, or a host that hands one); null unpublishes. */
|
|
25
|
+
export declare function publishGovernedLanesFlags(next: GovernedLanesFlagReader | null): void;
|
|
26
|
+
/** Fill or empty the fallback reader's seat (the flags store fills it itself, by the seat's own module). */
|
|
27
|
+
export declare function setGovernedLanesFlagsFallback(next: GovernedLanesFlagReader | null): void;
|
|
28
|
+
/** The token a server-lane CME run captures before it asks (frozen: a holder cannot move it forward). */
|
|
29
|
+
export declare function captureCmeLanesFence(): {
|
|
30
|
+
fence: number;
|
|
31
|
+
};
|
|
32
|
+
/** Move the fence on: every server-lane CME run captured before is no longer current. Returns the new fence. */
|
|
33
|
+
export declare function bumpCmeLanesFence(): number;
|
|
34
|
+
/** The fence now (specs and the debug ring read it). */
|
|
35
|
+
export declare function cmeLanesFenceNow(): number;
|
|
36
|
+
/** Whether a captured fence token is current; a missing or malformed token is not. */
|
|
37
|
+
export declare function isCmeLanesFenceCurrent(token: {
|
|
38
|
+
fence: number;
|
|
39
|
+
} | null | undefined): boolean;
|
|
40
|
+
/** Whether a value names a governed lane plane. */
|
|
41
|
+
export declare function isGovernedLanePlane(plane: unknown): plane is GovernedLanePlane;
|
|
42
|
+
/**
|
|
43
|
+
* True only when the plane's cutover flag is lit. Fails closed: no reader published, flags not loaded, guest map, or
|
|
44
|
+
* an unknown plane all read false. Worker-safe.
|
|
45
|
+
*/
|
|
46
|
+
export declare function governedLanesOpen(plane: GovernedLanePlane): boolean;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The governed-lanes cutover switch as the venue policy reads it (kscript-venue-policy.util, the one decider of the
|
|
3
|
+
* governed walls). One runtime flag per licensed plane (`cme-lanes`, `opra-lanes`, `stocks-lanes`); while a plane's
|
|
4
|
+
* flag is lit, that plane opens to the server lanes too: the hosted (Cloud) runs, the protected scripts, strategy
|
|
5
|
+
* testing and every alert kind. While it is dark (the default), the plane reads exactly as it did before the cutover.
|
|
6
|
+
*
|
|
7
|
+
* Store-free on purpose, the shape of the `cme-user-scripts` gate leaf (cme-user-scripts-gate.util): the venue policy
|
|
8
|
+
* stays worker-safe, so the main thread hands it a reader instead. Its one import is the fallback reader's seat
|
|
9
|
+
* (governed-lanes-reader-seat, itself dependency-free), which the flags store fills with its override-aware `isOn`
|
|
10
|
+
* when it is evaluated, so the dev and internal `kiyo.flag-overrides` lens reaches the walls exactly as it reaches
|
|
11
|
+
* every surface reading `isOn`. A published reader (a spec's, or a host that hands one) answers over the seat's.
|
|
12
|
+
*
|
|
13
|
+
* Fail closed everywhere: no reader (a worker, a spec without a store), a reader that throws, a reader that answers
|
|
14
|
+
* anything but `true`, an unloaded or guest map (the store's `isOn` reads those false) and a plane this module does
|
|
15
|
+
* not name all read dark. The flags never open a lane on their own: each plane's own decision still holds (the CME
|
|
16
|
+
* plane keeps the `cme-user-scripts` gate: the flag, sign-in and the CME data terms).
|
|
17
|
+
*/
|
|
18
|
+
import { governedLanesFallbackSeat } from './governed-lanes-reader-seat.js';
|
|
19
|
+
/** Every governed lane plane, in the order the planes shipped. */
|
|
20
|
+
export const GOVERNED_LANE_PLANES = Object.freeze(['cme', 'opra', 'stocks']);
|
|
21
|
+
let published = null;
|
|
22
|
+
/** A reader that answers over the fallback seat's (a spec's, or a host that hands one); null unpublishes. */
|
|
23
|
+
export function publishGovernedLanesFlags(next) {
|
|
24
|
+
published = next;
|
|
25
|
+
}
|
|
26
|
+
/** Fill or empty the fallback reader's seat (the flags store fills it itself, by the seat's own module). */
|
|
27
|
+
export function setGovernedLanesFlagsFallback(next) {
|
|
28
|
+
governedLanesFallbackSeat.reader = next;
|
|
29
|
+
}
|
|
30
|
+
// ── The CME lanes fence (2026-11-11) ────────────────────────────────────────────────────────────────────────────────
|
|
31
|
+
//
|
|
32
|
+
// A server-lane user run reading CME (a Cloud record or a protected script on a CME chart, or whose effective sheet pins
|
|
33
|
+
// a CME market) captures this fence at its head; the `cme-lanes` flag going dark moves it (the CME user-study lifecycle,
|
|
34
|
+
// `bumpCmeLanesFence`). Apart from the CME authorisation epoch on purpose: a lanes move must drop an in-flight
|
|
35
|
+
// server-lane CME answer (even one no stamp shows yet) and never a browser run's, which the flag does not govern.
|
|
36
|
+
let cmeLanesFence = 0;
|
|
37
|
+
/** The token a server-lane CME run captures before it asks (frozen: a holder cannot move it forward). */
|
|
38
|
+
export function captureCmeLanesFence() {
|
|
39
|
+
return Object.freeze({ fence: cmeLanesFence });
|
|
40
|
+
}
|
|
41
|
+
/** Move the fence on: every server-lane CME run captured before is no longer current. Returns the new fence. */
|
|
42
|
+
export function bumpCmeLanesFence() {
|
|
43
|
+
cmeLanesFence += 1;
|
|
44
|
+
return cmeLanesFence;
|
|
45
|
+
}
|
|
46
|
+
/** The fence now (specs and the debug ring read it). */
|
|
47
|
+
export function cmeLanesFenceNow() {
|
|
48
|
+
return cmeLanesFence;
|
|
49
|
+
}
|
|
50
|
+
/** Whether a captured fence token is current; a missing or malformed token is not. */
|
|
51
|
+
export function isCmeLanesFenceCurrent(token) {
|
|
52
|
+
return typeof token?.fence === 'number' && token.fence === cmeLanesFence;
|
|
53
|
+
}
|
|
54
|
+
/** Whether a value names a governed lane plane. */
|
|
55
|
+
export function isGovernedLanePlane(plane) {
|
|
56
|
+
return plane === 'cme' || plane === 'opra' || plane === 'stocks';
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* True only when the plane's cutover flag is lit. Fails closed: no reader published, flags not loaded, guest map, or
|
|
60
|
+
* an unknown plane all read false. Worker-safe.
|
|
61
|
+
*/
|
|
62
|
+
export function governedLanesOpen(plane) {
|
|
63
|
+
if (!isGovernedLanePlane(plane))
|
|
64
|
+
return false;
|
|
65
|
+
try {
|
|
66
|
+
return (published ?? governedLanesFallbackSeat.reader)?.(plane) === true;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The seat of the governed-lanes fallback reader: governed-lanes-gate.util reads it and the flags store fills it. It
|
|
3
|
+
* is alone in its own module because the store ships in the boot entry, which has no bytes to spare
|
|
4
|
+
* (entry-size-guard): the store imports this seat, never the gate.
|
|
5
|
+
*
|
|
6
|
+
* The store fills it when it is evaluated, never later. A surface that read the gate before a reader sat here would
|
|
7
|
+
* have tracked nothing reactive, and would never see a lanes flag land.
|
|
8
|
+
*
|
|
9
|
+
* Dependency-free (zero imports), so the gate stays worker-safe: in a worker nothing fills the seat and every lane
|
|
10
|
+
* reads dark.
|
|
11
|
+
*/
|
|
12
|
+
export declare const governedLanesFallbackSeat: {
|
|
13
|
+
reader: ((plane: 'cme' | 'opra' | 'stocks') => boolean) | null;
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The seat of the governed-lanes fallback reader: governed-lanes-gate.util reads it and the flags store fills it. It
|
|
3
|
+
* is alone in its own module because the store ships in the boot entry, which has no bytes to spare
|
|
4
|
+
* (entry-size-guard): the store imports this seat, never the gate.
|
|
5
|
+
*
|
|
6
|
+
* The store fills it when it is evaluated, never later. A surface that read the gate before a reader sat here would
|
|
7
|
+
* have tracked nothing reactive, and would never see a lanes flag land.
|
|
8
|
+
*
|
|
9
|
+
* Dependency-free (zero imports), so the gate stays worker-safe: in a worker nothing fills the seat and every lane
|
|
10
|
+
* reads dark.
|
|
11
|
+
*/
|
|
12
|
+
export const governedLanesFallbackSeat = {
|
|
13
|
+
reader: null,
|
|
14
|
+
};
|
|
@@ -33,9 +33,15 @@ export type HistoryWallKind = 'plan-wall' | 'data-start';
|
|
|
33
33
|
* maps it with `grpcIntervalOf(interval)`
|
|
34
34
|
* (workers/indicators/controls/ohlcv.worker.ts): the twelve native labels and
|
|
35
35
|
* the custom ones go out as themselves ('3M' as QUARTER, '3m' as
|
|
36
|
-
* THREE_MINUTES),
|
|
36
|
+
* THREE_MINUTES), a typed width (4m to 3h, 2d to 20w) goes out as CUSTOM with
|
|
37
|
+
* its own bar length, which the gateway counts the wall in (its own bars), so
|
|
38
|
+
* it answers as itself; any other label ('5s' to '30s', '1mm') falls back to
|
|
37
39
|
* AggregationInterval.MINUTE. The gateway measures the wall in that interval,
|
|
38
40
|
* so the chart label would put the wall far too deep.
|
|
41
|
+
*
|
|
42
|
+
* A custom size the app builds asks its SOURCE instead (18m from 3m), which this store-free package cannot know: a
|
|
43
|
+
* web caller with a chart passes the app's `gatewayWallInterval(interval, chart)` (retention-validation.util) here,
|
|
44
|
+
* never the chart's label (tests/structure/history-wall-readers.spec.ts).
|
|
39
45
|
*/
|
|
40
46
|
export declare function gatewayRequestIntervalFor(chartInterval: string): string;
|
|
41
47
|
/** How far back the tier's gateway window reaches at this chart interval, in ms. */
|
|
@@ -52,9 +58,14 @@ export interface HistoryWallInput {
|
|
|
52
58
|
sessionBound: boolean;
|
|
53
59
|
/** The wire omits tradeless buckets (mayServeLegitimatelySparseHistory): the first trade can land after the wall. */
|
|
54
60
|
sparseHistory: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* A custom size the app builds from the interval asked: its bar length. The fold keeps whole bars only, so the
|
|
63
|
+
* oldest one opens up to one such bar past the wall. Absent for every chart the gateway answers at its own label.
|
|
64
|
+
*/
|
|
65
|
+
foldedBarMs?: number;
|
|
55
66
|
}
|
|
56
67
|
/** `plan-wall` iff the edge sits at (or behind) the viewer's tier wall, within slack. */
|
|
57
|
-
export declare function classifyHistoryWall({ edgeMs, requestIntervalMs, tierMaxBars, nowMs, sessionBound, sparseHistory, }: HistoryWallInput): HistoryWallKind;
|
|
68
|
+
export declare function classifyHistoryWall({ edgeMs, requestIntervalMs, tierMaxBars, nowMs, sessionBound, sparseHistory, foldedBarMs, }: HistoryWallInput): HistoryWallKind;
|
|
58
69
|
export type HistoryReachUnit = 'hours' | 'days' | 'months' | 'years';
|
|
59
70
|
/**
|
|
60
71
|
* A reach in the words the plan copy uses: hours under a day, days under 60
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import { Intervals } from '../../constants/interval.constants.js';
|
|
23
23
|
import { lookupGrpcInterval } from './interval-registry.util.js';
|
|
24
|
+
import { isTypedWidth } from '../../constants/typed-width.leaf.js';
|
|
24
25
|
import { gatewayTierMaxBars } from '../../constants/feature-limits.constants.js';
|
|
25
26
|
const HOUR_MS = 3_600_000;
|
|
26
27
|
const DAY_MS = 86_400_000;
|
|
@@ -51,12 +52,18 @@ const GAP_SLACK_MAX_REACH_SHARE = 0.25;
|
|
|
51
52
|
* maps it with `grpcIntervalOf(interval)`
|
|
52
53
|
* (workers/indicators/controls/ohlcv.worker.ts): the twelve native labels and
|
|
53
54
|
* the custom ones go out as themselves ('3M' as QUARTER, '3m' as
|
|
54
|
-
* THREE_MINUTES),
|
|
55
|
+
* THREE_MINUTES), a typed width (4m to 3h, 2d to 20w) goes out as CUSTOM with
|
|
56
|
+
* its own bar length, which the gateway counts the wall in (its own bars), so
|
|
57
|
+
* it answers as itself; any other label ('5s' to '30s', '1mm') falls back to
|
|
55
58
|
* AggregationInterval.MINUTE. The gateway measures the wall in that interval,
|
|
56
59
|
* so the chart label would put the wall far too deep.
|
|
60
|
+
*
|
|
61
|
+
* A custom size the app builds asks its SOURCE instead (18m from 3m), which this store-free package cannot know: a
|
|
62
|
+
* web caller with a chart passes the app's `gatewayWallInterval(interval, chart)` (retention-validation.util) here,
|
|
63
|
+
* never the chart's label (tests/structure/history-wall-readers.spec.ts).
|
|
57
64
|
*/
|
|
58
65
|
export function gatewayRequestIntervalFor(chartInterval) {
|
|
59
|
-
return lookupGrpcInterval(chartInterval) !== undefined ? chartInterval : '1m';
|
|
66
|
+
return lookupGrpcInterval(chartInterval) !== undefined || isTypedWidth(chartInterval) ? chartInterval : '1m';
|
|
60
67
|
}
|
|
61
68
|
/** How far back the tier's gateway window reaches at this chart interval, in ms. */
|
|
62
69
|
export function historyReachMs(tier, chartInterval) {
|
|
@@ -64,10 +71,10 @@ export function historyReachMs(tier, chartInterval) {
|
|
|
64
71
|
return gatewayTierMaxBars(tier, requestInterval) * Intervals.map_unit[requestInterval];
|
|
65
72
|
}
|
|
66
73
|
/** `plan-wall` iff the edge sits at (or behind) the viewer's tier wall, within slack. */
|
|
67
|
-
export function classifyHistoryWall({ edgeMs, requestIntervalMs, tierMaxBars, nowMs, sessionBound, sparseHistory, }) {
|
|
74
|
+
export function classifyHistoryWall({ edgeMs, requestIntervalMs, tierMaxBars, nowMs, sessionBound, sparseHistory, foldedBarMs = 0, }) {
|
|
68
75
|
const reachMs = tierMaxBars * requestIntervalMs;
|
|
69
76
|
const gapSlackMs = Math.min((sessionBound ? SESSION_GAP_SLACK_MS : 0) + (sparseHistory ? NO_TRADE_GAP_SLACK_MS : 0), reachMs * GAP_SLACK_MAX_REACH_SHARE);
|
|
70
|
-
const slackMs = PLAN_WALL_SLACK_BARS * requestIntervalMs + PLAN_WALL_DRIFT_MS + gapSlackMs;
|
|
77
|
+
const slackMs = PLAN_WALL_SLACK_BARS * requestIntervalMs + foldedBarMs + PLAN_WALL_DRIFT_MS + gapSlackMs;
|
|
71
78
|
return edgeMs <= nowMs - reachMs + slackMs ? 'plan-wall' : 'data-start';
|
|
72
79
|
}
|
|
73
80
|
/**
|
|
@@ -8,8 +8,10 @@ declare const EXTENDED_INTERVAL_LABELS: readonly ["5s", "15s", "30s", "6M"];
|
|
|
8
8
|
export type ExtendedInterval = (typeof EXTENDED_INTERVAL_LABELS)[number];
|
|
9
9
|
export declare const EXTENDED_INTERVALS: readonly ExtendedInterval[];
|
|
10
10
|
export declare function isExtendedInterval(label: unknown): label is ExtendedInterval;
|
|
11
|
-
/** Every label the resolver knows, in the wire map's order: the classic ladder, the presets, the extended rungs
|
|
11
|
+
/** Every label the resolver knows, in the wire map's order: the classic ladder, the presets, the extended rungs, the
|
|
12
|
+
* typed widths (wire CUSTOM plus their length, typed-width.leaf). */
|
|
12
13
|
export declare const RESOLVED_INTERVAL_LABELS: readonly string[];
|
|
14
|
+
export declare const LENGTH_TABLE_INTERVAL_LABELS: readonly string[];
|
|
13
15
|
export declare function intervalLabelForMs(ms: unknown): string | undefined;
|
|
14
16
|
export declare function intervalMs(label: unknown): number | undefined;
|
|
15
17
|
/**
|
|
@@ -17,7 +19,8 @@ export declare function intervalMs(label: unknown): number | undefined;
|
|
|
17
19
|
* (profile rows, footprint bars, heatmap depth, restrictions...) list only
|
|
18
20
|
* the classic ladder, so a preset or an extended rung takes the largest
|
|
19
21
|
* classic label that is no longer than it (5s 15s 30s -> 1s, 3m -> 1m,
|
|
20
|
-
* 10m -> 5m, 45m -> 30m, 6h -> 4h, 12h -> 4h, 3d -> 1d, 6M -> 3M
|
|
22
|
+
* 10m -> 5m, 45m -> 30m, 6h -> 4h, 12h -> 4h, 3d -> 1d, 6M -> 3M, typed 20m -> 15m, 3h -> 1h, 2d to 6d -> 1d,
|
|
23
|
+
* 8d and up and every week size -> 1w). A classic
|
|
21
24
|
* or unknown label comes back unchanged. Never use this for a wire interval:
|
|
22
25
|
* a chart must not be served another interval's bars.
|
|
23
26
|
*/
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* `@orangecharts/wrun-chart-host` package (docs/features/kscript/wrun/wrun-chart-host.md).
|
|
7
7
|
*/
|
|
8
8
|
import { Intervals } from '../../constants/interval.constants.js';
|
|
9
|
+
import { isTypedWidth, TYPED_WIDTH_LABELS } from '../../constants/typed-width.leaf.js';
|
|
9
10
|
// The classic labels the wire map lists first, in its order (the reversed length map keeps the last label of a
|
|
10
11
|
// length, so the order is the resolver's).
|
|
11
12
|
const STANDARD_INTERVAL_LABELS = ['1m', '5m', '15m', '1h', '4h', '1d', '1w', '1s', '30m', '1M', '3M', '1Y'];
|
|
@@ -28,11 +29,46 @@ const EXTENDED_INTERVAL_SET = new Set(EXTENDED_INTERVALS);
|
|
|
28
29
|
export function isExtendedInterval(label) {
|
|
29
30
|
return typeof label === 'string' && EXTENDED_INTERVAL_SET.has(label);
|
|
30
31
|
}
|
|
31
|
-
/** Every label the resolver knows, in the wire map's order: the classic ladder, the presets, the extended rungs
|
|
32
|
+
/** Every label the resolver knows, in the wire map's order: the classic ladder, the presets, the extended rungs, the
|
|
33
|
+
* typed widths (wire CUSTOM plus their length, typed-width.leaf). */
|
|
32
34
|
export const RESOLVED_INTERVAL_LABELS = [
|
|
33
35
|
...STANDARD_INTERVAL_LABELS,
|
|
34
36
|
...CUSTOM_INTERVAL_LABELS,
|
|
35
37
|
...EXTENDED_INTERVAL_LABELS,
|
|
38
|
+
...TYPED_WIDTH_LABELS,
|
|
39
|
+
];
|
|
40
|
+
// The table's rungs written out, so a row added to Intervals.map_unit never joins a set-of-rungs reader's pick.
|
|
41
|
+
export const LENGTH_TABLE_INTERVAL_LABELS = [
|
|
42
|
+
'1s',
|
|
43
|
+
'5s',
|
|
44
|
+
'10s',
|
|
45
|
+
'15s',
|
|
46
|
+
'20s',
|
|
47
|
+
'30s',
|
|
48
|
+
'1m',
|
|
49
|
+
'2m',
|
|
50
|
+
'3m',
|
|
51
|
+
'4m',
|
|
52
|
+
'5m',
|
|
53
|
+
'10m',
|
|
54
|
+
'15m',
|
|
55
|
+
'30m',
|
|
56
|
+
'45m',
|
|
57
|
+
'1h',
|
|
58
|
+
'2h',
|
|
59
|
+
'3h',
|
|
60
|
+
'4h',
|
|
61
|
+
'6h',
|
|
62
|
+
'8h',
|
|
63
|
+
'12h',
|
|
64
|
+
'1d',
|
|
65
|
+
'3d',
|
|
66
|
+
'1w',
|
|
67
|
+
'1mm',
|
|
68
|
+
'1M',
|
|
69
|
+
'3M',
|
|
70
|
+
'6M',
|
|
71
|
+
'1Y',
|
|
36
72
|
];
|
|
37
73
|
const hasOwn = (record, key) => Object.prototype.hasOwnProperty.call(record, key);
|
|
38
74
|
// map_unit reversed over every label this resolver knows, so a label added
|
|
@@ -56,16 +92,17 @@ export function intervalMs(label) {
|
|
|
56
92
|
// The classic ladder, ascending: the labels the tuning tables were written for.
|
|
57
93
|
// The scan keeps the last (largest) match.
|
|
58
94
|
const TUNING_STANDARD_INTERVALS = Intervals.INTERVAL_ORDER;
|
|
59
|
-
/** A label with no tuning rows of its own: a preset
|
|
95
|
+
/** A label with no tuning rows of its own: a preset, an extended rung or a typed width. */
|
|
60
96
|
function readsTuningAtOrBelow(label) {
|
|
61
|
-
return isCustomInterval(label) || isExtendedInterval(label);
|
|
97
|
+
return isCustomInterval(label) || isExtendedInterval(label) || isTypedWidth(label);
|
|
62
98
|
}
|
|
63
99
|
/**
|
|
64
100
|
* The standard label whose per-interval settings a label uses. Tuning tables
|
|
65
101
|
* (profile rows, footprint bars, heatmap depth, restrictions...) list only
|
|
66
102
|
* the classic ladder, so a preset or an extended rung takes the largest
|
|
67
103
|
* classic label that is no longer than it (5s 15s 30s -> 1s, 3m -> 1m,
|
|
68
|
-
* 10m -> 5m, 45m -> 30m, 6h -> 4h, 12h -> 4h, 3d -> 1d, 6M -> 3M
|
|
104
|
+
* 10m -> 5m, 45m -> 30m, 6h -> 4h, 12h -> 4h, 3d -> 1d, 6M -> 3M, typed 20m -> 15m, 3h -> 1h, 2d to 6d -> 1d,
|
|
105
|
+
* 8d and up and every week size -> 1w). A classic
|
|
69
106
|
* or unknown label comes back unchanged. Never use this for a wire interval:
|
|
70
107
|
* a chart must not be served another interval's bars.
|
|
71
108
|
*/
|
|
@@ -77,6 +114,9 @@ export function standardIntervalAtOrBelow(label) {
|
|
|
77
114
|
return label;
|
|
78
115
|
let standard = label;
|
|
79
116
|
for (const candidate of TUNING_STANDARD_INTERVALS) {
|
|
117
|
+
// A typed day or week size never lands on a calendar rung (the ladder is ascending: 1M is the first one).
|
|
118
|
+
if (candidate === '1M' && isTypedWidth(label))
|
|
119
|
+
break;
|
|
80
120
|
const candidateMs = intervalMs(candidate);
|
|
81
121
|
if (candidateMs !== undefined && candidateMs <= ms)
|
|
82
122
|
standard = candidate;
|
|
@@ -16,8 +16,29 @@ export declare function lookupGrpcInterval(label: unknown): AggregationInterval
|
|
|
16
16
|
/**
|
|
17
17
|
* `lookupGrpcInterval` with MINUTE for a missing label: worker payloads that
|
|
18
18
|
* legitimately omit their tf keep the default they always had. An unknown
|
|
19
|
-
* label string warns once, so the fallback is visible.
|
|
19
|
+
* label string warns once, so the fallback is visible. A typed width reads
|
|
20
|
+
* CUSTOM, never MINUTE.
|
|
20
21
|
*/
|
|
21
22
|
export declare function grpcIntervalOf(label: unknown): AggregationInterval;
|
|
23
|
+
/**
|
|
24
|
+
* The wire interval a series read sends for a label: its fixed rung, or CUSTOM for a typed width (sent with
|
|
25
|
+
* `wireBarSecondsOf`), `undefined` for anything else. Only the series adapters and the transport read it: every other
|
|
26
|
+
* reader keeps `lookupGrpcInterval`, which knows no typed width, so links, books and parsers stay on the ladder.
|
|
27
|
+
*/
|
|
28
|
+
export declare function wireIntervalOf(label: unknown): number | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Whether a source may be asked at `label`: a fixed rung, or a typed width while typed widths are on (`typedWidthsOn`,
|
|
31
|
+
* read by the main-thread caller only for a typed width). A label with only a length (4m today, any typed width while off) is not: its caller
|
|
32
|
+
* keeps the chart's interval, the route it took before typed widths had rows.
|
|
33
|
+
*/
|
|
34
|
+
export declare function isSourceAskInterval(label: unknown, typedWidthsOn?: () => boolean): boolean;
|
|
35
|
+
/** The `barSeconds` a typed width's read carries beside CUSTOM, `undefined` for every other label. */
|
|
36
|
+
export declare function wireBarSecondsOf(label: unknown): number | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Where a label this build does not know lands, read by its own spelling: the longest fixed rung with a wire interval
|
|
39
|
+
* no longer than it (a typed width an older build offered: 144m gives 2h, 24m gives 15m). `undefined` for a known
|
|
40
|
+
* label and for one that spells no length, which stay as they are.
|
|
41
|
+
*/
|
|
42
|
+
export declare function rungAtOrBelowUnknownLabel(label: unknown): string | undefined;
|
|
22
43
|
/** True for the rungs shorter than a minute (1s 5s 15s 30s): one Plus gate, one venue rule, served where 1s is. */
|
|
23
44
|
export declare function isSubMinuteInterval(label: unknown): boolean;
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* (`grpcIntervalOf`), so a label missing here would paint 1m candles.
|
|
11
11
|
*/
|
|
12
12
|
import { AggregationInterval } from '../v2/v2-enums.leaf.js';
|
|
13
|
-
import {
|
|
13
|
+
import { CUSTOM_WIRE_INTERVAL, isTypedWidth, typedWidthSeconds } from '../../constants/typed-width.leaf.js';
|
|
14
|
+
import { intervalMs, LENGTH_TABLE_INTERVAL_LABELS, } from './interval-ladder.util.js';
|
|
14
15
|
// The label half (the labels, their lengths and the tuning ladder) is the pure leaf's (interval-ladder.util); its
|
|
15
16
|
// importers keep this path.
|
|
16
17
|
export { CUSTOM_INTERVALS, EXTENDED_INTERVALS, intervalLabelForMs, intervalMs, isCustomInterval, isExtendedInterval, standardIntervalAtOrBelow, standardIntervalMsAtOrBelow, } from './interval-ladder.util.js';
|
|
@@ -64,18 +65,65 @@ const warnedUnknownLabels = new Set();
|
|
|
64
65
|
/**
|
|
65
66
|
* `lookupGrpcInterval` with MINUTE for a missing label: worker payloads that
|
|
66
67
|
* legitimately omit their tf keep the default they always had. An unknown
|
|
67
|
-
* label string warns once, so the fallback is visible.
|
|
68
|
+
* label string warns once, so the fallback is visible. A typed width reads
|
|
69
|
+
* CUSTOM, never MINUTE.
|
|
68
70
|
*/
|
|
69
71
|
export function grpcIntervalOf(label) {
|
|
70
72
|
const interval = lookupGrpcInterval(label);
|
|
71
73
|
if (interval !== undefined)
|
|
72
74
|
return interval;
|
|
75
|
+
// A typed width is never asked as MINUTE: CUSTOM, which the transport refuses off trade candles (wireRefusalReason).
|
|
76
|
+
if (isTypedWidth(label))
|
|
77
|
+
return CUSTOM_WIRE_INTERVAL;
|
|
73
78
|
if (typeof label === 'string' && !warnedUnknownLabels.has(label)) {
|
|
74
79
|
warnedUnknownLabels.add(label);
|
|
75
80
|
console.warn(`[interval-registry] Unknown interval "${label}"; requesting 1m.`);
|
|
76
81
|
}
|
|
77
82
|
return AggregationInterval.MINUTE;
|
|
78
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* The wire interval a series read sends for a label: its fixed rung, or CUSTOM for a typed width (sent with
|
|
86
|
+
* `wireBarSecondsOf`), `undefined` for anything else. Only the series adapters and the transport read it: every other
|
|
87
|
+
* reader keeps `lookupGrpcInterval`, which knows no typed width, so links, books and parsers stay on the ladder.
|
|
88
|
+
*/
|
|
89
|
+
export function wireIntervalOf(label) {
|
|
90
|
+
return lookupGrpcInterval(label) ?? (isTypedWidth(label) ? CUSTOM_WIRE_INTERVAL : undefined);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Whether a source may be asked at `label`: a fixed rung, or a typed width while typed widths are on (`typedWidthsOn`,
|
|
94
|
+
* read by the main-thread caller only for a typed width). A label with only a length (4m today, any typed width while off) is not: its caller
|
|
95
|
+
* keeps the chart's interval, the route it took before typed widths had rows.
|
|
96
|
+
*/
|
|
97
|
+
export function isSourceAskInterval(label, typedWidthsOn = () => false) {
|
|
98
|
+
return lookupGrpcInterval(label) !== undefined || (isTypedWidth(label) && typedWidthsOn());
|
|
99
|
+
}
|
|
100
|
+
/** The `barSeconds` a typed width's read carries beside CUSTOM, `undefined` for every other label. */
|
|
101
|
+
export function wireBarSecondsOf(label) {
|
|
102
|
+
return typedWidthSeconds(label);
|
|
103
|
+
}
|
|
104
|
+
const LABEL_UNIT_MS = { s: 1e3, m: 6e4, h: 36e5, d: 864e5, w: 6048e5 };
|
|
105
|
+
/**
|
|
106
|
+
* Where a label this build does not know lands, read by its own spelling: the longest fixed rung with a wire interval
|
|
107
|
+
* no longer than it (a typed width an older build offered: 144m gives 2h, 24m gives 15m). `undefined` for a known
|
|
108
|
+
* label and for one that spells no length, which stay as they are.
|
|
109
|
+
*/
|
|
110
|
+
export function rungAtOrBelowUnknownLabel(label) {
|
|
111
|
+
if (typeof label !== 'string' || intervalMs(label) !== undefined)
|
|
112
|
+
return undefined;
|
|
113
|
+
const match = /^(\d+)([smhdw])$/.exec(label);
|
|
114
|
+
if (!match)
|
|
115
|
+
return undefined;
|
|
116
|
+
const ms = Number(match[1]) * LABEL_UNIT_MS[match[2]];
|
|
117
|
+
let rung;
|
|
118
|
+
// The table is ascending; a calendar rung (1M 3M 6M 1Y) has no fixed length to compare.
|
|
119
|
+
for (const candidate of LENGTH_TABLE_INTERVAL_LABELS) {
|
|
120
|
+
if (/[MY]$/.test(candidate) || lookupGrpcInterval(candidate) === undefined)
|
|
121
|
+
continue;
|
|
122
|
+
if ((intervalMs(candidate) ?? Infinity) <= ms)
|
|
123
|
+
rung = candidate;
|
|
124
|
+
}
|
|
125
|
+
return rung;
|
|
126
|
+
}
|
|
79
127
|
/** True for the rungs shorter than a minute (1s 5s 15s 30s): one Plus gate, one venue rule, served where 1s is. */
|
|
80
128
|
export function isSubMinuteInterval(label) {
|
|
81
129
|
const ms = intervalMs(label);
|