@commercelayer/demo-store-types 1.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.
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rawDataPages_schema = void 0;
4
+ const zod_1 = require("zod");
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({
48
+ title: zod_1.z.string().optional(),
49
+ description: zod_1.z.string().optional(),
50
+ components: zod_1.z.discriminatedUnion('type', [
51
+ carousel_schema,
52
+ grid_schema,
53
+ hero_schema,
54
+ productGrid_schema,
55
+ markdown_schema,
56
+ ]).array()
57
+ })));
58
+ exports.rawDataPages_schema = pages_schema;
@@ -0,0 +1,169 @@
1
+ import { z } from 'zod';
2
+ declare const product_schema: z.ZodObject<{
3
+ productCode: z.ZodString;
4
+ variantCode: z.ZodString;
5
+ 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[];
84
+ }>;
85
+ export declare const rawDataProducts_schema: z.ZodArray<z.ZodObject<{
86
+ productCode: z.ZodString;
87
+ variantCode: z.ZodString;
88
+ 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">>;
127
+ }, "passthrough", z.ZodTypeAny, {
128
+ details?: {
129
+ title: {
130
+ [x: string]: string | undefined;
131
+ };
132
+ content: {
133
+ [x: string]: string | undefined;
134
+ };
135
+ }[] | undefined;
136
+ name: {
137
+ [x: string]: string | undefined;
138
+ };
139
+ description: {
140
+ [x: string]: string | undefined;
141
+ };
142
+ productCode: string;
143
+ variantCode: string;
144
+ sku: string;
145
+ slug: string;
146
+ images: string[];
147
+ }, {
148
+ details?: {
149
+ title: {
150
+ [x: string]: string | undefined;
151
+ };
152
+ content: {
153
+ [x: string]: string | undefined;
154
+ };
155
+ }[] | undefined;
156
+ name: {
157
+ [x: string]: string | undefined;
158
+ };
159
+ description: {
160
+ [x: string]: string | undefined;
161
+ };
162
+ productCode: string;
163
+ variantCode: string;
164
+ sku: string;
165
+ slug: string;
166
+ images: string[];
167
+ }>, "many">;
168
+ export declare type RawDataProduct = z.infer<typeof product_schema>;
169
+ export {};
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rawDataProducts_schema = void 0;
4
+ const zod_1 = require("zod");
5
+ const locale_1 = require("../utils/locale");
6
+ const detail_schema = zod_1.z.object({
7
+ title: (0, locale_1.localizedFieldSchema)(zod_1.z.string()),
8
+ content: (0, locale_1.localizedFieldSchema)(zod_1.z.string())
9
+ });
10
+ const product_schema = zod_1.z.object({
11
+ productCode: zod_1.z.string(),
12
+ variantCode: zod_1.z.string(),
13
+ sku: zod_1.z.string(),
14
+ slug: zod_1.z.string().transform(slug => slug.replace(/^\//, '')),
15
+ name: (0, locale_1.localizedFieldSchema)(zod_1.z.string()),
16
+ description: (0, locale_1.localizedFieldSchema)(zod_1.z.string()),
17
+ images: zod_1.z.string().array(),
18
+ details: detail_schema.array().optional()
19
+ });
20
+ exports.rawDataProducts_schema = product_schema.passthrough().array();
@@ -0,0 +1,35 @@
1
+ import { z } from 'zod';
2
+ declare const taxonomy_schema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ name: z.ZodString;
5
+ 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[];
17
+ }>;
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>;
35
+ export {};
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rawDataTaxonomies_schema = void 0;
4
+ const zod_1 = require("zod");
5
+ const taxonomy_schema = zod_1.z.object({
6
+ id: zod_1.z.string(),
7
+ name: zod_1.z.string(),
8
+ facetKey: zod_1.z.string(),
9
+ taxons: zod_1.z.string().array()
10
+ });
11
+ exports.rawDataTaxonomies_schema = taxonomy_schema.array();
@@ -0,0 +1,85 @@
1
+ import { z } from 'zod';
2
+ declare const taxon_schema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ name: z.ZodString;
5
+ label: z.ZodObject<{}, "strip", z.ZodOptional<z.ZodString>, {
6
+ [x: string]: string | undefined;
7
+ }, {
8
+ [x: string]: string | undefined;
9
+ }>;
10
+ description: z.ZodObject<{}, "strip", z.ZodOptional<z.ZodString>, {
11
+ [x: string]: string | undefined;
12
+ }, {
13
+ [x: string]: string | undefined;
14
+ }>;
15
+ slug: z.ZodEffects<z.ZodString, string, string>;
16
+ references: z.ZodArray<z.ZodString, "many">;
17
+ taxons: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
18
+ }, "strip", z.ZodTypeAny, {
19
+ taxons?: string[] | undefined;
20
+ id: string;
21
+ name: string;
22
+ description: {
23
+ [x: string]: string | undefined;
24
+ };
25
+ slug: string;
26
+ label: {
27
+ [x: string]: string | undefined;
28
+ };
29
+ references: string[];
30
+ }, {
31
+ taxons?: string[] | undefined;
32
+ id: string;
33
+ name: string;
34
+ description: {
35
+ [x: string]: string | undefined;
36
+ };
37
+ slug: string;
38
+ label: {
39
+ [x: string]: string | undefined;
40
+ };
41
+ references: string[];
42
+ }>;
43
+ export declare const rawDataTaxons_schema: z.ZodArray<z.ZodObject<{
44
+ id: z.ZodString;
45
+ name: z.ZodString;
46
+ label: z.ZodObject<{}, "strip", z.ZodOptional<z.ZodString>, {
47
+ [x: string]: string | undefined;
48
+ }, {
49
+ [x: string]: string | undefined;
50
+ }>;
51
+ description: z.ZodObject<{}, "strip", z.ZodOptional<z.ZodString>, {
52
+ [x: string]: string | undefined;
53
+ }, {
54
+ [x: string]: string | undefined;
55
+ }>;
56
+ slug: z.ZodEffects<z.ZodString, string, string>;
57
+ references: z.ZodArray<z.ZodString, "many">;
58
+ taxons: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
59
+ }, "strip", z.ZodTypeAny, {
60
+ taxons?: string[] | undefined;
61
+ id: string;
62
+ name: string;
63
+ description: {
64
+ [x: string]: string | undefined;
65
+ };
66
+ slug: string;
67
+ label: {
68
+ [x: string]: string | undefined;
69
+ };
70
+ references: string[];
71
+ }, {
72
+ taxons?: string[] | undefined;
73
+ id: string;
74
+ name: string;
75
+ description: {
76
+ [x: string]: string | undefined;
77
+ };
78
+ slug: string;
79
+ label: {
80
+ [x: string]: string | undefined;
81
+ };
82
+ references: string[];
83
+ }>, "many">;
84
+ export declare type RawDataTaxon = z.infer<typeof taxon_schema>;
85
+ export {};
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rawDataTaxons_schema = void 0;
4
+ const zod_1 = require("zod");
5
+ const locale_1 = require("../utils/locale");
6
+ const taxon_schema = zod_1.z.object({
7
+ id: zod_1.z.string(),
8
+ name: zod_1.z.string(),
9
+ label: (0, locale_1.localizedFieldSchema)(zod_1.z.string()),
10
+ description: (0, locale_1.localizedFieldSchema)(zod_1.z.string()),
11
+ slug: zod_1.z.string().transform(slug => slug.replace(/^\//, '')),
12
+ references: zod_1.z.string().array(),
13
+ taxons: zod_1.z.string().array().optional()
14
+ });
15
+ exports.rawDataTaxons_schema = taxon_schema.array();
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ export declare const localizedFieldSchema: <T extends z.ZodTypeAny>(type: T) => z.ZodObject<{}, "strip", z.ZodOptional<T>, {
3
+ [x: string]: T["_output"] | undefined;
4
+ }, {
5
+ [x: string]: T["_input"] | undefined;
6
+ }>;
7
+ export declare type LocalizedField<T> = {
8
+ [localeCode: string]: T | undefined;
9
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.localizedFieldSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const localizedFieldSchema = (type) => zod_1.z
6
+ .object({})
7
+ .catchall(type.optional());
8
+ exports.localizedFieldSchema = localizedFieldSchema;
@@ -0,0 +1,11 @@
1
+ export declare type SortValue = string | boolean | number;
2
+ export declare type SortingRule = {
3
+ /**
4
+ * RegExp to match the value.
5
+ */
6
+ pattern: RegExp;
7
+ /**
8
+ * Sorting algorithm to apply.
9
+ */
10
+ sort?: <T extends SortValue>(values: T[]) => T[];
11
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@commercelayer/demo-store-types",
3
+ "version": "1.0.0",
4
+ "description": "Demo Store types",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "dependencies": {
11
+ "zod": "^3.18.0"
12
+ },
13
+ "devDependencies": {
14
+ "typescript": "^4.7.4"
15
+ },
16
+ "scripts": {
17
+ "ts:check": "tsc --noEmit",
18
+ "build": "tsc"
19
+ },
20
+ "license": "MIT",
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "gitHead": "daa49911f414b7a635544e5dd117d386ee19ea8b"
25
+ }