@lyxa.ai/marketing 1.0.62 → 1.0.64

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 (372) hide show
  1. package/dist/lib/event/event-initializations.d.ts.map +1 -1
  2. package/dist/lib/event/event-initializations.js +2 -0
  3. package/dist/lib/event/event-initializations.js.map +1 -1
  4. package/dist/lib/event/event-listeners/event-listeners.d.ts +2 -0
  5. package/dist/lib/event/event-listeners/event-listeners.d.ts.map +1 -1
  6. package/dist/lib/event/event-listeners/event-listeners.js +69 -12
  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 +1 -2
  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/event/events/marketing-product-sync.event.d.ts +11 -0
  12. package/dist/lib/event/events/marketing-product-sync.event.d.ts.map +1 -0
  13. package/dist/lib/event/events/marketing-product-sync.event.js +12 -0
  14. package/dist/lib/event/events/marketing-product-sync.event.js.map +1 -0
  15. package/dist/lib/index.d.ts +536 -19
  16. package/dist/lib/index.d.ts.map +1 -1
  17. package/dist/lib/index.js +5 -1
  18. package/dist/lib/index.js.map +1 -1
  19. package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
  20. package/dist/lib/modules/coupon/services/custom-coupon.service.d.ts +15 -3
  21. package/dist/lib/modules/coupon/services/custom-coupon.service.d.ts.map +1 -1
  22. package/dist/lib/modules/coupon/services/helper.service.d.ts +15 -3
  23. package/dist/lib/modules/coupon/services/helper.service.d.ts.map +1 -1
  24. package/dist/lib/modules/coupon/services/individual-store-coupon.service.d.ts +15 -3
  25. package/dist/lib/modules/coupon/services/individual-store-coupon.service.d.ts.map +1 -1
  26. package/dist/lib/modules/coupon/services/shops-categories-coupon.service.d.ts +15 -3
  27. package/dist/lib/modules/coupon/services/shops-categories-coupon.service.d.ts.map +1 -1
  28. package/dist/lib/modules/coupon/validations/create-coupon.validation.d.ts.map +1 -1
  29. package/dist/lib/modules/coupon/validations/create-coupon.validation.js +4 -1
  30. package/dist/lib/modules/coupon/validations/create-coupon.validation.js.map +1 -1
  31. package/dist/lib/modules/deal-setting/services/deal-setting.service.d.ts.map +1 -1
  32. package/dist/lib/modules/deal-setting/services/deal-setting.service.js +4 -1
  33. package/dist/lib/modules/deal-setting/services/deal-setting.service.js.map +1 -1
  34. package/dist/lib/modules/featured-setting/services/featured-setting.service.d.ts.map +1 -1
  35. package/dist/lib/modules/featured-setting/services/featured-setting.service.js +3 -0
  36. package/dist/lib/modules/featured-setting/services/featured-setting.service.js.map +1 -1
  37. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts +54 -8
  38. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
  39. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js +11 -0
  40. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js.map +1 -1
  41. package/dist/lib/modules/limited-time-offer/campaign/jobs/index.d.ts.map +1 -1
  42. package/dist/lib/modules/limited-time-offer/campaign/jobs/index.js +6 -0
  43. package/dist/lib/modules/limited-time-offer/campaign/jobs/index.js.map +1 -1
  44. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts +0 -1
  45. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts.map +1 -1
  46. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.js +2 -6
  47. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.js.map +1 -1
  48. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts +16 -3
  49. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts.map +1 -1
  50. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.js +22 -3
  51. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.js.map +1 -1
  52. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.d.ts +2 -0
  53. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.d.ts.map +1 -1
  54. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.js +12 -0
  55. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.js.map +1 -1
  56. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +242 -35
  57. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts.map +1 -1
  58. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js +19 -1
  59. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js.map +1 -1
  60. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts +10 -1
  61. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts.map +1 -1
  62. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.js +78 -1
  63. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.js.map +1 -1
  64. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.d.ts +3 -0
  65. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.d.ts.map +1 -1
  66. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.js +66 -8
  67. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.js.map +1 -1
  68. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts +1 -1
  69. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
  70. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js +41 -19
  71. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js.map +1 -1
  72. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts +249 -18
  73. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
  74. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts +2 -0
  75. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -1
  76. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js +10 -4
  77. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js.map +1 -1
  78. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts +1 -1
  79. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.js +1 -1
  80. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.js.map +1 -1
  81. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts +30 -3
  82. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts.map +1 -1
  83. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.js +23 -1
  84. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.js.map +1 -1
  85. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +18 -0
  86. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
  87. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js +103 -0
  88. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js.map +1 -1
  89. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +195 -10
  90. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
  91. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.js +29 -0
  92. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.js.map +1 -1
  93. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +547 -148
  94. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
  95. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js +16 -6
  96. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js.map +1 -1
  97. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts +11 -4
  98. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts.map +1 -1
  99. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.js +48 -7
  100. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.js.map +1 -1
  101. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +18 -5
  102. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  103. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js +98 -17
  104. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js.map +1 -1
  105. package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.d.ts +13 -0
  106. package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.d.ts.map +1 -0
  107. package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.js +75 -0
  108. package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.js.map +1 -0
  109. package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.d.ts +21 -0
  110. package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.d.ts.map +1 -0
  111. package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.js +83 -0
  112. package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.js.map +1 -0
  113. package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts +2 -0
  114. package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts.map +1 -1
  115. package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.js +41 -0
  116. package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.js.map +1 -1
  117. package/dist/lib/modules/marketing/routers/marketing.router.d.ts +16 -0
  118. package/dist/lib/modules/marketing/routers/marketing.router.d.ts.map +1 -1
  119. package/dist/lib/modules/marketing/routers/marketing.router.js +5 -0
  120. package/dist/lib/modules/marketing/routers/marketing.router.js.map +1 -1
  121. package/dist/lib/modules/marketing/services/index.d.ts +3 -0
  122. package/dist/lib/modules/marketing/services/index.d.ts.map +1 -1
  123. package/dist/lib/modules/marketing/services/index.js +3 -0
  124. package/dist/lib/modules/marketing/services/index.js.map +1 -1
  125. package/dist/lib/modules/marketing/services/marketing-conflict.repository.d.ts +9 -0
  126. package/dist/lib/modules/marketing/services/marketing-conflict.repository.d.ts.map +1 -0
  127. package/dist/lib/modules/marketing/services/marketing-conflict.repository.js +63 -0
  128. package/dist/lib/modules/marketing/services/marketing-conflict.repository.js.map +1 -0
  129. package/dist/lib/modules/marketing/services/marketing-conflict.service.d.ts +28 -0
  130. package/dist/lib/modules/marketing/services/marketing-conflict.service.d.ts.map +1 -0
  131. package/dist/lib/modules/marketing/services/marketing-conflict.service.js +139 -0
  132. package/dist/lib/modules/marketing/services/marketing-conflict.service.js.map +1 -0
  133. package/dist/lib/modules/marketing/services/marketing.service.d.ts +7 -2
  134. package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
  135. package/dist/lib/modules/marketing/services/marketing.service.js +107 -48
  136. package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -1
  137. package/dist/lib/modules/marketing/services/product-marketing.service.d.ts +2 -3
  138. package/dist/lib/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
  139. package/dist/lib/modules/marketing/services/product-marketing.service.js +42 -13
  140. package/dist/lib/modules/marketing/services/product-marketing.service.js.map +1 -1
  141. package/dist/lib/modules/marketing/services/spend-to-get-marketing.repository.d.ts +14 -0
  142. package/dist/lib/modules/marketing/services/spend-to-get-marketing.repository.d.ts.map +1 -0
  143. package/dist/lib/modules/marketing/services/spend-to-get-marketing.repository.js +82 -0
  144. package/dist/lib/modules/marketing/services/spend-to-get-marketing.repository.js.map +1 -0
  145. package/dist/lib/modules/marketing/services/spend-to-get-marketing.service.d.ts +11 -0
  146. package/dist/lib/modules/marketing/services/spend-to-get-marketing.service.d.ts.map +1 -0
  147. package/dist/lib/modules/marketing/services/spend-to-get-marketing.service.js +100 -0
  148. package/dist/lib/modules/marketing/services/spend-to-get-marketing.service.js.map +1 -0
  149. package/dist/lib/modules/marketing/services/spend-to-get-progress.repository.d.ts +9 -0
  150. package/dist/lib/modules/marketing/services/spend-to-get-progress.repository.d.ts.map +1 -0
  151. package/dist/lib/modules/marketing/services/spend-to-get-progress.repository.js +69 -0
  152. package/dist/lib/modules/marketing/services/spend-to-get-progress.repository.js.map +1 -0
  153. package/dist/lib/modules/marketing/services/spend-to-get-progress.service.d.ts +31 -0
  154. package/dist/lib/modules/marketing/services/spend-to-get-progress.service.d.ts.map +1 -0
  155. package/dist/lib/modules/marketing/services/spend-to-get-progress.service.js +123 -0
  156. package/dist/lib/modules/marketing/services/spend-to-get-progress.service.js.map +1 -0
  157. package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.d.ts.map +1 -1
  158. package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.js +95 -27
  159. package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.js.map +1 -1
  160. package/dist/lib/modules/marketing/validations/all-marketings.validation.d.ts.map +1 -1
  161. package/dist/lib/modules/marketing/validations/all-marketings.validation.js +3 -0
  162. package/dist/lib/modules/marketing/validations/all-marketings.validation.js.map +1 -1
  163. package/dist/lib/modules/marketing/validations/buy1-get1-marketing.validation.d.ts +3 -3
  164. package/dist/lib/modules/marketing/validations/discount-marketing.validation.d.ts +3 -3
  165. package/dist/lib/modules/marketing/validations/index.d.ts +1 -0
  166. package/dist/lib/modules/marketing/validations/index.d.ts.map +1 -1
  167. package/dist/lib/modules/marketing/validations/index.js +1 -0
  168. package/dist/lib/modules/marketing/validations/index.js.map +1 -1
  169. package/dist/lib/modules/marketing/validations/marketing.validation.d.ts +23 -0
  170. package/dist/lib/modules/marketing/validations/marketing.validation.d.ts.map +1 -1
  171. package/dist/lib/modules/marketing/validations/marketing.validation.js +9 -1
  172. package/dist/lib/modules/marketing/validations/marketing.validation.js.map +1 -1
  173. package/dist/lib/modules/marketing/validations/product-marketing.validation.d.ts +2 -2
  174. package/dist/lib/modules/marketing/validations/spend-to-get-marketing.validation.d.ts +617 -0
  175. package/dist/lib/modules/marketing/validations/spend-to-get-marketing.validation.d.ts.map +1 -0
  176. package/dist/lib/modules/marketing/validations/spend-to-get-marketing.validation.js +119 -0
  177. package/dist/lib/modules/marketing/validations/spend-to-get-marketing.validation.js.map +1 -0
  178. package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +1 -1
  179. package/dist/lib/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +2 -2
  180. package/dist/lib/modules/spend-to-get-history/routers/index.d.ts +2 -0
  181. package/dist/lib/modules/spend-to-get-history/routers/index.d.ts.map +1 -0
  182. package/dist/lib/modules/spend-to-get-history/routers/index.js +18 -0
  183. package/dist/lib/modules/spend-to-get-history/routers/index.js.map +1 -0
  184. package/dist/lib/modules/spend-to-get-history/routers/spend-to-get-history.router.js +62 -0
  185. package/dist/lib/modules/spend-to-get-history/routers/spend-to-get-history.router.js.map +1 -0
  186. package/dist/lib/modules/spend-to-get-history/services/index.d.ts +2 -0
  187. package/dist/lib/modules/spend-to-get-history/services/index.d.ts.map +1 -0
  188. package/dist/lib/modules/spend-to-get-history/services/index.js +18 -0
  189. package/dist/lib/modules/spend-to-get-history/services/index.js.map +1 -0
  190. package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts +24 -0
  191. package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts.map +1 -0
  192. package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.js +136 -0
  193. package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.js.map +1 -0
  194. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.d.ts +24 -0
  195. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.d.ts.map +1 -0
  196. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.js +108 -0
  197. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.js.map +1 -0
  198. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.d.ts +271 -0
  199. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.d.ts.map +1 -0
  200. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.js +62 -0
  201. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.js.map +1 -0
  202. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.d.ts +24 -0
  203. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.d.ts.map +1 -0
  204. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.js +116 -0
  205. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.js.map +1 -0
  206. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.d.ts +232 -0
  207. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.d.ts.map +1 -0
  208. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.js +30 -0
  209. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.js.map +1 -0
  210. package/dist/lib/modules/spend-to-get-history/validations/index.d.ts +2 -0
  211. package/dist/lib/modules/spend-to-get-history/validations/index.d.ts.map +1 -0
  212. package/dist/lib/modules/spend-to-get-history/validations/index.js +18 -0
  213. package/dist/lib/modules/spend-to-get-history/validations/index.js.map +1 -0
  214. package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.d.ts +232 -0
  215. package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.d.ts.map +1 -0
  216. package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.js +30 -0
  217. package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.js.map +1 -0
  218. package/dist/lib/modules/tournament/match/events/match-ended.consumer.d.ts +2 -0
  219. package/dist/lib/modules/tournament/match/events/match-ended.consumer.d.ts.map +1 -0
  220. package/dist/lib/modules/tournament/match/events/match-ended.consumer.js +15 -0
  221. package/dist/lib/modules/tournament/match/events/match-ended.consumer.js.map +1 -0
  222. package/dist/lib/modules/tournament/match/events/match-ended.event.d.ts +14 -0
  223. package/dist/lib/modules/tournament/match/events/match-ended.event.d.ts.map +1 -0
  224. package/dist/lib/modules/tournament/match/events/match-ended.event.js +12 -0
  225. package/dist/lib/modules/tournament/match/events/match-ended.event.js.map +1 -0
  226. package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts +10 -0
  227. package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts.map +1 -0
  228. package/dist/lib/modules/tournament/notification/jobs/notification.producer.js +23 -0
  229. package/dist/lib/modules/tournament/notification/jobs/notification.producer.js.map +1 -0
  230. package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts +9 -0
  231. package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts.map +1 -0
  232. package/dist/lib/modules/tournament/notification/jobs/notification.worker.js +82 -0
  233. package/dist/lib/modules/tournament/notification/jobs/notification.worker.js.map +1 -0
  234. package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts +10 -0
  235. package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts.map +1 -0
  236. package/dist/lib/modules/tournament/notification/notification.schedule.config.js +15 -0
  237. package/dist/lib/modules/tournament/notification/notification.schedule.config.js.map +1 -0
  238. package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts +10 -0
  239. package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts.map +1 -0
  240. package/dist/lib/modules/tournament/notification/notification.scheduler.service.js +73 -0
  241. package/dist/lib/modules/tournament/notification/notification.scheduler.service.js.map +1 -0
  242. package/dist/types/event/event-initializations.d.ts.map +1 -1
  243. package/dist/types/event/event-listeners/event-listeners.d.ts +2 -0
  244. package/dist/types/event/event-listeners/event-listeners.d.ts.map +1 -1
  245. package/dist/types/event/events/marketing-product-seed.event.d.ts +1 -2
  246. package/dist/types/event/events/marketing-product-seed.event.d.ts.map +1 -1
  247. package/dist/types/event/events/marketing-product-sync.event.d.ts +11 -0
  248. package/dist/types/event/events/marketing-product-sync.event.d.ts.map +1 -0
  249. package/dist/types/events/event-initializations.d.ts +2 -0
  250. package/dist/types/events/event-initializations.d.ts.map +1 -0
  251. package/dist/types/index.d.ts +536 -19
  252. package/dist/types/index.d.ts.map +1 -1
  253. package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
  254. package/dist/types/modules/coupon/services/custom-coupon.service.d.ts +15 -3
  255. package/dist/types/modules/coupon/services/custom-coupon.service.d.ts.map +1 -1
  256. package/dist/types/modules/coupon/services/helper.service.d.ts +15 -3
  257. package/dist/types/modules/coupon/services/helper.service.d.ts.map +1 -1
  258. package/dist/types/modules/coupon/services/individual-store-coupon.service.d.ts +15 -3
  259. package/dist/types/modules/coupon/services/individual-store-coupon.service.d.ts.map +1 -1
  260. package/dist/types/modules/coupon/services/shops-categories-coupon.service.d.ts +15 -3
  261. package/dist/types/modules/coupon/services/shops-categories-coupon.service.d.ts.map +1 -1
  262. package/dist/types/modules/coupon/validations/create-coupon.validation.d.ts.map +1 -1
  263. package/dist/types/modules/deal-setting/services/deal-setting.service.d.ts.map +1 -1
  264. package/dist/types/modules/featured-setting/services/featured-setting.service.d.ts.map +1 -1
  265. package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts +54 -8
  266. package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
  267. package/dist/types/modules/limited-time-offer/campaign/jobs/index.d.ts.map +1 -1
  268. package/dist/types/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts +0 -1
  269. package/dist/types/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts.map +1 -1
  270. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts +16 -3
  271. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts.map +1 -1
  272. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.d.ts +2 -0
  273. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.d.ts.map +1 -1
  274. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +242 -35
  275. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts.map +1 -1
  276. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts +10 -1
  277. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts.map +1 -1
  278. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.d.ts +3 -0
  279. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.d.ts.map +1 -1
  280. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts +1 -1
  281. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
  282. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts +249 -18
  283. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
  284. package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts +2 -0
  285. package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -1
  286. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts +1 -1
  287. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts +30 -3
  288. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts.map +1 -1
  289. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +18 -0
  290. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
  291. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +195 -10
  292. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
  293. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts +1 -0
  294. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts.map +1 -0
  295. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +547 -148
  296. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
  297. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts +11 -4
  298. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts.map +1 -1
  299. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +18 -5
  300. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  301. package/dist/types/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.d.ts +13 -0
  302. package/dist/types/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.d.ts.map +1 -0
  303. package/dist/types/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.d.ts +21 -0
  304. package/dist/types/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.d.ts.map +1 -0
  305. package/dist/types/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts +2 -0
  306. package/dist/types/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts.map +1 -1
  307. package/dist/types/modules/marketing/routers/marketing.router.d.ts +16 -0
  308. package/dist/types/modules/marketing/routers/marketing.router.d.ts.map +1 -1
  309. package/dist/types/modules/marketing/services/index.d.ts +3 -0
  310. package/dist/types/modules/marketing/services/index.d.ts.map +1 -1
  311. package/dist/types/modules/marketing/services/marketing-conflict.repository.d.ts +9 -0
  312. package/dist/types/modules/marketing/services/marketing-conflict.repository.d.ts.map +1 -0
  313. package/dist/types/modules/marketing/services/marketing-conflict.service.d.ts +46 -0
  314. package/dist/types/modules/marketing/services/marketing-conflict.service.d.ts.map +1 -0
  315. package/dist/types/modules/marketing/services/marketing.service.d.ts +7 -2
  316. package/dist/types/modules/marketing/services/marketing.service.d.ts.map +1 -1
  317. package/dist/types/modules/marketing/services/product-marketing.service.d.ts +7 -3
  318. package/dist/types/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
  319. package/dist/types/modules/marketing/services/spend-to-get-marketing.repository.d.ts +14 -0
  320. package/dist/types/modules/marketing/services/spend-to-get-marketing.repository.d.ts.map +1 -0
  321. package/dist/types/modules/marketing/services/spend-to-get-marketing.service.d.ts +20 -0
  322. package/dist/types/modules/marketing/services/spend-to-get-marketing.service.d.ts.map +1 -0
  323. package/dist/types/modules/marketing/services/spend-to-get-progress.repository.d.ts +9 -0
  324. package/dist/types/modules/marketing/services/spend-to-get-progress.repository.d.ts.map +1 -0
  325. package/dist/types/modules/marketing/services/spend-to-get-progress.service.d.ts +37 -0
  326. package/dist/types/modules/marketing/services/spend-to-get-progress.service.d.ts.map +1 -0
  327. package/dist/types/modules/marketing/services/synchronize-product-marketing.service.d.ts.map +1 -1
  328. package/dist/types/modules/marketing/validations/all-marketings.validation.d.ts.map +1 -1
  329. package/dist/types/modules/marketing/validations/buy1-get1-marketing.validation.d.ts +3 -3
  330. package/dist/types/modules/marketing/validations/discount-marketing.validation.d.ts +3 -3
  331. package/dist/types/modules/marketing/validations/index.d.ts +1 -0
  332. package/dist/types/modules/marketing/validations/index.d.ts.map +1 -1
  333. package/dist/types/modules/marketing/validations/marketing.validation.d.ts +23 -0
  334. package/dist/types/modules/marketing/validations/marketing.validation.d.ts.map +1 -1
  335. package/dist/types/modules/marketing/validations/product-marketing.validation.d.ts +2 -2
  336. package/dist/types/modules/marketing/validations/spend-to-get-marketing.validation.d.ts +630 -0
  337. package/dist/types/modules/marketing/validations/spend-to-get-marketing.validation.d.ts.map +1 -0
  338. package/dist/types/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +1 -1
  339. package/dist/types/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +2 -2
  340. package/dist/types/modules/spend-to-get-history/routers/index.d.ts +2 -0
  341. package/dist/types/modules/spend-to-get-history/routers/index.d.ts.map +1 -0
  342. package/dist/types/modules/spend-to-get-history/services/index.d.ts +2 -0
  343. package/dist/types/modules/spend-to-get-history/services/index.d.ts.map +1 -0
  344. package/dist/types/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts +56 -0
  345. package/dist/types/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts.map +1 -0
  346. package/dist/types/modules/spend-to-get-history/spend-to-get-history.repository.d.ts +24 -0
  347. package/dist/types/modules/spend-to-get-history/spend-to-get-history.repository.d.ts.map +1 -0
  348. package/dist/types/modules/spend-to-get-history/spend-to-get-history.router.d.ts +271 -0
  349. package/dist/types/modules/spend-to-get-history/spend-to-get-history.router.d.ts.map +1 -0
  350. package/dist/types/modules/spend-to-get-history/spend-to-get-history.service.d.ts +56 -0
  351. package/dist/types/modules/spend-to-get-history/spend-to-get-history.service.d.ts.map +1 -0
  352. package/dist/types/modules/spend-to-get-history/spend-to-get-history.validation.d.ts +241 -0
  353. package/dist/types/modules/spend-to-get-history/spend-to-get-history.validation.d.ts.map +1 -0
  354. package/dist/types/modules/spend-to-get-history/validations/index.d.ts +2 -0
  355. package/dist/types/modules/spend-to-get-history/validations/index.d.ts.map +1 -0
  356. package/dist/types/modules/spend-to-get-history/validations/spend-to-get-history.validation.d.ts +241 -0
  357. package/dist/types/modules/spend-to-get-history/validations/spend-to-get-history.validation.d.ts.map +1 -0
  358. package/dist/types/modules/tournament/config/tournament-config.validation.d.ts +201 -0
  359. package/dist/types/modules/tournament/config/tournament-config.validation.d.ts.map +1 -0
  360. package/dist/types/modules/tournament/match/events/match-ended.consumer.d.ts +2 -0
  361. package/dist/types/modules/tournament/match/events/match-ended.consumer.d.ts.map +1 -0
  362. package/dist/types/modules/tournament/match/events/match-ended.event.d.ts +14 -0
  363. package/dist/types/modules/tournament/match/events/match-ended.event.d.ts.map +1 -0
  364. package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts +10 -0
  365. package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts.map +1 -0
  366. package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts +9 -0
  367. package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts.map +1 -0
  368. package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts +10 -0
  369. package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts.map +1 -0
  370. package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts +10 -0
  371. package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts.map +1 -0
  372. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer-participant.validation.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AACtB,OAAO,EAAuB,GAAG,EAAgB,MAAM,yCAAyC,CAAC;AAEjG,oBAAY,YAAY;IACpB,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,IAAI,SAAS;IACb,MAAM,WAAW;CACpB;AAED,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgC5B,CAAC;AAEP,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAe5B,CAAC;AAEH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ACzE,MAAM,MAAM,oBAAoB,GAAG,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACvE,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAAC,qBAAqB,EAAE,aAAa,CAAC,CAAC;AAGvF,MAAM,MAAM,wBAAwB,GAAG,IAAI,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,GAAG;IAAC,SAAS,EAAE,qBAAqB,CAAC,aAAa,CAAC,CAAA;CAAC,CAAC"}
1
+ {"version":3,"file":"limited-time-offer-participant.validation.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AACtB,OAAO,EAAC,KAAK,EAAC,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAuB,GAAG,EAAgB,MAAM,yCAAyC,CAAC;AAEjG,oBAAY,YAAY;IACpB,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,IAAI,SAAS;IACb,MAAM,WAAW;CACpB;AAsCD,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAkD,CAAC;AAErF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAe5B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;EAQhC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;EASnC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIlC,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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EAA+C,CAAC;AAE5F,MAAM,MAAM,oBAAoB,GAAG,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACvE,MAAM,MAAM,uBAAuB,GAAG,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAC7E,MAAM,MAAM,mBAAmB,GAAG,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACrE,MAAM,MAAM,kBAAkB,GAAG,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACnE,MAAM,MAAM,cAAc,GAAG,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC3D,MAAM,MAAM,kBAAkB,GAAG,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACnE,MAAM,MAAM,qBAAqB,GAAG,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC;AACzE,MAAM,MAAM,oBAAoB,GAAG,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACvE,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAAC,qBAAqB,EAAE,aAAa,CAAC,CAAC;AAGvF,MAAM,MAAM,wBAAwB,GAAG,IAAI,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,GAAG;IAChF,SAAS,EAAE,qBAAqB,CAAC,aAAa,CAAC,CAAC;IAChD,gBAAgB,CAAC,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;IACpC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACxC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParticipantStatusResponseSchema = exports.ParticipantResponseSchema = exports.ParticipantStatusSchema = exports.ParticipantSummarySchema = exports.CampaignSummarySchema = exports.ParticipantSchema = exports.JoinLtoCampaignSchema = exports.LtoCardState = void 0;
3
+ exports.AdminGetParticipantByShopSchema = exports.AdminWithdrawShopSchema = exports.AdminUpdateShopSchema = exports.AdminJoinParticipantsResponseSchema = exports.AdminEnrollShopsSchema = exports.AdminEnrollShopEntrySchema = exports.ParticipantStatusResponseSchema = exports.ParticipantResponseSchema = exports.ParticipantStatusSchema = exports.ParticipantSummarySchema = exports.CampaignSummarySchema = exports.ParticipantSchema = exports.JoinLtoCampaignSchema = exports.LtoCardState = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const validation_1 = require("@lyxa.ai/core/dist/utilities/validation");
6
6
  var LtoCardState;
@@ -10,8 +10,7 @@ var LtoCardState;
10
10
  LtoCardState["LIVE"] = "LIVE";
11
11
  LtoCardState["JOINED"] = "JOINED";
12
12
  })(LtoCardState || (exports.LtoCardState = LtoCardState = {}));
13
- exports.JoinLtoCampaignSchema = zod_1.z
14
- .object({
13
+ const joinLtoCampaignBase = zod_1.z.object({
15
14
  isEntireMenu: zod_1.z.boolean(),
16
15
  products: zod_1.z.array(validation_1.ZodValidation.objectId()).default([]),
17
16
  shopCategories: zod_1.z.array(validation_1.ZodValidation.objectId()).default([]),
@@ -19,8 +18,8 @@ exports.JoinLtoCampaignSchema = zod_1.z
19
18
  maxDiscountCap: validation_1.ZodValidation.number('Max discount cap'),
20
19
  isOrderCapacityEnabled: zod_1.z.boolean(),
21
20
  maxOrderCapacity: validation_1.ZodValidation.number('Max order capacity').optional(),
22
- })
23
- .superRefine((d, ctx) => {
21
+ });
22
+ const joinRefinement = (d, ctx) => {
24
23
  if (!d.isEntireMenu && d.products.length === 0 && d.shopCategories.length === 0) {
25
24
  ctx.addIssue({
26
25
  code: zod_1.z.ZodIssueCode.custom,
@@ -42,7 +41,8 @@ exports.JoinLtoCampaignSchema = zod_1.z
42
41
  path: ['maxOrderCapacity']
43
42
  });
44
43
  }
45
- });
44
+ };
45
+ exports.JoinLtoCampaignSchema = joinLtoCampaignBase.superRefine(joinRefinement);
46
46
  exports.ParticipantSchema = zod_1.z.object({
47
47
  _id: validation_1.ZodValidation.objectId(),
48
48
  campaign: validation_1.ZodValidation.objectId(),
@@ -85,4 +85,14 @@ exports.ParticipantStatusSchema = zod_1.z.object({
85
85
  });
86
86
  exports.ParticipantResponseSchema = (0, validation_1.createResponseSchema)(exports.ParticipantSchema);
87
87
  exports.ParticipantStatusResponseSchema = (0, validation_1.createResponseSchema)(exports.ParticipantStatusSchema);
88
+ exports.AdminEnrollShopEntrySchema = joinLtoCampaignBase
89
+ .extend({ shopId: validation_1.ZodValidation.objectId() })
90
+ .superRefine(joinRefinement);
91
+ exports.AdminEnrollShopsSchema = zod_1.z.object({
92
+ shops: zod_1.z.array(exports.AdminEnrollShopEntrySchema).min(1),
93
+ });
94
+ exports.AdminJoinParticipantsResponseSchema = (0, validation_1.createResponseSchema)(zod_1.z.array(exports.ParticipantSchema));
95
+ exports.AdminUpdateShopSchema = exports.AdminEnrollShopEntrySchema;
96
+ exports.AdminWithdrawShopSchema = zod_1.z.object({ shopId: validation_1.ZodValidation.objectId() });
97
+ exports.AdminGetParticipantByShopSchema = zod_1.z.object({ shopId: validation_1.ZodValidation.objectId() });
88
98
  //# sourceMappingURL=limited-time-offer-participant.validation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer-participant.validation.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.validation.ts"],"names":[],"mappings":";;;AAAA,6BAAsB;AACtB,wEAAiG;AAEjG,IAAY,YAKX;AALD,WAAY,YAAY;IACpB,6BAAa,CAAA;IACb,uCAAuB,CAAA;IACvB,6BAAa,CAAA;IACb,iCAAiB,CAAA;AACrB,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB;AAEY,QAAA,qBAAqB,GAAG,OAAC;KACjC,MAAM,CAAC;IACJ,YAAY,EAAE,OAAC,CAAC,OAAO,EAAE;IACzB,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,0BAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IACvD,cAAc,EAAE,OAAC,CAAC,KAAK,CAAC,0BAAa,CAAC,QAAQ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AEU,QAAA,yBAAyB,GAAG,IAAA,iCAAoB,EAAC,yBAAiB,CAAC,CAAC;AACpE,QAAA,+BAA+B,GAAG,IAAA,iCAAoB,EAAC,+BAAuB,CAAC,CAAC","sourcesContent":["import {z} from 'zod';\nimport {createResponseSchema, DTO, ZodValidation} from '@lyxa.ai/core/dist/utilities/validation';\n\nexport enum LtoCardState {\n NONE = 'NONE',\n SCHEDULED = 'SCHEDULED',\n LIVE = 'LIVE',\n JOINED = 'JOINED',\n}\n\nexport const JoinLtoCampaignSchema = z\n .object({\n isEntireMenu: z.boolean(),\n products: z.array(ZodValidation.objectId()).default([]),\n shopCategories: z.array(ZodValidation.objectId()).default([]),\n discountPercentage: ZodValidation.number('Discount percentage'),\n maxDiscountCap: ZodValidation.number('Max discount cap'),\n isOrderCapacityEnabled: z.boolean(),\n maxOrderCapacity: ZodValidation.number('Max order capacity').optional(),\n })\n .superRefine((d, ctx) => {\n if (!d.isEntireMenu && d.products.length === 0 && d.shopCategories.length === 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'At least one product or category must be selected',\n path: ['products']\n });\n }\n if (d.isOrderCapacityEnabled && !d.maxOrderCapacity) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Max order capacity is required when capacity is enabled',\n path: ['maxOrderCapacity']\n });\n }\n if (d.isOrderCapacityEnabled && d.maxOrderCapacity !== undefined && d.maxOrderCapacity <= 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Max order capacity must be greater than 0',\n path: ['maxOrderCapacity']\n });\n }\n });\n\nexport const ParticipantSchema = z.object({\n _id: ZodValidation.objectId(),\n campaign: ZodValidation.objectId(),\n shop: ZodValidation.objectId(),\n joinedAt: z.date(),\n products: z.array(ZodValidation.objectId()).default([]),\n isEntireMenu: z.boolean(),\n discountPercentage: ZodValidation.number('Discount percentage').optional(),\n maxDiscountCap: ZodValidation.number('Max discount cap').optional(),\n isOrderCapacityEnabled: z.boolean(),\n maxOrderCapacity: ZodValidation.number('Max order capacity').optional(),\n isWithdrawn: z.boolean(),\n withdrawnAt: z.date().nullable().optional(),\n createdAt: z.date().nullable().optional(),\n updatedAt: z.date().nullable().optional(),\n});\n\nexport const CampaignSummarySchema = z.object({\n _id: ZodValidation.objectId(),\n title: ZodValidation.string('Title').optional(),\n subTitle: ZodValidation.string('Subtitle').optional(),\n startDate: z.date().nullable().optional(),\n endDate: z.date().nullable().optional(),\n discountOptions: z.array(ZodValidation.number('Discount option')).default([]),\n maxDiscountCaps: z.array(ZodValidation.number('Max discount cap')).default([]),\n});\n\nexport const ParticipantSummarySchema = z.object({\n discountPercentage: ZodValidation.number('Discount percentage').optional(),\n maxDiscountCap: ZodValidation.number('Max discount cap').optional(),\n joinedAt: z.date(),\n isEntireMenu: z.boolean(),\n isOrderCapacityEnabled: z.boolean(),\n maxOrderCapacity: ZodValidation.number('Max order capacity').optional(),\n productIds: z.array(ZodValidation.objectId()).default([]),\n marketingId: ZodValidation.objectId().optional(),\n});\n\nexport const ParticipantStatusSchema = z.object({\n campaignState: z.nativeEnum(LtoCardState),\n campaign: CampaignSummarySchema.optional(),\n participant: ParticipantSummarySchema.optional(),\n});\n\nexport const ParticipantResponseSchema = createResponseSchema(ParticipantSchema);\nexport const ParticipantStatusResponseSchema = createResponseSchema(ParticipantStatusSchema);\n\nexport type JoinLtoCampaignDTO = DTO<typeof JoinLtoCampaignSchema>;\nexport type ParticipantDTO = DTO<typeof ParticipantSchema>;\nexport type CampaignSummaryDTO = DTO<typeof CampaignSummarySchema>;\nexport type ParticipantSummaryDTO = DTO<typeof ParticipantSummarySchema>;\nexport type ParticipantStatusDTO = DTO<typeof ParticipantStatusSchema>;\nexport type ActiveParticipantMarketingDTO = Pick<ParticipantSummaryDTO, 'marketingId'>;\n// shopCategories are intentionally excluded: the participant record does not persist category\n// selections — they live on the linked marketing doc and are derived from there for display.\nexport type UpdateParticipantDataDTO = Omit<JoinLtoCampaignDTO, 'shopCategories'> & {marketing: ParticipantSummaryDTO['marketingId']};\n"]}
1
+ {"version":3,"file":"limited-time-offer-participant.validation.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.validation.ts"],"names":[],"mappings":";;;AAAA,6BAAsB;AAEtB,wEAAiG;AAEjG,IAAY,YAKX;AALD,WAAY,YAAY;IACpB,6BAAa,CAAA;IACb,uCAAuB,CAAA;IACvB,6BAAa,CAAA;IACb,iCAAiB,CAAA;AACrB,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB;AAED,MAAM,mBAAmB,GAAG,OAAC,CAAC,MAAM,CAAC;IACjC,YAAY,EAAE,OAAC,CAAC,OAAO,EAAE;IACzB,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,0BAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IACvD,cAAc,EAAE,OAAC,CAAC,KAAK,CAAC,0BAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAC7D,kBAAkB,EAAE,0BAAa,CAAC,MAAM,CAAC,qBAAqB,CAAC;IAC/D,cAAc,EAAE,0BAAa,CAAC,MAAM,CAAC,kBAAkB,CAAC;IACxD,sBAAsB,EAAE,OAAC,CAAC,OAAO,EAAE;IACnC,gBAAgB,EAAE,0BAAa,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,QAAQ,EAAE;CAC1E,CAAC,CAAC;AAIH,MAAM,cAAc,GAAG,CAAC,CAAsB,EAAE,GAAoB,EAAE,EAAE;IACpE,IAAI,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9E,GAAG,CAAC,QAAQ,CAAC;YACT,IAAI,EAAE,OAAC,CAAC,YAAY,CAAC,MAAM;YAC3B,OAAO,EAAE,mDAAmD;YAC5D,IAAI,EAAE,CAAC,UAAU,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CAAC;AACnD,QAAA,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC,EAAC,MAAM,EAAE,0BAAa,CAAC,QAAQ,EAAE,EAAC,CAAC,CAAC;AACvE,QAAA,+BAA+B,GAAG,OAAC,CAAC,MAAM,CAAC,EAAC,MAAM,EAAE,0BAAa,CAAC,QAAQ,EAAE,EAAC,CAAC,CAAC","sourcesContent":["import {z} from 'zod';\nimport {Types} from 'mongoose';\nimport {createResponseSchema, DTO, ZodValidation} from '@lyxa.ai/core/dist/utilities/validation';\n\nexport enum LtoCardState {\n NONE = 'NONE',\n SCHEDULED = 'SCHEDULED',\n LIVE = 'LIVE',\n JOINED = 'JOINED',\n}\n\nconst joinLtoCampaignBase = z.object({\n isEntireMenu: z.boolean(),\n products: z.array(ZodValidation.objectId()).default([]),\n shopCategories: z.array(ZodValidation.objectId()).default([]),\n discountPercentage: ZodValidation.number('Discount percentage'),\n maxDiscountCap: ZodValidation.number('Max discount cap'),\n isOrderCapacityEnabled: z.boolean(),\n maxOrderCapacity: ZodValidation.number('Max order capacity').optional(),\n});\n\ntype JoinLtoCampaignBase = z.infer<typeof joinLtoCampaignBase>;\n\nconst joinRefinement = (d: JoinLtoCampaignBase, ctx: z.RefinementCtx) => {\n if (!d.isEntireMenu && d.products.length === 0 && d.shopCategories.length === 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'At least one product or category must be selected',\n path: ['products']\n });\n }\n if (d.isOrderCapacityEnabled && !d.maxOrderCapacity) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Max order capacity is required when capacity is enabled',\n path: ['maxOrderCapacity']\n });\n }\n if (d.isOrderCapacityEnabled && d.maxOrderCapacity !== undefined && d.maxOrderCapacity <= 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Max order capacity must be greater than 0',\n path: ['maxOrderCapacity']\n });\n }\n};\n\nexport const JoinLtoCampaignSchema = joinLtoCampaignBase.superRefine(joinRefinement);\n\nexport const ParticipantSchema = z.object({\n _id: ZodValidation.objectId(),\n campaign: ZodValidation.objectId(),\n shop: ZodValidation.objectId(),\n joinedAt: z.date(),\n products: z.array(ZodValidation.objectId()).default([]),\n isEntireMenu: z.boolean(),\n discountPercentage: ZodValidation.number('Discount percentage').optional(),\n maxDiscountCap: ZodValidation.number('Max discount cap').optional(),\n isOrderCapacityEnabled: z.boolean(),\n maxOrderCapacity: ZodValidation.number('Max order capacity').optional(),\n isWithdrawn: z.boolean(),\n withdrawnAt: z.date().nullable().optional(),\n createdAt: z.date().nullable().optional(),\n updatedAt: z.date().nullable().optional(),\n});\n\nexport const CampaignSummarySchema = z.object({\n _id: ZodValidation.objectId(),\n title: ZodValidation.string('Title').optional(),\n subTitle: ZodValidation.string('Subtitle').optional(),\n startDate: z.date().nullable().optional(),\n endDate: z.date().nullable().optional(),\n discountOptions: z.array(ZodValidation.number('Discount option')).default([]),\n maxDiscountCaps: z.array(ZodValidation.number('Max discount cap')).default([]),\n});\n\nexport const ParticipantSummarySchema = z.object({\n discountPercentage: ZodValidation.number('Discount percentage').optional(),\n maxDiscountCap: ZodValidation.number('Max discount cap').optional(),\n joinedAt: z.date(),\n isEntireMenu: z.boolean(),\n isOrderCapacityEnabled: z.boolean(),\n maxOrderCapacity: ZodValidation.number('Max order capacity').optional(),\n productIds: z.array(ZodValidation.objectId()).default([]),\n marketingId: ZodValidation.objectId().optional(),\n});\n\nexport const ParticipantStatusSchema = z.object({\n campaignState: z.nativeEnum(LtoCardState),\n campaign: CampaignSummarySchema.optional(),\n participant: ParticipantSummarySchema.optional(),\n});\n\nexport const ParticipantResponseSchema = createResponseSchema(ParticipantSchema);\nexport const ParticipantStatusResponseSchema = createResponseSchema(ParticipantStatusSchema);\n\nexport const AdminEnrollShopEntrySchema = joinLtoCampaignBase\n .extend({ shopId: ZodValidation.objectId() })\n .superRefine(joinRefinement);\n\nexport const AdminEnrollShopsSchema = z.object({\n shops: z.array(AdminEnrollShopEntrySchema).min(1),\n});\n\nexport const AdminJoinParticipantsResponseSchema = createResponseSchema(z.array(ParticipantSchema));\n\n// Admin edit reuses the enroll entry shape (shopId + join fields); withdraw and get-by-shop only need the shop.\nexport const AdminUpdateShopSchema = AdminEnrollShopEntrySchema;\nexport const AdminWithdrawShopSchema = z.object({shopId: ZodValidation.objectId()});\nexport const AdminGetParticipantByShopSchema = z.object({shopId: ZodValidation.objectId()});\n\nexport type AdminWithdrawShopDTO = DTO<typeof AdminWithdrawShopSchema>;\nexport type AdminEnrollShopEntryDTO = DTO<typeof AdminEnrollShopEntrySchema>;\nexport type AdminEnrollShopsDTO = DTO<typeof AdminEnrollShopsSchema>;\nexport type JoinLtoCampaignDTO = DTO<typeof JoinLtoCampaignSchema>;\nexport type ParticipantDTO = DTO<typeof ParticipantSchema>;\nexport type CampaignSummaryDTO = DTO<typeof CampaignSummarySchema>;\nexport type ParticipantSummaryDTO = DTO<typeof ParticipantSummarySchema>;\nexport type ParticipantStatusDTO = DTO<typeof ParticipantStatusSchema>;\nexport type ActiveParticipantMarketingDTO = Pick<ParticipantSummaryDTO, 'marketingId'>;\n// shopCategories are intentionally excluded: the participant record does not persist category\n// selections — they live on the linked marketing doc and are derived from there for display.\nexport type UpdateParticipantDataDTO = Omit<JoinLtoCampaignDTO, 'shopCategories'> & {\n marketing: ParticipantSummaryDTO['marketingId'];\n pausedMarketings?: Types.ObjectId[];\n pausedOrderCapacity?: number;\n pausedOrderCapacityEnabled?: boolean;\n};\n"]}
@@ -1,17 +1,24 @@
1
1
  import { mongoose } from '@typegoose/typegoose';
2
2
  import { LimitedTimeOfferCampaign } from '@lyxa.ai/core/dist/libraries/mongo/models';
3
+ import { MarketingType } from '@lyxa.ai/core/dist/utilities/enum';
3
4
  import { JoinLtoCampaignDTO } from '../limited-time-offer-participant.validation';
4
5
  export declare class LtoParticipantMarketingService {
5
6
  private repository;
6
7
  constructor();
7
- applyMarketing(shopId: mongoose.Types.ObjectId, campaign: LimitedTimeOfferCampaign & {
8
+ createMarketing(shopId: mongoose.Types.ObjectId, campaign: LimitedTimeOfferCampaign & {
8
9
  _id: mongoose.Types.ObjectId;
9
10
  }, dto: JoinLtoCampaignDTO): Promise<mongoose.Types.ObjectId>;
10
- removeMarketing(marketingId: mongoose.Types.ObjectId): Promise<void>;
11
- replaceMarketing(oldMarketingId: mongoose.Types.ObjectId, shopId: mongoose.Types.ObjectId, campaign: LimitedTimeOfferCampaign & {
11
+ pauseConflicts(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO): Promise<mongoose.Types.ObjectId[]>;
12
+ applyMarketing(shopId: mongoose.Types.ObjectId, campaign: LimitedTimeOfferCampaign & {
12
13
  _id: mongoose.Types.ObjectId;
13
- }, dto: JoinLtoCampaignDTO): Promise<mongoose.Types.ObjectId>;
14
+ }, dto: JoinLtoCampaignDTO): Promise<{
15
+ marketingId: mongoose.Types.ObjectId;
16
+ pausedMarketingIds: mongoose.Types.ObjectId[];
17
+ }>;
18
+ removeMarketing(marketingId: mongoose.Types.ObjectId): Promise<void>;
14
19
  removeAllCampaignMarketings(campaignId: mongoose.Types.ObjectId): Promise<void>;
20
+ pauseActiveShopMarketings(shopId: mongoose.Types.ObjectId, marketingType: MarketingType): Promise<mongoose.Types.ObjectId[]>;
21
+ resumeMarketings(marketingIds: mongoose.Types.ObjectId[]): Promise<void>;
15
22
  }
16
23
  export declare const ltoParticipantMarketingService: LtoParticipantMarketingService;
17
24
  //# sourceMappingURL=limited-time-offer-participant-marketing.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer-participant-marketing.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAC,wBAAwB,EAAC,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAC,kBAAkB,EAAC,MAAM,8CAA8C,CAAC;AAIhF,qBACa,8BAA8B;IACvC,OAAO,CAAC,UAAU,CAA2B;;IAMhC,cAAc,CACvB,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,QAAQ,EAAE,wBAAwB,GAAG;QAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAA;KAAC,EACnE,GAAG,EAAE,kBAAkB,GACxB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IAOtB,eAAe,CAAC,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpE,gBAAgB,CACzB,cAAc,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACvC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,QAAQ,EAAE,wBAAwB,GAAG;QAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAA;KAAC,EACnE,GAAG,EAAE,kBAAkB,GACxB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IAKtB,2BAA2B,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAI/F;AAED,eAAO,MAAM,8BAA8B,gCAAgD,CAAC"}
1
+ {"version":3,"file":"limited-time-offer-participant-marketing.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAG9C,OAAO,EAAC,wBAAwB,EAAC,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAkB,aAAa,EAAC,MAAM,mCAAmC,CAAC;AAGjF,OAAO,EAAC,kBAAkB,EAAC,MAAM,8CAA8C,CAAC;AAIhF,qBACa,8BAA8B;IACvC,OAAO,CAAC,UAAU,CAA2B;;IAShC,eAAe,CACxB,MAAM,EAAE,QAAQ,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|| function (k, v) {
44
44
  Object.defineProperty(exports, "__esModule", { value: true });
45
45
  exports.ltoParticipantMarketingService = exports.LtoParticipantMarketingService = void 0;
46
46
  const typedi_1 = __importStar(require("typedi"));
47
+ const server_1 = require("@trpc/server");
47
48
  const services_1 = require("../../../marketing/services");
49
+ const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
48
50
  const limited_time_offer_participant_builder_1 = require("../limited-time-offer-participant.builder");
49
51
  const limited_time_offer_participant_repository_1 = require("../limited-time-offer-participant.repository");
50
52
  let LtoParticipantMarketingService = class LtoParticipantMarketingService {
@@ -52,21 +54,60 @@ let LtoParticipantMarketingService = class LtoParticipantMarketingService {
52
54
  constructor() {
53
55
  this.repository = typedi_1.default.get(limited_time_offer_participant_repository_1.LtoParticipantRepository);
54
56
  }
55
- async applyMarketing(shopId, campaign, dto) {
56
- const marketing = await services_1.marketingService.create(limited_time_offer_participant_builder_1.LtoParticipantQueryBuilder.buildMarketingInput(shopId, campaign, dto));
57
+ async createMarketing(shopId, campaign, dto) {
58
+ const marketing = await services_1.marketingService.create(limited_time_offer_participant_builder_1.LtoParticipantQueryBuilder.buildMarketingInput(shopId, campaign, dto), undefined, { skipLimitedTimeOfferGuard: true });
57
59
  return marketing._id;
58
60
  }
59
- async removeMarketing(marketingId) {
60
- await services_1.marketingService.deleteById({ _id: marketingId, softDelete: true });
61
+ async pauseConflicts(shopId, dto) {
62
+ if (dto.isEntireMenu) {
63
+ return this.pauseActiveShopMarketings(shopId, enum_1.MarketingType.DISCOUNT);
64
+ }
65
+ const productIds = dto.products ?? [];
66
+ return productIds.length ? services_1.productMarketingService.pauseConflictingMarketings(productIds) : [];
61
67
  }
62
- async replaceMarketing(oldMarketingId, shopId, campaign, dto) {
63
- await this.removeMarketing(oldMarketingId);
64
- return this.applyMarketing(shopId, campaign, dto);
68
+ async applyMarketing(shopId, campaign, dto) {
69
+ const pausedMarketingIds = await this.pauseConflicts(shopId, dto);
70
+ try {
71
+ const marketingId = await this.createMarketing(shopId, campaign, dto);
72
+ return { marketingId, pausedMarketingIds };
73
+ }
74
+ catch (err) {
75
+ await this.resumeMarketings(pausedMarketingIds);
76
+ throw err;
77
+ }
78
+ }
79
+ async removeMarketing(marketingId) {
80
+ try {
81
+ await services_1.marketingService.deleteById({ _id: marketingId, softDelete: true }, undefined, { skipLimitedTimeOfferGuard: true });
82
+ }
83
+ catch (err) {
84
+ if (err instanceof server_1.TRPCError && err.code === 'NOT_FOUND')
85
+ return;
86
+ throw err;
87
+ }
65
88
  }
66
89
  async removeAllCampaignMarketings(campaignId) {
67
90
  const marketingIds = await this.repository.findMarketingIdsByCampaign(campaignId);
68
91
  await services_1.marketingService.deleteManyByIds(marketingIds);
69
92
  }
93
+ async pauseActiveShopMarketings(shopId, marketingType) {
94
+ const ids = await this.repository.findActiveMarketingIdsByShop(shopId, marketingType);
95
+ if (!ids.length)
96
+ return [];
97
+ await this.repository.updateMarketingStatus(ids, enum_1.MarketingStatus.PAUSED);
98
+ await services_1.synchronizeProductMarketingService.syncProductMarketingInfoByMarketingIds(ids);
99
+ return ids;
100
+ }
101
+ async resumeMarketings(marketingIds) {
102
+ if (!marketingIds?.length)
103
+ return;
104
+ const revivable = await this.repository.findRevivableMarketings(marketingIds);
105
+ if (!revivable.length)
106
+ return;
107
+ const ids = revivable.map(m => m._id);
108
+ await this.repository.updateMarketingStatus(ids, enum_1.MarketingStatus.ACTIVE);
109
+ await services_1.synchronizeProductMarketingService.syncProductMarketingInfoByMarketingIds(ids);
110
+ }
70
111
  };
71
112
  exports.LtoParticipantMarketingService = LtoParticipantMarketingService;
72
113
  exports.LtoParticipantMarketingService = LtoParticipantMarketingService = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer-participant-marketing.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1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from '@typegoose/typegoose';\nimport {marketingService} from '@modules/marketing/services';\nimport {LimitedTimeOfferCampaign} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {JoinLtoCampaignDTO} from '../limited-time-offer-participant.validation';\nimport {LtoParticipantQueryBuilder} from '../limited-time-offer-participant.builder';\nimport {LtoParticipantRepository} from '../limited-time-offer-participant.repository';\n\n@Service()\nexport class LtoParticipantMarketingService {\n private repository: LtoParticipantRepository;\n\n constructor() {\n this.repository = Container.get(LtoParticipantRepository);\n }\n\n public async applyMarketing(\n shopId: mongoose.Types.ObjectId,\n campaign: LimitedTimeOfferCampaign & {_id: mongoose.Types.ObjectId},\n dto: JoinLtoCampaignDTO,\n ): Promise<mongoose.Types.ObjectId> {\n const marketing = await marketingService.create(\n LtoParticipantQueryBuilder.buildMarketingInput(shopId, campaign, dto),\n );\n return marketing._id;\n }\n\n public async removeMarketing(marketingId: mongoose.Types.ObjectId): Promise<void> {\n await marketingService.deleteById({_id: marketingId, softDelete: true});\n }\n\n public async replaceMarketing(\n oldMarketingId: mongoose.Types.ObjectId,\n shopId: mongoose.Types.ObjectId,\n campaign: LimitedTimeOfferCampaign & {_id: mongoose.Types.ObjectId},\n dto: JoinLtoCampaignDTO,\n ): Promise<mongoose.Types.ObjectId> {\n await this.removeMarketing(oldMarketingId);\n return this.applyMarketing(shopId, campaign, dto);\n }\n\n public async removeAllCampaignMarketings(campaignId: mongoose.Types.ObjectId): Promise<void> {\n const marketingIds = await this.repository.findMarketingIdsByCampaign(campaignId);\n await marketingService.deleteManyByIds(marketingIds);\n }\n}\n\nexport const ltoParticipantMarketingService = Container.get(LtoParticipantMarketingService);\n"]}
1
+ {"version":3,"file":"limited-time-offer-participant-marketing.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,yCAAuC;AACvC,0D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AAC,uBAAuB,CAAC,YAAY,CAAC,CAAC;QAC9E,IAAI,CAAC,SAAS,CAAC,MAAM;YAAE,OAAO;QAC9B,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACtC,MAAM,IAAI,CAAC,UAAU,CAAC,qBAAqB,CAAC,GAAG,EAAE,sBAAe,CAAC,MAAM,CAAC,CAAC;QACzE,MAAM,6CAAkC,CAAC,sCAAsC,CAAC,GAAG,CAAC,CAAC;IACzF,CAAC;CACJ,CAAA;AAxFY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,gBAAO,GAAE;;GACG,8BAA8B,CAwF1C;AAEY,QAAA,8BAA8B,GAAG,gBAAS,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {TRPCError} from '@trpc/server';\nimport {marketingService, productMarketingService, synchronizeProductMarketingService} from '@modules/marketing/services';\nimport {LimitedTimeOfferCampaign} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {MarketingStatus, MarketingType} from '@lyxa.ai/core/dist/utilities/enum';\nimport {publishSyncSingleShopSectionsInCacheProcessEvent} from '@lyxa.ai/core/dist/utilities/events-common-methods';\nimport {ChangeStreamOperationTypes} from '@lyxa.ai/core/dist/libraries/event/events/mongo-stream-changes-batch-process-shops-event';\nimport {JoinLtoCampaignDTO} from '../limited-time-offer-participant.validation';\nimport {LtoParticipantQueryBuilder} from '../limited-time-offer-participant.builder';\nimport {LtoParticipantRepository} from '../limited-time-offer-participant.repository';\n\n@Service()\nexport class LtoParticipantMarketingService {\n private repository: LtoParticipantRepository;\n\n constructor() {\n this.repository = Container.get(LtoParticipantRepository);\n }\n\n // Creates the participant's LTO discount marketing without disturbing the shop's own marketings.\n // Used on its own when a shop joins a SCHEDULED campaign — the marketing exists but the shop's\n // existing discounts are only paused once the campaign actually starts.\n public async createMarketing(\n shopId: mongoose.Types.ObjectId,\n campaign: LimitedTimeOfferCampaign & {_id: mongoose.Types.ObjectId},\n dto: JoinLtoCampaignDTO,\n ): Promise<mongoose.Types.ObjectId> {\n const marketing = await marketingService.create(\n LtoParticipantQueryBuilder.buildMarketingInput(shopId, campaign, dto),\n undefined,\n {skipLimitedTimeOfferGuard: true},\n );\n return marketing._id;\n }\n\n // Pauses the shop's existing discounts that would clash with the LTO (all of them for an\n // entire-menu offer, otherwise just the ones on the offered products).\n public async pauseConflicts(\n shopId: mongoose.Types.ObjectId,\n dto: JoinLtoCampaignDTO,\n ): Promise<mongoose.Types.ObjectId[]> {\n if (dto.isEntireMenu) {\n return this.pauseActiveShopMarketings(shopId, MarketingType.DISCOUNT);\n }\n const productIds = dto.products ?? [];\n return productIds.length ? productMarketingService.pauseConflictingMarketings(productIds) : [];\n }\n\n // Active-campaign path: pause conflicts and create the LTO marketing together, rolling the pause\n // back if creation fails.\n public async applyMarketing(\n shopId: mongoose.Types.ObjectId,\n campaign: LimitedTimeOfferCampaign & {_id: mongoose.Types.ObjectId},\n dto: JoinLtoCampaignDTO,\n ): Promise<{marketingId: mongoose.Types.ObjectId; pausedMarketingIds: mongoose.Types.ObjectId[]}> {\n const pausedMarketingIds = await this.pauseConflicts(shopId, dto);\n\n try {\n const marketingId = await this.createMarketing(shopId, campaign, dto);\n return {marketingId, pausedMarketingIds};\n } catch (err) {\n await this.resumeMarketings(pausedMarketingIds);\n throw err;\n }\n }\n\n public async removeMarketing(marketingId: mongoose.Types.ObjectId): Promise<void> {\n try {\n await marketingService.deleteById(\n {_id: marketingId, softDelete: true},\n undefined,\n {skipLimitedTimeOfferGuard: true},\n );\n } catch (err) {\n if (err instanceof TRPCError && err.code === 'NOT_FOUND') return;\n throw err;\n }\n }\n\n public async removeAllCampaignMarketings(campaignId: mongoose.Types.ObjectId): Promise<void> {\n const marketingIds = await this.repository.findMarketingIdsByCampaign(campaignId);\n await marketingService.deleteManyByIds(marketingIds);\n }\n\n public async pauseActiveShopMarketings(shopId: mongoose.Types.ObjectId, marketingType: MarketingType): Promise<mongoose.Types.ObjectId[]> {\n const ids = await this.repository.findActiveMarketingIdsByShop(shopId, marketingType);\n if (!ids.length) return [];\n await this.repository.updateMarketingStatus(ids, MarketingStatus.PAUSED);\n await synchronizeProductMarketingService.syncProductMarketingInfoByMarketingIds(ids);\n return ids;\n }\n\n public async resumeMarketings(marketingIds: mongoose.Types.ObjectId[]): Promise<void> {\n if (!marketingIds?.length) return;\n const revivable = await this.repository.findRevivableMarketings(marketingIds);\n if (!revivable.length) return;\n const ids = revivable.map(m => m._id);\n await this.repository.updateMarketingStatus(ids, MarketingStatus.ACTIVE);\n await synchronizeProductMarketingService.syncProductMarketingInfoByMarketingIds(ids);\n }\n}\n\nexport const ltoParticipantMarketingService = Container.get(LtoParticipantMarketingService);\n"]}
@@ -1,23 +1,34 @@
1
1
  import { DocumentType, mongoose } from '@typegoose/typegoose';
2
- import { JoinLtoCampaignDTO, ParticipantStatusDTO } from '../limited-time-offer-participant.validation';
2
+ import { LimitedTimeOfferCampaign, LimitedTimeOfferParticipant } from '@lyxa.ai/core/dist/libraries/mongo/models';
3
+ import { AdminEnrollShopEntryDTO, JoinLtoCampaignDTO, ParticipantStatusDTO } from '../limited-time-offer-participant.validation';
3
4
  import { GetLtoCampaignParticipantsDTO } from '../../campaign/limited-time-offer-campaign.validation';
4
5
  export declare class LimitedTimeOfferParticipantService {
5
6
  private repository;
6
7
  private campaignService;
7
8
  private marketingService;
8
9
  constructor();
9
- join(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO): Promise<DocumentType<import("@lyxa.ai/core/dist/libraries/mongo/models").LimitedTimeOfferParticipant>>;
10
+ join(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO): Promise<DocumentType<LimitedTimeOfferParticipant>>;
11
+ enrollShops(entries: AdminEnrollShopEntryDTO[]): Promise<(mongoose.Document<unknown, import("@typegoose/typegoose/lib/types").BeAnObject, LimitedTimeOfferParticipant, Record<string, any>, {}> & LimitedTimeOfferParticipant & {
12
+ _id: mongoose.Types.ObjectId;
13
+ } & {
14
+ __v: number;
15
+ } & import("@typegoose/typegoose/lib/types").IObjectWithTypegooseFunction)[]>;
16
+ private joinShop;
17
+ private isCampaignLive;
18
+ private setupParticipantMarketing;
19
+ private restoreShopCapacity;
10
20
  withdraw(shopId: mongoose.Types.ObjectId): Promise<void>;
21
+ isActiveParticipant(shopId: mongoose.Types.ObjectId): Promise<boolean>;
11
22
  getStatus(shopId: mongoose.Types.ObjectId): Promise<ParticipantStatusDTO>;
12
- update(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO): Promise<DocumentType<import("@lyxa.ai/core/dist/libraries/mongo/models").LimitedTimeOfferParticipant> | null>;
23
+ update(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO): Promise<DocumentType<LimitedTimeOfferParticipant> | null>;
13
24
  getParticipants(dto: GetLtoCampaignParticipantsDTO): Promise<{
14
25
  documents: {
15
26
  shopId: mongoose.Types.ObjectId;
16
27
  joinedAt: Date;
17
28
  shopName: string | null;
18
- discountPercentage?: number | undefined;
19
29
  maxDiscountCap?: number | undefined;
20
30
  shopPhoto?: string | null | undefined;
31
+ discountPercentage?: number | undefined;
21
32
  }[];
22
33
  metadata: {
23
34
  page: number;
@@ -31,7 +42,9 @@ export declare class LimitedTimeOfferParticipantService {
31
42
  latitude: number;
32
43
  longitude: number;
33
44
  }): Promise<any[]>;
34
- removeCampaignMarketings(campaignId: mongoose.Types.ObjectId): Promise<void>;
45
+ applyLiveEffectsToParticipants(campaign: DocumentType<LimitedTimeOfferCampaign>): Promise<void>;
46
+ private applyLiveEffects;
47
+ private toParticipantDto;
35
48
  private fetchCurrentCampaignOrThrow;
36
49
  private assertNotAlreadyJoined;
37
50
  private resolveCategorySelection;
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer-participant.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-off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M,qBAAqB,oCAAoD,CAAC"}
1
+ {"version":3,"file":"limited-time-offer-participant.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAC,wBAAwB,EAAE,2BAA2B,EAAU,MAAM,2CAA2C,CAAC;AAKzH,OAAO,EACN,uBAAuB,EACvB,kBAAkB,EAElB,oBAAoB,EAEpB,MAAM,8CAA8C,CAAC;AAGtD,OAAO,EAAC,6BAA6B,EAAC,MAAM,uDAAuD,CAAC;AAGpG,qBACa,kCAAkC;IAC9C,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,eAAe,CAAqB;IAC5C,OAAO,CAAC,gBAAgB,CAAiC;;IAQ5C,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,kBAAkB;IAK7D,WAAW,CAAC,OAAO,EAAE,uBAAuB,EAAE;;;;;YAK7C,QAAQ;IA4CtB,OAAO,CAAC,cAAc;YAMR,yBAAyB;YAoBzB,mBAAmB;IAapB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAexD,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAMtE,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAmBzE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,kBAAkB;IAuC/D,eAAe,CAAC,GAAG,EAAE,6BAA6B;;;;;;;;;;;;;;;;IAQlD,6BAA6B,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ;IAIjE,SAAS,CACrB,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACnC,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE;IAWlC,8BAA8B,CAC1C,QAAQ,EAAE,YAAY,CAAC,wBAAwB,CAAC,GAC9C,OAAO,CAAC,IAAI,CAAC;YAQF,gBAAgB;IA8B9B,OAAO,CAAC,gBAAgB;YAYV,2BAA2B;YAQ3B,sBAAsB;YActB,wBAAwB;YAqBxB,0BAA0B;IAexC,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,0BAA0B;CAkBlC;AAED,eAAO,MAAM,qBAAqB,oCAAoD,CAAC"}
@@ -63,15 +63,52 @@ let LimitedTimeOfferParticipantService = class LimitedTimeOfferParticipantServic
63
63
  }
64
64
  async join(shopId, dto) {
65
65
  const campaign = await this.fetchCurrentCampaignOrThrow();
66
+ return this.joinShop(campaign, shopId, dto);
67
+ }
68
+ async enrollShops(entries) {
69
+ const campaign = await this.fetchCurrentCampaignOrThrow();
70
+ return Promise.all(entries.map(({ shopId, ...dto }) => this.joinShop(campaign, shopId, dto)));
71
+ }
72
+ async joinShop(campaign, shopId, dto) {
66
73
  await this.assertNotAlreadyJoined(campaign._id, shopId);
67
- this.validateDiscountSelections(campaign, dto.discountPercentage, dto.maxDiscountCap);
74
+ this.validateDiscountSelections({ campaign, discountPercentage: dto.discountPercentage, maxDiscountCap: dto.maxDiscountCap });
68
75
  await this.assertProductsBelongToShop(shopId, dto);
69
76
  const resolvedDto = await this.resolveCategorySelection(shopId, dto);
70
- const marketingId = await this.marketingService.applyMarketing(shopId, campaign, resolvedDto);
71
- const participant = await this.repository.create(limited_time_offer_participant_builder_1.LtoParticipantQueryBuilder.buildCreateInput(campaign._id, shopId, marketingId, resolvedDto));
72
- await this.repository.updateShopOrderCapacity(shopId, resolvedDto.isOrderCapacityEnabled, resolvedDto.maxOrderCapacity);
77
+ const isLive = this.isCampaignLive(campaign);
78
+ const { marketingId, pausedMarketings } = await this.setupParticipantMarketing(campaign, shopId, resolvedDto, isLive);
79
+ const capacitySnapshot = isLive && resolvedDto.isOrderCapacityEnabled
80
+ ? await this.repository.getShopOrderCapacity(shopId)
81
+ : undefined;
82
+ const participant = await this.repository.create(limited_time_offer_participant_builder_1.LtoParticipantQueryBuilder.buildCreateInput({
83
+ campaignId: campaign._id,
84
+ shopId,
85
+ marketingId,
86
+ dto: resolvedDto,
87
+ pausedMarketings,
88
+ pausedOrderCapacity: capacitySnapshot?.orderCapacity,
89
+ pausedOrderCapacityEnabled: capacitySnapshot?.orderCapacityEnabled,
90
+ }));
91
+ if (isLive && resolvedDto.isOrderCapacityEnabled) {
92
+ await this.repository.updateShopOrderCapacity(shopId, true, resolvedDto.maxOrderCapacity);
93
+ }
73
94
  return participant;
74
95
  }
96
+ isCampaignLive(campaign) {
97
+ return campaign.status === enum_1.LimitedTimeOfferCampaignStatus.ACTIVE;
98
+ }
99
+ async setupParticipantMarketing(campaign, shopId, dto, isLive) {
100
+ if (!isLive) {
101
+ const marketingId = await this.marketingService.createMarketing(shopId, campaign, dto);
102
+ return { marketingId, pausedMarketings: [] };
103
+ }
104
+ const { marketingId, pausedMarketingIds } = await this.marketingService.applyMarketing(shopId, campaign, dto);
105
+ return { marketingId, pausedMarketings: pausedMarketingIds };
106
+ }
107
+ async restoreShopCapacity(participant) {
108
+ if (participant.pausedOrderCapacityEnabled === undefined)
109
+ return;
110
+ await this.repository.restoreShopOrderCapacity(participant.shop, participant.pausedOrderCapacity, participant.pausedOrderCapacityEnabled);
111
+ }
75
112
  async withdraw(shopId) {
76
113
  const campaign = await this.fetchCurrentCampaignOrThrow();
77
114
  const participant = await this.repository.withdraw(campaign._id, shopId);
@@ -80,6 +117,14 @@ let LimitedTimeOfferParticipantService = class LimitedTimeOfferParticipantServic
80
117
  if (participant.marketing) {
81
118
  await this.marketingService.removeMarketing(participant.marketing);
82
119
  }
120
+ await this.marketingService.resumeMarketings((participant.pausedMarketings ?? []));
121
+ await this.restoreShopCapacity(participant);
122
+ }
123
+ async isActiveParticipant(shopId) {
124
+ const campaign = await this.campaignService.getCurrent();
125
+ if (!campaign)
126
+ return false;
127
+ return this.repository.existsActiveByCampaignAndShop(campaign._id, shopId);
83
128
  }
84
129
  async getStatus(shopId) {
85
130
  const campaign = await this.campaignService.getCurrent();
@@ -100,12 +145,17 @@ let LimitedTimeOfferParticipantService = class LimitedTimeOfferParticipantServic
100
145
  const participant = await this.repository.findActiveByCampaignAndShop(campaign._id, shopId);
101
146
  if (!participant)
102
147
  throw (0, error_common_1.notFoundError)('You have not joined this campaign.');
103
- this.validateDiscountSelections(campaign, dto.discountPercentage, dto.maxDiscountCap, participant);
148
+ this.validateDiscountSelections({ campaign, discountPercentage: dto.discountPercentage, maxDiscountCap: dto.maxDiscountCap, participant });
104
149
  await this.assertProductsBelongToShop(shopId, dto);
105
150
  const resolvedDto = await this.resolveCategorySelection(shopId, dto);
106
- const newMarketingId = participant.marketingId
107
- ? await this.marketingService.replaceMarketing(participant.marketingId, shopId, campaign, resolvedDto)
108
- : await this.marketingService.applyMarketing(shopId, campaign, resolvedDto);
151
+ const isLive = this.isCampaignLive(campaign);
152
+ if (participant.marketingId) {
153
+ await this.marketingService.removeMarketing(participant.marketingId);
154
+ }
155
+ const { marketingId: newMarketingId } = await this.setupParticipantMarketing(campaign, shopId, resolvedDto, isLive);
156
+ if (isLive && resolvedDto.isOrderCapacityEnabled) {
157
+ await this.repository.updateShopOrderCapacity(shopId, true, resolvedDto.maxOrderCapacity);
158
+ }
109
159
  return this.repository.updateParticipant(campaign._id, shopId, {
110
160
  products: resolvedDto.products ?? [],
111
161
  isEntireMenu: resolvedDto.isEntireMenu,
@@ -120,12 +170,7 @@ let LimitedTimeOfferParticipantService = class LimitedTimeOfferParticipantServic
120
170
  const { documents, total } = await this.repository.findByCampaign(dto);
121
171
  return {
122
172
  documents,
123
- metadata: {
124
- page: dto.page,
125
- size: dto.size,
126
- totalElements: total,
127
- totalPages: Math.ceil(total / dto.size),
128
- },
173
+ metadata: { page: dto.page, size: dto.size, totalElements: total, totalPages: Math.ceil(total / dto.size) },
129
174
  };
130
175
  }
131
176
  async getParticipantIdsByCampaignId(campaignId) {
@@ -136,8 +181,43 @@ let LimitedTimeOfferParticipantService = class LimitedTimeOfferParticipantServic
136
181
  const nearByShopDistance = settings.nearByShopDistance || 10000;
137
182
  return this.repository.findNearby(campaignId, input, nearByShopDistance);
138
183
  }
139
- async removeCampaignMarketings(campaignId) {
140
- await this.marketingService.removeAllCampaignMarketings(campaignId);
184
+ async applyLiveEffectsToParticipants(campaign) {
185
+ const participants = await this.repository.findAllActiveByCampaign(campaign._id);
186
+ for (const participant of participants) {
187
+ await this.applyLiveEffects(campaign, participant);
188
+ }
189
+ }
190
+ async applyLiveEffects(campaign, participant) {
191
+ const shopId = participant.shop;
192
+ const dto = this.toParticipantDto(participant);
193
+ const marketingId = participant.marketing
194
+ ? participant.marketing
195
+ : await this.marketingService.createMarketing(shopId, campaign, dto);
196
+ const pausedMarketings = await this.marketingService.pauseConflicts(shopId, dto);
197
+ const capacitySnapshot = dto.isOrderCapacityEnabled
198
+ ? await this.repository.getShopOrderCapacity(shopId)
199
+ : undefined;
200
+ await this.repository.updateParticipant(campaign._id, shopId, {
201
+ ...dto,
202
+ marketing: marketingId,
203
+ pausedMarketings,
204
+ pausedOrderCapacity: capacitySnapshot?.orderCapacity,
205
+ pausedOrderCapacityEnabled: capacitySnapshot?.orderCapacityEnabled,
206
+ });
207
+ if (dto.isOrderCapacityEnabled) {
208
+ await this.repository.updateShopOrderCapacity(shopId, true, participant.maxOrderCapacity);
209
+ }
210
+ }
211
+ toParticipantDto(participant) {
212
+ return {
213
+ isEntireMenu: participant.isEntireMenu,
214
+ products: (participant.products ?? []),
215
+ shopCategories: [],
216
+ discountPercentage: participant.discountPercentage ?? 0,
217
+ maxDiscountCap: participant.maxDiscountCap ?? 0,
218
+ isOrderCapacityEnabled: participant.isOrderCapacityEnabled,
219
+ maxOrderCapacity: participant.maxOrderCapacity,
220
+ };
141
221
  }
142
222
  async fetchCurrentCampaignOrThrow() {
143
223
  const campaign = await this.campaignService.getCurrent();
@@ -175,7 +255,8 @@ let LimitedTimeOfferParticipantService = class LimitedTimeOfferParticipantServic
175
255
  uniqueObjectIds(ids) {
176
256
  return [...new Map(ids.map(id => [id.toString(), id])).values()];
177
257
  }
178
- validateDiscountSelections(campaign, discountPercentage, maxDiscountCap, participant) {
258
+ validateDiscountSelections(input) {
259
+ const { campaign, discountPercentage, maxDiscountCap, participant } = input;
179
260
  if (!campaign.discountOptions.includes(discountPercentage)) {
180
261
  if (!participant || discountPercentage != participant.discountPercentage) {
181
262
  throw (0, error_common_1.badRequestError)('Selected discount is not an available option for this campaign.');
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer-participant.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAG1C,4DAAiF;AACjF,4EAAwG;AACxG,2IAAqH;AACrH,yHAAkG;AAClG,4GAKsD;AACtD,sGAAqF;AACrF,4GAAsF;AAEtF,wCAA2C;AAGpC,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IACtC,UAAU,CAA2B;IACrC,eAAe,CAAqB;IACpC,gBAAgB,CAAiC;IAEzD;QACC,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,oEAAwB,CAAC,CAAC;QAC1D,IAAI,CAAC,eAAe,GAAG,gBAAS,CAAC,GAAG,CAAC,wDAAkB,CAAC,CAAC;QACzD,IAAI,CAAC,gBAAgB,GAAG,gBAAS,CAAC,GAAG,CAAC,iFAA8B,CAAC,CAAC;IACvE,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,MAA+B,EAAE,GAAuB;QACzE,MAAM,QAAQ,GAAG,M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B,IAAI,WAAW,CAAC,kBAAkB,EAAE,CAAC;gBAC1E,MAAM,IAAA,8BAAe,EAAC,iEAAiE,CAAC,CAAC;YAC1F,CAAC;QACF,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;YACxD,IAAI,CAAC,WAAW,IAAI,cAAc,IAAI,WAAW,CAAC,cAAc,EAAE,CAAC;gBAClE,MAAM,IAAA,8BAAe,EAAC,yEAAyE,CAAC,CAAC;YAClG,CAAC;QACF,CAAC;IACF,CAAC;CACD,CAAA;AAtMY,gFAAkC;6CAAlC,kCAAkC;IAD9C,IAAA,gBAAO,GAAE;;GACG,kCAAkC,CAsM9C;AAEY,QAAA,qBAAqB,GAAG,gBAAS,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {DocumentType, mongoose} from '@typegoose/typegoose';\nimport {LimitedTimeOfferCampaign, Setting} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {LimitedTimeOfferCampaignStatus} from '@lyxa.ai/core/dist/utilities/enum';\nimport {badRequestError, conflictError, notFoundError} from '@lyxa.ai/core/dist/utilities/error-common';\nimport {LtoCampaignService} from '@modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service';\nimport {LtoParticipantMarketingService} from './limited-time-offer-participant-marketing.service';\nimport {\n\tJoinLtoCampaignDTO,\n\tLtoCardState,\n\tParticipantStatusDTO,\n\tParticipantSummaryDTO,\n} from '../limited-time-offer-participant.validation';\nimport {LtoParticipantQueryBuilder} from '../limited-time-offer-participant.builder';\nimport {LtoParticipantRepository} from '../limited-time-offer-participant.repository';\nimport {GetLtoCampaignParticipantsDTO} from '../../campaign/limited-time-offer-campaign.validation';\nimport {getLibraries} from '@lyxa.ai/core';\n\n@Service()\nexport class LimitedTimeOfferParticipantService {\n\tprivate repository: LtoParticipantRepository;\n\tprivate campaignService: LtoCampaignService;\n\tprivate marketingService: LtoParticipantMarketingService;\n\n\tconstructor() {\n\t\tthis.repository = Container.get(LtoParticipantRepository);\n\t\tthis.campaignService = Container.get(LtoCampaignService);\n\t\tthis.marketingService = Container.get(LtoParticipantMarketingService);\n\t}\n\n\tpublic async join(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO) {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\n\t\tawait this.assertNotAlreadyJoined(campaign._id, shopId);\n\t\tthis.validateDiscountSelections(campaign, dto.discountPercentage, dto.maxDiscountCap);\n\t\tawait this.assertProductsBelongToShop(shopId, dto);\n\n\t\tconst resolvedDto = await this.resolveCategorySelection(shopId, dto);\n\t\tconst marketingId = await this.marketingService.applyMarketing(shopId, campaign, resolvedDto);\n\n\t\tconst participant = await this.repository.create(\n\t\t\tLtoParticipantQueryBuilder.buildCreateInput(campaign._id, shopId, marketingId, resolvedDto)\n\t\t);\n\t\t// Update shop\n\t\tawait this.repository.updateShopOrderCapacity(\n\t\t\tshopId,\n\t\t\tresolvedDto.isOrderCapacityEnabled,\n\t\t\tresolvedDto.maxOrderCapacity\n\t\t);\n\t\treturn participant;\n\t}\n\n\tpublic async withdraw(shopId: mongoose.Types.ObjectId): Promise<void> {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\n\t\tconst participant = await this.repository.withdraw(campaign._id, shopId);\n\t\tif (!participant) throw notFoundError('You have not joined this campaign.');\n\n\t\tif (participant.marketing) {\n\t\t\tawait this.marketingService.removeMarketing(participant.marketing as mongoose.Types.ObjectId);\n\t\t}\n\t}\n\n\tpublic async getStatus(shopId: mongoose.Types.ObjectId): Promise<ParticipantStatusDTO> {\n\t\tconst campaign = await this.campaignService.getCurrent();\n\n\t\tif (!campaign) return { campaignState: LtoCardState.NONE };\n\n\t\tconst participant = await this.repository.findActiveByCampaignAndShop(campaign._id, shopId);\n\n\t\tconst campaignState =\n\t\t\tcampaign.status === LimitedTimeOfferCampaignStatus.SCHEDULED\n\t\t\t\t? LtoCardState.SCHEDULED\n\t\t\t\t: campaign.status === LimitedTimeOfferCampaignStatus.ACTIVE\n\t\t\t\t\t? LtoCardState.LIVE\n\t\t\t\t\t: LtoCardState.NONE;\n\n\t\treturn participant\n\t\t\t? { campaignState, campaign: campaign as any, participant }\n\t\t\t: { campaignState, campaign: campaign as any };\n\t}\n\n\tpublic async update(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO) {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\n\t\tconst participant = await this.repository.findActiveByCampaignAndShop(campaign._id, shopId);\n\t\tif (!participant) throw notFoundError('You have not joined this campaign.');\n\n\t\tthis.validateDiscountSelections(campaign, dto.discountPercentage, dto.maxDiscountCap, participant);\n\t\tawait this.assertProductsBelongToShop(shopId, dto);\n\n\t\tconst resolvedDto = await this.resolveCategorySelection(shopId, dto);\n\n\t\tconst newMarketingId = participant.marketingId\n\t\t\t? await this.marketingService.replaceMarketing(participant.marketingId, shopId, campaign, resolvedDto)\n\t\t\t: await this.marketingService.applyMarketing(shopId, campaign, resolvedDto);\n\n\t\treturn this.repository.updateParticipant(campaign._id, shopId, {\n\t\t\tproducts: resolvedDto.products ?? [],\n\t\t\tisEntireMenu: resolvedDto.isEntireMenu,\n\t\t\tdiscountPercentage: resolvedDto.discountPercentage,\n\t\t\tmaxDiscountCap: resolvedDto.maxDiscountCap,\n\t\t\tisOrderCapacityEnabled: resolvedDto.isOrderCapacityEnabled,\n\t\t\tmaxOrderCapacity: resolvedDto.maxOrderCapacity,\n\t\t\tmarketing: newMarketingId,\n\t\t});\n\t}\n\n\tpublic async getParticipants(dto: GetLtoCampaignParticipantsDTO) {\n\t\tconst { documents, total } = await this.repository.findByCampaign(dto);\n\t\treturn {\n\t\t\tdocuments,\n\t\t\tmetadata: {\n\t\t\t\tpage: dto.page,\n\t\t\t\tsize: dto.size,\n\t\t\t\ttotalElements: total,\n\t\t\t\ttotalPages: Math.ceil(total / dto.size),\n\t\t\t},\n\t\t};\n\t}\n\n\tpublic async getParticipantIdsByCampaignId(campaignId: mongoose.Types.ObjectId) {\n\t\treturn await this.repository.findParticipantIdsByCampaignId(campaignId);\n\t}\n\n\tpublic async getNearby(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tinput: { latitude: number; longitude: number }\n\t) {\n\t\tconst settings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst nearByShopDistance = settings.nearByShopDistance || 10000;\n\t\treturn this.repository.findNearby(campaignId, input, nearByShopDistance);\n\t}\n\n\tpublic async removeCampaignMarketings(campaignId: mongoose.Types.ObjectId): Promise<void> {\n\t\tawait this.marketingService.removeAllCampaignMarketings(campaignId);\n\t}\n\n\tprivate async fetchCurrentCampaignOrThrow(): Promise<DocumentType<LimitedTimeOfferCampaign>> {\n\t\tconst campaign = await this.campaignService.getCurrent();\n\t\tif (!campaign) {\n\t\t\tthrow badRequestError('No campaign active or scheduled.');\n\t\t}\n\t\treturn campaign;\n\t}\n\n\tprivate async assertNotAlreadyJoined(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<void> {\n\t\tif (await this.repository.existsActiveByCampaignAndShop(campaignId, shopId)) {\n\t\t\tthrow conflictError('Your shop has already joined this campaign.');\n\t\t}\n\t}\n\n\t/**\n\t * Expands the selected shop categories into their product ids and merges them with any explicitly\n\t * selected products. The marketing layer only ever receives a flat product list, so category\n\t * selection is purely an LTO-side convenience that is resolved here before anything is persisted.\n\t */\n\tprivate async resolveCategorySelection(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdto: JoinLtoCampaignDTO\n\t): Promise<JoinLtoCampaignDTO> {\n\t\tif (dto.isEntireMenu || !dto.shopCategories?.length) return dto;\n\n\t\tconst categoryProductIds = await this.repository.findProductIdsByCategories(shopId, dto.shopCategories);\n\t\tconst products = this.uniqueObjectIds([...(dto.products ?? []), ...categoryProductIds]);\n\n\t\tif (products.length === 0) {\n\t\t\tthrow badRequestError('The selected categories do not contain any products.');\n\t\t}\n\n\t\treturn { ...dto, products };\n\t}\n\n\t/**\n\t * Validates that explicitly selected products belong to the shop. Categories are not checked here:\n\t * {@link resolveCategorySelection} fetches their products with a shop-scoped query, so any category\n\t * that does not belong to the shop simply contributes no products.\n\t */\n\tprivate async assertProductsBelongToShop(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdto: JoinLtoCampaignDTO\n\t): Promise<void> {\n\t\tif (dto.isEntireMenu) return;\n\n\t\tconst productIds = this.uniqueObjectIds(dto.products ?? []);\n\t\tif (!productIds.length) return;\n\n\t\tconst owned = await this.repository.countShopProducts(shopId, productIds);\n\t\tif (owned !== productIds.length) {\n\t\t\tthrow badRequestError('One or more selected products do not belong to your shop.');\n\t\t}\n\t}\n\n\tprivate uniqueObjectIds(ids: mongoose.Types.ObjectId[]): mongoose.Types.ObjectId[] {\n\t\treturn [...new Map(ids.map(id => [id.toString(), id])).values()];\n\t}\n\n\tprivate validateDiscountSelections(\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>,\n\t\tdiscountPercentage: number,\n\t\tmaxDiscountCap: number,\n\t\tparticipant?: ParticipantSummaryDTO\n\t): void {\n\t\tif (!campaign.discountOptions.includes(discountPercentage)) {\n\t\t\tif (!participant || discountPercentage != participant.discountPercentage) {\n\t\t\t\tthrow badRequestError('Selected discount is not an available option for this campaign.');\n\t\t\t}\n\t\t}\n\t\tif (!campaign.maxDiscountCaps.includes(maxDiscountCap)) {\n\t\t\tif (!participant || maxDiscountCap != participant.maxDiscountCap) {\n\t\t\t\tthrow badRequestError('Selected max discount cap is not an available option for this campaign.');\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport const ltoParticipantService = Container.get(LimitedTimeOfferParticipantService);\n"]}
1
+ {"version":3,"file":"limited-time-offer-participant.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A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IAAI,cAAc,IAAI,WAAW,CAAC,cAAc,EAAE,CAAC;gBAClE,MAAM,IAAA,8BAAe,EAAC,yEAAyE,CAAC,CAAC;YAClG,CAAC;QACF,CAAC;IACF,CAAC;CACD,CAAA;AApVY,gFAAkC;6CAAlC,kCAAkC;IAD9C,IAAA,gBAAO,GAAE;;GACG,kCAAkC,CAoV9C;AAEY,QAAA,qBAAqB,GAAG,gBAAS,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {DocumentType, mongoose} from '@typegoose/typegoose';\nimport {LimitedTimeOfferCampaign, LimitedTimeOfferParticipant, Setting} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {LimitedTimeOfferCampaignStatus} from '@lyxa.ai/core/dist/utilities/enum';\nimport {badRequestError, conflictError, notFoundError} from '@lyxa.ai/core/dist/utilities/error-common';\nimport {LtoCampaignService} from '@modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service';\nimport {LtoParticipantMarketingService} from './limited-time-offer-participant-marketing.service';\nimport {\n\tAdminEnrollShopEntryDTO,\n\tJoinLtoCampaignDTO,\n\tLtoCardState,\n\tParticipantStatusDTO,\n\tParticipantSummaryDTO,\n} from '../limited-time-offer-participant.validation';\nimport {LtoParticipantQueryBuilder} from '../limited-time-offer-participant.builder';\nimport {LtoParticipantRepository} from '../limited-time-offer-participant.repository';\nimport {GetLtoCampaignParticipantsDTO} from '../../campaign/limited-time-offer-campaign.validation';\nimport {getLibraries} from '@lyxa.ai/core';\n\n@Service()\nexport class LimitedTimeOfferParticipantService {\n\tprivate repository: LtoParticipantRepository;\n\tprivate campaignService: LtoCampaignService;\n\tprivate marketingService: LtoParticipantMarketingService;\n\n\tconstructor() {\n\t\tthis.repository = Container.get(LtoParticipantRepository);\n\t\tthis.campaignService = Container.get(LtoCampaignService);\n\t\tthis.marketingService = Container.get(LtoParticipantMarketingService);\n\t}\n\n\tpublic async join(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO) {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\t\treturn this.joinShop(campaign, shopId, dto);\n\t}\n\n\tpublic async enrollShops(entries: AdminEnrollShopEntryDTO[]) {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\t\treturn Promise.all(entries.map(({shopId, ...dto}) => this.joinShop(campaign, shopId, dto)));\n\t}\n\n\tprivate async joinShop(\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>,\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdto: JoinLtoCampaignDTO\n\t) {\n\t\tawait this.assertNotAlreadyJoined(campaign._id, shopId);\n\t\tthis.validateDiscountSelections({campaign, discountPercentage: dto.discountPercentage, maxDiscountCap: dto.maxDiscountCap});\n\t\tawait this.assertProductsBelongToShop(shopId, dto);\n\n\t\tconst resolvedDto = await this.resolveCategorySelection(shopId, dto);\n\t\tconst isLive = this.isCampaignLive(campaign);\n\n\t\t// The LTO marketing is created as soon as the shop joins (its future duration keeps it dormant\n\t\t// until the campaign runs). Pausing the shop's own discounts and overriding its order capacity\n\t\t// are deferred to activation unless the campaign is already live.\n\t\tconst {marketingId, pausedMarketings} = await this.setupParticipantMarketing(\n\t\t\tcampaign,\n\t\t\tshopId,\n\t\t\tresolvedDto,\n\t\t\tisLive\n\t\t);\n\n\t\tconst capacitySnapshot =\n\t\t\tisLive && resolvedDto.isOrderCapacityEnabled\n\t\t\t\t? await this.repository.getShopOrderCapacity(shopId)\n\t\t\t\t: undefined;\n\n\t\tconst participant = await this.repository.create(\n\t\t\tLtoParticipantQueryBuilder.buildCreateInput({\n\t\t\t\tcampaignId: campaign._id,\n\t\t\t\tshopId,\n\t\t\t\tmarketingId,\n\t\t\t\tdto: resolvedDto,\n\t\t\t\tpausedMarketings,\n\t\t\t\tpausedOrderCapacity: capacitySnapshot?.orderCapacity,\n\t\t\t\tpausedOrderCapacityEnabled: capacitySnapshot?.orderCapacityEnabled,\n\t\t\t})\n\t\t);\n\t\tif (isLive && resolvedDto.isOrderCapacityEnabled) {\n\t\t\tawait this.repository.updateShopOrderCapacity(shopId, true, resolvedDto.maxOrderCapacity);\n\t\t}\n\t\treturn participant;\n\t}\n\n\tprivate isCampaignLive(campaign: {status: LimitedTimeOfferCampaignStatus}): boolean {\n\t\treturn campaign.status === LimitedTimeOfferCampaignStatus.ACTIVE;\n\t}\n\n\t// Always creates the LTO marketing. Only pauses the shop's clashing discounts when the campaign is\n\t// live; a scheduled campaign leaves them running until it starts.\n\tprivate async setupParticipantMarketing(\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>,\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdto: JoinLtoCampaignDTO,\n\t\tisLive: boolean\n\t): Promise<{marketingId: mongoose.Types.ObjectId; pausedMarketings: mongoose.Types.ObjectId[]}> {\n\t\tif (!isLive) {\n\t\t\tconst marketingId = await this.marketingService.createMarketing(shopId, campaign, dto);\n\t\t\treturn {marketingId, pausedMarketings: []};\n\t\t}\n\t\tconst {marketingId, pausedMarketingIds} = await this.marketingService.applyMarketing(\n\t\t\tshopId,\n\t\t\tcampaign,\n\t\t\tdto\n\t\t);\n\t\treturn {marketingId, pausedMarketings: pausedMarketingIds};\n\t}\n\n\t// Puts the shop's own order-capacity config back after the LTO override ends, and clears any\n\t// capacity-induced BUSY. No-op when this participant never overrode the shop's capacity.\n\tprivate async restoreShopCapacity(participant: {\n\t\tshop: unknown;\n\t\tpausedOrderCapacity?: number;\n\t\tpausedOrderCapacityEnabled?: boolean;\n\t}): Promise<void> {\n\t\tif (participant.pausedOrderCapacityEnabled === undefined) return;\n\t\tawait this.repository.restoreShopOrderCapacity(\n\t\t\tparticipant.shop as mongoose.Types.ObjectId,\n\t\t\tparticipant.pausedOrderCapacity,\n\t\t\tparticipant.pausedOrderCapacityEnabled\n\t\t);\n\t}\n\n\tpublic async withdraw(shopId: mongoose.Types.ObjectId): Promise<void> {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\n\t\tconst participant = await this.repository.withdraw(campaign._id, shopId);\n\t\tif (!participant) throw notFoundError('You have not joined this campaign.');\n\n\t\tif (participant.marketing) {\n\t\t\tawait this.marketingService.removeMarketing(participant.marketing as mongoose.Types.ObjectId);\n\t\t}\n\t\tawait this.marketingService.resumeMarketings(\n\t\t\t(participant.pausedMarketings ?? []) as mongoose.Types.ObjectId[]\n\t\t);\n\t\tawait this.restoreShopCapacity(participant);\n\t}\n\n\tpublic async isActiveParticipant(shopId: mongoose.Types.ObjectId): Promise<boolean> {\n\t\tconst campaign = await this.campaignService.getCurrent();\n\t\tif (!campaign) return false;\n\t\treturn this.repository.existsActiveByCampaignAndShop(campaign._id, shopId);\n\t}\n\n\tpublic async getStatus(shopId: mongoose.Types.ObjectId): Promise<ParticipantStatusDTO> {\n\t\tconst campaign = await this.campaignService.getCurrent();\n\n\t\tif (!campaign) return { campaignState: LtoCardState.NONE };\n\n\t\tconst participant = await this.repository.findActiveByCampaignAndShop(campaign._id, shopId);\n\n\t\tconst campaignState =\n\t\t\tcampaign.status === LimitedTimeOfferCampaignStatus.SCHEDULED\n\t\t\t\t? LtoCardState.SCHEDULED\n\t\t\t\t: campaign.status === LimitedTimeOfferCampaignStatus.ACTIVE\n\t\t\t\t\t? LtoCardState.LIVE\n\t\t\t\t\t: LtoCardState.NONE;\n\n\t\treturn participant\n\t\t\t? { campaignState, campaign: campaign as any, participant }\n\t\t\t: { campaignState, campaign: campaign as any };\n\t}\n\n\tpublic async update(shopId: mongoose.Types.ObjectId, dto: JoinLtoCampaignDTO) {\n\t\tconst campaign = await this.fetchCurrentCampaignOrThrow();\n\n\t\tconst participant = await this.repository.findActiveByCampaignAndShop(campaign._id, shopId);\n\t\tif (!participant) throw notFoundError('You have not joined this campaign.');\n\n\t\tthis.validateDiscountSelections({campaign, discountPercentage: dto.discountPercentage, maxDiscountCap: dto.maxDiscountCap, participant});\n\t\tawait this.assertProductsBelongToShop(shopId, dto);\n\n\t\tconst resolvedDto = await this.resolveCategorySelection(shopId, dto);\n\t\tconst isLive = this.isCampaignLive(campaign);\n\n\t\tif (participant.marketingId) {\n\t\t\tawait this.marketingService.removeMarketing(participant.marketingId);\n\t\t}\n\t\tconst {marketingId: newMarketingId} = await this.setupParticipantMarketing(\n\t\t\tcampaign,\n\t\t\tshopId,\n\t\t\tresolvedDto,\n\t\t\tisLive\n\t\t);\n\n\t\t// Mirrors joinShop: while the campaign is live, the shop's order-capacity override must track\n\t\t// the participant's current configuration, not just what was in effect at join/activation time.\n\t\tif (isLive && resolvedDto.isOrderCapacityEnabled) {\n\t\t\tawait this.repository.updateShopOrderCapacity(shopId, true, resolvedDto.maxOrderCapacity);\n\t\t}\n\n\t\treturn this.repository.updateParticipant(campaign._id, shopId, {\n\t\t\tproducts: resolvedDto.products ?? [],\n\t\t\tisEntireMenu: resolvedDto.isEntireMenu,\n\t\t\tdiscountPercentage: resolvedDto.discountPercentage,\n\t\t\tmaxDiscountCap: resolvedDto.maxDiscountCap,\n\t\t\tisOrderCapacityEnabled: resolvedDto.isOrderCapacityEnabled,\n\t\t\tmaxOrderCapacity: resolvedDto.maxOrderCapacity,\n\t\t\tmarketing: newMarketingId,\n\t\t});\n\t}\n\n\tpublic async getParticipants(dto: GetLtoCampaignParticipantsDTO) {\n\t\tconst {documents, total} = await this.repository.findByCampaign(dto);\n\t\treturn {\n\t\t\tdocuments,\n\t\t\tmetadata: {page: dto.page, size: dto.size, totalElements: total, totalPages: Math.ceil(total / dto.size)},\n\t\t};\n\t}\n\n\tpublic async getParticipantIdsByCampaignId(campaignId: mongoose.Types.ObjectId) {\n\t\treturn await this.repository.findParticipantIdsByCampaignId(campaignId);\n\t}\n\n\tpublic async getNearby(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tinput: { latitude: number; longitude: number }\n\t) {\n\t\tconst settings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst nearByShopDistance = settings.nearByShopDistance || 10000;\n\t\treturn this.repository.findNearby(campaignId, input, nearByShopDistance);\n\t}\n\n\t// Runs when a campaign transitions to ACTIVE. For every participant that joined while the campaign\n\t// was scheduled, this is where the deferred effects finally land: the LTO marketing is created if\n\t// it doesn't already exist (recurrence clones start without one), the shop's clashing discounts are\n\t// paused, and the order-capacity override is applied (snapshotting the shop's own config first).\n\tpublic async applyLiveEffectsToParticipants(\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>\n\t): Promise<void> {\n\t\tconst participants = await this.repository.findAllActiveByCampaign(campaign._id);\n\n\t\tfor (const participant of participants) {\n\t\t\tawait this.applyLiveEffects(campaign, participant);\n\t\t}\n\t}\n\n\tprivate async applyLiveEffects(\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>,\n\t\tparticipant: DocumentType<LimitedTimeOfferParticipant>\n\t): Promise<void> {\n\t\tconst shopId = participant.shop as mongoose.Types.ObjectId;\n\t\tconst dto = this.toParticipantDto(participant);\n\n\t\tconst marketingId = participant.marketing\n\t\t\t? (participant.marketing as mongoose.Types.ObjectId)\n\t\t\t: await this.marketingService.createMarketing(shopId, campaign, dto);\n\n\t\tconst pausedMarketings = await this.marketingService.pauseConflicts(shopId, dto);\n\n\t\tconst capacitySnapshot = dto.isOrderCapacityEnabled\n\t\t\t? await this.repository.getShopOrderCapacity(shopId)\n\t\t\t: undefined;\n\n\t\tawait this.repository.updateParticipant(campaign._id, shopId, {\n\t\t\t...dto,\n\t\t\tmarketing: marketingId,\n\t\t\tpausedMarketings,\n\t\t\tpausedOrderCapacity: capacitySnapshot?.orderCapacity,\n\t\t\tpausedOrderCapacityEnabled: capacitySnapshot?.orderCapacityEnabled,\n\t\t});\n\n\t\tif (dto.isOrderCapacityEnabled) {\n\t\t\tawait this.repository.updateShopOrderCapacity(shopId, true, participant.maxOrderCapacity);\n\t\t}\n\t}\n\n\tprivate toParticipantDto(participant: DocumentType<LimitedTimeOfferParticipant>): JoinLtoCampaignDTO {\n\t\treturn {\n\t\t\tisEntireMenu: participant.isEntireMenu,\n\t\t\tproducts: (participant.products ?? []) as mongoose.Types.ObjectId[],\n\t\t\tshopCategories: [],\n\t\t\tdiscountPercentage: participant.discountPercentage ?? 0,\n\t\t\tmaxDiscountCap: participant.maxDiscountCap ?? 0,\n\t\t\tisOrderCapacityEnabled: participant.isOrderCapacityEnabled,\n\t\t\tmaxOrderCapacity: participant.maxOrderCapacity,\n\t\t};\n\t}\n\n\tprivate async fetchCurrentCampaignOrThrow(): Promise<DocumentType<LimitedTimeOfferCampaign>> {\n\t\tconst campaign = await this.campaignService.getCurrent();\n\t\tif (!campaign) {\n\t\t\tthrow badRequestError('No campaign active or scheduled.');\n\t\t}\n\t\treturn campaign;\n\t}\n\n\tprivate async assertNotAlreadyJoined(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<void> {\n\t\tif (await this.repository.existsActiveByCampaignAndShop(campaignId, shopId)) {\n\t\t\tthrow conflictError('Your shop has already joined this campaign.');\n\t\t}\n\t}\n\n\t/**\n\t * Expands the selected shop categories into their product ids and merges them with any explicitly\n\t * selected products. The marketing layer only ever receives a flat product list, so category\n\t * selection is purely an LTO-side convenience that is resolved here before anything is persisted.\n\t */\n\tprivate async resolveCategorySelection(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdto: JoinLtoCampaignDTO\n\t): Promise<JoinLtoCampaignDTO> {\n\t\tif (dto.isEntireMenu || !dto.shopCategories?.length) return dto;\n\n\t\tconst categoryProductIds = await this.repository.findProductIdsByCategories(shopId, dto.shopCategories);\n\t\tconst products = this.uniqueObjectIds([...(dto.products ?? []), ...categoryProductIds]);\n\n\t\tif (products.length === 0) {\n\t\t\tthrow badRequestError('The selected categories do not contain any products.');\n\t\t}\n\n\t\treturn { ...dto, products };\n\t}\n\n\t/**\n\t * Validates that explicitly selected products belong to the shop. Categories are not checked here:\n\t * {@link resolveCategorySelection} fetches their products with a shop-scoped query, so any category\n\t * that does not belong to the shop simply contributes no products.\n\t */\n\tprivate async assertProductsBelongToShop(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdto: JoinLtoCampaignDTO\n\t): Promise<void> {\n\t\tif (dto.isEntireMenu) return;\n\n\t\tconst productIds = this.uniqueObjectIds(dto.products ?? []);\n\t\tif (!productIds.length) return;\n\n\t\tconst owned = await this.repository.countShopProducts(shopId, productIds);\n\t\tif (owned !== productIds.length) {\n\t\t\tthrow badRequestError('One or more selected products do not belong to your shop.');\n\t\t}\n\t}\n\n\tprivate uniqueObjectIds(ids: mongoose.Types.ObjectId[]): mongoose.Types.ObjectId[] {\n\t\treturn [...new Map(ids.map(id => [id.toString(), id])).values()];\n\t}\n\n\tprivate validateDiscountSelections(input: {\n\t\tcampaign: DocumentType<LimitedTimeOfferCampaign>;\n\t\tdiscountPercentage: number;\n\t\tmaxDiscountCap: number;\n\t\tparticipant?: ParticipantSummaryDTO;\n\t}): void {\n\t\tconst {campaign, discountPercentage, maxDiscountCap, participant} = input;\n\t\tif (!campaign.discountOptions.includes(discountPercentage)) {\n\t\t\tif (!participant || discountPercentage != participant.discountPercentage) {\n\t\t\t\tthrow badRequestError('Selected discount is not an available option for this campaign.');\n\t\t\t}\n\t\t}\n\t\tif (!campaign.maxDiscountCaps.includes(maxDiscountCap)) {\n\t\t\tif (!participant || maxDiscountCap != participant.maxDiscountCap) {\n\t\t\t\tthrow badRequestError('Selected max discount cap is not an available option for this campaign.');\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport const ltoParticipantService = Container.get(LimitedTimeOfferParticipantService);\n"]}
@@ -0,0 +1,13 @@
1
+ import { mongoose } from '@typegoose/typegoose';
2
+ import { LimitedTimeOfferCampaignSession as Model } from '@lyxa.ai/core/dist/libraries/mongo/models';
3
+ export declare class LtoCampaignSessionRepository {
4
+ private model;
5
+ constructor();
6
+ create(data: object): Promise<InstanceType<typeof Model>>;
7
+ findByCampaign(campaignId: mongoose.Types.ObjectId, page: number, size: number): Promise<{
8
+ documents: InstanceType<typeof Model>[];
9
+ total: number;
10
+ }>;
11
+ }
12
+ export declare const ltoCampaignSessionRepository: LtoCampaignSessionRepository;
13
+ //# sourceMappingURL=limited-time-offer-campaign-session.repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limited-time-offer-campaign-session.repository.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EACH,+BAA+B,IAAI,KAAK,EAE3C,MAAM,2CAA2C,CAAC;AAEnD,qBACa,4BAA4B;IACrC,OAAO,CAAC,KAAK,CAA8C;;IAMrD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,OAAO,KAAK,CAAC,CAAC;IAIzD,cAAc,CAChB,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EACnC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACb,OAAO,CAAC;QAAC,SAAS,EAAE,YAAY,CAAC,OAAO,KAAK,CAAC,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAAC;CAYvE;AAED,eAAO,MAAM,4BAA4B,8BAA8C,CAAC"}