chore: fixes to HTTP and request types for carts (#13821)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}>
|
||||
|
||||
@@ -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
|
||||
}>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user