@lyxa.ai/marketing 1.0.49 → 1.0.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/dist/lib/index.d.ts +236 -17
  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 +1 -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 +6 -0
  63. package/dist/lib/modules/tournament/participant/participant.repository.js.map +1 -1
  64. package/dist/lib/modules/tournament/prediction/prediction.builder.d.ts.map +1 -1
  65. package/dist/lib/modules/tournament/prediction/prediction.builder.js +3 -2
  66. package/dist/lib/modules/tournament/prediction/prediction.builder.js.map +1 -1
  67. package/dist/lib/modules/tournament/prediction/prediction.service.d.ts +1 -0
  68. package/dist/lib/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
  69. package/dist/lib/modules/tournament/prediction/prediction.service.js +10 -1
  70. package/dist/lib/modules/tournament/prediction/prediction.service.js.map +1 -1
  71. package/dist/lib/modules/tournament/reward/reward.builder.d.ts.map +1 -1
  72. package/dist/lib/modules/tournament/reward/reward.builder.js +2 -1
  73. package/dist/lib/modules/tournament/reward/reward.builder.js.map +1 -1
  74. package/dist/lib/modules/tournament/reward/reward.repository.d.ts +8 -0
  75. package/dist/lib/modules/tournament/reward/reward.repository.d.ts.map +1 -0
  76. package/dist/lib/modules/tournament/reward/reward.repository.js +66 -0
  77. package/dist/lib/modules/tournament/reward/reward.repository.js.map +1 -0
  78. package/dist/lib/modules/tournament/schedule/schedule.router.d.ts +27 -0
  79. package/dist/lib/modules/tournament/schedule/schedule.router.d.ts.map +1 -0
  80. package/dist/lib/modules/tournament/schedule/schedule.router.js +17 -0
  81. package/dist/lib/modules/tournament/schedule/schedule.router.js.map +1 -0
  82. package/dist/lib/modules/tournament/schedule/schedule.service.d.ts +10 -0
  83. package/dist/lib/modules/tournament/schedule/schedule.service.d.ts.map +1 -0
  84. package/dist/lib/modules/tournament/schedule/schedule.service.js +87 -0
  85. package/dist/lib/modules/tournament/schedule/schedule.service.js.map +1 -0
  86. package/dist/lib/modules/tournament/score/score.repository.d.ts +8 -1
  87. package/dist/lib/modules/tournament/score/score.repository.d.ts.map +1 -1
  88. package/dist/lib/modules/tournament/score/score.repository.js +12 -2
  89. package/dist/lib/modules/tournament/score/score.repository.js.map +1 -1
  90. package/dist/lib/modules/tournament/score/score.router.d.ts +98 -0
  91. package/dist/lib/modules/tournament/score/score.router.d.ts.map +1 -0
  92. package/dist/lib/modules/tournament/score/score.router.js +20 -0
  93. package/dist/lib/modules/tournament/score/score.router.js.map +1 -0
  94. package/dist/lib/modules/tournament/score/score.service.d.ts +7 -0
  95. package/dist/lib/modules/tournament/score/score.service.d.ts.map +1 -1
  96. package/dist/lib/modules/tournament/score/score.service.js +49 -0
  97. package/dist/lib/modules/tournament/score/score.service.js.map +1 -1
  98. package/dist/lib/modules/tournament/score/score.validation.d.ts +375 -0
  99. package/dist/lib/modules/tournament/score/score.validation.d.ts.map +1 -0
  100. package/dist/lib/modules/tournament/score/score.validation.js +19 -0
  101. package/dist/lib/modules/tournament/score/score.validation.js.map +1 -0
  102. package/dist/lib/modules/tournament/statistics/statistics.builder.d.ts +10 -0
  103. package/dist/lib/modules/tournament/statistics/statistics.builder.d.ts.map +1 -0
  104. package/dist/lib/modules/tournament/statistics/statistics.builder.js +53 -0
  105. package/dist/lib/modules/tournament/statistics/statistics.builder.js.map +1 -0
  106. package/dist/lib/modules/tournament/statistics/statistics.router.d.ts +80 -0
  107. package/dist/lib/modules/tournament/statistics/statistics.router.d.ts.map +1 -0
  108. package/dist/lib/modules/tournament/statistics/statistics.router.js +21 -0
  109. package/dist/lib/modules/tournament/statistics/statistics.router.js.map +1 -0
  110. package/dist/lib/modules/tournament/statistics/statistics.service.d.ts +11 -0
  111. package/dist/lib/modules/tournament/statistics/statistics.service.d.ts.map +1 -0
  112. package/dist/lib/modules/tournament/statistics/statistics.service.js +80 -0
  113. package/dist/lib/modules/tournament/statistics/statistics.service.js.map +1 -0
  114. package/dist/lib/modules/tournament/statistics/statistics.validation.d.ts +404 -0
  115. package/dist/lib/modules/tournament/statistics/statistics.validation.d.ts.map +1 -0
  116. package/dist/lib/modules/tournament/statistics/statistics.validation.js +36 -0
  117. package/dist/lib/modules/tournament/statistics/statistics.validation.js.map +1 -0
  118. package/dist/lib/modules/tournament/team/team.router.d.ts +9 -3
  119. package/dist/lib/modules/tournament/team/team.router.d.ts.map +1 -1
  120. package/dist/lib/modules/tournament/team/team.service.d.ts +1 -0
  121. package/dist/lib/modules/tournament/team/team.service.d.ts.map +1 -1
  122. package/dist/lib/modules/tournament/team/team.service.js +21 -16
  123. package/dist/lib/modules/tournament/team/team.service.js.map +1 -1
  124. package/dist/lib/modules/tournament/team/team.validation.d.ts +54 -4
  125. package/dist/lib/modules/tournament/team/team.validation.d.ts.map +1 -1
  126. package/dist/lib/modules/tournament/team/team.validation.js +4 -2
  127. package/dist/lib/modules/tournament/team/team.validation.js.map +1 -1
  128. package/dist/lib/modules/tournament/tournament.router.d.ts +236 -17
  129. package/dist/lib/modules/tournament/tournament.router.d.ts.map +1 -1
  130. package/dist/lib/modules/tournament/tournament.router.js +6 -0
  131. package/dist/lib/modules/tournament/tournament.router.js.map +1 -1
  132. package/dist/lib/modules/tournament/tournament.types.d.ts +9 -0
  133. package/dist/lib/modules/tournament/tournament.types.d.ts.map +1 -0
  134. package/dist/lib/modules/tournament/tournament.types.js +14 -0
  135. package/dist/lib/modules/tournament/tournament.types.js.map +1 -0
  136. package/dist/lib/modules/tournament/tournament.utils.d.ts +2 -0
  137. package/dist/lib/modules/tournament/tournament.utils.d.ts.map +1 -0
  138. package/dist/lib/modules/tournament/tournament.utils.js +6 -0
  139. package/dist/lib/modules/tournament/tournament.utils.js.map +1 -0
  140. package/dist/types/index.d.ts +236 -17
  141. package/dist/types/index.d.ts.map +1 -1
  142. package/dist/types/modules/tournament/config/config.repository.d.ts +3 -0
  143. package/dist/types/modules/tournament/config/config.repository.d.ts.map +1 -1
  144. package/dist/types/modules/tournament/config/config.router.d.ts +10 -10
  145. package/dist/types/modules/tournament/config/config.validation.d.ts +37 -36
  146. package/dist/types/modules/tournament/config/config.validation.d.ts.map +1 -1
  147. package/dist/types/modules/tournament/match/events/evaluate-predictions.consumer.d.ts.map +1 -1
  148. package/dist/types/modules/tournament/match/match.builder.d.ts.map +1 -1
  149. package/dist/types/modules/tournament/match/match.repository.d.ts +2 -0
  150. package/dist/types/modules/tournament/match/match.repository.d.ts.map +1 -1
  151. package/dist/types/modules/tournament/match/match.router.d.ts +16 -4
  152. package/dist/types/modules/tournament/match/match.router.d.ts.map +1 -1
  153. package/dist/types/modules/tournament/match/match.service.d.ts +0 -1
  154. package/dist/types/modules/tournament/match/match.service.d.ts.map +1 -1
  155. package/dist/types/modules/tournament/match/match.validation.d.ts +50 -0
  156. package/dist/types/modules/tournament/match/match.validation.d.ts.map +1 -1
  157. package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts +2 -5
  158. package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts.map +1 -1
  159. package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts +2 -0
  160. package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts.map +1 -1
  161. package/dist/types/modules/tournament/notification/notification-template.repository.d.ts +8 -0
  162. package/dist/types/modules/tournament/notification/notification-template.repository.d.ts.map +1 -0
  163. package/dist/types/modules/tournament/notification/notification.config.d.ts +10 -0
  164. package/dist/types/modules/tournament/notification/notification.config.d.ts.map +1 -0
  165. package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts +10 -0
  166. package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts.map +1 -0
  167. package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts +4 -4
  168. package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts.map +1 -1
  169. package/dist/types/modules/tournament/notification/notification.service.d.ts +5 -4
  170. package/dist/types/modules/tournament/notification/notification.service.d.ts.map +1 -1
  171. package/dist/types/modules/tournament/participant/participant.repository.d.ts +1 -0
  172. package/dist/types/modules/tournament/participant/participant.repository.d.ts.map +1 -1
  173. package/dist/types/modules/tournament/prediction/prediction.builder.d.ts.map +1 -1
  174. package/dist/types/modules/tournament/prediction/prediction.service.d.ts +1 -0
  175. package/dist/types/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
  176. package/dist/types/modules/tournament/reward/reward.builder.d.ts.map +1 -1
  177. package/dist/types/modules/tournament/reward/reward.repository.d.ts +8 -0
  178. package/dist/types/modules/tournament/reward/reward.repository.d.ts.map +1 -0
  179. package/dist/types/modules/tournament/schedule/schedule.router.d.ts +27 -0
  180. package/dist/types/modules/tournament/schedule/schedule.router.d.ts.map +1 -0
  181. package/dist/types/modules/tournament/schedule/schedule.service.d.ts +10 -0
  182. package/dist/types/modules/tournament/schedule/schedule.service.d.ts.map +1 -0
  183. package/dist/types/modules/tournament/score/score.repository.d.ts +8 -1
  184. package/dist/types/modules/tournament/score/score.repository.d.ts.map +1 -1
  185. package/dist/types/modules/tournament/score/score.router.d.ts +98 -0
  186. package/dist/types/modules/tournament/score/score.router.d.ts.map +1 -0
  187. package/dist/types/modules/tournament/score/score.service.d.ts +7 -0
  188. package/dist/types/modules/tournament/score/score.service.d.ts.map +1 -1
  189. package/dist/types/modules/tournament/score/score.validation.d.ts +375 -0
  190. package/dist/types/modules/tournament/score/score.validation.d.ts.map +1 -0
  191. package/dist/types/modules/tournament/statistics/statistics.builder.d.ts +10 -0
  192. package/dist/types/modules/tournament/statistics/statistics.builder.d.ts.map +1 -0
  193. package/dist/types/modules/tournament/statistics/statistics.router.d.ts +80 -0
  194. package/dist/types/modules/tournament/statistics/statistics.router.d.ts.map +1 -0
  195. package/dist/types/modules/tournament/statistics/statistics.service.d.ts +11 -0
  196. package/dist/types/modules/tournament/statistics/statistics.service.d.ts.map +1 -0
  197. package/dist/types/modules/tournament/statistics/statistics.validation.d.ts +404 -0
  198. package/dist/types/modules/tournament/statistics/statistics.validation.d.ts.map +1 -0
  199. package/dist/types/modules/tournament/team/team.router.d.ts +9 -3
  200. package/dist/types/modules/tournament/team/team.router.d.ts.map +1 -1
  201. package/dist/types/modules/tournament/team/team.service.d.ts +1 -0
  202. package/dist/types/modules/tournament/team/team.service.d.ts.map +1 -1
  203. package/dist/types/modules/tournament/team/team.validation.d.ts +54 -4
  204. package/dist/types/modules/tournament/team/team.validation.d.ts.map +1 -1
  205. package/dist/types/modules/tournament/tournament.router.d.ts +236 -17
  206. package/dist/types/modules/tournament/tournament.router.d.ts.map +1 -1
  207. package/dist/types/modules/tournament/tournament.types.d.ts +9 -0
  208. package/dist/types/modules/tournament/tournament.types.d.ts.map +1 -0
  209. package/dist/types/modules/tournament/tournament.utils.d.ts +2 -0
  210. package/dist/types/modules/tournament/tournament.utils.d.ts.map +1 -0
  211. package/package.json +2 -2
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __metadata = (this && this.__metadata) || function (k, v) {
42
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.rewardRepository = exports.RewardRepository = void 0;
46
+ const typedi_1 = __importStar(require("typedi"));
47
+ const models_1 = require("@lyxa.ai/core/dist/libraries/mongo/models");
48
+ let RewardRepository = class RewardRepository {
49
+ couponModel;
50
+ constructor() {
51
+ this.couponModel = models_1.CouponModel;
52
+ }
53
+ async findCouponCodesByIds(ids) {
54
+ if (ids.length === 0)
55
+ return new Map();
56
+ const coupons = await this.couponModel.find({ _id: { $in: ids } }).select('_id code').lean();
57
+ return new Map(coupons.map(c => [c._id.toString(), c.code]));
58
+ }
59
+ };
60
+ exports.RewardRepository = RewardRepository;
61
+ exports.RewardRepository = RewardRepository = __decorate([
62
+ (0, typedi_1.Service)(),
63
+ __metadata("design:paramtypes", [])
64
+ ], RewardRepository);
65
+ exports.rewardRepository = typedi_1.default.get(RewardRepository);
66
+ //# sourceMappingURL=reward.repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reward.repository.js","sourceRoot":"/","sources":["modules/tournament/reward/reward.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,sEAAwE;AAGjE,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IACjB,WAAW,CAAqB;IAExC;QACI,IAAI,CAAC,WAAW,GAAG,oBAAW,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,GAA8B;QACrD,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,GAAG,EAAE,CAAC;QACvC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC;QAC7F,OAAO,IAAI,GAAG,CAAE,OAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,IAAc,CAAC,CAAC,CAAC,CAAC;IACtF,CAAC;CACJ,CAAA;AAZY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,gBAAO,GAAE;;GACG,gBAAgB,CAY5B;AAEY,QAAA,gBAAgB,GAAG,gBAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport { CouponModel } from '@lyxa.ai/core/dist/libraries/mongo/models';\n\n@Service()\nexport class RewardRepository {\n private couponModel: typeof CouponModel;\n\n constructor() {\n this.couponModel = CouponModel;\n }\n\n async findCouponCodesByIds(ids: mongoose.Types.ObjectId[]): Promise<Map<string, string>> {\n if (ids.length === 0) return new Map();\n const coupons = await this.couponModel.find({ _id: { $in: ids } }).select('_id code').lean();\n return new Map((coupons as any[]).map(c => [c._id.toString(), c.code as string]));\n }\n}\n\nexport const rewardRepository = Container.get(RewardRepository);\n"]}
@@ -0,0 +1,27 @@
1
+ export declare const scheduleRouter: import("@trpc/server").TRPCBuiltRouter<{
2
+ ctx: import("@lyxa.ai/core/dist/libraries/trpc/context").LyxaHTTPContext;
3
+ meta: object;
4
+ errorShape: {
5
+ message: string;
6
+ data: {
7
+ stack: undefined;
8
+ path: undefined;
9
+ code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
10
+ httpStatus: number;
11
+ };
12
+ stack: undefined;
13
+ code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
14
+ };
15
+ transformer: false;
16
+ }, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
17
+ dispatch: import("@trpc/server").TRPCMutationProcedure<{
18
+ input: void;
19
+ output: {
20
+ success: boolean;
21
+ message: string;
22
+ data: null | undefined;
23
+ };
24
+ meta: object;
25
+ }>;
26
+ }>>;
27
+ //# sourceMappingURL=schedule.router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedule.router.d.ts","sourceRoot":"/","sources":["modules/tournament/schedule/schedule.router.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;GAQzB,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.scheduleRouter = void 0;
4
+ const trpc_1 = require("@lyxa.ai/core/dist/libraries/trpc");
5
+ const auth_1 = require("@lyxa.ai/core/dist/libraries/auth");
6
+ const auth_2 = require("@lyxa.ai/core/dist/libraries/trpc/middlewares/auth");
7
+ const error_handler_1 = require("@lyxa.ai/core/dist/utilities/error-handler");
8
+ const response_1 = require("@lyxa.ai/core/dist/utilities/response");
9
+ const schedule_service_1 = require("./schedule.service");
10
+ exports.scheduleRouter = (0, trpc_1.createTRPCRouter)({
11
+ dispatch: (0, auth_2.createAuthenticatedProcedure)({ entityTypes: [auth_1.AuthEntityType.CRM] })
12
+ .mutation(() => error_handler_1.ErrorHandler.wrapAsync(async () => {
13
+ await schedule_service_1.scheduleDispatchService.dispatchPending();
14
+ return (0, response_1.response)('Notifications dispatched successfully', null);
15
+ })),
16
+ });
17
+ //# sourceMappingURL=schedule.router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedule.router.js","sourceRoot":"/","sources":["modules/tournament/schedule/schedule.router.ts"],"names":[],"mappings":";;;AAAA,4DAAmE;AACnE,4DAAiE;AACjE,6EAAgG;AAChG,8EAAwE;AACxE,oEAA+D;AAC/D,yDAAsE;AAEzD,QAAA,cAAc,GAAG,IAAA,uBAAgB,EAAC;IAC3C,QAAQ,EAAE,IAAA,mCAA4B,EAAC,EAAC,WAAW,EAAE,CAAC,qBAAc,CAAC,GAAG,CAAC,EAAC,CAAC;SACtE,QAAQ,CAAC,GAAG,EAAE,CACX,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,MAAM,0CAAO,CAAC,eAAe,EAAE,CAAC;QAChC,OAAO,IAAA,mBAAQ,EAAC,uCAAuC,EAAE,IAAI,CAAC,CAAC;IACnE,CAAC,CAAC,CACL;CACR,CAAC,CAAC","sourcesContent":["import {createTRPCRouter} from '@lyxa.ai/core/dist/libraries/trpc';\nimport {AuthEntityType} from '@lyxa.ai/core/dist/libraries/auth';\nimport {createAuthenticatedProcedure} from '@lyxa.ai/core/dist/libraries/trpc/middlewares/auth';\nimport {ErrorHandler} from '@lyxa.ai/core/dist/utilities/error-handler';\nimport {response} from '@lyxa.ai/core/dist/utilities/response';\nimport {scheduleDispatchService as service} from './schedule.service';\n\nexport const scheduleRouter = createTRPCRouter({\n dispatch: createAuthenticatedProcedure({entityTypes: [AuthEntityType.CRM]})\n .mutation(() =>\n ErrorHandler.wrapAsync(async () => {\n await service.dispatchPending();\n return response('Notifications dispatched successfully', null);\n })\n ),\n});\n"]}
@@ -0,0 +1,10 @@
1
+ export declare class ScheduleService {
2
+ private configRepository;
3
+ private matchRepository;
4
+ private templateRepository;
5
+ private notificationService;
6
+ constructor();
7
+ dispatchPending(): Promise<void>;
8
+ }
9
+ export declare const scheduleDispatchService: ScheduleService;
10
+ //# sourceMappingURL=schedule.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedule.service.d.ts","sourceRoot":"/","sources":["modules/tournament/schedule/schedule.service.ts"],"names":[],"mappings":"AAMA,qBACa,eAAe;IACxB,OAAO,CAAC,gBAAgB,CAA6B;IACrD,OAAO,CAAC,eAAe,CAA4B;IACnD,OAAO,CAAC,kBAAkB,CAAiC;IAC3D,OAAO,CAAC,mBAAmB,CAAgC;;IAS9C,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;CAyBhD;AAED,eAAO,MAAM,uBAAuB,iBAAiC,CAAC"}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __metadata = (this && this.__metadata) || function (k, v) {
42
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.scheduleDispatchService = exports.ScheduleService = void 0;
46
+ const typedi_1 = __importStar(require("typedi"));
47
+ const config_repository_1 = require("../config/config.repository");
48
+ const match_repository_1 = require("../match/match.repository");
49
+ const notification_template_repository_1 = require("../notification/notification-template.repository");
50
+ const notification_service_1 = require("../notification/notification.service");
51
+ let ScheduleService = class ScheduleService {
52
+ configRepository;
53
+ matchRepository;
54
+ templateRepository;
55
+ notificationService;
56
+ constructor() {
57
+ this.configRepository = typedi_1.default.get(config_repository_1.TournamentConfigRepository);
58
+ this.matchRepository = typedi_1.default.get(match_repository_1.TournamentMatchRepository);
59
+ this.templateRepository = typedi_1.default.get(notification_template_repository_1.NotificationTemplateRepository);
60
+ this.notificationService = typedi_1.default.get(notification_service_1.TournamentNotificationService);
61
+ }
62
+ async dispatchPending() {
63
+ const tournament = await this.configRepository.findActiveFull();
64
+ if (!tournament)
65
+ return;
66
+ const tournamentId = tournament._id;
67
+ const templates = await this.templateRepository.findTemplates(tournamentId);
68
+ const now = Date.now();
69
+ await Promise.all(tournament.matches.map(match => Promise.all(tournament.scheduledNotifications.map(async ({ type, durationMins, target }) => {
70
+ const notificationTime = new Date(match.startingDate).getTime() - durationMins * 60 * 1000;
71
+ const flags = match.notificationFlags;
72
+ if (now < notificationTime)
73
+ return;
74
+ if (flags?.[type] === true)
75
+ return;
76
+ await this.notificationService.dispatchScheduledJob(type, target, templates, tournamentId, match._id);
77
+ await this.matchRepository.setNotificationFlag(tournamentId, match._id, type);
78
+ }))));
79
+ }
80
+ };
81
+ exports.ScheduleService = ScheduleService;
82
+ exports.ScheduleService = ScheduleService = __decorate([
83
+ (0, typedi_1.Service)(),
84
+ __metadata("design:paramtypes", [])
85
+ ], ScheduleService);
86
+ exports.scheduleDispatchService = typedi_1.default.get(ScheduleService);
87
+ //# sourceMappingURL=schedule.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedule.service.js","sourceRoot":"/","sources":["modules/tournament/schedule/schedule.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAC1C,mEAAuE;AACvE,gEAAoE;AACpE,uGAAgG;AAChG,+EAAmF;AAG5E,IAAM,eAAe,GAArB,MAAM,eAAe;IAChB,gBAAgB,CAA6B;IAC7C,eAAe,CAA4B;IAC3C,kBAAkB,CAAiC;IACnD,mBAAmB,CAAgC;IAE3D;QACI,IAAI,CAAC,gBAAgB,GAAG,gBAAS,CAAC,GAAG,CAAC,8CAA0B,CAAC,CAAC;QAClE,IAAI,CAAC,eAAe,GAAG,gBAAS,CAAC,GAAG,CAAC,4CAAyB,CAAC,CAAC;QAChE,IAAI,CAAC,kBAAkB,GAAG,gBAAS,CAAC,GAAG,CAAC,iEAA8B,CAAC,CAAC;QACxE,IAAI,CAAC,mBAAmB,GAAG,gBAAS,CAAC,GAAG,CAAC,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;GACG,eAAe,CAsC3B;AAEY,QAAA,uBAAuB,GAAG,gBAAS,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {TournamentConfigRepository} from '../config/config.repository';\nimport {TournamentMatchRepository} from '../match/match.repository';\nimport {NotificationTemplateRepository} from '../notification/notification-template.repository';\nimport {TournamentNotificationService} from '../notification/notification.service';\n\n@Service()\nexport class ScheduleService {\n private configRepository: TournamentConfigRepository;\n private matchRepository: TournamentMatchRepository;\n private templateRepository: NotificationTemplateRepository;\n private notificationService: TournamentNotificationService;\n\n constructor() {\n this.configRepository = Container.get(TournamentConfigRepository);\n this.matchRepository = Container.get(TournamentMatchRepository);\n this.templateRepository = Container.get(NotificationTemplateRepository);\n this.notificationService = Container.get(TournamentNotificationService);\n }\n\n public async dispatchPending(): Promise<void> {\n const tournament = await this.configRepository.findActiveFull();\n if (!tournament) return;\n\n const tournamentId = tournament._id;\n const templates = await this.templateRepository.findTemplates(tournamentId);\n const now = Date.now();\n\n await Promise.all(\n tournament.matches.map(match =>\n Promise.all(\n tournament.scheduledNotifications.map(async ({type, durationMins, target}) => {\n const notificationTime = new Date(match.startingDate).getTime() - durationMins * 60 * 1000;\n const flags = match.notificationFlags as unknown as Record<string, boolean> | undefined;\n\n if (now < notificationTime) return;\n if (flags?.[type] === true) return;\n\n await this.notificationService.dispatchScheduledJob(type, target, templates, tournamentId, match._id);\n await this.matchRepository.setNotificationFlag(tournamentId, match._id, type);\n })\n )\n )\n );\n }\n}\n\nexport const scheduleDispatchService = Container.get(ScheduleService);\n"]}
@@ -1,6 +1,13 @@
1
+ import { mongoose } from '@typegoose/typegoose';
2
+ import { Tournament as Model } from '@lyxa.ai/core/dist/libraries/mongo/models';
1
3
  export declare class ScoreRepository {
2
- private participantModel;
4
+ private model;
3
5
  constructor();
6
+ findMatchInTournament(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<Model | null>;
7
+ updateMatchScore(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, score: {
8
+ team1: number;
9
+ team2: number;
10
+ }): Promise<Model | null>;
4
11
  }
5
12
  export declare const scoreRepository: ScoreRepository;
6
13
  //# sourceMappingURL=score.repository.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"score.repository.d.ts","sourceRoot":"/","sources":["modules/tournament/score/score.repository.ts"],"names":[],"mappings":"AAGA,qBACa,eAAe;IACxB,OAAO,CAAC,gBAAgB,CAAoC;;CAK/D;AAED,eAAO,MAAM,eAAe,iBAAiC,CAAC"}
1
+ {"version":3,"file":"score.repository.d.ts","sourceRoot":"/","sources":["modules/tournament/score/score.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,UAAU,IAAI,KAAK,EAAkB,MAAM,2CAA2C,CAAC;AAE/F,qBACa,eAAe;IACxB,OAAO,CAAC,KAAK,CAAyB;;IAMhC,qBAAqB,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAMrH,gBAAgB,CAClB,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAChC,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GACxC,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;CAS3B;AAED,eAAO,MAAM,eAAe,iBAAiC,CAAC"}
@@ -46,9 +46,19 @@ exports.scoreRepository = exports.ScoreRepository = void 0;
46
46
  const typedi_1 = __importStar(require("typedi"));
47
47
  const models_1 = require("@lyxa.ai/core/dist/libraries/mongo/models");
48
48
  let ScoreRepository = class ScoreRepository {
49
- participantModel;
49
+ model;
50
50
  constructor() {
51
- this.participantModel = models_1.TournamentParticipantModel;
51
+ this.model = models_1.TournamentModel;
52
+ }
53
+ async findMatchInTournament(tournamentId, matchId) {
54
+ return this.model
55
+ .findOne({ _id: tournamentId, 'matches._id': matchId })
56
+ .lean();
57
+ }
58
+ async updateMatchScore(tournamentId, matchId, score) {
59
+ return this.model
60
+ .findOneAndUpdate({ _id: tournamentId, 'matches._id': matchId }, { $set: { 'matches.$.score': score } }, { new: true })
61
+ .lean();
52
62
  }
53
63
  };
54
64
  exports.ScoreRepository = ScoreRepository;
@@ -1 +1 @@
1
- {"version":3,"file":"score.repository.js","sourceRoot":"/","sources":["modules/tournament/score/score.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAC1C,sEAAqF;AAG9E,IAAM,eAAe,GAArB,MAAM,eAAe;IAChB,gBAAgB,CAAoC;IAE5D;QACI,IAAI,CAAC,gBAAgB,GAAG,mCAA0B,CAAC;IACvD,CAAC;CACJ,CAAA;AANY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,gBAAO,GAAE;;GACG,eAAe,CAM3B;AAEY,QAAA,eAAe,GAAG,gBAAS,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {TournamentParticipantModel} from '@lyxa.ai/core/dist/libraries/mongo/models';\n\n@Service()\nexport class ScoreRepository {\n private participantModel: typeof TournamentParticipantModel;\n\n constructor() {\n this.participantModel = TournamentParticipantModel;\n }\n}\n\nexport const scoreRepository = Container.get(ScoreRepository);\n"]}
1
+ {"version":3,"file":"score.repository.js","sourceRoot":"/","sources":["modules/tournament/score/score.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,sEAA+F;AAGxF,IAAM,eAAe,GAArB,MAAM,eAAe;IAChB,KAAK,CAAyB;IAEtC;QACI,IAAI,CAAC,KAAK,GAAG,wBAAe,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,YAAqC,EAAE,OAAgC;QAC/F,OAAO,IAAI,CAAC,KAAK;aACZ,OAAO,CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC;aACtD,IAAI,EAA2B,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,gBAAgB,CAClB,YAAqC,EACrC,OAAgC,EAChC,KAAuC;QAEvC,OAAO,IAAI,CAAC,KAAK;aACZ,gBAAgB,CACb,EAAE,GAAG,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,EAC7C,EAAC,IAAI,EAAE,EAAC,iBAAiB,EAAE,KAAK,EAAC,EAAC,EAClC,EAAE,GAAG,EAAE,IAAI,EAAE,CAChB;aACA,IAAI,EAA2B,CAAC;IACzC,CAAC;CACJ,CAAA;AA1BY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,gBAAO,GAAE;;GACG,eAAe,CA0B3B;AAEY,QAAA,eAAe,GAAG,gBAAS,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {Tournament as Model, TournamentModel} from '@lyxa.ai/core/dist/libraries/mongo/models';\n\n@Service()\nexport class ScoreRepository {\n private model: typeof TournamentModel;\n\n constructor() {\n this.model = TournamentModel;\n }\n\n async findMatchInTournament(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<Model | null> {\n return this.model\n .findOne({ _id: tournamentId, 'matches._id': matchId })\n .lean() as Promise<Model | null>;\n }\n\n async updateMatchScore(\n tournamentId: mongoose.Types.ObjectId,\n matchId: mongoose.Types.ObjectId,\n score: { team1: number; team2: number },\n ): Promise<Model | null> {\n return this.model\n .findOneAndUpdate(\n { _id: tournamentId, 'matches._id': matchId },\n {$set: {'matches.$.score': score}},\n { new: true }\n )\n .lean() as Promise<Model | null>;\n }\n}\n\nexport const scoreRepository = Container.get(ScoreRepository);\n"]}
@@ -0,0 +1,98 @@
1
+ export declare const scoreRouter: import("@trpc/server").TRPCBuiltRouter<{
2
+ ctx: import("@lyxa.ai/core/dist/libraries/trpc/context").LyxaHTTPContext;
3
+ meta: object;
4
+ errorShape: {
5
+ message: string;
6
+ data: {
7
+ stack: undefined;
8
+ path: undefined;
9
+ code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
10
+ httpStatus: number;
11
+ };
12
+ stack: undefined;
13
+ code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
14
+ };
15
+ transformer: false;
16
+ }, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
17
+ updateMatchScore: import("@trpc/server").TRPCMutationProcedure<{
18
+ input: {
19
+ tournamentId: string | import("mongoose").Types.ObjectId;
20
+ matchId: string | import("mongoose").Types.ObjectId;
21
+ teams: {
22
+ score: number;
23
+ teamId: string | import("mongoose").Types.ObjectId;
24
+ }[];
25
+ };
26
+ output: {
27
+ message: string;
28
+ success: boolean;
29
+ data?: {
30
+ _id: string | import("mongoose").Types.ObjectId;
31
+ team1: {
32
+ name: string;
33
+ teamId: string | import("mongoose").Types.ObjectId;
34
+ picture?: string | undefined;
35
+ };
36
+ team2: {
37
+ name: string;
38
+ teamId: string | import("mongoose").Types.ObjectId;
39
+ picture?: string | undefined;
40
+ };
41
+ score: {
42
+ team1: number | null;
43
+ team2: number | null;
44
+ };
45
+ stage: string;
46
+ endDate?: Date | null | undefined;
47
+ additionalTag?: string | undefined;
48
+ winnerId?: string | import("mongoose").Types.ObjectId | null | undefined;
49
+ startingDate?: Date | null | undefined;
50
+ prediction?: {
51
+ score: {
52
+ team1: number | null;
53
+ team2: number | null;
54
+ };
55
+ succeeded?: boolean | null | undefined;
56
+ } | null | undefined;
57
+ } | {
58
+ documents: {
59
+ _id: string | import("mongoose").Types.ObjectId;
60
+ team1: {
61
+ name: string;
62
+ teamId: string | import("mongoose").Types.ObjectId;
63
+ picture?: string | undefined;
64
+ };
65
+ team2: {
66
+ name: string;
67
+ teamId: string | import("mongoose").Types.ObjectId;
68
+ picture?: string | undefined;
69
+ };
70
+ score: {
71
+ team1: number | null;
72
+ team2: number | null;
73
+ };
74
+ stage: string;
75
+ endDate?: Date | null | undefined;
76
+ additionalTag?: string | undefined;
77
+ winnerId?: string | import("mongoose").Types.ObjectId | null | undefined;
78
+ startingDate?: Date | null | undefined;
79
+ prediction?: {
80
+ score: {
81
+ team1: number | null;
82
+ team2: number | null;
83
+ };
84
+ succeeded?: boolean | null | undefined;
85
+ } | null | undefined;
86
+ }[];
87
+ metadata?: {
88
+ page: number;
89
+ size: number;
90
+ totalElements: number;
91
+ totalPages: number;
92
+ } | undefined;
93
+ } | undefined;
94
+ };
95
+ meta: object;
96
+ }>;
97
+ }>>;
98
+ //# sourceMappingURL=score.router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"score.router.d.ts","sourceRoot":"/","sources":["modules/tournament/score/score.router.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAUtB,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.scoreRouter = void 0;
4
+ const trpc_1 = require("@lyxa.ai/core/dist/libraries/trpc");
5
+ const auth_1 = require("@lyxa.ai/core/dist/libraries/auth");
6
+ const auth_2 = require("@lyxa.ai/core/dist/libraries/trpc/middlewares/auth");
7
+ const error_handler_1 = require("@lyxa.ai/core/dist/utilities/error-handler");
8
+ const response_1 = require("@lyxa.ai/core/dist/utilities/response");
9
+ const score_service_1 = require("./score.service");
10
+ const score_validation_1 = require("./score.validation");
11
+ exports.scoreRouter = (0, trpc_1.createTRPCRouter)({
12
+ updateMatchScore: (0, auth_2.createAuthenticatedProcedure)({ entityTypes: [auth_1.AuthEntityType.CRM] })
13
+ .input(score_validation_1.UpdateMatchScoreSchema)
14
+ .output(score_validation_1.ScoreResponseSchema)
15
+ .mutation(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
16
+ const result = await score_service_1.scoreService.updateMatchScore(input);
17
+ return (0, response_1.response)('Match score updated successfully', result);
18
+ })),
19
+ });
20
+ //# sourceMappingURL=score.router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"score.router.js","sourceRoot":"/","sources":["modules/tournament/score/score.router.ts"],"names":[],"mappings":";;;AAAA,4DAAqE;AACrE,4DAAmE;AACnE,6EAAkG;AAClG,8EAA0E;AAC1E,oEAAiE;AACjE,mDAA0D;AAC1D,yDAAiF;AAEpE,QAAA,WAAW,GAAG,IAAA,uBAAgB,EAAC;IACxC,gBAAgB,EAAE,IAAA,mCAA4B,EAAC,EAAE,WAAW,EAAE,CAAC,qBAAc,CAAC,GAAG,CAAC,EAAE,CAAC;SAChF,KAAK,CAAC,yCAAsB,CAAC;SAC7B,MAAM,CAAC,sCAAmB,CAAC;SAC3B,QAAQ,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAC1B,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,MAAM,MAAM,GAAG,MAAM,4BAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;QACrD,OAAO,IAAA,mBAAQ,EAAC,kCAAkC,EAAE,MAAM,CAAC,CAAC;IAChE,CAAC,CAAC,CACL;CACR,CAAC,CAAC","sourcesContent":["import { createTRPCRouter } from '@lyxa.ai/core/dist/libraries/trpc';\nimport { AuthEntityType } from '@lyxa.ai/core/dist/libraries/auth';\nimport { createAuthenticatedProcedure } from '@lyxa.ai/core/dist/libraries/trpc/middlewares/auth';\nimport { ErrorHandler } from '@lyxa.ai/core/dist/utilities/error-handler';\nimport { response } from '@lyxa.ai/core/dist/utilities/response';\nimport { scoreService as service } from './score.service';\nimport { ScoreResponseSchema, UpdateMatchScoreSchema } from './score.validation';\n\nexport const scoreRouter = createTRPCRouter({\n updateMatchScore: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n .input(UpdateMatchScoreSchema)\n .output(ScoreResponseSchema)\n .mutation(async ({ input }) =>\n ErrorHandler.wrapAsync(async () => {\n const result = await service.updateMatchScore(input);\n return response('Match score updated successfully', result);\n })\n ),\n});\n"]}
@@ -1,6 +1,13 @@
1
+ import { UpdateMatchScoreInputDTO } from './score.validation';
2
+ import { TournamentMatchOutputDTO } from '../match/match.validation';
1
3
  export declare class ScoreService {
2
4
  private repository;
3
5
  constructor();
6
+ private getMatch;
7
+ private resolveScore;
8
+ private resolveWinner;
9
+ private extractUpdatedMatch;
10
+ updateMatchScore(input: UpdateMatchScoreInputDTO): Promise<TournamentMatchOutputDTO>;
4
11
  }
5
12
  export declare const scoreService: ScoreService;
6
13
  //# sourceMappingURL=score.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"score.service.d.ts","sourceRoot":"/","sources":["modules/tournament/score/score.service.ts"],"names":[],"mappings":"AAGA,qBACa,YAAY;IACrB,OAAO,CAAC,UAAU,CAAkB;;CAKvC;AAED,eAAO,MAAM,YAAY,cAA8B,CAAC"}
1
+ {"version":3,"file":"score.service.d.ts","sourceRoot":"/","sources":["modules/tournament/score/score.service.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAErE,qBACa,YAAY;IACrB,OAAO,CAAC,UAAU,CAAkB;;YAMtB,QAAQ;IAQtB,OAAO,CAAC,YAAY;IAuBpB,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,mBAAmB;IASd,gBAAgB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,wBAAwB,CAAC;CASpG;AAED,eAAO,MAAM,YAAY,cAA8B,CAAC"}
@@ -44,12 +44,61 @@ var __metadata = (this && this.__metadata) || function (k, v) {
44
44
  Object.defineProperty(exports, "__esModule", { value: true });
45
45
  exports.scoreService = exports.ScoreService = void 0;
46
46
  const typedi_1 = __importStar(require("typedi"));
47
+ const typegoose_1 = require("@typegoose/typegoose");
48
+ const error_common_1 = require("@lyxa.ai/core/dist/utilities/error-common");
47
49
  const score_repository_1 = require("./score.repository");
48
50
  let ScoreService = class ScoreService {
49
51
  repository;
50
52
  constructor() {
51
53
  this.repository = typedi_1.default.get(score_repository_1.ScoreRepository);
52
54
  }
55
+ async getMatch(tournamentId, matchId) {
56
+ const tournament = await this.repository.findMatchInTournament(tournamentId, matchId);
57
+ if (!tournament)
58
+ throw (0, error_common_1.notFoundError)('Tournament or match not found');
59
+ const match = tournament.matches.find(m => m._id.toString() === matchId.toString());
60
+ if (!match)
61
+ throw (0, error_common_1.notFoundError)('Match not found');
62
+ return { tournament, match };
63
+ }
64
+ resolveScore(match, teams) {
65
+ const positionByTeamId = new Map([
66
+ [match.team1.teamId.toString(), 'team1'],
67
+ [match.team2.teamId.toString(), 'team2'],
68
+ ]);
69
+ const score = {};
70
+ for (const { teamId, score: teamScore } of teams) {
71
+ const position = positionByTeamId.get(teamId.toString());
72
+ if (!position)
73
+ throw (0, error_common_1.badRequestError)(`Team ${teamId} is not part of this match`);
74
+ score[position] = teamScore;
75
+ }
76
+ if (score.team1 === undefined || score.team2 === undefined) {
77
+ throw (0, error_common_1.badRequestError)('Both teams in this match must have a score');
78
+ }
79
+ return { team1: score.team1, team2: score.team2 };
80
+ }
81
+ resolveWinner(match, score) {
82
+ if (score.team1 > score.team2)
83
+ return new typegoose_1.mongoose.Types.ObjectId(match.team1.teamId.toString());
84
+ if (score.team2 > score.team1)
85
+ return new typegoose_1.mongoose.Types.ObjectId(match.team2.teamId.toString());
86
+ return null;
87
+ }
88
+ extractUpdatedMatch(tournament, matchId) {
89
+ const updated = tournament.matches.find(m => m._id.toString() === matchId.toString());
90
+ if (!updated)
91
+ throw (0, error_common_1.notFoundError)('Match not found after update');
92
+ return updated;
93
+ }
94
+ async updateMatchScore(input) {
95
+ const { match } = await this.getMatch(input.tournamentId, input.matchId);
96
+ const score = this.resolveScore(match, input.teams);
97
+ const result = await this.repository.updateMatchScore(input.tournamentId, input.matchId, score);
98
+ if (!result)
99
+ throw (0, error_common_1.notFoundError)('Tournament not found');
100
+ return this.extractUpdatedMatch(result, input.matchId);
101
+ }
53
102
  };
54
103
  exports.ScoreService = ScoreService;
55
104
  exports.ScoreService = ScoreService = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"score.service.js","sourceRoot":"/","sources":["modules/tournament/score/score.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAC1C,yDAAmD;AAG5C,IAAM,YAAY,GAAlB,MAAM,YAAY;IACb,UAAU,CAAkB;IAEpC;QACI,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,kCAAe,CAAC,CAAC;IACrD,CAAC;CACJ,CAAA;AANY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,gBAAO,GAAE;;GACG,YAAY,CAMxB;AAEY,QAAA,YAAY,GAAG,gBAAS,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {ScoreRepository} from './score.repository';\n\n@Service()\nexport class ScoreService {\n private repository: ScoreRepository;\n\n constructor() {\n this.repository = Container.get(ScoreRepository);\n }\n}\n\nexport const scoreService = Container.get(ScoreService);\n"]}
1
+ {"version":3,"file":"score.service.js","sourceRoot":"/","sources":["modules/tournament/score/score.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAC5C,oDAAgD;AAChD,4EAA2F;AAE3F,yDAAqD;AAK9C,IAAM,YAAY,GAAlB,MAAM,YAAY;IACb,UAAU,CAAkB;I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AAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;QAEpD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAChG,IAAI,CAAC,MAAM;YAAE,MAAM,IAAA,4BAAa,EAAC,sBAAsB,CAAC,CAAC;QAEzD,OAAO,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3D,CAAC;CACJ,CAAA;AAjEY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,gBAAO,GAAE;;GACG,YAAY,CAiExB;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 { Tournament as TournamentType } from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport { ScoreRepository } from './score.repository';\nimport { UpdateMatchScoreInputDTO } from './score.validation';\nimport { TournamentMatchOutputDTO } from '../match/match.validation';\n\n@Service()\nexport class ScoreService {\n private repository: ScoreRepository;\n\n constructor() {\n this.repository = Container.get(ScoreRepository);\n }\n\n private async getMatch(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId) {\n const tournament = await this.repository.findMatchInTournament(tournamentId, matchId);\n if (!tournament) throw notFoundError('Tournament or match not found');\n const match = tournament.matches.find(m => m._id.toString() === matchId.toString());\n if (!match) throw notFoundError('Match not found');\n return { tournament, match };\n }\n\n private resolveScore(\n match: TournamentType['matches'][number],\n teams: UpdateMatchScoreInputDTO['teams']\n ): { team1: number; team2: number } {\n const positionByTeamId = new Map([\n [match.team1.teamId.toString(), 'team1' as const],\n [match.team2.teamId.toString(), 'team2' as const],\n ]);\n\n const score: Partial<{ team1: number; team2: number }> = {};\n for (const { teamId, score: teamScore } of teams) {\n const position = positionByTeamId.get(teamId.toString());\n if (!position) throw badRequestError(`Team ${teamId} is not part of this match`);\n score[position] = teamScore;\n }\n\n if (score.team1 === undefined || score.team2 === undefined) {\n throw badRequestError('Both teams in this match must have a score');\n }\n\n return { team1: score.team1, team2: score.team2 };\n }\n\n private resolveWinner(\n match: TournamentType['matches'][number],\n score: { team1: number; team2: number }\n ): mongoose.Types.ObjectId | null {\n if (score.team1 > score.team2) return new mongoose.Types.ObjectId(match.team1.teamId.toString());\n if (score.team2 > score.team1) return new mongoose.Types.ObjectId(match.team2.teamId.toString());\n return null;\n }\n\n private extractUpdatedMatch(\n tournament: TournamentType,\n matchId: mongoose.Types.ObjectId\n ): TournamentMatchOutputDTO {\n const updated = tournament.matches.find(m => m._id.toString() === matchId.toString());\n if (!updated) throw notFoundError('Match not found after update');\n return updated as TournamentMatchOutputDTO;\n }\n\n public async updateMatchScore(input: UpdateMatchScoreInputDTO): Promise<TournamentMatchOutputDTO> {\n const { match } = await this.getMatch(input.tournamentId, input.matchId);\n const score = this.resolveScore(match, input.teams);\n\n const result = await this.repository.updateMatchScore(input.tournamentId, input.matchId, score);\n if (!result) throw notFoundError('Tournament not found');\n\n return this.extractUpdatedMatch(result, input.matchId);\n }\n}\n\nexport const scoreService = Container.get(ScoreService);\n"]}