@levrbet/shared 0.0.1

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 (488) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +92 -0
  3. package/bin/setup-prisma.js +44 -0
  4. package/dist/core/config/dotenv.d.ts +16 -0
  5. package/dist/core/config/dotenv.js +77 -0
  6. package/dist/core/config/dotenv.js.map +1 -0
  7. package/dist/core/config/index.d.ts +2 -0
  8. package/dist/core/config/index.js +19 -0
  9. package/dist/core/config/index.js.map +1 -0
  10. package/dist/core/config/urls.d.ts +55 -0
  11. package/dist/core/config/urls.js +61 -0
  12. package/dist/core/config/urls.js.map +1 -0
  13. package/dist/core/contracts/abis/LevrBaseMarket.d.ts +1009 -0
  14. package/dist/core/contracts/abis/LevrBaseMarket.js +976 -0
  15. package/dist/core/contracts/abis/LevrBaseMarket.js.map +1 -0
  16. package/dist/core/contracts/abis/LevrConfigProvider.d.ts +2671 -0
  17. package/dist/core/contracts/abis/LevrConfigProvider.js +2551 -0
  18. package/dist/core/contracts/abis/LevrConfigProvider.js.map +1 -0
  19. package/dist/core/contracts/abis/LevrFeeCollector.d.ts +259 -0
  20. package/dist/core/contracts/abis/LevrFeeCollector.js +143 -0
  21. package/dist/core/contracts/abis/LevrFeeCollector.js.map +1 -0
  22. package/dist/core/contracts/abis/LevrFulltimeMarket.d.ts +1050 -0
  23. package/dist/core/contracts/abis/LevrFulltimeMarket.js +462 -0
  24. package/dist/core/contracts/abis/LevrFulltimeMarket.js.map +1 -0
  25. package/dist/core/contracts/abis/LevrFundManager.d.ts +51 -0
  26. package/dist/core/contracts/abis/LevrFundManager.js +4 -0
  27. package/dist/core/contracts/abis/LevrFundManager.js.map +1 -0
  28. package/dist/core/contracts/abis/LevrLiquidationEngine.d.ts +244 -0
  29. package/dist/core/contracts/abis/LevrLiquidationEngine.js +231 -0
  30. package/dist/core/contracts/abis/LevrLiquidationEngine.js.map +1 -0
  31. package/dist/core/contracts/abis/LevrManager.d.ts +1281 -0
  32. package/dist/core/contracts/abis/LevrManager.js +1090 -0
  33. package/dist/core/contracts/abis/LevrManager.js.map +1 -0
  34. package/dist/core/contracts/abis/LevrMarketFeed.d.ts +902 -0
  35. package/dist/core/contracts/abis/LevrMarketFeed.js +775 -0
  36. package/dist/core/contracts/abis/LevrMarketFeed.js.map +1 -0
  37. package/dist/core/contracts/abis/LevrMarketMaker.d.ts +175 -0
  38. package/dist/core/contracts/abis/LevrMarketMaker.js +108 -0
  39. package/dist/core/contracts/abis/LevrMarketMaker.js.map +1 -0
  40. package/dist/core/contracts/abis/LevrMarketRiskSentinel.d.ts +682 -0
  41. package/dist/core/contracts/abis/LevrMarketRiskSentinel.js +323 -0
  42. package/dist/core/contracts/abis/LevrMarketRiskSentinel.js.map +1 -0
  43. package/dist/core/contracts/abis/LevrMarketRouter.d.ts +281 -0
  44. package/dist/core/contracts/abis/LevrMarketRouter.js +262 -0
  45. package/dist/core/contracts/abis/LevrMarketRouter.js.map +1 -0
  46. package/dist/core/contracts/abis/LevrMvpDepository.d.ts +766 -0
  47. package/dist/core/contracts/abis/LevrMvpDepository.js +396 -0
  48. package/dist/core/contracts/abis/LevrMvpDepository.js.map +1 -0
  49. package/dist/core/contracts/abis/LevrMvpRouter.d.ts +305 -0
  50. package/dist/core/contracts/abis/LevrMvpRouter.js +291 -0
  51. package/dist/core/contracts/abis/LevrMvpRouter.js.map +1 -0
  52. package/dist/core/contracts/abis/LevrMvpStaker.d.ts +746 -0
  53. package/dist/core/contracts/abis/LevrMvpStaker.js +386 -0
  54. package/dist/core/contracts/abis/LevrMvpStaker.js.map +1 -0
  55. package/dist/core/contracts/abis/LevrMvpToken.d.ts +341 -0
  56. package/dist/core/contracts/abis/LevrMvpToken.js +183 -0
  57. package/dist/core/contracts/abis/LevrMvpToken.js.map +1 -0
  58. package/dist/core/contracts/abis/LevrOrderbook.d.ts +471 -0
  59. package/dist/core/contracts/abis/LevrOrderbook.js +486 -0
  60. package/dist/core/contracts/abis/LevrOrderbook.js.map +1 -0
  61. package/dist/core/contracts/abis/LevrOrderbookLens.d.ts +167 -0
  62. package/dist/core/contracts/abis/LevrOrderbookLens.js +103 -0
  63. package/dist/core/contracts/abis/LevrOrderbookLens.js.map +1 -0
  64. package/dist/core/contracts/abis/LevrOverUnderMarket.d.ts +1054 -0
  65. package/dist/core/contracts/abis/LevrOverUnderMarket.js +463 -0
  66. package/dist/core/contracts/abis/LevrOverUnderMarket.js.map +1 -0
  67. package/dist/core/contracts/abis/LevrPythFeed.d.ts +225 -0
  68. package/dist/core/contracts/abis/LevrPythFeed.js +131 -0
  69. package/dist/core/contracts/abis/LevrPythFeed.js.map +1 -0
  70. package/dist/core/contracts/abis/LevrUtil.d.ts +485 -0
  71. package/dist/core/contracts/abis/LevrUtil.js +226 -0
  72. package/dist/core/contracts/abis/LevrUtil.js.map +1 -0
  73. package/dist/core/contracts/abis/Storage.d.ts +34 -0
  74. package/dist/core/contracts/abis/Storage.js +47 -0
  75. package/dist/core/contracts/abis/Storage.js.map +1 -0
  76. package/dist/core/contracts/abis/index.d.ts +12174 -0
  77. package/dist/core/contracts/abis/index.js +51 -0
  78. package/dist/core/contracts/abis/index.js.map +1 -0
  79. package/dist/core/contracts/addresses.d.ts +154 -0
  80. package/dist/core/contracts/addresses.js +160 -0
  81. package/dist/core/contracts/addresses.js.map +1 -0
  82. package/dist/core/contracts/chains.d.ts +4 -0
  83. package/dist/core/contracts/chains.js +14 -0
  84. package/dist/core/contracts/chains.js.map +1 -0
  85. package/dist/core/contracts/clients/index.d.ts +1 -0
  86. package/dist/core/contracts/clients/index.js +18 -0
  87. package/dist/core/contracts/clients/index.js.map +1 -0
  88. package/dist/core/contracts/clients/publicClients.d.ts +24 -0
  89. package/dist/core/contracts/clients/publicClients.js +123 -0
  90. package/dist/core/contracts/clients/publicClients.js.map +1 -0
  91. package/dist/core/contracts/constants.d.ts +15 -0
  92. package/dist/core/contracts/constants.js +30 -0
  93. package/dist/core/contracts/constants.js.map +1 -0
  94. package/dist/core/contracts/index.d.ts +6 -0
  95. package/dist/core/contracts/index.js +23 -0
  96. package/dist/core/contracts/index.js.map +1 -0
  97. package/dist/core/contracts/instances.d.ts +48 -0
  98. package/dist/core/contracts/instances.js +101 -0
  99. package/dist/core/contracts/instances.js.map +1 -0
  100. package/dist/core/index.d.ts +9 -0
  101. package/dist/core/index.js +26 -0
  102. package/dist/core/index.js.map +1 -0
  103. package/dist/core/indexers/envio.test.query.d.ts +5 -0
  104. package/dist/core/indexers/envio.test.query.js +32 -0
  105. package/dist/core/indexers/envio.test.query.js.map +1 -0
  106. package/dist/core/indexers/index.d.ts +1 -0
  107. package/dist/core/indexers/index.js +18 -0
  108. package/dist/core/indexers/index.js.map +1 -0
  109. package/dist/core/indexers/indexers.service.d.ts +19 -0
  110. package/dist/core/indexers/indexers.service.js +104 -0
  111. package/dist/core/indexers/indexers.service.js.map +1 -0
  112. package/dist/core/indexers/subsquid.test.query.d.ts +4 -0
  113. package/dist/core/indexers/subsquid.test.query.js +42 -0
  114. package/dist/core/indexers/subsquid.test.query.js.map +1 -0
  115. package/dist/core/prisma/index.d.ts +1 -0
  116. package/dist/core/prisma/index.js +21 -0
  117. package/dist/core/prisma/index.js.map +1 -0
  118. package/dist/core/prisma/schema.prisma +360 -0
  119. package/dist/core/privy/constants.d.ts +19 -0
  120. package/dist/core/privy/constants.js +28 -0
  121. package/dist/core/privy/constants.js.map +1 -0
  122. package/dist/core/privy/index.d.ts +1 -0
  123. package/dist/core/privy/index.js +18 -0
  124. package/dist/core/privy/index.js.map +1 -0
  125. package/dist/core/socket.io/events.d.ts +20 -0
  126. package/dist/core/socket.io/events.js +20 -0
  127. package/dist/core/socket.io/events.js.map +1 -0
  128. package/dist/core/socket.io/index.d.ts +2 -0
  129. package/dist/core/socket.io/index.js +19 -0
  130. package/dist/core/socket.io/index.js.map +1 -0
  131. package/dist/core/socket.io/rooms.d.ts +6 -0
  132. package/dist/core/socket.io/rooms.js +10 -0
  133. package/dist/core/socket.io/rooms.js.map +1 -0
  134. package/dist/core/types/auth/auth.types.d.ts +31 -0
  135. package/dist/core/types/auth/auth.types.js +15 -0
  136. package/dist/core/types/auth/auth.types.js.map +1 -0
  137. package/dist/core/types/auth/index.d.ts +2 -0
  138. package/dist/core/types/auth/index.js +19 -0
  139. package/dist/core/types/auth/index.js.map +1 -0
  140. package/dist/core/types/auth/request.types.d.ts +19 -0
  141. package/dist/core/types/auth/request.types.js +15 -0
  142. package/dist/core/types/auth/request.types.js.map +1 -0
  143. package/dist/core/types/blockchain/chains.types.d.ts +3 -0
  144. package/dist/core/types/blockchain/chains.types.js +8 -0
  145. package/dist/core/types/blockchain/chains.types.js.map +1 -0
  146. package/dist/core/types/blockchain/contract.types.d.ts +8 -0
  147. package/dist/core/types/blockchain/contract.types.js +13 -0
  148. package/dist/core/types/blockchain/contract.types.js.map +1 -0
  149. package/dist/core/types/blockchain/index.d.ts +3 -0
  150. package/dist/core/types/blockchain/index.js +20 -0
  151. package/dist/core/types/blockchain/index.js.map +1 -0
  152. package/dist/core/types/blockchain/oz.relayer.types.d.ts +7 -0
  153. package/dist/core/types/blockchain/oz.relayer.types.js +13 -0
  154. package/dist/core/types/blockchain/oz.relayer.types.js.map +1 -0
  155. package/dist/core/types/index.d.ts +6 -0
  156. package/dist/core/types/index.js +23 -0
  157. package/dist/core/types/index.js.map +1 -0
  158. package/dist/core/types/indexers.types.d.ts +4 -0
  159. package/dist/core/types/indexers.types.js +9 -0
  160. package/dist/core/types/indexers.types.js.map +1 -0
  161. package/dist/core/types/misc.types.d.ts +6 -0
  162. package/dist/core/types/misc.types.js +11 -0
  163. package/dist/core/types/misc.types.js.map +1 -0
  164. package/dist/core/types/oracle/fixture.types.d.ts +75 -0
  165. package/dist/core/types/oracle/fixture.types.js +4 -0
  166. package/dist/core/types/oracle/fixture.types.js.map +1 -0
  167. package/dist/core/types/oracle/game/game.types.d.ts +108 -0
  168. package/dist/core/types/oracle/game/game.types.js +64 -0
  169. package/dist/core/types/oracle/game/game.types.js.map +1 -0
  170. package/dist/core/types/oracle/game/index.d.ts +2 -0
  171. package/dist/core/types/oracle/game/index.js +19 -0
  172. package/dist/core/types/oracle/game/index.js.map +1 -0
  173. package/dist/core/types/oracle/game/zod.game.types.d.ts +31 -0
  174. package/dist/core/types/oracle/game/zod.game.types.js +22 -0
  175. package/dist/core/types/oracle/game/zod.game.types.js.map +1 -0
  176. package/dist/core/types/oracle/index.d.ts +4 -0
  177. package/dist/core/types/oracle/index.js +21 -0
  178. package/dist/core/types/oracle/index.js.map +1 -0
  179. package/dist/core/types/oracle/market/index.d.ts +3 -0
  180. package/dist/core/types/oracle/market/index.js +20 -0
  181. package/dist/core/types/oracle/market/index.js.map +1 -0
  182. package/dist/core/types/oracle/market/markets.types.d.ts +95 -0
  183. package/dist/core/types/oracle/market/markets.types.js +35 -0
  184. package/dist/core/types/oracle/market/markets.types.js.map +1 -0
  185. package/dist/core/types/oracle/market/odds.types.d.ts +14 -0
  186. package/dist/core/types/oracle/market/odds.types.js +3 -0
  187. package/dist/core/types/oracle/market/odds.types.js.map +1 -0
  188. package/dist/core/types/oracle/market/positions.types.d.ts +57 -0
  189. package/dist/core/types/oracle/market/positions.types.js +3 -0
  190. package/dist/core/types/oracle/market/positions.types.js.map +1 -0
  191. package/dist/core/types/oracle/requests/game.request.types.d.ts +170 -0
  192. package/dist/core/types/oracle/requests/game.request.types.js +126 -0
  193. package/dist/core/types/oracle/requests/game.request.types.js.map +1 -0
  194. package/dist/core/types/oracle/requests/game.response.types.d.ts +8 -0
  195. package/dist/core/types/oracle/requests/game.response.types.js +3 -0
  196. package/dist/core/types/oracle/requests/game.response.types.js.map +1 -0
  197. package/dist/core/types/oracle/requests/index.d.ts +5 -0
  198. package/dist/core/types/oracle/requests/index.js +22 -0
  199. package/dist/core/types/oracle/requests/index.js.map +1 -0
  200. package/dist/core/types/oracle/requests/market.request.types.d.ts +63 -0
  201. package/dist/core/types/oracle/requests/market.request.types.js +41 -0
  202. package/dist/core/types/oracle/requests/market.request.types.js.map +1 -0
  203. package/dist/core/types/oracle/requests/odds.response.types.d.ts +2 -0
  204. package/dist/core/types/oracle/requests/odds.response.types.js +3 -0
  205. package/dist/core/types/oracle/requests/odds.response.types.js.map +1 -0
  206. package/dist/core/types/oracle/requests/user.request.type.d.ts +4 -0
  207. package/dist/core/types/oracle/requests/user.request.type.js +3 -0
  208. package/dist/core/types/oracle/requests/user.request.type.js.map +1 -0
  209. package/dist/core/types/privy.types.d.ts +4 -0
  210. package/dist/core/types/privy.types.js +9 -0
  211. package/dist/core/types/privy.types.js.map +1 -0
  212. package/dist/core/utils/converters.utils.d.ts +29 -0
  213. package/dist/core/utils/converters.utils.js +97 -0
  214. package/dist/core/utils/converters.utils.js.map +1 -0
  215. package/dist/core/utils/game.utils.d.ts +4 -0
  216. package/dist/core/utils/game.utils.js +79 -0
  217. package/dist/core/utils/game.utils.js.map +1 -0
  218. package/dist/core/utils/index.d.ts +4 -0
  219. package/dist/core/utils/index.js +21 -0
  220. package/dist/core/utils/index.js.map +1 -0
  221. package/dist/core/utils/misc.utils.d.ts +14 -0
  222. package/dist/core/utils/misc.utils.js +33 -0
  223. package/dist/core/utils/misc.utils.js.map +1 -0
  224. package/dist/core/utils/position.utils.d.ts +18 -0
  225. package/dist/core/utils/position.utils.js +68 -0
  226. package/dist/core/utils/position.utils.js.map +1 -0
  227. package/dist/core/validators/bytes.validators.d.ts +32 -0
  228. package/dist/core/validators/bytes.validators.js +47 -0
  229. package/dist/core/validators/bytes.validators.js.map +1 -0
  230. package/dist/core/validators/index.d.ts +2 -0
  231. package/dist/core/validators/index.js +19 -0
  232. package/dist/core/validators/index.js.map +1 -0
  233. package/dist/core/validators/mongo.validators.d.ts +2 -0
  234. package/dist/core/validators/mongo.validators.js +10 -0
  235. package/dist/core/validators/mongo.validators.js.map +1 -0
  236. package/dist/index.d.ts +1 -0
  237. package/dist/index.js +23 -0
  238. package/dist/index.js.map +1 -0
  239. package/dist/react/hooks/auth/index.d.ts +1 -0
  240. package/dist/react/hooks/auth/index.js +18 -0
  241. package/dist/react/hooks/auth/index.js.map +1 -0
  242. package/dist/react/hooks/auth/useAuthHeaders.d.ts +45 -0
  243. package/dist/react/hooks/auth/useAuthHeaders.js +58 -0
  244. package/dist/react/hooks/auth/useAuthHeaders.js.map +1 -0
  245. package/dist/react/hooks/contracts/erc20/index.d.ts +6 -0
  246. package/dist/react/hooks/contracts/erc20/index.js +23 -0
  247. package/dist/react/hooks/contracts/erc20/index.js.map +1 -0
  248. package/dist/react/hooks/contracts/erc20/useApproveErc20.d.ts +13 -0
  249. package/dist/react/hooks/contracts/erc20/useApproveErc20.js +28 -0
  250. package/dist/react/hooks/contracts/erc20/useApproveErc20.js.map +1 -0
  251. package/dist/react/hooks/contracts/erc20/useErc20Allowance.d.ts +10 -0
  252. package/dist/react/hooks/contracts/erc20/useErc20Allowance.js +34 -0
  253. package/dist/react/hooks/contracts/erc20/useErc20Allowance.js.map +1 -0
  254. package/dist/react/hooks/contracts/erc20/useErc20Balance.d.ts +22 -0
  255. package/dist/react/hooks/contracts/erc20/useErc20Balance.js +95 -0
  256. package/dist/react/hooks/contracts/erc20/useErc20Balance.js.map +1 -0
  257. package/dist/react/hooks/contracts/erc20/useErc20Decimals.d.ts +8 -0
  258. package/dist/react/hooks/contracts/erc20/useErc20Decimals.js +28 -0
  259. package/dist/react/hooks/contracts/erc20/useErc20Decimals.js.map +1 -0
  260. package/dist/react/hooks/contracts/erc20/useErc20Symbol.d.ts +8 -0
  261. package/dist/react/hooks/contracts/erc20/useErc20Symbol.js +28 -0
  262. package/dist/react/hooks/contracts/erc20/useErc20Symbol.js.map +1 -0
  263. package/dist/react/hooks/contracts/erc20/useTransferErc20.d.ts +13 -0
  264. package/dist/react/hooks/contracts/erc20/useTransferErc20.js +31 -0
  265. package/dist/react/hooks/contracts/erc20/useTransferErc20.js.map +1 -0
  266. package/dist/react/hooks/contracts/index.d.ts +3 -0
  267. package/dist/react/hooks/contracts/index.js +20 -0
  268. package/dist/react/hooks/contracts/index.js.map +1 -0
  269. package/dist/react/hooks/contracts/useContracts.d.ts +120 -0
  270. package/dist/react/hooks/contracts/useContracts.js +81 -0
  271. package/dist/react/hooks/contracts/useContracts.js.map +1 -0
  272. package/dist/react/hooks/contracts/useLevrMarketContractAddresses.d.ts +3 -0
  273. package/dist/react/hooks/contracts/useLevrMarketContractAddresses.js +27 -0
  274. package/dist/react/hooks/contracts/useLevrMarketContractAddresses.js.map +1 -0
  275. package/dist/react/hooks/index.d.ts +2 -0
  276. package/dist/react/hooks/index.js +19 -0
  277. package/dist/react/hooks/index.js.map +1 -0
  278. package/dist/react/index.d.ts +6 -0
  279. package/dist/react/index.js +23 -0
  280. package/dist/react/index.js.map +1 -0
  281. package/dist/react/injectedDependencies.d.ts +78 -0
  282. package/dist/react/injectedDependencies.js +94 -0
  283. package/dist/react/injectedDependencies.js.map +1 -0
  284. package/dist/react/queryClient.d.ts +9 -0
  285. package/dist/react/queryClient.js +13 -0
  286. package/dist/react/queryClient.js.map +1 -0
  287. package/dist/react/queryKeys.d.ts +17 -0
  288. package/dist/react/queryKeys.js +23 -0
  289. package/dist/react/queryKeys.js.map +1 -0
  290. package/dist/react/types/contracts.types.d.ts +4 -0
  291. package/dist/react/types/contracts.types.js +3 -0
  292. package/dist/react/types/contracts.types.js.map +1 -0
  293. package/dist/react/types/index.d.ts +1 -0
  294. package/dist/react/types/index.js +18 -0
  295. package/dist/react/types/index.js.map +1 -0
  296. package/dist/server/config/cloudflare.d.ts +30 -0
  297. package/dist/server/config/cloudflare.js +45 -0
  298. package/dist/server/config/cloudflare.js.map +1 -0
  299. package/dist/server/config/constants.d.ts +1 -0
  300. package/dist/server/config/constants.js +7 -0
  301. package/dist/server/config/constants.js.map +1 -0
  302. package/dist/server/config/dotenv.d.ts +35 -0
  303. package/dist/server/config/dotenv.js +42 -0
  304. package/dist/server/config/dotenv.js.map +1 -0
  305. package/dist/server/config/index.d.ts +9 -0
  306. package/dist/server/config/index.js +31 -0
  307. package/dist/server/config/index.js.map +1 -0
  308. package/dist/server/config/kms.d.ts +22 -0
  309. package/dist/server/config/kms.js +54 -0
  310. package/dist/server/config/kms.js.map +1 -0
  311. package/dist/server/config/prisma.d.ts +20 -0
  312. package/dist/server/config/prisma.js +40 -0
  313. package/dist/server/config/prisma.js.map +1 -0
  314. package/dist/server/config/redis.d.ts +57 -0
  315. package/dist/server/config/redis.js +121 -0
  316. package/dist/server/config/redis.js.map +1 -0
  317. package/dist/server/config/urls.d.ts +49 -0
  318. package/dist/server/config/urls.js +7 -0
  319. package/dist/server/config/urls.js.map +1 -0
  320. package/dist/server/config/winston.d.ts +3 -0
  321. package/dist/server/config/winston.js +14 -0
  322. package/dist/server/config/winston.js.map +1 -0
  323. package/dist/server/contracts/clients/index.d.ts +1 -0
  324. package/dist/server/contracts/clients/index.js +18 -0
  325. package/dist/server/contracts/clients/index.js.map +1 -0
  326. package/dist/server/contracts/clients/ozRelayerService.d.ts +18 -0
  327. package/dist/server/contracts/clients/ozRelayerService.js +167 -0
  328. package/dist/server/contracts/clients/ozRelayerService.js.map +1 -0
  329. package/dist/server/contracts/index.d.ts +2 -0
  330. package/dist/server/contracts/index.js +19 -0
  331. package/dist/server/contracts/index.js.map +1 -0
  332. package/dist/server/contracts/instances.d.ts +20 -0
  333. package/dist/server/contracts/instances.js +28 -0
  334. package/dist/server/contracts/instances.js.map +1 -0
  335. package/dist/server/index.d.ts +11 -0
  336. package/dist/server/index.js +36 -0
  337. package/dist/server/index.js.map +1 -0
  338. package/dist/server/instrumentation.d.ts +9 -0
  339. package/dist/server/instrumentation.js +37 -0
  340. package/dist/server/instrumentation.js.map +1 -0
  341. package/dist/server/liquidation-engine/index.d.ts +3 -0
  342. package/dist/server/liquidation-engine/index.js +20 -0
  343. package/dist/server/liquidation-engine/index.js.map +1 -0
  344. package/dist/server/liquidation-engine/redis.cache.manager/cache.keys.util.d.ts +10 -0
  345. package/dist/server/liquidation-engine/redis.cache.manager/cache.keys.util.js +15 -0
  346. package/dist/server/liquidation-engine/redis.cache.manager/cache.keys.util.js.map +1 -0
  347. package/dist/server/liquidation-engine/redis.cache.manager/prices.set.manager.d.ts +124 -0
  348. package/dist/server/liquidation-engine/redis.cache.manager/prices.set.manager.js +242 -0
  349. package/dist/server/liquidation-engine/redis.cache.manager/prices.set.manager.js.map +1 -0
  350. package/dist/server/liquidation-engine/redis.cache.manager/prices.set.manager.test.d.ts +1 -0
  351. package/dist/server/liquidation-engine/redis.cache.manager/prices.set.manager.test.js +115 -0
  352. package/dist/server/liquidation-engine/redis.cache.manager/prices.set.manager.test.js.map +1 -0
  353. package/dist/server/liquidation-engine/types/index.d.ts +1 -0
  354. package/dist/server/liquidation-engine/types/index.js +3 -0
  355. package/dist/server/liquidation-engine/types/index.js.map +1 -0
  356. package/dist/server/middleware/auth/cloudflare.handler.d.ts +6 -0
  357. package/dist/server/middleware/auth/cloudflare.handler.js +37 -0
  358. package/dist/server/middleware/auth/cloudflare.handler.js.map +1 -0
  359. package/dist/server/middleware/auth/hmac.handler.d.ts +11 -0
  360. package/dist/server/middleware/auth/hmac.handler.js +157 -0
  361. package/dist/server/middleware/auth/hmac.handler.js.map +1 -0
  362. package/dist/server/middleware/auth/index.d.ts +3 -0
  363. package/dist/server/middleware/auth/index.js +20 -0
  364. package/dist/server/middleware/auth/index.js.map +1 -0
  365. package/dist/server/middleware/auth/privy.handler.d.ts +7 -0
  366. package/dist/server/middleware/auth/privy.handler.js +31 -0
  367. package/dist/server/middleware/auth/privy.handler.js.map +1 -0
  368. package/dist/server/middleware/index.d.ts +2 -0
  369. package/dist/server/middleware/index.js +19 -0
  370. package/dist/server/middleware/index.js.map +1 -0
  371. package/dist/server/middleware/multiAuth.examples.d.ts +46 -0
  372. package/dist/server/middleware/multiAuth.examples.js +123 -0
  373. package/dist/server/middleware/multiAuth.examples.js.map +1 -0
  374. package/dist/server/middleware/multiAuth.middleware.d.ts +30 -0
  375. package/dist/server/middleware/multiAuth.middleware.js +90 -0
  376. package/dist/server/middleware/multiAuth.middleware.js.map +1 -0
  377. package/dist/server/middleware/rateLimit.middleware.d.ts +1 -0
  378. package/dist/server/middleware/rateLimit.middleware.js +19 -0
  379. package/dist/server/middleware/rateLimit.middleware.js.map +1 -0
  380. package/dist/server/oracle/index.d.ts +3 -0
  381. package/dist/server/oracle/index.js +20 -0
  382. package/dist/server/oracle/index.js.map +1 -0
  383. package/dist/server/oracle/redis-cache-manager/cache.keys.utils.d.ts +90 -0
  384. package/dist/server/oracle/redis-cache-manager/cache.keys.utils.js +147 -0
  385. package/dist/server/oracle/redis-cache-manager/cache.keys.utils.js.map +1 -0
  386. package/dist/server/oracle/redis-cache-manager/channels.d.ts +2 -0
  387. package/dist/server/oracle/redis-cache-manager/channels.js +11 -0
  388. package/dist/server/oracle/redis-cache-manager/channels.js.map +1 -0
  389. package/dist/server/oracle/redis-cache-manager/game.cache.service.d.ts +184 -0
  390. package/dist/server/oracle/redis-cache-manager/game.cache.service.js +698 -0
  391. package/dist/server/oracle/redis-cache-manager/game.cache.service.js.map +1 -0
  392. package/dist/server/oracle/redis-cache-manager/index.d.ts +4 -0
  393. package/dist/server/oracle/redis-cache-manager/index.js +21 -0
  394. package/dist/server/oracle/redis-cache-manager/index.js.map +1 -0
  395. package/dist/server/oracle/redis-cache-manager/market.cache.service.d.ts +115 -0
  396. package/dist/server/oracle/redis-cache-manager/market.cache.service.js +279 -0
  397. package/dist/server/oracle/redis-cache-manager/market.cache.service.js.map +1 -0
  398. package/dist/server/oracle/rmq-manager/base.queue.manager.d.ts +21 -0
  399. package/dist/server/oracle/rmq-manager/base.queue.manager.js +128 -0
  400. package/dist/server/oracle/rmq-manager/base.queue.manager.js.map +1 -0
  401. package/dist/server/oracle/rmq-manager/index.d.ts +2 -0
  402. package/dist/server/oracle/rmq-manager/index.js +19 -0
  403. package/dist/server/oracle/rmq-manager/index.js.map +1 -0
  404. package/dist/server/oracle/rmq-manager/queue.configs.d.ts +5 -0
  405. package/dist/server/oracle/rmq-manager/queue.configs.js +38 -0
  406. package/dist/server/oracle/rmq-manager/queue.configs.js.map +1 -0
  407. package/dist/server/oracle/types/index.d.ts +2 -0
  408. package/dist/server/oracle/types/index.js +19 -0
  409. package/dist/server/oracle/types/index.js.map +1 -0
  410. package/dist/server/oracle/types/providers/index.d.ts +4 -0
  411. package/dist/server/oracle/types/providers/index.js +21 -0
  412. package/dist/server/oracle/types/providers/index.js.map +1 -0
  413. package/dist/server/oracle/types/providers/lsports.types.d.ts +148 -0
  414. package/dist/server/oracle/types/providers/lsports.types.js +13 -0
  415. package/dist/server/oracle/types/providers/lsports.types.js.map +1 -0
  416. package/dist/server/oracle/types/providers/optic.odds.types.d.ts +293 -0
  417. package/dist/server/oracle/types/providers/optic.odds.types.js +140 -0
  418. package/dist/server/oracle/types/providers/optic.odds.types.js.map +1 -0
  419. package/dist/server/oracle/types/providers/providers.types.d.ts +5 -0
  420. package/dist/server/oracle/types/providers/providers.types.js +10 -0
  421. package/dist/server/oracle/types/providers/providers.types.js.map +1 -0
  422. package/dist/server/oracle/types/providers/rundown.types.d.ts +194 -0
  423. package/dist/server/oracle/types/providers/rundown.types.js +22 -0
  424. package/dist/server/oracle/types/providers/rundown.types.js.map +1 -0
  425. package/dist/server/oracle/types/queue/index.d.ts +2 -0
  426. package/dist/server/oracle/types/queue/index.js +19 -0
  427. package/dist/server/oracle/types/queue/index.js.map +1 -0
  428. package/dist/server/oracle/types/queue/queue.constant.d.ts +10 -0
  429. package/dist/server/oracle/types/queue/queue.constant.js +14 -0
  430. package/dist/server/oracle/types/queue/queue.constant.js.map +1 -0
  431. package/dist/server/oracle/types/queue/queue.types.d.ts +5 -0
  432. package/dist/server/oracle/types/queue/queue.types.js +3 -0
  433. package/dist/server/oracle/types/queue/queue.types.js.map +1 -0
  434. package/dist/server/prisma/index.d.ts +2 -0
  435. package/dist/server/prisma/index.js +24 -0
  436. package/dist/server/prisma/index.js.map +1 -0
  437. package/dist/server/repositories/apiKey.repository.d.ts +7 -0
  438. package/dist/server/repositories/apiKey.repository.js +19 -0
  439. package/dist/server/repositories/apiKey.repository.js.map +1 -0
  440. package/dist/server/repositories/index.d.ts +1 -0
  441. package/dist/server/repositories/index.js +18 -0
  442. package/dist/server/repositories/index.js.map +1 -0
  443. package/dist/server/services/cloudflare.service.d.ts +12 -0
  444. package/dist/server/services/cloudflare.service.js +24 -0
  445. package/dist/server/services/cloudflare.service.js.map +1 -0
  446. package/dist/server/services/crypto.service.d.ts +17 -0
  447. package/dist/server/services/crypto.service.js +50 -0
  448. package/dist/server/services/crypto.service.js.map +1 -0
  449. package/dist/server/services/hmac.service.d.ts +52 -0
  450. package/dist/server/services/hmac.service.js +115 -0
  451. package/dist/server/services/hmac.service.js.map +1 -0
  452. package/dist/server/services/index.d.ts +5 -0
  453. package/dist/server/services/index.js +22 -0
  454. package/dist/server/services/index.js.map +1 -0
  455. package/dist/server/services/presigned.urls.d.ts +11 -0
  456. package/dist/server/services/presigned.urls.js +41 -0
  457. package/dist/server/services/presigned.urls.js.map +1 -0
  458. package/dist/server/services/privy.service.d.ts +30 -0
  459. package/dist/server/services/privy.service.js +122 -0
  460. package/dist/server/services/privy.service.js.map +1 -0
  461. package/dist/server/test-relayers.d.ts +1 -0
  462. package/dist/server/test-relayers.js +17 -0
  463. package/dist/server/test-relayers.js.map +1 -0
  464. package/dist/server/types/auth.types.d.ts +8 -0
  465. package/dist/server/types/auth.types.js +3 -0
  466. package/dist/server/types/auth.types.js.map +1 -0
  467. package/dist/server/types/global.types.d.ts +35 -0
  468. package/dist/server/types/global.types.js +4 -0
  469. package/dist/server/types/global.types.js.map +1 -0
  470. package/dist/server/types/index.d.ts +2 -0
  471. package/dist/server/types/index.js +19 -0
  472. package/dist/server/types/index.js.map +1 -0
  473. package/dist/server/utils/express.utils.d.ts +24 -0
  474. package/dist/server/utils/express.utils.js +36 -0
  475. package/dist/server/utils/express.utils.js.map +1 -0
  476. package/dist/server/utils/index.d.ts +2 -0
  477. package/dist/server/utils/index.js +19 -0
  478. package/dist/server/utils/index.js.map +1 -0
  479. package/dist/server/utils/tracing/index.d.ts +2 -0
  480. package/dist/server/utils/tracing/index.js +19 -0
  481. package/dist/server/utils/tracing/index.js.map +1 -0
  482. package/dist/server/utils/tracing/trace.d.ts +12 -0
  483. package/dist/server/utils/tracing/trace.js +50 -0
  484. package/dist/server/utils/tracing/trace.js.map +1 -0
  485. package/dist/server/utils/tracing/wrap.module.with.tracing.d.ts +126 -0
  486. package/dist/server/utils/tracing/wrap.module.with.tracing.js +202 -0
  487. package/dist/server/utils/tracing/wrap.module.with.tracing.js.map +1 -0
  488. package/package.json +126 -0
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateRequest = validateRequest;
4
+ /**
5
+ * Validates a part of an Express request using a Zod schema and returns the validated data.
6
+ *
7
+ * @param schema - The Zod schema to validate against
8
+ * @param req - The Express request object
9
+ * @param part - The part of the request to validate ("body", "query", "params", etc.)
10
+ * @param res - The Express response object
11
+ * @returns The validated data if successful, undefined if validation fails (and sends 400 response)
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const bodySchema = z.object({ name: z.string() });
16
+ *
17
+ * app.post("/api", (req, res) => {
18
+ * const body = validateRequest(bodySchema, req, "body", res);
19
+ * if (!body) return;
20
+ * // body is now typed as { name: string }
21
+ * console.log(body.name);
22
+ * });
23
+ * ```
24
+ */
25
+ function validateRequest(schema, req, part, res) {
26
+ const result = schema.safeParse(req[part]);
27
+ if (!result.success) {
28
+ res.status(400).json({
29
+ error: `Validation failed for request ${part.toString()}`,
30
+ details: result.error.issues,
31
+ });
32
+ return undefined;
33
+ }
34
+ return result.data;
35
+ }
36
+ //# sourceMappingURL=express.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"express.utils.js","sourceRoot":"","sources":["../../../src/server/utils/express.utils.ts"],"names":[],"mappings":";;AAwBA,0CAYC;AAjCD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,eAAe,CAAI,MAAkB,EAAE,GAAY,EAAE,IAAmB,EAAE,GAAa;IACnG,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA;IAE1C,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAClB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACjB,KAAK,EAAE,iCAAiC,IAAI,CAAC,QAAQ,EAAE,EAAE;YACzD,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM;SAC/B,CAAC,CAAA;QACF,OAAO,SAAS,CAAA;IACpB,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAA;AACtB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./express.utils";
2
+ export * from "./tracing";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./express.utils"), exports);
18
+ __exportStar(require("./tracing"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;AAC/B,4CAAyB"}
@@ -0,0 +1,2 @@
1
+ export * from "./trace";
2
+ export * from "./wrap.module.with.tracing";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./trace"), exports);
18
+ __exportStar(require("./wrap.module.with.tracing"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/server/utils/tracing/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,6DAA0C"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Traces a function call with OpenTelemetry.
3
+ * @param fn The function to trace.
4
+ * @param attributes Optional attributes to set on the span.
5
+ * @notice all sync functions are elevated to async functions for uniformity
6
+ * @returns The result of the function call.
7
+ */
8
+ export declare const traceFn: <T>(fn: () => T | Promise<T>, attributes?: Record<string, string>) => Promise<T>;
9
+ /**
10
+ * Wraps a function in an OpenTelemetry span.
11
+ */
12
+ export declare const traceWrap: <T extends (...args: unknown[]) => Promise<U>, U>(fn: T) => T;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.traceWrap = exports.traceFn = void 0;
4
+ const api_1 = require("@opentelemetry/api");
5
+ /**
6
+ * Traces a function call with OpenTelemetry.
7
+ * @param fn The function to trace.
8
+ * @param attributes Optional attributes to set on the span.
9
+ * @notice all sync functions are elevated to async functions for uniformity
10
+ * @returns The result of the function call.
11
+ */
12
+ const traceFn = async (fn, attributes) => {
13
+ const tracer = api_1.trace.getTracer("default");
14
+ return tracer.startActiveSpan(fn.name || "anonymous", async (span) => {
15
+ try {
16
+ if (attributes) {
17
+ span.setAttributes(attributes);
18
+ }
19
+ const result = fn(); // don’t await yet
20
+ if (result instanceof Promise) {
21
+ const awaited = await result;
22
+ span.setStatus({ code: 0 }); // Assuming 0 is OK
23
+ return awaited;
24
+ }
25
+ else {
26
+ span.setStatus({ code: 0 }); // Assuming 0 is OK
27
+ return result;
28
+ }
29
+ }
30
+ catch (error) {
31
+ span.recordException(error);
32
+ span.setStatus({ code: 2, message: error.message });
33
+ throw error;
34
+ }
35
+ finally {
36
+ span.end();
37
+ }
38
+ });
39
+ };
40
+ exports.traceFn = traceFn;
41
+ /**
42
+ * Wraps a function in an OpenTelemetry span.
43
+ */
44
+ const traceWrap = (fn) => {
45
+ return (async (...args) => {
46
+ return (0, exports.traceFn)(() => fn(...args));
47
+ });
48
+ };
49
+ exports.traceWrap = traceWrap;
50
+ //# sourceMappingURL=trace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace.js","sourceRoot":"","sources":["../../../../src/server/utils/tracing/trace.ts"],"names":[],"mappings":";;;AAAA,4CAA0C;AAE1C;;;;;;GAMG;AACI,MAAM,OAAO,GAAG,KAAK,EAAK,EAAwB,EAAE,UAAmC,EAAc,EAAE;IAC1G,MAAM,MAAM,GAAG,WAAK,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;IAEzC,OAAO,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC,IAAI,IAAI,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACjE,IAAI,CAAC;YACD,IAAI,UAAU,EAAE,CAAC;gBACb,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAA;YAClC,CAAC;YAED,MAAM,MAAM,GAAG,EAAE,EAAE,CAAA,CAAC,kBAAkB;YACtC,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;gBAC5B,MAAM,OAAO,GAAG,MAAM,MAAM,CAAA;gBAC5B,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAA,CAAC,mBAAmB;gBAC/C,OAAO,OAAO,CAAA;YAClB,CAAC;iBAAM,CAAC;gBACJ,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAA,CAAC,mBAAmB;gBAC/C,OAAO,MAAM,CAAA;YACjB,CAAC;QACL,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACtB,IAAI,CAAC,eAAe,CAAC,KAAc,CAAC,CAAA;YACpC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAG,KAAe,CAAC,OAAO,EAAE,CAAC,CAAA;YAC9D,MAAM,KAAK,CAAA;QACf,CAAC;gBAAS,CAAC;YACP,IAAI,CAAC,GAAG,EAAE,CAAA;QACd,CAAC;IACL,CAAC,CAAC,CAAA;AACN,CAAC,CAAA;AA1BY,QAAA,OAAO,WA0BnB;AAED;;GAEG;AACI,MAAM,SAAS,GAAG,CAAkD,EAAK,EAAK,EAAE;IACnF,OAAO,CAAC,KAAK,EAAE,GAAG,IAAmB,EAAE,EAAE;QACrC,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IACrC,CAAC,CAAM,CAAA;AACX,CAAC,CAAA;AAJY,QAAA,SAAS,aAIrB"}
@@ -0,0 +1,126 @@
1
+ import { type NextFunction } from "express";
2
+ /**
3
+ * Wraps an Express request handler with tracing instrumentation.
4
+ *
5
+ * This utility function is intended to be used as a higher-order function to add tracing capabilities
6
+ * to any standard Express handler. It leverages the `traceFn` function to automatically trace the
7
+ * execution of the wrapped handler, capturing relevant telemetry for observability and debugging.
8
+ *
9
+ * The wrapped handler maintains the original signature and supports both synchronous and asynchronous
10
+ * handlers. Any errors thrown by the handler will propagate as usual, allowing Express error handling
11
+ * middleware to function as expected.
12
+ *
13
+ * @template TReq - The type of the Express request object. Defaults to `Request`.
14
+ * @template TRes - The type of the Express response object. Defaults to `Response`.
15
+ * @param handler - The original Express handler function to be wrapped. It can be synchronous or return a Promise.
16
+ * @returns A new Express-compatible handler function with tracing instrumentation applied.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * app.get('/endpoint', wrapExpressHandler(async (req, res) => {
21
+ * // handler logic
22
+ * }));
23
+ * ```
24
+ *
25
+ * @remarks
26
+ * - The `traceFn` function must be defined in the scope and should handle the tracing logic.
27
+ * - This wrapper is transparent to the handler's logic and does not alter request or response objects.
28
+ */
29
+ export declare function wrapExpressHandler<TReq extends Request = Request, TRes extends Response = Response>(handler: (req: TReq, res: TRes, next?: NextFunction) => void | Promise<void>): (req: TReq, res: TRes, next?: NextFunction) => Promise<void>;
30
+ /**
31
+ * Wraps all function properties of a given module object with tracing logic.
32
+ *
33
+ * This utility iterates over each property of the provided module object. If a property is a function,
34
+ * it replaces it with an async wrapper that invokes the original function within a tracing context
35
+ * using `traceFn`. Non-function properties are copied as-is. The returned object preserves the original
36
+ * module's shape and types.
37
+ *
38
+ * @typeParam T - The type of the module object whose functions will be wrapped.
39
+ * @param module - The module object whose function properties should be wrapped with tracing.
40
+ * @returns A new object with the same properties as the input module, where all function properties
41
+ * are wrapped with tracing logic.
42
+ *
43
+ * @remarks
44
+ * - The tracing logic assumes that all function properties are asynchronous and return Promises.
45
+ * - The original module object is not mutated; a new object is returned.
46
+ * - Non-function properties are shallow-copied.
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const tracedModule = wrapFunctionsWithTracing(myModule);
51
+ * await tracedModule.someAsyncFunction();
52
+ * ```
53
+ */
54
+ export declare function wrapFunctionsWithTracing<T extends object>(module: T): T;
55
+ /**
56
+ * Wraps a class method with tracing logic, supporting both synchronous and asynchronous functions.
57
+ *
58
+ * This decorator factory intercepts method calls, invoking the provided `traceFn` utility to record
59
+ * tracing information for each invocation. It ensures that both synchronous and asynchronous methods
60
+ * are traced uniformly by always passing a Promise to `traceFn`. The original method's `this` context
61
+ * and arguments are preserved.
62
+ *
63
+ * @template This - The type of the class instance (`this`) the method belongs to.
64
+ * @template Args - The tuple type representing the method's argument list.
65
+ * @template Return - The return type of the original method.
66
+ *
67
+ * @param target - The original method to be wrapped and traced.
68
+ * @param context - The decorator context, providing metadata such as the method name.
69
+ * @returns A replacement method that wraps the original method with tracing logic.
70
+ *
71
+ * @remarks
72
+ * - The tracing is performed by the `traceFn` utility, which is expected to handle both sync and async flows.
73
+ * - The method name is extracted from the decorator context and passed as metadata to `traceFn`.
74
+ * - This utility is intended for use as a method decorator in class-based modules.
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * class MyService {
79
+ * @traced
80
+ * async fetchData(id: string): Promise<Data> {
81
+ * // ...
82
+ * }
83
+ * }
84
+ * ```
85
+ */
86
+ export declare function traced<This, Args extends unknown[], Return>(target: (this: This, ...args: Args) => Return, context: ClassMethodDecoratorContext<This, (this: This, ...args: Args) => Return>): (this: This, ...args: Args) => Return;
87
+ type Constructor<T = object> = new (...args: any[]) => T;
88
+ /**
89
+ * A class decorator factory that wraps all methods of a given class with tracing logic.
90
+ *
91
+ * This higher-order function returns a new class that extends the provided `BaseClass`.
92
+ * In the constructor of the new class, it iterates over all own property names of the prototype,
93
+ * and for each method (excluding the constructor), it replaces the method with a wrapped version
94
+ * that invokes the `traceFn` function. This enables automatic tracing of both async and sync methods.
95
+ *
96
+ * - Async methods are detected by checking if the method's constructor name is `"AsyncFunction"`.
97
+ * - Both async and sync methods are wrapped such that their execution is traced, and the method name
98
+ * is passed as metadata to the tracing function.
99
+ * - The original method's `this` context and arguments are preserved.
100
+ *
101
+ * @template TBase - The type of the base class to be extended and wrapped.
102
+ * @param BaseClass - The class whose methods should be wrapped with tracing logic.
103
+ * @returns A new class extending `BaseClass` with all methods wrapped for tracing.
104
+ *
105
+ * @example
106
+ * ```typescript
107
+ * @TracedClass
108
+ * class MyService {
109
+ * async fetchData() { ... }
110
+ * calculate() { ... }
111
+ * }
112
+ * or
113
+ * const TracedService = TracedClass(MyService);
114
+ * const service = new TracedService();
115
+ * // All method calls on `service` will be traced.
116
+ * ```
117
+ *
118
+ * @remarks
119
+ * - The `traceFn` function must be defined in the module scope and should accept a function to execute
120
+ * and an options object containing at least the method name.
121
+ * - This decorator is intended for use in environments where method-level tracing is required for
122
+ * observability or debugging purposes.
123
+ * - The decorator assumes that all methods are either synchronous or asynchronous functions.
124
+ */
125
+ export declare function TracedClass<TBase extends Constructor>(BaseClass: TBase): TBase;
126
+ export {};
@@ -0,0 +1,202 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.wrapExpressHandler = wrapExpressHandler;
4
+ exports.wrapFunctionsWithTracing = wrapFunctionsWithTracing;
5
+ exports.traced = traced;
6
+ exports.TracedClass = TracedClass;
7
+ const trace_1 = require("./trace");
8
+ /**
9
+ * Wraps an Express request handler with tracing instrumentation.
10
+ *
11
+ * This utility function is intended to be used as a higher-order function to add tracing capabilities
12
+ * to any standard Express handler. It leverages the `traceFn` function to automatically trace the
13
+ * execution of the wrapped handler, capturing relevant telemetry for observability and debugging.
14
+ *
15
+ * The wrapped handler maintains the original signature and supports both synchronous and asynchronous
16
+ * handlers. Any errors thrown by the handler will propagate as usual, allowing Express error handling
17
+ * middleware to function as expected.
18
+ *
19
+ * @template TReq - The type of the Express request object. Defaults to `Request`.
20
+ * @template TRes - The type of the Express response object. Defaults to `Response`.
21
+ * @param handler - The original Express handler function to be wrapped. It can be synchronous or return a Promise.
22
+ * @returns A new Express-compatible handler function with tracing instrumentation applied.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * app.get('/endpoint', wrapExpressHandler(async (req, res) => {
27
+ * // handler logic
28
+ * }));
29
+ * ```
30
+ *
31
+ * @remarks
32
+ * - The `traceFn` function must be defined in the scope and should handle the tracing logic.
33
+ * - This wrapper is transparent to the handler's logic and does not alter request or response objects.
34
+ */
35
+ function wrapExpressHandler(handler) {
36
+ return async (req, res, next) => {
37
+ return (0, trace_1.traceFn)(async () => {
38
+ await handler(req, res, next);
39
+ });
40
+ };
41
+ }
42
+ /**
43
+ * Wraps all function properties of a given module object with tracing logic.
44
+ *
45
+ * This utility iterates over each property of the provided module object. If a property is a function,
46
+ * it replaces it with an async wrapper that invokes the original function within a tracing context
47
+ * using `traceFn`. Non-function properties are copied as-is. The returned object preserves the original
48
+ * module's shape and types.
49
+ *
50
+ * @typeParam T - The type of the module object whose functions will be wrapped.
51
+ * @param module - The module object whose function properties should be wrapped with tracing.
52
+ * @returns A new object with the same properties as the input module, where all function properties
53
+ * are wrapped with tracing logic.
54
+ *
55
+ * @remarks
56
+ * - The tracing logic assumes that all function properties are asynchronous and return Promises.
57
+ * - The original module object is not mutated; a new object is returned.
58
+ * - Non-function properties are shallow-copied.
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * const tracedModule = wrapFunctionsWithTracing(myModule);
63
+ * await tracedModule.someAsyncFunction();
64
+ * ```
65
+ */
66
+ function wrapFunctionsWithTracing(module) {
67
+ const wrapped = {};
68
+ for (const key of Object.keys(module)) {
69
+ const value = module[key];
70
+ if (typeof value === "function") {
71
+ wrapped[key] = (async (...args) => {
72
+ return (0, trace_1.traceFn)(() => value(...args));
73
+ });
74
+ }
75
+ else {
76
+ wrapped[key] = value;
77
+ }
78
+ }
79
+ return wrapped;
80
+ }
81
+ /**
82
+ * Wraps a class method with tracing logic, supporting both synchronous and asynchronous functions.
83
+ *
84
+ * This decorator factory intercepts method calls, invoking the provided `traceFn` utility to record
85
+ * tracing information for each invocation. It ensures that both synchronous and asynchronous methods
86
+ * are traced uniformly by always passing a Promise to `traceFn`. The original method's `this` context
87
+ * and arguments are preserved.
88
+ *
89
+ * @template This - The type of the class instance (`this`) the method belongs to.
90
+ * @template Args - The tuple type representing the method's argument list.
91
+ * @template Return - The return type of the original method.
92
+ *
93
+ * @param target - The original method to be wrapped and traced.
94
+ * @param context - The decorator context, providing metadata such as the method name.
95
+ * @returns A replacement method that wraps the original method with tracing logic.
96
+ *
97
+ * @remarks
98
+ * - The tracing is performed by the `traceFn` utility, which is expected to handle both sync and async flows.
99
+ * - The method name is extracted from the decorator context and passed as metadata to `traceFn`.
100
+ * - This utility is intended for use as a method decorator in class-based modules.
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * class MyService {
105
+ * @traced
106
+ * async fetchData(id: string): Promise<Data> {
107
+ * // ...
108
+ * }
109
+ * }
110
+ * ```
111
+ */
112
+ function traced(target, context) {
113
+ const methodName = String(context.name);
114
+ return function replacementMethod(...args) {
115
+ // Handle both sync and async functions
116
+ const result = target.call(this, ...args);
117
+ if (result instanceof Promise) {
118
+ return (0, trace_1.traceFn)(() => result, { method: methodName });
119
+ }
120
+ else {
121
+ // If it's a synchronous function, we can still trace it
122
+ return (0, trace_1.traceFn)(() => Promise.resolve(result), { method: methodName });
123
+ }
124
+ };
125
+ }
126
+ /**
127
+ * A class decorator factory that wraps all methods of a given class with tracing logic.
128
+ *
129
+ * This higher-order function returns a new class that extends the provided `BaseClass`.
130
+ * In the constructor of the new class, it iterates over all own property names of the prototype,
131
+ * and for each method (excluding the constructor), it replaces the method with a wrapped version
132
+ * that invokes the `traceFn` function. This enables automatic tracing of both async and sync methods.
133
+ *
134
+ * - Async methods are detected by checking if the method's constructor name is `"AsyncFunction"`.
135
+ * - Both async and sync methods are wrapped such that their execution is traced, and the method name
136
+ * is passed as metadata to the tracing function.
137
+ * - The original method's `this` context and arguments are preserved.
138
+ *
139
+ * @template TBase - The type of the base class to be extended and wrapped.
140
+ * @param BaseClass - The class whose methods should be wrapped with tracing logic.
141
+ * @returns A new class extending `BaseClass` with all methods wrapped for tracing.
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * @TracedClass
146
+ * class MyService {
147
+ * async fetchData() { ... }
148
+ * calculate() { ... }
149
+ * }
150
+ * or
151
+ * const TracedService = TracedClass(MyService);
152
+ * const service = new TracedService();
153
+ * // All method calls on `service` will be traced.
154
+ * ```
155
+ *
156
+ * @remarks
157
+ * - The `traceFn` function must be defined in the module scope and should accept a function to execute
158
+ * and an options object containing at least the method name.
159
+ * - This decorator is intended for use in environments where method-level tracing is required for
160
+ * observability or debugging purposes.
161
+ * - The decorator assumes that all methods are either synchronous or asynchronous functions.
162
+ */
163
+ function TracedClass(BaseClass) {
164
+ return class extends BaseClass {
165
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
166
+ constructor(...args) {
167
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
168
+ super(...args);
169
+ const prototype = Object.getPrototypeOf(this);
170
+ for (const key of Object.getOwnPropertyNames(prototype)) {
171
+ if (key === "constructor")
172
+ continue;
173
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, key);
174
+ const method = descriptor?.value;
175
+ if (typeof method === "function" && method.constructor.name === "AsyncFunction") {
176
+ const wrapped = async (...args) => {
177
+ return (0, trace_1.traceFn)(() => method.apply(this, args), { method: key });
178
+ };
179
+ Object.defineProperty(this, key, {
180
+ value: wrapped,
181
+ writable: true,
182
+ configurable: true,
183
+ });
184
+ }
185
+ else {
186
+ // If it's not an async function, we can still trace it
187
+ const wrapped = (...args) => {
188
+ return (0, trace_1.traceFn)(() => Promise.resolve(method.apply(this, args)), {
189
+ method: key,
190
+ });
191
+ };
192
+ Object.defineProperty(this, key, {
193
+ value: wrapped,
194
+ writable: true,
195
+ configurable: true,
196
+ });
197
+ }
198
+ }
199
+ }
200
+ };
201
+ }
202
+ //# sourceMappingURL=wrap.module.with.tracing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrap.module.with.tracing.js","sourceRoot":"","sources":["../../../../src/server/utils/tracing/wrap.module.with.tracing.ts"],"names":[],"mappings":";;AA8BA,gDAQC;AA0BD,4DAgBC;AAiCD,wBAiBC;AA2CD,kCAwCC;AApND,mCAAiC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,kBAAkB,CAC9B,OAA4E;IAE5E,OAAO,KAAK,EAAE,GAAS,EAAE,GAAS,EAAE,IAAmB,EAAE,EAAE;QACvD,OAAO,IAAA,eAAO,EAAC,KAAK,IAAI,EAAE;YACtB,MAAM,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;QACjC,CAAC,CAAC,CAAA;IACN,CAAC,CAAA;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAgB,wBAAwB,CAAmB,MAAS;IAChE,MAAM,OAAO,GAAe,EAAE,CAAA;IAE9B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACpC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAc,CAAC,CAAA;QAEpC,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;YAC9B,OAAO,CAAC,GAAc,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,IAAe,EAAE,EAAE;gBACpD,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE,CAAE,KAAkD,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;YACtF,CAAC,CAA0B,CAAA;QAC/B,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,GAAc,CAAC,GAAG,KAAK,CAAA;QACnC,CAAC;IACL,CAAC;IAED,OAAO,OAAY,CAAA;AACvB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,SAAgB,MAAM,CAClB,MAA6C,EAC7C,OAAiF;IAEjF,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAEvC,OAAO,SAAS,iBAAiB,CAAa,GAAG,IAAU;QACvD,uCAAuC;QACvC,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAA;QAEzC,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;YAC5B,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,CAAW,CAAA;QAClE,CAAC;aAAM,CAAC;YACJ,wDAAwD;YACxD,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,CAAW,CAAA;QACnF,CAAC;IACL,CAAC,CAAA;AACL,CAAC;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,SAAgB,WAAW,CAA4B,SAAgB;IACnE,OAAO,KAAM,SAAQ,SAAS;QAC1B,8DAA8D;QAC9D,YAAY,GAAG,IAAW;YACtB,iEAAiE;YACjE,KAAK,CAAC,GAAG,IAAI,CAAC,CAAA;YAEd,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAW,CAAA;YAEvD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,mBAAmB,CAAC,SAAS,CAAC,EAAE,CAAC;gBACtD,IAAI,GAAG,KAAK,aAAa;oBAAE,SAAQ;gBAEnC,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;gBAClE,MAAM,MAAM,GAAG,UAAU,EAAE,KAAgB,CAAA;gBAE3C,IAAI,OAAO,MAAM,KAAK,UAAU,IAAI,MAAM,CAAC,WAAW,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;oBAC9E,MAAM,OAAO,GAAG,KAAK,EAAE,GAAG,IAAe,EAAoB,EAAE;wBAC3D,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE,CAAE,MAAsB,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;oBACpF,CAAC,CAAA;oBACD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE;wBAC7B,KAAK,EAAE,OAAO;wBACd,QAAQ,EAAE,IAAI;wBACd,YAAY,EAAE,IAAI;qBACrB,CAAC,CAAA;gBACN,CAAC;qBAAM,CAAC;oBACJ,uDAAuD;oBACvD,MAAM,OAAO,GAAG,CAAC,GAAG,IAAe,EAAW,EAAE;wBAC5C,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAE,MAA0C,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE;4BACjG,MAAM,EAAE,GAAG;yBACd,CAAC,CAAA;oBACN,CAAC,CAAA;oBACD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE;wBAC7B,KAAK,EAAE,OAAO;wBACd,QAAQ,EAAE,IAAI;wBACd,YAAY,EAAE,IAAI;qBACrB,CAAC,CAAA;gBACN,CAAC;YACL,CAAC;QACL,CAAC;KACJ,CAAA;AACL,CAAC"}
package/package.json ADDED
@@ -0,0 +1,126 @@
1
+ {
2
+ "name": "@levrbet/shared",
3
+ "version": "0.0.1",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/index.js",
10
+ "require": "./dist/index.js"
11
+ },
12
+ "./core": {
13
+ "types": "./dist/core/index.d.ts",
14
+ "import": "./dist/core/index.js",
15
+ "require": "./dist/core/index.js"
16
+ },
17
+ "./server": {
18
+ "types": "./dist/server/index.d.ts",
19
+ "import": "./dist/server/index.js",
20
+ "require": "./dist/server/index.js"
21
+ },
22
+ "./react": {
23
+ "types": "./dist/react/index.d.ts",
24
+ "import": "./dist/react/index.js",
25
+ "require": "./dist/react/index.js"
26
+ }
27
+ },
28
+ "bin": {
29
+ "levrbet-setup-prisma": "./bin/setup-prisma.js"
30
+ },
31
+ "files": [
32
+ "dist",
33
+ "bin"
34
+ ],
35
+ "sideEffects": false,
36
+ "scripts": {
37
+ "build": "npm run clean && npx prisma generate && npx tsc && npm run copy-assets",
38
+ "build:publish": "npm run clean && npx prisma generate && npx tsc && npm run copy-schema",
39
+ "dev": "npm run build && npm pack",
40
+ "copy-assets": "mkdir -p dist/core/prisma/generated && cp -r src/core/prisma/generated/* dist/core/prisma/generated/",
41
+ "copy-schema": "mkdir -p dist/core/prisma && cp src/core/prisma/schema.prisma dist/core/prisma/",
42
+ "clean": "rm -rf dist",
43
+ "prepublishOnly": "npm run build:publish",
44
+ "test-get-healthy-indexer": "tsx src/core/indexers/indexers.service.ts"
45
+ },
46
+ "peerDependencies": {
47
+ "@privy-io/react-auth": ">=3.0.0",
48
+ "@tanstack/react-query": ">=5.0.0",
49
+ "@types/react": ">=18.0.0",
50
+ "prisma": ">=6.0.0",
51
+ "react": ">=18.0.0"
52
+ },
53
+ "peerDependenciesMeta": {
54
+ "react": {
55
+ "optional": true
56
+ },
57
+ "@types/react": {
58
+ "optional": true
59
+ },
60
+ "@tanstack/react-query": {
61
+ "optional": true
62
+ },
63
+ "@privy-io/react-auth": {
64
+ "optional": true
65
+ },
66
+ "prisma": {
67
+ "optional": true
68
+ }
69
+ },
70
+ "devDependencies": {
71
+ "@privy-io/react-auth": ">=3.0.0",
72
+ "@swc-node/register": "^1.11.1",
73
+ "@tanstack/react-query": ">=5.0.0",
74
+ "@types/express": "^5.0.3",
75
+ "@types/lodash": "^4.17.20",
76
+ "@types/ms": "^2.1.0",
77
+ "@types/node": "24.9.1",
78
+ "@types/object-hash": "^3.0.6",
79
+ "@types/react": ">=18.0.0",
80
+ "cross-fetch": "^4.1.0",
81
+ "prisma": "^6.19.0",
82
+ "react": ">=18.0.0",
83
+ "tsx": "^4.20.6",
84
+ "typescript": "^5.9.3"
85
+ },
86
+ "dependencies": {
87
+ "@aws-sdk/client-kms": "^3.913.0",
88
+ "@aws-sdk/client-s3": "^3.926.0",
89
+ "@aws-sdk/client-sts": "^3.913.0",
90
+ "@aws-sdk/s3-request-presigner": "^3.926.0",
91
+ "@opentelemetry/api": "^1.9.0",
92
+ "@opentelemetry/auto-instrumentations-node": "0.65.0",
93
+ "@opentelemetry/exporter-metrics-otlp-http": "^0.206.0",
94
+ "@opentelemetry/exporter-trace-otlp-http": "^0.206.0",
95
+ "@opentelemetry/resources": "^2.1.0",
96
+ "@opentelemetry/sdk-metrics": "^2.1.0",
97
+ "@opentelemetry/sdk-node": "^0.206.0",
98
+ "@openzeppelin/relayer-sdk": "^1.6.0",
99
+ "@prisma/client": "^6.19.0",
100
+ "@privy-io/node": "^0.3.0",
101
+ "@types/amqplib": "^0.10.7",
102
+ "amqplib": "^0.10.9",
103
+ "axios": "^1.12.2",
104
+ "bson": "^6.10.4",
105
+ "coralogix-logger": "^1.1.34",
106
+ "dayjs": "^1.11.18",
107
+ "dotenv": "17.2.3",
108
+ "express": "^5.1.0",
109
+ "express-rate-limit": "^8.1.0",
110
+ "ioredis": "^5.8.1",
111
+ "jose": "^6.1.0",
112
+ "lodash": "^4.17.21",
113
+ "ms": "^2.1.3",
114
+ "object-hash": "^3.0.0",
115
+ "ox": "^0.9.12",
116
+ "rate-limit-redis": "^4.2.3",
117
+ "redis": "^5.8.3",
118
+ "typescript-memoize": "^1.1.1",
119
+ "viem": "2.38.3",
120
+ "winston": "3.18.3",
121
+ "zod": "^4.1.12"
122
+ },
123
+ "publishConfig": {
124
+ "access": "public"
125
+ }
126
+ }