Skip to content

Commit

Permalink
feat(cart): JoinerConfig (medusajs#6157)
Browse files Browse the repository at this point in the history
  • Loading branch information
olivermrbl authored Jan 28, 2024
1 parent 360c71e commit 5c4a5a1
Showing 1 changed file with 73 additions and 6 deletions.
79 changes: 73 additions & 6 deletions packages/cart/src/joiner-config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
import { Modules } from "@medusajs/modules-sdk"
import { ModuleJoinerConfig } from "@medusajs/types"
import { MapToConfig } from "@medusajs/utils"
import { Cart } from "@models"
import {
Address,
Cart,
LineItem,
LineItemAdjustment,
LineItemTaxLine,
ShippingMethod,
ShippingMethodAdjustment,
ShippingMethodTaxLine,
} from "@models"

export const LinkableKeys = {
cart_id: Cart.name,
line_item_id: LineItem.name,
shipping_method_id: ShippingMethod.name,
address_id: Address.name,
line_item_adjustment_id: LineItemAdjustment.name,
shipping_method_adjustment_id: ShippingMethodAdjustment.name,
line_item_tax_line_id: LineItemTaxLine.name,
shipping_method_tax_line_id: ShippingMethodTaxLine.name,
}

const entityLinkableKeysMap: MapToConfig = {}
Expand All @@ -22,10 +38,61 @@ export const joinerConfig: ModuleJoinerConfig = {
serviceName: Modules.CART,
primaryKeys: ["id"],
linkableKeys: LinkableKeys,
alias: {
name: ["cart", "carts"],
args: {
entity: Cart.name,
alias: [
{
name: ["cart", "carts"],
args: {
entity: Cart.name,
},
},
},
{
name: ["line_item", "line_items"],
args: {
entity: LineItem.name,
methodSuffix: "LineItems",
},
},
{
name: ["shipping_method", "shipping_methods"],
args: {
entity: ShippingMethod.name,
methodSuffix: "ShippingMethods",
},
},
{
name: ["address", "addresses"],
args: {
entity: Address.name,
methodSuffix: "Addresses",
},
},
{
name: ["line_item_adjustment", "line_item_adjustments"],
args: {
entity: LineItemAdjustment.name,
methodSuffix: "LineItemAdjustments",
},
},
{
name: ["shipping_method_adjustment", "shipping_method_adjustments"],
args: {
entity: ShippingMethodAdjustment.name,
methodSuffix: "ShippingMethodAdjustments",
},
},
{
name: ["line_item_tax_line", "line_item_tax_lines"],
args: {
entity: LineItemTaxLine.name,
methodSuffix: "LineItemTaxLines",
},
},
{
name: ["shipping_method_tax_line", "shipping_method_tax_lines"],
args: {
entity: ShippingMethodTaxLine.name,
methodSuffix: "ShippingMethodTaxLines",
},
},
],
}

0 comments on commit 5c4a5a1

Please sign in to comment.