@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
|
@@ -47,8 +47,6 @@ const typedi_1 = __importStar(require("typedi"));
|
|
|
47
47
|
const core_1 = require("@lyxa.ai/core");
|
|
48
48
|
const models_1 = require("@lyxa.ai/core/dist/libraries/mongo/models");
|
|
49
49
|
const product_pipeline_stages_1 = require("@lyxa.ai/core/dist/utilities/pipelines/product-pipeline-stages");
|
|
50
|
-
const common_pipeline_functions_1 = require("@lyxa.ai/core/dist/utilities/pipelines/common-pipeline-functions");
|
|
51
|
-
const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
|
|
52
50
|
const events_common_methods_1 = require("@lyxa.ai/core/dist/utilities/events-common-methods");
|
|
53
51
|
const TAG = 'marketing.seed.entire-menu';
|
|
54
52
|
let SynchronizeProductMarketingService = class SynchronizeProductMarketingService {
|
|
@@ -200,116 +198,50 @@ let SynchronizeProductMarketingService = class SynchronizeProductMarketingServic
|
|
|
200
198
|
const exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;
|
|
201
199
|
const secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';
|
|
202
200
|
const BATCH_SIZE = 500;
|
|
203
|
-
const now = new Date();
|
|
204
201
|
const results = [];
|
|
202
|
+
const totalBatches = Math.ceil(productIds.length / BATCH_SIZE);
|
|
205
203
|
for (let i = 0; i < productIds.length; i += BATCH_SIZE) {
|
|
206
204
|
const batchIds = productIds.slice(i, i + BATCH_SIZE);
|
|
207
|
-
const batchResults = await this.
|
|
208
|
-
{ $match: { product: { $in: batchIds }, deletedAt: null } },
|
|
205
|
+
const batchResults = await this.productModel.aggregate([
|
|
209
206
|
{
|
|
210
|
-
$
|
|
211
|
-
|
|
212
|
-
let: { mid: '$marketing' },
|
|
213
|
-
pipeline: [
|
|
214
|
-
{
|
|
215
|
-
$match: {
|
|
216
|
-
$expr: { $eq: ['$_id', '$$mid'] },
|
|
217
|
-
status: 'active',
|
|
218
|
-
'duration.start': { $lte: now },
|
|
219
|
-
'duration.end': { $gte: now },
|
|
220
|
-
},
|
|
221
|
-
},
|
|
222
|
-
{ $project: { marketingType: 1, duration: 1, isAppliedByCompany: 1 } },
|
|
223
|
-
],
|
|
224
|
-
as: 'marketing',
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
{ $unwind: '$marketing' },
|
|
228
|
-
{
|
|
229
|
-
$addFields: {
|
|
230
|
-
secondaryCurrencyValue: {
|
|
231
|
-
$cond: [
|
|
232
|
-
{ $eq: ['$valueType', 'fixed'] },
|
|
233
|
-
(0, common_pipeline_functions_1.getRoundSecondaryCurrencyStage)({ $multiply: ['$value', exchangeRate] }),
|
|
234
|
-
'$$REMOVE',
|
|
235
|
-
],
|
|
236
|
-
},
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
$addFields: {
|
|
241
|
-
label: {
|
|
242
|
-
$switch: {
|
|
243
|
-
branches: [
|
|
244
|
-
{ case: { $eq: ['$marketing.marketingType', enum_1.MarketingType.BUY1GET1] }, then: 'Buy 1 Get 1' },
|
|
245
|
-
{ case: { $eq: ['$marketing.marketingType', enum_1.MarketingType.PUNCH_MARKETING] }, then: 'Punch' },
|
|
246
|
-
{
|
|
247
|
-
case: { $eq: ['$marketing.marketingType', enum_1.MarketingType.DISCOUNT] },
|
|
248
|
-
then: {
|
|
249
|
-
$switch: {
|
|
250
|
-
branches: [
|
|
251
|
-
{
|
|
252
|
-
case: { $eq: ['$valueType', enum_1.ValueType.FIXED] },
|
|
253
|
-
then: { $concat: [secondaryCurrencyName, ' ', { $toString: '$secondaryCurrencyValue' }] },
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
case: { $eq: ['$valueType', enum_1.ValueType.PERCENTAGE] },
|
|
257
|
-
then: { $concat: [{ $toString: '$value' }, '%'] },
|
|
258
|
-
},
|
|
259
|
-
],
|
|
260
|
-
default: 'Discount',
|
|
261
|
-
},
|
|
262
|
-
},
|
|
263
|
-
},
|
|
264
|
-
],
|
|
265
|
-
default: '$marketing.marketingType',
|
|
266
|
-
},
|
|
267
|
-
},
|
|
207
|
+
$match: {
|
|
208
|
+
_id: { $in: batchIds },
|
|
268
209
|
},
|
|
269
210
|
},
|
|
211
|
+
...(0, product_pipeline_stages_1.addProductMarketingInfo)(exchangeRate, secondaryCurrencyName),
|
|
270
212
|
{
|
|
271
213
|
$group: {
|
|
272
|
-
_id: '$
|
|
214
|
+
_id: '$_id',
|
|
273
215
|
productMarketingInfo: {
|
|
274
|
-
$push:
|
|
275
|
-
marketing: {
|
|
276
|
-
_id: '$marketing._id',
|
|
277
|
-
marketingType: '$marketing.marketingType',
|
|
278
|
-
duration: '$marketing.duration',
|
|
279
|
-
},
|
|
280
|
-
isBuy1Get1: '$isBuy1Get1',
|
|
281
|
-
valueType: '$valueType',
|
|
282
|
-
value: '$value',
|
|
283
|
-
secondaryCurrencyValue: '$secondaryCurrencyValue',
|
|
284
|
-
label: '$label',
|
|
285
|
-
isAppliedByCompany: '$marketing.isAppliedByCompany',
|
|
286
|
-
},
|
|
216
|
+
$push: '$productMarketing',
|
|
287
217
|
},
|
|
288
218
|
},
|
|
289
219
|
},
|
|
290
220
|
]);
|
|
291
221
|
results.push(...batchResults);
|
|
292
222
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
223
|
+
if (!results.length)
|
|
224
|
+
return 'No matching products found';
|
|
225
|
+
const bulkOps = results.map(product => {
|
|
226
|
+
const productMarketingInfo = (product.productMarketingInfo || []).map((pm) => ({
|
|
227
|
+
marketing: pm.marketingInfo,
|
|
228
|
+
isBuy1Get1: pm.isBuy1Get1,
|
|
229
|
+
valueType: pm.valueType,
|
|
230
|
+
value: pm.value,
|
|
231
|
+
secondaryCurrencyValue: pm.secondaryCurrencyValue,
|
|
232
|
+
label: pm.label,
|
|
233
|
+
isAppliedByCompany: pm.isAppliedByCompany ?? false,
|
|
234
|
+
}));
|
|
235
|
+
return {
|
|
236
|
+
updateOne: {
|
|
237
|
+
filter: { _id: product._id },
|
|
238
|
+
update: {
|
|
239
|
+
$set: { productMarketingInfo },
|
|
308
240
|
},
|
|
309
241
|
},
|
|
310
|
-
}
|
|
311
|
-
})
|
|
312
|
-
await this.productModel.bulkWrite(bulkOps
|
|
242
|
+
};
|
|
243
|
+
});
|
|
244
|
+
await this.productModel.bulkWrite(bulkOps);
|
|
313
245
|
return `Synchronized product marketing info for ${bulkOps.length} products`;
|
|
314
246
|
}
|
|
315
247
|
async syncProductMarketingInfoByMarketingIds(marketingIds) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synchronize-product-marketing.service.js","sourceRoot":"/","sources":["modules/marketing/services/synchronize-product-marketing.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAC5C,wCAA6C;AAG7C,sEAMmD;AACnD,4GAAyG;AACzG,gHAAkH;AAClH,4DAA6E;AAC7E,8FAAwH;AAGxH,MAAM,GAAG,GAAG,4BAA4B,CAAC;AAGlC,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IACtC,YAAY,CAA+C;IAC3D,qBAAqB,CAAmE;IAEhG;QACC,IAAI,CAAC,YAAY,GAAG,qBAA4D,CAAC;QACjF,IAAI,CAAC,qBAAqB,GAAG,8BACK,CAAC;IACpC,CAAC;IAEM,KAAK,CAAC,kDAAkD;QAC9D,MAAM,IAAA,0EAAkD,EAAC,EAAE,CAAC,CAAC;QAC7D,OAAO,yDAAyD,CAAC;IAClE,CAAC;IAEM,2CAA2C,CACjD,OAAsD;QAEtD,IAAI,CAAC,4BAA4B,EAAE,CAAC;QACpC,OAAO,yDAAyD,CAAC;IAClE,CAAC;IAEM,4BAA4B,GAAG,KAAK,IAAkB,EAAE;QAC9D,MAAM,MAAM,GAAG,IAAA,mBAAY,GAAE,CAAC,YAAY,EAAE,CAAC;QAC7C,MAAM,UAAU,GAAG,GAAG,CAAC;QAEvB,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,gCAAgC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,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oCAAoC,CAAC,UAAU,CAAC,CAAC;IACpE,CAAC;CACD,CAAA;AAnUY,gFAAkC;6CAAlC,kCAAkC;IAD9C,IAAA,gBAAO,GAAE;;GACG,kCAAkC,CAmU9C;AAEY,QAAA,kCAAkC,GAAG,gBAAS,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { getLibraries } from '@lyxa.ai/core';\nimport { mongoose } from '@typegoose/typegoose';\nimport { SoftDeleteModel } from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport {\n\tProductModel,\n\tProduct as Model,\n\tSetting,\n\tProductMarketingModel,\n\tProductMarketing,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport { addProductMarketingInfo } from '@lyxa.ai/core/dist/utilities/pipelines/product-pipeline-stages';\nimport { getRoundSecondaryCurrencyStage } from '@lyxa.ai/core/dist/utilities/pipelines/common-pipeline-functions';\nimport { MarketingType, ValueType } from '@lyxa.ai/core/dist/utilities/enum';\nimport { publishAllProductsProductMarketingInfoProcessEvent } from '@lyxa.ai/core/dist/utilities/events-common-methods';\nimport { SynchronizeAllProductsProductMarketingInfoDTO } from '@lyxa.ai/core/dist/libraries/event/events/sync-all-products-product-marketing-info-event';\n\nconst TAG = 'marketing.seed.entire-menu';\n\n@Service()\nexport class SynchronizeProductMarketingService {\n\tprivate productModel: typeof ProductModel & SoftDeleteModel<Model>;\n\tprivate productMarketingModel: typeof ProductMarketingModel & SoftDeleteModel<ProductMarketing>;\n\n\tconstructor() {\n\t\tthis.productModel = ProductModel as typeof ProductModel & SoftDeleteModel<Model>;\n\t\tthis.productMarketingModel = ProductMarketingModel as typeof ProductMarketingModel &\n\t\t\tSoftDeleteModel<ProductMarketing>;\n\t}\n\n\tpublic async publishAllProductsProductMarketingInfoProcessEvent() {\n\t\tawait publishAllProductsProductMarketingInfoProcessEvent({});\n\t\treturn 'Processing all products product marketing information! ';\n\t}\n\n\tpublic processAllProductsProductMarketingInfoEvent(\n\t\tpayload: SynchronizeAllProductsProductMarketingInfoDTO\n\t): string {\n\t\tthis.syncAllProductsMarketingInfo();\n\t\treturn 'Processing all products product marketing information! ';\n\t}\n\n\tpublic syncAllProductsMarketingInfo = async (): Promise<any> => {\n\t\tconst logger = getLibraries().getLoggerKit();\n\t\tconst CHUNK_SIZE = 500;\n\n\t\tconst cursor = this.productModel.find().select('_id shop price priceBreakdowns').lean().cursor();\n\n\t\tconst adminSettings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;\n\t\tconst secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';\n\n\t\tlet batch: any[] = [];\n\t\tlet batchIndex = 0;\n\t\tlet totalProcessed = 0;\n\n\t\tfor await (const product of cursor) {\n\t\t\tbatch.push(product);\n\n\t\t\tif (batch.length === CHUNK_SIZE) {\n\t\t\t\tbatchIndex++;\n\t\t\t\ttotalProcessed += batch.length;\n\t\t\t\tawait this.processProductsBatch(batch, exchangeRate, secondaryCurrencyName, batchIndex);\n\t\t\t\tbatch = [];\n\t\t\t}\n\t\t}\n\n\t\tif (batch.length) {\n\t\t\tbatchIndex++;\n\t\t\ttotalProcessed += batch.length;\n\t\t\tawait this.processProductsBatch(batch, exchangeRate, secondaryCurrencyName, batchIndex);\n\t\t}\n\n\t\tlogger.debug('full product marketing sync complete', {\n\t\t\ttag: TAG,\n\t\t\tdata: { totalProducts: totalProcessed },\n\t\t});\n\n\t\treturn 'Bulk product marketing info sync completed';\n\t};\n\n\tprivate async processProductsBatch(\n\t\tproductsBatch: any[],\n\t\texchangeRate: number,\n\t\tsecondaryCurrencyName: string,\n\t\tbatchIndex: number\n\t): Promise<void> {\n\t\tconst productIds = productsBatch.map(p => p._id);\n\n\t\tconst results = await this.productModel.aggregate([\n\t\t\t{ $match: { _id: { $in: productIds } } },\n\t\t\t...addProductMarketingInfo(exchangeRate, secondaryCurrencyName),\n\t\t\t{\n\t\t\t\t$group: {\n\t\t\t\t\t_id: '$_id',\n\t\t\t\t\tproductMarketingInfo: { $push: '$productMarketing' },\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\n\t\tconst bulkOps = results.map(r => ({\n\t\t\tupdateOne: {\n\t\t\t\tfilter: { _id: r._id },\n\t\t\t\tupdate: {\n\t\t\t\t\t$set: {\n\t\t\t\t\t\tproductMarketingInfo: (r.productMarketingInfo ?? []).filter(Boolean).map((pm: any) => ({\n\t\t\t\t\t\t\tmarketing: pm.marketingInfo,\n\t\t\t\t\t\t\tisBuy1Get1: pm.isBuy1Get1,\n\t\t\t\t\t\t\tvalueType: pm.valueType,\n\t\t\t\t\t\t\tvalue: pm.value,\n\t\t\t\t\t\t\tsecondaryCurrencyValue: pm.secondaryCurrencyValue,\n\t\t\t\t\t\t\tlabel: pm.label,\n\t\t\t\t\t\t\tisAppliedByCompany: pm.isAppliedByCompany ?? false,\n\t\t\t\t\t\t})),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t}));\n\n\t\tif (bulkOps.length) {\n\t\t\tawait this.productModel.bulkWrite(bulkOps, { ordered: false });\n\t\t}\n\t}\n\n\tprivate async getProductMarketingInfoByProductId(productId: mongoose.Types.ObjectId): Promise<any[]> {\n\t\tconst adminSettings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\n\t\tconst exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;\n\t\tconst secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';\n\n\t\tconst result = await this.productModel.aggregate([\n\t\t\t{\n\t\t\t\t$match: { _id: productId },\n\t\t\t},\n\t\t\t...addProductMarketingInfo(exchangeRate, secondaryCurrencyName),\n\t\t\t{\n\t\t\t\t$group: {\n\t\t\t\t\t_id: '$_id',\n\t\t\t\t\tproductMarketingInfo: {\n\t\t\t\t\t\t$push: '$productMarketing',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\n\t\tconst productMarketingInfo = result?.[0]?.productMarketing\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tmarketing: result?.[0].productMarketing.marketingInfo,\n\t\t\t\t\t\tisBuy1Get1: result?.[0].productMarketing.isBuy1Get1,\n\t\t\t\t\t\tvalueType: result?.[0].productMarketing.valueType,\n\t\t\t\t\t\tvalue: result?.[0].productMarketing.value,\n\t\t\t\t\t\tsecondaryCurrencyValue: result?.[0].productMarketing.secondaryCurrencyValue,\n\t\t\t\t\t\tlabel: result?.[0].productMarketing.label,\n\t\t\t\t\t\tisAppliedByCompany: result?.[0].productMarketing.isAppliedByCompany ?? false,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t: [];\n\n\t\treturn productMarketingInfo;\n\t}\n\n\tpublic async syncProductMarketingInfoByProductId(productId: mongoose.Types.ObjectId) {\n\t\tconst adminSettings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;\n\n\t\tconst secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';\n\t\tconst result = await this.productModel.aggregate([\n\t\t\t{\n\t\t\t\t$match: {\n\t\t\t\t\t_id: productId,\n\t\t\t\t},\n\t\t\t},\n\t\t\t...addProductMarketingInfo(exchangeRate, secondaryCurrencyName),\n\t\t]);\n\n\t\tconst productMarketingInfo = (result || [])\n\t\t\t.filter(item => item?.productMarketing)\n\t\t\t.map(item => ({\n\t\t\t\tmarketing: item.productMarketing.marketingInfo,\n\t\t\t\tisBuy1Get1: item.productMarketing.isBuy1Get1,\n\t\t\t\tvalueType: item.productMarketing.valueType,\n\t\t\t\tvalue: item.productMarketing.value,\n\t\t\t\tsecondaryCurrencyValue: item.productMarketing.secondaryCurrencyValue,\n\t\t\t\tlabel: item.productMarketing.label,\n\t\t\t\tisAppliedByCompany: item.productMarketing.isAppliedByCompany ?? false,\n\t\t\t}));\n\n\t\tawait this.productModel.updateOne(\n\t\t\t{ _id: productId },\n\t\t\t{\n\t\t\t\t$set: {\n\t\t\t\t\tproductMarketingInfo,\n\t\t\t\t},\n\t\t\t}\n\t\t);\n\t\treturn 'Synchronized product marketing info';\n\t}\n\n\tpublic async syncProductMarketingInfoByProductIds(productIds: mongoose.Types.ObjectId[]) {\n\t\tif (!productIds.length) return 'No products to sync';\n\n\t\tconst adminSettings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;\n\t\tconst secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';\n\n\t\tconst BATCH_SIZE = 500;\n\t\tconst now = new Date();\n\t\tconst results: any[] = [];\n\n\t\tfor (let i = 0; i < productIds.length; i += BATCH_SIZE) {\n\t\t\tconst batchIds = productIds.slice(i, i + BATCH_SIZE);\n\n\t\t\t// Inverted join: scan productMarketings once per batch (grouped by product) instead of\n\t\t\t// one correlated $lookup per product (the old product-first addProductMarketingInfo path).\n\t\t\tconst batchResults = await this.productMarketingModel.aggregate([\n\t\t\t\t{ $match: { product: { $in: batchIds }, deletedAt: null } },\n\t\t\t\t{\n\t\t\t\t\t$lookup: {\n\t\t\t\t\t\tfrom: 'marketings',\n\t\t\t\t\t\tlet: { mid: '$marketing' },\n\t\t\t\t\t\tpipeline: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t\t$expr: { $eq: ['$_id', '$$mid'] }, // joins on indexed _id\n\t\t\t\t\t\t\t\t\tstatus: 'active',\n\t\t\t\t\t\t\t\t\t'duration.start': { $lte: now },\n\t\t\t\t\t\t\t\t\t'duration.end': { $gte: now },\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ $project: { marketingType: 1, duration: 1, isAppliedByCompany: 1 } },\n\t\t\t\t\t\t],\n\t\t\t\t\t\tas: 'marketing',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{ $unwind: '$marketing' }, // drops productMarketings whose marketing isn't active\n\t\t\t\t{\n\t\t\t\t\t$addFields: {\n\t\t\t\t\t\tsecondaryCurrencyValue: {\n\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t{ $eq: ['$valueType', 'fixed'] },\n\t\t\t\t\t\t\t\tgetRoundSecondaryCurrencyStage({ $multiply: ['$value', exchangeRate] }),\n\t\t\t\t\t\t\t\t'$$REMOVE',\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t$addFields: {\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\t$switch: {\n\t\t\t\t\t\t\t\tbranches: [\n\t\t\t\t\t\t\t\t\t{ case: { $eq: ['$marketing.marketingType', MarketingType.BUY1GET1] }, then: 'Buy 1 Get 1' },\n\t\t\t\t\t\t\t\t\t{ case: { $eq: ['$marketing.marketingType', MarketingType.PUNCH_MARKETING] }, then: 'Punch' },\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$marketing.marketingType', MarketingType.DISCOUNT] },\n\t\t\t\t\t\t\t\t\t\tthen: {\n\t\t\t\t\t\t\t\t\t\t\t$switch: {\n\t\t\t\t\t\t\t\t\t\t\t\tbranches: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$valueType', ValueType.FIXED] },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen: { $concat: [secondaryCurrencyName, ' ', { $toString: '$secondaryCurrencyValue' }] },\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$valueType', ValueType.PERCENTAGE] },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen: { $concat: [{ $toString: '$value' }, '%'] },\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\tdefault: 'Discount',\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tdefault: '$marketing.marketingType',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t$group: {\n\t\t\t\t\t\t_id: '$product',\n\t\t\t\t\t\tproductMarketingInfo: {\n\t\t\t\t\t\t\t$push: {\n\t\t\t\t\t\t\t\tmarketing: {\n\t\t\t\t\t\t\t\t\t_id: '$marketing._id',\n\t\t\t\t\t\t\t\t\tmarketingType: '$marketing.marketingType',\n\t\t\t\t\t\t\t\t\tduration: '$marketing.duration',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tisBuy1Get1: '$isBuy1Get1',\n\t\t\t\t\t\t\t\tvalueType: '$valueType',\n\t\t\t\t\t\t\t\tvalue: '$value',\n\t\t\t\t\t\t\t\tsecondaryCurrencyValue: '$secondaryCurrencyValue',\n\t\t\t\t\t\t\t\tlabel: '$label',\n\t\t\t\t\t\t\t\tisAppliedByCompany: '$marketing.isAppliedByCompany',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t]);\n\n\t\t\tresults.push(...batchResults);\n\t\t}\n\n\t\t// Products with no active marketing left aren't returned by the aggregate above, so reset\n\t\t// them to [] explicitly — keeps the recompute self-healing for the delete/update callers.\n\t\tconst byProduct = new Map<string, any[]>(results.map(r => [r._id.toString(), r.productMarketingInfo ?? []]));\n\n\t\tconst bulkOps = productIds.map(productId => ({\n\t\t\tupdateOne: {\n\t\t\t\tfilter: { _id: productId },\n\t\t\t\tupdate: {\n\t\t\t\t\t$set: {\n\t\t\t\t\t\tproductMarketingInfo: (byProduct.get(productId.toString()) ?? []).map((pm: any) => ({\n\t\t\t\t\t\t\tmarketing: pm.marketing,\n\t\t\t\t\t\t\tisBuy1Get1: pm.isBuy1Get1,\n\t\t\t\t\t\t\tvalueType: pm.valueType,\n\t\t\t\t\t\t\tvalue: pm.value,\n\t\t\t\t\t\t\tsecondaryCurrencyValue: pm.secondaryCurrencyValue,\n\t\t\t\t\t\t\tlabel: pm.label,\n\t\t\t\t\t\t\tisAppliedByCompany: pm.isAppliedByCompany ?? false,\n\t\t\t\t\t\t})),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t}));\n\n\t\tawait this.productModel.bulkWrite(bulkOps, { ordered: false });\n\n\t\treturn `Synchronized product marketing info for ${bulkOps.length} products`;\n\t}\n\n\tpublic async syncProductMarketingInfoByMarketingIds(marketingIds: mongoose.Types.ObjectId[]) {\n\t\tif (!marketingIds.length) return 'No marketings to sync';\n\n\t\tconst productsToUpdate = await this.productMarketingModel\n\t\t\t.find({ marketing: { $in: marketingIds } })\n\t\t\t.select('product')\n\t\t\t.lean();\n\t\tif (!productsToUpdate.length) return 'No matching products found';\n\n\t\tconst productIds = productsToUpdate.map(p => p.product._id);\n\t\treturn await this.syncProductMarketingInfoByProductIds(productIds);\n\t}\n}\n\nexport const synchronizeProductMarketingService = Container.get(SynchronizeProductMarketingService);\n"]}
|
|
1
|
+
{"version":3,"file":"synchronize-product-marketing.service.js","sourceRoot":"/","sources":["modules/marketing/services/synchronize-product-marketing.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAC5C,wCAA6C;AAG7C,sEAMmD;AACnD,4GAAyG;AACzG,8FAAwH;AAGxH,MAAM,GAAG,GAAG,4BAA4B,CAAC;AAGlC,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IACtC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typegoose/typegoose';\nimport { SoftDeleteModel } from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport {\n\tProductModel,\n\tProduct as Model,\n\tSetting,\n\tProductMarketingModel,\n\tProductMarketing,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport { addProductMarketingInfo } from '@lyxa.ai/core/dist/utilities/pipelines/product-pipeline-stages';\nimport { publishAllProductsProductMarketingInfoProcessEvent } from '@lyxa.ai/core/dist/utilities/events-common-methods';\nimport { SynchronizeAllProductsProductMarketingInfoDTO } from '@lyxa.ai/core/dist/libraries/event/events/sync-all-products-product-marketing-info-event';\n\nconst TAG = 'marketing.seed.entire-menu';\n\n@Service()\nexport class SynchronizeProductMarketingService {\n\tprivate productModel: typeof ProductModel & SoftDeleteModel<Model>;\n\tprivate productMarketingModel: typeof ProductMarketingModel & SoftDeleteModel<ProductMarketing>;\n\n\tconstructor() {\n\t\tthis.productModel = ProductModel as typeof ProductModel & SoftDeleteModel<Model>;\n\t\tthis.productMarketingModel = ProductMarketingModel as typeof ProductMarketingModel &\n\t\t\tSoftDeleteModel<ProductMarketing>;\n\t}\n\n\tpublic async publishAllProductsProductMarketingInfoProcessEvent() {\n\t\tawait publishAllProductsProductMarketingInfoProcessEvent({});\n\t\treturn 'Processing all products product marketing information! ';\n\t}\n\n\tpublic processAllProductsProductMarketingInfoEvent(\n\t\tpayload: SynchronizeAllProductsProductMarketingInfoDTO\n\t): string {\n\t\tthis.syncAllProductsMarketingInfo();\n\t\treturn 'Processing all products product marketing information! ';\n\t}\n\n\tpublic syncAllProductsMarketingInfo = async (): Promise<any> => {\n\t\tconst logger = getLibraries().getLoggerKit();\n\t\tconst CHUNK_SIZE = 500;\n\n\t\tconst cursor = this.productModel.find().select('_id shop price priceBreakdowns').lean().cursor();\n\n\t\tconst adminSettings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;\n\t\tconst secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';\n\n\t\tlet batch: any[] = [];\n\t\tlet batchIndex = 0;\n\t\tlet totalProcessed = 0;\n\n\t\tfor await (const product of cursor) {\n\t\t\tbatch.push(product);\n\n\t\t\tif (batch.length === CHUNK_SIZE) {\n\t\t\t\tbatchIndex++;\n\t\t\t\ttotalProcessed += batch.length;\n\t\t\t\tawait this.processProductsBatch(batch, exchangeRate, secondaryCurrencyName, batchIndex);\n\t\t\t\tbatch = [];\n\t\t\t}\n\t\t}\n\n\t\tif (batch.length) {\n\t\t\tbatchIndex++;\n\t\t\ttotalProcessed += batch.length;\n\t\t\tawait this.processProductsBatch(batch, exchangeRate, secondaryCurrencyName, batchIndex);\n\t\t}\n\n\t\tlogger.debug('full product marketing sync complete', {\n\t\t\ttag: TAG,\n\t\t\tdata: { totalProducts: totalProcessed },\n\t\t});\n\n\t\treturn 'Bulk product marketing info sync completed';\n\t};\n\n\tprivate async processProductsBatch(\n\t\tproductsBatch: any[],\n\t\texchangeRate: number,\n\t\tsecondaryCurrencyName: string,\n\t\tbatchIndex: number\n\t): Promise<void> {\n\t\tconst productIds = productsBatch.map(p => p._id);\n\n\t\tconst results = await this.productModel.aggregate([\n\t\t\t{ $match: { _id: { $in: productIds } } },\n\t\t\t...addProductMarketingInfo(exchangeRate, secondaryCurrencyName),\n\t\t\t{\n\t\t\t\t$group: {\n\t\t\t\t\t_id: '$_id',\n\t\t\t\t\tproductMarketingInfo: { $push: '$productMarketing' },\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\n\t\tconst bulkOps = results.map(r => ({\n\t\t\tupdateOne: {\n\t\t\t\tfilter: { _id: r._id },\n\t\t\t\tupdate: {\n\t\t\t\t\t$set: {\n\t\t\t\t\t\tproductMarketingInfo: (r.productMarketingInfo ?? []).filter(Boolean).map((pm: any) => ({\n\t\t\t\t\t\t\tmarketing: pm.marketingInfo,\n\t\t\t\t\t\t\tisBuy1Get1: pm.isBuy1Get1,\n\t\t\t\t\t\t\tvalueType: pm.valueType,\n\t\t\t\t\t\t\tvalue: pm.value,\n\t\t\t\t\t\t\tsecondaryCurrencyValue: pm.secondaryCurrencyValue,\n\t\t\t\t\t\t\tlabel: pm.label,\n\t\t\t\t\t\t\tisAppliedByCompany: pm.isAppliedByCompany ?? false,\n\t\t\t\t\t\t})),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t}));\n\n\t\tif (bulkOps.length) {\n\t\t\tawait this.productModel.bulkWrite(bulkOps, { ordered: false });\n\t\t}\n\t}\n\n\tprivate async getProductMarketingInfoByProductId(productId: mongoose.Types.ObjectId): Promise<any[]> {\n\t\tconst adminSettings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\n\t\tconst exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;\n\t\tconst secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';\n\n\t\tconst result = await this.productModel.aggregate([\n\t\t\t{\n\t\t\t\t$match: { _id: productId },\n\t\t\t},\n\t\t\t...addProductMarketingInfo(exchangeRate, secondaryCurrencyName),\n\t\t\t{\n\t\t\t\t$group: {\n\t\t\t\t\t_id: '$_id',\n\t\t\t\t\tproductMarketingInfo: {\n\t\t\t\t\t\t$push: '$productMarketing',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\n\t\tconst productMarketingInfo = result?.[0]?.productMarketing\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tmarketing: result?.[0].productMarketing.marketingInfo,\n\t\t\t\t\t\tisBuy1Get1: result?.[0].productMarketing.isBuy1Get1,\n\t\t\t\t\t\tvalueType: result?.[0].productMarketing.valueType,\n\t\t\t\t\t\tvalue: result?.[0].productMarketing.value,\n\t\t\t\t\t\tsecondaryCurrencyValue: result?.[0].productMarketing.secondaryCurrencyValue,\n\t\t\t\t\t\tlabel: result?.[0].productMarketing.label,\n\t\t\t\t\t\tisAppliedByCompany: result?.[0].productMarketing.isAppliedByCompany ?? false,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t: [];\n\n\t\treturn productMarketingInfo;\n\t}\n\n\tpublic async syncProductMarketingInfoByProductId(productId: mongoose.Types.ObjectId) {\n\t\tconst adminSettings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;\n\n\t\tconst secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';\n\t\tconst result = await this.productModel.aggregate([\n\t\t\t{\n\t\t\t\t$match: {\n\t\t\t\t\t_id: productId,\n\t\t\t\t},\n\t\t\t},\n\t\t\t...addProductMarketingInfo(exchangeRate, secondaryCurrencyName),\n\t\t]);\n\n\t\tconst productMarketingInfo = (result || [])\n\t\t\t.filter(item => item?.productMarketing)\n\t\t\t.map(item => ({\n\t\t\t\tmarketing: item.productMarketing.marketingInfo,\n\t\t\t\tisBuy1Get1: item.productMarketing.isBuy1Get1,\n\t\t\t\tvalueType: item.productMarketing.valueType,\n\t\t\t\tvalue: item.productMarketing.value,\n\t\t\t\tsecondaryCurrencyValue: item.productMarketing.secondaryCurrencyValue,\n\t\t\t\tlabel: item.productMarketing.label,\n\t\t\t\tisAppliedByCompany: item.productMarketing.isAppliedByCompany ?? false,\n\t\t\t}));\n\n\t\tawait this.productModel.updateOne(\n\t\t\t{ _id: productId },\n\t\t\t{\n\t\t\t\t$set: {\n\t\t\t\t\tproductMarketingInfo,\n\t\t\t\t},\n\t\t\t}\n\t\t);\n\t\treturn 'Synchronized product marketing info';\n\t}\n\n\tpublic async syncProductMarketingInfoByProductIds(productIds: mongoose.Types.ObjectId[]) {\n\t\tif (!productIds.length) return 'No products to sync';\n\n\t\tconst adminSettings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;\n\t\tconst secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';\n\n\t\tconst BATCH_SIZE = 500;\n\t\tconst results: any[] = [];\n\t\tconst totalBatches = Math.ceil(productIds.length / BATCH_SIZE);\n\n\t\tfor (let i = 0; i < productIds.length; i += BATCH_SIZE) {\n\t\t\tconst batchIds = productIds.slice(i, i + BATCH_SIZE);\n\n\t\t\tconst batchResults = await this.productModel.aggregate([\n\t\t\t\t{\n\t\t\t\t\t$match: {\n\t\t\t\t\t\t_id: { $in: batchIds },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t...addProductMarketingInfo(exchangeRate, secondaryCurrencyName),\n\t\t\t\t{\n\t\t\t\t\t$group: {\n\t\t\t\t\t\t_id: '$_id',\n\t\t\t\t\t\tproductMarketingInfo: {\n\t\t\t\t\t\t\t$push: '$productMarketing',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t]);\n\n\t\t\tresults.push(...batchResults);\n\t\t}\n\n\t\tif (!results.length) return 'No matching products found';\n\n\t\tconst bulkOps = results.map(product => {\n\t\t\tconst productMarketingInfo = (product.productMarketingInfo || []).map((pm: any) => ({\n\t\t\t\tmarketing: pm.marketingInfo,\n\t\t\t\tisBuy1Get1: pm.isBuy1Get1,\n\t\t\t\tvalueType: pm.valueType,\n\t\t\t\tvalue: pm.value,\n\t\t\t\tsecondaryCurrencyValue: pm.secondaryCurrencyValue,\n\t\t\t\tlabel: pm.label,\n\t\t\t\tisAppliedByCompany: pm.isAppliedByCompany ?? false,\n\t\t\t}));\n\n\t\t\treturn {\n\t\t\t\tupdateOne: {\n\t\t\t\t\tfilter: { _id: product._id },\n\t\t\t\t\tupdate: {\n\t\t\t\t\t\t$set: { productMarketingInfo },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t});\n\n\t\tawait this.productModel.bulkWrite(bulkOps);\n\n\t\treturn `Synchronized product marketing info for ${bulkOps.length} products`;\n\t}\n\n\tpublic async syncProductMarketingInfoByMarketingIds(marketingIds: mongoose.Types.ObjectId[]) {\n\t\tif (!marketingIds.length) return 'No marketings to sync';\n\n\t\tconst productsToUpdate = await this.productMarketingModel\n\t\t\t.find({ marketing: { $in: marketingIds } })\n\t\t\t.select('product')\n\t\t\t.lean();\n\t\tif (!productsToUpdate.length) return 'No matching products found';\n\n\t\tconst productIds = productsToUpdate.map(p => p.product._id);\n\t\treturn await this.syncProductMarketingInfoByProductIds(productIds);\n\t}\n}\n\nexport const synchronizeProductMarketingService = Container.get(SynchronizeProductMarketingService);\n"]}
|
|
@@ -12,13 +12,13 @@ export declare const MarketingResponseSchema: z.ZodObject<{
|
|
|
12
12
|
totalElements: z.ZodNumber;
|
|
13
13
|
totalPages: z.ZodNumber;
|
|
14
14
|
}, "strip", z.ZodTypeAny, {
|
|
15
|
-
page: number;
|
|
16
15
|
size: number;
|
|
16
|
+
page: number;
|
|
17
17
|
totalElements: number;
|
|
18
18
|
totalPages: number;
|
|
19
19
|
}, {
|
|
20
|
-
page: number;
|
|
21
20
|
size: number;
|
|
21
|
+
page: number;
|
|
22
22
|
totalElements: number;
|
|
23
23
|
totalPages: number;
|
|
24
24
|
}>>;
|
|
@@ -26,16 +26,16 @@ export declare const MarketingResponseSchema: z.ZodObject<{
|
|
|
26
26
|
}, "strip", z.ZodTypeAny, {
|
|
27
27
|
documents: any[];
|
|
28
28
|
metadata?: {
|
|
29
|
-
page: number;
|
|
30
29
|
size: number;
|
|
30
|
+
page: number;
|
|
31
31
|
totalElements: number;
|
|
32
32
|
totalPages: number;
|
|
33
33
|
} | undefined;
|
|
34
34
|
}, {
|
|
35
35
|
documents: any[];
|
|
36
36
|
metadata?: {
|
|
37
|
-
page: number;
|
|
38
37
|
size: number;
|
|
38
|
+
page: number;
|
|
39
39
|
totalElements: number;
|
|
40
40
|
totalPages: number;
|
|
41
41
|
} | undefined;
|
|
@@ -59,7 +59,6 @@ declare const Buy1Get1MarketingValidationSchema: z.ZodObject<{
|
|
|
59
59
|
isAppliedByCompany: boolean;
|
|
60
60
|
isEntireMenu: boolean;
|
|
61
61
|
pausedAt: Date | null;
|
|
62
|
-
marketingType: MarketingType.BUY1GET1;
|
|
63
62
|
products: {
|
|
64
63
|
product: import("mongoose").Types.ObjectId;
|
|
65
64
|
value?: number | undefined;
|
|
@@ -68,6 +67,7 @@ declare const Buy1Get1MarketingValidationSchema: z.ZodObject<{
|
|
|
68
67
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
69
68
|
isBuy1Get1?: boolean | undefined;
|
|
70
69
|
}[];
|
|
70
|
+
marketingType: MarketingType.BUY1GET1;
|
|
71
71
|
excludeProducts: import("mongoose").Types.ObjectId[];
|
|
72
72
|
isOnlyForSubscriber: boolean;
|
|
73
73
|
admin?: import("mongoose").Types.ObjectId | null | undefined;
|
|
@@ -437,7 +437,6 @@ declare const Buy1Get1MarketingValidationSchemaRefined: z.ZodEffects<z.ZodObject
|
|
|
437
437
|
isAppliedByCompany: boolean;
|
|
438
438
|
isEntireMenu: boolean;
|
|
439
439
|
pausedAt: Date | null;
|
|
440
|
-
marketingType: MarketingType.BUY1GET1;
|
|
441
440
|
products: {
|
|
442
441
|
product: import("mongoose").Types.ObjectId;
|
|
443
442
|
value?: number | undefined;
|
|
@@ -446,6 +445,7 @@ declare const Buy1Get1MarketingValidationSchemaRefined: z.ZodEffects<z.ZodObject
|
|
|
446
445
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
447
446
|
isBuy1Get1?: boolean | undefined;
|
|
448
447
|
}[];
|
|
448
|
+
marketingType: MarketingType.BUY1GET1;
|
|
449
449
|
excludeProducts: import("mongoose").Types.ObjectId[];
|
|
450
450
|
isOnlyForSubscriber: boolean;
|
|
451
451
|
admin?: import("mongoose").Types.ObjectId | null | undefined;
|
|
@@ -487,7 +487,6 @@ declare const Buy1Get1MarketingValidationSchemaRefined: z.ZodEffects<z.ZodObject
|
|
|
487
487
|
isAppliedByCompany: boolean;
|
|
488
488
|
isEntireMenu: boolean;
|
|
489
489
|
pausedAt: Date | null;
|
|
490
|
-
marketingType: MarketingType.BUY1GET1;
|
|
491
490
|
products: {
|
|
492
491
|
product: import("mongoose").Types.ObjectId;
|
|
493
492
|
value?: number | undefined;
|
|
@@ -496,6 +495,7 @@ declare const Buy1Get1MarketingValidationSchemaRefined: z.ZodEffects<z.ZodObject
|
|
|
496
495
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
497
496
|
isBuy1Get1?: boolean | undefined;
|
|
498
497
|
}[];
|
|
498
|
+
marketingType: MarketingType.BUY1GET1;
|
|
499
499
|
excludeProducts: import("mongoose").Types.ObjectId[];
|
|
500
500
|
isOnlyForSubscriber: boolean;
|
|
501
501
|
admin?: import("mongoose").Types.ObjectId | null | undefined;
|
|
@@ -67,7 +67,6 @@ declare const DiscountMarketingValidationSchema: z.ZodObject<{
|
|
|
67
67
|
isMaxDiscountPerOrderEnabled: boolean;
|
|
68
68
|
maxDiscountPerOrder: number;
|
|
69
69
|
pausedAt: Date | null;
|
|
70
|
-
marketingType: MarketingType.DISCOUNT;
|
|
71
70
|
products: {
|
|
72
71
|
product: import("mongoose").Types.ObjectId;
|
|
73
72
|
value?: number | undefined;
|
|
@@ -76,6 +75,7 @@ declare const DiscountMarketingValidationSchema: z.ZodObject<{
|
|
|
76
75
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
77
76
|
isBuy1Get1?: boolean | undefined;
|
|
78
77
|
}[];
|
|
78
|
+
marketingType: MarketingType.DISCOUNT;
|
|
79
79
|
excludeProducts: import("mongoose").Types.ObjectId[];
|
|
80
80
|
isOnlyForSubscriber: boolean;
|
|
81
81
|
value?: number | undefined;
|
|
@@ -337,7 +337,6 @@ declare const DiscountMarketingValidationSchemaRefined: z.ZodEffects<z.ZodObject
|
|
|
337
337
|
isMaxDiscountPerOrderEnabled: boolean;
|
|
338
338
|
maxDiscountPerOrder: number;
|
|
339
339
|
pausedAt: Date | null;
|
|
340
|
-
marketingType: MarketingType.DISCOUNT;
|
|
341
340
|
products: {
|
|
342
341
|
product: import("mongoose").Types.ObjectId;
|
|
343
342
|
value?: number | undefined;
|
|
@@ -346,6 +345,7 @@ declare const DiscountMarketingValidationSchemaRefined: z.ZodEffects<z.ZodObject
|
|
|
346
345
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
347
346
|
isBuy1Get1?: boolean | undefined;
|
|
348
347
|
}[];
|
|
348
|
+
marketingType: MarketingType.DISCOUNT;
|
|
349
349
|
excludeProducts: import("mongoose").Types.ObjectId[];
|
|
350
350
|
isOnlyForSubscriber: boolean;
|
|
351
351
|
value?: number | undefined;
|
|
@@ -399,7 +399,6 @@ declare const DiscountMarketingValidationSchemaRefined: z.ZodEffects<z.ZodObject
|
|
|
399
399
|
isMaxDiscountPerOrderEnabled: boolean;
|
|
400
400
|
maxDiscountPerOrder: number;
|
|
401
401
|
pausedAt: Date | null;
|
|
402
|
-
marketingType: MarketingType.DISCOUNT;
|
|
403
402
|
products: {
|
|
404
403
|
product: import("mongoose").Types.ObjectId;
|
|
405
404
|
value?: number | undefined;
|
|
@@ -408,6 +407,7 @@ declare const DiscountMarketingValidationSchemaRefined: z.ZodEffects<z.ZodObject
|
|
|
408
407
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
409
408
|
isBuy1Get1?: boolean | undefined;
|
|
410
409
|
}[];
|
|
410
|
+
marketingType: MarketingType.DISCOUNT;
|
|
411
411
|
excludeProducts: import("mongoose").Types.ObjectId[];
|
|
412
412
|
isOnlyForSubscriber: boolean;
|
|
413
413
|
value?: number | undefined;
|
|
@@ -197,6 +197,13 @@ export declare const SpendToGetProgressInputSchema: z.ZodObject<{
|
|
|
197
197
|
basketTotal: number;
|
|
198
198
|
userId?: string | import("mongoose").Types.ObjectId | undefined;
|
|
199
199
|
}>;
|
|
200
|
+
export declare const SpendToGetTiersInputSchema: z.ZodObject<{
|
|
201
|
+
shop: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>;
|
|
202
|
+
}, "strip", z.ZodTypeAny, {
|
|
203
|
+
shop: import("mongoose").Types.ObjectId;
|
|
204
|
+
}, {
|
|
205
|
+
shop: string | import("mongoose").Types.ObjectId;
|
|
206
|
+
}>;
|
|
200
207
|
export declare const MarketingSpendLimitsEvaluationSchema: z.ZodObject<{
|
|
201
208
|
marketings: z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>, "many">;
|
|
202
209
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -324,6 +331,7 @@ export type MarketingDTO = DTO<typeof MarketingSchema>;
|
|
|
324
331
|
export type UpdateMarketingDTO = DTO<typeof UpdateMarketingSchema>;
|
|
325
332
|
export type ProductEntireMenuMarketingHandlerDTO = DTO<typeof ProductEntireMenuMarketingHandlerSchema>;
|
|
326
333
|
export type SpendToGetProgressInputDTO = DTO<typeof SpendToGetProgressInputSchema>;
|
|
334
|
+
export type SpendToGetTiersInputDTO = DTO<typeof SpendToGetTiersInputSchema>;
|
|
327
335
|
export type IncreaseDuringDiscountDTO = DTO<typeof IncreaseDuringDiscountSchema>;
|
|
328
336
|
export type MarketingMetricsDTO = DTO<typeof MarketingMetricsSchema>;
|
|
329
337
|
export type MarketingGraphInputDTO = DTO<typeof MarketingGraphInputSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marketing.validation.d.ts","sourceRoot":"/","sources":["modules/marketing/validations/marketing.validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAGN,GAAG,EACH,MAAM,2DAA2D,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAO9F,eAA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vG,MAAM,MAAM,0BAA0B,GAAG,GAAG,CAAC,OAAO,6BAA6B,CAAC,CAAC;AACnF,MAAM,MAAM,yBAAyB,GAAG,GAAG,CAAC,OAAO,4BAA4B,CAAC,CAAC;AACjF,MAAM,MAAM,mBAAmB,GAAG,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACrE,MAAM,MAAM,sBAAsB,GAAG,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC3E,MAAM,MAAM,6BAA6B,GAAG,GAAG,CAAC,OAAO,gCAAgC,CAAC,CAAC;AACzF,MAAM,MAAM,gCAAgC,GAAG,GAAG,CAAC,OAAO,mCAAmC,CAAC,CAAC;AAC/F,MAAM,MAAM,kCAAkC,GAAG,GAAG,CAAC,OAAO,qCAAqC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"marketing.validation.d.ts","sourceRoot":"/","sources":["modules/marketing/validations/marketing.validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAGN,GAAG,EACH,MAAM,2DAA2D,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAO9F,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;CAQ/B,CAAC;AAYF,QAAA,MACa,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACvB,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCACnB,iBAAiB,mNACb,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCACgB,CAAC;AAKrD,OAAO,EACN,yBAAyB,EACzB,eAAe,EACf,iBAAiB,IAAI,2BAA2B,EAChD,qBAAqB,GACrB,CAAC;AAEF,eAAO,MAAM,uCAAuC;;;;;;;;;EAGlD,CAAC;AA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C,CAAC,CAAC;AACzF,MAAM,MAAM,gCAAgC,GAAG,GAAG,CAAC,OAAO,mCAAmC,CAAC,CAAC;AAC/F,MAAM,MAAM,kCAAkC,GAAG,GAAG,CAAC,OAAO,qCAAqC,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MarketingAmountSpentGraphOutputSchema = exports.MarketingCustomersGraphOutputSchema = exports.MarketingOrdersGraphOutputSchema = exports.MarketingGraphInputSchema = exports.MarketingMetricsSchema = exports.IncreaseDuringDiscountSchema = exports.SyncProductMarketingForMultipleProductsSchema = exports.MarketingSpendLimitsEvaluationSchema = exports.SpendToGetProgressInputSchema = exports.ProductEntireMenuMarketingHandlerSchema = exports.UpdateMarketingSchema = exports.MarketingIdValidationSchema = exports.MarketingSchema = exports.MarketingValidationSchema = exports.baseMarketingFields = void 0;
|
|
3
|
+
exports.MarketingAmountSpentGraphOutputSchema = exports.MarketingCustomersGraphOutputSchema = exports.MarketingOrdersGraphOutputSchema = exports.MarketingGraphInputSchema = exports.MarketingMetricsSchema = exports.IncreaseDuringDiscountSchema = exports.SyncProductMarketingForMultipleProductsSchema = exports.MarketingSpendLimitsEvaluationSchema = exports.SpendToGetTiersInputSchema = exports.SpendToGetProgressInputSchema = exports.ProductEntireMenuMarketingHandlerSchema = exports.UpdateMarketingSchema = exports.MarketingIdValidationSchema = exports.MarketingSchema = exports.MarketingValidationSchema = exports.baseMarketingFields = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const global_validation_1 = require("@lyxa.ai/core/dist/utilities/validation/global-validation");
|
|
6
6
|
const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
|
|
@@ -30,6 +30,9 @@ exports.SpendToGetProgressInputSchema = zod_1.z.object({
|
|
|
30
30
|
basketTotal: global_validation_1.ZodValidation.number('Basket total', { isNonnegative: true }),
|
|
31
31
|
userId: global_validation_1.ZodValidation.objectId('User').optional(),
|
|
32
32
|
});
|
|
33
|
+
exports.SpendToGetTiersInputSchema = zod_1.z.object({
|
|
34
|
+
shop: global_validation_1.ZodValidation.objectId('Shop'),
|
|
35
|
+
});
|
|
33
36
|
exports.MarketingSpendLimitsEvaluationSchema = zod_1.z.object({
|
|
34
37
|
marketings: global_validation_1.ZodValidation.array(global_validation_1.ZodValidation.objectId('marketing'), 'marketings'),
|
|
35
38
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marketing.validation.js","sourceRoot":"/","sources":["modules/marketing/validations/marketing.validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,iGAImE;AACnE,4DAA8F;AAC9F,iGAA2F;AAC3F,8DAA2D;AAK9C,QAAA,mBAAmB,GAAG;IAClC,IAAI,EAAE,iCAAa,CAAC,QAAQ,CAAC,MAAM,CAAC;IACpC,aAAa,EAAE,iCAAa,CAAC,QAAQ,CAAC,oBAAa,EAAE,gBAAgB,CAAC;IACtE,kBAAkB,EAAE,iCAAa,CAAC,OAAO,CAAC,oBAAoB,CAAC;IAC/D,QAAQ,EAAE,kCAAc;IACxB,MAAM,EAAE,iCAAa,CAAC,QAAQ,CAAC,sBAAe,EAAE,kBAAkB,CAAC,CAAC,OAAO,CAAC,sBAAe,CAAC,MAAM,CAAC;IACnG,QAAQ,EAAE,iCAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAC7E,KAAK,EAAE,iCAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CAC5D,CAAC;AAOF,MAAM,aAAa,GAAG,IAAA,uCAAmB,EAAC,2BAAmB,CAAC,CAAC;AAK/D,MAAM,EACL,UAAU,EAAE,yBAAyB,EACrC,YAAY,EAAE,eAAe,EAC7B,QAAQ,EAAE,iBAAiB,EAC3B,Y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,iCAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;CACjD,CAAC,CACF,CAAC;AAEW,QAAA,mCAAmC,GAAG,OAAC,CAAC,KAAK,CACzD,OAAC,CAAC,MAAM,CAAC;IACR,IAAI,EAAE,iCAAa,CAAC,MAAM,CAAC,MAAM,CAAC;IAClC,SAAS,EAAE,iCAAa,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;CACvD,CAAC,CACF,CAAC;AAEW,QAAA,qCAAqC,GAAG,OAAC,CAAC,KAAK,CAC3D,OAAC,CAAC,MAAM,CAAC;IACR,IAAI,EAAE,iCAAa,CAAC,MAAM,CAAC,MAAM,CAAC;IAClC,MAAM,EAAE,iCAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;CACjD,CAAC,CACF,CAAC","sourcesContent":["import { z } from 'zod';\nimport {\n\tZodValidation,\n\tcreateSchemaBuilder,\n\tDTO,\n} from '@lyxa.ai/core/dist/utilities/validation/global-validation';\nimport { GraphType, MarketingStatus, MarketingType } from '@lyxa.ai/core/dist/utilities/enum';\nimport { DurationSchema } from '@lyxa.ai/core/dist/utilities/validation/common-validation';\nimport { dayjs } from '@lyxa.ai/core/dist/utilities/dayjs';\n\n/**\n * Define the base parent schema fields\n */\nexport const baseMarketingFields = {\n\tshop: ZodValidation.objectId('Shop'),\n\tmarketingType: ZodValidation.enumType(MarketingType, 'Marketing type'),\n\tisAppliedByCompany: ZodValidation.boolean('isAppliedByCompany'),\n\tduration: DurationSchema,\n\tstatus: ZodValidation.enumType(MarketingStatus, 'Marketing status').default(MarketingStatus.ACTIVE),\n\tpausedAt: ZodValidation.date('Paused at').optional().nullable().default(null),\n\tadmin: ZodValidation.objectId('Admin').optional().nullable(),\n};\n\n/**\n * Create schema builder for Parent entity\n * - Includes timestamps\n * - Excludes 'createdAt' from update operations\n */\nconst schemaBuilder = createSchemaBuilder(baseMarketingFields);\n\n/**\n * Get all schemas for the Parent entity\n */\nconst {\n\tBaseSchema: MarketingValidationSchema,\n\tEntitySchema: MarketingSchema,\n\tIdSchema: MarketingIdSchema,\n\tUpdateSchema: UpdateMarketingSchema,\n} = schemaBuilder.getAllSchemas({ createdAt: true });\n\n/**\n * Export schemas\n */\nexport {\n\tMarketingValidationSchema,\n\tMarketingSchema,\n\tMarketingIdSchema as MarketingIdValidationSchema,\n\tUpdateMarketingSchema,\n};\n\nexport const ProductEntireMenuMarketingHandlerSchema = z.object({\n\tproduct: ZodValidation.objectId('Product'),\n\tshop: ZodValidation.objectId('Shop'),\n});\n\nexport const SpendToGetProgressInputSchema = z.object({\n\tshop: ZodValidation.objectId('Shop'),\n\tbasketTotal: ZodValidation.number('Basket total', { isNonnegative: true }),\n\tuserId: ZodValidation.objectId('User').optional(),\n});\n\nexport const MarketingSpendLimitsEvaluationSchema = z.object({\n\tmarketings: ZodValidation.array(ZodValidation.objectId('marketing'), 'marketings'),\n});\n\nexport const SyncProductMarketingForMultipleProductsSchema = z.object({\n\tproductIds: ZodValidation.array(ZodValidation.objectId('product id'), 'product ids'),\n});\n\nexport const IncreaseDuringDiscountSchema = z.object({\n\tcount: ZodValidation.number('Count of orders or customers during discount').optional().default(0),\n\tpercentageIncrease: ZodValidation.number('Percentage increase compared to previous duration')\n\t\t.optional()\n\t\t.default(0),\n});\n\nexport const MarketingMetricsSchema = z.object({\n\tnumberOfItems: ZodValidation.number('Number of items in the marketing').optional(),\n\torderIncreaseWithDiscount: IncreaseDuringDiscountSchema.optional(),\n\tcustomerIncreaseWithDiscount: IncreaseDuringDiscountSchema.optional(),\n\ttotalRedemptions: ZodValidation.number('Total redemptions').optional(),\n\ttotalValueGiven: ZodValidation.number('Total discount/free delivery value given').optional(),\n\tremainingBudget: ZodValidation.number('Remaining spend-limit budget').optional(),\n});\n\nexport const MarketingGraphInputSchema = z.object({\n\tmarketingId: ZodValidation.objectIdOrStringSchema,\n\tstartDate: ZodValidation.date('Start Date').transform(val => dayjs(val).startOf('day').toDate()),\n\tendDate: ZodValidation.date('End Date').transform(val => dayjs(val).endOf('day').toDate()),\n\ttype: ZodValidation.enumType(GraphType, 'Type').default(GraphType.DAILY),\n});\n\nexport const MarketingOrdersGraphOutputSchema = z.array(\n\tz.object({\n\t\tdate: ZodValidation.string('Date'),\n\t\torders: ZodValidation.number('Orders').default(0),\n\t})\n);\n\nexport const MarketingCustomersGraphOutputSchema = z.array(\n\tz.object({\n\t\tdate: ZodValidation.string('Date'),\n\t\tcustomers: ZodValidation.number('Customers').default(0),\n\t})\n);\n\nexport const MarketingAmountSpentGraphOutputSchema = z.array(\n\tz.object({\n\t\tdate: ZodValidation.string('Date'),\n\t\tamount: ZodValidation.number('Amount').default(0),\n\t})\n);\n\n/**\n * Export DTO types\n */\nexport type CreateMarketingDTO = DTO<typeof MarketingValidationSchema>;\nexport type MarketingDTO = DTO<typeof MarketingSchema>;\nexport type UpdateMarketingDTO = DTO<typeof UpdateMarketingSchema>;\nexport type ProductEntireMenuMarketingHandlerDTO = DTO<typeof ProductEntireMenuMarketingHandlerSchema>;\nexport type SpendToGetProgressInputDTO = DTO<typeof SpendToGetProgressInputSchema>;\nexport type IncreaseDuringDiscountDTO = DTO<typeof IncreaseDuringDiscountSchema>;\nexport type MarketingMetricsDTO = DTO<typeof MarketingMetricsSchema>;\nexport type MarketingGraphInputDTO = DTO<typeof MarketingGraphInputSchema>;\nexport type MarketingOrdersGraphOutputDTO = DTO<typeof MarketingOrdersGraphOutputSchema>;\nexport type MarketingCustomersGraphOutputDTO = DTO<typeof MarketingCustomersGraphOutputSchema>;\nexport type MarketingAmountSpentGraphOutputDTO = DTO<typeof MarketingAmountSpentGraphOutputSchema>;"]}
|
|
1
|
+
{"version":3,"file":"marketing.validation.js","sourceRoot":"/","sources":["modules/marketing/validations/marketing.validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,iGAImE;AACnE,4DAA8F;AAC9F,iGAA2F;AA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,QAAA,qCAAqC,GAAG,OAAC,CAAC,KAAK,CAC3D,OAAC,CAAC,MAAM,CAAC;IACR,IAAI,EAAE,iCAAa,CAAC,MAAM,CAAC,MAAM,CAAC;IAClC,MAAM,EAAE,iCAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;CACjD,CAAC,CACF,CAAC","sourcesContent":["import { z } from 'zod';\nimport {\n\tZodValidation,\n\tcreateSchemaBuilder,\n\tDTO,\n} from '@lyxa.ai/core/dist/utilities/validation/global-validation';\nimport { GraphType, MarketingStatus, MarketingType } from '@lyxa.ai/core/dist/utilities/enum';\nimport { DurationSchema } from '@lyxa.ai/core/dist/utilities/validation/common-validation';\nimport { dayjs } from '@lyxa.ai/core/dist/utilities/dayjs';\n\n/**\n * Define the base parent schema fields\n */\nexport const baseMarketingFields = {\n\tshop: ZodValidation.objectId('Shop'),\n\tmarketingType: ZodValidation.enumType(MarketingType, 'Marketing type'),\n\tisAppliedByCompany: ZodValidation.boolean('isAppliedByCompany'),\n\tduration: DurationSchema,\n\tstatus: ZodValidation.enumType(MarketingStatus, 'Marketing status').default(MarketingStatus.ACTIVE),\n\tpausedAt: ZodValidation.date('Paused at').optional().nullable().default(null),\n\tadmin: ZodValidation.objectId('Admin').optional().nullable(),\n};\n\n/**\n * Create schema builder for Parent entity\n * - Includes timestamps\n * - Excludes 'createdAt' from update operations\n */\nconst schemaBuilder = createSchemaBuilder(baseMarketingFields);\n\n/**\n * Get all schemas for the Parent entity\n */\nconst {\n\tBaseSchema: MarketingValidationSchema,\n\tEntitySchema: MarketingSchema,\n\tIdSchema: MarketingIdSchema,\n\tUpdateSchema: UpdateMarketingSchema,\n} = schemaBuilder.getAllSchemas({ createdAt: true });\n\n/**\n * Export schemas\n */\nexport {\n\tMarketingValidationSchema,\n\tMarketingSchema,\n\tMarketingIdSchema as MarketingIdValidationSchema,\n\tUpdateMarketingSchema,\n};\n\nexport const ProductEntireMenuMarketingHandlerSchema = z.object({\n\tproduct: ZodValidation.objectId('Product'),\n\tshop: ZodValidation.objectId('Shop'),\n});\n\nexport const SpendToGetProgressInputSchema = z.object({\n\tshop: ZodValidation.objectId('Shop'),\n\tbasketTotal: ZodValidation.number('Basket total', { isNonnegative: true }),\n\tuserId: ZodValidation.objectId('User').optional(),\n});\n\nexport const SpendToGetTiersInputSchema = z.object({\n\tshop: ZodValidation.objectId('Shop'),\n});\n\nexport const MarketingSpendLimitsEvaluationSchema = z.object({\n\tmarketings: ZodValidation.array(ZodValidation.objectId('marketing'), 'marketings'),\n});\n\nexport const SyncProductMarketingForMultipleProductsSchema = z.object({\n\tproductIds: ZodValidation.array(ZodValidation.objectId('product id'), 'product ids'),\n});\n\nexport const IncreaseDuringDiscountSchema = z.object({\n\tcount: ZodValidation.number('Count of orders or customers during discount').optional().default(0),\n\tpercentageIncrease: ZodValidation.number('Percentage increase compared to previous duration')\n\t\t.optional()\n\t\t.default(0),\n});\n\nexport const MarketingMetricsSchema = z.object({\n\tnumberOfItems: ZodValidation.number('Number of items in the marketing').optional(),\n\torderIncreaseWithDiscount: IncreaseDuringDiscountSchema.optional(),\n\tcustomerIncreaseWithDiscount: IncreaseDuringDiscountSchema.optional(),\n\ttotalRedemptions: ZodValidation.number('Total redemptions').optional(),\n\ttotalValueGiven: ZodValidation.number('Total discount/free delivery value given').optional(),\n\tremainingBudget: ZodValidation.number('Remaining spend-limit budget').optional(),\n});\n\nexport const MarketingGraphInputSchema = z.object({\n\tmarketingId: ZodValidation.objectIdOrStringSchema,\n\tstartDate: ZodValidation.date('Start Date').transform(val => dayjs(val).startOf('day').toDate()),\n\tendDate: ZodValidation.date('End Date').transform(val => dayjs(val).endOf('day').toDate()),\n\ttype: ZodValidation.enumType(GraphType, 'Type').default(GraphType.DAILY),\n});\n\nexport const MarketingOrdersGraphOutputSchema = z.array(\n\tz.object({\n\t\tdate: ZodValidation.string('Date'),\n\t\torders: ZodValidation.number('Orders').default(0),\n\t})\n);\n\nexport const MarketingCustomersGraphOutputSchema = z.array(\n\tz.object({\n\t\tdate: ZodValidation.string('Date'),\n\t\tcustomers: ZodValidation.number('Customers').default(0),\n\t})\n);\n\nexport const MarketingAmountSpentGraphOutputSchema = z.array(\n\tz.object({\n\t\tdate: ZodValidation.string('Date'),\n\t\tamount: ZodValidation.number('Amount').default(0),\n\t})\n);\n\n/**\n * Export DTO types\n */\nexport type CreateMarketingDTO = DTO<typeof MarketingValidationSchema>;\nexport type MarketingDTO = DTO<typeof MarketingSchema>;\nexport type UpdateMarketingDTO = DTO<typeof UpdateMarketingSchema>;\nexport type ProductEntireMenuMarketingHandlerDTO = DTO<typeof ProductEntireMenuMarketingHandlerSchema>;\nexport type SpendToGetProgressInputDTO = DTO<typeof SpendToGetProgressInputSchema>;\nexport type SpendToGetTiersInputDTO = DTO<typeof SpendToGetTiersInputSchema>;\nexport type IncreaseDuringDiscountDTO = DTO<typeof IncreaseDuringDiscountSchema>;\nexport type MarketingMetricsDTO = DTO<typeof MarketingMetricsSchema>;\nexport type MarketingGraphInputDTO = DTO<typeof MarketingGraphInputSchema>;\nexport type MarketingOrdersGraphOutputDTO = DTO<typeof MarketingOrdersGraphOutputSchema>;\nexport type MarketingCustomersGraphOutputDTO = DTO<typeof MarketingCustomersGraphOutputSchema>;\nexport type MarketingAmountSpentGraphOutputDTO = DTO<typeof MarketingAmountSpentGraphOutputSchema>;"]}
|
|
@@ -187,13 +187,13 @@ export declare const BatchCreateProductMarketingsInputSchema: z.ZodObject<{
|
|
|
187
187
|
shop: import("mongoose").Types.ObjectId;
|
|
188
188
|
categories: import("mongoose").Types.ObjectId[];
|
|
189
189
|
isEntireMenu: boolean;
|
|
190
|
-
isBuy1Get1: boolean;
|
|
191
190
|
products: {
|
|
192
191
|
product: import("mongoose").Types.ObjectId;
|
|
193
192
|
value?: number | undefined;
|
|
194
193
|
valueType?: ValueType | null | undefined;
|
|
195
194
|
}[];
|
|
196
195
|
marketingId: import("mongoose").Types.ObjectId;
|
|
196
|
+
isBuy1Get1: boolean;
|
|
197
197
|
value?: number | undefined;
|
|
198
198
|
valueType?: ValueType | undefined;
|
|
199
199
|
isAppliedByCompany?: boolean | undefined;
|
|
@@ -202,8 +202,8 @@ export declare const BatchCreateProductMarketingsInputSchema: z.ZodObject<{
|
|
|
202
202
|
}, {
|
|
203
203
|
shop: string | import("mongoose").Types.ObjectId;
|
|
204
204
|
isEntireMenu: boolean;
|
|
205
|
-
isBuy1Get1: boolean;
|
|
206
205
|
marketingId: string | import("mongoose").Types.ObjectId;
|
|
206
|
+
isBuy1Get1: boolean;
|
|
207
207
|
value?: number | undefined;
|
|
208
208
|
valueType?: ValueType | undefined;
|
|
209
209
|
categories?: (string | import("mongoose").Types.ObjectId)[] | undefined;
|
|
@@ -104,10 +104,10 @@ declare const PunchMarketingValidationSchema: z.ZodEffects<z.ZodObject<{
|
|
|
104
104
|
end?: Date | undefined;
|
|
105
105
|
};
|
|
106
106
|
shop: import("mongoose").Types.ObjectId;
|
|
107
|
+
minimumOrderValue: number;
|
|
107
108
|
isAppliedByCompany: boolean;
|
|
108
109
|
pausedAt: Date | null;
|
|
109
110
|
marketingType: MarketingType.PUNCH_MARKETING;
|
|
110
|
-
minimumOrderValue: number;
|
|
111
111
|
couponValueType: ValueType;
|
|
112
112
|
couponValue: number;
|
|
113
113
|
couponDurationInDays: number;
|
|
@@ -120,9 +120,9 @@ declare const PunchMarketingValidationSchema: z.ZodEffects<z.ZodObject<{
|
|
|
120
120
|
end?: string | Date | undefined;
|
|
121
121
|
};
|
|
122
122
|
shop: string | import("mongoose").Types.ObjectId;
|
|
123
|
+
minimumOrderValue: number;
|
|
123
124
|
isAppliedByCompany: boolean;
|
|
124
125
|
marketingType: MarketingType.PUNCH_MARKETING;
|
|
125
|
-
minimumOrderValue: number;
|
|
126
126
|
couponValueType: ValueType;
|
|
127
127
|
couponValue: number;
|
|
128
128
|
couponDurationInDays: number;
|
|
@@ -138,10 +138,10 @@ declare const PunchMarketingValidationSchema: z.ZodEffects<z.ZodObject<{
|
|
|
138
138
|
end?: Date | undefined;
|
|
139
139
|
};
|
|
140
140
|
shop: import("mongoose").Types.ObjectId;
|
|
141
|
+
minimumOrderValue: number;
|
|
141
142
|
isAppliedByCompany: boolean;
|
|
142
143
|
pausedAt: Date | null;
|
|
143
144
|
marketingType: MarketingType.PUNCH_MARKETING;
|
|
144
|
-
minimumOrderValue: number;
|
|
145
145
|
couponValueType: ValueType;
|
|
146
146
|
couponValue: number;
|
|
147
147
|
couponDurationInDays: number;
|
|
@@ -154,9 +154,9 @@ declare const PunchMarketingValidationSchema: z.ZodEffects<z.ZodObject<{
|
|
|
154
154
|
end?: string | Date | undefined;
|
|
155
155
|
};
|
|
156
156
|
shop: string | import("mongoose").Types.ObjectId;
|
|
157
|
+
minimumOrderValue: number;
|
|
157
158
|
isAppliedByCompany: boolean;
|
|
158
159
|
marketingType: MarketingType.PUNCH_MARKETING;
|
|
159
|
-
minimumOrderValue: number;
|
|
160
160
|
couponValueType: ValueType;
|
|
161
161
|
couponValue: number;
|
|
162
162
|
couponDurationInDays: number;
|