@lyxa.ai/marketing 1.0.61 → 1.0.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/event/event-initializations.d.ts.map +1 -1
- package/dist/lib/event/event-initializations.js +0 -2
- package/dist/lib/event/event-initializations.js.map +1 -1
- package/dist/lib/event/event-listeners/event-listeners.d.ts +0 -2
- package/dist/lib/event/event-listeners/event-listeners.d.ts.map +1 -1
- package/dist/lib/event/event-listeners/event-listeners.js +12 -69
- package/dist/lib/event/event-listeners/event-listeners.js.map +1 -1
- package/dist/lib/event/events/marketing-product-seed.event.d.ts +2 -1
- package/dist/lib/event/events/marketing-product-seed.event.d.ts.map +1 -1
- package/dist/lib/event/events/marketing-product-seed.event.js.map +1 -1
- package/dist/lib/index.d.ts +194 -650
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +1 -5
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts +59 -0
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.js +7 -0
- package/dist/lib/modules/coupon/routers/coupon.router.js.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts +1 -0
- package/dist/lib/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.js +3 -0
- package/dist/lib/modules/coupon/services/coupon.service.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 +1 -4
- 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 +1 -4
- 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 +0 -3
- 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 +8 -54
- 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 +0 -11
- 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 +0 -6
- 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 +1 -0
- 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 +6 -2
- 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 +3 -16
- 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 +3 -22
- 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 +0 -2
- 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 +0 -12
- 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 +35 -242
- 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 +1 -19
- 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 +1 -8
- 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 +1 -64
- 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 +0 -3
- 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 +8 -66
- 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 +19 -37
- 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 +18 -249
- 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 +0 -2
- package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js +3 -15
- 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 +3 -24
- 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 +1 -19
- 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 +0 -10
- 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 +0 -43
- 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 +10 -195
- 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 +0 -29
- 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 +33 -428
- 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 +6 -16
- 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 +4 -7
- 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 +7 -42
- 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 +3 -14
- 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 +16 -76
- 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 +0 -1
- package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts.map +1 -1
- package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.js +0 -29
- package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.js.map +1 -1
- package/dist/lib/modules/marketing/routers/marketing.router.d.ts +0 -14
- package/dist/lib/modules/marketing/routers/marketing.router.d.ts.map +1 -1
- package/dist/lib/modules/marketing/routers/marketing.router.js +0 -5
- package/dist/lib/modules/marketing/routers/marketing.router.js.map +1 -1
- package/dist/lib/modules/marketing/services/index.d.ts +0 -3
- package/dist/lib/modules/marketing/services/index.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/index.js +0 -3
- package/dist/lib/modules/marketing/services/index.js.map +1 -1
- package/dist/lib/modules/marketing/services/marketing.service.d.ts +2 -7
- package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/marketing.service.js +51 -97
- package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/services/product-marketing.service.d.ts +3 -2
- package/dist/lib/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/product-marketing.service.js +13 -42
- package/dist/lib/modules/marketing/services/product-marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.js +27 -95
- package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/validations/all-marketings.validation.d.ts.map +1 -1
- package/dist/lib/modules/marketing/validations/all-marketings.validation.js +0 -3
- 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 +0 -1
- package/dist/lib/modules/marketing/validations/index.d.ts.map +1 -1
- package/dist/lib/modules/marketing/validations/index.js +0 -1
- package/dist/lib/modules/marketing/validations/index.js.map +1 -1
- package/dist/lib/modules/marketing/validations/marketing.validation.d.ts +0 -17
- package/dist/lib/modules/marketing/validations/marketing.validation.d.ts.map +1 -1
- package/dist/lib/modules/marketing/validations/marketing.validation.js +1 -7
- 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/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 +1 -0
- 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 +49 -2
- 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/types/event/event-initializations.d.ts.map +1 -1
- package/dist/types/event/event-listeners/event-listeners.d.ts +0 -2
- package/dist/types/event/event-listeners/event-listeners.d.ts.map +1 -1
- package/dist/types/event/events/marketing-product-seed.event.d.ts +2 -1
- package/dist/types/event/events/marketing-product-seed.event.d.ts.map +1 -1
- package/dist/types/index.d.ts +194 -650
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/coupon/routers/coupon.router.d.ts +59 -0
- package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/coupon.service.d.ts +1 -0
- package/dist/types/modules/coupon/services/coupon.service.d.ts.map +1 -1
- 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 +8 -54
- 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 +1 -0
- 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 +3 -16
- 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 +0 -2
- 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 +35 -242
- 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 +1 -8
- 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 +0 -3
- 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 +18 -249
- 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 +0 -2
- 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 +3 -24
- 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 +0 -10
- 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 +10 -195
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +33 -428
- 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 +4 -7
- 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 +3 -14
- 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 +0 -1
- package/dist/types/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts.map +1 -1
- package/dist/types/modules/marketing/routers/marketing.router.d.ts +0 -14
- package/dist/types/modules/marketing/routers/marketing.router.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/index.d.ts +0 -3
- package/dist/types/modules/marketing/services/index.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/marketing.service.d.ts +2 -7
- package/dist/types/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/product-marketing.service.d.ts +3 -7
- package/dist/types/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/synchronize-product-marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/validations/all-marketings.validation.d.ts.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 +0 -1
- package/dist/types/modules/marketing/validations/index.d.ts.map +1 -1
- package/dist/types/modules/marketing/validations/marketing.validation.d.ts +0 -17
- 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/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 +5 -0
- 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/package.json +2 -2
- package/dist/lib/event/events/marketing-product-sync.event.d.ts +0 -11
- package/dist/lib/event/events/marketing-product-sync.event.d.ts.map +0 -1
- package/dist/lib/event/events/marketing-product-sync.event.js +0 -12
- package/dist/lib/event/events/marketing-product-sync.event.js.map +0 -1
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.d.ts +0 -13
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.d.ts.map +0 -1
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.js +0 -75
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.js.map +0 -1
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.d.ts +0 -21
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.d.ts.map +0 -1
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.js +0 -83
- package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.js.map +0 -1
- package/dist/lib/modules/marketing/services/marketing-conflict.repository.d.ts +0 -9
- package/dist/lib/modules/marketing/services/marketing-conflict.repository.d.ts.map +0 -1
- package/dist/lib/modules/marketing/services/marketing-conflict.repository.js +0 -63
- package/dist/lib/modules/marketing/services/marketing-conflict.repository.js.map +0 -1
- package/dist/lib/modules/marketing/services/marketing-conflict.service.d.ts +0 -27
- package/dist/lib/modules/marketing/services/marketing-conflict.service.d.ts.map +0 -1
- package/dist/lib/modules/marketing/services/marketing-conflict.service.js +0 -135
- package/dist/lib/modules/marketing/services/marketing-conflict.service.js.map +0 -1
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.repository.d.ts +0 -14
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.repository.d.ts.map +0 -1
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.repository.js +0 -82
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.repository.js.map +0 -1
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.service.d.ts +0 -11
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.service.d.ts.map +0 -1
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.service.js +0 -99
- package/dist/lib/modules/marketing/services/spend-to-get-marketing.service.js.map +0 -1
- package/dist/lib/modules/marketing/services/spend-to-get-progress.repository.d.ts +0 -9
- package/dist/lib/modules/marketing/services/spend-to-get-progress.repository.d.ts.map +0 -1
- package/dist/lib/modules/marketing/services/spend-to-get-progress.repository.js +0 -69
- package/dist/lib/modules/marketing/services/spend-to-get-progress.repository.js.map +0 -1
- package/dist/lib/modules/marketing/services/spend-to-get-progress.service.d.ts +0 -31
- package/dist/lib/modules/marketing/services/spend-to-get-progress.service.d.ts.map +0 -1
- package/dist/lib/modules/marketing/services/spend-to-get-progress.service.js +0 -123
- package/dist/lib/modules/marketing/services/spend-to-get-progress.service.js.map +0 -1
- package/dist/lib/modules/marketing/validations/spend-to-get-marketing.validation.d.ts +0 -617
- package/dist/lib/modules/marketing/validations/spend-to-get-marketing.validation.d.ts.map +0 -1
- package/dist/lib/modules/marketing/validations/spend-to-get-marketing.validation.js +0 -119
- package/dist/lib/modules/marketing/validations/spend-to-get-marketing.validation.js.map +0 -1
- package/dist/lib/modules/spend-to-get-history/routers/index.d.ts +0 -2
- package/dist/lib/modules/spend-to-get-history/routers/index.d.ts.map +0 -1
- package/dist/lib/modules/spend-to-get-history/routers/index.js +0 -18
- package/dist/lib/modules/spend-to-get-history/routers/index.js.map +0 -1
- package/dist/lib/modules/spend-to-get-history/routers/spend-to-get-history.router.js +0 -62
- package/dist/lib/modules/spend-to-get-history/routers/spend-to-get-history.router.js.map +0 -1
- package/dist/lib/modules/spend-to-get-history/services/index.d.ts +0 -2
- package/dist/lib/modules/spend-to-get-history/services/index.d.ts.map +0 -1
- package/dist/lib/modules/spend-to-get-history/services/index.js +0 -18
- package/dist/lib/modules/spend-to-get-history/services/index.js.map +0 -1
- package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts +0 -24
- package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts.map +0 -1
- package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.js +0 -136
- package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.js.map +0 -1
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.d.ts +0 -24
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.d.ts.map +0 -1
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.js +0 -97
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.js.map +0 -1
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.d.ts +0 -271
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.d.ts.map +0 -1
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.js +0 -62
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.js.map +0 -1
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.d.ts +0 -24
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.d.ts.map +0 -1
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.js +0 -116
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.js.map +0 -1
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.d.ts +0 -232
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.d.ts.map +0 -1
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.js +0 -30
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.js.map +0 -1
- package/dist/lib/modules/spend-to-get-history/validations/index.d.ts +0 -2
- package/dist/lib/modules/spend-to-get-history/validations/index.d.ts.map +0 -1
- package/dist/lib/modules/spend-to-get-history/validations/index.js +0 -18
- package/dist/lib/modules/spend-to-get-history/validations/index.js.map +0 -1
- package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.d.ts +0 -232
- package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.d.ts.map +0 -1
- package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.js +0 -30
- package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.js.map +0 -1
- package/dist/lib/modules/tournament/match/events/match-ended.consumer.d.ts +0 -2
- package/dist/lib/modules/tournament/match/events/match-ended.consumer.d.ts.map +0 -1
- package/dist/lib/modules/tournament/match/events/match-ended.consumer.js +0 -15
- package/dist/lib/modules/tournament/match/events/match-ended.consumer.js.map +0 -1
- package/dist/lib/modules/tournament/match/events/match-ended.event.d.ts +0 -14
- package/dist/lib/modules/tournament/match/events/match-ended.event.d.ts.map +0 -1
- package/dist/lib/modules/tournament/match/events/match-ended.event.js +0 -12
- package/dist/lib/modules/tournament/match/events/match-ended.event.js.map +0 -1
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts +0 -10
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts.map +0 -1
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.js +0 -23
- package/dist/lib/modules/tournament/notification/jobs/notification.producer.js.map +0 -1
- package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts +0 -9
- package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts.map +0 -1
- package/dist/lib/modules/tournament/notification/jobs/notification.worker.js +0 -82
- package/dist/lib/modules/tournament/notification/jobs/notification.worker.js.map +0 -1
- package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts +0 -10
- package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts.map +0 -1
- package/dist/lib/modules/tournament/notification/notification.schedule.config.js +0 -15
- package/dist/lib/modules/tournament/notification/notification.schedule.config.js.map +0 -1
- package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts +0 -10
- package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts.map +0 -1
- package/dist/lib/modules/tournament/notification/notification.scheduler.service.js +0 -73
- package/dist/lib/modules/tournament/notification/notification.scheduler.service.js.map +0 -1
- package/dist/types/event/events/marketing-product-sync.event.d.ts +0 -11
- package/dist/types/event/events/marketing-product-sync.event.d.ts.map +0 -1
- package/dist/types/events/event-initializations.d.ts +0 -2
- package/dist/types/events/event-initializations.d.ts.map +0 -1
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts +0 -1
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts.map +0 -1
- package/dist/types/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.d.ts +0 -13
- package/dist/types/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.d.ts.map +0 -1
- package/dist/types/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.d.ts +0 -21
- package/dist/types/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.d.ts.map +0 -1
- package/dist/types/modules/marketing/services/marketing-conflict.repository.d.ts +0 -9
- package/dist/types/modules/marketing/services/marketing-conflict.repository.d.ts.map +0 -1
- package/dist/types/modules/marketing/services/marketing-conflict.service.d.ts +0 -41
- package/dist/types/modules/marketing/services/marketing-conflict.service.d.ts.map +0 -1
- package/dist/types/modules/marketing/services/spend-to-get-marketing.repository.d.ts +0 -14
- package/dist/types/modules/marketing/services/spend-to-get-marketing.repository.d.ts.map +0 -1
- package/dist/types/modules/marketing/services/spend-to-get-marketing.service.d.ts +0 -20
- package/dist/types/modules/marketing/services/spend-to-get-marketing.service.d.ts.map +0 -1
- package/dist/types/modules/marketing/services/spend-to-get-progress.repository.d.ts +0 -9
- package/dist/types/modules/marketing/services/spend-to-get-progress.repository.d.ts.map +0 -1
- package/dist/types/modules/marketing/services/spend-to-get-progress.service.d.ts +0 -37
- package/dist/types/modules/marketing/services/spend-to-get-progress.service.d.ts.map +0 -1
- package/dist/types/modules/marketing/validations/spend-to-get-marketing.validation.d.ts +0 -630
- package/dist/types/modules/marketing/validations/spend-to-get-marketing.validation.d.ts.map +0 -1
- package/dist/types/modules/spend-to-get-history/routers/index.d.ts +0 -2
- package/dist/types/modules/spend-to-get-history/routers/index.d.ts.map +0 -1
- package/dist/types/modules/spend-to-get-history/services/index.d.ts +0 -2
- package/dist/types/modules/spend-to-get-history/services/index.d.ts.map +0 -1
- package/dist/types/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts +0 -56
- package/dist/types/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts.map +0 -1
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.repository.d.ts +0 -24
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.repository.d.ts.map +0 -1
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.router.d.ts +0 -271
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.router.d.ts.map +0 -1
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.service.d.ts +0 -56
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.service.d.ts.map +0 -1
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.validation.d.ts +0 -241
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.validation.d.ts.map +0 -1
- package/dist/types/modules/spend-to-get-history/validations/index.d.ts +0 -2
- package/dist/types/modules/spend-to-get-history/validations/index.d.ts.map +0 -1
- package/dist/types/modules/spend-to-get-history/validations/spend-to-get-history.validation.d.ts +0 -241
- package/dist/types/modules/spend-to-get-history/validations/spend-to-get-history.validation.d.ts.map +0 -1
- package/dist/types/modules/tournament/config/tournament-config.validation.d.ts +0 -201
- package/dist/types/modules/tournament/config/tournament-config.validation.d.ts.map +0 -1
- package/dist/types/modules/tournament/match/events/match-ended.consumer.d.ts +0 -2
- package/dist/types/modules/tournament/match/events/match-ended.consumer.d.ts.map +0 -1
- package/dist/types/modules/tournament/match/events/match-ended.event.d.ts +0 -14
- package/dist/types/modules/tournament/match/events/match-ended.event.d.ts.map +0 -1
- package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts +0 -10
- package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts.map +0 -1
- package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts +0 -9
- package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts.map +0 -1
- package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts +0 -10
- package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts.map +0 -1
- package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts +0 -10
- package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-marketing.service.js","sourceRoot":"/","sources":["modules/marketing/services/product-marketing.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAC5C,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nModelType } from '@typegoose/typegoose';\nimport {\n\tMarketingModel,\n\tProductMarketingModel,\n\tProductMarketing as Model,\n\tProductModel,\n} from '@lyxa.ai/core/dist/libraries/mongo/models/';\nimport {\n\tBatchCreateProductMarketingsInputDTO,\n\tCreateProductMarketingDTO as CreateDTO,\n\tQueryProductMarketingDTO as QueryDTO,\n\tQueryMultipleProductMarketingDTO,\n\tUpdateProductMarketingDTO as UpdateDTO,\n} from '@modules/marketing/validations';\nimport { SoftDeleteModel } from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport { FilterDTO, PaginatedResponse } from '@lyxa.ai/core/dist/utilities/validation';\nimport { createRawDocumentPaginatorObject, PaginatorOptions } from '@lyxa.ai/core/dist/utilities/pagination';\nimport { ModelType } from '@typegoose/typegoose/lib/types';\nimport { MarketingCampaignType, MarketingStatus, ValueType } from '@lyxa.ai/core/dist/utilities/enum';\nimport {\n\tSynchronizeProductMarketingService,\n\tsynchronizeProductMarketingService,\n} from './synchronize-product-marketing.service';\nimport { badRequestError } from '@lyxa.ai/core/dist/utilities/error-common';\n\n@Service()\nexport class ProductMarketingService {\n\tprivate model: typeof ProductMarketingModel & SoftDeleteModel<Model>;\n\tprivate productModel: typeof ProductModel;\n\n\tprivate syncProductsMarketingInfoService: SynchronizeProductMarketingService;\n\n\tconstructor() {\n\t\tthis.model = ProductMarketingModel as typeof ProductMarketingModel & SoftDeleteModel<Model>;\n\t\tthis.productModel = ProductModel;\n\n\t\tthis.syncProductsMarketingInfoService = synchronizeProductMarketingService;\n\t}\n\n\t/**\n\t * Create a new record\n\t * @param data Data for the new record\n\t */\n\tpublic async create(data: CreateDTO): Promise<DocumentType<Model>> {\n\t\tconst result = await this.model.create(data);\n\t\tif (!result) badRequestError('Product marketing creation failed');\n\t\treturn result;\n\t}\n\n\t/**\n\t * Bulk create new records\n\t * @param data Data for the new records\n\t */\n\tpublic async bulkCreate(data: CreateDTO[]): Promise<void> {\n\t\tawait this.model.insertMany(data, { ordered: false });\n\t}\n\n\tpublic async bulkCreateFromCursor<T>(cursor: AsyncIterable<T>, mapper: (item: T) => any) {\n\t\tconst BATCH_SIZE = 500;\n\t\tconst batch = [];\n\n\t\tfor await (const item of cursor) {\n\t\t\tbatch.push(mapper(item));\n\n\t\t\tif (batch.length === BATCH_SIZE) {\n\t\t\t\tawait this.bulkCreate(batch);\n\t\t\t\tbatch.length = 0;\n\t\t\t}\n\t\t}\n\n\t\tif (batch.length) {\n\t\t\tawait this.bulkCreate(batch);\n\t\t}\n\t}\n\n\tpublic async bulkCreateFromArray<T>(items: Iterable<T>, mapper: (item: T) => any) {\n\t\tconst BATCH_SIZE = 500;\n\t\tconst batch = [];\n\n\t\tfor (const item of items) {\n\t\t\tbatch.push(mapper(item));\n\n\t\t\tif (batch.length === BATCH_SIZE) {\n\t\t\t\tawait this.bulkCreate(batch);\n\t\t\t\tbatch.length = 0;\n\t\t\t}\n\t\t}\n\n\t\tif (batch.length) {\n\t\t\tawait this.bulkCreate(batch);\n\t\t}\n\t}\n\n\tprivate async buildProductsMap(data: {\n\t\tproducts: {\n\t\t\tproduct: mongoose.Types.ObjectId;\n\t\t\tvalue?: number;\n\t\t\tvalueType?: ValueType | null;\n\t\t}[];\n\t\tisBuy1Get1: boolean;\n\t\tcategories?: mongoose.Types.ObjectId[];\n\t\tcategoryValue?: number;\n\t\tcategoryValueType?: ValueType;\n\t}): Promise<Record<string, { value?: number; valueType?: ValueType; isBuy1Get1?: boolean }>> {\n\t\tconst map: Record<string, { value?: number; valueType?: ValueType; isBuy1Get1?: boolean }> = {};\n\n\t\t// explicit products\n\t\tfor (const p of data.products || []) {\n\t\t\tif (data.isBuy1Get1) {\n\t\t\t\tmap[p.product.toString()] = {\n\t\t\t\t\tisBuy1Get1: true,\n\t\t\t\t};\n\t\t\t} else if (p.value !== undefined && p.valueType) {\n\t\t\t\tmap[p.product.toString()] = {\n\t\t\t\t\tvalue: Number(p.value),\n\t\t\t\t\tvalueType: p.valueType,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\t// category products\n\t\tif (data.categories?.length) {\n\t\t\tconst categoryProducts = await this.productModel\n\t\t\t\t.find({ shopCategory: { $in: data.categories } })\n\t\t\t\t.select('_id')\n\t\t\t\t.lean();\n\n\t\t\tfor (const p of categoryProducts) {\n\t\t\t\tconst id = p._id.toString();\n\t\t\t\tif (!map[id]) {\n\t\t\t\t\tif (data.isBuy1Get1) {\n\t\t\t\t\t\tmap[id.toString()] = {\n\t\t\t\t\t\t\tisBuy1Get1: true,\n\t\t\t\t\t\t};\n\t\t\t\t\t} else if (data.categoryValue !== undefined && data.categoryValueType) {\n\t\t\t\t\t\tmap[id] = {\n\t\t\t\t\t\t\tvalue: Number(data.categoryValue),\n\t\t\t\t\t\t\tvalueType: data.categoryValueType,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn map;\n\t}\n\n\tpublic async createProductMarketings(data: BatchCreateProductMarketingsInputDTO): Promise<void> {\n\t\tconst {\n\t\t\tshop,\n\t\t\tmarketingId,\n\t\t\tproducts,\n\t\t\tcategories,\n\t\t\tisEntireMenu,\n\t\t\tisAppliedByCompany,\n\t\t\tcategoryValue,\n\t\t\tcategoryValueType,\n\t\t\tvalue,\n\t\t\tvalueType,\n\t\t\tisBuy1Get1,\n\t\t} = data;\n\n\t\tif (isEntireMenu) {\n\t\t\tawait this.bulkCreateFromCursor(\n\t\t\t\tthis.productModel.find({ shop }).select('_id').lean().cursor(),\n\t\t\t\tproduct => ({\n\t\t\t\t\tmarketing: marketingId,\n\t\t\t\t\tproduct: product._id,\n\t\t\t\t\tvalue,\n\t\t\t\t\tvalueType,\n\t\t\t\t\tisAppliedByCompany,\n\t\t\t\t\tisBuy1Get1,\n\t\t\t\t})\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst productsMap = await this.buildProductsMap({\n\t\t\tproducts: data.products,\n\t\t\tisBuy1Get1: data.isBuy1Get1,\n\t\t\tcategories: data.categories,\n\t\t\tcategoryValue: data.categoryValue,\n\t\t\tcategoryValueType: data.categoryValueType,\n\t\t});\n\n\t\tawait this.bulkCreateFromArray(Object.entries(productsMap), ([productId, info]) => ({\n\t\t\tmarketing: marketingId,\n\t\t\tproduct: new mongoose.Types.ObjectId(productId),\n\t\t\tvalue: info.value,\n\t\t\tvalueType: info.valueType,\n\t\t\tisAppliedByCompany,\n\t\t\tisBuy1Get1: info.isBuy1Get1,\n\t\t}));\n\t}\n\n\t/**\n\t * Get record by ID\n\t * @param id ID of the record\n\t */\n\tpublic async findById(id: string | mongoose.Types.ObjectId): Promise<DocumentType<Model>> {\n\t\tconst result = await this.model.findOne({\n\t\t\t_id: id,\n\t\t\tdeletedAt: null,\n\t\t});\n\t\tif (!result) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Record not found',\n\t\t\t});\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Get records\n\t * @param query Query to find records\n\t */\n\tpublic async find(data?: Partial<FilterDTO>): Promise<PaginatedResponse<DocumentType<ModelType<Model>>>> {\n\t\ttry {\n\t\t\tconst paginate = createRawDocumentPaginatorObject(this.model as ReturnModelType<typeof this.model>);\n\t\t\tconst options: PaginatorOptions<typeof Model> = {\n\t\t\t\tpage: data?.page,\n\t\t\t\tsize: data?.size,\n\t\t\t\tsort: data?.sort,\n\t\t\t\tquery: data?.query,\n\t\t\t\tselect: data?.select,\n\t\t\t\tpopulate: data?.populate,\n\t\t\t};\n\t\t\tconst paginatedResult = await paginate(options);\n\t\t\treturn paginatedResult;\n\t\t} catch (err) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: `err: ${err}`,\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Update single record based on query\n\t * @param query Query to find the record\n\t * @param data Data to update\n\t */\n\tpublic async updateOne(query: QueryDTO, data: UpdateDTO): Promise<string> {\n\t\tconst record = await this.model.findOneAndUpdate(query, data, {\n\t\t\tnew: true,\n\t\t\trunValidators: true,\n\t\t});\n\n\t\tif (!record) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: `Record not found`,\n\t\t\t});\n\t\t}\n\n\t\treturn 'Records updated successfully';\n\t}\n\n\t/**\n\t * Delete record\n\t * @param data Data for delete\n\t */\n\tpublic async deleteMany(filter: QueryDTO, softDelete: boolean): Promise<string> {\n\t\tconst productMarketings = await this.model.find(filter);\n\n\t\tawait this.model.deleteRecords(filter, softDelete);\n\n\t\tconst productIds: mongoose.Types.ObjectId[] = productMarketings\n\t\t\t.map((r: any) => r.product)\n\t\t\t.filter((p: any): p is mongoose.Types.ObjectId | string => !!p) // filter out null/undefined\n\t\t\t.map((p: any) => (p instanceof mongoose.Types.ObjectId ? p : new mongoose.Types.ObjectId(p))); // convert to ObjectId\n\n\t\tconst uniqueProductIds = [...new Set(productIds.map((id: any) => new mongoose.Types.ObjectId(id)))];\n\t\tawait this.syncProductsMarketingInfoService.syncProductMarketingInfoByProductIds(uniqueProductIds);\n\n\t\treturn 'Record deleted successfully';\n\t}\n\n\tpublic async deleteManyByMarketingIds(marketingIds: mongoose.Types.ObjectId[], softDelete: boolean): Promise<void> {\n\t\tif (marketingIds.length === 0) return;\n\n\t\tconst productMarketings = await this.model\n\t\t\t.find({ marketing: { $in: marketingIds } })\n\t\t\t.select('product')\n\t\t\t.lean();\n\n\t\tawait this.model.deleteRecords({ marketing: { $in: marketingIds } }, softDelete);\n\n\t\tconst uniqueProductIds = [\n\t\t\t...new Map(\n\t\t\t\tproductMarketings\n\t\t\t\t\t.map((r: any) => r.product)\n\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t.map((p: any) => {\n\t\t\t\t\t\tconst id = p instanceof mongoose.Types.ObjectId ? p : new mongoose.Types.ObjectId(p);\n\t\t\t\t\t\treturn [id.toString(), id] as [string, mongoose.Types.ObjectId];\n\t\t\t\t\t})\n\t\t\t).values(),\n\t\t];\n\n\t\tif (uniqueProductIds.length) {\n\t\t\tawait this.syncProductsMarketingInfoService.syncProductMarketingInfoByProductIds(uniqueProductIds);\n\t\t}\n\t}\n\n\tpublic async syncProductMarketingInfo(marketingId: mongoose.Types.ObjectId) {\n\t\tconst productMarketings = await this.model\n\t\t\t.find({ marketing: marketingId, deletedAt: null })\n\t\t\t.select('product')\n\t\t\t.lean();\n\n\t\tconst productIds: mongoose.Types.ObjectId[] = productMarketings\n\t\t\t.map((r: any) => r.product)\n\t\t\t.filter((p: any): p is mongoose.Types.ObjectId | string => !!p) // filter out null/undefined\n\t\t\t.map((p: any) => (p instanceof mongoose.Types.ObjectId ? p : new mongoose.Types.ObjectId(p))); // convert to ObjectId\n\n\t\tawait this.syncProductsMarketingInfoService.syncProductMarketingInfoByProductIds(productIds);\n\t}\n\n\t/**\n\t * Delete record\n\t * @param data Data for delete\n\t */\n\tpublic async deleteMultipleProducts(\n\t\tfilter: QueryMultipleProductMarketingDTO,\n\t\tsoftDelete: boolean\n\t): Promise<string> {\n\t\tconst result = await this.model.deleteRecords(\n\t\t\t{\n\t\t\t\tmarketing: filter.marketing,\n\t\t\t\tproduct: { $in: filter.products },\n\t\t\t},\n\t\t\tsoftDelete\n\t\t);\n\t\t// sync\n\t\treturn 'Record deleted successfully';\n\t}\n\n\t/**\n\t * Check if products are available for marketing\n\t * @param products Array of product IDs\n\t */\n\tpublic async checkProductMarketingAvailability(\n\t\tproducts: mongoose.Types.ObjectId[],\n\t\tisAppliedByCompany?: boolean\n\t): Promise<boolean> {\n\t\tconst now = new Date();\n\n\t\tconst marketingMatch: any = {\n\t\t\t'marketingDoc.status': MarketingStatus.ACTIVE,\n\t\t\t'marketingDoc.duration.start': { $lt: now },\n\t\t\t'marketingDoc.duration.end': { $gt: now },\n\t\t};\n\n\t\t// Only add this filter if explicitly provided\n\t\tif (typeof isAppliedByCompany === 'boolean') {\n\t\t\tmarketingMatch['marketingDoc.isAppliedByCompany'] = isAppliedByCompany;\n\t\t}\n\n\t\tconst result = await this.model.aggregate([\n\t\t\t{\n\t\t\t\t$match: { product: { $in: products }, deletedAt: null },\n\t\t\t},\n\t\t\t{\n\t\t\t\t$lookup: {\n\t\t\t\t\tfrom: 'marketings',\n\t\t\t\t\tlocalField: 'marketing',\n\t\t\t\t\tforeignField: '_id',\n\t\t\t\t\tas: 'marketingDoc',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{ $unwind: '$marketingDoc' },\n\t\t\t{\n\t\t\t\t$match: marketingMatch,\n\t\t\t},\n\t\t\t{ $limit: 1 }, // stop as soon as one match is found\n\t\t]);\n\n\t\tconst anyExist = result.length > 0;\n\n\t\treturn !anyExist;\n\t}\n\n\t/**\n\t * Pause any standard (non-LTO) marketing already covering these products, so a\n\t * Limited Time Offer marketing can take them over instead of being blocked by it.\n\t * @param products Array of product IDs\n\t */\n\tpublic async pauseConflictingMarketings(\n\t\tproducts: mongoose.Types.ObjectId[]\n\t): Promise<mongoose.Types.ObjectId[]> {\n\t\tconst now = new Date();\n\n\t\tconst result = await this.model.aggregate([\n\t\t\t{\n\t\t\t\t$match: { product: { $in: products }, deletedAt: null },\n\t\t\t},\n\t\t\t{\n\t\t\t\t$lookup: {\n\t\t\t\t\tfrom: 'marketings',\n\t\t\t\t\tlocalField: 'marketing',\n\t\t\t\t\tforeignField: '_id',\n\t\t\t\t\tas: 'marketingDoc',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{ $unwind: '$marketingDoc' },\n\t\t\t{\n\t\t\t\t$match: {\n\t\t\t\t\t'marketingDoc.status': MarketingStatus.ACTIVE,\n\t\t\t\t\t'marketingDoc.duration.start': { $lt: now },\n\t\t\t\t\t'marketingDoc.duration.end': { $gt: now },\n\t\t\t\t\t'marketingDoc.campaignType': { $in: [MarketingCampaignType.STANDARD, null] },\n\t\t\t\t},\n\t\t\t},\n\t\t\t{ $group: { _id: '$marketingDoc._id' } },\n\t\t]);\n\n\t\tconst marketingIds = result.map(r => r._id);\n\t\tif (!marketingIds.length) return [];\n\n\t\tawait MarketingModel.updateMany({ _id: { $in: marketingIds } }, { $set: { status: MarketingStatus.PAUSED } });\n\t\tawait synchronizeProductMarketingService.syncProductMarketingInfoByMarketingIds(marketingIds);\n\t\treturn marketingIds;\n\t}\n\n\tpublic async upsertProductMarketingsForPage(data: {\n\t\tmarketingId: mongoose.Types.ObjectId;\n\t\tproductIds: mongoose.Types.ObjectId[];\n\t\tisAppliedByCompany: boolean;\n\t\tisBuy1Get1: boolean;\n\t\tvalue?: number;\n\t\tvalueType?: ValueType;\n\t}): Promise<mongoose.Types.ObjectId[]> {\n\t\tconst { marketingId, productIds, isAppliedByCompany, isBuy1Get1, value, valueType } = data;\n\n\t\tif (!productIds.length) return [];\n\n\t\tconst ops = productIds.map(productId => ({\n\t\t\tupdateOne: {\n\t\t\t\tfilter: { marketing: marketingId, product: productId, deletedAt: null },\n\t\t\t\tupdate: {\n\t\t\t\t\t$set: { value, valueType, isAppliedByCompany, isBuy1Get1 },\n\t\t\t\t\t$setOnInsert: { marketing: marketingId, product: productId },\n\t\t\t\t},\n\t\t\t\tupsert: true,\n\t\t\t},\n\t\t}));\n\n\t\tawait this.model.bulkWrite(ops);\n\n\t\treturn productIds;\n\t}\n\n\tpublic async countDocuments(filter: QueryDTO): Promise<number> {\n\t\tconst count = await this.model.countDocuments({ ...filter, deletedAt: null });\n\t\treturn count ?? 0;\n\t}\n}\n\nexport const productMarketingService = Container.get(ProductMarketingService);\n"]}
|
|
1
|
+
{"version":3,"file":"product-marketing.service.js","sourceRoot":"/","sources":["modules/marketing/services/product-marketing.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAC5C,yCAAyC;AACzC,oDAA+E;AAC/E,uEAIoD;AAUpD,wEAA6G;AAE7G,4DAA+E;AAC/E,mGAGiD;AACjD,4EAA4E;AAGrE,IAAM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uB,CA4YnC;AAEY,QAAA,uBAAuB,GAAG,gBAAS,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { TRPCError } from '@trpc/server';\nimport { DocumentType, mongoose, ReturnModelType } from '@typegoose/typegoose';\nimport {\n\tProductMarketingModel,\n\tProductMarketing as Model,\n\tProductModel,\n} from '@lyxa.ai/core/dist/libraries/mongo/models/';\nimport {\n\tBatchCreateProductMarketingsInputDTO,\n\tCreateProductMarketingDTO as CreateDTO,\n\tQueryProductMarketingDTO as QueryDTO,\n\tQueryMultipleProductMarketingDTO,\n\tUpdateProductMarketingDTO as UpdateDTO,\n} from '@modules/marketing/validations';\nimport { SoftDeleteModel } from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport { FilterDTO, PaginatedResponse } from '@lyxa.ai/core/dist/utilities/validation';\nimport { createRawDocumentPaginatorObject, PaginatorOptions } from '@lyxa.ai/core/dist/utilities/pagination';\nimport { ModelType } from '@typegoose/typegoose/lib/types';\nimport { MarketingStatus, ValueType } from '@lyxa.ai/core/dist/utilities/enum';\nimport {\n\tSynchronizeProductMarketingService,\n\tsynchronizeProductMarketingService,\n} from './synchronize-product-marketing.service';\nimport { badRequestError } from '@lyxa.ai/core/dist/utilities/error-common';\n\n@Service()\nexport class ProductMarketingService {\n\tprivate model: typeof ProductMarketingModel & SoftDeleteModel<Model>;\n\tprivate productModel: typeof ProductModel;\n\n\tprivate syncProductsMarketingInfoService: SynchronizeProductMarketingService;\n\n\tconstructor() {\n\t\tthis.model = ProductMarketingModel as typeof ProductMarketingModel & SoftDeleteModel<Model>;\n\t\tthis.productModel = ProductModel;\n\n\t\tthis.syncProductsMarketingInfoService = synchronizeProductMarketingService;\n\t}\n\n\t/**\n\t * Create a new record\n\t * @param data Data for the new record\n\t */\n\tpublic async create(data: CreateDTO): Promise<DocumentType<Model>> {\n\t\tconst result = await this.model.create(data);\n\t\tif (!result) badRequestError('Product marketing creation failed');\n\t\treturn result;\n\t}\n\n\t/**\n\t * Bulk create new records\n\t * @param data Data for the new records\n\t */\n\tpublic async bulkCreate(data: CreateDTO[]): Promise<void> {\n\t\tawait this.model.insertMany(data, { ordered: false });\n\t}\n\n\tpublic async bulkCreateFromCursor<T>(cursor: AsyncIterable<T>, mapper: (item: T) => any) {\n\t\tconst BATCH_SIZE = 500;\n\t\tconst batch = [];\n\n\t\tfor await (const item of cursor) {\n\t\t\tbatch.push(mapper(item));\n\n\t\t\tif (batch.length === BATCH_SIZE) {\n\t\t\t\tawait this.bulkCreate(batch);\n\t\t\t\tbatch.length = 0;\n\t\t\t}\n\t\t}\n\n\t\tif (batch.length) {\n\t\t\tawait this.bulkCreate(batch);\n\t\t}\n\t}\n\n\tpublic async bulkCreateFromArray<T>(items: Iterable<T>, mapper: (item: T) => any) {\n\t\tconst BATCH_SIZE = 500;\n\t\tconst batch = [];\n\n\t\tfor (const item of items) {\n\t\t\tbatch.push(mapper(item));\n\n\t\t\tif (batch.length === BATCH_SIZE) {\n\t\t\t\tawait this.bulkCreate(batch);\n\t\t\t\tbatch.length = 0;\n\t\t\t}\n\t\t}\n\n\t\tif (batch.length) {\n\t\t\tawait this.bulkCreate(batch);\n\t\t}\n\t}\n\n\tprivate async buildProductsMap(data: {\n\t\tproducts: {\n\t\t\tproduct: mongoose.Types.ObjectId;\n\t\t\tvalue?: number;\n\t\t\tvalueType?: ValueType | null;\n\t\t}[];\n\t\tisBuy1Get1: boolean;\n\t\tcategories?: mongoose.Types.ObjectId[];\n\t\tcategoryValue?: number;\n\t\tcategoryValueType?: ValueType;\n\t}): Promise<Record<string, { value?: number; valueType?: ValueType; isBuy1Get1?: boolean }>> {\n\t\tconst map: Record<string, { value?: number; valueType?: ValueType; isBuy1Get1?: boolean }> = {};\n\n\t\t// explicit products\n\t\tfor (const p of data.products || []) {\n\t\t\tif (data.isBuy1Get1) {\n\t\t\t\tmap[p.product.toString()] = {\n\t\t\t\t\tisBuy1Get1: true,\n\t\t\t\t};\n\t\t\t} else if (p.value !== undefined && p.valueType) {\n\t\t\t\tmap[p.product.toString()] = {\n\t\t\t\t\tvalue: Number(p.value),\n\t\t\t\t\tvalueType: p.valueType,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\t// category products\n\t\tif (data.categories?.length) {\n\t\t\tconst categoryProducts = await this.productModel\n\t\t\t\t.find({ shopCategory: { $in: data.categories } })\n\t\t\t\t.select('_id')\n\t\t\t\t.lean();\n\n\t\t\tfor (const p of categoryProducts) {\n\t\t\t\tconst id = p._id.toString();\n\t\t\t\tif (!map[id]) {\n\t\t\t\t\tif (data.isBuy1Get1) {\n\t\t\t\t\t\tmap[id.toString()] = {\n\t\t\t\t\t\t\tisBuy1Get1: true,\n\t\t\t\t\t\t};\n\t\t\t\t\t} else if (data.categoryValue !== undefined && data.categoryValueType) {\n\t\t\t\t\t\tmap[id] = {\n\t\t\t\t\t\t\tvalue: Number(data.categoryValue),\n\t\t\t\t\t\t\tvalueType: data.categoryValueType,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn map;\n\t}\n\n\tpublic async createProductMarketings(data: BatchCreateProductMarketingsInputDTO): Promise<void> {\n\t\tconst {\n\t\t\tshop,\n\t\t\tmarketingId,\n\t\t\tproducts,\n\t\t\tcategories,\n\t\t\tisEntireMenu,\n\t\t\tisAppliedByCompany,\n\t\t\tcategoryValue,\n\t\t\tcategoryValueType,\n\t\t\tvalue,\n\t\t\tvalueType,\n\t\t\tisBuy1Get1,\n\t\t} = data;\n\n\t\tif (isEntireMenu) {\n\t\t\tawait this.bulkCreateFromCursor(\n\t\t\t\tthis.productModel.find({ shop }).select('_id').lean().cursor(),\n\t\t\t\tproduct => ({\n\t\t\t\t\tmarketing: marketingId,\n\t\t\t\t\tproduct: product._id,\n\t\t\t\t\tvalue,\n\t\t\t\t\tvalueType,\n\t\t\t\t\tisAppliedByCompany,\n\t\t\t\t\tisBuy1Get1,\n\t\t\t\t})\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst productsMap = await this.buildProductsMap({\n\t\t\tproducts: data.products,\n\t\t\tisBuy1Get1: data.isBuy1Get1,\n\t\t\tcategories: data.categories,\n\t\t\tcategoryValue: data.categoryValue,\n\t\t\tcategoryValueType: data.categoryValueType,\n\t\t});\n\n\t\tawait this.bulkCreateFromArray(Object.entries(productsMap), ([productId, info]) => ({\n\t\t\tmarketing: marketingId,\n\t\t\tproduct: new mongoose.Types.ObjectId(productId),\n\t\t\tvalue: info.value,\n\t\t\tvalueType: info.valueType,\n\t\t\tisAppliedByCompany,\n\t\t\tisBuy1Get1: info.isBuy1Get1,\n\t\t}));\n\t}\n\n\t/**\n\t * Get record by ID\n\t * @param id ID of the record\n\t */\n\tpublic async findById(id: string | mongoose.Types.ObjectId): Promise<DocumentType<Model>> {\n\t\tconst result = await this.model.findOne({\n\t\t\t_id: id,\n\t\t\tdeletedAt: null,\n\t\t});\n\t\tif (!result) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Record not found',\n\t\t\t});\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Get records\n\t * @param query Query to find records\n\t */\n\tpublic async find(data?: Partial<FilterDTO>): Promise<PaginatedResponse<DocumentType<ModelType<Model>>>> {\n\t\ttry {\n\t\t\tconst paginate = createRawDocumentPaginatorObject(this.model as ReturnModelType<typeof this.model>);\n\t\t\tconst options: PaginatorOptions<typeof Model> = {\n\t\t\t\tpage: data?.page,\n\t\t\t\tsize: data?.size,\n\t\t\t\tsort: data?.sort,\n\t\t\t\tquery: data?.query,\n\t\t\t\tselect: data?.select,\n\t\t\t\tpopulate: data?.populate,\n\t\t\t};\n\t\t\tconst paginatedResult = await paginate(options);\n\t\t\treturn paginatedResult;\n\t\t} catch (err) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: `err: ${err}`,\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Update single record based on query\n\t * @param query Query to find the record\n\t * @param data Data to update\n\t */\n\tpublic async updateOne(query: QueryDTO, data: UpdateDTO): Promise<string> {\n\t\tconst record = await this.model.findOneAndUpdate(query, data, {\n\t\t\tnew: true,\n\t\t\trunValidators: true,\n\t\t});\n\n\t\tif (!record) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: `Record not found`,\n\t\t\t});\n\t\t}\n\n\t\treturn 'Records updated successfully';\n\t}\n\n\t/**\n\t * Delete record\n\t * @param data Data for delete\n\t */\n\tpublic async deleteMany(filter: QueryDTO, softDelete: boolean): Promise<string> {\n\t\tconst productMarketings = await this.model.find(filter);\n\n\t\tawait this.model.deleteRecords(filter, softDelete);\n\n\t\tconst productIds: mongoose.Types.ObjectId[] = productMarketings\n\t\t\t.map((r: any) => r.product)\n\t\t\t.filter((p: any): p is mongoose.Types.ObjectId | string => !!p) // filter out null/undefined\n\t\t\t.map((p: any) => (p instanceof mongoose.Types.ObjectId ? p : new mongoose.Types.ObjectId(p))); // convert to ObjectId\n\n\t\tconst uniqueProductIds = [...new Set(productIds.map((id: any) => new mongoose.Types.ObjectId(id)))];\n\t\tawait this.syncProductsMarketingInfoService.syncProductMarketingInfoByProductIds(uniqueProductIds);\n\n\t\treturn 'Record deleted successfully';\n\t}\n\n\tpublic async deleteManyByMarketingIds(marketingIds: mongoose.Types.ObjectId[], softDelete: boolean): Promise<void> {\n\t\tif (marketingIds.length === 0) return;\n\n\t\tconst productMarketings = await this.model\n\t\t\t.find({ marketing: { $in: marketingIds } })\n\t\t\t.select('product')\n\t\t\t.lean();\n\n\t\tawait this.model.deleteRecords({ marketing: { $in: marketingIds } }, softDelete);\n\n\t\tconst uniqueProductIds = [\n\t\t\t...new Map(\n\t\t\t\tproductMarketings\n\t\t\t\t\t.map((r: any) => r.product)\n\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t.map((p: any) => {\n\t\t\t\t\t\tconst id = p instanceof mongoose.Types.ObjectId ? p : new mongoose.Types.ObjectId(p);\n\t\t\t\t\t\treturn [id.toString(), id] as [string, mongoose.Types.ObjectId];\n\t\t\t\t\t})\n\t\t\t).values(),\n\t\t];\n\n\t\tif (uniqueProductIds.length) {\n\t\t\tawait this.syncProductsMarketingInfoService.syncProductMarketingInfoByProductIds(uniqueProductIds);\n\t\t}\n\t}\n\n\tpublic async syncProductMarketingInfo(marketingId: mongoose.Types.ObjectId) {\n\t\tconst productMarketings = await this.model.find({ marketing: marketingId });\n\n\t\tconst productIds: mongoose.Types.ObjectId[] = productMarketings\n\t\t\t.map((r: any) => r.product)\n\t\t\t.filter((p: any): p is mongoose.Types.ObjectId | string => !!p) // filter out null/undefined\n\t\t\t.map((p: any) => (p instanceof mongoose.Types.ObjectId ? p : new mongoose.Types.ObjectId(p))); // convert to ObjectId\n\n\t\tawait this.syncProductsMarketingInfoService.syncProductMarketingInfoByProductIds(productIds);\n\t}\n\n\t/**\n\t * Delete record\n\t * @param data Data for delete\n\t */\n\tpublic async deleteMultipleProducts(\n\t\tfilter: QueryMultipleProductMarketingDTO,\n\t\tsoftDelete: boolean\n\t): Promise<string> {\n\t\tconst result = await this.model.deleteRecords(\n\t\t\t{\n\t\t\t\tmarketing: filter.marketing,\n\t\t\t\tproduct: { $in: filter.products },\n\t\t\t},\n\t\t\tsoftDelete\n\t\t);\n\t\t// sync\n\t\treturn 'Record deleted successfully';\n\t}\n\n\t/**\n\t * Check if products are available for marketing\n\t * @param products Array of product IDs\n\t */\n\tpublic async checkProductMarketingAvailability(\n\t\tproducts: mongoose.Types.ObjectId[],\n\t\tisAppliedByCompany?: boolean\n\t): Promise<boolean> {\n\t\tconst now = new Date();\n\n\t\tconst marketingMatch: any = {\n\t\t\t'marketingDoc.status': MarketingStatus.ACTIVE,\n\t\t\t'marketingDoc.duration.start': { $lt: now },\n\t\t\t'marketingDoc.duration.end': { $gt: now },\n\t\t};\n\n\t\t// Only add this filter if explicitly provided\n\t\tif (typeof isAppliedByCompany === 'boolean') {\n\t\t\tmarketingMatch['marketingDoc.isAppliedByCompany'] = isAppliedByCompany;\n\t\t}\n\n\t\tconst result = await this.model.aggregate([\n\t\t\t{\n\t\t\t\t$match: { product: { $in: products }, deletedAt: null },\n\t\t\t},\n\t\t\t{\n\t\t\t\t$lookup: {\n\t\t\t\t\tfrom: 'marketings',\n\t\t\t\t\tlocalField: 'marketing',\n\t\t\t\t\tforeignField: '_id',\n\t\t\t\t\tas: 'marketingDoc',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{ $unwind: '$marketingDoc' },\n\t\t\t{\n\t\t\t\t$match: marketingMatch,\n\t\t\t},\n\t\t\t{ $limit: 1 }, // stop as soon as one match is found\n\t\t]);\n\n\t\tconst anyExist = result.length > 0;\n\n\t\treturn !anyExist;\n\t}\n\n\tpublic async upsertProductMarketingsForPage(data: {\n\t\tshop: mongoose.Types.ObjectId;\n\t\tmarketingId: mongoose.Types.ObjectId;\n\t\tpage: number;\n\t\tpageSize: number;\n\t\tisAppliedByCompany: boolean;\n\t\tisBuy1Get1: boolean;\n\t\tvalue?: number;\n\t\tvalueType?: ValueType;\n\t}): Promise<mongoose.Types.ObjectId[]> {\n\t\tconst { shop, marketingId, page, pageSize, isAppliedByCompany, isBuy1Get1, value, valueType } = data;\n\n\t\tconst products = await this.productModel\n\t\t\t.find({ shop })\n\t\t\t.select('_id')\n\t\t\t.skip(page * pageSize)\n\t\t\t.limit(pageSize)\n\t\t\t.lean();\n\n\t\tif (!products.length) return [];\n\n\t\tconst ops = products.map(product => ({\n\t\t\tupdateOne: {\n\t\t\t\tfilter: { marketing: marketingId, product: product._id, deletedAt: null },\n\t\t\t\tupdate: {\n\t\t\t\t\t$set: { value, valueType, isAppliedByCompany, isBuy1Get1 },\n\t\t\t\t\t$setOnInsert: { marketing: marketingId, product: product._id },\n\t\t\t\t},\n\t\t\t\tupsert: true,\n\t\t\t},\n\t\t}));\n\n\t\tawait this.model.bulkWrite(ops);\n\n\t\treturn products.map(p => p._id as mongoose.Types.ObjectId);\n\t}\n\n\tpublic async countDocuments(filter: QueryDTO): Promise<number> {\n\t\tconst count = await this.model.countDocuments({ ...filter, deletedAt: null });\n\t\treturn count ?? 0;\n\t}\n}\n\nexport const productMarketingService = Container.get(ProductMarketingService);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synchronize-product-marketing.service.d.ts","sourceRoot":"/","sources":["modules/marketing/services/synchronize-product-marketing.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"synchronize-product-marketing.service.d.ts","sourceRoot":"/","sources":["modules/marketing/services/synchronize-product-marketing.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAWhD,OAAO,EAAE,6CAA6C,EAAE,MAAM,0FAA0F,CAAC;AAIzJ,qBACa,kCAAkC;IAC9C,OAAO,CAAC,YAAY,CAA+C;IACnE,OAAO,CAAC,qBAAqB,CAAmE;;IAQnF,kDAAkD;IAKxD,2CAA2C,CACjD,OAAO,EAAE,6CAA6C,GACpD,MAAM;IAKF,4BAA4B,QAAa,OAAO,CAAC,GAAG,CAAC,CAqC1D;YAEY,oBAAoB;YA2CpB,kCAAkC;IAsCnC,mCAAmC,CAAC,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ;IAqCtE,oCAAoC,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE;IA8D1E,sCAAsC,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE;CAY3F;AAED,eAAO,MAAM,kCAAkC,oCAAoD,CAAC"}
|
|
@@ -47,8 +47,6 @@ const typedi_1 = __importStar(require("typedi"));
|
|
|
47
47
|
const core_1 = require("@lyxa.ai/core");
|
|
48
48
|
const models_1 = require("@lyxa.ai/core/dist/libraries/mongo/models");
|
|
49
49
|
const product_pipeline_stages_1 = require("@lyxa.ai/core/dist/utilities/pipelines/product-pipeline-stages");
|
|
50
|
-
const common_pipeline_functions_1 = require("@lyxa.ai/core/dist/utilities/pipelines/common-pipeline-functions");
|
|
51
|
-
const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
|
|
52
50
|
const events_common_methods_1 = require("@lyxa.ai/core/dist/utilities/events-common-methods");
|
|
53
51
|
const TAG = 'marketing.seed.entire-menu';
|
|
54
52
|
let SynchronizeProductMarketingService = class SynchronizeProductMarketingService {
|
|
@@ -200,116 +198,50 @@ let SynchronizeProductMarketingService = class SynchronizeProductMarketingServic
|
|
|
200
198
|
const exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;
|
|
201
199
|
const secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';
|
|
202
200
|
const BATCH_SIZE = 500;
|
|
203
|
-
const now = new Date();
|
|
204
201
|
const results = [];
|
|
202
|
+
const totalBatches = Math.ceil(productIds.length / BATCH_SIZE);
|
|
205
203
|
for (let i = 0; i < productIds.length; i += BATCH_SIZE) {
|
|
206
204
|
const batchIds = productIds.slice(i, i + BATCH_SIZE);
|
|
207
|
-
const batchResults = await this.
|
|
208
|
-
{ $match: { product: { $in: batchIds }, deletedAt: null } },
|
|
205
|
+
const batchResults = await this.productModel.aggregate([
|
|
209
206
|
{
|
|
210
|
-
$
|
|
211
|
-
|
|
212
|
-
let: { mid: '$marketing' },
|
|
213
|
-
pipeline: [
|
|
214
|
-
{
|
|
215
|
-
$match: {
|
|
216
|
-
$expr: { $eq: ['$_id', '$$mid'] },
|
|
217
|
-
status: 'active',
|
|
218
|
-
'duration.start': { $lte: now },
|
|
219
|
-
'duration.end': { $gte: now },
|
|
220
|
-
},
|
|
221
|
-
},
|
|
222
|
-
{ $project: { marketingType: 1, duration: 1, isAppliedByCompany: 1 } },
|
|
223
|
-
],
|
|
224
|
-
as: 'marketing',
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
{ $unwind: '$marketing' },
|
|
228
|
-
{
|
|
229
|
-
$addFields: {
|
|
230
|
-
secondaryCurrencyValue: {
|
|
231
|
-
$cond: [
|
|
232
|
-
{ $eq: ['$valueType', 'fixed'] },
|
|
233
|
-
(0, common_pipeline_functions_1.getRoundSecondaryCurrencyStage)({ $multiply: ['$value', exchangeRate] }),
|
|
234
|
-
'$$REMOVE',
|
|
235
|
-
],
|
|
236
|
-
},
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
$addFields: {
|
|
241
|
-
label: {
|
|
242
|
-
$switch: {
|
|
243
|
-
branches: [
|
|
244
|
-
{ case: { $eq: ['$marketing.marketingType', enum_1.MarketingType.BUY1GET1] }, then: 'Buy 1 Get 1' },
|
|
245
|
-
{ case: { $eq: ['$marketing.marketingType', enum_1.MarketingType.PUNCH_MARKETING] }, then: 'Punch' },
|
|
246
|
-
{
|
|
247
|
-
case: { $eq: ['$marketing.marketingType', enum_1.MarketingType.DISCOUNT] },
|
|
248
|
-
then: {
|
|
249
|
-
$switch: {
|
|
250
|
-
branches: [
|
|
251
|
-
{
|
|
252
|
-
case: { $eq: ['$valueType', enum_1.ValueType.FIXED] },
|
|
253
|
-
then: { $concat: [secondaryCurrencyName, ' ', { $toString: '$secondaryCurrencyValue' }] },
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
case: { $eq: ['$valueType', enum_1.ValueType.PERCENTAGE] },
|
|
257
|
-
then: { $concat: [{ $toString: '$value' }, '%'] },
|
|
258
|
-
},
|
|
259
|
-
],
|
|
260
|
-
default: 'Discount',
|
|
261
|
-
},
|
|
262
|
-
},
|
|
263
|
-
},
|
|
264
|
-
],
|
|
265
|
-
default: '$marketing.marketingType',
|
|
266
|
-
},
|
|
267
|
-
},
|
|
207
|
+
$match: {
|
|
208
|
+
_id: { $in: batchIds },
|
|
268
209
|
},
|
|
269
210
|
},
|
|
211
|
+
...(0, product_pipeline_stages_1.addProductMarketingInfo)(exchangeRate, secondaryCurrencyName),
|
|
270
212
|
{
|
|
271
213
|
$group: {
|
|
272
|
-
_id: '$
|
|
214
|
+
_id: '$_id',
|
|
273
215
|
productMarketingInfo: {
|
|
274
|
-
$push:
|
|
275
|
-
marketing: {
|
|
276
|
-
_id: '$marketing._id',
|
|
277
|
-
marketingType: '$marketing.marketingType',
|
|
278
|
-
duration: '$marketing.duration',
|
|
279
|
-
},
|
|
280
|
-
isBuy1Get1: '$isBuy1Get1',
|
|
281
|
-
valueType: '$valueType',
|
|
282
|
-
value: '$value',
|
|
283
|
-
secondaryCurrencyValue: '$secondaryCurrencyValue',
|
|
284
|
-
label: '$label',
|
|
285
|
-
isAppliedByCompany: '$marketing.isAppliedByCompany',
|
|
286
|
-
},
|
|
216
|
+
$push: '$productMarketing',
|
|
287
217
|
},
|
|
288
218
|
},
|
|
289
219
|
},
|
|
290
220
|
]);
|
|
291
221
|
results.push(...batchResults);
|
|
292
222
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
223
|
+
if (!results.length)
|
|
224
|
+
return 'No matching products found';
|
|
225
|
+
const bulkOps = results.map(product => {
|
|
226
|
+
const productMarketingInfo = (product.productMarketingInfo || []).map((pm) => ({
|
|
227
|
+
marketing: pm.marketingInfo,
|
|
228
|
+
isBuy1Get1: pm.isBuy1Get1,
|
|
229
|
+
valueType: pm.valueType,
|
|
230
|
+
value: pm.value,
|
|
231
|
+
secondaryCurrencyValue: pm.secondaryCurrencyValue,
|
|
232
|
+
label: pm.label,
|
|
233
|
+
isAppliedByCompany: pm.isAppliedByCompany ?? false,
|
|
234
|
+
}));
|
|
235
|
+
return {
|
|
236
|
+
updateOne: {
|
|
237
|
+
filter: { _id: product._id },
|
|
238
|
+
update: {
|
|
239
|
+
$set: { productMarketingInfo },
|
|
308
240
|
},
|
|
309
241
|
},
|
|
310
|
-
}
|
|
311
|
-
})
|
|
312
|
-
await this.productModel.bulkWrite(bulkOps
|
|
242
|
+
};
|
|
243
|
+
});
|
|
244
|
+
await this.productModel.bulkWrite(bulkOps);
|
|
313
245
|
return `Synchronized product marketing info for ${bulkOps.length} products`;
|
|
314
246
|
}
|
|
315
247
|
async syncProductMarketingInfoByMarketingIds(marketingIds) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synchronize-product-marketing.service.js","sourceRoot":"/","sources":["modules/marketing/services/synchronize-product-marketing.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAC5C,wCAA6C;AAG7C,sEAMmD;AACnD,4GAAyG;AACzG,gHAAkH;AAClH,4DAA6E;AAC7E,8FAAwH;AAGxH,MAAM,GAAG,GAAG,4BAA4B,CAAC;AAGlC,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IACtC,YAAY,CAA+C;IAC3D,qBAAqB,CAAmE;IAEhG;QACC,IAAI,CAAC,YAAY,GAAG,qBAA4D,CAAC;QACjF,IAAI,CAAC,qBAAqB,GAAG,8BACK,CAAC;IACpC,CAAC;IAEM,KAAK,CAAC,kDAAkD;QAC9D,MAAM,IAAA,0EAAkD,EAAC,EAAE,CAAC,CAAC;QAC7D,OAAO,yDAAyD,CAAC;IAClE,CAAC;IAEM,2CAA2C,CACjD,OAAsD;QAEtD,IAAI,CAAC,4BAA4B,EAAE,CAAC;QACpC,OAAO,yDAAyD,CAAC;IAClE,CAAC;IAEM,4BAA4B,GAAG,KAAK,IAAkB,EAAE;QAC9D,MAAM,MAAM,GAAG,IAAA,mBAAY,GAAE,CAAC,YAAY,EAAE,CAAC;QAC7C,MAAM,UAAU,GAAG,GAAG,CAAC;QAEv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gB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5D,OAAO,MAAM,IAAI,CAAC,oCAAoC,CAAC,UAAU,CAAC,CAAC;IACpE,CAAC;CACD,CAAA;AAnUY,gFAAkC;6CAAlC,kCAAkC;IAD9C,IAAA,gBAAO,GAAE;;GACG,kCAAkC,CAmU9C;AAEY,QAAA,kCAAkC,GAAG,gBAAS,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { getLibraries } from '@lyxa.ai/core';\nimport { mongoose } from '@typegoose/typegoose';\nimport { SoftDeleteModel } from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport {\n\tProductModel,\n\tProduct as Model,\n\tSetting,\n\tProductMarketingModel,\n\tProductMarketing,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport { addProductMarketingInfo } from '@lyxa.ai/core/dist/utilities/pipelines/product-pipeline-stages';\nimport { getRoundSecondaryCurrencyStage } from '@lyxa.ai/core/dist/utilities/pipelines/common-pipeline-functions';\nimport { MarketingType, ValueType } from '@lyxa.ai/core/dist/utilities/enum';\nimport { publishAllProductsProductMarketingInfoProcessEvent } from '@lyxa.ai/core/dist/utilities/events-common-methods';\nimport { SynchronizeAllProductsProductMarketingInfoDTO } from '@lyxa.ai/core/dist/libraries/event/events/sync-all-products-product-marketing-info-event';\n\nconst TAG = 'marketing.seed.entire-menu';\n\n@Service()\nexport class SynchronizeProductMarketingService {\n\tprivate productModel: typeof ProductModel & SoftDeleteModel<Model>;\n\tprivate productMarketingModel: typeof ProductMarketingModel & SoftDeleteModel<ProductMarketing>;\n\n\tconstructor() {\n\t\tthis.productModel = ProductModel as typeof ProductModel & SoftDeleteModel<Model>;\n\t\tthis.productMarketingModel = ProductMarketingModel as typeof ProductMarketingModel &\n\t\t\tSoftDeleteModel<ProductMarketing>;\n\t}\n\n\tpublic async publishAllProductsProductMarketingInfoProcessEvent() {\n\t\tawait publishAllProductsProductMarketingInfoProcessEvent({});\n\t\treturn 'Processing all products product marketing information! ';\n\t}\n\n\tpublic processAllProductsProductMarketingInfoEvent(\n\t\tpayload: SynchronizeAllProductsProductMarketingInfoDTO\n\t): string {\n\t\tthis.syncAllProductsMarketingInfo();\n\t\treturn 'Processing all products product marketing information! ';\n\t}\n\n\tpublic syncAllProductsMarketingInfo = async (): Promise<any> => {\n\t\tconst logger = getLibraries().getLoggerKit();\n\t\tconst CHUNK_SIZE = 500;\n\n\t\tconst cursor = this.productModel.find().select('_id shop price priceBreakdowns').lean().cursor();\n\n\t\tconst adminSettings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;\n\t\tconst secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';\n\n\t\tlet batch: any[] = [];\n\t\tlet batchIndex = 0;\n\t\tlet totalProcessed = 0;\n\n\t\tfor await (const product of cursor) {\n\t\t\tbatch.push(product);\n\n\t\t\tif (batch.length === CHUNK_SIZE) {\n\t\t\t\tbatchIndex++;\n\t\t\t\ttotalProcessed += batch.length;\n\t\t\t\tawait this.processProductsBatch(batch, exchangeRate, secondaryCurrencyName, batchIndex);\n\t\t\t\tbatch = [];\n\t\t\t}\n\t\t}\n\n\t\tif (batch.length) {\n\t\t\tbatchIndex++;\n\t\t\ttotalProcessed += batch.length;\n\t\t\tawait this.processProductsBatch(batch, exchangeRate, secondaryCurrencyName, batchIndex);\n\t\t}\n\n\t\tlogger.debug('full product marketing sync complete', {\n\t\t\ttag: TAG,\n\t\t\tdata: { totalProducts: totalProcessed },\n\t\t});\n\n\t\treturn 'Bulk product marketing info sync completed';\n\t};\n\n\tprivate async processProductsBatch(\n\t\tproductsBatch: any[],\n\t\texchangeRate: number,\n\t\tsecondaryCurrencyName: string,\n\t\tbatchIndex: number\n\t): Promise<void> {\n\t\tconst productIds = productsBatch.map(p => p._id);\n\n\t\tconst results = await this.productModel.aggregate([\n\t\t\t{ $match: { _id: { $in: productIds } } },\n\t\t\t...addProductMarketingInfo(exchangeRate, secondaryCurrencyName),\n\t\t\t{\n\t\t\t\t$group: {\n\t\t\t\t\t_id: '$_id',\n\t\t\t\t\tproductMarketingInfo: { $push: '$productMarketing' },\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\n\t\tconst bulkOps = results.map(r => ({\n\t\t\tupdateOne: {\n\t\t\t\tfilter: { _id: r._id },\n\t\t\t\tupdate: {\n\t\t\t\t\t$set: {\n\t\t\t\t\t\tproductMarketingInfo: (r.productMarketingInfo ?? []).filter(Boolean).map((pm: any) => ({\n\t\t\t\t\t\t\tmarketing: pm.marketingInfo,\n\t\t\t\t\t\t\tisBuy1Get1: pm.isBuy1Get1,\n\t\t\t\t\t\t\tvalueType: pm.valueType,\n\t\t\t\t\t\t\tvalue: pm.value,\n\t\t\t\t\t\t\tsecondaryCurrencyValue: pm.secondaryCurrencyValue,\n\t\t\t\t\t\t\tlabel: pm.label,\n\t\t\t\t\t\t\tisAppliedByCompany: pm.isAppliedByCompany ?? false,\n\t\t\t\t\t\t})),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t}));\n\n\t\tif (bulkOps.length) {\n\t\t\tawait this.productModel.bulkWrite(bulkOps, { ordered: false });\n\t\t}\n\t}\n\n\tprivate async getProductMarketingInfoByProductId(productId: mongoose.Types.ObjectId): Promise<any[]> {\n\t\tconst adminSettings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\n\t\tconst exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;\n\t\tconst secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';\n\n\t\tconst result = await this.productModel.aggregate([\n\t\t\t{\n\t\t\t\t$match: { _id: productId },\n\t\t\t},\n\t\t\t...addProductMarketingInfo(exchangeRate, secondaryCurrencyName),\n\t\t\t{\n\t\t\t\t$group: {\n\t\t\t\t\t_id: '$_id',\n\t\t\t\t\tproductMarketingInfo: {\n\t\t\t\t\t\t$push: '$productMarketing',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\n\t\tconst productMarketingInfo = result?.[0]?.productMarketing\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tmarketing: result?.[0].productMarketing.marketingInfo,\n\t\t\t\t\t\tisBuy1Get1: result?.[0].productMarketing.isBuy1Get1,\n\t\t\t\t\t\tvalueType: result?.[0].productMarketing.valueType,\n\t\t\t\t\t\tvalue: result?.[0].productMarketing.value,\n\t\t\t\t\t\tsecondaryCurrencyValue: result?.[0].productMarketing.secondaryCurrencyValue,\n\t\t\t\t\t\tlabel: result?.[0].productMarketing.label,\n\t\t\t\t\t\tisAppliedByCompany: result?.[0].productMarketing.isAppliedByCompany ?? false,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t: [];\n\n\t\treturn productMarketingInfo;\n\t}\n\n\tpublic async syncProductMarketingInfoByProductId(productId: mongoose.Types.ObjectId) {\n\t\tconst adminSettings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;\n\n\t\tconst secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';\n\t\tconst result = await this.productModel.aggregate([\n\t\t\t{\n\t\t\t\t$match: {\n\t\t\t\t\t_id: productId,\n\t\t\t\t},\n\t\t\t},\n\t\t\t...addProductMarketingInfo(exchangeRate, secondaryCurrencyName),\n\t\t]);\n\n\t\tconst productMarketingInfo = (result || [])\n\t\t\t.filter(item => item?.productMarketing)\n\t\t\t.map(item => ({\n\t\t\t\tmarketing: item.productMarketing.marketingInfo,\n\t\t\t\tisBuy1Get1: item.productMarketing.isBuy1Get1,\n\t\t\t\tvalueType: item.productMarketing.valueType,\n\t\t\t\tvalue: item.productMarketing.value,\n\t\t\t\tsecondaryCurrencyValue: item.productMarketing.secondaryCurrencyValue,\n\t\t\t\tlabel: item.productMarketing.label,\n\t\t\t\tisAppliedByCompany: item.productMarketing.isAppliedByCompany ?? false,\n\t\t\t}));\n\n\t\tawait this.productModel.updateOne(\n\t\t\t{ _id: productId },\n\t\t\t{\n\t\t\t\t$set: {\n\t\t\t\t\tproductMarketingInfo,\n\t\t\t\t},\n\t\t\t}\n\t\t);\n\t\treturn 'Synchronized product marketing info';\n\t}\n\n\tpublic async syncProductMarketingInfoByProductIds(productIds: mongoose.Types.ObjectId[]) {\n\t\tif (!productIds.length) return 'No products to sync';\n\n\t\tconst adminSettings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;\n\t\tconst secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';\n\n\t\tconst BATCH_SIZE = 500;\n\t\tconst now = new Date();\n\t\tconst results: any[] = [];\n\n\t\tfor (let i = 0; i < productIds.length; i += BATCH_SIZE) {\n\t\t\tconst batchIds = productIds.slice(i, i + BATCH_SIZE);\n\n\t\t\t// Inverted join: scan productMarketings once per batch (grouped by product) instead of\n\t\t\t// one correlated $lookup per product (the old product-first addProductMarketingInfo path).\n\t\t\tconst batchResults = await this.productMarketingModel.aggregate([\n\t\t\t\t{ $match: { product: { $in: batchIds }, deletedAt: null } },\n\t\t\t\t{\n\t\t\t\t\t$lookup: {\n\t\t\t\t\t\tfrom: 'marketings',\n\t\t\t\t\t\tlet: { mid: '$marketing' },\n\t\t\t\t\t\tpipeline: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t\t$expr: { $eq: ['$_id', '$$mid'] }, // joins on indexed _id\n\t\t\t\t\t\t\t\t\tstatus: 'active',\n\t\t\t\t\t\t\t\t\t'duration.start': { $lte: now },\n\t\t\t\t\t\t\t\t\t'duration.end': { $gte: now },\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ $project: { marketingType: 1, duration: 1, isAppliedByCompany: 1 } },\n\t\t\t\t\t\t],\n\t\t\t\t\t\tas: 'marketing',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{ $unwind: '$marketing' }, // drops productMarketings whose marketing isn't active\n\t\t\t\t{\n\t\t\t\t\t$addFields: {\n\t\t\t\t\t\tsecondaryCurrencyValue: {\n\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t{ $eq: ['$valueType', 'fixed'] },\n\t\t\t\t\t\t\t\tgetRoundSecondaryCurrencyStage({ $multiply: ['$value', exchangeRate] }),\n\t\t\t\t\t\t\t\t'$$REMOVE',\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t$addFields: {\n\t\t\t\t\t\tlabel: {\n\t\t\t\t\t\t\t$switch: {\n\t\t\t\t\t\t\t\tbranches: [\n\t\t\t\t\t\t\t\t\t{ case: { $eq: ['$marketing.marketingType', MarketingType.BUY1GET1] }, then: 'Buy 1 Get 1' },\n\t\t\t\t\t\t\t\t\t{ case: { $eq: ['$marketing.marketingType', MarketingType.PUNCH_MARKETING] }, then: 'Punch' },\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$marketing.marketingType', MarketingType.DISCOUNT] },\n\t\t\t\t\t\t\t\t\t\tthen: {\n\t\t\t\t\t\t\t\t\t\t\t$switch: {\n\t\t\t\t\t\t\t\t\t\t\t\tbranches: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$valueType', ValueType.FIXED] },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen: { $concat: [secondaryCurrencyName, ' ', { $toString: '$secondaryCurrencyValue' }] },\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase: { $eq: ['$valueType', ValueType.PERCENTAGE] },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen: { $concat: [{ $toString: '$value' }, '%'] },\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\tdefault: 'Discount',\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tdefault: '$marketing.marketingType',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t$group: {\n\t\t\t\t\t\t_id: '$product',\n\t\t\t\t\t\tproductMarketingInfo: {\n\t\t\t\t\t\t\t$push: {\n\t\t\t\t\t\t\t\tmarketing: {\n\t\t\t\t\t\t\t\t\t_id: '$marketing._id',\n\t\t\t\t\t\t\t\t\tmarketingType: '$marketing.marketingType',\n\t\t\t\t\t\t\t\t\tduration: '$marketing.duration',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tisBuy1Get1: '$isBuy1Get1',\n\t\t\t\t\t\t\t\tvalueType: '$valueType',\n\t\t\t\t\t\t\t\tvalue: '$value',\n\t\t\t\t\t\t\t\tsecondaryCurrencyValue: '$secondaryCurrencyValue',\n\t\t\t\t\t\t\t\tlabel: '$label',\n\t\t\t\t\t\t\t\tisAppliedByCompany: '$marketing.isAppliedByCompany',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t]);\n\n\t\t\tresults.push(...batchResults);\n\t\t}\n\n\t\t// Products with no active marketing left aren't returned by the aggregate above, so reset\n\t\t// them to [] explicitly — keeps the recompute self-healing for the delete/update callers.\n\t\tconst byProduct = new Map<string, any[]>(results.map(r => [r._id.toString(), r.productMarketingInfo ?? []]));\n\n\t\tconst bulkOps = productIds.map(productId => ({\n\t\t\tupdateOne: {\n\t\t\t\tfilter: { _id: productId },\n\t\t\t\tupdate: {\n\t\t\t\t\t$set: {\n\t\t\t\t\t\tproductMarketingInfo: (byProduct.get(productId.toString()) ?? []).map((pm: any) => ({\n\t\t\t\t\t\t\tmarketing: pm.marketing,\n\t\t\t\t\t\t\tisBuy1Get1: pm.isBuy1Get1,\n\t\t\t\t\t\t\tvalueType: pm.valueType,\n\t\t\t\t\t\t\tvalue: pm.value,\n\t\t\t\t\t\t\tsecondaryCurrencyValue: pm.secondaryCurrencyValue,\n\t\t\t\t\t\t\tlabel: pm.label,\n\t\t\t\t\t\t\tisAppliedByCompany: pm.isAppliedByCompany ?? false,\n\t\t\t\t\t\t})),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t}));\n\n\t\tawait this.productModel.bulkWrite(bulkOps, { ordered: false });\n\n\t\treturn `Synchronized product marketing info for ${bulkOps.length} products`;\n\t}\n\n\tpublic async syncProductMarketingInfoByMarketingIds(marketingIds: mongoose.Types.ObjectId[]) {\n\t\tif (!marketingIds.length) return 'No marketings to sync';\n\n\t\tconst productsToUpdate = await this.productMarketingModel\n\t\t\t.find({ marketing: { $in: marketingIds } })\n\t\t\t.select('product')\n\t\t\t.lean();\n\t\tif (!productsToUpdate.length) return 'No matching products found';\n\n\t\tconst productIds = productsToUpdate.map(p => p.product._id);\n\t\treturn await this.syncProductMarketingInfoByProductIds(productIds);\n\t}\n}\n\nexport const synchronizeProductMarketingService = Container.get(SynchronizeProductMarketingService);\n"]}
|
|
1
|
+
{"version":3,"file":"synchronize-product-marketing.service.js","sourceRoot":"/","sources":["modules/marketing/services/synchronize-product-marketing.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAC5C,wCAA6C;AAG7C,sEAMm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,gBAAS,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { getLibraries } from '@lyxa.ai/core';\nimport { mongoose } from '@typegoose/typegoose';\nimport { SoftDeleteModel } from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport {\n\tProductModel,\n\tProduct as Model,\n\tSetting,\n\tProductMarketingModel,\n\tProductMarketing,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport { addProductMarketingInfo } from '@lyxa.ai/core/dist/utilities/pipelines/product-pipeline-stages';\nimport { publishAllProductsProductMarketingInfoProcessEvent } from '@lyxa.ai/core/dist/utilities/events-common-methods';\nimport { SynchronizeAllProductsProductMarketingInfoDTO } from '@lyxa.ai/core/dist/libraries/event/events/sync-all-products-product-marketing-info-event';\n\nconst TAG = 'marketing.seed.entire-menu';\n\n@Service()\nexport class SynchronizeProductMarketingService {\n\tprivate productModel: typeof ProductModel & SoftDeleteModel<Model>;\n\tprivate productMarketingModel: typeof ProductMarketingModel & SoftDeleteModel<ProductMarketing>;\n\n\tconstructor() {\n\t\tthis.productModel = ProductModel as typeof ProductModel & SoftDeleteModel<Model>;\n\t\tthis.productMarketingModel = ProductMarketingModel as typeof ProductMarketingModel &\n\t\t\tSoftDeleteModel<ProductMarketing>;\n\t}\n\n\tpublic async publishAllProductsProductMarketingInfoProcessEvent() {\n\t\tawait publishAllProductsProductMarketingInfoProcessEvent({});\n\t\treturn 'Processing all products product marketing information! ';\n\t}\n\n\tpublic processAllProductsProductMarketingInfoEvent(\n\t\tpayload: SynchronizeAllProductsProductMarketingInfoDTO\n\t): string {\n\t\tthis.syncAllProductsMarketingInfo();\n\t\treturn 'Processing all products product marketing information! ';\n\t}\n\n\tpublic syncAllProductsMarketingInfo = async (): Promise<any> => {\n\t\tconst logger = getLibraries().getLoggerKit();\n\t\tconst CHUNK_SIZE = 500;\n\n\t\tconst cursor = this.productModel.find().select('_id shop price priceBreakdowns').lean().cursor();\n\n\t\tconst adminSettings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;\n\t\tconst secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';\n\n\t\tlet batch: any[] = [];\n\t\tlet batchIndex = 0;\n\t\tlet totalProcessed = 0;\n\n\t\tfor await (const product of cursor) {\n\t\t\tbatch.push(product);\n\n\t\t\tif (batch.length === CHUNK_SIZE) {\n\t\t\t\tbatchIndex++;\n\t\t\t\ttotalProcessed += batch.length;\n\t\t\t\tawait this.processProductsBatch(batch, exchangeRate, secondaryCurrencyName, batchIndex);\n\t\t\t\tbatch = [];\n\t\t\t}\n\t\t}\n\n\t\tif (batch.length) {\n\t\t\tbatchIndex++;\n\t\t\ttotalProcessed += batch.length;\n\t\t\tawait this.processProductsBatch(batch, exchangeRate, secondaryCurrencyName, batchIndex);\n\t\t}\n\n\t\tlogger.debug('full product marketing sync complete', {\n\t\t\ttag: TAG,\n\t\t\tdata: { totalProducts: totalProcessed },\n\t\t});\n\n\t\treturn 'Bulk product marketing info sync completed';\n\t};\n\n\tprivate async processProductsBatch(\n\t\tproductsBatch: any[],\n\t\texchangeRate: number,\n\t\tsecondaryCurrencyName: string,\n\t\tbatchIndex: number\n\t): Promise<void> {\n\t\tconst productIds = productsBatch.map(p => p._id);\n\n\t\tconst results = await this.productModel.aggregate([\n\t\t\t{ $match: { _id: { $in: productIds } } },\n\t\t\t...addProductMarketingInfo(exchangeRate, secondaryCurrencyName),\n\t\t\t{\n\t\t\t\t$group: {\n\t\t\t\t\t_id: '$_id',\n\t\t\t\t\tproductMarketingInfo: { $push: '$productMarketing' },\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\n\t\tconst bulkOps = results.map(r => ({\n\t\t\tupdateOne: {\n\t\t\t\tfilter: { _id: r._id },\n\t\t\t\tupdate: {\n\t\t\t\t\t$set: {\n\t\t\t\t\t\tproductMarketingInfo: (r.productMarketingInfo ?? []).filter(Boolean).map((pm: any) => ({\n\t\t\t\t\t\t\tmarketing: pm.marketingInfo,\n\t\t\t\t\t\t\tisBuy1Get1: pm.isBuy1Get1,\n\t\t\t\t\t\t\tvalueType: pm.valueType,\n\t\t\t\t\t\t\tvalue: pm.value,\n\t\t\t\t\t\t\tsecondaryCurrencyValue: pm.secondaryCurrencyValue,\n\t\t\t\t\t\t\tlabel: pm.label,\n\t\t\t\t\t\t\tisAppliedByCompany: pm.isAppliedByCompany ?? false,\n\t\t\t\t\t\t})),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t}));\n\n\t\tif (bulkOps.length) {\n\t\t\tawait this.productModel.bulkWrite(bulkOps, { ordered: false });\n\t\t}\n\t}\n\n\tprivate async getProductMarketingInfoByProductId(productId: mongoose.Types.ObjectId): Promise<any[]> {\n\t\tconst adminSettings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\n\t\tconst exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;\n\t\tconst secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';\n\n\t\tconst result = await this.productModel.aggregate([\n\t\t\t{\n\t\t\t\t$match: { _id: productId },\n\t\t\t},\n\t\t\t...addProductMarketingInfo(exchangeRate, secondaryCurrencyName),\n\t\t\t{\n\t\t\t\t$group: {\n\t\t\t\t\t_id: '$_id',\n\t\t\t\t\tproductMarketingInfo: {\n\t\t\t\t\t\t$push: '$productMarketing',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\n\t\tconst productMarketingInfo = result?.[0]?.productMarketing\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tmarketing: result?.[0].productMarketing.marketingInfo,\n\t\t\t\t\t\tisBuy1Get1: result?.[0].productMarketing.isBuy1Get1,\n\t\t\t\t\t\tvalueType: result?.[0].productMarketing.valueType,\n\t\t\t\t\t\tvalue: result?.[0].productMarketing.value,\n\t\t\t\t\t\tsecondaryCurrencyValue: result?.[0].productMarketing.secondaryCurrencyValue,\n\t\t\t\t\t\tlabel: result?.[0].productMarketing.label,\n\t\t\t\t\t\tisAppliedByCompany: result?.[0].productMarketing.isAppliedByCompany ?? false,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t: [];\n\n\t\treturn productMarketingInfo;\n\t}\n\n\tpublic async syncProductMarketingInfoByProductId(productId: mongoose.Types.ObjectId) {\n\t\tconst adminSettings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;\n\n\t\tconst secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';\n\t\tconst result = await this.productModel.aggregate([\n\t\t\t{\n\t\t\t\t$match: {\n\t\t\t\t\t_id: productId,\n\t\t\t\t},\n\t\t\t},\n\t\t\t...addProductMarketingInfo(exchangeRate, secondaryCurrencyName),\n\t\t]);\n\n\t\tconst productMarketingInfo = (result || [])\n\t\t\t.filter(item => item?.productMarketing)\n\t\t\t.map(item => ({\n\t\t\t\tmarketing: item.productMarketing.marketingInfo,\n\t\t\t\tisBuy1Get1: item.productMarketing.isBuy1Get1,\n\t\t\t\tvalueType: item.productMarketing.valueType,\n\t\t\t\tvalue: item.productMarketing.value,\n\t\t\t\tsecondaryCurrencyValue: item.productMarketing.secondaryCurrencyValue,\n\t\t\t\tlabel: item.productMarketing.label,\n\t\t\t\tisAppliedByCompany: item.productMarketing.isAppliedByCompany ?? false,\n\t\t\t}));\n\n\t\tawait this.productModel.updateOne(\n\t\t\t{ _id: productId },\n\t\t\t{\n\t\t\t\t$set: {\n\t\t\t\t\tproductMarketingInfo,\n\t\t\t\t},\n\t\t\t}\n\t\t);\n\t\treturn 'Synchronized product marketing info';\n\t}\n\n\tpublic async syncProductMarketingInfoByProductIds(productIds: mongoose.Types.ObjectId[]) {\n\t\tif (!productIds.length) return 'No products to sync';\n\n\t\tconst adminSettings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;\n\t\tconst secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';\n\n\t\tconst BATCH_SIZE = 500;\n\t\tconst results: any[] = [];\n\t\tconst totalBatches = Math.ceil(productIds.length / BATCH_SIZE);\n\n\t\tfor (let i = 0; i < productIds.length; i += BATCH_SIZE) {\n\t\t\tconst batchIds = productIds.slice(i, i + BATCH_SIZE);\n\n\t\t\tconst batchResults = await this.productModel.aggregate([\n\t\t\t\t{\n\t\t\t\t\t$match: {\n\t\t\t\t\t\t_id: { $in: batchIds },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t...addProductMarketingInfo(exchangeRate, secondaryCurrencyName),\n\t\t\t\t{\n\t\t\t\t\t$group: {\n\t\t\t\t\t\t_id: '$_id',\n\t\t\t\t\t\tproductMarketingInfo: {\n\t\t\t\t\t\t\t$push: '$productMarketing',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t]);\n\n\t\t\tresults.push(...batchResults);\n\t\t}\n\n\t\tif (!results.length) return 'No matching products found';\n\n\t\tconst bulkOps = results.map(product => {\n\t\t\tconst productMarketingInfo = (product.productMarketingInfo || []).map((pm: any) => ({\n\t\t\t\tmarketing: pm.marketingInfo,\n\t\t\t\tisBuy1Get1: pm.isBuy1Get1,\n\t\t\t\tvalueType: pm.valueType,\n\t\t\t\tvalue: pm.value,\n\t\t\t\tsecondaryCurrencyValue: pm.secondaryCurrencyValue,\n\t\t\t\tlabel: pm.label,\n\t\t\t\tisAppliedByCompany: pm.isAppliedByCompany ?? false,\n\t\t\t}));\n\n\t\t\treturn {\n\t\t\t\tupdateOne: {\n\t\t\t\t\tfilter: { _id: product._id },\n\t\t\t\t\tupdate: {\n\t\t\t\t\t\t$set: { productMarketingInfo },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t});\n\n\t\tawait this.productModel.bulkWrite(bulkOps);\n\n\t\treturn `Synchronized product marketing info for ${bulkOps.length} products`;\n\t}\n\n\tpublic async syncProductMarketingInfoByMarketingIds(marketingIds: mongoose.Types.ObjectId[]) {\n\t\tif (!marketingIds.length) return 'No marketings to sync';\n\n\t\tconst productsToUpdate = await this.productMarketingModel\n\t\t\t.find({ marketing: { $in: marketingIds } })\n\t\t\t.select('product')\n\t\t\t.lean();\n\t\tif (!productsToUpdate.length) return 'No matching products found';\n\n\t\tconst productIds = productsToUpdate.map(p => p.product._id);\n\t\treturn await this.syncProductMarketingInfoByProductIds(productIds);\n\t}\n}\n\nexport const synchronizeProductMarketingService = Container.get(SynchronizeProductMarketingService);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"all-marketings.validation.d.ts","sourceRoot":"/","sources":["modules/marketing/validations/all-marketings.validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"all-marketings.validation.d.ts","sourceRoot":"/","sources":["modules/marketing/validations/all-marketings.validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAoBjC,eAAO,MAAM,6BAA6B,EAAE,OAM1C,CAAC;AAEH,eAAO,MAAM,mBAAmB,EAAE,OAMhC,CAAC;AAEH,eAAO,MAAM,yBAAyB,EAAE,OAMtC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA4C,CAAC;AAEjF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AACvF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
|
@@ -10,7 +10,6 @@ exports.AllMarketingsValidationSchema = zod_1.z.union([
|
|
|
10
10
|
_1.FeaturedMarketingValidationSchema,
|
|
11
11
|
_1.FreeDeliveryMarketingValidationSchema,
|
|
12
12
|
_1.PunchMarketingValidationSchema,
|
|
13
|
-
_1.SpendToGetMarketingValidationSchema,
|
|
14
13
|
]);
|
|
15
14
|
exports.AllMarketingsSchema = zod_1.z.union([
|
|
16
15
|
_1.DiscountMarketingSchema,
|
|
@@ -18,7 +17,6 @@ exports.AllMarketingsSchema = zod_1.z.union([
|
|
|
18
17
|
_1.PunchMarketingSchema,
|
|
19
18
|
_1.FeaturedMarketingSchema,
|
|
20
19
|
_1.FreeDeliveryMarketingSchema,
|
|
21
|
-
_1.SpendToGetMarketingSchema,
|
|
22
20
|
]);
|
|
23
21
|
exports.AllMarketingsUpdateSchema = zod_1.z.union([
|
|
24
22
|
_1.UpdateDiscountMarketingSchema,
|
|
@@ -26,7 +24,6 @@ exports.AllMarketingsUpdateSchema = zod_1.z.union([
|
|
|
26
24
|
_1.UpdatePunchMarketingSchema,
|
|
27
25
|
_1.UpdateFeaturedMarketingSchema,
|
|
28
26
|
_1.UpdateFreeDeliveryMarketingSchema,
|
|
29
|
-
_1.UpdateSpendToGetMarketingSchema,
|
|
30
27
|
]);
|
|
31
28
|
exports.MarketingResponseSchema = (0, validation_1.createResponseSchema)(exports.AllMarketingsSchema);
|
|
32
29
|
//# sourceMappingURL=all-marketings.validation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"all-marketings.validation.js","sourceRoot":"/","sources":["modules/marketing/validations/all-marketings.validation.ts"],"names":[],"mappings":";;;AAAA,6BAAiC;AACjC,
|
|
1
|
+
{"version":3,"file":"all-marketings.validation.js","sourceRoot":"/","sources":["modules/marketing/validations/all-marketings.validation.ts"],"names":[],"mappings":";;;AAAA,6BAAiC;AACjC,wBAgBW;AACX,wEAA+E;AAElE,QAAA,6BAA6B,GAAY,OAAC,CAAC,KAAK,CAAC;IAC7D,oCAAiC;IACjC,oCAAiC;IACjC,oCAAiC;IACjC,wCAAqC;IACrC,iCAA8B;CAC9B,CAAC,CAAC;AAEU,QAAA,mBAAmB,GAAY,OAAC,CAAC,KAAK,CAAC;IACnD,0BAAuB;IACvB,0BAAuB;IACvB,uBAAoB;IACpB,0BAAuB;IACvB,8BAA2B;CAC3B,CAAC,CAAC;AAEU,QAAA,yBAAyB,GAAY,OAAC,CAAC,KAAK,CAAC;IACzD,gCAA6B;IAC7B,gCAA6B;IAC7B,6BAA0B;IAC1B,gCAA6B;IAC7B,oCAAiC;CACjC,CAAC,CAAC;AAEU,QAAA,uBAAuB,GAAG,IAAA,iCAAoB,EAAC,2BAAmB,CAAC,CAAC","sourcesContent":["import { z, ZodType } from 'zod';\nimport {\n\tBuy1Get1MarketingSchema,\n\tBuy1Get1MarketingValidationSchema,\n\tDiscountMarketingSchema,\n\tDiscountMarketingValidationSchema,\n\tFeaturedMarketingSchema,\n\tFeaturedMarketingValidationSchema,\n\tFreeDeliveryMarketingSchema,\n\tFreeDeliveryMarketingValidationSchema,\n\tPunchMarketingSchema,\n\tPunchMarketingValidationSchema,\n\tUpdateBuy1Get1MarketingSchema,\n\tUpdateDiscountMarketingSchema,\n\tUpdateFeaturedMarketingSchema,\n\tUpdateFreeDeliveryMarketingSchema,\n\tUpdatePunchMarketingSchema,\n} from '.';\nimport { createResponseSchema } from '@lyxa.ai/core/dist/utilities/validation';\n\nexport const AllMarketingsValidationSchema: ZodType = z.union([\n\tBuy1Get1MarketingValidationSchema,\n\tDiscountMarketingValidationSchema,\n\tFeaturedMarketingValidationSchema,\n\tFreeDeliveryMarketingValidationSchema,\n\tPunchMarketingValidationSchema,\n]);\n\nexport const AllMarketingsSchema: ZodType = z.union([\n\tDiscountMarketingSchema,\n\tBuy1Get1MarketingSchema,\n\tPunchMarketingSchema,\n\tFeaturedMarketingSchema,\n\tFreeDeliveryMarketingSchema,\n]);\n\nexport const AllMarketingsUpdateSchema: ZodType = z.union([\n\tUpdateDiscountMarketingSchema,\n\tUpdateBuy1Get1MarketingSchema,\n\tUpdatePunchMarketingSchema,\n\tUpdateFeaturedMarketingSchema,\n\tUpdateFreeDeliveryMarketingSchema,\n]);\n\nexport const MarketingResponseSchema = createResponseSchema(AllMarketingsSchema);\n\nexport type AllMarketingsValidationDTO = z.infer<typeof AllMarketingsValidationSchema>;\nexport type AllMarketingsDTO = z.infer<typeof AllMarketingsSchema>;\n"]}
|
|
@@ -59,7 +59,6 @@ declare const Buy1Get1MarketingValidationSchema: z.ZodObject<{
|
|
|
59
59
|
isAppliedByCompany: boolean;
|
|
60
60
|
isEntireMenu: boolean;
|
|
61
61
|
pausedAt: Date | null;
|
|
62
|
-
marketingType: MarketingType.BUY1GET1;
|
|
63
62
|
products: {
|
|
64
63
|
product: import("mongoose").Types.ObjectId;
|
|
65
64
|
value?: number | undefined;
|
|
@@ -68,6 +67,7 @@ declare const Buy1Get1MarketingValidationSchema: z.ZodObject<{
|
|
|
68
67
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
69
68
|
isBuy1Get1?: boolean | undefined;
|
|
70
69
|
}[];
|
|
70
|
+
marketingType: MarketingType.BUY1GET1;
|
|
71
71
|
excludeProducts: import("mongoose").Types.ObjectId[];
|
|
72
72
|
isOnlyForSubscriber: boolean;
|
|
73
73
|
admin?: import("mongoose").Types.ObjectId | null | undefined;
|
|
@@ -437,7 +437,6 @@ declare const Buy1Get1MarketingValidationSchemaRefined: z.ZodEffects<z.ZodObject
|
|
|
437
437
|
isAppliedByCompany: boolean;
|
|
438
438
|
isEntireMenu: boolean;
|
|
439
439
|
pausedAt: Date | null;
|
|
440
|
-
marketingType: MarketingType.BUY1GET1;
|
|
441
440
|
products: {
|
|
442
441
|
product: import("mongoose").Types.ObjectId;
|
|
443
442
|
value?: number | undefined;
|
|
@@ -446,6 +445,7 @@ declare const Buy1Get1MarketingValidationSchemaRefined: z.ZodEffects<z.ZodObject
|
|
|
446
445
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
447
446
|
isBuy1Get1?: boolean | undefined;
|
|
448
447
|
}[];
|
|
448
|
+
marketingType: MarketingType.BUY1GET1;
|
|
449
449
|
excludeProducts: import("mongoose").Types.ObjectId[];
|
|
450
450
|
isOnlyForSubscriber: boolean;
|
|
451
451
|
admin?: import("mongoose").Types.ObjectId | null | undefined;
|
|
@@ -487,7 +487,6 @@ declare const Buy1Get1MarketingValidationSchemaRefined: z.ZodEffects<z.ZodObject
|
|
|
487
487
|
isAppliedByCompany: boolean;
|
|
488
488
|
isEntireMenu: boolean;
|
|
489
489
|
pausedAt: Date | null;
|
|
490
|
-
marketingType: MarketingType.BUY1GET1;
|
|
491
490
|
products: {
|
|
492
491
|
product: import("mongoose").Types.ObjectId;
|
|
493
492
|
value?: number | undefined;
|
|
@@ -496,6 +495,7 @@ declare const Buy1Get1MarketingValidationSchemaRefined: z.ZodEffects<z.ZodObject
|
|
|
496
495
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
497
496
|
isBuy1Get1?: boolean | undefined;
|
|
498
497
|
}[];
|
|
498
|
+
marketingType: MarketingType.BUY1GET1;
|
|
499
499
|
excludeProducts: import("mongoose").Types.ObjectId[];
|
|
500
500
|
isOnlyForSubscriber: boolean;
|
|
501
501
|
admin?: import("mongoose").Types.ObjectId | null | undefined;
|
|
@@ -67,7 +67,6 @@ declare const DiscountMarketingValidationSchema: z.ZodObject<{
|
|
|
67
67
|
isMaxDiscountPerOrderEnabled: boolean;
|
|
68
68
|
maxDiscountPerOrder: number;
|
|
69
69
|
pausedAt: Date | null;
|
|
70
|
-
marketingType: MarketingType.DISCOUNT;
|
|
71
70
|
products: {
|
|
72
71
|
product: import("mongoose").Types.ObjectId;
|
|
73
72
|
value?: number | undefined;
|
|
@@ -76,6 +75,7 @@ declare const DiscountMarketingValidationSchema: z.ZodObject<{
|
|
|
76
75
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
77
76
|
isBuy1Get1?: boolean | undefined;
|
|
78
77
|
}[];
|
|
78
|
+
marketingType: MarketingType.DISCOUNT;
|
|
79
79
|
excludeProducts: import("mongoose").Types.ObjectId[];
|
|
80
80
|
isOnlyForSubscriber: boolean;
|
|
81
81
|
value?: number | undefined;
|
|
@@ -337,7 +337,6 @@ declare const DiscountMarketingValidationSchemaRefined: z.ZodEffects<z.ZodObject
|
|
|
337
337
|
isMaxDiscountPerOrderEnabled: boolean;
|
|
338
338
|
maxDiscountPerOrder: number;
|
|
339
339
|
pausedAt: Date | null;
|
|
340
|
-
marketingType: MarketingType.DISCOUNT;
|
|
341
340
|
products: {
|
|
342
341
|
product: import("mongoose").Types.ObjectId;
|
|
343
342
|
value?: number | undefined;
|
|
@@ -346,6 +345,7 @@ declare const DiscountMarketingValidationSchemaRefined: z.ZodEffects<z.ZodObject
|
|
|
346
345
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
347
346
|
isBuy1Get1?: boolean | undefined;
|
|
348
347
|
}[];
|
|
348
|
+
marketingType: MarketingType.DISCOUNT;
|
|
349
349
|
excludeProducts: import("mongoose").Types.ObjectId[];
|
|
350
350
|
isOnlyForSubscriber: boolean;
|
|
351
351
|
value?: number | undefined;
|
|
@@ -399,7 +399,6 @@ declare const DiscountMarketingValidationSchemaRefined: z.ZodEffects<z.ZodObject
|
|
|
399
399
|
isMaxDiscountPerOrderEnabled: boolean;
|
|
400
400
|
maxDiscountPerOrder: number;
|
|
401
401
|
pausedAt: Date | null;
|
|
402
|
-
marketingType: MarketingType.DISCOUNT;
|
|
403
402
|
products: {
|
|
404
403
|
product: import("mongoose").Types.ObjectId;
|
|
405
404
|
value?: number | undefined;
|
|
@@ -408,6 +407,7 @@ declare const DiscountMarketingValidationSchemaRefined: z.ZodEffects<z.ZodObject
|
|
|
408
407
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
409
408
|
isBuy1Get1?: boolean | undefined;
|
|
410
409
|
}[];
|
|
410
|
+
marketingType: MarketingType.DISCOUNT;
|
|
411
411
|
excludeProducts: import("mongoose").Types.ObjectId[];
|
|
412
412
|
isOnlyForSubscriber: boolean;
|
|
413
413
|
value?: number | undefined;
|
|
@@ -3,7 +3,6 @@ export * from './discount-marketing.validation';
|
|
|
3
3
|
export * from './featured-marketing.validation';
|
|
4
4
|
export * from './free-delivery-marketing.validation';
|
|
5
5
|
export * from './punch-marketing.validation';
|
|
6
|
-
export * from './spend-to-get-marketing.validation';
|
|
7
6
|
export * from './product-marketing.validation';
|
|
8
7
|
export * from './marketing.validation';
|
|
9
8
|
export * from './all-marketings.validation';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/marketing/validations/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,sCAAsC,CAAC;AACrD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/marketing/validations/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,sCAAsC,CAAC;AACrD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC"}
|
|
@@ -19,7 +19,6 @@ __exportStar(require("./discount-marketing.validation"), exports);
|
|
|
19
19
|
__exportStar(require("./featured-marketing.validation"), exports);
|
|
20
20
|
__exportStar(require("./free-delivery-marketing.validation"), exports);
|
|
21
21
|
__exportStar(require("./punch-marketing.validation"), exports);
|
|
22
|
-
__exportStar(require("./spend-to-get-marketing.validation"), exports);
|
|
23
22
|
__exportStar(require("./product-marketing.validation"), exports);
|
|
24
23
|
__exportStar(require("./marketing.validation"), exports);
|
|
25
24
|
__exportStar(require("./all-marketings.validation"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/marketing/validations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mEAAiD;AACjD,kEAAgD;AAChD,kEAAgD;AAChD,uEAAqD;AACrD,+DAA6C;AAC7C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/marketing/validations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mEAAiD;AACjD,kEAAgD;AAChD,kEAAgD;AAChD,uEAAqD;AACrD,+DAA6C;AAC7C,iEAA+C;AAC/C,yDAAuC;AACvC,8DAA4C","sourcesContent":["export * from './buy1-get1-marketing.validation';\nexport * from './discount-marketing.validation';\nexport * from './featured-marketing.validation';\nexport * from './free-delivery-marketing.validation';\nexport * from './punch-marketing.validation';\nexport * from './product-marketing.validation';\nexport * from './marketing.validation';\nexport * from './all-marketings.validation';\n"]}
|
|
@@ -184,19 +184,6 @@ export declare const ProductEntireMenuMarketingHandlerSchema: z.ZodObject<{
|
|
|
184
184
|
shop: string | import("mongoose").Types.ObjectId;
|
|
185
185
|
product: string | import("mongoose").Types.ObjectId;
|
|
186
186
|
}>;
|
|
187
|
-
export declare const SpendToGetProgressInputSchema: z.ZodObject<{
|
|
188
|
-
shop: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>;
|
|
189
|
-
basketTotal: z.ZodNumber;
|
|
190
|
-
userId: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>>;
|
|
191
|
-
}, "strip", z.ZodTypeAny, {
|
|
192
|
-
shop: import("mongoose").Types.ObjectId;
|
|
193
|
-
basketTotal: number;
|
|
194
|
-
userId?: import("mongoose").Types.ObjectId | undefined;
|
|
195
|
-
}, {
|
|
196
|
-
shop: string | import("mongoose").Types.ObjectId;
|
|
197
|
-
basketTotal: number;
|
|
198
|
-
userId?: string | import("mongoose").Types.ObjectId | undefined;
|
|
199
|
-
}>;
|
|
200
187
|
export declare const MarketingSpendLimitsEvaluationSchema: z.ZodObject<{
|
|
201
188
|
marketings: z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>, "many">;
|
|
202
189
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -243,7 +230,6 @@ export declare const MarketingMetricsSchema: z.ZodObject<{
|
|
|
243
230
|
count?: number | undefined;
|
|
244
231
|
percentageIncrease?: number | undefined;
|
|
245
232
|
}>>;
|
|
246
|
-
totalRedemptions: z.ZodOptional<z.ZodNumber>;
|
|
247
233
|
}, "strip", z.ZodTypeAny, {
|
|
248
234
|
numberOfItems?: number | undefined;
|
|
249
235
|
orderIncreaseWithDiscount?: {
|
|
@@ -254,7 +240,6 @@ export declare const MarketingMetricsSchema: z.ZodObject<{
|
|
|
254
240
|
count: number;
|
|
255
241
|
percentageIncrease: number;
|
|
256
242
|
} | undefined;
|
|
257
|
-
totalRedemptions?: number | undefined;
|
|
258
243
|
}, {
|
|
259
244
|
numberOfItems?: number | undefined;
|
|
260
245
|
orderIncreaseWithDiscount?: {
|
|
@@ -265,7 +250,6 @@ export declare const MarketingMetricsSchema: z.ZodObject<{
|
|
|
265
250
|
count?: number | undefined;
|
|
266
251
|
percentageIncrease?: number | undefined;
|
|
267
252
|
} | undefined;
|
|
268
|
-
totalRedemptions?: number | undefined;
|
|
269
253
|
}>;
|
|
270
254
|
export declare const MarketingGraphInputSchema: z.ZodObject<{
|
|
271
255
|
marketingId: z.ZodType<string | import("mongoose").Types.ObjectId, z.ZodTypeDef, string | import("mongoose").Types.ObjectId>;
|
|
@@ -317,7 +301,6 @@ export type CreateMarketingDTO = DTO<typeof MarketingValidationSchema>;
|
|
|
317
301
|
export type MarketingDTO = DTO<typeof MarketingSchema>;
|
|
318
302
|
export type UpdateMarketingDTO = DTO<typeof UpdateMarketingSchema>;
|
|
319
303
|
export type ProductEntireMenuMarketingHandlerDTO = DTO<typeof ProductEntireMenuMarketingHandlerSchema>;
|
|
320
|
-
export type SpendToGetProgressInputDTO = DTO<typeof SpendToGetProgressInputSchema>;
|
|
321
304
|
export type IncreaseDuringDiscountDTO = DTO<typeof IncreaseDuringDiscountSchema>;
|
|
322
305
|
export type MarketingMetricsDTO = DTO<typeof MarketingMetricsSchema>;
|
|
323
306
|
export type MarketingGraphInputDTO = DTO<typeof MarketingGraphInputSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marketing.validation.d.ts","sourceRoot":"/","sources":["modules/marketing/validations/marketing.validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAGN,GAAG,EACH,MAAM,2DAA2D,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAO9F,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;CAQ/B,CAAC;AAYF,QAAA,MACa,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACvB,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCACnB,iBAAiB,mNACb,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCACgB,CAAC;AAKrD,OAAO,EACN,yBAAyB,EACzB,eAAe,EACf,iBAAiB,IAAI,2BAA2B,EAChD,qBAAqB,GACrB,CAAC;AAEF,eAAO,MAAM,uCAAuC;;;;;;;;;EAGlD,CAAC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