@lyxa.ai/marketing 1.0.47 → 1.0.49
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.d.ts.map +1 -1
- package/dist/lib/event/event-initializations.js +2 -0
- package/dist/lib/event/event-initializations.js.map +1 -1
- package/dist/lib/index.d.ts +1102 -28
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +3 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts +4 -0
- package/dist/lib/modules/coupon/routers/coupon.router.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 +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/custom-coupon.service.d.ts +2 -0
- package/dist/lib/modules/coupon/services/custom-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/custom-coupon.service.js +1 -1
- package/dist/lib/modules/coupon/services/custom-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/global-coupon.service.d.ts +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 +18 -10
- package/dist/lib/modules/coupon/services/global-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/helper.service.d.ts +2 -1
- package/dist/lib/modules/coupon/services/helper.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/helper.service.js +9 -1
- package/dist/lib/modules/coupon/services/helper.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/individual-store-coupon.service.d.ts +2 -0
- package/dist/lib/modules/coupon/services/individual-store-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/individual-store-coupon.service.js +2 -2
- package/dist/lib/modules/coupon/services/individual-store-coupon.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 +8 -0
- package/dist/lib/modules/coupon/services/individual-user-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.js +20 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.js.map +1 -1
- package/dist/lib/modules/coupon/services/referral-code-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/referral-code-coupon.service.js +1 -1
- package/dist/lib/modules/coupon/services/referral-code-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/referral-reward-coupon.service.d.ts +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 +23 -15
- package/dist/lib/modules/coupon/services/referral-reward-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/shops-categories-coupon.service.d.ts +2 -0
- package/dist/lib/modules/coupon/services/shops-categories-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/shops-categories-coupon.service.js +2 -2
- package/dist/lib/modules/coupon/services/shops-categories-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts +13 -0
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.js +1 -0
- package/dist/lib/modules/coupon/validations/coupon.validation.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 +16 -27
- package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +6 -6
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +30 -30
- package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/marketing.service.js +8 -2
- package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.d.ts +2 -0
- package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.js +14 -0
- package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/validations/buy1-get1-marketing.validation.d.ts +18 -18
- package/dist/lib/modules/marketing/validations/discount-marketing.validation.d.ts +30 -30
- package/dist/lib/modules/marketing/validations/featured-marketing.validation.d.ts +6 -6
- package/dist/lib/modules/marketing/validations/free-delivery-marketing.validation.d.ts +4 -4
- package/dist/lib/modules/marketing/validations/marketing.validation.d.ts +2 -2
- package/dist/lib/modules/marketing/validations/product-marketing.validation.d.ts +5 -5
- package/dist/lib/modules/marketing/validations/punch-marketing.validation.d.ts +4 -4
- package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +1 -1
- package/dist/lib/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +2 -2
- package/dist/lib/modules/tournament/config/config.builder.d.ts +5 -0
- package/dist/lib/modules/tournament/config/config.builder.d.ts.map +1 -0
- package/dist/lib/modules/tournament/config/config.builder.js +23 -0
- package/dist/lib/modules/tournament/config/config.builder.js.map +1 -0
- package/dist/lib/modules/tournament/config/config.repository.d.ts +14 -0
- package/dist/lib/modules/tournament/config/config.repository.d.ts.map +1 -0
- package/dist/lib/modules/tournament/config/config.repository.js +83 -0
- package/dist/lib/modules/tournament/config/config.repository.js.map +1 -0
- package/dist/lib/modules/tournament/config/config.router.d.ts +251 -0
- package/dist/lib/modules/tournament/config/config.router.d.ts.map +1 -0
- package/dist/lib/modules/tournament/config/config.router.js +40 -0
- package/dist/lib/modules/tournament/config/config.router.js.map +1 -0
- package/dist/lib/modules/tournament/config/config.service.d.ts +14 -0
- package/dist/lib/modules/tournament/config/config.service.d.ts.map +1 -0
- package/dist/lib/modules/tournament/config/config.service.js +101 -0
- package/dist/lib/modules/tournament/config/config.service.js.map +1 -0
- package/dist/lib/modules/tournament/config/config.validation.d.ts +767 -0
- package/dist/lib/modules/tournament/config/config.validation.d.ts.map +1 -0
- package/dist/lib/modules/tournament/config/config.validation.js +85 -0
- package/dist/lib/modules/tournament/config/config.validation.js.map +1 -0
- 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 +20 -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/events/match-ended.consumer.d.ts +2 -0
- package/dist/lib/modules/tournament/match/events/match-ended.consumer.d.ts.map +1 -0
- package/dist/lib/modules/tournament/match/events/match-ended.consumer.js +15 -0
- package/dist/lib/modules/tournament/match/events/match-ended.consumer.js.map +1 -0
- package/dist/lib/modules/tournament/match/events/match-ended.event.d.ts +14 -0
- package/dist/lib/modules/tournament/match/events/match-ended.event.d.ts.map +1 -0
- package/dist/lib/modules/tournament/match/events/match-ended.event.js +12 -0
- package/dist/lib/modules/tournament/match/events/match-ended.event.js.map +1 -0
- package/dist/lib/modules/tournament/match/match.builder.d.ts +41 -0
- package/dist/lib/modules/tournament/match/match.builder.d.ts.map +1 -0
- package/dist/lib/modules/tournament/match/match.builder.js +42 -0
- package/dist/lib/modules/tournament/match/match.builder.js.map +1 -0
- package/dist/lib/modules/tournament/match/match.repository.d.ts +13 -0
- package/dist/lib/modules/tournament/match/match.repository.d.ts.map +1 -0
- package/dist/lib/modules/tournament/match/match.repository.js +84 -0
- package/dist/lib/modules/tournament/match/match.repository.js.map +1 -0
- package/dist/lib/modules/tournament/match/match.router.d.ts +352 -0
- package/dist/lib/modules/tournament/match/match.router.d.ts.map +1 -0
- package/dist/lib/modules/tournament/match/match.router.js +49 -0
- package/dist/lib/modules/tournament/match/match.router.js.map +1 -0
- package/dist/lib/modules/tournament/match/match.service.d.ts +19 -0
- package/dist/lib/modules/tournament/match/match.service.d.ts.map +1 -0
- package/dist/lib/modules/tournament/match/match.service.js +149 -0
- package/dist/lib/modules/tournament/match/match.service.js.map +1 -0
- package/dist/lib/modules/tournament/match/match.validation.d.ts +892 -0
- package/dist/lib/modules/tournament/match/match.validation.d.ts.map +1 -0
- package/dist/lib/modules/tournament/match/match.validation.js +76 -0
- package/dist/lib/modules/tournament/match/match.validation.js.map +1 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts +13 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts.map +1 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.js +28 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.js.map +1 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts +7 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts.map +1 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.worker.js +76 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.worker.js.map +1 -0
- package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts +10 -0
- package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts.map +1 -0
- package/dist/lib/modules/tournament/notification/notification.scheduler.service.js +86 -0
- package/dist/lib/modules/tournament/notification/notification.scheduler.service.js.map +1 -0
- package/dist/lib/modules/tournament/notification/notification.service.d.ts +12 -0
- package/dist/lib/modules/tournament/notification/notification.service.d.ts.map +1 -0
- package/dist/lib/modules/tournament/notification/notification.service.js +106 -0
- package/dist/lib/modules/tournament/notification/notification.service.js.map +1 -0
- package/dist/lib/modules/tournament/participant/participant.repository.d.ts +12 -0
- package/dist/lib/modules/tournament/participant/participant.repository.d.ts.map +1 -0
- package/dist/lib/modules/tournament/participant/participant.repository.js +73 -0
- package/dist/lib/modules/tournament/participant/participant.repository.js.map +1 -0
- package/dist/lib/modules/tournament/participant/participant.router.d.ts +104 -0
- package/dist/lib/modules/tournament/participant/participant.router.d.ts.map +1 -0
- package/dist/lib/modules/tournament/participant/participant.router.js +28 -0
- package/dist/lib/modules/tournament/participant/participant.router.js.map +1 -0
- package/dist/lib/modules/tournament/participant/participant.service.d.ts +14 -0
- package/dist/lib/modules/tournament/participant/participant.service.d.ts.map +1 -0
- package/dist/lib/modules/tournament/participant/participant.service.js +103 -0
- package/dist/lib/modules/tournament/participant/participant.service.js.map +1 -0
- package/dist/lib/modules/tournament/participant/participant.validation.d.ts +719 -0
- package/dist/lib/modules/tournament/participant/participant.validation.d.ts.map +1 -0
- package/dist/lib/modules/tournament/participant/participant.validation.js +44 -0
- package/dist/lib/modules/tournament/participant/participant.validation.js.map +1 -0
- package/dist/lib/modules/tournament/prediction/prediction.builder.d.ts +14 -0
- package/dist/lib/modules/tournament/prediction/prediction.builder.d.ts.map +1 -0
- package/dist/lib/modules/tournament/prediction/prediction.builder.js +23 -0
- package/dist/lib/modules/tournament/prediction/prediction.builder.js.map +1 -0
- package/dist/lib/modules/tournament/prediction/prediction.repository.d.ts +14 -0
- package/dist/lib/modules/tournament/prediction/prediction.repository.d.ts.map +1 -0
- package/dist/lib/modules/tournament/prediction/prediction.repository.js +91 -0
- package/dist/lib/modules/tournament/prediction/prediction.repository.js.map +1 -0
- package/dist/lib/modules/tournament/prediction/prediction.router.d.ts +133 -0
- package/dist/lib/modules/tournament/prediction/prediction.router.d.ts.map +1 -0
- package/dist/lib/modules/tournament/prediction/prediction.router.js +36 -0
- package/dist/lib/modules/tournament/prediction/prediction.router.js.map +1 -0
- package/dist/lib/modules/tournament/prediction/prediction.service.d.ts +25 -0
- package/dist/lib/modules/tournament/prediction/prediction.service.d.ts.map +1 -0
- package/dist/lib/modules/tournament/prediction/prediction.service.js +142 -0
- package/dist/lib/modules/tournament/prediction/prediction.service.js.map +1 -0
- package/dist/lib/modules/tournament/prediction/prediction.validation.d.ts +575 -0
- package/dist/lib/modules/tournament/prediction/prediction.validation.d.ts.map +1 -0
- package/dist/lib/modules/tournament/prediction/prediction.validation.js +46 -0
- package/dist/lib/modules/tournament/prediction/prediction.validation.js.map +1 -0
- package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.d.ts +11 -0
- package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.d.ts.map +1 -0
- package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.js +81 -0
- package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.js.map +1 -0
- 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 +43 -0
- package/dist/lib/modules/tournament/reward/reward.builder.js.map +1 -0
- package/dist/lib/modules/tournament/reward/reward.factory.d.ts +6 -0
- package/dist/lib/modules/tournament/reward/reward.factory.d.ts.map +1 -0
- package/dist/lib/modules/tournament/reward/reward.factory.js +21 -0
- package/dist/lib/modules/tournament/reward/reward.factory.js.map +1 -0
- package/dist/lib/modules/tournament/reward/reward.interface.d.ts +5 -0
- package/dist/lib/modules/tournament/reward/reward.interface.d.ts.map +1 -0
- package/dist/lib/modules/tournament/reward/reward.interface.js +3 -0
- package/dist/lib/modules/tournament/reward/reward.interface.js.map +1 -0
- package/dist/lib/modules/tournament/reward/reward.service.d.ts +6 -0
- package/dist/lib/modules/tournament/reward/reward.service.d.ts.map +1 -0
- package/dist/lib/modules/tournament/reward/reward.service.js +56 -0
- package/dist/lib/modules/tournament/reward/reward.service.js.map +1 -0
- package/dist/lib/modules/tournament/reward/reward.types.d.ts +11 -0
- package/dist/lib/modules/tournament/reward/reward.types.d.ts.map +1 -0
- package/dist/lib/modules/tournament/reward/reward.types.js +8 -0
- package/dist/lib/modules/tournament/reward/reward.types.js.map +1 -0
- package/dist/lib/modules/tournament/score/score.repository.d.ts +6 -0
- package/dist/lib/modules/tournament/score/score.repository.d.ts.map +1 -0
- package/dist/lib/modules/tournament/score/score.repository.js +60 -0
- package/dist/lib/modules/tournament/score/score.repository.js.map +1 -0
- package/dist/lib/modules/tournament/score/score.service.d.ts +6 -0
- package/dist/lib/modules/tournament/score/score.service.d.ts.map +1 -0
- package/dist/lib/modules/tournament/score/score.service.js +60 -0
- package/dist/lib/modules/tournament/score/score.service.js.map +1 -0
- package/dist/lib/modules/tournament/team/team.builder.d.ts +19 -0
- package/dist/lib/modules/tournament/team/team.builder.d.ts.map +1 -0
- package/dist/lib/modules/tournament/team/team.builder.js +18 -0
- package/dist/lib/modules/tournament/team/team.builder.js.map +1 -0
- package/dist/lib/modules/tournament/team/team.repository.d.ts +11 -0
- package/dist/lib/modules/tournament/team/team.repository.d.ts.map +1 -0
- package/dist/lib/modules/tournament/team/team.repository.js +71 -0
- package/dist/lib/modules/tournament/team/team.repository.js.map +1 -0
- package/dist/lib/modules/tournament/team/team.router.d.ts +205 -0
- package/dist/lib/modules/tournament/team/team.router.d.ts.map +1 -0
- package/dist/lib/modules/tournament/team/team.router.js +36 -0
- package/dist/lib/modules/tournament/team/team.router.js.map +1 -0
- package/dist/lib/modules/tournament/team/team.service.d.ts +15 -0
- package/dist/lib/modules/tournament/team/team.service.d.ts.map +1 -0
- package/dist/lib/modules/tournament/team/team.service.js +137 -0
- package/dist/lib/modules/tournament/team/team.service.js.map +1 -0
- package/dist/lib/modules/tournament/team/team.validation.d.ts +986 -0
- package/dist/lib/modules/tournament/team/team.validation.d.ts.map +1 -0
- package/dist/lib/modules/tournament/team/team.validation.js +55 -0
- package/dist/lib/modules/tournament/team/team.validation.js.map +1 -0
- package/dist/lib/modules/tournament/tournament.router.d.ts +1082 -0
- package/dist/lib/modules/tournament/tournament.router.d.ts.map +1 -0
- package/dist/lib/modules/tournament/tournament.router.js +25 -0
- package/dist/lib/modules/tournament/tournament.router.js.map +1 -0
- 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.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/event/event-initializations.d.ts.map +1 -1
- package/dist/types/events/event-initializations.d.ts +2 -0
- package/dist/types/events/event-initializations.d.ts.map +1 -0
- package/dist/types/index.d.ts +1102 -28
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/coupon/routers/coupon.router.d.ts +4 -0
- package/dist/types/modules/coupon/routers/coupon.router.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/custom-coupon.service.d.ts +2 -0
- package/dist/types/modules/coupon/services/custom-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/global-coupon.service.d.ts +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 +2 -1
- package/dist/types/modules/coupon/services/helper.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/individual-store-coupon.service.d.ts +2 -0
- package/dist/types/modules/coupon/services/individual-store-coupon.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/patterns/repository/CouponRepository.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/referral-code-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/referral-reward-coupon.service.d.ts +1 -1
- package/dist/types/modules/coupon/services/referral-reward-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/shops-categories-coupon.service.d.ts +2 -0
- package/dist/types/modules/coupon/services/shops-categories-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts +13 -0
- package/dist/types/modules/coupon/validations/coupon.validation.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 +16 -27
- package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +6 -6
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +30 -30
- package/dist/types/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/synchronize-product-marketing.service.d.ts +2 -0
- package/dist/types/modules/marketing/services/synchronize-product-marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/validations/buy1-get1-marketing.validation.d.ts +18 -18
- package/dist/types/modules/marketing/validations/discount-marketing.validation.d.ts +30 -30
- package/dist/types/modules/marketing/validations/featured-marketing.validation.d.ts +6 -6
- package/dist/types/modules/marketing/validations/free-delivery-marketing.validation.d.ts +4 -4
- package/dist/types/modules/marketing/validations/marketing.validation.d.ts +2 -2
- package/dist/types/modules/marketing/validations/product-marketing.validation.d.ts +5 -5
- package/dist/types/modules/marketing/validations/punch-marketing.validation.d.ts +4 -4
- package/dist/types/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +1 -1
- package/dist/types/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +2 -2
- package/dist/types/modules/tournament/config/config.builder.d.ts +5 -0
- package/dist/types/modules/tournament/config/config.builder.d.ts.map +1 -0
- package/dist/types/modules/tournament/config/config.repository.d.ts +14 -0
- package/dist/types/modules/tournament/config/config.repository.d.ts.map +1 -0
- package/dist/types/modules/tournament/config/config.router.d.ts +251 -0
- package/dist/types/modules/tournament/config/config.router.d.ts.map +1 -0
- package/dist/types/modules/tournament/config/config.service.d.ts +14 -0
- package/dist/types/modules/tournament/config/config.service.d.ts.map +1 -0
- package/dist/types/modules/tournament/config/config.validation.d.ts +767 -0
- package/dist/types/modules/tournament/config/config.validation.d.ts.map +1 -0
- package/dist/types/modules/tournament/config/tournament-config.validation.d.ts +201 -0
- package/dist/types/modules/tournament/config/tournament-config.validation.d.ts.map +1 -0
- 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/events/match-ended.consumer.d.ts +2 -0
- package/dist/types/modules/tournament/match/events/match-ended.consumer.d.ts.map +1 -0
- package/dist/types/modules/tournament/match/events/match-ended.event.d.ts +14 -0
- package/dist/types/modules/tournament/match/events/match-ended.event.d.ts.map +1 -0
- package/dist/types/modules/tournament/match/match.builder.d.ts +41 -0
- package/dist/types/modules/tournament/match/match.builder.d.ts.map +1 -0
- package/dist/types/modules/tournament/match/match.repository.d.ts +13 -0
- package/dist/types/modules/tournament/match/match.repository.d.ts.map +1 -0
- package/dist/types/modules/tournament/match/match.router.d.ts +352 -0
- package/dist/types/modules/tournament/match/match.router.d.ts.map +1 -0
- package/dist/types/modules/tournament/match/match.service.d.ts +19 -0
- package/dist/types/modules/tournament/match/match.service.d.ts.map +1 -0
- package/dist/types/modules/tournament/match/match.validation.d.ts +892 -0
- package/dist/types/modules/tournament/match/match.validation.d.ts.map +1 -0
- package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts +13 -0
- package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts.map +1 -0
- package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts +7 -0
- package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts.map +1 -0
- package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts +10 -0
- package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts.map +1 -0
- package/dist/types/modules/tournament/notification/notification.service.d.ts +12 -0
- package/dist/types/modules/tournament/notification/notification.service.d.ts.map +1 -0
- package/dist/types/modules/tournament/participant/participant.repository.d.ts +12 -0
- package/dist/types/modules/tournament/participant/participant.repository.d.ts.map +1 -0
- package/dist/types/modules/tournament/participant/participant.router.d.ts +104 -0
- package/dist/types/modules/tournament/participant/participant.router.d.ts.map +1 -0
- package/dist/types/modules/tournament/participant/participant.service.d.ts +14 -0
- package/dist/types/modules/tournament/participant/participant.service.d.ts.map +1 -0
- package/dist/types/modules/tournament/participant/participant.validation.d.ts +719 -0
- package/dist/types/modules/tournament/participant/participant.validation.d.ts.map +1 -0
- package/dist/types/modules/tournament/prediction/prediction.builder.d.ts +14 -0
- package/dist/types/modules/tournament/prediction/prediction.builder.d.ts.map +1 -0
- package/dist/types/modules/tournament/prediction/prediction.repository.d.ts +14 -0
- package/dist/types/modules/tournament/prediction/prediction.repository.d.ts.map +1 -0
- package/dist/types/modules/tournament/prediction/prediction.router.d.ts +133 -0
- package/dist/types/modules/tournament/prediction/prediction.router.d.ts.map +1 -0
- package/dist/types/modules/tournament/prediction/prediction.service.d.ts +25 -0
- package/dist/types/modules/tournament/prediction/prediction.service.d.ts.map +1 -0
- package/dist/types/modules/tournament/prediction/prediction.validation.d.ts +575 -0
- package/dist/types/modules/tournament/prediction/prediction.validation.d.ts.map +1 -0
- package/dist/types/modules/tournament/reward/handlers/coupon-reward.handler.d.ts +11 -0
- package/dist/types/modules/tournament/reward/handlers/coupon-reward.handler.d.ts.map +1 -0
- 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.factory.d.ts +6 -0
- package/dist/types/modules/tournament/reward/reward.factory.d.ts.map +1 -0
- package/dist/types/modules/tournament/reward/reward.interface.d.ts +5 -0
- package/dist/types/modules/tournament/reward/reward.interface.d.ts.map +1 -0
- package/dist/types/modules/tournament/reward/reward.service.d.ts +6 -0
- package/dist/types/modules/tournament/reward/reward.service.d.ts.map +1 -0
- package/dist/types/modules/tournament/reward/reward.types.d.ts +11 -0
- package/dist/types/modules/tournament/reward/reward.types.d.ts.map +1 -0
- package/dist/types/modules/tournament/score/score.repository.d.ts +6 -0
- package/dist/types/modules/tournament/score/score.repository.d.ts.map +1 -0
- package/dist/types/modules/tournament/score/score.service.d.ts +6 -0
- package/dist/types/modules/tournament/score/score.service.d.ts.map +1 -0
- package/dist/types/modules/tournament/team/team.builder.d.ts +19 -0
- package/dist/types/modules/tournament/team/team.builder.d.ts.map +1 -0
- package/dist/types/modules/tournament/team/team.repository.d.ts +11 -0
- package/dist/types/modules/tournament/team/team.repository.d.ts.map +1 -0
- package/dist/types/modules/tournament/team/team.router.d.ts +205 -0
- package/dist/types/modules/tournament/team/team.router.d.ts.map +1 -0
- package/dist/types/modules/tournament/team/team.service.d.ts +15 -0
- package/dist/types/modules/tournament/team/team.service.d.ts.map +1 -0
- package/dist/types/modules/tournament/team/team.validation.d.ts +986 -0
- package/dist/types/modules/tournament/team/team.validation.d.ts.map +1 -0
- package/dist/types/modules/tournament/tournament.router.d.ts +1082 -0
- package/dist/types/modules/tournament/tournament.router.d.ts.map +1 -0
- 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.validation.d.ts +133 -0
- package/dist/types/modules/tournament/tournament.validation.d.ts.map +1 -0
- package/package.json +3 -3
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts +0 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts.map +0 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.js +0 -2
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"participant.validation.d.ts","sourceRoot":"/","sources":["modules/tournament/participant/participant.validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,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AO,oBAAoB,CAAC,CAAC;AACtE,MAAM,MAAM,kCAAkC,GAAG,GAAG,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAC7F,MAAM,MAAM,8BAA8B,GAAG,GAAG,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TournamentParticipantListResponseSchema = exports.TournamentParticipantResponseSchema = exports.JoinTournamentResponseSchema = exports.JoinTournamentParticipantSchema = exports.TournamentParticipantSchema = exports.GetTournamentParticipantsSchema = exports.JoinTournamentSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const global_validation_1 = require("@lyxa.ai/core/dist/utilities/validation/global-validation");
|
|
6
|
+
const validation_1 = require("@lyxa.ai/core/dist/utilities/validation");
|
|
7
|
+
const MatchScoreSchema = zod_1.z.object({
|
|
8
|
+
team1: global_validation_1.ZodValidation.number('Team 1 score').nullable(),
|
|
9
|
+
team2: global_validation_1.ZodValidation.number('Team 2 score').nullable(),
|
|
10
|
+
});
|
|
11
|
+
const PredictionSchema = zod_1.z.object({
|
|
12
|
+
_id: global_validation_1.ZodValidation.objectId(),
|
|
13
|
+
matchId: global_validation_1.ZodValidation.objectId('Match id'),
|
|
14
|
+
score: MatchScoreSchema,
|
|
15
|
+
predictionTime: zod_1.z.date().nullable().optional(),
|
|
16
|
+
succeeded: zod_1.z.boolean().nullable().optional(),
|
|
17
|
+
coupon: global_validation_1.ZodValidation.objectId('Coupon id').optional(),
|
|
18
|
+
});
|
|
19
|
+
exports.JoinTournamentSchema = zod_1.z.object({
|
|
20
|
+
tournamentId: global_validation_1.ZodValidation.objectId('Tournament id'),
|
|
21
|
+
teamId: global_validation_1.ZodValidation.objectId('Team id'),
|
|
22
|
+
});
|
|
23
|
+
exports.GetTournamentParticipantsSchema = zod_1.z.object({
|
|
24
|
+
tournamentId: global_validation_1.ZodValidation.objectId('Tournament id'),
|
|
25
|
+
});
|
|
26
|
+
exports.TournamentParticipantSchema = zod_1.z.object({
|
|
27
|
+
_id: global_validation_1.ZodValidation.objectId(),
|
|
28
|
+
userId: global_validation_1.ZodValidation.objectId('User id'),
|
|
29
|
+
tournamentId: global_validation_1.ZodValidation.objectId('Tournament id'),
|
|
30
|
+
teamId: global_validation_1.ZodValidation.objectId('Team id'),
|
|
31
|
+
predictions: zod_1.z.array(PredictionSchema).default([]),
|
|
32
|
+
createdAt: zod_1.z.date().nullable().optional(),
|
|
33
|
+
updatedAt: zod_1.z.date().nullable().optional(),
|
|
34
|
+
});
|
|
35
|
+
exports.JoinTournamentParticipantSchema = zod_1.z.object({
|
|
36
|
+
_id: global_validation_1.ZodValidation.objectId(),
|
|
37
|
+
tournamentId: global_validation_1.ZodValidation.objectId('Tournament id'),
|
|
38
|
+
teamId: global_validation_1.ZodValidation.objectId('Team id'),
|
|
39
|
+
createdAt: zod_1.z.date().nullable().optional(),
|
|
40
|
+
});
|
|
41
|
+
exports.JoinTournamentResponseSchema = (0, validation_1.createResponseSchema)(exports.JoinTournamentParticipantSchema);
|
|
42
|
+
exports.TournamentParticipantResponseSchema = (0, validation_1.createResponseSchema)(exports.TournamentParticipantSchema);
|
|
43
|
+
exports.TournamentParticipantListResponseSchema = (0, validation_1.createResponseSchema)(zod_1.z.array(exports.TournamentParticipantSchema));
|
|
44
|
+
//# sourceMappingURL=participant.validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"participant.validation.js","sourceRoot":"/","sources":["modules/tournament/participant/participant.validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,iGAA+F;AAC/F,wEAA+E;AAE/E,MAAM,gBAAgB,GAAG,OAAC,CAAC,MAAM,CAAC;IACjC,KAAK,EAAE,iCAAa,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE;IACtD,KAAK,EAAE,iCAAa,CAAC,MAAM,CAAC,cAA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AAS,EAAE,OAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CACzC,CAAC,CAAC;AAEU,QAAA,+BAA+B,GAAG,OAAC,CAAC,MAAM,CAAC;IACvD,GAAG,EAAE,iCAAa,CAAC,QAAQ,EAAE;IAC7B,YAAY,EAAE,iCAAa,CAAC,QAAQ,CAAC,eAAe,CAAC;IACrD,MAAM,EAAE,iCAAa,CAAC,QAAQ,CAAC,SAAS,CAAC;IACzC,SAAS,EAAE,OAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CACzC,CAAC,CAAC;AAEU,QAAA,4BAA4B,GAAG,IAAA,iCAAoB,EAAC,uCAA+B,CAAC,CAAC;AACrF,QAAA,mCAAmC,GAAG,IAAA,iCAAoB,EAAC,mCAA2B,CAAC,CAAC;AACxF,QAAA,uCAAuC,GAAG,IAAA,iCAAoB,EAAC,OAAC,CAAC,KAAK,CAAC,mCAA2B,CAAC,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { DTO, ZodValidation } from '@lyxa.ai/core/dist/utilities/validation/global-validation';\nimport { createResponseSchema } from '@lyxa.ai/core/dist/utilities/validation';\n\nconst MatchScoreSchema = z.object({\n\tteam1: ZodValidation.number('Team 1 score').nullable(),\n\tteam2: ZodValidation.number('Team 2 score').nullable(),\n});\n\nconst PredictionSchema = z.object({\n\t_id: ZodValidation.objectId(),\n\tmatchId: ZodValidation.objectId('Match id'),\n\tscore: MatchScoreSchema,\n\tpredictionTime: z.date().nullable().optional(),\n\tsucceeded: z.boolean().nullable().optional(),\n\tcoupon: ZodValidation.objectId('Coupon id').optional(),\n});\n\nexport const JoinTournamentSchema = z.object({\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n\tteamId: ZodValidation.objectId('Team id'),\n});\n\nexport const GetTournamentParticipantsSchema = z.object({\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n});\n\nexport const TournamentParticipantSchema = z.object({\n\t_id: ZodValidation.objectId(),\n\tuserId: ZodValidation.objectId('User id'),\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n\tteamId: ZodValidation.objectId('Team id'),\n\tpredictions: z.array(PredictionSchema).default([]),\n\tcreatedAt: z.date().nullable().optional(),\n\tupdatedAt: z.date().nullable().optional(),\n});\n\nexport const JoinTournamentParticipantSchema = z.object({\n\t_id: ZodValidation.objectId(),\n\ttournamentId: ZodValidation.objectId('Tournament id'),\n\tteamId: ZodValidation.objectId('Team id'),\n\tcreatedAt: z.date().nullable().optional(),\n});\n\nexport const JoinTournamentResponseSchema = createResponseSchema(JoinTournamentParticipantSchema);\nexport const TournamentParticipantResponseSchema = createResponseSchema(TournamentParticipantSchema);\nexport const TournamentParticipantListResponseSchema = createResponseSchema(z.array(TournamentParticipantSchema));\n\nexport type JoinTournamentInputDTO = DTO<typeof JoinTournamentSchema>;\nexport type JoinTournamentParticipantOutputDTO = DTO<typeof JoinTournamentParticipantSchema>;\nexport type TournamentParticipantOutputDTO = DTO<typeof TournamentParticipantSchema>;\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { mongoose } from '@typegoose/typegoose';
|
|
2
|
+
import { PredictionOutputDTO } from './prediction.validation';
|
|
3
|
+
interface PredictionScoreInput {
|
|
4
|
+
team1: number;
|
|
5
|
+
team2: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class PredictionBuilder {
|
|
8
|
+
static buildPrediction(matchId: mongoose.Types.ObjectId, score: PredictionScoreInput): Omit<PredictionOutputDTO, '_id'> & {
|
|
9
|
+
_id: mongoose.Types.ObjectId;
|
|
10
|
+
};
|
|
11
|
+
static buildScoreUpdate(score: PredictionScoreInput): Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=prediction.builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prediction.builder.d.ts","sourceRoot":"/","sources":["modules/tournament/prediction/prediction.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,UAAU,oBAAoB;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,iBAAiB;IAC1B,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAAC,mBAAmB,EAAE,KAAK,CAAC,GAAG;QAAE,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAA;KAAE;IAU1J,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAMhF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PredictionBuilder = void 0;
|
|
4
|
+
const typegoose_1 = require("@typegoose/typegoose");
|
|
5
|
+
class PredictionBuilder {
|
|
6
|
+
static buildPrediction(matchId, score) {
|
|
7
|
+
return {
|
|
8
|
+
_id: new typegoose_1.mongoose.Types.ObjectId(),
|
|
9
|
+
matchId,
|
|
10
|
+
score,
|
|
11
|
+
predictionTime: new Date(),
|
|
12
|
+
succeeded: null,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
static buildScoreUpdate(score) {
|
|
16
|
+
return {
|
|
17
|
+
'predictions.$.score': score,
|
|
18
|
+
'predictions.$.predictionTime': new Date(),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.PredictionBuilder = PredictionBuilder;
|
|
23
|
+
//# sourceMappingURL=prediction.builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prediction.builder.js","sourceRoot":"/","sources":["modules/tournament/prediction/prediction.builder.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAQhD,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,IAAI,IAAI,EAAE;YAC1B,SAAS,EAAE,IAAI;SAClB,CAAC;IACN,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,KAA2B;QAC/C,OAAO;YACH,qBAAqB,EAAE,KAAK;YAC5B,8BAA8B,EAAE,IAAI,IAAI,EAAE;SAC7C,CAAC;IACN,CAAC;CACJ;AAjBD,8CAiBC","sourcesContent":["import { mongoose } from '@typegoose/typegoose';\nimport { PredictionOutputDTO } from './prediction.validation';\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: new Date(),\n succeeded: null,\n };\n }\n\n static buildScoreUpdate(score: PredictionScoreInput): Record<string, unknown> {\n return {\n 'predictions.$.score': score,\n 'predictions.$.predictionTime': new Date(),\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { mongoose } from '@typegoose/typegoose';
|
|
2
|
+
import { TournamentParticipant as ParticipantType } from '@lyxa.ai/core/dist/libraries/mongo/models';
|
|
3
|
+
export declare class PredictionRepository {
|
|
4
|
+
private participantModel;
|
|
5
|
+
constructor();
|
|
6
|
+
addPrediction(participantId: mongoose.Types.ObjectId, prediction: object): Promise<ParticipantType | null>;
|
|
7
|
+
updatePrediction(participantId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, updates: Record<string, unknown>): Promise<ParticipantType | null>;
|
|
8
|
+
evaluate(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, finalScore: {
|
|
9
|
+
team1: number;
|
|
10
|
+
team2: number;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare const predictionRepository: PredictionRepository;
|
|
14
|
+
//# sourceMappingURL=prediction.repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,91 @@
|
|
|
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.predictionRepository = exports.PredictionRepository = void 0;
|
|
46
|
+
const typedi_1 = __importStar(require("typedi"));
|
|
47
|
+
const models_1 = require("@lyxa.ai/core/dist/libraries/mongo/models");
|
|
48
|
+
let PredictionRepository = class PredictionRepository {
|
|
49
|
+
participantModel;
|
|
50
|
+
constructor() {
|
|
51
|
+
this.participantModel = models_1.TournamentParticipantModel;
|
|
52
|
+
}
|
|
53
|
+
async addPrediction(participantId, prediction) {
|
|
54
|
+
return this.participantModel
|
|
55
|
+
.findByIdAndUpdate(participantId, { $push: { predictions: prediction } }, { new: true })
|
|
56
|
+
.lean();
|
|
57
|
+
}
|
|
58
|
+
async updatePrediction(participantId, matchId, updates) {
|
|
59
|
+
return this.participantModel
|
|
60
|
+
.findOneAndUpdate({ _id: participantId, 'predictions.matchId': matchId }, { $set: updates }, { new: true })
|
|
61
|
+
.lean();
|
|
62
|
+
}
|
|
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
|
+
]);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
exports.PredictionRepository = PredictionRepository;
|
|
86
|
+
exports.PredictionRepository = PredictionRepository = __decorate([
|
|
87
|
+
(0, typedi_1.Service)(),
|
|
88
|
+
__metadata("design:paramtypes", [])
|
|
89
|
+
], PredictionRepository);
|
|
90
|
+
exports.predictionRepository = typedi_1.default.get(PredictionRepository);
|
|
91
|
+
//# sourceMappingURL=prediction.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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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B,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);"]}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { mongoose } from '@typegoose/typegoose';
|
|
2
|
+
export declare const predictionRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
3
|
+
ctx: import("@lyxa.ai/core/dist/libraries/trpc/context").LyxaHTTPContext;
|
|
4
|
+
meta: object;
|
|
5
|
+
errorShape: {
|
|
6
|
+
message: string;
|
|
7
|
+
data: {
|
|
8
|
+
stack: undefined;
|
|
9
|
+
path: undefined;
|
|
10
|
+
code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
|
|
11
|
+
httpStatus: number;
|
|
12
|
+
};
|
|
13
|
+
stack: undefined;
|
|
14
|
+
code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
|
|
15
|
+
};
|
|
16
|
+
transformer: false;
|
|
17
|
+
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
18
|
+
create: import("@trpc/server").TRPCMutationProcedure<{
|
|
19
|
+
input: {
|
|
20
|
+
tournamentId: string | mongoose.Types.ObjectId;
|
|
21
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
22
|
+
score: {
|
|
23
|
+
team1: number;
|
|
24
|
+
team2: number;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
output: {
|
|
28
|
+
message: string;
|
|
29
|
+
success: boolean;
|
|
30
|
+
data?: {
|
|
31
|
+
_id: string | mongoose.Types.ObjectId;
|
|
32
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
33
|
+
score: {
|
|
34
|
+
team1: number | null;
|
|
35
|
+
team2: number | null;
|
|
36
|
+
};
|
|
37
|
+
} | {
|
|
38
|
+
documents: {
|
|
39
|
+
_id: string | mongoose.Types.ObjectId;
|
|
40
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
41
|
+
score: {
|
|
42
|
+
team1: number | null;
|
|
43
|
+
team2: number | null;
|
|
44
|
+
};
|
|
45
|
+
}[];
|
|
46
|
+
metadata?: {
|
|
47
|
+
page: number;
|
|
48
|
+
size: number;
|
|
49
|
+
totalElements: number;
|
|
50
|
+
totalPages: number;
|
|
51
|
+
} | undefined;
|
|
52
|
+
} | undefined;
|
|
53
|
+
};
|
|
54
|
+
meta: object;
|
|
55
|
+
}>;
|
|
56
|
+
edit: import("@trpc/server").TRPCMutationProcedure<{
|
|
57
|
+
input: {
|
|
58
|
+
tournamentId: string | mongoose.Types.ObjectId;
|
|
59
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
60
|
+
score: {
|
|
61
|
+
team1: number;
|
|
62
|
+
team2: number;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
output: {
|
|
66
|
+
message: string;
|
|
67
|
+
success: boolean;
|
|
68
|
+
data?: {
|
|
69
|
+
_id: string | mongoose.Types.ObjectId;
|
|
70
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
71
|
+
score: {
|
|
72
|
+
team1: number | null;
|
|
73
|
+
team2: number | null;
|
|
74
|
+
};
|
|
75
|
+
} | {
|
|
76
|
+
documents: {
|
|
77
|
+
_id: string | mongoose.Types.ObjectId;
|
|
78
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
79
|
+
score: {
|
|
80
|
+
team1: number | null;
|
|
81
|
+
team2: number | null;
|
|
82
|
+
};
|
|
83
|
+
}[];
|
|
84
|
+
metadata?: {
|
|
85
|
+
page: number;
|
|
86
|
+
size: number;
|
|
87
|
+
totalElements: number;
|
|
88
|
+
totalPages: number;
|
|
89
|
+
} | undefined;
|
|
90
|
+
} | undefined;
|
|
91
|
+
};
|
|
92
|
+
meta: object;
|
|
93
|
+
}>;
|
|
94
|
+
get: import("@trpc/server").TRPCQueryProcedure<{
|
|
95
|
+
input: {
|
|
96
|
+
tournamentId: string | mongoose.Types.ObjectId;
|
|
97
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
98
|
+
};
|
|
99
|
+
output: {
|
|
100
|
+
message: string;
|
|
101
|
+
success: boolean;
|
|
102
|
+
data?: {
|
|
103
|
+
_id: string | mongoose.Types.ObjectId;
|
|
104
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
105
|
+
score: {
|
|
106
|
+
team1: number | null;
|
|
107
|
+
team2: number | null;
|
|
108
|
+
};
|
|
109
|
+
predictionTime?: Date | null | undefined;
|
|
110
|
+
succeeded?: boolean | null | undefined;
|
|
111
|
+
} | {
|
|
112
|
+
documents: ({
|
|
113
|
+
_id: string | mongoose.Types.ObjectId;
|
|
114
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
115
|
+
score: {
|
|
116
|
+
team1: number | null;
|
|
117
|
+
team2: number | null;
|
|
118
|
+
};
|
|
119
|
+
predictionTime?: Date | null | undefined;
|
|
120
|
+
succeeded?: boolean | null | undefined;
|
|
121
|
+
} | null)[];
|
|
122
|
+
metadata?: {
|
|
123
|
+
page: number;
|
|
124
|
+
size: number;
|
|
125
|
+
totalElements: number;
|
|
126
|
+
totalPages: number;
|
|
127
|
+
} | undefined;
|
|
128
|
+
} | null | undefined;
|
|
129
|
+
};
|
|
130
|
+
meta: object;
|
|
131
|
+
}>;
|
|
132
|
+
}>>;
|
|
133
|
+
//# sourceMappingURL=prediction.router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prediction.router.d.ts","sourceRoot":"/","sources":["modules/tournament/prediction/prediction.router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAiBhD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8B3B,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.predictionRouter = void 0;
|
|
4
|
+
const typegoose_1 = require("@typegoose/typegoose");
|
|
5
|
+
const trpc_1 = require("@lyxa.ai/core/dist/libraries/trpc");
|
|
6
|
+
const auth_1 = require("@lyxa.ai/core/dist/libraries/auth");
|
|
7
|
+
const auth_2 = require("@lyxa.ai/core/dist/libraries/trpc/middlewares/auth");
|
|
8
|
+
const error_handler_1 = require("@lyxa.ai/core/dist/utilities/error-handler");
|
|
9
|
+
const response_1 = require("@lyxa.ai/core/dist/utilities/response");
|
|
10
|
+
const prediction_service_1 = require("./prediction.service");
|
|
11
|
+
const prediction_validation_1 = require("./prediction.validation");
|
|
12
|
+
const userProcedure = (0, auth_2.createAuthenticatedProcedure)({ entityTypes: [auth_1.AuthEntityType.USER] });
|
|
13
|
+
exports.predictionRouter = (0, trpc_1.createTRPCRouter)({
|
|
14
|
+
create: userProcedure
|
|
15
|
+
.input(prediction_validation_1.CreatePredictionSchema)
|
|
16
|
+
.output(prediction_validation_1.MutatePredictionResponseSchema)
|
|
17
|
+
.mutation(async ({ ctx, input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
18
|
+
const result = await prediction_service_1.predictionService.create(new typegoose_1.mongoose.Types.ObjectId(ctx.entity?.id), input);
|
|
19
|
+
return (0, response_1.response)('Prediction created successfully', result);
|
|
20
|
+
})),
|
|
21
|
+
edit: userProcedure
|
|
22
|
+
.input(prediction_validation_1.EditPredictionSchema)
|
|
23
|
+
.output(prediction_validation_1.MutatePredictionResponseSchema)
|
|
24
|
+
.mutation(async ({ ctx, input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
25
|
+
const result = await prediction_service_1.predictionService.edit(new typegoose_1.mongoose.Types.ObjectId(ctx.entity?.id), input);
|
|
26
|
+
return (0, response_1.response)('Prediction updated successfully', result);
|
|
27
|
+
})),
|
|
28
|
+
get: userProcedure
|
|
29
|
+
.input(prediction_validation_1.GetPredictionSchema)
|
|
30
|
+
.output(prediction_validation_1.PredictionNullableResponseSchema)
|
|
31
|
+
.query(async ({ ctx, input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
32
|
+
const result = await prediction_service_1.predictionService.get(new typegoose_1.mongoose.Types.ObjectId(ctx.entity?.id), input);
|
|
33
|
+
return (0, response_1.response)('Prediction fetched successfully', result);
|
|
34
|
+
})),
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=prediction.router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prediction.router.js","sourceRoot":"/","sources":["modules/tournament/prediction/prediction.router.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAChD,4DAAqE;AACrE,4DAAmE;AACnE,6EAAkG;AAClG,8EAA0E;AAC1E,oEAAiE;AACjE,6DAAoE;AACpE,mEAMiC;AAEjC,MAAM,aAAa,GAAG,IAAA,mCAA4B,EAAC,EAAE,WAAW,EAAE,CAAC,qBAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAE9E,QAAA,gBAAgB,GAAG,IAAA,uBAAgB,EAAC;IAC7C,MAAM,EAAE,aAAa;SAChB,KAAK,CAAC,8CAAsB,CAAC;SAC7B,MAAM,CAAC,sDAA8B,CAAC;SACtC,QAAQ,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAC/B,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,MAAM,MAAM,GAAG,MAAM,sCAAO,CAAC,MAAM,CAAC,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QACxF,OAAO,IAAA,mBAAQ,EAAC,iCAAiC,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC,CAAC,CACL;IAEL,IAAI,EAAE,aAAa;SACd,KAAK,CAAC,4CAAoB,CAAC;SAC3B,MAAM,CAAC,sDAA8B,CAAC;SACtC,QAAQ,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAC/B,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,MAAM,MAAM,GAAG,MAAM,sCAAO,CAAC,IAAI,CAAC,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QACtF,OAAO,IAAA,mBAAQ,EAAC,iCAAiC,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC,CAAC,CACL;IAEL,GAAG,EAAE,aAAa;SACb,KAAK,CAAC,2CAAmB,CAAC;SAC1B,MAAM,CAAC,wDAAgC,CAAC;SACxC,KAAK,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAC5B,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,MAAM,MAAM,GAAG,MAAM,sCAAO,CAAC,GAAG,CAAC,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QACrF,OAAO,IAAA,mBAAQ,EAAC,iCAAiC,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC,CAAC,CACL;CACR,CAAC,CAAC","sourcesContent":["import { mongoose } from '@typegoose/typegoose';\nimport { createTRPCRouter } from '@lyxa.ai/core/dist/libraries/trpc';\nimport { AuthEntityType } from '@lyxa.ai/core/dist/libraries/auth';\nimport { createAuthenticatedProcedure } from '@lyxa.ai/core/dist/libraries/trpc/middlewares/auth';\nimport { ErrorHandler } from '@lyxa.ai/core/dist/utilities/error-handler';\nimport { response } from '@lyxa.ai/core/dist/utilities/response';\nimport { predictionService as service } from './prediction.service';\nimport {\n CreatePredictionSchema,\n EditPredictionSchema,\n GetPredictionSchema,\n MutatePredictionResponseSchema,\n PredictionNullableResponseSchema,\n} from './prediction.validation';\n\nconst userProcedure = createAuthenticatedProcedure({ entityTypes: [AuthEntityType.USER] });\n\nexport const predictionRouter = createTRPCRouter({\n create: userProcedure\n .input(CreatePredictionSchema)\n .output(MutatePredictionResponseSchema)\n .mutation(async ({ ctx, input }) =>\n ErrorHandler.wrapAsync(async () => {\n const result = await service.create(new mongoose.Types.ObjectId(ctx.entity?.id), input);\n return response('Prediction created successfully', result);\n })\n ),\n\n edit: userProcedure\n .input(EditPredictionSchema)\n .output(MutatePredictionResponseSchema)\n .mutation(async ({ ctx, input }) =>\n ErrorHandler.wrapAsync(async () => {\n const result = await service.edit(new mongoose.Types.ObjectId(ctx.entity?.id), input);\n return response('Prediction updated successfully', result);\n })\n ),\n\n get: userProcedure\n .input(GetPredictionSchema)\n .output(PredictionNullableResponseSchema)\n .query(async ({ ctx, input }) =>\n ErrorHandler.wrapAsync(async () => {\n const result = await service.get(new mongoose.Types.ObjectId(ctx.entity?.id), input);\n return response('Prediction fetched successfully', result);\n })\n ),\n});\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { mongoose } from '@typegoose/typegoose';
|
|
2
|
+
import { CreatePredictionInputDTO, EditPredictionInputDTO, GetPredictionInputDTO, PredictionOutputDTO } from './prediction.validation';
|
|
3
|
+
export declare class PredictionService {
|
|
4
|
+
private repository;
|
|
5
|
+
private matchRepository;
|
|
6
|
+
private participantService;
|
|
7
|
+
constructor();
|
|
8
|
+
private findMatch;
|
|
9
|
+
private ensureMatchIsOpen;
|
|
10
|
+
private ensureNoPriorPrediction;
|
|
11
|
+
private findPrediction;
|
|
12
|
+
private resolveOutcomes;
|
|
13
|
+
evaluate(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, finalScore: {
|
|
14
|
+
team1: number;
|
|
15
|
+
team2: number;
|
|
16
|
+
}): Promise<{
|
|
17
|
+
winnerIds: mongoose.Types.ObjectId[];
|
|
18
|
+
loserIds: mongoose.Types.ObjectId[];
|
|
19
|
+
}>;
|
|
20
|
+
create(userId: mongoose.Types.ObjectId, input: CreatePredictionInputDTO): Promise<PredictionOutputDTO>;
|
|
21
|
+
edit(userId: mongoose.Types.ObjectId, input: EditPredictionInputDTO): Promise<PredictionOutputDTO>;
|
|
22
|
+
get(userId: mongoose.Types.ObjectId, input: GetPredictionInputDTO): Promise<PredictionOutputDTO | null>;
|
|
23
|
+
}
|
|
24
|
+
export declare const predictionService: PredictionService;
|
|
25
|
+
//# sourceMappingURL=prediction.service.d.ts.map
|
|
@@ -0,0 +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;AAOjC,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,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;IActG,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAoBlG,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"}
|
|
@@ -0,0 +1,142 @@
|
|
|
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.predictionService = exports.PredictionService = void 0;
|
|
46
|
+
const typedi_1 = __importStar(require("typedi"));
|
|
47
|
+
const error_common_1 = require("@lyxa.ai/core/dist/utilities/error-common");
|
|
48
|
+
const prediction_repository_1 = require("./prediction.repository");
|
|
49
|
+
const prediction_builder_1 = require("./prediction.builder");
|
|
50
|
+
const participant_service_1 = require("../participant/participant.service");
|
|
51
|
+
const match_repository_1 = require("../match/match.repository");
|
|
52
|
+
let PredictionService = class PredictionService {
|
|
53
|
+
repository;
|
|
54
|
+
matchRepository;
|
|
55
|
+
participantService;
|
|
56
|
+
constructor() {
|
|
57
|
+
this.repository = typedi_1.default.get(prediction_repository_1.PredictionRepository);
|
|
58
|
+
this.matchRepository = typedi_1.default.get(match_repository_1.TournamentMatchRepository);
|
|
59
|
+
this.participantService = typedi_1.default.get(participant_service_1.ParticipantService);
|
|
60
|
+
}
|
|
61
|
+
async findMatch(tournamentId, matchId) {
|
|
62
|
+
const tournament = await this.matchRepository.findMatchInTournament(tournamentId, matchId);
|
|
63
|
+
if (!tournament)
|
|
64
|
+
throw (0, error_common_1.notFoundError)('Match not found in this tournament');
|
|
65
|
+
const match = tournament.matches.find(m => m._id.toString() === matchId.toString());
|
|
66
|
+
if (!match)
|
|
67
|
+
throw (0, error_common_1.notFoundError)('Match not found');
|
|
68
|
+
return match;
|
|
69
|
+
}
|
|
70
|
+
ensureMatchIsOpen(match) {
|
|
71
|
+
if (match.endDate)
|
|
72
|
+
throw (0, error_common_1.badRequestError)('This match has already ended');
|
|
73
|
+
if (match.startingDate && match.startingDate <= new Date()) {
|
|
74
|
+
throw (0, error_common_1.badRequestError)('The prediction window for this match has closed');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
ensureNoPriorPrediction(participant, matchId) {
|
|
78
|
+
const exists = participant.predictions.some(p => p.matchId.toString() === matchId.toString());
|
|
79
|
+
if (exists)
|
|
80
|
+
throw (0, error_common_1.badRequestError)('You have already predicted for this match');
|
|
81
|
+
}
|
|
82
|
+
findPrediction(participant, matchId) {
|
|
83
|
+
const prediction = participant.predictions.find(p => p.matchId.toString() === matchId.toString());
|
|
84
|
+
if (!prediction)
|
|
85
|
+
throw (0, error_common_1.notFoundError)('No prediction found for this match');
|
|
86
|
+
return prediction;
|
|
87
|
+
}
|
|
88
|
+
resolveOutcomes(participants, matchId, finalScore) {
|
|
89
|
+
const winnerIds = [];
|
|
90
|
+
const loserIds = [];
|
|
91
|
+
for (const participant of participants) {
|
|
92
|
+
const prediction = participant.predictions.find(p => p.matchId.toString() === matchId.toString());
|
|
93
|
+
if (!prediction)
|
|
94
|
+
continue;
|
|
95
|
+
const isWinner = prediction.score.team1 === finalScore.team1 && prediction.score.team2 === finalScore.team2;
|
|
96
|
+
(isWinner ? winnerIds : loserIds).push(participant.userId);
|
|
97
|
+
}
|
|
98
|
+
return { winnerIds, loserIds };
|
|
99
|
+
}
|
|
100
|
+
async evaluate(tournamentId, matchId, finalScore) {
|
|
101
|
+
const participants = await this.participantService.getAll(tournamentId);
|
|
102
|
+
const outcomes = this.resolveOutcomes(participants, matchId, finalScore);
|
|
103
|
+
await this.repository.evaluate(tournamentId, matchId, finalScore);
|
|
104
|
+
return outcomes;
|
|
105
|
+
}
|
|
106
|
+
async create(userId, input) {
|
|
107
|
+
const match = await this.findMatch(input.tournamentId, input.matchId);
|
|
108
|
+
this.ensureMatchIsOpen(match);
|
|
109
|
+
const participant = await this.participantService.getByUserAndTournament(userId, input.tournamentId);
|
|
110
|
+
this.ensureNoPriorPrediction(participant, input.matchId);
|
|
111
|
+
const prediction = prediction_builder_1.PredictionBuilder.buildPrediction(input.matchId, input.score);
|
|
112
|
+
const result = await this.repository.addPrediction(participant._id, prediction);
|
|
113
|
+
if (!result)
|
|
114
|
+
throw (0, error_common_1.notFoundError)('Participant not found');
|
|
115
|
+
return prediction;
|
|
116
|
+
}
|
|
117
|
+
async edit(userId, input) {
|
|
118
|
+
const match = await this.findMatch(input.tournamentId, input.matchId);
|
|
119
|
+
this.ensureMatchIsOpen(match);
|
|
120
|
+
const participant = await this.participantService.getByUserAndTournament(userId, input.tournamentId);
|
|
121
|
+
this.findPrediction(participant, input.matchId);
|
|
122
|
+
const result = await this.repository.updatePrediction(participant._id, input.matchId, prediction_builder_1.PredictionBuilder.buildScoreUpdate(input.score));
|
|
123
|
+
if (!result)
|
|
124
|
+
throw (0, error_common_1.notFoundError)('Participant not found');
|
|
125
|
+
const updated = result.predictions.find(p => p.matchId.toString() === input.matchId.toString());
|
|
126
|
+
if (!updated)
|
|
127
|
+
throw (0, error_common_1.notFoundError)('Prediction not found after update');
|
|
128
|
+
return updated;
|
|
129
|
+
}
|
|
130
|
+
async get(userId, input) {
|
|
131
|
+
const participant = await this.participantService.getByUserAndTournament(userId, input.tournamentId);
|
|
132
|
+
const prediction = participant.predictions.find(p => p.matchId.toString() === input.matchId.toString());
|
|
133
|
+
return prediction ?? null;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
exports.PredictionService = PredictionService;
|
|
137
|
+
exports.PredictionService = PredictionService = __decorate([
|
|
138
|
+
(0, typedi_1.Service)(),
|
|
139
|
+
__metadata("design:paramtypes", [])
|
|
140
|
+
], PredictionService);
|
|
141
|
+
exports.predictionService = typedi_1.default.get(PredictionService);
|
|
142
|
+
//# sourceMappingURL=prediction.service.js.map
|
|
@@ -0,0 +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,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,QAA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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;AA1GY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,gBAAO,GAAE;;GACG,iBAAiB,CA0G7B;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';\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"]}
|