fix(medusa): Add module config to transaction base service (#3033)

This commit is contained in:
Oliver Windall Juhl
2023-01-15 19:37:11 +01:00
committed by GitHub
parent 93d0dc1bdc
commit 1547dd8143
4 changed files with 41 additions and 30 deletions
+7
View File
@@ -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
+18 -17
View File
@@ -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(