chore(): Reorganize modules (#7210)

**What**
Move all modules to the modules directory
This commit is contained in:
Adrien de Peretti
2024-05-02 17:33:34 +02:00
committed by GitHub
parent 7a351eef09
commit 4eae25e1ef
870 changed files with 91 additions and 62 deletions

View File

@@ -0,0 +1,5 @@
describe("noop", function () {
it("should run", function () {
expect(true).toBe(true)
})
})

View File

@@ -0,0 +1,2 @@
export { default as InventoryModuleService } from "./inventory"
export { default as InventoryLevelService } from "./inventory-level"

View File

@@ -0,0 +1,79 @@
import {
Context,
CreateInventoryLevelInput,
DAL,
SharedContext,
} from "@medusajs/types"
import {
InjectTransactionManager,
MedusaContext,
ModulesSdkUtils,
} from "@medusajs/utils"
import { InventoryLevel } from "../models/inventory-level"
import { InventoryLevelRepository } from "@repositories"
type InjectedDependencies = {
inventoryLevelRepository: InventoryLevelRepository
}
export default class InventoryLevelService<
TEntity extends InventoryLevel = InventoryLevel
> extends ModulesSdkUtils.internalModuleServiceFactory<InjectedDependencies>(
InventoryLevel
)<TEntity> {
protected readonly inventoryLevelRepository: InventoryLevelRepository
constructor(container: InjectedDependencies) {
super(container)
this.inventoryLevelRepository = container.inventoryLevelRepository
}
async retrieveStockedQuantity(
inventoryItemId: string,
locationIds: string[] | string,
context: Context = {}
): Promise<number> {
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<number> {
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
)
}
}

File diff suppressed because it is too large Load Diff