@vedhae/cms-schema 4.2.2 → 4.2.4
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 +2 -0
- package/dist/index.js +8 -4
- package/dist/product.meta.d.ts +43 -0
- package/dist/product.meta.js +58 -0
- package/dist/product.schema.d.ts +10 -14
- package/dist/product.schema.js +0 -8
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,10 +3,12 @@ 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";
|
|
6
7
|
export { AboutHeroSchema, AboutContentSchema, AboutImagesSchema, } from "./about.schema.js";
|
|
7
8
|
export type { ImageAsset } from "./image.schema.js";
|
|
8
9
|
export type { HeroSection } from "./hero.schema.js";
|
|
9
10
|
export type { CardSection } from "./cardSection.schema.js";
|
|
10
11
|
export type { Product } from "./product.schema.js";
|
|
11
12
|
export type { ProductHero } from "./productHero.schema.js";
|
|
13
|
+
export type { ProductCategory, ProductUser, ProductRoute, RouteConfig, } from "./product.meta.js";
|
|
12
14
|
export type { AboutHero, AboutContent, AboutImages, } from "./about.schema.js";
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/* ======================================================
|
|
2
|
+
SCHEMAS
|
|
3
|
+
====================================================== */
|
|
4
|
+
// Core
|
|
4
5
|
export { ImageAssetSchema } from "./image.schema.js";
|
|
5
6
|
export { HeroSectionSchema } from "./hero.schema.js";
|
|
6
7
|
export { CardSectionSchema } from "./cardSection.schema.js";
|
|
8
|
+
// Products
|
|
7
9
|
export { ProductSchema } from "./product.schema.js";
|
|
8
10
|
export { ProductHeroSchema } from "./productHero.schema.js";
|
|
9
|
-
//
|
|
11
|
+
// Product meta (ROUTES / CATEGORIES / USERS)
|
|
12
|
+
export { ProductCategorySchema, ProductUserSchema, ProductRouteSchema, } from "./product.meta.js";
|
|
13
|
+
// About
|
|
10
14
|
export { AboutHeroSchema, AboutContentSchema, AboutImagesSchema, } from "./about.schema.js";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Categories represent *where* a product belongs
|
|
4
|
+
* Example routes:
|
|
5
|
+
* /products/body
|
|
6
|
+
* /products/face-lips
|
|
7
|
+
*/
|
|
8
|
+
export declare const PRODUCT_CATEGORIES: readonly ["face", "lip", "face-lips", "body", "hair"];
|
|
9
|
+
export declare const ProductCategorySchema: z.ZodEnum<["face", "lip", "face-lips", "body", "hair"]>;
|
|
10
|
+
export type ProductCategory = z.infer<typeof ProductCategorySchema>;
|
|
11
|
+
/**
|
|
12
|
+
* Users represent *who* the product is for
|
|
13
|
+
* Example routes:
|
|
14
|
+
* /products/men
|
|
15
|
+
* /products/women
|
|
16
|
+
* /products/kids
|
|
17
|
+
*/
|
|
18
|
+
export declare const PRODUCT_USERS: readonly ["men", "women", "kids", "adults", "teens"];
|
|
19
|
+
export declare const ProductUserSchema: z.ZodEnum<["men", "women", "kids", "adults", "teens"]>;
|
|
20
|
+
export type ProductUser = z.infer<typeof ProductUserSchema>;
|
|
21
|
+
/**
|
|
22
|
+
* These are the ONLY allowed product listing routes
|
|
23
|
+
* Used by:
|
|
24
|
+
* - Astro getStaticPaths
|
|
25
|
+
* - Admin routing
|
|
26
|
+
* - Worker validation
|
|
27
|
+
*/
|
|
28
|
+
export declare const PRODUCT_ROUTES: readonly ["face-lips", "body", "hair", "men", "women", "kids"];
|
|
29
|
+
export declare const ProductRouteSchema: z.ZodEnum<["face-lips", "body", "hair", "men", "women", "kids"]>;
|
|
30
|
+
export type ProductRoute = z.infer<typeof ProductRouteSchema>;
|
|
31
|
+
/**
|
|
32
|
+
* Shared route config shape
|
|
33
|
+
* Used by website to map routes → filters
|
|
34
|
+
*/
|
|
35
|
+
export type RouteConfig = {
|
|
36
|
+
type: "category";
|
|
37
|
+
values: ProductCategory[];
|
|
38
|
+
title: string;
|
|
39
|
+
} | {
|
|
40
|
+
type: "user";
|
|
41
|
+
values: ProductUser[];
|
|
42
|
+
title: string;
|
|
43
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/* =========================================================
|
|
3
|
+
PRODUCT CATEGORIES
|
|
4
|
+
(used for category pages, filtering, hero selection)
|
|
5
|
+
========================================================= */
|
|
6
|
+
/**
|
|
7
|
+
* Categories represent *where* a product belongs
|
|
8
|
+
* Example routes:
|
|
9
|
+
* /products/body
|
|
10
|
+
* /products/face-lips
|
|
11
|
+
*/
|
|
12
|
+
export const PRODUCT_CATEGORIES = [
|
|
13
|
+
"face",
|
|
14
|
+
"lip",
|
|
15
|
+
"face-lips",
|
|
16
|
+
"body",
|
|
17
|
+
"hair",
|
|
18
|
+
];
|
|
19
|
+
export const ProductCategorySchema = z.enum(PRODUCT_CATEGORIES);
|
|
20
|
+
/* =========================================================
|
|
21
|
+
PRODUCT USERS / AUDIENCE
|
|
22
|
+
(used for "Shop by Person" pages)
|
|
23
|
+
========================================================= */
|
|
24
|
+
/**
|
|
25
|
+
* Users represent *who* the product is for
|
|
26
|
+
* Example routes:
|
|
27
|
+
* /products/men
|
|
28
|
+
* /products/women
|
|
29
|
+
* /products/kids
|
|
30
|
+
*/
|
|
31
|
+
export const PRODUCT_USERS = [
|
|
32
|
+
"men",
|
|
33
|
+
"women",
|
|
34
|
+
"kids",
|
|
35
|
+
"adults",
|
|
36
|
+
"teens",
|
|
37
|
+
];
|
|
38
|
+
export const ProductUserSchema = z.enum(PRODUCT_USERS);
|
|
39
|
+
/* =========================================================
|
|
40
|
+
PRODUCT ROUTES
|
|
41
|
+
(all valid /products/:route pages)
|
|
42
|
+
========================================================= */
|
|
43
|
+
/**
|
|
44
|
+
* These are the ONLY allowed product listing routes
|
|
45
|
+
* Used by:
|
|
46
|
+
* - Astro getStaticPaths
|
|
47
|
+
* - Admin routing
|
|
48
|
+
* - Worker validation
|
|
49
|
+
*/
|
|
50
|
+
export const PRODUCT_ROUTES = [
|
|
51
|
+
"face-lips",
|
|
52
|
+
"body",
|
|
53
|
+
"hair",
|
|
54
|
+
"men",
|
|
55
|
+
"women",
|
|
56
|
+
"kids",
|
|
57
|
+
];
|
|
58
|
+
export const ProductRouteSchema = z.enum(PRODUCT_ROUTES);
|
package/dist/product.schema.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ 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.ZodEnum<["men", "women", "kids", "adults", "teens"]>, "many">;
|
|
11
|
+
categories: z.ZodArray<z.ZodEnum<["face", "lip", "face-lips", "body", "hair"]>, "many">;
|
|
12
12
|
internalLink: z.ZodString;
|
|
13
13
|
externalLink: z.ZodOptional<z.ZodString>;
|
|
14
14
|
price: z.ZodNumber;
|
|
@@ -33,10 +33,6 @@ export declare const ProductSchema: z.ZodEffects<z.ZodObject<{
|
|
|
33
33
|
howToUseTitle: z.ZodString;
|
|
34
34
|
howToUseDescription: z.ZodString;
|
|
35
35
|
ingredientsTitle: z.ZodString;
|
|
36
|
-
/**
|
|
37
|
-
* Each ingredient item:
|
|
38
|
-
* [ingredientName, ingredientDescription]
|
|
39
|
-
*/
|
|
40
36
|
ingredients: z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString], null>, "many">;
|
|
41
37
|
active: z.ZodBoolean;
|
|
42
38
|
order: z.ZodNumber;
|
|
@@ -49,8 +45,8 @@ export declare const ProductSchema: z.ZodEffects<z.ZodObject<{
|
|
|
49
45
|
id: string;
|
|
50
46
|
titleDescription: string;
|
|
51
47
|
size: string;
|
|
52
|
-
users:
|
|
53
|
-
categories:
|
|
48
|
+
users: ("men" | "women" | "kids" | "adults" | "teens")[];
|
|
49
|
+
categories: ("face" | "lip" | "face-lips" | "body" | "hair")[];
|
|
54
50
|
internalLink: string;
|
|
55
51
|
price: number;
|
|
56
52
|
stockStatus: boolean;
|
|
@@ -77,8 +73,8 @@ export declare const ProductSchema: z.ZodEffects<z.ZodObject<{
|
|
|
77
73
|
id: string;
|
|
78
74
|
titleDescription: string;
|
|
79
75
|
size: string;
|
|
80
|
-
users:
|
|
81
|
-
categories:
|
|
76
|
+
users: ("men" | "women" | "kids" | "adults" | "teens")[];
|
|
77
|
+
categories: ("face" | "lip" | "face-lips" | "body" | "hair")[];
|
|
82
78
|
internalLink: string;
|
|
83
79
|
price: number;
|
|
84
80
|
stockStatus: boolean;
|
|
@@ -105,8 +101,8 @@ export declare const ProductSchema: z.ZodEffects<z.ZodObject<{
|
|
|
105
101
|
id: string;
|
|
106
102
|
titleDescription: string;
|
|
107
103
|
size: string;
|
|
108
|
-
users:
|
|
109
|
-
categories:
|
|
104
|
+
users: ("men" | "women" | "kids" | "adults" | "teens")[];
|
|
105
|
+
categories: ("face" | "lip" | "face-lips" | "body" | "hair")[];
|
|
110
106
|
internalLink: string;
|
|
111
107
|
price: number;
|
|
112
108
|
stockStatus: boolean;
|
|
@@ -133,8 +129,8 @@ export declare const ProductSchema: z.ZodEffects<z.ZodObject<{
|
|
|
133
129
|
id: string;
|
|
134
130
|
titleDescription: string;
|
|
135
131
|
size: string;
|
|
136
|
-
users:
|
|
137
|
-
categories:
|
|
132
|
+
users: ("men" | "women" | "kids" | "adults" | "teens")[];
|
|
133
|
+
categories: ("face" | "lip" | "face-lips" | "body" | "hair")[];
|
|
138
134
|
internalLink: string;
|
|
139
135
|
price: number;
|
|
140
136
|
stockStatus: boolean;
|
package/dist/product.schema.js
CHANGED
|
@@ -41,10 +41,6 @@ export const ProductSchema = z
|
|
|
41
41
|
howToUseTitle: z.string().min(1),
|
|
42
42
|
howToUseDescription: z.string().min(1),
|
|
43
43
|
ingredientsTitle: z.string().min(1),
|
|
44
|
-
/**
|
|
45
|
-
* Each ingredient item:
|
|
46
|
-
* [ingredientName, ingredientDescription]
|
|
47
|
-
*/
|
|
48
44
|
ingredients: z.array(z.tuple([z.string(), z.string()])).min(1),
|
|
49
45
|
/* =========================
|
|
50
46
|
System fields
|
|
@@ -55,10 +51,6 @@ export const ProductSchema = z
|
|
|
55
51
|
updatedAt: z.number(),
|
|
56
52
|
})
|
|
57
53
|
.superRefine((data, ctx) => {
|
|
58
|
-
/**
|
|
59
|
-
* Enforce stock logic:
|
|
60
|
-
* If stockStatus is false, stockVolume must be 0
|
|
61
|
-
*/
|
|
62
54
|
if (data.stockStatus === false && data.stockVolume !== 0) {
|
|
63
55
|
ctx.addIssue({
|
|
64
56
|
path: ["stockVolume"],
|