@lyxa.ai/marketing 1.0.48 → 1.0.50

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 (324) hide show
  1. package/dist/lib/event/event-initializations.js +2 -2
  2. package/dist/lib/event/event-initializations.js.map +1 -1
  3. package/dist/lib/index.d.ts +462 -508
  4. package/dist/lib/index.d.ts.map +1 -1
  5. package/dist/lib/modules/coupon/services/coupon.service.d.ts +2 -2
  6. package/dist/lib/modules/coupon/services/coupon.service.d.ts.map +1 -1
  7. package/dist/lib/modules/coupon/services/coupon.service.js.map +1 -1
  8. package/dist/lib/modules/coupon/services/global-coupon.service.d.ts.map +1 -1
  9. package/dist/lib/modules/coupon/services/global-coupon.service.js +2 -0
  10. package/dist/lib/modules/coupon/services/global-coupon.service.js.map +1 -1
  11. package/dist/lib/modules/coupon/services/helper.service.d.ts.map +1 -1
  12. package/dist/lib/modules/coupon/services/helper.service.js +2 -0
  13. package/dist/lib/modules/coupon/services/helper.service.js.map +1 -1
  14. package/dist/lib/modules/coupon/services/individual-user-coupon.service.d.ts.map +1 -1
  15. package/dist/lib/modules/coupon/services/individual-user-coupon.service.js +2 -0
  16. package/dist/lib/modules/coupon/services/individual-user-coupon.service.js.map +1 -1
  17. package/dist/lib/modules/coupon/services/referral-reward-coupon.service.d.ts.map +1 -1
  18. package/dist/lib/modules/coupon/services/referral-reward-coupon.service.js +2 -0
  19. package/dist/lib/modules/coupon/services/referral-reward-coupon.service.js.map +1 -1
  20. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts +10 -21
  21. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
  22. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js +5 -4
  23. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js.map +1 -1
  24. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +154 -0
  25. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts.map +1 -1
  26. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js +13 -1
  27. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js.map +1 -1
  28. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts +8 -2
  29. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
  30. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js +11 -2
  31. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js.map +1 -1
  32. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts +10 -21
  33. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
  34. package/dist/lib/modules/tournament/config/config.builder.d.ts.map +1 -1
  35. package/dist/lib/modules/tournament/config/config.builder.js +4 -0
  36. package/dist/lib/modules/tournament/config/config.builder.js.map +1 -1
  37. package/dist/lib/modules/tournament/config/config.repository.d.ts +4 -0
  38. package/dist/lib/modules/tournament/config/config.repository.d.ts.map +1 -1
  39. package/dist/lib/modules/tournament/config/config.repository.js +10 -1
  40. package/dist/lib/modules/tournament/config/config.repository.js.map +1 -1
  41. package/dist/lib/modules/tournament/config/config.router.d.ts +106 -218
  42. package/dist/lib/modules/tournament/config/config.router.d.ts.map +1 -1
  43. package/dist/lib/modules/tournament/config/config.service.d.ts +2 -2
  44. package/dist/lib/modules/tournament/config/config.service.d.ts.map +1 -1
  45. package/dist/lib/modules/tournament/config/config.service.js.map +1 -1
  46. package/dist/lib/modules/tournament/config/config.validation.d.ts +446 -692
  47. package/dist/lib/modules/tournament/config/config.validation.d.ts.map +1 -1
  48. package/dist/lib/modules/tournament/config/config.validation.js +44 -28
  49. package/dist/lib/modules/tournament/config/config.validation.js.map +1 -1
  50. package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.d.ts +2 -0
  51. package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.d.ts.map +1 -0
  52. package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js +28 -0
  53. package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js.map +1 -0
  54. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.d.ts +15 -0
  55. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.d.ts.map +1 -0
  56. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.js +12 -0
  57. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.js.map +1 -0
  58. package/dist/lib/modules/tournament/match/match.builder.d.ts +5 -2
  59. package/dist/lib/modules/tournament/match/match.builder.d.ts.map +1 -1
  60. package/dist/lib/modules/tournament/match/match.builder.js +13 -7
  61. package/dist/lib/modules/tournament/match/match.builder.js.map +1 -1
  62. package/dist/lib/modules/tournament/match/match.repository.d.ts +2 -0
  63. package/dist/lib/modules/tournament/match/match.repository.d.ts.map +1 -1
  64. package/dist/lib/modules/tournament/match/match.repository.js +10 -0
  65. package/dist/lib/modules/tournament/match/match.repository.js.map +1 -1
  66. package/dist/lib/modules/tournament/match/match.router.d.ts +66 -191
  67. package/dist/lib/modules/tournament/match/match.router.d.ts.map +1 -1
  68. package/dist/lib/modules/tournament/match/match.router.js +0 -7
  69. package/dist/lib/modules/tournament/match/match.router.js.map +1 -1
  70. package/dist/lib/modules/tournament/match/match.service.d.ts +1 -12
  71. package/dist/lib/modules/tournament/match/match.service.d.ts.map +1 -1
  72. package/dist/lib/modules/tournament/match/match.service.js +18 -68
  73. package/dist/lib/modules/tournament/match/match.service.js.map +1 -1
  74. package/dist/lib/modules/tournament/match/match.validation.d.ts +96 -34
  75. package/dist/lib/modules/tournament/match/match.validation.d.ts.map +1 -1
  76. package/dist/lib/modules/tournament/match/match.validation.js +5 -2
  77. package/dist/lib/modules/tournament/match/match.validation.js.map +1 -1
  78. package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts +2 -5
  79. package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts.map +1 -1
  80. package/dist/lib/modules/tournament/notification/jobs/notification.producer.js +1 -6
  81. package/dist/lib/modules/tournament/notification/jobs/notification.producer.js.map +1 -1
  82. package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts +2 -0
  83. package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts.map +1 -1
  84. package/dist/lib/modules/tournament/notification/jobs/notification.worker.js +15 -9
  85. package/dist/lib/modules/tournament/notification/jobs/notification.worker.js.map +1 -1
  86. package/dist/lib/modules/tournament/notification/notification-template.repository.d.ts +8 -0
  87. package/dist/lib/modules/tournament/notification/notification-template.repository.d.ts.map +1 -0
  88. package/dist/lib/modules/tournament/notification/notification-template.repository.js +60 -0
  89. package/dist/lib/modules/tournament/notification/notification-template.repository.js.map +1 -0
  90. package/dist/lib/modules/tournament/notification/notification.config.d.ts +10 -0
  91. package/dist/lib/modules/tournament/notification/notification.config.d.ts.map +1 -0
  92. package/dist/lib/modules/tournament/notification/notification.config.js +15 -0
  93. package/dist/lib/modules/tournament/notification/notification.config.js.map +1 -0
  94. package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts +10 -0
  95. package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts.map +1 -0
  96. package/dist/lib/modules/tournament/notification/notification.schedule.config.js +15 -0
  97. package/dist/lib/modules/tournament/notification/notification.schedule.config.js.map +1 -0
  98. package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts +4 -4
  99. package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts.map +1 -1
  100. package/dist/lib/modules/tournament/notification/notification.scheduler.service.js +15 -28
  101. package/dist/lib/modules/tournament/notification/notification.scheduler.service.js.map +1 -1
  102. package/dist/lib/modules/tournament/notification/notification.service.d.ts +5 -3
  103. package/dist/lib/modules/tournament/notification/notification.service.d.ts.map +1 -1
  104. package/dist/lib/modules/tournament/notification/notification.service.js +33 -23
  105. package/dist/lib/modules/tournament/notification/notification.service.js.map +1 -1
  106. package/dist/lib/modules/tournament/participant/participant.repository.d.ts +1 -0
  107. package/dist/lib/modules/tournament/participant/participant.repository.d.ts.map +1 -1
  108. package/dist/lib/modules/tournament/participant/participant.repository.js +6 -0
  109. package/dist/lib/modules/tournament/participant/participant.repository.js.map +1 -1
  110. package/dist/lib/modules/tournament/participant/participant.router.d.ts +9 -9
  111. package/dist/lib/modules/tournament/participant/participant.validation.d.ts +84 -84
  112. package/dist/lib/modules/tournament/prediction/prediction.builder.d.ts.map +1 -1
  113. package/dist/lib/modules/tournament/prediction/prediction.builder.js +3 -2
  114. package/dist/lib/modules/tournament/prediction/prediction.builder.js.map +1 -1
  115. package/dist/lib/modules/tournament/prediction/prediction.repository.d.ts +4 -1
  116. package/dist/lib/modules/tournament/prediction/prediction.repository.d.ts.map +1 -1
  117. package/dist/lib/modules/tournament/prediction/prediction.repository.js +20 -2
  118. package/dist/lib/modules/tournament/prediction/prediction.repository.js.map +1 -1
  119. package/dist/lib/modules/tournament/prediction/prediction.router.d.ts +12 -12
  120. package/dist/lib/modules/tournament/prediction/prediction.service.d.ts +9 -0
  121. package/dist/lib/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
  122. package/dist/lib/modules/tournament/prediction/prediction.service.js +30 -4
  123. package/dist/lib/modules/tournament/prediction/prediction.service.js.map +1 -1
  124. package/dist/lib/modules/tournament/prediction/prediction.validation.d.ts +64 -64
  125. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.d.ts +3 -0
  126. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.d.ts.map +1 -1
  127. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.js +21 -5
  128. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.js.map +1 -1
  129. package/dist/lib/modules/tournament/reward/reward.builder.d.ts +6 -0
  130. package/dist/lib/modules/tournament/reward/reward.builder.d.ts.map +1 -0
  131. package/dist/lib/modules/tournament/reward/reward.builder.js +44 -0
  132. package/dist/lib/modules/tournament/reward/reward.builder.js.map +1 -0
  133. package/dist/lib/modules/tournament/reward/reward.interface.d.ts.map +1 -1
  134. package/dist/lib/modules/tournament/reward/reward.interface.js.map +1 -1
  135. package/dist/lib/modules/tournament/reward/reward.repository.d.ts +8 -0
  136. package/dist/lib/modules/tournament/reward/reward.repository.d.ts.map +1 -0
  137. package/dist/lib/modules/tournament/reward/reward.repository.js +66 -0
  138. package/dist/lib/modules/tournament/reward/reward.repository.js.map +1 -0
  139. package/dist/lib/modules/tournament/reward/reward.service.d.ts.map +1 -1
  140. package/dist/lib/modules/tournament/reward/reward.service.js.map +1 -1
  141. package/dist/lib/modules/tournament/reward/reward.types.d.ts +1 -1
  142. package/dist/lib/modules/tournament/reward/reward.types.d.ts.map +1 -1
  143. package/dist/lib/modules/tournament/reward/reward.types.js.map +1 -1
  144. package/dist/lib/modules/tournament/schedule/schedule.router.d.ts +27 -0
  145. package/dist/lib/modules/tournament/schedule/schedule.router.d.ts.map +1 -0
  146. package/dist/lib/modules/tournament/schedule/schedule.router.js +17 -0
  147. package/dist/lib/modules/tournament/schedule/schedule.router.js.map +1 -0
  148. package/dist/lib/modules/tournament/schedule/schedule.service.d.ts +10 -0
  149. package/dist/lib/modules/tournament/schedule/schedule.service.d.ts.map +1 -0
  150. package/dist/lib/modules/tournament/schedule/schedule.service.js +87 -0
  151. package/dist/lib/modules/tournament/schedule/schedule.service.js.map +1 -0
  152. package/dist/lib/modules/tournament/score/score.repository.d.ts +13 -0
  153. package/dist/lib/modules/tournament/score/score.repository.d.ts.map +1 -0
  154. package/dist/lib/modules/tournament/score/score.repository.js +70 -0
  155. package/dist/lib/modules/tournament/score/score.repository.js.map +1 -0
  156. package/dist/lib/modules/tournament/score/score.router.d.ts +98 -0
  157. package/dist/lib/modules/tournament/score/score.router.d.ts.map +1 -0
  158. package/dist/lib/modules/tournament/score/score.router.js +20 -0
  159. package/dist/lib/modules/tournament/score/score.router.js.map +1 -0
  160. package/dist/lib/modules/tournament/score/score.service.d.ts +13 -0
  161. package/dist/lib/modules/tournament/score/score.service.d.ts.map +1 -0
  162. package/dist/lib/modules/tournament/score/score.service.js +109 -0
  163. package/dist/lib/modules/tournament/score/score.service.js.map +1 -0
  164. package/dist/lib/modules/tournament/score/score.validation.d.ts +375 -0
  165. package/dist/lib/modules/tournament/score/score.validation.d.ts.map +1 -0
  166. package/dist/lib/modules/tournament/score/score.validation.js +19 -0
  167. package/dist/lib/modules/tournament/score/score.validation.js.map +1 -0
  168. package/dist/lib/modules/tournament/statistics/statistics.builder.d.ts +10 -0
  169. package/dist/lib/modules/tournament/statistics/statistics.builder.d.ts.map +1 -0
  170. package/dist/lib/modules/tournament/statistics/statistics.builder.js +53 -0
  171. package/dist/lib/modules/tournament/statistics/statistics.builder.js.map +1 -0
  172. package/dist/lib/modules/tournament/statistics/statistics.router.d.ts +80 -0
  173. package/dist/lib/modules/tournament/statistics/statistics.router.d.ts.map +1 -0
  174. package/dist/lib/modules/tournament/statistics/statistics.router.js +21 -0
  175. package/dist/lib/modules/tournament/statistics/statistics.router.js.map +1 -0
  176. package/dist/lib/modules/tournament/statistics/statistics.service.d.ts +11 -0
  177. package/dist/lib/modules/tournament/statistics/statistics.service.d.ts.map +1 -0
  178. package/dist/lib/modules/tournament/statistics/statistics.service.js +80 -0
  179. package/dist/lib/modules/tournament/statistics/statistics.service.js.map +1 -0
  180. package/dist/lib/modules/tournament/statistics/statistics.validation.d.ts +404 -0
  181. package/dist/lib/modules/tournament/statistics/statistics.validation.d.ts.map +1 -0
  182. package/dist/lib/modules/tournament/statistics/statistics.validation.js +36 -0
  183. package/dist/lib/modules/tournament/statistics/statistics.validation.js.map +1 -0
  184. package/dist/lib/modules/tournament/team/team.router.d.ts +31 -57
  185. package/dist/lib/modules/tournament/team/team.router.d.ts.map +1 -1
  186. package/dist/lib/modules/tournament/team/team.service.d.ts +1 -0
  187. package/dist/lib/modules/tournament/team/team.service.d.ts.map +1 -1
  188. package/dist/lib/modules/tournament/team/team.service.js +21 -16
  189. package/dist/lib/modules/tournament/team/team.service.js.map +1 -1
  190. package/dist/lib/modules/tournament/team/team.validation.d.ts +68 -18
  191. package/dist/lib/modules/tournament/team/team.validation.d.ts.map +1 -1
  192. package/dist/lib/modules/tournament/team/team.validation.js +4 -2
  193. package/dist/lib/modules/tournament/team/team.validation.js.map +1 -1
  194. package/dist/lib/modules/tournament/tournament.router.d.ts +466 -501
  195. package/dist/lib/modules/tournament/tournament.router.d.ts.map +1 -1
  196. package/dist/lib/modules/tournament/tournament.router.js +14 -0
  197. package/dist/lib/modules/tournament/tournament.router.js.map +1 -1
  198. package/dist/lib/modules/tournament/tournament.service.d.ts +8 -0
  199. package/dist/lib/modules/tournament/tournament.service.d.ts.map +1 -0
  200. package/dist/lib/modules/tournament/tournament.service.js +63 -0
  201. package/dist/lib/modules/tournament/tournament.service.js.map +1 -0
  202. package/dist/lib/modules/tournament/tournament.types.d.ts +9 -0
  203. package/dist/lib/modules/tournament/tournament.types.d.ts.map +1 -0
  204. package/dist/lib/modules/tournament/tournament.types.js +14 -0
  205. package/dist/lib/modules/tournament/tournament.types.js.map +1 -0
  206. package/dist/lib/modules/tournament/tournament.utils.d.ts +2 -0
  207. package/dist/lib/modules/tournament/tournament.utils.d.ts.map +1 -0
  208. package/dist/lib/modules/tournament/tournament.utils.js +6 -0
  209. package/dist/lib/modules/tournament/tournament.utils.js.map +1 -0
  210. package/dist/lib/modules/tournament/tournament.validation.d.ts +133 -0
  211. package/dist/lib/modules/tournament/tournament.validation.d.ts.map +1 -0
  212. package/dist/lib/modules/tournament/tournament.validation.js +14 -0
  213. package/dist/lib/modules/tournament/tournament.validation.js.map +1 -0
  214. package/dist/types/index.d.ts +462 -508
  215. package/dist/types/index.d.ts.map +1 -1
  216. package/dist/types/modules/coupon/services/coupon.service.d.ts +2 -2
  217. package/dist/types/modules/coupon/services/coupon.service.d.ts.map +1 -1
  218. package/dist/types/modules/coupon/services/global-coupon.service.d.ts.map +1 -1
  219. package/dist/types/modules/coupon/services/helper.service.d.ts.map +1 -1
  220. package/dist/types/modules/coupon/services/individual-user-coupon.service.d.ts.map +1 -1
  221. package/dist/types/modules/coupon/services/referral-reward-coupon.service.d.ts.map +1 -1
  222. package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts +10 -21
  223. package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
  224. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +154 -0
  225. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts.map +1 -1
  226. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts +8 -2
  227. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
  228. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts +10 -21
  229. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
  230. package/dist/types/modules/tournament/config/config.builder.d.ts.map +1 -1
  231. package/dist/types/modules/tournament/config/config.repository.d.ts +4 -0
  232. package/dist/types/modules/tournament/config/config.repository.d.ts.map +1 -1
  233. package/dist/types/modules/tournament/config/config.router.d.ts +106 -218
  234. package/dist/types/modules/tournament/config/config.router.d.ts.map +1 -1
  235. package/dist/types/modules/tournament/config/config.service.d.ts +2 -2
  236. package/dist/types/modules/tournament/config/config.service.d.ts.map +1 -1
  237. package/dist/types/modules/tournament/config/config.validation.d.ts +446 -692
  238. package/dist/types/modules/tournament/config/config.validation.d.ts.map +1 -1
  239. package/dist/types/modules/tournament/match/events/evaluate-predictions.consumer.d.ts +2 -0
  240. package/dist/types/modules/tournament/match/events/evaluate-predictions.consumer.d.ts.map +1 -0
  241. package/dist/types/modules/tournament/match/events/evaluate-predictions.event.d.ts +15 -0
  242. package/dist/types/modules/tournament/match/events/evaluate-predictions.event.d.ts.map +1 -0
  243. package/dist/types/modules/tournament/match/match.builder.d.ts +5 -2
  244. package/dist/types/modules/tournament/match/match.builder.d.ts.map +1 -1
  245. package/dist/types/modules/tournament/match/match.repository.d.ts +2 -0
  246. package/dist/types/modules/tournament/match/match.repository.d.ts.map +1 -1
  247. package/dist/types/modules/tournament/match/match.router.d.ts +66 -191
  248. package/dist/types/modules/tournament/match/match.router.d.ts.map +1 -1
  249. package/dist/types/modules/tournament/match/match.service.d.ts +1 -12
  250. package/dist/types/modules/tournament/match/match.service.d.ts.map +1 -1
  251. package/dist/types/modules/tournament/match/match.validation.d.ts +96 -34
  252. package/dist/types/modules/tournament/match/match.validation.d.ts.map +1 -1
  253. package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts +2 -5
  254. package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts.map +1 -1
  255. package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts +2 -0
  256. package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts.map +1 -1
  257. package/dist/types/modules/tournament/notification/notification-template.repository.d.ts +8 -0
  258. package/dist/types/modules/tournament/notification/notification-template.repository.d.ts.map +1 -0
  259. package/dist/types/modules/tournament/notification/notification.config.d.ts +10 -0
  260. package/dist/types/modules/tournament/notification/notification.config.d.ts.map +1 -0
  261. package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts +10 -0
  262. package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts.map +1 -0
  263. package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts +4 -4
  264. package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts.map +1 -1
  265. package/dist/types/modules/tournament/notification/notification.service.d.ts +5 -3
  266. package/dist/types/modules/tournament/notification/notification.service.d.ts.map +1 -1
  267. package/dist/types/modules/tournament/participant/participant.repository.d.ts +1 -0
  268. package/dist/types/modules/tournament/participant/participant.repository.d.ts.map +1 -1
  269. package/dist/types/modules/tournament/participant/participant.router.d.ts +9 -9
  270. package/dist/types/modules/tournament/participant/participant.validation.d.ts +84 -84
  271. package/dist/types/modules/tournament/prediction/prediction.builder.d.ts.map +1 -1
  272. package/dist/types/modules/tournament/prediction/prediction.repository.d.ts +4 -1
  273. package/dist/types/modules/tournament/prediction/prediction.repository.d.ts.map +1 -1
  274. package/dist/types/modules/tournament/prediction/prediction.router.d.ts +12 -12
  275. package/dist/types/modules/tournament/prediction/prediction.service.d.ts +9 -0
  276. package/dist/types/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
  277. package/dist/types/modules/tournament/prediction/prediction.validation.d.ts +64 -64
  278. package/dist/types/modules/tournament/reward/handlers/coupon-reward.handler.d.ts +3 -0
  279. package/dist/types/modules/tournament/reward/handlers/coupon-reward.handler.d.ts.map +1 -1
  280. package/dist/types/modules/tournament/reward/reward.builder.d.ts +6 -0
  281. package/dist/types/modules/tournament/reward/reward.builder.d.ts.map +1 -0
  282. package/dist/types/modules/tournament/reward/reward.interface.d.ts.map +1 -1
  283. package/dist/types/modules/tournament/reward/reward.repository.d.ts +8 -0
  284. package/dist/types/modules/tournament/reward/reward.repository.d.ts.map +1 -0
  285. package/dist/types/modules/tournament/reward/reward.service.d.ts.map +1 -1
  286. package/dist/types/modules/tournament/reward/reward.types.d.ts +1 -1
  287. package/dist/types/modules/tournament/reward/reward.types.d.ts.map +1 -1
  288. package/dist/types/modules/tournament/schedule/schedule.router.d.ts +27 -0
  289. package/dist/types/modules/tournament/schedule/schedule.router.d.ts.map +1 -0
  290. package/dist/types/modules/tournament/schedule/schedule.service.d.ts +10 -0
  291. package/dist/types/modules/tournament/schedule/schedule.service.d.ts.map +1 -0
  292. package/dist/types/modules/tournament/score/score.repository.d.ts +13 -0
  293. package/dist/types/modules/tournament/score/score.repository.d.ts.map +1 -0
  294. package/dist/types/modules/tournament/score/score.router.d.ts +98 -0
  295. package/dist/types/modules/tournament/score/score.router.d.ts.map +1 -0
  296. package/dist/types/modules/tournament/score/score.service.d.ts +13 -0
  297. package/dist/types/modules/tournament/score/score.service.d.ts.map +1 -0
  298. package/dist/types/modules/tournament/score/score.validation.d.ts +375 -0
  299. package/dist/types/modules/tournament/score/score.validation.d.ts.map +1 -0
  300. package/dist/types/modules/tournament/statistics/statistics.builder.d.ts +10 -0
  301. package/dist/types/modules/tournament/statistics/statistics.builder.d.ts.map +1 -0
  302. package/dist/types/modules/tournament/statistics/statistics.router.d.ts +80 -0
  303. package/dist/types/modules/tournament/statistics/statistics.router.d.ts.map +1 -0
  304. package/dist/types/modules/tournament/statistics/statistics.service.d.ts +11 -0
  305. package/dist/types/modules/tournament/statistics/statistics.service.d.ts.map +1 -0
  306. package/dist/types/modules/tournament/statistics/statistics.validation.d.ts +404 -0
  307. package/dist/types/modules/tournament/statistics/statistics.validation.d.ts.map +1 -0
  308. package/dist/types/modules/tournament/team/team.router.d.ts +31 -57
  309. package/dist/types/modules/tournament/team/team.router.d.ts.map +1 -1
  310. package/dist/types/modules/tournament/team/team.service.d.ts +1 -0
  311. package/dist/types/modules/tournament/team/team.service.d.ts.map +1 -1
  312. package/dist/types/modules/tournament/team/team.validation.d.ts +68 -18
  313. package/dist/types/modules/tournament/team/team.validation.d.ts.map +1 -1
  314. package/dist/types/modules/tournament/tournament.router.d.ts +466 -501
  315. package/dist/types/modules/tournament/tournament.router.d.ts.map +1 -1
  316. package/dist/types/modules/tournament/tournament.service.d.ts +8 -0
  317. package/dist/types/modules/tournament/tournament.service.d.ts.map +1 -0
  318. package/dist/types/modules/tournament/tournament.types.d.ts +9 -0
  319. package/dist/types/modules/tournament/tournament.types.d.ts.map +1 -0
  320. package/dist/types/modules/tournament/tournament.utils.d.ts +2 -0
  321. package/dist/types/modules/tournament/tournament.utils.d.ts.map +1 -0
  322. package/dist/types/modules/tournament/tournament.validation.d.ts +133 -0
  323. package/dist/types/modules/tournament/tournament.validation.d.ts.map +1 -0
  324. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"match.validation.js","sourceRoot":"/","sources":["modules/tournament/match/match.validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,iGAA+F;AAC/F,wEAA+E;AAE/E,MAAM,gBAAgB,GAAG,OA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AG,IAAA,iCAAoB,EAAC,OAAC,CAAC,KAAK,CAAC,6BAAqB,CAAC,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { DTO, ZodValidation } from '@lyxa.ai/core/dist/utilities/validation/global-validation';\nimport { createResponseSchema } from '@lyxa.ai/core/dist/utilities/validation';\n\nconst MatchScoreSchema = z.object({\n\tteam1: ZodValidation.number('Team 1 score').nullable(),\n\tteam2: ZodValidation.number('Team 2 score').nullable(),\n});\n\nconst MatchTeamSchema = z.object({\n\tteamId: ZodValidation.objectId('Team id'),\n\tname: ZodValidation.string('Team name'),\n});\n\nconst MatchPredictionSchema = z.object({\n\tscore: MatchScoreSchema,\n\tsucceeded: z.boolean().nullable().optional(),\n});\n\nconst MatchInputSchema = z\n\t.object({\n\t\tstage: ZodValidation.string('Stage'),\n\t\tteam1Id: ZodValidation.objectId('Team 1 id'),\n\t\tteam2Id: ZodValidation.objectId('Team 2 id'),\n\t\tstartingDate: ZodValidation.date('Starting date'),\n\t\tendDate: ZodValidation.date('End date').optional(),\n\t\tadditionalTag: ZodValidation.string('Additional tag').optional(),\n\t})\n\t.superRefine((d, ctx) => {\n\t\tif (d.team1Id.toString() === d.team2Id.toString()) {\n\t\t\tctx.addIssue({ code: z.ZodIssueCode.custom, message: 'Teams must be different', path: ['team2Id'] });\n\t\t}\n\t\tif (d.endDate && d.endDate <= d.startingDate) {\n\t\t\tctx.addIssue({ code: z.ZodIssueCode.custom, message: 'End date must be after start date', path: ['endDate'] });\n\t\t}\n\t});\n\nexport const AddTournamentMatchesSchema = z.object({\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n\tmatches: z.array(MatchInputSchema).min(1, 'At least one match is required'),\n});\n\nexport const GetTournamentMatchesSchema = z.object({\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n});\n\nexport const UpdateMatchScoreSchema = z.object({\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n\tmatchId: ZodValidation.objectId('Match id'),\n\tteam1Score: ZodValidation.number('Team 1 score', { min: 0, isInt: true }),\n\tteam2Score: ZodValidation.number('Team 2 score', { min: 0, isInt: true }),\n\twinnerId: ZodValidation.objectId('Winner id').optional(),\n});\n\nexport const StartTournamentMatchSchema = z.object({\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n\tmatchId: ZodValidation.objectId('Match id'),\n});\n\nexport const EndTournamentMatchSchema = z.object({\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n\tmatchId: ZodValidation.objectId('Match id'),\n\tendDate: ZodValidation.date('End date').optional(),\n\twinnerId: ZodValidation.objectId('Winner id').optional(),\n});\n\nexport const TournamentMatchSchema = z.object({\n\t_id: ZodValidation.objectId(),\n\tadditionalTag: ZodValidation.string('Additional tag').optional(),\n\tstage: ZodValidation.string('Stage'),\n\tteam1: MatchTeamSchema,\n\tteam2: MatchTeamSchema,\n\tscore: MatchScoreSchema,\n\tprediction: MatchPredictionSchema.optional().nullable(),\n\twinnerId: ZodValidation.objectId('Winner id').nullable().optional(),\n\tstartingDate: z.date().nullable().optional(),\n\tendDate: z.date().nullable().optional(),\n});\n\nexport const TournamentMatchResponseSchema = createResponseSchema(TournamentMatchSchema);\nexport const TournamentMatchListResponseSchema = createResponseSchema(z.array(TournamentMatchSchema));\n\nexport type AddTournamentMatchesInputDTO = DTO<typeof AddTournamentMatchesSchema>;\nexport type StartTournamentMatchInputDTO = DTO<typeof StartTournamentMatchSchema>;\nexport type UpdateMatchScoreInputDTO = DTO<typeof UpdateMatchScoreSchema>;\nexport type EndTournamentMatchInputDTO = DTO<typeof EndTournamentMatchSchema>;\nexport type TournamentMatchOutputDTO = DTO<typeof TournamentMatchSchema>;\n"]}
1
+ {"version":3,"file":"match.validation.js","sourceRoot":"/","sources":["modules/tournament/match/match.validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,iGAA+F;AAC/F,wEAA+E;AAE/E,MAAM,gBAAgB,GAAG,OAAC,CAAC,MAAM,CAAC;IACjC,KAAK,EAAE,iCAAa,CAAC,MAA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AC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CACvC,CAAC,CAAC;AAEU,QAAA,6BAA6B,GAAG,IAAA,iCAAoB,EAAC,6BAAqB,CAAC,CAAC;AAC5E,QAAA,iCAAiC,GAAG,IAAA,iCAAoB,EAAC,OAAC,CAAC,KAAK,CAAC,6BAAqB,CAAC,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { DTO, ZodValidation } from '@lyxa.ai/core/dist/utilities/validation/global-validation';\nimport { createResponseSchema } from '@lyxa.ai/core/dist/utilities/validation';\n\nconst MatchScoreSchema = z.object({\n\tteam1: ZodValidation.number('Team 1 score').nullable(),\n\tteam2: ZodValidation.number('Team 2 score').nullable(),\n});\n\nconst MatchTeamSchema = z.object({\n\tteamId: ZodValidation.objectId('Team id'),\n\tname: ZodValidation.string('Team name'),\n\tpicture: ZodValidation.string('Team picture').optional(),\n});\n\nconst MatchPredictionSchema = z.object({\n\tscore: MatchScoreSchema,\n\tsucceeded: z.boolean().nullable().optional(),\n});\n\nconst MatchInputSchema = z\n\t.object({\n\t\tstage: ZodValidation.string('Stage'),\n\t\tteam1Id: ZodValidation.objectId('Team 1 id'),\n\t\tteam2Id: ZodValidation.objectId('Team 2 id'),\n\t\tstartingDate: ZodValidation.date('Starting date'),\n\t\tendDate: ZodValidation.date('End date').optional(),\n\t\tadditionalTag: ZodValidation.string('Additional tag').optional(),\n\t})\n\t.superRefine((d, ctx) => {\n\t\tif (d.team1Id.toString() === d.team2Id.toString()) {\n\t\t\tctx.addIssue({ code: z.ZodIssueCode.custom, message: 'Teams must be different', path: ['team2Id'] });\n\t\t}\n\t\tif (d.endDate && d.endDate <= d.startingDate) {\n\t\t\tctx.addIssue({ code: z.ZodIssueCode.custom, message: 'End date must be after start date', path: ['endDate'] });\n\t\t}\n\t});\n\nexport const AddTournamentMatchesSchema = z.object({\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n\tmatches: z.array(MatchInputSchema).min(1, 'At least one match is required'),\n});\n\nexport const GetTournamentMatchesSchema = z.object({\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n});\n\nexport const UpdateMatchScoreSchema = z.object({\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n\tmatchId: ZodValidation.objectId('Match id'),\n\tteam1Score: ZodValidation.number('Team 1 score', { min: 0, isInt: true }),\n\tteam2Score: ZodValidation.number('Team 2 score', { min: 0, isInt: true }),\n\twinnerId: ZodValidation.objectId('Winner id').optional(),\n});\n\nexport const StartTournamentMatchSchema = z.object({\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n\tmatchId: ZodValidation.objectId('Match id'),\n});\n\nexport const EndTournamentMatchSchema = z.object({\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n\tmatchId: ZodValidation.objectId('Match id'),\n\tfinalScore: z.object({\n\t\tteam1: ZodValidation.number('Team 1 score', {min: 0, isInt: true}),\n\t\tteam2: ZodValidation.number('Team 2 score', {min: 0, isInt: true}),\n\t}).optional(),\n});\n\nexport const TournamentMatchSchema = z.object({\n\t_id: ZodValidation.objectId(),\n\tadditionalTag: ZodValidation.string('Additional tag').optional(),\n\tstage: ZodValidation.string('Stage'),\n\tteam1: MatchTeamSchema,\n\tteam2: MatchTeamSchema,\n\tscore: MatchScoreSchema,\n\tprediction: MatchPredictionSchema.optional().nullable(),\n\twinnerId: ZodValidation.objectId('Winner id').nullable().optional(),\n\tstartingDate: z.date().nullable().optional(),\n\tendDate: z.date().nullable().optional(),\n});\n\nexport const TournamentMatchResponseSchema = createResponseSchema(TournamentMatchSchema);\nexport const TournamentMatchListResponseSchema = createResponseSchema(z.array(TournamentMatchSchema));\n\nexport type AddTournamentMatchesInputDTO = DTO<typeof AddTournamentMatchesSchema>;\nexport type StartTournamentMatchInputDTO = DTO<typeof StartTournamentMatchSchema>;\nexport type UpdateMatchScoreInputDTO = DTO<typeof UpdateMatchScoreSchema>;\nexport type EndTournamentMatchInputDTO = DTO<typeof EndTournamentMatchSchema>;\nexport type TournamentMatchOutputDTO = DTO<typeof TournamentMatchSchema>;\n"]}
@@ -1,13 +1,10 @@
1
1
  import { JobsOptions } from 'bullmq';
2
2
  export declare const TOURNAMENT_NOTIFICATION_QUEUE = "tournament-match-notifications";
3
- export declare enum TournamentNotificationJobName {
4
- NOTIFY_3H_BEFORE = "notify-3h-before",
5
- NOTIFY_15MIN_BEFORE = "notify-15min-before"
6
- }
7
3
  export interface TournamentNotificationJobData {
8
4
  tournamentId: string;
9
5
  matchId: string;
6
+ target: string;
10
7
  }
11
- export declare function addNotificationJob(name: TournamentNotificationJobName, data: TournamentNotificationJobData, options: JobsOptions): Promise<void>;
8
+ export declare function addNotificationJob(name: string, data: TournamentNotificationJobData, options: JobsOptions): Promise<void>;
12
9
  export declare function removeNotificationJob(jobId: string): Promise<void>;
13
10
  //# sourceMappingURL=notification.producer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notification.producer.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/jobs/notification.producer.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,WAAW,EAAE,MAAM,QAAQ,CAAC;AAE5C,eAAO,MAAM,6BAA6B,mCAAmC,CAAC;AAE9E,oBAAY,6BAA6B;IACrC,gBAAgB,qBAAqB;IACrC,mBAAmB,wBAAwB;CAC9C;AAED,MAAM,WAAW,6BAA6B;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACnB;AAYD,wBAAsB,kBAAkB,CACpC,IAAI,EAAE,6BAA6B,EACnC,IAAI,EAAE,6BAA6B,EACnC,OAAO,EAAE,WAAW,GACrB,OAAO,CAAC,IAAI,CAAC,CAEf;AAED,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGxE"}
1
+ {"version":3,"file":"notification.producer.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/jobs/notification.producer.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,WAAW,EAAE,MAAM,QAAQ,CAAC;AAE5C,eAAO,MAAM,6BAA6B,mCAAmC,CAAC;AAE9E,MAAM,WAAW,6BAA6B;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAClB;AAYD,wBAAsB,kBAAkB,CACpC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,6BAA6B,EACnC,OAAO,EAAE,WAAW,GACrB,OAAO,CAAC,IAAI,CAAC,CAEf;AAED,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGxE"}
@@ -1,15 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TournamentNotificationJobName = exports.TOURNAMENT_NOTIFICATION_QUEUE = void 0;
3
+ exports.TOURNAMENT_NOTIFICATION_QUEUE = void 0;
4
4
  exports.addNotificationJob = addNotificationJob;
5
5
  exports.removeNotificationJob = removeNotificationJob;
6
6
  const core_1 = require("@lyxa.ai/core");
7
7
  exports.TOURNAMENT_NOTIFICATION_QUEUE = 'tournament-match-notifications';
8
- var TournamentNotificationJobName;
9
- (function (TournamentNotificationJobName) {
10
- TournamentNotificationJobName["NOTIFY_3H_BEFORE"] = "notify-3h-before";
11
- TournamentNotificationJobName["NOTIFY_15MIN_BEFORE"] = "notify-15min-before";
12
- })(TournamentNotificationJobName || (exports.TournamentNotificationJobName = TournamentNotificationJobName = {}));
13
8
  let _queue = null;
14
9
  function getQueue() {
15
10
  if (!_queue) {
@@ -1 +1 @@
1
- {"version":3,"file":"notification.producer.js","sourceRoot":"/","sources":["modules/tournament/notification/jobs/notification.producer.ts"],"names":[],"mappings":";;;AAyBA,gDAMC;AAED,sDAGC;AApCD,wCAA6C;AAGhC,QAAA,6BAA6B,GAAG,gCAAgC,CAAC;AAE9E,IAAY,6BAGX;AAHD,WAAY,6BAA6B;IACrC,sEAAqC,CAAA;IACrC,4EAA2C,CAAA;AAC/C,CAAC,EAHW,6BAA6B,6CAA7B,6BAA6B,QAGxC;AAOD,IAAI,MAAM,GAAiB,IAAI,CAAC;AAEhC,SAAS,QAAQ;IACb,IAAI,CAAC,MAAM,EAAE,CAAC;QAEV,MAAM,GAAG,IAAA,mBAAY,GAAE,CAAC,gBAAgB,EAAE,CAAC,WAAW,CAAC,qCAA6B,CAAC,CAAC;IAC1F,CAAC;IACD,OAAO,MAAO,CAAC;AACnB,CAAC;AAEM,KAAK,UAAU,kBAAkB,CACpC,IAAmC,EACnC,IAAmC,EACnC,OAAoB;IAEpB,MAAM,QAAQ,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAEM,KAAK,UAAU,qBAAqB,CAAC,KAAa;IACrD,MAAM,GAAG,GAAG,MAAM,QAAQ,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3C,IAAI,GAAG;QAAE,MAAM,GAAG,CAAC,MAAM,EAAE,CAAC;AAChC,CAAC","sourcesContent":["import { getLibraries } from '@lyxa.ai/core';\nimport { Queue, JobsOptions } from 'bullmq';\n\nexport const TOURNAMENT_NOTIFICATION_QUEUE = 'tournament-match-notifications';\n\nexport enum TournamentNotificationJobName {\n NOTIFY_3H_BEFORE = 'notify-3h-before',\n NOTIFY_15MIN_BEFORE = 'notify-15min-before',\n}\n\nexport interface TournamentNotificationJobData {\n tournamentId: string;\n matchId: string;\n}\n\nlet _queue: Queue | null = null;\n\nfunction getQueue(): Queue {\n if (!_queue) {\n // @ts-ignore\n _queue = getLibraries().getBullMQService().createQueue(TOURNAMENT_NOTIFICATION_QUEUE);\n }\n return _queue!;\n}\n\nexport async function addNotificationJob(\n name: TournamentNotificationJobName,\n data: TournamentNotificationJobData,\n options: JobsOptions\n): Promise<void> {\n await getQueue().add(name, data, options);\n}\n\nexport async function removeNotificationJob(jobId: string): Promise<void> {\n const job = await getQueue().getJob(jobId);\n if (job) await job.remove();\n}\n"]}
1
+ {"version":3,"file":"notification.producer.js","sourceRoot":"/","sources":["modules/tournament/notification/jobs/notification.producer.ts"],"names":[],"mappings":";;;AAqBA,gDAMC;AAED,sDAGC;AAhCD,wCAA6C;AAGhC,QAAA,6BAA6B,GAAG,gCAAgC,CAAC;AAQ9E,IAAI,MAAM,GAAiB,IAAI,CAAC;AAEhC,SAAS,QAAQ;IACb,IAAI,CAAC,MAAM,EAAE,CAAC;QAEV,MAAM,GAAG,IAAA,mBAAY,GAAE,CAAC,gBAAgB,EAAE,CAAC,WAAW,CAAC,qCAA6B,CAAC,CAAC;IAC1F,CAAC;IACD,OAAO,MAAO,CAAC;AACnB,CAAC;AAEM,KAAK,UAAU,kBAAkB,CACpC,IAAY,EACZ,IAAmC,EACnC,OAAoB;IAEpB,MAAM,QAAQ,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAEM,KAAK,UAAU,qBAAqB,CAAC,KAAa;IACrD,MAAM,GAAG,GAAG,MAAM,QAAQ,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3C,IAAI,GAAG;QAAE,MAAM,GAAG,CAAC,MAAM,EAAE,CAAC;AAChC,CAAC","sourcesContent":["import { getLibraries } from '@lyxa.ai/core';\nimport { Queue, JobsOptions } from 'bullmq';\n\nexport const TOURNAMENT_NOTIFICATION_QUEUE = 'tournament-match-notifications';\n\nexport interface TournamentNotificationJobData {\n tournamentId: string;\n matchId: string;\n target: string;\n}\n\nlet _queue: Queue | null = null;\n\nfunction getQueue(): Queue {\n if (!_queue) {\n // @ts-ignore\n _queue = getLibraries().getBullMQService().createQueue(TOURNAMENT_NOTIFICATION_QUEUE);\n }\n return _queue!;\n}\n\nexport async function addNotificationJob(\n name: string,\n data: TournamentNotificationJobData,\n options: JobsOptions\n): Promise<void> {\n await getQueue().add(name, data, options);\n}\n\nexport async function removeNotificationJob(jobId: string): Promise<void> {\n const job = await getQueue().getJob(jobId);\n if (job) await job.remove();\n}\n"]}
@@ -1,5 +1,7 @@
1
1
  export declare class TournamentNotificationWorker {
2
2
  private notificationService;
3
+ private templateRepository;
4
+ private matchRepository;
3
5
  constructor();
4
6
  startWorker(): void;
5
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"notification.worker.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/jobs/notification.worker.ts"],"names":[],"mappings":"AAUA,qBACa,4BAA4B;IACrC,OAAO,CAAC,mBAAmB,CAAgC;;IAMpD,WAAW,IAAI,IAAI;CAa7B;AAED,eAAO,MAAM,4BAA4B,8BAA8C,CAAC"}
1
+ {"version":3,"file":"notification.worker.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/jobs/notification.worker.ts"],"names":[],"mappings":"AAQA,qBACa,4BAA4B;IACrC,OAAO,CAAC,mBAAmB,CAAgC;IAC3D,OAAO,CAAC,kBAAkB,CAAiC;IAC3D,OAAO,CAAC,eAAe,CAA4B;;IAQ5C,WAAW,IAAI,IAAI;CAe7B;AAED,eAAO,MAAM,4BAA4B,8BAA8C,CAAC"}
@@ -48,22 +48,28 @@ const typegoose_1 = require("@typegoose/typegoose");
48
48
  const core_1 = require("@lyxa.ai/core");
49
49
  const notification_producer_1 = require("./notification.producer");
50
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");
51
53
  let TournamentNotificationWorker = class TournamentNotificationWorker {
52
54
  notificationService;
55
+ templateRepository;
56
+ matchRepository;
53
57
  constructor() {
54
58
  this.notificationService = typedi_1.default.get(notification_service_1.TournamentNotificationService);
59
+ this.templateRepository = typedi_1.default.get(notification_template_repository_1.NotificationTemplateRepository);
60
+ this.matchRepository = typedi_1.default.get(match_repository_1.TournamentMatchRepository);
55
61
  }
56
62
  startWorker() {
57
63
  (0, core_1.getLibraries)().getBullMQService().createWorker(notification_producer_1.TOURNAMENT_NOTIFICATION_QUEUE, async (job) => {
58
- const { tournamentId, matchId } = job.data;
59
- const tournamentObjectId = new typegoose_1.mongoose.Types.ObjectId(tournamentId);
60
- const matchObjectId = new typegoose_1.mongoose.Types.ObjectId(matchId);
61
- if (job.name === notification_producer_1.TournamentNotificationJobName.NOTIFY_3H_BEFORE) {
62
- await this.notificationService.notifyUnpredictedParticipants(tournamentObjectId, matchObjectId, 'before3h');
63
- }
64
- else if (job.name === notification_producer_1.TournamentNotificationJobName.NOTIFY_15MIN_BEFORE) {
65
- await this.notificationService.notifyUnpredictedParticipants(tournamentObjectId, matchObjectId, 'before15min');
66
- }
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);
67
73
  });
68
74
  }
69
75
  };
@@ -1 +1 @@
1
- {"version":3,"file":"notification.worker.js","sourceRoot":"/","sources":["modules/tournament/notification/jobs/notification.worker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAC5C,oDAAgD;AAChD,wCAA6C;AAC7C,mEAIiC;AACjC,kEAAwE;AAGjE,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IAC7B,mBAAmB,CAAgC;IAE3D;QACI,IAAI,CAAC,mBAAmB,GAAG,gBAAS,CAAC,GAAG,CAAC,oDAA6B,CAAC,CAAC;IAC5E,CAAC;IAEM,WAAW;QACd,IAAA,mBAAY,GAAE,CAAC,gBAAgB,EAAE,CAAC,YAAY,CAAC,qDAA6B,EAAE,KAAK,EAAC,GAAG,EAAC,EAAE;YACtF,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC,IAAqC,CAAC;YAC5E,MAAM,kBAAkB,GAAG,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;YACrE,MAAM,aAAa,GAAG,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAE3D,IAAI,GAAG,CAAC,IAAI,KAAK,qDAA6B,CAAC,gBAAgB,EAAE,CAAC;gBAC9D,MAAM,IAAI,CAAC,mBAAmB,CAAC,6BAA6B,CAAC,kBAAkB,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;YAChH,CAAC;iBAAM,IAAI,GAAG,CAAC,IAAI,KAAK,qDAA6B,CAAC,mBAAmB,EAAE,CAAC;gBACxE,MAAM,IAAI,CAAC,mBAAmB,CAAC,6BAA6B,CAAC,kBAAkB,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC;YACnH,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AApBY,oEAA4B;uCAA5B,4BAA4B;IADxC,IAAA,gBAAO,GAAE;;GACG,4BAA4B,CAoBxC;AAEY,QAAA,4BAA4B,GAAG,gBAAS,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport { getLibraries } from '@lyxa.ai/core';\nimport {\n TOURNAMENT_NOTIFICATION_QUEUE,\n TournamentNotificationJobData,\n TournamentNotificationJobName,\n} from './notification.producer';\nimport { TournamentNotificationService } from '../notification.service';\n\n@Service()\nexport class TournamentNotificationWorker {\n private notificationService: TournamentNotificationService;\n\n constructor() {\n this.notificationService = Container.get(TournamentNotificationService);\n }\n\n public startWorker(): void {\n getLibraries().getBullMQService().createWorker(TOURNAMENT_NOTIFICATION_QUEUE, async job => {\n const { tournamentId, matchId } = job.data as TournamentNotificationJobData;\n const tournamentObjectId = new mongoose.Types.ObjectId(tournamentId);\n const matchObjectId = new mongoose.Types.ObjectId(matchId);\n\n if (job.name === TournamentNotificationJobName.NOTIFY_3H_BEFORE) {\n await this.notificationService.notifyUnpredictedParticipants(tournamentObjectId, matchObjectId, 'before3h');\n } else if (job.name === TournamentNotificationJobName.NOTIFY_15MIN_BEFORE) {\n await this.notificationService.notifyUnpredictedParticipants(tournamentObjectId, matchObjectId, 'before15min');\n }\n });\n }\n}\n\nexport const tournamentNotificationWorker = Container.get(TournamentNotificationWorker);\n"]}
1
+ {"version":3,"file":"notification.worker.js","sourceRoot":"/","sources":["modules/tournament/notification/jobs/notification.worker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAC1C,oDAA8C;AAC9C,wCAA2C;AAC3C,mEAAqG;AACrG,kEAAsE;AACtE,0FAAmF;AACnF,mEAAuE;AAGhE,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IAC7B,mBAAmB,CAAgC;IACnD,kBAAkB,CAAiC;IACnD,eAAe,CAA4B;IAEnD;QACI,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,eAAe,GAAG,gBAAS,CAAC,GAAG,CAAC,4CAAyB,CAAC,CAAC;IACpE,CAAC;IAEM,WAAW;QACd,IAAA,mBAAY,GAAE,CAAC,gBAAgB,EAAE,CAAC,YAAY,CAAC,qDAA6B,EAAE,KAAK,EAAC,GAAG,EAAC,EAAE;YACtF,MAAM,EAAC,YAAY,EAAE,OAAO,EAAE,MAAM,EAAC,GAAG,GAAG,CAAC,IAAqC,CAAC;YAClF,MAAM,eAAe,GAAG,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;YAClE,MAAM,UAAU,GAAG,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAExD,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,eAAe,EAAE,UAAU,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;YAC1G,IAAI,WAAW;gBAAE,OAAO;YAExB,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;YAC/E,MAAM,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC;YAE9G,MAAM,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,eAAe,EAAE,UAAU,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;QAC1F,CAAC,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AA1BY,oEAA4B;uCAA5B,4BAA4B;IADxC,IAAA,gBAAO,GAAE;;GACG,4BAA4B,CA0BxC;AAEY,QAAA,4BAA4B,GAAG,gBAAS,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {getLibraries} from '@lyxa.ai/core';\nimport {TOURNAMENT_NOTIFICATION_QUEUE, TournamentNotificationJobData} from './notification.producer';\nimport {TournamentNotificationService} from '../notification.service';\nimport {NotificationTemplateRepository} from '../notification-template.repository';\nimport {TournamentMatchRepository} from '../../match/match.repository';\n\n@Service()\nexport class TournamentNotificationWorker {\n private notificationService: TournamentNotificationService;\n private templateRepository: NotificationTemplateRepository;\n private matchRepository: TournamentMatchRepository;\n\n constructor() {\n this.notificationService = Container.get(TournamentNotificationService);\n this.templateRepository = Container.get(NotificationTemplateRepository);\n this.matchRepository = Container.get(TournamentMatchRepository);\n }\n\n public startWorker(): void {\n getLibraries().getBullMQService().createWorker(TOURNAMENT_NOTIFICATION_QUEUE, async job => {\n const {tournamentId, matchId, target} = job.data as TournamentNotificationJobData;\n const tournamentObjId = new mongoose.Types.ObjectId(tournamentId);\n const matchObjId = new mongoose.Types.ObjectId(matchId);\n\n const alreadySent = await this.matchRepository.getNotificationFlag(tournamentObjId, matchObjId, job.name);\n if (alreadySent) return;\n\n const templates = await this.templateRepository.findTemplates(tournamentObjId);\n await this.notificationService.dispatchScheduledJob(job.name, target, templates, tournamentObjId, matchObjId);\n\n await this.matchRepository.setNotificationFlag(tournamentObjId, matchObjId, job.name);\n });\n }\n}\n\nexport const tournamentNotificationWorker = Container.get(TournamentNotificationWorker);\n"]}
@@ -0,0 +1,8 @@
1
+ import { mongoose } from '@typegoose/typegoose';
2
+ import { NotificationMessage } from '@lyxa.ai/core/dist/libraries/mongo/models';
3
+ export declare class NotificationTemplateRepository {
4
+ private model;
5
+ findTemplates(tournamentId: mongoose.Types.ObjectId): Promise<Map<string, NotificationMessage>>;
6
+ }
7
+ export declare const notificationTemplateRepository: NotificationTemplateRepository;
8
+ //# sourceMappingURL=notification-template.repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification-template.repository.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification-template.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAmB,MAAM,2CAA2C,CAAC;AAEjG,qBACa,8BAA8B;IACvC,OAAO,CAAC,KAAK,CAAmB;IAEnB,aAAa,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;CAM/G;AAED,eAAO,MAAM,8BAA8B,gCAAgD,CAAC"}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.notificationTemplateRepository = exports.NotificationTemplateRepository = void 0;
43
+ const typedi_1 = __importStar(require("typedi"));
44
+ const models_1 = require("@lyxa.ai/core/dist/libraries/mongo/models");
45
+ let NotificationTemplateRepository = class NotificationTemplateRepository {
46
+ model = models_1.TournamentModel;
47
+ async findTemplates(tournamentId) {
48
+ const doc = await this.model.findById(tournamentId, { notificationTemplates: 1 }).lean();
49
+ if (!doc)
50
+ throw new Error(`Tournament not found: ${tournamentId}`);
51
+ const raw = doc.notificationTemplates;
52
+ return new Map(Object.entries(raw ?? {}));
53
+ }
54
+ };
55
+ exports.NotificationTemplateRepository = NotificationTemplateRepository;
56
+ exports.NotificationTemplateRepository = NotificationTemplateRepository = __decorate([
57
+ (0, typedi_1.Service)()
58
+ ], NotificationTemplateRepository);
59
+ exports.notificationTemplateRepository = typedi_1.default.get(NotificationTemplateRepository);
60
+ //# sourceMappingURL=notification-template.repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification-template.repository.js","sourceRoot":"/","sources":["modules/tournament/notification/notification-template.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,sEAAiG;AAG1F,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAC/B,KAAK,GAAG,wBAAe,CAAC;IAEzB,KAAK,CAAC,aAAa,CAAC,YAAqC;QAC5D,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,EAAE,EAAE,qBAAqB,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACzF,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,YAAY,EAAE,CAAC,CAAC;QACnE,MAAM,GAAG,GAAG,GAAG,CAAC,qBAAwE,CAAC;QACzF,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC;IAC9C,CAAC;CACJ,CAAA;AATY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,gBAAO,GAAE;GACG,8BAA8B,CAS1C;AAEY,QAAA,8BAA8B,GAAG,gBAAS,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport { NotificationMessage, TournamentModel } from '@lyxa.ai/core/dist/libraries/mongo/models';\n\n@Service()\nexport class NotificationTemplateRepository {\n private model = TournamentModel;\n\n public async findTemplates(tournamentId: mongoose.Types.ObjectId): Promise<Map<string, NotificationMessage>> {\n const doc = await this.model.findById(tournamentId, { notificationTemplates: 1 }).lean();\n if (!doc) throw new Error(`Tournament not found: ${tournamentId}`);\n const raw = doc.notificationTemplates as Record<string, NotificationMessage> | undefined;\n return new Map(Object.entries(raw ?? {}));\n }\n}\n\nexport const notificationTemplateRepository = Container.get(NotificationTemplateRepository);\n"]}
@@ -0,0 +1,10 @@
1
+ export declare enum NotificationTag {
2
+ TOURNAMENT_ACTIVATION = "tournament-activation",
3
+ MATCH_RESULT_WINNER = "match-result-winner",
4
+ MATCH_RESULT_LOSER = "match-result-loser"
5
+ }
6
+ export declare enum ScheduledTarget {
7
+ GLOBAL = "global",
8
+ UNPREDICTED_PARTICIPANTS = "unpredicted-participants"
9
+ }
10
+ //# sourceMappingURL=notification.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification.config.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification.config.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IACvB,qBAAqB,0BAA0B;IAC/C,mBAAmB,wBAAwB;IAC3C,kBAAkB,uBAAuB;CAC5C;AAED,oBAAY,eAAe;IACvB,MAAM,WAAW;IACjB,wBAAwB,6BAA6B;CACxD"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScheduledTarget = exports.NotificationTag = void 0;
4
+ var NotificationTag;
5
+ (function (NotificationTag) {
6
+ NotificationTag["TOURNAMENT_ACTIVATION"] = "tournament-activation";
7
+ NotificationTag["MATCH_RESULT_WINNER"] = "match-result-winner";
8
+ NotificationTag["MATCH_RESULT_LOSER"] = "match-result-loser";
9
+ })(NotificationTag || (exports.NotificationTag = NotificationTag = {}));
10
+ var ScheduledTarget;
11
+ (function (ScheduledTarget) {
12
+ ScheduledTarget["GLOBAL"] = "global";
13
+ ScheduledTarget["UNPREDICTED_PARTICIPANTS"] = "unpredicted-participants";
14
+ })(ScheduledTarget || (exports.ScheduledTarget = ScheduledTarget = {}));
15
+ //# sourceMappingURL=notification.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification.config.js","sourceRoot":"/","sources":["modules/tournament/notification/notification.config.ts"],"names":[],"mappings":";;;AAAA,IAAY,eAIX;AAJD,WAAY,eAAe;IACvB,kEAA+C,CAAA;IAC/C,8DAA2C,CAAA;IAC3C,4DAAyC,CAAA;AAC7C,CAAC,EAJW,eAAe,+BAAf,eAAe,QAI1B;AAED,IAAY,eAGX;AAHD,WAAY,eAAe;IACvB,oCAAiB,CAAA;IACjB,wEAAqD,CAAA;AACzD,CAAC,EAHW,eAAe,+BAAf,eAAe,QAG1B","sourcesContent":["export enum NotificationTag {\n TOURNAMENT_ACTIVATION = 'tournament-activation',\n MATCH_RESULT_WINNER = 'match-result-winner',\n MATCH_RESULT_LOSER = 'match-result-loser',\n}\n\nexport enum ScheduledTarget {\n GLOBAL = 'global',\n UNPREDICTED_PARTICIPANTS = 'unpredicted-participants',\n}\n"]}
@@ -0,0 +1,10 @@
1
+ export declare enum NotificationTag {
2
+ TOURNAMENT_ACTIVATION = "tournament-activation",
3
+ MATCH_RESULT_WINNER = "match-result-winner",
4
+ MATCH_RESULT_LOSER = "match-result-loser"
5
+ }
6
+ export declare enum ScheduledTarget {
7
+ GLOBAL = "global",
8
+ UNPREDICTED_PARTICIPANTS = "unpredicted-participants"
9
+ }
10
+ //# sourceMappingURL=notification.schedule.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification.schedule.config.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification.schedule.config.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IACvB,qBAAqB,0BAA0B;IAC/C,mBAAmB,wBAAwB;IAC3C,kBAAkB,uBAAuB;CAC5C;AAED,oBAAY,eAAe;IACvB,MAAM,WAAW;IACjB,wBAAwB,6BAA6B;CACxD"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScheduledTarget = exports.NotificationTag = void 0;
4
+ var NotificationTag;
5
+ (function (NotificationTag) {
6
+ NotificationTag["TOURNAMENT_ACTIVATION"] = "tournament-activation";
7
+ NotificationTag["MATCH_RESULT_WINNER"] = "match-result-winner";
8
+ NotificationTag["MATCH_RESULT_LOSER"] = "match-result-loser";
9
+ })(NotificationTag || (exports.NotificationTag = NotificationTag = {}));
10
+ var ScheduledTarget;
11
+ (function (ScheduledTarget) {
12
+ ScheduledTarget["GLOBAL"] = "global";
13
+ ScheduledTarget["UNPREDICTED_PARTICIPANTS"] = "unpredicted-participants";
14
+ })(ScheduledTarget || (exports.ScheduledTarget = ScheduledTarget = {}));
15
+ //# sourceMappingURL=notification.schedule.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification.schedule.config.js","sourceRoot":"/","sources":["modules/tournament/notification/notification.schedule.config.ts"],"names":[],"mappings":";;;AAAA,IAAY,eAIX;AAJD,WAAY,eAAe;IACvB,kEAA+C,CAAA;IAC/C,8DAA2C,CAAA;IAC3C,4DAAyC,CAAA;AAC7C,CAAC,EAJW,eAAe,+BAAf,eAAe,QAI1B;AAED,IAAY,eAGX;AAHD,WAAY,eAAe;IACvB,oCAAiB,CAAA;IACjB,wEAAqD,CAAA;AACzD,CAAC,EAHW,eAAe,+BAAf,eAAe,QAG1B","sourcesContent":["export enum NotificationTag {\n TOURNAMENT_ACTIVATION = 'tournament-activation',\n MATCH_RESULT_WINNER = 'match-result-winner',\n MATCH_RESULT_LOSER = 'match-result-loser',\n}\n\nexport enum ScheduledTarget {\n GLOBAL = 'global',\n UNPREDICTED_PARTICIPANTS = 'unpredicted-participants',\n}\n"]}
@@ -1,10 +1,10 @@
1
1
  import { mongoose } from '@typegoose/typegoose';
2
+ import { ScheduledNotificationConfig } from '@lyxa.ai/core/dist/libraries/mongo/models';
2
3
  export declare class NotificationSchedulerService {
3
- private jobId3h;
4
- private jobId15min;
4
+ private jobId;
5
5
  private buildJobData;
6
- scheduleForMatch(matchId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId, startingDate: Date): Promise<void>;
7
- cancelForMatch(matchId: mongoose.Types.ObjectId): Promise<void>;
6
+ scheduleForMatch(matchId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId, startingDate: Date, scheduledNotifications: ScheduledNotificationConfig[]): Promise<void>;
7
+ cancelForMatch(matchId: mongoose.Types.ObjectId, scheduledNotifications: ScheduledNotificationConfig[]): Promise<void>;
8
8
  }
9
9
  export declare const notificationSchedulerService: NotificationSchedulerService;
10
10
  //# sourceMappingURL=notification.scheduler.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notification.scheduler.service.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification.scheduler.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAWhD,qBACa,4BAA4B;IACrC,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,YAAY;IAIP,gBAAgB,CACzB,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAChC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,YAAY,EAAE,IAAI,GACnB,OAAO,CAAC,IAAI,CAAC;IAsBH,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAI/E;AAED,eAAO,MAAM,4BAA4B,8BAA8C,CAAC"}
1
+ {"version":3,"file":"notification.scheduler.service.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification.scheduler.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAC;AAGxF,qBACa,4BAA4B;IACrC,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,YAAY;IAIP,gBAAgB,CACzB,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAChC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,YAAY,EAAE,IAAI,EAClB,sBAAsB,EAAE,2BAA2B,EAAE,GACtD,OAAO,CAAC,IAAI,CAAC;IAcH,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAGtI;AAED,eAAO,MAAM,4BAA4B,8BAA8C,CAAC"}
@@ -42,40 +42,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
42
42
  exports.notificationSchedulerService = exports.NotificationSchedulerService = void 0;
43
43
  const typedi_1 = __importStar(require("typedi"));
44
44
  const notification_producer_1 = require("./jobs/notification.producer");
45
- const THREE_HOURS_MS = 3 * 60 * 60 * 1000;
46
- const FIFTEEN_MINUTES_MS = 15 * 60 * 1000;
47
45
  let NotificationSchedulerService = class NotificationSchedulerService {
48
- jobId3h(matchId) {
49
- return `tournament-notify-3h-${matchId}`;
46
+ jobId(type, matchId) {
47
+ return `tournament-${type}-${matchId}`;
50
48
  }
51
- jobId15min(matchId) {
52
- return `tournament-notify-15min-${matchId}`;
49
+ buildJobData(tournamentId, matchId, target) {
50
+ return { tournamentId: tournamentId.toString(), matchId: matchId.toString(), target };
53
51
  }
54
- buildJobData(tournamentId, matchId) {
55
- return { tournamentId: tournamentId.toString(), matchId: matchId.toString() };
56
- }
57
- async scheduleForMatch(matchId, tournamentId, startingDate) {
58
- const data = this.buildJobData(tournamentId, matchId);
59
- const delay3h = startingDate.getTime() - THREE_HOURS_MS - Date.now();
60
- if (delay3h > 0) {
61
- await (0, notification_producer_1.addNotificationJob)(notification_producer_1.TournamentNotificationJobName.NOTIFY_3H_BEFORE, data, {
62
- delay: delay3h,
63
- jobId: this.jobId3h(matchId),
64
- removeOnComplete: true,
65
- });
66
- }
67
- const delay15min = startingDate.getTime() - FIFTEEN_MINUTES_MS - Date.now();
68
- if (delay15min > 0) {
69
- await (0, notification_producer_1.addNotificationJob)(notification_producer_1.TournamentNotificationJobName.NOTIFY_15MIN_BEFORE, data, {
70
- delay: delay15min,
71
- jobId: this.jobId15min(matchId),
52
+ async scheduleForMatch(matchId, tournamentId, startingDate, scheduledNotifications) {
53
+ await Promise.all(scheduledNotifications.map(({ type, durationMins, target }) => {
54
+ const delay = startingDate.getTime() - durationMins * 60 * 1000 - Date.now();
55
+ if (delay <= 0)
56
+ return Promise.resolve();
57
+ return (0, notification_producer_1.addNotificationJob)(type, this.buildJobData(tournamentId, matchId, target), {
58
+ delay,
59
+ jobId: this.jobId(type, matchId),
72
60
  removeOnComplete: true,
73
61
  });
74
- }
62
+ }));
75
63
  }
76
- async cancelForMatch(matchId) {
77
- await (0, notification_producer_1.removeNotificationJob)(this.jobId3h(matchId));
78
- await (0, notification_producer_1.removeNotificationJob)(this.jobId15min(matchId));
64
+ async cancelForMatch(matchId, scheduledNotifications) {
65
+ await Promise.all(scheduledNotifications.map(({ type }) => (0, notification_producer_1.removeNotificationJob)(this.jobId(type, matchId))));
79
66
  }
80
67
  };
81
68
  exports.NotificationSchedulerService = NotificationSchedulerService;
@@ -1 +1 @@
1
- {"version":3,"file":"notification.scheduler.service.js","sourceRoot":"/","sources":["modules/tournament/notification/notification.scheduler.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA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E;gBAC9E,KAAK,EAAE,UAAU;gBACjB,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;gBAC/B,gBAAgB,EAAE,IAAI;aACzB,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,OAAgC;QACxD,MAAM,IAAA,6CAAqB,EAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QACnD,MAAM,IAAA,6CAAqB,EAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1D,CAAC;CACJ,CAAA;AA3CY,oEAA4B;uCAA5B,4BAA4B;IADxC,IAAA,gBAAO,GAAE;GACG,4BAA4B,CA2CxC;AAEY,QAAA,4BAA4B,GAAG,gBAAS,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport {\n TournamentNotificationJobName,\n TournamentNotificationJobData,\n addNotificationJob,\n removeNotificationJob,\n} from './jobs/notification.producer';\n\nconst THREE_HOURS_MS = 3 * 60 * 60 * 1000;\nconst FIFTEEN_MINUTES_MS = 15 * 60 * 1000;\n\n@Service()\nexport class NotificationSchedulerService {\n private jobId3h(matchId: mongoose.Types.ObjectId): string {\n return `tournament-notify-3h-${matchId}`;\n }\n\n private jobId15min(matchId: mongoose.Types.ObjectId): string {\n return `tournament-notify-15min-${matchId}`;\n }\n\n private buildJobData(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): TournamentNotificationJobData {\n return { tournamentId: tournamentId.toString(), matchId: matchId.toString() };\n }\n\n public async scheduleForMatch(\n matchId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId,\n startingDate: Date\n ): Promise<void> {\n const data = this.buildJobData(tournamentId, matchId);\n\n const delay3h = startingDate.getTime() - THREE_HOURS_MS - Date.now();\n if (delay3h > 0) {\n await addNotificationJob(TournamentNotificationJobName.NOTIFY_3H_BEFORE, data, {\n delay: delay3h,\n jobId: this.jobId3h(matchId),\n removeOnComplete: true,\n });\n }\n\n const delay15min = startingDate.getTime() - FIFTEEN_MINUTES_MS - Date.now();\n if (delay15min > 0) {\n await addNotificationJob(TournamentNotificationJobName.NOTIFY_15MIN_BEFORE, data, {\n delay: delay15min,\n jobId: this.jobId15min(matchId),\n removeOnComplete: true,\n });\n }\n }\n\n public async cancelForMatch(matchId: mongoose.Types.ObjectId): Promise<void> {\n await removeNotificationJob(this.jobId3h(matchId));\n await removeNotificationJob(this.jobId15min(matchId));\n }\n}\n\nexport const notificationSchedulerService = Container.get(NotificationSchedulerService);\n"]}
1
+ {"version":3,"file":"notification.scheduler.service.js","sourceRoot":"/","sources":["modules/tournament/notification/notification.scheduler.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAG5C,wEAAwH;AAGjH,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IAC7B,KAAK,CAAC,IAAY,EAAE,OAAgC;QACxD,OAAO,cAAc,IAAI,IAAI,OAAO,EAAE,CAAC;IAC3C,CAAC;IAEO,YAAY,CAAC,YAAqC,EAAE,OAAgC,EAAE,MAAc;QACxG,OAAO,EAAE,YAAY,EAAE,YAAY,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC;IAC1F,CAAC;IAEM,KAAK,CAAC,gBAAgB,CACzB,OAAgC,EAChC,YAAqC,EACrC,YAAkB,EAClB,sBAAqD;QAErD,MAAM,OAAO,CAAC,GAAG,CACb,sBAAsB,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE;YAC1D,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,EAAE,GAAG,YAAY,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAC7E,IAAI,KAAK,IAAI,CAAC;gBAAE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;YACzC,OAAO,IAAA,0CAAkB,EAAC,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE;gBAC9E,KAAK;gBACL,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC;gBAChC,gBAAgB,EAAE,IAAI;aACzB,CAAC,CAAC;QACP,CAAC,CAAC,CACL,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,OAAgC,EAAE,sBAAqD;QAC/G,MAAM,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAA,6CAAqB,EAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAClH,CAAC;CACJ,CAAA;AA/BY,oEAA4B;uCAA5B,4BAA4B;IADxC,IAAA,gBAAO,GAAE;GACG,4BAA4B,CA+BxC;AAEY,QAAA,4BAA4B,GAAG,gBAAS,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport { ScheduledNotificationConfig } from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport { addNotificationJob, removeNotificationJob, TournamentNotificationJobData } from './jobs/notification.producer';\n\n@Service()\nexport class NotificationSchedulerService {\n private jobId(type: string, matchId: mongoose.Types.ObjectId): string {\n return `tournament-${type}-${matchId}`;\n }\n\n private buildJobData(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, target: string): TournamentNotificationJobData {\n return { tournamentId: tournamentId.toString(), matchId: matchId.toString(), target };\n }\n\n public async scheduleForMatch(\n matchId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId,\n startingDate: Date,\n scheduledNotifications: ScheduledNotificationConfig[]\n ): Promise<void> {\n await Promise.all(\n scheduledNotifications.map(({ type, durationMins, target }) => {\n const delay = startingDate.getTime() - durationMins * 60 * 1000 - Date.now();\n if (delay <= 0) return Promise.resolve();\n return addNotificationJob(type, this.buildJobData(tournamentId, matchId, target), {\n delay,\n jobId: this.jobId(type, matchId),\n removeOnComplete: true,\n });\n })\n );\n }\n\n public async cancelForMatch(matchId: mongoose.Types.ObjectId, scheduledNotifications: ScheduledNotificationConfig[]): Promise<void> {\n await Promise.all(scheduledNotifications.map(({ type }) => removeNotificationJob(this.jobId(type, matchId))));\n }\n}\n\nexport const notificationSchedulerService = Container.get(NotificationSchedulerService);\n"]}
@@ -1,11 +1,13 @@
1
1
  import { mongoose } from '@typegoose/typegoose';
2
+ import { NotificationMessage } from '@lyxa.ai/core/dist/libraries/mongo/models';
2
3
  export declare class TournamentNotificationService {
3
4
  private participantService;
4
5
  constructor();
6
+ private getTemplate;
5
7
  private hasNotPredicted;
6
- private publishNotification;
7
- notifyUnpredictedParticipants(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, type: 'before3h' | 'before15min'): Promise<void>;
8
- notifyMatchEnded(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<void>;
8
+ notifyGlobal(title: string, body: string): Promise<void>;
9
+ notifyUsers(title: string, body: string, userIds: mongoose.Types.ObjectId[]): Promise<void>;
10
+ dispatchScheduledJob(type: string, target: string, templates: Map<string, NotificationMessage>, tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<void>;
9
11
  }
10
12
  export declare const tournamentNotificationService: TournamentNotificationService;
11
13
  //# sourceMappingURL=notification.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notification.service.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAOhD,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OAAO,CAAC,IAAI,CAAC;CAWnB;AAED,eAAO,MAAM,6BAA6B,+BAA+C,CAAC"}
@@ -48,48 +48,58 @@ const event_1 = require("@lyxa.ai/core/dist/libraries/event");
48
48
  const notification_1 = require("@lyxa.ai/core/dist/libraries/notification");
49
49
  const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
50
50
  const participant_service_1 = require("../participant/participant.service");
51
+ const notification_config_1 = require("./notification.config");
51
52
  let TournamentNotificationService = class TournamentNotificationService {
52
53
  participantService;
53
54
  constructor() {
54
55
  this.participantService = typedi_1.default.get(participant_service_1.ParticipantService);
55
56
  }
57
+ getTemplate(templates, tag) {
58
+ const t = templates.get(tag);
59
+ if (!t)
60
+ throw new Error(`No notification template for tag: ${tag}`);
61
+ return t;
62
+ }
56
63
  hasNotPredicted(participant, matchId) {
57
64
  return !participant.predictions.some(p => p.matchId.toString() === matchId.toString());
58
65
  }
59
- async publishNotification(recipientId, title, body) {
60
- await (0, event_1.publishEvent)(new notification_1.NotificationEvent({
66
+ async notifyGlobal(title, body) {
67
+ await (0, event_1.publishEvent)(new notification_1.NotificationGlobalEvent({
61
68
  title,
62
69
  body,
63
70
  data: {
64
71
  saveNotification: true,
65
72
  accountType: enum_1.NotificationAccountType.USER,
66
- recipientId,
67
- isGlobal: false,
73
+ isGlobal: true,
68
74
  isClickable: true,
69
75
  clickType: enum_1.ClickType.CLICKABLE_FALLBACK,
70
76
  },
71
77
  }));
72
78
  }
73
- async notifyUnpredictedParticipants(tournamentId, matchId, type) {
74
- const participants = await this.participantService.getAll(tournamentId);
75
- const unpredicted = participants.filter(p => this.hasNotPredicted(p, matchId));
76
- const title = type === 'before3h' ? "⏰ Don't miss today's match!" : '🚨 Final call!';
77
- const body = type === 'before3h'
78
- ? 'You still have time to predict the exact score and win'
79
- : 'Only 15 minutes left to submit your prediction';
80
- await Promise.all(unpredicted.map(p => this.publishNotification(p.userId, title, body)));
79
+ async notifyUsers(title, body, userIds) {
80
+ await Promise.all(userIds.map(recipientId => (0, event_1.publishEvent)(new notification_1.NotificationEvent({
81
+ title,
82
+ body,
83
+ data: {
84
+ saveNotification: true,
85
+ accountType: enum_1.NotificationAccountType.USER,
86
+ recipientId,
87
+ isGlobal: false,
88
+ isClickable: true,
89
+ clickType: enum_1.ClickType.CLICKABLE_FALLBACK,
90
+ },
91
+ }))));
81
92
  }
82
- async notifyMatchEnded(tournamentId, matchId) {
83
- const participants = await this.participantService.getAll(tournamentId);
84
- await Promise.all(participants.map(p => {
85
- const prediction = p.predictions.find(pred => pred.matchId.toString() === matchId.toString());
86
- const won = prediction?.succeeded === true;
87
- const title = won ? '🎉 Your prediction was correct.' : 'Full-time whistle 🏁';
88
- const body = won
89
- ? 'Your coupon is now available'
90
- : 'Better luck next match. New predictions are now open';
91
- return this.publishNotification(p.userId, title, body);
92
- }));
93
+ async dispatchScheduledJob(type, target, templates, tournamentId, matchId) {
94
+ const { title, body } = this.getTemplate(templates, type);
95
+ if (target === notification_config_1.ScheduledTarget.GLOBAL) {
96
+ await this.notifyGlobal(title, body);
97
+ }
98
+ else {
99
+ const participants = await this.participantService.getAll(tournamentId);
100
+ const unpredicted = participants.filter(p => this.hasNotPredicted(p, matchId));
101
+ await this.notifyUsers(title, body, unpredicted.map(p => p.userId));
102
+ }
93
103
  }
94
104
  };
95
105
  exports.TournamentNotificationService = TournamentNotificationService;
@@ -1 +1 @@
1
- {"version":3,"file":"notification.service.js","sourceRoot":"/","sources":["modules/tournament/notification/notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,8DAAkE;AAClE,4EAA8E;AAC9E,4DAAuF;AACvF,4EAAwE;AAIjE,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IAC9B,kBAAkB,CAAqB;IAE/C;QACI,IAAI,CAAC,kBAAkB,GAAG,gBAAS,CAAC,GAAG,CAAC,wCAAkB,CAAC,CAAC;IAChE,CAAC;IAEO,eA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AC;IAC7F,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAAC,YAAqC,EAAE,OAAgC;QACjG,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAExE,MAAM,OAAO,CAAC,GAAG,CACb,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YACjB,MAAM,UAAU,GAAG,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC9F,MAAM,GAAG,GAAG,UAAU,EAAE,SAAS,KAAK,IAAI,CAAC;YAE3C,MAAM,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,iCAAiC,CAAC,CAAC,CAAC,sBAAsB,CAAC;YAC/E,MAAM,IAAI,GAAG,GAAG;gBACZ,CAAC,CAAC,8BAA8B;gBAChC,CAAC,CAAC,sDAAsD,CAAC;YAE7D,OAAO,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QAC3D,CAAC,CAAC,CACL,CAAC;IACN,CAAC;CACJ,CAAA;AAlEY,sEAA6B;wCAA7B,6BAA6B;IADzC,IAAA,gBAAO,GAAE;;GACG,6BAA6B,CAkEzC;AAEY,QAAA,6BAA6B,GAAG,gBAAS,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport { publishEvent } from '@lyxa.ai/core/dist/libraries/event';\nimport { NotificationEvent } from '@lyxa.ai/core/dist/libraries/notification';\nimport { ClickType, NotificationAccountType } from '@lyxa.ai/core/dist/utilities/enum';\nimport { ParticipantService } from '../participant/participant.service';\nimport { TournamentParticipantOutputDTO } from '../participant/participant.validation';\n\n@Service()\nexport class TournamentNotificationService {\n private participantService: ParticipantService;\n\n constructor() {\n this.participantService = Container.get(ParticipantService);\n }\n\n private hasNotPredicted(participant: TournamentParticipantOutputDTO, matchId: mongoose.Types.ObjectId): boolean {\n return !participant.predictions.some(p => p.matchId.toString() === matchId.toString());\n }\n\n private async publishNotification(\n recipientId: mongoose.Types.ObjectId,\n title: string,\n body: string\n ): Promise<void> {\n await publishEvent(\n new NotificationEvent({\n title,\n body,\n data: {\n saveNotification: true,\n accountType: NotificationAccountType.USER,\n recipientId,\n isGlobal: false,\n isClickable: true,\n clickType: ClickType.CLICKABLE_FALLBACK,\n },\n })\n );\n }\n\n public async notifyUnpredictedParticipants(\n tournamentId: mongoose.Types.ObjectId,\n matchId: mongoose.Types.ObjectId,\n type: 'before3h' | 'before15min'\n ): Promise<void> {\n const participants = await this.participantService.getAll(tournamentId);\n const unpredicted = participants.filter(p => this.hasNotPredicted(p, matchId));\n\n const title = type === 'before3h' ? \"⏰ Don't miss today's match!\" : '🚨 Final call!';\n const body =\n type === 'before3h'\n ? 'You still have time to predict the exact score and win'\n : 'Only 15 minutes left to submit your prediction';\n\n await Promise.all(unpredicted.map(p => this.publishNotification(p.userId, title, body)));\n }\n\n public async notifyMatchEnded(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<void> {\n const participants = await this.participantService.getAll(tournamentId);\n\n await Promise.all(\n participants.map(p => {\n const prediction = p.predictions.find(pred => pred.matchId.toString() === matchId.toString());\n const won = prediction?.succeeded === true;\n\n const title = won ? '🎉 Your prediction was correct.' : 'Full-time whistle 🏁';\n const body = won\n ? 'Your coupon is now available'\n : 'Better luck next match. New predictions are now open';\n\n return this.publishNotification(p.userId, title, body);\n })\n );\n }\n}\n\nexport const tournamentNotificationService = Container.get(TournamentNotificationService);\n"]}
1
+ {"version":3,"file":"notification.service.js","sourceRoot":"/","sources":["modules/tournament/notification/notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA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,IAAI,EAAE;gBACF,gBAAgB,EAAE,IAAI;gBACtB,WAAW,EAAE,8BAAuB,CAAC,IAAI;gBACzC,WAAW;gBACX,QAAQ,EAAE,KAAK;gBACf,WAAW,EAAE,IAAI;gBACjB,SAAS,EAAE,gBAAS,CAAC,kBAAkB;aAC1C;SACJ,CAAC,CACL,CACJ,CACJ,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAC7B,IAAY,EACZ,MAAc,EACd,SAA2C,EAC3C,YAAqC,EACrC,OAAgC;QAEhC,MAAM,EAAC,KAAK,EAAE,IAAI,EAAC,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAExD,IAAI,MAAM,KAAK,qCAAe,CAAC,MAAM,EAAE,CAAC;YACpC,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACzC,CAAC;aAAM,CAAC;YACJ,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YACxE,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;YAC/E,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;QACxE,CAAC;IACL,CAAC;CACJ,CAAA;AAvEY,sEAA6B;wCAA7B,6BAA6B;IADzC,IAAA,gBAAO,GAAE;;GACG,6BAA6B,CAuEzC;AAEY,QAAA,6BAA6B,GAAG,gBAAS,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {publishEvent} from '@lyxa.ai/core/dist/libraries/event';\nimport {NotificationEvent, NotificationGlobalEvent} from '@lyxa.ai/core/dist/libraries/notification';\nimport {ClickType, NotificationAccountType} from '@lyxa.ai/core/dist/utilities/enum';\nimport {NotificationMessage} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {ParticipantService} from '../participant/participant.service';\nimport {TournamentParticipantOutputDTO} from '../participant/participant.validation';\nimport {ScheduledTarget} from './notification.config';\n\n@Service()\nexport class TournamentNotificationService {\n private participantService: ParticipantService;\n\n constructor() {\n this.participantService = Container.get(ParticipantService);\n }\n\n private getTemplate(templates: Map<string, NotificationMessage>, tag: string): NotificationMessage {\n const t = templates.get(tag);\n if (!t) throw new Error(`No notification template for tag: ${tag}`);\n return t;\n }\n\n private hasNotPredicted(participant: TournamentParticipantOutputDTO, matchId: mongoose.Types.ObjectId): boolean {\n return !participant.predictions.some(p => p.matchId.toString() === matchId.toString());\n }\n\n public async notifyGlobal(title: string, body: string): Promise<void> {\n await publishEvent(\n new NotificationGlobalEvent({\n title,\n body,\n data: {\n saveNotification: true,\n accountType: NotificationAccountType.USER,\n isGlobal: true,\n isClickable: true,\n clickType: ClickType.CLICKABLE_FALLBACK,\n },\n })\n );\n }\n\n public async notifyUsers(title: string, body: string, userIds: mongoose.Types.ObjectId[]): Promise<void> {\n await Promise.all(\n userIds.map(recipientId =>\n publishEvent(\n new NotificationEvent({\n title,\n body,\n data: {\n saveNotification: true,\n accountType: NotificationAccountType.USER,\n recipientId,\n isGlobal: false,\n isClickable: true,\n clickType: ClickType.CLICKABLE_FALLBACK,\n },\n })\n )\n )\n );\n }\n\n public async dispatchScheduledJob(\n type: string,\n target: string,\n templates: Map<string, NotificationMessage>,\n tournamentId: mongoose.Types.ObjectId,\n matchId: mongoose.Types.ObjectId\n ): Promise<void> {\n const {title, body} = this.getTemplate(templates, type);\n\n if (target === ScheduledTarget.GLOBAL) {\n await this.notifyGlobal(title, body);\n } else {\n const participants = await this.participantService.getAll(tournamentId);\n const unpredicted = participants.filter(p => this.hasNotPredicted(p, matchId));\n await this.notifyUsers(title, body, unpredicted.map(p => p.userId));\n }\n }\n}\n\nexport const tournamentNotificationService = Container.get(TournamentNotificationService);\n"]}
@@ -7,6 +7,7 @@ export declare class TournamentParticipantRepository {
7
7
  create(input: object): Promise<ParticipantModelType>;
8
8
  findByUserAndTournament(userId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId): Promise<ParticipantModelType | null>;
9
9
  findByTournament(tournamentId: mongoose.Types.ObjectId): Promise<ParticipantModelType[]>;
10
+ findByUser(userId: mongoose.Types.ObjectId): Promise<ParticipantModelType | null>;
10
11
  }
11
12
  export declare const tournamentParticipantRepository: TournamentParticipantRepository;
12
13
  //# sourceMappingURL=participant.repository.d.ts.map