@lyxa.ai/marketing 1.0.29 → 1.0.31
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 +2 -0
- package/dist/lib/event/event-initializations.d.ts.map +1 -0
- package/dist/lib/event/event-initializations.js +8 -0
- package/dist/lib/event/event-initializations.js.map +1 -0
- package/dist/lib/event/event-listeners/event-listeners.d.ts +2 -0
- package/dist/lib/event/event-listeners/event-listeners.d.ts.map +1 -0
- package/dist/lib/event/event-listeners/event-listeners.js +12 -0
- package/dist/lib/event/event-listeners/event-listeners.js.map +1 -0
- package/dist/lib/index.d.ts +734 -78
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +17 -17
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts +710 -75
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.js +4 -0
- package/dist/lib/modules/coupon/routers/coupon.router.js.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts +2 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.js +42 -18
- package/dist/lib/modules/coupon/services/coupon.service.js.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 -1
- package/dist/lib/modules/coupon/services/global-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/helper.service.js +1 -1
- package/dist/lib/modules/coupon/services/helper.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/individual-store-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/individual-store-coupon.service.js +4 -1
- package/dist/lib/modules/coupon/services/individual-store-coupon.service.js.map +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 +1 -0
- package/dist/lib/modules/coupon/services/individual-user-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.d.ts +1 -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 +123 -5
- package/dist/lib/modules/coupon/services/patterns/repository/CouponRepository.js.map +1 -1
- package/dist/lib/modules/coupon/services/referral-code-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/referral-code-coupon.service.js +2 -0
- package/dist/lib/modules/coupon/services/referral-code-coupon.service.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 +4 -1
- 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.map +1 -1
- package/dist/lib/modules/coupon/services/shops-categories-coupon.service.js +4 -1
- package/dist/lib/modules/coupon/services/shops-categories-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts +153 -153
- package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/all-coupons.validation.js.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts +33 -12
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.js +12 -5
- package/dist/lib/modules/coupon/validations/coupon.validation.js.map +1 -1
- package/dist/lib/modules/coupon/validations/custom-coupon.validation.d.ts +8 -8
- package/dist/lib/modules/coupon/validations/global-coupon.validation.d.ts +8 -8
- package/dist/lib/modules/coupon/validations/individual-store-coupon.validation.d.ts +10 -10
- package/dist/lib/modules/coupon/validations/individual-user-coupon.validation.d.ts +8 -8
- package/dist/lib/modules/coupon/validations/referral-reward-coupon.validation.d.ts +9 -9
- package/dist/lib/modules/coupon/validations/shops-categories-coupon.validation.d.ts +8 -8
- package/dist/lib/modules/deal-setting/validations/deal-setting.validation.d.ts +1 -1
- package/dist/lib/modules/marketing/routers/marketing.router.d.ts +21 -0
- package/dist/lib/modules/marketing/routers/marketing.router.d.ts.map +1 -1
- package/dist/lib/modules/marketing/routers/marketing.router.js +19 -8
- package/dist/lib/modules/marketing/routers/marketing.router.js.map +1 -1
- package/dist/lib/modules/marketing/services/buy1-get1-marketing.service.d.ts +2 -1
- package/dist/lib/modules/marketing/services/buy1-get1-marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/buy1-get1-marketing.service.js +45 -102
- package/dist/lib/modules/marketing/services/buy1-get1-marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/services/discount-marketing.service.d.ts +2 -1
- package/dist/lib/modules/marketing/services/discount-marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/discount-marketing.service.js +54 -163
- package/dist/lib/modules/marketing/services/discount-marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/services/featured-marketing.service.d.ts +2 -0
- package/dist/lib/modules/marketing/services/featured-marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/featured-marketing.service.js +30 -2
- package/dist/lib/modules/marketing/services/featured-marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/services/free-delivery-marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/free-delivery-marketing.service.js +6 -1
- package/dist/lib/modules/marketing/services/free-delivery-marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/services/index.d.ts +1 -0
- package/dist/lib/modules/marketing/services/index.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/index.js +1 -0
- package/dist/lib/modules/marketing/services/index.js.map +1 -1
- package/dist/lib/modules/marketing/services/marketing.service.d.ts +6 -0
- package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/marketing.service.js +230 -8
- package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/services/product-marketing.service.d.ts +1 -0
- package/dist/lib/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/product-marketing.service.js +21 -3
- package/dist/lib/modules/marketing/services/product-marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/services/punch-marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/punch-marketing.service.js +6 -1
- package/dist/lib/modules/marketing/services/punch-marketing.service.js.map +1 -1
- package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.d.ts +14 -0
- package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.d.ts.map +1 -0
- package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.js +209 -0
- package/dist/lib/modules/marketing/services/synchronize-product-marketing.service.js.map +1 -0
- package/dist/lib/modules/marketing/transformers/buy1-get1-marketing.transformer.d.ts +2 -2
- package/dist/lib/modules/marketing/transformers/discount-marketing.transformer.d.ts +2 -2
- package/dist/lib/modules/marketing/validations/buy1-get1-marketing.validation.d.ts +58 -58
- package/dist/lib/modules/marketing/validations/discount-marketing.validation.d.ts +68 -68
- package/dist/lib/modules/marketing/validations/featured-marketing.validation.d.ts +21 -21
- package/dist/lib/modules/marketing/validations/free-delivery-marketing.validation.d.ts +18 -18
- package/dist/lib/modules/marketing/validations/marketing.validation.d.ts +14 -7
- package/dist/lib/modules/marketing/validations/marketing.validation.d.ts.map +1 -1
- package/dist/lib/modules/marketing/validations/marketing.validation.js +4 -1
- package/dist/lib/modules/marketing/validations/marketing.validation.js.map +1 -1
- package/dist/lib/modules/marketing/validations/product-marketing.validation.d.ts +4 -4
- package/dist/lib/modules/marketing/validations/punch-marketing.validation.d.ts +22 -22
- package/dist/lib/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +3 -3
- package/dist/lib/modules/punch-marketing-history/services/punch-marketing-history.service.js +2 -2
- 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 +6 -6
- package/dist/types/event/event-initializations.d.ts +2 -0
- package/dist/types/event/event-initializations.d.ts.map +1 -0
- package/dist/types/event/event-listeners/event-listeners.d.ts +2 -0
- package/dist/types/event/event-listeners/event-listeners.d.ts.map +1 -0
- package/dist/types/index.d.ts +734 -78
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/coupon/routers/coupon.router.d.ts +710 -75
- package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/coupon.service.d.ts +2 -1
- package/dist/types/modules/coupon/services/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/individual-store-coupon.service.d.ts.map +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/CouponRepository.d.ts +1 -0
- package/dist/types/modules/coupon/services/patterns/repository/CouponRepository.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/referral-code-coupon.service.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.map +1 -1
- package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts +153 -153
- package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts +33 -12
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/custom-coupon.validation.d.ts +8 -8
- package/dist/types/modules/coupon/validations/global-coupon.validation.d.ts +8 -8
- package/dist/types/modules/coupon/validations/individual-store-coupon.validation.d.ts +10 -10
- package/dist/types/modules/coupon/validations/individual-user-coupon.validation.d.ts +8 -8
- package/dist/types/modules/coupon/validations/referral-reward-coupon.validation.d.ts +9 -9
- package/dist/types/modules/coupon/validations/shops-categories-coupon.validation.d.ts +8 -8
- package/dist/types/modules/deal-setting/validations/deal-setting.validation.d.ts +1 -1
- package/dist/types/modules/marketing/routers/marketing.router.d.ts +21 -0
- package/dist/types/modules/marketing/routers/marketing.router.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/buy1-get1-marketing.service.d.ts +2 -1
- package/dist/types/modules/marketing/services/buy1-get1-marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/discount-marketing.service.d.ts +2 -1
- package/dist/types/modules/marketing/services/discount-marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/featured-marketing.service.d.ts +2 -0
- package/dist/types/modules/marketing/services/featured-marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/free-delivery-marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/index.d.ts +1 -0
- package/dist/types/modules/marketing/services/index.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/marketing.service.d.ts +6 -0
- package/dist/types/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/product-marketing.service.d.ts +1 -0
- package/dist/types/modules/marketing/services/product-marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/punch-marketing.service.d.ts.map +1 -1
- package/dist/types/modules/marketing/services/synchronize-product-marketing.service.d.ts +14 -0
- package/dist/types/modules/marketing/services/synchronize-product-marketing.service.d.ts.map +1 -0
- package/dist/types/modules/marketing/transformers/buy1-get1-marketing.transformer.d.ts +2 -2
- package/dist/types/modules/marketing/transformers/discount-marketing.transformer.d.ts +2 -2
- package/dist/types/modules/marketing/validations/buy1-get1-marketing.validation.d.ts +58 -58
- package/dist/types/modules/marketing/validations/discount-marketing.validation.d.ts +68 -68
- package/dist/types/modules/marketing/validations/featured-marketing.validation.d.ts +21 -21
- package/dist/types/modules/marketing/validations/free-delivery-marketing.validation.d.ts +18 -18
- package/dist/types/modules/marketing/validations/marketing.validation.d.ts +14 -7
- package/dist/types/modules/marketing/validations/marketing.validation.d.ts.map +1 -1
- package/dist/types/modules/marketing/validations/product-marketing.validation.d.ts +4 -4
- package/dist/types/modules/marketing/validations/punch-marketing.validation.d.ts +22 -22
- package/dist/types/modules/punch-marketing-history/routers/punch-marketing-history.router.d.ts +3 -3
- package/dist/types/modules/punch-marketing-history/validations/punch-marketing-history.validation.d.ts +6 -6
- package/package.json +2 -2
|
@@ -0,0 +1,209 @@
|
|
|
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.synchronizeProductMarketingService = exports.SynchronizeProductMarketingService = void 0;
|
|
46
|
+
const typedi_1 = __importStar(require("typedi"));
|
|
47
|
+
const core_1 = require("@lyxa.ai/core");
|
|
48
|
+
const models_1 = require("@lyxa.ai/core/dist/libraries/mongo/models");
|
|
49
|
+
const product_pipeline_stages_1 = require("@lyxa.ai/core/dist/utilities/pipelines/product-pipeline-stages");
|
|
50
|
+
const events_common_methods_1 = require("@lyxa.ai/core/dist/utilities/events-common-methods");
|
|
51
|
+
let SynchronizeProductMarketingService = class SynchronizeProductMarketingService {
|
|
52
|
+
productModel;
|
|
53
|
+
constructor() {
|
|
54
|
+
this.productModel = models_1.ProductModel;
|
|
55
|
+
}
|
|
56
|
+
async publishAllProductsProductMarketingInfoProcessEvent() {
|
|
57
|
+
await (0, events_common_methods_1.publishAllProductsProductMarketingInfoProcessEvent)({});
|
|
58
|
+
return 'Processing all products product marketing information! ';
|
|
59
|
+
}
|
|
60
|
+
processAllProductsProductMarketingInfoEvent(payload) {
|
|
61
|
+
this.syncAllProductsMarketingInfo();
|
|
62
|
+
return 'Processing all products product marketing information! ';
|
|
63
|
+
}
|
|
64
|
+
syncAllProductsMarketingInfo = async () => {
|
|
65
|
+
const CHUNK_SIZE = 500;
|
|
66
|
+
console.time('TOTAL_SYNC_TIME');
|
|
67
|
+
console.log('[SYNC] Starting product marketing info sync');
|
|
68
|
+
const cursor = this.productModel.find().select('_id shop price priceBreakdowns').lean().cursor();
|
|
69
|
+
const adminSettings = (await (0, core_1.getLibraries)().getCachedSettingsService().getSettings());
|
|
70
|
+
const exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;
|
|
71
|
+
const secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';
|
|
72
|
+
let batch = [];
|
|
73
|
+
let batchIndex = 0;
|
|
74
|
+
let totalProcessed = 0;
|
|
75
|
+
for await (const product of cursor) {
|
|
76
|
+
batch.push(product);
|
|
77
|
+
if (batch.length === CHUNK_SIZE) {
|
|
78
|
+
batchIndex++;
|
|
79
|
+
totalProcessed += batch.length;
|
|
80
|
+
console.log(`[SYNC][BATCH ${batchIndex}] Processing ${batch.length} products (Total processed: ${totalProcessed})`);
|
|
81
|
+
console.time(`[BATCH ${batchIndex}] TIME`);
|
|
82
|
+
await this.processProductsBatch(batch, exchangeRate, secondaryCurrencyName, batchIndex);
|
|
83
|
+
console.timeEnd(`[BATCH ${batchIndex}] TIME`);
|
|
84
|
+
batch = [];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (batch.length) {
|
|
88
|
+
batchIndex++;
|
|
89
|
+
totalProcessed += batch.length;
|
|
90
|
+
console.log(`[SYNC][BATCH ${batchIndex}] Processing remaining ${batch.length} products (Total processed: ${totalProcessed})`);
|
|
91
|
+
console.time(`[BATCH ${batchIndex}] TIME`);
|
|
92
|
+
await this.processProductsBatch(batch, exchangeRate, secondaryCurrencyName, batchIndex);
|
|
93
|
+
console.timeEnd(`[BATCH ${batchIndex}] TIME`);
|
|
94
|
+
}
|
|
95
|
+
console.log(`[SYNC] Completed. Total batches: ${batchIndex}, Total products: ${totalProcessed}`);
|
|
96
|
+
console.timeEnd('TOTAL_SYNC_TIME');
|
|
97
|
+
return 'Bulk product marketing info sync completed';
|
|
98
|
+
};
|
|
99
|
+
async processProductsBatch(productsBatch, exchangeRate, secondaryCurrencyName, batchIndex) {
|
|
100
|
+
const productIds = productsBatch.map(p => p._id);
|
|
101
|
+
console.log(`[BATCH ${batchIndex}] Aggregating marketing info for ${productIds.length} products`, `| First ID: ${productIds[0]}`, `| Last ID: ${productIds[productIds.length - 1]}`);
|
|
102
|
+
const results = await this.productModel.aggregate([
|
|
103
|
+
{ $match: { _id: { $in: productIds } } },
|
|
104
|
+
...(0, product_pipeline_stages_1.addProductMarketingInfo)(exchangeRate, secondaryCurrencyName),
|
|
105
|
+
{
|
|
106
|
+
$group: {
|
|
107
|
+
_id: '$_id',
|
|
108
|
+
productMarketingInfo: { $push: '$productMarketing' },
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
]);
|
|
112
|
+
console.log(`[BATCH ${batchIndex}] Aggregation completed. Result count: ${results.length}`);
|
|
113
|
+
const bulkOps = results.map(r => ({
|
|
114
|
+
updateOne: {
|
|
115
|
+
filter: { _id: r._id },
|
|
116
|
+
update: {
|
|
117
|
+
$set: {
|
|
118
|
+
productMarketingInfo: (r.productMarketingInfo ?? []).filter(Boolean).map((pm) => ({
|
|
119
|
+
marketing: pm.marketingInfo,
|
|
120
|
+
isBuy1Get1: pm.isBuy1Get1,
|
|
121
|
+
valueType: pm.valueType,
|
|
122
|
+
value: pm.value,
|
|
123
|
+
secondaryCurrencyValue: pm.secondaryCurrencyValue,
|
|
124
|
+
label: pm.label,
|
|
125
|
+
})),
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
}));
|
|
130
|
+
if (bulkOps.length) {
|
|
131
|
+
console.log(`[BATCH ${batchIndex}] bulkWrite started (${bulkOps.length} ops)`);
|
|
132
|
+
await this.productModel.bulkWrite(bulkOps, { ordered: false });
|
|
133
|
+
console.log(`[BATCH ${batchIndex}] bulkWrite completed`);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
console.log(`[BATCH ${batchIndex}] No bulk operations to write`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async getProductMarketingInfoByProductId(productId) {
|
|
140
|
+
const adminSettings = (await (0, core_1.getLibraries)().getCachedSettingsService().getSettings());
|
|
141
|
+
const exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;
|
|
142
|
+
const secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';
|
|
143
|
+
const result = await this.productModel.aggregate([
|
|
144
|
+
{
|
|
145
|
+
$match: { _id: productId },
|
|
146
|
+
},
|
|
147
|
+
...(0, product_pipeline_stages_1.addProductMarketingInfo)(exchangeRate, secondaryCurrencyName),
|
|
148
|
+
{
|
|
149
|
+
$group: {
|
|
150
|
+
_id: '$_id',
|
|
151
|
+
productMarketingInfo: {
|
|
152
|
+
$push: '$productMarketing',
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
]);
|
|
157
|
+
const productMarketingInfo = result?.[0]?.productMarketing
|
|
158
|
+
? [
|
|
159
|
+
{
|
|
160
|
+
marketing: result?.[0].productMarketing.marketingInfo,
|
|
161
|
+
isBuy1Get1: result?.[0].productMarketing.isBuy1Get1,
|
|
162
|
+
valueType: result?.[0].productMarketing.valueType,
|
|
163
|
+
value: result?.[0].productMarketing.value,
|
|
164
|
+
secondaryCurrencyValue: result?.[0].productMarketing.secondaryCurrencyValue,
|
|
165
|
+
label: result?.[0].productMarketing.label,
|
|
166
|
+
},
|
|
167
|
+
]
|
|
168
|
+
: [];
|
|
169
|
+
return productMarketingInfo;
|
|
170
|
+
}
|
|
171
|
+
async syncProductMarketingInfoByProductId(productId) {
|
|
172
|
+
const adminSettings = (await (0, core_1.getLibraries)().getCachedSettingsService().getSettings());
|
|
173
|
+
const exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;
|
|
174
|
+
const secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';
|
|
175
|
+
const result = await this.productModel.aggregate([
|
|
176
|
+
{
|
|
177
|
+
$match: {
|
|
178
|
+
_id: productId,
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
...(0, product_pipeline_stages_1.addProductMarketingInfo)(exchangeRate, secondaryCurrencyName),
|
|
182
|
+
]);
|
|
183
|
+
const productMarketingInfo = result?.[0]?.productMarketing
|
|
184
|
+
? [
|
|
185
|
+
{
|
|
186
|
+
marketing: result?.[0].productMarketing.marketingInfo,
|
|
187
|
+
isBuy1Get1: result?.[0].productMarketing.isBuy1Get1,
|
|
188
|
+
valueType: result?.[0].productMarketing.valueType,
|
|
189
|
+
value: result?.[0].productMarketing.value,
|
|
190
|
+
secondaryCurrencyValue: result?.[0].productMarketing.secondaryCurrencyValue,
|
|
191
|
+
label: result?.[0].productMarketing.label,
|
|
192
|
+
},
|
|
193
|
+
]
|
|
194
|
+
: [];
|
|
195
|
+
await this.productModel.updateOne({ _id: productId }, {
|
|
196
|
+
$set: {
|
|
197
|
+
productMarketingInfo,
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
return 'Synchronized product marketing info';
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
exports.SynchronizeProductMarketingService = SynchronizeProductMarketingService;
|
|
204
|
+
exports.SynchronizeProductMarketingService = SynchronizeProductMarketingService = __decorate([
|
|
205
|
+
(0, typedi_1.Service)(),
|
|
206
|
+
__metadata("design:paramtypes", [])
|
|
207
|
+
], SynchronizeProductMarketingService);
|
|
208
|
+
exports.synchronizeProductMarketingService = typedi_1.default.get(SynchronizeProductMarketingService);
|
|
209
|
+
//# sourceMappingURL=synchronize-product-marketing.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"synchronize-product-marketing.service.js","sourceRoot":"/","sources":["modules/marketing/services/synchronize-product-marketing.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAC5C,wCAA6C;AAG7C,sEAAoG;AACpG,4GAAyG;AACzG,8FAAwH;AAGjH,IAAM,kCAAkC,GAAxC,MAAM,kCAAkC;IACtC,YAAY,CAA+C;IAEnE;QACC,IAAI,CAAC,YAAY,GAAG,qBAA4D,CAAC;IAClF,CAAC;IAEM,KAAK,CAAC,kDAAkD;QAC9D,MAAM,IAAA,0EAAkD,EAAC,EAAE,CAAC,CAAC;QAC7D,OAAO,yDAAyD,CAAC;IAClE,CAAC;IAEM,2CAA2C,CACjD,OAAsD;QAEtD,IAAI,CAAC,4BAA4B,EAAE,CAAC;QACpC,OAAO,yDAAyD,CAAC;IAClE,CAAC;IAEM,4BAA4B,GAAG,KAAK,IAAkB,EAAE;QAC9D,MAAM,UAAU,GAAG,GAAG,CAAC;QAEvB,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAChC,OAAO,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;QAE3D,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,gCAAgC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,CAAC;QAEjG,MAAM,aAAa,GAAG,CAAC,MAAM,IAAA,mBAAY,GAAE,CAAC,wBAAwB,EAAE,CAAC,WAAW,EAAE,CAAY,CAAC;QAEjG,MAAM,YAAY,GAAG,aAAa,EAAE,eAAe,EAAE,YAAY,IAAI,CAAC,CAAC;QACvE,MAAM,qBAAqB,GAAG,aAAa,EAAE,eAAe,EAAE,iBAAiB,EAAE,IAAI,IAAI,KAAK,CAAC;QAE/F,IAAI,KAAK,G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AC,CAAC;QAEH,MAAM,oBAAoB,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,gBAAgB;YACzD,CAAC,CAAC;gBACA;oBACC,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,aAAa;oBACrD,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,UAAU;oBACnD,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,SAAS;oBACjD,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK;oBACzC,sBAAsB,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,sBAAsB;oBAC3E,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK;iBACzC;aACD;YACF,CAAC,CAAC,EAAE,CAAC;QAEN,MAAM,IAAI,CAAC,YAAY,CAAC,SAAS,CAChC,EAAE,GAAG,EAAE,SAAS,EAAE,EAClB;YACC,IAAI,EAAE;gBACL,oBAAoB;aACpB;SACD,CACD,CAAC;QACF,OAAO,qCAAqC,CAAC;IAC9C,CAAC;CACD,CAAA;AA3MY,gFAAkC;6CAAlC,kCAAkC;IAD9C,IAAA,gBAAO,GAAE;;GACG,kCAAkC,CA2M9C;AAEY,QAAA,kCAAkC,GAAG,gBAAS,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { getLibraries } from '@lyxa.ai/core';\nimport { mongoose } from '@typegoose/typegoose';\nimport { SoftDeleteModel } from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport { ProductModel, Product as Model, Setting } from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport { addProductMarketingInfo } from '@lyxa.ai/core/dist/utilities/pipelines/product-pipeline-stages';\nimport { publishAllProductsProductMarketingInfoProcessEvent } from '@lyxa.ai/core/dist/utilities/events-common-methods';\nimport { SynchronizeAllProductsProductMarketingInfoDTO } from '@lyxa.ai/core/dist/libraries/event/events/sync-all-products-product-marketing-info-event';\n@Service()\nexport class SynchronizeProductMarketingService {\n\tprivate productModel: typeof ProductModel & SoftDeleteModel<Model>;\n\n\tconstructor() {\n\t\tthis.productModel = ProductModel as typeof ProductModel & SoftDeleteModel<Model>;\n\t}\n\n\tpublic async publishAllProductsProductMarketingInfoProcessEvent() {\n\t\tawait publishAllProductsProductMarketingInfoProcessEvent({});\n\t\treturn 'Processing all products product marketing information! ';\n\t}\n\n\tpublic processAllProductsProductMarketingInfoEvent(\n\t\tpayload: SynchronizeAllProductsProductMarketingInfoDTO\n\t): string {\n\t\tthis.syncAllProductsMarketingInfo();\n\t\treturn 'Processing all products product marketing information! ';\n\t}\n\n\tpublic syncAllProductsMarketingInfo = async (): Promise<any> => {\n\t\tconst CHUNK_SIZE = 500;\n\n\t\tconsole.time('TOTAL_SYNC_TIME');\n\t\tconsole.log('[SYNC] Starting product marketing info sync');\n\n\t\tconst cursor = this.productModel.find().select('_id shop price priceBreakdowns').lean().cursor();\n\n\t\tconst adminSettings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\n\t\tconst exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;\n\t\tconst secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';\n\n\t\tlet batch: any[] = [];\n\t\tlet batchIndex = 0;\n\t\tlet totalProcessed = 0;\n\n\t\tfor await (const product of cursor) {\n\t\t\tbatch.push(product);\n\n\t\t\tif (batch.length === CHUNK_SIZE) {\n\t\t\t\tbatchIndex++;\n\t\t\t\ttotalProcessed += batch.length;\n\n\t\t\t\tconsole.log(\n\t\t\t\t\t`[SYNC][BATCH ${batchIndex}] Processing ${batch.length} products (Total processed: ${totalProcessed})`\n\t\t\t\t);\n\n\t\t\t\tconsole.time(`[BATCH ${batchIndex}] TIME`);\n\t\t\t\tawait this.processProductsBatch(batch, exchangeRate, secondaryCurrencyName, batchIndex);\n\t\t\t\tconsole.timeEnd(`[BATCH ${batchIndex}] TIME`);\n\n\t\t\t\tbatch = [];\n\t\t\t}\n\t\t}\n\n\t\t// Process remaining products\n\t\tif (batch.length) {\n\t\t\tbatchIndex++;\n\t\t\ttotalProcessed += batch.length;\n\n\t\t\tconsole.log(\n\t\t\t\t`[SYNC][BATCH ${batchIndex}] Processing remaining ${batch.length} products (Total processed: ${totalProcessed})`\n\t\t\t);\n\n\t\t\tconsole.time(`[BATCH ${batchIndex}] TIME`);\n\t\t\tawait this.processProductsBatch(batch, exchangeRate, secondaryCurrencyName, batchIndex);\n\t\t\tconsole.timeEnd(`[BATCH ${batchIndex}] TIME`);\n\t\t}\n\n\t\tconsole.log(`[SYNC] Completed. Total batches: ${batchIndex}, Total products: ${totalProcessed}`);\n\t\tconsole.timeEnd('TOTAL_SYNC_TIME');\n\n\t\treturn 'Bulk product marketing info sync completed';\n\t};\n\n\tprivate async processProductsBatch(\n\t\tproductsBatch: any[],\n\t\texchangeRate: number,\n\t\tsecondaryCurrencyName: string,\n\t\tbatchIndex: number\n\t): Promise<void> {\n\t\tconst productIds = productsBatch.map(p => p._id);\n\n\t\tconsole.log(\n\t\t\t`[BATCH ${batchIndex}] Aggregating marketing info for ${productIds.length} products`,\n\t\t\t`| First ID: ${productIds[0]}`,\n\t\t\t`| Last ID: ${productIds[productIds.length - 1]}`\n\t\t);\n\n\t\tconst results = await this.productModel.aggregate([\n\t\t\t{ $match: { _id: { $in: productIds } } },\n\t\t\t...addProductMarketingInfo(exchangeRate, secondaryCurrencyName),\n\t\t\t{\n\t\t\t\t$group: {\n\t\t\t\t\t_id: '$_id',\n\t\t\t\t\tproductMarketingInfo: { $push: '$productMarketing' },\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\n\t\tconsole.log(`[BATCH ${batchIndex}] Aggregation completed. Result count: ${results.length}`);\n\n\t\tconst bulkOps = results.map(r => ({\n\t\t\tupdateOne: {\n\t\t\t\tfilter: { _id: r._id },\n\t\t\t\tupdate: {\n\t\t\t\t\t$set: {\n\t\t\t\t\t\tproductMarketingInfo: (r.productMarketingInfo ?? []).filter(Boolean).map((pm: any) => ({\n\t\t\t\t\t\t\tmarketing: pm.marketingInfo,\n\t\t\t\t\t\t\tisBuy1Get1: pm.isBuy1Get1,\n\t\t\t\t\t\t\tvalueType: pm.valueType,\n\t\t\t\t\t\t\tvalue: pm.value,\n\t\t\t\t\t\t\tsecondaryCurrencyValue: pm.secondaryCurrencyValue,\n\t\t\t\t\t\t\tlabel: pm.label,\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\tif (bulkOps.length) {\n\t\t\tconsole.log(`[BATCH ${batchIndex}] bulkWrite started (${bulkOps.length} ops)`);\n\t\t\tawait this.productModel.bulkWrite(bulkOps, { ordered: false });\n\t\t\tconsole.log(`[BATCH ${batchIndex}] bulkWrite completed`);\n\t\t} else {\n\t\t\tconsole.log(`[BATCH ${batchIndex}] No bulk operations to write`);\n\t\t}\n\t}\n\n\tprivate async getProductMarketingInfoByProductId(productId: mongoose.Types.ObjectId): Promise<any[]> {\n\t\tconst adminSettings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\n\t\tconst exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;\n\t\tconst secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';\n\n\t\tconst result = await this.productModel.aggregate([\n\t\t\t{\n\t\t\t\t$match: { _id: productId },\n\t\t\t},\n\t\t\t...addProductMarketingInfo(exchangeRate, secondaryCurrencyName),\n\t\t\t{\n\t\t\t\t$group: {\n\t\t\t\t\t_id: '$_id',\n\t\t\t\t\tproductMarketingInfo: {\n\t\t\t\t\t\t$push: '$productMarketing',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\n\t\tconst productMarketingInfo = result?.[0]?.productMarketing\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tmarketing: result?.[0].productMarketing.marketingInfo,\n\t\t\t\t\t\tisBuy1Get1: result?.[0].productMarketing.isBuy1Get1,\n\t\t\t\t\t\tvalueType: result?.[0].productMarketing.valueType,\n\t\t\t\t\t\tvalue: result?.[0].productMarketing.value,\n\t\t\t\t\t\tsecondaryCurrencyValue: result?.[0].productMarketing.secondaryCurrencyValue,\n\t\t\t\t\t\tlabel: result?.[0].productMarketing.label,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t: [];\n\n\t\treturn productMarketingInfo;\n\t}\n\n\tpublic async syncProductMarketingInfoByProductId(productId: mongoose.Types.ObjectId) {\n\t\tconst adminSettings = (await getLibraries().getCachedSettingsService().getSettings()) as Setting;\n\t\tconst exchangeRate = adminSettings?.currencySetting?.exchangeRate ?? 0;\n\n\t\tconst secondaryCurrencyName = adminSettings?.currencySetting?.secondaryCurrency?.name ?? 'LBP';\n\t\tconst result = await this.productModel.aggregate([\n\t\t\t{\n\t\t\t\t$match: {\n\t\t\t\t\t_id: productId,\n\t\t\t\t},\n\t\t\t},\n\t\t\t...addProductMarketingInfo(exchangeRate, secondaryCurrencyName),\n\t\t]);\n\n\t\tconst productMarketingInfo = result?.[0]?.productMarketing\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tmarketing: result?.[0].productMarketing.marketingInfo,\n\t\t\t\t\t\tisBuy1Get1: result?.[0].productMarketing.isBuy1Get1,\n\t\t\t\t\t\tvalueType: result?.[0].productMarketing.valueType,\n\t\t\t\t\t\tvalue: result?.[0].productMarketing.value,\n\t\t\t\t\t\tsecondaryCurrencyValue: result?.[0].productMarketing.secondaryCurrencyValue,\n\t\t\t\t\t\tlabel: result?.[0].productMarketing.label,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t: [];\n\n\t\tawait this.productModel.updateOne(\n\t\t\t{ _id: productId },\n\t\t\t{\n\t\t\t\t$set: {\n\t\t\t\t\tproductMarketingInfo,\n\t\t\t\t},\n\t\t\t}\n\t\t);\n\t\treturn 'Synchronized product marketing info';\n\t}\n}\n\nexport const synchronizeProductMarketingService = Container.get(SynchronizeProductMarketingService);\n"]}
|
|
@@ -12,15 +12,15 @@ export declare const buy1Get1MarketingTransformer: import("@lyxa.ai/core/dist/ut
|
|
|
12
12
|
}, "strip", import("zod").ZodTypeAny, {
|
|
13
13
|
product: import("mongoose").Types.ObjectId;
|
|
14
14
|
value?: number | undefined;
|
|
15
|
+
valueType?: import("@lyxa.ai/core/dist/utilities/enum").ValueType | null | undefined;
|
|
15
16
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
16
17
|
isBuy1Get1?: boolean | undefined;
|
|
17
|
-
valueType?: import("@lyxa.ai/core/dist/utilities/enum").ValueType | null | undefined;
|
|
18
18
|
}, {
|
|
19
19
|
product: string | import("mongoose").Types.ObjectId;
|
|
20
20
|
value?: number | undefined;
|
|
21
|
+
valueType?: import("@lyxa.ai/core/dist/utilities/enum").ValueType | null | undefined;
|
|
21
22
|
marketing?: string | import("mongoose").Types.ObjectId | undefined;
|
|
22
23
|
isBuy1Get1?: boolean | undefined;
|
|
23
|
-
valueType?: import("@lyxa.ai/core/dist/utilities/enum").ValueType | null | undefined;
|
|
24
24
|
}>, "many">>>>;
|
|
25
25
|
excludeProducts: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodUnion<[import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodString, string, string>, import("mongoose").Types.ObjectId, string>, import("zod").ZodType<import("mongoose").Types.ObjectId, import("zod").ZodTypeDef, import("mongoose").Types.ObjectId>]>, "many">>>>;
|
|
26
26
|
spendLimit: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>;
|
|
@@ -16,15 +16,15 @@ export declare const discountMarketingTransformer: import("@lyxa.ai/core/dist/ut
|
|
|
16
16
|
}, "strip", import("zod").ZodTypeAny, {
|
|
17
17
|
product: import("mongoose").Types.ObjectId;
|
|
18
18
|
value?: number | undefined;
|
|
19
|
+
valueType?: import("@lyxa.ai/core/dist/utilities/enum").ValueType | null | undefined;
|
|
19
20
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
20
21
|
isBuy1Get1?: boolean | undefined;
|
|
21
|
-
valueType?: import("@lyxa.ai/core/dist/utilities/enum").ValueType | null | undefined;
|
|
22
22
|
}, {
|
|
23
23
|
product: string | import("mongoose").Types.ObjectId;
|
|
24
24
|
value?: number | undefined;
|
|
25
|
+
valueType?: import("@lyxa.ai/core/dist/utilities/enum").ValueType | null | undefined;
|
|
25
26
|
marketing?: string | import("mongoose").Types.ObjectId | undefined;
|
|
26
27
|
isBuy1Get1?: boolean | undefined;
|
|
27
|
-
valueType?: import("@lyxa.ai/core/dist/utilities/enum").ValueType | null | undefined;
|
|
28
28
|
}>, "many">>>>;
|
|
29
29
|
excludeProducts: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodUnion<[import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodString, string, string>, import("mongoose").Types.ObjectId, string>, import("zod").ZodType<import("mongoose").Types.ObjectId, import("zod").ZodTypeDef, import("mongoose").Types.ObjectId>]>, "many">>>>;
|
|
30
30
|
maxDiscountPerOrder: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>;
|
|
@@ -14,15 +14,15 @@ declare const Buy1Get1MarketingValidationSchema: z.ZodObject<{
|
|
|
14
14
|
}, "strip", z.ZodTypeAny, {
|
|
15
15
|
product: import("mongoose").Types.ObjectId;
|
|
16
16
|
value?: number | undefined;
|
|
17
|
+
valueType?: ValueType | null | undefined;
|
|
17
18
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
18
19
|
isBuy1Get1?: boolean | undefined;
|
|
19
|
-
valueType?: ValueType | null | undefined;
|
|
20
20
|
}, {
|
|
21
21
|
product: string | import("mongoose").Types.ObjectId;
|
|
22
22
|
value?: number | undefined;
|
|
23
|
+
valueType?: ValueType | null | undefined;
|
|
23
24
|
marketing?: string | import("mongoose").Types.ObjectId | undefined;
|
|
24
25
|
isBuy1Get1?: boolean | undefined;
|
|
25
|
-
valueType?: ValueType | null | undefined;
|
|
26
26
|
}>, "many">>>;
|
|
27
27
|
excludeProducts: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>, "many">>>;
|
|
28
28
|
spendLimit: z.ZodDefault<z.ZodNumber>;
|
|
@@ -44,52 +44,52 @@ declare const Buy1Get1MarketingValidationSchema: z.ZodObject<{
|
|
|
44
44
|
pausedAt: z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>, z.ZodDate]>, Date, string | Date>, Date, string | Date>>>>;
|
|
45
45
|
admin: z.ZodNullable<z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>>>;
|
|
46
46
|
}, "strict", z.ZodTypeAny, {
|
|
47
|
-
isAppliedByCompany: boolean;
|
|
48
|
-
shop: import("mongoose").Types.ObjectId;
|
|
49
47
|
status: import("@lyxa.ai/core/dist/utilities/enum").MarketingStatus;
|
|
50
|
-
marketingType: MarketingType.BUY1GET1;
|
|
51
48
|
duration: {
|
|
52
49
|
start: Date;
|
|
53
50
|
end?: Date | undefined;
|
|
54
51
|
};
|
|
55
|
-
|
|
52
|
+
spendLimit: number;
|
|
53
|
+
isSpendLimitEnabled: boolean;
|
|
54
|
+
shop: import("mongoose").Types.ObjectId;
|
|
56
55
|
products: {
|
|
57
56
|
product: import("mongoose").Types.ObjectId;
|
|
58
57
|
value?: number | undefined;
|
|
58
|
+
valueType?: ValueType | null | undefined;
|
|
59
59
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
60
60
|
isBuy1Get1?: boolean | undefined;
|
|
61
|
-
valueType?: ValueType | null | undefined;
|
|
62
61
|
}[];
|
|
62
|
+
marketingType: MarketingType.BUY1GET1;
|
|
63
|
+
isAppliedByCompany: boolean;
|
|
64
|
+
pausedAt: Date | null;
|
|
63
65
|
categories: import("mongoose").Types.ObjectId[];
|
|
64
66
|
isEntireMenu: boolean;
|
|
65
67
|
excludeProducts: import("mongoose").Types.ObjectId[];
|
|
66
|
-
spendLimit: number;
|
|
67
|
-
isSpendLimitEnabled: boolean;
|
|
68
68
|
isOnlyForSubscriber: boolean;
|
|
69
69
|
admin?: import("mongoose").Types.ObjectId | null | undefined;
|
|
70
70
|
}, {
|
|
71
|
-
isAppliedByCompany: boolean;
|
|
72
|
-
shop: string | import("mongoose").Types.ObjectId;
|
|
73
|
-
marketingType: MarketingType.BUY1GET1;
|
|
74
71
|
duration: {
|
|
75
72
|
start: string | Date;
|
|
76
73
|
end?: string | Date | undefined;
|
|
77
74
|
};
|
|
75
|
+
shop: string | import("mongoose").Types.ObjectId;
|
|
76
|
+
marketingType: MarketingType.BUY1GET1;
|
|
77
|
+
isAppliedByCompany: boolean;
|
|
78
78
|
status?: import("@lyxa.ai/core/dist/utilities/enum").MarketingStatus | undefined;
|
|
79
|
-
|
|
79
|
+
spendLimit?: number | undefined;
|
|
80
|
+
isSpendLimitEnabled?: boolean | undefined;
|
|
80
81
|
admin?: string | import("mongoose").Types.ObjectId | null | undefined;
|
|
81
82
|
products?: {
|
|
82
83
|
product: string | import("mongoose").Types.ObjectId;
|
|
83
84
|
value?: number | undefined;
|
|
85
|
+
valueType?: ValueType | null | undefined;
|
|
84
86
|
marketing?: string | import("mongoose").Types.ObjectId | undefined;
|
|
85
87
|
isBuy1Get1?: boolean | undefined;
|
|
86
|
-
valueType?: ValueType | null | undefined;
|
|
87
88
|
}[] | undefined;
|
|
89
|
+
pausedAt?: string | Date | null | undefined;
|
|
88
90
|
categories?: (string | import("mongoose").Types.ObjectId)[] | undefined;
|
|
89
91
|
isEntireMenu?: boolean | undefined;
|
|
90
92
|
excludeProducts?: (string | import("mongoose").Types.ObjectId)[] | undefined;
|
|
91
|
-
spendLimit?: number | undefined;
|
|
92
|
-
isSpendLimitEnabled?: boolean | undefined;
|
|
93
93
|
isOnlyForSubscriber?: boolean | undefined;
|
|
94
94
|
}>, Buy1Get1MarketingSchema: z.ZodObject<{
|
|
95
95
|
marketingType: z.ZodOptional<z.ZodLiteral<MarketingType.BUY1GET1>>;
|
|
@@ -104,15 +104,15 @@ declare const Buy1Get1MarketingValidationSchema: z.ZodObject<{
|
|
|
104
104
|
}, "strip", z.ZodTypeAny, {
|
|
105
105
|
product: import("mongoose").Types.ObjectId;
|
|
106
106
|
value?: number | undefined;
|
|
107
|
+
valueType?: ValueType | null | undefined;
|
|
107
108
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
108
109
|
isBuy1Get1?: boolean | undefined;
|
|
109
|
-
valueType?: ValueType | null | undefined;
|
|
110
110
|
}, {
|
|
111
111
|
product: string | import("mongoose").Types.ObjectId;
|
|
112
112
|
value?: number | undefined;
|
|
113
|
+
valueType?: ValueType | null | undefined;
|
|
113
114
|
marketing?: string | import("mongoose").Types.ObjectId | undefined;
|
|
114
115
|
isBuy1Get1?: boolean | undefined;
|
|
115
|
-
valueType?: ValueType | null | undefined;
|
|
116
116
|
}>, "many">>>>;
|
|
117
117
|
excludeProducts: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>, "many">>>>;
|
|
118
118
|
spendLimit: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
@@ -147,15 +147,15 @@ declare const Buy1Get1MarketingValidationSchema: z.ZodObject<{
|
|
|
147
147
|
}, "strip", z.ZodTypeAny, {
|
|
148
148
|
product: import("mongoose").Types.ObjectId;
|
|
149
149
|
value?: number | undefined;
|
|
150
|
+
valueType?: ValueType | null | undefined;
|
|
150
151
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
151
152
|
isBuy1Get1?: boolean | undefined;
|
|
152
|
-
valueType?: ValueType | null | undefined;
|
|
153
153
|
}, {
|
|
154
154
|
product: string | import("mongoose").Types.ObjectId;
|
|
155
155
|
value?: number | undefined;
|
|
156
|
+
valueType?: ValueType | null | undefined;
|
|
156
157
|
marketing?: string | import("mongoose").Types.ObjectId | undefined;
|
|
157
158
|
isBuy1Get1?: boolean | undefined;
|
|
158
|
-
valueType?: ValueType | null | undefined;
|
|
159
159
|
}>, "many">>>>;
|
|
160
160
|
excludeProducts: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>, "many">>>>;
|
|
161
161
|
spendLimit: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
@@ -190,15 +190,15 @@ declare const Buy1Get1MarketingValidationSchema: z.ZodObject<{
|
|
|
190
190
|
}, "strip", z.ZodTypeAny, {
|
|
191
191
|
product: import("mongoose").Types.ObjectId;
|
|
192
192
|
value?: number | undefined;
|
|
193
|
+
valueType?: ValueType | null | undefined;
|
|
193
194
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
194
195
|
isBuy1Get1?: boolean | undefined;
|
|
195
|
-
valueType?: ValueType | null | undefined;
|
|
196
196
|
}, {
|
|
197
197
|
product: string | import("mongoose").Types.ObjectId;
|
|
198
198
|
value?: number | undefined;
|
|
199
|
+
valueType?: ValueType | null | undefined;
|
|
199
200
|
marketing?: string | import("mongoose").Types.ObjectId | undefined;
|
|
200
201
|
isBuy1Get1?: boolean | undefined;
|
|
201
|
-
valueType?: ValueType | null | undefined;
|
|
202
202
|
}>, "many">>>>;
|
|
203
203
|
excludeProducts: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>, "many">>>>;
|
|
204
204
|
spendLimit: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
@@ -239,15 +239,15 @@ declare const Buy1Get1MarketingValidationSchema: z.ZodObject<{
|
|
|
239
239
|
}, "strip", z.ZodTypeAny, {
|
|
240
240
|
product: import("mongoose").Types.ObjectId;
|
|
241
241
|
value?: number | undefined;
|
|
242
|
+
valueType?: ValueType | null | undefined;
|
|
242
243
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
243
244
|
isBuy1Get1?: boolean | undefined;
|
|
244
|
-
valueType?: ValueType | null | undefined;
|
|
245
245
|
}, {
|
|
246
246
|
product: string | import("mongoose").Types.ObjectId;
|
|
247
247
|
value?: number | undefined;
|
|
248
|
+
valueType?: ValueType | null | undefined;
|
|
248
249
|
marketing?: string | import("mongoose").Types.ObjectId | undefined;
|
|
249
250
|
isBuy1Get1?: boolean | undefined;
|
|
250
|
-
valueType?: ValueType | null | undefined;
|
|
251
251
|
}>, "many">>>>;
|
|
252
252
|
excludeProducts: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>, "many">>>>;
|
|
253
253
|
spendLimit: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
@@ -282,15 +282,15 @@ declare const Buy1Get1MarketingValidationSchema: z.ZodObject<{
|
|
|
282
282
|
}, "strip", z.ZodTypeAny, {
|
|
283
283
|
product: import("mongoose").Types.ObjectId;
|
|
284
284
|
value?: number | undefined;
|
|
285
|
+
valueType?: ValueType | null | undefined;
|
|
285
286
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
286
287
|
isBuy1Get1?: boolean | undefined;
|
|
287
|
-
valueType?: ValueType | null | undefined;
|
|
288
288
|
}, {
|
|
289
289
|
product: string | import("mongoose").Types.ObjectId;
|
|
290
290
|
value?: number | undefined;
|
|
291
|
+
valueType?: ValueType | null | undefined;
|
|
291
292
|
marketing?: string | import("mongoose").Types.ObjectId | undefined;
|
|
292
293
|
isBuy1Get1?: boolean | undefined;
|
|
293
|
-
valueType?: ValueType | null | undefined;
|
|
294
294
|
}>, "many">>>>;
|
|
295
295
|
excludeProducts: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>, "many">>>>;
|
|
296
296
|
spendLimit: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
@@ -325,15 +325,15 @@ declare const Buy1Get1MarketingValidationSchema: z.ZodObject<{
|
|
|
325
325
|
}, "strip", z.ZodTypeAny, {
|
|
326
326
|
product: import("mongoose").Types.ObjectId;
|
|
327
327
|
value?: number | undefined;
|
|
328
|
+
valueType?: ValueType | null | undefined;
|
|
328
329
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
329
330
|
isBuy1Get1?: boolean | undefined;
|
|
330
|
-
valueType?: ValueType | null | undefined;
|
|
331
331
|
}, {
|
|
332
332
|
product: string | import("mongoose").Types.ObjectId;
|
|
333
333
|
value?: number | undefined;
|
|
334
|
+
valueType?: ValueType | null | undefined;
|
|
334
335
|
marketing?: string | import("mongoose").Types.ObjectId | undefined;
|
|
335
336
|
isBuy1Get1?: boolean | undefined;
|
|
336
|
-
valueType?: ValueType | null | undefined;
|
|
337
337
|
}>, "many">>>>;
|
|
338
338
|
excludeProducts: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>, "many">>>>;
|
|
339
339
|
spendLimit: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
@@ -369,15 +369,15 @@ declare const Buy1Get1MarketingValidationSchemaRefined: z.ZodEffects<z.ZodObject
|
|
|
369
369
|
}, "strip", z.ZodTypeAny, {
|
|
370
370
|
product: import("mongoose").Types.ObjectId;
|
|
371
371
|
value?: number | undefined;
|
|
372
|
+
valueType?: ValueType | null | undefined;
|
|
372
373
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
373
374
|
isBuy1Get1?: boolean | undefined;
|
|
374
|
-
valueType?: ValueType | null | undefined;
|
|
375
375
|
}, {
|
|
376
376
|
product: string | import("mongoose").Types.ObjectId;
|
|
377
377
|
value?: number | undefined;
|
|
378
|
+
valueType?: ValueType | null | undefined;
|
|
378
379
|
marketing?: string | import("mongoose").Types.ObjectId | undefined;
|
|
379
380
|
isBuy1Get1?: boolean | undefined;
|
|
380
|
-
valueType?: ValueType | null | undefined;
|
|
381
381
|
}>, "many">>>;
|
|
382
382
|
excludeProducts: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>, "many">>>;
|
|
383
383
|
spendLimit: z.ZodDefault<z.ZodNumber>;
|
|
@@ -399,100 +399,100 @@ declare const Buy1Get1MarketingValidationSchemaRefined: z.ZodEffects<z.ZodObject
|
|
|
399
399
|
pausedAt: z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>, z.ZodDate]>, Date, string | Date>, Date, string | Date>>>>;
|
|
400
400
|
admin: z.ZodNullable<z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>>>;
|
|
401
401
|
}, "strict", z.ZodTypeAny, {
|
|
402
|
-
isAppliedByCompany: boolean;
|
|
403
|
-
shop: import("mongoose").Types.ObjectId;
|
|
404
402
|
status: import("@lyxa.ai/core/dist/utilities/enum").MarketingStatus;
|
|
405
|
-
marketingType: MarketingType.BUY1GET1;
|
|
406
403
|
duration: {
|
|
407
404
|
start: Date;
|
|
408
405
|
end?: Date | undefined;
|
|
409
406
|
};
|
|
410
|
-
|
|
407
|
+
spendLimit: number;
|
|
408
|
+
isSpendLimitEnabled: boolean;
|
|
409
|
+
shop: import("mongoose").Types.ObjectId;
|
|
411
410
|
products: {
|
|
412
411
|
product: import("mongoose").Types.ObjectId;
|
|
413
412
|
value?: number | undefined;
|
|
413
|
+
valueType?: ValueType | null | undefined;
|
|
414
414
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
415
415
|
isBuy1Get1?: boolean | undefined;
|
|
416
|
-
valueType?: ValueType | null | undefined;
|
|
417
416
|
}[];
|
|
417
|
+
marketingType: MarketingType.BUY1GET1;
|
|
418
|
+
isAppliedByCompany: boolean;
|
|
419
|
+
pausedAt: Date | null;
|
|
418
420
|
categories: import("mongoose").Types.ObjectId[];
|
|
419
421
|
isEntireMenu: boolean;
|
|
420
422
|
excludeProducts: import("mongoose").Types.ObjectId[];
|
|
421
|
-
spendLimit: number;
|
|
422
|
-
isSpendLimitEnabled: boolean;
|
|
423
423
|
isOnlyForSubscriber: boolean;
|
|
424
424
|
admin?: import("mongoose").Types.ObjectId | null | undefined;
|
|
425
425
|
}, {
|
|
426
|
-
isAppliedByCompany: boolean;
|
|
427
|
-
shop: string | import("mongoose").Types.ObjectId;
|
|
428
|
-
marketingType: MarketingType.BUY1GET1;
|
|
429
426
|
duration: {
|
|
430
427
|
start: string | Date;
|
|
431
428
|
end?: string | Date | undefined;
|
|
432
429
|
};
|
|
430
|
+
shop: string | import("mongoose").Types.ObjectId;
|
|
431
|
+
marketingType: MarketingType.BUY1GET1;
|
|
432
|
+
isAppliedByCompany: boolean;
|
|
433
433
|
status?: import("@lyxa.ai/core/dist/utilities/enum").MarketingStatus | undefined;
|
|
434
|
-
|
|
434
|
+
spendLimit?: number | undefined;
|
|
435
|
+
isSpendLimitEnabled?: boolean | undefined;
|
|
435
436
|
admin?: string | import("mongoose").Types.ObjectId | null | undefined;
|
|
436
437
|
products?: {
|
|
437
438
|
product: string | import("mongoose").Types.ObjectId;
|
|
438
439
|
value?: number | undefined;
|
|
440
|
+
valueType?: ValueType | null | undefined;
|
|
439
441
|
marketing?: string | import("mongoose").Types.ObjectId | undefined;
|
|
440
442
|
isBuy1Get1?: boolean | undefined;
|
|
441
|
-
valueType?: ValueType | null | undefined;
|
|
442
443
|
}[] | undefined;
|
|
444
|
+
pausedAt?: string | Date | null | undefined;
|
|
443
445
|
categories?: (string | import("mongoose").Types.ObjectId)[] | undefined;
|
|
444
446
|
isEntireMenu?: boolean | undefined;
|
|
445
447
|
excludeProducts?: (string | import("mongoose").Types.ObjectId)[] | undefined;
|
|
446
|
-
spendLimit?: number | undefined;
|
|
447
|
-
isSpendLimitEnabled?: boolean | undefined;
|
|
448
448
|
isOnlyForSubscriber?: boolean | undefined;
|
|
449
449
|
}>, {
|
|
450
|
-
isAppliedByCompany: boolean;
|
|
451
|
-
shop: import("mongoose").Types.ObjectId;
|
|
452
450
|
status: import("@lyxa.ai/core/dist/utilities/enum").MarketingStatus;
|
|
453
|
-
marketingType: MarketingType.BUY1GET1;
|
|
454
451
|
duration: {
|
|
455
452
|
start: Date;
|
|
456
453
|
end?: Date | undefined;
|
|
457
454
|
};
|
|
458
|
-
|
|
455
|
+
spendLimit: number;
|
|
456
|
+
isSpendLimitEnabled: boolean;
|
|
457
|
+
shop: import("mongoose").Types.ObjectId;
|
|
459
458
|
products: {
|
|
460
459
|
product: import("mongoose").Types.ObjectId;
|
|
461
460
|
value?: number | undefined;
|
|
461
|
+
valueType?: ValueType | null | undefined;
|
|
462
462
|
marketing?: import("mongoose").Types.ObjectId | undefined;
|
|
463
463
|
isBuy1Get1?: boolean | undefined;
|
|
464
|
-
valueType?: ValueType | null | undefined;
|
|
465
464
|
}[];
|
|
465
|
+
marketingType: MarketingType.BUY1GET1;
|
|
466
|
+
isAppliedByCompany: boolean;
|
|
467
|
+
pausedAt: Date | null;
|
|
466
468
|
categories: import("mongoose").Types.ObjectId[];
|
|
467
469
|
isEntireMenu: boolean;
|
|
468
470
|
excludeProducts: import("mongoose").Types.ObjectId[];
|
|
469
|
-
spendLimit: number;
|
|
470
|
-
isSpendLimitEnabled: boolean;
|
|
471
471
|
isOnlyForSubscriber: boolean;
|
|
472
472
|
admin?: import("mongoose").Types.ObjectId | null | undefined;
|
|
473
473
|
}, {
|
|
474
|
-
isAppliedByCompany: boolean;
|
|
475
|
-
shop: string | import("mongoose").Types.ObjectId;
|
|
476
|
-
marketingType: MarketingType.BUY1GET1;
|
|
477
474
|
duration: {
|
|
478
475
|
start: string | Date;
|
|
479
476
|
end?: string | Date | undefined;
|
|
480
477
|
};
|
|
478
|
+
shop: string | import("mongoose").Types.ObjectId;
|
|
479
|
+
marketingType: MarketingType.BUY1GET1;
|
|
480
|
+
isAppliedByCompany: boolean;
|
|
481
481
|
status?: import("@lyxa.ai/core/dist/utilities/enum").MarketingStatus | undefined;
|
|
482
|
-
|
|
482
|
+
spendLimit?: number | undefined;
|
|
483
|
+
isSpendLimitEnabled?: boolean | undefined;
|
|
483
484
|
admin?: string | import("mongoose").Types.ObjectId | null | undefined;
|
|
484
485
|
products?: {
|
|
485
486
|
product: string | import("mongoose").Types.ObjectId;
|
|
486
487
|
value?: number | undefined;
|
|
488
|
+
valueType?: ValueType | null | undefined;
|
|
487
489
|
marketing?: string | import("mongoose").Types.ObjectId | undefined;
|
|
488
490
|
isBuy1Get1?: boolean | undefined;
|
|
489
|
-
valueType?: ValueType | null | undefined;
|
|
490
491
|
}[] | undefined;
|
|
492
|
+
pausedAt?: string | Date | null | undefined;
|
|
491
493
|
categories?: (string | import("mongoose").Types.ObjectId)[] | undefined;
|
|
492
494
|
isEntireMenu?: boolean | undefined;
|
|
493
495
|
excludeProducts?: (string | import("mongoose").Types.ObjectId)[] | undefined;
|
|
494
|
-
spendLimit?: number | undefined;
|
|
495
|
-
isSpendLimitEnabled?: boolean | undefined;
|
|
496
496
|
isOnlyForSubscriber?: boolean | undefined;
|
|
497
497
|
}>;
|
|
498
498
|
export { Buy1Get1MarketingValidationSchemaRefined as Buy1Get1MarketingValidationSchema, Buy1Get1MarketingSchema, Buy1Get1MarketingIdSchema as Buy1Get1MarketingIdValidationSchema, UpdateBuy1Get1MarketingSchema, };
|