feat(medusa): Add ProductVariantInventoryService (#2883)

* add mw feature flag

* add services

* add types

* add module interfaces

* add interface export

* add models for mw

* to be ammended

* remove featureflag

* use correct count

* update cart completion strategy

* swap service conversion

* update return service

* update order service

* update claim service

* add exception to claim item

* update cart service

* add indicies

* add changeset

* nullable changes in store

* store model update

* fix unit tests

* remove old inventory service

* format integration test

* update snapshots

* remove old inventory service tests

* update snapshots

* remove old code

* option updates

* naming

* add jsdoc to pv inventory service

* rename class variables

* pr feedback

* rename option to context

* if(variant_id) instead of if(typeof varia...)

* update tests

* add jsdoc

* go for custom

* update code for readability
This commit is contained in:
Philip Korsholm
2022-12-30 11:30:04 +01:00
committed by GitHub
parent eda26f6e81
commit b9680b641f
42 changed files with 1514 additions and 761 deletions
@@ -1 +1,3 @@
export * from "./cache"
export * from "./stock-location"
export * from "./inventory"
@@ -0,0 +1,94 @@
import { FindConfig } from "../../types/common"
import {
InventoryItemDTO,
ReservationItemDTO,
InventoryLevelDTO,
FilterableInventoryItemProps,
CreateInventoryItemInput,
CreateReservationItemInput,
FilterableInventoryLevelProps,
FilterableReservationItemProps,
CreateInventoryLevelInput,
UpdateInventoryLevelInput,
} from "../../types/inventory"
export interface IInventoryService {
listInventoryItems(
selector: FilterableInventoryItemProps,
config?: FindConfig<InventoryItemDTO>
): Promise<[InventoryItemDTO[], number]>
listReservationItems(
selector: FilterableReservationItemProps,
config?: FindConfig<ReservationItemDTO>
): Promise<[ReservationItemDTO[], number]>
listInventoryLevels(
selector: FilterableInventoryLevelProps,
config?: FindConfig<InventoryLevelDTO>
): Promise<[InventoryLevelDTO[], number]>
retrieveInventoryItem(
itemId: string,
config?: FindConfig<InventoryItemDTO>
): Promise<InventoryItemDTO>
retrieveInventoryLevel(
itemId: string,
locationId: string
): Promise<InventoryLevelDTO>
createReservationItem(
input: CreateReservationItemInput
): Promise<ReservationItemDTO>
createInventoryItem(
input: CreateInventoryItemInput
): Promise<InventoryItemDTO>
createInventoryLevel(
data: CreateInventoryLevelInput
): Promise<InventoryLevelDTO>
updateInventoryLevel(
itemId: string,
locationId: string,
update: UpdateInventoryLevelInput
): Promise<InventoryLevelDTO>
updateInventoryItem(
itemId: string,
input: CreateInventoryItemInput
): Promise<InventoryItemDTO>
deleteReservationItemsByLineItem(lineItemId: string): Promise<void>
deleteReservationItem(id: string): Promise<void>
deleteInventoryItem(itemId: string): Promise<void>
deleteInventoryLevel(itemId: string, locationId: string): Promise<void>
adjustInventory(
itemId: string,
locationId: string,
adjustment: number
): Promise<InventoryLevelDTO>
confirmInventory(
itemId: string,
locationIds: string[],
quantity: number
): Promise<boolean>
retrieveAvailableQuantity(
itemId: string,
locationIds: string[]
): Promise<number>
retrieveStockedQuantity(
itemId: string,
locationIds: string[]
): Promise<number>
}
@@ -0,0 +1,26 @@
import { FindConfig } from "../../types/common"
import {
StockLocationDTO,
FilterableStockLocationProps,
CreateStockLocationInput,
UpdateStockLocationInput,
} from "../../types/stock-location"
export interface IStockLocationService {
list(
selector: FilterableStockLocationProps,
config?: FindConfig<StockLocationDTO>
): Promise<StockLocationDTO[]>
listAndCount(
selector: FilterableStockLocationProps,
config?: FindConfig<StockLocationDTO>
): Promise<[StockLocationDTO[], number]>
retrieve(id: string): Promise<StockLocationDTO>
create(input: CreateStockLocationInput): Promise<StockLocationDTO>
update(id: string, input: UpdateStockLocationInput): Promise<StockLocationDTO>
}