chore: remove internal module resources option (#9582)
What: * removes resouces type "shared" or "isolated" from internal modules. * modules can have an isolated database connection by providing a database config as part of their options on `medusa-config` CLOSES: FRMW-2593
This commit is contained in:
committed by
GitHub
parent
b07dd33a57
commit
902ac12f73
@@ -1,8 +1,4 @@
|
||||
import {
|
||||
MedusaModule,
|
||||
MODULE_RESOURCE_TYPE,
|
||||
MODULE_SCOPE,
|
||||
} from "@medusajs/framework/modules-sdk"
|
||||
import { MedusaModule, MODULE_SCOPE } from "@medusajs/framework/modules-sdk"
|
||||
import {
|
||||
ExternalModuleDeclaration,
|
||||
ILinkModule,
|
||||
@@ -158,11 +154,6 @@ export const initialize = async (
|
||||
dependencies: [Modules.EVENT_BUS],
|
||||
defaultModuleDeclaration: {
|
||||
scope: MODULE_SCOPE.INTERNAL,
|
||||
resources: injectedDependencies?.[
|
||||
ContainerRegistrationKeys.PG_CONNECTION
|
||||
]
|
||||
? MODULE_RESOURCE_TYPE.SHARED
|
||||
: MODULE_RESOURCE_TYPE.ISOLATED,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import {
|
||||
ModulesSdkUtils,
|
||||
} from "@medusajs/framework/utils"
|
||||
import { LinkService } from "@services"
|
||||
import { shouldForceTransaction } from "../utils"
|
||||
|
||||
type InjectedDependencies = {
|
||||
baseRepository: DAL.RepositoryService
|
||||
@@ -173,7 +172,7 @@ export default class LinkModuleService implements ILinkModule {
|
||||
return [rows.map((row) => row.toJSON()), count]
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager()
|
||||
async create(
|
||||
primaryKeyOrBulkData:
|
||||
| string
|
||||
@@ -222,7 +221,7 @@ export default class LinkModuleService implements ILinkModule {
|
||||
return links.map((row) => row.toJSON())
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager()
|
||||
async dismiss(
|
||||
primaryKeyOrBulkData: string | string[] | [string | string[], string][],
|
||||
foreignKeyData?: string,
|
||||
@@ -247,7 +246,7 @@ export default class LinkModuleService implements ILinkModule {
|
||||
return links.map((row) => row.toJSON())
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager()
|
||||
async delete(
|
||||
data: any,
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -322,7 +321,7 @@ export default class LinkModuleService implements ILinkModule {
|
||||
return mappedCascadedEntitiesMap ? mappedCascadedEntitiesMap : void 0
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager()
|
||||
protected async softDelete_(
|
||||
data: any[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -380,7 +379,7 @@ export default class LinkModuleService implements ILinkModule {
|
||||
return mappedCascadedEntitiesMap ? mappedCascadedEntitiesMap : void 0
|
||||
}
|
||||
|
||||
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
|
||||
@InjectTransactionManager()
|
||||
async restore_(
|
||||
data: any,
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
MedusaContext,
|
||||
ModulesSdkUtils,
|
||||
} from "@medusajs/framework/utils"
|
||||
import { doNotForceTransaction } from "../utils"
|
||||
|
||||
type InjectedDependencies = {
|
||||
linkRepository: any
|
||||
@@ -41,7 +40,7 @@ export default class LinkService<TEntity> {
|
||||
return await this.linkRepository_.findAndCount(queryOptions, sharedContext)
|
||||
}
|
||||
|
||||
@InjectTransactionManager(doNotForceTransaction, "linkRepository_")
|
||||
@InjectTransactionManager("linkRepository_")
|
||||
async create(
|
||||
data: unknown[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -51,7 +50,7 @@ export default class LinkService<TEntity> {
|
||||
})
|
||||
}
|
||||
|
||||
@InjectTransactionManager(doNotForceTransaction, "linkRepository_")
|
||||
@InjectTransactionManager("linkRepository_")
|
||||
async dismiss(
|
||||
data: unknown[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -75,7 +74,7 @@ export default class LinkService<TEntity> {
|
||||
return rows
|
||||
}
|
||||
|
||||
@InjectTransactionManager(doNotForceTransaction, "linkRepository_")
|
||||
@InjectTransactionManager("linkRepository_")
|
||||
async delete(
|
||||
data: unknown,
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -85,7 +84,7 @@ export default class LinkService<TEntity> {
|
||||
})
|
||||
}
|
||||
|
||||
@InjectTransactionManager(doNotForceTransaction, "linkRepository_")
|
||||
@InjectTransactionManager("linkRepository_")
|
||||
async softDelete(
|
||||
data: any[],
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
@@ -109,7 +108,7 @@ export default class LinkService<TEntity> {
|
||||
})
|
||||
}
|
||||
|
||||
@InjectTransactionManager(doNotForceTransaction, "linkRepository_")
|
||||
@InjectTransactionManager("linkRepository_")
|
||||
async restore(
|
||||
data: any,
|
||||
@MedusaContext() sharedContext: Context = {}
|
||||
|
||||
@@ -1,12 +1,2 @@
|
||||
import { MODULE_RESOURCE_TYPE } from "@medusajs/framework/modules-sdk"
|
||||
|
||||
export * from "./generate-entity"
|
||||
export * from "./generate-schema"
|
||||
|
||||
export function shouldForceTransaction(target: any): boolean {
|
||||
return target.moduleDeclaration?.resources === MODULE_RESOURCE_TYPE.ISOLATED
|
||||
}
|
||||
|
||||
export function doNotForceTransaction(): boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user