@lyxa.ai/marketing 1.0.42 → 1.0.43

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 (184) hide show
  1. package/dist/lib/event/event-initializations.d.ts.map +1 -1
  2. package/dist/lib/event/event-initializations.js +1 -0
  3. package/dist/lib/event/event-initializations.js.map +1 -1
  4. package/dist/lib/event/event-listeners/event-listeners.d.ts +1 -0
  5. package/dist/lib/event/event-listeners/event-listeners.d.ts.map +1 -1
  6. package/dist/lib/event/event-listeners/event-listeners.js +52 -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 +165 -83
  13. package/dist/lib/index.d.ts.map +1 -1
  14. package/dist/lib/modules/coupon/routers/coupon.router.d.ts +116 -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 +503 -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 +407 -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 +39 -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 +35 -78
  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 +18 -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 +126 -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 +6 -6
  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 +1 -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 +24 -24
  88. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts +3 -1
  89. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts.map +1 -1
  90. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.js +13 -38
  91. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.js.map +1 -1
  92. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +19 -8
  93. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  94. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js +19 -27
  95. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js.map +1 -1
  96. package/dist/lib/modules/marketing/routers/marketing.router.d.ts +12 -3
  97. package/dist/lib/modules/marketing/routers/marketing.router.d.ts.map +1 -1
  98. package/dist/lib/modules/marketing/routers/marketing.router.js +7 -0
  99. package/dist/lib/modules/marketing/routers/marketing.router.js.map +1 -1
  100. package/dist/lib/modules/marketing/services/buy1-get1-marketing.service.d.ts.map +1 -1
  101. package/dist/lib/modules/marketing/services/buy1-get1-marketing.service.js +11 -9
  102. package/dist/lib/modules/marketing/services/buy1-get1-marketing.service.js.map +1 -1
  103. package/dist/lib/modules/marketing/services/discount-marketing.service.d.ts.map +1 -1
  104. package/dist/lib/modules/marketing/services/discount-marketing.service.js +15 -13
  105. package/dist/lib/modules/marketing/services/discount-marketing.service.js.map +1 -1
  106. package/dist/lib/modules/marketing/services/marketing.service.d.ts +1 -0
  107. package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
  108. package/dist/lib/modules/marketing/services/marketing.service.js +57 -7
  109. package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -1
  110. package/dist/lib/modules/marketing/services/product-marketing.service.d.ts +11 -0
  111. package/dist/lib/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
  112. package/dist/lib/modules/marketing/services/product-marketing.service.js +23 -0
  113. package/dist/lib/modules/marketing/services/product-marketing.service.js.map +1 -1
  114. package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.d.ts.map +1 -1
  115. package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.js +6 -31
  116. package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.js.map +1 -1
  117. package/dist/lib/modules/marketing/validations/marketing.validation.d.ts +2 -2
  118. package/dist/lib/modules/marketing/validations/product-marketing.validation.d.ts +2 -2
  119. package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +2 -2
  120. package/dist/lib/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +4 -4
  121. package/dist/types/event/event-initializations.d.ts.map +1 -1
  122. package/dist/types/event/event-listeners/event-listeners.d.ts +1 -0
  123. package/dist/types/event/event-listeners/event-listeners.d.ts.map +1 -1
  124. package/dist/types/event/events/marketing-product-seed.event.d.ts +17 -0
  125. package/dist/types/event/events/marketing-product-seed.event.d.ts.map +1 -0
  126. package/dist/types/index.d.ts +165 -83
  127. package/dist/types/index.d.ts.map +1 -1
  128. package/dist/types/modules/coupon/routers/coupon.router.d.ts +116 -0
  129. package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
  130. package/dist/types/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts +32 -0
  131. package/dist/types/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -0
  132. package/dist/types/modules/coupon/validations/coupon.validation.d.ts +407 -1
  133. package/dist/types/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
  134. package/dist/types/modules/coupon/validations/create-coupon.validation.d.ts +1118 -0
  135. package/dist/types/modules/coupon/validations/create-coupon.validation.d.ts.map +1 -0
  136. package/dist/types/modules/coupon/validations/index.d.ts +1 -0
  137. package/dist/types/modules/coupon/validations/index.d.ts.map +1 -1
  138. package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts +29 -72
  139. package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts.map +1 -1
  140. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts +36 -0
  141. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.builder.d.ts.map +1 -0
  142. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.d.ts +22 -0
  143. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.repository.d.ts.map +1 -0
  144. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +78 -78
  145. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts +1 -2
  146. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign-lifecycle.service.d.ts.map +1 -1
  147. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts +16 -51
  148. package/dist/types/modules/limited-time-offer/campaign/services/limited-time-offer-campaign.service.d.ts.map +1 -1
  149. package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.builder.d.ts +8 -0
  150. package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.builder.d.ts.map +1 -0
  151. package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.repository.d.ts +14 -0
  152. package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.repository.d.ts.map +1 -0
  153. package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts +1 -2
  154. package/dist/types/modules/limited-time-offer/config/limited-time-offer-config.service.d.ts.map +1 -1
  155. package/dist/types/modules/limited-time-offer/config/limited-time-offer.router.d.ts.map +1 -1
  156. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts +35 -78
  157. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
  158. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts +53 -0
  159. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.builder.d.ts.map +1 -0
  160. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +18 -0
  161. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -0
  162. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +6 -6
  163. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
  164. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +24 -24
  165. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts +3 -1
  166. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts.map +1 -1
  167. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +19 -8
  168. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  169. package/dist/types/modules/marketing/routers/marketing.router.d.ts +12 -3
  170. package/dist/types/modules/marketing/routers/marketing.router.d.ts.map +1 -1
  171. package/dist/types/modules/marketing/services/buy1-get1-marketing.service.d.ts.map +1 -1
  172. package/dist/types/modules/marketing/services/discount-marketing.service.d.ts.map +1 -1
  173. package/dist/types/modules/marketing/services/marketing.service.d.ts +1 -0
  174. package/dist/types/modules/marketing/services/marketing.service.d.ts.map +1 -1
  175. package/dist/types/modules/marketing/services/product-marketing.service.d.ts +11 -0
  176. package/dist/types/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
  177. package/dist/types/modules/marketing/services/synchronize-product-marketing.service.d.ts.map +1 -1
  178. package/dist/types/modules/marketing/validations/marketing.validation.d.ts +2 -2
  179. package/dist/types/modules/marketing/validations/product-marketing.validation.d.ts +2 -2
  180. package/dist/types/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +2 -2
  181. package/dist/types/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +4 -4
  182. package/package.json +2 -2
  183. package/dist/types/events/event-initializations.d.ts +0 -2
  184. package/dist/types/events/event-initializations.d.ts.map +0 -1
@@ -0,0 +1,126 @@
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
+ return this.model
59
+ .findOne({ campaign: campaignId, shop: shopId, isWithdrawn: false })
60
+ .select('discountPercentage maxDiscountCap joinedAt isEntireMenu isOrderCapacityEnabled maxOrderCapacity')
61
+ .lean();
62
+ }
63
+ async withdraw(campaignId, shopId) {
64
+ return this.model.findOneAndUpdate({ campaign: campaignId, shop: shopId, isWithdrawn: false }, { $set: { isWithdrawn: true, withdrawnAt: new Date() } }, { new: true });
65
+ }
66
+ async existsActiveByCampaignAndShop(campaignId, shopId) {
67
+ return !!(await this.model.exists({ campaign: campaignId, shop: shopId, isWithdrawn: false }));
68
+ }
69
+ async findMarketingIdsByCampaign(campaignId) {
70
+ const participants = await this.model
71
+ .find({ campaign: campaignId, isWithdrawn: false, marketing: { $exists: true, $ne: null } })
72
+ .select('marketing')
73
+ .lean();
74
+ return participants.map(p => p.marketing).filter(Boolean);
75
+ }
76
+ async findByCampaign(dto) {
77
+ const filter = limited_time_offer_participant_builder_1.LtoParticipantQueryBuilder.buildCampaignFilter(dto);
78
+ const search = limited_time_offer_participant_builder_1.LtoParticipantQueryBuilder.buildSearchTerm(dto);
79
+ const [result] = await this.model.aggregate([
80
+ { $match: filter },
81
+ {
82
+ $lookup: {
83
+ from: models_1.ShopModel.collection.name,
84
+ let: { shopId: '$shop' },
85
+ pipeline: [
86
+ { $match: { $expr: { $eq: ['$_id', '$$shopId'] } } },
87
+ { $project: { name: 1, logo: 1 } },
88
+ ],
89
+ as: 'shopData',
90
+ },
91
+ },
92
+ { $unwind: { path: '$shopData', preserveNullAndEmptyArrays: true } },
93
+ ...(search ? [{ $match: { 'shopData.name': { $regex: search, $options: 'i' } } }] : []),
94
+ { $sort: { joinedAt: -1 } },
95
+ {
96
+ $facet: {
97
+ total: [{ $count: 'count' }],
98
+ documents: [
99
+ { $skip: (dto.page - 1) * dto.size },
100
+ { $limit: dto.size },
101
+ {
102
+ $project: {
103
+ shopName: { $ifNull: ['$shopData.name', null] },
104
+ shopPhoto: { $ifNull: ['$shopData.logo', null] },
105
+ joinedAt: 1,
106
+ discountPercentage: 1,
107
+ maxDiscountCap: 1,
108
+ },
109
+ },
110
+ ],
111
+ },
112
+ },
113
+ ]);
114
+ return {
115
+ documents: result?.documents ?? [],
116
+ total: result?.total?.[0]?.count ?? 0,
117
+ };
118
+ }
119
+ };
120
+ exports.LtoParticipantRepository = LtoParticipantRepository;
121
+ exports.LtoParticipantRepository = LtoParticipantRepository = __decorate([
122
+ (0, typedi_1.Service)(),
123
+ __metadata("design:paramtypes", [])
124
+ ], LtoParticipantRepository);
125
+ exports.ltoParticipantRepository = typedi_1.default.get(LtoParticipantRepository);
126
+ //# 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;AAG7E,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACzB,KAAK,CAAmE;IAEhF;QACI,IAAI,CAAC,KAAK,GAAG,yCAAoG,CAAC;IACtH,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAa;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,2BAA2B,CAC7B,UAAmC,EACnC,MAA+B;QAE/B,OAAO,IAAI,CAAC,KAAK;aACZ,OAAO,CAAC,EAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,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C,EAAC;gCAC7C,SAAS,EAAE,EAAC,OAAO,EAAE,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAC;gCAC9C,QAAQ,EAAE,CAAC;gCACX,kBAAkB,EAAE,CAAC;gCACrB,cAAc,EAAE,CAAC;6BACpB;yBACJ;qBACJ;iBACJ;aACJ;SACJ,CAAC,CAAC;QAEH,OAAO;YACH,SAAS,EAAE,MAAM,EAAE,SAAS,IAAI,EAAE;YAClC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC;SACxC,CAAC;IACN,CAAC;CACJ,CAAA;AA5FY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,gBAAO,GAAE;;GACG,wBAAwB,CA4FpC;AAEY,QAAA,wBAAwB,GAAG,gBAAS,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {DocumentType, mongoose} from '@typegoose/typegoose';\nimport {\n LimitedTimeOfferParticipant as Model,\n LimitedTimeOfferParticipantModel,\n ShopModel,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {SoftDeleteModel} from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport {GetLtoCampaignParticipantsDTO, LtoCampaignParticipantItemDTO} from '../campaign/limited-time-offer-campaign.validation';\nimport {LtoParticipantQueryBuilder} from './limited-time-offer-participant.builder';\n\n@Service()\nexport class LtoParticipantRepository {\n private model: typeof LimitedTimeOfferParticipantModel & SoftDeleteModel<Model>;\n\n constructor() {\n this.model = LimitedTimeOfferParticipantModel as typeof LimitedTimeOfferParticipantModel & SoftDeleteModel<Model>;\n }\n\n async create(input: object): Promise<DocumentType<Model>> {\n return this.model.create(input);\n }\n\n async findActiveByCampaignAndShop(\n campaignId: mongoose.Types.ObjectId,\n shopId: mongoose.Types.ObjectId,\n ): Promise<Pick<Model, 'discountPercentage' | 'maxDiscountCap' | 'joinedAt' | 'isEntireMenu' | 'isOrderCapacityEnabled' | 'maxOrderCapacity'> | null> {\n return this.model\n .findOne({campaign: campaignId, shop: shopId, isWithdrawn: false})\n .select('discountPercentage maxDiscountCap joinedAt isEntireMenu isOrderCapacityEnabled maxOrderCapacity')\n .lean() as any;\n }\n\n async withdraw(\n campaignId: mongoose.Types.ObjectId,\n shopId: mongoose.Types.ObjectId,\n ): Promise<DocumentType<Model> | null> {\n return this.model.findOneAndUpdate(\n {campaign: campaignId, shop: shopId, isWithdrawn: false},\n {$set: {isWithdrawn: true, withdrawnAt: new Date()}},\n {new: true},\n );\n }\n\n async existsActiveByCampaignAndShop(\n campaignId: mongoose.Types.ObjectId,\n shopId: mongoose.Types.ObjectId,\n ): Promise<boolean> {\n return !!(await this.model.exists({campaign: campaignId, shop: shopId, isWithdrawn: false}));\n }\n\n async findMarketingIdsByCampaign(campaignId: mongoose.Types.ObjectId): Promise<mongoose.Types.ObjectId[]> {\n const participants = await this.model\n .find({campaign: campaignId, isWithdrawn: false, marketing: {$exists: true, $ne: null}})\n .select('marketing')\n .lean();\n return participants.map(p => p.marketing as mongoose.Types.ObjectId).filter(Boolean);\n }\n\n async findByCampaign(dto: GetLtoCampaignParticipantsDTO): Promise<{documents: LtoCampaignParticipantItemDTO[]; total: number}> {\n const filter = LtoParticipantQueryBuilder.buildCampaignFilter(dto);\n const search = LtoParticipantQueryBuilder.buildSearchTerm(dto);\n\n const [result] = await this.model.aggregate([\n {$match: filter},\n {\n $lookup: {\n from: ShopModel.collection.name,\n let: {shopId: '$shop'},\n pipeline: [\n {$match: {$expr: {$eq: ['$_id', '$$shopId']}}},\n {$project: {name: 1, logo: 1}},\n ],\n as: 'shopData',\n },\n },\n {$unwind: {path: '$shopData', preserveNullAndEmptyArrays: true}},\n ...(search ? [{$match: {'shopData.name': {$regex: search, $options: 'i'}}}] : []),\n {$sort: {joinedAt: -1}},\n {\n $facet: {\n total: [{$count: 'count'}],\n documents: [\n {$skip: (dto.page - 1) * dto.size},\n {$limit: dto.size},\n {\n $project: {\n shopName: {$ifNull: ['$shopData.name', null]},\n shopPhoto: {$ifNull: ['$shopData.logo', null]},\n joinedAt: 1,\n discountPercentage: 1,\n maxDiscountCap: 1,\n },\n },\n ],\n },\n },\n ]);\n\n return {\n documents: result?.documents ?? [],\n total: result?.total?.[0]?.count ?? 0,\n };\n }\n}\n\nexport const ltoParticipantRepository = Container.get(LtoParticipantRepository);\n"]}
@@ -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,8 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
48
48
  shop: string | mongoose.Types.ObjectId;
49
49
  joinedAt: Date;
50
50
  isEntireMenu: boolean;
51
- isOrderCapacityEnabled: boolean;
52
51
  campaign: string | mongoose.Types.ObjectId;
52
+ isOrderCapacityEnabled: boolean;
53
53
  isWithdrawn: boolean;
54
54
  createdAt?: Date | null | undefined;
55
55
  updatedAt?: Date | null | undefined;
@@ -86,9 +86,9 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
86
86
  campaignState: import("./limited-time-offer-participant.validation").LtoCardState;
87
87
  campaign?: {
88
88
  _id: string | mongoose.Types.ObjectId;
89
- title?: string | undefined;
90
89
  startDate?: Date | null | undefined;
91
90
  endDate?: Date | null | undefined;
91
+ title?: string | undefined;
92
92
  subTitle?: string | undefined;
93
93
  discountOptions?: number[] | undefined;
94
94
  maxDiscountCaps?: number[] | undefined;
@@ -106,9 +106,9 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
106
106
  campaignState: import("./limited-time-offer-participant.validation").LtoCardState;
107
107
  campaign?: {
108
108
  _id: string | mongoose.Types.ObjectId;
109
- title?: string | undefined;
110
109
  startDate?: Date | null | undefined;
111
110
  endDate?: Date | null | undefined;
111
+ title?: string | undefined;
112
112
  subTitle?: string | undefined;
113
113
  discountOptions?: number[] | undefined;
114
114
  maxDiscountCaps?: number[] | undefined;
@@ -145,16 +145,16 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
145
145
  data?: {
146
146
  joinedAt: Date;
147
147
  shopName: string | null;
148
+ shopPhoto?: string | null | undefined;
148
149
  discountPercentage?: number | undefined;
149
150
  maxDiscountCap?: number | undefined;
150
- shopPhoto?: string | null | undefined;
151
151
  } | {
152
152
  documents: {
153
153
  joinedAt: Date;
154
154
  shopName: string | null;
155
+ shopPhoto?: string | null | undefined;
155
156
  discountPercentage?: number | undefined;
156
157
  maxDiscountCap?: number | undefined;
157
- shopPhoto?: string | null | undefined;
158
158
  }[];
159
159
  metadata?: {
160
160
  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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsC5B,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");
@@ -44,7 +43,7 @@ exports.participantRouter = (0, trpc_1.createTRPCRouter)({
44
43
  .input(limited_time_offer_campaign_validation_1.GetLtoCampaignParticipantsSchema)
45
44
  .output(limited_time_offer_campaign_validation_1.LtoCampaignParticipantsResponseSchema)
46
45
  .query(async ({ input }) => error_handler_1.ErrorHandler.wrapAsync(async () => {
47
- const result = await limited_time_offer_campaign_service_1.ltoCampaignService.getParticipants(input);
46
+ const result = await limited_time_offer_participant_service_1.ltoParticipantService.getParticipants(input);
48
47
  return (0, response_1.response)('Participants fetched successfully', result);
49
48
  })),
50
49
  });
@@ -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,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AC,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,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":[],"m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,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 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":[""]}
@@ -56,15 +56,15 @@ declare const ParticipantStatusSchema: z.ZodObject<{
56
56
  _id: import("mongoose").Types.ObjectId;
57
57
  discountOptions: number[];
58
58
  maxDiscountCaps: number[];
59
- title?: string | undefined;
60
59
  startDate?: Date | null | undefined;
61
60
  endDate?: Date | null | undefined;
61
+ title?: string | undefined;
62
62
  subTitle?: string | undefined;
63
63
  }, {
64
64
  _id: string | import("mongoose").Types.ObjectId;
65
- title?: string | undefined;
66
65
  startDate?: Date | null | undefined;
67
66
  endDate?: Date | null | undefined;
67
+ title?: string | undefined;
68
68
  subTitle?: string | undefined;
69
69
  discountOptions?: number[] | undefined;
70
70
  maxDiscountCaps?: number[] | undefined;
@@ -97,9 +97,9 @@ declare const ParticipantStatusSchema: z.ZodObject<{
97
97
  _id: import("mongoose").Types.ObjectId;
98
98
  discountOptions: number[];
99
99
  maxDiscountCaps: number[];
100
- title?: string | undefined;
101
100
  startDate?: Date | null | undefined;
102
101
  endDate?: Date | null | undefined;
102
+ title?: string | undefined;
103
103
  subTitle?: string | undefined;
104
104
  } | undefined;
105
105
  participant?: {
@@ -114,9 +114,9 @@ declare const ParticipantStatusSchema: z.ZodObject<{
114
114
  campaignState: LtoCardState;
115
115
  campaign?: {
116
116
  _id: string | import("mongoose").Types.ObjectId;
117
- title?: string | undefined;
118
117
  startDate?: Date | null | undefined;
119
118
  endDate?: Date | null | undefined;
119
+ title?: string | undefined;
120
120
  subTitle?: string | undefined;
121
121
  discountOptions?: number[] | undefined;
122
122
  maxDiscountCaps?: number[] | undefined;
@@ -155,8 +155,8 @@ export declare const ParticipantResponseSchema: z.ZodObject<{
155
155
  shop: string | import("mongoose").Types.ObjectId;
156
156
  joinedAt: Date;
157
157
  isEntireMenu: boolean;
158
- isOrderCapacityEnabled: boolean;
159
158
  campaign: string | import("mongoose").Types.ObjectId;
159
+ isOrderCapacityEnabled: boolean;
160
160
  isWithdrawn: boolean;
161
161
  createdAt?: Date | null | undefined;
162
162
  updatedAt?: Date | null | undefined;
@@ -170,8 +170,8 @@ export declare const ParticipantResponseSchema: z.ZodObject<{
170
170
  shop: string | import("mongoose").Types.ObjectId;
171
171
  joinedAt: Date;
172
172
  isEntireMenu: boolean;
173
- isOrderCapacityEnabled: boolean;
174
173
  campaign: string | import("mongoose").Types.ObjectId;
174
+ isOrderCapacityEnabled: boolean;
175
175
  isWithdrawn: boolean;
176
176
  createdAt?: Date | null | undefined;
177
177
  updatedAt?: Date | null | undefined;
@@ -187,8 +187,8 @@ export declare const ParticipantResponseSchema: z.ZodObject<{
187
187
  shop: string | import("mongoose").Types.ObjectId;
188
188
  joinedAt: Date;
189
189
  isEntireMenu: boolean;
190
- isOrderCapacityEnabled: boolean;
191
190
  campaign: string | import("mongoose").Types.ObjectId;
191
+ isOrderCapacityEnabled: boolean;
192
192
  isWithdrawn: boolean;
193
193
  createdAt?: Date | null | undefined;
194
194
  updatedAt?: Date | null | undefined;
@@ -210,8 +210,8 @@ export declare const ParticipantResponseSchema: z.ZodObject<{
210
210
  shop: string | import("mongoose").Types.ObjectId;
211
211
  joinedAt: Date;
212
212
  isEntireMenu: boolean;
213
- isOrderCapacityEnabled: boolean;
214
213
  campaign: string | import("mongoose").Types.ObjectId;
214
+ isOrderCapacityEnabled: boolean;
215
215
  isWithdrawn: boolean;
216
216
  createdAt?: Date | null | undefined;
217
217
  updatedAt?: Date | null | undefined;
@@ -232,8 +232,8 @@ export declare const ParticipantResponseSchema: z.ZodObject<{
232
232
  shop: string | import("mongoose").Types.ObjectId;
233
233
  joinedAt: Date;
234
234
  isEntireMenu: boolean;
235
- isOrderCapacityEnabled: boolean;
236
235
  campaign: string | import("mongoose").Types.ObjectId;
236
+ isOrderCapacityEnabled: boolean;
237
237
  isWithdrawn: boolean;
238
238
  createdAt?: Date | null | undefined;
239
239
  updatedAt?: Date | null | undefined;
@@ -247,8 +247,8 @@ export declare const ParticipantResponseSchema: z.ZodObject<{
247
247
  shop: string | import("mongoose").Types.ObjectId;
248
248
  joinedAt: Date;
249
249
  isEntireMenu: boolean;
250
- isOrderCapacityEnabled: boolean;
251
250
  campaign: string | import("mongoose").Types.ObjectId;
251
+ isOrderCapacityEnabled: boolean;
252
252
  isWithdrawn: boolean;
253
253
  createdAt?: Date | null | undefined;
254
254
  updatedAt?: Date | null | undefined;
@@ -266,8 +266,8 @@ export declare const ParticipantResponseSchema: z.ZodObject<{
266
266
  shop: string | import("mongoose").Types.ObjectId;
267
267
  joinedAt: Date;
268
268
  isEntireMenu: boolean;
269
- isOrderCapacityEnabled: boolean;
270
269
  campaign: string | import("mongoose").Types.ObjectId;
270
+ isOrderCapacityEnabled: boolean;
271
271
  isWithdrawn: boolean;
272
272
  createdAt?: Date | null | undefined;
273
273
  updatedAt?: Date | null | undefined;
@@ -282,8 +282,8 @@ export declare const ParticipantResponseSchema: z.ZodObject<{
282
282
  shop: string | import("mongoose").Types.ObjectId;
283
283
  joinedAt: Date;
284
284
  isEntireMenu: boolean;
285
- isOrderCapacityEnabled: boolean;
286
285
  campaign: string | import("mongoose").Types.ObjectId;
286
+ isOrderCapacityEnabled: boolean;
287
287
  isWithdrawn: boolean;
288
288
  createdAt?: Date | null | undefined;
289
289
  updatedAt?: Date | null | undefined;
@@ -308,8 +308,8 @@ export declare const ParticipantResponseSchema: z.ZodObject<{
308
308
  shop: string | import("mongoose").Types.ObjectId;
309
309
  joinedAt: Date;
310
310
  isEntireMenu: boolean;
311
- isOrderCapacityEnabled: boolean;
312
311
  campaign: string | import("mongoose").Types.ObjectId;
312
+ isOrderCapacityEnabled: boolean;
313
313
  isWithdrawn: boolean;
314
314
  createdAt?: Date | null | undefined;
315
315
  updatedAt?: Date | null | undefined;
@@ -324,8 +324,8 @@ export declare const ParticipantResponseSchema: z.ZodObject<{
324
324
  shop: string | import("mongoose").Types.ObjectId;
325
325
  joinedAt: Date;
326
326
  isEntireMenu: boolean;
327
- isOrderCapacityEnabled: boolean;
328
327
  campaign: string | import("mongoose").Types.ObjectId;
328
+ isOrderCapacityEnabled: boolean;
329
329
  isWithdrawn: boolean;
330
330
  createdAt?: Date | null | undefined;
331
331
  updatedAt?: Date | null | undefined;
@@ -367,9 +367,9 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
367
367
  campaignState: LtoCardState;
368
368
  campaign?: {
369
369
  _id: string | import("mongoose").Types.ObjectId;
370
- title?: string | undefined;
371
370
  startDate?: Date | null | undefined;
372
371
  endDate?: Date | null | undefined;
372
+ title?: string | undefined;
373
373
  subTitle?: string | undefined;
374
374
  discountOptions?: number[] | undefined;
375
375
  maxDiscountCaps?: number[] | undefined;
@@ -386,9 +386,9 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
386
386
  campaignState: LtoCardState;
387
387
  campaign?: {
388
388
  _id: string | import("mongoose").Types.ObjectId;
389
- title?: string | undefined;
390
389
  startDate?: Date | null | undefined;
391
390
  endDate?: Date | null | undefined;
391
+ title?: string | undefined;
392
392
  subTitle?: string | undefined;
393
393
  discountOptions?: number[] | undefined;
394
394
  maxDiscountCaps?: number[] | undefined;
@@ -407,9 +407,9 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
407
407
  campaignState: LtoCardState;
408
408
  campaign?: {
409
409
  _id: string | import("mongoose").Types.ObjectId;
410
- title?: string | undefined;
411
410
  startDate?: Date | null | undefined;
412
411
  endDate?: Date | null | undefined;
412
+ title?: string | undefined;
413
413
  subTitle?: string | undefined;
414
414
  discountOptions?: number[] | undefined;
415
415
  maxDiscountCaps?: number[] | undefined;
@@ -434,9 +434,9 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
434
434
  campaignState: LtoCardState;
435
435
  campaign?: {
436
436
  _id: string | import("mongoose").Types.ObjectId;
437
- title?: string | undefined;
438
437
  startDate?: Date | null | undefined;
439
438
  endDate?: Date | null | undefined;
439
+ title?: string | undefined;
440
440
  subTitle?: string | undefined;
441
441
  discountOptions?: number[] | undefined;
442
442
  maxDiscountCaps?: number[] | undefined;
@@ -460,9 +460,9 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
460
460
  campaignState: LtoCardState;
461
461
  campaign?: {
462
462
  _id: string | import("mongoose").Types.ObjectId;
463
- title?: string | undefined;
464
463
  startDate?: Date | null | undefined;
465
464
  endDate?: Date | null | undefined;
465
+ title?: string | undefined;
466
466
  subTitle?: string | undefined;
467
467
  discountOptions?: number[] | undefined;
468
468
  maxDiscountCaps?: number[] | undefined;
@@ -479,9 +479,9 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
479
479
  campaignState: LtoCardState;
480
480
  campaign?: {
481
481
  _id: string | import("mongoose").Types.ObjectId;
482
- title?: string | undefined;
483
482
  startDate?: Date | null | undefined;
484
483
  endDate?: Date | null | undefined;
484
+ title?: string | undefined;
485
485
  subTitle?: string | undefined;
486
486
  discountOptions?: number[] | undefined;
487
487
  maxDiscountCaps?: number[] | undefined;
@@ -502,9 +502,9 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
502
502
  campaignState: LtoCardState;
503
503
  campaign?: {
504
504
  _id: string | import("mongoose").Types.ObjectId;
505
- title?: string | undefined;
506
505
  startDate?: Date | null | undefined;
507
506
  endDate?: Date | null | undefined;
507
+ title?: string | undefined;
508
508
  subTitle?: string | undefined;
509
509
  discountOptions?: number[] | undefined;
510
510
  maxDiscountCaps?: number[] | undefined;
@@ -522,9 +522,9 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
522
522
  campaignState: LtoCardState;
523
523
  campaign?: {
524
524
  _id: string | import("mongoose").Types.ObjectId;
525
- title?: string | undefined;
526
525
  startDate?: Date | null | undefined;
527
526
  endDate?: Date | null | undefined;
527
+ title?: string | undefined;
528
528
  subTitle?: string | undefined;
529
529
  discountOptions?: number[] | undefined;
530
530
  maxDiscountCaps?: number[] | undefined;
@@ -552,9 +552,9 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
552
552
  campaignState: LtoCardState;
553
553
  campaign?: {
554
554
  _id: string | import("mongoose").Types.ObjectId;
555
- title?: string | undefined;
556
555
  startDate?: Date | null | undefined;
557
556
  endDate?: Date | null | undefined;
557
+ title?: string | undefined;
558
558
  subTitle?: string | undefined;
559
559
  discountOptions?: number[] | undefined;
560
560
  maxDiscountCaps?: number[] | undefined;
@@ -572,9 +572,9 @@ export declare const ParticipantStatusResponseSchema: z.ZodObject<{
572
572
  campaignState: LtoCardState;
573
573
  campaign?: {
574
574
  _id: string | import("mongoose").Types.ObjectId;
575
- title?: string | undefined;
576
575
  startDate?: Date | null | undefined;
577
576
  endDate?: Date | null | undefined;
577
+ title?: string | undefined;
578
578
  subTitle?: string | undefined;
579
579
  discountOptions?: number[] | undefined;
580
580
  maxDiscountCaps?: number[] | undefined;
@@ -1,7 +1,9 @@
1
1
  import { mongoose } from '@typegoose/typegoose';
2
- import { JoinLtoCampaignDTO } from '../limited-time-offer-participant.validation';
3
2
  import { LimitedTimeOfferCampaign } from '@lyxa.ai/core/dist/libraries/mongo/models';
3
+ import { JoinLtoCampaignDTO } from '../limited-time-offer-participant.validation';
4
4
  export declare class LtoParticipantMarketingService {
5
+ private repository;
6
+ constructor();
5
7
  applyMarketing(shopId: mongoose.Types.ObjectId, campaign: LimitedTimeOfferCampaign & {
6
8
  _id: mongoose.Types.ObjectId;
7
9
  }, dto: JoinLtoCampaignDTO): Promise<mongoose.Types.ObjectId>;
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer-participant-marketing.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAG9C,OAAO,EAAC,kBAAkB,EAAC,MAAM,8CAA8C,CAAC;AAChF,OAAO,EAAC,wBAAwB,EAAmC,MAAM,2CAA2C,CAAC;AAGrH,qBACa,8BAA8B;IAE1B,cAAc,CACvB,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,QAAQ,EAAE,wBAAwB,GAAG;QAAE,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAA;KAAE,EACrE,GAAG,EAAE,kBAAkB,GACxB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IA6BtB,eAAe,CAAC,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpE,2BAA2B,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAgB/F;AAED,eAAO,MAAM,8BAA8B,gCAAgD,CAAC"}
1
+ {"version":3,"file":"limited-time-offer-participant-marketing.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAC,wBAAwB,EAAC,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAC,kBAAkB,EAAC,MAAM,8CAA8C,CAAC;AAIhF,qBACa,8BAA8B;IACvC,OAAO,CAAC,UAAU,CAA2B;;IAMhC,cAAc,CACvB,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,QAAQ,EAAE,wBAAwB,GAAG;QAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAA;KAAC,EACnE,GAAG,EAAE,kBAAkB,GACxB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;IAOtB,eAAe,CAAC,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpE,2BAA2B,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAI/F;AAED,eAAO,MAAM,8BAA8B,gCAAgD,CAAC"}
@@ -38,61 +38,36 @@ var __importStar = (this && this.__importStar) || (function () {
38
38
  return result;
39
39
  };
40
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
+ };
41
44
  Object.defineProperty(exports, "__esModule", { value: true });
42
45
  exports.ltoParticipantMarketingService = exports.LtoParticipantMarketingService = void 0;
43
46
  const typedi_1 = __importStar(require("typedi"));
44
47
  const services_1 = require("../../../marketing/services");
45
- const models_1 = require("@lyxa.ai/core/dist/libraries/mongo/models");
46
- const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
48
+ const limited_time_offer_participant_builder_1 = require("../limited-time-offer-participant.builder");
49
+ const limited_time_offer_participant_repository_1 = require("../limited-time-offer-participant.repository");
47
50
  let LtoParticipantMarketingService = class LtoParticipantMarketingService {
51
+ repository;
52
+ constructor() {
53
+ this.repository = typedi_1.default.get(limited_time_offer_participant_repository_1.LtoParticipantRepository);
54
+ }
48
55
  async applyMarketing(shopId, campaign, dto) {
49
- const marketing = await services_1.marketingService.create({
50
- shop: shopId,
51
- marketingType: enum_1.MarketingType.DISCOUNT,
52
- isAppliedByCompany: true,
53
- duration: { start: campaign.startDate, end: campaign.endDate },
54
- status: enum_1.MarketingStatus.ACTIVE,
55
- isEntireMenu: dto.isEntireMenu,
56
- value: dto.isEntireMenu ? dto.discountPercentage : undefined,
57
- valueType: dto.isEntireMenu ? enum_1.ValueType.PERCENTAGE : undefined,
58
- products: dto.isEntireMenu
59
- ? []
60
- : dto.products.map(productId => ({
61
- product: productId,
62
- value: dto.discountPercentage,
63
- valueType: enum_1.ValueType.PERCENTAGE,
64
- })),
65
- maxDiscountPerOrder: dto.maxDiscountCap,
66
- isMaxDiscountPerOrderEnabled: dto.maxDiscountCap > 0,
67
- categories: [],
68
- excludeProducts: [],
69
- spendLimit: 0,
70
- isSpendLimitEnabled: false,
71
- isOnlyForSubscriber: false,
72
- });
56
+ const marketing = await services_1.marketingService.create(limited_time_offer_participant_builder_1.LtoParticipantQueryBuilder.buildMarketingInput(shopId, campaign, dto));
73
57
  return marketing._id;
74
58
  }
75
59
  async removeMarketing(marketingId) {
76
60
  await services_1.marketingService.deleteById({ _id: marketingId, softDelete: true });
77
61
  }
78
62
  async removeAllCampaignMarketings(campaignId) {
79
- const participants = await models_1.LimitedTimeOfferParticipantModel
80
- .find({
81
- campaign: campaignId,
82
- isWithdrawn: false,
83
- marketing: { $exists: true, $ne: null },
84
- })
85
- .select('marketing')
86
- .lean();
87
- const marketingIds = participants
88
- .map(p => p.marketing)
89
- .filter(Boolean);
63
+ const marketingIds = await this.repository.findMarketingIdsByCampaign(campaignId);
90
64
  await services_1.marketingService.deleteManyByIds(marketingIds);
91
65
  }
92
66
  };
93
67
  exports.LtoParticipantMarketingService = LtoParticipantMarketingService;
94
68
  exports.LtoParticipantMarketingService = LtoParticipantMarketingService = __decorate([
95
- (0, typedi_1.Service)()
69
+ (0, typedi_1.Service)(),
70
+ __metadata("design:paramtypes", [])
96
71
  ], LtoParticipantMarketingService);
97
72
  exports.ltoParticipantMarketingService = typedi_1.default.get(LtoParticipantMarketingService);
98
73
  //# sourceMappingURL=limited-time-offer-participant-marketing.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer-participant-marketing.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.ts"],"names":[],"mappings":";;;;;;;;;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AAC;QAEH,OAAO,SAAS,CAAC,GAAG,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,WAAoC;QAC7D,MAAM,2BAAgB,CAAC,UAAU,CAAC,EAAC,GAAG,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAC,CAAC,CAAC;IAC5E,CAAC;IAEM,KAAK,CAAC,2BAA2B,CAAC,UAAmC;QACxE,MAAM,YAAY,GAAG,MAAM,yCAAgC;aACtD,IAAI,CAAC;YACF,QAAQ,EAAE,UAAU;YACpB,WAAW,EAAE,KAAK;YAClB,SAAS,EAAE,EAAC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAC;SACxC,CAAC;aACD,MAAM,CAAC,WAAW,CAAC;aACnB,IAAI,EAAE,CAAC;QAEZ,MAAM,YAAY,GAAG,YAAY;aAC5B,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAoC,CAAC;aAChD,MAAM,CAAC,OAAO,CAAC,CAAC;QAErB,MAAM,2BAAgB,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;IACzD,CAAC;CACJ,CAAA;AAvDY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,gBAAO,GAAE;GACG,8BAA8B,CAuD1C;AAEY,QAAA,8BAA8B,GAAG,gBAAS,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\n\nimport {marketingService} from '@modules/marketing/services';\nimport {JoinLtoCampaignDTO} from '../limited-time-offer-participant.validation';\nimport {LimitedTimeOfferCampaign, LimitedTimeOfferParticipantModel} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {MarketingStatus, MarketingType, ValueType} from '@lyxa.ai/core/dist/utilities/enum';\n\n@Service()\nexport class LtoParticipantMarketingService {\n\n public async applyMarketing(\n shopId: mongoose.Types.ObjectId,\n campaign: LimitedTimeOfferCampaign & { _id: mongoose.Types.ObjectId },\n dto: JoinLtoCampaignDTO,\n ): Promise<mongoose.Types.ObjectId> {\n const marketing = await marketingService.create({\n shop: shopId,\n marketingType: MarketingType.DISCOUNT,\n isAppliedByCompany: true,\n duration: {start: campaign.startDate, end: campaign.endDate},\n status: MarketingStatus.ACTIVE,\n isEntireMenu: dto.isEntireMenu,\n value: dto.isEntireMenu ? dto.discountPercentage : undefined,\n valueType: dto.isEntireMenu ? ValueType.PERCENTAGE : undefined,\n products: dto.isEntireMenu\n ? []\n : dto.products.map(productId => ({\n product: productId,\n value: dto.discountPercentage,\n valueType: ValueType.PERCENTAGE,\n })),\n maxDiscountPerOrder: dto.maxDiscountCap,\n isMaxDiscountPerOrderEnabled: dto.maxDiscountCap > 0,\n categories: [],\n excludeProducts: [],\n spendLimit: 0,\n isSpendLimitEnabled: false,\n isOnlyForSubscriber: false,\n });\n\n return marketing._id;\n }\n\n public async removeMarketing(marketingId: mongoose.Types.ObjectId): Promise<void> {\n await marketingService.deleteById({_id: marketingId, softDelete: true});\n }\n\n public async removeAllCampaignMarketings(campaignId: mongoose.Types.ObjectId): Promise<void> {\n const participants = await LimitedTimeOfferParticipantModel\n .find({\n campaign: campaignId,\n isWithdrawn: false,\n marketing: {$exists: true, $ne: null},\n })\n .select('marketing')\n .lean();\n\n const marketingIds = participants\n .map(p => p.marketing as mongoose.Types.ObjectId)\n .filter(Boolean);\n\n await marketingService.deleteManyByIds(marketingIds);\n }\n}\n\nexport const ltoParticipantMarketingService = Container.get(LtoParticipantMarketingService);\n"]}
1
+ {"version":3,"file":"limited-time-offer-participant-marketing.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,0DAA6D;AAG7D,sGAAqF;AACrF,4GAAsF;AAG/E,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAC/B,UAAU,CAA2B;IAE7C;QACI,IAAI,CAAC,UAAU,GAAG,gBAAS,CAAC,GAAG,CAAC,oEAAwB,CAAC,CAAC;IAC9D,CAAC;IAEM,KAAK,CAAC,cAAc,CACvB,MAA+B,EAC/B,QAAmE,EACnE,GAAuB;QAEvB,MAAM,SAAS,GAAG,MAAM,2BAAgB,CAAC,MAAM,CAC3C,mEAA0B,CAAC,mBAAmB,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAC,CACxE,CAAC;QACF,OAAO,SAAS,CAAC,GAAG,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,WAAoC;QAC7D,MAAM,2BAAgB,CAAC,UAAU,CAAC,EAAC,GAAG,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAC,CAAC,CAAC;IAC5E,CAAC;IAEM,KAAK,CAAC,2BAA2B,CAAC,UAAmC;QACxE,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,0BAA0B,CAAC,UAAU,CAAC,CAAC;QAClF,MAAM,2BAAgB,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;IACzD,CAAC;CACJ,CAAA;AA1BY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,gBAAO,GAAE;;GACG,8BAA8B,CA0B1C;AAEY,QAAA,8BAA8B,GAAG,gBAAS,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {mongoose} from '@typegoose/typegoose';\nimport {marketingService} from '@modules/marketing/services';\nimport {LimitedTimeOfferCampaign} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {JoinLtoCampaignDTO} from '../limited-time-offer-participant.validation';\nimport {LtoParticipantQueryBuilder} from '../limited-time-offer-participant.builder';\nimport {LtoParticipantRepository} from '../limited-time-offer-participant.repository';\n\n@Service()\nexport class LtoParticipantMarketingService {\n private repository: LtoParticipantRepository;\n\n constructor() {\n this.repository = Container.get(LtoParticipantRepository);\n }\n\n public async applyMarketing(\n shopId: mongoose.Types.ObjectId,\n campaign: LimitedTimeOfferCampaign & {_id: mongoose.Types.ObjectId},\n dto: JoinLtoCampaignDTO,\n ): Promise<mongoose.Types.ObjectId> {\n const marketing = await marketingService.create(\n LtoParticipantQueryBuilder.buildMarketingInput(shopId, campaign, dto),\n );\n return marketing._id;\n }\n\n public async removeMarketing(marketingId: mongoose.Types.ObjectId): Promise<void> {\n await marketingService.deleteById({_id: marketingId, softDelete: true});\n }\n\n public async removeAllCampaignMarketings(campaignId: mongoose.Types.ObjectId): Promise<void> {\n const marketingIds = await this.repository.findMarketingIdsByCampaign(campaignId);\n await marketingService.deleteManyByIds(marketingIds);\n }\n}\n\nexport const ltoParticipantMarketingService = Container.get(LtoParticipantMarketingService);\n"]}