@lyxa.ai/marketing 1.0.53 → 1.0.55
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 +679 -28
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +2 -2
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts +651 -0
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.js +8 -1
- package/dist/lib/modules/coupon/routers/coupon.router.js.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts +8 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.js +234 -27
- package/dist/lib/modules/coupon/services/coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/custom-coupon.service.d.ts +5 -0
- package/dist/lib/modules/coupon/services/custom-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/helper.service.d.ts +5 -0
- package/dist/lib/modules/coupon/services/helper.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/individual-store-coupon.service.d.ts +5 -0
- package/dist/lib/modules/coupon/services/individual-store-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts +1 -0
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js +27 -9
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js.map +1 -1
- package/dist/lib/modules/coupon/services/shops-categories-coupon.service.d.ts +5 -0
- package/dist/lib/modules/coupon/services/shops-categories-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts +293 -1125
- package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/all-coupons.validation.js +2 -16
- package/dist/lib/modules/coupon/validations/all-coupons.validation.js.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts +44 -0
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.js +16 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.js.map +1 -1
- package/dist/lib/modules/coupon/validations/create-coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/create-coupon.validation.js +4 -1
- package/dist/lib/modules/coupon/validations/create-coupon.validation.js.map +1 -1
- package/dist/lib/modules/coupon/validations/index.d.ts +1 -0
- package/dist/lib/modules/coupon/validations/index.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/index.js +1 -0
- package/dist/lib/modules/coupon/validations/index.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts +8 -8
- package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +34 -34
- package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.validation.d.ts +9 -1
- package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.validation.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.validation.js +26 -3
- package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.validation.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts +28 -28
- package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts +1 -0
- package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js +6 -0
- 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.builder.d.ts +13 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.builder.d.ts.map +1 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.builder.js +22 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.builder.js.map +1 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts +20 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts.map +1 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.js +26 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.js.map +1 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.service.d.ts +8 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.service.d.ts.map +1 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.service.js +60 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.service.js.map +1 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.type.d.ts +5 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.type.d.ts.map +1 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.type.js +3 -0
- package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.type.js.map +1 -0
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.js +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +1 -0
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js +8 -1
- 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 +20 -20
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +82 -82
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +2 -1
- 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 +12 -5
- 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 +1 -0
- package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/marketing.service.js +9 -0
- package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -1
- package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js +1 -1
- package/dist/lib/modules/tournament/match/events/evaluate-predictions.consumer.js.map +1 -1
- package/dist/lib/modules/tournament/notification/__tests__/notification.service.spec.d.ts +2 -0
- package/dist/lib/modules/tournament/notification/__tests__/notification.service.spec.d.ts.map +1 -0
- package/dist/lib/modules/tournament/notification/__tests__/notification.service.spec.js +266 -0
- package/dist/lib/modules/tournament/notification/__tests__/notification.service.spec.js.map +1 -0
- package/dist/lib/modules/tournament/notification/notification.service.d.ts +14 -3
- package/dist/lib/modules/tournament/notification/notification.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/notification/notification.service.js +89 -31
- package/dist/lib/modules/tournament/notification/notification.service.js.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.repository.d.ts +1 -0
- package/dist/lib/modules/tournament/participant/participant.repository.d.ts.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.repository.js +9 -0
- package/dist/lib/modules/tournament/participant/participant.repository.js.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.service.d.ts +1 -0
- package/dist/lib/modules/tournament/participant/participant.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/participant/participant.service.js +6 -0
- package/dist/lib/modules/tournament/participant/participant.service.js.map +1 -1
- package/dist/lib/modules/tournament/reward/reward.builder.d.ts.map +1 -1
- package/dist/lib/modules/tournament/reward/reward.builder.js +3 -3
- package/dist/lib/modules/tournament/reward/reward.builder.js.map +1 -1
- package/dist/lib/modules/tournament/reward/reward.types.d.ts +1 -0
- package/dist/lib/modules/tournament/reward/reward.types.d.ts.map +1 -1
- package/dist/lib/modules/tournament/reward/reward.types.js.map +1 -1
- package/dist/lib/modules/tournament/schedule/schedule.service.d.ts +7 -0
- package/dist/lib/modules/tournament/schedule/schedule.service.d.ts.map +1 -1
- package/dist/lib/modules/tournament/schedule/schedule.service.js +52 -19
- package/dist/lib/modules/tournament/schedule/schedule.service.js.map +1 -1
- package/dist/lib/utility/utils.js +2 -2
- package/dist/lib/utility/utils.js.map +1 -1
- package/dist/types/index.d.ts +679 -28
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/coupon/routers/coupon.router.d.ts +651 -0
- package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/coupon.service.d.ts +8 -1
- package/dist/types/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/custom-coupon.service.d.ts +5 -0
- package/dist/types/modules/coupon/services/custom-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/helper.service.d.ts +5 -0
- package/dist/types/modules/coupon/services/helper.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/individual-store-coupon.service.d.ts +5 -0
- package/dist/types/modules/coupon/services/individual-store-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts +1 -0
- package/dist/types/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/shops-categories-coupon.service.d.ts +5 -0
- package/dist/types/modules/coupon/services/shops-categories-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts +293 -1125
- package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts +44 -0
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/create-coupon.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/index.d.ts +1 -0
- package/dist/types/modules/coupon/validations/index.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts +8 -8
- package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +34 -34
- package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.validation.d.ts +9 -1
- package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.validation.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts +28 -28
- package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts +1 -0
- package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.builder.d.ts +13 -0
- package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.builder.d.ts.map +1 -0
- package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts +20 -0
- package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts.map +1 -0
- package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.service.d.ts +8 -0
- package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.service.d.ts.map +1 -0
- package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.type.d.ts +5 -0
- package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.type.d.ts.map +1 -0
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +1 -0
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +20 -20
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +82 -82
- package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +2 -1
- 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 +1 -0
- package/dist/types/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/notification/notification.service.d.ts +14 -3
- package/dist/types/modules/tournament/notification/notification.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/participant/participant.repository.d.ts +1 -0
- package/dist/types/modules/tournament/participant/participant.repository.d.ts.map +1 -1
- package/dist/types/modules/tournament/participant/participant.service.d.ts +1 -0
- package/dist/types/modules/tournament/participant/participant.service.d.ts.map +1 -1
- package/dist/types/modules/tournament/reward/reward.builder.d.ts.map +1 -1
- package/dist/types/modules/tournament/reward/reward.types.d.ts +1 -0
- package/dist/types/modules/tournament/reward/reward.types.d.ts.map +1 -1
- package/dist/types/modules/tournament/schedule/schedule.service.d.ts +7 -0
- package/dist/types/modules/tournament/schedule/schedule.service.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -203,16 +203,6 @@ export declare const ParticipantStatusSchema: z.ZodObject<{
|
|
|
203
203
|
}>>;
|
|
204
204
|
}, "strip", z.ZodTypeAny, {
|
|
205
205
|
campaignState: LtoCardState;
|
|
206
|
-
participant?: {
|
|
207
|
-
isEntireMenu: boolean;
|
|
208
|
-
joinedAt: Date;
|
|
209
|
-
productIds: import("mongoose").Types.ObjectId[];
|
|
210
|
-
isOrderCapacityEnabled: boolean;
|
|
211
|
-
marketingId?: import("mongoose").Types.ObjectId | undefined;
|
|
212
|
-
discountPercentage?: number | undefined;
|
|
213
|
-
maxDiscountCap?: number | undefined;
|
|
214
|
-
maxOrderCapacity?: number | undefined;
|
|
215
|
-
} | undefined;
|
|
216
206
|
campaign?: {
|
|
217
207
|
_id: import("mongoose").Types.ObjectId;
|
|
218
208
|
discountOptions: number[];
|
|
@@ -222,18 +212,18 @@ export declare const ParticipantStatusSchema: z.ZodObject<{
|
|
|
222
212
|
title?: string | undefined;
|
|
223
213
|
subTitle?: string | undefined;
|
|
224
214
|
} | undefined;
|
|
225
|
-
}, {
|
|
226
|
-
campaignState: LtoCardState;
|
|
227
215
|
participant?: {
|
|
228
216
|
isEntireMenu: boolean;
|
|
229
217
|
joinedAt: Date;
|
|
218
|
+
productIds: import("mongoose").Types.ObjectId[];
|
|
230
219
|
isOrderCapacityEnabled: boolean;
|
|
231
|
-
|
|
232
|
-
marketingId?: string | import("mongoose").Types.ObjectId | undefined;
|
|
220
|
+
marketingId?: import("mongoose").Types.ObjectId | undefined;
|
|
233
221
|
discountPercentage?: number | undefined;
|
|
234
222
|
maxDiscountCap?: number | undefined;
|
|
235
223
|
maxOrderCapacity?: number | undefined;
|
|
236
224
|
} | undefined;
|
|
225
|
+
}, {
|
|
226
|
+
campaignState: LtoCardState;
|
|
237
227
|
campaign?: {
|
|
238
228
|
_id: string | import("mongoose").Types.ObjectId;
|
|
239
229
|
startDate?: Date | null | undefined;
|
|
@@ -243,6 +233,16 @@ export declare const ParticipantStatusSchema: z.ZodObject<{
|
|
|
243
233
|
discountOptions?: number[] | undefined;
|
|
244
234
|
maxDiscountCaps?: number[] | undefined;
|
|
245
235
|
} | undefined;
|
|
236
|
+
participant?: {
|
|
237
|
+
isEntireMenu: boolean;
|
|
238
|
+
joinedAt: Date;
|
|
239
|
+
isOrderCapacityEnabled: boolean;
|
|
240
|
+
productIds?: (string | import("mongoose").Types.ObjectId)[] | undefined;
|
|
241
|
+
marketingId?: string | import("mongoose").Types.ObjectId | undefined;
|
|
242
|
+
discountPercentage?: number | undefined;
|
|
243
|
+
maxDiscountCap?: number | undefined;
|
|
244
|
+
maxOrderCapacity?: number | undefined;
|
|
245
|
+
} | undefined;
|
|
246
246
|
}>;
|
|
247
247
|
export declare const ParticipantResponseSchema: z.ZodObject<{
|
|
248
248
|
success: z.ZodBoolean;
|
|
@@ -479,6 +479,15 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
|
|
|
479
479
|
}>>;
|
|
480
480
|
documents: z.ZodArray<z.ZodType<{
|
|
481
481
|
campaignState: LtoCardState;
|
|
482
|
+
campaign?: {
|
|
483
|
+
_id: string | import("mongoose").Types.ObjectId;
|
|
484
|
+
startDate?: Date | null | undefined;
|
|
485
|
+
endDate?: Date | null | undefined;
|
|
486
|
+
title?: string | undefined;
|
|
487
|
+
subTitle?: string | undefined;
|
|
488
|
+
discountOptions?: number[] | undefined;
|
|
489
|
+
maxDiscountCaps?: number[] | undefined;
|
|
490
|
+
} | undefined;
|
|
482
491
|
participant?: {
|
|
483
492
|
isEntireMenu: boolean;
|
|
484
493
|
joinedAt: Date;
|
|
@@ -489,6 +498,8 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
|
|
|
489
498
|
maxDiscountCap?: number | undefined;
|
|
490
499
|
maxOrderCapacity?: number | undefined;
|
|
491
500
|
} | undefined;
|
|
501
|
+
}, z.ZodTypeDef, {
|
|
502
|
+
campaignState: LtoCardState;
|
|
492
503
|
campaign?: {
|
|
493
504
|
_id: string | import("mongoose").Types.ObjectId;
|
|
494
505
|
startDate?: Date | null | undefined;
|
|
@@ -498,8 +509,6 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
|
|
|
498
509
|
discountOptions?: number[] | undefined;
|
|
499
510
|
maxDiscountCaps?: number[] | undefined;
|
|
500
511
|
} | undefined;
|
|
501
|
-
}, z.ZodTypeDef, {
|
|
502
|
-
campaignState: LtoCardState;
|
|
503
512
|
participant?: {
|
|
504
513
|
isEntireMenu: boolean;
|
|
505
514
|
joinedAt: Date;
|
|
@@ -510,6 +519,10 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
|
|
|
510
519
|
maxDiscountCap?: number | undefined;
|
|
511
520
|
maxOrderCapacity?: number | undefined;
|
|
512
521
|
} | undefined;
|
|
522
|
+
}>, "many">;
|
|
523
|
+
}, "strip", z.ZodTypeAny, {
|
|
524
|
+
documents: {
|
|
525
|
+
campaignState: LtoCardState;
|
|
513
526
|
campaign?: {
|
|
514
527
|
_id: string | import("mongoose").Types.ObjectId;
|
|
515
528
|
startDate?: Date | null | undefined;
|
|
@@ -519,10 +532,6 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
|
|
|
519
532
|
discountOptions?: number[] | undefined;
|
|
520
533
|
maxDiscountCaps?: number[] | undefined;
|
|
521
534
|
} | undefined;
|
|
522
|
-
}>, "many">;
|
|
523
|
-
}, "strip", z.ZodTypeAny, {
|
|
524
|
-
documents: {
|
|
525
|
-
campaignState: LtoCardState;
|
|
526
535
|
participant?: {
|
|
527
536
|
isEntireMenu: boolean;
|
|
528
537
|
joinedAt: Date;
|
|
@@ -533,15 +542,6 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
|
|
|
533
542
|
maxDiscountCap?: number | undefined;
|
|
534
543
|
maxOrderCapacity?: number | undefined;
|
|
535
544
|
} | undefined;
|
|
536
|
-
campaign?: {
|
|
537
|
-
_id: string | import("mongoose").Types.ObjectId;
|
|
538
|
-
startDate?: Date | null | undefined;
|
|
539
|
-
endDate?: Date | null | undefined;
|
|
540
|
-
title?: string | undefined;
|
|
541
|
-
subTitle?: string | undefined;
|
|
542
|
-
discountOptions?: number[] | undefined;
|
|
543
|
-
maxDiscountCaps?: number[] | undefined;
|
|
544
|
-
} | undefined;
|
|
545
545
|
}[];
|
|
546
546
|
metadata?: {
|
|
547
547
|
page: number;
|
|
@@ -552,6 +552,15 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
|
|
|
552
552
|
}, {
|
|
553
553
|
documents: {
|
|
554
554
|
campaignState: LtoCardState;
|
|
555
|
+
campaign?: {
|
|
556
|
+
_id: string | import("mongoose").Types.ObjectId;
|
|
557
|
+
startDate?: Date | null | undefined;
|
|
558
|
+
endDate?: Date | null | undefined;
|
|
559
|
+
title?: string | undefined;
|
|
560
|
+
subTitle?: string | undefined;
|
|
561
|
+
discountOptions?: number[] | undefined;
|
|
562
|
+
maxDiscountCaps?: number[] | undefined;
|
|
563
|
+
} | undefined;
|
|
555
564
|
participant?: {
|
|
556
565
|
isEntireMenu: boolean;
|
|
557
566
|
joinedAt: Date;
|
|
@@ -562,15 +571,6 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
|
|
|
562
571
|
maxDiscountCap?: number | undefined;
|
|
563
572
|
maxOrderCapacity?: number | undefined;
|
|
564
573
|
} | undefined;
|
|
565
|
-
campaign?: {
|
|
566
|
-
_id: string | import("mongoose").Types.ObjectId;
|
|
567
|
-
startDate?: Date | null | undefined;
|
|
568
|
-
endDate?: Date | null | undefined;
|
|
569
|
-
title?: string | undefined;
|
|
570
|
-
subTitle?: string | undefined;
|
|
571
|
-
discountOptions?: number[] | undefined;
|
|
572
|
-
maxDiscountCaps?: number[] | undefined;
|
|
573
|
-
} | undefined;
|
|
574
574
|
}[];
|
|
575
575
|
metadata?: {
|
|
576
576
|
page: number;
|
|
@@ -580,6 +580,15 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
|
|
|
580
580
|
} | undefined;
|
|
581
581
|
}>, z.ZodType<{
|
|
582
582
|
campaignState: LtoCardState;
|
|
583
|
+
campaign?: {
|
|
584
|
+
_id: string | import("mongoose").Types.ObjectId;
|
|
585
|
+
startDate?: Date | null | undefined;
|
|
586
|
+
endDate?: Date | null | undefined;
|
|
587
|
+
title?: string | undefined;
|
|
588
|
+
subTitle?: string | undefined;
|
|
589
|
+
discountOptions?: number[] | undefined;
|
|
590
|
+
maxDiscountCaps?: number[] | undefined;
|
|
591
|
+
} | undefined;
|
|
583
592
|
participant?: {
|
|
584
593
|
isEntireMenu: boolean;
|
|
585
594
|
joinedAt: Date;
|
|
@@ -590,6 +599,8 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
|
|
|
590
599
|
maxDiscountCap?: number | undefined;
|
|
591
600
|
maxOrderCapacity?: number | undefined;
|
|
592
601
|
} | undefined;
|
|
602
|
+
}, z.ZodTypeDef, {
|
|
603
|
+
campaignState: LtoCardState;
|
|
593
604
|
campaign?: {
|
|
594
605
|
_id: string | import("mongoose").Types.ObjectId;
|
|
595
606
|
startDate?: Date | null | undefined;
|
|
@@ -599,8 +610,6 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
|
|
|
599
610
|
discountOptions?: number[] | undefined;
|
|
600
611
|
maxDiscountCaps?: number[] | undefined;
|
|
601
612
|
} | undefined;
|
|
602
|
-
}, z.ZodTypeDef, {
|
|
603
|
-
campaignState: LtoCardState;
|
|
604
613
|
participant?: {
|
|
605
614
|
isEntireMenu: boolean;
|
|
606
615
|
joinedAt: Date;
|
|
@@ -611,6 +620,12 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
|
|
|
611
620
|
maxDiscountCap?: number | undefined;
|
|
612
621
|
maxOrderCapacity?: number | undefined;
|
|
613
622
|
} | undefined;
|
|
623
|
+
}>]>>;
|
|
624
|
+
}, "strip", z.ZodTypeAny, {
|
|
625
|
+
message: string;
|
|
626
|
+
success: boolean;
|
|
627
|
+
data?: {
|
|
628
|
+
campaignState: LtoCardState;
|
|
614
629
|
campaign?: {
|
|
615
630
|
_id: string | import("mongoose").Types.ObjectId;
|
|
616
631
|
startDate?: Date | null | undefined;
|
|
@@ -620,12 +635,6 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
|
|
|
620
635
|
discountOptions?: number[] | undefined;
|
|
621
636
|
maxDiscountCaps?: number[] | undefined;
|
|
622
637
|
} | undefined;
|
|
623
|
-
}>]>>;
|
|
624
|
-
}, "strip", z.ZodTypeAny, {
|
|
625
|
-
message: string;
|
|
626
|
-
success: boolean;
|
|
627
|
-
data?: {
|
|
628
|
-
campaignState: LtoCardState;
|
|
629
638
|
participant?: {
|
|
630
639
|
isEntireMenu: boolean;
|
|
631
640
|
joinedAt: Date;
|
|
@@ -636,18 +645,18 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
|
|
|
636
645
|
maxDiscountCap?: number | undefined;
|
|
637
646
|
maxOrderCapacity?: number | undefined;
|
|
638
647
|
} | undefined;
|
|
639
|
-
campaign?: {
|
|
640
|
-
_id: string | import("mongoose").Types.ObjectId;
|
|
641
|
-
startDate?: Date | null | undefined;
|
|
642
|
-
endDate?: Date | null | undefined;
|
|
643
|
-
title?: string | undefined;
|
|
644
|
-
subTitle?: string | undefined;
|
|
645
|
-
discountOptions?: number[] | undefined;
|
|
646
|
-
maxDiscountCaps?: number[] | undefined;
|
|
647
|
-
} | undefined;
|
|
648
648
|
} | {
|
|
649
649
|
documents: {
|
|
650
650
|
campaignState: LtoCardState;
|
|
651
|
+
campaign?: {
|
|
652
|
+
_id: string | import("mongoose").Types.ObjectId;
|
|
653
|
+
startDate?: Date | null | undefined;
|
|
654
|
+
endDate?: Date | null | undefined;
|
|
655
|
+
title?: string | undefined;
|
|
656
|
+
subTitle?: string | undefined;
|
|
657
|
+
discountOptions?: number[] | undefined;
|
|
658
|
+
maxDiscountCaps?: number[] | undefined;
|
|
659
|
+
} | undefined;
|
|
651
660
|
participant?: {
|
|
652
661
|
isEntireMenu: boolean;
|
|
653
662
|
joinedAt: Date;
|
|
@@ -658,15 +667,6 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
|
|
|
658
667
|
maxDiscountCap?: number | undefined;
|
|
659
668
|
maxOrderCapacity?: number | undefined;
|
|
660
669
|
} | undefined;
|
|
661
|
-
campaign?: {
|
|
662
|
-
_id: string | import("mongoose").Types.ObjectId;
|
|
663
|
-
startDate?: Date | null | undefined;
|
|
664
|
-
endDate?: Date | null | undefined;
|
|
665
|
-
title?: string | undefined;
|
|
666
|
-
subTitle?: string | undefined;
|
|
667
|
-
discountOptions?: number[] | undefined;
|
|
668
|
-
maxDiscountCaps?: number[] | undefined;
|
|
669
|
-
} | undefined;
|
|
670
670
|
}[];
|
|
671
671
|
metadata?: {
|
|
672
672
|
page: number;
|
|
@@ -680,6 +680,15 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
|
|
|
680
680
|
success: boolean;
|
|
681
681
|
data?: {
|
|
682
682
|
campaignState: LtoCardState;
|
|
683
|
+
campaign?: {
|
|
684
|
+
_id: string | import("mongoose").Types.ObjectId;
|
|
685
|
+
startDate?: Date | null | undefined;
|
|
686
|
+
endDate?: Date | null | undefined;
|
|
687
|
+
title?: string | undefined;
|
|
688
|
+
subTitle?: string | undefined;
|
|
689
|
+
discountOptions?: number[] | undefined;
|
|
690
|
+
maxDiscountCaps?: number[] | undefined;
|
|
691
|
+
} | undefined;
|
|
683
692
|
participant?: {
|
|
684
693
|
isEntireMenu: boolean;
|
|
685
694
|
joinedAt: Date;
|
|
@@ -690,18 +699,18 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
|
|
|
690
699
|
maxDiscountCap?: number | undefined;
|
|
691
700
|
maxOrderCapacity?: number | undefined;
|
|
692
701
|
} | undefined;
|
|
693
|
-
campaign?: {
|
|
694
|
-
_id: string | import("mongoose").Types.ObjectId;
|
|
695
|
-
startDate?: Date | null | undefined;
|
|
696
|
-
endDate?: Date | null | undefined;
|
|
697
|
-
title?: string | undefined;
|
|
698
|
-
subTitle?: string | undefined;
|
|
699
|
-
discountOptions?: number[] | undefined;
|
|
700
|
-
maxDiscountCaps?: number[] | undefined;
|
|
701
|
-
} | undefined;
|
|
702
702
|
} | {
|
|
703
703
|
documents: {
|
|
704
704
|
campaignState: LtoCardState;
|
|
705
|
+
campaign?: {
|
|
706
|
+
_id: string | import("mongoose").Types.ObjectId;
|
|
707
|
+
startDate?: Date | null | undefined;
|
|
708
|
+
endDate?: Date | null | undefined;
|
|
709
|
+
title?: string | undefined;
|
|
710
|
+
subTitle?: string | undefined;
|
|
711
|
+
discountOptions?: number[] | undefined;
|
|
712
|
+
maxDiscountCaps?: number[] | undefined;
|
|
713
|
+
} | undefined;
|
|
705
714
|
participant?: {
|
|
706
715
|
isEntireMenu: boolean;
|
|
707
716
|
joinedAt: Date;
|
|
@@ -712,15 +721,6 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
|
|
|
712
721
|
maxDiscountCap?: number | undefined;
|
|
713
722
|
maxOrderCapacity?: number | undefined;
|
|
714
723
|
} | undefined;
|
|
715
|
-
campaign?: {
|
|
716
|
-
_id: string | import("mongoose").Types.ObjectId;
|
|
717
|
-
startDate?: Date | null | undefined;
|
|
718
|
-
endDate?: Date | null | undefined;
|
|
719
|
-
title?: string | undefined;
|
|
720
|
-
subTitle?: string | undefined;
|
|
721
|
-
discountOptions?: number[] | undefined;
|
|
722
|
-
maxDiscountCaps?: number[] | undefined;
|
|
723
|
-
} | undefined;
|
|
724
724
|
}[];
|
|
725
725
|
metadata?: {
|
|
726
726
|
page: number;
|
|
@@ -15,9 +15,9 @@ export declare class LimitedTimeOfferParticipantService {
|
|
|
15
15
|
shopId: mongoose.Types.ObjectId;
|
|
16
16
|
joinedAt: Date;
|
|
17
17
|
shopName: string | null;
|
|
18
|
-
shopPhoto?: string | null | undefined;
|
|
19
18
|
discountPercentage?: number | undefined;
|
|
20
19
|
maxDiscountCap?: number | undefined;
|
|
20
|
+
shopPhoto?: string | null | undefined;
|
|
21
21
|
}[];
|
|
22
22
|
metadata: {
|
|
23
23
|
page: number;
|
|
@@ -26,6 +26,7 @@ export declare class LimitedTimeOfferParticipantService {
|
|
|
26
26
|
totalPages: number;
|
|
27
27
|
};
|
|
28
28
|
}>;
|
|
29
|
+
getParticipantIdsByCampaignId(campaignId: mongoose.Types.ObjectId): Promise<mongoose.Types.ObjectId[]>;
|
|
29
30
|
getNearby(campaignId: mongoose.Types.ObjectId, input: {
|
|
30
31
|
latitude: number;
|
|
31
32
|
longitude: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limited-time-offer-participant.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant.service.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"limited-time-offer-participant.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,sBAAsB,CAA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
97
|
}
|
|
98
98
|
async update(shopId, dto) {
|
|
99
99
|
const campaign = await this.fetchCurrentCampaignOrThrow();
|
|
100
|
-
const participant = await this.repository.
|
|
100
|
+
const participant = await this.repository.findActiveByCampaignAndShop(campaign._id, shopId);
|
|
101
101
|
if (!participant)
|
|
102
102
|
throw (0, error_common_1.notFoundError)('You have not joined this campaign.');
|
|
103
|
-
this.validateDiscountSelections(campaign, dto.discountPercentage, dto.maxDiscountCap);
|
|
103
|
+
this.validateDiscountSelections(campaign, dto.discountPercentage, dto.maxDiscountCap, participant);
|
|
104
104
|
await this.assertProductsBelongToShop(shopId, dto);
|
|
105
105
|
const resolvedDto = await this.resolveCategorySelection(shopId, dto);
|
|
106
106
|
const newMarketingId = participant.marketingId
|
|
@@ -128,6 +128,9 @@ let LimitedTimeOfferParticipantService = class LimitedTimeOfferParticipantServic
|
|
|
128
128
|
},
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
|
+
async getParticipantIdsByCampaignId(campaignId) {
|
|
132
|
+
return await this.repository.findParticipantIdsByCampaignId(campaignId);
|
|
133
|
+
}
|
|
131
134
|
async getNearby(campaignId, input) {
|
|
132
135
|
const settings = (await (0, core_1.getLibraries)().getCachedSettingsService().getSettings());
|
|
133
136
|
const nearByShopDistance = settings.nearByShopDistance || 10000;
|
|
@@ -172,12 +175,16 @@ let LimitedTimeOfferParticipantService = class LimitedTimeOfferParticipantServic
|
|
|
172
175
|
uniqueObjectIds(ids) {
|
|
173
176
|
return [...new Map(ids.map(id => [id.toString(), id])).values()];
|
|
174
177
|
}
|
|
175
|
-
validateDiscountSelections(campaign, discountPercentage, maxDiscountCap) {
|
|
178
|
+
validateDiscountSelections(campaign, discountPercentage, maxDiscountCap, participant) {
|
|
176
179
|
if (!campaign.discountOptions.includes(discountPercentage)) {
|
|
177
|
-
|
|
180
|
+
if (!participant || discountPercentage != participant.discountPercentage) {
|
|
181
|
+
throw (0, error_common_1.badRequestError)('Selected discount is not an available option for this campaign.');
|
|
182
|
+
}
|
|
178
183
|
}
|
|
179
184
|
if (!campaign.maxDiscountCaps.includes(maxDiscountCap)) {
|
|
180
|
-
|
|
185
|
+
if (!participant || maxDiscountCap != participant.maxDiscountCap) {
|
|
186
|
+
throw (0, error_common_1.badRequestError)('Selected max discount cap is not an available option for this campaign.');
|
|
187
|
+
}
|
|
181
188
|
}
|
|
182
189
|
}
|
|
183
190
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limited-time-offer-participant.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAG5C,4DAAmF;AACnF,4EAA0G;AAC1G,2IAAuH;AACvH,yHAAoG;AACpG,4GAIsD;AACtD,sGAAuF;AACvF,4GAAwF;AAExF,wCAA6C;AAGtC,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IACtC,UAAU,CAA2B;IACrC,eAAe,CAAqB;IACpC,gBAAgB,CAAiC;IAEzD;QACC,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,oEAAwB,CAAC,CAAC;QAC1D,IAAI,CAAC,eAAe,GAAG,gBAAS,CAAC,GAAG,CAAC,wDAAkB,CAAC,CAAC;QACzD,IAAI,CAAC,gBAAgB,GAAG,gBAAS,CAAC,GAAG,CAAC,iFAA8B,CAAC,CAAC;IACvE,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,MAA+B,EAAE,GAAuB;QACzE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,2BAA2B,EAAE,CAAC;QAE1D,MAAM,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACxD,IAAI,CAAC,0BAA0B,CAAC,QAAQ,EAAE,GAAG,CAAC,kBAAkB,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;QACtF,MAAM,IA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oose } from '@typegoose/typegoose';\nimport { LimitedTimeOfferCampaign, Setting } from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport { LimitedTimeOfferCampaignStatus } from '@lyxa.ai/core/dist/utilities/enum';\nimport { badRequestError, conflictError, notFoundError } from '@lyxa.ai/core/dist/utilities/error-common';\nimport { LtoCampaignService } from '@modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service';\nimport { LtoParticipantMarketingService } from './limited-time-offer-participant-marketing.service';\nimport {\n\tJoinLtoCampaignDTO,\n\tLtoCardState,\n\tParticipantStatusDTO,\n} from '../limited-time-offer-participant.validation';\nimport { LtoParticipantQueryBuilder } from '../limited-time-offer-participant.builder';\nimport { LtoParticipantRepository } from '../limited-time-offer-participant.repository';\nimport { GetLtoCampaignParticipantsDTO } from '../../campaign/limited-time-offer-campaign.validation';\nimport { getLibraries } from '@lyxa.ai/core';\n\n@Service()\nexport class LimitedTimeOfferParticipantService {\n\tprivate repository: LtoParticipantRepository;\n\tprivate campaignService: LtoCampaignService;\n\tprivate marketingService: LtoParticipantMarketingService;\n\n\tconstructor() {\n\t\tthis.repository = Container.get(LtoParticipantRepository);\n\t\tthis.campaignService = Container.get(LtoCampaignService);\n\t\tthis.marketingService = Container.get(LtoParticipantMarketingService);\n\t}\n\n\tpublic async join(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO) {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\n\t\tawait this.assertNotAlreadyJoined(campaign._id, shopId);\n\t\tthis.validateDiscountSelections(campaign, dto.discountPercentage, dto.maxDiscountCap);\n\t\tawait this.assertProductsBelongToShop(shopId, dto);\n\n\t\tconst resolvedDto = await this.resolveCategorySelection(shopId, dto);\n\t\tconst marketingId = await this.marketingService.applyMarketing(shopId, campaign, resolvedDto);\n\n\t\tconst participant = await this.repository.create(\n\t\t\tLtoParticipantQueryBuilder.buildCreateInput(campaign._id, shopId, marketingId, resolvedDto)\n\t\t);\n\t\t// Update shop\n\t\tawait this.repository.updateShopOrderCapacity(\n\t\t\tshopId,\n\t\t\tresolvedDto.isOrderCapacityEnabled,\n\t\t\tresolvedDto.maxOrderCapacity\n\t\t);\n\t\treturn participant;\n\t}\n\n\tpublic async withdraw(shopId: mongoose.Types.ObjectId): Promise<void> {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\n\t\tconst participant = await this.repository.withdraw(campaign._id, shopId);\n\t\tif (!participant) throw notFoundError('You have not joined this campaign.');\n\n\t\tif (participant.marketing) {\n\t\t\tawait this.marketingService.removeMarketing(participant.marketing as mongoose.Types.ObjectId);\n\t\t}\n\t}\n\n\tpublic async getStatus(shopId: mongoose.Types.ObjectId): Promise<ParticipantStatusDTO> {\n\t\tconst campaign = await this.campaignService.getCurrent();\n\n\t\tif (!campaign) return { campaignState: LtoCardState.NONE };\n\n\t\tconst participant = await this.repository.findActiveByCampaignAndShop(campaign._id, shopId);\n\n\t\tconst campaignState =\n\t\t\tcampaign.status === LimitedTimeOfferCampaignStatus.SCHEDULED\n\t\t\t\t? LtoCardState.SCHEDULED\n\t\t\t\t: campaign.status === LimitedTimeOfferCampaignStatus.ACTIVE\n\t\t\t\t\t? LtoCardState.LIVE\n\t\t\t\t\t: LtoCardState.NONE;\n\n\t\treturn participant\n\t\t\t? { campaignState, campaign: campaign as any, participant }\n\t\t\t: { campaignState, campaign: campaign as any };\n\t}\n\n\tpublic async update(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO) {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\n\t\tconst participant = await this.repository.findActiveForUpdate(campaign._id, shopId);\n\t\tif (!participant) throw notFoundError('You have not joined this campaign.');\n\n\t\tthis.validateDiscountSelections(campaign, dto.discountPercentage, dto.maxDiscountCap);\n\t\tawait this.assertProductsBelongToShop(shopId, dto);\n\n\t\tconst resolvedDto = await this.resolveCategorySelection(shopId, dto);\n\n\t\tconst newMarketingId = participant.marketingId\n\t\t\t? await this.marketingService.replaceMarketing(participant.marketingId, shopId, campaign, resolvedDto)\n\t\t\t: await this.marketingService.applyMarketing(shopId, campaign, resolvedDto);\n\n\t\treturn this.repository.updateParticipant(campaign._id, shopId, {\n\t\t\tproducts: resolvedDto.products ?? [],\n\t\t\tisEntireMenu: resolvedDto.isEntireMenu,\n\t\t\tdiscountPercentage: resolvedDto.discountPercentage,\n\t\t\tmaxDiscountCap: resolvedDto.maxDiscountCap,\n\t\t\tisOrderCapacityEnabled: resolvedDto.isOrderCapacityEnabled,\n\t\t\tmaxOrderCapacity: resolvedDto.maxOrderCapacity,\n\t\t\tmarketing: newMarketingId,\n\t\t});\n\t}\n\n\tpublic async getParticipants(dto: GetLtoCampaignParticipantsDTO) {\n\t\tconst { documents, total } = await this.repository.findByCampaign(dto);\n\t\treturn {\n\t\t\tdocuments,\n\t\t\tmetadata: {\n\t\t\t\tpage: dto.page,\n\t\t\t\tsize: dto.size,\n\t\t\t\ttotalElements: total,\n\t\t\t\ttotalPages: Math.ceil(total / dto.size),\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic async getNearby(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tinput: { latitude: number; longitude: number }\n\t) {\n\t\tconst settings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst nearByShopDistance = settings.nearByShopDistance || 10000;\n\t\treturn this.repository.findNearby(campaignId, input, nearByShopDistance);\n\t}\n\n\tpublic async removeCampaignMarketings(campaignId: mongoose.Types.ObjectId): Promise<void> {\n\t\tawait this.marketingService.removeAllCampaignMarketings(campaignId);\n\t}\n\n\tprivate async fetchCurrentCampaignOrThrow(): Promise<DocumentType<LimitedTimeOfferCampaign>> {\n\t\tconst campaign = await this.campaignService.getCurrent();\n\t\tif (!campaign) {\n\t\t\tthrow badRequestError('No campaign active or scheduled.');\n\t\t}\n\t\treturn campaign;\n\t}\n\n\tprivate async assertNotAlreadyJoined(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<void> {\n\t\tif (await this.repository.existsActiveByCampaignAndShop(campaignId, shopId)) {\n\t\t\tthrow conflictError('Your shop has already joined this campaign.');\n\t\t}\n\t}\n\n\t/**\n\t * Expands the selected shop categories into their product ids and merges them with any explicitly\n\t * selected products. The marketing layer only ever receives a flat product list, so category\n\t * selection is purely an LTO-side convenience that is resolved here before anything is persisted.\n\t */\n\tprivate async resolveCategorySelection(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdto: JoinLtoCampaignDTO\n\t): Promise<JoinLtoCampaignDTO> {\n\t\tif (dto.isEntireMenu || !dto.shopCategories?.length) return dto;\n\n\t\tconst categoryProductIds = await this.repository.findProductIdsByCategories(shopId, dto.shopCategories);\n\t\tconst products = this.uniqueObjectIds([...(dto.products ?? []), ...categoryProductIds]);\n\n\t\tif (products.length === 0) {\n\t\t\tthrow badRequestError('The selected categories do not contain any products.');\n\t\t}\n\n\t\treturn { ...dto, products };\n\t}\n\n\t/**\n\t * Validates that explicitly selected products belong to the shop. Categories are not checked here:\n\t * {@link resolveCategorySelection} fetches their products with a shop-scoped query, so any category\n\t * that does not belong to the shop simply contributes no products.\n\t */\n\tprivate async assertProductsBelongToShop(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdto: JoinLtoCampaignDTO\n\t): Promise<void> {\n\t\tif (dto.isEntireMenu) return;\n\n\t\tconst productIds = this.uniqueObjectIds(dto.products ?? []);\n\t\tif (!productIds.length) return;\n\n\t\tconst owned = await this.repository.countShopProducts(shopId, productIds);\n\t\tif (owned !== productIds.length) {\n\t\t\tthrow badRequestError('One or more selected products do not belong to your shop.');\n\t\t}\n\t}\n\n\tprivate uniqueObjectIds(ids: mongoose.Types.ObjectId[]): mongoose.Types.ObjectId[] {\n\t\treturn [...new Map(ids.map(id => [id.toString(), id])).values()];\n\t}\n\n\tprivate validateDiscountSelections(\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>,\n\t\tdiscountPercentage: number,\n\t\tmaxDiscountCap: number\n\t): void {\n\t\tif (!campaign.discountOptions.includes(discountPercentage)) {\n\t\t\tthrow badRequestError('Selected discount is not an available option for this campaign.');\n\t\t}\n\t\tif (!campaign.maxDiscountCaps.includes(maxDiscountCap)) {\n\t\t\tthrow badRequestError('Selected max discount cap is not an available option for this campaign.');\n\t\t}\n\t}\n}\n\nexport const ltoParticipantService = Container.get(LimitedTimeOfferParticipantService);\n"]}
|
|
1
|
+
{"version":3,"file":"limited-time-offer-participant.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAG1C,4DAAiF;AACjF,4EAAwG;AACxG,2IAAqH;AACrH,yHAAkG;AAClG,4GAKsD;AACtD,sGAAqF;AACrF,4GAAsF;AAEtF,wCAA2C;AAGpC,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IACtC,UAAU,CAA2B;IACrC,eAAe,CAAqB;IACpC,gBAAgB,CAAiC;IAEzD;QACC,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,oEAAwB,CAAC,CAAC;QAC1D,IAAI,CAAC,eAAe,GAAG,gBAAS,CAAC,GAAG,CAAC,wDAAkB,CAAC,CAAC;QACzD,IAAI,CAAC,gBAAgB,GAAG,gBAAS,CAAC,GAAG,CAAC,iFAA8B,CAAC,CAAC;IACvE,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,MAA+B,EAAE,GAAuB;QACzE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,2BAA2B,EAAE,CAAC;QAE1D,MAAM,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACxD,IAAI,CAAC,0BAA0B,CAAC,QAAQ,EAAE,GAAG,CAAC,kBAAkB,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;QACtF,MAAM,IAAI,CAAC,0BAA0B,CAAC,MAA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CAAC;gBAClE,MAAM,IAAA,8BAAe,EAAC,yEAAyE,CAAC,CAAC;YAClG,CAAC;QACF,CAAC;IACF,CAAC;CACD,CAAA;AAtMY,gFAAkC;6CAAlC,kCAAkC;IAD9C,IAAA,gBAAO,GAAE;;GACG,kCAAkC,CAsM9C;AAEY,QAAA,qBAAqB,GAAG,gBAAS,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {DocumentType, mongoose} from '@typegoose/typegoose';\nimport {LimitedTimeOfferCampaign, Setting} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {LimitedTimeOfferCampaignStatus} from '@lyxa.ai/core/dist/utilities/enum';\nimport {badRequestError, conflictError, notFoundError} from '@lyxa.ai/core/dist/utilities/error-common';\nimport {LtoCampaignService} from '@modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service';\nimport {LtoParticipantMarketingService} from './limited-time-offer-participant-marketing.service';\nimport {\n\tJoinLtoCampaignDTO,\n\tLtoCardState,\n\tParticipantStatusDTO,\n\tParticipantSummaryDTO,\n} from '../limited-time-offer-participant.validation';\nimport {LtoParticipantQueryBuilder} from '../limited-time-offer-participant.builder';\nimport {LtoParticipantRepository} from '../limited-time-offer-participant.repository';\nimport {GetLtoCampaignParticipantsDTO} from '../../campaign/limited-time-offer-campaign.validation';\nimport {getLibraries} from '@lyxa.ai/core';\n\n@Service()\nexport class LimitedTimeOfferParticipantService {\n\tprivate repository: LtoParticipantRepository;\n\tprivate campaignService: LtoCampaignService;\n\tprivate marketingService: LtoParticipantMarketingService;\n\n\tconstructor() {\n\t\tthis.repository = Container.get(LtoParticipantRepository);\n\t\tthis.campaignService = Container.get(LtoCampaignService);\n\t\tthis.marketingService = Container.get(LtoParticipantMarketingService);\n\t}\n\n\tpublic async join(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO) {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\n\t\tawait this.assertNotAlreadyJoined(campaign._id, shopId);\n\t\tthis.validateDiscountSelections(campaign, dto.discountPercentage, dto.maxDiscountCap);\n\t\tawait this.assertProductsBelongToShop(shopId, dto);\n\n\t\tconst resolvedDto = await this.resolveCategorySelection(shopId, dto);\n\t\tconst marketingId = await this.marketingService.applyMarketing(shopId, campaign, resolvedDto);\n\n\t\tconst participant = await this.repository.create(\n\t\t\tLtoParticipantQueryBuilder.buildCreateInput(campaign._id, shopId, marketingId, resolvedDto)\n\t\t);\n\t\t// Update shop\n\t\tawait this.repository.updateShopOrderCapacity(\n\t\t\tshopId,\n\t\t\tresolvedDto.isOrderCapacityEnabled,\n\t\t\tresolvedDto.maxOrderCapacity\n\t\t);\n\t\treturn participant;\n\t}\n\n\tpublic async withdraw(shopId: mongoose.Types.ObjectId): Promise<void> {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\n\t\tconst participant = await this.repository.withdraw(campaign._id, shopId);\n\t\tif (!participant) throw notFoundError('You have not joined this campaign.');\n\n\t\tif (participant.marketing) {\n\t\t\tawait this.marketingService.removeMarketing(participant.marketing as mongoose.Types.ObjectId);\n\t\t}\n\t}\n\n\tpublic async getStatus(shopId: mongoose.Types.ObjectId): Promise<ParticipantStatusDTO> {\n\t\tconst campaign = await this.campaignService.getCurrent();\n\n\t\tif (!campaign) return { campaignState: LtoCardState.NONE };\n\n\t\tconst participant = await this.repository.findActiveByCampaignAndShop(campaign._id, shopId);\n\n\t\tconst campaignState =\n\t\t\tcampaign.status === LimitedTimeOfferCampaignStatus.SCHEDULED\n\t\t\t\t? LtoCardState.SCHEDULED\n\t\t\t\t: campaign.status === LimitedTimeOfferCampaignStatus.ACTIVE\n\t\t\t\t\t? LtoCardState.LIVE\n\t\t\t\t\t: LtoCardState.NONE;\n\n\t\treturn participant\n\t\t\t? { campaignState, campaign: campaign as any, participant }\n\t\t\t: { campaignState, campaign: campaign as any };\n\t}\n\n\tpublic async update(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO) {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\n\t\tconst participant = await this.repository.findActiveByCampaignAndShop(campaign._id, shopId);\n\t\tif (!participant) throw notFoundError('You have not joined this campaign.');\n\n\t\tthis.validateDiscountSelections(campaign, dto.discountPercentage, dto.maxDiscountCap, participant);\n\t\tawait this.assertProductsBelongToShop(shopId, dto);\n\n\t\tconst resolvedDto = await this.resolveCategorySelection(shopId, dto);\n\n\t\tconst newMarketingId = participant.marketingId\n\t\t\t? await this.marketingService.replaceMarketing(participant.marketingId, shopId, campaign, resolvedDto)\n\t\t\t: await this.marketingService.applyMarketing(shopId, campaign, resolvedDto);\n\n\t\treturn this.repository.updateParticipant(campaign._id, shopId, {\n\t\t\tproducts: resolvedDto.products ?? [],\n\t\t\tisEntireMenu: resolvedDto.isEntireMenu,\n\t\t\tdiscountPercentage: resolvedDto.discountPercentage,\n\t\t\tmaxDiscountCap: resolvedDto.maxDiscountCap,\n\t\t\tisOrderCapacityEnabled: resolvedDto.isOrderCapacityEnabled,\n\t\t\tmaxOrderCapacity: resolvedDto.maxOrderCapacity,\n\t\t\tmarketing: newMarketingId,\n\t\t});\n\t}\n\n\tpublic async getParticipants(dto: GetLtoCampaignParticipantsDTO) {\n\t\tconst { documents, total } = await this.repository.findByCampaign(dto);\n\t\treturn {\n\t\t\tdocuments,\n\t\t\tmetadata: {\n\t\t\t\tpage: dto.page,\n\t\t\t\tsize: dto.size,\n\t\t\t\ttotalElements: total,\n\t\t\t\ttotalPages: Math.ceil(total / dto.size),\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic async getParticipantIdsByCampaignId(campaignId: mongoose.Types.ObjectId) {\n\t\treturn await this.repository.findParticipantIdsByCampaignId(campaignId);\n\t}\n\n\tpublic async getNearby(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tinput: { latitude: number; longitude: number }\n\t) {\n\t\tconst settings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst nearByShopDistance = settings.nearByShopDistance || 10000;\n\t\treturn this.repository.findNearby(campaignId, input, nearByShopDistance);\n\t}\n\n\tpublic async removeCampaignMarketings(campaignId: mongoose.Types.ObjectId): Promise<void> {\n\t\tawait this.marketingService.removeAllCampaignMarketings(campaignId);\n\t}\n\n\tprivate async fetchCurrentCampaignOrThrow(): Promise<DocumentType<LimitedTimeOfferCampaign>> {\n\t\tconst campaign = await this.campaignService.getCurrent();\n\t\tif (!campaign) {\n\t\t\tthrow badRequestError('No campaign active or scheduled.');\n\t\t}\n\t\treturn campaign;\n\t}\n\n\tprivate async assertNotAlreadyJoined(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<void> {\n\t\tif (await this.repository.existsActiveByCampaignAndShop(campaignId, shopId)) {\n\t\t\tthrow conflictError('Your shop has already joined this campaign.');\n\t\t}\n\t}\n\n\t/**\n\t * Expands the selected shop categories into their product ids and merges them with any explicitly\n\t * selected products. The marketing layer only ever receives a flat product list, so category\n\t * selection is purely an LTO-side convenience that is resolved here before anything is persisted.\n\t */\n\tprivate async resolveCategorySelection(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdto: JoinLtoCampaignDTO\n\t): Promise<JoinLtoCampaignDTO> {\n\t\tif (dto.isEntireMenu || !dto.shopCategories?.length) return dto;\n\n\t\tconst categoryProductIds = await this.repository.findProductIdsByCategories(shopId, dto.shopCategories);\n\t\tconst products = this.uniqueObjectIds([...(dto.products ?? []), ...categoryProductIds]);\n\n\t\tif (products.length === 0) {\n\t\t\tthrow badRequestError('The selected categories do not contain any products.');\n\t\t}\n\n\t\treturn { ...dto, products };\n\t}\n\n\t/**\n\t * Validates that explicitly selected products belong to the shop. Categories are not checked here:\n\t * {@link resolveCategorySelection} fetches their products with a shop-scoped query, so any category\n\t * that does not belong to the shop simply contributes no products.\n\t */\n\tprivate async assertProductsBelongToShop(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdto: JoinLtoCampaignDTO\n\t): Promise<void> {\n\t\tif (dto.isEntireMenu) return;\n\n\t\tconst productIds = this.uniqueObjectIds(dto.products ?? []);\n\t\tif (!productIds.length) return;\n\n\t\tconst owned = await this.repository.countShopProducts(shopId, productIds);\n\t\tif (owned !== productIds.length) {\n\t\t\tthrow badRequestError('One or more selected products do not belong to your shop.');\n\t\t}\n\t}\n\n\tprivate uniqueObjectIds(ids: mongoose.Types.ObjectId[]): mongoose.Types.ObjectId[] {\n\t\treturn [...new Map(ids.map(id => [id.toString(), id])).values()];\n\t}\n\n\tprivate validateDiscountSelections(\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>,\n\t\tdiscountPercentage: number,\n\t\tmaxDiscountCap: number,\n\t\tparticipant?: ParticipantSummaryDTO\n\t): void {\n\t\tif (!campaign.discountOptions.includes(discountPercentage)) {\n\t\t\tif (!participant || discountPercentage != participant.discountPercentage) {\n\t\t\t\tthrow badRequestError('Selected discount is not an available option for this campaign.');\n\t\t\t}\n\t\t}\n\t\tif (!campaign.maxDiscountCaps.includes(maxDiscountCap)) {\n\t\t\tif (!participant || maxDiscountCap != participant.maxDiscountCap) {\n\t\t\t\tthrow badRequestError('Selected max discount cap is not an available option for this campaign.');\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport const ltoParticipantService = Container.get(LimitedTimeOfferParticipantService);\n"]}
|
|
@@ -8,6 +8,7 @@ export declare class MarketingService {
|
|
|
8
8
|
private shopModel;
|
|
9
9
|
private orderModel;
|
|
10
10
|
private marketingMetricsRepository;
|
|
11
|
+
private limitedTimeOfferParticipantModel;
|
|
11
12
|
constructor();
|
|
12
13
|
create(data: AllMarketingsValidationDTO, admin?: mongoose.Types.ObjectId): Promise<DocumentType<Model>>;
|
|
13
14
|
findById(data: GetByIdInputDTO): Promise<DocumentType<Model>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marketing.service.d.ts","sourceRoot":"/","sources":["modules/marketing/services/marketing.service.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EA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AAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;YA0HjB,uBAAuB;YAkBvB,uBAAuB;IAmBxB,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;IAsC7E,eAAe,CAAC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,UAAU,UAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAoC1F,sCAAsC,CAAC,IAAI,EAAE,oCAAoC;IA8BjF,gCAAgC,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAiChF,gCAAgC,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;YAiC/E,oCAAoC;YAgBpC,kCAAkC;IAgBnC,iCAAiC,IAAI,OAAO,CAAC,IAAI,CAAC;IAqClD,yBAAyB,CAAC,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAoC3F;AAED,eAAO,MAAM,gBAAgB,kBAAkC,CAAC"}
|
|
@@ -65,11 +65,14 @@ let MarketingService = class MarketingService {
|
|
|
65
65
|
shopModel;
|
|
66
66
|
orderModel;
|
|
67
67
|
marketingMetricsRepository;
|
|
68
|
+
limitedTimeOfferParticipantModel;
|
|
68
69
|
constructor() {
|
|
69
70
|
this.model = models_1.MarketingModel;
|
|
70
71
|
this.shopModel = models_1.ShopModel;
|
|
71
72
|
this.orderModel = models_1.RegularOrderModel;
|
|
72
73
|
this.marketingMetricsRepository = MarketingMetricsRepository_1.marketingMetricsRepository;
|
|
74
|
+
this.limitedTimeOfferParticipantModel =
|
|
75
|
+
models_1.LimitedTimeOfferParticipantModel;
|
|
73
76
|
}
|
|
74
77
|
async create(data, admin) {
|
|
75
78
|
const now = (0, dayjs_1.dayjs)().toDate();
|
|
@@ -235,6 +238,12 @@ let MarketingService = class MarketingService {
|
|
|
235
238
|
}
|
|
236
239
|
async update(_id, data, admin) {
|
|
237
240
|
let marketing;
|
|
241
|
+
const partOfLimitedTimeOffer = await this.limitedTimeOfferParticipantModel.exists({
|
|
242
|
+
marketing: _id,
|
|
243
|
+
});
|
|
244
|
+
if (partOfLimitedTimeOffer) {
|
|
245
|
+
(0, error_common_1.forbiddenError)('You are currently participating in a Limited Time Offer. Please make your edits from the Limited Time Offer section.');
|
|
246
|
+
}
|
|
238
247
|
const oldMarketing = await this.model.findById(_id).populate({
|
|
239
248
|
path: 'shop',
|
|
240
249
|
select: '_id name shopId',
|