@reactionary/source 0.0.52 → 0.2.16

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 (293) hide show
  1. package/.env-template +19 -0
  2. package/.github/workflows/pull-request.yml +3 -1
  3. package/.github/workflows/release.yml +9 -0
  4. package/.vscode/extensions.json +0 -2
  5. package/LICENSE +21 -0
  6. package/README.md +175 -23
  7. package/core/package.json +6 -3
  8. package/core/src/cache/cache.interface.ts +1 -0
  9. package/core/src/cache/index.ts +4 -0
  10. package/core/src/cache/memory-cache.ts +30 -2
  11. package/core/src/cache/noop-cache.ts +15 -1
  12. package/core/src/cache/redis-cache.ts +20 -0
  13. package/core/src/client/client-builder.ts +71 -54
  14. package/core/src/client/client.ts +9 -47
  15. package/core/src/client/index.ts +2 -0
  16. package/core/src/decorators/index.ts +1 -0
  17. package/core/src/decorators/reactionary.decorator.ts +203 -34
  18. package/core/src/index.ts +6 -19
  19. package/core/src/initialization.ts +1 -18
  20. package/core/src/metrics/metrics.ts +67 -0
  21. package/core/src/providers/analytics.provider.ts +1 -6
  22. package/core/src/providers/base.provider.ts +5 -69
  23. package/core/src/providers/cart.provider.ts +15 -55
  24. package/core/src/providers/category.provider.ts +7 -11
  25. package/core/src/providers/checkout.provider.ts +17 -15
  26. package/core/src/providers/identity.provider.ts +6 -8
  27. package/core/src/providers/index.ts +2 -1
  28. package/core/src/providers/inventory.provider.ts +15 -5
  29. package/core/src/providers/order-search.provider.ts +29 -0
  30. package/core/src/providers/order.provider.ts +47 -15
  31. package/core/src/providers/price.provider.ts +30 -36
  32. package/core/src/providers/product-search.provider.ts +61 -0
  33. package/core/src/providers/product.provider.ts +71 -12
  34. package/core/src/providers/profile.provider.ts +74 -14
  35. package/core/src/providers/store.provider.ts +3 -5
  36. package/core/src/schemas/capabilities.schema.ts +10 -3
  37. package/core/src/schemas/errors/generic.error.ts +9 -0
  38. package/core/src/schemas/errors/index.ts +4 -0
  39. package/core/src/schemas/errors/invalid-input.error.ts +9 -0
  40. package/core/src/schemas/errors/invalid-output.error.ts +9 -0
  41. package/core/src/schemas/errors/not-found.error.ts +9 -0
  42. package/core/src/schemas/index.ts +7 -0
  43. package/core/src/schemas/models/analytics.model.ts +2 -1
  44. package/core/src/schemas/models/base.model.ts +6 -24
  45. package/core/src/schemas/models/cart.model.ts +5 -8
  46. package/core/src/schemas/models/category.model.ts +4 -9
  47. package/core/src/schemas/models/checkout.model.ts +6 -7
  48. package/core/src/schemas/models/cost.model.ts +4 -3
  49. package/core/src/schemas/models/currency.model.ts +2 -1
  50. package/core/src/schemas/models/identifiers.model.ts +106 -62
  51. package/core/src/schemas/models/identity.model.ts +10 -19
  52. package/core/src/schemas/models/index.ts +2 -1
  53. package/core/src/schemas/models/inventory.model.ts +8 -5
  54. package/core/src/schemas/models/order-search.model.ts +28 -0
  55. package/core/src/schemas/models/order.model.ts +20 -26
  56. package/core/src/schemas/models/payment.model.ts +14 -17
  57. package/core/src/schemas/models/price.model.ts +11 -11
  58. package/core/src/schemas/models/product-search.model.ts +42 -0
  59. package/core/src/schemas/models/product.model.ts +64 -22
  60. package/core/src/schemas/models/profile.model.ts +19 -22
  61. package/core/src/schemas/models/shipping-method.model.ts +24 -29
  62. package/core/src/schemas/models/store.model.ts +9 -5
  63. package/core/src/schemas/mutations/analytics.mutation.ts +8 -7
  64. package/core/src/schemas/mutations/base.mutation.ts +2 -1
  65. package/core/src/schemas/mutations/cart.mutation.ts +33 -33
  66. package/core/src/schemas/mutations/checkout.mutation.ts +23 -30
  67. package/core/src/schemas/mutations/identity.mutation.ts +4 -3
  68. package/core/src/schemas/mutations/profile.mutation.ts +38 -3
  69. package/core/src/schemas/queries/base.query.ts +2 -1
  70. package/core/src/schemas/queries/cart.query.ts +3 -3
  71. package/core/src/schemas/queries/category.query.ts +18 -18
  72. package/core/src/schemas/queries/checkout.query.ts +7 -9
  73. package/core/src/schemas/queries/identity.query.ts +2 -1
  74. package/core/src/schemas/queries/index.ts +2 -1
  75. package/core/src/schemas/queries/inventory.query.ts +5 -5
  76. package/core/src/schemas/queries/order-search.query.ts +10 -0
  77. package/core/src/schemas/queries/order.query.ts +3 -2
  78. package/core/src/schemas/queries/price.query.ts +10 -4
  79. package/core/src/schemas/queries/product-search.query.ts +16 -0
  80. package/core/src/schemas/queries/product.query.ts +13 -6
  81. package/core/src/schemas/queries/profile.query.ts +5 -2
  82. package/core/src/schemas/queries/store.query.ts +6 -5
  83. package/core/src/schemas/result.ts +107 -0
  84. package/core/src/schemas/session.schema.ts +4 -4
  85. package/core/src/test/reactionary.decorator.spec.ts +249 -0
  86. package/core/src/zod-utils.ts +19 -0
  87. package/core/tsconfig.json +1 -1
  88. package/core/tsconfig.spec.json +2 -26
  89. package/core/vitest.config.ts +14 -0
  90. package/documentation/1-purpose.md +114 -0
  91. package/documentation/2-getting-started.md +229 -0
  92. package/documentation/3-querying-and-changing-data.md +74 -0
  93. package/documentation/4-product-data.md +107 -0
  94. package/documentation/5-cart-and-checkout.md +211 -0
  95. package/documentation/6-product-search.md +143 -0
  96. package/documentation/7-marketing.md +3 -0
  97. package/eslint.config.mjs +1 -0
  98. package/examples/node/eslint.config.mjs +1 -4
  99. package/examples/node/package.json +10 -3
  100. package/examples/node/project.json +4 -1
  101. package/examples/node/src/basic/basic-node-provider-model-extension.spec.ts +22 -23
  102. package/examples/node/src/basic/basic-node-provider-query-extension.spec.ts +15 -11
  103. package/examples/node/src/basic/basic-node-setup.spec.ts +44 -28
  104. package/examples/node/src/basic/client-creation.spec.ts +53 -0
  105. package/examples/node/src/capabilities/cart.spec.ts +255 -0
  106. package/examples/node/src/capabilities/category.spec.ts +193 -0
  107. package/examples/node/src/capabilities/checkout.spec.ts +341 -0
  108. package/examples/node/src/capabilities/identity.spec.ts +93 -0
  109. package/examples/node/src/capabilities/inventory.spec.ts +66 -0
  110. package/examples/node/src/capabilities/order-search.spec.ts +265 -0
  111. package/examples/node/src/capabilities/order.spec.ts +91 -0
  112. package/examples/node/src/capabilities/price.spec.ts +51 -0
  113. package/examples/node/src/capabilities/product-search.spec.ts +293 -0
  114. package/examples/node/src/capabilities/product.spec.ts +122 -0
  115. package/examples/node/src/capabilities/profile.spec.ts +316 -0
  116. package/examples/node/src/capabilities/store.spec.ts +26 -0
  117. package/examples/node/src/utils.ts +147 -0
  118. package/examples/node/tsconfig.json +9 -12
  119. package/examples/node/tsconfig.lib.json +1 -2
  120. package/examples/node/tsconfig.spec.json +2 -14
  121. package/examples/node/vitest.config.ts +14 -0
  122. package/migrations.json +22 -5
  123. package/nx.json +8 -47
  124. package/package.json +24 -96
  125. package/providers/algolia/README.md +39 -2
  126. package/providers/algolia/package.json +2 -1
  127. package/providers/algolia/src/core/initialize.ts +7 -14
  128. package/providers/algolia/src/index.ts +2 -4
  129. package/providers/algolia/src/providers/index.ts +1 -0
  130. package/providers/algolia/src/providers/product-search.provider.ts +241 -0
  131. package/providers/algolia/src/schema/capabilities.schema.ts +2 -3
  132. package/providers/algolia/src/schema/index.ts +3 -0
  133. package/providers/algolia/src/schema/search.schema.ts +8 -8
  134. package/providers/algolia/tsconfig.json +1 -1
  135. package/providers/algolia/tsconfig.lib.json +1 -1
  136. package/providers/algolia/tsconfig.spec.json +2 -14
  137. package/providers/algolia/vitest.config.ts +14 -0
  138. package/providers/commercetools/README.md +30 -3
  139. package/providers/commercetools/package.json +2 -1
  140. package/providers/commercetools/src/core/client.ts +178 -99
  141. package/providers/commercetools/src/core/initialize.ts +130 -74
  142. package/providers/commercetools/src/core/token-cache.ts +45 -0
  143. package/providers/commercetools/src/index.ts +3 -2
  144. package/providers/commercetools/src/providers/cart.provider.ts +281 -341
  145. package/providers/commercetools/src/providers/category.provider.ts +223 -138
  146. package/providers/commercetools/src/providers/checkout.provider.ts +631 -449
  147. package/providers/commercetools/src/providers/identity.provider.ts +50 -29
  148. package/providers/commercetools/src/providers/index.ts +2 -2
  149. package/providers/commercetools/src/providers/inventory.provider.ts +76 -74
  150. package/providers/commercetools/src/providers/order-search.provider.ts +220 -0
  151. package/providers/commercetools/src/providers/order.provider.ts +96 -61
  152. package/providers/commercetools/src/providers/price.provider.ts +147 -117
  153. package/providers/commercetools/src/providers/product-search.provider.ts +528 -0
  154. package/providers/commercetools/src/providers/product.provider.ts +249 -74
  155. package/providers/commercetools/src/providers/profile.provider.ts +445 -28
  156. package/providers/commercetools/src/providers/store.provider.ts +54 -40
  157. package/providers/commercetools/src/schema/capabilities.schema.ts +3 -1
  158. package/providers/commercetools/src/schema/commercetools.schema.ts +17 -3
  159. package/providers/commercetools/src/schema/configuration.schema.ts +1 -0
  160. package/providers/commercetools/src/schema/session.schema.ts +7 -0
  161. package/providers/commercetools/src/test/caching.spec.ts +82 -0
  162. package/providers/commercetools/src/test/identity.spec.ts +109 -0
  163. package/providers/commercetools/src/test/test-utils.ts +21 -19
  164. package/providers/commercetools/tsconfig.json +1 -1
  165. package/providers/commercetools/tsconfig.lib.json +1 -1
  166. package/providers/commercetools/tsconfig.spec.json +2 -14
  167. package/providers/commercetools/vitest.config.ts +15 -0
  168. package/providers/fake/README.md +20 -4
  169. package/providers/fake/package.json +2 -1
  170. package/providers/fake/src/core/initialize.ts +47 -49
  171. package/providers/fake/src/providers/analytics.provider.ts +5 -7
  172. package/providers/fake/src/providers/cart.provider.ts +163 -92
  173. package/providers/fake/src/providers/category.provider.ts +78 -50
  174. package/providers/fake/src/providers/checkout.provider.ts +254 -0
  175. package/providers/fake/src/providers/identity.provider.ts +57 -65
  176. package/providers/fake/src/providers/index.ts +6 -2
  177. package/providers/fake/src/providers/inventory.provider.ts +40 -36
  178. package/providers/fake/src/providers/order-search.provider.ts +78 -0
  179. package/providers/fake/src/providers/order.provider.ts +106 -0
  180. package/providers/fake/src/providers/price.provider.ts +93 -41
  181. package/providers/fake/src/providers/product-search.provider.ts +206 -0
  182. package/providers/fake/src/providers/product.provider.ts +56 -41
  183. package/providers/fake/src/providers/profile.provider.ts +147 -0
  184. package/providers/fake/src/providers/store.provider.ts +30 -20
  185. package/providers/fake/src/schema/capabilities.schema.ts +5 -1
  186. package/providers/fake/src/test/cart.provider.spec.ts +59 -80
  187. package/providers/fake/src/test/category.provider.spec.ts +145 -87
  188. package/providers/fake/src/test/checkout.provider.spec.ts +222 -0
  189. package/providers/fake/src/test/order-search.provider.spec.ts +50 -0
  190. package/providers/fake/src/test/order.provider.spec.ts +44 -0
  191. package/providers/fake/src/test/price.provider.spec.ts +50 -45
  192. package/providers/fake/src/test/product.provider.spec.ts +15 -7
  193. package/providers/fake/src/test/profile.provider.spec.ts +167 -0
  194. package/providers/fake/tsconfig.json +1 -1
  195. package/providers/fake/tsconfig.lib.json +1 -1
  196. package/providers/fake/tsconfig.spec.json +2 -12
  197. package/providers/fake/vitest.config.ts +14 -0
  198. package/providers/medusa/README.md +30 -0
  199. package/providers/medusa/TESTING.md +98 -0
  200. package/providers/medusa/eslint.config.mjs +19 -0
  201. package/providers/medusa/package.json +22 -0
  202. package/providers/medusa/project.json +34 -0
  203. package/providers/medusa/src/core/client.ts +370 -0
  204. package/providers/medusa/src/core/initialize.ts +78 -0
  205. package/providers/medusa/src/index.ts +13 -0
  206. package/providers/medusa/src/providers/cart.provider.ts +575 -0
  207. package/providers/medusa/src/providers/category.provider.ts +247 -0
  208. package/providers/medusa/src/providers/checkout.provider.ts +636 -0
  209. package/providers/medusa/src/providers/identity.provider.ts +137 -0
  210. package/providers/medusa/src/providers/inventory.provider.ts +173 -0
  211. package/providers/medusa/src/providers/order-search.provider.ts +202 -0
  212. package/providers/medusa/src/providers/order.provider.ts +226 -0
  213. package/providers/medusa/src/providers/price.provider.ts +140 -0
  214. package/providers/medusa/src/providers/product-search.provider.ts +243 -0
  215. package/providers/medusa/src/providers/product.provider.ts +261 -0
  216. package/providers/medusa/src/providers/profile.provider.ts +392 -0
  217. package/providers/medusa/src/schema/capabilities.schema.ts +18 -0
  218. package/providers/medusa/src/schema/configuration.schema.ts +11 -0
  219. package/providers/medusa/src/schema/medusa.schema.ts +31 -0
  220. package/providers/medusa/src/test/cart.provider.spec.ts +240 -0
  221. package/providers/medusa/src/test/category.provider.spec.ts +231 -0
  222. package/providers/medusa/src/test/checkout.spec.ts +349 -0
  223. package/providers/medusa/src/test/identity.provider.spec.ts +122 -0
  224. package/providers/medusa/src/test/inventory.provider.spec.ts +88 -0
  225. package/providers/medusa/src/test/large-cart.provider.spec.ts +103 -0
  226. package/providers/medusa/src/test/price.provider.spec.ts +104 -0
  227. package/providers/medusa/src/test/product.provider.spec.ts +146 -0
  228. package/providers/medusa/src/test/search.provider.spec.ts +203 -0
  229. package/providers/medusa/src/test/test-utils.ts +13 -0
  230. package/providers/medusa/src/utils/medusa-helpers.ts +89 -0
  231. package/providers/medusa/tsconfig.json +21 -0
  232. package/providers/medusa/tsconfig.lib.json +9 -0
  233. package/providers/medusa/tsconfig.spec.json +4 -0
  234. package/providers/medusa/vitest.config.ts +15 -0
  235. package/providers/meilisearch/README.md +48 -0
  236. package/providers/meilisearch/eslint.config.mjs +22 -0
  237. package/providers/meilisearch/package.json +13 -0
  238. package/providers/meilisearch/project.json +34 -0
  239. package/providers/meilisearch/src/core/initialize.ts +21 -0
  240. package/providers/meilisearch/src/index.ts +6 -0
  241. package/providers/meilisearch/src/providers/index.ts +1 -0
  242. package/providers/meilisearch/src/providers/order-search.provider.ts +222 -0
  243. package/providers/meilisearch/src/providers/product-search.provider.ts +251 -0
  244. package/providers/meilisearch/src/schema/capabilities.schema.ts +10 -0
  245. package/providers/meilisearch/src/schema/configuration.schema.ts +11 -0
  246. package/providers/meilisearch/src/schema/index.ts +3 -0
  247. package/providers/meilisearch/src/schema/search.schema.ts +14 -0
  248. package/providers/meilisearch/tsconfig.json +24 -0
  249. package/providers/meilisearch/tsconfig.lib.json +10 -0
  250. package/providers/meilisearch/tsconfig.spec.json +4 -0
  251. package/providers/meilisearch/vitest.config.ts +14 -0
  252. package/providers/posthog/package.json +2 -1
  253. package/providers/posthog/tsconfig.json +1 -1
  254. package/tsconfig.base.json +5 -0
  255. package/vitest.config.ts +10 -0
  256. package/core/src/providers/search.provider.ts +0 -18
  257. package/core/src/schemas/models/search.model.ts +0 -36
  258. package/core/src/schemas/queries/search.query.ts +0 -9
  259. package/examples/next/.swcrc +0 -30
  260. package/examples/next/eslint.config.mjs +0 -21
  261. package/examples/next/index.d.ts +0 -6
  262. package/examples/next/next-env.d.ts +0 -5
  263. package/examples/next/next.config.js +0 -31
  264. package/examples/next/project.json +0 -9
  265. package/examples/next/public/.gitkeep +0 -0
  266. package/examples/next/public/favicon.ico +0 -0
  267. package/examples/next/src/app/global.css +0 -0
  268. package/examples/next/src/app/layout.tsx +0 -18
  269. package/examples/next/src/app/page.module.scss +0 -2
  270. package/examples/next/src/app/page.tsx +0 -47
  271. package/examples/next/src/instrumentation.ts +0 -9
  272. package/examples/next/tsconfig.json +0 -44
  273. package/examples/node/jest.config.ts +0 -10
  274. package/jest.config.ts +0 -6
  275. package/jest.preset.js +0 -3
  276. package/providers/algolia/jest.config.ts +0 -10
  277. package/providers/algolia/src/providers/product.provider.ts +0 -66
  278. package/providers/algolia/src/providers/search.provider.ts +0 -106
  279. package/providers/algolia/src/test/search.provider.spec.ts +0 -91
  280. package/providers/commercetools/jest.config.cjs +0 -10
  281. package/providers/commercetools/src/providers/search.provider.ts +0 -96
  282. package/providers/commercetools/src/test/cart.provider.spec.ts +0 -199
  283. package/providers/commercetools/src/test/category.provider.spec.ts +0 -168
  284. package/providers/commercetools/src/test/checkout.provider.spec.ts +0 -312
  285. package/providers/commercetools/src/test/identity.provider.spec.ts +0 -88
  286. package/providers/commercetools/src/test/inventory.provider.spec.ts +0 -41
  287. package/providers/commercetools/src/test/price.provider.spec.ts +0 -81
  288. package/providers/commercetools/src/test/product.provider.spec.ts +0 -80
  289. package/providers/commercetools/src/test/profile.provider.spec.ts +0 -49
  290. package/providers/commercetools/src/test/search.provider.spec.ts +0 -61
  291. package/providers/commercetools/src/test/store.provider.spec.ts +0 -37
  292. package/providers/fake/jest.config.cjs +0 -10
  293. package/providers/fake/src/providers/search.provider.ts +0 -132
@@ -1,31 +1,73 @@
1
1
  import { z } from 'zod';
2
- import { ProductIdentifierSchema, SKUIdentifierSchema } from './identifiers.model.js';
3
- import { BaseModelSchema } from './base.model.js';
4
-
5
- export const SKUSchema = z.looseObject({
6
- identifier: SKUIdentifierSchema.default(() => SKUIdentifierSchema.parse({})),
7
- /* name: z.string().default(''),
8
- slug: z.string().default(''),
9
- image: ImageSchema.default(() => ImageSchema.parse({})), */
2
+ import { CategoryIdentifierSchema, ProductAttributeIdentifierSchema, ProductAttributeValueIdentifierSchema, ProductIdentifierSchema, ProductOptionIdentifierSchema, ProductOptionValueIdentifierSchema, ProductVariantIdentifierSchema } from './identifiers.model.js';
3
+ import { BaseModelSchema, ImageSchema } from './base.model.js';
4
+ import type { InferType } from '../../zod-utils.js';
5
+
6
+
7
+ export const ProductOptionValueSchema = z.looseObject({
8
+ identifier: ProductOptionValueIdentifierSchema.describe('The unique identifier for the product option value.'),
9
+ label: z.string().describe('The human-friendly label for the product option value.'),
10
+ });
11
+
12
+ export const ProductOptionSchema = z.looseObject({
13
+ identifier: ProductOptionIdentifierSchema.describe('The unique identifier for the option.'),
14
+ name: z.string().describe('The name of the option, e.g., Size or Color.'),
15
+ values: z.array(ProductOptionValueSchema).describe('A list of possible values for the option.'),
10
16
  });
11
17
 
18
+ export const ProductVariantOptionSchema = z.looseObject({
19
+ identifier: ProductOptionIdentifierSchema.describe('The unique identifier for the option.'),
20
+ name: z.string().describe('The name of the option, e.g., Size or Color.'),
21
+ value: ProductOptionValueSchema.describe('The unique identifier for the option value.'),
22
+ });
23
+
24
+ export const ProductVariantSchema = z.looseObject({
25
+ identifier: ProductVariantIdentifierSchema.describe('The unique identifier for the variant. Often its SKU'),
26
+ name: z.string(),
27
+ images: z.array(ImageSchema).describe('A list of images associated with the product variant'),
28
+ ean: z.string().describe('The European Article Number identifier for the product variant'),
29
+ gtin: z.string().describe('The Global Trade Item Number identifier for the product variant'),
30
+ upc: z.string().describe('The Universal Product Code identifier for the product variant'),
31
+ barcode: z.string().describe('The barcode identifier for the product variant'),
32
+ options: z.array(ProductVariantOptionSchema).describe('A list of option identifiers that define this variant'),
33
+ });
34
+
35
+ export const ProductAttributeValueSchema = z.looseObject({
36
+ identifier: ProductAttributeValueIdentifierSchema.describe('The unique identifier for the attribute value.'),
37
+ value: z.string().describe('The value of the attribute. Typically a language independent string'),
38
+ label: z.string().describe('The human friendly label for the attribute value. Typically a language dependent string'),
39
+ });
40
+
41
+
42
+
12
43
  export const ProductAttributeSchema = z.looseObject({
13
- id: z.string(),
44
+ identifier: ProductAttributeIdentifierSchema.describe('The unique identifier for the attribute, also typically used as the facet key if the attribute is filterable.'),
45
+ group: z.string(),
14
46
  name: z.string(),
15
- value: z.string()
47
+ values: z.array(ProductAttributeValueSchema)
16
48
  });
17
49
 
18
50
  export const ProductSchema = BaseModelSchema.extend({
19
- identifier: ProductIdentifierSchema.default(() => ProductIdentifierSchema.parse({})),
20
- name: z.string().default(''),
21
- slug: z.string().default(''),
22
- description: z.string().default(''),
23
- image: z.string().url().default('https://placehold.co/400'),
24
- images: z.string().url().array().default(() => []),
25
- attributes: z.array(ProductAttributeSchema).default(() => []),
26
- skus: z.array(SKUSchema).default(() => [])
27
- });
51
+ identifier: ProductIdentifierSchema,
52
+ name: z.string().describe('The name of the product'),
53
+ slug: z.string().describe('The URL-friendly identifier for the product'),
54
+ description: z.string().describe('A brief description of the product'),
55
+ longDescription: z.string().describe('A detailed description of the product'),
56
+ brand: z.string().describe('The brand associated with the product'),
57
+ manufacturer: z.string().describe('The manufacturer of the product'),
58
+ parentCategories: z.array(CategoryIdentifierSchema).describe('A list of parent categories the product belongs to'),
59
+ published: z.boolean().describe('Indicates whether the product is published and visible to customers'),
60
+ sharedAttributes: z.array(ProductAttributeSchema).describe('A list of technical attributes associated with the product'),
61
+ options: z.array(ProductOptionSchema).describe('A list of options available for the product, such as size or color. Can be empty if product is single-sku'),
62
+ mainVariant: ProductVariantSchema.describe('The primary SKU for the product'),
63
+ variants: z.array(ProductVariantSchema).default([]).describe('A list of all SKUs for the product. Can be empty or omitted if product is single-sku'),
64
+ }).describe('A product is a wrapper around sellable items. It contains all the shared information for a set of SKUs. All products have at least one SKU, but can potentially have hundreds.');
65
+
28
66
 
29
- export type SKU = z.infer<typeof SKUSchema>;
30
- export type Product = z.infer<typeof ProductSchema>;
31
- export type ProductAttribute = z.infer<typeof ProductAttributeSchema>;
67
+ export type ProductVariant = InferType<typeof ProductVariantSchema>;
68
+ export type Product = InferType<typeof ProductSchema>;
69
+ export type ProductAttribute = InferType<typeof ProductAttributeSchema>;
70
+ export type ProductAttributeValue = InferType<typeof ProductAttributeValueSchema>;
71
+ export type ProductOption = InferType<typeof ProductOptionSchema>;
72
+ export type ProductOptionValue = InferType<typeof ProductOptionValueSchema>;
73
+ export type ProductVariantOption = InferType<typeof ProductVariantOptionSchema>;
@@ -1,35 +1,32 @@
1
- import z from "zod";
1
+ import { z } from "zod";
2
2
  import { AddressIdentifierSchema, IdentityIdentifierSchema } from "./identifiers.model.js";
3
3
  import { BaseModelSchema } from "./base.model.js";
4
+ import type { InferType } from '../../zod-utils.js';
4
5
 
5
6
  export const AddressSchema = BaseModelSchema.extend({
6
7
  identifier: AddressIdentifierSchema.default(() => AddressIdentifierSchema.parse({})),
7
- firstName: z.string().default(''),
8
- lastName: z.string().default(''),
9
- streetAddress: z.string().default(''),
10
- streetNumber: z.string().default(''),
11
- city: z.string().default(''),
12
- region: z.string().default(''),
13
- postalCode: z.string().default(''),
14
- countryCode: z.string().default('US'),
8
+ firstName: z.string(),
9
+ lastName: z.string(),
10
+ streetAddress: z.string(),
11
+ streetNumber: z.string(),
12
+ city: z.string(),
13
+ region: z.string(),
14
+ postalCode: z.string(),
15
+ countryCode: z.string(),
15
16
  });
16
17
 
17
18
  export const ProfileSchema = BaseModelSchema.extend({
18
- identifier: IdentityIdentifierSchema.default(() => IdentityIdentifierSchema.parse({})),
19
- email: z.string().email().default(''),
20
- phone: z.string().default(''),
21
-
22
- emailVerified: z.boolean().default(false),
23
- phoneVerified: z.boolean().default(false),
24
-
25
- createdAt: z.string().default(() => new Date().toISOString()),
26
- updatedAt: z.string().default(() => new Date().toISOString()),
27
-
19
+ identifier: IdentityIdentifierSchema,
20
+ email: z.email(),
21
+ phone: z.string(),
22
+ emailVerified: z.boolean(),
23
+ phoneVerified: z.boolean(),
24
+ createdAt: z.string(),
25
+ updatedAt: z.string(),
28
26
  shippingAddress: AddressSchema.optional(),
29
27
  billingAddress: AddressSchema.optional(),
30
-
31
28
  alternateShippingAddresses: z.array(AddressSchema).default(() => []),
32
29
  });
33
30
 
34
- export type Address = z.infer<typeof AddressSchema>;
35
- export type Profile = z.infer<typeof ProfileSchema>;
31
+ export type Address = InferType<typeof AddressSchema>;
32
+ export type Profile = InferType<typeof ProfileSchema>;
@@ -1,45 +1,40 @@
1
- import z from "zod";
1
+ import { z } from "zod";
2
2
  import { ShippingMethodIdentifierSchema } from "./identifiers.model.js";
3
3
  import { MonetaryAmountSchema } from "./price.model.js";
4
4
  import { BaseModelSchema, ImageSchema } from "./base.model.js";
5
5
  import { AddressSchema } from "./profile.model.js";
6
-
7
-
8
-
6
+ import type { InferType } from '../../zod-utils.js';
9
7
 
10
8
  export const PickupPointSchema = z.looseObject({
11
9
  identifier: z.object({
12
- key: z.string().default('').nonoptional()
13
- }).default(() => ({ key: '' })),
14
- name: z.string().default(''),
15
- description: z.string().default(''),
16
- address: AddressSchema.default(() => AddressSchema.parse({})),
17
- openingHours: z.string().default('').optional().describe('The opening hours of the pickup point, if applicable. This could be a string like "Mon-Fri 9am-5pm".'),
18
- contactPhone: z.string().default('').optional().describe('The contact phone number for the pickup point, if applicable.'),
19
- contactEmail: z.string().default('').optional().describe('The contact email for the pickup point, if applicable.'),
20
- instructions: z.string().default('').optional().describe('Any special instructions for picking up from this point.'),
10
+ key: z.string()
11
+ }),
12
+ name: z.string(),
13
+ description: z.string(),
14
+ address: AddressSchema,
15
+ openingHours: z.string().optional().describe('The opening hours of the pickup point, if applicable. This could be a string like "Mon-Fri 9am-5pm".'),
16
+ contactPhone: z.string().optional().describe('The contact phone number for the pickup point, if applicable.'),
17
+ contactEmail: z.string().optional().describe('The contact email for the pickup point, if applicable.'),
18
+ instructions: z.string().optional().describe('Any special instructions for picking up from this point.'),
21
19
  });
22
20
 
23
-
24
21
  export const ShippingMethodSchema = z.looseObject({
25
- identifier: ShippingMethodIdentifierSchema.default(() => ShippingMethodIdentifierSchema.parse({})),
26
- name: z.string().default(''),
27
- description: z.string().default(''),
22
+ identifier: ShippingMethodIdentifierSchema,
23
+ name: z.string(),
24
+ description: z.string(),
28
25
  logo: ImageSchema.optional(),
29
- price: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})),
30
- deliveryTime: z.string().default(''),
31
- carrier: z.string().default('').optional(),
26
+ price: MonetaryAmountSchema,
27
+ deliveryTime: z.string(),
28
+ carrier: z.string().optional(),
32
29
  });
33
30
 
34
-
35
31
  export const ShippingInstructionSchema = BaseModelSchema.extend({
36
- shippingMethod: ShippingMethodIdentifierSchema.default(() => ShippingMethodIdentifierSchema.parse({})),
37
- pickupPoint: z.string().default('').describe('An optional pickup point for the shipping method. This could be a physical store, a locker, or similar. If not set, it means home delivery to the shipping address.'),
38
- instructions: z.string().default('').describe('Optional instructions for the shipping. This could be delivery instructions, or similar.'),
39
- consentForUnattendedDelivery: z.boolean().default(false).describe('Indicates if the customer has given consent for unattended delivery, if applicable.'),
32
+ shippingMethod: ShippingMethodIdentifierSchema,
33
+ pickupPoint: z.string().describe('An optional pickup point for the shipping method. This could be a physical store, a locker, or similar. If not set, it means home delivery to the shipping address.'),
34
+ instructions: z.string().describe('Optional instructions for the shipping. This could be delivery instructions, or similar.'),
35
+ consentForUnattendedDelivery: z.boolean().describe('Indicates if the customer has given consent for unattended delivery, if applicable.'),
40
36
  });
41
37
 
42
-
43
- export type ShippingMethod = z.infer<typeof ShippingMethodSchema>;
44
- export type PickupPoint = z.infer<typeof PickupPointSchema>;
45
- export type ShippingInstruction = z.infer<typeof ShippingInstructionSchema>;
38
+ export type ShippingMethod = InferType<typeof ShippingMethodSchema>;
39
+ export type PickupPoint = InferType<typeof PickupPointSchema>;
40
+ export type ShippingInstruction = InferType<typeof ShippingInstructionSchema>;
@@ -1,11 +1,15 @@
1
1
  import { z } from 'zod';
2
2
  import { BaseModelSchema } from './base.model.js';
3
- import { FulfillmentCenterIdentifierSchema, StoreIdentifierSchema } from './identifiers.model.js';
3
+ import {
4
+ FulfillmentCenterIdentifierSchema,
5
+ StoreIdentifierSchema,
6
+ } from './identifiers.model.js';
7
+ import type { InferType } from '../../zod-utils.js';
4
8
 
5
9
  export const StoreSchema = BaseModelSchema.extend({
6
- identifier: StoreIdentifierSchema.default(() => StoreIdentifierSchema.parse({})),
7
- name: z.string().default(''),
8
- fulfillmentCenter: FulfillmentCenterIdentifierSchema.default(() => FulfillmentCenterIdentifierSchema.parse({}))
10
+ identifier: StoreIdentifierSchema,
11
+ name: z.string(),
12
+ fulfillmentCenter: FulfillmentCenterIdentifierSchema,
9
13
  });
10
14
 
11
- export type Store = z.infer<typeof StoreSchema>;
15
+ export type Store = InferType<typeof StoreSchema>;
@@ -1,22 +1,23 @@
1
1
  import { z } from 'zod';
2
2
  import { BaseMutationSchema } from './base.mutation.js';
3
- import { ProductIdentifierSchema, SearchIdentifierSchema } from '../models/identifiers.model.js';
3
+ import { ProductIdentifierSchema, ProductSearchIdentifierSchema } from '../models/identifiers.model.js';
4
+ import type { InferType } from '../../zod-utils.js';
4
5
 
5
6
  export const AnalyticsMutationSearchEventSchema = BaseMutationSchema.extend({
6
7
  mutation: z.literal('search'),
7
- search: SearchIdentifierSchema.required(),
8
+ search: ProductSearchIdentifierSchema,
8
9
  products: z.array(ProductIdentifierSchema),
9
10
  });
10
11
 
11
12
  export const AnalyticsMutationSearchProductClickEventSchema = BaseMutationSchema.extend({
12
13
  mutation: z.literal('product-search-click'),
13
- search: SearchIdentifierSchema.required(),
14
- product: ProductIdentifierSchema.required(),
14
+ search: ProductSearchIdentifierSchema,
15
+ product: ProductIdentifierSchema,
15
16
  position: z.number().min(0)
16
17
  });
17
18
 
18
19
  export const AnalyticsMutationSchema = z.union([AnalyticsMutationSearchEventSchema, AnalyticsMutationSearchProductClickEventSchema]);
19
20
 
20
- export type AnalyticsMutation = z.infer<typeof AnalyticsMutationSchema>;
21
- export type AnalyticsMutationSearchEvent = z.infer<typeof AnalyticsMutationSearchEventSchema>;
22
- export type AnalyticsMutationSearchProductClickEvent = z.infer<typeof AnalyticsMutationSearchProductClickEventSchema>;
21
+ export type AnalyticsMutation = InferType<typeof AnalyticsMutationSchema>;
22
+ export type AnalyticsMutationSearchEvent = InferType<typeof AnalyticsMutationSearchEventSchema>;
23
+ export type AnalyticsMutationSearchProductClickEvent = InferType<typeof AnalyticsMutationSearchProductClickEventSchema>;
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
+ import type { InferType } from '../../zod-utils.js';
2
3
 
3
4
  export const BaseMutationSchema = z.looseObject({
4
5
  });
5
6
 
6
- export type BaseMutation = z.infer<typeof BaseMutationSchema>;
7
+ export type BaseMutation = InferType<typeof BaseMutationSchema>;
@@ -1,83 +1,83 @@
1
1
  import { z } from 'zod';
2
2
  import { BaseMutationSchema } from './base.mutation.js';
3
- import { CartIdentifierSchema, CartItemIdentifierSchema, PaymentMethodIdentifierSchema, ShippingMethodIdentifierSchema, SKUIdentifierSchema } from '../models/identifiers.model.js';
3
+ import { CartIdentifierSchema, CartItemIdentifierSchema, PaymentMethodIdentifierSchema, ShippingMethodIdentifierSchema, ProductVariantIdentifierSchema } from '../models/identifiers.model.js';
4
4
  import { AddressSchema } from '../models/profile.model.js';
5
5
  import { CurrencySchema } from '../models/currency.model.js';
6
6
  import { MonetaryAmountSchema } from '../models/price.model.js';
7
+ import type { InferType } from '../../zod-utils.js';
7
8
 
8
9
  export const CartMutationItemAddSchema = BaseMutationSchema.extend({
9
- cart: CartIdentifierSchema.nonoptional(),
10
- sku: SKUIdentifierSchema.nonoptional(),
10
+ cart: CartIdentifierSchema.optional(),
11
+ variant: ProductVariantIdentifierSchema,
11
12
  quantity: z.number()
12
13
  });
13
14
 
14
15
  export const CartMutationItemRemoveSchema = BaseMutationSchema.extend({
15
- cart: CartIdentifierSchema.nonoptional(),
16
- item: CartItemIdentifierSchema.nonoptional()
16
+ cart: CartIdentifierSchema,
17
+ item: CartItemIdentifierSchema,
17
18
  });
18
19
 
19
20
  export const CartMutationItemQuantityChangeSchema = BaseMutationSchema.extend({
20
- cart: CartIdentifierSchema.nonoptional(),
21
- item: CartItemIdentifierSchema.nonoptional(),
21
+ cart: CartIdentifierSchema,
22
+ item: CartItemIdentifierSchema,
22
23
  quantity: z.number()
23
24
  });
24
25
 
25
26
  export const CartMutationDeleteCartSchema = BaseMutationSchema.extend({
26
- cart: CartIdentifierSchema.required()
27
+ cart: CartIdentifierSchema
27
28
  });
28
29
 
29
30
  export const CartMutationSetShippingInfoSchema = BaseMutationSchema.extend({
30
- cart: CartIdentifierSchema.required(),
31
+ cart: CartIdentifierSchema,
31
32
  shippingMethod: ShippingMethodIdentifierSchema.optional(),
32
33
  shippingAddress: AddressSchema.optional(),
33
34
  });
34
35
 
35
36
  export const CartMutationSetBillingAddressSchema = BaseMutationSchema.extend({
36
- cart: CartIdentifierSchema.required(),
37
- billingAddress: AddressSchema.required(),
37
+ cart: CartIdentifierSchema,
38
+ billingAddress: AddressSchema,
38
39
  notificationEmailAddress: z.string().optional(),
39
40
  notificationPhoneNumber: z.string().optional(),
40
41
  });
41
42
 
42
43
  export const CartMutationApplyCouponSchema = BaseMutationSchema.extend({
43
- cart: CartIdentifierSchema.required(),
44
- couponCode: z.string().default('').nonoptional()
44
+ cart: CartIdentifierSchema,
45
+ couponCode: z.string()
45
46
  });
46
47
 
47
48
  export const CartMutationRemoveCouponSchema = BaseMutationSchema.extend({
48
- cart: CartIdentifierSchema.required(),
49
- couponCode: z.string().default('').nonoptional()
49
+ cart: CartIdentifierSchema,
50
+ couponCode: z.string()
50
51
  });
51
52
 
52
53
  export const CartMutationCheckoutSchema = BaseMutationSchema.extend({
53
- cart: CartIdentifierSchema.required()
54
+ cart: CartIdentifierSchema
54
55
  });
55
56
 
56
57
  export const CartMutationAddPaymentMethodSchema = BaseMutationSchema.extend({
57
- cart: CartIdentifierSchema.required(),
58
- paymentMethodId: PaymentMethodIdentifierSchema.required(),
58
+ cart: CartIdentifierSchema,
59
+ paymentMethodId: PaymentMethodIdentifierSchema,
59
60
  amount: MonetaryAmountSchema.optional().describe('The amount to authorize for the payment method. If not provided, the full remaining balance of the cart will be authorized.')
60
61
  });
61
62
 
62
63
  export const CartMutationRemovePaymentMethodSchema = BaseMutationSchema.extend({
63
- cart: CartIdentifierSchema.required(),
64
+ cart: CartIdentifierSchema,
64
65
  });
65
66
 
66
67
  export const CartMutationChangeCurrencySchema = BaseMutationSchema.extend({
67
68
  cart: CartIdentifierSchema.required(),
68
- newCurrency: CurrencySchema.default(() => CurrencySchema.parse({})).describe('The new currency to set for the cart.')
69
+ newCurrency: CurrencySchema.describe('The new currency to set for the cart.')
69
70
  });
70
71
 
71
-
72
- export type CartMutationChangeCurrency = z.infer<typeof CartMutationChangeCurrencySchema>;
73
- export type CartMutationAddPaymentMethod = z.infer<typeof CartMutationAddPaymentMethodSchema>;
74
- export type CartMutationRemovePaymentMethod = z.infer<typeof CartMutationRemovePaymentMethodSchema>;
75
- export type CartMutationCheckout = z.infer<typeof CartMutationCheckoutSchema>;
76
- export type CartMutationItemAdd = z.infer<typeof CartMutationItemAddSchema>;
77
- export type CartMutationItemRemove = z.infer<typeof CartMutationItemRemoveSchema>;
78
- export type CartMutationItemQuantityChange = z.infer<typeof CartMutationItemQuantityChangeSchema>;
79
- export type CartMutationDeleteCart = z.infer<typeof CartMutationDeleteCartSchema>;
80
- export type CartMutationSetShippingInfo = z.infer<typeof CartMutationSetShippingInfoSchema>;
81
- export type CartMutationSetBillingAddress = z.infer<typeof CartMutationSetBillingAddressSchema>;
82
- export type CartMutationApplyCoupon = z.infer<typeof CartMutationApplyCouponSchema>;
83
- export type CartMutationRemoveCoupon = z.infer<typeof CartMutationRemoveCouponSchema>;
72
+ export type CartMutationChangeCurrency = InferType<typeof CartMutationChangeCurrencySchema>;
73
+ export type CartMutationAddPaymentMethod = InferType<typeof CartMutationAddPaymentMethodSchema>;
74
+ export type CartMutationRemovePaymentMethod = InferType<typeof CartMutationRemovePaymentMethodSchema>;
75
+ export type CartMutationCheckout = InferType<typeof CartMutationCheckoutSchema>;
76
+ export type CartMutationItemAdd = InferType<typeof CartMutationItemAddSchema>;
77
+ export type CartMutationItemRemove = InferType<typeof CartMutationItemRemoveSchema>;
78
+ export type CartMutationItemQuantityChange = InferType<typeof CartMutationItemQuantityChangeSchema>;
79
+ export type CartMutationDeleteCart = InferType<typeof CartMutationDeleteCartSchema>;
80
+ export type CartMutationSetShippingInfo = InferType<typeof CartMutationSetShippingInfoSchema>;
81
+ export type CartMutationSetBillingAddress = InferType<typeof CartMutationSetBillingAddressSchema>;
82
+ export type CartMutationApplyCoupon = InferType<typeof CartMutationApplyCouponSchema>;
83
+ export type CartMutationRemoveCoupon = InferType<typeof CartMutationRemoveCouponSchema>;
@@ -1,50 +1,43 @@
1
- import z from "zod";
2
- import { CartIdentifierSchema, AddressSchema, PaymentInstructionIdentifierSchema, PaymentInstructionSchema, ShippingInstructionSchema } from "../models/index.js";
1
+ import { z } from "zod";
2
+ import { CartIdentifierSchema, AddressSchema, PaymentInstructionIdentifierSchema, PaymentInstructionSchema, ShippingInstructionSchema, CartSchema } from "../models/index.js";
3
3
  import { BaseMutationSchema } from "./base.mutation.js";
4
+ import type { InferType } from '../../zod-utils.js';
4
5
 
5
6
 
6
7
  export const CheckoutMutationInitiateCheckoutSchema = BaseMutationSchema.extend({
7
- cart: CartIdentifierSchema.required(),
8
- billingAddress: AddressSchema.omit({identifier: true}).optional(),
8
+ cart: CartSchema,
9
+ billingAddress: AddressSchema.omit({ identifier: true }).optional(),
9
10
  notificationEmail: z.string().optional(),
10
11
  notificationPhone: z.string().optional(),
11
12
  });
12
13
 
13
14
  export const CheckoutMutationSetShippingAddressSchema = BaseMutationSchema.extend({
14
- checkout: CartIdentifierSchema.required(),
15
- shippingAddress: AddressSchema.omit({identifier: true}).required(),
15
+ checkout: CartIdentifierSchema,
16
+ shippingAddress: AddressSchema.omit({ identifier: true }),
16
17
  });
17
18
 
18
-
19
19
  export const CheckoutMutationFinalizeCheckoutSchema = BaseMutationSchema.extend({
20
- checkout: CartIdentifierSchema.required(),
20
+ checkout: CartIdentifierSchema,
21
21
  });
22
22
 
23
-
24
- export const CheckoutMutationAddPaymentInstruction = BaseMutationSchema.extend({
25
- paymentInstruction: PaymentInstructionSchema.omit({ meta: true, status: true, identifier: true }).required(),
26
- checkout: CartIdentifierSchema.required()
23
+ export const CheckoutMutationAddPaymentInstructionSchema = BaseMutationSchema.extend({
24
+ paymentInstruction: PaymentInstructionSchema.omit({ status: true, identifier: true }),
25
+ checkout: CartIdentifierSchema,
27
26
  });
28
27
 
29
- export const CheckoutMutationRemovePaymentInstruction = BaseMutationSchema.extend({
30
- paymentInstruction: PaymentInstructionIdentifierSchema.required(),
31
- checkout: CartIdentifierSchema.required()
28
+ export const CheckoutMutationRemovePaymentInstructionSchema = BaseMutationSchema.extend({
29
+ paymentInstruction: PaymentInstructionIdentifierSchema,
30
+ checkout: CartIdentifierSchema,
32
31
  });
33
32
 
34
-
35
-
36
- export const CheckoutMutationSetShippingInstruction = BaseMutationSchema.extend({
37
- shippingInstruction: ShippingInstructionSchema.omit({ meta: true, status: true, identifier: true }).required(),
38
- checkout: CartIdentifierSchema.required()
33
+ export const CheckoutMutationSetShippingInstructionSchema = BaseMutationSchema.extend({
34
+ shippingInstruction: ShippingInstructionSchema,
35
+ checkout: CartIdentifierSchema,
39
36
  });
40
37
 
41
-
42
-
43
-
44
-
45
- export type CheckoutMutationInitiateCheckout = z.infer<typeof CheckoutMutationInitiateCheckoutSchema>;
46
- export type CheckoutMutationSetShippingAddress = z.infer<typeof CheckoutMutationSetShippingAddressSchema>;
47
- export type CheckoutMutationFinalizeCheckout = z.infer<typeof CheckoutMutationFinalizeCheckoutSchema>;
48
- export type CheckoutMutationAddPaymentInstruction = z.infer<typeof CheckoutMutationAddPaymentInstruction>;
49
- export type CheckoutMutationRemovePaymentInstruction = z.infer<typeof CheckoutMutationRemovePaymentInstruction>;
50
- export type CheckoutMutationSetShippingInstruction = z.infer<typeof CheckoutMutationSetShippingInstruction>;
38
+ export type CheckoutMutationInitiateCheckout = InferType<typeof CheckoutMutationInitiateCheckoutSchema>;
39
+ export type CheckoutMutationSetShippingAddress = InferType<typeof CheckoutMutationSetShippingAddressSchema>;
40
+ export type CheckoutMutationFinalizeCheckout = InferType<typeof CheckoutMutationFinalizeCheckoutSchema>;
41
+ export type CheckoutMutationAddPaymentInstruction = InferType<typeof CheckoutMutationAddPaymentInstructionSchema>;
42
+ export type CheckoutMutationRemovePaymentInstruction = InferType<typeof CheckoutMutationRemovePaymentInstructionSchema>;
43
+ export type CheckoutMutationSetShippingInstruction = InferType<typeof CheckoutMutationSetShippingInstructionSchema>;
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { BaseMutationSchema } from './base.mutation.js';
3
+ import type { InferType } from '../../zod-utils.js';
3
4
 
4
5
  export const IdentityMutationLoginSchema = BaseMutationSchema.extend({
5
6
  username: z.string(),
@@ -15,6 +16,6 @@ export const IdentityMutationRegisterSchema = BaseMutationSchema.extend({
15
16
  });
16
17
 
17
18
 
18
- export type IdentityMutationLogin = z.infer<typeof IdentityMutationLoginSchema>;
19
- export type IdentityMutationLogout = z.infer<typeof IdentityMutationLogoutSchema>;
20
- export type IdentityMutationRegister = z.infer<typeof IdentityMutationRegisterSchema>;
19
+ export type IdentityMutationLogin = InferType<typeof IdentityMutationLoginSchema>;
20
+ export type IdentityMutationLogout = InferType<typeof IdentityMutationLogoutSchema>;
21
+ export type IdentityMutationRegister = InferType<typeof IdentityMutationRegisterSchema>;
@@ -1,9 +1,44 @@
1
1
  import { z } from 'zod';
2
2
  import { BaseMutationSchema } from './base.mutation.js';
3
+ import type { InferType } from '../../zod-utils.js';
4
+ import { AddressIdentifierSchema, IdentityIdentifierSchema } from '../models/identifiers.model.js';
5
+ import { AddressSchema } from '../models/profile.model.js';
3
6
 
4
7
  export const ProfileMutationUpdateSchema = BaseMutationSchema.extend({
5
- email: z.email().default('base@example.com'),
6
- phone: z.string().default(''),
8
+ identifier: IdentityIdentifierSchema,
9
+ email: z.email().describe('The main contact email of the profile'),
10
+ phone: z.string().describe('The main phone number of the profile'),
7
11
  });
8
12
 
9
- export type ProfileMutationUpdate = z.infer<typeof ProfileMutationUpdateSchema>;
13
+ export const ProfileMutationAddShippingAddressSchema = BaseMutationSchema.extend({
14
+ identifier: IdentityIdentifierSchema,
15
+ address: AddressSchema,
16
+ });
17
+
18
+ export const ProfileMutationRemoveShippingAddressSchema = BaseMutationSchema.extend({
19
+ identifier: IdentityIdentifierSchema,
20
+ addressIdentifier: AddressIdentifierSchema,
21
+ });
22
+
23
+ export const ProfileMutationUpdateShippingAddressSchema = BaseMutationSchema.extend({
24
+ identifier: IdentityIdentifierSchema,
25
+ address: AddressSchema,
26
+ });
27
+
28
+ export const ProfileMutationMakeShippingAddressDefaultSchema = BaseMutationSchema.extend({
29
+ identifier: IdentityIdentifierSchema,
30
+ addressIdentifier: AddressIdentifierSchema,
31
+ });
32
+
33
+ export const ProfileMutationSetBillingAddressSchema = BaseMutationSchema.extend({
34
+ identifier: IdentityIdentifierSchema,
35
+ address: AddressSchema,
36
+ });
37
+
38
+
39
+ export type ProfileMutationUpdate = InferType<typeof ProfileMutationUpdateSchema>;
40
+ export type ProfileMutationAddShippingAddress = InferType<typeof ProfileMutationAddShippingAddressSchema>;
41
+ export type ProfileMutationRemoveShippingAddress = InferType<typeof ProfileMutationRemoveShippingAddressSchema>;
42
+ export type ProfileMutationMakeShippingAddressDefault = InferType<typeof ProfileMutationMakeShippingAddressDefaultSchema>;
43
+ export type ProfileMutationSetBillingAddress = InferType<typeof ProfileMutationSetBillingAddressSchema>;
44
+ export type ProfileMutationUpdateShippingAddress = InferType<typeof ProfileMutationUpdateShippingAddressSchema>;
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
+ import type { InferType } from '../../zod-utils.js';
2
3
 
3
4
  export const BaseQuerySchema = z.looseObject({
4
5
  });
5
6
 
6
- export type BaseQuery = z.infer<typeof BaseQuerySchema>;
7
+ export type BaseQuery = InferType<typeof BaseQuerySchema>;
@@ -1,9 +1,9 @@
1
- import type { z } from 'zod';
2
1
  import { BaseQuerySchema } from './base.query.js';
3
2
  import { CartIdentifierSchema } from '../models/identifiers.model.js';
3
+ import type { InferType } from '../../zod-utils.js';
4
4
 
5
5
  export const CartQueryByIdSchema = BaseQuerySchema.extend({
6
- cart: CartIdentifierSchema.required()
6
+ cart: CartIdentifierSchema
7
7
  });
8
8
 
9
- export type CartQueryById = z.infer<typeof CartQueryByIdSchema>;
9
+ export type CartQueryById = InferType<typeof CartQueryByIdSchema>;
@@ -1,32 +1,32 @@
1
- import z from "zod";
1
+ import { z } from "zod";
2
2
  import { CategoryIdentifierSchema } from "../models/identifiers.model.js";
3
3
  import { BaseQuerySchema } from "./base.query.js";
4
4
  import { PaginationOptionsSchema } from "../models/base.model.js";
5
+ import type { InferType } from '../../zod-utils.js';
5
6
 
6
- export const CategoryQueryById = BaseQuerySchema.extend({
7
- id: CategoryIdentifierSchema.default(() => CategoryIdentifierSchema.parse({})),
7
+ export const CategoryQueryByIdSchema = BaseQuerySchema.extend({
8
+ id: CategoryIdentifierSchema,
8
9
  });
9
10
 
10
- export const CategoryQueryBySlug = BaseQuerySchema.extend({
11
- slug: z.string().default(''),
11
+ export const CategoryQueryBySlugSchema = BaseQuerySchema.extend({
12
+ slug: z.string(),
12
13
  });
13
14
 
14
- export const CategoryQueryForBreadcrumb = BaseQuerySchema.extend({
15
- id: CategoryIdentifierSchema.default(() => CategoryIdentifierSchema.parse({})),
15
+ export const CategoryQueryForBreadcrumbSchema = BaseQuerySchema.extend({
16
+ id: CategoryIdentifierSchema,
16
17
  });
17
18
 
18
- export const CategoryQueryForChildCategories = BaseQuerySchema.extend({
19
- parentId: CategoryIdentifierSchema.default(() => CategoryIdentifierSchema.parse({})),
20
- paginationOptions: PaginationOptionsSchema.default(() => PaginationOptionsSchema.parse({})),
19
+ export const CategoryQueryForChildCategoriesSchema = BaseQuerySchema.extend({
20
+ parentId: CategoryIdentifierSchema,
21
+ paginationOptions: PaginationOptionsSchema,
21
22
  });
22
23
 
23
- export const CategoryQueryForTopCategories = BaseQuerySchema.extend({
24
- paginationOptions: PaginationOptionsSchema.default(() => PaginationOptionsSchema.parse({})),
24
+ export const CategoryQueryForTopCategoriesSchema = BaseQuerySchema.extend({
25
+ paginationOptions: PaginationOptionsSchema,
25
26
  });
26
27
 
27
-
28
- export type CategoryQueryById = z.infer<typeof CategoryQueryById>;
29
- export type CategoryQueryBySlug = z.infer<typeof CategoryQueryBySlug>;
30
- export type CategoryQueryForBreadcrumb = z.infer<typeof CategoryQueryForBreadcrumb>;
31
- export type CategoryQueryForChildCategories = z.infer<typeof CategoryQueryForChildCategories>;
32
- export type CategoryQueryForTopCategories = z.infer<typeof CategoryQueryForTopCategories>;
28
+ export type CategoryQueryById = InferType<typeof CategoryQueryByIdSchema>;
29
+ export type CategoryQueryBySlug = InferType<typeof CategoryQueryBySlugSchema>;
30
+ export type CategoryQueryForBreadcrumb = InferType<typeof CategoryQueryForBreadcrumbSchema>;
31
+ export type CategoryQueryForChildCategories = InferType<typeof CategoryQueryForChildCategoriesSchema>;
32
+ export type CategoryQueryForTopCategories = InferType<typeof CategoryQueryForTopCategoriesSchema>;