31 lines
966 B
TypeScript
31 lines
966 B
TypeScript
import {
|
|
ExternalModuleDeclaration,
|
|
InternalModuleDeclaration,
|
|
MedusaModule,
|
|
MODULE_PACKAGE_NAMES,
|
|
Modules,
|
|
} from "@medusajs/modules-sdk"
|
|
import { IEventBusService, IStockLocationService } from "@medusajs/types"
|
|
import { moduleDefinition } from "../module-definition"
|
|
import { StockLocationServiceInitializeOptions } from "../types"
|
|
|
|
export const initialize = async (
|
|
options: StockLocationServiceInitializeOptions | ExternalModuleDeclaration,
|
|
injectedDependencies?: {
|
|
eventBusService: IEventBusService
|
|
}
|
|
): Promise<IStockLocationService> => {
|
|
const serviceKey = Modules.STOCK_LOCATION
|
|
const loaded = await MedusaModule.bootstrap<IStockLocationService>({
|
|
moduleKey: serviceKey,
|
|
defaultPath: MODULE_PACKAGE_NAMES[Modules.STOCK_LOCATION],
|
|
declaration: options as
|
|
| InternalModuleDeclaration
|
|
| ExternalModuleDeclaration,
|
|
injectedDependencies,
|
|
moduleExports: moduleDefinition,
|
|
})
|
|
|
|
return loaded[serviceKey]
|
|
}
|