@orangecharts/wrun-chart-host 0.1.0 → 0.3.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.
Files changed (337) hide show
  1. package/README.md +39 -6
  2. package/dist/constants/common.constants.d.ts +15 -0
  3. package/dist/constants/common.constants.js +23 -0
  4. package/dist/constants/data-source.constants.d.ts +1 -0
  5. package/dist/constants/data-source.constants.js +1 -0
  6. package/dist/constants/economic.constants.d.ts +39 -0
  7. package/dist/constants/economic.constants.js +77 -0
  8. package/dist/constants/etf-covered-coins.constants.d.ts +1 -0
  9. package/dist/constants/etf-covered-coins.constants.js +9 -0
  10. package/dist/constants/feature-flags.constants.d.ts +60 -0
  11. package/dist/constants/feature-flags.constants.js +308 -0
  12. package/dist/constants/feature-limits.constants.d.ts +134 -0
  13. package/dist/constants/feature-limits.constants.js +155 -0
  14. package/dist/constants/marketCapabilities.constants.d.ts +87 -0
  15. package/dist/constants/marketCapabilities.constants.js +213 -0
  16. package/dist/constants/option-venues.constants.d.ts +100 -0
  17. package/dist/constants/option-venues.constants.js +167 -0
  18. package/dist/constants/overlay-data.constants.d.ts +53 -0
  19. package/dist/constants/overlay-data.constants.js +80 -0
  20. package/dist/constants/pane-grid.constants.d.ts +15 -0
  21. package/dist/constants/pane-grid.constants.js +17 -0
  22. package/dist/constants/venue-presets.constants.d.ts +10 -0
  23. package/dist/constants/venue-presets.constants.js +22 -0
  24. package/dist/enums/chart.enum.d.ts +68 -0
  25. package/dist/enums/chart.enum.js +70 -0
  26. package/dist/helpers/data.helpers.d.ts +2 -0
  27. package/dist/helpers/data.helpers.js +14 -0
  28. package/dist/host-env.d.ts +161 -5
  29. package/dist/host-ports.types.d.ts +446 -0
  30. package/dist/host-ports.types.js +1 -0
  31. package/dist/index.d.ts +131 -0
  32. package/dist/index.js +131 -0
  33. package/dist/indicators/controls/technical-script/technical-script-input-rendering.d.ts +86 -0
  34. package/dist/indicators/controls/technical-script/technical-script-input-rendering.js +179 -0
  35. package/dist/interfaces/asset-venue.interface.d.ts +91 -0
  36. package/dist/interfaces/asset-venue.interface.js +1 -0
  37. package/dist/interfaces/cancel-reason.interface.d.ts +24 -0
  38. package/dist/interfaces/cancel-reason.interface.js +2 -0
  39. package/dist/interfaces/catalog-display.interface.d.ts +3 -0
  40. package/dist/interfaces/catalog-display.interface.js +1 -0
  41. package/dist/interfaces/cme-realtime.interface.d.ts +251 -0
  42. package/dist/interfaces/cme-realtime.interface.js +46 -0
  43. package/dist/interfaces/feed.interface.d.ts +80 -0
  44. package/dist/interfaces/feed.interface.js +7 -0
  45. package/dist/interfaces/market-kind.interface.d.ts +8 -0
  46. package/dist/interfaces/market-kind.interface.js +1 -0
  47. package/dist/interfaces/opra-realtime.interface.d.ts +224 -0
  48. package/dist/interfaces/opra-realtime.interface.js +105 -0
  49. package/dist/interfaces/option-instrument.interface.d.ts +32 -0
  50. package/dist/interfaces/option-instrument.interface.js +1 -0
  51. package/dist/interfaces/options-chain-scope.interface.d.ts +29 -0
  52. package/dist/interfaces/options-chain-scope.interface.js +7 -0
  53. package/dist/interfaces/prediction-market.interface.d.ts +88 -0
  54. package/dist/interfaces/prediction-market.interface.js +8 -0
  55. package/dist/interfaces/wrun-runtime.interface.d.ts +5 -0
  56. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +185 -0
  57. package/dist/kscript-data/controls/live-trades-merge.util.js +357 -0
  58. package/dist/settings-templates/frvp-fields.d.ts +27 -0
  59. package/dist/settings-templates/frvp-fields.js +108 -0
  60. package/dist/settings-templates/index.d.ts +119 -0
  61. package/dist/settings-templates/index.js +442 -0
  62. package/dist/settings-templates/indicator-fields.d.ts +56 -0
  63. package/dist/settings-templates/indicator-fields.js +793 -0
  64. package/dist/settings-templates/tool-rules.d.ts +59 -0
  65. package/dist/settings-templates/tool-rules.js +49 -0
  66. package/dist/settings-templates/tool-tables.generated.d.ts +2 -0
  67. package/dist/settings-templates/tool-tables.generated.js +1668 -0
  68. package/dist/utility/blk-market.util.d.ts +5 -0
  69. package/dist/utility/blk-market.util.js +12 -0
  70. package/dist/utility/chart/chart-load-phase.util.d.ts +32 -0
  71. package/dist/utility/chart/chart-load-phase.util.js +78 -0
  72. package/dist/utility/chart/cme-cache-context.util.d.ts +108 -0
  73. package/dist/utility/chart/cme-cache-context.util.js +166 -0
  74. package/dist/utility/chart/cme-session-bucket.util.d.ts +82 -0
  75. package/dist/utility/chart/cme-session-bucket.util.js +343 -0
  76. package/dist/utility/chart/cme-trade-calendar.util.d.ts +26 -0
  77. package/dist/utility/chart/cme-trade-calendar.util.js +147 -0
  78. package/dist/utility/chart/continuous-contracts.util.d.ts +138 -0
  79. package/dist/utility/chart/continuous-contracts.util.js +374 -0
  80. package/dist/utility/chart/feed-interval.util.d.ts +119 -0
  81. package/dist/utility/chart/feed-interval.util.js +321 -0
  82. package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +110 -0
  83. package/dist/utility/chart/fetch-dedupe-policy.util.js +407 -0
  84. package/dist/utility/chart/footprint-band.util.d.ts +76 -0
  85. package/dist/utility/chart/footprint-band.util.js +205 -0
  86. package/dist/utility/chart/footprint-cell-identity.util.d.ts +82 -0
  87. package/dist/utility/chart/footprint-cell-identity.util.js +346 -0
  88. package/dist/utility/chart/formula-calendar.util.d.ts +27 -0
  89. package/dist/utility/chart/formula-calendar.util.js +59 -0
  90. package/dist/utility/chart/history-wall.util.d.ts +67 -0
  91. package/dist/utility/chart/history-wall.util.js +87 -0
  92. package/dist/utility/chart/index-mode.util.d.ts +66 -0
  93. package/dist/utility/chart/index-mode.util.js +360 -0
  94. package/dist/utility/chart/indicator-coverage-planner.util.d.ts +217 -0
  95. package/dist/utility/chart/indicator-coverage-planner.util.js +443 -0
  96. package/dist/utility/chart/indicator-coverage-state.util.d.ts +33 -0
  97. package/dist/utility/chart/indicator-coverage-state.util.js +110 -0
  98. package/dist/utility/chart/indicator-gap-detector.util.d.ts +127 -0
  99. package/dist/utility/chart/indicator-gap-detector.util.js +260 -0
  100. package/dist/utility/chart/indicator-gap-repair.util.d.ts +88 -0
  101. package/dist/utility/chart/indicator-gap-repair.util.js +177 -0
  102. package/dist/utility/chart/indicator-inflight-registry.util.d.ts +26 -0
  103. package/dist/utility/chart/indicator-inflight-registry.util.js +254 -0
  104. package/dist/utility/chart/interval-registry.util.d.ts +23 -0
  105. package/dist/utility/chart/interval-registry.util.js +83 -0
  106. package/dist/utility/chart/kscript-main-grid-stages.util.d.ts +21 -0
  107. package/dist/utility/chart/kscript-main-grid-stages.util.js +332 -0
  108. package/dist/utility/chart/legacy-exchange.leaf.d.ts +11 -0
  109. package/dist/utility/chart/legacy-exchange.leaf.js +43 -0
  110. package/dist/utility/chart/live-bucket.util.d.ts +66 -0
  111. package/dist/utility/chart/live-bucket.util.js +165 -0
  112. package/dist/utility/chart/market-session-schedule.util.d.ts +91 -0
  113. package/dist/utility/chart/market-session-schedule.util.js +337 -0
  114. package/dist/utility/chart/marketKind.util.d.ts +181 -0
  115. package/dist/utility/chart/marketKind.util.js +371 -0
  116. package/dist/utility/chart/om-panel.util.js +6 -0
  117. package/dist/utility/chart/om-widget.util.d.ts +4 -0
  118. package/dist/utility/chart/opra-read-access.leaf.d.ts +26 -0
  119. package/dist/utility/chart/opra-read-access.leaf.js +25 -0
  120. package/dist/utility/chart/prediction-identity.util.d.ts +159 -0
  121. package/dist/utility/chart/prediction-identity.util.js +236 -0
  122. package/dist/utility/chart/rth-session.util.d.ts +352 -0
  123. package/dist/utility/chart/rth-session.util.js +926 -0
  124. package/dist/utility/chart/titan-constants.pin.d.ts +43 -0
  125. package/dist/utility/chart/titan-constants.pin.js +50 -0
  126. package/dist/utility/chart/us-equities-session.util.d.ts +127 -0
  127. package/dist/utility/chart/us-equities-session.util.js +251 -0
  128. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +100 -0
  129. package/dist/utility/chart/wrun-bar-session-facts.util.js +354 -0
  130. package/dist/utility/chart/wrun-run-result.util.js +10 -0
  131. package/dist/utility/chart/wrun-wire-ref.util.d.ts +23 -0
  132. package/dist/utility/chart/wrun-wire-ref.util.js +16 -0
  133. package/dist/utility/common/safe-math-eval.d.ts +18 -0
  134. package/dist/utility/common/safe-math-eval.js +160 -0
  135. package/dist/utility/common/time.util.d.ts +134 -0
  136. package/dist/utility/common/time.util.js +428 -0
  137. package/dist/utility/common/transformations.util.d.ts +126 -0
  138. package/dist/utility/common/transformations.util.js +711 -0
  139. package/dist/utility/common/visible-timeout.util.d.ts +17 -0
  140. package/dist/utility/common/visible-timeout.util.js +75 -0
  141. package/dist/utility/exchange-normalization.util.d.ts +8 -0
  142. package/dist/utility/exchange-normalization.util.js +32 -0
  143. package/dist/utility/intl-locale.util.d.ts +2 -0
  144. package/dist/utility/intl-locale.util.js +28 -0
  145. package/dist/utility/number-format.util.d.ts +14 -1
  146. package/dist/utility/number-format.util.js +50 -19
  147. package/dist/utility/options/option-symbol.util.d.ts +28 -0
  148. package/dist/utility/options/option-symbol.util.js +176 -0
  149. package/dist/utility/options/option-trade-units.util.d.ts +190 -0
  150. package/dist/utility/options/option-trade-units.util.js +283 -0
  151. package/dist/utility/options/option-venue.util.d.ts +75 -0
  152. package/dist/utility/options/option-venue.util.js +85 -0
  153. package/dist/utility/pool-symbol.leaf.d.ts +34 -0
  154. package/dist/utility/pool-symbol.leaf.js +95 -0
  155. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +109 -0
  156. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +302 -0
  157. package/dist/utility/symbol-selection/contract-expiry.util.d.ts +39 -0
  158. package/dist/utility/symbol-selection/contract-expiry.util.js +111 -0
  159. package/dist/utility/v2/gate-plane.util.d.ts +58 -0
  160. package/dist/utility/v2/gate-plane.util.js +99 -0
  161. package/dist/utility/v2/gate-session-latch.util.d.ts +22 -0
  162. package/dist/utility/v2/gate-session-latch.util.js +34 -0
  163. package/dist/utility/watchlist/import/tradingview-symbols.leaf.d.ts +76 -0
  164. package/dist/utility/watchlist/import/tradingview-symbols.leaf.js +221 -0
  165. package/dist/utility/wrun/sources/host-grid-landing.d.ts +15 -0
  166. package/dist/utility/wrun/sources/host-grid-landing.js +26 -0
  167. package/dist/utility/wrun/sources/lanes/bitfinex_funding.d.ts +27 -0
  168. package/dist/utility/wrun/sources/lanes/bitfinex_funding.js +85 -0
  169. package/dist/utility/wrun/sources/lanes/economic.d.ts +27 -0
  170. package/dist/utility/wrun/sources/lanes/economic.js +79 -0
  171. package/dist/utility/wrun/sources/lanes/etf_holdings.d.ts +35 -0
  172. package/dist/utility/wrun/sources/lanes/etf_holdings.js +165 -0
  173. package/dist/utility/wrun/sources/lanes/etf_premium.d.ts +19 -0
  174. package/dist/utility/wrun/sources/lanes/etf_premium.js +114 -0
  175. package/dist/utility/wrun/sources/lanes/ethena_positions.d.ts +30 -0
  176. package/dist/utility/wrun/sources/lanes/ethena_positions.js +51 -0
  177. package/dist/utility/wrun/sources/lanes/index.d.ts +2 -0
  178. package/dist/utility/wrun/sources/lanes/index.js +32 -0
  179. package/dist/utility/wrun/sources/lanes/long_short_ratio.d.ts +17 -0
  180. package/dist/utility/wrun/sources/lanes/long_short_ratio.js +47 -0
  181. package/dist/utility/wrun/sources/lanes/option_daily.d.ts +30 -0
  182. package/dist/utility/wrun/sources/lanes/option_daily.js +53 -0
  183. package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +23 -0
  184. package/dist/utility/wrun/sources/lanes/option_stats_10m.js +20 -0
  185. package/dist/utility/wrun/sources/lanes/options_flow.d.ts +50 -0
  186. package/dist/utility/wrun/sources/lanes/options_flow.js +155 -0
  187. package/dist/utility/wrun/sources/lanes/options_oi.d.ts +29 -0
  188. package/dist/utility/wrun/sources/lanes/options_oi.js +59 -0
  189. package/dist/utility/wrun/sources/lanes/options_volume.d.ts +38 -0
  190. package/dist/utility/wrun/sources/lanes/options_volume.js +63 -0
  191. package/dist/utility/wrun/sources/lanes/series.d.ts +67 -0
  192. package/dist/utility/wrun/sources/lanes/series.js +321 -0
  193. package/dist/utility/wrun/sources/lanes/token_supply.d.ts +30 -0
  194. package/dist/utility/wrun/sources/lanes/token_supply.js +145 -0
  195. package/dist/utility/wrun/sources/lanes/treasury_balance.d.ts +25 -0
  196. package/dist/utility/wrun/sources/lanes/treasury_balance.js +47 -0
  197. package/dist/utility/wrun/sources/lanes/volatility_index.d.ts +21 -0
  198. package/dist/utility/wrun/sources/lanes/volatility_index.js +11 -0
  199. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +196 -0
  200. package/dist/utility/wrun/sources/opra-option-lanes.util.js +446 -0
  201. package/dist/utility/wrun/sources/registry.d.ts +21 -0
  202. package/dist/utility/wrun/sources/registry.js +207 -0
  203. package/dist/utility/wrun/sources/row-lane-registry.d.ts +28 -0
  204. package/dist/utility/wrun/sources/row-lane-registry.js +230 -0
  205. package/dist/utility/wrun/sources/row-lanes/index.d.ts +2 -0
  206. package/dist/utility/wrun/sources/row-lanes/index.js +12 -0
  207. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +2 -0
  208. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +38 -0
  209. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +6 -0
  210. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +70 -0
  211. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +4 -0
  212. package/dist/utility/wrun/sources/row-lanes/option_prints.js +191 -0
  213. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +13 -0
  214. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +137 -0
  215. package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +38 -0
  216. package/dist/utility/wrun/sources/row-lanes/option_surface.js +150 -0
  217. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +275 -0
  218. package/dist/utility/wrun/sources/wrun-poll-lane.types.js +26 -0
  219. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +224 -0
  220. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +394 -0
  221. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +283 -0
  222. package/dist/utility/wrun/sources/wrun-row-lane.types.js +16 -0
  223. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +205 -0
  224. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +469 -0
  225. package/dist/utility/wrun/wrun-browser-sources.leaf.d.ts +28 -0
  226. package/dist/utility/wrun/wrun-browser-sources.leaf.js +66 -0
  227. package/dist/utility/wrun/wrun-cloud-record.util.d.ts +65 -0
  228. package/dist/utility/wrun/wrun-cloud-record.util.js +121 -0
  229. package/dist/utility/wrun/wrun-color-settings.util.js +1 -1
  230. package/dist/utility/wrun/wrun-daily-lane.util.d.ts +95 -0
  231. package/dist/utility/wrun/wrun-daily-lane.util.js +297 -0
  232. package/dist/utility/wrun/wrun-deadline.util.d.ts +52 -0
  233. package/dist/utility/wrun/wrun-deadline.util.js +82 -0
  234. package/dist/utility/wrun/wrun-etf-flow-lane.util.d.ts +94 -0
  235. package/dist/utility/wrun/wrun-etf-flow-lane.util.js +224 -0
  236. package/dist/utility/wrun/wrun-etf-funds.util.d.ts +82 -0
  237. package/dist/utility/wrun/wrun-etf-funds.util.js +242 -0
  238. package/dist/utility/wrun/wrun-failure-cause.d.ts +39 -0
  239. package/dist/utility/wrun/wrun-failure-cause.js +94 -0
  240. package/dist/utility/wrun/wrun-frames.d.ts +28 -3
  241. package/dist/utility/wrun/wrun-frames.js +132 -52
  242. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +167 -4
  243. package/dist/utility/wrun/wrun-hosted-wire-caps.js +47 -2
  244. package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +5 -2
  245. package/dist/utility/wrun/wrun-hosted-wire.util.js +4 -2
  246. package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +22 -0
  247. package/dist/utility/wrun/wrun-lane-refusal.leaf.js +32 -0
  248. package/dist/utility/wrun/wrun-lane-warmup.util.d.ts +18 -0
  249. package/dist/utility/wrun/wrun-lane-warmup.util.js +112 -0
  250. package/dist/utility/wrun/wrun-leg-close.util.d.ts +57 -0
  251. package/dist/utility/wrun/wrun-leg-close.util.js +187 -0
  252. package/dist/utility/wrun/wrun-leg-fetch.util.d.ts +144 -0
  253. package/dist/utility/wrun/wrun-leg-fetch.util.js +212 -0
  254. package/dist/utility/wrun/wrun-leg-stream-classes.d.ts +73 -0
  255. package/dist/utility/wrun/wrun-leg-stream-classes.js +86 -0
  256. package/dist/utility/wrun/wrun-levels-child.util.d.ts +101 -6
  257. package/dist/utility/wrun/wrun-levels-child.util.js +335 -157
  258. package/dist/utility/wrun/wrun-memory-clamp.util.d.ts +33 -0
  259. package/dist/utility/wrun/wrun-memory-clamp.util.js +146 -0
  260. package/dist/utility/wrun/wrun-odds-template-market.util.d.ts +51 -0
  261. package/dist/utility/wrun/wrun-odds-template-market.util.js +251 -0
  262. package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +65 -0
  263. package/dist/utility/wrun/wrun-opra-flow.leaf.js +94 -0
  264. package/dist/utility/wrun/wrun-opra-lane.util.d.ts +47 -0
  265. package/dist/utility/wrun/wrun-opra-lane.util.js +58 -0
  266. package/dist/utility/wrun/wrun-opra-stats.leaf.d.ts +30 -0
  267. package/dist/utility/wrun/wrun-opra-stats.leaf.js +96 -0
  268. package/dist/utility/wrun/wrun-opra-underlying.util.d.ts +12 -0
  269. package/dist/utility/wrun/wrun-opra-underlying.util.js +1 -0
  270. package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +142 -0
  271. package/dist/utility/wrun/wrun-option-contract-flow.util.js +451 -0
  272. package/dist/utility/wrun/wrun-option-knobs.util.d.ts +43 -0
  273. package/dist/utility/wrun/wrun-option-knobs.util.js +81 -0
  274. package/dist/utility/wrun/wrun-option-prints.util.d.ts +144 -0
  275. package/dist/utility/wrun/wrun-option-prints.util.js +356 -0
  276. package/dist/utility/wrun/wrun-option-summary-lane.util.d.ts +102 -0
  277. package/dist/utility/wrun/wrun-option-summary-lane.util.js +143 -0
  278. package/dist/utility/wrun/wrun-options-chain.util.d.ts +308 -0
  279. package/dist/utility/wrun/wrun-options-chain.util.js +502 -0
  280. package/dist/utility/wrun/wrun-overlay-identity.util.d.ts +9 -4
  281. package/dist/utility/wrun/wrun-overlay-identity.util.js +16 -6
  282. package/dist/utility/wrun/wrun-pack.util.d.ts +6 -2
  283. package/dist/utility/wrun/wrun-pack.util.js +13 -3
  284. package/dist/utility/wrun/wrun-param-map.util.d.ts +298 -0
  285. package/dist/utility/wrun/wrun-param-map.util.js +581 -0
  286. package/dist/utility/wrun/wrun-param-values.util.d.ts +8 -0
  287. package/dist/utility/wrun/wrun-param-values.util.js +8 -0
  288. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +149 -0
  289. package/dist/utility/wrun/wrun-pin-spelling.util.js +523 -0
  290. package/dist/utility/wrun/wrun-pin-venues.util.d.ts +116 -0
  291. package/dist/utility/wrun/wrun-pin-venues.util.js +320 -0
  292. package/dist/utility/wrun/wrun-pinned-interval.util.d.ts +20 -0
  293. package/dist/utility/wrun/wrun-pinned-interval.util.js +47 -0
  294. package/dist/utility/wrun/wrun-present-bits.util.d.ts +37 -0
  295. package/dist/utility/wrun/wrun-present-bits.util.js +73 -0
  296. package/dist/utility/wrun/wrun-protocol-pending.util.d.ts +33 -0
  297. package/dist/utility/wrun/wrun-protocol-pending.util.js +57 -0
  298. package/dist/utility/wrun/wrun-refusal.util.d.ts +95 -7
  299. package/dist/utility/wrun/wrun-refusal.util.js +314 -18
  300. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +1 -14
  301. package/dist/utility/wrun/wrun-registry-errors.util.js +0 -16
  302. package/dist/utility/wrun/wrun-render-select.util.js +1 -0
  303. package/dist/utility/wrun/wrun-row-market.util.d.ts +29 -0
  304. package/dist/utility/wrun/wrun-row-market.util.js +92 -0
  305. package/dist/utility/wrun/wrun-row-source.d.ts +158 -0
  306. package/dist/utility/wrun/wrun-row-source.js +75 -0
  307. package/dist/utility/wrun/wrun-run-health.util.d.ts +155 -0
  308. package/dist/utility/wrun/wrun-run-health.util.js +273 -0
  309. package/dist/utility/wrun/wrun-socket-row-source.d.ts +439 -0
  310. package/dist/utility/wrun/wrun-socket-row-source.js +1689 -0
  311. package/dist/utility/wrun/wrun-socket-session-losses.util.d.ts +18 -0
  312. package/dist/utility/wrun/wrun-socket-session-losses.util.js +25 -0
  313. package/dist/utility/wrun/wrun-source-rows.util.d.ts +911 -0
  314. package/dist/utility/wrun/wrun-source-rows.util.js +2597 -0
  315. package/dist/utility/wrun/wrun-symbol-code.util.d.ts +32 -0
  316. package/dist/utility/wrun/wrun-symbol-code.util.js +56 -0
  317. package/dist/utility/wrun/wrun-tape-source.util.d.ts +82 -0
  318. package/dist/utility/wrun/wrun-tape-source.util.js +151 -0
  319. package/dist/utility/wrun/wrun-tier-grid.util.d.ts +137 -0
  320. package/dist/utility/wrun/wrun-tier-grid.util.js +279 -0
  321. package/dist/utility/wrun/wrun-trades-lane.util.d.ts +52 -0
  322. package/dist/utility/wrun/wrun-trades-lane.util.js +58 -0
  323. package/dist/utility/wrun/wrun-volume-profile-lane.util.d.ts +41 -0
  324. package/dist/utility/wrun/wrun-volume-profile-lane.util.js +66 -0
  325. package/dist/utility/wrun-display-name.util.d.ts +33 -0
  326. package/dist/utility/wrun-display-name.util.js +64 -0
  327. package/dist/workers/constants/kscript-transport-codes.d.ts +15 -0
  328. package/dist/workers/constants/kscript-transport-codes.js +15 -0
  329. package/dist/workers/constants/socket-slots.d.ts +574 -0
  330. package/dist/workers/constants/socket-slots.js +539 -0
  331. package/dist/workers/utils/number.worker.util.d.ts +5 -0
  332. package/dist/workers/utils/number.worker.util.js +10 -0
  333. package/dist/workers/utils/time.worker.util.d.ts +12 -0
  334. package/dist/workers/utils/time.worker.util.js +24 -0
  335. package/dist/workers/utils/volume-profile.worker.util.d.ts +200 -0
  336. package/dist/workers/utils/volume-profile.worker.util.js +631 -0
  337. package/package.json +10 -4
@@ -0,0 +1,179 @@
1
+ export const KSCRIPT_INPUT_TYPES = [
2
+ 'number',
3
+ 'int',
4
+ 'float',
5
+ 'boolean',
6
+ 'string',
7
+ 'source',
8
+ 'timeframe',
9
+ 'session',
10
+ 'symbol',
11
+ 'color',
12
+ 'color[]',
13
+ 'text',
14
+ 'select',
15
+ 'multiSelect',
16
+ 'slider',
17
+ ];
18
+ export function technicalScriptInputControlKind(option) {
19
+ if (option.type === 'number' || option.type === 'int' || option.type === 'float')
20
+ return 'number';
21
+ if (option.type === 'text' || option.type === 'string' || option.type === 'timeframe')
22
+ return 'text';
23
+ if (option.type === 'session' || option.type === 'symbol')
24
+ return 'text';
25
+ if (option.type === 'source')
26
+ return option.options?.length ? 'choice' : 'text';
27
+ if (option.type === 'select')
28
+ return 'choice';
29
+ if (option.type === 'multiSelect')
30
+ return 'multiSelect';
31
+ if (option.type === 'boolean')
32
+ return 'boolean';
33
+ if (option.type === 'slider')
34
+ return 'slider';
35
+ if (option.type === 'color')
36
+ return 'color';
37
+ if (option.type === 'color[]')
38
+ return 'colorArray';
39
+ return null;
40
+ }
41
+ /**
42
+ * A section's kScript inputs as the rows the dialog draws, in order: an input
43
+ * declared `inline` (the engine's `input(..., inline=true)`) shares the row of
44
+ * the input before it, its words beside its control the way a typed-inputs
45
+ * row pair names each field; every other input starts a row of its own. The
46
+ * section's first input always starts one, `inline` or not: there is nothing
47
+ * before it to sit beside.
48
+ */
49
+ export function technicalScriptInputRows(options) {
50
+ const rows = [];
51
+ for (const option of options) {
52
+ const last = rows[rows.length - 1];
53
+ if (option.inline === true && last)
54
+ last.push(option);
55
+ else
56
+ rows.push([option]);
57
+ }
58
+ return rows;
59
+ }
60
+ /** A kScript input label from camelCase or snake_case to Title Case, acronyms
61
+ * kept ("smoothLength" -> "Smooth Length", "USDValue" -> "USD Value", "ATRs"
62
+ * stays "ATRs"). kScript rows only: a browser-run Indicator's row prints its
63
+ * label verbatim (wrun-script-inputs.util wrunRowLabel). */
64
+ export function formatTechnicalScriptLabel(name) {
65
+ return (name
66
+ .replace(/_/g, ' ')
67
+ // Space only at real camelCase boundaries, never between the letters of an
68
+ // acronym: "smoothLength" -> "smooth Length", but "USD"/"EQ" stay intact.
69
+ .replace(/([a-z0-9])([A-Z])/g, '$1 $2')
70
+ // Split a trailing word off a leading acronym: "USDValue" -> "USD Value".
71
+ // The word needs two lower-case letters after its capital, so an
72
+ // acronym's plural stays whole ("ATRs", "EMAs", never "AT Rs").
73
+ .replace(/([A-Z]+)([A-Z][a-z]{2,})/g, '$1 $2')
74
+ .split(/\s+/)
75
+ .filter(Boolean)
76
+ // Keep all-caps tokens as acronyms (USD, EQ, MA); Title-case ordinary words.
77
+ .map((word) => (/^[A-Z0-9]+$/.test(word) ? word : word.charAt(0).toUpperCase() + word.slice(1)))
78
+ .join(' '));
79
+ }
80
+ /** A typed-inputs row label as the dialog shows it: an identifier-like label
81
+ * (one token: "maLength", "zone_atr") as Title Case words, a label with
82
+ * spaces (the author's words, or the description a sheet without labels
83
+ * falls back to) as written, so a sentence never reads "A Day Is Tagged". */
84
+ export function formatWrunRowLabel(label) {
85
+ const written = label.trim();
86
+ return /\s/.test(written) ? written : formatTechnicalScriptLabel(written);
87
+ }
88
+ /** The finest step the fallback derives (0.0001). */
89
+ const FALLBACK_STEP_MAX_DECIMALS = 4;
90
+ function decimalPlaces(value) {
91
+ if (typeof value !== 'number' || !Number.isFinite(value) || Number.isInteger(value))
92
+ return 0;
93
+ // Exponent notation counts the decimals of 1e-7 and 0.000012 as well as 0.618's.
94
+ const [digits, exponent] = value.toExponential().split('e');
95
+ return Math.max(0, (digits.split('.')[1]?.length ?? 0) - Number(exponent));
96
+ }
97
+ /**
98
+ * The step a number field moves by: its declared step, else 10^-d for the
99
+ * most decimals among its default, min and max (d capped at 4: a 0.618
100
+ * default steps by 0.001, a 0.25 by 0.01), else 1. A sheet published without
101
+ * the original's step (abcd-pattern, supply-demand-zones) no longer steps
102
+ * past every decimal; display only, the stored value is the field's.
103
+ */
104
+ export function effectiveStep(decl) {
105
+ const declared = decl.constraints?.step;
106
+ if (typeof declared === 'number' && Number.isFinite(declared) && declared > 0)
107
+ return declared;
108
+ const decimals = Math.min(FALLBACK_STEP_MAX_DECIMALS, Math.max(decimalPlaces(decl.defaultValue), decimalPlaces(decl.constraints?.min), decimalPlaces(decl.constraints?.max)));
109
+ return decimals === 0 ? 1 : Number((10 ** -decimals).toFixed(decimals));
110
+ }
111
+ /** The step the kScript dialog moves a number input by: its declared step, else 1. */
112
+ export function kscriptNumberStep(constraints) {
113
+ return constraints?.step || 1;
114
+ }
115
+ /**
116
+ * The step a package's number field moves by. A PORT of a kScript original
117
+ * (`port`: the twins join names its package, a built-in's twin or an
118
+ * official doc's) moves the way its original's dialog moves the same input,
119
+ * kscriptNumberStep. Its sheet declares the original's inputs as written, so
120
+ * an input its original declares without a step (cci's Constant 0.015, psar's
121
+ * Start, zig-zag's Price Deviation, cusum-change-point's Drift (k)) carries
122
+ * none and takes the original dialog's 1 here. Every other package moves by
123
+ * effectiveStep. Display only: the stored value is the field's, and a sheet
124
+ * `step` is only the stepper's increment (the param value rule,
125
+ * wrunParamValueRefusal, never reads it).
126
+ */
127
+ export function wrunNumberStep(decl, port) {
128
+ return port ? kscriptNumberStep(decl.constraints) : effectiveStep(decl);
129
+ }
130
+ /**
131
+ * The control kind of one typed-inputs row: a style row by its bound
132
+ * property (resolved by the control), a numeric row with `slider: true` as
133
+ * the slider, an interval host param as the timeframe select, every other
134
+ * declared type as its own control; an unknown type falls back to the number
135
+ * field every param rendered as before the typed kinds.
136
+ */
137
+ export function wrunRowControlKind(decl, host) {
138
+ if (decl.styleOf)
139
+ return 'style';
140
+ switch (decl.type) {
141
+ case 'number':
142
+ case 'int':
143
+ return decl.slider ? 'slider' : 'number';
144
+ case 'slider':
145
+ return 'slider';
146
+ case 'boolean':
147
+ return 'boolean';
148
+ case 'select':
149
+ return host === 'interval' ? 'timeframe' : 'select';
150
+ case 'multi':
151
+ return 'multi';
152
+ case 'color':
153
+ return 'color';
154
+ case 'color[]':
155
+ return 'colorArray';
156
+ case 'symbol':
157
+ return 'symbol';
158
+ case 'text':
159
+ return 'text';
160
+ case 'time':
161
+ return 'time';
162
+ case 'price':
163
+ return decl.slider ? 'slider' : 'price';
164
+ case 'range':
165
+ return 'range';
166
+ case 'list':
167
+ return 'list';
168
+ case 'unit':
169
+ return 'unit';
170
+ case 'session':
171
+ return 'session';
172
+ case 'divider':
173
+ return 'divider';
174
+ case 'note':
175
+ return 'note';
176
+ default:
177
+ return 'number';
178
+ }
179
+ }
@@ -0,0 +1,91 @@
1
+ import type { CatalogDisplayFields } from './catalog-display.interface.js';
2
+ /**
3
+ * The gateway's `Representation` (MarketSymbol field 46) as the enum NAME a row carries
4
+ * (`normalizeRepresentationName`). UNKNOWN_REPRESENTATION and values this build does not know are
5
+ * left absent: absence never establishes a native listing.
6
+ */
7
+ export type RepresentationName = 'REPRESENTATION_NATIVE' | 'REPRESENTATION_TOKENIZED';
8
+ /**
9
+ * One tradeable market on a specific exchange, as symbol search lists it under its asset. Its own interface, so the
10
+ * governed contract annotations (utility/symbol-selection/contract-expiry.util.ts) read it without the asset search
11
+ * model, which reaches the symbol catalog's sources and the chart interface. asset-search.interface.ts re-exports it.
12
+ */
13
+ export interface Venue extends CatalogDisplayFields {
14
+ /** Tradeable pair symbol: "BTCUSDT", "GOLD-USDC", "XAUUSD" */
15
+ symbol: string;
16
+ /** Backend exchange key: "BINANCE_FUTURES", "HYPERLIQUID_FUTURES", "HYPERLIQUID_HIP3" */
17
+ exchange: string;
18
+ /** Human-readable exchange name: "Binance", "Hyperliquid" */
19
+ displayExchange: string;
20
+ /**
21
+ * Listing venue as the enum member name (the gateway's `displayExchange`): "NASDAQ" for a stock
22
+ * whose `exchange` is the shared "POLYGON" feed, the exchange itself for most venues. Absent where
23
+ * the source does not carry it (the names-only universe directory).
24
+ */
25
+ listingExchange?: string;
26
+ /** Key for icon resolution via useIcon composable */
27
+ exchangeId: string;
28
+ /** Market type (simplified for filtering) */
29
+ pairType: 'spot' | 'perp';
30
+ /** Raw instrument type from API: "SPOT", "PERPETUAL", "FUTURE", "OPTION", etc. */
31
+ instrumentType: string;
32
+ /** Governed futures only: conservative expiry instant (end of delivery month, UTC ms). */
33
+ contractExpiryTs?: number;
34
+ /** Governed futures only: nearest-expiry live contract within its asset group. */
35
+ isFrontMonth?: boolean;
36
+ /** Governed futures only: continuous contract row (ES1!); never expires, never front month. */
37
+ isContinuous?: boolean;
38
+ /** 24h trading volume in the venue's own quote currency (`MarketSymbol.volume24h`). */
39
+ volume24h: number;
40
+ /**
41
+ * 24h volume converted to USD by the gateway (`MarketSymbol.volume24hUsd`,
42
+ * field 54): the only figure comparable across venues, so it is what ranks
43
+ * a group's venues and picks the Enter target. Absent means not computable
44
+ * (an unpriced quote, no volume at all) and is never read as zero.
45
+ */
46
+ volume24hUsd?: number;
47
+ /** Open interest (perps/futures only) */
48
+ openInterest?: number;
49
+ /** Funding rate (perps only) */
50
+ fundingRate?: number;
51
+ /** HIP-3 deployer name: "xyzzy", "cash", "fax", "km" */
52
+ deployer?: string;
53
+ /** Quote asset human name: "USD Coin", "Tether", "HyperUSD" */
54
+ quoteName?: string;
55
+ /** Original backend raw symbol (for API calls) */
56
+ rawSymbol?: string;
57
+ /** Normalized symbol: "BTC-USD", "GOLD-USDC" */
58
+ normalizedSymbol?: string;
59
+ /** Display symbol base portion: "BTC", "GOLD" */
60
+ displayBase?: string;
61
+ /** Display symbol quote portion: "USDT", "USDC" */
62
+ displayQuote?: string;
63
+ /** Latest trade price for this venue */
64
+ lastPrice?: number;
65
+ /** 24h price change as a percentage (e.g. -1.08 for -1.08%) */
66
+ priceChangePct?: number;
67
+ /** Sparkline points for this venue */
68
+ chartData?: number[];
69
+ /**
70
+ * Backend `representation` is TOKENIZED: the pair is a token wrapping an
71
+ * off-chain asset (an xStock such as AAPLX). Absent means unknown, not native.
72
+ */
73
+ isTokenized?: boolean;
74
+ /**
75
+ * Backend `representation` as the enum NAME: NATIVE for an instrument in its own form (a stock's
76
+ * exchange listing, a perp), TOKENIZED for a token wrapping an off-chain asset. Absent means
77
+ * unknown, never native (`isNativeListing` in `own-market.util` reads an explicit NATIVE only).
78
+ */
79
+ representation?: RepresentationName;
80
+ /**
81
+ * Backend `assetClass` (MarketSymbol field 45) as the enum NAME
82
+ * (`ASSET_CLASS_STOCK`): the catalog's per-instrument class, which a HIP-3
83
+ * stock perp or a tokenized stock carries while its exchange reads crypto.
84
+ * Absent means the row was not classified (or predates the field).
85
+ */
86
+ assetClass?: string;
87
+ chain?: string;
88
+ poolAddress?: string;
89
+ baseTokenAddress?: string;
90
+ quoteTokenAddress?: string;
91
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Why a subscriber cancelled: the codes every cancel endpoint accepts (`POST /kiyo-plus/subscription/cancel`,
3
+ * `/api-tier/subscription/cancel`, `/cme/subscription/cancel` at period end, `/opra/subscription/cancel`).
4
+ * Frozen with the backend; a new code is a wire change on both sides.
5
+ */
6
+ export type CancelReason = 'too_expensive' | 'not_using' | 'missing_data' | 'technical_issues' | 'switched' | 'no_auto_renew' | 'other';
7
+ /**
8
+ * The optional JSON body of a cancel request. A field is omitted when the subscriber gave nothing for it,
9
+ * never sent as null or an empty string, and no body at all goes out when both are absent.
10
+ */
11
+ export interface CancelFeedback {
12
+ reason?: CancelReason;
13
+ /** Trimmed and at most CANCEL_COMMENT_MAX_LENGTH characters. */
14
+ comment?: string;
15
+ }
16
+ /** The picker's v-model: one reason or none, and the comment box's text. */
17
+ export interface CancelReasonSelection {
18
+ reason: CancelReason | null;
19
+ comment: string;
20
+ }
21
+ /** The product a cancel ends, as the `billing:cancel` event names it. */
22
+ export type CancelProduct = 'plus' | 'api' | 'cme' | 'opra';
23
+ /** The server's comment limit, in UTF-16 code units (what a textarea's maxlength and a JS length count). */
24
+ export declare const CANCEL_COMMENT_MAX_LENGTH = 500;
@@ -0,0 +1,2 @@
1
+ /** The server's comment limit, in UTF-16 code units (what a textarea's maxlength and a JS length count). */
2
+ export const CANCEL_COMMENT_MAX_LENGTH = 500;
@@ -0,0 +1,3 @@
1
+ import type { MarketSymbol } from '@orangecharts/orange-v2-pb-common';
2
+ /** Venue label and quote facts; chart prices remain in their native quote units. */
3
+ export type CatalogDisplayFields = Partial<Pick<MarketSymbol, 'dexName' | 'shareMultiplier' | 'quoteAssetId' | 'liquidity'>>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,251 @@
1
+ import type { WsSlotId } from '../workers/constants/socket-slots.js';
2
+ import type { CancelFeedback } from './cancel-reason.interface.js';
3
+ type CmeClassificationDto = 'professional' | 'non_professional';
4
+ export type CmeExchangeDto = 'CME' | 'CBOT' | 'NYMEX' | 'COMEX';
5
+ /**
6
+ * A governed CME-family exchange code, including GLOBEX — the metadata alias
7
+ * some feeds use for CME-family symbols. Governed for disclosure/capability
8
+ * purposes but never purchasable (see the catalog below).
9
+ */
10
+ export type CmeGovernedExchange = CmeExchangeDto | 'GLOBEX';
11
+ /**
12
+ * The single source of truth for CME-family exchange codes and their role.
13
+ * Every governed/purchasable/filter list derives from this table, so GLOBEX's
14
+ * alias-only status (governed for disclosure, never a Stripe line item, no gate
15
+ * mapping yet — an open backend confirmation item) holds by construction rather
16
+ * than by separate lists agreeing. Order is stable and load-bearing: the
17
+ * purchasable slice IS the launch bundle, in this order.
18
+ */
19
+ export declare const CME_EXCHANGE_CATALOG: readonly {
20
+ code: CmeGovernedExchange;
21
+ role: 'purchasable' | 'alias';
22
+ }[];
23
+ /** Every governed code (the purchasable DCMs plus the GLOBEX alias), stable order. */
24
+ export declare const CME_GOVERNED_EXCHANGES: readonly CmeGovernedExchange[];
25
+ /**
26
+ * The launch bundle: the purchasable slice of the catalog, in stable order.
27
+ * Lives here (not in the service) so the mock provider can enumerate it
28
+ * without importing the service.
29
+ */
30
+ export declare const CME_BUNDLE_EXCHANGES: readonly CmeExchangeDto[];
31
+ type CmeDepthDto = 'l1' | 'depth';
32
+ type CmeIntervalDto = '1m' | '1y';
33
+ /** POST /cme/attestation request body. */
34
+ export interface SubmitCmeAttestationDto {
35
+ classification: CmeClassificationDto;
36
+ /** Keyed by stable machine question IDs, never translated question text. */
37
+ answers: Record<string, unknown>;
38
+ legalName: string;
39
+ employer?: string;
40
+ occupation?: string;
41
+ /** Additive: backend stores it into the immutable record (audit reconstruction). */
42
+ formVersion?: string;
43
+ }
44
+ /** POST /cme/attestation -> 201 body. */
45
+ export interface SubmitCmeAttestationResponseDto {
46
+ attestationId: number;
47
+ }
48
+ /** Attestation record as served by GET /cme/attestation (snake_case pass-through). */
49
+ export interface CmeAttestationDto {
50
+ id: number;
51
+ access_id: string;
52
+ classification: CmeClassificationDto;
53
+ expires_at: string;
54
+ }
55
+ /** GET /cme/attestation -> 200 body. */
56
+ export interface GetCmeAttestationResponseDto {
57
+ attestation: CmeAttestationDto | null;
58
+ }
59
+ /** POST /cme/checkout request body. `exchanges` must be the full distinct 4-exchange bundle. */
60
+ export interface CmeCheckoutDto {
61
+ exchanges: CmeExchangeDto[];
62
+ depth: CmeDepthDto;
63
+ interval: CmeIntervalDto;
64
+ locale?: string;
65
+ }
66
+ /** POST /cme/checkout -> 200: Stripe redirect for a fresh purchase, message for an in-place change. */
67
+ export type CmeCheckoutResponseDto = {
68
+ url: string;
69
+ } | {
70
+ message: string;
71
+ };
72
+ /** Subscription as served by GET /cme/subscription (already camelCase on the wire). */
73
+ export interface CmeSubscriptionDto {
74
+ /** Held-now access level ('depth' while a downgrade is pending). */
75
+ level: CmeDepthDto;
76
+ pendingDowngrade: 'l1' | null;
77
+ interval: CmeIntervalDto;
78
+ /** ISO timestamp of the current period end. */
79
+ renewsAt: string;
80
+ pendingCancellation: boolean;
81
+ /** Next-cycle price (already L1-priced during a pending downgrade). */
82
+ priceUsd: number;
83
+ }
84
+ /** GET /cme/subscription -> 200 body. */
85
+ export interface GetCmeSubscriptionResponseDto {
86
+ subscription: CmeSubscriptionDto | null;
87
+ }
88
+ /**
89
+ * GET /cme/data-terms -> 200 body; POST /cme/data-terms -> 201 body. The server
90
+ * derives `accepted` from the entitlement ledger, so users already granted or
91
+ * subscribed read as accepted without ever posting; posting registers the
92
+ * free/delayed plan and the registration row IS the acceptance record.
93
+ */
94
+ export interface CmeDataTermsDto {
95
+ accepted: boolean;
96
+ }
97
+ export type CmeClassification = CmeClassificationDto;
98
+ export type CmeDepth = CmeDepthDto;
99
+ export type CmeBillingInterval = CmeIntervalDto;
100
+ export interface CmeAttestation {
101
+ id: number;
102
+ accessId: string;
103
+ classification: CmeClassification;
104
+ /** ISO timestamp; validity is derived at read time, never cached as a boolean. */
105
+ expiresAt: string;
106
+ }
107
+ export interface CmeSubscription {
108
+ level: CmeDepth;
109
+ pendingDowngrade: 'l1' | null;
110
+ interval: CmeBillingInterval;
111
+ renewsAt: string;
112
+ pendingCancellation: boolean;
113
+ priceUsd: number;
114
+ }
115
+ export interface CmeAttestationSubmission {
116
+ classification: CmeClassification;
117
+ answers: Record<string, unknown>;
118
+ legalName: string;
119
+ employer?: string;
120
+ occupation?: string;
121
+ /** Form wording/ID-set version captured into the immutable record. */
122
+ formVersion: string;
123
+ }
124
+ /** What the UI decides; the repository supplies the fixed exchange bundle itself. */
125
+ export interface CmeCheckoutIntent {
126
+ depth: CmeDepth;
127
+ interval: CmeBillingInterval;
128
+ locale?: string;
129
+ }
130
+ /**
131
+ * Normalized checkout outcome. 'redirect' = fresh purchase, leave for Stripe.
132
+ * 'applied' = the subscription was changed in place; reload state before
133
+ * showing success. 'busy' = a checkout for this account is already in flight.
134
+ * Backend message strings ride along as diagnostics only; user-visible copy
135
+ * comes from i18n keyed off the outcome.
136
+ */
137
+ export type CmeCheckoutResult = {
138
+ kind: 'redirect';
139
+ url: string;
140
+ } | {
141
+ kind: 'applied';
142
+ message: string | null;
143
+ } | {
144
+ kind: 'busy';
145
+ };
146
+ /**
147
+ * What the data plane is actually serving, which is NOT the billing state:
148
+ * a paid subscription does not prove entitlement propagation has completed.
149
+ * 'unknown' must be treated delayed-safe by every consumer.
150
+ */
151
+ export type CmeServedAccess = {
152
+ status: 'unknown';
153
+ } | {
154
+ status: 'known';
155
+ timing: 'delayed';
156
+ depth: null;
157
+ delaySeconds?: number;
158
+ } | {
159
+ status: 'known';
160
+ timing: 'realtime';
161
+ depth: CmeDepth;
162
+ };
163
+ /**
164
+ * Served access per governed exchange, keyed by uppercased exchange code
165
+ * (e.g. `CME`). The gate's tier frame is per-exchange and, once the BE splits
166
+ * sockets by tier, several sockets serve one account at once — so served access
167
+ * is fundamentally per-exchange, not one account-level value. An exchange absent
168
+ * from the map is treated 'unknown' (delayed-safe) by every consumer.
169
+ */
170
+ export type CmeServedAccessByExchange = Record<string, CmeServedAccess>;
171
+ /** Attestation validity is derived at read time from expiresAt, never cached. */
172
+ export declare function isCmeAttestationValid(attestation: CmeAttestation | null, now?: number): boolean;
173
+ /**
174
+ * Stable, transport-free error surface for billing calls. 'attestation_rejected'
175
+ * covers the checkout 403 gates (missing OR expired attestation); callers
176
+ * re-fetch attestation state to learn which, rather than matching message text.
177
+ * 'invoice_owed' is the checkout refusal while Stripe is still collecting a CME
178
+ * invoice (the renewal is in retries): a retry gets the same answer until that
179
+ * invoice is paid, so it carries the pay link instead of reading as a conflict.
180
+ */
181
+ export type CmeBillingErrorKind = 'attestation_rejected' | 'conflict' | 'invoice_owed' | 'unauthorized' | 'network' | 'aborted' | 'server';
182
+ export declare class CmeBillingError extends Error {
183
+ readonly kind: CmeBillingErrorKind;
184
+ readonly status: number | null;
185
+ /** Raw backend message: diagnostic/fallback content only, never primary UI copy. */
186
+ readonly diagnosticMessage: string | null;
187
+ /** Stripe's hosted invoice on an 'invoice_owed' refusal; null when Stripe published none, and on every other kind. */
188
+ readonly invoiceUrl: string | null;
189
+ constructor(kind: CmeBillingErrorKind, options?: {
190
+ status?: number | null;
191
+ diagnosticMessage?: string | null;
192
+ invoiceUrl?: string | null;
193
+ });
194
+ }
195
+ export interface CmeBillingRepository {
196
+ getAttestation(signal?: AbortSignal): Promise<CmeAttestation | null>;
197
+ submitAttestation(submission: CmeAttestationSubmission, signal?: AbortSignal): Promise<{
198
+ attestationId: number;
199
+ }>;
200
+ getSubscription(signal?: AbortSignal): Promise<CmeSubscription | null>;
201
+ /**
202
+ * `idempotencyId` follows the plan-tier checkout convention: minted per user
203
+ * action, retained across retries of that same action, replaced for a new one.
204
+ */
205
+ checkout(intent: CmeCheckoutIntent, options: {
206
+ idempotencyId: string;
207
+ signal?: AbortSignal;
208
+ }): Promise<CmeCheckoutResult>;
209
+ /**
210
+ * `immediate` ends the sub now (classification switch); default cancels at period end. `feedback` is the
211
+ * subscriber's optional reason, period-end cancels only: the switch asks nothing and sends none.
212
+ */
213
+ cancelSubscription(immediate?: boolean, signal?: AbortSignal, feedback?: CancelFeedback): Promise<{
214
+ message: string | null;
215
+ }>;
216
+ retractCancellation(signal?: AbortSignal): Promise<{
217
+ message: string | null;
218
+ }>;
219
+ /** First-access data-terms gate: whether this account has accepted the CME data terms. */
220
+ getDataTerms(signal?: AbortSignal): Promise<{
221
+ accepted: boolean;
222
+ }>;
223
+ /** Accepts the terms (registers the free/delayed plan; the row is the acceptance record). */
224
+ acceptDataTerms(signal?: AbortSignal): Promise<{
225
+ accepted: boolean;
226
+ }>;
227
+ }
228
+ /**
229
+ * Read/watch contract for the served data tier, per governed exchange. The live
230
+ * implementation reports 'unknown' for an exchange until the gate's tier frame
231
+ * says otherwise; it must never infer 'realtime' from billing state.
232
+ */
233
+ export interface CmeRuntimeAccessProvider {
234
+ /** Latest served access for one exchange; 'unknown' (delayed-safe) if absent. */
235
+ getServedAccessForExchange(exchange: string): CmeServedAccess;
236
+ /** Immediately invokes the listener with the current per-exchange map; returns an unsubscribe. */
237
+ watchServedAccess(listener: (byExchange: CmeServedAccessByExchange) => void): () => void;
238
+ /**
239
+ * Retire the frame a now-closed socket contributed. Optional: only the live
240
+ * provider keeps per-slot frames. Without it a stale realtime frame outranks
241
+ * the live delayed one forever (the merge is most-permissive), pinning an
242
+ * unentitled account to the `/live/*` slots. `immediate` skips the coalescing
243
+ * window a close normally gets — for a definitive gate refusal, not a blip.
244
+ */
245
+ retireTierFrame?(sourceSlot: WsSlotId, options?: {
246
+ immediate?: boolean;
247
+ }): void;
248
+ /** Drop every frame (logout / account change). Optional, see above. */
249
+ resetTierFrames?(): void;
250
+ }
251
+ export {};
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The single source of truth for CME-family exchange codes and their role.
3
+ * Every governed/purchasable/filter list derives from this table, so GLOBEX's
4
+ * alias-only status (governed for disclosure, never a Stripe line item, no gate
5
+ * mapping yet — an open backend confirmation item) holds by construction rather
6
+ * than by separate lists agreeing. Order is stable and load-bearing: the
7
+ * purchasable slice IS the launch bundle, in this order.
8
+ */
9
+ export const CME_EXCHANGE_CATALOG = [
10
+ { code: 'CME', role: 'purchasable' },
11
+ { code: 'CBOT', role: 'purchasable' },
12
+ { code: 'NYMEX', role: 'purchasable' },
13
+ { code: 'COMEX', role: 'purchasable' },
14
+ { code: 'GLOBEX', role: 'alias' },
15
+ ];
16
+ /** Every governed code (the purchasable DCMs plus the GLOBEX alias), stable order. */
17
+ export const CME_GOVERNED_EXCHANGES = CME_EXCHANGE_CATALOG.map((e) => e.code);
18
+ /**
19
+ * The launch bundle: the purchasable slice of the catalog, in stable order.
20
+ * Lives here (not in the service) so the mock provider can enumerate it
21
+ * without importing the service.
22
+ */
23
+ export const CME_BUNDLE_EXCHANGES = CME_EXCHANGE_CATALOG.filter((e) => e.role === 'purchasable').map((e) => e.code);
24
+ /** Attestation validity is derived at read time from expiresAt, never cached. */
25
+ export function isCmeAttestationValid(attestation, now = Date.now()) {
26
+ if (!attestation)
27
+ return false;
28
+ const expires = Date.parse(attestation.expiresAt);
29
+ return Number.isFinite(expires) && expires > now;
30
+ }
31
+ export class CmeBillingError extends Error {
32
+ kind;
33
+ status;
34
+ /** Raw backend message: diagnostic/fallback content only, never primary UI copy. */
35
+ diagnosticMessage;
36
+ /** Stripe's hosted invoice on an 'invoice_owed' refusal; null when Stripe published none, and on every other kind. */
37
+ invoiceUrl;
38
+ constructor(kind, options) {
39
+ super(`cme billing error: ${kind}`);
40
+ this.name = 'CmeBillingError';
41
+ this.kind = kind;
42
+ this.status = options?.status ?? null;
43
+ this.diagnosticMessage = options?.diagnosticMessage ?? null;
44
+ this.invoiceUrl = options?.invoiceUrl ?? null;
45
+ }
46
+ }