@lyxa.ai/marketing 1.0.52 → 1.0.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (509) hide show
  1. package/dist/lib/index.d.ts +946 -53
  2. package/dist/lib/index.d.ts.map +1 -1
  3. package/dist/lib/index.js +1 -1
  4. package/dist/lib/index.js.map +1 -1
  5. package/dist/lib/modules/coupon/routers/coupon.router.d.ts +647 -0
  6. package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
  7. package/dist/lib/modules/coupon/routers/coupon.router.js +7 -0
  8. package/dist/lib/modules/coupon/routers/coupon.router.js.map +1 -1
  9. package/dist/lib/modules/coupon/services/coupon.service.d.ts +8 -1
  10. package/dist/lib/modules/coupon/services/coupon.service.d.ts.map +1 -1
  11. package/dist/lib/modules/coupon/services/coupon.service.js +231 -27
  12. package/dist/lib/modules/coupon/services/coupon.service.js.map +1 -1
  13. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
  14. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js +17 -4
  15. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js.map +1 -1
  16. package/dist/lib/modules/coupon/validations/coupon.validation.d.ts +26 -0
  17. package/dist/lib/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
  18. package/dist/lib/modules/coupon/validations/coupon.validation.js +10 -1
  19. package/dist/lib/modules/coupon/validations/coupon.validation.js.map +1 -1
  20. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts +40 -40
  21. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js +9 -9
  22. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js.map +1 -1
  23. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts +0 -1
  24. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts.map +1 -1
  25. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.js +2 -5
  26. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.js.map +1 -1
  27. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts +1 -0
  28. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts.map +1 -1
  29. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.js +2 -0
  30. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.js.map +1 -1
  31. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +53 -40
  32. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts.map +1 -1
  33. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js +3 -2
  34. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js.map +1 -1
  35. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts +3 -9
  36. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
  37. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js +4 -7
  38. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js.map +1 -1
  39. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts +1 -0
  40. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts.map +1 -1
  41. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.service.js +15 -0
  42. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.service.js.map +1 -1
  43. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts +88 -42
  44. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
  45. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.js +23 -0
  46. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.js.map +1 -1
  47. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts +19 -0
  48. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -0
  49. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js +84 -0
  50. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js.map +1 -0
  51. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.builder.d.ts +13 -0
  52. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.builder.d.ts.map +1 -0
  53. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.builder.js +22 -0
  54. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.builder.js.map +1 -0
  55. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts +20 -0
  56. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts.map +1 -0
  57. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.js +26 -0
  58. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.js.map +1 -0
  59. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.service.d.ts +8 -0
  60. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.service.d.ts.map +1 -0
  61. package/dist/lib/modules/{tournament/notification/notification.scheduler.service.js → limited-time-offer/notification/limited-time-offer-notification.service.js} +15 -28
  62. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.service.js.map +1 -0
  63. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.type.d.ts +5 -0
  64. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.type.d.ts.map +1 -0
  65. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.type.js +3 -0
  66. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.type.js.map +1 -0
  67. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.js +1 -1
  68. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.js.map +1 -1
  69. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +13 -0
  70. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
  71. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js +75 -0
  72. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js.map +1 -1
  73. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +6 -2
  74. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
  75. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts +1 -0
  76. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts.map +1 -0
  77. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.js +2 -0
  78. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.js.map +1 -0
  79. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +6 -1
  80. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
  81. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js +3 -2
  82. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js.map +1 -1
  83. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +12 -2
  84. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  85. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js +80 -27
  86. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js.map +1 -1
  87. package/dist/lib/modules/marketing/services/marketing.service.d.ts +1 -0
  88. package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
  89. package/dist/lib/modules/marketing/services/marketing.service.js +9 -0
  90. package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -1
  91. package/dist/lib/modules/marketing/validations/product-marketing.validation.d.ts +2 -2
  92. package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +1 -1
  93. package/dist/lib/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +2 -2
  94. package/dist/lib/modules/tournament/config/config.builder.d.ts.map +1 -1
  95. package/dist/lib/modules/tournament/config/config.builder.js +4 -0
  96. package/dist/lib/modules/tournament/config/config.builder.js.map +1 -1
  97. package/dist/lib/modules/tournament/config/config.repository.d.ts +8 -2
  98. package/dist/lib/modules/tournament/config/config.repository.d.ts.map +1 -1
  99. package/dist/lib/modules/tournament/config/config.repository.js +30 -1
  100. package/dist/lib/modules/tournament/config/config.repository.js.map +1 -1
  101. package/dist/lib/modules/tournament/config/config.router.d.ts +92 -2
  102. package/dist/lib/modules/tournament/config/config.router.d.ts.map +1 -1
  103. package/dist/lib/modules/tournament/config/config.types.d.ts +15 -0
  104. package/dist/lib/modules/tournament/config/config.types.d.ts.map +1 -0
  105. package/dist/lib/modules/tournament/config/config.types.js +3 -0
  106. package/dist/lib/modules/tournament/config/config.types.js.map +1 -0
  107. package/dist/lib/modules/tournament/config/config.validation.d.ts +395 -15
  108. package/dist/lib/modules/tournament/config/config.validation.d.ts.map +1 -1
  109. package/dist/lib/modules/tournament/config/config.validation.js +17 -2
  110. package/dist/lib/modules/tournament/config/config.validation.js.map +1 -1
  111. package/dist/lib/modules/tournament/integration/integration.factory.d.ts +4 -0
  112. package/dist/lib/modules/tournament/integration/integration.factory.d.ts.map +1 -0
  113. package/dist/lib/modules/tournament/integration/integration.factory.js +18 -0
  114. package/dist/lib/modules/tournament/integration/integration.factory.js.map +1 -0
  115. package/dist/lib/modules/tournament/integration/interfaces/ITournamentService.d.ts +36 -0
  116. package/dist/lib/modules/tournament/integration/interfaces/ITournamentService.d.ts.map +1 -0
  117. package/dist/lib/modules/tournament/integration/interfaces/ITournamentService.js +3 -0
  118. package/dist/lib/modules/tournament/integration/interfaces/ITournamentService.js.map +1 -0
  119. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.provider.d.ts +14 -0
  120. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.provider.d.ts.map +1 -0
  121. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.provider.js +92 -0
  122. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.provider.js.map +1 -0
  123. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.types.d.ts +51 -0
  124. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.types.d.ts.map +1 -0
  125. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.types.js +3 -0
  126. package/dist/lib/modules/tournament/integration/providers/api-football/api-football.types.js.map +1 -0
  127. package/dist/lib/modules/tournament/integration/providers/api-football/index.d.ts +3 -0
  128. package/dist/lib/modules/tournament/integration/providers/api-football/index.d.ts.map +1 -0
  129. package/dist/lib/modules/tournament/integration/providers/api-football/index.js +19 -0
  130. package/dist/lib/modules/tournament/integration/providers/api-football/index.js.map +1 -0
  131. package/dist/lib/modules/tournament/integration/providers/index.d.ts +3 -0
  132. package/dist/lib/modules/tournament/integration/providers/index.d.ts.map +1 -0
  133. package/dist/lib/modules/tournament/integration/providers/index.js +19 -0
  134. package/dist/lib/modules/tournament/integration/providers/index.js.map +1 -0
  135. package/dist/lib/modules/tournament/integration/providers/mock.provider.d.ts +7 -0
  136. package/dist/lib/modules/tournament/integration/providers/mock.provider.d.ts.map +1 -0
  137. package/dist/lib/modules/tournament/integration/providers/mock.provider.js +22 -0
  138. package/dist/lib/modules/tournament/integration/providers/mock.provider.js.map +1 -0
  139. package/dist/lib/modules/tournament/integration/tournamentService.d.ts +9 -0
  140. package/dist/lib/modules/tournament/integration/tournamentService.d.ts.map +1 -0
  141. package/dist/lib/modules/tournament/integration/tournamentService.js +20 -0
  142. package/dist/lib/modules/tournament/integration/tournamentService.js.map +1 -0
  143. package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.d.ts.map +1 -1
  144. package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js +47 -11
  145. package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js.map +1 -1
  146. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.d.ts +7 -3
  147. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.d.ts.map +1 -1
  148. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.js +1 -1
  149. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.js.map +1 -1
  150. package/dist/lib/modules/tournament/match/events/match-evaluation.orchestrator.d.ts +14 -0
  151. package/dist/lib/modules/tournament/match/events/match-evaluation.orchestrator.d.ts.map +1 -0
  152. package/dist/lib/modules/tournament/{notification/jobs/notification.worker.js → match/events/match-evaluation.orchestrator.js} +31 -27
  153. package/dist/lib/modules/tournament/match/events/match-evaluation.orchestrator.js.map +1 -0
  154. package/dist/lib/modules/tournament/match/match.builder.d.ts +13 -34
  155. package/dist/lib/modules/tournament/match/match.builder.d.ts.map +1 -1
  156. package/dist/lib/modules/tournament/match/match.builder.js +31 -10
  157. package/dist/lib/modules/tournament/match/match.builder.js.map +1 -1
  158. package/dist/lib/modules/tournament/match/match.repository.d.ts +1 -1
  159. package/dist/lib/modules/tournament/match/match.repository.d.ts.map +1 -1
  160. package/dist/lib/modules/tournament/match/match.repository.js.map +1 -1
  161. package/dist/lib/modules/tournament/match/match.router.d.ts +36 -0
  162. package/dist/lib/modules/tournament/match/match.router.d.ts.map +1 -1
  163. package/dist/lib/modules/tournament/match/match.service.d.ts +3 -0
  164. package/dist/lib/modules/tournament/match/match.service.d.ts.map +1 -1
  165. package/dist/lib/modules/tournament/match/match.service.js +15 -12
  166. package/dist/lib/modules/tournament/match/match.service.js.map +1 -1
  167. package/dist/lib/modules/tournament/match/match.types.d.ts +51 -0
  168. package/dist/lib/modules/tournament/match/match.types.d.ts.map +1 -0
  169. package/dist/lib/modules/tournament/match/match.types.js +3 -0
  170. package/dist/lib/modules/tournament/match/match.types.js.map +1 -0
  171. package/dist/lib/modules/tournament/notification/notification-template.repository.d.ts +2 -1
  172. package/dist/lib/modules/tournament/notification/notification-template.repository.d.ts.map +1 -1
  173. package/dist/lib/modules/tournament/notification/notification-template.repository.js +2 -1
  174. package/dist/lib/modules/tournament/notification/notification-template.repository.js.map +1 -1
  175. package/dist/lib/modules/tournament/notification/notification.builder.d.ts +30 -0
  176. package/dist/lib/modules/tournament/notification/notification.builder.d.ts.map +1 -0
  177. package/dist/lib/modules/tournament/notification/notification.builder.js +35 -0
  178. package/dist/lib/modules/tournament/notification/notification.builder.js.map +1 -0
  179. package/dist/lib/modules/tournament/notification/notification.config.d.ts +10 -9
  180. package/dist/lib/modules/tournament/notification/notification.config.d.ts.map +1 -1
  181. package/dist/lib/modules/tournament/notification/notification.config.js +0 -12
  182. package/dist/lib/modules/tournament/notification/notification.config.js.map +1 -1
  183. package/dist/lib/modules/tournament/notification/notification.service.d.ts +5 -3
  184. package/dist/lib/modules/tournament/notification/notification.service.d.ts.map +1 -1
  185. package/dist/lib/modules/tournament/notification/notification.service.js +23 -15
  186. package/dist/lib/modules/tournament/notification/notification.service.js.map +1 -1
  187. package/dist/lib/modules/tournament/participant/participant.builder.d.ts +12 -0
  188. package/dist/lib/modules/tournament/participant/participant.builder.d.ts.map +1 -0
  189. package/dist/lib/modules/tournament/participant/participant.builder.js +17 -0
  190. package/dist/lib/modules/tournament/participant/participant.builder.js.map +1 -0
  191. package/dist/lib/modules/tournament/participant/participant.repository.d.ts +8 -7
  192. package/dist/lib/modules/tournament/participant/participant.repository.d.ts.map +1 -1
  193. package/dist/lib/modules/tournament/participant/participant.repository.js +12 -2
  194. package/dist/lib/modules/tournament/participant/participant.repository.js.map +1 -1
  195. package/dist/lib/modules/tournament/participant/participant.service.d.ts +1 -0
  196. package/dist/lib/modules/tournament/participant/participant.service.d.ts.map +1 -1
  197. package/dist/lib/modules/tournament/participant/participant.service.js +15 -17
  198. package/dist/lib/modules/tournament/participant/participant.service.js.map +1 -1
  199. package/dist/lib/modules/tournament/prediction/prediction.builder.d.ts +3 -9
  200. package/dist/lib/modules/tournament/prediction/prediction.builder.d.ts.map +1 -1
  201. package/dist/lib/modules/tournament/prediction/prediction.builder.js.map +1 -1
  202. package/dist/lib/modules/tournament/prediction/prediction.repository.d.ts +11 -3
  203. package/dist/lib/modules/tournament/prediction/prediction.repository.d.ts.map +1 -1
  204. package/dist/lib/modules/tournament/prediction/prediction.repository.js +47 -0
  205. package/dist/lib/modules/tournament/prediction/prediction.repository.js.map +1 -1
  206. package/dist/lib/modules/tournament/prediction/prediction.service.d.ts +1 -1
  207. package/dist/lib/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
  208. package/dist/lib/modules/tournament/prediction/prediction.service.js +16 -26
  209. package/dist/lib/modules/tournament/prediction/prediction.service.js.map +1 -1
  210. package/dist/lib/modules/tournament/prediction/prediction.types.d.ts +17 -0
  211. package/dist/lib/modules/tournament/prediction/prediction.types.d.ts.map +1 -0
  212. package/dist/lib/modules/tournament/prediction/prediction.types.js +3 -0
  213. package/dist/lib/modules/tournament/prediction/prediction.types.js.map +1 -0
  214. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.d.ts +8 -5
  215. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.d.ts.map +1 -1
  216. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.js +58 -16
  217. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.js.map +1 -1
  218. package/dist/lib/modules/tournament/reward/reward.builder.d.ts +5 -2
  219. package/dist/lib/modules/tournament/reward/reward.builder.d.ts.map +1 -1
  220. package/dist/lib/modules/tournament/reward/reward.builder.js +44 -28
  221. package/dist/lib/modules/tournament/reward/reward.builder.js.map +1 -1
  222. package/dist/lib/modules/tournament/reward/reward.factory.d.ts +1 -1
  223. package/dist/lib/modules/tournament/reward/reward.factory.d.ts.map +1 -1
  224. package/dist/lib/modules/tournament/reward/reward.factory.js.map +1 -1
  225. package/dist/lib/modules/tournament/reward/reward.interface.d.ts +2 -2
  226. package/dist/lib/modules/tournament/reward/reward.interface.d.ts.map +1 -1
  227. package/dist/lib/modules/tournament/reward/reward.interface.js.map +1 -1
  228. package/dist/lib/modules/tournament/reward/reward.service.d.ts +1 -1
  229. package/dist/lib/modules/tournament/reward/reward.service.d.ts.map +1 -1
  230. package/dist/lib/modules/tournament/reward/reward.service.js +1 -1
  231. package/dist/lib/modules/tournament/reward/reward.service.js.map +1 -1
  232. package/dist/lib/modules/tournament/reward/reward.types.d.ts +35 -2
  233. package/dist/lib/modules/tournament/reward/reward.types.d.ts.map +1 -1
  234. package/dist/lib/modules/tournament/reward/reward.types.js.map +1 -1
  235. package/dist/lib/modules/tournament/schedule/schedule.router.d.ts.map +1 -1
  236. package/dist/lib/modules/tournament/schedule/schedule.router.js +1 -3
  237. package/dist/lib/modules/tournament/schedule/schedule.router.js.map +1 -1
  238. package/dist/lib/modules/tournament/schedule/schedule.service.d.ts +3 -0
  239. package/dist/lib/modules/tournament/schedule/schedule.service.d.ts.map +1 -1
  240. package/dist/lib/modules/tournament/schedule/schedule.service.js +30 -1
  241. package/dist/lib/modules/tournament/schedule/schedule.service.js.map +1 -1
  242. package/dist/lib/modules/tournament/score/score.repository.d.ts +13 -0
  243. package/dist/lib/modules/tournament/score/score.repository.d.ts.map +1 -1
  244. package/dist/lib/modules/tournament/score/score.repository.js +20 -0
  245. package/dist/lib/modules/tournament/score/score.repository.js.map +1 -1
  246. package/dist/lib/modules/tournament/score/score.service.d.ts +3 -0
  247. package/dist/lib/modules/tournament/score/score.service.d.ts.map +1 -1
  248. package/dist/lib/modules/tournament/score/score.service.js +3 -0
  249. package/dist/lib/modules/tournament/score/score.service.js.map +1 -1
  250. package/dist/lib/modules/tournament/statistics/statistics.builder.d.ts +5 -0
  251. package/dist/lib/modules/tournament/statistics/statistics.builder.d.ts.map +1 -1
  252. package/dist/lib/modules/tournament/statistics/statistics.builder.js +47 -28
  253. package/dist/lib/modules/tournament/statistics/statistics.builder.js.map +1 -1
  254. package/dist/lib/modules/tournament/statistics/statistics.router.d.ts +4 -2
  255. package/dist/lib/modules/tournament/statistics/statistics.router.d.ts.map +1 -1
  256. package/dist/lib/modules/tournament/statistics/statistics.service.js +4 -4
  257. package/dist/lib/modules/tournament/statistics/statistics.service.js.map +1 -1
  258. package/dist/lib/modules/tournament/statistics/statistics.validation.d.ts +32 -14
  259. package/dist/lib/modules/tournament/statistics/statistics.validation.d.ts.map +1 -1
  260. package/dist/lib/modules/tournament/statistics/statistics.validation.js +2 -1
  261. package/dist/lib/modules/tournament/statistics/statistics.validation.js.map +1 -1
  262. package/dist/lib/modules/tournament/sync/sync.repository.d.ts +11 -0
  263. package/dist/lib/modules/tournament/sync/sync.repository.d.ts.map +1 -0
  264. package/dist/lib/modules/tournament/sync/sync.repository.js +67 -0
  265. package/dist/lib/modules/tournament/sync/sync.repository.js.map +1 -0
  266. package/dist/lib/modules/tournament/sync/sync.router.d.ts +27 -0
  267. package/dist/lib/modules/tournament/sync/sync.router.d.ts.map +1 -0
  268. package/dist/lib/modules/tournament/sync/sync.router.js +15 -0
  269. package/dist/lib/modules/tournament/sync/sync.router.js.map +1 -0
  270. package/dist/lib/modules/tournament/sync/sync.service.d.ts +9 -0
  271. package/dist/lib/modules/tournament/sync/sync.service.d.ts.map +1 -0
  272. package/dist/lib/modules/tournament/sync/sync.service.js +117 -0
  273. package/dist/lib/modules/tournament/sync/sync.service.js.map +1 -0
  274. package/dist/lib/modules/tournament/team/team.builder.d.ts +4 -0
  275. package/dist/lib/modules/tournament/team/team.builder.d.ts.map +1 -1
  276. package/dist/lib/modules/tournament/team/team.builder.js +6 -0
  277. package/dist/lib/modules/tournament/team/team.builder.js.map +1 -1
  278. package/dist/lib/modules/tournament/team/team.repository.d.ts +3 -0
  279. package/dist/lib/modules/tournament/team/team.repository.d.ts.map +1 -1
  280. package/dist/lib/modules/tournament/team/team.repository.js +6 -0
  281. package/dist/lib/modules/tournament/team/team.repository.js.map +1 -1
  282. package/dist/lib/modules/tournament/team/team.router.d.ts +22 -4
  283. package/dist/lib/modules/tournament/team/team.router.d.ts.map +1 -1
  284. package/dist/lib/modules/tournament/team/team.router.js +1 -1
  285. package/dist/lib/modules/tournament/team/team.router.js.map +1 -1
  286. package/dist/lib/modules/tournament/team/team.service.d.ts +2 -1
  287. package/dist/lib/modules/tournament/team/team.service.d.ts.map +1 -1
  288. package/dist/lib/modules/tournament/team/team.service.js +26 -23
  289. package/dist/lib/modules/tournament/team/team.service.js.map +1 -1
  290. package/dist/lib/modules/tournament/team/team.validation.d.ts +23 -24
  291. package/dist/lib/modules/tournament/team/team.validation.d.ts.map +1 -1
  292. package/dist/lib/modules/tournament/team/team.validation.js +3 -4
  293. package/dist/lib/modules/tournament/team/team.validation.js.map +1 -1
  294. package/dist/lib/modules/tournament/tournament.builder.d.ts +11 -0
  295. package/dist/lib/modules/tournament/tournament.builder.d.ts.map +1 -0
  296. package/dist/lib/modules/tournament/tournament.builder.js +34 -0
  297. package/dist/lib/modules/tournament/tournament.builder.js.map +1 -0
  298. package/dist/lib/modules/tournament/tournament.router.d.ts +210 -10
  299. package/dist/lib/modules/tournament/tournament.router.d.ts.map +1 -1
  300. package/dist/lib/modules/tournament/tournament.router.js +2 -0
  301. package/dist/lib/modules/tournament/tournament.router.js.map +1 -1
  302. package/dist/lib/modules/tournament/tournament.service.d.ts.map +1 -1
  303. package/dist/lib/modules/tournament/tournament.service.js +3 -10
  304. package/dist/lib/modules/tournament/tournament.service.js.map +1 -1
  305. package/dist/lib/modules/tournament/tournament.utils.d.ts +4 -0
  306. package/dist/lib/modules/tournament/tournament.utils.d.ts.map +1 -1
  307. package/dist/lib/modules/tournament/tournament.utils.js +8 -1
  308. package/dist/lib/modules/tournament/tournament.utils.js.map +1 -1
  309. package/dist/lib/modules/tournament/tournament.validation.d.ts +205 -1
  310. package/dist/lib/modules/tournament/tournament.validation.d.ts.map +1 -1
  311. package/dist/lib/modules/tournament/tournament.validation.js +23 -2
  312. package/dist/lib/modules/tournament/tournament.validation.js.map +1 -1
  313. package/dist/types/index.d.ts +946 -53
  314. package/dist/types/index.d.ts.map +1 -1
  315. package/dist/types/modules/coupon/routers/coupon.router.d.ts +647 -0
  316. package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
  317. package/dist/types/modules/coupon/services/coupon.service.d.ts +8 -1
  318. package/dist/types/modules/coupon/services/coupon.service.d.ts.map +1 -1
  319. package/dist/types/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
  320. package/dist/types/modules/coupon/validations/coupon.validation.d.ts +26 -0
  321. package/dist/types/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
  322. package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts +42 -40
  323. package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
  324. package/dist/types/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts +0 -1
  325. package/dist/types/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts.map +1 -1
  326. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts +1 -0
  327. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts.map +1 -1
  328. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +53 -40
  329. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts.map +1 -1
  330. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts +3 -9
  331. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
  332. package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts +1 -0
  333. package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts.map +1 -1
  334. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts +88 -42
  335. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
  336. package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts +24 -0
  337. package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -0
  338. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.builder.d.ts +13 -0
  339. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.builder.d.ts.map +1 -0
  340. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts +20 -0
  341. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts.map +1 -0
  342. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.service.d.ts +8 -0
  343. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.service.d.ts.map +1 -0
  344. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.type.d.ts +5 -0
  345. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.type.d.ts.map +1 -0
  346. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +13 -0
  347. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
  348. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +6 -2
  349. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
  350. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +6 -1
  351. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
  352. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +22 -2
  353. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  354. package/dist/types/modules/marketing/services/marketing.service.d.ts +1 -0
  355. package/dist/types/modules/marketing/services/marketing.service.d.ts.map +1 -1
  356. package/dist/types/modules/marketing/validations/product-marketing.validation.d.ts +2 -2
  357. package/dist/types/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +1 -1
  358. package/dist/types/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +2 -2
  359. package/dist/types/modules/tournament/config/config.builder.d.ts.map +1 -1
  360. package/dist/types/modules/tournament/config/config.repository.d.ts +8 -2
  361. package/dist/types/modules/tournament/config/config.repository.d.ts.map +1 -1
  362. package/dist/types/modules/tournament/config/config.router.d.ts +92 -2
  363. package/dist/types/modules/tournament/config/config.router.d.ts.map +1 -1
  364. package/dist/types/modules/tournament/config/config.types.d.ts +15 -0
  365. package/dist/types/modules/tournament/config/config.types.d.ts.map +1 -0
  366. package/dist/types/modules/tournament/config/config.validation.d.ts +395 -15
  367. package/dist/types/modules/tournament/config/config.validation.d.ts.map +1 -1
  368. package/dist/types/modules/tournament/integration/integration.factory.d.ts +4 -0
  369. package/dist/types/modules/tournament/integration/integration.factory.d.ts.map +1 -0
  370. package/dist/types/modules/tournament/integration/interfaces/ITournamentService.d.ts +36 -0
  371. package/dist/types/modules/tournament/integration/interfaces/ITournamentService.d.ts.map +1 -0
  372. package/dist/types/modules/tournament/integration/providers/api-football/api-football.provider.d.ts +14 -0
  373. package/dist/types/modules/tournament/integration/providers/api-football/api-football.provider.d.ts.map +1 -0
  374. package/dist/types/modules/tournament/integration/providers/api-football/api-football.types.d.ts +51 -0
  375. package/dist/types/modules/tournament/integration/providers/api-football/api-football.types.d.ts.map +1 -0
  376. package/dist/types/modules/tournament/integration/providers/api-football/index.d.ts +3 -0
  377. package/dist/types/modules/tournament/integration/providers/api-football/index.d.ts.map +1 -0
  378. package/dist/types/modules/tournament/integration/providers/index.d.ts +3 -0
  379. package/dist/types/modules/tournament/integration/providers/index.d.ts.map +1 -0
  380. package/dist/types/modules/tournament/integration/providers/mock.provider.d.ts +7 -0
  381. package/dist/types/modules/tournament/integration/providers/mock.provider.d.ts.map +1 -0
  382. package/dist/types/modules/tournament/integration/tournamentService.d.ts +9 -0
  383. package/dist/types/modules/tournament/integration/tournamentService.d.ts.map +1 -0
  384. package/dist/types/modules/tournament/match/events/evaluate-predictions.consumer.d.ts.map +1 -1
  385. package/dist/types/modules/tournament/match/events/evaluate-predictions.event.d.ts +7 -3
  386. package/dist/types/modules/tournament/match/events/evaluate-predictions.event.d.ts.map +1 -1
  387. package/dist/types/modules/tournament/match/events/match-evaluation.orchestrator.d.ts +14 -0
  388. package/dist/types/modules/tournament/match/events/match-evaluation.orchestrator.d.ts.map +1 -0
  389. package/dist/types/modules/tournament/match/match.builder.d.ts +13 -34
  390. package/dist/types/modules/tournament/match/match.builder.d.ts.map +1 -1
  391. package/dist/types/modules/tournament/match/match.repository.d.ts +1 -1
  392. package/dist/types/modules/tournament/match/match.repository.d.ts.map +1 -1
  393. package/dist/types/modules/tournament/match/match.router.d.ts +36 -0
  394. package/dist/types/modules/tournament/match/match.router.d.ts.map +1 -1
  395. package/dist/types/modules/tournament/match/match.service.d.ts +3 -0
  396. package/dist/types/modules/tournament/match/match.service.d.ts.map +1 -1
  397. package/dist/types/modules/tournament/match/match.types.d.ts +51 -0
  398. package/dist/types/modules/tournament/match/match.types.d.ts.map +1 -0
  399. package/dist/types/modules/tournament/notification/notification-template.repository.d.ts +2 -1
  400. package/dist/types/modules/tournament/notification/notification-template.repository.d.ts.map +1 -1
  401. package/dist/types/modules/tournament/notification/notification.builder.d.ts +30 -0
  402. package/dist/types/modules/tournament/notification/notification.builder.d.ts.map +1 -0
  403. package/dist/types/modules/tournament/notification/notification.config.d.ts +10 -9
  404. package/dist/types/modules/tournament/notification/notification.config.d.ts.map +1 -1
  405. package/dist/types/modules/tournament/notification/notification.service.d.ts +5 -3
  406. package/dist/types/modules/tournament/notification/notification.service.d.ts.map +1 -1
  407. package/dist/types/modules/tournament/participant/participant.builder.d.ts +12 -0
  408. package/dist/types/modules/tournament/participant/participant.builder.d.ts.map +1 -0
  409. package/dist/types/modules/tournament/participant/participant.repository.d.ts +8 -7
  410. package/dist/types/modules/tournament/participant/participant.repository.d.ts.map +1 -1
  411. package/dist/types/modules/tournament/participant/participant.service.d.ts +1 -0
  412. package/dist/types/modules/tournament/participant/participant.service.d.ts.map +1 -1
  413. package/dist/types/modules/tournament/prediction/prediction.builder.d.ts +3 -9
  414. package/dist/types/modules/tournament/prediction/prediction.builder.d.ts.map +1 -1
  415. package/dist/types/modules/tournament/prediction/prediction.repository.d.ts +11 -3
  416. package/dist/types/modules/tournament/prediction/prediction.repository.d.ts.map +1 -1
  417. package/dist/types/modules/tournament/prediction/prediction.service.d.ts +1 -1
  418. package/dist/types/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
  419. package/dist/types/modules/tournament/prediction/prediction.types.d.ts +17 -0
  420. package/dist/types/modules/tournament/prediction/prediction.types.d.ts.map +1 -0
  421. package/dist/types/modules/tournament/reward/handlers/coupon-reward.handler.d.ts +8 -5
  422. package/dist/types/modules/tournament/reward/handlers/coupon-reward.handler.d.ts.map +1 -1
  423. package/dist/types/modules/tournament/reward/reward.builder.d.ts +5 -2
  424. package/dist/types/modules/tournament/reward/reward.builder.d.ts.map +1 -1
  425. package/dist/types/modules/tournament/reward/reward.factory.d.ts +1 -1
  426. package/dist/types/modules/tournament/reward/reward.factory.d.ts.map +1 -1
  427. package/dist/types/modules/tournament/reward/reward.interface.d.ts +2 -2
  428. package/dist/types/modules/tournament/reward/reward.interface.d.ts.map +1 -1
  429. package/dist/types/modules/tournament/reward/reward.service.d.ts +1 -1
  430. package/dist/types/modules/tournament/reward/reward.service.d.ts.map +1 -1
  431. package/dist/types/modules/tournament/reward/reward.types.d.ts +35 -2
  432. package/dist/types/modules/tournament/reward/reward.types.d.ts.map +1 -1
  433. package/dist/types/modules/tournament/schedule/schedule.router.d.ts.map +1 -1
  434. package/dist/types/modules/tournament/schedule/schedule.service.d.ts +3 -0
  435. package/dist/types/modules/tournament/schedule/schedule.service.d.ts.map +1 -1
  436. package/dist/types/modules/tournament/score/score.repository.d.ts +13 -0
  437. package/dist/types/modules/tournament/score/score.repository.d.ts.map +1 -1
  438. package/dist/types/modules/tournament/score/score.service.d.ts +3 -0
  439. package/dist/types/modules/tournament/score/score.service.d.ts.map +1 -1
  440. package/dist/types/modules/tournament/statistics/statistics.builder.d.ts +5 -0
  441. package/dist/types/modules/tournament/statistics/statistics.builder.d.ts.map +1 -1
  442. package/dist/types/modules/tournament/statistics/statistics.router.d.ts +4 -2
  443. package/dist/types/modules/tournament/statistics/statistics.router.d.ts.map +1 -1
  444. package/dist/types/modules/tournament/statistics/statistics.validation.d.ts +32 -14
  445. package/dist/types/modules/tournament/statistics/statistics.validation.d.ts.map +1 -1
  446. package/dist/types/modules/tournament/sync/sync.repository.d.ts +11 -0
  447. package/dist/types/modules/tournament/sync/sync.repository.d.ts.map +1 -0
  448. package/dist/types/modules/tournament/sync/sync.router.d.ts +27 -0
  449. package/dist/types/modules/tournament/sync/sync.router.d.ts.map +1 -0
  450. package/dist/types/modules/tournament/sync/sync.service.d.ts +9 -0
  451. package/dist/types/modules/tournament/sync/sync.service.d.ts.map +1 -0
  452. package/dist/types/modules/tournament/team/team.builder.d.ts +4 -0
  453. package/dist/types/modules/tournament/team/team.builder.d.ts.map +1 -1
  454. package/dist/types/modules/tournament/team/team.repository.d.ts +3 -0
  455. package/dist/types/modules/tournament/team/team.repository.d.ts.map +1 -1
  456. package/dist/types/modules/tournament/team/team.router.d.ts +22 -4
  457. package/dist/types/modules/tournament/team/team.router.d.ts.map +1 -1
  458. package/dist/types/modules/tournament/team/team.service.d.ts +2 -1
  459. package/dist/types/modules/tournament/team/team.service.d.ts.map +1 -1
  460. package/dist/types/modules/tournament/team/team.validation.d.ts +23 -24
  461. package/dist/types/modules/tournament/team/team.validation.d.ts.map +1 -1
  462. package/dist/types/modules/tournament/tournament.builder.d.ts +11 -0
  463. package/dist/types/modules/tournament/tournament.builder.d.ts.map +1 -0
  464. package/dist/types/modules/tournament/tournament.router.d.ts +210 -10
  465. package/dist/types/modules/tournament/tournament.router.d.ts.map +1 -1
  466. package/dist/types/modules/tournament/tournament.service.d.ts.map +1 -1
  467. package/dist/types/modules/tournament/tournament.utils.d.ts +4 -0
  468. package/dist/types/modules/tournament/tournament.utils.d.ts.map +1 -1
  469. package/dist/types/modules/tournament/tournament.validation.d.ts +205 -1
  470. package/dist/types/modules/tournament/tournament.validation.d.ts.map +1 -1
  471. package/package.json +2 -2
  472. package/dist/lib/modules/tournament/match/events/match-ended.consumer.d.ts +0 -2
  473. package/dist/lib/modules/tournament/match/events/match-ended.consumer.d.ts.map +0 -1
  474. package/dist/lib/modules/tournament/match/events/match-ended.consumer.js +0 -15
  475. package/dist/lib/modules/tournament/match/events/match-ended.consumer.js.map +0 -1
  476. package/dist/lib/modules/tournament/match/events/match-ended.event.d.ts +0 -14
  477. package/dist/lib/modules/tournament/match/events/match-ended.event.d.ts.map +0 -1
  478. package/dist/lib/modules/tournament/match/events/match-ended.event.js +0 -12
  479. package/dist/lib/modules/tournament/match/events/match-ended.event.js.map +0 -1
  480. package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts +0 -10
  481. package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts.map +0 -1
  482. package/dist/lib/modules/tournament/notification/jobs/notification.producer.js +0 -23
  483. package/dist/lib/modules/tournament/notification/jobs/notification.producer.js.map +0 -1
  484. package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts +0 -9
  485. package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts.map +0 -1
  486. package/dist/lib/modules/tournament/notification/jobs/notification.worker.js.map +0 -1
  487. package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts +0 -10
  488. package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts.map +0 -1
  489. package/dist/lib/modules/tournament/notification/notification.schedule.config.js +0 -15
  490. package/dist/lib/modules/tournament/notification/notification.schedule.config.js.map +0 -1
  491. package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts +0 -10
  492. package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts.map +0 -1
  493. package/dist/lib/modules/tournament/notification/notification.scheduler.service.js.map +0 -1
  494. package/dist/types/events/event-initializations.d.ts +0 -2
  495. package/dist/types/events/event-initializations.d.ts.map +0 -1
  496. package/dist/types/modules/tournament/config/tournament-config.validation.d.ts +0 -201
  497. package/dist/types/modules/tournament/config/tournament-config.validation.d.ts.map +0 -1
  498. package/dist/types/modules/tournament/match/events/match-ended.consumer.d.ts +0 -2
  499. package/dist/types/modules/tournament/match/events/match-ended.consumer.d.ts.map +0 -1
  500. package/dist/types/modules/tournament/match/events/match-ended.event.d.ts +0 -14
  501. package/dist/types/modules/tournament/match/events/match-ended.event.d.ts.map +0 -1
  502. package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts +0 -10
  503. package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts.map +0 -1
  504. package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts +0 -9
  505. package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts.map +0 -1
  506. package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts +0 -10
  507. package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts.map +0 -1
  508. package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts +0 -10
  509. package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"coupon-reward.handler.js","sourceRoot":"/","sources":["modules/tournament/reward/handlers/coupon-reward.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,sEAAsF;AAItF,4GAAoG;AACpG,4EAAsE;AAEtE,MAAM,eAAe,GAAG,KAAK,CAAC;AAGvB,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IACpB,2BAA2B,CAA8B;IACzD,aAAa,CAAgB;IAC7B,eAAe,CAAuD;IAE9E;QACI,IAAI,CAAC,2BAA2B,GAAG,gBAAS,CAAC,GAAG,CAAC,4DAA2B,CAAC,CAAC;QAC9E,IAAI,CAAC,aAAa,GAAG,gBAAS,CAAC,GAAG,CAAC,8BAAa,CAAC,CAAC;QAClD,IAAI,CAAC,eAAe,GAAG,wBAAuE,CAAC;IACnG,CAAC;IAEO,KAAK,CAAC,WAAW;QACrB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,EAAC,IAAI,EAAE,IAAI,MAAM,CAAC,IAAI,eAAe,EAAE,CAAC,EAAC,CAAC,CAAC;QACnG,OAAO,GAAG,eAAe,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;IACrE,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAAsB;QAC9B,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACnC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;YACtC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,2BAA2B,CAAC,MAAM,CAAC;gBACzD,GAAG,OAAO,CAAC,OAAO;gBAClB,IAAI;gBACJ,KAAK,EAAE,CAAC,MAAM,CAAC;aACX,CAAC,CAAC;YAEV,MAAM,IAAI,CAAC,aAAa,CAAC,0BAA0B,CAC/C,EAAC,GAAG,EAAE,MAAM,EAAC,EACb,MAAM,CAAC,GAAG,CACb,CAAC;QACN,CAAC;IACL,CAAC;CACJ,CAAA;AA/BY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,gBAAO,GAAE;;GACG,mBAAmB,CA+B/B","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {BaseCoupon, BaseCouponModel} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {SoftDeleteModel} from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport {IRewardHandler} from '../reward.interface';\nimport {RewardContext} from '../reward.types';\nimport {IndividualUserCouponService} from '@modules/coupon/services/individual-user-coupon.service';\nimport {CouponService} from '@modules/coupon/services/coupon.service';\n\nconst FWC_CODE_PREFIX = 'FWC';\n\n@Service()\nexport class CouponRewardHandler implements IRewardHandler {\n private individualUserCouponService: IndividualUserCouponService;\n private couponService: CouponService;\n private baseCouponModel: typeof BaseCouponModel & SoftDeleteModel<BaseCoupon>;\n\n constructor() {\n this.individualUserCouponService = Container.get(IndividualUserCouponService);\n this.couponService = Container.get(CouponService);\n this.baseCouponModel = BaseCouponModel as typeof BaseCouponModel & SoftDeleteModel<BaseCoupon>;\n }\n\n private async nextFwcCode(): Promise<string> {\n const count = await this.baseCouponModel.countDocuments({code: new RegExp(`^${FWC_CODE_PREFIX}`)});\n return `${FWC_CODE_PREFIX}${String(count + 1).padStart(2, '0')}`;\n }\n\n async grant(context: RewardContext): Promise<void> {\n for (const userId of context.userIds) {\n const code = await this.nextFwcCode();\n const coupon = await this.individualUserCouponService.create({\n ...context.payload,\n code,\n users: [userId],\n } as any);\n\n await this.couponService.assignCouponToMultipleUser(\n {_id: userId},\n coupon._id\n );\n }\n }\n}\n"]}
1
+ {"version":3,"file":"coupon-reward.handler.js","sourceRoot":"/","sources":["modules/tournament/reward/handlers/coupon-reward.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAI1C,sDAAgD;AAChD,4GAAoG;AACpG,4EAAsE;AACtE,kFAA4E;AAE5E,wCAA6C;AAC7C,2EAAsF;AAG/E,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IACpB,2BAA2B,CAA8B;IACzD,aAAa,CAAgB;IAErC;QACI,IAAI,CAAC,2BAA2B,GAAG,gBAAS,CAAC,GAAG,CAAC,4DAA2B,CAAC,CAAC;QAC9E,IAAI,CAAC,aAAa,GAAG,gBAAS,CAAC,GAAG,CAAC,8BAAa,CAAC,CAAC;IACtD,CAAC;IAEO,KAAK,CAAC,QAAQ,CAAC,MAAc,EAAE,MAA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M,IAAI,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;QACxE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,2BAA2B,CAAC,MAAM,CAAC,8BAAa,CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QACrI,MAAM,IAAI,CAAC,aAAa,CAAC,0BAA0B,CAAC,EAAC,GAAG,EAAE,EAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAC,EAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;QAC/F,MAAM,4CAAoB,CAAC,qBAAqB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;QAErH,MAAM,QAAQ,GAAY,CAAC,MAAM,IAAA,mBAAY,GAAE,CAAC,wBAAwB,EAAE,CAAC,WAAW,EAAE,CAAY,CAAC;QAC3G,MAAM,YAAY,GAAG,QAAQ,EAAE,eAAe,EAAE,YAAY,IAAI,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACtD,CAAC;CAEJ,CAAA;AAzFY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,gBAAO,GAAE;;GACG,mBAAmB,CAyF/B","sourcesContent":["import Container, {Service} from 'typedi';\nimport {IndividualUserCoupon, Setting} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {IRewardHandler} from '../reward.interface';\nimport {CouponRewardPayload, CouponRewardResult, RewardContext} from '../reward.types';\nimport {RewardBuilder} from '../reward.builder';\nimport {IndividualUserCouponService} from '@modules/coupon/services/individual-user-coupon.service';\nimport {CouponService} from '@modules/coupon/services/coupon.service';\nimport {predictionRepository} from '../../prediction/prediction.repository';\nimport { DocumentType } from '@typegoose/typegoose';\nimport { getLibraries } from '@lyxa.ai/core';\nimport { roundSecondaryCurrency } from '@lyxa.ai/core/dist/utilities/shared/currency';\n\n@Service()\nexport class CouponRewardHandler implements IRewardHandler<CouponRewardPayload, CouponRewardResult> {\n private individualUserCouponService: IndividualUserCouponService;\n private couponService: CouponService;\n\n constructor() {\n this.individualUserCouponService = Container.get(IndividualUserCouponService);\n this.couponService = Container.get(CouponService);\n }\n\n private async nextCode(prefix: string, number: number): Promise<string> {\n return `${prefix}${String(number).padStart(3, '0')}`;\n }\n\n private formatCurrency(value: any, secondaryCurrencyValue: any) {\n\t\t// Use coma separator for thousands and round secondary currency value\n\t\tconst formatterUSD = new Intl.NumberFormat('en-US', {\n\t\t\tminimumFractionDigits: 0,\n\t\t\tmaximumFractionDigits: 2,\n\t\t});\n\n\t\tconst formatterLBP = new Intl.NumberFormat('en-US', {\n\t\t\tminimumFractionDigits: 0,\n\t\t});\n\n\t\tif (secondaryCurrencyValue !== null && secondaryCurrencyValue !== undefined) {\n\t\t\treturn 'LBP ' + formatterLBP.format(Number(secondaryCurrencyValue));\n\t\t}\n\n\t\treturn '$' + formatterUSD.format(Number(value ?? 0));\n\t}\n\n private buildCouponOfferLabel(coupon: DocumentType<IndividualUserCoupon>, exchangeRate: number): string {\n const valuePart =\n\t\t\t\tcoupon.valueType === 'fixed'\n\t\t\t\t\t? this.formatCurrency(coupon.value, roundSecondaryCurrency(coupon.value * exchangeRate))\n\t\t\t\t\t: `${coupon.value}%`;\n\n\t\t\tconst maxDiscountPart =\n\t\t\t\tcoupon.isMaxDiscountLimitEnabled && coupon.maxDiscountLimit && coupon.maxDiscountLimit > 0\n\t\t\t\t\t? ` up to ${this.formatCurrency(coupon.maxDiscountLimit, roundSecondaryCurrency(coupon.maxDiscountLimit * exchangeRate))}`\n\t\t\t\t\t: '';\n\n return `Save ${valuePart}${maxDiscountPart}`;\n }\n\n private buildCouponValidityLabel(coupon: DocumentType<IndividualUserCoupon>, exchangeRate: number): string {\n\t\t\tlet validityParts: string[] = [];\n\n\t\t\t// 1. Minimum Order\n\t\t\tif (coupon.isMinOrderValueEnabled && coupon.minOrderValue && coupon.minOrderValue > 0) {\n\t\t\t\tvalidityParts.push(\n\t\t\t\t\t`Minimum order ${this.formatCurrency(coupon.minOrderValue, roundSecondaryCurrency(coupon.minOrderValue * exchangeRate))}`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// 2. Order Limit\n\t\t\tif (coupon.isOrderLimitPerUserEnabled && coupon.orderLimitPerUser && coupon.orderLimitPerUser > 0) {\n\t\t\t\tvalidityParts.push(`Applied on ${coupon.orderLimitPerUser} order`);\n\t\t\t}\n\n\t\t\treturn validityParts.join('. ');\n\t\t}\n\n private buildCouponInfo(coupon: DocumentType<IndividualUserCoupon>, exchangeRate: number): CouponRewardResult {\n return {\n code: coupon.code,\n duration: {\n start: coupon.duration.start,\n end: coupon.duration.end!\n },\n couponOfferLabel: this.buildCouponOfferLabel(coupon, exchangeRate),\n couponValidityLabel: this.buildCouponValidityLabel(coupon, exchangeRate),\n _id: coupon._id\n };\n }\n\n async grant(context: RewardContext): Promise<CouponRewardResult> {\n const {couponNamePrefix} = context.payload;\n const code = await this.nextCode(couponNamePrefix, context.matchNumber);\n const coupon = await this.individualUserCouponService.create(RewardBuilder.buildCouponInput(context.payload, code, context.userIds));\n await this.couponService.assignCouponToMultipleUser({_id: {$in: context.userIds}}, coupon._id);\n await predictionRepository.setCouponOnPrediction(context.userIds, context.tournamentId, context.matchId, coupon._id);\n\n const settings: Setting = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst exchangeRate = settings?.currencySetting?.exchangeRate || 1;\n\n return this.buildCouponInfo(coupon, exchangeRate);\n }\n\n}\n"]}
@@ -1,6 +1,9 @@
1
1
  import { mongoose } from '@typegoose/typegoose';
2
- import { RewardContext } from './reward.types';
2
+ import { CouponRewardConfig, CouponRewardPayload, RewardContext } from './reward.types';
3
+ import { CreateIndividualUserCouponDTO } from '../../coupon/validations/individual-user-coupon.validation';
3
4
  export declare class RewardBuilder {
4
- static buildCouponRewardContext(matchId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId, winnerIds: mongoose.Types.ObjectId[]): RewardContext;
5
+ static buildCouponRewardContext(matchId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId, winnerIds: mongoose.Types.ObjectId[], matchNumber: number, config: CouponRewardConfig): RewardContext;
6
+ static buildCouponInput(payload: CouponRewardPayload, code: string, userId: mongoose.Types.ObjectId[]): CreateIndividualUserCouponDTO;
7
+ private static buildCouponPayload;
5
8
  }
6
9
  //# sourceMappingURL=reward.builder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reward.builder.d.ts","sourceRoot":"/","sources":["modules/tournament/reward/reward.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAQ7C,qBAAa,aAAa;IACtB,MAAM,CAAC,wBAAwB,CAC3B,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAChC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GACrC,aAAa;CAiCnB"}
1
+ {"version":3,"file":"reward.builder.d.ts","sourceRoot":"/","sources":["modules/tournament/reward/reward.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAC,kBAAkB,EAAE,mBAAmB,EAAE,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAEtF,OAAO,EAAC,6BAA6B,EAAC,MAAM,+DAA+D,CAAC;AAe5G,qBAAa,aAAa;IACtB,MAAM,CAAC,wBAAwB,CAC3B,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAChC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,EACpC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,kBAAkB,GAC3B,aAAa;IAUhB,MAAM,CAAC,gBAAgB,CACnB,OAAO,EAAE,mBAAmB,EAC5B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAG,GACnC,6BAA6B;IAWhC,OAAO,CAAC,MAAM,CAAC,kBAAkB;CAqBpC"}
@@ -3,40 +3,56 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RewardBuilder = void 0;
4
4
  const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
5
5
  const tournament_utils_1 = require("../tournament.utils");
6
- const FWC_DISCOUNT_PERCENTAGE = 10;
7
- const FWC_MAX_DISCOUNT_AMOUNT = 5;
8
6
  const FWC_MIN_ORDER_VALUE = 5;
7
+ const FWC_ORDER_LIMIT_PER_USER = 1;
8
+ const FWC_COUPON_DURATION_MONTHS = 1;
9
+ const FWC_ELIGIBLE_ITEM_TYPES = [
10
+ enum_1.ItemType.FOOD,
11
+ enum_1.ItemType.GROCERY,
12
+ enum_1.ItemType.PHARMACY,
13
+ enum_1.ItemType.COFFEE,
14
+ enum_1.ItemType.FLOWER,
15
+ enum_1.ItemType.PET,
16
+ enum_1.ItemType.HEALTHY_CORNER,
17
+ ];
9
18
  class RewardBuilder {
10
- static buildCouponRewardContext(matchId, tournamentId, winnerIds) {
11
- const now = (0, tournament_utils_1.utcNow)();
12
- const expiresAt = new Date(now);
13
- expiresAt.setMonth(expiresAt.getMonth() + 1);
19
+ static buildCouponRewardContext(matchId, tournamentId, winnerIds, matchNumber, config) {
14
20
  return {
15
21
  userIds: winnerIds,
16
22
  tournamentId,
17
23
  matchId,
18
- payload: {
19
- couponType: enum_1.CouponType.INDIVIDUAL_USER,
20
- valueType: enum_1.ValueType.PERCENTAGE,
21
- value: FWC_DISCOUNT_PERCENTAGE,
22
- maxDiscountLimit: FWC_MAX_DISCOUNT_AMOUNT,
23
- duration: { start: now, end: expiresAt },
24
- isSpendLimitEnabled: false,
25
- spendLimit: null,
26
- isOrderLimitPerUserEnabled: true,
27
- orderLimitPerUser: 1,
28
- isMinOrderValueEnabled: true,
29
- minOrderValue: FWC_MIN_ORDER_VALUE,
30
- itemTypes: [
31
- enum_1.ItemType.FOOD,
32
- enum_1.ItemType.GROCERY,
33
- enum_1.ItemType.PHARMACY,
34
- enum_1.ItemType.COFFEE,
35
- enum_1.ItemType.FLOWER,
36
- enum_1.ItemType.PET,
37
- enum_1.ItemType.HEALTHY_CORNER,
38
- ],
39
- },
24
+ matchNumber,
25
+ payload: RewardBuilder.buildCouponPayload(config),
26
+ };
27
+ }
28
+ static buildCouponInput(payload, code, userId) {
29
+ const { couponNamePrefix: _ignored, ...rest } = payload;
30
+ return {
31
+ ...rest,
32
+ code,
33
+ users: userId,
34
+ shops: [],
35
+ vendors: [],
36
+ };
37
+ }
38
+ static buildCouponPayload(config) {
39
+ const now = (0, tournament_utils_1.utcNow)();
40
+ const expiresAt = new Date(now);
41
+ expiresAt.setMonth(expiresAt.getMonth() + FWC_COUPON_DURATION_MONTHS);
42
+ return {
43
+ couponType: enum_1.CouponType.INDIVIDUAL_USER,
44
+ valueType: enum_1.ValueType.PERCENTAGE,
45
+ value: config.percentage,
46
+ maxDiscountLimit: config.maxDiscountPerOrder,
47
+ couponNamePrefix: config.couponNamePrefix,
48
+ duration: { start: now, end: expiresAt },
49
+ isSpendLimitEnabled: false,
50
+ spendLimit: null,
51
+ isOrderLimitPerUserEnabled: true,
52
+ orderLimitPerUser: FWC_ORDER_LIMIT_PER_USER,
53
+ isMinOrderValueEnabled: true,
54
+ minOrderValue: FWC_MIN_ORDER_VALUE,
55
+ itemTypes: FWC_ELIGIBLE_ITEM_TYPES,
40
56
  };
41
57
  }
42
58
  }
@@ -1 +1 @@
1
- {"version":3,"file":"reward.builder.js","sourceRoot":"/","sources":["modules/tournament/reward/reward.builder.ts"],"names":[],"mappings":";;;AACA,4DAAkF;AAElF,0DAA2C;AAG3C,MAAM,uBAAuB,GAAG,EAAE,CAAC;AACnC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAClC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B,MAAa,aAAa;IACtB,MAAM,CAAC,wBAAwB,CAC3B,OAAgC,EAChC,YAAqC,EACrC,SAAoC;QAEpC,MAAM,GAAG,GAAG,IAAA,yBAAM,GAAE,CAAC;QACrB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;QAChC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC;QAE7C,OAAO;YACH,OAAO,EAAE,SAAS;YAClB,YAAY;YACZ,OAAO;YACP,OAAO,EAAE;gBACL,UAAU,EAAE,iBAAU,CAAC,eAAe;gBACtC,SAAS,EAAE,gBAAS,CAAC,UAAU;gBAC/B,KAAK,EAAE,uBAAuB;gBAC9B,gBAAgB,EAAE,uBAAuB;gBACzC,QAAQ,EAAE,EAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAC;gBACtC,mBAAmB,EAAE,KAAK;gBAC1B,UAAU,EAAE,IAAI;gBAChB,0BAA0B,EAAE,IAAI;gBAChC,iBAAiB,EAAE,CAAC;gBACpB,sBAAsB,EAAE,IAAI;gBAC5B,aAAa,EAAE,mBAAmB;gBAClC,SAAS,EAAE;oBACP,eAAQ,CAAC,IAAI;oBACb,eAAQ,CAAC,OAAO;oBAChB,eAAQ,CAAC,QAAQ;oBACjB,eAAQ,CAAC,MAAM;oBACf,eAAQ,CAAC,MAAM;oBACf,eAAQ,CAAC,GAAG;oBACZ,eAAQ,CAAC,cAAc;iBAC1B;aACJ;SACJ,CAAC;IACN,CAAC;CACJ;AAtCD,sCAsCC","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\nimport {CouponType, ItemType, ValueType} from '@lyxa.ai/core/dist/utilities/enum';\nimport {RewardContext} from './reward.types';\nimport {utcNow} from '../tournament.utils';\n\n// TODO: make these admin-configurable via tournament reward settings\nconst FWC_DISCOUNT_PERCENTAGE = 10;\nconst FWC_MAX_DISCOUNT_AMOUNT = 5;\nconst FWC_MIN_ORDER_VALUE = 5;\n\nexport class RewardBuilder {\n static buildCouponRewardContext(\n matchId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId,\n winnerIds: mongoose.Types.ObjectId[]\n ): RewardContext {\n const now = utcNow();\n const expiresAt = new Date(now);\n expiresAt.setMonth(expiresAt.getMonth() + 1);\n\n return {\n userIds: winnerIds,\n tournamentId,\n matchId,\n payload: {\n couponType: CouponType.INDIVIDUAL_USER,\n valueType: ValueType.PERCENTAGE,\n value: FWC_DISCOUNT_PERCENTAGE,\n maxDiscountLimit: FWC_MAX_DISCOUNT_AMOUNT,\n duration: {start: now, end: expiresAt},\n isSpendLimitEnabled: false,\n spendLimit: null,\n isOrderLimitPerUserEnabled: true,\n orderLimitPerUser: 1,\n isMinOrderValueEnabled: true,\n minOrderValue: FWC_MIN_ORDER_VALUE,\n itemTypes: [\n ItemType.FOOD,\n ItemType.GROCERY,\n ItemType.PHARMACY,\n ItemType.COFFEE,\n ItemType.FLOWER,\n ItemType.PET,\n ItemType.HEALTHY_CORNER,\n ],\n },\n };\n }\n}\n"]}
1
+ {"version":3,"file":"reward.builder.js","sourceRoot":"/","sources":["modules/tournament/reward/reward.builder.ts"],"names":[],"mappings":";;;AACA,4DAAkF;AAElF,0DAA2C;AAG3C,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAC9B,MAAM,wBAAwB,GAAG,CAAC,CAAC;AACnC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AACrC,MAAM,uBAAuB,GAAe;IACxC,eAAQ,CAAC,IAAI;IACb,eAAQ,CAAC,OAAO;IAChB,eAAQ,CAAC,QAAQ;IACjB,eAAQ,CAAC,MAAM;IAC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EAAE,wBAAwB;YAC3C,sBAAsB,EAAE,IAAI;YAC5B,aAAa,EAAE,mBAAmB;YAClC,SAAS,EAAE,uBAAuB;SACrC,CAAC;IACN,CAAC;CACJ;AArDD,sCAqDC","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\nimport {CouponType, ItemType, ValueType} from '@lyxa.ai/core/dist/utilities/enum';\nimport {CouponRewardConfig, CouponRewardPayload, RewardContext} from './reward.types';\nimport {utcNow} from '../tournament.utils';\nimport {CreateIndividualUserCouponDTO} from '@modules/coupon/validations/individual-user-coupon.validation';\n\nconst FWC_MIN_ORDER_VALUE = 5;\nconst FWC_ORDER_LIMIT_PER_USER = 1;\nconst FWC_COUPON_DURATION_MONTHS = 1;\nconst FWC_ELIGIBLE_ITEM_TYPES: ItemType[] = [\n ItemType.FOOD,\n ItemType.GROCERY,\n ItemType.PHARMACY,\n ItemType.COFFEE,\n ItemType.FLOWER,\n ItemType.PET,\n ItemType.HEALTHY_CORNER,\n];\n\nexport class RewardBuilder {\n static buildCouponRewardContext(\n matchId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId,\n winnerIds: mongoose.Types.ObjectId[],\n matchNumber: number,\n config: CouponRewardConfig\n ): RewardContext {\n return {\n userIds: winnerIds,\n tournamentId,\n matchId,\n matchNumber,\n payload: RewardBuilder.buildCouponPayload(config),\n };\n }\n\n static buildCouponInput(\n payload: CouponRewardPayload,\n code: string,\n userId: mongoose.Types.ObjectId []\n ): CreateIndividualUserCouponDTO {\n const {couponNamePrefix: _ignored, ...rest} = payload;\n return {\n ...rest,\n code,\n users: userId,\n shops: [],\n vendors: [],\n } as unknown as CreateIndividualUserCouponDTO;\n }\n\n private static buildCouponPayload(config: CouponRewardConfig): CouponRewardPayload {\n const now = utcNow();\n const expiresAt = new Date(now);\n expiresAt.setMonth(expiresAt.getMonth() + FWC_COUPON_DURATION_MONTHS);\n\n return {\n couponType: CouponType.INDIVIDUAL_USER,\n valueType: ValueType.PERCENTAGE,\n value: config.percentage,\n maxDiscountLimit: config.maxDiscountPerOrder,\n couponNamePrefix: config.couponNamePrefix,\n duration: {start: now, end: expiresAt},\n isSpendLimitEnabled: false,\n spendLimit: null,\n isOrderLimitPerUserEnabled: true,\n orderLimitPerUser: FWC_ORDER_LIMIT_PER_USER,\n isMinOrderValueEnabled: true,\n minOrderValue: FWC_MIN_ORDER_VALUE,\n itemTypes: FWC_ELIGIBLE_ITEM_TYPES,\n };\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { RewardType } from './reward.types';
2
2
  import { IRewardHandler } from './reward.interface';
3
3
  export declare class RewardFactory {
4
- static getHandler(type: RewardType): IRewardHandler;
4
+ static getHandler<P = unknown, R = unknown>(type: RewardType): IRewardHandler<P, R>;
5
5
  }
6
6
  //# sourceMappingURL=reward.factory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reward.factory.d.ts","sourceRoot":"/","sources":["modules/tournament/reward/reward.factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,qBAAa,aAAa;IACtB,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,cAAc;CAQtD"}
1
+ {"version":3,"file":"reward.factory.d.ts","sourceRoot":"/","sources":["modules/tournament/reward/reward.factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,qBAAa,aAAa;IACtB,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,UAAU,GAAG,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;CAQtF"}
@@ -1 +1 @@
1
- {"version":3,"file":"reward.factory.js","sourceRoot":"/","sources":["modules/tournament/reward/reward.factory.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA+B;AAC/B,iDAA4C;AAE5C,4EAAuE;AAEvE,MAAa,aAAa;IACtB,MAAM,CAAC,UAAU,CAAC,IAAgB;QAC9B,QAAQ,IAAI,EAAE,CAAC;YACX,KAAK,yBAAU,CAAC,MAAM;gBAClB,OAAO,gBAAS,CAAC,GAAG,CAAC,2CAAmB,CAAC,CAAC;YAC9C;gBACI,MAAM,IAAI,KAAK,CAAC,0CAA0C,IAAI,EAAE,CAAC,CAAC;QAC1E,CAAC;IACL,CAAC;CACJ;AATD,sCASC","sourcesContent":["import Container from 'typedi';\nimport { RewardType } from './reward.types';\nimport { IRewardHandler } from './reward.interface';\nimport { CouponRewardHandler } from './handlers/coupon-reward.handler';\n\nexport class RewardFactory {\n static getHandler(type: RewardType): IRewardHandler {\n switch (type) {\n case RewardType.COUPON:\n return Container.get(CouponRewardHandler);\n default:\n throw new Error(`No handler registered for reward type: ${type}`);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"reward.factory.js","sourceRoot":"/","sources":["modules/tournament/reward/reward.factory.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA+B;AAC/B,iDAA4C;AAE5C,4EAAuE;AAEvE,MAAa,aAAa;IACtB,MAAM,CAAC,UAAU,CAA2B,IAAgB;QACxD,QAAQ,IAAI,EAAE,CAAC;YACX,KAAK,yBAAU,CAAC,MAAM;gBAClB,OAAO,gBAAS,CAAC,GAAG,CAAC,2CAAmB,CAAoC,CAAC;YACjF;gBACI,MAAM,IAAI,KAAK,CAAC,0CAA0C,IAAI,EAAE,CAAC,CAAC;QAC1E,CAAC;IACL,CAAC;CACJ;AATD,sCASC","sourcesContent":["import Container from 'typedi';\nimport { RewardType } from './reward.types';\nimport { IRewardHandler } from './reward.interface';\nimport { CouponRewardHandler } from './handlers/coupon-reward.handler';\n\nexport class RewardFactory {\n static getHandler<P = unknown, R = unknown>(type: RewardType): IRewardHandler<P, R> {\n switch (type) {\n case RewardType.COUPON:\n return Container.get(CouponRewardHandler) as unknown as IRewardHandler<P, R>;\n default:\n throw new Error(`No handler registered for reward type: ${type}`);\n }\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { RewardContext } from './reward.types';
2
- export interface IRewardHandler {
3
- grant(context: RewardContext): Promise<void>;
2
+ export interface IRewardHandler<P = unknown, R = unknown> {
3
+ grant(context: RewardContext<P>): Promise<R>;
4
4
  }
5
5
  //# sourceMappingURL=reward.interface.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reward.interface.d.ts","sourceRoot":"/","sources":["modules/tournament/reward/reward.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAE7C,MAAM,WAAW,cAAc;IAC3B,KAAK,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD"}
1
+ {"version":3,"file":"reward.interface.d.ts","sourceRoot":"/","sources":["modules/tournament/reward/reward.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAE7C,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO;IACpD,KAAK,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAChD"}
@@ -1 +1 @@
1
- {"version":3,"file":"reward.interface.js","sourceRoot":"/","sources":["modules/tournament/reward/reward.interface.ts"],"names":[],"mappings":"","sourcesContent":["import {RewardContext} from './reward.types';\n\nexport interface IRewardHandler {\n grant(context: RewardContext): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"reward.interface.js","sourceRoot":"/","sources":["modules/tournament/reward/reward.interface.ts"],"names":[],"mappings":"","sourcesContent":["import {RewardContext} from './reward.types';\n\nexport interface IRewardHandler<P = unknown, R = unknown> {\n grant(context: RewardContext<P>): Promise<R>;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { RewardContext, RewardType } from './reward.types';
2
2
  export declare class RewardService {
3
- grant(type: RewardType, context: RewardContext): Promise<void>;
3
+ grant<P, R>(type: RewardType, context: RewardContext<P>): Promise<R>;
4
4
  }
5
5
  export declare const rewardService: RewardService;
6
6
  //# sourceMappingURL=reward.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reward.service.d.ts","sourceRoot":"/","sources":["modules/tournament/reward/reward.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAE,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAGzD,qBACa,aAAa;IAChB,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAIvE;AAED,eAAO,MAAM,aAAa,eAA+B,CAAC"}
1
+ {"version":3,"file":"reward.service.d.ts","sourceRoot":"/","sources":["modules/tournament/reward/reward.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAE,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAGzD,qBACa,aAAa;IAChB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAI7E;AAED,eAAO,MAAM,aAAa,eAA+B,CAAC"}
@@ -45,7 +45,7 @@ const reward_factory_1 = require("./reward.factory");
45
45
  let RewardService = class RewardService {
46
46
  async grant(type, context) {
47
47
  const handler = reward_factory_1.RewardFactory.getHandler(type);
48
- await handler.grant(context);
48
+ return await handler.grant(context);
49
49
  }
50
50
  };
51
51
  exports.RewardService = RewardService;
@@ -1 +1 @@
1
- {"version":3,"file":"reward.service.js","sourceRoot":"/","sources":["modules/tournament/reward/reward.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,qDAA+C;AAGxC,IAAM,aAAa,GAAnB,MAAM,aAAa;IACtB,KAAK,CAAC,KAAK,CAAC,IAAgB,EAAE,OAAsB;QAChD,MAAM,OAAO,GAAG,8BAAa,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC/C,MAAM,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;CACJ,CAAA;AALY,sCAAa;wBAAb,aAAa;IADzB,IAAA,gBAAO,GAAE;GACG,aAAa,CAKzB;AAEY,QAAA,aAAa,GAAG,gBAAS,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {RewardContext, RewardType} from './reward.types';\nimport {RewardFactory} from './reward.factory';\n\n@Service()\nexport class RewardService {\n async grant(type: RewardType, context: RewardContext): Promise<void> {\n const handler = RewardFactory.getHandler(type);\n await handler.grant(context);\n }\n}\n\nexport const rewardService = Container.get(RewardService);\n"]}
1
+ {"version":3,"file":"reward.service.js","sourceRoot":"/","sources":["modules/tournament/reward/reward.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,qDAA+C;AAGxC,IAAM,aAAa,GAAnB,MAAM,aAAa;IACtB,KAAK,CAAC,KAAK,CAAO,IAAgB,EAAE,OAAyB;QACzD,MAAM,OAAO,GAAG,8BAAa,CAAC,UAAU,CAAO,IAAI,CAAC,CAAC;QACrD,OAAO,MAAM,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;CACJ,CAAA;AALY,sCAAa;wBAAb,aAAa;IADzB,IAAA,gBAAO,GAAE;GACG,aAAa,CAKzB;AAEY,QAAA,aAAa,GAAG,gBAAS,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {RewardContext, RewardType} from './reward.types';\nimport {RewardFactory} from './reward.factory';\n\n@Service()\nexport class RewardService {\n async grant<P, R>(type: RewardType, context: RewardContext<P>): Promise<R> {\n const handler = RewardFactory.getHandler<P, R>(type);\n return await handler.grant(context);\n }\n}\n\nexport const rewardService = Container.get(RewardService);\n"]}
@@ -1,11 +1,44 @@
1
1
  import { mongoose } from '@typegoose/typegoose';
2
+ import { CouponType, ItemType, ValueType } from '@lyxa.ai/core/dist/utilities/enum';
2
3
  export declare enum RewardType {
3
4
  COUPON = "coupon"
4
5
  }
5
- export interface RewardContext {
6
+ export interface CouponRewardConfig {
7
+ percentage: number;
8
+ maxDiscountPerOrder: number;
9
+ couponNamePrefix: string;
10
+ }
11
+ export interface CouponRewardDuration {
12
+ start: Date;
13
+ end: Date;
14
+ }
15
+ export interface CouponRewardPayload {
16
+ couponType: CouponType.INDIVIDUAL_USER;
17
+ valueType: ValueType.PERCENTAGE;
18
+ value: number;
19
+ maxDiscountLimit: number;
20
+ couponNamePrefix: string;
21
+ duration: CouponRewardDuration;
22
+ isSpendLimitEnabled: boolean;
23
+ spendLimit: number | null;
24
+ isOrderLimitPerUserEnabled: boolean;
25
+ orderLimitPerUser: number;
26
+ isMinOrderValueEnabled: boolean;
27
+ minOrderValue: number;
28
+ itemTypes: ItemType[];
29
+ }
30
+ export type CouponRewardResult = {
31
+ code: string;
32
+ duration: CouponRewardDuration;
33
+ couponOfferLabel: string;
34
+ couponValidityLabel: string;
35
+ _id: mongoose.Types.ObjectId;
36
+ };
37
+ export interface RewardContext<P = CouponRewardPayload> {
6
38
  userIds: mongoose.Types.ObjectId[];
7
39
  tournamentId: mongoose.Types.ObjectId;
8
40
  matchId: mongoose.Types.ObjectId;
9
- payload: Record<string, unknown>;
41
+ matchNumber: number;
42
+ payload: P;
10
43
  }
11
44
  //# sourceMappingURL=reward.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reward.types.d.ts","sourceRoot":"/","sources":["modules/tournament/reward/reward.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAE9C,oBAAY,UAAU;IAClB,MAAM,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AC;CACzB;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;CAChC,CAAC;AAEF,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,mBAAmB;IAClD,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IACnC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IACtC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,CAAC,CAAC;CACd"}
@@ -1 +1 @@
1
- {"version":3,"file":"reward.types.js","sourceRoot":"/","sources":["modules/tournament/reward/reward.types.ts"],"names":[],"mappings":";;;AAEA,IAAY,UAEX;AAFD,WAAY,UAAU;IAClB,+BAAiB,CAAA;AACrB,CAAC,EAFW,UAAU,0BAAV,UAAU,QAErB","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\n\nexport enum RewardType {\n COUPON = 'coupon',\n}\n\nexport interface RewardContext {\n userIds: mongoose.Types.ObjectId[];\n tournamentId: mongoose.Types.ObjectId;\n matchId: mongoose.Types.ObjectId;\n payload: Record<string, unknown>;\n}\n"]}
1
+ {"version":3,"file":"reward.types.js","sourceRoot":"/","sources":["modules/tournament/reward/reward.types.ts"],"names":[],"mappings":";;;AAGA,IAAY,UAEX;AAFD,WAAY,UAAU;IAClB,+BAAiB,CAAA;AACrB,CAAC,EAFW,UAAU,0BAAV,UAAU,QAErB","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\nimport {CouponType, ItemType, ValueType} from '@lyxa.ai/core/dist/utilities/enum';\n\nexport enum RewardType {\n COUPON = 'coupon',\n}\n\nexport interface CouponRewardConfig {\n percentage: number;\n maxDiscountPerOrder: number;\n couponNamePrefix: string;\n}\n\nexport interface CouponRewardDuration {\n start: Date;\n end: Date;\n}\n\nexport interface CouponRewardPayload {\n couponType: CouponType.INDIVIDUAL_USER;\n valueType: ValueType.PERCENTAGE;\n value: number;\n maxDiscountLimit: number;\n couponNamePrefix: string;\n duration: CouponRewardDuration;\n isSpendLimitEnabled: boolean;\n spendLimit: number | null;\n isOrderLimitPerUserEnabled: boolean;\n orderLimitPerUser: number;\n isMinOrderValueEnabled: boolean;\n minOrderValue: number;\n itemTypes: ItemType[];\n}\n\nexport type CouponRewardResult = {\n code: string;\n duration: CouponRewardDuration;\n couponOfferLabel: string;\n couponValidityLabel: string;\n _id: mongoose.Types.ObjectId;\n};\n\nexport interface RewardContext<P = CouponRewardPayload> {\n userIds: mongoose.Types.ObjectId[];\n tournamentId: mongoose.Types.ObjectId;\n matchId: mongoose.Types.ObjectId;\n matchNumber: number;\n payload: P;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"schedule.router.d.ts","sourceRoot":"/","sources":["modules/tournament/schedule/schedule.router.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;GAQzB,CAAC"}
1
+ {"version":3,"file":"schedule.router.d.ts","sourceRoot":"/","sources":["modules/tournament/schedule/schedule.router.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;GAkBzB,CAAC"}
@@ -2,13 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.scheduleRouter = void 0;
4
4
  const trpc_1 = require("@lyxa.ai/core/dist/libraries/trpc");
5
- const auth_1 = require("@lyxa.ai/core/dist/libraries/auth");
6
- const auth_2 = require("@lyxa.ai/core/dist/libraries/trpc/middlewares/auth");
7
5
  const error_handler_1 = require("@lyxa.ai/core/dist/utilities/error-handler");
8
6
  const response_1 = require("@lyxa.ai/core/dist/utilities/response");
9
7
  const schedule_service_1 = require("./schedule.service");
10
8
  exports.scheduleRouter = (0, trpc_1.createTRPCRouter)({
11
- dispatch: (0, auth_2.createAuthenticatedProcedure)({ entityTypes: [auth_1.AuthEntityType.CRM] })
9
+ dispatch: trpc_1.publicProcedure
12
10
  .mutation(() => error_handler_1.ErrorHandler.wrapAsync(async () => {
13
11
  await schedule_service_1.scheduleDispatchService.dispatchPending();
14
12
  return (0, response_1.response)('Notifications dispatched successfully', null);
@@ -1 +1 @@
1
- {"version":3,"file":"schedule.router.js","sourceRoot":"/","sources":["modules/tournament/schedule/schedule.router.ts"],"names":[],"mappings":";;;AAAA,4DAAmE;AACnE,4DAAiE;AACjE,6EAAgG;AAChG,8EAAwE;AACxE,oEAA+D;AAC/D,yDAAsE;AAEzD,QAAA,cAAc,GAAG,IAAA,uBAAgB,EAAC;IAC3C,QAAQ,EAAE,IAAA,mCAA4B,EAAC,EAAC,WAAW,EAAE,CAAC,qBAAc,CAAC,GAAG,CAAC,EAAC,CAAC;SACtE,QAAQ,CAAC,GAAG,EAAE,CACX,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,MAAM,0CAAO,CAAC,eAAe,EAAE,CAAC;QAChC,OAAO,IAAA,mBAAQ,EAAC,uCAAuC,EAAE,IAAI,CAAC,CAAC;IACnE,CAAC,CAAC,CACL;CACR,CAAC,CAAC","sourcesContent":["import {createTRPCRouter} from '@lyxa.ai/core/dist/libraries/trpc';\nimport {AuthEntityType} from '@lyxa.ai/core/dist/libraries/auth';\nimport {createAuthenticatedProcedure} from '@lyxa.ai/core/dist/libraries/trpc/middlewares/auth';\nimport {ErrorHandler} from '@lyxa.ai/core/dist/utilities/error-handler';\nimport {response} from '@lyxa.ai/core/dist/utilities/response';\nimport {scheduleDispatchService as service} from './schedule.service';\n\nexport const scheduleRouter = createTRPCRouter({\n dispatch: createAuthenticatedProcedure({entityTypes: [AuthEntityType.CRM]})\n .mutation(() =>\n ErrorHandler.wrapAsync(async () => {\n await service.dispatchPending();\n return response('Notifications dispatched successfully', null);\n })\n ),\n});\n"]}
1
+ {"version":3,"file":"schedule.router.js","sourceRoot":"/","sources":["modules/tournament/schedule/schedule.router.ts"],"names":[],"mappings":";;;AAAA,4DAAoF;AACpF,8EAAwE;AACxE,oEAA+D;AAC/D,yDAAsE;AAEzD,QAAA,cAAc,GAAG,IAAA,uBAAgB,EAAC;IAC3C,QAAQ,EAAE,sBAAe;SACpB,QAAQ,CAAC,GAAG,EAAE,CACX,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,MAAM,0CAAO,CAAC,eAAe,EAAE,CAAC;QAChC,OAAO,IAAA,mBAAQ,EAAC,uCAAuC,EAAE,IAAI,CAAC,CAAC;IACnE,CAAC,CAAC,CACL;CAWR,CAAC,CAAC","sourcesContent":["import {createTRPCRouter, publicProcedure} from '@lyxa.ai/core/dist/libraries/trpc';\nimport {ErrorHandler} from '@lyxa.ai/core/dist/utilities/error-handler';\nimport {response} from '@lyxa.ai/core/dist/utilities/response';\nimport {scheduleDispatchService as service} from './schedule.service';\n\nexport const scheduleRouter = createTRPCRouter({\n dispatch: publicProcedure\n .mutation(() =>\n ErrorHandler.wrapAsync(async () => {\n await service.dispatchPending();\n return response('Notifications dispatched successfully', null);\n })\n ),\n\n // NOTE: there is a huge possibility we will not use this feature, left it out in case they want it back\n //\n // dispatchPreTournamentReminders: publicProcedure\n // .mutation(() =>\n // ErrorHandler.wrapAsync(async () => {\n // await service.dispatchPreTournamentReminders();\n // return response('Pre-tournament reminders dispatched successfully', null);\n // })\n // ),\n});\n"]}
@@ -1,9 +1,12 @@
1
1
  export declare class ScheduleService {
2
2
  private configRepository;
3
3
  private matchRepository;
4
+ private participantRepository;
4
5
  private templateRepository;
5
6
  private notificationService;
7
+ private userModel;
6
8
  constructor();
9
+ private dispatchTournamentActivationNotification;
7
10
  dispatchPending(): Promise<void>;
8
11
  }
9
12
  export declare const scheduleDispatchService: ScheduleService;
@@ -1 +1 @@
1
- {"version":3,"file":"schedule.service.d.ts","sourceRoot":"/","sources":["modules/tournament/schedule/schedule.service.ts"],"names":[],"mappings":"AAMA,qBACa,eAAe;IACxB,OAAO,CAAC,gBAAgB,CAA6B;IACrD,OAAO,CAAC,eAAe,CAA4B;IACnD,OAAO,CAAC,kBAAkB,CAAiC;IAC3D,OAAO,CAAC,mBAAmB,CAAgC;;IAS9C,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;CAyBhD;AAED,eAAO,MAAM,uBAAuB,iBAAiC,CAAC"}
1
+ {"version":3,"file":"schedule.service.d.ts","sourceRoot":"/","sources":["modules/tournament/schedule/schedule.service.ts"],"names":[],"mappings":"AAYA,qBACa,eAAe;IAC3B,OAAO,CAAC,gBAAgB,CAA6B;IACrD,OAAO,CAAC,eAAe,CAA4B;IACnD,OAAO,CAAC,qBAAqB,CAAkC;IAC/D,OAAO,CAAC,kBAAkB,CAAiC;IAC3D,OAAO,CAAC,mBAAmB,CAAgC;IAC3D,OAAO,CAAC,SAAS,CAA2C;;YA0D9C,wCAAwC;IAuBzC,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;CA4C7C;AAED,eAAO,MAAM,uBAAuB,iBAAiC,CAAC"}
@@ -44,20 +44,43 @@ var __metadata = (this && this.__metadata) || function (k, v) {
44
44
  Object.defineProperty(exports, "__esModule", { value: true });
45
45
  exports.scheduleDispatchService = exports.ScheduleService = void 0;
46
46
  const typedi_1 = __importStar(require("typedi"));
47
+ const models_1 = require("@lyxa.ai/core/dist/libraries/mongo/models");
48
+ const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
47
49
  const config_repository_1 = require("../config/config.repository");
48
50
  const match_repository_1 = require("../match/match.repository");
51
+ const participant_repository_1 = require("../participant/participant.repository");
49
52
  const notification_template_repository_1 = require("../notification/notification-template.repository");
50
53
  const notification_service_1 = require("../notification/notification.service");
51
54
  let ScheduleService = class ScheduleService {
52
55
  configRepository;
53
56
  matchRepository;
57
+ participantRepository;
54
58
  templateRepository;
55
59
  notificationService;
60
+ userModel;
56
61
  constructor() {
57
62
  this.configRepository = typedi_1.default.get(config_repository_1.TournamentConfigRepository);
58
63
  this.matchRepository = typedi_1.default.get(match_repository_1.TournamentMatchRepository);
64
+ this.participantRepository = typedi_1.default.get(participant_repository_1.TournamentParticipantRepository);
59
65
  this.templateRepository = typedi_1.default.get(notification_template_repository_1.NotificationTemplateRepository);
60
66
  this.notificationService = typedi_1.default.get(notification_service_1.TournamentNotificationService);
67
+ this.userModel = models_1.UserModel;
68
+ }
69
+ async dispatchTournamentActivationNotification(tournament, templates) {
70
+ const flags = new Map(Object.entries(tournament.notificationFlags || {}));
71
+ if (flags.get(enum_1.TournamentNotificationTag.TOURNAMENT_ACTIVATION) === true)
72
+ return;
73
+ const template = templates.get(enum_1.TournamentNotificationTag.TOURNAMENT_ACTIVATION);
74
+ if (!template)
75
+ return;
76
+ await this.notificationService.notifyGlobal({
77
+ title: template.title,
78
+ body: template.body,
79
+ tournamentNotificationType: enum_1.TournamentNotificationTag.TOURNAMENT_ACTIVATION,
80
+ tournamentId: tournament._id.toString(),
81
+ deepLinkRoute: tournament.deepLinkRoute,
82
+ });
83
+ await this.configRepository.setNotificationFlag(tournament._id, enum_1.TournamentNotificationTag.TOURNAMENT_ACTIVATION);
61
84
  }
62
85
  async dispatchPending() {
63
86
  const tournament = await this.configRepository.findActiveFull();
@@ -66,14 +89,20 @@ let ScheduleService = class ScheduleService {
66
89
  const tournamentId = tournament._id;
67
90
  const templates = await this.templateRepository.findTemplates(tournamentId);
68
91
  const now = Date.now();
92
+ await this.dispatchTournamentActivationNotification(tournament, templates);
69
93
  await Promise.all(tournament.matches.map(match => Promise.all(tournament.scheduledNotifications.map(async ({ type, durationMins, target }) => {
94
+ if (![
95
+ enum_1.TournamentNotificationTag.PREDICTION_REMINDER_15_MINUTES,
96
+ enum_1.TournamentNotificationTag.PREDICTION_REMINDER_3_HOURS,
97
+ ].includes(type))
98
+ return;
70
99
  const notificationTime = new Date(match.startingDate).getTime() - durationMins * 60 * 1000;
71
100
  const flags = match.notificationFlags;
72
101
  if (now < notificationTime)
73
102
  return;
74
103
  if (flags?.[type] === true)
75
104
  return;
76
- await this.notificationService.dispatchScheduledJob(type, target, templates, tournamentId, match._id);
105
+ await this.notificationService.dispatchScheduledJob(type, target, templates, tournamentId, [match.team1.teamId, match.team2.teamId], match._id, match.startingDate, tournament.deepLinkRoute);
77
106
  await this.matchRepository.setNotificationFlag(tournamentId, match._id, type);
78
107
  }))));
79
108
  }
@@ -1 +1 @@
1
- {"version":3,"file":"schedule.service.js","sourceRoot":"/","sources":["modules/tournament/schedule/schedule.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAC1C,mEAAuE;AACvE,gEAAoE;AACpE,uGAAgG;AAChG,+EAAmF;AAG5E,IAAM,eAAe,GAArB,MAAM,eAAe;IAChB,gBAAgB,CAA6B;IAC7C,eAAe,CAA4B;IAC3C,kBAAkB,CAAiC;IACnD,mBAAmB,CAAgC;IAE3D;QACI,IAAI,CAAC,gBAAgB,GAAG,gBAAS,CAAC,GAAG,CAAC,8CAA0B,CAAC,CAAC;QAClE,IAAI,CAAC,eAAe,GAAG,gBAAS,CAAC,GAAG,CAAC,4CAAyB,CAAC,CAAC;QAChE,IAAI,CAAC,kBAAkB,GAAG,gBAAS,CAAC,GAAG,CAAC,iEAA8B,CAAC,CAAC;QACxE,IAAI,CAAC,mBAAmB,GAAG,gBAAS,CAAC,GAAG,CAAC,oDAA6B,CAAC,CAAC;IAC5E,CAAC;IAEM,KAAK,CAAC,eAAe;QACxB,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC;QAChE,IAAI,CAAC,UAAU;YAAE,OAAO;QAExB,MAAM,YAAY,GAAG,UAAU,CAAC,GAAG,CAAC;QACpC,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;QAC5E,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEvB,MAAM,OAAO,CAAC,GAAG,CACb,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAC3B,OAAO,CAAC,GAAG,CACP,UAAU,CAAC,sBAAsB,CAAC,GAAG,CAAC,KAAK,EAAE,EAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAC,EAAE,EAAE;YACzE,MAAM,gBAAgB,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,GAAG,YAAY,GAAG,EAAE,GAAG,IAAI,CAAC;YAC3F,MAAM,KAAK,GAAG,KAAK,CAAC,iBAAmE,CAAC;YAExF,IAAI,GAAG,GAAG,gBAAgB;gBAAE,OAAO;YACnC,IAAI,KAAK,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI;gBAAE,OAAO;YAEnC,MAAM,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;YACtG,MAAM,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,YAAY,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAClF,CAAC,CAAC,CACL,CACJ,CACJ,CAAC;IACN,CAAC;CACJ,CAAA;AAtCY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,gBAAO,GAAE;;GACG,eAAe,CAsC3B;AAEY,QAAA,uBAAuB,GAAG,gBAAS,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {TournamentConfigRepository} from '../config/config.repository';\nimport {TournamentMatchRepository} from '../match/match.repository';\nimport {NotificationTemplateRepository} from '../notification/notification-template.repository';\nimport {TournamentNotificationService} from '../notification/notification.service';\n\n@Service()\nexport class ScheduleService {\n private configRepository: TournamentConfigRepository;\n private matchRepository: TournamentMatchRepository;\n private templateRepository: NotificationTemplateRepository;\n private notificationService: TournamentNotificationService;\n\n constructor() {\n this.configRepository = Container.get(TournamentConfigRepository);\n this.matchRepository = Container.get(TournamentMatchRepository);\n this.templateRepository = Container.get(NotificationTemplateRepository);\n this.notificationService = Container.get(TournamentNotificationService);\n }\n\n public async dispatchPending(): Promise<void> {\n const tournament = await this.configRepository.findActiveFull();\n if (!tournament) return;\n\n const tournamentId = tournament._id;\n const templates = await this.templateRepository.findTemplates(tournamentId);\n const now = Date.now();\n\n await Promise.all(\n tournament.matches.map(match =>\n Promise.all(\n tournament.scheduledNotifications.map(async ({type, durationMins, target}) => {\n const notificationTime = new Date(match.startingDate).getTime() - durationMins * 60 * 1000;\n const flags = match.notificationFlags as unknown as Record<string, boolean> | undefined;\n\n if (now < notificationTime) return;\n if (flags?.[type] === true) return;\n\n await this.notificationService.dispatchScheduledJob(type, target, templates, tournamentId, match._id);\n await this.matchRepository.setNotificationFlag(tournamentId, match._id, type);\n })\n )\n )\n );\n }\n}\n\nexport const scheduleDispatchService = Container.get(ScheduleService);\n"]}
1
+ {"version":3,"file":"schedule.service.js","sourceRoot":"/","sources":["modules/tournament/schedule/schedule.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAG5C,sEAAiG;AACjG,4DAA8E;AAC9E,mEAAyE;AACzE,gEAAsE;AACtE,kFAAwF;AACxF,uGAAkG;AAClG,+EAAqF;AAI9E,IAAM,eAAe,GAArB,MAAM,eAAe;IACnB,gBAAgB,CAA6B;IAC7C,eAAe,CAA4B;IAC3C,qBAAqB,CAAkC;IACvD,kBAAkB,CAAiC;IACnD,mBAAmB,CAAgC;IACnD,SAAS,CAA2C;IAE5D;QACC,IAAI,CAAC,gBAAgB,GAAG,gBAAS,CAAC,GAAG,CAAC,8CAA0B,CAAC,CAAC;QAClE,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AM,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,YAAY,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC/E,CAAC,CAAC,CACF,CACD,CACD,CAAC;IACH,CAAC;CACD,CAAA;AAnIY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,gBAAO,GAAE;;GACG,eAAe,CAmI3B;AAEY,QAAA,uBAAuB,GAAG,gBAAS,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport { SoftDeleteModel } from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport { NotificationMessage, User, UserModel } from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport { TournamentNotificationTag } from '@lyxa.ai/core/dist/utilities/enum';\nimport { TournamentConfigRepository } from '../config/config.repository';\nimport { TournamentMatchRepository } from '../match/match.repository';\nimport { TournamentParticipantRepository } from '../participant/participant.repository';\nimport { NotificationTemplateRepository } from '../notification/notification-template.repository';\nimport { TournamentNotificationService } from '../notification/notification.service';\nimport { TournamentDocument } from '../config/config.types';\n\n@Service()\nexport class ScheduleService {\n\tprivate configRepository: TournamentConfigRepository;\n\tprivate matchRepository: TournamentMatchRepository;\n\tprivate participantRepository: TournamentParticipantRepository;\n\tprivate templateRepository: NotificationTemplateRepository;\n\tprivate notificationService: TournamentNotificationService;\n\tprivate userModel: typeof UserModel & SoftDeleteModel<User>;\n\n\tconstructor() {\n\t\tthis.configRepository = Container.get(TournamentConfigRepository);\n\t\tthis.matchRepository = Container.get(TournamentMatchRepository);\n\t\tthis.participantRepository = Container.get(TournamentParticipantRepository);\n\t\tthis.templateRepository = Container.get(NotificationTemplateRepository);\n\t\tthis.notificationService = Container.get(TournamentNotificationService);\n\t\tthis.userModel = UserModel as typeof UserModel & SoftDeleteModel<User>;\n\t}\n\n\t// NOTE: there is a huge possibility we will not use this feature, left it out in case they want it back\n\t//\n\t// public async dispatchPreTournamentReminders(): Promise<void> {\n\t// \tconst tournaments = await this.configRepository.findPendingReminderTournaments();\n\t// \tif (!tournaments.length) return;\n\t//\n\t// \tawait Promise.all(\n\t// \t\ttournaments.map(async tournament => {\n\t// \t\t\tconst templates = await this.templateRepository.findTemplates(tournament._id);\n\t// \t\t\tconst reminderTemplate = templates.get(TournamentNotificationTag.TEAM_SELECTION_REMINDER_1_DAY);\n\t// \t\t\tif (!reminderTemplate) return;\n\t//\n\t// \t\t\tconst participants = await this.participantRepository.findByTournament(tournament._id);\n\t// \t\t\tconst usersWithTeam = participants\n\t// \t\t\t\t.filter(participant => participant.teamId)\n\t// \t\t\t\t.map(participant => participant.userId);\n\t// \t\t\tconst recipients = await this.userModel\n\t// \t\t\t\t.find({ _id: { $nin: usersWithTeam } })\n\t// \t\t\t\t.select('_id')\n\t// \t\t\t\t.lean();\n\t//\n\t// \t\t\tif (!recipients.length) {\n\t// \t\t\t\tawait this.configRepository.setNotificationFlag(\n\t// \t\t\t\t\ttournament._id,\n\t// \t\t\t\t\tTournamentNotificationTag.TEAM_SELECTION_REMINDER_1_DAY\n\t// \t\t\t\t);\n\t// \t\t\t\treturn;\n\t// \t\t\t}\n\t//\n\t// \t\t\tawait this.notificationService.notifyUsers(\n\t// \t\t\t\t{\n\t// \t\t\t\t\ttitle: reminderTemplate.title,\n\t// \t\t\t\t\tbody: reminderTemplate.body,\n\t// \t\t\t\t\ttournamentNotificationType: TournamentNotificationTag.TEAM_SELECTION_REMINDER_1_DAY,\n\t// \t\t\t\t\ttournamentId: tournament._id.toString(),\n\t// \t\t\t\t\tdeepLinkRoute: tournament.deepLinkRoute,\n\t// \t\t\t\t},\n\t// \t\t\t\trecipients.map(user => user._id as mongoose.Types.ObjectId)\n\t// \t\t\t);\n\t// \t\t\tawait this.configRepository.setNotificationFlag(\n\t// \t\t\t\ttournament._id,\n\t// \t\t\t\tTournamentNotificationTag.TEAM_SELECTION_REMINDER_1_DAY\n\t// \t\t\t);\n\t// \t\t})\n\t// \t);\n\t// }\n\n\tprivate async dispatchTournamentActivationNotification(\n\t\ttournament: TournamentDocument,\n\t\ttemplates: Map<TournamentNotificationTag, NotificationMessage>\n\t): Promise<void> {\n\t\tconst flags = new Map(Object.entries(tournament.notificationFlags || {}) as Array<[TournamentNotificationTag, boolean]>);\n\t\tif (flags.get(TournamentNotificationTag.TOURNAMENT_ACTIVATION) === true) return;\n\n\t\tconst template = templates.get(TournamentNotificationTag.TOURNAMENT_ACTIVATION);\n\t\tif (!template) return;\n\n\t\tawait this.notificationService.notifyGlobal({\n\t\t\ttitle: template.title,\n\t\t\tbody: template.body,\n\t\t\ttournamentNotificationType: TournamentNotificationTag.TOURNAMENT_ACTIVATION,\n\t\t\ttournamentId: tournament._id.toString(),\n\t\t\tdeepLinkRoute: tournament.deepLinkRoute,\n\t\t});\n\t\tawait this.configRepository.setNotificationFlag(\n\t\t\ttournament._id,\n\t\t\tTournamentNotificationTag.TOURNAMENT_ACTIVATION\n\t\t);\n\t}\n\n\tpublic async dispatchPending(): Promise<void> {\n\t\tconst tournament = await this.configRepository.findActiveFull();\n\t\tif (!tournament) return;\n\n\t\tconst tournamentId = tournament._id;\n\t\tconst templates = await this.templateRepository.findTemplates(tournamentId);\n\t\tconst now = Date.now();\n\n\t\tawait this.dispatchTournamentActivationNotification(tournament, templates);\n\n\t\tawait Promise.all(\n\t\t\ttournament.matches.map(match =>\n\t\t\t\tPromise.all(\n\t\t\t\t\ttournament.scheduledNotifications.map(async ({ type, durationMins, target }) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t![\n\t\t\t\t\t\t\t\tTournamentNotificationTag.PREDICTION_REMINDER_15_MINUTES,\n\t\t\t\t\t\t\t\tTournamentNotificationTag.PREDICTION_REMINDER_3_HOURS,\n\t\t\t\t\t\t\t].includes(type)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\treturn;\n\n\t\t\t\t\t\tconst notificationTime = new Date(match.startingDate).getTime() - durationMins * 60 * 1000;\n\t\t\t\t\t\tconst flags = match.notificationFlags as unknown as Record<string, boolean> | undefined;\n\n\t\t\t\t\t\tif (now < notificationTime) return;\n\t\t\t\t\t\tif (flags?.[type] === true) return;\n\n\t\t\t\t\t\tawait this.notificationService.dispatchScheduledJob(\n\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\ttarget,\n\t\t\t\t\t\t\ttemplates,\n\t\t\t\t\t\t\ttournamentId,\n\t\t\t\t\t\t\t[match.team1.teamId, match.team2.teamId],\n\t\t\t\t\t\t\tmatch._id,\n match.startingDate,\n\t\t\t\t\t\t\ttournament.deepLinkRoute,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this.matchRepository.setNotificationFlag(tournamentId, match._id, type);\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t)\n\t\t);\n\t}\n}\n\nexport const scheduleDispatchService = Container.get(ScheduleService);\n"]}
@@ -1,5 +1,17 @@
1
1
  import { mongoose } from '@typegoose/typegoose';
2
2
  import { Tournament as Model } from '@lyxa.ai/core/dist/libraries/mongo/models';
3
+ import { TournamentMatchStatus } from '@lyxa.ai/core/dist/utilities/enum';
4
+ export interface BulkScoreUpdate {
5
+ matchId: mongoose.Types.ObjectId;
6
+ score: {
7
+ team1: number;
8
+ team2: number;
9
+ };
10
+ matchStatus: TournamentMatchStatus;
11
+ matchEnded?: boolean;
12
+ endDate?: Date;
13
+ winnerId?: mongoose.Types.ObjectId | null;
14
+ }
3
15
  export declare class ScoreRepository {
4
16
  private model;
5
17
  constructor();
@@ -8,6 +20,7 @@ export declare class ScoreRepository {
8
20
  team1: number;
9
21
  team2: number;
10
22
  }): Promise<Model | null>;
23
+ bulkSyncScores(tournamentId: mongoose.Types.ObjectId, updates: BulkScoreUpdate[]): Promise<void>;
11
24
  }
12
25
  export declare const scoreRepository: ScoreRepository;
13
26
  //# sourceMappingURL=score.repository.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"score.repository.d.ts","sourceRoot":"/","sources":["modules/tournament/score/score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I,CAAC;CAC7C;AAED,qBACa,eAAe;IACxB,OAAO,CAAC,KAAK,CAAyB;;IAMhC,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,gBAAgB,CAClB,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAChC,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GACxC,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAUlB,cAAc,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAmBzG;AAED,eAAO,MAAM,eAAe,iBAAiC,CAAC"}
@@ -60,6 +60,26 @@ let ScoreRepository = class ScoreRepository {
60
60
  .findOneAndUpdate({ _id: tournamentId, 'matches._id': matchId }, { $set: { 'matches.$.score': score } }, { new: true })
61
61
  .lean();
62
62
  }
63
+ async bulkSyncScores(tournamentId, updates) {
64
+ await this.model.bulkWrite(updates.map(({ matchId, score, matchStatus, matchEnded, endDate, winnerId }) => {
65
+ const set = {
66
+ 'matches.$.score': score,
67
+ 'matches.$.matchStatus': matchStatus,
68
+ };
69
+ if (matchEnded !== undefined)
70
+ set['matches.$.matchEnded'] = matchEnded;
71
+ if (endDate !== undefined)
72
+ set['matches.$.endDate'] = endDate;
73
+ if (winnerId !== undefined)
74
+ set['matches.$.winnerId'] = winnerId;
75
+ return {
76
+ updateOne: {
77
+ filter: { _id: tournamentId, 'matches._id': matchId },
78
+ update: { $set: set },
79
+ },
80
+ };
81
+ }));
82
+ }
63
83
  };
64
84
  exports.ScoreRepository = ScoreRepository;
65
85
  exports.ScoreRepository = ScoreRepository = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"score.repository.js","sourceRoot":"/","sources":["modules/tournament/score/score.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,sEAA+F;AAGxF,IAAM,eAAe,GAArB,MAAM,eAAe;IAChB,KAAK,CAAyB;IAEtC;QACI,IAAI,CAAC,KAAK,GAAG,wBAAe,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,YAAqC,EAAE,OAAgC;QAC/F,OAAO,IAAI,CAAC,KAAK;aACZ,OAAO,CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC;aACtD,IAAI,EAA2B,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,gBAAgB,CAClB,YAAqC,EACrC,OAAgC,EAChC,KAAuC;QAEvC,OAAO,IAAI,CAAC,KAAK;aACZ,gBAAgB,CACb,EAAE,GAAG,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,EAC7C,EAAC,IAAI,EAAE,EAAC,iBAAiB,EAAE,KAAK,EAAC,EAAC,EAClC,EAAE,GAAG,EAAE,IAAI,EAAE,CAChB;aACA,IAAI,EAA2B,CAAC;IACzC,CAAC;CACJ,CAAA;AA1BY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,gBAAO,GAAE;;GACG,eAAe,CA0B3B;AAEY,QAAA,eAAe,GAAG,gBAAS,CAAC,GAAG,CAAC,eAAe,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 ScoreRepository {\n private model: typeof TournamentModel;\n\n constructor() {\n this.model = TournamentModel;\n }\n\n async findMatchInTournament(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<Model | null> {\n return this.model\n .findOne({ _id: tournamentId, 'matches._id': matchId })\n .lean() as Promise<Model | null>;\n }\n\n async updateMatchScore(\n tournamentId: mongoose.Types.ObjectId,\n matchId: mongoose.Types.ObjectId,\n score: { team1: number; team2: number },\n ): Promise<Model | null> {\n return this.model\n .findOneAndUpdate(\n { _id: tournamentId, 'matches._id': matchId },\n {$set: {'matches.$.score': score}},\n { new: true }\n )\n .lean() as Promise<Model | null>;\n }\n}\n\nexport const scoreRepository = Container.get(ScoreRepository);\n"]}
1
+ {"version":3,"file":"score.repository.js","sourceRoot":"/","sources":["modules/tournament/score/score.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,sEAA+F;AAaxF,IAAM,eAAe,GAArB,MAAM,eAAe;IAChB,KAAK,CAAyB;IAEtC;QACI,IAAI,CAAC,KAAK,GAAG,wBAAe,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,YAAqC,EAAE,OAAgC;QAC/F,OAAO,IAAI,CAAC,KAAK;aACZ,OAAO,CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC;aACtD,IAAI,EAA2B,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,gBAAgB,CAClB,YAAqC,EACrC,OAAgC,EAChC,KAAuC;QAEvC,OAAO,IAAI,CAAC,KAAK;aACZ,gBAAgB,CACb,EAAE,GAAG,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,EAC7C,EAAC,IAAI,EAAE,EAAC,iBAAiB,EAAE,KAAK,EAAC,EAAC,EAClC,EAAE,GAAG,EAAE,IAAI,EAAE,CAChB;aACA,IAAI,EAA2B,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,YAAqC,EAAE,OAA0B;QAClF,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,CACtB,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;YAC3E,MAAM,GAAG,GAA4B;gBACjC,iBAAiB,EAAE,KAAK;gBACxB,uBAAuB,EAAE,WAAW;aACvC,CAAC;YACF,IAAI,UAAU,KAAK,SAAS;gBAAE,GAAG,CAAC,sBAAsB,CAAC,GAAG,UAAU,CAAC;YACvE,IAAI,OAAO,KAAK,SAAS;gBAAE,GAAG,CAAC,mBAAmB,CAAC,GAAG,OAAO,CAAC;YAC9D,IAAI,QAAQ,KAAK,SAAS;gBAAE,GAAG,CAAC,oBAAoB,CAAC,GAAG,QAAQ,CAAC;YACjE,OAAO;gBACH,SAAS,EAAE;oBACP,MAAM,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE;oBACrD,MAAM,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE;iBACxB;aACJ,CAAC;QACN,CAAC,CAAC,CACL,CAAC;IACN,CAAC;CACJ,CAAA;AA9CY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,gBAAO,GAAE;;GACG,eAAe,CA8C3B;AAEY,QAAA,eAAe,GAAG,gBAAS,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {Tournament as Model, TournamentModel} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {TournamentMatchStatus} from '@lyxa.ai/core/dist/utilities/enum';\n\nexport interface BulkScoreUpdate {\n matchId: mongoose.Types.ObjectId;\n score: { team1: number; team2: number };\n matchStatus: TournamentMatchStatus;\n matchEnded?: boolean;\n endDate?: Date;\n winnerId?: mongoose.Types.ObjectId | null;\n}\n\n@Service()\nexport class ScoreRepository {\n private model: typeof TournamentModel;\n\n constructor() {\n this.model = TournamentModel;\n }\n\n async findMatchInTournament(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<Model | null> {\n return this.model\n .findOne({ _id: tournamentId, 'matches._id': matchId })\n .lean() as Promise<Model | null>;\n }\n\n async updateMatchScore(\n tournamentId: mongoose.Types.ObjectId,\n matchId: mongoose.Types.ObjectId,\n score: { team1: number; team2: number },\n ): Promise<Model | null> {\n return this.model\n .findOneAndUpdate(\n { _id: tournamentId, 'matches._id': matchId },\n {$set: {'matches.$.score': score}},\n { new: true }\n )\n .lean() as Promise<Model | null>;\n }\n\n async bulkSyncScores(tournamentId: mongoose.Types.ObjectId, updates: BulkScoreUpdate[]): Promise<void> {\n await this.model.bulkWrite(\n updates.map(({ matchId, score, matchStatus, matchEnded, endDate, winnerId }) => {\n const set: Record<string, unknown> = {\n 'matches.$.score': score,\n 'matches.$.matchStatus': matchStatus,\n };\n if (matchEnded !== undefined) set['matches.$.matchEnded'] = matchEnded;\n if (endDate !== undefined) set['matches.$.endDate'] = endDate;\n if (winnerId !== undefined) set['matches.$.winnerId'] = winnerId;\n return {\n updateOne: {\n filter: { _id: tournamentId, 'matches._id': matchId },\n update: { $set: set },\n },\n };\n })\n );\n }\n}\n\nexport const scoreRepository = Container.get(ScoreRepository);\n"]}
@@ -1,3 +1,5 @@
1
+ import { mongoose } from '@typegoose/typegoose';
2
+ import { BulkScoreUpdate } from './score.repository';
1
3
  import { UpdateMatchScoreInputDTO } from './score.validation';
2
4
  import { TournamentMatchOutputDTO } from '../match/match.validation';
3
5
  export declare class ScoreService {
@@ -7,6 +9,7 @@ export declare class ScoreService {
7
9
  private resolveScore;
8
10
  private resolveWinner;
9
11
  private extractUpdatedMatch;
12
+ bulkSyncScores(tournamentId: mongoose.Types.ObjectId, updates: BulkScoreUpdate[]): Promise<void>;
10
13
  updateMatchScore(input: UpdateMatchScoreInputDTO): Promise<TournamentMatchOutputDTO>;
11
14
  }
12
15
  export declare const scoreService: ScoreService;
@@ -1 +1 @@
1
- {"version":3,"file":"score.service.d.ts","sourceRoot":"/","sources":["modules/tournament/score/score.service.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAErE,qBACa,YAAY;IACrB,OAAO,CAAC,UAAU,CAAkB;;YAMtB,QAAQ;IAQtB,OAAO,CAAC,YAAY;IAuBpB,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,mBAAmB;IASd,gBAAgB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,wBAAwB,CAAC;CASpG;AAED,eAAO,MAAM,YAAY,cAA8B,CAAC"}
1
+ {"version":3,"file":"score.service.d.ts","sourceRoot":"/","sources":["modules/tournament/score/score.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAE,eAAe,EAAmB,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAErE,qBACa,YAAY;IACrB,OAAO,CAAC,UAAU,CAAkB;;YAMtB,QAAQ;IAQtB,OAAO,CAAC,YAAY;IAuBpB,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,mBAAmB;IASd,cAAc,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhG,gBAAgB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,wBAAwB,CAAC;CASpG;AAED,eAAO,MAAM,YAAY,cAA8B,CAAC"}
@@ -91,6 +91,9 @@ let ScoreService = class ScoreService {
91
91
  throw (0, error_common_1.notFoundError)('Match not found after update');
92
92
  return updated;
93
93
  }
94
+ async bulkSyncScores(tournamentId, updates) {
95
+ await this.repository.bulkSyncScores(tournamentId, updates);
96
+ }
94
97
  async updateMatchScore(input) {
95
98
  const { match } = await this.getMatch(input.tournamentId, input.matchId);
96
99
  const score = this.resolveScore(match, input.teams);