@polyester/sdk 0.36.0-devnet-20261117035807 → 0.36.0-devnet-20261118141710

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 (345) hide show
  1. package/CHANGELOG.md +66 -8
  2. package/dist/catalogs/index.d.ts +2 -2
  3. package/dist/catalogs/snapshot-validation.js +10 -1
  4. package/dist/catalogs/snapshot-validation.js.map +1 -1
  5. package/dist/catalogs/zipper-catalog.d.ts +2 -0
  6. package/dist/catalogs/zipper-catalog.d.ts.map +1 -1
  7. package/dist/catalogs/zipper-catalog.js.map +1 -1
  8. package/dist/catalogs/zipper-supply.d.ts +2 -0
  9. package/dist/catalogs/zipper-supply.d.ts.map +1 -1
  10. package/dist/catalogs/zipper-supply.js +7 -5
  11. package/dist/catalogs/zipper-supply.js.map +1 -1
  12. package/dist/client.d.ts +2 -0
  13. package/dist/client.d.ts.map +1 -1
  14. package/dist/client.js +2 -0
  15. package/dist/client.js.map +1 -1
  16. package/dist/gen/ai/v1/assistant_pb.d.ts +679 -13
  17. package/dist/gen/ai/v1/assistant_pb.d.ts.map +1 -1
  18. package/dist/gen/ai/v1/assistant_pb.js +355 -97
  19. package/dist/gen/ai/v1/assistant_pb.js.map +1 -1
  20. package/dist/gen/alerts/v1/price_alerts_pb.d.ts +33 -4
  21. package/dist/gen/alerts/v1/price_alerts_pb.d.ts.map +1 -1
  22. package/dist/gen/alerts/v1/price_alerts_pb.js +23 -2
  23. package/dist/gen/alerts/v1/price_alerts_pb.js.map +1 -1
  24. package/dist/gen/auth/v1/activity_pb.d.ts +148 -0
  25. package/dist/gen/auth/v1/activity_pb.d.ts.map +1 -0
  26. package/dist/gen/auth/v1/activity_pb.js +40 -0
  27. package/dist/gen/auth/v1/activity_pb.js.map +1 -0
  28. package/dist/gen/auth/v1/api_keys_pb.d.ts +10 -4
  29. package/dist/gen/auth/v1/api_keys_pb.d.ts.map +1 -1
  30. package/dist/gen/auth/v1/api_keys_pb.js +3 -1
  31. package/dist/gen/auth/v1/api_keys_pb.js.map +1 -1
  32. package/dist/gen/auth/v1/auth_pb.d.ts +61 -5
  33. package/dist/gen/auth/v1/auth_pb.d.ts.map +1 -1
  34. package/dist/gen/auth/v1/auth_pb.js +23 -6
  35. package/dist/gen/auth/v1/auth_pb.js.map +1 -1
  36. package/dist/gen/auth/v1/mfa_pb.d.ts +140 -2
  37. package/dist/gen/auth/v1/mfa_pb.d.ts.map +1 -1
  38. package/dist/gen/auth/v1/mfa_pb.js +80 -8
  39. package/dist/gen/auth/v1/mfa_pb.js.map +1 -1
  40. package/dist/gen/auth/v1/policies_pb.d.ts +18 -3
  41. package/dist/gen/auth/v1/policies_pb.d.ts.map +1 -1
  42. package/dist/gen/auth/v1/policies_pb.js +18 -3
  43. package/dist/gen/auth/v1/policies_pb.js.map +1 -1
  44. package/dist/gen/auth/v1/social_verification_pb.d.ts +36 -15
  45. package/dist/gen/auth/v1/social_verification_pb.d.ts.map +1 -1
  46. package/dist/gen/auth/v1/social_verification_pb.js +1 -1
  47. package/dist/gen/auth/v1/social_verification_pb.js.map +1 -1
  48. package/dist/gen/auth/v1/subaccounts_pb.d.ts +15 -1
  49. package/dist/gen/auth/v1/subaccounts_pb.d.ts.map +1 -1
  50. package/dist/gen/auth/v1/subaccounts_pb.js +1 -1
  51. package/dist/gen/auth/v1/subaccounts_pb.js.map +1 -1
  52. package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.d.ts +6 -2
  53. package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.d.ts.map +1 -1
  54. package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.js.map +1 -1
  55. package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts +104 -6
  56. package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts.map +1 -1
  57. package/dist/gen/chain/withdraw/v1/withdraw_pb.js +49 -3
  58. package/dist/gen/chain/withdraw/v1/withdraw_pb.js.map +1 -1
  59. package/dist/gen/chain/zipper/v1/zipper_pb.d.ts +76 -3
  60. package/dist/gen/chain/zipper/v1/zipper_pb.d.ts.map +1 -1
  61. package/dist/gen/chain/zipper/v1/zipper_pb.js +46 -2
  62. package/dist/gen/chain/zipper/v1/zipper_pb.js.map +1 -1
  63. package/dist/gen/index.d.ts +3 -1
  64. package/dist/gen/index.js +4 -2
  65. package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts +21 -139
  66. package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts.map +1 -1
  67. package/dist/gen/ledger/read/v1/ledger_read_pb.js +16 -17
  68. package/dist/gen/ledger/read/v1/ledger_read_pb.js.map +1 -1
  69. package/dist/gen/ledger/read/v1/statement_export_pb.d.ts +236 -20
  70. package/dist/gen/ledger/read/v1/statement_export_pb.d.ts.map +1 -1
  71. package/dist/gen/ledger/read/v1/statement_export_pb.js +44 -10
  72. package/dist/gen/ledger/read/v1/statement_export_pb.js.map +1 -1
  73. package/dist/gen/ledger/v1/catalog_pb.d.ts +9 -1
  74. package/dist/gen/ledger/v1/catalog_pb.d.ts.map +1 -1
  75. package/dist/gen/ledger/v1/catalog_pb.js +9 -1
  76. package/dist/gen/ledger/v1/catalog_pb.js.map +1 -1
  77. package/dist/gen/marketdata/v1/asset_info_pb.d.ts +158 -7
  78. package/dist/gen/marketdata/v1/asset_info_pb.d.ts.map +1 -1
  79. package/dist/gen/marketdata/v1/asset_info_pb.js +56 -6
  80. package/dist/gen/marketdata/v1/asset_info_pb.js.map +1 -1
  81. package/dist/gen/notifications/v1/notifications_pb.d.ts +45 -6
  82. package/dist/gen/notifications/v1/notifications_pb.d.ts.map +1 -1
  83. package/dist/gen/notifications/v1/notifications_pb.js +23 -5
  84. package/dist/gen/notifications/v1/notifications_pb.js.map +1 -1
  85. package/dist/gen/orders/v1/orders_pb.d.ts +105 -29
  86. package/dist/gen/orders/v1/orders_pb.d.ts.map +1 -1
  87. package/dist/gen/orders/v1/orders_pb.js +14 -2
  88. package/dist/gen/orders/v1/orders_pb.js.map +1 -1
  89. package/dist/gen/orders/v1/orders_read_pb.d.ts +50 -20
  90. package/dist/gen/orders/v1/orders_read_pb.d.ts.map +1 -1
  91. package/dist/gen/orders/v1/orders_read_pb.js +1 -1
  92. package/dist/gen/orders/v1/orders_read_pb.js.map +1 -1
  93. package/dist/gen/polyester/api/options_pb.d.ts +11 -2
  94. package/dist/gen/polyester/api/options_pb.d.ts.map +1 -1
  95. package/dist/gen/polyester/api/options_pb.js +13 -3
  96. package/dist/gen/polyester/api/options_pb.js.map +1 -1
  97. package/dist/gen/privatews/v1/private_ws_pb.d.ts +13 -3
  98. package/dist/gen/privatews/v1/private_ws_pb.d.ts.map +1 -1
  99. package/dist/gen/privatews/v1/private_ws_pb.js.map +1 -1
  100. package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.d.ts +126 -10
  101. package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.d.ts.map +1 -1
  102. package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.js +14 -6
  103. package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.js.map +1 -1
  104. package/dist/gen/swap/quickswap/v1/quickswap_explorer_pb.d.ts +665 -0
  105. package/dist/gen/swap/quickswap/v1/quickswap_explorer_pb.d.ts.map +1 -0
  106. package/dist/gen/swap/quickswap/v1/quickswap_explorer_pb.js +216 -0
  107. package/dist/gen/swap/quickswap/v1/quickswap_explorer_pb.js.map +1 -0
  108. package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts +166 -52
  109. package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts.map +1 -1
  110. package/dist/gen/swap/quickswap/v1/quickswap_pb.js +50 -12
  111. package/dist/gen/swap/quickswap/v1/quickswap_pb.js.map +1 -1
  112. package/dist/gen/system/v1/system_pb.d.ts +49 -2
  113. package/dist/gen/system/v1/system_pb.d.ts.map +1 -1
  114. package/dist/gen/system/v1/system_pb.js +18 -6
  115. package/dist/gen/system/v1/system_pb.js.map +1 -1
  116. package/dist/gen/transfer/v1/internal_transfer_pb.d.ts +150 -71
  117. package/dist/gen/transfer/v1/internal_transfer_pb.d.ts.map +1 -1
  118. package/dist/gen/transfer/v1/internal_transfer_pb.js +56 -34
  119. package/dist/gen/transfer/v1/internal_transfer_pb.js.map +1 -1
  120. package/dist/gen/triggers/v1/triggers_pb.d.ts +117 -16
  121. package/dist/gen/triggers/v1/triggers_pb.d.ts.map +1 -1
  122. package/dist/gen/triggers/v1/triggers_pb.js +45 -2
  123. package/dist/gen/triggers/v1/triggers_pb.js.map +1 -1
  124. package/dist/index.d.ts +13 -9
  125. package/dist/realtime/client.js +5 -1
  126. package/dist/realtime/client.js.map +1 -1
  127. package/dist/realtime/snapshot-then-stream.js +5 -3
  128. package/dist/realtime/snapshot-then-stream.js.map +1 -1
  129. package/dist/services/account-activity/account-activity.d.ts +22 -0
  130. package/dist/services/account-activity/account-activity.d.ts.map +1 -0
  131. package/dist/services/account-activity/account-activity.js +32 -0
  132. package/dist/services/account-activity/account-activity.js.map +1 -0
  133. package/dist/services/account-activity/account-activity.schemas.d.ts +78 -0
  134. package/dist/services/account-activity/account-activity.schemas.d.ts.map +1 -0
  135. package/dist/services/account-activity/account-activity.schemas.js +44 -0
  136. package/dist/services/account-activity/account-activity.schemas.js.map +1 -0
  137. package/dist/services/account-activity/account-activity.types.d.ts +2 -0
  138. package/dist/services/account-activity/service.d.ts +8 -0
  139. package/dist/services/account-activity/service.d.ts.map +1 -0
  140. package/dist/services/account-activity/service.js +9 -0
  141. package/dist/services/account-activity/service.js.map +1 -0
  142. package/dist/services/address-book/address-book.schemas.js +2 -2
  143. package/dist/services/api-keys/api-keys.schemas.js +2 -2
  144. package/dist/services/assistant/assistant-events.schemas.d.ts +81 -81
  145. package/dist/services/assistant/assistant.codecs.d.ts +7 -2
  146. package/dist/services/assistant/assistant.codecs.d.ts.map +1 -1
  147. package/dist/services/assistant/assistant.codecs.js +18 -2
  148. package/dist/services/assistant/assistant.codecs.js.map +1 -1
  149. package/dist/services/assistant/assistant.d.ts +29 -2
  150. package/dist/services/assistant/assistant.d.ts.map +1 -1
  151. package/dist/services/assistant/assistant.js +44 -2
  152. package/dist/services/assistant/assistant.js.map +1 -1
  153. package/dist/services/assistant/assistant.schemas.d.ts +111 -6
  154. package/dist/services/assistant/assistant.schemas.d.ts.map +1 -1
  155. package/dist/services/assistant/assistant.schemas.js +74 -6
  156. package/dist/services/assistant/assistant.schemas.js.map +1 -1
  157. package/dist/services/assistant/assistant.types.d.ts +3 -3
  158. package/dist/services/auto-withdraw/auto-withdraw.codecs.d.ts +3 -1
  159. package/dist/services/auto-withdraw/auto-withdraw.codecs.d.ts.map +1 -1
  160. package/dist/services/auto-withdraw/auto-withdraw.codecs.js.map +1 -1
  161. package/dist/services/auto-withdraw/auto-withdraw.schemas.d.ts +15 -13
  162. package/dist/services/auto-withdraw/auto-withdraw.schemas.d.ts.map +1 -1
  163. package/dist/services/auto-withdraw/auto-withdraw.schemas.js +1 -0
  164. package/dist/services/auto-withdraw/auto-withdraw.schemas.js.map +1 -1
  165. package/dist/services/balances/balances.d.ts +1 -13
  166. package/dist/services/balances/balances.d.ts.map +1 -1
  167. package/dist/services/balances/balances.js +1 -45
  168. package/dist/services/balances/balances.js.map +1 -1
  169. package/dist/services/balances/balances.schemas.d.ts +1 -67
  170. package/dist/services/balances/balances.schemas.d.ts.map +1 -1
  171. package/dist/services/balances/balances.schemas.js +1 -22
  172. package/dist/services/balances/balances.schemas.js.map +1 -1
  173. package/dist/services/balances/balances.types.d.ts +2 -2
  174. package/dist/services/candles/candles.schemas.d.ts +10 -10
  175. package/dist/services/changelog/changelog.schemas.d.ts +38 -38
  176. package/dist/services/checkpoints/checkpoints.schemas.d.ts +3 -3
  177. package/dist/services/dust-conversion/dust-conversion.schemas.d.ts +11 -11
  178. package/dist/services/dust-conversion/dust-conversion.schemas.d.ts.map +1 -1
  179. package/dist/services/dust-conversion/dust-conversion.schemas.js +1 -1
  180. package/dist/services/dust-conversion/dust-conversion.schemas.js.map +1 -1
  181. package/dist/services/heatmap/heatmap.schemas.d.ts +4 -4
  182. package/dist/services/internal-transfers/internal-transfers.codecs.d.ts +11 -6
  183. package/dist/services/internal-transfers/internal-transfers.codecs.d.ts.map +1 -1
  184. package/dist/services/internal-transfers/internal-transfers.codecs.js +6 -6
  185. package/dist/services/internal-transfers/internal-transfers.codecs.js.map +1 -1
  186. package/dist/services/internal-transfers/internal-transfers.d.ts +17 -10
  187. package/dist/services/internal-transfers/internal-transfers.d.ts.map +1 -1
  188. package/dist/services/internal-transfers/internal-transfers.js +21 -10
  189. package/dist/services/internal-transfers/internal-transfers.js.map +1 -1
  190. package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +43 -31
  191. package/dist/services/internal-transfers/internal-transfers.schemas.d.ts.map +1 -1
  192. package/dist/services/internal-transfers/internal-transfers.schemas.js +23 -12
  193. package/dist/services/internal-transfers/internal-transfers.schemas.js.map +1 -1
  194. package/dist/services/internal-transfers/internal-transfers.types.d.ts +2 -2
  195. package/dist/services/lifecycle/lifecycle.d.ts +1 -1
  196. package/dist/services/lifecycle/lifecycle.js +2 -3
  197. package/dist/services/lifecycle/lifecycle.js.map +1 -1
  198. package/dist/services/lifecycle/lifecycle.schemas.d.ts +40 -40
  199. package/dist/services/market-data/market-data.codecs.d.ts +8 -0
  200. package/dist/services/market-data/market-data.codecs.d.ts.map +1 -0
  201. package/dist/services/market-data/market-data.codecs.js +7 -1
  202. package/dist/services/market-data/market-data.codecs.js.map +1 -1
  203. package/dist/services/market-data/market-data.d.ts +3 -2
  204. package/dist/services/market-data/market-data.d.ts.map +1 -1
  205. package/dist/services/market-data/market-data.js +3 -2
  206. package/dist/services/market-data/market-data.js.map +1 -1
  207. package/dist/services/market-data/market-data.schemas.d.ts +332 -4
  208. package/dist/services/market-data/market-data.schemas.d.ts.map +1 -1
  209. package/dist/services/market-data/market-data.schemas.js +56 -8
  210. package/dist/services/market-data/market-data.schemas.js.map +1 -1
  211. package/dist/services/market-data/market-data.types.d.ts +3 -2
  212. package/dist/services/notifications/notifications.codecs.d.ts +1 -1
  213. package/dist/services/notifications/notifications.codecs.d.ts.map +1 -1
  214. package/dist/services/notifications/notifications.codecs.js +2 -1
  215. package/dist/services/notifications/notifications.codecs.js.map +1 -1
  216. package/dist/services/notifications/notifications.d.ts +4 -2
  217. package/dist/services/notifications/notifications.d.ts.map +1 -1
  218. package/dist/services/notifications/notifications.js +4 -2
  219. package/dist/services/notifications/notifications.js.map +1 -1
  220. package/dist/services/notifications/notifications.schemas.d.ts +63 -7
  221. package/dist/services/notifications/notifications.schemas.d.ts.map +1 -1
  222. package/dist/services/notifications/notifications.schemas.js +5 -0
  223. package/dist/services/notifications/notifications.schemas.js.map +1 -1
  224. package/dist/services/orderbook/orderbook.js +3 -2
  225. package/dist/services/orderbook/orderbook.js.map +1 -1
  226. package/dist/services/orders/order-enums.codecs.d.ts +2 -0
  227. package/dist/services/orders/order-errors.schemas.d.ts +50 -5
  228. package/dist/services/orders/order-errors.schemas.d.ts.map +1 -1
  229. package/dist/services/orders/order-errors.schemas.js +13 -3
  230. package/dist/services/orders/order-errors.schemas.js.map +1 -1
  231. package/dist/services/orders/orders-batch.schemas.d.ts +310 -70
  232. package/dist/services/orders/orders-batch.schemas.d.ts.map +1 -1
  233. package/dist/services/orders/orders-input.schemas.d.ts +58 -11
  234. package/dist/services/orders/orders-input.schemas.d.ts.map +1 -1
  235. package/dist/services/orders/orders-input.schemas.js +1 -1
  236. package/dist/services/orders/orders-output.schemas.d.ts +13 -13
  237. package/dist/services/policies/api-key-policies/api-key-policies.schemas.d.ts +15 -15
  238. package/dist/services/policies/api-key-policies/api-key-policies.schemas.js +1 -1
  239. package/dist/services/policies/shared.codecs.js +12 -6
  240. package/dist/services/policies/shared.codecs.js.map +1 -1
  241. package/dist/services/policies/shared.d.ts +1 -1
  242. package/dist/services/policies/shared.js +1 -1
  243. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts +9 -9
  244. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js +4 -30
  245. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js.map +1 -1
  246. package/dist/services/price-alerts/price-alerts.d.ts +5 -2
  247. package/dist/services/price-alerts/price-alerts.d.ts.map +1 -1
  248. package/dist/services/price-alerts/price-alerts.js +5 -2
  249. package/dist/services/price-alerts/price-alerts.js.map +1 -1
  250. package/dist/services/price-alerts/price-alerts.schemas.js +1 -1
  251. package/dist/services/rewards/rewards.schemas.d.ts +4 -4
  252. package/dist/services/social-verification/social-verification.schemas.d.ts +9 -0
  253. package/dist/services/social-verification/social-verification.schemas.d.ts.map +1 -1
  254. package/dist/services/social-verification/social-verification.schemas.js +9 -2
  255. package/dist/services/social-verification/social-verification.schemas.js.map +1 -1
  256. package/dist/services/statement-exports/statement-exports.codecs.d.ts +3 -2
  257. package/dist/services/statement-exports/statement-exports.codecs.d.ts.map +1 -1
  258. package/dist/services/statement-exports/statement-exports.codecs.js +2 -1
  259. package/dist/services/statement-exports/statement-exports.codecs.js.map +1 -1
  260. package/dist/services/statement-exports/statement-exports.d.ts +25 -10
  261. package/dist/services/statement-exports/statement-exports.d.ts.map +1 -1
  262. package/dist/services/statement-exports/statement-exports.js +33 -10
  263. package/dist/services/statement-exports/statement-exports.js.map +1 -1
  264. package/dist/services/statement-exports/statement-exports.schemas.d.ts +38 -10
  265. package/dist/services/statement-exports/statement-exports.schemas.d.ts.map +1 -1
  266. package/dist/services/statement-exports/statement-exports.schemas.js +25 -6
  267. package/dist/services/statement-exports/statement-exports.schemas.js.map +1 -1
  268. package/dist/services/statement-exports/statement-exports.types.d.ts +2 -2
  269. package/dist/services/subaccounts/subaccounts.codecs.js +112 -38
  270. package/dist/services/subaccounts/subaccounts.codecs.js.map +1 -1
  271. package/dist/services/subaccounts/subaccounts.d.ts +2 -1
  272. package/dist/services/subaccounts/subaccounts.d.ts.map +1 -1
  273. package/dist/services/subaccounts/subaccounts.js +3 -3
  274. package/dist/services/subaccounts/subaccounts.js.map +1 -1
  275. package/dist/services/subaccounts/subaccounts.schemas.d.ts +12 -5
  276. package/dist/services/subaccounts/subaccounts.schemas.d.ts.map +1 -1
  277. package/dist/services/subaccounts/subaccounts.schemas.js +10 -3
  278. package/dist/services/subaccounts/subaccounts.schemas.js.map +1 -1
  279. package/dist/services/system/system.d.ts +12 -1
  280. package/dist/services/system/system.d.ts.map +1 -1
  281. package/dist/services/system/system.js +5 -0
  282. package/dist/services/system/system.js.map +1 -1
  283. package/dist/services/system/system.schemas.d.ts +13 -13
  284. package/dist/services/system/system.types.d.ts +2 -2
  285. package/dist/services/trades/trades.schemas.d.ts +2 -2
  286. package/dist/services/trading-withdraws/trading-withdraws.codecs.d.ts +8 -0
  287. package/dist/services/trading-withdraws/trading-withdraws.codecs.d.ts.map +1 -0
  288. package/dist/services/trading-withdraws/trading-withdraws.codecs.js +7 -1
  289. package/dist/services/trading-withdraws/trading-withdraws.codecs.js.map +1 -1
  290. package/dist/services/trading-withdraws/trading-withdraws.d.ts +2 -1
  291. package/dist/services/trading-withdraws/trading-withdraws.d.ts.map +1 -1
  292. package/dist/services/trading-withdraws/trading-withdraws.js +2 -1
  293. package/dist/services/trading-withdraws/trading-withdraws.js.map +1 -1
  294. package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts +15 -0
  295. package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts.map +1 -1
  296. package/dist/services/trading-withdraws/trading-withdraws.schemas.js +16 -2
  297. package/dist/services/trading-withdraws/trading-withdraws.schemas.js.map +1 -1
  298. package/dist/services/trading-withdraws/trading-withdraws.types.d.ts +2 -1
  299. package/dist/services/transfers/transfers.schemas.d.ts +4 -4
  300. package/dist/services/triggers/trigger-child-order.schemas.js +1 -1
  301. package/dist/services/triggers/trigger-child-order.schemas.js.map +1 -1
  302. package/dist/services/triggers/trigger-input.schemas.d.ts +10 -10
  303. package/dist/services/triggers/triggers-output.schemas.d.ts +170 -52
  304. package/dist/services/triggers/triggers-output.schemas.d.ts.map +1 -1
  305. package/dist/services/triggers/triggers-output.schemas.js +13 -3
  306. package/dist/services/triggers/triggers-output.schemas.js.map +1 -1
  307. package/dist/services/triggers/triggers.codecs.d.ts +10 -0
  308. package/dist/services/triggers/triggers.codecs.d.ts.map +1 -0
  309. package/dist/services/triggers/triggers.codecs.js +7 -1
  310. package/dist/services/triggers/triggers.codecs.js.map +1 -1
  311. package/dist/services/triggers/triggers.d.ts +2 -2
  312. package/dist/services/triggers/triggers.js +2 -2
  313. package/dist/services/triggers/triggers.js.map +1 -1
  314. package/dist/services/zipper/zipper.d.ts.map +1 -1
  315. package/dist/services/zipper/zipper.js +13 -7
  316. package/dist/services/zipper/zipper.js.map +1 -1
  317. package/dist/services/zipper/zipper.schemas.d.ts +7 -2
  318. package/dist/services/zipper/zipper.schemas.d.ts.map +1 -1
  319. package/dist/services/zipper/zipper.schemas.js +29 -9
  320. package/dist/services/zipper/zipper.schemas.js.map +1 -1
  321. package/dist/services/zipper/zipper.types.d.ts +2 -2
  322. package/dist/shared/catalog-config.d.ts +16 -2
  323. package/dist/shared/catalog-config.d.ts.map +1 -1
  324. package/dist/shared/catalog-config.js.map +1 -1
  325. package/dist/shared/connect-error-mapping.d.ts.map +1 -1
  326. package/dist/shared/connect-error-mapping.js +27 -4
  327. package/dist/shared/connect-error-mapping.js.map +1 -1
  328. package/dist/shared/error-detail.d.ts +10 -0
  329. package/dist/shared/error-detail.d.ts.map +1 -1
  330. package/dist/shared/error-detail.js.map +1 -1
  331. package/dist/shared/error-details/auth.js +6 -0
  332. package/dist/shared/error-details/auth.js.map +1 -1
  333. package/dist/shared/errors.d.ts +5 -1
  334. package/dist/shared/errors.d.ts.map +1 -1
  335. package/dist/shared/errors.js +3 -0
  336. package/dist/shared/errors.js.map +1 -1
  337. package/dist/shared/ledger-codes.d.ts +3 -1
  338. package/dist/shared/ledger-codes.d.ts.map +1 -1
  339. package/dist/shared/ledger-codes.js +6 -3
  340. package/dist/shared/ledger-codes.js.map +1 -1
  341. package/dist/shared/rate-limit.schemas.d.ts +1 -1
  342. package/dist/wired-services.d.ts.map +1 -1
  343. package/dist/wired-services.js +3 -1
  344. package/dist/wired-services.js.map +1 -1
  345. package/package.json +1 -1
@@ -3,8 +3,10 @@ import { PolyesterRequestOptions } from "../../shared/request-options.js";
3
3
  import { AccountNotification, GetNotificationInput, ListNotificationsInput, ListNotificationsResult, MarkAllNotificationsReadInput, MarkNotificationsInput, NotificationCounts } from "./notifications.schemas.js";
4
4
  //#region src/services/notifications/notifications.d.ts
5
5
  /**
6
- * Reads and marks the caller's notification center. Available on devnet only. Session JWT only:
7
- * API keys are refused. An unknown notification ID, including another account's, throws
6
+ * Reads and marks the caller's notification center: the main account's notifications. Available
7
+ * on devnet only. `list`, `get` and `getCounts` also take a main-account API key whose policy
8
+ * grants `read-notifications`; a sub-account key is refused (`PermissionError`). Marking takes a
9
+ * session only. An unknown notification ID, including another account's, throws
8
10
  * `ResourceNotFoundError` (`NOTIFICATION_NOT_FOUND`); a retryable `ServiceUnavailableError`
9
11
  * means retry the same request.
10
12
  */
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.d.ts","names":[],"sources":["../../../src/services/notifications/notifications.ts"],"mappings":";;;;;;;;;;cAgCa;;EAGG,YAAA,YAAY;;EAKlB,KACF,QAAO,wBACP,UAAU,0BACX,QAAQ;;EAaL,IACF,OAAO,sBACP,UAAU,0BACX,QAAQ;;EAWL,UAAU,UAAU,0BAA0B,QAAQ;;;;;EAYtD,SACF,OAAO,wBACP,UAAU,0BACX;IAAU;;;;;;EAaP,WACF,OAAO,wBACP,UAAU,0BACX;IAAU;;;EAUP,YACF,QAAO,+BACP,UAAU,0BACX;IAAU"}
1
+ {"version":3,"file":"notifications.d.ts","names":[],"sources":["../../../src/services/notifications/notifications.ts"],"mappings":";;;;;;;;;;;;cAkCa;;EAGG,YAAA,YAAY;;EAKlB,KACF,QAAO,wBACP,UAAU,0BACX,QAAQ;;EAaL,IACF,OAAO,sBACP,UAAU,0BACX,QAAQ;;EAWL,UAAU,UAAU,0BAA0B,QAAQ;;;;;EAYtD,SACF,OAAO,wBACP,UAAU,0BACX;IAAU;;;;;;EAaP,WACF,OAAO,wBACP,UAAU,0BACX;IAAU;;;EAUP,YACF,QAAO,+BACP,UAAU,0BACX;IAAU"}
@@ -7,8 +7,10 @@ import { GetNotificationInputSchema, ListNotificationsInputSchema, MarkAllNotifi
7
7
  import { createClient } from "@connectrpc/connect";
8
8
  //#region src/services/notifications/notifications.ts
9
9
  /**
10
- * Reads and marks the caller's notification center. Available on devnet only. Session JWT only:
11
- * API keys are refused. An unknown notification ID, including another account's, throws
10
+ * Reads and marks the caller's notification center: the main account's notifications. Available
11
+ * on devnet only. `list`, `get` and `getCounts` also take a main-account API key whose policy
12
+ * grants `read-notifications`; a sub-account key is refused (`PermissionError`). Marking takes a
13
+ * session only. An unknown notification ID, including another account's, throws
12
14
  * `ResourceNotFoundError` (`NOTIFICATION_NOT_FOUND`); a retryable `ServiceUnavailableError`
13
15
  * means retry the same request.
14
16
  */
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.js","names":["#client","Proto.NotificationService"],"sources":["../../../src/services/notifications/notifications.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/notifications/v1/notifications_pb.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport { InternalServerError } from \"../../shared/errors.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport { parse } from \"../../shared/validation.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport {\n formatNotification,\n formatNotificationCounts,\n GetNotificationInputSchema,\n ListNotificationsInputSchema,\n MarkAllNotificationsReadInputSchema,\n MarkNotificationsInputSchema,\n type AccountNotification,\n type GetNotificationInput,\n type ListNotificationsInput,\n type ListNotificationsResult,\n type MarkAllNotificationsReadInput,\n type MarkNotificationsInput,\n type NotificationCounts,\n} from \"./notifications.schemas.js\";\n\n/**\n * Reads and marks the caller's notification center. Available on devnet only. Session JWT only:\n * API keys are refused. An unknown notification ID, including another account's, throws\n * `ResourceNotFoundError` (`NOTIFICATION_NOT_FOUND`); a retryable `ServiceUnavailableError`\n * means retry the same request.\n */\nexport class NotificationsService {\n #client: Client<typeof Proto.NotificationService>;\n\n constructor(transports: AuthApiTransports) {\n this.#client = createClient(Proto.NotificationService, transports.authApi);\n }\n\n /** Lists the caller's notifications, newest first. */\n async list(\n input: ListNotificationsInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<ListNotificationsResult> {\n const request = parse(ListNotificationsInputSchema, input);\n const response = await this.#client.listNotifications(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return {\n notifications: response.notifications.map(formatNotification),\n nextPageToken: response.nextPageToken,\n };\n }\n\n /** Reads one notification. */\n async get(\n input: GetNotificationInput,\n options?: PolyesterRequestOptions,\n ): Promise<AccountNotification> {\n const request = parse(GetNotificationInputSchema, input);\n const { notification } = await this.#client.getNotification(\n request,\n toConnectCallOptions(options),\n );\n if (!notification) throw new InternalServerError(\"Response has no notification.\");\n return formatNotification(notification);\n }\n\n /** Counts the caller's notifications and unread notifications, in total and by type. */\n async getCounts(options?: PolyesterRequestOptions): Promise<NotificationCounts> {\n const response = await this.#client.getNotificationCounts(\n {},\n toConnectCallOptions(options),\n );\n return formatNotificationCounts(response);\n }\n\n /**\n * Marks notifications read. All or nothing: one unknown ID throws `ResourceNotFoundError`\n * and marks none. `changed` leaves out notifications already read.\n */\n async markRead(\n input: MarkNotificationsInput,\n options?: PolyesterRequestOptions,\n ): Promise<{ changed: number }> {\n const request = parse(MarkNotificationsInputSchema, input);\n const response = await this.#client.markNotificationsRead(\n request,\n toConnectCallOptions(options),\n );\n return { changed: response.changed };\n }\n\n /**\n * Marks notifications unread. All or nothing: one unknown ID throws `ResourceNotFoundError`\n * and marks none. `changed` leaves out notifications already unread.\n */\n async markUnread(\n input: MarkNotificationsInput,\n options?: PolyesterRequestOptions,\n ): Promise<{ changed: number }> {\n const request = parse(MarkNotificationsInputSchema, input);\n const response = await this.#client.markNotificationsUnread(\n request,\n toConnectCallOptions(options),\n );\n return { changed: response.changed };\n }\n\n /** Marks every unread notification read, within the given categories and up to the given one. */\n async markAllRead(\n input: MarkAllNotificationsReadInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<{ changed: number }> {\n const request = parse(MarkAllNotificationsReadInputSchema, input);\n const response = await this.#client.markAllNotificationsRead(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return { changed: Number(response.changed) };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAgCA,IAAa,uBAAb,MAAkC;CAC9B;CAEA,YAAY,YAA+B;EACvC,KAAKA,UAAU,aAAaC,qBAA2B,WAAW,OAAO;CAC7E;;CAGA,MAAM,KACF,QAAgC,CAAC,GACjC,SACgC;EAChC,MAAM,UAAU,MAAM,8BAA8B,KAAK;EACzD,MAAM,WAAW,MAAM,KAAKD,QAAQ,kBAChC,gBAAgB,OAAO,GACvB,qBAAqB,OAAO,CAChC;EACA,OAAO;GACH,eAAe,SAAS,cAAc,IAAI,kBAAkB;GAC5D,eAAe,SAAS;EAC5B;CACJ;;CAGA,MAAM,IACF,OACA,SAC4B;EAC5B,MAAM,UAAU,MAAM,4BAA4B,KAAK;EACvD,MAAM,EAAE,iBAAiB,MAAM,KAAKA,QAAQ,gBACxC,SACA,qBAAqB,OAAO,CAChC;EACA,IAAI,CAAC,cAAc,MAAM,IAAI,oBAAoB,+BAA+B;EAChF,OAAO,mBAAmB,YAAY;CAC1C;;CAGA,MAAM,UAAU,SAAgE;EAC5E,MAAM,WAAW,MAAM,KAAKA,QAAQ,sBAChC,CAAC,GACD,qBAAqB,OAAO,CAChC;EACA,OAAO,yBAAyB,QAAQ;CAC5C;;;;;CAMA,MAAM,SACF,OACA,SAC4B;EAC5B,MAAM,UAAU,MAAM,8BAA8B,KAAK;EAKzD,OAAO,EAAE,UAAS,MAJK,KAAKA,QAAQ,sBAChC,SACA,qBAAqB,OAAO,CAChC,EAAA,CAC2B,QAAQ;CACvC;;;;;CAMA,MAAM,WACF,OACA,SAC4B;EAC5B,MAAM,UAAU,MAAM,8BAA8B,KAAK;EAKzD,OAAO,EAAE,UAAS,MAJK,KAAKA,QAAQ,wBAChC,SACA,qBAAqB,OAAO,CAChC,EAAA,CAC2B,QAAQ;CACvC;;CAGA,MAAM,YACF,QAAuC,CAAC,GACxC,SAC4B;EAC5B,MAAM,UAAU,MAAM,qCAAqC,KAAK;EAChE,MAAM,WAAW,MAAM,KAAKA,QAAQ,yBAChC,gBAAgB,OAAO,GACvB,qBAAqB,OAAO,CAChC;EACA,OAAO,EAAE,SAAS,OAAO,SAAS,OAAO,EAAE;CAC/C;AACJ"}
1
+ {"version":3,"file":"notifications.js","names":["#client","Proto.NotificationService"],"sources":["../../../src/services/notifications/notifications.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/notifications/v1/notifications_pb.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport { InternalServerError } from \"../../shared/errors.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport { parse } from \"../../shared/validation.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport {\n formatNotification,\n formatNotificationCounts,\n GetNotificationInputSchema,\n ListNotificationsInputSchema,\n MarkAllNotificationsReadInputSchema,\n MarkNotificationsInputSchema,\n type AccountNotification,\n type GetNotificationInput,\n type ListNotificationsInput,\n type ListNotificationsResult,\n type MarkAllNotificationsReadInput,\n type MarkNotificationsInput,\n type NotificationCounts,\n} from \"./notifications.schemas.js\";\n\n/**\n * Reads and marks the caller's notification center: the main account's notifications. Available\n * on devnet only. `list`, `get` and `getCounts` also take a main-account API key whose policy\n * grants `read-notifications`; a sub-account key is refused (`PermissionError`). Marking takes a\n * session only. An unknown notification ID, including another account's, throws\n * `ResourceNotFoundError` (`NOTIFICATION_NOT_FOUND`); a retryable `ServiceUnavailableError`\n * means retry the same request.\n */\nexport class NotificationsService {\n #client: Client<typeof Proto.NotificationService>;\n\n constructor(transports: AuthApiTransports) {\n this.#client = createClient(Proto.NotificationService, transports.authApi);\n }\n\n /** Lists the caller's notifications, newest first. */\n async list(\n input: ListNotificationsInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<ListNotificationsResult> {\n const request = parse(ListNotificationsInputSchema, input);\n const response = await this.#client.listNotifications(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return {\n notifications: response.notifications.map(formatNotification),\n nextPageToken: response.nextPageToken,\n };\n }\n\n /** Reads one notification. */\n async get(\n input: GetNotificationInput,\n options?: PolyesterRequestOptions,\n ): Promise<AccountNotification> {\n const request = parse(GetNotificationInputSchema, input);\n const { notification } = await this.#client.getNotification(\n request,\n toConnectCallOptions(options),\n );\n if (!notification) throw new InternalServerError(\"Response has no notification.\");\n return formatNotification(notification);\n }\n\n /** Counts the caller's notifications and unread notifications, in total and by type. */\n async getCounts(options?: PolyesterRequestOptions): Promise<NotificationCounts> {\n const response = await this.#client.getNotificationCounts(\n {},\n toConnectCallOptions(options),\n );\n return formatNotificationCounts(response);\n }\n\n /**\n * Marks notifications read. All or nothing: one unknown ID throws `ResourceNotFoundError`\n * and marks none. `changed` leaves out notifications already read.\n */\n async markRead(\n input: MarkNotificationsInput,\n options?: PolyesterRequestOptions,\n ): Promise<{ changed: number }> {\n const request = parse(MarkNotificationsInputSchema, input);\n const response = await this.#client.markNotificationsRead(\n request,\n toConnectCallOptions(options),\n );\n return { changed: response.changed };\n }\n\n /**\n * Marks notifications unread. All or nothing: one unknown ID throws `ResourceNotFoundError`\n * and marks none. `changed` leaves out notifications already unread.\n */\n async markUnread(\n input: MarkNotificationsInput,\n options?: PolyesterRequestOptions,\n ): Promise<{ changed: number }> {\n const request = parse(MarkNotificationsInputSchema, input);\n const response = await this.#client.markNotificationsUnread(\n request,\n toConnectCallOptions(options),\n );\n return { changed: response.changed };\n }\n\n /** Marks every unread notification read, within the given categories and up to the given one. */\n async markAllRead(\n input: MarkAllNotificationsReadInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<{ changed: number }> {\n const request = parse(MarkAllNotificationsReadInputSchema, input);\n const response = await this.#client.markAllNotificationsRead(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return { changed: Number(response.changed) };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkCA,IAAa,uBAAb,MAAkC;CAC9B;CAEA,YAAY,YAA+B;EACvC,KAAKA,UAAU,aAAaC,qBAA2B,WAAW,OAAO;CAC7E;;CAGA,MAAM,KACF,QAAgC,CAAC,GACjC,SACgC;EAChC,MAAM,UAAU,MAAM,8BAA8B,KAAK;EACzD,MAAM,WAAW,MAAM,KAAKD,QAAQ,kBAChC,gBAAgB,OAAO,GACvB,qBAAqB,OAAO,CAChC;EACA,OAAO;GACH,eAAe,SAAS,cAAc,IAAI,kBAAkB;GAC5D,eAAe,SAAS;EAC5B;CACJ;;CAGA,MAAM,IACF,OACA,SAC4B;EAC5B,MAAM,UAAU,MAAM,4BAA4B,KAAK;EACvD,MAAM,EAAE,iBAAiB,MAAM,KAAKA,QAAQ,gBACxC,SACA,qBAAqB,OAAO,CAChC;EACA,IAAI,CAAC,cAAc,MAAM,IAAI,oBAAoB,+BAA+B;EAChF,OAAO,mBAAmB,YAAY;CAC1C;;CAGA,MAAM,UAAU,SAAgE;EAC5E,MAAM,WAAW,MAAM,KAAKA,QAAQ,sBAChC,CAAC,GACD,qBAAqB,OAAO,CAChC;EACA,OAAO,yBAAyB,QAAQ;CAC5C;;;;;CAMA,MAAM,SACF,OACA,SAC4B;EAC5B,MAAM,UAAU,MAAM,8BAA8B,KAAK;EAKzD,OAAO,EAAE,UAAS,MAJK,KAAKA,QAAQ,sBAChC,SACA,qBAAqB,OAAO,CAChC,EAAA,CAC2B,QAAQ;CACvC;;;;;CAMA,MAAM,WACF,OACA,SAC4B;EAC5B,MAAM,UAAU,MAAM,8BAA8B,KAAK;EAKzD,OAAO,EAAE,UAAS,MAJK,KAAKA,QAAQ,wBAChC,SACA,qBAAqB,OAAO,CAChC,EAAA,CAC2B,QAAQ;CACvC;;CAGA,MAAM,YACF,QAAuC,CAAC,GACxC,SAC4B;EAC5B,MAAM,UAAU,MAAM,qCAAqC,KAAK;EAChE,MAAM,WAAW,MAAM,KAAKA,QAAQ,yBAChC,gBAAgB,OAAO,GACvB,qBAAqB,OAAO,CAChC;EACA,OAAO,EAAE,SAAS,OAAO,SAAS,OAAO,EAAE;CAC/C;AACJ"}
@@ -2,7 +2,7 @@ import { GetNotificationCountsResponse, Notification, NotificationCategory, Read
2
2
  import * as v from "valibot";
3
3
  //#region src/services/notifications/notifications.schemas.d.ts
4
4
  declare const ListNotificationsInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
5
- readonly categories: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["alerts", "security"], undefined>, undefined>, v.TransformAction<("alerts" | "security")[], (NotificationCategory.ALERTS | NotificationCategory.SECURITY)[]>]>, undefined>;
5
+ readonly categories: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["alerts", "security"], undefined>, undefined>, v.TransformAction<("security" | "alerts")[], (NotificationCategory.ALERTS | NotificationCategory.SECURITY)[]>]>, undefined>;
6
6
  /** Only read or only unread notifications; omit for both. */
7
7
  readonly readState: v.OptionalSchema<v.PicklistSchema<readonly ["unread", "read"], undefined>, undefined>;
8
8
  /** Epoch ms, inclusive. */
@@ -46,7 +46,7 @@ declare const MarkNotificationsInputSchema: v.StrictObjectSchema<{
46
46
  }, undefined>;
47
47
  type MarkNotificationsInput = v.InferInput<typeof MarkNotificationsInputSchema>;
48
48
  declare const MarkAllNotificationsReadInputSchema: v.StrictObjectSchema<{
49
- readonly categories: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["alerts", "security"], undefined>, undefined>, v.TransformAction<("alerts" | "security")[], (NotificationCategory.ALERTS | NotificationCategory.SECURITY)[]>]>, undefined>;
49
+ readonly categories: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["alerts", "security"], undefined>, undefined>, v.TransformAction<("security" | "alerts")[], (NotificationCategory.ALERTS | NotificationCategory.SECURITY)[]>]>, undefined>;
50
50
  /**
51
51
  * Mark only this notification and older ones. Pass the newest one shown, so one that arrives
52
52
  * later stays unread; omit to mark every notification that exists when the call runs.
@@ -56,8 +56,8 @@ declare const MarkAllNotificationsReadInputSchema: v.StrictObjectSchema<{
56
56
  type MarkAllNotificationsReadInput = v.InferInput<typeof MarkAllNotificationsReadInputSchema>;
57
57
  declare function formatNotification(notification: Notification): {
58
58
  notificationId: string;
59
- type: "unspecified" | "price_alert" | "telegram_approval" | "broker_allowlist_change";
60
- category: "unspecified" | "alerts" | "security";
59
+ type: "unspecified" | "price_alert" | "telegram_approval" | "broker_allowlist_change" | "telegram_linked";
60
+ category: "unspecified" | "security" | "alerts";
61
61
  /** Plain-text title, the same for every notification of a type. */
62
62
  title: string;
63
63
  /** Plain-text summary; may span several lines. */
@@ -77,10 +77,13 @@ declare function formatNotification(notification: Notification): {
77
77
  /** Price that fired the alert, as a decimal string. */
78
78
  triggeredPrice: string;
79
79
  triggeredAt: number | null;
80
+ /** The approval's ID in `client.assistant`. */
80
81
  approvalId?: undefined;
81
82
  action?: undefined;
83
+ /** Trading account (subaccount) the action acted on. */
82
84
  accountId?: undefined;
83
85
  summary?: undefined;
86
+ /** Key parameters in display order, such as market, side and quantity. */
84
87
  parameters?: undefined;
85
88
  approvedAt?: undefined;
86
89
  broker?: undefined;
@@ -100,11 +103,12 @@ declare function formatNotification(notification: Notification): {
100
103
  * after it is listed.
101
104
  */
102
105
  requestedByAccountId?: undefined;
106
+ linkedAt?: undefined;
103
107
  } | {
104
108
  type: "telegram_approval";
105
109
  /** The approval's ID in `client.assistant`. */
106
110
  approvalId: string;
107
- action: "unspecified" | "swap" | "place_orders" | "place_order" | "modify_orders" | "cancel_order" | "cancel_all_orders" | "modify_trigger" | "pause_trigger" | "resume_trigger";
111
+ action: "unspecified" | "place_order" | "place_orders" | "modify_orders" | "cancel_order" | "cancel_all_orders" | "modify_trigger" | "pause_trigger" | "resume_trigger" | "swap";
108
112
  /** Trading account (subaccount) the action acted on. */
109
113
  accountId: string;
110
114
  summary: string;
@@ -119,6 +123,7 @@ declare function formatNotification(notification: Notification): {
119
123
  symbolId?: undefined;
120
124
  direction?: undefined;
121
125
  priceSource?: undefined;
126
+ /** Alert price, as a decimal string. */
122
127
  price?: undefined;
123
128
  /** Price that fired the alert, as a decimal string. */
124
129
  triggeredPrice?: undefined;
@@ -140,6 +145,7 @@ declare function formatNotification(notification: Notification): {
140
145
  * after it is listed.
141
146
  */
142
147
  requestedByAccountId?: undefined;
148
+ linkedAt?: undefined;
143
149
  } | {
144
150
  type: "broker_allowlist_change";
145
151
  broker: string;
@@ -165,15 +171,60 @@ declare function formatNotification(notification: Notification): {
165
171
  symbolId?: undefined;
166
172
  direction?: undefined;
167
173
  priceSource?: undefined;
174
+ /** Alert price, as a decimal string. */
168
175
  price?: undefined;
169
176
  /** Price that fired the alert, as a decimal string. */
170
177
  triggeredPrice?: undefined;
171
178
  triggeredAt?: undefined;
179
+ /** The approval's ID in `client.assistant`. */
172
180
  approvalId?: undefined;
181
+ /** Trading account (subaccount) the action acted on. */
173
182
  accountId?: undefined;
174
183
  summary?: undefined;
184
+ /** Key parameters in display order, such as market, side and quantity. */
175
185
  parameters?: undefined;
176
186
  approvedAt?: undefined;
187
+ linkedAt?: undefined;
188
+ } | {
189
+ /** A Telegram account was linked; if the caller did not link it, unlink it. */
190
+ type: "telegram_linked";
191
+ linkedAt: number | null;
192
+ /** The alert's ID in `client.priceAlerts`. */
193
+ alertId?: undefined;
194
+ symbolId?: undefined;
195
+ direction?: undefined;
196
+ priceSource?: undefined;
197
+ /** Alert price, as a decimal string. */
198
+ price?: undefined;
199
+ /** Price that fired the alert, as a decimal string. */
200
+ triggeredPrice?: undefined;
201
+ triggeredAt?: undefined;
202
+ /** The approval's ID in `client.assistant`. */
203
+ approvalId?: undefined;
204
+ action?: undefined;
205
+ /** Trading account (subaccount) the action acted on. */
206
+ accountId?: undefined;
207
+ summary?: undefined;
208
+ /** Key parameters in display order, such as market, side and quantity. */
209
+ parameters?: undefined;
210
+ approvedAt?: undefined;
211
+ broker?: undefined;
212
+ /** Sub-account ID of the broker vault. */
213
+ vaultAccountId?: undefined;
214
+ /** The change's ID; key the broker's vault allowlist view on it. */
215
+ changeId?: undefined;
216
+ event?: undefined;
217
+ /** Destination chain ID, as a decimal string. */
218
+ destinationChainId?: undefined;
219
+ destinationAddress?: undefined;
220
+ /** The requesting member's name for an added address; empty when none. */
221
+ label?: undefined;
222
+ /**
223
+ * Account ID of the member who requested the change. Show a `change_requested`
224
+ * the caller did not make prominently: an added address becomes payable 24 hours
225
+ * after it is listed.
226
+ */
227
+ requestedByAccountId?: undefined;
177
228
  } | {
178
229
  type: "unspecified";
179
230
  /** The alert's ID in `client.priceAlerts`. */
@@ -181,14 +232,18 @@ declare function formatNotification(notification: Notification): {
181
232
  symbolId?: undefined;
182
233
  direction?: undefined;
183
234
  priceSource?: undefined;
235
+ /** Alert price, as a decimal string. */
184
236
  price?: undefined;
185
237
  /** Price that fired the alert, as a decimal string. */
186
238
  triggeredPrice?: undefined;
187
239
  triggeredAt?: undefined;
240
+ /** The approval's ID in `client.assistant`. */
188
241
  approvalId?: undefined;
189
242
  action?: undefined;
243
+ /** Trading account (subaccount) the action acted on. */
190
244
  accountId?: undefined;
191
245
  summary?: undefined;
246
+ /** Key parameters in display order, such as market, side and quantity. */
192
247
  parameters?: undefined;
193
248
  approvedAt?: undefined;
194
249
  broker?: undefined;
@@ -208,6 +263,7 @@ declare function formatNotification(notification: Notification): {
208
263
  * after it is listed.
209
264
  */
210
265
  requestedByAccountId?: undefined;
266
+ linkedAt?: undefined;
211
267
  };
212
268
  };
213
269
  /**
@@ -226,8 +282,8 @@ declare function formatNotificationCounts(counts: GetNotificationCountsResponse)
226
282
  unread: number;
227
283
  /** Every type in ascending enum order, including types with no notification. */
228
284
  types: {
229
- type: "unspecified" | "price_alert" | "telegram_approval" | "broker_allowlist_change";
230
- category: "unspecified" | "alerts" | "security";
285
+ type: "unspecified" | "price_alert" | "telegram_approval" | "broker_allowlist_change" | "telegram_linked";
286
+ category: "unspecified" | "security" | "alerts";
231
287
  total: number;
232
288
  unread: number;
233
289
  }[];
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.schemas.d.ts","names":[],"sources":["../../../src/services/notifications/notifications.schemas.ts"],"mappings":";;;cA2Ca,8BAA4B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2B7B,yBAAyB,EAAE,kBAAkB;cAE5C,4BAA0B,EAAA;;;KAI3B,uBAAuB,EAAE,kBAAkB;cAE1C,8BAA4B,EAAA;;;;KAU7B,yBAAyB,EAAE,kBAAkB;cAE5C,qCAAmC,EAAA;;;;;;;;KASpC,gCAAgC,EAAE,kBACnC;iBA4EK,mBAAmB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAoBrC,sBAAsB,kBAAkB;KAExC,4BAA4B;;KAG5B;EACR,eAAe;EACf;;iBAGY,yBAAyB,QAAQ;;;;;;;;;;;;KAerC,qBAAqB,kBAAkB"}
1
+ {"version":3,"file":"notifications.schemas.d.ts","names":[],"sources":["../../../src/services/notifications/notifications.schemas.ts"],"mappings":";;;cA2Ca,8BAA4B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2B7B,yBAAyB,EAAE,kBAAkB;cAE5C,4BAA0B,EAAA;;;KAI3B,uBAAuB,EAAE,kBAAkB;cAE1C,8BAA4B,EAAA;;;;KAU7B,yBAAyB,EAAE,kBAAkB;cAE5C,qCAAmC,EAAA;;;;;;;;KASpC,gCAAgC,EAAE,kBACnC;iBAkFK,mBAAmB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAoBrC,sBAAsB,kBAAkB;KAExC,4BAA4B;;KAG5B;EACR,eAAe;EACf;;iBAGY,yBAAyB,QAAQ;;;;;;;;;;;;KAerC,qBAAqB,kBAAkB"}
@@ -103,6 +103,11 @@ function formatDetail(detail) {
103
103
  requestedByAccountId: formatId(notice.requestedByAccountId)
104
104
  };
105
105
  }
106
+ case "telegramLink": return {
107
+ /** A Telegram account was linked; if the caller did not link it, unlink it. */
108
+ type: "telegram_linked",
109
+ linkedAt: tsObjToMs(detail.value.linkedAt) ?? null
110
+ };
106
111
  default: return { type: "unspecified" };
107
112
  }
108
113
  }
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.schemas.js","names":[],"sources":["../../../src/services/notifications/notifications.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { PRICE_SCALE } from \"../../catalogs/readers.js\";\nimport type * as Proto from \"../../gen/notifications/v1/notifications_pb.js\";\nimport { scaledToDecimalOutput } from \"../../shared/decimal-surface.js\";\nimport { enumLabel } from \"../../shared/proto-enum-codec.js\";\nimport { idInputSchema, optionalIdInputSchema } from \"../../shared/schemas.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport { tsObjToMs } from \"../../utils/time.js\";\nimport { msToTimestamp } from \"../../utils/timestamp.js\";\nimport {\n PriceAlertDirectionCodec,\n PriceAlertPriceSourceCodec,\n} from \"../price-alerts/price-alerts.codecs.js\";\nimport {\n BrokerAllowlistActionCodec,\n BrokerAllowlistEventCodec,\n NOTIFICATION_CATEGORY_VALUES,\n NOTIFICATION_READ_STATE_VALUES,\n NotificationCategoryCodec,\n NotificationReadStateCodec,\n NotificationTypeCodec,\n TelegramApprovalActionCodec,\n} from \"./notifications.codecs.js\";\n\nconst NotificationIdInputSchema = idInputSchema(\"notificationId\");\n\n/** Omit or pass empty for every category. */\nconst CategoriesInputSchema = v.optional(\n v.pipe(\n v.array(v.picklist(NOTIFICATION_CATEGORY_VALUES)),\n v.transform((categories) =>\n categories.map((category) => NotificationCategoryCodec.inputToProto[category]),\n ),\n ),\n);\n\nconst TimestampMsInputSchema = v.pipe(\n v.number(),\n v.integer(),\n v.minValue(0),\n v.maxValue(Number.MAX_SAFE_INTEGER),\n);\n\nexport const ListNotificationsInputSchema = v.pipe(\n v.strictObject({\n categories: CategoriesInputSchema,\n /** Only read or only unread notifications; omit for both. */\n readState: v.optional(v.picklist(NOTIFICATION_READ_STATE_VALUES)),\n /** Epoch ms, inclusive. */\n startTime: v.optional(TimestampMsInputSchema),\n /** Epoch ms, exclusive; after `startTime` when both are set. */\n endTime: v.optional(TimestampMsInputSchema),\n /** Page size: default 25, at most 100. */\n limit: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(100))),\n /** Previous `nextPageToken`; reuse only with the same filters. */\n pageToken: v.optional(v.pipe(v.string(), v.trim())),\n }),\n v.check(\n ({ startTime, endTime }) =>\n startTime === undefined || endTime === undefined || endTime > startTime,\n \"endTime: must be after startTime\",\n ),\n v.transform(({ readState, startTime, endTime, ...input }) => ({\n ...input,\n readState: readState && NotificationReadStateCodec.inputToProto[readState],\n startTime: startTime === undefined ? undefined : msToTimestamp(startTime),\n endTime: endTime === undefined ? undefined : msToTimestamp(endTime),\n })),\n);\n\nexport type ListNotificationsInput = v.InferInput<typeof ListNotificationsInputSchema>;\n\nexport const GetNotificationInputSchema = v.strictObject({\n notificationId: NotificationIdInputSchema,\n});\n\nexport type GetNotificationInput = v.InferInput<typeof GetNotificationInputSchema>;\n\nexport const MarkNotificationsInputSchema = v.strictObject({\n /** One to 100 distinct notification IDs. */\n notificationIds: v.pipe(\n v.array(NotificationIdInputSchema),\n v.minLength(1, \"At least one notification ID is required.\"),\n v.maxLength(100, \"At most 100 notification IDs are allowed.\"),\n v.check((ids) => new Set(ids).size === ids.length, \"Notification IDs must be distinct.\"),\n ),\n});\n\nexport type MarkNotificationsInput = v.InferInput<typeof MarkNotificationsInputSchema>;\n\nexport const MarkAllNotificationsReadInputSchema = v.strictObject({\n categories: CategoriesInputSchema,\n /**\n * Mark only this notification and older ones. Pass the newest one shown, so one that arrives\n * later stays unread; omit to mark every notification that exists when the call runs.\n */\n throughNotificationId: optionalIdInputSchema(\"throughNotificationId\"),\n});\n\nexport type MarkAllNotificationsReadInput = v.InferInput<\n typeof MarkAllNotificationsReadInputSchema\n>;\n\n/*\n * Outputs are formatted straight from the decoded messages, like the assistant's run events.\n * The `detail` oneof becomes a `type`-tagged union; a case this build does not know becomes\n * `{ type: \"unspecified\" }`, and the notification's `title` and `text` describe it.\n */\n\nconst price = (ticks: bigint) => scaledToDecimalOutput(ticks, PRICE_SCALE);\n\nfunction formatDetail(detail: Proto.Notification[\"detail\"]) {\n switch (detail.case) {\n case \"priceAlert\": {\n const notice = detail.value;\n return {\n type: \"price_alert\" as const,\n /** The alert's ID in `client.priceAlerts`. */\n alertId: formatId(notice.alertId),\n symbolId: notice.symbolId,\n direction: enumLabel(PriceAlertDirectionCodec.protoToOutput, notice.direction),\n priceSource: enumLabel(\n PriceAlertPriceSourceCodec.protoToOutput,\n notice.priceSource,\n ),\n /** Alert price, as a decimal string. */\n price: price(notice.priceTicks),\n /** Price that fired the alert, as a decimal string. */\n triggeredPrice: price(notice.triggeredPriceTicks),\n triggeredAt: tsObjToMs(notice.triggeredAt) ?? null,\n };\n }\n case \"telegramApproval\": {\n const notice = detail.value;\n return {\n type: \"telegram_approval\" as const,\n /** The approval's ID in `client.assistant`. */\n approvalId: formatId(notice.approvalId),\n action: enumLabel(TelegramApprovalActionCodec.protoToOutput, notice.action),\n /** Trading account (subaccount) the action acted on. */\n accountId: formatId(notice.accountId),\n summary: notice.summary,\n /** Key parameters in display order, such as market, side and quantity. */\n parameters: notice.parameters.map(({ label, value }) => ({ label, value })),\n approvedAt: tsObjToMs(notice.approvedAt) ?? null,\n };\n }\n case \"brokerAllowlist\": {\n const notice = detail.value;\n return {\n type: \"broker_allowlist_change\" as const,\n broker: notice.broker,\n /** Sub-account ID of the broker vault. */\n vaultAccountId: formatId(notice.vaultAccountId),\n /** The change's ID; key the broker's vault allowlist view on it. */\n changeId: formatId(notice.changeId),\n event: enumLabel(BrokerAllowlistEventCodec.protoToOutput, notice.event),\n action: enumLabel(BrokerAllowlistActionCodec.protoToOutput, notice.action),\n /** Destination chain ID, as a decimal string. */\n destinationChainId: notice.destinationChainId.toString(),\n destinationAddress: notice.destinationAddress,\n /** The requesting member's name for an added address; empty when none. */\n label: notice.label,\n /**\n * Account ID of the member who requested the change. Show a `change_requested`\n * the caller did not make prominently: an added address becomes payable 24 hours\n * after it is listed.\n */\n requestedByAccountId: formatId(notice.requestedByAccountId),\n };\n }\n default:\n return { type: \"unspecified\" as const };\n }\n}\n\nexport function formatNotification(notification: Proto.Notification) {\n return {\n notificationId: formatId(notification.notificationId),\n type: enumLabel(NotificationTypeCodec.protoToOutput, notification.type),\n category: enumLabel(NotificationCategoryCodec.protoToOutput, notification.category),\n /** Plain-text title, the same for every notification of a type. */\n title: notification.title,\n /** Plain-text summary; may span several lines. */\n text: notification.text,\n createdAt: tsObjToMs(notification.createdAt) ?? null,\n /** Null while unread. */\n readAt: tsObjToMs(notification.readAt) ?? null,\n detail: formatDetail(notification.detail),\n };\n}\n\n/**\n * One notification. When `detail.type` is `\"unspecified\"` (a type this SDK build does not\n * know), show `title` and `text` only.\n */\nexport type AccountNotification = ReturnType<typeof formatNotification>;\n\nexport type AccountNotificationDetail = AccountNotification[\"detail\"];\n\n/** One page of notifications, newest first; an empty `nextPageToken` means no more. */\nexport type ListNotificationsResult = {\n notifications: AccountNotification[];\n nextPageToken: string;\n};\n\nexport function formatNotificationCounts(counts: Proto.GetNotificationCountsResponse) {\n return {\n total: Number(counts.total),\n unread: Number(counts.unread),\n /** Every type in ascending enum order, including types with no notification. */\n types: counts.types.map((count) => ({\n type: enumLabel(NotificationTypeCodec.protoToOutput, count.type),\n category: enumLabel(NotificationCategoryCodec.protoToOutput, count.category),\n total: Number(count.total),\n unread: Number(count.unread),\n })),\n };\n}\n\n/** Exact counts of the caller's notifications, as of one moment. */\nexport type NotificationCounts = ReturnType<typeof formatNotificationCounts>;\n"],"mappings":";;;;;;;;;;AAwBA,MAAM,4BAA4B,cAAc,gBAAgB;;AAGhE,MAAM,wBAAwB,EAAE,SAC5B,EAAE,KACE,EAAE,MAAM,EAAE,SAAS,4BAA4B,CAAC,GAChD,EAAE,WAAW,eACT,WAAW,KAAK,aAAa,0BAA0B,aAAa,SAAS,CACjF,CACJ,CACJ;AAEA,MAAM,yBAAyB,EAAE,KAC7B,EAAE,OAAO,GACT,EAAE,QAAQ,GACV,EAAE,SAAS,CAAC,GACZ,EAAE,SAAS,OAAO,gBAAgB,CACtC;AAEA,MAAa,+BAA+B,EAAE,KAC1C,EAAE,aAAa;CACX,YAAY;;CAEZ,WAAW,EAAE,SAAS,EAAE,SAAS,8BAA8B,CAAC;;CAEhE,WAAW,EAAE,SAAS,sBAAsB;;CAE5C,SAAS,EAAE,SAAS,sBAAsB;;CAE1C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,QAAQ,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,SAAS,GAAG,CAAC,CAAC;;CAEjF,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,CAAC;AACtD,CAAC,GACD,EAAE,OACG,E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M,MAAM;EAC/B,EAAE;CACN;AACJ"}
1
+ {"version":3,"file":"notifications.schemas.js","names":[],"sources":["../../../src/services/notifications/notifications.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { PRICE_SCALE } from \"../../catalogs/readers.js\";\nimport type * as Proto from \"../../gen/notifications/v1/notifications_pb.js\";\nimport { scaledToDecimalOutput } from \"../../shared/decimal-surface.js\";\nimport { enumLabel } from \"../../shared/proto-enum-codec.js\";\nimport { idInputSchema, optionalIdInputSchema } from \"../../shared/schemas.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport { tsObjToMs } from \"../../utils/time.js\";\nimport { msToTimestamp } from \"../../utils/timestamp.js\";\nimport {\n PriceAlertDirectionCodec,\n PriceAlertPriceSourceCodec,\n} from \"../price-alerts/price-alerts.codecs.js\";\nimport {\n BrokerAllowlistActionCodec,\n BrokerAllowlistEventCodec,\n NOTIFICATION_CATEGORY_VALUES,\n NOTIFICATION_READ_STATE_VALUES,\n NotificationCategoryCodec,\n NotificationReadStateCodec,\n NotificationTypeCodec,\n TelegramApprovalActionCodec,\n} from \"./notifications.codecs.js\";\n\nconst NotificationIdInputSchema = idInputSchema(\"notificationId\");\n\n/** Omit or pass empty for every category. */\nconst CategoriesInputSchema = v.optional(\n v.pipe(\n v.array(v.picklist(NOTIFICATION_CATEGORY_VALUES)),\n v.transform((categories) =>\n categories.map((category) => NotificationCategoryCodec.inputToProto[category]),\n ),\n ),\n);\n\nconst TimestampMsInputSchema = v.pipe(\n v.number(),\n v.integer(),\n v.minValue(0),\n v.maxValue(Number.MAX_SAFE_INTEGER),\n);\n\nexport const ListNotificationsInputSchema = v.pipe(\n v.strictObject({\n categories: CategoriesInputSchema,\n /** Only read or only unread notifications; omit for both. */\n readState: v.optional(v.picklist(NOTIFICATION_READ_STATE_VALUES)),\n /** Epoch ms, inclusive. */\n startTime: v.optional(TimestampMsInputSchema),\n /** Epoch ms, exclusive; after `startTime` when both are set. */\n endTime: v.optional(TimestampMsInputSchema),\n /** Page size: default 25, at most 100. */\n limit: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(100))),\n /** Previous `nextPageToken`; reuse only with the same filters. */\n pageToken: v.optional(v.pipe(v.string(), v.trim())),\n }),\n v.check(\n ({ startTime, endTime }) =>\n startTime === undefined || endTime === undefined || endTime > startTime,\n \"endTime: must be after startTime\",\n ),\n v.transform(({ readState, startTime, endTime, ...input }) => ({\n ...input,\n readState: readState && NotificationReadStateCodec.inputToProto[readState],\n startTime: startTime === undefined ? undefined : msToTimestamp(startTime),\n endTime: endTime === undefined ? undefined : msToTimestamp(endTime),\n })),\n);\n\nexport type ListNotificationsInput = v.InferInput<typeof ListNotificationsInputSchema>;\n\nexport const GetNotificationInputSchema = v.strictObject({\n notificationId: NotificationIdInputSchema,\n});\n\nexport type GetNotificationInput = v.InferInput<typeof GetNotificationInputSchema>;\n\nexport const MarkNotificationsInputSchema = v.strictObject({\n /** One to 100 distinct notification IDs. */\n notificationIds: v.pipe(\n v.array(NotificationIdInputSchema),\n v.minLength(1, \"At least one notification ID is required.\"),\n v.maxLength(100, \"At most 100 notification IDs are allowed.\"),\n v.check((ids) => new Set(ids).size === ids.length, \"Notification IDs must be distinct.\"),\n ),\n});\n\nexport type MarkNotificationsInput = v.InferInput<typeof MarkNotificationsInputSchema>;\n\nexport const MarkAllNotificationsReadInputSchema = v.strictObject({\n categories: CategoriesInputSchema,\n /**\n * Mark only this notification and older ones. Pass the newest one shown, so one that arrives\n * later stays unread; omit to mark every notification that exists when the call runs.\n */\n throughNotificationId: optionalIdInputSchema(\"throughNotificationId\"),\n});\n\nexport type MarkAllNotificationsReadInput = v.InferInput<\n typeof MarkAllNotificationsReadInputSchema\n>;\n\n/*\n * Outputs are formatted straight from the decoded messages, like the assistant's run events.\n * The `detail` oneof becomes a `type`-tagged union; a case this build does not know becomes\n * `{ type: \"unspecified\" }`, and the notification's `title` and `text` describe it.\n */\n\nconst price = (ticks: bigint) => scaledToDecimalOutput(ticks, PRICE_SCALE);\n\nfunction formatDetail(detail: Proto.Notification[\"detail\"]) {\n switch (detail.case) {\n case \"priceAlert\": {\n const notice = detail.value;\n return {\n type: \"price_alert\" as const,\n /** The alert's ID in `client.priceAlerts`. */\n alertId: formatId(notice.alertId),\n symbolId: notice.symbolId,\n direction: enumLabel(PriceAlertDirectionCodec.protoToOutput, notice.direction),\n priceSource: enumLabel(\n PriceAlertPriceSourceCodec.protoToOutput,\n notice.priceSource,\n ),\n /** Alert price, as a decimal string. */\n price: price(notice.priceTicks),\n /** Price that fired the alert, as a decimal string. */\n triggeredPrice: price(notice.triggeredPriceTicks),\n triggeredAt: tsObjToMs(notice.triggeredAt) ?? null,\n };\n }\n case \"telegramApproval\": {\n const notice = detail.value;\n return {\n type: \"telegram_approval\" as const,\n /** The approval's ID in `client.assistant`. */\n approvalId: formatId(notice.approvalId),\n action: enumLabel(TelegramApprovalActionCodec.protoToOutput, notice.action),\n /** Trading account (subaccount) the action acted on. */\n accountId: formatId(notice.accountId),\n summary: notice.summary,\n /** Key parameters in display order, such as market, side and quantity. */\n parameters: notice.parameters.map(({ label, value }) => ({ label, value })),\n approvedAt: tsObjToMs(notice.approvedAt) ?? null,\n };\n }\n case \"brokerAllowlist\": {\n const notice = detail.value;\n return {\n type: \"broker_allowlist_change\" as const,\n broker: notice.broker,\n /** Sub-account ID of the broker vault. */\n vaultAccountId: formatId(notice.vaultAccountId),\n /** The change's ID; key the broker's vault allowlist view on it. */\n changeId: formatId(notice.changeId),\n event: enumLabel(BrokerAllowlistEventCodec.protoToOutput, notice.event),\n action: enumLabel(BrokerAllowlistActionCodec.protoToOutput, notice.action),\n /** Destination chain ID, as a decimal string. */\n destinationChainId: notice.destinationChainId.toString(),\n destinationAddress: notice.destinationAddress,\n /** The requesting member's name for an added address; empty when none. */\n label: notice.label,\n /**\n * Account ID of the member who requested the change. Show a `change_requested`\n * the caller did not make prominently: an added address becomes payable 24 hours\n * after it is listed.\n */\n requestedByAccountId: formatId(notice.requestedByAccountId),\n };\n }\n case \"telegramLink\":\n return {\n /** A Telegram account was linked; if the caller did not link it, unlink it. */\n type: \"telegram_linked\" as const,\n linkedAt: tsObjToMs(detail.value.linkedAt) ?? null,\n };\n default:\n return { type: \"unspecified\" as const };\n }\n}\n\nexport function formatNotification(notification: Proto.Notification) {\n return {\n notificationId: formatId(notification.notificationId),\n type: enumLabel(NotificationTypeCodec.protoToOutput, notification.type),\n category: enumLabel(NotificationCategoryCodec.protoToOutput, notification.category),\n /** Plain-text title, the same for every notification of a type. */\n title: notification.title,\n /** Plain-text summary; may span several lines. */\n text: notification.text,\n createdAt: tsObjToMs(notification.createdAt) ?? null,\n /** Null while unread. */\n readAt: tsObjToMs(notification.readAt) ?? null,\n detail: formatDetail(notification.detail),\n };\n}\n\n/**\n * One notification. When `detail.type` is `\"unspecified\"` (a type this SDK build does not\n * know), show `title` and `text` only.\n */\nexport type AccountNotification = ReturnType<typeof formatNotification>;\n\nexport type AccountNotificationDetail = AccountNotification[\"detail\"];\n\n/** One page of notifications, newest first; an empty `nextPageToken` means no more. */\nexport type ListNotificationsResult = {\n notifications: AccountNotification[];\n nextPageToken: string;\n};\n\nexport function formatNotificationCounts(counts: Proto.GetNotificationCountsResponse) {\n return {\n total: Number(counts.total),\n unread: Number(counts.unread),\n /** Every type in ascending enum order, including types with no notification. */\n types: counts.types.map((count) => ({\n type: enumLabel(NotificationTypeCodec.protoToOutput, count.type),\n category: enumLabel(NotificationCategoryCodec.protoToOutput, count.category),\n total: Number(count.total),\n unread: Number(count.unread),\n })),\n };\n}\n\n/** Exact counts of the caller's notifications, as of one moment. */\nexport type NotificationCounts = ReturnType<typeof formatNotificationCounts>;\n"],"mappings":";;;;;;;;;;AAwBA,MAAM,4BAA4B,cAAc,gBAAgB;;AAGhE,MAAM,wBAAwB,EAAE,SAC5B,EAAE,KACE,EAAE,MAAM,EAAE,SAAS,4BAA4B,CAAC,GAChD,EAAE,WAAW,eACT,WAAW,KAAK,aAAa,0BAA0B,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ACJ,SACI,OAAO,EAAE,MAAM,cAAuB;CAC9C;AACJ;AAEA,SAAgB,mBAAmB,cAAkC;CACjE,OAAO;EACH,gBAAgB,SAAS,aAAa,cAAc;EACpD,MAAM,UAAU,sBAAsB,eAAe,aAAa,IAAI;EACtE,UAAU,UAAU,0BAA0B,eAAe,aAAa,QAAQ;;EAElF,OAAO,aAAa;;EAEpB,MAAM,aAAa;EACnB,WAAW,UAAU,aAAa,SAAS,KAAK;;EAEhD,QAAQ,UAAU,aAAa,MAAM,KAAK;EAC1C,QAAQ,aAAa,aAAa,MAAM;CAC5C;AACJ;AAgBA,SAAgB,yBAAyB,QAA6C;CAClF,OAAO;EACH,OAAO,OAAO,OAAO,KAAK;EAC1B,QAAQ,OAAO,OAAO,MAAM;;EAE5B,OAAO,OAAO,MAAM,KAAK,WAAW;GAChC,MAAM,UAAU,sBAAsB,eAAe,MAAM,IAAI;GAC/D,UAAU,UAAU,0BAA0B,eAAe,MAAM,QAAQ;GAC3E,OAAO,OAAO,MAAM,KAAK;GACzB,QAAQ,OAAO,MAAM,MAAM;EAC/B,EAAE;CACN;AACJ"}
@@ -188,8 +188,9 @@ var OrderbookService = class {
188
188
  maxBufferedPublications: 200,
189
189
  snapshotErrorLog: "Failed to fetch orderbook",
190
190
  snapshotRetry: {
191
- maxAttempts: 3,
192
- delayMs: 1e3
191
+ maxAttempts: Number.POSITIVE_INFINITY,
192
+ delayMs: 1e3,
193
+ maxDelayMs: 8e3
193
194
  },
194
195
  fetchSnapshot: inputServiceFetch,
195
196
  readPublication: (delta) => [delta],
@@ -1 +1 @@
1
- {"version":3,"file":"orderbook.js","names":["#client","Proto.OrderbookService","#realtime","#scales","Proto.GetOrderBookResponseSchema","Proto.OrderBookDeltaSchema"],"sources":["../../../src/services/orderbook/orderbook.ts"],"sourcesContent":["import { create } from \"@bufbuild/protobuf\";\nimport * as Proto from \"../../gen/orderbook/v1/orderbook_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport { publicationHandlerErrorContext } from \"../../shared/subscription-errors.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport {\n snapshotThenStream,\n type SnapshotThenStreamSubscription,\n} from \"../../realtime/snapshot-then-stream.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport { decimalInputToScaled, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport {\n formatOrderbookLevel,\n GetOrderbookInputSchema,\n createOrderbookDataSchema,\n type OrderbookLevel,\n type OrderbookData,\n} from \"./orderbook.schemas.js\";\nimport { orderbookWsChannelDepth } from \"./orderbook.codecs.js\";\nimport { isResourceNotFoundError } from \"../../utils/errors.js\";\nimport { ServiceUnavailableError, ValidationError } from \"../../shared/errors.js\";\nimport type * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport type { PublicApiTransports } from \"../../shared/transports.js\";\n\ninterface SubscribeOrderbookInput extends BaseSubscribeInput<OrderbookData> {\n symbolId: number;\n depth?: number;\n bucket?: string | null;\n}\n\nexport interface OrderbookStreamHandlers extends BaseSubscribeInput<OrderbookData> {}\n\nexport interface OrderbookSubscription {\n unsubscribe: () => void;\n setBucket: (bucket: string | null | undefined) => void;\n}\n\nexport interface CreateOrderbookSubscriptionInput\n extends\n OrderbookStreamHandlers,\n Pick<SubscribeOrderbookInput, \"symbolId\" | \"depth\" | \"bucket\"> {}\n\ntype BookSide = Map<bigint, bigint>;\n\n/**\n * Reads spot order book snapshots and maintains realtime local order book state from public delta channels.\n */\nexport class OrderbookService {\n #client: Client<typeof Proto.OrderbookService>;\n #realtime: PolyesterRealtime;\n #scales: SdkScales;\n\n constructor(transports: PublicApiTransports, realtime: PolyesterRealtime, scales: SdkScales) {\n this.#client = createClient(Proto.OrderbookService, transports.publicApi);\n this.#realtime = realtime;\n this.#scales = scales;\n }\n\n /**\n * Fetches a spot order book depth snapshot for a symbol ID and requested depth, returning best bids and asks with the backend book sequence.\n * When `available` is false the book is being built or was invalidated: its levels are unknown, not empty, so read it again later instead of treating empty sides as no liquidity.\n */\n async get(\n input: v.InferInput<typeof GetOrderbookInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<OrderbookData> {\n const validated = parse(GetOrderbookInputSchema, input);\n await this.#scales.ready();\n const res = await this.#client.getOrderBook(\n { symbolId: validated.symbolId, depth: validated.depth },\n toConnectCallOptions(options),\n );\n return parse(createOrderbookDataSchema(this.#scales, validated.symbolId), {\n symbolId: res.symbolId,\n depth: validated.depth,\n bookSeq: res.bookSeq,\n bookEpoch: res.bookEpoch,\n maxDepth: res.maxDepth,\n available: isBookAvailable(res),\n bids: res.bids,\n asks: res.asks,\n ts: res.ts,\n });\n }\n\n /**\n * Subscribes to the managed order book stream for a symbol ID and forwards reconstructed snapshots to onEvent. This is a convenience wrapper around createSubscription().unsubscribe.\n */\n subscribe(input: SubscribeOrderbookInput): () => void {\n return this.createSubscription(input).unsubscribe;\n }\n\n /**\n * Creates a stateful order book subscription that first fetches a snapshot, buffers proto deltas from public:spot:orderbook:deltas:depth:{depth}:{symbolId}:proto, applies each delta only when it chains onto the book, and refetches on reconnects. After a sequence gap the book holds its last state until the server's next reset, sent about every 30 seconds and after gaps. A snapshot whose book is not available fails with ServiceUnavailableError through onError and is retried; no event is emitted until a snapshot is available. The snapshot is fetched once the channel opens, so a socket that cannot connect reports a retryable RealtimeError with type \"transport\" through onError instead, once per outage; onOpen follows when it recovers. The returned handle can unsubscribe or change local price bucket aggregation without reconnecting.\n *\n * `depth` above 500 throws ValidationError; other depths ride the smallest published channel depth that covers it (see ORDERBOOK_WS_DEPTHS); levels are sliced back to the requested depth locally.\n *\n * A refetched snapshot from an older `bookEpoch` than the book's is discarded and retried.\n *\n * Refetching is driven by reconnect events only. A feed that stays subscribed but stops publishing is indistinguishable from a quiet market, so it does not trigger onError or a refetch. Callers that must detect a stalled book need their own idle watchdog plus a REST refetch.\n */\n createSubscription(input: CreateOrderbookSubscriptionInput): OrderbookSubscription {\n const { symbolId, depth } = parse(GetOrderbookInputSchema, {\n symbolId: input.symbolId,\n depth: input.depth,\n });\n if (depth > 500) {\n throw new ValidationError(\n `depth must be at most 500 for a managed order book, got ${depth}`,\n );\n }\n const channelDepth = orderbookWsChannelDepth(depth);\n const channel = `public:spot:orderbook:deltas:depth:${channelDepth}:${symbolId}:proto`;\n\n const client = this.#client;\n const scales = this.#scales;\n let bidsMap: BookSide = new Map();\n let asksMap: BookSide = new Map();\n let currentBookSeq = 0n;\n let currentBookEpoch = 0n;\n let maxDepth = 0;\n // Set when a delta does not chain onto the book; only the next reset recovers it.\n let awaitingReset = false;\n let bucketTicks: bigint | null = null;\n let stream: SnapshotThenStreamSubscription | undefined;\n\n function levelsToMap(levels: Proto.PriceLevel[] | undefined): BookSide {\n const map: BookSide = new Map();\n for (const l of levels ?? []) {\n if (l.qtyScaled === 0n) continue;\n map.set(l.priceTicks, l.qtyScaled);\n }\n return map;\n }\n\n function applySideDelta(map: BookSide, levels: Proto.PriceLevel[] | undefined): void {\n for (const l of levels ?? []) {\n if (l.qtyScaled === 0n) map.delete(l.priceTicks);\n else map.set(l.priceTicks, l.qtyScaled);\n }\n }\n\n function sideToUI(map: BookSide, side: \"bids\" | \"asks\", limit: number): OrderbookLevel[] {\n const entries = Array.from(map.entries());\n entries.sort(([pa], [pb]) => {\n if (pa === pb) return 0;\n return side === \"bids\" ? (pa > pb ? -1 : 1) : pa < pb ? -1 : 1;\n });\n return entries\n .slice(0, limit)\n .map(([priceTicks, qtyScaled]) =>\n formatOrderbookLevel({ priceTicks, qtyScaled }, scales, symbolId),\n );\n }\n\n function sideToUIBucketed(\n map: BookSide,\n side: \"bids\" | \"asks\",\n limit: number,\n bucket: bigint | null,\n ): OrderbookLevel[] {\n if (!bucket || bucket <= 0n) return sideToUI(map, side, limit);\n\n const agg: BookSide = new Map();\n for (const [priceTicks, qtyScaled] of map.entries()) {\n if (qtyScaled <= 0n) continue;\n const bucketFloor = (priceTicks / bucket) * bucket;\n const bucketPrice =\n side === \"asks\" && bucketFloor !== priceTicks\n ? bucketFloor + bucket\n : bucketFloor;\n agg.set(bucketPrice, (agg.get(bucketPrice) ?? 0n) + qtyScaled);\n }\n return sideToUI(agg, side, limit);\n }\n\n function emit(): void {\n try {\n input.onEvent({\n symbolId,\n depth,\n bookSeq: currentBookSeq.toString(),\n bookEpoch: currentBookEpoch.toString(),\n maxDepth,\n available: true,\n bids: sideToUIBucketed(bidsMap, \"bids\", depth, bucketTicks),\n asks: sideToUIBucketed(asksMap, \"asks\", depth, bucketTicks),\n });\n } catch (error) {\n input.onError?.(publicationHandlerErrorContext(channel, error));\n }\n }\n\n function setBucket(bucket: string | null | undefined): void {\n if (!bucket) {\n bucketTicks = null;\n } else {\n try {\n bucketTicks = decimalInputToScaled(\"bucket\", bucket, scales.price());\n } catch {\n bucketTicks = null;\n }\n }\n if (stream?.isReady()) emit();\n }\n\n async function inputServiceFetch(): Promise<Proto.GetOrderBookResponse> {\n await scales.ready();\n let res: Proto.GetOrderBookResponse;\n try {\n res = await client.getOrderBook({ symbolId, depth: channelDepth });\n } catch (error: unknown) {\n if (!isResourceNotFoundError(error)) throw error;\n\n return create(Proto.GetOrderBookResponseSchema, {\n symbolId,\n bookSeq: 0n,\n available: true,\n bids: [],\n asks: [],\n });\n }\n // An unavailable book's levels are unknown, not empty: fail the snapshot so it is retried.\n if (!isBookAvailable(res)) {\n throw new ServiceUnavailableError(\n `Order book for symbol ${symbolId} is not available yet`,\n );\n }\n if (res.bookEpoch < currentBookEpoch) {\n throw new ServiceUnavailableError(\n `Order book snapshot for symbol ${symbolId} is from an older epoch`,\n );\n }\n return res;\n }\n\n /**\n * Applies a delta only when it chains onto the current book (`bookSeqStart` equals the\n * last applied `bookSeqEnd`) or is a reset. A delta that does not chain leaves the book\n * waiting for the next reset, which the server sends periodically and after a gap.\n */\n function handleDelta(delta: Proto.OrderBookDelta): void {\n if (delta.bookSeqEnd <= currentBookSeq) return;\n\n if (delta.reset) {\n bidsMap.clear();\n asksMap.clear();\n awaitingReset = false;\n } else if (awaitingReset || delta.bookSeqStart !== currentBookSeq) {\n awaitingReset = true;\n return;\n }\n\n applySideDelta(bidsMap, delta.bids);\n applySideDelta(asksMap, delta.asks);\n\n currentBookSeq = delta.bookSeqEnd;\n emit();\n }\n\n setBucket(input.bucket);\n stream = snapshotThenStream({\n realtime: this.#realtime,\n channel,\n schema: Proto.OrderBookDeltaSchema,\n maxBufferedPublications: 200,\n snapshotErrorLog: \"Failed to fetch orderbook\",\n snapshotRetry: { maxAttempts: 3, delayMs: 1_000 },\n fetchSnapshot: inputServiceFetch,\n readPublication: (delta) => [delta],\n applySnapshot: (snapshot, bufferedDeltas) => {\n bidsMap = levelsToMap(snapshot.bids);\n asksMap = levelsToMap(snapshot.asks);\n currentBookSeq = snapshot.bookSeq;\n currentBookEpoch = snapshot.bookEpoch;\n maxDepth = snapshot.maxDepth;\n awaitingReset = false;\n emit();\n for (const delta of bufferedDeltas) {\n if (stream?.isDisposed()) return;\n handleDelta(delta);\n }\n },\n applyLivePublications: (deltas) => {\n for (const delta of deltas) {\n if (stream?.isDisposed()) return;\n handleDelta(delta);\n }\n },\n onOpen: input.onOpen,\n onClose: input.onClose,\n onError: input.onError,\n });\n\n function dispose(): void {\n stream?.unsubscribe();\n }\n\n return { unsubscribe: dispose, setBucket };\n }\n}\n\n/**\n * Whether a snapshot's levels are the book. A snapshot carrying levels is current even with\n * `available` false, which is how servers that predate the field encode every snapshot.\n */\nfunction isBookAvailable(res: Proto.GetOrderBookResponse): boolean {\n return res.available || res.bids.length > 0 || res.asks.length > 0;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoDA,IAAa,mBAAb,MAA8B;CAC1B;CACA;CACA;CAEA,YAAY,YAAiC,UAA6B,QAAmB;EACzF,KAAKA,UAAU,aAAaC,oBAAwB,WAAW,SAAS;EACxE,KAAKC,YAAY;EACjB,KAAKC,UAAU;CACnB;;;;;CAMA,MAAM,IAC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AS,IAAI;IACnC,iBAAiB,SAAS;IAC1B,mBAAmB,SAAS;IAC5B,WAAW,SAAS;IACpB,gBAAgB;IAChB,KAAK;IACL,KAAK,MAAM,SAAS,gBAAgB;KAChC,IAAI,QAAQ,WAAW,GAAG;KAC1B,YAAY,KAAK;IACrB;GACJ;GACA,wBAAwB,WAAW;IAC/B,KAAK,MAAM,SAAS,QAAQ;KACxB,IAAI,QAAQ,WAAW,GAAG;KAC1B,YAAY,KAAK;IACrB;GACJ;GACA,QAAQ,MAAM;GACd,SAAS,MAAM;GACf,SAAS,MAAM;EACnB,CAAC;EAED,SAAS,UAAgB;GACrB,QAAQ,YAAY;EACxB;EAEA,OAAO;GAAE,aAAa;GAAS;EAAU;CAC7C;AACJ;;;;;AAMA,SAAS,gBAAgB,KAA0C;CAC/D,OAAO,IAAI,aAAa,IAAI,KAAK,SAAS,KAAK,IAAI,KAAK,SAAS;AACrE"}
1
+ {"version":3,"file":"orderbook.js","names":["#client","Proto.OrderbookService","#realtime","#scales","Proto.GetOrderBookResponseSchema","Proto.OrderBookDeltaSchema"],"sources":["../../../src/services/orderbook/orderbook.ts"],"sourcesContent":["import { create } from \"@bufbuild/protobuf\";\nimport * as Proto from \"../../gen/orderbook/v1/orderbook_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport { publicationHandlerErrorContext } from \"../../shared/subscription-errors.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport {\n snapshotThenStream,\n type SnapshotThenStreamSubscription,\n} from \"../../realtime/snapshot-then-stream.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport { decimalInputToScaled, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport {\n formatOrderbookLevel,\n GetOrderbookInputSchema,\n createOrderbookDataSchema,\n type OrderbookLevel,\n type OrderbookData,\n} from \"./orderbook.schemas.js\";\nimport { orderbookWsChannelDepth } from \"./orderbook.codecs.js\";\nimport { isResourceNotFoundError } from \"../../utils/errors.js\";\nimport { ServiceUnavailableError, ValidationError } from \"../../shared/errors.js\";\nimport type * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport type { PublicApiTransports } from \"../../shared/transports.js\";\n\ninterface SubscribeOrderbookInput extends BaseSubscribeInput<OrderbookData> {\n symbolId: number;\n depth?: number;\n bucket?: string | null;\n}\n\nexport interface OrderbookStreamHandlers extends BaseSubscribeInput<OrderbookData> {}\n\nexport interface OrderbookSubscription {\n unsubscribe: () => void;\n setBucket: (bucket: string | null | undefined) => void;\n}\n\nexport interface CreateOrderbookSubscriptionInput\n extends\n OrderbookStreamHandlers,\n Pick<SubscribeOrderbookInput, \"symbolId\" | \"depth\" | \"bucket\"> {}\n\ntype BookSide = Map<bigint, bigint>;\n\n/**\n * Reads spot order book snapshots and maintains realtime local order book state from public delta channels.\n */\nexport class OrderbookService {\n #client: Client<typeof Proto.OrderbookService>;\n #realtime: PolyesterRealtime;\n #scales: SdkScales;\n\n constructor(transports: PublicApiTransports, realtime: PolyesterRealtime, scales: SdkScales) {\n this.#client = createClient(Proto.OrderbookService, transports.publicApi);\n this.#realtime = realtime;\n this.#scales = scales;\n }\n\n /**\n * Fetches a spot order book depth snapshot for a symbol ID and requested depth, returning best bids and asks with the backend book sequence.\n * When `available` is false the book is being built or was invalidated: its levels are unknown, not empty, so read it again later instead of treating empty sides as no liquidity.\n */\n async get(\n input: v.InferInput<typeof GetOrderbookInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<OrderbookData> {\n const validated = parse(GetOrderbookInputSchema, input);\n await this.#scales.ready();\n const res = await this.#client.getOrderBook(\n { symbolId: validated.symbolId, depth: validated.depth },\n toConnectCallOptions(options),\n );\n return parse(createOrderbookDataSchema(this.#scales, validated.symbolId), {\n symbolId: res.symbolId,\n depth: validated.depth,\n bookSeq: res.bookSeq,\n bookEpoch: res.bookEpoch,\n maxDepth: res.maxDepth,\n available: isBookAvailable(res),\n bids: res.bids,\n asks: res.asks,\n ts: res.ts,\n });\n }\n\n /**\n * Subscribes to the managed order book stream for a symbol ID and forwards reconstructed snapshots to onEvent. This is a convenience wrapper around createSubscription().unsubscribe.\n */\n subscribe(input: SubscribeOrderbookInput): () => void {\n return this.createSubscription(input).unsubscribe;\n }\n\n /**\n * Creates a stateful order book subscription that first fetches a snapshot, buffers proto deltas from public:spot:orderbook:deltas:depth:{depth}:{symbolId}:proto, applies each delta only when it chains onto the book, and refetches on reconnects. After a sequence gap the book holds its last state until the server's next reset, sent about every 30 seconds and after gaps. A snapshot whose book is not available fails with ServiceUnavailableError through onError and is retried; no event is emitted until a snapshot is available. The snapshot is fetched once the channel opens, so a socket that cannot connect reports a retryable RealtimeError with type \"transport\" through onError instead, once per outage; onOpen follows when it recovers. The returned handle can unsubscribe or change local price bucket aggregation without reconnecting.\n *\n * `depth` above 500 throws ValidationError; other depths ride the smallest published channel depth that covers it (see ORDERBOOK_WS_DEPTHS); levels are sliced back to the requested depth locally.\n *\n * A refetched snapshot from an older `bookEpoch` than the book's is discarded and retried.\n *\n * Refetching is driven by reconnect events only. A feed that stays subscribed but stops publishing is indistinguishable from a quiet market, so it does not trigger onError or a refetch. Callers that must detect a stalled book need their own idle watchdog plus a REST refetch.\n */\n createSubscription(input: CreateOrderbookSubscriptionInput): OrderbookSubscription {\n const { symbolId, depth } = parse(GetOrderbookInputSchema, {\n symbolId: input.symbolId,\n depth: input.depth,\n });\n if (depth > 500) {\n throw new ValidationError(\n `depth must be at most 500 for a managed order book, got ${depth}`,\n );\n }\n const channelDepth = orderbookWsChannelDepth(depth);\n const channel = `public:spot:orderbook:deltas:depth:${channelDepth}:${symbolId}:proto`;\n\n const client = this.#client;\n const scales = this.#scales;\n let bidsMap: BookSide = new Map();\n let asksMap: BookSide = new Map();\n let currentBookSeq = 0n;\n let currentBookEpoch = 0n;\n let maxDepth = 0;\n // Set when a delta does not chain onto the book; only the next reset recovers it.\n let awaitingReset = false;\n let bucketTicks: bigint | null = null;\n let stream: SnapshotThenStreamSubscription | undefined;\n\n function levelsToMap(levels: Proto.PriceLevel[] | undefined): BookSide {\n const map: BookSide = new Map();\n for (const l of levels ?? []) {\n if (l.qtyScaled === 0n) continue;\n map.set(l.priceTicks, l.qtyScaled);\n }\n return map;\n }\n\n function applySideDelta(map: BookSide, levels: Proto.PriceLevel[] | undefined): void {\n for (const l of levels ?? []) {\n if (l.qtyScaled === 0n) map.delete(l.priceTicks);\n else map.set(l.priceTicks, l.qtyScaled);\n }\n }\n\n function sideToUI(map: BookSide, side: \"bids\" | \"asks\", limit: number): OrderbookLevel[] {\n const entries = Array.from(map.entries());\n entries.sort(([pa], [pb]) => {\n if (pa === pb) return 0;\n return side === \"bids\" ? (pa > pb ? -1 : 1) : pa < pb ? -1 : 1;\n });\n return entries\n .slice(0, limit)\n .map(([priceTicks, qtyScaled]) =>\n formatOrderbookLevel({ priceTicks, qtyScaled }, scales, symbolId),\n );\n }\n\n function sideToUIBucketed(\n map: BookSide,\n side: \"bids\" | \"asks\",\n limit: number,\n bucket: bigint | null,\n ): OrderbookLevel[] {\n if (!bucket || bucket <= 0n) return sideToUI(map, side, limit);\n\n const agg: BookSide = new Map();\n for (const [priceTicks, qtyScaled] of map.entries()) {\n if (qtyScaled <= 0n) continue;\n const bucketFloor = (priceTicks / bucket) * bucket;\n const bucketPrice =\n side === \"asks\" && bucketFloor !== priceTicks\n ? bucketFloor + bucket\n : bucketFloor;\n agg.set(bucketPrice, (agg.get(bucketPrice) ?? 0n) + qtyScaled);\n }\n return sideToUI(agg, side, limit);\n }\n\n function emit(): void {\n try {\n input.onEvent({\n symbolId,\n depth,\n bookSeq: currentBookSeq.toString(),\n bookEpoch: currentBookEpoch.toString(),\n maxDepth,\n available: true,\n bids: sideToUIBucketed(bidsMap, \"bids\", depth, bucketTicks),\n asks: sideToUIBucketed(asksMap, \"asks\", depth, bucketTicks),\n });\n } catch (error) {\n input.onError?.(publicationHandlerErrorContext(channel, error));\n }\n }\n\n function setBucket(bucket: string | null | undefined): void {\n if (!bucket) {\n bucketTicks = null;\n } else {\n try {\n bucketTicks = decimalInputToScaled(\"bucket\", bucket, scales.price());\n } catch {\n bucketTicks = null;\n }\n }\n if (stream?.isReady()) emit();\n }\n\n async function inputServiceFetch(): Promise<Proto.GetOrderBookResponse> {\n await scales.ready();\n let res: Proto.GetOrderBookResponse;\n try {\n res = await client.getOrderBook({ symbolId, depth: channelDepth });\n } catch (error: unknown) {\n if (!isResourceNotFoundError(error)) throw error;\n\n return create(Proto.GetOrderBookResponseSchema, {\n symbolId,\n bookSeq: 0n,\n available: true,\n bids: [],\n asks: [],\n });\n }\n // An unavailable book's levels are unknown, not empty: fail the snapshot so it is retried.\n if (!isBookAvailable(res)) {\n throw new ServiceUnavailableError(\n `Order book for symbol ${symbolId} is not available yet`,\n );\n }\n if (res.bookEpoch < currentBookEpoch) {\n throw new ServiceUnavailableError(\n `Order book snapshot for symbol ${symbolId} is from an older epoch`,\n );\n }\n return res;\n }\n\n /**\n * Applies a delta only when it chains onto the current book (`bookSeqStart` equals the\n * last applied `bookSeqEnd`) or is a reset. A delta that does not chain leaves the book\n * waiting for the next reset, which the server sends periodically and after a gap.\n */\n function handleDelta(delta: Proto.OrderBookDelta): void {\n if (delta.bookSeqEnd <= currentBookSeq) return;\n\n if (delta.reset) {\n bidsMap.clear();\n asksMap.clear();\n awaitingReset = false;\n } else if (awaitingReset || delta.bookSeqStart !== currentBookSeq) {\n awaitingReset = true;\n return;\n }\n\n applySideDelta(bidsMap, delta.bids);\n applySideDelta(asksMap, delta.asks);\n\n currentBookSeq = delta.bookSeqEnd;\n emit();\n }\n\n setBucket(input.bucket);\n stream = snapshotThenStream({\n realtime: this.#realtime,\n channel,\n schema: Proto.OrderBookDeltaSchema,\n maxBufferedPublications: 200,\n snapshotErrorLog: \"Failed to fetch orderbook\",\n // GetOrderBook answers unavailable while the book is (re)built; keep asking until it is ready.\n snapshotRetry: {\n maxAttempts: Number.POSITIVE_INFINITY,\n delayMs: 1_000,\n maxDelayMs: 8_000,\n },\n fetchSnapshot: inputServiceFetch,\n readPublication: (delta) => [delta],\n applySnapshot: (snapshot, bufferedDeltas) => {\n bidsMap = levelsToMap(snapshot.bids);\n asksMap = levelsToMap(snapshot.asks);\n currentBookSeq = snapshot.bookSeq;\n currentBookEpoch = snapshot.bookEpoch;\n maxDepth = snapshot.maxDepth;\n awaitingReset = false;\n emit();\n for (const delta of bufferedDeltas) {\n if (stream?.isDisposed()) return;\n handleDelta(delta);\n }\n },\n applyLivePublications: (deltas) => {\n for (const delta of deltas) {\n if (stream?.isDisposed()) return;\n handleDelta(delta);\n }\n },\n onOpen: input.onOpen,\n onClose: input.onClose,\n onError: input.onError,\n });\n\n function dispose(): void {\n stream?.unsubscribe();\n }\n\n return { unsubscribe: dispose, setBucket };\n }\n}\n\n/**\n * Whether a snapshot's levels are the book. A snapshot carrying levels is current even with\n * `available` false, which is how servers that predate the field encode every snapshot.\n */\nfunction isBookAvailable(res: Proto.GetOrderBookResponse): boolean {\n return res.available || res.bids.length > 0 || res.asks.length > 0;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoDA,IAAa,mBAAb,MAA8B;CAC1B;CACA;CACA;CAEA,YAAY,YAAiC,UAA6B,QAAmB;EACzF,KAAKA,UAAU,aAAaC,oBAAwB,WAAW,SAAS;EACxE,KAAKC,YAAY;EACjB,KAAKC,UAAU;CACnB;;;;;CAMA,MAAM,IACF,OACA,SACsB;EACtB,MAAM,YAAY,MAAM,yBAAyB,KAAK;EACtD,MAAM,KAAKA,QAAQ,MAAM;EACzB,MAAM,MAAM,MAAM,KAAKH,QAAQ,aAC3B;GAAE,UAAU,UAAU;GAAU,OAAO,UAAU;EAAM,GACvD,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,0BAA0B,KAAKG,SAAS,UAAU,QAAQ,GAAG;GACtE,UAAU,IAAI;GACd,OAAO,UAAU;GACjB,SAAS,IAAI;GACb,WAAW,IAAI;GAC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