@vedhae/cms-schema 4.2.4 → 4.2.5
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/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/product.schema.d.ts +15 -10
- package/dist/product.schema.js +20 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,12 +3,10 @@ export { HeroSectionSchema } from "./hero.schema.js";
|
|
|
3
3
|
export { CardSectionSchema } from "./cardSection.schema.js";
|
|
4
4
|
export { ProductSchema } from "./product.schema.js";
|
|
5
5
|
export { ProductHeroSchema } from "./productHero.schema.js";
|
|
6
|
-
export { ProductCategorySchema, ProductUserSchema, ProductRouteSchema, } from "./product.meta.js";
|
|
7
6
|
export { AboutHeroSchema, AboutContentSchema, AboutImagesSchema, } from "./about.schema.js";
|
|
8
7
|
export type { ImageAsset } from "./image.schema.js";
|
|
9
8
|
export type { HeroSection } from "./hero.schema.js";
|
|
10
9
|
export type { CardSection } from "./cardSection.schema.js";
|
|
11
10
|
export type { Product } from "./product.schema.js";
|
|
12
11
|
export type { ProductHero } from "./productHero.schema.js";
|
|
13
|
-
export type { ProductCategory, ProductUser, ProductRoute, RouteConfig, } from "./product.meta.js";
|
|
14
12
|
export type { AboutHero, AboutContent, AboutImages, } from "./about.schema.js";
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,5 @@ export { CardSectionSchema } from "./cardSection.schema.js";
|
|
|
8
8
|
// Products
|
|
9
9
|
export { ProductSchema } from "./product.schema.js";
|
|
10
10
|
export { ProductHeroSchema } from "./productHero.schema.js";
|
|
11
|
-
// Product meta (ROUTES / CATEGORIES / USERS)
|
|
12
|
-
export { ProductCategorySchema, ProductUserSchema, ProductRouteSchema, } from "./product.meta.js";
|
|
13
11
|
// About
|
|
14
12
|
export { AboutHeroSchema, AboutContentSchema, AboutImagesSchema, } from "./about.schema.js";
|
package/dist/product.schema.d.ts
CHANGED
|
@@ -7,11 +7,12 @@ export declare const ProductSchema: z.ZodEffects<z.ZodObject<{
|
|
|
7
7
|
title: z.ZodString;
|
|
8
8
|
titleDescription: z.ZodString;
|
|
9
9
|
size: z.ZodString;
|
|
10
|
-
users: z.ZodArray<z.
|
|
11
|
-
categories: z.ZodArray<z.
|
|
10
|
+
users: z.ZodArray<z.ZodString, "many">;
|
|
11
|
+
categories: z.ZodArray<z.ZodString, "many">;
|
|
12
12
|
internalLink: z.ZodString;
|
|
13
13
|
externalLink: z.ZodOptional<z.ZodString>;
|
|
14
14
|
price: z.ZodNumber;
|
|
15
|
+
discountPercent: z.ZodOptional<z.ZodNumber>;
|
|
15
16
|
priceSubText: z.ZodOptional<z.ZodString>;
|
|
16
17
|
stockStatus: z.ZodBoolean;
|
|
17
18
|
stockVolume: z.ZodNumber;
|
|
@@ -45,8 +46,8 @@ export declare const ProductSchema: z.ZodEffects<z.ZodObject<{
|
|
|
45
46
|
id: string;
|
|
46
47
|
titleDescription: string;
|
|
47
48
|
size: string;
|
|
48
|
-
users:
|
|
49
|
-
categories:
|
|
49
|
+
users: string[];
|
|
50
|
+
categories: string[];
|
|
50
51
|
internalLink: string;
|
|
51
52
|
price: number;
|
|
52
53
|
stockStatus: boolean;
|
|
@@ -65,6 +66,7 @@ export declare const ProductSchema: z.ZodEffects<z.ZodObject<{
|
|
|
65
66
|
createdAt: number;
|
|
66
67
|
updatedAt: number;
|
|
67
68
|
externalLink?: string | undefined;
|
|
69
|
+
discountPercent?: number | undefined;
|
|
68
70
|
priceSubText?: string | undefined;
|
|
69
71
|
}, {
|
|
70
72
|
title: string;
|
|
@@ -73,8 +75,8 @@ export declare const ProductSchema: z.ZodEffects<z.ZodObject<{
|
|
|
73
75
|
id: string;
|
|
74
76
|
titleDescription: string;
|
|
75
77
|
size: string;
|
|
76
|
-
users:
|
|
77
|
-
categories:
|
|
78
|
+
users: string[];
|
|
79
|
+
categories: string[];
|
|
78
80
|
internalLink: string;
|
|
79
81
|
price: number;
|
|
80
82
|
stockStatus: boolean;
|
|
@@ -93,6 +95,7 @@ export declare const ProductSchema: z.ZodEffects<z.ZodObject<{
|
|
|
93
95
|
createdAt: number;
|
|
94
96
|
updatedAt: number;
|
|
95
97
|
externalLink?: string | undefined;
|
|
98
|
+
discountPercent?: number | undefined;
|
|
96
99
|
priceSubText?: string | undefined;
|
|
97
100
|
}>, {
|
|
98
101
|
title: string;
|
|
@@ -101,8 +104,8 @@ export declare const ProductSchema: z.ZodEffects<z.ZodObject<{
|
|
|
101
104
|
id: string;
|
|
102
105
|
titleDescription: string;
|
|
103
106
|
size: string;
|
|
104
|
-
users:
|
|
105
|
-
categories:
|
|
107
|
+
users: string[];
|
|
108
|
+
categories: string[];
|
|
106
109
|
internalLink: string;
|
|
107
110
|
price: number;
|
|
108
111
|
stockStatus: boolean;
|
|
@@ -121,6 +124,7 @@ export declare const ProductSchema: z.ZodEffects<z.ZodObject<{
|
|
|
121
124
|
createdAt: number;
|
|
122
125
|
updatedAt: number;
|
|
123
126
|
externalLink?: string | undefined;
|
|
127
|
+
discountPercent?: number | undefined;
|
|
124
128
|
priceSubText?: string | undefined;
|
|
125
129
|
}, {
|
|
126
130
|
title: string;
|
|
@@ -129,8 +133,8 @@ export declare const ProductSchema: z.ZodEffects<z.ZodObject<{
|
|
|
129
133
|
id: string;
|
|
130
134
|
titleDescription: string;
|
|
131
135
|
size: string;
|
|
132
|
-
users:
|
|
133
|
-
categories:
|
|
136
|
+
users: string[];
|
|
137
|
+
categories: string[];
|
|
134
138
|
internalLink: string;
|
|
135
139
|
price: number;
|
|
136
140
|
stockStatus: boolean;
|
|
@@ -149,6 +153,7 @@ export declare const ProductSchema: z.ZodEffects<z.ZodObject<{
|
|
|
149
153
|
createdAt: number;
|
|
150
154
|
updatedAt: number;
|
|
151
155
|
externalLink?: string | undefined;
|
|
156
|
+
discountPercent?: number | undefined;
|
|
152
157
|
priceSubText?: string | undefined;
|
|
153
158
|
}>;
|
|
154
159
|
export type Product = z.infer<typeof ProductSchema>;
|
package/dist/product.schema.js
CHANGED
|
@@ -23,10 +23,18 @@ export const ProductSchema = z
|
|
|
23
23
|
internalLink: z.string().startsWith("/"),
|
|
24
24
|
externalLink: z.string().url().optional(),
|
|
25
25
|
/* =========================
|
|
26
|
-
Pricing
|
|
26
|
+
Pricing
|
|
27
27
|
========================= */
|
|
28
28
|
price: z.number().nonnegative(),
|
|
29
|
+
discountPercent: z
|
|
30
|
+
.number()
|
|
31
|
+
.min(0)
|
|
32
|
+
.max(100)
|
|
33
|
+
.optional(),
|
|
29
34
|
priceSubText: z.string().optional(),
|
|
35
|
+
/* =========================
|
|
36
|
+
Stock
|
|
37
|
+
========================= */
|
|
30
38
|
stockStatus: z.boolean(),
|
|
31
39
|
stockVolume: z.number().int().nonnegative(),
|
|
32
40
|
/* =========================
|
|
@@ -43,7 +51,7 @@ export const ProductSchema = z
|
|
|
43
51
|
ingredientsTitle: z.string().min(1),
|
|
44
52
|
ingredients: z.array(z.tuple([z.string(), z.string()])).min(1),
|
|
45
53
|
/* =========================
|
|
46
|
-
System
|
|
54
|
+
System
|
|
47
55
|
========================= */
|
|
48
56
|
active: z.boolean(),
|
|
49
57
|
order: z.number(),
|
|
@@ -51,11 +59,20 @@ export const ProductSchema = z
|
|
|
51
59
|
updatedAt: z.number(),
|
|
52
60
|
})
|
|
53
61
|
.superRefine((data, ctx) => {
|
|
54
|
-
|
|
62
|
+
// stock logic
|
|
63
|
+
if (!data.stockStatus && data.stockVolume !== 0) {
|
|
55
64
|
ctx.addIssue({
|
|
56
65
|
path: ["stockVolume"],
|
|
57
66
|
message: "stockVolume must be 0 when stockStatus is false",
|
|
58
67
|
code: z.ZodIssueCode.custom,
|
|
59
68
|
});
|
|
60
69
|
}
|
|
70
|
+
// discount sanity
|
|
71
|
+
if (data.discountPercent && data.discountPercent > 0 && data.price === 0) {
|
|
72
|
+
ctx.addIssue({
|
|
73
|
+
path: ["discountPercent"],
|
|
74
|
+
message: "Discount cannot be applied when price is 0",
|
|
75
|
+
code: z.ZodIssueCode.custom,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
61
78
|
});
|