@vedhae/cms-schema 4.2.3 → 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 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";
@@ -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.ZodEnum<["men", "women", "kids", "adults", "teens"]>, "many">;
11
- categories: z.ZodArray<z.ZodEnum<["face", "lip", "face-lips", "body", "hair"]>, "many">;
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: ("men" | "women" | "kids" | "adults" | "teens")[];
49
- categories: ("face" | "lip" | "face-lips" | "body" | "hair")[];
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: ("men" | "women" | "kids" | "adults" | "teens")[];
77
- categories: ("face" | "lip" | "face-lips" | "body" | "hair")[];
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: ("men" | "women" | "kids" | "adults" | "teens")[];
105
- categories: ("face" | "lip" | "face-lips" | "body" | "hair")[];
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: ("men" | "women" | "kids" | "adults" | "teens")[];
133
- categories: ("face" | "lip" | "face-lips" | "body" | "hair")[];
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>;
@@ -1,6 +1,5 @@
1
1
  import { z } from "zod";
2
2
  import { ImageAssetSchema } from "./image.schema.js";
3
- import { ProductCategorySchema, ProductUserSchema, } from "./product.meta.js";
4
3
  /**
5
4
  * Product schema
6
5
  */
@@ -16,18 +15,26 @@ export const ProductSchema = z
16
15
  /* =========================
17
16
  Audience & classification
18
17
  ========================= */
19
- users: z.array(ProductUserSchema).min(1),
20
- categories: z.array(ProductCategorySchema).min(1),
18
+ users: z.array(z.string()).min(1),
19
+ categories: z.array(z.string()).min(1),
21
20
  /* =========================
22
21
  Navigation
23
22
  ========================= */
24
23
  internalLink: z.string().startsWith("/"),
25
24
  externalLink: z.string().url().optional(),
26
25
  /* =========================
27
- Pricing & availability
26
+ Pricing
28
27
  ========================= */
29
28
  price: z.number().nonnegative(),
29
+ discountPercent: z
30
+ .number()
31
+ .min(0)
32
+ .max(100)
33
+ .optional(),
30
34
  priceSubText: z.string().optional(),
35
+ /* =========================
36
+ Stock
37
+ ========================= */
31
38
  stockStatus: z.boolean(),
32
39
  stockVolume: z.number().int().nonnegative(),
33
40
  /* =========================
@@ -44,7 +51,7 @@ export const ProductSchema = z
44
51
  ingredientsTitle: z.string().min(1),
45
52
  ingredients: z.array(z.tuple([z.string(), z.string()])).min(1),
46
53
  /* =========================
47
- System fields
54
+ System
48
55
  ========================= */
49
56
  active: z.boolean(),
50
57
  order: z.number(),
@@ -52,11 +59,20 @@ export const ProductSchema = z
52
59
  updatedAt: z.number(),
53
60
  })
54
61
  .superRefine((data, ctx) => {
55
- if (data.stockStatus === false && data.stockVolume !== 0) {
62
+ // stock logic
63
+ if (!data.stockStatus && data.stockVolume !== 0) {
56
64
  ctx.addIssue({
57
65
  path: ["stockVolume"],
58
66
  message: "stockVolume must be 0 when stockStatus is false",
59
67
  code: z.ZodIssueCode.custom,
60
68
  });
61
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
+ }
62
78
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vedhae/cms-schema",
3
- "version": "4.2.3",
3
+ "version": "4.2.5",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",