import { createApplication } from "../application/create-application.js"; /** * This is the only module allowed to join concrete adapters to application * ports. Boot phases are explicit so failures can stop before product mount. * * @template Config * @template Release * @template {Parameters[0]} OutputPorts * @template Infrastructure * @param {{ * loadConfig(): Promise, * loadRelease(config: Config): Promise, * createAdapters(context: { * config: Config, * release: Release * }): Promise<{ * outputPorts: OutputPorts, * infrastructure: Infrastructure * }> * }} factories * @returns {Promise * }>>} */ export async function createCompositionRoot(factories) { const config = await factories.loadConfig(); const release = await factories.loadRelease(config); const adapters = await factories.createAdapters({ config, release }); const application = createApplication(adapters.outputPorts); return Object.freeze({ config, release, infrastructure: adapters.infrastructure, application, }); }