diff --git a/.changeset/stupid-beans-peel.md b/.changeset/stupid-beans-peel.md new file mode 100644 index 0000000000..7b944a25b3 --- /dev/null +++ b/.changeset/stupid-beans-peel.md @@ -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 diff --git a/packages/inventory/src/services/inventory.ts b/packages/inventory/src/services/inventory.ts index 84c823ebc1..0afeb18319 100644 --- a/packages/inventory/src/services/inventory.ts +++ b/packages/inventory/src/services/inventory.ts @@ -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( diff --git a/packages/medusa/src/interfaces/transaction-base-service.ts b/packages/medusa/src/interfaces/transaction-base-service.ts index 5f9e914b0c..aadccd649b 100644 --- a/packages/medusa/src/interfaces/transaction-base-service.ts +++ b/packages/medusa/src/interfaces/transaction-base-service.ts @@ -7,7 +7,8 @@ export abstract class TransactionBaseService { protected constructor( protected readonly __container__: any, - protected readonly __configModule__?: Record + protected readonly __configModule__?: Record, + protected readonly __moduleDeclaration__?: Record ) {} 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 diff --git a/packages/stock-location/src/services/stock-location.ts b/packages/stock-location/src/services/stock-location.ts index 258ad8310d..b33eda506f 100644 --- a/packages/stock-location/src/services/stock-location.ts +++ b/packages/stock-location/src/services/stock-location.ts @@ -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(