fix(medusa): Add module config to transaction base service (#3033)
This commit is contained in:
committed by
GitHub
parent
93d0dc1bdc
commit
1547dd8143
@@ -0,0 +1,7 @@
|
||||
---
|
||||
"@medusajs/inventory": patch
|
||||
"@medusajs/medusa": patch
|
||||
"@medusajs/stock-location": patch
|
||||
---
|
||||
|
||||
fix(medusa): Add module options to transaction base service to use in modules
|
||||
@@ -1,30 +1,30 @@
|
||||
import { MedusaError } from "medusa-core-utils"
|
||||
import {
|
||||
FindConfig,
|
||||
IInventoryService,
|
||||
FilterableInventoryItemProps,
|
||||
FilterableReservationItemProps,
|
||||
ConfigurableModuleDeclaration,
|
||||
CreateInventoryItemInput,
|
||||
CreateReservationItemInput,
|
||||
FilterableInventoryLevelProps,
|
||||
CreateInventoryLevelInput,
|
||||
CreateReservationItemInput,
|
||||
FilterableInventoryItemProps,
|
||||
FilterableInventoryLevelProps,
|
||||
FilterableReservationItemProps,
|
||||
FindConfig,
|
||||
IEventBusService,
|
||||
IInventoryService,
|
||||
InventoryItemDTO,
|
||||
InventoryLevelDTO,
|
||||
MODULE_RESOURCE_TYPE,
|
||||
ReservationItemDTO,
|
||||
TransactionBaseService,
|
||||
UpdateInventoryLevelInput,
|
||||
UpdateReservationItemInput,
|
||||
IEventBusService,
|
||||
InventoryItemDTO,
|
||||
ReservationItemDTO,
|
||||
InventoryLevelDTO,
|
||||
TransactionBaseService,
|
||||
ConfigurableModuleDeclaration,
|
||||
MODULE_RESOURCE_TYPE,
|
||||
} from "@medusajs/medusa"
|
||||
import { MedusaError } from "medusa-core-utils"
|
||||
|
||||
import { EntityManager } from "typeorm"
|
||||
import {
|
||||
InventoryItemService,
|
||||
ReservationItemService,
|
||||
InventoryLevelService,
|
||||
ReservationItemService,
|
||||
} from "./"
|
||||
import { EntityManager } from "typeorm"
|
||||
|
||||
type InjectedDependencies = {
|
||||
manager: EntityManager
|
||||
@@ -47,7 +47,8 @@ export default class InventoryService
|
||||
options?: unknown,
|
||||
moduleDeclaration?: ConfigurableModuleDeclaration
|
||||
) {
|
||||
super(arguments[0])
|
||||
// @ts-ignore
|
||||
super(...arguments)
|
||||
|
||||
if (moduleDeclaration?.resources !== MODULE_RESOURCE_TYPE.SHARED) {
|
||||
throw new MedusaError(
|
||||
|
||||
@@ -7,7 +7,8 @@ export abstract class TransactionBaseService {
|
||||
|
||||
protected constructor(
|
||||
protected readonly __container__: any,
|
||||
protected readonly __configModule__?: Record<string, unknown>
|
||||
protected readonly __configModule__?: Record<string, unknown>,
|
||||
protected readonly __moduleDeclaration__?: Record<string, unknown>
|
||||
) {}
|
||||
|
||||
withTransaction(transactionManager?: EntityManager): this {
|
||||
@@ -17,7 +18,8 @@ export abstract class TransactionBaseService {
|
||||
|
||||
const cloned = new (this.constructor as any)(
|
||||
this.__container__,
|
||||
this.__configModule__
|
||||
this.__configModule__,
|
||||
this.__moduleDeclaration__
|
||||
)
|
||||
|
||||
cloned.manager_ = transactionManager
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { EntityManager } from "typeorm"
|
||||
import { isDefined, MedusaError } from "medusa-core-utils"
|
||||
import {
|
||||
FindConfig,
|
||||
buildQuery,
|
||||
FilterableStockLocationProps,
|
||||
CreateStockLocationInput,
|
||||
UpdateStockLocationInput,
|
||||
StockLocationAddressInput,
|
||||
IEventBusService,
|
||||
setMetadata,
|
||||
TransactionBaseService,
|
||||
ConfigurableModuleDeclaration,
|
||||
CreateStockLocationInput,
|
||||
FilterableStockLocationProps,
|
||||
FindConfig,
|
||||
IEventBusService,
|
||||
MODULE_RESOURCE_TYPE,
|
||||
setMetadata,
|
||||
StockLocationAddressInput,
|
||||
TransactionBaseService,
|
||||
UpdateStockLocationInput,
|
||||
} from "@medusajs/medusa"
|
||||
import { isDefined, MedusaError } from "medusa-core-utils"
|
||||
import { EntityManager } from "typeorm"
|
||||
|
||||
import { StockLocation, StockLocationAddress } from "../models"
|
||||
|
||||
@@ -42,7 +42,8 @@ export default class StockLocationService extends TransactionBaseService {
|
||||
options?: unknown,
|
||||
moduleDeclaration?: ConfigurableModuleDeclaration
|
||||
) {
|
||||
super(arguments[0])
|
||||
// @ts-ignore
|
||||
super(...arguments)
|
||||
|
||||
if (moduleDeclaration?.resources !== MODULE_RESOURCE_TYPE.SHARED) {
|
||||
throw new MedusaError(
|
||||
|
||||
Reference in New Issue
Block a user