Feat: Move container bindings declaration merging within the framework (#9467)

This commit is contained in:
Harminder Virk
2024-10-04 15:47:06 +05:30
committed by GitHub
parent 0a2ecdc889
commit d98f22c7d6
13 changed files with 119 additions and 105 deletions
@@ -6,7 +6,13 @@ import {
TransactionHandlerType,
TransactionState,
} from "@medusajs/orchestration"
import { Context, LoadedModule, MedusaContainer } from "@medusajs/types"
import {
Context,
IEventBusModuleService,
LoadedModule,
Logger,
MedusaContainer,
} from "@medusajs/types"
import {
ContainerRegistrationKeys,
isPresent,
@@ -514,7 +520,7 @@ function attachOnFinishReleaseEvents(
const flowEventGroupId = transaction.getFlow().metadata?.eventGroupId
const logger =
(flow.container as MedusaContainer).resolve(
(flow.container as MedusaContainer).resolve<Logger>(
ContainerRegistrationKeys.LOGGER,
{ allowUnregistered: true }
) || console
@@ -539,10 +545,11 @@ function attachOnFinishReleaseEvents(
await onFinish?.(args)
const eventBusService = (flow.container as MedusaContainer).resolve(
Modules.EVENT_BUS,
{ allowUnregistered: true }
)
const eventBusService = (
flow.container as MedusaContainer
).resolve<IEventBusModuleService>(Modules.EVENT_BUS, {
allowUnregistered: true,
})
if (!eventBusService || !flowEventGroupId) {
return
@@ -2216,7 +2216,9 @@ describe("Workflow composer", function () {
throwOnError: false,
})
const eventBusMock = container.resolve(Modules.EVENT_BUS)
const eventBusMock = container.resolve<IEventBusModuleService>(
Modules.EVENT_BUS
)
expect(eventBusMock.emit).toHaveBeenCalledTimes(1)
expect(eventBusMock.releaseGroupedEvents).toHaveBeenCalledTimes(0)