@reactionary/medusa 0.6.3

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 (72) hide show
  1. package/README.md +11 -0
  2. package/capabilities/cart.capability.js +517 -0
  3. package/capabilities/category.capability.js +216 -0
  4. package/capabilities/checkout.capability.js +533 -0
  5. package/capabilities/identity.capability.js +128 -0
  6. package/capabilities/inventory.capability.js +142 -0
  7. package/capabilities/order-search.capability.js +161 -0
  8. package/capabilities/order.capability.js +179 -0
  9. package/capabilities/price.capability.js +120 -0
  10. package/capabilities/product-associations.capability.js +148 -0
  11. package/capabilities/product-recommendations.capability.js +116 -0
  12. package/capabilities/product-search.capability.js +177 -0
  13. package/capabilities/product.capability.js +252 -0
  14. package/capabilities/profile.capability.js +333 -0
  15. package/core/client.js +269 -0
  16. package/core/initialize.js +290 -0
  17. package/core/initialize.types.js +13 -0
  18. package/factories/cart/cart.factory.js +17 -0
  19. package/factories/category/category.factory.js +17 -0
  20. package/factories/checkout/checkout.factory.js +22 -0
  21. package/factories/identity/identity.factory.js +12 -0
  22. package/factories/index.js +12 -0
  23. package/factories/inventory/inventory.factory.js +12 -0
  24. package/factories/order/order.factory.js +12 -0
  25. package/factories/order-search/order-search.factory.js +12 -0
  26. package/factories/price/price.factory.js +12 -0
  27. package/factories/product/product.factory.js +12 -0
  28. package/factories/product-associations/product-associations.factory.js +12 -0
  29. package/factories/product-search/product-search.factory.js +12 -0
  30. package/factories/profile/profile.factory.js +12 -0
  31. package/index.js +17 -0
  32. package/package.json +17 -0
  33. package/schema/capabilities.schema.js +43 -0
  34. package/schema/configuration.schema.js +11 -0
  35. package/schema/medusa.schema.js +26 -0
  36. package/src/capabilities/cart.capability.d.ts +100 -0
  37. package/src/capabilities/category.capability.d.ts +36 -0
  38. package/src/capabilities/checkout.capability.d.ts +88 -0
  39. package/src/capabilities/identity.capability.d.ts +13 -0
  40. package/src/capabilities/inventory.capability.d.ts +21 -0
  41. package/src/capabilities/order-search.capability.d.ts +53 -0
  42. package/src/capabilities/order.capability.d.ts +49 -0
  43. package/src/capabilities/price.capability.d.ts +16 -0
  44. package/src/capabilities/product-associations.capability.d.ts +19 -0
  45. package/src/capabilities/product-recommendations.capability.d.ts +41 -0
  46. package/src/capabilities/product-search.capability.d.ts +45 -0
  47. package/src/capabilities/product.capability.d.ts +32 -0
  48. package/src/capabilities/profile.capability.d.ts +39 -0
  49. package/src/core/client.d.ts +81 -0
  50. package/src/core/initialize.d.ts +5 -0
  51. package/src/core/initialize.types.d.ts +108 -0
  52. package/src/factories/cart/cart.factory.d.ts +9 -0
  53. package/src/factories/category/category.factory.d.ts +9 -0
  54. package/src/factories/checkout/checkout.factory.d.ts +11 -0
  55. package/src/factories/identity/identity.factory.d.ts +7 -0
  56. package/src/factories/index.d.ts +12 -0
  57. package/src/factories/inventory/inventory.factory.d.ts +7 -0
  58. package/src/factories/order/order.factory.d.ts +7 -0
  59. package/src/factories/order-search/order-search.factory.d.ts +7 -0
  60. package/src/factories/price/price.factory.d.ts +9 -0
  61. package/src/factories/product/product.factory.d.ts +7 -0
  62. package/src/factories/product-associations/product-associations.factory.d.ts +7 -0
  63. package/src/factories/product-search/product-search.factory.d.ts +7 -0
  64. package/src/factories/profile/profile.factory.d.ts +7 -0
  65. package/src/index.d.ts +17 -0
  66. package/src/schema/capabilities.schema.d.ts +116 -0
  67. package/src/schema/configuration.schema.d.ts +9 -0
  68. package/src/schema/medusa.schema.d.ts +33 -0
  69. package/src/test/test-utils.d.ts +2 -0
  70. package/src/utils/medusa-helpers.d.ts +35 -0
  71. package/test/test-utils.js +12 -0
  72. package/utils/medusa-helpers.js +72 -0
@@ -0,0 +1,290 @@
1
+ import {
2
+ CartIdentifierSchema,
3
+ CartSchema,
4
+ CategoryPaginatedResultSchema,
5
+ CategorySchema,
6
+ CheckoutSchema,
7
+ InventorySchema,
8
+ OrderSchema,
9
+ OrderSearchResultSchema,
10
+ PaymentMethodSchema,
11
+ PriceSchema,
12
+ ProductAssociationSchema,
13
+ ProductSchema,
14
+ ProductSearchResultSchema,
15
+ ProfileSchema,
16
+ ShippingMethodSchema
17
+ } from "@reactionary/core";
18
+ import { MedusaCartCapability } from "../capabilities/cart.capability.js";
19
+ import { MedusaCategoryCapability } from "../capabilities/category.capability.js";
20
+ import { MedusaCheckoutCapability } from "../capabilities/checkout.capability.js";
21
+ import { MedusaIdentityCapability } from "../capabilities/identity.capability.js";
22
+ import { MedusaInventoryCapability } from "../capabilities/inventory.capability.js";
23
+ import { MedusaOrderSearchCapability } from "../capabilities/order-search.capability.js";
24
+ import { MedusaOrderCapability } from "../capabilities/order.capability.js";
25
+ import { MedusaPriceCapability } from "../capabilities/price.capability.js";
26
+ import { MedusaProductSearchCapability } from "../capabilities/product-search.capability.js";
27
+ import { MedusaProductRecommendationsCapability } from "../capabilities/product-recommendations.capability.js";
28
+ import { MedusaProductCapability } from "../capabilities/product.capability.js";
29
+ import { MedusaProductAssociationsCapability } from "../capabilities/product-associations.capability.js";
30
+ import { MedusaProfileCapability } from "../capabilities/profile.capability.js";
31
+ import {
32
+ MedusaCapabilitiesSchema
33
+ } from "../schema/capabilities.schema.js";
34
+ import {
35
+ MedusaConfigurationSchema
36
+ } from "../schema/configuration.schema.js";
37
+ import { MedusaAPI } from "./client.js";
38
+ import {
39
+ MedusaCartFactory,
40
+ MedusaCategoryFactory,
41
+ MedusaCheckoutFactory,
42
+ MedusaInventoryFactory,
43
+ MedusaOrderFactory,
44
+ MedusaOrderSearchFactory,
45
+ MedusaPriceFactory,
46
+ MedusaProductAssociationsFactory,
47
+ MedusaProductFactory,
48
+ MedusaProductSearchFactory,
49
+ MedusaProfileFactory
50
+ } from "../factories/index.js";
51
+ import {
52
+ resolveCapabilityWithFactory,
53
+ resolveDirectCapability
54
+ } from "./initialize.types.js";
55
+ function withMedusaCapabilities(configuration, capabilities) {
56
+ return (cache, context) => {
57
+ const client = {};
58
+ const config = MedusaConfigurationSchema.parse(configuration);
59
+ const caps = MedusaCapabilitiesSchema.parse(capabilities);
60
+ const medusaApi = new MedusaAPI(config, context);
61
+ const buildCapabilityArgs = (factory) => ({
62
+ cache,
63
+ context,
64
+ config,
65
+ medusaApi,
66
+ factory
67
+ });
68
+ if (caps.product?.enabled) {
69
+ client.product = resolveCapabilityWithFactory(
70
+ capabilities.product,
71
+ {
72
+ factory: new MedusaProductFactory(ProductSchema),
73
+ capability: (args) => new MedusaProductCapability(
74
+ args.config,
75
+ args.cache,
76
+ args.context,
77
+ args.medusaApi,
78
+ args.factory
79
+ )
80
+ },
81
+ buildCapabilityArgs
82
+ );
83
+ }
84
+ if (caps.productSearch?.enabled) {
85
+ client.productSearch = resolveCapabilityWithFactory(
86
+ capabilities.productSearch,
87
+ {
88
+ factory: new MedusaProductSearchFactory(ProductSearchResultSchema),
89
+ capability: (args) => new MedusaProductSearchCapability(
90
+ args.config,
91
+ args.cache,
92
+ args.context,
93
+ args.medusaApi,
94
+ args.factory
95
+ )
96
+ },
97
+ buildCapabilityArgs
98
+ );
99
+ }
100
+ if (caps.category?.enabled) {
101
+ client.category = resolveCapabilityWithFactory(
102
+ capabilities.category,
103
+ {
104
+ factory: new MedusaCategoryFactory(
105
+ CategorySchema,
106
+ CategoryPaginatedResultSchema
107
+ ),
108
+ capability: (args) => new MedusaCategoryCapability(
109
+ args.config,
110
+ args.cache,
111
+ args.context,
112
+ args.medusaApi,
113
+ args.factory
114
+ )
115
+ },
116
+ buildCapabilityArgs
117
+ );
118
+ }
119
+ if (caps.checkout?.enabled) {
120
+ client.checkout = resolveCapabilityWithFactory(
121
+ capabilities.checkout,
122
+ {
123
+ factory: new MedusaCheckoutFactory(
124
+ CheckoutSchema,
125
+ ShippingMethodSchema,
126
+ PaymentMethodSchema
127
+ ),
128
+ capability: (args) => new MedusaCheckoutCapability(
129
+ args.config,
130
+ args.cache,
131
+ args.context,
132
+ args.medusaApi,
133
+ args.factory
134
+ )
135
+ },
136
+ buildCapabilityArgs
137
+ );
138
+ }
139
+ if (caps.productRecommendations?.enabled) {
140
+ client.productRecommendations = resolveDirectCapability(
141
+ capabilities.productRecommendations,
142
+ (args) => new MedusaProductRecommendationsCapability(
143
+ args.config,
144
+ args.cache,
145
+ args.context,
146
+ args.medusaApi
147
+ ),
148
+ {
149
+ cache,
150
+ context,
151
+ config,
152
+ medusaApi
153
+ }
154
+ );
155
+ }
156
+ if (caps.cart?.enabled) {
157
+ client.cart = resolveCapabilityWithFactory(
158
+ capabilities.cart,
159
+ {
160
+ factory: new MedusaCartFactory(CartSchema, CartIdentifierSchema),
161
+ capability: (args) => new MedusaCartCapability(
162
+ args.config,
163
+ args.cache,
164
+ args.context,
165
+ args.medusaApi,
166
+ args.factory
167
+ )
168
+ },
169
+ buildCapabilityArgs
170
+ );
171
+ }
172
+ if (caps.price?.enabled) {
173
+ client.price = resolveCapabilityWithFactory(
174
+ capabilities.price,
175
+ {
176
+ factory: new MedusaPriceFactory(PriceSchema),
177
+ capability: (args) => new MedusaPriceCapability(
178
+ args.config,
179
+ args.cache,
180
+ args.context,
181
+ args.medusaApi,
182
+ args.factory
183
+ )
184
+ },
185
+ buildCapabilityArgs
186
+ );
187
+ }
188
+ if (caps.inventory?.enabled) {
189
+ client.inventory = resolveCapabilityWithFactory(
190
+ capabilities.inventory,
191
+ {
192
+ factory: new MedusaInventoryFactory(InventorySchema),
193
+ capability: (args) => new MedusaInventoryCapability(
194
+ args.config,
195
+ args.cache,
196
+ args.context,
197
+ args.medusaApi,
198
+ args.factory
199
+ )
200
+ },
201
+ buildCapabilityArgs
202
+ );
203
+ }
204
+ if (caps.identity?.enabled) {
205
+ client.identity = resolveDirectCapability(
206
+ capabilities.identity,
207
+ (args) => new MedusaIdentityCapability(
208
+ args.config,
209
+ args.cache,
210
+ args.context,
211
+ args.medusaApi
212
+ ),
213
+ {
214
+ cache,
215
+ context,
216
+ config,
217
+ medusaApi
218
+ }
219
+ );
220
+ }
221
+ if (caps.profile?.enabled) {
222
+ client.profile = resolveCapabilityWithFactory(
223
+ capabilities.profile,
224
+ {
225
+ factory: new MedusaProfileFactory(ProfileSchema),
226
+ capability: (args) => new MedusaProfileCapability(
227
+ args.config,
228
+ args.cache,
229
+ args.context,
230
+ args.medusaApi,
231
+ args.factory
232
+ )
233
+ },
234
+ buildCapabilityArgs
235
+ );
236
+ }
237
+ if (caps.order?.enabled) {
238
+ client.order = resolveCapabilityWithFactory(
239
+ capabilities.order,
240
+ {
241
+ factory: new MedusaOrderFactory(OrderSchema),
242
+ capability: (args) => new MedusaOrderCapability(
243
+ args.config,
244
+ args.cache,
245
+ args.context,
246
+ args.medusaApi,
247
+ args.factory
248
+ )
249
+ },
250
+ buildCapabilityArgs
251
+ );
252
+ }
253
+ if (caps.orderSearch?.enabled) {
254
+ client.orderSearch = resolveCapabilityWithFactory(
255
+ capabilities.orderSearch,
256
+ {
257
+ factory: new MedusaOrderSearchFactory(OrderSearchResultSchema),
258
+ capability: (args) => new MedusaOrderSearchCapability(
259
+ args.config,
260
+ args.cache,
261
+ args.context,
262
+ args.medusaApi,
263
+ args.factory
264
+ )
265
+ },
266
+ buildCapabilityArgs
267
+ );
268
+ }
269
+ if (caps.productAssociations?.enabled) {
270
+ client.productAssociations = resolveCapabilityWithFactory(
271
+ capabilities.productAssociations,
272
+ {
273
+ factory: new MedusaProductAssociationsFactory(ProductAssociationSchema),
274
+ capability: (args) => new MedusaProductAssociationsCapability(
275
+ args.config,
276
+ args.cache,
277
+ args.context,
278
+ args.medusaApi,
279
+ args.factory
280
+ )
281
+ },
282
+ buildCapabilityArgs
283
+ );
284
+ }
285
+ return client;
286
+ };
287
+ }
288
+ export {
289
+ withMedusaCapabilities
290
+ };
@@ -0,0 +1,13 @@
1
+ function resolveCapabilityWithFactory(capability, defaults, buildCapabilityArgs) {
2
+ const factory = capability?.factory ?? defaults.factory;
3
+ const capabilityFactory = capability?.capability ?? defaults.capability;
4
+ return capabilityFactory(buildCapabilityArgs(factory));
5
+ }
6
+ function resolveDirectCapability(capability, defaultCapability, args) {
7
+ const capabilityFactory = capability?.capability ?? defaultCapability;
8
+ return capabilityFactory(args);
9
+ }
10
+ export {
11
+ resolveCapabilityWithFactory,
12
+ resolveDirectCapability
13
+ };
@@ -0,0 +1,17 @@
1
+ class MedusaCartFactory {
2
+ cartSchema;
3
+ cartIdentifierSchema;
4
+ constructor(cartSchema, cartIdentifierSchema) {
5
+ this.cartSchema = cartSchema;
6
+ this.cartIdentifierSchema = cartIdentifierSchema;
7
+ }
8
+ parseCart(_context, data) {
9
+ return this.cartSchema.parse(data);
10
+ }
11
+ parseCartIdentifier(_context, data) {
12
+ return this.cartIdentifierSchema.parse(data);
13
+ }
14
+ }
15
+ export {
16
+ MedusaCartFactory
17
+ };
@@ -0,0 +1,17 @@
1
+ class MedusaCategoryFactory {
2
+ categorySchema;
3
+ categoryPaginatedResultSchema;
4
+ constructor(categorySchema, categoryPaginatedResultSchema) {
5
+ this.categorySchema = categorySchema;
6
+ this.categoryPaginatedResultSchema = categoryPaginatedResultSchema;
7
+ }
8
+ parseCategory(_context, data) {
9
+ return this.categorySchema.parse(data);
10
+ }
11
+ parseCategoryPaginatedResult(_context, data) {
12
+ return this.categoryPaginatedResultSchema.parse(data);
13
+ }
14
+ }
15
+ export {
16
+ MedusaCategoryFactory
17
+ };
@@ -0,0 +1,22 @@
1
+ class MedusaCheckoutFactory {
2
+ checkoutSchema;
3
+ shippingMethodSchema;
4
+ paymentMethodSchema;
5
+ constructor(checkoutSchema, shippingMethodSchema, paymentMethodSchema) {
6
+ this.checkoutSchema = checkoutSchema;
7
+ this.shippingMethodSchema = shippingMethodSchema;
8
+ this.paymentMethodSchema = paymentMethodSchema;
9
+ }
10
+ parseCheckout(_context, data) {
11
+ return this.checkoutSchema.parse(data);
12
+ }
13
+ parseShippingMethod(_context, data) {
14
+ return this.shippingMethodSchema.parse(data);
15
+ }
16
+ parsePaymentMethod(_context, data) {
17
+ return this.paymentMethodSchema.parse(data);
18
+ }
19
+ }
20
+ export {
21
+ MedusaCheckoutFactory
22
+ };
@@ -0,0 +1,12 @@
1
+ class MedusaIdentityFactory {
2
+ identitySchema;
3
+ constructor(identitySchema) {
4
+ this.identitySchema = identitySchema;
5
+ }
6
+ parseIdentity(_context, data) {
7
+ return this.identitySchema.parse(data);
8
+ }
9
+ }
10
+ export {
11
+ MedusaIdentityFactory
12
+ };
@@ -0,0 +1,12 @@
1
+ export * from "./cart/cart.factory.js";
2
+ export * from "./category/category.factory.js";
3
+ export * from "./checkout/checkout.factory.js";
4
+ export * from "./identity/identity.factory.js";
5
+ export * from "./inventory/inventory.factory.js";
6
+ export * from "./order/order.factory.js";
7
+ export * from "./order-search/order-search.factory.js";
8
+ export * from "./price/price.factory.js";
9
+ export * from "./product/product.factory.js";
10
+ export * from "./product-associations/product-associations.factory.js";
11
+ export * from "./product-search/product-search.factory.js";
12
+ export * from "./profile/profile.factory.js";
@@ -0,0 +1,12 @@
1
+ class MedusaInventoryFactory {
2
+ inventorySchema;
3
+ constructor(inventorySchema) {
4
+ this.inventorySchema = inventorySchema;
5
+ }
6
+ parseInventory(_context, data) {
7
+ return this.inventorySchema.parse(data);
8
+ }
9
+ }
10
+ export {
11
+ MedusaInventoryFactory
12
+ };
@@ -0,0 +1,12 @@
1
+ class MedusaOrderFactory {
2
+ orderSchema;
3
+ constructor(orderSchema) {
4
+ this.orderSchema = orderSchema;
5
+ }
6
+ parseOrder(_context, data) {
7
+ return this.orderSchema.parse(data);
8
+ }
9
+ }
10
+ export {
11
+ MedusaOrderFactory
12
+ };
@@ -0,0 +1,12 @@
1
+ class MedusaOrderSearchFactory {
2
+ orderSearchResultSchema;
3
+ constructor(orderSearchResultSchema) {
4
+ this.orderSearchResultSchema = orderSearchResultSchema;
5
+ }
6
+ parseOrderSearchResult(_context, data, _query) {
7
+ return this.orderSearchResultSchema.parse(data);
8
+ }
9
+ }
10
+ export {
11
+ MedusaOrderSearchFactory
12
+ };
@@ -0,0 +1,12 @@
1
+ class MedusaPriceFactory {
2
+ priceSchema;
3
+ constructor(priceSchema) {
4
+ this.priceSchema = priceSchema;
5
+ }
6
+ parsePrice(_context, data, _options) {
7
+ return this.priceSchema.parse(data);
8
+ }
9
+ }
10
+ export {
11
+ MedusaPriceFactory
12
+ };
@@ -0,0 +1,12 @@
1
+ class MedusaProductFactory {
2
+ productSchema;
3
+ constructor(productSchema) {
4
+ this.productSchema = productSchema;
5
+ }
6
+ parseProduct(_context, data) {
7
+ return this.productSchema.parse(data);
8
+ }
9
+ }
10
+ export {
11
+ MedusaProductFactory
12
+ };
@@ -0,0 +1,12 @@
1
+ class MedusaProductAssociationsFactory {
2
+ productAssociationSchema;
3
+ constructor(productAssociationSchema) {
4
+ this.productAssociationSchema = productAssociationSchema;
5
+ }
6
+ parseAssociation(_context, data) {
7
+ return this.productAssociationSchema.parse(data);
8
+ }
9
+ }
10
+ export {
11
+ MedusaProductAssociationsFactory
12
+ };
@@ -0,0 +1,12 @@
1
+ class MedusaProductSearchFactory {
2
+ productSearchResultSchema;
3
+ constructor(productSearchResultSchema) {
4
+ this.productSearchResultSchema = productSearchResultSchema;
5
+ }
6
+ parseSearchResult(_context, data, _query) {
7
+ return this.productSearchResultSchema.parse(data);
8
+ }
9
+ }
10
+ export {
11
+ MedusaProductSearchFactory
12
+ };
@@ -0,0 +1,12 @@
1
+ class MedusaProfileFactory {
2
+ profileSchema;
3
+ constructor(profileSchema) {
4
+ this.profileSchema = profileSchema;
5
+ }
6
+ parseProfile(_context, data) {
7
+ return this.profileSchema.parse(data);
8
+ }
9
+ }
10
+ export {
11
+ MedusaProfileFactory
12
+ };
package/index.js ADDED
@@ -0,0 +1,17 @@
1
+ export * from "./schema/configuration.schema.js";
2
+ export * from "./schema/medusa.schema.js";
3
+ export * from "./schema/capabilities.schema.js";
4
+ export * from "./core/initialize.js";
5
+ export * from "./core/initialize.types.js";
6
+ export * from "./core/client.js";
7
+ export * from "./factories/index.js";
8
+ export * from "./capabilities/cart.capability.js";
9
+ export * from "./capabilities/identity.capability.js";
10
+ export * from "./capabilities/inventory.capability.js";
11
+ export * from "./capabilities/order.capability.js";
12
+ export * from "./capabilities/order-search.capability.js";
13
+ export * from "./capabilities/price.capability.js";
14
+ export * from "./capabilities/product-search.capability.js";
15
+ export * from "./capabilities/product-recommendations.capability.js";
16
+ export * from "./capabilities/product-associations.capability.js";
17
+ export * from "./capabilities/profile.capability.js";
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@reactionary/medusa",
3
+ "version": "0.6.3",
4
+ "type": "module",
5
+ "main": "./index.js",
6
+ "types": "./src/index.d.ts",
7
+ "dependencies": {
8
+ "@medusajs/js-sdk": "^2.13.3",
9
+ "@reactionary/core": "0.6.3",
10
+ "debug": "^4.4.3",
11
+ "@medusajs/types": "^2.13.3",
12
+ "zod": "4.1.9",
13
+ "vitest": "^4.0.9",
14
+ "@nx/vite": "22.4.5"
15
+ },
16
+ "sideEffects": false
17
+ }
@@ -0,0 +1,43 @@
1
+ import { CapabilitiesSchema } from "@reactionary/core";
2
+ import * as z from "zod";
3
+ const OverridableCapabilitySchema = z.looseObject({
4
+ enabled: z.boolean(),
5
+ factory: z.unknown().optional(),
6
+ capability: z.unknown().optional()
7
+ });
8
+ const DirectCapabilitySchema = z.looseObject({
9
+ enabled: z.boolean(),
10
+ capability: z.unknown().optional()
11
+ });
12
+ const MedusaCapabilitiesSchema = CapabilitiesSchema.pick({
13
+ productSearch: true,
14
+ productRecommendations: true,
15
+ cart: true,
16
+ checkout: true,
17
+ category: true,
18
+ product: true,
19
+ price: true,
20
+ order: true,
21
+ orderSearch: true,
22
+ inventory: true,
23
+ identity: true,
24
+ profile: true,
25
+ productAssociations: true
26
+ }).extend({
27
+ product: OverridableCapabilitySchema.optional(),
28
+ productSearch: OverridableCapabilitySchema.optional(),
29
+ cart: OverridableCapabilitySchema.optional(),
30
+ checkout: OverridableCapabilitySchema.optional(),
31
+ category: OverridableCapabilitySchema.optional(),
32
+ price: OverridableCapabilitySchema.optional(),
33
+ order: OverridableCapabilitySchema.optional(),
34
+ orderSearch: OverridableCapabilitySchema.optional(),
35
+ inventory: OverridableCapabilitySchema.optional(),
36
+ identity: DirectCapabilitySchema.optional(),
37
+ profile: OverridableCapabilitySchema.optional(),
38
+ productAssociations: OverridableCapabilitySchema.optional(),
39
+ productRecommendations: DirectCapabilitySchema.optional()
40
+ }).partial();
41
+ export {
42
+ MedusaCapabilitiesSchema
43
+ };
@@ -0,0 +1,11 @@
1
+ import * as z from "zod";
2
+ const MedusaConfigurationSchema = z.looseObject({
3
+ publishable_key: z.string().meta({ description: "The publishable API key for the Medusa store. Used for all storefront operations." }),
4
+ adminApiKey: z.string().meta({ description: "The API key for Medusa admin operations. Needed for the few tasks that require admin access." }),
5
+ apiUrl: z.string().meta({ description: "The base URL for the Medusa API." }),
6
+ defaultCurrency: z.string().default(""),
7
+ allCurrencies: z.array(z.string()).default(() => [])
8
+ });
9
+ export {
10
+ MedusaConfigurationSchema
11
+ };
@@ -0,0 +1,26 @@
1
+ import { CartIdentifierSchema, OrderIdentifierSchema } from "@reactionary/core";
2
+ import * as z from "zod";
3
+ const MedusaCartIdentifierSchema = CartIdentifierSchema.extend({
4
+ region_id: z.string().optional()
5
+ });
6
+ const MedusaOrderIdentifierSchema = OrderIdentifierSchema.extend({
7
+ display_id: z.number().optional()
8
+ });
9
+ const MedusaRegionSchema = z.looseObject({
10
+ id: z.string(),
11
+ name: z.string(),
12
+ currency_code: z.string()
13
+ });
14
+ const MedusaSessionSchema = z.looseObject({
15
+ activeCartId: z.string().optional(),
16
+ token: z.string().optional(),
17
+ expires: z.string().optional(),
18
+ allRegions: z.array(MedusaRegionSchema).optional(),
19
+ selectedRegion: MedusaRegionSchema.optional()
20
+ });
21
+ export {
22
+ MedusaCartIdentifierSchema,
23
+ MedusaOrderIdentifierSchema,
24
+ MedusaRegionSchema,
25
+ MedusaSessionSchema
26
+ };