chore: fixes to http and request types for inventory (#13827)
* chore: fixes to http and request types for inventory * fix type error
This commit is contained in:
@@ -10,10 +10,9 @@ import {
|
||||
} from "@medusajs/core-flows"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
import { refetchInventoryItem } from "../../../helpers"
|
||||
import { AdminUpdateInventoryLocationLevelType } from "../../../validators"
|
||||
|
||||
export const DELETE = async (
|
||||
req: MedusaRequest,
|
||||
req: MedusaRequest<{}, HttpTypes.SelectParams>,
|
||||
res: MedusaResponse<HttpTypes.AdminInventoryLevelDeleteResponse>
|
||||
) => {
|
||||
const { id, location_id } = req.params
|
||||
@@ -65,7 +64,10 @@ export const DELETE = async (
|
||||
}
|
||||
|
||||
export const POST = async (
|
||||
req: MedusaRequest<AdminUpdateInventoryLocationLevelType>,
|
||||
req: MedusaRequest<
|
||||
HttpTypes.AdminUpdateInventoryLevel,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminInventoryItemResponse>
|
||||
) => {
|
||||
const { id, location_id } = req.params
|
||||
|
||||
@@ -5,15 +5,14 @@ import {
|
||||
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
||||
|
||||
import { createInventoryLevelsWorkflow } from "@medusajs/core-flows"
|
||||
import {
|
||||
AdminCreateInventoryLocationLevelType,
|
||||
AdminGetInventoryLocationLevelsParamsType,
|
||||
} from "../../validators"
|
||||
import { refetchInventoryItem } from "../../helpers"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const POST = async (
|
||||
req: MedusaRequest<AdminCreateInventoryLocationLevelType>,
|
||||
req: MedusaRequest<
|
||||
HttpTypes.AdminBatchCreateInventoryItemLocationLevels,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminInventoryItemResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
@@ -39,7 +38,7 @@ export const POST = async (
|
||||
}
|
||||
|
||||
export const GET = async (
|
||||
req: MedusaRequest<AdminGetInventoryLocationLevelsParamsType>,
|
||||
req: MedusaRequest<HttpTypes.AdminInventoryLevelFilters>,
|
||||
res: MedusaResponse<HttpTypes.AdminInventoryLevelListResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
@@ -4,15 +4,11 @@ import {
|
||||
deleteInventoryItemWorkflow,
|
||||
updateInventoryItemsWorkflow,
|
||||
} from "@medusajs/core-flows"
|
||||
import {
|
||||
AdminGetInventoryItemParamsType,
|
||||
AdminUpdateInventoryItemType,
|
||||
} from "../validators"
|
||||
import { refetchInventoryItem } from "../helpers"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const GET = async (
|
||||
req: MedusaRequest<AdminGetInventoryItemParamsType>,
|
||||
req: MedusaRequest<HttpTypes.SelectParams>,
|
||||
res: MedusaResponse<HttpTypes.AdminInventoryItemResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
@@ -35,7 +31,10 @@ export const GET = async (
|
||||
|
||||
// Update inventory item
|
||||
export const POST = async (
|
||||
req: MedusaRequest<AdminUpdateInventoryItemType>,
|
||||
req: MedusaRequest<
|
||||
HttpTypes.AdminUpdateInventoryItem,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminInventoryItemResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
@@ -12,7 +12,10 @@ import { refetchInventoryItem } from "./helpers"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<HttpTypes.AdminCreateInventoryItem>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminCreateInventoryItem,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminInventoryItemResponse>
|
||||
) => {
|
||||
const { result } = await createInventoryItemsWorkflow(req.scope).run({
|
||||
@@ -29,7 +32,7 @@ export const POST = async (
|
||||
}
|
||||
|
||||
export const GET = async (
|
||||
req: AuthenticatedMedusaRequest<HttpTypes.AdminInventoryItemParams>,
|
||||
req: AuthenticatedMedusaRequest<HttpTypes.AdminInventoryItemsParams>,
|
||||
res: MedusaResponse<HttpTypes.AdminInventoryItemListResponse>
|
||||
) => {
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
@@ -2,10 +2,6 @@ import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import {
|
||||
AdminGetReservationParamsType,
|
||||
AdminUpdateReservationType,
|
||||
} from "../validators"
|
||||
import { MedusaError } from "@medusajs/framework/utils"
|
||||
import {
|
||||
deleteReservationsWorkflow,
|
||||
@@ -15,7 +11,9 @@ import { refetchReservation } from "../helpers"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const GET = async (
|
||||
req: AuthenticatedMedusaRequest<AdminGetReservationParamsType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminReservationParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminReservationResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
@@ -37,7 +35,10 @@ export const GET = async (
|
||||
}
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminUpdateReservationType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminUpdateReservation,
|
||||
HttpTypes.AdminReservationParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminReservationResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
@@ -37,7 +37,10 @@ export const GET = async (
|
||||
}
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<HttpTypes.AdminCreateReservation>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminCreateReservation,
|
||||
HttpTypes.AdminGetReservationsParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminReservationResponse>
|
||||
) => {
|
||||
const input = [req.validatedBody]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { batchLinksWorkflow } from "@medusajs/core-flows"
|
||||
import { HttpTypes, LinkMethodRequest } from "@medusajs/framework/types"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
import { Modules } from "@medusajs/framework/utils"
|
||||
|
||||
import {
|
||||
@@ -18,7 +18,10 @@ const buildLinks = (id, fulfillmentProviderIds: string[]) => {
|
||||
}
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<LinkMethodRequest>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminBatchLink,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminStockLocationResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
@@ -4,11 +4,13 @@ import {
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import { refetchStockLocation } from "../../helpers"
|
||||
import { AdminCreateStockLocationFulfillmentSetType } from "../../validators"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminCreateStockLocationFulfillmentSetType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminCreateStockLocationFulfillmentSet,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminStockLocationResponse>
|
||||
) => {
|
||||
await createLocationFulfillmentSetWorkflow(req.scope).run({
|
||||
|
||||
@@ -11,12 +11,14 @@ import { MedusaError } from "@medusajs/framework/utils"
|
||||
import { refetchStockLocation } from "../helpers"
|
||||
import {
|
||||
AdminGetStockLocationParamsType,
|
||||
AdminUpdateStockLocationType,
|
||||
} from "../validators"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminUpdateStockLocationType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminUpdateStockLocation,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminStockLocationResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
@@ -4,11 +4,14 @@ import {
|
||||
} from "@medusajs/framework/http"
|
||||
|
||||
import { linkSalesChannelsToStockLocationWorkflow } from "@medusajs/core-flows"
|
||||
import { HttpTypes, LinkMethodRequest } from "@medusajs/framework/types"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
import { refetchStockLocation } from "../../helpers"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<LinkMethodRequest>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminBatchLink,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminStockLocationResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
@@ -13,7 +13,10 @@ import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
// Create stock location
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<HttpTypes.AdminCreateStockLocation>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminCreateStockLocation,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminStockLocationResponse>
|
||||
) => {
|
||||
const { result } = await createStockLocationsWorkflow(req.scope).run({
|
||||
|
||||
Reference in New Issue
Block a user