@lyxa.ai/marketing 1.0.49 → 1.0.51

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 (241) hide show
  1. package/dist/lib/index.d.ts +265 -21
  2. package/dist/lib/index.d.ts.map +1 -1
  3. package/dist/lib/modules/tournament/config/config.repository.d.ts +3 -0
  4. package/dist/lib/modules/tournament/config/config.repository.d.ts.map +1 -1
  5. package/dist/lib/modules/tournament/config/config.repository.js +3 -0
  6. package/dist/lib/modules/tournament/config/config.repository.js.map +1 -1
  7. package/dist/lib/modules/tournament/config/config.router.d.ts +10 -10
  8. package/dist/lib/modules/tournament/config/config.validation.d.ts +37 -36
  9. package/dist/lib/modules/tournament/config/config.validation.d.ts.map +1 -1
  10. package/dist/lib/modules/tournament/config/config.validation.js +4 -3
  11. package/dist/lib/modules/tournament/config/config.validation.js.map +1 -1
  12. package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.d.ts.map +1 -1
  13. package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js +9 -1
  14. package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js.map +1 -1
  15. package/dist/lib/modules/tournament/match/match.builder.d.ts.map +1 -1
  16. package/dist/lib/modules/tournament/match/match.builder.js +2 -1
  17. package/dist/lib/modules/tournament/match/match.builder.js.map +1 -1
  18. package/dist/lib/modules/tournament/match/match.repository.d.ts +2 -0
  19. package/dist/lib/modules/tournament/match/match.repository.d.ts.map +1 -1
  20. package/dist/lib/modules/tournament/match/match.repository.js +10 -0
  21. package/dist/lib/modules/tournament/match/match.repository.js.map +1 -1
  22. package/dist/lib/modules/tournament/match/match.router.d.ts +16 -4
  23. package/dist/lib/modules/tournament/match/match.router.d.ts.map +1 -1
  24. package/dist/lib/modules/tournament/match/match.service.d.ts +0 -1
  25. package/dist/lib/modules/tournament/match/match.service.d.ts.map +1 -1
  26. package/dist/lib/modules/tournament/match/match.service.js +3 -9
  27. package/dist/lib/modules/tournament/match/match.service.js.map +1 -1
  28. package/dist/lib/modules/tournament/match/match.validation.d.ts +50 -0
  29. package/dist/lib/modules/tournament/match/match.validation.d.ts.map +1 -1
  30. package/dist/lib/modules/tournament/match/match.validation.js +1 -0
  31. package/dist/lib/modules/tournament/match/match.validation.js.map +1 -1
  32. package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts +2 -5
  33. package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts.map +1 -1
  34. package/dist/lib/modules/tournament/notification/jobs/notification.producer.js +1 -6
  35. package/dist/lib/modules/tournament/notification/jobs/notification.producer.js.map +1 -1
  36. package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts +2 -0
  37. package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts.map +1 -1
  38. package/dist/lib/modules/tournament/notification/jobs/notification.worker.js +15 -9
  39. package/dist/lib/modules/tournament/notification/jobs/notification.worker.js.map +1 -1
  40. package/dist/lib/modules/tournament/notification/notification-template.repository.d.ts +8 -0
  41. package/dist/lib/modules/tournament/notification/notification-template.repository.d.ts.map +1 -0
  42. package/dist/lib/modules/tournament/notification/notification-template.repository.js +60 -0
  43. package/dist/lib/modules/tournament/notification/notification-template.repository.js.map +1 -0
  44. package/dist/lib/modules/tournament/notification/notification.config.d.ts +10 -0
  45. package/dist/lib/modules/tournament/notification/notification.config.d.ts.map +1 -0
  46. package/dist/lib/modules/tournament/notification/notification.config.js +15 -0
  47. package/dist/lib/modules/tournament/notification/notification.config.js.map +1 -0
  48. package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts +10 -0
  49. package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts.map +1 -0
  50. package/dist/lib/modules/tournament/notification/notification.schedule.config.js +15 -0
  51. package/dist/lib/modules/tournament/notification/notification.schedule.config.js.map +1 -0
  52. package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts +4 -4
  53. package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts.map +1 -1
  54. package/dist/lib/modules/tournament/notification/notification.scheduler.service.js +15 -28
  55. package/dist/lib/modules/tournament/notification/notification.scheduler.service.js.map +1 -1
  56. package/dist/lib/modules/tournament/notification/notification.service.d.ts +5 -4
  57. package/dist/lib/modules/tournament/notification/notification.service.d.ts.map +1 -1
  58. package/dist/lib/modules/tournament/notification/notification.service.js +33 -28
  59. package/dist/lib/modules/tournament/notification/notification.service.js.map +1 -1
  60. package/dist/lib/modules/tournament/participant/participant.repository.d.ts +3 -0
  61. package/dist/lib/modules/tournament/participant/participant.repository.d.ts.map +1 -1
  62. package/dist/lib/modules/tournament/participant/participant.repository.js +14 -0
  63. package/dist/lib/modules/tournament/participant/participant.repository.js.map +1 -1
  64. package/dist/lib/modules/tournament/participant/participant.router.d.ts +27 -4
  65. package/dist/lib/modules/tournament/participant/participant.router.d.ts.map +1 -1
  66. package/dist/lib/modules/tournament/participant/participant.router.js +7 -0
  67. package/dist/lib/modules/tournament/participant/participant.router.js.map +1 -1
  68. package/dist/lib/modules/tournament/participant/participant.service.d.ts +2 -2
  69. package/dist/lib/modules/tournament/participant/participant.service.d.ts.map +1 -1
  70. package/dist/lib/modules/tournament/participant/participant.service.js +20 -6
  71. package/dist/lib/modules/tournament/participant/participant.service.js.map +1 -1
  72. package/dist/lib/modules/tournament/participant/participant.validation.d.ts +144 -36
  73. package/dist/lib/modules/tournament/participant/participant.validation.d.ts.map +1 -1
  74. package/dist/lib/modules/tournament/participant/participant.validation.js +10 -3
  75. package/dist/lib/modules/tournament/participant/participant.validation.js.map +1 -1
  76. package/dist/lib/modules/tournament/prediction/prediction.builder.d.ts.map +1 -1
  77. package/dist/lib/modules/tournament/prediction/prediction.builder.js +3 -2
  78. package/dist/lib/modules/tournament/prediction/prediction.builder.js.map +1 -1
  79. package/dist/lib/modules/tournament/prediction/prediction.service.d.ts +1 -0
  80. package/dist/lib/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
  81. package/dist/lib/modules/tournament/prediction/prediction.service.js +12 -1
  82. package/dist/lib/modules/tournament/prediction/prediction.service.js.map +1 -1
  83. package/dist/lib/modules/tournament/reward/reward.builder.d.ts.map +1 -1
  84. package/dist/lib/modules/tournament/reward/reward.builder.js +2 -1
  85. package/dist/lib/modules/tournament/reward/reward.builder.js.map +1 -1
  86. package/dist/lib/modules/tournament/reward/reward.repository.d.ts +8 -0
  87. package/dist/lib/modules/tournament/reward/reward.repository.d.ts.map +1 -0
  88. package/dist/lib/modules/tournament/reward/reward.repository.js +66 -0
  89. package/dist/lib/modules/tournament/reward/reward.repository.js.map +1 -0
  90. package/dist/lib/modules/tournament/schedule/schedule.router.d.ts +27 -0
  91. package/dist/lib/modules/tournament/schedule/schedule.router.d.ts.map +1 -0
  92. package/dist/lib/modules/tournament/schedule/schedule.router.js +17 -0
  93. package/dist/lib/modules/tournament/schedule/schedule.router.js.map +1 -0
  94. package/dist/lib/modules/tournament/schedule/schedule.service.d.ts +10 -0
  95. package/dist/lib/modules/tournament/schedule/schedule.service.d.ts.map +1 -0
  96. package/dist/lib/modules/tournament/schedule/schedule.service.js +87 -0
  97. package/dist/lib/modules/tournament/schedule/schedule.service.js.map +1 -0
  98. package/dist/lib/modules/tournament/score/score.repository.d.ts +8 -1
  99. package/dist/lib/modules/tournament/score/score.repository.d.ts.map +1 -1
  100. package/dist/lib/modules/tournament/score/score.repository.js +12 -2
  101. package/dist/lib/modules/tournament/score/score.repository.js.map +1 -1
  102. package/dist/lib/modules/tournament/score/score.router.d.ts +98 -0
  103. package/dist/lib/modules/tournament/score/score.router.d.ts.map +1 -0
  104. package/dist/lib/modules/tournament/score/score.router.js +20 -0
  105. package/dist/lib/modules/tournament/score/score.router.js.map +1 -0
  106. package/dist/lib/modules/tournament/score/score.service.d.ts +7 -0
  107. package/dist/lib/modules/tournament/score/score.service.d.ts.map +1 -1
  108. package/dist/lib/modules/tournament/score/score.service.js +49 -0
  109. package/dist/lib/modules/tournament/score/score.service.js.map +1 -1
  110. package/dist/lib/modules/tournament/score/score.validation.d.ts +375 -0
  111. package/dist/lib/modules/tournament/score/score.validation.d.ts.map +1 -0
  112. package/dist/lib/modules/tournament/score/score.validation.js +19 -0
  113. package/dist/lib/modules/tournament/score/score.validation.js.map +1 -0
  114. package/dist/lib/modules/tournament/statistics/statistics.builder.d.ts +10 -0
  115. package/dist/lib/modules/tournament/statistics/statistics.builder.d.ts.map +1 -0
  116. package/dist/lib/modules/tournament/statistics/statistics.builder.js +53 -0
  117. package/dist/lib/modules/tournament/statistics/statistics.builder.js.map +1 -0
  118. package/dist/lib/modules/tournament/statistics/statistics.router.d.ts +80 -0
  119. package/dist/lib/modules/tournament/statistics/statistics.router.d.ts.map +1 -0
  120. package/dist/lib/modules/tournament/statistics/statistics.router.js +21 -0
  121. package/dist/lib/modules/tournament/statistics/statistics.router.js.map +1 -0
  122. package/dist/lib/modules/tournament/statistics/statistics.service.d.ts +11 -0
  123. package/dist/lib/modules/tournament/statistics/statistics.service.d.ts.map +1 -0
  124. package/dist/lib/modules/tournament/statistics/statistics.service.js +80 -0
  125. package/dist/lib/modules/tournament/statistics/statistics.service.js.map +1 -0
  126. package/dist/lib/modules/tournament/statistics/statistics.validation.d.ts +404 -0
  127. package/dist/lib/modules/tournament/statistics/statistics.validation.d.ts.map +1 -0
  128. package/dist/lib/modules/tournament/statistics/statistics.validation.js +36 -0
  129. package/dist/lib/modules/tournament/statistics/statistics.validation.js.map +1 -0
  130. package/dist/lib/modules/tournament/team/team.router.d.ts +9 -3
  131. package/dist/lib/modules/tournament/team/team.router.d.ts.map +1 -1
  132. package/dist/lib/modules/tournament/team/team.service.d.ts +1 -0
  133. package/dist/lib/modules/tournament/team/team.service.d.ts.map +1 -1
  134. package/dist/lib/modules/tournament/team/team.service.js +23 -16
  135. package/dist/lib/modules/tournament/team/team.service.js.map +1 -1
  136. package/dist/lib/modules/tournament/team/team.validation.d.ts +54 -4
  137. package/dist/lib/modules/tournament/team/team.validation.d.ts.map +1 -1
  138. package/dist/lib/modules/tournament/team/team.validation.js +4 -2
  139. package/dist/lib/modules/tournament/team/team.validation.js.map +1 -1
  140. package/dist/lib/modules/tournament/tournament.router.d.ts +370 -125
  141. package/dist/lib/modules/tournament/tournament.router.d.ts.map +1 -1
  142. package/dist/lib/modules/tournament/tournament.router.js +13 -2
  143. package/dist/lib/modules/tournament/tournament.router.js.map +1 -1
  144. package/dist/lib/modules/tournament/tournament.service.d.ts +3 -1
  145. package/dist/lib/modules/tournament/tournament.service.d.ts.map +1 -1
  146. package/dist/lib/modules/tournament/tournament.service.js +17 -2
  147. package/dist/lib/modules/tournament/tournament.service.js.map +1 -1
  148. package/dist/lib/modules/tournament/tournament.types.d.ts +14 -0
  149. package/dist/lib/modules/tournament/tournament.types.d.ts.map +1 -0
  150. package/dist/lib/modules/tournament/tournament.types.js +20 -0
  151. package/dist/lib/modules/tournament/tournament.types.js.map +1 -0
  152. package/dist/lib/modules/tournament/tournament.utils.d.ts +2 -0
  153. package/dist/lib/modules/tournament/tournament.utils.d.ts.map +1 -0
  154. package/dist/lib/modules/tournament/tournament.utils.js +6 -0
  155. package/dist/lib/modules/tournament/tournament.utils.js.map +1 -0
  156. package/dist/lib/modules/tournament/tournament.validation.d.ts +15 -0
  157. package/dist/lib/modules/tournament/tournament.validation.d.ts.map +1 -1
  158. package/dist/lib/modules/tournament/tournament.validation.js +4 -1
  159. package/dist/lib/modules/tournament/tournament.validation.js.map +1 -1
  160. package/dist/types/index.d.ts +265 -21
  161. package/dist/types/index.d.ts.map +1 -1
  162. package/dist/types/modules/tournament/config/config.repository.d.ts +3 -0
  163. package/dist/types/modules/tournament/config/config.repository.d.ts.map +1 -1
  164. package/dist/types/modules/tournament/config/config.router.d.ts +10 -10
  165. package/dist/types/modules/tournament/config/config.validation.d.ts +37 -36
  166. package/dist/types/modules/tournament/config/config.validation.d.ts.map +1 -1
  167. package/dist/types/modules/tournament/match/events/evaluate-predictions.consumer.d.ts.map +1 -1
  168. package/dist/types/modules/tournament/match/match.builder.d.ts.map +1 -1
  169. package/dist/types/modules/tournament/match/match.repository.d.ts +2 -0
  170. package/dist/types/modules/tournament/match/match.repository.d.ts.map +1 -1
  171. package/dist/types/modules/tournament/match/match.router.d.ts +16 -4
  172. package/dist/types/modules/tournament/match/match.router.d.ts.map +1 -1
  173. package/dist/types/modules/tournament/match/match.service.d.ts +0 -1
  174. package/dist/types/modules/tournament/match/match.service.d.ts.map +1 -1
  175. package/dist/types/modules/tournament/match/match.validation.d.ts +50 -0
  176. package/dist/types/modules/tournament/match/match.validation.d.ts.map +1 -1
  177. package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts +2 -5
  178. package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts.map +1 -1
  179. package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts +2 -0
  180. package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts.map +1 -1
  181. package/dist/types/modules/tournament/notification/notification-template.repository.d.ts +8 -0
  182. package/dist/types/modules/tournament/notification/notification-template.repository.d.ts.map +1 -0
  183. package/dist/types/modules/tournament/notification/notification.config.d.ts +10 -0
  184. package/dist/types/modules/tournament/notification/notification.config.d.ts.map +1 -0
  185. package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts +10 -0
  186. package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts.map +1 -0
  187. package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts +4 -4
  188. package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts.map +1 -1
  189. package/dist/types/modules/tournament/notification/notification.service.d.ts +5 -4
  190. package/dist/types/modules/tournament/notification/notification.service.d.ts.map +1 -1
  191. package/dist/types/modules/tournament/participant/participant.repository.d.ts +3 -0
  192. package/dist/types/modules/tournament/participant/participant.repository.d.ts.map +1 -1
  193. package/dist/types/modules/tournament/participant/participant.router.d.ts +27 -4
  194. package/dist/types/modules/tournament/participant/participant.router.d.ts.map +1 -1
  195. package/dist/types/modules/tournament/participant/participant.service.d.ts +2 -2
  196. package/dist/types/modules/tournament/participant/participant.service.d.ts.map +1 -1
  197. package/dist/types/modules/tournament/participant/participant.validation.d.ts +144 -36
  198. package/dist/types/modules/tournament/participant/participant.validation.d.ts.map +1 -1
  199. package/dist/types/modules/tournament/prediction/prediction.builder.d.ts.map +1 -1
  200. package/dist/types/modules/tournament/prediction/prediction.service.d.ts +1 -0
  201. package/dist/types/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
  202. package/dist/types/modules/tournament/reward/reward.builder.d.ts.map +1 -1
  203. package/dist/types/modules/tournament/reward/reward.repository.d.ts +8 -0
  204. package/dist/types/modules/tournament/reward/reward.repository.d.ts.map +1 -0
  205. package/dist/types/modules/tournament/schedule/schedule.router.d.ts +27 -0
  206. package/dist/types/modules/tournament/schedule/schedule.router.d.ts.map +1 -0
  207. package/dist/types/modules/tournament/schedule/schedule.service.d.ts +10 -0
  208. package/dist/types/modules/tournament/schedule/schedule.service.d.ts.map +1 -0
  209. package/dist/types/modules/tournament/score/score.repository.d.ts +8 -1
  210. package/dist/types/modules/tournament/score/score.repository.d.ts.map +1 -1
  211. package/dist/types/modules/tournament/score/score.router.d.ts +98 -0
  212. package/dist/types/modules/tournament/score/score.router.d.ts.map +1 -0
  213. package/dist/types/modules/tournament/score/score.service.d.ts +7 -0
  214. package/dist/types/modules/tournament/score/score.service.d.ts.map +1 -1
  215. package/dist/types/modules/tournament/score/score.validation.d.ts +375 -0
  216. package/dist/types/modules/tournament/score/score.validation.d.ts.map +1 -0
  217. package/dist/types/modules/tournament/statistics/statistics.builder.d.ts +10 -0
  218. package/dist/types/modules/tournament/statistics/statistics.builder.d.ts.map +1 -0
  219. package/dist/types/modules/tournament/statistics/statistics.router.d.ts +80 -0
  220. package/dist/types/modules/tournament/statistics/statistics.router.d.ts.map +1 -0
  221. package/dist/types/modules/tournament/statistics/statistics.service.d.ts +11 -0
  222. package/dist/types/modules/tournament/statistics/statistics.service.d.ts.map +1 -0
  223. package/dist/types/modules/tournament/statistics/statistics.validation.d.ts +404 -0
  224. package/dist/types/modules/tournament/statistics/statistics.validation.d.ts.map +1 -0
  225. package/dist/types/modules/tournament/team/team.router.d.ts +9 -3
  226. package/dist/types/modules/tournament/team/team.router.d.ts.map +1 -1
  227. package/dist/types/modules/tournament/team/team.service.d.ts +1 -0
  228. package/dist/types/modules/tournament/team/team.service.d.ts.map +1 -1
  229. package/dist/types/modules/tournament/team/team.validation.d.ts +54 -4
  230. package/dist/types/modules/tournament/team/team.validation.d.ts.map +1 -1
  231. package/dist/types/modules/tournament/tournament.router.d.ts +370 -125
  232. package/dist/types/modules/tournament/tournament.router.d.ts.map +1 -1
  233. package/dist/types/modules/tournament/tournament.service.d.ts +3 -1
  234. package/dist/types/modules/tournament/tournament.service.d.ts.map +1 -1
  235. package/dist/types/modules/tournament/tournament.types.d.ts +14 -0
  236. package/dist/types/modules/tournament/tournament.types.d.ts.map +1 -0
  237. package/dist/types/modules/tournament/tournament.utils.d.ts +2 -0
  238. package/dist/types/modules/tournament/tournament.utils.d.ts.map +1 -0
  239. package/dist/types/modules/tournament/tournament.validation.d.ts +15 -0
  240. package/dist/types/modules/tournament/tournament.validation.d.ts.map +1 -1
  241. package/package.json +2 -2
@@ -5,6 +5,7 @@ const zod_1 = require("zod");
5
5
  const global_validation_1 = require("@lyxa.ai/core/dist/utilities/validation/global-validation");
6
6
  const validation_1 = require("@lyxa.ai/core/dist/utilities/validation");
7
7
  const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
8
+ const tournament_types_1 = require("../tournament.types");
8
9
  const TournamentFreeDeliveryRewardSchema = zod_1.z.object({
9
10
  type: zod_1.z.literal(enum_1.TournamentRewardType.FREE_DELIVERY),
10
11
  });
@@ -40,7 +41,7 @@ const TournamentRewardListOutputSchema = zod_1.z.discriminatedUnion('type', [
40
41
  exports.CreateTournamentConfigSchema = zod_1.z
41
42
  .object({
42
43
  name: global_validation_1.ZodValidation.string('Tournament name'),
43
- tag: global_validation_1.ZodValidation.string('Tournament tag'),
44
+ tag: global_validation_1.ZodValidation.enumType(tournament_types_1.TournamentTag, 'Tournament tag'),
44
45
  startDate: global_validation_1.ZodValidation.date('Start date'),
45
46
  endDate: global_validation_1.ZodValidation.date('End date'),
46
47
  status: global_validation_1.ZodValidation.enumType(enum_1.Status, 'Status').optional(),
@@ -55,7 +56,7 @@ exports.UpdateTournamentConfigSchema = zod_1.z
55
56
  .object({
56
57
  _id: global_validation_1.ZodValidation.objectId(),
57
58
  name: global_validation_1.ZodValidation.string('Tournament name').optional(),
58
- tag: global_validation_1.ZodValidation.string('Tournament tag').optional(),
59
+ tag: global_validation_1.ZodValidation.enumType(tournament_types_1.TournamentTag, 'Tournament tag').optional(),
59
60
  startDate: global_validation_1.ZodValidation.date('Start date').optional(),
60
61
  endDate: global_validation_1.ZodValidation.date('End date').optional(),
61
62
  status: global_validation_1.ZodValidation.enumType(enum_1.Status, 'Status').optional(),
@@ -69,7 +70,7 @@ exports.UpdateTournamentConfigSchema = zod_1.z
69
70
  exports.TournamentConfigSchema = zod_1.z.object({
70
71
  _id: global_validation_1.ZodValidation.objectId().optional(),
71
72
  name: global_validation_1.ZodValidation.string('Tournament name'),
72
- tag: global_validation_1.ZodValidation.string('Tournament tag'),
73
+ tag: global_validation_1.ZodValidation.enumType(tournament_types_1.TournamentTag, 'Tournament tag').default(tournament_types_1.TournamentTag.FOOTBALL_WORLD_CUP),
73
74
  startDate: zod_1.z.date().nullable().optional(),
74
75
  endDate: zod_1.z.date().nullable().optional(),
75
76
  status: global_validation_1.ZodValidation.enumType(enum_1.Status, 'Status'),
@@ -1 +1 @@
1
- {"version":3,"file":"config.validation.js","sourceRoot":"/","sources":["modules/tournament/config/config.validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,iGAA+F;AAC/F,wEAA+E;AAC/E,4DAAiF;AAEjF,MAAM,kCAAkC,GAAG,OAAC,CAAC,MAAM,CAAC;IACnD,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,2BAAoB,CAAC,aAAa,CAAC;CACnD,CAAC,CAAC;AAEH,MAAM,4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AAQ,EAAE;CACzC,CAAC,CAAC;AAEU,QAAA,8BAA8B,GAAG,8BAAsB,CAAC,MAAM,CAAC;IAC3E,MAAM,EAAE,gCAAgC,CAAC,QAAQ,EAAE;CACnD,CAAC,CAAC;AAEU,QAAA,8BAA8B,GAAG,IAAA,iCAAoB,EAAC,8BAAsB,CAAC,CAAC;AAC9E,QAAA,kCAAkC,GAAG,IAAA,iCAAoB,EAAC,OAAC,CAAC,KAAK,CAAC,sCAA8B,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';\nimport { Status, TournamentRewardType } from '@lyxa.ai/core/dist/utilities/enum';\n\nconst TournamentFreeDeliveryRewardSchema = z.object({\n\ttype: z.literal(TournamentRewardType.FREE_DELIVERY),\n});\n\nconst TournamentCouponRewardSchema = z.object({\n\ttype: z.literal(TournamentRewardType.COUPON),\n\tcouponNamePrefix: ZodValidation.string('Coupon name prefix'),\n\tpercentage: ZodValidation.number('Percentage'),\n\tmaxDiscountPerOrder: ZodValidation.number('Max discount per order').nullable().optional(),\n});\n\nconst TournamentCouponRewardOutputSchema = z.object({\n\ttype: z.literal(TournamentRewardType.COUPON),\n\tcouponNamePrefix: ZodValidation.string('Coupon name prefix').optional(),\n\tpercentage: ZodValidation.number('Percentage').optional(),\n\tmaxDiscountPerOrder: ZodValidation.number('Max discount per order').nullable().optional(),\n});\n\nconst TournamentCouponRewardListOutputSchema = z.object({\n\ttype: z.literal(TournamentRewardType.COUPON),\n\tpercentage: ZodValidation.number('Percentage').optional(),\n\tmaxDiscountPerOrder: ZodValidation.number('Max discount per order').nullable().optional(),\n});\n\nconst TournamentRewardSchema = z.discriminatedUnion('type', [\n\tTournamentCouponRewardSchema,\n\tTournamentFreeDeliveryRewardSchema,\n]);\n\nconst TournamentRewardOutputSchema = z.discriminatedUnion('type', [\n\tTournamentCouponRewardOutputSchema,\n\tTournamentFreeDeliveryRewardSchema,\n]);\n\nconst TournamentRewardListOutputSchema = z.discriminatedUnion('type', [\n\tTournamentCouponRewardListOutputSchema,\n\tTournamentFreeDeliveryRewardSchema,\n]);\n\n\nexport const CreateTournamentConfigSchema = z\n\t.object({\n\t\tname: ZodValidation.string('Tournament name'),\n\t\ttag: ZodValidation.string('Tournament tag'),\n\t\tstartDate: ZodValidation.date('Start date'),\n\t\tendDate: ZodValidation.date('End date'),\n\t\tstatus: ZodValidation.enumType(Status, 'Status').optional(),\n\t\treward: TournamentRewardSchema.optional(),\n\t})\n\t.superRefine((d, ctx) => {\n\t\tif (d.endDate <= d.startDate) {\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 UpdateTournamentConfigSchema = z\n\t.object({\n\t\t_id: ZodValidation.objectId(),\n\t\tname: ZodValidation.string('Tournament name').optional(),\n\t\ttag: ZodValidation.string('Tournament tag').optional(),\n\t\tstartDate: ZodValidation.date('Start date').optional(),\n\t\tendDate: ZodValidation.date('End date').optional(),\n\t\tstatus: ZodValidation.enumType(Status, 'Status').optional(),\n\t\treward: TournamentRewardSchema.optional(),\n\t})\n\t.superRefine((d, ctx) => {\n\t\tif (d.startDate && d.endDate && d.endDate <= d.startDate) {\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 TournamentConfigSchema = z.object({\n\t_id: ZodValidation.objectId().optional(),\n\tname: ZodValidation.string('Tournament name'),\n\ttag: ZodValidation.string('Tournament tag'),\n\tstartDate: z.date().nullable().optional(),\n\tendDate: z.date().nullable().optional(),\n\tstatus: ZodValidation.enumType(Status, 'Status'),\n\treward: TournamentRewardOutputSchema.optional(),\n\tcreatedAt: z.date().nullable().optional(),\n\tupdatedAt: z.date().nullable().optional(),\n});\n\nexport const TournamentConfigListItemSchema = TournamentConfigSchema.extend({\n\treward: TournamentRewardListOutputSchema.optional(),\n});\n\nexport const TournamentConfigResponseSchema = createResponseSchema(TournamentConfigSchema);\nexport const TournamentConfigListResponseSchema = createResponseSchema(z.array(TournamentConfigListItemSchema));\n\nexport type CreateTournamentConfigInputDTO = DTO<typeof CreateTournamentConfigSchema>;\nexport type UpdateTournamentConfigInputDTO = DTO<typeof UpdateTournamentConfigSchema>;\nexport type TournamentConfigOutputDTO = DTO<typeof TournamentConfigSchema>;\nexport type TournamentConfigListItemOutputDTO = DTO<typeof TournamentConfigListItemSchema>;\n"]}
1
+ {"version":3,"file":"config.validation.js","sourceRoot":"/","sources":["modules/tournament/config/config.validation.ts"],"names":[],"mappings":";;;AAAA,6BAAsB;AACtB,iGAA6F;AAC7F,wEAA6E;AAC7E,4DAA+E;AAC/E,0DAAkD;AAElD,MAAM,kCAAkC,GAAG,OAAC,CAAC,MAAM,CAAC;IACnD,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,2BAAoB,CAAC,aAAa,CAAC;CACnD,CAAC,CAAC;AAEH,MAAM,4BAA4B,GAAG,OAAC,CAAC,MAAM,CAAC;IAC7C,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,2BAAoB,CAAC,MAAM,CAAC;IAC5C,gBAAgB,EAAE,iCAAa,CAAC,MAAM,CAAC,oBAAoB,CAAC;IAC5D,UAAU,EAAE,iCAAa,CAAC,MAAM,CAAC,YAAY,CAAC;IAC9C,mBAAmB,EAAE,iCAAa,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CACzF,CAAC,CAAC;AAEH,MAAM,kCAAkC,GAAG,OAAC,CAAC,MAAM,CAAC;IACnD,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,2BAAoB,CAAC,MAAM,CAAC;IAC5C,gBAAgB,EAAE,iCAAa,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,QAAQ,EAAE;IACvE,UAAU,EAAE,iCAAa,CAAC,MAA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;AACF,CAAC,CAAC,CAAC;AAES,QAAA,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC9C,GAAG,EAAE,iCAAa,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACxC,IAAI,EAAE,iCAAa,CAAC,MAAM,CAAC,iBAAiB,CAAC;IAC7C,GAAG,EAAE,iCAAa,CAAC,QAAQ,CAAC,gCAAa,EAAE,gBAAgB,CAAC,CAAC,OAAO,CAAC,gCAAa,CAAC,kBAAkB,CAAC;IACtG,SAAS,EAAE,OAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACzC,OAAO,EAAE,OAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACvC,MAAM,EAAE,iCAAa,CAAC,QAAQ,CAAC,aAAM,EAAE,QAAQ,CAAC;IAChD,MAAM,EAAE,4BAA4B,CAAC,QAAQ,EAAE;IAC/C,SAAS,EAAE,OAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACzC,SAAS,EAAE,OAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CACzC,CAAC,CAAC;AAEU,QAAA,8BAA8B,GAAG,8BAAsB,CAAC,MAAM,CAAC;IAC3E,MAAM,EAAE,gCAAgC,CAAC,QAAQ,EAAE;CACnD,CAAC,CAAC;AAEU,QAAA,8BAA8B,GAAG,IAAA,iCAAoB,EAAC,8BAAsB,CAAC,CAAC;AAC9E,QAAA,kCAAkC,GAAG,IAAA,iCAAoB,EAAC,OAAC,CAAC,KAAK,CAAC,sCAA8B,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';\nimport {Status, TournamentRewardType} from '@lyxa.ai/core/dist/utilities/enum';\nimport {TournamentTag} from '../tournament.types';\n\nconst TournamentFreeDeliveryRewardSchema = z.object({\n\ttype: z.literal(TournamentRewardType.FREE_DELIVERY),\n});\n\nconst TournamentCouponRewardSchema = z.object({\n\ttype: z.literal(TournamentRewardType.COUPON),\n\tcouponNamePrefix: ZodValidation.string('Coupon name prefix'),\n\tpercentage: ZodValidation.number('Percentage'),\n\tmaxDiscountPerOrder: ZodValidation.number('Max discount per order').nullable().optional(),\n});\n\nconst TournamentCouponRewardOutputSchema = z.object({\n\ttype: z.literal(TournamentRewardType.COUPON),\n\tcouponNamePrefix: ZodValidation.string('Coupon name prefix').optional(),\n\tpercentage: ZodValidation.number('Percentage').optional(),\n\tmaxDiscountPerOrder: ZodValidation.number('Max discount per order').nullable().optional(),\n});\n\nconst TournamentCouponRewardListOutputSchema = z.object({\n\ttype: z.literal(TournamentRewardType.COUPON),\n\tpercentage: ZodValidation.number('Percentage').optional(),\n\tmaxDiscountPerOrder: ZodValidation.number('Max discount per order').nullable().optional(),\n});\n\nconst TournamentRewardSchema = z.discriminatedUnion('type', [\n\tTournamentCouponRewardSchema,\n\tTournamentFreeDeliveryRewardSchema,\n]);\n\nconst TournamentRewardOutputSchema = z.discriminatedUnion('type', [\n\tTournamentCouponRewardOutputSchema,\n\tTournamentFreeDeliveryRewardSchema,\n]);\n\nconst TournamentRewardListOutputSchema = z.discriminatedUnion('type', [\n\tTournamentCouponRewardListOutputSchema,\n\tTournamentFreeDeliveryRewardSchema,\n]);\n\n\nexport const CreateTournamentConfigSchema = z\n\t.object({\n\t\tname: ZodValidation.string('Tournament name'),\n\t\ttag: ZodValidation.enumType(TournamentTag, 'Tournament tag'),\n\t\tstartDate: ZodValidation.date('Start date'),\n\t\tendDate: ZodValidation.date('End date'),\n\t\tstatus: ZodValidation.enumType(Status, 'Status').optional(),\n\t\treward: TournamentRewardSchema.optional(),\n\t})\n\t.superRefine((d, ctx) => {\n\t\tif (d.endDate <= d.startDate) {\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 UpdateTournamentConfigSchema = z\n\t.object({\n\t\t_id: ZodValidation.objectId(),\n\t\tname: ZodValidation.string('Tournament name').optional(),\n\t\ttag: ZodValidation.enumType(TournamentTag, 'Tournament tag').optional(),\n\t\tstartDate: ZodValidation.date('Start date').optional(),\n\t\tendDate: ZodValidation.date('End date').optional(),\n\t\tstatus: ZodValidation.enumType(Status, 'Status').optional(),\n\t\treward: TournamentRewardSchema.optional(),\n\t})\n\t.superRefine((d, ctx) => {\n\t\tif (d.startDate && d.endDate && d.endDate <= d.startDate) {\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 TournamentConfigSchema = z.object({\n\t_id: ZodValidation.objectId().optional(),\n\tname: ZodValidation.string('Tournament name'),\n\ttag: ZodValidation.enumType(TournamentTag, 'Tournament tag').default(TournamentTag.FOOTBALL_WORLD_CUP),\n\tstartDate: z.date().nullable().optional(),\n\tendDate: z.date().nullable().optional(),\n\tstatus: ZodValidation.enumType(Status, 'Status'),\n\treward: TournamentRewardOutputSchema.optional(),\n\tcreatedAt: z.date().nullable().optional(),\n\tupdatedAt: z.date().nullable().optional(),\n});\n\nexport const TournamentConfigListItemSchema = TournamentConfigSchema.extend({\n\treward: TournamentRewardListOutputSchema.optional(),\n});\n\nexport const TournamentConfigResponseSchema = createResponseSchema(TournamentConfigSchema);\nexport const TournamentConfigListResponseSchema = createResponseSchema(z.array(TournamentConfigListItemSchema));\n\nexport type CreateTournamentConfigInputDTO = DTO<typeof CreateTournamentConfigSchema>;\nexport type UpdateTournamentConfigInputDTO = DTO<typeof UpdateTournamentConfigSchema>;\nexport type TournamentConfigOutputDTO = DTO<typeof TournamentConfigSchema>;\nexport type TournamentConfigListItemOutputDTO = DTO<typeof TournamentConfigListItemSchema>;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"evaluate-predictions.consumer.d.ts","sourceRoot":"/","sources":["modules/tournament/match/events/evaluate-predictions.consumer.ts"],"names":[],"mappings":"AAQA,wBAAsB,2BAA2B,kBAahD"}
1
+ {"version":3,"file":"evaluate-predictions.consumer.d.ts","sourceRoot":"/","sources":["modules/tournament/match/events/evaluate-predictions.consumer.ts"],"names":[],"mappings":"AAUA,wBAAsB,2BAA2B,kBAoBhD"}
@@ -5,13 +5,21 @@ const evaluate_predictions_event_1 = require("./evaluate-predictions.event");
5
5
  const prediction_service_1 = require("../../prediction/prediction.service");
6
6
  const reward_service_1 = require("../../reward/reward.service");
7
7
  const notification_service_1 = require("../../notification/notification.service");
8
+ const notification_template_repository_1 = require("../../notification/notification-template.repository");
9
+ const notification_config_1 = require("../../notification/notification.config");
8
10
  const reward_builder_1 = require("../../reward/reward.builder");
9
11
  const reward_types_1 = require("../../reward/reward.types");
10
12
  const event_1 = require("@lyxa.ai/core/dist/libraries/event");
11
13
  async function EvaluatePredictionsConsumer() {
12
14
  await (0, event_1.subscribeToEvent)(evaluate_predictions_event_1.TOURNAMENT_EVALUATE_PREDICTIONS_EVENT, async (payload) => {
13
15
  const { winnerIds, loserIds } = await prediction_service_1.predictionService.evaluate(payload.tournamentId, payload.matchId, payload.finalScore);
14
- await notification_service_1.tournamentNotificationService.notifyMatchResult(winnerIds, loserIds);
16
+ const templates = await notification_template_repository_1.notificationTemplateRepository.findTemplates(payload.tournamentId);
17
+ const winner = templates.get(notification_config_1.NotificationTag.MATCH_RESULT_WINNER);
18
+ const loser = templates.get(notification_config_1.NotificationTag.MATCH_RESULT_LOSER);
19
+ await Promise.all([
20
+ winner && winnerIds.length > 0 ? notification_service_1.tournamentNotificationService.notifyUsers(winner.title, winner.body, winnerIds) : Promise.resolve(),
21
+ loser && loserIds.length > 0 ? notification_service_1.tournamentNotificationService.notifyUsers(loser.title, loser.body, loserIds) : Promise.resolve(),
22
+ ]);
15
23
  if (winnerIds.length > 0) {
16
24
  await reward_service_1.rewardService.grant(reward_types_1.RewardType.COUPON, reward_builder_1.RewardBuilder.buildCouponRewardContext(payload.matchId, payload.tournamentId, winnerIds));
17
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"evaluate-predictions.consumer.js","sourceRoot":"/","sources":["modules/tournament/match/events/evaluate-predictions.consumer.ts"],"names":[],"mappings":";;AAQA,kEAaC;AArBD,6EAA+G;AAC/G,4EAAsE;AACtE,gEAA0D;AAC1D,kFAAsF;AACtF,gEAA0D;AAC1D,4DAAqD;AACrD,8DAAoE;AAE7D,KAAK,UAAU,2BAA2B;IAC7C,MAAM,IAAA,wBAAgB,EAAC,kEAAqC,EAAE,KAAK,EAAE,OAAmC,EAAE,EAAE;QACxG,MAAM,EAAC,SAAS,EAAE,QAAQ,EAAC,GAAG,MAAM,sCAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;QAE1H,MAAM,oDAA6B,CAAC,iBAAiB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAE3E,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,MAAM,8BAAa,CAAC,KAAK,CACrB,yBAAU,CAAC,MAAM,EACjB,8BAAa,CAAC,wBAAwB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,EAAE,SAAS,CAAC,CAC3F,CAAC;QACN,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import {EvaluatePredictionsPayload, TOURNAMENT_EVALUATE_PREDICTIONS_EVENT} from './evaluate-predictions.event';\nimport {predictionService} from '../../prediction/prediction.service';\nimport {rewardService} from '../../reward/reward.service';\nimport {tournamentNotificationService} from '../../notification/notification.service';\nimport {RewardBuilder} from '../../reward/reward.builder';\nimport {RewardType} from '../../reward/reward.types';\nimport {subscribeToEvent} from '@lyxa.ai/core/dist/libraries/event';\n\nexport async function EvaluatePredictionsConsumer() {\n await subscribeToEvent(TOURNAMENT_EVALUATE_PREDICTIONS_EVENT, async (payload: EvaluatePredictionsPayload) => {\n const {winnerIds, loserIds} = await predictionService.evaluate(payload.tournamentId, payload.matchId, payload.finalScore);\n\n await tournamentNotificationService.notifyMatchResult(winnerIds, loserIds);\n\n if (winnerIds.length > 0) {\n await rewardService.grant(\n RewardType.COUPON,\n RewardBuilder.buildCouponRewardContext(payload.matchId, payload.tournamentId, winnerIds)\n );\n }\n });\n}\n"]}
1
+ {"version":3,"file":"evaluate-predictions.consumer.js","sourceRoot":"/","sources":["modules/tournament/match/events/evaluate-predictions.consumer.ts"],"names":[],"mappings":";;AAUA,kEAoBC;AA9BD,6EAA+G;AAC/G,4EAAsE;AACtE,gEAA0D;AAC1D,kFAAsF;AACtF,0GAAmG;AACnG,gFAAuE;AACvE,gEAA0D;AAC1D,4DAAqD;AACrD,8DAAoE;AAE7D,KAAK,UAAU,2BAA2B;IAC7C,MAAM,IAAA,wBAAgB,EAAC,kEAAqC,EAAE,KAAK,EAAE,OAAmC,EAAE,EAAE;QACxG,MAAM,EAAC,SAAS,EAAE,QAAQ,EAAC,GAAG,MAAM,sCAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;QAE1H,MAAM,SAAS,GAAG,MAAM,iEAA8B,CAAC,aAAa,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC3F,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,qCAAe,CAAC,mBAAmB,CAAC,CAAC;QAClE,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,qCAAe,CAAC,kBAAkB,CAAC,CAAC;QAEhE,MAAM,OAAO,CAAC,GAAG,CAAC;YACd,MAAM,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,oDAA6B,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE;YACpI,KAAK,IAAK,QAAQ,CAAC,MAAM,GAAI,CAAC,CAAC,CAAC,CAAC,oDAA6B,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,EAAG,KAAK,CAAC,IAAI,EAAG,QAAQ,CAAC,CAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE;SACvI,CAAC,CAAC;QAEH,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,MAAM,8BAAa,CAAC,KAAK,CACrB,yBAAU,CAAC,MAAM,EACjB,8BAAa,CAAC,wBAAwB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,EAAE,SAAS,CAAC,CAC3F,CAAC;QACN,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import {EvaluatePredictionsPayload, TOURNAMENT_EVALUATE_PREDICTIONS_EVENT} from './evaluate-predictions.event';\nimport {predictionService} from '../../prediction/prediction.service';\nimport {rewardService} from '../../reward/reward.service';\nimport {tournamentNotificationService} from '../../notification/notification.service';\nimport {notificationTemplateRepository} from '../../notification/notification-template.repository';\nimport {NotificationTag} from '../../notification/notification.config';\nimport {RewardBuilder} from '../../reward/reward.builder';\nimport {RewardType} from '../../reward/reward.types';\nimport {subscribeToEvent} from '@lyxa.ai/core/dist/libraries/event';\n\nexport async function EvaluatePredictionsConsumer() {\n await subscribeToEvent(TOURNAMENT_EVALUATE_PREDICTIONS_EVENT, async (payload: EvaluatePredictionsPayload) => {\n const {winnerIds, loserIds} = await predictionService.evaluate(payload.tournamentId, payload.matchId, payload.finalScore);\n\n const templates = await notificationTemplateRepository.findTemplates(payload.tournamentId);\n const winner = templates.get(NotificationTag.MATCH_RESULT_WINNER);\n const loser = templates.get(NotificationTag.MATCH_RESULT_LOSER);\n\n await Promise.all([\n winner && winnerIds.length > 0 ? tournamentNotificationService.notifyUsers(winner.title, winner.body, winnerIds) : Promise.resolve(),\n loser && loserIds.length > 0 ? tournamentNotificationService.notifyUsers(loser.title, loser.body, loserIds) : Promise.resolve(),\n ]);\n\n if (winnerIds.length > 0) {\n await rewardService.grant(\n RewardType.COUPON,\n RewardBuilder.buildCouponRewardContext(payload.matchId, payload.tournamentId, winnerIds)\n );\n }\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"match.builder.d.ts","sourceRoot":"/","sources":["modules/tournament/match/match.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,wBAAwB,EAAE,wBAAwB,EAAC,MAAM,oBAAoB,CAAC;AAEtF,UAAU,YAAY;IAClB,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,UAAU;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,IAAI,CAAC;IACnB,OAAO,CAAC,EAAE,IAAI,CAAC;CAClB;AAED,qBAAa,YAAY;IACrB,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY;;;;;;;;;;;;;;;;;;;;IAc7E,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAQjF,MAAM,CAAC,cAAc,CACjB,KAAK,EAAE,wBAAwB,EAC/B,UAAU,CAAC,EAAE;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,GAC5C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAc7B"}
1
+ {"version":3,"file":"match.builder.d.ts","sourceRoot":"/","sources":["modules/tournament/match/match.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,wBAAwB,EAAE,wBAAwB,EAAC,MAAM,oBAAoB,CAAC;AAGtF,UAAU,YAAY;IAClB,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,UAAU;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,IAAI,CAAC;IACnB,OAAO,CAAC,EAAE,IAAI,CAAC;CAClB;AAED,qBAAa,YAAY;IACrB,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY;;;;;;;;;;;;;;;;;;;;IAc7E,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAQjF,MAAM,CAAC,cAAc,CACjB,KAAK,EAAE,wBAAwB,EAC/B,UAAU,CAAC,EAAE;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,GAC5C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAc7B"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MatchBuilder = void 0;
4
4
  const typegoose_1 = require("@typegoose/typegoose");
5
+ const tournament_utils_1 = require("../tournament.utils");
5
6
  class MatchBuilder {
6
7
  static buildMatch(input, team1, team2) {
7
8
  return {
@@ -32,7 +33,7 @@ class MatchBuilder {
32
33
  : team2 > team1 ? match.team2.teamId
33
34
  : null
34
35
  : null;
35
- const update = { endDate: new Date(), winnerId };
36
+ const update = { endDate: (0, tournament_utils_1.utcNow)(), winnerId };
36
37
  if (finalScore)
37
38
  update.score = finalScore;
38
39
  return update;
@@ -1 +1 @@
1
- {"version":3,"file":"match.builder.js","sourceRoot":"/","sources":["mod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,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM;gBACpC,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM;oBACpC,CAAC,CAAC,IAAI;YACV,CAAC,CAAC,IAAI,CAAC;QAEX,MAAM,MAAM,GAA4B,EAAC,OAAO,EAAE,IAAI,IAAI,EAAE,EAAE,QAAQ,EAAC,CAAC;QACxE,IAAI,UAAU;YAAE,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC;QAC1C,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAxCD,oCAwCC","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\nimport {TournamentMatchOutputDTO, UpdateMatchScoreInputDTO} from './match.validation';\n\ninterface MatchTeamRef {\n _id: mongoose.Types.ObjectId;\n name: string;\n}\n\ninterface MatchInput {\n stage: string;\n additionalTag?: string;\n startingDate: Date;\n endDate?: Date;\n}\n\nexport class MatchBuilder {\n static buildMatch(input: MatchInput, team1: MatchTeamRef, team2: MatchTeamRef) {\n return {\n _id: new mongoose.Types.ObjectId(),\n additionalTag: input.additionalTag,\n stage: input.stage,\n team1: {teamId: team1._id, name: team1.name},\n team2: {teamId: team2._id, name: team2.name},\n score: {team1: null, team2: null},\n winnerId: null,\n startingDate: input.startingDate,\n endDate: input.endDate,\n };\n }\n\n static buildScoreUpdate(input: UpdateMatchScoreInputDTO): Record<string, unknown> {\n const updates: Record<string, unknown> = {\n score: {team1: input.team1Score, team2: input.team2Score},\n };\n if (input.winnerId !== undefined) updates.winnerId = input.winnerId;\n return updates;\n }\n\n static buildEndUpdate(\n match: TournamentMatchOutputDTO,\n finalScore?: {team1: number; team2: number}\n ): Record<string, unknown> {\n const score = finalScore ?? match.score;\n const {team1, team2} = score;\n const winnerId =\n team1 !== null && team2 !== null\n ? team1 > team2 ? match.team1.teamId\n : team2 > team1 ? match.team2.teamId\n : null\n : null;\n\n const update: Record<string, unknown> = {endDate: new Date(), winnerId};\n if (finalScore) update.score = finalScore;\n return update;\n }\n}\n"]}
1
+ {"version":3,"file":"match.builder.js","sourceRoot":"/","sources":["modules/tournament/match/match.builder.ts"],"names":[],"mappings":";;;AAAA,oDAA8C;AAE9C,0DAA2C;AAc3C,MAAa,YAAY;IACrB,MAAM,CAAC,UAAU,CAAC,KAAiB,EAAE,KAAmB,EAAE,KAAmB;QACzE,OAAO;YACH,GAAG,EAAE,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE;YAClC,aAAa,EAAE,KAAK,CAAC,aAAa;YAClC,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,KAAK,EAAE,EAAC,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAC;YAC5C,KAAK,EAAE,EAAC,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAC;YAC5C,KAAK,EAAE,EAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAC;YACjC,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,OAAO,EAAE,KAAK,CAAC,OAAO;SACzB,CAAC;IACN,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,KAA+B;QACnD,MAAM,OAAO,GAA4B;YACrC,KAAK,EAAE,EAAC,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU,EAAC;SAC5D,CAAC;QACF,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS;YAAE,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QACpE,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,cAAc,CACjB,KAA+B,EAC/B,UAA2C;QAE3C,MAAM,KAAK,GAAG,UAAU,IAAI,KAAK,CAAC,KAAK,CAAC;QACxC,MAAM,EAAC,KAAK,EAAE,KAAK,EAAC,GAAG,KAAK,CAAC;QAC7B,MAAM,QAAQ,GACV,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,IAAI;YAC5B,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM;gBACpC,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM;oBACpC,CAAC,CAAC,IAAI;YACV,CAAC,CAAC,IAAI,CAAC;QAEX,MAAM,MAAM,GAA4B,EAAC,OAAO,EAAE,IAAA,yBAAM,GAAE,EAAE,QAAQ,EAAC,CAAC;QACtE,IAAI,UAAU;YAAE,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC;QAC1C,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAxCD,oCAwCC","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\nimport {TournamentMatchOutputDTO, UpdateMatchScoreInputDTO} from './match.validation';\nimport {utcNow} from '../tournament.utils';\n\ninterface MatchTeamRef {\n _id: mongoose.Types.ObjectId;\n name: string;\n}\n\ninterface MatchInput {\n stage: string;\n additionalTag?: string;\n startingDate: Date;\n endDate?: Date;\n}\n\nexport class MatchBuilder {\n static buildMatch(input: MatchInput, team1: MatchTeamRef, team2: MatchTeamRef) {\n return {\n _id: new mongoose.Types.ObjectId(),\n additionalTag: input.additionalTag,\n stage: input.stage,\n team1: {teamId: team1._id, name: team1.name},\n team2: {teamId: team2._id, name: team2.name},\n score: {team1: null, team2: null},\n winnerId: null,\n startingDate: input.startingDate,\n endDate: input.endDate,\n };\n }\n\n static buildScoreUpdate(input: UpdateMatchScoreInputDTO): Record<string, unknown> {\n const updates: Record<string, unknown> = {\n score: {team1: input.team1Score, team2: input.team2Score},\n };\n if (input.winnerId !== undefined) updates.winnerId = input.winnerId;\n return updates;\n }\n\n static buildEndUpdate(\n match: TournamentMatchOutputDTO,\n finalScore?: {team1: number; team2: number}\n ): Record<string, unknown> {\n const score = finalScore ?? match.score;\n const {team1, team2} = score;\n const winnerId =\n team1 !== null && team2 !== null\n ? team1 > team2 ? match.team1.teamId\n : team2 > team1 ? match.team2.teamId\n : null\n : null;\n\n const update: Record<string, unknown> = {endDate: utcNow(), winnerId};\n if (finalScore) update.score = finalScore;\n return update;\n }\n}\n"]}
@@ -8,6 +8,8 @@ export declare class TournamentMatchRepository {
8
8
  updateMatch(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, updates: Record<string, unknown>): Promise<Model | null>;
9
9
  deleteMatch(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<Model | null>;
10
10
  findMatchInTournament(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<Model | null>;
11
+ getNotificationFlag(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, type: string): Promise<boolean>;
12
+ setNotificationFlag(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, type: string): Promise<void>;
11
13
  }
12
14
  export declare const tournamentMatchRepository: TournamentMatchRepository;
13
15
  //# sourceMappingURL=match.repository.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"match.repository.d.ts","sourceRoot":"/","sources":["modules/tournament/match/match.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,UAAU,IAAI,KAAK,EAAmB,MAAM,2CAA2C,CAAC;AAEjG,qBACa,yBAAyB;IACrC,OAAO,CAAC,KAAK,CAAyB;;IAMhC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAI5D,UAAU,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,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AO,CAAC,GAC9B,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAalB,WAAW,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAM3G,qBAAqB,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAMrH,mBAAmB,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ5H,mBAAmB,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAM/H;AAED,eAAO,MAAM,yBAAyB,2BAA2C,CAAC"}
@@ -74,6 +74,16 @@ let TournamentMatchRepository = class TournamentMatchRepository {
74
74
  .findOne({ _id: tournamentId, 'matches._id': matchId })
75
75
  .lean();
76
76
  }
77
+ async getNotificationFlag(tournamentId, matchId, type) {
78
+ const doc = await this.model
79
+ .findOne({ _id: tournamentId, 'matches._id': matchId }, { 'matches.$': 1 })
80
+ .lean();
81
+ const match = doc?.matches?.[0];
82
+ return match?.notificationFlags?.[type] === true;
83
+ }
84
+ async setNotificationFlag(tournamentId, matchId, type) {
85
+ await this.model.updateOne({ _id: tournamentId, 'matches._id': matchId }, { $set: { [`matches.$.notificationFlags.${type}`]: true } });
86
+ }
77
87
  };
78
88
  exports.TournamentMatchRepository = TournamentMatchRepository;
79
89
  exports.TournamentMatchRepository = TournamentMatchRepository = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"match.repository.js","sourceRoot":"/","sources":["modules/tournament/match/match.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,sEAAiG;AAG1F,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAC7B,KAAK,CAAyB;IAEtC;QACC,IAAI,CAAC,KAAK,GAAG,wBAAe,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,EAA2B;QACzC,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,EAA2B,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,EAA2B,EAAE,OAAiB;QAC9D,OAAO,IAAI,CAAC,KAAK;aACf,iBAAiB,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;aAChF,IAAI,EAA2B,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,WAAW,CAChB,YAAqC,EACrC,OAAgC,EAChC,OAAgC;QAEhC,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CACpC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,aAAa,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC,CAC1E,CAAC;QACF,OAAO,IAAI,CAAC,KAAK;aACf,gBAAgB,CAChB,EAAE,GAAG,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,EAC7C,EAAE,IAAI,EAAE,UAAU,EAAE,EACpB,EAAE,GAAG,EAAE,IAAI,EAAE,CACb;aACA,IAAI,EAA2B,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,YAAqC,EAAE,OAAgC;QACxF,OAAO,IAAI,CAAC,KAAK;aACf,iBAAiB,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;aACxF,IAAI,EAA2B,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,YAAqC,EAAE,OAAgC;QAClG,OAAO,IAAI,CAAC,KAAK;aACf,OAAO,CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC;aACtD,IAAI,EAA2B,CAAC;IACnC,CAAC;CACD,CAAA;AA7CY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,gBAAO,GAAE;;GACG,yBAAyB,CA6CrC;AAEY,QAAA,yBAAyB,GAAG,gBAAS,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport { Tournament as Model, TournamentModel } from '@lyxa.ai/core/dist/libraries/mongo/models';\n\n@Service()\nexport class TournamentMatchRepository {\n\tprivate model: typeof TournamentModel;\n\n\tconstructor() {\n\t\tthis.model = TournamentModel;\n\t}\n\n\tasync findById(id: mongoose.Types.ObjectId): Promise<Model | null> {\n\t\treturn this.model.findById(id).lean() as Promise<Model | null>;\n\t}\n\n\tasync addMatches(id: mongoose.Types.ObjectId, matches: object[]): Promise<Model | null> {\n\t\treturn this.model\n\t\t\t.findByIdAndUpdate(id, { $push: { matches: { $each: matches } } }, { new: true })\n\t\t\t.lean() as Promise<Model | null>;\n\t}\n\n\tasync updateMatch(\n\t\ttournamentId: mongoose.Types.ObjectId,\n\t\tmatchId: mongoose.Types.ObjectId,\n\t\tupdates: Record<string, unknown>\n\t): Promise<Model | null> {\n\t\tconst setUpdates = Object.fromEntries(\n\t\t\tObject.entries(updates).map(([key, value]) => [`matches.$.${key}`, value])\n\t\t);\n\t\treturn this.model\n\t\t\t.findOneAndUpdate(\n\t\t\t\t{ _id: tournamentId, 'matches._id': matchId },\n\t\t\t\t{ $set: setUpdates },\n\t\t\t\t{ new: true }\n\t\t\t)\n\t\t\t.lean() as Promise<Model | null>;\n\t}\n\n\tasync deleteMatch(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<Model | null> {\n\t\treturn this.model\n\t\t\t.findByIdAndUpdate(tournamentId, { $pull: { matches: { _id: matchId } } }, { new: true })\n\t\t\t.lean() as Promise<Model | null>;\n\t}\n\n\tasync findMatchInTournament(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<Model | null> {\n\t\treturn this.model\n\t\t\t.findOne({ _id: tournamentId, 'matches._id': matchId })\n\t\t\t.lean() as Promise<Model | null>;\n\t}\n}\n\nexport const tournamentMatchRepository = Container.get(TournamentMatchRepository);\n"]}
1
+ {"version":3,"file":"match.repository.js","sourceRoot":"/","sources":["modules/tournament/match/match.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,sEAAiG;AAG1F,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAC7B,KAAK,CAAyB;IAEtC;QACC,IAAI,CAAC,KAAK,GAAG,wBAAe,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,EAA2B;QACzC,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,EAA2B,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,EAA2B,EAAE,OAAiB;QAC9D,OAAO,IAAI,CAAC,KAAK;aACf,iBAAiB,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EA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CAAC,EAAE,CAAC;aAC1E,IAAI,EAAE,CAAC;QACT,MAAM,KAAK,GAAG,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC,CAAQ,CAAC;QACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,YAAqC,EAAE,OAAgC,EAAE,IAAY;QAC9G,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,CACzB,EAAE,GAAG,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,EAC7C,EAAE,IAAI,EAAE,EAAE,CAAC,+BAA+B,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,CAC3D,CAAC;IACH,CAAC;CACD,CAAA;AA5DY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,gBAAO,GAAE;;GACG,yBAAyB,CA4DrC;AAEY,QAAA,yBAAyB,GAAG,gBAAS,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport { Tournament as Model, TournamentModel } from '@lyxa.ai/core/dist/libraries/mongo/models';\n\n@Service()\nexport class TournamentMatchRepository {\n\tprivate model: typeof TournamentModel;\n\n\tconstructor() {\n\t\tthis.model = TournamentModel;\n\t}\n\n\tasync findById(id: mongoose.Types.ObjectId): Promise<Model | null> {\n\t\treturn this.model.findById(id).lean() as Promise<Model | null>;\n\t}\n\n\tasync addMatches(id: mongoose.Types.ObjectId, matches: object[]): Promise<Model | null> {\n\t\treturn this.model\n\t\t\t.findByIdAndUpdate(id, { $push: { matches: { $each: matches } } }, { new: true })\n\t\t\t.lean() as Promise<Model | null>;\n\t}\n\n\tasync updateMatch(\n\t\ttournamentId: mongoose.Types.ObjectId,\n\t\tmatchId: mongoose.Types.ObjectId,\n\t\tupdates: Record<string, unknown>\n\t): Promise<Model | null> {\n\t\tconst setUpdates = Object.fromEntries(\n\t\t\tObject.entries(updates).map(([key, value]) => [`matches.$.${key}`, value])\n\t\t);\n\t\treturn this.model\n\t\t\t.findOneAndUpdate(\n\t\t\t\t{ _id: tournamentId, 'matches._id': matchId },\n\t\t\t\t{ $set: setUpdates },\n\t\t\t\t{ new: true }\n\t\t\t)\n\t\t\t.lean() as Promise<Model | null>;\n\t}\n\n\tasync deleteMatch(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<Model | null> {\n\t\treturn this.model\n\t\t\t.findByIdAndUpdate(tournamentId, { $pull: { matches: { _id: matchId } } }, { new: true })\n\t\t\t.lean() as Promise<Model | null>;\n\t}\n\n\tasync findMatchInTournament(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<Model | null> {\n\t\treturn this.model\n\t\t\t.findOne({ _id: tournamentId, 'matches._id': matchId })\n\t\t\t.lean() as Promise<Model | null>;\n\t}\n\n\tasync getNotificationFlag(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, type: string): Promise<boolean> {\n\t\tconst doc = await this.model\n\t\t\t.findOne({ _id: tournamentId, 'matches._id': matchId }, { 'matches.$': 1 })\n\t\t\t.lean();\n\t\tconst match = doc?.matches?.[0] as any;\n\t\treturn match?.notificationFlags?.[type] === true;\n\t}\n\n\tasync setNotificationFlag(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, type: string): Promise<void> {\n\t\tawait this.model.updateOne(\n\t\t\t{ _id: tournamentId, 'matches._id': matchId },\n\t\t\t{ $set: { [`matches.$.notificationFlags.${type}`]: true } }\n\t\t);\n\t}\n}\n\nexport const tournamentMatchRepository = Container.get(TournamentMatchRepository);\n"]}
@@ -32,12 +32,12 @@ export declare const matchRouter: import("@trpc/server").TRPCBuiltRouter<{
32
32
  data?: {
33
33
  status: import("@lyxa.ai/core/dist/utilities/enum").Status;
34
34
  name: string;
35
- tag: string;
36
35
  _id?: string | import("mongoose").Types.ObjectId | undefined;
37
36
  createdAt?: Date | null | undefined;
38
37
  startDate?: Date | null | undefined;
39
38
  endDate?: Date | null | undefined;
40
39
  updatedAt?: Date | null | undefined;
40
+ tag?: import("../tournament.types").TournamentTag | undefined;
41
41
  reward?: {
42
42
  type: import("@lyxa.ai/core/dist/utilities/enum").TournamentRewardType.FREE_DELIVERY;
43
43
  } | {
@@ -50,12 +50,12 @@ export declare const matchRouter: import("@trpc/server").TRPCBuiltRouter<{
50
50
  documents: {
51
51
  status: import("@lyxa.ai/core/dist/utilities/enum").Status;
52
52
  name: string;
53
- tag: string;
54
53
  _id?: string | import("mongoose").Types.ObjectId | undefined;
55
54
  createdAt?: Date | null | undefined;
56
55
  startDate?: Date | null | undefined;
57
56
  endDate?: Date | null | undefined;
58
57
  updatedAt?: Date | null | undefined;
58
+ tag?: import("../tournament.types").TournamentTag | undefined;
59
59
  reward?: {
60
60
  type: import("@lyxa.ai/core/dist/utilities/enum").TournamentRewardType.FREE_DELIVERY;
61
61
  } | {
@@ -87,10 +87,12 @@ export declare const matchRouter: import("@trpc/server").TRPCBuiltRouter<{
87
87
  team1: {
88
88
  name: string;
89
89
  teamId: string | import("mongoose").Types.ObjectId;
90
+ picture?: string | undefined;
90
91
  };
91
92
  team2: {
92
93
  name: string;
93
94
  teamId: string | import("mongoose").Types.ObjectId;
95
+ picture?: string | undefined;
94
96
  };
95
97
  score: {
96
98
  team1: number | null;
@@ -114,10 +116,12 @@ export declare const matchRouter: import("@trpc/server").TRPCBuiltRouter<{
114
116
  team1: {
115
117
  name: string;
116
118
  teamId: string | import("mongoose").Types.ObjectId;
119
+ picture?: string | undefined;
117
120
  };
118
121
  team2: {
119
122
  name: string;
120
123
  teamId: string | import("mongoose").Types.ObjectId;
124
+ picture?: string | undefined;
121
125
  };
122
126
  score: {
123
127
  team1: number | null;
@@ -159,10 +163,12 @@ export declare const matchRouter: import("@trpc/server").TRPCBuiltRouter<{
159
163
  team1: {
160
164
  name: string;
161
165
  teamId: string | import("mongoose").Types.ObjectId;
166
+ picture?: string | undefined;
162
167
  };
163
168
  team2: {
164
169
  name: string;
165
170
  teamId: string | import("mongoose").Types.ObjectId;
171
+ picture?: string | undefined;
166
172
  };
167
173
  score: {
168
174
  team1: number | null;
@@ -186,10 +192,12 @@ export declare const matchRouter: import("@trpc/server").TRPCBuiltRouter<{
186
192
  team1: {
187
193
  name: string;
188
194
  teamId: string | import("mongoose").Types.ObjectId;
195
+ picture?: string | undefined;
189
196
  };
190
197
  team2: {
191
198
  name: string;
192
199
  teamId: string | import("mongoose").Types.ObjectId;
200
+ picture?: string | undefined;
193
201
  };
194
202
  score: {
195
203
  team1: number | null;
@@ -235,10 +243,12 @@ export declare const matchRouter: import("@trpc/server").TRPCBuiltRouter<{
235
243
  team1: {
236
244
  name: string;
237
245
  teamId: string | import("mongoose").Types.ObjectId;
246
+ picture?: string | undefined;
238
247
  };
239
248
  team2: {
240
249
  name: string;
241
250
  teamId: string | import("mongoose").Types.ObjectId;
251
+ picture?: string | undefined;
242
252
  };
243
253
  score: {
244
254
  team1: number | null;
@@ -262,10 +272,12 @@ export declare const matchRouter: import("@trpc/server").TRPCBuiltRouter<{
262
272
  team1: {
263
273
  name: string;
264
274
  teamId: string | import("mongoose").Types.ObjectId;
275
+ picture?: string | undefined;
265
276
  };
266
277
  team2: {
267
278
  name: string;
268
279
  teamId: string | import("mongoose").Types.ObjectId;
280
+ picture?: string | undefined;
269
281
  };
270
282
  score: {
271
283
  team1: number | null;
@@ -305,12 +317,12 @@ export declare const matchRouter: import("@trpc/server").TRPCBuiltRouter<{
305
317
  data?: {
306
318
  status: import("@lyxa.ai/core/dist/utilities/enum").Status;
307
319
  name: string;
308
- tag: string;
309
320
  _id?: string | import("mongoose").Types.ObjectId | undefined;
310
321
  createdAt?: Date | null | undefined;
311
322
  startDate?: Date | null | undefined;
312
323
  endDate?: Date | null | undefined;
313
324
  updatedAt?: Date | null | undefined;
325
+ tag?: import("../tournament.types").TournamentTag | undefined;
314
326
  reward?: {
315
327
  type: import("@lyxa.ai/core/dist/utilities/enum").TournamentRewardType.FREE_DELIVERY;
316
328
  } | {
@@ -323,12 +335,12 @@ export declare const matchRouter: import("@trpc/server").TRPCBuiltRouter<{
323
335
  documents: {
324
336
  status: import("@lyxa.ai/core/dist/utilities/enum").Status;
325
337
  name: string;
326
- tag: string;
327
338
  _id?: string | import("mongoose").Types.ObjectId | undefined;
328
339
  createdAt?: Date | null | undefined;
329
340
  startDate?: Date | null | undefined;
330
341
  endDate?: Date | null | undefined;
331
342
  updatedAt?: Date | null | undefined;
343
+ tag?: import("../tournament.types").TournamentTag | undefined;
332
344
  reward?: {
333
345
  type: import("@lyxa.ai/core/dist/utilities/enum").TournamentRewardType.FREE_DELIVERY;
334
346
  } | {
@@ -1 +1 @@
1
- {"version":3,"file":"match.router.d.ts","sourceRoot":"/","sources":["modules/tournament/match/match.router.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDtB,CAAC"}
1
+ {"version":3,"file":"match.router.d.ts","sourceRoot":"/","sources":["modules/tournament/match/match.router.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDtB,CAAC"}
@@ -3,7 +3,6 @@ import { AddTournamentMatchesInputDTO, EndTournamentMatchInputDTO, StartTourname
3
3
  import { TournamentConfigOutputDTO } from '../config/config.validation';
4
4
  export declare class MatchService {
5
5
  private repository;
6
- private notificationScheduler;
7
6
  constructor();
8
7
  private getTournament;
9
8
  private getMatch;
@@ -1 +1 @@
1
- {"version":3,"file":"match.service.d.ts","sourceRoot":"/","sources":["modules/tournament/match/match.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAG9C,OAAO,EACH,4BAA4B,EAC5B,0BAA0B,EAC1B,4BAA4B,EAC5B,wBAAwB,EAC3B,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAC,yBAAyB,EAAC,MAAM,6BAA6B,CAAC;AAKtE,qBACa,YAAY;IACrB,OAAO,CAAC,UAAU,CAA4B;IAC9C,OAAO,CAAC,qBAAqB,CAA+B;;YAO9C,aAAa;IAM3B,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,iBAAiB;YAQX,gBAAgB;IAYjB,GAAG,CAAC,KAAK,EAAE,4BAA4B,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAoB5E,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,wBAAwB,EAAE,CAAC;IAKlF,KAAK,CAAC,KAAK,EAAE,4BAA4B,GAAG,OAAO,CAAC,wBA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 = require("@lyxa.ai/core/dist/utilities/error-common");
48
48
  const event_1 = require("@lyxa.ai/core/dist/libraries/event");
49
49
  const match_repository_1 = require("./match.repository");
50
50
  const match_builder_1 = require("./match.builder");
51
- const notification_scheduler_service_1 = require("../notification/notification.scheduler.service");
52
51
  const evaluate_predictions_event_1 = require("./events/evaluate-predictions.event");
52
+ const tournament_utils_1 = require("../tournament.utils");
53
53
  let MatchService = class MatchService {
54
54
  repository;
55
- notificationScheduler;
56
55
  constructor() {
57
56
  this.repository = typedi_1.default.get(match_repository_1.TournamentMatchRepository);
58
- this.notificationScheduler = typedi_1.default.get(notification_scheduler_service_1.NotificationSchedulerService);
59
57
  }
60
58
  async getTournament(tournamentId) {
61
59
  const tournament = await this.repository.findById(tournamentId);
@@ -95,7 +93,6 @@ let MatchService = class MatchService {
95
93
  const result = await this.repository.addMatches(input.tournamentId, matches);
96
94
  if (!result)
97
95
  throw (0, error_common_1.notFoundError)('Tournament not found');
98
- await Promise.all(matches.map(match => this.notificationScheduler.scheduleForMatch(match._id, input.tournamentId, match.startingDate)));
99
96
  return result;
100
97
  }
101
98
  async getAll(tournamentId) {
@@ -105,17 +102,16 @@ let MatchService = class MatchService {
105
102
  async start(input) {
106
103
  const tournament = await this.getTournament(input.tournamentId);
107
104
  const match = this.getMatch(tournament, input.matchId);
108
- if (!match.startingDate || match.startingDate > new Date())
105
+ if (!match.startingDate || match.startingDate > (0, tournament_utils_1.utcNow)())
109
106
  throw (0, error_common_1.badRequestError)('This match has not started yet');
110
107
  if (match.endDate)
111
108
  throw (0, error_common_1.badRequestError)('This match has already ended');
112
- await this.notificationScheduler.cancelForMatch(input.matchId);
113
109
  return match;
114
110
  }
115
111
  async end(input) {
116
112
  const tournament = await this.getTournament(input.tournamentId);
117
113
  const match = this.getMatch(tournament, input.matchId);
118
- if (!match.startingDate || match.startingDate > new Date())
114
+ if (!match.startingDate || match.startingDate > (0, tournament_utils_1.utcNow)())
119
115
  throw (0, error_common_1.badRequestError)('This match has not started yet');
120
116
  if (match.endDate)
121
117
  throw (0, error_common_1.badRequestError)('This match has already ended');
@@ -132,11 +128,9 @@ let MatchService = class MatchService {
132
128
  return ended;
133
129
  }
134
130
  async delete(tournamentId, matchId) {
135
- await this.getTournament(tournamentId);
136
131
  const result = await this.repository.deleteMatch(tournamentId, matchId);
137
132
  if (!result)
138
133
  throw (0, error_common_1.notFoundError)('Tournament not found');
139
- await this.notificationScheduler.cancelForMatch(matchId);
140
134
  return result;
141
135
  }
142
136
  };
@@ -1 +1 @@
1
- {"version":3,"file":"match.service.js","sourceRoot":"/","sources":["modules/tournament/match/match.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,4EAAyF;AACzF,8DAAgE;AAOhE,yDAA6D;AAC7D,mDAA6C;AAG7C,mGAA4F;AAC5F,oFAA6E;AAGtE,IAAM,YAAY,GAAlB,MAAM,YAAY;IACb,UAAU,CAA4B;IACtC,qBAAqB,CAA+B;IAE5D;QACI,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,4CAAyB,CAAC,CAAC;QAC3D,IAAI,CAAC,qBAAqB,GAAG,gBAAS,CAAC,GAAG,CAAC,6DAA4B,CAAC,CAAC;IAC7E,CAAC;IAEO,KAAK,CAAC,aAAa,CAAC,YAAqC;QAC7D,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAChE,IAAI,CAAC,UAAU;YAAE,MAAM,IAAA,4BAAa,EAAC,sBAAsB,CAAC,CAAC;QAC7D,OAAO,UAAU,CAAC;IACtB,CAAC;IAEO,QAAQ,CAAC,UAAiD,EAAE,OAAgC;QAChG,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,OAAO,CAAC,QAAQ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,qDAAwB,CAAC;gBAC5C,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,UAAU,EAAE,EAAC,KAAK,EAAE,KAAK,EAAC;aAC7B,CAAC,CAAC,CAAC;QACR,CAAC;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,YAAqC,EAAE,OAAgC;QACvF,MAAM,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,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"]}
1
+ {"version":3,"file":"match.service.js","sourceRoot":"/","sources":["modules/tournament/match/match.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,4EAAyF;AACzF,8DAAgE;AAOhE,yDAA6D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AG,MAAM,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QAE3F,MAAM,EAAC,KAAK,EAAE,KAAK,EAAC,GAAG,KAAK,CAAC,KAAK,CAAC;QACnC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACjF,MAAM,IAAA,oBAAY,EAAC,IAAI,qDAAwB,CAAC;gBAC5C,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,UAAU,EAAE,EAAC,KAAK,EAAE,KAAK,EAAC;aAC7B,CAAC,CAAC,CAAC;QACR,CAAC;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,YAAqC,EAAE,OAAgC;QACvF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACxE,IAAI,CAAC,MAAM;YAAE,MAAM,IAAA,4BAAa,EAAC,sBAAsB,CAAC,CAAC;QAEzD,OAAO,MAAmC,CAAC;IAC/C,CAAC;CACJ,CAAA;AA/FY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,gBAAO,GAAE;;GACG,YAAY,CA+FxB;AAEY,QAAA,YAAY,GAAG,gBAAS,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {badRequestError, notFoundError} from '@lyxa.ai/core/dist/utilities/error-common';\nimport {publishEvent} from '@lyxa.ai/core/dist/libraries/event';\nimport {\n AddTournamentMatchesInputDTO,\n EndTournamentMatchInputDTO,\n StartTournamentMatchInputDTO,\n TournamentMatchOutputDTO,\n} from './match.validation';\nimport {TournamentMatchRepository} from './match.repository';\nimport {MatchBuilder} from './match.builder';\nimport {TournamentConfigOutputDTO} from '../config/config.validation';\nimport {Tournament as TournamentType} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {EvaluatePredictionsEvent} from './events/evaluate-predictions.event';\nimport {utcNow} from '../tournament.utils';\n\n@Service()\nexport class MatchService {\n private repository: TournamentMatchRepository;\n\n constructor() {\n this.repository = Container.get(TournamentMatchRepository);\n }\n\n private async getTournament(tournamentId: mongoose.Types.ObjectId) {\n const tournament = await this.repository.findById(tournamentId);\n if (!tournament) throw notFoundError('Tournament not found');\n return tournament;\n }\n\n private getMatch(tournament: {matches: TournamentMatchOutputDTO[]}, matchId: mongoose.Types.ObjectId) {\n const match = tournament.matches.find(m => m._id.toString() === matchId.toString());\n if (!match) throw notFoundError('Match not found');\n return match;\n }\n\n private resolveMatchTeams(tournament: TournamentType, team1Id: mongoose.Types.ObjectId, team2Id: mongoose.Types.ObjectId) {\n const teamsById = new Map(tournament.teams.map(team => [team._id.toString(), team]));\n const team1 = teamsById.get(team1Id.toString());\n const team2 = teamsById.get(team2Id.toString());\n if (!team1 || !team2) throw badRequestError('All match teams must exist in the tournament');\n return {team1, team2};\n }\n\n private async applyMatchUpdate(\n tournamentId: mongoose.Types.ObjectId,\n matchId: mongoose.Types.ObjectId,\n updates: Record<string, unknown>\n ): Promise<TournamentMatchOutputDTO> {\n const result = await this.repository.updateMatch(tournamentId, matchId, updates);\n if (!result) throw notFoundError('Tournament not found');\n const updated = result.matches.find(m => m._id.toString() === matchId.toString());\n if (!updated) throw notFoundError('Match not found');\n return updated as TournamentMatchOutputDTO;\n }\n\n public async add(input: AddTournamentMatchesInputDTO): Promise<TournamentConfigOutputDTO> {\n const tournament = await this.getTournament(input.tournamentId);\n\n const matches = input.matches.map(match => {\n const {team1, team2} = this.resolveMatchTeams(tournament, match.team1Id, match.team2Id);\n return MatchBuilder.buildMatch(match, team1, team2);\n });\n\n const result = await this.repository.addMatches(input.tournamentId, matches);\n if (!result) throw notFoundError('Tournament not found');\n\n return result as TournamentConfigOutputDTO;\n }\n\n public async getAll(tournamentId: mongoose.Types.ObjectId): Promise<TournamentMatchOutputDTO[]> {\n const tournament = await this.getTournament(tournamentId);\n return tournament.matches as TournamentMatchOutputDTO[];\n }\n\n public async start(input: StartTournamentMatchInputDTO): Promise<TournamentMatchOutputDTO> {\n const tournament = await this.getTournament(input.tournamentId);\n const match = this.getMatch(tournament, input.matchId);\n\n if (!match.startingDate || match.startingDate > utcNow()) throw badRequestError('This match has not started yet');\n if (match.endDate) throw badRequestError('This match has already ended');\n return match;\n }\n\n public async end(input: EndTournamentMatchInputDTO): Promise<TournamentMatchOutputDTO> {\n const tournament = await this.getTournament(input.tournamentId);\n const match = this.getMatch(tournament, input.matchId);\n\n if (!match.startingDate || match.startingDate > utcNow()) throw badRequestError('This match has not started yet');\n if (match.endDate) throw badRequestError('This match has already ended');\n\n const matchUpdates = MatchBuilder.buildEndUpdate(match, input.finalScore)\n const ended = await this.applyMatchUpdate(input.tournamentId, input.matchId, matchUpdates);\n\n const {team1, team2} = ended.score;\n if (team1 !== null && team1 !== undefined && team2 !== null && team2 !== undefined) {\n await publishEvent(new EvaluatePredictionsEvent({\n tournamentId: input.tournamentId,\n matchId: input.matchId,\n finalScore: {team1, team2},\n }));\n }\n\n return ended;\n }\n\n public async delete(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<TournamentConfigOutputDTO> {\n const result = await this.repository.deleteMatch(tournamentId, matchId);\n if (!result) throw notFoundError('Tournament not found');\n\n return result as TournamentConfigOutputDTO;\n }\n}\n\nexport const matchService = Container.get(MatchService);\n"]}