chore: fixes to HTTP and request types for carts (#13821)

This commit is contained in:
Shahed Nasser
2025-10-28 11:04:27 +02:00
committed by GitHub
parent 24ff9d3382
commit cc1a37f2f5
9 changed files with 30 additions and 16 deletions

View File

@@ -11,7 +11,7 @@ import { refetchCart } from "../../helpers"
import { defaultStoreCartFields } from "../../query-config"
export const POST = async (
req: MedusaRequest,
req: MedusaRequest<{}, HttpTypes.SelectParams>,
res: MedusaResponse<HttpTypes.StoreCompleteCartResponse>
) => {
const cart_id = req.params.id

View File

@@ -10,7 +10,7 @@ import { refetchCart } from "../../helpers"
import { AdditionalData } from "@medusajs/types"
export const POST = async (
req: AuthenticatedMedusaRequest<AdditionalData>,
req: AuthenticatedMedusaRequest<AdditionalData, HttpTypes.SelectParams>,
res: MedusaResponse<HttpTypes.StoreCartResponse>
) => {
const we = req.scope.resolve(Modules.WORKFLOW_ENGINE)

View File

@@ -6,10 +6,12 @@ import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { AdditionalData, HttpTypes } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
import { refetchCart } from "../../../helpers"
import { StoreUpdateCartLineItemType } from "../../../validators"
export const POST = async (
req: MedusaRequest<StoreUpdateCartLineItemType & AdditionalData>,
req: MedusaRequest<
HttpTypes.StoreUpdateCartLineItem & AdditionalData,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.StoreCartResponse>
) => {
const we = req.scope.resolve(Modules.WORKFLOW_ENGINE)
@@ -33,7 +35,7 @@ export const POST = async (
}
export const DELETE = async (
req: MedusaRequest,
req: MedusaRequest<{}, HttpTypes.SelectParams>,
res: MedusaResponse<HttpTypes.StoreLineItemDeleteResponse>
) => {
const id = req.params.line_id

View File

@@ -3,11 +3,13 @@ import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { HttpTypes } from "@medusajs/framework/types"
import { Modules } from "@medusajs/utils"
import { refetchCart } from "../../helpers"
import { StoreAddCartLineItemType } from "../../validators"
import { AdditionalData } from "@medusajs/types"
export const POST = async (
req: MedusaRequest<StoreAddCartLineItemType & AdditionalData>,
req: MedusaRequest<
HttpTypes.StoreAddCartLineItem & AdditionalData,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.StoreCartResponse>
) => {
const we = req.scope.resolve(Modules.WORKFLOW_ENGINE)

View File

@@ -5,7 +5,10 @@ import { Modules, PromotionActions } from "@medusajs/framework/utils"
import { refetchCart } from "../../helpers"
export const POST = async (
req: MedusaRequest<HttpTypes.StoreCartAddPromotion>,
req: MedusaRequest<
HttpTypes.StoreCartAddPromotion,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.StoreCartResponse>
) => {
const we = req.scope.resolve(Modules.WORKFLOW_ENGINE)
@@ -33,7 +36,7 @@ export const POST = async (
}
export const DELETE = async (
req: MedusaRequest<HttpTypes.StoreCartRemovePromotion>,
req: MedusaRequest<HttpTypes.StoreCartRemovePromotion, HttpTypes.SelectParams>,
res: MedusaResponse<{
cart: HttpTypes.StoreCart
}>

View File

@@ -2,7 +2,6 @@ import { updateCartWorkflowId } from "@medusajs/core-flows"
import {
AdditionalData,
HttpTypes,
UpdateCartDataDTO,
} from "@medusajs/framework/types"
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
@@ -10,7 +9,7 @@ import { Modules } from "@medusajs/framework/utils"
import { refetchCart } from "../helpers"
export const GET = async (
req: MedusaRequest,
req: MedusaRequest<HttpTypes.SelectParams>,
res: MedusaResponse<HttpTypes.StoreCartResponse>
) => {
const cart = await refetchCart(
@@ -23,7 +22,10 @@ export const GET = async (
}
export const POST = async (
req: MedusaRequest<UpdateCartDataDTO & AdditionalData>,
req: MedusaRequest<
HttpTypes.StoreUpdateCart & AdditionalData,
HttpTypes.SelectParams
>,
res: MedusaResponse<{
cart: HttpTypes.StoreCart
}>

View File

@@ -2,10 +2,12 @@ import { addShippingMethodToCartWorkflow } from "@medusajs/core-flows"
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { AdditionalData, HttpTypes } from "@medusajs/framework/types"
import { refetchCart } from "../../helpers"
import { StoreAddCartShippingMethodsType } from "../../validators"
export const POST = async (
req: MedusaRequest<StoreAddCartShippingMethodsType & AdditionalData>,
req: MedusaRequest<
HttpTypes.StoreAddCartShippingMethods & AdditionalData,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.StoreCartResponse>
) => {
const payload = req.validatedBody

View File

@@ -4,7 +4,7 @@ import { HttpTypes } from "@medusajs/framework/types"
import { refetchCart } from "../../helpers"
export const POST = async (
req: MedusaRequest,
req: MedusaRequest<{}, HttpTypes.SelectParams>,
res: MedusaResponse<HttpTypes.StoreCartResponse>
) => {
await updateTaxLinesWorkflow(req.scope).run({

View File

@@ -11,7 +11,10 @@ import {
import { refetchCart } from "./helpers"
export const POST = async (
req: AuthenticatedMedusaRequest<HttpTypes.StoreCreateCart & AdditionalData>,
req: AuthenticatedMedusaRequest<
HttpTypes.StoreCreateCart & AdditionalData,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.StoreCartResponse>
) => {
const workflowInput = {