@lyxa.ai/marketing 1.0.48 → 1.0.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/event/event-initializations.js +2 -2
- package/dist/lib/event/event-initializations.js.map +1 -1
- package/dist/lib/index.d.ts +462 -508
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts +2 -2
- package/dist/lib/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/global-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/global-coupon.service.js +2 -0
- package/dist/lib/modules/coupon/services/global-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/helper.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/helper.service.js +2 -0
- package/dist/lib/modules/coupon/services/helper.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/individual-user-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/individual-user-coupon.service.js +2 -0
- package/dist/lib/modules/coupon/services/individual-user-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/referral-reward-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/referral-reward-coupon.service.js +2 -0
- package/dist/lib/modules/coupon/services/referral-reward-coupon.service.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts +10 -21
- package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js +5 -4
- package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +154 -0
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js +13 -1
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts +8 -2
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js +11 -2
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts +10 -21
- package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
- package/dist/lib/modules/tournament/config/config.builder.d.ts.map +1 -1
- package/dist/lib/modules/tournament/config/config.builder.js +4 -0
- package/dist/lib/modules/tournament/config/config.builder.js.map +1 -1
- package/dist/lib/modules/tournament/config/config.repository.d.ts +4 -0
- package/dist/lib/modules/tournament/config/config.repository.d.ts.map +1 -1
- package/dist/lib/modules/tournament/config/config.repository.js +10 -1
- package/dist/lib/modules/tournament/config/config.repository.js.map +1 -1
- package/dist/lib/modules/tournament/config/config.router.d.ts +106 -218
- package/dist/lib/modules/tournament/config/config.router.d.ts.map +1 -1
- package/dist/lib/modules/tournament/config/config.service.d.ts +2 -2
- package/dist/lib/modules/tournament/config/config.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/config/config.service.js.map +1 -1
- package/dist/lib/modules/tournament/config/config.validation.d.ts +446 -692
- package/dist/lib/modules/tournament/config/config.validation.d.ts.map +1 -1
- package/dist/lib/modules/tournament/config/config.validation.js +44 -28
- package/dist/lib/modules/tournament/config/config.validation.js.map +1 -1
- package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.d.ts +2 -0
- package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.d.ts.map +1 -0
- package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js +28 -0
- package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js.map +1 -0
- package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.d.ts +15 -0
- package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.d.ts.map +1 -0
- package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.js +12 -0
- package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.js.map +1 -0
- package/dist/lib/modules/tournament/match/match.builder.d.ts +5 -2
- package/dist/lib/modules/tournament/match/match.builder.d.ts.map +1 -1
- package/dist/lib/modules/tournament/match/match.builder.js +13 -7
- 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 +66 -191
- package/dist/lib/modules/tournament/match/match.router.d.ts.map +1 -1
- package/dist/lib/modules/tournament/match/match.router.js +0 -7
- package/dist/lib/modules/tournament/match/match.router.js.map +1 -1
- package/dist/lib/modules/tournament/match/match.service.d.ts +1 -12
- package/dist/lib/modules/tournament/match/match.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/match/match.service.js +18 -68
- package/dist/lib/modules/tournament/match/match.service.js.map +1 -1
- package/dist/lib/modules/tournament/match/match.validation.d.ts +96 -34
- package/dist/lib/modules/tournament/match/match.validation.d.ts.map +1 -1
- package/dist/lib/modules/tournament/match/match.validation.js +5 -2
- 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 -3
- package/dist/lib/modules/tournament/notification/notification.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/notification/notification.service.js +33 -23
- package/dist/lib/modules/tournament/notification/notification.service.js.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.repository.d.ts +1 -0
- package/dist/lib/modules/tournament/participant/participant.repository.d.ts.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.repository.js +6 -0
- package/dist/lib/modules/tournament/participant/participant.repository.js.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.router.d.ts +9 -9
- package/dist/lib/modules/tournament/participant/participant.validation.d.ts +84 -84
- 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.repository.d.ts +4 -1
- package/dist/lib/modules/tournament/prediction/prediction.repository.d.ts.map +1 -1
- package/dist/lib/modules/tournament/prediction/prediction.repository.js +20 -2
- package/dist/lib/modules/tournament/prediction/prediction.repository.js.map +1 -1
- package/dist/lib/modules/tournament/prediction/prediction.router.d.ts +12 -12
- package/dist/lib/modules/tournament/prediction/prediction.service.d.ts +9 -0
- package/dist/lib/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/prediction/prediction.service.js +30 -4
- package/dist/lib/modules/tournament/prediction/prediction.service.js.map +1 -1
- package/dist/lib/modules/tournament/prediction/prediction.validation.d.ts +64 -64
- package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.d.ts +3 -0
- package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.d.ts.map +1 -1
- package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.js +21 -5
- package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.js.map +1 -1
- package/dist/lib/modules/tournament/reward/reward.builder.d.ts +6 -0
- package/dist/lib/modules/tournament/reward/reward.builder.d.ts.map +1 -0
- package/dist/lib/modules/tournament/reward/reward.builder.js +44 -0
- package/dist/lib/modules/tournament/reward/reward.builder.js.map +1 -0
- package/dist/lib/modules/tournament/reward/reward.interface.d.ts.map +1 -1
- package/dist/lib/modules/tournament/reward/reward.interface.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/reward/reward.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/reward/reward.service.js.map +1 -1
- package/dist/lib/modules/tournament/reward/reward.types.d.ts +1 -1
- package/dist/lib/modules/tournament/reward/reward.types.d.ts.map +1 -1
- package/dist/lib/modules/tournament/reward/reward.types.js.map +1 -1
- 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 +13 -0
- package/dist/lib/modules/tournament/score/score.repository.d.ts.map +1 -0
- package/dist/lib/modules/tournament/score/score.repository.js +70 -0
- package/dist/lib/modules/tournament/score/score.repository.js.map +1 -0
- 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 +13 -0
- package/dist/lib/modules/tournament/score/score.service.d.ts.map +1 -0
- package/dist/lib/modules/tournament/score/score.service.js +109 -0
- package/dist/lib/modules/tournament/score/score.service.js.map +1 -0
- 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 +31 -57
- 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 +21 -16
- package/dist/lib/modules/tournament/team/team.service.js.map +1 -1
- package/dist/lib/modules/tournament/team/team.validation.d.ts +68 -18
- 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 +466 -501
- package/dist/lib/modules/tournament/tournament.router.d.ts.map +1 -1
- package/dist/lib/modules/tournament/tournament.router.js +14 -0
- package/dist/lib/modules/tournament/tournament.router.js.map +1 -1
- package/dist/lib/modules/tournament/tournament.service.d.ts +8 -0
- package/dist/lib/modules/tournament/tournament.service.d.ts.map +1 -0
- package/dist/lib/modules/tournament/tournament.service.js +63 -0
- package/dist/lib/modules/tournament/tournament.service.js.map +1 -0
- package/dist/lib/modules/tournament/tournament.types.d.ts +9 -0
- package/dist/lib/modules/tournament/tournament.types.d.ts.map +1 -0
- package/dist/lib/modules/tournament/tournament.types.js +14 -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 +133 -0
- package/dist/lib/modules/tournament/tournament.validation.d.ts.map +1 -0
- package/dist/lib/modules/tournament/tournament.validation.js +14 -0
- package/dist/lib/modules/tournament/tournament.validation.js.map +1 -0
- package/dist/types/index.d.ts +462 -508
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/coupon.service.d.ts +2 -2
- package/dist/types/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/global-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/helper.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/individual-user-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/referral-reward-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts +10 -21
- package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +154 -0
- package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts +8 -2
- package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts +10 -21
- package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
- package/dist/types/modules/tournament/config/config.builder.d.ts.map +1 -1
- package/dist/types/modules/tournament/config/config.repository.d.ts +4 -0
- package/dist/types/modules/tournament/config/config.repository.d.ts.map +1 -1
- package/dist/types/modules/tournament/config/config.router.d.ts +106 -218
- package/dist/types/modules/tournament/config/config.router.d.ts.map +1 -1
- package/dist/types/modules/tournament/config/config.service.d.ts +2 -2
- package/dist/types/modules/tournament/config/config.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/config/config.validation.d.ts +446 -692
- 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 +2 -0
- package/dist/types/modules/tournament/match/events/evaluate-predictions.consumer.d.ts.map +1 -0
- package/dist/types/modules/tournament/match/events/evaluate-predictions.event.d.ts +15 -0
- package/dist/types/modules/tournament/match/events/evaluate-predictions.event.d.ts.map +1 -0
- package/dist/types/modules/tournament/match/match.builder.d.ts +5 -2
- 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 +66 -191
- package/dist/types/modules/tournament/match/match.router.d.ts.map +1 -1
- package/dist/types/modules/tournament/match/match.service.d.ts +1 -12
- package/dist/types/modules/tournament/match/match.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/match/match.validation.d.ts +96 -34
- 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 -3
- package/dist/types/modules/tournament/notification/notification.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/participant/participant.repository.d.ts +1 -0
- package/dist/types/modules/tournament/participant/participant.repository.d.ts.map +1 -1
- package/dist/types/modules/tournament/participant/participant.router.d.ts +9 -9
- package/dist/types/modules/tournament/participant/participant.validation.d.ts +84 -84
- package/dist/types/modules/tournament/prediction/prediction.builder.d.ts.map +1 -1
- package/dist/types/modules/tournament/prediction/prediction.repository.d.ts +4 -1
- package/dist/types/modules/tournament/prediction/prediction.repository.d.ts.map +1 -1
- package/dist/types/modules/tournament/prediction/prediction.router.d.ts +12 -12
- package/dist/types/modules/tournament/prediction/prediction.service.d.ts +9 -0
- package/dist/types/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/prediction/prediction.validation.d.ts +64 -64
- package/dist/types/modules/tournament/reward/handlers/coupon-reward.handler.d.ts +3 -0
- package/dist/types/modules/tournament/reward/handlers/coupon-reward.handler.d.ts.map +1 -1
- package/dist/types/modules/tournament/reward/reward.builder.d.ts +6 -0
- package/dist/types/modules/tournament/reward/reward.builder.d.ts.map +1 -0
- package/dist/types/modules/tournament/reward/reward.interface.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/reward/reward.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/reward/reward.types.d.ts +1 -1
- package/dist/types/modules/tournament/reward/reward.types.d.ts.map +1 -1
- 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 +13 -0
- package/dist/types/modules/tournament/score/score.repository.d.ts.map +1 -0
- 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 +13 -0
- package/dist/types/modules/tournament/score/score.service.d.ts.map +1 -0
- 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 +31 -57
- 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 +68 -18
- package/dist/types/modules/tournament/team/team.validation.d.ts.map +1 -1
- package/dist/types/modules/tournament/tournament.router.d.ts +466 -501
- package/dist/types/modules/tournament/tournament.router.d.ts.map +1 -1
- package/dist/types/modules/tournament/tournament.service.d.ts +8 -0
- package/dist/types/modules/tournament/tournament.service.d.ts.map +1 -0
- package/dist/types/modules/tournament/tournament.types.d.ts +9 -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 +133 -0
- package/dist/types/modules/tournament/tournament.validation.d.ts.map +1 -0
- 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"]}
|
|
@@ -5,7 +5,10 @@ export declare class PredictionRepository {
|
|
|
5
5
|
constructor();
|
|
6
6
|
addPrediction(participantId: mongoose.Types.ObjectId, prediction: object): Promise<ParticipantType | null>;
|
|
7
7
|
updatePrediction(participantId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, updates: Record<string, unknown>): Promise<ParticipantType | null>;
|
|
8
|
-
|
|
8
|
+
evaluate(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, finalScore: {
|
|
9
|
+
team1: number;
|
|
10
|
+
team2: number;
|
|
11
|
+
}): Promise<void>;
|
|
9
12
|
}
|
|
10
13
|
export declare const predictionRepository: PredictionRepository;
|
|
11
14
|
//# sourceMappingURL=prediction.repository.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prediction.repository.d.ts","sourceRoot":"/","sources":["modules/tournament/prediction/prediction.repository.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"prediction.repository.d.ts","sourceRoot":"/","sources":["modules/tournament/prediction/prediction.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EACH,qBAAqB,IAAI,eAAe,EAE3C,MAAM,2CAA2C,CAAC;AAEnD,qBACa,oBAAoB;IAC7B,OAAO,CAAC,gBAAgB,CAAoC;;IAMtD,aAAa,CAAC,aAAa,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAM1G,gBAAgB,CAClB,aAAa,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACtC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAU5B,QAAQ,CACV,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAChC,UAAU,EAAE;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,GAC3C,OAAO,CAAC,IAAI,CAAC;CAsBnB;AAED,eAAO,MAAM,oBAAoB,sBAAsC,CAAC"}
|
|
@@ -60,8 +60,26 @@ let PredictionRepository = class PredictionRepository {
|
|
|
60
60
|
.findOneAndUpdate({ _id: participantId, 'predictions.matchId': matchId }, { $set: updates }, { new: true })
|
|
61
61
|
.lean();
|
|
62
62
|
}
|
|
63
|
-
async
|
|
64
|
-
|
|
63
|
+
async evaluate(tournamentId, matchId, finalScore) {
|
|
64
|
+
const forMatch = { 'pred.matchId': matchId };
|
|
65
|
+
const correctScore = { 'pred.score.team1': finalScore.team1, 'pred.score.team2': finalScore.team2 };
|
|
66
|
+
const incorrectScore = { $or: [{ 'pred.score.team1': { $ne: finalScore.team1 } }, { 'pred.score.team2': { $ne: finalScore.team2 } }] };
|
|
67
|
+
await this.participantModel.bulkWrite([
|
|
68
|
+
{
|
|
69
|
+
updateMany: {
|
|
70
|
+
filter: { tournamentId },
|
|
71
|
+
update: { $set: { 'predictions.$[pred].succeeded': true } },
|
|
72
|
+
arrayFilters: [{ ...forMatch, ...correctScore }],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
updateMany: {
|
|
77
|
+
filter: { tournamentId },
|
|
78
|
+
update: { $set: { 'predictions.$[pred].succeeded': false } },
|
|
79
|
+
arrayFilters: [{ ...forMatch, ...incorrectScore }],
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
]);
|
|
65
83
|
}
|
|
66
84
|
};
|
|
67
85
|
exports.PredictionRepository = PredictionRepository;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prediction.repository.js","sourceRoot":"/","sources":["modules/tournament/prediction/prediction.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"prediction.repository.js","sourceRoot":"/","sources":["modules/tournament/prediction/prediction.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,sEAGmD;AAG5C,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IACrB,gBAAgB,CAAoC;IAE5D;QACI,IAAI,CAAC,gBAAgB,GAAG,mCAA0B,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,aAAsC,EAAE,UAAkB;QAC1E,OAAO,IAAI,CAAC,gBAAgB;aACvB,iBAAiB,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;aACvF,IAAI,EAAqC,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,gBAAgB,CAClB,aAAsC,EACtC,OAAgC,EAChC,OAAgC;QAEhC,OAAO,IAAI,CAAC,gBAAgB;aACvB,gBAAgB,CACb,EAAE,GAAG,EAAE,aAAa,EAAE,qBAAqB,EAAE,OAAO,EAAE,EACtD,EAAE,IAAI,EAAE,OAAO,EAAE,EACjB,EAAE,GAAG,EAAE,IAAI,EAAE,CAChB;aACA,IAAI,EAAqC,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,QAAQ,CACV,YAAqC,EACrC,OAAgC,EAChC,UAA0C;QAE1C,MAAM,QAAQ,GAAG,EAAC,cAAc,EAAE,OAAO,EAAC,CAAC;QAC3C,MAAM,YAAY,GAAG,EAAC,kBAAkB,EAAE,UAAU,CAAC,KAAK,EAAE,kBAAkB,EAAE,UAAU,CAAC,KAAK,EAAC,CAAC;QAClG,MAAM,cAAc,GAAG,EAAC,GAAG,EAAE,CAAC,EAAC,kBAAkB,EAAE,EAAC,GAAG,EAAE,UAAU,CAAC,KAAK,EAAC,EAAC,EAAE,EAAC,kBAAkB,EAAE,EAAC,GAAG,EAAE,UAAU,CAAC,KAAK,EAAC,EAAC,CAAC,EAAC,CAAC;QAE7H,MAAM,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC;YAClC;gBACI,UAAU,EAAE;oBACR,MAAM,EAAE,EAAC,YAAY,EAAC;oBACtB,MAAM,EAAE,EAAC,IAAI,EAAE,EAAC,+BAA+B,EAAE,IAAI,EAAC,EAAC;oBACvD,YAAY,EAAE,CAAC,EAAC,GAAG,QAAQ,EAAE,GAAG,YAAY,EAAC,CAAC;iBACjD;aACJ;YACD;gBACI,UAAU,EAAE;oBACR,MAAM,EAAE,EAAC,YAAY,EAAC;oBACtB,MAAM,EAAE,EAAC,IAAI,EAAE,EAAC,+BAA+B,EAAE,KAAK,EAAC,EAAC;oBACxD,YAAY,EAAE,CAAC,EAAC,GAAG,QAAQ,EAAE,GAAG,cAAc,EAAC,CAAC;iBACnD;aACJ;SACJ,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AArDY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,gBAAO,GAAE;;GACG,oBAAoB,CAqDhC;AAEY,QAAA,oBAAoB,GAAG,gBAAS,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {\n TournamentParticipant as ParticipantType,\n TournamentParticipantModel,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\n\n@Service()\nexport class PredictionRepository {\n private participantModel: typeof TournamentParticipantModel;\n\n constructor() {\n this.participantModel = TournamentParticipantModel;\n }\n\n async addPrediction(participantId: mongoose.Types.ObjectId, prediction: object): Promise<ParticipantType | null> {\n return this.participantModel\n .findByIdAndUpdate(participantId, { $push: { predictions: prediction } }, { new: true })\n .lean() as Promise<ParticipantType | null>;\n }\n\n async updatePrediction(\n participantId: mongoose.Types.ObjectId,\n matchId: mongoose.Types.ObjectId,\n updates: Record<string, unknown>\n ): Promise<ParticipantType | null> {\n return this.participantModel\n .findOneAndUpdate(\n { _id: participantId, 'predictions.matchId': matchId },\n { $set: updates },\n { new: true }\n )\n .lean() as Promise<ParticipantType | null>;\n }\n\n async evaluate(\n tournamentId: mongoose.Types.ObjectId,\n matchId: mongoose.Types.ObjectId,\n finalScore: {team1: number; team2: number}\n ): Promise<void> {\n const forMatch = {'pred.matchId': matchId};\n const correctScore = {'pred.score.team1': finalScore.team1, 'pred.score.team2': finalScore.team2};\n const incorrectScore = {$or: [{'pred.score.team1': {$ne: finalScore.team1}}, {'pred.score.team2': {$ne: finalScore.team2}}]};\n\n await this.participantModel.bulkWrite([\n {\n updateMany: {\n filter: {tournamentId},\n update: {$set: {'predictions.$[pred].succeeded': true}},\n arrayFilters: [{...forMatch, ...correctScore}],\n },\n },\n {\n updateMany: {\n filter: {tournamentId},\n update: {$set: {'predictions.$[pred].succeeded': false}},\n arrayFilters: [{...forMatch, ...incorrectScore}],\n },\n },\n ]);\n }\n}\n\nexport const predictionRepository = Container.get(PredictionRepository);"]}
|
|
@@ -17,31 +17,31 @@ export declare const predictionRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
17
17
|
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
18
18
|
create: import("@trpc/server").TRPCMutationProcedure<{
|
|
19
19
|
input: {
|
|
20
|
+
tournamentId: string | mongoose.Types.ObjectId;
|
|
21
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
20
22
|
score: {
|
|
21
23
|
team1: number;
|
|
22
24
|
team2: number;
|
|
23
25
|
};
|
|
24
|
-
tournamentId: string | mongoose.Types.ObjectId;
|
|
25
|
-
matchId: string | mongoose.Types.ObjectId;
|
|
26
26
|
};
|
|
27
27
|
output: {
|
|
28
28
|
message: string;
|
|
29
29
|
success: boolean;
|
|
30
30
|
data?: {
|
|
31
31
|
_id: string | mongoose.Types.ObjectId;
|
|
32
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
32
33
|
score: {
|
|
33
34
|
team1: number | null;
|
|
34
35
|
team2: number | null;
|
|
35
36
|
};
|
|
36
|
-
matchId: string | mongoose.Types.ObjectId;
|
|
37
37
|
} | {
|
|
38
38
|
documents: {
|
|
39
39
|
_id: string | mongoose.Types.ObjectId;
|
|
40
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
40
41
|
score: {
|
|
41
42
|
team1: number | null;
|
|
42
43
|
team2: number | null;
|
|
43
44
|
};
|
|
44
|
-
matchId: string | mongoose.Types.ObjectId;
|
|
45
45
|
}[];
|
|
46
46
|
metadata?: {
|
|
47
47
|
page: number;
|
|
@@ -55,31 +55,31 @@ export declare const predictionRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
55
55
|
}>;
|
|
56
56
|
edit: import("@trpc/server").TRPCMutationProcedure<{
|
|
57
57
|
input: {
|
|
58
|
+
tournamentId: string | mongoose.Types.ObjectId;
|
|
59
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
58
60
|
score: {
|
|
59
61
|
team1: number;
|
|
60
62
|
team2: number;
|
|
61
63
|
};
|
|
62
|
-
tournamentId: string | mongoose.Types.ObjectId;
|
|
63
|
-
matchId: string | mongoose.Types.ObjectId;
|
|
64
64
|
};
|
|
65
65
|
output: {
|
|
66
66
|
message: string;
|
|
67
67
|
success: boolean;
|
|
68
68
|
data?: {
|
|
69
69
|
_id: string | mongoose.Types.ObjectId;
|
|
70
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
70
71
|
score: {
|
|
71
72
|
team1: number | null;
|
|
72
73
|
team2: number | null;
|
|
73
74
|
};
|
|
74
|
-
matchId: string | mongoose.Types.ObjectId;
|
|
75
75
|
} | {
|
|
76
76
|
documents: {
|
|
77
77
|
_id: string | mongoose.Types.ObjectId;
|
|
78
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
78
79
|
score: {
|
|
79
80
|
team1: number | null;
|
|
80
81
|
team2: number | null;
|
|
81
82
|
};
|
|
82
|
-
matchId: string | mongoose.Types.ObjectId;
|
|
83
83
|
}[];
|
|
84
84
|
metadata?: {
|
|
85
85
|
page: number;
|
|
@@ -101,23 +101,23 @@ export declare const predictionRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
101
101
|
success: boolean;
|
|
102
102
|
data?: {
|
|
103
103
|
_id: string | mongoose.Types.ObjectId;
|
|
104
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
104
105
|
score: {
|
|
105
106
|
team1: number | null;
|
|
106
107
|
team2: number | null;
|
|
107
108
|
};
|
|
108
|
-
matchId: string | mongoose.Types.ObjectId;
|
|
109
|
-
succeeded?: boolean | null | undefined;
|
|
110
109
|
predictionTime?: Date | null | undefined;
|
|
110
|
+
succeeded?: boolean | null | undefined;
|
|
111
111
|
} | {
|
|
112
112
|
documents: ({
|
|
113
113
|
_id: string | mongoose.Types.ObjectId;
|
|
114
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
114
115
|
score: {
|
|
115
116
|
team1: number | null;
|
|
116
117
|
team2: number | null;
|
|
117
118
|
};
|
|
118
|
-
matchId: string | mongoose.Types.ObjectId;
|
|
119
|
-
succeeded?: boolean | null | undefined;
|
|
120
119
|
predictionTime?: Date | null | undefined;
|
|
120
|
+
succeeded?: boolean | null | undefined;
|
|
121
121
|
} | null)[];
|
|
122
122
|
metadata?: {
|
|
123
123
|
page: number;
|
|
@@ -7,8 +7,17 @@ export declare class PredictionService {
|
|
|
7
7
|
constructor();
|
|
8
8
|
private findMatch;
|
|
9
9
|
private ensureMatchIsOpen;
|
|
10
|
+
private ensureMatchInvolvesParticipantTeam;
|
|
10
11
|
private ensureNoPriorPrediction;
|
|
11
12
|
private findPrediction;
|
|
13
|
+
private resolveOutcomes;
|
|
14
|
+
evaluate(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, finalScore: {
|
|
15
|
+
team1: number;
|
|
16
|
+
team2: number;
|
|
17
|
+
}): Promise<{
|
|
18
|
+
winnerIds: mongoose.Types.ObjectId[];
|
|
19
|
+
loserIds: mongoose.Types.ObjectId[];
|
|
20
|
+
}>;
|
|
12
21
|
create(userId: mongoose.Types.ObjectId, input: CreatePredictionInputDTO): Promise<PredictionOutputDTO>;
|
|
13
22
|
edit(userId: mongoose.Types.ObjectId, input: EditPredictionInputDTO): Promise<PredictionOutputDTO>;
|
|
14
23
|
get(userId: mongoose.Types.ObjectId, input: GetPredictionInputDTO): Promise<PredictionOutputDTO | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prediction.service.d.ts","sourceRoot":"/","sources":["modules/tournament/prediction/prediction.service.ts"],"names":[],"mappings":"
|
|
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;IAS1C,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"}
|
|
@@ -44,12 +44,12 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
44
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
45
|
exports.predictionService = exports.PredictionService = void 0;
|
|
46
46
|
const typedi_1 = __importStar(require("typedi"));
|
|
47
|
-
const server_1 = require("@trpc/server");
|
|
48
47
|
const error_common_1 = require("@lyxa.ai/core/dist/utilities/error-common");
|
|
49
48
|
const prediction_repository_1 = require("./prediction.repository");
|
|
50
49
|
const prediction_builder_1 = require("./prediction.builder");
|
|
51
50
|
const participant_service_1 = require("../participant/participant.service");
|
|
52
51
|
const match_repository_1 = require("../match/match.repository");
|
|
52
|
+
const tournament_utils_1 = require("../tournament.utils");
|
|
53
53
|
let PredictionService = class PredictionService {
|
|
54
54
|
repository;
|
|
55
55
|
matchRepository;
|
|
@@ -71,10 +71,16 @@ let PredictionService = class PredictionService {
|
|
|
71
71
|
ensureMatchIsOpen(match) {
|
|
72
72
|
if (match.endDate)
|
|
73
73
|
throw (0, error_common_1.badRequestError)('This match has already ended');
|
|
74
|
-
if (match.startingDate && match.startingDate <=
|
|
74
|
+
if (match.startingDate && match.startingDate <= (0, tournament_utils_1.utcNow)()) {
|
|
75
75
|
throw (0, error_common_1.badRequestError)('The prediction window for this match has closed');
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
+
ensureMatchInvolvesParticipantTeam(match, participant) {
|
|
79
|
+
const teamId = participant.teamId.toString();
|
|
80
|
+
const involved = match.team1.teamId.toString() === teamId || match.team2.teamId.toString() === teamId;
|
|
81
|
+
if (!involved)
|
|
82
|
+
throw (0, error_common_1.badRequestError)('You can only predict for matches involving your selected team');
|
|
83
|
+
}
|
|
78
84
|
ensureNoPriorPrediction(participant, matchId) {
|
|
79
85
|
const exists = participant.predictions.some(p => p.matchId.toString() === matchId.toString());
|
|
80
86
|
if (exists)
|
|
@@ -86,25 +92,45 @@ let PredictionService = class PredictionService {
|
|
|
86
92
|
throw (0, error_common_1.notFoundError)('No prediction found for this match');
|
|
87
93
|
return prediction;
|
|
88
94
|
}
|
|
95
|
+
resolveOutcomes(participants, matchId, finalScore) {
|
|
96
|
+
const winnerIds = [];
|
|
97
|
+
const loserIds = [];
|
|
98
|
+
for (const participant of participants) {
|
|
99
|
+
const prediction = participant.predictions.find(p => p.matchId.toString() === matchId.toString());
|
|
100
|
+
if (!prediction)
|
|
101
|
+
continue;
|
|
102
|
+
const isWinner = prediction.score.team1 === finalScore.team1 && prediction.score.team2 === finalScore.team2;
|
|
103
|
+
(isWinner ? winnerIds : loserIds).push(participant.userId);
|
|
104
|
+
}
|
|
105
|
+
return { winnerIds, loserIds };
|
|
106
|
+
}
|
|
107
|
+
async evaluate(tournamentId, matchId, finalScore) {
|
|
108
|
+
const participants = await this.participantService.getAll(tournamentId);
|
|
109
|
+
const outcomes = this.resolveOutcomes(participants, matchId, finalScore);
|
|
110
|
+
await this.repository.evaluate(tournamentId, matchId, finalScore);
|
|
111
|
+
return outcomes;
|
|
112
|
+
}
|
|
89
113
|
async create(userId, input) {
|
|
90
114
|
const match = await this.findMatch(input.tournamentId, input.matchId);
|
|
91
115
|
this.ensureMatchIsOpen(match);
|
|
92
116
|
const participant = await this.participantService.getByUserAndTournament(userId, input.tournamentId);
|
|
117
|
+
this.ensureMatchInvolvesParticipantTeam(match, participant);
|
|
93
118
|
this.ensureNoPriorPrediction(participant, input.matchId);
|
|
94
119
|
const prediction = prediction_builder_1.PredictionBuilder.buildPrediction(input.matchId, input.score);
|
|
95
120
|
const result = await this.repository.addPrediction(participant._id, prediction);
|
|
96
121
|
if (!result)
|
|
97
|
-
throw
|
|
122
|
+
throw (0, error_common_1.notFoundError)('Participant not found');
|
|
98
123
|
return prediction;
|
|
99
124
|
}
|
|
100
125
|
async edit(userId, input) {
|
|
101
126
|
const match = await this.findMatch(input.tournamentId, input.matchId);
|
|
102
127
|
this.ensureMatchIsOpen(match);
|
|
103
128
|
const participant = await this.participantService.getByUserAndTournament(userId, input.tournamentId);
|
|
129
|
+
this.ensureMatchInvolvesParticipantTeam(match, participant);
|
|
104
130
|
this.findPrediction(participant, input.matchId);
|
|
105
131
|
const result = await this.repository.updatePrediction(participant._id, input.matchId, prediction_builder_1.PredictionBuilder.buildScoreUpdate(input.score));
|
|
106
132
|
if (!result)
|
|
107
|
-
throw
|
|
133
|
+
throw (0, error_common_1.notFoundError)('Participant not found');
|
|
108
134
|
const updated = result.predictions.find(p => p.matchId.toString() === input.matchId.toString());
|
|
109
135
|
if (!updated)
|
|
110
136
|
throw (0, error_common_1.notFoundError)('Prediction not found after update');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prediction.service.js","sourceRoot":"/","sources":["modules/tournament/prediction/prediction.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAC5C,yCAAyC;AAEzC,4EAA2F;AAE3F,mEAA+D;AAC/D,6DAAyD;AACzD,4EAAwE;AA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AAM,UAAU,GAAG,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;QACxG,OAAQ,UAA6C,IAAI,IAAI,CAAC;IAClE,CAAC;CACJ,CAAA;AA5EY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,gBAAO,GAAE;;GACG,iBAAiB,CA4E7B;AAEY,QAAA,iBAAiB,GAAG,gBAAS,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { TRPCError } from '@trpc/server';\nimport { mongoose } from '@typegoose/typegoose';\nimport { badRequestError, notFoundError } from '@lyxa.ai/core/dist/utilities/error-common';\nimport { CreatePredictionInputDTO, EditPredictionInputDTO, GetPredictionInputDTO, PredictionOutputDTO } 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 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 new TRPCError({ code: 'INTERNAL_SERVER_ERROR', message: 'Failed to create prediction' });\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 new TRPCError({ code: 'INTERNAL_SERVER_ERROR', message: 'Failed to update prediction' });\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;QACpF,IAAI,CAAC,KAAK;YAAE,MAAM,IAAA,4BAAa,EAAC,iBAAiB,CAAC,CAAC;QACnD,OAAO,KAAK,CAAC;IACjB,CAAC;IAEO,iBAAiB,CAA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iB,CAAC,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,CAClD,CAAC;QACF,IAAI,CAAC,MAAM;YAAE,MAAM,IAAA,4BAAa,EAAC,uBAAuB,CAAC,CAAC;QAE1D,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;QAChG,IAAI,CAAC,OAAO;YAAE,MAAM,IAAA,4BAAa,EAAC,mCAAmC,CAAC,CAAC;QAEvE,OAAO,OAAyC,CAAC;IACrD,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,MAA+B,EAAE,KAA4B;QAC1E,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,sBAAsB,CAAC,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;QACrG,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;QACxG,OAAQ,UAA6C,IAAI,IAAI,CAAC;IAClE,CAAC;CACJ,CAAA;AArHY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,gBAAO,GAAE;;GACG,iBAAiB,CAqH7B;AAEY,QAAA,iBAAiB,GAAG,gBAAS,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {badRequestError, notFoundError} from '@lyxa.ai/core/dist/utilities/error-common';\nimport {\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 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"]}
|