@lyxa.ai/marketing 1.0.67 → 1.0.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/index.d.ts +21 -11810
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +3 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts +1415 -7085
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.js +37 -22
- package/dist/lib/modules/coupon/routers/coupon.router.js.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts +41 -6
- package/dist/lib/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.js +290 -93
- 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 +11 -15
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.d.ts +30 -2
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.js +494 -54
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.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 +54 -2
- package/dist/lib/modules/coupon/transformers/coupon.transformer.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts +364 -3193
- package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/all-coupons.validation.js +1 -2
- package/dist/lib/modules/coupon/validations/all-coupons.validation.js.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts +580 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.js +48 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.js.map +1 -1
- package/dist/lib/modules/coupon/validations/create-coupon.validation.d.ts +116 -8
- package/dist/lib/modules/coupon/validations/create-coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/create-coupon.validation.js +4 -1
- package/dist/lib/modules/coupon/validations/create-coupon.validation.js.map +1 -1
- package/dist/lib/modules/coupon/validations/global-coupon.validation.d.ts +18 -0
- package/dist/lib/modules/coupon/validations/global-coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/global-coupon.validation.js +2 -0
- package/dist/lib/modules/coupon/validations/global-coupon.validation.js.map +1 -1
- package/dist/lib/modules/coupon/validations/individual-store-coupon.validation.d.ts +18 -18
- package/dist/lib/modules/coupon/validations/individual-store-coupon.validation.js +2 -2
- package/dist/lib/modules/coupon/validations/individual-store-coupon.validation.js.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 +5 -5
- package/dist/lib/modules/deal-setting/routers/deal-setting.router.d.ts.map +1 -1
- package/dist/lib/modules/deal-setting/services/deal-setting.service.d.ts.map +1 -1
- package/dist/lib/modules/deal-setting/services/deal-setting.service.js +4 -1
- package/dist/lib/modules/deal-setting/services/deal-setting.service.js.map +1 -1
- package/dist/lib/modules/featured-setting/routers/featured-setting.router.d.ts +5 -5
- package/dist/lib/modules/featured-setting/routers/featured-setting.router.d.ts.map +1 -1
- package/dist/lib/modules/featured-setting/services/featured-setting.service.d.ts.map +1 -1
- package/dist/lib/modules/featured-setting/services/featured-setting.service.js +3 -0
- package/dist/lib/modules/featured-setting/services/featured-setting.service.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts +54 -8
- 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 +13 -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 +9 -0
- package/dist/lib/modules/limited-time-offer/campaign/jobs/index.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts +0 -1
- package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.js +2 -6
- package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts +16 -3
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.js +22 -3
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.d.ts +2 -0
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.js +12 -0
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +242 -35
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js +19 -1
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts +10 -1
- 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 +83 -1
- 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 +4 -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 +75 -6
- 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 +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 +46 -19
- 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/limited-time-offer.router.d.ts +241 -10
- package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts +2 -0
- 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 +13 -4
- package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts +1 -1
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.js +1 -1
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts +30 -3
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.js +23 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +18 -0
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js +103 -0
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +187 -2
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.js +34 -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 +515 -116
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js +16 -6
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts +12 -4
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.js +53 -7
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +19 -5
- 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 +114 -16
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js.map +1 -1
- package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts.map +1 -1
- package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.js +1 -0
- package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.js.map +1 -1
- package/dist/lib/modules/marketing/routers/marketing.router.d.ts +5 -5
- package/dist/lib/modules/marketing/routers/marketing.router.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/index.d.ts +1 -0
- package/dist/lib/modules/marketing/services/index.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/index.js +1 -0
- package/dist/lib/modules/marketing/services/index.js.map +1 -1
- package/dist/lib/modules/marketing/services/marketing.service.d.ts +7 -3
- package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/marketing.service.js +87 -19
- package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/services/new-user-discount-marketing.service.d.ts +11 -0
- package/dist/lib/modules/marketing/services/new-user-discount-marketing.service.d.ts.map +1 -0
- package/dist/lib/modules/marketing/services/new-user-discount-marketing.service.js +116 -0
- package/dist/lib/modules/marketing/services/new-user-discount-marketing.service.js.map +1 -0
- package/dist/lib/modules/marketing/services/product-marketing.service.d.ts +1 -0
- package/dist/lib/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/product-marketing.service.js +32 -0
- package/dist/lib/modules/marketing/services/product-marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/validations/all-marketings.validation.d.ts.map +1 -1
- package/dist/lib/modules/marketing/validations/all-marketings.validation.js +3 -0
- package/dist/lib/modules/marketing/validations/all-marketings.validation.js.map +1 -1
- package/dist/lib/modules/marketing/validations/discount-marketing.validation.d.ts +6 -6
- package/dist/lib/modules/marketing/validations/index.d.ts +1 -0
- package/dist/lib/modules/marketing/validations/index.d.ts.map +1 -1
- package/dist/lib/modules/marketing/validations/index.js +1 -0
- package/dist/lib/modules/marketing/validations/index.js.map +1 -1
- package/dist/lib/modules/marketing/validations/new-user-discount-marketing.validation.d.ts +677 -0
- package/dist/lib/modules/marketing/validations/new-user-discount-marketing.validation.d.ts.map +1 -0
- package/dist/lib/modules/marketing/validations/new-user-discount-marketing.validation.js +83 -0
- package/dist/lib/modules/marketing/validations/new-user-discount-marketing.validation.js.map +1 -0
- package/dist/lib/modules/marketing/validations/punch-marketing.validation.d.ts +8 -8
- package/dist/lib/modules/marketing/validations/spend-to-get-marketing.validation.d.ts.map +1 -1
- package/dist/lib/modules/marketing/validations/spend-to-get-marketing.validation.js +30 -0
- package/dist/lib/modules/marketing/validations/spend-to-get-marketing.validation.js.map +1 -1
- package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +6 -6
- 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 +2 -2
- 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 +21 -5
- 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 +19 -0
- 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/types/index.d.ts +21 -11810
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/coupon/routers/coupon.router.d.ts +1415 -7085
- package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/coupon.service.d.ts +41 -6
- package/dist/types/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/patterns/repository/CouponRepository.d.ts +30 -2
- package/dist/types/modules/coupon/services/patterns/repository/CouponRepository.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 +54 -2
- package/dist/types/modules/coupon/transformers/coupon.transformer.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts +364 -3193
- package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts +580 -1
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/create-coupon.validation.d.ts +116 -8
- package/dist/types/modules/coupon/validations/create-coupon.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/global-coupon.validation.d.ts +18 -0
- package/dist/types/modules/coupon/validations/global-coupon.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/individual-store-coupon.validation.d.ts +18 -18
- 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 +5 -5
- package/dist/types/modules/deal-setting/routers/deal-setting.router.d.ts.map +1 -1
- package/dist/types/modules/deal-setting/services/deal-setting.service.d.ts.map +1 -1
- package/dist/types/modules/featured-setting/routers/featured-setting.router.d.ts +5 -5
- package/dist/types/modules/featured-setting/routers/featured-setting.router.d.ts.map +1 -1
- package/dist/types/modules/featured-setting/services/featured-setting.service.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts +54 -8
- 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/jobs/limited-time-offer-campaign.worker.d.ts +0 -1
- package/dist/types/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts +16 -3
- package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.d.ts +2 -0
- package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +242 -35
- package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts +10 -1
- 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 +4 -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 +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/limited-time-offer.router.d.ts +241 -10
- package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts +2 -0
- package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts +1 -1
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts +30 -3
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +18 -0
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +187 -2
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts +1 -0
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts.map +1 -0
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +515 -116
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts +12 -4
- package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +19 -5
- package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts.map +1 -1
- package/dist/types/modules/marketing/routers/marketing.router.d.ts +5 -5
- package/dist/types/modules/marketing/routers/marketing.router.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/index.d.ts +1 -0
- package/dist/types/modules/marketing/services/index.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/marketing.service.d.ts +7 -3
- package/dist/types/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/new-user-discount-marketing.service.d.ts +20 -0
- package/dist/types/modules/marketing/services/new-user-discount-marketing.service.d.ts.map +1 -0
- package/dist/types/modules/marketing/services/product-marketing.service.d.ts +6 -0
- package/dist/types/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/validations/all-marketings.validation.d.ts.map +1 -1
- package/dist/types/modules/marketing/validations/discount-marketing.validation.d.ts +6 -6
- package/dist/types/modules/marketing/validations/index.d.ts +1 -0
- package/dist/types/modules/marketing/validations/index.d.ts.map +1 -1
- package/dist/types/modules/marketing/validations/new-user-discount-marketing.validation.d.ts +686 -0
- package/dist/types/modules/marketing/validations/new-user-discount-marketing.validation.d.ts.map +1 -0
- package/dist/types/modules/marketing/validations/punch-marketing.validation.d.ts +8 -8
- package/dist/types/modules/marketing/validations/spend-to-get-marketing.validation.d.ts.map +1 -1
- package/dist/types/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +6 -6
- 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 +2 -2
- 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 +21 -5
- 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 +19 -0
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.validation.d.ts.map +1 -1
- package/package.json +2 -6
package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LtoEmptyResponseSchema = exports.LtoCampaignParticipantsResponseSchema = exports.LtoCampaignHistoryResponseSchema = exports.LtoActiveCampaignResponseSchema = exports.LtoCampaignNullableResponseSchema = exports.LtoCampaignResponseSchema = exports.LtoActiveCampaignSchema = exports.LtoCampaignParticipantItemSchema = exports.LtoCampaignHistoryItemSchema = exports.LtoCampaignSchema = exports.GetLtoCampaignParticipantsSchema = exports.GetLtoCampaignHistorySchema = exports.GetActiveCampaignSchema = exports.UpdateLtoCampaignSchema = exports.CreateLtoCampaignSchema = void 0;
|
|
3
|
+
exports.LtoEmptyResponseSchema = exports.LtoCampaignSessionsResponseSchema = exports.LtoCampaignParticipantsResponseSchema = exports.LtoCampaignHistoryResponseSchema = exports.LtoActiveCampaignResponseSchema = exports.LtoCampaignNullableResponseSchema = exports.LtoCampaignResponseSchema = exports.LtoCampaignSessionSchema = exports.GetLtoCampaignSessionsSchema = exports.LtoActiveCampaignSchema = exports.LtoCampaignParticipantItemSchema = exports.LtoCampaignHistoryItemSchema = exports.LtoCampaignSchema = exports.GetLtoCampaignParticipantsSchema = exports.GetLtoCampaignHistorySchema = exports.GetActiveCampaignSchema = exports.UpdateLtoCampaignSchema = exports.CreateLtoCampaignSchema = void 0;
|
|
4
4
|
const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
|
|
5
5
|
const validation_1 = require("@lyxa.ai/core/dist/utilities/validation");
|
|
6
6
|
const zod_1 = require("zod");
|
|
@@ -10,6 +10,8 @@ exports.CreateLtoCampaignSchema = zod_1.z
|
|
|
10
10
|
subTitle: validation_1.ZodValidation.string('Campaign subtitle').optional(),
|
|
11
11
|
startDate: validation_1.ZodValidation.date('Start date'),
|
|
12
12
|
endDate: validation_1.ZodValidation.date('End date'),
|
|
13
|
+
campaignType: validation_1.ZodValidation.enumType(enum_1.MarketingType, 'Campaign type').default(enum_1.MarketingType.DISCOUNT),
|
|
14
|
+
repeatDays: zod_1.z.array(zod_1.z.number().int().min(0).max(6)).optional(),
|
|
13
15
|
})
|
|
14
16
|
.superRefine((d, ctx) => {
|
|
15
17
|
const now = new Date();
|
|
@@ -29,6 +31,7 @@ exports.UpdateLtoCampaignSchema = zod_1.z
|
|
|
29
31
|
endDate: validation_1.ZodValidation.date('End date'),
|
|
30
32
|
discountOptions: zod_1.z.array(validation_1.ZodValidation.number('Discount option')).min(1).optional(),
|
|
31
33
|
maxDiscountCaps: zod_1.z.array(validation_1.ZodValidation.number('Max discount cap')).min(1).optional(),
|
|
34
|
+
repeatDays: zod_1.z.array(zod_1.z.number().int().min(0).max(6)).optional(),
|
|
32
35
|
confirmActive: zod_1.z.boolean().optional(),
|
|
33
36
|
})
|
|
34
37
|
.superRefine((d, ctx) => {
|
|
@@ -74,6 +77,7 @@ exports.LtoCampaignSchema = zod_1.z.object({
|
|
|
74
77
|
status: validation_1.ZodValidation.enumType(enum_1.LimitedTimeOfferCampaignStatus, 'Status'),
|
|
75
78
|
discountOptions: zod_1.z.array(validation_1.ZodValidation.number('Discount option')).default([]),
|
|
76
79
|
maxDiscountCaps: zod_1.z.array(validation_1.ZodValidation.number('Max discount cap')).default([]),
|
|
80
|
+
repeatDays: zod_1.z.array(zod_1.z.number().int().min(0).max(6)).default([]),
|
|
77
81
|
archivedAt: zod_1.z.date().nullable().optional(),
|
|
78
82
|
createdAt: zod_1.z.date().nullable().optional(),
|
|
79
83
|
updatedAt: zod_1.z.date().nullable().optional(),
|
|
@@ -101,11 +105,25 @@ exports.LtoActiveCampaignSchema = zod_1.z.object({
|
|
|
101
105
|
startTime: zod_1.z.date().nullable().optional(),
|
|
102
106
|
endTime: zod_1.z.date().nullable().optional(),
|
|
103
107
|
});
|
|
108
|
+
exports.GetLtoCampaignSessionsSchema = zod_1.z.object({
|
|
109
|
+
campaignId: validation_1.ZodValidation.objectId(),
|
|
110
|
+
page: zod_1.z.number().int().positive().default(1),
|
|
111
|
+
size: zod_1.z.number().int().positive().max(100).default(20),
|
|
112
|
+
});
|
|
113
|
+
exports.LtoCampaignSessionSchema = zod_1.z.object({
|
|
114
|
+
_id: validation_1.ZodValidation.objectId(),
|
|
115
|
+
campaign: validation_1.ZodValidation.objectId(),
|
|
116
|
+
startDate: zod_1.z.date(),
|
|
117
|
+
endDate: zod_1.z.date(),
|
|
118
|
+
shopCount: validation_1.ZodValidation.number('Shop count'),
|
|
119
|
+
archivedAt: zod_1.z.date(),
|
|
120
|
+
});
|
|
104
121
|
exports.LtoCampaignResponseSchema = (0, validation_1.createResponseSchema)(exports.LtoCampaignSchema);
|
|
105
122
|
exports.LtoCampaignNullableResponseSchema = (0, validation_1.createResponseSchema)(exports.LtoCampaignSchema.nullable());
|
|
106
123
|
exports.LtoActiveCampaignResponseSchema = (0, validation_1.createResponseSchema)(exports.LtoActiveCampaignSchema.nullable());
|
|
107
124
|
exports.LtoCampaignHistoryResponseSchema = (0, validation_1.createResponseSchema)(exports.LtoCampaignHistoryItemSchema);
|
|
108
125
|
exports.LtoCampaignParticipantsResponseSchema = (0, validation_1.createResponseSchema)(exports.LtoCampaignParticipantItemSchema);
|
|
126
|
+
exports.LtoCampaignSessionsResponseSchema = (0, validation_1.createResponseSchema)(exports.LtoCampaignSessionSchema);
|
|
109
127
|
exports.LtoEmptyResponseSchema = zod_1.z.object({
|
|
110
128
|
success: zod_1.z.boolean(),
|
|
111
129
|
message: zod_1.z.string(),
|
package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limited-time-offer-campaign.validation.js","sourceRoot":"/","sources":["modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.ts"],"names":[],"mappings":";;;AAAA,4DAAiF;AACjF,wEAAiG;AACjG,6BAAsB;AAET,QAAA,uBAAuB,GAAG,OAAC;KACnC,MAAM,CAAC;IACJ,KAAK,EAAE,0BAAa,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE;IACxD,QAAQ,EAAE,0BAAa,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,QAAQ,EAAE;IAC9D,SAAS,EAAE,0BAAa,CAAC,IAAI,CAAC,YAAY,CAAC;IAC3C,OAAO,EAAE,0BAAa,CAAC,IAAI,CAAC,UAAU,CAAC;CAC1C,CAAC;KACD,WAAW,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE;IACpB,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,IAAI,CAAC,CAAC,OAAO,IAAI,GAAG,EAAE,CAAC;QACnB,GAAG,CAAC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAC,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,gCAAgC,EAAE,IAAI,EAAE,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CACtE,CAAC,CAAC;AAEU,QAAA,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,GAAG,EAAE,0BAAa,CAAC,QAAQ,EAAE;IAC7B,KAAK,EAAE,0BAAa,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE;IACxD,QAAQ,EAAE,0BAAa,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,QAAQ,EAAE;IAC9D,SAAS,EAAE,OAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACzC,OAAO,EAAE,OAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CAC1C,CAAC,CAAC;AAGU,QAAA,yBAAyB,GAAG,IAAA,iCAAoB,EAAC,yBAAiB,CAAC,CAAC;AACpE,QAAA,iCAAiC,GAAG,IAAA,iCAAoB,EAAC,yBAAiB,CAAC,QAAQ,EAAE,CAAC,CAAC;AACvF,QAAA,+BAA+B,GAAG,IAAA,iCAAoB,EAAC,+BAAuB,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC3F,QAAA,gCAAgC,GAAG,IAAA,iCAAoB,EAAC,oCAA4B,CAAC,CAAC;AACtF,QAAA,qCAAqC,GAAG,IAAA,iCAAoB,EAAC,wCAAgC,CAAC,CAAC;AAC/F,QAAA,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3C,OAAO,EAAE,OAAC,CAAC,OAAO,EAAE;IACpB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;CACtB,CAAC,CAAC","sourcesContent":["import {LimitedTimeOfferCampaignStatus} from '@lyxa.ai/core/dist/utilities/enum';\nimport {createResponseSchema, DTO, ZodValidation} from '@lyxa.ai/core/dist/utilities/validation';\nimport {z} from 'zod';\n\nexport const CreateLtoCampaignSchema = z\n .object({\n title: ZodValidation.string('Campaign title').optional(),\n subTitle: ZodValidation.string('Campaign subtitle').optional(),\n startDate: ZodValidation.date('Start date'),\n endDate: ZodValidation.date('End date'),\n })\n .superRefine((d, ctx) => {\n const now = new Date();\n if (d.endDate <= now) {\n ctx.addIssue({code: z.ZodIssueCode.custom, message: 'End date cannot be in the past', path: ['endDate']});\n }\n if (d.endDate <= d.startDate) {\n ctx.addIssue({code: z.ZodIssueCode.custom, message: 'End date must be after start date', path: ['endDate']});\n }\n });\n\nexport const UpdateLtoCampaignSchema = z\n .object({\n _id: ZodValidation.objectId(),\n title: ZodValidation.string('Campaign title').optional(),\n subTitle: ZodValidation.string('Campaign subtitle').optional(),\n startDate: ZodValidation.date('Start date'),\n endDate: ZodValidation.date('End date'),\n discountOptions: z.array(ZodValidation.number('Discount option')).min(1).optional(),\n maxDiscountCaps: z.array(ZodValidation.number('Max discount cap')).min(1).optional(),\n confirmActive: z.boolean().optional(),\n })\n .superRefine((d, ctx) => {\n const now = new Date();\n if (d.endDate <= now) {\n ctx.addIssue({code: z.ZodIssueCode.custom, message: 'End date cannot be in the past', path: ['endDate']});\n }\n if (d.endDate <= d.startDate) {\n ctx.addIssue({code: z.ZodIssueCode.custom, message: 'End date must be after start date', path: ['endDate']});\n }\n });\n\nexport const GetActiveCampaignSchema = z.object({\n latitude: ZodValidation.number('Latitude'),\n longitude: ZodValidation.number('Longitude'),\n});\n\nexport const GetLtoCampaignHistorySchema = z.object({\n page: z.number().int().positive().default(1),\n size: z.number().int().positive().max(50).default(20),\n status: z\n .union([\n z.literal(LimitedTimeOfferCampaignStatus.EXPIRED),\n z.literal(LimitedTimeOfferCampaignStatus.CANCELLED),\n ])\n .optional(),\n sortBy: z\n .enum(['id', 'campaignNumber', 'startDateTime', 'endDateTime', 'shopsJoined', 'status'])\n .optional(),\n sortOrder: z.enum(['asc', 'desc']).optional(),\n});\n\nexport const GetLtoCampaignParticipantsSchema = z.object({\n campaignId: ZodValidation.objectId(),\n search: ZodValidation.string('Search').optional(),\n page: z.number().int().positive().default(1),\n size: z.number().int().positive().max(100).default(20),\n});\n\nexport const LtoCampaignSchema = z.object({\n _id: ZodValidation.objectId(),\n campaignNumber: ZodValidation.number('Campaign number'),\n title: ZodValidation.string('Campaign title').optional(),\n subTitle: ZodValidation.string('Campaign subtitle').optional(),\n startDate: z.date().nullable().optional(),\n endDate: z.date().nullable().optional(),\n status: ZodValidation.enumType(LimitedTimeOfferCampaignStatus, 'Status'),\n discountOptions: z.array(ZodValidation.number('Discount option')).default([]),\n maxDiscountCaps: z.array(ZodValidation.number('Max discount cap')).default([]),\n archivedAt: z.date().nullable().optional(),\n createdAt: z.date().nullable().optional(),\n updatedAt: z.date().nullable().optional(),\n});\n\nexport const LtoCampaignHistoryItemSchema = z.object({\n id: z.string(),\n campaignNumber: ZodValidation.number('Campaign number'),\n startDateTime: z.date().nullable().optional(),\n endDateTime: z.date().nullable().optional(),\n shopsJoined: ZodValidation.number('Shops joined'),\n status: ZodValidation.enumType(LimitedTimeOfferCampaignStatus, 'Status'),\n});\n\nexport const LtoCampaignParticipantItemSchema = z.object({\n shopId: ZodValidation.objectId(),\n shopName: z.string().nullable(),\n shopPhoto: z.string().nullable().optional(),\n joinedAt: z.date(),\n discountPercentage: ZodValidation.number('Discount percentage').optional(),\n maxDiscountCap: ZodValidation.number('Max discount cap').optional(),\n});\n\nexport const LtoActiveCampaignSchema = z.object({\n _id: ZodValidation.objectId(),\n title: ZodValidation.string('Campaign title').optional(),\n subtitle: ZodValidation.string('Campaign subtitle').optional(),\n startTime: z.date().nullable().optional(),\n endTime: z.date().nullable().optional(),\n});\n\n// Response schemas\nexport const LtoCampaignResponseSchema = createResponseSchema(LtoCampaignSchema);\nexport const LtoCampaignNullableResponseSchema = createResponseSchema(LtoCampaignSchema.nullable());\nexport const LtoActiveCampaignResponseSchema = createResponseSchema(LtoActiveCampaignSchema.nullable());\nexport const LtoCampaignHistoryResponseSchema = createResponseSchema(LtoCampaignHistoryItemSchema);\nexport const LtoCampaignParticipantsResponseSchema = createResponseSchema(LtoCampaignParticipantItemSchema);\nexport const LtoEmptyResponseSchema = z.object({\n success: z.boolean(),\n message: z.string(),\n});\n\n// DTOs\nexport type GetActiveCampaignDTO = DTO<typeof GetActiveCampaignSchema>;\nexport type CreateLtoCampaignDTO = DTO<typeof CreateLtoCampaignSchema>;\nexport type UpdateLtoCampaignDTO = DTO<typeof UpdateLtoCampaignSchema>;\nexport type GetLtoCampaignHistoryDTO = DTO<typeof GetLtoCampaignHistorySchema>;\nexport type GetLtoCampaignParticipantsDTO = DTO<typeof GetLtoCampaignParticipantsSchema>;\nexport type LtoCampaignDTO = DTO<typeof LtoCampaignSchema>;\nexport type LtoActiveCampaignDTO = DTO<typeof LtoActiveCampaignSchema>;\nexport type LtoCampaignHistoryItemDTO = DTO<typeof LtoCampaignHistoryItemSchema>;\nexport type LtoCampaignParticipantItemDTO = DTO<typeof LtoCampaignParticipantItemSchema>;\n"]}
|
|
1
|
+
{"version":3,"file":"limited-time-offer-campaign.validation.js","sourceRoot":"/","sources":["modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.ts"],"names":[],"mappings":";;;AAAA,4DAAgG;AAChG,wEAAiG;AACjG,6BAAsB;AAET,QAAA,uBAAuB,GAAG,OAAC;KACnC,MAAM,CAAC;IACJ,KAAK,EAAE,0BAAa,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE;IACxD,QAAQ,EAAE,0BAAa,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,QAAQ,EAAE;IAC9D,SAAS,EAAE,0BAAa,CAAC,IAAI,CAAC,YAAY,CAAC;IAC3C,OAAO,EAAE,0BAAa,CAAC,IAAI,CAAC,UAAU,CAAC;IACvC,YAAY,EAAE,0BAAa,CAAC,QAAQ,CAAC,oBAAa,EAAE,eAAe,CAAC,CAAC,OAAO,CAAC,oBAAa,CAAC,QAAQ,CAAC;IACpG,UAAU,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAA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edTimeOfferCampaignStatus, MarketingType} from '@lyxa.ai/core/dist/utilities/enum';\nimport {createResponseSchema, DTO, ZodValidation} from '@lyxa.ai/core/dist/utilities/validation';\nimport {z} from 'zod';\n\nexport const CreateLtoCampaignSchema = z\n .object({\n title: ZodValidation.string('Campaign title').optional(),\n subTitle: ZodValidation.string('Campaign subtitle').optional(),\n startDate: ZodValidation.date('Start date'),\n endDate: ZodValidation.date('End date'),\n campaignType: ZodValidation.enumType(MarketingType, 'Campaign type').default(MarketingType.DISCOUNT),\n repeatDays: z.array(z.number().int().min(0).max(6)).optional(),\n })\n .superRefine((d, ctx) => {\n const now = new Date();\n if (d.endDate <= now) {\n ctx.addIssue({code: z.ZodIssueCode.custom, message: 'End date cannot be in the past', path: ['endDate']});\n }\n if (d.endDate <= d.startDate) {\n ctx.addIssue({code: z.ZodIssueCode.custom, message: 'End date must be after start date', path: ['endDate']});\n }\n });\n\nexport const UpdateLtoCampaignSchema = z\n .object({\n _id: ZodValidation.objectId(),\n title: ZodValidation.string('Campaign title').optional(),\n subTitle: ZodValidation.string('Campaign subtitle').optional(),\n startDate: ZodValidation.date('Start date'),\n endDate: ZodValidation.date('End date'),\n discountOptions: z.array(ZodValidation.number('Discount option')).min(1).optional(),\n maxDiscountCaps: z.array(ZodValidation.number('Max discount cap')).min(1).optional(),\n repeatDays: z.array(z.number().int().min(0).max(6)).optional(),\n confirmActive: z.boolean().optional(),\n })\n .superRefine((d, ctx) => {\n const now = new Date();\n if (d.endDate <= now) {\n ctx.addIssue({code: z.ZodIssueCode.custom, message: 'End date cannot be in the past', path: ['endDate']});\n }\n if (d.endDate <= d.startDate) {\n ctx.addIssue({code: z.ZodIssueCode.custom, message: 'End date must be after start date', path: ['endDate']});\n }\n });\n\nexport const GetActiveCampaignSchema = z.object({\n latitude: ZodValidation.number('Latitude'),\n longitude: ZodValidation.number('Longitude'),\n});\n\nexport const GetLtoCampaignHistorySchema = z.object({\n page: z.number().int().positive().default(1),\n size: z.number().int().positive().max(50).default(20),\n status: z\n .union([\n z.literal(LimitedTimeOfferCampaignStatus.EXPIRED),\n z.literal(LimitedTimeOfferCampaignStatus.CANCELLED),\n ])\n .optional(),\n sortBy: z\n .enum(['id', 'campaignNumber', 'startDateTime', 'endDateTime', 'shopsJoined', 'status'])\n .optional(),\n sortOrder: z.enum(['asc', 'desc']).optional(),\n});\n\nexport const GetLtoCampaignParticipantsSchema = z.object({\n campaignId: ZodValidation.objectId(),\n search: ZodValidation.string('Search').optional(),\n page: z.number().int().positive().default(1),\n size: z.number().int().positive().max(100).default(20),\n});\n\nexport const LtoCampaignSchema = z.object({\n _id: ZodValidation.objectId(),\n campaignNumber: ZodValidation.number('Campaign number'),\n title: ZodValidation.string('Campaign title').optional(),\n subTitle: ZodValidation.string('Campaign subtitle').optional(),\n startDate: z.date().nullable().optional(),\n endDate: z.date().nullable().optional(),\n status: ZodValidation.enumType(LimitedTimeOfferCampaignStatus, 'Status'),\n discountOptions: z.array(ZodValidation.number('Discount option')).default([]),\n maxDiscountCaps: z.array(ZodValidation.number('Max discount cap')).default([]),\n repeatDays: z.array(z.number().int().min(0).max(6)).default([]),\n archivedAt: z.date().nullable().optional(),\n createdAt: z.date().nullable().optional(),\n updatedAt: z.date().nullable().optional(),\n});\n\nexport const LtoCampaignHistoryItemSchema = z.object({\n id: z.string(),\n campaignNumber: ZodValidation.number('Campaign number'),\n startDateTime: z.date().nullable().optional(),\n endDateTime: z.date().nullable().optional(),\n shopsJoined: ZodValidation.number('Shops joined'),\n status: ZodValidation.enumType(LimitedTimeOfferCampaignStatus, 'Status'),\n});\n\nexport const LtoCampaignParticipantItemSchema = z.object({\n shopId: ZodValidation.objectId(),\n shopName: z.string().nullable(),\n shopPhoto: z.string().nullable().optional(),\n joinedAt: z.date(),\n discountPercentage: ZodValidation.number('Discount percentage').optional(),\n maxDiscountCap: ZodValidation.number('Max discount cap').optional(),\n});\n\nexport const LtoActiveCampaignSchema = z.object({\n _id: ZodValidation.objectId(),\n title: ZodValidation.string('Campaign title').optional(),\n subtitle: ZodValidation.string('Campaign subtitle').optional(),\n startTime: z.date().nullable().optional(),\n endTime: z.date().nullable().optional(),\n});\n\nexport const GetLtoCampaignSessionsSchema = z.object({\n campaignId: ZodValidation.objectId(),\n page: z.number().int().positive().default(1),\n size: z.number().int().positive().max(100).default(20),\n});\n\nexport const LtoCampaignSessionSchema = z.object({\n _id: ZodValidation.objectId(),\n campaign: ZodValidation.objectId(),\n startDate: z.date(),\n endDate: z.date(),\n shopCount: ZodValidation.number('Shop count'),\n archivedAt: z.date(),\n});\n\n// Response schemas\nexport const LtoCampaignResponseSchema = createResponseSchema(LtoCampaignSchema);\nexport const LtoCampaignNullableResponseSchema = createResponseSchema(LtoCampaignSchema.nullable());\nexport const LtoActiveCampaignResponseSchema = createResponseSchema(LtoActiveCampaignSchema.nullable());\nexport const LtoCampaignHistoryResponseSchema = createResponseSchema(LtoCampaignHistoryItemSchema);\nexport const LtoCampaignParticipantsResponseSchema = createResponseSchema(LtoCampaignParticipantItemSchema);\nexport const LtoCampaignSessionsResponseSchema = createResponseSchema(LtoCampaignSessionSchema);\nexport const LtoEmptyResponseSchema = z.object({\n success: z.boolean(),\n message: z.string(),\n});\n\n// DTOs\nexport type GetActiveCampaignDTO = DTO<typeof GetActiveCampaignSchema>;\nexport type CreateLtoCampaignDTO = DTO<typeof CreateLtoCampaignSchema>;\nexport type UpdateLtoCampaignDTO = DTO<typeof UpdateLtoCampaignSchema>;\nexport type GetLtoCampaignHistoryDTO = DTO<typeof GetLtoCampaignHistorySchema>;\nexport type GetLtoCampaignParticipantsDTO = DTO<typeof GetLtoCampaignParticipantsSchema>;\nexport type GetLtoCampaignSessionsDTO = DTO<typeof GetLtoCampaignSessionsSchema>;\nexport type LtoCampaignDTO = DTO<typeof LtoCampaignSchema>;\nexport type LtoActiveCampaignDTO = DTO<typeof LtoActiveCampaignSchema>;\nexport type LtoCampaignHistoryItemDTO = DTO<typeof LtoCampaignHistoryItemSchema>;\nexport type LtoCampaignParticipantItemDTO = DTO<typeof LtoCampaignParticipantItemSchema>;\n"]}
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { mongoose } from '@typegoose/typegoose';
|
|
2
2
|
export declare class LtoCampaignLifecycleService {
|
|
3
3
|
private repository;
|
|
4
|
+
private scheduler;
|
|
5
|
+
private participantRepository;
|
|
6
|
+
private marketingService;
|
|
7
|
+
private sessionService;
|
|
4
8
|
constructor();
|
|
5
9
|
activateCampaign(campaignId: mongoose.Types.ObjectId): Promise<void>;
|
|
6
|
-
expireCampaign(campaignId: mongoose.Types.ObjectId): Promise<
|
|
10
|
+
expireCampaign(campaignId: mongoose.Types.ObjectId): Promise<boolean>;
|
|
11
|
+
demoteToScheduled(campaignId: mongoose.Types.ObjectId): Promise<void>;
|
|
7
12
|
cancelCampaign(campaignId: mongoose.Types.ObjectId): Promise<void>;
|
|
13
|
+
private revertParticipantEffects;
|
|
14
|
+
private expireRecurring;
|
|
15
|
+
private createNextOccurrence;
|
|
16
|
+
private cloneParticipants;
|
|
8
17
|
}
|
|
9
18
|
export declare const ltoCampaignLifecycleService: LtoCampaignLifecycleService;
|
|
10
19
|
//# sourceMappingURL=limited-time-offer-campaign-lifecycle.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limited-time-offer-campaign-lifecycle.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"limited-time-offer-campaign-lifecycle.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAqB5D,qBACa,2BAA2B;IACpC,OAAO,CAAC,UAAU,CAAwB;IAC1C,OAAO,CAAC,SAAS,CAA8B;IAC/C,OAAO,CAAC,qBAAqB,CAA2B;IACxD,OAAO,CAAC,gBAAgB,CAAiC;IACzD,OAAO,CAAC,cAAc,CAA4B;;IAUrC,gBAAgB,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAKpE,cAAc,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAmBrE,iBAAiB,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAKrE,cAAc,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;YAsBjE,wBAAwB;YAkBxB,eAAe;YAcf,oBAAoB;YAmBpB,iBAAiB;CAWlC;AAED,eAAO,MAAM,2BAA2B,6BAA6C,CAAC"}
|
|
@@ -45,20 +45,102 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
45
45
|
exports.ltoCampaignLifecycleService = exports.LtoCampaignLifecycleService = void 0;
|
|
46
46
|
const typedi_1 = __importStar(require("typedi"));
|
|
47
47
|
const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
|
|
48
|
+
const error_common_1 = require("@lyxa.ai/core/dist/utilities/error-common");
|
|
48
49
|
const limited_time_offer_campaign_repository_1 = require("../../../limited-time-offer/campaign/limited-time-offer-campaign.repository");
|
|
50
|
+
const limited_time_offer_campaign_scheduler_service_1 = require("./limited-time-offer-campaign-scheduler.service");
|
|
51
|
+
const limited_time_offer_participant_marketing_service_1 = require("../../../limited-time-offer/participant/services/limited-time-offer-participant-marketing.service");
|
|
52
|
+
const limited_time_offer_participant_repository_1 = require("../../../limited-time-offer/participant/limited-time-offer-participant.repository");
|
|
53
|
+
const limited_time_offer_participant_builder_1 = require("../../../limited-time-offer/participant/limited-time-offer-participant.builder");
|
|
54
|
+
const limited_time_offer_campaign_session_service_1 = require("../../../limited-time-offer/session/limited-time-offer-campaign-session.service");
|
|
55
|
+
const limited_time_offer_campaign_builder_1 = require("../limited-time-offer-campaign.builder");
|
|
56
|
+
const feature_flags_1 = require("../../../../utility/feature-flags");
|
|
49
57
|
let LtoCampaignLifecycleService = class LtoCampaignLifecycleService {
|
|
50
58
|
repository;
|
|
59
|
+
scheduler;
|
|
60
|
+
participantRepository;
|
|
61
|
+
marketingService;
|
|
62
|
+
sessionService;
|
|
51
63
|
constructor() {
|
|
52
64
|
this.repository = typedi_1.default.get(limited_time_offer_campaign_repository_1.LtoCampaignRepository);
|
|
65
|
+
this.scheduler = typedi_1.default.get(limited_time_offer_campaign_scheduler_service_1.LtoCampaignSchedulerService);
|
|
66
|
+
this.participantRepository = typedi_1.default.get(limited_time_offer_participant_repository_1.LtoParticipantRepository);
|
|
67
|
+
this.marketingService = typedi_1.default.get(limited_time_offer_participant_marketing_service_1.LtoParticipantMarketingService);
|
|
68
|
+
this.sessionService = typedi_1.default.get(limited_time_offer_campaign_session_service_1.LtoCampaignSessionService);
|
|
53
69
|
}
|
|
54
70
|
async activateCampaign(campaignId) {
|
|
55
71
|
await this.repository.setStatus(campaignId, enum_1.LimitedTimeOfferCampaignStatus.ACTIVE);
|
|
56
72
|
}
|
|
57
73
|
async expireCampaign(campaignId) {
|
|
58
|
-
await this.repository.
|
|
74
|
+
const campaign = await this.repository.findById(campaignId);
|
|
75
|
+
if (!campaign)
|
|
76
|
+
throw (0, error_common_1.notFoundError)('Campaign not found');
|
|
77
|
+
const isRecurring = (await (0, feature_flags_1.isLtoScheduleEnabled)()) && (campaign.repeatDays ?? []).length > 0;
|
|
78
|
+
if (isRecurring) {
|
|
79
|
+
await this.expireRecurring(campaign);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
await this.repository.setStatus(campaignId, enum_1.LimitedTimeOfferCampaignStatus.EXPIRED, true);
|
|
83
|
+
}
|
|
84
|
+
await this.revertParticipantEffects(campaignId);
|
|
85
|
+
return isRecurring;
|
|
86
|
+
}
|
|
87
|
+
async demoteToScheduled(campaignId) {
|
|
88
|
+
await this.revertParticipantEffects(campaignId);
|
|
89
|
+
await this.participantRepository.clearLiveEffects(campaignId);
|
|
59
90
|
}
|
|
60
91
|
async cancelCampaign(campaignId) {
|
|
92
|
+
const campaign = await this.repository.findById(campaignId);
|
|
93
|
+
if (!campaign)
|
|
94
|
+
throw (0, error_common_1.notFoundError)('Campaign not found');
|
|
95
|
+
if ((await (0, feature_flags_1.isLtoScheduleEnabled)()) &&
|
|
96
|
+
(campaign.repeatDays ?? []).length > 0 &&
|
|
97
|
+
campaign.status === enum_1.LimitedTimeOfferCampaignStatus.ACTIVE) {
|
|
98
|
+
const shopCount = await this.participantRepository.countNonWithdrawnByCampaign(campaign._id);
|
|
99
|
+
await this.sessionService.logSession(campaign, shopCount);
|
|
100
|
+
}
|
|
61
101
|
await this.repository.setStatus(campaignId, enum_1.LimitedTimeOfferCampaignStatus.CANCELLED, true);
|
|
102
|
+
await this.revertParticipantEffects(campaignId);
|
|
103
|
+
}
|
|
104
|
+
async revertParticipantEffects(campaignId) {
|
|
105
|
+
await this.marketingService.removeAllCampaignMarketings(campaignId);
|
|
106
|
+
if (!(await (0, feature_flags_1.isLtoScheduleEnabled)()))
|
|
107
|
+
return;
|
|
108
|
+
const pausedMarketingIds = await this.participantRepository.findPausedMarketingIdsByCampaign(campaignId);
|
|
109
|
+
await this.marketingService.resumeMarketings(pausedMarketingIds);
|
|
110
|
+
const participants = await this.participantRepository.findAllActiveByCampaign(campaignId);
|
|
111
|
+
for (const participant of participants) {
|
|
112
|
+
await this.participantRepository.restoreShopOrderCapacity(participant.shop, participant.pausedOrderCapacity, participant.pausedOrderCapacityEnabled);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async expireRecurring(campaign) {
|
|
116
|
+
const shopCount = await this.participantRepository.countNonWithdrawnByCampaign(campaign._id);
|
|
117
|
+
await this.sessionService.logSession(campaign, shopCount);
|
|
118
|
+
await this.repository.setStatus(campaign._id, enum_1.LimitedTimeOfferCampaignStatus.EXPIRED, true);
|
|
119
|
+
const { startDate, endDate } = (0, limited_time_offer_campaign_builder_1.nextOccurrenceDate)(campaign.repeatDays, campaign.startDate, campaign.endDate);
|
|
120
|
+
const nextCampaign = await this.createNextOccurrence(campaign, startDate, endDate);
|
|
121
|
+
await this.cloneParticipants(campaign._id, nextCampaign._id);
|
|
122
|
+
await this.scheduler.scheduleActivation(nextCampaign._id, startDate);
|
|
123
|
+
await this.scheduler.scheduleExpiry(nextCampaign._id, endDate);
|
|
124
|
+
}
|
|
125
|
+
async createNextOccurrence(campaign, startDate, endDate) {
|
|
126
|
+
return this.repository.create({
|
|
127
|
+
campaignNumber: await this.repository.nextCampaignNumber(),
|
|
128
|
+
title: campaign.title,
|
|
129
|
+
subTitle: campaign.subTitle,
|
|
130
|
+
startDate,
|
|
131
|
+
endDate,
|
|
132
|
+
status: enum_1.LimitedTimeOfferCampaignStatus.SCHEDULED,
|
|
133
|
+
campaignType: campaign.campaignType,
|
|
134
|
+
discountOptions: campaign.discountOptions,
|
|
135
|
+
maxDiscountCaps: campaign.maxDiscountCaps,
|
|
136
|
+
repeatDays: campaign.repeatDays,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
async cloneParticipants(fromCampaignId, toCampaignId) {
|
|
140
|
+
const participants = await this.participantRepository.findAllActiveByCampaign(fromCampaignId);
|
|
141
|
+
for (const participant of participants) {
|
|
142
|
+
await this.participantRepository.create(limited_time_offer_participant_builder_1.LtoParticipantQueryBuilder.buildCloneInput(toCampaignId, participant));
|
|
143
|
+
}
|
|
62
144
|
}
|
|
63
145
|
};
|
|
64
146
|
exports.LtoCampaignLifecycleService = LtoCampaignLifecycleService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limited-time-offer-campaign-lifecycle.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,4DAAiF;AACjF,wIAAkH;AAG3G,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IAC5B,UAAU,CAAwB;IAE1C;QACI,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,8DAAqB,CAAC,CAAC;IAC3D,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAAC,UAAmC;QAC7D,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,EAAE,qCAA8B,CAAC,MAAM,CAAC,CAAC;IACvF,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,UAAmC;QAC3D,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,EAAE,qCAA8B,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC9F,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,UAAmC;QAC3D,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,EAAE,qCAA8B,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAChG,CAAC;CACJ,CAAA;AAlBY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,gBAAO,GAAE;;GACG,2BAA2B,CAkBvC;AAEY,QAAA,2BAA2B,GAAG,gBAAS,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {LimitedTimeOfferCampaignStatus} from '@lyxa.ai/core/dist/utilities/enum';\nimport {LtoCampaignRepository} from '@modules/limited-time-offer/campaign/limited-time-offer-campaign.repository';\n\n@Service()\nexport class LtoCampaignLifecycleService {\n private repository: LtoCampaignRepository;\n\n constructor() {\n this.repository = Container.get(LtoCampaignRepository);\n }\n\n public async activateCampaign(campaignId: mongoose.Types.ObjectId): Promise<void> {\n await this.repository.setStatus(campaignId, LimitedTimeOfferCampaignStatus.ACTIVE);\n }\n\n public async expireCampaign(campaignId: mongoose.Types.ObjectId): Promise<void> {\n await this.repository.setStatus(campaignId, LimitedTimeOfferCampaignStatus.EXPIRED, true);\n }\n\n public async cancelCampaign(campaignId: mongoose.Types.ObjectId): Promise<void> {\n await this.repository.setStatus(campaignId, LimitedTimeOfferCampaignStatus.CANCELLED, true);\n }\n}\n\nexport const ltoCampaignLifecycleService = Container.get(LtoCampaignLifecycleService);\n"]}
|
|
1
|
+
{"version":3,"file":"limited-time-offer-campaign-lifecycle.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAG1C,4DAAiF;AACjF,4EAAwE;AACxE,wIAAkH;AAClH,mHAA4F;AAC5F,wKAE2G;AAC3G,iJAE2F;AAC3F,2IAEwF;AACxF,iJAEyF;AACzF,gGAA0E;AAC1E,0DAA4D;AAGrD,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IAC5B,UAAU,CAAwB;IAClC,SAAS,CAA8B;IACvC,qBAAqB,CAA2B;IAChD,gBAAgB,CAAiC;IACjD,cAAc,CAA4B;IAElD;QACI,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,8DAAqB,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,GAAG,gBAAS,CAAC,GAAG,CAAC,2EAA2B,CAAC,CAAC;QAC5D,IAAI,CAAC,qBAAqB,GAAG,gBAAS,CAAC,GAAG,CAAC,oEAAwB,CAAC,CAAC;QACrE,IAAI,CAAC,gBAAgB,GAAG,gBAAS,CAAC,GAAG,CAAC,iFAA8B,CAAC,CAAC;QACtE,IAAI,CAAC,cAAc,GAAG,gBAAS,CAAC,GAAG,CAAC,uEAAyB,CAAC,CAAC;IACnE,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAAC,UAAmC;QAC7D,MAAM,IAAI,CAAC,UAAU,C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P,CAAC;IAEO,KAAK,CAAC,iBAAiB,CAC3B,cAAuC,EACvC,YAAqC;QAErC,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,uBAAuB,CAAC,cAAc,CAAC,CAAC;QAC9F,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;YACrC,MAAM,IAAI,CAAC,qBAAqB,CAAC,MAAM,CACnC,mEAA0B,CAAC,eAAe,CAAC,YAAY,EAAE,WAAW,CAAC,CACxE,CAAC;QACN,CAAC;IACL,CAAC;CACJ,CAAA;AAhIY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,gBAAO,GAAE;;GACG,2BAA2B,CAgIvC;AAEY,QAAA,2BAA2B,GAAG,gBAAS,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {DocumentType, mongoose} from '@typegoose/typegoose';\nimport {LimitedTimeOfferCampaign} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {LimitedTimeOfferCampaignStatus} from '@lyxa.ai/core/dist/utilities/enum';\nimport {notFoundError} from '@lyxa.ai/core/dist/utilities/error-common';\nimport {LtoCampaignRepository} from '@modules/limited-time-offer/campaign/limited-time-offer-campaign.repository';\nimport {LtoCampaignSchedulerService} from './limited-time-offer-campaign-scheduler.service';\nimport {\n LtoParticipantMarketingService\n} from '@modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service';\nimport {\n LtoParticipantRepository\n} from '@modules/limited-time-offer/participant/limited-time-offer-participant.repository';\nimport {\n LtoParticipantQueryBuilder\n} from '@modules/limited-time-offer/participant/limited-time-offer-participant.builder';\nimport {\n LtoCampaignSessionService\n} from '@modules/limited-time-offer/session/limited-time-offer-campaign-session.service';\nimport {nextOccurrenceDate} from '../limited-time-offer-campaign.builder';\nimport {isLtoScheduleEnabled} from '@utility/feature-flags';\n\n@Service()\nexport class LtoCampaignLifecycleService {\n private repository: LtoCampaignRepository;\n private scheduler: LtoCampaignSchedulerService;\n private participantRepository: LtoParticipantRepository;\n private marketingService: LtoParticipantMarketingService;\n private sessionService: LtoCampaignSessionService;\n\n constructor() {\n this.repository = Container.get(LtoCampaignRepository);\n this.scheduler = Container.get(LtoCampaignSchedulerService);\n this.participantRepository = Container.get(LtoParticipantRepository);\n this.marketingService = Container.get(LtoParticipantMarketingService);\n this.sessionService = Container.get(LtoCampaignSessionService);\n }\n\n public async activateCampaign(campaignId: mongoose.Types.ObjectId): Promise<void> {\n await this.repository.setStatus(campaignId, LimitedTimeOfferCampaignStatus.ACTIVE);\n }\n\n // Returns whether the ended campaign was recurring (a fresh scheduled occurrence was spawned).\n public async expireCampaign(campaignId: mongoose.Types.ObjectId): Promise<boolean> {\n const campaign = await this.repository.findById(campaignId);\n if (!campaign) throw notFoundError('Campaign not found');\n\n const isRecurring = (await isLtoScheduleEnabled()) && (campaign.repeatDays ?? []).length > 0;\n if (isRecurring) {\n await this.expireRecurring(campaign);\n } else {\n await this.repository.setStatus(campaignId, LimitedTimeOfferCampaignStatus.EXPIRED, true);\n }\n\n await this.revertParticipantEffects(campaignId);\n return isRecurring;\n }\n\n // Undoes live-campaign effects when postponed back to SCHEDULED: same participants, same campaign\n // doc, no cloning. Reuses the same revert logic cancel/expire rely on, then clears the participants'\n // stale marketing/pause snapshots — safe to skip for cancel/expire since those either end the\n // participant's lifecycle or clone into fresh docs that already omit these fields.\n public async demoteToScheduled(campaignId: mongoose.Types.ObjectId): Promise<void> {\n await this.revertParticipantEffects(campaignId);\n await this.participantRepository.clearLiveEffects(campaignId);\n }\n\n public async cancelCampaign(campaignId: mongoose.Types.ObjectId): Promise<void> {\n const campaign = await this.repository.findById(campaignId);\n if (!campaign) throw notFoundError('Campaign not found');\n\n // Deleting a live recurring session logs that day's session before archiving the campaign.\n if (\n (await isLtoScheduleEnabled()) &&\n (campaign.repeatDays ?? []).length > 0 &&\n campaign.status === LimitedTimeOfferCampaignStatus.ACTIVE\n ) {\n const shopCount = await this.participantRepository.countNonWithdrawnByCampaign(campaign._id);\n await this.sessionService.logSession(campaign, shopCount);\n }\n\n await this.repository.setStatus(campaignId, LimitedTimeOfferCampaignStatus.CANCELLED, true);\n await this.revertParticipantEffects(campaignId);\n }\n\n // Undoes everything the campaign imposed on its participant shops: deletes the LTO discounts,\n // resumes the shops' own paused discounts, and restores each shop's saved order capacity. Runs on\n // every end-of-campaign path (scheduled expiry, admin immediate-expiry, and cancel) so the shops\n // are always reset — for a recurring campaign the next occurrence re-applies them at its activation.\n private async revertParticipantEffects(campaignId: mongoose.Types.ObjectId): Promise<void> {\n await this.marketingService.removeAllCampaignMarketings(campaignId);\n\n if (!(await isLtoScheduleEnabled())) return;\n\n const pausedMarketingIds = await this.participantRepository.findPausedMarketingIdsByCampaign(campaignId);\n await this.marketingService.resumeMarketings(pausedMarketingIds);\n\n const participants = await this.participantRepository.findAllActiveByCampaign(campaignId);\n for (const participant of participants) {\n await this.participantRepository.restoreShopOrderCapacity(\n participant.shop as mongoose.Types.ObjectId,\n participant.pausedOrderCapacity,\n participant.pausedOrderCapacityEnabled\n );\n }\n }\n\n private async expireRecurring(campaign: DocumentType<LimitedTimeOfferCampaign>): Promise<void> {\n const shopCount = await this.participantRepository.countNonWithdrawnByCampaign(campaign._id);\n await this.sessionService.logSession(campaign, shopCount);\n\n await this.repository.setStatus(campaign._id, LimitedTimeOfferCampaignStatus.EXPIRED, true);\n\n const {startDate, endDate} = nextOccurrenceDate(campaign.repeatDays, campaign.startDate, campaign.endDate);\n const nextCampaign = await this.createNextOccurrence(campaign, startDate, endDate);\n await this.cloneParticipants(campaign._id, nextCampaign._id);\n\n await this.scheduler.scheduleActivation(nextCampaign._id, startDate);\n await this.scheduler.scheduleExpiry(nextCampaign._id, endDate);\n }\n\n private async createNextOccurrence(\n campaign: DocumentType<LimitedTimeOfferCampaign>,\n startDate: Date,\n endDate: Date,\n ): Promise<DocumentType<LimitedTimeOfferCampaign>> {\n return this.repository.create({\n campaignNumber: await this.repository.nextCampaignNumber(),\n title: campaign.title,\n subTitle: campaign.subTitle,\n startDate,\n endDate,\n status: LimitedTimeOfferCampaignStatus.SCHEDULED,\n campaignType: campaign.campaignType,\n discountOptions: campaign.discountOptions,\n maxDiscountCaps: campaign.maxDiscountCaps,\n repeatDays: campaign.repeatDays,\n });\n }\n\n private async cloneParticipants(\n fromCampaignId: mongoose.Types.ObjectId,\n toCampaignId: mongoose.Types.ObjectId,\n ): Promise<void> {\n const participants = await this.participantRepository.findAllActiveByCampaign(fromCampaignId);\n for (const participant of participants) {\n await this.participantRepository.create(\n LtoParticipantQueryBuilder.buildCloneInput(toCampaignId, participant),\n );\n }\n }\n}\n\nexport const ltoCampaignLifecycleService = Container.get(LtoCampaignLifecycleService);\n"]}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { mongoose } from '@typegoose/typegoose';
|
|
2
2
|
export declare class LtoCampaignSchedulerService {
|
|
3
|
+
private repository;
|
|
4
|
+
constructor();
|
|
3
5
|
scheduleActivation(campaignId: mongoose.Types.ObjectId, startDate: Date): Promise<void>;
|
|
4
6
|
scheduleExpiry(campaignId: mongoose.Types.ObjectId, endDate: Date): Promise<void>;
|
|
7
|
+
private resolveJobDelay;
|
|
5
8
|
cancelJobs(campaignId: mongoose.Types.ObjectId): Promise<void>;
|
|
9
|
+
rescheduleOrphanedRecurring(): Promise<void>;
|
|
6
10
|
private activationJobId;
|
|
7
11
|
private expiryJobId;
|
|
8
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limited-time-offer-campaign-scheduler.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"limited-time-offer-campaign-scheduler.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAMhD,qBACa,2BAA2B;IACpC,OAAO,CAAC,UAAU,CAAwB;;IAM7B,kBAAkB,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAWvF,cAAc,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;YAahF,eAAe;IAMhB,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAK9D,2BAA2B,IAAI,OAAO,CAAC,IAAI,CAAC;IAwBzD,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,WAAW;CAGtB"}
|
|
@@ -1,33 +1,101 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
2
18
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
19
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
20
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
21
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
22
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
23
|
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
8
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
45
|
exports.LtoCampaignSchedulerService = void 0;
|
|
10
|
-
const typedi_1 = require("typedi");
|
|
46
|
+
const typedi_1 = __importStar(require("typedi"));
|
|
11
47
|
const limited_time_offer_campaign_producer_1 = require("../../../limited-time-offer/campaign/jobs/limited-time-offer-campaign.producer");
|
|
48
|
+
const limited_time_offer_campaign_repository_1 = require("../../../limited-time-offer/campaign/limited-time-offer-campaign.repository");
|
|
49
|
+
const feature_flags_1 = require("../../../../utility/feature-flags");
|
|
12
50
|
let LtoCampaignSchedulerService = class LtoCampaignSchedulerService {
|
|
51
|
+
repository;
|
|
52
|
+
constructor() {
|
|
53
|
+
this.repository = typedi_1.default.get(limited_time_offer_campaign_repository_1.LtoCampaignRepository);
|
|
54
|
+
}
|
|
13
55
|
async scheduleActivation(campaignId, startDate) {
|
|
14
|
-
const delay = startDate.getTime()
|
|
15
|
-
if (delay
|
|
56
|
+
const delay = await this.resolveJobDelay(startDate.getTime());
|
|
57
|
+
if (delay === null)
|
|
16
58
|
return;
|
|
17
59
|
await (0, limited_time_offer_campaign_producer_1.removeLtoCampaignJob)(this.activationJobId(campaignId));
|
|
18
60
|
await (0, limited_time_offer_campaign_producer_1.addLtoCampaignJob)(limited_time_offer_campaign_producer_1.LtoCampaignJobName.ACTIVATE, { campaignId: campaignId.toString() }, { delay, jobId: this.activationJobId(campaignId), removeOnComplete: true });
|
|
19
61
|
}
|
|
20
62
|
async scheduleExpiry(campaignId, endDate) {
|
|
21
|
-
const delay = endDate.getTime()
|
|
22
|
-
if (delay
|
|
63
|
+
const delay = await this.resolveJobDelay(endDate.getTime());
|
|
64
|
+
if (delay === null)
|
|
23
65
|
return;
|
|
24
66
|
await (0, limited_time_offer_campaign_producer_1.removeLtoCampaignJob)(this.expiryJobId(campaignId));
|
|
25
67
|
await (0, limited_time_offer_campaign_producer_1.addLtoCampaignJob)(limited_time_offer_campaign_producer_1.LtoCampaignJobName.EXPIRE, { campaignId: campaignId.toString() }, { delay, jobId: this.expiryJobId(campaignId), removeOnComplete: true });
|
|
26
68
|
}
|
|
69
|
+
async resolveJobDelay(targetTime) {
|
|
70
|
+
const delay = targetTime - Date.now();
|
|
71
|
+
if (await (0, feature_flags_1.isLtoScheduleEnabled)())
|
|
72
|
+
return Math.max(0, delay);
|
|
73
|
+
return delay > 0 ? delay : null;
|
|
74
|
+
}
|
|
27
75
|
async cancelJobs(campaignId) {
|
|
28
76
|
await (0, limited_time_offer_campaign_producer_1.removeLtoCampaignJob)(this.activationJobId(campaignId));
|
|
29
77
|
await (0, limited_time_offer_campaign_producer_1.removeLtoCampaignJob)(this.expiryJobId(campaignId));
|
|
30
78
|
}
|
|
79
|
+
async rescheduleOrphanedRecurring() {
|
|
80
|
+
const queue = (0, limited_time_offer_campaign_producer_1.getLtoCampaignQueue)();
|
|
81
|
+
const delayed = await queue.getDelayed();
|
|
82
|
+
const existingJobIds = new Set(delayed.map(j => j.opts.jobId).filter(Boolean));
|
|
83
|
+
const scheduled = await this.repository.findScheduledRecurring();
|
|
84
|
+
for (const campaign of scheduled) {
|
|
85
|
+
if (!existingJobIds.has(this.activationJobId(campaign._id))) {
|
|
86
|
+
await this.scheduleActivation(campaign._id, campaign.startDate);
|
|
87
|
+
}
|
|
88
|
+
if (!existingJobIds.has(this.expiryJobId(campaign._id))) {
|
|
89
|
+
await this.scheduleExpiry(campaign._id, campaign.endDate);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const active = await this.repository.findActiveRecurring();
|
|
93
|
+
for (const campaign of active) {
|
|
94
|
+
if (!existingJobIds.has(this.expiryJobId(campaign._id))) {
|
|
95
|
+
await this.scheduleExpiry(campaign._id, campaign.endDate);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
31
99
|
activationJobId(campaignId) {
|
|
32
100
|
return `lto-activate-${campaignId.toString()}`;
|
|
33
101
|
}
|
|
@@ -37,6 +105,7 @@ let LtoCampaignSchedulerService = class LtoCampaignSchedulerService {
|
|
|
37
105
|
};
|
|
38
106
|
exports.LtoCampaignSchedulerService = LtoCampaignSchedulerService;
|
|
39
107
|
exports.LtoCampaignSchedulerService = LtoCampaignSchedulerService = __decorate([
|
|
40
|
-
(0, typedi_1.Service)()
|
|
108
|
+
(0, typedi_1.Service)(),
|
|
109
|
+
__metadata("design:paramtypes", [])
|
|
41
110
|
], LtoCampaignSchedulerService);
|
|
42
111
|
//# sourceMappingURL=limited-time-offer-campaign-scheduler.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limited-time-offer-campaign-scheduler.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"limited-time-offer-campaign-scheduler.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAG5C,yIAAkL;AAClL,wIAAoH;AACpH,0DAA8D;AAGvD,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IAC5B,UAAU,CAAwB;IAE1C;QACI,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,8DAAqB,CAAC,CAAC;IAC3D,CAAC;IAEM,KAAK,CAAC,kBAAkB,CAAC,UAAmC,EAAE,SAAe;QAChF,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC;QAC9D,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO;QAC3B,MAAM,IAAA,2DAAoB,EAAC,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC;QAC7D,MAAM,IAAA,wDAAiB,EACnB,yDAAkB,CAAC,QAAQ,EAC3B,EAAE,UAAU,EAAE,UAAU,CAAC,QAAQ,EAAE,EAAE,EACrC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAC7E,CAAC;IACN,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,UAAmC,EAAE,OAAa;QAC1E,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5D,IAAI,KAAK,KAAK,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lyxa.ai/core/dist/utilities/enum';\nimport { LtoCampaignJobName, addLtoCampaignJob, removeLtoCampaignJob, getLtoCampaignQueue } from '@modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.producer';\nimport { LtoCampaignRepository } from '@modules/limited-time-offer/campaign/limited-time-offer-campaign.repository';\nimport { isLtoScheduleEnabled } from '@utility/feature-flags';\n\n@Service()\nexport class LtoCampaignSchedulerService {\n private repository: LtoCampaignRepository;\n\n constructor() {\n this.repository = Container.get(LtoCampaignRepository);\n }\n\n public async scheduleActivation(campaignId: mongoose.Types.ObjectId, startDate: Date): Promise<void> {\n const delay = await this.resolveJobDelay(startDate.getTime());\n if (delay === null) return;\n await removeLtoCampaignJob(this.activationJobId(campaignId));\n await addLtoCampaignJob(\n LtoCampaignJobName.ACTIVATE,\n { campaignId: campaignId.toString() },\n { delay, jobId: this.activationJobId(campaignId), removeOnComplete: true }\n );\n }\n\n public async scheduleExpiry(campaignId: mongoose.Types.ObjectId, endDate: Date): Promise<void> {\n const delay = await this.resolveJobDelay(endDate.getTime());\n if (delay === null) return;\n await removeLtoCampaignJob(this.expiryJobId(campaignId));\n await addLtoCampaignJob(\n LtoCampaignJobName.EXPIRE,\n { campaignId: campaignId.toString() },\n { delay, jobId: this.expiryJobId(campaignId), removeOnComplete: true }\n );\n }\n\n // Flag on: clamp to 0 so a start/end time that already passed (e.g. during downtime) fires\n // immediately. Flag off: reproduce master by skipping any job whose time has already passed.\n private async resolveJobDelay(targetTime: number): Promise<number | null> {\n const delay = targetTime - Date.now();\n if (await isLtoScheduleEnabled()) return Math.max(0, delay);\n return delay > 0 ? delay : null;\n }\n\n public async cancelJobs(campaignId: mongoose.Types.ObjectId): Promise<void> {\n await removeLtoCampaignJob(this.activationJobId(campaignId));\n await removeLtoCampaignJob(this.expiryJobId(campaignId));\n }\n\n public async rescheduleOrphanedRecurring(): Promise<void> {\n const queue = getLtoCampaignQueue();\n const delayed = await queue.getDelayed();\n const existingJobIds = new Set(delayed.map(j => j.opts.jobId).filter(Boolean));\n\n const scheduled = await this.repository.findScheduledRecurring();\n for (const campaign of scheduled) {\n if (!existingJobIds.has(this.activationJobId(campaign._id))) {\n await this.scheduleActivation(campaign._id, campaign.startDate);\n }\n if (!existingJobIds.has(this.expiryJobId(campaign._id))) {\n await this.scheduleExpiry(campaign._id, campaign.endDate);\n }\n }\n\n // An ACTIVE recurring campaign whose expiry job was lost would otherwise hang forever.\n const active = await this.repository.findActiveRecurring();\n for (const campaign of active) {\n if (!existingJobIds.has(this.expiryJobId(campaign._id))) {\n await this.scheduleExpiry(campaign._id, campaign.endDate);\n }\n }\n }\n\n private activationJobId(campaignId: mongoose.Types.ObjectId): string {\n return `lto-activate-${campaignId.toString()}`;\n }\n\n private expiryJobId(campaignId: mongoose.Types.ObjectId): string {\n return `lto-expire-${campaignId.toString()}`;\n }\n}\n"]}
|
|
@@ -9,6 +9,7 @@ export declare class LtoCampaignService {
|
|
|
9
9
|
private configService;
|
|
10
10
|
constructor();
|
|
11
11
|
create(dto: CreateLtoCampaignDTO): Promise<DocumentType<Model>>;
|
|
12
|
+
private deriveCampaignStatus;
|
|
12
13
|
getCurrent(): Promise<DocumentType<Model> | null>;
|
|
13
14
|
getActive(): Promise<LtoActiveCampaignDTO | null>;
|
|
14
15
|
getById(campaignId: mongoose.Types.ObjectId): Promise<DocumentType<Model>>;
|
|
@@ -30,7 +31,6 @@ export declare class LtoCampaignService {
|
|
|
30
31
|
}>;
|
|
31
32
|
update(dto: UpdateLtoCampaignDTO): Promise<DocumentType<Model>>;
|
|
32
33
|
cancel(campaignId: mongoose.Types.ObjectId): Promise<void>;
|
|
33
|
-
expire(campaignId: mongoose.Types.ObjectId): Promise<void>;
|
|
34
34
|
private assertUpdateAllowed;
|
|
35
35
|
private shouldExpireImmediately;
|
|
36
36
|
private applyImmediateExpiry;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limited-time-offer-campaign.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAC,wBAAwB,IAAI,KAAK,EAAC,MAAM,2CAA2C,CAAC;AAC5F,OAAO,EAAC,8BAA8B,EAAgB,MAAM,mCAAmC,CAAC;AAEhG,OAAO,EACH,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,EACpB,oBAAoB,EACvB,MAAM,2CAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"limited-time-offer-campaign.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAC,wBAAwB,IAAI,KAAK,EAAC,MAAM,2CAA2C,CAAC;AAC5F,OAAO,EAAC,8BAA8B,EAAgB,MAAM,mCAAmC,CAAC;AAEhG,OAAO,EACH,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,EACpB,oBAAoB,EACvB,MAAM,2CAA2C,CAAC;AAUnD,qBACa,kBAAkB;IAC3B,OAAO,CAAC,UAAU,CAAwB;IAC1C,OAAO,CAAC,SAAS,CAA8B;IAC/C,OAAO,CAAC,SAAS,CAA8B;IAC/C,OAAO,CAAC,aAAa,CAAgC;;IASxC,MAAM,CAAC,GAAG,EAAE,oBAAoB;IAyB7C,OAAO,CAAC,oBAAoB;IAMf,UAAU;IAIV,SAAS,IAAI,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAajD,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ;IAM3C,UAAU,CAAC,GAAG,EAAE,wBAAwB;;;;;;;;;;;;;;;;IAaxC,MAAM,CAAC,GAAG,EAAE,oBAAoB;IA6ChC,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IASvE,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,uBAAuB;YAIjB,oBAAoB;YASpB,wBAAwB;YAiBxB,uBAAuB;IAMrC,OAAO,CAAC,cAAc;YAMR,kBAAkB;CAWnC;AAED,eAAO,MAAM,kBAAkB,oBAAoC,CAAC"}
|
package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js
CHANGED
|
@@ -51,6 +51,7 @@ const limited_time_offer_campaign_scheduler_service_1 = require("./limited-time-
|
|
|
51
51
|
const limited_time_offer_campaign_repository_1 = require("../../../limited-time-offer/campaign/limited-time-offer-campaign.repository");
|
|
52
52
|
const limited_time_offer_campaign_builder_1 = require("../../../limited-time-offer/campaign/limited-time-offer-campaign.builder");
|
|
53
53
|
const limited_time_offer_config_service_1 = require("../../../limited-time-offer/config/limited-time-offer-config.service");
|
|
54
|
+
const feature_flags_1 = require("../../../../utility/feature-flags");
|
|
54
55
|
const ACTIVE_STATUSES = [enum_1.LimitedTimeOfferCampaignStatus.SCHEDULED, enum_1.LimitedTimeOfferCampaignStatus.ACTIVE];
|
|
55
56
|
let LtoCampaignService = class LtoCampaignService {
|
|
56
57
|
repository;
|
|
@@ -65,18 +66,27 @@ let LtoCampaignService = class LtoCampaignService {
|
|
|
65
66
|
}
|
|
66
67
|
async create(dto) {
|
|
67
68
|
await this.assertNoCampaignRunning();
|
|
68
|
-
const now = new Date();
|
|
69
69
|
const config = await this.loadConfigSnapshot();
|
|
70
|
-
const status = dto.startDate
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
const status = this.deriveCampaignStatus(dto.startDate);
|
|
71
|
+
const campaign = await this.repository.create(limited_time_offer_campaign_builder_1.LtoCampaignQueryBuilder.buildCreateInput({
|
|
72
|
+
dto,
|
|
73
|
+
status,
|
|
74
|
+
campaignNumber: await this.repository.nextCampaignNumber(),
|
|
75
|
+
config,
|
|
76
|
+
startDate: dto.startDate,
|
|
77
|
+
endDate: dto.endDate,
|
|
78
|
+
}));
|
|
74
79
|
if (status === enum_1.LimitedTimeOfferCampaignStatus.SCHEDULED) {
|
|
75
80
|
await this.scheduler.scheduleActivation(campaign._id, dto.startDate);
|
|
76
81
|
}
|
|
77
82
|
await this.scheduler.scheduleExpiry(campaign._id, dto.endDate);
|
|
78
83
|
return campaign;
|
|
79
84
|
}
|
|
85
|
+
deriveCampaignStatus(startDate) {
|
|
86
|
+
return startDate <= new Date()
|
|
87
|
+
? enum_1.LimitedTimeOfferCampaignStatus.ACTIVE
|
|
88
|
+
: enum_1.LimitedTimeOfferCampaignStatus.SCHEDULED;
|
|
89
|
+
}
|
|
80
90
|
async getCurrent() {
|
|
81
91
|
return this.repository.findCurrent();
|
|
82
92
|
}
|
|
@@ -102,7 +112,12 @@ let LtoCampaignService = class LtoCampaignService {
|
|
|
102
112
|
const { documents, total } = await this.repository.findHistory(dto);
|
|
103
113
|
return {
|
|
104
114
|
documents,
|
|
105
|
-
metadata: {
|
|
115
|
+
metadata: {
|
|
116
|
+
page: dto.page,
|
|
117
|
+
size: dto.size,
|
|
118
|
+
totalElements: total,
|
|
119
|
+
totalPages: Math.ceil(total / dto.size),
|
|
120
|
+
},
|
|
106
121
|
};
|
|
107
122
|
}
|
|
108
123
|
async update(dto) {
|
|
@@ -114,10 +129,24 @@ let LtoCampaignService = class LtoCampaignService {
|
|
|
114
129
|
if (this.shouldExpireImmediately(campaign.status, dto.endDate)) {
|
|
115
130
|
return this.applyImmediateExpiry(dto._id, updates);
|
|
116
131
|
}
|
|
132
|
+
const ltoScheduleEnabled = await (0, feature_flags_1.isLtoScheduleEnabled)();
|
|
133
|
+
const repeatDays = (updates.repeatDays ?? campaign.repeatDays ?? []);
|
|
134
|
+
if (ltoScheduleEnabled &&
|
|
135
|
+
updates.status === enum_1.LimitedTimeOfferCampaignStatus.SCHEDULED &&
|
|
136
|
+
repeatDays.length > 0) {
|
|
137
|
+
const occurrence = (0, limited_time_offer_campaign_builder_1.nextOccurrenceDate)(repeatDays, dto.startDate, dto.endDate);
|
|
138
|
+
updates.startDate = occurrence.startDate;
|
|
139
|
+
updates.endDate = occurrence.endDate;
|
|
140
|
+
}
|
|
117
141
|
const result = await this.repository.updateById(dto._id, updates);
|
|
118
142
|
if (!result)
|
|
119
143
|
throw (0, error_common_1.notFoundError)('Campaign not found after update');
|
|
120
|
-
|
|
144
|
+
if (ltoScheduleEnabled &&
|
|
145
|
+
campaign.status === enum_1.LimitedTimeOfferCampaignStatus.ACTIVE &&
|
|
146
|
+
result.status === enum_1.LimitedTimeOfferCampaignStatus.SCHEDULED) {
|
|
147
|
+
await this.lifecycle.demoteToScheduled(dto._id);
|
|
148
|
+
}
|
|
149
|
+
await this.rescheduleIfDatesChanged(result, campaign);
|
|
121
150
|
return result;
|
|
122
151
|
}
|
|
123
152
|
async cancel(campaignId) {
|
|
@@ -128,9 +157,6 @@ let LtoCampaignService = class LtoCampaignService {
|
|
|
128
157
|
await this.scheduler.cancelJobs(campaignId);
|
|
129
158
|
await this.lifecycle.cancelCampaign(campaignId);
|
|
130
159
|
}
|
|
131
|
-
async expire(campaignId) {
|
|
132
|
-
await this.lifecycle.expireCampaign(campaignId);
|
|
133
|
-
}
|
|
134
160
|
assertUpdateAllowed(campaign, dto) {
|
|
135
161
|
this.assertEditable(campaign.status);
|
|
136
162
|
if (campaign.status === enum_1.LimitedTimeOfferCampaignStatus.ACTIVE && !dto.confirmActive) {
|
|
@@ -152,16 +178,16 @@ let LtoCampaignService = class LtoCampaignService {
|
|
|
152
178
|
throw (0, error_common_1.notFoundError)('Campaign not found after expiry');
|
|
153
179
|
return result;
|
|
154
180
|
}
|
|
155
|
-
async rescheduleIfDatesChanged(
|
|
156
|
-
const datesChanged =
|
|
157
|
-
|
|
181
|
+
async rescheduleIfDatesChanged(result, original) {
|
|
182
|
+
const datesChanged = result.startDate.getTime() !== original.startDate.getTime() ||
|
|
183
|
+
result.endDate.getTime() !== original.endDate.getTime();
|
|
158
184
|
if (!datesChanged)
|
|
159
185
|
return;
|
|
160
|
-
await this.scheduler.cancelJobs(
|
|
161
|
-
if (
|
|
162
|
-
await this.scheduler.scheduleActivation(
|
|
186
|
+
await this.scheduler.cancelJobs(result._id);
|
|
187
|
+
if (result.status === enum_1.LimitedTimeOfferCampaignStatus.SCHEDULED) {
|
|
188
|
+
await this.scheduler.scheduleActivation(result._id, result.startDate);
|
|
163
189
|
}
|
|
164
|
-
await this.scheduler.scheduleExpiry(
|
|
190
|
+
await this.scheduler.scheduleExpiry(result._id, result.endDate);
|
|
165
191
|
}
|
|
166
192
|
async assertNoCampaignRunning() {
|
|
167
193
|
if (await this.repository.hasActiveCampaign()) {
|
|
@@ -174,8 +200,9 @@ let LtoCampaignService = class LtoCampaignService {
|
|
|
174
200
|
}
|
|
175
201
|
}
|
|
176
202
|
async loadConfigSnapshot() {
|
|
177
|
-
const config = await this.configService.getByType(enum_1.MarketingType.DISCOUNT)
|
|
178
|
-
|
|
203
|
+
const config = await this.configService.getByType(enum_1.MarketingType.DISCOUNT).catch(() => {
|
|
204
|
+
throw (0, error_common_1.badRequestError)('Global config is incomplete. Set discount options and max caps first.');
|
|
205
|
+
});
|
|
179
206
|
if (config.discountOptions.length === 0 || config.maxDiscountCaps.length === 0) {
|
|
180
207
|
throw (0, error_common_1.badRequestError)('Global config is incomplete. Set discount options and max caps first.');
|
|
181
208
|
}
|