diff --git a/packages/link-modules/src/definitions/cart-sales-channel.ts b/packages/link-modules/src/definitions/cart-sales-channel.ts index e990437ff47d7..3615958780cac 100644 --- a/packages/link-modules/src/definitions/cart-sales-channel.ts +++ b/packages/link-modules/src/definitions/cart-sales-channel.ts @@ -1,6 +1,6 @@ +import { Modules } from "@medusajs/modules-sdk" import { ModuleJoinerConfig } from "@medusajs/types" import { LINKS } from "../links" -import { Modules } from "@medusajs/modules-sdk" export const CartSalesChannel: ModuleJoinerConfig = { serviceName: LINKS.CartSalesChannel, @@ -21,14 +21,12 @@ export const CartSalesChannel: ModuleJoinerConfig = { relationships: [ { serviceName: Modules.CART, - isInternalService: true, primaryKey: "id", foreignKey: "cart_id", alias: "cart", }, { serviceName: Modules.SALES_CHANNEL, - isInternalService: true, primaryKey: "id", foreignKey: "sales_channel_id", alias: "sales_channel", @@ -42,7 +40,6 @@ export const CartSalesChannel: ModuleJoinerConfig = { }, relationship: { serviceName: LINKS.CartSalesChannel, - isInternalService: true, primaryKey: "cart_id", foreignKey: "id", alias: "sales_channel_link", @@ -55,7 +52,6 @@ export const CartSalesChannel: ModuleJoinerConfig = { }, relationship: { serviceName: LINKS.CartSalesChannel, - isInternalService: true, primaryKey: "sales_channel_id", foreignKey: "id", alias: "cart_link", diff --git a/packages/medusa/src/api-v2/store/carts/[id]/route.ts b/packages/medusa/src/api-v2/store/carts/[id]/route.ts index e0bbedacf8d09..c4c6071c08de2 100644 --- a/packages/medusa/src/api-v2/store/carts/[id]/route.ts +++ b/packages/medusa/src/api-v2/store/carts/[id]/route.ts @@ -1,30 +1,19 @@ -import { ModuleRegistrationName } from "@medusajs/modules-sdk" -import { ICartModuleService } from "@medusajs/types" import { MedusaRequest, MedusaResponse } from "../../../../types/routing" +import { defaultStoreCartRemoteQueryObject } from "../query-config" export const GET = async (req: MedusaRequest, res: MedusaResponse) => { - const cartModuleService: ICartModuleService = req.scope.resolve( - ModuleRegistrationName.CART - ) + const remoteQuery = req.scope.resolve("remoteQuery") - // TODO: Replace with remoteQuery - const cart = await cartModuleService.retrieve(req.params.id, { - select: req.retrieveConfig.select, - relations: req.retrieveConfig.relations, - }) + const variables = { id: req.params.id } - // const remoteQuery = req.scope.resolve("remoteQuery") + const query = { + cart: { + __args: variables, + ...defaultStoreCartRemoteQueryObject, + }, + } - // const variables = { id: req.params.id } - - // const query = { - // cart: { - // __args: variables, - // ...defaultStoreCartRemoteQueryObject, - // }, - // } - - // const [cart] = await remoteQuery(query) + const [cart] = await remoteQuery(query) res.json({ cart }) } diff --git a/packages/medusa/src/api-v2/store/carts/query-config.ts b/packages/medusa/src/api-v2/store/carts/query-config.ts index a77526002a5c6..dbe313b6812cc 100644 --- a/packages/medusa/src/api-v2/store/carts/query-config.ts +++ b/packages/medusa/src/api-v2/store/carts/query-config.ts @@ -22,7 +22,7 @@ export const retrieveTransformQueryConfig = { export const defaultStoreCartRemoteQueryObject = { fields: defaultStoreCartFields, - line_items: { + items: { fields: [ "id", "created_at", diff --git a/packages/medusa/src/joiner-configs/cart-service.ts b/packages/medusa/src/joiner-configs/cart-service.ts deleted file mode 100644 index f236208ebfe6e..0000000000000 --- a/packages/medusa/src/joiner-configs/cart-service.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { Modules } from "@medusajs/modules-sdk" -import { ModuleJoinerConfig } from "@medusajs/types" - -import { Cart } from "../models" - -export default { - serviceName: "cartService", - primaryKeys: ["id"], - linkableKeys: { cart_id: "Cart" }, - alias: { - name: ["cart", "carts"], - args: { entity: Cart.name }, - }, - relationships: [ - { - serviceName: Modules.PRODUCT, - primaryKey: "id", - foreignKey: "variant_id", - alias: "variant", - args: { - methodSuffix: "Variants", - }, - }, - { - serviceName: "regionService", - primaryKey: "id", - foreignKey: "region_id", - alias: "region", - }, - { - serviceName: "customerService", - primaryKey: "id", - foreignKey: "customer_id", - alias: "customer", - }, - ], -} as ModuleJoinerConfig diff --git a/packages/medusa/src/joiner-configs/customer-service.ts b/packages/medusa/src/joiner-configs/customer-service.ts deleted file mode 100644 index 5a2fcd9d4bb01..0000000000000 --- a/packages/medusa/src/joiner-configs/customer-service.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { ModuleJoinerConfig } from "@medusajs/types" - -export default { - serviceName: "customerService", - primaryKeys: ["id"], - linkableKeys: { customer_id: "Customer" }, - alias: [ - { - name: "customer", - }, - { - name: "customers", - }, - ], -} as ModuleJoinerConfig diff --git a/packages/medusa/src/joiner-configs/index.ts b/packages/medusa/src/joiner-configs/index.ts index 4fccd04161ad5..74555665ea267 100644 --- a/packages/medusa/src/joiner-configs/index.ts +++ b/packages/medusa/src/joiner-configs/index.ts @@ -1,6 +1,3 @@ -export * as cart from "./cart-service" -export * as customer from "./customer-service" export * as publishableApiKey from "./publishable-api-key-service" -export * as region from "./region-service" export * as shippingProfile from "./shipping-profile-service" diff --git a/packages/medusa/src/joiner-configs/order-service.ts b/packages/medusa/src/joiner-configs/order-service.ts deleted file mode 100644 index 3a5e3dc5feb6f..0000000000000 --- a/packages/medusa/src/joiner-configs/order-service.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { ModuleJoinerConfig } from "@medusajs/types" - -export default { - serviceName: "orderService", - primaryKeys: ["id"], - linkableKeys: { order_id: "Order" }, - alias: [ - { - name: "order", - }, - { - name: "orders", - }, - ], -} as ModuleJoinerConfig diff --git a/packages/medusa/src/joiner-configs/region-service.ts b/packages/medusa/src/joiner-configs/region-service.ts deleted file mode 100644 index 8e1f5479b0b71..0000000000000 --- a/packages/medusa/src/joiner-configs/region-service.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { ModuleJoinerConfig } from "@medusajs/types" - -export default { - serviceName: "regionService", - primaryKeys: ["id"], - linkableKeys: { region_id: "Region" }, - alias: [ - { - name: "region", - }, - { - name: "regions", - }, - ], -} as ModuleJoinerConfig