@lyxa.ai/marketing 1.0.52 → 1.0.53
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 +307 -61
- 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.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.js +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.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 +16 -3
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js.map +1 -1
- package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts +1117 -285
- package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/all-coupons.validation.js +16 -2
- package/dist/lib/modules/coupon/validations/all-coupons.validation.js.map +1 -1
- package/dist/lib/modules/coupon/validations/index.d.ts +0 -1
- package/dist/lib/modules/coupon/validations/index.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/index.js +0 -1
- package/dist/lib/modules/coupon/validations/index.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts +32 -32
- 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 +19 -6
- 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 +96 -50
- 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 +18 -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 +78 -0
- package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js.map +1 -0
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +12 -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 +68 -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 +22 -18
- 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 +88 -83
- 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 +10 -1
- 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 +68 -22
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.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/{notification/notification.scheduler.service.js → sync/sync.repository.js} +22 -28
- 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 +307 -61
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/coupon/routers/coupon.router.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/all-coupons.validation.d.ts +1117 -285
- package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/index.d.ts +0 -1
- package/dist/types/modules/coupon/validations/index.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts +34 -32
- 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 +19 -6
- 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 +96 -50
- 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 +23 -0
- package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -0
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +12 -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 +22 -18
- 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 +88 -83
- 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 +20 -1
- package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.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 +3 -3
- 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
|
@@ -62,10 +62,11 @@ let MatchService = class MatchService {
|
|
|
62
62
|
return tournament;
|
|
63
63
|
}
|
|
64
64
|
getMatch(tournament, matchId) {
|
|
65
|
-
const
|
|
65
|
+
const matchIndex = tournament.matches.findIndex(m => m._id.toString() === matchId.toString());
|
|
66
|
+
const match = tournament.matches[matchIndex];
|
|
66
67
|
if (!match)
|
|
67
68
|
throw (0, error_common_1.notFoundError)('Match not found');
|
|
68
|
-
return match;
|
|
69
|
+
return { ...match, matchNumber: matchIndex + 1 };
|
|
69
70
|
}
|
|
70
71
|
resolveMatchTeams(tournament, team1Id, team2Id) {
|
|
71
72
|
const teamsById = new Map(tournament.teams.map(team => [team._id.toString(), team]));
|
|
@@ -115,18 +116,20 @@ let MatchService = class MatchService {
|
|
|
115
116
|
throw (0, error_common_1.badRequestError)('This match has not started yet');
|
|
116
117
|
if (match.endDate)
|
|
117
118
|
throw (0, error_common_1.badRequestError)('This match has already ended');
|
|
118
|
-
const
|
|
119
|
-
const ended = await this.applyMatchUpdate(input.tournamentId, input.matchId,
|
|
120
|
-
|
|
121
|
-
if (team1 !== null && team1 !== undefined && team2 !== null && team2 !== undefined) {
|
|
122
|
-
await (0, event_1.publishEvent)(new evaluate_predictions_event_1.EvaluatePredictionsEvent({
|
|
123
|
-
tournamentId: input.tournamentId,
|
|
124
|
-
matchId: input.matchId,
|
|
125
|
-
finalScore: { team1, team2 },
|
|
126
|
-
}));
|
|
127
|
-
}
|
|
119
|
+
const { update, evaluation } = match_builder_1.MatchBuilder.buildEnd(match, match.matchNumber, input.finalScore);
|
|
120
|
+
const ended = await this.applyMatchUpdate(input.tournamentId, input.matchId, update);
|
|
121
|
+
await this.publishEvaluations(input.tournamentId, [evaluation]);
|
|
128
122
|
return ended;
|
|
129
123
|
}
|
|
124
|
+
async publishEvaluations(tournamentId, evaluations) {
|
|
125
|
+
const matches = evaluations.filter((evaluation) => evaluation !== null);
|
|
126
|
+
if (!matches.length)
|
|
127
|
+
return;
|
|
128
|
+
await (0, event_1.publishEvent)(new evaluate_predictions_event_1.EvaluatePredictionsEvent({ tournamentId, matches }));
|
|
129
|
+
}
|
|
130
|
+
getMatchNumber(_id) {
|
|
131
|
+
throw new Error('Method not implemented.');
|
|
132
|
+
}
|
|
130
133
|
async delete(tournamentId, matchId) {
|
|
131
134
|
const result = await this.repository.deleteMatch(tournamentId, matchId);
|
|
132
135
|
if (!result)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"match.service.js","sourceRoot":"/","sources":["modules/tournament/match/match.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,4EAAyF;AACzF,8DAAgE;AAOhE,yDAA6D;AAC7D,mDAA6C;AAG7C,oFAA6E;AAC7E,0DAA2C;AAGpC,IAAM,YAAY,GAAlB,MAAM,YAAY;IACb,UAAU,CAA4B;IAE9C;QACI,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,4CAAyB,CAAC,CAAC;IAC/D,CAAC;IAEO,KAAK,CAAC,aAAa,CAAC,YAAqC;QAC7D,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAChE,IAAI,CAAC,UAAU;YAAE,MAAM,IAAA,4BAAa,EAAC,sBAAsB,CAAC,CAAC;QAC7D,OAAO,UAAU,CAAC;IACtB,CAAC;IAEO,QAAQ,CAAC,UAAiD,EAAE,OAAgC;QAChG,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAA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AK,CAAC,MAAM,CAAC,YAAqC,EAAE,OAAgC;QACvF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACxE,IAAI,CAAC,MAAM;YAAE,MAAM,IAAA,4BAAa,EAAC,sBAAsB,CAAC,CAAC;QAEzD,OAAO,MAAmC,CAAC;IAC/C,CAAC;CACJ,CAAA;AA/FY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,gBAAO,GAAE;;GACG,YAAY,CA+FxB;AAEY,QAAA,YAAY,GAAG,gBAAS,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {badRequestError, notFoundError} from '@lyxa.ai/core/dist/utilities/error-common';\nimport {publishEvent} from '@lyxa.ai/core/dist/libraries/event';\nimport {\n AddTournamentMatchesInputDTO,\n EndTournamentMatchInputDTO,\n StartTournamentMatchInputDTO,\n TournamentMatchOutputDTO,\n} from './match.validation';\nimport {TournamentMatchRepository} from './match.repository';\nimport {MatchBuilder} from './match.builder';\nimport {TournamentConfigOutputDTO} from '../config/config.validation';\nimport {Tournament as TournamentType} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {EvaluatePredictionsEvent} from './events/evaluate-predictions.event';\nimport {utcNow} from '../tournament.utils';\n\n@Service()\nexport class MatchService {\n private repository: TournamentMatchRepository;\n\n constructor() {\n this.repository = Container.get(TournamentMatchRepository);\n }\n\n private async getTournament(tournamentId: mongoose.Types.ObjectId) {\n const tournament = await this.repository.findById(tournamentId);\n if (!tournament) throw notFoundError('Tournament not found');\n return tournament;\n }\n\n private getMatch(tournament: {matches: TournamentMatchOutputDTO[]}, matchId: mongoose.Types.ObjectId) {\n const match = tournament.matches.find(m => m._id.toString() === matchId.toString());\n if (!match) throw notFoundError('Match not found');\n return match;\n }\n\n private resolveMatchTeams(tournament: TournamentType, team1Id: mongoose.Types.ObjectId, team2Id: mongoose.Types.ObjectId) {\n const teamsById = new Map(tournament.teams.map(team => [team._id.toString(), team]));\n const team1 = teamsById.get(team1Id.toString());\n const team2 = teamsById.get(team2Id.toString());\n if (!team1 || !team2) throw badRequestError('All match teams must exist in the tournament');\n return {team1, team2};\n }\n\n private async applyMatchUpdate(\n tournamentId: mongoose.Types.ObjectId,\n matchId: mongoose.Types.ObjectId,\n updates: Record<string, unknown>\n ): Promise<TournamentMatchOutputDTO> {\n const result = await this.repository.updateMatch(tournamentId, matchId, updates);\n if (!result) throw notFoundError('Tournament not found');\n const updated = result.matches.find(m => m._id.toString() === matchId.toString());\n if (!updated) throw notFoundError('Match not found');\n return updated as TournamentMatchOutputDTO;\n }\n\n public async add(input: AddTournamentMatchesInputDTO): Promise<TournamentConfigOutputDTO> {\n const tournament = await this.getTournament(input.tournamentId);\n\n const matches = input.matches.map(match => {\n const {team1, team2} = this.resolveMatchTeams(tournament, match.team1Id, match.team2Id);\n return MatchBuilder.buildMatch(match, team1, team2);\n });\n\n const result = await this.repository.addMatches(input.tournamentId, matches);\n if (!result) throw notFoundError('Tournament not found');\n\n return result as TournamentConfigOutputDTO;\n }\n\n public async getAll(tournamentId: mongoose.Types.ObjectId): Promise<TournamentMatchOutputDTO[]> {\n const tournament = await this.getTournament(tournamentId);\n return tournament.matches as TournamentMatchOutputDTO[];\n }\n\n public async start(input: StartTournamentMatchInputDTO): Promise<TournamentMatchOutputDTO> {\n const tournament = await this.getTournament(input.tournamentId);\n const match = this.getMatch(tournament, input.matchId);\n\n if (!match.startingDate || match.startingDate > utcNow()) throw badRequestError('This match has not started yet');\n if (match.endDate) throw badRequestError('This match has already ended');\n return match;\n }\n\n public async end(input: EndTournamentMatchInputDTO): Promise<TournamentMatchOutputDTO> {\n const tournament = await this.getTournament(input.tournamentId);\n const match = this.getMatch(tournament, input.matchId);\n\n if (!match.startingDate || match.startingDate > utcNow()) throw badRequestError('This match has not started yet');\n if (match.endDate) throw badRequestError('This match has already ended');\n\n const matchUpdates = MatchBuilder.buildEndUpdate(match, input.finalScore)\n const ended = await this.applyMatchUpdate(input.tournamentId, input.matchId, matchUpdates);\n\n const {team1, team2} = ended.score;\n if (team1 !== null && team1 !== undefined && team2 !== null && team2 !== undefined) {\n await publishEvent(new EvaluatePredictionsEvent({\n tournamentId: input.tournamentId,\n matchId: input.matchId,\n finalScore: {team1, team2},\n }));\n }\n\n return ended;\n }\n\n public async delete(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<TournamentConfigOutputDTO> {\n const result = await this.repository.deleteMatch(tournamentId, matchId);\n if (!result) throw notFoundError('Tournament not found');\n\n return result as TournamentConfigOutputDTO;\n }\n}\n\nexport const matchService = Container.get(MatchService);\n"]}
|
|
1
|
+
{"version":3,"file":"match.service.js","sourceRoot":"/","sources":["modules/tournament/match/match.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,4EAAyF;AACzF,8DAAgE;AAOhE,yDAA6D;AAC7D,mDAA6C;AAG7C,oFAAuG;AACvG,0DAA2C;AAGpC,IAAM,YAAY,GAAlB,MAAM,YAAY;IACb,UAAU,CAA4B;IAE9C;QACI,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,4CAAyB,CAAC,CAAC;IAC/D,CAAC;IAEO,KAAK,CAAC,aAAa,CAAC,YAAqC;QAC7D,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAChE,IAAI,CAAC,UAAU;YAAE,MAAM,IAAA,4BAAa,EAAC,sBAAsB,CAAC,CAAC;QAC7D,OAAO,UAAU,CAAC;IACtB,CAAC;IAEO,QAAQ,CAAC,UAAiD,EAAE,OAAgC;QAChG,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,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,CAAC,OAAO,CAAC,MAAM;YAAE,OAAO;QAC5B,MAAM,IAAA,oBAAY,EAAC,IAAI,qDAAwB,CAAC,EAAC,YAAY,EAAE,OAAO,EAAC,CAAC,CAAC,CAAC;IAC9E,CAAC;IAED,cAAc,CAAC,GAA4B;QACvC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC/C,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,YAAqC,EAAE,OAAgC;QACvF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACxE,IAAI,CAAC,MAAM;YAAE,MAAM,IAAA,4BAAa,EAAC,sBAAsB,CAAC,CAAC;QAEzD,OAAO,MAAmC,CAAC;IAC/C,CAAC;CACJ,CAAA;AAtGY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,gBAAO,GAAE;;GACG,YAAY,CAsGxB;AAEY,QAAA,YAAY,GAAG,gBAAS,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {badRequestError, notFoundError} from '@lyxa.ai/core/dist/utilities/error-common';\nimport {publishEvent} from '@lyxa.ai/core/dist/libraries/event';\nimport {\n AddTournamentMatchesInputDTO,\n EndTournamentMatchInputDTO,\n StartTournamentMatchInputDTO,\n TournamentMatchOutputDTO,\n} from './match.validation';\nimport {TournamentMatchRepository} from './match.repository';\nimport {MatchBuilder} from './match.builder';\nimport {TournamentConfigOutputDTO} from '../config/config.validation';\nimport {Tournament as TournamentType} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {EvaluatePredictionsEvent, EvaluatePredictionsMatch} from './events/evaluate-predictions.event';\nimport {utcNow} from '../tournament.utils';\n\n@Service()\nexport class MatchService {\n private repository: TournamentMatchRepository;\n\n constructor() {\n this.repository = Container.get(TournamentMatchRepository);\n }\n\n private async getTournament(tournamentId: mongoose.Types.ObjectId) {\n const tournament = await this.repository.findById(tournamentId);\n if (!tournament) throw notFoundError('Tournament not found');\n return tournament;\n }\n\n private getMatch(tournament: {matches: TournamentMatchOutputDTO[]}, matchId: mongoose.Types.ObjectId) {\n const matchIndex = tournament.matches.findIndex(m => m._id.toString() === matchId.toString());\n const match = tournament.matches[matchIndex]\n if (!match) throw notFoundError('Match not found');\n return {...match, matchNumber: matchIndex + 1};\n }\n\n private resolveMatchTeams(tournament: TournamentType, team1Id: mongoose.Types.ObjectId, team2Id: mongoose.Types.ObjectId) {\n const teamsById = new Map(tournament.teams.map(team => [team._id.toString(), team]));\n const team1 = teamsById.get(team1Id.toString());\n const team2 = teamsById.get(team2Id.toString());\n if (!team1 || !team2) throw badRequestError('All match teams must exist in the tournament');\n return {team1, team2};\n }\n\n private async applyMatchUpdate<T extends object>(\n tournamentId: mongoose.Types.ObjectId,\n matchId: mongoose.Types.ObjectId,\n updates: T\n ): Promise<TournamentMatchOutputDTO> {\n const result = await this.repository.updateMatch(tournamentId, matchId, updates);\n if (!result) throw notFoundError('Tournament not found');\n const updated = result.matches.find(m => m._id.toString() === matchId.toString());\n if (!updated) throw notFoundError('Match not found');\n return updated as TournamentMatchOutputDTO;\n }\n\n public async add(input: AddTournamentMatchesInputDTO): Promise<TournamentConfigOutputDTO> {\n const tournament = await this.getTournament(input.tournamentId);\n\n const matches = input.matches.map(match => {\n const {team1, team2} = this.resolveMatchTeams(tournament, match.team1Id, match.team2Id);\n return MatchBuilder.buildMatch(match, team1, team2);\n });\n\n const result = await this.repository.addMatches(input.tournamentId, matches);\n if (!result) throw notFoundError('Tournament not found');\n\n return result as TournamentConfigOutputDTO;\n }\n\n public async getAll(tournamentId: mongoose.Types.ObjectId): Promise<TournamentMatchOutputDTO[]> {\n const tournament = await this.getTournament(tournamentId);\n return tournament.matches as TournamentMatchOutputDTO[];\n }\n\n public async start(input: StartTournamentMatchInputDTO): Promise<TournamentMatchOutputDTO> {\n const tournament = await this.getTournament(input.tournamentId);\n const match = this.getMatch(tournament, input.matchId);\n\n if (!match.startingDate || match.startingDate > utcNow()) throw badRequestError('This match has not started yet');\n if (match.endDate) throw badRequestError('This match has already ended');\n return match;\n }\n\n public async end(input: EndTournamentMatchInputDTO): Promise<TournamentMatchOutputDTO> {\n const tournament = await this.getTournament(input.tournamentId);\n const match = this.getMatch(tournament, input.matchId);\n\n if (!match.startingDate || match.startingDate > utcNow()) throw badRequestError('This match has not started yet');\n if (match.endDate) throw badRequestError('This match has already ended');\n\n const {update, evaluation} = MatchBuilder.buildEnd(match, match.matchNumber, input.finalScore);\n const ended = await this.applyMatchUpdate(input.tournamentId, input.matchId, update);\n\n await this.publishEvaluations(input.tournamentId, [evaluation]);\n\n return ended;\n }\n\n public async publishEvaluations(\n tournamentId: mongoose.Types.ObjectId,\n evaluations: Array<EvaluatePredictionsMatch | null>\n ): Promise<void> {\n const matches = evaluations.filter((evaluation): evaluation is EvaluatePredictionsMatch => evaluation !== null);\n if (!matches.length) return;\n await publishEvent(new EvaluatePredictionsEvent({tournamentId, matches}));\n }\n\n getMatchNumber(_id: mongoose.Types.ObjectId) {\n throw new Error('Method not implemented.');\n }\n\n public async delete(tournamentId: mongoose.Types.ObjectId, matchId: mongoose.Types.ObjectId): Promise<TournamentConfigOutputDTO> {\n const result = await this.repository.deleteMatch(tournamentId, matchId);\n if (!result) throw notFoundError('Tournament not found');\n\n return result as TournamentConfigOutputDTO;\n }\n}\n\nexport const matchService = Container.get(MatchService);\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { mongoose } from '@typegoose/typegoose';
|
|
2
|
+
import { TournamentMatchStatus } from '@lyxa.ai/core/dist/utilities/enum';
|
|
3
|
+
export interface MatchTeamRef {
|
|
4
|
+
_id: mongoose.Types.ObjectId;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
export interface MatchInput {
|
|
8
|
+
stage: string;
|
|
9
|
+
additionalTag?: string;
|
|
10
|
+
startingDate: Date;
|
|
11
|
+
endDate?: Date;
|
|
12
|
+
}
|
|
13
|
+
export interface MatchScore {
|
|
14
|
+
team1: number | null;
|
|
15
|
+
team2: number | null;
|
|
16
|
+
}
|
|
17
|
+
export interface BuiltMatch {
|
|
18
|
+
_id: mongoose.Types.ObjectId;
|
|
19
|
+
additionalTag?: string;
|
|
20
|
+
stage: string;
|
|
21
|
+
team1: {
|
|
22
|
+
teamId: mongoose.Types.ObjectId;
|
|
23
|
+
name: string;
|
|
24
|
+
};
|
|
25
|
+
team2: {
|
|
26
|
+
teamId: mongoose.Types.ObjectId;
|
|
27
|
+
name: string;
|
|
28
|
+
};
|
|
29
|
+
score: MatchScore;
|
|
30
|
+
winnerId: mongoose.Types.ObjectId | null;
|
|
31
|
+
startingDate: Date;
|
|
32
|
+
endDate?: Date;
|
|
33
|
+
}
|
|
34
|
+
export interface MatchScoreUpdate {
|
|
35
|
+
score: {
|
|
36
|
+
team1: number;
|
|
37
|
+
team2: number;
|
|
38
|
+
};
|
|
39
|
+
winnerId?: mongoose.Types.ObjectId;
|
|
40
|
+
}
|
|
41
|
+
export interface MatchEndUpdate {
|
|
42
|
+
endDate: Date;
|
|
43
|
+
matchEnded: true;
|
|
44
|
+
matchStatus: TournamentMatchStatus;
|
|
45
|
+
winnerId: mongoose.Types.ObjectId | null;
|
|
46
|
+
score?: {
|
|
47
|
+
team1: number;
|
|
48
|
+
team2: number;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=match.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match.types.d.ts","sourceRoot":"/","sources":["modules/tournament/match/match.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,qBAAqB,EAAC,MAAM,mCAAmC,CAAC;AAExE,MAAM,WAAW,YAAY;IACzB,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,I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AAK,CAAC,EAAE;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAAC;CAC1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match.types.js","sourceRoot":"/","sources":["modules/tournament/match/match.types.ts"],"names":[],"mappings":"","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\nimport {TournamentMatchStatus} from '@lyxa.ai/core/dist/utilities/enum';\n\nexport interface MatchTeamRef {\n _id: mongoose.Types.ObjectId;\n name: string;\n}\n\nexport interface MatchInput {\n stage: string;\n additionalTag?: string;\n startingDate: Date;\n endDate?: Date;\n}\n\nexport interface MatchScore {\n team1: number | null;\n team2: number | null;\n}\n\nexport interface BuiltMatch {\n _id: mongoose.Types.ObjectId;\n additionalTag?: string;\n stage: string;\n team1: {teamId: mongoose.Types.ObjectId; name: string};\n team2: {teamId: mongoose.Types.ObjectId; name: string};\n score: MatchScore;\n winnerId: mongoose.Types.ObjectId | null;\n startingDate: Date;\n endDate?: Date;\n}\n\nexport interface MatchScoreUpdate {\n score: {team1: number; team2: number};\n winnerId?: mongoose.Types.ObjectId;\n}\n\nexport interface MatchEndUpdate {\n endDate: Date;\n matchEnded: true;\n matchStatus: TournamentMatchStatus;\n winnerId: mongoose.Types.ObjectId | null;\n score?: {team1: number; team2: number};\n}\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { mongoose } from '@typegoose/typegoose';
|
|
2
2
|
import { NotificationMessage } from '@lyxa.ai/core/dist/libraries/mongo/models';
|
|
3
|
+
import { TournamentNotificationTag } from '@lyxa.ai/core/dist/utilities/enum';
|
|
3
4
|
export declare class NotificationTemplateRepository {
|
|
4
5
|
private model;
|
|
5
|
-
findTemplates(tournamentId: mongoose.Types.ObjectId): Promise<Map<
|
|
6
|
+
findTemplates(tournamentId: mongoose.Types.ObjectId): Promise<Map<TournamentNotificationTag, NotificationMessage>>;
|
|
6
7
|
}
|
|
7
8
|
export declare const notificationTemplateRepository: NotificationTemplateRepository;
|
|
8
9
|
//# sourceMappingURL=notification-template.repository.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-template.repository.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification-template.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAmB,MAAM,2CAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"notification-template.repository.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification-template.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAmB,MAAM,2CAA2C,CAAC;AACjG,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,qBACa,8BAA8B;IACvC,OAAO,CAAC,KAAK,CAAmB;IAEnB,aAAa,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAyB,EAAE,mBAAmB,CAAC,CAAC;CAOlI;AAED,eAAO,MAAM,8BAA8B,gCAAgD,CAAC"}
|
|
@@ -49,7 +49,8 @@ let NotificationTemplateRepository = class NotificationTemplateRepository {
|
|
|
49
49
|
if (!doc)
|
|
50
50
|
throw new Error(`Tournament not found: ${tournamentId}`);
|
|
51
51
|
const raw = doc.notificationTemplates;
|
|
52
|
-
|
|
52
|
+
const entries = Object.entries(raw ?? {});
|
|
53
|
+
return new Map(entries);
|
|
53
54
|
}
|
|
54
55
|
};
|
|
55
56
|
exports.NotificationTemplateRepository = NotificationTemplateRepository;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-template.repository.js","sourceRoot":"/","sources":["modules/tournament/notification/notification-template.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,sEAAiG;
|
|
1
|
+
{"version":3,"file":"notification-template.repository.js","sourceRoot":"/","sources":["modules/tournament/notification/notification-template.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,sEAAiG;AAI1F,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAC/B,KAAK,GAAG,wBAAe,CAAC;IAEzB,KAAK,CAAC,aAAa,CAAC,YAAqC;QAC5D,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,EAAE,EAAE,qBAAqB,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACzF,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,YAAY,EAAE,CAAC,CAAC;QACnE,MAAM,GAAG,GAAG,GAAG,CAAC,qBAA2F,CAAC;QAC5G,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,EAAE,CAAuD,CAAC;QAChG,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;CACJ,CAAA;AAVY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,gBAAO,GAAE;GACG,8BAA8B,CAU1C;AAEY,QAAA,8BAA8B,GAAG,gBAAS,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport { NotificationMessage, TournamentModel } from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport { TournamentNotificationTag } from '@lyxa.ai/core/dist/utilities/enum';\n\n@Service()\nexport class NotificationTemplateRepository {\n private model = TournamentModel;\n\n public async findTemplates(tournamentId: mongoose.Types.ObjectId): Promise<Map<TournamentNotificationTag, NotificationMessage>> {\n const doc = await this.model.findById(tournamentId, { notificationTemplates: 1 }).lean();\n if (!doc) throw new Error(`Tournament not found: ${tournamentId}`);\n const raw = doc.notificationTemplates as Record<TournamentNotificationTag, NotificationMessage> | undefined;\n const entries = Object.entries(raw ?? {}) as [TournamentNotificationTag, NotificationMessage][];\n return new Map(entries);\n }\n}\n\nexport const notificationTemplateRepository = Container.get(NotificationTemplateRepository);\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { mongoose } from '@typegoose/typegoose';
|
|
2
|
+
import { ClickType, NotificationAccountType } from '@lyxa.ai/core/dist/utilities/enum';
|
|
3
|
+
export interface NotificationBody {
|
|
4
|
+
title: string;
|
|
5
|
+
body: string;
|
|
6
|
+
}
|
|
7
|
+
export interface DirectNotificationPayload extends NotificationBody {
|
|
8
|
+
data: {
|
|
9
|
+
saveNotification: boolean;
|
|
10
|
+
accountType: NotificationAccountType;
|
|
11
|
+
recipientId: mongoose.Types.ObjectId;
|
|
12
|
+
isGlobal: boolean;
|
|
13
|
+
isClickable: boolean;
|
|
14
|
+
clickType: ClickType;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface GlobalNotificationPayload extends NotificationBody {
|
|
18
|
+
data: {
|
|
19
|
+
saveNotification: boolean;
|
|
20
|
+
accountType: NotificationAccountType;
|
|
21
|
+
isGlobal: boolean;
|
|
22
|
+
isClickable: boolean;
|
|
23
|
+
clickType: ClickType;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export declare class NotificationPayloadBuilder {
|
|
27
|
+
static buildGlobal(content: NotificationBody): GlobalNotificationPayload;
|
|
28
|
+
static buildForUser(content: NotificationBody, recipientId: mongoose.Types.ObjectId): DirectNotificationPayload;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=notification.builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.builder.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,SAAS,EAAE,uBAAuB,EAAC,MAAM,mCAAmC,CAAC;AAErF,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,yBAA0B,SAAQ,gBAAgB;IAC/D,IAAI,EAAE;QACF,gBAAgB,EAAE,OAAO,CAAC;QAC1B,WAAW,EAAE,uBAAuB,CAAC;QACrC,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;QACrC,QAAQ,EAAE,OAAO,CAAC;QAClB,WAAW,EAAE,OAAO,CAAC;QACrB,SAAS,EAAE,SAAS,CAAC;KACxB,CAAC;CACL;AAED,MAAM,WAAW,yBAA0B,SAAQ,gBAAgB;IAC/D,IAAI,EAAE;QACF,gBAAgB,EAAE,OAAO,CAAC;QAC1B,WAAW,EAAE,uBAAuB,CAAC;QACrC,QAAQ,EAAE,OAAO,CAAC;QAClB,WAAW,EAAE,OAAO,CAAC;QACrB,SAAS,EAAE,SAAS,CAAC;KACxB,CAAC;CACL;AAED,qBAAa,0BAA0B;IACnC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,yBAAyB;IAcxE,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,yBAAyB;CAclH"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationPayloadBuilder = void 0;
|
|
4
|
+
const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
|
|
5
|
+
class NotificationPayloadBuilder {
|
|
6
|
+
static buildGlobal(content) {
|
|
7
|
+
return {
|
|
8
|
+
title: content.title,
|
|
9
|
+
body: content.body,
|
|
10
|
+
data: {
|
|
11
|
+
saveNotification: true,
|
|
12
|
+
accountType: enum_1.NotificationAccountType.USER,
|
|
13
|
+
isGlobal: true,
|
|
14
|
+
isClickable: true,
|
|
15
|
+
clickType: enum_1.ClickType.CLICKABLE_FALLBACK,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
static buildForUser(content, recipientId) {
|
|
20
|
+
return {
|
|
21
|
+
title: content.title,
|
|
22
|
+
body: content.body,
|
|
23
|
+
data: {
|
|
24
|
+
saveNotification: true,
|
|
25
|
+
accountType: enum_1.NotificationAccountType.USER,
|
|
26
|
+
recipientId,
|
|
27
|
+
isGlobal: false,
|
|
28
|
+
isClickable: true,
|
|
29
|
+
clickType: enum_1.ClickType.CLICKABLE_FALLBACK,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.NotificationPayloadBuilder = NotificationPayloadBuilder;
|
|
35
|
+
//# sourceMappingURL=notification.builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.builder.js","sourceRoot":"/","sources":["modules/tournament/notification/notification.builder.ts"],"names":[],"mappings":";;;AACA,4DAAqF;AA4BrF,MAAa,0BAA0B;IACnC,MAAM,CAAC,WAAW,CAAC,OAAyB;QACxC,OAAO;YACH,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,IAAI,EAAE;gBACF,gBAAgB,EAAE,IAAI;gBACtB,WAAW,EAAE,8BAAuB,CAAC,IAAI;gBACzC,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,IAAI;gBACjB,SAAS,EAAE,gBAAS,CAAC,kBAAkB;aAC1C;SACJ,CAAC;IACN,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,OAAyB,EAAE,WAAoC;QAC/E,OAAO;YACH,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,IAAI,EAAE;gBACF,gBAAgB,EAAE,IAAI;gBACtB,WAAW,EAAE,8BAAuB,CAAC,IAAI;gBACzC,WAAW;gBACX,QAAQ,EAAE,KAAK;gBACf,WAAW,EAAE,IAAI;gBACjB,SAAS,EAAE,gBAAS,CAAC,kBAAkB;aAC1C;SACJ,CAAC;IACN,CAAC;CACJ;AA7BD,gEA6BC","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\nimport {ClickType, NotificationAccountType} from '@lyxa.ai/core/dist/utilities/enum';\n\nexport interface NotificationBody {\n title: string;\n body: string;\n}\n\nexport interface DirectNotificationPayload extends NotificationBody {\n data: {\n saveNotification: boolean;\n accountType: NotificationAccountType;\n recipientId: mongoose.Types.ObjectId;\n isGlobal: boolean;\n isClickable: boolean;\n clickType: ClickType;\n };\n}\n\nexport interface GlobalNotificationPayload extends NotificationBody {\n data: {\n saveNotification: boolean;\n accountType: NotificationAccountType;\n isGlobal: boolean;\n isClickable: boolean;\n clickType: ClickType;\n };\n}\n\nexport class NotificationPayloadBuilder {\n static buildGlobal(content: NotificationBody): GlobalNotificationPayload {\n return {\n title: content.title,\n body: content.body,\n data: {\n saveNotification: true,\n accountType: NotificationAccountType.USER,\n isGlobal: true,\n isClickable: true,\n clickType: ClickType.CLICKABLE_FALLBACK,\n },\n };\n }\n\n static buildForUser(content: NotificationBody, recipientId: mongoose.Types.ObjectId): DirectNotificationPayload {\n return {\n title: content.title,\n body: content.body,\n data: {\n saveNotification: true,\n accountType: NotificationAccountType.USER,\n recipientId,\n isGlobal: false,\n isClickable: true,\n clickType: ClickType.CLICKABLE_FALLBACK,\n },\n };\n }\n}\n"]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { TournamentNotificationTag } from "@lyxa.ai/core/dist/utilities/enum";
|
|
2
|
+
export type NotificationObject = {
|
|
3
|
+
title: string;
|
|
4
|
+
body: string;
|
|
5
|
+
tournamentNotificationType: TournamentNotificationTag;
|
|
6
|
+
tournamentId: string;
|
|
7
|
+
deepLinkRoute?: string;
|
|
8
|
+
matchId?: string;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
10
11
|
//# sourceMappingURL=notification.config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.config.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification.config.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"notification.config.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,MAAM,MAAM,kBAAkB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B,EAAE,yBAAyB,CAAC;IACtD,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB,CAAC"}
|
|
@@ -1,15 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ScheduledTarget = exports.NotificationTag = void 0;
|
|
4
|
-
var NotificationTag;
|
|
5
|
-
(function (NotificationTag) {
|
|
6
|
-
NotificationTag["TOURNAMENT_ACTIVATION"] = "tournament-activation";
|
|
7
|
-
NotificationTag["MATCH_RESULT_WINNER"] = "match-result-winner";
|
|
8
|
-
NotificationTag["MATCH_RESULT_LOSER"] = "match-result-loser";
|
|
9
|
-
})(NotificationTag || (exports.NotificationTag = NotificationTag = {}));
|
|
10
|
-
var ScheduledTarget;
|
|
11
|
-
(function (ScheduledTarget) {
|
|
12
|
-
ScheduledTarget["GLOBAL"] = "global";
|
|
13
|
-
ScheduledTarget["UNPREDICTED_PARTICIPANTS"] = "unpredicted-participants";
|
|
14
|
-
})(ScheduledTarget || (exports.ScheduledTarget = ScheduledTarget = {}));
|
|
15
3
|
//# sourceMappingURL=notification.config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.config.js","sourceRoot":"/","sources":["modules/tournament/notification/notification.config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notification.config.js","sourceRoot":"/","sources":["modules/tournament/notification/notification.config.ts"],"names":[],"mappings":"","sourcesContent":["import { TournamentNotificationTag } from \"@lyxa.ai/core/dist/utilities/enum\";\n\nexport type NotificationObject = {\n title: string;\n body: string;\n tournamentNotificationType: TournamentNotificationTag;\n tournamentId: string;\n deepLinkRoute?: string;\n matchId?: string;\n [key: string]: any; // For any additional data that might be needed in the future\n};"]}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { mongoose } from '@typegoose/typegoose';
|
|
2
|
+
import { TournamentNotificationTag, TournamentScheduledNotificationTarget } from '@lyxa.ai/core/dist/utilities/enum';
|
|
2
3
|
import { NotificationMessage } from '@lyxa.ai/core/dist/libraries/mongo/models';
|
|
4
|
+
import { NotificationObject } from './notification.config';
|
|
3
5
|
export declare class TournamentNotificationService {
|
|
4
6
|
private participantService;
|
|
5
7
|
constructor();
|
|
6
8
|
private getTemplate;
|
|
7
9
|
private hasNotPredicted;
|
|
8
|
-
notifyGlobal(
|
|
9
|
-
notifyUsers(
|
|
10
|
-
dispatchScheduledJob(type:
|
|
10
|
+
notifyGlobal(notification: NotificationObject): Promise<void>;
|
|
11
|
+
notifyUsers(notification: NotificationObject, userIds: mongoose.Types.ObjectId[]): Promise<void>;
|
|
12
|
+
dispatchScheduledJob(type: TournamentNotificationTag, target: TournamentScheduledNotificationTarget, templates: Map<TournamentNotificationTag, NotificationMessage>, tournamentId: mongoose.Types.ObjectId, teamIds: mongoose.Types.ObjectId[], matchId: mongoose.Types.ObjectId, matchStartTime: Date, deepLinkRoute?: string): Promise<void>;
|
|
11
13
|
}
|
|
12
14
|
export declare const tournamentNotificationService: TournamentNotificationService;
|
|
13
15
|
//# sourceMappingURL=notification.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.service.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"notification.service.d.ts","sourceRoot":"/","sources":["modules/tournament/notification/notification.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAG9C,OAAO,EAGH,yBAAyB,EACzB,qCAAqC,EACxC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAC,mBAAmB,EAAC,MAAM,2CAA2C,CAAC;AAG9E,OAAO,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAC;AAEzD,qBACa,6BAA6B;IACtC,OAAO,CAAC,kBAAkB,CAAqB;;IAM/C,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,eAAe;IAIV,YAAY,CAAC,YAAY,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB7D,WAAW,CAAC,YAAY,EAAE,kBAAkB,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBhG,oBAAoB,CAC7B,IAAI,EAAE,yBAAyB,EAC/B,MAAM,EAAE,qCAAqC,EAC7C,SAAS,EAAE,GAAG,CAAC,yBAAyB,EAAE,mBAAmB,CAAC,EAC9D,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,EAClC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAChC,cAAc,EAAE,IAAI,EACpB,aAAa,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,IAAI,CAAC;CAqBnB;AAED,eAAO,MAAM,6BAA6B,+BAA+C,CAAC"}
|
|
@@ -48,7 +48,6 @@ const event_1 = require("@lyxa.ai/core/dist/libraries/event");
|
|
|
48
48
|
const notification_1 = require("@lyxa.ai/core/dist/libraries/notification");
|
|
49
49
|
const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
|
|
50
50
|
const participant_service_1 = require("../participant/participant.service");
|
|
51
|
-
const notification_config_1 = require("./notification.config");
|
|
52
51
|
let TournamentNotificationService = class TournamentNotificationService {
|
|
53
52
|
participantService;
|
|
54
53
|
constructor() {
|
|
@@ -63,42 +62,51 @@ let TournamentNotificationService = class TournamentNotificationService {
|
|
|
63
62
|
hasNotPredicted(participant, matchId) {
|
|
64
63
|
return !participant.predictions.some(p => p.matchId.toString() === matchId.toString());
|
|
65
64
|
}
|
|
66
|
-
async notifyGlobal(
|
|
65
|
+
async notifyGlobal(notification) {
|
|
67
66
|
await (0, event_1.publishEvent)(new notification_1.NotificationGlobalEvent({
|
|
68
|
-
title,
|
|
69
|
-
body,
|
|
67
|
+
title: notification.title,
|
|
68
|
+
body: notification.body,
|
|
70
69
|
data: {
|
|
71
70
|
saveNotification: true,
|
|
72
71
|
accountType: enum_1.NotificationAccountType.USER,
|
|
73
72
|
isGlobal: true,
|
|
74
73
|
isClickable: true,
|
|
75
|
-
clickType: enum_1.ClickType.
|
|
74
|
+
clickType: enum_1.ClickType.CLICKABLE_TOURNAMENT,
|
|
75
|
+
...notification,
|
|
76
76
|
},
|
|
77
77
|
}));
|
|
78
78
|
}
|
|
79
|
-
async notifyUsers(
|
|
79
|
+
async notifyUsers(notification, userIds) {
|
|
80
80
|
await Promise.all(userIds.map(recipientId => (0, event_1.publishEvent)(new notification_1.NotificationEvent({
|
|
81
|
-
title,
|
|
82
|
-
body,
|
|
81
|
+
title: notification.title,
|
|
82
|
+
body: notification.body,
|
|
83
83
|
data: {
|
|
84
84
|
saveNotification: true,
|
|
85
85
|
accountType: enum_1.NotificationAccountType.USER,
|
|
86
86
|
recipientId,
|
|
87
87
|
isGlobal: false,
|
|
88
88
|
isClickable: true,
|
|
89
|
-
clickType: enum_1.ClickType.
|
|
89
|
+
clickType: enum_1.ClickType.CLICKABLE_TOURNAMENT,
|
|
90
|
+
...notification,
|
|
90
91
|
},
|
|
91
92
|
}))));
|
|
92
93
|
}
|
|
93
|
-
async dispatchScheduledJob(type, target, templates, tournamentId, matchId) {
|
|
94
|
+
async dispatchScheduledJob(type, target, templates, tournamentId, teamIds, matchId, matchStartTime, deepLinkRoute) {
|
|
94
95
|
const { title, body } = this.getTemplate(templates, type);
|
|
95
|
-
if (target ===
|
|
96
|
-
await this.notifyGlobal(title, body);
|
|
96
|
+
if (target === enum_1.TournamentScheduledNotificationTarget.GLOBAL) {
|
|
97
|
+
await this.notifyGlobal({ title, body, tournamentNotificationType: type, tournamentId: tournamentId.toString(), deepLinkRoute });
|
|
97
98
|
}
|
|
98
99
|
else {
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
const unpredicted = await this.participantService.getUnpredicted(tournamentId, teamIds, matchId);
|
|
101
|
+
await this.notifyUsers({
|
|
102
|
+
title,
|
|
103
|
+
body,
|
|
104
|
+
tournamentNotificationType: type,
|
|
105
|
+
predictionExpiryTime: matchStartTime,
|
|
106
|
+
matchId: matchId.toString(),
|
|
107
|
+
tournamentId: tournamentId.toString(),
|
|
108
|
+
deepLinkRoute,
|
|
109
|
+
}, unpredicted.map(p => p.userId));
|
|
102
110
|
}
|
|
103
111
|
}
|
|
104
112
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.service.js","sourceRoot":"/","sources":["modules/tournament/notification/notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,8DAAgE;AAChE,4EAAqG;AACrG,
|
|
1
|
+
{"version":3,"file":"notification.service.js","sourceRoot":"/","sources":["modules/tournament/notification/notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,8DAAgE;AAChE,4EAAqG;AACrG,4DAK2C;AAE3C,4EAAsE;AAK/D,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IAC9B,kBAAkB,CAAqB;IAE/C;QACI,IAAI,CAAC,kBAAkB,GAAG,gBAAS,CAAC,GAAG,CAAC,wCAAkB,CAAC,CAAC;IAChE,CAAC;IAEO,WAAW,CAAC,SAA2C,EAAE,GAAW;QACxE,MAAM,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,CAAC,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,GAAG,EAAE,CAAC,CAAC;QACpE,OAAO,CAAC,CAAC;IACb,CAAC;IAEO,eAAe,CAAC,WAA2C,EAAE,OAAgC;QACjG,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC3F,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,YAAgC;QACtD,MAAM,IAAA,oBAAY,EACd,IAAI,sCAAuB,CAAC;YACxB,KAAK,EAAE,YAAY,CAAC,KAAK;YACzB,IAAI,EAAE,YAAY,CAAC,IAAI;YACvB,IAAI,EAAE;gBACF,gBAAgB,EAAE,IAAI;gBACtB,WAAW,EAAE,8BAAuB,CAAC,IAAI;gBACzC,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,IAAI;gBACjB,SAAS,EAAE,gBAAS,CAAC,oBAAoB;gBACzC,GAAG,YAAY;aAClB;SACJ,CAAC,CACL,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,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B,YAAY,EAAE,YAAY,CAAC,QAAQ,EAAE;gBACrC,aAAa;aAChB,EACD,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CACjC,CAAC;QACN,CAAC;IACL,CAAC;CACJ,CAAA;AAtFY,sEAA6B;wCAA7B,6BAA6B;IADzC,IAAA,gBAAO,GAAE;;GACG,6BAA6B,CAsFzC;AAEY,QAAA,6BAA6B,GAAG,gBAAS,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {publishEvent} from '@lyxa.ai/core/dist/libraries/event';\nimport {NotificationEvent, NotificationGlobalEvent} from '@lyxa.ai/core/dist/libraries/notification';\nimport {\n ClickType,\n NotificationAccountType,\n TournamentNotificationTag,\n TournamentScheduledNotificationTarget\n} from '@lyxa.ai/core/dist/utilities/enum';\nimport {NotificationMessage} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {ParticipantService} from '../participant/participant.service';\nimport {TournamentParticipantOutputDTO} from '../participant/participant.validation';\nimport {NotificationObject} from './notification.config';\n\n@Service()\nexport class TournamentNotificationService {\n private participantService: ParticipantService;\n\n constructor() {\n this.participantService = Container.get(ParticipantService);\n }\n\n private getTemplate(templates: Map<string, NotificationMessage>, tag: string): NotificationMessage {\n const t = templates.get(tag);\n if (!t) throw new Error(`No notification template for tag: ${tag}`);\n return t;\n }\n\n private hasNotPredicted(participant: TournamentParticipantOutputDTO, matchId: mongoose.Types.ObjectId): boolean {\n return !participant.predictions.some(p => p.matchId.toString() === matchId.toString());\n }\n\n public async notifyGlobal(notification: NotificationObject): Promise<void> {\n await publishEvent(\n new NotificationGlobalEvent({\n title: notification.title,\n body: notification.body,\n data: {\n saveNotification: true,\n accountType: NotificationAccountType.USER,\n isGlobal: true,\n isClickable: true,\n clickType: ClickType.CLICKABLE_TOURNAMENT,\n ...notification,\n },\n })\n );\n }\n\n public async notifyUsers(notification: NotificationObject, userIds: mongoose.Types.ObjectId[]): Promise<void> {\n await Promise.all(\n userIds.map(recipientId =>\n publishEvent(\n new NotificationEvent({\n title: notification.title,\n body: notification.body,\n data: {\n saveNotification: true,\n accountType: NotificationAccountType.USER,\n recipientId,\n isGlobal: false,\n isClickable: true,\n clickType: ClickType.CLICKABLE_TOURNAMENT,\n ...notification,\n },\n })\n )\n )\n );\n }\n\n public async dispatchScheduledJob(\n type: TournamentNotificationTag,\n target: TournamentScheduledNotificationTarget,\n templates: Map<TournamentNotificationTag, NotificationMessage>,\n tournamentId: mongoose.Types.ObjectId,\n teamIds: mongoose.Types.ObjectId[],\n matchId: mongoose.Types.ObjectId,\n matchStartTime: Date,\n deepLinkRoute?: string\n ): Promise<void> {\n const {title, body} = this.getTemplate(templates, type);\n\n if (target === TournamentScheduledNotificationTarget.GLOBAL) {\n await this.notifyGlobal({title, body, tournamentNotificationType: type, tournamentId: tournamentId.toString(), deepLinkRoute});\n } else {\n const unpredicted = await this.participantService.getUnpredicted(tournamentId, teamIds, matchId);\n await this.notifyUsers(\n {\n title,\n body,\n tournamentNotificationType: type,\n predictionExpiryTime: matchStartTime,\n matchId: matchId.toString(),\n tournamentId: tournamentId.toString(),\n deepLinkRoute,\n },\n unpredicted.map(p => p.userId)\n );\n }\n }\n}\n\nexport const tournamentNotificationService = Container.get(TournamentNotificationService);\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { mongoose } from '@typegoose/typegoose';
|
|
2
|
+
import { TournamentParticipantStatus } from '../tournament.types';
|
|
3
|
+
export declare class ParticipantBuilder {
|
|
4
|
+
static buildNewParticipant(userId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId, teamId: mongoose.Types.ObjectId): {
|
|
5
|
+
userId: mongoose.Types.ObjectId;
|
|
6
|
+
tournamentId: mongoose.Types.ObjectId;
|
|
7
|
+
teamId: mongoose.Types.ObjectId;
|
|
8
|
+
status: TournamentParticipantStatus;
|
|
9
|
+
predictions: never[];
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=participant.builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"participant.builder.d.ts","sourceRoot":"/","sources":["modules/tournament/participant/participant.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,2BAA2B,EAAC,MAAM,qBAAqB,CAAC;AAEhE,qBAAa,kBAAkB;IAC3B,MAAM,CAAC,mBAAmB,CACtB,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ;;;;;;;CAUtC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ParticipantBuilder = void 0;
|
|
4
|
+
const tournament_types_1 = require("../tournament.types");
|
|
5
|
+
class ParticipantBuilder {
|
|
6
|
+
static buildNewParticipant(userId, tournamentId, teamId) {
|
|
7
|
+
return {
|
|
8
|
+
userId,
|
|
9
|
+
tournamentId,
|
|
10
|
+
teamId,
|
|
11
|
+
status: tournament_types_1.TournamentParticipantStatus.JOINED,
|
|
12
|
+
predictions: [],
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.ParticipantBuilder = ParticipantBuilder;
|
|
17
|
+
//# sourceMappingURL=participant.builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"participant.builder.js","sourceRoot":"/","sources":["modules/tournament/participant/participant.builder.ts"],"names":[],"mappings":";;;AACA,0DAAgE;AAEhE,MAAa,kBAAkB;IAC3B,MAAM,CAAC,mBAAmB,CACtB,MAA+B,EAC/B,YAAqC,EACrC,MAA+B;QAE/B,OAAO;YACH,MAAM;YACN,YAAY;YACZ,MAAM;YACN,MAAM,EAAE,8CAA2B,CAAC,MAAM;YAC1C,WAAW,EAAE,EAAE;SAClB,CAAC;IACN,CAAC;CACJ;AAdD,gDAcC","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\nimport {TournamentParticipantStatus} from '../tournament.types';\n\nexport class ParticipantBuilder {\n static buildNewParticipant(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId,\n teamId: mongoose.Types.ObjectId\n ) {\n return {\n userId,\n tournamentId,\n teamId,\n status: TournamentParticipantStatus.JOINED,\n predictions: [],\n };\n }\n}\n"]}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { mongoose } from '@typegoose/typegoose';
|
|
2
|
-
import {
|
|
2
|
+
import { TournamentParticipantOutputDTO } from './participant.validation';
|
|
3
3
|
export declare class TournamentParticipantRepository {
|
|
4
4
|
private participantModel;
|
|
5
5
|
constructor();
|
|
6
6
|
existsByUserAndTournament(userId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId): Promise<boolean>;
|
|
7
|
-
create(input: object): Promise<
|
|
8
|
-
findByUserAndTournament(userId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId): Promise<
|
|
9
|
-
findByTournament(tournamentId: mongoose.Types.ObjectId): Promise<
|
|
10
|
-
findByUser(userId: mongoose.Types.ObjectId): Promise<
|
|
11
|
-
updateToJoined(userId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId, teamId: mongoose.Types.ObjectId): Promise<
|
|
12
|
-
|
|
7
|
+
create(input: object): Promise<TournamentParticipantOutputDTO>;
|
|
8
|
+
findByUserAndTournament(userId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId): Promise<TournamentParticipantOutputDTO | null>;
|
|
9
|
+
findByTournament(tournamentId: mongoose.Types.ObjectId): Promise<TournamentParticipantOutputDTO[]>;
|
|
10
|
+
findByUser(userId: mongoose.Types.ObjectId): Promise<TournamentParticipantOutputDTO | null>;
|
|
11
|
+
updateToJoined(userId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId, teamId: mongoose.Types.ObjectId): Promise<TournamentParticipantOutputDTO | null>;
|
|
12
|
+
createIfAbsent(userId: mongoose.Types.ObjectId, tournamentId: mongoose.Types.ObjectId, status: string): Promise<void>;
|
|
13
|
+
findByTournamentWithoutPrediction(tournamentId: mongoose.Types.ObjectId, teamIds: mongoose.Types.ObjectId[], matchId: mongoose.Types.ObjectId): Promise<TournamentParticipantOutputDTO[]>;
|
|
13
14
|
}
|
|
14
15
|
export declare const tournamentParticipantRepository: TournamentParticipantRepository;
|
|
15
16
|
//# sourceMappingURL=participant.repository.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"participant.repository.d.ts","sourceRoot":"/","sources":["modules/tournament/participant/participant.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"participant.repository.d.ts","sourceRoot":"/","sources":["modules/tournament/participant/participant.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAE1E,qBACa,+BAA+B;IACxC,OAAO,CAAC,gBAAgB,CAAoC;;IAMtD,yBAAyB,CAC3B,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GACtC,OAAO,CAAC,OAAO,CAAC;IAIb,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,8BAA8B,CAAC;IAK9D,uBAAuB,CACzB,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GACtC,OAAO,CAAC,8BAA8B,GAAG,IAAI,CAAC;IAI3C,gBAAgB,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,8BAA8B,EAAE,CAAC;IAIlG,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,8BAA8B,GAAG,IAAI,CAAC;IAO3F,cAAc,CAChB,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAChC,OAAO,CAAC,8BAA8B,GAAG,IAAI,CAAC;IAM3C,cAAc,CAChB,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,MAAM,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;IAQH,iCAAiC,CAC1C,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACrC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,EAClC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GACjC,OAAO,CAAC,8BAA8B,EAAE,CAAC;CAW/C;AAED,eAAO,MAAM,+BAA+B,iCAAiD,CAAC"}
|
|
@@ -74,8 +74,18 @@ let TournamentParticipantRepository = class TournamentParticipantRepository {
|
|
|
74
74
|
.findOneAndUpdate({ userId, tournamentId }, { $set: { status: 'joined', teamId } }, { new: true })
|
|
75
75
|
.lean();
|
|
76
76
|
}
|
|
77
|
-
async
|
|
78
|
-
await this.participantModel.findOneAndUpdate({ userId, tournamentId }, { $setOnInsert: { userId, tournamentId, predictions: []
|
|
77
|
+
async createIfAbsent(userId, tournamentId, status) {
|
|
78
|
+
await this.participantModel.findOneAndUpdate({ userId, tournamentId }, { $setOnInsert: { userId, tournamentId, predictions: [], status } }, { upsert: true });
|
|
79
|
+
}
|
|
80
|
+
async findByTournamentWithoutPrediction(tournamentId, teamIds, matchId) {
|
|
81
|
+
return this.participantModel
|
|
82
|
+
.find({
|
|
83
|
+
tournamentId,
|
|
84
|
+
teamId: { $in: teamIds },
|
|
85
|
+
'predictions.matchId': { $ne: matchId },
|
|
86
|
+
})
|
|
87
|
+
.lean()
|
|
88
|
+
.exec();
|
|
79
89
|
}
|
|
80
90
|
};
|
|
81
91
|
exports.TournamentParticipantRepository = TournamentParticipantRepository;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"participant.repository.js","sourceRoot":"/","sources":["modules/tournament/participant/participant.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,
|
|
1
|
+
{"version":3,"file":"participant.repository.js","sourceRoot":"/","sources":["modules/tournament/participant/participant.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,sEAAuF;AAIhF,IAAM,+BAA+B,GAArC,MAAM,+BAA+B;IAChC,gBAAgB,CAAoC;IAE5D;QACI,IAAI,CAAC,gBAAgB,GAAG,mCAA0B,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,yBAAyB,CAC3B,MAA+B,EAC/B,YAAqC;QAErC,OAAO,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAa;QACtB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtD,OAAO,GAAG,CAAC,QAAQ,EAA+C,CAAC;IACvE,CAAC;IAED,KAAK,CAAC,uBAAuB,CACzB,MAA+B,EAC/B,Y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AM,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE;YACxB,qBAAqB,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE;SAC1C,CAAC;aACD,IAAI,EAAE;aACN,IAAI,EAA+C,CAAC;IAC7D,CAAC;CAEJ,CAAA;AA1EY,0EAA+B;0CAA/B,+BAA+B;IAD3C,IAAA,gBAAO,GAAE;;GACG,+BAA+B,CA0E3C;AAEY,QAAA,+BAA+B,GAAG,gBAAS,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport { TournamentParticipantModel } from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport { TournamentParticipantOutputDTO } from './participant.validation';\n\n@Service()\nexport class TournamentParticipantRepository {\n private participantModel: typeof TournamentParticipantModel;\n\n constructor() {\n this.participantModel = TournamentParticipantModel;\n }\n\n async existsByUserAndTournament(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId\n ): Promise<boolean> {\n return !!(await this.participantModel.exists({ userId, tournamentId }));\n }\n\n async create(input: object): Promise<TournamentParticipantOutputDTO> {\n const doc = await this.participantModel.create(input);\n return doc.toObject() as unknown as TournamentParticipantOutputDTO;\n }\n\n async findByUserAndTournament(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId\n ): Promise<TournamentParticipantOutputDTO | null> {\n return this.participantModel.findOne({ userId, tournamentId }).lean() as Promise<TournamentParticipantOutputDTO | null>;\n }\n\n async findByTournament(tournamentId: mongoose.Types.ObjectId): Promise<TournamentParticipantOutputDTO[]> {\n return this.participantModel.find({ tournamentId }).lean() as Promise<TournamentParticipantOutputDTO[]>;\n }\n\n async findByUser(userId: mongoose.Types.ObjectId): Promise<TournamentParticipantOutputDTO | null> {\n return this.participantModel\n .findOne({ userId })\n .sort({ createdAt: -1 })\n .lean() as Promise<TournamentParticipantOutputDTO | null>;\n }\n\n async updateToJoined(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId,\n teamId: mongoose.Types.ObjectId\n ): Promise<TournamentParticipantOutputDTO | null> {\n return this.participantModel\n .findOneAndUpdate({ userId, tournamentId }, { $set: { status: 'joined', teamId } }, { new: true })\n .lean() as Promise<TournamentParticipantOutputDTO | null>;\n }\n\n async createIfAbsent(\n userId: mongoose.Types.ObjectId,\n tournamentId: mongoose.Types.ObjectId,\n status: string\n ): Promise<void> {\n await this.participantModel.findOneAndUpdate(\n { userId, tournamentId },\n { $setOnInsert: { userId, tournamentId, predictions: [], status } },\n { upsert: true }\n );\n }\n\n public async findByTournamentWithoutPrediction(\n tournamentId: mongoose.Types.ObjectId,\n teamIds: mongoose.Types.ObjectId[],\n matchId: mongoose.Types.ObjectId\n ): Promise<TournamentParticipantOutputDTO[]> {\n return this.participantModel\n .find({\n tournamentId,\n teamId: { $in: teamIds },\n 'predictions.matchId': { $ne: matchId },\n })\n .lean()\n .exec() as Promise<TournamentParticipantOutputDTO[]>;\n }\n\n}\n\nexport const tournamentParticipantRepository = Container.get(TournamentParticipantRepository);\n"]}
|