@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prediction.builder.js","sourceRoot":"/","sources":["modules/tournament/prediction/prediction.builder.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;
|
|
1
|
+
{"version":3,"file":"prediction.builder.js","sourceRoot":"/","sources":["modules/tournament/prediction/prediction.builder.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAEhD,0DAA2C;AAO3C,MAAa,iBAAiB;IAC1B,MAAM,CAAC,eAAe,CAAC,OAAgC,EAAE,KAA2B;QAChF,OAAO;YACH,GAAG,EAAE,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE;YAClC,OAAO;YACP,KAAK;YACL,cAAc,EAAE,IAAA,yBAAM,GAAE;YACxB,SAAS,EAAE,IAAI;SAClB,CAAC;IACN,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,KAA2B;QAC/C,OAAO;YACH,qBAAqB,EAAE,KAAK;YAC5B,8BAA8B,EAAE,IAAA,yBAAM,GAAE;SAC3C,CAAC;IACN,CAAC;CACJ;AAjBD,8CAiBC","sourcesContent":["import { mongoose } from '@typegoose/typegoose';\nimport { PredictionOutputDTO } from './prediction.validation';\nimport {utcNow} from '../tournament.utils';\n\ninterface PredictionScoreInput {\n team1: number;\n team2: number;\n}\n\nexport class PredictionBuilder {\n static buildPrediction(matchId: mongoose.Types.ObjectId, score: PredictionScoreInput): Omit<PredictionOutputDTO, '_id'> & { _id: mongoose.Types.ObjectId } {\n return {\n _id: new mongoose.Types.ObjectId(),\n matchId,\n score,\n predictionTime: utcNow(),\n succeeded: null,\n };\n }\n\n static buildScoreUpdate(score: PredictionScoreInput): Record<string, unknown> {\n return {\n 'predictions.$.score': score,\n 'predictions.$.predictionTime': utcNow(),\n };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prediction.service.d.ts","sourceRoot":"/","sources":["modules/tournament/prediction/prediction.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EACH,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACtB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"prediction.service.d.ts","sourceRoot":"/","sources":["modules/tournament/prediction/prediction.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EACH,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACtB,MAAM,yBAAyB,CAAC;AAQjC,qBACa,iBAAiB;IAC1B,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,eAAe,CAA4B;IACnD,OAAO,CAAC,kBAAkB,CAAqB;;YAQjC,SAAS;IAQvB,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,kCAAkC;IAU1C,OAAO,CAAC,uBAAuB;IAK/B,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,eAAe;IAmBV,QAAQ,CACjB,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAChC,UAAU,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAC7C,OAAO,CAAC;QAAC,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAA;KAAC,CAAC;IAO1E,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAetG,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAqBlG,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;CAKvH;AAED,eAAO,MAAM,iBAAiB,mBAAmC,CAAC"}
|
|
@@ -49,6 +49,7 @@ const prediction_repository_1 = require("./prediction.repository");
|
|
|
49
49
|
const prediction_builder_1 = require("./prediction.builder");
|
|
50
50
|
const participant_service_1 = require("../participant/participant.service");
|
|
51
51
|
const match_repository_1 = require("../match/match.repository");
|
|
52
|
+
const tournament_utils_1 = require("../tournament.utils");
|
|
52
53
|
let PredictionService = class PredictionService {
|
|
53
54
|
repository;
|
|
54
55
|
matchRepository;
|
|
@@ -70,10 +71,18 @@ let PredictionService = class PredictionService {
|
|
|
70
71
|
ensureMatchIsOpen(match) {
|
|
71
72
|
if (match.endDate)
|
|
72
73
|
throw (0, error_common_1.badRequestError)('This match has already ended');
|
|
73
|
-
if (match.startingDate && match.startingDate <=
|
|
74
|
+
if (match.startingDate && match.startingDate <= (0, tournament_utils_1.utcNow)()) {
|
|
74
75
|
throw (0, error_common_1.badRequestError)('The prediction window for this match has closed');
|
|
75
76
|
}
|
|
76
77
|
}
|
|
78
|
+
ensureMatchInvolvesParticipantTeam(match, participant) {
|
|
79
|
+
if (!participant.teamId)
|
|
80
|
+
throw (0, error_common_1.badRequestError)('You have not joined this tournament');
|
|
81
|
+
const teamId = participant.teamId.toString();
|
|
82
|
+
const involved = match.team1.teamId.toString() === teamId || match.team2.teamId.toString() === teamId;
|
|
83
|
+
if (!involved)
|
|
84
|
+
throw (0, error_common_1.badRequestError)('You can only predict for matches involving your selected team');
|
|
85
|
+
}
|
|
77
86
|
ensureNoPriorPrediction(participant, matchId) {
|
|
78
87
|
const exists = participant.predictions.some(p => p.matchId.toString() === matchId.toString());
|
|
79
88
|
if (exists)
|
|
@@ -107,6 +116,7 @@ let PredictionService = class PredictionService {
|
|
|
107
116
|
const match = await this.findMatch(input.tournamentId, input.matchId);
|
|
108
117
|
this.ensureMatchIsOpen(match);
|
|
109
118
|
const participant = await this.participantService.getByUserAndTournament(userId, input.tournamentId);
|
|
119
|
+
this.ensureMatchInvolvesParticipantTeam(match, participant);
|
|
110
120
|
this.ensureNoPriorPrediction(participant, input.matchId);
|
|
111
121
|
const prediction = prediction_builder_1.PredictionBuilder.buildPrediction(input.matchId, input.score);
|
|
112
122
|
const result = await this.repository.addPrediction(participant._id, prediction);
|
|
@@ -118,6 +128,7 @@ let PredictionService = class PredictionService {
|
|
|
118
128
|
const match = await this.findMatch(input.tournamentId, input.matchId);
|
|
119
129
|
this.ensureMatchIsOpen(match);
|
|
120
130
|
const participant = await this.participantService.getByUserAndTournament(userId, input.tournamentId);
|
|
131
|
+
this.ensureMatchInvolvesParticipantTeam(match, participant);
|
|
121
132
|
this.findPrediction(participant, input.matchId);
|
|
122
133
|
const result = await this.repository.updatePrediction(participant._id, input.matchId, prediction_builder_1.PredictionBuilder.buildScoreUpdate(input.score));
|
|
123
134
|
if (!result)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prediction.service.js","sourceRoot":"/","sources":["modules/tournament/prediction/prediction.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,4EAAyF;AAOzF,mEAA6D;AAC7D,6DAAuD;AACvD,4EAAsE;AAEtE,gEAAoE;AAG7D,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAClB,UAAU,CAAuB;IACjC,eAAe,CAA4B;IAC3C,kBAAkB,CAAqB;IAE/C;QACI,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,4CAAoB,CAAC,CAAC;QACtD,IAAI,CAAC,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estError, notFoundError} from '@lyxa.ai/core/dist/utilities/error-common';\nimport {\n CreatePredictionInputDTO,\n EditPredictionInputDTO,\n GetPredictionInputDTO,\n PredictionOutputDTO\n} from './prediction.validation';\nimport {PredictionRepository} from './prediction.repository';\nimport {PredictionBuilder} from './prediction.builder';\nimport {ParticipantService} from '../participant/participant.service';\nimport {TournamentParticipantOutputDTO} from '../participant/participant.validation';\nimport {TournamentMatchRepository} from '../match/match.repository';\n\n@Service()\nexport class PredictionService {\n private repository: PredictionRepository;\n private matchRepository: TournamentMatchRepository;\n private participantService: ParticipantService;\n\n constructor() {\n this.repository = Container.get(PredictionRepository);\n this.matchRepository = Container.get(TournamentMatchRepository);\n this.participantService = Container.get(ParticipantService);\n }\n\n private async findMatch(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId) {\n const tournament = await this.matchRepository.findMatchInTournament(tournamentId, matchId);\n if (!tournament) throw notFoundError('Match not found in this tournament');\n const match = tournament.matches.find(m => m._id.toString() === matchId.toString());\n if (!match) throw notFoundError('Match not found');\n return match;\n }\n\n private ensureMatchIsOpen(match: { startingDate?: Date | null; endDate?: Date | null }) {\n if (match.endDate) throw badRequestError('This match has already ended');\n if (match.startingDate && match.startingDate <= new Date()) {\n throw badRequestError('The prediction window for this match has closed');\n }\n }\n\n private ensureNoPriorPrediction(participant: TournamentParticipantOutputDTO, matchId: mongoose.Types.ObjectId) {\n const exists = participant.predictions.some(p => p.matchId.toString() === matchId.toString());\n if (exists) throw badRequestError('You have already predicted for this match');\n }\n\n private findPrediction(participant: TournamentParticipantOutputDTO, matchId: mongoose.Types.ObjectId) {\n const prediction = participant.predictions.find(p => p.matchId.toString() === matchId.toString());\n if (!prediction) throw notFoundError('No prediction found for this match');\n return prediction;\n }\n\n private resolveOutcomes(\n participants: TournamentParticipantOutputDTO[],\n matchId: mongoose.Types.ObjectId,\n finalScore: { team1: number; team2: number }\n ): {winnerIds: mongoose.Types.ObjectId[]; loserIds: mongoose.Types.ObjectId[]} {\n const winnerIds: mongoose.Types.ObjectId[] = [];\n const loserIds: mongoose.Types.ObjectId[] = [];\n\n for (const participant of participants) {\n const prediction = participant.predictions.find(p => p.matchId.toString() === matchId.toString());\n if (!prediction) continue;\n\n const isWinner = prediction.score.team1 === finalScore.team1 && prediction.score.team2 === finalScore.team2;\n (isWinner ? winnerIds : loserIds).push(participant.userId);\n }\n\n return {winnerIds, loserIds};\n }\n\n public async evaluate(\n tournamentId: mongoose.Types.ObjectId,\n matchId: mongoose.Types.ObjectId,\n finalScore: { team1: number; team2: number }\n ): Promise<{winnerIds: mongoose.Types.ObjectId[]; loserIds: mongoose.Types.ObjectId[]}> {\n const participants = await this.participantService.getAll(tournamentId);\n const outcomes = this.resolveOutcomes(participants, matchId, finalScore);\n await this.repository.evaluate(tournamentId, matchId, finalScore);\n return outcomes;\n }\n\n public async create(userId: mongoose.Types.ObjectId, input: CreatePredictionInputDTO): Promise<PredictionOutputDTO> {\n const match = await this.findMatch(input.tournamentId, input.matchId);\n this.ensureMatchIsOpen(match);\n\n const participant = await this.participantService.getByUserAndTournament(userId, input.tournamentId);\n this.ensureNoPriorPrediction(participant, input.matchId);\n\n const prediction = PredictionBuilder.buildPrediction(input.matchId, input.score);\n const result = await this.repository.addPrediction(participant._id, prediction);\n if (!result) throw notFoundError('Participant not found');\n\n return prediction as PredictionOutputDTO;\n }\n\n public async edit(userId: mongoose.Types.ObjectId, input: EditPredictionInputDTO): Promise<PredictionOutputDTO> {\n const match = await this.findMatch(input.tournamentId, input.matchId);\n this.ensureMatchIsOpen(match);\n\n const participant = await this.participantService.getByUserAndTournament(userId, input.tournamentId);\n this.findPrediction(participant, input.matchId);\n\n const result = await this.repository.updatePrediction(\n participant._id,\n input.matchId,\n PredictionBuilder.buildScoreUpdate(input.score)\n );\n if (!result) throw notFoundError('Participant not found');\n\n const updated = result.predictions.find(p => p.matchId.toString() === input.matchId.toString());\n if (!updated) throw notFoundError('Prediction not found after update');\n\n return updated as unknown as PredictionOutputDTO;\n }\n\n public async get(userId: mongoose.Types.ObjectId, input: GetPredictionInputDTO): Promise<PredictionOutputDTO | null> {\n const participant = await this.participantService.getByUserAndTournament(userId, input.tournamentId);\n const prediction = participant.predictions.find(p => p.matchId.toString() === input.matchId.toString());\n return (prediction as unknown as PredictionOutputDTO) ?? null;\n }\n}\n\nexport const predictionService = Container.get(PredictionService);\n"]}
|
|
1
|
+
{"version":3,"file":"prediction.service.js","sourceRoot":"/","sources":["modules/tournament/prediction/prediction.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,4EAAyF;AAOzF,mEAA6D;AAC7D,6DAAuD;AACvD,4EAAsE;AAEtE,gEAAoE;AACpE,0DAA2C;AAGpC,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAClB,UAAU,CAAuB;IACjC,eAAe,CAA4B;IAC3C,kBAAkB,CAAqB;IAE/C;QACI,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,4CAAoB,CAAC,CAAC;QACtD,IAAI,CAAC,eAAe,GAAG,gBAAS,CAAC,GAAG,CAAC,4CAAyB,CAAC,CAAC;QAChE,IAAI,CAAC,kBAAkB,GAAG,gBAAS,CAAC,GAAG,CAAC,wCAAkB,CAAC,CAAC;IAChE,CAAC;IAEO,KAAK,CAAC,SAAS,CAAC,YAAqC,EAAE,OAAgC;QAC3F,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,qBAAqB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QAC3F,IAAI,CAAC,UAAU;YAAE,MAAM,IAAA,4BAAa,EAAC,oCAAoC,CAAC,CAAC;QAC3E,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;QACp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{mongoose} from '@typegoose/typegoose';\nimport {badRequestError, notFoundError} from '@lyxa.ai/core/dist/utilities/error-common';\nimport {\n CreatePredictionInputDTO,\n EditPredictionInputDTO,\n GetPredictionInputDTO,\n PredictionOutputDTO\n} from './prediction.validation';\nimport {PredictionRepository} from './prediction.repository';\nimport {PredictionBuilder} from './prediction.builder';\nimport {ParticipantService} from '../participant/participant.service';\nimport {TournamentParticipantOutputDTO} from '../participant/participant.validation';\nimport {TournamentMatchRepository} from '../match/match.repository';\nimport {utcNow} from '../tournament.utils';\n\n@Service()\nexport class PredictionService {\n private repository: PredictionRepository;\n private matchRepository: TournamentMatchRepository;\n private participantService: ParticipantService;\n\n constructor() {\n this.repository = Container.get(PredictionRepository);\n this.matchRepository = Container.get(TournamentMatchRepository);\n this.participantService = Container.get(ParticipantService);\n }\n\n private async findMatch(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId) {\n const tournament = await this.matchRepository.findMatchInTournament(tournamentId, matchId);\n if (!tournament) throw notFoundError('Match not found in this tournament');\n const match = tournament.matches.find(m => m._id.toString() === matchId.toString());\n if (!match) throw notFoundError('Match not found');\n return match;\n }\n\n private ensureMatchIsOpen(match: { startingDate?: Date | null; endDate?: Date | null }) {\n if (match.endDate) throw badRequestError('This match has already ended'); // change to flag \"matchEnded\n if (match.startingDate && match.startingDate <= utcNow()) {\n throw badRequestError('The prediction window for this match has closed');\n }\n }\n\n private ensureMatchInvolvesParticipantTeam(\n match: { team1: { teamId: mongoose.Types.ObjectId }; team2: { teamId: mongoose.Types.ObjectId } },\n participant: TournamentParticipantOutputDTO\n ) {\n if (!participant.teamId) throw badRequestError('You have not joined this tournament');\n const teamId = participant.teamId.toString();\n const involved = match.team1.teamId.toString() === teamId || match.team2.teamId.toString() === teamId;\n if (!involved) throw badRequestError('You can only predict for matches involving your selected team');\n }\n\n private ensureNoPriorPrediction(participant: TournamentParticipantOutputDTO, matchId: mongoose.Types.ObjectId) {\n const exists = participant.predictions.some(p => p.matchId.toString() === matchId.toString());\n if (exists) throw badRequestError('You have already predicted for this match');\n }\n\n private findPrediction(participant: TournamentParticipantOutputDTO, matchId: mongoose.Types.ObjectId) {\n const prediction = participant.predictions.find(p => p.matchId.toString() === matchId.toString());\n if (!prediction) throw notFoundError('No prediction found for this match');\n return prediction;\n }\n\n private resolveOutcomes(\n participants: TournamentParticipantOutputDTO[],\n matchId: mongoose.Types.ObjectId,\n finalScore: { team1: number; team2: number }\n ): {winnerIds: mongoose.Types.ObjectId[]; loserIds: mongoose.Types.ObjectId[]} {\n const winnerIds: mongoose.Types.ObjectId[] = [];\n const loserIds: mongoose.Types.ObjectId[] = [];\n\n for (const participant of participants) {\n const prediction = participant.predictions.find(p => p.matchId.toString() === matchId.toString());\n if (!prediction) continue;\n\n const isWinner = prediction.score.team1 === finalScore.team1 && prediction.score.team2 === finalScore.team2;\n (isWinner ? winnerIds : loserIds).push(participant.userId);\n }\n\n return {winnerIds, loserIds};\n }\n\n public async evaluate(\n tournamentId: mongoose.Types.ObjectId,\n matchId: mongoose.Types.ObjectId,\n finalScore: { team1: number; team2: number }\n ): Promise<{winnerIds: mongoose.Types.ObjectId[]; loserIds: mongoose.Types.ObjectId[]}> {\n const participants = await this.participantService.getAll(tournamentId);\n const outcomes = this.resolveOutcomes(participants, matchId, finalScore);\n await this.repository.evaluate(tournamentId, matchId, finalScore);\n return outcomes;\n }\n\n public async create(userId: mongoose.Types.ObjectId, input: CreatePredictionInputDTO): Promise<PredictionOutputDTO> {\n const match = await this.findMatch(input.tournamentId, input.matchId);\n this.ensureMatchIsOpen(match);\n\n const participant = await this.participantService.getByUserAndTournament(userId, input.tournamentId);\n this.ensureMatchInvolvesParticipantTeam(match, participant);\n this.ensureNoPriorPrediction(participant, input.matchId);\n\n const prediction = PredictionBuilder.buildPrediction(input.matchId, input.score);\n const result = await this.repository.addPrediction(participant._id, prediction);\n if (!result) throw notFoundError('Participant not found');\n\n return prediction as PredictionOutputDTO;\n }\n\n public async edit(userId: mongoose.Types.ObjectId, input: EditPredictionInputDTO): Promise<PredictionOutputDTO> {\n const match = await this.findMatch(input.tournamentId, input.matchId);\n this.ensureMatchIsOpen(match);\n\n const participant = await this.participantService.getByUserAndTournament(userId, input.tournamentId);\n this.ensureMatchInvolvesParticipantTeam(match, participant);\n this.findPrediction(participant, input.matchId);\n\n const result = await this.repository.updatePrediction(\n participant._id,\n input.matchId,\n PredictionBuilder.buildScoreUpdate(input.score)\n );\n if (!result) throw notFoundError('Participant not found');\n\n const updated = result.predictions.find(p => p.matchId.toString() === input.matchId.toString());\n if (!updated) throw notFoundError('Prediction not found after update');\n\n return updated as unknown as PredictionOutputDTO;\n }\n\n public async get(userId: mongoose.Types.ObjectId, input: GetPredictionInputDTO): Promise<PredictionOutputDTO | null> {\n const participant = await this.participantService.getByUserAndTournament(userId, input.tournamentId);\n const prediction = participant.predictions.find(p => p.matchId.toString() === input.matchId.toString());\n return (prediction as unknown as PredictionOutputDTO) ?? null;\n }\n}\n\nexport const predictionService = Container.get(PredictionService);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reward.builder.d.ts","sourceRoot":"/","sources":["modules/tournament/reward/reward.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"reward.builder.d.ts","sourceRoot":"/","sources":["modules/tournament/reward/reward.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAQ7C,qBAAa,aAAa;IACtB,MAAM,CAAC,wBAAwB,CAC3B,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAChC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GACrC,aAAa;CAiCnB"}
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RewardBuilder = void 0;
|
|
4
4
|
const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
|
|
5
|
+
const tournament_utils_1 = require("../tournament.utils");
|
|
5
6
|
const FWC_DISCOUNT_PERCENTAGE = 10;
|
|
6
7
|
const FWC_MAX_DISCOUNT_AMOUNT = 5;
|
|
7
8
|
const FWC_MIN_ORDER_VALUE = 5;
|
|
8
9
|
class RewardBuilder {
|
|
9
10
|
static buildCouponRewardContext(matchId, tournamentId, winnerIds) {
|
|
10
|
-
const now =
|
|
11
|
+
const now = (0, tournament_utils_1.utcNow)();
|
|
11
12
|
const expiresAt = new Date(now);
|
|
12
13
|
expiresAt.setMonth(expiresAt.getMonth() + 1);
|
|
13
14
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reward.builder.js","sourceRoot":"/","sources":["modules/tournament/reward/reward.builder.ts"],"names":[],"mappings":";;;AACA,4DAAkF;
|
|
1
|
+
{"version":3,"file":"reward.builder.js","sourceRoot":"/","sources":["modules/tournament/reward/reward.builder.ts"],"names":[],"mappings":";;;AACA,4DAAkF;AAElF,0DAA2C;AAG3C,MAAM,uBAAuB,GAAG,EAAE,CAAC;AACnC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAClC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B,MAAa,aAAa;IACtB,MAAM,CAAC,wBAAwB,CAC3B,OAAgC,EAChC,YAAqC,EACrC,SAAoC;QAEpC,MAAM,GAAG,GAAG,IAAA,yBAAM,GAAE,CAAC;QACrB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;QAChC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC;QAE7C,OAAO;YACH,OAAO,EAAE,SAAS;YAClB,YAAY;YACZ,OAAO;YACP,OAAO,EAAE;gBACL,UAAU,EAAE,iBAAU,CAAC,eAAe;gBACtC,SAAS,EAAE,gBAAS,CAAC,UAAU;gBAC/B,KAAK,EAAE,uBAAuB;gBAC9B,gBAAgB,EAAE,uBAAuB;gBACzC,QAAQ,EAAE,EAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAC;gBACtC,mBAAmB,EAAE,KAAK;gBAC1B,UAAU,EAAE,IAAI;gBAChB,0BAA0B,EAAE,IAAI;gBAChC,iBAAiB,EAAE,CAAC;gBACpB,sBAAsB,EAAE,IAAI;gBAC5B,aAAa,EAAE,mBAAmB;gBAClC,SAAS,EAAE;oBACP,eAAQ,CAAC,IAAI;oBACb,eAAQ,CAAC,OAAO;oBAChB,eAAQ,CAAC,QAAQ;oBACjB,eAAQ,CAAC,MAAM;oBACf,eAAQ,CAAC,MAAM;oBACf,eAAQ,CAAC,GAAG;oBACZ,eAAQ,CAAC,cAAc;iBAC1B;aACJ;SACJ,CAAC;IACN,CAAC;CACJ;AAtCD,sCAsCC","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\nimport {CouponType, ItemType, ValueType} from '@lyxa.ai/core/dist/utilities/enum';\nimport {RewardContext} from './reward.types';\nimport {utcNow} from '../tournament.utils';\n\n// TODO: make these admin-configurable via tournament reward settings\nconst FWC_DISCOUNT_PERCENTAGE = 10;\nconst FWC_MAX_DISCOUNT_AMOUNT = 5;\nconst FWC_MIN_ORDER_VALUE = 5;\n\nexport class RewardBuilder {\n static buildCouponRewardContext(\n matchId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId,\n winnerIds: mongoose.Types.ObjectId[]\n ): RewardContext {\n const now = utcNow();\n const expiresAt = new Date(now);\n expiresAt.setMonth(expiresAt.getMonth() + 1);\n\n return {\n userIds: winnerIds,\n tournamentId,\n matchId,\n payload: {\n couponType: CouponType.INDIVIDUAL_USER,\n valueType: ValueType.PERCENTAGE,\n value: FWC_DISCOUNT_PERCENTAGE,\n maxDiscountLimit: FWC_MAX_DISCOUNT_AMOUNT,\n duration: {start: now, end: expiresAt},\n isSpendLimitEnabled: false,\n spendLimit: null,\n isOrderLimitPerUserEnabled: true,\n orderLimitPerUser: 1,\n isMinOrderValueEnabled: true,\n minOrderValue: FWC_MIN_ORDER_VALUE,\n itemTypes: [\n ItemType.FOOD,\n ItemType.GROCERY,\n ItemType.PHARMACY,\n ItemType.COFFEE,\n ItemType.FLOWER,\n ItemType.PET,\n ItemType.HEALTHY_CORNER,\n ],\n },\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mongoose } from '@typegoose/typegoose';
|
|
2
|
+
export declare class RewardRepository {
|
|
3
|
+
private couponModel;
|
|
4
|
+
constructor();
|
|
5
|
+
findCouponCodesByIds(ids: mongoose.Types.ObjectId[]): Promise<Map<string, string>>;
|
|
6
|
+
}
|
|
7
|
+
export declare const rewardRepository: RewardRepository;
|
|
8
|
+
//# sourceMappingURL=reward.repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reward.repository.d.ts","sourceRoot":"/","sources":["modules/tournament/reward/reward.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,qBACa,gBAAgB;IACzB,OAAO,CAAC,WAAW,CAAqB;;IAMlC,oBAAoB,CAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAK3F;AAED,eAAO,MAAM,gBAAgB,kBAAkC,CAAC"}
|
|
@@ -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,oDAA6B,CAAC,CAAC;IAC5E,CAAC;IAEM,KAAK,CAAC,eAAe;QACxB,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC;QAChE,IAAI,CAAC,UAAU;YAAE,OAAO;QAExB,MAAM,YAAY,GAAG,UAAU,CAAC,GAAG,CAAC;QACpC,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;QAC5E,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEvB,MAAM,OAAO,CAAC,GAAG,CACb,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAC3B,OAAO,CAAC,GAAG,CACP,UAAU,CAAC,sBAAsB,CAAC,GAAG,CAAC,KAAK,EAAE,EAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAC,EAAE,EAAE;YACzE,MAAM,gBAAgB,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,GAAG,YAAY,GAAG,EAAE,GAAG,IAAI,CAAC;YAC3F,MAAM,KAAK,GAAG,KAAK,CAAC,iBAAmE,CAAC;YAExF,IAAI,GAAG,GAAG,gBAAgB;gBAAE,OAAO;YACnC,IAAI,KAAK,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI;gBAAE,OAAO;YAEnC,MAAM,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;YACtG,MAAM,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,YAAY,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAClF,CAAC,CAAC,CACL,CACJ,CACJ,CAAC;IACN,CAAC;CACJ,CAAA;AAtCY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,gBAAO,GAAE;;GACG,eAAe,CAsC3B;AAEY,QAAA,uBAAuB,GAAG,gBAAS,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {TournamentConfigRepository} from '../config/config.repository';\nimport {TournamentMatchRepository} from '../match/match.repository';\nimport {NotificationTemplateRepository} from '../notification/notification-template.repository';\nimport {TournamentNotificationService} from '../notification/notification.service';\n\n@Service()\nexport class ScheduleService {\n private configRepository: TournamentConfigRepository;\n private matchRepository: TournamentMatchRepository;\n private templateRepository: NotificationTemplateRepository;\n private notificationService: TournamentNotificationService;\n\n constructor() {\n this.configRepository = Container.get(TournamentConfigRepository);\n this.matchRepository = Container.get(TournamentMatchRepository);\n this.templateRepository = Container.get(NotificationTemplateRepository);\n this.notificationService = Container.get(TournamentNotificationService);\n }\n\n public async dispatchPending(): Promise<void> {\n const tournament = await this.configRepository.findActiveFull();\n if (!tournament) return;\n\n const tournamentId = tournament._id;\n const templates = await this.templateRepository.findTemplates(tournamentId);\n const now = Date.now();\n\n await Promise.all(\n tournament.matches.map(match =>\n Promise.all(\n tournament.scheduledNotifications.map(async ({type, durationMins, target}) => {\n const notificationTime = new Date(match.startingDate).getTime() - durationMins * 60 * 1000;\n const flags = match.notificationFlags as unknown as Record<string, boolean> | undefined;\n\n if (now < notificationTime) return;\n if (flags?.[type] === true) return;\n\n await this.notificationService.dispatchScheduledJob(type, target, templates, tournamentId, match._id);\n await this.matchRepository.setNotificationFlag(tournamentId, match._id, type);\n })\n )\n )\n );\n }\n}\n\nexport const scheduleDispatchService = Container.get(ScheduleService);\n"]}
|
|
@@ -1,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
|
|
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":"
|
|
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
|
-
|
|
49
|
+
model;
|
|
50
50
|
constructor() {
|
|
51
|
-
this.
|
|
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;
|
|
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"]}
|