@lyxa.ai/marketing 1.0.53 → 1.0.54

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 (97) hide show
  1. package/dist/lib/index.d.ts +675 -28
  2. package/dist/lib/index.d.ts.map +1 -1
  3. package/dist/lib/modules/coupon/routers/coupon.router.d.ts +647 -0
  4. package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
  5. package/dist/lib/modules/coupon/routers/coupon.router.js +8 -1
  6. package/dist/lib/modules/coupon/routers/coupon.router.js.map +1 -1
  7. package/dist/lib/modules/coupon/services/coupon.service.d.ts +8 -1
  8. package/dist/lib/modules/coupon/services/coupon.service.d.ts.map +1 -1
  9. package/dist/lib/modules/coupon/services/coupon.service.js +231 -27
  10. package/dist/lib/modules/coupon/services/coupon.service.js.map +1 -1
  11. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js +2 -2
  12. package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js.map +1 -1
  13. package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts +293 -1125
  14. package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
  15. package/dist/lib/modules/coupon/validations/all-coupons.validation.js +2 -16
  16. package/dist/lib/modules/coupon/validations/all-coupons.validation.js.map +1 -1
  17. package/dist/lib/modules/coupon/validations/coupon.validation.d.ts +26 -0
  18. package/dist/lib/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
  19. package/dist/lib/modules/coupon/validations/coupon.validation.js +10 -1
  20. package/dist/lib/modules/coupon/validations/coupon.validation.js.map +1 -1
  21. package/dist/lib/modules/coupon/validations/index.d.ts +1 -0
  22. package/dist/lib/modules/coupon/validations/index.d.ts.map +1 -1
  23. package/dist/lib/modules/coupon/validations/index.js +1 -0
  24. package/dist/lib/modules/coupon/validations/index.js.map +1 -1
  25. package/dist/lib/modules/limited-time-offer/campaign/campaign.router.d.ts +8 -8
  26. package/dist/lib/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +34 -34
  27. package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts +28 -28
  28. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts +1 -0
  29. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -1
  30. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js +6 -0
  31. package/dist/lib/modules/limited-time-offer/limited-time-offer.service.js.map +1 -1
  32. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.builder.d.ts +13 -0
  33. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.builder.d.ts.map +1 -0
  34. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.builder.js +22 -0
  35. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.builder.js.map +1 -0
  36. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts +20 -0
  37. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts.map +1 -0
  38. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.js +26 -0
  39. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.constants.js.map +1 -0
  40. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.service.d.ts +8 -0
  41. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.service.d.ts.map +1 -0
  42. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.service.js +60 -0
  43. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.service.js.map +1 -0
  44. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.type.d.ts +5 -0
  45. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.type.d.ts.map +1 -0
  46. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.type.js +3 -0
  47. package/dist/lib/modules/limited-time-offer/notification/limited-time-offer-notification.type.js.map +1 -0
  48. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.js +1 -1
  49. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.builder.js.map +1 -1
  50. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +1 -0
  51. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
  52. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js +8 -1
  53. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js.map +1 -1
  54. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +20 -20
  55. package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +82 -82
  56. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +2 -1
  57. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  58. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js +12 -5
  59. package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js.map +1 -1
  60. package/dist/lib/modules/marketing/services/marketing.service.d.ts +1 -0
  61. package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
  62. package/dist/lib/modules/marketing/services/marketing.service.js +9 -0
  63. package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -1
  64. package/dist/types/index.d.ts +675 -28
  65. package/dist/types/index.d.ts.map +1 -1
  66. package/dist/types/modules/coupon/routers/coupon.router.d.ts +647 -0
  67. package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
  68. package/dist/types/modules/coupon/services/coupon.service.d.ts +8 -1
  69. package/dist/types/modules/coupon/services/coupon.service.d.ts.map +1 -1
  70. package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts +293 -1125
  71. package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
  72. package/dist/types/modules/coupon/validations/coupon.validation.d.ts +26 -0
  73. package/dist/types/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
  74. package/dist/types/modules/coupon/validations/index.d.ts +1 -0
  75. package/dist/types/modules/coupon/validations/index.d.ts.map +1 -1
  76. package/dist/types/modules/limited-time-offer/campaign/campaign.router.d.ts +8 -8
  77. package/dist/types/modules/limited-time-offer/campaign/limited-time-offer-campaign.validation.d.ts +34 -34
  78. package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts +28 -28
  79. package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts +1 -0
  80. package/dist/types/modules/limited-time-offer/limited-time-offer.service.d.ts.map +1 -1
  81. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.builder.d.ts +13 -0
  82. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.builder.d.ts.map +1 -0
  83. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts +20 -0
  84. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.constants.d.ts.map +1 -0
  85. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.service.d.ts +8 -0
  86. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.service.d.ts.map +1 -0
  87. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.type.d.ts +5 -0
  88. package/dist/types/modules/limited-time-offer/notification/limited-time-offer-notification.type.d.ts.map +1 -0
  89. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +1 -0
  90. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
  91. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +20 -20
  92. package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +82 -82
  93. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +2 -1
  94. package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
  95. package/dist/types/modules/marketing/services/marketing.service.d.ts +1 -0
  96. package/dist/types/modules/marketing/services/marketing.service.d.ts.map +1 -1
  97. package/package.json +2 -2
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NOTIFICATIONS = exports.TARGET_ACCOUNT_TYPES = exports.NotificationType = void 0;
4
+ const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
5
+ exports.NotificationType = {
6
+ Cancel: "cancel",
7
+ Activate: "activate",
8
+ };
9
+ exports.TARGET_ACCOUNT_TYPES = [
10
+ enum_1.NotificationAccountType.SHOP,
11
+ enum_1.NotificationAccountType.SHOP_CONSOLE,
12
+ ];
13
+ const CUSTOM_NOTIFICATION_SOUND = 'notification_sound';
14
+ exports.NOTIFICATIONS = {
15
+ CAMPAIGN_CANCELLED: {
16
+ title: "Lyxa deleted the current campaign",
17
+ body: "The ongoing limited time offer campaign has been deleted by lyxa.",
18
+ sound: CUSTOM_NOTIFICATION_SOUND
19
+ },
20
+ CAMPAIGN_ACTIVATED: {
21
+ title: "Limited Time Offer is Live!",
22
+ body: "A new limited time offer has started. Check it out now!",
23
+ sound: CUSTOM_NOTIFICATION_SOUND
24
+ },
25
+ };
26
+ //# sourceMappingURL=limited-time-offer-notification.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limited-time-offer-notification.constants.js","sourceRoot":"/","sources":["modules/limited-time-offer/notification/limited-time-offer-notification.constants.ts"],"names":[],"mappings":";;;AAAA,4DAA0E;AAE7D,QAAA,gBAAgB,GAAG;IAC5B,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;CACd,CAAC;AAME,QAAA,oBAAoB,GAAG;IAChC,8BAAuB,CAAC,IAAI;IAC5B,8BAAuB,CAAC,YAAY;CAC9B,CAAC;AAEX,MAAM,yBAAyB,GAAG,oBAAoB,CAAC;AAE1C,QAAA,aAAa,GAAG;IACzB,kBAAkB,EAAE;QAChB,KAAK,EAAE,mCAAmC;QAC1C,IAAI,EAAE,mEAAmE;QACzE,KAAK,EAAE,yBAAyB;KACnC;IACD,kBAAkB,EAAE;QAChB,KAAK,EAAE,6BAA6B;QACpC,IAAI,EAAE,yDAAyD;QAC/D,KAAK,EAAE,yBAAyB;KACnC;CACK,CAAC","sourcesContent":["import {NotificationAccountType} from \"@lyxa.ai/core/dist/utilities/enum\";\n\nexport const NotificationType = {\n Cancel: \"cancel\",\n Activate: \"activate\",\n} as const;\n\nexport type NotificationType =\n (typeof NotificationType)[keyof typeof NotificationType];\n\n\nexport const TARGET_ACCOUNT_TYPES = [\n NotificationAccountType.SHOP,\n NotificationAccountType.SHOP_CONSOLE,\n] as const;\n\nconst CUSTOM_NOTIFICATION_SOUND = 'notification_sound';\n\nexport const NOTIFICATIONS = {\n CAMPAIGN_CANCELLED: {\n title: \"Lyxa deleted the current campaign\",\n body: \"The ongoing limited time offer campaign has been deleted by lyxa.\",\n sound: CUSTOM_NOTIFICATION_SOUND\n },\n CAMPAIGN_ACTIVATED: {\n title: \"Limited Time Offer is Live!\",\n body: \"A new limited time offer has started. Check it out now!\",\n sound: CUSTOM_NOTIFICATION_SOUND\n },\n} as const;"]}
@@ -0,0 +1,8 @@
1
+ import { mongoose } from "@typegoose/typegoose";
2
+ import { NotificationType } from "./limited-time-offer-notification.constants";
3
+ import { SendLimitedTimeOfferNotificationDto } from "./limited-time-offer-notification.type";
4
+ export declare class LimitedTimeOfferNotificationService {
5
+ send(type: NotificationType, recipientIds: mongoose.Types.ObjectId[], dto: SendLimitedTimeOfferNotificationDto): Promise<void>;
6
+ }
7
+ export declare const limitedTimeOfferNotificationService: LimitedTimeOfferNotificationService;
8
+ //# sourceMappingURL=limited-time-offer-notification.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limited-time-offer-notification.service.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/notification/limited-time-offer-notification.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAG9C,OAAO,EAAC,gBAAgB,EAAwB,MAAM,6CAA6C,CAAC;AAEpG,OAAO,EAAC,mCAAmC,EAAC,MAAM,wCAAwC,CAAC;AAE3F,qBACa,mCAAmC;IACtC,IAAI,CACN,IAAI,EAAE,gBAAgB,EACtB,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,EACvC,GAAG,EAAE,mCAAmC,GACzC,OAAO,CAAC,IAAI,CAAC;CAWnB;AAED,eAAO,MAAM,mCAAmC,qCAE/C,CAAC"}
@@ -0,0 +1,60 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.limitedTimeOfferNotificationService = exports.LimitedTimeOfferNotificationService = void 0;
43
+ const event_1 = require("@lyxa.ai/core/dist/libraries/event");
44
+ const typedi_1 = __importStar(require("typedi"));
45
+ const limited_time_offer_notification_constants_1 = require("./limited-time-offer-notification.constants");
46
+ const limited_time_offer_notification_builder_1 = require("./limited-time-offer-notification.builder");
47
+ let LimitedTimeOfferNotificationService = class LimitedTimeOfferNotificationService {
48
+ async send(type, recipientIds, dto) {
49
+ const builder = limited_time_offer_notification_builder_1.NOTIFICATION_BUILDERS[type];
50
+ const { campaignId } = dto;
51
+ const events = recipientIds.flatMap((recipientId) => limited_time_offer_notification_constants_1.TARGET_ACCOUNT_TYPES.map((accountType) => builder({ campaignId, recipientId, accountType })));
52
+ await Promise.all(events.map(event_1.publishEvent));
53
+ }
54
+ };
55
+ exports.LimitedTimeOfferNotificationService = LimitedTimeOfferNotificationService;
56
+ exports.LimitedTimeOfferNotificationService = LimitedTimeOfferNotificationService = __decorate([
57
+ (0, typedi_1.Service)()
58
+ ], LimitedTimeOfferNotificationService);
59
+ exports.limitedTimeOfferNotificationService = typedi_1.default.get(LimitedTimeOfferNotificationService);
60
+ //# sourceMappingURL=limited-time-offer-notification.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limited-time-offer-notification.service.js","sourceRoot":"/","sources":["modules/limited-time-offer/notification/limited-time-offer-notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAgE;AAEhE,iDAA0C;AAE1C,2GAAoG;AACpG,uGAAgF;AAIzE,IAAM,mCAAmC,GAAzC,MAAM,mCAAmC;IAC5C,KAAK,CAAC,IAAI,CACN,IAAsB,EACtB,YAAuC,EACvC,GAAwC;QAExC,MAAM,OAAO,GAAG,+DAAqB,CAAC,IAAI,CAAC,CAAC;QAC5C,MAAM,EAAC,UAAU,EAAC,GAAG,GAAG,CAAC;QAEzB,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CAChD,gEAAoB,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CACrC,OAAO,CAAC,EAAC,UAAU,EAAE,WAAW,EAAE,WAAW,EAAC,CAAC,CAClD,CACJ,CAAC;QACF,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAY,CAAC,CAAC,CAAC;IAChD,CAAC;CACJ,CAAA;AAhBY,kFAAmC;8CAAnC,mCAAmC;IAD/C,IAAA,gBAAO,GAAE;GACG,mCAAmC,CAgB/C;AAEY,QAAA,mCAAmC,GAAG,gBAAS,CAAC,GAAG,CAC5D,mCAAmC,CACtC,CAAC","sourcesContent":["import {publishEvent} from \"@lyxa.ai/core/dist/libraries/event\";\nimport {mongoose} from \"@typegoose/typegoose\";\nimport Container, {Service} from \"typedi\";\n\nimport {NotificationType, TARGET_ACCOUNT_TYPES,} from \"./limited-time-offer-notification.constants\";\nimport {NOTIFICATION_BUILDERS} from \"./limited-time-offer-notification.builder\";\nimport {SendLimitedTimeOfferNotificationDto} from \"./limited-time-offer-notification.type\";\n\n@Service()\nexport class LimitedTimeOfferNotificationService {\n async send(\n type: NotificationType,\n recipientIds: mongoose.Types.ObjectId[],\n dto: SendLimitedTimeOfferNotificationDto,\n ): Promise<void> {\n const builder = NOTIFICATION_BUILDERS[type];\n const {campaignId} = dto;\n\n const events = recipientIds.flatMap((recipientId) =>\n TARGET_ACCOUNT_TYPES.map((accountType) =>\n builder({campaignId, recipientId, accountType}),\n ),\n );\n await Promise.all(events.map(publishEvent));\n }\n}\n\nexport const limitedTimeOfferNotificationService = Container.get(\n LimitedTimeOfferNotificationService,\n);"]}
@@ -0,0 +1,5 @@
1
+ import { mongoose } from "@typegoose/typegoose";
2
+ export interface SendLimitedTimeOfferNotificationDto {
3
+ campaignId: mongoose.Types.ObjectId;
4
+ }
5
+ //# sourceMappingURL=limited-time-offer-notification.type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limited-time-offer-notification.type.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/notification/limited-time-offer-notification.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAE9C,MAAM,WAAW,mCAAmC;IAChD,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;CACvC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=limited-time-offer-notification.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limited-time-offer-notification.type.js","sourceRoot":"/","sources":["modules/limited-time-offer/notification/limited-time-offer-notification.type.ts"],"names":[],"mappings":"","sourcesContent":["import {mongoose} from \"@typegoose/typegoose\";\n\nexport interface SendLimitedTimeOfferNotificationDto {\n campaignId: mongoose.Types.ObjectId;\n}\n"]}
@@ -28,7 +28,7 @@ class LtoParticipantQueryBuilder {
28
28
  return {
29
29
  shop: shopId,
30
30
  marketingType: enum_1.MarketingType.DISCOUNT,
31
- isAppliedByCompany: true,
31
+ isAppliedByCompany: false,
32
32
  duration: { start: campaign.startDate, end: campaign.endDate },
33
33
  status: enum_1.MarketingStatus.ACTIVE,
34
34
  isEntireMenu: dto.isEntireMenu,
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer-participant.builder.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/lim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C,kBAAkB,CAAC,CAAC,CAAC,SAAS;YAC5D,SAAS,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,gBAAS,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;YAC9D,QAAQ,EAAE,GAAG,CAAC,YAAY;gBACtB,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;oBAC7B,OAAO,EAAE,SAAS;oBAClB,KAAK,EAAE,GAAG,CAAC,kBAAkB;oBAC7B,SAAS,EAAE,gBAAS,CAAC,UAAU;iBAClC,CAAC,CAAC;YACP,mBAAmB,EAAE,GAAG,CAAC,cAAc;YACvC,4BAA4B,EAAE,GAAG,CAAC,cAAc,GAAG,CAAC;YACpD,UAAU,EAAE,EAAE;YACd,eAAe,EAAE,EAAE;YACnB,UAAU,EAAE,CAAC;YACb,mBAAmB,EAAE,KAAK;YAC1B,mBAAmB,EAAE,KAAK;SAC7B,CAAC;IACN,CAAC;CACJ;AA5DD,gEA4DC","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\nimport {LimitedTimeOfferCampaign} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {MarketingStatus, MarketingType, ValueType} from '@lyxa.ai/core/dist/utilities/enum';\nimport {GetLtoCampaignParticipantsDTO} from '../campaign/limited-time-offer-campaign.validation';\nimport {JoinLtoCampaignDTO} from './limited-time-offer-participant.validation';\n\nexport class LtoParticipantQueryBuilder {\n static buildCampaignFilter(dto: GetLtoCampaignParticipantsDTO) {\n return {campaign: dto.campaignId, isWithdrawn: false};\n }\n\n static buildSearchTerm(dto: GetLtoCampaignParticipantsDTO): string | undefined {\n return dto.search?.trim() || undefined;\n }\n\n static buildCreateInput(\n campaignId: mongoose.Types.ObjectId,\n shopId: mongoose.Types.ObjectId,\n marketingId: mongoose.Types.ObjectId,\n dto: JoinLtoCampaignDTO,\n ) {\n return {\n campaign: campaignId,\n shop: shopId,\n marketing: marketingId,\n joinedAt: new Date(),\n products: dto.products ?? [],\n isEntireMenu: dto.isEntireMenu,\n discountPercentage: dto.discountPercentage,\n maxDiscountCap: dto.maxDiscountCap,\n isOrderCapacityEnabled: dto.isOrderCapacityEnabled,\n maxOrderCapacity: dto.maxOrderCapacity,\n isWithdrawn: false,\n };\n }\n\n static buildMarketingInput(\n shopId: mongoose.Types.ObjectId,\n campaign: LimitedTimeOfferCampaign & {_id: mongoose.Types.ObjectId},\n dto: JoinLtoCampaignDTO,\n ) {\n return {\n shop: shopId,\n marketingType: MarketingType.DISCOUNT,\n 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}\n"]}
1
+ {"version":3,"file":"limited-time-offer-participant.builder.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.builder.ts"],"names":[],"mappings":";;;AAEA,4DAA4F;AAI5F,MAAa,0BAA0B;IACnC,MAAM,CAAC,mBAAmB,CAAC,GAAkC;QACzD,OAAO,EAAC,QAAQ,EAAE,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,KAAK,EAAC,CAAC;IAC1D,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,GAAkC;QACrD,OAAO,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,SAAS,CAAC;IAC3C,CAAC;IAED,MAAM,CAAC,gBAAgB,CACnB,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,SAAS,EAAE,gBAAS,CAAC,UAAU;iBAClC,CAAC,CAAC;YACP,mBAAmB,EAAE,GAAG,CAAC,cAAc;YACvC,4BAA4B,EAAE,GAAG,CAAC,cAAc,GAAG,CAAC;YACpD,UAAU,EAAE,EAAE;YACd,eAAe,EAAE,EAAE;YACnB,UAAU,EAAE,CAAC;YACb,mBAAmB,EAAE,KAAK;YAC1B,mBAAmB,EAAE,KAAK;SAC7B,CAAC;IACN,CAAC;CACJ;AA5DD,gEA4DC","sourcesContent":["import {mongoose} from '@typegoose/typegoose';\nimport {LimitedTimeOfferCampaign} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {MarketingStatus, MarketingType, ValueType} from '@lyxa.ai/core/dist/utilities/enum';\nimport {GetLtoCampaignParticipantsDTO} from '../campaign/limited-time-offer-campaign.validation';\nimport {JoinLtoCampaignDTO} from './limited-time-offer-participant.validation';\n\nexport class LtoParticipantQueryBuilder {\n static buildCampaignFilter(dto: GetLtoCampaignParticipantsDTO) {\n return {campaign: dto.campaignId, isWithdrawn: false};\n }\n\n static buildSearchTerm(dto: GetLtoCampaignParticipantsDTO): string | undefined {\n return dto.search?.trim() || undefined;\n }\n\n static buildCreateInput(\n campaignId: mongoose.Types.ObjectId,\n shopId: mongoose.Types.ObjectId,\n marketingId: mongoose.Types.ObjectId,\n dto: JoinLtoCampaignDTO,\n ) {\n return {\n campaign: campaignId,\n shop: shopId,\n marketing: marketingId,\n joinedAt: new Date(),\n products: dto.products ?? [],\n isEntireMenu: dto.isEntireMenu,\n discountPercentage: dto.discountPercentage,\n maxDiscountCap: dto.maxDiscountCap,\n isOrderCapacityEnabled: dto.isOrderCapacityEnabled,\n maxOrderCapacity: dto.maxOrderCapacity,\n isWithdrawn: false,\n };\n }\n\n static buildMarketingInput(\n shopId: mongoose.Types.ObjectId,\n campaign: LimitedTimeOfferCampaign & {_id: mongoose.Types.ObjectId},\n dto: JoinLtoCampaignDTO,\n ) {\n return {\n shop: shopId,\n marketingType: MarketingType.DISCOUNT,\n isAppliedByCompany: false,\n duration: {start: campaign.startDate, end: campaign.endDate},\n status: MarketingStatus.ACTIVE,\n isEntireMenu: dto.isEntireMenu,\n value: dto.isEntireMenu ? dto.discountPercentage : undefined,\n valueType: dto.isEntireMenu ? ValueType.PERCENTAGE : undefined,\n products: dto.isEntireMenu\n ? []\n : dto.products.map(productId => ({\n product: productId,\n value: dto.discountPercentage,\n valueType: ValueType.PERCENTAGE,\n })),\n maxDiscountPerOrder: dto.maxDiscountCap,\n isMaxDiscountPerOrderEnabled: dto.maxDiscountCap > 0,\n categories: [],\n excludeProducts: [],\n spendLimit: 0,\n isSpendLimitEnabled: false,\n isOnlyForSubscriber: false,\n };\n }\n}\n"]}
@@ -24,6 +24,7 @@ export declare class LtoParticipantRepository {
24
24
  countShopProducts(shopId: mongoose.Types.ObjectId, productIds: mongoose.Types.ObjectId[]): Promise<number>;
25
25
  findProductIdsByCategories(shopId: mongoose.Types.ObjectId, categoryIds: mongoose.Types.ObjectId[]): Promise<mongoose.Types.ObjectId[]>;
26
26
  findMarketingIdsByCampaign(campaignId: mongoose.Types.ObjectId): Promise<mongoose.Types.ObjectId[]>;
27
+ findParticipantIdsByCampaignId(campaignId: mongoose.Types.ObjectId): Promise<mongoose.Types.ObjectId[]>;
27
28
  findByCampaign(dto: GetLtoCampaignParticipantsDTO): Promise<{
28
29
  documents: LtoCampaignParticipantItemDTO[];
29
30
  total: number;
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer-participant.repository.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EACN,2BAA2B,IAAI,KAAK,EAIpC,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EACN,6BAA6B,EAC7B,6BAA6B,EAC7B,MAAM,oDAAoD,CAAC;AAE5D,OAAO,EACN,6BAA6B,E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AC,QAAQ,EACnC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,IAAI,EAAE,wBAAwB,GAC5B,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAQhC,iBAAiB,CACtB,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GACnC,OAAO,CAAC,MAAM,CAAC;IAKZ,0BAA0B,CAC/B,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GACpC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAa/B,0BAA0B,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAQnG,cAAc,CACnB,GAAG,EAAE,6BAA6B,GAChC,OAAO,CAAC;QAAE,SAAS,EAAE,6BAA6B,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CA8CzE;AAED,eAAO,MAAM,wBAAwB,0BAA0C,CAAC"}
1
+ {"version":3,"file":"limited-time-offer-participant.repository.d.ts","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EACN,2BAA2B,IAAI,KAAK,EAIpC,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EACN,6BAA6B,EAC7B,6BAA6B,EAC7B,MAAM,oDAAoD,CAAC;AAE5D,OAAO,EACN,6BAA6B,EAC7B,qBAAqB,EACrB,wBAAwB,EACxB,MAAM,6CAA6C,CAAC;AAErD,qBACa,wBAAwB;IACpC,OAAO,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,GAC5B,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAQhC,iBAAiB,CACtB,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GACnC,OAAO,CAAC,MAAM,CAAC;IAKZ,0BAA0B,CAC/B,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAC/B,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GACpC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAa/B,0BAA0B,CAAC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAQnG,8BAA8B,CACnC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GACjC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAU/B,cAAc,CACnB,GAAG,EAAE,6BAA6B,GAChC,OAAO,CAAC;QAAE,SAAS,EAAE,6BAA6B,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CA8CzE;AAED,eAAO,MAAM,wBAAwB,0BAA0C,CAAC"}
@@ -96,7 +96,6 @@ let LtoParticipantRepository = class LtoParticipantRepository {
96
96
  return this.model.create(input);
97
97
  }
98
98
  async updateShopOrderCapacity(shopId, isOrderCapacityEnabled, maxOrderCapacity) {
99
- console.log('Updating shop order capacity', { shopId, isOrderCapacityEnabled, maxOrderCapacity });
100
99
  return this.shopModel.findByIdAndUpdate(shopId, {
101
100
  $set: {
102
101
  orderCapacityEnabled: isOrderCapacityEnabled,
@@ -156,6 +155,14 @@ let LtoParticipantRepository = class LtoParticipantRepository {
156
155
  .lean();
157
156
  return participants.map(p => p.marketing).filter(Boolean);
158
157
  }
158
+ async findParticipantIdsByCampaignId(campaignId) {
159
+ const participants = await this.model
160
+ .find({ campaign: campaignId, isWithdrawn: false })
161
+ .select("shop")
162
+ .lean()
163
+ .exec();
164
+ return participants.map((p) => p.shop);
165
+ }
159
166
  async findByCampaign(dto) {
160
167
  const filter = limited_time_offer_participant_builder_1.LtoParticipantQueryBuilder.buildCampaignFilter(dto);
161
168
  const search = limited_time_offer_participant_builder_1.LtoParticipantQueryBuilder.buildSearchTerm(dto);
@@ -1 +1 @@
1
- {"version":3,"file":"limited-time-offer-participant.repository.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAE5C,sEAKmD;AAMnD,qGAAsF;AAQ/E,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAC5B,KAAK,CAAmE;IACxE,SAAS,CAAmB;IAEpC;QACC,IAAI,CAAC,KAAK,GAAG,yCACU,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,kBAA6B,CAAC;IAChD,CAAC;IAEM,KAAK,CAAC,UAAU,CACtB,UAAmC,EACnC,KAGC,EACD,WAAmB;QAEnB,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,KAAK;aACnC,IAAI,CAAC;YACL,QAAQ,EAAE,UAAU;YACpB,WAAW,EAAE,KAAK;YAClB,SAAS,EAAE,IAAI;SACf,CAAC;aACD,MAAM,CAAC,MAAM,CAAC;aACd,IAAI,EAAE,CAAC;QAET,IAAI,CAAC,YAAY,CAAC,MAAM;YAAE,OAAO,EAAE,CAAC;QAEpC,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAE9C,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;YAC/B;gBACC,QAAQ,EAAE;oBACT,IAAI,EAAE;wBACL,IAAI,EAAE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EAAE,CAAC;oBAC5B,SAAS,EAAE;wBACV,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE;wBACpC,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE;wBACpB;4BACC,QAAQ,EAAE;gCACG,MAAM,EAAE,eAAe;gCACnC,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;gCAC/C,SAAS,EAAE,EAAE,OAAO,EAAE,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;gCAChD,QAAQ,EAAE,CAAC;gCACX,kBAAkB,EAAE,CAAC;gCACrB,cAAc,EAAE,CAAC;6BACjB;yBACD;qBACD;iBACD;aACD;SACD,CAAC,CAAC;QAEH,OAAO;YACN,SAAS,EAAE,MAAM,EAAE,SAAS,IAAI,EAAE;YAClC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC;SACrC,CAAC;IACH,CAAC;CACD,CAAA;AAzNY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,gBAAO,GAAE;;GACG,wBAAwB,CAyNpC;AAEY,QAAA,wBAAwB,GAAG,gBAAS,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { DocumentType, mongoose } from '@typegoose/typegoose';\nimport {\n\tLimitedTimeOfferParticipant as Model,\n\tLimitedTimeOfferParticipantModel,\n\tProductModel,\n\tShopModel,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport { SoftDeleteModel } from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport {\n\tGetLtoCampaignParticipantsDTO,\n\tLtoCampaignParticipantItemDTO,\n} from '../campaign/limited-time-offer-campaign.validation';\nimport { LtoParticipantQueryBuilder } from './limited-time-offer-participant.builder';\nimport {\n\tActiveParticipantMarketingDTO,\n\tParticipantSummaryDTO,\n\tUpdateParticipantDataDTO,\n} from './limited-time-offer-participant.validation';\n\n@Service()\nexport class LtoParticipantRepository {\n\tprivate model: typeof LimitedTimeOfferParticipantModel & SoftDeleteModel<Model>;\n\tprivate shopModel: typeof ShopModel;\n\n\tconstructor() {\n\t\tthis.model = LimitedTimeOfferParticipantModel as typeof LimitedTimeOfferParticipantModel &\n\t\t\tSoftDeleteModel<Model>;\n\t\tthis.shopModel = ShopModel as typeof ShopModel;\n\t}\n\n\tpublic async findNearby(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tinput: {\n\t\t\tlatitude: number;\n\t\t\tlongitude: number;\n\t\t},\n\t\tmaxDistance: number\n\t) {\n\t\tconst participants = await this.model\n\t\t\t.find({\n\t\t\t\tcampaign: campaignId,\n\t\t\t\tisWithdrawn: false,\n\t\t\t\tdeletedAt: null,\n\t\t\t})\n\t\t\t.select('shop')\n\t\t\t.lean();\n\n\t\tif (!participants.length) return [];\n\n\t\tconst shopIds = participants.map(p => p.shop);\n\n\t\treturn this.shopModel.aggregate([\n\t\t\t{\n\t\t\t\t$geoNear: {\n\t\t\t\t\tnear: {\n\t\t\t\t\t\ttype: 'Point',\n\t\t\t\t\t\tcoordinates: [input.longitude, input.latitude],\n\t\t\t\t\t},\n\t\t\t\t\tdistanceField: 'distance',\n\t\t\t\t\tmaxDistance: maxDistance,\n\t\t\t\t\tspherical: true,\n\t\t\t\t\tkey: 'address.location',\n\t\t\t\t\tquery: {\n\t\t\t\t\t\t_id: { $in: shopIds },\n\t\t\t\t\t\tstatus: 'active',\n\t\t\t\t\t\tdeletedAt: null,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t$project: {\n\t\t\t\t\t_id: 1,\n\t\t\t\t\tname: 1,\n\t\t\t\t\t'address.location': 1,\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tasync create(input: object): Promise<DocumentType<Model>> {\n\t\treturn this.model.create(input);\n\t}\n\n\tasync updateShopOrderCapacity(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tisOrderCapacityEnabled: boolean,\n\t\tmaxOrderCapacity?: number\n\t) {\n\t\tconsole.log('Updating shop order capacity', { shopId, isOrderCapacityEnabled, maxOrderCapacity });\n\t\treturn this.shopModel.findByIdAndUpdate(\n\t\t\tshopId,\n\t\t\t{\n\t\t\t\t$set: {\n\t\t\t\t\torderCapacityEnabled: isOrderCapacityEnabled,\n\t\t\t\t\torderCapacity: maxOrderCapacity,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{ new: true }\n\t\t);\n\t}\n\tasync findActiveByCampaignAndShop(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<ParticipantSummaryDTO | null> {\n\t\tconst result = await this.model\n\t\t\t.findOne({ campaign: campaignId, shop: shopId, isWithdrawn: false })\n\t\t\t.select(\n\t\t\t\t'discountPercentage maxDiscountCap joinedAt isEntireMenu isOrderCapacityEnabled maxOrderCapacity products marketing'\n\t\t\t)\n\t\t\t.lean();\n\t\tif (!result) return null;\n\t\tconst { products, marketing, ...rest } = result as any;\n\t\treturn { ...rest, productIds: products ?? [], marketingId: marketing };\n\t}\n\n\tasync withdraw(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<DocumentType<Model> | null> {\n\t\treturn this.model.findOneAndUpdate(\n\t\t\t{ campaign: campaignId, shop: shopId, isWithdrawn: false },\n\t\t\t{ $set: { isWithdrawn: true, withdrawnAt: new Date() } },\n\t\t\t{ new: true }\n\t\t);\n\t}\n\n\tasync existsActiveByCampaignAndShop(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<boolean> {\n\t\treturn !!(await this.model.exists({ campaign: campaignId, shop: shopId, isWithdrawn: false }));\n\t}\n\n\tasync findActiveForUpdate(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<ActiveParticipantMarketingDTO | null> {\n\t\tconst result = await this.model\n\t\t\t.findOne({ campaign: campaignId, shop: shopId, isWithdrawn: false })\n\t\t\t.select('marketing')\n\t\t\t.lean();\n\t\tif (!result) return null;\n\t\treturn { marketingId: (result as any).marketing };\n\t}\n\n\tasync updateParticipant(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdata: UpdateParticipantDataDTO\n\t): Promise<DocumentType<Model> | null> {\n\t\treturn this.model.findOneAndUpdate(\n\t\t\t{ campaign: campaignId, shop: shopId, isWithdrawn: false },\n\t\t\t{ $set: data },\n\t\t\t{ new: true }\n\t\t);\n\t}\n\n\tasync countShopProducts(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tproductIds: mongoose.Types.ObjectId[]\n\t): Promise<number> {\n\t\tif (!productIds.length) return 0;\n\t\treturn ProductModel.countDocuments({ _id: { $in: productIds }, shop: shopId, deletedAt: null });\n\t}\n\n\tasync findProductIdsByCategories(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tcategoryIds: mongoose.Types.ObjectId[]\n\t): Promise<mongoose.Types.ObjectId[]> {\n\t\tif (!categoryIds.length) return [];\n\t\t// Shop-scoped so the {shop, shopCategory} partial index is used; only _id is needed.\n\t\tconst products = await ProductModel.find({\n\t\t\tshop: shopId,\n\t\t\tshopCategory: { $in: categoryIds },\n\t\t\tdeletedAt: null,\n\t\t})\n\t\t\t.select('_id')\n\t\t\t.lean();\n\t\treturn products.map(p => p._id as mongoose.Types.ObjectId);\n\t}\n\n\tasync findMarketingIdsByCampaign(campaignId: mongoose.Types.ObjectId): Promise<mongoose.Types.ObjectId[]> {\n\t\tconst participants = await this.model\n\t\t\t.find({ campaign: campaignId, isWithdrawn: false, marketing: { $exists: true, $ne: null } })\n\t\t\t.select('marketing')\n\t\t\t.lean();\n\t\treturn participants.map(p => p.marketing as mongoose.Types.ObjectId).filter(Boolean);\n\t}\n\n\tasync findByCampaign(\n\t\tdto: GetLtoCampaignParticipantsDTO\n\t): Promise<{ documents: LtoCampaignParticipantItemDTO[]; total: number }> {\n\t\tconst filter = LtoParticipantQueryBuilder.buildCampaignFilter(dto);\n\t\tconst search = LtoParticipantQueryBuilder.buildSearchTerm(dto);\n\n\t\tconst [result] = await this.model.aggregate([\n\t\t\t{ $match: filter },\n\t\t\t{\n\t\t\t\t$lookup: {\n\t\t\t\t\tfrom: ShopModel.collection.name,\n\t\t\t\t\tlet: { shopId: '$shop' },\n\t\t\t\t\tpipeline: [\n\t\t\t\t\t\t{ $match: { $expr: { $eq: ['$_id', '$$shopId'] } } },\n\t\t\t\t\t\t{ $project: { name: 1, logo: 1 } },\n\t\t\t\t\t],\n\t\t\t\t\tas: 'shopData',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{ $unwind: { path: '$shopData', preserveNullAndEmptyArrays: true } },\n\t\t\t...(search ? [{ $match: { 'shopData.name': { $regex: search, $options: 'i' } } }] : []),\n\t\t\t{ $sort: { joinedAt: -1 } },\n\t\t\t{\n\t\t\t\t$facet: {\n\t\t\t\t\ttotal: [{ $count: 'count' }],\n\t\t\t\t\tdocuments: [\n\t\t\t\t\t\t{ $skip: (dto.page - 1) * dto.size },\n\t\t\t\t\t\t{ $limit: dto.size },\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$project: {\n \t\t\t\tshopId: '$shopData._id',\n\t\t\t\t\t\t\t\tshopName: { $ifNull: ['$shopData.name', null] },\n\t\t\t\t\t\t\t\tshopPhoto: { $ifNull: ['$shopData.logo', null] },\n\t\t\t\t\t\t\t\tjoinedAt: 1,\n\t\t\t\t\t\t\t\tdiscountPercentage: 1,\n\t\t\t\t\t\t\t\tmaxDiscountCap: 1,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\n\t\treturn {\n\t\t\tdocuments: result?.documents ?? [],\n\t\t\ttotal: result?.total?.[0]?.count ?? 0,\n\t\t};\n\t}\n}\n\nexport const ltoParticipantRepository = Container.get(LtoParticipantRepository);\n"]}
1
+ {"version":3,"file":"limited-time-offer-participant.repository.js","sourceRoot":"/","sources":["modules/limited-time-offer/participant/limited-time-offer-participant.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA0C;AAE1C,sEAKmD;AAMnD,qGAAoF;AAQ7E,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAC5B,KAAK,CAAmE;IACxE,SAAS,CAAmB;IAEpC;QACC,IAAI,CAAC,KAAK,GAAG,yCACU,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,kBAA6B,CAAC;IAChD,CAAC;IAEM,KAAK,CAAC,UAAU,CACtB,UAAmC,EACnC,KAGC,EACD,WAAmB;QAEnB,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,KAAK;aACnC,IAAI,CAAC;YACL,QAAQ,EAAE,UAAU;YACpB,WAAW,EAAE,KAAK;YAClB,SAAS,EAAE,IAAI;SACf,CAAC;aACD,MAAM,CAAC,MAAM,CAAC;aACd,IAAI,EAAE,CAAC;QAET,IAAI,CAAC,YAAY,CAAC,MAAM;YAAE,OAAO,EAAE,CAAC;QAEpC,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAE9C,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;YAC/B;gBACC,QAAQ,EAAE;oBACT,IAAI,EAAE;wBACL,IAAI,EAAE,OAAO;wBACb,WAAW,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC;qBAC9C;oBACD,aAAa,EAAE,UAAU;oBACzB,WAAW,EAAE,WAAW;oBACxB,SAAS,EAAE,IAAI;oBACf,GAAG,EAAE,kBAAkB;oBACvB,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P,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;oBAC5B,SAAS,EAAE;wBACV,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE;wBACpC,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE;wBACpB;4BACC,QAAQ,EAAE;gCACT,MAAM,EAAE,eAAe;gCACvB,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;gCAC/C,SAAS,EAAE,EAAE,OAAO,EAAE,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;gCAChD,QAAQ,EAAE,CAAC;gCACX,kBAAkB,EAAE,CAAC;gCACrB,cAAc,EAAE,CAAC;6BACjB;yBACD;qBACD;iBACD;aACD;SACD,CAAC,CAAC;QAEH,OAAO;YACN,SAAS,EAAE,MAAM,EAAE,SAAS,IAAI,EAAE;YAClC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC;SACrC,CAAC;IACH,CAAC;CACD,CAAA;AAnOY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,gBAAO,GAAE;;GACG,wBAAwB,CAmOpC;AAEY,QAAA,wBAAwB,GAAG,gBAAS,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC","sourcesContent":["import Container, {Service} from 'typedi';\nimport {DocumentType, mongoose} from '@typegoose/typegoose';\nimport {\n\tLimitedTimeOfferParticipant as Model,\n\tLimitedTimeOfferParticipantModel,\n\tProductModel,\n\tShopModel,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {SoftDeleteModel} from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport {\n\tGetLtoCampaignParticipantsDTO,\n\tLtoCampaignParticipantItemDTO,\n} from '../campaign/limited-time-offer-campaign.validation';\nimport {LtoParticipantQueryBuilder} from './limited-time-offer-participant.builder';\nimport {\n\tActiveParticipantMarketingDTO,\n\tParticipantSummaryDTO,\n\tUpdateParticipantDataDTO,\n} from './limited-time-offer-participant.validation';\n\n@Service()\nexport class LtoParticipantRepository {\n\tprivate model: typeof LimitedTimeOfferParticipantModel & SoftDeleteModel<Model>;\n\tprivate shopModel: typeof ShopModel;\n\n\tconstructor() {\n\t\tthis.model = LimitedTimeOfferParticipantModel as typeof LimitedTimeOfferParticipantModel &\n\t\t\tSoftDeleteModel<Model>;\n\t\tthis.shopModel = ShopModel as typeof ShopModel;\n\t}\n\n\tpublic async findNearby(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tinput: {\n\t\t\tlatitude: number;\n\t\t\tlongitude: number;\n\t\t},\n\t\tmaxDistance: number\n\t) {\n\t\tconst participants = await this.model\n\t\t\t.find({\n\t\t\t\tcampaign: campaignId,\n\t\t\t\tisWithdrawn: false,\n\t\t\t\tdeletedAt: null,\n\t\t\t})\n\t\t\t.select('shop')\n\t\t\t.lean();\n\n\t\tif (!participants.length) return [];\n\n\t\tconst shopIds = participants.map(p => p.shop);\n\n\t\treturn this.shopModel.aggregate([\n\t\t\t{\n\t\t\t\t$geoNear: {\n\t\t\t\t\tnear: {\n\t\t\t\t\t\ttype: 'Point',\n\t\t\t\t\t\tcoordinates: [input.longitude, input.latitude],\n\t\t\t\t\t},\n\t\t\t\t\tdistanceField: 'distance',\n\t\t\t\t\tmaxDistance: maxDistance,\n\t\t\t\t\tspherical: true,\n\t\t\t\t\tkey: 'address.location',\n\t\t\t\t\tquery: {\n\t\t\t\t\t\t_id: { $in: shopIds },\n\t\t\t\t\t\tstatus: 'active',\n\t\t\t\t\t\tdeletedAt: null,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t$project: {\n\t\t\t\t\t_id: 1,\n\t\t\t\t\tname: 1,\n\t\t\t\t\t'address.location': 1,\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tasync create(input: object): Promise<DocumentType<Model>> {\n\t\treturn this.model.create(input);\n\t}\n\tasync updateShopOrderCapacity(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tisOrderCapacityEnabled: boolean,\n\t\tmaxOrderCapacity?: number\n\t) {\n\t\treturn this.shopModel.findByIdAndUpdate(\n\t\t\tshopId,\n\t\t\t{\n\t\t\t\t$set: {\n\t\t\t\t\torderCapacityEnabled: isOrderCapacityEnabled,\n\t\t\t\t\torderCapacity: maxOrderCapacity,\n\t\t\t\t},\n\t\t\t},\n\t\t\t{ new: true }\n\t\t);\n\t}\n\tasync findActiveByCampaignAndShop(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<ParticipantSummaryDTO | null> {\n\t\tconst result = await this.model\n\t\t\t.findOne({ campaign: campaignId, shop: shopId, isWithdrawn: false })\n\t\t\t.select(\n\t\t\t\t'discountPercentage maxDiscountCap joinedAt isEntireMenu isOrderCapacityEnabled maxOrderCapacity products marketing'\n\t\t\t)\n\t\t\t.lean();\n\t\tif (!result) return null;\n\t\tconst { products, marketing, ...rest } = result as any;\n\t\treturn { ...rest, productIds: products ?? [], marketingId: marketing };\n\t}\n\n\tasync withdraw(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<DocumentType<Model> | null> {\n\t\treturn this.model.findOneAndUpdate(\n\t\t\t{ campaign: campaignId, shop: shopId, isWithdrawn: false },\n\t\t\t{ $set: { isWithdrawn: true, withdrawnAt: new Date() } },\n\t\t\t{ new: true }\n\t\t);\n\t}\n\n\tasync existsActiveByCampaignAndShop(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<boolean> {\n\t\treturn !!(await this.model.exists({ campaign: campaignId, shop: shopId, isWithdrawn: false }));\n\t}\n\n\tasync findActiveForUpdate(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId\n\t): Promise<ActiveParticipantMarketingDTO | null> {\n\t\tconst result = await this.model\n\t\t\t.findOne({ campaign: campaignId, shop: shopId, isWithdrawn: false })\n\t\t\t.select('marketing')\n\t\t\t.lean();\n\t\tif (!result) return null;\n\t\treturn { marketingId: (result as any).marketing };\n\t}\n\n\tasync updateParticipant(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tdata: UpdateParticipantDataDTO\n\t): Promise<DocumentType<Model> | null> {\n\t\treturn this.model.findOneAndUpdate(\n\t\t\t{ campaign: campaignId, shop: shopId, isWithdrawn: false },\n\t\t\t{ $set: data },\n\t\t\t{ new: true }\n\t\t);\n\t}\n\n\tasync countShopProducts(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tproductIds: mongoose.Types.ObjectId[]\n\t): Promise<number> {\n\t\tif (!productIds.length) return 0;\n\t\treturn ProductModel.countDocuments({ _id: { $in: productIds }, shop: shopId, deletedAt: null });\n\t}\n\n\tasync findProductIdsByCategories(\n\t\tshopId: mongoose.Types.ObjectId,\n\t\tcategoryIds: mongoose.Types.ObjectId[]\n\t): Promise<mongoose.Types.ObjectId[]> {\n\t\tif (!categoryIds.length) return [];\n\t\t// Shop-scoped so the {shop, shopCategory} partial index is used; only _id is needed.\n\t\tconst products = await ProductModel.find({\n\t\t\tshop: shopId,\n\t\t\tshopCategory: { $in: categoryIds },\n\t\t\tdeletedAt: null,\n\t\t})\n\t\t\t.select('_id')\n\t\t\t.lean();\n\t\treturn products.map(p => p._id as mongoose.Types.ObjectId);\n\t}\n\n\tasync findMarketingIdsByCampaign(campaignId: mongoose.Types.ObjectId): Promise<mongoose.Types.ObjectId[]> {\n\t\tconst participants = await this.model\n\t\t\t.find({ campaign: campaignId, isWithdrawn: false, marketing: { $exists: true, $ne: null } })\n\t\t\t.select('marketing')\n\t\t\t.lean();\n\t\treturn participants.map(p => p.marketing as mongoose.Types.ObjectId).filter(Boolean);\n\t}\n\n\tasync findParticipantIdsByCampaignId(\n\t\tcampaignId: mongoose.Types.ObjectId,\n\t): Promise<mongoose.Types.ObjectId[]> {\n\t\tconst participants = await this.model\n\t\t\t.find({campaign: campaignId, isWithdrawn: false})\n\t\t\t.select(\"shop\")\n\t\t\t.lean()\n\t\t\t.exec();\n\n\t\treturn participants.map((p) => p.shop as mongoose.Types.ObjectId);\n\t}\n\n\tasync findByCampaign(\n\t\tdto: GetLtoCampaignParticipantsDTO\n\t): Promise<{ documents: LtoCampaignParticipantItemDTO[]; total: number }> {\n\t\tconst filter = LtoParticipantQueryBuilder.buildCampaignFilter(dto);\n\t\tconst search = LtoParticipantQueryBuilder.buildSearchTerm(dto);\n\n\t\tconst [result] = await this.model.aggregate([\n\t\t\t{ $match: filter },\n\t\t\t{\n\t\t\t\t$lookup: {\n\t\t\t\t\tfrom: ShopModel.collection.name,\n\t\t\t\t\tlet: { shopId: '$shop' },\n\t\t\t\t\tpipeline: [\n\t\t\t\t\t\t{ $match: { $expr: { $eq: ['$_id', '$$shopId'] } } },\n\t\t\t\t\t\t{ $project: { name: 1, logo: 1 } },\n\t\t\t\t\t],\n\t\t\t\t\tas: 'shopData',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{ $unwind: { path: '$shopData', preserveNullAndEmptyArrays: true } },\n\t\t\t...(search ? [{ $match: { 'shopData.name': { $regex: search, $options: 'i' } } }] : []),\n\t\t\t{ $sort: { joinedAt: -1 } },\n\t\t\t{\n\t\t\t\t$facet: {\n\t\t\t\t\ttotal: [{ $count: 'count' }],\n\t\t\t\t\tdocuments: [\n\t\t\t\t\t\t{ $skip: (dto.page - 1) * dto.size },\n\t\t\t\t\t\t{ $limit: dto.size },\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$project: {\n\t\t\t\t\t\t\t\tshopId: '$shopData._id',\n\t\t\t\t\t\t\t\tshopName: { $ifNull: ['$shopData.name', null] },\n\t\t\t\t\t\t\t\tshopPhoto: { $ifNull: ['$shopData.logo', null] },\n\t\t\t\t\t\t\t\tjoinedAt: 1,\n\t\t\t\t\t\t\t\tdiscountPercentage: 1,\n\t\t\t\t\t\t\t\tmaxDiscountCap: 1,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\n\t\treturn {\n\t\t\tdocuments: result?.documents ?? [],\n\t\t\ttotal: result?.total?.[0]?.count ?? 0,\n\t\t};\n\t}\n}\n\nexport const ltoParticipantRepository = Container.get(LtoParticipantRepository);\n"]}
@@ -140,6 +140,15 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
140
140
  success: boolean;
141
141
  data?: {
142
142
  campaignState: import("./limited-time-offer-participant.validation").LtoCardState;
143
+ campaign?: {
144
+ _id: string | mongoose.Types.ObjectId;
145
+ startDate?: Date | null | undefined;
146
+ endDate?: Date | null | undefined;
147
+ title?: string | undefined;
148
+ subTitle?: string | undefined;
149
+ discountOptions?: number[] | undefined;
150
+ maxDiscountCaps?: number[] | undefined;
151
+ } | undefined;
143
152
  participant?: {
144
153
  isEntireMenu: boolean;
145
154
  joinedAt: Date;
@@ -150,18 +159,18 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
150
159
  maxDiscountCap?: number | undefined;
151
160
  maxOrderCapacity?: number | undefined;
152
161
  } | undefined;
153
- campaign?: {
154
- _id: string | mongoose.Types.ObjectId;
155
- startDate?: Date | null | undefined;
156
- endDate?: Date | null | undefined;
157
- title?: string | undefined;
158
- subTitle?: string | undefined;
159
- discountOptions?: number[] | undefined;
160
- maxDiscountCaps?: number[] | undefined;
161
- } | undefined;
162
162
  } | {
163
163
  documents: {
164
164
  campaignState: import("./limited-time-offer-participant.validation").LtoCardState;
165
+ campaign?: {
166
+ _id: string | mongoose.Types.ObjectId;
167
+ startDate?: Date | null | undefined;
168
+ endDate?: Date | null | undefined;
169
+ title?: string | undefined;
170
+ subTitle?: string | undefined;
171
+ discountOptions?: number[] | undefined;
172
+ maxDiscountCaps?: number[] | undefined;
173
+ } | undefined;
165
174
  participant?: {
166
175
  isEntireMenu: boolean;
167
176
  joinedAt: Date;
@@ -172,15 +181,6 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
172
181
  maxDiscountCap?: number | undefined;
173
182
  maxOrderCapacity?: number | undefined;
174
183
  } | undefined;
175
- campaign?: {
176
- _id: string | mongoose.Types.ObjectId;
177
- startDate?: Date | null | undefined;
178
- endDate?: Date | null | undefined;
179
- title?: string | undefined;
180
- subTitle?: string | undefined;
181
- discountOptions?: number[] | undefined;
182
- maxDiscountCaps?: number[] | undefined;
183
- } | undefined;
184
184
  }[];
185
185
  metadata?: {
186
186
  page: number;
@@ -206,17 +206,17 @@ export declare const participantRouter: import("@trpc/server").TRPCBuiltRouter<{
206
206
  shopId: string | mongoose.Types.ObjectId;
207
207
  joinedAt: Date;
208
208
  shopName: string | null;
209
- shopPhoto?: string | null | undefined;
210
209
  discountPercentage?: number | undefined;
211
210
  maxDiscountCap?: number | undefined;
211
+ shopPhoto?: string | null | undefined;
212
212
  } | {
213
213
  documents: {
214
214
  shopId: string | mongoose.Types.ObjectId;
215
215
  joinedAt: Date;
216
216
  shopName: string | null;
217
- shopPhoto?: string | null | undefined;
218
217
  discountPercentage?: number | undefined;
219
218
  maxDiscountCap?: number | undefined;
219
+ shopPhoto?: string | null | undefined;
220
220
  }[];
221
221
  metadata?: {
222
222
  page: number;