@lyxa.ai/marketing 1.0.43 → 1.0.46
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.
- package/dist/lib/event/event-initializations.d.ts.map +1 -1
- package/dist/lib/event/event-initializations.js +1 -0
- package/dist/lib/event/event-initializations.js.map +1 -1
- package/dist/lib/event/event-listeners/event-listeners.d.ts +1 -0
- package/dist/lib/event/event-listeners/event-listeners.d.ts.map +1 -1
- package/dist/lib/event/event-listeners/event-listeners.js +7 -0
- package/dist/lib/event/event-listeners/event-listeners.js.map +1 -1
- package/dist/lib/index.d.ts +162 -22
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts +103 -21
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.js +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.js.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts +3 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.js +33 -12
- package/dist/lib/modules/coupon/services/coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/custom-coupon.service.d.ts +208 -3
- package/dist/lib/modules/coupon/services/custom-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/global-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/global-coupon.service.js +2 -0
- package/dist/lib/modules/coupon/services/global-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/helper.service.d.ts +214 -4
- package/dist/lib/modules/coupon/services/helper.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/helper.service.js +114 -16
- package/dist/lib/modules/coupon/services/helper.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/individual-store-coupon.service.d.ts +208 -3
- package/dist/lib/modules/coupon/services/individual-store-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/individual-user-coupon.service.d.ts +1 -1
- package/dist/lib/modules/coupon/services/individual-user-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/individual-user-coupon.service.js +20 -11
- package/dist/lib/modules/coupon/services/individual-user-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js +3 -5
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.d.ts +2 -2
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.js +151 -45
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.js.map +1 -1
- package/dist/lib/modules/coupon/services/referral-reward-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/referral-reward-coupon.service.js +2 -0
- package/dist/lib/modules/coupon/services/referral-reward-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/shops-categories-coupon.service.d.ts +208 -3
- package/dist/lib/modules/coupon/services/shops-categories-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/transformers/coupon.transformer.d.ts +5 -1
- package/dist/lib/modules/coupon/transformers/coupon.transformer.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts +243 -23
- package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts +82 -17
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.js +25 -3
- package/dist/lib/modules/coupon/validations/coupon.validation.js.map +1 -1
- package/dist/lib/modules/coupon/validations/create-coupon.validation.d.ts +94 -6
- package/dist/lib/modules/coupon/validations/create-coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/custom-coupon.validation.d.ts +9 -0
- package/dist/lib/modules/coupon/validations/custom-coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/custom-coupon.validation.js +1 -0
- package/dist/lib/modules/coupon/validations/custom-coupon.validation.js.map +1 -1
- package/dist/lib/modules/coupon/validations/individual-store-coupon.validation.d.ts +200 -122
- package/dist/lib/modules/coupon/validations/individual-store-coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/individual-store-coupon.validation.js +20 -3
- package/dist/lib/modules/coupon/validations/individual-store-coupon.validation.js.map +1 -1
- package/dist/lib/modules/coupon/validations/individual-user-coupon.validation.d.ts +9 -0
- package/dist/lib/modules/coupon/validations/individual-user-coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/individual-user-coupon.validation.js +1 -0
- package/dist/lib/modules/coupon/validations/individual-user-coupon.validation.js.map +1 -1
- package/dist/lib/modules/coupon/validations/shops-categories-coupon.validation.d.ts +9 -0
- package/dist/lib/modules/coupon/validations/shops-categories-coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/shops-categories-coupon.validation.js +1 -0
- package/dist/lib/modules/coupon/validations/shops-categories-coupon.validation.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts +58 -0
- package/dist/lib/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +4 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js +18 -2
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.repository.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +58 -0
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.js +7 -0
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.router.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +137 -3
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js +11 -9
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.validation.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts +3 -0
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.js +4 -0
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.js.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +1 -0
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js +19 -0
- package/dist/lib/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.js.map +1 -1
- package/dist/lib/modules/marketing/routers/marketing.router.js.map +1 -1
- package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +1 -1
- package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts +1 -0
- package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts.map +1 -1
- package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.js +14 -0
- package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.js.map +1 -1
- package/dist/lib/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +2 -2
- package/dist/types/event/event-initializations.d.ts.map +1 -1
- package/dist/types/event/event-listeners/event-listeners.d.ts +1 -0
- package/dist/types/event/event-listeners/event-listeners.d.ts.map +1 -1
- package/dist/types/index.d.ts +162 -22
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/coupon/routers/coupon.router.d.ts +103 -21
- package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/coupon.service.d.ts +3 -1
- package/dist/types/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/custom-coupon.service.d.ts +208 -3
- package/dist/types/modules/coupon/services/custom-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/global-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/helper.service.d.ts +214 -4
- package/dist/types/modules/coupon/services/helper.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/individual-store-coupon.service.d.ts +208 -3
- package/dist/types/modules/coupon/services/individual-store-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/individual-user-coupon.service.d.ts +1 -1
- package/dist/types/modules/coupon/services/individual-user-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/patterns/repository/CouponRepository.d.ts +2 -2
- package/dist/types/modules/coupon/services/patterns/repository/CouponRepository.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/referral-reward-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/shops-categories-coupon.service.d.ts +208 -3
- package/dist/types/modules/coupon/services/shops-categories-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/transformers/coupon.transformer.d.ts +5 -1
- package/dist/types/modules/coupon/transformers/coupon.transformer.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts +243 -23
- package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts +82 -17
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/create-coupon.validation.d.ts +94 -6
- package/dist/types/modules/coupon/validations/create-coupon.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/custom-coupon.validation.d.ts +9 -0
- package/dist/types/modules/coupon/validations/custom-coupon.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/individual-store-coupon.validation.d.ts +200 -122
- package/dist/types/modules/coupon/validations/individual-store-coupon.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/individual-user-coupon.validation.d.ts +9 -0
- package/dist/types/modules/coupon/validations/individual-user-coupon.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/shops-categories-coupon.validation.d.ts +9 -0
- package/dist/types/modules/coupon/validations/shops-categories-coupon.validation.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts +58 -0
- package/dist/types/modules/limited-time-offer/limited-time-offer.router.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts +4 -1
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.repository.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts +58 -0
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.router.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts +137 -3
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.validation.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts +3 -0
- package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant-marketing.service.d.ts.map +1 -1
- package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts +1 -0
- package/dist/types/modules/limited-time-offer/participant/services/limited-time-offer-participant.service.d.ts.map +1 -1
- package/dist/types/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +1 -1
- package/dist/types/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts +1 -0
- package/dist/types/modules/punch-marketing-history/services/punch-marketing-history.service.d.ts.map +1 -1
- package/dist/types/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +2 -2
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-initializations.d.ts","sourceRoot":"/","sources":["event/event-initializations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"event-initializations.d.ts","sourceRoot":"/","sources":["event/event-initializations.ts"],"names":[],"mappings":"AAOA,wBAAsB,kBAAkB,kBAKvC"}
|
|
@@ -6,6 +6,7 @@ const jobs_1 = require("../modules/limited-time-offer/campaign/jobs");
|
|
|
6
6
|
async function initEventListeners() {
|
|
7
7
|
(0, event_listeners_1.subscribeToSyncAllProductsProductMarketingInfoProcessEvent)();
|
|
8
8
|
await (0, event_listeners_1.subscribeToMarketingEntireMenuSeedEvent)();
|
|
9
|
+
await (0, event_listeners_1.subscribeToMarketingReturnPunchCouponEvent)();
|
|
9
10
|
await (0, jobs_1.startBullMQWorkers)();
|
|
10
11
|
}
|
|
11
12
|
//# sourceMappingURL=event-initializations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-initializations.js","sourceRoot":"/","sources":["event/event-initializations.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"event-initializations.js","sourceRoot":"/","sources":["event/event-initializations.ts"],"names":[],"mappings":";;AAOA,gDAKC;AAZD,uEAI2C;AAC3C,oEAA+E;AAExE,KAAK,UAAU,kBAAkB;IACpC,IAAA,4EAA0D,GAAE,CAAC;IAC7D,MAAM,IAAA,yDAAuC,GAAE,CAAC;IAChD,MAAM,IAAA,4DAA0C,GAAE,CAAC;IACnD,MAAM,IAAA,yBAAkB,GAAE,CAAC;AAC/B,CAAC","sourcesContent":["import {\n subscribeToSyncAllProductsProductMarketingInfoProcessEvent,\n subscribeToMarketingEntireMenuSeedEvent,\n subscribeToMarketingReturnPunchCouponEvent,\n} from './event-listeners/event-listeners';\nimport { startBullMQWorkers } from '@modules/limited-time-offer/campaign/jobs';\n\nexport async function initEventListeners() {\n subscribeToSyncAllProductsProductMarketingInfoProcessEvent();\n await subscribeToMarketingEntireMenuSeedEvent();\n await subscribeToMarketingReturnPunchCouponEvent();\n await startBullMQWorkers();\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare function subscribeToSyncAllProductsProductMarketingInfoProcessEvent(): Promise<void>;
|
|
2
2
|
export declare function subscribeToMarketingEntireMenuSeedEvent(): Promise<void>;
|
|
3
|
+
export declare function subscribeToMarketingReturnPunchCouponEvent(): Promise<void>;
|
|
3
4
|
//# sourceMappingURL=event-listeners.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-listeners.d.ts","sourceRoot":"/","sources":["event/event-listeners/event-listeners.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"event-listeners.d.ts","sourceRoot":"/","sources":["event/event-listeners/event-listeners.ts"],"names":[],"mappings":"AAaA,wBAAsB,0DAA0D,kBAI/E;AAED,wBAAsB,uCAAuC,kBAmD5D;AAED,wBAAsB,0CAA0C,kBAI/D"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.subscribeToSyncAllProductsProductMarketingInfoProcessEvent = subscribeToSyncAllProductsProductMarketingInfoProcessEvent;
|
|
4
4
|
exports.subscribeToMarketingEntireMenuSeedEvent = subscribeToMarketingEntireMenuSeedEvent;
|
|
5
|
+
exports.subscribeToMarketingReturnPunchCouponEvent = subscribeToMarketingReturnPunchCouponEvent;
|
|
5
6
|
const event_1 = require("@lyxa.ai/core/dist/libraries/event");
|
|
6
7
|
const core_1 = require("@lyxa.ai/core");
|
|
7
8
|
const services_1 = require("../../modules/marketing/services");
|
|
@@ -10,6 +11,7 @@ const typegoose_1 = require("@typegoose/typegoose");
|
|
|
10
11
|
const mongo_stream_changes_batch_process_shops_event_1 = require("@lyxa.ai/core/dist/libraries/event/events/mongo-stream-changes-batch-process-shops-event");
|
|
11
12
|
const events_common_methods_1 = require("@lyxa.ai/core/dist/utilities/events-common-methods");
|
|
12
13
|
const marketing_product_seed_event_1 = require("../events/marketing-product-seed.event");
|
|
14
|
+
const services_2 = require("../../modules/punch-marketing-history/services");
|
|
13
15
|
async function subscribeToSyncAllProductsProductMarketingInfoProcessEvent() {
|
|
14
16
|
await (0, event_1.subscribeToEvent)(EventEnums_1.PublishEventEnums.SYNC_ALL_PRODUCTS_PRODUCT_MARKETING_INFO_EVENT, async (payload) => {
|
|
15
17
|
services_1.synchronizeProductMarketingService.processAllProductsProductMarketingInfoEvent(payload);
|
|
@@ -61,4 +63,9 @@ async function subscribeToMarketingEntireMenuSeedEvent() {
|
|
|
61
63
|
});
|
|
62
64
|
});
|
|
63
65
|
}
|
|
66
|
+
async function subscribeToMarketingReturnPunchCouponEvent() {
|
|
67
|
+
await (0, event_1.subscribeToEvent)(EventEnums_1.PublishEventEnums.MARKETING_RETURN_PUNCH_COUPON_EVENT, async (payload) => {
|
|
68
|
+
services_2.punchMarketingHistoryService.returnPunchCoupon(payload.orderId);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
64
71
|
//# sourceMappingURL=event-listeners.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-listeners.js","sourceRoot":"/","sources":["event/event-listeners/event-listeners.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"event-listeners.js","sourceRoot":"/","sources":["event/event-listeners/event-listeners.ts"],"names":[],"mappings":"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","sourcesContent":["import { subscribeToEvent } from '@lyxa.ai/core/dist/libraries/event';\nimport { getLibraries } from '@lyxa.ai/core';\nimport { productMarketingService, synchronizeProductMarketingService } from '@modules/marketing/services';\nimport { PublishEventEnums } from '@lyxa.ai/core/dist/libraries/event/EventEnums';\nimport { mongoose } from '@typegoose/typegoose';\nimport { ChangeStreamOperationTypes } from '@lyxa.ai/core/dist/libraries/event/events/mongo-stream-changes-batch-process-shops-event';\nimport { publishSyncSingleShopSectionsInCacheProcessEvent } from '@lyxa.ai/core/dist/utilities/events-common-methods';\nimport {\n\tMARKETING_ENTIRE_MENU_SEED_EVENT,\n\tMarketingProductSeedPayload,\n} from '../events/marketing-product-seed.event';\nimport { punchMarketingHistoryService } from '@modules/punch-marketing-history/services';\n\nexport async function subscribeToSyncAllProductsProductMarketingInfoProcessEvent() {\n\tawait subscribeToEvent(PublishEventEnums.SYNC_ALL_PRODUCTS_PRODUCT_MARKETING_INFO_EVENT, async payload => {\n\t\tsynchronizeProductMarketingService.processAllProductsProductMarketingInfoEvent(payload);\n\t});\n}\n\nexport async function subscribeToMarketingEntireMenuSeedEvent() {\n\tawait subscribeToEvent(MARKETING_ENTIRE_MENU_SEED_EVENT, async (payload: MarketingProductSeedPayload) => {\n\t\tconst logger = getLibraries().getLoggerKit();\n\t\tconst { marketingId: mid, shopId: sid, page, pageSize } = payload;\n\t\tconst marketingId = new mongoose.Types.ObjectId(mid);\n\t\tconst shopId = new mongoose.Types.ObjectId(sid);\n\n\t\tconst MAX_ATTEMPTS = 3;\n\t\tlet lastError: unknown;\n\n\t\tfor (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {\n\t\t\ttry {\n\t\t\t\tconst productIds = await productMarketingService.upsertProductMarketingsForPage({\n\t\t\t\t\tshop: shopId,\n\t\t\t\t\tmarketingId,\n\t\t\t\t\tpage,\n\t\t\t\t\tpageSize,\n\t\t\t\t\tisAppliedByCompany: payload.isAppliedByCompany,\n\t\t\t\t\tisBuy1Get1: payload.isBuy1Get1,\n\t\t\t\t\tvalue: payload.value,\n\t\t\t\t\tvalueType: payload.valueType,\n\t\t\t\t});\n\n\t\t\t\tif (productIds.length) {\n\t\t\t\t\tawait synchronizeProductMarketingService.syncProductMarketingInfoByProductIds(productIds);\n\t\t\t\t}\n\n\t\t\t\tpublishSyncSingleShopSectionsInCacheProcessEvent({\n\t\t\t\t\tshopId,\n\t\t\t\t\toperation: ChangeStreamOperationTypes.UPDATE,\n\t\t\t\t});\n\n\t\t\t\tlogger.debug(`page ${page} seeded — ${productIds.length} products updated`, {\n\t\t\t\t\ttag: 'marketing.seed.entire-menu',\n\t\t\t\t\tdata: { marketingId: mid, shopId: sid, page, count: productIds.length },\n\t\t\t\t});\n\n\t\t\t\treturn;\n\t\t\t} catch (error) {\n\t\t\t\tlastError = error;\n\t\t\t\tif (attempt < MAX_ATTEMPTS) {\n\t\t\t\t\tawait new Promise(resolve => setTimeout(resolve, 2000 * attempt));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlogger.error(`page ${page} seed failed after ${MAX_ATTEMPTS} attempts — manual reseed required`, lastError, {\n\t\t\ttag: 'marketing.seed.entire-menu',\n\t\t\tdata: { marketingId: mid, shopId: sid, page, pageSize },\n\t\t});\n\t});\n}\n\nexport async function subscribeToMarketingReturnPunchCouponEvent() {\n\tawait subscribeToEvent(PublishEventEnums.MARKETING_RETURN_PUNCH_COUPON_EVENT, async payload => {\n\t\tpunchMarketingHistoryService.returnPunchCoupon(payload.orderId);\n\t});\n}\n"]}
|