@reactionary/source 0.0.27
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/.editorconfig +13 -0
- package/.github/workflows/pull-request.yml +37 -0
- package/.github/workflows/release.yml +49 -0
- package/.nvmrc +1 -0
- package/.prettierignore +6 -0
- package/.prettierrc +3 -0
- package/.verdaccio/config.yml +28 -0
- package/.vscode/extensions.json +9 -0
- package/README.md +39 -0
- package/core/README.md +11 -0
- package/core/eslint.config.mjs +23 -0
- package/core/package.json +8 -0
- package/core/project.json +33 -0
- package/core/src/cache/caching-strategy.ts +25 -0
- package/core/src/cache/redis-cache.ts +41 -0
- package/core/src/client/client.ts +39 -0
- package/core/src/index.ts +42 -0
- package/core/src/providers/analytics.provider.ts +10 -0
- package/core/src/providers/base.provider.ts +75 -0
- package/core/src/providers/cart.provider.ts +10 -0
- package/core/src/providers/identity.provider.ts +10 -0
- package/core/src/providers/inventory.provider.ts +11 -0
- package/core/src/providers/price.provider.ts +10 -0
- package/core/src/providers/product.provider.ts +11 -0
- package/core/src/providers/search.provider.ts +12 -0
- package/core/src/schemas/capabilities.schema.ts +13 -0
- package/core/src/schemas/models/analytics.model.ts +7 -0
- package/core/src/schemas/models/base.model.ts +19 -0
- package/core/src/schemas/models/cart.model.ts +17 -0
- package/core/src/schemas/models/currency.model.ts +187 -0
- package/core/src/schemas/models/identifiers.model.ts +45 -0
- package/core/src/schemas/models/identity.model.ts +15 -0
- package/core/src/schemas/models/inventory.model.ts +8 -0
- package/core/src/schemas/models/price.model.ts +17 -0
- package/core/src/schemas/models/product.model.ts +28 -0
- package/core/src/schemas/models/search.model.ts +35 -0
- package/core/src/schemas/mutations/analytics.mutation.ts +22 -0
- package/core/src/schemas/mutations/base.mutation.ts +7 -0
- package/core/src/schemas/mutations/cart.mutation.ts +30 -0
- package/core/src/schemas/mutations/identity.mutation.ts +18 -0
- package/core/src/schemas/mutations/inventory.mutation.ts +5 -0
- package/core/src/schemas/mutations/price.mutation.ts +5 -0
- package/core/src/schemas/mutations/product.mutation.ts +6 -0
- package/core/src/schemas/mutations/search.mutation.ts +5 -0
- package/core/src/schemas/queries/analytics.query.ts +5 -0
- package/core/src/schemas/queries/base.query.ts +7 -0
- package/core/src/schemas/queries/cart.query.ts +12 -0
- package/core/src/schemas/queries/identity.query.ts +10 -0
- package/core/src/schemas/queries/inventory.query.ts +9 -0
- package/core/src/schemas/queries/price.query.ts +12 -0
- package/core/src/schemas/queries/product.query.ts +18 -0
- package/core/src/schemas/queries/search.query.ts +12 -0
- package/core/src/schemas/session.schema.ts +9 -0
- package/core/tsconfig.json +23 -0
- package/core/tsconfig.lib.json +23 -0
- package/core/tsconfig.spec.json +28 -0
- package/eslint.config.mjs +46 -0
- package/examples/angular/e2e/example.spec.ts +9 -0
- package/examples/angular/eslint.config.mjs +41 -0
- package/examples/angular/playwright.config.ts +38 -0
- package/examples/angular/project.json +86 -0
- package/examples/angular/public/favicon.ico +0 -0
- package/examples/angular/src/app/app.component.html +6 -0
- package/examples/angular/src/app/app.component.scss +22 -0
- package/examples/angular/src/app/app.component.ts +14 -0
- package/examples/angular/src/app/app.config.ts +16 -0
- package/examples/angular/src/app/app.routes.ts +25 -0
- package/examples/angular/src/app/cart/cart.component.html +4 -0
- package/examples/angular/src/app/cart/cart.component.scss +14 -0
- package/examples/angular/src/app/cart/cart.component.ts +73 -0
- package/examples/angular/src/app/identity/identity.component.html +6 -0
- package/examples/angular/src/app/identity/identity.component.scss +18 -0
- package/examples/angular/src/app/identity/identity.component.ts +49 -0
- package/examples/angular/src/app/product/product.component.html +14 -0
- package/examples/angular/src/app/product/product.component.scss +11 -0
- package/examples/angular/src/app/product/product.component.ts +42 -0
- package/examples/angular/src/app/search/search.component.html +35 -0
- package/examples/angular/src/app/search/search.component.scss +129 -0
- package/examples/angular/src/app/search/search.component.ts +50 -0
- package/examples/angular/src/app/services/product.service.ts +35 -0
- package/examples/angular/src/app/services/search.service.ts +48 -0
- package/examples/angular/src/app/services/trpc.client.ts +27 -0
- package/examples/angular/src/index.html +13 -0
- package/examples/angular/src/main.ts +7 -0
- package/examples/angular/src/styles.scss +17 -0
- package/examples/angular/src/test-setup.ts +6 -0
- package/examples/angular/tsconfig.app.json +10 -0
- package/examples/angular/tsconfig.editor.json +6 -0
- package/examples/angular/tsconfig.json +32 -0
- package/examples/node/README.md +11 -0
- package/examples/node/eslint.config.mjs +22 -0
- package/examples/node/jest.config.ts +10 -0
- package/examples/node/package.json +10 -0
- package/examples/node/project.json +20 -0
- package/examples/node/src/index.ts +2 -0
- package/examples/node/src/initialize-algolia.spec.ts +29 -0
- package/examples/node/src/initialize-commercetools.spec.ts +31 -0
- package/examples/node/src/initialize-extended-providers.spec.ts +38 -0
- package/examples/node/src/initialize-mixed-providers.spec.ts +36 -0
- package/examples/node/src/providers/custom-algolia-product.provider.ts +18 -0
- package/examples/node/src/schemas/custom-product.schema.ts +8 -0
- package/examples/node/tsconfig.json +23 -0
- package/examples/node/tsconfig.lib.json +10 -0
- package/examples/node/tsconfig.spec.json +15 -0
- package/examples/trpc-node/eslint.config.mjs +3 -0
- package/examples/trpc-node/project.json +61 -0
- package/examples/trpc-node/src/assets/.gitkeep +0 -0
- package/examples/trpc-node/src/main.ts +55 -0
- package/examples/trpc-node/src/router-instance.ts +52 -0
- package/examples/trpc-node/tsconfig.app.json +9 -0
- package/examples/trpc-node/tsconfig.json +13 -0
- package/examples/vue/eslint.config.mjs +24 -0
- package/examples/vue/index.html +13 -0
- package/examples/vue/project.json +8 -0
- package/examples/vue/src/app/App.vue +275 -0
- package/examples/vue/src/main.ts +6 -0
- package/examples/vue/src/styles.scss +9 -0
- package/examples/vue/src/vue-shims.d.ts +5 -0
- package/examples/vue/tsconfig.app.json +14 -0
- package/examples/vue/tsconfig.json +20 -0
- package/examples/vue/vite.config.ts +31 -0
- package/jest.config.ts +6 -0
- package/jest.preset.js +3 -0
- package/migrations.json +11 -0
- package/nx.json +130 -0
- package/package.json +118 -0
- package/project.json +14 -0
- package/providers/algolia/README.md +11 -0
- package/providers/algolia/eslint.config.mjs +22 -0
- package/providers/algolia/jest.config.ts +10 -0
- package/providers/algolia/package.json +9 -0
- package/providers/algolia/project.json +33 -0
- package/providers/algolia/src/core/initialize.ts +20 -0
- package/providers/algolia/src/index.ts +7 -0
- package/providers/algolia/src/providers/product.provider.ts +25 -0
- package/providers/algolia/src/providers/search.provider.ts +125 -0
- package/providers/algolia/src/schema/capabilities.schema.ts +10 -0
- package/providers/algolia/src/schema/configuration.schema.ts +9 -0
- package/providers/algolia/src/schema/search.schema.ts +14 -0
- package/providers/algolia/src/test/product.provider.spec.ts +18 -0
- package/providers/algolia/src/test/search.provider.spec.ts +82 -0
- package/providers/algolia/tsconfig.json +23 -0
- package/providers/algolia/tsconfig.lib.json +10 -0
- package/providers/algolia/tsconfig.spec.json +15 -0
- package/providers/commercetools/README.md +11 -0
- package/providers/commercetools/eslint.config.mjs +22 -0
- package/providers/commercetools/jest.config.ts +10 -0
- package/providers/commercetools/package.json +10 -0
- package/providers/commercetools/project.json +33 -0
- package/providers/commercetools/src/core/client.ts +152 -0
- package/providers/commercetools/src/core/initialize.ts +40 -0
- package/providers/commercetools/src/index.ts +12 -0
- package/providers/commercetools/src/providers/cart.provider.ts +223 -0
- package/providers/commercetools/src/providers/identity.provider.ts +130 -0
- package/providers/commercetools/src/providers/inventory.provider.ts +82 -0
- package/providers/commercetools/src/providers/price.provider.ts +66 -0
- package/providers/commercetools/src/providers/product.provider.ts +90 -0
- package/providers/commercetools/src/providers/search.provider.ts +86 -0
- package/providers/commercetools/src/schema/capabilities.schema.ts +13 -0
- package/providers/commercetools/src/schema/configuration.schema.ts +11 -0
- package/providers/commercetools/src/test/product.provider.spec.ts +20 -0
- package/providers/commercetools/src/test/search.provider.spec.ts +18 -0
- package/providers/commercetools/tsconfig.json +23 -0
- package/providers/commercetools/tsconfig.lib.json +10 -0
- package/providers/commercetools/tsconfig.spec.json +15 -0
- package/providers/fake/README.md +7 -0
- package/providers/fake/eslint.config.mjs +22 -0
- package/providers/fake/package.json +9 -0
- package/providers/fake/project.json +33 -0
- package/providers/fake/src/core/initialize.ts +24 -0
- package/providers/fake/src/index.ts +8 -0
- package/providers/fake/src/providers/identity.provider.ts +91 -0
- package/providers/fake/src/providers/product.provider.ts +73 -0
- package/providers/fake/src/providers/search.provider.ts +142 -0
- package/providers/fake/src/schema/capabilities.schema.ts +10 -0
- package/providers/fake/src/schema/configuration.schema.ts +15 -0
- package/providers/fake/src/utilities/jitter.ts +14 -0
- package/providers/fake/tsconfig.json +20 -0
- package/providers/fake/tsconfig.lib.json +9 -0
- package/providers/posthog/README.md +7 -0
- package/providers/posthog/eslint.config.mjs +22 -0
- package/providers/posthog/package.json +11 -0
- package/providers/posthog/project.json +33 -0
- package/providers/posthog/src/core/initialize.ts +9 -0
- package/providers/posthog/src/index.ts +4 -0
- package/providers/posthog/src/schema/capabilities.schema.ts +8 -0
- package/providers/posthog/src/schema/configuration.schema.ts +8 -0
- package/providers/posthog/tsconfig.json +20 -0
- package/providers/posthog/tsconfig.lib.json +9 -0
- package/trpc/README.md +7 -0
- package/trpc/eslint.config.mjs +19 -0
- package/trpc/package.json +13 -0
- package/trpc/project.json +31 -0
- package/trpc/src/index.ts +64 -0
- package/trpc/tsconfig.json +13 -0
- package/trpc/tsconfig.lib.json +9 -0
- package/tsconfig.base.json +30 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const CurrencySchema = z.enum([
|
|
4
|
+
'AED',
|
|
5
|
+
'AFN',
|
|
6
|
+
'ALL',
|
|
7
|
+
'AMD',
|
|
8
|
+
'ANG',
|
|
9
|
+
'AOA',
|
|
10
|
+
'ARS',
|
|
11
|
+
'AUD',
|
|
12
|
+
'AWG',
|
|
13
|
+
'AZN',
|
|
14
|
+
'BAM',
|
|
15
|
+
'BBD',
|
|
16
|
+
'BDT',
|
|
17
|
+
'BGN',
|
|
18
|
+
'BHD',
|
|
19
|
+
'BIF',
|
|
20
|
+
'BMD',
|
|
21
|
+
'BND',
|
|
22
|
+
'BOB',
|
|
23
|
+
'BOV',
|
|
24
|
+
'BRL',
|
|
25
|
+
'BSD',
|
|
26
|
+
'BTN',
|
|
27
|
+
'BWP',
|
|
28
|
+
'BYN',
|
|
29
|
+
'BZD',
|
|
30
|
+
'CAD',
|
|
31
|
+
'CDF',
|
|
32
|
+
'CHE',
|
|
33
|
+
'CHF',
|
|
34
|
+
'CHW',
|
|
35
|
+
'CLF',
|
|
36
|
+
'CLP',
|
|
37
|
+
'CNY',
|
|
38
|
+
'COP',
|
|
39
|
+
'COU',
|
|
40
|
+
'CRC',
|
|
41
|
+
'CUC',
|
|
42
|
+
'CUP',
|
|
43
|
+
'CVE',
|
|
44
|
+
'CZK',
|
|
45
|
+
'DJF',
|
|
46
|
+
'DKK',
|
|
47
|
+
'DOP',
|
|
48
|
+
'DZD',
|
|
49
|
+
'EGP',
|
|
50
|
+
'ERN',
|
|
51
|
+
'ETB',
|
|
52
|
+
'EUR',
|
|
53
|
+
'FJD',
|
|
54
|
+
'FKP',
|
|
55
|
+
'GBP',
|
|
56
|
+
'GEL',
|
|
57
|
+
'GHS',
|
|
58
|
+
'GIP',
|
|
59
|
+
'GMD',
|
|
60
|
+
'GNF',
|
|
61
|
+
'GTQ',
|
|
62
|
+
'GYD',
|
|
63
|
+
'HKD',
|
|
64
|
+
'HNL',
|
|
65
|
+
'HRK',
|
|
66
|
+
'HTG',
|
|
67
|
+
'HUF',
|
|
68
|
+
'IDR',
|
|
69
|
+
'ILS',
|
|
70
|
+
'INR',
|
|
71
|
+
'IQD',
|
|
72
|
+
'IRR',
|
|
73
|
+
'ISK',
|
|
74
|
+
'JMD',
|
|
75
|
+
'JOD',
|
|
76
|
+
'JPY',
|
|
77
|
+
'KES',
|
|
78
|
+
'KGS',
|
|
79
|
+
'KHR',
|
|
80
|
+
'KMF',
|
|
81
|
+
'KPW',
|
|
82
|
+
'KRW',
|
|
83
|
+
'KWD',
|
|
84
|
+
'KYD',
|
|
85
|
+
'KZT',
|
|
86
|
+
'LAK',
|
|
87
|
+
'LBP',
|
|
88
|
+
'LKR',
|
|
89
|
+
'LRD',
|
|
90
|
+
'LSL',
|
|
91
|
+
'LYD',
|
|
92
|
+
'MAD',
|
|
93
|
+
'MDL',
|
|
94
|
+
'MGA',
|
|
95
|
+
'MKD',
|
|
96
|
+
'MMK',
|
|
97
|
+
'MNT',
|
|
98
|
+
'MOP',
|
|
99
|
+
'MRU',
|
|
100
|
+
'MUR',
|
|
101
|
+
'MVR',
|
|
102
|
+
'MWK',
|
|
103
|
+
'MXN',
|
|
104
|
+
'MXV',
|
|
105
|
+
'MYR',
|
|
106
|
+
'MZN',
|
|
107
|
+
'NAD',
|
|
108
|
+
'NGN',
|
|
109
|
+
'NIO',
|
|
110
|
+
'NOK',
|
|
111
|
+
'NPR',
|
|
112
|
+
'NZD',
|
|
113
|
+
'OMR',
|
|
114
|
+
'PAB',
|
|
115
|
+
'PEN',
|
|
116
|
+
'PGK',
|
|
117
|
+
'PHP',
|
|
118
|
+
'PKR',
|
|
119
|
+
'PLN',
|
|
120
|
+
'PYG',
|
|
121
|
+
'QAR',
|
|
122
|
+
'RON',
|
|
123
|
+
'RSD',
|
|
124
|
+
'RUB',
|
|
125
|
+
'RWF',
|
|
126
|
+
'SAR',
|
|
127
|
+
'SBD',
|
|
128
|
+
'SCR',
|
|
129
|
+
'SDG',
|
|
130
|
+
'SEK',
|
|
131
|
+
'SGD',
|
|
132
|
+
'SHP',
|
|
133
|
+
'SLE',
|
|
134
|
+
'SLL',
|
|
135
|
+
'SOS',
|
|
136
|
+
'SRD',
|
|
137
|
+
'SSP',
|
|
138
|
+
'STN',
|
|
139
|
+
'SYP',
|
|
140
|
+
'SZL',
|
|
141
|
+
'THB',
|
|
142
|
+
'TJS',
|
|
143
|
+
'TMT',
|
|
144
|
+
'TND',
|
|
145
|
+
'TOP',
|
|
146
|
+
'TRY',
|
|
147
|
+
'TTD',
|
|
148
|
+
'TVD',
|
|
149
|
+
'TWD',
|
|
150
|
+
'TZS',
|
|
151
|
+
'UAH',
|
|
152
|
+
'UGX',
|
|
153
|
+
'USD',
|
|
154
|
+
'USN',
|
|
155
|
+
'UYI',
|
|
156
|
+
'UYU',
|
|
157
|
+
'UYW',
|
|
158
|
+
'UZS',
|
|
159
|
+
'VED',
|
|
160
|
+
'VES',
|
|
161
|
+
'VND',
|
|
162
|
+
'VUV',
|
|
163
|
+
'WST',
|
|
164
|
+
'XAF',
|
|
165
|
+
'XAG',
|
|
166
|
+
'XAU',
|
|
167
|
+
'XBA',
|
|
168
|
+
'XBB',
|
|
169
|
+
'XBC',
|
|
170
|
+
'XBD',
|
|
171
|
+
'XCD',
|
|
172
|
+
'XDR',
|
|
173
|
+
'XOF',
|
|
174
|
+
'XPD',
|
|
175
|
+
'XPF',
|
|
176
|
+
'XPT',
|
|
177
|
+
'XSU',
|
|
178
|
+
'XTS',
|
|
179
|
+
'XUA',
|
|
180
|
+
'XXX',
|
|
181
|
+
'YER',
|
|
182
|
+
'ZAR',
|
|
183
|
+
'ZMW',
|
|
184
|
+
'ZWL',
|
|
185
|
+
]);
|
|
186
|
+
|
|
187
|
+
export type Currency = z.infer<typeof CurrencySchema>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const FacetIdentifierSchema = z.looseInterface({
|
|
4
|
+
key: z.string().default('').nonoptional()
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
export const FacetValueIdentifierSchema = z.looseInterface({
|
|
8
|
+
facet: FacetIdentifierSchema.default(() => FacetIdentifierSchema.parse({})),
|
|
9
|
+
key: z.string().default('')
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const SKUIdentifierSchema = z.looseInterface({
|
|
13
|
+
key: z.string().default('').nonoptional()
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const ProductIdentifierSchema = z.looseInterface({
|
|
17
|
+
key: z.string().default(''),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export const SearchIdentifierSchema = z.looseInterface({
|
|
21
|
+
term: z.string().default(''),
|
|
22
|
+
page: z.number().default(0),
|
|
23
|
+
pageSize: z.number().default(20),
|
|
24
|
+
facets: z.array(FacetValueIdentifierSchema.required()).default(() => [])
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const CartIdentifierSchema = z.looseInterface({
|
|
28
|
+
key: z.string().default('')
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const CartItemIdentifierSchema = z.looseInterface({
|
|
32
|
+
key: z.string().default('')
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const PriceIdentifierSchema = z.looseInterface({
|
|
36
|
+
sku: SKUIdentifierSchema.default(() => SKUIdentifierSchema.parse({})),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export type ProductIdentifier = z.infer<typeof ProductIdentifierSchema>;
|
|
40
|
+
export type SearchIdentifier = z.infer<typeof SearchIdentifierSchema>;
|
|
41
|
+
export type FacetIdentifier = z.infer<typeof FacetIdentifierSchema>;
|
|
42
|
+
export type FacetValueIdentifier = z.infer<typeof FacetValueIdentifierSchema>;
|
|
43
|
+
export type CartIdentifier = z.infer<typeof CartIdentifierSchema>;
|
|
44
|
+
export type CartItemIdentifier = z.infer<typeof CartItemIdentifierSchema>;
|
|
45
|
+
export type PriceIdentifier = z.infer<typeof PriceIdentifierSchema>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseModelSchema } from './base.model';
|
|
3
|
+
|
|
4
|
+
export const IdentityTypeSchema = z.enum(["Anonymous", "Guest", "Registered"]);
|
|
5
|
+
|
|
6
|
+
export const IdentitySchema = BaseModelSchema.extend({
|
|
7
|
+
id: z.string().default(''),
|
|
8
|
+
type: IdentityTypeSchema.default("Anonymous"),
|
|
9
|
+
token: z.string().optional(),
|
|
10
|
+
issued: z.coerce.date().default(new Date()),
|
|
11
|
+
expiry: z.coerce.date().default(new Date())
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export type IdentityType = z.infer<typeof IdentityTypeSchema>;
|
|
15
|
+
export type Identity = z.infer<typeof IdentitySchema>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseModelSchema } from './base.model';
|
|
3
|
+
import { PriceIdentifierSchema } from './identifiers.model';
|
|
4
|
+
import { CurrencySchema } from './currency.model';
|
|
5
|
+
|
|
6
|
+
export const MonetaryAmountSchema = z.looseInterface({
|
|
7
|
+
cents: z.number().default(0).describe('The monetary amount in cent-precision.'),
|
|
8
|
+
currency: CurrencySchema.default("XXX").describe('The currency associated with the amount, as a ISO 4217 standardized code.')
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const PriceSchema = BaseModelSchema.extend({
|
|
12
|
+
identifier: PriceIdentifierSchema.default(() => PriceIdentifierSchema.parse({})),
|
|
13
|
+
value: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({}))
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export type MonetaryAmount = z.infer<typeof MonetaryAmountSchema>;
|
|
17
|
+
export type Price = z.infer<typeof PriceSchema>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ProductIdentifierSchema } from './identifiers.model';
|
|
3
|
+
import { BaseModelSchema } from './base.model';
|
|
4
|
+
|
|
5
|
+
export const SKUSchema = z.looseInterface({
|
|
6
|
+
identifier: ProductIdentifierSchema.default(() => ProductIdentifierSchema.parse({})),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const ProductAttributeSchema = z.looseInterface({
|
|
10
|
+
id: z.string(),
|
|
11
|
+
name: z.string(),
|
|
12
|
+
value: z.string()
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const ProductSchema = BaseModelSchema.extend({
|
|
16
|
+
identifier: ProductIdentifierSchema.default(() => ProductIdentifierSchema.parse({})),
|
|
17
|
+
name: z.string().default(''),
|
|
18
|
+
slug: z.string().default(''),
|
|
19
|
+
description: z.string().default(''),
|
|
20
|
+
image: z.string().url().default('https://placehold.co/400'),
|
|
21
|
+
images: z.string().url().array().default(() => []),
|
|
22
|
+
attributes: z.array(ProductAttributeSchema).default(() => []),
|
|
23
|
+
skus: z.array(SKUSchema).default(() => [])
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export type SKU = z.infer<typeof SKUSchema>;
|
|
27
|
+
export type Product = z.infer<typeof ProductSchema>;
|
|
28
|
+
export type ProductAttribute = z.infer<typeof ProductAttributeSchema>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ProductIdentifierSchema, FacetValueIdentifierSchema, FacetIdentifierSchema, SearchIdentifierSchema } from './identifiers.model';
|
|
3
|
+
import { BaseModelSchema } from './base.model';
|
|
4
|
+
|
|
5
|
+
export const SearchResultProductSchema = z.looseInterface({
|
|
6
|
+
identifier: ProductIdentifierSchema.default(ProductIdentifierSchema.parse({})),
|
|
7
|
+
name: z.string().default(''),
|
|
8
|
+
image: z.string().url().default('https://placehold.co/400'),
|
|
9
|
+
slug: z.string().default('')
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const SearchResultFacetValueSchema = z.looseInterface({
|
|
13
|
+
identifier: FacetValueIdentifierSchema.default(() => FacetValueIdentifierSchema.parse({})),
|
|
14
|
+
name: z.string().default(''),
|
|
15
|
+
count: z.number().default(0),
|
|
16
|
+
active: z.boolean().default(false)
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const SearchResultFacetSchema = z.looseInterface({
|
|
20
|
+
identifier: FacetIdentifierSchema.default(() => FacetIdentifierSchema.parse({})),
|
|
21
|
+
name: z.string().default(''),
|
|
22
|
+
values: z.array(SearchResultFacetValueSchema).default(() => [])
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export const SearchResultSchema = BaseModelSchema.extend({
|
|
26
|
+
identifier: SearchIdentifierSchema.default(() => SearchIdentifierSchema.parse({})),
|
|
27
|
+
products: z.array(SearchResultProductSchema).default(() => []),
|
|
28
|
+
pages: z.number().default(0),
|
|
29
|
+
facets: z.array(SearchResultFacetSchema).default(() => [])
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export type SearchResultProduct = z.infer<typeof SearchResultProductSchema>;
|
|
33
|
+
export type SearchResult = z.infer<typeof SearchResultSchema>;
|
|
34
|
+
export type SearchResultFacet = z.infer<typeof SearchResultFacetSchema>;
|
|
35
|
+
export type SearchResultFacetValue = z.infer<typeof SearchResultFacetValueSchema>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseMutationSchema } from './base.mutation';
|
|
3
|
+
import { ProductIdentifierSchema, SearchIdentifierSchema } from '../models/identifiers.model';
|
|
4
|
+
|
|
5
|
+
export const AnalyticsMutationSearchEventSchema = BaseMutationSchema.extend({
|
|
6
|
+
mutation: z.literal('search'),
|
|
7
|
+
search: SearchIdentifierSchema.required(),
|
|
8
|
+
products: z.array(ProductIdentifierSchema),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const AnalyticsMutationSearchProductClickEventSchema = BaseMutationSchema.extend({
|
|
12
|
+
mutation: z.literal('product-search-click'),
|
|
13
|
+
search: SearchIdentifierSchema.required(),
|
|
14
|
+
product: ProductIdentifierSchema.required(),
|
|
15
|
+
position: z.number().min(0)
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const AnalyticsMutationSchema = z.union([AnalyticsMutationSearchEventSchema, AnalyticsMutationSearchProductClickEventSchema]);
|
|
19
|
+
|
|
20
|
+
export type AnalyticsMutation = z.infer<typeof AnalyticsMutationSchema>;
|
|
21
|
+
export type AnalyticsMutationSearchEvent = z.infer<typeof AnalyticsMutationSearchEventSchema>;
|
|
22
|
+
export type AnalyticsMutationSearchProductClickEvent = z.infer<typeof AnalyticsMutationSearchProductClickEventSchema>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseMutationSchema } from './base.mutation';
|
|
3
|
+
import { CartIdentifierSchema, CartItemIdentifierSchema, ProductIdentifierSchema } from '../models/identifiers.model';
|
|
4
|
+
|
|
5
|
+
export const CartMutationItemAddSchema = BaseMutationSchema.extend({
|
|
6
|
+
mutation: z.literal('add'),
|
|
7
|
+
cart: CartIdentifierSchema.required(),
|
|
8
|
+
product: ProductIdentifierSchema.required(),
|
|
9
|
+
quantity: z.number()
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const CartMutationItemRemoveSchema = BaseMutationSchema.extend({
|
|
13
|
+
mutation: z.literal('remove'),
|
|
14
|
+
cart: CartIdentifierSchema.required(),
|
|
15
|
+
item: CartItemIdentifierSchema.required()
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const CartMutationItemQuantityChangeSchema = BaseMutationSchema.extend({
|
|
19
|
+
mutation: z.literal('adjustQuantity'),
|
|
20
|
+
cart: CartIdentifierSchema.required(),
|
|
21
|
+
item: CartItemIdentifierSchema.required(),
|
|
22
|
+
quantity: z.number()
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export const CartMutationSchema = z.union([CartMutationItemAddSchema, CartMutationItemRemoveSchema, CartMutationItemQuantityChangeSchema]);
|
|
26
|
+
|
|
27
|
+
export type CartMutation = z.infer<typeof CartMutationSchema>;
|
|
28
|
+
export type CartMutationItemAdd = z.infer<typeof CartMutationItemAddSchema>;
|
|
29
|
+
export type CartMutationItemRemove = z.infer<typeof CartMutationItemRemoveSchema>;
|
|
30
|
+
export type CartMutationItemQuantityChange = z.infer<typeof CartMutationItemQuantityChangeSchema>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseMutationSchema } from './base.mutation';
|
|
3
|
+
|
|
4
|
+
export const IdentityMutationLoginSchema = BaseMutationSchema.extend({
|
|
5
|
+
mutation: z.literal('login'),
|
|
6
|
+
username: z.string(),
|
|
7
|
+
password: z.string()
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export const IdentityMutationLogoutSchema = BaseMutationSchema.extend({
|
|
11
|
+
mutation: z.literal('logout')
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const IdentityMutationSchema = z.union([IdentityMutationLoginSchema, IdentityMutationLogoutSchema]);
|
|
15
|
+
|
|
16
|
+
export type IdentityMutation = z.infer<typeof IdentityMutationSchema>;
|
|
17
|
+
export type IdentityMutationLogin = z.infer<typeof IdentityMutationLoginSchema>;
|
|
18
|
+
export type IdentityMutationLogout = z.infer<typeof IdentityMutationLogoutSchema>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseQuerySchema } from './base.query';
|
|
3
|
+
import { CartIdentifierSchema } from '../models/identifiers.model';
|
|
4
|
+
|
|
5
|
+
export const CartQueryByIdSchema = BaseQuerySchema.extend({
|
|
6
|
+
query: z.literal('id'),
|
|
7
|
+
cart: CartIdentifierSchema.required()
|
|
8
|
+
});
|
|
9
|
+
export const CartQuerySchema = z.union([CartQueryByIdSchema]);
|
|
10
|
+
|
|
11
|
+
export type CartQueryById = z.infer<typeof CartQueryByIdSchema>;
|
|
12
|
+
export type CartQuery = z.infer<typeof CartQuerySchema>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseQuerySchema } from './base.query';
|
|
3
|
+
|
|
4
|
+
export const IdentityQuerySelfSchema = BaseQuerySchema.extend({
|
|
5
|
+
query: z.literal('self')
|
|
6
|
+
});
|
|
7
|
+
export const IdentityQuerySchema = z.union([IdentityQuerySelfSchema]);
|
|
8
|
+
|
|
9
|
+
export type IdentityQuery = z.infer<typeof IdentityQuerySchema>;
|
|
10
|
+
export type IdentityQuerySelf = z.infer<typeof IdentityQuerySelfSchema>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseQuerySchema } from './base.query';
|
|
3
|
+
import { SKUIdentifierSchema } from '../models/identifiers.model';
|
|
4
|
+
|
|
5
|
+
export const PriceQueryBySkuSchema = BaseQuerySchema.extend({
|
|
6
|
+
query: z.literal('sku'),
|
|
7
|
+
sku: SKUIdentifierSchema.required(),
|
|
8
|
+
});
|
|
9
|
+
export const PriceQuerySchema = z.union([PriceQueryBySkuSchema]);
|
|
10
|
+
|
|
11
|
+
export type PriceQueryBySku = z.infer<typeof PriceQueryBySkuSchema>;
|
|
12
|
+
export type PriceQuery = z.infer<typeof PriceQuerySchema>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseQuerySchema } from './base.query';
|
|
3
|
+
|
|
4
|
+
export const ProductQueryBySlugSchema = BaseQuerySchema.extend({
|
|
5
|
+
query: z.literal('slug'),
|
|
6
|
+
slug: z.string()
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const ProductQueryByIdSchema = BaseQuerySchema.extend({
|
|
10
|
+
query: z.literal('id'),
|
|
11
|
+
id: z.string()
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const ProductQuerySchema = z.union([ProductQueryBySlugSchema, ProductQueryByIdSchema]);
|
|
15
|
+
|
|
16
|
+
export type ProductQueryBySlug = z.infer<typeof ProductQueryBySlugSchema>;
|
|
17
|
+
export type ProductQueryById = z.infer<typeof ProductQueryByIdSchema>;
|
|
18
|
+
export type ProductQuery = z.infer<typeof ProductQuerySchema>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseQuerySchema } from './base.query';
|
|
3
|
+
import { SearchIdentifierSchema } from '../models/identifiers.model';
|
|
4
|
+
|
|
5
|
+
export const SearchQueryByTermSchema = BaseQuerySchema.extend({
|
|
6
|
+
query: z.literal('term'),
|
|
7
|
+
search: SearchIdentifierSchema.required()
|
|
8
|
+
});
|
|
9
|
+
export const SearchQuerySchema = z.union([SearchQueryByTermSchema]);
|
|
10
|
+
|
|
11
|
+
export type SearchQuery = z.infer<typeof SearchQuerySchema>;
|
|
12
|
+
export type SearchQueryByTerm = z.infer<typeof SearchQueryByTermSchema>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { IdentitySchema } from './models/identity.model';
|
|
3
|
+
|
|
4
|
+
export const SessionSchema = z.looseObject({
|
|
5
|
+
id: z.string(),
|
|
6
|
+
identity: IdentitySchema.default(() => IdentitySchema.parse({}))
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export type Session = z.infer<typeof SessionSchema>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"forceConsistentCasingInFileNames": true,
|
|
6
|
+
"strict": true,
|
|
7
|
+
"importHelpers": true,
|
|
8
|
+
"noImplicitOverride": true,
|
|
9
|
+
"noImplicitReturns": true,
|
|
10
|
+
"noFallthroughCasesInSwitch": true,
|
|
11
|
+
"noPropertyAccessFromIndexSignature": true
|
|
12
|
+
},
|
|
13
|
+
"files": [],
|
|
14
|
+
"include": [],
|
|
15
|
+
"references": [
|
|
16
|
+
{
|
|
17
|
+
"path": "./tsconfig.lib.json"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"path": "./tsconfig.spec.json"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../dist/out-tsc",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"types": ["node"]
|
|
7
|
+
},
|
|
8
|
+
"include": ["src/**/*.ts"],
|
|
9
|
+
"exclude": [
|
|
10
|
+
"vite.config.ts",
|
|
11
|
+
"vite.config.mts",
|
|
12
|
+
"vitest.config.ts",
|
|
13
|
+
"vitest.config.mts",
|
|
14
|
+
"src/**/*.test.ts",
|
|
15
|
+
"src/**/*.spec.ts",
|
|
16
|
+
"src/**/*.test.tsx",
|
|
17
|
+
"src/**/*.spec.tsx",
|
|
18
|
+
"src/**/*.test.js",
|
|
19
|
+
"src/**/*.spec.js",
|
|
20
|
+
"src/**/*.test.jsx",
|
|
21
|
+
"src/**/*.spec.jsx"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../dist/out-tsc",
|
|
5
|
+
"types": [
|
|
6
|
+
"vitest/globals",
|
|
7
|
+
"vitest/importMeta",
|
|
8
|
+
"vite/client",
|
|
9
|
+
"node",
|
|
10
|
+
"vitest"
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
"include": [
|
|
14
|
+
"vite.config.ts",
|
|
15
|
+
"vite.config.mts",
|
|
16
|
+
"vitest.config.ts",
|
|
17
|
+
"vitest.config.mts",
|
|
18
|
+
"src/**/*.test.ts",
|
|
19
|
+
"src/**/*.spec.ts",
|
|
20
|
+
"src/**/*.test.tsx",
|
|
21
|
+
"src/**/*.spec.tsx",
|
|
22
|
+
"src/**/*.test.js",
|
|
23
|
+
"src/**/*.spec.js",
|
|
24
|
+
"src/**/*.test.jsx",
|
|
25
|
+
"src/**/*.spec.jsx",
|
|
26
|
+
"src/**/*.d.ts"
|
|
27
|
+
]
|
|
28
|
+
}
|