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:
@@ -132,7 +132,7 @@ export class InventoryItem {
|
|||||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).
|
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).
|
||||||
*/
|
*/
|
||||||
async list(
|
async list(
|
||||||
query?: HttpTypes.AdminInventoryItemParams,
|
query?: HttpTypes.AdminInventoryItemsParams,
|
||||||
headers?: ClientHeaders
|
headers?: ClientHeaders
|
||||||
) {
|
) {
|
||||||
return await this.client.fetch<HttpTypes.AdminInventoryItemListResponse>(
|
return await this.client.fetch<HttpTypes.AdminInventoryItemListResponse>(
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { FindParams } from "../../common"
|
import { FindParams } from "../../common"
|
||||||
import { BaseFilterable, OperatorMap } from "../../../dal"
|
import { BaseFilterable, OperatorMap } from "../../../dal"
|
||||||
|
|
||||||
export interface AdminInventoryItemParams
|
export interface AdminInventoryItemsParams
|
||||||
extends FindParams,
|
extends FindParams,
|
||||||
BaseFilterable<AdminInventoryItemParams> {
|
BaseFilterable<AdminInventoryItemsParams> {
|
||||||
/**
|
/**
|
||||||
* Filter by inventory item ID(s).
|
* Filter by inventory item ID(s).
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,15 +1,11 @@
|
|||||||
import { OperatorMap } from "../../../dal"
|
import { OperatorMap } from "../../../dal"
|
||||||
import { SelectParams } from "../../common"
|
import { FindParams, SelectParams } from "../../common"
|
||||||
|
|
||||||
export interface AdminGetReservationsParams {
|
export interface AdminGetReservationsParams extends FindParams {
|
||||||
/**
|
/**
|
||||||
* The maximum number of reservations to retrieve.
|
* A search term to search for reservations by their searchable fields.
|
||||||
*/
|
*/
|
||||||
limit?: number
|
q?: string
|
||||||
/**
|
|
||||||
* The number of reservations to skip.
|
|
||||||
*/
|
|
||||||
offset?: number
|
|
||||||
/**
|
/**
|
||||||
* Filter by the ID(s) of the location(s) to retrieve the
|
* Filter by the ID(s) of the location(s) to retrieve the
|
||||||
* reservations for.
|
* reservations for.
|
||||||
@@ -25,10 +21,6 @@ export interface AdminGetReservationsParams {
|
|||||||
* reservations for.
|
* reservations for.
|
||||||
*/
|
*/
|
||||||
line_item_id?: string | string[]
|
line_item_id?: string | string[]
|
||||||
/**
|
|
||||||
* Sort the reservations by the given field.
|
|
||||||
*/
|
|
||||||
order_id?: string | string[]
|
|
||||||
/**
|
/**
|
||||||
* Filter by the ID(s) of the user(s) to retrieve the
|
* Filter by the ID(s) of the user(s) to retrieve the
|
||||||
* reservations they created.
|
* reservations they created.
|
||||||
@@ -38,6 +30,10 @@ export interface AdminGetReservationsParams {
|
|||||||
* Filter by reservation description(s).
|
* Filter by reservation description(s).
|
||||||
*/
|
*/
|
||||||
description?: string | OperatorMap<string>
|
description?: string | OperatorMap<string>
|
||||||
|
/**
|
||||||
|
* Filter by reservation quantity.
|
||||||
|
*/
|
||||||
|
quantity?: OperatorMap<number>
|
||||||
/**
|
/**
|
||||||
* Apply filters on the reservation's creation date.
|
* Apply filters on the reservation's creation date.
|
||||||
*/
|
*/
|
||||||
|
|||||||
+5
-3
@@ -10,10 +10,9 @@ import {
|
|||||||
} from "@medusajs/core-flows"
|
} from "@medusajs/core-flows"
|
||||||
import { HttpTypes } from "@medusajs/framework/types"
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
import { refetchInventoryItem } from "../../../helpers"
|
import { refetchInventoryItem } from "../../../helpers"
|
||||||
import { AdminUpdateInventoryLocationLevelType } from "../../../validators"
|
|
||||||
|
|
||||||
export const DELETE = async (
|
export const DELETE = async (
|
||||||
req: MedusaRequest,
|
req: MedusaRequest<{}, HttpTypes.SelectParams>,
|
||||||
res: MedusaResponse<HttpTypes.AdminInventoryLevelDeleteResponse>
|
res: MedusaResponse<HttpTypes.AdminInventoryLevelDeleteResponse>
|
||||||
) => {
|
) => {
|
||||||
const { id, location_id } = req.params
|
const { id, location_id } = req.params
|
||||||
@@ -65,7 +64,10 @@ export const DELETE = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: MedusaRequest<AdminUpdateInventoryLocationLevelType>,
|
req: MedusaRequest<
|
||||||
|
HttpTypes.AdminUpdateInventoryLevel,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminInventoryItemResponse>
|
res: MedusaResponse<HttpTypes.AdminInventoryItemResponse>
|
||||||
) => {
|
) => {
|
||||||
const { id, location_id } = req.params
|
const { id, location_id } = req.params
|
||||||
|
|||||||
@@ -5,15 +5,14 @@ import {
|
|||||||
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
||||||
|
|
||||||
import { createInventoryLevelsWorkflow } from "@medusajs/core-flows"
|
import { createInventoryLevelsWorkflow } from "@medusajs/core-flows"
|
||||||
import {
|
|
||||||
AdminCreateInventoryLocationLevelType,
|
|
||||||
AdminGetInventoryLocationLevelsParamsType,
|
|
||||||
} from "../../validators"
|
|
||||||
import { refetchInventoryItem } from "../../helpers"
|
import { refetchInventoryItem } from "../../helpers"
|
||||||
import { HttpTypes } from "@medusajs/framework/types"
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: MedusaRequest<AdminCreateInventoryLocationLevelType>,
|
req: MedusaRequest<
|
||||||
|
HttpTypes.AdminBatchCreateInventoryItemLocationLevels,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminInventoryItemResponse>
|
res: MedusaResponse<HttpTypes.AdminInventoryItemResponse>
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
@@ -39,7 +38,7 @@ export const POST = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: MedusaRequest<AdminGetInventoryLocationLevelsParamsType>,
|
req: MedusaRequest<HttpTypes.AdminInventoryLevelFilters>,
|
||||||
res: MedusaResponse<HttpTypes.AdminInventoryLevelListResponse>
|
res: MedusaResponse<HttpTypes.AdminInventoryLevelListResponse>
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
|
|||||||
@@ -4,15 +4,11 @@ import {
|
|||||||
deleteInventoryItemWorkflow,
|
deleteInventoryItemWorkflow,
|
||||||
updateInventoryItemsWorkflow,
|
updateInventoryItemsWorkflow,
|
||||||
} from "@medusajs/core-flows"
|
} from "@medusajs/core-flows"
|
||||||
import {
|
|
||||||
AdminGetInventoryItemParamsType,
|
|
||||||
AdminUpdateInventoryItemType,
|
|
||||||
} from "../validators"
|
|
||||||
import { refetchInventoryItem } from "../helpers"
|
import { refetchInventoryItem } from "../helpers"
|
||||||
import { HttpTypes } from "@medusajs/framework/types"
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: MedusaRequest<AdminGetInventoryItemParamsType>,
|
req: MedusaRequest<HttpTypes.SelectParams>,
|
||||||
res: MedusaResponse<HttpTypes.AdminInventoryItemResponse>
|
res: MedusaResponse<HttpTypes.AdminInventoryItemResponse>
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
@@ -35,7 +31,10 @@ export const GET = async (
|
|||||||
|
|
||||||
// Update inventory item
|
// Update inventory item
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: MedusaRequest<AdminUpdateInventoryItemType>,
|
req: MedusaRequest<
|
||||||
|
HttpTypes.AdminUpdateInventoryItem,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminInventoryItemResponse>
|
res: MedusaResponse<HttpTypes.AdminInventoryItemResponse>
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
|
|||||||
@@ -12,7 +12,10 @@ import { refetchInventoryItem } from "./helpers"
|
|||||||
import { HttpTypes } from "@medusajs/framework/types"
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<HttpTypes.AdminCreateInventoryItem>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.AdminCreateInventoryItem,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminInventoryItemResponse>
|
res: MedusaResponse<HttpTypes.AdminInventoryItemResponse>
|
||||||
) => {
|
) => {
|
||||||
const { result } = await createInventoryItemsWorkflow(req.scope).run({
|
const { result } = await createInventoryItemsWorkflow(req.scope).run({
|
||||||
@@ -29,7 +32,7 @@ export const POST = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: AuthenticatedMedusaRequest<HttpTypes.AdminInventoryItemParams>,
|
req: AuthenticatedMedusaRequest<HttpTypes.AdminInventoryItemsParams>,
|
||||||
res: MedusaResponse<HttpTypes.AdminInventoryItemListResponse>
|
res: MedusaResponse<HttpTypes.AdminInventoryItemListResponse>
|
||||||
) => {
|
) => {
|
||||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||||
|
|||||||
@@ -2,10 +2,6 @@ import {
|
|||||||
AuthenticatedMedusaRequest,
|
AuthenticatedMedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "@medusajs/framework/http"
|
} from "@medusajs/framework/http"
|
||||||
import {
|
|
||||||
AdminGetReservationParamsType,
|
|
||||||
AdminUpdateReservationType,
|
|
||||||
} from "../validators"
|
|
||||||
import { MedusaError } from "@medusajs/framework/utils"
|
import { MedusaError } from "@medusajs/framework/utils"
|
||||||
import {
|
import {
|
||||||
deleteReservationsWorkflow,
|
deleteReservationsWorkflow,
|
||||||
@@ -15,7 +11,9 @@ import { refetchReservation } from "../helpers"
|
|||||||
import { HttpTypes } from "@medusajs/framework/types"
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminGetReservationParamsType>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.AdminReservationParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminReservationResponse>
|
res: MedusaResponse<HttpTypes.AdminReservationResponse>
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
@@ -37,7 +35,10 @@ export const GET = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminUpdateReservationType>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.AdminUpdateReservation,
|
||||||
|
HttpTypes.AdminReservationParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminReservationResponse>
|
res: MedusaResponse<HttpTypes.AdminReservationResponse>
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
|
|||||||
@@ -37,7 +37,10 @@ export const GET = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<HttpTypes.AdminCreateReservation>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.AdminCreateReservation,
|
||||||
|
HttpTypes.AdminGetReservationsParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminReservationResponse>
|
res: MedusaResponse<HttpTypes.AdminReservationResponse>
|
||||||
) => {
|
) => {
|
||||||
const input = [req.validatedBody]
|
const input = [req.validatedBody]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { batchLinksWorkflow } from "@medusajs/core-flows"
|
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 { Modules } from "@medusajs/framework/utils"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -18,7 +18,10 @@ const buildLinks = (id, fulfillmentProviderIds: string[]) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<LinkMethodRequest>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.AdminBatchLink,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminStockLocationResponse>
|
res: MedusaResponse<HttpTypes.AdminStockLocationResponse>
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
|
|||||||
@@ -4,11 +4,13 @@ import {
|
|||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "@medusajs/framework/http"
|
} from "@medusajs/framework/http"
|
||||||
import { refetchStockLocation } from "../../helpers"
|
import { refetchStockLocation } from "../../helpers"
|
||||||
import { AdminCreateStockLocationFulfillmentSetType } from "../../validators"
|
|
||||||
import { HttpTypes } from "@medusajs/framework/types"
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminCreateStockLocationFulfillmentSetType>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.AdminCreateStockLocationFulfillmentSet,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminStockLocationResponse>
|
res: MedusaResponse<HttpTypes.AdminStockLocationResponse>
|
||||||
) => {
|
) => {
|
||||||
await createLocationFulfillmentSetWorkflow(req.scope).run({
|
await createLocationFulfillmentSetWorkflow(req.scope).run({
|
||||||
|
|||||||
@@ -11,12 +11,14 @@ import { MedusaError } from "@medusajs/framework/utils"
|
|||||||
import { refetchStockLocation } from "../helpers"
|
import { refetchStockLocation } from "../helpers"
|
||||||
import {
|
import {
|
||||||
AdminGetStockLocationParamsType,
|
AdminGetStockLocationParamsType,
|
||||||
AdminUpdateStockLocationType,
|
|
||||||
} from "../validators"
|
} from "../validators"
|
||||||
import { HttpTypes } from "@medusajs/framework/types"
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminUpdateStockLocationType>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.AdminUpdateStockLocation,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminStockLocationResponse>
|
res: MedusaResponse<HttpTypes.AdminStockLocationResponse>
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
|
|||||||
@@ -4,11 +4,14 @@ import {
|
|||||||
} from "@medusajs/framework/http"
|
} from "@medusajs/framework/http"
|
||||||
|
|
||||||
import { linkSalesChannelsToStockLocationWorkflow } from "@medusajs/core-flows"
|
import { linkSalesChannelsToStockLocationWorkflow } from "@medusajs/core-flows"
|
||||||
import { HttpTypes, LinkMethodRequest } from "@medusajs/framework/types"
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
import { refetchStockLocation } from "../../helpers"
|
import { refetchStockLocation } from "../../helpers"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<LinkMethodRequest>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.AdminBatchLink,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminStockLocationResponse>
|
res: MedusaResponse<HttpTypes.AdminStockLocationResponse>
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ import { HttpTypes } from "@medusajs/framework/types"
|
|||||||
|
|
||||||
// Create stock location
|
// Create stock location
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<HttpTypes.AdminCreateStockLocation>,
|
req: AuthenticatedMedusaRequest<
|
||||||
|
HttpTypes.AdminCreateStockLocation,
|
||||||
|
HttpTypes.SelectParams
|
||||||
|
>,
|
||||||
res: MedusaResponse<HttpTypes.AdminStockLocationResponse>
|
res: MedusaResponse<HttpTypes.AdminStockLocationResponse>
|
||||||
) => {
|
) => {
|
||||||
const { result } = await createStockLocationsWorkflow(req.scope).run({
|
const { result } = await createStockLocationsWorkflow(req.scope).run({
|
||||||
|
|||||||
Reference in New Issue
Block a user