@reactionary/medusa 0.6.3 → 0.6.5

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 (45) hide show
  1. package/capabilities/cart.capability.js +7 -99
  2. package/capabilities/category.capability.js +29 -47
  3. package/capabilities/checkout.capability.js +19 -209
  4. package/capabilities/inventory.capability.js +10 -54
  5. package/capabilities/order-search.capability.js +2 -76
  6. package/capabilities/order.capability.js +2 -130
  7. package/capabilities/price.capability.js +3 -38
  8. package/capabilities/product-associations.capability.js +19 -54
  9. package/capabilities/product-search.capability.js +15 -67
  10. package/capabilities/product.capability.js +18 -131
  11. package/capabilities/profile.capability.js +14 -63
  12. package/factories/cart/cart.factory.js +91 -2
  13. package/factories/category/category.factory.js +33 -3
  14. package/factories/checkout/checkout.factory.js +187 -4
  15. package/factories/inventory/inventory.factory.js +19 -1
  16. package/factories/order/order.factory.js +128 -2
  17. package/factories/order-search/order-search.factory.js +75 -2
  18. package/factories/price/price.factory.js +31 -2
  19. package/factories/product/product.factory.js +155 -2
  20. package/factories/product-associations/product-associations.factory.js +38 -2
  21. package/factories/product-search/product-search.factory.js +51 -2
  22. package/factories/profile/profile.factory.js +54 -2
  23. package/package.json +2 -2
  24. package/src/capabilities/cart.capability.d.ts +2 -28
  25. package/src/capabilities/category.capability.d.ts +5 -7
  26. package/src/capabilities/checkout.capability.d.ts +3 -35
  27. package/src/capabilities/inventory.capability.d.ts +2 -12
  28. package/src/capabilities/order-search.capability.d.ts +2 -42
  29. package/src/capabilities/order.capability.d.ts +2 -39
  30. package/src/capabilities/price.capability.d.ts +1 -4
  31. package/src/capabilities/product-associations.capability.d.ts +3 -7
  32. package/src/capabilities/product-search.capability.d.ts +4 -34
  33. package/src/capabilities/product.capability.d.ts +1 -6
  34. package/src/capabilities/profile.capability.d.ts +3 -5
  35. package/src/factories/cart/cart.factory.d.ts +23 -2
  36. package/src/factories/category/category.factory.d.ts +4 -3
  37. package/src/factories/checkout/checkout.factory.d.ts +31 -4
  38. package/src/factories/inventory/inventory.factory.d.ts +7 -1
  39. package/src/factories/order/order.factory.d.ts +38 -2
  40. package/src/factories/order-search/order-search.factory.d.ts +20 -2
  41. package/src/factories/price/price.factory.d.ts +6 -1
  42. package/src/factories/product/product.factory.d.ts +6 -2
  43. package/src/factories/product-associations/product-associations.factory.d.ts +8 -2
  44. package/src/factories/product-search/product-search.factory.d.ts +5 -2
  45. package/src/factories/profile/profile.factory.d.ts +4 -2
@@ -1,8 +1,8 @@
1
- import type { StoreProductCategory, StoreProductCategoryListResponse } from '@medusajs/types';
1
+ import type { StoreProductCategory } from '@medusajs/types';
2
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';
3
+ import { CategoryCapability, type CategoryQueryById, type CategoryQueryBySlug, type CategoryQueryForBreadcrumb, type CategoryQueryForChildCategories, type CategoryQueryForTopCategories, type NotFoundError, type RequestContext, type Result } from '@reactionary/core';
5
4
  import type { MedusaCategoryFactory } from '../factories/category/category.factory.js';
5
+ import type { MedusaAPI, MedusaConfiguration } from '../index.js';
6
6
  export declare class MedusaCategoryCapability<TFactory extends CategoryFactory = MedusaCategoryFactory> extends CategoryCapability<CategoryFactoryCategoryOutput<TFactory>, CategoryFactoryPaginatedOutput<TFactory>> {
7
7
  medusaApi: MedusaAPI;
8
8
  protected config: MedusaConfiguration;
@@ -23,14 +23,12 @@ export declare class MedusaCategoryCapability<TFactory extends CategoryFactory =
23
23
  limit: number;
24
24
  offset: number;
25
25
  };
26
- findChildCategories(payload: CategoryQueryForChildCategories): Promise<import("@reactionary/core").Ok<CategoryFactoryPaginatedOutput<TFactory>>>;
26
+ findChildCategories(payload: CategoryQueryForChildCategories): Promise<import("@reactionary/core").Ok<ReturnType<TFactory["parseCategoryPaginatedResult"]>>>;
27
27
  protected findTopCategoriesPayload(payload: CategoryQueryForTopCategories): {
28
28
  fields: string;
29
29
  parent_category_id: string;
30
30
  limit: number;
31
31
  offset: number;
32
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>;
33
+ findTopCategories(payload: CategoryQueryForTopCategories): Promise<import("@reactionary/core").Ok<ReturnType<TFactory["parseCategoryPaginatedResult"]>>>;
36
34
  }
@@ -1,9 +1,9 @@
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';
1
+ import type { StoreAddCartShippingMethods, StoreInitializePaymentSession, StoreUpdateCart } from '@medusajs/types';
2
+ import type { Address, Cache, CheckoutFactory, CheckoutFactoryCheckoutOutput, CheckoutFactoryPaymentMethodOutput, CheckoutFactoryShippingMethodOutput, CheckoutFactoryWithOutput, CheckoutIdentifier, CheckoutMutationAddPaymentInstruction, CheckoutMutationFinalizeCheckout, CheckoutMutationInitiateCheckout, CheckoutMutationRemovePaymentInstruction, CheckoutMutationSetShippingAddress, CheckoutMutationSetShippingInstruction, CheckoutQueryById, CheckoutQueryForAvailablePaymentMethods, CheckoutQueryForAvailableShippingMethods, NotFoundError, RequestContext, Result } from '@reactionary/core';
3
3
  import { CheckoutCapability } from '@reactionary/core';
4
4
  import type { MedusaAPI } from '../core/client.js';
5
- import type { MedusaConfiguration } from '../schema/configuration.schema.js';
6
5
  import type { MedusaCheckoutFactory } from '../factories/checkout/checkout.factory.js';
6
+ import type { MedusaConfiguration } from '../schema/configuration.schema.js';
7
7
  export declare class CheckoutNotReadyForFinalizationError extends Error {
8
8
  checkoutIdentifier: CheckoutIdentifier;
9
9
  constructor(checkoutIdentifier: CheckoutIdentifier);
@@ -53,36 +53,4 @@ export declare class MedusaCheckoutCapability<TFactory extends CheckoutFactory =
53
53
  postal_code: string | undefined;
54
54
  country_code: string | undefined;
55
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
56
  }
@@ -1,21 +1,11 @@
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';
1
+ import { type Cache, InventoryCapability, type InventoryFactory, type InventoryFactoryOutput, type InventoryFactoryWithOutput, type InventoryQueryBySKU, type NotFoundError, type RequestContext, type Result } from '@reactionary/core';
3
2
  import { type MedusaAPI } from '../core/client.js';
4
3
  import type { MedusaInventoryFactory } from '../factories/inventory/inventory.factory.js';
4
+ import type { MedusaConfiguration } from '../schema/configuration.schema.js';
5
5
  export declare class MedusaInventoryCapability<TFactory extends InventoryFactory = MedusaInventoryFactory> extends InventoryCapability<InventoryFactoryOutput<TFactory>> {
6
6
  medusaApi: MedusaAPI;
7
7
  protected config: MedusaConfiguration;
8
8
  protected factory: InventoryFactoryWithOutput<TFactory>;
9
9
  constructor(config: MedusaConfiguration, cache: Cache, context: RequestContext, medusaApi: MedusaAPI, factory: InventoryFactoryWithOutput<TFactory>);
10
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
11
  }
@@ -1,9 +1,8 @@
1
- import type { RequestContext, Cache, OrderSearchQueryByTerm, Result, Address, IdentityIdentifier, MonetaryAmount, OrderSearchResultItem, OrderSearchFactory, OrderSearchFactoryOutput, OrderSearchFactoryWithOutput } from '@reactionary/core';
1
+ import type { Cache, OrderSearchFactory, OrderSearchFactoryOutput, OrderSearchFactoryWithOutput, OrderSearchQueryByTerm, RequestContext, Result } from '@reactionary/core';
2
2
  import { OrderSearchCapability } from '@reactionary/core';
3
- import type { MedusaConfiguration } from '../schema/configuration.schema.js';
4
3
  import type { MedusaAPI } from '../core/client.js';
5
- import type { StoreOrder, StoreOrderAddress, StoreOrderListResponse } from '@medusajs/types';
6
4
  import type { MedusaOrderSearchFactory } from '../factories/order-search/order-search.factory.js';
5
+ import type { MedusaConfiguration } from '../schema/configuration.schema.js';
7
6
  export declare class MedusaOrderSearchCapability<TFactory extends OrderSearchFactory = MedusaOrderSearchFactory> extends OrderSearchCapability<OrderSearchFactoryOutput<TFactory>> {
8
7
  medusaApi: MedusaAPI;
9
8
  protected config: MedusaConfiguration;
@@ -11,43 +10,4 @@ export declare class MedusaOrderSearchCapability<TFactory extends OrderSearchFac
11
10
  constructor(config: MedusaConfiguration, cache: Cache, context: RequestContext, medusaApi: MedusaAPI, factory: OrderSearchFactoryWithOutput<TFactory>);
12
11
  protected queryByTermPayload(payload: OrderSearchQueryByTerm): any;
13
12
  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
13
  }
@@ -1,49 +1,12 @@
1
- import type { Cache, OrderQueryById, RequestContext, Result, NotFoundError, CostBreakDown, Currency, OrderItem, ItemCostBreakdown, PaymentMethodIdentifier, OrderFactory, OrderFactoryOutput, OrderFactoryWithOutput } from '@reactionary/core';
1
+ import type { Cache, NotFoundError, OrderFactory, OrderFactoryOutput, OrderFactoryWithOutput, OrderQueryById, RequestContext, Result } from '@reactionary/core';
2
2
  import { OrderCapability } from '@reactionary/core';
3
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
4
  import type { MedusaOrderFactory } from '../factories/order/order.factory.js';
5
+ import type { MedusaConfiguration } from '../schema/configuration.schema.js';
7
6
  export declare class MedusaOrderCapability<TFactory extends OrderFactory = MedusaOrderFactory> extends OrderCapability<OrderFactoryOutput<TFactory>> {
8
7
  medusaApi: MedusaAPI;
9
8
  protected config: MedusaConfiguration;
10
9
  protected factory: OrderFactoryWithOutput<TFactory>;
11
10
  constructor(config: MedusaConfiguration, cache: Cache, context: RequestContext, medusaApi: MedusaAPI, factory: OrderFactoryWithOutput<TFactory>);
12
11
  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
12
  }
@@ -1,8 +1,7 @@
1
- import type { StoreProductVariant } from '@medusajs/types';
2
1
  import { PriceCapability, type Cache, type CustomerPriceQuery, type ListPriceQuery, type PriceFactory, type PriceFactoryOutput, type PriceFactoryWithOutput, type RequestContext, type Result } from '@reactionary/core';
3
2
  import type { MedusaAPI } from '../core/client.js';
4
- import type { MedusaConfiguration } from '../schema/configuration.schema.js';
5
3
  import type { MedusaPriceFactory } from '../factories/price/price.factory.js';
4
+ import type { MedusaConfiguration } from '../schema/configuration.schema.js';
6
5
  export declare class MedusaPriceCapability<TFactory extends PriceFactory = MedusaPriceFactory> extends PriceCapability<PriceFactoryOutput<TFactory>> {
7
6
  medusaApi: MedusaAPI;
8
7
  protected config: MedusaConfiguration;
@@ -11,6 +10,4 @@ export declare class MedusaPriceCapability<TFactory extends PriceFactory = Medus
11
10
  getListPrice(payload: ListPriceQuery): Promise<Result<PriceFactoryOutput<TFactory>>>;
12
11
  getCustomerPrice(payload: CustomerPriceQuery): Promise<Result<PriceFactoryOutput<TFactory>>>;
13
12
  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
13
  }
@@ -1,19 +1,15 @@
1
+ import type { Cache, ProductAssociationsFactory, ProductAssociationsFactoryOutput, ProductAssociationsFactoryWithOutput, ProductAssociationsGetAccessoriesQuery, ProductAssociationsGetReplacementsQuery, ProductAssociationsGetSparepartsQuery, ProductIdentifier, RequestContext, Result } from '@reactionary/core';
1
2
  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
3
  import type { MedusaAPI } from '../core/client.js';
6
- import type { StoreProduct, StoreProductVariant } from '@medusajs/types';
7
4
  import type { MedusaProductAssociationsFactory } from '../factories/product-associations/product-associations.factory.js';
5
+ import type { MedusaConfiguration } from '../schema/configuration.schema.js';
8
6
  export declare class MedusaProductAssociationsCapability<TFactory extends ProductAssociationsFactory = MedusaProductAssociationsFactory> extends ProductAssociationsCapability<ProductAssociationsFactoryOutput<TFactory>> {
9
7
  protected config: MedusaConfiguration;
10
8
  protected medusa: MedusaAPI;
11
9
  protected factory: ProductAssociationsFactoryWithOutput<TFactory>;
12
10
  constructor(config: MedusaConfiguration, cache: Cache, context: RequestContext, medusa: MedusaAPI, factory: ProductAssociationsFactoryWithOutput<TFactory>);
13
- protected fetchAssociatedProductsFor(productKey: ProductIdentifier, maxNumberOfAssociations: number, attributeName: string): Promise<ProductSearchResultItem[]>;
11
+ protected fetchAssociatedProductsFor(productKey: ProductIdentifier, maxNumberOfAssociations: number, attributeName: string): Promise<import("@medusajs/types").StoreProduct[]>;
14
12
  getAccessories(query: ProductAssociationsGetAccessoriesQuery): Promise<Result<ProductAssociationsFactoryOutput<TFactory>[]>>;
15
13
  getSpareparts(query: ProductAssociationsGetSparepartsQuery): Promise<Result<ProductAssociationsFactoryOutput<TFactory>[]>>;
16
14
  getReplacements(query: ProductAssociationsGetReplacementsQuery): Promise<Result<ProductAssociationsFactoryOutput<TFactory>[]>>;
17
- protected parseSingle(_body: StoreProduct): ProductSearchResultItem;
18
- protected parseVariant(variant: StoreProductVariant, product: StoreProduct): ProductSearchResultItemVariant;
19
15
  }
@@ -1,8 +1,8 @@
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';
1
+ import type { StoreProductCategory } from '@medusajs/types';
2
+ import { ProductSearchCapability, type Cache, type FacetValueIdentifier, type ProductSearchFactory, type ProductSearchFactoryOutput, type ProductSearchFactoryWithOutput, type ProductSearchQueryByTerm, type ProductSearchQueryCreateNavigationFilter, type RequestContext, type Result } from '@reactionary/core';
3
3
  import type { MedusaAPI } from '../core/client.js';
4
- import type { StoreProduct, StoreProductCategory, StoreProductListResponse, StoreProductVariant } from '@medusajs/types';
5
4
  import type { MedusaProductSearchFactory } from '../factories/product-search/product-search.factory.js';
5
+ import type { MedusaConfiguration } from '../schema/configuration.schema.js';
6
6
  export declare class MedusaProductSearchCapability<TFactory extends ProductSearchFactory = MedusaProductSearchFactory> extends ProductSearchCapability<ProductSearchFactoryOutput<TFactory>> {
7
7
  medusaApi: MedusaAPI;
8
8
  protected config: MedusaConfiguration;
@@ -10,36 +10,6 @@ export declare class MedusaProductSearchCapability<TFactory extends ProductSearc
10
10
  constructor(config: MedusaConfiguration, cache: Cache, context: RequestContext, medusaApi: MedusaAPI, factory: ProductSearchFactoryWithOutput<TFactory>);
11
11
  protected resolveCategoryIdByExternalId(externalId: string): Promise<StoreProductCategory | null>;
12
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
13
  createCategoryNavigationFilter(payload: ProductSearchQueryCreateNavigationFilter): Promise<Result<FacetValueIdentifier>>;
14
+ queryByTerm(payload: ProductSearchQueryByTerm): Promise<Result<ProductSearchFactoryOutput<TFactory>>>;
45
15
  }
@@ -1,8 +1,7 @@
1
- import type { Cache, NotFoundError, ProductAttribute, ProductFactory, ProductFactoryOutput, ProductFactoryWithOutput, ProductQueryById, ProductQueryBySKU, ProductQueryBySlug, ProductVariant, RequestContext, Result } from '@reactionary/core';
1
+ import type { Cache, NotFoundError, ProductFactory, ProductFactoryOutput, ProductFactoryWithOutput, ProductQueryById, ProductQueryBySKU, ProductQueryBySlug, RequestContext, Result } from '@reactionary/core';
2
2
  import { ProductCapability } from '@reactionary/core';
3
3
  import type { MedusaAPI } from '../core/client.js';
4
4
  import type { MedusaConfiguration } from '../schema/configuration.schema.js';
5
- import type { StoreProduct, StoreProductVariant } from '@medusajs/types';
6
5
  import type { MedusaProductFactory } from '../factories/product/product.factory.js';
7
6
  export declare class MedusaProductCapability<TFactory extends ProductFactory = MedusaProductFactory> extends ProductCapability<ProductFactoryOutput<TFactory>> {
8
7
  medusaApi: MedusaAPI;
@@ -25,8 +24,4 @@ export declare class MedusaProductCapability<TFactory extends ProductFactory = M
25
24
  };
26
25
  getBySlug(payload: ProductQueryBySlug): Promise<Result<ProductFactoryOutput<TFactory>, NotFoundError>>;
27
26
  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
27
  }
@@ -1,8 +1,8 @@
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';
1
+ import type { StoreCreateCustomerAddress } from '@medusajs/types';
2
+ import { type Address, type Cache, type NotFoundError, ProfileCapability, type ProfileFactory, type ProfileFactoryOutput, type ProfileFactoryWithOutput, type ProfileMutationAddShippingAddress, type ProfileMutationMakeShippingAddressDefault, type ProfileMutationRemoveShippingAddress, type ProfileMutationSetBillingAddress, type ProfileMutationUpdate, type ProfileMutationUpdateShippingAddress, type ProfileQuerySelf as ProfileQueryById, type RequestContext, type Result } from '@reactionary/core';
3
3
  import type { MedusaAPI } from '../core/client.js';
4
- import type { StoreCreateCustomerAddress, StoreCustomer, StoreCustomerAddress } from '@medusajs/types';
5
4
  import type { MedusaProfileFactory } from '../factories/profile/profile.factory.js';
5
+ import type { MedusaConfiguration } from '../schema/configuration.schema.js';
6
6
  /**
7
7
  * Medusa Profile Capability
8
8
  *
@@ -34,6 +34,4 @@ export declare class MedusaProfileCapability<TFactory extends ProfileFactory = M
34
34
  protected setBillingAddressPayload(payload: ProfileMutationSetBillingAddress): StoreCreateCustomerAddress;
35
35
  setBillingAddress(payload: ProfileMutationSetBillingAddress): Promise<Result<ProfileFactoryOutput<TFactory>, NotFoundError>>;
36
36
  protected createMedusaAddress(address: Address): StoreCreateCustomerAddress;
37
- protected parseAddress(address: StoreCustomerAddress): Address;
38
- protected parseSingle(customer: StoreCustomer): ProfileFactoryOutput<TFactory>;
39
37
  }
@@ -1,9 +1,30 @@
1
- import type { AnyCartIdentifierSchema, AnyCartSchema, CartFactory, CartIdentifierSchema, CartSchema, RequestContext } from '@reactionary/core';
1
+ import type { StoreCart, StoreCartLineItem } from '@medusajs/types';
2
+ import { type AnyCartIdentifierSchema, type AnyCartSchema, type CartFactory, type CartIdentifierSchema, type CartItem, type CartSchema, type CostBreakDown, type Currency, type ItemCostBreakdown, type RequestContext } from '@reactionary/core';
2
3
  import type * as z from 'zod';
3
4
  export declare class MedusaCartFactory<TCartSchema extends AnyCartSchema = typeof CartSchema, TCartIdentifierSchema extends AnyCartIdentifierSchema = typeof CartIdentifierSchema> implements CartFactory<TCartSchema, TCartIdentifierSchema> {
4
5
  readonly cartSchema: TCartSchema;
5
6
  readonly cartIdentifierSchema: TCartIdentifierSchema;
6
7
  constructor(cartSchema: TCartSchema, cartIdentifierSchema: TCartIdentifierSchema);
7
- parseCart(_context: RequestContext, data: unknown): z.output<TCartSchema>;
8
+ parseCart(context: RequestContext, data: StoreCart): z.output<TCartSchema>;
8
9
  parseCartIdentifier(_context: RequestContext, data: unknown): z.output<TCartIdentifierSchema>;
10
+ /**
11
+ * Extension point to control the parsing of a single cart item price
12
+ * @param remoteItem
13
+ * @param currency
14
+ * @returns
15
+ */
16
+ protected parseItemPrice(_context: RequestContext, remoteItem: StoreCartLineItem, currency: Currency): ItemCostBreakdown;
17
+ /**
18
+ * Extension point to control the parsing of the cost breakdown of a cart
19
+ * @param remote
20
+ * @returns
21
+ */
22
+ protected parseCostBreakdown(_context: RequestContext, remote: StoreCart): CostBreakDown;
23
+ /**
24
+ * Extension point to control the parsing of a single cart item
25
+ * @param remoteItem
26
+ * @param currency
27
+ * @returns
28
+ */
29
+ protected parseCartItem(context: RequestContext, remoteItem: StoreCartLineItem, currency: Currency): CartItem;
9
30
  }
@@ -1,9 +1,10 @@
1
- import type { AnyCategoryPaginatedResultSchema, AnyCategorySchema, CategoryFactory, CategoryPaginatedResultSchema, CategorySchema, RequestContext } from '@reactionary/core';
1
+ import type { StoreProductCategory, StoreProductCategoryListResponse } from '@medusajs/types';
2
+ import { type AnyCategoryPaginatedResultSchema, type AnyCategorySchema, type CategoryFactory, type CategoryPaginatedResultSchema, type CategorySchema, type RequestContext } from '@reactionary/core';
2
3
  import type * as z from 'zod';
3
4
  export declare class MedusaCategoryFactory<TCategorySchema extends AnyCategorySchema = typeof CategorySchema, TCategoryPaginatedSchema extends AnyCategoryPaginatedResultSchema = typeof CategoryPaginatedResultSchema> implements CategoryFactory<TCategorySchema, TCategoryPaginatedSchema> {
4
5
  readonly categorySchema: TCategorySchema;
5
6
  readonly categoryPaginatedResultSchema: TCategoryPaginatedSchema;
6
7
  constructor(categorySchema: TCategorySchema, categoryPaginatedResultSchema: TCategoryPaginatedSchema);
7
- parseCategory(_context: RequestContext, data: unknown): z.output<TCategorySchema>;
8
- parseCategoryPaginatedResult(_context: RequestContext, data: unknown): z.output<TCategoryPaginatedSchema>;
8
+ parseCategory(_context: RequestContext, data: StoreProductCategory): z.output<TCategorySchema>;
9
+ parseCategoryPaginatedResult(context: RequestContext, data: StoreProductCategoryListResponse): z.output<TCategoryPaginatedSchema>;
9
10
  }
@@ -1,11 +1,38 @@
1
- import type { AnyCheckoutSchema, AnyPaymentMethodSchema, AnyShippingMethodSchema, CheckoutFactory, CheckoutSchema, PaymentMethodSchema, RequestContext, ShippingMethodSchema } from '@reactionary/core';
1
+ import type { StoreCart, StoreCartAddress, StoreCartLineItem, StoreCartShippingOptionWithServiceZone, StorePaymentProvider } from '@medusajs/types';
2
+ import { type Address, type AnyCheckoutSchema, type AnyPaymentMethodSchema, type AnyShippingMethodSchema, type CheckoutFactory, type CheckoutItem, type CheckoutSchema, type CostBreakDown, type Currency, type ItemCostBreakdown, type PaymentMethodSchema, type RequestContext, type ShippingMethodSchema } from '@reactionary/core';
2
3
  import type * as z from 'zod';
3
4
  export declare class MedusaCheckoutFactory<TCheckoutSchema extends AnyCheckoutSchema = typeof CheckoutSchema, TShippingMethodSchema extends AnyShippingMethodSchema = typeof ShippingMethodSchema, TPaymentMethodSchema extends AnyPaymentMethodSchema = typeof PaymentMethodSchema> implements CheckoutFactory<TCheckoutSchema, TShippingMethodSchema, TPaymentMethodSchema> {
4
5
  readonly checkoutSchema: TCheckoutSchema;
5
6
  readonly shippingMethodSchema: TShippingMethodSchema;
6
7
  readonly paymentMethodSchema: TPaymentMethodSchema;
7
8
  constructor(checkoutSchema: TCheckoutSchema, shippingMethodSchema: TShippingMethodSchema, paymentMethodSchema: TPaymentMethodSchema);
8
- parseCheckout(_context: RequestContext, data: unknown): z.output<TCheckoutSchema>;
9
- parseShippingMethod(_context: RequestContext, data: unknown): z.output<TShippingMethodSchema>;
10
- parsePaymentMethod(_context: RequestContext, data: unknown): z.output<TPaymentMethodSchema>;
9
+ /**
10
+ * Extension point to control the parsing of a single cart item price
11
+ * @param remoteItem
12
+ * @param currency
13
+ * @returns
14
+ */
15
+ protected parseItemPrice(_context: RequestContext, remoteItem: StoreCartLineItem, currency: Currency): ItemCostBreakdown;
16
+ /**
17
+ * Extension point to control the parsing of the cost breakdown of a cart
18
+ * @param remote
19
+ * @returns
20
+ */
21
+ protected parseCostBreakdown(_context: RequestContext, remote: StoreCart): CostBreakDown;
22
+ /**
23
+ * Extension point to control the parsing of a single checkout item
24
+ * @param remoteItem
25
+ * @param currency
26
+ * @returns
27
+ */
28
+ protected parseCheckoutItem(context: RequestContext, remoteItem: StoreCartLineItem, currency: Currency): CheckoutItem;
29
+ /**
30
+ * Extension point to control the parsing of an address from a store cart address
31
+ * @param storeAddress
32
+ * @returns
33
+ */
34
+ protected parseAddress(_context: RequestContext, storeAddress: StoreCartAddress): Address;
35
+ parseCheckout(context: RequestContext, data: StoreCart): z.output<TCheckoutSchema>;
36
+ parseShippingMethod(_context: RequestContext, data: StoreCartShippingOptionWithServiceZone): z.output<TShippingMethodSchema>;
37
+ parsePaymentMethod(_context: RequestContext, data: StorePaymentProvider): z.output<TPaymentMethodSchema>;
11
38
  }
@@ -1,7 +1,13 @@
1
1
  import type { AnyInventorySchema, InventoryFactory, InventorySchema, RequestContext } from '@reactionary/core';
2
2
  import type * as z from 'zod';
3
+ export interface MedusaInventoryParseInput {
4
+ sku: string;
5
+ fulfillmentCenterKey: string;
6
+ quantity: number;
7
+ inventoryItemId: string;
8
+ }
3
9
  export declare class MedusaInventoryFactory<TInventorySchema extends AnyInventorySchema = typeof InventorySchema> implements InventoryFactory<TInventorySchema> {
4
10
  readonly inventorySchema: TInventorySchema;
5
11
  constructor(inventorySchema: TInventorySchema);
6
- parseInventory(_context: RequestContext, data: unknown): z.output<TInventorySchema>;
12
+ parseInventory(_context: RequestContext, data: MedusaInventoryParseInput): z.output<TInventorySchema>;
7
13
  }
@@ -1,7 +1,43 @@
1
- import type { AnyOrderSchema, OrderFactory, OrderSchema, RequestContext } from '@reactionary/core';
1
+ import type { StoreOrder, StoreOrderLineItem, StorePaymentCollection } from '@medusajs/types';
2
+ import { type AnyOrderSchema, type CostBreakDown, type Currency, type ItemCostBreakdown, type OrderFactory, type OrderItem, type OrderSchema, type PaymentMethodIdentifier, type RequestContext } from '@reactionary/core';
2
3
  import type * as z from 'zod';
3
4
  export declare class MedusaOrderFactory<TOrderSchema extends AnyOrderSchema = typeof OrderSchema> implements OrderFactory<TOrderSchema> {
4
5
  readonly orderSchema: TOrderSchema;
5
6
  constructor(orderSchema: TOrderSchema);
6
- parseOrder(_context: RequestContext, data: unknown): z.output<TOrderSchema>;
7
+ parseOrder(context: RequestContext, data: StoreOrder): z.output<TOrderSchema>;
8
+ /**
9
+ * Extension point to control the parsing of a single cart item price
10
+ * @param remoteItem
11
+ * @param currency
12
+ * @returns
13
+ */
14
+ protected parseItemPrice(context: RequestContext, remoteItem: StoreOrderLineItem, currency: Currency): ItemCostBreakdown;
15
+ /**
16
+ * Extension point to control the parsing of the cost breakdown of a cart
17
+ * @param remote
18
+ * @returns
19
+ */
20
+ protected parseCostBreakdown(_context: RequestContext, remote: StoreOrder): CostBreakDown;
21
+ /**
22
+ * Extension point to control the parsing of a single cart item
23
+ * @param remoteItem
24
+ * @param currency
25
+ * @returns
26
+ */
27
+ protected parseOrderItem(context: RequestContext, remoteItem: StoreOrderLineItem, currency: Currency): OrderItem;
28
+ protected parsePaymentInstruction(_context: RequestContext, remotePayment: StorePaymentCollection, order: StoreOrder): {
29
+ identifier: {
30
+ key: string;
31
+ };
32
+ amount: {
33
+ value: number;
34
+ currency: Currency;
35
+ };
36
+ paymentMethod: PaymentMethodIdentifier;
37
+ protocolData: {
38
+ key: string;
39
+ value: string;
40
+ }[];
41
+ status: "pending" | "authorized" | "canceled" | "capture";
42
+ };
7
43
  }
@@ -1,7 +1,25 @@
1
- import type { AnyOrderSearchResultSchema, OrderSearchFactory, OrderSearchQueryByTerm, OrderSearchResultSchema, RequestContext } from '@reactionary/core';
1
+ import type { StoreOrder, StoreOrderAddress, StoreOrderListResponse } from '@medusajs/types';
2
+ import { type Address, type AnyOrderSearchResultSchema, type IdentityIdentifier, type MonetaryAmount, type OrderSearchFactory, type OrderSearchQueryByTerm, type OrderSearchResultSchema, type RequestContext } from '@reactionary/core';
2
3
  import type * as z from 'zod';
3
4
  export declare class MedusaOrderSearchFactory<TOrderSearchResultSchema extends AnyOrderSearchResultSchema = typeof OrderSearchResultSchema> implements OrderSearchFactory<TOrderSearchResultSchema> {
4
5
  readonly orderSearchResultSchema: TOrderSearchResultSchema;
5
6
  constructor(orderSearchResultSchema: TOrderSearchResultSchema);
6
- parseOrderSearchResult(_context: RequestContext, data: unknown, _query: OrderSearchQueryByTerm): z.output<TOrderSearchResultSchema>;
7
+ protected parseOrderSearchResultItem(context: RequestContext, body: StoreOrder): {
8
+ identifier: {
9
+ key: string;
10
+ };
11
+ userId: IdentityIdentifier;
12
+ customerName: string;
13
+ shippingAddress: Address;
14
+ orderDate: string;
15
+ orderStatus: "AwaitingPayment" | "ReleasedToFulfillment" | "Shipped" | "Cancelled";
16
+ inventoryStatus: ("NotAllocated" & {
17
+ _?: never;
18
+ }) | ("Allocated" & {
19
+ _?: never;
20
+ });
21
+ totalAmount: MonetaryAmount;
22
+ };
23
+ protected parseAddress(_context: RequestContext, storeAddress: StoreOrderAddress): Address;
24
+ parseOrderSearchResult(_context: RequestContext, data: StoreOrderListResponse, query: OrderSearchQueryByTerm): z.output<TOrderSearchResultSchema>;
7
25
  }
@@ -1,9 +1,14 @@
1
+ import type { StoreProductVariant } from '@medusajs/types';
1
2
  import type { AnyPriceSchema, PriceFactory, PriceSchema, RequestContext } from '@reactionary/core';
2
3
  import type * as z from 'zod';
4
+ export interface MedusaPriceFactoryParseInput {
5
+ variant: StoreProductVariant;
6
+ mode: 'list' | 'customer';
7
+ }
3
8
  export declare class MedusaPriceFactory<TPriceSchema extends AnyPriceSchema = typeof PriceSchema> implements PriceFactory<TPriceSchema> {
4
9
  readonly priceSchema: TPriceSchema;
5
10
  constructor(priceSchema: TPriceSchema);
6
- parsePrice(_context: RequestContext, data: unknown, _options?: {
11
+ parsePrice(context: RequestContext, data: MedusaPriceFactoryParseInput, _options?: {
7
12
  includeDiscounts: boolean;
8
13
  }): z.output<TPriceSchema>;
9
14
  }
@@ -1,7 +1,11 @@
1
- import type { AnyProductSchema, ProductFactory, ProductSchema, RequestContext } from '@reactionary/core';
1
+ import type { StoreProduct, StoreProductVariant } from '@medusajs/types';
2
+ import { type AnyProductSchema, type ProductAttribute, type ProductFactory, type ProductSchema, type ProductVariant, type RequestContext } from '@reactionary/core';
2
3
  import type * as z from 'zod';
3
4
  export declare class MedusaProductFactory<TProductSchema extends AnyProductSchema = typeof ProductSchema> implements ProductFactory<TProductSchema> {
4
5
  readonly productSchema: TProductSchema;
5
6
  constructor(productSchema: TProductSchema);
6
- parseProduct(_context: RequestContext, data: unknown): z.output<TProductSchema>;
7
+ protected parseVariant(_context: RequestContext, variant: StoreProductVariant, product: StoreProduct): ProductVariant;
8
+ protected createSynthAttribute(key: string, name: string, value: string): ProductAttribute;
9
+ protected parseAttributes(_context: RequestContext, _body: StoreProduct): Array<ProductAttribute>;
10
+ parseProduct(context: RequestContext, data: StoreProduct): z.output<TProductSchema>;
7
11
  }
@@ -1,7 +1,13 @@
1
- import type { AnyProductAssociationSchema, ProductAssociationSchema, ProductAssociationsFactory, RequestContext } from '@reactionary/core';
1
+ import type { StoreProduct, StoreProductVariant } from '@medusajs/types';
2
+ import { type AnyProductAssociationSchema, type ProductAssociationSchema, type ProductAssociationsFactory, type ProductAssociationsIdentifier, type ProductSearchResultItemVariant, type RequestContext } from '@reactionary/core';
2
3
  import type * as z from 'zod';
4
+ export interface MedusaProductAssociationFactoryInput {
5
+ product: StoreProduct;
6
+ identifier: ProductAssociationsIdentifier;
7
+ }
3
8
  export declare class MedusaProductAssociationsFactory<TProductAssociationSchema extends AnyProductAssociationSchema = typeof ProductAssociationSchema> implements ProductAssociationsFactory<TProductAssociationSchema> {
4
9
  readonly productAssociationSchema: TProductAssociationSchema;
5
10
  constructor(productAssociationSchema: TProductAssociationSchema);
6
- parseAssociation(_context: RequestContext, data: unknown): z.output<TProductAssociationSchema>;
11
+ parseAssociation(context: RequestContext, data: MedusaProductAssociationFactoryInput): z.output<TProductAssociationSchema>;
12
+ protected parseVariant(_context: RequestContext, variant: StoreProductVariant, product: StoreProduct): ProductSearchResultItemVariant;
7
13
  }
@@ -1,7 +1,10 @@
1
- import type { AnyProductSearchResultSchema, ProductSearchFactory, ProductSearchQueryByTerm, ProductSearchResultSchema, RequestContext } from '@reactionary/core';
1
+ import type { StoreProduct, StoreProductListResponse, StoreProductVariant } from '@medusajs/types';
2
+ import { type AnyProductSearchResultSchema, type ProductSearchFactory, type ProductSearchQueryByTerm, type ProductSearchResultItem, type ProductSearchResultItemVariant, type ProductSearchResultSchema, type RequestContext } from '@reactionary/core';
2
3
  import type * as z from 'zod';
3
4
  export declare class MedusaProductSearchFactory<TProductSearchResultSchema extends AnyProductSearchResultSchema = typeof ProductSearchResultSchema> implements ProductSearchFactory<TProductSearchResultSchema> {
4
5
  readonly productSearchResultSchema: TProductSearchResultSchema;
5
6
  constructor(productSearchResultSchema: TProductSearchResultSchema);
6
- parseSearchResult(_context: RequestContext, data: unknown, _query: ProductSearchQueryByTerm): z.output<TProductSearchResultSchema>;
7
+ parseSearchResult(context: RequestContext, remote: StoreProductListResponse, query: ProductSearchQueryByTerm): z.output<TProductSearchResultSchema>;
8
+ protected parseProductSearchResultItem(context: RequestContext, data: StoreProduct): ProductSearchResultItem;
9
+ protected parseVariant(_context: RequestContext, variant: StoreProductVariant, product: StoreProduct): ProductSearchResultItemVariant;
7
10
  }
@@ -1,7 +1,9 @@
1
- import type { AnyProfileSchema, ProfileFactory, ProfileSchema, RequestContext } from '@reactionary/core';
1
+ import type { StoreCustomer, StoreCustomerAddress } from '@medusajs/types';
2
+ import type { Address, AnyProfileSchema, ProfileFactory, ProfileSchema, RequestContext } from '@reactionary/core';
2
3
  import type * as z from 'zod';
3
4
  export declare class MedusaProfileFactory<TProfileSchema extends AnyProfileSchema = typeof ProfileSchema> implements ProfileFactory<TProfileSchema> {
4
5
  readonly profileSchema: TProfileSchema;
5
6
  constructor(profileSchema: TProfileSchema);
6
- parseProfile(_context: RequestContext, data: unknown): z.output<TProfileSchema>;
7
+ parseProfile(context: RequestContext, data: StoreCustomer): z.output<TProfileSchema>;
8
+ protected parseAddress(context: RequestContext, address: StoreCustomerAddress): Address;
7
9
  }