@lyxa.ai/marketing 1.0.63 → 1.0.65

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 (274) hide show
  1. package/dist/lib/event/event-initializations.d.ts.map +1 -1
  2. package/dist/lib/event/event-initializations.js +0 -1
  3. package/dist/lib/event/event-initializations.js.map +1 -1
  4. package/dist/lib/event/event-listeners/event-listeners.d.ts +0 -1
  5. package/dist/lib/event/event-listeners/event-listeners.d.ts.map +1 -1
  6. package/dist/lib/event/event-listeners/event-listeners.js +12 -62
  7. package/dist/lib/event/event-listeners/event-listeners.js.map +1 -1
  8. package/dist/lib/event/events/marketing-product-seed.event.d.ts +2 -1
  9. package/dist/lib/event/events/marketing-product-seed.event.d.ts.map +1 -1
  10. package/dist/lib/event/events/marketing-product-seed.event.js.map +1 -1
  11. package/dist/lib/index.d.ts +21 -12028
  12. package/dist/lib/index.d.ts.map +1 -1
  13. package/dist/lib/index.js.map +1 -1
  14. package/dist/lib/modules/coupon/routers/coupon.router.d.ts +1101 -27
  15. package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
  16. package/dist/lib/modules/coupon/services/coupon.service.d.ts +1 -1
  17. package/dist/lib/modules/coupon/services/coupon.service.js +1 -1
  18. package/dist/lib/modules/coupon/services/coupon.service.js.map +1 -1
  19. package/dist/lib/modules/coupon/services/custom-coupon.service.d.ts +15 -3
  20. package/dist/lib/modules/coupon/services/custom-coupon.service.d.ts.map +1 -1
  21. package/dist/lib/modules/coupon/services/helper.service.d.ts +15 -3
  22. package/dist/lib/modules/coupon/services/helper.service.d.ts.map +1 -1
  23. package/dist/lib/modules/coupon/services/individual-store-coupon.service.d.ts +15 -3
  24. package/dist/lib/modules/coupon/services/individual-store-coupon.service.d.ts.map +1 -1
  25. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
  26. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js +21 -6
  27. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js.map +1 -1
  28. package/dist/lib/modules/coupon/services/referral-reward-coupon.service.d.ts.map +1 -1
  29. package/dist/lib/modules/coupon/services/referral-reward-coupon.service.js +1 -0
  30. package/dist/lib/modules/coupon/services/referral-reward-coupon.service.js.map +1 -1
  31. package/dist/lib/modules/coupon/services/shops-categories-coupon.service.d.ts +15 -3
  32. package/dist/lib/modules/coupon/services/shops-categories-coupon.service.d.ts.map +1 -1
  33. package/dist/lib/modules/coupon/transformers/coupon.transformer.d.ts +50 -0
  34. package/dist/lib/modules/coupon/transformers/coupon.transformer.d.ts.map +1 -1
  35. package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts +828 -6
  36. package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
  37. package/dist/lib/modules/coupon/validations/coupon.validation.d.ts +30 -30
  38. package/dist/lib/modules/coupon/validations/create-coupon.validation.d.ts +98 -0
  39. package/dist/lib/modules/coupon/validations/create-coupon.validation.d.ts.map +1 -1
  40. package/dist/lib/modules/coupon/validations/referral-reward-coupon.validation.d.ts +374 -0
  41. package/dist/lib/modules/coupon/validations/referral-reward-coupon.validation.d.ts.map +1 -1
  42. package/dist/lib/modules/coupon/validations/referral-reward-coupon.validation.js +2 -0
  43. package/dist/lib/modules/coupon/validations/referral-reward-coupon.validation.js.map +1 -1
  44. package/dist/lib/modules/deal-setting/routers/deal-setting.router.d.ts +9 -9
  45. package/dist/lib/modules/deal-setting/routers/deal-setting.router.d.ts.map +1 -1
  46. package/dist/lib/modules/deal-setting/validations/deal-setting.validation.d.ts +6 -6
  47. package/dist/lib/modules/featured-setting/routers/featured-setting.router.d.ts +8 -8
  48. package/dist/lib/modules/featured-setting/routers/featured-setting.router.d.ts.map +1 -1
  49. package/dist/lib/modules/featured-setting/validations/featured-setting.validation.d.ts +6 -6
  50. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts +7 -7
  51. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
  52. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js +2 -0
  53. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js.map +1 -1
  54. package/dist/lib/modules/limited-time-offer/campaign/jobs/index.d.ts.map +1 -1
  55. package/dist/lib/modules/limited-time-offer/campaign/jobs/index.js +4 -1
  56. package/dist/lib/modules/limited-time-offer/campaign/jobs/index.js.map +1 -1
  57. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +36 -36
  58. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts +2 -0
  59. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts.map +1 -1
  60. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.js +24 -5
  61. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.js.map +1 -1
  62. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.d.ts +1 -0
  63. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.d.ts.map +1 -1
  64. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.js +13 -2
  65. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.js.map +1 -1
  66. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
  67. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js +10 -1
  68. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js.map +1 -1
  69. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.validation.d.ts +6 -6
  70. package/dist/lib/modules/limited-time-offer/config/limited-time-offer.router.d.ts +3 -3
  71. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts +18 -18
  72. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -1
  73. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js +6 -9
  74. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js.map +1 -1
  75. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts +7 -1
  76. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts.map +1 -1
  77. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.js +5 -1
  78. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.js.map +1 -1
  79. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +8 -0
  80. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
  81. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js +60 -0
  82. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js.map +1 -1
  83. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +7 -7
  84. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
  85. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.js +5 -0
  86. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.js.map +1 -1
  87. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +235 -231
  88. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
  89. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js.map +1 -1
  90. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts +4 -0
  91. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts.map +1 -1
  92. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.js +14 -8
  93. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.js.map +1 -1
  94. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +11 -9
  95. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  96. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js +78 -46
  97. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js.map +1 -1
  98. package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts +1 -0
  99. package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts.map +1 -1
  100. package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.js +15 -3
  101. package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.js.map +1 -1
  102. package/dist/lib/modules/marketing/routers/marketing.router.d.ts +16 -3
  103. package/dist/lib/modules/marketing/routers/marketing.router.d.ts.map +1 -1
  104. package/dist/lib/modules/marketing/routers/marketing.router.js +4 -0
  105. package/dist/lib/modules/marketing/routers/marketing.router.js.map +1 -1
  106. package/dist/lib/modules/marketing/services/marketing.service.d.ts +1 -2
  107. package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
  108. package/dist/lib/modules/marketing/services/marketing.service.js +88 -70
  109. package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -1
  110. package/dist/lib/modules/marketing/services/product-marketing.service.d.ts +3 -1
  111. package/dist/lib/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
  112. package/dist/lib/modules/marketing/services/product-marketing.service.js +13 -10
  113. package/dist/lib/modules/marketing/services/product-marketing.service.js.map +1 -1
  114. package/dist/lib/modules/marketing/services/spend-to-get-progress.service.d.ts +13 -0
  115. package/dist/lib/modules/marketing/services/spend-to-get-progress.service.d.ts.map +1 -1
  116. package/dist/lib/modules/marketing/services/spend-to-get-progress.service.js +24 -0
  117. package/dist/lib/modules/marketing/services/spend-to-get-progress.service.js.map +1 -1
  118. package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.d.ts.map +1 -1
  119. package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.js +27 -95
  120. package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.js.map +1 -1
  121. package/dist/lib/modules/marketing/validations/all-marketings.validation.d.ts +4 -4
  122. package/dist/lib/modules/marketing/validations/marketing.validation.d.ts +14 -0
  123. package/dist/lib/modules/marketing/validations/marketing.validation.d.ts.map +1 -1
  124. package/dist/lib/modules/marketing/validations/marketing.validation.js +6 -1
  125. package/dist/lib/modules/marketing/validations/marketing.validation.js.map +1 -1
  126. package/dist/lib/modules/marketing/validations/punch-marketing.validation.d.ts +4 -4
  127. package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +11 -11
  128. package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts.map +1 -1
  129. package/dist/lib/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +6 -6
  130. package/dist/lib/modules/referral-setting/routers/referral-setting.router.d.ts +4 -4
  131. package/dist/lib/modules/referral-setting/validations/referral-setting.validation.d.ts +6 -6
  132. package/dist/lib/modules/referral-setting/validations/referral-setting.validation.d.ts.map +1 -1
  133. package/dist/lib/modules/referral-setting/validations/referral-setting.validation.js.map +1 -1
  134. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.d.ts +3 -2
  135. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.d.ts.map +1 -1
  136. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.js +21 -2
  137. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.js.map +1 -1
  138. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.d.ts +42 -26
  139. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.d.ts.map +1 -1
  140. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.d.ts +2 -2
  141. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.d.ts.map +1 -1
  142. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.js.map +1 -1
  143. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.d.ts +44 -25
  144. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.d.ts.map +1 -1
  145. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.js +2 -1
  146. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.js.map +1 -1
  147. package/dist/lib/modules/tournament/config/config.router.d.ts +4 -4
  148. package/dist/lib/modules/tournament/config/config.validation.d.ts +12 -12
  149. package/dist/lib/modules/tournament/match/match.router.d.ts +5 -5
  150. package/dist/lib/modules/tournament/match/match.validation.d.ts +12 -12
  151. package/dist/lib/modules/tournament/participant/participant.router.d.ts +3 -3
  152. package/dist/lib/modules/tournament/participant/participant.validation.d.ts +24 -24
  153. package/dist/lib/modules/tournament/prediction/prediction.router.d.ts +3 -3
  154. package/dist/lib/modules/tournament/prediction/prediction.validation.d.ts +18 -18
  155. package/dist/lib/modules/tournament/score/score.router.d.ts +1 -1
  156. package/dist/lib/modules/tournament/score/score.validation.d.ts +6 -6
  157. package/dist/lib/modules/tournament/statistics/statistics.router.d.ts +1 -1
  158. package/dist/lib/modules/tournament/statistics/statistics.validation.d.ts +6 -6
  159. package/dist/lib/modules/tournament/team/team.router.d.ts +3 -3
  160. package/dist/lib/modules/tournament/team/team.validation.d.ts +18 -18
  161. package/dist/lib/modules/tournament/tournament.router.d.ts +21 -21
  162. package/dist/lib/modules/tournament/tournament.validation.d.ts +6 -6
  163. package/dist/lib/utility/feature-flags.d.ts +3 -0
  164. package/dist/lib/utility/feature-flags.d.ts.map +1 -0
  165. package/dist/lib/utility/feature-flags.js +16 -0
  166. package/dist/lib/utility/feature-flags.js.map +1 -0
  167. package/dist/types/event/event-initializations.d.ts.map +1 -1
  168. package/dist/types/event/event-listeners/event-listeners.d.ts +0 -1
  169. package/dist/types/event/event-listeners/event-listeners.d.ts.map +1 -1
  170. package/dist/types/event/events/marketing-product-seed.event.d.ts +2 -1
  171. package/dist/types/event/events/marketing-product-seed.event.d.ts.map +1 -1
  172. package/dist/types/index.d.ts +21 -12028
  173. package/dist/types/index.d.ts.map +1 -1
  174. package/dist/types/modules/coupon/routers/coupon.router.d.ts +1101 -27
  175. package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
  176. package/dist/types/modules/coupon/services/coupon.service.d.ts +1 -1
  177. package/dist/types/modules/coupon/services/custom-coupon.service.d.ts +15 -3
  178. package/dist/types/modules/coupon/services/custom-coupon.service.d.ts.map +1 -1
  179. package/dist/types/modules/coupon/services/helper.service.d.ts +15 -3
  180. package/dist/types/modules/coupon/services/helper.service.d.ts.map +1 -1
  181. package/dist/types/modules/coupon/services/individual-store-coupon.service.d.ts +15 -3
  182. package/dist/types/modules/coupon/services/individual-store-coupon.service.d.ts.map +1 -1
  183. package/dist/types/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
  184. package/dist/types/modules/coupon/services/referral-reward-coupon.service.d.ts.map +1 -1
  185. package/dist/types/modules/coupon/services/shops-categories-coupon.service.d.ts +15 -3
  186. package/dist/types/modules/coupon/services/shops-categories-coupon.service.d.ts.map +1 -1
  187. package/dist/types/modules/coupon/transformers/coupon.transformer.d.ts +50 -0
  188. package/dist/types/modules/coupon/transformers/coupon.transformer.d.ts.map +1 -1
  189. package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts +828 -6
  190. package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
  191. package/dist/types/modules/coupon/validations/coupon.validation.d.ts +30 -30
  192. package/dist/types/modules/coupon/validations/create-coupon.validation.d.ts +98 -0
  193. package/dist/types/modules/coupon/validations/create-coupon.validation.d.ts.map +1 -1
  194. package/dist/types/modules/coupon/validations/referral-reward-coupon.validation.d.ts +374 -0
  195. package/dist/types/modules/coupon/validations/referral-reward-coupon.validation.d.ts.map +1 -1
  196. package/dist/types/modules/deal-setting/routers/deal-setting.router.d.ts +9 -9
  197. package/dist/types/modules/deal-setting/routers/deal-setting.router.d.ts.map +1 -1
  198. package/dist/types/modules/deal-setting/validations/deal-setting.validation.d.ts +6 -6
  199. package/dist/types/modules/featured-setting/routers/featured-setting.router.d.ts +8 -8
  200. package/dist/types/modules/featured-setting/routers/featured-setting.router.d.ts.map +1 -1
  201. package/dist/types/modules/featured-setting/validations/featured-setting.validation.d.ts +6 -6
  202. package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts +7 -7
  203. package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
  204. package/dist/types/modules/limited-time-offer/campaign/jobs/index.d.ts.map +1 -1
  205. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +36 -36
  206. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts +2 -0
  207. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts.map +1 -1
  208. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.d.ts +1 -0
  209. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.d.ts.map +1 -1
  210. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
  211. package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.validation.d.ts +6 -6
  212. package/dist/types/modules/limited-time-offer/config/limited-time-offer.router.d.ts +3 -3
  213. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts +18 -18
  214. package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -1
  215. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts +7 -1
  216. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts.map +1 -1
  217. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +8 -0
  218. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
  219. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +7 -7
  220. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
  221. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +235 -231
  222. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
  223. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts +4 -0
  224. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts.map +1 -1
  225. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +11 -9
  226. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  227. package/dist/types/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts +1 -0
  228. package/dist/types/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts.map +1 -1
  229. package/dist/types/modules/marketing/routers/marketing.router.d.ts +16 -3
  230. package/dist/types/modules/marketing/routers/marketing.router.d.ts.map +1 -1
  231. package/dist/types/modules/marketing/services/marketing.service.d.ts +1 -2
  232. package/dist/types/modules/marketing/services/marketing.service.d.ts.map +1 -1
  233. package/dist/types/modules/marketing/services/product-marketing.service.d.ts +3 -1
  234. package/dist/types/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
  235. package/dist/types/modules/marketing/services/spend-to-get-progress.service.d.ts +18 -0
  236. package/dist/types/modules/marketing/services/spend-to-get-progress.service.d.ts.map +1 -1
  237. package/dist/types/modules/marketing/services/synchronize-product-marketing.service.d.ts.map +1 -1
  238. package/dist/types/modules/marketing/validations/all-marketings.validation.d.ts +4 -4
  239. package/dist/types/modules/marketing/validations/marketing.validation.d.ts +14 -0
  240. package/dist/types/modules/marketing/validations/marketing.validation.d.ts.map +1 -1
  241. package/dist/types/modules/marketing/validations/punch-marketing.validation.d.ts +4 -4
  242. package/dist/types/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +11 -11
  243. package/dist/types/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts.map +1 -1
  244. package/dist/types/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +6 -6
  245. package/dist/types/modules/referral-setting/routers/referral-setting.router.d.ts +4 -4
  246. package/dist/types/modules/referral-setting/validations/referral-setting.validation.d.ts +6 -6
  247. package/dist/types/modules/referral-setting/validations/referral-setting.validation.d.ts.map +1 -1
  248. package/dist/types/modules/spend-to-get-history/spend-to-get-history.repository.d.ts +3 -2
  249. package/dist/types/modules/spend-to-get-history/spend-to-get-history.repository.d.ts.map +1 -1
  250. package/dist/types/modules/spend-to-get-history/spend-to-get-history.router.d.ts +42 -26
  251. package/dist/types/modules/spend-to-get-history/spend-to-get-history.router.d.ts.map +1 -1
  252. package/dist/types/modules/spend-to-get-history/spend-to-get-history.service.d.ts +2 -2
  253. package/dist/types/modules/spend-to-get-history/spend-to-get-history.service.d.ts.map +1 -1
  254. package/dist/types/modules/spend-to-get-history/spend-to-get-history.validation.d.ts +44 -25
  255. package/dist/types/modules/spend-to-get-history/spend-to-get-history.validation.d.ts.map +1 -1
  256. package/dist/types/modules/tournament/config/config.router.d.ts +4 -4
  257. package/dist/types/modules/tournament/config/config.validation.d.ts +12 -12
  258. package/dist/types/modules/tournament/match/match.router.d.ts +5 -5
  259. package/dist/types/modules/tournament/match/match.validation.d.ts +12 -12
  260. package/dist/types/modules/tournament/participant/participant.router.d.ts +3 -3
  261. package/dist/types/modules/tournament/participant/participant.validation.d.ts +24 -24
  262. package/dist/types/modules/tournament/prediction/prediction.router.d.ts +3 -3
  263. package/dist/types/modules/tournament/prediction/prediction.validation.d.ts +18 -18
  264. package/dist/types/modules/tournament/score/score.router.d.ts +1 -1
  265. package/dist/types/modules/tournament/score/score.validation.d.ts +6 -6
  266. package/dist/types/modules/tournament/statistics/statistics.router.d.ts +1 -1
  267. package/dist/types/modules/tournament/statistics/statistics.validation.d.ts +6 -6
  268. package/dist/types/modules/tournament/team/team.router.d.ts +3 -3
  269. package/dist/types/modules/tournament/team/team.validation.d.ts +18 -18
  270. package/dist/types/modules/tournament/tournament.router.d.ts +21 -21
  271. package/dist/types/modules/tournament/tournament.validation.d.ts +6 -6
  272. package/dist/types/utility/feature-flags.d.ts +12 -0
  273. package/dist/types/utility/feature-flags.d.ts.map +1 -0
  274. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/limited-time-offer.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,2IAG2F;AAC3F,+JAEqG;AAErG,oJAGiG;AACjG,8IAE0F;AAC1F,kJAAoH;AAQ7G,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IACxB,eAAe,CAAqB;IACpC,SAAS,CAA8B;IACvC,kBAAkB,CAAqC;IACvD,mBAAmB,CAAsC;IAEjE;QACI,IAAI,CAAC,eAAe,GAAG,wDAAkB,CAAC;QAC1C,IAAI,CAAC,SAAS,GAAG,gBAAS,CAAC,GAAG,CAAC,2EAA2B,CAAC,CAAC;QAC5D,IAAI,CAAC,kBAAkB,GAAG,8DAAqB,CAAC;QAChD,IAAI,CAAC,mBAAmB,GAAG,gBAAS,CAAC,GAAG,CAAC,6EAAmC,CAAC,CAAC;IAClF,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAAC,UAAmC;QAC7D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAChE,MAAM,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QAClD,IAAI,CAAC,QAAQ,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzC,MAAM,IAAI,CAAC,kBAAkB,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AAC,GAAG,CAAC,uBAAuB,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {\n ltoCampaignService,\n LtoCampaignService,\n} from '@modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service';\nimport {\n LtoCampaignLifecycleService,\n} from '@modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service';\nimport {GetActiveCampaignDTO} from '@modules/limited-time-offer/campaign/limited-time-offer-campaign.validation';\nimport {\n LimitedTimeOfferParticipantService,\n ltoParticipantService,\n} from '@modules/limited-time-offer/participant/services/limited-time-offer-participant.service';\nimport {\n LimitedTimeOfferNotificationService\n} from \"@modules/limited-time-offer/notification/limited-time-offer-notification.service\";\nimport {NotificationType} from \"@modules/limited-time-offer/notification/limited-time-offer-notification.constants\";\n\n/**\n * Application/orchestration layer for the Limited Time Offer module. Owns every flow that spans the\n * campaign and participant aggregates so neither domain service has to reach across the boundary.\n * Pure single-aggregate operations stay on their respective domain services.\n */\n@Service()\nexport class LimitedTimeOfferService {\n private campaignService: LtoCampaignService;\n private lifecycle: LtoCampaignLifecycleService;\n private participantService: LimitedTimeOfferParticipantService;\n private notificationService: LimitedTimeOfferNotificationService;\n\n constructor() {\n this.campaignService = ltoCampaignService;\n this.lifecycle = Container.get(LtoCampaignLifecycleService);\n this.participantService = ltoParticipantService;\n this.notificationService = Container.get(LimitedTimeOfferNotificationService);\n }\n\n public async activateCampaign(campaignId: mongoose.Types.ObjectId): Promise<void> {\n const campaign = await this.campaignService.getById(campaignId);\n await this.lifecycle.activateCampaign(campaignId);\n if ((campaign.repeatDays ?? []).length > 0) {\n await this.participantService.reactivateMarketings(campaign);\n }\n }\n\n public async getActiveCampaign(input: GetActiveCampaignDTO) {\n const campaign = await this.campaignService.getActive();\n if (!campaign) return null;\n\n const nearbyParticipants = await this.participantService.getNearby(campaign._id, input);\n return nearbyParticipants.length > 0 ? campaign : null;\n }\n\n public async cancelCampaign(campaignId: mongoose.Types.ObjectId): Promise<void> {\n await this.campaignService.cancel(campaignId);\n const participantIds = await this.participantService.getParticipantIdsByCampaignId(campaignId);\n await this.participantService.cleanupCampaignMarketings(campaignId);\n await this.notificationService.send(NotificationType.Cancel, participantIds, {campaignId});\n }\n\n public async expireCampaign(campaignId: mongoose.Types.ObjectId): Promise<void> {\n const isRecurring = await this.lifecycle.expireCampaign(campaignId);\n if (!isRecurring) {\n await this.participantService.cleanupCampaignMarketings(campaignId);\n }\n }\n}\n\nexport const limitedTimeOfferService = Container.get(LimitedTimeOfferService);\n"]}
1
+ {"version":3,"file":"limited-time-offer.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/limited-time-offer.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,2IAG2F;AAC3F,+JAEqG;AAErG,oJAGiG;AACjG,8IAE0F;AAC1F,kJAAoH;AACpH,0DAA4D;AAQrD,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IACxB,eAAe,CAAqB;IACpC,SAAS,CAA8B;IACvC,kBAAkB,CAAqC;IACvD,mBAAmB,CAAsC;IAEjE;QACI,IAAI,CAAC,eAAe,GAAG,wDAAkB,CAAC;QAC1C,IAAI,CAAC,SAAS,GAAG,gBAAS,CAAC,GAAG,CAAC,2EAA2B,CAAC,CAAC;QAC5D,IAAI,CAAC,kBAAkB,GAAG,8DAAqB,CAAC;QAChD,IAAI,CAAC,mBAAmB,GAAG,gBAAS,CAAC,GAAG,CAAC,6EAAmC,CAAC,CAAC;IAClF,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAAC,UAAmC;QAC7D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAChE,MAAM,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QAClD,IAAI,CAAC,CAAC,MAAM,IAAA,oCAAoB,GAAE,CAAC;YAAE,OAAO;QAI5C,MAAM,IAAI,CAAC,kBAAkB,CAAC,8BAA8B,CAAC,QAAQ,CAAC,CAAC;IAC3E,CAAC;IAEM,KAAK,CAAC,iBAAiB,CAAC,KAA2B;QACtD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,CAAC;QACxD,IAAI,CAAC,QAAQ;YAAE,OAAO,IAAI,CAAC;QAE3B,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACxF,OAAO,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3D,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,UAAmC;QAE3D,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,6BAA6B,CAAC,UAAU,CAAC,CAAC;QAC/F,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC9C,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,4DAAgB,CAAC,MAAM,EAAE,cAAc,EAAE,EAAC,UAAU,EAAC,CAAC,CAAC;IAC/F,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,UAAmC;QAC3D,MAAM,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IACpD,CAAC;CACJ,CAAA;AAzCY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,gBAAO,GAAE;;GACG,uBAAuB,CAyCnC;AAEY,QAAA,uBAAuB,GAAG,gBAAS,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {\n ltoCampaignService,\n LtoCampaignService,\n} from '@modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service';\nimport {\n LtoCampaignLifecycleService,\n} from '@modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service';\nimport {GetActiveCampaignDTO} from '@modules/limited-time-offer/campaign/limited-time-offer-campaign.validation';\nimport {\n LimitedTimeOfferParticipantService,\n ltoParticipantService,\n} from '@modules/limited-time-offer/participant/services/limited-time-offer-participant.service';\nimport {\n LimitedTimeOfferNotificationService\n} from \"@modules/limited-time-offer/notification/limited-time-offer-notification.service\";\nimport {NotificationType} from \"@modules/limited-time-offer/notification/limited-time-offer-notification.constants\";\nimport {isLtoScheduleEnabled} from '@utility/feature-flags';\n\n/**\n * Application/orchestration layer for the Limited Time Offer module. Owns every flow that spans the\n * campaign and participant aggregates so neither domain service has to reach across the boundary.\n * Pure single-aggregate operations stay on their respective domain services.\n */\n@Service()\nexport class LimitedTimeOfferService {\n private campaignService: LtoCampaignService;\n private lifecycle: LtoCampaignLifecycleService;\n private participantService: LimitedTimeOfferParticipantService;\n private notificationService: LimitedTimeOfferNotificationService;\n\n constructor() {\n this.campaignService = ltoCampaignService;\n this.lifecycle = Container.get(LtoCampaignLifecycleService);\n this.participantService = ltoParticipantService;\n this.notificationService = Container.get(LimitedTimeOfferNotificationService);\n }\n\n public async activateCampaign(campaignId: mongoose.Types.ObjectId): Promise<void> {\n const campaign = await this.campaignService.getById(campaignId);\n await this.lifecycle.activateCampaign(campaignId);\n if (!(await isLtoScheduleEnabled())) return;\n // Now that the campaign is live, apply the effects that join deferred while it was scheduled\n // (pause the shops' clashing discounts, override order capacity) for every participant —\n // including recurrence clones, whose marketing is (re)created here.\n await this.participantService.applyLiveEffectsToParticipants(campaign);\n }\n\n public async getActiveCampaign(input: GetActiveCampaignDTO) {\n const campaign = await this.campaignService.getActive();\n if (!campaign) return null;\n\n const nearbyParticipants = await this.participantService.getNearby(campaign._id, input);\n return nearbyParticipants.length > 0 ? campaign : null;\n }\n\n public async cancelCampaign(campaignId: mongoose.Types.ObjectId): Promise<void> {\n // Capture participants before cancelling reverts their effects, so the notification still reaches them.\n const participantIds = await this.participantService.getParticipantIdsByCampaignId(campaignId);\n await this.campaignService.cancel(campaignId);\n await this.notificationService.send(NotificationType.Cancel, participantIds, {campaignId});\n }\n\n public async expireCampaign(campaignId: mongoose.Types.ObjectId): Promise<void> {\n await this.lifecycle.expireCampaign(campaignId);\n }\n}\n\nexport const limitedTimeOfferService = Container.get(LimitedTimeOfferService);\n"]}
@@ -15,6 +15,8 @@ export declare class LtoParticipantQueryBuilder {
15
15
  marketingId: mongoose.Types.ObjectId;
16
16
  dto: JoinLtoCampaignDTO;
17
17
  pausedMarketings?: mongoose.Types.ObjectId[];
18
+ pausedOrderCapacity?: number;
19
+ pausedOrderCapacityEnabled?: boolean;
18
20
  }): {
19
21
  campaign: mongoose.Types.ObjectId;
20
22
  shop: mongoose.Types.ObjectId;
@@ -26,10 +28,12 @@ export declare class LtoParticipantQueryBuilder {
26
28
  maxDiscountCap: number;
27
29
  isOrderCapacityEnabled: boolean;
28
30
  maxOrderCapacity: number | undefined;
31
+ pausedOrderCapacity: number | undefined;
32
+ pausedOrderCapacityEnabled: boolean | undefined;
29
33
  isWithdrawn: boolean;
30
34
  pausedMarketings: mongoose.Types.ObjectId[];
31
35
  };
32
- static buildCloneInput(campaignId: mongoose.Types.ObjectId, source: Pick<LimitedTimeOfferParticipant, 'shop' | 'products' | 'isEntireMenu' | 'discountPercentage' | 'maxDiscountCap' | 'isOrderCapacityEnabled' | 'maxOrderCapacity'>): {
36
+ static buildCloneInput(campaignId: mongoose.Types.ObjectId, source: Pick<LimitedTimeOfferParticipant, 'shop' | 'products' | 'isEntireMenu' | 'discountPercentage' | 'maxDiscountCap' | 'isOrderCapacityEnabled' | 'maxOrderCapacity' | 'pausedOrderCapacity' | 'pausedOrderCapacityEnabled'>): {
33
37
  campaign: mongoose.Types.ObjectId;
34
38
  shop: import("@typegoose/typegoose").Ref<import("@lyxa.ai/core/dist/libraries/mongo/models").Shop>;
35
39
  joinedAt: Date;
@@ -39,6 +43,8 @@ export declare class LtoParticipantQueryBuilder {
39
43
  maxDiscountCap: number | undefined;
40
44
  isOrderCapacityEnabled: boolean;
41
45
  maxOrderCapacity: number | undefined;
46
+ pausedOrderCapacity: number | undefined;
47
+ pausedOrderCapacityEnabled: boolean | undefined;
42
48
  isWithdrawn: boolean;
43
49
  pausedMarketings: never[];
44
50
  };
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer-participant.builder.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,wBAAwB,EAAE,2BAA2B,EAAC,MAAM,2CAA2C,CAAC;AAChH,OAAO,EAAC,qBAAqB,EAAE,eAAe,EAAE,aAAa,EAAE,SAAS,EAAC,MAAM,mCAAmC,CAAC;AACnH,OAAO,EAAC,6BAA6B,EAAC,MAAM,oDAAoD,CAAC;AACjG,OAAO,EAAC,kBAAkB,EAAC,MAAM,6CAA6C,CAAC;AAE/E,qBAAa,0BAA0B;IACnC,MAAM,CAAC,mBAAmB,CAAC,GAAG,EAAE,6BAA6B;;;;IAI7D,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,6BAA6B,GAAG,MAAM,GAAG,SAAS;IAI9E,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE;QAC3B,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;QACpC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;QAChC,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;QACrC,GAAG,EAAE,kBAAkB,CAAC;QACxB,gBAAgB,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;KAChD;;;;;;;;;;;;;;IAkBD,MAAM,CAAC,eAAe,CAClB,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACnC,MAAM,EAAE,IAAI,CACR,2BAA2B,EACzB,MAAM,GACN,UAAU,GACV,cAAc,GACd,oBAAoB,GACpB,gBAAgB,GAChB,wBAAwB,GACxB,kBAAkB,CACvB;;;;;;;;;;;;;IAiBL,MAAM,CAAC,mBAAmB,CACtB,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,QAAQ,EAAE,wBAAwB,GAAG;QAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAA;KAAC,EACnE,GAAG,EAAE,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;CA4B9B"}
1
+ {"version":3,"file":"limited-time-offer-participant.builder.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,wBAAwB,EAAE,2BAA2B,EAAC,MAAM,2CAA2C,CAAC;AAChH,OAAO,EAAC,qBAAqB,EAAE,eAAe,EAAE,aAAa,EAAE,SAAS,EAAC,MAAM,mCAAmC,CAAC;AACnH,OAAO,EAAC,6BAA6B,EAAC,MAAM,oDAAoD,CAAC;AACjG,OAAO,EAAC,kBAAkB,EAAC,MAAM,6CAA6C,CAAC;AAE/E,qBAAa,0BAA0B;IACnC,MAAM,CAAC,mBAAmB,CAAC,GAAG,EAAE,6BAA6B;;;;IAI7D,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,6BAA6B,GAAG,MAAM,GAAG,SAAS;IAI9E,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE;QAC3B,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;QACpC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;QAChC,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;QACrC,GAAG,EAAE,kBAAkB,CAAC;QACxB,gBAAgB,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC7C,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,0BAA0B,CAAC,EAAE,OAAO,CAAC;KACxC;;;;;;;;;;;;;;;;IA4BD,MAAM,CAAC,eAAe,CAClB,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACnC,MAAM,EAAE,IAAI,CACR,2BAA2B,EACzB,MAAM,GACN,UAAU,GACV,cAAc,GACd,oBAAoB,GACpB,gBAAgB,GAChB,wBAAwB,GACxB,kBAAkB,GAClB,qBAAqB,GACrB,4BAA4B,CACjC;;;;;;;;;;;;;;;IAmBL,MAAM,CAAC,mBAAmB,CACtB,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,QAAQ,EAAE,wBAAwB,GAAG;QAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAA;KAAC,EACnE,GAAG,EAAE,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;CA4B9B"}
@@ -10,7 +10,7 @@ class LtoParticipantQueryBuilder {
10
10
  return dto.search?.trim() || undefined;
11
11
  }
12
12
  static buildCreateInput(input) {
13
- const { campaignId, shopId, marketingId, dto, pausedMarketings = [] } = input;
13
+ const { campaignId, shopId, marketingId, dto, pausedMarketings = [], pausedOrderCapacity, pausedOrderCapacityEnabled, } = input;
14
14
  return {
15
15
  campaign: campaignId,
16
16
  shop: shopId,
@@ -22,6 +22,8 @@ class LtoParticipantQueryBuilder {
22
22
  maxDiscountCap: dto.maxDiscountCap,
23
23
  isOrderCapacityEnabled: dto.isOrderCapacityEnabled,
24
24
  maxOrderCapacity: dto.maxOrderCapacity,
25
+ pausedOrderCapacity,
26
+ pausedOrderCapacityEnabled,
25
27
  isWithdrawn: false,
26
28
  pausedMarketings,
27
29
  };
@@ -37,6 +39,8 @@ class LtoParticipantQueryBuilder {
37
39
  maxDiscountCap: source.maxDiscountCap,
38
40
  isOrderCapacityEnabled: source.isOrderCapacityEnabled,
39
41
  maxOrderCapacity: source.maxOrderCapacity,
42
+ pausedOrderCapacity: source.pausedOrderCapacity,
43
+ pausedOrderCapacityEnabled: source.pausedOrderCapacityEnabled,
40
44
  isWithdrawn: false,
41
45
  pausedMarketings: [],
42
46
  };
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer-participant.builder.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.builder.ts"],"names":[],"mappings":";;;AAEA,4DAAmH;AAInH,MAAa,0BAA0B;IACnC,MAAM,CAAC,mBAAmB,CAAC,GAAkC;QACzD,OAAO,EAAC,QAAQ,EAAE,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,KAAK,EAAC,CAAC;IAC1D,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,GAAkC;QACrD,OAAO,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,SAAS,CAAC;IAC3C,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,KAMvB;QACG,MAAM,EAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,gBAAgB,GAAG,EAAE,EAAC,GAAG,KAAK,CAAC;QAC5E,OAAO;YACH,QAAQ,EAAE,UAAU;YACpB,IAAI,EAAE,MAAM;YACZ,SAAS,EAAE,WAAW;YACtB,QAAQ,EAAE,IAAI,IAAI,EAAE;YACpB,QAAQ,EAAE,GAAG,CAAC,QAAQ,IAAI,EAAE;YAC5B,YAAY,EAAE,GAAG,CAAC,YAAY;YAC9B,kBAAkB,EAAE,GAAG,CAAC,kBAAkB;YAC1C,cAAc,EAAE,GAAG,CAAC,cAAc;YAClC,sBAAsB,EAAE,GAAG,CAAC,sBAAsB;YAClD,gBAAgB,EAAE,GAAG,CAAC,gBAAgB;YACtC,WAAW,EAAE,KAAK;YAClB,gBAAgB;SACnB,CAAC;IACN,CAAC;IAED,MAAM,CAAC,eAAe,CAClB,UA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AC,kBAAkB;oBAC7B,SAAS,EAAE,gBAAS,CAAC,UAAU;iBAClC,CAAC,CAAC;YACP,mBAAmB,EAAE,GAAG,CAAC,cAAc;YACvC,4BAA4B,EAAE,GAAG,CAAC,cAAc,GAAG,CAAC;YACpD,UAAU,EAAE,EAAE;YACd,eAAe,EAAE,EAAE;YACnB,UAAU,EAAE,CAAC;YACb,mBAAmB,EAAE,KAAK;YAC1B,mBAAmB,EAAE,KAAK;SAC7B,CAAC;IACN,CAAC;CACJ;AA5FD,gEA4FC","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\nimport {LimitedTimeOfferCampaign, LimitedTimeOfferParticipant} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {MarketingCampaignType, MarketingStatus, MarketingType, ValueType} from '@lyxa.ai/core/dist/utilities/enum';\nimport {GetLtoCampaignParticipantsDTO} from '../campaign/limited-time-offer-campaign.validation';\nimport {JoinLtoCampaignDTO} from './limited-time-offer-participant.validation';\n\nexport class LtoParticipantQueryBuilder {\n static buildCampaignFilter(dto: GetLtoCampaignParticipantsDTO) {\n return {campaign: dto.campaignId, isWithdrawn: false};\n }\n\n static buildSearchTerm(dto: GetLtoCampaignParticipantsDTO): string | undefined {\n return dto.search?.trim() || undefined;\n }\n\n static buildCreateInput(input: {\n campaignId: mongoose.Types.ObjectId;\n shopId: mongoose.Types.ObjectId;\n marketingId: mongoose.Types.ObjectId;\n dto: JoinLtoCampaignDTO;\n pausedMarketings?: mongoose.Types.ObjectId[];\n }) {\n const {campaignId, shopId, marketingId, dto, pausedMarketings = []} = input;\n return {\n campaign: campaignId,\n shop: shopId,\n marketing: marketingId,\n joinedAt: new Date(),\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 isWithdrawn: false,\n pausedMarketings,\n };\n }\n\n static buildCloneInput(\n campaignId: mongoose.Types.ObjectId,\n source: Pick<\n LimitedTimeOfferParticipant,\n | 'shop'\n | 'products'\n | 'isEntireMenu'\n | 'discountPercentage'\n | 'maxDiscountCap'\n | 'isOrderCapacityEnabled'\n | 'maxOrderCapacity'\n >,\n ) {\n return {\n campaign: campaignId,\n shop: source.shop,\n joinedAt: new Date(),\n products: source.products ?? [],\n isEntireMenu: source.isEntireMenu,\n discountPercentage: source.discountPercentage,\n maxDiscountCap: source.maxDiscountCap,\n isOrderCapacityEnabled: source.isOrderCapacityEnabled,\n maxOrderCapacity: source.maxOrderCapacity,\n isWithdrawn: false,\n pausedMarketings: [],\n };\n }\n\n static buildMarketingInput(\n shopId: mongoose.Types.ObjectId,\n campaign: LimitedTimeOfferCampaign & {_id: mongoose.Types.ObjectId},\n dto: JoinLtoCampaignDTO,\n ) {\n return {\n shop: shopId,\n marketingType: MarketingType.DISCOUNT,\n campaignType: MarketingCampaignType.LIMITED_TIME_OFFER,\n isAppliedByCompany: false,\n duration: {start: campaign.startDate, end: campaign.endDate},\n status: MarketingStatus.ACTIVE,\n isEntireMenu: dto.isEntireMenu,\n value: dto.isEntireMenu ? dto.discountPercentage : undefined,\n valueType: dto.isEntireMenu ? ValueType.PERCENTAGE : undefined,\n products: dto.isEntireMenu\n ? []\n : dto.products.map(productId => ({\n product: productId,\n value: dto.discountPercentage,\n valueType: ValueType.PERCENTAGE,\n })),\n maxDiscountPerOrder: dto.maxDiscountCap,\n isMaxDiscountPerOrderEnabled: dto.maxDiscountCap > 0,\n categories: [],\n excludeProducts: [],\n spendLimit: 0,\n isSpendLimitEnabled: false,\n isOnlyForSubscriber: false,\n };\n }\n}\n"]}
1
+ {"version":3,"file":"limited-time-offer-participant.builder.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.builder.ts"],"names":[],"mappings":";;;AAEA,4DAAmH;AAInH,MAAa,0BAA0B;IACnC,MAAM,CAAC,mBAAmB,CAAC,GAAkC;QACzD,OA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KAAK;SAC7B,CAAC;IACN,CAAC;CACJ;AA5GD,gEA4GC","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\nimport {LimitedTimeOfferCampaign, LimitedTimeOfferParticipant} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {MarketingCampaignType, MarketingStatus, MarketingType, ValueType} from '@lyxa.ai/core/dist/utilities/enum';\nimport {GetLtoCampaignParticipantsDTO} from '../campaign/limited-time-offer-campaign.validation';\nimport {JoinLtoCampaignDTO} from './limited-time-offer-participant.validation';\n\nexport class LtoParticipantQueryBuilder {\n static buildCampaignFilter(dto: GetLtoCampaignParticipantsDTO) {\n return {campaign: dto.campaignId, isWithdrawn: false};\n }\n\n static buildSearchTerm(dto: GetLtoCampaignParticipantsDTO): string | undefined {\n return dto.search?.trim() || undefined;\n }\n\n static buildCreateInput(input: {\n campaignId: mongoose.Types.ObjectId;\n shopId: mongoose.Types.ObjectId;\n marketingId: mongoose.Types.ObjectId;\n dto: JoinLtoCampaignDTO;\n pausedMarketings?: mongoose.Types.ObjectId[];\n pausedOrderCapacity?: number;\n pausedOrderCapacityEnabled?: boolean;\n }) {\n const {\n campaignId,\n shopId,\n marketingId,\n dto,\n pausedMarketings = [],\n pausedOrderCapacity,\n pausedOrderCapacityEnabled,\n } = input;\n return {\n campaign: campaignId,\n shop: shopId,\n marketing: marketingId,\n joinedAt: new Date(),\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 pausedOrderCapacity,\n pausedOrderCapacityEnabled,\n isWithdrawn: false,\n pausedMarketings,\n };\n }\n\n static buildCloneInput(\n campaignId: mongoose.Types.ObjectId,\n source: Pick<\n LimitedTimeOfferParticipant,\n | 'shop'\n | 'products'\n | 'isEntireMenu'\n | 'discountPercentage'\n | 'maxDiscountCap'\n | 'isOrderCapacityEnabled'\n | 'maxOrderCapacity'\n | 'pausedOrderCapacity'\n | 'pausedOrderCapacityEnabled'\n >,\n ) {\n return {\n campaign: campaignId,\n shop: source.shop,\n joinedAt: new Date(),\n products: source.products ?? [],\n isEntireMenu: source.isEntireMenu,\n discountPercentage: source.discountPercentage,\n maxDiscountCap: source.maxDiscountCap,\n isOrderCapacityEnabled: source.isOrderCapacityEnabled,\n maxOrderCapacity: source.maxOrderCapacity,\n pausedOrderCapacity: source.pausedOrderCapacity,\n pausedOrderCapacityEnabled: source.pausedOrderCapacityEnabled,\n isWithdrawn: false,\n pausedMarketings: [],\n };\n }\n\n static buildMarketingInput(\n shopId: mongoose.Types.ObjectId,\n campaign: LimitedTimeOfferCampaign & {_id: mongoose.Types.ObjectId},\n dto: JoinLtoCampaignDTO,\n ) {\n return {\n shop: shopId,\n marketingType: MarketingType.DISCOUNT,\n campaignType: MarketingCampaignType.LIMITED_TIME_OFFER,\n isAppliedByCompany: false,\n duration: {start: campaign.startDate, end: campaign.endDate},\n status: MarketingStatus.ACTIVE,\n isEntireMenu: dto.isEntireMenu,\n value: dto.isEntireMenu ? dto.discountPercentage : undefined,\n valueType: dto.isEntireMenu ? ValueType.PERCENTAGE : undefined,\n products: dto.isEntireMenu\n ? []\n : dto.products.map(productId => ({\n product: productId,\n value: dto.discountPercentage,\n valueType: ValueType.PERCENTAGE,\n })),\n maxDiscountPerOrder: dto.maxDiscountCap,\n isMaxDiscountPerOrderEnabled: dto.maxDiscountCap > 0,\n categories: [],\n excludeProducts: [],\n spendLimit: 0,\n isSpendLimitEnabled: false,\n isOnlyForSubscriber: false,\n };\n }\n}\n"]}
@@ -12,11 +12,18 @@ export declare class LtoParticipantRepository {
12
12
  longitude: number;
13
13
  }, maxDistance: number): Promise<any[]>;
14
14
  create(input: object): Promise<DocumentType<Model>>;
15
+ getShopOrderCapacity(shopId: mongoose.Types.ObjectId): Promise<{
16
+ orderCapacityEnabled: boolean;
17
+ orderCapacity?: number;
18
+ }>;
15
19
  updateShopOrderCapacity(shopId: mongoose.Types.ObjectId, isOrderCapacityEnabled: boolean, maxOrderCapacity?: number): Promise<(mongoose.Document<unknown, import("@typegoose/typegoose/lib/types").BeAnObject, import("@lyxa.ai/core/dist/libraries/mongo/models").Shop, import("@typegoose/typegoose/lib/types").BeAnyObject, {}> & Omit<import("@lyxa.ai/core/dist/libraries/mongo/models").Shop & {
16
20
  _id: mongoose.Types.ObjectId;
17
21
  } & {
18
22
  __v: number;
19
23
  }, "typegooseName"> & import("@typegoose/typegoose/lib/types").IObjectWithTypegooseFunction) | null>;
24
+ restoreShopOrderCapacity(shopId: mongoose.Types.ObjectId, pausedOrderCapacity?: number, pausedOrderCapacityEnabled?: boolean): Promise<void>;
25
+ private reevaluateShopBusyStatus;
26
+ private deriveCapacityStatus;
20
27
  findActiveByCampaignAndShop(campaignId: mongoose.Types.ObjectId, shopId: mongoose.Types.ObjectId): Promise<ParticipantSummaryDTO | null>;
21
28
  withdraw(campaignId: mongoose.Types.ObjectId, shopId: mongoose.Types.ObjectId): Promise<DocumentType<Model> | null>;
22
29
  existsActiveByCampaignAndShop(campaignId: mongoose.Types.ObjectId, shopId: mongoose.Types.ObjectId): Promise<boolean>;
@@ -28,6 +35,7 @@ export declare class LtoParticipantRepository {
28
35
  countNonWithdrawnByCampaign(campaignId: mongoose.Types.ObjectId): Promise<number>;
29
36
  findAllActiveByCampaign(campaignId: mongoose.Types.ObjectId): Promise<DocumentType<Model>[]>;
30
37
  findPausedMarketingIdsByCampaign(campaignId: mongoose.Types.ObjectId): Promise<mongoose.Types.ObjectId[]>;
38
+ clearLiveEffects(campaignId: mongoose.Types.ObjectId): Promise<void>;
31
39
  findActiveMarketingIdsByShop(shopId: mongoose.Types.ObjectId, marketingType: MarketingType): Promise<mongoose.Types.ObjectId[]>;
32
40
  findRevivableMarketings(ids: mongoose.Types.ObjectId[]): Promise<Array<{
33
41
  _id: mongoose.Types.ObjectId;
@@ -1 +1 @@
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,EACN,2BAA2B,IAAI,KAAK,EAKpC,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAwB,eAAe,EAAE,aAAa,EAAC,MAAM,mCAAmC,CAAC;AAExG,OAAO,EACN,6BAA6B,EAC7B,6BAA6B,EAC7B,MAAM,oDAAoD,CAAC;AAE5D,OAAO,EACN,6BAA6B,EAC7B,qBAAqB,EACrB,wBAAwB,EACxB,MAAM,6CAA6C,CAAC;AAErD,qBACa,wBAAwB;IACpC,OAAO,CAAC,KAAK,CAAmE;IAChF,OAAO,CAAC,SAAS,CAAmB;;IAQvB,UAAU,CACtB,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACnC,KAAK,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;KAClB,EACD,WAAW,EAAE,MAAM;IA2Cd,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAGnD,uBAAuB,CAC5B,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,sBAAsB,EAAE,OAAO,EAC/B,gBAAgB,CAAC,EAAE,MAAM;;;;;IAapB,2BAA2B,CAChC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACnC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAC7B,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAYlC,QAAQ,CACb,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACnC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAC7B,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,IAA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UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GACjC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAQ/B,4BAA4B,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAgB/H,uBAAuB,CAC5B,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GAC5B,OAAO,CAAC,KAAK,CAAC;QAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;QAAC,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAA;KAAC,CAAC,CAAC;IAY1E,qBAAqB,CAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7F,8BAA8B,CACnC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GACjC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAU/B,cAAc,CACnB,GAAG,EAAE,6BAA6B,GAChC,OAAO,CAAC;QAAE,SAAS,EAAE,6BAA6B,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CA8CzE;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,EACN,2BAA2B,IAAI,KAAK,EAMpC,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAEN,eAAe,EACf,aAAa,EAGb,MAAM,mCAAm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ShopOrderCapacity(shopId) {
100
+ const shop = await this.shopModel
101
+ .findById(shopId)
102
+ .select('orderCapacityEnabled orderCapacity')
103
+ .lean();
104
+ return {
105
+ orderCapacityEnabled: shop?.orderCapacityEnabled ?? false,
106
+ orderCapacity: shop?.orderCapacity,
107
+ };
108
+ }
99
109
  async updateShopOrderCapacity(shopId, isOrderCapacityEnabled, maxOrderCapacity) {
100
110
  return this.shopModel.findByIdAndUpdate(shopId, {
101
111
  $set: {
@@ -104,6 +114,50 @@ let LtoParticipantRepository = class LtoParticipantRepository {
104
114
  },
105
115
  }, { new: true });
106
116
  }
117
+ async restoreShopOrderCapacity(shopId, pausedOrderCapacity, pausedOrderCapacityEnabled) {
118
+ if (pausedOrderCapacityEnabled === undefined)
119
+ return;
120
+ await this.shopModel.findByIdAndUpdate(shopId, {
121
+ $set: {
122
+ orderCapacityEnabled: pausedOrderCapacityEnabled ?? false,
123
+ orderCapacity: pausedOrderCapacity,
124
+ },
125
+ });
126
+ await this.reevaluateShopBusyStatus(shopId);
127
+ }
128
+ async reevaluateShopBusyStatus(shopId) {
129
+ const shop = await this.shopModel
130
+ .findById(shopId)
131
+ .select('orderCapacityEnabled orderCapacity onlineStatus')
132
+ .lean();
133
+ if (!shop ||
134
+ (shop.onlineStatus !== enum_1.ShopOnlineStatus.ONLINE && shop.onlineStatus !== enum_1.ShopOnlineStatus.BUSY)) {
135
+ return;
136
+ }
137
+ const nextStatus = await this.deriveCapacityStatus(shopId, shop.orderCapacityEnabled, shop.orderCapacity);
138
+ if (nextStatus === shop.onlineStatus)
139
+ return;
140
+ await this.shopModel.findByIdAndUpdate(shopId, { $set: { onlineStatus: nextStatus } });
141
+ }
142
+ async deriveCapacityStatus(shopId, orderCapacityEnabled, orderCapacity) {
143
+ if (!orderCapacityEnabled)
144
+ return enum_1.ShopOnlineStatus.ONLINE;
145
+ const activeOrderCount = await models_1.RegularOrderModel.countDocuments({
146
+ shop: shopId,
147
+ status: {
148
+ $in: [
149
+ enum_1.RegularOrderStatus.PLACED,
150
+ enum_1.RegularOrderStatus.PREPARING,
151
+ enum_1.RegularOrderStatus.READY_FOR_PICKUP,
152
+ enum_1.RegularOrderStatus.ACCEPTED_BY_RIDER,
153
+ ],
154
+ },
155
+ deletedAt: null,
156
+ });
157
+ return activeOrderCount >= (orderCapacity ?? Infinity)
158
+ ? enum_1.ShopOnlineStatus.BUSY
159
+ : enum_1.ShopOnlineStatus.ONLINE;
160
+ }
107
161
  async findActiveByCampaignAndShop(campaignId, shopId) {
108
162
  const result = await this.model
109
163
  .findOne({ campaign: campaignId, shop: shopId, isWithdrawn: false })
@@ -169,6 +223,12 @@ let LtoParticipantRepository = class LtoParticipantRepository {
169
223
  .lean();
170
224
  return participants.flatMap(p => (p.pausedMarketings ?? []));
171
225
  }
226
+ async clearLiveEffects(campaignId) {
227
+ await this.model.updateMany({ campaign: campaignId, isWithdrawn: false }, {
228
+ $set: { pausedMarketings: [] },
229
+ $unset: { marketing: '', pausedOrderCapacity: '', pausedOrderCapacityEnabled: '' },
230
+ });
231
+ }
172
232
  async findActiveMarketingIdsByShop(shopId, marketingType) {
173
233
  const marketings = await models_1.MarketingModel.find({
174
234
  shop: shopId,
@@ -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,sEAMmD;AACnD,4DAAwG;AAMxG,qGAAoF;AAQ7E,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAC5B,KAAK,CAAmE;IACxE,SAAS,CAAmB;IAEpC;QACC,IAAI,CAAC,KAAK,GAAG,yCACU,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,kBAA6B,CAAC;IAChD,CAAC;IAEM,KAAK,CAAC,UAAU,CACtB,UAAmC,EACnC,KAGC,EACD,WAAmB;QAEnB,MAAM,YA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AAE,CAAC,CAAC,EAAE,EAAE;YAC3B;gBACC,MAAM,EAAE;oBACP,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;oBAC5B,SAAS,EAAE;wBACV,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE;wBACpC,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE;wBACpB;4BACC,QAAQ,EAAE;gCACT,MAAM,EAAE,eAAe;gCACvB,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;gCAC/C,SAAS,EAAE,EAAE,OAAO,EAAE,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;gCAChD,QAAQ,EAAE,CAAC;gCACX,kBAAkB,EAAE,CAAC;gCACrB,cAAc,EAAE,CAAC;6BACjB;yBACD;qBACD;iBACD;aACD;SACD,CAAC,CAAC;QAEH,OAAO;YACN,SAAS,EAAE,MAAM,EAAE,SAAS,IAAI,EAAE;YAClC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC;SACrC,CAAC;IACH,CAAC;CACD,CAAA;AAvRY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,gBAAO,GAAE;;GACG,wBAAwB,CAuRpC;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\tLimitedTimeOfferParticipant as Model,\n\tLimitedTimeOfferParticipantModel,\n\tMarketingModel,\n\tProductModel,\n\tShopModel,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {MarketingCampaignType, MarketingStatus, MarketingType} from '@lyxa.ai/core/dist/utilities/enum';\nimport {SoftDeleteModel} from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport {\n\tGetLtoCampaignParticipantsDTO,\n\tLtoCampaignParticipantItemDTO,\n} from '../campaign/limited-time-offer-campaign.validation';\nimport {LtoParticipantQueryBuilder} from './limited-time-offer-participant.builder';\nimport {\n\tActiveParticipantMarketingDTO,\n\tParticipantSummaryDTO,\n\tUpdateParticipantDataDTO,\n} from './limited-time-offer-participant.validation';\n\n@Service()\nexport class LtoParticipantRepository {\n\tprivate model: typeof LimitedTimeOfferParticipantModel & SoftDeleteModel<Model>;\n\tprivate shopModel: typeof ShopModel;\n\n\tconstructor() {\n\t\tthis.model = LimitedTimeOfferParticipantModel as typeof LimitedTimeOfferParticipantModel &\n\t\t\tSoftDeleteModel<Model>;\n\t\tthis.shopModel = ShopModel as typeof ShopModel;\n\t}\n\n\tpublic async findNearby(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tinput: {\n\t\t\tlatitude: number;\n\t\t\tlongitude: number;\n\t\t},\n\t\tmaxDistance: number\n\t) {\n\t\tconst participants = await this.model\n\t\t\t.find({\n\t\t\t\tcampaign: campaignId,\n\t\t\t\tisWithdrawn: false,\n\t\t\t\tdeletedAt: null,\n\t\t\t})\n\t\t\t.select('shop')\n\t\t\t.lean();\n\n\t\tif (!participants.length) return [];\n\n\t\tconst shopIds = participants.map(p => p.shop);\n\n\t\treturn this.shopModel.aggregate([\n\t\t\t{\n\t\t\t\t$geoNear: {\n\t\t\t\t\tnear: {\n\t\t\t\t\t\ttype: 'Point',\n\t\t\t\t\t\tcoordinates: [input.longitude, input.latitude],\n\t\t\t\t\t},\n\t\t\t\t\tdistanceField: 'distance',\n\t\t\t\t\tmaxDistance: maxDistance,\n\t\t\t\t\tspherical: true,\n\t\t\t\t\tkey: 'address.location',\n\t\t\t\t\tquery: {\n\t\t\t\t\t\t_id: { $in: shopIds },\n\t\t\t\t\t\tstatus: 'active',\n\t\t\t\t\t\tdeletedAt: null,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t$project: {\n\t\t\t\t\t_id: 1,\n\t\t\t\t\tname: 1,\n\t\t\t\t\t'address.location': 1,\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tasync create(input: object): Promise<DocumentType<Model>> {\n\t\treturn this.model.create(input);\n\t}\n\tasync updateShopOrderCapacity(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tisOrderCapacityEnabled: boolean,\n\t\tmaxOrderCapacity?: number\n\t) {\n\t\treturn this.shopModel.findByIdAndUpdate(\n\t\t\tshopId,\n\t\t\t{\n\t\t\t\t$set: {\n\t\t\t\t\torderCapacityEnabled: isOrderCapacityEnabled,\n\t\t\t\t\torderCapacity: maxOrderCapacity,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{ new: true }\n\t\t);\n\t}\n\tasync findActiveByCampaignAndShop(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<ParticipantSummaryDTO | null> {\n\t\tconst result = await this.model\n\t\t\t.findOne({ campaign: campaignId, shop: shopId, isWithdrawn: false })\n\t\t\t.select(\n\t\t\t\t'discountPercentage maxDiscountCap joinedAt isEntireMenu isOrderCapacityEnabled maxOrderCapacity products marketing'\n\t\t\t)\n\t\t\t.lean();\n\t\tif (!result) return null;\n\t\tconst { products, marketing, ...rest } = result as any;\n\t\treturn { ...rest, productIds: products ?? [], marketingId: marketing };\n\t}\n\n\tasync withdraw(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<DocumentType<Model> | null> {\n\t\treturn this.model.findOneAndUpdate(\n\t\t\t{ campaign: campaignId, shop: shopId, isWithdrawn: false },\n\t\t\t{ $set: { isWithdrawn: true, withdrawnAt: new Date() } },\n\t\t\t{ new: true }\n\t\t);\n\t}\n\n\tasync existsActiveByCampaignAndShop(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<boolean> {\n\t\treturn !!(await this.model.exists({ campaign: campaignId, shop: shopId, isWithdrawn: false }));\n\t}\n\n\tasync findActiveForUpdate(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<ActiveParticipantMarketingDTO | null> {\n\t\tconst result = await this.model\n\t\t\t.findOne({ campaign: campaignId, shop: shopId, isWithdrawn: false })\n\t\t\t.select('marketing')\n\t\t\t.lean();\n\t\tif (!result) return null;\n\t\treturn { marketingId: (result as any).marketing };\n\t}\n\n\tasync updateParticipant(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdata: UpdateParticipantDataDTO\n\t): Promise<DocumentType<Model> | null> {\n\t\treturn this.model.findOneAndUpdate(\n\t\t\t{ campaign: campaignId, shop: shopId, isWithdrawn: false },\n\t\t\t{ $set: data },\n\t\t\t{ new: true }\n\t\t);\n\t}\n\n\tasync countShopProducts(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tproductIds: mongoose.Types.ObjectId[]\n\t): Promise<number> {\n\t\tif (!productIds.length) return 0;\n\t\treturn ProductModel.countDocuments({ _id: { $in: productIds }, shop: shopId, deletedAt: null });\n\t}\n\n\tasync findProductIdsByCategories(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tcategoryIds: mongoose.Types.ObjectId[]\n\t): Promise<mongoose.Types.ObjectId[]> {\n\t\tif (!categoryIds.length) return [];\n\t\t// Shop-scoped so the {shop, shopCategory} partial index is used; only _id is needed.\n\t\tconst products = await ProductModel.find({\n\t\t\tshop: shopId,\n\t\t\tshopCategory: { $in: categoryIds },\n\t\t\tdeletedAt: null,\n\t\t})\n\t\t\t.select('_id')\n\t\t\t.lean();\n\t\treturn products.map(p => p._id as mongoose.Types.ObjectId);\n\t}\n\n\tasync findMarketingIdsByCampaign(campaignId: mongoose.Types.ObjectId): Promise<mongoose.Types.ObjectId[]> {\n\t\tconst participants = await this.model\n\t\t\t.find({ campaign: campaignId, isWithdrawn: false, marketing: { $exists: true, $ne: null } })\n\t\t\t.select('marketing')\n\t\t\t.lean();\n\t\treturn participants.map(p => p.marketing as mongoose.Types.ObjectId).filter(Boolean);\n\t}\n\n\tasync countNonWithdrawnByCampaign(campaignId: mongoose.Types.ObjectId): Promise<number> {\n\t\treturn this.model.countDocuments({campaign: campaignId, isWithdrawn: false});\n\t}\n\n\tasync findAllActiveByCampaign(campaignId: mongoose.Types.ObjectId): Promise<DocumentType<Model>[]> {\n\t\treturn this.model.find({campaign: campaignId, isWithdrawn: false});\n\t}\n\n\tasync findPausedMarketingIdsByCampaign(\n\t\tcampaignId: mongoose.Types.ObjectId\n\t): Promise<mongoose.Types.ObjectId[]> {\n\t\tconst participants = await this.model\n\t\t\t.find({ campaign: campaignId, isWithdrawn: false, pausedMarketings: { $exists: true, $ne: [] } })\n\t\t\t.select('pausedMarketings')\n\t\t\t.lean();\n\t\treturn participants.flatMap(p => (p.pausedMarketings ?? []) as mongoose.Types.ObjectId[]);\n\t}\n\n\tasync findActiveMarketingIdsByShop(shopId: mongoose.Types.ObjectId, marketingType: MarketingType): Promise<mongoose.Types.ObjectId[]> {\n\t\tconst marketings = await MarketingModel.find({\n\t\t\tshop: shopId,\n\t\t\tmarketingType,\n\t\t\tcampaignType: {\n\t\t\t\t$in: [MarketingCampaignType.STANDARD, null],\n\t\t\t},\n\t\t\tstatus: MarketingStatus.ACTIVE,\n\t\t\tdeletedAt: null,\n\t\t\t'duration.end': {$gt: new Date()},\n\t\t})\n\t\t\t.select('_id')\n\t\t\t.lean();\n\t\treturn marketings.map(m => m._id as mongoose.Types.ObjectId);\n\t}\n\n\tasync findRevivableMarketings(\n\t\tids: mongoose.Types.ObjectId[]\n\t): Promise<Array<{_id: mongoose.Types.ObjectId; shop: mongoose.Types.ObjectId}>> {\n\t\tconst results = await MarketingModel.find({\n\t\t\t_id: {$in: ids},\n\t\t\tstatus: MarketingStatus.PAUSED,\n\t\t\tdeletedAt: null,\n\t\t\t'duration.end': {$gt: new Date()},\n\t\t})\n\t\t\t.select('_id shop')\n\t\t\t.lean();\n\t\treturn results as Array<{_id: mongoose.Types.ObjectId; shop: mongoose.Types.ObjectId}>;\n\t}\n\n\tasync updateMarketingStatus(ids: mongoose.Types.ObjectId[], status: MarketingStatus): Promise<void> {\n\t\tawait MarketingModel.updateMany({_id: {$in: ids}}, {$set: {status}});\n\t}\n\n\tasync findParticipantIdsByCampaignId(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t): Promise<mongoose.Types.ObjectId[]> {\n\t\tconst participants = await this.model\n\t\t\t.find({campaign: campaignId, isWithdrawn: false})\n\t\t\t.select(\"shop\")\n\t\t\t.lean()\n\t\t\t.exec();\n\n\t\treturn participants.map((p) => p.shop as mongoose.Types.ObjectId);\n\t}\n\n\tasync findByCampaign(\n\t\tdto: GetLtoCampaignParticipantsDTO\n\t): Promise<{ documents: LtoCampaignParticipantItemDTO[]; total: number }> {\n\t\tconst filter = LtoParticipantQueryBuilder.buildCampaignFilter(dto);\n\t\tconst search = LtoParticipantQueryBuilder.buildSearchTerm(dto);\n\n\t\tconst [result] = await this.model.aggregate([\n\t\t\t{ $match: filter },\n\t\t\t{\n\t\t\t\t$lookup: {\n\t\t\t\t\tfrom: ShopModel.collection.name,\n\t\t\t\t\tlet: { shopId: '$shop' },\n\t\t\t\t\tpipeline: [\n\t\t\t\t\t\t{ $match: { $expr: { $eq: ['$_id', '$$shopId'] } } },\n\t\t\t\t\t\t{ $project: { name: 1, logo: 1 } },\n\t\t\t\t\t],\n\t\t\t\t\tas: 'shopData',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{ $unwind: { path: '$shopData', preserveNullAndEmptyArrays: true } },\n\t\t\t...(search ? [{ $match: { 'shopData.name': { $regex: search, $options: 'i' } } }] : []),\n\t\t\t{ $sort: { joinedAt: -1 } },\n\t\t\t{\n\t\t\t\t$facet: {\n\t\t\t\t\ttotal: [{ $count: 'count' }],\n\t\t\t\t\tdocuments: [\n\t\t\t\t\t\t{ $skip: (dto.page - 1) * dto.size },\n\t\t\t\t\t\t{ $limit: dto.size },\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$project: {\n\t\t\t\t\t\t\t\tshopId: '$shopData._id',\n\t\t\t\t\t\t\t\tshopName: { $ifNull: ['$shopData.name', null] },\n\t\t\t\t\t\t\t\tshopPhoto: { $ifNull: ['$shopData.logo', null] },\n\t\t\t\t\t\t\t\tjoinedAt: 1,\n\t\t\t\t\t\t\t\tdiscountPercentage: 1,\n\t\t\t\t\t\t\t\tmaxDiscountCap: 1,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\n\t\treturn {\n\t\t\tdocuments: result?.documents ?? [],\n\t\t\ttotal: result?.total?.[0]?.count ?? 0,\n\t\t};\n\t}\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,sEAOmD;AACnD,4DAM2C;AAM3C,qGAAoF;AAQ7E,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAC5B,KAAK,CAAmE;IACxE,SAAS,CAAmB;IAEpC;QACC,IAAI,CAAC,KAAK,GAAG,yCACU,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,kBAA6B,CAAC;IAChD,CAAC;IAEM,KAAK,CAAC,UAAU,CACtB,UAAmC,EACnC,KAGC,EACD,WAAmB;QAEnB,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,KAAK;aACnC,IAAI,CAAC;YACL,QAAQ,EAAE,UAAU;YACpB,WAAW,EAAE,KAAK;YAClB,SAAS,EAAE,IAAI;SACf,CAAC;aACD,MAAM,CAAC,MAAM,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,IAAI,CAAC,EAAE;gCAC/C,SAAS,EAAE,EAAE,OAAO,EAAE,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;gCAChD,QAAQ,EAAE,CAAC;gCACX,kBAAkB,EAAE,CAAC;gCACrB,cAAc,EAAE,CAAC;6BACjB;yBACD;qBACD;iBACD;aACD;SACD,CAAC,CAAC;QAEH,OAAO;YACN,SAAS,EAAE,MAAM,EAAE,SAAS,IAAI,EAAE;YAClC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC;SACrC,CAAC;IACH,CAAC;CACD,CAAA;AAzXY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,gBAAO,GAAE;;GACG,wBAAwB,CAyXpC;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\tLimitedTimeOfferParticipant as Model,\n\tLimitedTimeOfferParticipantModel,\n\tMarketingModel,\n\tProductModel,\n\tRegularOrderModel,\n\tShopModel,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {\n\tMarketingCampaignType,\n\tMarketingStatus,\n\tMarketingType,\n\tRegularOrderStatus,\n\tShopOnlineStatus,\n} from '@lyxa.ai/core/dist/utilities/enum';\nimport {SoftDeleteModel} from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport {\n\tGetLtoCampaignParticipantsDTO,\n\tLtoCampaignParticipantItemDTO,\n} from '../campaign/limited-time-offer-campaign.validation';\nimport {LtoParticipantQueryBuilder} from './limited-time-offer-participant.builder';\nimport {\n\tActiveParticipantMarketingDTO,\n\tParticipantSummaryDTO,\n\tUpdateParticipantDataDTO,\n} from './limited-time-offer-participant.validation';\n\n@Service()\nexport class LtoParticipantRepository {\n\tprivate model: typeof LimitedTimeOfferParticipantModel & SoftDeleteModel<Model>;\n\tprivate shopModel: typeof ShopModel;\n\n\tconstructor() {\n\t\tthis.model = LimitedTimeOfferParticipantModel as typeof LimitedTimeOfferParticipantModel &\n\t\t\tSoftDeleteModel<Model>;\n\t\tthis.shopModel = ShopModel as typeof ShopModel;\n\t}\n\n\tpublic async findNearby(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tinput: {\n\t\t\tlatitude: number;\n\t\t\tlongitude: number;\n\t\t},\n\t\tmaxDistance: number\n\t) {\n\t\tconst participants = await this.model\n\t\t\t.find({\n\t\t\t\tcampaign: campaignId,\n\t\t\t\tisWithdrawn: false,\n\t\t\t\tdeletedAt: null,\n\t\t\t})\n\t\t\t.select('shop')\n\t\t\t.lean();\n\n\t\tif (!participants.length) return [];\n\n\t\tconst shopIds = participants.map(p => p.shop);\n\n\t\treturn this.shopModel.aggregate([\n\t\t\t{\n\t\t\t\t$geoNear: {\n\t\t\t\t\tnear: {\n\t\t\t\t\t\ttype: 'Point',\n\t\t\t\t\t\tcoordinates: [input.longitude, input.latitude],\n\t\t\t\t\t},\n\t\t\t\t\tdistanceField: 'distance',\n\t\t\t\t\tmaxDistance: maxDistance,\n\t\t\t\t\tspherical: true,\n\t\t\t\t\tkey: 'address.location',\n\t\t\t\t\tquery: {\n\t\t\t\t\t\t_id: { $in: shopIds },\n\t\t\t\t\t\tstatus: 'active',\n\t\t\t\t\t\tdeletedAt: null,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t$project: {\n\t\t\t\t\t_id: 1,\n\t\t\t\t\tname: 1,\n\t\t\t\t\t'address.location': 1,\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tasync create(input: object): Promise<DocumentType<Model>> {\n\t\treturn this.model.create(input);\n\t}\n\n\tasync getShopOrderCapacity(\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<{ orderCapacityEnabled: boolean; orderCapacity?: number }> {\n\t\tconst shop = await this.shopModel\n\t\t\t.findById(shopId)\n\t\t\t.select('orderCapacityEnabled orderCapacity')\n\t\t\t.lean();\n\t\treturn {\n\t\t\torderCapacityEnabled: shop?.orderCapacityEnabled ?? false,\n\t\t\torderCapacity: shop?.orderCapacity,\n\t\t};\n\t}\n\n\tasync updateShopOrderCapacity(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tisOrderCapacityEnabled: boolean,\n\t\tmaxOrderCapacity?: number\n\t) {\n\t\treturn this.shopModel.findByIdAndUpdate(\n\t\t\tshopId,\n\t\t\t{\n\t\t\t\t$set: {\n\t\t\t\t\torderCapacityEnabled: isOrderCapacityEnabled,\n\t\t\t\t\torderCapacity: maxOrderCapacity,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{ new: true }\n\t\t);\n\t}\n\n\t// Restores the shop's own capacity config saved when the LTO overrode it, then re-derives the\n\t// shop's BUSY/ONLINE state against that restored capacity (a shop still over its own capacity\n\t// stays BUSY; one that now fits becomes ONLINE).\n\tasync restoreShopOrderCapacity(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tpausedOrderCapacity?: number,\n\t\tpausedOrderCapacityEnabled?: boolean\n\t): Promise<void> {\n\t\t// No snapshot means the LTO never overrode this shop's capacity — nothing to restore.\n\t\tif (pausedOrderCapacityEnabled === undefined) return;\n\n\t\tawait this.shopModel.findByIdAndUpdate(shopId, {\n\t\t\t$set: {\n\t\t\t\torderCapacityEnabled: pausedOrderCapacityEnabled ?? false,\n\t\t\t\torderCapacity: pausedOrderCapacity,\n\t\t\t},\n\t\t});\n\t\tawait this.reevaluateShopBusyStatus(shopId);\n\t}\n\n\tprivate async reevaluateShopBusyStatus(shopId: mongoose.Types.ObjectId): Promise<void> {\n\t\tconst shop = await this.shopModel\n\t\t\t.findById(shopId)\n\t\t\t.select('orderCapacityEnabled orderCapacity onlineStatus')\n\t\t\t.lean();\n\t\t// Only manage the capacity-driven ONLINE↔BUSY flip; leave an owner-set OFFLINE shop untouched.\n\t\tif (\n\t\t\t!shop ||\n\t\t\t(shop.onlineStatus !== ShopOnlineStatus.ONLINE && shop.onlineStatus !== ShopOnlineStatus.BUSY)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst nextStatus = await this.deriveCapacityStatus(\n\t\t\tshopId,\n\t\t\tshop.orderCapacityEnabled,\n\t\t\tshop.orderCapacity\n\t\t);\n\t\tif (nextStatus === shop.onlineStatus) return;\n\n\t\tawait this.shopModel.findByIdAndUpdate(shopId, { $set: { onlineStatus: nextStatus } });\n\t}\n\n\t// Availability implied purely by the (restored) capacity: BUSY once active orders reach it,\n\t// ONLINE while below it or when capacity is disabled.\n\tprivate async deriveCapacityStatus(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\torderCapacityEnabled?: boolean,\n\t\torderCapacity?: number\n\t): Promise<ShopOnlineStatus> {\n\t\tif (!orderCapacityEnabled) return ShopOnlineStatus.ONLINE;\n\n\t\tconst activeOrderCount = await RegularOrderModel.countDocuments({\n\t\t\tshop: shopId,\n\t\t\tstatus: {\n\t\t\t\t$in: [\n\t\t\t\t\tRegularOrderStatus.PLACED,\n\t\t\t\t\tRegularOrderStatus.PREPARING,\n\t\t\t\t\tRegularOrderStatus.READY_FOR_PICKUP,\n\t\t\t\t\tRegularOrderStatus.ACCEPTED_BY_RIDER,\n\t\t\t\t],\n\t\t\t},\n\t\t\tdeletedAt: null,\n\t\t});\n\n\t\treturn activeOrderCount >= (orderCapacity ?? Infinity)\n\t\t\t? ShopOnlineStatus.BUSY\n\t\t\t: ShopOnlineStatus.ONLINE;\n\t}\n\tasync findActiveByCampaignAndShop(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<ParticipantSummaryDTO | null> {\n\t\tconst result = await this.model\n\t\t\t.findOne({ campaign: campaignId, shop: shopId, isWithdrawn: false })\n\t\t\t.select(\n\t\t\t\t'discountPercentage maxDiscountCap joinedAt isEntireMenu isOrderCapacityEnabled maxOrderCapacity products marketing'\n\t\t\t)\n\t\t\t.lean();\n\t\tif (!result) return null;\n\t\tconst { products, marketing, ...rest } = result as any;\n\t\treturn { ...rest, productIds: products ?? [], marketingId: marketing };\n\t}\n\n\tasync withdraw(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<DocumentType<Model> | null> {\n\t\treturn this.model.findOneAndUpdate(\n\t\t\t{ campaign: campaignId, shop: shopId, isWithdrawn: false },\n\t\t\t{ $set: { isWithdrawn: true, withdrawnAt: new Date() } },\n\t\t\t{ new: true }\n\t\t);\n\t}\n\n\tasync existsActiveByCampaignAndShop(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<boolean> {\n\t\treturn !!(await this.model.exists({ campaign: campaignId, shop: shopId, isWithdrawn: false }));\n\t}\n\n\tasync findActiveForUpdate(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<ActiveParticipantMarketingDTO | null> {\n\t\tconst result = await this.model\n\t\t\t.findOne({ campaign: campaignId, shop: shopId, isWithdrawn: false })\n\t\t\t.select('marketing')\n\t\t\t.lean();\n\t\tif (!result) return null;\n\t\treturn { marketingId: (result as any).marketing };\n\t}\n\n\tasync updateParticipant(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdata: UpdateParticipantDataDTO\n\t): Promise<DocumentType<Model> | null> {\n\t\treturn this.model.findOneAndUpdate(\n\t\t\t{ campaign: campaignId, shop: shopId, isWithdrawn: false },\n\t\t\t{ $set: data },\n\t\t\t{ new: true }\n\t\t);\n\t}\n\n\tasync countShopProducts(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tproductIds: mongoose.Types.ObjectId[]\n\t): Promise<number> {\n\t\tif (!productIds.length) return 0;\n\t\treturn ProductModel.countDocuments({ _id: { $in: productIds }, shop: shopId, deletedAt: null });\n\t}\n\n\tasync findProductIdsByCategories(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tcategoryIds: mongoose.Types.ObjectId[]\n\t): Promise<mongoose.Types.ObjectId[]> {\n\t\tif (!categoryIds.length) return [];\n\t\t// Shop-scoped so the {shop, shopCategory} partial index is used; only _id is needed.\n\t\tconst products = await ProductModel.find({\n\t\t\tshop: shopId,\n\t\t\tshopCategory: { $in: categoryIds },\n\t\t\tdeletedAt: null,\n\t\t})\n\t\t\t.select('_id')\n\t\t\t.lean();\n\t\treturn products.map(p => p._id as mongoose.Types.ObjectId);\n\t}\n\n\tasync findMarketingIdsByCampaign(campaignId: mongoose.Types.ObjectId): Promise<mongoose.Types.ObjectId[]> {\n\t\tconst participants = await this.model\n\t\t\t.find({ campaign: campaignId, isWithdrawn: false, marketing: { $exists: true, $ne: null } })\n\t\t\t.select('marketing')\n\t\t\t.lean();\n\t\treturn participants.map(p => p.marketing as mongoose.Types.ObjectId).filter(Boolean);\n\t}\n\n\tasync countNonWithdrawnByCampaign(campaignId: mongoose.Types.ObjectId): Promise<number> {\n\t\treturn this.model.countDocuments({campaign: campaignId, isWithdrawn: false});\n\t}\n\n\tasync findAllActiveByCampaign(campaignId: mongoose.Types.ObjectId): Promise<DocumentType<Model>[]> {\n\t\treturn this.model.find({campaign: campaignId, isWithdrawn: false});\n\t}\n\n\tasync findPausedMarketingIdsByCampaign(\n\t\tcampaignId: mongoose.Types.ObjectId\n\t): Promise<mongoose.Types.ObjectId[]> {\n\t\tconst participants = await this.model\n\t\t\t.find({ campaign: campaignId, isWithdrawn: false, pausedMarketings: { $exists: true, $ne: [] } })\n\t\t\t.select('pausedMarketings')\n\t\t\t.lean();\n\t\treturn participants.flatMap(p => (p.pausedMarketings ?? []) as mongoose.Types.ObjectId[]);\n\t}\n\n\t// Puts a campaign's non-withdrawn participants back into \"not yet live\" shape after it's demoted\n\t// from ACTIVE back to SCHEDULED (postponed startDate). The stale LTO marketing ref is cleared (the\n\t// underlying doc was already soft-deleted by removeAllCampaignMarketings) so the next real\n\t// activation creates a fresh one against the new dates — the same shape recurring clones already use.\n\tasync clearLiveEffects(campaignId: mongoose.Types.ObjectId): Promise<void> {\n\t\tawait this.model.updateMany(\n\t\t\t{campaign: campaignId, isWithdrawn: false},\n\t\t\t{\n\t\t\t\t$set: {pausedMarketings: []},\n\t\t\t\t$unset: {marketing: '', pausedOrderCapacity: '', pausedOrderCapacityEnabled: ''},\n\t\t\t}\n\t\t);\n\t}\n\n\tasync findActiveMarketingIdsByShop(shopId: mongoose.Types.ObjectId, marketingType: MarketingType): Promise<mongoose.Types.ObjectId[]> {\n\t\tconst marketings = await MarketingModel.find({\n\t\t\tshop: shopId,\n\t\t\tmarketingType,\n\t\t\tcampaignType: {\n\t\t\t\t$in: [MarketingCampaignType.STANDARD, null],\n\t\t\t},\n\t\t\tstatus: MarketingStatus.ACTIVE,\n\t\t\tdeletedAt: null,\n\t\t\t'duration.end': {$gt: new Date()},\n\t\t})\n\t\t\t.select('_id')\n\t\t\t.lean();\n\t\treturn marketings.map(m => m._id as mongoose.Types.ObjectId);\n\t}\n\n\tasync findRevivableMarketings(\n\t\tids: mongoose.Types.ObjectId[]\n\t): Promise<Array<{_id: mongoose.Types.ObjectId; shop: mongoose.Types.ObjectId}>> {\n\t\tconst results = await MarketingModel.find({\n\t\t\t_id: {$in: ids},\n\t\t\tstatus: MarketingStatus.PAUSED,\n\t\t\tdeletedAt: null,\n\t\t\t'duration.end': {$gt: new Date()},\n\t\t})\n\t\t\t.select('_id shop')\n\t\t\t.lean();\n\t\treturn results as Array<{_id: mongoose.Types.ObjectId; shop: mongoose.Types.ObjectId}>;\n\t}\n\n\tasync updateMarketingStatus(ids: mongoose.Types.ObjectId[], status: MarketingStatus): Promise<void> {\n\t\tawait MarketingModel.updateMany({_id: {$in: ids}}, {$set: {status}});\n\t}\n\n\tasync findParticipantIdsByCampaignId(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t): Promise<mongoose.Types.ObjectId[]> {\n\t\tconst participants = await this.model\n\t\t\t.find({campaign: campaignId, isWithdrawn: false})\n\t\t\t.select(\"shop\")\n\t\t\t.lean()\n\t\t\t.exec();\n\n\t\treturn participants.map((p) => p.shop as mongoose.Types.ObjectId);\n\t}\n\n\tasync findByCampaign(\n\t\tdto: GetLtoCampaignParticipantsDTO\n\t): Promise<{ documents: LtoCampaignParticipantItemDTO[]; total: number }> {\n\t\tconst filter = LtoParticipantQueryBuilder.buildCampaignFilter(dto);\n\t\tconst search = LtoParticipantQueryBuilder.buildSearchTerm(dto);\n\n\t\tconst [result] = await this.model.aggregate([\n\t\t\t{ $match: filter },\n\t\t\t{\n\t\t\t\t$lookup: {\n\t\t\t\t\tfrom: ShopModel.collection.name,\n\t\t\t\t\tlet: { shopId: '$shop' },\n\t\t\t\t\tpipeline: [\n\t\t\t\t\t\t{ $match: { $expr: { $eq: ['$_id', '$$shopId'] } } },\n\t\t\t\t\t\t{ $project: { name: 1, logo: 1 } },\n\t\t\t\t\t],\n\t\t\t\t\tas: 'shopData',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{ $unwind: { path: '$shopData', preserveNullAndEmptyArrays: true } },\n\t\t\t...(search ? [{ $match: { 'shopData.name': { $regex: search, $options: 'i' } } }] : []),\n\t\t\t{ $sort: { joinedAt: -1 } },\n\t\t\t{\n\t\t\t\t$facet: {\n\t\t\t\t\ttotal: [{ $count: 'count' }],\n\t\t\t\t\tdocuments: [\n\t\t\t\t\t\t{ $skip: (dto.page - 1) * dto.size },\n\t\t\t\t\t\t{ $limit: dto.size },\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$project: {\n\t\t\t\t\t\t\t\tshopId: '$shopData._id',\n\t\t\t\t\t\t\t\tshopName: { $ifNull: ['$shopData.name', null] },\n\t\t\t\t\t\t\t\tshopPhoto: { $ifNull: ['$shopData.logo', null] },\n\t\t\t\t\t\t\t\tjoinedAt: 1,\n\t\t\t\t\t\t\t\tdiscountPercentage: 1,\n\t\t\t\t\t\t\t\tmaxDiscountCap: 1,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\n\t\treturn {\n\t\t\tdocuments: result?.documents ?? [],\n\t\t\ttotal: result?.total?.[0]?.count ?? 0,\n\t\t};\n\t}\n}\n\nexport const ltoParticipantRepository = Container.get(LtoParticipantRepository);\n"]}
@@ -61,8 +61,8 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
61
61
  withdrawnAt?: Date | null | undefined;
62
62
  }[];
63
63
  metadata?: {
64
- page: number;
65
64
  size: number;
65
+ page: number;
66
66
  totalElements: number;
67
67
  totalPages: number;
68
68
  } | undefined;
@@ -116,8 +116,8 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
116
116
  withdrawnAt?: Date | null | undefined;
117
117
  }[];
118
118
  metadata?: {
119
- page: number;
120
119
  size: number;
120
+ page: number;
121
121
  totalElements: number;
122
122
  totalPages: number;
123
123
  } | undefined;
@@ -183,8 +183,8 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
183
183
  } | undefined;
184
184
  }[];
185
185
  metadata?: {
186
- page: number;
187
186
  size: number;
187
+ page: number;
188
188
  totalElements: number;
189
189
  totalPages: number;
190
190
  } | undefined;
@@ -241,8 +241,8 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
241
241
  withdrawnAt?: Date | null | undefined;
242
242
  }[][];
243
243
  metadata?: {
244
- page: number;
245
244
  size: number;
245
+ page: number;
246
246
  totalElements: number;
247
247
  totalPages: number;
248
248
  } | undefined;
@@ -297,8 +297,8 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
297
297
  withdrawnAt?: Date | null | undefined;
298
298
  }[];
299
299
  metadata?: {
300
- page: number;
301
300
  size: number;
301
+ page: number;
302
302
  totalElements: number;
303
303
  totalPages: number;
304
304
  } | undefined;
@@ -343,8 +343,8 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
343
343
  discountPercentage?: number | undefined;
344
344
  }[];
345
345
  metadata?: {
346
- page: number;
347
346
  size: number;
347
+ page: number;
348
348
  totalElements: number;
349
349
  totalPages: number;
350
350
  } | undefined;
@@ -404,8 +404,8 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
404
404
  } | undefined;
405
405
  }[];
406
406
  metadata?: {
407
- page: number;
408
407
  size: number;
408
+ page: number;
409
409
  totalElements: number;
410
410
  totalPages: number;
411
411
  } | 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":"AAqBA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAY9C,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyF5B,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":"AAqBA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAa9C,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6F5B,CAAC"}
@@ -11,6 +11,7 @@ const limited_time_offer_participant_validation_1 = require("./limited-time-offe
11
11
  const limited_time_offer_campaign_validation_1 = require("../campaign/limited-time-offer-campaign.validation");
12
12
  const typegoose_1 = require("@typegoose/typegoose");
13
13
  const error_common_1 = require("@lyxa.ai/core/dist/utilities/error-common");
14
+ const feature_flags_1 = require("../../../utility/feature-flags");
14
15
  const sellerProcedure = (0, auth_2.createAuthenticatedProcedure)({ entityTypes: [auth_1.AuthEntityType.SELLER] });
15
16
  const crmProcedure = (0, auth_2.createAuthenticatedProcedure)({ entityTypes: [auth_1.AuthEntityType.CRM] });
16
17
  function resolveShopId(ctx) {
@@ -50,6 +51,7 @@ exports.participantRouter = (0, trpc_1.createTRPCRouter)({
50
51
  .input(limited_time_offer_participant_validation_1.AdminEnrollShopsSchema)
51
52
  .output(limited_time_offer_participant_validation_1.AdminJoinParticipantsResponseSchema)
52
53
  .mutation(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
54
+ await (0, feature_flags_1.assertLtoScheduleEnabled)();
53
55
  const results = await limited_time_offer_participant_service_1.ltoParticipantService.enrollShops(input.shops);
54
56
  return (0, response_1.response)('Successfully joined the campaign', results);
55
57
  })),
@@ -57,6 +59,7 @@ exports.participantRouter = (0, trpc_1.createTRPCRouter)({
57
59
  .input(limited_time_offer_participant_validation_1.AdminUpdateShopSchema)
58
60
  .output(limited_time_offer_participant_validation_1.ParticipantResponseSchema)
59
61
  .mutation(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
62
+ await (0, feature_flags_1.assertLtoScheduleEnabled)();
60
63
  const { shopId, ...dto } = input;
61
64
  const result = await limited_time_offer_participant_service_1.ltoParticipantService.update(shopId, dto);
62
65
  return (0, response_1.response)('Participation updated successfully', result);
@@ -65,6 +68,7 @@ exports.participantRouter = (0, trpc_1.createTRPCRouter)({
65
68
  .input(limited_time_offer_participant_validation_1.AdminWithdrawShopSchema)
66
69
  .output(limited_time_offer_campaign_validation_1.LtoEmptyResponseSchema)
67
70
  .mutation(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
71
+ await (0, feature_flags_1.assertLtoScheduleEnabled)();
68
72
  await limited_time_offer_participant_service_1.ltoParticipantService.withdraw(input.shopId);
69
73
  return (0, response_1.response)('Successfully withdrawn from the campaign');
70
74
  })),
@@ -79,6 +83,7 @@ exports.participantRouter = (0, trpc_1.createTRPCRouter)({
79
83
  .input(limited_time_offer_participant_validation_1.AdminGetParticipantByShopSchema)
80
84
  .output(limited_time_offer_participant_validation_1.ParticipantStatusResponseSchema)
81
85
  .query(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
86
+ await (0, feature_flags_1.assertLtoScheduleEnabled)();
82
87
  const result = await limited_time_offer_participant_service_1.ltoParticipantService.getStatus(input.shopId);
83
88
  return (0, response_1.response)('Status fetched successfully', result);
84
89
  })),
@@ -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,2GASqD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AAK,CAAC,2EAA+B,CAAC;SACtC,MAAM,CAAC,2EAA+B,CAAC;SACvC,KAAK,CAAC,KAAK,EAAE,EAAC,KAAK,EAAC,EAAE,EAAE,CACrB,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,MAAM,MAAM,GAAG,MAAM,8DAAO,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACrD,OAAO,IAAA,mBAAQ,EAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;IAC3D,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 AdminEnrollShopsSchema,\n AdminGetParticipantByShopSchema,\n AdminJoinParticipantsResponseSchema,\n AdminUpdateShopSchema,\n AdminWithdrawShopSchema,\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 enrollShops: crmProcedure\n .input(AdminEnrollShopsSchema)\n .output(AdminJoinParticipantsResponseSchema)\n .mutation(async ({input}) =>\n ErrorHandler.wrapAsync(async () => {\n const results = await service.enrollShops(input.shops);\n return response('Successfully joined the campaign', results as any);\n })\n ),\n\n updateShop: crmProcedure\n .input(AdminUpdateShopSchema)\n .output(ParticipantResponseSchema)\n .mutation(async ({input}) =>\n ErrorHandler.wrapAsync(async () => {\n const {shopId, ...dto} = input;\n const result = await service.update(shopId, dto);\n return response('Participation updated successfully', result as any);\n })\n ),\n\n withdrawShop: crmProcedure\n .input(AdminWithdrawShopSchema)\n .output(LtoEmptyResponseSchema)\n .mutation(async ({input}) =>\n ErrorHandler.wrapAsync(async () => {\n await service.withdraw(input.shopId);\n return response('Successfully withdrawn from the campaign');\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 getParticipantByShop: crmProcedure\n .input(AdminGetParticipantByShopSchema)\n .output(ParticipantStatusResponseSchema)\n .query(async ({input}) =>\n ErrorHandler.wrapAsync(async () => {\n const result = await service.getStatus(input.shopId);\n return response('Status 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,2GASqD;AACrD,+GAI4D;AAC5D,oDAA8C;AAC9C,4EAA0E;AAC1E,0DAAgE;AAEhE,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;IACpE,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAA,8BAAe,EAAC,sCAAsC,CAAC,CAAC;IAChG,OAAO,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC;AAEY,QAAA,iBAAiB,GAAG,IAAA,uBAAgB,EAAC;IAC9C,IAAI,EAAE,eAAe;SAChB,KAAK,CAAC,iEAAqB,CAAC;SA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,EAAE,EAAE,CACxB,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,MAAM,IAAA,wCAAwB,GAAE,CAAC;QACjC,MAAM,8DAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACrC,OAAO,IAAA,mBAAQ,EAAC,0CAA0C,CAAC,CAAC;IAChE,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;IAEL,oBAAoB,EAAE,YAAY;SAC7B,KAAK,CAAC,2EAA+B,CAAC;SACtC,MAAM,CAAC,2EAA+B,CAAC;SACvC,KAAK,CAAC,KAAK,EAAE,EAAC,KAAK,EAAC,EAAE,EAAE,CACrB,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,MAAM,IAAA,wCAAwB,GAAE,CAAC;QACjC,MAAM,MAAM,GAAG,MAAM,8DAAO,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACrD,OAAO,IAAA,mBAAQ,EAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;IAC3D,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 AdminEnrollShopsSchema,\n AdminGetParticipantByShopSchema,\n AdminJoinParticipantsResponseSchema,\n AdminUpdateShopSchema,\n AdminWithdrawShopSchema,\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';\nimport {assertLtoScheduleEnabled} from '@utility/feature-flags';\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 enrollShops: crmProcedure\n .input(AdminEnrollShopsSchema)\n .output(AdminJoinParticipantsResponseSchema)\n .mutation(async ({input}) =>\n ErrorHandler.wrapAsync(async () => {\n await assertLtoScheduleEnabled();\n const results = await service.enrollShops(input.shops);\n return response('Successfully joined the campaign', results as any);\n })\n ),\n\n updateShop: crmProcedure\n .input(AdminUpdateShopSchema)\n .output(ParticipantResponseSchema)\n .mutation(async ({input}) =>\n ErrorHandler.wrapAsync(async () => {\n await assertLtoScheduleEnabled();\n const {shopId, ...dto} = input;\n const result = await service.update(shopId, dto);\n return response('Participation updated successfully', result as any);\n })\n ),\n\n withdrawShop: crmProcedure\n .input(AdminWithdrawShopSchema)\n .output(LtoEmptyResponseSchema)\n .mutation(async ({input}) =>\n ErrorHandler.wrapAsync(async () => {\n await assertLtoScheduleEnabled();\n await service.withdraw(input.shopId);\n return response('Successfully withdrawn from the campaign');\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 getParticipantByShop: crmProcedure\n .input(AdminGetParticipantByShopSchema)\n .output(ParticipantStatusResponseSchema)\n .query(async ({input}) =>\n ErrorHandler.wrapAsync(async () => {\n await assertLtoScheduleEnabled();\n const result = await service.getStatus(input.shopId);\n return response('Status fetched successfully', result);\n })\n ),\n});\n"]}