@lyxa.ai/marketing 1.0.24 → 1.0.26-test-01
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/index.d.ts +1302 -38
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts +1307 -43
- package/dist/lib/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/lib/modules/coupon/routers/coupon.router.js +21 -0
- package/dist/lib/modules/coupon/routers/coupon.router.js.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts +7 -1
- package/dist/lib/modules/coupon/services/coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/coupon.service.js +229 -41
- package/dist/lib/modules/coupon/services/coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/custom-coupon.service.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/custom-coupon.service.js +6 -2
- package/dist/lib/modules/coupon/services/custom-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 +6 -2
- package/dist/lib/modules/coupon/services/global-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/index.d.ts +1 -0
- package/dist/lib/modules/coupon/services/index.d.ts.map +1 -1
- package/dist/lib/modules/coupon/services/index.js +1 -0
- package/dist/lib/modules/coupon/services/index.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 +7 -3
- 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 +6 -2
- package/dist/lib/modules/coupon/services/individual-user-coupon.service.js.map +1 -1
- package/dist/lib/modules/coupon/services/referral-code-coupon.service.d.ts +1 -0
- 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 +11 -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 +6 -2
- 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 +14 -0
- package/dist/lib/modules/coupon/services/shops-categories-coupon.service.d.ts.map +1 -0
- package/dist/lib/modules/coupon/services/shops-categories-coupon.service.js +139 -0
- package/dist/lib/modules/coupon/services/shops-categories-coupon.service.js.map +1 -0
- package/dist/lib/modules/coupon/transformers/coupon.transformer.d.ts +51 -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 +973 -27
- package/dist/lib/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/all-coupons.validation.js +2 -0
- package/dist/lib/modules/coupon/validations/all-coupons.validation.js.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts +11 -0
- package/dist/lib/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.js +5 -1
- package/dist/lib/modules/coupon/validations/coupon.validation.js.map +1 -1
- package/dist/lib/modules/coupon/validations/index.d.ts +1 -0
- package/dist/lib/modules/coupon/validations/index.d.ts.map +1 -1
- package/dist/lib/modules/coupon/validations/index.js +1 -0
- package/dist/lib/modules/coupon/validations/index.js.map +1 -1
- package/dist/lib/modules/coupon/validations/individual-store-coupon.validation.d.ts +10 -19
- 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 +2 -3
- package/dist/lib/modules/coupon/validations/individual-store-coupon.validation.js.map +1 -1
- package/dist/lib/modules/coupon/validations/shops-categories-coupon.validation.d.ts +439 -0
- package/dist/lib/modules/coupon/validations/shops-categories-coupon.validation.d.ts.map +1 -0
- package/dist/lib/modules/coupon/validations/shops-categories-coupon.validation.js +22 -0
- package/dist/lib/modules/coupon/validations/shops-categories-coupon.validation.js.map +1 -0
- package/dist/lib/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/dist/lib/modules/marketing/services/marketing.service.js +2 -1
- package/dist/lib/modules/marketing/services/marketing.service.js.map +1 -1
- package/dist/types/index.d.ts +1302 -38
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/coupon/routers/coupon.router.d.ts +1307 -43
- package/dist/types/modules/coupon/routers/coupon.router.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/coupon.service.d.ts +7 -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.map +1 -1
- package/dist/types/modules/coupon/services/global-coupon.service.d.ts.map +1 -1
- package/dist/types/modules/coupon/services/index.d.ts +1 -0
- package/dist/types/modules/coupon/services/index.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/referral-code-coupon.service.d.ts +1 -0
- 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 +23 -0
- package/dist/types/modules/coupon/services/shops-categories-coupon.service.d.ts.map +1 -0
- package/dist/types/modules/coupon/transformers/coupon.transformer.d.ts +51 -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 +973 -27
- package/dist/types/modules/coupon/validations/all-coupons.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts +11 -0
- package/dist/types/modules/coupon/validations/coupon.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/index.d.ts +1 -0
- package/dist/types/modules/coupon/validations/index.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/individual-store-coupon.validation.d.ts +10 -19
- package/dist/types/modules/coupon/validations/individual-store-coupon.validation.d.ts.map +1 -1
- package/dist/types/modules/coupon/validations/shops-categories-coupon.validation.d.ts +448 -0
- package/dist/types/modules/coupon/validations/shops-categories-coupon.validation.d.ts.map +1 -0
- package/dist/types/modules/marketing/services/marketing.service.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/lib/modules/loyalty-point-setting/routers/index.d.ts +0 -2
- package/dist/lib/modules/loyalty-point-setting/routers/index.d.ts.map +0 -1
- package/dist/lib/modules/loyalty-point-setting/routers/index.js +0 -18
- package/dist/lib/modules/loyalty-point-setting/routers/index.js.map +0 -1
- package/dist/lib/modules/loyalty-point-setting/routers/loyalty-point-setting.router.d.ts +0 -321
- package/dist/lib/modules/loyalty-point-setting/routers/loyalty-point-setting.router.d.ts.map +0 -1
- package/dist/lib/modules/loyalty-point-setting/routers/loyalty-point-setting.router.js +0 -82
- package/dist/lib/modules/loyalty-point-setting/routers/loyalty-point-setting.router.js.map +0 -1
- package/dist/lib/modules/loyalty-point-setting/services/index.d.ts +0 -3
- package/dist/lib/modules/loyalty-point-setting/services/index.d.ts.map +0 -1
- package/dist/lib/modules/loyalty-point-setting/services/index.js +0 -19
- package/dist/lib/modules/loyalty-point-setting/services/index.js.map +0 -1
- package/dist/lib/modules/loyalty-point-setting/services/loyalty-point-category.service.d.ts +0 -16
- package/dist/lib/modules/loyalty-point-setting/services/loyalty-point-category.service.d.ts.map +0 -1
- package/dist/lib/modules/loyalty-point-setting/services/loyalty-point-category.service.js +0 -133
- package/dist/lib/modules/loyalty-point-setting/services/loyalty-point-category.service.js.map +0 -1
- package/dist/lib/modules/loyalty-point-setting/services/loyalty-point-setting.service.d.ts +0 -16
- package/dist/lib/modules/loyalty-point-setting/services/loyalty-point-setting.service.d.ts.map +0 -1
- package/dist/lib/modules/loyalty-point-setting/services/loyalty-point-setting.service.js +0 -156
- package/dist/lib/modules/loyalty-point-setting/services/loyalty-point-setting.service.js.map +0 -1
- package/dist/lib/modules/loyalty-point-setting/transformers/index.d.ts +0 -3
- package/dist/lib/modules/loyalty-point-setting/transformers/index.d.ts.map +0 -1
- package/dist/lib/modules/loyalty-point-setting/transformers/index.js +0 -19
- package/dist/lib/modules/loyalty-point-setting/transformers/index.js.map +0 -1
- package/dist/lib/modules/loyalty-point-setting/transformers/loyalty-point-category.transformer.d.ts +0 -8
- package/dist/lib/modules/loyalty-point-setting/transformers/loyalty-point-category.transformer.d.ts.map +0 -1
- package/dist/lib/modules/loyalty-point-setting/transformers/loyalty-point-category.transformer.js +0 -7
- package/dist/lib/modules/loyalty-point-setting/transformers/loyalty-point-category.transformer.js.map +0 -1
- package/dist/lib/modules/loyalty-point-setting/transformers/loyalty-point-setting.transformer.d.ts +0 -9
- package/dist/lib/modules/loyalty-point-setting/transformers/loyalty-point-setting.transformer.d.ts.map +0 -1
- package/dist/lib/modules/loyalty-point-setting/transformers/loyalty-point-setting.transformer.js +0 -7
- package/dist/lib/modules/loyalty-point-setting/transformers/loyalty-point-setting.transformer.js.map +0 -1
- package/dist/lib/modules/loyalty-point-setting/validations/index.d.ts +0 -3
- package/dist/lib/modules/loyalty-point-setting/validations/index.d.ts.map +0 -1
- package/dist/lib/modules/loyalty-point-setting/validations/index.js +0 -19
- package/dist/lib/modules/loyalty-point-setting/validations/index.js.map +0 -1
- package/dist/lib/modules/loyalty-point-setting/validations/loyalty-point-category.validation.d.ts +0 -170
- package/dist/lib/modules/loyalty-point-setting/validations/loyalty-point-category.validation.d.ts.map +0 -1
- package/dist/lib/modules/loyalty-point-setting/validations/loyalty-point-category.validation.js +0 -19
- package/dist/lib/modules/loyalty-point-setting/validations/loyalty-point-category.validation.js.map +0 -1
- package/dist/lib/modules/loyalty-point-setting/validations/loyalty-point-setting.validation.d.ts +0 -188
- package/dist/lib/modules/loyalty-point-setting/validations/loyalty-point-setting.validation.d.ts.map +0 -1
- package/dist/lib/modules/loyalty-point-setting/validations/loyalty-point-setting.validation.js +0 -19
- package/dist/lib/modules/loyalty-point-setting/validations/loyalty-point-setting.validation.js.map +0 -1
- package/dist/lib/modules/marketing/services/loyalty-point-marketing.service.d.ts +0 -12
- package/dist/lib/modules/marketing/services/loyalty-point-marketing.service.d.ts.map +0 -1
- package/dist/lib/modules/marketing/services/loyalty-point-marketing.service.js +0 -149
- package/dist/lib/modules/marketing/services/loyalty-point-marketing.service.js.map +0 -1
- package/dist/lib/modules/marketing/transformers/loyalty-point-marketing.transformer.d.ts +0 -47
- package/dist/lib/modules/marketing/transformers/loyalty-point-marketing.transformer.d.ts.map +0 -1
- package/dist/lib/modules/marketing/transformers/loyalty-point-marketing.transformer.js +0 -7
- package/dist/lib/modules/marketing/transformers/loyalty-point-marketing.transformer.js.map +0 -1
- package/dist/lib/modules/marketing/validations/loyalty-point-marketing.validation.d.ts +0 -504
- package/dist/lib/modules/marketing/validations/loyalty-point-marketing.validation.d.ts.map +0 -1
- package/dist/lib/modules/marketing/validations/loyalty-point-marketing.validation.js +0 -34
- package/dist/lib/modules/marketing/validations/loyalty-point-marketing.validation.js.map +0 -1
- package/dist/types/modules/loyalty-point-setting/routers/index.d.ts +0 -2
- package/dist/types/modules/loyalty-point-setting/routers/index.d.ts.map +0 -1
- package/dist/types/modules/loyalty-point-setting/routers/loyalty-point-setting.router.d.ts +0 -321
- package/dist/types/modules/loyalty-point-setting/routers/loyalty-point-setting.router.d.ts.map +0 -1
- package/dist/types/modules/loyalty-point-setting/services/index.d.ts +0 -3
- package/dist/types/modules/loyalty-point-setting/services/index.d.ts.map +0 -1
- package/dist/types/modules/loyalty-point-setting/services/loyalty-point-category.service.d.ts +0 -37
- package/dist/types/modules/loyalty-point-setting/services/loyalty-point-category.service.d.ts.map +0 -1
- package/dist/types/modules/loyalty-point-setting/services/loyalty-point-setting.service.d.ts +0 -34
- package/dist/types/modules/loyalty-point-setting/services/loyalty-point-setting.service.d.ts.map +0 -1
- package/dist/types/modules/loyalty-point-setting/transformers/index.d.ts +0 -3
- package/dist/types/modules/loyalty-point-setting/transformers/index.d.ts.map +0 -1
- package/dist/types/modules/loyalty-point-setting/transformers/loyalty-point-category.transformer.d.ts +0 -8
- package/dist/types/modules/loyalty-point-setting/transformers/loyalty-point-category.transformer.d.ts.map +0 -1
- package/dist/types/modules/loyalty-point-setting/transformers/loyalty-point-setting.transformer.d.ts +0 -9
- package/dist/types/modules/loyalty-point-setting/transformers/loyalty-point-setting.transformer.d.ts.map +0 -1
- package/dist/types/modules/loyalty-point-setting/validations/index.d.ts +0 -3
- package/dist/types/modules/loyalty-point-setting/validations/index.d.ts.map +0 -1
- package/dist/types/modules/loyalty-point-setting/validations/loyalty-point-category.validation.d.ts +0 -179
- package/dist/types/modules/loyalty-point-setting/validations/loyalty-point-category.validation.d.ts.map +0 -1
- package/dist/types/modules/loyalty-point-setting/validations/loyalty-point-setting.validation.d.ts +0 -197
- package/dist/types/modules/loyalty-point-setting/validations/loyalty-point-setting.validation.d.ts.map +0 -1
- package/dist/types/modules/marketing/services/loyalty-point-marketing.service.d.ts +0 -21
- package/dist/types/modules/marketing/services/loyalty-point-marketing.service.d.ts.map +0 -1
- package/dist/types/modules/marketing/transformers/loyalty-point-marketing.transformer.d.ts +0 -47
- package/dist/types/modules/marketing/transformers/loyalty-point-marketing.transformer.d.ts.map +0 -1
- package/dist/types/modules/marketing/validations/loyalty-point-marketing.validation.d.ts +0 -513
- package/dist/types/modules/marketing/validations/loyalty-point-marketing.validation.d.ts.map +0 -1
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { DTO } from '@lyxa.ai/core/dist/utilities/validation/global-validation';
|
|
3
|
+
import { CouponType, ItemType } from '@lyxa.ai/core/dist/utilities/enum';
|
|
4
|
+
declare const ShopsCategoriesCouponValidationSchema: z.ZodObject<{
|
|
5
|
+
couponType: z.ZodLiteral<CouponType.SHOPS_CATEGORIES>;
|
|
6
|
+
itemTypes: z.ZodDefault<z.ZodArray<z.ZodNativeEnum<typeof ItemType>, "many">>;
|
|
7
|
+
shops: z.ZodDefault<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">>;
|
|
8
|
+
isShopCoverExpenses: z.ZodDefault<z.ZodBoolean>;
|
|
9
|
+
firstOrderOnly: z.ZodDefault<z.ZodBoolean>;
|
|
10
|
+
valueType: z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").ValueType>;
|
|
11
|
+
value: z.ZodNumber;
|
|
12
|
+
secondaryCurrencyValue: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
maxDiscountLimit: z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>;
|
|
14
|
+
secondaryCurrencyMaxDiscountLimit: z.ZodOptional<z.ZodNumber>;
|
|
15
|
+
isMaxDiscountLimitEnabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
16
|
+
duration: z.ZodEffects<z.ZodObject<{
|
|
17
|
+
start: z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>, z.ZodDate]>, Date, string | Date>, Date, string | Date>;
|
|
18
|
+
end: 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>>;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
start: Date;
|
|
21
|
+
end?: Date | undefined;
|
|
22
|
+
}, {
|
|
23
|
+
start: string | Date;
|
|
24
|
+
end?: string | Date | undefined;
|
|
25
|
+
}>, {
|
|
26
|
+
start: Date;
|
|
27
|
+
end?: Date | undefined;
|
|
28
|
+
}, {
|
|
29
|
+
start: string | Date;
|
|
30
|
+
end?: string | Date | undefined;
|
|
31
|
+
}>;
|
|
32
|
+
spendLimit: z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>;
|
|
33
|
+
isSpendLimitEnabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
34
|
+
totalOrderLimit: z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>;
|
|
35
|
+
isTotalOrderLimitEnabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
36
|
+
minOrderValue: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
37
|
+
secondaryCurrencyMinOrderValue: z.ZodOptional<z.ZodNumber>;
|
|
38
|
+
isMinOrderValueEnabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
39
|
+
forNewUserOnly: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
40
|
+
status: z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").Status>>>;
|
|
41
|
+
expirationReason: z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").CouponExpirationReason>>>>;
|
|
42
|
+
referringUser: z.ZodOptional<z.ZodObject<{
|
|
43
|
+
name: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
|
45
|
+
name?: string | undefined;
|
|
46
|
+
}, {
|
|
47
|
+
name?: string | undefined;
|
|
48
|
+
}>>;
|
|
49
|
+
code: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
50
|
+
orderLimitPerUser: z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>;
|
|
51
|
+
isOrderLimitPerUserEnabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
52
|
+
createdBy: 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>]>>;
|
|
53
|
+
isExpired: z.ZodOptional<z.ZodBoolean>;
|
|
54
|
+
}, "strict", z.ZodTypeAny, {
|
|
55
|
+
value: number;
|
|
56
|
+
code: string;
|
|
57
|
+
status: import("@lyxa.ai/core/dist/utilities/enum").Status;
|
|
58
|
+
duration: {
|
|
59
|
+
start: Date;
|
|
60
|
+
end?: Date | undefined;
|
|
61
|
+
};
|
|
62
|
+
valueType: import("@lyxa.ai/core/dist/utilities/enum").ValueType;
|
|
63
|
+
spendLimit: number | null;
|
|
64
|
+
isSpendLimitEnabled: boolean;
|
|
65
|
+
maxDiscountLimit: number | null;
|
|
66
|
+
isMaxDiscountLimitEnabled: boolean;
|
|
67
|
+
totalOrderLimit: number | null;
|
|
68
|
+
isTotalOrderLimitEnabled: boolean;
|
|
69
|
+
minOrderValue: number | null;
|
|
70
|
+
isMinOrderValueEnabled: boolean;
|
|
71
|
+
forNewUserOnly: boolean;
|
|
72
|
+
expirationReason: import("@lyxa.ai/core/dist/utilities/enum").CouponExpirationReason | null;
|
|
73
|
+
orderLimitPerUser: number | null;
|
|
74
|
+
isOrderLimitPerUserEnabled: boolean;
|
|
75
|
+
couponType: CouponType.SHOPS_CATEGORIES;
|
|
76
|
+
itemTypes: ItemType[];
|
|
77
|
+
shops: import("mongoose").Types.ObjectId[];
|
|
78
|
+
isShopCoverExpenses: boolean;
|
|
79
|
+
firstOrderOnly: boolean;
|
|
80
|
+
secondaryCurrencyValue?: number | undefined;
|
|
81
|
+
secondaryCurrencyMaxDiscountLimit?: number | undefined;
|
|
82
|
+
secondaryCurrencyMinOrderValue?: number | undefined;
|
|
83
|
+
referringUser?: {
|
|
84
|
+
name?: string | undefined;
|
|
85
|
+
} | undefined;
|
|
86
|
+
createdBy?: import("mongoose").Types.ObjectId | undefined;
|
|
87
|
+
isExpired?: boolean | undefined;
|
|
88
|
+
}, {
|
|
89
|
+
value: number;
|
|
90
|
+
code: string;
|
|
91
|
+
duration: {
|
|
92
|
+
start: string | Date;
|
|
93
|
+
end?: string | Date | undefined;
|
|
94
|
+
};
|
|
95
|
+
valueType: import("@lyxa.ai/core/dist/utilities/enum").ValueType;
|
|
96
|
+
couponType: CouponType.SHOPS_CATEGORIES;
|
|
97
|
+
status?: import("@lyxa.ai/core/dist/utilities/enum").Status | undefined;
|
|
98
|
+
spendLimit?: number | null | undefined;
|
|
99
|
+
isSpendLimitEnabled?: boolean | undefined;
|
|
100
|
+
secondaryCurrencyValue?: number | undefined;
|
|
101
|
+
maxDiscountLimit?: number | null | undefined;
|
|
102
|
+
secondaryCurrencyMaxDiscountLimit?: number | undefined;
|
|
103
|
+
isMaxDiscountLimitEnabled?: boolean | undefined;
|
|
104
|
+
totalOrderLimit?: number | null | undefined;
|
|
105
|
+
isTotalOrderLimitEnabled?: boolean | undefined;
|
|
106
|
+
minOrderValue?: number | null | undefined;
|
|
107
|
+
secondaryCurrencyMinOrderValue?: number | undefined;
|
|
108
|
+
isMinOrderValueEnabled?: boolean | undefined;
|
|
109
|
+
forNewUserOnly?: boolean | undefined;
|
|
110
|
+
expirationReason?: import("@lyxa.ai/core/dist/utilities/enum").CouponExpirationReason | null | undefined;
|
|
111
|
+
referringUser?: {
|
|
112
|
+
name?: string | undefined;
|
|
113
|
+
} | undefined;
|
|
114
|
+
orderLimitPerUser?: number | null | undefined;
|
|
115
|
+
isOrderLimitPerUserEnabled?: boolean | undefined;
|
|
116
|
+
createdBy?: string | import("mongoose").Types.ObjectId | undefined;
|
|
117
|
+
isExpired?: boolean | undefined;
|
|
118
|
+
itemTypes?: ItemType[] | undefined;
|
|
119
|
+
shops?: (string | import("mongoose").Types.ObjectId)[] | undefined;
|
|
120
|
+
isShopCoverExpenses?: boolean | undefined;
|
|
121
|
+
firstOrderOnly?: boolean | undefined;
|
|
122
|
+
}>, ShopsCategoriesCouponSchema: z.ZodObject<{
|
|
123
|
+
couponType: z.ZodOptional<z.ZodLiteral<CouponType.SHOPS_CATEGORIES>>;
|
|
124
|
+
itemTypes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodNativeEnum<typeof ItemType>, "many">>>;
|
|
125
|
+
shops: z.ZodOptional<z.ZodDefault<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">>>;
|
|
126
|
+
isShopCoverExpenses: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
127
|
+
firstOrderOnly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
128
|
+
valueType: z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").ValueType>>;
|
|
129
|
+
value: z.ZodOptional<z.ZodNumber>;
|
|
130
|
+
secondaryCurrencyValue: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
131
|
+
maxDiscountLimit: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
132
|
+
secondaryCurrencyMaxDiscountLimit: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
133
|
+
isMaxDiscountLimitEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
134
|
+
duration: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
135
|
+
start: z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>, z.ZodDate]>, Date, string | Date>, Date, string | Date>;
|
|
136
|
+
end: 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>>;
|
|
137
|
+
}, "strip", z.ZodTypeAny, {
|
|
138
|
+
start: Date;
|
|
139
|
+
end?: Date | undefined;
|
|
140
|
+
}, {
|
|
141
|
+
start: string | Date;
|
|
142
|
+
end?: string | Date | undefined;
|
|
143
|
+
}>, {
|
|
144
|
+
start: Date;
|
|
145
|
+
end?: Date | undefined;
|
|
146
|
+
}, {
|
|
147
|
+
start: string | Date;
|
|
148
|
+
end?: string | Date | undefined;
|
|
149
|
+
}>>;
|
|
150
|
+
spendLimit: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
151
|
+
isSpendLimitEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
152
|
+
totalOrderLimit: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
153
|
+
isTotalOrderLimitEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
154
|
+
minOrderValue: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodNumber>>>;
|
|
155
|
+
secondaryCurrencyMinOrderValue: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
156
|
+
isMinOrderValueEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
157
|
+
forNewUserOnly: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
158
|
+
status: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").Status>>>>;
|
|
159
|
+
expirationReason: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").CouponExpirationReason>>>>>;
|
|
160
|
+
referringUser: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
161
|
+
name: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
162
|
+
}, "strip", z.ZodTypeAny, {
|
|
163
|
+
name?: string | undefined;
|
|
164
|
+
}, {
|
|
165
|
+
name?: string | undefined;
|
|
166
|
+
}>>>;
|
|
167
|
+
code: z.ZodOptional<z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
168
|
+
orderLimitPerUser: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
169
|
+
isOrderLimitPerUserEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
170
|
+
createdBy: z.ZodOptional<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>]>>>;
|
|
171
|
+
isExpired: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
172
|
+
_id: 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>]>>;
|
|
173
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
174
|
+
couponType: z.ZodOptional<z.ZodLiteral<CouponType.SHOPS_CATEGORIES>>;
|
|
175
|
+
itemTypes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodNativeEnum<typeof ItemType>, "many">>>;
|
|
176
|
+
shops: z.ZodOptional<z.ZodDefault<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">>>;
|
|
177
|
+
isShopCoverExpenses: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
178
|
+
firstOrderOnly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
179
|
+
valueType: z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").ValueType>>;
|
|
180
|
+
value: z.ZodOptional<z.ZodNumber>;
|
|
181
|
+
secondaryCurrencyValue: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
182
|
+
maxDiscountLimit: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
183
|
+
secondaryCurrencyMaxDiscountLimit: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
184
|
+
isMaxDiscountLimitEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
185
|
+
duration: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
186
|
+
start: z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>, z.ZodDate]>, Date, string | Date>, Date, string | Date>;
|
|
187
|
+
end: 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>>;
|
|
188
|
+
}, "strip", z.ZodTypeAny, {
|
|
189
|
+
start: Date;
|
|
190
|
+
end?: Date | undefined;
|
|
191
|
+
}, {
|
|
192
|
+
start: string | Date;
|
|
193
|
+
end?: string | Date | undefined;
|
|
194
|
+
}>, {
|
|
195
|
+
start: Date;
|
|
196
|
+
end?: Date | undefined;
|
|
197
|
+
}, {
|
|
198
|
+
start: string | Date;
|
|
199
|
+
end?: string | Date | undefined;
|
|
200
|
+
}>>;
|
|
201
|
+
spendLimit: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
202
|
+
isSpendLimitEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
203
|
+
totalOrderLimit: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
204
|
+
isTotalOrderLimitEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
205
|
+
minOrderValue: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodNumber>>>;
|
|
206
|
+
secondaryCurrencyMinOrderValue: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
207
|
+
isMinOrderValueEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
208
|
+
forNewUserOnly: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
209
|
+
status: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").Status>>>>;
|
|
210
|
+
expirationReason: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").CouponExpirationReason>>>>>;
|
|
211
|
+
referringUser: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
212
|
+
name: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
213
|
+
}, "strip", z.ZodTypeAny, {
|
|
214
|
+
name?: string | undefined;
|
|
215
|
+
}, {
|
|
216
|
+
name?: string | undefined;
|
|
217
|
+
}>>>;
|
|
218
|
+
code: z.ZodOptional<z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
219
|
+
orderLimitPerUser: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
220
|
+
isOrderLimitPerUserEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
221
|
+
createdBy: z.ZodOptional<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>]>>>;
|
|
222
|
+
isExpired: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
223
|
+
_id: 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>]>>;
|
|
224
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
225
|
+
couponType: z.ZodOptional<z.ZodLiteral<CouponType.SHOPS_CATEGORIES>>;
|
|
226
|
+
itemTypes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodNativeEnum<typeof ItemType>, "many">>>;
|
|
227
|
+
shops: z.ZodOptional<z.ZodDefault<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">>>;
|
|
228
|
+
isShopCoverExpenses: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
229
|
+
firstOrderOnly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
230
|
+
valueType: z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").ValueType>>;
|
|
231
|
+
value: z.ZodOptional<z.ZodNumber>;
|
|
232
|
+
secondaryCurrencyValue: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
233
|
+
maxDiscountLimit: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
234
|
+
secondaryCurrencyMaxDiscountLimit: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
235
|
+
isMaxDiscountLimitEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
236
|
+
duration: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
237
|
+
start: z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>, z.ZodDate]>, Date, string | Date>, Date, string | Date>;
|
|
238
|
+
end: 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>>;
|
|
239
|
+
}, "strip", z.ZodTypeAny, {
|
|
240
|
+
start: Date;
|
|
241
|
+
end?: Date | undefined;
|
|
242
|
+
}, {
|
|
243
|
+
start: string | Date;
|
|
244
|
+
end?: string | Date | undefined;
|
|
245
|
+
}>, {
|
|
246
|
+
start: Date;
|
|
247
|
+
end?: Date | undefined;
|
|
248
|
+
}, {
|
|
249
|
+
start: string | Date;
|
|
250
|
+
end?: string | Date | undefined;
|
|
251
|
+
}>>;
|
|
252
|
+
spendLimit: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
253
|
+
isSpendLimitEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
254
|
+
totalOrderLimit: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
255
|
+
isTotalOrderLimitEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
256
|
+
minOrderValue: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodNumber>>>;
|
|
257
|
+
secondaryCurrencyMinOrderValue: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
258
|
+
isMinOrderValueEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
259
|
+
forNewUserOnly: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
260
|
+
status: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").Status>>>>;
|
|
261
|
+
expirationReason: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").CouponExpirationReason>>>>>;
|
|
262
|
+
referringUser: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
263
|
+
name: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
264
|
+
}, "strip", z.ZodTypeAny, {
|
|
265
|
+
name?: string | undefined;
|
|
266
|
+
}, {
|
|
267
|
+
name?: string | undefined;
|
|
268
|
+
}>>>;
|
|
269
|
+
code: z.ZodOptional<z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
270
|
+
orderLimitPerUser: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
271
|
+
isOrderLimitPerUserEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
272
|
+
createdBy: z.ZodOptional<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>]>>>;
|
|
273
|
+
isExpired: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
274
|
+
_id: 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>]>>;
|
|
275
|
+
}, z.ZodTypeAny, "passthrough">>, ShopsCategoriesCouponIdSchema: 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>]>, UpdateShopsCategoriesCouponSchema: z.ZodObject<{
|
|
276
|
+
[x: string]: z.ZodOptional<z.ZodTypeAny>;
|
|
277
|
+
}, "strict", z.ZodTypeAny, {
|
|
278
|
+
[x: string]: any;
|
|
279
|
+
}, {
|
|
280
|
+
[x: string]: any;
|
|
281
|
+
}> | z.ZodObject<{
|
|
282
|
+
couponType: z.ZodOptional<z.ZodLiteral<CouponType.SHOPS_CATEGORIES>>;
|
|
283
|
+
itemTypes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodNativeEnum<typeof ItemType>, "many">>>;
|
|
284
|
+
shops: z.ZodOptional<z.ZodDefault<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">>>;
|
|
285
|
+
isShopCoverExpenses: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
286
|
+
firstOrderOnly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
287
|
+
valueType: z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").ValueType>>;
|
|
288
|
+
value: z.ZodOptional<z.ZodNumber>;
|
|
289
|
+
secondaryCurrencyValue: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
290
|
+
maxDiscountLimit: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
291
|
+
secondaryCurrencyMaxDiscountLimit: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
292
|
+
isMaxDiscountLimitEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
293
|
+
duration: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
294
|
+
start: z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>, z.ZodDate]>, Date, string | Date>, Date, string | Date>;
|
|
295
|
+
end: 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>>;
|
|
296
|
+
}, "strip", z.ZodTypeAny, {
|
|
297
|
+
start: Date;
|
|
298
|
+
end?: Date | undefined;
|
|
299
|
+
}, {
|
|
300
|
+
start: string | Date;
|
|
301
|
+
end?: string | Date | undefined;
|
|
302
|
+
}>, {
|
|
303
|
+
start: Date;
|
|
304
|
+
end?: Date | undefined;
|
|
305
|
+
}, {
|
|
306
|
+
start: string | Date;
|
|
307
|
+
end?: string | Date | undefined;
|
|
308
|
+
}>>;
|
|
309
|
+
spendLimit: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
310
|
+
isSpendLimitEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
311
|
+
totalOrderLimit: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
312
|
+
isTotalOrderLimitEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
313
|
+
minOrderValue: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodNumber>>>;
|
|
314
|
+
secondaryCurrencyMinOrderValue: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
315
|
+
isMinOrderValueEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
316
|
+
forNewUserOnly: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
317
|
+
status: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").Status>>>>;
|
|
318
|
+
expirationReason: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").CouponExpirationReason>>>>>;
|
|
319
|
+
referringUser: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
320
|
+
name: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
321
|
+
}, "strip", z.ZodTypeAny, {
|
|
322
|
+
name?: string | undefined;
|
|
323
|
+
}, {
|
|
324
|
+
name?: string | undefined;
|
|
325
|
+
}>>>;
|
|
326
|
+
code: z.ZodOptional<z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
327
|
+
orderLimitPerUser: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
328
|
+
isOrderLimitPerUserEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
329
|
+
createdBy: z.ZodOptional<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>]>>>;
|
|
330
|
+
isExpired: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
331
|
+
_id: 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>]>>;
|
|
332
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
333
|
+
couponType: z.ZodOptional<z.ZodLiteral<CouponType.SHOPS_CATEGORIES>>;
|
|
334
|
+
itemTypes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodNativeEnum<typeof ItemType>, "many">>>;
|
|
335
|
+
shops: z.ZodOptional<z.ZodDefault<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">>>;
|
|
336
|
+
isShopCoverExpenses: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
337
|
+
firstOrderOnly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
338
|
+
valueType: z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").ValueType>>;
|
|
339
|
+
value: z.ZodOptional<z.ZodNumber>;
|
|
340
|
+
secondaryCurrencyValue: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
341
|
+
maxDiscountLimit: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
342
|
+
secondaryCurrencyMaxDiscountLimit: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
343
|
+
isMaxDiscountLimitEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
344
|
+
duration: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
345
|
+
start: z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>, z.ZodDate]>, Date, string | Date>, Date, string | Date>;
|
|
346
|
+
end: 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>>;
|
|
347
|
+
}, "strip", z.ZodTypeAny, {
|
|
348
|
+
start: Date;
|
|
349
|
+
end?: Date | undefined;
|
|
350
|
+
}, {
|
|
351
|
+
start: string | Date;
|
|
352
|
+
end?: string | Date | undefined;
|
|
353
|
+
}>, {
|
|
354
|
+
start: Date;
|
|
355
|
+
end?: Date | undefined;
|
|
356
|
+
}, {
|
|
357
|
+
start: string | Date;
|
|
358
|
+
end?: string | Date | undefined;
|
|
359
|
+
}>>;
|
|
360
|
+
spendLimit: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
361
|
+
isSpendLimitEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
362
|
+
totalOrderLimit: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
363
|
+
isTotalOrderLimitEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
364
|
+
minOrderValue: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodNumber>>>;
|
|
365
|
+
secondaryCurrencyMinOrderValue: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
366
|
+
isMinOrderValueEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
367
|
+
forNewUserOnly: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
368
|
+
status: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").Status>>>>;
|
|
369
|
+
expirationReason: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").CouponExpirationReason>>>>>;
|
|
370
|
+
referringUser: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
371
|
+
name: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
372
|
+
}, "strip", z.ZodTypeAny, {
|
|
373
|
+
name?: string | undefined;
|
|
374
|
+
}, {
|
|
375
|
+
name?: string | undefined;
|
|
376
|
+
}>>>;
|
|
377
|
+
code: z.ZodOptional<z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
378
|
+
orderLimitPerUser: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
379
|
+
isOrderLimitPerUserEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
380
|
+
createdBy: z.ZodOptional<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>]>>>;
|
|
381
|
+
isExpired: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
382
|
+
_id: 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>]>>;
|
|
383
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
384
|
+
couponType: z.ZodOptional<z.ZodLiteral<CouponType.SHOPS_CATEGORIES>>;
|
|
385
|
+
itemTypes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodNativeEnum<typeof ItemType>, "many">>>;
|
|
386
|
+
shops: z.ZodOptional<z.ZodDefault<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">>>;
|
|
387
|
+
isShopCoverExpenses: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
388
|
+
firstOrderOnly: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
389
|
+
valueType: z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").ValueType>>;
|
|
390
|
+
value: z.ZodOptional<z.ZodNumber>;
|
|
391
|
+
secondaryCurrencyValue: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
392
|
+
maxDiscountLimit: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
393
|
+
secondaryCurrencyMaxDiscountLimit: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
394
|
+
isMaxDiscountLimitEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
395
|
+
duration: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
396
|
+
start: z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>, z.ZodDate]>, Date, string | Date>, Date, string | Date>;
|
|
397
|
+
end: 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>>;
|
|
398
|
+
}, "strip", z.ZodTypeAny, {
|
|
399
|
+
start: Date;
|
|
400
|
+
end?: Date | undefined;
|
|
401
|
+
}, {
|
|
402
|
+
start: string | Date;
|
|
403
|
+
end?: string | Date | undefined;
|
|
404
|
+
}>, {
|
|
405
|
+
start: Date;
|
|
406
|
+
end?: Date | undefined;
|
|
407
|
+
}, {
|
|
408
|
+
start: string | Date;
|
|
409
|
+
end?: string | Date | undefined;
|
|
410
|
+
}>>;
|
|
411
|
+
spendLimit: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
412
|
+
isSpendLimitEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
413
|
+
totalOrderLimit: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
414
|
+
isTotalOrderLimitEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
415
|
+
minOrderValue: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodNumber>>>;
|
|
416
|
+
secondaryCurrencyMinOrderValue: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
417
|
+
isMinOrderValueEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
418
|
+
forNewUserOnly: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
419
|
+
status: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").Status>>>>;
|
|
420
|
+
expirationReason: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNativeEnum<typeof import("@lyxa.ai/core/dist/utilities/enum").CouponExpirationReason>>>>>;
|
|
421
|
+
referringUser: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
422
|
+
name: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
423
|
+
}, "strip", z.ZodTypeAny, {
|
|
424
|
+
name?: string | undefined;
|
|
425
|
+
}, {
|
|
426
|
+
name?: string | undefined;
|
|
427
|
+
}>>>;
|
|
428
|
+
code: z.ZodOptional<z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
429
|
+
orderLimitPerUser: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodNumber>>>>;
|
|
430
|
+
isOrderLimitPerUserEnabled: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
|
|
431
|
+
createdBy: z.ZodOptional<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>]>>>;
|
|
432
|
+
isExpired: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
433
|
+
_id: 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>]>>;
|
|
434
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
435
|
+
export { ShopsCategoriesCouponValidationSchema, ShopsCategoriesCouponSchema, ShopsCategoriesCouponIdSchema as ShopsCategoriesCouponIdValidationSchema, UpdateShopsCategoriesCouponSchema, };
|
|
436
|
+
export type CreateShopsCategoriesCouponDTO = DTO<typeof ShopsCategoriesCouponValidationSchema>;
|
|
437
|
+
export type ShopsCategoriesCouponDTO = DTO<typeof ShopsCategoriesCouponSchema>;
|
|
438
|
+
export type UpdateShopsCategoriesCouponDTO = DTO<typeof UpdateShopsCategoriesCouponSchema>;
|
|
439
|
+
//# sourceMappingURL=shops-categories-coupon.validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shops-categories-coupon.validation.d.ts","sourceRoot":"/","sources":["modules/coupon/validations/shops-categories-coupon.validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAGN,GAAG,EACH,MAAM,2DAA2D,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAwBzE,QAAA,MACa,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACnC,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAC/B,6BAA6B,mNACzB,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCACI,CAAC;AAKrD,OAAO,EACN,qCAAqC,EACrC,2BAA2B,EAC3B,6BAA6B,IAAI,uCAAuC,EACxE,iCAAiC,GACjC,CAAC;AAKF,MAAM,MAAM,8BAA8B,GAAG,GAAG,CAAC,OAAO,qCAAqC,CAAC,CAAC;AAC/F,MAAM,MAAM,wBAAwB,GAAG,GAAG,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAC/E,MAAM,MAAM,8BAA8B,GAAG,GAAG,CAAC,OAAO,iCAAiC,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UpdateShopsCategoriesCouponSchema = exports.ShopsCategoriesCouponIdValidationSchema = exports.ShopsCategoriesCouponSchema = exports.ShopsCategoriesCouponValidationSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const global_validation_1 = require("@lyxa.ai/core/dist/utilities/validation/global-validation");
|
|
6
|
+
const coupon_validation_1 = require("./coupon.validation");
|
|
7
|
+
const enum_1 = require("@lyxa.ai/core/dist/utilities/enum");
|
|
8
|
+
const baseFields = {
|
|
9
|
+
...coupon_validation_1.baseFields,
|
|
10
|
+
couponType: zod_1.z.literal(enum_1.CouponType.SHOPS_CATEGORIES),
|
|
11
|
+
itemTypes: global_validation_1.ZodValidation.array(global_validation_1.ZodValidation.enumType(enum_1.ItemType, 'Item type'), 'Item types').default([]),
|
|
12
|
+
shops: global_validation_1.ZodValidation.array(global_validation_1.ZodValidation.objectId('Shop'), 'Shops').default([]),
|
|
13
|
+
isShopCoverExpenses: global_validation_1.ZodValidation.boolean('IsShopCoverExpenses').default(false),
|
|
14
|
+
firstOrderOnly: global_validation_1.ZodValidation.boolean('FirstOrderOnly').default(false),
|
|
15
|
+
};
|
|
16
|
+
const schemaBuilder = (0, global_validation_1.createSchemaBuilder)(baseFields);
|
|
17
|
+
const { BaseSchema: ShopsCategoriesCouponValidationSchema, EntitySchema: ShopsCategoriesCouponSchema, IdSchema: ShopsCategoriesCouponIdSchema, UpdateSchema: UpdateShopsCategoriesCouponSchema, } = schemaBuilder.getAllSchemas({ createdAt: true });
|
|
18
|
+
exports.ShopsCategoriesCouponValidationSchema = ShopsCategoriesCouponValidationSchema;
|
|
19
|
+
exports.ShopsCategoriesCouponSchema = ShopsCategoriesCouponSchema;
|
|
20
|
+
exports.ShopsCategoriesCouponIdValidationSchema = ShopsCategoriesCouponIdSchema;
|
|
21
|
+
exports.UpdateShopsCategoriesCouponSchema = UpdateShopsCategoriesCouponSchema;
|
|
22
|
+
//# sourceMappingURL=shops-categories-coupon.validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shops-categories-coupon.validation.js","sourceRoot":"/","sources":["modules/coupon/validations/shops-categories-coupon.validation.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,iGAImE;AACnE,2DAAqE;AACrE,4DAAyE;AAKzE,MAAM,UAAU,GAAG;IAClB,GAAG,8BAAgB;IACnB,UAAU,EAAE,OAAC,CAAC,OAAO,CAAC,iBAAU,CAAC,gBAAgB,CAAC;IAClD,SAAS,EAAE,iCAAa,CAAC,KAAK,CAAC,iCAAa,CAAC,QAAQ,CAAC,eAAQ,EAAE,WAAW,CAAC,EAAE,YAAY,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IACvG,KAAK,EAAE,iCAAa,CAAC,KAAK,CAAC,iCAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAC/E,mBAAmB,EAAE,iCAAa,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IAChF,cAAc,EAAE,iCAAa,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;CACtE,CAAC;AAOF,MAAM,aAAa,GAAG,IAAA,uCAAmB,EAAC,UAAU,CAAC,CAAC;AAKtD,MAAM,EACL,UAAU,EAAE,qCAAqC,EACjD,YAAY,EAAE,2BAA2B,EACzC,QAAQ,EAAE,6BAA6B,EACvC,YAAY,EAAE,iCAAiC,GAC/C,GAAG,aAAa,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAMpD,sFAAqC;AACrC,kEAA2B;AACM,gFAAuC;AACxE,8EAAiC","sourcesContent":["import { z } from 'zod';\nimport {\n\tZodValidation,\n\tcreateSchemaBuilder,\n\tDTO,\n} from '@lyxa.ai/core/dist/utilities/validation/global-validation';\nimport { baseFields as baseCouponFields } from './coupon.validation';\nimport { CouponType, ItemType } from '@lyxa.ai/core/dist/utilities/enum';\n\n/**\n * Define the base parent schema fields\n */\nconst baseFields = {\n\t...baseCouponFields,\n\tcouponType: z.literal(CouponType.SHOPS_CATEGORIES),\n\titemTypes: ZodValidation.array(ZodValidation.enumType(ItemType, 'Item type'), 'Item types').default([]),\n\tshops: ZodValidation.array(ZodValidation.objectId('Shop'), 'Shops').default([]),\n\tisShopCoverExpenses: ZodValidation.boolean('IsShopCoverExpenses').default(false),\n\tfirstOrderOnly: ZodValidation.boolean('FirstOrderOnly').default(false),\n};\n\n/**\n * Create schema builder for Parent entity\n * - Includes timestamps\n * - Excludes 'createdAt' from update operations\n */\nconst schemaBuilder = createSchemaBuilder(baseFields);\n\n/**\n * Get all schemas for the Parent entity\n */\nconst {\n\tBaseSchema: ShopsCategoriesCouponValidationSchema,\n\tEntitySchema: ShopsCategoriesCouponSchema,\n\tIdSchema: ShopsCategoriesCouponIdSchema,\n\tUpdateSchema: UpdateShopsCategoriesCouponSchema,\n} = schemaBuilder.getAllSchemas({ createdAt: true });\n\n/**\n * Export schemas\n */\nexport {\n\tShopsCategoriesCouponValidationSchema,\n\tShopsCategoriesCouponSchema,\n\tShopsCategoriesCouponIdSchema as ShopsCategoriesCouponIdValidationSchema,\n\tUpdateShopsCategoriesCouponSchema,\n};\n\n/**\n * Export DTO types\n */\nexport type CreateShopsCategoriesCouponDTO = DTO<typeof ShopsCategoriesCouponValidationSchema>;\nexport type ShopsCategoriesCouponDTO = DTO<typeof ShopsCategoriesCouponSchema>;\nexport type UpdateShopsCategoriesCouponDTO = DTO<typeof UpdateShopsCategoriesCouponSchema>;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marketing.service.d.ts","sourceRoot":"/","sources":["modules/marketing/services/marketing.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAmB,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAGN,SAAS,IAAI,KAAK,EAElB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAEN,0BAA0B,EAE1B,oCAAoC,EACpC,kBAAkB,IAAI,SAAS,EAC/B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACN,SAAS,EACT,iBAAiB,EACjB,SAAS,EACT,eAAe,EACf,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAsB3D,qBACa,gBAAgB;IAC5B,OAAO,CAAC,KAAK,CAAiD;;IAUjD,MAAM,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B;IAmBxB,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;IA4B7E,sCAAsC,CAAC,IAAI,EAAE,oCAAoC;CAgC9F;AAED,eAAO,MAAM,gBAAgB,kBAAkC,CAAC"}
|
|
@@ -79,11 +79,12 @@ let MarketingService = class MarketingService {
|
|
|
79
79
|
'duration.start': { $lt: now },
|
|
80
80
|
'duration.end': { $gt: now },
|
|
81
81
|
status: enum_1.MarketingStatus.ACTIVE,
|
|
82
|
+
marketingType: { $in: [enum_2.MarketingType.BUY1GET1, enum_2.MarketingType.DISCOUNT] },
|
|
82
83
|
});
|
|
83
84
|
if (existingMarketing) {
|
|
84
85
|
throw new server_1.TRPCError({
|
|
85
86
|
code: 'CONFLICT',
|
|
86
|
-
message: `Cannot create marketing for entire menu while another marketing exists for the shop`,
|
|
87
|
+
message: `Cannot create marketing for entire menu while another product based marketing exists for the shop`,
|
|
87
88
|
});
|
|
88
89
|
}
|
|
89
90
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marketing.service.js","sourceRoot":"/","sources":["modules/marketing/services/marketing.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAC5C,yCAAyC;AAEzC,sEAKmD;AAenD,wEAA6G;AAE7G,8FAA6G;AAC7G,iGAAoG;AACpG,4DAAgG;AAChG,8DAAkE;AAGlE,wBAOW;AACX,4DAAkE;AAClE,4EAImD;AAG5C,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IACpB,KAAK,CAAiD;IAE9D;QACC,IAAI,CAAC,KAAK,GAAG,uBAAgE,CAAC;IAC/E,CAAC;IAMM,KAAK,CAAC,MAAM,CAClB,IAAgC,EAChC,KAA+B;QAE/B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QAEvB,MAA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AhB,gBAAgB;IAD5B,IAAA,gBAAO,GAAE;;GACG,gBAAgB,CA8U5B;AAEY,QAAA,gBAAgB,GAAG,gBAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { TRPCError } from '@trpc/server';\nimport { DocumentType, mongoose, ReturnModelType } from '@typegoose/typegoose';\nimport {\n\tDiscountMarketing,\n\tMarketingModel,\n\tMarketing as Model,\n\tPunchMarketingHistory,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {\n\tAllMarketingsDTO,\n\tAllMarketingsValidationDTO,\n\tCreateProductMarketingDTO,\n\tProductEntireMenuMarketingHandlerDTO,\n\tUpdateMarketingDTO as UpdateDTO,\n} from '@modules/marketing/validations';\nimport {\n\tFilterDTO,\n\tPaginatedResponse,\n\tDeleteDTO,\n\tGetByIdInputDTO,\n} from '@lyxa.ai/core/dist/utilities/validation';\nimport { SoftDeleteModel } from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport { createRawDocumentPaginatorObject, PaginatorOptions } from '@lyxa.ai/core/dist/utilities/pagination';\nimport { ModelType } from '@typegoose/typegoose/lib/types';\nimport { filterRelevantChanges, getChangedFields } from '@lyxa.ai/core/dist/utilities/events-common-methods';\nimport { AdminActivityLogsEvent } from '@lyxa.ai/core/dist/libraries/event/events/admin-logs-event';\nimport { AdminLogsUpdatedFieldsType, MarketingStatus } from '@lyxa.ai/core/dist/utilities/enum';\nimport { publishEvent } from '@lyxa.ai/core/dist/libraries/event';\nimport { BaseEvent } from '@lyxa.ai/core/dist/libraries/event/BaseEvent';\n\nimport {\n\tbuy1Get1MarketingService,\n\tdiscountMarketingService,\n\tfeaturedMarketingService,\n\tfreeDeliveryMarketingService,\n\tproductMarketingService,\n\tpunchMarketingService,\n} from '.';\nimport { MarketingType } from '@lyxa.ai/core/dist/utilities/enum';\nimport {\n\tinternalServerError,\n\tnotFoundError,\n\tunauthorizedError,\n} from '@lyxa.ai/core/dist/utilities/error-common';\n\n@Service()\nexport class MarketingService {\n\tprivate model: typeof MarketingModel & SoftDeleteModel<Model>;\n\n\tconstructor() {\n\t\tthis.model = MarketingModel as typeof MarketingModel & SoftDeleteModel<Model>;\n\t}\n\n\t/**\n\t * Create a new record\n\t * @param data Data for the new record\n\t */\n\tpublic async create(\n\t\tdata: AllMarketingsValidationDTO,\n\t\tadmin?: mongoose.Types.ObjectId\n\t): Promise<DocumentType<Model>> {\n\t\tconst now = new Date();\n\n\t\tconst existingRecord = await this.model.findOne({\n\t\t\tshop: data.shop,\n\t\t\tmarketingType: data.marketingType,\n\t\t\t'duration.end': { $gt: new Date() },\n\t\t\tstatus: MarketingStatus.ACTIVE,\n\t\t});\n\t\tif (existingRecord) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'CONFLICT',\n\t\t\t\tmessage: `This shop already has a ${data.marketingType} marketing`,\n\t\t\t});\n\t\t}\n\n\t\tif (data.isEntireMenu) {\n\t\t\tconst existingMarketing = await this.model.findOne({\n\t\t\t\tshop: data.shop,\n\t\t\t\t'duration.start': { $lt: now },\n\t\t\t\t'duration.end': { $gt: now },\n\t\t\t\tstatus: MarketingStatus.ACTIVE,\n\t\t\t});\n\t\t\tif (existingMarketing) {\n\t\t\t\tthrow new TRPCError({\n\t\t\t\t\tcode: 'CONFLICT',\n\t\t\t\t\tmessage: `Cannot create marketing for entire menu while another marketing exists for the shop`,\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (data.products && data.products.length > 0) {\n\t\t\tconst productIds = data.products.map((product: CreateProductMarketingDTO) => product.product);\n\n\t\t\tconst hasDuplicates = new Set(productIds.map(String)).size !== productIds.length;\n\n\t\t\tif (hasDuplicates) {\n\t\t\t\tthrow new TRPCError({\n\t\t\t\t\tcode: 'BAD_REQUEST',\n\t\t\t\t\tmessage: `Product list contains duplicate products`,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst isAvailable = await productMarketingService.checkProductMarketingAvailability(productIds);\n\n\t\t\tif (!isAvailable) {\n\t\t\t\tthrow new TRPCError({\n\t\t\t\t\tcode: 'CONFLICT',\n\t\t\t\t\tmessage: `Product list contains products which already have marketing applied`,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tlet marketing: AllMarketingsDTO;\n\n\t\tswitch (data.marketingType) {\n\t\t\tcase MarketingType.DISCOUNT: {\n\t\t\t\tmarketing = await discountMarketingService.create(data);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase MarketingType.BUY1GET1: {\n\t\t\t\tmarketing = await buy1Get1MarketingService.create(data);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase MarketingType.FEATURED: {\n\t\t\t\tif (!admin) {\n\t\t\t\t\tthrow new TRPCError({\n\t\t\t\t\t\tcode: 'UNAUTHORIZED',\n\t\t\t\t\t\tmessage: `Only admin is allowed to create ${data.marketingType} marketing`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tmarketing = await featuredMarketingService.create(data);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase MarketingType.FREE_DELIVERY: {\n\t\t\t\tmarketing = await freeDeliveryMarketingService.create(data);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase MarketingType.PUNCH_MARKETING: {\n\t\t\t\tmarketing = await punchMarketingService.create(data);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\tmarketing = await this.model.create(data);\n\t\t\t}\n\t\t}\n\n\t\tif (admin) {\n\t\t\tthis.logMarketingAdminAction(\n\t\t\t\tadmin,\n\t\t\t\tAdminLogsUpdatedFieldsType.ACTIVATED_MARKETING_PROMOTIONS,\n\t\t\t\t'',\n\t\t\t\tmarketing\n\t\t\t);\n\t\t}\n\n\t\treturn marketing;\n\t}\n\n\t/**\n\t * Get record by ID\n\t * @param id ID of the record\n\t */\n\tpublic async findById(data: GetByIdInputDTO): Promise<DocumentType<Model>> {\n\t\tconst result = await this.model.findRecordById(data);\n\t\tif (!result) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Record not found',\n\t\t\t});\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Get records\n\t * @param query Query to find records\n\t */\n\tpublic async find(data?: Partial<FilterDTO>): Promise<PaginatedResponse<DocumentType<ModelType<Model>>>> {\n\t\ttry {\n\t\t\tconst paginate = createRawDocumentPaginatorObject(this.model as ReturnModelType<typeof this.model>);\n\t\t\tconst options: PaginatorOptions<typeof Model> = {\n\t\t\t\tpage: data?.page,\n\t\t\t\tsize: data?.size,\n\t\t\t\tsort: data?.sort,\n\t\t\t\tquery: data?.query,\n\t\t\t\tselect: data?.select,\n\t\t\t\tpopulate: data?.populate,\n\t\t\t};\n\t\t\tconst paginatedResult = await paginate(options);\n\t\t\treturn paginatedResult;\n\t\t} catch (err) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: `err: ${err}`,\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Update record\n\t * @param id ID of the record\n\t * @param data Data to update\n\t */\n\tpublic async update(\n\t\t_id: mongoose.Types.ObjectId,\n\t\tdata: UpdateDTO,\n\t\tadmin?: mongoose.Types.ObjectId\n\t): Promise<DocumentType<Model>> {\n\t\tlet marketing: AllMarketingsDTO;\n\n\t\tconst oldMarketing = await this.model.findById(_id);\n\n\t\tif (!oldMarketing) {\n\t\t\tnotFoundError('Could not find marketing');\n\t\t}\n\n\t\tswitch (oldMarketing.marketingType) {\n\t\t\tcase MarketingType.DISCOUNT: {\n\t\t\t\tmarketing = await discountMarketingService.update(_id, data);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase MarketingType.BUY1GET1: {\n\t\t\t\tmarketing = await buy1Get1MarketingService.update(_id, data);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase MarketingType.FEATURED: {\n\t\t\t\tif (!admin) {\n\t\t\t\t\tunauthorizedError(`Only admin is allowed to update ${data.marketingType} marketing`);\n\t\t\t\t}\n\t\t\t\tmarketing = await featuredMarketingService.update(_id, data);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase MarketingType.FREE_DELIVERY: {\n\t\t\t\tmarketing = await freeDeliveryMarketingService.update(_id, data);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase MarketingType.PUNCH_MARKETING: {\n\t\t\t\tmarketing = await punchMarketingService.update(_id, data);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\tmarketing = await this.model.findOneAndUpdate(\n\t\t\t\t\t{\n\t\t\t\t\t\t_id: _id,\n\t\t\t\t\t\tdeletedAt: null,\n\t\t\t\t\t},\n\t\t\t\t\tdata,\n\t\t\t\t\t{\n\t\t\t\t\t\tnew: true,\n\t\t\t\t\t\trunValidators: true,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (!marketing) {\n\t\t\tinternalServerError('Could not update marketing');\n\t\t}\n\n\t\tif (admin) {\n\t\t\tconst allChanges = getChangedFields(oldMarketing, marketing);\n\t\t\tconst relevantChanges = filterRelevantChanges(allChanges, data);\n\n\t\t\tif (Object.keys(relevantChanges).includes('pausedAt')) {\n\t\t\t\tif (data.pausedAt == null) {\n\t\t\t\t\tthis.logMarketingAdminAction(\n\t\t\t\t\t\tadmin,\n\t\t\t\t\t\tAdminLogsUpdatedFieldsType.CONTINUED_MARKETING_PROMOTIONS,\n\t\t\t\t\t\toldMarketing,\n\t\t\t\t\t\tmarketing\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis.logMarketingAdminAction(\n\t\t\t\t\t\tadmin,\n\t\t\t\t\t\tAdminLogsUpdatedFieldsType.PAUSED_MARKETING_PROMOTIONS,\n\t\t\t\t\t\toldMarketing,\n\t\t\t\t\t\tmarketing\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.logMarketingAdminAction(\n\t\t\t\tadmin,\n\t\t\t\tAdminLogsUpdatedFieldsType.EDITED_MARKETING_PROMOTIONS,\n\t\t\t\toldMarketing,\n\t\t\t\tmarketing\n\t\t\t);\n\t\t}\n\n\t\treturn marketing;\n\t}\n\n\tprivate async logMarketingAdminAction(\n\t\tadmin: mongoose.Types.ObjectId,\n\t\tactionType: AdminLogsUpdatedFieldsType,\n\t\toldDocument?: any,\n\t\tnewDocument?: any\n\t) {\n\t\tconst adminActivityLogsEvent: BaseEvent<Record<string, unknown>> = new AdminActivityLogsEvent({\n\t\t\tadmin,\n\t\t\tupdatedField: actionType,\n\t\t\toldDocument: oldDocument ?? '',\n\t\t\tnewDocument: newDocument ?? '',\n\t\t});\n\t\tawait publishEvent(adminActivityLogsEvent);\n\t}\n\n\t/**\n\t * Delete record\n\t * @param data Data for delete\n\t */\n\tpublic async deleteById(data: DeleteDTO, admin?: mongoose.Types.ObjectId): Promise<string> {\n\t\tconst { _id, softDelete } = data;\n\n\t\tconst record = await this.model.findById(_id);\n\n\t\tif (!record) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Record not found',\n\t\t\t});\n\t\t}\n\t\tconst result = await this.model.deleteRecord({ _id, deletedAt: null }, softDelete);\n\t\tif (!result) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: 'Unable to delete marketing',\n\t\t\t});\n\t\t}\n\n\t\tif (admin) {\n\t\t\tthis.logMarketingAdminAction(admin, AdminLogsUpdatedFieldsType.DELETED_MARKETING_PROMOTIONS, record);\n\t\t}\n\n\t\tproductMarketingService.deleteMany({ marketing: data._id }, data.softDelete);\n\n\t\treturn 'Record deleted successfully';\n\t}\n\n\tpublic async handleNewProductForEntireMenuMarketing(data: ProductEntireMenuMarketingHandlerDTO) {\n\t\tconst existingMarketing = await this.model.findOne({\n\t\t\tshop: data.shop,\n\t\t\tmarketingType: { $in: [MarketingType.BUY1GET1, MarketingType.DISCOUNT] },\n\t\t\t'duration.end': { $gt: new Date() },\n\t\t\tstatus: MarketingStatus.ACTIVE,\n\t\t\tisEntireMenu: true,\n\t\t});\n\n\t\t// check if existing marketing\n\t\tif (existingMarketing) {\n\t\t\tconst isAvailable = await productMarketingService.checkProductMarketingAvailability([data.product]);\n\t\t\tif (isAvailable) {\n\t\t\t\tconst productMarketingData: CreateProductMarketingDTO = {\n\t\t\t\t\tproduct: data.product,\n\t\t\t\t\tmarketing: existingMarketing._id,\n\t\t\t\t};\n\t\t\t\tif (existingMarketing.marketingType == MarketingType.BUY1GET1) {\n\t\t\t\t\tproductMarketingData.isBuy1Get1 = true;\n\t\t\t\t}\n\t\t\t\tif (existingMarketing.marketingType == MarketingType.DISCOUNT) {\n\t\t\t\t\tproductMarketingData.value = (existingMarketing as DocumentType<DiscountMarketing>).value;\n\t\t\t\t\tproductMarketingData.valueType = (existingMarketing as DocumentType<DiscountMarketing>).valueType;\n\t\t\t\t}\n\t\t\t\tconst result = await productMarketingService.create(productMarketingData);\n\n\t\t\t\tconsole.log(`Created product marketing: ${result}`);\n\t\t\t}\n\t\t}\n\n\t\treturn 'Product handled successfully';\n\t}\n}\n\nexport const marketingService = Container.get(MarketingService);\n"]}
|
|
1
|
+
{"version":3,"file":"marketing.service.js","sourceRoot":"/","sources":["modules/marketing/services/marketing.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4C;AAC5C,yCAAyC;AAEzC,sEAKmD;AAenD,wEAA6G;AAE7G,8FAA6G;AAC7G,iGAAoG;AACpG,4DAAgG;AAChG,8DAAkE;AAGlE,wBAOW;AACX,4DAAkE;AAClE,4EAImD;AAG5C,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IACpB,KAAK,CAAiD;IAE9D;QACC,IAAI,CAAC,KAAK,GAAG,uBAAgE,CAAC;IAC/E,CAAC;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AAG,MAAM,0BAAuB,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;gBAE1E,OAAO,CAAC,GAAG,CAAC,8BAA8B,MAAM,EAAE,CAAC,CAAC;YACrD,CAAC;QACF,CAAC;QAED,OAAO,8BAA8B,CAAC;IACvC,CAAC;CACD,CAAA;AA/UY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,gBAAO,GAAE;;GACG,gBAAgB,CA+U5B;AAEY,QAAA,gBAAgB,GAAG,gBAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["import Container, { Service } from 'typedi';\nimport { TRPCError } from '@trpc/server';\nimport { DocumentType, mongoose, ReturnModelType } from '@typegoose/typegoose';\nimport {\n\tDiscountMarketing,\n\tMarketingModel,\n\tMarketing as Model,\n\tPunchMarketingHistory,\n} from '@lyxa.ai/core/dist/libraries/mongo/models';\nimport {\n\tAllMarketingsDTO,\n\tAllMarketingsValidationDTO,\n\tCreateProductMarketingDTO,\n\tProductEntireMenuMarketingHandlerDTO,\n\tUpdateMarketingDTO as UpdateDTO,\n} from '@modules/marketing/validations';\nimport {\n\tFilterDTO,\n\tPaginatedResponse,\n\tDeleteDTO,\n\tGetByIdInputDTO,\n} from '@lyxa.ai/core/dist/utilities/validation';\nimport { SoftDeleteModel } from '@lyxa.ai/core/dist/libraries/mongo/plugins/soft-delete-plugin';\nimport { createRawDocumentPaginatorObject, PaginatorOptions } from '@lyxa.ai/core/dist/utilities/pagination';\nimport { ModelType } from '@typegoose/typegoose/lib/types';\nimport { filterRelevantChanges, getChangedFields } from '@lyxa.ai/core/dist/utilities/events-common-methods';\nimport { AdminActivityLogsEvent } from '@lyxa.ai/core/dist/libraries/event/events/admin-logs-event';\nimport { AdminLogsUpdatedFieldsType, MarketingStatus } from '@lyxa.ai/core/dist/utilities/enum';\nimport { publishEvent } from '@lyxa.ai/core/dist/libraries/event';\nimport { BaseEvent } from '@lyxa.ai/core/dist/libraries/event/BaseEvent';\n\nimport {\n\tbuy1Get1MarketingService,\n\tdiscountMarketingService,\n\tfeaturedMarketingService,\n\tfreeDeliveryMarketingService,\n\tproductMarketingService,\n\tpunchMarketingService,\n} from '.';\nimport { MarketingType } from '@lyxa.ai/core/dist/utilities/enum';\nimport {\n\tinternalServerError,\n\tnotFoundError,\n\tunauthorizedError,\n} from '@lyxa.ai/core/dist/utilities/error-common';\n\n@Service()\nexport class MarketingService {\n\tprivate model: typeof MarketingModel & SoftDeleteModel<Model>;\n\n\tconstructor() {\n\t\tthis.model = MarketingModel as typeof MarketingModel & SoftDeleteModel<Model>;\n\t}\n\n\t/**\n\t * Create a new record\n\t * @param data Data for the new record\n\t */\n\tpublic async create(\n\t\tdata: AllMarketingsValidationDTO,\n\t\tadmin?: mongoose.Types.ObjectId\n\t): Promise<DocumentType<Model>> {\n\t\tconst now = new Date();\n\n\t\tconst existingRecord = await this.model.findOne({\n\t\t\tshop: data.shop,\n\t\t\tmarketingType: data.marketingType,\n\t\t\t'duration.end': { $gt: new Date() },\n\t\t\tstatus: MarketingStatus.ACTIVE,\n\t\t});\n\t\tif (existingRecord) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'CONFLICT',\n\t\t\t\tmessage: `This shop already has a ${data.marketingType} marketing`,\n\t\t\t});\n\t\t}\n\n\t\tif (data.isEntireMenu) {\n\t\t\tconst existingMarketing = await this.model.findOne({\n\t\t\t\tshop: data.shop,\n\t\t\t\t'duration.start': { $lt: now },\n\t\t\t\t'duration.end': { $gt: now },\n\t\t\t\tstatus: MarketingStatus.ACTIVE,\n\t\t\t\tmarketingType: { $in: [MarketingType.BUY1GET1, MarketingType.DISCOUNT] },\n\t\t\t});\n\t\t\tif (existingMarketing) {\n\t\t\t\tthrow new TRPCError({\n\t\t\t\t\tcode: 'CONFLICT',\n\t\t\t\t\tmessage: `Cannot create marketing for entire menu while another product based marketing exists for the shop`,\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (data.products && data.products.length > 0) {\n\t\t\tconst productIds = data.products.map((product: CreateProductMarketingDTO) => product.product);\n\n\t\t\tconst hasDuplicates = new Set(productIds.map(String)).size !== productIds.length;\n\n\t\t\tif (hasDuplicates) {\n\t\t\t\tthrow new TRPCError({\n\t\t\t\t\tcode: 'BAD_REQUEST',\n\t\t\t\t\tmessage: `Product list contains duplicate products`,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst isAvailable = await productMarketingService.checkProductMarketingAvailability(productIds);\n\n\t\t\tif (!isAvailable) {\n\t\t\t\tthrow new TRPCError({\n\t\t\t\t\tcode: 'CONFLICT',\n\t\t\t\t\tmessage: `Product list contains products which already have marketing applied`,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tlet marketing: AllMarketingsDTO;\n\n\t\tswitch (data.marketingType) {\n\t\t\tcase MarketingType.DISCOUNT: {\n\t\t\t\tmarketing = await discountMarketingService.create(data);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase MarketingType.BUY1GET1: {\n\t\t\t\tmarketing = await buy1Get1MarketingService.create(data);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase MarketingType.FEATURED: {\n\t\t\t\tif (!admin) {\n\t\t\t\t\tthrow new TRPCError({\n\t\t\t\t\t\tcode: 'UNAUTHORIZED',\n\t\t\t\t\t\tmessage: `Only admin is allowed to create ${data.marketingType} marketing`,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tmarketing = await featuredMarketingService.create(data);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase MarketingType.FREE_DELIVERY: {\n\t\t\t\tmarketing = await freeDeliveryMarketingService.create(data);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase MarketingType.PUNCH_MARKETING: {\n\t\t\t\tmarketing = await punchMarketingService.create(data);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\tmarketing = await this.model.create(data);\n\t\t\t}\n\t\t}\n\n\t\tif (admin) {\n\t\t\tthis.logMarketingAdminAction(\n\t\t\t\tadmin,\n\t\t\t\tAdminLogsUpdatedFieldsType.ACTIVATED_MARKETING_PROMOTIONS,\n\t\t\t\t'',\n\t\t\t\tmarketing\n\t\t\t);\n\t\t}\n\n\t\treturn marketing;\n\t}\n\n\t/**\n\t * Get record by ID\n\t * @param id ID of the record\n\t */\n\tpublic async findById(data: GetByIdInputDTO): Promise<DocumentType<Model>> {\n\t\tconst result = await this.model.findRecordById(data);\n\t\tif (!result) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Record not found',\n\t\t\t});\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Get records\n\t * @param query Query to find records\n\t */\n\tpublic async find(data?: Partial<FilterDTO>): Promise<PaginatedResponse<DocumentType<ModelType<Model>>>> {\n\t\ttry {\n\t\t\tconst paginate = createRawDocumentPaginatorObject(this.model as ReturnModelType<typeof this.model>);\n\t\t\tconst options: PaginatorOptions<typeof Model> = {\n\t\t\t\tpage: data?.page,\n\t\t\t\tsize: data?.size,\n\t\t\t\tsort: data?.sort,\n\t\t\t\tquery: data?.query,\n\t\t\t\tselect: data?.select,\n\t\t\t\tpopulate: data?.populate,\n\t\t\t};\n\t\t\tconst paginatedResult = await paginate(options);\n\t\t\treturn paginatedResult;\n\t\t} catch (err) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: `err: ${err}`,\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Update record\n\t * @param id ID of the record\n\t * @param data Data to update\n\t */\n\tpublic async update(\n\t\t_id: mongoose.Types.ObjectId,\n\t\tdata: UpdateDTO,\n\t\tadmin?: mongoose.Types.ObjectId\n\t): Promise<DocumentType<Model>> {\n\t\tlet marketing: AllMarketingsDTO;\n\n\t\tconst oldMarketing = await this.model.findById(_id);\n\n\t\tif (!oldMarketing) {\n\t\t\tnotFoundError('Could not find marketing');\n\t\t}\n\n\t\tswitch (oldMarketing.marketingType) {\n\t\t\tcase MarketingType.DISCOUNT: {\n\t\t\t\tmarketing = await discountMarketingService.update(_id, data);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase MarketingType.BUY1GET1: {\n\t\t\t\tmarketing = await buy1Get1MarketingService.update(_id, data);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase MarketingType.FEATURED: {\n\t\t\t\tif (!admin) {\n\t\t\t\t\tunauthorizedError(`Only admin is allowed to update ${data.marketingType} marketing`);\n\t\t\t\t}\n\t\t\t\tmarketing = await featuredMarketingService.update(_id, data);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase MarketingType.FREE_DELIVERY: {\n\t\t\t\tmarketing = await freeDeliveryMarketingService.update(_id, data);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase MarketingType.PUNCH_MARKETING: {\n\t\t\t\tmarketing = await punchMarketingService.update(_id, data);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\tmarketing = await this.model.findOneAndUpdate(\n\t\t\t\t\t{\n\t\t\t\t\t\t_id: _id,\n\t\t\t\t\t\tdeletedAt: null,\n\t\t\t\t\t},\n\t\t\t\t\tdata,\n\t\t\t\t\t{\n\t\t\t\t\t\tnew: true,\n\t\t\t\t\t\trunValidators: true,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (!marketing) {\n\t\t\tinternalServerError('Could not update marketing');\n\t\t}\n\n\t\tif (admin) {\n\t\t\tconst allChanges = getChangedFields(oldMarketing, marketing);\n\t\t\tconst relevantChanges = filterRelevantChanges(allChanges, data);\n\n\t\t\tif (Object.keys(relevantChanges).includes('pausedAt')) {\n\t\t\t\tif (data.pausedAt == null) {\n\t\t\t\t\tthis.logMarketingAdminAction(\n\t\t\t\t\t\tadmin,\n\t\t\t\t\t\tAdminLogsUpdatedFieldsType.CONTINUED_MARKETING_PROMOTIONS,\n\t\t\t\t\t\toldMarketing,\n\t\t\t\t\t\tmarketing\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis.logMarketingAdminAction(\n\t\t\t\t\t\tadmin,\n\t\t\t\t\t\tAdminLogsUpdatedFieldsType.PAUSED_MARKETING_PROMOTIONS,\n\t\t\t\t\t\toldMarketing,\n\t\t\t\t\t\tmarketing\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.logMarketingAdminAction(\n\t\t\t\tadmin,\n\t\t\t\tAdminLogsUpdatedFieldsType.EDITED_MARKETING_PROMOTIONS,\n\t\t\t\toldMarketing,\n\t\t\t\tmarketing\n\t\t\t);\n\t\t}\n\n\t\treturn marketing;\n\t}\n\n\tprivate async logMarketingAdminAction(\n\t\tadmin: mongoose.Types.ObjectId,\n\t\tactionType: AdminLogsUpdatedFieldsType,\n\t\toldDocument?: any,\n\t\tnewDocument?: any\n\t) {\n\t\tconst adminActivityLogsEvent: BaseEvent<Record<string, unknown>> = new AdminActivityLogsEvent({\n\t\t\tadmin,\n\t\t\tupdatedField: actionType,\n\t\t\toldDocument: oldDocument ?? '',\n\t\t\tnewDocument: newDocument ?? '',\n\t\t});\n\t\tawait publishEvent(adminActivityLogsEvent);\n\t}\n\n\t/**\n\t * Delete record\n\t * @param data Data for delete\n\t */\n\tpublic async deleteById(data: DeleteDTO, admin?: mongoose.Types.ObjectId): Promise<string> {\n\t\tconst { _id, softDelete } = data;\n\n\t\tconst record = await this.model.findById(_id);\n\n\t\tif (!record) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'NOT_FOUND',\n\t\t\t\tmessage: 'Record not found',\n\t\t\t});\n\t\t}\n\t\tconst result = await this.model.deleteRecord({ _id, deletedAt: null }, softDelete);\n\t\tif (!result) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: 'Unable to delete marketing',\n\t\t\t});\n\t\t}\n\n\t\tif (admin) {\n\t\t\tthis.logMarketingAdminAction(admin, AdminLogsUpdatedFieldsType.DELETED_MARKETING_PROMOTIONS, record);\n\t\t}\n\n\t\tproductMarketingService.deleteMany({ marketing: data._id }, data.softDelete);\n\n\t\treturn 'Record deleted successfully';\n\t}\n\n\tpublic async handleNewProductForEntireMenuMarketing(data: ProductEntireMenuMarketingHandlerDTO) {\n\t\tconst existingMarketing = await this.model.findOne({\n\t\t\tshop: data.shop,\n\t\t\tmarketingType: { $in: [MarketingType.BUY1GET1, MarketingType.DISCOUNT] },\n\t\t\t'duration.end': { $gt: new Date() },\n\t\t\tstatus: MarketingStatus.ACTIVE,\n\t\t\tisEntireMenu: true,\n\t\t});\n\n\t\t// check if existing marketing\n\t\tif (existingMarketing) {\n\t\t\tconst isAvailable = await productMarketingService.checkProductMarketingAvailability([data.product]);\n\t\t\tif (isAvailable) {\n\t\t\t\tconst productMarketingData: CreateProductMarketingDTO = {\n\t\t\t\t\tproduct: data.product,\n\t\t\t\t\tmarketing: existingMarketing._id,\n\t\t\t\t};\n\t\t\t\tif (existingMarketing.marketingType == MarketingType.BUY1GET1) {\n\t\t\t\t\tproductMarketingData.isBuy1Get1 = true;\n\t\t\t\t}\n\t\t\t\tif (existingMarketing.marketingType == MarketingType.DISCOUNT) {\n\t\t\t\t\tproductMarketingData.value = (existingMarketing as DocumentType<DiscountMarketing>).value;\n\t\t\t\t\tproductMarketingData.valueType = (existingMarketing as DocumentType<DiscountMarketing>).valueType;\n\t\t\t\t}\n\t\t\t\tconst result = await productMarketingService.create(productMarketingData);\n\n\t\t\t\tconsole.log(`Created product marketing: ${result}`);\n\t\t\t}\n\t\t}\n\n\t\treturn 'Product handled successfully';\n\t}\n}\n\nexport const marketingService = Container.get(MarketingService);\n"]}
|