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"
|
import { defaultStoreCartFields } from "../../query-config"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: MedusaRequest,
|
req: MedusaRequest<{}, HttpTypes.SelectParams>,
|
||||||
res: MedusaResponse<HttpTypes.StoreCompleteCartResponse>
|
res: MedusaResponse<HttpTypes.StoreCompleteCartResponse>
|
||||||
) => {
|
) => {
|
||||||
const cart_id = req.params.id
|
const cart_id = req.params.id
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { refetchCart } from "../../helpers"
|
|||||||
import { AdditionalData } from "@medusajs/types"
|
import { AdditionalData } from "@medusajs/types"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdditionalData>,
|
req: AuthenticatedMedusaRequest<AdditionalData, HttpTypes.SelectParams>,
|
||||||
res: MedusaResponse<HttpTypes.StoreCartResponse>
|
res: MedusaResponse<HttpTypes.StoreCartResponse>
|
||||||
) => {
|
) => {
|
||||||
const we = req.scope.resolve(Modules.WORKFLOW_ENGINE)
|
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 { AdditionalData, HttpTypes } from "@medusajs/framework/types"
|
||||||
import { Modules } from "@medusajs/framework/utils"
|
import { Modules } from "@medusajs/framework/utils"
|
||||||
import { refetchCart } from "../../../helpers"
|
import { refetchCart } from "../../../helpers"
|
||||||
import { StoreUpdateCartLineItemType } from "../../../validators"
|
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: MedusaRequest<StoreUpdateCartLineItemType & AdditionalData>,
|
req: MedusaRequest<
|
||||||
|
HttpTypes.StoreUpdateCartLineItem & AdditionalData,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.StoreCartResponse>
|
res: MedusaResponse<HttpTypes.StoreCartResponse>
|
||||||
) => {
|
) => {
|
||||||
const we = req.scope.resolve(Modules.WORKFLOW_ENGINE)
|
const we = req.scope.resolve(Modules.WORKFLOW_ENGINE)
|
||||||
@@ -33,7 +35,7 @@ export const POST = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const DELETE = async (
|
export const DELETE = async (
|
||||||
req: MedusaRequest,
|
req: MedusaRequest<{}, HttpTypes.SelectParams>,
|
||||||
res: MedusaResponse<HttpTypes.StoreLineItemDeleteResponse>
|
res: MedusaResponse<HttpTypes.StoreLineItemDeleteResponse>
|
||||||
) => {
|
) => {
|
||||||
const id = req.params.line_id
|
const id = req.params.line_id
|
||||||
|
|||||||
@@ -3,11 +3,13 @@ import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
|||||||
import { HttpTypes } from "@medusajs/framework/types"
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
import { Modules } from "@medusajs/utils"
|
import { Modules } from "@medusajs/utils"
|
||||||
import { refetchCart } from "../../helpers"
|
import { refetchCart } from "../../helpers"
|
||||||
import { StoreAddCartLineItemType } from "../../validators"
|
|
||||||
import { AdditionalData } from "@medusajs/types"
|
import { AdditionalData } from "@medusajs/types"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: MedusaRequest<StoreAddCartLineItemType & AdditionalData>,
|
req: MedusaRequest<
|
||||||
|
HttpTypes.StoreAddCartLineItem & AdditionalData,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.StoreCartResponse>
|
res: MedusaResponse<HttpTypes.StoreCartResponse>
|
||||||
) => {
|
) => {
|
||||||
const we = req.scope.resolve(Modules.WORKFLOW_ENGINE)
|
const we = req.scope.resolve(Modules.WORKFLOW_ENGINE)
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ import { Modules, PromotionActions } from "@medusajs/framework/utils"
|
|||||||
import { refetchCart } from "../../helpers"
|
import { refetchCart } from "../../helpers"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: MedusaRequest<HttpTypes.StoreCartAddPromotion>,
|
req: MedusaRequest<
|
||||||
|
HttpTypes.StoreCartAddPromotion,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.StoreCartResponse>
|
res: MedusaResponse<HttpTypes.StoreCartResponse>
|
||||||
) => {
|
) => {
|
||||||
const we = req.scope.resolve(Modules.WORKFLOW_ENGINE)
|
const we = req.scope.resolve(Modules.WORKFLOW_ENGINE)
|
||||||
@@ -33,7 +36,7 @@ export const POST = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const DELETE = async (
|
export const DELETE = async (
|
||||||
req: MedusaRequest<HttpTypes.StoreCartRemovePromotion>,
|
req: MedusaRequest<HttpTypes.StoreCartRemovePromotion, HttpTypes.SelectParams>,
|
||||||
res: MedusaResponse<{
|
res: MedusaResponse<{
|
||||||
cart: HttpTypes.StoreCart
|
cart: HttpTypes.StoreCart
|
||||||
}>
|
}>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { updateCartWorkflowId } from "@medusajs/core-flows"
|
|||||||
import {
|
import {
|
||||||
AdditionalData,
|
AdditionalData,
|
||||||
HttpTypes,
|
HttpTypes,
|
||||||
UpdateCartDataDTO,
|
|
||||||
} from "@medusajs/framework/types"
|
} from "@medusajs/framework/types"
|
||||||
|
|
||||||
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
||||||
@@ -10,7 +9,7 @@ import { Modules } from "@medusajs/framework/utils"
|
|||||||
import { refetchCart } from "../helpers"
|
import { refetchCart } from "../helpers"
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: MedusaRequest,
|
req: MedusaRequest<HttpTypes.SelectParams>,
|
||||||
res: MedusaResponse<HttpTypes.StoreCartResponse>
|
res: MedusaResponse<HttpTypes.StoreCartResponse>
|
||||||
) => {
|
) => {
|
||||||
const cart = await refetchCart(
|
const cart = await refetchCart(
|
||||||
@@ -23,7 +22,10 @@ export const GET = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: MedusaRequest<UpdateCartDataDTO & AdditionalData>,
|
req: MedusaRequest<
|
||||||
|
HttpTypes.StoreUpdateCart & AdditionalData,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<{
|
res: MedusaResponse<{
|
||||||
cart: HttpTypes.StoreCart
|
cart: HttpTypes.StoreCart
|
||||||
}>
|
}>
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ import { addShippingMethodToCartWorkflow } from "@medusajs/core-flows"
|
|||||||
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
||||||
import { AdditionalData, HttpTypes } from "@medusajs/framework/types"
|
import { AdditionalData, HttpTypes } from "@medusajs/framework/types"
|
||||||
import { refetchCart } from "../../helpers"
|
import { refetchCart } from "../../helpers"
|
||||||
import { StoreAddCartShippingMethodsType } from "../../validators"
|
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: MedusaRequest<StoreAddCartShippingMethodsType & AdditionalData>,
|
req: MedusaRequest<
|
||||||
|
HttpTypes.StoreAddCartShippingMethods & AdditionalData,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.StoreCartResponse>
|
res: MedusaResponse<HttpTypes.StoreCartResponse>
|
||||||
) => {
|
) => {
|
||||||
const payload = req.validatedBody
|
const payload = req.validatedBody
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { HttpTypes } from "@medusajs/framework/types"
|
|||||||
import { refetchCart } from "../../helpers"
|
import { refetchCart } from "../../helpers"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: MedusaRequest,
|
req: MedusaRequest<{}, HttpTypes.SelectParams>,
|
||||||
res: MedusaResponse<HttpTypes.StoreCartResponse>
|
res: MedusaResponse<HttpTypes.StoreCartResponse>
|
||||||
) => {
|
) => {
|
||||||
await updateTaxLinesWorkflow(req.scope).run({
|
await updateTaxLinesWorkflow(req.scope).run({
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ import {
|
|||||||
import { refetchCart } from "./helpers"
|
import { refetchCart } from "./helpers"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<HttpTypes.StoreCreateCart & AdditionalData>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.StoreCreateCart & AdditionalData,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.StoreCartResponse>
|
res: MedusaResponse<HttpTypes.StoreCartResponse>
|
||||||
) => {
|
) => {
|
||||||
const workflowInput = {
|
const workflowInput = {
|
||||||
|
|||||||
Reference in New Issue
Block a user