@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
@@ -38,7 +38,7 @@ declare const SubaccountPolicySchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
38
38
  readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
39
39
  }, undefined>, undefined>, readonly []>;
40
40
  readonly spotMarketScope: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"all" | "allowlist">>]>;
41
- readonly actions: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.NumberSchema<undefined>, undefined>, readonly []>, v.TransformAction<number[], DecodedEnum<"swap" | "trade-spot" | "internal-transfer" | "external-withdraw" | "read-balances" | "read-spot" | "read-internal-transfers" | "read-address-book" | "manage-address-book" | "read-auto-withdraw" | "manage-auto-withdraw" | "read-api-keys" | "read-api-policies" | "read-subaccount-policies" | "read-subaccount-permissions" | "read-vip-status" | "read-social-verification" | "read-profile" | "read-account-directory" | "read-withdraw-validation" | "read-daily-claims" | "claim-daily-reward" | "read-checkpoints" | "read-rewards" | "create-deposit-address" | "read-deposit-addresses" | "read-subaccounts" | "read-subaccount-activity" | "read-subaccount-members" | "read-subaccount-invites" | "read-guard-signer-status" | "read-price-alerts" | "manage-price-alerts" | "read-statements" | "convert-dust" | "read-funding-flows">[]>]>;
41
+ readonly actions: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.NumberSchema<undefined>, undefined>, readonly []>, v.TransformAction<number[], DecodedEnum<"swap" | "trade-spot" | "internal-transfer" | "external-withdraw" | "read-balances" | "read-spot" | "read-internal-transfers" | "read-address-book" | "manage-address-book" | "read-auto-withdraw" | "manage-auto-withdraw" | "read-statements" | "convert-dust" | "read-funding-flows" | "read-api-keys" | "read-api-policies" | "read-subaccount-policies" | "read-subaccount-permissions" | "read-vip-status" | "read-social-verification" | "read-profile" | "read-account-directory" | "read-withdraw-validation" | "read-daily-claims" | "claim-daily-reward" | "read-checkpoints" | "read-rewards" | "create-deposit-address" | "read-deposit-addresses" | "read-subaccounts" | "read-subaccount-activity" | "read-subaccount-members" | "read-subaccount-invites" | "read-guard-signer-status" | "read-price-alerts" | "manage-price-alerts" | "read-notifications" | "read-account-activity">[]>]>;
42
42
  readonly isTemplate: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
43
43
  readonly sourceTemplateId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.BigintSchema<undefined>, undefined>, v.TransformAction<bigint | undefined, string | undefined>]>;
44
44
  readonly maxOrderNotional: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
@@ -79,7 +79,7 @@ declare const SubaccountPolicySchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
79
79
  symbolId: number;
80
80
  }[];
81
81
  spotMarketScope: DecodedEnum<"all" | "allowlist">;
82
- actions: DecodedEnum<"swap" | "trade-spot" | "internal-transfer" | "external-withdraw" | "read-balances" | "read-spot" | "read-internal-transfers" | "read-address-book" | "manage-address-book" | "read-auto-withdraw" | "manage-auto-withdraw" | "read-api-keys" | "read-api-policies" | "read-subaccount-policies" | "read-subaccount-permissions" | "read-vip-status" | "read-social-verification" | "read-profile" | "read-account-directory" | "read-withdraw-validation" | "read-daily-claims" | "claim-daily-reward" | "read-checkpoints" | "read-rewards" | "create-deposit-address" | "read-deposit-addresses" | "read-subaccounts" | "read-subaccount-activity" | "read-subaccount-members" | "read-subaccount-invites" | "read-guard-signer-status" | "read-price-alerts" | "manage-price-alerts" | "read-statements" | "convert-dust" | "read-funding-flows">[];
82
+ actions: DecodedEnum<"swap" | "trade-spot" | "internal-transfer" | "external-withdraw" | "read-balances" | "read-spot" | "read-internal-transfers" | "read-address-book" | "manage-address-book" | "read-auto-withdraw" | "manage-auto-withdraw" | "read-statements" | "convert-dust" | "read-funding-flows" | "read-api-keys" | "read-api-policies" | "read-subaccount-policies" | "read-subaccount-permissions" | "read-vip-status" | "read-social-verification" | "read-profile" | "read-account-directory" | "read-withdraw-validation" | "read-daily-claims" | "claim-daily-reward" | "read-checkpoints" | "read-rewards" | "create-deposit-address" | "read-deposit-addresses" | "read-subaccounts" | "read-subaccount-activity" | "read-subaccount-members" | "read-subaccount-invites" | "read-guard-signer-status" | "read-price-alerts" | "manage-price-alerts" | "read-notifications" | "read-account-activity">[];
83
83
  isTemplate: boolean;
84
84
  sourceTemplateId?: string | undefined;
85
85
  maxOrderNotional: string;
@@ -104,7 +104,7 @@ declare const SubaccountPolicySchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
104
104
  symbolId: number;
105
105
  }[];
106
106
  spotMarketScope: DecodedEnum<"all" | "allowlist">;
107
- actions: DecodedEnum<"swap" | "trade-spot" | "internal-transfer" | "external-withdraw" | "read-balances" | "read-spot" | "read-internal-transfers" | "read-address-book" | "manage-address-book" | "read-auto-withdraw" | "manage-auto-withdraw" | "read-api-keys" | "read-api-policies" | "read-subaccount-policies" | "read-subaccount-permissions" | "read-vip-status" | "read-social-verification" | "read-profile" | "read-account-directory" | "read-withdraw-validation" | "read-daily-claims" | "claim-daily-reward" | "read-checkpoints" | "read-rewards" | "create-deposit-address" | "read-deposit-addresses" | "read-subaccounts" | "read-subaccount-activity" | "read-subaccount-members" | "read-subaccount-invites" | "read-guard-signer-status" | "read-price-alerts" | "manage-price-alerts" | "read-statements" | "convert-dust" | "read-funding-flows">[];
107
+ actions: DecodedEnum<"swap" | "trade-spot" | "internal-transfer" | "external-withdraw" | "read-balances" | "read-spot" | "read-internal-transfers" | "read-address-book" | "manage-address-book" | "read-auto-withdraw" | "manage-auto-withdraw" | "read-statements" | "convert-dust" | "read-funding-flows" | "read-api-keys" | "read-api-policies" | "read-subaccount-policies" | "read-subaccount-permissions" | "read-vip-status" | "read-social-verification" | "read-profile" | "read-account-directory" | "read-withdraw-validation" | "read-daily-claims" | "claim-daily-reward" | "read-checkpoints" | "read-rewards" | "create-deposit-address" | "read-deposit-addresses" | "read-subaccounts" | "read-subaccount-activity" | "read-subaccount-members" | "read-subaccount-invites" | "read-guard-signer-status" | "read-price-alerts" | "manage-price-alerts" | "read-notifications" | "read-account-activity">[];
108
108
  isTemplate: boolean;
109
109
  sourceTemplateId?: string | undefined;
110
110
  maxOpenOrders: number;
@@ -124,7 +124,7 @@ declare const CreateSubaccountPolicyInputSchema: v.SchemaWithPipe<readonly [v.St
124
124
  readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
125
125
  }, undefined>, undefined>, readonly []>;
126
126
  readonly spotMarketScope: v.SchemaWithPipe<readonly [v.PicklistSchema<readonly ["all", "allowlist"], undefined>, v.TransformAction<"all" | "allowlist", MarketScope_Value.ALL | MarketScope_Value.ALLOWLIST>]>;
127
- readonly actions: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["trade-spot", "internal-transfer", "external-withdraw", "read-balances", "read-spot", "read-internal-transfers", "read-address-book", "manage-address-book", "read-auto-withdraw", "manage-auto-withdraw", "swap"], undefined>, undefined>, readonly []>, v.TransformAction<("swap" | "trade-spot" | "internal-transfer" | "external-withdraw" | "read-balances" | "read-spot" | "read-internal-transfers" | "read-address-book" | "manage-address-book" | "read-auto-withdraw" | "manage-auto-withdraw")[], (PolicyAction.TRADE_SPOT | PolicyAction.INTERNAL_TRANSFER | PolicyAction.EXTERNAL_WITHDRAW | PolicyAction.READ_BALANCES | PolicyAction.READ_SPOT | PolicyAction.READ_INTERNAL_TRANSFERS | PolicyAction.READ_ADDRESS_BOOK | PolicyAction.MANAGE_ADDRESS_BOOK | PolicyAction.READ_AUTO_WITHDRAW | PolicyAction.MANAGE_AUTO_WITHDRAW | PolicyAction.SWAP)[]>]>;
127
+ readonly actions: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["trade-spot", "internal-transfer", "external-withdraw", "read-balances", "read-spot", "read-internal-transfers", "read-address-book", "manage-address-book", "read-auto-withdraw", "manage-auto-withdraw", "swap", "read-statements", "convert-dust", "read-funding-flows"], undefined>, undefined>, readonly []>, v.TransformAction<("swap" | "trade-spot" | "internal-transfer" | "external-withdraw" | "read-balances" | "read-spot" | "read-internal-transfers" | "read-address-book" | "manage-address-book" | "read-auto-withdraw" | "manage-auto-withdraw" | "read-statements" | "convert-dust" | "read-funding-flows")[], (PolicyAction.TRADE_SPOT | PolicyAction.INTERNAL_TRANSFER | PolicyAction.EXTERNAL_WITHDRAW | PolicyAction.READ_BALANCES | PolicyAction.READ_SPOT | PolicyAction.READ_INTERNAL_TRANSFERS | PolicyAction.READ_ADDRESS_BOOK | PolicyAction.MANAGE_ADDRESS_BOOK | PolicyAction.READ_AUTO_WITHDRAW | PolicyAction.MANAGE_AUTO_WITHDRAW | PolicyAction.SWAP | PolicyAction.READ_STATEMENTS | PolicyAction.CONVERT_DUST | PolicyAction.READ_FUNDING_FLOWS)[]>]>;
128
128
  readonly maxOrderSize: v.SchemaWithPipe<readonly [v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, bigint>]>, undefined>, null>, v.TransformAction<bigint | null, bigint>]>;
129
129
  readonly maxOpenOrders: v.SchemaWithPipe<readonly [v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>, null>, v.TransformAction<number | null, number>]>;
130
130
  readonly tradingHalted: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
@@ -139,7 +139,7 @@ declare const CreateSubaccountPolicyInputSchema: v.SchemaWithPipe<readonly [v.St
139
139
  symbolId: number;
140
140
  }[];
141
141
  spotMarketScope: MarketScope_Value.ALL | MarketScope_Value.ALLOWLIST;
142
- actions: (PolicyAction.TRADE_SPOT | PolicyAction.INTERNAL_TRANSFER | PolicyAction.EXTERNAL_WITHDRAW | PolicyAction.READ_BALANCES | PolicyAction.READ_SPOT | PolicyAction.READ_INTERNAL_TRANSFERS | PolicyAction.READ_ADDRESS_BOOK | PolicyAction.MANAGE_ADDRESS_BOOK | PolicyAction.READ_AUTO_WITHDRAW | PolicyAction.MANAGE_AUTO_WITHDRAW | PolicyAction.SWAP)[];
142
+ actions: (PolicyAction.TRADE_SPOT | PolicyAction.INTERNAL_TRANSFER | PolicyAction.EXTERNAL_WITHDRAW | PolicyAction.READ_BALANCES | PolicyAction.READ_SPOT | PolicyAction.READ_INTERNAL_TRANSFERS | PolicyAction.READ_ADDRESS_BOOK | PolicyAction.MANAGE_ADDRESS_BOOK | PolicyAction.READ_AUTO_WITHDRAW | PolicyAction.MANAGE_AUTO_WITHDRAW | PolicyAction.SWAP | PolicyAction.READ_STATEMENTS | PolicyAction.CONVERT_DUST | PolicyAction.READ_FUNDING_FLOWS)[];
143
143
  maxOrderSize: bigint;
144
144
  maxOpenOrders: number;
145
145
  tradingHalted: boolean;
@@ -159,7 +159,7 @@ declare const CreateSubaccountPolicyInputSchema: v.SchemaWithPipe<readonly [v.St
159
159
  symbolId: number;
160
160
  }[];
161
161
  spotMarketScope: MarketScope_Value.ALL | MarketScope_Value.ALLOWLIST;
162
- actions: (PolicyAction.TRADE_SPOT | PolicyAction.INTERNAL_TRANSFER | PolicyAction.EXTERNAL_WITHDRAW | PolicyAction.READ_BALANCES | PolicyAction.READ_SPOT | PolicyAction.READ_INTERNAL_TRANSFERS | PolicyAction.READ_ADDRESS_BOOK | PolicyAction.MANAGE_ADDRESS_BOOK | PolicyAction.READ_AUTO_WITHDRAW | PolicyAction.MANAGE_AUTO_WITHDRAW | PolicyAction.SWAP)[];
162
+ actions: (PolicyAction.TRADE_SPOT | PolicyAction.INTERNAL_TRANSFER | PolicyAction.EXTERNAL_WITHDRAW | PolicyAction.READ_BALANCES | PolicyAction.READ_SPOT | PolicyAction.READ_INTERNAL_TRANSFERS | PolicyAction.READ_ADDRESS_BOOK | PolicyAction.MANAGE_ADDRESS_BOOK | PolicyAction.READ_AUTO_WITHDRAW | PolicyAction.MANAGE_AUTO_WITHDRAW | PolicyAction.SWAP | PolicyAction.READ_STATEMENTS | PolicyAction.CONVERT_DUST | PolicyAction.READ_FUNDING_FLOWS)[];
163
163
  maxOpenOrders: number;
164
164
  tradingHalted: boolean;
165
165
  };
@@ -175,7 +175,7 @@ declare const UpdateSubaccountPolicyInputSchema: v.SchemaWithPipe<readonly [v.St
175
175
  readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
176
176
  }, undefined>, undefined>, undefined>;
177
177
  readonly spotMarketScope: v.OptionalSchema<v.PicklistSchema<readonly ["all", "allowlist"], undefined>, undefined>;
178
- readonly actions: v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["trade-spot", "internal-transfer", "external-withdraw", "read-balances", "read-spot", "read-internal-transfers", "read-address-book", "manage-address-book", "read-auto-withdraw", "manage-auto-withdraw", "swap"], undefined>, undefined>, undefined>;
178
+ readonly actions: v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["trade-spot", "internal-transfer", "external-withdraw", "read-balances", "read-spot", "read-internal-transfers", "read-address-book", "manage-address-book", "read-auto-withdraw", "manage-auto-withdraw", "swap", "read-statements", "convert-dust", "read-funding-flows"], undefined>, undefined>, undefined>;
179
179
  readonly maxOrderSize: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, bigint>]>, undefined>, undefined>;
180
180
  readonly maxOpenOrders: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>, undefined>;
181
181
  readonly tradingHalted: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
@@ -191,7 +191,7 @@ declare const UpdateSubaccountPolicyInputSchema: v.SchemaWithPipe<readonly [v.St
191
191
  symbolId: number;
192
192
  }[] | undefined;
193
193
  spotMarketScope?: "all" | "allowlist" | undefined;
194
- actions?: ("swap" | "trade-spot" | "internal-transfer" | "external-withdraw" | "read-balances" | "read-spot" | "read-internal-transfers" | "read-address-book" | "manage-address-book" | "read-auto-withdraw" | "manage-auto-withdraw")[] | undefined;
194
+ actions?: ("swap" | "trade-spot" | "internal-transfer" | "external-withdraw" | "read-balances" | "read-spot" | "read-internal-transfers" | "read-address-book" | "manage-address-book" | "read-auto-withdraw" | "manage-auto-withdraw" | "read-statements" | "convert-dust" | "read-funding-flows")[] | undefined;
195
195
  maxOrderSize?: bigint | null | undefined;
196
196
  maxOpenOrders?: number | null | undefined;
197
197
  tradingHalted?: boolean | undefined;
@@ -207,7 +207,7 @@ declare const UpdateSubaccountPolicyInputSchema: v.SchemaWithPipe<readonly [v.St
207
207
  symbolId: number;
208
208
  }[] | undefined;
209
209
  spotMarketScope?: "all" | "allowlist" | undefined;
210
- actions?: ("swap" | "trade-spot" | "internal-transfer" | "external-withdraw" | "read-balances" | "read-spot" | "read-internal-transfers" | "read-address-book" | "manage-address-book" | "read-auto-withdraw" | "manage-auto-withdraw")[] | undefined;
210
+ actions?: ("swap" | "trade-spot" | "internal-transfer" | "external-withdraw" | "read-balances" | "read-spot" | "read-internal-transfers" | "read-address-book" | "manage-address-book" | "read-auto-withdraw" | "manage-auto-withdraw" | "read-statements" | "convert-dust" | "read-funding-flows")[] | undefined;
211
211
  maxOrderSize?: bigint | null | undefined;
212
212
  maxOpenOrders?: number | null | undefined;
213
213
  tradingHalted?: boolean | undefined;
@@ -3,11 +3,11 @@ import { PROTOBUF_UINT32_MAX } from "../../../shared/wire-bounds.js";
3
3
  import { tsObjToMs, tsObjToNsString } from "../../../utils/time.js";
4
4
  import { BigIntStringSchema, OptionalNumberToIntOrZeroSchema, OptionalPublicIdSchema, OptionalTimestampMsSchema, PublicIdSchema, TimestampMsSchema, TimestampSchema, idInputSchema, optionalSubaccountIdInputSchema, positiveBigintStringInputSchema } from "../../../shared/schemas.js";
5
5
  import { decimalInputToScaled, scaledToDecimalOutput } from "../../../shared/decimal-surface.js";
6
- import { AccountScopeInputEntries, accountScopeToSubaccountId } from "../../../shared/account-scope.js";
7
- import { buildProtoPatch, defineProtoPatchFields } from "../../../utils/proto-patch.js";
6
+ import { msToTimestamp } from "../../../utils/timestamp.js";
8
7
  import { PolicyActionCodec, PolicyMarketScopeCodec, policyActionLabelFor, policyMarketScopeLabelFor } from "../shared.codecs.js";
8
+ import { buildProtoPatch, defineProtoPatchFields } from "../../../utils/proto-patch.js";
9
+ import { AccountScopeInputEntries, accountScopeToSubaccountId } from "../../../shared/account-scope.js";
9
10
  import { PolicyMarketScopeEnumSchema, ProtoPolicyActionEnumSchema, ProtoPolicyMarketScopeEnumSchema, SpotMarketRuleSchema, SubaccountPolicyActionEnumSchema } from "../shared.js";
10
- import { msToTimestamp } from "../../../utils/timestamp.js";
11
11
  import * as v from "valibot";
12
12
  //#region src/services/policies/subaccount-policies/subaccount-policies.schemas.ts
13
13
  const ListSubaccountPoliciesInputSchema = v.pipe(v.strictObject(AccountScopeInputEntries), v.transform(({ account }) => ({ subaccountId: accountScopeToSubaccountId(account) })));
@@ -167,33 +167,7 @@ const ApplySubaccountPolicyInputSchema = v.strictObject({
167
167
  subaccountId: idInputSchema("subaccountId"),
168
168
  policyId: v.pipe(v.nullable(v.pipe(v.string(), v.trim())), v.transform((value) => value ? idToBigInt(value, "policyId") : void 0))
169
169
  });
170
- const DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT = Date.now();
171
- const DEFAULT_SUBACCOUNT_POLICY = {
172
- id: "",
173
- name: "Subaccount Policy",
174
- description: "Subaccount Policy description",
175
- spotMarkets: [],
176
- spotMarketScope: "all",
177
- actions: [
178
- "read-balances",
179
- "read-internal-transfers",
180
- "read-address-book",
181
- "read-spot"
182
- ],
183
- maxOrderSize: "0",
184
- maxOpenOrders: 0,
185
- tradingHalted: false,
186
- createdAt: DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT,
187
- updatedAt: DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT,
188
- updatedAtNs: (BigInt(DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT) * 1000000n).toString(),
189
- isTemplate: false,
190
- sourceTemplateId: void 0,
191
- locked: false,
192
- reviewAt: void 0,
193
- expiresAt: void 0,
194
- revision: "0"
195
- };
196
170
  //#endregion
197
- export { ApplySubaccountPolicyInputSchema, CreateSubaccountPolicyInputSchema, DEFAULT_SUBACCOUNT_POLICY, GetSubaccountPolicyInputSchema, ListSubaccountPoliciesInputSchema, PolicyIdSchema, SubaccountPolicySchema, UpdateSubaccountPolicyInputSchema };
171
+ export { ApplySubaccountPolicyInputSchema, CreateSubaccountPolicyInputSchema, GetSubaccountPolicyInputSchema, ListSubaccountPoliciesInputSchema, PolicyIdSchema, SubaccountPolicySchema, UpdateSubaccountPolicyInputSchema };
198
172
 
199
173
  //# sourceMappingURL=subaccount-policies.schemas.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"subaccount-policies.schemas.js","names":[],"sources":["../../../../src/services/policies/subaccount-policies/subaccount-policies.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport {\n PolicyMarketScopeEnumSchema,\n ProtoPolicyActionEnumSchema,\n ProtoPolicyMarketScopeEnumSchema,\n SpotMarketRuleSchema,\n SubaccountPolicyActionEnumSchema,\n} from \"../shared.js\";\nimport {\n PolicyMarketScopeCodec,\n PolicyActionCodec,\n policyMarketScopeLabelFor,\n policyActionLabelFor,\n} from \"../shared.codecs.js\";\nimport { idToBigInt } from \"../../../utils/base58-id.js\";\nimport {\n OptionalNumberToIntOrZeroSchema,\n OptionalPublicIdSchema,\n OptionalTimestampMsSchema,\n BigIntStringSchema,\n PublicIdSchema,\n TimestampSchema,\n TimestampMsSchema,\n idInputSchema,\n optionalSubaccountIdInputSchema,\n positiveBigintStringInputSchema,\n} from \"../../../shared/schemas.js\";\nimport { tsObjToMs, tsObjToNsString } from \"../../../utils/time.js\";\nimport { msToTimestamp } from \"../../../utils/timestamp.js\";\nimport {\n QUOTE_NOTIONAL_SCALE,\n decimalInputToScaled,\n scaledToDecimalOutput,\n} from \"../../../shared/decimal-surface.js\";\nimport { PROTOBUF_UINT32_MAX } from \"../../../shared/wire-bounds.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../../shared/account-scope.js\";\nimport { buildProtoPatch, defineProtoPatchFields } from \"../../../utils/proto-patch.js\";\n\nexport const ListSubaccountPoliciesInputSchema = v.pipe(\n v.strictObject(AccountScopeInputEntries),\n v.transform(({ account }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type ListSubaccountPoliciesInput = v.InferInput<typeof ListSubaccountPoliciesInputSchema>;\n\nexport const GetSubaccountPolicyInputSchema = v.pipe(\n v.strictObject({\n policyId: v.pipe(v.string(), v.trim(), v.minLength(1)),\n ...AccountScopeInputEntries,\n }),\n v.transform(({ policyId, account }) => ({\n policyId: idToBigInt(policyId, \"policyId\"),\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type GetSubaccountPolicyInput = v.InferInput<typeof GetSubaccountPolicyInputSchema>;\n\n/**\n * From the backend format to a usable frontend/UI format, so big ints to numbers, etc.\n */\nexport const SubaccountPolicySchema = v.pipe(\n v.object({\n id: PublicIdSchema,\n name: v.string(),\n description: v.string(),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema), []),\n spotMarketScope: v.pipe(\n ProtoPolicyMarketScopeEnumSchema,\n v.transform((v) => policyMarketScopeLabelFor(v)),\n ),\n actions: v.pipe(\n v.optional(v.array(ProtoPolicyActionEnumSchema), []),\n v.transform((v) => v.map((action) => policyActionLabelFor(action))),\n ),\n isTemplate: v.optional(v.boolean(), false),\n sourceTemplateId: OptionalPublicIdSchema,\n maxOrderNotional: v.pipe(\n v.bigint(),\n v.transform((value) => scaledToDecimalOutput(value, QUOTE_NOTIONAL_SCALE)),\n ),\n maxOpenOrders: v.number(),\n tradingHalted: v.boolean(),\n locked: v.boolean(),\n reviewAt: OptionalTimestampMsSchema,\n expiresAt: OptionalTimestampMsSchema,\n createdAt: TimestampMsSchema,\n updatedAt: TimestampSchema,\n revision: BigIntStringSchema,\n }),\n v.transform(({ maxOrderNotional, updatedAt, ...rest }) => ({\n maxOrderSize: maxOrderNotional,\n ...rest,\n updatedAt: tsObjToMs(updatedAt),\n updatedAtNs: tsObjToNsString(updatedAt),\n })),\n);\n\nexport type SubaccountPolicy = v.InferOutput<typeof SubaccountPolicySchema>;\n\n/**\n * Max spot order notional as a decimal USDT string (e.g. `\"100000.5\"`). The wire\n * field is canonical quote microunits, so `\"100000\"` caps orders at 100,000 USDT.\n * `\"0\"` means no cap.\n */\nconst MaxOrderSizeInputSchema = v.pipe(\n v.string(),\n v.transform((value) => decimalInputToScaled(\"maxOrderSize\", value, QUOTE_NOTIONAL_SCALE)),\n);\n\nconst OptionalMaxOrderSizeInputSchema = v.pipe(\n v.optional(v.nullable(MaxOrderSizeInputSchema), null),\n v.transform((value) => value ?? 0n),\n);\n\nconst SubaccountPolicyInputBaseSchema = v.strictObject({\n name: v.string(),\n description: v.optional(v.string(), \"\"),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema), []),\n spotMarketScope: v.pipe(\n PolicyMarketScopeEnumSchema,\n v.transform((v) => PolicyMarketScopeCodec.inputToProto[v]),\n ),\n actions: v.pipe(\n v.optional(v.array(SubaccountPolicyActionEnumSchema), []),\n v.transform((v) => (v ?? []).map((action) => PolicyActionCodec.inputToProto[action])),\n ),\n maxOrderSize: OptionalMaxOrderSizeInputSchema,\n maxOpenOrders: OptionalNumberToIntOrZeroSchema,\n tradingHalted: v.optional(v.boolean(), false),\n policyLocked: v.optional(v.boolean(), false),\n reviewAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n expiresAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n subaccountId: optionalSubaccountIdInputSchema(),\n});\n\nfunction timestampFromMs(value: number | null | undefined) {\n if (value == null) return undefined;\n return msToTimestamp(value);\n}\n\nfunction createSubaccountPolicyBaseTransform(\n input: v.InferOutput<typeof SubaccountPolicyInputBaseSchema>,\n) {\n const {\n subaccountId: _subaccountId,\n reviewAt,\n expiresAt,\n maxOrderSize,\n policyLocked,\n ...rest\n } = input;\n return {\n ...rest,\n maxOrderNotional: maxOrderSize,\n locked: policyLocked,\n reviewAt: timestampFromMs(reviewAt),\n expiresAt: timestampFromMs(expiresAt),\n };\n}\n\nexport const CreateSubaccountPolicyInputSchema = v.pipe(\n SubaccountPolicyInputBaseSchema,\n v.transform((input) => ({\n policy: createSubaccountPolicyBaseTransform(input),\n subaccountId: input.subaccountId,\n })),\n);\nexport type SubaccountPolicyCreateInput = v.InferInput<typeof CreateSubaccountPolicyInputSchema>;\n\nconst SubaccountPolicyPatchSchema = v.strictObject({\n name: v.optional(v.string()),\n description: v.optional(v.string()),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema)),\n spotMarketScope: v.optional(PolicyMarketScopeEnumSchema),\n actions: v.optional(v.array(SubaccountPolicyActionEnumSchema)),\n maxOrderSize: v.optional(v.nullable(MaxOrderSizeInputSchema)),\n maxOpenOrders: v.optional(\n v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(PROTOBUF_UINT32_MAX))),\n ),\n tradingHalted: v.optional(v.boolean()),\n policyLocked: v.optional(v.boolean()),\n reviewAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n expiresAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n});\n\ntype SubaccountPolicyPatch = v.InferOutput<typeof SubaccountPolicyPatchSchema>;\n\nconst SUBACCOUNT_POLICY_PATCH_FIELDS = defineProtoPatchFields<SubaccountPolicyPatch>()({\n name: { path: \"name\", encode: (name) => ({ name }) },\n description: { path: \"description\", encode: (description) => ({ description }) },\n spotMarkets: { path: \"spot_markets\", encode: (spotMarkets) => ({ spotMarkets }) },\n spotMarketScope: {\n path: \"spot_market_scope\",\n encode: (scope) => ({ spotMarketScope: PolicyMarketScopeCodec.inputToProto[scope] }),\n },\n actions: {\n path: \"actions\",\n encode: (actions) => ({\n actions: actions.map((action) => PolicyActionCodec.inputToProto[action]),\n }),\n },\n maxOrderSize: {\n path: \"max_order_notional\",\n encode: (value) => ({ maxOrderNotional: value ?? 0n }),\n },\n maxOpenOrders: {\n path: \"max_open_orders\",\n encode: (value) => ({ maxOpenOrders: value ?? 0 }),\n },\n tradingHalted: {\n path: \"trading_halted\",\n encode: (tradingHalted) => ({ tradingHalted }),\n },\n policyLocked: { path: \"locked\", encode: (locked) => ({ locked }) },\n reviewAt: {\n path: \"review_at\",\n encode: (reviewAt) => {\n const timestamp = timestampFromMs(reviewAt);\n return timestamp === undefined ? {} : { reviewAt: timestamp };\n },\n },\n expiresAt: {\n path: \"expires_at\",\n encode: (expiresAt) => {\n const timestamp = timestampFromMs(expiresAt);\n return timestamp === undefined ? {} : { expiresAt: timestamp };\n },\n },\n});\n\nexport const UpdateSubaccountPolicyInputSchema = v.pipe(\n v.strictObject({\n ...SubaccountPolicyPatchSchema.entries,\n policyId: v.pipe(\n v.string(),\n v.transform((v) => idToBigInt(v, \"policyId\")),\n ),\n expectedRevision: positiveBigintStringInputSchema(\"expectedRevision\"),\n }),\n v.check(\n ({ policyId: _policyId, expectedRevision: _expectedRevision, ...patch }) =>\n Object.values(patch).some((value) => value !== undefined),\n \"At least one subaccount policy field must be provided\",\n ),\n v.transform(({ policyId, expectedRevision, ...patch }) => {\n const { patch: policy, updateMask } = buildProtoPatch(\n patch,\n SUBACCOUNT_POLICY_PATCH_FIELDS,\n );\n return {\n policyId,\n policy,\n updateMask,\n expectedRevision,\n };\n }),\n);\nexport type SubaccountPolicyUpdateInput = v.InferInput<typeof UpdateSubaccountPolicyInputSchema>;\n\nexport const PolicyIdSchema = v.pipe(\n v.string(),\n v.trim(),\n v.minLength(1),\n v.transform((v) => idToBigInt(v, \"policyId\")),\n);\n\nexport const ApplySubaccountPolicyInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n policyId: v.pipe(\n v.nullable(v.pipe(v.string(), v.trim())),\n v.transform((value) => (value ? idToBigInt(value, \"policyId\") : undefined)),\n ),\n});\n\nexport type SubaccountPolicyApplyInput = v.InferInput<typeof ApplySubaccountPolicyInputSchema>;\n\nconst DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT = Date.now();\n\nexport const DEFAULT_SUBACCOUNT_POLICY: SubaccountPolicy = {\n id: \"\",\n name: \"Subaccount Policy\",\n description: \"Subaccount Policy description\",\n spotMarkets: [],\n spotMarketScope: \"all\",\n actions: [\"read-balances\", \"read-internal-transfers\", \"read-address-book\", \"read-spot\"],\n maxOrderSize: \"0\",\n maxOpenOrders: 0,\n tradingHalted: false,\n createdAt: DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT,\n updatedAt: DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT,\n updatedAtNs: (BigInt(DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT) * 1_000_000n).toString(),\n isTemplate: false,\n sourceTemplateId: undefined,\n locked: false,\n reviewAt: undefined,\n expiresAt: undefined,\n revision: \"0\",\n};\n"],"mappings":";;;;;;;;;;;;AAyCA,MAAa,oCAAoC,EAAE,KAC/C,EAAE,aAAa,wBAAwB,GACvC,EAAE,WAAW,EAAE,eAAe,EAC1B,cAAc,2BAA2B,OAAO,EACpD,EAAE,CACN;AAIA,MAAa,iCAAiC,EAAE,KAC5C,EAAE,aAAa;CACX,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK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R,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,CAAC,GACvC,EAAE,WAAW,UAAW,QAAQ,WAAW,OAAO,UAAU,IAAI,KAAA,CAAU,CAC9E;AACJ,CAAC;AAID,MAAM,uCAAuC,KAAK,IAAI;AAEtD,MAAa,4BAA8C;CACvD,IAAI;CACJ,MAAM;CACN,aAAa;CACb,aAAa,CAAC;CACd,iBAAiB;CACjB,SAAS;EAAC;EAAiB;EAA2B;EAAqB;CAAW;CACtF,cAAc;CACd,eAAe;CACf,eAAe;CACf,WAAW;CACX,WAAW;CACX,cAAc,OAAO,oCAAoC,IAAI,SAAA,CAAY,SAAS;CAClF,YAAY;CACZ,kBAAkB,KAAA;CAClB,QAAQ;CACR,UAAU,KAAA;CACV,WAAW,KAAA;CACX,UAAU;AACd"}
1
+ {"version":3,"file":"subaccount-policies.schemas.js","names":[],"sources":["../../../../src/services/policies/subaccount-policies/subaccount-policies.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport {\n PolicyMarketScopeEnumSchema,\n ProtoPolicyActionEnumSchema,\n ProtoPolicyMarketScopeEnumSchema,\n SpotMarketRuleSchema,\n SubaccountPolicyActionEnumSchema,\n} from \"../shared.js\";\nimport {\n PolicyMarketScopeCodec,\n PolicyActionCodec,\n policyMarketScopeLabelFor,\n policyActionLabelFor,\n} from \"../shared.codecs.js\";\nimport { idToBigInt } from \"../../../utils/base58-id.js\";\nimport {\n OptionalNumberToIntOrZeroSchema,\n OptionalPublicIdSchema,\n OptionalTimestampMsSchema,\n BigIntStringSchema,\n PublicIdSchema,\n TimestampSchema,\n TimestampMsSchema,\n idInputSchema,\n optionalSubaccountIdInputSchema,\n positiveBigintStringInputSchema,\n} from \"../../../shared/schemas.js\";\nimport { tsObjToMs, tsObjToNsString } from \"../../../utils/time.js\";\nimport { msToTimestamp } from \"../../../utils/timestamp.js\";\nimport {\n QUOTE_NOTIONAL_SCALE,\n decimalInputToScaled,\n scaledToDecimalOutput,\n} from \"../../../shared/decimal-surface.js\";\nimport { PROTOBUF_UINT32_MAX } from \"../../../shared/wire-bounds.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../../shared/account-scope.js\";\nimport { buildProtoPatch, defineProtoPatchFields } from \"../../../utils/proto-patch.js\";\n\nexport const ListSubaccountPoliciesInputSchema = v.pipe(\n v.strictObject(AccountScopeInputEntries),\n v.transform(({ account }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type ListSubaccountPoliciesInput = v.InferInput<typeof ListSubaccountPoliciesInputSchema>;\n\nexport const GetSubaccountPolicyInputSchema = v.pipe(\n v.strictObject({\n policyId: v.pipe(v.string(), v.trim(), v.minLength(1)),\n ...AccountScopeInputEntries,\n }),\n v.transform(({ policyId, account }) => ({\n policyId: idToBigInt(policyId, \"policyId\"),\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type GetSubaccountPolicyInput = v.InferInput<typeof GetSubaccountPolicyInputSchema>;\n\n/**\n * From the backend format to a usable frontend/UI format, so big ints to numbers, etc.\n */\nexport const SubaccountPolicySchema = v.pipe(\n v.object({\n id: PublicIdSchema,\n name: v.string(),\n description: v.string(),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema), []),\n spotMarketScope: v.pipe(\n ProtoPolicyMarketScopeEnumSchema,\n v.transform((v) => policyMarketScopeLabelFor(v)),\n ),\n actions: v.pipe(\n v.optional(v.array(ProtoPolicyActionEnumSchema), []),\n v.transform((v) => v.map((action) => policyActionLabelFor(action))),\n ),\n isTemplate: v.optional(v.boolean(), false),\n sourceTemplateId: OptionalPublicIdSchema,\n maxOrderNotional: v.pipe(\n v.bigint(),\n v.transform((value) => scaledToDecimalOutput(value, QUOTE_NOTIONAL_SCALE)),\n ),\n maxOpenOrders: v.number(),\n tradingHalted: v.boolean(),\n locked: v.boolean(),\n reviewAt: OptionalTimestampMsSchema,\n expiresAt: OptionalTimestampMsSchema,\n createdAt: TimestampMsSchema,\n updatedAt: TimestampSchema,\n revision: BigIntStringSchema,\n }),\n v.transform(({ maxOrderNotional, updatedAt, ...rest }) => ({\n maxOrderSize: maxOrderNotional,\n ...rest,\n updatedAt: tsObjToMs(updatedAt),\n updatedAtNs: tsObjToNsString(updatedAt),\n })),\n);\n\nexport type SubaccountPolicy = v.InferOutput<typeof SubaccountPolicySchema>;\n\n/**\n * Max spot order notional as a decimal USDT string (e.g. `\"100000.5\"`). The wire\n * field is canonical quote microunits, so `\"100000\"` caps orders at 100,000 USDT.\n * `\"0\"` means no cap.\n */\nconst MaxOrderSizeInputSchema = v.pipe(\n v.string(),\n v.transform((value) => decimalInputToScaled(\"maxOrderSize\", value, QUOTE_NOTIONAL_SCALE)),\n);\n\nconst OptionalMaxOrderSizeInputSchema = v.pipe(\n v.optional(v.nullable(MaxOrderSizeInputSchema), null),\n v.transform((value) => value ?? 0n),\n);\n\nconst SubaccountPolicyInputBaseSchema = v.strictObject({\n name: v.string(),\n description: v.optional(v.string(), \"\"),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema), []),\n spotMarketScope: v.pipe(\n PolicyMarketScopeEnumSchema,\n v.transform((v) => PolicyMarketScopeCodec.inputToProto[v]),\n ),\n actions: v.pipe(\n v.optional(v.array(SubaccountPolicyActionEnumSchema), []),\n v.transform((v) => (v ?? []).map((action) => PolicyActionCodec.inputToProto[action])),\n ),\n maxOrderSize: OptionalMaxOrderSizeInputSchema,\n maxOpenOrders: OptionalNumberToIntOrZeroSchema,\n tradingHalted: v.optional(v.boolean(), false),\n policyLocked: v.optional(v.boolean(), false),\n reviewAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n expiresAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n subaccountId: optionalSubaccountIdInputSchema(),\n});\n\nfunction timestampFromMs(value: number | null | undefined) {\n if (value == null) return undefined;\n return msToTimestamp(value);\n}\n\nfunction createSubaccountPolicyBaseTransform(\n input: v.InferOutput<typeof SubaccountPolicyInputBaseSchema>,\n) {\n const {\n subaccountId: _subaccountId,\n reviewAt,\n expiresAt,\n maxOrderSize,\n policyLocked,\n ...rest\n } = input;\n return {\n ...rest,\n maxOrderNotional: maxOrderSize,\n locked: policyLocked,\n reviewAt: timestampFromMs(reviewAt),\n expiresAt: timestampFromMs(expiresAt),\n };\n}\n\nexport const CreateSubaccountPolicyInputSchema = v.pipe(\n SubaccountPolicyInputBaseSchema,\n v.transform((input) => ({\n policy: createSubaccountPolicyBaseTransform(input),\n subaccountId: input.subaccountId,\n })),\n);\nexport type SubaccountPolicyCreateInput = v.InferInput<typeof CreateSubaccountPolicyInputSchema>;\n\nconst SubaccountPolicyPatchSchema = v.strictObject({\n name: v.optional(v.string()),\n description: v.optional(v.string()),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema)),\n spotMarketScope: v.optional(PolicyMarketScopeEnumSchema),\n actions: v.optional(v.array(SubaccountPolicyActionEnumSchema)),\n maxOrderSize: v.optional(v.nullable(MaxOrderSizeInputSchema)),\n maxOpenOrders: v.optional(\n v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(PROTOBUF_UINT32_MAX))),\n ),\n tradingHalted: v.optional(v.boolean()),\n policyLocked: v.optional(v.boolean()),\n reviewAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n expiresAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n});\n\ntype SubaccountPolicyPatch = v.InferOutput<typeof SubaccountPolicyPatchSchema>;\n\nconst SUBACCOUNT_POLICY_PATCH_FIELDS = defineProtoPatchFields<SubaccountPolicyPatch>()({\n name: { path: \"name\", encode: (name) => ({ name }) },\n description: { path: \"description\", encode: (description) => ({ description }) },\n spotMarkets: { path: \"spot_markets\", encode: (spotMarkets) => ({ spotMarkets }) },\n spotMarketScope: {\n path: \"spot_market_scope\",\n encode: (scope) => ({ spotMarketScope: PolicyMarketScopeCodec.inputToProto[scope] }),\n },\n actions: {\n path: \"actions\",\n encode: (actions) => ({\n actions: actions.map((action) => PolicyActionCodec.inputToProto[action]),\n }),\n },\n maxOrderSize: {\n path: \"max_order_notional\",\n encode: (value) => ({ maxOrderNotional: value ?? 0n }),\n },\n maxOpenOrders: {\n path: \"max_open_orders\",\n encode: (value) => ({ maxOpenOrders: value ?? 0 }),\n },\n tradingHalted: {\n path: \"trading_halted\",\n encode: (tradingHalted) => ({ tradingHalted }),\n },\n policyLocked: { path: \"locked\", encode: (locked) => ({ locked }) },\n reviewAt: {\n path: \"review_at\",\n encode: (reviewAt) => {\n const timestamp = timestampFromMs(reviewAt);\n return timestamp === undefined ? {} : { reviewAt: timestamp };\n },\n },\n expiresAt: {\n path: \"expires_at\",\n encode: (expiresAt) => {\n const timestamp = timestampFromMs(expiresAt);\n return timestamp === undefined ? {} : { expiresAt: timestamp };\n },\n },\n});\n\nexport const UpdateSubaccountPolicyInputSchema = v.pipe(\n v.strictObject({\n ...SubaccountPolicyPatchSchema.entries,\n policyId: v.pipe(\n v.string(),\n v.transform((v) => idToBigInt(v, \"policyId\")),\n ),\n expectedRevision: positiveBigintStringInputSchema(\"expectedRevision\"),\n }),\n v.check(\n ({ policyId: _policyId, expectedRevision: _expectedRevision, ...patch }) =>\n Object.values(patch).some((value) => value !== undefined),\n \"At least one subaccount policy field must be provided\",\n ),\n v.transform(({ policyId, expectedRevision, ...patch }) => {\n const { patch: policy, updateMask } = buildProtoPatch(\n patch,\n SUBACCOUNT_POLICY_PATCH_FIELDS,\n );\n return {\n policyId,\n policy,\n updateMask,\n expectedRevision,\n };\n }),\n);\nexport type SubaccountPolicyUpdateInput = v.InferInput<typeof UpdateSubaccountPolicyInputSchema>;\n\nexport const PolicyIdSchema = v.pipe(\n v.string(),\n v.trim(),\n v.minLength(1),\n v.transform((v) => idToBigInt(v, \"policyId\")),\n);\n\nexport const ApplySubaccountPolicyInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n policyId: v.pipe(\n v.nullable(v.pipe(v.string(), v.trim())),\n v.transform((value) => (value ? idToBigInt(value, \"policyId\") : undefined)),\n ),\n});\n\nexport type SubaccountPolicyApplyInput = v.InferInput<typeof ApplySubaccountPolicyInputSchema>;\n"],"mappings":";;;;;;;;;;;;AAyCA,MAAa,oCAAoC,EAAE,KAC/C,EAAE,aAAa,wBAAwB,GACvC,EAAE,WAAW,EAAE,eAAe,EAC1B,cAAc,2BAA2B,OAAO,EACpD,EAAE,CACN;AAIA,MAAa,iCAAiC,EAAE,KAC5C,EAAE,aAAa;CACX,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;CACrD,GAAG;AACP,CAAC,GACD,EAAE,WAAW,EAAE,UAAU,eAAe;CACpC,UAAU,WAAW,UAAU,UAAU;CACzC,cAAc,2BAA2B,OAAO;AACpD,EAAE,CACN;;;;AAOA,MAAa,yBAAyB,EAAE,KACpC,EAAE,OAAO;CACL,IAAI;CACJ,MAAM,EAAE,OAAO;CACf,aAAa,EAAE,OAAO;CACtB,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,GAAG,CAAC,CAAC;CACzD,iBAAiB,EAAE,KACf,kCACA,EAAE,WAAW,MAAM,0BAA0B,CAAC,CAAC,CACnD;CACA,SAAS,EAAE,KACP,EAAE,SAAS,EAAE,MAAM,2BAA2B,GAAG,CAAC,CAAC,GACnD,EAAE,WAAW,MAAM,EAAE,KAAK,WAAW,qBAAqB,MAAM,CAAC,CAAC,CACtE;CACA,YAAY,EAAE,SAAS,EAAE,QAAQ,GAAG,KAAK;CACzC,kBAAkB;CAClB,kBAAkB,EAAE,KAChB,EAAE,OAAO,GACT,EAAE,WAAW,UAAU,sBAAsB,OAAA,CAA2B,CAAC,CAC7E;CACA,eAAe,EAAE,OAAO;CACxB,eAAe,EAAE,QAAQ;CACzB,QAAQ,EAAE,QAAQ;CAClB,UAAU;CACV,WAAW;CACX,WAAW;CACX,WAAW;C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A,CAAS,GAC5D,uDACJ,GACA,EAAE,WAAW,EAAE,UAAU,kBAAkB,GAAG,YAAY;CACtD,MAAM,EAAE,OAAO,QAAQ,eAAe,gBAClC,OACA,8BACJ;CACA,OAAO;EACH;EACA;EACA;EACA;CACJ;AACJ,CAAC,CACL;AAGA,MAAa,iBAAiB,EAAE,KAC5B,EAAE,OAAO,GACT,EAAE,KAAK,GACP,EAAE,UAAU,CAAC,GACb,EAAE,WAAW,MAAM,WAAW,GAAG,UAAU,CAAC,CAChD;AAEA,MAAa,mCAAmC,EAAE,aAAa;CAC3D,cAAc,cAAc,cAAc;CAC1C,UAAU,EAAE,KACR,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,CAAC,GACvC,EAAE,WAAW,UAAW,QAAQ,WAAW,OAAO,UAAU,IAAI,KAAA,CAAU,CAC9E;AACJ,CAAC"}
@@ -16,7 +16,9 @@ declare class PriceAlertsService {
16
16
  constructor(transports: AuthApiTransports);
17
17
  /**
18
18
  * Creates an active alert. Throws `PreconditionFailedError` when the market has no index
19
- * price (`PRICE_SOURCE_UNSUPPORTED`) or the active-alert limit is reached, and a retryable
19
+ * price (`PRICE_SOURCE_UNSUPPORTED`), the active-alert limit is reached, or the `telegram`
20
+ * channel is asked for without a linked Telegram account (`TELEGRAM_NOT_LINKED`) or where
21
+ * Telegram delivery is not available (`TELEGRAM_UNAVAILABLE`), and a retryable
20
22
  * `ServiceUnavailableError` when the market has no current price yet. API keys need
21
23
  * `manage-price-alerts`.
22
24
  */
@@ -27,7 +29,8 @@ declare class PriceAlertsService {
27
29
  * Changes an alert's direction, price or channels; omitted fields stay as they are. A new
28
30
  * direction or price records a new reference price. Updating a triggered alert sets it
29
31
  * again, even with no field given. A stale `expectedRevision` throws
30
- * `RevisionConflictError`; a canceled alert throws `PreconditionFailedError`. API keys need
32
+ * `RevisionConflictError`; a canceled alert, or an alert left with the `telegram` channel
33
+ * when Telegram is not linked or not available, throws `PreconditionFailedError`. API keys need
31
34
  * `manage-price-alerts`.
32
35
  */
33
36
  update(input: UpdatePriceAlertInput, options?: PolyesterRequestOptions): Promise<UpdatePriceAlertResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"price-alerts.d.ts","names":[],"sources":["../../../src/services/price-alerts/price-alerts.ts"],"mappings":";;;;;;;;;;;;;cAmCa;;EAGG,YAAA,YAAY;;;;;;;EAUlB,OACF,OAAO,uBACP,UAAU,0BACX,QAAQ;;EAUL,KACF,QAAO,sBACP,UAAU,0BACX,QAAQ;;;;;;;;EAgBL,OACF,OAAO,uBACP,UAAU,0BACX,QAAQ;;;;;;EAcL,OACF,OAAO,uBACP,UAAU,0BACX,QAAQ"}
1
+ {"version":3,"file":"price-alerts.d.ts","names":[],"sources":["../../../src/services/price-alerts/price-alerts.ts"],"mappings":";;;;;;;;;;;;;cAmCa;;EAGG,YAAA,YAAY;;;;;;;;;EAYlB,OACF,OAAO,uBACP,UAAU,0BACX,QAAQ;;EAUL,KACF,QAAO,sBACP,UAAU,0BACX,QAAQ;;;;;;;;;EAiBL,OACF,OAAO,uBACP,UAAU,0BACX,QAAQ;;;;;;EAcL,OACF,OAAO,uBACP,UAAU,0BACX,QAAQ"}
@@ -21,7 +21,9 @@ var PriceAlertsService = class {
21
21
  }
22
22
  /**
23
23
  * Creates an active alert. Throws `PreconditionFailedError` when the market has no index
24
- * price (`PRICE_SOURCE_UNSUPPORTED`) or the active-alert limit is reached, and a retryable
24
+ * price (`PRICE_SOURCE_UNSUPPORTED`), the active-alert limit is reached, or the `telegram`
25
+ * channel is asked for without a linked Telegram account (`TELEGRAM_NOT_LINKED`) or where
26
+ * Telegram delivery is not available (`TELEGRAM_UNAVAILABLE`), and a retryable
25
27
  * `ServiceUnavailableError` when the market has no current price yet. API keys need
26
28
  * `manage-price-alerts`.
27
29
  */
@@ -40,7 +42,8 @@ var PriceAlertsService = class {
40
42
  * Changes an alert's direction, price or channels; omitted fields stay as they are. A new
41
43
  * direction or price records a new reference price. Updating a triggered alert sets it
42
44
  * again, even with no field given. A stale `expectedRevision` throws
43
- * `RevisionConflictError`; a canceled alert throws `PreconditionFailedError`. API keys need
45
+ * `RevisionConflictError`; a canceled alert, or an alert left with the `telegram` channel
46
+ * when Telegram is not linked or not available, throws `PreconditionFailedError`. API keys need
44
47
  * `manage-price-alerts`.
45
48
  */
46
49
  async update(input, options) {
@@ -1 +1 @@
1
- {"version":3,"file":"price-alerts.js","names":["#client","Proto.PriceAlertService"],"sources":["../../../src/services/price-alerts/price-alerts.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/alerts/v1/price_alerts_pb.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport { parse } from \"../../shared/validation.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport {\n CancelPriceAlertInputSchema,\n CreatePriceAlertInputSchema,\n ListPriceAlertsInputSchema,\n ListPriceAlertsResultSchema,\n PriceAlertSchema,\n UpdatePriceAlertInputSchema,\n UpdatePriceAlertResultSchema,\n type CancelPriceAlertInput,\n type CreatePriceAlertInput,\n type ListPriceAlertsInput,\n type ListPriceAlertsResult,\n type PriceAlert,\n type UpdatePriceAlertInput,\n type UpdatePriceAlertResult,\n} from \"./price-alerts.schemas.js\";\n\n/**\n * Manages the caller's price alerts. Alerts belong to the root account, not a trading account:\n * a session and the root account's API keys see the same alerts, and an API key scoped to a\n * subaccount is refused (`PermissionError`, detail `SUBACCOUNT_KEY_REFUSED`). An API key whose\n * policy lacks the method's permission is refused too (`PermissionError`, detail\n * `AUTH_API_KEY_ACCESS_DENIED`). An alert fires at\n * most once, only on a crossing it observes from its `referencePrice`; `update` sets a fired\n * alert again. No call changes balances, orders or account settings.\n */\nexport class PriceAlertsService {\n #client: Client<typeof Proto.PriceAlertService>;\n\n constructor(transports: AuthApiTransports) {\n this.#client = createClient(Proto.PriceAlertService, transports.authApi);\n }\n\n /**\n * Creates an active alert. Throws `PreconditionFailedError` when the market has no index\n * price (`PRICE_SOURCE_UNSUPPORTED`) or the active-alert limit is reached, and a retryable\n * `ServiceUnavailableError` when the market has no current price yet. API keys need\n * `manage-price-alerts`.\n */\n async create(\n input: CreatePriceAlertInput,\n options?: PolyesterRequestOptions,\n ): Promise<PriceAlert> {\n const request = parse(CreatePriceAlertInputSchema, input);\n const response = await this.#client.createAlert(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(PriceAlertSchema, response.alert);\n }\n\n /** Lists the caller's alerts, newest first. API keys need `read-price-alerts`. */\n async list(\n input: ListPriceAlertsInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<ListPriceAlertsResult> {\n const request = parse(ListPriceAlertsInputSchema, input);\n const response = await this.#client.listAlerts(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(ListPriceAlertsResultSchema, response);\n }\n\n /**\n * Changes an alert's direction, price or channels; omitted fields stay as they are. A new\n * direction or price records a new reference price. Updating a triggered alert sets it\n * again, even with no field given. A stale `expectedRevision` throws\n * `RevisionConflictError`; a canceled alert throws `PreconditionFailedError`. API keys need\n * `manage-price-alerts`.\n */\n async update(\n input: UpdatePriceAlertInput,\n options?: PolyesterRequestOptions,\n ): Promise<UpdatePriceAlertResult> {\n const request = parse(UpdatePriceAlertInputSchema, input);\n const response = await this.#client.updateAlert(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(UpdatePriceAlertResultSchema, response);\n }\n\n /**\n * Cancels an active alert; canceling a canceled alert returns it unchanged. A triggered\n * alert throws `PreconditionFailedError` (`ALERT_TRIGGERED`). API keys need\n * `manage-price-alerts`.\n */\n async cancel(\n input: CancelPriceAlertInput,\n options?: PolyesterRequestOptions,\n ): Promise<PriceAlert> {\n const request = parse(CancelPriceAlertInputSchema, input);\n const response = await this.#client.cancelAlert(request, toConnectCallOptions(options));\n return parse(PriceAlertSchema, response.alert);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmCA,IAAa,qBAAb,MAAgC;CAC5B;CAEA,YAAY,YAA+B;EACvC,KAAKA,UAAU,aAAaC,mBAAyB,WAAW,OAAO;CAC3E;;;;;;;CAQA,MAAM,OACF,OACA,SACmB;EACnB,MAAM,UAAU,MAAM,6BAA6B,KAAK;EACxD,MAAM,WAAW,MAAM,KAAKD,QAAQ,YAChC,gBAAgB,OAAO,GACvB,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,kBAAkB,SAAS,KAAK;CACjD;;CAGA,MAAM,KACF,QAA8B,CAAC,GAC/B,SAC8B;EAC9B,MAAM,UAAU,MAAM,4BAA4B,KAAK;EACvD,MAAM,WAAW,MAAM,KAAKA,QAAQ,WAChC,gBAAgB,OAAO,GACvB,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,6BAA6B,QAAQ;CACtD;;;;;;;;CASA,MAAM,OACF,OACA,SAC+B;EAC/B,MAAM,UAAU,MAAM,6BAA6B,KAAK;EACxD,MAAM,WAAW,MAAM,KAAKA,QAAQ,YAChC,gBAAgB,OAAO,GACvB,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,8BAA8B,QAAQ;CACvD;;;;;;CAOA,MAAM,OACF,OACA,SACmB;EACnB,MAAM,UAAU,MAAM,6BAA6B,KAAK;EACxD,MAAM,WAAW,MAAM,KAAKA,QAAQ,YAAY,SAAS,qBAAqB,OAAO,CAAC;EACtF,OAAO,MAAM,kBAAkB,SAAS,KAAK;CACjD;AACJ"}
1
+ {"version":3,"file":"price-alerts.js","names":["#client","Proto.PriceAlertService"],"sources":["../../../src/services/price-alerts/price-alerts.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/alerts/v1/price_alerts_pb.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport { parse } from \"../../shared/validation.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport {\n CancelPriceAlertInputSchema,\n CreatePriceAlertInputSchema,\n ListPriceAlertsInputSchema,\n ListPriceAlertsResultSchema,\n PriceAlertSchema,\n UpdatePriceAlertInputSchema,\n UpdatePriceAlertResultSchema,\n type CancelPriceAlertInput,\n type CreatePriceAlertInput,\n type ListPriceAlertsInput,\n type ListPriceAlertsResult,\n type PriceAlert,\n type UpdatePriceAlertInput,\n type UpdatePriceAlertResult,\n} from \"./price-alerts.schemas.js\";\n\n/**\n * Manages the caller's price alerts. Alerts belong to the root account, not a trading account:\n * a session and the root account's API keys see the same alerts, and an API key scoped to a\n * subaccount is refused (`PermissionError`, detail `SUBACCOUNT_KEY_REFUSED`). An API key whose\n * policy lacks the method's permission is refused too (`PermissionError`, detail\n * `AUTH_API_KEY_ACCESS_DENIED`). An alert fires at\n * most once, only on a crossing it observes from its `referencePrice`; `update` sets a fired\n * alert again. No call changes balances, orders or account settings.\n */\nexport class PriceAlertsService {\n #client: Client<typeof Proto.PriceAlertService>;\n\n constructor(transports: AuthApiTransports) {\n this.#client = createClient(Proto.PriceAlertService, transports.authApi);\n }\n\n /**\n * Creates an active alert. Throws `PreconditionFailedError` when the market has no index\n * price (`PRICE_SOURCE_UNSUPPORTED`), the active-alert limit is reached, or the `telegram`\n * channel is asked for without a linked Telegram account (`TELEGRAM_NOT_LINKED`) or where\n * Telegram delivery is not available (`TELEGRAM_UNAVAILABLE`), and a retryable\n * `ServiceUnavailableError` when the market has no current price yet. API keys need\n * `manage-price-alerts`.\n */\n async create(\n input: CreatePriceAlertInput,\n options?: PolyesterRequestOptions,\n ): Promise<PriceAlert> {\n const request = parse(CreatePriceAlertInputSchema, input);\n const response = await this.#client.createAlert(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(PriceAlertSchema, response.alert);\n }\n\n /** Lists the caller's alerts, newest first. API keys need `read-price-alerts`. */\n async list(\n input: ListPriceAlertsInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<ListPriceAlertsResult> {\n const request = parse(ListPriceAlertsInputSchema, input);\n const response = await this.#client.listAlerts(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(ListPriceAlertsResultSchema, response);\n }\n\n /**\n * Changes an alert's direction, price or channels; omitted fields stay as they are. A new\n * direction or price records a new reference price. Updating a triggered alert sets it\n * again, even with no field given. A stale `expectedRevision` throws\n * `RevisionConflictError`; a canceled alert, or an alert left with the `telegram` channel\n * when Telegram is not linked or not available, throws `PreconditionFailedError`. API keys need\n * `manage-price-alerts`.\n */\n async update(\n input: UpdatePriceAlertInput,\n options?: PolyesterRequestOptions,\n ): Promise<UpdatePriceAlertResult> {\n const request = parse(UpdatePriceAlertInputSchema, input);\n const response = await this.#client.updateAlert(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(UpdatePriceAlertResultSchema, response);\n }\n\n /**\n * Cancels an active alert; canceling a canceled alert returns it unchanged. A triggered\n * alert throws `PreconditionFailedError` (`ALERT_TRIGGERED`). API keys need\n * `manage-price-alerts`.\n */\n async cancel(\n input: CancelPriceAlertInput,\n options?: PolyesterRequestOptions,\n ): Promise<PriceAlert> {\n const request = parse(CancelPriceAlertInputSchema, input);\n const response = await this.#client.cancelAlert(request, toConnectCallOptions(options));\n return parse(PriceAlertSchema, response.alert);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmCA,IAAa,qBAAb,MAAgC;CAC5B;CAEA,YAAY,YAA+B;EACvC,KAAKA,UAAU,aAAaC,mBAAyB,WAAW,OAAO;CAC3E;;;;;;;;;CAUA,MAAM,OACF,OACA,SACmB;EACnB,MAAM,UAAU,MAAM,6BAA6B,KAAK;EACxD,MAAM,WAAW,MAAM,KAAKD,QAAQ,YAChC,gBAAgB,OAAO,GACvB,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,kBAAkB,SAAS,KAAK;CACjD;;CAGA,MAAM,KACF,QAA8B,CAAC,GAC/B,SAC8B;EAC9B,MAAM,UAAU,MAAM,4BAA4B,KAAK;EACvD,MAAM,WAAW,MAAM,KAAKA,QAAQ,WAChC,gBAAgB,OAAO,GACvB,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,6BAA6B,QAAQ;CACtD;;;;;;;;;CAUA,MAAM,OACF,OACA,SAC+B;EAC/B,MAAM,UAAU,MAAM,6BAA6B,KAAK;EACxD,MAAM,WAAW,MAAM,KAAKA,QAAQ,YAChC,gBAAgB,OAAO,GACvB,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,8BAA8B,QAAQ;CACvD;;;;;;CAOA,MAAM,OACF,OACA,SACmB;EACnB,MAAM,UAAU,MAAM,6BAA6B,KAAK;EACxD,MAAM,WAAW,MAAM,KAAKA,QAAQ,YAAY,SAAS,qBAAqB,OAAO,CAAC;EACtF,OAAO,MAAM,kBAAkB,SAAS,KAAK;CACjD;AACJ"}
@@ -2,8 +2,8 @@ import { PROTOBUF_UINT64_MAX } from "../../shared/wire-bounds.js";
2
2
  import { BigIntStringSchema, OptionalTimestampMsSchema, PublicIdSchema, idInputSchema, positiveBigintStringInputSchema } from "../../shared/schemas.js";
3
3
  import { enumLabelSchema } from "../../shared/proto-enum-codec.js";
4
4
  import { positiveDecimalInputToScaled, scaledToDecimalOutput } from "../../shared/decimal-surface.js";
5
- import { SymbolIdInputSchema } from "../shared.js";
6
5
  import { buildProtoPatch, defineProtoPatchFields } from "../../utils/proto-patch.js";
6
+ import { SymbolIdInputSchema } from "../shared.js";
7
7
  import { PRICE_ALERT_CHANNEL_VALUES, PRICE_ALERT_DIRECTION_VALUES, PRICE_ALERT_PRICE_SOURCE_VALUES, PRICE_ALERT_STATUS_VALUES, PriceAlertChannelCodec, PriceAlertDirectionCodec, PriceAlertPriceSourceCodec, PriceAlertStatusCodec, PriceAlertUpdateOutcomeCodec } from "./price-alerts.codecs.js";
8
8
  import * as v from "valibot";
9
9
  //#region src/services/price-alerts/price-alerts.schemas.ts
@@ -29,7 +29,7 @@ declare const RewardAwardSchema: v.ObjectSchema<{
29
29
  readonly assetId: v.NumberSchema<undefined>;
30
30
  readonly amountBaseUnits: v.StringSchema<undefined>;
31
31
  readonly fulfillmentMethod: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "external_testnet" | "internal_trading">]>;
32
- readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "awaiting_destination" | "ready_for_payout" | "paid" | "failed" | "canceled">]>;
32
+ readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "awaiting_destination" | "ready_for_payout" | "paid" | "canceled">]>;
33
33
  readonly publishedAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
34
34
  readonly seconds: v.BigintSchema<undefined>;
35
35
  readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
@@ -67,7 +67,7 @@ declare const ListRewardAwardsResultSchema: v.ObjectSchema<{
67
67
  readonly assetId: v.NumberSchema<undefined>;
68
68
  readonly amountBaseUnits: v.StringSchema<undefined>;
69
69
  readonly fulfillmentMethod: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "external_testnet" | "internal_trading">]>;
70
- readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "awaiting_destination" | "ready_for_payout" | "paid" | "failed" | "canceled">]>;
70
+ readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "awaiting_destination" | "ready_for_payout" | "paid" | "canceled">]>;
71
71
  readonly publishedAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
72
72
  readonly seconds: v.BigintSchema<undefined>;
73
73
  readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
@@ -114,7 +114,7 @@ declare const SetRewardDestinationResultSchema: v.ObjectSchema<{
114
114
  readonly assetId: v.NumberSchema<undefined>;
115
115
  readonly amountBaseUnits: v.StringSchema<undefined>;
116
116
  readonly fulfillmentMethod: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "external_testnet" | "internal_trading">]>;
117
- readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "awaiting_destination" | "ready_for_payout" | "paid" | "failed" | "canceled">]>;
117
+ readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "awaiting_destination" | "ready_for_payout" | "paid" | "canceled">]>;
118
118
  readonly publishedAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
119
119
  readonly seconds: v.BigintSchema<undefined>;
120
120
  readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
@@ -153,7 +153,7 @@ declare const AcknowledgeRewardAwardResultSchema: v.ObjectSchema<{
153
153
  readonly assetId: v.NumberSchema<undefined>;
154
154
  readonly amountBaseUnits: v.StringSchema<undefined>;
155
155
  readonly fulfillmentMethod: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "external_testnet" | "internal_trading">]>;
156
- readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "awaiting_destination" | "ready_for_payout" | "paid" | "failed" | "canceled">]>;
156
+ readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "awaiting_destination" | "ready_for_payout" | "paid" | "canceled">]>;
157
157
  readonly publishedAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
158
158
  readonly seconds: v.BigintSchema<undefined>;
159
159
  readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
@@ -53,6 +53,15 @@ declare const SocialVerificationSchema: v.ObjectSchema<{
53
53
  readonly seconds: v.BigintSchema<undefined>;
54
54
  readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
55
55
  }, undefined>, undefined>;
56
+ /**
57
+ * X and Discord only: when the linked account may be changed or unlinked again, while the
58
+ * once-per-30-days limit applies; absent when a change or unlink is allowed now. A first
59
+ * link and re-verifying the linked X handle are not changes.
60
+ */
61
+ readonly changeAvailableAt: v.OptionalSchema<v.ObjectSchema<{
62
+ readonly seconds: v.BigintSchema<undefined>;
63
+ readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
64
+ }, undefined>, undefined>;
56
65
  }, undefined>;
57
66
  type SocialVerificationBase = v.InferOutput<typeof SocialVerificationSchema>;
58
67
  type SocialVerification = Omit<SocialVerificationBase, "provider" | "method" | "status"> & {
@@ -1 +1 @@
1
- {"version":3,"file":"social-verification.schemas.d.ts","names":[],"sources":["../../../src/services/social-verification/social-verification.schemas.ts"],"mappings":";;;;;cAuBa,sBAAoB,EAAA;KACrB,iBAAiB,EAAE,kBAAkB;cAEpC,gCAA8B,EAAA;KAC/B,2BAA2B,EAAE,kBAAkB;cAE9C,mCAAiC,EAAA;KAClC,8BAA8B,EAAE,mBAAmB;cAElD,gCAA8B,EAAA;KAC/B,2BAA2B,EAAE,mBAAmB;cAmC/C,0BAAwB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6BhC,yBAAyB,EAAE,mBAAmB;KACvC,qBAAqB,KAAK;EAClC,UAAU,YAAY;EACtB,QAAQ,YAAY;EACpB,QAAQ,YAAY;;;;;;;EAOpB,WAAW,YAAY;;cAGd,8BAA4B,EAAA,yBAAA,EAAA,2BAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;KAmC7B,yBAAyB,EAAE,kBAAkB;cAO5C,2BAAyB,EAAA;;;KAI1B,sBAAsB,EAAE,kBAAkB;cAEzC,iCAA+B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;KAgBhC,4BAA4B,EAAE,mBAAmB;cAEhD,iCAA+B,EAAA,yBAAA,EAAA;;;;;;;KAShC,4BAA4B,EAAE,mBAAmB;cAEhD,+BAA6B,EAAA,yBAAA,EAAA;;;;;;;KAS9B,0BAA0B,EAAE,mBAAmB;cAQ9C,gCAA8B,EAAA;;;;;KAS/B,2BAA2B,EAAE,kBAAkB;cAE9C,gCAA8B,EAAA;;;KAI/B,2BAA2B,EAAE,kBAAkB"}
1
+ {"version":3,"file":"social-verification.schemas.d.ts","names":[],"sources":["../../../src/services/social-verification/social-verification.schemas.ts"],"mappings":";;;;;cAuBa,sBAAoB,EAAA;KACrB,iBAAiB,EAAE,kBAAkB;cAEpC,gCAA8B,EAAA;KAC/B,2BAA2B,EAAE,kBAAkB;cAE9C,mCAAiC,EAAA;KAClC,8BAA8B,EAAE,mBAAmB;cAElD,gCAA8B,EAAA;KAC/B,2BAA2B,EAAE,mBAAmB;cAoC/C,0BAAwB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAmChC,yBAAyB,EAAE,mBAAmB;KACvC,qBAAqB,KAAK;EAClC,UAAU,YAAY;EACtB,QAAQ,YAAY;EACpB,QAAQ,YAAY;;;;;;;EAOpB,WAAW,YAAY;;cAGd,8BAA4B,EAAA,yBAAA,EAAA,2BAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;KAmC7B,yBAAyB,EAAE,kBAAkB;cAO5C,2BAAyB,EAAA;;;KAI1B,sBAAsB,EAAE,kBAAkB;cAEzC,iCAA+B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;KAgBhC,4BAA4B,EAAE,mBAAmB;cAEhD,iCAA+B,EAAA,yBAAA,EAAA;;;;;;;KAShC,4BAA4B,EAAE,mBAAmB;cAEhD,+BAA6B,EAAA,yBAAA,EAAA;;;;;;;KAS9B,0BAA0B,EAAE,mBAAmB;cAQ9C,gCAA8B,EAAA;;;;;KAS/B,2BAA2B,EAAE,kBAAkB;cAE9C,gCAA8B,EAAA;;;KAI/B,2BAA2B,EAAE,kBAAkB"}
@@ -33,7 +33,8 @@ function transformVerification(v) {
33
33
  lastError: v.lastError,
34
34
  errorCode: enumLabel(SocialVerificationErrorCodeCodec.protoToOutput, v.errorCode),
35
35
  updatedAt: v.updatedAt,
36
- retryAfter: v.retryAfter
36
+ retryAfter: v.retryAfter,
37
+ changeAvailableAt: v.changeAvailableAt
37
38
  };
38
39
  }
39
40
  v.object({
@@ -62,7 +63,13 @@ v.object({
62
63
  * When a new verification may succeed, after this one failed with
63
64
  * `social_account_cooldown` or `social_change_limit_reached`; absent otherwise.
64
65
  */
65
- retryAfter: v.optional(TimestampSchema)
66
+ retryAfter: v.optional(TimestampSchema),
67
+ /**
68
+ * X and Discord only: when the linked account may be changed or unlinked again, while the
69
+ * once-per-30-days limit applies; absent when a change or unlink is allowed now. A first
70
+ * link and re-verifying the linked X handle are not changes.
71
+ */
72
+ changeAvailableAt: v.optional(TimestampSchema)
66
73
  });
67
74
  const StartVerificationInputSchema = v.pipe(v.variant("provider", [
68
75
  v.strictObject({
@@ -1 +1 @@
1
- {"version":3,"file":"social-verification.schemas.js","names":[],"sources":["../../../src/services/social-verification/social-verification.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { TimestampSchema } from \"../../shared/schemas.js\";\nimport { enumLabel } from \"../../shared/proto-enum-codec.js\";\nimport type { DecodedEnum } from \"../../utils/types.js\";\nimport * as Proto from \"../../gen/auth/v1/social_verification_pb.js\";\nimport {\n SOCIAL_PROVIDER_VALUES,\n SOCIAL_VERIFICATION_ERROR_CODE_VALUES,\n SOCIAL_VERIFICATION_METHOD_VALUES,\n SOCIAL_VERIFICATION_STATUS_VALUES,\n SocialProviderCodec,\n SocialVerificationErrorCodeCodec,\n SocialVerificationMethodCodec,\n SocialVerificationStatusCodec,\n} from \"./social-verification.codecs.js\";\n\nexport {\n SOCIAL_PROVIDER_VALUES,\n SOCIAL_VERIFICATION_ERROR_CODE_VALUES,\n SOCIAL_VERIFICATION_METHOD_VALUES,\n SOCIAL_VERIFICATION_STATUS_VALUES,\n} from \"./social-verification.codecs.js\";\n\nexport const SocialProviderSchema = v.picklist(SOCIAL_PROVIDER_VALUES);\nexport type SocialProvider = v.InferInput<typeof SocialProviderSchema>;\n\nexport const SocialVerificationMethodSchema = v.picklist(SOCIAL_VERIFICATION_METHOD_VALUES);\nexport type SocialVerificationMethod = v.InferInput<typeof SocialVerificationMethodSchema>;\n\nexport const SocialVerificationErrorCodeSchema = v.picklist(SOCIAL_VERIFICATION_ERROR_CODE_VALUES);\nexport type SocialVerificationErrorCode = v.InferOutput<typeof SocialVerificationErrorCodeSchema>;\n\nexport const SocialVerificationStatusSchema = v.picklist(SOCIAL_VERIFICATION_STATUS_VALUES);\nexport type SocialVerificationStatus = v.InferOutput<typeof SocialVerificationStatusSchema>;\n\nfunction normalizeHandle(input: string): string {\n return (input ?? \"\").trim().replace(/^@+/, \"\");\n}\n\nconst TWITTER_HANDLE_PATTERN = /^[A-Za-z0-9_]{1,15}$/;\n\n/**\n * Normalizes a social verification response into the SDK verification shape.\n */\nexport function transformVerification(\n v: Proto.SocialVerification | undefined,\n): SocialVerification | undefined {\n if (!v) return undefined;\n return {\n id: v.id,\n provider: enumLabel(SocialProviderCodec.protoToOutput, v.provider),\n method: enumLabel(SocialVerificationMethodCodec.protoToOutput, v.method),\n handle: v.handle,\n providerUserId: v.providerUserId,\n displayName: v.displayName,\n challengeCode: v.challengeCode,\n status: enumLabel(SocialVerificationStatusCodec.protoToOutput, v.status),\n requestedAt: v.requestedAt,\n expiresAt: v.expiresAt,\n verifiedAt: v.verifiedAt,\n attempts: v.attempts,\n lastError: v.lastError,\n errorCode: enumLabel(SocialVerificationErrorCodeCodec.protoToOutput, v.errorCode),\n updatedAt: v.updatedAt,\n retryAfter: v.retryAfter,\n };\n}\n\nexport const SocialVerificationSchema = v.object({\n id: v.bigint(),\n provider: SocialProviderSchema,\n method: SocialVerificationMethodSchema,\n handle: v.string(),\n /**\n * Provider-side user ID of the linked account, empty while none is linked. A restarted\n * X or Discord verification keeps the current link, and this value, until it succeeds.\n * For Telegram in `awaiting_confirmation`, the\n * decimal user ID of the account that sent the code: pass it to `confirm` as is.\n */\n providerUserId: v.string(),\n /** Telegram only: the account's name once the code is submitted; empty otherwise. */\n displayName: v.string(),\n challengeCode: v.string(),\n status: SocialVerificationStatusSchema,\n requestedAt: v.optional(TimestampSchema),\n expiresAt: v.optional(TimestampSchema),\n verifiedAt: v.optional(TimestampSchema),\n attempts: v.number(),\n lastError: v.string(),\n updatedAt: v.optional(TimestampSchema),\n /**\n * When a new verification may succeed, after this one failed with\n * `social_account_cooldown` or `social_change_limit_reached`; absent otherwise.\n */\n retryAfter: v.optional(TimestampSchema),\n});\n\ntype SocialVerificationBase = v.InferOutput<typeof SocialVerificationSchema>;\nexport type SocialVerification = Omit<SocialVerificationBase, \"provider\" | \"method\" | \"status\"> & {\n provider: DecodedEnum<SocialProvider>;\n method: DecodedEnum<SocialVerificationMethod>;\n status: DecodedEnum<SocialVerificationStatus>;\n /**\n * Machine-readable failure for the current state; branch on this, not `lastError`.\n * `\"unspecified\"` when no typed failure applies or the code is newer than this SDK.\n * `\"social_account_already_linked\"` is non-retryable for this account: send the\n * user to the account already linked to that identity instead of restarting.\n */\n errorCode: DecodedEnum<SocialVerificationErrorCode>;\n};\n\nexport const StartVerificationInputSchema = v.pipe(\n v.variant(\"provider\", [\n v.strictObject({\n provider: v.literal(\"twitter\"),\n handle: v.pipe(\n v.string(),\n v.transform(normalizeHandle),\n v.minLength(1),\n v.regex(\n TWITTER_HANDLE_PATTERN,\n \"Twitter handle must be 1-15 letters, digits, or underscores\",\n ),\n ),\n method: v.optional(v.literal(\"profile\")),\n }),\n v.strictObject({\n provider: v.literal(\"discord\"),\n method: v.optional(v.picklist([\"channel\", \"dm\"])),\n }),\n v.strictObject({\n provider: v.literal(\"telegram\"),\n method: v.optional(v.literal(\"dm\")),\n }),\n ]),\n v.transform(({ provider, method, ...input }) => ({\n ...input,\n provider: SocialProviderCodec.inputToProto[provider],\n // METHOD_UNSPECIFIED lets the API choose Twitter's profile or Discord's channel default.\n method:\n method === undefined\n ? Proto.SocialVerificationMethod.METHOD_UNSPECIFIED\n : SocialVerificationMethodCodec.inputToProto[method],\n })),\n);\n\nexport type StartVerificationInput = v.InferInput<typeof StartVerificationInputSchema>;\n\nexport const ProviderInputSchema = v.pipe(\n SocialProviderSchema,\n v.transform((v) => SocialProviderCodec.inputToProto[v]),\n);\n\nexport const SocialProviderInputSchema = v.strictObject({\n provider: ProviderInputSchema,\n});\n\nexport type SocialProviderInput = v.InferInput<typeof SocialProviderInputSchema>;\n\nexport const StartVerificationResponseSchema = v.pipe(\n v.object({\n challengeCode: v.string(),\n expiresAt: v.optional(TimestampSchema),\n verification: v.optional(v.custom<Proto.SocialVerification>(() => true)),\n /** Telegram: the `https://t.me/...` link that sends the code to the bot; empty otherwise. */\n actionUrl: v.optional(v.string(), \"\"),\n }),\n v.transform((res) => ({\n challengeCode: res.challengeCode,\n expiresAt: res.expiresAt,\n actionUrl: res.actionUrl,\n verification: transformVerification(res.verification),\n })),\n);\n\nexport type StartVerificationResponse = v.InferOutput<typeof StartVerificationResponseSchema>;\n\nexport const VerificationReadyResponseSchema = v.pipe(\n v.object({\n verification: v.optional(v.custom<Proto.SocialVerification>(() => true)),\n }),\n v.transform((res) => ({\n verification: transformVerification(res.verification),\n })),\n);\n\nexport type VerificationReadyResponse = v.InferOutput<typeof VerificationReadyResponseSchema>;\n\nexport const GetVerificationResponseSchema = v.pipe(\n v.object({\n verification: v.optional(v.custom<Proto.SocialVerification>(() => true)),\n }),\n v.transform((res) => ({\n verification: transformVerification(res.verification),\n })),\n);\n\nexport type GetVerificationResponse = v.InferOutput<typeof GetVerificationResponseSchema>;\n\n/** Only Telegram links through confirmation. */\nconst TelegramProviderInputSchema = v.pipe(\n v.literal(\"telegram\"),\n v.transform(() => Proto.SocialProvider.TELEGRAM),\n);\n\nexport const ConfirmVerificationInputSchema = v.strictObject({\n provider: TelegramProviderInputSchema,\n /** The verification's `providerUserId` in `awaiting_confirmation`: a decimal 64-bit ID. */\n providerUserId: v.pipe(\n v.string(),\n v.regex(/^[1-9]\\d{0,19}$/u, \"providerUserId must be a decimal Telegram user ID\"),\n ),\n});\n\nexport type ConfirmVerificationInput = v.InferInput<typeof ConfirmVerificationInputSchema>;\n\nexport const UnlinkSocialAccountInputSchema = v.strictObject({\n provider: ProviderInputSchema,\n});\n\nexport type UnlinkSocialAccountInput = v.InferInput<typeof UnlinkSocialAccountInputSchema>;\n"],"mappings":";;;;;;AAuBA,MAAa,uBAAuB,EAAE,SAAS,sBAAsB;AAGrE,MAAa,iCAAiC,EAAE,SAAS,iCAAiC;AAGzC,EAAE,SAAS,qCAAqC;AAGjG,MAAa,iCAAiC,EAAE,SAAS,iCAAiC;AAG1F,SAAS,gBAAgB,OAAuB;CAC5C,QAAQ,SAAS,GAAA,CAAI,KAAK,CAAC,CAAC,QAAQ,OAAO,EAAE;AACjD;AAEA,MAAM,yBAAyB;;;;AAK/B,SAAgB,sBACZ,GAC8B;CAC9B,IAAI,CAAC,GAAG,OAAO,KAAA;CACf,OAAO;EACH,IAAI,EAAE;EACN,UAAU,UAAU,oBAAoB,eAAe,EAAE,QAAQ;EACjE,QAAQ,UAAU,8BAA8B,eAAe,EAAE,MAAM;EACvE,QAAQ,EAAE;EACV,gBAAgB,EAAE;EAClB,aAAa,EAAE;EACf,eAAe,EAAE;EACjB,QAAQ,UAAU,8BAA8B,eAAe,EAAE,MAAM;EACvE,aAAa,EAAE;EACf,WAAW,EAAE;EACb,YAAY,EAAE;EACd,UAAU,EAAE;EACZ,WAAW,EAAE;EACb,WAAW,UAAU,iCAAiC,eAAe,EAAE,SAAS;EAChF,WAAW,EAAE;EACb,YAAY,EAAE;CAClB;AACJ;AAEwC,EAAE,OAAO;CAC7C,IAAI,EAAE,OAAO;CACb,UAAU;CACV,QAAQ;CACR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CACxB,WAAW,EAAE,SAAS,eAAe;CACrC,cAAc,EAAE,SAAS,EAAE,aAAuC,IAAI,CAAC;;CAEvE,WAAW,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;AACxC,CAAC,GACD,EAAE,WAAW,SAAS;CAClB,eAAe,IAAI;CACnB,WAAW,IAAI;CACf,WAAW,IAAI;CACf,cAAc,sBAAsB,IAAI,YAAY;AACxD,EAAE,CACN;AAIA,MAAa,kCAAkC,EAAE,KAC7C,EAAE,OAAO,EACL,cAAc,EAAE,SAAS,EAAE,aAAuC,IAAI,CAAC,EAC3E,CAAC,GACD,EAAE,WAAW,SAAS,EAClB,cAAc,sBAAsB,IAAI,YAAY,EACxD,EAAE,CACN;AAIA,MAAa,gCAAgC,EAAE,KAC3C,EAAE,OAAO,EACL,cAAc,EAAE,SAAS,EAAE,aAAuC,IAAI,CAAC,EAC3E,CAAC,GACD,EAAE,WAAW,SAAS,EAClB,cAAc,sBAAsB,IAAI,YAAY,EACxD,EAAE,CACN;;AAKA,MAAM,8BAA8B,EAAE,KAClC,EAAE,QAAQ,UAAU,GACpB,EAAE,gBAAA,CAA6C,CACnD;AAEA,MAAa,iCAAiC,EAAE,aAAa;CACzD,UAAU;;CAEV,gBAAgB,EAAE,KACd,EAAE,OAAO,GACT,EAAE,MAAM,oBAAoB,mDAAmD,CACnF;AACJ,CAAC;AAID,MAAa,iCAAiC,EAAE,aAAa,EACzD,UAAU,oBACd,CAAC"}
1
+ {"version":3,"file":"social-verification.schemas.js","names":[],"sources":["../../../src/services/social-verification/social-verification.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { TimestampSchema } from \"../../shared/schemas.js\";\nimport { enumLabel } from \"../../shared/proto-enum-codec.js\";\nimport type { DecodedEnum } from \"../../utils/types.js\";\nimport * as Proto from \"../../gen/auth/v1/social_verification_pb.js\";\nimport {\n SOCIAL_PROVIDER_VALUES,\n SOCIAL_VERIFICATION_ERROR_CODE_VALUES,\n SOCIAL_VERIFICATION_METHOD_VALUES,\n SOCIAL_VERIFICATION_STATUS_VALUES,\n SocialProviderCodec,\n SocialVerificationErrorCodeCodec,\n SocialVerificationMethodCodec,\n SocialVerificationStatusCodec,\n} from \"./social-verification.codecs.js\";\n\nexport {\n SOCIAL_PROVIDER_VALUES,\n SOCIAL_VERIFICATION_ERROR_CODE_VALUES,\n SOCIAL_VERIFICATION_METHOD_VALUES,\n SOCIAL_VERIFICATION_STATUS_VALUES,\n} from \"./social-verification.codecs.js\";\n\nexport const SocialProviderSchema = v.picklist(SOCIAL_PROVIDER_VALUES);\nexport type SocialProvider = v.InferInput<typeof SocialProviderSchema>;\n\nexport const SocialVerificationMethodSchema = v.picklist(SOCIAL_VERIFICATION_METHOD_VALUES);\nexport type SocialVerificationMethod = v.InferInput<typeof SocialVerificationMethodSchema>;\n\nexport const SocialVerificationErrorCodeSchema = v.picklist(SOCIAL_VERIFICATION_ERROR_CODE_VALUES);\nexport type SocialVerificationErrorCode = v.InferOutput<typeof SocialVerificationErrorCodeSchema>;\n\nexport const SocialVerificationStatusSchema = v.picklist(SOCIAL_VERIFICATION_STATUS_VALUES);\nexport type SocialVerificationStatus = v.InferOutput<typeof SocialVerificationStatusSchema>;\n\nfunction normalizeHandle(input: string): string {\n return (input ?? \"\").trim().replace(/^@+/, \"\");\n}\n\nconst TWITTER_HANDLE_PATTERN = /^[A-Za-z0-9_]{1,15}$/;\n\n/**\n * Normalizes a social verification response into the SDK verification shape.\n */\nexport function transformVerification(\n v: Proto.SocialVerification | undefined,\n): SocialVerification | undefined {\n if (!v) return undefined;\n return {\n id: v.id,\n provider: enumLabel(SocialProviderCodec.protoToOutput, v.provider),\n method: enumLabel(SocialVerificationMethodCodec.protoToOutput, v.method),\n handle: v.handle,\n providerUserId: v.providerUserId,\n displayName: v.displayName,\n challengeCode: v.challengeCode,\n status: enumLabel(SocialVerificationStatusCodec.protoToOutput, v.status),\n requestedAt: v.requestedAt,\n expiresAt: v.expiresAt,\n verifiedAt: v.verifiedAt,\n attempts: v.attempts,\n lastError: v.lastError,\n errorCode: enumLabel(SocialVerificationErrorCodeCodec.protoToOutput, v.errorCode),\n updatedAt: v.updatedAt,\n retryAfter: v.retryAfter,\n changeAvailableAt: v.changeAvailableAt,\n };\n}\n\nexport const SocialVerificationSchema = v.object({\n id: v.bigint(),\n provider: SocialProviderSchema,\n method: SocialVerificationMethodSchema,\n handle: v.string(),\n /**\n * Provider-side user ID of the linked account, empty while none is linked. A restarted\n * X or Discord verification keeps the current link, and this value, until it succeeds.\n * For Telegram in `awaiting_confirmation`, the\n * decimal user ID of the account that sent the code: pass it to `confirm` as is.\n */\n providerUserId: v.string(),\n /** Telegram only: the account's name once the code is submitted; empty otherwise. */\n displayName: v.string(),\n challengeCode: v.string(),\n status: SocialVerificationStatusSchema,\n requestedAt: v.optional(TimestampSchema),\n expiresAt: v.optional(TimestampSchema),\n verifiedAt: v.optional(TimestampSchema),\n attempts: v.number(),\n lastError: v.string(),\n updatedAt: v.optional(TimestampSchema),\n /**\n * When a new verification may succeed, after this one failed with\n * `social_account_cooldown` or `social_change_limit_reached`; absent otherwise.\n */\n retryAfter: v.optional(TimestampSchema),\n /**\n * X and Discord only: when the linked account may be changed or unlinked again, while the\n * once-per-30-days limit applies; absent when a change or unlink is allowed now. A first\n * link and re-verifying the linked X handle are not changes.\n */\n changeAvailableAt: v.optional(TimestampSchema),\n});\n\ntype SocialVerificationBase = v.InferOutput<typeof SocialVerificationSchema>;\nexport type SocialVerification = Omit<SocialVerificationBase, \"provider\" | \"method\" | \"status\"> & {\n provider: DecodedEnum<SocialProvider>;\n method: DecodedEnum<SocialVerificationMethod>;\n status: DecodedEnum<SocialVerificationStatus>;\n /**\n * Machine-readable failure for the current state; branch on this, not `lastError`.\n * `\"unspecified\"` when no typed failure applies or the code is newer than this SDK.\n * `\"social_account_already_linked\"` is non-retryable for this account: send the\n * user to the account already linked to that identity instead of restarting.\n */\n errorCode: DecodedEnum<SocialVerificationErrorCode>;\n};\n\nexport const StartVerificationInputSchema = v.pipe(\n v.variant(\"provider\", [\n v.strictObject({\n provider: v.literal(\"twitter\"),\n handle: v.pipe(\n v.string(),\n v.transform(normalizeHandle),\n v.minLength(1),\n v.regex(\n TWITTER_HANDLE_PATTERN,\n \"Twitter handle must be 1-15 letters, digits, or underscores\",\n ),\n ),\n method: v.optional(v.literal(\"profile\")),\n }),\n v.strictObject({\n provider: v.literal(\"discord\"),\n method: v.optional(v.picklist([\"channel\", \"dm\"])),\n }),\n v.strictObject({\n provider: v.literal(\"telegram\"),\n method: v.optional(v.literal(\"dm\")),\n }),\n ]),\n v.transform(({ provider, method, ...input }) => ({\n ...input,\n provider: SocialProviderCodec.inputToProto[provider],\n // METHOD_UNSPECIFIED lets the API choose Twitter's profile or Discord's channel default.\n method:\n method === undefined\n ? Proto.SocialVerificationMethod.METHOD_UNSPECIFIED\n : SocialVerificationMethodCodec.inputToProto[method],\n })),\n);\n\nexport type StartVerificationInput = v.InferInput<typeof StartVerificationInputSchema>;\n\nexport const ProviderInputSchema = v.pipe(\n SocialProviderSchema,\n v.transform((v) => SocialProviderCodec.inputToProto[v]),\n);\n\nexport const SocialProviderInputSchema = v.strictObject({\n provider: ProviderInputSchema,\n});\n\nexport type SocialProviderInput = v.InferInput<typeof SocialProviderInputSchema>;\n\nexport const StartVerificationResponseSchema = v.pipe(\n v.object({\n challengeCode: v.string(),\n expiresAt: v.optional(TimestampSchema),\n verification: v.optional(v.custom<Proto.SocialVerification>(() => true)),\n /** Telegram: the `https://t.me/...` link that sends the code to the bot; empty otherwise. */\n actionUrl: v.optional(v.string(), \"\"),\n }),\n v.transform((res) => ({\n challengeCode: res.challengeCode,\n expiresAt: res.expiresAt,\n actionUrl: res.actionUrl,\n verification: transformVerification(res.verification),\n })),\n);\n\nexport type StartVerificationResponse = v.InferOutput<typeof StartVerificationResponseSchema>;\n\nexport const VerificationReadyResponseSchema = v.pipe(\n v.object({\n verification: v.optional(v.custom<Proto.SocialVerification>(() => true)),\n }),\n v.transform((res) => ({\n verification: transformVerification(res.verification),\n })),\n);\n\nexport type VerificationReadyResponse = v.InferOutput<typeof VerificationReadyResponseSchema>;\n\nexport const GetVerificationResponseSchema = v.pipe(\n v.object({\n verification: v.optional(v.custom<Proto.SocialVerification>(() => true)),\n }),\n v.transform((res) => ({\n verification: transformVerification(res.verification),\n })),\n);\n\nexport type GetVerificationResponse = v.InferOutput<typeof GetVerificationResponseSchema>;\n\n/** Only Telegram links through confirmation. */\nconst TelegramProviderInputSchema = v.pipe(\n v.literal(\"telegram\"),\n v.transform(() => Proto.SocialProvider.TELEGRAM),\n);\n\nexport const ConfirmVerificationInputSchema = v.strictObject({\n provider: TelegramProviderInputSchema,\n /** The verification's `providerUserId` in `awaiting_confirmation`: a decimal 64-bit ID. */\n providerUserId: v.pipe(\n v.string(),\n v.regex(/^[1-9]\\d{0,19}$/u, \"providerUserId must be a decimal Telegram user ID\"),\n ),\n});\n\nexport type ConfirmVerificationInput = v.InferInput<typeof ConfirmVerificationInputSchema>;\n\nexport const UnlinkSocialAccountInputSchema = v.strictObject({\n provider: ProviderInputSchema,\n});\n\nexport type UnlinkSocialAccountInput = v.InferInput<typeof UnlinkSocialAccountInputSchema>;\n"],"mappings":";;;;;;AAuBA,MAAa,uBAAuB,EAAE,SAAS,sBAAsB;AAGrE,MAAa,iCAAiC,EAAE,SAAS,iCAAiC;AAGzC,EAAE,SAAS,qCAAqC;AAGjG,MAAa,iCAAiC,EAAE,SAAS,iCAAiC;AAG1F,SAAS,gBAAgB,OAAuB;CAC5C,QAAQ,SAAS,GAAA,CAAI,KAAK,CAAC,CAAC,QAAQ,OAAO,EAAE;AACjD;AAEA,MAAM,yBAAyB;;;;AAK/B,SAAgB,sBACZ,GAC8B;CAC9B,IAAI,CAAC,GAAG,OAAO,KAAA;CACf,OAAO;EACH,IAAI,EAAE;EACN,UAAU,UAAU,oBAAoB,eAAe,EAAE,QAAQ;EACjE,QAAQ,UAAU,8BAA8B,eAAe,EAAE,MAAM;EACvE,QAAQ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mDAAmD,CACnF;AACJ,CAAC;AAID,MAAa,iCAAiC,EAAE,aAAa,EACzD,UAAU,oBACd,CAAC"}
@@ -1,9 +1,10 @@
1
1
  //#region src/services/statement-exports/statement-exports.codecs.d.ts
2
- declare const STATEMENT_EXPORT_STATUS_VALUES: readonly ["queued", "processing", "ready", "failed", "expired"];
2
+ declare const STATEMENT_EXPORT_STATUS_VALUES: readonly ["queued", "processing", "ready", "failed", "expired", "canceled"];
3
3
  /**
4
4
  * `queued` waits for the account history to cover the period and for the account's other
5
5
  * export to finish, `processing` is writing the file, `ready` can be downloaded until
6
- * `expiresAt`, `failed` has no file (see `failureReason`), and `expired` had its file deleted.
6
+ * `expiresAt`, `failed` has no file (see `failureReason`), `expired` had its file deleted, and
7
+ * `canceled` was stopped with `statementExports.cancel` before it finished and has no file.
7
8
  */
8
9
  type StatementExportStatus = (typeof STATEMENT_EXPORT_STATUS_VALUES)[number];
9
10
  declare const STATEMENT_EXPORT_FAILURE_REASON_VALUES: readonly ["too_large", "unavailable"];
@@ -1 +1 @@
1
- {"version":3,"file":"statement-exports.codecs.d.ts","names":[],"sources":["../../../src/services/statement-exports/statement-exports.codecs.ts"],"mappings":";cAGa;;;;;;KAYD,gCAAgC;cAE/B;;;;;KAKD,uCAAuC"}
1
+ {"version":3,"file":"statement-exports.codecs.d.ts","names":[],"sources":["../../../src/services/statement-exports/statement-exports.codecs.ts"],"mappings":";cAGa;;;;;;;KAcD,gCAAgC;cAE/B;;;;;KAKD,uCAAuC"}
@@ -6,7 +6,8 @@ const StatementExportStatusCodec = { protoToOutput: {
6
6
  [2]: "processing",
7
7
  [3]: "ready",
8
8
  [4]: "failed",
9
- [5]: "expired"
9
+ [5]: "expired",
10
+ [6]: "canceled"
10
11
  } };
11
12
  const StatementExportFailureReasonCodec = { protoToOutput: {
12
13
  [0]: "unspecified",
@@ -1 +1 @@
1
- {"version":3,"file":"statement-exports.codecs.js","names":[],"sources":["../../../src/services/statement-exports/statement-exports.codecs.ts"],"sourcesContent":["import * as Proto from \"../../gen/ledger/read/v1/statement_export_pb.js\";\nimport type { ProtoToOutput } from \"../../utils/types.js\";\n\nexport const STATEMENT_EXPORT_STATUS_VALUES = [\n \"queued\",\n \"processing\",\n \"ready\",\n \"failed\",\n \"expired\",\n] as const;\n/**\n * `queued` waits for the account history to cover the period and for the account's other\n * export to finish, `processing` is writing the file, `ready` can be downloaded until\n * `expiresAt`, `failed` has no file (see `failureReason`), and `expired` had its file deleted.\n */\nexport type StatementExportStatus = (typeof STATEMENT_EXPORT_STATUS_VALUES)[number];\n\nexport const STATEMENT_EXPORT_FAILURE_REASON_VALUES = [\"too_large\", \"unavailable\"] as const;\n/**\n * `too_large`: the period holds more than 4,000,000 ledger movements; split it into shorter\n * exports. `unavailable`: the file could not be produced in time; create a new export.\n */\nexport type StatementExportFailureReason = (typeof STATEMENT_EXPORT_FAILURE_REASON_VALUES)[number];\n\nexport const StatementExportStatusCodec = {\n protoToOutput: {\n [Proto.StatementExportStatus.UNSPECIFIED]: \"unspecified\",\n [Proto.StatementExportStatus.QUEUED]: \"queued\",\n [Proto.StatementExportStatus.PROCESSING]: \"processing\",\n [Proto.StatementExportStatus.READY]: \"ready\",\n [Proto.StatementExportStatus.FAILED]: \"failed\",\n [Proto.StatementExportStatus.EXPIRED]: \"expired\",\n } satisfies ProtoToOutput<Proto.StatementExportStatus, StatementExportStatus>,\n} as const;\n\nexport const StatementExportFailureReasonCodec = {\n protoToOutput: {\n [Proto.StatementExportFailureReason.UNSPECIFIED]: \"unspecified\",\n [Proto.StatementExportFailureReason.TOO_LARGE]: \"too_large\",\n [Proto.StatementExportFailureReason.UNAVAILABLE]: \"unavailable\",\n } satisfies ProtoToOutput<Proto.StatementExportFailureReason, StatementExportFailureReason>,\n} as const;\n"],"mappings":";;AAwBA,MAAa,6BAA6B,EACtC,eAAe;EACgC,IAAA;EACL,IAAA;EACI,IAAA;EACL,IAAA;EACC,IAAA;EACC,IAAA;AAC3C,EACJ;AAEA,MAAa,oCAAoC,EAC7C,eAAe;EACuC,IAAA;EACF,IAAA;EACE,IAAA;AACtD,EACJ"}
1
+ {"version":3,"file":"statement-exports.codecs.js","names":[],"sources":["../../../src/services/statement-exports/statement-exports.codecs.ts"],"sourcesContent":["import * as Proto from \"../../gen/ledger/read/v1/statement_export_pb.js\";\nimport type { ProtoToOutput } from \"../../utils/types.js\";\n\nexport const STATEMENT_EXPORT_STATUS_VALUES = [\n \"queued\",\n \"processing\",\n \"ready\",\n \"failed\",\n \"expired\",\n \"canceled\",\n] as const;\n/**\n * `queued` waits for the account history to cover the period and for the account's other\n * export to finish, `processing` is writing the file, `ready` can be downloaded until\n * `expiresAt`, `failed` has no file (see `failureReason`), `expired` had its file deleted, and\n * `canceled` was stopped with `statementExports.cancel` before it finished and has no file.\n */\nexport type StatementExportStatus = (typeof STATEMENT_EXPORT_STATUS_VALUES)[number];\n\nexport const STATEMENT_EXPORT_FAILURE_REASON_VALUES = [\"too_large\", \"unavailable\"] as const;\n/**\n * `too_large`: the period holds more than 4,000,000 ledger movements; split it into shorter\n * exports. `unavailable`: the file could not be produced in time; create a new export.\n */\nexport type StatementExportFailureReason = (typeof STATEMENT_EXPORT_FAILURE_REASON_VALUES)[number];\n\nexport const StatementExportStatusCodec = {\n protoToOutput: {\n [Proto.StatementExportStatus.UNSPECIFIED]: \"unspecified\",\n [Proto.StatementExportStatus.QUEUED]: \"queued\",\n [Proto.StatementExportStatus.PROCESSING]: \"processing\",\n [Proto.StatementExportStatus.READY]: \"ready\",\n [Proto.StatementExportStatus.FAILED]: \"failed\",\n [Proto.StatementExportStatus.EXPIRED]: \"expired\",\n [Proto.StatementExportStatus.CANCELED]: \"canceled\",\n } satisfies ProtoToOutput<Proto.StatementExportStatus, StatementExportStatus>,\n} as const;\n\nexport const StatementExportFailureReasonCodec = {\n protoToOutput: {\n [Proto.StatementExportFailureReason.UNSPECIFIED]: \"unspecified\",\n [Proto.StatementExportFailureReason.TOO_LARGE]: \"too_large\",\n [Proto.StatementExportFailureReason.UNAVAILABLE]: \"unavailable\",\n } satisfies ProtoToOutput<Proto.StatementExportFailureReason, StatementExportFailureReason>,\n} as const;\n"],"mappings":";;AA0BA,MAAa,6BAA6B,EACtC,eAAe;EACgC,IAAA;EACL,IAAA;EACI,IAAA;EACL,IAAA;EACC,IAAA;EACC,IAAA;EACC,IAAA;AAC5C,EACJ;AAEA,MAAa,oCAAoC,EAC7C,eAAe;EACuC,IAAA;EACF,IAAA;EACE,IAAA;AACtD,EACJ"}
@@ -1,17 +1,17 @@
1
1
  import { AuthApiTransports } from "../../shared/transports.js";
2
2
  import { PolyesterRequestOptions } from "../../shared/request-options.js";
3
3
  import { SubaccountResolver } from "../subaccount-resolver.js";
4
- import { CreateStatementExportInput, GetStatementExportInput, ListStatementExportsInput, ListStatementExportsResult, StatementExport } from "./statement-exports.schemas.js";
4
+ import { CancelStatementExportInput, CreateStatementExportInput, GetStatementExportDownloadUrlInput, GetStatementExportInput, ListStatementExportsInput, ListStatementExportsResult, StatementExport, StatementExportDownloadUrl } from "./statement-exports.schemas.js";
5
5
  //#region src/services/statement-exports/statement-exports.d.ts
6
6
  /**
7
- * Produces whole-period account statements in the background, one CSV file each: the same
8
- * rows, account, asset and period choices as `balances.exportStatement`, concatenated. API keys
9
- * need `read-statements`. A root account has at most 5 exports queued or processing, each
10
- * account produces one at a time, and a ready file can be downloaded for 7 days.
7
+ * Produces whole-period account statements in the background, one RFC 4180 CSV file each: one
8
+ * account, optionally one asset, for a period of at most 366 days. API keys need
9
+ * `read-statements`. A root account has at most 5 exports queued or processing, each account
10
+ * produces one at a time, and a ready file can be downloaded for 7 days.
11
11
  *
12
- * The file itself is REST only: an authenticated `GET /v1/statements/exports/{exportId}/file`
13
- * returns `text/csv` and supports `Range`; `?redirect=true` answers a 307 to a URL valid for 60
14
- * seconds. An expired export's file answers 410.
12
+ * Download a ready file in a browser from `getDownloadUrl`. Servers and CLIs can instead send
13
+ * an authenticated `GET /v1/statements/exports/{exportId}/file`, which returns `text/csv` and
14
+ * supports `Range`; an expired export's file answers 410.
15
15
  */
16
16
  declare class StatementExportsService {
17
17
  #private;
@@ -24,9 +24,24 @@ declare class StatementExportsService {
24
24
  * with the same request.
25
25
  */
26
26
  create(input: CreateStatementExportInput, options?: PolyesterRequestOptions): Promise<StatementExport>;
27
- /** Returns one export; poll it until `status` is `ready`, `failed` or `expired`. */
27
+ /** Returns one export; poll it until `status` is `ready`, `failed`, `expired` or `canceled`. */
28
28
  get(input: GetStatementExportInput, options?: PolyesterRequestOptions): Promise<StatementExport>;
29
- /** Lists the resolved account's exports, newest first. */
29
+ /**
30
+ * Returns a link valid for 60 seconds that downloads a ready export's file without
31
+ * credentials, for a browser to save; each call returns a new link. Never log `url`. Throws
32
+ * `PreconditionFailedError` before the file is ready (`STATEMENT_EXPORT_NOT_READY`) and for
33
+ * a `failed`, `canceled` or `expired` export, or one with less than 5 seconds left
34
+ * (`STATEMENT_EXPORT_FAILED`, `STATEMENT_EXPORT_CANCELED`, `STATEMENT_EXPORT_EXPIRED`).
35
+ */
36
+ getDownloadUrl(input: GetStatementExportDownloadUrlInput, options?: PolyesterRequestOptions): Promise<StatementExportDownloadUrl>;
37
+ /**
38
+ * Cancels a queued or processing export and returns it `canceled`: it frees its place under
39
+ * the root account's 5, the account's next queued export can start, and any partial file is
40
+ * deleted. Canceling a `canceled` export returns it as it is; a finished one throws
41
+ * `PreconditionFailedError` (`STATEMENT_EXPORT_NOT_CANCELABLE`).
42
+ */
43
+ cancel(input: CancelStatementExportInput, options?: PolyesterRequestOptions): Promise<StatementExport>;
44
+ /** Lists the resolved account's exports, newest first, with the root's in-progress count. */
30
45
  list(input?: ListStatementExportsInput, options?: PolyesterRequestOptions): Promise<ListStatementExportsResult>;
31
46
  }
32
47
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"statement-exports.d.ts","names":[],"sources":["../../../src/services/statement-exports/statement-exports.ts"],"mappings":";;;;;;;;;;;;;;;cAgCa;;EAIG,YAAA,YAAY,mBAAmB,WAAW;;;;;;;;EAYhD,OACF,OAAO,4BACP,UAAU,0BACX,QAAQ;;EAaL,IACF,OAAO,yBACP,UAAU,0BACX,QAAQ;;EAUL,KACF,QAAO,2BACP,UAAU,0BACX,QAAQ"}
1
+ {"version":3,"file":"statement-exports.d.ts","names":[],"sources":["../../../src/services/statement-exports/statement-exports.ts"],"mappings":";;;;;;;;;;;;;;;cAoCa;;EAIG,YAAA,YAAY,mBAAmB,WAAW;;;;;;;;EAYhD,OACF,OAAO,4BACP,UAAU,0BACX,QAAQ;;EAaL,IACF,OAAO,yBACP,UAAU,0BACX,QAAQ;;;;;;;;EAgBL,eACF,OAAO,oCACP,UAAU,0BACX,QAAQ;;;;;;;EAeL,OACF,OAAO,4BACP,UAAU,0BACX,QAAQ;;EAUL,KACF,QAAO,2BACP,UAAU,0BACX,QAAQ"}