@lyxa.ai/marketing 1.0.43 → 1.0.44

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.
Files changed (70) hide show
  1. package/dist/lib/event/event-initializations.d.ts.map +1 -1
  2. package/dist/lib/event/event-initializations.js +1 -0
  3. package/dist/lib/event/event-initializations.js.map +1 -1
  4. package/dist/lib/event/event-listeners/event-listeners.d.ts +1 -0
  5. package/dist/lib/event/event-listeners/event-listeners.d.ts.map +1 -1
  6. package/dist/lib/event/event-listeners/event-listeners.js +7 -0
  7. package/dist/lib/event/event-listeners/event-listeners.js.map +1 -1
  8. package/dist/lib/index.d.ts +60 -0
  9. package/dist/lib/index.d.ts.map +1 -1
  10. package/dist/lib/modules/coupon/routers/coupon.router.d.ts +2 -0
  11. package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
  12. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
  13. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js +1 -0
  14. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js.map +1 -1
  15. package/dist/lib/modules/coupon/validations/coupon.validation.d.ts +13 -0
  16. package/dist/lib/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
  17. package/dist/lib/modules/coupon/validations/coupon.validation.js +1 -0
  18. package/dist/lib/modules/coupon/validations/coupon.validation.js.map +1 -1
  19. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts +58 -0
  20. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
  21. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +4 -1
  22. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
  23. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js +18 -2
  24. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js.map +1 -1
  25. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +58 -0
  26. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
  27. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.js +7 -0
  28. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.js.map +1 -1
  29. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +137 -3
  30. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
  31. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js +11 -9
  32. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js.map +1 -1
  33. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts +3 -0
  34. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts.map +1 -1
  35. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.js +4 -0
  36. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.js.map +1 -1
  37. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +1 -0
  38. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  39. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js +19 -0
  40. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js.map +1 -1
  41. package/dist/lib/modules/marketing/routers/marketing.router.js.map +1 -1
  42. package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts +1 -0
  43. package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts.map +1 -1
  44. package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.js +14 -0
  45. package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.js.map +1 -1
  46. package/dist/types/event/event-initializations.d.ts.map +1 -1
  47. package/dist/types/event/event-listeners/event-listeners.d.ts +1 -0
  48. package/dist/types/event/event-listeners/event-listeners.d.ts.map +1 -1
  49. package/dist/types/index.d.ts +60 -0
  50. package/dist/types/index.d.ts.map +1 -1
  51. package/dist/types/modules/coupon/routers/coupon.router.d.ts +2 -0
  52. package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
  53. package/dist/types/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
  54. package/dist/types/modules/coupon/validations/coupon.validation.d.ts +13 -0
  55. package/dist/types/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
  56. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts +58 -0
  57. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
  58. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +4 -1
  59. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
  60. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +58 -0
  61. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
  62. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +137 -3
  63. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
  64. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts +3 -0
  65. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts.map +1 -1
  66. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +1 -0
  67. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  68. package/dist/types/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts +1 -0
  69. package/dist/types/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts.map +1 -1
  70. package/package.json +2 -2
@@ -42,7 +42,106 @@ export declare const JoinLtoCampaignSchema: z.ZodEffects<z.ZodObject<{
42
42
  products?: (string | import("mongoose").Types.ObjectId)[] | undefined;
43
43
  maxOrderCapacity?: number | undefined;
44
44
  }>;
45
- declare const ParticipantStatusSchema: z.ZodObject<{
45
+ export declare const ParticipantSchema: z.ZodObject<{
46
+ _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>;
47
+ campaign: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>;
48
+ shop: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>;
49
+ joinedAt: z.ZodDate;
50
+ products: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>, "many">>;
51
+ isEntireMenu: z.ZodBoolean;
52
+ discountPercentage: z.ZodOptional<z.ZodNumber>;
53
+ maxDiscountCap: z.ZodOptional<z.ZodNumber>;
54
+ isOrderCapacityEnabled: z.ZodBoolean;
55
+ maxOrderCapacity: z.ZodOptional<z.ZodNumber>;
56
+ isWithdrawn: z.ZodBoolean;
57
+ withdrawnAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
58
+ createdAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
59
+ updatedAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
60
+ }, "strip", z.ZodTypeAny, {
61
+ _id: import("mongoose").Types.ObjectId;
62
+ shop: import("mongoose").Types.ObjectId;
63
+ products: import("mongoose").Types.ObjectId[];
64
+ joinedAt: Date;
65
+ isEntireMenu: boolean;
66
+ campaign: import("mongoose").Types.ObjectId;
67
+ isOrderCapacityEnabled: boolean;
68
+ isWithdrawn: boolean;
69
+ createdAt?: Date | null | undefined;
70
+ updatedAt?: Date | null | undefined;
71
+ discountPercentage?: number | undefined;
72
+ maxDiscountCap?: number | undefined;
73
+ maxOrderCapacity?: number | undefined;
74
+ withdrawnAt?: Date | null | undefined;
75
+ }, {
76
+ _id: string | import("mongoose").Types.ObjectId;
77
+ shop: string | import("mongoose").Types.ObjectId;
78
+ joinedAt: Date;
79
+ isEntireMenu: boolean;
80
+ campaign: string | import("mongoose").Types.ObjectId;
81
+ isOrderCapacityEnabled: boolean;
82
+ isWithdrawn: boolean;
83
+ createdAt?: Date | null | undefined;
84
+ updatedAt?: Date | null | undefined;
85
+ products?: (string | import("mongoose").Types.ObjectId)[] | undefined;
86
+ discountPercentage?: number | undefined;
87
+ maxDiscountCap?: number | undefined;
88
+ maxOrderCapacity?: number | undefined;
89
+ withdrawnAt?: Date | null | undefined;
90
+ }>;
91
+ export declare const CampaignSummarySchema: z.ZodObject<{
92
+ _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>;
93
+ title: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
94
+ subTitle: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
95
+ startDate: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
96
+ endDate: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
97
+ discountOptions: z.ZodDefault<z.ZodArray<z.ZodNumber, "many">>;
98
+ maxDiscountCaps: z.ZodDefault<z.ZodArray<z.ZodNumber, "many">>;
99
+ }, "strip", z.ZodTypeAny, {
100
+ _id: import("mongoose").Types.ObjectId;
101
+ discountOptions: number[];
102
+ maxDiscountCaps: number[];
103
+ startDate?: Date | null | undefined;
104
+ endDate?: Date | null | undefined;
105
+ title?: string | undefined;
106
+ subTitle?: string | undefined;
107
+ }, {
108
+ _id: string | import("mongoose").Types.ObjectId;
109
+ startDate?: Date | null | undefined;
110
+ endDate?: Date | null | undefined;
111
+ title?: string | undefined;
112
+ subTitle?: string | undefined;
113
+ discountOptions?: number[] | undefined;
114
+ maxDiscountCaps?: number[] | undefined;
115
+ }>;
116
+ export declare const ParticipantSummarySchema: z.ZodObject<{
117
+ discountPercentage: z.ZodOptional<z.ZodNumber>;
118
+ maxDiscountCap: z.ZodOptional<z.ZodNumber>;
119
+ joinedAt: z.ZodDate;
120
+ isEntireMenu: z.ZodBoolean;
121
+ isOrderCapacityEnabled: z.ZodBoolean;
122
+ maxOrderCapacity: z.ZodOptional<z.ZodNumber>;
123
+ productIds: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>, "many">>;
124
+ marketingId: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>>;
125
+ }, "strip", z.ZodTypeAny, {
126
+ joinedAt: Date;
127
+ productIds: import("mongoose").Types.ObjectId[];
128
+ isEntireMenu: boolean;
129
+ isOrderCapacityEnabled: boolean;
130
+ marketingId?: import("mongoose").Types.ObjectId | undefined;
131
+ discountPercentage?: number | undefined;
132
+ maxDiscountCap?: number | undefined;
133
+ maxOrderCapacity?: number | undefined;
134
+ }, {
135
+ joinedAt: Date;
136
+ isEntireMenu: boolean;
137
+ isOrderCapacityEnabled: boolean;
138
+ productIds?: (string | import("mongoose").Types.ObjectId)[] | undefined;
139
+ marketingId?: string | import("mongoose").Types.ObjectId | undefined;
140
+ discountPercentage?: number | undefined;
141
+ maxDiscountCap?: number | undefined;
142
+ maxOrderCapacity?: number | undefined;
143
+ }>;
144
+ export declare const ParticipantStatusSchema: z.ZodObject<{
46
145
  campaignState: z.ZodNativeEnum<typeof LtoCardState>;
47
146
  campaign: z.ZodOptional<z.ZodObject<{
48
147
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>;
@@ -76,10 +175,14 @@ declare const ParticipantStatusSchema: z.ZodObject<{
76
175
  isEntireMenu: z.ZodBoolean;
77
176
  isOrderCapacityEnabled: z.ZodBoolean;
78
177
  maxOrderCapacity: z.ZodOptional<z.ZodNumber>;
178
+ productIds: z.ZodDefault<z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>, "many">>;
179
+ marketingId: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>>;
79
180
  }, "strip", z.ZodTypeAny, {
80
181
  joinedAt: Date;
182
+ productIds: import("mongoose").Types.ObjectId[];
81
183
  isEntireMenu: boolean;
82
184
  isOrderCapacityEnabled: boolean;
185
+ marketingId?: import("mongoose").Types.ObjectId | undefined;
83
186
  discountPercentage?: number | undefined;
84
187
  maxDiscountCap?: number | undefined;
85
188
  maxOrderCapacity?: number | undefined;
@@ -87,6 +190,8 @@ declare const ParticipantStatusSchema: z.ZodObject<{
87
190
  joinedAt: Date;
88
191
  isEntireMenu: boolean;
89
192
  isOrderCapacityEnabled: boolean;
193
+ productIds?: (string | import("mongoose").Types.ObjectId)[] | undefined;
194
+ marketingId?: string | import("mongoose").Types.ObjectId | undefined;
90
195
  discountPercentage?: number | undefined;
91
196
  maxDiscountCap?: number | undefined;
92
197
  maxOrderCapacity?: number | undefined;
@@ -104,8 +209,10 @@ declare const ParticipantStatusSchema: z.ZodObject<{
104
209
  } | undefined;
105
210
  participant?: {
106
211
  joinedAt: Date;
212
+ productIds: import("mongoose").Types.ObjectId[];
107
213
  isEntireMenu: boolean;
108
214
  isOrderCapacityEnabled: boolean;
215
+ marketingId?: import("mongoose").Types.ObjectId | undefined;
109
216
  discountPercentage?: number | undefined;
110
217
  maxDiscountCap?: number | undefined;
111
218
  maxOrderCapacity?: number | undefined;
@@ -125,6 +232,8 @@ declare const ParticipantStatusSchema: z.ZodObject<{
125
232
  joinedAt: Date;
126
233
  isEntireMenu: boolean;
127
234
  isOrderCapacityEnabled: boolean;
235
+ productIds?: (string | import("mongoose").Types.ObjectId)[] | undefined;
236
+ marketingId?: string | import("mongoose").Types.ObjectId | undefined;
128
237
  discountPercentage?: number | undefined;
129
238
  maxDiscountCap?: number | undefined;
130
239
  maxOrderCapacity?: number | undefined;
@@ -378,6 +487,8 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
378
487
  joinedAt: Date;
379
488
  isEntireMenu: boolean;
380
489
  isOrderCapacityEnabled: boolean;
490
+ productIds?: (string | import("mongoose").Types.ObjectId)[] | undefined;
491
+ marketingId?: string | import("mongoose").Types.ObjectId | undefined;
381
492
  discountPercentage?: number | undefined;
382
493
  maxDiscountCap?: number | undefined;
383
494
  maxOrderCapacity?: number | undefined;
@@ -397,6 +508,8 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
397
508
  joinedAt: Date;
398
509
  isEntireMenu: boolean;
399
510
  isOrderCapacityEnabled: boolean;
511
+ productIds?: (string | import("mongoose").Types.ObjectId)[] | undefined;
512
+ marketingId?: string | import("mongoose").Types.ObjectId | undefined;
400
513
  discountPercentage?: number | undefined;
401
514
  maxDiscountCap?: number | undefined;
402
515
  maxOrderCapacity?: number | undefined;
@@ -418,6 +531,8 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
418
531
  joinedAt: Date;
419
532
  isEntireMenu: boolean;
420
533
  isOrderCapacityEnabled: boolean;
534
+ productIds?: (string | import("mongoose").Types.ObjectId)[] | undefined;
535
+ marketingId?: string | import("mongoose").Types.ObjectId | undefined;
421
536
  discountPercentage?: number | undefined;
422
537
  maxDiscountCap?: number | undefined;
423
538
  maxOrderCapacity?: number | undefined;
@@ -445,6 +560,8 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
445
560
  joinedAt: Date;
446
561
  isEntireMenu: boolean;
447
562
  isOrderCapacityEnabled: boolean;
563
+ productIds?: (string | import("mongoose").Types.ObjectId)[] | undefined;
564
+ marketingId?: string | import("mongoose").Types.ObjectId | undefined;
448
565
  discountPercentage?: number | undefined;
449
566
  maxDiscountCap?: number | undefined;
450
567
  maxOrderCapacity?: number | undefined;
@@ -471,6 +588,8 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
471
588
  joinedAt: Date;
472
589
  isEntireMenu: boolean;
473
590
  isOrderCapacityEnabled: boolean;
591
+ productIds?: (string | import("mongoose").Types.ObjectId)[] | undefined;
592
+ marketingId?: string | import("mongoose").Types.ObjectId | undefined;
474
593
  discountPercentage?: number | undefined;
475
594
  maxDiscountCap?: number | undefined;
476
595
  maxOrderCapacity?: number | undefined;
@@ -490,6 +609,8 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
490
609
  joinedAt: Date;
491
610
  isEntireMenu: boolean;
492
611
  isOrderCapacityEnabled: boolean;
612
+ productIds?: (string | import("mongoose").Types.ObjectId)[] | undefined;
613
+ marketingId?: string | import("mongoose").Types.ObjectId | undefined;
493
614
  discountPercentage?: number | undefined;
494
615
  maxDiscountCap?: number | undefined;
495
616
  maxOrderCapacity?: number | undefined;
@@ -513,6 +634,8 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
513
634
  joinedAt: Date;
514
635
  isEntireMenu: boolean;
515
636
  isOrderCapacityEnabled: boolean;
637
+ productIds?: (string | import("mongoose").Types.ObjectId)[] | undefined;
638
+ marketingId?: string | import("mongoose").Types.ObjectId | undefined;
516
639
  discountPercentage?: number | undefined;
517
640
  maxDiscountCap?: number | undefined;
518
641
  maxOrderCapacity?: number | undefined;
@@ -533,6 +656,8 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
533
656
  joinedAt: Date;
534
657
  isEntireMenu: boolean;
535
658
  isOrderCapacityEnabled: boolean;
659
+ productIds?: (string | import("mongoose").Types.ObjectId)[] | undefined;
660
+ marketingId?: string | import("mongoose").Types.ObjectId | undefined;
536
661
  discountPercentage?: number | undefined;
537
662
  maxDiscountCap?: number | undefined;
538
663
  maxOrderCapacity?: number | undefined;
@@ -563,6 +688,8 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
563
688
  joinedAt: Date;
564
689
  isEntireMenu: boolean;
565
690
  isOrderCapacityEnabled: boolean;
691
+ productIds?: (string | import("mongoose").Types.ObjectId)[] | undefined;
692
+ marketingId?: string | import("mongoose").Types.ObjectId | undefined;
566
693
  discountPercentage?: number | undefined;
567
694
  maxDiscountCap?: number | undefined;
568
695
  maxOrderCapacity?: number | undefined;
@@ -583,6 +710,8 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
583
710
  joinedAt: Date;
584
711
  isEntireMenu: boolean;
585
712
  isOrderCapacityEnabled: boolean;
713
+ productIds?: (string | import("mongoose").Types.ObjectId)[] | undefined;
714
+ marketingId?: string | import("mongoose").Types.ObjectId | undefined;
586
715
  discountPercentage?: number | undefined;
587
716
  maxDiscountCap?: number | undefined;
588
717
  maxOrderCapacity?: number | undefined;
@@ -597,7 +726,12 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
597
726
  } | undefined;
598
727
  }>;
599
728
  export type JoinLtoCampaignDTO = DTO<typeof JoinLtoCampaignSchema>;
600
- export type JoinLtoCampaignInputDTO = JoinLtoCampaignDTO;
729
+ export type ParticipantDTO = DTO<typeof ParticipantSchema>;
730
+ export type CampaignSummaryDTO = DTO<typeof CampaignSummarySchema>;
731
+ export type ParticipantSummaryDTO = DTO<typeof ParticipantSummarySchema>;
601
732
  export type ParticipantStatusDTO = DTO<typeof ParticipantStatusSchema>;
602
- export {};
733
+ export type ActiveParticipantMarketingDTO = Pick<ParticipantSummaryDTO, 'marketingId'>;
734
+ export type UpdateParticipantDataDTO = JoinLtoCampaignDTO & {
735
+ marketing: ParticipantSummaryDTO['marketingId'];
736
+ };
603
737
  //# sourceMappingURL=limited-time-offer-participant.validation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer-participant.validation.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AACtB,OAAO,EAAuB,GAAG,EAAgB,MAAM,yCAAyC,CAAC;AAEjG,oBAAY,YAAY;IACpB,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,IAAI,SAAS;IACb,MAAM,WAAW;CACpB;AAED,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+B5B,CAAC;AAsCP,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAI3B,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA0C,CAAC;AACjF,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAgD,CAAC;AAE7F,MAAM,MAAM,kBAAkB,GAAG,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACnE,MAAM,MAAM,uBAAuB,GAAG,kBAAkB,CAAC;AACzD,MAAM,MAAM,oBAAoB,GAAG,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
1
+ {"version":3,"file":"limited-time-offer-participant.validation.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AACtB,OAAO,EAAuB,GAAG,EAAgB,MAAM,yCAAyC,CAAC;AAEjG,oBAAY,YAAY;IACpB,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,IAAI,SAAS;IACb,MAAM,WAAW;CACpB;AAED,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+B5B,CAAC;AAEP,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAe5B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;EAQhC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;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I,CAAC,qBAAqB,EAAE,aAAa,CAAC,CAAC;AACvF,MAAM,MAAM,wBAAwB,GAAG,kBAAkB,GAAG;IAAC,SAAS,EAAE,qBAAqB,CAAC,aAAa,CAAC,CAAA;CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParticipantStatusResponseSchema = exports.ParticipantResponseSchema = exports.JoinLtoCampaignSchema = exports.LtoCardState = void 0;
3
+ exports.ParticipantStatusResponseSchema = exports.ParticipantResponseSchema = exports.ParticipantStatusSchema = exports.ParticipantSummarySchema = exports.CampaignSummarySchema = exports.ParticipantSchema = exports.JoinLtoCampaignSchema = exports.LtoCardState = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const validation_1 = require("@lyxa.ai/core/dist/utilities/validation");
6
6
  var LtoCardState;
@@ -42,7 +42,7 @@ exports.JoinLtoCampaignSchema = zod_1.z
42
42
  });
43
43
  }
44
44
  });
45
- const ParticipantSchema = zod_1.z.object({
45
+ exports.ParticipantSchema = zod_1.z.object({
46
46
  _id: validation_1.ZodValidation.objectId(),
47
47
  campaign: validation_1.ZodValidation.objectId(),
48
48
  shop: validation_1.ZodValidation.objectId(),
@@ -58,7 +58,7 @@ const ParticipantSchema = zod_1.z.object({
58
58
  createdAt: zod_1.z.date().nullable().optional(),
59
59
  updatedAt: zod_1.z.date().nullable().optional(),
60
60
  });
61
- const CampaignSummarySchema = zod_1.z.object({
61
+ exports.CampaignSummarySchema = zod_1.z.object({
62
62
  _id: validation_1.ZodValidation.objectId(),
63
63
  title: validation_1.ZodValidation.string('Title').optional(),
64
64
  subTitle: validation_1.ZodValidation.string('Subtitle').optional(),
@@ -67,19 +67,21 @@ const CampaignSummarySchema = zod_1.z.object({
67
67
  discountOptions: zod_1.z.array(validation_1.ZodValidation.number('Discount option')).default([]),
68
68
  maxDiscountCaps: zod_1.z.array(validation_1.ZodValidation.number('Max discount cap')).default([]),
69
69
  });
70
- const ParticipantSummarySchema = zod_1.z.object({
70
+ exports.ParticipantSummarySchema = zod_1.z.object({
71
71
  discountPercentage: validation_1.ZodValidation.number('Discount percentage').optional(),
72
72
  maxDiscountCap: validation_1.ZodValidation.number('Max discount cap').optional(),
73
73
  joinedAt: zod_1.z.date(),
74
74
  isEntireMenu: zod_1.z.boolean(),
75
75
  isOrderCapacityEnabled: zod_1.z.boolean(),
76
76
  maxOrderCapacity: validation_1.ZodValidation.number('Max order capacity').optional(),
77
+ productIds: zod_1.z.array(validation_1.ZodValidation.objectId()).default([]),
78
+ marketingId: validation_1.ZodValidation.objectId().optional(),
77
79
  });
78
- const ParticipantStatusSchema = zod_1.z.object({
80
+ exports.ParticipantStatusSchema = zod_1.z.object({
79
81
  campaignState: zod_1.z.nativeEnum(LtoCardState),
80
- campaign: CampaignSummarySchema.optional(),
81
- participant: ParticipantSummarySchema.optional(),
82
+ campaign: exports.CampaignSummarySchema.optional(),
83
+ participant: exports.ParticipantSummarySchema.optional(),
82
84
  });
83
- exports.ParticipantResponseSchema = (0, validation_1.createResponseSchema)(ParticipantSchema);
84
- exports.ParticipantStatusResponseSchema = (0, validation_1.createResponseSchema)(ParticipantStatusSchema);
85
+ exports.ParticipantResponseSchema = (0, validation_1.createResponseSchema)(exports.ParticipantSchema);
86
+ exports.ParticipantStatusResponseSchema = (0, validation_1.createResponseSchema)(exports.ParticipantStatusSchema);
85
87
  //# sourceMappingURL=limited-time-offer-participant.validation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer-participant.validation.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.validation.ts"],"names":[],"mappings":";;;AAAA,6BAAsB;AACtB,wEAAiG;AAEjG,IAAY,YAKX;AALD,WAAY,YAAY;IACpB,6BAAa,CAAA;IACb,uCAAuB,CAAA;IACvB,6BAAa,CAAA;IACb,iCAAiB,CAAA;AACrB,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB;AAEY,QAAA,qBAAqB,GA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AAG,IAAA,iCAAoB,EAAC,uBAAuB,CAAC,CAAC","sourcesContent":["import {z} from 'zod';\nimport {createResponseSchema, DTO, ZodValidation} from '@lyxa.ai/core/dist/utilities/validation';\n\nexport enum LtoCardState {\n NONE = 'NONE',\n SCHEDULED = 'SCHEDULED',\n LIVE = 'LIVE',\n JOINED = 'JOINED',\n}\n\nexport const JoinLtoCampaignSchema = z\n .object({\n isEntireMenu: z.boolean(),\n products: z.array(ZodValidation.objectId()).default([]),\n discountPercentage: ZodValidation.number('Discount percentage'),\n maxDiscountCap: ZodValidation.number('Max discount cap'),\n isOrderCapacityEnabled: z.boolean(),\n maxOrderCapacity: ZodValidation.number('Max order capacity').optional(),\n })\n .superRefine((d, ctx) => {\n if (!d.isEntireMenu && d.products.length === 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'At least one product must be selected',\n path: ['products']\n });\n }\n if (d.isOrderCapacityEnabled && !d.maxOrderCapacity) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Max order capacity is required when capacity is enabled',\n path: ['maxOrderCapacity']\n });\n }\n if (d.isOrderCapacityEnabled && d.maxOrderCapacity !== undefined && d.maxOrderCapacity <= 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Max order capacity must be greater than 0',\n path: ['maxOrderCapacity']\n });\n }\n });\n\nconst ParticipantSchema = z.object({\n _id: ZodValidation.objectId(),\n campaign: ZodValidation.objectId(),\n shop: ZodValidation.objectId(),\n joinedAt: z.date(),\n products: z.array(ZodValidation.objectId()).default([]),\n isEntireMenu: z.boolean(),\n discountPercentage: ZodValidation.number('Discount percentage').optional(),\n maxDiscountCap: ZodValidation.number('Max discount cap').optional(),\n isOrderCapacityEnabled: z.boolean(),\n maxOrderCapacity: ZodValidation.number('Max order capacity').optional(),\n isWithdrawn: z.boolean(),\n withdrawnAt: z.date().nullable().optional(),\n createdAt: z.date().nullable().optional(),\n updatedAt: z.date().nullable().optional(),\n});\n\nconst CampaignSummarySchema = z.object({\n _id: ZodValidation.objectId(),\n title: ZodValidation.string('Title').optional(),\n subTitle: ZodValidation.string('Subtitle').optional(),\n startDate: z.date().nullable().optional(),\n endDate: z.date().nullable().optional(),\n discountOptions: z.array(ZodValidation.number('Discount option')).default([]),\n maxDiscountCaps: z.array(ZodValidation.number('Max discount cap')).default([]),\n});\n\nconst ParticipantSummarySchema = z.object({\n discountPercentage: ZodValidation.number('Discount percentage').optional(),\n maxDiscountCap: ZodValidation.number('Max discount cap').optional(),\n joinedAt: z.date(),\n isEntireMenu: z.boolean(),\n isOrderCapacityEnabled: z.boolean(),\n maxOrderCapacity: ZodValidation.number('Max order capacity').optional(),\n});\n\nconst ParticipantStatusSchema = z.object({\n campaignState: z.nativeEnum(LtoCardState),\n campaign: CampaignSummarySchema.optional(),\n participant: ParticipantSummarySchema.optional(),\n});\n\nexport const ParticipantResponseSchema = createResponseSchema(ParticipantSchema);\nexport const ParticipantStatusResponseSchema = createResponseSchema(ParticipantStatusSchema);\n\nexport type JoinLtoCampaignDTO = DTO<typeof JoinLtoCampaignSchema>;\nexport type JoinLtoCampaignInputDTO = JoinLtoCampaignDTO;\nexport type ParticipantStatusDTO = DTO<typeof ParticipantStatusSchema>;\n"]}
1
+ {"version":3,"file":"limited-time-offer-participant.validation.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.validation.ts"],"names":[],"mappings":";;;AAAA,6BAAsB;AACtB,wEAAiG;AAEjG,IAAY,YAKX;AALD,WAAY,YAAY;IACpB,6BAAa,CAAA;IACb,uCAAuB,CAAA;IACvB,6BAAa,CAAA;IACb,iCAAiB,CAAA;AACrB,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB;AAEY,QAAA,qBAAqB,GAAG,OAAC;KACjC,MAAM,CAAC;IACJ,YAAY,EAAE,OAAC,CAAC,OAAO,EAAE;IACzB,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,0BAAa,CAAC,QAAQ,EAAE,CAAC,CAAC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pE,QAAA,+BAA+B,GAAG,IAAA,iCAAoB,EAAC,+BAAuB,CAAC,CAAC","sourcesContent":["import {z} from 'zod';\nimport {createResponseSchema, DTO, ZodValidation} from '@lyxa.ai/core/dist/utilities/validation';\n\nexport enum LtoCardState {\n NONE = 'NONE',\n SCHEDULED = 'SCHEDULED',\n LIVE = 'LIVE',\n JOINED = 'JOINED',\n}\n\nexport const JoinLtoCampaignSchema = z\n .object({\n isEntireMenu: z.boolean(),\n products: z.array(ZodValidation.objectId()).default([]),\n discountPercentage: ZodValidation.number('Discount percentage'),\n maxDiscountCap: ZodValidation.number('Max discount cap'),\n isOrderCapacityEnabled: z.boolean(),\n maxOrderCapacity: ZodValidation.number('Max order capacity').optional(),\n })\n .superRefine((d, ctx) => {\n if (!d.isEntireMenu && d.products.length === 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'At least one product must be selected',\n path: ['products']\n });\n }\n if (d.isOrderCapacityEnabled && !d.maxOrderCapacity) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Max order capacity is required when capacity is enabled',\n path: ['maxOrderCapacity']\n });\n }\n if (d.isOrderCapacityEnabled && d.maxOrderCapacity !== undefined && d.maxOrderCapacity <= 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Max order capacity must be greater than 0',\n path: ['maxOrderCapacity']\n });\n }\n });\n\nexport const ParticipantSchema = z.object({\n _id: ZodValidation.objectId(),\n campaign: ZodValidation.objectId(),\n shop: ZodValidation.objectId(),\n joinedAt: z.date(),\n products: z.array(ZodValidation.objectId()).default([]),\n isEntireMenu: z.boolean(),\n discountPercentage: ZodValidation.number('Discount percentage').optional(),\n maxDiscountCap: ZodValidation.number('Max discount cap').optional(),\n isOrderCapacityEnabled: z.boolean(),\n maxOrderCapacity: ZodValidation.number('Max order capacity').optional(),\n isWithdrawn: z.boolean(),\n withdrawnAt: z.date().nullable().optional(),\n createdAt: z.date().nullable().optional(),\n updatedAt: z.date().nullable().optional(),\n});\n\nexport const CampaignSummarySchema = z.object({\n _id: ZodValidation.objectId(),\n title: ZodValidation.string('Title').optional(),\n subTitle: ZodValidation.string('Subtitle').optional(),\n startDate: z.date().nullable().optional(),\n endDate: z.date().nullable().optional(),\n discountOptions: z.array(ZodValidation.number('Discount option')).default([]),\n maxDiscountCaps: z.array(ZodValidation.number('Max discount cap')).default([]),\n});\n\nexport const ParticipantSummarySchema = z.object({\n discountPercentage: ZodValidation.number('Discount percentage').optional(),\n maxDiscountCap: ZodValidation.number('Max discount cap').optional(),\n joinedAt: z.date(),\n isEntireMenu: z.boolean(),\n isOrderCapacityEnabled: z.boolean(),\n maxOrderCapacity: ZodValidation.number('Max order capacity').optional(),\n productIds: z.array(ZodValidation.objectId()).default([]),\n marketingId: ZodValidation.objectId().optional(),\n});\n\nexport const ParticipantStatusSchema = z.object({\n campaignState: z.nativeEnum(LtoCardState),\n campaign: CampaignSummarySchema.optional(),\n participant: ParticipantSummarySchema.optional(),\n});\n\nexport const ParticipantResponseSchema = createResponseSchema(ParticipantSchema);\nexport const ParticipantStatusResponseSchema = createResponseSchema(ParticipantStatusSchema);\n\nexport type JoinLtoCampaignDTO = DTO<typeof JoinLtoCampaignSchema>;\nexport type ParticipantDTO = DTO<typeof ParticipantSchema>;\nexport type CampaignSummaryDTO = DTO<typeof CampaignSummarySchema>;\nexport type ParticipantSummaryDTO = DTO<typeof ParticipantSummarySchema>;\nexport type ParticipantStatusDTO = DTO<typeof ParticipantStatusSchema>;\nexport type ActiveParticipantMarketingDTO = Pick<ParticipantSummaryDTO, 'marketingId'>;\nexport type UpdateParticipantDataDTO = JoinLtoCampaignDTO & {marketing: ParticipantSummaryDTO['marketingId']};\n"]}
@@ -8,6 +8,9 @@ export declare class LtoParticipantMarketingService {
8
8
  _id: mongoose.Types.ObjectId;
9
9
  }, dto: JoinLtoCampaignDTO): Promise<mongoose.Types.ObjectId>;
10
10
  removeMarketing(marketingId: mongoose.Types.ObjectId): Promise<void>;
11
+ replaceMarketing(oldMarketingId: mongoose.Types.ObjectId, shopId: mongoose.Types.ObjectId, campaign: LimitedTimeOfferCampaign & {
12
+ _id: mongoose.Types.ObjectId;
13
+ }, dto: JoinLtoCampaignDTO): Promise<mongoose.Types.ObjectId>;
11
14
  removeAllCampaignMarketings(campaignId: mongoose.Types.ObjectId): Promise<void>;
12
15
  }
13
16
  export declare const ltoParticipantMarketingService: LtoParticipantMarketingService;
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer-participant-marketing.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAC,wBAAwB,EAAC,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAC,kBAAkB,EAAC,MAAM,8CAA8C,CAAC;AAIhF,qBACa,8BAA8B;IACvC,OAAO,CAAC,UAAU,CAA2B;;IAMhC,cAAc,CACvB,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,GACxB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IAOtB,eAAe,CAAC,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpE,2BAA2B,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAI/F;AAED,eAAO,MAAM,8BAA8B,gCAAgD,CAAC"}
1
+ {"version":3,"file":"limited-time-offer-participant-marketing.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAC,wBAAwB,EAAC,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAC,kBAAkB,EAAC,MAAM,8CAA8C,CAAC;AAIhF,qBACa,8BAA8B;IACvC,OAAO,CAAC,UAAU,CAA2B;;IAMhC,cAAc,CACvB,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,GACxB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IAOtB,eAAe,CAAC,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpE,gBAAgB,CACzB,cAAc,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACvC,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,GACxB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IAKtB,2BAA2B,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAI/F;AAED,eAAO,MAAM,8BAA8B,gCAAgD,CAAC"}
@@ -59,6 +59,10 @@ let LtoParticipantMarketingService = class LtoParticipantMarketingService {
59
59
  async removeMarketing(marketingId) {
60
60
  await services_1.marketingService.deleteById({ _id: marketingId, softDelete: true });
61
61
  }
62
+ async replaceMarketing(oldMarketingId, shopId, campaign, dto) {
63
+ await this.removeMarketing(oldMarketingId);
64
+ return this.applyMarketing(shopId, campaign, dto);
65
+ }
62
66
  async removeAllCampaignMarketings(campaignId) {
63
67
  const marketingIds = await this.repository.findMarketingIdsByCampaign(campaignId);
64
68
  await services_1.marketingService.deleteManyByIds(marketingIds);
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer-participant-marketing.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,0DAA6D;AAG7D,sGAAqF;AACrF,4GAAsF;AAG/E,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAC/B,UAAU,CAA2B;IAE7C;QACI,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,oEAAwB,CAAC,CAAC;IAC9D,CAAC;IAEM,KAAK,CAAC,cAAc,CACvB,MAA+B,EAC/B,QAAmE,EACnE,GAAuB;QAEvB,MAAM,SAAS,GAAG,MAAM,2BAAgB,CAAC,MAAM,CAC3C,mEAA0B,CAAC,mBAAmB,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAC,CACxE,CAAC;QACF,OAAO,SAAS,CAAC,GAAG,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,WAAoC;QAC7D,MAAM,2BAAgB,CAAC,UAAU,CAAC,EAAC,GAAG,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAC,CAAC,CAAC;IAC5E,CAAC;IAEM,KAAK,CAAC,2BAA2B,CAAC,UAAmC;QACxE,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,0BAA0B,CAAC,UAAU,CAAC,CAAC;QAClF,MAAM,2BAAgB,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;IACzD,CAAC;CACJ,CAAA;AA1BY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,gBAAO,GAAE;;GACG,8BAA8B,CA0B1C;AAEY,QAAA,8BAA8B,GAAG,gBAAS,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {marketingService} from '@modules/marketing/services';\nimport {LimitedTimeOfferCampaign} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {JoinLtoCampaignDTO} from '../limited-time-offer-participant.validation';\nimport {LtoParticipantQueryBuilder} from '../limited-time-offer-participant.builder';\nimport {LtoParticipantRepository} from '../limited-time-offer-participant.repository';\n\n@Service()\nexport class LtoParticipantMarketingService {\n private repository: LtoParticipantRepository;\n\n constructor() {\n this.repository = Container.get(LtoParticipantRepository);\n }\n\n public async applyMarketing(\n shopId: mongoose.Types.ObjectId,\n campaign: LimitedTimeOfferCampaign & {_id: mongoose.Types.ObjectId},\n dto: JoinLtoCampaignDTO,\n ): Promise<mongoose.Types.ObjectId> {\n const marketing = await marketingService.create(\n LtoParticipantQueryBuilder.buildMarketingInput(shopId, campaign, dto),\n );\n return marketing._id;\n }\n\n public async removeMarketing(marketingId: mongoose.Types.ObjectId): Promise<void> {\n await marketingService.deleteById({_id: marketingId, softDelete: true});\n }\n\n public async removeAllCampaignMarketings(campaignId: mongoose.Types.ObjectId): Promise<void> {\n const marketingIds = await this.repository.findMarketingIdsByCampaign(campaignId);\n await marketingService.deleteManyByIds(marketingIds);\n }\n}\n\nexport const ltoParticipantMarketingService = Container.get(LtoParticipantMarketingService);\n"]}
1
+ {"version":3,"file":"limited-time-offer-participant-marketing.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,0DAA6D;AAG7D,sGAAqF;AACrF,4GAAsF;AAG/E,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAC/B,UAAU,CAA2B;IAE7C;QACI,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,oEAAwB,CAAC,CAAC;IAC9D,CAAC;IAEM,KAAK,CAAC,cAAc,CACvB,MAA+B,EAC/B,QAAmE,EACnE,GAAuB;QAEvB,MAAM,SAAS,GAAG,MAAM,2BAAgB,CAAC,MAAM,CAC3C,mEAA0B,CAAC,mBAAmB,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAC,CACxE,CAAC;QACF,OAAO,SAAS,CAAC,GAAG,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,WAAoC;QAC7D,MAAM,2BAAgB,CAAC,UAAU,CAAC,EAAC,GAAG,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAC,CAAC,CAAC;IAC5E,CAAC;IAEM,KAAK,CAAC,gBAAgB,CACzB,cAAuC,EACvC,MAA+B,EAC/B,QAAmE,EACnE,GAAuB;QAEvB,MAAM,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;IACtD,CAAC;IAEM,KAAK,CAAC,2BAA2B,CAAC,UAAmC;QACxE,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,0BAA0B,CAAC,UAAU,CAAC,CAAC;QAClF,MAAM,2BAAgB,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;IACzD,CAAC;CACJ,CAAA;AApCY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,gBAAO,GAAE;;GACG,8BAA8B,CAoC1C;AAEY,QAAA,8BAA8B,GAAG,gBAAS,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {marketingService} from '@modules/marketing/services';\nimport {LimitedTimeOfferCampaign} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {JoinLtoCampaignDTO} from '../limited-time-offer-participant.validation';\nimport {LtoParticipantQueryBuilder} from '../limited-time-offer-participant.builder';\nimport {LtoParticipantRepository} from '../limited-time-offer-participant.repository';\n\n@Service()\nexport class LtoParticipantMarketingService {\n private repository: LtoParticipantRepository;\n\n constructor() {\n this.repository = Container.get(LtoParticipantRepository);\n }\n\n public async applyMarketing(\n shopId: mongoose.Types.ObjectId,\n campaign: LimitedTimeOfferCampaign & {_id: mongoose.Types.ObjectId},\n dto: JoinLtoCampaignDTO,\n ): Promise<mongoose.Types.ObjectId> {\n const marketing = await marketingService.create(\n LtoParticipantQueryBuilder.buildMarketingInput(shopId, campaign, dto),\n );\n return marketing._id;\n }\n\n public async removeMarketing(marketingId: mongoose.Types.ObjectId): Promise<void> {\n await marketingService.deleteById({_id: marketingId, softDelete: true});\n }\n\n public async replaceMarketing(\n oldMarketingId: mongoose.Types.ObjectId,\n shopId: mongoose.Types.ObjectId,\n campaign: LimitedTimeOfferCampaign & {_id: mongoose.Types.ObjectId},\n dto: JoinLtoCampaignDTO,\n ): Promise<mongoose.Types.ObjectId> {\n await this.removeMarketing(oldMarketingId);\n return this.applyMarketing(shopId, campaign, dto);\n }\n\n public async removeAllCampaignMarketings(campaignId: mongoose.Types.ObjectId): Promise<void> {\n const marketingIds = await this.repository.findMarketingIdsByCampaign(campaignId);\n await marketingService.deleteManyByIds(marketingIds);\n }\n}\n\nexport const ltoParticipantMarketingService = Container.get(LtoParticipantMarketingService);\n"]}
@@ -9,6 +9,7 @@ export declare class LimitedTimeOfferParticipantService {
9
9
  join(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO): Promise<DocumentType<import("@lyxa.ai/core/dist/libraries/mongo/models").LimitedTimeOfferParticipant>>;
10
10
  withdraw(shopId: mongoose.Types.ObjectId): Promise<void>;
11
11
  getStatus(shopId: mongoose.Types.ObjectId): Promise<ParticipantStatusDTO>;
12
+ update(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO): Promise<DocumentType<import("@lyxa.ai/core/dist/libraries/mongo/models").LimitedTimeOfferParticipant> | null>;
12
13
  getParticipants(dto: GetLtoCampaignParticipantsDTO): Promise<{
13
14
  documents: {
14
15
  joinedAt: Date;
@@ -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,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAM5D,OAAO,EAAC,kBAAkB,EAAgB,oBAAoB,EAAC,MAAM,8CAA8C,CAAC;AAGpH,OAAO,EAAC,6BAA6B,EAAC,MAAM,uDAAuD,CAAC;AAEpG,qBACa,kCAAkC;IAC3C,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,eAAe,CAAqB;IAC5C,OAAO,CAAC,gBAAgB,CAAiC;;IAQ5C,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,kBAAkB;IAa7D,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAaxD,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAgBzE,eAAe,CAAC,GAAG,EAAE,6BAA6B;;;;;;;;;;;;;;;YAQjD,0BAA0B;YAQ1B,sBAAsB;IAMpC,OAAO,CAAC,0BAA0B;CAQrC;AAED,eAAO,MAAM,qBAAqB,oCAAoD,CAAC"}
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,CAAC;AAM5D,OAAO,EAAC,kBAAkB,EAAgB,oBAAoB,EAAC,MAAM,8CAA8C,CAAC;AAGpH,OAAO,EAAC,6BAA6B,EAAC,MAAM,uDAAuD,CAAC;AAEpG,qBACa,kCAAkC;IAC3C,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,eAAe,CAAqB;IAC5C,OAAO,CAAC,gBAAgB,CAAiC;;IAQ5C,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,kBAAkB;IAa7D,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAaxD,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAgBzE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,kBAAkB;IAuB/D,eAAe,CAAC,GAAG,EAAE,6BAA6B;;;;;;;;;;;;;;;YAQjD,0BAA0B;YAQ1B,sBAAsB;IAMpC,OAAO,CAAC,0BAA0B;CAQrC;AAED,eAAO,MAAM,qBAAqB,oCAAoD,CAAC"}
@@ -88,6 +88,25 @@ let LimitedTimeOfferParticipantService = class LimitedTimeOfferParticipantServic
88
88
  ? { campaignState: limited_time_offer_participant_validation_1.LtoCardState.JOINED, campaign: campaign, participant }
89
89
  : { campaignState: limited_time_offer_participant_validation_1.LtoCardState.LIVE, campaign: campaign };
90
90
  }
91
+ async update(shopId, dto) {
92
+ const campaign = await this.fetchActiveCampaignOrThrow();
93
+ const participant = await this.repository.findActiveForUpdate(campaign._id, shopId);
94
+ if (!participant)
95
+ throw (0, error_common_1.notFoundError)('You have not joined this campaign.');
96
+ this.validateDiscountSelections(campaign, dto.discountPercentage, dto.maxDiscountCap);
97
+ const newMarketingId = participant.marketingId
98
+ ? await this.marketingService.replaceMarketing(participant.marketingId, shopId, campaign, dto)
99
+ : await this.marketingService.applyMarketing(shopId, campaign, dto);
100
+ return this.repository.updateParticipant(campaign._id, shopId, {
101
+ products: dto.products ?? [],
102
+ isEntireMenu: dto.isEntireMenu,
103
+ discountPercentage: dto.discountPercentage,
104
+ maxDiscountCap: dto.maxDiscountCap,
105
+ isOrderCapacityEnabled: dto.isOrderCapacityEnabled,
106
+ maxOrderCapacity: dto.maxOrderCapacity,
107
+ marketing: newMarketingId,
108
+ });
109
+ }
91
110
  async getParticipants(dto) {
92
111
  const { documents, total } = await this.repository.findByCampaign(dto);
93
112
  return {
@@ -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,iDAA0C;AAG1C,4DAAiF;AACjF,4EAAwG;AACxG,2IAAqH;AACrH,yHAAkG;AAClG,4GAAoH;AACpH,sGAAqF;AACrF,4GAAsF;AAI/E,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IACnC,UAAU,CAA2B;IACrC,eAAe,CAAqB;IACpC,gBAAgB,CAAiC;IAEzD;QACI,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;IAC1E,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,MAA+B,EAAE,GAAuB;QACtE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,0BAA0B,EAAE,CAAC;QAEzD,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;QAEtF,MAAM,WAAW,GAAG,M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AAiE,CAAC,CAAC;QAC7F,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;YACrD,MAAM,IAAA,8BAAe,EAAC,yEAAyE,CAAC,CAAC;QACrG,CAAC;IACL,CAAC;CACJ,CAAA;AAnFY,gFAAkC;6CAAlC,kCAAkC;IAD9C,IAAA,gBAAO,GAAE;;GACG,kCAAkC,CAmF9C;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} 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 {JoinLtoCampaignDTO, LtoCardState, ParticipantStatusDTO} 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';\n\n@Service()\nexport class LimitedTimeOfferParticipantService {\n private repository: LtoParticipantRepository;\n private campaignService: LtoCampaignService;\n private marketingService: LtoParticipantMarketingService;\n\n constructor() {\n this.repository = Container.get(LtoParticipantRepository);\n this.campaignService = Container.get(LtoCampaignService);\n this.marketingService = Container.get(LtoParticipantMarketingService);\n }\n\n public async join(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO) {\n const campaign = await this.fetchActiveCampaignOrThrow();\n\n await this.assertNotAlreadyJoined(campaign._id, shopId);\n this.validateDiscountSelections(campaign, dto.discountPercentage, dto.maxDiscountCap);\n\n const marketingId = await this.marketingService.applyMarketing(shopId, campaign, dto);\n\n return this.repository.create(\n LtoParticipantQueryBuilder.buildCreateInput(campaign._id, shopId, marketingId, dto),\n );\n }\n\n public async withdraw(shopId: mongoose.Types.ObjectId): Promise<void> {\n const campaign = await this.fetchActiveCampaignOrThrow();\n\n const participant = await this.repository.withdraw(campaign._id, shopId);\n if (!participant) throw notFoundError('You have not joined this campaign.');\n\n if (participant.marketing) {\n await this.marketingService.removeMarketing(\n participant.marketing as mongoose.Types.ObjectId,\n );\n }\n }\n\n public async getStatus(shopId: mongoose.Types.ObjectId): Promise<ParticipantStatusDTO> {\n const campaign = await this.campaignService.getCurrent();\n\n if (!campaign) return {campaignState: LtoCardState.NONE};\n\n if (campaign.status === LimitedTimeOfferCampaignStatus.SCHEDULED) {\n return {campaignState: LtoCardState.SCHEDULED, campaign: campaign as any};\n }\n\n const participant = await this.repository.findActiveByCampaignAndShop(campaign._id, shopId);\n\n return participant\n ? {campaignState: LtoCardState.JOINED, campaign: campaign as any, participant}\n : {campaignState: LtoCardState.LIVE, campaign: campaign as any};\n }\n\n public async getParticipants(dto: GetLtoCampaignParticipantsDTO) {\n const {documents, total} = await this.repository.findByCampaign(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 private async fetchActiveCampaignOrThrow(): Promise<DocumentType<LimitedTimeOfferCampaign>> {\n const campaign = await this.campaignService.getCurrent();\n if (!campaign || campaign.status !== LimitedTimeOfferCampaignStatus.ACTIVE) {\n throw badRequestError('No active campaign is currently running.');\n }\n return campaign;\n }\n\n private async assertNotAlreadyJoined(campaignId: mongoose.Types.ObjectId, shopId: mongoose.Types.ObjectId): Promise<void> {\n if (await this.repository.existsActiveByCampaignAndShop(campaignId, shopId)) {\n throw conflictError('Your shop has already joined this campaign.');\n }\n }\n\n private validateDiscountSelections(campaign: DocumentType<LimitedTimeOfferCampaign>, discountPercentage: number, maxDiscountCap: number): void {\n if (!campaign.discountOptions.includes(discountPercentage)) {\n throw badRequestError('Selected discount is not an available option for this campaign.');\n }\n if (!campaign.maxDiscountCaps.includes(maxDiscountCap)) {\n throw badRequestError('Selected max discount cap is not an available option for this campaign.');\n }\n }\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,4GAAoH;AACpH,sGAAqF;AACrF,4GAAsF;AAI/E,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IACnC,UAAU,CAA2B;IACrC,eAAe,CAAqB;IACpC,gBAAgB,CAAiC;IAEzD;QACI,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;IAC1E,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,MAA+B,EAAE,GAAuB;QACtE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,0BAA0B,EAAE,CAAC;QAEzD,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;QAEtF,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC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AA1GY,gFAAkC;6CAAlC,kCAAkC;IAD9C,IAAA,gBAAO,GAAE;;GACG,kCAAkC,CA0G9C;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} 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 {JoinLtoCampaignDTO, LtoCardState, ParticipantStatusDTO} 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';\n\n@Service()\nexport class LimitedTimeOfferParticipantService {\n private repository: LtoParticipantRepository;\n private campaignService: LtoCampaignService;\n private marketingService: LtoParticipantMarketingService;\n\n constructor() {\n this.repository = Container.get(LtoParticipantRepository);\n this.campaignService = Container.get(LtoCampaignService);\n this.marketingService = Container.get(LtoParticipantMarketingService);\n }\n\n public async join(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO) {\n const campaign = await this.fetchActiveCampaignOrThrow();\n\n await this.assertNotAlreadyJoined(campaign._id, shopId);\n this.validateDiscountSelections(campaign, dto.discountPercentage, dto.maxDiscountCap);\n\n const marketingId = await this.marketingService.applyMarketing(shopId, campaign, dto);\n\n return this.repository.create(\n LtoParticipantQueryBuilder.buildCreateInput(campaign._id, shopId, marketingId, dto),\n );\n }\n\n public async withdraw(shopId: mongoose.Types.ObjectId): Promise<void> {\n const campaign = await this.fetchActiveCampaignOrThrow();\n\n const participant = await this.repository.withdraw(campaign._id, shopId);\n if (!participant) throw notFoundError('You have not joined this campaign.');\n\n if (participant.marketing) {\n await this.marketingService.removeMarketing(\n participant.marketing as mongoose.Types.ObjectId,\n );\n }\n }\n\n public async getStatus(shopId: mongoose.Types.ObjectId): Promise<ParticipantStatusDTO> {\n const campaign = await this.campaignService.getCurrent();\n\n if (!campaign) return {campaignState: LtoCardState.NONE};\n\n if (campaign.status === LimitedTimeOfferCampaignStatus.SCHEDULED) {\n return {campaignState: LtoCardState.SCHEDULED, campaign: campaign as any};\n }\n\n const participant = await this.repository.findActiveByCampaignAndShop(campaign._id, shopId);\n\n return participant\n ? {campaignState: LtoCardState.JOINED, campaign: campaign as any, participant}\n : {campaignState: LtoCardState.LIVE, campaign: campaign as any};\n }\n\n public async update(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO) {\n const campaign = await this.fetchActiveCampaignOrThrow();\n\n const participant = await this.repository.findActiveForUpdate(campaign._id, shopId);\n if (!participant) throw notFoundError('You have not joined this campaign.');\n\n this.validateDiscountSelections(campaign, dto.discountPercentage, dto.maxDiscountCap);\n\n const newMarketingId = participant.marketingId\n ? await this.marketingService.replaceMarketing(participant.marketingId, shopId, campaign, dto)\n : await this.marketingService.applyMarketing(shopId, campaign, dto);\n\n return this.repository.updateParticipant(campaign._id, shopId, {\n products: dto.products ?? [],\n isEntireMenu: dto.isEntireMenu,\n discountPercentage: dto.discountPercentage,\n maxDiscountCap: dto.maxDiscountCap,\n isOrderCapacityEnabled: dto.isOrderCapacityEnabled,\n maxOrderCapacity: dto.maxOrderCapacity,\n marketing: newMarketingId,\n });\n }\n\n public async getParticipants(dto: GetLtoCampaignParticipantsDTO) {\n const {documents, total} = await this.repository.findByCampaign(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 private async fetchActiveCampaignOrThrow(): Promise<DocumentType<LimitedTimeOfferCampaign>> {\n const campaign = await this.campaignService.getCurrent();\n if (!campaign || campaign.status !== LimitedTimeOfferCampaignStatus.ACTIVE) {\n throw badRequestError('No active campaign is currently running.');\n }\n return campaign;\n }\n\n private async assertNotAlreadyJoined(campaignId: mongoose.Types.ObjectId, shopId: mongoose.Types.ObjectId): Promise<void> {\n if (await this.repository.existsActiveByCampaignAndShop(campaignId, shopId)) {\n throw conflictError('Your shop has already joined this campaign.');\n }\n }\n\n private validateDiscountSelections(campaign: DocumentType<LimitedTimeOfferCampaign>, discountPercentage: number, maxDiscountCap: number): void {\n if (!campaign.discountOptions.includes(discountPercentage)) {\n throw badRequestError('Selected discount is not an available option for this campaign.');\n }\n if (!campaign.maxDiscountCaps.includes(maxDiscountCap)) {\n throw badRequestError('Selected max discount cap is not an available option for this campaign.');\n }\n }\n}\n\nexport const ltoParticipantService = Container.get(LimitedTimeOfferParticipantService);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"marketing.router.js","sourceRoot":"/","sources":["modules/marketing/routers/marketing.router.ts"],"names":[],"mappings":";;;AAAA,4DAAsF;AACtF,6EAAkG;AAClG,0DAA0E;AAC1E,0DAAoH;AACpH,gEAQwC;AACxC,oEAAiE;AACjE,wEAKiD;AACjD,8EAA0E;AAC1E,4DAAmE;AACnE,oDAAgD;AAChD,kGAA+F;AAElF,QAAA,eAAe,GAAG,IAAA,uBAAgB,EAAC;IAC/C,MAAM,EAAE,IAAA,mCAA4B,EAAC,EAAE,WAAW,EAAE,CAAC,qBAAc,CAAC,GAAG,EAAE,qBAAc,CAAC,MAAM,CAAC,EAAE,CAAC;SAChG,KAAK,CAAC,2CAA6B,CAAC;SACpC,MAAM,CAAC,qCAAc,CAAC;SACtB,QAAQ,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAClC,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,IA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GAAG,MAAM,uDAA0B,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAC3E,OAAO,IAAA,mBAAQ,EAAC,wDAAwD,EAAE,MAAM,CAAC,CAAC;IACnF,CAAC,CAAC,CACF;IAED,yBAAyB,EAAE,IAAA,mCAA4B,EAAC,EAAE,WAAW,EAAE,CAAC,qBAAc,CAAC,GAAG,CAAC,EAAE,CAAC;SAC5F,KAAK,CAAC,qBAAQ,CAAC;SACf,MAAM,CAAC,qCAAc,CAAC;SACtB,QAAQ,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAC7B,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,2BAAO,CAAC,yBAAyB,CAAC,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5E,OAAO,IAAA,mBAAQ,EAAC,sDAAsD,CAAC,CAAC;IACzE,CAAC,CAAC,CACF;CACF,CAAC,CAAC","sourcesContent":["import { createTRPCRouter, publicProcedure } from '@lyxa.ai/core/dist/libraries/trpc';\nimport { createAuthenticatedProcedure } from '@lyxa.ai/core/dist/libraries/trpc/middlewares/auth';\nimport { marketingService as service } from '@modules/marketing/services';\nimport { synchronizeProductMarketingService as syncMarketingProductInfoService } from '@modules/marketing/services';\nimport {\n\tAllMarketingsValidationSchema,\n\tMarketingResponseSchema as ResponseSchema,\n\tAllMarketingsUpdateSchema,\n\tProductEntireMenuMarketingHandlerSchema,\n\tMarketingSpendLimitsEvaluationSchema,\n\tSyncProductMarketingForMultipleProductsSchema,\n\tMarketingGraphInputSchema,\n} from '@modules/marketing/validations';\nimport { response } from '@lyxa.ai/core/dist/utilities/response';\nimport {\n\tFilterSchema,\n\tDeleteSchema,\n\tGetByIdInputSchema,\n\tIdSchema,\n} from '@lyxa.ai/core/dist/utilities/validation';\nimport { ErrorHandler } from '@lyxa.ai/core/dist/utilities/error-handler';\nimport { AuthEntityType } from '@lyxa.ai/core/dist/libraries/auth';\nimport { mongoose } from '@typegoose/typegoose';\nimport { marketingMetricsRepository } from '../patterns/repository/MarketingMetricsRepository';\n\nexport const marketingRouter = createTRPCRouter({\n\tcreate: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM, AuthEntityType.SELLER] })\n\t\t.input(AllMarketingsValidationSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst isAdmin = ctx.entity?.type == AuthEntityType.CRM;\n\t\t\t\tawait service.create(input, isAdmin ? new mongoose.Types.ObjectId(ctx.entity?.id) : undefined);\n\t\t\t\treturn response('Marketing created successfully');\n\t\t\t})\n\t\t),\n\n\tgetById: publicProcedure.input(GetByIdInputSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.findById(input);\n\t\t\treturn response('Marketing fetched successfully', result);\n\t\t})\n\t),\n\n\tget: publicProcedure.input(FilterSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.find(input);\n\t\t\treturn response('Marketing fetched successfully', result);\n\t\t})\n\t),\n\n\tupdate: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM, AuthEntityType.SELLER] })\n\t\t.input(AllMarketingsUpdateSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst { _id, ...rest } = input;\n\t\t\t\tconst isAdmin = ctx.entity?.type == AuthEntityType.CRM;\n\n\t\t\t\tawait service.update(_id, rest, isAdmin ? new mongoose.Types.ObjectId(ctx.entity?.id) : undefined);\n\t\t\t\treturn response('Marketing updated successfully');\n\t\t\t})\n\t\t),\n\n\tdeleteById: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM, AuthEntityType.SELLER] })\n\t\t.input(DeleteSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst isAdmin = ctx.entity?.type == AuthEntityType.CRM;\n\t\t\t\tawait service.deleteById(input, isAdmin ? new mongoose.Types.ObjectId(ctx.entity?.id) : undefined);\n\t\t\t\treturn response('Marketing deleted successfully');\n\t\t\t})\n\t\t),\n\n\thandleNewProductForEntireMenuMarketing: publicProcedure\n\t\t.input(ProductEntireMenuMarketingHandlerSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tawait service.handleNewProductForEntireMenuMarketing(input);\n\t\t\t\treturn response('Product handled successfully');\n\t\t\t})\n\t\t),\n\n\tsyncAllProductsMarketingInfo: publicProcedure.query(async ({}) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\treturn await syncMarketingProductInfoService.publishAllProductsProductMarketingInfoProcessEvent();\n\t\t})\n\t),\n\n\tsyncAllProductsMarketingInfoLocal: publicProcedure.mutation(async ({}) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\treturn await syncMarketingProductInfoService.syncAllProductsMarketingInfo();\n\t\t})\n\t),\n\n\t// DEV purpose only\n\tsyncProductMarketingInfoByProductId: publicProcedure.query(async ({}) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst productId = new mongoose.Types.ObjectId('68f663c355f42c826a129fc6'); // Todo: use productId sent from param\n\t\t\treturn await syncMarketingProductInfoService.syncProductMarketingInfoByProductId(productId);\n\t\t})\n\t),\n\n\tsyncProductMarketingInfoByProductIds: publicProcedure\n\t\t.input(SyncProductMarketingForMultipleProductsSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\treturn await syncMarketingProductInfoService.syncProductMarketingInfoByProductIds(input.productIds);\n\t\t\t})\n\t\t),\n\n\tcalculateMarketingSpent: publicProcedure.input(IdSchema).mutation(async ({ ctx, input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await marketingMetricsRepository.calculateMarketingSpent(input);\n\t\t\treturn response('Marketing amount spent calculated successfully', result);\n\t\t})\n\t),\n\n\tincrementMarketingSpentFromOrder: publicProcedure.input(IdSchema).mutation(async ({ ctx, input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.incrementMarketingSpentFromOrder(input);\n\t\t\treturn response('Marketing amount spent incremented successfully', result);\n\t\t})\n\t),\n\n\tdecrementMarketingSpentFromOrder: publicProcedure.input(IdSchema).mutation(async ({ ctx, input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.decrementMarketingSpentFromOrder(input);\n\t\t\treturn response('Marketing amount spent decremented successfully', result);\n\t\t})\n\t),\n\n\trecomputeAndSyncAllMarketingSpent: publicProcedure.mutation(async ({}) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.recomputeAndSyncAllMarketingSpent();\n\t\t\treturn response('Marketing amount spent recomputed and synced successfully', result);\n\t\t})\n\t),\n\n\tgetMetrics: publicProcedure.input(IdSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await marketingMetricsRepository.getMetrics(input);\n\t\t\treturn response('Marketing metrics fetched successfully', result);\n\t\t})\n\t),\n\n\tgetOrdersGraph: publicProcedure.input(MarketingGraphInputSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await marketingMetricsRepository.getOrdersGraph(input);\n\t\t\treturn response('Marketing orders graph data fetched successfully', result);\n\t\t})\n\t),\n\n\tgetCustomersGraph: publicProcedure.input(MarketingGraphInputSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await marketingMetricsRepository.getCustomersGraph(input);\n\t\t\treturn response('Marketing customers graph data fetched successfully', result);\n\t\t})\n\t),\n\n\tgetAmountSpentGraph: publicProcedure.input(MarketingGraphInputSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await marketingMetricsRepository.getAmountSpentGraph(input);\n\t\t\treturn response('Marketing amount spent graph data fetched successfully', result);\n\t\t})\n\t),\n\n\treseedEntireMenuMarketing: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n\t\t.input(IdSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tawait service.reseedEntireMenuMarketing(new mongoose.Types.ObjectId(input));\n\t\t\t\treturn response('Entire menu marketing reseed dispatched successfully');\n\t\t\t})\n\t\t),\n});\n"]}
1
+ {"version":3,"file":"marketing.router.js","sourceRoot":"/","sources":["modules/marketing/routers/marketing.router.ts"],"names":[],"mappings":";;;AAAA,4DAAsF;AACtF,6EAAkG;AAClG,0DAA0E;AAC1E,0DAAoH;AACpH,gEAQwC;AACxC,oEAAiE;AACjE,wEAKiD;AACjD,8EAA0E;AAC1E,4DAAmE;AACnE,oDAAgD;AAChD,kGAA+F;AAElF,QAAA,eAAe,GAAG,IAAA,uBAAgB,EAAC;IAC/C,MAAM,EAAE,IAAA,mCAA4B,EAAC,EAAE,WAAW,EAAE,CAAC,qBAAc,CAAC,GAAG,EAAE,qBAAc,CAAC,MAAM,CAAC,EAAE,CAAC;SAChG,KAAK,CAAC,2CAA6B,CAAC;SACpC,MAAM,CAAC,qCAAc,CAAC;SACtB,QAAQ,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAClC,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,IAAI,IAAI,qBAAc,CAAC,GAAG,CAAC;QACvD,MAAM,2BAAO,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,M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IAAA,mCAA4B,EAAC,EAAE,WAAW,EAAE,CAAC,qBAAc,CAAC,GAAG,CAAC,EAAE,CAAC;SAC5F,KAAK,CAAC,qBAAQ,CAAC;SACf,MAAM,CAAC,qCAAc,CAAC;SACtB,QAAQ,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAC7B,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,2BAAO,CAAC,yBAAyB,CAAC,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5E,OAAO,IAAA,mBAAQ,EAAC,sDAAsD,CAAC,CAAC;IACzE,CAAC,CAAC,CACF;CACF,CAAC,CAAC","sourcesContent":["import { createTRPCRouter, publicProcedure } from '@lyxa.ai/core/dist/libraries/trpc';\nimport { createAuthenticatedProcedure } from '@lyxa.ai/core/dist/libraries/trpc/middlewares/auth';\nimport { marketingService as service } from '@modules/marketing/services';\nimport { synchronizeProductMarketingService as syncMarketingProductInfoService } from '@modules/marketing/services';\nimport {\n\tAllMarketingsValidationSchema,\n\tMarketingResponseSchema as ResponseSchema,\n\tAllMarketingsUpdateSchema,\n\tProductEntireMenuMarketingHandlerSchema,\n\tMarketingSpendLimitsEvaluationSchema,\n\tSyncProductMarketingForMultipleProductsSchema,\n\tMarketingGraphInputSchema,\n} from '@modules/marketing/validations';\nimport { response } from '@lyxa.ai/core/dist/utilities/response';\nimport {\n\tFilterSchema,\n\tDeleteSchema,\n\tGetByIdInputSchema,\n\tIdSchema,\n} from '@lyxa.ai/core/dist/utilities/validation';\nimport { ErrorHandler } from '@lyxa.ai/core/dist/utilities/error-handler';\nimport { AuthEntityType } from '@lyxa.ai/core/dist/libraries/auth';\nimport { mongoose } from '@typegoose/typegoose';\nimport { marketingMetricsRepository } from '../patterns/repository/MarketingMetricsRepository';\n\nexport const marketingRouter = createTRPCRouter({\n\tcreate: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM, AuthEntityType.SELLER] })\n\t\t.input(AllMarketingsValidationSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst isAdmin = ctx.entity?.type == AuthEntityType.CRM;\n\t\t\t\tawait service.create(input, isAdmin ? new mongoose.Types.ObjectId(ctx.entity?.id) : undefined);\n\t\t\t\treturn response('Marketing created successfully');\n\t\t\t})\n\t\t),\n\n\tgetById: publicProcedure.input(GetByIdInputSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.findById(input);\n\t\t\treturn response('Marketing fetched successfully', result);\n\t\t})\n\t),\n\n\tget: publicProcedure.input(FilterSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.find(input);\n\t\t\treturn response('Marketing fetched successfully', result);\n\t\t})\n\t),\n\n\tupdate: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM, AuthEntityType.SELLER] })\n\t\t.input(AllMarketingsUpdateSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst { _id, ...rest } = input;\n\t\t\t\tconst isAdmin = ctx.entity?.type == AuthEntityType.CRM;\n\n\t\t\t\tawait service.update(_id, rest, isAdmin ? new mongoose.Types.ObjectId(ctx.entity?.id) : undefined);\n\t\t\t\treturn response('Marketing updated successfully');\n\t\t\t})\n\t\t),\n\n\tdeleteById: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM, AuthEntityType.SELLER] })\n\t\t.input(DeleteSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst isAdmin = ctx.entity?.type == AuthEntityType.CRM;\n\t\t\t\tawait service.deleteById(input, isAdmin ? new mongoose.Types.ObjectId(ctx.entity?.id) : undefined);\n\t\t\t\treturn response('Marketing deleted successfully');\n\t\t\t})\n\t\t),\n\n\thandleNewProductForEntireMenuMarketing: publicProcedure\n\t\t.input(ProductEntireMenuMarketingHandlerSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tawait service.handleNewProductForEntireMenuMarketing(input);\n\t\t\t\treturn response('Product handled successfully');\n\t\t\t})\n\t\t),\n\n\tsyncAllProductsMarketingInfo: publicProcedure.query(async ({}) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\treturn await syncMarketingProductInfoService.publishAllProductsProductMarketingInfoProcessEvent();\n\t\t})\n\t),\n\n\tsyncAllProductsMarketingInfoLocal: publicProcedure.mutation(async ({}) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\treturn await syncMarketingProductInfoService.syncAllProductsMarketingInfo();\n\t\t})\n\t),\n\n\t// DEV purpose only\n\tsyncProductMarketingInfoByProductId: publicProcedure.query(async ({}) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst productId = new mongoose.Types.ObjectId('68f663c355f42c826a129fc6'); // Todo: use productId sent from param\n\t\t\treturn await syncMarketingProductInfoService.syncProductMarketingInfoByProductId(productId);\n\t\t})\n\t),\n\n\tsyncProductMarketingInfoByProductIds: publicProcedure\n\t\t.input(SyncProductMarketingForMultipleProductsSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\treturn await syncMarketingProductInfoService.syncProductMarketingInfoByProductIds(input.productIds);\n\t\t\t})\n\t\t),\n\n\tcalculateMarketingSpent: publicProcedure.input(IdSchema).mutation(async ({ ctx, input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await marketingMetricsRepository.calculateMarketingSpent(input);\n\t\t\treturn response('Marketing amount spent calculated successfully', result);\n\t\t})\n\t),\n\n\tincrementMarketingSpentFromOrder: publicProcedure.input(IdSchema).mutation(async ({ ctx, input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.incrementMarketingSpentFromOrder(input);\n\t\t\treturn response('Marketing amount spent incremented successfully', result);\n\t\t})\n\t),\n\n\tdecrementMarketingSpentFromOrder: publicProcedure.input(IdSchema).mutation(async ({ ctx, input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.decrementMarketingSpentFromOrder(input);\n\t\t\treturn response('Marketing amount spent decremented successfully', result);\n\t\t})\n\t),\n\n\trecomputeAndSyncAllMarketingSpent: publicProcedure.mutation(async ({}) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.recomputeAndSyncAllMarketingSpent();\n\t\t\treturn response('Marketing amount spent recomputed and synced successfully', result);\n\t\t})\n\t),\n \n\tgetMetrics: publicProcedure.input(IdSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await marketingMetricsRepository.getMetrics(input);\n\t\t\treturn response('Marketing metrics fetched successfully', result);\n\t\t})\n\t),\n \n\tgetOrdersGraph: publicProcedure.input(MarketingGraphInputSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await marketingMetricsRepository.getOrdersGraph(input);\n\t\t\treturn response('Marketing orders graph data fetched successfully', result);\n\t\t})\n\t),\n\n\tgetCustomersGraph: publicProcedure.input(MarketingGraphInputSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await marketingMetricsRepository.getCustomersGraph(input);\n\t\t\treturn response('Marketing customers graph data fetched successfully', result);\n\t\t})\n\t),\n\n\tgetAmountSpentGraph: publicProcedure.input(MarketingGraphInputSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await marketingMetricsRepository.getAmountSpentGraph(input);\n\t\t\treturn response('Marketing amount spent graph data fetched successfully', result);\n\t\t})\n\t),\n\n\treseedEntireMenuMarketing: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n\t\t.input(IdSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tawait service.reseedEntireMenuMarketing(new mongoose.Types.ObjectId(input));\n\t\t\t\treturn response('Entire menu marketing reseed dispatched successfully');\n\t\t\t})\n\t\t),\n});\n"]}
@@ -20,6 +20,7 @@ export declare class PunchMarketingHistoryService {
20
20
  applyPunchDiscountToOrder(userId: mongoose.Types.ObjectId, orderId: mongoose.Types.ObjectId): Promise<void>;
21
21
  getPunchDiscount(data: ValidateCouponDTO): Promise<CouponValidationOutputDTO>;
22
22
  getPunchCoupon(user: mongoose.Types.ObjectId, shop: mongoose.Types.ObjectId): Promise<any>;
23
+ returnPunchCoupon(orderId: mongoose.Types.ObjectId): Promise<void>;
23
24
  }
24
25
  export declare const punchMarketingHistoryService: PunchMarketingHistoryService;
25
26
  //# sourceMappingURL=punch-marketing-history.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"punch-marketing-history.service.d.ts","sourceRoot":"/","sources":["modules/punch-marketing-history/services/punch-marketing-history.service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAmB,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAElG,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAEN,qBAAqB,IAAI,KAAK,EAK9B,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACN,8BAA8B,IAAI,SAAS,EAC3C,mBAAmB,EACnB,8BAA8B,IAAI,SAAS,EAC3C,MAAM,8CAA8C,CAAC;AAWtD,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAO3F,qBACa,4BAA4B;IACxC,OAAO,CAAC,KAAK,CAA6D;IAC1E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 {"version":3,"file":"punch-marketing-history.service.d.ts","sourceRoot":"/","sources":["modules/punch-marketing-history/services/punch-marketing-history.service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAmB,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAElG,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAEN,qBAAqB,IAAI,KAAK,EAK9B,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACN,8BAA8B,IAAI,SAAS,EAC3C,mBAAmB,EACnB,8BAA8B,IAAI,SAAS,EAC3C,MAAM,8CAA8C,CAAC;AAWtD,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAO3F,qBACa,4BAA4B;IACxC,OAAO,CAAC,KAAK,CAA6D;IAC1E,OAAO,CAAC,cAAc,CAA+D;IACrF,OAAO,CAAC,UAAU,CAA2D;;IAYhE,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAQrD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAkB5E,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,YAAY,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAyB3F,gBAAgB,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC;IAuCzD,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IA2BjE,UAAU,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;IAmB5C,oBAAoB,CAChC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAC9B,OAAO,CAAC,MAAM,CAAC;YA0DJ,gBAAgB;IA+CjB,yBAAyB,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ;IA0C3F,gBAAgB,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,yBAAyB,CAAC;IA2D7E,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IA6C1F,iBAAiB,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAkB/E;AAED,eAAO,MAAM,4BAA4B,8BAA8C,CAAC"}
@@ -362,6 +362,20 @@ let PunchMarketingHistoryService = class PunchMarketingHistoryService {
362
362
  };
363
363
  return punchCoupon;
364
364
  }
365
+ async returnPunchCoupon(orderId) {
366
+ await this.model.findOneAndUpdate({
367
+ order: orderId,
368
+ status: enum_1.PunchMarketingStatus.COUPON_USED,
369
+ }, {
370
+ $set: {
371
+ status: enum_1.PunchMarketingStatus.COMPLETED,
372
+ order: null,
373
+ },
374
+ }, {
375
+ new: true,
376
+ runValidators: true,
377
+ });
378
+ }
365
379
  };
366
380
  exports.PunchMarketingHistoryService = PunchMarketingHistoryService;
367
381
  exports.PunchMarketingHistoryService = PunchMarketingHistoryService = __decorate([