@vedhae/cms-schema 2.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.
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- export declare const ShopByCategoryItemSchema: z.ZodObject<{
2
+ export declare const CardItemSchema: z.ZodObject<{
3
3
  name: z.ZodString;
4
4
  link: z.ZodString;
5
5
  order: z.ZodNumber;
@@ -17,30 +17,31 @@ export declare const ShopByCategoryItemSchema: z.ZodObject<{
17
17
  alt: string;
18
18
  }>;
19
19
  }, "strip", z.ZodTypeAny, {
20
+ name: string;
21
+ link: string;
22
+ order: number;
20
23
  image: {
21
24
  url: string;
22
25
  path: string;
23
26
  alt: string;
24
27
  };
28
+ }, {
25
29
  name: string;
26
30
  link: string;
27
31
  order: number;
28
- }, {
29
32
  image: {
30
33
  url: string;
31
34
  path: string;
32
35
  alt: string;
33
36
  };
34
- name: string;
35
- link: string;
36
- order: number;
37
37
  }>;
38
- export declare const ShopByCategorySchema: z.ZodObject<{
38
+ export declare const CardSectionSchema: z.ZodObject<{
39
39
  page: z.ZodLiteral<"home">;
40
- section: z.ZodLiteral<"shopByCategory">;
41
- active: z.ZodBoolean;
40
+ section: z.ZodEnum<["one", "two"]>;
42
41
  title: z.ZodString;
43
- categories: z.ZodArray<z.ZodObject<{
42
+ order: z.ZodNumber;
43
+ active: z.ZodBoolean;
44
+ items: z.ZodArray<z.ZodObject<{
44
45
  name: z.ZodString;
45
46
  link: z.ZodString;
46
47
  order: z.ZodNumber;
@@ -58,53 +59,55 @@ export declare const ShopByCategorySchema: z.ZodObject<{
58
59
  alt: string;
59
60
  }>;
60
61
  }, "strip", z.ZodTypeAny, {
62
+ name: string;
63
+ link: string;
64
+ order: number;
61
65
  image: {
62
66
  url: string;
63
67
  path: string;
64
68
  alt: string;
65
69
  };
70
+ }, {
66
71
  name: string;
67
72
  link: string;
68
73
  order: number;
69
- }, {
70
74
  image: {
71
75
  url: string;
72
76
  path: string;
73
77
  alt: string;
74
78
  };
75
- name: string;
76
- link: string;
77
- order: number;
78
79
  }>, "many">;
79
80
  }, "strip", z.ZodTypeAny, {
81
+ order: number;
80
82
  page: "home";
81
- section: "shopByCategory";
82
- active: boolean;
83
+ section: "one" | "two";
83
84
  title: string;
84
- categories: {
85
+ active: boolean;
86
+ items: {
87
+ name: string;
88
+ link: string;
89
+ order: number;
85
90
  image: {
86
91
  url: string;
87
92
  path: string;
88
93
  alt: string;
89
94
  };
90
- name: string;
91
- link: string;
92
- order: number;
93
95
  }[];
94
96
  }, {
97
+ order: number;
95
98
  page: "home";
96
- section: "shopByCategory";
97
- active: boolean;
99
+ section: "one" | "two";
98
100
  title: string;
99
- categories: {
101
+ active: boolean;
102
+ items: {
103
+ name: string;
104
+ link: string;
105
+ order: number;
100
106
  image: {
101
107
  url: string;
102
108
  path: string;
103
109
  alt: string;
104
110
  };
105
- name: string;
106
- link: string;
107
- order: number;
108
111
  }[];
109
112
  }>;
110
- export type ShopByCategorySection = z.infer<typeof ShopByCategorySchema>;
113
+ export type CardSection = z.infer<typeof CardSectionSchema>;
@@ -0,0 +1,16 @@
1
+ import { z } from "zod";
2
+ import { ImageAssetSchema } from "./image.schema.js";
3
+ export const CardItemSchema = z.object({
4
+ name: z.string(),
5
+ link: z.string(),
6
+ order: z.number(),
7
+ image: ImageAssetSchema,
8
+ });
9
+ export const CardSectionSchema = z.object({
10
+ page: z.literal("home"),
11
+ section: z.enum(["one", "two"]),
12
+ title: z.string(),
13
+ order: z.number(),
14
+ active: z.boolean(),
15
+ items: z.array(CardItemSchema),
16
+ });
@@ -24,30 +24,30 @@ export declare const HeroSectionSchema: z.ZodObject<{
24
24
  }, "strip", z.ZodTypeAny, {
25
25
  page: "home";
26
26
  section: "hero";
27
+ title: string;
27
28
  active: boolean;
28
29
  tagline: string;
29
- title: string;
30
30
  ctaText: string;
31
31
  ctaLink: string;
32
- description?: string | undefined;
33
32
  image?: {
34
33
  url: string;
35
34
  path: string;
36
35
  alt: string;
37
36
  } | undefined;
37
+ description?: string | undefined;
38
38
  }, {
39
39
  page: "home";
40
40
  section: "hero";
41
+ title: string;
41
42
  active: boolean;
42
43
  tagline: string;
43
- title: string;
44
44
  ctaText: string;
45
45
  ctaLink: string;
46
- description?: string | undefined;
47
46
  image?: {
48
47
  url: string;
49
48
  path: string;
50
49
  alt: string;
51
50
  } | undefined;
51
+ description?: string | undefined;
52
52
  }>;
53
53
  export type HeroSection = z.infer<typeof HeroSectionSchema>;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export { ImageAssetSchema } from "./image.schema.js";
2
2
  export { HeroSectionSchema } from "./hero.schema.js";
3
- export { ShopByCategorySchema } from "./shopByCategory.schema.js";
4
- export { ShopByPersonSchema } from "./shopByPerson.schema.js";
3
+ export { CardSectionSchema } from "./cardSection.schema.js";
4
+ export { ProductSchema } from "./product.schema.js";
5
5
  export type { ImageAsset } from "./image.schema.js";
6
6
  export type { HeroSection } from "./hero.schema.js";
7
- export type { ShopByCategorySection } from "./shopByCategory.schema.js";
8
- export type { ShopByPersonSection } from "./shopByPerson.schema.js";
7
+ export type { CardSection } from "./cardSection.schema.js";
8
+ export type { Product } from "./product.schema.js";
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
+ // schemas
1
2
  export { ImageAssetSchema } from "./image.schema.js";
2
3
  export { HeroSectionSchema } from "./hero.schema.js";
3
- export { ShopByCategorySchema } from "./shopByCategory.schema.js";
4
- export { ShopByPersonSchema } from "./shopByPerson.schema.js";
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": "2.0.0",
3
+ "version": "4.0.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,15 +0,0 @@
1
- import { z } from "zod";
2
- import { ImageAssetSchema } from "./image.schema.js";
3
- export const ShopByCategoryItemSchema = z.object({
4
- name: z.string().min(1),
5
- link: z.string().min(1),
6
- order: z.number().int(),
7
- image: ImageAssetSchema,
8
- });
9
- export const ShopByCategorySchema = z.object({
10
- page: z.literal("home"),
11
- section: z.literal("shopByCategory"),
12
- active: z.boolean(),
13
- title: z.string().min(1),
14
- categories: z.array(ShopByCategoryItemSchema),
15
- });
@@ -1,110 +0,0 @@
1
- import { z } from "zod";
2
- export declare const ShopByPersonItemSchema: z.ZodObject<{
3
- label: z.ZodString;
4
- link: z.ZodString;
5
- order: z.ZodNumber;
6
- image: z.ZodObject<{
7
- url: z.ZodString;
8
- path: z.ZodString;
9
- alt: z.ZodString;
10
- }, "strip", z.ZodTypeAny, {
11
- url: string;
12
- path: string;
13
- alt: string;
14
- }, {
15
- url: string;
16
- path: string;
17
- alt: string;
18
- }>;
19
- }, "strip", z.ZodTypeAny, {
20
- image: {
21
- url: string;
22
- path: string;
23
- alt: string;
24
- };
25
- link: string;
26
- order: number;
27
- label: string;
28
- }, {
29
- image: {
30
- url: string;
31
- path: string;
32
- alt: string;
33
- };
34
- link: string;
35
- order: number;
36
- label: string;
37
- }>;
38
- export declare const ShopByPersonSchema: z.ZodObject<{
39
- page: z.ZodLiteral<"home">;
40
- section: z.ZodLiteral<"shopByPerson">;
41
- active: z.ZodBoolean;
42
- title: z.ZodString;
43
- cards: z.ZodArray<z.ZodObject<{
44
- label: z.ZodString;
45
- link: z.ZodString;
46
- order: z.ZodNumber;
47
- image: z.ZodObject<{
48
- url: z.ZodString;
49
- path: z.ZodString;
50
- alt: z.ZodString;
51
- }, "strip", z.ZodTypeAny, {
52
- url: string;
53
- path: string;
54
- alt: string;
55
- }, {
56
- url: string;
57
- path: string;
58
- alt: string;
59
- }>;
60
- }, "strip", z.ZodTypeAny, {
61
- image: {
62
- url: string;
63
- path: string;
64
- alt: string;
65
- };
66
- link: string;
67
- order: number;
68
- label: string;
69
- }, {
70
- image: {
71
- url: string;
72
- path: string;
73
- alt: string;
74
- };
75
- link: string;
76
- order: number;
77
- label: string;
78
- }>, "many">;
79
- }, "strip", z.ZodTypeAny, {
80
- page: "home";
81
- section: "shopByPerson";
82
- active: boolean;
83
- title: string;
84
- cards: {
85
- image: {
86
- url: string;
87
- path: string;
88
- alt: string;
89
- };
90
- link: string;
91
- order: number;
92
- label: string;
93
- }[];
94
- }, {
95
- page: "home";
96
- section: "shopByPerson";
97
- active: boolean;
98
- title: string;
99
- cards: {
100
- image: {
101
- url: string;
102
- path: string;
103
- alt: string;
104
- };
105
- link: string;
106
- order: number;
107
- label: string;
108
- }[];
109
- }>;
110
- export type ShopByPersonSection = z.infer<typeof ShopByPersonSchema>;
@@ -1,15 +0,0 @@
1
- import { z } from "zod";
2
- import { ImageAssetSchema } from "./image.schema.js";
3
- export const ShopByPersonItemSchema = z.object({
4
- label: z.string().min(1),
5
- link: z.string().min(1),
6
- order: z.number().int(),
7
- image: ImageAssetSchema,
8
- });
9
- export const ShopByPersonSchema = z.object({
10
- page: z.literal("home"),
11
- section: z.literal("shopByPerson"),
12
- active: z.boolean(),
13
- title: z.string().min(1),
14
- cards: z.array(ShopByPersonItemSchema),
15
- });