@lyxa.ai/marketing 1.0.51 → 1.0.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (481) hide show
  1. package/dist/lib/index.d.ts +323 -77
  2. package/dist/lib/index.d.ts.map +1 -1
  3. package/dist/lib/index.js +1 -1
  4. package/dist/lib/index.js.map +1 -1
  5. package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
  6. package/dist/lib/modules/coupon/routers/coupon.router.js +1 -1
  7. package/dist/lib/modules/coupon/routers/coupon.router.js.map +1 -1
  8. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
  9. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js +16 -3
  10. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js.map +1 -1
  11. package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts +1117 -285
  12. package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
  13. package/dist/lib/modules/coupon/validations/all-coupons.validation.js +16 -2
  14. package/dist/lib/modules/coupon/validations/all-coupons.validation.js.map +1 -1
  15. package/dist/lib/modules/coupon/validations/index.d.ts +0 -1
  16. package/dist/lib/modules/coupon/validations/index.d.ts.map +1 -1
  17. package/dist/lib/modules/coupon/validations/index.js +0 -1
  18. package/dist/lib/modules/coupon/validations/index.js.map +1 -1
  19. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts +32 -32
  20. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js +9 -9
  21. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js.map +1 -1
  22. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts +0 -1
  23. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts.map +1 -1
  24. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.js +2 -5
  25. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.js.map +1 -1
  26. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts +1 -0
  27. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts.map +1 -1
  28. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.js +2 -0
  29. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.js.map +1 -1
  30. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +19 -6
  31. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts.map +1 -1
  32. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js +3 -2
  33. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js.map +1 -1
  34. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts +3 -9
  35. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
  36. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js +4 -7
  37. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js.map +1 -1
  38. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts +1 -0
  39. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts.map +1 -1
  40. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.service.js +15 -0
  41. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.service.js.map +1 -1
  42. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts +96 -50
  43. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
  44. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.js +23 -0
  45. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.js.map +1 -1
  46. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts +18 -0
  47. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -0
  48. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js +78 -0
  49. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js.map +1 -0
  50. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +12 -0
  51. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
  52. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js +68 -0
  53. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js.map +1 -1
  54. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +22 -18
  55. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
  56. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts +1 -0
  57. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts.map +1 -0
  58. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.js +2 -0
  59. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.js.map +1 -0
  60. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +88 -83
  61. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
  62. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js +3 -2
  63. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js.map +1 -1
  64. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +10 -1
  65. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  66. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js +68 -22
  67. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js.map +1 -1
  68. package/dist/lib/modules/marketing/validations/product-marketing.validation.d.ts +2 -2
  69. package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +1 -1
  70. package/dist/lib/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +2 -2
  71. package/dist/lib/modules/tournament/config/config.builder.d.ts.map +1 -1
  72. package/dist/lib/modules/tournament/config/config.builder.js +4 -0
  73. package/dist/lib/modules/tournament/config/config.builder.js.map +1 -1
  74. package/dist/lib/modules/tournament/config/config.repository.d.ts +8 -2
  75. package/dist/lib/modules/tournament/config/config.repository.d.ts.map +1 -1
  76. package/dist/lib/modules/tournament/config/config.repository.js +30 -1
  77. package/dist/lib/modules/tournament/config/config.repository.js.map +1 -1
  78. package/dist/lib/modules/tournament/config/config.router.d.ts +102 -12
  79. package/dist/lib/modules/tournament/config/config.router.d.ts.map +1 -1
  80. package/dist/lib/modules/tournament/config/config.types.d.ts +15 -0
  81. package/dist/lib/modules/tournament/config/config.types.d.ts.map +1 -0
  82. package/dist/lib/modules/tournament/config/config.types.js +3 -0
  83. package/dist/lib/modules/tournament/config/config.types.js.map +1 -0
  84. package/dist/lib/modules/tournament/config/config.validation.d.ts +431 -52
  85. package/dist/lib/modules/tournament/config/config.validation.d.ts.map +1 -1
  86. package/dist/lib/modules/tournament/config/config.validation.js +20 -6
  87. package/dist/lib/modules/tournament/config/config.validation.js.map +1 -1
  88. package/dist/lib/modules/tournament/integration/integration.factory.d.ts +4 -0
  89. package/dist/lib/modules/tournament/integration/integration.factory.d.ts.map +1 -0
  90. package/dist/lib/modules/tournament/integration/integration.factory.js +18 -0
  91. package/dist/lib/modules/tournament/integration/integration.factory.js.map +1 -0
  92. package/dist/lib/modules/tournament/integration/interfaces/ITournamentService.d.ts +36 -0
  93. package/dist/lib/modules/tournament/integration/interfaces/ITournamentService.d.ts.map +1 -0
  94. package/dist/lib/modules/tournament/integration/interfaces/ITournamentService.js +3 -0
  95. package/dist/lib/modules/tournament/integration/interfaces/ITournamentService.js.map +1 -0
  96. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.provider.d.ts +14 -0
  97. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.provider.d.ts.map +1 -0
  98. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.provider.js +92 -0
  99. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.provider.js.map +1 -0
  100. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.types.d.ts +51 -0
  101. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.types.d.ts.map +1 -0
  102. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.types.js +3 -0
  103. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.types.js.map +1 -0
  104. package/dist/lib/modules/tournament/integration/providers/api-football/index.d.ts +3 -0
  105. package/dist/lib/modules/tournament/integration/providers/api-football/index.d.ts.map +1 -0
  106. package/dist/lib/modules/tournament/integration/providers/api-football/index.js +19 -0
  107. package/dist/lib/modules/tournament/integration/providers/api-football/index.js.map +1 -0
  108. package/dist/lib/modules/tournament/integration/providers/index.d.ts +3 -0
  109. package/dist/lib/modules/tournament/integration/providers/index.d.ts.map +1 -0
  110. package/dist/lib/modules/tournament/integration/providers/index.js +19 -0
  111. package/dist/lib/modules/tournament/integration/providers/index.js.map +1 -0
  112. package/dist/lib/modules/tournament/integration/providers/mock.provider.d.ts +7 -0
  113. package/dist/lib/modules/tournament/integration/providers/mock.provider.d.ts.map +1 -0
  114. package/dist/lib/modules/tournament/integration/providers/mock.provider.js +22 -0
  115. package/dist/lib/modules/tournament/integration/providers/mock.provider.js.map +1 -0
  116. package/dist/lib/modules/tournament/integration/tournamentService.d.ts +9 -0
  117. package/dist/lib/modules/tournament/integration/tournamentService.d.ts.map +1 -0
  118. package/dist/lib/modules/tournament/integration/tournamentService.js +20 -0
  119. package/dist/lib/modules/tournament/integration/tournamentService.js.map +1 -0
  120. package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.d.ts.map +1 -1
  121. package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js +50 -11
  122. package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js.map +1 -1
  123. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.d.ts +7 -3
  124. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.d.ts.map +1 -1
  125. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.js +1 -1
  126. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.js.map +1 -1
  127. package/dist/lib/modules/tournament/match/events/match-evaluation.orchestrator.d.ts +14 -0
  128. package/dist/lib/modules/tournament/match/events/match-evaluation.orchestrator.d.ts.map +1 -0
  129. package/dist/lib/modules/tournament/{notification/jobs/notification.worker.js → match/events/match-evaluation.orchestrator.js} +31 -27
  130. package/dist/lib/modules/tournament/match/events/match-evaluation.orchestrator.js.map +1 -0
  131. package/dist/lib/modules/tournament/match/match.builder.d.ts +13 -34
  132. package/dist/lib/modules/tournament/match/match.builder.d.ts.map +1 -1
  133. package/dist/lib/modules/tournament/match/match.builder.js +31 -10
  134. package/dist/lib/modules/tournament/match/match.builder.js.map +1 -1
  135. package/dist/lib/modules/tournament/match/match.repository.d.ts +1 -1
  136. package/dist/lib/modules/tournament/match/match.repository.d.ts.map +1 -1
  137. package/dist/lib/modules/tournament/match/match.repository.js.map +1 -1
  138. package/dist/lib/modules/tournament/match/match.router.d.ts +40 -4
  139. package/dist/lib/modules/tournament/match/match.router.d.ts.map +1 -1
  140. package/dist/lib/modules/tournament/match/match.service.d.ts +3 -0
  141. package/dist/lib/modules/tournament/match/match.service.d.ts.map +1 -1
  142. package/dist/lib/modules/tournament/match/match.service.js +15 -12
  143. package/dist/lib/modules/tournament/match/match.service.js.map +1 -1
  144. package/dist/lib/modules/tournament/match/match.types.d.ts +51 -0
  145. package/dist/lib/modules/tournament/match/match.types.d.ts.map +1 -0
  146. package/dist/lib/modules/tournament/match/match.types.js +3 -0
  147. package/dist/lib/modules/tournament/match/match.types.js.map +1 -0
  148. package/dist/lib/modules/tournament/notification/notification-template.repository.d.ts +2 -1
  149. package/dist/lib/modules/tournament/notification/notification-template.repository.d.ts.map +1 -1
  150. package/dist/lib/modules/tournament/notification/notification-template.repository.js +2 -1
  151. package/dist/lib/modules/tournament/notification/notification-template.repository.js.map +1 -1
  152. package/dist/lib/modules/tournament/notification/notification.builder.d.ts +30 -0
  153. package/dist/lib/modules/tournament/notification/notification.builder.d.ts.map +1 -0
  154. package/dist/lib/modules/tournament/notification/notification.builder.js +35 -0
  155. package/dist/lib/modules/tournament/notification/notification.builder.js.map +1 -0
  156. package/dist/lib/modules/tournament/notification/notification.config.d.ts +10 -9
  157. package/dist/lib/modules/tournament/notification/notification.config.d.ts.map +1 -1
  158. package/dist/lib/modules/tournament/notification/notification.config.js +0 -12
  159. package/dist/lib/modules/tournament/notification/notification.config.js.map +1 -1
  160. package/dist/lib/modules/tournament/notification/notification.service.d.ts +5 -3
  161. package/dist/lib/modules/tournament/notification/notification.service.d.ts.map +1 -1
  162. package/dist/lib/modules/tournament/notification/notification.service.js +23 -15
  163. package/dist/lib/modules/tournament/notification/notification.service.js.map +1 -1
  164. package/dist/lib/modules/tournament/participant/participant.builder.d.ts +12 -0
  165. package/dist/lib/modules/tournament/participant/participant.builder.d.ts.map +1 -0
  166. package/dist/lib/modules/tournament/participant/participant.builder.js +17 -0
  167. package/dist/lib/modules/tournament/participant/participant.builder.js.map +1 -0
  168. package/dist/lib/modules/tournament/participant/participant.repository.d.ts +8 -7
  169. package/dist/lib/modules/tournament/participant/participant.repository.d.ts.map +1 -1
  170. package/dist/lib/modules/tournament/participant/participant.repository.js +12 -2
  171. package/dist/lib/modules/tournament/participant/participant.repository.js.map +1 -1
  172. package/dist/lib/modules/tournament/participant/participant.service.d.ts +1 -0
  173. package/dist/lib/modules/tournament/participant/participant.service.d.ts.map +1 -1
  174. package/dist/lib/modules/tournament/participant/participant.service.js +15 -17
  175. package/dist/lib/modules/tournament/participant/participant.service.js.map +1 -1
  176. package/dist/lib/modules/tournament/prediction/prediction.builder.d.ts +3 -9
  177. package/dist/lib/modules/tournament/prediction/prediction.builder.d.ts.map +1 -1
  178. package/dist/lib/modules/tournament/prediction/prediction.builder.js.map +1 -1
  179. package/dist/lib/modules/tournament/prediction/prediction.repository.d.ts +11 -3
  180. package/dist/lib/modules/tournament/prediction/prediction.repository.d.ts.map +1 -1
  181. package/dist/lib/modules/tournament/prediction/prediction.repository.js +47 -0
  182. package/dist/lib/modules/tournament/prediction/prediction.repository.js.map +1 -1
  183. package/dist/lib/modules/tournament/prediction/prediction.service.d.ts +1 -1
  184. package/dist/lib/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
  185. package/dist/lib/modules/tournament/prediction/prediction.service.js +16 -26
  186. package/dist/lib/modules/tournament/prediction/prediction.service.js.map +1 -1
  187. package/dist/lib/modules/tournament/prediction/prediction.types.d.ts +17 -0
  188. package/dist/lib/modules/tournament/prediction/prediction.types.d.ts.map +1 -0
  189. package/dist/lib/modules/tournament/prediction/prediction.types.js +3 -0
  190. package/dist/lib/modules/tournament/prediction/prediction.types.js.map +1 -0
  191. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.d.ts +8 -5
  192. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.d.ts.map +1 -1
  193. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.js +58 -16
  194. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.js.map +1 -1
  195. package/dist/lib/modules/tournament/reward/reward.builder.d.ts +5 -2
  196. package/dist/lib/modules/tournament/reward/reward.builder.d.ts.map +1 -1
  197. package/dist/lib/modules/tournament/reward/reward.builder.js +44 -28
  198. package/dist/lib/modules/tournament/reward/reward.builder.js.map +1 -1
  199. package/dist/lib/modules/tournament/reward/reward.factory.d.ts +1 -1
  200. package/dist/lib/modules/tournament/reward/reward.factory.d.ts.map +1 -1
  201. package/dist/lib/modules/tournament/reward/reward.factory.js.map +1 -1
  202. package/dist/lib/modules/tournament/reward/reward.interface.d.ts +2 -2
  203. package/dist/lib/modules/tournament/reward/reward.interface.d.ts.map +1 -1
  204. package/dist/lib/modules/tournament/reward/reward.interface.js.map +1 -1
  205. package/dist/lib/modules/tournament/reward/reward.service.d.ts +1 -1
  206. package/dist/lib/modules/tournament/reward/reward.service.d.ts.map +1 -1
  207. package/dist/lib/modules/tournament/reward/reward.service.js +1 -1
  208. package/dist/lib/modules/tournament/reward/reward.service.js.map +1 -1
  209. package/dist/lib/modules/tournament/reward/reward.types.d.ts +35 -2
  210. package/dist/lib/modules/tournament/reward/reward.types.d.ts.map +1 -1
  211. package/dist/lib/modules/tournament/reward/reward.types.js.map +1 -1
  212. package/dist/lib/modules/tournament/schedule/schedule.router.d.ts.map +1 -1
  213. package/dist/lib/modules/tournament/schedule/schedule.router.js +1 -3
  214. package/dist/lib/modules/tournament/schedule/schedule.router.js.map +1 -1
  215. package/dist/lib/modules/tournament/schedule/schedule.service.d.ts +3 -0
  216. package/dist/lib/modules/tournament/schedule/schedule.service.d.ts.map +1 -1
  217. package/dist/lib/modules/tournament/schedule/schedule.service.js +30 -1
  218. package/dist/lib/modules/tournament/schedule/schedule.service.js.map +1 -1
  219. package/dist/lib/modules/tournament/score/score.repository.d.ts +13 -0
  220. package/dist/lib/modules/tournament/score/score.repository.d.ts.map +1 -1
  221. package/dist/lib/modules/tournament/score/score.repository.js +20 -0
  222. package/dist/lib/modules/tournament/score/score.repository.js.map +1 -1
  223. package/dist/lib/modules/tournament/score/score.service.d.ts +3 -0
  224. package/dist/lib/modules/tournament/score/score.service.d.ts.map +1 -1
  225. package/dist/lib/modules/tournament/score/score.service.js +3 -0
  226. package/dist/lib/modules/tournament/score/score.service.js.map +1 -1
  227. package/dist/lib/modules/tournament/statistics/statistics.builder.d.ts +5 -0
  228. package/dist/lib/modules/tournament/statistics/statistics.builder.d.ts.map +1 -1
  229. package/dist/lib/modules/tournament/statistics/statistics.builder.js +47 -28
  230. package/dist/lib/modules/tournament/statistics/statistics.builder.js.map +1 -1
  231. package/dist/lib/modules/tournament/statistics/statistics.router.d.ts +4 -2
  232. package/dist/lib/modules/tournament/statistics/statistics.router.d.ts.map +1 -1
  233. package/dist/lib/modules/tournament/statistics/statistics.service.js +4 -4
  234. package/dist/lib/modules/tournament/statistics/statistics.service.js.map +1 -1
  235. package/dist/lib/modules/tournament/statistics/statistics.validation.d.ts +32 -14
  236. package/dist/lib/modules/tournament/statistics/statistics.validation.d.ts.map +1 -1
  237. package/dist/lib/modules/tournament/statistics/statistics.validation.js +2 -1
  238. package/dist/lib/modules/tournament/statistics/statistics.validation.js.map +1 -1
  239. package/dist/lib/modules/tournament/sync/sync.repository.d.ts +11 -0
  240. package/dist/lib/modules/tournament/sync/sync.repository.d.ts.map +1 -0
  241. package/dist/lib/modules/tournament/{notification/notification.scheduler.service.js → sync/sync.repository.js} +22 -28
  242. package/dist/lib/modules/tournament/sync/sync.repository.js.map +1 -0
  243. package/dist/lib/modules/tournament/sync/sync.router.d.ts +27 -0
  244. package/dist/lib/modules/tournament/sync/sync.router.d.ts.map +1 -0
  245. package/dist/lib/modules/tournament/sync/sync.router.js +15 -0
  246. package/dist/lib/modules/tournament/sync/sync.router.js.map +1 -0
  247. package/dist/lib/modules/tournament/sync/sync.service.d.ts +9 -0
  248. package/dist/lib/modules/tournament/sync/sync.service.d.ts.map +1 -0
  249. package/dist/lib/modules/tournament/sync/sync.service.js +117 -0
  250. package/dist/lib/modules/tournament/sync/sync.service.js.map +1 -0
  251. package/dist/lib/modules/tournament/team/team.builder.d.ts +4 -0
  252. package/dist/lib/modules/tournament/team/team.builder.d.ts.map +1 -1
  253. package/dist/lib/modules/tournament/team/team.builder.js +6 -0
  254. package/dist/lib/modules/tournament/team/team.builder.js.map +1 -1
  255. package/dist/lib/modules/tournament/team/team.repository.d.ts +3 -0
  256. package/dist/lib/modules/tournament/team/team.repository.d.ts.map +1 -1
  257. package/dist/lib/modules/tournament/team/team.repository.js +6 -0
  258. package/dist/lib/modules/tournament/team/team.repository.js.map +1 -1
  259. package/dist/lib/modules/tournament/team/team.router.d.ts +24 -6
  260. package/dist/lib/modules/tournament/team/team.router.d.ts.map +1 -1
  261. package/dist/lib/modules/tournament/team/team.router.js +1 -1
  262. package/dist/lib/modules/tournament/team/team.router.js.map +1 -1
  263. package/dist/lib/modules/tournament/team/team.service.d.ts +2 -1
  264. package/dist/lib/modules/tournament/team/team.service.d.ts.map +1 -1
  265. package/dist/lib/modules/tournament/team/team.service.js +26 -23
  266. package/dist/lib/modules/tournament/team/team.service.js.map +1 -1
  267. package/dist/lib/modules/tournament/team/team.validation.d.ts +23 -24
  268. package/dist/lib/modules/tournament/team/team.validation.d.ts.map +1 -1
  269. package/dist/lib/modules/tournament/team/team.validation.js +3 -4
  270. package/dist/lib/modules/tournament/team/team.validation.js.map +1 -1
  271. package/dist/lib/modules/tournament/tournament.builder.d.ts +11 -0
  272. package/dist/lib/modules/tournament/tournament.builder.d.ts.map +1 -0
  273. package/dist/lib/modules/tournament/tournament.builder.js +34 -0
  274. package/dist/lib/modules/tournament/tournament.builder.js.map +1 -0
  275. package/dist/lib/modules/tournament/tournament.router.d.ts +226 -26
  276. package/dist/lib/modules/tournament/tournament.router.d.ts.map +1 -1
  277. package/dist/lib/modules/tournament/tournament.router.js +2 -0
  278. package/dist/lib/modules/tournament/tournament.router.js.map +1 -1
  279. package/dist/lib/modules/tournament/tournament.service.d.ts.map +1 -1
  280. package/dist/lib/modules/tournament/tournament.service.js +3 -10
  281. package/dist/lib/modules/tournament/tournament.service.js.map +1 -1
  282. package/dist/lib/modules/tournament/tournament.types.d.ts +0 -3
  283. package/dist/lib/modules/tournament/tournament.types.d.ts.map +1 -1
  284. package/dist/lib/modules/tournament/tournament.types.js +1 -5
  285. package/dist/lib/modules/tournament/tournament.types.js.map +1 -1
  286. package/dist/lib/modules/tournament/tournament.utils.d.ts +4 -0
  287. package/dist/lib/modules/tournament/tournament.utils.d.ts.map +1 -1
  288. package/dist/lib/modules/tournament/tournament.utils.js +8 -1
  289. package/dist/lib/modules/tournament/tournament.utils.js.map +1 -1
  290. package/dist/lib/modules/tournament/tournament.validation.d.ts +205 -1
  291. package/dist/lib/modules/tournament/tournament.validation.d.ts.map +1 -1
  292. package/dist/lib/modules/tournament/tournament.validation.js +23 -2
  293. package/dist/lib/modules/tournament/tournament.validation.js.map +1 -1
  294. package/dist/types/index.d.ts +323 -77
  295. package/dist/types/index.d.ts.map +1 -1
  296. package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
  297. package/dist/types/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
  298. package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts +1117 -285
  299. package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
  300. package/dist/types/modules/coupon/validations/index.d.ts +0 -1
  301. package/dist/types/modules/coupon/validations/index.d.ts.map +1 -1
  302. package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts +34 -32
  303. package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
  304. package/dist/types/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts +0 -1
  305. package/dist/types/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts.map +1 -1
  306. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts +1 -0
  307. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts.map +1 -1
  308. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +19 -6
  309. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts.map +1 -1
  310. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts +3 -9
  311. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
  312. package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts +1 -0
  313. package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts.map +1 -1
  314. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts +96 -50
  315. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
  316. package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts +23 -0
  317. package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -0
  318. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +12 -0
  319. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
  320. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +22 -18
  321. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
  322. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +88 -83
  323. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
  324. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +20 -1
  325. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  326. package/dist/types/modules/marketing/validations/product-marketing.validation.d.ts +2 -2
  327. package/dist/types/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +1 -1
  328. package/dist/types/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +2 -2
  329. package/dist/types/modules/tournament/config/config.builder.d.ts.map +1 -1
  330. package/dist/types/modules/tournament/config/config.repository.d.ts +8 -2
  331. package/dist/types/modules/tournament/config/config.repository.d.ts.map +1 -1
  332. package/dist/types/modules/tournament/config/config.router.d.ts +102 -12
  333. package/dist/types/modules/tournament/config/config.router.d.ts.map +1 -1
  334. package/dist/types/modules/tournament/config/config.types.d.ts +15 -0
  335. package/dist/types/modules/tournament/config/config.types.d.ts.map +1 -0
  336. package/dist/types/modules/tournament/config/config.validation.d.ts +431 -52
  337. package/dist/types/modules/tournament/config/config.validation.d.ts.map +1 -1
  338. package/dist/types/modules/tournament/integration/integration.factory.d.ts +4 -0
  339. package/dist/types/modules/tournament/integration/integration.factory.d.ts.map +1 -0
  340. package/dist/types/modules/tournament/integration/interfaces/ITournamentService.d.ts +36 -0
  341. package/dist/types/modules/tournament/integration/interfaces/ITournamentService.d.ts.map +1 -0
  342. package/dist/types/modules/tournament/integration/providers/api-football/api-football.provider.d.ts +14 -0
  343. package/dist/types/modules/tournament/integration/providers/api-football/api-football.provider.d.ts.map +1 -0
  344. package/dist/types/modules/tournament/integration/providers/api-football/api-football.types.d.ts +51 -0
  345. package/dist/types/modules/tournament/integration/providers/api-football/api-football.types.d.ts.map +1 -0
  346. package/dist/types/modules/tournament/integration/providers/api-football/index.d.ts +3 -0
  347. package/dist/types/modules/tournament/integration/providers/api-football/index.d.ts.map +1 -0
  348. package/dist/types/modules/tournament/integration/providers/index.d.ts +3 -0
  349. package/dist/types/modules/tournament/integration/providers/index.d.ts.map +1 -0
  350. package/dist/types/modules/tournament/integration/providers/mock.provider.d.ts +7 -0
  351. package/dist/types/modules/tournament/integration/providers/mock.provider.d.ts.map +1 -0
  352. package/dist/types/modules/tournament/integration/tournamentService.d.ts +9 -0
  353. package/dist/types/modules/tournament/integration/tournamentService.d.ts.map +1 -0
  354. package/dist/types/modules/tournament/match/events/evaluate-predictions.consumer.d.ts.map +1 -1
  355. package/dist/types/modules/tournament/match/events/evaluate-predictions.event.d.ts +7 -3
  356. package/dist/types/modules/tournament/match/events/evaluate-predictions.event.d.ts.map +1 -1
  357. package/dist/types/modules/tournament/match/events/match-evaluation.orchestrator.d.ts +14 -0
  358. package/dist/types/modules/tournament/match/events/match-evaluation.orchestrator.d.ts.map +1 -0
  359. package/dist/types/modules/tournament/match/match.builder.d.ts +13 -34
  360. package/dist/types/modules/tournament/match/match.builder.d.ts.map +1 -1
  361. package/dist/types/modules/tournament/match/match.repository.d.ts +1 -1
  362. package/dist/types/modules/tournament/match/match.repository.d.ts.map +1 -1
  363. package/dist/types/modules/tournament/match/match.router.d.ts +40 -4
  364. package/dist/types/modules/tournament/match/match.router.d.ts.map +1 -1
  365. package/dist/types/modules/tournament/match/match.service.d.ts +3 -0
  366. package/dist/types/modules/tournament/match/match.service.d.ts.map +1 -1
  367. package/dist/types/modules/tournament/match/match.types.d.ts +51 -0
  368. package/dist/types/modules/tournament/match/match.types.d.ts.map +1 -0
  369. package/dist/types/modules/tournament/notification/notification-template.repository.d.ts +2 -1
  370. package/dist/types/modules/tournament/notification/notification-template.repository.d.ts.map +1 -1
  371. package/dist/types/modules/tournament/notification/notification.builder.d.ts +30 -0
  372. package/dist/types/modules/tournament/notification/notification.builder.d.ts.map +1 -0
  373. package/dist/types/modules/tournament/notification/notification.config.d.ts +10 -9
  374. package/dist/types/modules/tournament/notification/notification.config.d.ts.map +1 -1
  375. package/dist/types/modules/tournament/notification/notification.service.d.ts +5 -3
  376. package/dist/types/modules/tournament/notification/notification.service.d.ts.map +1 -1
  377. package/dist/types/modules/tournament/participant/participant.builder.d.ts +12 -0
  378. package/dist/types/modules/tournament/participant/participant.builder.d.ts.map +1 -0
  379. package/dist/types/modules/tournament/participant/participant.repository.d.ts +8 -7
  380. package/dist/types/modules/tournament/participant/participant.repository.d.ts.map +1 -1
  381. package/dist/types/modules/tournament/participant/participant.service.d.ts +1 -0
  382. package/dist/types/modules/tournament/participant/participant.service.d.ts.map +1 -1
  383. package/dist/types/modules/tournament/prediction/prediction.builder.d.ts +3 -9
  384. package/dist/types/modules/tournament/prediction/prediction.builder.d.ts.map +1 -1
  385. package/dist/types/modules/tournament/prediction/prediction.repository.d.ts +11 -3
  386. package/dist/types/modules/tournament/prediction/prediction.repository.d.ts.map +1 -1
  387. package/dist/types/modules/tournament/prediction/prediction.service.d.ts +1 -1
  388. package/dist/types/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
  389. package/dist/types/modules/tournament/prediction/prediction.types.d.ts +17 -0
  390. package/dist/types/modules/tournament/prediction/prediction.types.d.ts.map +1 -0
  391. package/dist/types/modules/tournament/reward/handlers/coupon-reward.handler.d.ts +8 -5
  392. package/dist/types/modules/tournament/reward/handlers/coupon-reward.handler.d.ts.map +1 -1
  393. package/dist/types/modules/tournament/reward/reward.builder.d.ts +5 -2
  394. package/dist/types/modules/tournament/reward/reward.builder.d.ts.map +1 -1
  395. package/dist/types/modules/tournament/reward/reward.factory.d.ts +1 -1
  396. package/dist/types/modules/tournament/reward/reward.factory.d.ts.map +1 -1
  397. package/dist/types/modules/tournament/reward/reward.interface.d.ts +2 -2
  398. package/dist/types/modules/tournament/reward/reward.interface.d.ts.map +1 -1
  399. package/dist/types/modules/tournament/reward/reward.service.d.ts +1 -1
  400. package/dist/types/modules/tournament/reward/reward.service.d.ts.map +1 -1
  401. package/dist/types/modules/tournament/reward/reward.types.d.ts +35 -2
  402. package/dist/types/modules/tournament/reward/reward.types.d.ts.map +1 -1
  403. package/dist/types/modules/tournament/schedule/schedule.router.d.ts.map +1 -1
  404. package/dist/types/modules/tournament/schedule/schedule.service.d.ts +3 -0
  405. package/dist/types/modules/tournament/schedule/schedule.service.d.ts.map +1 -1
  406. package/dist/types/modules/tournament/score/score.repository.d.ts +13 -0
  407. package/dist/types/modules/tournament/score/score.repository.d.ts.map +1 -1
  408. package/dist/types/modules/tournament/score/score.service.d.ts +3 -0
  409. package/dist/types/modules/tournament/score/score.service.d.ts.map +1 -1
  410. package/dist/types/modules/tournament/statistics/statistics.builder.d.ts +5 -0
  411. package/dist/types/modules/tournament/statistics/statistics.builder.d.ts.map +1 -1
  412. package/dist/types/modules/tournament/statistics/statistics.router.d.ts +4 -2
  413. package/dist/types/modules/tournament/statistics/statistics.router.d.ts.map +1 -1
  414. package/dist/types/modules/tournament/statistics/statistics.validation.d.ts +32 -14
  415. package/dist/types/modules/tournament/statistics/statistics.validation.d.ts.map +1 -1
  416. package/dist/types/modules/tournament/sync/sync.repository.d.ts +11 -0
  417. package/dist/types/modules/tournament/sync/sync.repository.d.ts.map +1 -0
  418. package/dist/types/modules/tournament/sync/sync.router.d.ts +27 -0
  419. package/dist/types/modules/tournament/sync/sync.router.d.ts.map +1 -0
  420. package/dist/types/modules/tournament/sync/sync.service.d.ts +9 -0
  421. package/dist/types/modules/tournament/sync/sync.service.d.ts.map +1 -0
  422. package/dist/types/modules/tournament/team/team.builder.d.ts +4 -0
  423. package/dist/types/modules/tournament/team/team.builder.d.ts.map +1 -1
  424. package/dist/types/modules/tournament/team/team.repository.d.ts +3 -0
  425. package/dist/types/modules/tournament/team/team.repository.d.ts.map +1 -1
  426. package/dist/types/modules/tournament/team/team.router.d.ts +24 -6
  427. package/dist/types/modules/tournament/team/team.router.d.ts.map +1 -1
  428. package/dist/types/modules/tournament/team/team.service.d.ts +2 -1
  429. package/dist/types/modules/tournament/team/team.service.d.ts.map +1 -1
  430. package/dist/types/modules/tournament/team/team.validation.d.ts +23 -24
  431. package/dist/types/modules/tournament/team/team.validation.d.ts.map +1 -1
  432. package/dist/types/modules/tournament/tournament.builder.d.ts +11 -0
  433. package/dist/types/modules/tournament/tournament.builder.d.ts.map +1 -0
  434. package/dist/types/modules/tournament/tournament.router.d.ts +226 -26
  435. package/dist/types/modules/tournament/tournament.router.d.ts.map +1 -1
  436. package/dist/types/modules/tournament/tournament.service.d.ts.map +1 -1
  437. package/dist/types/modules/tournament/tournament.types.d.ts +0 -3
  438. package/dist/types/modules/tournament/tournament.types.d.ts.map +1 -1
  439. package/dist/types/modules/tournament/tournament.utils.d.ts +4 -0
  440. package/dist/types/modules/tournament/tournament.utils.d.ts.map +1 -1
  441. package/dist/types/modules/tournament/tournament.validation.d.ts +205 -1
  442. package/dist/types/modules/tournament/tournament.validation.d.ts.map +1 -1
  443. package/package.json +3 -3
  444. package/dist/lib/modules/tournament/match/events/match-ended.consumer.d.ts +0 -2
  445. package/dist/lib/modules/tournament/match/events/match-ended.consumer.d.ts.map +0 -1
  446. package/dist/lib/modules/tournament/match/events/match-ended.consumer.js +0 -15
  447. package/dist/lib/modules/tournament/match/events/match-ended.consumer.js.map +0 -1
  448. package/dist/lib/modules/tournament/match/events/match-ended.event.d.ts +0 -14
  449. package/dist/lib/modules/tournament/match/events/match-ended.event.d.ts.map +0 -1
  450. package/dist/lib/modules/tournament/match/events/match-ended.event.js +0 -12
  451. package/dist/lib/modules/tournament/match/events/match-ended.event.js.map +0 -1
  452. package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts +0 -10
  453. package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts.map +0 -1
  454. package/dist/lib/modules/tournament/notification/jobs/notification.producer.js +0 -23
  455. package/dist/lib/modules/tournament/notification/jobs/notification.producer.js.map +0 -1
  456. package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts +0 -9
  457. package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts.map +0 -1
  458. package/dist/lib/modules/tournament/notification/jobs/notification.worker.js.map +0 -1
  459. package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts +0 -10
  460. package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts.map +0 -1
  461. package/dist/lib/modules/tournament/notification/notification.schedule.config.js +0 -15
  462. package/dist/lib/modules/tournament/notification/notification.schedule.config.js.map +0 -1
  463. package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts +0 -10
  464. package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts.map +0 -1
  465. package/dist/lib/modules/tournament/notification/notification.scheduler.service.js.map +0 -1
  466. package/dist/types/events/event-initializations.d.ts +0 -2
  467. package/dist/types/events/event-initializations.d.ts.map +0 -1
  468. package/dist/types/modules/tournament/config/tournament-config.validation.d.ts +0 -201
  469. package/dist/types/modules/tournament/config/tournament-config.validation.d.ts.map +0 -1
  470. package/dist/types/modules/tournament/match/events/match-ended.consumer.d.ts +0 -2
  471. package/dist/types/modules/tournament/match/events/match-ended.consumer.d.ts.map +0 -1
  472. package/dist/types/modules/tournament/match/events/match-ended.event.d.ts +0 -14
  473. package/dist/types/modules/tournament/match/events/match-ended.event.d.ts.map +0 -1
  474. package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts +0 -10
  475. package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts.map +0 -1
  476. package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts +0 -9
  477. package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts.map +0 -1
  478. package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts +0 -10
  479. package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts.map +0 -1
  480. package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts +0 -10
  481. package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts.map +0 -1
@@ -1,27 +1,66 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EvaluatePredictionsConsumer = EvaluatePredictionsConsumer;
4
+ const typegoose_1 = require("@typegoose/typegoose");
4
5
  const evaluate_predictions_event_1 = require("./evaluate-predictions.event");
5
6
  const prediction_service_1 = require("../../prediction/prediction.service");
6
7
  const reward_service_1 = require("../../reward/reward.service");
7
8
  const notification_service_1 = require("../../notification/notification.service");
8
9
  const notification_template_repository_1 = require("../../notification/notification-template.repository");
9
- const notification_config_1 = require("../../notification/notification.config");
10
+ const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
10
11
  const reward_builder_1 = require("../../reward/reward.builder");
11
12
  const reward_types_1 = require("../../reward/reward.types");
12
13
  const event_1 = require("@lyxa.ai/core/dist/libraries/event");
14
+ const config_repository_1 = require("../../../tournament/config/config.repository");
15
+ const error_common_1 = require("@lyxa.ai/core/dist/utilities/error-common");
16
+ const match_evaluation_orchestrator_1 = require("../../../tournament/match/events/match-evaluation.orchestrator");
17
+ const core_1 = require("@lyxa.ai/core");
13
18
  async function EvaluatePredictionsConsumer() {
14
19
  await (0, event_1.subscribeToEvent)(evaluate_predictions_event_1.TOURNAMENT_EVALUATE_PREDICTIONS_EVENT, async (payload) => {
15
- const { winnerIds, loserIds } = await prediction_service_1.predictionService.evaluate(payload.tournamentId, payload.matchId, payload.finalScore);
16
- const templates = await notification_template_repository_1.notificationTemplateRepository.findTemplates(payload.tournamentId);
17
- const winner = templates.get(notification_config_1.NotificationTag.MATCH_RESULT_WINNER);
18
- const loser = templates.get(notification_config_1.NotificationTag.MATCH_RESULT_LOSER);
19
- await Promise.all([
20
- winner && winnerIds.length > 0 ? notification_service_1.tournamentNotificationService.notifyUsers(winner.title, winner.body, winnerIds) : Promise.resolve(),
21
- loser && loserIds.length > 0 ? notification_service_1.tournamentNotificationService.notifyUsers(loser.title, loser.body, loserIds) : Promise.resolve(),
22
- ]);
23
- if (winnerIds.length > 0) {
24
- await reward_service_1.rewardService.grant(reward_types_1.RewardType.COUPON, reward_builder_1.RewardBuilder.buildCouponRewardContext(payload.matchId, payload.tournamentId, winnerIds));
20
+ if (!payload.matches?.length)
21
+ return;
22
+ const tournamentId = new typegoose_1.mongoose.Types.ObjectId(payload.tournamentId.toString());
23
+ const logger = (0, core_1.getLibraries)().getLoggerKit();
24
+ logger.info('Evaluate predictions event received', {
25
+ tag: 'tournament.prediction.evaluate',
26
+ data: { tournamentId: tournamentId.toString(), matchCount: payload.matches.length, matches: payload.matches },
27
+ });
28
+ const tournament = await config_repository_1.tournamentConfigRepository.findById(tournamentId);
29
+ if (!tournament) {
30
+ (0, error_common_1.notFoundError)('Tournament not found');
31
+ }
32
+ const templates = await notification_template_repository_1.notificationTemplateRepository.findTemplates(tournamentId);
33
+ const winner = templates.get(enum_1.TournamentNotificationTag.MATCH_RESULT_WINNER);
34
+ const config = await match_evaluation_orchestrator_1.matchEvaluationOrchestrator.resolveCouponConfig(tournamentId);
35
+ if (!config)
36
+ return;
37
+ for (const m of payload.matches) {
38
+ const matchId = new typegoose_1.mongoose.Types.ObjectId(m.matchId.toString());
39
+ const { winnerIds } = await prediction_service_1.predictionService.evaluate(tournamentId, matchId, m.finalScore);
40
+ logger.info('Predictions evaluated', {
41
+ tag: 'tournament.prediction.evaluate',
42
+ data: { tournamentId: tournamentId.toString(), matchId: matchId.toString(), matchNumber: m.matchNumber, finalScore: m.finalScore, winnerCount: winnerIds.length, winnerIds },
43
+ });
44
+ if (config && winnerIds.length > 0) {
45
+ const couponDetails = await reward_service_1.rewardService.grant(reward_types_1.RewardType.COUPON, reward_builder_1.RewardBuilder.buildCouponRewardContext(matchId, tournamentId, winnerIds, m.matchNumber, config));
46
+ logger.info('Coupon reward granted', {
47
+ tag: 'tournament.prediction.evaluate',
48
+ data: { tournamentId: tournamentId.toString(), matchId: matchId.toString(), winnerCount: winnerIds.length, couponDetails },
49
+ });
50
+ await notification_service_1.tournamentNotificationService.notifyUsers({
51
+ title: winner?.title ?? '🎉 Your prediction was currect.',
52
+ body: winner?.body ?? 'Your coupon is now available',
53
+ tournamentId: tournamentId.toString(),
54
+ tournamentNotificationType: enum_1.TournamentNotificationTag.MATCH_RESULT_WINNER,
55
+ deepLinkRoute: tournament.deepLinkRoute,
56
+ matchId: matchId.toString(),
57
+ couponCode: couponDetails.code,
58
+ couponOfferLabel: couponDetails.couponOfferLabel,
59
+ couponValidityLabel: couponDetails.couponValidityLabel,
60
+ couponStartDate: couponDetails.duration.start,
61
+ couponEndDate: couponDetails.duration.end,
62
+ }, winnerIds);
63
+ }
25
64
  }
26
65
  });
27
66
  }
@@ -1 +1 @@
1
- {"version":3,"file":"evaluate-predictions.consumer.js","sourceRoot":"/","sources":["modules/tournament/match/events/evaluate-predictions.consumer.ts"],"names":[],"mappings":";;AAUA,kEAoBC;AA9BD,6EAA+G;AAC/G,4EAAsE;AACtE,gEAA0D;AAC1D,kFAAsF;AACtF,0GAAmG;AACnG,gFAAuE;AACvE,gEAA0D;AAC1D,4DAAqD;AACrD,8DAAoE;AAE7D,KAAK,UAAU,2BAA2B;IAC7C,MAAM,IAAA,wBAAgB,EAAC,kEAAqC,EAAE,KAAK,EAAE,OAAmC,EAAE,EAAE;QACxG,MAAM,EAAC,SAAS,EAAE,QAAQ,EAAC,GAAG,MAAM,sCAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;QAE1H,MAAM,SAAS,GAAG,MAAM,iEAA8B,CAAC,aAAa,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC3F,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,qCAAe,CAAC,mBAAmB,CAAC,CAAC;QAClE,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,qCAAe,CAAC,kBAAkB,CAAC,CAAC;QAEhE,MAAM,OAAO,CAAC,GAAG,CAAC;YACd,MAAM,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,oDAA6B,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE;YACpI,KAAK,IAAK,QAAQ,CAAC,MAAM,GAAI,CAAC,CAAC,CAAC,CAAC,oDAA6B,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,EAAG,KAAK,CAAC,IAAI,EAAG,QAAQ,CAAC,CAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE;SACvI,CAAC,CAAC;QAEH,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,MAAM,8BAAa,CAAC,KAAK,CACrB,yBAAU,CAAC,MAAM,EACjB,8BAAa,CAAC,wBAAwB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,EAAE,SAAS,CAAC,CAC3F,CAAC;QACN,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import {EvaluatePredictionsPayload, TOURNAMENT_EVALUATE_PREDICTIONS_EVENT} from './evaluate-predictions.event';\nimport {predictionService} from '../../prediction/prediction.service';\nimport {rewardService} from '../../reward/reward.service';\nimport {tournamentNotificationService} from '../../notification/notification.service';\nimport {notificationTemplateRepository} from '../../notification/notification-template.repository';\nimport {NotificationTag} from '../../notification/notification.config';\nimport {RewardBuilder} from '../../reward/reward.builder';\nimport {RewardType} from '../../reward/reward.types';\nimport {subscribeToEvent} from '@lyxa.ai/core/dist/libraries/event';\n\nexport async function EvaluatePredictionsConsumer() {\n await subscribeToEvent(TOURNAMENT_EVALUATE_PREDICTIONS_EVENT, async (payload: EvaluatePredictionsPayload) => {\n const {winnerIds, loserIds} = await predictionService.evaluate(payload.tournamentId, payload.matchId, payload.finalScore);\n\n const templates = await notificationTemplateRepository.findTemplates(payload.tournamentId);\n const winner = templates.get(NotificationTag.MATCH_RESULT_WINNER);\n const loser = templates.get(NotificationTag.MATCH_RESULT_LOSER);\n\n await Promise.all([\n winner && winnerIds.length > 0 ? tournamentNotificationService.notifyUsers(winner.title, winner.body, winnerIds) : Promise.resolve(),\n loser && loserIds.length > 0 ? tournamentNotificationService.notifyUsers(loser.title, loser.body, loserIds) : Promise.resolve(),\n ]);\n\n if (winnerIds.length > 0) {\n await rewardService.grant(\n RewardType.COUPON,\n RewardBuilder.buildCouponRewardContext(payload.matchId, payload.tournamentId, winnerIds)\n );\n }\n });\n}\n"]}
1
+ {"version":3,"file":"evaluate-predictions.consumer.js","sourceRoot":"/","sources":["modules/tournament/match/events/evaluate-predictions.consumer.ts"],"names":[],"mappings":";;AAeA,kEA4DC;AA3ED,oDAA8C;AAC9C,6EAA+G;AAC/G,4EAAsE;AACtE,gEAA0D;AAC1D,kFAAsF;AACtF,0GAAmG;AACnG,4DAA4E;AAC5E,gEAA0D;AAC1D,4DAAyE;AACzE,8DAAoE;AACpE,oFAAwF;AACxF,4EAAwE;AACxE,kHAA2G;AAC3G,wCAA2C;AAEpC,KAAK,UAAU,2BAA2B;IAC7C,MAAM,IAAA,wBAAgB,EAAC,kEAAqC,EAAE,KAAK,EAAE,OAAmC,EAAE,EAAE;QACxG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM;YAAE,OAAO;QACrC,MAAM,YAAY,GA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AAC,QAAQ,CAAC,KAAK;oBACrE,aAAa,EAAG,aAAoC,CAAC,QAAQ,CAAC,GAAG;iBACpE,EACD,SAAS,CACZ,CAAC;YACF,CAAC;QACL,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\nimport {EvaluatePredictionsPayload, TOURNAMENT_EVALUATE_PREDICTIONS_EVENT} from './evaluate-predictions.event';\nimport {predictionService} from '../../prediction/prediction.service';\nimport {rewardService} from '../../reward/reward.service';\nimport {tournamentNotificationService} from '../../notification/notification.service';\nimport {notificationTemplateRepository} from '../../notification/notification-template.repository';\nimport {TournamentNotificationTag} from '@lyxa.ai/core/dist/utilities/enum';\nimport {RewardBuilder} from '../../reward/reward.builder';\nimport {CouponRewardResult, RewardType} from '../../reward/reward.types';\nimport {subscribeToEvent} from '@lyxa.ai/core/dist/libraries/event';\nimport {tournamentConfigRepository} from '@modules/tournament/config/config.repository';\nimport {notFoundError} from '@lyxa.ai/core/dist/utilities/error-common';\nimport {matchEvaluationOrchestrator} from \"@modules/tournament/match/events/match-evaluation.orchestrator\";\nimport {getLibraries} from '@lyxa.ai/core';\n\nexport async function EvaluatePredictionsConsumer() {\n await subscribeToEvent(TOURNAMENT_EVALUATE_PREDICTIONS_EVENT, async (payload: EvaluatePredictionsPayload) => {\n if (!payload.matches?.length) return;\n const tournamentId = new mongoose.Types.ObjectId(payload.tournamentId.toString());\n const logger = getLibraries().getLoggerKit();\n\n logger.info('Evaluate predictions event received', {\n tag: 'tournament.prediction.evaluate',\n data: { tournamentId: tournamentId.toString(), matchCount: payload.matches.length, matches: payload.matches },\n });\n\n const tournament = await tournamentConfigRepository.findById(tournamentId);\n if (!tournament) {\n notFoundError('Tournament not found');\n }\n\n const templates = await notificationTemplateRepository.findTemplates(tournamentId);\n const winner = templates.get(TournamentNotificationTag.MATCH_RESULT_WINNER);\n const config = await matchEvaluationOrchestrator.resolveCouponConfig(tournamentId);\n\t\tif (!config) return;\n\n for (const m of payload.matches) {\n const matchId = new mongoose.Types.ObjectId(m.matchId.toString());\n const { winnerIds } = await predictionService.evaluate(tournamentId, matchId, m.finalScore);\n\n logger.info('Predictions evaluated', {\n tag: 'tournament.prediction.evaluate',\n data: { tournamentId: tournamentId.toString(), matchId: matchId.toString(), matchNumber: m.matchNumber, finalScore: m.finalScore, winnerCount: winnerIds.length, winnerIds },\n });\n\n if (config && winnerIds.length > 0) {\n const couponDetails = await rewardService.grant(\n RewardType.COUPON,\n RewardBuilder.buildCouponRewardContext(matchId, tournamentId, winnerIds, m.matchNumber, config)\n );\n\n logger.info('Coupon reward granted', {\n tag: 'tournament.prediction.evaluate',\n data: { tournamentId: tournamentId.toString(), matchId: matchId.toString(), winnerCount: winnerIds.length, couponDetails },\n });\n\n await tournamentNotificationService.notifyUsers(\n {\n title: winner?.title ?? '🎉 Your prediction was currect.',\n body: winner?.body ?? 'Your coupon is now available',\n tournamentId: tournamentId.toString(),\n tournamentNotificationType: TournamentNotificationTag.MATCH_RESULT_WINNER,\n deepLinkRoute: tournament.deepLinkRoute,\n matchId: matchId.toString(),\n couponCode: (couponDetails as CouponRewardResult).code,\n couponOfferLabel: (couponDetails as CouponRewardResult).couponOfferLabel,\n couponValidityLabel: (couponDetails as CouponRewardResult).couponValidityLabel,\n couponStartDate: (couponDetails as CouponRewardResult).duration.start,\n couponEndDate: (couponDetails as CouponRewardResult).duration.end,\n },\n winnerIds\n );\n }\n }\n });\n}\n"]}
@@ -1,14 +1,18 @@
1
1
  import { mongoose } from '@typegoose/typegoose';
2
2
  import { BaseEvent } from '@lyxa.ai/core/dist/libraries/event/BaseEvent';
3
- export declare const TOURNAMENT_EVALUATE_PREDICTIONS_EVENT = "tournament_evaluate_predictions_event";
4
- export interface EvaluatePredictionsPayload {
5
- tournamentId: mongoose.Types.ObjectId;
3
+ export declare const TOURNAMENT_EVALUATE_PREDICTIONS_EVENT = "tournament_evaluate_predictions_event1";
4
+ export interface EvaluatePredictionsMatch {
6
5
  matchId: mongoose.Types.ObjectId;
6
+ matchNumber: number;
7
7
  finalScore: {
8
8
  team1: number;
9
9
  team2: number;
10
10
  };
11
11
  }
12
+ export interface EvaluatePredictionsPayload {
13
+ tournamentId: mongoose.Types.ObjectId;
14
+ matches: EvaluatePredictionsMatch[];
15
+ }
12
16
  export declare class EvaluatePredictionsEvent extends BaseEvent<EvaluatePredictionsPayload> {
13
17
  constructor(payload: EvaluatePredictionsPayload);
14
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"evaluate-predictions.event.d.ts","sourceRoot":"/","sources":["modules/tournament/match/events/evaluate-predictions.event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,SAAS,EAAC,MAAM,8CAA8C,CAAC;AAEvE,eAAO,MAAM,qCAAqC,0CAA0C,CAAC;AAE7F,MAAM,WAAW,0BAA0B;IACvC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IACtC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IACjC,UAAU,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAChD;AAED,qBAAa,wBAAyB,SAAQ,SAAS,CAAC,0BAA0B,CAAC;gBACnE,OAAO,EAAE,0BAA0B;CAGlD"}
1
+ {"version":3,"file":"evaluate-predictions.event.d.ts","sourceRoot":"/","sources":["modules/tournament/match/events/evaluate-predictions.event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,SAAS,EAAC,MAAM,8CAA8C,CAAC;AAEvE,eAAO,MAAM,qCAAqC,2CAA2C,CAAC;AAE9F,MAAM,WAAW,wBAAwB;IACrC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAChD;AAED,MAAM,WAAW,0BAA0B;IACvC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IACtC,OAAO,EAAE,wBAAwB,EAAE,CAAC;CACvC;AAED,qBAAa,wBAAyB,SAAQ,SAAS,CAAC,0BAA0B,CAAC;gBACnE,OAAO,EAAE,0BAA0B;CAGlD"}
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EvaluatePredictionsEvent = exports.TOURNAMENT_EVALUATE_PREDICTIONS_EVENT = void 0;
4
4
  const BaseEvent_1 = require("@lyxa.ai/core/dist/libraries/event/BaseEvent");
5
- exports.TOURNAMENT_EVALUATE_PREDICTIONS_EVENT = 'tournament_evaluate_predictions_event';
5
+ exports.TOURNAMENT_EVALUATE_PREDICTIONS_EVENT = 'tournament_evaluate_predictions_event1';
6
6
  class EvaluatePredictionsEvent extends BaseEvent_1.BaseEvent {
7
7
  constructor(payload) {
8
8
  super(exports.TOURNAMENT_EVALUATE_PREDICTIONS_EVENT, payload);
@@ -1 +1 @@
1
- {"version":3,"file":"evaluate-predictions.event.js","sourceRoot":"/","sources":["modules/tournament/match/events/evaluate-predictions.event.ts"],"names":[],"mappings":";;;AACA,4EAAuE;AAE1D,QAAA,qCAAqC,GAAG,uCAAuC,CAAC;AAQ7F,MAAa,wBAAyB,SAAQ,qBAAqC;IAC/E,YAAY,OAAmC;QAC3C,KAAK,CAAC,6CAAqC,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;CACJ;AAJD,4DAIC","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\nimport {BaseEvent} from '@lyxa.ai/core/dist/libraries/event/BaseEvent';\n\nexport const TOURNAMENT_EVALUATE_PREDICTIONS_EVENT = 'tournament_evaluate_predictions_event';\n\nexport interface EvaluatePredictionsPayload {\n tournamentId: mongoose.Types.ObjectId;\n matchId: mongoose.Types.ObjectId;\n finalScore: { team1: number; team2: number };\n}\n\nexport class EvaluatePredictionsEvent extends BaseEvent<EvaluatePredictionsPayload> {\n constructor(payload: EvaluatePredictionsPayload) {\n super(TOURNAMENT_EVALUATE_PREDICTIONS_EVENT, payload);\n }\n}\n"]}
1
+ {"version":3,"file":"evaluate-predictions.event.js","sourceRoot":"/","sources":["modules/tournament/match/events/evaluate-predictions.event.ts"],"names":[],"mappings":";;;AACA,4EAAuE;AAE1D,QAAA,qCAAqC,GAAG,wCAAwC,CAAC;AAa9F,MAAa,wBAAyB,SAAQ,qBAAqC;IAC/E,YAAY,OAAmC;QAC3C,KAAK,CAAC,6CAAqC,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;CACJ;AAJD,4DAIC","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\nimport {BaseEvent} from '@lyxa.ai/core/dist/libraries/event/BaseEvent';\n\nexport const TOURNAMENT_EVALUATE_PREDICTIONS_EVENT = 'tournament_evaluate_predictions_event1';\n\nexport interface EvaluatePredictionsMatch {\n matchId: mongoose.Types.ObjectId;\n matchNumber: number;\n finalScore: { team1: number; team2: number };\n}\n\nexport interface EvaluatePredictionsPayload {\n tournamentId: mongoose.Types.ObjectId;\n matches: EvaluatePredictionsMatch[];\n}\n\nexport class EvaluatePredictionsEvent extends BaseEvent<EvaluatePredictionsPayload> {\n constructor(payload: EvaluatePredictionsPayload) {\n super(TOURNAMENT_EVALUATE_PREDICTIONS_EVENT, payload);\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import { mongoose } from '@typegoose/typegoose';
2
+ import { CouponRewardConfig } from '../../reward/reward.types';
3
+ export declare class MatchEvaluationOrchestrator {
4
+ private predictionService;
5
+ private rewardService;
6
+ private notificationService;
7
+ private templateRepository;
8
+ private configRepository;
9
+ constructor();
10
+ resolveCouponConfig(tournamentId: mongoose.Types.ObjectId): Promise<CouponRewardConfig | null>;
11
+ private static isCouponReward;
12
+ }
13
+ export declare const matchEvaluationOrchestrator: MatchEvaluationOrchestrator;
14
+ //# sourceMappingURL=match-evaluation.orchestrator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"match-evaluation.orchestrator.d.ts","sourceRoot":"/","sources":["modules/tournament/match/events/match-evaluation.orchestrator.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAU9C,OAAO,EAAC,kBAAkB,EAAa,MAAM,2BAA2B,CAAC;AAKzE,qBACa,2BAA2B;IACpC,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,mBAAmB,CAAgC;IAC3D,OAAO,CAAC,kBAAkB,CAAiC;IAC3D,OAAO,CAAC,gBAAgB,CAA6B;;IAWxC,mBAAmB,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAU3G,OAAO,CAAC,MAAM,CAAC,cAAc;CAGhC;AAED,eAAO,MAAM,2BAA2B,6BAA6C,CAAC"}
@@ -41,42 +41,46 @@ var __importStar = (this && this.__importStar) || (function () {
41
41
  var __metadata = (this && this.__metadata) || function (k, v) {
42
42
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
43
  };
44
+ var MatchEvaluationOrchestrator_1;
44
45
  Object.defineProperty(exports, "__esModule", { value: true });
45
- exports.tournamentNotificationWorker = exports.TournamentNotificationWorker = void 0;
46
+ exports.matchEvaluationOrchestrator = exports.MatchEvaluationOrchestrator = void 0;
46
47
  const typedi_1 = __importStar(require("typedi"));
47
- const typegoose_1 = require("@typegoose/typegoose");
48
- const core_1 = require("@lyxa.ai/core");
49
- const notification_producer_1 = require("./notification.producer");
50
- const notification_service_1 = require("../notification.service");
51
- const notification_template_repository_1 = require("../notification-template.repository");
52
- const match_repository_1 = require("../../match/match.repository");
53
- let TournamentNotificationWorker = class TournamentNotificationWorker {
48
+ const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
49
+ const prediction_service_1 = require("../../prediction/prediction.service");
50
+ const reward_service_1 = require("../../reward/reward.service");
51
+ const notification_service_1 = require("../../notification/notification.service");
52
+ const notification_template_repository_1 = require("../../notification/notification-template.repository");
53
+ const config_repository_1 = require("../../config/config.repository");
54
+ let MatchEvaluationOrchestrator = MatchEvaluationOrchestrator_1 = class MatchEvaluationOrchestrator {
55
+ predictionService;
56
+ rewardService;
54
57
  notificationService;
55
58
  templateRepository;
56
- matchRepository;
59
+ configRepository;
57
60
  constructor() {
61
+ this.predictionService = typedi_1.default.get(prediction_service_1.PredictionService);
62
+ this.rewardService = typedi_1.default.get(reward_service_1.RewardService);
58
63
  this.notificationService = typedi_1.default.get(notification_service_1.TournamentNotificationService);
59
64
  this.templateRepository = typedi_1.default.get(notification_template_repository_1.NotificationTemplateRepository);
60
- this.matchRepository = typedi_1.default.get(match_repository_1.TournamentMatchRepository);
65
+ this.configRepository = typedi_1.default.get(config_repository_1.TournamentConfigRepository);
61
66
  }
62
- startWorker() {
63
- (0, core_1.getLibraries)().getBullMQService().createWorker(notification_producer_1.TOURNAMENT_NOTIFICATION_QUEUE, async (job) => {
64
- const { tournamentId, matchId, target } = job.data;
65
- const tournamentObjId = new typegoose_1.mongoose.Types.ObjectId(tournamentId);
66
- const matchObjId = new typegoose_1.mongoose.Types.ObjectId(matchId);
67
- const alreadySent = await this.matchRepository.getNotificationFlag(tournamentObjId, matchObjId, job.name);
68
- if (alreadySent)
69
- return;
70
- const templates = await this.templateRepository.findTemplates(tournamentObjId);
71
- await this.notificationService.dispatchScheduledJob(job.name, target, templates, tournamentObjId, matchObjId);
72
- await this.matchRepository.setNotificationFlag(tournamentObjId, matchObjId, job.name);
73
- });
67
+ async resolveCouponConfig(tournamentId) {
68
+ const tournament = await this.configRepository.findById(tournamentId);
69
+ if (!MatchEvaluationOrchestrator_1.isCouponReward(tournament?.reward))
70
+ return null;
71
+ const { percentage, maxDiscountPerOrder, couponNamePrefix } = tournament.reward;
72
+ if (percentage === undefined || maxDiscountPerOrder == null || !couponNamePrefix)
73
+ return null;
74
+ return { percentage, maxDiscountPerOrder, couponNamePrefix };
75
+ }
76
+ static isCouponReward(reward) {
77
+ return reward?.type === enum_1.TournamentRewardType.COUPON;
74
78
  }
75
79
  };
76
- exports.TournamentNotificationWorker = TournamentNotificationWorker;
77
- exports.TournamentNotificationWorker = TournamentNotificationWorker = __decorate([
80
+ exports.MatchEvaluationOrchestrator = MatchEvaluationOrchestrator;
81
+ exports.MatchEvaluationOrchestrator = MatchEvaluationOrchestrator = MatchEvaluationOrchestrator_1 = __decorate([
78
82
  (0, typedi_1.Service)(),
79
83
  __metadata("design:paramtypes", [])
80
- ], TournamentNotificationWorker);
81
- exports.tournamentNotificationWorker = typedi_1.default.get(TournamentNotificationWorker);
82
- //# sourceMappingURL=notification.worker.js.map
84
+ ], MatchEvaluationOrchestrator);
85
+ exports.matchEvaluationOrchestrator = typedi_1.default.get(MatchEvaluationOrchestrator);
86
+ //# sourceMappingURL=match-evaluation.orchestrator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"match-evaluation.orchestrator.js","sourceRoot":"/","sources":["modules/tournament/match/events/match-evaluation.orchestrator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAO1C,4DAAuE;AACvE,4EAAsE;AACtE,gEAA0D;AAG1D,kFAAsF;AACtF,0GAAmG;AACnG,sEAA0E;AAGnE,IAAM,2BAA2B,mCAAjC,MAAM,2BAA2B;IAC5B,iBAAiB,CAAoB;IACrC,aAAa,CAAgB;IAC7B,mBAAmB,CAAgC;IACnD,kBAAkB,CAAiC;IACnD,gBAAgB,CAA6B;IAErD;QACI,IAAI,CAAC,iBAAiB,GAAG,gBAAS,CAAC,GAAG,CAAC,sCAAiB,CAAC,CAAC;QAC1D,IAAI,CAAC,aAAa,GAAG,gBAAS,CAAC,GAAG,CAAC,8BAAa,CAAC,CAAC;QAClD,IAAI,CAAC,mBAAmB,GAAG,gBAAS,CAAC,GAAG,CAAC,oDAA6B,CAAC,CAAC;QACxE,IAAI,CAAC,kBAAkB,GAAG,gBAAS,CAAC,GAAG,CAAC,iEAA8B,CAAC,CAAC;QACxE,IAAI,CAAC,gBAAgB,GAAG,gBAAS,CAAC,GAAG,CAAC,8CAA0B,CAAC,CAAC;IACtE,CAAC;IAGM,KAAK,CAAC,mBAAmB,CAAC,YAAqC;QAClE,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QACtE,IAAI,CAAC,6BAA2B,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC;YAAE,OAAO,IAAI,CAAC;QAEjF,MAAM,EAAC,UAAU,EAAE,mBAAmB,EAAE,gBAAgB,EAAC,GAAG,UAAW,CAAC,MAAgC,CAAC;QACzG,IAAI,UAAU,KAAK,SAAS,IAAI,mBAAmB,IAAI,IAAI,IAAI,CAAC,gBAAgB;YAAE,OAAO,IAAI,CAAC;QAE9F,OAAO,EAAC,UAAU,EAAE,mBAAmB,EAAE,gBAAgB,EAAC,CAAC;IAC/D,CAAC;IAEO,MAAM,CAAC,cAAc,CAAC,MAAoC;QAC9D,OAAO,MAAM,EAAE,IAAI,KAAK,2BAAoB,CAAC,MAAM,CAAC;IACxD,CAAC;CACJ,CAAA;AA7BY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,gBAAO,GAAE;;GACG,2BAA2B,CA6BvC;AAEY,QAAA,2BAA2B,GAAG,gBAAS,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {\n NotificationMessage,\n TournamentCouponReward,\n TournamentReward,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {TournamentRewardType} from '@lyxa.ai/core/dist/utilities/enum';\nimport {PredictionService} from '../../prediction/prediction.service';\nimport {RewardService} from '../../reward/reward.service';\nimport {RewardBuilder} from '../../reward/reward.builder';\nimport {CouponRewardConfig, RewardType} from '../../reward/reward.types';\nimport {TournamentNotificationService} from '../../notification/notification.service';\nimport {NotificationTemplateRepository} from '../../notification/notification-template.repository';\nimport {TournamentConfigRepository} from '../../config/config.repository';\n\n@Service()\nexport class MatchEvaluationOrchestrator {\n private predictionService: PredictionService;\n private rewardService: RewardService;\n private notificationService: TournamentNotificationService;\n private templateRepository: NotificationTemplateRepository;\n private configRepository: TournamentConfigRepository;\n\n constructor() {\n this.predictionService = Container.get(PredictionService);\n this.rewardService = Container.get(RewardService);\n this.notificationService = Container.get(TournamentNotificationService);\n this.templateRepository = Container.get(NotificationTemplateRepository);\n this.configRepository = Container.get(TournamentConfigRepository);\n }\n\n\n public async resolveCouponConfig(tournamentId: mongoose.Types.ObjectId): Promise<CouponRewardConfig | null> {\n const tournament = await this.configRepository.findById(tournamentId);\n if (!MatchEvaluationOrchestrator.isCouponReward(tournament?.reward)) return null;\n\n const {percentage, maxDiscountPerOrder, couponNamePrefix} = tournament!.reward as TournamentCouponReward;\n if (percentage === undefined || maxDiscountPerOrder == null || !couponNamePrefix) return null;\n\n return {percentage, maxDiscountPerOrder, couponNamePrefix};\n }\n\n private static isCouponReward(reward: TournamentReward | undefined): reward is TournamentCouponReward {\n return reward?.type === TournamentRewardType.COUPON;\n }\n}\n\nexport const matchEvaluationOrchestrator = Container.get(MatchEvaluationOrchestrator);\n"]}
@@ -1,41 +1,20 @@
1
- import { mongoose } from '@typegoose/typegoose';
2
1
  import { TournamentMatchOutputDTO, UpdateMatchScoreInputDTO } from './match.validation';
3
- interface MatchTeamRef {
4
- _id: mongoose.Types.ObjectId;
5
- name: string;
6
- }
7
- interface MatchInput {
8
- stage: string;
9
- additionalTag?: string;
10
- startingDate: Date;
11
- endDate?: Date;
12
- }
2
+ import { BuiltMatch, MatchEndUpdate, MatchInput, MatchScoreUpdate, MatchTeamRef } from './match.types';
3
+ import { EvaluatePredictionsMatch } from './events/evaluate-predictions.event';
13
4
  export declare class MatchBuilder {
14
- static buildMatch(input: MatchInput, team1: MatchTeamRef, team2: MatchTeamRef): {
15
- _id: mongoose.Types.ObjectId;
16
- additionalTag: string | undefined;
17
- stage: string;
18
- team1: {
19
- teamId: mongoose.Types.ObjectId;
20
- name: string;
21
- };
22
- team2: {
23
- teamId: mongoose.Types.ObjectId;
24
- name: string;
25
- };
26
- score: {
27
- team1: null;
28
- team2: null;
29
- };
30
- winnerId: null;
31
- startingDate: Date;
32
- endDate: Date | undefined;
33
- };
34
- static buildScoreUpdate(input: UpdateMatchScoreInputDTO): Record<string, unknown>;
5
+ static buildMatch(input: MatchInput, team1: MatchTeamRef, team2: MatchTeamRef): BuiltMatch;
6
+ static buildScoreUpdate(input: UpdateMatchScoreInputDTO): MatchScoreUpdate;
35
7
  static buildEndUpdate(match: TournamentMatchOutputDTO, finalScore?: {
36
8
  team1: number;
37
9
  team2: number;
38
- }): Record<string, unknown>;
10
+ }): MatchEndUpdate;
11
+ static buildEnd(match: TournamentMatchOutputDTO, matchNumber: number, finalScore?: {
12
+ team1: number;
13
+ team2: number;
14
+ }): {
15
+ update: MatchEndUpdate;
16
+ evaluation: EvaluatePredictionsMatch | null;
17
+ };
18
+ private static resolveWinnerId;
39
19
  }
40
- export {};
41
20
  //# sourceMappingURL=match.builder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"match.builder.d.ts","sourceRoot":"/","sources":["modules/tournament/match/match.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,wBAAwB,EAAE,wBAAwB,EAAC,MAAM,oBAAoB,CAAC;AAGtF,UAAU,YAAY;IAClB,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,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;IAYjB,MAAM,CAAC,QAAQ,CACX,KAAK,EAAE,wBAAwB,EAC/B,WAAW,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,GAC5C;QAAC,MAAM,EAAE,cAAc,CAAC;QAAC,UAAU,EAAE,wBAAwB,GAAG,IAAI,CAAA;KAAC;IAYxE,OAAO,CAAC,MAAM,CAAC,eAAe;CAUjC"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MatchBuilder = void 0;
4
4
  const typegoose_1 = require("@typegoose/typegoose");
5
+ const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
5
6
  const tournament_utils_1 = require("../tournament.utils");
6
7
  class MatchBuilder {
7
8
  static buildMatch(input, team1, team2) {
@@ -18,26 +19,46 @@ class MatchBuilder {
18
19
  };
19
20
  }
20
21
  static buildScoreUpdate(input) {
21
- const updates = {
22
+ const update = {
22
23
  score: { team1: input.team1Score, team2: input.team2Score },
23
24
  };
24
25
  if (input.winnerId !== undefined)
25
- updates.winnerId = input.winnerId;
26
- return updates;
26
+ update.winnerId = input.winnerId;
27
+ return update;
27
28
  }
28
29
  static buildEndUpdate(match, finalScore) {
29
30
  const score = finalScore ?? match.score;
30
- const { team1, team2 } = score;
31
- const winnerId = team1 !== null && team2 !== null
32
- ? team1 > team2 ? match.team1.teamId
33
- : team2 > team1 ? match.team2.teamId
34
- : null
35
- : null;
36
- const update = { endDate: (0, tournament_utils_1.utcNow)(), winnerId };
31
+ const update = {
32
+ endDate: (0, tournament_utils_1.utcNow)(),
33
+ matchEnded: true,
34
+ matchStatus: enum_1.TournamentMatchStatus.ENDED,
35
+ winnerId: MatchBuilder.resolveWinnerId(match, score),
36
+ };
37
37
  if (finalScore)
38
38
  update.score = finalScore;
39
39
  return update;
40
40
  }
41
+ static buildEnd(match, matchNumber, finalScore) {
42
+ const update = MatchBuilder.buildEndUpdate(match, finalScore);
43
+ const score = finalScore ?? match.score;
44
+ if (score.team1 == null || score.team2 == null) {
45
+ return { update, evaluation: null };
46
+ }
47
+ return {
48
+ update,
49
+ evaluation: { matchId: match._id, matchNumber, finalScore: { team1: score.team1, team2: score.team2 } },
50
+ };
51
+ }
52
+ static resolveWinnerId(match, score) {
53
+ const { team1, team2 } = score;
54
+ if (team1 == null || team2 == null)
55
+ return null;
56
+ if (team1 > team2)
57
+ return match.team1.teamId;
58
+ if (team2 > team1)
59
+ return match.team2.teamId;
60
+ return null;
61
+ }
41
62
  }
42
63
  exports.MatchBuilder = MatchBuilder;
43
64
  //# sourceMappingURL=match.builder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"match.builder.js","sourceRoot":"/","sources":["modules/tournament/match/match.builder.ts"],"names":[],"mappings":";;;AAAA,oDAA8C;AAE9C,0DAA2C;AAc3C,MAAa,YAAY;IACrB,MAAM,CAAC,UAAU,CAAC,KAAiB,EAAE,KAAmB,EAAE,KAAmB;QACzE,OAAO;YACH,GAAG,EAAE,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE;YAClC,aAAa,EAAE,KAAK,CAAC,aAAa;YAClC,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,KAAK,EAAE,EAAC,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAC;YAC5C,KAAK,EAAE,EAAC,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAC;YAC5C,KAAK,EAAE,EAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAC;YACjC,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,OAAO,EAAE,KAAK,CAAC,OAAO;SACzB,CAAC;IACN,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,KAA+B;QACnD,MAAM,OAAO,GAA4B;YACrC,KAAK,EAAE,EAAC,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU,EAAC;SAC5D,CAAC;QACF,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS;YAAE,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QACpE,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,cAAc,CACjB,KAA+B,EAC/B,UAA2C;QAE3C,MAAM,KAAK,GAAG,UAAU,IAAI,KAAK,CAAC,KAAK,CAAC;QACxC,MAAM,EAAC,KAAK,EAAE,KAAK,EAAC,GAAG,KAAK,CAAC;QAC7B,MAAM,QAAQ,GACV,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,IAAI;YAC5B,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM;gBACpC,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM;oBACpC,CAAC,CAAC,IAAI;YACV,CAAC,CAAC,IAAI,CAAC;QAEX,MAAM,MAAM,GAA4B,EAAC,OAAO,EAAE,IAAA,yBAAM,GAAE,EAAE,QAAQ,EAAC,CAAC;QACtE,IAAI,UAAU;YAAE,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC;QAC1C,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAxCD,oCAwCC","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\nimport {TournamentMatchOutputDTO, UpdateMatchScoreInputDTO} from './match.validation';\nimport {utcNow} from '../tournament.utils';\n\ninterface MatchTeamRef {\n _id: mongoose.Types.ObjectId;\n name: string;\n}\n\ninterface MatchInput {\n stage: string;\n additionalTag?: string;\n startingDate: Date;\n endDate?: Date;\n}\n\nexport class MatchBuilder {\n static buildMatch(input: MatchInput, team1: MatchTeamRef, team2: MatchTeamRef) {\n return {\n _id: new mongoose.Types.ObjectId(),\n additionalTag: input.additionalTag,\n stage: input.stage,\n team1: {teamId: team1._id, name: team1.name},\n team2: {teamId: team2._id, name: team2.name},\n score: {team1: null, team2: null},\n winnerId: null,\n startingDate: input.startingDate,\n endDate: input.endDate,\n };\n }\n\n static buildScoreUpdate(input: UpdateMatchScoreInputDTO): Record<string, unknown> {\n const updates: Record<string, unknown> = {\n score: {team1: input.team1Score, team2: input.team2Score},\n };\n if (input.winnerId !== undefined) updates.winnerId = input.winnerId;\n return updates;\n }\n\n static buildEndUpdate(\n match: TournamentMatchOutputDTO,\n finalScore?: {team1: number; team2: number}\n ): Record<string, unknown> {\n const score = finalScore ?? match.score;\n const {team1, team2} = score;\n const winnerId =\n team1 !== null && team2 !== null\n ? team1 > team2 ? match.team1.teamId\n : team2 > team1 ? match.team2.teamId\n : null\n : null;\n\n const update: Record<string, unknown> = {endDate: utcNow(), winnerId};\n if (finalScore) update.score = finalScore;\n return update;\n }\n}\n"]}
1
+ {"version":3,"file":"match.builder.js","sourceRoot":"/","sources":["modules/tournament/match/match.builder.ts"],"names":[],"mappings":";;;AAAA,oDAA8C;AAC9C,4DAAwE;AAIxE,0DAA2C;AAE3C,MAAa,YAAY;IACrB,MAAM,CAAC,UAAU,CAAC,KAAiB,EAAE,KAAmB,EAAE,KAAmB;QACzE,OAAO;YACH,GAAG,EAAE,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE;YAClC,aAAa,EAAE,KAAK,CAAC,aAAa;YAClC,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,KAAK,EAAE,EAAC,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAC;YAC5C,KAAK,EAAE,EAAC,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAC;YAC5C,KAAK,EAAE,EAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAC;YACjC,QAAQ,EAAE,IAAI;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AO,EAAE,KAAK,CAAC,GAAG,EAAE,WAAW,EAAE,UAAU,EAAE,EAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAC,EAAC;SACtG,CAAC;IACN,CAAC;IAEO,MAAM,CAAC,eAAe,CAC1B,KAA+B,EAC/B,KAAmD;QAEnD,MAAM,EAAC,KAAK,EAAE,KAAK,EAAC,GAAG,KAAK,CAAC;QAC7B,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC;QAChD,IAAI,KAAK,GAAG,KAAK;YAAE,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC;QAC7C,IAAI,KAAK,GAAG,KAAK;YAAE,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC;QAC7C,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAhED,oCAgEC","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\nimport {TournamentMatchStatus} from '@lyxa.ai/core/dist/utilities/enum';\nimport {TournamentMatchOutputDTO, UpdateMatchScoreInputDTO} from './match.validation';\nimport {BuiltMatch, MatchEndUpdate, MatchInput, MatchScoreUpdate, MatchTeamRef} from './match.types';\nimport {EvaluatePredictionsMatch} from './events/evaluate-predictions.event';\nimport {utcNow} from '../tournament.utils';\n\nexport class MatchBuilder {\n static buildMatch(input: MatchInput, team1: MatchTeamRef, team2: MatchTeamRef): BuiltMatch {\n return {\n _id: new mongoose.Types.ObjectId(),\n additionalTag: input.additionalTag,\n stage: input.stage,\n team1: {teamId: team1._id, name: team1.name},\n team2: {teamId: team2._id, name: team2.name},\n score: {team1: null, team2: null},\n winnerId: null,\n startingDate: input.startingDate,\n endDate: input.endDate,\n };\n }\n\n static buildScoreUpdate(input: UpdateMatchScoreInputDTO): MatchScoreUpdate {\n const update: MatchScoreUpdate = {\n score: {team1: input.team1Score, team2: input.team2Score},\n };\n if (input.winnerId !== undefined) update.winnerId = input.winnerId;\n return update;\n }\n\n static buildEndUpdate(\n match: TournamentMatchOutputDTO,\n finalScore?: {team1: number; team2: number}\n ): MatchEndUpdate {\n const score = finalScore ?? match.score;\n const update: MatchEndUpdate = {\n endDate: utcNow(),\n matchEnded: true,\n matchStatus: TournamentMatchStatus.ENDED,\n winnerId: MatchBuilder.resolveWinnerId(match, score),\n };\n if (finalScore) update.score = finalScore;\n return update;\n }\n\n static buildEnd(\n match: TournamentMatchOutputDTO,\n matchNumber: number,\n finalScore?: {team1: number; team2: number}\n ): {update: MatchEndUpdate; evaluation: EvaluatePredictionsMatch | null} {\n const update = MatchBuilder.buildEndUpdate(match, finalScore);\n const score = finalScore ?? match.score;\n if (score.team1 == null || score.team2 == null) {\n return {update, evaluation: null};\n }\n return {\n update,\n evaluation: {matchId: match._id, matchNumber, finalScore: {team1: score.team1, team2: score.team2}},\n };\n }\n\n private static resolveWinnerId(\n match: TournamentMatchOutputDTO,\n score: {team1: number | null; team2: number | null}\n ): mongoose.Types.ObjectId | null {\n const {team1, team2} = score;\n if (team1 == null || team2 == null) return null;\n if (team1 > team2) return match.team1.teamId;\n if (team2 > team1) return match.team2.teamId;\n return null;\n }\n}\n"]}
@@ -5,7 +5,7 @@ export declare class TournamentMatchRepository {
5
5
  constructor();
6
6
  findById(id: mongoose.Types.ObjectId): Promise<Model | null>;
7
7
  addMatches(id: mongoose.Types.ObjectId, matches: object[]): Promise<Model | null>;
8
- updateMatch(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, updates: Record<string, unknown>): Promise<Model | null>;
8
+ updateMatch<T extends object>(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, updates: T): Promise<Model | null>;
9
9
  deleteMatch(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<Model | null>;
10
10
  findMatchInTournament(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<Model | null>;
11
11
  getNotificationFlag(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, type: string): Promise<boolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"match.repository.d.ts","sourceRoot":"/","sources":["modules/tournament/match/match.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,UAAU,IAAI,KAAK,EAAmB,MAAM,2CAA2C,CAAC;AAEjG,qBACa,yBAAyB;IACrC,OAAO,CAAC,KAAK,CAAyB;;IAMhC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAI5D,UAAU,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAMjF,WAAW,CAChB,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAalB,WAAW,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAM3G,qBAAqB,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAMrH,mBAAmB,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,OAA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AK,IAAI,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,YAAqC,EAAE,OAAgC,EAAE,IAAY;QAC9G,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,CACzB,EAAE,GAAG,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,EAC7C,EAAE,IAAI,EAAE,EAAE,CAAC,+BAA+B,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,CAC3D,CAAC;IACH,CAAC;CACD,CAAA;AA5DY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,gBAAO,GAAE;;GACG,yBAAyB,CA4DrC;AAEY,QAAA,yBAAyB,GAAG,gBAAS,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport { Tournament as Model, TournamentModel } from '@lyxa.ai/core/dist/libraries/mongo/models';\n\n@Service()\nexport class TournamentMatchRepository {\n\tprivate model: typeof TournamentModel;\n\n\tconstructor() {\n\t\tthis.model = TournamentModel;\n\t}\n\n\tasync findById(id: mongoose.Types.ObjectId): Promise<Model | null> {\n\t\treturn this.model.findById(id).lean() as Promise<Model | null>;\n\t}\n\n\tasync addMatches(id: mongoose.Types.ObjectId, matches: object[]): Promise<Model | null> {\n\t\treturn this.model\n\t\t\t.findByIdAndUpdate(id, { $push: { matches: { $each: matches } } }, { new: true })\n\t\t\t.lean() as Promise<Model | null>;\n\t}\n\n\tasync updateMatch(\n\t\ttournamentId: mongoose.Types.ObjectId,\n\t\tmatchId: mongoose.Types.ObjectId,\n\t\tupdates: Record<string, unknown>\n\t): Promise<Model | null> {\n\t\tconst setUpdates = Object.fromEntries(\n\t\t\tObject.entries(updates).map(([key, value]) => [`matches.$.${key}`, value])\n\t\t);\n\t\treturn this.model\n\t\t\t.findOneAndUpdate(\n\t\t\t\t{ _id: tournamentId, 'matches._id': matchId },\n\t\t\t\t{ $set: setUpdates },\n\t\t\t\t{ new: true }\n\t\t\t)\n\t\t\t.lean() as Promise<Model | null>;\n\t}\n\n\tasync deleteMatch(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<Model | null> {\n\t\treturn this.model\n\t\t\t.findByIdAndUpdate(tournamentId, { $pull: { matches: { _id: matchId } } }, { new: true })\n\t\t\t.lean() as Promise<Model | null>;\n\t}\n\n\tasync findMatchInTournament(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<Model | null> {\n\t\treturn this.model\n\t\t\t.findOne({ _id: tournamentId, 'matches._id': matchId })\n\t\t\t.lean() as Promise<Model | null>;\n\t}\n\n\tasync getNotificationFlag(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, type: string): Promise<boolean> {\n\t\tconst doc = await this.model\n\t\t\t.findOne({ _id: tournamentId, 'matches._id': matchId }, { 'matches.$': 1 })\n\t\t\t.lean();\n\t\tconst match = doc?.matches?.[0] as any;\n\t\treturn match?.notificationFlags?.[type] === true;\n\t}\n\n\tasync setNotificationFlag(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, type: string): Promise<void> {\n\t\tawait this.model.updateOne(\n\t\t\t{ _id: tournamentId, 'matches._id': matchId },\n\t\t\t{ $set: { [`matches.$.notificationFlags.${type}`]: true } }\n\t\t);\n\t}\n}\n\nexport const tournamentMatchRepository = Container.get(TournamentMatchRepository);\n"]}
1
+ {"version":3,"file":"match.repository.js","sourceRoot":"/","sources":["modules/tournament/match/match.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,sEAAiG;AAG1F,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAC7B,KAAK,CAAyB;IAEtC;QACC,IAAI,CAAC,KAAK,GAAG,wBAAe,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,EAA2B;QACzC,OAAO,IAAI,CAA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,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC;aACtD,IAAI,EAA2B,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,YAAqC,EAAE,OAAgC,EAAE,IAAY;QAC9G,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK;aAC1B,OAAO,CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;aAC1E,IAAI,EAAE,CAAC;QACT,MAAM,KAAK,GAAG,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC,CAAQ,CAAC;QACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,YAAqC,EAAE,OAAgC,EAAE,IAAY;QAC9G,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,CACzB,EAAE,GAAG,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,EAC7C,EAAE,IAAI,EAAE,EAAE,CAAC,+BAA+B,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,CAC3D,CAAC;IACH,CAAC;CACD,CAAA;AA5DY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,gBAAO,GAAE;;GACG,yBAAyB,CA4DrC;AAEY,QAAA,yBAAyB,GAAG,gBAAS,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport { Tournament as Model, TournamentModel } from '@lyxa.ai/core/dist/libraries/mongo/models';\n\n@Service()\nexport class TournamentMatchRepository {\n\tprivate model: typeof TournamentModel;\n\n\tconstructor() {\n\t\tthis.model = TournamentModel;\n\t}\n\n\tasync findById(id: mongoose.Types.ObjectId): Promise<Model | null> {\n\t\treturn this.model.findById(id).lean() as Promise<Model | null>;\n\t}\n\n\tasync addMatches(id: mongoose.Types.ObjectId, matches: object[]): Promise<Model | null> {\n\t\treturn this.model\n\t\t\t.findByIdAndUpdate(id, { $push: { matches: { $each: matches } } }, { new: true })\n\t\t\t.lean() as Promise<Model | null>;\n\t}\n\n\tasync updateMatch<T extends object>(\n\t\ttournamentId: mongoose.Types.ObjectId,\n\t\tmatchId: mongoose.Types.ObjectId,\n\t\tupdates: T\n\t): Promise<Model | null> {\n\t\tconst setUpdates = Object.fromEntries(\n\t\t\tObject.entries(updates).map(([key, value]) => [`matches.$.${key}`, value])\n\t\t);\n\t\treturn this.model\n\t\t\t.findOneAndUpdate(\n\t\t\t\t{ _id: tournamentId, 'matches._id': matchId },\n\t\t\t\t{ $set: setUpdates },\n\t\t\t\t{ new: true }\n\t\t\t)\n\t\t\t.lean() as Promise<Model | null>;\n\t}\n\n\tasync deleteMatch(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<Model | null> {\n\t\treturn this.model\n\t\t\t.findByIdAndUpdate(tournamentId, { $pull: { matches: { _id: matchId } } }, { new: true })\n\t\t\t.lean() as Promise<Model | null>;\n\t}\n\n\tasync findMatchInTournament(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<Model | null> {\n\t\treturn this.model\n\t\t\t.findOne({ _id: tournamentId, 'matches._id': matchId })\n\t\t\t.lean() as Promise<Model | null>;\n\t}\n\n\tasync getNotificationFlag(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, type: string): Promise<boolean> {\n\t\tconst doc = await this.model\n\t\t\t.findOne({ _id: tournamentId, 'matches._id': matchId }, { 'matches.$': 1 })\n\t\t\t.lean();\n\t\tconst match = doc?.matches?.[0] as any;\n\t\treturn match?.notificationFlags?.[type] === true;\n\t}\n\n\tasync setNotificationFlag(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, type: string): Promise<void> {\n\t\tawait this.model.updateOne(\n\t\t\t{ _id: tournamentId, 'matches._id': matchId },\n\t\t\t{ $set: { [`matches.$.notificationFlags.${type}`]: true } }\n\t\t);\n\t}\n}\n\nexport const tournamentMatchRepository = Container.get(TournamentMatchRepository);\n"]}
@@ -32,12 +32,12 @@ export declare const matchRouter: import("@trpc/server").TRPCBuiltRouter<{
32
32
  data?: {
33
33
  status: import("@lyxa.ai/core/dist/utilities/enum").Status;
34
34
  name: string;
35
+ tag: string;
35
36
  _id?: string | import("mongoose").Types.ObjectId | undefined;
36
37
  createdAt?: Date | null | undefined;
37
38
  startDate?: Date | null | undefined;
38
39
  endDate?: Date | null | undefined;
39
40
  updatedAt?: Date | null | undefined;
40
- tag?: import("../tournament.types").TournamentTag | undefined;
41
41
  reward?: {
42
42
  type: import("@lyxa.ai/core/dist/utilities/enum").TournamentRewardType.FREE_DELIVERY;
43
43
  } | {
@@ -46,16 +46,25 @@ export declare const matchRouter: import("@trpc/server").TRPCBuiltRouter<{
46
46
  couponNamePrefix?: string | undefined;
47
47
  percentage?: number | undefined;
48
48
  } | undefined;
49
+ notificationTemplates?: Partial<Record<import("@lyxa.ai/core/dist/utilities/enum").TournamentNotificationTag, {
50
+ title: string;
51
+ body: string;
52
+ }>> | undefined;
53
+ scheduledNotifications?: {
54
+ type: import("@lyxa.ai/core/dist/utilities/enum").TournamentNotificationTag;
55
+ durationMins: number;
56
+ target: import("@lyxa.ai/core/dist/utilities/enum").TournamentScheduledNotificationTarget;
57
+ }[] | undefined;
49
58
  } | {
50
59
  documents: {
51
60
  status: import("@lyxa.ai/core/dist/utilities/enum").Status;
52
61
  name: string;
62
+ tag: string;
53
63
  _id?: string | import("mongoose").Types.ObjectId | undefined;
54
64
  createdAt?: Date | null | undefined;
55
65
  startDate?: Date | null | undefined;
56
66
  endDate?: Date | null | undefined;
57
67
  updatedAt?: Date | null | undefined;
58
- tag?: import("../tournament.types").TournamentTag | undefined;
59
68
  reward?: {
60
69
  type: import("@lyxa.ai/core/dist/utilities/enum").TournamentRewardType.FREE_DELIVERY;
61
70
  } | {
@@ -64,6 +73,15 @@ export declare const matchRouter: import("@trpc/server").TRPCBuiltRouter<{
64
73
  couponNamePrefix?: string | undefined;
65
74
  percentage?: number | undefined;
66
75
  } | undefined;
76
+ notificationTemplates?: Partial<Record<import("@lyxa.ai/core/dist/utilities/enum").TournamentNotificationTag, {
77
+ title: string;
78
+ body: string;
79
+ }>> | undefined;
80
+ scheduledNotifications?: {
81
+ type: import("@lyxa.ai/core/dist/utilities/enum").TournamentNotificationTag;
82
+ durationMins: number;
83
+ target: import("@lyxa.ai/core/dist/utilities/enum").TournamentScheduledNotificationTarget;
84
+ }[] | undefined;
67
85
  }[];
68
86
  metadata?: {
69
87
  page: number;
@@ -317,12 +335,12 @@ export declare const matchRouter: import("@trpc/server").TRPCBuiltRouter<{
317
335
  data?: {
318
336
  status: import("@lyxa.ai/core/dist/utilities/enum").Status;
319
337
  name: string;
338
+ tag: string;
320
339
  _id?: string | import("mongoose").Types.ObjectId | undefined;
321
340
  createdAt?: Date | null | undefined;
322
341
  startDate?: Date | null | undefined;
323
342
  endDate?: Date | null | undefined;
324
343
  updatedAt?: Date | null | undefined;
325
- tag?: import("../tournament.types").TournamentTag | undefined;
326
344
  reward?: {
327
345
  type: import("@lyxa.ai/core/dist/utilities/enum").TournamentRewardType.FREE_DELIVERY;
328
346
  } | {
@@ -331,16 +349,25 @@ export declare const matchRouter: import("@trpc/server").TRPCBuiltRouter<{
331
349
  couponNamePrefix?: string | undefined;
332
350
  percentage?: number | undefined;
333
351
  } | undefined;
352
+ notificationTemplates?: Partial<Record<import("@lyxa.ai/core/dist/utilities/enum").TournamentNotificationTag, {
353
+ title: string;
354
+ body: string;
355
+ }>> | undefined;
356
+ scheduledNotifications?: {
357
+ type: import("@lyxa.ai/core/dist/utilities/enum").TournamentNotificationTag;
358
+ durationMins: number;
359
+ target: import("@lyxa.ai/core/dist/utilities/enum").TournamentScheduledNotificationTarget;
360
+ }[] | undefined;
334
361
  } | {
335
362
  documents: {
336
363
  status: import("@lyxa.ai/core/dist/utilities/enum").Status;
337
364
  name: string;
365
+ tag: string;
338
366
  _id?: string | import("mongoose").Types.ObjectId | undefined;
339
367
  createdAt?: Date | null | undefined;
340
368
  startDate?: Date | null | undefined;
341
369
  endDate?: Date | null | undefined;
342
370
  updatedAt?: Date | null | undefined;
343
- tag?: import("../tournament.types").TournamentTag | undefined;
344
371
  reward?: {
345
372
  type: import("@lyxa.ai/core/dist/utilities/enum").TournamentRewardType.FREE_DELIVERY;
346
373
  } | {
@@ -349,6 +376,15 @@ export declare const matchRouter: import("@trpc/server").TRPCBuiltRouter<{
349
376
  couponNamePrefix?: string | undefined;
350
377
  percentage?: number | undefined;
351
378
  } | undefined;
379
+ notificationTemplates?: Partial<Record<import("@lyxa.ai/core/dist/utilities/enum").TournamentNotificationTag, {
380
+ title: string;
381
+ body: string;
382
+ }>> | undefined;
383
+ scheduledNotifications?: {
384
+ type: import("@lyxa.ai/core/dist/utilities/enum").TournamentNotificationTag;
385
+ durationMins: number;
386
+ target: import("@lyxa.ai/core/dist/utilities/enum").TournamentScheduledNotificationTarget;
387
+ }[] | undefined;
352
388
  }[];
353
389
  metadata?: {
354
390
  page: number;
@@ -1 +1 @@
1
- {"version":3,"file":"match.router.d.ts","sourceRoot":"/","sources":["modules/tournament/match/match.router.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDtB,CAAC"}
1
+ {"version":3,"file":"match.router.d.ts","sourceRoot":"/","sources":["modules/tournament/match/match.router.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDtB,CAAC"}