@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.
- package/dist/lib/index.d.ts +265 -21
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/modules/tournament/config/config.repository.d.ts +3 -0
- package/dist/lib/modules/tournament/config/config.repository.d.ts.map +1 -1
- package/dist/lib/modules/tournament/config/config.repository.js +3 -0
- package/dist/lib/modules/tournament/config/config.repository.js.map +1 -1
- package/dist/lib/modules/tournament/config/config.router.d.ts +10 -10
- package/dist/lib/modules/tournament/config/config.validation.d.ts +37 -36
- package/dist/lib/modules/tournament/config/config.validation.d.ts.map +1 -1
- package/dist/lib/modules/tournament/config/config.validation.js +4 -3
- package/dist/lib/modules/tournament/config/config.validation.js.map +1 -1
- package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.d.ts.map +1 -1
- package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js +9 -1
- package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js.map +1 -1
- package/dist/lib/modules/tournament/match/match.builder.d.ts.map +1 -1
- package/dist/lib/modules/tournament/match/match.builder.js +2 -1
- package/dist/lib/modules/tournament/match/match.builder.js.map +1 -1
- package/dist/lib/modules/tournament/match/match.repository.d.ts +2 -0
- package/dist/lib/modules/tournament/match/match.repository.d.ts.map +1 -1
- package/dist/lib/modules/tournament/match/match.repository.js +10 -0
- package/dist/lib/modules/tournament/match/match.repository.js.map +1 -1
- package/dist/lib/modules/tournament/match/match.router.d.ts +16 -4
- package/dist/lib/modules/tournament/match/match.router.d.ts.map +1 -1
- package/dist/lib/modules/tournament/match/match.service.d.ts +0 -1
- package/dist/lib/modules/tournament/match/match.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/match/match.service.js +3 -9
- package/dist/lib/modules/tournament/match/match.service.js.map +1 -1
- package/dist/lib/modules/tournament/match/match.validation.d.ts +50 -0
- package/dist/lib/modules/tournament/match/match.validation.d.ts.map +1 -1
- package/dist/lib/modules/tournament/match/match.validation.js +1 -0
- package/dist/lib/modules/tournament/match/match.validation.js.map +1 -1
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts +2 -5
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts.map +1 -1
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.js +1 -6
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.js.map +1 -1
- package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts +2 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts.map +1 -1
- package/dist/lib/modules/tournament/notification/jobs/notification.worker.js +15 -9
- package/dist/lib/modules/tournament/notification/jobs/notification.worker.js.map +1 -1
- package/dist/lib/modules/tournament/notification/notification-template.repository.d.ts +8 -0
- package/dist/lib/modules/tournament/notification/notification-template.repository.d.ts.map +1 -0
- package/dist/lib/modules/tournament/notification/notification-template.repository.js +60 -0
- package/dist/lib/modules/tournament/notification/notification-template.repository.js.map +1 -0
- package/dist/lib/modules/tournament/notification/notification.config.d.ts +10 -0
- package/dist/lib/modules/tournament/notification/notification.config.d.ts.map +1 -0
- package/dist/lib/modules/tournament/notification/notification.config.js +15 -0
- package/dist/lib/modules/tournament/notification/notification.config.js.map +1 -0
- package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts +10 -0
- package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts.map +1 -0
- package/dist/lib/modules/tournament/notification/notification.schedule.config.js +15 -0
- package/dist/lib/modules/tournament/notification/notification.schedule.config.js.map +1 -0
- package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts +4 -4
- package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/notification/notification.scheduler.service.js +15 -28
- package/dist/lib/modules/tournament/notification/notification.scheduler.service.js.map +1 -1
- package/dist/lib/modules/tournament/notification/notification.service.d.ts +5 -4
- package/dist/lib/modules/tournament/notification/notification.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/notification/notification.service.js +33 -28
- package/dist/lib/modules/tournament/notification/notification.service.js.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.repository.d.ts +3 -0
- package/dist/lib/modules/tournament/participant/participant.repository.d.ts.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.repository.js +14 -0
- package/dist/lib/modules/tournament/participant/participant.repository.js.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.router.d.ts +27 -4
- package/dist/lib/modules/tournament/participant/participant.router.d.ts.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.router.js +7 -0
- package/dist/lib/modules/tournament/participant/participant.router.js.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.service.d.ts +2 -2
- package/dist/lib/modules/tournament/participant/participant.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.service.js +20 -6
- package/dist/lib/modules/tournament/participant/participant.service.js.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.validation.d.ts +144 -36
- package/dist/lib/modules/tournament/participant/participant.validation.d.ts.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.validation.js +10 -3
- package/dist/lib/modules/tournament/participant/participant.validation.js.map +1 -1
- package/dist/lib/modules/tournament/prediction/prediction.builder.d.ts.map +1 -1
- package/dist/lib/modules/tournament/prediction/prediction.builder.js +3 -2
- package/dist/lib/modules/tournament/prediction/prediction.builder.js.map +1 -1
- package/dist/lib/modules/tournament/prediction/prediction.service.d.ts +1 -0
- package/dist/lib/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/prediction/prediction.service.js +12 -1
- package/dist/lib/modules/tournament/prediction/prediction.service.js.map +1 -1
- package/dist/lib/modules/tournament/reward/reward.builder.d.ts.map +1 -1
- package/dist/lib/modules/tournament/reward/reward.builder.js +2 -1
- package/dist/lib/modules/tournament/reward/reward.builder.js.map +1 -1
- package/dist/lib/modules/tournament/reward/reward.repository.d.ts +8 -0
- package/dist/lib/modules/tournament/reward/reward.repository.d.ts.map +1 -0
- package/dist/lib/modules/tournament/reward/reward.repository.js +66 -0
- package/dist/lib/modules/tournament/reward/reward.repository.js.map +1 -0
- package/dist/lib/modules/tournament/schedule/schedule.router.d.ts +27 -0
- package/dist/lib/modules/tournament/schedule/schedule.router.d.ts.map +1 -0
- package/dist/lib/modules/tournament/schedule/schedule.router.js +17 -0
- package/dist/lib/modules/tournament/schedule/schedule.router.js.map +1 -0
- package/dist/lib/modules/tournament/schedule/schedule.service.d.ts +10 -0
- package/dist/lib/modules/tournament/schedule/schedule.service.d.ts.map +1 -0
- package/dist/lib/modules/tournament/schedule/schedule.service.js +87 -0
- package/dist/lib/modules/tournament/schedule/schedule.service.js.map +1 -0
- package/dist/lib/modules/tournament/score/score.repository.d.ts +8 -1
- package/dist/lib/modules/tournament/score/score.repository.d.ts.map +1 -1
- package/dist/lib/modules/tournament/score/score.repository.js +12 -2
- package/dist/lib/modules/tournament/score/score.repository.js.map +1 -1
- package/dist/lib/modules/tournament/score/score.router.d.ts +98 -0
- package/dist/lib/modules/tournament/score/score.router.d.ts.map +1 -0
- package/dist/lib/modules/tournament/score/score.router.js +20 -0
- package/dist/lib/modules/tournament/score/score.router.js.map +1 -0
- package/dist/lib/modules/tournament/score/score.service.d.ts +7 -0
- package/dist/lib/modules/tournament/score/score.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/score/score.service.js +49 -0
- package/dist/lib/modules/tournament/score/score.service.js.map +1 -1
- package/dist/lib/modules/tournament/score/score.validation.d.ts +375 -0
- package/dist/lib/modules/tournament/score/score.validation.d.ts.map +1 -0
- package/dist/lib/modules/tournament/score/score.validation.js +19 -0
- package/dist/lib/modules/tournament/score/score.validation.js.map +1 -0
- package/dist/lib/modules/tournament/statistics/statistics.builder.d.ts +10 -0
- package/dist/lib/modules/tournament/statistics/statistics.builder.d.ts.map +1 -0
- package/dist/lib/modules/tournament/statistics/statistics.builder.js +53 -0
- package/dist/lib/modules/tournament/statistics/statistics.builder.js.map +1 -0
- package/dist/lib/modules/tournament/statistics/statistics.router.d.ts +80 -0
- package/dist/lib/modules/tournament/statistics/statistics.router.d.ts.map +1 -0
- package/dist/lib/modules/tournament/statistics/statistics.router.js +21 -0
- package/dist/lib/modules/tournament/statistics/statistics.router.js.map +1 -0
- package/dist/lib/modules/tournament/statistics/statistics.service.d.ts +11 -0
- package/dist/lib/modules/tournament/statistics/statistics.service.d.ts.map +1 -0
- package/dist/lib/modules/tournament/statistics/statistics.service.js +80 -0
- package/dist/lib/modules/tournament/statistics/statistics.service.js.map +1 -0
- package/dist/lib/modules/tournament/statistics/statistics.validation.d.ts +404 -0
- package/dist/lib/modules/tournament/statistics/statistics.validation.d.ts.map +1 -0
- package/dist/lib/modules/tournament/statistics/statistics.validation.js +36 -0
- package/dist/lib/modules/tournament/statistics/statistics.validation.js.map +1 -0
- package/dist/lib/modules/tournament/team/team.router.d.ts +9 -3
- package/dist/lib/modules/tournament/team/team.router.d.ts.map +1 -1
- package/dist/lib/modules/tournament/team/team.service.d.ts +1 -0
- package/dist/lib/modules/tournament/team/team.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/team/team.service.js +23 -16
- package/dist/lib/modules/tournament/team/team.service.js.map +1 -1
- package/dist/lib/modules/tournament/team/team.validation.d.ts +54 -4
- package/dist/lib/modules/tournament/team/team.validation.d.ts.map +1 -1
- package/dist/lib/modules/tournament/team/team.validation.js +4 -2
- package/dist/lib/modules/tournament/team/team.validation.js.map +1 -1
- package/dist/lib/modules/tournament/tournament.router.d.ts +370 -125
- package/dist/lib/modules/tournament/tournament.router.d.ts.map +1 -1
- package/dist/lib/modules/tournament/tournament.router.js +13 -2
- package/dist/lib/modules/tournament/tournament.router.js.map +1 -1
- package/dist/lib/modules/tournament/tournament.service.d.ts +3 -1
- package/dist/lib/modules/tournament/tournament.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/tournament.service.js +17 -2
- package/dist/lib/modules/tournament/tournament.service.js.map +1 -1
- package/dist/lib/modules/tournament/tournament.types.d.ts +14 -0
- package/dist/lib/modules/tournament/tournament.types.d.ts.map +1 -0
- package/dist/lib/modules/tournament/tournament.types.js +20 -0
- package/dist/lib/modules/tournament/tournament.types.js.map +1 -0
- package/dist/lib/modules/tournament/tournament.utils.d.ts +2 -0
- package/dist/lib/modules/tournament/tournament.utils.d.ts.map +1 -0
- package/dist/lib/modules/tournament/tournament.utils.js +6 -0
- package/dist/lib/modules/tournament/tournament.utils.js.map +1 -0
- package/dist/lib/modules/tournament/tournament.validation.d.ts +15 -0
- package/dist/lib/modules/tournament/tournament.validation.d.ts.map +1 -1
- package/dist/lib/modules/tournament/tournament.validation.js +4 -1
- package/dist/lib/modules/tournament/tournament.validation.js.map +1 -1
- package/dist/types/index.d.ts +265 -21
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/tournament/config/config.repository.d.ts +3 -0
- package/dist/types/modules/tournament/config/config.repository.d.ts.map +1 -1
- package/dist/types/modules/tournament/config/config.router.d.ts +10 -10
- package/dist/types/modules/tournament/config/config.validation.d.ts +37 -36
- package/dist/types/modules/tournament/config/config.validation.d.ts.map +1 -1
- package/dist/types/modules/tournament/match/events/evaluate-predictions.consumer.d.ts.map +1 -1
- package/dist/types/modules/tournament/match/match.builder.d.ts.map +1 -1
- package/dist/types/modules/tournament/match/match.repository.d.ts +2 -0
- package/dist/types/modules/tournament/match/match.repository.d.ts.map +1 -1
- package/dist/types/modules/tournament/match/match.router.d.ts +16 -4
- package/dist/types/modules/tournament/match/match.router.d.ts.map +1 -1
- package/dist/types/modules/tournament/match/match.service.d.ts +0 -1
- package/dist/types/modules/tournament/match/match.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/match/match.validation.d.ts +50 -0
- package/dist/types/modules/tournament/match/match.validation.d.ts.map +1 -1
- package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts +2 -5
- package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts.map +1 -1
- package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts +2 -0
- package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts.map +1 -1
- package/dist/types/modules/tournament/notification/notification-template.repository.d.ts +8 -0
- package/dist/types/modules/tournament/notification/notification-template.repository.d.ts.map +1 -0
- package/dist/types/modules/tournament/notification/notification.config.d.ts +10 -0
- package/dist/types/modules/tournament/notification/notification.config.d.ts.map +1 -0
- package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts +10 -0
- package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts.map +1 -0
- package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts +4 -4
- package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/notification/notification.service.d.ts +5 -4
- package/dist/types/modules/tournament/notification/notification.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/participant/participant.repository.d.ts +3 -0
- package/dist/types/modules/tournament/participant/participant.repository.d.ts.map +1 -1
- package/dist/types/modules/tournament/participant/participant.router.d.ts +27 -4
- package/dist/types/modules/tournament/participant/participant.router.d.ts.map +1 -1
- package/dist/types/modules/tournament/participant/participant.service.d.ts +2 -2
- package/dist/types/modules/tournament/participant/participant.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/participant/participant.validation.d.ts +144 -36
- package/dist/types/modules/tournament/participant/participant.validation.d.ts.map +1 -1
- package/dist/types/modules/tournament/prediction/prediction.builder.d.ts.map +1 -1
- package/dist/types/modules/tournament/prediction/prediction.service.d.ts +1 -0
- package/dist/types/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/reward/reward.builder.d.ts.map +1 -1
- package/dist/types/modules/tournament/reward/reward.repository.d.ts +8 -0
- package/dist/types/modules/tournament/reward/reward.repository.d.ts.map +1 -0
- package/dist/types/modules/tournament/schedule/schedule.router.d.ts +27 -0
- package/dist/types/modules/tournament/schedule/schedule.router.d.ts.map +1 -0
- package/dist/types/modules/tournament/schedule/schedule.service.d.ts +10 -0
- package/dist/types/modules/tournament/schedule/schedule.service.d.ts.map +1 -0
- package/dist/types/modules/tournament/score/score.repository.d.ts +8 -1
- package/dist/types/modules/tournament/score/score.repository.d.ts.map +1 -1
- package/dist/types/modules/tournament/score/score.router.d.ts +98 -0
- package/dist/types/modules/tournament/score/score.router.d.ts.map +1 -0
- package/dist/types/modules/tournament/score/score.service.d.ts +7 -0
- package/dist/types/modules/tournament/score/score.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/score/score.validation.d.ts +375 -0
- package/dist/types/modules/tournament/score/score.validation.d.ts.map +1 -0
- package/dist/types/modules/tournament/statistics/statistics.builder.d.ts +10 -0
- package/dist/types/modules/tournament/statistics/statistics.builder.d.ts.map +1 -0
- package/dist/types/modules/tournament/statistics/statistics.router.d.ts +80 -0
- package/dist/types/modules/tournament/statistics/statistics.router.d.ts.map +1 -0
- package/dist/types/modules/tournament/statistics/statistics.service.d.ts +11 -0
- package/dist/types/modules/tournament/statistics/statistics.service.d.ts.map +1 -0
- package/dist/types/modules/tournament/statistics/statistics.validation.d.ts +404 -0
- package/dist/types/modules/tournament/statistics/statistics.validation.d.ts.map +1 -0
- package/dist/types/modules/tournament/team/team.router.d.ts +9 -3
- package/dist/types/modules/tournament/team/team.router.d.ts.map +1 -1
- package/dist/types/modules/tournament/team/team.service.d.ts +1 -0
- package/dist/types/modules/tournament/team/team.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/team/team.validation.d.ts +54 -4
- package/dist/types/modules/tournament/team/team.validation.d.ts.map +1 -1
- package/dist/types/modules/tournament/tournament.router.d.ts +370 -125
- package/dist/types/modules/tournament/tournament.router.d.ts.map +1 -1
- package/dist/types/modules/tournament/tournament.service.d.ts +3 -1
- package/dist/types/modules/tournament/tournament.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/tournament.types.d.ts +14 -0
- package/dist/types/modules/tournament/tournament.types.d.ts.map +1 -0
- package/dist/types/modules/tournament/tournament.utils.d.ts +2 -0
- package/dist/types/modules/tournament/tournament.utils.d.ts.map +1 -0
- package/dist/types/modules/tournament/tournament.validation.d.ts +15 -0
- package/dist/types/modules/tournament/tournament.validation.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ScheduledTarget = exports.NotificationTag = void 0;
|
|
4
|
+
var NotificationTag;
|
|
5
|
+
(function (NotificationTag) {
|
|
6
|
+
NotificationTag["TOURNAMENT_ACTIVATION"] = "tournament-activation";
|
|
7
|
+
NotificationTag["MATCH_RESULT_WINNER"] = "match-result-winner";
|
|
8
|
+
NotificationTag["MATCH_RESULT_LOSER"] = "match-result-loser";
|
|
9
|
+
})(NotificationTag || (exports.NotificationTag = NotificationTag = {}));
|
|
10
|
+
var ScheduledTarget;
|
|
11
|
+
(function (ScheduledTarget) {
|
|
12
|
+
ScheduledTarget["GLOBAL"] = "global";
|
|
13
|
+
ScheduledTarget["UNPREDICTED_PARTICIPANTS"] = "unpredicted-participants";
|
|
14
|
+
})(ScheduledTarget || (exports.ScheduledTarget = ScheduledTarget = {}));
|
|
15
|
+
//# sourceMappingURL=notification.schedule.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.schedule.config.js","sourceRoot":"/","sources":["modules/tournament/notification/notification.schedule.config.ts"],"names":[],"mappings":";;;AAAA,IAAY,eAIX;AAJD,WAAY,eAAe;IACvB,kEAA+C,CAAA;IAC/C,8DAA2C,CAAA;IAC3C,4DAAyC,CAAA;AAC7C,CAAC,EAJW,eAAe,+BAAf,eAAe,QAI1B;AAED,IAAY,eAGX;AAHD,WAAY,eAAe;IACvB,oCAAiB,CAAA;IACjB,wEAAqD,CAAA;AACzD,CAAC,EAHW,eAAe,+BAAf,eAAe,QAG1B","sourcesContent":["export enum NotificationTag {\n TOURNAMENT_ACTIVATION = 'tournament-activation',\n MATCH_RESULT_WINNER = 'match-result-winner',\n MATCH_RESULT_LOSER = 'match-result-loser',\n}\n\nexport enum ScheduledTarget {\n GLOBAL = 'global',\n UNPREDICTED_PARTICIPANTS = 'unpredicted-participants',\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { mongoose } from '@typegoose/typegoose';
|
|
2
|
+
import { ScheduledNotificationConfig } from '@lyxa.ai/core/dist/libraries/mongo/models';
|
|
2
3
|
export declare class NotificationSchedulerService {
|
|
3
|
-
private
|
|
4
|
-
private jobId15min;
|
|
4
|
+
private jobId;
|
|
5
5
|
private buildJobData;
|
|
6
|
-
scheduleForMatch(matchId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId, startingDate: Date): Promise<void>;
|
|
7
|
-
cancelForMatch(matchId: mongoose.Types.ObjectId): Promise<void>;
|
|
6
|
+
scheduleForMatch(matchId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId, startingDate: Date, scheduledNotifications: ScheduledNotificationConfig[]): Promise<void>;
|
|
7
|
+
cancelForMatch(matchId: mongoose.Types.ObjectId, scheduledNotifications: ScheduledNotificationConfig[]): Promise<void>;
|
|
8
8
|
}
|
|
9
9
|
export declare const notificationSchedulerService: NotificationSchedulerService;
|
|
10
10
|
//# sourceMappingURL=notification.scheduler.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.scheduler.service.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification.scheduler.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"notification.scheduler.service.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification.scheduler.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAC;AAGxF,qBACa,4BAA4B;IACrC,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,YAAY;IAIP,gBAAgB,CACzB,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAChC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,YAAY,EAAE,IAAI,EAClB,sBAAsB,EAAE,2BAA2B,EAAE,GACtD,OAAO,CAAC,IAAI,CAAC;IAcH,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAGtI;AAED,eAAO,MAAM,4BAA4B,8BAA8C,CAAC"}
|
|
@@ -42,40 +42,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
42
42
|
exports.notificationSchedulerService = exports.NotificationSchedulerService = void 0;
|
|
43
43
|
const typedi_1 = __importStar(require("typedi"));
|
|
44
44
|
const notification_producer_1 = require("./jobs/notification.producer");
|
|
45
|
-
const THREE_HOURS_MS = 3 * 60 * 60 * 1000;
|
|
46
|
-
const FIFTEEN_MINUTES_MS = 15 * 60 * 1000;
|
|
47
45
|
let NotificationSchedulerService = class NotificationSchedulerService {
|
|
48
|
-
|
|
49
|
-
return `tournament
|
|
46
|
+
jobId(type, matchId) {
|
|
47
|
+
return `tournament-${type}-${matchId}`;
|
|
50
48
|
}
|
|
51
|
-
|
|
52
|
-
return
|
|
49
|
+
buildJobData(tournamentId, matchId, target) {
|
|
50
|
+
return { tournamentId: tournamentId.toString(), matchId: matchId.toString(), target };
|
|
53
51
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
delay: delay3h,
|
|
63
|
-
jobId: this.jobId3h(matchId),
|
|
64
|
-
removeOnComplete: true,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
const delay15min = startingDate.getTime() - FIFTEEN_MINUTES_MS - Date.now();
|
|
68
|
-
if (delay15min > 0) {
|
|
69
|
-
await (0, notification_producer_1.addNotificationJob)(notification_producer_1.TournamentNotificationJobName.NOTIFY_15MIN_BEFORE, data, {
|
|
70
|
-
delay: delay15min,
|
|
71
|
-
jobId: this.jobId15min(matchId),
|
|
52
|
+
async scheduleForMatch(matchId, tournamentId, startingDate, scheduledNotifications) {
|
|
53
|
+
await Promise.all(scheduledNotifications.map(({ type, durationMins, target }) => {
|
|
54
|
+
const delay = startingDate.getTime() - durationMins * 60 * 1000 - Date.now();
|
|
55
|
+
if (delay <= 0)
|
|
56
|
+
return Promise.resolve();
|
|
57
|
+
return (0, notification_producer_1.addNotificationJob)(type, this.buildJobData(tournamentId, matchId, target), {
|
|
58
|
+
delay,
|
|
59
|
+
jobId: this.jobId(type, matchId),
|
|
72
60
|
removeOnComplete: true,
|
|
73
61
|
});
|
|
74
|
-
}
|
|
62
|
+
}));
|
|
75
63
|
}
|
|
76
|
-
async cancelForMatch(matchId) {
|
|
77
|
-
await (0, notification_producer_1.removeNotificationJob)(this.
|
|
78
|
-
await (0, notification_producer_1.removeNotificationJob)(this.jobId15min(matchId));
|
|
64
|
+
async cancelForMatch(matchId, scheduledNotifications) {
|
|
65
|
+
await Promise.all(scheduledNotifications.map(({ type }) => (0, notification_producer_1.removeNotificationJob)(this.jobId(type, matchId))));
|
|
79
66
|
}
|
|
80
67
|
};
|
|
81
68
|
exports.NotificationSchedulerService = NotificationSchedulerService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.scheduler.service.js","sourceRoot":"/","sources":["modules/tournament/notification/notification.scheduler.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;
|
|
1
|
+
{"version":3,"file":"notification.scheduler.service.js","sourceRoot":"/","sources":["modules/tournament/notification/notification.scheduler.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAG5C,wEAA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,CAAC,CAAC,CAAC,CAAC;IAClH,CAAC;CACJ,CAAA;AA/BY,oEAA4B;uCAA5B,4BAA4B;IADxC,IAAA,gBAAO,GAAE;GACG,4BAA4B,CA+BxC;AAEY,QAAA,4BAA4B,GAAG,gBAAS,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport { ScheduledNotificationConfig } from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport { addNotificationJob, removeNotificationJob, TournamentNotificationJobData } from './jobs/notification.producer';\n\n@Service()\nexport class NotificationSchedulerService {\n private jobId(type: string, matchId: mongoose.Types.ObjectId): string {\n return `tournament-${type}-${matchId}`;\n }\n\n private buildJobData(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, target: string): TournamentNotificationJobData {\n return { tournamentId: tournamentId.toString(), matchId: matchId.toString(), target };\n }\n\n public async scheduleForMatch(\n matchId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId,\n startingDate: Date,\n scheduledNotifications: ScheduledNotificationConfig[]\n ): Promise<void> {\n await Promise.all(\n scheduledNotifications.map(({ type, durationMins, target }) => {\n const delay = startingDate.getTime() - durationMins * 60 * 1000 - Date.now();\n if (delay <= 0) return Promise.resolve();\n return addNotificationJob(type, this.buildJobData(tournamentId, matchId, target), {\n delay,\n jobId: this.jobId(type, matchId),\n removeOnComplete: true,\n });\n })\n );\n }\n\n public async cancelForMatch(matchId: mongoose.Types.ObjectId, scheduledNotifications: ScheduledNotificationConfig[]): Promise<void> {\n await Promise.all(scheduledNotifications.map(({ type }) => removeNotificationJob(this.jobId(type, matchId))));\n }\n}\n\nexport const notificationSchedulerService = Container.get(NotificationSchedulerService);\n"]}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { mongoose } from '@typegoose/typegoose';
|
|
2
|
+
import { NotificationMessage } from '@lyxa.ai/core/dist/libraries/mongo/models';
|
|
2
3
|
export declare class TournamentNotificationService {
|
|
3
4
|
private participantService;
|
|
4
5
|
constructor();
|
|
6
|
+
private getTemplate;
|
|
5
7
|
private hasNotPredicted;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
notifyMatchResult(winnerIds: mongoose.Types.ObjectId[], loserIds: mongoose.Types.ObjectId[]): Promise<void>;
|
|
8
|
+
notifyGlobal(title: string, body: string): Promise<void>;
|
|
9
|
+
notifyUsers(title: string, body: string, userIds: mongoose.Types.ObjectId[]): Promise<void>;
|
|
10
|
+
dispatchScheduledJob(type: string, target: string, templates: Map<string, NotificationMessage>, tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<void>;
|
|
10
11
|
}
|
|
11
12
|
export declare const tournamentNotificationService: TournamentNotificationService;
|
|
12
13
|
//# sourceMappingURL=notification.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.service.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification.service.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"notification.service.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAI9C,OAAO,EAAC,mBAAmB,EAAC,MAAM,2CAA2C,CAAC;AAK9E,qBACa,6BAA6B;IACtC,OAAO,CAAC,kBAAkB,CAAqB;;IAM/C,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,eAAe;IAIV,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBxD,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAqB3F,oBAAoB,CAC7B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAC3C,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GACjC,OAAO,CAAC,IAAI,CAAC;CAWnB;AAED,eAAO,MAAM,6BAA6B,+BAA+C,CAAC"}
|
|
@@ -48,53 +48,58 @@ const event_1 = require("@lyxa.ai/core/dist/libraries/event");
|
|
|
48
48
|
const notification_1 = require("@lyxa.ai/core/dist/libraries/notification");
|
|
49
49
|
const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
|
|
50
50
|
const participant_service_1 = require("../participant/participant.service");
|
|
51
|
+
const notification_config_1 = require("./notification.config");
|
|
51
52
|
let TournamentNotificationService = class TournamentNotificationService {
|
|
52
53
|
participantService;
|
|
53
54
|
constructor() {
|
|
54
55
|
this.participantService = typedi_1.default.get(participant_service_1.ParticipantService);
|
|
55
56
|
}
|
|
57
|
+
getTemplate(templates, tag) {
|
|
58
|
+
const t = templates.get(tag);
|
|
59
|
+
if (!t)
|
|
60
|
+
throw new Error(`No notification template for tag: ${tag}`);
|
|
61
|
+
return t;
|
|
62
|
+
}
|
|
56
63
|
hasNotPredicted(participant, matchId) {
|
|
57
64
|
return !participant.predictions.some(p => p.matchId.toString() === matchId.toString());
|
|
58
65
|
}
|
|
59
|
-
async
|
|
60
|
-
await (0, event_1.publishEvent)(new notification_1.
|
|
66
|
+
async notifyGlobal(title, body) {
|
|
67
|
+
await (0, event_1.publishEvent)(new notification_1.NotificationGlobalEvent({
|
|
61
68
|
title,
|
|
62
69
|
body,
|
|
63
70
|
data: {
|
|
64
71
|
saveNotification: true,
|
|
65
72
|
accountType: enum_1.NotificationAccountType.USER,
|
|
66
|
-
|
|
67
|
-
isGlobal: false,
|
|
73
|
+
isGlobal: true,
|
|
68
74
|
isClickable: true,
|
|
69
75
|
clickType: enum_1.ClickType.CLICKABLE_FALLBACK,
|
|
70
76
|
},
|
|
71
77
|
}));
|
|
72
78
|
}
|
|
73
|
-
async
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
async notifyUsers(title, body, userIds) {
|
|
80
|
+
await Promise.all(userIds.map(recipientId => (0, event_1.publishEvent)(new notification_1.NotificationEvent({
|
|
81
|
+
title,
|
|
82
|
+
body,
|
|
83
|
+
data: {
|
|
84
|
+
saveNotification: true,
|
|
85
|
+
accountType: enum_1.NotificationAccountType.USER,
|
|
86
|
+
recipientId,
|
|
87
|
+
isGlobal: false,
|
|
88
|
+
isClickable: true,
|
|
89
|
+
clickType: enum_1.ClickType.CLICKABLE_FALLBACK,
|
|
90
|
+
},
|
|
91
|
+
}))));
|
|
81
92
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
async notifyMatchResult(winnerIds, loserIds) {
|
|
93
|
-
const { winner, loser } = this.matchResultTemplates;
|
|
94
|
-
await Promise.all([
|
|
95
|
-
...winnerIds.map(id => this.publishNotification(id, winner.title, winner.body)),
|
|
96
|
-
...loserIds.map(id => this.publishNotification(id, loser.title, loser.body)),
|
|
97
|
-
]);
|
|
93
|
+
async dispatchScheduledJob(type, target, templates, tournamentId, matchId) {
|
|
94
|
+
const { title, body } = this.getTemplate(templates, type);
|
|
95
|
+
if (target === notification_config_1.ScheduledTarget.GLOBAL) {
|
|
96
|
+
await this.notifyGlobal(title, body);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
const participants = await this.participantService.getAll(tournamentId);
|
|
100
|
+
const unpredicted = participants.filter(p => this.hasNotPredicted(p, matchId));
|
|
101
|
+
await this.notifyUsers(title, body, unpredicted.map(p => p.userId));
|
|
102
|
+
}
|
|
98
103
|
}
|
|
99
104
|
};
|
|
100
105
|
exports.TournamentNotificationService = TournamentNotificationService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.service.js","sourceRoot":"/","sources":["modules/tournament/notification/notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"notification.service.js","sourceRoot":"/","sources":["modules/tournament/notification/notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,8DAAgE;AAChE,4EAAqG;AACrG,4DAAqF;AAErF,4EAAsE;AAEtE,+DAAsD;AAG/C,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IAC9B,kBAAkB,CAAqB;IAE/C;QACI,IAAI,CAAC,kBAAkB,GAAG,gBAAS,CAAC,GAAG,CAAC,wCAAkB,CAAC,CAAC;IAChE,CAAC;IAEO,WAAW,CAAC,SAA2C,EAAE,GAAW;QACxE,MAAM,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,CAAC,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,GAAG,EAAE,CAAC,CAAC;QACpE,OAAO,CAAC,CAAC;IACb,CAAC;IAEO,eAAe,CAAC,WAA2C,EAAE,OAAgC;QACjG,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC3F,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,KAAa,EAAE,IAAY;QACjD,MAAM,IAAA,oBAAY,EACd,IAAI,sCAAuB,CAAC;YACxB,KAAK;YACL,IAAI;YACJ,IAAI,EAAE;gBACF,gBAAgB,EAAE,IAAI;gBACtB,WAAW,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CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;QACxE,CAAC;IACL,CAAC;CACJ,CAAA;AAvEY,sEAA6B;wCAA7B,6BAA6B;IADzC,IAAA,gBAAO,GAAE;;GACG,6BAA6B,CAuEzC;AAEY,QAAA,6BAA6B,GAAG,gBAAS,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {publishEvent} from '@lyxa.ai/core/dist/libraries/event';\nimport {NotificationEvent, NotificationGlobalEvent} from '@lyxa.ai/core/dist/libraries/notification';\nimport {ClickType, NotificationAccountType} from '@lyxa.ai/core/dist/utilities/enum';\nimport {NotificationMessage} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {ParticipantService} from '../participant/participant.service';\nimport {TournamentParticipantOutputDTO} from '../participant/participant.validation';\nimport {ScheduledTarget} from './notification.config';\n\n@Service()\nexport class TournamentNotificationService {\n private participantService: ParticipantService;\n\n constructor() {\n this.participantService = Container.get(ParticipantService);\n }\n\n private getTemplate(templates: Map<string, NotificationMessage>, tag: string): NotificationMessage {\n const t = templates.get(tag);\n if (!t) throw new Error(`No notification template for tag: ${tag}`);\n return t;\n }\n\n private hasNotPredicted(participant: TournamentParticipantOutputDTO, matchId: mongoose.Types.ObjectId): boolean {\n return !participant.predictions.some(p => p.matchId.toString() === matchId.toString());\n }\n\n public async notifyGlobal(title: string, body: string): Promise<void> {\n await publishEvent(\n new NotificationGlobalEvent({\n title,\n body,\n data: {\n saveNotification: true,\n accountType: NotificationAccountType.USER,\n isGlobal: true,\n isClickable: true,\n clickType: ClickType.CLICKABLE_FALLBACK,\n },\n })\n );\n }\n\n public async notifyUsers(title: string, body: string, userIds: mongoose.Types.ObjectId[]): Promise<void> {\n await Promise.all(\n userIds.map(recipientId =>\n publishEvent(\n new NotificationEvent({\n title,\n body,\n data: {\n saveNotification: true,\n accountType: NotificationAccountType.USER,\n recipientId,\n isGlobal: false,\n isClickable: true,\n clickType: ClickType.CLICKABLE_FALLBACK,\n },\n })\n )\n )\n );\n }\n\n public async dispatchScheduledJob(\n type: string,\n target: string,\n templates: Map<string, NotificationMessage>,\n tournamentId: mongoose.Types.ObjectId,\n matchId: mongoose.Types.ObjectId\n ): Promise<void> {\n const {title, body} = this.getTemplate(templates, type);\n\n if (target === ScheduledTarget.GLOBAL) {\n await this.notifyGlobal(title, body);\n } else {\n const participants = await this.participantService.getAll(tournamentId);\n const unpredicted = participants.filter(p => this.hasNotPredicted(p, matchId));\n await this.notifyUsers(title, body, unpredicted.map(p => p.userId));\n }\n }\n}\n\nexport const tournamentNotificationService = Container.get(TournamentNotificationService);\n"]}
|
|
@@ -7,6 +7,9 @@ export declare class TournamentParticipantRepository {
|
|
|
7
7
|
create(input: object): Promise<ParticipantModelType>;
|
|
8
8
|
findByUserAndTournament(userId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId): Promise<ParticipantModelType | null>;
|
|
9
9
|
findByTournament(tournamentId: mongoose.Types.ObjectId): Promise<ParticipantModelType[]>;
|
|
10
|
+
findByUser(userId: mongoose.Types.ObjectId): Promise<ParticipantModelType | null>;
|
|
11
|
+
updateToJoined(userId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId, teamId: mongoose.Types.ObjectId): Promise<ParticipantModelType | null>;
|
|
12
|
+
upsertStatus(userId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId, status: string): Promise<void>;
|
|
10
13
|
}
|
|
11
14
|
export declare const tournamentParticipantRepository: TournamentParticipantRepository;
|
|
12
15
|
//# sourceMappingURL=participant.repository.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"participant.repository.d.ts","sourceRoot":"/","sources":["modules/tournament/participant/participant.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EACH,qB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AAC;IAIjC,gBAAgB,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAIxF,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAOjF,cAAc,CAChB,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAChC,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAMjC,YAAY,CACd,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,MAAM,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;CAOnB;AAED,eAAO,MAAM,+BAA+B,iCAAiD,CAAC"}
|
|
@@ -63,6 +63,20 @@ let TournamentParticipantRepository = class TournamentParticipantRepository {
|
|
|
63
63
|
async findByTournament(tournamentId) {
|
|
64
64
|
return this.participantModel.find({ tournamentId }).lean();
|
|
65
65
|
}
|
|
66
|
+
async findByUser(userId) {
|
|
67
|
+
return this.participantModel
|
|
68
|
+
.findOne({ userId })
|
|
69
|
+
.sort({ createdAt: -1 })
|
|
70
|
+
.lean();
|
|
71
|
+
}
|
|
72
|
+
async updateToJoined(userId, tournamentId, teamId) {
|
|
73
|
+
return this.participantModel
|
|
74
|
+
.findOneAndUpdate({ userId, tournamentId }, { $set: { status: 'joined', teamId } }, { new: true })
|
|
75
|
+
.lean();
|
|
76
|
+
}
|
|
77
|
+
async upsertStatus(userId, tournamentId, status) {
|
|
78
|
+
await this.participantModel.findOneAndUpdate({ userId, tournamentId }, { $setOnInsert: { userId, tournamentId, predictions: [] }, $set: { status } }, { upsert: true });
|
|
79
|
+
}
|
|
66
80
|
};
|
|
67
81
|
exports.TournamentParticipantRepository = TournamentParticipantRepository;
|
|
68
82
|
exports.TournamentParticipantRepository = TournamentParticipantRepository = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"participant.repository.js","sourceRoot":"/","sources":["modules/tournament/participant/participant.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,sEAGmD;AAG5C,IAAM,+BAA+B,GAArC,MAAM,+BAA+B;IAChC,gBAAgB,CAAoC;IAE5D;QACI,IAAI,CAAC,gBAAgB,GAAG,mCAA0B,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,yBAAyB,CAC3B,MAA+B,EAC/B,YAAqC;QAErC,OAAO,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAa;QACtB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,uBAAuB,CACzB,MAA+B,EAC/B,YAAqC;QAErC,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,IAAI,EAA0C,CAAC;IAClH,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,YAAqC;QACxD,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,IAAI,EAAqC,CAAC;IAClG,CAAC;CACJ,CAAA;
|
|
1
|
+
{"version":3,"file":"participant.repository.js","sourceRoot":"/","sources":["modules/tournament/participant/participant.repository.ts"],"names":[],"mappings":";;;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EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;aACjG,IAAI,EAA0C,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,YAAY,CACd,MAA+B,EAC/B,YAAqC,EACrC,MAAc;QAEd,MAAM,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CACxC,EAAE,MAAM,EAAE,YAAY,EAAE,EACxB,EAAE,YAAY,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAC7E,EAAE,MAAM,EAAE,IAAI,EAAE,CACnB,CAAC;IACN,CAAC;CACJ,CAAA;AA1DY,0EAA+B;0CAA/B,+BAA+B;IAD3C,IAAA,gBAAO,GAAE;;GACG,+BAA+B,CA0D3C;AAEY,QAAA,+BAA+B,GAAG,gBAAS,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport {\n TournamentParticipant as ParticipantModelType,\n TournamentParticipantModel,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\n\n@Service()\nexport class TournamentParticipantRepository {\n private participantModel: typeof TournamentParticipantModel;\n\n constructor() {\n this.participantModel = TournamentParticipantModel;\n }\n\n async existsByUserAndTournament(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId\n ): Promise<boolean> {\n return !!(await this.participantModel.exists({ userId, tournamentId }));\n }\n\n async create(input: object): Promise<ParticipantModelType> {\n const doc = await this.participantModel.create(input);\n return doc.toObject();\n }\n\n async findByUserAndTournament(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId\n ): Promise<ParticipantModelType | null> {\n return this.participantModel.findOne({ userId, tournamentId }).lean() as Promise<ParticipantModelType | null>;\n }\n\n async findByTournament(tournamentId: mongoose.Types.ObjectId): Promise<ParticipantModelType[]> {\n return this.participantModel.find({ tournamentId }).lean() as Promise<ParticipantModelType[]>;\n }\n\n async findByUser(userId: mongoose.Types.ObjectId): Promise<ParticipantModelType | null> {\n return this.participantModel\n .findOne({ userId })\n .sort({ createdAt: -1 })\n .lean() as Promise<ParticipantModelType | null>;\n }\n\n async updateToJoined(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId,\n teamId: mongoose.Types.ObjectId\n ): Promise<ParticipantModelType | null> {\n return this.participantModel\n .findOneAndUpdate({ userId, tournamentId }, { $set: { status: 'joined', teamId } }, { new: true })\n .lean() as Promise<ParticipantModelType | null>;\n }\n\n async upsertStatus(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId,\n status: string\n ): Promise<void> {\n await this.participantModel.findOneAndUpdate(\n { userId, tournamentId },\n { $setOnInsert: { userId, tournamentId, predictions: [] }, $set: { status } },\n { upsert: true }\n );\n }\n}\n\nexport const tournamentParticipantRepository = Container.get(TournamentParticipantRepository);"]}
|
|
@@ -24,16 +24,18 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
24
24
|
message: string;
|
|
25
25
|
success: boolean;
|
|
26
26
|
data?: {
|
|
27
|
+
status: "joined" | "seen";
|
|
27
28
|
_id: string | mongoose.Types.ObjectId;
|
|
28
29
|
tournamentId: string | mongoose.Types.ObjectId;
|
|
29
|
-
teamId: string | mongoose.Types.ObjectId;
|
|
30
30
|
createdAt?: Date | null | undefined;
|
|
31
|
+
teamId?: string | mongoose.Types.ObjectId | undefined;
|
|
31
32
|
} | {
|
|
32
33
|
documents: {
|
|
34
|
+
status: "joined" | "seen";
|
|
33
35
|
_id: string | mongoose.Types.ObjectId;
|
|
34
36
|
tournamentId: string | mongoose.Types.ObjectId;
|
|
35
|
-
teamId: string | mongoose.Types.ObjectId;
|
|
36
37
|
createdAt?: Date | null | undefined;
|
|
38
|
+
teamId?: string | mongoose.Types.ObjectId | undefined;
|
|
37
39
|
}[];
|
|
38
40
|
metadata?: {
|
|
39
41
|
page: number;
|
|
@@ -45,6 +47,25 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
45
47
|
};
|
|
46
48
|
meta: object;
|
|
47
49
|
}>;
|
|
50
|
+
markSeen: import("@trpc/server").TRPCMutationProcedure<{
|
|
51
|
+
input: {
|
|
52
|
+
tournamentId: string | mongoose.Types.ObjectId;
|
|
53
|
+
};
|
|
54
|
+
output: {
|
|
55
|
+
message: string;
|
|
56
|
+
success: boolean;
|
|
57
|
+
data?: {
|
|
58
|
+
documents: null[];
|
|
59
|
+
metadata?: {
|
|
60
|
+
page: number;
|
|
61
|
+
size: number;
|
|
62
|
+
totalElements: number;
|
|
63
|
+
totalPages: number;
|
|
64
|
+
} | undefined;
|
|
65
|
+
} | null | undefined;
|
|
66
|
+
};
|
|
67
|
+
meta: object;
|
|
68
|
+
}>;
|
|
48
69
|
getAll: import("@trpc/server").TRPCQueryProcedure<{
|
|
49
70
|
input: {
|
|
50
71
|
tournamentId: string | mongoose.Types.ObjectId;
|
|
@@ -53,12 +74,13 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
53
74
|
message: string;
|
|
54
75
|
success: boolean;
|
|
55
76
|
data?: {
|
|
77
|
+
status: "joined" | "seen";
|
|
56
78
|
_id: string | mongoose.Types.ObjectId;
|
|
57
79
|
userId: string | mongoose.Types.ObjectId;
|
|
58
80
|
tournamentId: string | mongoose.Types.ObjectId;
|
|
59
|
-
teamId: string | mongoose.Types.ObjectId;
|
|
60
81
|
createdAt?: Date | null | undefined;
|
|
61
82
|
updatedAt?: Date | null | undefined;
|
|
83
|
+
teamId?: string | mongoose.Types.ObjectId | undefined;
|
|
62
84
|
predictions?: {
|
|
63
85
|
_id: string | mongoose.Types.ObjectId;
|
|
64
86
|
matchId: string | mongoose.Types.ObjectId;
|
|
@@ -72,12 +94,13 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
72
94
|
}[] | undefined;
|
|
73
95
|
}[] | {
|
|
74
96
|
documents: {
|
|
97
|
+
status: "joined" | "seen";
|
|
75
98
|
_id: string | mongoose.Types.ObjectId;
|
|
76
99
|
userId: string | mongoose.Types.ObjectId;
|
|
77
100
|
tournamentId: string | mongoose.Types.ObjectId;
|
|
78
|
-
teamId: string | mongoose.Types.ObjectId;
|
|
79
101
|
createdAt?: Date | null | undefined;
|
|
80
102
|
updatedAt?: Date | null | undefined;
|
|
103
|
+
teamId?: string | mongoose.Types.ObjectId | undefined;
|
|
81
104
|
predictions?: {
|
|
82
105
|
_id: string | mongoose.Types.ObjectId;
|
|
83
106
|
matchId: string | mongoose.Types.ObjectId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"participant.router.d.ts","sourceRoot":"/","sources":["modules/tournament/participant/participant.router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"participant.router.d.ts","sourceRoot":"/","sources":["modules/tournament/participant/participant.router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAgBhD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8B5B,CAAC"}
|
|
@@ -17,6 +17,13 @@ exports.participantRouter = (0, trpc_1.createTRPCRouter)({
|
|
|
17
17
|
const result = await participant_service_1.participantService.join(new typegoose_1.mongoose.Types.ObjectId(ctx.entity?.id), input);
|
|
18
18
|
return (0, response_1.response)('Tournament joined successfully', result);
|
|
19
19
|
})),
|
|
20
|
+
markSeen: (0, auth_2.createAuthenticatedProcedure)({ entityTypes: [auth_1.AuthEntityType.USER] })
|
|
21
|
+
.input(participant_validation_1.MarkSeenTournamentSchema)
|
|
22
|
+
.output(participant_validation_1.MarkSeenTournamentResponseSchema)
|
|
23
|
+
.mutation(async ({ ctx, input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
24
|
+
await participant_service_1.participantService.markSeen(new typegoose_1.mongoose.Types.ObjectId(ctx.entity?.id), input);
|
|
25
|
+
return (0, response_1.response)('Tournament marked as seen', null);
|
|
26
|
+
})),
|
|
20
27
|
getAll: (0, auth_2.createAuthenticatedProcedure)({ entityTypes: [auth_1.AuthEntityType.CRM] })
|
|
21
28
|
.input(participant_validation_1.GetTournamentParticipantsSchema)
|
|
22
29
|
.output(participant_validation_1.TournamentParticipantListResponseSchema)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"participant.router.js","sourceRoot":"/","sources":["modules/tournament/participant/participant.router.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAChD,4DAAqE;AACrE,4DAAmE;AACnE,6EAAkG;AAClG,8EAA0E;AAC1E,oEAAiE;AACjE,+DAAsE;AACtE,
|
|
1
|
+
{"version":3,"file":"participant.router.js","sourceRoot":"/","sources":["modules/tournament/participant/participant.router.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAChD,4DAAqE;AACrE,4DAAmE;AACnE,6EAAkG;AAClG,8EAA0E;AAC1E,oEAAiE;AACjE,+DAAsE;AACtE,qEAOkC;AAErB,QAAA,iBAAiB,GAAG,IAAA,uBAAgB,EAAC;IACjD,IAAI,EAAE,IAAA,mCAA4B,EAAC,EAAE,WAAW,EAAE,CAAC,qBAAc,CAAC,IAAI,CAAC,EAAE,CAAC;SACxE,KAAK,CAAC,6CAAoB,CAAC;SAC3B,MAAM,CAAC,qDAA4B,CAAC;SACpC,QAAQ,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAClC,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAA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,CAAC,CAAC","sourcesContent":["import { mongoose } from '@typegoose/typegoose';\nimport { 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 { participantService as service } from './participant.service';\nimport {\n\tJoinTournamentSchema,\n\tJoinTournamentResponseSchema,\n\tTournamentParticipantListResponseSchema,\n\tGetTournamentParticipantsSchema,\n\tMarkSeenTournamentSchema,\n\tMarkSeenTournamentResponseSchema,\n} from './participant.validation';\n\nexport const participantRouter = createTRPCRouter({\n\tjoin: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.USER] })\n\t\t.input(JoinTournamentSchema)\n\t\t.output(JoinTournamentResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.join(new mongoose.Types.ObjectId(ctx.entity?.id), input);\n\t\t\t\treturn response('Tournament joined successfully', result);\n\t\t\t})\n\t\t),\n\n\tmarkSeen: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.USER] })\n\t\t.input(MarkSeenTournamentSchema)\n\t\t.output(MarkSeenTournamentResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tawait service.markSeen(new mongoose.Types.ObjectId(ctx.entity?.id), input);\n\t\t\t\treturn response('Tournament marked as seen', null);\n\t\t\t})\n\t\t),\n\n\tgetAll: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n\t\t.input(GetTournamentParticipantsSchema)\n\t\t.output(TournamentParticipantListResponseSchema)\n\t\t.query(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.getAll(input.tournamentId);\n\t\t\t\treturn response('Participants fetched successfully', result);\n\t\t\t})\n\t\t),\n});\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { mongoose } from '@typegoose/typegoose';
|
|
2
|
-
import { JoinTournamentInputDTO, TournamentParticipantOutputDTO } from './participant.validation';
|
|
2
|
+
import { JoinTournamentInputDTO, MarkSeenTournamentInputDTO, TournamentParticipantOutputDTO } from './participant.validation';
|
|
3
3
|
export declare class ParticipantService {
|
|
4
4
|
private repository;
|
|
5
5
|
private matchRepository;
|
|
6
6
|
constructor();
|
|
7
7
|
private ensureTeamExists;
|
|
8
|
-
private ensureNotAlreadyJoined;
|
|
9
8
|
join(userId: mongoose.Types.ObjectId, input: JoinTournamentInputDTO): Promise<TournamentParticipantOutputDTO>;
|
|
9
|
+
markSeen(userId: mongoose.Types.ObjectId, input: MarkSeenTournamentInputDTO): Promise<void>;
|
|
10
10
|
getByUserAndTournament(userId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId): Promise<TournamentParticipantOutputDTO>;
|
|
11
11
|
getAll(tournamentId: mongoose.Types.ObjectId): Promise<TournamentParticipantOutputDTO[]>;
|
|
12
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"participant.service.d.ts","sourceRoot":"/","sources":["modules/tournament/participant/participant.service.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"participant.service.d.ts","sourceRoot":"/","sources":["modules/tournament/participant/participant.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAG9C,OAAO,EACH,sBAAsB,EACtB,0BAA0B,EAC1B,8BAA8B,EACjC,MAAM,0BAA0B,CAAC;AAKlC,qBACa,kBAAkB;IAC3B,OAAO,CAAC,UAAU,CAAkC;IACpD,OAAO,CAAC,eAAe,CAA4B;;IAOnD,OAAO,CAAC,gBAAgB;IAKX,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,8BAA8B,CAAC;IA2B7G,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3F,sBAAsB,CAC/B,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GACtC,OAAO,CAAC,8BAA8B,CAAC;IAM7B,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,8BAA8B,EAAE,CAAC;CAKxG;AAED,eAAO,MAAM,kBAAkB,oBAAoC,CAAC"}
|
|
@@ -48,6 +48,7 @@ const server_1 = require("@trpc/server");
|
|
|
48
48
|
const error_common_1 = require("@lyxa.ai/core/dist/utilities/error-common");
|
|
49
49
|
const participant_repository_1 = require("./participant.repository");
|
|
50
50
|
const match_repository_1 = require("../match/match.repository");
|
|
51
|
+
const tournament_types_1 = require("../tournament.types");
|
|
51
52
|
let ParticipantService = class ParticipantService {
|
|
52
53
|
repository;
|
|
53
54
|
matchRepository;
|
|
@@ -60,27 +61,40 @@ let ParticipantService = class ParticipantService {
|
|
|
60
61
|
if (!exists)
|
|
61
62
|
throw (0, error_common_1.badRequestError)('Selected team does not exist in this tournament');
|
|
62
63
|
}
|
|
63
|
-
async ensureNotAlreadyJoined(userId, tournamentId) {
|
|
64
|
-
if (await this.repository.existsByUserAndTournament(userId, tournamentId)) {
|
|
65
|
-
throw (0, error_common_1.conflictError)('You have already joined this tournament');
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
64
|
async join(userId, input) {
|
|
69
65
|
const tournament = await this.matchRepository.findById(input.tournamentId);
|
|
70
66
|
if (!tournament)
|
|
71
67
|
throw (0, error_common_1.notFoundError)('Tournament not found');
|
|
72
68
|
this.ensureTeamExists(tournament, input.teamId);
|
|
73
|
-
await this.
|
|
69
|
+
const existing = await this.repository.findByUserAndTournament(userId, input.tournamentId);
|
|
70
|
+
if (existing?.status === tournament_types_1.TournamentParticipantStatus.JOINED)
|
|
71
|
+
throw (0, error_common_1.conflictError)('You have already joined this tournament');
|
|
72
|
+
if (existing) {
|
|
73
|
+
const updated = await this.repository.updateToJoined(userId, input.tournamentId, input.teamId);
|
|
74
|
+
if (!updated)
|
|
75
|
+
throw new server_1.TRPCError({ code: 'INTERNAL_SERVER_ERROR', message: 'Failed to join tournament' });
|
|
76
|
+
return updated;
|
|
77
|
+
}
|
|
74
78
|
const result = await this.repository.create({
|
|
75
79
|
userId,
|
|
76
80
|
tournamentId: input.tournamentId,
|
|
77
81
|
teamId: input.teamId,
|
|
82
|
+
status: tournament_types_1.TournamentParticipantStatus.JOINED,
|
|
78
83
|
predictions: [],
|
|
79
84
|
});
|
|
80
85
|
if (!result)
|
|
81
86
|
throw new server_1.TRPCError({ code: 'INTERNAL_SERVER_ERROR', message: 'Failed to join tournament' });
|
|
82
87
|
return result;
|
|
83
88
|
}
|
|
89
|
+
async markSeen(userId, input) {
|
|
90
|
+
const tournament = await this.matchRepository.findById(input.tournamentId);
|
|
91
|
+
if (!tournament)
|
|
92
|
+
throw (0, error_common_1.notFoundError)('Tournament not found');
|
|
93
|
+
const existing = await this.repository.findByUserAndTournament(userId, input.tournamentId);
|
|
94
|
+
if (existing)
|
|
95
|
+
return;
|
|
96
|
+
await this.repository.upsertStatus(userId, input.tournamentId, tournament_types_1.TournamentParticipantStatus.SEEN);
|
|
97
|
+
}
|
|
84
98
|
async getByUserAndTournament(userId, tournamentId) {
|
|
85
99
|
const participant = await this.repository.findByUserAndTournament(userId, tournamentId);
|
|
86
100
|
if (!participant)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"participant.service.js","sourceRoot":"/","sources":["modules/tournament/participant/participant.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;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C,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,YAAY,EAAE,8CAA2B,CAAC,IAAI,CAAC,CAAC;IACrG,CAAC;IAEM,KAAK,CAAC,sBAAsB,CAC/B,MAA+B,EAC/B,YAAqC;QAErC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,uBAAuB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QACxF,IAAI,CAAC,WAAW;YAAE,MAAM,IAAA,4BAAa,EAAC,qCAAqC,CAAC,CAAC;QAC7E,OAAO,WAA6C,CAAC;IACzD,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,YAAqC;QACrD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QACrE,IAAI,CAAC,UAAU;YAAE,MAAM,IAAA,4BAAa,EAAC,sBAAsB,CAAC,CAAC;QAC7D,OAAO,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,YAAY,CAA8C,CAAC;IACvG,CAAC;CACJ,CAAA;AAjEY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,gBAAO,GAAE;;GACG,kBAAkB,CAiE9B;AAEY,QAAA,kBAAkB,GAAG,gBAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {TRPCError} from '@trpc/server';\nimport {mongoose} from '@typegoose/typegoose';\nimport {badRequestError, conflictError, notFoundError} from '@lyxa.ai/core/dist/utilities/error-common';\nimport {TournamentParticipantRepository} from './participant.repository';\nimport {\n JoinTournamentInputDTO,\n MarkSeenTournamentInputDTO,\n TournamentParticipantOutputDTO,\n} from './participant.validation';\nimport {TournamentMatchRepository} from '../match/match.repository';\nimport {Tournament as TournamentType} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {TournamentParticipantStatus} from '../tournament.types';\n\n@Service()\nexport class ParticipantService {\n private repository: TournamentParticipantRepository;\n private matchRepository: TournamentMatchRepository;\n\n constructor() {\n this.repository = Container.get(TournamentParticipantRepository);\n this.matchRepository = Container.get(TournamentMatchRepository);\n }\n\n private ensureTeamExists(tournament: TournamentType, teamId: mongoose.Types.ObjectId) {\n const exists = tournament.teams.some(team => team._id.toString() === teamId.toString());\n if (!exists) throw badRequestError('Selected team does not exist in this tournament');\n }\n\n public async join(userId: mongoose.Types.ObjectId, input: JoinTournamentInputDTO): Promise<TournamentParticipantOutputDTO> {\n const tournament = await this.matchRepository.findById(input.tournamentId);\n if (!tournament) throw notFoundError('Tournament not found');\n\n this.ensureTeamExists(tournament, input.teamId);\n\n const existing = await this.repository.findByUserAndTournament(userId, input.tournamentId);\n if ((existing?.status as string) === TournamentParticipantStatus.JOINED) throw conflictError('You have already joined this tournament');\n\n if (existing) {\n const updated = await this.repository.updateToJoined(userId, input.tournamentId, input.teamId);\n if (!updated) throw new TRPCError({code: 'INTERNAL_SERVER_ERROR', message: 'Failed to join tournament'});\n return updated as TournamentParticipantOutputDTO;\n }\n\n const result = await this.repository.create({\n userId,\n tournamentId: input.tournamentId,\n teamId: input.teamId,\n status: TournamentParticipantStatus.JOINED,\n predictions: [],\n });\n if (!result) throw new TRPCError({ code: 'INTERNAL_SERVER_ERROR', message: 'Failed to join tournament' });\n\n return result as TournamentParticipantOutputDTO;\n }\n\n public async markSeen(userId: mongoose.Types.ObjectId, input: MarkSeenTournamentInputDTO): Promise<void> {\n const tournament = await this.matchRepository.findById(input.tournamentId);\n if (!tournament) throw notFoundError('Tournament not found');\n\n const existing = await this.repository.findByUserAndTournament(userId, input.tournamentId);\n if (existing) return;\n\n await this.repository.upsertStatus(userId, input.tournamentId, TournamentParticipantStatus.SEEN);\n }\n\n public async getByUserAndTournament(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId\n ): Promise<TournamentParticipantOutputDTO> {\n const participant = await this.repository.findByUserAndTournament(userId, tournamentId);\n if (!participant) throw notFoundError('You have not joined this tournament');\n return participant as TournamentParticipantOutputDTO;\n }\n\n public async getAll(tournamentId: mongoose.Types.ObjectId): Promise<TournamentParticipantOutputDTO[]> {\n const tournament = await this.matchRepository.findById(tournamentId);\n if (!tournament) throw notFoundError('Tournament not found');\n return this.repository.findByTournament(tournamentId) as Promise<TournamentParticipantOutputDTO[]>;\n }\n}\n\nexport const participantService = Container.get(ParticipantService);\n"]}
|