fix(medusa): Update typescript types to reflect oas and return types (#3344)
* update typescript types to reflect oas and return types * add changeset --------- Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
5
.changeset/quiet-deers-shake.md
Normal file
5
.changeset/quiet-deers-shake.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/medusa": patch
|
||||
---
|
||||
|
||||
Update types to reflect actual return-type
|
||||
@@ -230,11 +230,12 @@ export type AdminInventoryItemsListRes = PaginatedResponse & {
|
||||
* description: The number of items per page
|
||||
*/
|
||||
export type AdminInventoryItemsListWithVariantsAndLocationLevelsRes =
|
||||
Partial<InventoryItemDTO> & {
|
||||
location_levels?: InventoryLevelDTO[]
|
||||
variants?: ProductVariant[]
|
||||
PaginatedResponse & {
|
||||
inventory_items: (Partial<InventoryItemDTO> & {
|
||||
location_levels?: InventoryLevelDTO[]
|
||||
variants?: ProductVariant[]
|
||||
})[]
|
||||
}
|
||||
|
||||
/**
|
||||
* @schema AdminInventoryItemsLocationLevelsRes
|
||||
* type: object
|
||||
|
||||
@@ -3,10 +3,7 @@ import { IsBoolean, IsOptional, IsString } from "class-validator"
|
||||
import { Transform } from "class-transformer"
|
||||
import { IsType } from "../../../../utils/validators/is-type"
|
||||
import { getLevelsByInventoryItemId } from "./utils/join-levels"
|
||||
import {
|
||||
getVariantsByInventoryItemId,
|
||||
InventoryItemsWithVariants,
|
||||
} from "./utils/join-variants"
|
||||
import { getVariantsByInventoryItemId } from "./utils/join-variants"
|
||||
import {
|
||||
ProductVariantInventoryService,
|
||||
ProductVariantService,
|
||||
@@ -128,17 +125,14 @@ export default async (req: Request, res: Response) => {
|
||||
inventoryService
|
||||
)
|
||||
|
||||
const variantsByInventoryItemId: InventoryItemsWithVariants =
|
||||
await getVariantsByInventoryItemId(
|
||||
inventoryItems,
|
||||
productVariantInventoryService,
|
||||
productVariantService
|
||||
)
|
||||
const variantsByInventoryItemId = await getVariantsByInventoryItemId(
|
||||
inventoryItems,
|
||||
productVariantInventoryService,
|
||||
productVariantService
|
||||
)
|
||||
|
||||
const inventoryItemsWithVariantsAndLocationLevels = inventoryItems.map(
|
||||
(
|
||||
inventoryItem
|
||||
): AdminInventoryItemsListWithVariantsAndLocationLevelsRes => {
|
||||
(inventoryItem) => {
|
||||
return {
|
||||
...inventoryItem,
|
||||
variants: variantsByInventoryItemId[inventoryItem.id] ?? [],
|
||||
|
||||
@@ -13,7 +13,7 @@ export const getVariantsByInventoryItemId = async (
|
||||
inventoryItems: InventoryItemDTO[],
|
||||
productVariantInventoryService: ProductVariantInventoryService,
|
||||
productVariantService: ProductVariantService
|
||||
): Promise<Record<string, InventoryItemsWithVariants>> => {
|
||||
): Promise<Record<string, ProductVariant[]>> => {
|
||||
const variantInventory = await productVariantInventoryService.listByItem(
|
||||
inventoryItems.map((item) => item.id)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user