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