@lyxa.ai/marketing 1.0.52 → 1.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/index.d.ts +946 -53
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +1 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts +647 -0
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.js +7 -0
- package/dist/lib/modules/coupon/routers/coupon.router.js.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts +8 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.js +231 -27
- package/dist/lib/modules/coupon/services/coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js +17 -4
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts +26 -0
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.js +10 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts +40 -40
- package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js +9 -9
- package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts +0 -1
- package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.js +2 -5
- package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts +1 -0
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.js +2 -0
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +53 -40
- 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 +3 -2
- 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 +3 -9
- 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 +4 -7
- 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/config/limited-time-offer-config.service.d.ts +1 -0
- package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.service.js +15 -0
- package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.service.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts +88 -42
- package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/limited-time-offer.router.js +23 -0
- package/dist/lib/modules/limited-time-offer/limited-time-offer.router.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts +19 -0
- package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -0
- package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js +84 -0
- package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js.map +1 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.builder.d.ts +13 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.builder.d.ts.map +1 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.builder.js +22 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.builder.js.map +1 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts +20 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts.map +1 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.js +26 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.js.map +1 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.service.d.ts +8 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.service.d.ts.map +1 -0
- package/dist/lib/modules/{tournament/notification/notification.scheduler.service.js → limited-time-offer/notification/limited-time-offer-notification.service.js} +15 -28
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.service.js.map +1 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.type.d.ts +5 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.type.d.ts.map +1 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.type.js +3 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.type.js.map +1 -0
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.js +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +13 -0
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js +75 -0
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +6 -2
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts +1 -0
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts.map +1 -0
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.js +2 -0
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.js.map +1 -0
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +6 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js +3 -2
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +12 -2
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js +80 -27
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js.map +1 -1
- package/dist/lib/modules/marketing/services/marketing.service.d.ts +1 -0
- package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/marketing.service.js +9 -0
- package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/validations/product-marketing.validation.d.ts +2 -2
- 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.map +1 -1
- package/dist/lib/modules/tournament/config/config.builder.js +4 -0
- package/dist/lib/modules/tournament/config/config.builder.js.map +1 -1
- package/dist/lib/modules/tournament/config/config.repository.d.ts +8 -2
- package/dist/lib/modules/tournament/config/config.repository.d.ts.map +1 -1
- package/dist/lib/modules/tournament/config/config.repository.js +30 -1
- package/dist/lib/modules/tournament/config/config.repository.js.map +1 -1
- package/dist/lib/modules/tournament/config/config.router.d.ts +92 -2
- package/dist/lib/modules/tournament/config/config.router.d.ts.map +1 -1
- package/dist/lib/modules/tournament/config/config.types.d.ts +15 -0
- package/dist/lib/modules/tournament/config/config.types.d.ts.map +1 -0
- package/dist/lib/modules/tournament/config/config.types.js +3 -0
- package/dist/lib/modules/tournament/config/config.types.js.map +1 -0
- package/dist/lib/modules/tournament/config/config.validation.d.ts +395 -15
- package/dist/lib/modules/tournament/config/config.validation.d.ts.map +1 -1
- package/dist/lib/modules/tournament/config/config.validation.js +17 -2
- package/dist/lib/modules/tournament/config/config.validation.js.map +1 -1
- package/dist/lib/modules/tournament/integration/integration.factory.d.ts +4 -0
- package/dist/lib/modules/tournament/integration/integration.factory.d.ts.map +1 -0
- package/dist/lib/modules/tournament/integration/integration.factory.js +18 -0
- package/dist/lib/modules/tournament/integration/integration.factory.js.map +1 -0
- package/dist/lib/modules/tournament/integration/interfaces/ITournamentService.d.ts +36 -0
- package/dist/lib/modules/tournament/integration/interfaces/ITournamentService.d.ts.map +1 -0
- package/dist/lib/modules/tournament/integration/interfaces/ITournamentService.js +3 -0
- package/dist/lib/modules/tournament/integration/interfaces/ITournamentService.js.map +1 -0
- package/dist/lib/modules/tournament/integration/providers/api-football/api-football.provider.d.ts +14 -0
- package/dist/lib/modules/tournament/integration/providers/api-football/api-football.provider.d.ts.map +1 -0
- package/dist/lib/modules/tournament/integration/providers/api-football/api-football.provider.js +92 -0
- package/dist/lib/modules/tournament/integration/providers/api-football/api-football.provider.js.map +1 -0
- package/dist/lib/modules/tournament/integration/providers/api-football/api-football.types.d.ts +51 -0
- package/dist/lib/modules/tournament/integration/providers/api-football/api-football.types.d.ts.map +1 -0
- package/dist/lib/modules/tournament/integration/providers/api-football/api-football.types.js +3 -0
- package/dist/lib/modules/tournament/integration/providers/api-football/api-football.types.js.map +1 -0
- package/dist/lib/modules/tournament/integration/providers/api-football/index.d.ts +3 -0
- package/dist/lib/modules/tournament/integration/providers/api-football/index.d.ts.map +1 -0
- package/dist/lib/modules/tournament/integration/providers/api-football/index.js +19 -0
- package/dist/lib/modules/tournament/integration/providers/api-football/index.js.map +1 -0
- package/dist/lib/modules/tournament/integration/providers/index.d.ts +3 -0
- package/dist/lib/modules/tournament/integration/providers/index.d.ts.map +1 -0
- package/dist/lib/modules/tournament/integration/providers/index.js +19 -0
- package/dist/lib/modules/tournament/integration/providers/index.js.map +1 -0
- package/dist/lib/modules/tournament/integration/providers/mock.provider.d.ts +7 -0
- package/dist/lib/modules/tournament/integration/providers/mock.provider.d.ts.map +1 -0
- package/dist/lib/modules/tournament/integration/providers/mock.provider.js +22 -0
- package/dist/lib/modules/tournament/integration/providers/mock.provider.js.map +1 -0
- package/dist/lib/modules/tournament/integration/tournamentService.d.ts +9 -0
- package/dist/lib/modules/tournament/integration/tournamentService.d.ts.map +1 -0
- package/dist/lib/modules/tournament/integration/tournamentService.js +20 -0
- package/dist/lib/modules/tournament/integration/tournamentService.js.map +1 -0
- package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.d.ts.map +1 -1
- package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js +47 -11
- package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js.map +1 -1
- package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.d.ts +7 -3
- package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.d.ts.map +1 -1
- package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.js +1 -1
- package/dist/lib/modules/tournament/match/events/evaluate-predictions.event.js.map +1 -1
- package/dist/lib/modules/tournament/match/events/match-evaluation.orchestrator.d.ts +14 -0
- package/dist/lib/modules/tournament/match/events/match-evaluation.orchestrator.d.ts.map +1 -0
- package/dist/lib/modules/tournament/{notification/jobs/notification.worker.js → match/events/match-evaluation.orchestrator.js} +31 -27
- package/dist/lib/modules/tournament/match/events/match-evaluation.orchestrator.js.map +1 -0
- package/dist/lib/modules/tournament/match/match.builder.d.ts +13 -34
- package/dist/lib/modules/tournament/match/match.builder.d.ts.map +1 -1
- package/dist/lib/modules/tournament/match/match.builder.js +31 -10
- package/dist/lib/modules/tournament/match/match.builder.js.map +1 -1
- package/dist/lib/modules/tournament/match/match.repository.d.ts +1 -1
- package/dist/lib/modules/tournament/match/match.repository.d.ts.map +1 -1
- package/dist/lib/modules/tournament/match/match.repository.js.map +1 -1
- package/dist/lib/modules/tournament/match/match.router.d.ts +36 -0
- package/dist/lib/modules/tournament/match/match.router.d.ts.map +1 -1
- package/dist/lib/modules/tournament/match/match.service.d.ts +3 -0
- package/dist/lib/modules/tournament/match/match.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/match/match.service.js +15 -12
- package/dist/lib/modules/tournament/match/match.service.js.map +1 -1
- package/dist/lib/modules/tournament/match/match.types.d.ts +51 -0
- package/dist/lib/modules/tournament/match/match.types.d.ts.map +1 -0
- package/dist/lib/modules/tournament/match/match.types.js +3 -0
- package/dist/lib/modules/tournament/match/match.types.js.map +1 -0
- package/dist/lib/modules/tournament/notification/notification-template.repository.d.ts +2 -1
- package/dist/lib/modules/tournament/notification/notification-template.repository.d.ts.map +1 -1
- package/dist/lib/modules/tournament/notification/notification-template.repository.js +2 -1
- package/dist/lib/modules/tournament/notification/notification-template.repository.js.map +1 -1
- package/dist/lib/modules/tournament/notification/notification.builder.d.ts +30 -0
- package/dist/lib/modules/tournament/notification/notification.builder.d.ts.map +1 -0
- package/dist/lib/modules/tournament/notification/notification.builder.js +35 -0
- package/dist/lib/modules/tournament/notification/notification.builder.js.map +1 -0
- package/dist/lib/modules/tournament/notification/notification.config.d.ts +10 -9
- package/dist/lib/modules/tournament/notification/notification.config.d.ts.map +1 -1
- package/dist/lib/modules/tournament/notification/notification.config.js +0 -12
- package/dist/lib/modules/tournament/notification/notification.config.js.map +1 -1
- package/dist/lib/modules/tournament/notification/notification.service.d.ts +5 -3
- package/dist/lib/modules/tournament/notification/notification.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/notification/notification.service.js +23 -15
- package/dist/lib/modules/tournament/notification/notification.service.js.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.builder.d.ts +12 -0
- package/dist/lib/modules/tournament/participant/participant.builder.d.ts.map +1 -0
- package/dist/lib/modules/tournament/participant/participant.builder.js +17 -0
- package/dist/lib/modules/tournament/participant/participant.builder.js.map +1 -0
- package/dist/lib/modules/tournament/participant/participant.repository.d.ts +8 -7
- package/dist/lib/modules/tournament/participant/participant.repository.d.ts.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.repository.js +12 -2
- package/dist/lib/modules/tournament/participant/participant.repository.js.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.service.d.ts +1 -0
- package/dist/lib/modules/tournament/participant/participant.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.service.js +15 -17
- package/dist/lib/modules/tournament/participant/participant.service.js.map +1 -1
- package/dist/lib/modules/tournament/prediction/prediction.builder.d.ts +3 -9
- package/dist/lib/modules/tournament/prediction/prediction.builder.d.ts.map +1 -1
- package/dist/lib/modules/tournament/prediction/prediction.builder.js.map +1 -1
- package/dist/lib/modules/tournament/prediction/prediction.repository.d.ts +11 -3
- package/dist/lib/modules/tournament/prediction/prediction.repository.d.ts.map +1 -1
- package/dist/lib/modules/tournament/prediction/prediction.repository.js +47 -0
- package/dist/lib/modules/tournament/prediction/prediction.repository.js.map +1 -1
- package/dist/lib/modules/tournament/prediction/prediction.service.d.ts +1 -1
- package/dist/lib/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/prediction/prediction.service.js +16 -26
- package/dist/lib/modules/tournament/prediction/prediction.service.js.map +1 -1
- package/dist/lib/modules/tournament/prediction/prediction.types.d.ts +17 -0
- package/dist/lib/modules/tournament/prediction/prediction.types.d.ts.map +1 -0
- package/dist/lib/modules/tournament/prediction/prediction.types.js +3 -0
- package/dist/lib/modules/tournament/prediction/prediction.types.js.map +1 -0
- package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.d.ts +8 -5
- package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.d.ts.map +1 -1
- package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.js +58 -16
- package/dist/lib/modules/tournament/reward/handlers/coupon-reward.handler.js.map +1 -1
- package/dist/lib/modules/tournament/reward/reward.builder.d.ts +5 -2
- package/dist/lib/modules/tournament/reward/reward.builder.d.ts.map +1 -1
- package/dist/lib/modules/tournament/reward/reward.builder.js +44 -28
- package/dist/lib/modules/tournament/reward/reward.builder.js.map +1 -1
- package/dist/lib/modules/tournament/reward/reward.factory.d.ts +1 -1
- package/dist/lib/modules/tournament/reward/reward.factory.d.ts.map +1 -1
- package/dist/lib/modules/tournament/reward/reward.factory.js.map +1 -1
- package/dist/lib/modules/tournament/reward/reward.interface.d.ts +2 -2
- package/dist/lib/modules/tournament/reward/reward.interface.d.ts.map +1 -1
- package/dist/lib/modules/tournament/reward/reward.interface.js.map +1 -1
- package/dist/lib/modules/tournament/reward/reward.service.d.ts +1 -1
- package/dist/lib/modules/tournament/reward/reward.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/reward/reward.service.js +1 -1
- package/dist/lib/modules/tournament/reward/reward.service.js.map +1 -1
- package/dist/lib/modules/tournament/reward/reward.types.d.ts +35 -2
- package/dist/lib/modules/tournament/reward/reward.types.d.ts.map +1 -1
- package/dist/lib/modules/tournament/reward/reward.types.js.map +1 -1
- package/dist/lib/modules/tournament/schedule/schedule.router.d.ts.map +1 -1
- package/dist/lib/modules/tournament/schedule/schedule.router.js +1 -3
- package/dist/lib/modules/tournament/schedule/schedule.router.js.map +1 -1
- package/dist/lib/modules/tournament/schedule/schedule.service.d.ts +3 -0
- package/dist/lib/modules/tournament/schedule/schedule.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/schedule/schedule.service.js +30 -1
- package/dist/lib/modules/tournament/schedule/schedule.service.js.map +1 -1
- package/dist/lib/modules/tournament/score/score.repository.d.ts +13 -0
- package/dist/lib/modules/tournament/score/score.repository.d.ts.map +1 -1
- package/dist/lib/modules/tournament/score/score.repository.js +20 -0
- package/dist/lib/modules/tournament/score/score.repository.js.map +1 -1
- package/dist/lib/modules/tournament/score/score.service.d.ts +3 -0
- package/dist/lib/modules/tournament/score/score.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/score/score.service.js +3 -0
- package/dist/lib/modules/tournament/score/score.service.js.map +1 -1
- package/dist/lib/modules/tournament/statistics/statistics.builder.d.ts +5 -0
- package/dist/lib/modules/tournament/statistics/statistics.builder.d.ts.map +1 -1
- package/dist/lib/modules/tournament/statistics/statistics.builder.js +47 -28
- package/dist/lib/modules/tournament/statistics/statistics.builder.js.map +1 -1
- package/dist/lib/modules/tournament/statistics/statistics.router.d.ts +4 -2
- package/dist/lib/modules/tournament/statistics/statistics.router.d.ts.map +1 -1
- package/dist/lib/modules/tournament/statistics/statistics.service.js +4 -4
- package/dist/lib/modules/tournament/statistics/statistics.service.js.map +1 -1
- package/dist/lib/modules/tournament/statistics/statistics.validation.d.ts +32 -14
- package/dist/lib/modules/tournament/statistics/statistics.validation.d.ts.map +1 -1
- package/dist/lib/modules/tournament/statistics/statistics.validation.js +2 -1
- package/dist/lib/modules/tournament/statistics/statistics.validation.js.map +1 -1
- package/dist/lib/modules/tournament/sync/sync.repository.d.ts +11 -0
- package/dist/lib/modules/tournament/sync/sync.repository.d.ts.map +1 -0
- package/dist/lib/modules/tournament/sync/sync.repository.js +67 -0
- package/dist/lib/modules/tournament/sync/sync.repository.js.map +1 -0
- package/dist/lib/modules/tournament/sync/sync.router.d.ts +27 -0
- package/dist/lib/modules/tournament/sync/sync.router.d.ts.map +1 -0
- package/dist/lib/modules/tournament/sync/sync.router.js +15 -0
- package/dist/lib/modules/tournament/sync/sync.router.js.map +1 -0
- package/dist/lib/modules/tournament/sync/sync.service.d.ts +9 -0
- package/dist/lib/modules/tournament/sync/sync.service.d.ts.map +1 -0
- package/dist/lib/modules/tournament/sync/sync.service.js +117 -0
- package/dist/lib/modules/tournament/sync/sync.service.js.map +1 -0
- package/dist/lib/modules/tournament/team/team.builder.d.ts +4 -0
- package/dist/lib/modules/tournament/team/team.builder.d.ts.map +1 -1
- package/dist/lib/modules/tournament/team/team.builder.js +6 -0
- package/dist/lib/modules/tournament/team/team.builder.js.map +1 -1
- package/dist/lib/modules/tournament/team/team.repository.d.ts +3 -0
- package/dist/lib/modules/tournament/team/team.repository.d.ts.map +1 -1
- package/dist/lib/modules/tournament/team/team.repository.js +6 -0
- package/dist/lib/modules/tournament/team/team.repository.js.map +1 -1
- package/dist/lib/modules/tournament/team/team.router.d.ts +22 -4
- package/dist/lib/modules/tournament/team/team.router.d.ts.map +1 -1
- package/dist/lib/modules/tournament/team/team.router.js +1 -1
- package/dist/lib/modules/tournament/team/team.router.js.map +1 -1
- package/dist/lib/modules/tournament/team/team.service.d.ts +2 -1
- package/dist/lib/modules/tournament/team/team.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/team/team.service.js +26 -23
- package/dist/lib/modules/tournament/team/team.service.js.map +1 -1
- package/dist/lib/modules/tournament/team/team.validation.d.ts +23 -24
- package/dist/lib/modules/tournament/team/team.validation.d.ts.map +1 -1
- package/dist/lib/modules/tournament/team/team.validation.js +3 -4
- package/dist/lib/modules/tournament/team/team.validation.js.map +1 -1
- package/dist/lib/modules/tournament/tournament.builder.d.ts +11 -0
- package/dist/lib/modules/tournament/tournament.builder.d.ts.map +1 -0
- package/dist/lib/modules/tournament/tournament.builder.js +34 -0
- package/dist/lib/modules/tournament/tournament.builder.js.map +1 -0
- package/dist/lib/modules/tournament/tournament.router.d.ts +210 -10
- package/dist/lib/modules/tournament/tournament.router.d.ts.map +1 -1
- package/dist/lib/modules/tournament/tournament.router.js +2 -0
- package/dist/lib/modules/tournament/tournament.router.js.map +1 -1
- package/dist/lib/modules/tournament/tournament.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/tournament.service.js +3 -10
- package/dist/lib/modules/tournament/tournament.service.js.map +1 -1
- package/dist/lib/modules/tournament/tournament.utils.d.ts +4 -0
- package/dist/lib/modules/tournament/tournament.utils.d.ts.map +1 -1
- package/dist/lib/modules/tournament/tournament.utils.js +8 -1
- package/dist/lib/modules/tournament/tournament.utils.js.map +1 -1
- package/dist/lib/modules/tournament/tournament.validation.d.ts +205 -1
- package/dist/lib/modules/tournament/tournament.validation.d.ts.map +1 -1
- package/dist/lib/modules/tournament/tournament.validation.js +23 -2
- package/dist/lib/modules/tournament/tournament.validation.js.map +1 -1
- package/dist/types/index.d.ts +946 -53
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/coupon/routers/coupon.router.d.ts +647 -0
- package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/coupon.service.d.ts +8 -1
- package/dist/types/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts +26 -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 +42 -40
- package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts +0 -1
- package/dist/types/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts +1 -0
- package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +53 -40
- 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 +3 -9
- 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/config/limited-time-offer-config.service.d.ts +1 -0
- package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts +88 -42
- package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts +24 -0
- package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -0
- package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.builder.d.ts +13 -0
- package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.builder.d.ts.map +1 -0
- package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts +20 -0
- package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts.map +1 -0
- package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.service.d.ts +8 -0
- package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.service.d.ts.map +1 -0
- package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.type.d.ts +5 -0
- package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.type.d.ts.map +1 -0
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +13 -0
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +6 -2
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +6 -1
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +22 -2
- package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/marketing.service.d.ts +1 -0
- package/dist/types/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/validations/product-marketing.validation.d.ts +2 -2
- 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.map +1 -1
- package/dist/types/modules/tournament/config/config.repository.d.ts +8 -2
- package/dist/types/modules/tournament/config/config.repository.d.ts.map +1 -1
- package/dist/types/modules/tournament/config/config.router.d.ts +92 -2
- package/dist/types/modules/tournament/config/config.router.d.ts.map +1 -1
- package/dist/types/modules/tournament/config/config.types.d.ts +15 -0
- package/dist/types/modules/tournament/config/config.types.d.ts.map +1 -0
- package/dist/types/modules/tournament/config/config.validation.d.ts +395 -15
- package/dist/types/modules/tournament/config/config.validation.d.ts.map +1 -1
- package/dist/types/modules/tournament/integration/integration.factory.d.ts +4 -0
- package/dist/types/modules/tournament/integration/integration.factory.d.ts.map +1 -0
- package/dist/types/modules/tournament/integration/interfaces/ITournamentService.d.ts +36 -0
- package/dist/types/modules/tournament/integration/interfaces/ITournamentService.d.ts.map +1 -0
- package/dist/types/modules/tournament/integration/providers/api-football/api-football.provider.d.ts +14 -0
- package/dist/types/modules/tournament/integration/providers/api-football/api-football.provider.d.ts.map +1 -0
- package/dist/types/modules/tournament/integration/providers/api-football/api-football.types.d.ts +51 -0
- package/dist/types/modules/tournament/integration/providers/api-football/api-football.types.d.ts.map +1 -0
- package/dist/types/modules/tournament/integration/providers/api-football/index.d.ts +3 -0
- package/dist/types/modules/tournament/integration/providers/api-football/index.d.ts.map +1 -0
- package/dist/types/modules/tournament/integration/providers/index.d.ts +3 -0
- package/dist/types/modules/tournament/integration/providers/index.d.ts.map +1 -0
- package/dist/types/modules/tournament/integration/providers/mock.provider.d.ts +7 -0
- package/dist/types/modules/tournament/integration/providers/mock.provider.d.ts.map +1 -0
- package/dist/types/modules/tournament/integration/tournamentService.d.ts +9 -0
- package/dist/types/modules/tournament/integration/tournamentService.d.ts.map +1 -0
- package/dist/types/modules/tournament/match/events/evaluate-predictions.consumer.d.ts.map +1 -1
- package/dist/types/modules/tournament/match/events/evaluate-predictions.event.d.ts +7 -3
- package/dist/types/modules/tournament/match/events/evaluate-predictions.event.d.ts.map +1 -1
- package/dist/types/modules/tournament/match/events/match-evaluation.orchestrator.d.ts +14 -0
- package/dist/types/modules/tournament/match/events/match-evaluation.orchestrator.d.ts.map +1 -0
- package/dist/types/modules/tournament/match/match.builder.d.ts +13 -34
- package/dist/types/modules/tournament/match/match.builder.d.ts.map +1 -1
- package/dist/types/modules/tournament/match/match.repository.d.ts +1 -1
- package/dist/types/modules/tournament/match/match.repository.d.ts.map +1 -1
- package/dist/types/modules/tournament/match/match.router.d.ts +36 -0
- package/dist/types/modules/tournament/match/match.router.d.ts.map +1 -1
- package/dist/types/modules/tournament/match/match.service.d.ts +3 -0
- package/dist/types/modules/tournament/match/match.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/match/match.types.d.ts +51 -0
- package/dist/types/modules/tournament/match/match.types.d.ts.map +1 -0
- package/dist/types/modules/tournament/notification/notification-template.repository.d.ts +2 -1
- package/dist/types/modules/tournament/notification/notification-template.repository.d.ts.map +1 -1
- package/dist/types/modules/tournament/notification/notification.builder.d.ts +30 -0
- package/dist/types/modules/tournament/notification/notification.builder.d.ts.map +1 -0
- package/dist/types/modules/tournament/notification/notification.config.d.ts +10 -9
- package/dist/types/modules/tournament/notification/notification.config.d.ts.map +1 -1
- package/dist/types/modules/tournament/notification/notification.service.d.ts +5 -3
- package/dist/types/modules/tournament/notification/notification.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/participant/participant.builder.d.ts +12 -0
- package/dist/types/modules/tournament/participant/participant.builder.d.ts.map +1 -0
- package/dist/types/modules/tournament/participant/participant.repository.d.ts +8 -7
- package/dist/types/modules/tournament/participant/participant.repository.d.ts.map +1 -1
- package/dist/types/modules/tournament/participant/participant.service.d.ts +1 -0
- package/dist/types/modules/tournament/participant/participant.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/prediction/prediction.builder.d.ts +3 -9
- package/dist/types/modules/tournament/prediction/prediction.builder.d.ts.map +1 -1
- package/dist/types/modules/tournament/prediction/prediction.repository.d.ts +11 -3
- package/dist/types/modules/tournament/prediction/prediction.repository.d.ts.map +1 -1
- package/dist/types/modules/tournament/prediction/prediction.service.d.ts +1 -1
- package/dist/types/modules/tournament/prediction/prediction.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/prediction/prediction.types.d.ts +17 -0
- package/dist/types/modules/tournament/prediction/prediction.types.d.ts.map +1 -0
- package/dist/types/modules/tournament/reward/handlers/coupon-reward.handler.d.ts +8 -5
- package/dist/types/modules/tournament/reward/handlers/coupon-reward.handler.d.ts.map +1 -1
- package/dist/types/modules/tournament/reward/reward.builder.d.ts +5 -2
- package/dist/types/modules/tournament/reward/reward.builder.d.ts.map +1 -1
- package/dist/types/modules/tournament/reward/reward.factory.d.ts +1 -1
- package/dist/types/modules/tournament/reward/reward.factory.d.ts.map +1 -1
- package/dist/types/modules/tournament/reward/reward.interface.d.ts +2 -2
- package/dist/types/modules/tournament/reward/reward.interface.d.ts.map +1 -1
- package/dist/types/modules/tournament/reward/reward.service.d.ts +1 -1
- package/dist/types/modules/tournament/reward/reward.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/reward/reward.types.d.ts +35 -2
- package/dist/types/modules/tournament/reward/reward.types.d.ts.map +1 -1
- package/dist/types/modules/tournament/schedule/schedule.router.d.ts.map +1 -1
- package/dist/types/modules/tournament/schedule/schedule.service.d.ts +3 -0
- package/dist/types/modules/tournament/schedule/schedule.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/score/score.repository.d.ts +13 -0
- package/dist/types/modules/tournament/score/score.repository.d.ts.map +1 -1
- package/dist/types/modules/tournament/score/score.service.d.ts +3 -0
- package/dist/types/modules/tournament/score/score.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/statistics/statistics.builder.d.ts +5 -0
- package/dist/types/modules/tournament/statistics/statistics.builder.d.ts.map +1 -1
- package/dist/types/modules/tournament/statistics/statistics.router.d.ts +4 -2
- package/dist/types/modules/tournament/statistics/statistics.router.d.ts.map +1 -1
- package/dist/types/modules/tournament/statistics/statistics.validation.d.ts +32 -14
- package/dist/types/modules/tournament/statistics/statistics.validation.d.ts.map +1 -1
- package/dist/types/modules/tournament/sync/sync.repository.d.ts +11 -0
- package/dist/types/modules/tournament/sync/sync.repository.d.ts.map +1 -0
- package/dist/types/modules/tournament/sync/sync.router.d.ts +27 -0
- package/dist/types/modules/tournament/sync/sync.router.d.ts.map +1 -0
- package/dist/types/modules/tournament/sync/sync.service.d.ts +9 -0
- package/dist/types/modules/tournament/sync/sync.service.d.ts.map +1 -0
- package/dist/types/modules/tournament/team/team.builder.d.ts +4 -0
- package/dist/types/modules/tournament/team/team.builder.d.ts.map +1 -1
- package/dist/types/modules/tournament/team/team.repository.d.ts +3 -0
- package/dist/types/modules/tournament/team/team.repository.d.ts.map +1 -1
- package/dist/types/modules/tournament/team/team.router.d.ts +22 -4
- package/dist/types/modules/tournament/team/team.router.d.ts.map +1 -1
- package/dist/types/modules/tournament/team/team.service.d.ts +2 -1
- package/dist/types/modules/tournament/team/team.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/team/team.validation.d.ts +23 -24
- package/dist/types/modules/tournament/team/team.validation.d.ts.map +1 -1
- package/dist/types/modules/tournament/tournament.builder.d.ts +11 -0
- package/dist/types/modules/tournament/tournament.builder.d.ts.map +1 -0
- package/dist/types/modules/tournament/tournament.router.d.ts +210 -10
- package/dist/types/modules/tournament/tournament.router.d.ts.map +1 -1
- package/dist/types/modules/tournament/tournament.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/tournament.utils.d.ts +4 -0
- package/dist/types/modules/tournament/tournament.utils.d.ts.map +1 -1
- package/dist/types/modules/tournament/tournament.validation.d.ts +205 -1
- package/dist/types/modules/tournament/tournament.validation.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/lib/modules/tournament/match/events/match-ended.consumer.d.ts +0 -2
- package/dist/lib/modules/tournament/match/events/match-ended.consumer.d.ts.map +0 -1
- package/dist/lib/modules/tournament/match/events/match-ended.consumer.js +0 -15
- package/dist/lib/modules/tournament/match/events/match-ended.consumer.js.map +0 -1
- package/dist/lib/modules/tournament/match/events/match-ended.event.d.ts +0 -14
- package/dist/lib/modules/tournament/match/events/match-ended.event.d.ts.map +0 -1
- package/dist/lib/modules/tournament/match/events/match-ended.event.js +0 -12
- package/dist/lib/modules/tournament/match/events/match-ended.event.js.map +0 -1
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts +0 -10
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts.map +0 -1
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.js +0 -23
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.js.map +0 -1
- package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts +0 -9
- package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts.map +0 -1
- package/dist/lib/modules/tournament/notification/jobs/notification.worker.js.map +0 -1
- package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts +0 -10
- package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts.map +0 -1
- package/dist/lib/modules/tournament/notification/notification.schedule.config.js +0 -15
- package/dist/lib/modules/tournament/notification/notification.schedule.config.js.map +0 -1
- package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts +0 -10
- package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts.map +0 -1
- package/dist/lib/modules/tournament/notification/notification.scheduler.service.js.map +0 -1
- package/dist/types/events/event-initializations.d.ts +0 -2
- package/dist/types/events/event-initializations.d.ts.map +0 -1
- package/dist/types/modules/tournament/config/tournament-config.validation.d.ts +0 -201
- package/dist/types/modules/tournament/config/tournament-config.validation.d.ts.map +0 -1
- package/dist/types/modules/tournament/match/events/match-ended.consumer.d.ts +0 -2
- package/dist/types/modules/tournament/match/events/match-ended.consumer.d.ts.map +0 -1
- package/dist/types/modules/tournament/match/events/match-ended.event.d.ts +0 -14
- package/dist/types/modules/tournament/match/events/match-ended.event.d.ts.map +0 -1
- package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts +0 -10
- package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts.map +0 -1
- package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts +0 -9
- package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts.map +0 -1
- package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts +0 -10
- package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts.map +0 -1
- package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts +0 -10
- package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts.map +0 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare const syncRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
2
|
+
ctx: import("@lyxa.ai/core/dist/libraries/trpc/context").LyxaHTTPContext;
|
|
3
|
+
meta: object;
|
|
4
|
+
errorShape: {
|
|
5
|
+
message: string;
|
|
6
|
+
data: {
|
|
7
|
+
stack: undefined;
|
|
8
|
+
path: undefined;
|
|
9
|
+
code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
|
|
10
|
+
httpStatus: number;
|
|
11
|
+
};
|
|
12
|
+
stack: undefined;
|
|
13
|
+
code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
|
|
14
|
+
};
|
|
15
|
+
transformer: false;
|
|
16
|
+
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
17
|
+
syncLiveScores: import("@trpc/server").TRPCMutationProcedure<{
|
|
18
|
+
input: void;
|
|
19
|
+
output: {
|
|
20
|
+
success: boolean;
|
|
21
|
+
message: string;
|
|
22
|
+
data: null | undefined;
|
|
23
|
+
};
|
|
24
|
+
meta: object;
|
|
25
|
+
}>;
|
|
26
|
+
}>>;
|
|
27
|
+
//# sourceMappingURL=sync.router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.router.d.ts","sourceRoot":"/","sources":["modules/tournament/sync/sync.router.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;GAWrB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.syncRouter = void 0;
|
|
4
|
+
const trpc_1 = require("@lyxa.ai/core/dist/libraries/trpc");
|
|
5
|
+
const error_handler_1 = require("@lyxa.ai/core/dist/utilities/error-handler");
|
|
6
|
+
const response_1 = require("@lyxa.ai/core/dist/utilities/response");
|
|
7
|
+
const sync_service_1 = require("./sync.service");
|
|
8
|
+
exports.syncRouter = (0, trpc_1.createTRPCRouter)({
|
|
9
|
+
syncLiveScores: trpc_1.publicProcedure
|
|
10
|
+
.mutation(() => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
11
|
+
await sync_service_1.syncService.syncLiveScores();
|
|
12
|
+
return (0, response_1.response)('Live scores synced successfully', null);
|
|
13
|
+
})),
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=sync.router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.router.js","sourceRoot":"/","sources":["modules/tournament/sync/sync.router.ts"],"names":[],"mappings":";;;AAAA,4DAAoF;AACpF,8EAAwE;AACxE,oEAA+D;AAC/D,iDAAsD;AAEzC,QAAA,UAAU,GAAG,IAAA,uBAAgB,EAAC;IAEvC,cAAc,EACV,sBAAe;SAEd,QAAQ,CAAC,GAAG,EAAE,CACX,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,MAAM,0BAAO,CAAC,cAAc,EAAE,CAAC;QAC/B,OAAO,IAAA,mBAAQ,EAAC,iCAAiC,EAAE,IAAI,CAAC,CAAC;IAC7D,CAAC,CAAC,CACL;CACR,CAAC,CAAC","sourcesContent":["import {createTRPCRouter, publicProcedure} from '@lyxa.ai/core/dist/libraries/trpc';\nimport {ErrorHandler} from '@lyxa.ai/core/dist/utilities/error-handler';\nimport {response} from '@lyxa.ai/core/dist/utilities/response';\nimport {syncService as service} from './sync.service';\n\nexport const syncRouter = createTRPCRouter({\n // NOTE: this will be called every one minute from google scheduler\n syncLiveScores:\n publicProcedure\n // createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n .mutation(() =>\n ErrorHandler.wrapAsync(async () => {\n await service.syncLiveScores();\n return response('Live scores synced successfully', null);\n })\n ),\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.service.d.ts","sourceRoot":"/","sources":["modules/tournament/sync/sync.service.ts"],"names":[],"mappings":"AAYA,qBACa,WAAW;IACpB,OAAO,CAAC,UAAU,CAAiB;IACnC,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,YAAY,CAAe;;IAQtB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;CAkD/C;AAED,eAAO,MAAM,WAAW,aAA6B,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
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.syncService = exports.SyncService = void 0;
|
|
46
|
+
const typedi_1 = __importStar(require("typedi"));
|
|
47
|
+
const integration_factory_1 = require("../integration/integration.factory");
|
|
48
|
+
const sync_repository_1 = require("./sync.repository");
|
|
49
|
+
const score_repository_1 = require("../score/score.repository");
|
|
50
|
+
const match_builder_1 = require("../match/match.builder");
|
|
51
|
+
const match_service_1 = require("../match/match.service");
|
|
52
|
+
const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
|
|
53
|
+
const tournament_utils_1 = require("../tournament.utils");
|
|
54
|
+
let SyncService = class SyncService {
|
|
55
|
+
repository;
|
|
56
|
+
scoreRepository;
|
|
57
|
+
matchService;
|
|
58
|
+
constructor() {
|
|
59
|
+
this.repository = typedi_1.default.get(sync_repository_1.SyncRepository);
|
|
60
|
+
this.scoreRepository = typedi_1.default.get(score_repository_1.ScoreRepository);
|
|
61
|
+
this.matchService = typedi_1.default.get(match_service_1.MatchService);
|
|
62
|
+
}
|
|
63
|
+
async syncLiveScores() {
|
|
64
|
+
const tournament = await this.repository.findActiveTournament();
|
|
65
|
+
if (!tournament || !tournament.externalProvider || !tournament.externalApiKey)
|
|
66
|
+
return;
|
|
67
|
+
const now = (0, tournament_utils_1.utcNow)();
|
|
68
|
+
const liveCandidates = new Map();
|
|
69
|
+
tournament.matches.forEach((match, idx) => {
|
|
70
|
+
if (!match.externalId || match.matchEnded)
|
|
71
|
+
return;
|
|
72
|
+
if (!match.startingDate || match.startingDate > now)
|
|
73
|
+
return;
|
|
74
|
+
liveCandidates.set(match.externalId.toString(), { match, matchNumber: idx + 1 });
|
|
75
|
+
});
|
|
76
|
+
if (!liveCandidates.size)
|
|
77
|
+
return;
|
|
78
|
+
const provider = (0, integration_factory_1.createTournamentService)(tournament.externalProvider, tournament.externalApiKey);
|
|
79
|
+
const liveScores = await provider.getLiveScores({ externalIds: Array.from(liveCandidates.keys()) });
|
|
80
|
+
const updates = [];
|
|
81
|
+
const evaluations = [];
|
|
82
|
+
for (const score of liveScores) {
|
|
83
|
+
const entry = liveCandidates.get(score.externalId);
|
|
84
|
+
if (!entry)
|
|
85
|
+
continue;
|
|
86
|
+
const { match, matchNumber } = entry;
|
|
87
|
+
const newScore = { team1: score.homeScore, team2: score.awayScore };
|
|
88
|
+
const scoreChanged = match.score.team1 !== newScore.team1 || match.score.team2 !== newScore.team2;
|
|
89
|
+
const matchStatus = score.ended ? enum_1.TournamentMatchStatus.ENDED : enum_1.TournamentMatchStatus.STARTED;
|
|
90
|
+
const statusChanged = match.matchStatus !== matchStatus;
|
|
91
|
+
if (!scoreChanged && !statusChanged && !score.ended)
|
|
92
|
+
continue;
|
|
93
|
+
const update = {
|
|
94
|
+
matchId: match._id,
|
|
95
|
+
score: newScore,
|
|
96
|
+
matchStatus,
|
|
97
|
+
};
|
|
98
|
+
if (score.ended) {
|
|
99
|
+
const { update: endFields, evaluation } = match_builder_1.MatchBuilder.buildEnd(match, matchNumber, newScore);
|
|
100
|
+
Object.assign(update, endFields);
|
|
101
|
+
evaluations.push(evaluation);
|
|
102
|
+
}
|
|
103
|
+
updates.push(update);
|
|
104
|
+
}
|
|
105
|
+
if (!updates.length)
|
|
106
|
+
return;
|
|
107
|
+
await this.scoreRepository.bulkSyncScores(tournament._id, updates);
|
|
108
|
+
await this.matchService.publishEvaluations(tournament._id, evaluations);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
exports.SyncService = SyncService;
|
|
112
|
+
exports.SyncService = SyncService = __decorate([
|
|
113
|
+
(0, typedi_1.Service)(),
|
|
114
|
+
__metadata("design:paramtypes", [])
|
|
115
|
+
], SyncService);
|
|
116
|
+
exports.syncService = typedi_1.default.get(SyncService);
|
|
117
|
+
//# sourceMappingURL=sync.service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,MAAM,GAAoB;gBAC5B,OAAO,EAAE,KAAK,CAAC,GAAG;gBAClB,KAAK,EAAE,QAAQ;gBACf,WAAW;aACd,CAAC;YAEF,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;gBACd,MAAM,EAAC,MAAM,EAAE,SAAS,EAAE,UAAU,EAAC,GAAG,4BAAY,CAAC,QAAQ,CAAC,KAAiC,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;gBACxH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;gBACjC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACjC,CAAC;YAED,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,MAAM;YAAE,OAAO;QAE5B,MAAM,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACnE,MAAM,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,UAAU,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAC5E,CAAC;CACJ,CAAA;AA7DY,kCAAW;sBAAX,WAAW;IADvB,IAAA,gBAAO,GAAE;;GACG,WAAW,CA6DvB;AAEY,QAAA,WAAW,GAAG,gBAAS,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {Tournament as TournamentType} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {createTournamentService} from '../integration/integration.factory';\nimport {SyncRepository} from './sync.repository';\nimport {BulkScoreUpdate, ScoreRepository} from '../score/score.repository';\nimport {MatchBuilder} from '../match/match.builder';\nimport {MatchService} from '../match/match.service';\nimport {TournamentMatchOutputDTO} from '../match/match.validation';\nimport {EvaluatePredictionsMatch} from '../match/events/evaluate-predictions.event';\nimport {TournamentMatchStatus} from '@lyxa.ai/core/dist/utilities/enum';\nimport {utcNow} from '../tournament.utils';\n\n@Service()\nexport class SyncService {\n private repository: SyncRepository;\n private scoreRepository: ScoreRepository;\n private matchService: MatchService;\n\n constructor() {\n this.repository = Container.get(SyncRepository);\n this.scoreRepository = Container.get(ScoreRepository);\n this.matchService = Container.get(MatchService);\n }\n\n public async syncLiveScores(): Promise<void> {\n const tournament = await this.repository.findActiveTournament();\n if (!tournament || !tournament.externalProvider || !tournament.externalApiKey) return;\n\n const now = utcNow();\n const liveCandidates = new Map<string, {match: TournamentType['matches'][number]; matchNumber: number}>();\n tournament.matches.forEach((match, idx) => {\n if (!match.externalId || match.matchEnded) return;\n if (!match.startingDate || match.startingDate > now) return;\n liveCandidates.set(match.externalId.toString(), {match, matchNumber: idx + 1});\n });\n if (!liveCandidates.size) return;\n\n const provider = createTournamentService(tournament.externalProvider, tournament.externalApiKey);\n const liveScores = await provider.getLiveScores({externalIds: Array.from(liveCandidates.keys())});\n\n const updates: BulkScoreUpdate[] = [];\n const evaluations: Array<EvaluatePredictionsMatch | null> = [];\n\n for (const score of liveScores) {\n const entry = liveCandidates.get(score.externalId);\n if (!entry) continue;\n const {match, matchNumber} = entry;\n const newScore = {team1: score.homeScore, team2: score.awayScore};\n\n const scoreChanged = match.score.team1 !== newScore.team1 || match.score.team2 !== newScore.team2;\n const matchStatus = score.ended ? TournamentMatchStatus.ENDED : TournamentMatchStatus.STARTED;\n const statusChanged = match.matchStatus !== matchStatus;\n if (!scoreChanged && !statusChanged && !score.ended) continue;\n\n const update: BulkScoreUpdate = {\n matchId: match._id,\n score: newScore,\n matchStatus,\n };\n\n if (score.ended) {\n const {update: endFields, evaluation} = MatchBuilder.buildEnd(match as TournamentMatchOutputDTO, matchNumber, newScore);\n Object.assign(update, endFields);\n evaluations.push(evaluation);\n }\n\n updates.push(update);\n }\n\n if (!updates.length) return;\n\n await this.scoreRepository.bulkSyncScores(tournament._id, updates);\n await this.matchService.publishEvaluations(tournament._id, evaluations);\n }\n}\n\nexport const syncService = Container.get(SyncService);\n"]}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { mongoose } from '@typegoose/typegoose';
|
|
2
|
+
import { TournamentParticipantOutputDTO } from '../participant/participant.validation';
|
|
3
|
+
import { TournamentTeamOutputDTO } from './team.validation';
|
|
2
4
|
interface TeamInput {
|
|
3
5
|
name: string;
|
|
4
6
|
picture?: string;
|
|
@@ -14,6 +16,8 @@ export declare class TeamBuilder {
|
|
|
14
16
|
name: string;
|
|
15
17
|
picture: string | undefined;
|
|
16
18
|
}[];
|
|
19
|
+
static buildTeamPictureMap(teams: TournamentTeamOutputDTO[]): Map<string, string | undefined>;
|
|
20
|
+
static buildPredictionMap(predictions: TournamentParticipantOutputDTO['predictions']): Map<string, TournamentParticipantOutputDTO['predictions'][number]>;
|
|
17
21
|
}
|
|
18
22
|
export {};
|
|
19
23
|
//# sourceMappingURL=team.builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"team.builder.d.ts","sourceRoot":"/","sources":["modules/tournament/team/team.builder.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"team.builder.d.ts","sourceRoot":"/","sources":["modules/tournament/team/team.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,8BAA8B,EAAC,MAAM,uCAAuC,CAAC;AACrF,OAAO,EAAC,uBAAuB,EAAC,MAAM,mBAAmB,CAAC;AAE1D,UAAU,SAAS;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,WAAW;IACpB,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS;;;;;IAQjC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE;;;;;IAIrC,MAAM,CAAC,mBAAmB,CAAC,KAAK,EAAE,uBAAuB,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAI7F,MAAM,CAAC,kBAAkB,CACrB,WAAW,EAAE,8BAA8B,CAAC,aAAa,CAAC,GAC3D,GAAG,CAAC,MAAM,EAAE,8BAA8B,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;CAGxE"}
|
|
@@ -13,6 +13,12 @@ class TeamBuilder {
|
|
|
13
13
|
static buildTeams(inputs) {
|
|
14
14
|
return inputs.map(TeamBuilder.buildTeam);
|
|
15
15
|
}
|
|
16
|
+
static buildTeamPictureMap(teams) {
|
|
17
|
+
return new Map(teams.map(t => [t._id.toString(), t.picture]));
|
|
18
|
+
}
|
|
19
|
+
static buildPredictionMap(predictions) {
|
|
20
|
+
return new Map(predictions.map(p => [p.matchId.toString(), p]));
|
|
21
|
+
}
|
|
16
22
|
}
|
|
17
23
|
exports.TeamBuilder = TeamBuilder;
|
|
18
24
|
//# sourceMappingURL=team.builder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"team.builder.js","sourceRoot":"/","sources":["modules/tournament/team/team.builder.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"team.builder.js","sourceRoot":"/","sources":["modules/tournament/team/team.builder.ts"],"names":[],"mappings":";;;AAAA,oDAA8C;AAS9C,MAAa,WAAW;IACpB,MAAM,CAAC,SAAS,CAAC,KAAgB;QAC7B,OAAO;YACH,GAAG,EAAE,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE;YAClC,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,KAAK,CAAC,OAAO;SACzB,CAAC;IACN,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,MAAmB;QACjC,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,CAAC,mBAAmB,CAAC,KAAgC;QACvD,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,CAAC,kBAAkB,CACrB,WAA0D;QAE1D,OAAO,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACpE,CAAC;CACJ;AAtBD,kCAsBC","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\nimport {TournamentParticipantOutputDTO} from '../participant/participant.validation';\nimport {TournamentTeamOutputDTO} from './team.validation';\n\ninterface TeamInput {\n name: string;\n picture?: string;\n}\n\nexport class TeamBuilder {\n static buildTeam(input: TeamInput) {\n return {\n _id: new mongoose.Types.ObjectId(),\n name: input.name,\n picture: input.picture,\n };\n }\n\n static buildTeams(inputs: TeamInput[]) {\n return inputs.map(TeamBuilder.buildTeam);\n }\n\n static buildTeamPictureMap(teams: TournamentTeamOutputDTO[]): Map<string, string | undefined> {\n return new Map(teams.map(t => [t._id.toString(), t.picture]));\n }\n\n static buildPredictionMap(\n predictions: TournamentParticipantOutputDTO['predictions']\n ): Map<string, TournamentParticipantOutputDTO['predictions'][number]> {\n return new Map(predictions.map(p => [p.matchId.toString(), p]));\n }\n}\n"]}
|
|
@@ -4,6 +4,9 @@ export declare class TournamentTeamRepository {
|
|
|
4
4
|
private model;
|
|
5
5
|
constructor();
|
|
6
6
|
findById(id: mongoose.Types.ObjectId): Promise<Model | null>;
|
|
7
|
+
findActive(): Promise<(Model & {
|
|
8
|
+
_id: mongoose.Types.ObjectId;
|
|
9
|
+
}) | null>;
|
|
7
10
|
findByTeamId(teamId: mongoose.Types.ObjectId): Promise<Model | null>;
|
|
8
11
|
addTeams(id: mongoose.Types.ObjectId, teams: object[]): Promise<Model | null>;
|
|
9
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"team.repository.d.ts","sourceRoot":"/","sources":["modules/tournament/team/team.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,UAAU,IAAI,KAAK,EAAmB,MAAM,2CAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"team.repository.d.ts","sourceRoot":"/","sources":["modules/tournament/team/team.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,UAAU,IAAI,KAAK,EAAmB,MAAM,2CAA2C,CAAC;AAGjG,qBACa,wBAAwB;IACpC,OAAO,CAAC,KAAK,CAAyB;;IAMhC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAI5D,UAAU,IAAI,OAAO,CAAC,CAAC,KAAK,GAAG;QAAE,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAA;KAAE,CAAC,GAAG,IAAI,CAAC;IAMxE,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAIpE,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;CAKnF;AAED,eAAO,MAAM,wBAAwB,0BAA0C,CAAC"}
|
|
@@ -45,6 +45,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
45
45
|
exports.tournamentTeamRepository = exports.TournamentTeamRepository = void 0;
|
|
46
46
|
const typedi_1 = __importStar(require("typedi"));
|
|
47
47
|
const models_1 = require("@lyxa.ai/core/dist/libraries/mongo/models");
|
|
48
|
+
const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
|
|
48
49
|
let TournamentTeamRepository = class TournamentTeamRepository {
|
|
49
50
|
model;
|
|
50
51
|
constructor() {
|
|
@@ -53,6 +54,11 @@ let TournamentTeamRepository = class TournamentTeamRepository {
|
|
|
53
54
|
async findById(id) {
|
|
54
55
|
return this.model.findById(id).lean();
|
|
55
56
|
}
|
|
57
|
+
async findActive() {
|
|
58
|
+
return this.model
|
|
59
|
+
.findOne({ status: enum_1.Status.ACTIVE })
|
|
60
|
+
.lean();
|
|
61
|
+
}
|
|
56
62
|
async findByTeamId(teamId) {
|
|
57
63
|
return this.model.findOne({ 'teams._id': teamId }).lean();
|
|
58
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"team.repository.js","sourceRoot":"/","sources":["modules/tournament/team/team.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,sEAAiG;
|
|
1
|
+
{"version":3,"file":"team.repository.js","sourceRoot":"/","sources":["modules/tournament/team/team.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,sEAAiG;AACjG,4DAA2D;AAGpD,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAC5B,KAAK,CAAyB;IAEtC;QACC,IAAI,CAAC,KAAK,GAAG,wBAAe,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,EAA2B;QACzC,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,EAA2B,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,UAAU;QACf,OAAO,IAAI,CAAC,KAAK;aACf,OAAO,CAAC,EAAE,MAAM,EAAE,aAAM,CAAC,MAAM,EAAE,CAAC;aAClC,IAAI,EAAgE,CAAC;IACxE,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,MAA+B;QACjD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,EAA2B,CAAC;IACpF,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,EAA2B,EAAE,KAAe;QAC1D,OAAO,IAAI,CAAC,KAAK;aACf,iBAAiB,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;aAC5E,IAAI,EAA2B,CAAC;IACnC,CAAC;CACD,CAAA;AA1BY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,gBAAO,GAAE;;GACG,wBAAwB,CA0BpC;AAEY,QAAA,wBAAwB,GAAG,gBAAS,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport { Tournament as Model, TournamentModel } from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport { Status } from '@lyxa.ai/core/dist/utilities/enum';\n\n@Service()\nexport class TournamentTeamRepository {\n\tprivate model: typeof TournamentModel;\n\n\tconstructor() {\n\t\tthis.model = TournamentModel;\n\t}\n\n\tasync findById(id: mongoose.Types.ObjectId): Promise<Model | null> {\n\t\treturn this.model.findById(id).lean() as Promise<Model | null>;\n\t}\n\n\tasync findActive(): Promise<(Model & { _id: mongoose.Types.ObjectId }) | null> {\n\t\treturn this.model\n\t\t\t.findOne({ status: Status.ACTIVE })\n\t\t\t.lean() as Promise<(Model & { _id: mongoose.Types.ObjectId }) | null>;\n\t}\n\n\tasync findByTeamId(teamId: mongoose.Types.ObjectId): Promise<Model | null> {\n\t\treturn this.model.findOne({ 'teams._id': teamId }).lean() as Promise<Model | null>;\n\t}\n\n\tasync addTeams(id: mongoose.Types.ObjectId, teams: object[]): Promise<Model | null> {\n\t\treturn this.model\n\t\t\t.findByIdAndUpdate(id, { $push: { teams: { $each: teams } } }, { new: true })\n\t\t\t.lean() as Promise<Model | null>;\n\t}\n}\n\nexport const tournamentTeamRepository = Container.get(TournamentTeamRepository);\n"]}
|
|
@@ -43,6 +43,15 @@ export declare const teamRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
43
43
|
couponNamePrefix?: string | undefined;
|
|
44
44
|
percentage?: number | undefined;
|
|
45
45
|
} | undefined;
|
|
46
|
+
notificationTemplates?: Partial<Record<import("@lyxa.ai/core/dist/utilities/enum").TournamentNotificationTag, {
|
|
47
|
+
title: string;
|
|
48
|
+
body: string;
|
|
49
|
+
}>> | undefined;
|
|
50
|
+
scheduledNotifications?: {
|
|
51
|
+
type: import("@lyxa.ai/core/dist/utilities/enum").TournamentNotificationTag;
|
|
52
|
+
durationMins: number;
|
|
53
|
+
target: import("@lyxa.ai/core/dist/utilities/enum").TournamentScheduledNotificationTarget;
|
|
54
|
+
}[] | undefined;
|
|
46
55
|
} | {
|
|
47
56
|
documents: {
|
|
48
57
|
status: import("@lyxa.ai/core/dist/utilities/enum").Status;
|
|
@@ -61,6 +70,15 @@ export declare const teamRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
61
70
|
couponNamePrefix?: string | undefined;
|
|
62
71
|
percentage?: number | undefined;
|
|
63
72
|
} | undefined;
|
|
73
|
+
notificationTemplates?: Partial<Record<import("@lyxa.ai/core/dist/utilities/enum").TournamentNotificationTag, {
|
|
74
|
+
title: string;
|
|
75
|
+
body: string;
|
|
76
|
+
}>> | undefined;
|
|
77
|
+
scheduledNotifications?: {
|
|
78
|
+
type: import("@lyxa.ai/core/dist/utilities/enum").TournamentNotificationTag;
|
|
79
|
+
durationMins: number;
|
|
80
|
+
target: import("@lyxa.ai/core/dist/utilities/enum").TournamentScheduledNotificationTarget;
|
|
81
|
+
}[] | undefined;
|
|
64
82
|
}[];
|
|
65
83
|
metadata?: {
|
|
66
84
|
page: number;
|
|
@@ -74,7 +92,7 @@ export declare const teamRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
74
92
|
}>;
|
|
75
93
|
getAll: import("@trpc/server").TRPCQueryProcedure<{
|
|
76
94
|
input: {
|
|
77
|
-
tournamentId
|
|
95
|
+
tournamentId?: string | mongoose.Types.ObjectId | undefined;
|
|
78
96
|
};
|
|
79
97
|
output: {
|
|
80
98
|
message: string;
|
|
@@ -116,7 +134,7 @@ export declare const teamRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
116
134
|
getMatches: import("@trpc/server").TRPCQueryProcedure<{
|
|
117
135
|
input: {
|
|
118
136
|
tournamentId: string | mongoose.Types.ObjectId;
|
|
119
|
-
filter?: import("
|
|
137
|
+
filter?: import("@lyxa.ai/core/dist/utilities/enum").TournamentMatchStatus | undefined;
|
|
120
138
|
};
|
|
121
139
|
output: {
|
|
122
140
|
message: string;
|
|
@@ -142,7 +160,7 @@ export declare const teamRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
142
160
|
team2: number | null;
|
|
143
161
|
};
|
|
144
162
|
stage: string;
|
|
145
|
-
matchStatus: import("
|
|
163
|
+
matchStatus: import("@lyxa.ai/core/dist/utilities/enum").TournamentMatchStatus;
|
|
146
164
|
prediction: {
|
|
147
165
|
score: {
|
|
148
166
|
team1: number | null;
|
|
@@ -180,7 +198,7 @@ export declare const teamRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
180
198
|
team2: number | null;
|
|
181
199
|
};
|
|
182
200
|
stage: string;
|
|
183
|
-
matchStatus: import("
|
|
201
|
+
matchStatus: import("@lyxa.ai/core/dist/utilities/enum").TournamentMatchStatus;
|
|
184
202
|
prediction: {
|
|
185
203
|
score: {
|
|
186
204
|
team1: number | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"team.router.d.ts","sourceRoot":"/","sources":["modules/tournament/team/team.router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAgBhD,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"team.router.d.ts","sourceRoot":"/","sources":["modules/tournament/team/team.router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAgBhD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BrB,CAAC"}
|
|
@@ -22,7 +22,7 @@ exports.teamRouter = (0, trpc_1.createTRPCRouter)({
|
|
|
22
22
|
.input(team_validation_1.GetTournamentTeamsSchema)
|
|
23
23
|
.output(team_validation_1.TournamentWithTeamsResponseSchema)
|
|
24
24
|
.query(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
25
|
-
const result = await team_service_1.teamService.getAll(input.tournamentId);
|
|
25
|
+
const result = await team_service_1.teamService.getAll(input.tournamentId ?? undefined);
|
|
26
26
|
return (0, response_1.response)('Teams fetched successfully', result);
|
|
27
27
|
})),
|
|
28
28
|
getMatches: (0, auth_2.createAuthenticatedProcedure)({ entityTypes: [auth_1.AuthEntityType.USER] })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"team.router.js","sourceRoot":"/","sources":["modules/tournament/team/team.router.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAChD,4DAAsF;AACtF,4DAAmE;AACnE,6EAAkG;AAClG,8EAA0E;AAC1E,oEAAiE;AACjE,iDAAwD;AACxD,uDAM2B;AAC3B,mEAA6E;AAEhE,QAAA,UAAU,GAAG,IAAA,uBAAgB,EAAC;IAC1C,GAAG,EAAE,IAAA,mCAA4B,EAAC,EAAE,WAAW,EAAE,CAA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,MAAM,0BAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACxC,OAAO,IAAA,mBAAQ,EAAC,0BAA0B,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC,CAAC,CACF;IAEF,MAAM,EAAE,sBAAe;SACrB,KAAK,CAAC,0CAAwB,CAAC;SAC/B,MAAM,CAAC,mDAAiC,CAAC;SACzC,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAC1B,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,MAAM,GAAG,MAAM,0BAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,IAAI,SAAS,CAAC,CAAC;QACrE,OAAO,IAAA,mBAAQ,EAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC,CAAC,CACF;IAEF,UAAU,EAAE,IAAA,mCAA4B,EAAC,EAAE,WAAW,EAAE,CAAC,qBAAc,CAAC,IAAI,CAAC,EAAE,CAAC;SAC9E,KAAK,CAAC,sCAAoB,CAAC;SAC3B,MAAM,CAAC,qDAAmC,CAAC;SAC3C,KAAK,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAC/B,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,MAAM,GAAG,MAAM,0BAAO,CAAC,UAAU,CAAC,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QAC5F,OAAO,IAAA,mBAAQ,EAAC,mCAAmC,EAAE,MAAM,CAAC,CAAC;IAC9D,CAAC,CAAC,CACF;CACF,CAAC,CAAC","sourcesContent":["import { mongoose } from '@typegoose/typegoose';\nimport { createTRPCRouter, publicProcedure } 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 { teamService as service } from './team.service';\nimport {\n\tAddTournamentTeamsSchema,\n\tGetTeamMatchesSchema,\n\tGetTournamentTeamsSchema,\n\tTournamentWithTeamsResponseSchema,\n\tTournamentWithMatchesResponseSchema,\n} from './team.validation';\nimport { TournamentConfigResponseSchema } from '../config/config.validation';\n\nexport const teamRouter = createTRPCRouter({\n\tadd: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n\t\t.input(AddTournamentTeamsSchema)\n\t\t.output(TournamentConfigResponseSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.add(input);\n\t\t\t\treturn response('Teams added successfully', result);\n\t\t\t})\n\t\t),\n\n\tgetAll: publicProcedure\n\t\t.input(GetTournamentTeamsSchema)\n\t\t.output(TournamentWithTeamsResponseSchema)\n\t\t.query(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.getAll(input.tournamentId ?? undefined);\n\t\t\t\treturn response('Teams fetched successfully', result);\n\t\t\t})\n\t\t),\n\n\tgetMatches: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.USER] })\n\t\t.input(GetTeamMatchesSchema)\n\t\t.output(TournamentWithMatchesResponseSchema)\n\t\t.query(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst result = await service.getMatches(new mongoose.Types.ObjectId(ctx.entity?.id), input);\n\t\t\t\treturn response('Team matches fetched successfully', result);\n\t\t\t})\n\t\t),\n});\n"]}
|
|
@@ -9,8 +9,9 @@ export declare class TeamService {
|
|
|
9
9
|
private getMatchStatus;
|
|
10
10
|
private applyStatusFilter;
|
|
11
11
|
add(input: AddTournamentTeamsInputDTO): Promise<TournamentConfigOutputDTO>;
|
|
12
|
-
getAll(tournamentId
|
|
12
|
+
getAll(tournamentId?: mongoose.Types.ObjectId): Promise<TournamentWithTeamsOutputDTO>;
|
|
13
13
|
getMatches(userId: mongoose.Types.ObjectId, input: GetTeamMatchesInputDTO): Promise<TournamentWithMatchesOutputDTO>;
|
|
14
|
+
private enrichMatch;
|
|
14
15
|
}
|
|
15
16
|
export declare const teamService: TeamService;
|
|
16
17
|
//# sourceMappingURL=team.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"team.service.d.ts","sourceRoot":"/","sources":["modules/tournament/team/team.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EACH,0BAA0B,EAC1B,sBAAsB,EAEtB,8BAA8B,EAC9B,4BAA4B,EAC/B,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"team.service.d.ts","sourceRoot":"/","sources":["modules/tournament/team/team.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EACH,0BAA0B,EAC1B,sBAAsB,EAEtB,8BAA8B,EAC9B,4BAA4B,EAC/B,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAMxE,qBACa,WAAW;IACpB,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,kBAAkB,CAAqB;;IAO/C,OAAO,CAAC,mBAAmB;IAM3B,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,iBAAiB;IAYZ,GAAG,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAU1E,MAAM,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,4BAA4B,CAAC;IAgBrF,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,8BAA8B,CAAC;IA2BhI,OAAO,CAAC,WAAW;CAkBtB;AAED,eAAO,MAAM,WAAW,aAA6B,CAAC"}
|
|
@@ -50,7 +50,7 @@ const team_repository_1 = require("./team.repository");
|
|
|
50
50
|
const participant_service_1 = require("../participant/participant.service");
|
|
51
51
|
const team_builder_1 = require("./team.builder");
|
|
52
52
|
const tournament_utils_1 = require("../tournament.utils");
|
|
53
|
-
const
|
|
53
|
+
const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
|
|
54
54
|
let TeamService = class TeamService {
|
|
55
55
|
repository;
|
|
56
56
|
participantService;
|
|
@@ -63,10 +63,10 @@ let TeamService = class TeamService {
|
|
|
63
63
|
}
|
|
64
64
|
getMatchStatus(match, now) {
|
|
65
65
|
if (match.endDate)
|
|
66
|
-
return
|
|
66
|
+
return enum_1.TournamentMatchStatus.ENDED;
|
|
67
67
|
if (match.startingDate && match.startingDate <= now)
|
|
68
|
-
return
|
|
69
|
-
return
|
|
68
|
+
return enum_1.TournamentMatchStatus.STARTED;
|
|
69
|
+
return enum_1.TournamentMatchStatus.UPCOMING;
|
|
70
70
|
}
|
|
71
71
|
applyStatusFilter(matches, now, filter) {
|
|
72
72
|
const filtered = filter
|
|
@@ -75,7 +75,7 @@ let TeamService = class TeamService {
|
|
|
75
75
|
return filtered.sort((a, b) => {
|
|
76
76
|
const aTime = a.startingDate ? new Date(a.startingDate).getTime() : 0;
|
|
77
77
|
const bTime = b.startingDate ? new Date(b.startingDate).getTime() : 0;
|
|
78
|
-
return filter ===
|
|
78
|
+
return filter === enum_1.TournamentMatchStatus.ENDED ? bTime - aTime : aTime - bTime;
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
async add(input) {
|
|
@@ -88,11 +88,13 @@ let TeamService = class TeamService {
|
|
|
88
88
|
return result;
|
|
89
89
|
}
|
|
90
90
|
async getAll(tournamentId) {
|
|
91
|
-
const tournament =
|
|
91
|
+
const tournament = tournamentId
|
|
92
|
+
? await this.repository.findById(tournamentId)
|
|
93
|
+
: await this.repository.findActive();
|
|
92
94
|
if (!tournament)
|
|
93
95
|
throw (0, error_common_1.notFoundError)('Tournament not found');
|
|
94
96
|
return {
|
|
95
|
-
tournamentId,
|
|
97
|
+
tournamentId: tournament._id,
|
|
96
98
|
tag: tournament.tag,
|
|
97
99
|
startDate: tournament.startDate,
|
|
98
100
|
endDate: tournament.endDate,
|
|
@@ -105,26 +107,14 @@ let TeamService = class TeamService {
|
|
|
105
107
|
const tournament = await this.repository.findById(input.tournamentId);
|
|
106
108
|
if (!tournament)
|
|
107
109
|
throw (0, error_common_1.notFoundError)('Tournament not found');
|
|
108
|
-
const teamPictureById = new Map(tournament.teams.map(t => [t._id.toString(), t.picture]));
|
|
109
|
-
const now = (0, tournament_utils_1.utcNow)();
|
|
110
110
|
if (!participant.teamId)
|
|
111
111
|
throw (0, error_common_1.badRequestError)('You have not joined this tournament');
|
|
112
|
+
const now = (0, tournament_utils_1.utcNow)();
|
|
112
113
|
const teamMatches = this.filterMatchesByTeam(tournament.matches, participant.teamId);
|
|
113
114
|
const filteredMatches = this.applyStatusFilter(teamMatches, now, input.filter);
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
return {
|
|
118
|
-
...match,
|
|
119
|
-
team1: { ...match.team1, picture: teamPictureById.get(match.team1.teamId.toString()) },
|
|
120
|
-
team2: { ...match.team2, picture: teamPictureById.get(match.team2.teamId.toString()) },
|
|
121
|
-
prediction: prediction
|
|
122
|
-
? { score: prediction.score, succeeded: prediction.succeeded ?? null }
|
|
123
|
-
: null,
|
|
124
|
-
canPredict: !match.startingDate || now < new Date(match.startingDate),
|
|
125
|
-
matchStatus: this.getMatchStatus(match, now),
|
|
126
|
-
};
|
|
127
|
-
});
|
|
115
|
+
const teamPictureById = team_builder_1.TeamBuilder.buildTeamPictureMap(tournament.teams);
|
|
116
|
+
const predictionsByMatchId = team_builder_1.TeamBuilder.buildPredictionMap(participant.predictions);
|
|
117
|
+
const matches = filteredMatches.map(match => this.enrichMatch(match, now, teamPictureById, predictionsByMatchId));
|
|
128
118
|
return {
|
|
129
119
|
tournamentId: input.tournamentId,
|
|
130
120
|
tag: tournament.tag,
|
|
@@ -134,6 +124,19 @@ let TeamService = class TeamService {
|
|
|
134
124
|
matches,
|
|
135
125
|
};
|
|
136
126
|
}
|
|
127
|
+
enrichMatch(match, now, teamPictureById, predictionsByMatchId) {
|
|
128
|
+
const prediction = predictionsByMatchId.get(match._id.toString());
|
|
129
|
+
return {
|
|
130
|
+
...match,
|
|
131
|
+
team1: { ...match.team1, picture: teamPictureById.get(match.team1.teamId.toString()) },
|
|
132
|
+
team2: { ...match.team2, picture: teamPictureById.get(match.team2.teamId.toString()) },
|
|
133
|
+
prediction: prediction
|
|
134
|
+
? { score: prediction.score, succeeded: prediction.succeeded ?? null }
|
|
135
|
+
: null,
|
|
136
|
+
canPredict: !match.startingDate || now < new Date(match.startingDate),
|
|
137
|
+
matchStatus: this.getMatchStatus(match, now),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
137
140
|
};
|
|
138
141
|
exports.TeamService = TeamService;
|
|
139
142
|
exports.TeamService = TeamService = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"team.service.js","sourceRoot":"/","sources":["modules/tournament/team/team.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAC5C,yCAAyC;AAEzC,4EAA2F;AAQ3F,uDAA6D;AAC7D,4EAAwE;AACxE,iDAA6C;AAG7C,0DAA2C;AAC3C,0DAAgD;AAGzC,IAAM,WAAW,GAAjB,MAAM,WAAW;IACZ,UAAU,CAA2B;IACrC,kBAAkB,CAAqB;IAE/C;QACI,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,0CAAwB,CAAC,CAAC;QAC1D,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EAAE,OAAO,EAAE,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE;gBACtF,KAAK,EAAE,EAAE,GAAG,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE;gBACtF,UAAU,EAAE,UAAU;oBAClB,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC,SAAS,IAAI,IAAI,EAAE;oBACtE,CAAC,CAAC,IAAI;gBACV,UAAU,EAAE,CAAC,KAAK,CAAC,YAAY,IAAI,GAAG,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC;gBACrE,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,GAAG,CAAC;aAC/C,CAAC;QACN,CAAC,CAAC,CAAC;QAEH,OAAO;YACH,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,GAAG,EAAE,UAAU,CAAC,GAAG;YACnB,SAAS,EAAE,UAAU,CAAC,SAAS;YAC/B,OAAO,EAAE,UAAU,CAAC,OAAO;YAC3B,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,OAAO;SACwB,CAAC;IACxC,CAAC;CACJ,CAAA;AAlGY,kCAAW;sBAAX,WAAW;IADvB,IAAA,gBAAO,GAAE;;GACG,WAAW,CAkGvB;AAEY,QAAA,WAAW,GAAG,gBAAS,CAAC,GAAG,CAAC,WAAW,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 {\n AddTournamentTeamsInputDTO,\n GetTeamMatchesInputDTO,\n TournamentTeamOutputDTO,\n TournamentWithMatchesOutputDTO,\n TournamentWithTeamsOutputDTO,\n} from './team.validation';\nimport { TournamentTeamRepository } from './team.repository';\nimport { ParticipantService } from '../participant/participant.service';\nimport { TeamBuilder } from './team.builder';\nimport { TournamentConfigOutputDTO } from '../config/config.validation';\nimport { TournamentMatchOutputDTO } from '../match/match.validation';\nimport {utcNow} from '../tournament.utils';\nimport {MatchStatus} from '../tournament.types';\n\n@Service()\nexport class TeamService {\n private repository: TournamentTeamRepository;\n private participantService: ParticipantService;\n\n constructor() {\n this.repository = Container.get(TournamentTeamRepository);\n this.participantService = Container.get(ParticipantService);\n }\n\n private filterMatchesByTeam(matches: TournamentMatchOutputDTO[], teamId: mongoose.Types.ObjectId): TournamentMatchOutputDTO[] {\n return matches.filter(match =>\n [match.team1.teamId.toString(), match.team2.teamId.toString()].includes(teamId.toString())\n );\n }\n\n private getMatchStatus(match: TournamentMatchOutputDTO, now: Date): MatchStatus {\n if (match.endDate) return MatchStatus.ENDED;\n if (match.startingDate && match.startingDate <= now) return MatchStatus.STARTED;\n return MatchStatus.UPCOMING;\n }\n\n private applyStatusFilter(matches: TournamentMatchOutputDTO[], now: Date, filter?: MatchStatus): TournamentMatchOutputDTO[] {\n const filtered = filter\n ? matches.filter(match => this.getMatchStatus(match, now) === filter)\n : matches;\n\n return filtered.sort((a, b) => {\n const aTime = a.startingDate ? new Date(a.startingDate).getTime() : 0;\n const bTime = b.startingDate ? new Date(b.startingDate).getTime() : 0;\n return filter === MatchStatus.ENDED ? bTime - aTime : aTime - bTime;\n });\n }\n\n public async add(input: AddTournamentTeamsInputDTO): Promise<TournamentConfigOutputDTO> {\n const tournament = await this.repository.findById(input.tournamentId);\n if (!tournament) throw notFoundError('Tournament not found');\n\n const result = await this.repository.addTeams(input.tournamentId, TeamBuilder.buildTeams(input.teams));\n if (!result) throw new TRPCError({ code: 'INTERNAL_SERVER_ERROR', message: 'Failed to add teams' });\n\n return result as TournamentConfigOutputDTO;\n }\n\n public async getAll(tournamentId: mongoose.Types.ObjectId): Promise<TournamentWithTeamsOutputDTO> {\n const tournament = await this.repository.findById(tournamentId);\n if (!tournament) throw notFoundError('Tournament not found');\n\n return {\n tournamentId,\n tag: tournament.tag,\n startDate: tournament.startDate,\n endDate: tournament.endDate,\n status: tournament.status,\n teams: tournament.teams as TournamentTeamOutputDTO[],\n } as TournamentWithTeamsOutputDTO;\n }\n\n public async getMatches(userId: mongoose.Types.ObjectId, input: GetTeamMatchesInputDTO): Promise<TournamentWithMatchesOutputDTO> {\n const participant = await this.participantService.getByUserAndTournament(userId, input.tournamentId);\n const tournament = await this.repository.findById(input.tournamentId);\n if (!tournament) throw notFoundError('Tournament not found');\n\n const teamPictureById = new Map(\n (tournament.teams as TournamentTeamOutputDTO[]).map(t => [t._id.toString(), t.picture])\n );\n\n const now = utcNow();\n if (!participant.teamId) throw badRequestError('You have not joined this tournament');\n const teamMatches = this.filterMatchesByTeam(tournament.matches as TournamentMatchOutputDTO[], participant.teamId);\n const filteredMatches = this.applyStatusFilter(teamMatches, now, input.filter);\n\n const predictionsByMatchId = new Map(\n participant.predictions.map(p => [p.matchId.toString(), p])\n );\n\n const matches = filteredMatches.map(match => {\n const prediction = predictionsByMatchId.get(match._id.toString());\n return {\n ...match,\n team1: { ...match.team1, picture: teamPictureById.get(match.team1.teamId.toString()) },\n team2: { ...match.team2, picture: teamPictureById.get(match.team2.teamId.toString()) },\n prediction: prediction\n ? { score: prediction.score, succeeded: prediction.succeeded ?? null }\n : null,\n canPredict: !match.startingDate || now < new Date(match.startingDate),\n matchStatus: this.getMatchStatus(match, now),\n };\n });\n\n return {\n tournamentId: input.tournamentId,\n tag: tournament.tag,\n startDate: tournament.startDate,\n endDate: tournament.endDate,\n status: tournament.status,\n matches,\n } as TournamentWithMatchesOutputDTO;\n }\n}\n\nexport const teamService = Container.get(TeamService);\n"]}
|
|
1
|
+
{"version":3,"file":"team.service.js","sourceRoot":"/","sources":["modules/tournament/team/team.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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X,WAAW;IADvB,IAAA,gBAAO,GAAE;;GACG,WAAW,CAwGvB;AAEY,QAAA,WAAW,GAAG,gBAAS,CAAC,GAAG,CAAC,WAAW,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 {\n AddTournamentTeamsInputDTO,\n GetTeamMatchesInputDTO,\n TournamentTeamOutputDTO,\n TournamentWithMatchesOutputDTO,\n TournamentWithTeamsOutputDTO,\n} from './team.validation';\nimport { TournamentTeamRepository } from './team.repository';\nimport { ParticipantService } from '../participant/participant.service';\n\nimport { TeamBuilder } from './team.builder';\nimport { TournamentConfigOutputDTO } from '../config/config.validation';\nimport { TournamentMatchOutputDTO } from '../match/match.validation';\nimport { TournamentParticipantOutputDTO } from '../participant/participant.validation';\nimport {utcNow} from '../tournament.utils';\nimport {TournamentMatchStatus} from '@lyxa.ai/core/dist/utilities/enum';\n\n@Service()\nexport class TeamService {\n private repository: TournamentTeamRepository;\n private participantService: ParticipantService;\n\n constructor() {\n this.repository = Container.get(TournamentTeamRepository);\n this.participantService = Container.get(ParticipantService);\n }\n\n private filterMatchesByTeam(matches: TournamentMatchOutputDTO[], teamId: mongoose.Types.ObjectId): TournamentMatchOutputDTO[] {\n return matches.filter(match =>\n [match.team1.teamId.toString(), match.team2.teamId.toString()].includes(teamId.toString())\n );\n }\n\n private getMatchStatus(match: TournamentMatchOutputDTO, now: Date): TournamentMatchStatus {\n if (match.endDate) return TournamentMatchStatus.ENDED;\n if (match.startingDate && match.startingDate <= now) return TournamentMatchStatus.STARTED;\n return TournamentMatchStatus.UPCOMING;\n }\n\n private applyStatusFilter(matches: TournamentMatchOutputDTO[], now: Date, filter?: TournamentMatchStatus): TournamentMatchOutputDTO[] {\n const filtered = filter\n ? matches.filter(match => this.getMatchStatus(match, now) === filter)\n : matches;\n\n return filtered.sort((a, b) => {\n const aTime = a.startingDate ? new Date(a.startingDate).getTime() : 0;\n const bTime = b.startingDate ? new Date(b.startingDate).getTime() : 0;\n return filter === TournamentMatchStatus.ENDED ? bTime - aTime : aTime - bTime;\n });\n }\n\n public async add(input: AddTournamentTeamsInputDTO): Promise<TournamentConfigOutputDTO> {\n const tournament = await this.repository.findById(input.tournamentId);\n if (!tournament) throw notFoundError('Tournament not found');\n\n const result = await this.repository.addTeams(input.tournamentId, TeamBuilder.buildTeams(input.teams));\n if (!result) throw new TRPCError({ code: 'INTERNAL_SERVER_ERROR', message: 'Failed to add teams' });\n\n return result as TournamentConfigOutputDTO;\n }\n\n public async getAll(tournamentId?: mongoose.Types.ObjectId): Promise<TournamentWithTeamsOutputDTO> {\n const tournament = tournamentId\n ? await this.repository.findById(tournamentId)\n : await this.repository.findActive();\n if (!tournament) throw notFoundError('Tournament not found');\n\n return {\n tournamentId: (tournament as unknown as { _id: mongoose.Types.ObjectId })._id,\n tag: tournament.tag,\n startDate: tournament.startDate,\n endDate: tournament.endDate,\n status: tournament.status,\n teams: tournament.teams as TournamentTeamOutputDTO[],\n } as TournamentWithTeamsOutputDTO;\n }\n\n public async getMatches(userId: mongoose.Types.ObjectId, input: GetTeamMatchesInputDTO): Promise<TournamentWithMatchesOutputDTO> {\n const participant = await this.participantService.getByUserAndTournament(userId, input.tournamentId);\n const tournament = await this.repository.findById(input.tournamentId);\n if (!tournament) throw notFoundError('Tournament not found');\n if (!participant.teamId) throw badRequestError('You have not joined this tournament');\n\n const now = utcNow();\n const teamMatches = this.filterMatchesByTeam(tournament.matches as TournamentMatchOutputDTO[], participant.teamId);\n const filteredMatches = this.applyStatusFilter(teamMatches, now, input.filter);\n\n const teamPictureById = TeamBuilder.buildTeamPictureMap(tournament.teams as TournamentTeamOutputDTO[]);\n const predictionsByMatchId = TeamBuilder.buildPredictionMap(participant.predictions);\n\n const matches = filteredMatches.map(match =>\n this.enrichMatch(match, now, teamPictureById, predictionsByMatchId)\n );\n\n return {\n tournamentId: input.tournamentId,\n tag: tournament.tag,\n startDate: tournament.startDate,\n endDate: tournament.endDate,\n status: tournament.status,\n matches,\n } as TournamentWithMatchesOutputDTO;\n }\n\n private enrichMatch(\n match: TournamentMatchOutputDTO,\n now: Date,\n teamPictureById: Map<string, string | undefined>,\n predictionsByMatchId: Map<string, TournamentParticipantOutputDTO['predictions'][number]>\n ) {\n const prediction = predictionsByMatchId.get(match._id.toString());\n return {\n ...match,\n team1: { ...match.team1, picture: teamPictureById.get(match.team1.teamId.toString()) },\n team2: { ...match.team2, picture: teamPictureById.get(match.team2.teamId.toString()) },\n prediction: prediction\n ? { score: prediction.score, succeeded: prediction.succeeded ?? null }\n : null,\n canPredict: !match.startingDate || now < new Date(match.startingDate),\n matchStatus: this.getMatchStatus(match, now),\n };\n }\n}\n\nexport const teamService = Container.get(TeamService);\n"]}
|