breaking: rename package names to be consistent and under @medusajs scope (#9580)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
describe("noop", function () {
|
||||
it("should run", function () {
|
||||
expect(true).toBe(true)
|
||||
})
|
||||
})
|
||||
2
packages/modules/inventory/src/services/index.ts
Normal file
2
packages/modules/inventory/src/services/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export { default as InventoryLevelService } from "./inventory-level"
|
||||
export { default as InventoryModuleService } from "./inventory-module"
|
||||
69
packages/modules/inventory/src/services/inventory-level.ts
Normal file
69
packages/modules/inventory/src/services/inventory-level.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import { Context } from "@medusajs/framework/types"
|
||||
import { BigNumber, ModulesSdkUtils } from "@medusajs/framework/utils"
|
||||
|
||||
import { InventoryLevelRepository } from "@repositories"
|
||||
import { InventoryLevel } from "../models/inventory-level"
|
||||
|
||||
type InjectedDependencies = {
|
||||
inventoryLevelRepository: InventoryLevelRepository
|
||||
}
|
||||
|
||||
export default class InventoryLevelService extends ModulesSdkUtils.MedusaInternalService<
|
||||
InjectedDependencies,
|
||||
InventoryLevel
|
||||
>(InventoryLevel) {
|
||||
protected readonly inventoryLevelRepository: InventoryLevelRepository
|
||||
|
||||
constructor(container: InjectedDependencies) {
|
||||
super(container)
|
||||
this.inventoryLevelRepository = container.inventoryLevelRepository
|
||||
}
|
||||
|
||||
async retrieveStockedQuantity(
|
||||
inventoryItemId: string,
|
||||
locationIds: string[] | string,
|
||||
context: Context = {}
|
||||
): Promise<BigNumber> {
|
||||
const locationIdArray = Array.isArray(locationIds)
|
||||
? locationIds
|
||||
: [locationIds]
|
||||
|
||||
return await this.inventoryLevelRepository.getStockedQuantity(
|
||||
inventoryItemId,
|
||||
locationIdArray,
|
||||
context
|
||||
)
|
||||
}
|
||||
|
||||
async getAvailableQuantity(
|
||||
inventoryItemId: string,
|
||||
locationIds: string[] | string,
|
||||
context: Context = {}
|
||||
): Promise<BigNumber> {
|
||||
const locationIdArray = Array.isArray(locationIds)
|
||||
? locationIds
|
||||
: [locationIds]
|
||||
|
||||
return await this.inventoryLevelRepository.getAvailableQuantity(
|
||||
inventoryItemId,
|
||||
locationIdArray,
|
||||
context
|
||||
)
|
||||
}
|
||||
|
||||
async getReservedQuantity(
|
||||
inventoryItemId: string,
|
||||
locationIds: string[] | string,
|
||||
context: Context = {}
|
||||
) {
|
||||
if (!Array.isArray(locationIds)) {
|
||||
locationIds = [locationIds]
|
||||
}
|
||||
|
||||
return await this.inventoryLevelRepository.getReservedQuantity(
|
||||
inventoryItemId,
|
||||
locationIds,
|
||||
context
|
||||
)
|
||||
}
|
||||
}
|
||||
1267
packages/modules/inventory/src/services/inventory-module.ts
Normal file
1267
packages/modules/inventory/src/services/inventory-module.ts
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user