@lyxa.ai/marketing 1.0.48 → 1.0.49

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 (196) hide show
  1. package/dist/lib/event/event-initializations.js +2 -2
  2. package/dist/lib/event/event-initializations.js.map +1 -1
  3. package/dist/lib/index.d.ts +228 -493
  4. package/dist/lib/index.d.ts.map +1 -1
  5. package/dist/lib/modules/coupon/services/coupon.service.d.ts +2 -2
  6. package/dist/lib/modules/coupon/services/coupon.service.d.ts.map +1 -1
  7. package/dist/lib/modules/coupon/services/coupon.service.js.map +1 -1
  8. package/dist/lib/modules/coupon/services/global-coupon.service.d.ts.map +1 -1
  9. package/dist/lib/modules/coupon/services/global-coupon.service.js +2 -0
  10. package/dist/lib/modules/coupon/services/global-coupon.service.js.map +1 -1
  11. package/dist/lib/modules/coupon/services/helper.service.d.ts.map +1 -1
  12. package/dist/lib/modules/coupon/services/helper.service.js +2 -0
  13. package/dist/lib/modules/coupon/services/helper.service.js.map +1 -1
  14. package/dist/lib/modules/coupon/services/individual-user-coupon.service.d.ts.map +1 -1
  15. package/dist/lib/modules/coupon/services/individual-user-coupon.service.js +2 -0
  16. package/dist/lib/modules/coupon/services/individual-user-coupon.service.js.map +1 -1
  17. package/dist/lib/modules/coupon/services/referral-reward-coupon.service.d.ts.map +1 -1
  18. package/dist/lib/modules/coupon/services/referral-reward-coupon.service.js +2 -0
  19. package/dist/lib/modules/coupon/services/referral-reward-coupon.service.js.map +1 -1
  20. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts +10 -21
  21. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
  22. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js +5 -4
  23. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js.map +1 -1
  24. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +154 -0
  25. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts.map +1 -1
  26. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js +13 -1
  27. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js.map +1 -1
  28. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts +8 -2
  29. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
  30. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js +11 -2
  31. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js.map +1 -1
  32. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts +10 -21
  33. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
  34. package/dist/lib/modules/tournament/config/config.builder.d.ts.map +1 -1
  35. package/dist/lib/modules/tournament/config/config.builder.js +4 -0
  36. package/dist/lib/modules/tournament/config/config.builder.js.map +1 -1
  37. package/dist/lib/modules/tournament/config/config.repository.d.ts +1 -0
  38. package/dist/lib/modules/tournament/config/config.repository.d.ts.map +1 -1
  39. package/dist/lib/modules/tournament/config/config.repository.js +7 -1
  40. package/dist/lib/modules/tournament/config/config.repository.js.map +1 -1
  41. package/dist/lib/modules/tournament/config/config.router.d.ts +96 -208
  42. package/dist/lib/modules/tournament/config/config.router.d.ts.map +1 -1
  43. package/dist/lib/modules/tournament/config/config.service.d.ts +2 -2
  44. package/dist/lib/modules/tournament/config/config.service.d.ts.map +1 -1
  45. package/dist/lib/modules/tournament/config/config.service.js.map +1 -1
  46. package/dist/lib/modules/tournament/config/config.validation.d.ts +412 -659
  47. package/dist/lib/modules/tournament/config/config.validation.d.ts.map +1 -1
  48. package/dist/lib/modules/tournament/config/config.validation.js +40 -25
  49. package/dist/lib/modules/tournament/config/config.validation.js.map +1 -1
  50. package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.d.ts +2 -0
  51. package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.d.ts.map +1 -0
  52. package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js +20 -0
  53. package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js.map +1 -0
  54. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.d.ts +15 -0
  55. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.d.ts.map +1 -0
  56. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.js +12 -0
  57. package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.js.map +1 -0
  58. package/dist/lib/modules/tournament/match/match.builder.d.ts +5 -2
  59. package/dist/lib/modules/tournament/match/match.builder.d.ts.map +1 -1
  60. package/dist/lib/modules/tournament/match/match.builder.js +12 -7
  61. package/dist/lib/modules/tournament/match/match.builder.js.map +1 -1
  62. package/dist/lib/modules/tournament/match/match.router.d.ts +50 -187
  63. package/dist/lib/modules/tournament/match/match.router.d.ts.map +1 -1
  64. package/dist/lib/modules/tournament/match/match.router.js +0 -7
  65. package/dist/lib/modules/tournament/match/match.router.js.map +1 -1
  66. package/dist/lib/modules/tournament/match/match.service.d.ts +1 -11
  67. package/dist/lib/modules/tournament/match/match.service.d.ts.map +1 -1
  68. package/dist/lib/modules/tournament/match/match.service.js +17 -61
  69. package/dist/lib/modules/tournament/match/match.service.js.map +1 -1
  70. package/dist/lib/modules/tournament/match/match.validation.d.ts +46 -34
  71. package/dist/lib/modules/tournament/match/match.validation.d.ts.map +1 -1
  72. package/dist/lib/modules/tournament/match/match.validation.js +4 -2
  73. package/dist/lib/modules/tournament/match/match.validation.js.map +1 -1
  74. package/dist/lib/modules/tournament/notification/notification.service.d.ts +2 -1
  75. package/dist/lib/modules/tournament/notification/notification.service.d.ts.map +1 -1
  76. package/dist/lib/modules/tournament/notification/notification.service.js +16 -11
  77. package/dist/lib/modules/tournament/notification/notification.service.js.map +1 -1
  78. package/dist/lib/modules/tournament/participant/participant.router.d.ts +9 -9
  79. package/dist/lib/modules/tournament/participant/participant.validation.d.ts +84 -84
  80. package/dist/lib/modules/tournament/prediction/prediction.repository.d.ts +4 -1
  81. package/dist/lib/modules/tournament/prediction/prediction.repository.d.ts.map +1 -1
  82. package/dist/lib/modules/tournament/prediction/prediction.repository.js +20 -2
  83. package/dist/lib/modules/tournament/prediction/prediction.repository.js.map +1 -1
  84. package/dist/lib/modules/tournament/prediction/prediction.router.d.ts +12 -12
  85. package/dist/lib/modules/tournament/prediction/prediction.service.d.ts +8 -0
  86. package/dist/lib/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
  87. package/dist/lib/modules/tournament/prediction/prediction.service.js +20 -3
  88. package/dist/lib/modules/tournament/prediction/prediction.service.js.map +1 -1
  89. package/dist/lib/modules/tournament/prediction/prediction.validation.d.ts +64 -64
  90. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.d.ts +3 -0
  91. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.d.ts.map +1 -1
  92. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.js +21 -5
  93. package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.js.map +1 -1
  94. package/dist/lib/modules/tournament/reward/reward.builder.d.ts +6 -0
  95. package/dist/lib/modules/tournament/reward/reward.builder.d.ts.map +1 -0
  96. package/dist/lib/modules/tournament/reward/reward.builder.js +43 -0
  97. package/dist/lib/modules/tournament/reward/reward.builder.js.map +1 -0
  98. package/dist/lib/modules/tournament/reward/reward.interface.d.ts.map +1 -1
  99. package/dist/lib/modules/tournament/reward/reward.interface.js.map +1 -1
  100. package/dist/lib/modules/tournament/reward/reward.service.d.ts.map +1 -1
  101. package/dist/lib/modules/tournament/reward/reward.service.js.map +1 -1
  102. package/dist/lib/modules/tournament/reward/reward.types.d.ts +1 -1
  103. package/dist/lib/modules/tournament/reward/reward.types.d.ts.map +1 -1
  104. package/dist/lib/modules/tournament/reward/reward.types.js.map +1 -1
  105. package/dist/lib/modules/tournament/score/score.repository.d.ts +6 -0
  106. package/dist/lib/modules/tournament/score/score.repository.d.ts.map +1 -0
  107. package/dist/lib/modules/tournament/score/score.repository.js +60 -0
  108. package/dist/lib/modules/tournament/score/score.repository.js.map +1 -0
  109. package/dist/lib/modules/tournament/score/score.service.d.ts +6 -0
  110. package/dist/lib/modules/tournament/score/score.service.d.ts.map +1 -0
  111. package/dist/lib/modules/tournament/score/score.service.js +60 -0
  112. package/dist/lib/modules/tournament/score/score.service.js.map +1 -0
  113. package/dist/lib/modules/tournament/team/team.router.d.ts +22 -54
  114. package/dist/lib/modules/tournament/team/team.router.d.ts.map +1 -1
  115. package/dist/lib/modules/tournament/team/team.validation.d.ts +14 -14
  116. package/dist/lib/modules/tournament/tournament.router.d.ts +216 -470
  117. package/dist/lib/modules/tournament/tournament.router.d.ts.map +1 -1
  118. package/dist/lib/modules/tournament/tournament.router.js +8 -0
  119. package/dist/lib/modules/tournament/tournament.router.js.map +1 -1
  120. package/dist/lib/modules/tournament/tournament.service.d.ts +8 -0
  121. package/dist/lib/modules/tournament/tournament.service.d.ts.map +1 -0
  122. package/dist/lib/modules/tournament/tournament.service.js +63 -0
  123. package/dist/lib/modules/tournament/tournament.service.js.map +1 -0
  124. package/dist/lib/modules/tournament/tournament.validation.d.ts +133 -0
  125. package/dist/lib/modules/tournament/tournament.validation.d.ts.map +1 -0
  126. package/dist/lib/modules/tournament/tournament.validation.js +14 -0
  127. package/dist/lib/modules/tournament/tournament.validation.js.map +1 -0
  128. package/dist/types/index.d.ts +228 -493
  129. package/dist/types/index.d.ts.map +1 -1
  130. package/dist/types/modules/coupon/services/coupon.service.d.ts +2 -2
  131. package/dist/types/modules/coupon/services/coupon.service.d.ts.map +1 -1
  132. package/dist/types/modules/coupon/services/global-coupon.service.d.ts.map +1 -1
  133. package/dist/types/modules/coupon/services/helper.service.d.ts.map +1 -1
  134. package/dist/types/modules/coupon/services/individual-user-coupon.service.d.ts.map +1 -1
  135. package/dist/types/modules/coupon/services/referral-reward-coupon.service.d.ts.map +1 -1
  136. package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts +10 -21
  137. package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
  138. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +154 -0
  139. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts.map +1 -1
  140. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts +8 -2
  141. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
  142. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts +10 -21
  143. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
  144. package/dist/types/modules/tournament/config/config.builder.d.ts.map +1 -1
  145. package/dist/types/modules/tournament/config/config.repository.d.ts +1 -0
  146. package/dist/types/modules/tournament/config/config.repository.d.ts.map +1 -1
  147. package/dist/types/modules/tournament/config/config.router.d.ts +96 -208
  148. package/dist/types/modules/tournament/config/config.router.d.ts.map +1 -1
  149. package/dist/types/modules/tournament/config/config.service.d.ts +2 -2
  150. package/dist/types/modules/tournament/config/config.service.d.ts.map +1 -1
  151. package/dist/types/modules/tournament/config/config.validation.d.ts +412 -659
  152. package/dist/types/modules/tournament/config/config.validation.d.ts.map +1 -1
  153. package/dist/types/modules/tournament/match/events/evaluate-predictions.consumer.d.ts +2 -0
  154. package/dist/types/modules/tournament/match/events/evaluate-predictions.consumer.d.ts.map +1 -0
  155. package/dist/types/modules/tournament/match/events/evaluate-predictions.event.d.ts +15 -0
  156. package/dist/types/modules/tournament/match/events/evaluate-predictions.event.d.ts.map +1 -0
  157. package/dist/types/modules/tournament/match/match.builder.d.ts +5 -2
  158. package/dist/types/modules/tournament/match/match.builder.d.ts.map +1 -1
  159. package/dist/types/modules/tournament/match/match.router.d.ts +50 -187
  160. package/dist/types/modules/tournament/match/match.router.d.ts.map +1 -1
  161. package/dist/types/modules/tournament/match/match.service.d.ts +1 -11
  162. package/dist/types/modules/tournament/match/match.service.d.ts.map +1 -1
  163. package/dist/types/modules/tournament/match/match.validation.d.ts +46 -34
  164. package/dist/types/modules/tournament/match/match.validation.d.ts.map +1 -1
  165. package/dist/types/modules/tournament/notification/notification.service.d.ts +2 -1
  166. package/dist/types/modules/tournament/notification/notification.service.d.ts.map +1 -1
  167. package/dist/types/modules/tournament/participant/participant.router.d.ts +9 -9
  168. package/dist/types/modules/tournament/participant/participant.validation.d.ts +84 -84
  169. package/dist/types/modules/tournament/prediction/prediction.repository.d.ts +4 -1
  170. package/dist/types/modules/tournament/prediction/prediction.repository.d.ts.map +1 -1
  171. package/dist/types/modules/tournament/prediction/prediction.router.d.ts +12 -12
  172. package/dist/types/modules/tournament/prediction/prediction.service.d.ts +8 -0
  173. package/dist/types/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
  174. package/dist/types/modules/tournament/prediction/prediction.validation.d.ts +64 -64
  175. package/dist/types/modules/tournament/reward/handlers/coupon-reward.handler.d.ts +3 -0
  176. package/dist/types/modules/tournament/reward/handlers/coupon-reward.handler.d.ts.map +1 -1
  177. package/dist/types/modules/tournament/reward/reward.builder.d.ts +6 -0
  178. package/dist/types/modules/tournament/reward/reward.builder.d.ts.map +1 -0
  179. package/dist/types/modules/tournament/reward/reward.interface.d.ts.map +1 -1
  180. package/dist/types/modules/tournament/reward/reward.service.d.ts.map +1 -1
  181. package/dist/types/modules/tournament/reward/reward.types.d.ts +1 -1
  182. package/dist/types/modules/tournament/reward/reward.types.d.ts.map +1 -1
  183. package/dist/types/modules/tournament/score/score.repository.d.ts +6 -0
  184. package/dist/types/modules/tournament/score/score.repository.d.ts.map +1 -0
  185. package/dist/types/modules/tournament/score/score.service.d.ts +6 -0
  186. package/dist/types/modules/tournament/score/score.service.d.ts.map +1 -0
  187. package/dist/types/modules/tournament/team/team.router.d.ts +22 -54
  188. package/dist/types/modules/tournament/team/team.router.d.ts.map +1 -1
  189. package/dist/types/modules/tournament/team/team.validation.d.ts +14 -14
  190. package/dist/types/modules/tournament/tournament.router.d.ts +216 -470
  191. package/dist/types/modules/tournament/tournament.router.d.ts.map +1 -1
  192. package/dist/types/modules/tournament/tournament.service.d.ts +8 -0
  193. package/dist/types/modules/tournament/tournament.service.d.ts.map +1 -0
  194. package/dist/types/modules/tournament/tournament.validation.d.ts +133 -0
  195. package/dist/types/modules/tournament/tournament.validation.d.ts.map +1 -0
  196. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"match.service.js","sourceRoot":"/","sources":["modules/tournament/match/match.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAC5C,yCAAyC;AAEzC,4EAA2F;AAC3F,8DAAkE;AAQlE,yDAA+D;AAC/D,mDAA+C;AAG/C,mGAA8F;AAC9F,+EAAqF;AACrF,4EAAwE;AACxE,+EAA2E;AAC3E,6DAAyD;AACzD,yDAAoD;AACpD,kEAA6D;AAE7D,MAAM,eAAe,GAAG,OAAO,CAAC;AAGzB,IAAM,YAAY,GAAlB,MAAM,YAAY;IACb,UAAU,CAA4B;IACtC,qBAAqB,CAA+B;IACpD,mBAAmB,CAAgC;IACnD,kBAAkB,CAAqB;IACvC,oBAAoB,CAAuB;IAC3C,aAAa,CAAgB;IAErC;QACI,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,4CAAyB,CAAC,CAAC;QAC3D,IAAI,CAAC,qBAAqB,GAAG,gBAAS,CAAC,GAAG,CAAC,6DAA4B,CAAC,CAAC;QACzE,IAAI,CAAC,mBAAmB,GAAG,gBAAS,CAAC,GAAG,CAAC,oDAA6B,CAAC,CAAC;QACxE,IAAI,CAAC,kBAAkB,GAAG,gBAAS,CAAC,GAAG,CAAC,wCAAkB,CAAC,CAAC;QAC5D,IAAI,CAAC,oBAAoB,GAAG,gBAAS,CAAC,GAAG,CAAC,4CAAoB,CAAC,CAAC;QAChE,IAAI,CAAC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AAE;gBACjC,UAAU,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE;aAC/B,CAAC,CAAC,CAAC;QACR,CAAC;QAED,MAAM,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAEnF,OAAO,KAAK,CAAC;IACjB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,YAAqC,EAAE,OAAgC;QACvF,MAAM,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;QACvC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACxE,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,kBAAS,CAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,OAAO,EAAE,wBAAwB,EAAE,CAAC,CAAC;QAEvG,MAAM,IAAI,CAAC,qBAAqB,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAEzD,OAAO,MAAmC,CAAC;IAC/C,CAAC;CACJ,CAAA;AAzKY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,gBAAO,GAAE;;GACG,YAAY,CAyKxB;AAEY,QAAA,YAAY,GAAG,gBAAS,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { TRPCError } from '@trpc/server';\nimport { mongoose } from '@typegoose/typegoose';\nimport { badRequestError, notFoundError } from '@lyxa.ai/core/dist/utilities/error-common';\nimport { publishEvent } from '@lyxa.ai/core/dist/libraries/event';\nimport {\n AddTournamentMatchesInputDTO,\n EndTournamentMatchInputDTO,\n StartTournamentMatchInputDTO,\n TournamentMatchOutputDTO,\n UpdateMatchScoreInputDTO,\n} from './match.validation';\nimport { TournamentMatchRepository } from './match.repository';\nimport { MatchBuilder } from './match.builder';\nimport { TournamentConfigOutputDTO } from '../config/config.validation';\nimport { Tournament as TournamentType } from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport { NotificationSchedulerService } from '../notification/notification.scheduler.service';\nimport { TournamentNotificationService } from '../notification/notification.service';\nimport { ParticipantService } from '../participant/participant.service';\nimport { PredictionRepository } from '../prediction/prediction.repository';\nimport { RewardService } from '../reward/reward.service';\nimport { RewardType } from '../reward/reward.types';\nimport { MatchEndedEvent } from './events/match-ended.event';\n\nconst FWC_COUPON_CODE = 'FWC01';\n\n@Service()\nexport class MatchService {\n private repository: TournamentMatchRepository;\n private notificationScheduler: NotificationSchedulerService;\n private notificationService: TournamentNotificationService;\n private participantService: ParticipantService;\n private predictionRepository: PredictionRepository;\n private rewardService: RewardService;\n\n constructor() {\n this.repository = Container.get(TournamentMatchRepository);\n this.notificationScheduler = Container.get(NotificationSchedulerService);\n this.notificationService = Container.get(TournamentNotificationService);\n this.participantService = Container.get(ParticipantService);\n this.predictionRepository = Container.get(PredictionRepository);\n this.rewardService = Container.get(RewardService);\n }\n\n private async getTournament(tournamentId: mongoose.Types.ObjectId) {\n const tournament = await this.repository.findById(tournamentId);\n if (!tournament) throw notFoundError('Tournament not found');\n return tournament;\n }\n\n private getMatch(tournament: { matches: TournamentMatchOutputDTO[] }, matchId: mongoose.Types.ObjectId) {\n const match = tournament.matches.find(m => m._id.toString() === matchId.toString());\n if (!match) throw notFoundError('Match not found');\n return match;\n }\n\n private validateWinner(match: TournamentMatchOutputDTO, winnerId?: mongoose.Types.ObjectId) {\n if (!winnerId) return;\n if (![match.team1.teamId.toString(), match.team2.teamId.toString()].includes(winnerId.toString())) {\n throw badRequestError('Winner must be one of the match teams');\n }\n }\n\n private resolveMatchTeams(tournament: TournamentType, team1Id: mongoose.Types.ObjectId, team2Id: mongoose.Types.ObjectId) {\n const teamsById = new Map(tournament.teams.map(team => [team._id.toString(), team]));\n const team1 = teamsById.get(team1Id.toString());\n const team2 = teamsById.get(team2Id.toString());\n if (!team1 || !team2) throw badRequestError('All match teams must exist in the tournament');\n return { team1, team2 };\n }\n\n private async applyMatchUpdate(\n tournamentId: mongoose.Types.ObjectId,\n matchId: mongoose.Types.ObjectId,\n updates: Record<string, unknown>,\n errorMessage: string\n ): Promise<TournamentMatchOutputDTO> {\n const result = await this.repository.updateMatch(tournamentId, matchId, updates);\n if (!result) throw new TRPCError({ code: 'INTERNAL_SERVER_ERROR', message: errorMessage });\n const updated = result.matches.find(m => m._id.toString() === matchId.toString());\n if (!updated) throw notFoundError('Match not found');\n return updated as TournamentMatchOutputDTO;\n }\n\n public async handleMatchEnded(\n tournamentId: mongoose.Types.ObjectId,\n matchId: mongoose.Types.ObjectId,\n finalScore: { team1: number; team2: number }\n ): Promise<void> {\n const participants = await this.participantService.getAll(tournamentId);\n\n await Promise.all(\n participants.map(async participant => {\n const prediction = participant.predictions.find(\n p => p.matchId.toString() === matchId.toString()\n );\n if (!prediction) return;\n\n const correct =\n prediction.score.team1 === finalScore.team1 &&\n prediction.score.team2 === finalScore.team2;\n\n await this.predictionRepository.setSucceeded(participant._id, matchId, correct);\n\n if (correct) {\n const expiresAt = new Date();\n expiresAt.setMonth(expiresAt.getMonth() + 1);\n await this.rewardService.grant(RewardType.COUPON, {\n userId: participant.userId,\n tournamentId,\n matchId,\n payload: { code: FWC_COUPON_CODE, expiresAt },\n });\n }\n })\n );\n }\n\n public async add(input: AddTournamentMatchesInputDTO): Promise<TournamentConfigOutputDTO> {\n const tournament = await this.getTournament(input.tournamentId);\n\n const matches = input.matches.map(match => {\n const { team1, team2 } = this.resolveMatchTeams(tournament, match.team1Id, match.team2Id);\n return MatchBuilder.buildMatch(match, team1, team2);\n });\n\n const result = await this.repository.addMatches(input.tournamentId, matches);\n if (!result) throw new TRPCError({ code: 'INTERNAL_SERVER_ERROR', message: 'Failed to add matches' });\n\n await Promise.all(\n matches.map(match =>\n this.notificationScheduler.scheduleForMatch(match._id, input.tournamentId, match.startingDate!)\n )\n );\n\n return result as TournamentConfigOutputDTO;\n }\n\n public async getAll(tournamentId: mongoose.Types.ObjectId): Promise<TournamentMatchOutputDTO[]> {\n const tournament = await this.getTournament(tournamentId);\n return tournament.matches as TournamentMatchOutputDTO[];\n }\n\n public async start(input: StartTournamentMatchInputDTO): Promise<TournamentMatchOutputDTO> {\n const tournament = await this.getTournament(input.tournamentId);\n const match = this.getMatch(tournament, input.matchId);\n\n if (match.endDate) throw badRequestError('This match has already ended');\n\n await this.notificationScheduler.cancelForMatch(input.matchId);\n\n return this.applyMatchUpdate(\n input.tournamentId,\n input.matchId,\n { startingDate: new Date() },\n 'Failed to start match'\n );\n }\n\n public async updateScore(input: UpdateMatchScoreInputDTO): Promise<TournamentMatchOutputDTO> {\n const tournament = await this.getTournament(input.tournamentId);\n const match = this.getMatch(tournament, input.matchId);\n this.validateWinner(match, input.winnerId);\n return this.applyMatchUpdate(input.tournamentId, input.matchId, MatchBuilder.buildScoreUpdate(input), 'Failed to update match score');\n }\n\n public async end(input: EndTournamentMatchInputDTO): Promise<TournamentMatchOutputDTO> {\n const tournament = await this.getTournament(input.tournamentId);\n const match = this.getMatch(tournament, input.matchId);\n this.validateWinner(match, input.winnerId);\n\n const ended = await this.applyMatchUpdate(input.tournamentId, input.matchId, MatchBuilder.buildEndUpdate(input), 'Failed to end match');\n\n const { team1, team2 } = ended.score;\n if (team1 !== null && team1 !== undefined && team2 !== null && team2 !== undefined) {\n await publishEvent(new MatchEndedEvent({\n tournamentId: input.tournamentId.toString(),\n matchId: input.matchId.toString(),\n finalScore: { team1, team2 },\n }));\n }\n\n await this.notificationService.notifyMatchEnded(input.tournamentId, input.matchId);\n\n return ended;\n }\n\n public async delete(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<TournamentConfigOutputDTO> {\n await this.getTournament(tournamentId);\n const result = await this.repository.deleteMatch(tournamentId, matchId);\n if (!result) throw new TRPCError({ code: 'INTERNAL_SERVER_ERROR', message: 'Failed to delete match' });\n\n await this.notificationScheduler.cancelForMatch(matchId);\n\n return result as TournamentConfigOutputDTO;\n }\n}\n\nexport const matchService = Container.get(Mat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AC;QACvC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACxE,IAAI,CAAC,MAAM;YAAE,MAAM,IAAA,4BAAa,EAAC,sBAAsB,CAAC,CAAC;QAEzD,MAAM,IAAI,CAAC,qBAAqB,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAEzD,OAAO,MAAmC,CAAC;IAC/C,CAAC;CACJ,CAAA;AA5GY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,gBAAO,GAAE;;GACG,YAAY,CA4GxB;AAEY,QAAA,YAAY,GAAG,gBAAS,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {badRequestError, notFoundError} from '@lyxa.ai/core/dist/utilities/error-common';\nimport {publishEvent} from '@lyxa.ai/core/dist/libraries/event';\nimport {\n AddTournamentMatchesInputDTO,\n EndTournamentMatchInputDTO,\n StartTournamentMatchInputDTO,\n TournamentMatchOutputDTO,\n} from './match.validation';\nimport {TournamentMatchRepository} from './match.repository';\nimport {MatchBuilder} from './match.builder';\nimport {TournamentConfigOutputDTO} from '../config/config.validation';\nimport {Tournament as TournamentType} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {NotificationSchedulerService} from '../notification/notification.scheduler.service';\nimport {EvaluatePredictionsEvent} from './events/evaluate-predictions.event';\n\n@Service()\nexport class MatchService {\n private repository: TournamentMatchRepository;\n private notificationScheduler: NotificationSchedulerService;\n\n constructor() {\n this.repository = Container.get(TournamentMatchRepository);\n this.notificationScheduler = Container.get(NotificationSchedulerService);\n }\n\n private async getTournament(tournamentId: mongoose.Types.ObjectId) {\n const tournament = await this.repository.findById(tournamentId);\n if (!tournament) throw notFoundError('Tournament not found');\n return tournament;\n }\n\n private getMatch(tournament: {matches: TournamentMatchOutputDTO[]}, matchId: mongoose.Types.ObjectId) {\n const match = tournament.matches.find(m => m._id.toString() === matchId.toString());\n if (!match) throw notFoundError('Match not found');\n return match;\n }\n\n private resolveMatchTeams(tournament: TournamentType, team1Id: mongoose.Types.ObjectId, team2Id: mongoose.Types.ObjectId) {\n const teamsById = new Map(tournament.teams.map(team => [team._id.toString(), team]));\n const team1 = teamsById.get(team1Id.toString());\n const team2 = teamsById.get(team2Id.toString());\n if (!team1 || !team2) throw badRequestError('All match teams must exist in the tournament');\n return {team1, team2};\n }\n\n private async applyMatchUpdate(\n tournamentId: mongoose.Types.ObjectId,\n matchId: mongoose.Types.ObjectId,\n updates: Record<string, unknown>\n ): Promise<TournamentMatchOutputDTO> {\n const result = await this.repository.updateMatch(tournamentId, matchId, updates);\n if (!result) throw notFoundError('Tournament not found');\n const updated = result.matches.find(m => m._id.toString() === matchId.toString());\n if (!updated) throw notFoundError('Match not found');\n return updated as TournamentMatchOutputDTO;\n }\n\n public async add(input: AddTournamentMatchesInputDTO): Promise<TournamentConfigOutputDTO> {\n const tournament = await this.getTournament(input.tournamentId);\n\n const matches = input.matches.map(match => {\n const {team1, team2} = this.resolveMatchTeams(tournament, match.team1Id, match.team2Id);\n return MatchBuilder.buildMatch(match, team1, team2);\n });\n\n const result = await this.repository.addMatches(input.tournamentId, matches);\n if (!result) throw notFoundError('Tournament not found');\n\n await Promise.all(\n matches.map(match =>\n this.notificationScheduler.scheduleForMatch(match._id, input.tournamentId, match.startingDate!)\n )\n );\n\n return result as TournamentConfigOutputDTO;\n }\n\n public async getAll(tournamentId: mongoose.Types.ObjectId): Promise<TournamentMatchOutputDTO[]> {\n const tournament = await this.getTournament(tournamentId);\n return tournament.matches as TournamentMatchOutputDTO[];\n }\n\n public async start(input: StartTournamentMatchInputDTO): Promise<TournamentMatchOutputDTO> {\n const tournament = await this.getTournament(input.tournamentId);\n const match = this.getMatch(tournament, input.matchId);\n\n if (!match.startingDate || match.startingDate > new Date()) throw badRequestError('This match has not started yet');\n if (match.endDate) throw badRequestError('This match has already ended');\n\n await this.notificationScheduler.cancelForMatch(input.matchId);\n return match;\n }\n\n public async end(input: EndTournamentMatchInputDTO): Promise<TournamentMatchOutputDTO> {\n const tournament = await this.getTournament(input.tournamentId);\n const match = this.getMatch(tournament, input.matchId);\n\n if (!match.startingDate || match.startingDate > new Date()) throw badRequestError('This match has not started yet');\n if (match.endDate) throw badRequestError('This match has already ended');\n\n const matchUpdates = MatchBuilder.buildEndUpdate(match, input.finalScore)\n const ended = await this.applyMatchUpdate(input.tournamentId, input.matchId, matchUpdates);\n\n const {team1, team2} = ended.score;\n if (team1 !== null && team1 !== undefined && team2 !== null && team2 !== undefined) {\n await publishEvent(new EvaluatePredictionsEvent({\n tournamentId: input.tournamentId,\n matchId: input.matchId,\n finalScore: {team1, team2},\n }));\n }\n\n return ended;\n }\n\n public async delete(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<TournamentConfigOutputDTO> {\n await this.getTournament(tournamentId);\n const result = await this.repository.deleteMatch(tournamentId, matchId);\n if (!result) throw notFoundError('Tournament not found');\n\n await this.notificationScheduler.cancelForMatch(matchId);\n\n return result as TournamentConfigOutputDTO;\n }\n}\n\nexport const matchService = Container.get(MatchService);\n"]}
@@ -11,30 +11,30 @@ export declare const AddTournamentMatchesSchema: z.ZodObject<{
11
11
  additionalTag: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
12
12
  }, "strip", z.ZodTypeAny, {
13
13
  stage: string;
14
+ startingDate: Date;
14
15
  team1Id: import("mongoose").Types.ObjectId;
15
16
  team2Id: import("mongoose").Types.ObjectId;
16
- startingDate: Date;
17
17
  endDate?: Date | undefined;
18
18
  additionalTag?: string | undefined;
19
19
  }, {
20
20
  stage: string;
21
+ startingDate: string | Date;
21
22
  team1Id: string | import("mongoose").Types.ObjectId;
22
23
  team2Id: string | import("mongoose").Types.ObjectId;
23
- startingDate: string | Date;
24
24
  endDate?: string | Date | undefined;
25
25
  additionalTag?: string | undefined;
26
26
  }>, {
27
27
  stage: string;
28
+ startingDate: Date;
28
29
  team1Id: import("mongoose").Types.ObjectId;
29
30
  team2Id: import("mongoose").Types.ObjectId;
30
- startingDate: Date;
31
31
  endDate?: Date | undefined;
32
32
  additionalTag?: string | undefined;
33
33
  }, {
34
34
  stage: string;
35
+ startingDate: string | Date;
35
36
  team1Id: string | import("mongoose").Types.ObjectId;
36
37
  team2Id: string | import("mongoose").Types.ObjectId;
37
- startingDate: string | Date;
38
38
  endDate?: string | Date | undefined;
39
39
  additionalTag?: string | undefined;
40
40
  }>, "many">;
@@ -42,9 +42,9 @@ export declare const AddTournamentMatchesSchema: z.ZodObject<{
42
42
  tournamentId: import("mongoose").Types.ObjectId;
43
43
  matches: {
44
44
  stage: string;
45
+ startingDate: Date;
45
46
  team1Id: import("mongoose").Types.ObjectId;
46
47
  team2Id: import("mongoose").Types.ObjectId;
47
- startingDate: Date;
48
48
  endDate?: Date | undefined;
49
49
  additionalTag?: string | undefined;
50
50
  }[];
@@ -52,9 +52,9 @@ export declare const AddTournamentMatchesSchema: z.ZodObject<{
52
52
  tournamentId: string | import("mongoose").Types.ObjectId;
53
53
  matches: {
54
54
  stage: string;
55
+ startingDate: string | Date;
55
56
  team1Id: string | import("mongoose").Types.ObjectId;
56
57
  team2Id: string | import("mongoose").Types.ObjectId;
57
- startingDate: string | Date;
58
58
  endDate?: string | Date | undefined;
59
59
  additionalTag?: string | undefined;
60
60
  }[];
@@ -98,18 +98,30 @@ export declare const StartTournamentMatchSchema: z.ZodObject<{
98
98
  export declare const EndTournamentMatchSchema: z.ZodObject<{
99
99
  tournamentId: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>;
100
100
  matchId: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>;
101
- endDate: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>, z.ZodDate]>, Date, string | Date>, Date, string | Date>>;
102
- winnerId: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>>;
101
+ finalScore: z.ZodOptional<z.ZodObject<{
102
+ team1: z.ZodNumber;
103
+ team2: z.ZodNumber;
104
+ }, "strip", z.ZodTypeAny, {
105
+ team1: number;
106
+ team2: number;
107
+ }, {
108
+ team1: number;
109
+ team2: number;
110
+ }>>;
103
111
  }, "strip", z.ZodTypeAny, {
104
112
  tournamentId: import("mongoose").Types.ObjectId;
105
113
  matchId: import("mongoose").Types.ObjectId;
106
- endDate?: Date | undefined;
107
- winnerId?: import("mongoose").Types.ObjectId | undefined;
114
+ finalScore?: {
115
+ team1: number;
116
+ team2: number;
117
+ } | undefined;
108
118
  }, {
109
119
  tournamentId: string | import("mongoose").Types.ObjectId;
110
120
  matchId: string | import("mongoose").Types.ObjectId;
111
- endDate?: string | Date | undefined;
112
- winnerId?: string | import("mongoose").Types.ObjectId | undefined;
121
+ finalScore?: {
122
+ team1: number;
123
+ team2: number;
124
+ } | undefined;
113
125
  }>;
114
126
  export declare const TournamentMatchSchema: z.ZodObject<{
115
127
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>;
@@ -189,9 +201,9 @@ export declare const TournamentMatchSchema: z.ZodObject<{
189
201
  };
190
202
  stage: string;
191
203
  endDate?: Date | null | undefined;
192
- startingDate?: Date | null | undefined;
193
204
  additionalTag?: string | undefined;
194
205
  winnerId?: import("mongoose").Types.ObjectId | null | undefined;
206
+ startingDate?: Date | null | undefined;
195
207
  prediction?: {
196
208
  score: {
197
209
  team1: number | null;
@@ -215,9 +227,9 @@ export declare const TournamentMatchSchema: z.ZodObject<{
215
227
  };
216
228
  stage: string;
217
229
  endDate?: Date | null | undefined;
218
- startingDate?: Date | null | undefined;
219
230
  additionalTag?: string | undefined;
220
231
  winnerId?: string | import("mongoose").Types.ObjectId | null | undefined;
232
+ startingDate?: Date | null | undefined;
221
233
  prediction?: {
222
234
  score: {
223
235
  team1: number | null;
@@ -262,9 +274,9 @@ export declare const TournamentMatchResponseSchema: z.ZodObject<{
262
274
  };
263
275
  stage: string;
264
276
  endDate?: Date | null | undefined;
265
- startingDate?: Date | null | undefined;
266
277
  additionalTag?: string | undefined;
267
278
  winnerId?: string | import("mongoose").Types.ObjectId | null | undefined;
279
+ startingDate?: Date | null | undefined;
268
280
  prediction?: {
269
281
  score: {
270
282
  team1: number | null;
@@ -288,9 +300,9 @@ export declare const TournamentMatchResponseSchema: z.ZodObject<{
288
300
  };
289
301
  stage: string;
290
302
  endDate?: Date | null | undefined;
291
- startingDate?: Date | null | undefined;
292
303
  additionalTag?: string | undefined;
293
304
  winnerId?: string | import("mongoose").Types.ObjectId | null | undefined;
305
+ startingDate?: Date | null | undefined;
294
306
  prediction?: {
295
307
  score: {
296
308
  team1: number | null;
@@ -316,9 +328,9 @@ export declare const TournamentMatchResponseSchema: z.ZodObject<{
316
328
  };
317
329
  stage: string;
318
330
  endDate?: Date | null | undefined;
319
- startingDate?: Date | null | undefined;
320
331
  additionalTag?: string | undefined;
321
332
  winnerId?: string | import("mongoose").Types.ObjectId | null | undefined;
333
+ startingDate?: Date | null | undefined;
322
334
  prediction?: {
323
335
  score: {
324
336
  team1: number | null;
@@ -350,9 +362,9 @@ export declare const TournamentMatchResponseSchema: z.ZodObject<{
350
362
  };
351
363
  stage: string;
352
364
  endDate?: Date | null | undefined;
353
- startingDate?: Date | null | undefined;
354
365
  additionalTag?: string | undefined;
355
366
  winnerId?: string | import("mongoose").Types.ObjectId | null | undefined;
367
+ startingDate?: Date | null | undefined;
356
368
  prediction?: {
357
369
  score: {
358
370
  team1: number | null;
@@ -383,9 +395,9 @@ export declare const TournamentMatchResponseSchema: z.ZodObject<{
383
395
  };
384
396
  stage: string;
385
397
  endDate?: Date | null | undefined;
386
- startingDate?: Date | null | undefined;
387
398
  additionalTag?: string | undefined;
388
399
  winnerId?: string | import("mongoose").Types.ObjectId | null | undefined;
400
+ startingDate?: Date | null | undefined;
389
401
  prediction?: {
390
402
  score: {
391
403
  team1: number | null;
@@ -409,9 +421,9 @@ export declare const TournamentMatchResponseSchema: z.ZodObject<{
409
421
  };
410
422
  stage: string;
411
423
  endDate?: Date | null | undefined;
412
- startingDate?: Date | null | undefined;
413
424
  additionalTag?: string | undefined;
414
425
  winnerId?: string | import("mongoose").Types.ObjectId | null | undefined;
426
+ startingDate?: Date | null | undefined;
415
427
  prediction?: {
416
428
  score: {
417
429
  team1: number | null;
@@ -439,9 +451,9 @@ export declare const TournamentMatchResponseSchema: z.ZodObject<{
439
451
  };
440
452
  stage: string;
441
453
  endDate?: Date | null | undefined;
442
- startingDate?: Date | null | undefined;
443
454
  additionalTag?: string | undefined;
444
455
  winnerId?: string | import("mongoose").Types.ObjectId | null | undefined;
456
+ startingDate?: Date | null | undefined;
445
457
  prediction?: {
446
458
  score: {
447
459
  team1: number | null;
@@ -466,9 +478,9 @@ export declare const TournamentMatchResponseSchema: z.ZodObject<{
466
478
  };
467
479
  stage: string;
468
480
  endDate?: Date | null | undefined;
469
- startingDate?: Date | null | undefined;
470
481
  additionalTag?: string | undefined;
471
482
  winnerId?: string | import("mongoose").Types.ObjectId | null | undefined;
483
+ startingDate?: Date | null | undefined;
472
484
  prediction?: {
473
485
  score: {
474
486
  team1: number | null;
@@ -503,9 +515,9 @@ export declare const TournamentMatchResponseSchema: z.ZodObject<{
503
515
  };
504
516
  stage: string;
505
517
  endDate?: Date | null | undefined;
506
- startingDate?: Date | null | undefined;
507
518
  additionalTag?: string | undefined;
508
519
  winnerId?: string | import("mongoose").Types.ObjectId | null | undefined;
520
+ startingDate?: Date | null | undefined;
509
521
  prediction?: {
510
522
  score: {
511
523
  team1: number | null;
@@ -530,9 +542,9 @@ export declare const TournamentMatchResponseSchema: z.ZodObject<{
530
542
  };
531
543
  stage: string;
532
544
  endDate?: Date | null | undefined;
533
- startingDate?: Date | null | undefined;
534
545
  additionalTag?: string | undefined;
535
546
  winnerId?: string | import("mongoose").Types.ObjectId | null | undefined;
547
+ startingDate?: Date | null | undefined;
536
548
  prediction?: {
537
549
  score: {
538
550
  team1: number | null;
@@ -585,9 +597,9 @@ export declare const TournamentMatchListResponseSchema: z.ZodObject<{
585
597
  };
586
598
  stage: string;
587
599
  endDate?: Date | null | undefined;
588
- startingDate?: Date | null | undefined;
589
600
  additionalTag?: string | undefined;
590
601
  winnerId?: string | import("mongoose").Types.ObjectId | null | undefined;
602
+ startingDate?: Date | null | undefined;
591
603
  prediction?: {
592
604
  score: {
593
605
  team1: number | null;
@@ -611,9 +623,9 @@ export declare const TournamentMatchListResponseSchema: z.ZodObject<{
611
623
  };
612
624
  stage: string;
613
625
  endDate?: Date | null | undefined;
614
- startingDate?: Date | null | undefined;
615
626
  additionalTag?: string | undefined;
616
627
  winnerId?: string | import("mongoose").Types.ObjectId | null | undefined;
628
+ startingDate?: Date | null | undefined;
617
629
  prediction?: {
618
630
  score: {
619
631
  team1: number | null;
@@ -639,9 +651,9 @@ export declare const TournamentMatchListResponseSchema: z.ZodObject<{
639
651
  };
640
652
  stage: string;
641
653
  endDate?: Date | null | undefined;
642
- startingDate?: Date | null | undefined;
643
654
  additionalTag?: string | undefined;
644
655
  winnerId?: string | import("mongoose").Types.ObjectId | null | undefined;
656
+ startingDate?: Date | null | undefined;
645
657
  prediction?: {
646
658
  score: {
647
659
  team1: number | null;
@@ -673,9 +685,9 @@ export declare const TournamentMatchListResponseSchema: z.ZodObject<{
673
685
  };
674
686
  stage: string;
675
687
  endDate?: Date | null | undefined;
676
- startingDate?: Date | null | undefined;
677
688
  additionalTag?: string | undefined;
678
689
  winnerId?: string | import("mongoose").Types.ObjectId | null | undefined;
690
+ startingDate?: Date | null | undefined;
679
691
  prediction?: {
680
692
  score: {
681
693
  team1: number | null;
@@ -706,9 +718,9 @@ export declare const TournamentMatchListResponseSchema: z.ZodObject<{
706
718
  };
707
719
  stage: string;
708
720
  endDate?: Date | null | undefined;
709
- startingDate?: Date | null | undefined;
710
721
  additionalTag?: string | undefined;
711
722
  winnerId?: string | import("mongoose").Types.ObjectId | null | undefined;
723
+ startingDate?: Date | null | undefined;
712
724
  prediction?: {
713
725
  score: {
714
726
  team1: number | null;
@@ -732,9 +744,9 @@ export declare const TournamentMatchListResponseSchema: z.ZodObject<{
732
744
  };
733
745
  stage: string;
734
746
  endDate?: Date | null | undefined;
735
- startingDate?: Date | null | undefined;
736
747
  additionalTag?: string | undefined;
737
748
  winnerId?: string | import("mongoose").Types.ObjectId | null | undefined;
749
+ startingDate?: Date | null | undefined;
738
750
  prediction?: {
739
751
  score: {
740
752
  team1: number | null;
@@ -762,9 +774,9 @@ export declare const TournamentMatchListResponseSchema: z.ZodObject<{
762
774
  };
763
775
  stage: string;
764
776
  endDate?: Date | null | undefined;
765
- startingDate?: Date | null | undefined;
766
777
  additionalTag?: string | undefined;
767
778
  winnerId?: string | import("mongoose").Types.ObjectId | null | undefined;
779
+ startingDate?: Date | null | undefined;
768
780
  prediction?: {
769
781
  score: {
770
782
  team1: number | null;
@@ -789,9 +801,9 @@ export declare const TournamentMatchListResponseSchema: z.ZodObject<{
789
801
  };
790
802
  stage: string;
791
803
  endDate?: Date | null | undefined;
792
- startingDate?: Date | null | undefined;
793
804
  additionalTag?: string | undefined;
794
805
  winnerId?: string | import("mongoose").Types.ObjectId | null | undefined;
806
+ startingDate?: Date | null | undefined;
795
807
  prediction?: {
796
808
  score: {
797
809
  team1: number | null;
@@ -826,9 +838,9 @@ export declare const TournamentMatchListResponseSchema: z.ZodObject<{
826
838
  };
827
839
  stage: string;
828
840
  endDate?: Date | null | undefined;
829
- startingDate?: Date | null | undefined;
830
841
  additionalTag?: string | undefined;
831
842
  winnerId?: string | import("mongoose").Types.ObjectId | null | undefined;
843
+ startingDate?: Date | null | undefined;
832
844
  prediction?: {
833
845
  score: {
834
846
  team1: number | null;
@@ -853,9 +865,9 @@ export declare const TournamentMatchListResponseSchema: z.ZodObject<{
853
865
  };
854
866
  stage: string;
855
867
  endDate?: Date | null | undefined;
856
- startingDate?: Date | null | undefined;
857
868
  additionalTag?: string | undefined;
858
869
  winnerId?: string | import("mongoose").Types.ObjectId | null | undefined;
870
+ startingDate?: Date | null | undefined;
859
871
  prediction?: {
860
872
  score: {
861
873
  team1: number | null;
@@ -1 +1 @@
1
- {"version":3,"file":"match.validation.d.ts","sourceRoot":"/","sources":["modules/tournament/match/match.validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,GAAG,EAAiB,MAAM,2DAA2D,CAAC;AAoC/F,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGrC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;EAErC,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;EAMjC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;EAGrC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;EAKnC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWhC,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAuD,CAAC;AAEtG,MAAM,MAAM,4BAA4B,GAAG,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAClF,MAAM,MAAM,4BAA4B,GAAG,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAClF,MAAM,MAAM,wBAAwB,GAAG,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAC1E,MAAM,MAAM,0BAA0B,GAAG,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC9E,MAAM,MAAM,wBAAwB,GAAG,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
@@ -54,8 +54,10 @@ exports.StartTournamentMatchSchema = zod_1.z.object({
54
54
  exports.EndTournamentMatchSchema = zod_1.z.object({
55
55
  tournamentId: global_validation_1.ZodValidation.objectId('Tournament id'),
56
56
  matchId: global_validation_1.ZodValidation.objectId('Match id'),
57
- endDate: global_validation_1.ZodValidation.date('End date').optional(),
58
- winnerId: global_validation_1.ZodValidation.objectId('Winner id').optional(),
57
+ finalScore: zod_1.z.object({
58
+ team1: global_validation_1.ZodValidation.number('Team 1 score', { min: 0, isInt: true }),
59
+ team2: global_validation_1.ZodValidation.number('Team 2 score', { min: 0, isInt: true }),
60
+ }).optional(),
59
61
  });
60
62
  exports.TournamentMatchSchema = zod_1.z.object({
61
63
  _id: global_validation_1.ZodValidation.objectId(),
@@ -1 +1 @@
1
- {"version":3,"file":"match.validation.js","sourceRoot":"/","sources":["modules/tournament/match/match.validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,iGAA+F;AAC/F,wEAA+E;AAE/E,MAAM,g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AAA,iCAAiC,GAAG,IAAA,iCAAoB,EAAC,OAAC,CAAC,KAAK,CAAC,6BAAqB,CAAC,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { DTO, ZodValidation } from '@lyxa.ai/core/dist/utilities/validation/global-validation';\nimport { createResponseSchema } from '@lyxa.ai/core/dist/utilities/validation';\n\nconst MatchScoreSchema = z.object({\n\tteam1: ZodValidation.number('Team 1 score').nullable(),\n\tteam2: ZodValidation.number('Team 2 score').nullable(),\n});\n\nconst MatchTeamSchema = z.object({\n\tteamId: ZodValidation.objectId('Team id'),\n\tname: ZodValidation.string('Team name'),\n});\n\nconst MatchPredictionSchema = z.object({\n\tscore: MatchScoreSchema,\n\tsucceeded: z.boolean().nullable().optional(),\n});\n\nconst MatchInputSchema = z\n\t.object({\n\t\tstage: ZodValidation.string('Stage'),\n\t\tteam1Id: ZodValidation.objectId('Team 1 id'),\n\t\tteam2Id: ZodValidation.objectId('Team 2 id'),\n\t\tstartingDate: ZodValidation.date('Starting date'),\n\t\tendDate: ZodValidation.date('End date').optional(),\n\t\tadditionalTag: ZodValidation.string('Additional tag').optional(),\n\t})\n\t.superRefine((d, ctx) => {\n\t\tif (d.team1Id.toString() === d.team2Id.toString()) {\n\t\t\tctx.addIssue({ code: z.ZodIssueCode.custom, message: 'Teams must be different', path: ['team2Id'] });\n\t\t}\n\t\tif (d.endDate && d.endDate <= d.startingDate) {\n\t\t\tctx.addIssue({ code: z.ZodIssueCode.custom, message: 'End date must be after start date', path: ['endDate'] });\n\t\t}\n\t});\n\nexport const AddTournamentMatchesSchema = z.object({\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n\tmatches: z.array(MatchInputSchema).min(1, 'At least one match is required'),\n});\n\nexport const GetTournamentMatchesSchema = z.object({\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n});\n\nexport const UpdateMatchScoreSchema = z.object({\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n\tmatchId: ZodValidation.objectId('Match id'),\n\tteam1Score: ZodValidation.number('Team 1 score', { min: 0, isInt: true }),\n\tteam2Score: ZodValidation.number('Team 2 score', { min: 0, isInt: true }),\n\twinnerId: ZodValidation.objectId('Winner id').optional(),\n});\n\nexport const StartTournamentMatchSchema = z.object({\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n\tmatchId: ZodValidation.objectId('Match id'),\n});\n\nexport const EndTournamentMatchSchema = z.object({\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n\tmatchId: ZodValidation.objectId('Match id'),\n\tendDate: ZodValidation.date('End date').optional(),\n\twinnerId: ZodValidation.objectId('Winner id').optional(),\n});\n\nexport const TournamentMatchSchema = z.object({\n\t_id: ZodValidation.objectId(),\n\tadditionalTag: ZodValidation.string('Additional tag').optional(),\n\tstage: ZodValidation.string('Stage'),\n\tteam1: MatchTeamSchema,\n\tteam2: MatchTeamSchema,\n\tscore: MatchScoreSchema,\n\tprediction: MatchPredictionSchema.optional().nullable(),\n\twinnerId: ZodValidation.objectId('Winner id').nullable().optional(),\n\tstartingDate: z.date().nullable().optional(),\n\tendDate: z.date().nullable().optional(),\n});\n\nexport const TournamentMatchResponseSchema = createResponseSchema(TournamentMatchSchema);\nexport const TournamentMatchListResponseSchema = createResponseSchema(z.array(TournamentMatchSchema));\n\nexport type AddTournamentMatchesInputDTO = DTO<typeof AddTournamentMatchesSchema>;\nexport type StartTournamentMatchInputDTO = DTO<typeof StartTournamentMatchSchema>;\nexport type UpdateMatchScoreInputDTO = DTO<typeof UpdateMatchScoreSchema>;\nexport type EndTournamentMatchInputDTO = DTO<typeof EndTournamentMatchSchema>;\nexport type TournamentMatchOutputDTO = DTO<typeof TournamentMatchSchema>;\n"]}
1
+ {"version":3,"file":"match.validation.js","sourceRoot":"/","sources":["modules/tournament/match/match.validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,iGAA+F;AAC/F,wEAA+E;AAE/E,MAAM,gBAAgB,GAAG,OAAC,CAAC,MAAM,CAAC;IACjC,KAAK,EAAE,i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;CACvC,CAAC,CAAC;AAEU,QAAA,6BAA6B,GAAG,IAAA,iCAAoB,EAAC,6BAAqB,CAAC,CAAC;AAC5E,QAAA,iCAAiC,GAAG,IAAA,iCAAoB,EAAC,OAAC,CAAC,KAAK,CAAC,6BAAqB,CAAC,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { DTO, ZodValidation } from '@lyxa.ai/core/dist/utilities/validation/global-validation';\nimport { createResponseSchema } from '@lyxa.ai/core/dist/utilities/validation';\n\nconst MatchScoreSchema = z.object({\n\tteam1: ZodValidation.number('Team 1 score').nullable(),\n\tteam2: ZodValidation.number('Team 2 score').nullable(),\n});\n\nconst MatchTeamSchema = z.object({\n\tteamId: ZodValidation.objectId('Team id'),\n\tname: ZodValidation.string('Team name'),\n});\n\nconst MatchPredictionSchema = z.object({\n\tscore: MatchScoreSchema,\n\tsucceeded: z.boolean().nullable().optional(),\n});\n\nconst MatchInputSchema = z\n\t.object({\n\t\tstage: ZodValidation.string('Stage'),\n\t\tteam1Id: ZodValidation.objectId('Team 1 id'),\n\t\tteam2Id: ZodValidation.objectId('Team 2 id'),\n\t\tstartingDate: ZodValidation.date('Starting date'),\n\t\tendDate: ZodValidation.date('End date').optional(),\n\t\tadditionalTag: ZodValidation.string('Additional tag').optional(),\n\t})\n\t.superRefine((d, ctx) => {\n\t\tif (d.team1Id.toString() === d.team2Id.toString()) {\n\t\t\tctx.addIssue({ code: z.ZodIssueCode.custom, message: 'Teams must be different', path: ['team2Id'] });\n\t\t}\n\t\tif (d.endDate && d.endDate <= d.startingDate) {\n\t\t\tctx.addIssue({ code: z.ZodIssueCode.custom, message: 'End date must be after start date', path: ['endDate'] });\n\t\t}\n\t});\n\nexport const AddTournamentMatchesSchema = z.object({\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n\tmatches: z.array(MatchInputSchema).min(1, 'At least one match is required'),\n});\n\nexport const GetTournamentMatchesSchema = z.object({\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n});\n\nexport const UpdateMatchScoreSchema = z.object({\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n\tmatchId: ZodValidation.objectId('Match id'),\n\tteam1Score: ZodValidation.number('Team 1 score', { min: 0, isInt: true }),\n\tteam2Score: ZodValidation.number('Team 2 score', { min: 0, isInt: true }),\n\twinnerId: ZodValidation.objectId('Winner id').optional(),\n});\n\nexport const StartTournamentMatchSchema = z.object({\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n\tmatchId: ZodValidation.objectId('Match id'),\n});\n\nexport const EndTournamentMatchSchema = z.object({\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n\tmatchId: ZodValidation.objectId('Match id'),\n\tfinalScore: z.object({\n\t\tteam1: ZodValidation.number('Team 1 score', {min: 0, isInt: true}),\n\t\tteam2: ZodValidation.number('Team 2 score', {min: 0, isInt: true}),\n\t}).optional(),\n});\n\nexport const TournamentMatchSchema = z.object({\n\t_id: ZodValidation.objectId(),\n\tadditionalTag: ZodValidation.string('Additional tag').optional(),\n\tstage: ZodValidation.string('Stage'),\n\tteam1: MatchTeamSchema,\n\tteam2: MatchTeamSchema,\n\tscore: MatchScoreSchema,\n\tprediction: MatchPredictionSchema.optional().nullable(),\n\twinnerId: ZodValidation.objectId('Winner id').nullable().optional(),\n\tstartingDate: z.date().nullable().optional(),\n\tendDate: z.date().nullable().optional(),\n});\n\nexport const TournamentMatchResponseSchema = createResponseSchema(TournamentMatchSchema);\nexport const TournamentMatchListResponseSchema = createResponseSchema(z.array(TournamentMatchSchema));\n\nexport type AddTournamentMatchesInputDTO = DTO<typeof AddTournamentMatchesSchema>;\nexport type StartTournamentMatchInputDTO = DTO<typeof StartTournamentMatchSchema>;\nexport type UpdateMatchScoreInputDTO = DTO<typeof UpdateMatchScoreSchema>;\nexport type EndTournamentMatchInputDTO = DTO<typeof EndTournamentMatchSchema>;\nexport type TournamentMatchOutputDTO = DTO<typeof TournamentMatchSchema>;\n"]}
@@ -5,7 +5,8 @@ export declare class TournamentNotificationService {
5
5
  private hasNotPredicted;
6
6
  private publishNotification;
7
7
  notifyUnpredictedParticipants(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, type: 'before3h' | 'before15min'): Promise<void>;
8
- notifyMatchEnded(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<void>;
8
+ private readonly matchResultTemplates;
9
+ notifyMatchResult(winnerIds: mongoose.Types.ObjectId[], loserIds: mongoose.Types.ObjectId[]): Promise<void>;
9
10
  }
10
11
  export declare const tournamentNotificationService: TournamentNotificationService;
11
12
  //# sourceMappingURL=notification.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notification.service.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAOhD,qBACa,6BAA6B;IACtC,OAAO,CAAC,kBAAkB,CAAqB;;IAM/C,OAAO,CAAC,eAAe;YAIT,mBAAmB;IAqBpB,6BAA6B,CACtC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAChC,IAAI,EAAE,UAAU,GAAG,aAAa,GACjC,OAAO,CAAC,IAAI,CAAC;IAaH,gBAAgB,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAiBxH;AAED,eAAO,MAAM,6BAA6B,+BAA+C,CAAC"}
1
+ {"version":3,"file":"notification.service.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAOhD,qBACa,6BAA6B;IACtC,OAAO,CAAC,kBAAkB,CAAqB;;IAM/C,OAAO,CAAC,eAAe;YAIT,mBAAmB;IAqBpB,6BAA6B,CACtC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAChC,IAAI,EAAE,UAAU,GAAG,aAAa,GACjC,OAAO,CAAC,IAAI,CAAC;IAahB,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CASnC;IAEW,iBAAiB,CAC1B,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,EACpC,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GACpC,OAAO,CAAC,IAAI,CAAC;CAOnB;AAED,eAAO,MAAM,6BAA6B,+BAA+C,CAAC"}
@@ -79,17 +79,22 @@ let TournamentNotificationService = class TournamentNotificationService {
79
79
  : 'Only 15 minutes left to submit your prediction';
80
80
  await Promise.all(unpredicted.map(p => this.publishNotification(p.userId, title, body)));
81
81
  }
82
- async notifyMatchEnded(tournamentId, matchId) {
83
- const participants = await this.participantService.getAll(tournamentId);
84
- await Promise.all(participants.map(p => {
85
- const prediction = p.predictions.find(pred => pred.matchId.toString() === matchId.toString());
86
- const won = prediction?.succeeded === true;
87
- const title = won ? '🎉 Your prediction was correct.' : 'Full-time whistle 🏁';
88
- const body = won
89
- ? 'Your coupon is now available'
90
- : 'Better luck next match. New predictions are now open';
91
- return this.publishNotification(p.userId, title, body);
92
- }));
82
+ matchResultTemplates = {
83
+ winner: {
84
+ title: '🎉 Your prediction was correct.',
85
+ body: 'Your coupon is now available',
86
+ },
87
+ loser: {
88
+ title: 'Full-time whistle 🏁',
89
+ body: 'Better luck next match. New predictions are now open.',
90
+ },
91
+ };
92
+ async notifyMatchResult(winnerIds, loserIds) {
93
+ const { winner, loser } = this.matchResultTemplates;
94
+ await Promise.all([
95
+ ...winnerIds.map(id => this.publishNotification(id, winner.title, winner.body)),
96
+ ...loserIds.map(id => this.publishNotification(id, loser.title, loser.body)),
97
+ ]);
93
98
  }
94
99
  };
95
100
  exports.TournamentNotificationService = TournamentNotificationService;
@@ -1 +1 @@
1
- {"version":3,"file":"notification.service.js","sourceRoot":"/","sources":["modules/tournament/notification/notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,8DAAkE;AAClE,4EAA8E;AAC9E,4DAAuF;AACvF,4EAAwE;AAIjE,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IAC9B,kBAAkB,CAAqB;IAE/C;QACI,IAAI,CAAC,kBAAkB,GAAG,gBAAS,CAAC,GAAG,CAAC,wCAAkB,CAAC,CAAC;IAChE,CAAC;IAEO,eAAe,CAAC,WAA2C,EAAE,OAAgC;QACjG,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC3F,CAAC;IAEO,KAAK,CAAC,mBAAmB,CAC7B,WAAoC,EACpC,KAAa,EACb,IAAY;QAEZ,MAAM,IAAA,oBAAY,EACd,IAAI,gCAAiB,CAAC;YAClB,KAAK;YACL,IAAI;YACJ,IAAI,EAAE;gBACF,gBAAgB,EAAE,IAAI;gBACtB,WAAW,EAAE,8BAAuB,CAAC,IAAI;gBACzC,WAAW;gBACX,QAAQ,EAAE,KAAK;gBACf,WAAW,EAAE,IAAI;gBACjB,SAAS,EAAE,gBAAS,CAAC,kBAAkB;aAC1C;SACJ,CAAC,CACL,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,6BAA6B,CACtC,YAAqC,EACrC,OAAgC,EAChC,IAAgC;QAEhC,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QACxE,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,C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;IADzC,IAAA,gBAAO,GAAE;;GACG,6BAA6B,CAkEzC;AAEY,QAAA,6BAA6B,GAAG,gBAAS,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport { publishEvent } from '@lyxa.ai/core/dist/libraries/event';\nimport { NotificationEvent } from '@lyxa.ai/core/dist/libraries/notification';\nimport { ClickType, NotificationAccountType } from '@lyxa.ai/core/dist/utilities/enum';\nimport { ParticipantService } from '../participant/participant.service';\nimport { TournamentParticipantOutputDTO } from '../participant/participant.validation';\n\n@Service()\nexport class TournamentNotificationService {\n private participantService: ParticipantService;\n\n constructor() {\n this.participantService = Container.get(ParticipantService);\n }\n\n private hasNotPredicted(participant: TournamentParticipantOutputDTO, matchId: mongoose.Types.ObjectId): boolean {\n return !participant.predictions.some(p => p.matchId.toString() === matchId.toString());\n }\n\n private async publishNotification(\n recipientId: mongoose.Types.ObjectId,\n title: string,\n body: string\n ): Promise<void> {\n await publishEvent(\n new NotificationEvent({\n title,\n body,\n data: {\n saveNotification: true,\n accountType: NotificationAccountType.USER,\n recipientId,\n isGlobal: false,\n isClickable: true,\n clickType: ClickType.CLICKABLE_FALLBACK,\n },\n })\n );\n }\n\n public async notifyUnpredictedParticipants(\n tournamentId: mongoose.Types.ObjectId,\n matchId: mongoose.Types.ObjectId,\n type: 'before3h' | 'before15min'\n ): Promise<void> {\n const participants = await this.participantService.getAll(tournamentId);\n const unpredicted = participants.filter(p => this.hasNotPredicted(p, matchId));\n\n const title = type === 'before3h' ? \"⏰ Don't miss today's match!\" : '🚨 Final call!';\n const body =\n type === 'before3h'\n ? 'You still have time to predict the exact score and win'\n : 'Only 15 minutes left to submit your prediction';\n\n await Promise.all(unpredicted.map(p => this.publishNotification(p.userId, title, body)));\n }\n\n public async notifyMatchEnded(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<void> {\n const participants = await this.participantService.getAll(tournamentId);\n\n await Promise.all(\n participants.map(p => {\n const prediction = p.predictions.find(pred => pred.matchId.toString() === matchId.toString());\n const won = prediction?.succeeded === true;\n\n const title = won ? '🎉 Your prediction was correct.' : 'Full-time whistle 🏁';\n const body = won\n ? 'Your coupon is now available'\n : 'Better luck next match. New predictions are now open';\n\n return this.publishNotification(p.userId, title, body);\n })\n );\n }\n}\n\nexport const tournamentNotificationService = Container.get(TournamentNotificationService);\n"]}
1
+ {"version":3,"file":"notification.service.js","sourceRoot":"/","sources":["modules/tournament/notification/notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,8DAAkE;AAClE,4EAA8E;AAC9E,4DAAuF;AACvF,4EAAwE;AAIjE,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IAC9B,kBAAkB,CAAqB;IAE/C;QACI,IAAI,CAAC,kBAAkB,GAAG,gBAAS,CAAC,GAAG,CAAC,wCAAkB,CAAC,CAAC;IAChE,CAAC;IAEO,eAAe,CAAC,WAA2C,EAAE,OAAgC;QACjG,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC3F,CAAC;IAEO,KAAK,CAAC,mBAAmB,CAC7B,WAAoC,EACpC,KAAa,EACb,IAAY;QAEZ,MAAM,IAAA,oBAAY,EACd,IAAI,gCAAiB,CAAC;YAClB,KAAK;YACL,IAAI;YACJ,IAAI,EAAE;gBACF,gBAAgB,EAAE,IAAI;gBACtB,WAAW,EAAE,8BAAuB,CAAC,IAAI;gBACzC,WAAW;gBACX,QAAQ,EAAE,KAAK;gBACf,WAAW,EAAE,IAAI;gBACjB,SAAS,EAAE,gBAAS,CAAC,kBAAkB;aAC1C;SACJ,CAAC,CACL,CAAC;IACN,CAAC;IAEM,KAAK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CAAC,IAAI,CAAC,mBAAmB,CAAC,EAAE,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;SAC/E,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AAtEY,sEAA6B;wCAA7B,6BAA6B;IADzC,IAAA,gBAAO,GAAE;;GACG,6BAA6B,CAsEzC;AAEY,QAAA,6BAA6B,GAAG,gBAAS,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport { publishEvent } from '@lyxa.ai/core/dist/libraries/event';\nimport { NotificationEvent } from '@lyxa.ai/core/dist/libraries/notification';\nimport { ClickType, NotificationAccountType } from '@lyxa.ai/core/dist/utilities/enum';\nimport { ParticipantService } from '../participant/participant.service';\nimport { TournamentParticipantOutputDTO } from '../participant/participant.validation';\n\n@Service()\nexport class TournamentNotificationService {\n private participantService: ParticipantService;\n\n constructor() {\n this.participantService = Container.get(ParticipantService);\n }\n\n private hasNotPredicted(participant: TournamentParticipantOutputDTO, matchId: mongoose.Types.ObjectId): boolean {\n return !participant.predictions.some(p => p.matchId.toString() === matchId.toString());\n }\n\n private async publishNotification(\n recipientId: mongoose.Types.ObjectId,\n title: string,\n body: string\n ): Promise<void> {\n await publishEvent(\n new NotificationEvent({\n title,\n body,\n data: {\n saveNotification: true,\n accountType: NotificationAccountType.USER,\n recipientId,\n isGlobal: false,\n isClickable: true,\n clickType: ClickType.CLICKABLE_FALLBACK,\n },\n })\n );\n }\n\n public async notifyUnpredictedParticipants(\n tournamentId: mongoose.Types.ObjectId,\n matchId: mongoose.Types.ObjectId,\n type: 'before3h' | 'before15min'\n ): Promise<void> {\n const participants = await this.participantService.getAll(tournamentId);\n const unpredicted = participants.filter(p => this.hasNotPredicted(p, matchId));\n\n const title = type === 'before3h' ? \"⏰ Don't miss today's match!\" : '🚨 Final call!';\n const body =\n type === 'before3h'\n ? 'You still have time to predict the exact score and win'\n : 'Only 15 minutes left to submit your prediction';\n\n await Promise.all(unpredicted.map(p => this.publishNotification(p.userId, title, body)));\n }\n\n private readonly matchResultTemplates: Record<'winner' | 'loser', {title: string; body: string}> = {\n winner: {\n title: '🎉 Your prediction was correct.',\n body: 'Your coupon is now available',\n },\n loser: {\n title: 'Full-time whistle 🏁',\n body: 'Better luck next match. New predictions are now open.',\n },\n };\n\n public async notifyMatchResult(\n winnerIds: mongoose.Types.ObjectId[],\n loserIds: mongoose.Types.ObjectId[]\n ): Promise<void> {\n const {winner, loser} = this.matchResultTemplates;\n await Promise.all([\n ...winnerIds.map(id => this.publishNotification(id, winner.title, winner.body)),\n ...loserIds.map(id => this.publishNotification(id, loser.title, loser.body)),\n ]);\n }\n}\n\nexport const tournamentNotificationService = Container.get(TournamentNotificationService);\n"]}
@@ -17,22 +17,22 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
17
17
  }, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
18
18
  join: import("@trpc/server").TRPCMutationProcedure<{
19
19
  input: {
20
- teamId: string | mongoose.Types.ObjectId;
21
20
  tournamentId: string | mongoose.Types.ObjectId;
21
+ teamId: string | mongoose.Types.ObjectId;
22
22
  };
23
23
  output: {
24
24
  message: string;
25
25
  success: boolean;
26
26
  data?: {
27
27
  _id: string | mongoose.Types.ObjectId;
28
- teamId: string | mongoose.Types.ObjectId;
29
28
  tournamentId: string | mongoose.Types.ObjectId;
29
+ teamId: string | mongoose.Types.ObjectId;
30
30
  createdAt?: Date | null | undefined;
31
31
  } | {
32
32
  documents: {
33
33
  _id: string | mongoose.Types.ObjectId;
34
- teamId: string | mongoose.Types.ObjectId;
35
34
  tournamentId: string | mongoose.Types.ObjectId;
35
+ teamId: string | mongoose.Types.ObjectId;
36
36
  createdAt?: Date | null | undefined;
37
37
  }[];
38
38
  metadata?: {
@@ -55,39 +55,39 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
55
55
  data?: {
56
56
  _id: string | mongoose.Types.ObjectId;
57
57
  userId: string | mongoose.Types.ObjectId;
58
- teamId: string | mongoose.Types.ObjectId;
59
58
  tournamentId: string | mongoose.Types.ObjectId;
59
+ teamId: string | mongoose.Types.ObjectId;
60
60
  createdAt?: Date | null | undefined;
61
61
  updatedAt?: Date | null | undefined;
62
62
  predictions?: {
63
63
  _id: string | mongoose.Types.ObjectId;
64
+ matchId: string | mongoose.Types.ObjectId;
64
65
  score: {
65
66
  team1: number | null;
66
67
  team2: number | null;
67
68
  };
68
- matchId: string | mongoose.Types.ObjectId;
69
69
  coupon?: string | mongoose.Types.ObjectId | undefined;
70
- succeeded?: boolean | null | undefined;
71
70
  predictionTime?: Date | null | undefined;
71
+ succeeded?: boolean | null | undefined;
72
72
  }[] | undefined;
73
73
  }[] | {
74
74
  documents: {
75
75
  _id: string | mongoose.Types.ObjectId;
76
76
  userId: string | mongoose.Types.ObjectId;
77
- teamId: string | mongoose.Types.ObjectId;
78
77
  tournamentId: string | mongoose.Types.ObjectId;
78
+ teamId: string | mongoose.Types.ObjectId;
79
79
  createdAt?: Date | null | undefined;
80
80
  updatedAt?: Date | null | undefined;
81
81
  predictions?: {
82
82
  _id: string | mongoose.Types.ObjectId;
83
+ matchId: string | mongoose.Types.ObjectId;
83
84
  score: {
84
85
  team1: number | null;
85
86
  team2: number | null;
86
87
  };
87
- matchId: string | mongoose.Types.ObjectId;
88
88
  coupon?: string | mongoose.Types.ObjectId | undefined;
89
- succeeded?: boolean | null | undefined;
90
89
  predictionTime?: Date | null | undefined;
90
+ succeeded?: boolean | null | undefined;
91
91
  }[] | undefined;
92
92
  }[][];
93
93
  metadata?: {