@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,100 @@
1
+ import type { Cache, CartItem, CartFactory, CartFactoryCartOutput, CartFactoryIdentifierOutput, CartFactoryWithOutput, CartMutationApplyCoupon, CartMutationChangeCurrency, CartMutationDeleteCart, CartMutationItemAdd, CartMutationItemQuantityChange, CartMutationItemRemove, CartMutationRemoveCoupon, CartQueryById, CostBreakDown, Currency, ItemCostBreakdown, NotFoundError, RequestContext, Result } from '@reactionary/core';
2
+ import { CartCapability } from '@reactionary/core';
3
+ import type { MedusaAPI } from '../core/client.js';
4
+ import type { MedusaConfiguration } from '../schema/configuration.schema.js';
5
+ import type { StoreAddCartLineItem, StoreCart, StoreCartAddPromotion, StoreCartLineItem, StoreCartRemovePromotion, StoreCreateCart, StoreUpdateCart, StoreUpdateCartLineItem } from '@medusajs/types';
6
+ import type { MedusaCartFactory } from '../factories/cart/cart.factory.js';
7
+ export declare class MedusaCartCapability<TFactory extends CartFactory = MedusaCartFactory> extends CartCapability<CartFactoryCartOutput<TFactory>, CartFactoryIdentifierOutput<TFactory>> {
8
+ medusaApi: MedusaAPI;
9
+ protected config: MedusaConfiguration;
10
+ protected factory: CartFactoryWithOutput<TFactory>;
11
+ /**
12
+ * This controls which fields are always included when fetching a cart
13
+ * You can override this in a subclass to add more fields as needed.
14
+ *
15
+ * example: this.includedFields = [includedFields, '+discounts.*'].join(',');
16
+ */
17
+ protected includedFields: string;
18
+ constructor(config: MedusaConfiguration, cache: Cache, context: RequestContext, medusaApi: MedusaAPI, factory: CartFactoryWithOutput<TFactory>);
19
+ getById(payload: CartQueryById): Promise<Result<CartFactoryCartOutput<TFactory>, NotFoundError>>;
20
+ /**
21
+ * Extension point for the `add` operation to control the payload sent to Medusa when adding an item to the cart. By default, it only includes the variant ID and quantity, but you can override it to include more fields as needed.
22
+ *
23
+ * @param payload
24
+ * @param variantId
25
+ * @returns
26
+ */
27
+ protected addPayload(payload: CartMutationItemAdd, variantId: string): StoreAddCartLineItem;
28
+ add(payload: CartMutationItemAdd): Promise<Result<CartFactoryCartOutput<TFactory>>>;
29
+ remove(payload: CartMutationItemRemove): Promise<Result<CartFactoryCartOutput<TFactory>>>;
30
+ /**
31
+ * Extension point for the `changeQuantity` operation to control the payload sent to Medusa when changing the quantity of an item in the cart. By default, it only includes the new quantity, but you can override it to include more fields as needed.
32
+ * @param payload
33
+ * @returns
34
+ */
35
+ protected changeQuantityPayload(payload: CartMutationItemQuantityChange): StoreUpdateCartLineItem;
36
+ changeQuantity(payload: CartMutationItemQuantityChange): Promise<Result<CartFactoryCartOutput<TFactory>>>;
37
+ getActiveCartId(): Promise<Result<CartFactoryIdentifierOutput<TFactory>, NotFoundError>>;
38
+ deleteCart(payload: CartMutationDeleteCart): Promise<Result<void>>;
39
+ /**
40
+ * Extension point to apply a coupon code to the cart. By default, it only includes the coupon code, but you can override it to include more fields as needed.
41
+ * @param payload
42
+ * @returns
43
+ */
44
+ protected applyCouponCodePayload(payload: CartMutationApplyCoupon): StoreCartAddPromotion;
45
+ applyCouponCode(payload: CartMutationApplyCoupon): Promise<Result<CartFactoryCartOutput<TFactory>>>;
46
+ /**
47
+ * Extension point to remove a coupon code from the cart. By default, it only includes the coupon code to be removed, but you can override it to include more fields as needed.
48
+ * @param payload
49
+ * @returns
50
+ */
51
+ protected removeCouponCodePayload(payload: CartMutationRemoveCoupon): StoreCartRemovePromotion;
52
+ removeCouponCode(payload: CartMutationRemoveCoupon): Promise<Result<CartFactoryCartOutput<TFactory>>>;
53
+ /**
54
+ * Extension point to control the payload sent to Medusa when changing the currency of the cart. By default, it only includes the new region ID, but you can override it to include more fields as needed.
55
+ * @param payload
56
+ * @param newRegionId
57
+ * @returns
58
+ */
59
+ protected changeCurrencyPayload(payload: CartMutationChangeCurrency, newRegionId: string): StoreUpdateCart;
60
+ changeCurrency(payload: CartMutationChangeCurrency): Promise<Result<CartFactoryCartOutput<TFactory>>>;
61
+ /**
62
+ * Extension point to control the payload sent to Medusa when creating a cart. By default, it only includes the currency code, but you can override it to include more fields as needed.
63
+ * @param currency
64
+ * @returns
65
+ */
66
+ protected createCartPayload(currency?: string): StoreCreateCart;
67
+ protected createCart(currency?: string): Promise<CartFactoryIdentifierOutput<TFactory>>;
68
+ protected getClient(): Promise<{
69
+ client: import("@medusajs/js-sdk").Client;
70
+ admin: import("@medusajs/js-sdk").Admin;
71
+ store: import("@medusajs/js-sdk").Store;
72
+ auth: import("@medusajs/js-sdk").Auth;
73
+ }>;
74
+ /**
75
+ * Extension point to control the parsing of a single cart item price
76
+ * @param remoteItem
77
+ * @param currency
78
+ * @returns
79
+ */
80
+ protected parseItemPrice(remoteItem: StoreCartLineItem, currency: Currency): ItemCostBreakdown;
81
+ /**
82
+ * Extension point to control the parsing of the cost breakdown of a cart
83
+ * @param remote
84
+ * @returns
85
+ */
86
+ protected parseCostBreakdown(remote: StoreCart): CostBreakDown;
87
+ /**
88
+ * Extension point to control the parsing of a single cart item
89
+ * @param remoteItem
90
+ * @param currency
91
+ * @returns
92
+ */
93
+ protected parseCartItem(remoteItem: StoreCartLineItem, currency: Currency): CartItem;
94
+ /**
95
+ * Extension point to control the parsing of a single cart
96
+ * @param remote
97
+ * @returns
98
+ */
99
+ protected parseSingle(remote: StoreCart): CartFactoryCartOutput<TFactory>;
100
+ }
@@ -0,0 +1,36 @@
1
+ import type { StoreProductCategory, StoreProductCategoryListResponse } from '@medusajs/types';
2
+ import type { Cache, CategoryFactory, CategoryFactoryCategoryOutput, CategoryFactoryPaginatedOutput, CategoryFactoryWithOutput } from '@reactionary/core';
3
+ import { CategoryCapability, type Result, type NotFoundError, type CategoryQueryById, type CategoryQueryBySlug, type CategoryQueryForBreadcrumb, type CategoryQueryForChildCategories, type CategoryQueryForTopCategories, type RequestContext } from '@reactionary/core';
4
+ import type { MedusaAPI, MedusaConfiguration } from '../index.js';
5
+ import type { MedusaCategoryFactory } from '../factories/category/category.factory.js';
6
+ export declare class MedusaCategoryCapability<TFactory extends CategoryFactory = MedusaCategoryFactory> extends CategoryCapability<CategoryFactoryCategoryOutput<TFactory>, CategoryFactoryPaginatedOutput<TFactory>> {
7
+ medusaApi: MedusaAPI;
8
+ protected config: MedusaConfiguration;
9
+ protected factory: CategoryFactoryWithOutput<TFactory>;
10
+ constructor(config: MedusaConfiguration, cache: Cache, context: RequestContext, medusaApi: MedusaAPI, factory: CategoryFactoryWithOutput<TFactory>);
11
+ protected resolveCategoryIdByExternalId(externalId: string): Promise<StoreProductCategory | null>;
12
+ getById(payload: CategoryQueryById): Promise<Result<CategoryFactoryCategoryOutput<TFactory>, NotFoundError>>;
13
+ protected getBySlugPayload(payload: CategoryQueryBySlug): {
14
+ handle: string;
15
+ limit: number;
16
+ offset: number;
17
+ };
18
+ getBySlug(payload: CategoryQueryBySlug): Promise<Result<CategoryFactoryCategoryOutput<TFactory>, NotFoundError>>;
19
+ getBreadcrumbPathToCategory(payload: CategoryQueryForBreadcrumb): Promise<Result<CategoryFactoryCategoryOutput<TFactory>[]>>;
20
+ protected findChildCategoriesPayload(payload: CategoryQueryForChildCategories, actualParent: StoreProductCategory): {
21
+ fields: string;
22
+ parent_category_id: string;
23
+ limit: number;
24
+ offset: number;
25
+ };
26
+ findChildCategories(payload: CategoryQueryForChildCategories): Promise<import("@reactionary/core").Ok<CategoryFactoryPaginatedOutput<TFactory>>>;
27
+ protected findTopCategoriesPayload(payload: CategoryQueryForTopCategories): {
28
+ fields: string;
29
+ parent_category_id: string;
30
+ limit: number;
31
+ offset: number;
32
+ };
33
+ findTopCategories(payload: CategoryQueryForTopCategories): Promise<import("@reactionary/core").Ok<CategoryFactoryPaginatedOutput<TFactory>>>;
34
+ protected parseSingle(_body: StoreProductCategory): CategoryFactoryCategoryOutput<TFactory>;
35
+ protected parsePaginatedResult(body: StoreProductCategoryListResponse): CategoryFactoryPaginatedOutput<TFactory>;
36
+ }
@@ -0,0 +1,88 @@
1
+ import type { StoreAddCartShippingMethods, StoreCart, StoreCartAddress, StoreCartLineItem, StoreInitializePaymentSession, StoreUpdateCart } from '@medusajs/types';
2
+ import type { Address, Cache, CheckoutIdentifier, CheckoutItem, CheckoutMutationAddPaymentInstruction, CheckoutMutationFinalizeCheckout, CheckoutMutationInitiateCheckout, CheckoutMutationRemovePaymentInstruction, CheckoutMutationSetShippingAddress, CheckoutMutationSetShippingInstruction, CheckoutFactory, CheckoutFactoryCheckoutOutput, CheckoutFactoryPaymentMethodOutput, CheckoutFactoryShippingMethodOutput, CheckoutFactoryWithOutput, CheckoutQueryById, CheckoutQueryForAvailablePaymentMethods, CheckoutQueryForAvailableShippingMethods, CostBreakDown, Currency, ItemCostBreakdown, RequestContext, Result, NotFoundError } from '@reactionary/core';
3
+ import { CheckoutCapability } from '@reactionary/core';
4
+ import type { MedusaAPI } from '../core/client.js';
5
+ import type { MedusaConfiguration } from '../schema/configuration.schema.js';
6
+ import type { MedusaCheckoutFactory } from '../factories/checkout/checkout.factory.js';
7
+ export declare class CheckoutNotReadyForFinalizationError extends Error {
8
+ checkoutIdentifier: CheckoutIdentifier;
9
+ constructor(checkoutIdentifier: CheckoutIdentifier);
10
+ }
11
+ export declare class MedusaCheckoutCapability<TFactory extends CheckoutFactory = MedusaCheckoutFactory> extends CheckoutCapability<CheckoutFactoryCheckoutOutput<TFactory>, CheckoutFactoryShippingMethodOutput<TFactory>, CheckoutFactoryPaymentMethodOutput<TFactory>> {
12
+ medusaApi: MedusaAPI;
13
+ protected config: MedusaConfiguration;
14
+ protected factory: CheckoutFactoryWithOutput<TFactory>;
15
+ /**
16
+ * This controls which fields are always included when fetching a cart
17
+ * You can override this in a subclass to add more fields as needed.
18
+ *
19
+ * example: this.includedFields = [includedFields, '+discounts.*'].join(',');
20
+ */
21
+ protected includedFields: string;
22
+ constructor(config: MedusaConfiguration, cache: Cache, context: RequestContext, medusaApi: MedusaAPI, factory: CheckoutFactoryWithOutput<TFactory>);
23
+ protected initiateCheckoutForCartPayload(payload: CheckoutMutationInitiateCheckout): StoreUpdateCart;
24
+ initiateCheckoutForCart(payload: CheckoutMutationInitiateCheckout): Promise<Result<CheckoutFactoryCheckoutOutput<TFactory>>>;
25
+ getById(payload: CheckoutQueryById): Promise<Result<CheckoutFactoryCheckoutOutput<TFactory>, NotFoundError>>;
26
+ protected setShippingAddressPayload(payload: CheckoutMutationSetShippingAddress): StoreUpdateCart;
27
+ setShippingAddress(payload: CheckoutMutationSetShippingAddress): Promise<Result<CheckoutFactoryCheckoutOutput<TFactory>>>;
28
+ protected getAvailableShippingMethodsPayload(payload: CheckoutQueryForAvailableShippingMethods): {
29
+ cart_id: string;
30
+ };
31
+ getAvailableShippingMethods(payload: CheckoutQueryForAvailableShippingMethods): Promise<Result<CheckoutFactoryShippingMethodOutput<TFactory>[]>>;
32
+ protected getAvailablePaymentMethodsPayload(payload: CheckoutQueryForAvailablePaymentMethods, regionId: string): {
33
+ region_id: string;
34
+ };
35
+ getAvailablePaymentMethods(payload: CheckoutQueryForAvailablePaymentMethods): Promise<Result<CheckoutFactoryPaymentMethodOutput<TFactory>[]>>;
36
+ protected addPaymentInstructionPayload(payload: CheckoutMutationAddPaymentInstruction): StoreInitializePaymentSession;
37
+ addPaymentInstruction(payload: CheckoutMutationAddPaymentInstruction): Promise<Result<CheckoutFactoryCheckoutOutput<TFactory>>>;
38
+ removePaymentInstruction(payload: CheckoutMutationRemovePaymentInstruction): Promise<Result<CheckoutFactoryCheckoutOutput<TFactory>>>;
39
+ protected setShippingInstructionPayload(payload: CheckoutMutationSetShippingInstruction): StoreAddCartShippingMethods;
40
+ setShippingInstruction(payload: CheckoutMutationSetShippingInstruction): Promise<Result<CheckoutFactoryCheckoutOutput<TFactory>>>;
41
+ finalizeCheckout(payload: CheckoutMutationFinalizeCheckout): Promise<Result<CheckoutFactoryCheckoutOutput<TFactory>>>;
42
+ /**
43
+ * Extension point to map an Address to a Store Address
44
+ * @param address
45
+ * @returns
46
+ */
47
+ protected mapAddressToStoreAddress(address: Partial<Address>): {
48
+ first_name: string | undefined;
49
+ last_name: string | undefined;
50
+ address_1: string | undefined;
51
+ address_2: string;
52
+ city: string | undefined;
53
+ postal_code: string | undefined;
54
+ country_code: string | undefined;
55
+ };
56
+ /**
57
+ * Extension point to control the parsing of an address from a store cart address
58
+ * @param storeAddress
59
+ * @returns
60
+ */
61
+ protected composeAddressFromStoreAddress(storeAddress: StoreCartAddress): Address;
62
+ /**
63
+ * Extension point to control the parsing of a single cart item price
64
+ * @param remoteItem
65
+ * @param currency
66
+ * @returns
67
+ */
68
+ protected parseItemPrice(remoteItem: StoreCartLineItem, currency: Currency): ItemCostBreakdown;
69
+ /**
70
+ * Extension point to control the parsing of the cost breakdown of a cart
71
+ * @param remote
72
+ * @returns
73
+ */
74
+ protected parseCostBreakdown(remote: StoreCart): CostBreakDown;
75
+ /**
76
+ * Extension point to control the parsing of a single checkout item
77
+ * @param remoteItem
78
+ * @param currency
79
+ * @returns
80
+ */
81
+ protected parseCheckoutItem(remoteItem: StoreCartLineItem, currency: Currency): CheckoutItem;
82
+ /**
83
+ * Extension point to control the parsing of the Checkout object
84
+ * @param remote
85
+ * @returns
86
+ */
87
+ protected parseSingle(remote: StoreCart): CheckoutFactoryCheckoutOutput<TFactory>;
88
+ }
@@ -0,0 +1,13 @@
1
+ import { type Identity, type IdentityMutationLogin, type IdentityMutationLogout, type IdentityMutationRegister, type IdentityQuerySelf, type RequestContext, type Cache, IdentityCapability, type AnonymousIdentity, type Result } from '@reactionary/core';
2
+ import type { MedusaConfiguration } from '../schema/configuration.schema.js';
3
+ import type { MedusaAPI } from '../core/client.js';
4
+ export declare class MedusaIdentityCapability extends IdentityCapability {
5
+ protected config: MedusaConfiguration;
6
+ protected medusaApi: MedusaAPI;
7
+ constructor(config: MedusaConfiguration, cache: Cache, context: RequestContext, medusaApi: MedusaAPI);
8
+ protected createAnonymousIdentity(): AnonymousIdentity;
9
+ getSelf(_payload: IdentityQuerySelf): Promise<Result<Identity>>;
10
+ login(payload: IdentityMutationLogin): Promise<Result<Identity>>;
11
+ logout(_payload: IdentityMutationLogout): Promise<Result<Identity>>;
12
+ register(payload: IdentityMutationRegister): Promise<Result<Identity>>;
13
+ }
@@ -0,0 +1,21 @@
1
+ import { type InventoryQueryBySKU, type RequestContext, type Cache, InventoryCapability, type InventoryFactory, type InventoryFactoryOutput, type InventoryFactoryWithOutput, type NotFoundError, type Result } from '@reactionary/core';
2
+ import type { MedusaConfiguration } from '../schema/configuration.schema.js';
3
+ import { type MedusaAPI } from '../core/client.js';
4
+ import type { MedusaInventoryFactory } from '../factories/inventory/inventory.factory.js';
5
+ export declare class MedusaInventoryCapability<TFactory extends InventoryFactory = MedusaInventoryFactory> extends InventoryCapability<InventoryFactoryOutput<TFactory>> {
6
+ medusaApi: MedusaAPI;
7
+ protected config: MedusaConfiguration;
8
+ protected factory: InventoryFactoryWithOutput<TFactory>;
9
+ constructor(config: MedusaConfiguration, cache: Cache, context: RequestContext, medusaApi: MedusaAPI, factory: InventoryFactoryWithOutput<TFactory>);
10
+ getBySKU(payload: InventoryQueryBySKU): Promise<Result<InventoryFactoryOutput<TFactory>, NotFoundError>>;
11
+ protected parseSingle(_body: unknown): InventoryFactoryOutput<TFactory>;
12
+ /**
13
+ * Utility function to create an empty inventory result.
14
+ * This is used when no inventory is found for a given SKU + fulfillment center combination.
15
+ * @param sku
16
+ * @param fulfillmentCenterKey
17
+ * @returns
18
+ */
19
+ protected createEmptyInventoryResult(sku: string, fulfillmentCenterKey: string): InventoryFactoryOutput<TFactory>;
20
+ protected getResourceName(): string;
21
+ }
@@ -0,0 +1,53 @@
1
+ import type { RequestContext, Cache, OrderSearchQueryByTerm, Result, Address, IdentityIdentifier, MonetaryAmount, OrderSearchResultItem, OrderSearchFactory, OrderSearchFactoryOutput, OrderSearchFactoryWithOutput } from '@reactionary/core';
2
+ import { OrderSearchCapability } from '@reactionary/core';
3
+ import type { MedusaConfiguration } from '../schema/configuration.schema.js';
4
+ import type { MedusaAPI } from '../core/client.js';
5
+ import type { StoreOrder, StoreOrderAddress, StoreOrderListResponse } from '@medusajs/types';
6
+ import type { MedusaOrderSearchFactory } from '../factories/order-search/order-search.factory.js';
7
+ export declare class MedusaOrderSearchCapability<TFactory extends OrderSearchFactory = MedusaOrderSearchFactory> extends OrderSearchCapability<OrderSearchFactoryOutput<TFactory>> {
8
+ medusaApi: MedusaAPI;
9
+ protected config: MedusaConfiguration;
10
+ protected factory: OrderSearchFactoryWithOutput<TFactory>;
11
+ constructor(config: MedusaConfiguration, cache: Cache, context: RequestContext, medusaApi: MedusaAPI, factory: OrderSearchFactoryWithOutput<TFactory>);
12
+ protected queryByTermPayload(payload: OrderSearchQueryByTerm): any;
13
+ queryByTerm(payload: OrderSearchQueryByTerm): Promise<Result<OrderSearchFactoryOutput<TFactory>>>;
14
+ protected composeAddressFromStoreAddress(storeAddress: StoreOrderAddress): Address;
15
+ protected parseSingle(body: StoreOrder): {
16
+ identifier: {
17
+ key: string;
18
+ };
19
+ userId: IdentityIdentifier;
20
+ customerName: string;
21
+ shippingAddress: Address;
22
+ orderDate: string;
23
+ orderStatus: "AwaitingPayment" | "ReleasedToFulfillment" | "Shipped" | "Cancelled";
24
+ inventoryStatus: ("NotAllocated" & {
25
+ _?: never;
26
+ }) | ("Allocated" & {
27
+ _?: never;
28
+ });
29
+ totalAmount: MonetaryAmount;
30
+ };
31
+ protected parsePaginatedResult(body: StoreOrderListResponse, query: OrderSearchQueryByTerm): {
32
+ identifier: {
33
+ term: string;
34
+ filters: string[];
35
+ paginationOptions: {
36
+ pageNumber: number;
37
+ pageSize: number;
38
+ };
39
+ partNumber?: string[] | undefined;
40
+ orderStatus?: ("AwaitingPayment" | "ReleasedToFulfillment" | "Shipped" | "Cancelled")[] | undefined;
41
+ user?: {
42
+ userId: string;
43
+ } | undefined;
44
+ startDate?: string | undefined;
45
+ endDate?: string | undefined;
46
+ };
47
+ pageNumber: number;
48
+ pageSize: number;
49
+ totalCount: number;
50
+ totalPages: number;
51
+ items: OrderSearchResultItem[];
52
+ };
53
+ }
@@ -0,0 +1,49 @@
1
+ import type { Cache, OrderQueryById, RequestContext, Result, NotFoundError, CostBreakDown, Currency, OrderItem, ItemCostBreakdown, PaymentMethodIdentifier, OrderFactory, OrderFactoryOutput, OrderFactoryWithOutput } from '@reactionary/core';
2
+ import { OrderCapability } from '@reactionary/core';
3
+ import type { MedusaAPI } from '../core/client.js';
4
+ import type { MedusaConfiguration } from '../schema/configuration.schema.js';
5
+ import type { StoreOrder, StoreOrderLineItem, StorePaymentCollection } from '@medusajs/types';
6
+ import type { MedusaOrderFactory } from '../factories/order/order.factory.js';
7
+ export declare class MedusaOrderCapability<TFactory extends OrderFactory = MedusaOrderFactory> extends OrderCapability<OrderFactoryOutput<TFactory>> {
8
+ medusaApi: MedusaAPI;
9
+ protected config: MedusaConfiguration;
10
+ protected factory: OrderFactoryWithOutput<TFactory>;
11
+ constructor(config: MedusaConfiguration, cache: Cache, context: RequestContext, medusaApi: MedusaAPI, factory: OrderFactoryWithOutput<TFactory>);
12
+ getById(payload: OrderQueryById): Promise<Result<OrderFactoryOutput<TFactory>, NotFoundError>>;
13
+ /**
14
+ * Extension point to control the parsing of a single cart item price
15
+ * @param remoteItem
16
+ * @param currency
17
+ * @returns
18
+ */
19
+ protected parseItemPrice(remoteItem: StoreOrderLineItem, currency: Currency): ItemCostBreakdown;
20
+ /**
21
+ * Extension point to control the parsing of the cost breakdown of a cart
22
+ * @param remote
23
+ * @returns
24
+ */
25
+ protected parseCostBreakdown(remote: StoreOrder): CostBreakDown;
26
+ /**
27
+ * Extension point to control the parsing of a single cart item
28
+ * @param remoteItem
29
+ * @param currency
30
+ * @returns
31
+ */
32
+ protected parseOrderItem(remoteItem: StoreOrderLineItem, currency: Currency): OrderItem;
33
+ protected parsePaymentInstruction(remotePayment: StorePaymentCollection, order: StoreOrder): {
34
+ identifier: {
35
+ key: string;
36
+ };
37
+ amount: {
38
+ value: number;
39
+ currency: Currency;
40
+ };
41
+ paymentMethod: PaymentMethodIdentifier;
42
+ protocolData: {
43
+ key: string;
44
+ value: string;
45
+ }[];
46
+ status: "pending" | "authorized" | "canceled" | "capture";
47
+ };
48
+ protected parseSingle(body: StoreOrder): OrderFactoryOutput<TFactory>;
49
+ }
@@ -0,0 +1,16 @@
1
+ import type { StoreProductVariant } from '@medusajs/types';
2
+ import { PriceCapability, type Cache, type CustomerPriceQuery, type ListPriceQuery, type PriceFactory, type PriceFactoryOutput, type PriceFactoryWithOutput, type RequestContext, type Result } from '@reactionary/core';
3
+ import type { MedusaAPI } from '../core/client.js';
4
+ import type { MedusaConfiguration } from '../schema/configuration.schema.js';
5
+ import type { MedusaPriceFactory } from '../factories/price/price.factory.js';
6
+ export declare class MedusaPriceCapability<TFactory extends PriceFactory = MedusaPriceFactory> extends PriceCapability<PriceFactoryOutput<TFactory>> {
7
+ medusaApi: MedusaAPI;
8
+ protected config: MedusaConfiguration;
9
+ protected factory: PriceFactoryWithOutput<TFactory>;
10
+ constructor(config: MedusaConfiguration, cache: Cache, context: RequestContext, medusaApi: MedusaAPI, factory: PriceFactoryWithOutput<TFactory>);
11
+ getListPrice(payload: ListPriceQuery): Promise<Result<PriceFactoryOutput<TFactory>>>;
12
+ getCustomerPrice(payload: CustomerPriceQuery): Promise<Result<PriceFactoryOutput<TFactory>>>;
13
+ protected getBySKU(payload: ListPriceQuery | CustomerPriceQuery, mode: 'list' | 'customer'): Promise<PriceFactoryOutput<TFactory>>;
14
+ protected parseSingle(variant: StoreProductVariant, mode: 'list' | 'customer'): PriceFactoryOutput<TFactory>;
15
+ protected getResourceName(): string;
16
+ }
@@ -0,0 +1,19 @@
1
+ import { ProductAssociationsCapability } from '@reactionary/core';
2
+ import type { ProductAssociationsFactory, ProductAssociationsFactoryOutput, ProductAssociationsFactoryWithOutput } from '@reactionary/core';
3
+ import type { ProductIdentifier, ProductSearchResultItem, ProductSearchResultItemVariant, ProductAssociationsGetAccessoriesQuery, ProductAssociationsGetSparepartsQuery, ProductAssociationsGetReplacementsQuery, Result, RequestContext, Cache } from '@reactionary/core';
4
+ import type { MedusaConfiguration } from '../schema/configuration.schema.js';
5
+ import type { MedusaAPI } from '../core/client.js';
6
+ import type { StoreProduct, StoreProductVariant } from '@medusajs/types';
7
+ import type { MedusaProductAssociationsFactory } from '../factories/product-associations/product-associations.factory.js';
8
+ export declare class MedusaProductAssociationsCapability<TFactory extends ProductAssociationsFactory = MedusaProductAssociationsFactory> extends ProductAssociationsCapability<ProductAssociationsFactoryOutput<TFactory>> {
9
+ protected config: MedusaConfiguration;
10
+ protected medusa: MedusaAPI;
11
+ protected factory: ProductAssociationsFactoryWithOutput<TFactory>;
12
+ constructor(config: MedusaConfiguration, cache: Cache, context: RequestContext, medusa: MedusaAPI, factory: ProductAssociationsFactoryWithOutput<TFactory>);
13
+ protected fetchAssociatedProductsFor(productKey: ProductIdentifier, maxNumberOfAssociations: number, attributeName: string): Promise<ProductSearchResultItem[]>;
14
+ getAccessories(query: ProductAssociationsGetAccessoriesQuery): Promise<Result<ProductAssociationsFactoryOutput<TFactory>[]>>;
15
+ getSpareparts(query: ProductAssociationsGetSparepartsQuery): Promise<Result<ProductAssociationsFactoryOutput<TFactory>[]>>;
16
+ getReplacements(query: ProductAssociationsGetReplacementsQuery): Promise<Result<ProductAssociationsFactoryOutput<TFactory>[]>>;
17
+ protected parseSingle(_body: StoreProduct): ProductSearchResultItem;
18
+ protected parseVariant(variant: StoreProductVariant, product: StoreProduct): ProductSearchResultItemVariant;
19
+ }
@@ -0,0 +1,41 @@
1
+ import type { StoreCollection, StoreProduct, StoreProductVariant } from '@medusajs/types';
2
+ import { ProductRecommendationsCapability, type Cache, type ProductRecommendation, type ProductRecommendationsByCollectionQuery, type ProductSearchResultItemVariant, type RequestContext, type Result } from '@reactionary/core';
3
+ import type { MedusaAPI } from '../core/client.js';
4
+ import type { MedusaConfiguration } from '../schema/configuration.schema.js';
5
+ /**
6
+ * MedusaProductRecommendationsCapability
7
+ *
8
+ * Provides product recommendations using Medusa's collection-based product grouping.
9
+ * Only overrides the getCollection method to fetch products from Medusa collections.
10
+ *
11
+ * Note: This implementation leverages Medusa's product collections feature to provide
12
+ * curated product recommendations. Collections are typically manually managed or
13
+ * created through Medusa's admin panel or API.
14
+ */
15
+ export declare class MedusaProductRecommendationsCapability extends ProductRecommendationsCapability {
16
+ protected config: MedusaConfiguration;
17
+ protected medusaApi: MedusaAPI;
18
+ constructor(config: MedusaConfiguration, cache: Cache, context: RequestContext, medusaApi: MedusaAPI);
19
+ protected getCollectionPayload(query: ProductRecommendationsByCollectionQuery, collection: StoreCollection): {
20
+ collection_id: string[];
21
+ limit: number;
22
+ fields: string;
23
+ };
24
+ /**
25
+ * Get product recommendations from a Medusa collection
26
+ *
27
+ * This method fetches products from a specific Medusa collection by name or handle.
28
+ * It's useful for displaying curated product lists like "Featured Products",
29
+ * "New Arrivals", "Best Sellers", etc.
30
+ */
31
+ getCollection(query: ProductRecommendationsByCollectionQuery): Promise<Result<ProductRecommendation[]>>;
32
+ protected parseSearchResultItem(_body: StoreProduct): {
33
+ identifier: {
34
+ key: string;
35
+ };
36
+ name: string;
37
+ slug: string;
38
+ variants: ProductSearchResultItemVariant[];
39
+ };
40
+ protected parseVariant(variant: StoreProductVariant, product: StoreProduct): ProductSearchResultItemVariant;
41
+ }
@@ -0,0 +1,45 @@
1
+ import { ProductSearchCapability, type Cache, type RequestContext, type ProductSearchQueryByTerm, type ProductSearchResultItem, type ProductSearchResultItemVariant, type FacetValueIdentifier, type ProductSearchFactory, type ProductSearchFactoryOutput, type ProductSearchFactoryWithOutput, type ProductSearchQueryCreateNavigationFilter, type Result } from '@reactionary/core';
2
+ import type { MedusaConfiguration } from '../schema/configuration.schema.js';
3
+ import type { MedusaAPI } from '../core/client.js';
4
+ import type { StoreProduct, StoreProductCategory, StoreProductListResponse, StoreProductVariant } from '@medusajs/types';
5
+ import type { MedusaProductSearchFactory } from '../factories/product-search/product-search.factory.js';
6
+ export declare class MedusaProductSearchCapability<TFactory extends ProductSearchFactory = MedusaProductSearchFactory> extends ProductSearchCapability<ProductSearchFactoryOutput<TFactory>> {
7
+ medusaApi: MedusaAPI;
8
+ protected config: MedusaConfiguration;
9
+ protected factory: ProductSearchFactoryWithOutput<TFactory>;
10
+ constructor(config: MedusaConfiguration, cache: Cache, context: RequestContext, medusaApi: MedusaAPI, factory: ProductSearchFactoryWithOutput<TFactory>);
11
+ protected resolveCategoryIdByExternalId(externalId: string): Promise<StoreProductCategory | null>;
12
+ protected queryByTermPayload(payload: ProductSearchQueryByTerm, categoryIdToFind: string | null): any;
13
+ queryByTerm(payload: ProductSearchQueryByTerm): Promise<Result<ProductSearchFactoryOutput<TFactory>>>;
14
+ protected parsePaginatedResult(remote: StoreProductListResponse, query: ProductSearchQueryByTerm): {
15
+ identifier: {
16
+ term: string;
17
+ facets: {
18
+ facet: {
19
+ key: string;
20
+ };
21
+ key: string;
22
+ }[];
23
+ filters: string[];
24
+ paginationOptions: {
25
+ pageNumber: number;
26
+ pageSize: number;
27
+ };
28
+ categoryFilter?: {
29
+ facet: {
30
+ key: string;
31
+ };
32
+ key: string;
33
+ } | undefined;
34
+ };
35
+ pageNumber: number;
36
+ pageSize: number;
37
+ totalCount: number;
38
+ totalPages: number;
39
+ items: ProductSearchResultItem[];
40
+ facets: never[];
41
+ };
42
+ protected parseSingle(_body: StoreProduct): ProductSearchResultItem;
43
+ protected parseVariant(variant: StoreProductVariant, product: StoreProduct): ProductSearchResultItemVariant;
44
+ createCategoryNavigationFilter(payload: ProductSearchQueryCreateNavigationFilter): Promise<Result<FacetValueIdentifier>>;
45
+ }
@@ -0,0 +1,32 @@
1
+ import type { Cache, NotFoundError, ProductAttribute, ProductFactory, ProductFactoryOutput, ProductFactoryWithOutput, ProductQueryById, ProductQueryBySKU, ProductQueryBySlug, ProductVariant, RequestContext, Result } from '@reactionary/core';
2
+ import { ProductCapability } from '@reactionary/core';
3
+ import type { MedusaAPI } from '../core/client.js';
4
+ import type { MedusaConfiguration } from '../schema/configuration.schema.js';
5
+ import type { StoreProduct, StoreProductVariant } from '@medusajs/types';
6
+ import type { MedusaProductFactory } from '../factories/product/product.factory.js';
7
+ export declare class MedusaProductCapability<TFactory extends ProductFactory = MedusaProductFactory> extends ProductCapability<ProductFactoryOutput<TFactory>> {
8
+ medusaApi: MedusaAPI;
9
+ protected config: MedusaConfiguration;
10
+ protected alwaysIncludedFields: string[];
11
+ protected factory: ProductFactoryWithOutput<TFactory>;
12
+ constructor(config: MedusaConfiguration, cache: Cache, context: RequestContext, medusaApi: MedusaAPI, factory: ProductFactoryWithOutput<TFactory>);
13
+ protected getByIdPayload(payload: ProductQueryById): {
14
+ external_id: string;
15
+ limit: number;
16
+ offset: number;
17
+ fields: string;
18
+ };
19
+ getById(payload: ProductQueryById): Promise<Result<ProductFactoryOutput<TFactory>>>;
20
+ protected getBySlugPayload(payload: ProductQueryBySlug): {
21
+ handle: string;
22
+ limit: number;
23
+ offset: number;
24
+ fields: string;
25
+ };
26
+ getBySlug(payload: ProductQueryBySlug): Promise<Result<ProductFactoryOutput<TFactory>, NotFoundError>>;
27
+ getBySKU(payload: ProductQueryBySKU): Promise<Result<ProductFactoryOutput<TFactory>>>;
28
+ protected parseSingle(_body: StoreProduct): ProductFactoryOutput<TFactory>;
29
+ protected parseVariant(variant: StoreProductVariant, product: StoreProduct): ProductVariant;
30
+ protected createSynthAttribute(key: string, name: string, value: string): ProductAttribute;
31
+ protected parseAttributes(_body: StoreProduct): Array<ProductAttribute>;
32
+ }
@@ -0,0 +1,39 @@
1
+ import { type ProfileMutationAddShippingAddress, type ProfileMutationMakeShippingAddressDefault, type ProfileMutationRemoveShippingAddress, type ProfileMutationSetBillingAddress, type ProfileMutationUpdate, type ProfileMutationUpdateShippingAddress, type ProfileQuerySelf as ProfileQueryById, type RequestContext, type Cache, type Result, type NotFoundError, ProfileCapability, type Address, type ProfileFactory, type ProfileFactoryOutput, type ProfileFactoryWithOutput } from '@reactionary/core';
2
+ import type { MedusaConfiguration } from '../schema/configuration.schema.js';
3
+ import type { MedusaAPI } from '../core/client.js';
4
+ import type { StoreCreateCustomerAddress, StoreCustomer, StoreCustomerAddress } from '@medusajs/types';
5
+ import type { MedusaProfileFactory } from '../factories/profile/profile.factory.js';
6
+ /**
7
+ * Medusa Profile Capability
8
+ *
9
+ * Implements profile management using Medusa's customer APIs.
10
+ *
11
+ * TODO:
12
+ * - handle email and phone verification status properly using metadata or other means.
13
+ * - handle guest user scenarios (if applicable).
14
+ * - improve error handling and edge cases.
15
+ */
16
+ export declare class MedusaProfileCapability<TFactory extends ProfileFactory = MedusaProfileFactory> extends ProfileCapability<ProfileFactoryOutput<TFactory>> {
17
+ medusaApi: MedusaAPI;
18
+ protected config: MedusaConfiguration;
19
+ protected includedFields: string[];
20
+ protected factory: ProfileFactoryWithOutput<TFactory>;
21
+ constructor(config: MedusaConfiguration, cache: Cache, context: RequestContext, medusaApi: MedusaAPI, factory: ProfileFactoryWithOutput<TFactory>);
22
+ getById(payload: ProfileQueryById): Promise<Result<ProfileFactoryOutput<TFactory>, NotFoundError>>;
23
+ protected updatePayload(payload: ProfileMutationUpdate): any;
24
+ update(payload: ProfileMutationUpdate): Promise<Result<ProfileFactoryOutput<TFactory>, NotFoundError>>;
25
+ protected addShippingAddressPayload(payload: ProfileMutationAddShippingAddress): StoreCreateCustomerAddress;
26
+ addShippingAddress(payload: ProfileMutationAddShippingAddress): Promise<Result<ProfileFactoryOutput<TFactory>, NotFoundError>>;
27
+ protected updateShippingAddressPayload(payload: ProfileMutationUpdateShippingAddress): StoreCreateCustomerAddress;
28
+ updateShippingAddress(payload: ProfileMutationUpdateShippingAddress): Promise<Result<ProfileFactoryOutput<TFactory>, NotFoundError>>;
29
+ removeShippingAddress(payload: ProfileMutationRemoveShippingAddress): Promise<Result<ProfileFactoryOutput<TFactory>, NotFoundError>>;
30
+ protected makeShippingAddressDefaultPayload(payload: ProfileMutationMakeShippingAddressDefault): {
31
+ is_default_shipping: boolean;
32
+ };
33
+ makeShippingAddressDefault(payload: ProfileMutationMakeShippingAddressDefault): Promise<Result<ProfileFactoryOutput<TFactory>, NotFoundError>>;
34
+ protected setBillingAddressPayload(payload: ProfileMutationSetBillingAddress): StoreCreateCustomerAddress;
35
+ setBillingAddress(payload: ProfileMutationSetBillingAddress): Promise<Result<ProfileFactoryOutput<TFactory>, NotFoundError>>;
36
+ protected createMedusaAddress(address: Address): StoreCreateCustomerAddress;
37
+ protected parseAddress(address: StoreCustomerAddress): Address;
38
+ protected parseSingle(customer: StoreCustomer): ProfileFactoryOutput<TFactory>;
39
+ }