@vedhae/cms-schema 3.0.0 → 4.1.0

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
@@ -1,6 +1,8 @@
1
1
  export { ImageAssetSchema } from "./image.schema.js";
2
2
  export { HeroSectionSchema } from "./hero.schema.js";
3
+ export { CardSectionSchema } from "./cardSection.schema.js";
4
+ export { ProductSchema } from "./product.schema.js";
3
5
  export type { ImageAsset } from "./image.schema.js";
4
6
  export type { HeroSection } from "./hero.schema.js";
5
- export { CardSectionSchema } from "./cardSection.schema.js";
6
7
  export type { CardSection } from "./cardSection.schema.js";
8
+ export type { Product } from "./product.schema.js";
package/dist/index.js CHANGED
@@ -2,3 +2,4 @@
2
2
  export { ImageAssetSchema } from "./image.schema.js";
3
3
  export { HeroSectionSchema } from "./hero.schema.js";
4
4
  export { CardSectionSchema } from "./cardSection.schema.js";
5
+ export { ProductSchema } from "./product.schema.js";
@@ -0,0 +1,158 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Product schema
4
+ */
5
+ export declare const ProductSchema: z.ZodEffects<z.ZodObject<{
6
+ id: z.ZodString;
7
+ title: z.ZodString;
8
+ titleDescription: z.ZodString;
9
+ size: z.ZodString;
10
+ users: z.ZodArray<z.ZodString, "many">;
11
+ categories: z.ZodArray<z.ZodString, "many">;
12
+ internalLink: z.ZodString;
13
+ externalLink: z.ZodOptional<z.ZodString>;
14
+ price: z.ZodNumber;
15
+ priceSubText: z.ZodOptional<z.ZodString>;
16
+ stockStatus: z.ZodBoolean;
17
+ stockVolume: z.ZodNumber;
18
+ imageLinks: z.ZodArray<z.ZodObject<{
19
+ url: z.ZodString;
20
+ path: z.ZodString;
21
+ alt: z.ZodString;
22
+ }, "strip", z.ZodTypeAny, {
23
+ url: string;
24
+ path: string;
25
+ alt: string;
26
+ }, {
27
+ url: string;
28
+ path: string;
29
+ alt: string;
30
+ }>, "many">;
31
+ aboutTitle: z.ZodString;
32
+ aboutDescription: z.ZodString;
33
+ howToUseTitle: z.ZodString;
34
+ howToUseDescription: z.ZodString;
35
+ ingredientsTitle: z.ZodString;
36
+ /**
37
+ * Each ingredient item:
38
+ * [ingredientName, ingredientDescription]
39
+ */
40
+ ingredients: z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodString], null>, "many">;
41
+ active: z.ZodBoolean;
42
+ order: z.ZodNumber;
43
+ createdAt: z.ZodNumber;
44
+ updatedAt: z.ZodNumber;
45
+ }, "strip", z.ZodTypeAny, {
46
+ order: number;
47
+ title: string;
48
+ active: boolean;
49
+ id: string;
50
+ titleDescription: string;
51
+ size: string;
52
+ users: string[];
53
+ categories: string[];
54
+ internalLink: string;
55
+ price: number;
56
+ stockStatus: boolean;
57
+ stockVolume: number;
58
+ imageLinks: {
59
+ url: string;
60
+ path: string;
61
+ alt: string;
62
+ }[];
63
+ aboutTitle: string;
64
+ aboutDescription: string;
65
+ howToUseTitle: string;
66
+ howToUseDescription: string;
67
+ ingredientsTitle: string;
68
+ ingredients: [string, string][];
69
+ createdAt: number;
70
+ updatedAt: number;
71
+ externalLink?: string | undefined;
72
+ priceSubText?: string | undefined;
73
+ }, {
74
+ order: number;
75
+ title: string;
76
+ active: boolean;
77
+ id: string;
78
+ titleDescription: string;
79
+ size: string;
80
+ users: string[];
81
+ categories: string[];
82
+ internalLink: string;
83
+ price: number;
84
+ stockStatus: boolean;
85
+ stockVolume: number;
86
+ imageLinks: {
87
+ url: string;
88
+ path: string;
89
+ alt: string;
90
+ }[];
91
+ aboutTitle: string;
92
+ aboutDescription: string;
93
+ howToUseTitle: string;
94
+ howToUseDescription: string;
95
+ ingredientsTitle: string;
96
+ ingredients: [string, string][];
97
+ createdAt: number;
98
+ updatedAt: number;
99
+ externalLink?: string | undefined;
100
+ priceSubText?: string | undefined;
101
+ }>, {
102
+ order: number;
103
+ title: string;
104
+ active: boolean;
105
+ id: string;
106
+ titleDescription: string;
107
+ size: string;
108
+ users: string[];
109
+ categories: string[];
110
+ internalLink: string;
111
+ price: number;
112
+ stockStatus: boolean;
113
+ stockVolume: number;
114
+ imageLinks: {
115
+ url: string;
116
+ path: string;
117
+ alt: string;
118
+ }[];
119
+ aboutTitle: string;
120
+ aboutDescription: string;
121
+ howToUseTitle: string;
122
+ howToUseDescription: string;
123
+ ingredientsTitle: string;
124
+ ingredients: [string, string][];
125
+ createdAt: number;
126
+ updatedAt: number;
127
+ externalLink?: string | undefined;
128
+ priceSubText?: string | undefined;
129
+ }, {
130
+ order: number;
131
+ title: string;
132
+ active: boolean;
133
+ id: string;
134
+ titleDescription: string;
135
+ size: string;
136
+ users: string[];
137
+ categories: string[];
138
+ internalLink: string;
139
+ price: number;
140
+ stockStatus: boolean;
141
+ stockVolume: number;
142
+ imageLinks: {
143
+ url: string;
144
+ path: string;
145
+ alt: string;
146
+ }[];
147
+ aboutTitle: string;
148
+ aboutDescription: string;
149
+ howToUseTitle: string;
150
+ howToUseDescription: string;
151
+ ingredientsTitle: string;
152
+ ingredients: [string, string][];
153
+ createdAt: number;
154
+ updatedAt: number;
155
+ externalLink?: string | undefined;
156
+ priceSubText?: string | undefined;
157
+ }>;
158
+ export type Product = z.infer<typeof ProductSchema>;
@@ -0,0 +1,69 @@
1
+ import { z } from "zod";
2
+ import { ImageAssetSchema } from "./image.schema.js";
3
+ /**
4
+ * Product schema
5
+ */
6
+ export const ProductSchema = z
7
+ .object({
8
+ /* =========================
9
+ Core identity
10
+ ========================= */
11
+ id: z.string(),
12
+ title: z.string().min(1),
13
+ titleDescription: z.string().min(1),
14
+ size: z.string().min(1),
15
+ /* =========================
16
+ Audience & classification
17
+ ========================= */
18
+ users: z.array(z.string()).min(1),
19
+ categories: z.array(z.string()).min(1),
20
+ /* =========================
21
+ Navigation
22
+ ========================= */
23
+ internalLink: z.string().startsWith("/"),
24
+ externalLink: z.string().url().optional(),
25
+ /* =========================
26
+ Pricing & availability
27
+ ========================= */
28
+ price: z.number().nonnegative(),
29
+ priceSubText: z.string().optional(),
30
+ stockStatus: z.boolean(),
31
+ stockVolume: z.number().int().nonnegative(),
32
+ /* =========================
33
+ Media
34
+ ========================= */
35
+ imageLinks: z.array(ImageAssetSchema).min(1),
36
+ /* =========================
37
+ Content sections
38
+ ========================= */
39
+ aboutTitle: z.string().min(1),
40
+ aboutDescription: z.string().min(1),
41
+ howToUseTitle: z.string().min(1),
42
+ howToUseDescription: z.string().min(1),
43
+ ingredientsTitle: z.string().min(1),
44
+ /**
45
+ * Each ingredient item:
46
+ * [ingredientName, ingredientDescription]
47
+ */
48
+ ingredients: z.array(z.tuple([z.string(), z.string()])).min(1),
49
+ /* =========================
50
+ System fields
51
+ ========================= */
52
+ active: z.boolean(),
53
+ order: z.number(),
54
+ createdAt: z.number(),
55
+ updatedAt: z.number(),
56
+ })
57
+ .superRefine((data, ctx) => {
58
+ /**
59
+ * Enforce stock logic:
60
+ * If stockStatus is false, stockVolume must be 0
61
+ */
62
+ if (data.stockStatus === false && data.stockVolume !== 0) {
63
+ ctx.addIssue({
64
+ path: ["stockVolume"],
65
+ message: "stockVolume must be 0 when stockStatus is false",
66
+ code: z.ZodIssueCode.custom,
67
+ });
68
+ }
69
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vedhae/cms-schema",
3
- "version": "3.0.0",
3
+ "version": "4.1.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",