@lyxa.ai/marketing 1.0.43 → 1.0.46

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 (156) 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 +162 -22
  9. package/dist/lib/index.d.ts.map +1 -1
  10. package/dist/lib/modules/coupon/routers/coupon.router.d.ts +103 -21
  11. package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
  12. package/dist/lib/modules/coupon/routers/coupon.router.js +1 -1
  13. package/dist/lib/modules/coupon/routers/coupon.router.js.map +1 -1
  14. package/dist/lib/modules/coupon/services/coupon.service.d.ts +3 -1
  15. package/dist/lib/modules/coupon/services/coupon.service.d.ts.map +1 -1
  16. package/dist/lib/modules/coupon/services/coupon.service.js +33 -12
  17. package/dist/lib/modules/coupon/services/coupon.service.js.map +1 -1
  18. package/dist/lib/modules/coupon/services/custom-coupon.service.d.ts +208 -3
  19. package/dist/lib/modules/coupon/services/custom-coupon.service.d.ts.map +1 -1
  20. package/dist/lib/modules/coupon/services/global-coupon.service.d.ts.map +1 -1
  21. package/dist/lib/modules/coupon/services/global-coupon.service.js +2 -0
  22. package/dist/lib/modules/coupon/services/global-coupon.service.js.map +1 -1
  23. package/dist/lib/modules/coupon/services/helper.service.d.ts +214 -4
  24. package/dist/lib/modules/coupon/services/helper.service.d.ts.map +1 -1
  25. package/dist/lib/modules/coupon/services/helper.service.js +114 -16
  26. package/dist/lib/modules/coupon/services/helper.service.js.map +1 -1
  27. package/dist/lib/modules/coupon/services/individual-store-coupon.service.d.ts +208 -3
  28. package/dist/lib/modules/coupon/services/individual-store-coupon.service.d.ts.map +1 -1
  29. package/dist/lib/modules/coupon/services/individual-user-coupon.service.d.ts +1 -1
  30. package/dist/lib/modules/coupon/services/individual-user-coupon.service.d.ts.map +1 -1
  31. package/dist/lib/modules/coupon/services/individual-user-coupon.service.js +20 -11
  32. package/dist/lib/modules/coupon/services/individual-user-coupon.service.js.map +1 -1
  33. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
  34. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js +3 -5
  35. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js.map +1 -1
  36. package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.d.ts +2 -2
  37. package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.d.ts.map +1 -1
  38. package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.js +151 -45
  39. package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.js.map +1 -1
  40. package/dist/lib/modules/coupon/services/referral-reward-coupon.service.d.ts.map +1 -1
  41. package/dist/lib/modules/coupon/services/referral-reward-coupon.service.js +2 -0
  42. package/dist/lib/modules/coupon/services/referral-reward-coupon.service.js.map +1 -1
  43. package/dist/lib/modules/coupon/services/shops-categories-coupon.service.d.ts +208 -3
  44. package/dist/lib/modules/coupon/services/shops-categories-coupon.service.d.ts.map +1 -1
  45. package/dist/lib/modules/coupon/transformers/coupon.transformer.d.ts +5 -1
  46. package/dist/lib/modules/coupon/transformers/coupon.transformer.d.ts.map +1 -1
  47. package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts +243 -23
  48. package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
  49. package/dist/lib/modules/coupon/validations/coupon.validation.d.ts +82 -17
  50. package/dist/lib/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
  51. package/dist/lib/modules/coupon/validations/coupon.validation.js +25 -3
  52. package/dist/lib/modules/coupon/validations/coupon.validation.js.map +1 -1
  53. package/dist/lib/modules/coupon/validations/create-coupon.validation.d.ts +94 -6
  54. package/dist/lib/modules/coupon/validations/create-coupon.validation.d.ts.map +1 -1
  55. package/dist/lib/modules/coupon/validations/custom-coupon.validation.d.ts +9 -0
  56. package/dist/lib/modules/coupon/validations/custom-coupon.validation.d.ts.map +1 -1
  57. package/dist/lib/modules/coupon/validations/custom-coupon.validation.js +1 -0
  58. package/dist/lib/modules/coupon/validations/custom-coupon.validation.js.map +1 -1
  59. package/dist/lib/modules/coupon/validations/individual-store-coupon.validation.d.ts +200 -122
  60. package/dist/lib/modules/coupon/validations/individual-store-coupon.validation.d.ts.map +1 -1
  61. package/dist/lib/modules/coupon/validations/individual-store-coupon.validation.js +20 -3
  62. package/dist/lib/modules/coupon/validations/individual-store-coupon.validation.js.map +1 -1
  63. package/dist/lib/modules/coupon/validations/individual-user-coupon.validation.d.ts +9 -0
  64. package/dist/lib/modules/coupon/validations/individual-user-coupon.validation.d.ts.map +1 -1
  65. package/dist/lib/modules/coupon/validations/individual-user-coupon.validation.js +1 -0
  66. package/dist/lib/modules/coupon/validations/individual-user-coupon.validation.js.map +1 -1
  67. package/dist/lib/modules/coupon/validations/shops-categories-coupon.validation.d.ts +9 -0
  68. package/dist/lib/modules/coupon/validations/shops-categories-coupon.validation.d.ts.map +1 -1
  69. package/dist/lib/modules/coupon/validations/shops-categories-coupon.validation.js +1 -0
  70. package/dist/lib/modules/coupon/validations/shops-categories-coupon.validation.js.map +1 -1
  71. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts +58 -0
  72. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
  73. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +4 -1
  74. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
  75. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js +18 -2
  76. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js.map +1 -1
  77. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +58 -0
  78. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
  79. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.js +7 -0
  80. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.js.map +1 -1
  81. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +137 -3
  82. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
  83. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js +11 -9
  84. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js.map +1 -1
  85. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts +3 -0
  86. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts.map +1 -1
  87. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.js +4 -0
  88. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.js.map +1 -1
  89. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +1 -0
  90. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  91. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js +19 -0
  92. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js.map +1 -1
  93. package/dist/lib/modules/marketing/routers/marketing.router.js.map +1 -1
  94. package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +1 -1
  95. package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts +1 -0
  96. package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts.map +1 -1
  97. package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.js +14 -0
  98. package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.js.map +1 -1
  99. package/dist/lib/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +2 -2
  100. package/dist/types/event/event-initializations.d.ts.map +1 -1
  101. package/dist/types/event/event-listeners/event-listeners.d.ts +1 -0
  102. package/dist/types/event/event-listeners/event-listeners.d.ts.map +1 -1
  103. package/dist/types/index.d.ts +162 -22
  104. package/dist/types/index.d.ts.map +1 -1
  105. package/dist/types/modules/coupon/routers/coupon.router.d.ts +103 -21
  106. package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
  107. package/dist/types/modules/coupon/services/coupon.service.d.ts +3 -1
  108. package/dist/types/modules/coupon/services/coupon.service.d.ts.map +1 -1
  109. package/dist/types/modules/coupon/services/custom-coupon.service.d.ts +208 -3
  110. package/dist/types/modules/coupon/services/custom-coupon.service.d.ts.map +1 -1
  111. package/dist/types/modules/coupon/services/global-coupon.service.d.ts.map +1 -1
  112. package/dist/types/modules/coupon/services/helper.service.d.ts +214 -4
  113. package/dist/types/modules/coupon/services/helper.service.d.ts.map +1 -1
  114. package/dist/types/modules/coupon/services/individual-store-coupon.service.d.ts +208 -3
  115. package/dist/types/modules/coupon/services/individual-store-coupon.service.d.ts.map +1 -1
  116. package/dist/types/modules/coupon/services/individual-user-coupon.service.d.ts +1 -1
  117. package/dist/types/modules/coupon/services/individual-user-coupon.service.d.ts.map +1 -1
  118. package/dist/types/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
  119. package/dist/types/modules/coupon/services/patterns/repository/CouponRepository.d.ts +2 -2
  120. package/dist/types/modules/coupon/services/patterns/repository/CouponRepository.d.ts.map +1 -1
  121. package/dist/types/modules/coupon/services/referral-reward-coupon.service.d.ts.map +1 -1
  122. package/dist/types/modules/coupon/services/shops-categories-coupon.service.d.ts +208 -3
  123. package/dist/types/modules/coupon/services/shops-categories-coupon.service.d.ts.map +1 -1
  124. package/dist/types/modules/coupon/transformers/coupon.transformer.d.ts +5 -1
  125. package/dist/types/modules/coupon/transformers/coupon.transformer.d.ts.map +1 -1
  126. package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts +243 -23
  127. package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
  128. package/dist/types/modules/coupon/validations/coupon.validation.d.ts +82 -17
  129. package/dist/types/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
  130. package/dist/types/modules/coupon/validations/create-coupon.validation.d.ts +94 -6
  131. package/dist/types/modules/coupon/validations/create-coupon.validation.d.ts.map +1 -1
  132. package/dist/types/modules/coupon/validations/custom-coupon.validation.d.ts +9 -0
  133. package/dist/types/modules/coupon/validations/custom-coupon.validation.d.ts.map +1 -1
  134. package/dist/types/modules/coupon/validations/individual-store-coupon.validation.d.ts +200 -122
  135. package/dist/types/modules/coupon/validations/individual-store-coupon.validation.d.ts.map +1 -1
  136. package/dist/types/modules/coupon/validations/individual-user-coupon.validation.d.ts +9 -0
  137. package/dist/types/modules/coupon/validations/individual-user-coupon.validation.d.ts.map +1 -1
  138. package/dist/types/modules/coupon/validations/shops-categories-coupon.validation.d.ts +9 -0
  139. package/dist/types/modules/coupon/validations/shops-categories-coupon.validation.d.ts.map +1 -1
  140. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts +58 -0
  141. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
  142. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +4 -1
  143. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
  144. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +58 -0
  145. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
  146. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +137 -3
  147. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
  148. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts +3 -0
  149. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts.map +1 -1
  150. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +1 -0
  151. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  152. package/dist/types/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +1 -1
  153. package/dist/types/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts +1 -0
  154. package/dist/types/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts.map +1 -1
  155. package/dist/types/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +2 -2
  156. package/package.json +2 -2
@@ -5,6 +5,7 @@ declare const ShopsCategoriesCouponValidationSchema: z.ZodObject<{
5
5
  couponType: z.ZodLiteral<CouponType.SHOPS_CATEGORIES>;
6
6
  itemTypes: z.ZodDefault<z.ZodArray<z.ZodNativeEnum<typeof ItemType>, "many">>;
7
7
  shops: 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">>;
8
+ vendors: 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">>;
8
9
  isShopCoverExpenses: z.ZodDefault<z.ZodBoolean>;
9
10
  firstOrderOnly: z.ZodDefault<z.ZodBoolean>;
10
11
  valueType: z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").ValueType>;
@@ -75,6 +76,7 @@ declare const ShopsCategoriesCouponValidationSchema: z.ZodObject<{
75
76
  couponType: CouponType.SHOPS_CATEGORIES;
76
77
  itemTypes: ItemType[];
77
78
  shops: import("mongoose").Types.ObjectId[];
79
+ vendors: import("mongoose").Types.ObjectId[];
78
80
  isShopCoverExpenses: boolean;
79
81
  firstOrderOnly: boolean;
80
82
  secondaryCurrencyValue?: number | undefined;
@@ -117,12 +119,14 @@ declare const ShopsCategoriesCouponValidationSchema: z.ZodObject<{
117
119
  isExpired?: boolean | undefined;
118
120
  itemTypes?: ItemType[] | undefined;
119
121
  shops?: (string | import("mongoose").Types.ObjectId)[] | undefined;
122
+ vendors?: (string | import("mongoose").Types.ObjectId)[] | undefined;
120
123
  isShopCoverExpenses?: boolean | undefined;
121
124
  firstOrderOnly?: boolean | undefined;
122
125
  }>, ShopsCategoriesCouponSchema: z.ZodObject<{
123
126
  couponType: z.ZodOptional<z.ZodLiteral<CouponType.SHOPS_CATEGORIES>>;
124
127
  itemTypes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodNativeEnum<typeof ItemType>, "many">>>;
125
128
  shops: z.ZodOptional<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">>>;
129
+ vendors: z.ZodOptional<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">>>;
126
130
  isShopCoverExpenses: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
127
131
  firstOrderOnly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
128
132
  valueType: z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").ValueType>>;
@@ -174,6 +178,7 @@ declare const ShopsCategoriesCouponValidationSchema: z.ZodObject<{
174
178
  couponType: z.ZodOptional<z.ZodLiteral<CouponType.SHOPS_CATEGORIES>>;
175
179
  itemTypes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodNativeEnum<typeof ItemType>, "many">>>;
176
180
  shops: z.ZodOptional<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">>>;
181
+ vendors: z.ZodOptional<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">>>;
177
182
  isShopCoverExpenses: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
178
183
  firstOrderOnly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
179
184
  valueType: z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").ValueType>>;
@@ -225,6 +230,7 @@ declare const ShopsCategoriesCouponValidationSchema: z.ZodObject<{
225
230
  couponType: z.ZodOptional<z.ZodLiteral<CouponType.SHOPS_CATEGORIES>>;
226
231
  itemTypes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodNativeEnum<typeof ItemType>, "many">>>;
227
232
  shops: z.ZodOptional<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">>>;
233
+ vendors: z.ZodOptional<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">>>;
228
234
  isShopCoverExpenses: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
229
235
  firstOrderOnly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
230
236
  valueType: z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").ValueType>>;
@@ -282,6 +288,7 @@ declare const ShopsCategoriesCouponValidationSchema: z.ZodObject<{
282
288
  couponType: z.ZodOptional<z.ZodLiteral<CouponType.SHOPS_CATEGORIES>>;
283
289
  itemTypes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodNativeEnum<typeof ItemType>, "many">>>;
284
290
  shops: z.ZodOptional<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">>>;
291
+ vendors: z.ZodOptional<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">>>;
285
292
  isShopCoverExpenses: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
286
293
  firstOrderOnly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
287
294
  valueType: z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").ValueType>>;
@@ -333,6 +340,7 @@ declare const ShopsCategoriesCouponValidationSchema: z.ZodObject<{
333
340
  couponType: z.ZodOptional<z.ZodLiteral<CouponType.SHOPS_CATEGORIES>>;
334
341
  itemTypes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodNativeEnum<typeof ItemType>, "many">>>;
335
342
  shops: z.ZodOptional<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">>>;
343
+ vendors: z.ZodOptional<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">>>;
336
344
  isShopCoverExpenses: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
337
345
  firstOrderOnly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
338
346
  valueType: z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").ValueType>>;
@@ -384,6 +392,7 @@ declare const ShopsCategoriesCouponValidationSchema: z.ZodObject<{
384
392
  couponType: z.ZodOptional<z.ZodLiteral<CouponType.SHOPS_CATEGORIES>>;
385
393
  itemTypes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodNativeEnum<typeof ItemType>, "many">>>;
386
394
  shops: z.ZodOptional<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">>>;
395
+ vendors: z.ZodOptional<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">>>;
387
396
  isShopCoverExpenses: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
388
397
  firstOrderOnly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
389
398
  valueType: z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").ValueType>>;
@@ -1 +1 @@
1
- {"version":3,"file":"shops-categories-coupon.validation.d.ts","sourceRoot":"/","sources":["modules/coupon/validations/shops-categories-coupon.validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAGN,GAAG,EACH,MAAM,2DAA2D,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAwBzE,QAAA,MACa,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACnC,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAC/B,6BAA6B,mNACzB,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCACI,CAAC;AAKrD,OAAO,EACN,qCAAqC,EACrC,2BAA2B,EAC3B,6BAA6B,IAAI,uCAAuC,EACxE,iCAAiC,GACjC,CAAC;AAKF,MAAM,MAAM,8BAA8B,GAAG,GAAG,CAAC,OAAO,qCAAqC,CAAC,CAAC;AAC/F,MAAM,MAAM,wBAAwB,GAAG,GAAG,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAC/E,MAAM,MAAM,8BAA8B,GAAG,GAAG,CAAC,OAAO,iCAAiC,CAAC,CAAC"}
1
+ {"version":3,"file":"shops-categories-coupon.validation.d.ts","sourceRoot":"/","sources":["modules/coupon/validations/shops-categories-coupon.validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAGN,GAAG,EACH,MAAM,2DAA2D,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAyBzE,QAAA,MACa,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACnC,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAC/B,6BAA6B,mNACzB,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCACI,CAAC;AAKrD,OAAO,EACN,qCAAqC,EACrC,2BAA2B,EAC3B,6BAA6B,IAAI,uCAAuC,EACxE,iCAAiC,GACjC,CAAC;AAKF,MAAM,MAAM,8BAA8B,GAAG,GAAG,CAAC,OAAO,qCAAqC,CAAC,CAAC;AAC/F,MAAM,MAAM,wBAAwB,GAAG,GAAG,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAC/E,MAAM,MAAM,8BAA8B,GAAG,GAAG,CAAC,OAAO,iCAAiC,CAAC,CAAC"}
@@ -10,6 +10,7 @@ const baseFields = {
10
10
  couponType: zod_1.z.literal(enum_1.CouponType.SHOPS_CATEGORIES),
11
11
  itemTypes: global_validation_1.ZodValidation.array(global_validation_1.ZodValidation.enumType(enum_1.ItemType, 'Item type'), 'Item types').default([]),
12
12
  shops: global_validation_1.ZodValidation.array(global_validation_1.ZodValidation.objectId('Shop'), 'Shops').default([]),
13
+ vendors: global_validation_1.ZodValidation.array(global_validation_1.ZodValidation.objectId('Vendor'), 'Vendors').default([]),
13
14
  isShopCoverExpenses: global_validation_1.ZodValidation.boolean('IsShopCoverExpenses').default(false),
14
15
  firstOrderOnly: global_validation_1.ZodValidation.boolean('FirstOrderOnly').default(false),
15
16
  };
@@ -1 +1 @@
1
- {"version":3,"file":"shops-categories-coupon.validation.js","sourceRoot":"/","sources":["modules/coupon/validations/shops-categories-coupon.validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,iGAImE;AACnE,2DAAqE;AACrE,4DAAyE;AAKzE,MAAM,UAAU,GAAG;IAClB,GAAG,8BAAgB;IACnB,UAAU,EAAE,OAAC,CAAC,OAAO,CAAC,iBAAU,CAAC,gBAAgB,CAAC;IAClD,SAAS,EAAE,iCAAa,CAAC,KAAK,CAAC,iCAAa,CAAC,QAAQ,CAAC,eAAQ,EAAE,WAAW,CAAC,EAAE,YAAY,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IACvG,KAAK,EAAE,iCAAa,CAAC,KAAK,CAAC,iCAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAC/E,mBAAmB,EAAE,iCAAa,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IAChF,cAAc,EAAE,iCAAa,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;CACtE,CAAC;AAOF,MAAM,aAAa,GAAG,IAAA,uCAAmB,EAAC,UAAU,CAAC,CAAC;AAKtD,MAAM,EACL,UAAU,EAAE,qCAAqC,EACjD,YAAY,EAAE,2BAA2B,EACzC,QAAQ,EAAE,6BAA6B,EACvC,YAAY,EAAE,iCAAiC,GAC/C,GAAG,aAAa,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAMpD,sFAAqC;AACrC,kEAA2B;AACM,gFAAuC;AACxE,8EAAiC","sourcesContent":["import { z } from 'zod';\nimport {\n\tZodValidation,\n\tcreateSchemaBuilder,\n\tDTO,\n} from '@lyxa.ai/core/dist/utilities/validation/global-validation';\nimport { baseFields as baseCouponFields } from './coupon.validation';\nimport { CouponType, ItemType } from '@lyxa.ai/core/dist/utilities/enum';\n\n/**\n * Define the base parent schema fields\n */\nconst baseFields = {\n\t...baseCouponFields,\n\tcouponType: z.literal(CouponType.SHOPS_CATEGORIES),\n\titemTypes: ZodValidation.array(ZodValidation.enumType(ItemType, 'Item type'), 'Item types').default([]),\n\tshops: ZodValidation.array(ZodValidation.objectId('Shop'), 'Shops').default([]),\n\tisShopCoverExpenses: ZodValidation.boolean('IsShopCoverExpenses').default(false),\n\tfirstOrderOnly: ZodValidation.boolean('FirstOrderOnly').default(false),\n};\n\n/**\n * Create schema builder for Parent entity\n * - Includes timestamps\n * - Excludes 'createdAt' from update operations\n */\nconst schemaBuilder = createSchemaBuilder(baseFields);\n\n/**\n * Get all schemas for the Parent entity\n */\nconst {\n\tBaseSchema: ShopsCategoriesCouponValidationSchema,\n\tEntitySchema: ShopsCategoriesCouponSchema,\n\tIdSchema: ShopsCategoriesCouponIdSchema,\n\tUpdateSchema: UpdateShopsCategoriesCouponSchema,\n} = schemaBuilder.getAllSchemas({ createdAt: true });\n\n/**\n * Export schemas\n */\nexport {\n\tShopsCategoriesCouponValidationSchema,\n\tShopsCategoriesCouponSchema,\n\tShopsCategoriesCouponIdSchema as ShopsCategoriesCouponIdValidationSchema,\n\tUpdateShopsCategoriesCouponSchema,\n};\n\n/**\n * Export DTO types\n */\nexport type CreateShopsCategoriesCouponDTO = DTO<typeof ShopsCategoriesCouponValidationSchema>;\nexport type ShopsCategoriesCouponDTO = DTO<typeof ShopsCategoriesCouponSchema>;\nexport type UpdateShopsCategoriesCouponDTO = DTO<typeof UpdateShopsCategoriesCouponSchema>;\n"]}
1
+ {"version":3,"file":"shops-categories-coupon.validation.js","sourceRoot":"/","sources":["modules/coupon/validations/shops-categories-coupon.validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,iGAImE;AACnE,2DAAqE;AACrE,4DAAyE;AAKzE,MAAM,UAAU,GAAG;IAClB,GAAG,8BAAgB;IACnB,UAAU,EAAE,OAAC,CAAC,OAAO,CAAC,iBAAU,CAAC,gBAAgB,CAAC;IAClD,SAAS,EAAE,iCAAa,CAAC,KAAK,CAAC,iCAAa,CAAC,QAAQ,CAAC,eAAQ,EAAE,WAAW,CAAC,EAAE,YAAY,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IACvG,KAAK,EAAE,iCAAa,CAAC,KAAK,CAAC,iCAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAC/E,OAAO,EAAE,iCAAa,CAAC,KAAK,CAAC,iCAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IACrF,mBAAmB,EAAE,iCAAa,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IAChF,cAAc,EAAE,iCAAa,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;CACtE,CAAC;AAOF,MAAM,aAAa,GAAG,IAAA,uCAAmB,EAAC,UAAU,CAAC,CAAC;AAKtD,MAAM,EACL,UAAU,EAAE,qCAAqC,EACjD,YAAY,EAAE,2BAA2B,EACzC,QAAQ,EAAE,6BAA6B,EACvC,YAAY,EAAE,iCAAiC,GAC/C,GAAG,aAAa,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAMpD,sFAAqC;AACrC,kEAA2B;AACM,gFAAuC;AACxE,8EAAiC","sourcesContent":["import { z } from 'zod';\nimport {\n\tZodValidation,\n\tcreateSchemaBuilder,\n\tDTO,\n} from '@lyxa.ai/core/dist/utilities/validation/global-validation';\nimport { baseFields as baseCouponFields } from './coupon.validation';\nimport { CouponType, ItemType } from '@lyxa.ai/core/dist/utilities/enum';\n\n/**\n * Define the base parent schema fields\n */\nconst baseFields = {\n\t...baseCouponFields,\n\tcouponType: z.literal(CouponType.SHOPS_CATEGORIES),\n\titemTypes: ZodValidation.array(ZodValidation.enumType(ItemType, 'Item type'), 'Item types').default([]),\n\tshops: ZodValidation.array(ZodValidation.objectId('Shop'), 'Shops').default([]),\n\tvendors: ZodValidation.array(ZodValidation.objectId('Vendor'), 'Vendors').default([]),\n\tisShopCoverExpenses: ZodValidation.boolean('IsShopCoverExpenses').default(false),\n\tfirstOrderOnly: ZodValidation.boolean('FirstOrderOnly').default(false),\n};\n\n/**\n * Create schema builder for Parent entity\n * - Includes timestamps\n * - Excludes 'createdAt' from update operations\n */\nconst schemaBuilder = createSchemaBuilder(baseFields);\n\n/**\n * Get all schemas for the Parent entity\n */\nconst {\n\tBaseSchema: ShopsCategoriesCouponValidationSchema,\n\tEntitySchema: ShopsCategoriesCouponSchema,\n\tIdSchema: ShopsCategoriesCouponIdSchema,\n\tUpdateSchema: UpdateShopsCategoriesCouponSchema,\n} = schemaBuilder.getAllSchemas({ createdAt: true });\n\n/**\n * Export schemas\n */\nexport {\n\tShopsCategoriesCouponValidationSchema,\n\tShopsCategoriesCouponSchema,\n\tShopsCategoriesCouponIdSchema as ShopsCategoriesCouponIdValidationSchema,\n\tUpdateShopsCategoriesCouponSchema,\n};\n\n/**\n * Export DTO types\n */\nexport type CreateShopsCategoriesCouponDTO = DTO<typeof ShopsCategoriesCouponValidationSchema>;\nexport type ShopsCategoriesCouponDTO = DTO<typeof ShopsCategoriesCouponSchema>;\nexport type UpdateShopsCategoriesCouponDTO = DTO<typeof UpdateShopsCategoriesCouponSchema>;\n"]}
@@ -499,6 +499,60 @@ export declare const limitedTimeOfferRouter: import("@trpc/server").TRPCBuiltRou
499
499
  };
500
500
  meta: object;
501
501
  }>;
502
+ update: import("@trpc/server").TRPCMutationProcedure<{
503
+ input: {
504
+ isEntireMenu: boolean;
505
+ discountPercentage: number;
506
+ maxDiscountCap: number;
507
+ isOrderCapacityEnabled: boolean;
508
+ products?: (string | import("mongoose").Types.ObjectId)[] | undefined;
509
+ maxOrderCapacity?: number | undefined;
510
+ };
511
+ output: {
512
+ message: string;
513
+ success: boolean;
514
+ data?: {
515
+ _id: string | import("mongoose").Types.ObjectId;
516
+ shop: string | import("mongoose").Types.ObjectId;
517
+ joinedAt: Date;
518
+ isEntireMenu: boolean;
519
+ campaign: string | import("mongoose").Types.ObjectId;
520
+ isOrderCapacityEnabled: boolean;
521
+ isWithdrawn: boolean;
522
+ createdAt?: Date | null | undefined;
523
+ updatedAt?: Date | null | undefined;
524
+ products?: (string | import("mongoose").Types.ObjectId)[] | undefined;
525
+ discountPercentage?: number | undefined;
526
+ maxDiscountCap?: number | undefined;
527
+ maxOrderCapacity?: number | undefined;
528
+ withdrawnAt?: Date | null | undefined;
529
+ } | {
530
+ documents: {
531
+ _id: string | import("mongoose").Types.ObjectId;
532
+ shop: string | import("mongoose").Types.ObjectId;
533
+ joinedAt: Date;
534
+ isEntireMenu: boolean;
535
+ campaign: string | import("mongoose").Types.ObjectId;
536
+ isOrderCapacityEnabled: boolean;
537
+ isWithdrawn: boolean;
538
+ createdAt?: Date | null | undefined;
539
+ updatedAt?: Date | null | undefined;
540
+ products?: (string | import("mongoose").Types.ObjectId)[] | undefined;
541
+ discountPercentage?: number | undefined;
542
+ maxDiscountCap?: number | undefined;
543
+ maxOrderCapacity?: number | undefined;
544
+ withdrawnAt?: Date | null | undefined;
545
+ }[];
546
+ metadata?: {
547
+ page: number;
548
+ size: number;
549
+ totalElements: number;
550
+ totalPages: number;
551
+ } | undefined;
552
+ } | undefined;
553
+ };
554
+ meta: object;
555
+ }>;
502
556
  withdraw: import("@trpc/server").TRPCMutationProcedure<{
503
557
  input: void;
504
558
  output: {
@@ -527,6 +581,8 @@ export declare const limitedTimeOfferRouter: import("@trpc/server").TRPCBuiltRou
527
581
  joinedAt: Date;
528
582
  isEntireMenu: boolean;
529
583
  isOrderCapacityEnabled: boolean;
584
+ productIds?: (string | import("mongoose").Types.ObjectId)[] | undefined;
585
+ marketingId?: string | import("mongoose").Types.ObjectId | undefined;
530
586
  discountPercentage?: number | undefined;
531
587
  maxDiscountCap?: number | undefined;
532
588
  maxOrderCapacity?: number | undefined;
@@ -547,6 +603,8 @@ export declare const limitedTimeOfferRouter: import("@trpc/server").TRPCBuiltRou
547
603
  joinedAt: Date;
548
604
  isEntireMenu: boolean;
549
605
  isOrderCapacityEnabled: boolean;
606
+ productIds?: (string | import("mongoose").Types.ObjectId)[] | undefined;
607
+ marketingId?: string | import("mongoose").Types.ObjectId | undefined;
550
608
  discountPercentage?: number | undefined;
551
609
  maxDiscountCap?: number | undefined;
552
610
  maxOrderCapacity?: number | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer.router.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/limited-time-offer.router.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAIjC,CAAC"}
@@ -1,13 +1,16 @@
1
1
  import { DocumentType, mongoose } from '@typegoose/typegoose';
2
2
  import { LimitedTimeOfferParticipant as Model } from '@lyxa.ai/core/dist/libraries/mongo/models';
3
3
  import { GetLtoCampaignParticipantsDTO, LtoCampaignParticipantItemDTO } from '../campaign/limited-time-offer-campaign.validation';
4
+ import { ActiveParticipantMarketingDTO, ParticipantSummaryDTO, UpdateParticipantDataDTO } from './limited-time-offer-participant.validation';
4
5
  export declare class LtoParticipantRepository {
5
6
  private model;
6
7
  constructor();
7
8
  create(input: object): Promise<DocumentType<Model>>;
8
- findActiveByCampaignAndShop(campaignId: mongoose.Types.ObjectId, shopId: mongoose.Types.ObjectId): Promise<Pick<Model, 'discountPercentage' | 'maxDiscountCap' | 'joinedAt' | 'isEntireMenu' | 'isOrderCapacityEnabled' | 'maxOrderCapacity'> | null>;
9
+ findActiveByCampaignAndShop(campaignId: mongoose.Types.ObjectId, shopId: mongoose.Types.ObjectId): Promise<ParticipantSummaryDTO | null>;
9
10
  withdraw(campaignId: mongoose.Types.ObjectId, shopId: mongoose.Types.ObjectId): Promise<DocumentType<Model> | null>;
10
11
  existsActiveByCampaignAndShop(campaignId: mongoose.Types.ObjectId, shopId: mongoose.Types.ObjectId): Promise<boolean>;
12
+ findActiveForUpdate(campaignId: mongoose.Types.ObjectId, shopId: mongoose.Types.ObjectId): Promise<ActiveParticipantMarketingDTO | null>;
13
+ updateParticipant(campaignId: mongoose.Types.ObjectId, shopId: mongoose.Types.ObjectId, data: UpdateParticipantDataDTO): Promise<DocumentType<Model> | null>;
11
14
  findMarketingIdsByCampaign(campaignId: mongoose.Types.ObjectId): Promise<mongoose.Types.ObjectId[]>;
12
15
  findByCampaign(dto: GetLtoCampaignParticipantsDTO): Promise<{
13
16
  documents: LtoCampaignParticipantItemDTO[];
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-off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KAAK,EAAE,MAAM,CAAA;KAAC,CAAC;CA6CjI;AAED,eAAO,MAAM,wBAAwB,0BAA0C,CAAC"}
1
+ {"version":3,"file":"limited-time-offer-participant.repository.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EACH,2BAA2B,IAAI,KAAK,EAGvC,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EAAC,6BAA6B,EAAE,6BAA6B,EAAC,MAAM,oDAAoD,CAAC;AAEhI,OAAO,EAAC,6BAA6B,EAAE,qBAAqB,EAAE,wBAAwB,EAAC,MAAM,6CAA6C,CAAC;AAE3I,qBACa,wBAAwB;IACjC,OAAO,CAAC,KAAK,CAAmE;;IAM1E,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAInD,2BAA2B,CAC7B,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACnC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAChC,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAUlC,QAAQ,CACV,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACnC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAChC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAQhC,6BAA6B,CAC/B,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACnC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAChC,OAAO,CAAC,OAAO,CAAC;IAIb,mBAAmB,CACrB,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACnC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAChC,OAAO,CAAC,6BAA6B,GAAG,IAAI,CAAC;IAS1C,iBAAiB,CACnB,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACnC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,IAAI,EAAE,wBAAwB,GAC/B,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAQhC,0BAA0B,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAQnG,cAAc,CAAC,GAAG,EAAE,6BAA6B,GAAG,OAAO,CAAC;QAAC,SAAS,EAAE,6BAA6B,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAAC;CA6CjI;AAED,eAAO,MAAM,wBAAwB,0BAA0C,CAAC"}
@@ -55,10 +55,14 @@ let LtoParticipantRepository = class LtoParticipantRepository {
55
55
  return this.model.create(input);
56
56
  }
57
57
  async findActiveByCampaignAndShop(campaignId, shopId) {
58
- return this.model
58
+ const result = await this.model
59
59
  .findOne({ campaign: campaignId, shop: shopId, isWithdrawn: false })
60
- .select('discountPercentage maxDiscountCap joinedAt isEntireMenu isOrderCapacityEnabled maxOrderCapacity')
60
+ .select('discountPercentage maxDiscountCap joinedAt isEntireMenu isOrderCapacityEnabled maxOrderCapacity products marketing')
61
61
  .lean();
62
+ if (!result)
63
+ return null;
64
+ const { products, marketing, ...rest } = result;
65
+ return { ...rest, productIds: products ?? [], marketingId: marketing };
62
66
  }
63
67
  async withdraw(campaignId, shopId) {
64
68
  return this.model.findOneAndUpdate({ campaign: campaignId, shop: shopId, isWithdrawn: false }, { $set: { isWithdrawn: true, withdrawnAt: new Date() } }, { new: true });
@@ -66,6 +70,18 @@ let LtoParticipantRepository = class LtoParticipantRepository {
66
70
  async existsActiveByCampaignAndShop(campaignId, shopId) {
67
71
  return !!(await this.model.exists({ campaign: campaignId, shop: shopId, isWithdrawn: false }));
68
72
  }
73
+ async findActiveForUpdate(campaignId, shopId) {
74
+ const result = await this.model
75
+ .findOne({ campaign: campaignId, shop: shopId, isWithdrawn: false })
76
+ .select('marketing')
77
+ .lean();
78
+ if (!result)
79
+ return null;
80
+ return { marketingId: result.marketing };
81
+ }
82
+ async updateParticipant(campaignId, shopId, data) {
83
+ return this.model.findOneAndUpdate({ campaign: campaignId, shop: shopId, isWithdrawn: false }, { $set: data }, { new: true });
84
+ }
69
85
  async findMarketingIdsByCampaign(campaignId) {
70
86
  const participants = await this.model
71
87
  .find({ campaign: campaignId, isWithdrawn: false, marketing: { $exists: true, $ne: null } })
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer-participant.repository.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,sEAImD;AAGnD,qGAAoF;AAG7E,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACzB,KAAK,CAAmE;IAEhF;QACI,IAAI,CAAC,KAAK,GAAG,yCAAoG,CAAC;IACtH,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAa;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,2BAA2B,CAC7B,UAAmC,EACnC,MAA+B;QAE/B,OAAO,IAAI,CAAC,KAAK;aACZ,OAAO,CAAC,EAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAC,CAAC;aACjE,MAAM,CAAC,iGAAiG,CAAC;aACzG,IAAI,EAAS,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,QAAQ,CACV,UAAmC,EACnC,MAA+B;QAE/B,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAC9B,EAAC,QAAQ,EA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,OAAO;YACH,SAAS,EAAE,MAAM,EAAE,SAAS,IAAI,EAAE;YAClC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC;SACxC,CAAC;IACN,CAAC;CACJ,CAAA;AA5FY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,gBAAO,GAAE;;GACG,wBAAwB,CA4FpC;AAEY,QAAA,wBAAwB,GAAG,gBAAS,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {DocumentType, mongoose} from '@typegoose/typegoose';\nimport {\n LimitedTimeOfferParticipant as Model,\n LimitedTimeOfferParticipantModel,\n ShopModel,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {SoftDeleteModel} from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport {GetLtoCampaignParticipantsDTO, LtoCampaignParticipantItemDTO} from '../campaign/limited-time-offer-campaign.validation';\nimport {LtoParticipantQueryBuilder} from './limited-time-offer-participant.builder';\n\n@Service()\nexport class LtoParticipantRepository {\n private model: typeof LimitedTimeOfferParticipantModel & SoftDeleteModel<Model>;\n\n constructor() {\n this.model = LimitedTimeOfferParticipantModel as typeof LimitedTimeOfferParticipantModel & SoftDeleteModel<Model>;\n }\n\n async create(input: object): Promise<DocumentType<Model>> {\n return this.model.create(input);\n }\n\n async findActiveByCampaignAndShop(\n campaignId: mongoose.Types.ObjectId,\n shopId: mongoose.Types.ObjectId,\n ): Promise<Pick<Model, 'discountPercentage' | 'maxDiscountCap' | 'joinedAt' | 'isEntireMenu' | 'isOrderCapacityEnabled' | 'maxOrderCapacity'> | null> {\n return this.model\n .findOne({campaign: campaignId, shop: shopId, isWithdrawn: false})\n .select('discountPercentage maxDiscountCap joinedAt isEntireMenu isOrderCapacityEnabled maxOrderCapacity')\n .lean() as any;\n }\n\n async withdraw(\n campaignId: mongoose.Types.ObjectId,\n shopId: mongoose.Types.ObjectId,\n ): Promise<DocumentType<Model> | null> {\n return this.model.findOneAndUpdate(\n {campaign: campaignId, shop: shopId, isWithdrawn: false},\n {$set: {isWithdrawn: true, withdrawnAt: new Date()}},\n {new: true},\n );\n }\n\n async existsActiveByCampaignAndShop(\n campaignId: mongoose.Types.ObjectId,\n shopId: mongoose.Types.ObjectId,\n ): Promise<boolean> {\n return !!(await this.model.exists({campaign: campaignId, shop: shopId, isWithdrawn: false}));\n }\n\n async findMarketingIdsByCampaign(campaignId: mongoose.Types.ObjectId): Promise<mongoose.Types.ObjectId[]> {\n const participants = await this.model\n .find({campaign: campaignId, isWithdrawn: false, marketing: {$exists: true, $ne: null}})\n .select('marketing')\n .lean();\n return participants.map(p => p.marketing as mongoose.Types.ObjectId).filter(Boolean);\n }\n\n async findByCampaign(dto: GetLtoCampaignParticipantsDTO): Promise<{documents: LtoCampaignParticipantItemDTO[]; total: number}> {\n const filter = LtoParticipantQueryBuilder.buildCampaignFilter(dto);\n const search = LtoParticipantQueryBuilder.buildSearchTerm(dto);\n\n const [result] = await this.model.aggregate([\n {$match: filter},\n {\n $lookup: {\n from: ShopModel.collection.name,\n let: {shopId: '$shop'},\n pipeline: [\n {$match: {$expr: {$eq: ['$_id', '$$shopId']}}},\n {$project: {name: 1, logo: 1}},\n ],\n as: 'shopData',\n },\n },\n {$unwind: {path: '$shopData', preserveNullAndEmptyArrays: true}},\n ...(search ? [{$match: {'shopData.name': {$regex: search, $options: 'i'}}}] : []),\n {$sort: {joinedAt: -1}},\n {\n $facet: {\n total: [{$count: 'count'}],\n documents: [\n {$skip: (dto.page - 1) * dto.size},\n {$limit: dto.size},\n {\n $project: {\n shopName: {$ifNull: ['$shopData.name', null]},\n shopPhoto: {$ifNull: ['$shopData.logo', null]},\n joinedAt: 1,\n discountPercentage: 1,\n maxDiscountCap: 1,\n },\n },\n ],\n },\n },\n ]);\n\n return {\n documents: result?.documents ?? [],\n total: result?.total?.[0]?.count ?? 0,\n };\n }\n}\n\nexport const ltoParticipantRepository = Container.get(LtoParticipantRepository);\n"]}
1
+ {"version":3,"file":"limited-time-offer-participant.repository.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,sEAImD;AAGnD,qGAAoF;AAI7E,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACzB,KAAK,CAAmE;IAEhF;QACI,IAAI,CAAC,KAAK,GAAG,yCAAoG,CAAC;IACtH,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAa;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,2BAA2B,CAC7B,UAAmC,EACnC,MAA+B;QAE/B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK;aAC1B,OAAO,CAAC,EAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAC,CAAC;aACjE,MAAM,CAAC,oHAAoH,CAAC;aAC5H,IAAI,EAAE,CAAC;QACZ,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QACzB,MAAM,EAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,EAAC,GAAG,MAAa,CAAC;QACrD,OAAO,EAAC,GAAG,IAAI,EAAE,UAAU,EAAE,QAAQ,IAAI,EAAE,EAAE,WAAW,EAAE,SAAS,EAAC,CAAC;IACzE,CAAC;IAED,KAAK,CAAC,QAAQ,CACV,UAAmC,EACnC,MAA+B;QAE/B,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAC9B,EAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAC,EACxD,EAAC,IAAI,EAAE,EAAC,WAAW,EAAE,IAAI,EAAE,WAAW,EA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E;oBACJ,KAAK,EAAE,CAAC,EAAC,MAAM,EAAE,OAAO,EAAC,CAAC;oBAC1B,SAAS,EAAE;wBACP,EAAC,KAAK,EAAE,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,EAAC;wBAClC,EAAC,MAAM,EAAE,GAAG,CAAC,IAAI,EAAC;wBAClB;4BACI,QAAQ,EAAE;gCACN,QAAQ,EAAE,EAAC,OAAO,EAAE,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAC;gCAC7C,SAAS,EAAE,EAAC,OAAO,EAAE,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAC;gCAC9C,QAAQ,EAAE,CAAC;gCACX,kBAAkB,EAAE,CAAC;gCACrB,cAAc,EAAE,CAAC;6BACpB;yBACJ;qBACJ;iBACJ;aACJ;SACJ,CAAC,CAAC;QAEH,OAAO;YACH,SAAS,EAAE,MAAM,EAAE,SAAS,IAAI,EAAE;YAClC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC;SACxC,CAAC;IACN,CAAC;CACJ,CAAA;AAvHY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,gBAAO,GAAE;;GACG,wBAAwB,CAuHpC;AAEY,QAAA,wBAAwB,GAAG,gBAAS,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {DocumentType, mongoose} from '@typegoose/typegoose';\nimport {\n LimitedTimeOfferParticipant as Model,\n LimitedTimeOfferParticipantModel,\n ShopModel,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {SoftDeleteModel} from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport {GetLtoCampaignParticipantsDTO, LtoCampaignParticipantItemDTO} from '../campaign/limited-time-offer-campaign.validation';\nimport {LtoParticipantQueryBuilder} from './limited-time-offer-participant.builder';\nimport {ActiveParticipantMarketingDTO, ParticipantSummaryDTO, UpdateParticipantDataDTO} from './limited-time-offer-participant.validation';\n\n@Service()\nexport class LtoParticipantRepository {\n private model: typeof LimitedTimeOfferParticipantModel & SoftDeleteModel<Model>;\n\n constructor() {\n this.model = LimitedTimeOfferParticipantModel as typeof LimitedTimeOfferParticipantModel & SoftDeleteModel<Model>;\n }\n\n async create(input: object): Promise<DocumentType<Model>> {\n return this.model.create(input);\n }\n\n async findActiveByCampaignAndShop(\n campaignId: mongoose.Types.ObjectId,\n shopId: mongoose.Types.ObjectId,\n ): Promise<ParticipantSummaryDTO | null> {\n const result = await this.model\n .findOne({campaign: campaignId, shop: shopId, isWithdrawn: false})\n .select('discountPercentage maxDiscountCap joinedAt isEntireMenu isOrderCapacityEnabled maxOrderCapacity products marketing')\n .lean();\n if (!result) return null;\n const {products, marketing, ...rest} = result as any;\n return {...rest, productIds: products ?? [], marketingId: marketing};\n }\n\n async withdraw(\n campaignId: mongoose.Types.ObjectId,\n shopId: mongoose.Types.ObjectId,\n ): Promise<DocumentType<Model> | null> {\n return this.model.findOneAndUpdate(\n {campaign: campaignId, shop: shopId, isWithdrawn: false},\n {$set: {isWithdrawn: true, withdrawnAt: new Date()}},\n {new: true},\n );\n }\n\n async existsActiveByCampaignAndShop(\n campaignId: mongoose.Types.ObjectId,\n shopId: mongoose.Types.ObjectId,\n ): Promise<boolean> {\n return !!(await this.model.exists({campaign: campaignId, shop: shopId, isWithdrawn: false}));\n }\n\n async findActiveForUpdate(\n campaignId: mongoose.Types.ObjectId,\n shopId: mongoose.Types.ObjectId,\n ): Promise<ActiveParticipantMarketingDTO | null> {\n const result = await this.model\n .findOne({campaign: campaignId, shop: shopId, isWithdrawn: false})\n .select('marketing')\n .lean();\n if (!result) return null;\n return {marketingId: (result as any).marketing};\n }\n\n async updateParticipant(\n campaignId: mongoose.Types.ObjectId,\n shopId: mongoose.Types.ObjectId,\n data: UpdateParticipantDataDTO,\n ): Promise<DocumentType<Model> | null> {\n return this.model.findOneAndUpdate(\n {campaign: campaignId, shop: shopId, isWithdrawn: false},\n {$set: data},\n {new: true},\n );\n }\n\n async findMarketingIdsByCampaign(campaignId: mongoose.Types.ObjectId): Promise<mongoose.Types.ObjectId[]> {\n const participants = await this.model\n .find({campaign: campaignId, isWithdrawn: false, marketing: {$exists: true, $ne: null}})\n .select('marketing')\n .lean();\n return participants.map(p => p.marketing as mongoose.Types.ObjectId).filter(Boolean);\n }\n\n async findByCampaign(dto: GetLtoCampaignParticipantsDTO): Promise<{documents: LtoCampaignParticipantItemDTO[]; total: number}> {\n const filter = LtoParticipantQueryBuilder.buildCampaignFilter(dto);\n const search = LtoParticipantQueryBuilder.buildSearchTerm(dto);\n\n const [result] = await this.model.aggregate([\n {$match: filter},\n {\n $lookup: {\n from: ShopModel.collection.name,\n let: {shopId: '$shop'},\n pipeline: [\n {$match: {$expr: {$eq: ['$_id', '$$shopId']}}},\n {$project: {name: 1, logo: 1}},\n ],\n as: 'shopData',\n },\n },\n {$unwind: {path: '$shopData', preserveNullAndEmptyArrays: true}},\n ...(search ? [{$match: {'shopData.name': {$regex: search, $options: 'i'}}}] : []),\n {$sort: {joinedAt: -1}},\n {\n $facet: {\n total: [{$count: 'count'}],\n documents: [\n {$skip: (dto.page - 1) * dto.size},\n {$limit: dto.size},\n {\n $project: {\n shopName: {$ifNull: ['$shopData.name', null]},\n shopPhoto: {$ifNull: ['$shopData.logo', null]},\n joinedAt: 1,\n discountPercentage: 1,\n maxDiscountCap: 1,\n },\n },\n ],\n },\n },\n ]);\n\n return {\n documents: result?.documents ?? [],\n total: result?.total?.[0]?.count ?? 0,\n };\n }\n}\n\nexport const ltoParticipantRepository = Container.get(LtoParticipantRepository);\n"]}
@@ -69,6 +69,60 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
69
69
  };
70
70
  meta: object;
71
71
  }>;
72
+ update: import("@trpc/server").TRPCMutationProcedure<{
73
+ input: {
74
+ isEntireMenu: boolean;
75
+ discountPercentage: number;
76
+ maxDiscountCap: number;
77
+ isOrderCapacityEnabled: boolean;
78
+ products?: (string | mongoose.Types.ObjectId)[] | undefined;
79
+ maxOrderCapacity?: number | undefined;
80
+ };
81
+ output: {
82
+ message: string;
83
+ success: boolean;
84
+ data?: {
85
+ _id: string | mongoose.Types.ObjectId;
86
+ shop: string | mongoose.Types.ObjectId;
87
+ joinedAt: Date;
88
+ isEntireMenu: boolean;
89
+ campaign: string | mongoose.Types.ObjectId;
90
+ isOrderCapacityEnabled: boolean;
91
+ isWithdrawn: boolean;
92
+ createdAt?: Date | null | undefined;
93
+ updatedAt?: Date | null | undefined;
94
+ products?: (string | mongoose.Types.ObjectId)[] | undefined;
95
+ discountPercentage?: number | undefined;
96
+ maxDiscountCap?: number | undefined;
97
+ maxOrderCapacity?: number | undefined;
98
+ withdrawnAt?: Date | null | undefined;
99
+ } | {
100
+ documents: {
101
+ _id: string | mongoose.Types.ObjectId;
102
+ shop: string | mongoose.Types.ObjectId;
103
+ joinedAt: Date;
104
+ isEntireMenu: boolean;
105
+ campaign: string | mongoose.Types.ObjectId;
106
+ isOrderCapacityEnabled: boolean;
107
+ isWithdrawn: boolean;
108
+ createdAt?: Date | null | undefined;
109
+ updatedAt?: Date | null | undefined;
110
+ products?: (string | mongoose.Types.ObjectId)[] | undefined;
111
+ discountPercentage?: number | undefined;
112
+ maxDiscountCap?: number | undefined;
113
+ maxOrderCapacity?: number | undefined;
114
+ withdrawnAt?: Date | null | undefined;
115
+ }[];
116
+ metadata?: {
117
+ page: number;
118
+ size: number;
119
+ totalElements: number;
120
+ totalPages: number;
121
+ } | undefined;
122
+ } | undefined;
123
+ };
124
+ meta: object;
125
+ }>;
72
126
  withdraw: import("@trpc/server").TRPCMutationProcedure<{
73
127
  input: void;
74
128
  output: {
@@ -97,6 +151,8 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
97
151
  joinedAt: Date;
98
152
  isEntireMenu: boolean;
99
153
  isOrderCapacityEnabled: boolean;
154
+ productIds?: (string | mongoose.Types.ObjectId)[] | undefined;
155
+ marketingId?: string | mongoose.Types.ObjectId | undefined;
100
156
  discountPercentage?: number | undefined;
101
157
  maxDiscountCap?: number | undefined;
102
158
  maxOrderCapacity?: number | undefined;
@@ -117,6 +173,8 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
117
173
  joinedAt: Date;
118
174
  isEntireMenu: boolean;
119
175
  isOrderCapacityEnabled: boolean;
176
+ productIds?: (string | mongoose.Types.ObjectId)[] | undefined;
177
+ marketingId?: string | mongoose.Types.ObjectId | undefined;
120
178
  discountPercentage?: number | undefined;
121
179
  maxDiscountCap?: number | undefined;
122
180
  maxOrderCapacity?: number | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer-participant.router.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.router.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAY9C,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsC5B,CAAC"}
1
+ {"version":3,"file":"limited-time-offer-participant.router.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.router.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAY9C,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgD5B,CAAC"}
@@ -27,6 +27,13 @@ exports.participantRouter = (0, trpc_1.createTRPCRouter)({
27
27
  const result = await limited_time_offer_participant_service_1.ltoParticipantService.join(resolveShopId(ctx), input);
28
28
  return (0, response_1.response)('Successfully joined the campaign', result);
29
29
  })),
30
+ update: sellerProcedure
31
+ .input(limited_time_offer_participant_validation_1.JoinLtoCampaignSchema)
32
+ .output(limited_time_offer_participant_validation_1.ParticipantResponseSchema)
33
+ .mutation(async ({ input, ctx }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
34
+ const result = await limited_time_offer_participant_service_1.ltoParticipantService.update(resolveShopId(ctx), input);
35
+ return (0, response_1.response)('Participation updated successfully', result);
36
+ })),
30
37
  withdraw: sellerProcedure
31
38
  .output(limited_time_offer_campaign_validation_1.LtoEmptyResponseSchema)
32
39
  .mutation(async ({ ctx }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer-participant.router.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.router.ts"],"names":[],"mappings":";;;AAAA,4DAAmE;AACnE,4DAAiE;AACjE,6EAAgG;AAChG,8EAAwE;AACxE,oEAA+D;AAC/D,8GAAmG;AACnG,2GAIqD;AACrD,+GAI4D;AAC5D,oDAA8C;AAC9C,4EAA0E;AAE1E,MAAM,eAAe,GAAG,IAAA,mCAA4B,EAAC,EAAC,WAAW,EAAE,CAAC,qBAAc,CAAC,MAAM,CAAC,EAAC,CAAC,CAAC;AAC7F,MAAM,YAAY,GAAG,IAAA,mCAA4B,EAAC,EAAC,WAAW,EAAE,CAAC,qBAAc,CAAC,GAAG,CAAC,EAAC,CAAC,CAAC;AAEvF,SAAS,aAAa,CAAC,GAAiE;IACpF,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,KAA6B,CAAC;IAC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G,CAAC,CAAC,CAAC;QAC3D,OAAO,IAAA,mBAAQ,EAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC,CAAC,CACL;IAEL,eAAe,EAAE,YAAY;SACxB,KAAK,CAAC,yEAAgC,CAAC;SACvC,MAAM,CAAC,8EAAqC,CAAC;SAC7C,KAAK,CAAC,KAAK,EAAE,EAAC,KAAK,EAAC,EAAE,EAAE,CACrB,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,MAAM,MAAM,GAAG,MAAM,8DAAO,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QACpD,OAAO,IAAA,mBAAQ,EAAC,mCAAmC,EAAE,MAAM,CAAC,CAAC;IACjE,CAAC,CAAC,CACL;CACR,CAAC,CAAC","sourcesContent":["import {createTRPCRouter} from '@lyxa.ai/core/dist/libraries/trpc';\nimport {AuthEntityType} from '@lyxa.ai/core/dist/libraries/auth';\nimport {createAuthenticatedProcedure} from '@lyxa.ai/core/dist/libraries/trpc/middlewares/auth';\nimport {ErrorHandler} from '@lyxa.ai/core/dist/utilities/error-handler';\nimport {response} from '@lyxa.ai/core/dist/utilities/response';\nimport {ltoParticipantService as service} from './services/limited-time-offer-participant.service';\nimport {\n JoinLtoCampaignSchema,\n ParticipantResponseSchema,\n ParticipantStatusResponseSchema,\n} from './limited-time-offer-participant.validation';\nimport {\n GetLtoCampaignParticipantsSchema,\n LtoCampaignParticipantsResponseSchema,\n LtoEmptyResponseSchema,\n} from '../campaign/limited-time-offer-campaign.validation';\nimport {mongoose} from '@typegoose/typegoose';\nimport {badRequestError} from '@lyxa.ai/core/dist/utilities/error-common';\n\nconst sellerProcedure = createAuthenticatedProcedure({entityTypes: [AuthEntityType.SELLER]});\nconst crmProcedure = createAuthenticatedProcedure({entityTypes: [AuthEntityType.CRM]});\n\nfunction resolveShopId(ctx: { entity?: { parameters?: Record<string, unknown> } | null }): mongoose.Types.ObjectId {\n const shops = ctx.entity?.parameters?.shops as string[] | undefined;\n if (!shops || shops.length === 0) throw badRequestError('No shop associated with this account');\n return new mongoose.Types.ObjectId(shops[0]);\n}\n\nexport const participantRouter = createTRPCRouter({\n join: sellerProcedure\n .input(JoinLtoCampaignSchema)\n .output(ParticipantResponseSchema)\n .mutation(async ({input, ctx}) =>\n ErrorHandler.wrapAsync(async () => {\n const result = await service.join(resolveShopId(ctx), input);\n return response('Successfully joined the campaign', result as any);\n })\n ),\n\n withdraw: sellerProcedure\n .output(LtoEmptyResponseSchema)\n .mutation(async ({ctx}) =>\n ErrorHandler.wrapAsync(async () => {\n await service.withdraw(resolveShopId(ctx));\n return response('Successfully withdrawn from the campaign');\n })\n ),\n\n getStatus: sellerProcedure\n .output(ParticipantStatusResponseSchema)\n .query(async ({ctx}) =>\n ErrorHandler.wrapAsync(async () => {\n const result = await service.getStatus(resolveShopId(ctx));\n return response('Status fetched successfully', result);\n })\n ),\n\n getParticipants: crmProcedure\n .input(GetLtoCampaignParticipantsSchema)\n .output(LtoCampaignParticipantsResponseSchema)\n .query(async ({input}) =>\n ErrorHandler.wrapAsync(async () => {\n const result = await service.getParticipants(input);\n return response('Participants fetched successfully', result);\n })\n ),\n});\n"]}
1
+ {"version":3,"file":"limited-time-offer-participant.router.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.router.ts"],"names":[],"mappings":";;;AAAA,4DAAmE;AACnE,4DAAiE;AACjE,6EAAgG;AAChG,8EAAwE;AACxE,oEAA+D;AAC/D,8GAAmG;AACnG,2GAIqD;AACrD,+GAI4D;AAC5D,oDAA8C;AAC9C,4EAA0E;AAE1E,MAAM,eAAe,GAAG,IAAA,mCAA4B,EAAC,EAAC,WAAW,EAAE,CAAC,qBAAc,CAAC,MAAM,CAAC,EAAC,CAAC,CAAC;AAC7F,MAAM,YAAY,GAAG,IAAA,mCAA4B,EAAC,EAAC,WAAW,EAAE,CAAC,qBAAc,CAAC,GAAG,CAAC,EAAC,CAAC,CAAC;AAEvF,SAAS,aAA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9B,QAAQ,CAAC,KAAK,EAAE,EAAC,GAAG,EAAC,EAAE,EAAE,CACtB,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,MAAM,8DAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3C,OAAO,IAAA,mBAAQ,EAAC,0CAA0C,CAAC,CAAC;IAChE,CAAC,CAAC,CACL;IAEL,SAAS,EAAE,eAAe;SACrB,MAAM,CAAC,2EAA+B,CAAC;SACvC,KAAK,CAAC,KAAK,EAAE,EAAC,GAAG,EAAC,EAAE,EAAE,CACnB,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,MAAM,MAAM,GAAG,MAAM,8DAAO,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3D,OAAO,IAAA,mBAAQ,EAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC,CAAC,CACL;IAEL,eAAe,EAAE,YAAY;SACxB,KAAK,CAAC,yEAAgC,CAAC;SACvC,MAAM,CAAC,8EAAqC,CAAC;SAC7C,KAAK,CAAC,KAAK,EAAE,EAAC,KAAK,EAAC,EAAE,EAAE,CACrB,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,MAAM,MAAM,GAAG,MAAM,8DAAO,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QACpD,OAAO,IAAA,mBAAQ,EAAC,mCAAmC,EAAE,MAAM,CAAC,CAAC;IACjE,CAAC,CAAC,CACL;CACR,CAAC,CAAC","sourcesContent":["import {createTRPCRouter} from '@lyxa.ai/core/dist/libraries/trpc';\nimport {AuthEntityType} from '@lyxa.ai/core/dist/libraries/auth';\nimport {createAuthenticatedProcedure} from '@lyxa.ai/core/dist/libraries/trpc/middlewares/auth';\nimport {ErrorHandler} from '@lyxa.ai/core/dist/utilities/error-handler';\nimport {response} from '@lyxa.ai/core/dist/utilities/response';\nimport {ltoParticipantService as service} from './services/limited-time-offer-participant.service';\nimport {\n JoinLtoCampaignSchema,\n ParticipantResponseSchema,\n ParticipantStatusResponseSchema,\n} from './limited-time-offer-participant.validation';\nimport {\n GetLtoCampaignParticipantsSchema,\n LtoCampaignParticipantsResponseSchema,\n LtoEmptyResponseSchema,\n} from '../campaign/limited-time-offer-campaign.validation';\nimport {mongoose} from '@typegoose/typegoose';\nimport {badRequestError} from '@lyxa.ai/core/dist/utilities/error-common';\n\nconst sellerProcedure = createAuthenticatedProcedure({entityTypes: [AuthEntityType.SELLER]});\nconst crmProcedure = createAuthenticatedProcedure({entityTypes: [AuthEntityType.CRM]});\n\nfunction resolveShopId(ctx: { entity?: { parameters?: Record<string, unknown> } | null }): mongoose.Types.ObjectId {\n const shops = ctx.entity?.parameters?.shops as string[] | undefined;\n if (!shops || shops.length === 0) throw badRequestError('No shop associated with this account');\n return new mongoose.Types.ObjectId(shops[0]);\n}\n\nexport const participantRouter = createTRPCRouter({\n join: sellerProcedure\n .input(JoinLtoCampaignSchema)\n .output(ParticipantResponseSchema)\n .mutation(async ({input, ctx}) =>\n ErrorHandler.wrapAsync(async () => {\n const result = await service.join(resolveShopId(ctx), input);\n return response('Successfully joined the campaign', result as any);\n })\n ),\n\n update: sellerProcedure\n .input(JoinLtoCampaignSchema)\n .output(ParticipantResponseSchema)\n .mutation(async ({input, ctx}) =>\n ErrorHandler.wrapAsync(async () => {\n const result = await service.update(resolveShopId(ctx), input);\n return response('Participation updated successfully', result as any);\n })\n ),\n\n withdraw: sellerProcedure\n .output(LtoEmptyResponseSchema)\n .mutation(async ({ctx}) =>\n ErrorHandler.wrapAsync(async () => {\n await service.withdraw(resolveShopId(ctx));\n return response('Successfully withdrawn from the campaign');\n })\n ),\n\n getStatus: sellerProcedure\n .output(ParticipantStatusResponseSchema)\n .query(async ({ctx}) =>\n ErrorHandler.wrapAsync(async () => {\n const result = await service.getStatus(resolveShopId(ctx));\n return response('Status fetched successfully', result);\n })\n ),\n\n getParticipants: crmProcedure\n .input(GetLtoCampaignParticipantsSchema)\n .output(LtoCampaignParticipantsResponseSchema)\n .query(async ({input}) =>\n ErrorHandler.wrapAsync(async () => {\n const result = await service.getParticipants(input);\n return response('Participants fetched successfully', result);\n })\n ),\n});\n"]}