@commercelayer/demo-store-types 1.0.0 → 1.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.
Files changed (38) hide show
  1. package/README.md +105 -21
  2. package/dist/config/facets.config.d.ts +8 -8
  3. package/dist/config/general.config.d.ts +1 -1
  4. package/dist/config/variants.config.d.ts +5 -5
  5. package/dist/json/catalogs.d.ts +34 -24
  6. package/dist/json/catalogs.js +2 -2
  7. package/dist/json/countries.d.ts +44 -38
  8. package/dist/json/countries.js +2 -2
  9. package/dist/json/languages.d.ts +23 -23
  10. package/dist/json/languages.js +2 -2
  11. package/dist/json/organization.d.ts +45 -33
  12. package/dist/json/organization.js +1 -2
  13. package/dist/json/page-components/carousel.d.ts +19 -0
  14. package/dist/json/page-components/carousel.js +10 -0
  15. package/dist/json/page-components/grid.d.ts +17 -0
  16. package/dist/json/page-components/grid.js +10 -0
  17. package/dist/json/page-components/hero.d.ts +33 -0
  18. package/dist/json/page-components/hero.js +13 -0
  19. package/dist/json/page-components/image.d.ts +12 -0
  20. package/dist/json/page-components/image.js +8 -0
  21. package/dist/json/page-components/item.d.ts +31 -0
  22. package/dist/json/page-components/item.js +12 -0
  23. package/dist/json/page-components/markdown.d.ts +18 -0
  24. package/dist/json/page-components/markdown.js +20 -0
  25. package/dist/json/page-components/product-grid.d.ts +20 -0
  26. package/dist/json/page-components/product-grid.js +10 -0
  27. package/dist/json/pages.d.ts +120 -1195
  28. package/dist/json/pages.js +17 -50
  29. package/dist/json/products.d.ts +194 -126
  30. package/dist/json/products.js +8 -2
  31. package/dist/json/taxonomies.d.ts +38 -29
  32. package/dist/json/taxonomies.js +2 -2
  33. package/dist/json/taxons.d.ts +65 -80
  34. package/dist/json/taxons.js +2 -2
  35. package/dist/utils/locale.d.ts +11 -5
  36. package/dist/utils/locale.js +6 -1
  37. package/dist/utils/sort.d.ts +2 -2
  38. package/package.json +4 -4
@@ -1,58 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rawDataPages_schema = void 0;
3
+ exports.rawDataPages_schema = exports.rawDataPage_schema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const locale_1 = require("../utils/locale");
6
- const image_schema = zod_1.z.object({
7
- src: zod_1.z.string(),
8
- alt: zod_1.z.string()
9
- });
10
- const slide_schema = zod_1.z.object({
11
- image: image_schema,
12
- title: zod_1.z.string(),
13
- description: zod_1.z.string(),
14
- linkLabel: zod_1.z.string(),
15
- linkHref: zod_1.z.string()
16
- });
17
- const carousel_schema = zod_1.z.object({
18
- type: zod_1.z.literal('carousel'),
19
- id: zod_1.z.string(),
20
- slides: slide_schema.array()
21
- });
22
- const hero_schema = zod_1.z.object({
23
- type: zod_1.z.literal('hero'),
24
- id: zod_1.z.string(),
25
- image: image_schema,
26
- title: zod_1.z.string(),
27
- description: zod_1.z.string().optional(),
28
- href: zod_1.z.string()
29
- });
30
- const productGrid_schema = zod_1.z.object({
31
- type: zod_1.z.literal('product-grid'),
32
- id: zod_1.z.string(),
33
- title: zod_1.z.string(),
34
- skus: zod_1.z.string().array()
35
- });
36
- const grid_schema = zod_1.z.object({
37
- type: zod_1.z.literal('grid'),
38
- id: zod_1.z.string(),
39
- items: slide_schema.array()
40
- });
41
- const markdown_schema = zod_1.z.object({
42
- type: zod_1.z.literal('markdown'),
43
- id: zod_1.z.string(),
44
- content: zod_1.z.string()
45
- });
46
- const pages_schema = zod_1.z.object({})
47
- .catchall((0, locale_1.localizedFieldSchema)(zod_1.z.object({
6
+ const carousel_1 = require("./page-components/carousel");
7
+ const grid_1 = require("./page-components/grid");
8
+ const hero_1 = require("./page-components/hero");
9
+ const markdown_1 = require("./page-components/markdown");
10
+ const product_grid_1 = require("./page-components/product-grid");
11
+ exports.rawDataPage_schema = zod_1.z.object({
48
12
  title: zod_1.z.string().optional(),
49
13
  description: zod_1.z.string().optional(),
50
14
  components: zod_1.z.discriminatedUnion('type', [
51
- carousel_schema,
52
- grid_schema,
53
- hero_schema,
54
- productGrid_schema,
55
- markdown_schema,
15
+ carousel_1.carousel_schema,
16
+ grid_1.grid_schema,
17
+ hero_1.hero_schema,
18
+ product_grid_1.productGrid_schema,
19
+ markdown_1.markdown_schema,
56
20
  ]).array()
57
- })));
58
- exports.rawDataPages_schema = pages_schema;
21
+ });
22
+ const rawDataLocalizedPage_schema = (0, locale_1.localizedFieldSchema)(exports.rawDataPage_schema);
23
+ exports.rawDataPages_schema = zod_1.z
24
+ .object({})
25
+ .catchall(rawDataLocalizedPage_schema);
@@ -1,143 +1,204 @@
1
1
  import { z } from 'zod';
2
- declare const product_schema: z.ZodObject<{
2
+ import { LocalizedFieldSchema } from '../utils/locale';
3
+ type DetailSchema = z.ZodObject<{
4
+ /**
5
+ * Accordion title
6
+ */
7
+ title: LocalizedFieldSchema<z.ZodString>;
8
+ /**
9
+ * Accordion content
10
+ */
11
+ content: LocalizedFieldSchema<z.ZodString>;
12
+ }>;
13
+ type RawDataProductSchema = z.ZodObject<{
14
+ /**
15
+ * The **product code** identifies the base product
16
+ *
17
+ * A master product or base product is a non-sellable product that represents a group of similar or related products.
18
+ *
19
+ * For example, a clothing retailer may have a master product for each type of clothing item, such as "men's t-shirts" or "women's dresses".
20
+ * Each of these master products would contain multiple variations, such as different sizes, colors, and styles.
21
+ */
3
22
  productCode: z.ZodString;
23
+ /**
24
+ * The **variant code** identifies a variation product
25
+ *
26
+ * A variation product is a product that is part of a group of similar or related products,
27
+ * and it is identified by specific attributes or characteristics that distinguish it from the other products in the group (color, material, size, etc.).
28
+ *
29
+ * The `variantCode`, in Demo Store, is used for grouping similar products in the listing page.
30
+ * Usually a different `variantCode` corresponds to a different product image.
31
+ */
4
32
  variantCode: z.ZodString;
33
+ /**
34
+ * The **sku** is a **unique identifier**, meaning *Stock Keeping Unit*.
35
+ *
36
+ * This is the stock unit in a warehouse used to track availability and stock variations of an item to be sold.
37
+ * SKUs can be a variant of any item (e.g., Medium or Large size of a jogger pant).
38
+ *
39
+ * An SKU usually consists of letters and numbers (either EAN code, UPC, or any other code format) like "LSLEEVMM000000FFFFFFMXXX".
40
+ * SKU refers to an item's details, including variants data (e.g., a T-shirt, Red color, Nike brand, 0.5g, XL size).
41
+ * An SKU identifies each product item's characteristics such as manufacturer name, brand name, style, color, weight, and size.
42
+ */
5
43
  sku: z.ZodString;
6
- slug: z.ZodEffects<z.ZodString, string, string>;
7
- name: z.ZodObject<{}, "strip", z.ZodOptional<z.ZodString>, {
8
- [x: string]: string | undefined;
9
- }, {
10
- [x: string]: string | undefined;
11
- }>;
12
- description: z.ZodObject<{}, "strip", z.ZodOptional<z.ZodString>, {
13
- [x: string]: string | undefined;
14
- }, {
15
- [x: string]: string | undefined;
16
- }>;
17
- images: z.ZodArray<z.ZodString, "many">;
18
- details: z.ZodOptional<z.ZodArray<z.ZodObject<{
19
- title: z.ZodObject<{}, "strip", z.ZodOptional<z.ZodString>, {
20
- [x: string]: string | undefined;
21
- }, {
22
- [x: string]: string | undefined;
23
- }>;
24
- content: z.ZodObject<{}, "strip", z.ZodOptional<z.ZodString>, {
25
- [x: string]: string | undefined;
26
- }, {
27
- [x: string]: string | undefined;
28
- }>;
29
- }, "strip", z.ZodTypeAny, {
30
- title: {
31
- [x: string]: string | undefined;
32
- };
33
- content: {
34
- [x: string]: string | undefined;
35
- };
36
- }, {
37
- title: {
38
- [x: string]: string | undefined;
39
- };
40
- content: {
41
- [x: string]: string | undefined;
42
- };
43
- }>, "many">>;
44
- }, "strip", z.ZodTypeAny, {
45
- details?: {
46
- title: {
47
- [x: string]: string | undefined;
48
- };
49
- content: {
50
- [x: string]: string | undefined;
51
- };
52
- }[] | undefined;
53
- name: {
54
- [x: string]: string | undefined;
55
- };
56
- description: {
57
- [x: string]: string | undefined;
58
- };
59
- productCode: string;
60
- variantCode: string;
61
- sku: string;
62
- slug: string;
63
- images: string[];
64
- }, {
65
- details?: {
66
- title: {
67
- [x: string]: string | undefined;
68
- };
69
- content: {
70
- [x: string]: string | undefined;
71
- };
72
- }[] | undefined;
73
- name: {
74
- [x: string]: string | undefined;
75
- };
76
- description: {
77
- [x: string]: string | undefined;
78
- };
79
- productCode: string;
80
- variantCode: string;
81
- sku: string;
82
- slug: string;
83
- images: string[];
44
+ /**
45
+ * The product URL slug
46
+ *
47
+ * The slug is the part of a URL that identifies a particular page on a website in an easy-to-read form.
48
+ *
49
+ * It should always start with a forward slash (`/`).
50
+ * @example "/white-apron-with-black-logo/APRONXXXFFFFFF000000XXXX"
51
+ */
52
+ slug: z.ZodEffects<z.ZodString>;
53
+ /**
54
+ * The localized product name
55
+ *
56
+ * @example
57
+ * {
58
+ * "it": "Maglietta Grigia",
59
+ * "en-US": "Gray T-Shirt"
60
+ * }
61
+ */
62
+ name: LocalizedFieldSchema<z.ZodString>;
63
+ /**
64
+ * The localized product description
65
+ *
66
+ * @example
67
+ * {
68
+ * "it": "Descrizione"
69
+ * "en-US": "Description",
70
+ * }
71
+ */
72
+ description: LocalizedFieldSchema<z.ZodString>;
73
+ /**
74
+ * A carousel of image URLs that represent the product
75
+ *
76
+ * @example
77
+ * [
78
+ * "https://res.cloudinary.com/commercelayer/image/upload/f_auto,b_white/demo-store/skus/TSHIRTMSB0B0B2000000LXXX_FLAT.png"
79
+ * ]
80
+ */
81
+ images: z.ZodArray<z.ZodString>;
82
+ /**
83
+ * Additional product details
84
+ *
85
+ * This attribute is presented as accordion just below the "Add to cart" button.
86
+ *
87
+ * @example
88
+ * [
89
+ * {
90
+ * "title": {
91
+ * "en": "Details"
92
+ * },
93
+ * "content": {
94
+ * "en": "Content here."
95
+ * }
96
+ * }
97
+ * ]
98
+ */
99
+ details: z.ZodOptional<z.ZodArray<DetailSchema>>;
84
100
  }>;
85
101
  export declare const rawDataProducts_schema: z.ZodArray<z.ZodObject<{
102
+ /**
103
+ * The **product code** identifies the base product
104
+ *
105
+ * A master product or base product is a non-sellable product that represents a group of similar or related products.
106
+ *
107
+ * For example, a clothing retailer may have a master product for each type of clothing item, such as "men's t-shirts" or "women's dresses".
108
+ * Each of these master products would contain multiple variations, such as different sizes, colors, and styles.
109
+ */
86
110
  productCode: z.ZodString;
111
+ /**
112
+ * The **variant code** identifies a variation product
113
+ *
114
+ * A variation product is a product that is part of a group of similar or related products,
115
+ * and it is identified by specific attributes or characteristics that distinguish it from the other products in the group (color, material, size, etc.).
116
+ *
117
+ * The `variantCode`, in Demo Store, is used for grouping similar products in the listing page.
118
+ * Usually a different `variantCode` corresponds to a different product image.
119
+ */
87
120
  variantCode: z.ZodString;
121
+ /**
122
+ * The **sku** is a **unique identifier**, meaning *Stock Keeping Unit*.
123
+ *
124
+ * This is the stock unit in a warehouse used to track availability and stock variations of an item to be sold.
125
+ * SKUs can be a variant of any item (e.g., Medium or Large size of a jogger pant).
126
+ *
127
+ * An SKU usually consists of letters and numbers (either EAN code, UPC, or any other code format) like "LSLEEVMM000000FFFFFFMXXX".
128
+ * SKU refers to an item's details, including variants data (e.g., a T-shirt, Red color, Nike brand, 0.5g, XL size).
129
+ * An SKU identifies each product item's characteristics such as manufacturer name, brand name, style, color, weight, and size.
130
+ */
88
131
  sku: z.ZodString;
89
- slug: z.ZodEffects<z.ZodString, string, string>;
90
- name: z.ZodObject<{}, "strip", z.ZodOptional<z.ZodString>, {
91
- [x: string]: string | undefined;
92
- }, {
93
- [x: string]: string | undefined;
94
- }>;
95
- description: z.ZodObject<{}, "strip", z.ZodOptional<z.ZodString>, {
96
- [x: string]: string | undefined;
97
- }, {
98
- [x: string]: string | undefined;
99
- }>;
100
- images: z.ZodArray<z.ZodString, "many">;
101
- details: z.ZodOptional<z.ZodArray<z.ZodObject<{
102
- title: z.ZodObject<{}, "strip", z.ZodOptional<z.ZodString>, {
103
- [x: string]: string | undefined;
104
- }, {
105
- [x: string]: string | undefined;
106
- }>;
107
- content: z.ZodObject<{}, "strip", z.ZodOptional<z.ZodString>, {
108
- [x: string]: string | undefined;
109
- }, {
110
- [x: string]: string | undefined;
111
- }>;
112
- }, "strip", z.ZodTypeAny, {
113
- title: {
114
- [x: string]: string | undefined;
115
- };
116
- content: {
117
- [x: string]: string | undefined;
118
- };
119
- }, {
120
- title: {
121
- [x: string]: string | undefined;
122
- };
123
- content: {
124
- [x: string]: string | undefined;
125
- };
126
- }>, "many">>;
132
+ /**
133
+ * The product URL slug
134
+ *
135
+ * The slug is the part of a URL that identifies a particular page on a website in an easy-to-read form.
136
+ *
137
+ * It should always start with a forward slash (`/`).
138
+ * @example "/white-apron-with-black-logo/APRONXXXFFFFFF000000XXXX"
139
+ */
140
+ slug: z.ZodEffects<z.ZodString>;
141
+ /**
142
+ * The localized product name
143
+ *
144
+ * @example
145
+ * {
146
+ * "it": "Maglietta Grigia",
147
+ * "en-US": "Gray T-Shirt"
148
+ * }
149
+ */
150
+ name: LocalizedFieldSchema<z.ZodString>;
151
+ /**
152
+ * The localized product description
153
+ *
154
+ * @example
155
+ * {
156
+ * "it": "Descrizione"
157
+ * "en-US": "Description",
158
+ * }
159
+ */
160
+ description: LocalizedFieldSchema<z.ZodString>;
161
+ /**
162
+ * A carousel of image URLs that represent the product
163
+ *
164
+ * @example
165
+ * [
166
+ * "https://res.cloudinary.com/commercelayer/image/upload/f_auto,b_white/demo-store/skus/TSHIRTMSB0B0B2000000LXXX_FLAT.png"
167
+ * ]
168
+ */
169
+ images: z.ZodArray<z.ZodString>;
170
+ /**
171
+ * Additional product details
172
+ *
173
+ * This attribute is presented as accordion just below the "Add to cart" button.
174
+ *
175
+ * @example
176
+ * [
177
+ * {
178
+ * "title": {
179
+ * "en": "Details"
180
+ * },
181
+ * "content": {
182
+ * "en": "Content here."
183
+ * }
184
+ * }
185
+ * ]
186
+ */
187
+ details: z.ZodOptional<z.ZodArray<DetailSchema>>;
127
188
  }, "passthrough", z.ZodTypeAny, {
128
189
  details?: {
129
190
  title: {
130
- [x: string]: string | undefined;
191
+ [localeCode: string]: string;
131
192
  };
132
193
  content: {
133
- [x: string]: string | undefined;
194
+ [localeCode: string]: string;
134
195
  };
135
196
  }[] | undefined;
136
197
  name: {
137
- [x: string]: string | undefined;
198
+ [localeCode: string]: string;
138
199
  };
139
200
  description: {
140
- [x: string]: string | undefined;
201
+ [localeCode: string]: string;
141
202
  };
142
203
  productCode: string;
143
204
  variantCode: string;
@@ -147,17 +208,17 @@ export declare const rawDataProducts_schema: z.ZodArray<z.ZodObject<{
147
208
  }, {
148
209
  details?: {
149
210
  title: {
150
- [x: string]: string | undefined;
211
+ [localeCode: string]: string;
151
212
  };
152
213
  content: {
153
- [x: string]: string | undefined;
214
+ [localeCode: string]: string;
154
215
  };
155
216
  }[] | undefined;
156
217
  name: {
157
- [x: string]: string | undefined;
218
+ [localeCode: string]: string;
158
219
  };
159
220
  description: {
160
- [x: string]: string | undefined;
221
+ [localeCode: string]: string;
161
222
  };
162
223
  productCode: string;
163
224
  variantCode: string;
@@ -165,5 +226,12 @@ export declare const rawDataProducts_schema: z.ZodArray<z.ZodObject<{
165
226
  slug: string;
166
227
  images: string[];
167
228
  }>, "many">;
168
- export declare type RawDataProduct = z.infer<typeof product_schema>;
229
+ /**
230
+ * Product
231
+ *
232
+ * A product that can be purchased since it has a `sku` property.
233
+ *
234
+ * Products need to be assigned to a `taxon` to be visible in the Demo Store.
235
+ */
236
+ export type RawDataProduct = z.infer<RawDataProductSchema>;
169
237
  export {};
@@ -4,10 +4,16 @@ exports.rawDataProducts_schema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const locale_1 = require("../utils/locale");
6
6
  const detail_schema = zod_1.z.object({
7
+ /**
8
+ * Accordion title
9
+ */
7
10
  title: (0, locale_1.localizedFieldSchema)(zod_1.z.string()),
11
+ /**
12
+ * Accordion content
13
+ */
8
14
  content: (0, locale_1.localizedFieldSchema)(zod_1.z.string())
9
15
  });
10
- const product_schema = zod_1.z.object({
16
+ const rawDataProduct_schema = zod_1.z.object({
11
17
  productCode: zod_1.z.string(),
12
18
  variantCode: zod_1.z.string(),
13
19
  sku: zod_1.z.string(),
@@ -17,4 +23,4 @@ const product_schema = zod_1.z.object({
17
23
  images: zod_1.z.string().array(),
18
24
  details: detail_schema.array().optional()
19
25
  });
20
- exports.rawDataProducts_schema = product_schema.passthrough().array();
26
+ exports.rawDataProducts_schema = rawDataProduct_schema.passthrough().array();
@@ -1,35 +1,44 @@
1
1
  import { z } from 'zod';
2
- declare const taxonomy_schema: z.ZodObject<{
2
+ type RawDataTaxonomySchema = z.ZodObject<{
3
+ /**
4
+ * The taxonomy id
5
+ *
6
+ * This attribute is used to manage the relationship with `catalogs`.
7
+ */
3
8
  id: z.ZodString;
9
+ /**
10
+ * The taxonomy name
11
+ *
12
+ * This attribute is used to better identify the taxonomy. **Not used on the website**.
13
+ */
4
14
  name: z.ZodString;
15
+ /**
16
+ * The facet key is used inside the `facets.config.js` to define a facet.
17
+ *
18
+ * When you define a facet field in the `facets.config.js` that corresponds to a `facetKey`, the related taxonomy will be shown in the filter component.
19
+ *
20
+ * ![Taxonomies `gender` and `category` are visible in the filter component](https://user-images.githubusercontent.com/1681269/208090019-96b8b72c-bd2c-4125-a226-372443c87e4c.png|width=400px)
21
+ */
5
22
  facetKey: z.ZodString;
6
- taxons: z.ZodArray<z.ZodString, "many">;
7
- }, "strip", z.ZodTypeAny, {
8
- id: string;
9
- name: string;
10
- facetKey: string;
11
- taxons: string[];
12
- }, {
13
- id: string;
14
- name: string;
15
- facetKey: string;
16
- taxons: string[];
23
+ /**
24
+ * Reference to the `taxons` id
25
+ *
26
+ * Any child branches of a `taxonomy` are called `taxons`. Taxons themselves can have their own branches.
27
+ *
28
+ * ![Taxons - first level](https://user-images.githubusercontent.com/1681269/208094648-d8e8cb24-5a26-47b8-9cef-351a3b44e263.png|width=400px)
29
+ */
30
+ taxons: z.ZodArray<z.ZodString>;
17
31
  }>;
18
- export declare const rawDataTaxonomies_schema: z.ZodArray<z.ZodObject<{
19
- id: z.ZodString;
20
- name: z.ZodString;
21
- facetKey: z.ZodString;
22
- taxons: z.ZodArray<z.ZodString, "many">;
23
- }, "strip", z.ZodTypeAny, {
24
- id: string;
25
- name: string;
26
- facetKey: string;
27
- taxons: string[];
28
- }, {
29
- id: string;
30
- name: string;
31
- facetKey: string;
32
- taxons: string[];
33
- }>, "many">;
34
- export declare type RawDataTaxonomy = z.infer<typeof taxonomy_schema>;
32
+ export declare const rawDataTaxonomies_schema: z.ZodArray<RawDataTaxonomySchema, "many">;
33
+ /**
34
+ * Taxonomy
35
+ *
36
+ * Taxonomies are an approach to managing category trees.
37
+ * The heading of a tree is called `taxonomy`.
38
+ *
39
+ * For example, you can create a taxonomy for managing product categories, or for grouping products by their gender.
40
+ *
41
+ * ![Taxonomies](https://user-images.githubusercontent.com/1681269/208094651-b2942235-4d6d-40fb-8230-da2e79d11231.png|width=400px)
42
+ */
43
+ export type RawDataTaxonomy = z.infer<RawDataTaxonomySchema>;
35
44
  export {};
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.rawDataTaxonomies_schema = void 0;
4
4
  const zod_1 = require("zod");
5
- const taxonomy_schema = zod_1.z.object({
5
+ const rawDataTaxonomy_schema = zod_1.z.object({
6
6
  id: zod_1.z.string(),
7
7
  name: zod_1.z.string(),
8
8
  facetKey: zod_1.z.string(),
9
9
  taxons: zod_1.z.string().array()
10
10
  });
11
- exports.rawDataTaxonomies_schema = taxonomy_schema.array();
11
+ exports.rawDataTaxonomies_schema = rawDataTaxonomy_schema.array();