@lyxa.ai/marketing 1.0.64 → 1.0.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/event/event-initializations.d.ts.map +1 -1
- package/dist/lib/event/event-initializations.js +0 -1
- package/dist/lib/event/event-initializations.js.map +1 -1
- package/dist/lib/event/event-listeners/event-listeners.d.ts +0 -1
- package/dist/lib/event/event-listeners/event-listeners.d.ts.map +1 -1
- package/dist/lib/event/event-listeners/event-listeners.js +12 -62
- package/dist/lib/event/event-listeners/event-listeners.js.map +1 -1
- package/dist/lib/event/events/marketing-product-seed.event.d.ts +2 -1
- package/dist/lib/event/events/marketing-product-seed.event.d.ts.map +1 -1
- package/dist/lib/event/events/marketing-product-seed.event.js.map +1 -1
- package/dist/lib/index.d.ts +21 -12030
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts +1101 -27
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.js +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js +21 -6
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js.map +1 -1
- package/dist/lib/modules/coupon/services/referral-reward-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/referral-reward-coupon.service.js +1 -0
- package/dist/lib/modules/coupon/services/referral-reward-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/transformers/coupon.transformer.d.ts +50 -0
- package/dist/lib/modules/coupon/transformers/coupon.transformer.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts +828 -6
- package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts +30 -30
- package/dist/lib/modules/coupon/validations/create-coupon.validation.d.ts +98 -0
- package/dist/lib/modules/coupon/validations/create-coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/referral-reward-coupon.validation.d.ts +374 -0
- package/dist/lib/modules/coupon/validations/referral-reward-coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/referral-reward-coupon.validation.js +2 -0
- package/dist/lib/modules/coupon/validations/referral-reward-coupon.validation.js.map +1 -1
- package/dist/lib/modules/deal-setting/routers/deal-setting.router.d.ts +9 -9
- package/dist/lib/modules/deal-setting/routers/deal-setting.router.d.ts.map +1 -1
- package/dist/lib/modules/deal-setting/validations/deal-setting.validation.d.ts +6 -6
- package/dist/lib/modules/featured-setting/routers/featured-setting.router.d.ts +8 -8
- package/dist/lib/modules/featured-setting/routers/featured-setting.router.d.ts.map +1 -1
- package/dist/lib/modules/featured-setting/validations/featured-setting.validation.d.ts +6 -6
- package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts +7 -7
- package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js +2 -0
- package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/jobs/index.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/jobs/index.js +4 -1
- package/dist/lib/modules/limited-time-offer/campaign/jobs/index.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +36 -36
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.js +7 -2
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.d.ts +1 -0
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.js +13 -2
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.js.map +1 -1
- 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 +7 -2
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.validation.d.ts +6 -6
- package/dist/lib/modules/limited-time-offer/config/limited-time-offer.router.d.ts +3 -3
- package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts +18 -18
- package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js +3 -0
- package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +7 -7
- 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.router.js +5 -0
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.js.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 +19 -19
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +1 -0
- 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 +18 -1
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js.map +1 -1
- package/dist/lib/modules/marketing/routers/marketing.router.d.ts +14 -3
- package/dist/lib/modules/marketing/routers/marketing.router.d.ts.map +1 -1
- package/dist/lib/modules/marketing/routers/marketing.router.js +4 -0
- package/dist/lib/modules/marketing/routers/marketing.router.js.map +1 -1
- package/dist/lib/modules/marketing/services/marketing.service.d.ts +1 -2
- package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/marketing.service.js +85 -77
- package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/services/product-marketing.service.d.ts +3 -1
- package/dist/lib/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/product-marketing.service.js +13 -10
- package/dist/lib/modules/marketing/services/product-marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/services/spend-to-get-progress.service.d.ts +13 -0
- package/dist/lib/modules/marketing/services/spend-to-get-progress.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/spend-to-get-progress.service.js +24 -0
- package/dist/lib/modules/marketing/services/spend-to-get-progress.service.js.map +1 -1
- package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.js +27 -95
- package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/validations/all-marketings.validation.d.ts +4 -4
- package/dist/lib/modules/marketing/validations/buy1-get1-marketing.validation.d.ts +3 -3
- package/dist/lib/modules/marketing/validations/discount-marketing.validation.d.ts +3 -3
- package/dist/lib/modules/marketing/validations/marketing.validation.d.ts +8 -0
- package/dist/lib/modules/marketing/validations/marketing.validation.d.ts.map +1 -1
- package/dist/lib/modules/marketing/validations/marketing.validation.js +4 -1
- package/dist/lib/modules/marketing/validations/marketing.validation.js.map +1 -1
- package/dist/lib/modules/marketing/validations/product-marketing.validation.d.ts +2 -2
- package/dist/lib/modules/marketing/validations/punch-marketing.validation.d.ts +4 -4
- package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +12 -12
- package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts.map +1 -1
- package/dist/lib/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +8 -8
- package/dist/lib/modules/referral-setting/routers/referral-setting.router.d.ts +4 -4
- package/dist/lib/modules/referral-setting/validations/referral-setting.validation.d.ts +6 -6
- package/dist/lib/modules/referral-setting/validations/referral-setting.validation.d.ts.map +1 -1
- package/dist/lib/modules/referral-setting/validations/referral-setting.validation.js.map +1 -1
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.d.ts +3 -2
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.d.ts.map +1 -1
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.js +11 -3
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.js.map +1 -1
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.d.ts +26 -10
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.d.ts.map +1 -1
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.d.ts +2 -2
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.d.ts.map +1 -1
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.js.map +1 -1
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.d.ts +25 -6
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.d.ts.map +1 -1
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.js +1 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.js.map +1 -1
- package/dist/lib/modules/tournament/config/config.router.d.ts +4 -4
- package/dist/lib/modules/tournament/config/config.validation.d.ts +12 -12
- package/dist/lib/modules/tournament/match/match.router.d.ts +5 -5
- package/dist/lib/modules/tournament/match/match.validation.d.ts +12 -12
- package/dist/lib/modules/tournament/participant/participant.router.d.ts +3 -3
- package/dist/lib/modules/tournament/participant/participant.validation.d.ts +24 -24
- package/dist/lib/modules/tournament/prediction/prediction.router.d.ts +3 -3
- package/dist/lib/modules/tournament/prediction/prediction.validation.d.ts +18 -18
- package/dist/lib/modules/tournament/score/score.router.d.ts +1 -1
- package/dist/lib/modules/tournament/score/score.validation.d.ts +6 -6
- package/dist/lib/modules/tournament/statistics/statistics.router.d.ts +1 -1
- package/dist/lib/modules/tournament/statistics/statistics.validation.d.ts +6 -6
- package/dist/lib/modules/tournament/team/team.router.d.ts +3 -3
- package/dist/lib/modules/tournament/team/team.validation.d.ts +18 -18
- package/dist/lib/modules/tournament/tournament.router.d.ts +21 -21
- package/dist/lib/modules/tournament/tournament.validation.d.ts +6 -6
- package/dist/lib/utility/feature-flags.d.ts +3 -0
- package/dist/lib/utility/feature-flags.d.ts.map +1 -0
- package/dist/lib/utility/feature-flags.js +16 -0
- package/dist/lib/utility/feature-flags.js.map +1 -0
- package/dist/types/event/event-initializations.d.ts.map +1 -1
- package/dist/types/event/event-listeners/event-listeners.d.ts +0 -1
- package/dist/types/event/event-listeners/event-listeners.d.ts.map +1 -1
- package/dist/types/event/events/marketing-product-seed.event.d.ts +2 -1
- package/dist/types/event/events/marketing-product-seed.event.d.ts.map +1 -1
- package/dist/types/index.d.ts +21 -12030
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/coupon/routers/coupon.router.d.ts +1101 -27
- package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/coupon.service.d.ts +1 -1
- package/dist/types/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/referral-reward-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/transformers/coupon.transformer.d.ts +50 -0
- package/dist/types/modules/coupon/transformers/coupon.transformer.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts +828 -6
- package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts +30 -30
- package/dist/types/modules/coupon/validations/create-coupon.validation.d.ts +98 -0
- package/dist/types/modules/coupon/validations/create-coupon.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/referral-reward-coupon.validation.d.ts +374 -0
- package/dist/types/modules/coupon/validations/referral-reward-coupon.validation.d.ts.map +1 -1
- package/dist/types/modules/deal-setting/routers/deal-setting.router.d.ts +9 -9
- package/dist/types/modules/deal-setting/routers/deal-setting.router.d.ts.map +1 -1
- package/dist/types/modules/deal-setting/validations/deal-setting.validation.d.ts +6 -6
- package/dist/types/modules/featured-setting/routers/featured-setting.router.d.ts +8 -8
- package/dist/types/modules/featured-setting/routers/featured-setting.router.d.ts.map +1 -1
- package/dist/types/modules/featured-setting/validations/featured-setting.validation.d.ts +6 -6
- package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts +7 -7
- package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/jobs/index.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +36 -36
- package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.d.ts +1 -0
- package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.d.ts.map +1 -1
- 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.validation.d.ts +6 -6
- package/dist/types/modules/limited-time-offer/config/limited-time-offer.router.d.ts +3 -3
- package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts +18 -18
- package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +7 -7
- 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 +19 -19
- package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +1 -0
- package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/routers/marketing.router.d.ts +14 -3
- package/dist/types/modules/marketing/routers/marketing.router.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/marketing.service.d.ts +1 -2
- package/dist/types/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/product-marketing.service.d.ts +3 -1
- package/dist/types/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/spend-to-get-progress.service.d.ts +18 -0
- package/dist/types/modules/marketing/services/spend-to-get-progress.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/synchronize-product-marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/validations/all-marketings.validation.d.ts +4 -4
- package/dist/types/modules/marketing/validations/buy1-get1-marketing.validation.d.ts +3 -3
- package/dist/types/modules/marketing/validations/discount-marketing.validation.d.ts +3 -3
- package/dist/types/modules/marketing/validations/marketing.validation.d.ts +8 -0
- package/dist/types/modules/marketing/validations/marketing.validation.d.ts.map +1 -1
- package/dist/types/modules/marketing/validations/product-marketing.validation.d.ts +2 -2
- package/dist/types/modules/marketing/validations/punch-marketing.validation.d.ts +4 -4
- package/dist/types/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +12 -12
- package/dist/types/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts.map +1 -1
- package/dist/types/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +8 -8
- package/dist/types/modules/referral-setting/routers/referral-setting.router.d.ts +4 -4
- package/dist/types/modules/referral-setting/validations/referral-setting.validation.d.ts +6 -6
- package/dist/types/modules/referral-setting/validations/referral-setting.validation.d.ts.map +1 -1
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.repository.d.ts +3 -2
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.repository.d.ts.map +1 -1
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.router.d.ts +26 -10
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.router.d.ts.map +1 -1
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.service.d.ts +2 -2
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.service.d.ts.map +1 -1
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.validation.d.ts +25 -6
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.validation.d.ts.map +1 -1
- package/dist/types/modules/tournament/config/config.router.d.ts +4 -4
- package/dist/types/modules/tournament/config/config.validation.d.ts +12 -12
- package/dist/types/modules/tournament/match/match.router.d.ts +5 -5
- package/dist/types/modules/tournament/match/match.validation.d.ts +12 -12
- package/dist/types/modules/tournament/participant/participant.router.d.ts +3 -3
- package/dist/types/modules/tournament/participant/participant.validation.d.ts +24 -24
- package/dist/types/modules/tournament/prediction/prediction.router.d.ts +3 -3
- package/dist/types/modules/tournament/prediction/prediction.validation.d.ts +18 -18
- package/dist/types/modules/tournament/score/score.router.d.ts +1 -1
- package/dist/types/modules/tournament/score/score.validation.d.ts +6 -6
- package/dist/types/modules/tournament/statistics/statistics.router.d.ts +1 -1
- package/dist/types/modules/tournament/statistics/statistics.validation.d.ts +6 -6
- package/dist/types/modules/tournament/team/team.router.d.ts +3 -3
- package/dist/types/modules/tournament/team/team.validation.d.ts +18 -18
- package/dist/types/modules/tournament/tournament.router.d.ts +21 -21
- package/dist/types/modules/tournament/tournament.validation.d.ts +6 -6
- package/dist/types/utility/feature-flags.d.ts +12 -0
- package/dist/types/utility/feature-flags.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/lib/modules/spend-to-get-history/routers/index.d.ts +0 -2
- package/dist/lib/modules/spend-to-get-history/routers/index.d.ts.map +0 -1
- package/dist/lib/modules/spend-to-get-history/routers/index.js +0 -18
- package/dist/lib/modules/spend-to-get-history/routers/index.js.map +0 -1
- package/dist/lib/modules/spend-to-get-history/routers/spend-to-get-history.router.js +0 -62
- package/dist/lib/modules/spend-to-get-history/routers/spend-to-get-history.router.js.map +0 -1
- package/dist/lib/modules/spend-to-get-history/services/index.d.ts +0 -2
- package/dist/lib/modules/spend-to-get-history/services/index.d.ts.map +0 -1
- package/dist/lib/modules/spend-to-get-history/services/index.js +0 -18
- package/dist/lib/modules/spend-to-get-history/services/index.js.map +0 -1
- package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts +0 -24
- package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts.map +0 -1
- package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.js +0 -136
- package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.js.map +0 -1
- package/dist/lib/modules/spend-to-get-history/validations/index.d.ts +0 -2
- package/dist/lib/modules/spend-to-get-history/validations/index.d.ts.map +0 -1
- package/dist/lib/modules/spend-to-get-history/validations/index.js +0 -18
- package/dist/lib/modules/spend-to-get-history/validations/index.js.map +0 -1
- package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.d.ts +0 -232
- package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.d.ts.map +0 -1
- package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.js +0 -30
- package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.js.map +0 -1
- 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 +0 -82
- 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 +0 -73
- 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/spend-to-get-history/routers/index.d.ts +0 -2
- package/dist/types/modules/spend-to-get-history/routers/index.d.ts.map +0 -1
- package/dist/types/modules/spend-to-get-history/services/index.d.ts +0 -2
- package/dist/types/modules/spend-to-get-history/services/index.d.ts.map +0 -1
- package/dist/types/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts +0 -56
- package/dist/types/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts.map +0 -1
- package/dist/types/modules/spend-to-get-history/validations/index.d.ts +0 -2
- package/dist/types/modules/spend-to-get-history/validations/index.d.ts.map +0 -1
- package/dist/types/modules/spend-to-get-history/validations/spend-to-get-history.validation.d.ts +0 -241
- package/dist/types/modules/spend-to-get-history/validations/spend-to-get-history.validation.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
package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts
CHANGED
|
@@ -61,8 +61,8 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
61
61
|
withdrawnAt?: Date | null | undefined;
|
|
62
62
|
}[];
|
|
63
63
|
metadata?: {
|
|
64
|
-
page: number;
|
|
65
64
|
size: number;
|
|
65
|
+
page: number;
|
|
66
66
|
totalElements: number;
|
|
67
67
|
totalPages: number;
|
|
68
68
|
} | undefined;
|
|
@@ -116,8 +116,8 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
116
116
|
withdrawnAt?: Date | null | undefined;
|
|
117
117
|
}[];
|
|
118
118
|
metadata?: {
|
|
119
|
-
page: number;
|
|
120
119
|
size: number;
|
|
120
|
+
page: number;
|
|
121
121
|
totalElements: number;
|
|
122
122
|
totalPages: number;
|
|
123
123
|
} | undefined;
|
|
@@ -183,8 +183,8 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
183
183
|
} | undefined;
|
|
184
184
|
}[];
|
|
185
185
|
metadata?: {
|
|
186
|
-
page: number;
|
|
187
186
|
size: number;
|
|
187
|
+
page: number;
|
|
188
188
|
totalElements: number;
|
|
189
189
|
totalPages: number;
|
|
190
190
|
} | undefined;
|
|
@@ -241,8 +241,8 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
241
241
|
withdrawnAt?: Date | null | undefined;
|
|
242
242
|
}[][];
|
|
243
243
|
metadata?: {
|
|
244
|
-
page: number;
|
|
245
244
|
size: number;
|
|
245
|
+
page: number;
|
|
246
246
|
totalElements: number;
|
|
247
247
|
totalPages: number;
|
|
248
248
|
} | undefined;
|
|
@@ -297,8 +297,8 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
297
297
|
withdrawnAt?: Date | null | undefined;
|
|
298
298
|
}[];
|
|
299
299
|
metadata?: {
|
|
300
|
-
page: number;
|
|
301
300
|
size: number;
|
|
301
|
+
page: number;
|
|
302
302
|
totalElements: number;
|
|
303
303
|
totalPages: number;
|
|
304
304
|
} | undefined;
|
|
@@ -343,8 +343,8 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
343
343
|
discountPercentage?: number | undefined;
|
|
344
344
|
}[];
|
|
345
345
|
metadata?: {
|
|
346
|
-
page: number;
|
|
347
346
|
size: number;
|
|
347
|
+
page: number;
|
|
348
348
|
totalElements: number;
|
|
349
349
|
totalPages: number;
|
|
350
350
|
} | undefined;
|
|
@@ -404,8 +404,8 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
404
404
|
} | undefined;
|
|
405
405
|
}[];
|
|
406
406
|
metadata?: {
|
|
407
|
-
page: number;
|
|
408
407
|
size: number;
|
|
408
|
+
page: number;
|
|
409
409
|
totalElements: number;
|
|
410
410
|
totalPages: number;
|
|
411
411
|
} | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limited-time-offer-participant.router.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.router.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"limited-time-offer-participant.router.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.router.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAa9C,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6F5B,CAAC"}
|
package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.js
CHANGED
|
@@ -11,6 +11,7 @@ const limited_time_offer_participant_validation_1 = require("./limited-time-offe
|
|
|
11
11
|
const limited_time_offer_campaign_validation_1 = require("../campaign/limited-time-offer-campaign.validation");
|
|
12
12
|
const typegoose_1 = require("@typegoose/typegoose");
|
|
13
13
|
const error_common_1 = require("@lyxa.ai/core/dist/utilities/error-common");
|
|
14
|
+
const feature_flags_1 = require("../../../utility/feature-flags");
|
|
14
15
|
const sellerProcedure = (0, auth_2.createAuthenticatedProcedure)({ entityTypes: [auth_1.AuthEntityType.SELLER] });
|
|
15
16
|
const crmProcedure = (0, auth_2.createAuthenticatedProcedure)({ entityTypes: [auth_1.AuthEntityType.CRM] });
|
|
16
17
|
function resolveShopId(ctx) {
|
|
@@ -50,6 +51,7 @@ exports.participantRouter = (0, trpc_1.createTRPCRouter)({
|
|
|
50
51
|
.input(limited_time_offer_participant_validation_1.AdminEnrollShopsSchema)
|
|
51
52
|
.output(limited_time_offer_participant_validation_1.AdminJoinParticipantsResponseSchema)
|
|
52
53
|
.mutation(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
54
|
+
await (0, feature_flags_1.assertLtoScheduleEnabled)();
|
|
53
55
|
const results = await limited_time_offer_participant_service_1.ltoParticipantService.enrollShops(input.shops);
|
|
54
56
|
return (0, response_1.response)('Successfully joined the campaign', results);
|
|
55
57
|
})),
|
|
@@ -57,6 +59,7 @@ exports.participantRouter = (0, trpc_1.createTRPCRouter)({
|
|
|
57
59
|
.input(limited_time_offer_participant_validation_1.AdminUpdateShopSchema)
|
|
58
60
|
.output(limited_time_offer_participant_validation_1.ParticipantResponseSchema)
|
|
59
61
|
.mutation(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
62
|
+
await (0, feature_flags_1.assertLtoScheduleEnabled)();
|
|
60
63
|
const { shopId, ...dto } = input;
|
|
61
64
|
const result = await limited_time_offer_participant_service_1.ltoParticipantService.update(shopId, dto);
|
|
62
65
|
return (0, response_1.response)('Participation updated successfully', result);
|
|
@@ -65,6 +68,7 @@ exports.participantRouter = (0, trpc_1.createTRPCRouter)({
|
|
|
65
68
|
.input(limited_time_offer_participant_validation_1.AdminWithdrawShopSchema)
|
|
66
69
|
.output(limited_time_offer_campaign_validation_1.LtoEmptyResponseSchema)
|
|
67
70
|
.mutation(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
71
|
+
await (0, feature_flags_1.assertLtoScheduleEnabled)();
|
|
68
72
|
await limited_time_offer_participant_service_1.ltoParticipantService.withdraw(input.shopId);
|
|
69
73
|
return (0, response_1.response)('Successfully withdrawn from the campaign');
|
|
70
74
|
})),
|
|
@@ -79,6 +83,7 @@ exports.participantRouter = (0, trpc_1.createTRPCRouter)({
|
|
|
79
83
|
.input(limited_time_offer_participant_validation_1.AdminGetParticipantByShopSchema)
|
|
80
84
|
.output(limited_time_offer_participant_validation_1.ParticipantStatusResponseSchema)
|
|
81
85
|
.query(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
86
|
+
await (0, feature_flags_1.assertLtoScheduleEnabled)();
|
|
82
87
|
const result = await limited_time_offer_participant_service_1.ltoParticipantService.getStatus(input.shopId);
|
|
83
88
|
return (0, response_1.response)('Status fetched successfully', result);
|
|
84
89
|
})),
|
package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limited-time-offer-participant.router.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.router.ts"],"names":[],"mappings":";;;AAAA,4DAAmE;AACnE,4DAAiE;AACjE,6EAAgG;AAChG,8EAAwE;AACxE,oEAA+D;AAC/D,8GAAmG;AACnG,2GASqD;AACrD,+GAI4D;AAC5D,oDAA8C;AAC9C,4EAA0E;
|
|
1
|
+
{"version":3,"file":"limited-time-offer-participant.router.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.router.ts"],"names":[],"mappings":";;;AAAA,4DAAmE;AACnE,4DAAiE;AACjE,6EAAgG;AAChG,8EAAwE;AACxE,oEAA+D;AAC/D,8GAAmG;AACnG,2GASqD;AACrD,+GAI4D;AAC5D,oDAA8C;AAC9C,4EAA0E;AAC1E,0DAAgE;AAEhE,MAAM,eAAe,GAAG,IAAA,mCAA4B,EAAC,EAAC,WAAW,EAAE,CAAC,qBAAc,CAAC,MAAM,CAAC,EAAC,CAAC,CAAC;AAC7F,MAAM,YAAY,GAAG,IAAA,mCAA4B,EAAC,EAAC,WAAW,EAAE,CAAC,qBAAc,CAAC,GAAG,CAAC,EAAC,CAAC,CAAC;AAEvF,SAAS,aAAa,CAAC,GAAiE;IACpF,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,KAA6B,CAAC;IACpE,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAA,8BAAe,EAAC,sCAAsC,CAAC,CAAC;IAChG,OAAO,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC;AAEY,QAAA,iBAAiB,GAAG,IAAA,uBAAgB,EAAC;IAC9C,IAAI,EAAE,eAAe;SAChB,KAAK,CAAC,iEAAqB,CAAC;SAC5B,MAAM,CAAC,qEAAyB,CAAC;SACjC,QAAQ,CAAC,KAAK,EAAE,EAAC,KAAK,EAAE,GAAG,EAAC,EAAE,EAAE,CAC7B,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,MAAM,MAAM,GAAG,MAAM,8DAAO,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;QAC7D,OAAO,IAAA,mBAAQ,EAAC,kCAAkC,EAAE,MAAa,C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CAAC,8EAAqC,CAAC;SAC7C,KAAK,CAAC,KAAK,EAAE,EAAC,KAAK,EAAC,EAAE,EAAE,CACrB,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,MAAM,MAAM,GAAG,MAAM,8DAAO,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QACpD,OAAO,IAAA,mBAAQ,EAAC,mCAAmC,EAAE,MAAM,CAAC,CAAC;IACjE,CAAC,CAAC,CACL;IAEL,oBAAoB,EAAE,YAAY;SAC7B,KAAK,CAAC,2EAA+B,CAAC;SACtC,MAAM,CAAC,2EAA+B,CAAC;SACvC,KAAK,CAAC,KAAK,EAAE,EAAC,KAAK,EAAC,EAAE,EAAE,CACrB,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,MAAM,IAAA,wCAAwB,GAAE,CAAC;QACjC,MAAM,MAAM,GAAG,MAAM,8DAAO,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACrD,OAAO,IAAA,mBAAQ,EAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC,CAAC,CACL;CACR,CAAC,CAAC","sourcesContent":["import {createTRPCRouter} from '@lyxa.ai/core/dist/libraries/trpc';\nimport {AuthEntityType} from '@lyxa.ai/core/dist/libraries/auth';\nimport {createAuthenticatedProcedure} from '@lyxa.ai/core/dist/libraries/trpc/middlewares/auth';\nimport {ErrorHandler} from '@lyxa.ai/core/dist/utilities/error-handler';\nimport {response} from '@lyxa.ai/core/dist/utilities/response';\nimport {ltoParticipantService as service} from './services/limited-time-offer-participant.service';\nimport {\n AdminEnrollShopsSchema,\n AdminGetParticipantByShopSchema,\n AdminJoinParticipantsResponseSchema,\n AdminUpdateShopSchema,\n AdminWithdrawShopSchema,\n JoinLtoCampaignSchema,\n ParticipantResponseSchema,\n ParticipantStatusResponseSchema,\n} from './limited-time-offer-participant.validation';\nimport {\n GetLtoCampaignParticipantsSchema,\n LtoCampaignParticipantsResponseSchema,\n LtoEmptyResponseSchema,\n} from '../campaign/limited-time-offer-campaign.validation';\nimport {mongoose} from '@typegoose/typegoose';\nimport {badRequestError} from '@lyxa.ai/core/dist/utilities/error-common';\nimport {assertLtoScheduleEnabled} from '@utility/feature-flags';\n\nconst sellerProcedure = createAuthenticatedProcedure({entityTypes: [AuthEntityType.SELLER]});\nconst crmProcedure = createAuthenticatedProcedure({entityTypes: [AuthEntityType.CRM]});\n\nfunction resolveShopId(ctx: { entity?: { parameters?: Record<string, unknown> } | null }): mongoose.Types.ObjectId {\n const shops = ctx.entity?.parameters?.shops as string[] | undefined;\n if (!shops || shops.length === 0) throw badRequestError('No shop associated with this account');\n return new mongoose.Types.ObjectId(shops[0]);\n}\n\nexport const participantRouter = createTRPCRouter({\n join: sellerProcedure\n .input(JoinLtoCampaignSchema)\n .output(ParticipantResponseSchema)\n .mutation(async ({input, ctx}) =>\n ErrorHandler.wrapAsync(async () => {\n const result = await service.join(resolveShopId(ctx), input);\n return response('Successfully joined the campaign', result as any);\n })\n ),\n\n update: sellerProcedure\n .input(JoinLtoCampaignSchema)\n .output(ParticipantResponseSchema)\n .mutation(async ({input, ctx}) =>\n ErrorHandler.wrapAsync(async () => {\n const result = await service.update(resolveShopId(ctx), input);\n return response('Participation updated successfully', result as any);\n })\n ),\n\n withdraw: sellerProcedure\n .output(LtoEmptyResponseSchema)\n .mutation(async ({ctx}) =>\n ErrorHandler.wrapAsync(async () => {\n await service.withdraw(resolveShopId(ctx));\n return response('Successfully withdrawn from the campaign');\n })\n ),\n\n getStatus: sellerProcedure\n .output(ParticipantStatusResponseSchema)\n .query(async ({ctx}) =>\n ErrorHandler.wrapAsync(async () => {\n const result = await service.getStatus(resolveShopId(ctx));\n return response('Status fetched successfully', result);\n })\n ),\n\n enrollShops: crmProcedure\n .input(AdminEnrollShopsSchema)\n .output(AdminJoinParticipantsResponseSchema)\n .mutation(async ({input}) =>\n ErrorHandler.wrapAsync(async () => {\n await assertLtoScheduleEnabled();\n const results = await service.enrollShops(input.shops);\n return response('Successfully joined the campaign', results as any);\n })\n ),\n\n updateShop: crmProcedure\n .input(AdminUpdateShopSchema)\n .output(ParticipantResponseSchema)\n .mutation(async ({input}) =>\n ErrorHandler.wrapAsync(async () => {\n await assertLtoScheduleEnabled();\n const {shopId, ...dto} = input;\n const result = await service.update(shopId, dto);\n return response('Participation updated successfully', result as any);\n })\n ),\n\n withdrawShop: crmProcedure\n .input(AdminWithdrawShopSchema)\n .output(LtoEmptyResponseSchema)\n .mutation(async ({input}) =>\n ErrorHandler.wrapAsync(async () => {\n await assertLtoScheduleEnabled();\n await service.withdraw(input.shopId);\n return response('Successfully withdrawn from the campaign');\n })\n ),\n\n getParticipants: crmProcedure\n .input(GetLtoCampaignParticipantsSchema)\n .output(LtoCampaignParticipantsResponseSchema)\n .query(async ({input}) =>\n ErrorHandler.wrapAsync(async () => {\n const result = await service.getParticipants(input);\n return response('Participants fetched successfully', result);\n })\n ),\n\n getParticipantByShop: crmProcedure\n .input(AdminGetParticipantByShopSchema)\n .output(ParticipantStatusResponseSchema)\n .query(async ({input}) =>\n ErrorHandler.wrapAsync(async () => {\n await assertLtoScheduleEnabled();\n const result = await service.getStatus(input.shopId);\n return response('Status fetched successfully', result);\n })\n ),\n});\n"]}
|
package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=limited-time-offer-participant.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limited-time-offer-participant.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.service.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limited-time-offer-participant.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.service.ts"],"names":[],"mappings":"","sourcesContent":[""]}
|
|
@@ -67,8 +67,8 @@ export declare const ParticipantSchema: z.ZodObject<{
|
|
|
67
67
|
_id: Types.ObjectId;
|
|
68
68
|
shop: Types.ObjectId;
|
|
69
69
|
isEntireMenu: boolean;
|
|
70
|
-
joinedAt: Date;
|
|
71
70
|
products: Types.ObjectId[];
|
|
71
|
+
joinedAt: Date;
|
|
72
72
|
campaign: Types.ObjectId;
|
|
73
73
|
isOrderCapacityEnabled: boolean;
|
|
74
74
|
isWithdrawn: boolean;
|
|
@@ -255,13 +255,13 @@ export declare const ParticipantResponseSchema: z.ZodObject<{
|
|
|
255
255
|
totalElements: z.ZodNumber;
|
|
256
256
|
totalPages: z.ZodNumber;
|
|
257
257
|
}, "strip", z.ZodTypeAny, {
|
|
258
|
-
page: number;
|
|
259
258
|
size: number;
|
|
259
|
+
page: number;
|
|
260
260
|
totalElements: number;
|
|
261
261
|
totalPages: number;
|
|
262
262
|
}, {
|
|
263
|
-
page: number;
|
|
264
263
|
size: number;
|
|
264
|
+
page: number;
|
|
265
265
|
totalElements: number;
|
|
266
266
|
totalPages: number;
|
|
267
267
|
}>>;
|
|
@@ -314,8 +314,8 @@ export declare const ParticipantResponseSchema: z.ZodObject<{
|
|
|
314
314
|
withdrawnAt?: Date | null | undefined;
|
|
315
315
|
}[];
|
|
316
316
|
metadata?: {
|
|
317
|
-
page: number;
|
|
318
317
|
size: number;
|
|
318
|
+
page: number;
|
|
319
319
|
totalElements: number;
|
|
320
320
|
totalPages: number;
|
|
321
321
|
} | undefined;
|
|
@@ -337,8 +337,8 @@ export declare const ParticipantResponseSchema: z.ZodObject<{
|
|
|
337
337
|
withdrawnAt?: Date | null | undefined;
|
|
338
338
|
}[];
|
|
339
339
|
metadata?: {
|
|
340
|
-
page: number;
|
|
341
340
|
size: number;
|
|
341
|
+
page: number;
|
|
342
342
|
totalElements: number;
|
|
343
343
|
totalPages: number;
|
|
344
344
|
} | undefined;
|
|
@@ -409,8 +409,8 @@ export declare const ParticipantResponseSchema: z.ZodObject<{
|
|
|
409
409
|
withdrawnAt?: Date | null | undefined;
|
|
410
410
|
}[];
|
|
411
411
|
metadata?: {
|
|
412
|
-
page: number;
|
|
413
412
|
size: number;
|
|
413
|
+
page: number;
|
|
414
414
|
totalElements: number;
|
|
415
415
|
totalPages: number;
|
|
416
416
|
} | undefined;
|
|
@@ -451,8 +451,8 @@ export declare const ParticipantResponseSchema: z.ZodObject<{
|
|
|
451
451
|
withdrawnAt?: Date | null | undefined;
|
|
452
452
|
}[];
|
|
453
453
|
metadata?: {
|
|
454
|
-
page: number;
|
|
455
454
|
size: number;
|
|
455
|
+
page: number;
|
|
456
456
|
totalElements: number;
|
|
457
457
|
totalPages: number;
|
|
458
458
|
} | undefined;
|
|
@@ -468,13 +468,13 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
|
|
|
468
468
|
totalElements: z.ZodNumber;
|
|
469
469
|
totalPages: z.ZodNumber;
|
|
470
470
|
}, "strip", z.ZodTypeAny, {
|
|
471
|
-
page: number;
|
|
472
471
|
size: number;
|
|
472
|
+
page: number;
|
|
473
473
|
totalElements: number;
|
|
474
474
|
totalPages: number;
|
|
475
475
|
}, {
|
|
476
|
-
page: number;
|
|
477
476
|
size: number;
|
|
477
|
+
page: number;
|
|
478
478
|
totalElements: number;
|
|
479
479
|
totalPages: number;
|
|
480
480
|
}>>;
|
|
@@ -545,8 +545,8 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
|
|
|
545
545
|
} | undefined;
|
|
546
546
|
}[];
|
|
547
547
|
metadata?: {
|
|
548
|
-
page: number;
|
|
549
548
|
size: number;
|
|
549
|
+
page: number;
|
|
550
550
|
totalElements: number;
|
|
551
551
|
totalPages: number;
|
|
552
552
|
} | undefined;
|
|
@@ -574,8 +574,8 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
|
|
|
574
574
|
} | undefined;
|
|
575
575
|
}[];
|
|
576
576
|
metadata?: {
|
|
577
|
-
page: number;
|
|
578
577
|
size: number;
|
|
578
|
+
page: number;
|
|
579
579
|
totalElements: number;
|
|
580
580
|
totalPages: number;
|
|
581
581
|
} | undefined;
|
|
@@ -670,8 +670,8 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
|
|
|
670
670
|
} | undefined;
|
|
671
671
|
}[];
|
|
672
672
|
metadata?: {
|
|
673
|
-
page: number;
|
|
674
673
|
size: number;
|
|
674
|
+
page: number;
|
|
675
675
|
totalElements: number;
|
|
676
676
|
totalPages: number;
|
|
677
677
|
} | undefined;
|
|
@@ -724,8 +724,8 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
|
|
|
724
724
|
} | undefined;
|
|
725
725
|
}[];
|
|
726
726
|
metadata?: {
|
|
727
|
-
page: number;
|
|
728
727
|
size: number;
|
|
728
|
+
page: number;
|
|
729
729
|
totalElements: number;
|
|
730
730
|
totalPages: number;
|
|
731
731
|
} | undefined;
|
|
@@ -859,13 +859,13 @@ export declare const AdminJoinParticipantsResponseSchema: z.ZodObject<{
|
|
|
859
859
|
totalElements: z.ZodNumber;
|
|
860
860
|
totalPages: z.ZodNumber;
|
|
861
861
|
}, "strip", z.ZodTypeAny, {
|
|
862
|
-
page: number;
|
|
863
862
|
size: number;
|
|
863
|
+
page: number;
|
|
864
864
|
totalElements: number;
|
|
865
865
|
totalPages: number;
|
|
866
866
|
}, {
|
|
867
|
-
page: number;
|
|
868
867
|
size: number;
|
|
868
|
+
page: number;
|
|
869
869
|
totalElements: number;
|
|
870
870
|
totalPages: number;
|
|
871
871
|
}>>;
|
|
@@ -918,8 +918,8 @@ export declare const AdminJoinParticipantsResponseSchema: z.ZodObject<{
|
|
|
918
918
|
withdrawnAt?: Date | null | undefined;
|
|
919
919
|
}[][];
|
|
920
920
|
metadata?: {
|
|
921
|
-
page: number;
|
|
922
921
|
size: number;
|
|
922
|
+
page: number;
|
|
923
923
|
totalElements: number;
|
|
924
924
|
totalPages: number;
|
|
925
925
|
} | undefined;
|
|
@@ -941,8 +941,8 @@ export declare const AdminJoinParticipantsResponseSchema: z.ZodObject<{
|
|
|
941
941
|
withdrawnAt?: Date | null | undefined;
|
|
942
942
|
}[][];
|
|
943
943
|
metadata?: {
|
|
944
|
-
page: number;
|
|
945
944
|
size: number;
|
|
945
|
+
page: number;
|
|
946
946
|
totalElements: number;
|
|
947
947
|
totalPages: number;
|
|
948
948
|
} | undefined;
|
|
@@ -1013,8 +1013,8 @@ export declare const AdminJoinParticipantsResponseSchema: z.ZodObject<{
|
|
|
1013
1013
|
withdrawnAt?: Date | null | undefined;
|
|
1014
1014
|
}[][];
|
|
1015
1015
|
metadata?: {
|
|
1016
|
-
page: number;
|
|
1017
1016
|
size: number;
|
|
1017
|
+
page: number;
|
|
1018
1018
|
totalElements: number;
|
|
1019
1019
|
totalPages: number;
|
|
1020
1020
|
} | undefined;
|
|
@@ -1055,8 +1055,8 @@ export declare const AdminJoinParticipantsResponseSchema: z.ZodObject<{
|
|
|
1055
1055
|
withdrawnAt?: Date | null | undefined;
|
|
1056
1056
|
}[][];
|
|
1057
1057
|
metadata?: {
|
|
1058
|
-
page: number;
|
|
1059
1058
|
size: number;
|
|
1059
|
+
page: number;
|
|
1060
1060
|
totalElements: number;
|
|
1061
1061
|
totalPages: number;
|
|
1062
1062
|
} | undefined;
|
|
@@ -14,6 +14,7 @@ export declare class LimitedTimeOfferParticipantService {
|
|
|
14
14
|
__v: number;
|
|
15
15
|
} & import("@typegoose/typegoose/lib/types").IObjectWithTypegooseFunction)[]>;
|
|
16
16
|
private joinShop;
|
|
17
|
+
private joinShopImmediate;
|
|
17
18
|
private isCampaignLive;
|
|
18
19
|
private setupParticipantMarketing;
|
|
19
20
|
private restoreShopCapacity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limited-time-offer-participant.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAC,wBAAwB,EAAE,2BAA2B,EAAU,MAAM,2CAA2C,CAAC;AAKzH,OAAO,EACN,uBAAuB,EACvB,kBAAkB,EAElB,oBAAoB,EAEpB,MAAM,8CAA8C,CAAC;AAGtD,OAAO,EAAC,6BAA6B,EAAC,MAAM,uDAAuD,CAAC;
|
|
1
|
+
{"version":3,"file":"limited-time-offer-participant.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAC,wBAAwB,EAAE,2BAA2B,EAAU,MAAM,2CAA2C,CAAC;AAKzH,OAAO,EACN,uBAAuB,EACvB,kBAAkB,EAElB,oBAAoB,EAEpB,MAAM,8CAA8C,CAAC;AAGtD,OAAO,EAAC,6BAA6B,EAAC,MAAM,uDAAuD,CAAC;AAIpG,qBACa,kCAAkC;IAC9C,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,eAAe,CAAqB;IAC5C,OAAO,CAAC,gBAAgB,CAAiC;;IAQ5C,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,kBAAkB;IAK7D,WAAW,CAAC,OAAO,EAAE,uBAAuB,EAAE;;;;;YAK7C,QAAQ;YAmDR,iBAAiB;IAsB/B,OAAO,CAAC,cAAc;YAMR,yBAAyB;YAoBzB,mBAAmB;IAapB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBxD,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAMtE,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAmBzE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,kBAAkB;IAuC/D,eAAe,CAAC,GAAG,EAAE,6BAA6B;;;;;;;;;;;;;;;;IAQlD,6BAA6B,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ;IAIjE,SAAS,CACrB,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACnC,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE;IAWlC,8BAA8B,CAC1C,QAAQ,EAAE,YAAY,CAAC,wBAAwB,CAAC,GAC9C,OAAO,CAAC,IAAI,CAAC;YAQF,gBAAgB;IA8B9B,OAAO,CAAC,gBAAgB;YAYV,2BAA2B;YAQ3B,sBAAsB;YActB,wBAAwB;YAqBxB,0BAA0B;IAexC,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,0BAA0B;CAkBlC;AAED,eAAO,MAAM,qBAAqB,oCAAoD,CAAC"}
|
|
@@ -52,6 +52,7 @@ const limited_time_offer_participant_validation_1 = require("../limited-time-off
|
|
|
52
52
|
const limited_time_offer_participant_builder_1 = require("../limited-time-offer-participant.builder");
|
|
53
53
|
const limited_time_offer_participant_repository_1 = require("../limited-time-offer-participant.repository");
|
|
54
54
|
const core_1 = require("@lyxa.ai/core");
|
|
55
|
+
const feature_flags_1 = require("../../../../utility/feature-flags");
|
|
55
56
|
let LimitedTimeOfferParticipantService = class LimitedTimeOfferParticipantService {
|
|
56
57
|
repository;
|
|
57
58
|
campaignService;
|
|
@@ -74,6 +75,9 @@ let LimitedTimeOfferParticipantService = class LimitedTimeOfferParticipantServic
|
|
|
74
75
|
this.validateDiscountSelections({ campaign, discountPercentage: dto.discountPercentage, maxDiscountCap: dto.maxDiscountCap });
|
|
75
76
|
await this.assertProductsBelongToShop(shopId, dto);
|
|
76
77
|
const resolvedDto = await this.resolveCategorySelection(shopId, dto);
|
|
78
|
+
if (!(await (0, feature_flags_1.isLtoScheduleEnabled)())) {
|
|
79
|
+
return this.joinShopImmediate(campaign, shopId, resolvedDto);
|
|
80
|
+
}
|
|
77
81
|
const isLive = this.isCampaignLive(campaign);
|
|
78
82
|
const { marketingId, pausedMarketings } = await this.setupParticipantMarketing(campaign, shopId, resolvedDto, isLive);
|
|
79
83
|
const capacitySnapshot = isLive && resolvedDto.isOrderCapacityEnabled
|
|
@@ -93,6 +97,17 @@ let LimitedTimeOfferParticipantService = class LimitedTimeOfferParticipantServic
|
|
|
93
97
|
}
|
|
94
98
|
return participant;
|
|
95
99
|
}
|
|
100
|
+
async joinShopImmediate(campaign, shopId, resolvedDto) {
|
|
101
|
+
const marketingId = await this.marketingService.createMarketing(shopId, campaign, resolvedDto);
|
|
102
|
+
const participant = await this.repository.create(limited_time_offer_participant_builder_1.LtoParticipantQueryBuilder.buildCreateInput({
|
|
103
|
+
campaignId: campaign._id,
|
|
104
|
+
shopId,
|
|
105
|
+
marketingId,
|
|
106
|
+
dto: resolvedDto,
|
|
107
|
+
}));
|
|
108
|
+
await this.repository.updateShopOrderCapacity(shopId, resolvedDto.isOrderCapacityEnabled, resolvedDto.maxOrderCapacity);
|
|
109
|
+
return participant;
|
|
110
|
+
}
|
|
96
111
|
isCampaignLive(campaign) {
|
|
97
112
|
return campaign.status === enum_1.LimitedTimeOfferCampaignStatus.ACTIVE;
|
|
98
113
|
}
|
|
@@ -117,6 +132,8 @@ let LimitedTimeOfferParticipantService = class LimitedTimeOfferParticipantServic
|
|
|
117
132
|
if (participant.marketing) {
|
|
118
133
|
await this.marketingService.removeMarketing(participant.marketing);
|
|
119
134
|
}
|
|
135
|
+
if (!(await (0, feature_flags_1.isLtoScheduleEnabled)()))
|
|
136
|
+
return;
|
|
120
137
|
await this.marketingService.resumeMarketings((participant.pausedMarketings ?? []));
|
|
121
138
|
await this.restoreShopCapacity(participant);
|
|
122
139
|
}
|
|
@@ -148,7 +165,7 @@ let LimitedTimeOfferParticipantService = class LimitedTimeOfferParticipantServic
|
|
|
148
165
|
this.validateDiscountSelections({ campaign, discountPercentage: dto.discountPercentage, maxDiscountCap: dto.maxDiscountCap, participant });
|
|
149
166
|
await this.assertProductsBelongToShop(shopId, dto);
|
|
150
167
|
const resolvedDto = await this.resolveCategorySelection(shopId, dto);
|
|
151
|
-
const isLive = this.isCampaignLive(campaign);
|
|
168
|
+
const isLive = (await (0, feature_flags_1.isLtoScheduleEnabled)()) && this.isCampaignLive(campaign);
|
|
152
169
|
if (participant.marketingId) {
|
|
153
170
|
await this.marketingService.removeMarketing(participant.marketingId);
|
|
154
171
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limited-time-offer-participant.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAG1C,4DAAiF;AACjF,4EAAwG;AACxG,2IAAqH;AACrH,yHAAkG;AAClG,4GAMsD;AACtD,sGAAqF;AACrF,4GAAsF;AAEtF,wCAA2C;AAGpC,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IACtC,UAAU,CAA2B;IACrC,eAAe,CAAqB;IACpC,gBAAgB,CAAiC;IAEzD;QACC,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,oEAAwB,CAAC,CAAC;QAC1D,IAAI,CAAC,eAAe,GAAG,gBAAS,CAAC,GAAG,CAAC,wDAAkB,CAAC,CAAC;QACzD,IAAI,CAAC,gBAAgB,GAAG,gBAAS,CAAC,GAAG,CAAC,iFAA8B,CAAC,CAAC;IACvE,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,MAA+B,EAAE,GAAuB;QACzE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,2BAA2B,EAAE,CAAC;QAC1D,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,C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,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAClE,CAAC;IAEO,0BAA0B,CAAC,KAKlC;QACA,MAAM,EAAC,QAAQ,EAAE,kBAAkB,EAAE,cAAc,EAAE,WAAW,EAAC,GAAG,KAAK,CAAC;QAC1E,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAC5D,IAAI,CAAC,WAAW,IAAI,kBAAkB,IAAI,WAAW,CAAC,kBAAkB,EAAE,CAAC;gBAC1E,MAAM,IAAA,8BAAe,EAAC,iEAAiE,CAAC,CAAC;YAC1F,CAAC;QACF,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;YACxD,IAAI,CAAC,WAAW,IAAI,cAAc,IAAI,WAAW,CAAC,cAAc,EAAE,CAAC;gBAClE,MAAM,IAAA,8BAAe,EAAC,yEAAyE,CAAC,CAAC;YAClG,CAAC;QACF,CAAC;IACF,CAAC;CACD,CAAA;AApVY,gFAAkC;6CAAlC,kCAAkC;IAD9C,IAAA,gBAAO,GAAE;;GACG,kCAAkC,CAoV9C;AAEY,QAAA,qBAAqB,GAAG,gBAAS,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {DocumentType, mongoose} from '@typegoose/typegoose';\nimport {LimitedTimeOfferCampaign, LimitedTimeOfferParticipant, Setting} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {LimitedTimeOfferCampaignStatus} from '@lyxa.ai/core/dist/utilities/enum';\nimport {badRequestError, conflictError, notFoundError} from '@lyxa.ai/core/dist/utilities/error-common';\nimport {LtoCampaignService} from '@modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service';\nimport {LtoParticipantMarketingService} from './limited-time-offer-participant-marketing.service';\nimport {\n\tAdminEnrollShopEntryDTO,\n\tJoinLtoCampaignDTO,\n\tLtoCardState,\n\tParticipantStatusDTO,\n\tParticipantSummaryDTO,\n} from '../limited-time-offer-participant.validation';\nimport {LtoParticipantQueryBuilder} from '../limited-time-offer-participant.builder';\nimport {LtoParticipantRepository} from '../limited-time-offer-participant.repository';\nimport {GetLtoCampaignParticipantsDTO} from '../../campaign/limited-time-offer-campaign.validation';\nimport {getLibraries} from '@lyxa.ai/core';\n\n@Service()\nexport class LimitedTimeOfferParticipantService {\n\tprivate repository: LtoParticipantRepository;\n\tprivate campaignService: LtoCampaignService;\n\tprivate marketingService: LtoParticipantMarketingService;\n\n\tconstructor() {\n\t\tthis.repository = Container.get(LtoParticipantRepository);\n\t\tthis.campaignService = Container.get(LtoCampaignService);\n\t\tthis.marketingService = Container.get(LtoParticipantMarketingService);\n\t}\n\n\tpublic async join(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO) {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\t\treturn this.joinShop(campaign, shopId, dto);\n\t}\n\n\tpublic async enrollShops(entries: AdminEnrollShopEntryDTO[]) {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\t\treturn Promise.all(entries.map(({shopId, ...dto}) => this.joinShop(campaign, shopId, dto)));\n\t}\n\n\tprivate async joinShop(\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>,\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdto: JoinLtoCampaignDTO\n\t) {\n\t\tawait this.assertNotAlreadyJoined(campaign._id, shopId);\n\t\tthis.validateDiscountSelections({campaign, discountPercentage: dto.discountPercentage, maxDiscountCap: dto.maxDiscountCap});\n\t\tawait this.assertProductsBelongToShop(shopId, dto);\n\n\t\tconst resolvedDto = await this.resolveCategorySelection(shopId, dto);\n\t\tconst isLive = this.isCampaignLive(campaign);\n\n\t\t// The LTO marketing is created as soon as the shop joins (its future duration keeps it dormant\n\t\t// until the campaign runs). Pausing the shop's own discounts and overriding its order capacity\n\t\t// are deferred to activation unless the campaign is already live.\n\t\tconst {marketingId, pausedMarketings} = await this.setupParticipantMarketing(\n\t\t\tcampaign,\n\t\t\tshopId,\n\t\t\tresolvedDto,\n\t\t\tisLive\n\t\t);\n\n\t\tconst capacitySnapshot =\n\t\t\tisLive && resolvedDto.isOrderCapacityEnabled\n\t\t\t\t? await this.repository.getShopOrderCapacity(shopId)\n\t\t\t\t: undefined;\n\n\t\tconst participant = await this.repository.create(\n\t\t\tLtoParticipantQueryBuilder.buildCreateInput({\n\t\t\t\tcampaignId: campaign._id,\n\t\t\t\tshopId,\n\t\t\t\tmarketingId,\n\t\t\t\tdto: resolvedDto,\n\t\t\t\tpausedMarketings,\n\t\t\t\tpausedOrderCapacity: capacitySnapshot?.orderCapacity,\n\t\t\t\tpausedOrderCapacityEnabled: capacitySnapshot?.orderCapacityEnabled,\n\t\t\t})\n\t\t);\n\t\tif (isLive && resolvedDto.isOrderCapacityEnabled) {\n\t\t\tawait this.repository.updateShopOrderCapacity(shopId, true, resolvedDto.maxOrderCapacity);\n\t\t}\n\t\treturn participant;\n\t}\n\n\tprivate isCampaignLive(campaign: {status: LimitedTimeOfferCampaignStatus}): boolean {\n\t\treturn campaign.status === LimitedTimeOfferCampaignStatus.ACTIVE;\n\t}\n\n\t// Always creates the LTO marketing. Only pauses the shop's clashing discounts when the campaign is\n\t// live; a scheduled campaign leaves them running until it starts.\n\tprivate async setupParticipantMarketing(\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>,\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdto: JoinLtoCampaignDTO,\n\t\tisLive: boolean\n\t): Promise<{marketingId: mongoose.Types.ObjectId; pausedMarketings: mongoose.Types.ObjectId[]}> {\n\t\tif (!isLive) {\n\t\t\tconst marketingId = await this.marketingService.createMarketing(shopId, campaign, dto);\n\t\t\treturn {marketingId, pausedMarketings: []};\n\t\t}\n\t\tconst {marketingId, pausedMarketingIds} = await this.marketingService.applyMarketing(\n\t\t\tshopId,\n\t\t\tcampaign,\n\t\t\tdto\n\t\t);\n\t\treturn {marketingId, pausedMarketings: pausedMarketingIds};\n\t}\n\n\t// Puts the shop's own order-capacity config back after the LTO override ends, and clears any\n\t// capacity-induced BUSY. No-op when this participant never overrode the shop's capacity.\n\tprivate async restoreShopCapacity(participant: {\n\t\tshop: unknown;\n\t\tpausedOrderCapacity?: number;\n\t\tpausedOrderCapacityEnabled?: boolean;\n\t}): Promise<void> {\n\t\tif (participant.pausedOrderCapacityEnabled === undefined) return;\n\t\tawait this.repository.restoreShopOrderCapacity(\n\t\t\tparticipant.shop as mongoose.Types.ObjectId,\n\t\t\tparticipant.pausedOrderCapacity,\n\t\t\tparticipant.pausedOrderCapacityEnabled\n\t\t);\n\t}\n\n\tpublic async withdraw(shopId: mongoose.Types.ObjectId): Promise<void> {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\n\t\tconst participant = await this.repository.withdraw(campaign._id, shopId);\n\t\tif (!participant) throw notFoundError('You have not joined this campaign.');\n\n\t\tif (participant.marketing) {\n\t\t\tawait this.marketingService.removeMarketing(participant.marketing as mongoose.Types.ObjectId);\n\t\t}\n\t\tawait this.marketingService.resumeMarketings(\n\t\t\t(participant.pausedMarketings ?? []) as mongoose.Types.ObjectId[]\n\t\t);\n\t\tawait this.restoreShopCapacity(participant);\n\t}\n\n\tpublic async isActiveParticipant(shopId: mongoose.Types.ObjectId): Promise<boolean> {\n\t\tconst campaign = await this.campaignService.getCurrent();\n\t\tif (!campaign) return false;\n\t\treturn this.repository.existsActiveByCampaignAndShop(campaign._id, shopId);\n\t}\n\n\tpublic async getStatus(shopId: mongoose.Types.ObjectId): Promise<ParticipantStatusDTO> {\n\t\tconst campaign = await this.campaignService.getCurrent();\n\n\t\tif (!campaign) return { campaignState: LtoCardState.NONE };\n\n\t\tconst participant = await this.repository.findActiveByCampaignAndShop(campaign._id, shopId);\n\n\t\tconst campaignState =\n\t\t\tcampaign.status === LimitedTimeOfferCampaignStatus.SCHEDULED\n\t\t\t\t? LtoCardState.SCHEDULED\n\t\t\t\t: campaign.status === LimitedTimeOfferCampaignStatus.ACTIVE\n\t\t\t\t\t? LtoCardState.LIVE\n\t\t\t\t\t: LtoCardState.NONE;\n\n\t\treturn participant\n\t\t\t? { campaignState, campaign: campaign as any, participant }\n\t\t\t: { campaignState, campaign: campaign as any };\n\t}\n\n\tpublic async update(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO) {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\n\t\tconst participant = await this.repository.findActiveByCampaignAndShop(campaign._id, shopId);\n\t\tif (!participant) throw notFoundError('You have not joined this campaign.');\n\n\t\tthis.validateDiscountSelections({campaign, discountPercentage: dto.discountPercentage, maxDiscountCap: dto.maxDiscountCap, participant});\n\t\tawait this.assertProductsBelongToShop(shopId, dto);\n\n\t\tconst resolvedDto = await this.resolveCategorySelection(shopId, dto);\n\t\tconst isLive = this.isCampaignLive(campaign);\n\n\t\tif (participant.marketingId) {\n\t\t\tawait this.marketingService.removeMarketing(participant.marketingId);\n\t\t}\n\t\tconst {marketingId: newMarketingId} = await this.setupParticipantMarketing(\n\t\t\tcampaign,\n\t\t\tshopId,\n\t\t\tresolvedDto,\n\t\t\tisLive\n\t\t);\n\n\t\t// Mirrors joinShop: while the campaign is live, the shop's order-capacity override must track\n\t\t// the participant's current configuration, not just what was in effect at join/activation time.\n\t\tif (isLive && resolvedDto.isOrderCapacityEnabled) {\n\t\t\tawait this.repository.updateShopOrderCapacity(shopId, true, resolvedDto.maxOrderCapacity);\n\t\t}\n\n\t\treturn this.repository.updateParticipant(campaign._id, shopId, {\n\t\t\tproducts: resolvedDto.products ?? [],\n\t\t\tisEntireMenu: resolvedDto.isEntireMenu,\n\t\t\tdiscountPercentage: resolvedDto.discountPercentage,\n\t\t\tmaxDiscountCap: resolvedDto.maxDiscountCap,\n\t\t\tisOrderCapacityEnabled: resolvedDto.isOrderCapacityEnabled,\n\t\t\tmaxOrderCapacity: resolvedDto.maxOrderCapacity,\n\t\t\tmarketing: newMarketingId,\n\t\t});\n\t}\n\n\tpublic async getParticipants(dto: GetLtoCampaignParticipantsDTO) {\n\t\tconst {documents, total} = await this.repository.findByCampaign(dto);\n\t\treturn {\n\t\t\tdocuments,\n\t\t\tmetadata: {page: dto.page, size: dto.size, totalElements: total, totalPages: Math.ceil(total / dto.size)},\n\t\t};\n\t}\n\n\tpublic async getParticipantIdsByCampaignId(campaignId: mongoose.Types.ObjectId) {\n\t\treturn await this.repository.findParticipantIdsByCampaignId(campaignId);\n\t}\n\n\tpublic async getNearby(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tinput: { latitude: number; longitude: number }\n\t) {\n\t\tconst settings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst nearByShopDistance = settings.nearByShopDistance || 10000;\n\t\treturn this.repository.findNearby(campaignId, input, nearByShopDistance);\n\t}\n\n\t// Runs when a campaign transitions to ACTIVE. For every participant that joined while the campaign\n\t// was scheduled, this is where the deferred effects finally land: the LTO marketing is created if\n\t// it doesn't already exist (recurrence clones start without one), the shop's clashing discounts are\n\t// paused, and the order-capacity override is applied (snapshotting the shop's own config first).\n\tpublic async applyLiveEffectsToParticipants(\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>\n\t): Promise<void> {\n\t\tconst participants = await this.repository.findAllActiveByCampaign(campaign._id);\n\n\t\tfor (const participant of participants) {\n\t\t\tawait this.applyLiveEffects(campaign, participant);\n\t\t}\n\t}\n\n\tprivate async applyLiveEffects(\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>,\n\t\tparticipant: DocumentType<LimitedTimeOfferParticipant>\n\t): Promise<void> {\n\t\tconst shopId = participant.shop as mongoose.Types.ObjectId;\n\t\tconst dto = this.toParticipantDto(participant);\n\n\t\tconst marketingId = participant.marketing\n\t\t\t? (participant.marketing as mongoose.Types.ObjectId)\n\t\t\t: await this.marketingService.createMarketing(shopId, campaign, dto);\n\n\t\tconst pausedMarketings = await this.marketingService.pauseConflicts(shopId, dto);\n\n\t\tconst capacitySnapshot = dto.isOrderCapacityEnabled\n\t\t\t? await this.repository.getShopOrderCapacity(shopId)\n\t\t\t: undefined;\n\n\t\tawait this.repository.updateParticipant(campaign._id, shopId, {\n\t\t\t...dto,\n\t\t\tmarketing: marketingId,\n\t\t\tpausedMarketings,\n\t\t\tpausedOrderCapacity: capacitySnapshot?.orderCapacity,\n\t\t\tpausedOrderCapacityEnabled: capacitySnapshot?.orderCapacityEnabled,\n\t\t});\n\n\t\tif (dto.isOrderCapacityEnabled) {\n\t\t\tawait this.repository.updateShopOrderCapacity(shopId, true, participant.maxOrderCapacity);\n\t\t}\n\t}\n\n\tprivate toParticipantDto(participant: DocumentType<LimitedTimeOfferParticipant>): JoinLtoCampaignDTO {\n\t\treturn {\n\t\t\tisEntireMenu: participant.isEntireMenu,\n\t\t\tproducts: (participant.products ?? []) as mongoose.Types.ObjectId[],\n\t\t\tshopCategories: [],\n\t\t\tdiscountPercentage: participant.discountPercentage ?? 0,\n\t\t\tmaxDiscountCap: participant.maxDiscountCap ?? 0,\n\t\t\tisOrderCapacityEnabled: participant.isOrderCapacityEnabled,\n\t\t\tmaxOrderCapacity: participant.maxOrderCapacity,\n\t\t};\n\t}\n\n\tprivate async fetchCurrentCampaignOrThrow(): Promise<DocumentType<LimitedTimeOfferCampaign>> {\n\t\tconst campaign = await this.campaignService.getCurrent();\n\t\tif (!campaign) {\n\t\t\tthrow badRequestError('No campaign active or scheduled.');\n\t\t}\n\t\treturn campaign;\n\t}\n\n\tprivate async assertNotAlreadyJoined(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<void> {\n\t\tif (await this.repository.existsActiveByCampaignAndShop(campaignId, shopId)) {\n\t\t\tthrow conflictError('Your shop has already joined this campaign.');\n\t\t}\n\t}\n\n\t/**\n\t * Expands the selected shop categories into their product ids and merges them with any explicitly\n\t * selected products. The marketing layer only ever receives a flat product list, so category\n\t * selection is purely an LTO-side convenience that is resolved here before anything is persisted.\n\t */\n\tprivate async resolveCategorySelection(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdto: JoinLtoCampaignDTO\n\t): Promise<JoinLtoCampaignDTO> {\n\t\tif (dto.isEntireMenu || !dto.shopCategories?.length) return dto;\n\n\t\tconst categoryProductIds = await this.repository.findProductIdsByCategories(shopId, dto.shopCategories);\n\t\tconst products = this.uniqueObjectIds([...(dto.products ?? []), ...categoryProductIds]);\n\n\t\tif (products.length === 0) {\n\t\t\tthrow badRequestError('The selected categories do not contain any products.');\n\t\t}\n\n\t\treturn { ...dto, products };\n\t}\n\n\t/**\n\t * Validates that explicitly selected products belong to the shop. Categories are not checked here:\n\t * {@link resolveCategorySelection} fetches their products with a shop-scoped query, so any category\n\t * that does not belong to the shop simply contributes no products.\n\t */\n\tprivate async assertProductsBelongToShop(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdto: JoinLtoCampaignDTO\n\t): Promise<void> {\n\t\tif (dto.isEntireMenu) return;\n\n\t\tconst productIds = this.uniqueObjectIds(dto.products ?? []);\n\t\tif (!productIds.length) return;\n\n\t\tconst owned = await this.repository.countShopProducts(shopId, productIds);\n\t\tif (owned !== productIds.length) {\n\t\t\tthrow badRequestError('One or more selected products do not belong to your shop.');\n\t\t}\n\t}\n\n\tprivate uniqueObjectIds(ids: mongoose.Types.ObjectId[]): mongoose.Types.ObjectId[] {\n\t\treturn [...new Map(ids.map(id => [id.toString(), id])).values()];\n\t}\n\n\tprivate validateDiscountSelections(input: {\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>;\n\t\tdiscountPercentage: number;\n\t\tmaxDiscountCap: number;\n\t\tparticipant?: ParticipantSummaryDTO;\n\t}): void {\n\t\tconst {campaign, discountPercentage, maxDiscountCap, participant} = input;\n\t\tif (!campaign.discountOptions.includes(discountPercentage)) {\n\t\t\tif (!participant || discountPercentage != participant.discountPercentage) {\n\t\t\t\tthrow badRequestError('Selected discount is not an available option for this campaign.');\n\t\t\t}\n\t\t}\n\t\tif (!campaign.maxDiscountCaps.includes(maxDiscountCap)) {\n\t\t\tif (!participant || maxDiscountCap != participant.maxDiscountCap) {\n\t\t\t\tthrow badRequestError('Selected max discount cap is not an available option for this campaign.');\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport const ltoParticipantService = Container.get(LimitedTimeOfferParticipantService);\n"]}
|
|
1
|
+
{"version":3,"file":"limited-time-offer-participant.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAG1C,4DAAiF;AACjF,4EAAwG;AACxG,2IAAqH;AACrH,yHAAkG;AAClG,4GAMsD;AACtD,sGAAqF;AACrF,4GAAsF;AAEtF,wCAA2C;AAC3C,0DAA4D;AAGrD,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IACtC,UAAU,CAA2B;IACrC,eAAe,CAAqB;IACpC,gBAAgB,CAAiC;IAEzD;QACC,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,oEAAwB,CAAC,CAAC;QAC1D,IAAI,CAAC,eAAe,GAAG,gBAAS,CAAC,GAAG,CAAC,wDAAkB,CAAC,CAAC;QACzD,IAAI,CAAC,gBAAgB,GAAG,gBAAS,CAAC,GAAG,CAAC,iFAA8B,CAAC,CAAC;IACvE,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,MAA+B,EAAE,GAAuB;QACzE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,2BAA2B,EAAE,CAAC;QAC1D,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7C,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,OAAkC;QAC1D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,2BAA2B,EAAE,C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AAC;YACxD,IAAI,CAAC,WAAW,IAAI,cAAc,IAAI,WAAW,CAAC,cAAc,EAAE,CAAC;gBAClE,MAAM,IAAA,8BAAe,EAAC,yEAAyE,CAAC,CAAC;YAClG,CAAC;QACF,CAAC;IACF,CAAC;CACD,CAAA;AApXY,gFAAkC;6CAAlC,kCAAkC;IAD9C,IAAA,gBAAO,GAAE;;GACG,kCAAkC,CAoX9C;AAEY,QAAA,qBAAqB,GAAG,gBAAS,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {DocumentType, mongoose} from '@typegoose/typegoose';\nimport {LimitedTimeOfferCampaign, LimitedTimeOfferParticipant, Setting} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {LimitedTimeOfferCampaignStatus} from '@lyxa.ai/core/dist/utilities/enum';\nimport {badRequestError, conflictError, notFoundError} from '@lyxa.ai/core/dist/utilities/error-common';\nimport {LtoCampaignService} from '@modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service';\nimport {LtoParticipantMarketingService} from './limited-time-offer-participant-marketing.service';\nimport {\n\tAdminEnrollShopEntryDTO,\n\tJoinLtoCampaignDTO,\n\tLtoCardState,\n\tParticipantStatusDTO,\n\tParticipantSummaryDTO,\n} from '../limited-time-offer-participant.validation';\nimport {LtoParticipantQueryBuilder} from '../limited-time-offer-participant.builder';\nimport {LtoParticipantRepository} from '../limited-time-offer-participant.repository';\nimport {GetLtoCampaignParticipantsDTO} from '../../campaign/limited-time-offer-campaign.validation';\nimport {getLibraries} from '@lyxa.ai/core';\nimport {isLtoScheduleEnabled} from '@utility/feature-flags';\n\n@Service()\nexport class LimitedTimeOfferParticipantService {\n\tprivate repository: LtoParticipantRepository;\n\tprivate campaignService: LtoCampaignService;\n\tprivate marketingService: LtoParticipantMarketingService;\n\n\tconstructor() {\n\t\tthis.repository = Container.get(LtoParticipantRepository);\n\t\tthis.campaignService = Container.get(LtoCampaignService);\n\t\tthis.marketingService = Container.get(LtoParticipantMarketingService);\n\t}\n\n\tpublic async join(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO) {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\t\treturn this.joinShop(campaign, shopId, dto);\n\t}\n\n\tpublic async enrollShops(entries: AdminEnrollShopEntryDTO[]) {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\t\treturn Promise.all(entries.map(({shopId, ...dto}) => this.joinShop(campaign, shopId, dto)));\n\t}\n\n\tprivate async joinShop(\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>,\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdto: JoinLtoCampaignDTO\n\t) {\n\t\tawait this.assertNotAlreadyJoined(campaign._id, shopId);\n\t\tthis.validateDiscountSelections({campaign, discountPercentage: dto.discountPercentage, maxDiscountCap: dto.maxDiscountCap});\n\t\tawait this.assertProductsBelongToShop(shopId, dto);\n\n\t\tconst resolvedDto = await this.resolveCategorySelection(shopId, dto);\n\n\t\tif (!(await isLtoScheduleEnabled())) {\n\t\t\treturn this.joinShopImmediate(campaign, shopId, resolvedDto);\n\t\t}\n\n\t\tconst isLive = this.isCampaignLive(campaign);\n\n\t\t// The LTO marketing is created as soon as the shop joins (its future duration keeps it dormant\n\t\t// until the campaign runs). Pausing the shop's own discounts and overriding its order capacity\n\t\t// are deferred to activation unless the campaign is already live.\n\t\tconst {marketingId, pausedMarketings} = await this.setupParticipantMarketing(\n\t\t\tcampaign,\n\t\t\tshopId,\n\t\t\tresolvedDto,\n\t\t\tisLive\n\t\t);\n\n\t\tconst capacitySnapshot =\n\t\t\tisLive && resolvedDto.isOrderCapacityEnabled\n\t\t\t\t? await this.repository.getShopOrderCapacity(shopId)\n\t\t\t\t: undefined;\n\n\t\tconst participant = await this.repository.create(\n\t\t\tLtoParticipantQueryBuilder.buildCreateInput({\n\t\t\t\tcampaignId: campaign._id,\n\t\t\t\tshopId,\n\t\t\t\tmarketingId,\n\t\t\t\tdto: resolvedDto,\n\t\t\t\tpausedMarketings,\n\t\t\t\tpausedOrderCapacity: capacitySnapshot?.orderCapacity,\n\t\t\t\tpausedOrderCapacityEnabled: capacitySnapshot?.orderCapacityEnabled,\n\t\t\t})\n\t\t);\n\t\tif (isLive && resolvedDto.isOrderCapacityEnabled) {\n\t\t\tawait this.repository.updateShopOrderCapacity(shopId, true, resolvedDto.maxOrderCapacity);\n\t\t}\n\t\treturn participant;\n\t}\n\n\t// Flag-off path: applies the LTO marketing and order-capacity override immediately at join time,\n\t// without pausing the shop's own discounts — matching behavior before LTO scheduling was added.\n\tprivate async joinShopImmediate(\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>,\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tresolvedDto: JoinLtoCampaignDTO\n\t) {\n\t\tconst marketingId = await this.marketingService.createMarketing(shopId, campaign, resolvedDto);\n\t\tconst participant = await this.repository.create(\n\t\t\tLtoParticipantQueryBuilder.buildCreateInput({\n\t\t\t\tcampaignId: campaign._id,\n\t\t\t\tshopId,\n\t\t\t\tmarketingId,\n\t\t\t\tdto: resolvedDto,\n\t\t\t})\n\t\t);\n\t\tawait this.repository.updateShopOrderCapacity(\n\t\t\tshopId,\n\t\t\tresolvedDto.isOrderCapacityEnabled,\n\t\t\tresolvedDto.maxOrderCapacity\n\t\t);\n\t\treturn participant;\n\t}\n\n\tprivate isCampaignLive(campaign: {status: LimitedTimeOfferCampaignStatus}): boolean {\n\t\treturn campaign.status === LimitedTimeOfferCampaignStatus.ACTIVE;\n\t}\n\n\t// Always creates the LTO marketing. Only pauses the shop's clashing discounts when the campaign is\n\t// live; a scheduled campaign leaves them running until it starts.\n\tprivate async setupParticipantMarketing(\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>,\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdto: JoinLtoCampaignDTO,\n\t\tisLive: boolean\n\t): Promise<{marketingId: mongoose.Types.ObjectId; pausedMarketings: mongoose.Types.ObjectId[]}> {\n\t\tif (!isLive) {\n\t\t\tconst marketingId = await this.marketingService.createMarketing(shopId, campaign, dto);\n\t\t\treturn {marketingId, pausedMarketings: []};\n\t\t}\n\t\tconst {marketingId, pausedMarketingIds} = await this.marketingService.applyMarketing(\n\t\t\tshopId,\n\t\t\tcampaign,\n\t\t\tdto\n\t\t);\n\t\treturn {marketingId, pausedMarketings: pausedMarketingIds};\n\t}\n\n\t// Puts the shop's own order-capacity config back after the LTO override ends, and clears any\n\t// capacity-induced BUSY. No-op when this participant never overrode the shop's capacity.\n\tprivate async restoreShopCapacity(participant: {\n\t\tshop: unknown;\n\t\tpausedOrderCapacity?: number;\n\t\tpausedOrderCapacityEnabled?: boolean;\n\t}): Promise<void> {\n\t\tif (participant.pausedOrderCapacityEnabled === undefined) return;\n\t\tawait this.repository.restoreShopOrderCapacity(\n\t\t\tparticipant.shop as mongoose.Types.ObjectId,\n\t\t\tparticipant.pausedOrderCapacity,\n\t\t\tparticipant.pausedOrderCapacityEnabled\n\t\t);\n\t}\n\n\tpublic async withdraw(shopId: mongoose.Types.ObjectId): Promise<void> {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\n\t\tconst participant = await this.repository.withdraw(campaign._id, shopId);\n\t\tif (!participant) throw notFoundError('You have not joined this campaign.');\n\n\t\tif (participant.marketing) {\n\t\t\tawait this.marketingService.removeMarketing(participant.marketing as mongoose.Types.ObjectId);\n\t\t}\n\n\t\tif (!(await isLtoScheduleEnabled())) return;\n\n\t\tawait this.marketingService.resumeMarketings(\n\t\t\t(participant.pausedMarketings ?? []) as mongoose.Types.ObjectId[]\n\t\t);\n\t\tawait this.restoreShopCapacity(participant);\n\t}\n\n\tpublic async isActiveParticipant(shopId: mongoose.Types.ObjectId): Promise<boolean> {\n\t\tconst campaign = await this.campaignService.getCurrent();\n\t\tif (!campaign) return false;\n\t\treturn this.repository.existsActiveByCampaignAndShop(campaign._id, shopId);\n\t}\n\n\tpublic async getStatus(shopId: mongoose.Types.ObjectId): Promise<ParticipantStatusDTO> {\n\t\tconst campaign = await this.campaignService.getCurrent();\n\n\t\tif (!campaign) return { campaignState: LtoCardState.NONE };\n\n\t\tconst participant = await this.repository.findActiveByCampaignAndShop(campaign._id, shopId);\n\n\t\tconst campaignState =\n\t\t\tcampaign.status === LimitedTimeOfferCampaignStatus.SCHEDULED\n\t\t\t\t? LtoCardState.SCHEDULED\n\t\t\t\t: campaign.status === LimitedTimeOfferCampaignStatus.ACTIVE\n\t\t\t\t\t? LtoCardState.LIVE\n\t\t\t\t\t: LtoCardState.NONE;\n\n\t\treturn participant\n\t\t\t? { campaignState, campaign: campaign as any, participant }\n\t\t\t: { campaignState, campaign: campaign as any };\n\t}\n\n\tpublic async update(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO) {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\n\t\tconst participant = await this.repository.findActiveByCampaignAndShop(campaign._id, shopId);\n\t\tif (!participant) throw notFoundError('You have not joined this campaign.');\n\n\t\tthis.validateDiscountSelections({campaign, discountPercentage: dto.discountPercentage, maxDiscountCap: dto.maxDiscountCap, participant});\n\t\tawait this.assertProductsBelongToShop(shopId, dto);\n\n\t\tconst resolvedDto = await this.resolveCategorySelection(shopId, dto);\n\t\tconst isLive = (await isLtoScheduleEnabled()) && this.isCampaignLive(campaign);\n\n\t\tif (participant.marketingId) {\n\t\t\tawait this.marketingService.removeMarketing(participant.marketingId);\n\t\t}\n\t\tconst {marketingId: newMarketingId} = await this.setupParticipantMarketing(\n\t\t\tcampaign,\n\t\t\tshopId,\n\t\t\tresolvedDto,\n\t\t\tisLive\n\t\t);\n\n\t\t// Mirrors joinShop: while the campaign is live, the shop's order-capacity override must track\n\t\t// the participant's current configuration, not just what was in effect at join/activation time.\n\t\tif (isLive && resolvedDto.isOrderCapacityEnabled) {\n\t\t\tawait this.repository.updateShopOrderCapacity(shopId, true, resolvedDto.maxOrderCapacity);\n\t\t}\n\n\t\treturn this.repository.updateParticipant(campaign._id, shopId, {\n\t\t\tproducts: resolvedDto.products ?? [],\n\t\t\tisEntireMenu: resolvedDto.isEntireMenu,\n\t\t\tdiscountPercentage: resolvedDto.discountPercentage,\n\t\t\tmaxDiscountCap: resolvedDto.maxDiscountCap,\n\t\t\tisOrderCapacityEnabled: resolvedDto.isOrderCapacityEnabled,\n\t\t\tmaxOrderCapacity: resolvedDto.maxOrderCapacity,\n\t\t\tmarketing: newMarketingId,\n\t\t});\n\t}\n\n\tpublic async getParticipants(dto: GetLtoCampaignParticipantsDTO) {\n\t\tconst {documents, total} = await this.repository.findByCampaign(dto);\n\t\treturn {\n\t\t\tdocuments,\n\t\t\tmetadata: {page: dto.page, size: dto.size, totalElements: total, totalPages: Math.ceil(total / dto.size)},\n\t\t};\n\t}\n\n\tpublic async getParticipantIdsByCampaignId(campaignId: mongoose.Types.ObjectId) {\n\t\treturn await this.repository.findParticipantIdsByCampaignId(campaignId);\n\t}\n\n\tpublic async getNearby(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tinput: { latitude: number; longitude: number }\n\t) {\n\t\tconst settings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst nearByShopDistance = settings.nearByShopDistance || 10000;\n\t\treturn this.repository.findNearby(campaignId, input, nearByShopDistance);\n\t}\n\n\t// Runs when a campaign transitions to ACTIVE. For every participant that joined while the campaign\n\t// was scheduled, this is where the deferred effects finally land: the LTO marketing is created if\n\t// it doesn't already exist (recurrence clones start without one), the shop's clashing discounts are\n\t// paused, and the order-capacity override is applied (snapshotting the shop's own config first).\n\tpublic async applyLiveEffectsToParticipants(\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>\n\t): Promise<void> {\n\t\tconst participants = await this.repository.findAllActiveByCampaign(campaign._id);\n\n\t\tfor (const participant of participants) {\n\t\t\tawait this.applyLiveEffects(campaign, participant);\n\t\t}\n\t}\n\n\tprivate async applyLiveEffects(\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>,\n\t\tparticipant: DocumentType<LimitedTimeOfferParticipant>\n\t): Promise<void> {\n\t\tconst shopId = participant.shop as mongoose.Types.ObjectId;\n\t\tconst dto = this.toParticipantDto(participant);\n\n\t\tconst marketingId = participant.marketing\n\t\t\t? (participant.marketing as mongoose.Types.ObjectId)\n\t\t\t: await this.marketingService.createMarketing(shopId, campaign, dto);\n\n\t\tconst pausedMarketings = await this.marketingService.pauseConflicts(shopId, dto);\n\n\t\tconst capacitySnapshot = dto.isOrderCapacityEnabled\n\t\t\t? await this.repository.getShopOrderCapacity(shopId)\n\t\t\t: undefined;\n\n\t\tawait this.repository.updateParticipant(campaign._id, shopId, {\n\t\t\t...dto,\n\t\t\tmarketing: marketingId,\n\t\t\tpausedMarketings,\n\t\t\tpausedOrderCapacity: capacitySnapshot?.orderCapacity,\n\t\t\tpausedOrderCapacityEnabled: capacitySnapshot?.orderCapacityEnabled,\n\t\t});\n\n\t\tif (dto.isOrderCapacityEnabled) {\n\t\t\tawait this.repository.updateShopOrderCapacity(shopId, true, participant.maxOrderCapacity);\n\t\t}\n\t}\n\n\tprivate toParticipantDto(participant: DocumentType<LimitedTimeOfferParticipant>): JoinLtoCampaignDTO {\n\t\treturn {\n\t\t\tisEntireMenu: participant.isEntireMenu,\n\t\t\tproducts: (participant.products ?? []) as mongoose.Types.ObjectId[],\n\t\t\tshopCategories: [],\n\t\t\tdiscountPercentage: participant.discountPercentage ?? 0,\n\t\t\tmaxDiscountCap: participant.maxDiscountCap ?? 0,\n\t\t\tisOrderCapacityEnabled: participant.isOrderCapacityEnabled,\n\t\t\tmaxOrderCapacity: participant.maxOrderCapacity,\n\t\t};\n\t}\n\n\tprivate async fetchCurrentCampaignOrThrow(): Promise<DocumentType<LimitedTimeOfferCampaign>> {\n\t\tconst campaign = await this.campaignService.getCurrent();\n\t\tif (!campaign) {\n\t\t\tthrow badRequestError('No campaign active or scheduled.');\n\t\t}\n\t\treturn campaign;\n\t}\n\n\tprivate async assertNotAlreadyJoined(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<void> {\n\t\tif (await this.repository.existsActiveByCampaignAndShop(campaignId, shopId)) {\n\t\t\tthrow conflictError('Your shop has already joined this campaign.');\n\t\t}\n\t}\n\n\t/**\n\t * Expands the selected shop categories into their product ids and merges them with any explicitly\n\t * selected products. The marketing layer only ever receives a flat product list, so category\n\t * selection is purely an LTO-side convenience that is resolved here before anything is persisted.\n\t */\n\tprivate async resolveCategorySelection(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdto: JoinLtoCampaignDTO\n\t): Promise<JoinLtoCampaignDTO> {\n\t\tif (dto.isEntireMenu || !dto.shopCategories?.length) return dto;\n\n\t\tconst categoryProductIds = await this.repository.findProductIdsByCategories(shopId, dto.shopCategories);\n\t\tconst products = this.uniqueObjectIds([...(dto.products ?? []), ...categoryProductIds]);\n\n\t\tif (products.length === 0) {\n\t\t\tthrow badRequestError('The selected categories do not contain any products.');\n\t\t}\n\n\t\treturn { ...dto, products };\n\t}\n\n\t/**\n\t * Validates that explicitly selected products belong to the shop. Categories are not checked here:\n\t * {@link resolveCategorySelection} fetches their products with a shop-scoped query, so any category\n\t * that does not belong to the shop simply contributes no products.\n\t */\n\tprivate async assertProductsBelongToShop(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdto: JoinLtoCampaignDTO\n\t): Promise<void> {\n\t\tif (dto.isEntireMenu) return;\n\n\t\tconst productIds = this.uniqueObjectIds(dto.products ?? []);\n\t\tif (!productIds.length) return;\n\n\t\tconst owned = await this.repository.countShopProducts(shopId, productIds);\n\t\tif (owned !== productIds.length) {\n\t\t\tthrow badRequestError('One or more selected products do not belong to your shop.');\n\t\t}\n\t}\n\n\tprivate uniqueObjectIds(ids: mongoose.Types.ObjectId[]): mongoose.Types.ObjectId[] {\n\t\treturn [...new Map(ids.map(id => [id.toString(), id])).values()];\n\t}\n\n\tprivate validateDiscountSelections(input: {\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>;\n\t\tdiscountPercentage: number;\n\t\tmaxDiscountCap: number;\n\t\tparticipant?: ParticipantSummaryDTO;\n\t}): void {\n\t\tconst {campaign, discountPercentage, maxDiscountCap, participant} = input;\n\t\tif (!campaign.discountOptions.includes(discountPercentage)) {\n\t\t\tif (!participant || discountPercentage != participant.discountPercentage) {\n\t\t\t\tthrow badRequestError('Selected discount is not an available option for this campaign.');\n\t\t\t}\n\t\t}\n\t\tif (!campaign.maxDiscountCaps.includes(maxDiscountCap)) {\n\t\t\tif (!participant || maxDiscountCap != participant.maxDiscountCap) {\n\t\t\t\tthrow badRequestError('Selected max discount cap is not an available option for this campaign.');\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport const ltoParticipantService = Container.get(LimitedTimeOfferParticipantService);\n"]}
|
|
@@ -39,15 +39,15 @@ export declare const marketingRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
39
39
|
}>;
|
|
40
40
|
get: import("@trpc/server").TRPCQueryProcedure<{
|
|
41
41
|
input: {
|
|
42
|
+
sort?: Record<string, 1 | -1> | undefined;
|
|
42
43
|
search?: {
|
|
43
44
|
searchKey: string;
|
|
44
45
|
searchFields?: string[] | undefined;
|
|
45
46
|
} | undefined;
|
|
46
|
-
sort?: Record<string, 1 | -1> | undefined;
|
|
47
|
-
page?: number | undefined;
|
|
48
47
|
select?: Record<string, 0 | 1> | undefined;
|
|
49
|
-
size?: number | undefined;
|
|
50
48
|
populate?: any;
|
|
49
|
+
size?: number | undefined;
|
|
50
|
+
page?: number | undefined;
|
|
51
51
|
query?: Record<string, any> | undefined;
|
|
52
52
|
} | undefined;
|
|
53
53
|
output: {
|
|
@@ -237,6 +237,17 @@ export declare const marketingRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
237
237
|
};
|
|
238
238
|
meta: object;
|
|
239
239
|
}>;
|
|
240
|
+
getSpendToGetTiers: import("@trpc/server").TRPCQueryProcedure<{
|
|
241
|
+
input: {
|
|
242
|
+
shop: string | mongoose.Types.ObjectId;
|
|
243
|
+
};
|
|
244
|
+
output: {
|
|
245
|
+
success: boolean;
|
|
246
|
+
message: string;
|
|
247
|
+
data: import("../../marketing/services").SpendToGetTiersResult | undefined;
|
|
248
|
+
};
|
|
249
|
+
meta: object;
|
|
250
|
+
}>;
|
|
240
251
|
reseedEntireMenuMarketing: import("@trpc/server").TRPCMutationProcedure<{
|
|
241
252
|
input: string | mongoose.Types.ObjectId;
|
|
242
253
|
output: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marketing.router.d.ts","sourceRoot":"/","sources":["modules/marketing/routers/marketing.router.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"marketing.router.d.ts","sourceRoot":"/","sources":["modules/marketing/routers/marketing.router.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAMR,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgKnB,CAAC"}
|
|
@@ -104,6 +104,10 @@ exports.marketingRouter = (0, trpc_1.createTRPCRouter)({
|
|
|
104
104
|
const result = await services_3.spendToGetProgressService.getProgress(input);
|
|
105
105
|
return (0, response_1.response)('Spend to get progress fetched successfully', result);
|
|
106
106
|
})),
|
|
107
|
+
getSpendToGetTiers: trpc_1.publicProcedure.input(validations_1.SpendToGetTiersInputSchema).query(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
|
|
108
|
+
const result = await services_3.spendToGetProgressService.getTiers(input.shop);
|
|
109
|
+
return (0, response_1.response)('Spend to get tiers fetched successfully', result);
|
|
110
|
+
})),
|
|
107
111
|
reseedEntireMenuMarketing: (0, auth_1.createAuthenticatedProcedure)({ entityTypes: [auth_2.AuthEntityType.CRM] })
|
|
108
112
|
.input(validation_1.IdSchema)
|
|
109
113
|
.output(validations_1.MarketingResponseSchema)
|