@lyxa.ai/marketing 1.0.55 → 1.0.57
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-listeners/event-listeners.d.ts.map +1 -1
- package/dist/lib/event/event-listeners/event-listeners.js +19 -2
- package/dist/lib/event/event-listeners/event-listeners.js.map +1 -1
- package/dist/lib/index.d.ts +1314 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +6 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/modules/coupon/queues/coupon-notification.queue.d.ts +8 -0
- package/dist/lib/modules/coupon/queues/coupon-notification.queue.d.ts.map +1 -0
- package/dist/lib/modules/coupon/queues/coupon-notification.queue.js +54 -0
- package/dist/lib/modules/coupon/queues/coupon-notification.queue.js.map +1 -0
- package/dist/lib/modules/coupon/queues/coupon-notification.worker.d.ts +8 -0
- package/dist/lib/modules/coupon/queues/coupon-notification.worker.d.ts.map +1 -0
- package/dist/lib/modules/coupon/queues/coupon-notification.worker.js +83 -0
- package/dist/lib/modules/coupon/queues/coupon-notification.worker.js.map +1 -0
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts +1314 -0
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.js +20 -0
- package/dist/lib/modules/coupon/routers/coupon.router.js.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts +40 -3
- package/dist/lib/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.js +49 -0
- package/dist/lib/modules/coupon/services/coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts +1 -0
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js +52 -0
- package/dist/lib/modules/coupon/services/patterns/repository/CouponMetricsRepository.js.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.d.ts +26 -0
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.js +322 -0
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.js.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts +175 -0
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.js +53 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.js.map +1 -1
- package/dist/lib/modules/marketing/queues/marketing-product-sync.queue.d.ts +7 -0
- package/dist/lib/modules/marketing/queues/marketing-product-sync.queue.d.ts.map +1 -0
- package/dist/lib/modules/marketing/queues/marketing-product-sync.queue.js +62 -0
- package/dist/lib/modules/marketing/queues/marketing-product-sync.queue.js.map +1 -0
- package/dist/lib/modules/marketing/queues/marketing-product-sync.worker.d.ts +7 -0
- package/dist/lib/modules/marketing/queues/marketing-product-sync.worker.d.ts.map +1 -0
- package/dist/lib/modules/marketing/queues/marketing-product-sync.worker.js +94 -0
- package/dist/lib/modules/marketing/queues/marketing-product-sync.worker.js.map +1 -0
- package/dist/lib/modules/marketing/services/marketing.service.d.ts +2 -1
- package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/marketing.service.js +37 -29
- package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -1
- package/dist/types/event/event-listeners/event-listeners.d.ts.map +1 -1
- package/dist/types/index.d.ts +1314 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/coupon/queues/coupon-notification.queue.d.ts +8 -0
- package/dist/types/modules/coupon/queues/coupon-notification.queue.d.ts.map +1 -0
- package/dist/types/modules/coupon/queues/coupon-notification.worker.d.ts +8 -0
- package/dist/types/modules/coupon/queues/coupon-notification.worker.d.ts.map +1 -0
- package/dist/types/modules/coupon/routers/coupon.router.d.ts +1314 -0
- package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/coupon.service.d.ts +40 -3
- package/dist/types/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/patterns/repository/CouponMetricsRepository.d.ts +1 -0
- 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 +26 -0
- package/dist/types/modules/coupon/services/patterns/repository/CouponRepository.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts +175 -0
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
- package/dist/types/modules/marketing/queues/marketing-product-sync.queue.d.ts +7 -0
- package/dist/types/modules/marketing/queues/marketing-product-sync.queue.d.ts.map +1 -0
- package/dist/types/modules/marketing/queues/marketing-product-sync.worker.d.ts +7 -0
- package/dist/types/modules/marketing/queues/marketing-product-sync.worker.d.ts.map +1 -0
- package/dist/types/modules/marketing/services/marketing.service.d.ts +2 -1
- package/dist/types/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts +0 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts.map +0 -1
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.js +0 -2
- package/dist/lib/modules/limited-time-offer/participant/limited-time-offer-participant.service.js.map +0 -1
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts +0 -1
- package/dist/types/modules/limited-time-offer/participant/limited-time-offer-participant.service.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-listeners.d.ts","sourceRoot":"/","sources":["event/event-listeners/event-listeners.ts"],"names":[],"mappings":"AAaA,wBAAsB,0DAA0D,kBAI/E;
|
|
1
|
+
{"version":3,"file":"event-listeners.d.ts","sourceRoot":"/","sources":["event/event-listeners/event-listeners.ts"],"names":[],"mappings":"AAaA,wBAAsB,0DAA0D,kBAI/E;AAgBD,wBAAsB,uCAAuC,kBA4D5D;AAED,wBAAsB,0CAA0C,kBAI/D"}
|
|
@@ -17,10 +17,27 @@ async function subscribeToSyncAllProductsProductMarketingInfoProcessEvent() {
|
|
|
17
17
|
services_1.synchronizeProductMarketingService.processAllProductsProductMarketingInfoEvent(payload);
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
+
const noRequeue = (label, handler) => async (payload) => {
|
|
21
|
+
try {
|
|
22
|
+
await handler(payload);
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
(0, core_1.getLibraries)().getLoggerKit().error(`${label}: handler failed — dropping (no requeue)`, err, {
|
|
26
|
+
tag: 'event.no-requeue',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
};
|
|
20
30
|
async function subscribeToMarketingEntireMenuSeedEvent() {
|
|
21
|
-
await (0, event_1.subscribeToEvent)(marketing_product_seed_event_1.MARKETING_ENTIRE_MENU_SEED_EVENT, async (payload) => {
|
|
31
|
+
await (0, event_1.subscribeToEvent)(marketing_product_seed_event_1.MARKETING_ENTIRE_MENU_SEED_EVENT, noRequeue('entire-menu-seed', async (payload) => {
|
|
22
32
|
const logger = (0, core_1.getLibraries)().getLoggerKit();
|
|
23
33
|
const { marketingId: mid, shopId: sid, page, pageSize } = payload;
|
|
34
|
+
if (!typegoose_1.mongoose.isValidObjectId(mid) || !typegoose_1.mongoose.isValidObjectId(sid)) {
|
|
35
|
+
logger.error('entire-menu seed: invalid ids — dropping message', null, {
|
|
36
|
+
tag: 'marketing.seed.entire-menu',
|
|
37
|
+
data: { marketingId: mid, shopId: sid, page, pageSize },
|
|
38
|
+
});
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
24
41
|
const marketingId = new typegoose_1.mongoose.Types.ObjectId(mid);
|
|
25
42
|
const shopId = new typegoose_1.mongoose.Types.ObjectId(sid);
|
|
26
43
|
const MAX_ATTEMPTS = 3;
|
|
@@ -61,7 +78,7 @@ async function subscribeToMarketingEntireMenuSeedEvent() {
|
|
|
61
78
|
tag: 'marketing.seed.entire-menu',
|
|
62
79
|
data: { marketingId: mid, shopId: sid, page, pageSize },
|
|
63
80
|
});
|
|
64
|
-
});
|
|
81
|
+
}));
|
|
65
82
|
}
|
|
66
83
|
async function subscribeToMarketingReturnPunchCouponEvent() {
|
|
67
84
|
await (0, event_1.subscribeToEvent)(EventEnums_1.PublishEventEnums.MARKETING_RETURN_PUNCH_COUPON_EVENT, async (payload) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-listeners.js","sourceRoot":"/","sources":["event/event-listeners/event-listeners.ts"],"names":[],"mappings":";;AAaA,gIAIC;
|
|
1
|
+
{"version":3,"file":"event-listeners.js","sourceRoot":"/","sources":["event/event-listeners/event-listeners.ts"],"names":[],"mappings":";;AAaA,gIAIC;AAgBD,0FA4DC;AAED,gGAIC;AAnGD,8DAAsE;AACtE,wCAA6C;AAC7C,0DAA0G;AAC1G,8EAAkF;AAClF,oDAAgD;AAChD,6JAAsI;AACtI,8FAAsH;AACtH,yFAGgD;AAChD,wEAAyF;AAElF,KAAK,UAAU,0DAA0D;IAC/E,MAAM,IAAA,wBAAgB,EAAC,8BAAiB,CAAC,8CAA8C,EAAE,KAAK,EAAC,OAAO,EAAC,EAAE;QACxG,6CAAkC,CAAC,2CAA2C,CAAC,OAAO,CAAC,CAAC;IACzF,CAAC,CAAC,CAAC;AACJ,CAAC;AAID,MAAM,SAAS,GACd,CAAI,KAAa,EAAE,OAAsC,EAAE,EAAE,CAC7D,KAAK,EAAE,OAAU,EAAiB,EAAE;IACnC,IAAI,CAAC;QACJ,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACxB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,IAAA,mBAAY,GAAE,CAAC,YAAY,EAAE,CA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,0CAA0C;IAC/D,MAAM,IAAA,wBAAgB,EAAC,8BAAiB,CAAC,mCAAmC,EAAE,KAAK,EAAC,OAAO,EAAC,EAAE;QAC7F,uCAA4B,CAAC,iBAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;AACJ,CAAC","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\n// subscribeToEvent nacks with requeue=true on a thrown handler, so a failing message\n// bounces back to the queue forever. Swallow throws here -> handler returns -> message acked.\nconst noRequeue =\n\t<T>(label: string, handler: (payload: T) => Promise<void>) =>\n\tasync (payload: T): Promise<void> => {\n\t\ttry {\n\t\t\tawait handler(payload);\n\t\t} catch (err) {\n\t\t\tgetLibraries().getLoggerKit().error(`${label}: handler failed — dropping (no requeue)`, err, {\n\t\t\t\ttag: 'event.no-requeue',\n\t\t\t});\n\t\t}\n\t};\n\nexport async function subscribeToMarketingEntireMenuSeedEvent() {\n\tawait subscribeToEvent(MARKETING_ENTIRE_MENU_SEED_EVENT, noRequeue('entire-menu-seed', async (payload: MarketingProductSeedPayload) => {\n\t\tconst logger = getLibraries().getLoggerKit();\n\t\tconst { marketingId: mid, shopId: sid, page, pageSize } = payload;\n\n\t\tif (!mongoose.isValidObjectId(mid) || !mongoose.isValidObjectId(sid)) {\n\t\t\tlogger.error('entire-menu seed: invalid ids — dropping message', null, {\n\t\t\t\ttag: 'marketing.seed.entire-menu',\n\t\t\t\tdata: { marketingId: mid, shopId: sid, page, pageSize },\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\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"]}
|