@lyxa.ai/marketing 1.0.61 → 1.0.62

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 +0 -2
  3. package/dist/lib/event/event-initializations.js.map +1 -1
  4. package/dist/lib/event/event-listeners/event-listeners.d.ts +0 -2
  5. package/dist/lib/event/event-listeners/event-listeners.d.ts.map +1 -1
  6. package/dist/lib/event/event-listeners/event-listeners.js +12 -69
  7. package/dist/lib/event/event-listeners/event-listeners.js.map +1 -1
  8. package/dist/lib/event/events/marketing-product-seed.event.d.ts +2 -1
  9. package/dist/lib/event/events/marketing-product-seed.event.d.ts.map +1 -1
  10. package/dist/lib/event/events/marketing-product-seed.event.js.map +1 -1
  11. package/dist/lib/index.d.ts +194 -650
  12. package/dist/lib/index.d.ts.map +1 -1
  13. package/dist/lib/index.js +1 -5
  14. package/dist/lib/index.js.map +1 -1
  15. package/dist/lib/modules/coupon/routers/coupon.router.d.ts +59 -0
  16. package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
  17. package/dist/lib/modules/coupon/routers/coupon.router.js +7 -0
  18. package/dist/lib/modules/coupon/routers/coupon.router.js.map +1 -1
  19. package/dist/lib/modules/coupon/services/coupon.service.d.ts +1 -0
  20. package/dist/lib/modules/coupon/services/coupon.service.d.ts.map +1 -1
  21. package/dist/lib/modules/coupon/services/coupon.service.js +3 -0
  22. package/dist/lib/modules/coupon/services/coupon.service.js.map +1 -1
  23. package/dist/lib/modules/coupon/validations/create-coupon.validation.d.ts.map +1 -1
  24. package/dist/lib/modules/coupon/validations/create-coupon.validation.js +1 -4
  25. package/dist/lib/modules/coupon/validations/create-coupon.validation.js.map +1 -1
  26. package/dist/lib/modules/deal-setting/services/deal-setting.service.d.ts.map +1 -1
  27. package/dist/lib/modules/deal-setting/services/deal-setting.service.js +1 -4
  28. package/dist/lib/modules/deal-setting/services/deal-setting.service.js.map +1 -1
  29. package/dist/lib/modules/featured-setting/services/featured-setting.service.d.ts.map +1 -1
  30. package/dist/lib/modules/featured-setting/services/featured-setting.service.js +0 -3
  31. package/dist/lib/modules/featured-setting/services/featured-setting.service.js.map +1 -1
  32. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts +8 -54
  33. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
  34. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js +0 -11
  35. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js.map +1 -1
  36. package/dist/lib/modules/limited-time-offer/campaign/jobs/index.d.ts.map +1 -1
  37. package/dist/lib/modules/limited-time-offer/campaign/jobs/index.js +0 -6
  38. package/dist/lib/modules/limited-time-offer/campaign/jobs/index.js.map +1 -1
  39. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts +1 -0
  40. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts.map +1 -1
  41. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.js +6 -2
  42. package/dist/lib/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.js.map +1 -1
  43. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts +3 -16
  44. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts.map +1 -1
  45. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.js +3 -22
  46. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.js.map +1 -1
  47. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.d.ts +0 -2
  48. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.d.ts.map +1 -1
  49. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.js +0 -12
  50. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.js.map +1 -1
  51. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +35 -242
  52. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts.map +1 -1
  53. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js +1 -19
  54. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.js.map +1 -1
  55. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts +1 -8
  56. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts.map +1 -1
  57. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.js +1 -64
  58. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.js.map +1 -1
  59. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.d.ts +0 -3
  60. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.d.ts.map +1 -1
  61. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.js +8 -66
  62. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.js.map +1 -1
  63. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts +1 -1
  64. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
  65. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js +19 -37
  66. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js.map +1 -1
  67. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts +18 -249
  68. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
  69. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts +0 -2
  70. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -1
  71. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js +3 -15
  72. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js.map +1 -1
  73. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts +1 -1
  74. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.js +1 -1
  75. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.js.map +1 -1
  76. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts +3 -24
  77. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts.map +1 -1
  78. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.js +1 -19
  79. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.js.map +1 -1
  80. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +0 -10
  81. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
  82. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js +0 -43
  83. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js.map +1 -1
  84. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +10 -195
  85. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
  86. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.js +0 -29
  87. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.js.map +1 -1
  88. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +33 -428
  89. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
  90. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js +6 -16
  91. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js.map +1 -1
  92. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts +4 -7
  93. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts.map +1 -1
  94. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.js +7 -42
  95. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.js.map +1 -1
  96. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +3 -14
  97. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  98. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js +16 -76
  99. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js.map +1 -1
  100. package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts +0 -1
  101. package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts.map +1 -1
  102. package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.js +0 -29
  103. package/dist/lib/modules/marketing/patterns/repository/MarketingMetricsRepository.js.map +1 -1
  104. package/dist/lib/modules/marketing/routers/marketing.router.d.ts +0 -14
  105. package/dist/lib/modules/marketing/routers/marketing.router.d.ts.map +1 -1
  106. package/dist/lib/modules/marketing/routers/marketing.router.js +0 -5
  107. package/dist/lib/modules/marketing/routers/marketing.router.js.map +1 -1
  108. package/dist/lib/modules/marketing/services/index.d.ts +0 -3
  109. package/dist/lib/modules/marketing/services/index.d.ts.map +1 -1
  110. package/dist/lib/modules/marketing/services/index.js +0 -3
  111. package/dist/lib/modules/marketing/services/index.js.map +1 -1
  112. package/dist/lib/modules/marketing/services/marketing.service.d.ts +2 -7
  113. package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
  114. package/dist/lib/modules/marketing/services/marketing.service.js +51 -97
  115. package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -1
  116. package/dist/lib/modules/marketing/services/product-marketing.service.d.ts +3 -2
  117. package/dist/lib/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
  118. package/dist/lib/modules/marketing/services/product-marketing.service.js +13 -42
  119. package/dist/lib/modules/marketing/services/product-marketing.service.js.map +1 -1
  120. package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.d.ts.map +1 -1
  121. package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.js +27 -95
  122. package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.js.map +1 -1
  123. package/dist/lib/modules/marketing/validations/all-marketings.validation.d.ts.map +1 -1
  124. package/dist/lib/modules/marketing/validations/all-marketings.validation.js +0 -3
  125. package/dist/lib/modules/marketing/validations/all-marketings.validation.js.map +1 -1
  126. package/dist/lib/modules/marketing/validations/buy1-get1-marketing.validation.d.ts +3 -3
  127. package/dist/lib/modules/marketing/validations/discount-marketing.validation.d.ts +3 -3
  128. package/dist/lib/modules/marketing/validations/index.d.ts +0 -1
  129. package/dist/lib/modules/marketing/validations/index.d.ts.map +1 -1
  130. package/dist/lib/modules/marketing/validations/index.js +0 -1
  131. package/dist/lib/modules/marketing/validations/index.js.map +1 -1
  132. package/dist/lib/modules/marketing/validations/marketing.validation.d.ts +0 -17
  133. package/dist/lib/modules/marketing/validations/marketing.validation.d.ts.map +1 -1
  134. package/dist/lib/modules/marketing/validations/marketing.validation.js +1 -7
  135. package/dist/lib/modules/marketing/validations/marketing.validation.js.map +1 -1
  136. package/dist/lib/modules/marketing/validations/product-marketing.validation.d.ts +2 -2
  137. package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +1 -1
  138. package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts +1 -0
  139. package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts.map +1 -1
  140. package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.js +49 -2
  141. package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.js.map +1 -1
  142. package/dist/lib/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +2 -2
  143. package/dist/types/event/event-initializations.d.ts.map +1 -1
  144. package/dist/types/event/event-listeners/event-listeners.d.ts +0 -2
  145. package/dist/types/event/event-listeners/event-listeners.d.ts.map +1 -1
  146. package/dist/types/event/events/marketing-product-seed.event.d.ts +2 -1
  147. package/dist/types/event/events/marketing-product-seed.event.d.ts.map +1 -1
  148. package/dist/types/index.d.ts +194 -650
  149. package/dist/types/index.d.ts.map +1 -1
  150. package/dist/types/modules/coupon/routers/coupon.router.d.ts +59 -0
  151. package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
  152. package/dist/types/modules/coupon/services/coupon.service.d.ts +1 -0
  153. package/dist/types/modules/coupon/services/coupon.service.d.ts.map +1 -1
  154. package/dist/types/modules/coupon/validations/create-coupon.validation.d.ts.map +1 -1
  155. package/dist/types/modules/deal-setting/services/deal-setting.service.d.ts.map +1 -1
  156. package/dist/types/modules/featured-setting/services/featured-setting.service.d.ts.map +1 -1
  157. package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts +8 -54
  158. package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
  159. package/dist/types/modules/limited-time-offer/campaign/jobs/index.d.ts.map +1 -1
  160. package/dist/types/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts +1 -0
  161. package/dist/types/modules/limited-time-offer/campaign/jobs/limited-time-offer-campaign.worker.d.ts.map +1 -1
  162. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts +3 -16
  163. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts.map +1 -1
  164. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.d.ts +0 -2
  165. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.d.ts.map +1 -1
  166. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +35 -242
  167. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts.map +1 -1
  168. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts +1 -8
  169. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts.map +1 -1
  170. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.d.ts +0 -3
  171. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-scheduler.service.d.ts.map +1 -1
  172. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts +1 -1
  173. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
  174. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts +18 -249
  175. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
  176. package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts +0 -2
  177. package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -1
  178. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts +1 -1
  179. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts +3 -24
  180. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts.map +1 -1
  181. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +0 -10
  182. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
  183. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +10 -195
  184. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
  185. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +33 -428
  186. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
  187. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts +4 -7
  188. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts.map +1 -1
  189. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +3 -14
  190. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  191. package/dist/types/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts +0 -1
  192. package/dist/types/modules/marketing/patterns/repository/MarketingMetricsRepository.d.ts.map +1 -1
  193. package/dist/types/modules/marketing/routers/marketing.router.d.ts +0 -14
  194. package/dist/types/modules/marketing/routers/marketing.router.d.ts.map +1 -1
  195. package/dist/types/modules/marketing/services/index.d.ts +0 -3
  196. package/dist/types/modules/marketing/services/index.d.ts.map +1 -1
  197. package/dist/types/modules/marketing/services/marketing.service.d.ts +2 -7
  198. package/dist/types/modules/marketing/services/marketing.service.d.ts.map +1 -1
  199. package/dist/types/modules/marketing/services/product-marketing.service.d.ts +3 -7
  200. package/dist/types/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
  201. package/dist/types/modules/marketing/services/synchronize-product-marketing.service.d.ts.map +1 -1
  202. package/dist/types/modules/marketing/validations/all-marketings.validation.d.ts.map +1 -1
  203. package/dist/types/modules/marketing/validations/buy1-get1-marketing.validation.d.ts +3 -3
  204. package/dist/types/modules/marketing/validations/discount-marketing.validation.d.ts +3 -3
  205. package/dist/types/modules/marketing/validations/index.d.ts +0 -1
  206. package/dist/types/modules/marketing/validations/index.d.ts.map +1 -1
  207. package/dist/types/modules/marketing/validations/marketing.validation.d.ts +0 -17
  208. package/dist/types/modules/marketing/validations/marketing.validation.d.ts.map +1 -1
  209. package/dist/types/modules/marketing/validations/product-marketing.validation.d.ts +2 -2
  210. package/dist/types/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +1 -1
  211. package/dist/types/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts +5 -0
  212. package/dist/types/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts.map +1 -1
  213. package/dist/types/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +2 -2
  214. package/package.json +2 -2
  215. package/dist/lib/event/events/marketing-product-sync.event.d.ts +0 -11
  216. package/dist/lib/event/events/marketing-product-sync.event.d.ts.map +0 -1
  217. package/dist/lib/event/events/marketing-product-sync.event.js +0 -12
  218. package/dist/lib/event/events/marketing-product-sync.event.js.map +0 -1
  219. package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.d.ts +0 -13
  220. package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.d.ts.map +0 -1
  221. package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.js +0 -75
  222. package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.js.map +0 -1
  223. package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.d.ts +0 -21
  224. package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.d.ts.map +0 -1
  225. package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.js +0 -83
  226. package/dist/lib/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.js.map +0 -1
  227. package/dist/lib/modules/marketing/services/marketing-conflict.repository.d.ts +0 -9
  228. package/dist/lib/modules/marketing/services/marketing-conflict.repository.d.ts.map +0 -1
  229. package/dist/lib/modules/marketing/services/marketing-conflict.repository.js +0 -63
  230. package/dist/lib/modules/marketing/services/marketing-conflict.repository.js.map +0 -1
  231. package/dist/lib/modules/marketing/services/marketing-conflict.service.d.ts +0 -27
  232. package/dist/lib/modules/marketing/services/marketing-conflict.service.d.ts.map +0 -1
  233. package/dist/lib/modules/marketing/services/marketing-conflict.service.js +0 -135
  234. package/dist/lib/modules/marketing/services/marketing-conflict.service.js.map +0 -1
  235. package/dist/lib/modules/marketing/services/spend-to-get-marketing.repository.d.ts +0 -14
  236. package/dist/lib/modules/marketing/services/spend-to-get-marketing.repository.d.ts.map +0 -1
  237. package/dist/lib/modules/marketing/services/spend-to-get-marketing.repository.js +0 -82
  238. package/dist/lib/modules/marketing/services/spend-to-get-marketing.repository.js.map +0 -1
  239. package/dist/lib/modules/marketing/services/spend-to-get-marketing.service.d.ts +0 -11
  240. package/dist/lib/modules/marketing/services/spend-to-get-marketing.service.d.ts.map +0 -1
  241. package/dist/lib/modules/marketing/services/spend-to-get-marketing.service.js +0 -99
  242. package/dist/lib/modules/marketing/services/spend-to-get-marketing.service.js.map +0 -1
  243. package/dist/lib/modules/marketing/services/spend-to-get-progress.repository.d.ts +0 -9
  244. package/dist/lib/modules/marketing/services/spend-to-get-progress.repository.d.ts.map +0 -1
  245. package/dist/lib/modules/marketing/services/spend-to-get-progress.repository.js +0 -69
  246. package/dist/lib/modules/marketing/services/spend-to-get-progress.repository.js.map +0 -1
  247. package/dist/lib/modules/marketing/services/spend-to-get-progress.service.d.ts +0 -31
  248. package/dist/lib/modules/marketing/services/spend-to-get-progress.service.d.ts.map +0 -1
  249. package/dist/lib/modules/marketing/services/spend-to-get-progress.service.js +0 -123
  250. package/dist/lib/modules/marketing/services/spend-to-get-progress.service.js.map +0 -1
  251. package/dist/lib/modules/marketing/validations/spend-to-get-marketing.validation.d.ts +0 -617
  252. package/dist/lib/modules/marketing/validations/spend-to-get-marketing.validation.d.ts.map +0 -1
  253. package/dist/lib/modules/marketing/validations/spend-to-get-marketing.validation.js +0 -119
  254. package/dist/lib/modules/marketing/validations/spend-to-get-marketing.validation.js.map +0 -1
  255. package/dist/lib/modules/spend-to-get-history/routers/index.d.ts +0 -2
  256. package/dist/lib/modules/spend-to-get-history/routers/index.d.ts.map +0 -1
  257. package/dist/lib/modules/spend-to-get-history/routers/index.js +0 -18
  258. package/dist/lib/modules/spend-to-get-history/routers/index.js.map +0 -1
  259. package/dist/lib/modules/spend-to-get-history/routers/spend-to-get-history.router.js +0 -62
  260. package/dist/lib/modules/spend-to-get-history/routers/spend-to-get-history.router.js.map +0 -1
  261. package/dist/lib/modules/spend-to-get-history/services/index.d.ts +0 -2
  262. package/dist/lib/modules/spend-to-get-history/services/index.d.ts.map +0 -1
  263. package/dist/lib/modules/spend-to-get-history/services/index.js +0 -18
  264. package/dist/lib/modules/spend-to-get-history/services/index.js.map +0 -1
  265. package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts +0 -24
  266. package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts.map +0 -1
  267. package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.js +0 -136
  268. package/dist/lib/modules/spend-to-get-history/services/spend-to-get-history.service.js.map +0 -1
  269. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.d.ts +0 -24
  270. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.d.ts.map +0 -1
  271. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.js +0 -97
  272. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.repository.js.map +0 -1
  273. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.d.ts +0 -271
  274. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.d.ts.map +0 -1
  275. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.js +0 -62
  276. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.router.js.map +0 -1
  277. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.d.ts +0 -24
  278. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.d.ts.map +0 -1
  279. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.js +0 -116
  280. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.service.js.map +0 -1
  281. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.d.ts +0 -232
  282. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.d.ts.map +0 -1
  283. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.js +0 -30
  284. package/dist/lib/modules/spend-to-get-history/spend-to-get-history.validation.js.map +0 -1
  285. package/dist/lib/modules/spend-to-get-history/validations/index.d.ts +0 -2
  286. package/dist/lib/modules/spend-to-get-history/validations/index.d.ts.map +0 -1
  287. package/dist/lib/modules/spend-to-get-history/validations/index.js +0 -18
  288. package/dist/lib/modules/spend-to-get-history/validations/index.js.map +0 -1
  289. package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.d.ts +0 -232
  290. package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.d.ts.map +0 -1
  291. package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.js +0 -30
  292. package/dist/lib/modules/spend-to-get-history/validations/spend-to-get-history.validation.js.map +0 -1
  293. package/dist/lib/modules/tournament/match/events/match-ended.consumer.d.ts +0 -2
  294. package/dist/lib/modules/tournament/match/events/match-ended.consumer.d.ts.map +0 -1
  295. package/dist/lib/modules/tournament/match/events/match-ended.consumer.js +0 -15
  296. package/dist/lib/modules/tournament/match/events/match-ended.consumer.js.map +0 -1
  297. package/dist/lib/modules/tournament/match/events/match-ended.event.d.ts +0 -14
  298. package/dist/lib/modules/tournament/match/events/match-ended.event.d.ts.map +0 -1
  299. package/dist/lib/modules/tournament/match/events/match-ended.event.js +0 -12
  300. package/dist/lib/modules/tournament/match/events/match-ended.event.js.map +0 -1
  301. package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts +0 -10
  302. package/dist/lib/modules/tournament/notification/jobs/notification.producer.d.ts.map +0 -1
  303. package/dist/lib/modules/tournament/notification/jobs/notification.producer.js +0 -23
  304. package/dist/lib/modules/tournament/notification/jobs/notification.producer.js.map +0 -1
  305. package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts +0 -9
  306. package/dist/lib/modules/tournament/notification/jobs/notification.worker.d.ts.map +0 -1
  307. package/dist/lib/modules/tournament/notification/jobs/notification.worker.js +0 -82
  308. package/dist/lib/modules/tournament/notification/jobs/notification.worker.js.map +0 -1
  309. package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts +0 -10
  310. package/dist/lib/modules/tournament/notification/notification.schedule.config.d.ts.map +0 -1
  311. package/dist/lib/modules/tournament/notification/notification.schedule.config.js +0 -15
  312. package/dist/lib/modules/tournament/notification/notification.schedule.config.js.map +0 -1
  313. package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts +0 -10
  314. package/dist/lib/modules/tournament/notification/notification.scheduler.service.d.ts.map +0 -1
  315. package/dist/lib/modules/tournament/notification/notification.scheduler.service.js +0 -73
  316. package/dist/lib/modules/tournament/notification/notification.scheduler.service.js.map +0 -1
  317. package/dist/types/event/events/marketing-product-sync.event.d.ts +0 -11
  318. package/dist/types/event/events/marketing-product-sync.event.d.ts.map +0 -1
  319. package/dist/types/events/event-initializations.d.ts +0 -2
  320. package/dist/types/events/event-initializations.d.ts.map +0 -1
  321. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts +0 -1
  322. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts.map +0 -1
  323. package/dist/types/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.d.ts +0 -13
  324. package/dist/types/modules/limited-time-offer/session/limited-time-offer-campaign-session.repository.d.ts.map +0 -1
  325. package/dist/types/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.d.ts +0 -21
  326. package/dist/types/modules/limited-time-offer/session/limited-time-offer-campaign-session.service.d.ts.map +0 -1
  327. package/dist/types/modules/marketing/services/marketing-conflict.repository.d.ts +0 -9
  328. package/dist/types/modules/marketing/services/marketing-conflict.repository.d.ts.map +0 -1
  329. package/dist/types/modules/marketing/services/marketing-conflict.service.d.ts +0 -41
  330. package/dist/types/modules/marketing/services/marketing-conflict.service.d.ts.map +0 -1
  331. package/dist/types/modules/marketing/services/spend-to-get-marketing.repository.d.ts +0 -14
  332. package/dist/types/modules/marketing/services/spend-to-get-marketing.repository.d.ts.map +0 -1
  333. package/dist/types/modules/marketing/services/spend-to-get-marketing.service.d.ts +0 -20
  334. package/dist/types/modules/marketing/services/spend-to-get-marketing.service.d.ts.map +0 -1
  335. package/dist/types/modules/marketing/services/spend-to-get-progress.repository.d.ts +0 -9
  336. package/dist/types/modules/marketing/services/spend-to-get-progress.repository.d.ts.map +0 -1
  337. package/dist/types/modules/marketing/services/spend-to-get-progress.service.d.ts +0 -37
  338. package/dist/types/modules/marketing/services/spend-to-get-progress.service.d.ts.map +0 -1
  339. package/dist/types/modules/marketing/validations/spend-to-get-marketing.validation.d.ts +0 -630
  340. package/dist/types/modules/marketing/validations/spend-to-get-marketing.validation.d.ts.map +0 -1
  341. package/dist/types/modules/spend-to-get-history/routers/index.d.ts +0 -2
  342. package/dist/types/modules/spend-to-get-history/routers/index.d.ts.map +0 -1
  343. package/dist/types/modules/spend-to-get-history/services/index.d.ts +0 -2
  344. package/dist/types/modules/spend-to-get-history/services/index.d.ts.map +0 -1
  345. package/dist/types/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts +0 -56
  346. package/dist/types/modules/spend-to-get-history/services/spend-to-get-history.service.d.ts.map +0 -1
  347. package/dist/types/modules/spend-to-get-history/spend-to-get-history.repository.d.ts +0 -24
  348. package/dist/types/modules/spend-to-get-history/spend-to-get-history.repository.d.ts.map +0 -1
  349. package/dist/types/modules/spend-to-get-history/spend-to-get-history.router.d.ts +0 -271
  350. package/dist/types/modules/spend-to-get-history/spend-to-get-history.router.d.ts.map +0 -1
  351. package/dist/types/modules/spend-to-get-history/spend-to-get-history.service.d.ts +0 -56
  352. package/dist/types/modules/spend-to-get-history/spend-to-get-history.service.d.ts.map +0 -1
  353. package/dist/types/modules/spend-to-get-history/spend-to-get-history.validation.d.ts +0 -241
  354. package/dist/types/modules/spend-to-get-history/spend-to-get-history.validation.d.ts.map +0 -1
  355. package/dist/types/modules/spend-to-get-history/validations/index.d.ts +0 -2
  356. package/dist/types/modules/spend-to-get-history/validations/index.d.ts.map +0 -1
  357. package/dist/types/modules/spend-to-get-history/validations/spend-to-get-history.validation.d.ts +0 -241
  358. package/dist/types/modules/spend-to-get-history/validations/spend-to-get-history.validation.d.ts.map +0 -1
  359. package/dist/types/modules/tournament/config/tournament-config.validation.d.ts +0 -201
  360. package/dist/types/modules/tournament/config/tournament-config.validation.d.ts.map +0 -1
  361. package/dist/types/modules/tournament/match/events/match-ended.consumer.d.ts +0 -2
  362. package/dist/types/modules/tournament/match/events/match-ended.consumer.d.ts.map +0 -1
  363. package/dist/types/modules/tournament/match/events/match-ended.event.d.ts +0 -14
  364. package/dist/types/modules/tournament/match/events/match-ended.event.d.ts.map +0 -1
  365. package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts +0 -10
  366. package/dist/types/modules/tournament/notification/jobs/notification.producer.d.ts.map +0 -1
  367. package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts +0 -9
  368. package/dist/types/modules/tournament/notification/jobs/notification.worker.d.ts.map +0 -1
  369. package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts +0 -10
  370. package/dist/types/modules/tournament/notification/notification.schedule.config.d.ts.map +0 -1
  371. package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts +0 -10
  372. package/dist/types/modules/tournament/notification/notification.scheduler.service.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"MarketingMetricsRepository.js","sourceRoot":"/","sources":["modules/marketing/patterns/repository/MarketingMetricsRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAC5C,8DAA2D;AAC3D,oDAA+E;AAC/E,sEAQmD;AAQnD,4DAA6F;AAC7F,qGAAgG;AAChG,4DAAkE;AAClE,4EAA0E;AAE1E,4DAAiE;AACjE,0CAAoD;AAG7C,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAC9B,KAAK,CAAiD;IACtD,UAAU,CAA2D;IAE7E;QACC,IAAI,CAAC,KAAK,GAAG,uBAAgE,CAAC;QAC9E,IAAI,CAAC,UAAU,GAAG,0BAA6E,CAAC;IACjG,CAAC;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EACxC,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,IAAI,EACT;gBACC,MAAM,EAAE,CAAC;aACT,CACD,CAAC;QACH,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;QAEpF,OAAO,IAAA,0BAAkB,EAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE;YAC3E,MAAM,EAAE,CAAC;SACT,CAAC,CAAC;IACJ,CAAC;CACD,CAAA;AAptBY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,gBAAO,GAAE;;GACG,0BAA0B,CAotBtC;AAEY,QAAA,0BAA0B,GAAG,gBAAS,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { dayjs } from '@lyxa.ai/core/dist/utilities/dayjs';\nimport { DocumentType, mongoose, ReturnModelType } from '@typegoose/typegoose';\nimport {\n\tFeaturedMarketing,\n\tLineItem,\n\tMarketing,\n\tMarketingModel,\n\tMarketing as Model,\n\tRegularOrder,\n\tRegularOrderModel,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {\n\tIncreaseDuringDiscountDTO,\n\tMarketingGraphInputDTO,\n\tMarketingMetricsDTO,\n\tMarketingOrdersGraphOutputDTO,\n} from '@modules/marketing/validations';\nimport { SoftDeleteModel } from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport { GraphType, OrderType, RegularOrderStatus } from '@lyxa.ai/core/dist/utilities/enum';\nimport { productMarketingService } from '@modules/marketing/services/product-marketing.service';\nimport { MarketingType } from '@lyxa.ai/core/dist/utilities/enum';\nimport { notFoundError } from '@lyxa.ai/core/dist/utilities/error-common';\nimport { Duration } from '@lyxa.ai/core/dist/libraries/mongo/models/shared/duration.model';\nimport { LyxaTimezone } from '@lyxa.ai/core/dist/utilities/time';\nimport { fillMissingPeriods } from '@utility/utils';\n\n@Service()\nexport class MarketingMetricsRepository {\n\tprivate model: typeof MarketingModel & SoftDeleteModel<Model>;\n\tprivate orderModel: typeof RegularOrderModel & SoftDeleteModel<RegularOrder>;\n\n\tconstructor() {\n\t\tthis.model = MarketingModel as typeof MarketingModel & SoftDeleteModel<Model>;\n\t\tthis.orderModel = RegularOrderModel as typeof RegularOrderModel & SoftDeleteModel<RegularOrder>;\n\t}\n\n\tpublic calculateMarketingSpendPerOrder(\n\t\torder: DocumentType<RegularOrder> & {\n\t\t\tlineItems: DocumentType<LineItem>[];\n\t\t\tmarketings: DocumentType<Marketing>[];\n\t\t}\n\t): Map<mongoose.Types.ObjectId, number> {\n\t\tconst spendMap = new Map<mongoose.Types.ObjectId, number>();\n\n\t\tconst marketingOwnerMap = new Map<string, 'COMPANY' | 'SHOP'>();\n\n\t\t// Build owner map\n\t\tfor (const marketing of order.marketings ?? []) {\n\t\t\tmarketingOwnerMap.set(marketing._id.toString(), marketing.isAppliedByCompany ? 'COMPANY' : 'SHOP');\n\t\t}\n\n\t\tconst addSpend = (marketingId: mongoose.Types.ObjectId, amount: number) => {\n\t\t\tif (!amount || amount <= 0) return;\n\t\t\tspendMap.set(marketingId, (spendMap.get(marketingId) ?? 0) + amount);\n\t\t};\n\n\t\tconst getRelevantAmount = (\n\t\t\tmarketingId: mongoose.Types.ObjectId,\n\t\t\tcompanyAmount: number,\n\t\t\tshopAmount: number\n\t\t) => {\n\t\t\tconst owner = marketingOwnerMap.get(marketingId.toString());\n\t\t\treturn owner === 'COMPANY' ? companyAmount : shopAmount;\n\t\t};\n\n\t\t/**\n\t\t * ITEM-BASED\n\t\t */\n\t\tfor (const lineItem of order.lineItems ?? []) {\n\t\t\tfor (const marketingId of lineItem.marketings ?? []) {\n\t\t\t\tconst snap = lineItem.calculationSnap ?? {};\n\n\t\t\t\taddSpend(\n\t\t\t\t\tmarketingId._id,\n\t\t\t\t\tgetRelevantAmount(\n\t\t\t\t\t\tmarketingId._id,\n\t\t\t\t\t\t(Number(snap.itemDiscountByCompany) || 0) + (Number(snap.b1g1DiscountByCompany) || 0),\n\t\t\t\t\t\t(Number(snap.itemDiscountByShop) || 0) + (Number(snap.b1g1DiscountByShop) || 0)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * FREE DELIVERY\n\t\t */\n\t\tif (order.adjustedFinance?.freeDelivery) {\n\t\t\tfor (const marketingId of order.marketings ?? []) {\n\t\t\t\taddSpend(\n\t\t\t\t\tmarketingId._id,\n\t\t\t\t\tgetRelevantAmount(\n\t\t\t\t\t\tmarketingId._id,\n\t\t\t\t\t\torder.adjustedFinance.freeDelivery.companyCut ?? 0,\n\t\t\t\t\t\torder.adjustedFinance.freeDelivery.shopCut ?? 0\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * PUNCH MARKETING\n\t\t */\n\t\tif (order.adjustedFinance?.pricing?.punchMarketingDiscount) {\n\t\t\tfor (const marketingId of order.marketings ?? []) {\n\t\t\t\taddSpend(marketingId._id, order.adjustedFinance.pricing.punchMarketingDiscount);\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * SPEND TO GET\n\t\t */\n\t\tif (order.adjustedFinance?.spendToGet) {\n\t\t\tfor (const marketingId of order.marketings ?? []) {\n\t\t\t\taddSpend(\n\t\t\t\t\tmarketingId._id,\n\t\t\t\t\tgetRelevantAmount(\n\t\t\t\t\t\tmarketingId._id,\n\t\t\t\t\t\torder.adjustedFinance.spendToGet.companyCut ?? 0,\n\t\t\t\t\t\torder.adjustedFinance.spendToGet.shopCut ?? 0\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn spendMap;\n\t}\n\n\tpublic async calculateMarketingSpent(\n\t\tmarketingId: mongoose.Types.ObjectId,\n\t\tduration?: Duration\n\t): Promise<{ amount: number; marketingType: MarketingType }> {\n\t\tconst marketing = await this.model.findById(marketingId).lean();\n\n\t\tif (!marketing) {\n\t\t\tnotFoundError('Marketing not found');\n\t\t}\n\n\t\tconst calculators: Record<MarketingType, () => Promise<number>> = {\n\t\t\t[MarketingType.FREE_DELIVERY]: () => this.calculateFreeDeliverySpent(marketingId, duration),\n\n\t\t\t[MarketingType.DISCOUNT]: () =>\n\t\t\t\tthis.calculateItemBasedSpent(marketingId, marketing.isAppliedByCompany, duration),\n\n\t\t\t[MarketingType.BUY1GET1]: () =>\n\t\t\t\tthis.calculateItemBasedSpent(marketingId, marketing.isAppliedByCompany, duration),\n\n\t\t\t[MarketingType.PUNCH_MARKETING]: () => this.calculatePunchMarketingSpent(marketingId, duration),\n\t\t\t[MarketingType.SPEND_TO_GET]: () => this.calculateSpendToGetSpent(marketingId, duration),\n\t\t\t[MarketingType.FEATURED]: function (): Promise<number> {\n\t\t\t\treturn Promise.resolve((marketing as DocumentType<FeaturedMarketing>).amount || 0);\n\t\t\t},\n\t\t};\n\n\t\tconst amount = calculators[marketing.marketingType] ? await calculators[marketing.marketingType]() : 0;\n\n\t\treturn {\n\t\t\tamount,\n\t\t\tmarketingType: marketing.marketingType,\n\t\t};\n\t}\n\n\tprivate async calculateItemBasedSpent(\n\t\tmarketingId: mongoose.Types.ObjectId,\n\t\tisAppliedByAdmin: boolean,\n\t\tduration?: Duration\n\t): Promise<number> {\n\t\tconst addBlock = isAppliedByAdmin\n\t\t\t? [\n\t\t\t\t\t{ $ifNull: ['$lineItems.calculationSnap.itemDiscountByCompany', 0] },\n\t\t\t\t\t{ $ifNull: ['$lineItems.calculationSnap.b1g1DiscountByCompany', 0] },\n\t\t\t\t]\n\t\t\t: [\n\t\t\t\t\t{ $ifNull: ['$lineItems.calculationSnap.itemDiscountByShop', 0] },\n\t\t\t\t\t{ $ifNull: ['$lineItems.calculationSnap.b1g1DiscountByShop', 0] },\n\t\t\t\t];\n\n\t\tconst pipeline: mongoose.PipelineStage[] = [\n\t\t\tthis.buildBaseMatch(marketingId, duration),\n\n\t\t\t{\n\t\t\t\t$lookup: {\n\t\t\t\t\tfrom: 'lineItems',\n\t\t\t\t\tlocalField: 'cart',\n\t\t\t\t\tforeignField: 'cart',\n\t\t\t\t\tas: 'lineItems',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{ $unwind: '$lineItems' },\n\n\t\t\t{\n\t\t\t\t$group: {\n\t\t\t\t\t_id: null,\n\t\t\t\t\ttotalSpent: {\n\t\t\t\t\t\t$sum: {\n\t\t\t\t\t\t\t$add: addBlock,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\n\t\treturn this.runAggregateAndGetTotal(pipeline, 'totalSpent');\n\t}\n\n\tprivate async calculateFreeDeliverySpent(\n\t\tmarketingId: mongoose.Types.ObjectId,\n\t\tduration?: Duration\n\t): Promise<number> {\n\t\tconst pipeline: mongoose.PipelineStage[] = [\n\t\t\tthis.buildBaseMatch(marketingId, duration),\n\n\t\t\t{\n\t\t\t\t$group: {\n\t\t\t\t\t_id: null,\n\t\t\t\t\ttotalSpent: {\n\t\t\t\t\t\t$sum: {\n\t\t\t\t\t\t\t$add: [\n\t\t\t\t\t\t\t\t{ $ifNull: ['$adjustedFinance.freeDelivery.companyCut', 0] },\n\t\t\t\t\t\t\t\t{ $ifNull: ['$adjustedFinance.freeDelivery.shopCut', 0] },\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\n\t\treturn this.runAggregateAndGetTotal(pipeline, 'totalSpent');\n\t}\n\n\tprivate async calculateSpendToGetSpent(\n\t\tmarketingId: mongoose.Types.ObjectId,\n\t\tduration?: Duration\n\t): Promise<number> {\n\t\tconst pipeline: mongoose.PipelineStage[] = [\n\t\t\tthis.buildBaseMatch(marketingId, duration),\n\n\t\t\t{\n\t\t\t\t$group: {\n\t\t\t\t\t_id: null,\n\t\t\t\t\ttotalSpent: {\n\t\t\t\t\t\t$sum: {\n\t\t\t\t\t\t\t$add: [\n\t\t\t\t\t\t\t\t{ $ifNull: ['$adjustedFinance.spendToGet.companyCut', 0] },\n\t\t\t\t\t\t\t\t{ $ifNull: ['$adjustedFinance.spendToGet.shopCut', 0] },\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\n\t\treturn this.runAggregateAndGetTotal(pipeline, 'totalSpent');\n\t}\n\n\tprivate async calculatePunchMarketingSpent(\n\t\tmarketingId: mongoose.Types.ObjectId,\n\t\tduration?: Duration\n\t): Promise<number> {\n\t\tconst pipeline: mongoose.PipelineStage[] = [\n\t\t\tthis.buildBaseMatch(marketingId, duration),\n\n\t\t\t{\n\t\t\t\t$group: {\n\t\t\t\t\t_id: null,\n\t\t\t\t\ttotalSpent: {\n\t\t\t\t\t\t$sum: {\n\t\t\t\t\t\t\t$ifNull: ['$adjustedFinance.pricing.punchMarketingDiscount', 0],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\n\t\treturn this.runAggregateAndGetTotal(pipeline, 'totalSpent');\n\t}\n\n\tprivate buildBaseMatch(\n\t\tmarketingId: mongoose.Types.ObjectId,\n\t\tduration?: Duration\n\t): mongoose.PipelineStage.Match {\n\t\treturn {\n\t\t\t$match: {\n\t\t\t\tmarketings: marketingId,\n\t\t\t\tstatus: { $ne: RegularOrderStatus.CANCELLED },\n\t\t\t\t...(duration && {\n\t\t\t\t\tprocessedAt: {\n\t\t\t\t\t\t$gte: duration.start,\n\t\t\t\t\t\t$lte: duration.end,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate async runAggregateAndGetTotal(pipeline: mongoose.PipelineStage[], field: string): Promise<number> {\n\t\tconst [result] = await this.orderModel.aggregate(pipeline);\n\t\treturn result?.[field] ?? 0;\n\t}\n\n\tpublic async getMetrics(marketingId: mongoose.Types.ObjectId): Promise<MarketingMetricsDTO> {\n\t\tconst marketing = await this.model.findById(marketingId).lean();\n\n\t\tif (!marketing) {\n\t\t\tnotFoundError('Marketing not found');\n\t\t}\n\n\t\t//TODO: fix current end and previous start\n\n\t\tconst currentDuration = { start: marketing.duration.start, end: dayjs().toDate() };\n\t\tconst previousDuration = {\n\t\t\tstart: dayjs(marketing.duration.start).subtract(dayjs().diff(marketing.duration.start)).toDate(),\n\t\t\tend: marketing.duration.start,\n\t\t};\n\n\t\tlet metrics: MarketingMetricsDTO = {};\n\n\t\tif ([MarketingType.DISCOUNT, MarketingType.BUY1GET1].includes(marketing.marketingType)) {\n\t\t\tmetrics.numberOfItems = await this.getMarketingItemCount(marketingId);\n\t\t}\n\n\t\tmetrics.orderIncreaseWithDiscount = await this.calculateOrderIncreaseWithDiscount(\n\t\t\tmarketingId,\n\t\t\tmarketing.shop._id,\n\t\t\tcurrentDuration,\n\t\t\tpreviousDuration\n\t\t);\n\t\tmetrics.customerIncreaseWithDiscount = await this.calculateCustomerIncreaseWithDiscount(\n\t\t\tmarketingId,\n\t\t\tmarketing.shop._id,\n\t\t\tcurrentDuration,\n\t\t\tpreviousDuration\n\t\t);\n\t\tmetrics.totalRedemptions = await this.orderModel.countDocuments({\n\t\t\tmarketings: marketingId,\n\t\t\tstatus: { $ne: RegularOrderStatus.CANCELLED },\n\t\t});\n\n\t\treturn metrics;\n\t}\n\n\tprivate async getMarketingItemCount(marketingId: mongoose.Types.ObjectId): Promise<number> {\n\t\tconst result = await productMarketingService.countDocuments({ marketing: marketingId });\n\t\treturn result ?? 0;\n\t}\n\n\tprivate async calculateOrderIncreaseWithDiscount(\n\t\tmarketingId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tcurrentDuration: Duration,\n\t\tpreviousDuration: Duration\n\t): Promise<IncreaseDuringDiscountDTO> {\n\t\tconst [currentOrders, previousOrders] = await Promise.all([\n\t\t\tthis.orderModel.countDocuments({\n\t\t\t\tcreatedAt: {\n\t\t\t\t\t$gte: currentDuration.start,\n\t\t\t\t\t$lte: currentDuration.end,\n\t\t\t\t},\n\t\t\t\tmarketings: marketingId, // marketing must be applied\n\t\t\t\tshop: shopId,\n\t\t\t}),\n\t\t\tthis.orderModel.countDocuments({\n\t\t\t\tcreatedAt: {\n\t\t\t\t\t$gte: previousDuration.start,\n\t\t\t\t\t$lte: previousDuration.end,\n\t\t\t\t},\n\t\t\t\tshop: shopId,\n\t\t\t}),\n\t\t]);\n\n\t\treturn this.calculateIncrease(currentOrders, previousOrders);\n\t}\n\n\tprivate async calculateCustomerIncreaseWithDiscount(\n\t\tmarketingId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tcurrentDuration: Duration,\n\t\tpreviousDuration: Duration\n\t): Promise<IncreaseDuringDiscountDTO> {\n\t\tconst [currentNewCustomers, previousNewCustomers] = await Promise.all([\n\t\t\tthis.getNewCustomersForShop(shopId, currentDuration, { marketings: marketingId }),\n\t\t\tthis.getNewCustomersForShop(shopId, previousDuration),\n\t\t]);\n\n\t\treturn this.calculateIncrease(currentNewCustomers, previousNewCustomers);\n\t}\n\n\tprivate calculateIncrease(current: number, previous: number): IncreaseDuringDiscountDTO {\n\t\tconst count = current - previous;\n\n\t\tconst percentageIncrease = previous === 0 ? (current > 0 ? 100 : 0) : (count / previous) * 100;\n\n\t\treturn {\n\t\t\tcount,\n\t\t\tpercentageIncrease,\n\t\t};\n\t}\n\n\tprivate async getNewCustomersForShop(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tduration: Duration,\n\t\textraMatch: Record<string, any> = {}\n\t): Promise<number> {\n\t\t// Customers who ordered during the period\n\t\tconst customersInPeriod = await this.orderModel.distinct('user', {\n\t\t\tcreatedAt: {\n\t\t\t\t$gte: duration.start,\n\t\t\t\t$lte: duration.end,\n\t\t\t},\n\t\t\tshop: shopId,\n\t\t\t...extraMatch,\n\t\t});\n\n\t\tif (customersInPeriod.length === 0) {\n\t\t\treturn 0;\n\t\t}\n\n\t\t// Customers who had ordered from this shop BEFORE the period\n\t\tconst existingCustomers = await this.orderModel.distinct('user', {\n\t\t\tshop: shopId,\n\t\t\tcreatedAt: { $lt: duration.start },\n\t\t\tuser: { $in: customersInPeriod },\n\t\t});\n\n\t\t// New customers = in period − existing\n\t\treturn customersInPeriod.length - existingCustomers.length;\n\t}\n\n\tpublic async getOrdersGraph(data: MarketingGraphInputDTO): Promise<MarketingOrdersGraphOutputDTO> {\n\t\tconst dateFormat = data.type === GraphType.MONTHLY ? '%Y-%m' : '%Y-%m-%d';\n\n\t\tconst pipeline: mongoose.PipelineStage[] = [\n\t\t\t// Filter only delivered orders within the given date range\n\t\t\tthis.buildBaseMatch(new mongoose.Types.ObjectId(data.marketingId), {\n\t\t\t\tstart: data.startDate,\n\t\t\t\tend: data.endDate,\n\t\t\t}),\n\n\t\t\t// Extract formatted date from 'processedAt' for grouping\n\t\t\t{\n\t\t\t\t$project: {\n\t\t\t\t\tdate: {\n\t\t\t\t\t\t$dateToString: {\n\t\t\t\t\t\t\tformat: dateFormat,\n\t\t\t\t\t\t\tdate: '$processedAt',\n\t\t\t\t\t\t\ttimezone: LyxaTimezone,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\n\t\t\t// Group by formatted date and count orders\n\t\t\t{\n\t\t\t\t$group: {\n\t\t\t\t\t_id: '$date',\n\t\t\t\t\torders: { $sum: 1 },\n\t\t\t\t},\n\t\t\t},\n\n\t\t\t// Sort results chronologically\n\t\t\t{\n\t\t\t\t$sort: { _id: 1 },\n\t\t\t},\n\n\t\t\t// Format the response to match output DTO structure\n\t\t\t{\n\t\t\t\t$project: {\n\t\t\t\t\t_id: 0,\n\t\t\t\t\tdate: '$_id',\n\t\t\t\t\torders: 1,\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\n\t\t// Execute aggregation pipeline\n\t\tconst results = await this.orderModel.aggregate(pipeline).allowDiskUse(true).exec();\n\n\t\tconst graphData = fillMissingPeriods(results, data.startDate, data.endDate, data.type, {\n\t\t\torders: 0,\n\t\t});\n\n\t\treturn graphData;\n\t}\n\n\tpublic async getCustomersGraph(data: MarketingGraphInputDTO): Promise<{ date: string; users: number }[]> {\n\t\t// 1️⃣ Get shopId from marketing\n\t\tconst marketing = await this.model.findById(data.marketingId).select('shop').lean();\n\n\t\tif (!marketing) {\n\t\t\tnotFoundError('Marketing not found');\n\t\t}\n\n\t\tconst shopId = marketing.shop._id;\n\n\t\t// 2️⃣ Fetch users who ordered from this shop BEFORE the start date\n\t\tconst oldUsers = await this.orderModel.distinct('user', {\n\t\t\tshop: shopId,\n\t\t\tstatus: RegularOrderStatus.DELIVERED,\n\t\t\tprocessedAt: { $lt: data.startDate },\n\t\t});\n\n\t\tconst dateFormat = data.type === GraphType.MONTHLY ? '%Y-%m' : '%Y-%m-%d';\n\n\t\t// 3️⃣ Aggregation pipeline\n\t\tconst pipeline: mongoose.PipelineStage[] = [\n\t\t\t// Orders during the period with this marketing\n\t\t\t{\n\t\t\t\t$match: {\n\t\t\t\t\torderType: OrderType.REGULAR,\n\t\t\t\t\tstatus: RegularOrderStatus.DELIVERED,\n\t\t\t\t\tshop: shopId,\n\t\t\t\t\tmarketings: new mongoose.Types.ObjectId(data.marketingId),\n\t\t\t\t\tprocessedAt: { $gte: data.startDate, $lte: data.endDate },\n\t\t\t\t\tuser: { $nin: oldUsers }, // 🚫 exclude old users\n\t\t\t\t},\n\t\t\t},\n\n\t\t\t// Sort so earliest order per user comes first\n\t\t\t{ $sort: { processedAt: 1 } },\n\n\t\t\t// First order per user (new users only)\n\t\t\t{\n\t\t\t\t$group: {\n\t\t\t\t\t_id: '$user',\n\t\t\t\t\tfirstOrderDate: { $first: '$processedAt' },\n\t\t\t\t},\n\t\t\t},\n\n\t\t\t// Format date\n\t\t\t{\n\t\t\t\t$project: {\n\t\t\t\t\tdate: {\n\t\t\t\t\t\t$dateToString: {\n\t\t\t\t\t\t\tformat: dateFormat,\n\t\t\t\t\t\t\tdate: '$firstOrderDate',\n\t\t\t\t\t\t\ttimezone: LyxaTimezone,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\n\t\t\t// Group by date\n\t\t\t{\n\t\t\t\t$group: {\n\t\t\t\t\t_id: '$date',\n\t\t\t\t\tusers: { $sum: 1 },\n\t\t\t\t},\n\t\t\t},\n\n\t\t\t// Sort chronologically\n\t\t\t{ $sort: { _id: 1 } },\n\n\t\t\t// Shape response\n\t\t\t{\n\t\t\t\t$project: {\n\t\t\t\t\t_id: 0,\n\t\t\t\t\tdate: '$_id',\n\t\t\t\t\tusers: 1,\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\n\t\tconst results = await this.orderModel.aggregate(pipeline).allowDiskUse(true).exec();\n\n\t\t// 4️⃣ Fill missing periods\n\t\treturn fillMissingPeriods(results, data.startDate, data.endDate, data.type, {\n\t\t\tusers: 0,\n\t\t});\n\t}\n\n\tpublic async getAmountSpentGraph(\n\t\tdata: MarketingGraphInputDTO\n\t): Promise<{ date: string; amount: number }[]> {\n\t\tconst marketing = await this.model.findById(data.marketingId).lean();\n\n\t\tif (!marketing) {\n\t\t\tnotFoundError('Marketing not found');\n\t\t}\n\n\t\tconst marketingId = new mongoose.Types.ObjectId(data.marketingId);\n\t\tconst dateFormat = data.type === GraphType.MONTHLY ? '%Y-%m' : '%Y-%m-%d';\n\n\t\tlet pipeline: mongoose.PipelineStage[] | null = null;\n\n\t\t/**\n\t\t * ITEM-BASED (DISCOUNT / BUY1GET1)\n\t\t */\n\t\tif ([MarketingType.DISCOUNT, MarketingType.BUY1GET1].includes(marketing.marketingType)) {\n\t\t\tpipeline = [\n\t\t\t\tthis.buildBaseMatch(marketingId, {\n\t\t\t\t\tstart: data.startDate,\n\t\t\t\t\tend: data.endDate,\n\t\t\t\t}),\n\t\t\t\t{\n\t\t\t\t\t$lookup: {\n\t\t\t\t\t\tfrom: 'lineItems',\n\t\t\t\t\t\tlocalField: 'cart',\n\t\t\t\t\t\tforeignField: 'cart',\n\t\t\t\t\t\tas: 'lineItems',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{ $unwind: '$lineItems' },\n\t\t\t\t{\n\t\t\t\t\t$match: {\n\t\t\t\t\t\t'lineItems.marketings': marketingId,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t$project: {\n\t\t\t\t\t\tdate: {\n\t\t\t\t\t\t\t$dateToString: {\n\t\t\t\t\t\t\t\tformat: dateFormat,\n\t\t\t\t\t\t\t\tdate: '$processedAt',\n\t\t\t\t\t\t\t\ttimezone: LyxaTimezone,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tamount: {\n\t\t\t\t\t\t\t$add: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\tmarketing.isAppliedByCompany,\n\t\t\t\t\t\t\t\t\t\t{ $ifNull: ['$lineItems.calculationSnap.itemDiscountByCompany', 0] },\n\t\t\t\t\t\t\t\t\t\t{ $ifNull: ['$lineItems.calculationSnap.itemDiscountByShop', 0] },\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\tmarketing.isAppliedByCompany,\n\t\t\t\t\t\t\t\t\t\t{ $ifNull: ['$lineItems.calculationSnap.b1g1DiscountByCompany', 0] },\n\t\t\t\t\t\t\t\t\t\t{ $ifNull: ['$lineItems.calculationSnap.b1g1DiscountByShop', 0] },\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t$group: {\n\t\t\t\t\t\t_id: '$date',\n\t\t\t\t\t\tamount: { $sum: '$amount' },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{ $sort: { _id: 1 } },\n\t\t\t\t{\n\t\t\t\t\t$project: {\n\t\t\t\t\t\t_id: 0,\n\t\t\t\t\t\tdate: '$_id',\n\t\t\t\t\t\tamount: 1,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t];\n\t\t} else if (marketing.marketingType === MarketingType.FREE_DELIVERY) {\n\t\t\t/**\n\t\t\t * FREE DELIVERY\n\t\t\t */\n\t\t\tpipeline = [\n\t\t\t\tthis.buildBaseMatch(marketingId, {\n\t\t\t\t\tstart: data.startDate,\n\t\t\t\t\tend: data.endDate,\n\t\t\t\t}),\n\t\t\t\t{\n\t\t\t\t\t$project: {\n\t\t\t\t\t\tdate: {\n\t\t\t\t\t\t\t$dateToString: {\n\t\t\t\t\t\t\t\tformat: dateFormat,\n\t\t\t\t\t\t\t\tdate: '$processedAt',\n\t\t\t\t\t\t\t\ttimezone: LyxaTimezone,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tamount: {\n\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\tmarketing.isAppliedByCompany,\n\t\t\t\t\t\t\t\t{ $ifNull: ['$adjustedFinance.freeDelivery.companyCut', 0] },\n\t\t\t\t\t\t\t\t{ $ifNull: ['$adjustedFinance.freeDelivery.shopCut', 0] },\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t$group: {\n\t\t\t\t\t\t_id: '$date',\n\t\t\t\t\t\tamount: { $sum: '$amount' },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{ $sort: { _id: 1 } },\n\t\t\t\t{\n\t\t\t\t\t$project: {\n\t\t\t\t\t\t_id: 0,\n\t\t\t\t\t\tdate: '$_id',\n\t\t\t\t\t\tamount: 1,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t];\n\t\t} else if (marketing.marketingType === MarketingType.PUNCH_MARKETING) {\n\t\t\t/**\n\t\t\t * PUNCH MARKETING\n\t\t\t */\n\t\t\tpipeline = [\n\t\t\t\tthis.buildBaseMatch(marketingId, {\n\t\t\t\t\tstart: data.startDate,\n\t\t\t\t\tend: data.endDate,\n\t\t\t\t}),\n\t\t\t\t{\n\t\t\t\t\t$project: {\n\t\t\t\t\t\tdate: {\n\t\t\t\t\t\t\t$dateToString: {\n\t\t\t\t\t\t\t\tformat: dateFormat,\n\t\t\t\t\t\t\t\tdate: '$processedAt',\n\t\t\t\t\t\t\t\ttimezone: LyxaTimezone,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tamount: {\n\t\t\t\t\t\t\t$ifNull: ['$adjustedFinance.pricing.punchMarketingDiscount', 0],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t$group: {\n\t\t\t\t\t\t_id: '$date',\n\t\t\t\t\t\tamount: { $sum: '$amount' },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{ $sort: { _id: 1 } },\n\t\t\t\t{\n\t\t\t\t\t$project: {\n\t\t\t\t\t\t_id: 0,\n\t\t\t\t\t\tdate: '$_id',\n\t\t\t\t\t\tamount: 1,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\t// If marketing type doesn't produce spend graph → return empty graph\n\t\tif (!pipeline) {\n\t\t\treturn fillMissingPeriods(\n\t\t\t\t[] as { date: string; amount: number }[],\n\t\t\t\tdata.startDate,\n\t\t\t\tdata.endDate,\n\t\t\t\tdata.type,\n\t\t\t\t{\n\t\t\t\t\tamount: 0,\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tconst results = await this.orderModel.aggregate(pipeline).allowDiskUse(true).exec();\n\n\t\treturn fillMissingPeriods(results, data.startDate, data.endDate, data.type, {\n\t\t\tamount: 0,\n\t\t});\n\t}\n}\n\nexport const marketingMetricsRepository = Container.get(MarketingMetricsRepository);\n"]}
1
+ {"version":3,"file":"MarketingMetricsRepository.js","sourceRoot":"/","sources":["modules/marketing/patterns/repository/MarketingMetricsRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAC5C,8DAA2D;AAC3D,oDAA+E;AAC/E,sEAQmD;AAQnD,4DAA6F;AAC7F,qGAAgG;AAChG,4DAAkE;AAClE,4EAA0E;AAE1E,4DAAiE;AACjE,0CAAoD;AAG7C,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAC9B,KAAK,CAAiD;IACtD,UAAU,CAA2D;IAE7E;QACC,IAAI,CAAC,KAAK,GAAG,uBAAgE,CAAC;QAC9E,IAAI,CAAC,UAAU,GAAG,0BAA6E,CAAC;IACjG,CAAC;IAEM,+BAA+B,CACrC,KAGC;QAED,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAmC,CAAC;QAE5D,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAA8B,CAAC;QAGhE,KAAK,MAAM,SAAS,IAAI,KAAK,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC;YAChD,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,SAAS,CAAC,kBAAkB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACpG,CAAC;QAED,MAAM,QAAQ,GAAG,CAAC,WAAoC,EAAE,MAAc,EAAE,EAAE;YACzE,IAAI,CAAC,MAAM,IAAI,MAAM,IAAI,CAAC;gBAAE,OAAO;YACnC,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;QACtE,CAAC,CAAC;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AAS,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { dayjs } from '@lyxa.ai/core/dist/utilities/dayjs';\nimport { DocumentType, mongoose, ReturnModelType } from '@typegoose/typegoose';\nimport {\n\tFeaturedMarketing,\n\tLineItem,\n\tMarketing,\n\tMarketingModel,\n\tMarketing as Model,\n\tRegularOrder,\n\tRegularOrderModel,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {\n\tIncreaseDuringDiscountDTO,\n\tMarketingGraphInputDTO,\n\tMarketingMetricsDTO,\n\tMarketingOrdersGraphOutputDTO,\n} from '@modules/marketing/validations';\nimport { SoftDeleteModel } from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport { GraphType, OrderType, RegularOrderStatus } from '@lyxa.ai/core/dist/utilities/enum';\nimport { productMarketingService } from '@modules/marketing/services/product-marketing.service';\nimport { MarketingType } from '@lyxa.ai/core/dist/utilities/enum';\nimport { notFoundError } from '@lyxa.ai/core/dist/utilities/error-common';\nimport { Duration } from '@lyxa.ai/core/dist/libraries/mongo/models/shared/duration.model';\nimport { LyxaTimezone } from '@lyxa.ai/core/dist/utilities/time';\nimport { fillMissingPeriods } from '@utility/utils';\n\n@Service()\nexport class MarketingMetricsRepository {\n\tprivate model: typeof MarketingModel & SoftDeleteModel<Model>;\n\tprivate orderModel: typeof RegularOrderModel & SoftDeleteModel<RegularOrder>;\n\n\tconstructor() {\n\t\tthis.model = MarketingModel as typeof MarketingModel & SoftDeleteModel<Model>;\n\t\tthis.orderModel = RegularOrderModel as typeof RegularOrderModel & SoftDeleteModel<RegularOrder>;\n\t}\n\n\tpublic calculateMarketingSpendPerOrder(\n\t\torder: DocumentType<RegularOrder> & {\n\t\t\tlineItems: DocumentType<LineItem>[];\n\t\t\tmarketings: DocumentType<Marketing>[];\n\t\t}\n\t): Map<mongoose.Types.ObjectId, number> {\n\t\tconst spendMap = new Map<mongoose.Types.ObjectId, number>();\n\n\t\tconst marketingOwnerMap = new Map<string, 'COMPANY' | 'SHOP'>();\n\n\t\t// Build owner map\n\t\tfor (const marketing of order.marketings ?? []) {\n\t\t\tmarketingOwnerMap.set(marketing._id.toString(), marketing.isAppliedByCompany ? 'COMPANY' : 'SHOP');\n\t\t}\n\n\t\tconst addSpend = (marketingId: mongoose.Types.ObjectId, amount: number) => {\n\t\t\tif (!amount || amount <= 0) return;\n\t\t\tspendMap.set(marketingId, (spendMap.get(marketingId) ?? 0) + amount);\n\t\t};\n\n\t\tconst getRelevantAmount = (\n\t\t\tmarketingId: mongoose.Types.ObjectId,\n\t\t\tcompanyAmount: number,\n\t\t\tshopAmount: number\n\t\t) => {\n\t\t\tconst owner = marketingOwnerMap.get(marketingId.toString());\n\t\t\treturn owner === 'COMPANY' ? companyAmount : shopAmount;\n\t\t};\n\n\t\t/**\n\t\t * ITEM-BASED\n\t\t */\n\t\tfor (const lineItem of order.lineItems ?? []) {\n\t\t\tfor (const marketingId of lineItem.marketings ?? []) {\n\t\t\t\tconst snap = lineItem.calculationSnap ?? {};\n\n\t\t\t\taddSpend(\n\t\t\t\t\tmarketingId._id,\n\t\t\t\t\tgetRelevantAmount(\n\t\t\t\t\t\tmarketingId._id,\n\t\t\t\t\t\t(Number(snap.itemDiscountByCompany) || 0) + (Number(snap.b1g1DiscountByCompany) || 0),\n\t\t\t\t\t\t(Number(snap.itemDiscountByShop) || 0) + (Number(snap.b1g1DiscountByShop) || 0)\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * FREE DELIVERY\n\t\t */\n\t\tif (order.adjustedFinance?.freeDelivery) {\n\t\t\tfor (const marketingId of order.marketings ?? []) {\n\t\t\t\taddSpend(\n\t\t\t\t\tmarketingId._id,\n\t\t\t\t\tgetRelevantAmount(\n\t\t\t\t\t\tmarketingId._id,\n\t\t\t\t\t\torder.adjustedFinance.freeDelivery.companyCut ?? 0,\n\t\t\t\t\t\torder.adjustedFinance.freeDelivery.shopCut ?? 0\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * PUNCH MARKETING\n\t\t */\n\t\tif (order.adjustedFinance?.pricing?.punchMarketingDiscount) {\n\t\t\tfor (const marketingId of order.marketings ?? []) {\n\t\t\t\taddSpend(marketingId._id, order.adjustedFinance.pricing.punchMarketingDiscount);\n\t\t\t}\n\t\t}\n\n\t\treturn spendMap;\n\t}\n\n\tpublic async calculateMarketingSpent(\n\t\tmarketingId: mongoose.Types.ObjectId,\n\t\tduration?: Duration\n\t): Promise<{ amount: number; marketingType: MarketingType }> {\n\t\tconst marketing = await this.model.findById(marketingId).lean();\n\n\t\tif (!marketing) {\n\t\t\tnotFoundError('Marketing not found');\n\t\t}\n\n\t\tconst calculators: Record<MarketingType, () => Promise<number>> = {\n\t\t\t[MarketingType.FREE_DELIVERY]: () => this.calculateFreeDeliverySpent(marketingId, duration),\n\n\t\t\t[MarketingType.DISCOUNT]: () =>\n\t\t\t\tthis.calculateItemBasedSpent(marketingId, marketing.isAppliedByCompany, duration),\n\n\t\t\t[MarketingType.BUY1GET1]: () =>\n\t\t\t\tthis.calculateItemBasedSpent(marketingId, marketing.isAppliedByCompany, duration),\n\n\t\t\t[MarketingType.PUNCH_MARKETING]: () => this.calculatePunchMarketingSpent(marketingId, duration),\n\t\t\t[MarketingType.FEATURED]: function (): Promise<number> {\n\t\t\t\treturn Promise.resolve((marketing as DocumentType<FeaturedMarketing>).amount || 0);\n\t\t\t},\n\t\t};\n\n\t\tconst amount = calculators[marketing.marketingType] ? await calculators[marketing.marketingType]() : 0;\n\n\t\treturn {\n\t\t\tamount,\n\t\t\tmarketingType: marketing.marketingType,\n\t\t};\n\t}\n\n\tprivate async calculateItemBasedSpent(\n\t\tmarketingId: mongoose.Types.ObjectId,\n\t\tisAppliedByAdmin: boolean,\n\t\tduration?: Duration\n\t): Promise<number> {\n\t\tconst addBlock = isAppliedByAdmin\n\t\t\t? [\n\t\t\t\t\t{ $ifNull: ['$lineItems.calculationSnap.itemDiscountByCompany', 0] },\n\t\t\t\t\t{ $ifNull: ['$lineItems.calculationSnap.b1g1DiscountByCompany', 0] },\n\t\t\t\t]\n\t\t\t: [\n\t\t\t\t\t{ $ifNull: ['$lineItems.calculationSnap.itemDiscountByShop', 0] },\n\t\t\t\t\t{ $ifNull: ['$lineItems.calculationSnap.b1g1DiscountByShop', 0] },\n\t\t\t\t];\n\n\t\tconst pipeline: mongoose.PipelineStage[] = [\n\t\t\tthis.buildBaseMatch(marketingId, duration),\n\n\t\t\t{\n\t\t\t\t$lookup: {\n\t\t\t\t\tfrom: 'lineItems',\n\t\t\t\t\tlocalField: 'cart',\n\t\t\t\t\tforeignField: 'cart',\n\t\t\t\t\tas: 'lineItems',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{ $unwind: '$lineItems' },\n\n\t\t\t{\n\t\t\t\t$group: {\n\t\t\t\t\t_id: null,\n\t\t\t\t\ttotalSpent: {\n\t\t\t\t\t\t$sum: {\n\t\t\t\t\t\t\t$add: addBlock,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\n\t\treturn this.runAggregateAndGetTotal(pipeline, 'totalSpent');\n\t}\n\n\tprivate async calculateFreeDeliverySpent(\n\t\tmarketingId: mongoose.Types.ObjectId,\n\t\tduration?: Duration\n\t): Promise<number> {\n\t\tconst pipeline: mongoose.PipelineStage[] = [\n\t\t\tthis.buildBaseMatch(marketingId, duration),\n\n\t\t\t{\n\t\t\t\t$group: {\n\t\t\t\t\t_id: null,\n\t\t\t\t\ttotalSpent: {\n\t\t\t\t\t\t$sum: {\n\t\t\t\t\t\t\t$add: [\n\t\t\t\t\t\t\t\t{ $ifNull: ['$adjustedFinance.freeDelivery.companyCut', 0] },\n\t\t\t\t\t\t\t\t{ $ifNull: ['$adjustedFinance.freeDelivery.shopCut', 0] },\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\n\t\treturn this.runAggregateAndGetTotal(pipeline, 'totalSpent');\n\t}\n\n\tprivate async calculatePunchMarketingSpent(\n\t\tmarketingId: mongoose.Types.ObjectId,\n\t\tduration?: Duration\n\t): Promise<number> {\n\t\tconst pipeline: mongoose.PipelineStage[] = [\n\t\t\tthis.buildBaseMatch(marketingId, duration),\n\n\t\t\t{\n\t\t\t\t$group: {\n\t\t\t\t\t_id: null,\n\t\t\t\t\ttotalSpent: {\n\t\t\t\t\t\t$sum: {\n\t\t\t\t\t\t\t$ifNull: ['$adjustedFinance.pricing.punchMarketingDiscount', 0],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\n\t\treturn this.runAggregateAndGetTotal(pipeline, 'totalSpent');\n\t}\n\n\tprivate buildBaseMatch(\n\t\tmarketingId: mongoose.Types.ObjectId,\n\t\tduration?: Duration\n\t): mongoose.PipelineStage.Match {\n\t\treturn {\n\t\t\t$match: {\n\t\t\t\tmarketings: marketingId,\n\t\t\t\tstatus: { $ne: RegularOrderStatus.CANCELLED },\n\t\t\t\t...(duration && {\n\t\t\t\t\tprocessedAt: {\n\t\t\t\t\t\t$gte: duration.start,\n\t\t\t\t\t\t$lte: duration.end,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate async runAggregateAndGetTotal(pipeline: mongoose.PipelineStage[], field: string): Promise<number> {\n\t\tconst [result] = await this.orderModel.aggregate(pipeline);\n\t\treturn result?.[field] ?? 0;\n\t}\n\n\tpublic async getMetrics(marketingId: mongoose.Types.ObjectId): Promise<MarketingMetricsDTO> {\n\t\tconst marketing = await this.model.findById(marketingId).lean();\n\n\t\tif (!marketing) {\n\t\t\tnotFoundError('Marketing not found');\n\t\t}\n\n\t\t//TODO: fix current end and previous start\n\n\t\tconst currentDuration = { start: marketing.duration.start, end: dayjs().toDate() };\n\t\tconst previousDuration = {\n\t\t\tstart: dayjs(marketing.duration.start).subtract(dayjs().diff(marketing.duration.start)).toDate(),\n\t\t\tend: marketing.duration.start,\n\t\t};\n\n\t\tlet metrics: MarketingMetricsDTO = {};\n\n\t\tif ([MarketingType.DISCOUNT, MarketingType.BUY1GET1].includes(marketing.marketingType)) {\n\t\t\tmetrics.numberOfItems = await this.getMarketingItemCount(marketingId);\n\t\t}\n\n\t\tmetrics.orderIncreaseWithDiscount = await this.calculateOrderIncreaseWithDiscount(\n\t\t\tmarketingId,\n\t\t\tmarketing.shop._id,\n\t\t\tcurrentDuration,\n\t\t\tpreviousDuration\n\t\t);\n\t\tmetrics.customerIncreaseWithDiscount = await this.calculateCustomerIncreaseWithDiscount(\n\t\t\tmarketingId,\n\t\t\tmarketing.shop._id,\n\t\t\tcurrentDuration,\n\t\t\tpreviousDuration\n\t\t);\n\n\t\treturn metrics;\n\t}\n\n\tprivate async getMarketingItemCount(marketingId: mongoose.Types.ObjectId): Promise<number> {\n\t\tconst result = await productMarketingService.countDocuments({ marketing: marketingId });\n\t\treturn result ?? 0;\n\t}\n\n\tprivate async calculateOrderIncreaseWithDiscount(\n\t\tmarketingId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tcurrentDuration: Duration,\n\t\tpreviousDuration: Duration\n\t): Promise<IncreaseDuringDiscountDTO> {\n\t\tconst [currentOrders, previousOrders] = await Promise.all([\n\t\t\tthis.orderModel.countDocuments({\n\t\t\t\tcreatedAt: {\n\t\t\t\t\t$gte: currentDuration.start,\n\t\t\t\t\t$lte: currentDuration.end,\n\t\t\t\t},\n\t\t\t\tmarketings: marketingId, // marketing must be applied\n\t\t\t\tshop: shopId,\n\t\t\t}),\n\t\t\tthis.orderModel.countDocuments({\n\t\t\t\tcreatedAt: {\n\t\t\t\t\t$gte: previousDuration.start,\n\t\t\t\t\t$lte: previousDuration.end,\n\t\t\t\t},\n\t\t\t\tshop: shopId,\n\t\t\t}),\n\t\t]);\n\n\t\treturn this.calculateIncrease(currentOrders, previousOrders);\n\t}\n\n\tprivate async calculateCustomerIncreaseWithDiscount(\n\t\tmarketingId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tcurrentDuration: Duration,\n\t\tpreviousDuration: Duration\n\t): Promise<IncreaseDuringDiscountDTO> {\n\t\tconst [currentNewCustomers, previousNewCustomers] = await Promise.all([\n\t\t\tthis.getNewCustomersForShop(shopId, currentDuration, { marketings: marketingId }),\n\t\t\tthis.getNewCustomersForShop(shopId, previousDuration),\n\t\t]);\n\n\t\treturn this.calculateIncrease(currentNewCustomers, previousNewCustomers);\n\t}\n\n\tprivate calculateIncrease(current: number, previous: number): IncreaseDuringDiscountDTO {\n\t\tconst count = current - previous;\n\n\t\tconst percentageIncrease = previous === 0 ? (current > 0 ? 100 : 0) : (count / previous) * 100;\n\n\t\treturn {\n\t\t\tcount,\n\t\t\tpercentageIncrease,\n\t\t};\n\t}\n\n\tprivate async getNewCustomersForShop(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tduration: Duration,\n\t\textraMatch: Record<string, any> = {}\n\t): Promise<number> {\n\t\t// Customers who ordered during the period\n\t\tconst customersInPeriod = await this.orderModel.distinct('user', {\n\t\t\tcreatedAt: {\n\t\t\t\t$gte: duration.start,\n\t\t\t\t$lte: duration.end,\n\t\t\t},\n\t\t\tshop: shopId,\n\t\t\t...extraMatch,\n\t\t});\n\n\t\tif (customersInPeriod.length === 0) {\n\t\t\treturn 0;\n\t\t}\n\n\t\t// Customers who had ordered from this shop BEFORE the period\n\t\tconst existingCustomers = await this.orderModel.distinct('user', {\n\t\t\tshop: shopId,\n\t\t\tcreatedAt: { $lt: duration.start },\n\t\t\tuser: { $in: customersInPeriod },\n\t\t});\n\n\t\t// New customers = in period − existing\n\t\treturn customersInPeriod.length - existingCustomers.length;\n\t}\n\n\tpublic async getOrdersGraph(data: MarketingGraphInputDTO): Promise<MarketingOrdersGraphOutputDTO> {\n\t\tconst dateFormat = data.type === GraphType.MONTHLY ? '%Y-%m' : '%Y-%m-%d';\n\n\t\tconst pipeline: mongoose.PipelineStage[] = [\n\t\t\t// Filter only delivered orders within the given date range\n\t\t\tthis.buildBaseMatch(new mongoose.Types.ObjectId(data.marketingId), {\n\t\t\t\tstart: data.startDate,\n\t\t\t\tend: data.endDate,\n\t\t\t}),\n\n\t\t\t// Extract formatted date from 'processedAt' for grouping\n\t\t\t{\n\t\t\t\t$project: {\n\t\t\t\t\tdate: {\n\t\t\t\t\t\t$dateToString: {\n\t\t\t\t\t\t\tformat: dateFormat,\n\t\t\t\t\t\t\tdate: '$processedAt',\n\t\t\t\t\t\t\ttimezone: LyxaTimezone,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\n\t\t\t// Group by formatted date and count orders\n\t\t\t{\n\t\t\t\t$group: {\n\t\t\t\t\t_id: '$date',\n\t\t\t\t\torders: { $sum: 1 },\n\t\t\t\t},\n\t\t\t},\n\n\t\t\t// Sort results chronologically\n\t\t\t{\n\t\t\t\t$sort: { _id: 1 },\n\t\t\t},\n\n\t\t\t// Format the response to match output DTO structure\n\t\t\t{\n\t\t\t\t$project: {\n\t\t\t\t\t_id: 0,\n\t\t\t\t\tdate: '$_id',\n\t\t\t\t\torders: 1,\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\n\t\t// Execute aggregation pipeline\n\t\tconst results = await this.orderModel.aggregate(pipeline).allowDiskUse(true).exec();\n\n\t\tconst graphData = fillMissingPeriods(results, data.startDate, data.endDate, data.type, {\n\t\t\torders: 0,\n\t\t});\n\n\t\treturn graphData;\n\t}\n\n\tpublic async getCustomersGraph(data: MarketingGraphInputDTO): Promise<{ date: string; users: number }[]> {\n\t\t// 1️⃣ Get shopId from marketing\n\t\tconst marketing = await this.model.findById(data.marketingId).select('shop').lean();\n\n\t\tif (!marketing) {\n\t\t\tnotFoundError('Marketing not found');\n\t\t}\n\n\t\tconst shopId = marketing.shop._id;\n\n\t\t// 2️⃣ Fetch users who ordered from this shop BEFORE the start date\n\t\tconst oldUsers = await this.orderModel.distinct('user', {\n\t\t\tshop: shopId,\n\t\t\tstatus: RegularOrderStatus.DELIVERED,\n\t\t\tprocessedAt: { $lt: data.startDate },\n\t\t});\n\n\t\tconst dateFormat = data.type === GraphType.MONTHLY ? '%Y-%m' : '%Y-%m-%d';\n\n\t\t// 3️⃣ Aggregation pipeline\n\t\tconst pipeline: mongoose.PipelineStage[] = [\n\t\t\t// Orders during the period with this marketing\n\t\t\t{\n\t\t\t\t$match: {\n\t\t\t\t\torderType: OrderType.REGULAR,\n\t\t\t\t\tstatus: RegularOrderStatus.DELIVERED,\n\t\t\t\t\tshop: shopId,\n\t\t\t\t\tmarketings: new mongoose.Types.ObjectId(data.marketingId),\n\t\t\t\t\tprocessedAt: { $gte: data.startDate, $lte: data.endDate },\n\t\t\t\t\tuser: { $nin: oldUsers }, // 🚫 exclude old users\n\t\t\t\t},\n\t\t\t},\n\n\t\t\t// Sort so earliest order per user comes first\n\t\t\t{ $sort: { processedAt: 1 } },\n\n\t\t\t// First order per user (new users only)\n\t\t\t{\n\t\t\t\t$group: {\n\t\t\t\t\t_id: '$user',\n\t\t\t\t\tfirstOrderDate: { $first: '$processedAt' },\n\t\t\t\t},\n\t\t\t},\n\n\t\t\t// Format date\n\t\t\t{\n\t\t\t\t$project: {\n\t\t\t\t\tdate: {\n\t\t\t\t\t\t$dateToString: {\n\t\t\t\t\t\t\tformat: dateFormat,\n\t\t\t\t\t\t\tdate: '$firstOrderDate',\n\t\t\t\t\t\t\ttimezone: LyxaTimezone,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\n\t\t\t// Group by date\n\t\t\t{\n\t\t\t\t$group: {\n\t\t\t\t\t_id: '$date',\n\t\t\t\t\tusers: { $sum: 1 },\n\t\t\t\t},\n\t\t\t},\n\n\t\t\t// Sort chronologically\n\t\t\t{ $sort: { _id: 1 } },\n\n\t\t\t// Shape response\n\t\t\t{\n\t\t\t\t$project: {\n\t\t\t\t\t_id: 0,\n\t\t\t\t\tdate: '$_id',\n\t\t\t\t\tusers: 1,\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\n\t\tconst results = await this.orderModel.aggregate(pipeline).allowDiskUse(true).exec();\n\n\t\t// 4️⃣ Fill missing periods\n\t\treturn fillMissingPeriods(results, data.startDate, data.endDate, data.type, {\n\t\t\tusers: 0,\n\t\t});\n\t}\n\n\tpublic async getAmountSpentGraph(\n\t\tdata: MarketingGraphInputDTO\n\t): Promise<{ date: string; amount: number }[]> {\n\t\tconst marketing = await this.model.findById(data.marketingId).lean();\n\n\t\tif (!marketing) {\n\t\t\tnotFoundError('Marketing not found');\n\t\t}\n\n\t\tconst marketingId = new mongoose.Types.ObjectId(data.marketingId);\n\t\tconst dateFormat = data.type === GraphType.MONTHLY ? '%Y-%m' : '%Y-%m-%d';\n\n\t\tlet pipeline: mongoose.PipelineStage[] | null = null;\n\n\t\t/**\n\t\t * ITEM-BASED (DISCOUNT / BUY1GET1)\n\t\t */\n\t\tif ([MarketingType.DISCOUNT, MarketingType.BUY1GET1].includes(marketing.marketingType)) {\n\t\t\tpipeline = [\n\t\t\t\tthis.buildBaseMatch(marketingId, {\n\t\t\t\t\tstart: data.startDate,\n\t\t\t\t\tend: data.endDate,\n\t\t\t\t}),\n\t\t\t\t{\n\t\t\t\t\t$lookup: {\n\t\t\t\t\t\tfrom: 'lineItems',\n\t\t\t\t\t\tlocalField: 'cart',\n\t\t\t\t\t\tforeignField: 'cart',\n\t\t\t\t\t\tas: 'lineItems',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{ $unwind: '$lineItems' },\n\t\t\t\t{\n\t\t\t\t\t$match: {\n\t\t\t\t\t\t'lineItems.marketings': marketingId,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t$project: {\n\t\t\t\t\t\tdate: {\n\t\t\t\t\t\t\t$dateToString: {\n\t\t\t\t\t\t\t\tformat: dateFormat,\n\t\t\t\t\t\t\t\tdate: '$processedAt',\n\t\t\t\t\t\t\t\ttimezone: LyxaTimezone,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tamount: {\n\t\t\t\t\t\t\t$add: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\tmarketing.isAppliedByCompany,\n\t\t\t\t\t\t\t\t\t\t{ $ifNull: ['$lineItems.calculationSnap.itemDiscountByCompany', 0] },\n\t\t\t\t\t\t\t\t\t\t{ $ifNull: ['$lineItems.calculationSnap.itemDiscountByShop', 0] },\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\t\t\tmarketing.isAppliedByCompany,\n\t\t\t\t\t\t\t\t\t\t{ $ifNull: ['$lineItems.calculationSnap.b1g1DiscountByCompany', 0] },\n\t\t\t\t\t\t\t\t\t\t{ $ifNull: ['$lineItems.calculationSnap.b1g1DiscountByShop', 0] },\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t$group: {\n\t\t\t\t\t\t_id: '$date',\n\t\t\t\t\t\tamount: { $sum: '$amount' },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{ $sort: { _id: 1 } },\n\t\t\t\t{\n\t\t\t\t\t$project: {\n\t\t\t\t\t\t_id: 0,\n\t\t\t\t\t\tdate: '$_id',\n\t\t\t\t\t\tamount: 1,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t];\n\t\t} else if (marketing.marketingType === MarketingType.FREE_DELIVERY) {\n\t\t\t/**\n\t\t\t * FREE DELIVERY\n\t\t\t */\n\t\t\tpipeline = [\n\t\t\t\tthis.buildBaseMatch(marketingId, {\n\t\t\t\t\tstart: data.startDate,\n\t\t\t\t\tend: data.endDate,\n\t\t\t\t}),\n\t\t\t\t{\n\t\t\t\t\t$project: {\n\t\t\t\t\t\tdate: {\n\t\t\t\t\t\t\t$dateToString: {\n\t\t\t\t\t\t\t\tformat: dateFormat,\n\t\t\t\t\t\t\t\tdate: '$processedAt',\n\t\t\t\t\t\t\t\ttimezone: LyxaTimezone,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tamount: {\n\t\t\t\t\t\t\t$cond: [\n\t\t\t\t\t\t\t\tmarketing.isAppliedByCompany,\n\t\t\t\t\t\t\t\t{ $ifNull: ['$adjustedFinance.freeDelivery.companyCut', 0] },\n\t\t\t\t\t\t\t\t{ $ifNull: ['$adjustedFinance.freeDelivery.shopCut', 0] },\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t$group: {\n\t\t\t\t\t\t_id: '$date',\n\t\t\t\t\t\tamount: { $sum: '$amount' },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{ $sort: { _id: 1 } },\n\t\t\t\t{\n\t\t\t\t\t$project: {\n\t\t\t\t\t\t_id: 0,\n\t\t\t\t\t\tdate: '$_id',\n\t\t\t\t\t\tamount: 1,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t];\n\t\t} else if (marketing.marketingType === MarketingType.PUNCH_MARKETING) {\n\t\t\t/**\n\t\t\t * PUNCH MARKETING\n\t\t\t */\n\t\t\tpipeline = [\n\t\t\t\tthis.buildBaseMatch(marketingId, {\n\t\t\t\t\tstart: data.startDate,\n\t\t\t\t\tend: data.endDate,\n\t\t\t\t}),\n\t\t\t\t{\n\t\t\t\t\t$project: {\n\t\t\t\t\t\tdate: {\n\t\t\t\t\t\t\t$dateToString: {\n\t\t\t\t\t\t\t\tformat: dateFormat,\n\t\t\t\t\t\t\t\tdate: '$processedAt',\n\t\t\t\t\t\t\t\ttimezone: LyxaTimezone,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tamount: {\n\t\t\t\t\t\t\t$ifNull: ['$adjustedFinance.pricing.punchMarketingDiscount', 0],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t$group: {\n\t\t\t\t\t\t_id: '$date',\n\t\t\t\t\t\tamount: { $sum: '$amount' },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{ $sort: { _id: 1 } },\n\t\t\t\t{\n\t\t\t\t\t$project: {\n\t\t\t\t\t\t_id: 0,\n\t\t\t\t\t\tdate: '$_id',\n\t\t\t\t\t\tamount: 1,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\t// If marketing type doesn't produce spend graph → return empty graph\n\t\tif (!pipeline) {\n\t\t\treturn fillMissingPeriods(\n\t\t\t\t[] as { date: string; amount: number }[],\n\t\t\t\tdata.startDate,\n\t\t\t\tdata.endDate,\n\t\t\t\tdata.type,\n\t\t\t\t{\n\t\t\t\t\tamount: 0,\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tconst results = await this.orderModel.aggregate(pipeline).allowDiskUse(true).exec();\n\n\t\treturn fillMissingPeriods(results, data.startDate, data.endDate, data.type, {\n\t\t\tamount: 0,\n\t\t});\n\t}\n}\n\nexport const marketingMetricsRepository = Container.get(MarketingMetricsRepository);\n"]}
@@ -166,7 +166,6 @@ export declare const marketingRouter: import("@trpc/server").TRPCBuiltRouter<{
166
166
  count: number;
167
167
  percentageIncrease: number;
168
168
  } | undefined;
169
- totalRedemptions?: number | undefined;
170
169
  } | undefined;
171
170
  };
172
171
  meta: object;
@@ -222,19 +221,6 @@ export declare const marketingRouter: import("@trpc/server").TRPCBuiltRouter<{
222
221
  };
223
222
  meta: object;
224
223
  }>;
225
- getSpendToGetProgress: import("@trpc/server").TRPCQueryProcedure<{
226
- input: {
227
- shop: string | mongoose.Types.ObjectId;
228
- basketTotal: number;
229
- userId?: string | mongoose.Types.ObjectId | undefined;
230
- };
231
- output: {
232
- success: boolean;
233
- message: string;
234
- data: import("../../marketing/services").SpendToGetProgressResult | undefined;
235
- };
236
- meta: object;
237
- }>;
238
224
  reseedEntireMenuMarketing: import("@trpc/server").TRPCMutationProcedure<{
239
225
  input: string | mongoose.Types.ObjectId;
240
226
  output: {
@@ -1 +1 @@
1
- {"version":3,"file":"marketing.router.d.ts","sourceRoot":"/","sources":["modules/marketing/routers/marketing.router.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAMxB,CAAD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyJD,CAAC"}
1
+ {"version":3,"file":"marketing.router.d.ts","sourceRoot":"/","sources":["modules/marketing/routers/marketing.router.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAOmB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiJ9C,CAAC"}
@@ -5,7 +5,6 @@ const trpc_1 = require("@lyxa.ai/core/dist/libraries/trpc");
5
5
  const auth_1 = require("@lyxa.ai/core/dist/libraries/trpc/middlewares/auth");
6
6
  const services_1 = require("../../marketing/services");
7
7
  const services_2 = require("../../marketing/services");
8
- const services_3 = require("../../marketing/services");
9
8
  const validations_1 = require("../../marketing/validations");
10
9
  const response_1 = require("@lyxa.ai/core/dist/utilities/response");
11
10
  const validation_1 = require("@lyxa.ai/core/dist/utilities/validation");
@@ -100,10 +99,6 @@ exports.marketingRouter = (0, trpc_1.createTRPCRouter)({
100
99
  const result = await MarketingMetricsRepository_1.marketingMetricsRepository.getAmountSpentGraph(input);
101
100
  return (0, response_1.response)('Marketing amount spent graph data fetched successfully', result);
102
101
  })),
103
- getSpendToGetProgress: trpc_1.publicProcedure.input(validations_1.SpendToGetProgressInputSchema).query(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
104
- const result = await services_3.spendToGetProgressService.getProgress(input);
105
- return (0, response_1.response)('Spend to get progress fetched successfully', result);
106
- })),
107
102
  reseedEntireMenuMarketing: (0, auth_1.createAuthenticatedProcedure)({ entityTypes: [auth_2.AuthEntityType.CRM] })
108
103
  .input(validation_1.IdSchema)
109
104
  .output(validations_1.MarketingResponseSchema)
@@ -1 +1 @@
1
- {"version":3,"file":"marketing.router.js","sourceRoot":"/","sources":["modules/marketing/routers/marketing.router.ts"],"names":[],"mappings":";;;AAAA,4DAAsF;AACtF,6EAAkG;AAClG,0DAA0E;AAC1E,0DAAoH;AACpH,0DAAwE;AACxE,gEASwC;AACxC,oEAAiE;AACjE,wEAKiD;AACjD,8EAA0E;AAC1E,4DAAmE;AACnE,oDAAgD;AAChD,kGAA+F;AAElF,QAAA,eAAe,GAAG,IAAA,uBAAgB,EAAC;IAC/C,MAAM,EAAE,IAAA,mCAA4B,EAAC,EAAE,WAAW,EAAE,CAAC,qBAAc,CAAC,GAAG,EAAE,qBAA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esContent":["import { createTRPCRouter, publicProcedure } from '@lyxa.ai/core/dist/libraries/trpc';\nimport { createAuthenticatedProcedure } from '@lyxa.ai/core/dist/libraries/trpc/middlewares/auth';\nimport { marketingService as service } from '@modules/marketing/services';\nimport { synchronizeProductMarketingService as syncMarketingProductInfoService } from '@modules/marketing/services';\nimport { spendToGetProgressService } from '@modules/marketing/services';\nimport {\n\tAllMarketingsValidationSchema,\n\tMarketingResponseSchema as ResponseSchema,\n\tAllMarketingsUpdateSchema,\n\tProductEntireMenuMarketingHandlerSchema,\n\tMarketingSpendLimitsEvaluationSchema,\n\tSyncProductMarketingForMultipleProductsSchema,\n\tMarketingGraphInputSchema,\n\tSpendToGetProgressInputSchema,\n} from '@modules/marketing/validations';\nimport { response } from '@lyxa.ai/core/dist/utilities/response';\nimport {\n\tFilterSchema,\n\tDeleteSchema,\n\tGetByIdInputSchema,\n\tIdSchema,\n} from '@lyxa.ai/core/dist/utilities/validation';\nimport { ErrorHandler } from '@lyxa.ai/core/dist/utilities/error-handler';\nimport { AuthEntityType } from '@lyxa.ai/core/dist/libraries/auth';\nimport { mongoose } from '@typegoose/typegoose';\nimport { marketingMetricsRepository } from '../patterns/repository/MarketingMetricsRepository';\n\nexport const marketingRouter = createTRPCRouter({\n\tcreate: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM, AuthEntityType.SELLER] })\n\t\t.input(AllMarketingsValidationSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst isAdmin = ctx.entity?.type == AuthEntityType.CRM;\n\t\t\t\tawait service.create(input, isAdmin ? new mongoose.Types.ObjectId(ctx.entity?.id) : undefined);\n\t\t\t\treturn response('Marketing created successfully');\n\t\t\t})\n\t\t),\n\n\tgetById: publicProcedure.input(GetByIdInputSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.findById(input);\n\t\t\treturn response('Marketing fetched successfully', result);\n\t\t})\n\t),\n\n\tget: publicProcedure.input(FilterSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.find(input);\n\t\t\treturn response('Marketing fetched successfully', result);\n\t\t})\n\t),\n\n\tupdate: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM, AuthEntityType.SELLER] })\n\t\t.input(AllMarketingsUpdateSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst { _id, ...rest } = input;\n\t\t\t\tconst isAdmin = ctx.entity?.type == AuthEntityType.CRM;\n\n\t\t\t\tawait service.update(_id, rest, isAdmin ? new mongoose.Types.ObjectId(ctx.entity?.id) : undefined);\n\t\t\t\treturn response('Marketing updated successfully');\n\t\t\t})\n\t\t),\n\n\tdeleteById: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM, AuthEntityType.SELLER] })\n\t\t.input(DeleteSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst isAdmin = ctx.entity?.type == AuthEntityType.CRM;\n\t\t\t\tawait service.deleteById(input, isAdmin ? new mongoose.Types.ObjectId(ctx.entity?.id) : undefined);\n\t\t\t\treturn response('Marketing deleted successfully');\n\t\t\t})\n\t\t),\n\n\thandleNewProductForEntireMenuMarketing: publicProcedure\n\t\t.input(ProductEntireMenuMarketingHandlerSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tawait service.handleNewProductForEntireMenuMarketing(input);\n\t\t\t\treturn response('Product handled successfully');\n\t\t\t})\n\t\t),\n\n\tsyncAllProductsMarketingInfo: publicProcedure.query(async ({}) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\treturn await syncMarketingProductInfoService.publishAllProductsProductMarketingInfoProcessEvent();\n\t\t})\n\t),\n\n\tsyncAllProductsMarketingInfoLocal: publicProcedure.mutation(async ({}) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\treturn await syncMarketingProductInfoService.syncAllProductsMarketingInfo();\n\t\t})\n\t),\n\n\t// DEV purpose only\n\tsyncProductMarketingInfoByProductId: publicProcedure.query(async ({}) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst productId = new mongoose.Types.ObjectId('68f663c355f42c826a129fc6'); // Todo: use productId sent from param\n\t\t\treturn await syncMarketingProductInfoService.syncProductMarketingInfoByProductId(productId);\n\t\t})\n\t),\n\n\tsyncProductMarketingInfoByProductIds: publicProcedure\n\t\t.input(SyncProductMarketingForMultipleProductsSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\treturn await syncMarketingProductInfoService.syncProductMarketingInfoByProductIds(input.productIds);\n\t\t\t})\n\t\t),\n\n\tcalculateMarketingSpent: publicProcedure.input(IdSchema).mutation(async ({ ctx, input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await marketingMetricsRepository.calculateMarketingSpent(input);\n\t\t\treturn response('Marketing amount spent calculated successfully', result);\n\t\t})\n\t),\n\n\tincrementMarketingSpentFromOrder: publicProcedure.input(IdSchema).mutation(async ({ ctx, input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.incrementMarketingSpentFromOrder(input);\n\t\t\treturn response('Marketing amount spent incremented successfully', result);\n\t\t})\n\t),\n\n\tdecrementMarketingSpentFromOrder: publicProcedure.input(IdSchema).mutation(async ({ ctx, input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.decrementMarketingSpentFromOrder(input);\n\t\t\treturn response('Marketing amount spent decremented successfully', result);\n\t\t})\n\t),\n\n\trecomputeAndSyncAllMarketingSpent: publicProcedure.mutation(async ({}) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.recomputeAndSyncAllMarketingSpent();\n\t\t\treturn response('Marketing amount spent recomputed and synced successfully', result);\n\t\t})\n\t),\n \n\tgetMetrics: publicProcedure.input(IdSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await marketingMetricsRepository.getMetrics(input);\n\t\t\treturn response('Marketing metrics fetched successfully', result);\n\t\t})\n\t),\n \n\tgetOrdersGraph: publicProcedure.input(MarketingGraphInputSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await marketingMetricsRepository.getOrdersGraph(input);\n\t\t\treturn response('Marketing orders graph data fetched successfully', result);\n\t\t})\n\t),\n\n\tgetCustomersGraph: publicProcedure.input(MarketingGraphInputSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await marketingMetricsRepository.getCustomersGraph(input);\n\t\t\treturn response('Marketing customers graph data fetched successfully', result);\n\t\t})\n\t),\n\n\tgetAmountSpentGraph: publicProcedure.input(MarketingGraphInputSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await marketingMetricsRepository.getAmountSpentGraph(input);\n\t\t\treturn response('Marketing amount spent graph data fetched successfully', result);\n\t\t})\n\t),\n\n\tgetSpendToGetProgress: publicProcedure.input(SpendToGetProgressInputSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await spendToGetProgressService.getProgress(input);\n\t\t\treturn response('Spend to get progress fetched successfully', result);\n\t\t})\n\t),\n\n\treseedEntireMenuMarketing: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n\t\t.input(IdSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tawait service.reseedEntireMenuMarketing(new mongoose.Types.ObjectId(input));\n\t\t\t\treturn response('Entire menu marketing reseed dispatched successfully');\n\t\t\t})\n\t\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,sDAAsD,CAAC,CAAC;IACzE,CAAC,CAAC,CACF;CACF,CAAC,CAAC","sourcesContent":["import { createTRPCRouter, publicProcedure } from '@lyxa.ai/core/dist/libraries/trpc';\nimport { createAuthenticatedProcedure } from '@lyxa.ai/core/dist/libraries/trpc/middlewares/auth';\nimport { marketingService as service } from '@modules/marketing/services';\nimport { synchronizeProductMarketingService as syncMarketingProductInfoService } from '@modules/marketing/services';\nimport {\n\tAllMarketingsValidationSchema,\n\tMarketingResponseSchema as ResponseSchema,\n\tAllMarketingsUpdateSchema,\n\tProductEntireMenuMarketingHandlerSchema,\n\tMarketingSpendLimitsEvaluationSchema,\n\tSyncProductMarketingForMultipleProductsSchema,\n\tMarketingGraphInputSchema,\n} from '@modules/marketing/validations';\nimport { response } from '@lyxa.ai/core/dist/utilities/response';\nimport {\n\tFilterSchema,\n\tDeleteSchema,\n\tGetByIdInputSchema,\n\tIdSchema,\n} from '@lyxa.ai/core/dist/utilities/validation';\nimport { ErrorHandler } from '@lyxa.ai/core/dist/utilities/error-handler';\nimport { AuthEntityType } from '@lyxa.ai/core/dist/libraries/auth';\nimport { mongoose } from '@typegoose/typegoose';\nimport { marketingMetricsRepository } from '../patterns/repository/MarketingMetricsRepository';\n\nexport const marketingRouter = createTRPCRouter({\n\tcreate: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM, AuthEntityType.SELLER] })\n\t\t.input(AllMarketingsValidationSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst isAdmin = ctx.entity?.type == AuthEntityType.CRM;\n\t\t\t\tawait service.create(input, isAdmin ? new mongoose.Types.ObjectId(ctx.entity?.id) : undefined);\n\t\t\t\treturn response('Marketing created successfully');\n\t\t\t})\n\t\t),\n\n\tgetById: publicProcedure.input(GetByIdInputSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.findById(input);\n\t\t\treturn response('Marketing fetched successfully', result);\n\t\t})\n\t),\n\n\tget: publicProcedure.input(FilterSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.find(input);\n\t\t\treturn response('Marketing fetched successfully', result);\n\t\t})\n\t),\n\n\tupdate: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM, AuthEntityType.SELLER] })\n\t\t.input(AllMarketingsUpdateSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst { _id, ...rest } = input;\n\t\t\t\tconst isAdmin = ctx.entity?.type == AuthEntityType.CRM;\n\n\t\t\t\tawait service.update(_id, rest, isAdmin ? new mongoose.Types.ObjectId(ctx.entity?.id) : undefined);\n\t\t\t\treturn response('Marketing updated successfully');\n\t\t\t})\n\t\t),\n\n\tdeleteById: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM, AuthEntityType.SELLER] })\n\t\t.input(DeleteSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ ctx, input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tconst isAdmin = ctx.entity?.type == AuthEntityType.CRM;\n\t\t\t\tawait service.deleteById(input, isAdmin ? new mongoose.Types.ObjectId(ctx.entity?.id) : undefined);\n\t\t\t\treturn response('Marketing deleted successfully');\n\t\t\t})\n\t\t),\n\n\thandleNewProductForEntireMenuMarketing: publicProcedure\n\t\t.input(ProductEntireMenuMarketingHandlerSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tawait service.handleNewProductForEntireMenuMarketing(input);\n\t\t\t\treturn response('Product handled successfully');\n\t\t\t})\n\t\t),\n\n\tsyncAllProductsMarketingInfo: publicProcedure.query(async ({}) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\treturn await syncMarketingProductInfoService.publishAllProductsProductMarketingInfoProcessEvent();\n\t\t})\n\t),\n\n\tsyncAllProductsMarketingInfoLocal: publicProcedure.mutation(async ({}) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\treturn await syncMarketingProductInfoService.syncAllProductsMarketingInfo();\n\t\t})\n\t),\n\n\t// DEV purpose only\n\tsyncProductMarketingInfoByProductId: publicProcedure.query(async ({}) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst productId = new mongoose.Types.ObjectId('68f663c355f42c826a129fc6'); // Todo: use productId sent from param\n\t\t\treturn await syncMarketingProductInfoService.syncProductMarketingInfoByProductId(productId);\n\t\t})\n\t),\n\n\tsyncProductMarketingInfoByProductIds: publicProcedure\n\t\t.input(SyncProductMarketingForMultipleProductsSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\treturn await syncMarketingProductInfoService.syncProductMarketingInfoByProductIds(input.productIds);\n\t\t\t})\n\t\t),\n\n\tcalculateMarketingSpent: publicProcedure.input(IdSchema).mutation(async ({ ctx, input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await marketingMetricsRepository.calculateMarketingSpent(input);\n\t\t\treturn response('Marketing amount spent calculated successfully', result);\n\t\t})\n\t),\n\n\tincrementMarketingSpentFromOrder: publicProcedure.input(IdSchema).mutation(async ({ ctx, input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.incrementMarketingSpentFromOrder(input);\n\t\t\treturn response('Marketing amount spent incremented successfully', result);\n\t\t})\n\t),\n\n\tdecrementMarketingSpentFromOrder: publicProcedure.input(IdSchema).mutation(async ({ ctx, input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.decrementMarketingSpentFromOrder(input);\n\t\t\treturn response('Marketing amount spent decremented successfully', result);\n\t\t})\n\t),\n\n\trecomputeAndSyncAllMarketingSpent: publicProcedure.mutation(async ({}) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await service.recomputeAndSyncAllMarketingSpent();\n\t\t\treturn response('Marketing amount spent recomputed and synced successfully', result);\n\t\t})\n\t),\n \n\tgetMetrics: publicProcedure.input(IdSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await marketingMetricsRepository.getMetrics(input);\n\t\t\treturn response('Marketing metrics fetched successfully', result);\n\t\t})\n\t),\n \n\tgetOrdersGraph: publicProcedure.input(MarketingGraphInputSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await marketingMetricsRepository.getOrdersGraph(input);\n\t\t\treturn response('Marketing orders graph data fetched successfully', result);\n\t\t})\n\t),\n\n\tgetCustomersGraph: publicProcedure.input(MarketingGraphInputSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await marketingMetricsRepository.getCustomersGraph(input);\n\t\t\treturn response('Marketing customers graph data fetched successfully', result);\n\t\t})\n\t),\n\n\tgetAmountSpentGraph: publicProcedure.input(MarketingGraphInputSchema).query(async ({ input }) =>\n\t\tErrorHandler.wrapAsync(async () => {\n\t\t\tconst result = await marketingMetricsRepository.getAmountSpentGraph(input);\n\t\t\treturn response('Marketing amount spent graph data fetched successfully', result);\n\t\t})\n\t),\n\n\treseedEntireMenuMarketing: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n\t\t.input(IdSchema)\n\t\t.output(ResponseSchema)\n\t\t.mutation(async ({ input }) =>\n\t\t\tErrorHandler.wrapAsync(async () => {\n\t\t\t\tawait service.reseedEntireMenuMarketing(new mongoose.Types.ObjectId(input));\n\t\t\t\treturn response('Entire menu marketing reseed dispatched successfully');\n\t\t\t})\n\t\t),\n});\n"]}
@@ -3,9 +3,6 @@ export * from './discount-marketing.service';
3
3
  export * from './featured-marketing.service';
4
4
  export * from './free-delivery-marketing.service';
5
5
  export * from './punch-marketing.service';
6
- export * from './spend-to-get-marketing.service';
7
- export * from './spend-to-get-progress.service';
8
- export * from './marketing-conflict.service';
9
6
  export * from './product-marketing.service';
10
7
  export * from './marketing.service';
11
8
  export * from './synchronize-product-marketing.service';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/marketing/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,yCAAyC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/marketing/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,yCAAyC,CAAC"}
@@ -19,9 +19,6 @@ __exportStar(require("./discount-marketing.service"), exports);
19
19
  __exportStar(require("./featured-marketing.service"), exports);
20
20
  __exportStar(require("./free-delivery-marketing.service"), exports);
21
21
  __exportStar(require("./punch-marketing.service"), exports);
22
- __exportStar(require("./spend-to-get-marketing.service"), exports);
23
- __exportStar(require("./spend-to-get-progress.service"), exports);
24
- __exportStar(require("./marketing-conflict.service"), exports);
25
22
  __exportStar(require("./product-marketing.service"), exports);
26
23
  __exportStar(require("./marketing.service"), exports);
27
24
  __exportStar(require("./synchronize-product-marketing.service"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/marketing/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA8C;AAC9C,+DAA6C;AAC7C,+DAA6C;AAC7C,oEAAkD;AAClD,4DAA0C;AAC1C,mEAAiD;AACjD,kEAAgD;AAChD,+DAA6C;AAC7C,8DAA4C;AAC5C,sDAAoC;AACpC,0EAAwD","sourcesContent":["export * from './buy1-get1-marketing.service';\nexport * from './discount-marketing.service';\nexport * from './featured-marketing.service';\nexport * from './free-delivery-marketing.service';\nexport * from './punch-marketing.service';\nexport * from './spend-to-get-marketing.service';\nexport * from './spend-to-get-progress.service';\nexport * from './marketing-conflict.service';\nexport * from './product-marketing.service';\nexport * from './marketing.service';\nexport * from './synchronize-product-marketing.service';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/marketing/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA8C;AAC9C,+DAA6C;AAC7C,+DAA6C;AAC7C,oEAAkD;AAClD,4DAA0C;AAC1C,8DAA4C;AAC5C,sDAAoC;AACpC,0EAAwD","sourcesContent":["export * from './buy1-get1-marketing.service';\nexport * from './discount-marketing.service';\nexport * from './featured-marketing.service';\nexport * from './free-delivery-marketing.service';\nexport * from './punch-marketing.service';\nexport * from './product-marketing.service';\nexport * from './marketing.service';\nexport * from './synchronize-product-marketing.service';\n"]}
@@ -10,17 +10,13 @@ export declare class MarketingService {
10
10
  private marketingMetricsRepository;
11
11
  private limitedTimeOfferParticipantModel;
12
12
  constructor();
13
- create(data: AllMarketingsValidationDTO, admin?: mongoose.Types.ObjectId, options?: {
14
- skipLimitedTimeOfferGuard?: boolean;
15
- }): Promise<DocumentType<Model>>;
13
+ create(data: AllMarketingsValidationDTO, admin?: mongoose.Types.ObjectId): Promise<DocumentType<Model>>;
16
14
  findById(data: GetByIdInputDTO): Promise<DocumentType<Model>>;
17
15
  find(data?: Partial<FilterDTO>): Promise<PaginatedResponse<DocumentType<ModelType<Model>>>>;
18
16
  update(_id: mongoose.Types.ObjectId, data: UpdateDTO, admin?: mongoose.Types.ObjectId): Promise<DocumentType<Model>>;
19
17
  private verifyUnpauseConditions;
20
18
  private logMarketingAdminAction;
21
- deleteById(data: DeleteDTO, admin?: mongoose.Types.ObjectId, options?: {
22
- skipLimitedTimeOfferGuard?: boolean;
23
- }): Promise<string>;
19
+ deleteById(data: DeleteDTO, admin?: mongoose.Types.ObjectId): Promise<string>;
24
20
  deleteManyByIds(marketingIds: mongoose.Types.ObjectId[], softDelete?: boolean): Promise<void>;
25
21
  handleNewProductForEntireMenuMarketing(data: ProductEntireMenuMarketingHandlerDTO): Promise<string>;
26
22
  incrementMarketingSpentFromOrder(orderId: mongoose.Types.ObjectId): Promise<any>;
@@ -28,7 +24,6 @@ export declare class MarketingService {
28
24
  private expireMarketingsExceedingSpendLimits;
29
25
  private unExpireMarketingsBelowSpendLimits;
30
26
  recomputeAndSyncAllMarketingSpent(): Promise<void>;
31
- private publishEntireMenuSeedEvents;
32
27
  reseedEntireMenuMarketing(marketingId: mongoose.Types.ObjectId): Promise<void>;
33
28
  assignMarketingToProducts(marketing: DocumentType<Buy1Get1Marketing | DiscountMarketing>): Promise<void>;
34
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"marketing.service.d.ts","sourceRoot":"/","sources":["modules/marketing/services/marketing.service.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAmB,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EAMjB,SAAS,IAAI,KAAK,EAOlB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAEN,0BAA0B,EAE1B,oCAAoC,EACpC,kBAAkB,IAAI,SAAS,EAC/B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACN,SAAS,EACT,iBAAiB,EACjB,SAAS,EACT,eAAe,EACf,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AA+C3D,qBACa,gBAAgB;IAC5B,OAAO,CAAC,KAAK,CAAiD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