@lyxa.ai/marketing 1.0.52 → 1.0.54

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 (509) hide show
  1. package/dist/lib/index.d.ts +946 -53
  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 +647 -0
  6. package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
  7. package/dist/lib/modules/coupon/routers/coupon.router.js +7 -0
  8. package/dist/lib/modules/coupon/routers/coupon.router.js.map +1 -1
  9. package/dist/lib/modules/coupon/services/coupon.service.d.ts +8 -1
  10. package/dist/lib/modules/coupon/services/coupon.service.d.ts.map +1 -1
  11. package/dist/lib/modules/coupon/services/coupon.service.js +231 -27
  12. package/dist/lib/modules/coupon/services/coupon.service.js.map +1 -1
  13. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
  14. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js +17 -4
  15. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js.map +1 -1
  16. package/dist/lib/modules/coupon/validations/coupon.validation.d.ts +26 -0
  17. package/dist/lib/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
  18. package/dist/lib/modules/coupon/validations/coupon.validation.js +10 -1
  19. package/dist/lib/modules/coupon/validations/coupon.validation.js.map +1 -1
  20. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts +40 -40
  21. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js +9 -9
  22. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js.map +1 -1
  23. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts +0 -1
  24. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts.map +1 -1
  25. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.js +2 -5
  26. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.js.map +1 -1
  27. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts +1 -0
  28. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts.map +1 -1
  29. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.js +2 -0
  30. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.js.map +1 -1
  31. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +53 -40
  32. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts.map +1 -1
  33. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js +3 -2
  34. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js.map +1 -1
  35. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts +3 -9
  36. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
  37. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js +4 -7
  38. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js.map +1 -1
  39. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts +1 -0
  40. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts.map +1 -1
  41. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.service.js +15 -0
  42. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.service.js.map +1 -1
  43. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts +88 -42
  44. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
  45. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.js +23 -0
  46. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.js.map +1 -1
  47. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts +19 -0
  48. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -0
  49. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js +84 -0
  50. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js.map +1 -0
  51. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.builder.d.ts +13 -0
  52. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.builder.d.ts.map +1 -0
  53. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.builder.js +22 -0
  54. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.builder.js.map +1 -0
  55. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts +20 -0
  56. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts.map +1 -0
  57. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.js +26 -0
  58. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.js.map +1 -0
  59. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.service.d.ts +8 -0
  60. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.service.d.ts.map +1 -0
  61. package/dist/lib/modules/{tournament/notification/notification.scheduler.service.js → limited-time-offer/notification/limited-time-offer-notification.service.js} +15 -28
  62. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.service.js.map +1 -0
  63. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.type.d.ts +5 -0
  64. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.type.d.ts.map +1 -0
  65. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.type.js +3 -0
  66. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.type.js.map +1 -0
  67. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.js +1 -1
  68. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.js.map +1 -1
  69. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +13 -0
  70. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
  71. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js +75 -0
  72. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js.map +1 -1
  73. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +6 -2
  74. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
  75. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts +1 -0
  76. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts.map +1 -0
  77. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.js +2 -0
  78. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.js.map +1 -0
  79. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +6 -1
  80. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
  81. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js +3 -2
  82. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js.map +1 -1
  83. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +12 -2
  84. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  85. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js +80 -27
  86. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js.map +1 -1
  87. package/dist/lib/modules/marketing/services/marketing.service.d.ts +1 -0
  88. package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
  89. package/dist/lib/modules/marketing/services/marketing.service.js +9 -0
  90. package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -1
  91. package/dist/lib/modules/marketing/validations/product-marketing.validation.d.ts +2 -2
  92. package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +1 -1
  93. package/dist/lib/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +2 -2
  94. package/dist/lib/modules/tournament/config/config.builder.d.ts.map +1 -1
  95. package/dist/lib/modules/tournament/config/config.builder.js +4 -0
  96. package/dist/lib/modules/tournament/config/config.builder.js.map +1 -1
  97. package/dist/lib/modules/tournament/config/config.repository.d.ts +8 -2
  98. package/dist/lib/modules/tournament/config/config.repository.d.ts.map +1 -1
  99. package/dist/lib/modules/tournament/config/config.repository.js +30 -1
  100. package/dist/lib/modules/tournament/config/config.repository.js.map +1 -1
  101. package/dist/lib/modules/tournament/config/config.router.d.ts +92 -2
  102. package/dist/lib/modules/tournament/config/config.router.d.ts.map +1 -1
  103. package/dist/lib/modules/tournament/config/config.types.d.ts +15 -0
  104. package/dist/lib/modules/tournament/config/config.types.d.ts.map +1 -0
  105. package/dist/lib/modules/tournament/config/config.types.js +3 -0
  106. package/dist/lib/modules/tournament/config/config.types.js.map +1 -0
  107. package/dist/lib/modules/tournament/config/config.validation.d.ts +395 -15
  108. package/dist/lib/modules/tournament/config/config.validation.d.ts.map +1 -1
  109. package/dist/lib/modules/tournament/config/config.validation.js +17 -2
  110. package/dist/lib/modules/tournament/config/config.validation.js.map +1 -1
  111. package/dist/lib/modules/tournament/integration/integration.factory.d.ts +4 -0
  112. package/dist/lib/modules/tournament/integration/integration.factory.d.ts.map +1 -0
  113. package/dist/lib/modules/tournament/integration/integration.factory.js +18 -0
  114. package/dist/lib/modules/tournament/integration/integration.factory.js.map +1 -0
  115. package/dist/lib/modules/tournament/integration/interfaces/ITournamentService.d.ts +36 -0
  116. package/dist/lib/modules/tournament/integration/interfaces/ITournamentService.d.ts.map +1 -0
  117. package/dist/lib/modules/tournament/integration/interfaces/ITournamentService.js +3 -0
  118. package/dist/lib/modules/tournament/integration/interfaces/ITournamentService.js.map +1 -0
  119. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.provider.d.ts +14 -0
  120. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.provider.d.ts.map +1 -0
  121. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.provider.js +92 -0
  122. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.provider.js.map +1 -0
  123. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.types.d.ts +51 -0
  124. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.types.d.ts.map +1 -0
  125. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.types.js +3 -0
  126. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.types.js.map +1 -0
  127. package/dist/lib/modules/tournament/integration/providers/api-football/index.d.ts +3 -0
  128. package/dist/lib/modules/tournament/integration/providers/api-football/index.d.ts.map +1 -0
  129. package/dist/lib/modules/tournament/integration/providers/api-football/index.js +19 -0
  130. package/dist/lib/modules/tournament/integration/providers/api-football/index.js.map +1 -0
  131. package/dist/lib/modules/tournament/integration/providers/index.d.ts +3 -0
  132. package/dist/lib/modules/tournament/integration/providers/index.d.ts.map +1 -0
  133. package/dist/lib/modules/tournament/integration/providers/index.js +19 -0
  134. package/dist/lib/modules/tournament/integration/providers/index.js.map +1 -0
  135. package/dist/lib/modules/tournament/integration/providers/mock.provider.d.ts +7 -0
  136. package/dist/lib/modules/tournament/integration/providers/mock.provider.d.ts.map +1 -0
  137. package/dist/lib/modules/tournament/integration/providers/mock.provider.js +22 -0
  138. package/dist/lib/modules/tournament/integration/providers/mock.provider.js.map +1 -0
  139. package/dist/lib/modules/tournament/integration/tournamentService.d.ts +9 -0
  140. package/dist/lib/modules/tournament/integration/tournamentService.d.ts.map +1 -0
  141. package/dist/lib/modules/tournament/integration/tournamentService.js +20 -0
  142. package/dist/lib/modules/tournament/integration/tournamentService.js.map +1 -0
  143. package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.d.ts.map +1 -1
  144. package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js +47 -11
  145. package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js.map +1 -1
  146. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.d.ts +7 -3
  147. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.d.ts.map +1 -1
  148. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.js +1 -1
  149. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.js.map +1 -1
  150. package/dist/lib/modules/tournament/match/events/match-evaluation.orchestrator.d.ts +14 -0
  151. package/dist/lib/modules/tournament/match/events/match-evaluation.orchestrator.d.ts.map +1 -0
  152. package/dist/lib/modules/tournament/{notification/jobs/notification.worker.js → match/events/match-evaluation.orchestrator.js} +31 -27
  153. package/dist/lib/modules/tournament/match/events/match-evaluation.orchestrator.js.map +1 -0
  154. package/dist/lib/modules/tournament/match/match.builder.d.ts +13 -34
  155. package/dist/lib/modules/tournament/match/match.builder.d.ts.map +1 -1
  156. package/dist/lib/modules/tournament/match/match.builder.js +31 -10
  157. package/dist/lib/modules/tournament/match/match.builder.js.map +1 -1
  158. package/dist/lib/modules/tournament/match/match.repository.d.ts +1 -1
  159. package/dist/lib/modules/tournament/match/match.repository.d.ts.map +1 -1
  160. package/dist/lib/modules/tournament/match/match.repository.js.map +1 -1
  161. package/dist/lib/modules/tournament/match/match.router.d.ts +36 -0
  162. package/dist/lib/modules/tournament/match/match.router.d.ts.map +1 -1
  163. package/dist/lib/modules/tournament/match/match.service.d.ts +3 -0
  164. package/dist/lib/modules/tournament/match/match.service.d.ts.map +1 -1
  165. package/dist/lib/modules/tournament/match/match.service.js +15 -12
  166. package/dist/lib/modules/tournament/match/match.service.js.map +1 -1
  167. package/dist/lib/modules/tournament/match/match.types.d.ts +51 -0
  168. package/dist/lib/modules/tournament/match/match.types.d.ts.map +1 -0
  169. package/dist/lib/modules/tournament/match/match.types.js +3 -0
  170. package/dist/lib/modules/tournament/match/match.types.js.map +1 -0
  171. package/dist/lib/modules/tournament/notification/notification-template.repository.d.ts +2 -1
  172. package/dist/lib/modules/tournament/notification/notification-template.repository.d.ts.map +1 -1
  173. package/dist/lib/modules/tournament/notification/notification-template.repository.js +2 -1
  174. package/dist/lib/modules/tournament/notification/notification-template.repository.js.map +1 -1
  175. package/dist/lib/modules/tournament/notification/notification.builder.d.ts +30 -0
  176. package/dist/lib/modules/tournament/notification/notification.builder.d.ts.map +1 -0
  177. package/dist/lib/modules/tournament/notification/notification.builder.js +35 -0
  178. package/dist/lib/modules/tournament/notification/notification.builder.js.map +1 -0
  179. package/dist/lib/modules/tournament/notification/notification.config.d.ts +10 -9
  180. package/dist/lib/modules/tournament/notification/notification.config.d.ts.map +1 -1
  181. package/dist/lib/modules/tournament/notification/notification.config.js +0 -12
  182. package/dist/lib/modules/tournament/notification/notification.config.js.map +1 -1
  183. package/dist/lib/modules/tournament/notification/notification.service.d.ts +5 -3
  184. package/dist/lib/modules/tournament/notification/notification.service.d.ts.map +1 -1
  185. package/dist/lib/modules/tournament/notification/notification.service.js +23 -15
  186. package/dist/lib/modules/tournament/notification/notification.service.js.map +1 -1
  187. package/dist/lib/modules/tournament/participant/participant.builder.d.ts +12 -0
  188. package/dist/lib/modules/tournament/participant/participant.builder.d.ts.map +1 -0
  189. package/dist/lib/modules/tournament/participant/participant.builder.js +17 -0
  190. package/dist/lib/modules/tournament/participant/participant.builder.js.map +1 -0
  191. package/dist/lib/modules/tournament/participant/participant.repository.d.ts +8 -7
  192. package/dist/lib/modules/tournament/participant/participant.repository.d.ts.map +1 -1
  193. package/dist/lib/modules/tournament/participant/participant.repository.js +12 -2
  194. package/dist/lib/modules/tournament/participant/participant.repository.js.map +1 -1
  195. package/dist/lib/modules/tournament/participant/participant.service.d.ts +1 -0
  196. package/dist/lib/modules/tournament/participant/participant.service.d.ts.map +1 -1
  197. package/dist/lib/modules/tournament/participant/participant.service.js +15 -17
  198. package/dist/lib/modules/tournament/participant/participant.service.js.map +1 -1
  199. package/dist/lib/modules/tournament/prediction/prediction.builder.d.ts +3 -9
  200. package/dist/lib/modules/tournament/prediction/prediction.builder.d.ts.map +1 -1
  201. package/dist/lib/modules/tournament/prediction/prediction.builder.js.map +1 -1
  202. package/dist/lib/modules/tournament/prediction/prediction.repository.d.ts +11 -3
  203. package/dist/lib/modules/tournament/prediction/prediction.repository.d.ts.map +1 -1
  204. package/dist/lib/modules/tournament/prediction/prediction.repository.js +47 -0
  205. package/dist/lib/modules/tournament/prediction/prediction.repository.js.map +1 -1
  206. package/dist/lib/modules/tournament/prediction/prediction.service.d.ts +1 -1
  207. package/dist/lib/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
  208. package/dist/lib/modules/tournament/prediction/prediction.service.js +16 -26
  209. package/dist/lib/modules/tournament/prediction/prediction.service.js.map +1 -1
  210. package/dist/lib/modules/tournament/prediction/prediction.types.d.ts +17 -0
  211. package/dist/lib/modules/tournament/prediction/prediction.types.d.ts.map +1 -0
  212. package/dist/lib/modules/tournament/prediction/prediction.types.js +3 -0
  213. package/dist/lib/modules/tournament/prediction/prediction.types.js.map +1 -0
  214. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.d.ts +8 -5
  215. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.d.ts.map +1 -1
  216. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.js +58 -16
  217. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.js.map +1 -1
  218. package/dist/lib/modules/tournament/reward/reward.builder.d.ts +5 -2
  219. package/dist/lib/modules/tournament/reward/reward.builder.d.ts.map +1 -1
  220. package/dist/lib/modules/tournament/reward/reward.builder.js +44 -28
  221. package/dist/lib/modules/tournament/reward/reward.builder.js.map +1 -1
  222. package/dist/lib/modules/tournament/reward/reward.factory.d.ts +1 -1
  223. package/dist/lib/modules/tournament/reward/reward.factory.d.ts.map +1 -1
  224. package/dist/lib/modules/tournament/reward/reward.factory.js.map +1 -1
  225. package/dist/lib/modules/tournament/reward/reward.interface.d.ts +2 -2
  226. package/dist/lib/modules/tournament/reward/reward.interface.d.ts.map +1 -1
  227. package/dist/lib/modules/tournament/reward/reward.interface.js.map +1 -1
  228. package/dist/lib/modules/tournament/reward/reward.service.d.ts +1 -1
  229. package/dist/lib/modules/tournament/reward/reward.service.d.ts.map +1 -1
  230. package/dist/lib/modules/tournament/reward/reward.service.js +1 -1
  231. package/dist/lib/modules/tournament/reward/reward.service.js.map +1 -1
  232. package/dist/lib/modules/tournament/reward/reward.types.d.ts +35 -2
  233. package/dist/lib/modules/tournament/reward/reward.types.d.ts.map +1 -1
  234. package/dist/lib/modules/tournament/reward/reward.types.js.map +1 -1
  235. package/dist/lib/modules/tournament/schedule/schedule.router.d.ts.map +1 -1
  236. package/dist/lib/modules/tournament/schedule/schedule.router.js +1 -3
  237. package/dist/lib/modules/tournament/schedule/schedule.router.js.map +1 -1
  238. package/dist/lib/modules/tournament/schedule/schedule.service.d.ts +3 -0
  239. package/dist/lib/modules/tournament/schedule/schedule.service.d.ts.map +1 -1
  240. package/dist/lib/modules/tournament/schedule/schedule.service.js +30 -1
  241. package/dist/lib/modules/tournament/schedule/schedule.service.js.map +1 -1
  242. package/dist/lib/modules/tournament/score/score.repository.d.ts +13 -0
  243. package/dist/lib/modules/tournament/score/score.repository.d.ts.map +1 -1
  244. package/dist/lib/modules/tournament/score/score.repository.js +20 -0
  245. package/dist/lib/modules/tournament/score/score.repository.js.map +1 -1
  246. package/dist/lib/modules/tournament/score/score.service.d.ts +3 -0
  247. package/dist/lib/modules/tournament/score/score.service.d.ts.map +1 -1
  248. package/dist/lib/modules/tournament/score/score.service.js +3 -0
  249. package/dist/lib/modules/tournament/score/score.service.js.map +1 -1
  250. package/dist/lib/modules/tournament/statistics/statistics.builder.d.ts +5 -0
  251. package/dist/lib/modules/tournament/statistics/statistics.builder.d.ts.map +1 -1
  252. package/dist/lib/modules/tournament/statistics/statistics.builder.js +47 -28
  253. package/dist/lib/modules/tournament/statistics/statistics.builder.js.map +1 -1
  254. package/dist/lib/modules/tournament/statistics/statistics.router.d.ts +4 -2
  255. package/dist/lib/modules/tournament/statistics/statistics.router.d.ts.map +1 -1
  256. package/dist/lib/modules/tournament/statistics/statistics.service.js +4 -4
  257. package/dist/lib/modules/tournament/statistics/statistics.service.js.map +1 -1
  258. package/dist/lib/modules/tournament/statistics/statistics.validation.d.ts +32 -14
  259. package/dist/lib/modules/tournament/statistics/statistics.validation.d.ts.map +1 -1
  260. package/dist/lib/modules/tournament/statistics/statistics.validation.js +2 -1
  261. package/dist/lib/modules/tournament/statistics/statistics.validation.js.map +1 -1
  262. package/dist/lib/modules/tournament/sync/sync.repository.d.ts +11 -0
  263. package/dist/lib/modules/tournament/sync/sync.repository.d.ts.map +1 -0
  264. package/dist/lib/modules/tournament/sync/sync.repository.js +67 -0
  265. package/dist/lib/modules/tournament/sync/sync.repository.js.map +1 -0
  266. package/dist/lib/modules/tournament/sync/sync.router.d.ts +27 -0
  267. package/dist/lib/modules/tournament/sync/sync.router.d.ts.map +1 -0
  268. package/dist/lib/modules/tournament/sync/sync.router.js +15 -0
  269. package/dist/lib/modules/tournament/sync/sync.router.js.map +1 -0
  270. package/dist/lib/modules/tournament/sync/sync.service.d.ts +9 -0
  271. package/dist/lib/modules/tournament/sync/sync.service.d.ts.map +1 -0
  272. package/dist/lib/modules/tournament/sync/sync.service.js +117 -0
  273. package/dist/lib/modules/tournament/sync/sync.service.js.map +1 -0
  274. package/dist/lib/modules/tournament/team/team.builder.d.ts +4 -0
  275. package/dist/lib/modules/tournament/team/team.builder.d.ts.map +1 -1
  276. package/dist/lib/modules/tournament/team/team.builder.js +6 -0
  277. package/dist/lib/modules/tournament/team/team.builder.js.map +1 -1
  278. package/dist/lib/modules/tournament/team/team.repository.d.ts +3 -0
  279. package/dist/lib/modules/tournament/team/team.repository.d.ts.map +1 -1
  280. package/dist/lib/modules/tournament/team/team.repository.js +6 -0
  281. package/dist/lib/modules/tournament/team/team.repository.js.map +1 -1
  282. package/dist/lib/modules/tournament/team/team.router.d.ts +22 -4
  283. package/dist/lib/modules/tournament/team/team.router.d.ts.map +1 -1
  284. package/dist/lib/modules/tournament/team/team.router.js +1 -1
  285. package/dist/lib/modules/tournament/team/team.router.js.map +1 -1
  286. package/dist/lib/modules/tournament/team/team.service.d.ts +2 -1
  287. package/dist/lib/modules/tournament/team/team.service.d.ts.map +1 -1
  288. package/dist/lib/modules/tournament/team/team.service.js +26 -23
  289. package/dist/lib/modules/tournament/team/team.service.js.map +1 -1
  290. package/dist/lib/modules/tournament/team/team.validation.d.ts +23 -24
  291. package/dist/lib/modules/tournament/team/team.validation.d.ts.map +1 -1
  292. package/dist/lib/modules/tournament/team/team.validation.js +3 -4
  293. package/dist/lib/modules/tournament/team/team.validation.js.map +1 -1
  294. package/dist/lib/modules/tournament/tournament.builder.d.ts +11 -0
  295. package/dist/lib/modules/tournament/tournament.builder.d.ts.map +1 -0
  296. package/dist/lib/modules/tournament/tournament.builder.js +34 -0
  297. package/dist/lib/modules/tournament/tournament.builder.js.map +1 -0
  298. package/dist/lib/modules/tournament/tournament.router.d.ts +210 -10
  299. package/dist/lib/modules/tournament/tournament.router.d.ts.map +1 -1
  300. package/dist/lib/modules/tournament/tournament.router.js +2 -0
  301. package/dist/lib/modules/tournament/tournament.router.js.map +1 -1
  302. package/dist/lib/modules/tournament/tournament.service.d.ts.map +1 -1
  303. package/dist/lib/modules/tournament/tournament.service.js +3 -10
  304. package/dist/lib/modules/tournament/tournament.service.js.map +1 -1
  305. package/dist/lib/modules/tournament/tournament.utils.d.ts +4 -0
  306. package/dist/lib/modules/tournament/tournament.utils.d.ts.map +1 -1
  307. package/dist/lib/modules/tournament/tournament.utils.js +8 -1
  308. package/dist/lib/modules/tournament/tournament.utils.js.map +1 -1
  309. package/dist/lib/modules/tournament/tournament.validation.d.ts +205 -1
  310. package/dist/lib/modules/tournament/tournament.validation.d.ts.map +1 -1
  311. package/dist/lib/modules/tournament/tournament.validation.js +23 -2
  312. package/dist/lib/modules/tournament/tournament.validation.js.map +1 -1
  313. package/dist/types/index.d.ts +946 -53
  314. package/dist/types/index.d.ts.map +1 -1
  315. package/dist/types/modules/coupon/routers/coupon.router.d.ts +647 -0
  316. package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
  317. package/dist/types/modules/coupon/services/coupon.service.d.ts +8 -1
  318. package/dist/types/modules/coupon/services/coupon.service.d.ts.map +1 -1
  319. package/dist/types/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
  320. package/dist/types/modules/coupon/validations/coupon.validation.d.ts +26 -0
  321. package/dist/types/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
  322. package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts +42 -40
  323. package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
  324. package/dist/types/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts +0 -1
  325. package/dist/types/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts.map +1 -1
  326. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts +1 -0
  327. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts.map +1 -1
  328. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +53 -40
  329. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts.map +1 -1
  330. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts +3 -9
  331. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
  332. package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts +1 -0
  333. package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts.map +1 -1
  334. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts +88 -42
  335. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
  336. package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts +24 -0
  337. package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -0
  338. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.builder.d.ts +13 -0
  339. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.builder.d.ts.map +1 -0
  340. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts +20 -0
  341. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts.map +1 -0
  342. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.service.d.ts +8 -0
  343. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.service.d.ts.map +1 -0
  344. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.type.d.ts +5 -0
  345. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.type.d.ts.map +1 -0
  346. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +13 -0
  347. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
  348. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +6 -2
  349. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
  350. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +6 -1
  351. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
  352. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +22 -2
  353. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  354. package/dist/types/modules/marketing/services/marketing.service.d.ts +1 -0
  355. package/dist/types/modules/marketing/services/marketing.service.d.ts.map +1 -1
  356. package/dist/types/modules/marketing/validations/product-marketing.validation.d.ts +2 -2
  357. package/dist/types/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +1 -1
  358. package/dist/types/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +2 -2
  359. package/dist/types/modules/tournament/config/config.builder.d.ts.map +1 -1
  360. package/dist/types/modules/tournament/config/config.repository.d.ts +8 -2
  361. package/dist/types/modules/tournament/config/config.repository.d.ts.map +1 -1
  362. package/dist/types/modules/tournament/config/config.router.d.ts +92 -2
  363. package/dist/types/modules/tournament/config/config.router.d.ts.map +1 -1
  364. package/dist/types/modules/tournament/config/config.types.d.ts +15 -0
  365. package/dist/types/modules/tournament/config/config.types.d.ts.map +1 -0
  366. package/dist/types/modules/tournament/config/config.validation.d.ts +395 -15
  367. package/dist/types/modules/tournament/config/config.validation.d.ts.map +1 -1
  368. package/dist/types/modules/tournament/integration/integration.factory.d.ts +4 -0
  369. package/dist/types/modules/tournament/integration/integration.factory.d.ts.map +1 -0
  370. package/dist/types/modules/tournament/integration/interfaces/ITournamentService.d.ts +36 -0
  371. package/dist/types/modules/tournament/integration/interfaces/ITournamentService.d.ts.map +1 -0
  372. package/dist/types/modules/tournament/integration/providers/api-football/api-football.provider.d.ts +14 -0
  373. package/dist/types/modules/tournament/integration/providers/api-football/api-football.provider.d.ts.map +1 -0
  374. package/dist/types/modules/tournament/integration/providers/api-football/api-football.types.d.ts +51 -0
  375. package/dist/types/modules/tournament/integration/providers/api-football/api-football.types.d.ts.map +1 -0
  376. package/dist/types/modules/tournament/integration/providers/api-football/index.d.ts +3 -0
  377. package/dist/types/modules/tournament/integration/providers/api-football/index.d.ts.map +1 -0
  378. package/dist/types/modules/tournament/integration/providers/index.d.ts +3 -0
  379. package/dist/types/modules/tournament/integration/providers/index.d.ts.map +1 -0
  380. package/dist/types/modules/tournament/integration/providers/mock.provider.d.ts +7 -0
  381. package/dist/types/modules/tournament/integration/providers/mock.provider.d.ts.map +1 -0
  382. package/dist/types/modules/tournament/integration/tournamentService.d.ts +9 -0
  383. package/dist/types/modules/tournament/integration/tournamentService.d.ts.map +1 -0
  384. package/dist/types/modules/tournament/match/events/evaluate-predictions.consumer.d.ts.map +1 -1
  385. package/dist/types/modules/tournament/match/events/evaluate-predictions.event.d.ts +7 -3
  386. package/dist/types/modules/tournament/match/events/evaluate-predictions.event.d.ts.map +1 -1
  387. package/dist/types/modules/tournament/match/events/match-evaluation.orchestrator.d.ts +14 -0
  388. package/dist/types/modules/tournament/match/events/match-evaluation.orchestrator.d.ts.map +1 -0
  389. package/dist/types/modules/tournament/match/match.builder.d.ts +13 -34
  390. package/dist/types/modules/tournament/match/match.builder.d.ts.map +1 -1
  391. package/dist/types/modules/tournament/match/match.repository.d.ts +1 -1
  392. package/dist/types/modules/tournament/match/match.repository.d.ts.map +1 -1
  393. package/dist/types/modules/tournament/match/match.router.d.ts +36 -0
  394. package/dist/types/modules/tournament/match/match.router.d.ts.map +1 -1
  395. package/dist/types/modules/tournament/match/match.service.d.ts +3 -0
  396. package/dist/types/modules/tournament/match/match.service.d.ts.map +1 -1
  397. package/dist/types/modules/tournament/match/match.types.d.ts +51 -0
  398. package/dist/types/modules/tournament/match/match.types.d.ts.map +1 -0
  399. package/dist/types/modules/tournament/notification/notification-template.repository.d.ts +2 -1
  400. package/dist/types/modules/tournament/notification/notification-template.repository.d.ts.map +1 -1
  401. package/dist/types/modules/tournament/notification/notification.builder.d.ts +30 -0
  402. package/dist/types/modules/tournament/notification/notification.builder.d.ts.map +1 -0
  403. package/dist/types/modules/tournament/notification/notification.config.d.ts +10 -9
  404. package/dist/types/modules/tournament/notification/notification.config.d.ts.map +1 -1
  405. package/dist/types/modules/tournament/notification/notification.service.d.ts +5 -3
  406. package/dist/types/modules/tournament/notification/notification.service.d.ts.map +1 -1
  407. package/dist/types/modules/tournament/participant/participant.builder.d.ts +12 -0
  408. package/dist/types/modules/tournament/participant/participant.builder.d.ts.map +1 -0
  409. package/dist/types/modules/tournament/participant/participant.repository.d.ts +8 -7
  410. package/dist/types/modules/tournament/participant/participant.repository.d.ts.map +1 -1
  411. package/dist/types/modules/tournament/participant/participant.service.d.ts +1 -0
  412. package/dist/types/modules/tournament/participant/participant.service.d.ts.map +1 -1
  413. package/dist/types/modules/tournament/prediction/prediction.builder.d.ts +3 -9
  414. package/dist/types/modules/tournament/prediction/prediction.builder.d.ts.map +1 -1
  415. package/dist/types/modules/tournament/prediction/prediction.repository.d.ts +11 -3
  416. package/dist/types/modules/tournament/prediction/prediction.repository.d.ts.map +1 -1
  417. package/dist/types/modules/tournament/prediction/prediction.service.d.ts +1 -1
  418. package/dist/types/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
  419. package/dist/types/modules/tournament/prediction/prediction.types.d.ts +17 -0
  420. package/dist/types/modules/tournament/prediction/prediction.types.d.ts.map +1 -0
  421. package/dist/types/modules/tournament/reward/handlers/coupon-reward.handler.d.ts +8 -5
  422. package/dist/types/modules/tournament/reward/handlers/coupon-reward.handler.d.ts.map +1 -1
  423. package/dist/types/modules/tournament/reward/reward.builder.d.ts +5 -2
  424. package/dist/types/modules/tournament/reward/reward.builder.d.ts.map +1 -1
  425. package/dist/types/modules/tournament/reward/reward.factory.d.ts +1 -1
  426. package/dist/types/modules/tournament/reward/reward.factory.d.ts.map +1 -1
  427. package/dist/types/modules/tournament/reward/reward.interface.d.ts +2 -2
  428. package/dist/types/modules/tournament/reward/reward.interface.d.ts.map +1 -1
  429. package/dist/types/modules/tournament/reward/reward.service.d.ts +1 -1
  430. package/dist/types/modules/tournament/reward/reward.service.d.ts.map +1 -1
  431. package/dist/types/modules/tournament/reward/reward.types.d.ts +35 -2
  432. package/dist/types/modules/tournament/reward/reward.types.d.ts.map +1 -1
  433. package/dist/types/modules/tournament/schedule/schedule.router.d.ts.map +1 -1
  434. package/dist/types/modules/tournament/schedule/schedule.service.d.ts +3 -0
  435. package/dist/types/modules/tournament/schedule/schedule.service.d.ts.map +1 -1
  436. package/dist/types/modules/tournament/score/score.repository.d.ts +13 -0
  437. package/dist/types/modules/tournament/score/score.repository.d.ts.map +1 -1
  438. package/dist/types/modules/tournament/score/score.service.d.ts +3 -0
  439. package/dist/types/modules/tournament/score/score.service.d.ts.map +1 -1
  440. package/dist/types/modules/tournament/statistics/statistics.builder.d.ts +5 -0
  441. package/dist/types/modules/tournament/statistics/statistics.builder.d.ts.map +1 -1
  442. package/dist/types/modules/tournament/statistics/statistics.router.d.ts +4 -2
  443. package/dist/types/modules/tournament/statistics/statistics.router.d.ts.map +1 -1
  444. package/dist/types/modules/tournament/statistics/statistics.validation.d.ts +32 -14
  445. package/dist/types/modules/tournament/statistics/statistics.validation.d.ts.map +1 -1
  446. package/dist/types/modules/tournament/sync/sync.repository.d.ts +11 -0
  447. package/dist/types/modules/tournament/sync/sync.repository.d.ts.map +1 -0
  448. package/dist/types/modules/tournament/sync/sync.router.d.ts +27 -0
  449. package/dist/types/modules/tournament/sync/sync.router.d.ts.map +1 -0
  450. package/dist/types/modules/tournament/sync/sync.service.d.ts +9 -0
  451. package/dist/types/modules/tournament/sync/sync.service.d.ts.map +1 -0
  452. package/dist/types/modules/tournament/team/team.builder.d.ts +4 -0
  453. package/dist/types/modules/tournament/team/team.builder.d.ts.map +1 -1
  454. package/dist/types/modules/tournament/team/team.repository.d.ts +3 -0
  455. package/dist/types/modules/tournament/team/team.repository.d.ts.map +1 -1
  456. package/dist/types/modules/tournament/team/team.router.d.ts +22 -4
  457. package/dist/types/modules/tournament/team/team.router.d.ts.map +1 -1
  458. package/dist/types/modules/tournament/team/team.service.d.ts +2 -1
  459. package/dist/types/modules/tournament/team/team.service.d.ts.map +1 -1
  460. package/dist/types/modules/tournament/team/team.validation.d.ts +23 -24
  461. package/dist/types/modules/tournament/team/team.validation.d.ts.map +1 -1
  462. package/dist/types/modules/tournament/tournament.builder.d.ts +11 -0
  463. package/dist/types/modules/tournament/tournament.builder.d.ts.map +1 -0
  464. package/dist/types/modules/tournament/tournament.router.d.ts +210 -10
  465. package/dist/types/modules/tournament/tournament.router.d.ts.map +1 -1
  466. package/dist/types/modules/tournament/tournament.service.d.ts.map +1 -1
  467. package/dist/types/modules/tournament/tournament.utils.d.ts +4 -0
  468. package/dist/types/modules/tournament/tournament.utils.d.ts.map +1 -1
  469. package/dist/types/modules/tournament/tournament.validation.d.ts +205 -1
  470. package/dist/types/modules/tournament/tournament.validation.d.ts.map +1 -1
  471. package/package.json +2 -2
  472. package/dist/lib/modules/tournament/match/events/match-ended.consumer.d.ts +0 -2
  473. package/dist/lib/modules/tournament/match/events/match-ended.consumer.d.ts.map +0 -1
  474. package/dist/lib/modules/tournament/match/events/match-ended.consumer.js +0 -15
  475. package/dist/lib/modules/tournament/match/events/match-ended.consumer.js.map +0 -1
  476. package/dist/lib/modules/tournament/match/events/match-ended.event.d.ts +0 -14
  477. package/dist/lib/modules/tournament/match/events/match-ended.event.d.ts.map +0 -1
  478. package/dist/lib/modules/tournament/match/events/match-ended.event.js +0 -12
  479. package/dist/lib/modules/tournament/match/events/match-ended.event.js.map +0 -1
  480. package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts +0 -10
  481. package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts.map +0 -1
  482. package/dist/lib/modules/tournament/notification/jobs/notification.producer.js +0 -23
  483. package/dist/lib/modules/tournament/notification/jobs/notification.producer.js.map +0 -1
  484. package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts +0 -9
  485. package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts.map +0 -1
  486. package/dist/lib/modules/tournament/notification/jobs/notification.worker.js.map +0 -1
  487. package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts +0 -10
  488. package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts.map +0 -1
  489. package/dist/lib/modules/tournament/notification/notification.schedule.config.js +0 -15
  490. package/dist/lib/modules/tournament/notification/notification.schedule.config.js.map +0 -1
  491. package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts +0 -10
  492. package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts.map +0 -1
  493. package/dist/lib/modules/tournament/notification/notification.scheduler.service.js.map +0 -1
  494. package/dist/types/events/event-initializations.d.ts +0 -2
  495. package/dist/types/events/event-initializations.d.ts.map +0 -1
  496. package/dist/types/modules/tournament/config/tournament-config.validation.d.ts +0 -201
  497. package/dist/types/modules/tournament/config/tournament-config.validation.d.ts.map +0 -1
  498. package/dist/types/modules/tournament/match/events/match-ended.consumer.d.ts +0 -2
  499. package/dist/types/modules/tournament/match/events/match-ended.consumer.d.ts.map +0 -1
  500. package/dist/types/modules/tournament/match/events/match-ended.event.d.ts +0 -14
  501. package/dist/types/modules/tournament/match/events/match-ended.event.d.ts.map +0 -1
  502. package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts +0 -10
  503. package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts.map +0 -1
  504. package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts +0 -9
  505. package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts.map +0 -1
  506. package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts +0 -10
  507. package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts.map +0 -1
  508. package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts +0 -10
  509. package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts.map +0 -1
@@ -62,10 +62,11 @@ let MatchService = class MatchService {
62
62
  return tournament;
63
63
  }
64
64
  getMatch(tournament, matchId) {
65
- const match = tournament.matches.find(m => m._id.toString() === matchId.toString());
65
+ const matchIndex = tournament.matches.findIndex(m => m._id.toString() === matchId.toString());
66
+ const match = tournament.matches[matchIndex];
66
67
  if (!match)
67
68
  throw (0, error_common_1.notFoundError)('Match not found');
68
- return match;
69
+ return { ...match, matchNumber: matchIndex + 1 };
69
70
  }
70
71
  resolveMatchTeams(tournament, team1Id, team2Id) {
71
72
  const teamsById = new Map(tournament.teams.map(team => [team._id.toString(), team]));
@@ -115,18 +116,20 @@ let MatchService = class MatchService {
115
116
  throw (0, error_common_1.badRequestError)('This match has not started yet');
116
117
  if (match.endDate)
117
118
  throw (0, error_common_1.badRequestError)('This match has already ended');
118
- const matchUpdates = match_builder_1.MatchBuilder.buildEndUpdate(match, input.finalScore);
119
- const ended = await this.applyMatchUpdate(input.tournamentId, input.matchId, matchUpdates);
120
- const { team1, team2 } = ended.score;
121
- if (team1 !== null && team1 !== undefined && team2 !== null && team2 !== undefined) {
122
- await (0, event_1.publishEvent)(new evaluate_predictions_event_1.EvaluatePredictionsEvent({
123
- tournamentId: input.tournamentId,
124
- matchId: input.matchId,
125
- finalScore: { team1, team2 },
126
- }));
127
- }
119
+ const { update, evaluation } = match_builder_1.MatchBuilder.buildEnd(match, match.matchNumber, input.finalScore);
120
+ const ended = await this.applyMatchUpdate(input.tournamentId, input.matchId, update);
121
+ await this.publishEvaluations(input.tournamentId, [evaluation]);
128
122
  return ended;
129
123
  }
124
+ async publishEvaluations(tournamentId, evaluations) {
125
+ const matches = evaluations.filter((evaluation) => evaluation !== null);
126
+ if (!matches.length)
127
+ return;
128
+ await (0, event_1.publishEvent)(new evaluate_predictions_event_1.EvaluatePredictionsEvent({ tournamentId, matches }));
129
+ }
130
+ getMatchNumber(_id) {
131
+ throw new Error('Method not implemented.');
132
+ }
130
133
  async delete(tournamentId, matchId) {
131
134
  const result = await this.repository.deleteMatch(tournamentId, matchId);
132
135
  if (!result)
@@ -1 +1 @@
1
- {"version":3,"file":"match.service.js","sourceRoot":"/","sources":["modules/tournament/match/match.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,4EAAyF;AACzF,8DAAgE;AAOhE,yDAA6D;AAC7D,mDAA6C;AAG7C,oFAA6E;AAC7E,0DAA2C;AAGpC,IAAM,YAAY,GAAlB,MAAM,YAAY;IACb,UAAU,CAA4B;IAE9C;QACI,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,4CAAyB,CAAC,CAAC;IAC/D,CAAC;IAEO,KAAK,CAAC,a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AAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACjF,MAAM,IAAA,oBAAY,EAAC,IAAI,qDAAwB,CAAC;gBAC5C,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,UAAU,EAAE,EAAC,KAAK,EAAE,KAAK,EAAC;aAC7B,CAAC,CAAC,CAAC;QACR,CAAC;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,YAAqC,EAAE,OAAgC;QACvF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACxE,IAAI,CAAC,MAAM;YAAE,MAAM,IAAA,4BAAa,EAAC,sBAAsB,CAAC,CAAC;QAEzD,OAAO,MAAmC,CAAC;IAC/C,CAAC;CACJ,CAAA;AA/FY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,gBAAO,GAAE;;GACG,YAAY,CA+FxB;AAEY,QAAA,YAAY,GAAG,gBAAS,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {badRequestError, notFoundError} from '@lyxa.ai/core/dist/utilities/error-common';\nimport {publishEvent} from '@lyxa.ai/core/dist/libraries/event';\nimport {\n AddTournamentMatchesInputDTO,\n EndTournamentMatchInputDTO,\n StartTournamentMatchInputDTO,\n TournamentMatchOutputDTO,\n} from './match.validation';\nimport {TournamentMatchRepository} from './match.repository';\nimport {MatchBuilder} from './match.builder';\nimport {TournamentConfigOutputDTO} from '../config/config.validation';\nimport {Tournament as TournamentType} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {EvaluatePredictionsEvent} from './events/evaluate-predictions.event';\nimport {utcNow} from '../tournament.utils';\n\n@Service()\nexport class MatchService {\n private repository: TournamentMatchRepository;\n\n constructor() {\n this.repository = Container.get(TournamentMatchRepository);\n }\n\n private async getTournament(tournamentId: mongoose.Types.ObjectId) {\n const tournament = await this.repository.findById(tournamentId);\n if (!tournament) throw notFoundError('Tournament not found');\n return tournament;\n }\n\n private getMatch(tournament: {matches: TournamentMatchOutputDTO[]}, matchId: mongoose.Types.ObjectId) {\n const match = tournament.matches.find(m => m._id.toString() === matchId.toString());\n if (!match) throw notFoundError('Match not found');\n return match;\n }\n\n private resolveMatchTeams(tournament: TournamentType, team1Id: mongoose.Types.ObjectId, team2Id: mongoose.Types.ObjectId) {\n const teamsById = new Map(tournament.teams.map(team => [team._id.toString(), team]));\n const team1 = teamsById.get(team1Id.toString());\n const team2 = teamsById.get(team2Id.toString());\n if (!team1 || !team2) throw badRequestError('All match teams must exist in the tournament');\n return {team1, team2};\n }\n\n private async applyMatchUpdate(\n tournamentId: mongoose.Types.ObjectId,\n matchId: mongoose.Types.ObjectId,\n updates: Record<string, unknown>\n ): Promise<TournamentMatchOutputDTO> {\n const result = await this.repository.updateMatch(tournamentId, matchId, updates);\n if (!result) throw notFoundError('Tournament not found');\n const updated = result.matches.find(m => m._id.toString() === matchId.toString());\n if (!updated) throw notFoundError('Match not found');\n return updated as TournamentMatchOutputDTO;\n }\n\n public async add(input: AddTournamentMatchesInputDTO): Promise<TournamentConfigOutputDTO> {\n const tournament = await this.getTournament(input.tournamentId);\n\n const matches = input.matches.map(match => {\n const {team1, team2} = this.resolveMatchTeams(tournament, match.team1Id, match.team2Id);\n return MatchBuilder.buildMatch(match, team1, team2);\n });\n\n const result = await this.repository.addMatches(input.tournamentId, matches);\n if (!result) throw notFoundError('Tournament not found');\n\n return result as TournamentConfigOutputDTO;\n }\n\n public async getAll(tournamentId: mongoose.Types.ObjectId): Promise<TournamentMatchOutputDTO[]> {\n const tournament = await this.getTournament(tournamentId);\n return tournament.matches as TournamentMatchOutputDTO[];\n }\n\n public async start(input: StartTournamentMatchInputDTO): Promise<TournamentMatchOutputDTO> {\n const tournament = await this.getTournament(input.tournamentId);\n const match = this.getMatch(tournament, input.matchId);\n\n if (!match.startingDate || match.startingDate > utcNow()) throw badRequestError('This match has not started yet');\n if (match.endDate) throw badRequestError('This match has already ended');\n return match;\n }\n\n public async end(input: EndTournamentMatchInputDTO): Promise<TournamentMatchOutputDTO> {\n const tournament = await this.getTournament(input.tournamentId);\n const match = this.getMatch(tournament, input.matchId);\n\n if (!match.startingDate || match.startingDate > utcNow()) throw badRequestError('This match has not started yet');\n if (match.endDate) throw badRequestError('This match has already ended');\n\n const matchUpdates = MatchBuilder.buildEndUpdate(match, input.finalScore)\n const ended = await this.applyMatchUpdate(input.tournamentId, input.matchId, matchUpdates);\n\n const {team1, team2} = ended.score;\n if (team1 !== null && team1 !== undefined && team2 !== null && team2 !== undefined) {\n await publishEvent(new EvaluatePredictionsEvent({\n tournamentId: input.tournamentId,\n matchId: input.matchId,\n finalScore: {team1, team2},\n }));\n }\n\n return ended;\n }\n\n public async delete(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<TournamentConfigOutputDTO> {\n const result = await this.repository.deleteMatch(tournamentId, matchId);\n if (!result) throw notFoundError('Tournament not found');\n\n return result as TournamentConfigOutputDTO;\n }\n}\n\nexport const matchService = Container.get(MatchService);\n"]}
1
+ {"version":3,"file":"match.service.js","sourceRoot":"/","sources":["modules/tournament/match/match.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,4EAAyF;AACzF,8DAAgE;AAOhE,yDAA6D;AAC7D,mDAA6C;AAG7C,oFAAuG;AACvG,0DAA2C;AAGpC,IAAM,YAAY,GAAlB,MAAM,YAAY;IACb,UAAU,CAA4B;IAE9C;QACI,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,4CAAyB,CAAC,CAAC;IAC/D,CAAC;IAEO,KAAK,CAAC,aAAa,CAAC,YAAqC;QAC7D,MAAM,UAAU,GA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M,CAAC,CAAC;QAErF,MAAM,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;QAEhE,OAAO,KAAK,CAAC;IACjB,CAAC;IAEM,KAAK,CAAC,kBAAkB,CAC3B,YAAqC,EACrC,WAAmD;QAEnD,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,UAAU,EAA0C,EAAE,CAAC,UAAU,KAAK,IAAI,CAAC,CAAC;QAChH,IAAI,CAAC,OAAO,CAAC,MAAM;YAAE,OAAO;QAC5B,MAAM,IAAA,oBAAY,EAAC,IAAI,qDAAwB,CAAC,EAAC,YAAY,EAAE,OAAO,EAAC,CAAC,CAAC,CAAC;IAC9E,CAAC;IAED,cAAc,CAAC,GAA4B;QACvC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC/C,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,YAAqC,EAAE,OAAgC;QACvF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACxE,IAAI,CAAC,MAAM;YAAE,MAAM,IAAA,4BAAa,EAAC,sBAAsB,CAAC,CAAC;QAEzD,OAAO,MAAmC,CAAC;IAC/C,CAAC;CACJ,CAAA;AAtGY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,gBAAO,GAAE;;GACG,YAAY,CAsGxB;AAEY,QAAA,YAAY,GAAG,gBAAS,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {badRequestError, notFoundError} from '@lyxa.ai/core/dist/utilities/error-common';\nimport {publishEvent} from '@lyxa.ai/core/dist/libraries/event';\nimport {\n AddTournamentMatchesInputDTO,\n EndTournamentMatchInputDTO,\n StartTournamentMatchInputDTO,\n TournamentMatchOutputDTO,\n} from './match.validation';\nimport {TournamentMatchRepository} from './match.repository';\nimport {MatchBuilder} from './match.builder';\nimport {TournamentConfigOutputDTO} from '../config/config.validation';\nimport {Tournament as TournamentType} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {EvaluatePredictionsEvent, EvaluatePredictionsMatch} from './events/evaluate-predictions.event';\nimport {utcNow} from '../tournament.utils';\n\n@Service()\nexport class MatchService {\n private repository: TournamentMatchRepository;\n\n constructor() {\n this.repository = Container.get(TournamentMatchRepository);\n }\n\n private async getTournament(tournamentId: mongoose.Types.ObjectId) {\n const tournament = await this.repository.findById(tournamentId);\n if (!tournament) throw notFoundError('Tournament not found');\n return tournament;\n }\n\n private getMatch(tournament: {matches: TournamentMatchOutputDTO[]}, matchId: mongoose.Types.ObjectId) {\n const matchIndex = tournament.matches.findIndex(m => m._id.toString() === matchId.toString());\n const match = tournament.matches[matchIndex]\n if (!match) throw notFoundError('Match not found');\n return {...match, matchNumber: matchIndex + 1};\n }\n\n private resolveMatchTeams(tournament: TournamentType, team1Id: mongoose.Types.ObjectId, team2Id: mongoose.Types.ObjectId) {\n const teamsById = new Map(tournament.teams.map(team => [team._id.toString(), team]));\n const team1 = teamsById.get(team1Id.toString());\n const team2 = teamsById.get(team2Id.toString());\n if (!team1 || !team2) throw badRequestError('All match teams must exist in the tournament');\n return {team1, team2};\n }\n\n private async applyMatchUpdate<T extends object>(\n tournamentId: mongoose.Types.ObjectId,\n matchId: mongoose.Types.ObjectId,\n updates: T\n ): Promise<TournamentMatchOutputDTO> {\n const result = await this.repository.updateMatch(tournamentId, matchId, updates);\n if (!result) throw notFoundError('Tournament not found');\n const updated = result.matches.find(m => m._id.toString() === matchId.toString());\n if (!updated) throw notFoundError('Match not found');\n return updated as TournamentMatchOutputDTO;\n }\n\n public async add(input: AddTournamentMatchesInputDTO): Promise<TournamentConfigOutputDTO> {\n const tournament = await this.getTournament(input.tournamentId);\n\n const matches = input.matches.map(match => {\n const {team1, team2} = this.resolveMatchTeams(tournament, match.team1Id, match.team2Id);\n return MatchBuilder.buildMatch(match, team1, team2);\n });\n\n const result = await this.repository.addMatches(input.tournamentId, matches);\n if (!result) throw notFoundError('Tournament not found');\n\n return result as TournamentConfigOutputDTO;\n }\n\n public async getAll(tournamentId: mongoose.Types.ObjectId): Promise<TournamentMatchOutputDTO[]> {\n const tournament = await this.getTournament(tournamentId);\n return tournament.matches as TournamentMatchOutputDTO[];\n }\n\n public async start(input: StartTournamentMatchInputDTO): Promise<TournamentMatchOutputDTO> {\n const tournament = await this.getTournament(input.tournamentId);\n const match = this.getMatch(tournament, input.matchId);\n\n if (!match.startingDate || match.startingDate > utcNow()) throw badRequestError('This match has not started yet');\n if (match.endDate) throw badRequestError('This match has already ended');\n return match;\n }\n\n public async end(input: EndTournamentMatchInputDTO): Promise<TournamentMatchOutputDTO> {\n const tournament = await this.getTournament(input.tournamentId);\n const match = this.getMatch(tournament, input.matchId);\n\n if (!match.startingDate || match.startingDate > utcNow()) throw badRequestError('This match has not started yet');\n if (match.endDate) throw badRequestError('This match has already ended');\n\n const {update, evaluation} = MatchBuilder.buildEnd(match, match.matchNumber, input.finalScore);\n const ended = await this.applyMatchUpdate(input.tournamentId, input.matchId, update);\n\n await this.publishEvaluations(input.tournamentId, [evaluation]);\n\n return ended;\n }\n\n public async publishEvaluations(\n tournamentId: mongoose.Types.ObjectId,\n evaluations: Array<EvaluatePredictionsMatch | null>\n ): Promise<void> {\n const matches = evaluations.filter((evaluation): evaluation is EvaluatePredictionsMatch => evaluation !== null);\n if (!matches.length) return;\n await publishEvent(new EvaluatePredictionsEvent({tournamentId, matches}));\n }\n\n getMatchNumber(_id: mongoose.Types.ObjectId) {\n throw new Error('Method not implemented.');\n }\n\n public async delete(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<TournamentConfigOutputDTO> {\n const result = await this.repository.deleteMatch(tournamentId, matchId);\n if (!result) throw notFoundError('Tournament not found');\n\n return result as TournamentConfigOutputDTO;\n }\n}\n\nexport const matchService = Container.get(MatchService);\n"]}
@@ -0,0 +1,51 @@
1
+ import { mongoose } from '@typegoose/typegoose';
2
+ import { TournamentMatchStatus } from '@lyxa.ai/core/dist/utilities/enum';
3
+ export interface MatchTeamRef {
4
+ _id: mongoose.Types.ObjectId;
5
+ name: string;
6
+ }
7
+ export interface MatchInput {
8
+ stage: string;
9
+ additionalTag?: string;
10
+ startingDate: Date;
11
+ endDate?: Date;
12
+ }
13
+ export interface MatchScore {
14
+ team1: number | null;
15
+ team2: number | null;
16
+ }
17
+ export interface BuiltMatch {
18
+ _id: mongoose.Types.ObjectId;
19
+ additionalTag?: string;
20
+ stage: string;
21
+ team1: {
22
+ teamId: mongoose.Types.ObjectId;
23
+ name: string;
24
+ };
25
+ team2: {
26
+ teamId: mongoose.Types.ObjectId;
27
+ name: string;
28
+ };
29
+ score: MatchScore;
30
+ winnerId: mongoose.Types.ObjectId | null;
31
+ startingDate: Date;
32
+ endDate?: Date;
33
+ }
34
+ export interface MatchScoreUpdate {
35
+ score: {
36
+ team1: number;
37
+ team2: number;
38
+ };
39
+ winnerId?: mongoose.Types.ObjectId;
40
+ }
41
+ export interface MatchEndUpdate {
42
+ endDate: Date;
43
+ matchEnded: true;
44
+ matchStatus: TournamentMatchStatus;
45
+ winnerId: mongoose.Types.ObjectId | null;
46
+ score?: {
47
+ team1: number;
48
+ team2: number;
49
+ };
50
+ }
51
+ //# sourceMappingURL=match.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"match.types.d.ts","sourceRoot":"/","sources":["modules/tournament/match/match.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,qBAAqB,EAAC,MAAM,mCAAmC,CAAC;AAExE,MAAM,WAAW,YAAY;IACzB,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACvB,KAAK,EAAE,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,CAAA;KAAC,CAAC;CAC1C"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=match.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"match.types.js","sourceRoot":"/","sources":["modules/tournament/match/match.types.ts"],"names":[],"mappings":"","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\nimport {TournamentMatchStatus} from '@lyxa.ai/core/dist/utilities/enum';\n\nexport interface MatchTeamRef {\n _id: mongoose.Types.ObjectId;\n name: string;\n}\n\nexport interface MatchInput {\n stage: string;\n additionalTag?: string;\n startingDate: Date;\n endDate?: Date;\n}\n\nexport interface MatchScore {\n team1: number | null;\n team2: number | null;\n}\n\nexport interface BuiltMatch {\n _id: mongoose.Types.ObjectId;\n additionalTag?: string;\n stage: string;\n team1: {teamId: mongoose.Types.ObjectId; name: string};\n team2: {teamId: mongoose.Types.ObjectId; name: string};\n score: MatchScore;\n winnerId: mongoose.Types.ObjectId | null;\n startingDate: Date;\n endDate?: Date;\n}\n\nexport interface MatchScoreUpdate {\n score: {team1: number; team2: number};\n winnerId?: mongoose.Types.ObjectId;\n}\n\nexport interface MatchEndUpdate {\n endDate: Date;\n matchEnded: true;\n matchStatus: TournamentMatchStatus;\n winnerId: mongoose.Types.ObjectId | null;\n score?: {team1: number; team2: number};\n}\n"]}
@@ -1,8 +1,9 @@
1
1
  import { mongoose } from '@typegoose/typegoose';
2
2
  import { NotificationMessage } from '@lyxa.ai/core/dist/libraries/mongo/models';
3
+ import { TournamentNotificationTag } from '@lyxa.ai/core/dist/utilities/enum';
3
4
  export declare class NotificationTemplateRepository {
4
5
  private model;
5
- findTemplates(tournamentId: mongoose.Types.ObjectId): Promise<Map<string, NotificationMessage>>;
6
+ findTemplates(tournamentId: mongoose.Types.ObjectId): Promise<Map<TournamentNotificationTag, NotificationMessage>>;
6
7
  }
7
8
  export declare const notificationTemplateRepository: NotificationTemplateRepository;
8
9
  //# sourceMappingURL=notification-template.repository.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notification-template.repository.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification-template.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAmB,MAAM,2CAA2C,CAAC;AAEjG,qBACa,8BAA8B;IACvC,OAAO,CAAC,KAAK,CAAmB;IAEnB,aAAa,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;CAM/G;AAED,eAAO,MAAM,8BAA8B,gCAAgD,CAAC"}
1
+ {"version":3,"file":"notification-template.repository.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification-template.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAmB,MAAM,2CAA2C,CAAC;AACjG,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,qBACa,8BAA8B;IACvC,OAAO,CAAC,KAAK,CAAmB;IAEnB,aAAa,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAyB,EAAE,mBAAmB,CAAC,CAAC;CAOlI;AAED,eAAO,MAAM,8BAA8B,gCAAgD,CAAC"}
@@ -49,7 +49,8 @@ let NotificationTemplateRepository = class NotificationTemplateRepository {
49
49
  if (!doc)
50
50
  throw new Error(`Tournament not found: ${tournamentId}`);
51
51
  const raw = doc.notificationTemplates;
52
- return new Map(Object.entries(raw ?? {}));
52
+ const entries = Object.entries(raw ?? {});
53
+ return new Map(entries);
53
54
  }
54
55
  };
55
56
  exports.NotificationTemplateRepository = NotificationTemplateRepository;
@@ -1 +1 @@
1
- {"version":3,"file":"notification-template.repository.js","sourceRoot":"/","sources":["modules/tournament/notification/notification-template.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,sEAAiG;AAG1F,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAC/B,KAAK,GAAG,wBAAe,CAAC;IAEzB,KAAK,CAAC,aAAa,CAAC,YAAqC;QAC5D,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,EAAE,EAAE,qBAAqB,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACzF,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,YAAY,EAAE,CAAC,CAAC;QACnE,MAAM,GAAG,GAAG,GAAG,CAAC,qBAAwE,CAAC;QACzF,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC;IAC9C,CAAC;CACJ,CAAA;AATY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,gBAAO,GAAE;GACG,8BAA8B,CAS1C;AAEY,QAAA,8BAA8B,GAAG,gBAAS,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport { NotificationMessage, TournamentModel } from '@lyxa.ai/core/dist/libraries/mongo/models';\n\n@Service()\nexport class NotificationTemplateRepository {\n private model = TournamentModel;\n\n public async findTemplates(tournamentId: mongoose.Types.ObjectId): Promise<Map<string, NotificationMessage>> {\n const doc = await this.model.findById(tournamentId, { notificationTemplates: 1 }).lean();\n if (!doc) throw new Error(`Tournament not found: ${tournamentId}`);\n const raw = doc.notificationTemplates as Record<string, NotificationMessage> | undefined;\n return new Map(Object.entries(raw ?? {}));\n }\n}\n\nexport const notificationTemplateRepository = Container.get(NotificationTemplateRepository);\n"]}
1
+ {"version":3,"file":"notification-template.repository.js","sourceRoot":"/","sources":["modules/tournament/notification/notification-template.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,sEAAiG;AAI1F,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAC/B,KAAK,GAAG,wBAAe,CAAC;IAEzB,KAAK,CAAC,aAAa,CAAC,YAAqC;QAC5D,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,EAAE,EAAE,qBAAqB,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACzF,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,YAAY,EAAE,CAAC,CAAC;QACnE,MAAM,GAAG,GAAG,GAAG,CAAC,qBAA2F,CAAC;QAC5G,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,EAAE,CAAuD,CAAC;QAChG,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;CACJ,CAAA;AAVY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,gBAAO,GAAE;GACG,8BAA8B,CAU1C;AAEY,QAAA,8BAA8B,GAAG,gBAAS,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport { NotificationMessage, TournamentModel } from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport { TournamentNotificationTag } from '@lyxa.ai/core/dist/utilities/enum';\n\n@Service()\nexport class NotificationTemplateRepository {\n private model = TournamentModel;\n\n public async findTemplates(tournamentId: mongoose.Types.ObjectId): Promise<Map<TournamentNotificationTag, NotificationMessage>> {\n const doc = await this.model.findById(tournamentId, { notificationTemplates: 1 }).lean();\n if (!doc) throw new Error(`Tournament not found: ${tournamentId}`);\n const raw = doc.notificationTemplates as Record<TournamentNotificationTag, NotificationMessage> | undefined;\n const entries = Object.entries(raw ?? {}) as [TournamentNotificationTag, NotificationMessage][];\n return new Map(entries);\n }\n}\n\nexport const notificationTemplateRepository = Container.get(NotificationTemplateRepository);\n"]}
@@ -0,0 +1,30 @@
1
+ import { mongoose } from '@typegoose/typegoose';
2
+ import { ClickType, NotificationAccountType } from '@lyxa.ai/core/dist/utilities/enum';
3
+ export interface NotificationBody {
4
+ title: string;
5
+ body: string;
6
+ }
7
+ export interface DirectNotificationPayload extends NotificationBody {
8
+ data: {
9
+ saveNotification: boolean;
10
+ accountType: NotificationAccountType;
11
+ recipientId: mongoose.Types.ObjectId;
12
+ isGlobal: boolean;
13
+ isClickable: boolean;
14
+ clickType: ClickType;
15
+ };
16
+ }
17
+ export interface GlobalNotificationPayload extends NotificationBody {
18
+ data: {
19
+ saveNotification: boolean;
20
+ accountType: NotificationAccountType;
21
+ isGlobal: boolean;
22
+ isClickable: boolean;
23
+ clickType: ClickType;
24
+ };
25
+ }
26
+ export declare class NotificationPayloadBuilder {
27
+ static buildGlobal(content: NotificationBody): GlobalNotificationPayload;
28
+ static buildForUser(content: NotificationBody, recipientId: mongoose.Types.ObjectId): DirectNotificationPayload;
29
+ }
30
+ //# sourceMappingURL=notification.builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification.builder.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,SAAS,EAAE,uBAAuB,EAAC,MAAM,mCAAmC,CAAC;AAErF,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,yBAA0B,SAAQ,gBAAgB;IAC/D,IAAI,EAAE;QACF,gBAAgB,EAAE,OAAO,CAAC;QAC1B,WAAW,EAAE,uBAAuB,CAAC;QACrC,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;QACrC,QAAQ,EAAE,OAAO,CAAC;QAClB,WAAW,EAAE,OAAO,CAAC;QACrB,SAAS,EAAE,SAAS,CAAC;KACxB,CAAC;CACL;AAED,MAAM,WAAW,yBAA0B,SAAQ,gBAAgB;IAC/D,IAAI,EAAE;QACF,gBAAgB,EAAE,OAAO,CAAC;QAC1B,WAAW,EAAE,uBAAuB,CAAC;QACrC,QAAQ,EAAE,OAAO,CAAC;QAClB,WAAW,EAAE,OAAO,CAAC;QACrB,SAAS,EAAE,SAAS,CAAC;KACxB,CAAC;CACL;AAED,qBAAa,0BAA0B;IACnC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,yBAAyB;IAcxE,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,yBAAyB;CAclH"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotificationPayloadBuilder = void 0;
4
+ const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
5
+ class NotificationPayloadBuilder {
6
+ static buildGlobal(content) {
7
+ return {
8
+ title: content.title,
9
+ body: content.body,
10
+ data: {
11
+ saveNotification: true,
12
+ accountType: enum_1.NotificationAccountType.USER,
13
+ isGlobal: true,
14
+ isClickable: true,
15
+ clickType: enum_1.ClickType.CLICKABLE_FALLBACK,
16
+ },
17
+ };
18
+ }
19
+ static buildForUser(content, recipientId) {
20
+ return {
21
+ title: content.title,
22
+ body: content.body,
23
+ data: {
24
+ saveNotification: true,
25
+ accountType: enum_1.NotificationAccountType.USER,
26
+ recipientId,
27
+ isGlobal: false,
28
+ isClickable: true,
29
+ clickType: enum_1.ClickType.CLICKABLE_FALLBACK,
30
+ },
31
+ };
32
+ }
33
+ }
34
+ exports.NotificationPayloadBuilder = NotificationPayloadBuilder;
35
+ //# sourceMappingURL=notification.builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification.builder.js","sourceRoot":"/","sources":["modules/tournament/notification/notification.builder.ts"],"names":[],"mappings":";;;AACA,4DAAqF;AA4BrF,MAAa,0BAA0B;IACnC,MAAM,CAAC,WAAW,CAAC,OAAyB;QACxC,OAAO;YACH,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,IAAI,EAAE;gBACF,gBAAgB,EAAE,IAAI;gBACtB,WAAW,EAAE,8BAAuB,CAAC,IAAI;gBACzC,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,IAAI;gBACjB,SAAS,EAAE,gBAAS,CAAC,kBAAkB;aAC1C;SACJ,CAAC;IACN,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,OAAyB,EAAE,WAAoC;QAC/E,OAAO;YACH,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,IAAI,EAAE;gBACF,gBAAgB,EAAE,IAAI;gBACtB,WAAW,EAAE,8BAAuB,CAAC,IAAI;gBACzC,WAAW;gBACX,QAAQ,EAAE,KAAK;gBACf,WAAW,EAAE,IAAI;gBACjB,SAAS,EAAE,gBAAS,CAAC,kBAAkB;aAC1C;SACJ,CAAC;IACN,CAAC;CACJ;AA7BD,gEA6BC","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\nimport {ClickType, NotificationAccountType} from '@lyxa.ai/core/dist/utilities/enum';\n\nexport interface NotificationBody {\n title: string;\n body: string;\n}\n\nexport interface DirectNotificationPayload extends NotificationBody {\n data: {\n saveNotification: boolean;\n accountType: NotificationAccountType;\n recipientId: mongoose.Types.ObjectId;\n isGlobal: boolean;\n isClickable: boolean;\n clickType: ClickType;\n };\n}\n\nexport interface GlobalNotificationPayload extends NotificationBody {\n data: {\n saveNotification: boolean;\n accountType: NotificationAccountType;\n isGlobal: boolean;\n isClickable: boolean;\n clickType: ClickType;\n };\n}\n\nexport class NotificationPayloadBuilder {\n static buildGlobal(content: NotificationBody): GlobalNotificationPayload {\n return {\n title: content.title,\n body: content.body,\n data: {\n saveNotification: true,\n accountType: NotificationAccountType.USER,\n isGlobal: true,\n isClickable: true,\n clickType: ClickType.CLICKABLE_FALLBACK,\n },\n };\n }\n\n static buildForUser(content: NotificationBody, recipientId: mongoose.Types.ObjectId): DirectNotificationPayload {\n return {\n title: content.title,\n body: content.body,\n data: {\n saveNotification: true,\n accountType: NotificationAccountType.USER,\n recipientId,\n isGlobal: false,\n isClickable: true,\n clickType: ClickType.CLICKABLE_FALLBACK,\n },\n };\n }\n}\n"]}
@@ -1,10 +1,11 @@
1
- export declare enum NotificationTag {
2
- TOURNAMENT_ACTIVATION = "tournament-activation",
3
- MATCH_RESULT_WINNER = "match-result-winner",
4
- MATCH_RESULT_LOSER = "match-result-loser"
5
- }
6
- export declare enum ScheduledTarget {
7
- GLOBAL = "global",
8
- UNPREDICTED_PARTICIPANTS = "unpredicted-participants"
9
- }
1
+ import { TournamentNotificationTag } from "@lyxa.ai/core/dist/utilities/enum";
2
+ export type NotificationObject = {
3
+ title: string;
4
+ body: string;
5
+ tournamentNotificationType: TournamentNotificationTag;
6
+ tournamentId: string;
7
+ deepLinkRoute?: string;
8
+ matchId?: string;
9
+ [key: string]: any;
10
+ };
10
11
  //# sourceMappingURL=notification.config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notification.config.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification.config.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IACvB,qBAAqB,0BAA0B;IAC/C,mBAAmB,wBAAwB;IAC3C,kBAAkB,uBAAuB;CAC5C;AAED,oBAAY,eAAe;IACvB,MAAM,WAAW;IACjB,wBAAwB,6BAA6B;CACxD"}
1
+ {"version":3,"file":"notification.config.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,MAAM,MAAM,kBAAkB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B,EAAE,yBAAyB,CAAC;IACtD,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB,CAAC"}
@@ -1,15 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ScheduledTarget = exports.NotificationTag = void 0;
4
- var NotificationTag;
5
- (function (NotificationTag) {
6
- NotificationTag["TOURNAMENT_ACTIVATION"] = "tournament-activation";
7
- NotificationTag["MATCH_RESULT_WINNER"] = "match-result-winner";
8
- NotificationTag["MATCH_RESULT_LOSER"] = "match-result-loser";
9
- })(NotificationTag || (exports.NotificationTag = NotificationTag = {}));
10
- var ScheduledTarget;
11
- (function (ScheduledTarget) {
12
- ScheduledTarget["GLOBAL"] = "global";
13
- ScheduledTarget["UNPREDICTED_PARTICIPANTS"] = "unpredicted-participants";
14
- })(ScheduledTarget || (exports.ScheduledTarget = ScheduledTarget = {}));
15
3
  //# sourceMappingURL=notification.config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"notification.config.js","sourceRoot":"/","sources":["modules/tournament/notification/notification.config.ts"],"names":[],"mappings":";;;AAAA,IAAY,eAIX;AAJD,WAAY,eAAe;IACvB,kEAA+C,CAAA;IAC/C,8DAA2C,CAAA;IAC3C,4DAAyC,CAAA;AAC7C,CAAC,EAJW,eAAe,+BAAf,eAAe,QAI1B;AAED,IAAY,eAGX;AAHD,WAAY,eAAe;IACvB,oCAAiB,CAAA;IACjB,wEAAqD,CAAA;AACzD,CAAC,EAHW,eAAe,+BAAf,eAAe,QAG1B","sourcesContent":["export enum NotificationTag {\n TOURNAMENT_ACTIVATION = 'tournament-activation',\n MATCH_RESULT_WINNER = 'match-result-winner',\n MATCH_RESULT_LOSER = 'match-result-loser',\n}\n\nexport enum ScheduledTarget {\n GLOBAL = 'global',\n UNPREDICTED_PARTICIPANTS = 'unpredicted-participants',\n}\n"]}
1
+ {"version":3,"file":"notification.config.js","sourceRoot":"/","sources":["modules/tournament/notification/notification.config.ts"],"names":[],"mappings":"","sourcesContent":["import { TournamentNotificationTag } from \"@lyxa.ai/core/dist/utilities/enum\";\n\nexport type NotificationObject = {\n title: string;\n body: string;\n tournamentNotificationType: TournamentNotificationTag;\n tournamentId: string;\n deepLinkRoute?: string;\n matchId?: string;\n [key: string]: any; // For any additional data that might be needed in the future\n};"]}
@@ -1,13 +1,15 @@
1
1
  import { mongoose } from '@typegoose/typegoose';
2
+ import { TournamentNotificationTag, TournamentScheduledNotificationTarget } from '@lyxa.ai/core/dist/utilities/enum';
2
3
  import { NotificationMessage } from '@lyxa.ai/core/dist/libraries/mongo/models';
4
+ import { NotificationObject } from './notification.config';
3
5
  export declare class TournamentNotificationService {
4
6
  private participantService;
5
7
  constructor();
6
8
  private getTemplate;
7
9
  private hasNotPredicted;
8
- notifyGlobal(title: string, body: string): Promise<void>;
9
- notifyUsers(title: string, body: string, userIds: mongoose.Types.ObjectId[]): Promise<void>;
10
- dispatchScheduledJob(type: string, target: string, templates: Map<string, NotificationMessage>, tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<void>;
10
+ notifyGlobal(notification: NotificationObject): Promise<void>;
11
+ notifyUsers(notification: NotificationObject, userIds: mongoose.Types.ObjectId[]): Promise<void>;
12
+ dispatchScheduledJob(type: TournamentNotificationTag, target: TournamentScheduledNotificationTarget, templates: Map<TournamentNotificationTag, NotificationMessage>, tournamentId: mongoose.Types.ObjectId, teamIds: mongoose.Types.ObjectId[], matchId: mongoose.Types.ObjectId, matchStartTime: Date, deepLinkRoute?: string): Promise<void>;
11
13
  }
12
14
  export declare const tournamentNotificationService: TournamentNotificationService;
13
15
  //# sourceMappingURL=notification.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notification.service.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAI9C,OAAO,EAAC,mBAAmB,EAAC,MAAM,2CAA2C,CAAC;AAK9E,qBACa,6BAA6B;IACtC,OAAO,CAAC,kBAAkB,CAAqB;;IAM/C,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,eAAe;IAIV,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBxD,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAqB3F,oBAAoB,CAC7B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAC3C,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GACjC,OAAO,CAAC,IAAI,CAAC;CAWnB;AAED,eAAO,MAAM,6BAA6B,+BAA+C,CAAC"}
1
+ {"version":3,"file":"notification.service.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAG9C,OAAO,EAGH,yBAAyB,EACzB,qCAAqC,EACxC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAC,mBAAmB,EAAC,MAAM,2CAA2C,CAAC;AAG9E,OAAO,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAC;AAEzD,qBACa,6BAA6B;IACtC,OAAO,CAAC,kBAAkB,CAAqB;;IAM/C,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,eAAe;IAIV,YAAY,CAAC,YAAY,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB7D,WAAW,CAAC,YAAY,EAAE,kBAAkB,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBhG,oBAAoB,CAC7B,IAAI,EAAE,yBAAyB,EAC/B,MAAM,EAAE,qCAAqC,EAC7C,SAAS,EAAE,GAAG,CAAC,yBAAyB,EAAE,mBAAmB,CAAC,EAC9D,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,EAClC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAChC,cAAc,EAAE,IAAI,EACpB,aAAa,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,IAAI,CAAC;CAqBnB;AAED,eAAO,MAAM,6BAA6B,+BAA+C,CAAC"}
@@ -48,7 +48,6 @@ const event_1 = require("@lyxa.ai/core/dist/libraries/event");
48
48
  const notification_1 = require("@lyxa.ai/core/dist/libraries/notification");
49
49
  const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
50
50
  const participant_service_1 = require("../participant/participant.service");
51
- const notification_config_1 = require("./notification.config");
52
51
  let TournamentNotificationService = class TournamentNotificationService {
53
52
  participantService;
54
53
  constructor() {
@@ -63,42 +62,51 @@ let TournamentNotificationService = class TournamentNotificationService {
63
62
  hasNotPredicted(participant, matchId) {
64
63
  return !participant.predictions.some(p => p.matchId.toString() === matchId.toString());
65
64
  }
66
- async notifyGlobal(title, body) {
65
+ async notifyGlobal(notification) {
67
66
  await (0, event_1.publishEvent)(new notification_1.NotificationGlobalEvent({
68
- title,
69
- body,
67
+ title: notification.title,
68
+ body: notification.body,
70
69
  data: {
71
70
  saveNotification: true,
72
71
  accountType: enum_1.NotificationAccountType.USER,
73
72
  isGlobal: true,
74
73
  isClickable: true,
75
- clickType: enum_1.ClickType.CLICKABLE_FALLBACK,
74
+ clickType: enum_1.ClickType.CLICKABLE_TOURNAMENT,
75
+ ...notification,
76
76
  },
77
77
  }));
78
78
  }
79
- async notifyUsers(title, body, userIds) {
79
+ async notifyUsers(notification, userIds) {
80
80
  await Promise.all(userIds.map(recipientId => (0, event_1.publishEvent)(new notification_1.NotificationEvent({
81
- title,
82
- body,
81
+ title: notification.title,
82
+ body: notification.body,
83
83
  data: {
84
84
  saveNotification: true,
85
85
  accountType: enum_1.NotificationAccountType.USER,
86
86
  recipientId,
87
87
  isGlobal: false,
88
88
  isClickable: true,
89
- clickType: enum_1.ClickType.CLICKABLE_FALLBACK,
89
+ clickType: enum_1.ClickType.CLICKABLE_TOURNAMENT,
90
+ ...notification,
90
91
  },
91
92
  }))));
92
93
  }
93
- async dispatchScheduledJob(type, target, templates, tournamentId, matchId) {
94
+ async dispatchScheduledJob(type, target, templates, tournamentId, teamIds, matchId, matchStartTime, deepLinkRoute) {
94
95
  const { title, body } = this.getTemplate(templates, type);
95
- if (target === notification_config_1.ScheduledTarget.GLOBAL) {
96
- await this.notifyGlobal(title, body);
96
+ if (target === enum_1.TournamentScheduledNotificationTarget.GLOBAL) {
97
+ await this.notifyGlobal({ title, body, tournamentNotificationType: type, tournamentId: tournamentId.toString(), deepLinkRoute });
97
98
  }
98
99
  else {
99
- const participants = await this.participantService.getAll(tournamentId);
100
- const unpredicted = participants.filter(p => this.hasNotPredicted(p, matchId));
101
- await this.notifyUsers(title, body, unpredicted.map(p => p.userId));
100
+ const unpredicted = await this.participantService.getUnpredicted(tournamentId, teamIds, matchId);
101
+ await this.notifyUsers({
102
+ title,
103
+ body,
104
+ tournamentNotificationType: type,
105
+ predictionExpiryTime: matchStartTime,
106
+ matchId: matchId.toString(),
107
+ tournamentId: tournamentId.toString(),
108
+ deepLinkRoute,
109
+ }, unpredicted.map(p => p.userId));
102
110
  }
103
111
  }
104
112
  };
@@ -1 +1 @@
1
- {"version":3,"file":"notification.service.js","sourceRoot":"/","sources":["modules/tournament/notification/notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,8DAAgE;AAChE,4EAAqG;AACrG,4DAAqF;AAErF,4EAAsE;AAEtE,+DAAsD;AAG/C,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IAC9B,kBAAkB,CAAqB;IAE/C;QACI,IAAI,CAAC,kBAAkB,GAAG,gBAAS,CAAC,GAAG,CAAC,wCAAkB,CAAC,CAAC;IAChE,CAAC;IAEO,WAAW,CAAC,SAA2C,EAAE,GAAW;QACxE,MAAM,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,CAAC,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,GAAG,EAAE,CAAC,CAAC;QACpE,OAAO,CAAC,CAAC;IACb,CAAC;IAEO,eAAe,CAAC,WAA2C,EAAE,OAAgC;QACjG,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC3F,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,KAAa,EAAE,IAAY;QACjD,MAAM,IAAA,oBAAY,EACd,IAAI,sCAAuB,CAAC;YACxB,KAAK;YACL,IAAI;YACJ,IAAI,EAAE;gBACF,gBAAgB,EAAE,IAAI;gBACtB,WAAW,EAAE,8BAAuB,CAAC,IAAI;gBACzC,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,IAAI;gBACjB,SAAS,EAAE,gBAAS,CAAC,kBAAkB;aAC1C;SACJ,CAAC,CACL,CAAC;IACN,CAAC;IAEM,KAAK,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;GACG,6BAA6B,CAuEzC;AAEY,QAAA,6BAA6B,GAAG,gBAAS,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {publishEvent} from '@lyxa.ai/core/dist/libraries/event';\nimport {NotificationEvent, NotificationGlobalEvent} from '@lyxa.ai/core/dist/libraries/notification';\nimport {ClickType, NotificationAccountType} from '@lyxa.ai/core/dist/utilities/enum';\nimport {NotificationMessage} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {ParticipantService} from '../participant/participant.service';\nimport {TournamentParticipantOutputDTO} from '../participant/participant.validation';\nimport {ScheduledTarget} from './notification.config';\n\n@Service()\nexport class TournamentNotificationService {\n private participantService: ParticipantService;\n\n constructor() {\n this.participantService = Container.get(ParticipantService);\n }\n\n private getTemplate(templates: Map<string, NotificationMessage>, tag: string): NotificationMessage {\n const t = templates.get(tag);\n if (!t) throw new Error(`No notification template for tag: ${tag}`);\n return t;\n }\n\n private hasNotPredicted(participant: TournamentParticipantOutputDTO, matchId: mongoose.Types.ObjectId): boolean {\n return !participant.predictions.some(p => p.matchId.toString() === matchId.toString());\n }\n\n public async notifyGlobal(title: string, body: string): Promise<void> {\n await publishEvent(\n new NotificationGlobalEvent({\n title,\n body,\n data: {\n saveNotification: true,\n accountType: NotificationAccountType.USER,\n isGlobal: true,\n isClickable: true,\n clickType: ClickType.CLICKABLE_FALLBACK,\n },\n })\n );\n }\n\n public async notifyUsers(title: string, body: string, userIds: mongoose.Types.ObjectId[]): Promise<void> {\n await Promise.all(\n userIds.map(recipientId =>\n publishEvent(\n new NotificationEvent({\n title,\n body,\n data: {\n saveNotification: true,\n accountType: NotificationAccountType.USER,\n recipientId,\n isGlobal: false,\n isClickable: true,\n clickType: ClickType.CLICKABLE_FALLBACK,\n },\n })\n )\n )\n );\n }\n\n public async dispatchScheduledJob(\n type: string,\n target: string,\n templates: Map<string, NotificationMessage>,\n tournamentId: mongoose.Types.ObjectId,\n matchId: mongoose.Types.ObjectId\n ): Promise<void> {\n const {title, body} = this.getTemplate(templates, type);\n\n if (target === ScheduledTarget.GLOBAL) {\n await this.notifyGlobal(title, body);\n } else {\n const participants = await this.participantService.getAll(tournamentId);\n const unpredicted = participants.filter(p => this.hasNotPredicted(p, matchId));\n await this.notifyUsers(title, body, unpredicted.map(p => p.userId));\n }\n }\n}\n\nexport const tournamentNotificationService = Container.get(TournamentNotificationService);\n"]}
1
+ {"version":3,"file":"notification.service.js","sourceRoot":"/","sources":["modules/tournament/notification/notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,8DAAgE;AAChE,4EAAqG;AACrG,4DAK2C;AAE3C,4EAAsE;AAK/D,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IAC9B,kBAAkB,CAAqB;IAE/C;QACI,IAAI,CAAC,kBAAkB,GAAG,gBAAS,CAAC,GAAG,CAAC,wCAAkB,CAAC,CAAC;IAChE,CAAC;IAEO,WAAW,CAAC,SAA2C,EAAE,GAAW;QACxE,MAAM,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,CAAC,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,GAAG,EAAE,CAAC,CAAC;QACpE,OAAO,CAAC,CAAC;IACb,CAAC;IAEO,eAAe,CAAC,WAA2C,EAAE,OAAgC;QACjG,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC3F,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,YAAgC;QACtD,MAAM,IAAA,oBAAY,EACd,IAAI,sCAAuB,CAAC;YACxB,KAAK,EAAE,YAAY,CAAC,KAAK;YACzB,IAA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C;aAAM,CAAC;YACJ,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YACjG,MAAM,IAAI,CAAC,WAAW,CAClB;gBACI,KAAK;gBACL,IAAI;gBACJ,0BAA0B,EAAE,IAAI;gBAChC,oBAAoB,EAAE,cAAc;gBACpC,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE;gBAC3B,YAAY,EAAE,YAAY,CAAC,QAAQ,EAAE;gBACrC,aAAa;aAChB,EACD,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CACjC,CAAC;QACN,CAAC;IACL,CAAC;CACJ,CAAA;AAtFY,sEAA6B;wCAA7B,6BAA6B;IADzC,IAAA,gBAAO,GAAE;;GACG,6BAA6B,CAsFzC;AAEY,QAAA,6BAA6B,GAAG,gBAAS,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {publishEvent} from '@lyxa.ai/core/dist/libraries/event';\nimport {NotificationEvent, NotificationGlobalEvent} from '@lyxa.ai/core/dist/libraries/notification';\nimport {\n ClickType,\n NotificationAccountType,\n TournamentNotificationTag,\n TournamentScheduledNotificationTarget\n} from '@lyxa.ai/core/dist/utilities/enum';\nimport {NotificationMessage} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {ParticipantService} from '../participant/participant.service';\nimport {TournamentParticipantOutputDTO} from '../participant/participant.validation';\nimport {NotificationObject} from './notification.config';\n\n@Service()\nexport class TournamentNotificationService {\n private participantService: ParticipantService;\n\n constructor() {\n this.participantService = Container.get(ParticipantService);\n }\n\n private getTemplate(templates: Map<string, NotificationMessage>, tag: string): NotificationMessage {\n const t = templates.get(tag);\n if (!t) throw new Error(`No notification template for tag: ${tag}`);\n return t;\n }\n\n private hasNotPredicted(participant: TournamentParticipantOutputDTO, matchId: mongoose.Types.ObjectId): boolean {\n return !participant.predictions.some(p => p.matchId.toString() === matchId.toString());\n }\n\n public async notifyGlobal(notification: NotificationObject): Promise<void> {\n await publishEvent(\n new NotificationGlobalEvent({\n title: notification.title,\n body: notification.body,\n data: {\n saveNotification: true,\n accountType: NotificationAccountType.USER,\n isGlobal: true,\n isClickable: true,\n clickType: ClickType.CLICKABLE_TOURNAMENT,\n ...notification,\n },\n })\n );\n }\n\n public async notifyUsers(notification: NotificationObject, userIds: mongoose.Types.ObjectId[]): Promise<void> {\n await Promise.all(\n userIds.map(recipientId =>\n publishEvent(\n new NotificationEvent({\n title: notification.title,\n body: notification.body,\n data: {\n saveNotification: true,\n accountType: NotificationAccountType.USER,\n recipientId,\n isGlobal: false,\n isClickable: true,\n clickType: ClickType.CLICKABLE_TOURNAMENT,\n ...notification,\n },\n })\n )\n )\n );\n }\n\n public async dispatchScheduledJob(\n type: TournamentNotificationTag,\n target: TournamentScheduledNotificationTarget,\n templates: Map<TournamentNotificationTag, NotificationMessage>,\n tournamentId: mongoose.Types.ObjectId,\n teamIds: mongoose.Types.ObjectId[],\n matchId: mongoose.Types.ObjectId,\n matchStartTime: Date,\n deepLinkRoute?: string\n ): Promise<void> {\n const {title, body} = this.getTemplate(templates, type);\n\n if (target === TournamentScheduledNotificationTarget.GLOBAL) {\n await this.notifyGlobal({title, body, tournamentNotificationType: type, tournamentId: tournamentId.toString(), deepLinkRoute});\n } else {\n const unpredicted = await this.participantService.getUnpredicted(tournamentId, teamIds, matchId);\n await this.notifyUsers(\n {\n title,\n body,\n tournamentNotificationType: type,\n predictionExpiryTime: matchStartTime,\n matchId: matchId.toString(),\n tournamentId: tournamentId.toString(),\n deepLinkRoute,\n },\n unpredicted.map(p => p.userId)\n );\n }\n }\n}\n\nexport const tournamentNotificationService = Container.get(TournamentNotificationService);\n"]}
@@ -0,0 +1,12 @@
1
+ import { mongoose } from '@typegoose/typegoose';
2
+ import { TournamentParticipantStatus } from '../tournament.types';
3
+ export declare class ParticipantBuilder {
4
+ static buildNewParticipant(userId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId, teamId: mongoose.Types.ObjectId): {
5
+ userId: mongoose.Types.ObjectId;
6
+ tournamentId: mongoose.Types.ObjectId;
7
+ teamId: mongoose.Types.ObjectId;
8
+ status: TournamentParticipantStatus;
9
+ predictions: never[];
10
+ };
11
+ }
12
+ //# sourceMappingURL=participant.builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"participant.builder.d.ts","sourceRoot":"/","sources":["modules/tournament/participant/participant.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,2BAA2B,EAAC,MAAM,qBAAqB,CAAC;AAEhE,qBAAa,kBAAkB;IAC3B,MAAM,CAAC,mBAAmB,CACtB,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ;;;;;;;CAUtC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ParticipantBuilder = void 0;
4
+ const tournament_types_1 = require("../tournament.types");
5
+ class ParticipantBuilder {
6
+ static buildNewParticipant(userId, tournamentId, teamId) {
7
+ return {
8
+ userId,
9
+ tournamentId,
10
+ teamId,
11
+ status: tournament_types_1.TournamentParticipantStatus.JOINED,
12
+ predictions: [],
13
+ };
14
+ }
15
+ }
16
+ exports.ParticipantBuilder = ParticipantBuilder;
17
+ //# sourceMappingURL=participant.builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"participant.builder.js","sourceRoot":"/","sources":["modules/tournament/participant/participant.builder.ts"],"names":[],"mappings":";;;AACA,0DAAgE;AAEhE,MAAa,kBAAkB;IAC3B,MAAM,CAAC,mBAAmB,CACtB,MAA+B,EAC/B,YAAqC,EACrC,MAA+B;QAE/B,OAAO;YACH,MAAM;YACN,YAAY;YACZ,MAAM;YACN,MAAM,EAAE,8CAA2B,CAAC,MAAM;YAC1C,WAAW,EAAE,EAAE;SAClB,CAAC;IACN,CAAC;CACJ;AAdD,gDAcC","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\nimport {TournamentParticipantStatus} from '../tournament.types';\n\nexport class ParticipantBuilder {\n static buildNewParticipant(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId,\n teamId: mongoose.Types.ObjectId\n ) {\n return {\n userId,\n tournamentId,\n teamId,\n status: TournamentParticipantStatus.JOINED,\n predictions: [],\n };\n }\n}\n"]}
@@ -1,15 +1,16 @@
1
1
  import { mongoose } from '@typegoose/typegoose';
2
- import { TournamentParticipant as ParticipantModelType } from '@lyxa.ai/core/dist/libraries/mongo/models';
2
+ import { TournamentParticipantOutputDTO } from './participant.validation';
3
3
  export declare class TournamentParticipantRepository {
4
4
  private participantModel;
5
5
  constructor();
6
6
  existsByUserAndTournament(userId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId): Promise<boolean>;
7
- create(input: object): Promise<ParticipantModelType>;
8
- findByUserAndTournament(userId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId): Promise<ParticipantModelType | null>;
9
- findByTournament(tournamentId: mongoose.Types.ObjectId): Promise<ParticipantModelType[]>;
10
- findByUser(userId: mongoose.Types.ObjectId): Promise<ParticipantModelType | null>;
11
- updateToJoined(userId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId, teamId: mongoose.Types.ObjectId): Promise<ParticipantModelType | null>;
12
- upsertStatus(userId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId, status: string): Promise<void>;
7
+ create(input: object): Promise<TournamentParticipantOutputDTO>;
8
+ findByUserAndTournament(userId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId): Promise<TournamentParticipantOutputDTO | null>;
9
+ findByTournament(tournamentId: mongoose.Types.ObjectId): Promise<TournamentParticipantOutputDTO[]>;
10
+ findByUser(userId: mongoose.Types.ObjectId): Promise<TournamentParticipantOutputDTO | null>;
11
+ updateToJoined(userId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId, teamId: mongoose.Types.ObjectId): Promise<TournamentParticipantOutputDTO | null>;
12
+ createIfAbsent(userId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId, status: string): Promise<void>;
13
+ findByTournamentWithoutPrediction(tournamentId: mongoose.Types.ObjectId, teamIds: mongoose.Types.ObjectId[], matchId: mongoose.Types.ObjectId): Promise<TournamentParticipantOutputDTO[]>;
13
14
  }
14
15
  export declare const tournamentParticipantRepository: TournamentParticipantRepository;
15
16
  //# sourceMappingURL=participant.repository.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"participant.repository.d.ts","sourceRoot":"/","sources":["modules/tournament/participant/participant.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EACH,qBAAqB,IAAI,oBAAoB,EAEhD,MAAM,2CAA2C,CAAC;AAEnD,qBACa,+BAA+B;IACxC,OAAO,CAAC,gBAAgB,CAAoC;;IAMtD,yBAAyB,CAC3B,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GACtC,OAAO,CAAC,OAAO,CAAC;IAIb,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAKpD,uBAAuB,CACzB,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GACtC,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAIjC,gBAAgB,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,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,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,8BAA8B,EAAE,CAAC;IAIlG,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,8BAA8B,GAAG,IAAI,CAAC;IAO3F,cAAc,CAChB,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAChC,OAAO,CAAC,8BAA8B,GAAG,IAAI,CAAC;IAM3C,cAAc,CAChB,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,MAAM,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;IAQH,iCAAiC,CAC1C,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,EAClC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GACjC,OAAO,CAAC,8BAA8B,EAAE,CAAC;CAW/C;AAED,eAAO,MAAM,+BAA+B,iCAAiD,CAAC"}
@@ -74,8 +74,18 @@ let TournamentParticipantRepository = class TournamentParticipantRepository {
74
74
  .findOneAndUpdate({ userId, tournamentId }, { $set: { status: 'joined', teamId } }, { new: true })
75
75
  .lean();
76
76
  }
77
- async upsertStatus(userId, tournamentId, status) {
78
- await this.participantModel.findOneAndUpdate({ userId, tournamentId }, { $setOnInsert: { userId, tournamentId, predictions: [] }, $set: { status } }, { upsert: true });
77
+ async createIfAbsent(userId, tournamentId, status) {
78
+ await this.participantModel.findOneAndUpdate({ userId, tournamentId }, { $setOnInsert: { userId, tournamentId, predictions: [], status } }, { upsert: true });
79
+ }
80
+ async findByTournamentWithoutPrediction(tournamentId, teamIds, matchId) {
81
+ return this.participantModel
82
+ .find({
83
+ tournamentId,
84
+ teamId: { $in: teamIds },
85
+ 'predictions.matchId': { $ne: matchId },
86
+ })
87
+ .lean()
88
+ .exec();
79
89
  }
80
90
  };
81
91
  exports.TournamentParticipantRepository = TournamentParticipantRepository;
@@ -1 +1 @@
1
- {"version":3,"file":"participant.repository.js","sourceRoot":"/","sources":["modules/tournament/participant/participant.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,sEAGmD;AAG5C,IAAM,+BAA+B,GAArC,MAAM,+BAA+B;IAChC,gBAAgB,CAAoC;IAE5D;QACI,IAAI,CAAC,gBAAgB,GAAG,mCAA0B,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,yBAAyB,CAC3B,MAA+B,EAC/B,YAAqC;QAErC,OAAO,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAa;QACtB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,uBAAuB,CACzB,MAA+B,EAC/B,YAAqC;QAErC,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,IAAI,EAA0C,CAAC;IAClH,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,YAAqC;QACxD,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,IAAI,EAAqC,CAAC;IAClG,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,MAA+B;QAC5C,OAAO,IAAI,CAAC,gBAAgB;aACvB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;aACnB,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC;aACvB,IAAI,EAA0C,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,cAAc,CAChB,MAA+B,EAC/B,YAAqC,EACrC,MAA+B;QAE/B,OAAO,IAAI,CAAC,gBAAgB;aACvB,gBAAgB,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;aACjG,IAAI,EAA0C,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,YAAY,CACd,MAA+B,EAC/B,YAAqC,EACrC,MAAc;QAEd,MAAM,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CACxC,EAAE,MAAM,EAAE,YAAY,EAAE,EACxB,EAAE,YAAY,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAC7E,EAAE,MAAM,EAAE,IAAI,EAAE,CACnB,CAAC;IACN,CAAC;CACJ,CAAA;AA1DY,0EAA+B;0CAA/B,+BAA+B;IAD3C,IAAA,gBAAO,GAAE;;GACG,+BAA+B,CA0D3C;AAEY,QAAA,+BAA+B,GAAG,gBAAS,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport {\n TournamentParticipant as ParticipantModelType,\n TournamentParticipantModel,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\n\n@Service()\nexport class TournamentParticipantRepository {\n private participantModel: typeof TournamentParticipantModel;\n\n constructor() {\n this.participantModel = TournamentParticipantModel;\n }\n\n async existsByUserAndTournament(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId\n ): Promise<boolean> {\n return !!(await this.participantModel.exists({ userId, tournamentId }));\n }\n\n async create(input: object): Promise<ParticipantModelType> {\n const doc = await this.participantModel.create(input);\n return doc.toObject();\n }\n\n async findByUserAndTournament(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId\n ): Promise<ParticipantModelType | null> {\n return this.participantModel.findOne({ userId, tournamentId }).lean() as Promise<ParticipantModelType | null>;\n }\n\n async findByTournament(tournamentId: mongoose.Types.ObjectId): Promise<ParticipantModelType[]> {\n return this.participantModel.find({ tournamentId }).lean() as Promise<ParticipantModelType[]>;\n }\n\n async findByUser(userId: mongoose.Types.ObjectId): Promise<ParticipantModelType | null> {\n return this.participantModel\n .findOne({ userId })\n .sort({ createdAt: -1 })\n .lean() as Promise<ParticipantModelType | null>;\n }\n\n async updateToJoined(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId,\n teamId: mongoose.Types.ObjectId\n ): Promise<ParticipantModelType | null> {\n return this.participantModel\n .findOneAndUpdate({ userId, tournamentId }, { $set: { status: 'joined', teamId } }, { new: true })\n .lean() as Promise<ParticipantModelType | null>;\n }\n\n async upsertStatus(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId,\n status: string\n ): Promise<void> {\n await this.participantModel.findOneAndUpdate(\n { userId, tournamentId },\n { $setOnInsert: { userId, tournamentId, predictions: [] }, $set: { status } },\n { upsert: true }\n );\n }\n}\n\nexport const tournamentParticipantRepository = Container.get(TournamentParticipantRepository);"]}
1
+ {"version":3,"file":"participant.repository.js","sourceRoot":"/","sources":["modules/tournament/participant/participant.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,sEAAuF;AAIhF,IAAM,+BAA+B,GAArC,MAAM,+BAA+B;IAChC,gBAAgB,CAAoC;IAE5D;QACI,IAAI,CAAC,gBAAgB,GAAG,mCAA0B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KAAK,CAAC,cAAc,CAChB,MAA+B,EAC/B,YAAqC,EACrC,MAAc;QAEd,MAAM,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CACxC,EAAE,MAAM,EAAE,YAAY,EAAE,EACxB,EAAE,YAAY,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EACnE,EAAE,MAAM,EAAE,IAAI,EAAE,CACnB,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,iCAAiC,CAC1C,YAAqC,EACrC,OAAkC,EAClC,OAAgC;QAEhC,OAAO,IAAI,CAAC,gBAAgB;aACvB,IAAI,CAAC;YACF,YAAY;YACZ,MAAM,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE;YACxB,qBAAqB,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE;SAC1C,CAAC;aACD,IAAI,EAAE;aACN,IAAI,EAA+C,CAAC;IAC7D,CAAC;CAEJ,CAAA;AA1EY,0EAA+B;0CAA/B,+BAA+B;IAD3C,IAAA,gBAAO,GAAE;;GACG,+BAA+B,CA0E3C;AAEY,QAAA,+BAA+B,GAAG,gBAAS,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport { TournamentParticipantModel } from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport { TournamentParticipantOutputDTO } from './participant.validation';\n\n@Service()\nexport class TournamentParticipantRepository {\n private participantModel: typeof TournamentParticipantModel;\n\n constructor() {\n this.participantModel = TournamentParticipantModel;\n }\n\n async existsByUserAndTournament(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId\n ): Promise<boolean> {\n return !!(await this.participantModel.exists({ userId, tournamentId }));\n }\n\n async create(input: object): Promise<TournamentParticipantOutputDTO> {\n const doc = await this.participantModel.create(input);\n return doc.toObject() as unknown as TournamentParticipantOutputDTO;\n }\n\n async findByUserAndTournament(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId\n ): Promise<TournamentParticipantOutputDTO | null> {\n return this.participantModel.findOne({ userId, tournamentId }).lean() as Promise<TournamentParticipantOutputDTO | null>;\n }\n\n async findByTournament(tournamentId: mongoose.Types.ObjectId): Promise<TournamentParticipantOutputDTO[]> {\n return this.participantModel.find({ tournamentId }).lean() as Promise<TournamentParticipantOutputDTO[]>;\n }\n\n async findByUser(userId: mongoose.Types.ObjectId): Promise<TournamentParticipantOutputDTO | null> {\n return this.participantModel\n .findOne({ userId })\n .sort({ createdAt: -1 })\n .lean() as Promise<TournamentParticipantOutputDTO | null>;\n }\n\n async updateToJoined(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId,\n teamId: mongoose.Types.ObjectId\n ): Promise<TournamentParticipantOutputDTO | null> {\n return this.participantModel\n .findOneAndUpdate({ userId, tournamentId }, { $set: { status: 'joined', teamId } }, { new: true })\n .lean() as Promise<TournamentParticipantOutputDTO | null>;\n }\n\n async createIfAbsent(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId,\n status: string\n ): Promise<void> {\n await this.participantModel.findOneAndUpdate(\n { userId, tournamentId },\n { $setOnInsert: { userId, tournamentId, predictions: [], status } },\n { upsert: true }\n );\n }\n\n public async findByTournamentWithoutPrediction(\n tournamentId: mongoose.Types.ObjectId,\n teamIds: mongoose.Types.ObjectId[],\n matchId: mongoose.Types.ObjectId\n ): Promise<TournamentParticipantOutputDTO[]> {\n return this.participantModel\n .find({\n tournamentId,\n teamId: { $in: teamIds },\n 'predictions.matchId': { $ne: matchId },\n })\n .lean()\n .exec() as Promise<TournamentParticipantOutputDTO[]>;\n }\n\n}\n\nexport const tournamentParticipantRepository = Container.get(TournamentParticipantRepository);\n"]}