@lyxa.ai/marketing 1.0.65 → 1.0.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/index.d.ts +11810 -21
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +0 -2
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts +0 -1074
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.js +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js +3 -3
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js.map +1 -1
- package/dist/lib/modules/coupon/services/referral-reward-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/referral-reward-coupon.service.js +0 -1
- package/dist/lib/modules/coupon/services/referral-reward-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/transformers/coupon.transformer.d.ts +0 -50
- package/dist/lib/modules/coupon/transformers/coupon.transformer.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts +0 -822
- package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/create-coupon.validation.d.ts +0 -98
- 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/coupon/validations/referral-reward-coupon.validation.d.ts +0 -374
- package/dist/lib/modules/coupon/validations/referral-reward-coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/referral-reward-coupon.validation.js +0 -2
- package/dist/lib/modules/coupon/validations/referral-reward-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 -13
- 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 -9
- 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 -10
- 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 -83
- 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 -4
- 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 +6 -75
- 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 -46
- 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 +10 -241
- 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 +4 -13
- 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 -30
- 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 -23
- 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 -18
- 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 -103
- 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 +2 -187
- 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 -34
- 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 +116 -515
- 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 -11
- 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 -48
- 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 +5 -19
- 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 -114
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js.map +1 -1
- package/dist/lib/modules/marketing/services/marketing.service.d.ts +3 -7
- package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/marketing.service.js +32 -76
- package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/services/product-marketing.service.d.ts +0 -1
- package/dist/lib/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/product-marketing.service.js +0 -32
- package/dist/lib/modules/marketing/services/product-marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/validations/punch-marketing.validation.d.ts +4 -4
- package/dist/lib/modules/referral-setting/validations/referral-setting.validation.d.ts.map +1 -1
- package/dist/lib/modules/referral-setting/validations/referral-setting.validation.js.map +1 -1
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.d.ts +2 -3
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.d.ts.map +1 -1
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.js +3 -11
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.js.map +1 -1
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.d.ts +0 -16
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.d.ts.map +1 -1
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.d.ts +2 -2
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.d.ts.map +1 -1
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.js.map +1 -1
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.d.ts +0 -19
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.d.ts.map +1 -1
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.js +0 -1
- package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.js.map +1 -1
- package/dist/types/index.d.ts +11810 -21
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/coupon/routers/coupon.router.d.ts +0 -1074
- package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/coupon.service.d.ts +1 -1
- package/dist/types/modules/coupon/services/referral-reward-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/transformers/coupon.transformer.d.ts +0 -50
- package/dist/types/modules/coupon/transformers/coupon.transformer.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts +0 -822
- package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/create-coupon.validation.d.ts +0 -98
- package/dist/types/modules/coupon/validations/create-coupon.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/referral-reward-coupon.validation.d.ts +0 -374
- package/dist/types/modules/coupon/validations/referral-reward-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 -10
- 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 -4
- 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 +10 -241
- 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 -30
- 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 -18
- 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 +2 -187
- 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 +116 -515
- 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 -11
- 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 +5 -19
- package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/marketing.service.d.ts +3 -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 +0 -6
- package/dist/types/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/validations/punch-marketing.validation.d.ts +4 -4
- package/dist/types/modules/referral-setting/validations/referral-setting.validation.d.ts.map +1 -1
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.repository.d.ts +2 -3
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.repository.d.ts.map +1 -1
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.router.d.ts +0 -16
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.router.d.ts.map +1 -1
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.service.d.ts +2 -2
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.service.d.ts.map +1 -1
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.validation.d.ts +0 -19
- package/dist/types/modules/spend-to-get-history/spend-to-get-history.validation.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts +0 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts.map +0 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.js +0 -2
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.js.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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limited-time-offer-campaign.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAG1C,4DAAgG;AAChG,4EAAwG;AAOxG,mHAA4F;AAC5F,mHAA4F;AAC5F,wIAAkH;AAClH,kIAAqI;AACrI,4HAAmH;AACnH,0DAA4D;AAE5D,MAAM,eAAe,GAAG,CAAC,qCAA8B,CAAC,SAAS,EAAE,qCAA8B,CAAC,MAAM,CAAC,CAAC;AAGnG,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IACnB,UAAU,CAAwB;IAClC,SAAS,CAA8B;IACvC,SAAS,CAA8B;IACvC,aAAa,CAAgC;IAErD;QACI,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,8DAAqB,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,GAAG,gBAAS,CAAC,GAAG,CAAC,2EAA2B,CAAC,CAAC;QAC5D,IAAI,CAAC,SAAS,GAAG,gBAAS,CAAC,GAAG,CAAC,2EAA2B,CAAC,CAAC;QAC5D,IAAI,CAAC,aAAa,GAAG,gBAAS,CAAC,GAAG,CAAC,iEAA6B,CAAC,CAAC;IACtE,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,GAAyB;QACzC,MAA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,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,oBAAa,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;YACjF,MAAM,IAAA,8BAAe,EAAC,uEAAuE,CAAC,CAAC;QACnG,CAAC,CAAC,CAAC;QAEH,IAAI,MAAM,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7E,MAAM,IAAA,8BAAe,EAAC,uEAAuE,CAAC,CAAC;QACnG,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ,CAAA;AAvMY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,gBAAO,GAAE;;GACG,kBAAkB,CAuM9B;AAEY,QAAA,kBAAkB,GAAG,gBAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {DocumentType, mongoose} from '@typegoose/typegoose';\nimport {LimitedTimeOfferCampaign as Model} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {LimitedTimeOfferCampaignStatus, MarketingType} from '@lyxa.ai/core/dist/utilities/enum';\nimport {badRequestError, conflictError, notFoundError} from '@lyxa.ai/core/dist/utilities/error-common';\nimport {\n CreateLtoCampaignDTO,\n GetLtoCampaignHistoryDTO,\n LtoActiveCampaignDTO,\n UpdateLtoCampaignDTO,\n} from '../limited-time-offer-campaign.validation';\nimport {LtoCampaignLifecycleService} from './limited-time-offer-campaign-lifecycle.service';\nimport {LtoCampaignSchedulerService} from './limited-time-offer-campaign-scheduler.service';\nimport {LtoCampaignRepository} from '@modules/limited-time-offer/campaign/limited-time-offer-campaign.repository';\nimport {LtoCampaignQueryBuilder, nextOccurrenceDate} from '@modules/limited-time-offer/campaign/limited-time-offer-campaign.builder';\nimport {LimitedTimeOfferConfigService} from '@modules/limited-time-offer/config/limited-time-offer-config.service';\nimport {isLtoScheduleEnabled} from '@utility/feature-flags';\n\nconst ACTIVE_STATUSES = [LimitedTimeOfferCampaignStatus.SCHEDULED, LimitedTimeOfferCampaignStatus.ACTIVE];\n\n@Service()\nexport class LtoCampaignService {\n private repository: LtoCampaignRepository;\n private scheduler: LtoCampaignSchedulerService;\n private lifecycle: LtoCampaignLifecycleService;\n private configService: LimitedTimeOfferConfigService;\n\n constructor() {\n this.repository = Container.get(LtoCampaignRepository);\n this.scheduler = Container.get(LtoCampaignSchedulerService);\n this.lifecycle = Container.get(LtoCampaignLifecycleService);\n this.configService = Container.get(LimitedTimeOfferConfigService);\n }\n\n public async create(dto: CreateLtoCampaignDTO) {\n await this.assertNoCampaignRunning();\n\n const config = await this.loadConfigSnapshot();\n\n const status = this.deriveCampaignStatus(dto.startDate);\n const campaign = await this.repository.create(\n LtoCampaignQueryBuilder.buildCreateInput({\n dto,\n status,\n campaignNumber: await this.repository.nextCampaignNumber(),\n config,\n startDate: dto.startDate,\n endDate: dto.endDate,\n })\n );\n\n if (status === LimitedTimeOfferCampaignStatus.SCHEDULED) {\n await this.scheduler.scheduleActivation(campaign._id, dto.startDate);\n }\n await this.scheduler.scheduleExpiry(campaign._id, dto.endDate);\n\n return campaign;\n }\n\n private deriveCampaignStatus(startDate: Date) {\n return startDate <= new Date()\n ? LimitedTimeOfferCampaignStatus.ACTIVE\n : LimitedTimeOfferCampaignStatus.SCHEDULED;\n }\n\n public async getCurrent() {\n return this.repository.findCurrent();\n }\n\n public async getActive(): Promise<LtoActiveCampaignDTO | null> {\n const campaign = await this.repository.findActive();\n if (!campaign) return null;\n\n return {\n _id: campaign._id,\n title: campaign.title,\n subtitle: campaign.subTitle,\n startTime: campaign.startDate,\n endTime: campaign.endDate,\n };\n }\n\n public async getById(campaignId: mongoose.Types.ObjectId) {\n const campaign = await this.repository.findById(campaignId);\n if (!campaign) throw notFoundError('Campaign not found');\n return campaign;\n }\n\n public async getHistory(dto: GetLtoCampaignHistoryDTO) {\n const {documents, total} = await this.repository.findHistory(dto);\n return {\n documents,\n metadata: {\n page: dto.page,\n size: dto.size,\n totalElements: total,\n totalPages: Math.ceil(total / dto.size),\n },\n };\n }\n\n public async update(dto: UpdateLtoCampaignDTO) {\n const campaign = await this.repository.findById(dto._id);\n if (!campaign) throw notFoundError('Campaign not found');\n\n this.assertUpdateAllowed(campaign, dto);\n\n const updates = LtoCampaignQueryBuilder.buildUpdateInput(campaign, dto);\n\n if (this.shouldExpireImmediately(campaign.status, dto.endDate)) {\n return this.applyImmediateExpiry(dto._id, updates);\n }\n\n const ltoScheduleEnabled = await isLtoScheduleEnabled();\n\n // For a scheduled recurring campaign, snap the schedule to the next selected weekday so the\n // selected days stay authoritative — an active session keeps the dto dates (takes effect now).\n const repeatDays = (updates.repeatDays ?? campaign.repeatDays ?? []) as number[];\n if (\n ltoScheduleEnabled &&\n updates.status === LimitedTimeOfferCampaignStatus.SCHEDULED &&\n repeatDays.length > 0\n ) {\n const occurrence = nextOccurrenceDate(repeatDays, dto.startDate, dto.endDate);\n updates.startDate = occurrence.startDate;\n updates.endDate = occurrence.endDate;\n }\n\n const result = await this.repository.updateById(dto._id, updates);\n if (!result) throw notFoundError('Campaign not found after update');\n\n // Postponing a live campaign back to SCHEDULED must undo what activation applied — otherwise\n // the shops' own discounts stay paused until the campaign eventually cancels or expires.\n if (\n ltoScheduleEnabled &&\n campaign.status === LimitedTimeOfferCampaignStatus.ACTIVE &&\n result.status === LimitedTimeOfferCampaignStatus.SCHEDULED\n ) {\n await this.lifecycle.demoteToScheduled(dto._id);\n }\n\n await this.rescheduleIfDatesChanged(result, campaign);\n\n return result;\n }\n\n public async cancel(campaignId: mongoose.Types.ObjectId): Promise<void> {\n const campaign = await this.repository.findById(campaignId);\n if (!campaign) throw notFoundError('Campaign not found');\n\n this.assertEditable(campaign.status);\n await this.scheduler.cancelJobs(campaignId);\n await this.lifecycle.cancelCampaign(campaignId);\n }\n\n private assertUpdateAllowed(campaign: DocumentType<Model>, dto: UpdateLtoCampaignDTO): void {\n this.assertEditable(campaign.status);\n\n if (campaign.status === LimitedTimeOfferCampaignStatus.ACTIVE && !dto.confirmActive) {\n throw badRequestError('Set confirmActive=true to confirm editing a live campaign.');\n }\n\n if (dto.startDate < new Date() && campaign.status === LimitedTimeOfferCampaignStatus.SCHEDULED) {\n throw badRequestError('Start date cannot be in the past.');\n }\n }\n\n private shouldExpireImmediately(status: LimitedTimeOfferCampaignStatus, endDate: Date): boolean {\n return status === LimitedTimeOfferCampaignStatus.ACTIVE && endDate <= new Date();\n }\n\n private async applyImmediateExpiry(campaignId: mongoose.Types.ObjectId, updates: object) {\n await this.scheduler.cancelJobs(campaignId);\n await this.repository.updateById(campaignId, updates);\n await this.lifecycle.expireCampaign(campaignId);\n const result = await this.repository.findById(campaignId);\n if (!result) throw notFoundError('Campaign not found after expiry');\n return result;\n }\n\n private async rescheduleIfDatesChanged(\n result: DocumentType<Model>,\n original: DocumentType<Model>\n ): Promise<void> {\n const datesChanged =\n result.startDate!.getTime() !== original.startDate!.getTime() ||\n result.endDate!.getTime() !== original.endDate!.getTime();\n\n if (!datesChanged) return;\n\n await this.scheduler.cancelJobs(result._id);\n if (result.status === LimitedTimeOfferCampaignStatus.SCHEDULED) {\n await this.scheduler.scheduleActivation(result._id, result.startDate!);\n }\n await this.scheduler.scheduleExpiry(result._id, result.endDate!);\n }\n\n private async assertNoCampaignRunning(): Promise<void> {\n if (await this.repository.hasActiveCampaign()) {\n throw conflictError('A campaign is already scheduled or active. Delete it before creating a new one.');\n }\n }\n\n private assertEditable(status: LimitedTimeOfferCampaignStatus): void {\n if (!ACTIVE_STATUSES.includes(status)) {\n throw badRequestError('Only SCHEDULED or ACTIVE campaigns can be modified.');\n }\n }\n\n private async loadConfigSnapshot() {\n const config = await this.configService.getByType(MarketingType.DISCOUNT).catch(() => {\n throw badRequestError('Global config is incomplete. Set discount options and max caps first.');\n });\n\n if (config.discountOptions.length === 0 || config.maxDiscountCaps.length === 0) {\n throw badRequestError('Global config is incomplete. Set discount options and max caps first.');\n }\n\n return config;\n }\n}\n\nexport const ltoCampaignService = Container.get(LtoCampaignService);\n"]}
|
|
1
|
+
{"version":3,"file":"limited-time-offer-campaign.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAG1C,4DAAgG;AAChG,4EAAwG;AAOxG,mHAA4F;AAC5F,mHAA4F;AAC5F,wIAAkH;AAClH,kIAAiH;AACjH,4HAAmH;AAEnH,MAAM,eAAe,GAAG,CAAC,qCAA8B,CAAC,SAAS,EAAE,qCAA8B,CAAC,MAAM,CAAC,CAAC;AAGnG,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IACnB,UAAU,CAAwB;IAClC,SAAS,CAA8B;IACvC,SAAS,CAA8B;IACvC,aAAa,CAAgC;IAErD;QACI,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,8DAAqB,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,GAAG,gBAAS,CAAC,GAAG,CAAC,2EAA2B,CAAC,CAAC;QAC5D,IAAI,CAAC,SAAS,GAAG,gBAAS,CAAC,GAAG,CAAC,2EAA2B,CAAC,CAAC;QAC5D,IAAI,CAAC,aAAa,GAAG,gBAAS,CAAC,GAAG,CAAC,iEAA6B,CAAC,CAAC;IACtE,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,GAAyB;QACzC,MAAM,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAErC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC/C,MAAM,MAAM,GAAG,GAAG,CAAC,SAAS,IAAI,GAAG;YAC/B,CAAC,CAAC,qCAA8B,CAAC,MAAM;YACvC,CAAC,CAAC,qCAA8B,CAAC,SAAS,CAAC;QAE/C,MAAM,QAAQ,GAAG,MA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CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACpC,MAAM,IAAA,8BAAe,EAAC,qDAAqD,CAAC,CAAC;QACjF,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,kBAAkB;QAC5B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,oBAAa,CAAC,QAAQ,CAAC;aACpE,KAAK,CAAC,GAAG,EAAE,GAAG,MAAM,IAAA,8BAAe,EAAC,uEAAuE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAEtH,IAAI,MAAM,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7E,MAAM,IAAA,8BAAe,EAAC,uEAAuE,CAAC,CAAC;QACnG,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ,CAAA;AApKY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,gBAAO,GAAE;;GACG,kBAAkB,CAoK9B;AAEY,QAAA,kBAAkB,GAAG,gBAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {DocumentType, mongoose} from '@typegoose/typegoose';\nimport {LimitedTimeOfferCampaign as Model} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {LimitedTimeOfferCampaignStatus, MarketingType} from '@lyxa.ai/core/dist/utilities/enum';\nimport {badRequestError, conflictError, notFoundError} from '@lyxa.ai/core/dist/utilities/error-common';\nimport {\n CreateLtoCampaignDTO,\n GetLtoCampaignHistoryDTO,\n LtoActiveCampaignDTO,\n UpdateLtoCampaignDTO,\n} from '../limited-time-offer-campaign.validation';\nimport {LtoCampaignLifecycleService} from './limited-time-offer-campaign-lifecycle.service';\nimport {LtoCampaignSchedulerService} from './limited-time-offer-campaign-scheduler.service';\nimport {LtoCampaignRepository} from '@modules/limited-time-offer/campaign/limited-time-offer-campaign.repository';\nimport {LtoCampaignQueryBuilder} from '@modules/limited-time-offer/campaign/limited-time-offer-campaign.builder';\nimport {LimitedTimeOfferConfigService} from '@modules/limited-time-offer/config/limited-time-offer-config.service';\n\nconst ACTIVE_STATUSES = [LimitedTimeOfferCampaignStatus.SCHEDULED, LimitedTimeOfferCampaignStatus.ACTIVE];\n\n@Service()\nexport class LtoCampaignService {\n private repository: LtoCampaignRepository;\n private scheduler: LtoCampaignSchedulerService;\n private lifecycle: LtoCampaignLifecycleService;\n private configService: LimitedTimeOfferConfigService;\n\n constructor() {\n this.repository = Container.get(LtoCampaignRepository);\n this.scheduler = Container.get(LtoCampaignSchedulerService);\n this.lifecycle = Container.get(LtoCampaignLifecycleService);\n this.configService = Container.get(LimitedTimeOfferConfigService);\n }\n\n public async create(dto: CreateLtoCampaignDTO) {\n await this.assertNoCampaignRunning();\n\n const now = new Date();\n const config = await this.loadConfigSnapshot();\n const status = dto.startDate <= now\n ? LimitedTimeOfferCampaignStatus.ACTIVE\n : LimitedTimeOfferCampaignStatus.SCHEDULED;\n\n const campaign = await this.repository.create(\n LtoCampaignQueryBuilder.buildCreateInput(dto, status, await this.repository.nextCampaignNumber(), config),\n );\n\n if (status === LimitedTimeOfferCampaignStatus.SCHEDULED) {\n await this.scheduler.scheduleActivation(campaign._id, dto.startDate);\n }\n await this.scheduler.scheduleExpiry(campaign._id, dto.endDate);\n\n return campaign;\n }\n\n public async getCurrent() {\n return this.repository.findCurrent();\n }\n\n public async getActive(): Promise<LtoActiveCampaignDTO | null> {\n const campaign = await this.repository.findActive();\n if (!campaign) return null;\n\n return {\n _id: campaign._id,\n title: campaign.title,\n subtitle: campaign.subTitle,\n startTime: campaign.startDate,\n endTime: campaign.endDate,\n };\n }\n\n public async getById(campaignId: mongoose.Types.ObjectId) {\n const campaign = await this.repository.findById(campaignId);\n if (!campaign) throw notFoundError('Campaign not found');\n return campaign;\n }\n\n public async getHistory(dto: GetLtoCampaignHistoryDTO) {\n const {documents, total} = await this.repository.findHistory(dto);\n return {\n documents,\n metadata: {page: dto.page, size: dto.size, totalElements: total, totalPages: Math.ceil(total / dto.size)},\n };\n }\n\n public async update(dto: UpdateLtoCampaignDTO) {\n const campaign = await this.repository.findById(dto._id);\n if (!campaign) throw notFoundError('Campaign not found');\n\n this.assertUpdateAllowed(campaign, dto);\n\n const updates = LtoCampaignQueryBuilder.buildUpdateInput(campaign, dto);\n\n if (this.shouldExpireImmediately(campaign.status, dto.endDate)) {\n return this.applyImmediateExpiry(dto._id, updates);\n }\n\n const result = await this.repository.updateById(dto._id, updates);\n if (!result) throw notFoundError('Campaign not found after update');\n\n await this.rescheduleIfDatesChanged(dto._id, result.status, campaign, dto);\n\n return result;\n }\n\n public async cancel(campaignId: mongoose.Types.ObjectId): Promise<void> {\n const campaign = await this.repository.findById(campaignId);\n if (!campaign) throw notFoundError('Campaign not found');\n\n this.assertEditable(campaign.status);\n await this.scheduler.cancelJobs(campaignId);\n await this.lifecycle.cancelCampaign(campaignId);\n }\n\n public async expire(campaignId: mongoose.Types.ObjectId): Promise<void> {\n await this.lifecycle.expireCampaign(campaignId);\n }\n\n private assertUpdateAllowed(campaign: DocumentType<Model>, dto: UpdateLtoCampaignDTO): void {\n this.assertEditable(campaign.status);\n\n if (campaign.status === LimitedTimeOfferCampaignStatus.ACTIVE && !dto.confirmActive) {\n throw badRequestError('Set confirmActive=true to confirm editing a live campaign.');\n }\n\n if (dto.startDate < new Date() && campaign.status === LimitedTimeOfferCampaignStatus.SCHEDULED) {\n throw badRequestError('Start date cannot be in the past.');\n }\n }\n\n private shouldExpireImmediately(status: LimitedTimeOfferCampaignStatus, endDate: Date): boolean {\n return status === LimitedTimeOfferCampaignStatus.ACTIVE && endDate <= new Date();\n }\n\n private async applyImmediateExpiry(campaignId: mongoose.Types.ObjectId, updates: object) {\n await this.scheduler.cancelJobs(campaignId);\n await this.repository.updateById(campaignId, updates);\n await this.lifecycle.expireCampaign(campaignId);\n const result = await this.repository.findById(campaignId);\n if (!result) throw notFoundError('Campaign not found after expiry');\n return result;\n }\n\n private async rescheduleIfDatesChanged(\n campaignId: mongoose.Types.ObjectId,\n currentStatus: LimitedTimeOfferCampaignStatus,\n original: DocumentType<Model>,\n dto: UpdateLtoCampaignDTO,\n ): Promise<void> {\n const datesChanged =\n dto.startDate.getTime() !== original.startDate!.getTime() ||\n dto.endDate.getTime() !== original.endDate!.getTime();\n\n if (!datesChanged) return;\n\n await this.scheduler.cancelJobs(campaignId);\n if (currentStatus === LimitedTimeOfferCampaignStatus.SCHEDULED) {\n await this.scheduler.scheduleActivation(campaignId, dto.startDate);\n }\n await this.scheduler.scheduleExpiry(campaignId, dto.endDate);\n }\n\n private async assertNoCampaignRunning(): Promise<void> {\n if (await this.repository.hasActiveCampaign()) {\n throw conflictError('A campaign is already scheduled or active. Delete it before creating a new one.');\n }\n }\n\n private assertEditable(status: LimitedTimeOfferCampaignStatus): void {\n if (!ACTIVE_STATUSES.includes(status)) {\n throw badRequestError('Only SCHEDULED or ACTIVE campaigns can be modified.');\n }\n }\n\n private async loadConfigSnapshot() {\n const config = await this.configService.getByType(MarketingType.DISCOUNT)\n .catch(() => { throw badRequestError('Global config is incomplete. Set discount options and max caps first.'); });\n\n if (config.discountOptions.length === 0 || config.maxDiscountCaps.length === 0) {\n throw badRequestError('Global config is incomplete. Set discount options and max caps first.');\n }\n\n return config;\n }\n}\n\nexport const ltoCampaignService = Container.get(LtoCampaignService);\n"]}
|
|
@@ -197,9 +197,7 @@ export declare const limitedTimeOfferRouter: import("@trpc/server").TRPCBuiltRou
|
|
|
197
197
|
startDate: string | Date;
|
|
198
198
|
endDate: string | Date;
|
|
199
199
|
title?: string | undefined;
|
|
200
|
-
campaignType?: import("@lyxa.ai/core/dist/utilities/enum").MarketingType | undefined;
|
|
201
200
|
subTitle?: string | undefined;
|
|
202
|
-
repeatDays?: number[] | undefined;
|
|
203
201
|
};
|
|
204
202
|
output: {
|
|
205
203
|
message: string;
|
|
@@ -214,10 +212,9 @@ export declare const limitedTimeOfferRouter: import("@trpc/server").TRPCBuiltRou
|
|
|
214
212
|
updatedAt?: Date | null | undefined;
|
|
215
213
|
title?: string | undefined;
|
|
216
214
|
subTitle?: string | undefined;
|
|
217
|
-
|
|
215
|
+
archivedAt?: Date | null | undefined;
|
|
218
216
|
discountOptions?: number[] | undefined;
|
|
219
217
|
maxDiscountCaps?: number[] | undefined;
|
|
220
|
-
archivedAt?: Date | null | undefined;
|
|
221
218
|
} | {
|
|
222
219
|
documents: {
|
|
223
220
|
status: import("@lyxa.ai/core/dist/utilities/enum").LimitedTimeOfferCampaignStatus;
|
|
@@ -229,10 +226,9 @@ export declare const limitedTimeOfferRouter: import("@trpc/server").TRPCBuiltRou
|
|
|
229
226
|
updatedAt?: Date | null | undefined;
|
|
230
227
|
title?: string | undefined;
|
|
231
228
|
subTitle?: string | undefined;
|
|
232
|
-
|
|
229
|
+
archivedAt?: Date | null | undefined;
|
|
233
230
|
discountOptions?: number[] | undefined;
|
|
234
231
|
maxDiscountCaps?: number[] | undefined;
|
|
235
|
-
archivedAt?: Date | null | undefined;
|
|
236
232
|
}[];
|
|
237
233
|
metadata?: {
|
|
238
234
|
size: number;
|
|
@@ -259,10 +255,9 @@ export declare const limitedTimeOfferRouter: import("@trpc/server").TRPCBuiltRou
|
|
|
259
255
|
updatedAt?: Date | null | undefined;
|
|
260
256
|
title?: string | undefined;
|
|
261
257
|
subTitle?: string | undefined;
|
|
262
|
-
|
|
258
|
+
archivedAt?: Date | null | undefined;
|
|
263
259
|
discountOptions?: number[] | undefined;
|
|
264
260
|
maxDiscountCaps?: number[] | undefined;
|
|
265
|
-
archivedAt?: Date | null | undefined;
|
|
266
261
|
} | {
|
|
267
262
|
documents: ({
|
|
268
263
|
status: import("@lyxa.ai/core/dist/utilities/enum").LimitedTimeOfferCampaignStatus;
|
|
@@ -274,10 +269,9 @@ export declare const limitedTimeOfferRouter: import("@trpc/server").TRPCBuiltRou
|
|
|
274
269
|
updatedAt?: Date | null | undefined;
|
|
275
270
|
title?: string | undefined;
|
|
276
271
|
subTitle?: string | undefined;
|
|
277
|
-
|
|
272
|
+
archivedAt?: Date | null | undefined;
|
|
278
273
|
discountOptions?: number[] | undefined;
|
|
279
274
|
maxDiscountCaps?: number[] | undefined;
|
|
280
|
-
archivedAt?: Date | null | undefined;
|
|
281
275
|
} | null)[];
|
|
282
276
|
metadata?: {
|
|
283
277
|
size: number;
|
|
@@ -306,10 +300,9 @@ export declare const limitedTimeOfferRouter: import("@trpc/server").TRPCBuiltRou
|
|
|
306
300
|
updatedAt?: Date | null | undefined;
|
|
307
301
|
title?: string | undefined;
|
|
308
302
|
subTitle?: string | undefined;
|
|
309
|
-
|
|
303
|
+
archivedAt?: Date | null | undefined;
|
|
310
304
|
discountOptions?: number[] | undefined;
|
|
311
305
|
maxDiscountCaps?: number[] | undefined;
|
|
312
|
-
archivedAt?: Date | null | undefined;
|
|
313
306
|
} | {
|
|
314
307
|
documents: {
|
|
315
308
|
status: import("@lyxa.ai/core/dist/utilities/enum").LimitedTimeOfferCampaignStatus;
|
|
@@ -321,10 +314,9 @@ export declare const limitedTimeOfferRouter: import("@trpc/server").TRPCBuiltRou
|
|
|
321
314
|
updatedAt?: Date | null | undefined;
|
|
322
315
|
title?: string | undefined;
|
|
323
316
|
subTitle?: string | undefined;
|
|
324
|
-
|
|
317
|
+
archivedAt?: Date | null | undefined;
|
|
325
318
|
discountOptions?: number[] | undefined;
|
|
326
319
|
maxDiscountCaps?: number[] | undefined;
|
|
327
|
-
archivedAt?: Date | null | undefined;
|
|
328
320
|
}[];
|
|
329
321
|
metadata?: {
|
|
330
322
|
size: number;
|
|
@@ -380,7 +372,6 @@ export declare const limitedTimeOfferRouter: import("@trpc/server").TRPCBuiltRou
|
|
|
380
372
|
endDate: string | Date;
|
|
381
373
|
title?: string | undefined;
|
|
382
374
|
subTitle?: string | undefined;
|
|
383
|
-
repeatDays?: number[] | undefined;
|
|
384
375
|
discountOptions?: number[] | undefined;
|
|
385
376
|
maxDiscountCaps?: number[] | undefined;
|
|
386
377
|
confirmActive?: boolean | undefined;
|
|
@@ -398,10 +389,9 @@ export declare const limitedTimeOfferRouter: import("@trpc/server").TRPCBuiltRou
|
|
|
398
389
|
updatedAt?: Date | null | undefined;
|
|
399
390
|
title?: string | undefined;
|
|
400
391
|
subTitle?: string | undefined;
|
|
401
|
-
|
|
392
|
+
archivedAt?: Date | null | undefined;
|
|
402
393
|
discountOptions?: number[] | undefined;
|
|
403
394
|
maxDiscountCaps?: number[] | undefined;
|
|
404
|
-
archivedAt?: Date | null | undefined;
|
|
405
395
|
} | {
|
|
406
396
|
documents: {
|
|
407
397
|
status: import("@lyxa.ai/core/dist/utilities/enum").LimitedTimeOfferCampaignStatus;
|
|
@@ -413,10 +403,9 @@ export declare const limitedTimeOfferRouter: import("@trpc/server").TRPCBuiltRou
|
|
|
413
403
|
updatedAt?: Date | null | undefined;
|
|
414
404
|
title?: string | undefined;
|
|
415
405
|
subTitle?: string | undefined;
|
|
416
|
-
|
|
406
|
+
archivedAt?: Date | null | undefined;
|
|
417
407
|
discountOptions?: number[] | undefined;
|
|
418
408
|
maxDiscountCaps?: number[] | undefined;
|
|
419
|
-
archivedAt?: Date | null | undefined;
|
|
420
409
|
}[];
|
|
421
410
|
metadata?: {
|
|
422
411
|
size: number;
|
|
@@ -460,41 +449,6 @@ export declare const limitedTimeOfferRouter: import("@trpc/server").TRPCBuiltRou
|
|
|
460
449
|
};
|
|
461
450
|
meta: object;
|
|
462
451
|
}>;
|
|
463
|
-
getSessions: import("@trpc/server").TRPCQueryProcedure<{
|
|
464
|
-
input: {
|
|
465
|
-
campaignId: string | import("mongoose").Types.ObjectId;
|
|
466
|
-
page?: number | undefined;
|
|
467
|
-
size?: number | undefined;
|
|
468
|
-
};
|
|
469
|
-
output: {
|
|
470
|
-
message: string;
|
|
471
|
-
success: boolean;
|
|
472
|
-
data?: {
|
|
473
|
-
_id: string | import("mongoose").Types.ObjectId;
|
|
474
|
-
startDate: Date;
|
|
475
|
-
endDate: Date;
|
|
476
|
-
shopCount: number;
|
|
477
|
-
archivedAt: Date;
|
|
478
|
-
campaign: string | import("mongoose").Types.ObjectId;
|
|
479
|
-
} | {
|
|
480
|
-
documents: {
|
|
481
|
-
_id: string | import("mongoose").Types.ObjectId;
|
|
482
|
-
startDate: Date;
|
|
483
|
-
endDate: Date;
|
|
484
|
-
shopCount: number;
|
|
485
|
-
archivedAt: Date;
|
|
486
|
-
campaign: string | import("mongoose").Types.ObjectId;
|
|
487
|
-
}[];
|
|
488
|
-
metadata?: {
|
|
489
|
-
size: number;
|
|
490
|
-
page: number;
|
|
491
|
-
totalElements: number;
|
|
492
|
-
totalPages: number;
|
|
493
|
-
} | undefined;
|
|
494
|
-
} | undefined;
|
|
495
|
-
};
|
|
496
|
-
meta: object;
|
|
497
|
-
}>;
|
|
498
452
|
cancel: import("@trpc/server").TRPCMutationProcedure<{
|
|
499
453
|
input: {
|
|
500
454
|
campaignId: string | import("mongoose").Types.ObjectId;
|
|
@@ -699,130 +653,6 @@ export declare const limitedTimeOfferRouter: import("@trpc/server").TRPCBuiltRou
|
|
|
699
653
|
};
|
|
700
654
|
meta: object;
|
|
701
655
|
}>;
|
|
702
|
-
enrollShops: import("@trpc/server").TRPCMutationProcedure<{
|
|
703
|
-
input: {
|
|
704
|
-
shops: {
|
|
705
|
-
isEntireMenu: boolean;
|
|
706
|
-
shopId: string | import("mongoose").Types.ObjectId;
|
|
707
|
-
maxDiscountCap: number;
|
|
708
|
-
discountPercentage: number;
|
|
709
|
-
isOrderCapacityEnabled: boolean;
|
|
710
|
-
products?: (string | import("mongoose").Types.ObjectId)[] | undefined;
|
|
711
|
-
maxOrderCapacity?: number | undefined;
|
|
712
|
-
shopCategories?: (string | import("mongoose").Types.ObjectId)[] | undefined;
|
|
713
|
-
}[];
|
|
714
|
-
};
|
|
715
|
-
output: {
|
|
716
|
-
message: string;
|
|
717
|
-
success: boolean;
|
|
718
|
-
data?: {
|
|
719
|
-
_id: string | import("mongoose").Types.ObjectId;
|
|
720
|
-
shop: string | import("mongoose").Types.ObjectId;
|
|
721
|
-
isEntireMenu: boolean;
|
|
722
|
-
joinedAt: Date;
|
|
723
|
-
campaign: string | import("mongoose").Types.ObjectId;
|
|
724
|
-
isOrderCapacityEnabled: boolean;
|
|
725
|
-
isWithdrawn: boolean;
|
|
726
|
-
createdAt?: Date | null | undefined;
|
|
727
|
-
updatedAt?: Date | null | undefined;
|
|
728
|
-
products?: (string | import("mongoose").Types.ObjectId)[] | undefined;
|
|
729
|
-
maxDiscountCap?: number | undefined;
|
|
730
|
-
discountPercentage?: number | undefined;
|
|
731
|
-
maxOrderCapacity?: number | undefined;
|
|
732
|
-
withdrawnAt?: Date | null | undefined;
|
|
733
|
-
}[] | {
|
|
734
|
-
documents: {
|
|
735
|
-
_id: string | import("mongoose").Types.ObjectId;
|
|
736
|
-
shop: string | import("mongoose").Types.ObjectId;
|
|
737
|
-
isEntireMenu: boolean;
|
|
738
|
-
joinedAt: Date;
|
|
739
|
-
campaign: string | import("mongoose").Types.ObjectId;
|
|
740
|
-
isOrderCapacityEnabled: boolean;
|
|
741
|
-
isWithdrawn: boolean;
|
|
742
|
-
createdAt?: Date | null | undefined;
|
|
743
|
-
updatedAt?: Date | null | undefined;
|
|
744
|
-
products?: (string | import("mongoose").Types.ObjectId)[] | undefined;
|
|
745
|
-
maxDiscountCap?: number | undefined;
|
|
746
|
-
discountPercentage?: number | undefined;
|
|
747
|
-
maxOrderCapacity?: number | undefined;
|
|
748
|
-
withdrawnAt?: Date | null | undefined;
|
|
749
|
-
}[][];
|
|
750
|
-
metadata?: {
|
|
751
|
-
size: number;
|
|
752
|
-
page: number;
|
|
753
|
-
totalElements: number;
|
|
754
|
-
totalPages: number;
|
|
755
|
-
} | undefined;
|
|
756
|
-
} | undefined;
|
|
757
|
-
};
|
|
758
|
-
meta: object;
|
|
759
|
-
}>;
|
|
760
|
-
updateShop: import("@trpc/server").TRPCMutationProcedure<{
|
|
761
|
-
input: {
|
|
762
|
-
isEntireMenu: boolean;
|
|
763
|
-
shopId: string | import("mongoose").Types.ObjectId;
|
|
764
|
-
maxDiscountCap: number;
|
|
765
|
-
discountPercentage: number;
|
|
766
|
-
isOrderCapacityEnabled: boolean;
|
|
767
|
-
products?: (string | import("mongoose").Types.ObjectId)[] | undefined;
|
|
768
|
-
maxOrderCapacity?: number | undefined;
|
|
769
|
-
shopCategories?: (string | import("mongoose").Types.ObjectId)[] | undefined;
|
|
770
|
-
};
|
|
771
|
-
output: {
|
|
772
|
-
message: string;
|
|
773
|
-
success: boolean;
|
|
774
|
-
data?: {
|
|
775
|
-
_id: string | import("mongoose").Types.ObjectId;
|
|
776
|
-
shop: string | import("mongoose").Types.ObjectId;
|
|
777
|
-
isEntireMenu: boolean;
|
|
778
|
-
joinedAt: Date;
|
|
779
|
-
campaign: string | import("mongoose").Types.ObjectId;
|
|
780
|
-
isOrderCapacityEnabled: boolean;
|
|
781
|
-
isWithdrawn: boolean;
|
|
782
|
-
createdAt?: Date | null | undefined;
|
|
783
|
-
updatedAt?: Date | null | undefined;
|
|
784
|
-
products?: (string | import("mongoose").Types.ObjectId)[] | undefined;
|
|
785
|
-
maxDiscountCap?: number | undefined;
|
|
786
|
-
discountPercentage?: number | undefined;
|
|
787
|
-
maxOrderCapacity?: number | undefined;
|
|
788
|
-
withdrawnAt?: Date | null | undefined;
|
|
789
|
-
} | {
|
|
790
|
-
documents: {
|
|
791
|
-
_id: string | import("mongoose").Types.ObjectId;
|
|
792
|
-
shop: string | import("mongoose").Types.ObjectId;
|
|
793
|
-
isEntireMenu: boolean;
|
|
794
|
-
joinedAt: Date;
|
|
795
|
-
campaign: string | import("mongoose").Types.ObjectId;
|
|
796
|
-
isOrderCapacityEnabled: boolean;
|
|
797
|
-
isWithdrawn: boolean;
|
|
798
|
-
createdAt?: Date | null | undefined;
|
|
799
|
-
updatedAt?: Date | null | undefined;
|
|
800
|
-
products?: (string | import("mongoose").Types.ObjectId)[] | undefined;
|
|
801
|
-
maxDiscountCap?: number | undefined;
|
|
802
|
-
discountPercentage?: number | undefined;
|
|
803
|
-
maxOrderCapacity?: number | undefined;
|
|
804
|
-
withdrawnAt?: Date | null | undefined;
|
|
805
|
-
}[];
|
|
806
|
-
metadata?: {
|
|
807
|
-
size: number;
|
|
808
|
-
page: number;
|
|
809
|
-
totalElements: number;
|
|
810
|
-
totalPages: number;
|
|
811
|
-
} | undefined;
|
|
812
|
-
} | undefined;
|
|
813
|
-
};
|
|
814
|
-
meta: object;
|
|
815
|
-
}>;
|
|
816
|
-
withdrawShop: import("@trpc/server").TRPCMutationProcedure<{
|
|
817
|
-
input: {
|
|
818
|
-
shopId: string | import("mongoose").Types.ObjectId;
|
|
819
|
-
};
|
|
820
|
-
output: {
|
|
821
|
-
message: string;
|
|
822
|
-
success: boolean;
|
|
823
|
-
};
|
|
824
|
-
meta: object;
|
|
825
|
-
}>;
|
|
826
656
|
getParticipants: import("@trpc/server").TRPCQueryProcedure<{
|
|
827
657
|
input: {
|
|
828
658
|
campaignId: string | import("mongoose").Types.ObjectId;
|
|
@@ -838,77 +668,16 @@ export declare const limitedTimeOfferRouter: import("@trpc/server").TRPCBuiltRou
|
|
|
838
668
|
joinedAt: Date;
|
|
839
669
|
shopName: string | null;
|
|
840
670
|
maxDiscountCap?: number | undefined;
|
|
841
|
-
shopPhoto?: string | null | undefined;
|
|
842
671
|
discountPercentage?: number | undefined;
|
|
672
|
+
shopPhoto?: string | null | undefined;
|
|
843
673
|
} | {
|
|
844
674
|
documents: {
|
|
845
675
|
shopId: string | import("mongoose").Types.ObjectId;
|
|
846
676
|
joinedAt: Date;
|
|
847
677
|
shopName: string | null;
|
|
848
678
|
maxDiscountCap?: number | undefined;
|
|
849
|
-
shopPhoto?: string | null | undefined;
|
|
850
|
-
discountPercentage?: number | undefined;
|
|
851
|
-
}[];
|
|
852
|
-
metadata?: {
|
|
853
|
-
size: number;
|
|
854
|
-
page: number;
|
|
855
|
-
totalElements: number;
|
|
856
|
-
totalPages: number;
|
|
857
|
-
} | undefined;
|
|
858
|
-
} | undefined;
|
|
859
|
-
};
|
|
860
|
-
meta: object;
|
|
861
|
-
}>;
|
|
862
|
-
getParticipantByShop: import("@trpc/server").TRPCQueryProcedure<{
|
|
863
|
-
input: {
|
|
864
|
-
shopId: string | import("mongoose").Types.ObjectId;
|
|
865
|
-
};
|
|
866
|
-
output: {
|
|
867
|
-
message: string;
|
|
868
|
-
success: boolean;
|
|
869
|
-
data?: {
|
|
870
|
-
campaignState: import("./participant/limited-time-offer-participant.validation").LtoCardState;
|
|
871
|
-
campaign?: {
|
|
872
|
-
_id: string | import("mongoose").Types.ObjectId;
|
|
873
|
-
startDate?: Date | null | undefined;
|
|
874
|
-
endDate?: Date | null | undefined;
|
|
875
|
-
title?: string | undefined;
|
|
876
|
-
subTitle?: string | undefined;
|
|
877
|
-
discountOptions?: number[] | undefined;
|
|
878
|
-
maxDiscountCaps?: number[] | undefined;
|
|
879
|
-
} | undefined;
|
|
880
|
-
participant?: {
|
|
881
|
-
isEntireMenu: boolean;
|
|
882
|
-
joinedAt: Date;
|
|
883
|
-
isOrderCapacityEnabled: boolean;
|
|
884
|
-
productIds?: (string | import("mongoose").Types.ObjectId)[] | undefined;
|
|
885
|
-
marketingId?: string | import("mongoose").Types.ObjectId | undefined;
|
|
886
|
-
maxDiscountCap?: number | undefined;
|
|
887
679
|
discountPercentage?: number | undefined;
|
|
888
|
-
|
|
889
|
-
} | undefined;
|
|
890
|
-
} | {
|
|
891
|
-
documents: {
|
|
892
|
-
campaignState: import("./participant/limited-time-offer-participant.validation").LtoCardState;
|
|
893
|
-
campaign?: {
|
|
894
|
-
_id: string | import("mongoose").Types.ObjectId;
|
|
895
|
-
startDate?: Date | null | undefined;
|
|
896
|
-
endDate?: Date | null | undefined;
|
|
897
|
-
title?: string | undefined;
|
|
898
|
-
subTitle?: string | undefined;
|
|
899
|
-
discountOptions?: number[] | undefined;
|
|
900
|
-
maxDiscountCaps?: number[] | undefined;
|
|
901
|
-
} | undefined;
|
|
902
|
-
participant?: {
|
|
903
|
-
isEntireMenu: boolean;
|
|
904
|
-
joinedAt: Date;
|
|
905
|
-
isOrderCapacityEnabled: boolean;
|
|
906
|
-
productIds?: (string | import("mongoose").Types.ObjectId)[] | undefined;
|
|
907
|
-
marketingId?: string | import("mongoose").Types.ObjectId | undefined;
|
|
908
|
-
maxDiscountCap?: number | undefined;
|
|
909
|
-
discountPercentage?: number | undefined;
|
|
910
|
-
maxOrderCapacity?: number | undefined;
|
|
911
|
-
} | undefined;
|
|
680
|
+
shopPhoto?: string | null | undefined;
|
|
912
681
|
}[];
|
|
913
682
|
metadata?: {
|
|
914
683
|
size: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limited-time-offer.router.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/limited-time-offer.router.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,sBAAsB
|
|
1
|
+
{"version":3,"file":"limited-time-offer.router.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/limited-time-offer.router.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwBjC,CAAC"}
|
|
@@ -2,11 +2,9 @@ import { mongoose } from '@typegoose/typegoose';
|
|
|
2
2
|
import { GetActiveCampaignDTO } from '../limited-time-offer/campaign/limited-time-offer-campaign.validation';
|
|
3
3
|
export declare class LimitedTimeOfferService {
|
|
4
4
|
private campaignService;
|
|
5
|
-
private lifecycle;
|
|
6
5
|
private participantService;
|
|
7
6
|
private notificationService;
|
|
8
7
|
constructor();
|
|
9
|
-
activateCampaign(campaignId: mongoose.Types.ObjectId): Promise<void>;
|
|
10
8
|
getActiveCampaign(input: GetActiveCampaignDTO): Promise<{
|
|
11
9
|
_id: mongoose.Types.ObjectId;
|
|
12
10
|
title?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limited-time-offer.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/limited-time-offer.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"limited-time-offer.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/limited-time-offer.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAK9C,OAAO,EAAC,oBAAoB,EAAC,MAAM,6EAA6E,CAAC;AAejH,qBACa,uBAAuB;IAChC,OAAO,CAAC,eAAe,CAAqB;IAC5C,OAAO,CAAC,kBAAkB,CAAqC;IAC/D,OAAO,CAAC,mBAAmB,CAAsC;;IAQpD,iBAAiB,CAAC,KAAK,EAAE,oBAAoB;;;;;;;IAQ7C,cAAc,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAOlE,cAAc,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAIlF;AAED,eAAO,MAAM,uBAAuB,yBAAyC,CAAC"}
|
|
@@ -45,29 +45,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
45
45
|
exports.limitedTimeOfferService = exports.LimitedTimeOfferService = void 0;
|
|
46
46
|
const typedi_1 = __importStar(require("typedi"));
|
|
47
47
|
const limited_time_offer_campaign_service_1 = require("../limited-time-offer/campaign/services/limited-time-offer-campaign.service");
|
|
48
|
-
const limited_time_offer_campaign_lifecycle_service_1 = require("../limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service");
|
|
49
48
|
const limited_time_offer_participant_service_1 = require("../limited-time-offer/participant/services/limited-time-offer-participant.service");
|
|
50
49
|
const limited_time_offer_notification_service_1 = require("../limited-time-offer/notification/limited-time-offer-notification.service");
|
|
51
50
|
const limited_time_offer_notification_constants_1 = require("../limited-time-offer/notification/limited-time-offer-notification.constants");
|
|
52
|
-
const feature_flags_1 = require("../../utility/feature-flags");
|
|
53
51
|
let LimitedTimeOfferService = class LimitedTimeOfferService {
|
|
54
52
|
campaignService;
|
|
55
|
-
lifecycle;
|
|
56
53
|
participantService;
|
|
57
54
|
notificationService;
|
|
58
55
|
constructor() {
|
|
59
56
|
this.campaignService = limited_time_offer_campaign_service_1.ltoCampaignService;
|
|
60
|
-
this.lifecycle = typedi_1.default.get(limited_time_offer_campaign_lifecycle_service_1.LtoCampaignLifecycleService);
|
|
61
57
|
this.participantService = limited_time_offer_participant_service_1.ltoParticipantService;
|
|
62
58
|
this.notificationService = typedi_1.default.get(limited_time_offer_notification_service_1.LimitedTimeOfferNotificationService);
|
|
63
59
|
}
|
|
64
|
-
async activateCampaign(campaignId) {
|
|
65
|
-
const campaign = await this.campaignService.getById(campaignId);
|
|
66
|
-
await this.lifecycle.activateCampaign(campaignId);
|
|
67
|
-
if (!(await (0, feature_flags_1.isLtoScheduleEnabled)()))
|
|
68
|
-
return;
|
|
69
|
-
await this.participantService.applyLiveEffectsToParticipants(campaign);
|
|
70
|
-
}
|
|
71
60
|
async getActiveCampaign(input) {
|
|
72
61
|
const campaign = await this.campaignService.getActive();
|
|
73
62
|
if (!campaign)
|
|
@@ -76,12 +65,14 @@ let LimitedTimeOfferService = class LimitedTimeOfferService {
|
|
|
76
65
|
return nearbyParticipants.length > 0 ? campaign : null;
|
|
77
66
|
}
|
|
78
67
|
async cancelCampaign(campaignId) {
|
|
79
|
-
const participantIds = await this.participantService.getParticipantIdsByCampaignId(campaignId);
|
|
80
68
|
await this.campaignService.cancel(campaignId);
|
|
69
|
+
const participantIds = await this.participantService.getParticipantIdsByCampaignId(campaignId);
|
|
70
|
+
await this.participantService.removeCampaignMarketings(campaignId);
|
|
81
71
|
await this.notificationService.send(limited_time_offer_notification_constants_1.NotificationType.Cancel, participantIds, { campaignId });
|
|
82
72
|
}
|
|
83
73
|
async expireCampaign(campaignId) {
|
|
84
|
-
await this.
|
|
74
|
+
await this.campaignService.expire(campaignId);
|
|
75
|
+
await this.participantService.removeCampaignMarketings(campaignId);
|
|
85
76
|
}
|
|
86
77
|
};
|
|
87
78
|
exports.LimitedTimeOfferService = LimitedTimeOfferService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limited-time-offer.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/limited-time-offer.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,2IAG2F;
|
|
1
|
+
{"version":3,"file":"limited-time-offer.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/limited-time-offer.service.ts"],"names":[],"mappings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AC,cAAc,CAAC,UAAmC;QAC3D,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC9C,MAAM,IAAI,CAAC,kBAAkB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAC;IACvE,CAAC;CACJ,CAAA;AA9BY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,gBAAO,GAAE;;GACG,uBAAuB,CA8BnC;AAEY,QAAA,uBAAuB,GAAG,gBAAS,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {\n ltoCampaignService,\n LtoCampaignService,\n} from '@modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service';\nimport {GetActiveCampaignDTO} from '@modules/limited-time-offer/campaign/limited-time-offer-campaign.validation';\nimport {\n LimitedTimeOfferParticipantService,\n ltoParticipantService,\n} from '@modules/limited-time-offer/participant/services/limited-time-offer-participant.service';\nimport {\n LimitedTimeOfferNotificationService\n} from \"@modules/limited-time-offer/notification/limited-time-offer-notification.service\";\nimport {NotificationType} from \"@modules/limited-time-offer/notification/limited-time-offer-notification.constants\";\n\n/**\n * Application/orchestration layer for the Limited Time Offer module. Owns every flow that spans the\n * campaign and participant aggregates so neither domain service has to reach across the boundary.\n * Pure single-aggregate operations stay on their respective domain services.\n */\n@Service()\nexport class LimitedTimeOfferService {\n private campaignService: LtoCampaignService;\n private participantService: LimitedTimeOfferParticipantService;\n private notificationService: LimitedTimeOfferNotificationService;\n\n constructor() {\n this.campaignService = ltoCampaignService;\n this.participantService = ltoParticipantService;\n this.notificationService = Container.get(LimitedTimeOfferNotificationService);\n }\n\n public async getActiveCampaign(input: GetActiveCampaignDTO) {\n const campaign = await this.campaignService.getActive();\n if (!campaign) return null;\n\n const nearbyParticipants = await this.participantService.getNearby(campaign._id, input);\n return nearbyParticipants.length > 0 ? campaign : null;\n }\n\n public async cancelCampaign(campaignId: mongoose.Types.ObjectId): Promise<void> {\n await this.campaignService.cancel(campaignId);\n const participantIds = await this.participantService.getParticipantIdsByCampaignId(campaignId)\n await this.participantService.removeCampaignMarketings(campaignId);\n await this.notificationService.send(NotificationType.Cancel, participantIds, {campaignId})\n }\n\n public async expireCampaign(campaignId: mongoose.Types.ObjectId): Promise<void> {\n await this.campaignService.expire(campaignId);\n await this.participantService.removeCampaignMarketings(campaignId);\n }\n}\n\nexport const limitedTimeOfferService = Container.get(LimitedTimeOfferService);\n"]}
|
|
@@ -8,7 +8,7 @@ export declare const TARGET_ACCOUNT_TYPES: readonly [NotificationAccountType.SHO
|
|
|
8
8
|
export declare const NOTIFICATIONS: {
|
|
9
9
|
readonly CAMPAIGN_CANCELLED: {
|
|
10
10
|
readonly title: "Lyxa deleted the current campaign";
|
|
11
|
-
readonly body: "The ongoing limited time offer campaign has been deleted by
|
|
11
|
+
readonly body: "The ongoing limited time offer campaign has been deleted by lyxa.";
|
|
12
12
|
readonly sound: "notification_sound";
|
|
13
13
|
};
|
|
14
14
|
readonly CAMPAIGN_ACTIVATED: {
|
|
@@ -14,7 +14,7 @@ const CUSTOM_NOTIFICATION_SOUND = 'notification_sound';
|
|
|
14
14
|
exports.NOTIFICATIONS = {
|
|
15
15
|
CAMPAIGN_CANCELLED: {
|
|
16
16
|
title: "Lyxa deleted the current campaign",
|
|
17
|
-
body: "The ongoing limited time offer campaign has been deleted by
|
|
17
|
+
body: "The ongoing limited time offer campaign has been deleted by lyxa.",
|
|
18
18
|
sound: CUSTOM_NOTIFICATION_SOUND
|
|
19
19
|
},
|
|
20
20
|
CAMPAIGN_ACTIVATED: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limited-time-offer-notification.constants.js","sourceRoot":"/","sources":["modules/limited-time-offer/notification/limited-time-offer-notification.constants.ts"],"names":[],"mappings":";;;AAAA,4DAA0E;AAE7D,QAAA,gBAAgB,GAAG;IAC5B,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;CACd,CAAC;AAME,QAAA,oBAAoB,GAAG;IAChC,8BAAuB,CAAC,IAAI;IAC5B,8BAAuB,CAAC,YAAY;CAC9B,CAAC;AAEX,MAAM,yBAAyB,GAAG,oBAAoB,CAAC;AAE1C,QAAA,aAAa,GAAG;IACzB,kBAAkB,EAAE;QAChB,KAAK,EAAE,mCAAmC;QAC1C,IAAI,EAAE,mEAAmE;QACzE,KAAK,EAAE,yBAAyB;KACnC;IACD,kBAAkB,EAAE;QAChB,KAAK,EAAE,6BAA6B;QACpC,IAAI,EAAE,yDAAyD;QAC/D,KAAK,EAAE,yBAAyB;KACnC;CACK,CAAC","sourcesContent":["import {NotificationAccountType} from \"@lyxa.ai/core/dist/utilities/enum\";\n\nexport const NotificationType = {\n Cancel: \"cancel\",\n Activate: \"activate\",\n} as const;\n\nexport type NotificationType =\n (typeof NotificationType)[keyof typeof NotificationType];\n\n\nexport const TARGET_ACCOUNT_TYPES = [\n NotificationAccountType.SHOP,\n NotificationAccountType.SHOP_CONSOLE,\n] as const;\n\nconst CUSTOM_NOTIFICATION_SOUND = 'notification_sound';\n\nexport const NOTIFICATIONS = {\n CAMPAIGN_CANCELLED: {\n title: \"Lyxa deleted the current campaign\",\n body: \"The ongoing limited time offer campaign has been deleted by
|
|
1
|
+
{"version":3,"file":"limited-time-offer-notification.constants.js","sourceRoot":"/","sources":["modules/limited-time-offer/notification/limited-time-offer-notification.constants.ts"],"names":[],"mappings":";;;AAAA,4DAA0E;AAE7D,QAAA,gBAAgB,GAAG;IAC5B,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;CACd,CAAC;AAME,QAAA,oBAAoB,GAAG;IAChC,8BAAuB,CAAC,IAAI;IAC5B,8BAAuB,CAAC,YAAY;CAC9B,CAAC;AAEX,MAAM,yBAAyB,GAAG,oBAAoB,CAAC;AAE1C,QAAA,aAAa,GAAG;IACzB,kBAAkB,EAAE;QAChB,KAAK,EAAE,mCAAmC;QAC1C,IAAI,EAAE,mEAAmE;QACzE,KAAK,EAAE,yBAAyB;KACnC;IACD,kBAAkB,EAAE;QAChB,KAAK,EAAE,6BAA6B;QACpC,IAAI,EAAE,yDAAyD;QAC/D,KAAK,EAAE,yBAAyB;KACnC;CACK,CAAC","sourcesContent":["import {NotificationAccountType} from \"@lyxa.ai/core/dist/utilities/enum\";\n\nexport const NotificationType = {\n Cancel: \"cancel\",\n Activate: \"activate\",\n} as const;\n\nexport type NotificationType =\n (typeof NotificationType)[keyof typeof NotificationType];\n\n\nexport const TARGET_ACCOUNT_TYPES = [\n NotificationAccountType.SHOP,\n NotificationAccountType.SHOP_CONSOLE,\n] as const;\n\nconst CUSTOM_NOTIFICATION_SOUND = 'notification_sound';\n\nexport const NOTIFICATIONS = {\n CAMPAIGN_CANCELLED: {\n title: \"Lyxa deleted the current campaign\",\n body: \"The ongoing limited time offer campaign has been deleted by lyxa.\",\n sound: CUSTOM_NOTIFICATION_SOUND\n },\n CAMPAIGN_ACTIVATED: {\n title: \"Limited Time Offer is Live!\",\n body: \"A new limited time offer has started. Check it out now!\",\n sound: CUSTOM_NOTIFICATION_SOUND\n },\n} as const;"]}
|
package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mongoose } from '@typegoose/typegoose';
|
|
2
|
-
import { LimitedTimeOfferCampaign
|
|
3
|
-
import {
|
|
2
|
+
import { LimitedTimeOfferCampaign } from '@lyxa.ai/core/dist/libraries/mongo/models';
|
|
3
|
+
import { MarketingStatus, MarketingType, ValueType } from '@lyxa.ai/core/dist/utilities/enum';
|
|
4
4
|
import { GetLtoCampaignParticipantsDTO } from '../campaign/limited-time-offer-campaign.validation';
|
|
5
5
|
import { JoinLtoCampaignDTO } from './limited-time-offer-participant.validation';
|
|
6
6
|
export declare class LtoParticipantQueryBuilder {
|
|
@@ -9,15 +9,7 @@ export declare class LtoParticipantQueryBuilder {
|
|
|
9
9
|
isWithdrawn: boolean;
|
|
10
10
|
};
|
|
11
11
|
static buildSearchTerm(dto: GetLtoCampaignParticipantsDTO): string | undefined;
|
|
12
|
-
static buildCreateInput(
|
|
13
|
-
campaignId: mongoose.Types.ObjectId;
|
|
14
|
-
shopId: mongoose.Types.ObjectId;
|
|
15
|
-
marketingId: mongoose.Types.ObjectId;
|
|
16
|
-
dto: JoinLtoCampaignDTO;
|
|
17
|
-
pausedMarketings?: mongoose.Types.ObjectId[];
|
|
18
|
-
pausedOrderCapacity?: number;
|
|
19
|
-
pausedOrderCapacityEnabled?: boolean;
|
|
20
|
-
}): {
|
|
12
|
+
static buildCreateInput(campaignId: mongoose.Types.ObjectId, shopId: mongoose.Types.ObjectId, marketingId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO): {
|
|
21
13
|
campaign: mongoose.Types.ObjectId;
|
|
22
14
|
shop: mongoose.Types.ObjectId;
|
|
23
15
|
marketing: mongoose.Types.ObjectId;
|
|
@@ -28,32 +20,13 @@ export declare class LtoParticipantQueryBuilder {
|
|
|
28
20
|
maxDiscountCap: number;
|
|
29
21
|
isOrderCapacityEnabled: boolean;
|
|
30
22
|
maxOrderCapacity: number | undefined;
|
|
31
|
-
pausedOrderCapacity: number | undefined;
|
|
32
|
-
pausedOrderCapacityEnabled: boolean | undefined;
|
|
33
23
|
isWithdrawn: boolean;
|
|
34
|
-
pausedMarketings: mongoose.Types.ObjectId[];
|
|
35
|
-
};
|
|
36
|
-
static buildCloneInput(campaignId: mongoose.Types.ObjectId, source: Pick<LimitedTimeOfferParticipant, 'shop' | 'products' | 'isEntireMenu' | 'discountPercentage' | 'maxDiscountCap' | 'isOrderCapacityEnabled' | 'maxOrderCapacity' | 'pausedOrderCapacity' | 'pausedOrderCapacityEnabled'>): {
|
|
37
|
-
campaign: mongoose.Types.ObjectId;
|
|
38
|
-
shop: import("@typegoose/typegoose").Ref<import("@lyxa.ai/core/dist/libraries/mongo/models").Shop>;
|
|
39
|
-
joinedAt: Date;
|
|
40
|
-
products: import("@typegoose/typegoose").Ref<import("@lyxa.ai/core/dist/libraries/mongo/models").Product>[];
|
|
41
|
-
isEntireMenu: boolean;
|
|
42
|
-
discountPercentage: number | undefined;
|
|
43
|
-
maxDiscountCap: number | undefined;
|
|
44
|
-
isOrderCapacityEnabled: boolean;
|
|
45
|
-
maxOrderCapacity: number | undefined;
|
|
46
|
-
pausedOrderCapacity: number | undefined;
|
|
47
|
-
pausedOrderCapacityEnabled: boolean | undefined;
|
|
48
|
-
isWithdrawn: boolean;
|
|
49
|
-
pausedMarketings: never[];
|
|
50
24
|
};
|
|
51
25
|
static buildMarketingInput(shopId: mongoose.Types.ObjectId, campaign: LimitedTimeOfferCampaign & {
|
|
52
26
|
_id: mongoose.Types.ObjectId;
|
|
53
27
|
}, dto: JoinLtoCampaignDTO): {
|
|
54
28
|
shop: mongoose.Types.ObjectId;
|
|
55
29
|
marketingType: MarketingType;
|
|
56
|
-
campaignType: MarketingCampaignType;
|
|
57
30
|
isAppliedByCompany: boolean;
|
|
58
31
|
duration: {
|
|
59
32
|
start: Date;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limited-time-offer-participant.builder.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,wBAAwB,
|
|
1
|
+
{"version":3,"file":"limited-time-offer-participant.builder.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,wBAAwB,EAAC,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAC,eAAe,EAAE,aAAa,EAAE,SAAS,EAAC,MAAM,mCAAmC,CAAC;AAC5F,OAAO,EAAC,6BAA6B,EAAC,MAAM,oDAAoD,CAAC;AACjG,OAAO,EAAC,kBAAkB,EAAC,MAAM,6CAA6C,CAAC;AAE/E,qBAAa,0BAA0B;IACnC,MAAM,CAAC,mBAAmB,CAAC,GAAG,EAAE,6BAA6B;;;;IAI7D,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,6BAA6B,GAAG,MAAM,GAAG,SAAS;IAI9E,MAAM,CAAC,gBAAgB,CACnB,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACnC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACpC,GAAG,EAAE,kBAAkB;;;;;;;;;;;;;IAiB3B,MAAM,CAAC,mBAAmB,CACtB,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,QAAQ,EAAE,wBAAwB,GAAG;QAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAA;KAAC,EACnE,GAAG,EAAE,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;CA2B9B"}
|