@lyxa.ai/marketing 1.0.42 → 1.0.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/dist/lib/event/event-initializations.d.ts.map +1 -1
  2. package/dist/lib/event/event-initializations.js +2 -0
  3. package/dist/lib/event/event-initializations.js.map +1 -1
  4. package/dist/lib/event/event-listeners/event-listeners.d.ts +2 -0
  5. package/dist/lib/event/event-listeners/event-listeners.d.ts.map +1 -1
  6. package/dist/lib/event/event-listeners/event-listeners.js +59 -0
  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 +17 -0
  9. package/dist/lib/event/events/marketing-product-seed.event.d.ts.map +1 -0
  10. package/dist/lib/event/events/marketing-product-seed.event.js +12 -0
  11. package/dist/lib/event/events/marketing-product-seed.event.js.map +1 -0
  12. package/dist/lib/index.d.ts +224 -82
  13. package/dist/lib/index.d.ts.map +1 -1
  14. package/dist/lib/modules/coupon/routers/coupon.router.d.ts +118 -0
  15. package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
  16. package/dist/lib/modules/coupon/routers/coupon.router.js +33 -1
  17. package/dist/lib/modules/coupon/routers/coupon.router.js.map +1 -1
  18. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts +32 -0
  19. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -0
  20. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js +504 -0
  21. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js.map +1 -0
  22. package/dist/lib/modules/coupon/validations/coupon.validation.d.ts +420 -1
  23. package/dist/lib/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
  24. package/dist/lib/modules/coupon/validations/coupon.validation.js +40 -1
  25. package/dist/lib/modules/coupon/validations/coupon.validation.js.map +1 -1
  26. package/dist/lib/modules/coupon/validations/create-coupon.validation.d.ts +1118 -0
  27. package/dist/lib/modules/coupon/validations/create-coupon.validation.d.ts.map +1 -0
  28. package/dist/lib/modules/coupon/validations/create-coupon.validation.js +13 -0
  29. package/dist/lib/modules/coupon/validations/create-coupon.validation.js.map +1 -0
  30. package/dist/lib/modules/coupon/validations/index.d.ts +1 -0
  31. package/dist/lib/modules/coupon/validations/index.d.ts.map +1 -1
  32. package/dist/lib/modules/coupon/validations/index.js +1 -0
  33. package/dist/lib/modules/coupon/validations/index.js.map +1 -1
  34. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts +29 -72
  35. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
  36. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js +3 -16
  37. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.js.map +1 -1
  38. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts +36 -0
  39. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts.map +1 -0
  40. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.js +48 -0
  41. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.js.map +1 -0
  42. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.d.ts +22 -0
  43. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.d.ts.map +1 -0
  44. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.js +131 -0
  45. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.js.map +1 -0
  46. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +78 -78
  47. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts +1 -2
  48. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts.map +1 -1
  49. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.js +6 -11
  50. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.js.map +1 -1
  51. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts +16 -51
  52. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
  53. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js +33 -156
  54. package/dist/lib/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.js.map +1 -1
  55. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.builder.d.ts +8 -0
  56. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.builder.d.ts.map +1 -0
  57. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.builder.js +13 -0
  58. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.builder.js.map +1 -0
  59. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.repository.d.ts +14 -0
  60. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.repository.d.ts.map +1 -0
  61. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.repository.js +77 -0
  62. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.repository.js.map +1 -0
  63. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts +1 -2
  64. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts.map +1 -1
  65. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.service.js +19 -26
  66. package/dist/lib/modules/limited-time-offer/config/limited-time-offer-config.service.js.map +1 -1
  67. package/dist/lib/modules/limited-time-offer/config/limited-time-offer.router.d.ts.map +1 -1
  68. package/dist/lib/modules/limited-time-offer/config/limited-time-offer.router.js.map +1 -1
  69. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts +92 -77
  70. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
  71. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts +53 -0
  72. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts.map +1 -0
  73. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.js +55 -0
  74. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.js.map +1 -0
  75. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +21 -0
  76. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -0
  77. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js +142 -0
  78. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js.map +1 -0
  79. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +63 -5
  80. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
  81. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.js +8 -2
  82. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.js.map +1 -1
  83. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts +1 -0
  84. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts.map +1 -0
  85. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.js +2 -0
  86. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.js.map +1 -0
  87. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +161 -27
  88. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
  89. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js +11 -9
  90. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js.map +1 -1
  91. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts +6 -1
  92. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts.map +1 -1
  93. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.js +17 -38
  94. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.js.map +1 -1
  95. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +20 -8
  96. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  97. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js +38 -27
  98. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js.map +1 -1
  99. package/dist/lib/modules/marketing/routers/marketing.router.d.ts +12 -3
  100. package/dist/lib/modules/marketing/routers/marketing.router.d.ts.map +1 -1
  101. package/dist/lib/modules/marketing/routers/marketing.router.js +7 -0
  102. package/dist/lib/modules/marketing/routers/marketing.router.js.map +1 -1
  103. package/dist/lib/modules/marketing/services/buy1-get1-marketing.service.d.ts.map +1 -1
  104. package/dist/lib/modules/marketing/services/buy1-get1-marketing.service.js +11 -9
  105. package/dist/lib/modules/marketing/services/buy1-get1-marketing.service.js.map +1 -1
  106. package/dist/lib/modules/marketing/services/discount-marketing.service.d.ts.map +1 -1
  107. package/dist/lib/modules/marketing/services/discount-marketing.service.js +15 -13
  108. package/dist/lib/modules/marketing/services/discount-marketing.service.js.map +1 -1
  109. package/dist/lib/modules/marketing/services/marketing.service.d.ts +1 -0
  110. package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
  111. package/dist/lib/modules/marketing/services/marketing.service.js +57 -7
  112. package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -1
  113. package/dist/lib/modules/marketing/services/product-marketing.service.d.ts +11 -0
  114. package/dist/lib/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
  115. package/dist/lib/modules/marketing/services/product-marketing.service.js +23 -0
  116. package/dist/lib/modules/marketing/services/product-marketing.service.js.map +1 -1
  117. package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.d.ts.map +1 -1
  118. package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.js +6 -31
  119. package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.js.map +1 -1
  120. package/dist/lib/modules/marketing/validations/marketing.validation.d.ts +2 -2
  121. package/dist/lib/modules/marketing/validations/product-marketing.validation.d.ts +2 -2
  122. package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +2 -2
  123. package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts +1 -0
  124. package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts.map +1 -1
  125. package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.js +14 -0
  126. package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.js.map +1 -1
  127. package/dist/lib/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +4 -4
  128. package/dist/types/event/event-initializations.d.ts.map +1 -1
  129. package/dist/types/event/event-listeners/event-listeners.d.ts +2 -0
  130. package/dist/types/event/event-listeners/event-listeners.d.ts.map +1 -1
  131. package/dist/types/event/events/marketing-product-seed.event.d.ts +17 -0
  132. package/dist/types/event/events/marketing-product-seed.event.d.ts.map +1 -0
  133. package/dist/types/index.d.ts +224 -82
  134. package/dist/types/index.d.ts.map +1 -1
  135. package/dist/types/modules/coupon/routers/coupon.router.d.ts +118 -0
  136. package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
  137. package/dist/types/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts +32 -0
  138. package/dist/types/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -0
  139. package/dist/types/modules/coupon/validations/coupon.validation.d.ts +420 -1
  140. package/dist/types/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
  141. package/dist/types/modules/coupon/validations/create-coupon.validation.d.ts +1118 -0
  142. package/dist/types/modules/coupon/validations/create-coupon.validation.d.ts.map +1 -0
  143. package/dist/types/modules/coupon/validations/index.d.ts +1 -0
  144. package/dist/types/modules/coupon/validations/index.d.ts.map +1 -1
  145. package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts +29 -72
  146. package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
  147. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts +36 -0
  148. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts.map +1 -0
  149. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.d.ts +22 -0
  150. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.d.ts.map +1 -0
  151. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +78 -78
  152. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts +1 -2
  153. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts.map +1 -1
  154. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts +16 -51
  155. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
  156. package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.builder.d.ts +8 -0
  157. package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.builder.d.ts.map +1 -0
  158. package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.repository.d.ts +14 -0
  159. package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.repository.d.ts.map +1 -0
  160. package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts +1 -2
  161. package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts.map +1 -1
  162. package/dist/types/modules/limited-time-offer/config/limited-time-offer.router.d.ts.map +1 -1
  163. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts +92 -77
  164. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
  165. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts +53 -0
  166. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts.map +1 -0
  167. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +21 -0
  168. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -0
  169. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +63 -5
  170. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
  171. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +161 -27
  172. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
  173. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts +6 -1
  174. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts.map +1 -1
  175. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +20 -8
  176. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  177. package/dist/types/modules/marketing/routers/marketing.router.d.ts +12 -3
  178. package/dist/types/modules/marketing/routers/marketing.router.d.ts.map +1 -1
  179. package/dist/types/modules/marketing/services/buy1-get1-marketing.service.d.ts.map +1 -1
  180. package/dist/types/modules/marketing/services/discount-marketing.service.d.ts.map +1 -1
  181. package/dist/types/modules/marketing/services/marketing.service.d.ts +1 -0
  182. package/dist/types/modules/marketing/services/marketing.service.d.ts.map +1 -1
  183. package/dist/types/modules/marketing/services/product-marketing.service.d.ts +11 -0
  184. package/dist/types/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
  185. package/dist/types/modules/marketing/services/synchronize-product-marketing.service.d.ts.map +1 -1
  186. package/dist/types/modules/marketing/validations/marketing.validation.d.ts +2 -2
  187. package/dist/types/modules/marketing/validations/product-marketing.validation.d.ts +2 -2
  188. package/dist/types/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +2 -2
  189. package/dist/types/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts +1 -0
  190. package/dist/types/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts.map +1 -1
  191. package/dist/types/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +4 -4
  192. package/package.json +3 -3
  193. package/dist/types/events/event-initializations.d.ts +0 -2
  194. package/dist/types/events/event-initializations.d.ts.map +0 -1
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __metadata = (this && this.__metadata) || function (k, v) {
42
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.ltoParticipantRepository = exports.LtoParticipantRepository = void 0;
46
+ const typedi_1 = __importStar(require("typedi"));
47
+ const models_1 = require("@lyxa.ai/core/dist/libraries/mongo/models");
48
+ const limited_time_offer_participant_builder_1 = require("./limited-time-offer-participant.builder");
49
+ let LtoParticipantRepository = class LtoParticipantRepository {
50
+ model;
51
+ constructor() {
52
+ this.model = models_1.LimitedTimeOfferParticipantModel;
53
+ }
54
+ async create(input) {
55
+ return this.model.create(input);
56
+ }
57
+ async findActiveByCampaignAndShop(campaignId, shopId) {
58
+ const result = await this.model
59
+ .findOne({ campaign: campaignId, shop: shopId, isWithdrawn: false })
60
+ .select('discountPercentage maxDiscountCap joinedAt isEntireMenu isOrderCapacityEnabled maxOrderCapacity products marketing')
61
+ .lean();
62
+ if (!result)
63
+ return null;
64
+ const { products, marketing, ...rest } = result;
65
+ return { ...rest, productIds: products ?? [], marketingId: marketing };
66
+ }
67
+ async withdraw(campaignId, shopId) {
68
+ return this.model.findOneAndUpdate({ campaign: campaignId, shop: shopId, isWithdrawn: false }, { $set: { isWithdrawn: true, withdrawnAt: new Date() } }, { new: true });
69
+ }
70
+ async existsActiveByCampaignAndShop(campaignId, shopId) {
71
+ return !!(await this.model.exists({ campaign: campaignId, shop: shopId, isWithdrawn: false }));
72
+ }
73
+ async findActiveForUpdate(campaignId, shopId) {
74
+ const result = await this.model
75
+ .findOne({ campaign: campaignId, shop: shopId, isWithdrawn: false })
76
+ .select('marketing')
77
+ .lean();
78
+ if (!result)
79
+ return null;
80
+ return { marketingId: result.marketing };
81
+ }
82
+ async updateParticipant(campaignId, shopId, data) {
83
+ return this.model.findOneAndUpdate({ campaign: campaignId, shop: shopId, isWithdrawn: false }, { $set: data }, { new: true });
84
+ }
85
+ async findMarketingIdsByCampaign(campaignId) {
86
+ const participants = await this.model
87
+ .find({ campaign: campaignId, isWithdrawn: false, marketing: { $exists: true, $ne: null } })
88
+ .select('marketing')
89
+ .lean();
90
+ return participants.map(p => p.marketing).filter(Boolean);
91
+ }
92
+ async findByCampaign(dto) {
93
+ const filter = limited_time_offer_participant_builder_1.LtoParticipantQueryBuilder.buildCampaignFilter(dto);
94
+ const search = limited_time_offer_participant_builder_1.LtoParticipantQueryBuilder.buildSearchTerm(dto);
95
+ const [result] = await this.model.aggregate([
96
+ { $match: filter },
97
+ {
98
+ $lookup: {
99
+ from: models_1.ShopModel.collection.name,
100
+ let: { shopId: '$shop' },
101
+ pipeline: [
102
+ { $match: { $expr: { $eq: ['$_id', '$$shopId'] } } },
103
+ { $project: { name: 1, logo: 1 } },
104
+ ],
105
+ as: 'shopData',
106
+ },
107
+ },
108
+ { $unwind: { path: '$shopData', preserveNullAndEmptyArrays: true } },
109
+ ...(search ? [{ $match: { 'shopData.name': { $regex: search, $options: 'i' } } }] : []),
110
+ { $sort: { joinedAt: -1 } },
111
+ {
112
+ $facet: {
113
+ total: [{ $count: 'count' }],
114
+ documents: [
115
+ { $skip: (dto.page - 1) * dto.size },
116
+ { $limit: dto.size },
117
+ {
118
+ $project: {
119
+ shopName: { $ifNull: ['$shopData.name', null] },
120
+ shopPhoto: { $ifNull: ['$shopData.logo', null] },
121
+ joinedAt: 1,
122
+ discountPercentage: 1,
123
+ maxDiscountCap: 1,
124
+ },
125
+ },
126
+ ],
127
+ },
128
+ },
129
+ ]);
130
+ return {
131
+ documents: result?.documents ?? [],
132
+ total: result?.total?.[0]?.count ?? 0,
133
+ };
134
+ }
135
+ };
136
+ exports.LtoParticipantRepository = LtoParticipantRepository;
137
+ exports.LtoParticipantRepository = LtoParticipantRepository = __decorate([
138
+ (0, typedi_1.Service)(),
139
+ __metadata("design:paramtypes", [])
140
+ ], LtoParticipantRepository);
141
+ exports.ltoParticipantRepository = typedi_1.default.get(LtoParticipantRepository);
142
+ //# sourceMappingURL=limited-time-offer-participant.repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limited-time-offer-participant.repository.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,sEAImD;AAGnD,qGAAoF;AAI7E,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACzB,KAAK,CAAmE;IAEhF;QACI,IAAI,CAAC,KAAK,GAAG,yCAAoG,CAAC;IACtH,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAa;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,2BAA2B,CAC7B,UAAmC,EACnC,MAA+B;QAE/B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK;aAC1B,OAAO,CAAC,EAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAC,CAAC;aACjE,MAAM,CAAC,oHAAoH,CAAC;aAC5H,IAAI,EAAE,CAAC;QACZ,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QACzB,MAAM,EAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,EAAC,GAAG,MAAa,CAAC;QACrD,OAAO,EAAC,GAAG,IAAI,EAAE,UAAU,EAAE,QAAQ,IAA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oose';\nimport {\n LimitedTimeOfferParticipant as Model,\n LimitedTimeOfferParticipantModel,\n ShopModel,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {SoftDeleteModel} from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport {GetLtoCampaignParticipantsDTO, LtoCampaignParticipantItemDTO} from '../campaign/limited-time-offer-campaign.validation';\nimport {LtoParticipantQueryBuilder} from './limited-time-offer-participant.builder';\nimport {ActiveParticipantMarketingDTO, ParticipantSummaryDTO, UpdateParticipantDataDTO} from './limited-time-offer-participant.validation';\n\n@Service()\nexport class LtoParticipantRepository {\n private model: typeof LimitedTimeOfferParticipantModel & SoftDeleteModel<Model>;\n\n constructor() {\n this.model = LimitedTimeOfferParticipantModel as typeof LimitedTimeOfferParticipantModel & SoftDeleteModel<Model>;\n }\n\n async create(input: object): Promise<DocumentType<Model>> {\n return this.model.create(input);\n }\n\n async findActiveByCampaignAndShop(\n campaignId: mongoose.Types.ObjectId,\n shopId: mongoose.Types.ObjectId,\n ): Promise<ParticipantSummaryDTO | null> {\n const result = await this.model\n .findOne({campaign: campaignId, shop: shopId, isWithdrawn: false})\n .select('discountPercentage maxDiscountCap joinedAt isEntireMenu isOrderCapacityEnabled maxOrderCapacity products marketing')\n .lean();\n if (!result) return null;\n const {products, marketing, ...rest} = result as any;\n return {...rest, productIds: products ?? [], marketingId: marketing};\n }\n\n async withdraw(\n campaignId: mongoose.Types.ObjectId,\n shopId: mongoose.Types.ObjectId,\n ): Promise<DocumentType<Model> | null> {\n return this.model.findOneAndUpdate(\n {campaign: campaignId, shop: shopId, isWithdrawn: false},\n {$set: {isWithdrawn: true, withdrawnAt: new Date()}},\n {new: true},\n );\n }\n\n async existsActiveByCampaignAndShop(\n campaignId: mongoose.Types.ObjectId,\n shopId: mongoose.Types.ObjectId,\n ): Promise<boolean> {\n return !!(await this.model.exists({campaign: campaignId, shop: shopId, isWithdrawn: false}));\n }\n\n async findActiveForUpdate(\n campaignId: mongoose.Types.ObjectId,\n shopId: mongoose.Types.ObjectId,\n ): Promise<ActiveParticipantMarketingDTO | null> {\n const result = await this.model\n .findOne({campaign: campaignId, shop: shopId, isWithdrawn: false})\n .select('marketing')\n .lean();\n if (!result) return null;\n return {marketingId: (result as any).marketing};\n }\n\n async updateParticipant(\n campaignId: mongoose.Types.ObjectId,\n shopId: mongoose.Types.ObjectId,\n data: UpdateParticipantDataDTO,\n ): Promise<DocumentType<Model> | null> {\n return this.model.findOneAndUpdate(\n {campaign: campaignId, shop: shopId, isWithdrawn: false},\n {$set: data},\n {new: true},\n );\n }\n\n async findMarketingIdsByCampaign(campaignId: mongoose.Types.ObjectId): Promise<mongoose.Types.ObjectId[]> {\n const participants = await this.model\n .find({campaign: campaignId, isWithdrawn: false, marketing: {$exists: true, $ne: null}})\n .select('marketing')\n .lean();\n return participants.map(p => p.marketing as mongoose.Types.ObjectId).filter(Boolean);\n }\n\n async findByCampaign(dto: GetLtoCampaignParticipantsDTO): Promise<{documents: LtoCampaignParticipantItemDTO[]; total: number}> {\n const filter = LtoParticipantQueryBuilder.buildCampaignFilter(dto);\n const search = LtoParticipantQueryBuilder.buildSearchTerm(dto);\n\n const [result] = await this.model.aggregate([\n {$match: filter},\n {\n $lookup: {\n from: ShopModel.collection.name,\n let: {shopId: '$shop'},\n pipeline: [\n {$match: {$expr: {$eq: ['$_id', '$$shopId']}}},\n {$project: {name: 1, logo: 1}},\n ],\n as: 'shopData',\n },\n },\n {$unwind: {path: '$shopData', preserveNullAndEmptyArrays: true}},\n ...(search ? [{$match: {'shopData.name': {$regex: search, $options: 'i'}}}] : []),\n {$sort: {joinedAt: -1}},\n {\n $facet: {\n total: [{$count: 'count'}],\n documents: [\n {$skip: (dto.page - 1) * dto.size},\n {$limit: dto.size},\n {\n $project: {\n shopName: {$ifNull: ['$shopData.name', null]},\n shopPhoto: {$ifNull: ['$shopData.logo', null]},\n joinedAt: 1,\n discountPercentage: 1,\n maxDiscountCap: 1,\n },\n },\n ],\n },\n },\n ]);\n\n return {\n documents: result?.documents ?? [],\n total: result?.total?.[0]?.count ?? 0,\n };\n }\n}\n\nexport const ltoParticipantRepository = Container.get(LtoParticipantRepository);\n"]}
@@ -32,8 +32,8 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
32
32
  shop: string | mongoose.Types.ObjectId;
33
33
  joinedAt: Date;
34
34
  isEntireMenu: boolean;
35
- isOrderCapacityEnabled: boolean;
36
35
  campaign: string | mongoose.Types.ObjectId;
36
+ isOrderCapacityEnabled: boolean;
37
37
  isWithdrawn: boolean;
38
38
  createdAt?: Date | null | undefined;
39
39
  updatedAt?: Date | null | undefined;
@@ -48,8 +48,62 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
48
48
  shop: string | mongoose.Types.ObjectId;
49
49
  joinedAt: Date;
50
50
  isEntireMenu: boolean;
51
+ campaign: string | mongoose.Types.ObjectId;
51
52
  isOrderCapacityEnabled: boolean;
53
+ isWithdrawn: boolean;
54
+ createdAt?: Date | null | undefined;
55
+ updatedAt?: Date | null | undefined;
56
+ products?: (string | mongoose.Types.ObjectId)[] | undefined;
57
+ discountPercentage?: number | undefined;
58
+ maxDiscountCap?: number | undefined;
59
+ maxOrderCapacity?: number | undefined;
60
+ withdrawnAt?: Date | null | undefined;
61
+ }[];
62
+ metadata?: {
63
+ page: number;
64
+ size: number;
65
+ totalElements: number;
66
+ totalPages: number;
67
+ } | undefined;
68
+ } | undefined;
69
+ };
70
+ meta: object;
71
+ }>;
72
+ update: import("@trpc/server").TRPCMutationProcedure<{
73
+ input: {
74
+ isEntireMenu: boolean;
75
+ discountPercentage: number;
76
+ maxDiscountCap: number;
77
+ isOrderCapacityEnabled: boolean;
78
+ products?: (string | mongoose.Types.ObjectId)[] | undefined;
79
+ maxOrderCapacity?: number | undefined;
80
+ };
81
+ output: {
82
+ message: string;
83
+ success: boolean;
84
+ data?: {
85
+ _id: string | mongoose.Types.ObjectId;
86
+ shop: string | mongoose.Types.ObjectId;
87
+ joinedAt: Date;
88
+ isEntireMenu: boolean;
89
+ campaign: string | mongoose.Types.ObjectId;
90
+ isOrderCapacityEnabled: boolean;
91
+ isWithdrawn: boolean;
92
+ createdAt?: Date | null | undefined;
93
+ updatedAt?: Date | null | undefined;
94
+ products?: (string | mongoose.Types.ObjectId)[] | undefined;
95
+ discountPercentage?: number | undefined;
96
+ maxDiscountCap?: number | undefined;
97
+ maxOrderCapacity?: number | undefined;
98
+ withdrawnAt?: Date | null | undefined;
99
+ } | {
100
+ documents: {
101
+ _id: string | mongoose.Types.ObjectId;
102
+ shop: string | mongoose.Types.ObjectId;
103
+ joinedAt: Date;
104
+ isEntireMenu: boolean;
52
105
  campaign: string | mongoose.Types.ObjectId;
106
+ isOrderCapacityEnabled: boolean;
53
107
  isWithdrawn: boolean;
54
108
  createdAt?: Date | null | undefined;
55
109
  updatedAt?: Date | null | undefined;
@@ -86,9 +140,9 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
86
140
  campaignState: import("./limited-time-offer-participant.validation").LtoCardState;
87
141
  campaign?: {
88
142
  _id: string | mongoose.Types.ObjectId;
89
- title?: string | undefined;
90
143
  startDate?: Date | null | undefined;
91
144
  endDate?: Date | null | undefined;
145
+ title?: string | undefined;
92
146
  subTitle?: string | undefined;
93
147
  discountOptions?: number[] | undefined;
94
148
  maxDiscountCaps?: number[] | undefined;
@@ -97,6 +151,8 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
97
151
  joinedAt: Date;
98
152
  isEntireMenu: boolean;
99
153
  isOrderCapacityEnabled: boolean;
154
+ productIds?: (string | mongoose.Types.ObjectId)[] | undefined;
155
+ marketingId?: string | mongoose.Types.ObjectId | undefined;
100
156
  discountPercentage?: number | undefined;
101
157
  maxDiscountCap?: number | undefined;
102
158
  maxOrderCapacity?: number | undefined;
@@ -106,9 +162,9 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
106
162
  campaignState: import("./limited-time-offer-participant.validation").LtoCardState;
107
163
  campaign?: {
108
164
  _id: string | mongoose.Types.ObjectId;
109
- title?: string | undefined;
110
165
  startDate?: Date | null | undefined;
111
166
  endDate?: Date | null | undefined;
167
+ title?: string | undefined;
112
168
  subTitle?: string | undefined;
113
169
  discountOptions?: number[] | undefined;
114
170
  maxDiscountCaps?: number[] | undefined;
@@ -117,6 +173,8 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
117
173
  joinedAt: Date;
118
174
  isEntireMenu: boolean;
119
175
  isOrderCapacityEnabled: boolean;
176
+ productIds?: (string | mongoose.Types.ObjectId)[] | undefined;
177
+ marketingId?: string | mongoose.Types.ObjectId | undefined;
120
178
  discountPercentage?: number | undefined;
121
179
  maxDiscountCap?: number | undefined;
122
180
  maxOrderCapacity?: number | undefined;
@@ -145,16 +203,16 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
145
203
  data?: {
146
204
  joinedAt: Date;
147
205
  shopName: string | null;
206
+ shopPhoto?: string | null | undefined;
148
207
  discountPercentage?: number | undefined;
149
208
  maxDiscountCap?: number | undefined;
150
- shopPhoto?: string | null | undefined;
151
209
  } | {
152
210
  documents: {
153
211
  joinedAt: Date;
154
212
  shopName: string | null;
213
+ shopPhoto?: string | null | undefined;
155
214
  discountPercentage?: number | undefined;
156
215
  maxDiscountCap?: number | undefined;
157
- shopPhoto?: string | null | undefined;
158
216
  }[];
159
217
  metadata?: {
160
218
  page: number;
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer-participant.router.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.router.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAY9C,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsC5B,CAAC"}
1
+ {"version":3,"file":"limited-time-offer-participant.router.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.router.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAY9C,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgD5B,CAAC"}
@@ -7,7 +7,6 @@ const auth_2 = require("@lyxa.ai/core/dist/libraries/trpc/middlewares/auth");
7
7
  const error_handler_1 = require("@lyxa.ai/core/dist/utilities/error-handler");
8
8
  const response_1 = require("@lyxa.ai/core/dist/utilities/response");
9
9
  const limited_time_offer_participant_service_1 = require("./services/limited-time-offer-participant.service");
10
- const limited_time_offer_campaign_service_1 = require("../campaign/services/limited-time-offer-campaign.service");
11
10
  const limited_time_offer_participant_validation_1 = require("./limited-time-offer-participant.validation");
12
11
  const limited_time_offer_campaign_validation_1 = require("../campaign/limited-time-offer-campaign.validation");
13
12
  const typegoose_1 = require("@typegoose/typegoose");
@@ -28,6 +27,13 @@ exports.participantRouter = (0, trpc_1.createTRPCRouter)({
28
27
  const result = await limited_time_offer_participant_service_1.ltoParticipantService.join(resolveShopId(ctx), input);
29
28
  return (0, response_1.response)('Successfully joined the campaign', result);
30
29
  })),
30
+ update: sellerProcedure
31
+ .input(limited_time_offer_participant_validation_1.JoinLtoCampaignSchema)
32
+ .output(limited_time_offer_participant_validation_1.ParticipantResponseSchema)
33
+ .mutation(async ({ input, ctx }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
34
+ const result = await limited_time_offer_participant_service_1.ltoParticipantService.update(resolveShopId(ctx), input);
35
+ return (0, response_1.response)('Participation updated successfully', result);
36
+ })),
31
37
  withdraw: sellerProcedure
32
38
  .output(limited_time_offer_campaign_validation_1.LtoEmptyResponseSchema)
33
39
  .mutation(async ({ ctx }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
@@ -44,7 +50,7 @@ exports.participantRouter = (0, trpc_1.createTRPCRouter)({
44
50
  .input(limited_time_offer_campaign_validation_1.GetLtoCampaignParticipantsSchema)
45
51
  .output(limited_time_offer_campaign_validation_1.LtoCampaignParticipantsResponseSchema)
46
52
  .query(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
47
- const result = await limited_time_offer_campaign_service_1.ltoCampaignService.getParticipants(input);
53
+ const result = await limited_time_offer_participant_service_1.ltoParticipantService.getParticipants(input);
48
54
  return (0, response_1.response)('Participants fetched successfully', result);
49
55
  })),
50
56
  });
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer-participant.router.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.router.ts"],"names":[],"mappings":";;;AAAA,4DAAmE;AACnE,4DAAiE;AACjE,6EAAgG;AAChG,8EAAwE;AACxE,oEAA+D;AAC/D,8GAAmG;AACnG,kHAA+G;AAC/G,2GAIqD;AACrD,+GAI4D;AAC5D,oDAA8C;AAC9C,4EAA0E;AAE1E,MAAM,eAAe,GAAG,IAAA,mCAA4B,EAAC,EAAC,WAAW,EAAE,CAAC,qBAAc,CAAC,MAAM,CAAC,EAAC,CAAC,CAAC;AAC7F,MAAM,YAAY,GAAG,IAAA,mCAA4B,EAAC,EAAC,WAAW,EAAE,CAAC,qBAAc,CAAC,GAAG,CAAC,EAAC,CAAC,CAAC;AAEvF,SAAS,aAAa,CAAC,GAAiE;IACpF,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,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aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3D,OAAO,IAAA,mBAAQ,EAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC,CAAC,CACL;IAEL,eAAe,EAAE,YAAY;SACxB,KAAK,CAAC,yEAAgC,CAAC;SACvC,MAAM,CAAC,8EAAqC,CAAC;SAC7C,KAAK,CAAC,KAAK,EAAE,EAAC,KAAK,EAAC,EAAE,EAAE,CACrB,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,MAAM,MAAM,GAAG,MAAM,wDAAe,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAC5D,OAAO,IAAA,mBAAQ,EAAC,mCAAmC,EAAE,MAAM,CAAC,CAAC;IACjE,CAAC,CAAC,CACL;CACR,CAAC,CAAC","sourcesContent":["import {createTRPCRouter} from '@lyxa.ai/core/dist/libraries/trpc';\nimport {AuthEntityType} from '@lyxa.ai/core/dist/libraries/auth';\nimport {createAuthenticatedProcedure} from '@lyxa.ai/core/dist/libraries/trpc/middlewares/auth';\nimport {ErrorHandler} from '@lyxa.ai/core/dist/utilities/error-handler';\nimport {response} from '@lyxa.ai/core/dist/utilities/response';\nimport {ltoParticipantService as service} from './services/limited-time-offer-participant.service';\nimport {ltoCampaignService as campaignService} from '../campaign/services/limited-time-offer-campaign.service';\nimport {\n JoinLtoCampaignSchema,\n ParticipantResponseSchema,\n ParticipantStatusResponseSchema,\n} from './limited-time-offer-participant.validation';\nimport {\n GetLtoCampaignParticipantsSchema,\n LtoCampaignParticipantsResponseSchema,\n LtoEmptyResponseSchema,\n} from '../campaign/limited-time-offer-campaign.validation';\nimport {mongoose} from '@typegoose/typegoose';\nimport {badRequestError} from '@lyxa.ai/core/dist/utilities/error-common';\n\nconst sellerProcedure = createAuthenticatedProcedure({entityTypes: [AuthEntityType.SELLER]});\nconst crmProcedure = createAuthenticatedProcedure({entityTypes: [AuthEntityType.CRM]});\n\nfunction resolveShopId(ctx: { entity?: { parameters?: Record<string, unknown> } | null }): mongoose.Types.ObjectId {\n const shops = ctx.entity?.parameters?.shops as string[] | undefined;\n if (!shops || shops.length === 0) throw badRequestError('No shop associated with this account');\n return new mongoose.Types.ObjectId(shops[0]);\n}\n\nexport const participantRouter = createTRPCRouter({\n join: sellerProcedure\n .input(JoinLtoCampaignSchema)\n .output(ParticipantResponseSchema)\n .mutation(async ({input, ctx}) =>\n ErrorHandler.wrapAsync(async () => {\n const result = await service.join(resolveShopId(ctx), input);\n return response('Successfully joined the campaign', result as any);\n })\n ),\n\n withdraw: sellerProcedure\n .output(LtoEmptyResponseSchema)\n .mutation(async ({ctx}) =>\n ErrorHandler.wrapAsync(async () => {\n await service.withdraw(resolveShopId(ctx));\n return response('Successfully withdrawn from the campaign');\n })\n ),\n\n getStatus: sellerProcedure\n .output(ParticipantStatusResponseSchema)\n .query(async ({ctx}) =>\n ErrorHandler.wrapAsync(async () => {\n const result = await service.getStatus(resolveShopId(ctx));\n return response('Status fetched successfully', result);\n })\n ),\n\n getParticipants: crmProcedure\n .input(GetLtoCampaignParticipantsSchema)\n .output(LtoCampaignParticipantsResponseSchema)\n .query(async ({input}) =>\n ErrorHandler.wrapAsync(async () => {\n const result = await campaignService.getParticipants(input);\n return response('Participants fetched successfully', result);\n })\n ),\n});\n"]}
1
+ {"version":3,"file":"limited-time-offer-participant.router.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.router.ts"],"names":[],"mappings":";;;AAAA,4DAAmE;AACnE,4DAAiE;AACjE,6EAAgG;AAChG,8EAAwE;AACxE,oEAA+D;AAC/D,8GAAmG;AACnG,2GAIqD;AACrD,+GAI4D;AAC5D,oDAA8C;AAC9C,4EAA0E;AAE1E,MAAM,eAAe,GAAG,IAAA,mCAA4B,EAAC,EAAC,WAAW,EAAE,CAAC,qBAAc,CAAC,MAAM,CAAC,EAAC,CAAC,CAAC;AAC7F,MAAM,YAAY,GAAG,IAAA,mCAA4B,EAAC,EAAC,WAAW,E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AAC,CACL;IAEL,QAAQ,EAAE,eAAe;SACpB,MAAM,CAAC,+DAAsB,CAAC;SAC9B,QAAQ,CAAC,KAAK,EAAE,EAAC,GAAG,EAAC,EAAE,EAAE,CACtB,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,MAAM,8DAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3C,OAAO,IAAA,mBAAQ,EAAC,0CAA0C,CAAC,CAAC;IAChE,CAAC,CAAC,CACL;IAEL,SAAS,EAAE,eAAe;SACrB,MAAM,CAAC,2EAA+B,CAAC;SACvC,KAAK,CAAC,KAAK,EAAE,EAAC,GAAG,EAAC,EAAE,EAAE,CACnB,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,MAAM,MAAM,GAAG,MAAM,8DAAO,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3D,OAAO,IAAA,mBAAQ,EAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC,CAAC,CACL;IAEL,eAAe,EAAE,YAAY;SACxB,KAAK,CAAC,yEAAgC,CAAC;SACvC,MAAM,CAAC,8EAAqC,CAAC;SAC7C,KAAK,CAAC,KAAK,EAAE,EAAC,KAAK,EAAC,EAAE,EAAE,CACrB,4BAAY,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;QAC9B,MAAM,MAAM,GAAG,MAAM,8DAAO,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QACpD,OAAO,IAAA,mBAAQ,EAAC,mCAAmC,EAAE,MAAM,CAAC,CAAC;IACjE,CAAC,CAAC,CACL;CACR,CAAC,CAAC","sourcesContent":["import {createTRPCRouter} from '@lyxa.ai/core/dist/libraries/trpc';\nimport {AuthEntityType} from '@lyxa.ai/core/dist/libraries/auth';\nimport {createAuthenticatedProcedure} from '@lyxa.ai/core/dist/libraries/trpc/middlewares/auth';\nimport {ErrorHandler} from '@lyxa.ai/core/dist/utilities/error-handler';\nimport {response} from '@lyxa.ai/core/dist/utilities/response';\nimport {ltoParticipantService as service} from './services/limited-time-offer-participant.service';\nimport {\n JoinLtoCampaignSchema,\n ParticipantResponseSchema,\n ParticipantStatusResponseSchema,\n} from './limited-time-offer-participant.validation';\nimport {\n GetLtoCampaignParticipantsSchema,\n LtoCampaignParticipantsResponseSchema,\n LtoEmptyResponseSchema,\n} from '../campaign/limited-time-offer-campaign.validation';\nimport {mongoose} from '@typegoose/typegoose';\nimport {badRequestError} from '@lyxa.ai/core/dist/utilities/error-common';\n\nconst sellerProcedure = createAuthenticatedProcedure({entityTypes: [AuthEntityType.SELLER]});\nconst crmProcedure = createAuthenticatedProcedure({entityTypes: [AuthEntityType.CRM]});\n\nfunction resolveShopId(ctx: { entity?: { parameters?: Record<string, unknown> } | null }): mongoose.Types.ObjectId {\n const shops = ctx.entity?.parameters?.shops as string[] | undefined;\n if (!shops || shops.length === 0) throw badRequestError('No shop associated with this account');\n return new mongoose.Types.ObjectId(shops[0]);\n}\n\nexport const participantRouter = createTRPCRouter({\n join: sellerProcedure\n .input(JoinLtoCampaignSchema)\n .output(ParticipantResponseSchema)\n .mutation(async ({input, ctx}) =>\n ErrorHandler.wrapAsync(async () => {\n const result = await service.join(resolveShopId(ctx), input);\n return response('Successfully joined the campaign', result as any);\n })\n ),\n\n update: sellerProcedure\n .input(JoinLtoCampaignSchema)\n .output(ParticipantResponseSchema)\n .mutation(async ({input, ctx}) =>\n ErrorHandler.wrapAsync(async () => {\n const result = await service.update(resolveShopId(ctx), input);\n return response('Participation updated successfully', result as any);\n })\n ),\n\n withdraw: sellerProcedure\n .output(LtoEmptyResponseSchema)\n .mutation(async ({ctx}) =>\n ErrorHandler.wrapAsync(async () => {\n await service.withdraw(resolveShopId(ctx));\n return response('Successfully withdrawn from the campaign');\n })\n ),\n\n getStatus: sellerProcedure\n .output(ParticipantStatusResponseSchema)\n .query(async ({ctx}) =>\n ErrorHandler.wrapAsync(async () => {\n const result = await service.getStatus(resolveShopId(ctx));\n return response('Status fetched successfully', result);\n })\n ),\n\n getParticipants: crmProcedure\n .input(GetLtoCampaignParticipantsSchema)\n .output(LtoCampaignParticipantsResponseSchema)\n .query(async ({input}) =>\n ErrorHandler.wrapAsync(async () => {\n const result = await service.getParticipants(input);\n return response('Participants fetched successfully', result);\n })\n ),\n});\n"]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=limited-time-offer-participant.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limited-time-offer-participant.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.service.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=limited-time-offer-participant.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limited-time-offer-participant.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.service.ts"],"names":[],"mappings":"","sourcesContent":[""]}