@lyxa.ai/marketing 1.0.46 → 1.0.48
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 +1414 -13
- 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 +72 -6
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.js +12 -3
- package/dist/lib/modules/coupon/routers/coupon.router.js.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts +1 -0
- package/dist/lib/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.js +102 -4
- 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 +16 -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 +7 -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 +6 -0
- package/dist/lib/modules/coupon/services/individual-user-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts +10 -4
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js +88 -9
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.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 +36 -19
- 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 +359 -34
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.js +16 -3
- package/dist/lib/modules/coupon/validations/coupon.validation.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts +6 -6
- 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 +24 -24
- package/dist/lib/modules/marketing/validations/discount-marketing.validation.d.ts +36 -36
- 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 +7 -7
- 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 +19 -0
- package/dist/lib/modules/tournament/config/config.builder.js.map +1 -0
- package/dist/lib/modules/tournament/config/config.repository.d.ts +13 -0
- package/dist/lib/modules/tournament/config/config.repository.d.ts.map +1 -0
- package/dist/lib/modules/tournament/config/config.repository.js +77 -0
- package/dist/lib/modules/tournament/config/config.repository.js.map +1 -0
- package/dist/lib/modules/tournament/config/config.router.d.ts +363 -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 +1014 -0
- package/dist/lib/modules/tournament/config/config.validation.d.ts.map +1 -0
- package/dist/lib/modules/tournament/config/config.validation.js +70 -0
- package/dist/lib/modules/tournament/config/config.validation.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 +38 -0
- package/dist/lib/modules/tournament/match/match.builder.d.ts.map +1 -0
- package/dist/lib/modules/tournament/match/match.builder.js +37 -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 +489 -0
- package/dist/lib/modules/tournament/match/match.router.d.ts.map +1 -0
- package/dist/lib/modules/tournament/match/match.router.js +56 -0
- package/dist/lib/modules/tournament/match/match.router.js.map +1 -0
- package/dist/lib/modules/tournament/match/match.service.d.ts +29 -0
- package/dist/lib/modules/tournament/match/match.service.d.ts.map +1 -0
- package/dist/lib/modules/tournament/match/match.service.js +193 -0
- package/dist/lib/modules/tournament/match/match.service.js.map +1 -0
- package/dist/lib/modules/tournament/match/match.validation.d.ts +880 -0
- package/dist/lib/modules/tournament/match/match.validation.d.ts.map +1 -0
- package/dist/lib/modules/tournament/match/match.validation.js +74 -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 +11 -0
- package/dist/lib/modules/tournament/notification/notification.service.d.ts.map +1 -0
- package/dist/lib/modules/tournament/notification/notification.service.js +101 -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 +11 -0
- package/dist/lib/modules/tournament/prediction/prediction.repository.d.ts.map +1 -0
- package/dist/lib/modules/tournament/prediction/prediction.repository.js +73 -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 +17 -0
- package/dist/lib/modules/tournament/prediction/prediction.service.d.ts.map +1 -0
- package/dist/lib/modules/tournament/prediction/prediction.service.js +125 -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 +8 -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 +65 -0
- package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.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/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 +237 -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 +1336 -0
- package/dist/lib/modules/tournament/tournament.router.d.ts.map +1 -0
- package/dist/lib/modules/tournament/tournament.router.js +17 -0
- package/dist/lib/modules/tournament/tournament.router.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 +1414 -13
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/coupon/routers/coupon.router.d.ts +72 -6
- package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/coupon.service.d.ts +1 -0
- 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/CouponMetricsRepository.d.ts +10 -4
- package/dist/types/modules/coupon/services/patterns/repository/CouponMetricsRepository.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 +359 -34
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts +6 -6
- 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 +24 -24
- package/dist/types/modules/marketing/validations/discount-marketing.validation.d.ts +36 -36
- 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 +7 -7
- 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 +13 -0
- package/dist/types/modules/tournament/config/config.repository.d.ts.map +1 -0
- package/dist/types/modules/tournament/config/config.router.d.ts +363 -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 +1014 -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/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 +38 -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 +489 -0
- package/dist/types/modules/tournament/match/match.router.d.ts.map +1 -0
- package/dist/types/modules/tournament/match/match.service.d.ts +29 -0
- package/dist/types/modules/tournament/match/match.service.d.ts.map +1 -0
- package/dist/types/modules/tournament/match/match.validation.d.ts +880 -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 +11 -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 +11 -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 +17 -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 +8 -0
- package/dist/types/modules/tournament/reward/handlers/coupon-reward.handler.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/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 +237 -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 +1336 -0
- package/dist/types/modules/tournament/tournament.router.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,K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O,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,cAAc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AS,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,11 @@
|
|
|
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
|
+
setSucceeded(participantId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId, succeeded: boolean): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export declare const predictionRepository: PredictionRepository;
|
|
11
|
+
//# 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,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,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,YAAY,CACd,aAAa,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACtC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAChC,SAAS,EAAE,OAAO,GACnB,OAAO,CAAC,IAAI,CAAC;CAMnB;AAED,eAAO,MAAM,oBAAoB,sBAAsC,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
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 setSucceeded(participantId, matchId, succeeded) {
|
|
64
|
+
await this.participantModel.updateOne({ _id: participantId, 'predictions.matchId': matchId }, { $set: { 'predictions.$.succeeded': succeeded } });
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
exports.PredictionRepository = PredictionRepository;
|
|
68
|
+
exports.PredictionRepository = PredictionRepository = __decorate([
|
|
69
|
+
(0, typedi_1.Service)(),
|
|
70
|
+
__metadata("design:paramtypes", [])
|
|
71
|
+
], PredictionRepository);
|
|
72
|
+
exports.predictionRepository = typedi_1.default.get(PredictionRepository);
|
|
73
|
+
//# 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,iDAA4C;AAE5C,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,YAAY,CACd,aAAsC,EACtC,OAAgC,EAChC,SAAkB;QAElB,MAAM,IAAI,CAAC,gBAAgB,CAAC,SAAS,CACjC,EAAE,GAAG,EAAE,aAAa,EAAE,qBAAqB,EAAE,OAAO,EAAE,EACtD,EAAE,IAAI,EAAE,EAAE,yBAAyB,EAAE,SAAS,EAAE,EAAE,CACrD,CAAC;IACN,CAAC;CACJ,CAAA;AArCY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,gBAAO,GAAE;;GACG,oBAAoB,CAqChC;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 setSucceeded(\n participantId: mongoose.Types.ObjectId,\n matchId: mongoose.Types.ObjectId,\n succeeded: boolean\n ): Promise<void> {\n await this.participantModel.updateOne(\n { _id: participantId, 'predictions.matchId': matchId },\n { $set: { 'predictions.$.succeeded': succeeded } }\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
|
+
score: {
|
|
21
|
+
team1: number;
|
|
22
|
+
team2: number;
|
|
23
|
+
};
|
|
24
|
+
tournamentId: string | mongoose.Types.ObjectId;
|
|
25
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
26
|
+
};
|
|
27
|
+
output: {
|
|
28
|
+
message: string;
|
|
29
|
+
success: boolean;
|
|
30
|
+
data?: {
|
|
31
|
+
_id: string | mongoose.Types.ObjectId;
|
|
32
|
+
score: {
|
|
33
|
+
team1: number | null;
|
|
34
|
+
team2: number | null;
|
|
35
|
+
};
|
|
36
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
37
|
+
} | {
|
|
38
|
+
documents: {
|
|
39
|
+
_id: string | mongoose.Types.ObjectId;
|
|
40
|
+
score: {
|
|
41
|
+
team1: number | null;
|
|
42
|
+
team2: number | null;
|
|
43
|
+
};
|
|
44
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
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
|
+
score: {
|
|
59
|
+
team1: number;
|
|
60
|
+
team2: number;
|
|
61
|
+
};
|
|
62
|
+
tournamentId: string | mongoose.Types.ObjectId;
|
|
63
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
64
|
+
};
|
|
65
|
+
output: {
|
|
66
|
+
message: string;
|
|
67
|
+
success: boolean;
|
|
68
|
+
data?: {
|
|
69
|
+
_id: string | mongoose.Types.ObjectId;
|
|
70
|
+
score: {
|
|
71
|
+
team1: number | null;
|
|
72
|
+
team2: number | null;
|
|
73
|
+
};
|
|
74
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
75
|
+
} | {
|
|
76
|
+
documents: {
|
|
77
|
+
_id: string | mongoose.Types.ObjectId;
|
|
78
|
+
score: {
|
|
79
|
+
team1: number | null;
|
|
80
|
+
team2: number | null;
|
|
81
|
+
};
|
|
82
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
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
|
+
score: {
|
|
105
|
+
team1: number | null;
|
|
106
|
+
team2: number | null;
|
|
107
|
+
};
|
|
108
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
109
|
+
succeeded?: boolean | null | undefined;
|
|
110
|
+
predictionTime?: Date | null | undefined;
|
|
111
|
+
} | {
|
|
112
|
+
documents: ({
|
|
113
|
+
_id: string | mongoose.Types.ObjectId;
|
|
114
|
+
score: {
|
|
115
|
+
team1: number | null;
|
|
116
|
+
team2: number | null;
|
|
117
|
+
};
|
|
118
|
+
matchId: string | mongoose.Types.ObjectId;
|
|
119
|
+
succeeded?: boolean | null | undefined;
|
|
120
|
+
predictionTime?: Date | 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,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E,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,17 @@
|
|
|
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
|
+
create(userId: mongoose.Types.ObjectId, input: CreatePredictionInputDTO): Promise<PredictionOutputDTO>;
|
|
13
|
+
edit(userId: mongoose.Types.ObjectId, input: EditPredictionInputDTO): Promise<PredictionOutputDTO>;
|
|
14
|
+
get(userId: mongoose.Types.ObjectId, input: GetPredictionInputDTO): Promise<PredictionOutputDTO | null>;
|
|
15
|
+
}
|
|
16
|
+
export declare const predictionService: PredictionService;
|
|
17
|
+
//# 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":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAOvI,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;IAMT,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,125 @@
|
|
|
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 server_1 = require("@trpc/server");
|
|
48
|
+
const error_common_1 = require("@lyxa.ai/core/dist/utilities/error-common");
|
|
49
|
+
const prediction_repository_1 = require("./prediction.repository");
|
|
50
|
+
const prediction_builder_1 = require("./prediction.builder");
|
|
51
|
+
const participant_service_1 = require("../participant/participant.service");
|
|
52
|
+
const match_repository_1 = require("../match/match.repository");
|
|
53
|
+
let PredictionService = class PredictionService {
|
|
54
|
+
repository;
|
|
55
|
+
matchRepository;
|
|
56
|
+
participantService;
|
|
57
|
+
constructor() {
|
|
58
|
+
this.repository = typedi_1.default.get(prediction_repository_1.PredictionRepository);
|
|
59
|
+
this.matchRepository = typedi_1.default.get(match_repository_1.TournamentMatchRepository);
|
|
60
|
+
this.participantService = typedi_1.default.get(participant_service_1.ParticipantService);
|
|
61
|
+
}
|
|
62
|
+
async findMatch(tournamentId, matchId) {
|
|
63
|
+
const tournament = await this.matchRepository.findMatchInTournament(tournamentId, matchId);
|
|
64
|
+
if (!tournament)
|
|
65
|
+
throw (0, error_common_1.notFoundError)('Match not found in this tournament');
|
|
66
|
+
const match = tournament.matches.find(m => m._id.toString() === matchId.toString());
|
|
67
|
+
if (!match)
|
|
68
|
+
throw (0, error_common_1.notFoundError)('Match not found');
|
|
69
|
+
return match;
|
|
70
|
+
}
|
|
71
|
+
ensureMatchIsOpen(match) {
|
|
72
|
+
if (match.endDate)
|
|
73
|
+
throw (0, error_common_1.badRequestError)('This match has already ended');
|
|
74
|
+
if (match.startingDate && match.startingDate <= new Date()) {
|
|
75
|
+
throw (0, error_common_1.badRequestError)('The prediction window for this match has closed');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
ensureNoPriorPrediction(participant, matchId) {
|
|
79
|
+
const exists = participant.predictions.some(p => p.matchId.toString() === matchId.toString());
|
|
80
|
+
if (exists)
|
|
81
|
+
throw (0, error_common_1.badRequestError)('You have already predicted for this match');
|
|
82
|
+
}
|
|
83
|
+
findPrediction(participant, matchId) {
|
|
84
|
+
const prediction = participant.predictions.find(p => p.matchId.toString() === matchId.toString());
|
|
85
|
+
if (!prediction)
|
|
86
|
+
throw (0, error_common_1.notFoundError)('No prediction found for this match');
|
|
87
|
+
return prediction;
|
|
88
|
+
}
|
|
89
|
+
async create(userId, input) {
|
|
90
|
+
const match = await this.findMatch(input.tournamentId, input.matchId);
|
|
91
|
+
this.ensureMatchIsOpen(match);
|
|
92
|
+
const participant = await this.participantService.getByUserAndTournament(userId, input.tournamentId);
|
|
93
|
+
this.ensureNoPriorPrediction(participant, input.matchId);
|
|
94
|
+
const prediction = prediction_builder_1.PredictionBuilder.buildPrediction(input.matchId, input.score);
|
|
95
|
+
const result = await this.repository.addPrediction(participant._id, prediction);
|
|
96
|
+
if (!result)
|
|
97
|
+
throw new server_1.TRPCError({ code: 'INTERNAL_SERVER_ERROR', message: 'Failed to create prediction' });
|
|
98
|
+
return prediction;
|
|
99
|
+
}
|
|
100
|
+
async edit(userId, input) {
|
|
101
|
+
const match = await this.findMatch(input.tournamentId, input.matchId);
|
|
102
|
+
this.ensureMatchIsOpen(match);
|
|
103
|
+
const participant = await this.participantService.getByUserAndTournament(userId, input.tournamentId);
|
|
104
|
+
this.findPrediction(participant, input.matchId);
|
|
105
|
+
const result = await this.repository.updatePrediction(participant._id, input.matchId, prediction_builder_1.PredictionBuilder.buildScoreUpdate(input.score));
|
|
106
|
+
if (!result)
|
|
107
|
+
throw new server_1.TRPCError({ code: 'INTERNAL_SERVER_ERROR', message: 'Failed to update prediction' });
|
|
108
|
+
const updated = result.predictions.find(p => p.matchId.toString() === input.matchId.toString());
|
|
109
|
+
if (!updated)
|
|
110
|
+
throw (0, error_common_1.notFoundError)('Prediction not found after update');
|
|
111
|
+
return updated;
|
|
112
|
+
}
|
|
113
|
+
async get(userId, input) {
|
|
114
|
+
const participant = await this.participantService.getByUserAndTournament(userId, input.tournamentId);
|
|
115
|
+
const prediction = participant.predictions.find(p => p.matchId.toString() === input.matchId.toString());
|
|
116
|
+
return prediction ?? null;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
exports.PredictionService = PredictionService;
|
|
120
|
+
exports.PredictionService = PredictionService = __decorate([
|
|
121
|
+
(0, typedi_1.Service)(),
|
|
122
|
+
__metadata("design:paramtypes", [])
|
|
123
|
+
], PredictionService);
|
|
124
|
+
exports.predictionService = typedi_1.default.get(PredictionService);
|
|
125
|
+
//# sourceMappingURL=prediction.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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AC,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;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"]}
|