feat(medusa): Modules initializer (#3352)
This commit is contained in:
@@ -85,9 +85,6 @@ export default async (req, res) => {
|
||||
const orderServiceTx = orderService.withTransaction(manager)
|
||||
const cartServiceTx = cartService.withTransaction(manager)
|
||||
|
||||
const productVariantInventoryServiceTx =
|
||||
productVariantInventoryService.withTransaction(manager)
|
||||
|
||||
const draftOrder = await draftOrderServiceTx.retrieve(id)
|
||||
|
||||
const cart = await cartServiceTx.retrieveWithTotals(draftOrder.cart_id)
|
||||
@@ -116,7 +113,7 @@ export default async (req, res) => {
|
||||
})
|
||||
|
||||
await reserveQuantityForDraftOrder(order, {
|
||||
productVariantInventoryService: productVariantInventoryServiceTx,
|
||||
productVariantInventoryService,
|
||||
})
|
||||
|
||||
return order
|
||||
|
||||
@@ -59,9 +59,7 @@ export default async (req: Request, res: Response) => {
|
||||
.withTransaction(transactionManager)
|
||||
.detachInventoryItem(id)
|
||||
|
||||
await inventoryService
|
||||
.withTransaction(transactionManager)
|
||||
.deleteInventoryItem(id)
|
||||
await inventoryService.deleteInventoryItem(id)
|
||||
})
|
||||
|
||||
res.status(200).send({
|
||||
|
||||
@@ -74,11 +74,7 @@ export default async (req: Request, res: Response) => {
|
||||
)
|
||||
}
|
||||
|
||||
await manager.transaction(async (transactionManager) => {
|
||||
await inventoryService
|
||||
.withTransaction(transactionManager)
|
||||
.deleteInventoryLevel(id, location_id)
|
||||
})
|
||||
await inventoryService.deleteInventoryLevel(id, location_id)
|
||||
|
||||
const inventoryItem = await inventoryService.retrieveInventoryItem(
|
||||
id,
|
||||
|
||||
@@ -77,14 +77,10 @@ export default async (req: Request, res: Response) => {
|
||||
req.scope.resolve("inventoryService")
|
||||
const manager: EntityManager = req.scope.resolve("manager")
|
||||
|
||||
await manager.transaction(async (transactionManager) => {
|
||||
await inventoryService
|
||||
.withTransaction(transactionManager)
|
||||
.updateInventoryItem(
|
||||
id,
|
||||
req.validatedBody as AdminPostInventoryItemsInventoryItemReq
|
||||
)
|
||||
})
|
||||
await inventoryService.updateInventoryItem(
|
||||
id,
|
||||
req.validatedBody as AdminPostInventoryItemsInventoryItemReq
|
||||
)
|
||||
|
||||
const inventoryItem = await inventoryService.retrieveInventoryItem(
|
||||
id,
|
||||
|
||||
@@ -81,11 +81,7 @@ export default async (req: Request, res: Response) => {
|
||||
const validatedBody =
|
||||
req.validatedBody as AdminPostInventoryItemsItemLocationLevelsLevelReq
|
||||
|
||||
await manager.transaction(async (transactionManager) => {
|
||||
await inventoryService
|
||||
.withTransaction(transactionManager)
|
||||
.updateInventoryLevel(id, location_id, validatedBody)
|
||||
})
|
||||
await inventoryService.updateInventoryLevel(id, location_id, validatedBody)
|
||||
|
||||
const inventoryItem = await inventoryService.retrieveInventoryItem(
|
||||
id,
|
||||
|
||||
+11
-11
@@ -1,3 +1,14 @@
|
||||
import { MedusaError } from "medusa-core-utils"
|
||||
import { EntityManager } from "typeorm"
|
||||
import { ulid } from "ulid"
|
||||
import { IInventoryService } from "../../../../../interfaces"
|
||||
import { ProductVariant } from "../../../../../models"
|
||||
import {
|
||||
ProductVariantInventoryService,
|
||||
ProductVariantService,
|
||||
} from "../../../../../services"
|
||||
import { InventoryItemDTO } from "../../../../../types/inventory"
|
||||
import { CreateProductVariantInput } from "../../../../../types/product-variant"
|
||||
import {
|
||||
DistributedTransaction,
|
||||
TransactionHandlerType,
|
||||
@@ -6,17 +17,6 @@ import {
|
||||
TransactionState,
|
||||
TransactionStepsDefinition,
|
||||
} from "../../../../../utils/transaction"
|
||||
import { ulid } from "ulid"
|
||||
import { EntityManager } from "typeorm"
|
||||
import { IInventoryService } from "../../../../../interfaces"
|
||||
import {
|
||||
ProductVariantInventoryService,
|
||||
ProductVariantService,
|
||||
} from "../../../../../services"
|
||||
import { CreateProductVariantInput } from "../../../../../types/product-variant"
|
||||
import { InventoryItemDTO } from "../../../../../types/inventory"
|
||||
import { ProductVariant } from "../../../../../models"
|
||||
import { MedusaError } from "medusa-core-utils"
|
||||
|
||||
enum actions {
|
||||
createVariant = "createVariant",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { IsNumber, IsObject, IsOptional, IsString } from "class-validator"
|
||||
import { isDefined } from "medusa-core-utils"
|
||||
import { EntityManager } from "typeorm"
|
||||
import { IInventoryService } from "../../../../interfaces"
|
||||
import { validateUpdateReservationQuantity } from "./utils/validate-reservation-quantity"
|
||||
|
||||
@@ -66,8 +65,6 @@ import { validateUpdateReservationQuantity } from "./utils/validate-reservation-
|
||||
export default async (req, res) => {
|
||||
const { validatedBody } = req as { validatedBody: AdminPostReservationsReq }
|
||||
|
||||
const manager: EntityManager = req.scope.resolve("manager")
|
||||
|
||||
const inventoryService: IInventoryService =
|
||||
req.scope.resolve("inventoryService")
|
||||
|
||||
@@ -82,11 +79,9 @@ export default async (req, res) => {
|
||||
)
|
||||
}
|
||||
|
||||
const reservation = await manager.transaction(async (manager) => {
|
||||
return await inventoryService
|
||||
.withTransaction(manager)
|
||||
.createReservationItem(validatedBody)
|
||||
})
|
||||
const reservation = await inventoryService.createReservationItem(
|
||||
validatedBody
|
||||
)
|
||||
|
||||
res.status(200).json({ reservation })
|
||||
}
|
||||
|
||||
@@ -58,9 +58,7 @@ export default async (req, res) => {
|
||||
req.scope.resolve("inventoryService")
|
||||
const manager: EntityManager = req.scope.resolve("manager")
|
||||
|
||||
await manager.transaction(async (manager) => {
|
||||
await inventoryService.withTransaction(manager).deleteReservationItem(id)
|
||||
})
|
||||
await inventoryService.deleteReservationItem(id)
|
||||
|
||||
res.json({
|
||||
id,
|
||||
|
||||
@@ -91,9 +91,7 @@ export default async (req, res) => {
|
||||
}
|
||||
|
||||
const result = await manager.transaction(async (manager) => {
|
||||
await inventoryService
|
||||
.withTransaction(manager)
|
||||
.updateReservationItem(id, validatedBody)
|
||||
await inventoryService.updateReservationItem(id, validatedBody)
|
||||
})
|
||||
|
||||
res.status(200).json({ reservation: result })
|
||||
|
||||
@@ -79,12 +79,8 @@ export default async (req, res) => {
|
||||
|
||||
if (inventoryService) {
|
||||
await Promise.all([
|
||||
inventoryService
|
||||
.withTransaction(transactionManager)
|
||||
.deleteInventoryItemLevelByLocationId(id),
|
||||
inventoryService
|
||||
.withTransaction(transactionManager)
|
||||
.deleteReservationItemByLocationId(id),
|
||||
inventoryService.deleteInventoryItemLevelByLocationId(id),
|
||||
inventoryService.deleteReservationItemByLocationId(id),
|
||||
])
|
||||
}
|
||||
})
|
||||
|
||||
@@ -3,7 +3,11 @@ import featureFlagLoader from "../loaders/feature-flags"
|
||||
import Logger from "../loaders/logger"
|
||||
import databaseLoader from "../loaders/database"
|
||||
import configModuleLoader from "../loaders/config"
|
||||
import getMigrations, { getModuleSharedResources } from "./utils/get-migrations"
|
||||
import getMigrations, {
|
||||
getModuleSharedResources,
|
||||
revertIsolatedModulesMigration,
|
||||
runIsolatedModulesMigration,
|
||||
} from "./utils/get-migrations"
|
||||
|
||||
const getDataSource = async (directory) => {
|
||||
const configModule = configModuleLoader(directory)
|
||||
@@ -34,16 +38,19 @@ const main = async function ({ directory }) {
|
||||
args.shift()
|
||||
args.shift()
|
||||
|
||||
const configModule = configModuleLoader(directory)
|
||||
const dataSource = await getDataSource(directory)
|
||||
|
||||
if (args[0] === "run") {
|
||||
await dataSource.runMigrations()
|
||||
await dataSource.destroy()
|
||||
await runIsolatedModulesMigration(configModule)
|
||||
Logger.info("Migrations completed.")
|
||||
process.exit()
|
||||
} else if (args[0] === "revert") {
|
||||
await dataSource.undoLastMigration({ transaction: "all" })
|
||||
await dataSource.destroy()
|
||||
await revertIsolatedModulesMigration(configModule)
|
||||
Logger.info("Migrations reverted.")
|
||||
process.exit()
|
||||
} else if (args[0] === "show") {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { sync as existsSync } from "fs-exists-cached"
|
||||
import { getConfigFile } from "medusa-core-utils"
|
||||
import { track } from "medusa-telemetry"
|
||||
import path from "path"
|
||||
import { ConnectionOptions, createConnection } from "typeorm"
|
||||
import { DataSource, DataSourceOptions } from "typeorm"
|
||||
|
||||
import loaders from "../loaders"
|
||||
import { handleConfigError } from "../loaders/config"
|
||||
@@ -73,12 +73,14 @@ const seed = async function ({ directory, migrate, seedFile }: SeedOptions) {
|
||||
extra: configModule.projectConfig.database_extra || {},
|
||||
migrations: coreMigrations.concat(moduleMigrations),
|
||||
logging: true,
|
||||
} as ConnectionOptions
|
||||
} as DataSourceOptions
|
||||
|
||||
const connection = await createConnection(connectionOptions)
|
||||
const connection = new DataSource(connectionOptions)
|
||||
|
||||
await connection.initialize()
|
||||
await connection.runMigrations()
|
||||
await connection.close()
|
||||
await connection.destroy()
|
||||
|
||||
Logger.info("Migrations completed.")
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { registerModules } from "@medusajs/modules-sdk"
|
||||
import { MedusaModule, registerModules } from "@medusajs/modules-sdk"
|
||||
import fs from "fs"
|
||||
import { sync as existsSync } from "fs-exists-cached"
|
||||
import glob from "glob"
|
||||
@@ -96,7 +96,7 @@ function resolvePlugin(pluginName) {
|
||||
export function getInternalModules(configModule) {
|
||||
const modules = []
|
||||
|
||||
const moduleResolutions = registerModules(configModule)
|
||||
const moduleResolutions = registerModules(configModule.modules)
|
||||
|
||||
for (const moduleResolution of Object.values(moduleResolutions)) {
|
||||
if (
|
||||
@@ -200,7 +200,6 @@ export const getModuleMigrations = (configModule, isFlagEnabled) => {
|
||||
for (const loadedModule of loadedModules) {
|
||||
const mod = loadedModule.loadedModule
|
||||
|
||||
const isolatedMigrations = {}
|
||||
const moduleMigrations = (mod.migrations ?? [])
|
||||
.map((migration) => {
|
||||
if (
|
||||
@@ -218,7 +217,6 @@ export const getModuleMigrations = (configModule, isFlagEnabled) => {
|
||||
moduleDeclaration: loadedModule.moduleDeclaration,
|
||||
models: mod.models ?? [],
|
||||
migrations: moduleMigrations,
|
||||
externalMigrations: isolatedMigrations,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -249,3 +247,43 @@ export const getModuleSharedResources = (configModule, featureFlagsRouter) => {
|
||||
migrations,
|
||||
}
|
||||
}
|
||||
|
||||
export const runIsolatedModulesMigration = async (configModule) => {
|
||||
const moduleResolutions = registerModules(configModule.modules)
|
||||
|
||||
for (const moduleResolution of Object.values(moduleResolutions)) {
|
||||
if (
|
||||
!moduleResolution.resolutionPath ||
|
||||
moduleResolution.moduleDeclaration.scope !== "internal" ||
|
||||
moduleResolution.moduleDeclaration.resources !== "isolated"
|
||||
) {
|
||||
continue
|
||||
}
|
||||
|
||||
await MedusaModule.migrateUp(
|
||||
moduleResolution.definition.key,
|
||||
moduleResolution.resolutionPath,
|
||||
moduleResolution.options
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export const revertIsolatedModulesMigration = async (configModule) => {
|
||||
const moduleResolutions = registerModules(configModule.modules)
|
||||
|
||||
for (const moduleResolution of Object.values(moduleResolutions)) {
|
||||
if (
|
||||
!moduleResolution.resolutionPath ||
|
||||
moduleResolution.moduleDeclaration.scope !== "internal" ||
|
||||
moduleResolution.moduleDeclaration.resources !== "isolated"
|
||||
) {
|
||||
continue
|
||||
}
|
||||
|
||||
await MedusaModule.migrateDown(
|
||||
moduleResolution.definition.key,
|
||||
moduleResolution.resolutionPath,
|
||||
moduleResolution.options
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { EntityManager } from "typeorm"
|
||||
import { FindConfig } from "../../types/common"
|
||||
|
||||
import {
|
||||
@@ -16,8 +15,6 @@ import {
|
||||
} from "../../types/inventory"
|
||||
|
||||
export interface IInventoryService {
|
||||
withTransaction(transactionManager?: EntityManager): this
|
||||
|
||||
listInventoryItems(
|
||||
selector: FilterableInventoryItemProps,
|
||||
config?: FindConfig<InventoryItemDTO>
|
||||
|
||||
@@ -91,7 +91,7 @@ export default async ({
|
||||
track("MODULES_INIT_STARTED")
|
||||
await moduleLoader({
|
||||
container,
|
||||
moduleResolutions: registerModules(configModule),
|
||||
moduleResolutions: registerModules(configModule?.modules),
|
||||
logger: Logger,
|
||||
})
|
||||
const modAct = Logger.success(modulesActivity, "Modules initialized") || {}
|
||||
|
||||
@@ -24,11 +24,18 @@ describe("EventBusService", () => {
|
||||
find: () => Promise.resolve([]),
|
||||
})
|
||||
|
||||
eventBus = new EventBusService({
|
||||
manager: MockManager,
|
||||
stagedJobRepository,
|
||||
logger: loggerMock,
|
||||
})
|
||||
eventBus = new EventBusService(
|
||||
{
|
||||
manager: MockManager,
|
||||
stagedJobRepository,
|
||||
logger: loggerMock,
|
||||
},
|
||||
{
|
||||
projectConfig: {
|
||||
redis_url: "localhost",
|
||||
},
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
@@ -49,10 +56,17 @@ describe("EventBusService", () => {
|
||||
beforeEach(() => {
|
||||
jest.resetAllMocks()
|
||||
|
||||
eventBus = new EventBusService({
|
||||
manager: MockManager,
|
||||
logger: loggerMock,
|
||||
})
|
||||
eventBus = new EventBusService(
|
||||
{
|
||||
manager: MockManager,
|
||||
logger: loggerMock,
|
||||
},
|
||||
{
|
||||
projectConfig: {
|
||||
redis_url: "localhost",
|
||||
},
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
@@ -135,11 +149,18 @@ describe("EventBusService", () => {
|
||||
create: (data) => data,
|
||||
})
|
||||
|
||||
eventBus = new EventBusService({
|
||||
logger: loggerMock,
|
||||
manager: mockManager,
|
||||
stagedJobRepository,
|
||||
})
|
||||
eventBus = new EventBusService(
|
||||
{
|
||||
logger: loggerMock,
|
||||
manager: mockManager,
|
||||
stagedJobRepository,
|
||||
},
|
||||
{
|
||||
projectConfig: {
|
||||
redis_url: "localhost",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
eventBus.queue_.addBulk.mockImplementationOnce(() => "hi")
|
||||
})
|
||||
@@ -195,11 +216,18 @@ describe("EventBusService", () => {
|
||||
create: (data) => data,
|
||||
})
|
||||
|
||||
eventBus = new EventBusService({
|
||||
logger: loggerMock,
|
||||
manager: mockManager,
|
||||
stagedJobRepository,
|
||||
})
|
||||
eventBus = new EventBusService(
|
||||
{
|
||||
logger: loggerMock,
|
||||
manager: mockManager,
|
||||
stagedJobRepository,
|
||||
},
|
||||
{
|
||||
projectConfig: {
|
||||
redis_url: "localhost",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
eventBus.queue_.addBulk.mockImplementationOnce(() => "hi")
|
||||
})
|
||||
@@ -285,7 +313,10 @@ describe("EventBusService", () => {
|
||||
stagedJobRepository,
|
||||
},
|
||||
{
|
||||
projectConfig: { event_options: { removeOnComplete: 10 } },
|
||||
projectConfig: {
|
||||
event_options: { removeOnComplete: 10 },
|
||||
redis_url: "localhost",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -323,11 +354,18 @@ describe("EventBusService", () => {
|
||||
create: (data) => data,
|
||||
})
|
||||
|
||||
eventBus = new EventBusService({
|
||||
logger: loggerMock,
|
||||
manager: mockManager,
|
||||
stagedJobRepository,
|
||||
})
|
||||
eventBus = new EventBusService(
|
||||
{
|
||||
logger: loggerMock,
|
||||
manager: mockManager,
|
||||
stagedJobRepository,
|
||||
},
|
||||
{
|
||||
projectConfig: {
|
||||
redis_url: "localhost",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
eventBus.queue_.addBulk.mockImplementationOnce(() => "hi")
|
||||
|
||||
@@ -370,7 +408,10 @@ describe("EventBusService", () => {
|
||||
stagedJobRepository,
|
||||
},
|
||||
{
|
||||
projectConfig: { event_options: { removeOnComplete: 10 } },
|
||||
projectConfig: {
|
||||
event_options: { removeOnComplete: 10 },
|
||||
redis_url: "localhost",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -418,14 +459,11 @@ describe("EventBusService", () => {
|
||||
find: () => Promise.resolve([]),
|
||||
})
|
||||
|
||||
eventBus = new EventBusService(
|
||||
{
|
||||
manager: MockManager,
|
||||
stagedJobRepository,
|
||||
logger: loggerMock,
|
||||
},
|
||||
{}
|
||||
)
|
||||
eventBus = new EventBusService({
|
||||
manager: MockManager,
|
||||
stagedJobRepository,
|
||||
logger: loggerMock,
|
||||
})
|
||||
eventBus.subscribe("eventName", () => Promise.resolve("hi"))
|
||||
result = await eventBus.worker_({
|
||||
data: { eventName: "eventName", data: {} },
|
||||
|
||||
@@ -308,7 +308,9 @@ export default class EventBusService {
|
||||
return (!isBulkEmit ? stagedJobs[0] : stagedJobs) as unknown as TResult
|
||||
}
|
||||
|
||||
await this.queue_.addBulk(events)
|
||||
if (this.config_?.projectConfig?.redis_url) {
|
||||
await this.queue_.addBulk(events)
|
||||
}
|
||||
}
|
||||
|
||||
startEnqueuer(): void {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { isDefined, MedusaError } from "medusa-core-utils"
|
||||
import {
|
||||
Brackets,
|
||||
EntityManager,
|
||||
@@ -9,37 +10,36 @@ import {
|
||||
IsNull,
|
||||
SelectQueryBuilder,
|
||||
} from "typeorm"
|
||||
import {
|
||||
CreateProductVariantInput,
|
||||
FilterableProductVariantProps,
|
||||
GetRegionPriceContext,
|
||||
ProductVariantPrice,
|
||||
UpdateProductVariantInput,
|
||||
} from "../types/product-variant"
|
||||
import {
|
||||
FindWithRelationsOptions,
|
||||
ProductVariantRepository,
|
||||
} from "../repositories/product-variant"
|
||||
import {
|
||||
IPriceSelectionStrategy,
|
||||
PriceSelectionContext,
|
||||
TransactionBaseService,
|
||||
} from "../interfaces"
|
||||
import { MedusaError, isDefined } from "medusa-core-utils"
|
||||
import {
|
||||
MoneyAmount,
|
||||
Product,
|
||||
ProductOptionValue,
|
||||
ProductVariant,
|
||||
} from "../models"
|
||||
import {
|
||||
FindWithRelationsOptions,
|
||||
ProductVariantRepository,
|
||||
} from "../repositories/product-variant"
|
||||
import {
|
||||
CreateProductVariantInput,
|
||||
FilterableProductVariantProps,
|
||||
GetRegionPriceContext,
|
||||
ProductVariantPrice,
|
||||
UpdateProductVariantInput,
|
||||
} from "../types/product-variant"
|
||||
import { buildQuery, buildRelations, setMetadata } from "../utils"
|
||||
|
||||
import { CartRepository } from "../repositories/cart"
|
||||
import EventBusService from "./event-bus"
|
||||
import { FindConfig } from "../types/common"
|
||||
import { MoneyAmountRepository } from "../repositories/money-amount"
|
||||
import { ProductOptionValueRepository } from "../repositories/product-option-value"
|
||||
import { ProductRepository } from "../repositories/product"
|
||||
import { ProductOptionValueRepository } from "../repositories/product-option-value"
|
||||
import { FindConfig } from "../types/common"
|
||||
import EventBusService from "./event-bus"
|
||||
import RegionService from "./region"
|
||||
|
||||
class ProductVariantService extends TransactionBaseService {
|
||||
@@ -173,7 +173,9 @@ class ProductVariantService extends TransactionBaseService {
|
||||
"options",
|
||||
]),
|
||||
})) as Product
|
||||
} else if (!product.id) {
|
||||
}
|
||||
|
||||
if (!product?.id) {
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.INVALID_DATA,
|
||||
`Product id missing`
|
||||
|
||||
@@ -42,9 +42,10 @@ class SalesChannelInventoryService extends TransactionBaseService {
|
||||
.withTransaction(this.activeManager_)
|
||||
.listLocationIds(salesChannelId)
|
||||
|
||||
return await this.inventoryService_
|
||||
.withTransaction(this.activeManager_)
|
||||
.retrieveAvailableQuantity(inventoryItemId, locationIds)
|
||||
return await this.inventoryService_.retrieveAvailableQuantity(
|
||||
inventoryItemId,
|
||||
locationIds
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ type InjectedDependencies = {
|
||||
|
||||
class SalesChannelLocationService extends TransactionBaseService {
|
||||
protected readonly salesChannelService_: SalesChannelService
|
||||
protected readonly eventBusService: EventBusService
|
||||
protected readonly stockLocationService: IStockLocationService
|
||||
protected readonly eventBusService_: EventBusService
|
||||
protected readonly stockLocationService_: IStockLocationService
|
||||
|
||||
constructor({
|
||||
salesChannelService,
|
||||
@@ -30,8 +30,8 @@ class SalesChannelLocationService extends TransactionBaseService {
|
||||
super(arguments[0])
|
||||
|
||||
this.salesChannelService_ = salesChannelService
|
||||
this.eventBusService = eventBusService
|
||||
this.stockLocationService = stockLocationService
|
||||
this.eventBusService_ = eventBusService
|
||||
this.stockLocationService_ = stockLocationService
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,9 +77,9 @@ class SalesChannelLocationService extends TransactionBaseService {
|
||||
.withTransaction(this.activeManager_)
|
||||
.retrieve(salesChannelId)
|
||||
|
||||
if (this.stockLocationService) {
|
||||
if (this.stockLocationService_) {
|
||||
// trhows error if not found
|
||||
await this.stockLocationService.retrieve(locationId)
|
||||
await this.stockLocationService_.retrieve(locationId)
|
||||
}
|
||||
|
||||
const salesChannelLocation = this.activeManager_.create(
|
||||
@@ -129,7 +129,7 @@ class SalesChannelLocationService extends TransactionBaseService {
|
||||
*/
|
||||
async listSalesChannelIds(locationId: string): Promise<string[]> {
|
||||
const manager = this.transactionManager_ || this.manager_
|
||||
const location = await this.stockLocationService.retrieve(locationId)
|
||||
const location = await this.stockLocationService_.retrieve(locationId)
|
||||
|
||||
const salesChannelLocations = await manager.find(SalesChannelLocation, {
|
||||
where: { location_id: location.id },
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { InternalModuleDeclaration } from "@medusajs/modules-sdk"
|
||||
import { MedusaContainer as coreMedusaContainer } from "medusa-core-utils"
|
||||
import {
|
||||
ExternalModuleDeclaration,
|
||||
InternalModuleDeclaration,
|
||||
} from "@medusajs/modules-sdk"
|
||||
import { Request } from "express"
|
||||
import { MedusaContainer as coreMedusaContainer } from "medusa-core-utils"
|
||||
import { LoggerOptions } from "typeorm"
|
||||
import { Logger as _Logger } from "winston"
|
||||
import { Customer, User } from "../models"
|
||||
@@ -91,7 +94,12 @@ export type ConfigModule = {
|
||||
admin_cors?: string
|
||||
}
|
||||
featureFlags: Record<string, boolean | string>
|
||||
modules?: Record<string, false | string | Partial<InternalModuleDeclaration>>
|
||||
modules?: Record<
|
||||
string,
|
||||
| false
|
||||
| string
|
||||
| Partial<InternalModuleDeclaration | ExternalModuleDeclaration>
|
||||
>
|
||||
plugins: (
|
||||
| {
|
||||
resolve: string
|
||||
|
||||
Reference in New Issue
Block a user