@lyxa.ai/marketing 1.0.60 → 1.0.61
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 +2 -0
- package/dist/lib/event/event-initializations.js.map +1 -1
- package/dist/lib/event/event-listeners/event-listeners.d.ts +2 -0
- package/dist/lib/event/event-listeners/event-listeners.d.ts.map +1 -1
- package/dist/lib/event/event-listeners/event-listeners.js +69 -12
- package/dist/lib/event/event-listeners/event-listeners.js.map +1 -1
- package/dist/lib/event/events/marketing-product-seed.event.d.ts +1 -2
- 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/event/events/marketing-product-sync.event.d.ts +11 -0
- package/dist/lib/event/events/marketing-product-sync.event.d.ts.map +1 -0
- package/dist/lib/event/events/marketing-product-sync.event.js +12 -0
- package/dist/lib/event/events/marketing-product-sync.event.js.map +1 -0
- package/dist/lib/index.d.ts +8175 -33
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +4 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts +7630 -2
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.js +0 -7
- package/dist/lib/modules/coupon/routers/coupon.router.js.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts +0 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.js +3 -4
- package/dist/lib/modules/coupon/services/coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.js +2 -2
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.js.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts +6 -6
- package/dist/lib/modules/coupon/validations/coupon.validation.js +2 -2
- package/dist/lib/modules/coupon/validations/coupon.validation.js.map +1 -1
- 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/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/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 +11 -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 +6 -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 +8 -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 +64 -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 +3 -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 +66 -8
- 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 +37 -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 +249 -18
- 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 +15 -3
- 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 +24 -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 +19 -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 +10 -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 +43 -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 +195 -10
- 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 +29 -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.validation.d.ts +428 -33
- 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 +7 -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 +42 -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 +14 -3
- 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 +76 -16
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.d.ts +13 -0
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.d.ts.map +1 -0
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.js +75 -0
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.js.map +1 -0
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.d.ts +21 -0
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.d.ts.map +1 -0
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.js +83 -0
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.js.map +1 -0
- package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts +1 -0
- package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts.map +1 -1
- package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.js +29 -0
- package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.js.map +1 -1
- package/dist/lib/modules/marketing/routers/marketing.router.d.ts +14 -0
- package/dist/lib/modules/marketing/routers/marketing.router.d.ts.map +1 -1
- package/dist/lib/modules/marketing/routers/marketing.router.js +5 -0
- package/dist/lib/modules/marketing/routers/marketing.router.js.map +1 -1
- package/dist/lib/modules/marketing/services/index.d.ts +3 -0
- package/dist/lib/modules/marketing/services/index.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/index.js +3 -0
- package/dist/lib/modules/marketing/services/index.js.map +1 -1
- package/dist/lib/modules/marketing/services/marketing-conflict.repository.d.ts +9 -0
- package/dist/lib/modules/marketing/services/marketing-conflict.repository.d.ts.map +1 -0
- package/dist/lib/modules/marketing/services/marketing-conflict.repository.js +63 -0
- package/dist/lib/modules/marketing/services/marketing-conflict.repository.js.map +1 -0
- package/dist/lib/modules/marketing/services/marketing-conflict.service.d.ts +27 -0
- package/dist/lib/modules/marketing/services/marketing-conflict.service.d.ts.map +1 -0
- package/dist/lib/modules/marketing/services/marketing-conflict.service.js +135 -0
- package/dist/lib/modules/marketing/services/marketing-conflict.service.js.map +1 -0
- package/dist/lib/modules/marketing/services/marketing.service.d.ts +7 -2
- package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/marketing.service.js +97 -51
- package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/services/product-marketing.service.d.ts +2 -3
- package/dist/lib/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/product-marketing.service.js +42 -13
- package/dist/lib/modules/marketing/services/product-marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.repository.d.ts +14 -0
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.repository.d.ts.map +1 -0
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.repository.js +82 -0
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.repository.js.map +1 -0
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.service.d.ts +11 -0
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.service.d.ts.map +1 -0
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.service.js +99 -0
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.service.js.map +1 -0
- package/dist/lib/modules/marketing/services/spend-to-get-progress.repository.d.ts +9 -0
- package/dist/lib/modules/marketing/services/spend-to-get-progress.repository.d.ts.map +1 -0
- package/dist/lib/modules/marketing/services/spend-to-get-progress.repository.js +69 -0
- package/dist/lib/modules/marketing/services/spend-to-get-progress.repository.js.map +1 -0
- package/dist/lib/modules/marketing/services/spend-to-get-progress.service.d.ts +31 -0
- package/dist/lib/modules/marketing/services/spend-to-get-progress.service.d.ts.map +1 -0
- package/dist/lib/modules/marketing/services/spend-to-get-progress.service.js +123 -0
- package/dist/lib/modules/marketing/services/spend-to-get-progress.service.js.map +1 -0
- 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 +95 -27
- 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.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/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/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/marketing.validation.d.ts +17 -0
- package/dist/lib/modules/marketing/validations/marketing.validation.d.ts.map +1 -1
- package/dist/lib/modules/marketing/validations/marketing.validation.js +7 -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/spend-to-get-marketing.validation.d.ts +617 -0
- package/dist/lib/modules/marketing/validations/spend-to-get-marketing.validation.d.ts.map +1 -0
- package/dist/lib/modules/marketing/validations/spend-to-get-marketing.validation.js +119 -0
- package/dist/lib/modules/marketing/validations/spend-to-get-marketing.validation.js.map +1 -0
- package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +1 -1
- package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts +0 -1
- package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts.map +1 -1
- package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.js +2 -49
- package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.js.map +1 -1
- package/dist/lib/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +2 -2
- package/dist/lib/modules/spend-to-get-history/routers/index.d.ts +2 -0
- package/dist/lib/modules/spend-to-get-history/routers/index.d.ts.map +1 -0
- package/dist/lib/modules/spend-to-get-history/routers/index.js +18 -0
- package/dist/lib/modules/spend-to-get-history/routers/index.js.map +1 -0
- package/dist/lib/modules/spend-to-get-history/routers/spend-to-get-history.router.js +62 -0
- package/dist/lib/modules/spend-to-get-history/routers/spend-to-get-history.router.js.map +1 -0
- package/dist/lib/modules/spend-to-get-history/services/index.d.ts +2 -0
- package/dist/lib/modules/spend-to-get-history/services/index.d.ts.map +1 -0
- package/dist/lib/modules/spend-to-get-history/services/index.js +18 -0
- package/dist/lib/modules/spend-to-get-history/services/index.js.map +1 -0
- package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts +24 -0
- package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts.map +1 -0
- package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.js +136 -0
- package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.js.map +1 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.d.ts +24 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.d.ts.map +1 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.js +97 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.js.map +1 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.d.ts +271 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.d.ts.map +1 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.js +62 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.js.map +1 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.d.ts +24 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.d.ts.map +1 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.js +116 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.js.map +1 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.d.ts +232 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.d.ts.map +1 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.js +30 -0
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.js.map +1 -0
- package/dist/lib/modules/spend-to-get-history/validations/index.d.ts +2 -0
- package/dist/lib/modules/spend-to-get-history/validations/index.d.ts.map +1 -0
- package/dist/lib/modules/spend-to-get-history/validations/index.js +18 -0
- package/dist/lib/modules/spend-to-get-history/validations/index.js.map +1 -0
- package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.d.ts +232 -0
- package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.d.ts.map +1 -0
- package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.js +30 -0
- package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.js.map +1 -0
- package/dist/lib/modules/tournament/match/events/match-ended.consumer.d.ts +2 -0
- package/dist/lib/modules/tournament/match/events/match-ended.consumer.d.ts.map +1 -0
- package/dist/lib/modules/tournament/match/events/match-ended.consumer.js +15 -0
- package/dist/lib/modules/tournament/match/events/match-ended.consumer.js.map +1 -0
- package/dist/lib/modules/tournament/match/events/match-ended.event.d.ts +14 -0
- package/dist/lib/modules/tournament/match/events/match-ended.event.d.ts.map +1 -0
- package/dist/lib/modules/tournament/match/events/match-ended.event.js +12 -0
- package/dist/lib/modules/tournament/match/events/match-ended.event.js.map +1 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts +10 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts.map +1 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.js +23 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.js.map +1 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts +9 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts.map +1 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.worker.js +82 -0
- package/dist/lib/modules/tournament/notification/jobs/notification.worker.js.map +1 -0
- package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts +10 -0
- package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts.map +1 -0
- package/dist/lib/modules/tournament/notification/notification.schedule.config.js +15 -0
- package/dist/lib/modules/tournament/notification/notification.schedule.config.js.map +1 -0
- package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts +10 -0
- package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts.map +1 -0
- package/dist/lib/modules/tournament/notification/notification.scheduler.service.js +73 -0
- package/dist/lib/modules/tournament/notification/notification.scheduler.service.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 +2 -0
- package/dist/types/event/event-listeners/event-listeners.d.ts.map +1 -1
- package/dist/types/event/events/marketing-product-seed.event.d.ts +1 -2
- package/dist/types/event/events/marketing-product-seed.event.d.ts.map +1 -1
- package/dist/types/event/events/marketing-product-sync.event.d.ts +11 -0
- package/dist/types/event/events/marketing-product-sync.event.d.ts.map +1 -0
- package/dist/types/events/event-initializations.d.ts +2 -0
- package/dist/types/events/event-initializations.d.ts.map +1 -0
- package/dist/types/index.d.ts +8175 -33
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/coupon/routers/coupon.router.d.ts +7630 -2
- package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/coupon.service.d.ts +0 -1
- package/dist/types/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts +6 -6
- package/dist/types/modules/coupon/validations/create-coupon.validation.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/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 +8 -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 +3 -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 +249 -18
- 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 +24 -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 +10 -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 +195 -10
- 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 +428 -33
- 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 +7 -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 +14 -3
- package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.d.ts +13 -0
- package/dist/types/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.d.ts.map +1 -0
- package/dist/types/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.d.ts +21 -0
- package/dist/types/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.d.ts.map +1 -0
- package/dist/types/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts +1 -0
- package/dist/types/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts.map +1 -1
- package/dist/types/modules/marketing/routers/marketing.router.d.ts +14 -0
- package/dist/types/modules/marketing/routers/marketing.router.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/index.d.ts +3 -0
- package/dist/types/modules/marketing/services/index.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/marketing-conflict.repository.d.ts +9 -0
- package/dist/types/modules/marketing/services/marketing-conflict.repository.d.ts.map +1 -0
- package/dist/types/modules/marketing/services/marketing-conflict.service.d.ts +41 -0
- package/dist/types/modules/marketing/services/marketing-conflict.service.d.ts.map +1 -0
- package/dist/types/modules/marketing/services/marketing.service.d.ts +7 -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 +7 -3
- package/dist/types/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/spend-to-get-marketing.repository.d.ts +14 -0
- package/dist/types/modules/marketing/services/spend-to-get-marketing.repository.d.ts.map +1 -0
- package/dist/types/modules/marketing/services/spend-to-get-marketing.service.d.ts +20 -0
- package/dist/types/modules/marketing/services/spend-to-get-marketing.service.d.ts.map +1 -0
- package/dist/types/modules/marketing/services/spend-to-get-progress.repository.d.ts +9 -0
- package/dist/types/modules/marketing/services/spend-to-get-progress.repository.d.ts.map +1 -0
- package/dist/types/modules/marketing/services/spend-to-get-progress.service.d.ts +37 -0
- package/dist/types/modules/marketing/services/spend-to-get-progress.service.d.ts.map +1 -0
- 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.map +1 -1
- 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/index.d.ts +1 -0
- package/dist/types/modules/marketing/validations/index.d.ts.map +1 -1
- package/dist/types/modules/marketing/validations/marketing.validation.d.ts +17 -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/spend-to-get-marketing.validation.d.ts +630 -0
- package/dist/types/modules/marketing/validations/spend-to-get-marketing.validation.d.ts.map +1 -0
- package/dist/types/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +1 -1
- package/dist/types/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts +0 -5
- package/dist/types/modules/punch-marketing-history/services/punch-marketing-history.service.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/spend-to-get-history/routers/index.d.ts +2 -0
- package/dist/types/modules/spend-to-get-history/routers/index.d.ts.map +1 -0
- package/dist/types/modules/spend-to-get-history/services/index.d.ts +2 -0
- package/dist/types/modules/spend-to-get-history/services/index.d.ts.map +1 -0
- package/dist/types/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts +56 -0
- package/dist/types/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts.map +1 -0
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.repository.d.ts +24 -0
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.repository.d.ts.map +1 -0
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.router.d.ts +271 -0
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.router.d.ts.map +1 -0
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.service.d.ts +56 -0
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.service.d.ts.map +1 -0
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.validation.d.ts +241 -0
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.validation.d.ts.map +1 -0
- package/dist/types/modules/spend-to-get-history/validations/index.d.ts +2 -0
- package/dist/types/modules/spend-to-get-history/validations/index.d.ts.map +1 -0
- package/dist/types/modules/spend-to-get-history/validations/spend-to-get-history.validation.d.ts +241 -0
- package/dist/types/modules/spend-to-get-history/validations/spend-to-get-history.validation.d.ts.map +1 -0
- package/dist/types/modules/tournament/config/tournament-config.validation.d.ts +201 -0
- package/dist/types/modules/tournament/config/tournament-config.validation.d.ts.map +1 -0
- package/dist/types/modules/tournament/match/events/match-ended.consumer.d.ts +2 -0
- package/dist/types/modules/tournament/match/events/match-ended.consumer.d.ts.map +1 -0
- package/dist/types/modules/tournament/match/events/match-ended.event.d.ts +14 -0
- package/dist/types/modules/tournament/match/events/match-ended.event.d.ts.map +1 -0
- package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts +10 -0
- package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts.map +1 -0
- package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts +9 -0
- package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts.map +1 -0
- package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts +10 -0
- package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts.map +1 -0
- package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts +10 -0
- package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts.map +1 -0
- package/package.json +2 -2
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.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AAoB,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.valid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;IAC7C,UAAU,EAAE,OAAC,CAAC,IAAI,EAAE;CACvB,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,iCAAiC,GAAG,IAAA,iCAAoB,EAAC,gCAAwB,CAAC,CAAC;AACnF,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, 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,17 @@
|
|
|
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>;
|
|
7
11
|
cancelCampaign(campaignId: mongoose.Types.ObjectId): Promise<void>;
|
|
12
|
+
private expireRecurring;
|
|
13
|
+
private createNextOccurrence;
|
|
14
|
+
private cloneParticipants;
|
|
8
15
|
}
|
|
9
16
|
export declare const ltoCampaignLifecycleService: LtoCampaignLifecycleService;
|
|
10
17
|
//# 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;AAY5D,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;IAIpE,cAAc,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAarE,cAAc,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;YAajE,eAAe;YAef,oBAAoB;YAmBpB,iBAAiB;CAWlC;AAED,eAAO,MAAM,2BAA2B,6BAA6C,CAAC"}
|
|
@@ -45,21 +45,84 @@ 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");
|
|
49
56
|
let LtoCampaignLifecycleService = class LtoCampaignLifecycleService {
|
|
50
57
|
repository;
|
|
58
|
+
scheduler;
|
|
59
|
+
participantRepository;
|
|
60
|
+
marketingService;
|
|
61
|
+
sessionService;
|
|
51
62
|
constructor() {
|
|
52
63
|
this.repository = typedi_1.default.get(limited_time_offer_campaign_repository_1.LtoCampaignRepository);
|
|
64
|
+
this.scheduler = typedi_1.default.get(limited_time_offer_campaign_scheduler_service_1.LtoCampaignSchedulerService);
|
|
65
|
+
this.participantRepository = typedi_1.default.get(limited_time_offer_participant_repository_1.LtoParticipantRepository);
|
|
66
|
+
this.marketingService = typedi_1.default.get(limited_time_offer_participant_marketing_service_1.LtoParticipantMarketingService);
|
|
67
|
+
this.sessionService = typedi_1.default.get(limited_time_offer_campaign_session_service_1.LtoCampaignSessionService);
|
|
53
68
|
}
|
|
54
69
|
async activateCampaign(campaignId) {
|
|
55
70
|
await this.repository.setStatus(campaignId, enum_1.LimitedTimeOfferCampaignStatus.ACTIVE);
|
|
56
71
|
}
|
|
57
72
|
async expireCampaign(campaignId) {
|
|
58
|
-
await this.repository.
|
|
73
|
+
const campaign = await this.repository.findById(campaignId);
|
|
74
|
+
if (!campaign)
|
|
75
|
+
throw (0, error_common_1.notFoundError)('Campaign not found');
|
|
76
|
+
if ((campaign.repeatDays ?? []).length > 0) {
|
|
77
|
+
await this.expireRecurring(campaign);
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
await this.repository.setStatus(campaignId, enum_1.LimitedTimeOfferCampaignStatus.EXPIRED, true);
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
59
84
|
}
|
|
60
85
|
async cancelCampaign(campaignId) {
|
|
86
|
+
const campaign = await this.repository.findById(campaignId);
|
|
87
|
+
if (!campaign)
|
|
88
|
+
throw (0, error_common_1.notFoundError)('Campaign not found');
|
|
89
|
+
if ((campaign.repeatDays ?? []).length > 0 && campaign.status === enum_1.LimitedTimeOfferCampaignStatus.ACTIVE) {
|
|
90
|
+
const shopCount = await this.participantRepository.countNonWithdrawnByCampaign(campaign._id);
|
|
91
|
+
await this.sessionService.logSession(campaign, shopCount);
|
|
92
|
+
}
|
|
61
93
|
await this.repository.setStatus(campaignId, enum_1.LimitedTimeOfferCampaignStatus.CANCELLED, true);
|
|
62
94
|
}
|
|
95
|
+
async expireRecurring(campaign) {
|
|
96
|
+
const shopCount = await this.participantRepository.countNonWithdrawnByCampaign(campaign._id);
|
|
97
|
+
await this.marketingService.removeAllCampaignMarketings(campaign._id);
|
|
98
|
+
await this.sessionService.logSession(campaign, shopCount);
|
|
99
|
+
await this.repository.setStatus(campaign._id, enum_1.LimitedTimeOfferCampaignStatus.EXPIRED, true);
|
|
100
|
+
const { startDate, endDate } = (0, limited_time_offer_campaign_builder_1.nextOccurrenceDate)(campaign.repeatDays, campaign.startDate, campaign.endDate);
|
|
101
|
+
const nextCampaign = await this.createNextOccurrence(campaign, startDate, endDate);
|
|
102
|
+
await this.cloneParticipants(campaign._id, nextCampaign._id);
|
|
103
|
+
await this.scheduler.scheduleActivation(nextCampaign._id, startDate);
|
|
104
|
+
await this.scheduler.scheduleExpiry(nextCampaign._id, endDate);
|
|
105
|
+
}
|
|
106
|
+
async createNextOccurrence(campaign, startDate, endDate) {
|
|
107
|
+
return this.repository.create({
|
|
108
|
+
campaignNumber: await this.repository.nextCampaignNumber(),
|
|
109
|
+
title: campaign.title,
|
|
110
|
+
subTitle: campaign.subTitle,
|
|
111
|
+
startDate,
|
|
112
|
+
endDate,
|
|
113
|
+
status: enum_1.LimitedTimeOfferCampaignStatus.SCHEDULED,
|
|
114
|
+
campaignType: campaign.campaignType,
|
|
115
|
+
discountOptions: campaign.discountOptions,
|
|
116
|
+
maxDiscountCaps: campaign.maxDiscountCaps,
|
|
117
|
+
repeatDays: campaign.repeatDays,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
async cloneParticipants(fromCampaignId, toCampaignId) {
|
|
121
|
+
const participants = await this.participantRepository.findAllActiveByCampaign(fromCampaignId);
|
|
122
|
+
for (const participant of participants) {
|
|
123
|
+
await this.participantRepository.create(limited_time_offer_participant_builder_1.LtoParticipantQueryBuilder.buildCloneInput(toCampaignId, participant));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
63
126
|
};
|
|
64
127
|
exports.LtoCampaignLifecycleService = LtoCampaignLifecycleService;
|
|
65
128
|
exports.LtoCampaignLifecycleService = LtoCampaignLifecycleService = __decorate([
|
|
@@ -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;
|
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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M,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;AA1FY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,gBAAO,GAAE;;GACG,2BAA2B,CA0FvC;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 as Model, 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 {LtoParticipantMarketingService} from '@modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service';\nimport {LtoParticipantRepository} from '@modules/limited-time-offer/participant/limited-time-offer-participant.repository';\nimport {LtoParticipantQueryBuilder} from '@modules/limited-time-offer/participant/limited-time-offer-participant.builder';\nimport {LtoCampaignSessionService} from '@modules/limited-time-offer/session/limited-time-offer-campaign-session.service';\nimport {nextOccurrenceDate} from '../limited-time-offer-campaign.builder';\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 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 if ((campaign.repeatDays ?? []).length > 0) {\n await this.expireRecurring(campaign);\n return true;\n } else {\n await this.repository.setStatus(campaignId, LimitedTimeOfferCampaignStatus.EXPIRED, true);\n return false;\n }\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 ((campaign.repeatDays ?? []).length > 0 && campaign.status === LimitedTimeOfferCampaignStatus.ACTIVE) {\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 }\n\n private async expireRecurring(campaign: DocumentType<LimitedTimeOfferCampaign>): Promise<void> {\n const shopCount = await this.participantRepository.countNonWithdrawnByCampaign(campaign._id);\n await this.marketingService.removeAllCampaignMarketings(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,11 @@
|
|
|
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>;
|
|
5
7
|
cancelJobs(campaignId: mongoose.Types.ObjectId): Promise<void>;
|
|
8
|
+
rescheduleOrphanedRecurring(): Promise<void>;
|
|
6
9
|
private activationJobId;
|
|
7
10
|
private expiryJobId;
|
|
8
11
|
}
|
|
@@ -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;AAKhD,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;IAWjF,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,26 +1,63 @@
|
|
|
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");
|
|
12
49
|
let LtoCampaignSchedulerService = class LtoCampaignSchedulerService {
|
|
50
|
+
repository;
|
|
51
|
+
constructor() {
|
|
52
|
+
this.repository = typedi_1.default.get(limited_time_offer_campaign_repository_1.LtoCampaignRepository);
|
|
53
|
+
}
|
|
13
54
|
async scheduleActivation(campaignId, startDate) {
|
|
14
|
-
const delay = startDate.getTime() - Date.now();
|
|
15
|
-
if (delay <= 0)
|
|
16
|
-
return;
|
|
55
|
+
const delay = Math.max(0, startDate.getTime() - Date.now());
|
|
17
56
|
await (0, limited_time_offer_campaign_producer_1.removeLtoCampaignJob)(this.activationJobId(campaignId));
|
|
18
57
|
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
58
|
}
|
|
20
59
|
async scheduleExpiry(campaignId, endDate) {
|
|
21
|
-
const delay = endDate.getTime() - Date.now();
|
|
22
|
-
if (delay <= 0)
|
|
23
|
-
return;
|
|
60
|
+
const delay = Math.max(0, endDate.getTime() - Date.now());
|
|
24
61
|
await (0, limited_time_offer_campaign_producer_1.removeLtoCampaignJob)(this.expiryJobId(campaignId));
|
|
25
62
|
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
63
|
}
|
|
@@ -28,6 +65,26 @@ let LtoCampaignSchedulerService = class LtoCampaignSchedulerService {
|
|
|
28
65
|
await (0, limited_time_offer_campaign_producer_1.removeLtoCampaignJob)(this.activationJobId(campaignId));
|
|
29
66
|
await (0, limited_time_offer_campaign_producer_1.removeLtoCampaignJob)(this.expiryJobId(campaignId));
|
|
30
67
|
}
|
|
68
|
+
async rescheduleOrphanedRecurring() {
|
|
69
|
+
const queue = (0, limited_time_offer_campaign_producer_1.getLtoCampaignQueue)();
|
|
70
|
+
const delayed = await queue.getDelayed();
|
|
71
|
+
const existingJobIds = new Set(delayed.map(j => j.opts.jobId).filter(Boolean));
|
|
72
|
+
const scheduled = await this.repository.findScheduledRecurring();
|
|
73
|
+
for (const campaign of scheduled) {
|
|
74
|
+
if (!existingJobIds.has(this.activationJobId(campaign._id))) {
|
|
75
|
+
await this.scheduleActivation(campaign._id, campaign.startDate);
|
|
76
|
+
}
|
|
77
|
+
if (!existingJobIds.has(this.expiryJobId(campaign._id))) {
|
|
78
|
+
await this.scheduleExpiry(campaign._id, campaign.endDate);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const active = await this.repository.findActiveRecurring();
|
|
82
|
+
for (const campaign of active) {
|
|
83
|
+
if (!existingJobIds.has(this.expiryJobId(campaign._id))) {
|
|
84
|
+
await this.scheduleExpiry(campaign._id, campaign.endDate);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
31
88
|
activationJobId(campaignId) {
|
|
32
89
|
return `lto-activate-${campaignId.toString()}`;
|
|
33
90
|
}
|
|
@@ -37,6 +94,7 @@ let LtoCampaignSchedulerService = class LtoCampaignSchedulerService {
|
|
|
37
94
|
};
|
|
38
95
|
exports.LtoCampaignSchedulerService = LtoCampaignSchedulerService;
|
|
39
96
|
exports.LtoCampaignSchedulerService = LtoCampaignSchedulerService = __decorate([
|
|
40
|
-
(0, typedi_1.Service)()
|
|
97
|
+
(0, typedi_1.Service)(),
|
|
98
|
+
__metadata("design:paramtypes", [])
|
|
41
99
|
], LtoCampaignSchedulerService);
|
|
42
100
|
//# 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;AAG7G,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;QAEhF,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QAC5D,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;QAE1E,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QAC1D,MAAM,IAAA,2DAAoB,EAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;QACzD,MAAM,IAAA,wDAAiB,EACnB,yDAAkB,CAAC,MAAM,EACzB,EAAE,UAAU,EAAE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,CAAC;QACL,CAAC;QAGD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,mBAAmB,EAAE,CAAC;QAC3D,KAAK,MAAM,QAAQ,IAAI,MAAM,EAAE,CAAC;YAC5B,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBACtD,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;YAC9D,CAAC;QACL,CAAC;IACL,CAAC;IAEO,eAAe,CAAC,UAAmC;QACvD,OAAO,gBAAgB,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC;IACnD,CAAC;IAEO,WAAW,CAAC,UAAmC;QACnD,OAAO,cAAc,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC;IACjD,CAAC;CACJ,CAAA;AAjEY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,gBAAO,GAAE;;GACG,2BAA2B,CAiEvC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { mongoose } from '@typegoose/typegoose';\nimport { LimitedTimeOfferCampaignStatus } from '@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';\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 // ponytail: clamp to 0 so a start time that already passed (e.g. during downtime) fires immediately.\n const delay = Math.max(0, startDate.getTime() - Date.now());\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 // ponytail: clamp to 0 so an end time that already passed fires immediately (recovery -> recurrence).\n const delay = Math.max(0, endDate.getTime() - Date.now());\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 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;AASnD,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;
|
|
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;AASnD,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;IA6BhC,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
|
@@ -65,18 +65,27 @@ let LtoCampaignService = class LtoCampaignService {
|
|
|
65
65
|
}
|
|
66
66
|
async create(dto) {
|
|
67
67
|
await this.assertNoCampaignRunning();
|
|
68
|
-
const now = new Date();
|
|
69
68
|
const config = await this.loadConfigSnapshot();
|
|
70
|
-
const status = dto.startDate
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
const status = this.deriveCampaignStatus(dto.startDate);
|
|
70
|
+
const campaign = await this.repository.create(limited_time_offer_campaign_builder_1.LtoCampaignQueryBuilder.buildCreateInput({
|
|
71
|
+
dto,
|
|
72
|
+
status,
|
|
73
|
+
campaignNumber: await this.repository.nextCampaignNumber(),
|
|
74
|
+
config,
|
|
75
|
+
startDate: dto.startDate,
|
|
76
|
+
endDate: dto.endDate,
|
|
77
|
+
}));
|
|
74
78
|
if (status === enum_1.LimitedTimeOfferCampaignStatus.SCHEDULED) {
|
|
75
79
|
await this.scheduler.scheduleActivation(campaign._id, dto.startDate);
|
|
76
80
|
}
|
|
77
81
|
await this.scheduler.scheduleExpiry(campaign._id, dto.endDate);
|
|
78
82
|
return campaign;
|
|
79
83
|
}
|
|
84
|
+
deriveCampaignStatus(startDate) {
|
|
85
|
+
return startDate <= new Date()
|
|
86
|
+
? enum_1.LimitedTimeOfferCampaignStatus.ACTIVE
|
|
87
|
+
: enum_1.LimitedTimeOfferCampaignStatus.SCHEDULED;
|
|
88
|
+
}
|
|
80
89
|
async getCurrent() {
|
|
81
90
|
return this.repository.findCurrent();
|
|
82
91
|
}
|
|
@@ -102,7 +111,12 @@ let LtoCampaignService = class LtoCampaignService {
|
|
|
102
111
|
const { documents, total } = await this.repository.findHistory(dto);
|
|
103
112
|
return {
|
|
104
113
|
documents,
|
|
105
|
-
metadata: {
|
|
114
|
+
metadata: {
|
|
115
|
+
page: dto.page,
|
|
116
|
+
size: dto.size,
|
|
117
|
+
totalElements: total,
|
|
118
|
+
totalPages: Math.ceil(total / dto.size),
|
|
119
|
+
},
|
|
106
120
|
};
|
|
107
121
|
}
|
|
108
122
|
async update(dto) {
|
|
@@ -114,10 +128,16 @@ let LtoCampaignService = class LtoCampaignService {
|
|
|
114
128
|
if (this.shouldExpireImmediately(campaign.status, dto.endDate)) {
|
|
115
129
|
return this.applyImmediateExpiry(dto._id, updates);
|
|
116
130
|
}
|
|
131
|
+
const repeatDays = (updates.repeatDays ?? campaign.repeatDays ?? []);
|
|
132
|
+
if (updates.status === enum_1.LimitedTimeOfferCampaignStatus.SCHEDULED && repeatDays.length > 0) {
|
|
133
|
+
const occurrence = (0, limited_time_offer_campaign_builder_1.nextOccurrenceDate)(repeatDays, dto.startDate, dto.endDate);
|
|
134
|
+
updates.startDate = occurrence.startDate;
|
|
135
|
+
updates.endDate = occurrence.endDate;
|
|
136
|
+
}
|
|
117
137
|
const result = await this.repository.updateById(dto._id, updates);
|
|
118
138
|
if (!result)
|
|
119
139
|
throw (0, error_common_1.notFoundError)('Campaign not found after update');
|
|
120
|
-
await this.rescheduleIfDatesChanged(
|
|
140
|
+
await this.rescheduleIfDatesChanged(result, campaign);
|
|
121
141
|
return result;
|
|
122
142
|
}
|
|
123
143
|
async cancel(campaignId) {
|
|
@@ -128,9 +148,6 @@ let LtoCampaignService = class LtoCampaignService {
|
|
|
128
148
|
await this.scheduler.cancelJobs(campaignId);
|
|
129
149
|
await this.lifecycle.cancelCampaign(campaignId);
|
|
130
150
|
}
|
|
131
|
-
async expire(campaignId) {
|
|
132
|
-
await this.lifecycle.expireCampaign(campaignId);
|
|
133
|
-
}
|
|
134
151
|
assertUpdateAllowed(campaign, dto) {
|
|
135
152
|
this.assertEditable(campaign.status);
|
|
136
153
|
if (campaign.status === enum_1.LimitedTimeOfferCampaignStatus.ACTIVE && !dto.confirmActive) {
|
|
@@ -152,16 +169,16 @@ let LtoCampaignService = class LtoCampaignService {
|
|
|
152
169
|
throw (0, error_common_1.notFoundError)('Campaign not found after expiry');
|
|
153
170
|
return result;
|
|
154
171
|
}
|
|
155
|
-
async rescheduleIfDatesChanged(
|
|
156
|
-
const datesChanged =
|
|
157
|
-
|
|
172
|
+
async rescheduleIfDatesChanged(result, original) {
|
|
173
|
+
const datesChanged = result.startDate.getTime() !== original.startDate.getTime() ||
|
|
174
|
+
result.endDate.getTime() !== original.endDate.getTime();
|
|
158
175
|
if (!datesChanged)
|
|
159
176
|
return;
|
|
160
|
-
await this.scheduler.cancelJobs(
|
|
161
|
-
if (
|
|
162
|
-
await this.scheduler.scheduleActivation(
|
|
177
|
+
await this.scheduler.cancelJobs(result._id);
|
|
178
|
+
if (result.status === enum_1.LimitedTimeOfferCampaignStatus.SCHEDULED) {
|
|
179
|
+
await this.scheduler.scheduleActivation(result._id, result.startDate);
|
|
163
180
|
}
|
|
164
|
-
await this.scheduler.scheduleExpiry(
|
|
181
|
+
await this.scheduler.scheduleExpiry(result._id, result.endDate);
|
|
165
182
|
}
|
|
166
183
|
async assertNoCampaignRunning() {
|
|
167
184
|
if (await this.repository.hasActiveCampaign()) {
|
|
@@ -174,8 +191,9 @@ let LtoCampaignService = class LtoCampaignService {
|
|
|
174
191
|
}
|
|
175
192
|
}
|
|
176
193
|
async loadConfigSnapshot() {
|
|
177
|
-
const config = await this.configService.getByType(enum_1.MarketingType.DISCOUNT)
|
|
178
|
-
|
|
194
|
+
const config = await this.configService.getByType(enum_1.MarketingType.DISCOUNT).catch(() => {
|
|
195
|
+
throw (0, error_common_1.badRequestError)('Global config is incomplete. Set discount options and max caps first.');
|
|
196
|
+
});
|
|
179
197
|
if (config.discountOptions.length === 0 || config.maxDiscountCaps.length === 0) {
|
|
180
198
|
throw (0, error_common_1.badRequestError)('Global config is incomplete. Set discount options and max caps first.');
|
|
181
199
|
}
|