@lyxa.ai/marketing 1.0.51 → 1.0.53

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 (481) hide show
  1. package/dist/lib/index.d.ts +323 -77
  2. package/dist/lib/index.d.ts.map +1 -1
  3. package/dist/lib/index.js +1 -1
  4. package/dist/lib/index.js.map +1 -1
  5. package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
  6. package/dist/lib/modules/coupon/routers/coupon.router.js +1 -1
  7. package/dist/lib/modules/coupon/routers/coupon.router.js.map +1 -1
  8. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
  9. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js +16 -3
  10. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js.map +1 -1
  11. package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts +1117 -285
  12. package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
  13. package/dist/lib/modules/coupon/validations/all-coupons.validation.js +16 -2
  14. package/dist/lib/modules/coupon/validations/all-coupons.validation.js.map +1 -1
  15. package/dist/lib/modules/coupon/validations/index.d.ts +0 -1
  16. package/dist/lib/modules/coupon/validations/index.d.ts.map +1 -1
  17. package/dist/lib/modules/coupon/validations/index.js +0 -1
  18. package/dist/lib/modules/coupon/validations/index.js.map +1 -1
  19. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts +32 -32
  20. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js +9 -9
  21. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js.map +1 -1
  22. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts +0 -1
  23. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts.map +1 -1
  24. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.js +2 -5
  25. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.js.map +1 -1
  26. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts +1 -0
  27. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts.map +1 -1
  28. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.js +2 -0
  29. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.js.map +1 -1
  30. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +19 -6
  31. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts.map +1 -1
  32. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js +3 -2
  33. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js.map +1 -1
  34. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts +3 -9
  35. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
  36. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js +4 -7
  37. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js.map +1 -1
  38. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts +1 -0
  39. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts.map +1 -1
  40. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.service.js +15 -0
  41. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.service.js.map +1 -1
  42. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts +96 -50
  43. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
  44. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.js +23 -0
  45. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.js.map +1 -1
  46. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts +18 -0
  47. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -0
  48. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js +78 -0
  49. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js.map +1 -0
  50. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +12 -0
  51. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
  52. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js +68 -0
  53. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js.map +1 -1
  54. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +22 -18
  55. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
  56. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts +1 -0
  57. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts.map +1 -0
  58. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.js +2 -0
  59. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.js.map +1 -0
  60. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +88 -83
  61. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
  62. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js +3 -2
  63. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js.map +1 -1
  64. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +10 -1
  65. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  66. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js +68 -22
  67. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js.map +1 -1
  68. package/dist/lib/modules/marketing/validations/product-marketing.validation.d.ts +2 -2
  69. package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +1 -1
  70. package/dist/lib/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +2 -2
  71. package/dist/lib/modules/tournament/config/config.builder.d.ts.map +1 -1
  72. package/dist/lib/modules/tournament/config/config.builder.js +4 -0
  73. package/dist/lib/modules/tournament/config/config.builder.js.map +1 -1
  74. package/dist/lib/modules/tournament/config/config.repository.d.ts +8 -2
  75. package/dist/lib/modules/tournament/config/config.repository.d.ts.map +1 -1
  76. package/dist/lib/modules/tournament/config/config.repository.js +30 -1
  77. package/dist/lib/modules/tournament/config/config.repository.js.map +1 -1
  78. package/dist/lib/modules/tournament/config/config.router.d.ts +102 -12
  79. package/dist/lib/modules/tournament/config/config.router.d.ts.map +1 -1
  80. package/dist/lib/modules/tournament/config/config.types.d.ts +15 -0
  81. package/dist/lib/modules/tournament/config/config.types.d.ts.map +1 -0
  82. package/dist/lib/modules/tournament/config/config.types.js +3 -0
  83. package/dist/lib/modules/tournament/config/config.types.js.map +1 -0
  84. package/dist/lib/modules/tournament/config/config.validation.d.ts +431 -52
  85. package/dist/lib/modules/tournament/config/config.validation.d.ts.map +1 -1
  86. package/dist/lib/modules/tournament/config/config.validation.js +20 -6
  87. package/dist/lib/modules/tournament/config/config.validation.js.map +1 -1
  88. package/dist/lib/modules/tournament/integration/integration.factory.d.ts +4 -0
  89. package/dist/lib/modules/tournament/integration/integration.factory.d.ts.map +1 -0
  90. package/dist/lib/modules/tournament/integration/integration.factory.js +18 -0
  91. package/dist/lib/modules/tournament/integration/integration.factory.js.map +1 -0
  92. package/dist/lib/modules/tournament/integration/interfaces/ITournamentService.d.ts +36 -0
  93. package/dist/lib/modules/tournament/integration/interfaces/ITournamentService.d.ts.map +1 -0
  94. package/dist/lib/modules/tournament/integration/interfaces/ITournamentService.js +3 -0
  95. package/dist/lib/modules/tournament/integration/interfaces/ITournamentService.js.map +1 -0
  96. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.provider.d.ts +14 -0
  97. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.provider.d.ts.map +1 -0
  98. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.provider.js +92 -0
  99. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.provider.js.map +1 -0
  100. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.types.d.ts +51 -0
  101. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.types.d.ts.map +1 -0
  102. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.types.js +3 -0
  103. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.types.js.map +1 -0
  104. package/dist/lib/modules/tournament/integration/providers/api-football/index.d.ts +3 -0
  105. package/dist/lib/modules/tournament/integration/providers/api-football/index.d.ts.map +1 -0
  106. package/dist/lib/modules/tournament/integration/providers/api-football/index.js +19 -0
  107. package/dist/lib/modules/tournament/integration/providers/api-football/index.js.map +1 -0
  108. package/dist/lib/modules/tournament/integration/providers/index.d.ts +3 -0
  109. package/dist/lib/modules/tournament/integration/providers/index.d.ts.map +1 -0
  110. package/dist/lib/modules/tournament/integration/providers/index.js +19 -0
  111. package/dist/lib/modules/tournament/integration/providers/index.js.map +1 -0
  112. package/dist/lib/modules/tournament/integration/providers/mock.provider.d.ts +7 -0
  113. package/dist/lib/modules/tournament/integration/providers/mock.provider.d.ts.map +1 -0
  114. package/dist/lib/modules/tournament/integration/providers/mock.provider.js +22 -0
  115. package/dist/lib/modules/tournament/integration/providers/mock.provider.js.map +1 -0
  116. package/dist/lib/modules/tournament/integration/tournamentService.d.ts +9 -0
  117. package/dist/lib/modules/tournament/integration/tournamentService.d.ts.map +1 -0
  118. package/dist/lib/modules/tournament/integration/tournamentService.js +20 -0
  119. package/dist/lib/modules/tournament/integration/tournamentService.js.map +1 -0
  120. package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.d.ts.map +1 -1
  121. package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js +50 -11
  122. package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js.map +1 -1
  123. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.d.ts +7 -3
  124. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.d.ts.map +1 -1
  125. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.js +1 -1
  126. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.js.map +1 -1
  127. package/dist/lib/modules/tournament/match/events/match-evaluation.orchestrator.d.ts +14 -0
  128. package/dist/lib/modules/tournament/match/events/match-evaluation.orchestrator.d.ts.map +1 -0
  129. package/dist/lib/modules/tournament/{notification/jobs/notification.worker.js → match/events/match-evaluation.orchestrator.js} +31 -27
  130. package/dist/lib/modules/tournament/match/events/match-evaluation.orchestrator.js.map +1 -0
  131. package/dist/lib/modules/tournament/match/match.builder.d.ts +13 -34
  132. package/dist/lib/modules/tournament/match/match.builder.d.ts.map +1 -1
  133. package/dist/lib/modules/tournament/match/match.builder.js +31 -10
  134. package/dist/lib/modules/tournament/match/match.builder.js.map +1 -1
  135. package/dist/lib/modules/tournament/match/match.repository.d.ts +1 -1
  136. package/dist/lib/modules/tournament/match/match.repository.d.ts.map +1 -1
  137. package/dist/lib/modules/tournament/match/match.repository.js.map +1 -1
  138. package/dist/lib/modules/tournament/match/match.router.d.ts +40 -4
  139. package/dist/lib/modules/tournament/match/match.router.d.ts.map +1 -1
  140. package/dist/lib/modules/tournament/match/match.service.d.ts +3 -0
  141. package/dist/lib/modules/tournament/match/match.service.d.ts.map +1 -1
  142. package/dist/lib/modules/tournament/match/match.service.js +15 -12
  143. package/dist/lib/modules/tournament/match/match.service.js.map +1 -1
  144. package/dist/lib/modules/tournament/match/match.types.d.ts +51 -0
  145. package/dist/lib/modules/tournament/match/match.types.d.ts.map +1 -0
  146. package/dist/lib/modules/tournament/match/match.types.js +3 -0
  147. package/dist/lib/modules/tournament/match/match.types.js.map +1 -0
  148. package/dist/lib/modules/tournament/notification/notification-template.repository.d.ts +2 -1
  149. package/dist/lib/modules/tournament/notification/notification-template.repository.d.ts.map +1 -1
  150. package/dist/lib/modules/tournament/notification/notification-template.repository.js +2 -1
  151. package/dist/lib/modules/tournament/notification/notification-template.repository.js.map +1 -1
  152. package/dist/lib/modules/tournament/notification/notification.builder.d.ts +30 -0
  153. package/dist/lib/modules/tournament/notification/notification.builder.d.ts.map +1 -0
  154. package/dist/lib/modules/tournament/notification/notification.builder.js +35 -0
  155. package/dist/lib/modules/tournament/notification/notification.builder.js.map +1 -0
  156. package/dist/lib/modules/tournament/notification/notification.config.d.ts +10 -9
  157. package/dist/lib/modules/tournament/notification/notification.config.d.ts.map +1 -1
  158. package/dist/lib/modules/tournament/notification/notification.config.js +0 -12
  159. package/dist/lib/modules/tournament/notification/notification.config.js.map +1 -1
  160. package/dist/lib/modules/tournament/notification/notification.service.d.ts +5 -3
  161. package/dist/lib/modules/tournament/notification/notification.service.d.ts.map +1 -1
  162. package/dist/lib/modules/tournament/notification/notification.service.js +23 -15
  163. package/dist/lib/modules/tournament/notification/notification.service.js.map +1 -1
  164. package/dist/lib/modules/tournament/participant/participant.builder.d.ts +12 -0
  165. package/dist/lib/modules/tournament/participant/participant.builder.d.ts.map +1 -0
  166. package/dist/lib/modules/tournament/participant/participant.builder.js +17 -0
  167. package/dist/lib/modules/tournament/participant/participant.builder.js.map +1 -0
  168. package/dist/lib/modules/tournament/participant/participant.repository.d.ts +8 -7
  169. package/dist/lib/modules/tournament/participant/participant.repository.d.ts.map +1 -1
  170. package/dist/lib/modules/tournament/participant/participant.repository.js +12 -2
  171. package/dist/lib/modules/tournament/participant/participant.repository.js.map +1 -1
  172. package/dist/lib/modules/tournament/participant/participant.service.d.ts +1 -0
  173. package/dist/lib/modules/tournament/participant/participant.service.d.ts.map +1 -1
  174. package/dist/lib/modules/tournament/participant/participant.service.js +15 -17
  175. package/dist/lib/modules/tournament/participant/participant.service.js.map +1 -1
  176. package/dist/lib/modules/tournament/prediction/prediction.builder.d.ts +3 -9
  177. package/dist/lib/modules/tournament/prediction/prediction.builder.d.ts.map +1 -1
  178. package/dist/lib/modules/tournament/prediction/prediction.builder.js.map +1 -1
  179. package/dist/lib/modules/tournament/prediction/prediction.repository.d.ts +11 -3
  180. package/dist/lib/modules/tournament/prediction/prediction.repository.d.ts.map +1 -1
  181. package/dist/lib/modules/tournament/prediction/prediction.repository.js +47 -0
  182. package/dist/lib/modules/tournament/prediction/prediction.repository.js.map +1 -1
  183. package/dist/lib/modules/tournament/prediction/prediction.service.d.ts +1 -1
  184. package/dist/lib/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
  185. package/dist/lib/modules/tournament/prediction/prediction.service.js +16 -26
  186. package/dist/lib/modules/tournament/prediction/prediction.service.js.map +1 -1
  187. package/dist/lib/modules/tournament/prediction/prediction.types.d.ts +17 -0
  188. package/dist/lib/modules/tournament/prediction/prediction.types.d.ts.map +1 -0
  189. package/dist/lib/modules/tournament/prediction/prediction.types.js +3 -0
  190. package/dist/lib/modules/tournament/prediction/prediction.types.js.map +1 -0
  191. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.d.ts +8 -5
  192. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.d.ts.map +1 -1
  193. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.js +58 -16
  194. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.js.map +1 -1
  195. package/dist/lib/modules/tournament/reward/reward.builder.d.ts +5 -2
  196. package/dist/lib/modules/tournament/reward/reward.builder.d.ts.map +1 -1
  197. package/dist/lib/modules/tournament/reward/reward.builder.js +44 -28
  198. package/dist/lib/modules/tournament/reward/reward.builder.js.map +1 -1
  199. package/dist/lib/modules/tournament/reward/reward.factory.d.ts +1 -1
  200. package/dist/lib/modules/tournament/reward/reward.factory.d.ts.map +1 -1
  201. package/dist/lib/modules/tournament/reward/reward.factory.js.map +1 -1
  202. package/dist/lib/modules/tournament/reward/reward.interface.d.ts +2 -2
  203. package/dist/lib/modules/tournament/reward/reward.interface.d.ts.map +1 -1
  204. package/dist/lib/modules/tournament/reward/reward.interface.js.map +1 -1
  205. package/dist/lib/modules/tournament/reward/reward.service.d.ts +1 -1
  206. package/dist/lib/modules/tournament/reward/reward.service.d.ts.map +1 -1
  207. package/dist/lib/modules/tournament/reward/reward.service.js +1 -1
  208. package/dist/lib/modules/tournament/reward/reward.service.js.map +1 -1
  209. package/dist/lib/modules/tournament/reward/reward.types.d.ts +35 -2
  210. package/dist/lib/modules/tournament/reward/reward.types.d.ts.map +1 -1
  211. package/dist/lib/modules/tournament/reward/reward.types.js.map +1 -1
  212. package/dist/lib/modules/tournament/schedule/schedule.router.d.ts.map +1 -1
  213. package/dist/lib/modules/tournament/schedule/schedule.router.js +1 -3
  214. package/dist/lib/modules/tournament/schedule/schedule.router.js.map +1 -1
  215. package/dist/lib/modules/tournament/schedule/schedule.service.d.ts +3 -0
  216. package/dist/lib/modules/tournament/schedule/schedule.service.d.ts.map +1 -1
  217. package/dist/lib/modules/tournament/schedule/schedule.service.js +30 -1
  218. package/dist/lib/modules/tournament/schedule/schedule.service.js.map +1 -1
  219. package/dist/lib/modules/tournament/score/score.repository.d.ts +13 -0
  220. package/dist/lib/modules/tournament/score/score.repository.d.ts.map +1 -1
  221. package/dist/lib/modules/tournament/score/score.repository.js +20 -0
  222. package/dist/lib/modules/tournament/score/score.repository.js.map +1 -1
  223. package/dist/lib/modules/tournament/score/score.service.d.ts +3 -0
  224. package/dist/lib/modules/tournament/score/score.service.d.ts.map +1 -1
  225. package/dist/lib/modules/tournament/score/score.service.js +3 -0
  226. package/dist/lib/modules/tournament/score/score.service.js.map +1 -1
  227. package/dist/lib/modules/tournament/statistics/statistics.builder.d.ts +5 -0
  228. package/dist/lib/modules/tournament/statistics/statistics.builder.d.ts.map +1 -1
  229. package/dist/lib/modules/tournament/statistics/statistics.builder.js +47 -28
  230. package/dist/lib/modules/tournament/statistics/statistics.builder.js.map +1 -1
  231. package/dist/lib/modules/tournament/statistics/statistics.router.d.ts +4 -2
  232. package/dist/lib/modules/tournament/statistics/statistics.router.d.ts.map +1 -1
  233. package/dist/lib/modules/tournament/statistics/statistics.service.js +4 -4
  234. package/dist/lib/modules/tournament/statistics/statistics.service.js.map +1 -1
  235. package/dist/lib/modules/tournament/statistics/statistics.validation.d.ts +32 -14
  236. package/dist/lib/modules/tournament/statistics/statistics.validation.d.ts.map +1 -1
  237. package/dist/lib/modules/tournament/statistics/statistics.validation.js +2 -1
  238. package/dist/lib/modules/tournament/statistics/statistics.validation.js.map +1 -1
  239. package/dist/lib/modules/tournament/sync/sync.repository.d.ts +11 -0
  240. package/dist/lib/modules/tournament/sync/sync.repository.d.ts.map +1 -0
  241. package/dist/lib/modules/tournament/{notification/notification.scheduler.service.js → sync/sync.repository.js} +22 -28
  242. package/dist/lib/modules/tournament/sync/sync.repository.js.map +1 -0
  243. package/dist/lib/modules/tournament/sync/sync.router.d.ts +27 -0
  244. package/dist/lib/modules/tournament/sync/sync.router.d.ts.map +1 -0
  245. package/dist/lib/modules/tournament/sync/sync.router.js +15 -0
  246. package/dist/lib/modules/tournament/sync/sync.router.js.map +1 -0
  247. package/dist/lib/modules/tournament/sync/sync.service.d.ts +9 -0
  248. package/dist/lib/modules/tournament/sync/sync.service.d.ts.map +1 -0
  249. package/dist/lib/modules/tournament/sync/sync.service.js +117 -0
  250. package/dist/lib/modules/tournament/sync/sync.service.js.map +1 -0
  251. package/dist/lib/modules/tournament/team/team.builder.d.ts +4 -0
  252. package/dist/lib/modules/tournament/team/team.builder.d.ts.map +1 -1
  253. package/dist/lib/modules/tournament/team/team.builder.js +6 -0
  254. package/dist/lib/modules/tournament/team/team.builder.js.map +1 -1
  255. package/dist/lib/modules/tournament/team/team.repository.d.ts +3 -0
  256. package/dist/lib/modules/tournament/team/team.repository.d.ts.map +1 -1
  257. package/dist/lib/modules/tournament/team/team.repository.js +6 -0
  258. package/dist/lib/modules/tournament/team/team.repository.js.map +1 -1
  259. package/dist/lib/modules/tournament/team/team.router.d.ts +24 -6
  260. package/dist/lib/modules/tournament/team/team.router.d.ts.map +1 -1
  261. package/dist/lib/modules/tournament/team/team.router.js +1 -1
  262. package/dist/lib/modules/tournament/team/team.router.js.map +1 -1
  263. package/dist/lib/modules/tournament/team/team.service.d.ts +2 -1
  264. package/dist/lib/modules/tournament/team/team.service.d.ts.map +1 -1
  265. package/dist/lib/modules/tournament/team/team.service.js +26 -23
  266. package/dist/lib/modules/tournament/team/team.service.js.map +1 -1
  267. package/dist/lib/modules/tournament/team/team.validation.d.ts +23 -24
  268. package/dist/lib/modules/tournament/team/team.validation.d.ts.map +1 -1
  269. package/dist/lib/modules/tournament/team/team.validation.js +3 -4
  270. package/dist/lib/modules/tournament/team/team.validation.js.map +1 -1
  271. package/dist/lib/modules/tournament/tournament.builder.d.ts +11 -0
  272. package/dist/lib/modules/tournament/tournament.builder.d.ts.map +1 -0
  273. package/dist/lib/modules/tournament/tournament.builder.js +34 -0
  274. package/dist/lib/modules/tournament/tournament.builder.js.map +1 -0
  275. package/dist/lib/modules/tournament/tournament.router.d.ts +226 -26
  276. package/dist/lib/modules/tournament/tournament.router.d.ts.map +1 -1
  277. package/dist/lib/modules/tournament/tournament.router.js +2 -0
  278. package/dist/lib/modules/tournament/tournament.router.js.map +1 -1
  279. package/dist/lib/modules/tournament/tournament.service.d.ts.map +1 -1
  280. package/dist/lib/modules/tournament/tournament.service.js +3 -10
  281. package/dist/lib/modules/tournament/tournament.service.js.map +1 -1
  282. package/dist/lib/modules/tournament/tournament.types.d.ts +0 -3
  283. package/dist/lib/modules/tournament/tournament.types.d.ts.map +1 -1
  284. package/dist/lib/modules/tournament/tournament.types.js +1 -5
  285. package/dist/lib/modules/tournament/tournament.types.js.map +1 -1
  286. package/dist/lib/modules/tournament/tournament.utils.d.ts +4 -0
  287. package/dist/lib/modules/tournament/tournament.utils.d.ts.map +1 -1
  288. package/dist/lib/modules/tournament/tournament.utils.js +8 -1
  289. package/dist/lib/modules/tournament/tournament.utils.js.map +1 -1
  290. package/dist/lib/modules/tournament/tournament.validation.d.ts +205 -1
  291. package/dist/lib/modules/tournament/tournament.validation.d.ts.map +1 -1
  292. package/dist/lib/modules/tournament/tournament.validation.js +23 -2
  293. package/dist/lib/modules/tournament/tournament.validation.js.map +1 -1
  294. package/dist/types/index.d.ts +323 -77
  295. package/dist/types/index.d.ts.map +1 -1
  296. package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
  297. package/dist/types/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
  298. package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts +1117 -285
  299. package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
  300. package/dist/types/modules/coupon/validations/index.d.ts +0 -1
  301. package/dist/types/modules/coupon/validations/index.d.ts.map +1 -1
  302. package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts +34 -32
  303. package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
  304. package/dist/types/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts +0 -1
  305. package/dist/types/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts.map +1 -1
  306. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts +1 -0
  307. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts.map +1 -1
  308. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +19 -6
  309. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts.map +1 -1
  310. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts +3 -9
  311. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
  312. package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts +1 -0
  313. package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts.map +1 -1
  314. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts +96 -50
  315. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
  316. package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts +23 -0
  317. package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -0
  318. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +12 -0
  319. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
  320. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +22 -18
  321. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
  322. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +88 -83
  323. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
  324. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +20 -1
  325. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  326. package/dist/types/modules/marketing/validations/product-marketing.validation.d.ts +2 -2
  327. package/dist/types/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +1 -1
  328. package/dist/types/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +2 -2
  329. package/dist/types/modules/tournament/config/config.builder.d.ts.map +1 -1
  330. package/dist/types/modules/tournament/config/config.repository.d.ts +8 -2
  331. package/dist/types/modules/tournament/config/config.repository.d.ts.map +1 -1
  332. package/dist/types/modules/tournament/config/config.router.d.ts +102 -12
  333. package/dist/types/modules/tournament/config/config.router.d.ts.map +1 -1
  334. package/dist/types/modules/tournament/config/config.types.d.ts +15 -0
  335. package/dist/types/modules/tournament/config/config.types.d.ts.map +1 -0
  336. package/dist/types/modules/tournament/config/config.validation.d.ts +431 -52
  337. package/dist/types/modules/tournament/config/config.validation.d.ts.map +1 -1
  338. package/dist/types/modules/tournament/integration/integration.factory.d.ts +4 -0
  339. package/dist/types/modules/tournament/integration/integration.factory.d.ts.map +1 -0
  340. package/dist/types/modules/tournament/integration/interfaces/ITournamentService.d.ts +36 -0
  341. package/dist/types/modules/tournament/integration/interfaces/ITournamentService.d.ts.map +1 -0
  342. package/dist/types/modules/tournament/integration/providers/api-football/api-football.provider.d.ts +14 -0
  343. package/dist/types/modules/tournament/integration/providers/api-football/api-football.provider.d.ts.map +1 -0
  344. package/dist/types/modules/tournament/integration/providers/api-football/api-football.types.d.ts +51 -0
  345. package/dist/types/modules/tournament/integration/providers/api-football/api-football.types.d.ts.map +1 -0
  346. package/dist/types/modules/tournament/integration/providers/api-football/index.d.ts +3 -0
  347. package/dist/types/modules/tournament/integration/providers/api-football/index.d.ts.map +1 -0
  348. package/dist/types/modules/tournament/integration/providers/index.d.ts +3 -0
  349. package/dist/types/modules/tournament/integration/providers/index.d.ts.map +1 -0
  350. package/dist/types/modules/tournament/integration/providers/mock.provider.d.ts +7 -0
  351. package/dist/types/modules/tournament/integration/providers/mock.provider.d.ts.map +1 -0
  352. package/dist/types/modules/tournament/integration/tournamentService.d.ts +9 -0
  353. package/dist/types/modules/tournament/integration/tournamentService.d.ts.map +1 -0
  354. package/dist/types/modules/tournament/match/events/evaluate-predictions.consumer.d.ts.map +1 -1
  355. package/dist/types/modules/tournament/match/events/evaluate-predictions.event.d.ts +7 -3
  356. package/dist/types/modules/tournament/match/events/evaluate-predictions.event.d.ts.map +1 -1
  357. package/dist/types/modules/tournament/match/events/match-evaluation.orchestrator.d.ts +14 -0
  358. package/dist/types/modules/tournament/match/events/match-evaluation.orchestrator.d.ts.map +1 -0
  359. package/dist/types/modules/tournament/match/match.builder.d.ts +13 -34
  360. package/dist/types/modules/tournament/match/match.builder.d.ts.map +1 -1
  361. package/dist/types/modules/tournament/match/match.repository.d.ts +1 -1
  362. package/dist/types/modules/tournament/match/match.repository.d.ts.map +1 -1
  363. package/dist/types/modules/tournament/match/match.router.d.ts +40 -4
  364. package/dist/types/modules/tournament/match/match.router.d.ts.map +1 -1
  365. package/dist/types/modules/tournament/match/match.service.d.ts +3 -0
  366. package/dist/types/modules/tournament/match/match.service.d.ts.map +1 -1
  367. package/dist/types/modules/tournament/match/match.types.d.ts +51 -0
  368. package/dist/types/modules/tournament/match/match.types.d.ts.map +1 -0
  369. package/dist/types/modules/tournament/notification/notification-template.repository.d.ts +2 -1
  370. package/dist/types/modules/tournament/notification/notification-template.repository.d.ts.map +1 -1
  371. package/dist/types/modules/tournament/notification/notification.builder.d.ts +30 -0
  372. package/dist/types/modules/tournament/notification/notification.builder.d.ts.map +1 -0
  373. package/dist/types/modules/tournament/notification/notification.config.d.ts +10 -9
  374. package/dist/types/modules/tournament/notification/notification.config.d.ts.map +1 -1
  375. package/dist/types/modules/tournament/notification/notification.service.d.ts +5 -3
  376. package/dist/types/modules/tournament/notification/notification.service.d.ts.map +1 -1
  377. package/dist/types/modules/tournament/participant/participant.builder.d.ts +12 -0
  378. package/dist/types/modules/tournament/participant/participant.builder.d.ts.map +1 -0
  379. package/dist/types/modules/tournament/participant/participant.repository.d.ts +8 -7
  380. package/dist/types/modules/tournament/participant/participant.repository.d.ts.map +1 -1
  381. package/dist/types/modules/tournament/participant/participant.service.d.ts +1 -0
  382. package/dist/types/modules/tournament/participant/participant.service.d.ts.map +1 -1
  383. package/dist/types/modules/tournament/prediction/prediction.builder.d.ts +3 -9
  384. package/dist/types/modules/tournament/prediction/prediction.builder.d.ts.map +1 -1
  385. package/dist/types/modules/tournament/prediction/prediction.repository.d.ts +11 -3
  386. package/dist/types/modules/tournament/prediction/prediction.repository.d.ts.map +1 -1
  387. package/dist/types/modules/tournament/prediction/prediction.service.d.ts +1 -1
  388. package/dist/types/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
  389. package/dist/types/modules/tournament/prediction/prediction.types.d.ts +17 -0
  390. package/dist/types/modules/tournament/prediction/prediction.types.d.ts.map +1 -0
  391. package/dist/types/modules/tournament/reward/handlers/coupon-reward.handler.d.ts +8 -5
  392. package/dist/types/modules/tournament/reward/handlers/coupon-reward.handler.d.ts.map +1 -1
  393. package/dist/types/modules/tournament/reward/reward.builder.d.ts +5 -2
  394. package/dist/types/modules/tournament/reward/reward.builder.d.ts.map +1 -1
  395. package/dist/types/modules/tournament/reward/reward.factory.d.ts +1 -1
  396. package/dist/types/modules/tournament/reward/reward.factory.d.ts.map +1 -1
  397. package/dist/types/modules/tournament/reward/reward.interface.d.ts +2 -2
  398. package/dist/types/modules/tournament/reward/reward.interface.d.ts.map +1 -1
  399. package/dist/types/modules/tournament/reward/reward.service.d.ts +1 -1
  400. package/dist/types/modules/tournament/reward/reward.service.d.ts.map +1 -1
  401. package/dist/types/modules/tournament/reward/reward.types.d.ts +35 -2
  402. package/dist/types/modules/tournament/reward/reward.types.d.ts.map +1 -1
  403. package/dist/types/modules/tournament/schedule/schedule.router.d.ts.map +1 -1
  404. package/dist/types/modules/tournament/schedule/schedule.service.d.ts +3 -0
  405. package/dist/types/modules/tournament/schedule/schedule.service.d.ts.map +1 -1
  406. package/dist/types/modules/tournament/score/score.repository.d.ts +13 -0
  407. package/dist/types/modules/tournament/score/score.repository.d.ts.map +1 -1
  408. package/dist/types/modules/tournament/score/score.service.d.ts +3 -0
  409. package/dist/types/modules/tournament/score/score.service.d.ts.map +1 -1
  410. package/dist/types/modules/tournament/statistics/statistics.builder.d.ts +5 -0
  411. package/dist/types/modules/tournament/statistics/statistics.builder.d.ts.map +1 -1
  412. package/dist/types/modules/tournament/statistics/statistics.router.d.ts +4 -2
  413. package/dist/types/modules/tournament/statistics/statistics.router.d.ts.map +1 -1
  414. package/dist/types/modules/tournament/statistics/statistics.validation.d.ts +32 -14
  415. package/dist/types/modules/tournament/statistics/statistics.validation.d.ts.map +1 -1
  416. package/dist/types/modules/tournament/sync/sync.repository.d.ts +11 -0
  417. package/dist/types/modules/tournament/sync/sync.repository.d.ts.map +1 -0
  418. package/dist/types/modules/tournament/sync/sync.router.d.ts +27 -0
  419. package/dist/types/modules/tournament/sync/sync.router.d.ts.map +1 -0
  420. package/dist/types/modules/tournament/sync/sync.service.d.ts +9 -0
  421. package/dist/types/modules/tournament/sync/sync.service.d.ts.map +1 -0
  422. package/dist/types/modules/tournament/team/team.builder.d.ts +4 -0
  423. package/dist/types/modules/tournament/team/team.builder.d.ts.map +1 -1
  424. package/dist/types/modules/tournament/team/team.repository.d.ts +3 -0
  425. package/dist/types/modules/tournament/team/team.repository.d.ts.map +1 -1
  426. package/dist/types/modules/tournament/team/team.router.d.ts +24 -6
  427. package/dist/types/modules/tournament/team/team.router.d.ts.map +1 -1
  428. package/dist/types/modules/tournament/team/team.service.d.ts +2 -1
  429. package/dist/types/modules/tournament/team/team.service.d.ts.map +1 -1
  430. package/dist/types/modules/tournament/team/team.validation.d.ts +23 -24
  431. package/dist/types/modules/tournament/team/team.validation.d.ts.map +1 -1
  432. package/dist/types/modules/tournament/tournament.builder.d.ts +11 -0
  433. package/dist/types/modules/tournament/tournament.builder.d.ts.map +1 -0
  434. package/dist/types/modules/tournament/tournament.router.d.ts +226 -26
  435. package/dist/types/modules/tournament/tournament.router.d.ts.map +1 -1
  436. package/dist/types/modules/tournament/tournament.service.d.ts.map +1 -1
  437. package/dist/types/modules/tournament/tournament.types.d.ts +0 -3
  438. package/dist/types/modules/tournament/tournament.types.d.ts.map +1 -1
  439. package/dist/types/modules/tournament/tournament.utils.d.ts +4 -0
  440. package/dist/types/modules/tournament/tournament.utils.d.ts.map +1 -1
  441. package/dist/types/modules/tournament/tournament.validation.d.ts +205 -1
  442. package/dist/types/modules/tournament/tournament.validation.d.ts.map +1 -1
  443. package/package.json +3 -3
  444. package/dist/lib/modules/tournament/match/events/match-ended.consumer.d.ts +0 -2
  445. package/dist/lib/modules/tournament/match/events/match-ended.consumer.d.ts.map +0 -1
  446. package/dist/lib/modules/tournament/match/events/match-ended.consumer.js +0 -15
  447. package/dist/lib/modules/tournament/match/events/match-ended.consumer.js.map +0 -1
  448. package/dist/lib/modules/tournament/match/events/match-ended.event.d.ts +0 -14
  449. package/dist/lib/modules/tournament/match/events/match-ended.event.d.ts.map +0 -1
  450. package/dist/lib/modules/tournament/match/events/match-ended.event.js +0 -12
  451. package/dist/lib/modules/tournament/match/events/match-ended.event.js.map +0 -1
  452. package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts +0 -10
  453. package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts.map +0 -1
  454. package/dist/lib/modules/tournament/notification/jobs/notification.producer.js +0 -23
  455. package/dist/lib/modules/tournament/notification/jobs/notification.producer.js.map +0 -1
  456. package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts +0 -9
  457. package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts.map +0 -1
  458. package/dist/lib/modules/tournament/notification/jobs/notification.worker.js.map +0 -1
  459. package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts +0 -10
  460. package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts.map +0 -1
  461. package/dist/lib/modules/tournament/notification/notification.schedule.config.js +0 -15
  462. package/dist/lib/modules/tournament/notification/notification.schedule.config.js.map +0 -1
  463. package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts +0 -10
  464. package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts.map +0 -1
  465. package/dist/lib/modules/tournament/notification/notification.scheduler.service.js.map +0 -1
  466. package/dist/types/events/event-initializations.d.ts +0 -2
  467. package/dist/types/events/event-initializations.d.ts.map +0 -1
  468. package/dist/types/modules/tournament/config/tournament-config.validation.d.ts +0 -201
  469. package/dist/types/modules/tournament/config/tournament-config.validation.d.ts.map +0 -1
  470. package/dist/types/modules/tournament/match/events/match-ended.consumer.d.ts +0 -2
  471. package/dist/types/modules/tournament/match/events/match-ended.consumer.d.ts.map +0 -1
  472. package/dist/types/modules/tournament/match/events/match-ended.event.d.ts +0 -14
  473. package/dist/types/modules/tournament/match/events/match-ended.event.d.ts.map +0 -1
  474. package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts +0 -10
  475. package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts.map +0 -1
  476. package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts +0 -9
  477. package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts.map +0 -1
  478. package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts +0 -10
  479. package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts.map +0 -1
  480. package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts +0 -10
  481. package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.repository.d.ts","sourceRoot":"/","sources":["modules/tournament/sync/sync.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,UAAU,IAAI,KAAK,EAAmB,MAAM,2CAA2C,CAAC;AAGjG,qBACa,cAAc;IACvB,OAAO,CAAC,KAAK,CAAyB;;IAMhC,oBAAoB,IAAI,OAAO,CAAC,CAAC,KAAK,GAAG;QAAE,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAA;KAAE,CAAC,GAAG,IAAI,CAAC;CAM3F;AAED,eAAO,MAAM,cAAc,gBAAgC,CAAC"}
@@ -38,36 +38,30 @@ var __importStar = (this && this.__importStar) || (function () {
38
38
  return result;
39
39
  };
40
40
  })();
41
+ var __metadata = (this && this.__metadata) || function (k, v) {
42
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
+ };
41
44
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.notificationSchedulerService = exports.NotificationSchedulerService = void 0;
45
+ exports.syncRepository = exports.SyncRepository = void 0;
43
46
  const typedi_1 = __importStar(require("typedi"));
44
- const notification_producer_1 = require("./jobs/notification.producer");
45
- let NotificationSchedulerService = class NotificationSchedulerService {
46
- jobId(type, matchId) {
47
- return `tournament-${type}-${matchId}`;
48
- }
49
- buildJobData(tournamentId, matchId, target) {
50
- return { tournamentId: tournamentId.toString(), matchId: matchId.toString(), target };
51
- }
52
- async scheduleForMatch(matchId, tournamentId, startingDate, scheduledNotifications) {
53
- await Promise.all(scheduledNotifications.map(({ type, durationMins, target }) => {
54
- const delay = startingDate.getTime() - durationMins * 60 * 1000 - Date.now();
55
- if (delay <= 0)
56
- return Promise.resolve();
57
- return (0, notification_producer_1.addNotificationJob)(type, this.buildJobData(tournamentId, matchId, target), {
58
- delay,
59
- jobId: this.jobId(type, matchId),
60
- removeOnComplete: true,
61
- });
62
- }));
47
+ const models_1 = require("@lyxa.ai/core/dist/libraries/mongo/models");
48
+ const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
49
+ let SyncRepository = class SyncRepository {
50
+ model;
51
+ constructor() {
52
+ this.model = models_1.TournamentModel;
63
53
  }
64
- async cancelForMatch(matchId, scheduledNotifications) {
65
- await Promise.all(scheduledNotifications.map(({ type }) => (0, notification_producer_1.removeNotificationJob)(this.jobId(type, matchId))));
54
+ async findActiveTournament() {
55
+ const now = new Date();
56
+ return this.model
57
+ .findOne({ status: enum_1.Status.ACTIVE, startDate: { $lte: now }, endDate: { $gte: now } })
58
+ .lean();
66
59
  }
67
60
  };
68
- exports.NotificationSchedulerService = NotificationSchedulerService;
69
- exports.NotificationSchedulerService = NotificationSchedulerService = __decorate([
70
- (0, typedi_1.Service)()
71
- ], NotificationSchedulerService);
72
- exports.notificationSchedulerService = typedi_1.default.get(NotificationSchedulerService);
73
- //# sourceMappingURL=notification.scheduler.service.js.map
61
+ exports.SyncRepository = SyncRepository;
62
+ exports.SyncRepository = SyncRepository = __decorate([
63
+ (0, typedi_1.Service)(),
64
+ __metadata("design:paramtypes", [])
65
+ ], SyncRepository);
66
+ exports.syncRepository = typedi_1.default.get(SyncRepository);
67
+ //# sourceMappingURL=sync.repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.repository.js","sourceRoot":"/","sources":["modules/tournament/sync/sync.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,sEAAiG;AACjG,4DAA2D;AAGpD,IAAM,cAAc,GAApB,MAAM,cAAc;IACf,KAAK,CAAyB;IAEtC;QACI,IAAI,CAAC,KAAK,GAAG,wBAAe,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,oBAAoB;QACtB,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC,KAAK;aACZ,OAAO,CAAC,EAAE,MAAM,EAAE,aAAM,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC;aACpF,IAAI,EAAgE,CAAC;IAC9E,CAAC;CACJ,CAAA;AAbY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,gBAAO,GAAE;;GACG,cAAc,CAa1B;AAEY,QAAA,cAAc,GAAG,gBAAS,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport { Tournament as Model, TournamentModel } from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport { Status } from '@lyxa.ai/core/dist/utilities/enum';\n\n@Service()\nexport class SyncRepository {\n private model: typeof TournamentModel;\n\n constructor() {\n this.model = TournamentModel;\n }\n\n async findActiveTournament(): Promise<(Model & { _id: mongoose.Types.ObjectId }) | null> {\n const now = new Date();\n return this.model\n .findOne({ status: Status.ACTIVE, startDate: { $lte: now }, endDate: { $gte: now } })\n .lean() as Promise<(Model & { _id: mongoose.Types.ObjectId }) | null>;\n }\n}\n\nexport const syncRepository = Container.get(SyncRepository);\n"]}
@@ -0,0 +1,27 @@
1
+ export declare const syncRouter: import("@trpc/server").TRPCBuiltRouter<{
2
+ ctx: import("@lyxa.ai/core/dist/libraries/trpc/context").LyxaHTTPContext;
3
+ meta: object;
4
+ errorShape: {
5
+ message: string;
6
+ data: {
7
+ stack: undefined;
8
+ path: undefined;
9
+ code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
10
+ httpStatus: number;
11
+ };
12
+ stack: undefined;
13
+ code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
14
+ };
15
+ transformer: false;
16
+ }, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
17
+ syncLiveScores: import("@trpc/server").TRPCMutationProcedure<{
18
+ input: void;
19
+ output: {
20
+ success: boolean;
21
+ message: string;
22
+ data: null | undefined;
23
+ };
24
+ meta: object;
25
+ }>;
26
+ }>>;
27
+ //# sourceMappingURL=sync.router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.router.d.ts","sourceRoot":"/","sources":["modules/tournament/sync/sync.router.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;GAWrB,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.syncRouter = void 0;
4
+ const trpc_1 = require("@lyxa.ai/core/dist/libraries/trpc");
5
+ const error_handler_1 = require("@lyxa.ai/core/dist/utilities/error-handler");
6
+ const response_1 = require("@lyxa.ai/core/dist/utilities/response");
7
+ const sync_service_1 = require("./sync.service");
8
+ exports.syncRouter = (0, trpc_1.createTRPCRouter)({
9
+ syncLiveScores: trpc_1.publicProcedure
10
+ .mutation(() => error_handler_1.ErrorHandler.wrapAsync(async () => {
11
+ await sync_service_1.syncService.syncLiveScores();
12
+ return (0, response_1.response)('Live scores synced successfully', null);
13
+ })),
14
+ });
15
+ //# sourceMappingURL=sync.router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.router.js","sourceRoot":"/","sources":["modules/tournament/sync/sync.router.ts"],"names":[],"mappings":";;;AAAA,4DAAoF;AACpF,8EAAwE;AACxE,oEAA+D;AAC/D,iDAAsD;AAEzC,QAAA,UAAU,GAAG,IAAA,uBAAgB,EAAC;IAEvC,cAAc,EACV,sBAAe;SAEd,QAAQ,CAAC,GAAG,EAAE,CACX,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,MAAM,0BAAO,CAAC,cAAc,EAAE,CAAC;QAC/B,OAAO,IAAA,mBAAQ,EAAC,iCAAiC,EAAE,IAAI,CAAC,CAAC;IAC7D,CAAC,CAAC,CACL;CACR,CAAC,CAAC","sourcesContent":["import {createTRPCRouter, publicProcedure} from '@lyxa.ai/core/dist/libraries/trpc';\nimport {ErrorHandler} from '@lyxa.ai/core/dist/utilities/error-handler';\nimport {response} from '@lyxa.ai/core/dist/utilities/response';\nimport {syncService as service} from './sync.service';\n\nexport const syncRouter = createTRPCRouter({\n // NOTE: this will be called every one minute from google scheduler\n syncLiveScores:\n publicProcedure\n // createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n .mutation(() =>\n ErrorHandler.wrapAsync(async () => {\n await service.syncLiveScores();\n return response('Live scores synced successfully', null);\n })\n ),\n});\n"]}
@@ -0,0 +1,9 @@
1
+ export declare class SyncService {
2
+ private repository;
3
+ private scoreRepository;
4
+ private matchService;
5
+ constructor();
6
+ syncLiveScores(): Promise<void>;
7
+ }
8
+ export declare const syncService: SyncService;
9
+ //# sourceMappingURL=sync.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.service.d.ts","sourceRoot":"/","sources":["modules/tournament/sync/sync.service.ts"],"names":[],"mappings":"AAYA,qBACa,WAAW;IACpB,OAAO,CAAC,UAAU,CAAiB;IACnC,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,YAAY,CAAe;;IAQtB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;CAkD/C;AAED,eAAO,MAAM,WAAW,aAA6B,CAAC"}
@@ -0,0 +1,117 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __metadata = (this && this.__metadata) || function (k, v) {
42
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.syncService = exports.SyncService = void 0;
46
+ const typedi_1 = __importStar(require("typedi"));
47
+ const integration_factory_1 = require("../integration/integration.factory");
48
+ const sync_repository_1 = require("./sync.repository");
49
+ const score_repository_1 = require("../score/score.repository");
50
+ const match_builder_1 = require("../match/match.builder");
51
+ const match_service_1 = require("../match/match.service");
52
+ const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
53
+ const tournament_utils_1 = require("../tournament.utils");
54
+ let SyncService = class SyncService {
55
+ repository;
56
+ scoreRepository;
57
+ matchService;
58
+ constructor() {
59
+ this.repository = typedi_1.default.get(sync_repository_1.SyncRepository);
60
+ this.scoreRepository = typedi_1.default.get(score_repository_1.ScoreRepository);
61
+ this.matchService = typedi_1.default.get(match_service_1.MatchService);
62
+ }
63
+ async syncLiveScores() {
64
+ const tournament = await this.repository.findActiveTournament();
65
+ if (!tournament || !tournament.externalProvider || !tournament.externalApiKey)
66
+ return;
67
+ const now = (0, tournament_utils_1.utcNow)();
68
+ const liveCandidates = new Map();
69
+ tournament.matches.forEach((match, idx) => {
70
+ if (!match.externalId || match.matchEnded)
71
+ return;
72
+ if (!match.startingDate || match.startingDate > now)
73
+ return;
74
+ liveCandidates.set(match.externalId.toString(), { match, matchNumber: idx + 1 });
75
+ });
76
+ if (!liveCandidates.size)
77
+ return;
78
+ const provider = (0, integration_factory_1.createTournamentService)(tournament.externalProvider, tournament.externalApiKey);
79
+ const liveScores = await provider.getLiveScores({ externalIds: Array.from(liveCandidates.keys()) });
80
+ const updates = [];
81
+ const evaluations = [];
82
+ for (const score of liveScores) {
83
+ const entry = liveCandidates.get(score.externalId);
84
+ if (!entry)
85
+ continue;
86
+ const { match, matchNumber } = entry;
87
+ const newScore = { team1: score.homeScore, team2: score.awayScore };
88
+ const scoreChanged = match.score.team1 !== newScore.team1 || match.score.team2 !== newScore.team2;
89
+ const matchStatus = score.ended ? enum_1.TournamentMatchStatus.ENDED : enum_1.TournamentMatchStatus.STARTED;
90
+ const statusChanged = match.matchStatus !== matchStatus;
91
+ if (!scoreChanged && !statusChanged && !score.ended)
92
+ continue;
93
+ const update = {
94
+ matchId: match._id,
95
+ score: newScore,
96
+ matchStatus,
97
+ };
98
+ if (score.ended) {
99
+ const { update: endFields, evaluation } = match_builder_1.MatchBuilder.buildEnd(match, matchNumber, newScore);
100
+ Object.assign(update, endFields);
101
+ evaluations.push(evaluation);
102
+ }
103
+ updates.push(update);
104
+ }
105
+ if (!updates.length)
106
+ return;
107
+ await this.scoreRepository.bulkSyncScores(tournament._id, updates);
108
+ await this.matchService.publishEvaluations(tournament._id, evaluations);
109
+ }
110
+ };
111
+ exports.SyncService = SyncService;
112
+ exports.SyncService = SyncService = __decorate([
113
+ (0, typedi_1.Service)(),
114
+ __metadata("design:paramtypes", [])
115
+ ], SyncService);
116
+ exports.syncService = typedi_1.default.get(SyncService);
117
+ //# sourceMappingURL=sync.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.service.js","sourceRoot":"/","sources":["modules/tournament/sync/sync.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,4EAA2E;AAC3E,uDAAiD;AACjD,gEAA2E;AAC3E,0DAAoD;AACpD,0DAAoD;AAGpD,4DAAwE;AACxE,0DAA2C;AAGpC,IAAM,WAAW,GAAjB,MAAM,WAAW;IACZ,UAAU,CAAiB;IAC3B,eAAe,CAAkB;IACjC,YAAY,CAAe;IAEnC;QACI,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,gCAAc,CAAC,CAAC;QAChD,IAAI,CAAC,eAAe,GAAG,gBAAS,CAAC,GAAG,CAAC,kCAAe,CAAC,CAAC;QACtD,IAAI,CAAC,YAAY,GAAG,gBAAS,CAAC,GAAG,CAAC,4BAAY,CAAC,CAAC;IACpD,CAAC;IAEM,KAAK,CAAC,cAAc;QACvB,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC;QAChE,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,gBAAgB,IAAI,CAAC,UAAU,CAAC,cAAc;YAAE,OAAO;QAEtF,MAAM,GAAG,GAAG,IAAA,yBAAM,GAAE,CAAC;QACrB,MAAM,cAAc,GAAG,IAAI,GAAG,EAA2E,CAAC;QAC1G,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YACtC,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU;gBAAE,OAAO;YAClD,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,YAAY,GAAG,GAAG;gBAAE,OAAO;YAC5D,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,EAAC,KAAK,EAAE,WAAW,EAAE,GAAG,GAAG,CAAC,EAAC,CAAC,CAAC;QACnF,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,cAAc,CAAC,IAAI;YAAE,OAAO;QAEjC,MAAM,QAAQ,GAAG,IAAA,6CAAuB,EAAC,UAAU,CAAC,gBAAgB,EAAE,UAAU,CAAC,cAAc,CAAC,CAAC;QACjG,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,aAAa,CAAC,EAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,EAAC,CAAC,CAAC;QAElG,MAAM,OAAO,GAAsB,EAAE,CAAC;QACtC,MAAM,WAAW,GAA2C,EAAE,CAAC;QAE/D,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;YAC7B,MAAM,KAAK,GAAG,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;YACnD,IAAI,CAAC,KAAK;gBAAE,SAAS;YACrB,MAAM,EAAC,KAAK,EAAE,WAAW,EAAC,GAAG,KAAK,CAAC;YACnC,MAAM,QAAQ,GAAG,EAAC,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,SAAS,EAAC,CAAC;YAElE,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,CAAC;YAClG,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,4BAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,4BAAqB,CAAC,OAAO,CAAC;YAC9F,MAAM,aAAa,GAAG,KAAK,CAAC,WAAW,KAAK,WAAW,CAAC;YACxD,IAAI,CAAC,YAAY,IAAI,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,KAAK;gBAAE,SAAS;YAE9D,MAAM,MAAM,GAAoB;gBAC5B,OAAO,EAAE,KAAK,CAAC,GAAG;gBAClB,KAAK,EAAE,QAAQ;gBACf,WAAW;aACd,CAAC;YAEF,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;gBACd,MAAM,EAAC,MAAM,EAAE,SAAS,EAAE,UAAU,EAAC,GAAG,4BAAY,CAAC,QAAQ,CAAC,KAAiC,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;gBACxH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;gBACjC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACjC,CAAC;YAED,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,MAAM;YAAE,OAAO;QAE5B,MAAM,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACnE,MAAM,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,UAAU,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAC5E,CAAC;CACJ,CAAA;AA7DY,kCAAW;sBAAX,WAAW;IADvB,IAAA,gBAAO,GAAE;;GACG,WAAW,CA6DvB;AAEY,QAAA,WAAW,GAAG,gBAAS,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {Tournament as TournamentType} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {createTournamentService} from '../integration/integration.factory';\nimport {SyncRepository} from './sync.repository';\nimport {BulkScoreUpdate, ScoreRepository} from '../score/score.repository';\nimport {MatchBuilder} from '../match/match.builder';\nimport {MatchService} from '../match/match.service';\nimport {TournamentMatchOutputDTO} from '../match/match.validation';\nimport {EvaluatePredictionsMatch} from '../match/events/evaluate-predictions.event';\nimport {TournamentMatchStatus} from '@lyxa.ai/core/dist/utilities/enum';\nimport {utcNow} from '../tournament.utils';\n\n@Service()\nexport class SyncService {\n private repository: SyncRepository;\n private scoreRepository: ScoreRepository;\n private matchService: MatchService;\n\n constructor() {\n this.repository = Container.get(SyncRepository);\n this.scoreRepository = Container.get(ScoreRepository);\n this.matchService = Container.get(MatchService);\n }\n\n public async syncLiveScores(): Promise<void> {\n const tournament = await this.repository.findActiveTournament();\n if (!tournament || !tournament.externalProvider || !tournament.externalApiKey) return;\n\n const now = utcNow();\n const liveCandidates = new Map<string, {match: TournamentType['matches'][number]; matchNumber: number}>();\n tournament.matches.forEach((match, idx) => {\n if (!match.externalId || match.matchEnded) return;\n if (!match.startingDate || match.startingDate > now) return;\n liveCandidates.set(match.externalId.toString(), {match, matchNumber: idx + 1});\n });\n if (!liveCandidates.size) return;\n\n const provider = createTournamentService(tournament.externalProvider, tournament.externalApiKey);\n const liveScores = await provider.getLiveScores({externalIds: Array.from(liveCandidates.keys())});\n\n const updates: BulkScoreUpdate[] = [];\n const evaluations: Array<EvaluatePredictionsMatch | null> = [];\n\n for (const score of liveScores) {\n const entry = liveCandidates.get(score.externalId);\n if (!entry) continue;\n const {match, matchNumber} = entry;\n const newScore = {team1: score.homeScore, team2: score.awayScore};\n\n const scoreChanged = match.score.team1 !== newScore.team1 || match.score.team2 !== newScore.team2;\n const matchStatus = score.ended ? TournamentMatchStatus.ENDED : TournamentMatchStatus.STARTED;\n const statusChanged = match.matchStatus !== matchStatus;\n if (!scoreChanged && !statusChanged && !score.ended) continue;\n\n const update: BulkScoreUpdate = {\n matchId: match._id,\n score: newScore,\n matchStatus,\n };\n\n if (score.ended) {\n const {update: endFields, evaluation} = MatchBuilder.buildEnd(match as TournamentMatchOutputDTO, matchNumber, newScore);\n Object.assign(update, endFields);\n evaluations.push(evaluation);\n }\n\n updates.push(update);\n }\n\n if (!updates.length) return;\n\n await this.scoreRepository.bulkSyncScores(tournament._id, updates);\n await this.matchService.publishEvaluations(tournament._id, evaluations);\n }\n}\n\nexport const syncService = Container.get(SyncService);\n"]}
@@ -1,4 +1,6 @@
1
1
  import { mongoose } from '@typegoose/typegoose';
2
+ import { TournamentParticipantOutputDTO } from '../participant/participant.validation';
3
+ import { TournamentTeamOutputDTO } from './team.validation';
2
4
  interface TeamInput {
3
5
  name: string;
4
6
  picture?: string;
@@ -14,6 +16,8 @@ export declare class TeamBuilder {
14
16
  name: string;
15
17
  picture: string | undefined;
16
18
  }[];
19
+ static buildTeamPictureMap(teams: TournamentTeamOutputDTO[]): Map<string, string | undefined>;
20
+ static buildPredictionMap(predictions: TournamentParticipantOutputDTO['predictions']): Map<string, TournamentParticipantOutputDTO['predictions'][number]>;
17
21
  }
18
22
  export {};
19
23
  //# sourceMappingURL=team.builder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"team.builder.d.ts","sourceRoot":"/","sources":["modules/tournament/team/team.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,UAAU,SAAS;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,WAAW;IACpB,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS;;;;;IAQjC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE;;;;;CAGxC"}
1
+ {"version":3,"file":"team.builder.d.ts","sourceRoot":"/","sources":["modules/tournament/team/team.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,8BAA8B,EAAC,MAAM,uCAAuC,CAAC;AACrF,OAAO,EAAC,uBAAuB,EAAC,MAAM,mBAAmB,CAAC;AAE1D,UAAU,SAAS;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,WAAW;IACpB,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS;;;;;IAQjC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE;;;;;IAIrC,MAAM,CAAC,mBAAmB,CAAC,KAAK,EAAE,uBAAuB,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAI7F,MAAM,CAAC,kBAAkB,CACrB,WAAW,EAAE,8BAA8B,CAAC,aAAa,CAAC,GAC3D,GAAG,CAAC,MAAM,EAAE,8BAA8B,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;CAGxE"}
@@ -13,6 +13,12 @@ class TeamBuilder {
13
13
  static buildTeams(inputs) {
14
14
  return inputs.map(TeamBuilder.buildTeam);
15
15
  }
16
+ static buildTeamPictureMap(teams) {
17
+ return new Map(teams.map(t => [t._id.toString(), t.picture]));
18
+ }
19
+ static buildPredictionMap(predictions) {
20
+ return new Map(predictions.map(p => [p.matchId.toString(), p]));
21
+ }
16
22
  }
17
23
  exports.TeamBuilder = TeamBuilder;
18
24
  //# sourceMappingURL=team.builder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"team.builder.js","sourceRoot":"/","sources":["modules/tournament/team/team.builder.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAOhD,MAAa,WAAW;IACpB,MAAM,CAAC,SAAS,CAAC,KAAgB;QAC7B,OAAO;YACH,GAAG,EAAE,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE;YAClC,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,KAAK,CAAC,OAAO;SACzB,CAAC;IACN,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,MAAmB;QACjC,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;CACJ;AAZD,kCAYC","sourcesContent":["import { mongoose } from '@typegoose/typegoose';\n\ninterface TeamInput {\n name: string;\n picture?: string;\n}\n\nexport class TeamBuilder {\n static buildTeam(input: TeamInput) {\n return {\n _id: new mongoose.Types.ObjectId(),\n name: input.name,\n picture: input.picture,\n };\n }\n\n static buildTeams(inputs: TeamInput[]) {\n return inputs.map(TeamBuilder.buildTeam);\n }\n}\n"]}
1
+ {"version":3,"file":"team.builder.js","sourceRoot":"/","sources":["modules/tournament/team/team.builder.ts"],"names":[],"mappings":";;;AAAA,oDAA8C;AAS9C,MAAa,WAAW;IACpB,MAAM,CAAC,SAAS,CAAC,KAAgB;QAC7B,OAAO;YACH,GAAG,EAAE,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE;YAClC,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,KAAK,CAAC,OAAO;SACzB,CAAC;IACN,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,MAAmB;QACjC,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,CAAC,mBAAmB,CAAC,KAAgC;QACvD,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,CAAC,kBAAkB,CACrB,WAA0D;QAE1D,OAAO,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACpE,CAAC;CACJ;AAtBD,kCAsBC","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\nimport {TournamentParticipantOutputDTO} from '../participant/participant.validation';\nimport {TournamentTeamOutputDTO} from './team.validation';\n\ninterface TeamInput {\n name: string;\n picture?: string;\n}\n\nexport class TeamBuilder {\n static buildTeam(input: TeamInput) {\n return {\n _id: new mongoose.Types.ObjectId(),\n name: input.name,\n picture: input.picture,\n };\n }\n\n static buildTeams(inputs: TeamInput[]) {\n return inputs.map(TeamBuilder.buildTeam);\n }\n\n static buildTeamPictureMap(teams: TournamentTeamOutputDTO[]): Map<string, string | undefined> {\n return new Map(teams.map(t => [t._id.toString(), t.picture]));\n }\n\n static buildPredictionMap(\n predictions: TournamentParticipantOutputDTO['predictions']\n ): Map<string, TournamentParticipantOutputDTO['predictions'][number]> {\n return new Map(predictions.map(p => [p.matchId.toString(), p]));\n }\n}\n"]}
@@ -4,6 +4,9 @@ export declare class TournamentTeamRepository {
4
4
  private model;
5
5
  constructor();
6
6
  findById(id: mongoose.Types.ObjectId): Promise<Model | null>;
7
+ findActive(): Promise<(Model & {
8
+ _id: mongoose.Types.ObjectId;
9
+ }) | null>;
7
10
  findByTeamId(teamId: mongoose.Types.ObjectId): Promise<Model | null>;
8
11
  addTeams(id: mongoose.Types.ObjectId, teams: object[]): Promise<Model | null>;
9
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"team.repository.d.ts","sourceRoot":"/","sources":["modules/tournament/team/team.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,UAAU,IAAI,KAAK,EAAmB,MAAM,2CAA2C,CAAC;AAEjG,qBACa,wBAAwB;IACpC,OAAO,CAAC,KAAK,CAAyB;;IAMhC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAI5D,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAIpE,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;CAKnF;AAED,eAAO,MAAM,wBAAwB,0BAA0C,CAAC"}
1
+ {"version":3,"file":"team.repository.d.ts","sourceRoot":"/","sources":["modules/tournament/team/team.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,UAAU,IAAI,KAAK,EAAmB,MAAM,2CAA2C,CAAC;AAGjG,qBACa,wBAAwB;IACpC,OAAO,CAAC,KAAK,CAAyB;;IAMhC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAI5D,UAAU,IAAI,OAAO,CAAC,CAAC,KAAK,GAAG;QAAE,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAA;KAAE,CAAC,GAAG,IAAI,CAAC;IAMxE,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAIpE,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;CAKnF;AAED,eAAO,MAAM,wBAAwB,0BAA0C,CAAC"}
@@ -45,6 +45,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
45
45
  exports.tournamentTeamRepository = exports.TournamentTeamRepository = void 0;
46
46
  const typedi_1 = __importStar(require("typedi"));
47
47
  const models_1 = require("@lyxa.ai/core/dist/libraries/mongo/models");
48
+ const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
48
49
  let TournamentTeamRepository = class TournamentTeamRepository {
49
50
  model;
50
51
  constructor() {
@@ -53,6 +54,11 @@ let TournamentTeamRepository = class TournamentTeamRepository {
53
54
  async findById(id) {
54
55
  return this.model.findById(id).lean();
55
56
  }
57
+ async findActive() {
58
+ return this.model
59
+ .findOne({ status: enum_1.Status.ACTIVE })
60
+ .lean();
61
+ }
56
62
  async findByTeamId(teamId) {
57
63
  return this.model.findOne({ 'teams._id': teamId }).lean();
58
64
  }
@@ -1 +1 @@
1
- {"version":3,"file":"team.repository.js","sourceRoot":"/","sources":["modules/tournament/team/team.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,sEAAiG;AAG1F,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAC5B,KAAK,CAAyB;IAEtC;QACC,IAAI,CAAC,KAAK,GAAG,wBAAe,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,EAA2B;QACzC,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,EAA2B,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,MAA+B;QACjD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,EAA2B,CAAC;IACpF,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,EAA2B,EAAE,KAAe;QAC1D,OAAO,IAAI,CAAC,KAAK;aACf,iBAAiB,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;aAC5E,IAAI,EAA2B,CAAC;IACnC,CAAC;CACD,CAAA;AApBY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,gBAAO,GAAE;;GACG,wBAAwB,CAoBpC;AAEY,QAAA,wBAAwB,GAAG,gBAAS,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport { Tournament as Model, TournamentModel } from '@lyxa.ai/core/dist/libraries/mongo/models';\n\n@Service()\nexport class TournamentTeamRepository {\n\tprivate model: typeof TournamentModel;\n\n\tconstructor() {\n\t\tthis.model = TournamentModel;\n\t}\n\n\tasync findById(id: mongoose.Types.ObjectId): Promise<Model | null> {\n\t\treturn this.model.findById(id).lean() as Promise<Model | null>;\n\t}\n\n\tasync findByTeamId(teamId: mongoose.Types.ObjectId): Promise<Model | null> {\n\t\treturn this.model.findOne({ 'teams._id': teamId }).lean() as Promise<Model | null>;\n\t}\n\n\tasync addTeams(id: mongoose.Types.ObjectId, teams: object[]): Promise<Model | null> {\n\t\treturn this.model\n\t\t\t.findByIdAndUpdate(id, { $push: { teams: { $each: teams } } }, { new: true })\n\t\t\t.lean() as Promise<Model | null>;\n\t}\n}\n\nexport const tournamentTeamRepository = Container.get(TournamentTeamRepository);\n"]}
1
+ {"version":3,"file":"team.repository.js","sourceRoot":"/","sources":["modules/tournament/team/team.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,sEAAiG;AACjG,4DAA2D;AAGpD,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAC5B,KAAK,CAAyB;IAEtC;QACC,IAAI,CAAC,KAAK,GAAG,wBAAe,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,EAA2B;QACzC,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,EAA2B,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,UAAU;QACf,OAAO,IAAI,CAAC,KAAK;aACf,OAAO,CAAC,EAAE,MAAM,EAAE,aAAM,CAAC,MAAM,EAAE,CAAC;aAClC,IAAI,EAAgE,CAAC;IACxE,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,MAA+B;QACjD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,EAA2B,CAAC;IACpF,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,EAA2B,EAAE,KAAe;QAC1D,OAAO,IAAI,CAAC,KAAK;aACf,iBAAiB,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;aAC5E,IAAI,EAA2B,CAAC;IACnC,CAAC;CACD,CAAA;AA1BY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,gBAAO,GAAE;;GACG,wBAAwB,CA0BpC;AAEY,QAAA,wBAAwB,GAAG,gBAAS,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport { Tournament as Model, TournamentModel } from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport { Status } from '@lyxa.ai/core/dist/utilities/enum';\n\n@Service()\nexport class TournamentTeamRepository {\n\tprivate model: typeof TournamentModel;\n\n\tconstructor() {\n\t\tthis.model = TournamentModel;\n\t}\n\n\tasync findById(id: mongoose.Types.ObjectId): Promise<Model | null> {\n\t\treturn this.model.findById(id).lean() as Promise<Model | null>;\n\t}\n\n\tasync findActive(): Promise<(Model & { _id: mongoose.Types.ObjectId }) | null> {\n\t\treturn this.model\n\t\t\t.findOne({ status: Status.ACTIVE })\n\t\t\t.lean() as Promise<(Model & { _id: mongoose.Types.ObjectId }) | null>;\n\t}\n\n\tasync findByTeamId(teamId: mongoose.Types.ObjectId): Promise<Model | null> {\n\t\treturn this.model.findOne({ 'teams._id': teamId }).lean() as Promise<Model | null>;\n\t}\n\n\tasync addTeams(id: mongoose.Types.ObjectId, teams: object[]): Promise<Model | null> {\n\t\treturn this.model\n\t\t\t.findByIdAndUpdate(id, { $push: { teams: { $each: teams } } }, { new: true })\n\t\t\t.lean() as Promise<Model | null>;\n\t}\n}\n\nexport const tournamentTeamRepository = Container.get(TournamentTeamRepository);\n"]}
@@ -29,12 +29,12 @@ export declare const teamRouter: import("@trpc/server").TRPCBuiltRouter<{
29
29
  data?: {
30
30
  status: import("@lyxa.ai/core/dist/utilities/enum").Status;
31
31
  name: string;
32
+ tag: string;
32
33
  _id?: string | mongoose.Types.ObjectId | undefined;
33
34
  createdAt?: Date | null | undefined;
34
35
  startDate?: Date | null | undefined;
35
36
  endDate?: Date | null | undefined;
36
37
  updatedAt?: Date | null | undefined;
37
- tag?: import("../tournament.types").TournamentTag | undefined;
38
38
  reward?: {
39
39
  type: import("@lyxa.ai/core/dist/utilities/enum").TournamentRewardType.FREE_DELIVERY;
40
40
  } | {
@@ -43,16 +43,25 @@ export declare const teamRouter: import("@trpc/server").TRPCBuiltRouter<{
43
43
  couponNamePrefix?: string | undefined;
44
44
  percentage?: number | undefined;
45
45
  } | undefined;
46
+ notificationTemplates?: Partial<Record<import("@lyxa.ai/core/dist/utilities/enum").TournamentNotificationTag, {
47
+ title: string;
48
+ body: string;
49
+ }>> | undefined;
50
+ scheduledNotifications?: {
51
+ type: import("@lyxa.ai/core/dist/utilities/enum").TournamentNotificationTag;
52
+ durationMins: number;
53
+ target: import("@lyxa.ai/core/dist/utilities/enum").TournamentScheduledNotificationTarget;
54
+ }[] | undefined;
46
55
  } | {
47
56
  documents: {
48
57
  status: import("@lyxa.ai/core/dist/utilities/enum").Status;
49
58
  name: string;
59
+ tag: string;
50
60
  _id?: string | mongoose.Types.ObjectId | undefined;
51
61
  createdAt?: Date | null | undefined;
52
62
  startDate?: Date | null | undefined;
53
63
  endDate?: Date | null | undefined;
54
64
  updatedAt?: Date | null | undefined;
55
- tag?: import("../tournament.types").TournamentTag | undefined;
56
65
  reward?: {
57
66
  type: import("@lyxa.ai/core/dist/utilities/enum").TournamentRewardType.FREE_DELIVERY;
58
67
  } | {
@@ -61,6 +70,15 @@ export declare const teamRouter: import("@trpc/server").TRPCBuiltRouter<{
61
70
  couponNamePrefix?: string | undefined;
62
71
  percentage?: number | undefined;
63
72
  } | undefined;
73
+ notificationTemplates?: Partial<Record<import("@lyxa.ai/core/dist/utilities/enum").TournamentNotificationTag, {
74
+ title: string;
75
+ body: string;
76
+ }>> | undefined;
77
+ scheduledNotifications?: {
78
+ type: import("@lyxa.ai/core/dist/utilities/enum").TournamentNotificationTag;
79
+ durationMins: number;
80
+ target: import("@lyxa.ai/core/dist/utilities/enum").TournamentScheduledNotificationTarget;
81
+ }[] | undefined;
64
82
  }[];
65
83
  metadata?: {
66
84
  page: number;
@@ -74,7 +92,7 @@ export declare const teamRouter: import("@trpc/server").TRPCBuiltRouter<{
74
92
  }>;
75
93
  getAll: import("@trpc/server").TRPCQueryProcedure<{
76
94
  input: {
77
- tournamentId: string | mongoose.Types.ObjectId;
95
+ tournamentId?: string | mongoose.Types.ObjectId | undefined;
78
96
  };
79
97
  output: {
80
98
  message: string;
@@ -116,7 +134,7 @@ export declare const teamRouter: import("@trpc/server").TRPCBuiltRouter<{
116
134
  getMatches: import("@trpc/server").TRPCQueryProcedure<{
117
135
  input: {
118
136
  tournamentId: string | mongoose.Types.ObjectId;
119
- filter?: import("../tournament.types").MatchStatus | undefined;
137
+ filter?: import("@lyxa.ai/core/dist/utilities/enum").TournamentMatchStatus | undefined;
120
138
  };
121
139
  output: {
122
140
  message: string;
@@ -142,7 +160,7 @@ export declare const teamRouter: import("@trpc/server").TRPCBuiltRouter<{
142
160
  team2: number | null;
143
161
  };
144
162
  stage: string;
145
- matchStatus: import("../tournament.types").MatchStatus;
163
+ matchStatus: import("@lyxa.ai/core/dist/utilities/enum").TournamentMatchStatus;
146
164
  prediction: {
147
165
  score: {
148
166
  team1: number | null;
@@ -180,7 +198,7 @@ export declare const teamRouter: import("@trpc/server").TRPCBuiltRouter<{
180
198
  team2: number | null;
181
199
  };
182
200
  stage: string;
183
- matchStatus: import("../tournament.types").MatchStatus;
201
+ matchStatus: import("@lyxa.ai/core/dist/utilities/enum").TournamentMatchStatus;
184
202
  prediction: {
185
203
  score: {
186
204
  team1: number | null;
@@ -1 +1 @@
1
- {"version":3,"file":"team.router.d.ts","sourceRoot":"/","sources":["modules/tournament/team/team.router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAgBhD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BrB,CAAC"}
1
+ {"version":3,"file":"team.router.d.ts","sourceRoot":"/","sources":["modules/tournament/team/team.router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAgBhD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BrB,CAAC"}
@@ -22,7 +22,7 @@ exports.teamRouter = (0, trpc_1.createTRPCRouter)({
22
22
  .input(team_validation_1.GetTournamentTeamsSchema)
23
23
  .output(team_validation_1.TournamentWithTeamsResponseSchema)
24
24
  .query(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
25
- const result = await team_service_1.teamService.getAll(input.tournamentId);
25
+ const result = await team_service_1.teamService.getAll(input.tournamentId ?? undefined);
26
26
  return (0, response_1.response)('Teams fetched successfully', result);
27
27
  })),
28
28
  getMatches: (0, auth_2.createAuthenticatedProcedure)({ entityTypes: [auth_1.AuthEntityType.USER] })
@@ -1 +1 @@
1
- {"version":3,"file":"team.router.js","sourceRoot":"/","sources":["modules/tournament/team/team.router.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAChD,4DAAsF;AACtF,4DAAmE;AACnE,6EAAkG;AAClG,8EAA0E;AAC1E,oEAAiE;AACjE,iDAAwD;AACxD,uDAM2B;AAC3B,mEAA6E;AAEhE,QAAA,UAAU,GAAG,IAAA,uBAAgB,EAAC;IAC1C,GAAG,EAAE,IAAA,mCAA4B,EAAC,EAAE,WAAW,EAAE,CAAC,qBAAc,CAAC,GAAG,CAAC,EAAE,CAAC;SACtE,KAAK,CAAC,0CAAwB,CAAC;SAC/B,MAAM,CAAC,kDAA8B,CAAC;SACtC,QAAQ,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAC7B,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,MAAM,GAAG,MAAM,0BAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACxC,OAAO,IAAA,mBAAQ,EAAC,0BAA0B,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC,CAAC,CACF;IAEF,MAAM,EAAE,sBAAe;SACrB,KAAK,CAAC,0CAAwB,CAAC;SAC/B,MAAM,CAAC,mDAAiC,CAAC;SACzC,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAC1B,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,MAAM,GAAG,MAAM,0BAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACxD,OAAO,IAAA,mBAAQ,EAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC,CAAC,CACF;IAEF,UAAU,EAAE,IAAA,mCAA4B,EAAC,EAAE,WAAW,EAAE,CAAC,qBAAc,CAAC,IAAI,CAAC,EAAE,CAAC;SAC9E,KAAK,CAAC,sCAAoB,CAAC;SAC3B,MAAM,CAAC,qDAAmC,CAAC;SAC3C,KAAK,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAC/B,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,MAAM,GAAG,MAAM,0BAAO,CAAC,UAAU,CAAC,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QAC5F,OAAO,IAAA,mBAAQ,EAAC,mCAAmC,EAAE,MAAM,CAAC,CAAC;IAC9D,CAAC,CAAC,CACF;CACF,CAAC,CAAC","sourcesContent":["import { mongoose } from '@typegoose/typegoose';\nimport { createTRPCRouter, publicProcedure } from '@lyxa.ai/core/dist/libraries/trpc';\nimport { AuthEntityType } from '@lyxa.ai/core/dist/libraries/auth';\nimport { createAuthenticatedProcedure } from '@lyxa.ai/core/dist/libraries/trpc/middlewares/auth';\nimport { ErrorHandler } from '@lyxa.ai/core/dist/utilities/error-handler';\nimport { response } from '@lyxa.ai/core/dist/utilities/response';\nimport { teamService as service } from './team.service';\nimport {\n\tAddTournamentTeamsSchema,\n\tGetTeamMatchesSchema,\n\tGetTournamentTeamsSchema,\n\tTournamentWithTeamsResponseSchema,\n\tTournamentWithMatchesResponseSchema,\n} from './team.validation';\nimport { TournamentConfigResponseSchema } from '../config/config.validation';\n\nexport const teamRouter = createTRPCRouter({\n\tadd: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n\t\t.input(AddTournamentTeamsSchema)\n\t\t.output(TournamentConfigResponseSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.add(input);\n\t\t\t\treturn response('Teams added successfully', result);\n\t\t\t})\n\t\t),\n\n\tgetAll: publicProcedure\n\t\t.input(GetTournamentTeamsSchema)\n\t\t.output(TournamentWithTeamsResponseSchema)\n\t\t.query(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.getAll(input.tournamentId);\n\t\t\t\treturn response('Teams fetched successfully', result);\n\t\t\t})\n\t\t),\n\n\tgetMatches: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.USER] })\n\t\t.input(GetTeamMatchesSchema)\n\t\t.output(TournamentWithMatchesResponseSchema)\n\t\t.query(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.getMatches(new mongoose.Types.ObjectId(ctx.entity?.id), input);\n\t\t\t\treturn response('Team matches fetched successfully', result);\n\t\t\t})\n\t\t),\n});\n"]}
1
+ {"version":3,"file":"team.router.js","sourceRoot":"/","sources":["modules/tournament/team/team.router.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAChD,4DAAsF;AACtF,4DAAmE;AACnE,6EAAkG;AAClG,8EAA0E;AAC1E,oEAAiE;AACjE,iDAAwD;AACxD,uDAM2B;AAC3B,mEAA6E;AAEhE,QAAA,UAAU,GAAG,IAAA,uBAAgB,EAAC;IAC1C,GAAG,EAAE,IAAA,mCAA4B,EAAC,EAAE,WAAW,EAAE,CAAC,qBAAc,CAAC,GAAG,CAAC,EAAE,CAAC;SACtE,KAAK,CAAC,0CAAwB,CAAC;SAC/B,MAAM,CAAC,kDAA8B,CAAC;SACtC,QAAQ,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAC7B,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,MAAM,GAAG,MAAM,0BAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACxC,OAAO,IAAA,mBAAQ,EAAC,0BAA0B,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC,CAAC,CACF;IAEF,MAAM,EAAE,sBAAe;SACrB,KAAK,CAAC,0CAAwB,CAAC;SAC/B,MAAM,CAAC,mDAAiC,CAAC;SACzC,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAC1B,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,MAAM,GAAG,MAAM,0BAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,IAAI,SAAS,CAAC,CAAC;QACrE,OAAO,IAAA,mBAAQ,EAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC,CAAC,CACF;IAEF,UAAU,EAAE,IAAA,mCAA4B,EAAC,EAAE,WAAW,EAAE,CAAC,qBAAc,CAAC,IAAI,CAAC,EAAE,CAAC;SAC9E,KAAK,CAAC,sCAAoB,CAAC;SAC3B,MAAM,CAAC,qDAAmC,CAAC;SAC3C,KAAK,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAC/B,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,MAAM,GAAG,MAAM,0BAAO,CAAC,UAAU,CAAC,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QAC5F,OAAO,IAAA,mBAAQ,EAAC,mCAAmC,EAAE,MAAM,CAAC,CAAC;IAC9D,CAAC,CAAC,CACF;CACF,CAAC,CAAC","sourcesContent":["import { mongoose } from '@typegoose/typegoose';\nimport { createTRPCRouter, publicProcedure } from '@lyxa.ai/core/dist/libraries/trpc';\nimport { AuthEntityType } from '@lyxa.ai/core/dist/libraries/auth';\nimport { createAuthenticatedProcedure } from '@lyxa.ai/core/dist/libraries/trpc/middlewares/auth';\nimport { ErrorHandler } from '@lyxa.ai/core/dist/utilities/error-handler';\nimport { response } from '@lyxa.ai/core/dist/utilities/response';\nimport { teamService as service } from './team.service';\nimport {\n\tAddTournamentTeamsSchema,\n\tGetTeamMatchesSchema,\n\tGetTournamentTeamsSchema,\n\tTournamentWithTeamsResponseSchema,\n\tTournamentWithMatchesResponseSchema,\n} from './team.validation';\nimport { TournamentConfigResponseSchema } from '../config/config.validation';\n\nexport const teamRouter = createTRPCRouter({\n\tadd: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n\t\t.input(AddTournamentTeamsSchema)\n\t\t.output(TournamentConfigResponseSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.add(input);\n\t\t\t\treturn response('Teams added successfully', result);\n\t\t\t})\n\t\t),\n\n\tgetAll: publicProcedure\n\t\t.input(GetTournamentTeamsSchema)\n\t\t.output(TournamentWithTeamsResponseSchema)\n\t\t.query(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.getAll(input.tournamentId ?? undefined);\n\t\t\t\treturn response('Teams fetched successfully', result);\n\t\t\t})\n\t\t),\n\n\tgetMatches: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.USER] })\n\t\t.input(GetTeamMatchesSchema)\n\t\t.output(TournamentWithMatchesResponseSchema)\n\t\t.query(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.getMatches(new mongoose.Types.ObjectId(ctx.entity?.id), input);\n\t\t\t\treturn response('Team matches fetched successfully', result);\n\t\t\t})\n\t\t),\n});\n"]}
@@ -9,8 +9,9 @@ export declare class TeamService {
9
9
  private getMatchStatus;
10
10
  private applyStatusFilter;
11
11
  add(input: AddTournamentTeamsInputDTO): Promise<TournamentConfigOutputDTO>;
12
- getAll(tournamentId: mongoose.Types.ObjectId): Promise<TournamentWithTeamsOutputDTO>;
12
+ getAll(tournamentId?: mongoose.Types.ObjectId): Promise<TournamentWithTeamsOutputDTO>;
13
13
  getMatches(userId: mongoose.Types.ObjectId, input: GetTeamMatchesInputDTO): Promise<TournamentWithMatchesOutputDTO>;
14
+ private enrichMatch;
14
15
  }
15
16
  export declare const teamService: TeamService;
16
17
  //# sourceMappingURL=team.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"team.service.d.ts","sourceRoot":"/","sources":["modules/tournament/team/team.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EACH,0BAA0B,EAC1B,sBAAsB,EAEtB,8BAA8B,EAC9B,4BAA4B,EAC/B,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAKxE,qBACa,WAAW;IACpB,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,kBAAkB,CAAqB;;IAO/C,OAAO,CAAC,mBAAmB;IAM3B,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,iBAAiB;IAYZ,GAAG,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAU1E,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,4BAA4B,CAAC;IAcpF,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,8BAA8B,CAAC;CAyCnI;AAED,eAAO,MAAM,WAAW,aAA6B,CAAC"}
1
+ {"version":3,"file":"team.service.d.ts","sourceRoot":"/","sources":["modules/tournament/team/team.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EACH,0BAA0B,EAC1B,sBAAsB,EAEtB,8BAA8B,EAC9B,4BAA4B,EAC/B,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAMxE,qBACa,WAAW;IACpB,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,kBAAkB,CAAqB;;IAO/C,OAAO,CAAC,mBAAmB;IAM3B,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,iBAAiB;IAYZ,GAAG,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAU1E,MAAM,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,4BAA4B,CAAC;IAgBrF,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,8BAA8B,CAAC;IA2BhI,OAAO,CAAC,WAAW;CAkBtB;AAED,eAAO,MAAM,WAAW,aAA6B,CAAC"}
@@ -50,7 +50,7 @@ const team_repository_1 = require("./team.repository");
50
50
  const participant_service_1 = require("../participant/participant.service");
51
51
  const team_builder_1 = require("./team.builder");
52
52
  const tournament_utils_1 = require("../tournament.utils");
53
- const tournament_types_1 = require("../tournament.types");
53
+ const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
54
54
  let TeamService = class TeamService {
55
55
  repository;
56
56
  participantService;
@@ -63,10 +63,10 @@ let TeamService = class TeamService {
63
63
  }
64
64
  getMatchStatus(match, now) {
65
65
  if (match.endDate)
66
- return tournament_types_1.MatchStatus.ENDED;
66
+ return enum_1.TournamentMatchStatus.ENDED;
67
67
  if (match.startingDate && match.startingDate <= now)
68
- return tournament_types_1.MatchStatus.STARTED;
69
- return tournament_types_1.MatchStatus.UPCOMING;
68
+ return enum_1.TournamentMatchStatus.STARTED;
69
+ return enum_1.TournamentMatchStatus.UPCOMING;
70
70
  }
71
71
  applyStatusFilter(matches, now, filter) {
72
72
  const filtered = filter
@@ -75,7 +75,7 @@ let TeamService = class TeamService {
75
75
  return filtered.sort((a, b) => {
76
76
  const aTime = a.startingDate ? new Date(a.startingDate).getTime() : 0;
77
77
  const bTime = b.startingDate ? new Date(b.startingDate).getTime() : 0;
78
- return filter === tournament_types_1.MatchStatus.ENDED ? bTime - aTime : aTime - bTime;
78
+ return filter === enum_1.TournamentMatchStatus.ENDED ? bTime - aTime : aTime - bTime;
79
79
  });
80
80
  }
81
81
  async add(input) {
@@ -88,11 +88,13 @@ let TeamService = class TeamService {
88
88
  return result;
89
89
  }
90
90
  async getAll(tournamentId) {
91
- const tournament = await this.repository.findById(tournamentId);
91
+ const tournament = tournamentId
92
+ ? await this.repository.findById(tournamentId)
93
+ : await this.repository.findActive();
92
94
  if (!tournament)
93
95
  throw (0, error_common_1.notFoundError)('Tournament not found');
94
96
  return {
95
- tournamentId,
97
+ tournamentId: tournament._id,
96
98
  tag: tournament.tag,
97
99
  startDate: tournament.startDate,
98
100
  endDate: tournament.endDate,
@@ -105,26 +107,14 @@ let TeamService = class TeamService {
105
107
  const tournament = await this.repository.findById(input.tournamentId);
106
108
  if (!tournament)
107
109
  throw (0, error_common_1.notFoundError)('Tournament not found');
108
- const teamPictureById = new Map(tournament.teams.map(t => [t._id.toString(), t.picture]));
109
- const now = (0, tournament_utils_1.utcNow)();
110
110
  if (!participant.teamId)
111
111
  throw (0, error_common_1.badRequestError)('You have not joined this tournament');
112
+ const now = (0, tournament_utils_1.utcNow)();
112
113
  const teamMatches = this.filterMatchesByTeam(tournament.matches, participant.teamId);
113
114
  const filteredMatches = this.applyStatusFilter(teamMatches, now, input.filter);
114
- const predictionsByMatchId = new Map(participant.predictions.map(p => [p.matchId.toString(), p]));
115
- const matches = filteredMatches.map(match => {
116
- const prediction = predictionsByMatchId.get(match._id.toString());
117
- return {
118
- ...match,
119
- team1: { ...match.team1, picture: teamPictureById.get(match.team1.teamId.toString()) },
120
- team2: { ...match.team2, picture: teamPictureById.get(match.team2.teamId.toString()) },
121
- prediction: prediction
122
- ? { score: prediction.score, succeeded: prediction.succeeded ?? null }
123
- : null,
124
- canPredict: !match.startingDate || now < new Date(match.startingDate),
125
- matchStatus: this.getMatchStatus(match, now),
126
- };
127
- });
115
+ const teamPictureById = team_builder_1.TeamBuilder.buildTeamPictureMap(tournament.teams);
116
+ const predictionsByMatchId = team_builder_1.TeamBuilder.buildPredictionMap(participant.predictions);
117
+ const matches = filteredMatches.map(match => this.enrichMatch(match, now, teamPictureById, predictionsByMatchId));
128
118
  return {
129
119
  tournamentId: input.tournamentId,
130
120
  tag: tournament.tag,
@@ -134,6 +124,19 @@ let TeamService = class TeamService {
134
124
  matches,
135
125
  };
136
126
  }
127
+ enrichMatch(match, now, teamPictureById, predictionsByMatchId) {
128
+ const prediction = predictionsByMatchId.get(match._id.toString());
129
+ return {
130
+ ...match,
131
+ team1: { ...match.team1, picture: teamPictureById.get(match.team1.teamId.toString()) },
132
+ team2: { ...match.team2, picture: teamPictureById.get(match.team2.teamId.toString()) },
133
+ prediction: prediction
134
+ ? { score: prediction.score, succeeded: prediction.succeeded ?? null }
135
+ : null,
136
+ canPredict: !match.startingDate || now < new Date(match.startingDate),
137
+ matchStatus: this.getMatchStatus(match, now),
138
+ };
139
+ }
137
140
  };
138
141
  exports.TeamService = TeamService;
139
142
  exports.TeamService = TeamService = __decorate([