feat: Add in the setupExports

This commit is contained in:
Blu-J
2023-05-30 17:21:53 -06:00
parent bb35e676d3
commit 613bf74180
4 changed files with 40 additions and 12 deletions

View File

@@ -2,6 +2,7 @@ import { SetInterfaces } from "../interfaces/setupInterfaces"
import { ExpectedExports } from "../types"
import { createUtils } from "../util"
import { Migrations } from "./migrations/setupMigrations"
import { SetupExports } from "./setupExports"
import { Install } from "./setupInstall"
import { Uninstall } from "./setupUninstall"
@@ -10,19 +11,27 @@ export function setupInit<Store, Vault>(
install: Install<Store, Vault>,
uninstall: Uninstall<Store, Vault>,
setInterfaces: SetInterfaces<Store, Vault, any, any>,
setupExports: SetupExports<Store>,
): {
init: ExpectedExports.init
uninit: ExpectedExports.uninit
} {
return {
init: async (opts) => {
const utils = createUtils<Store>(opts.effects)
await migrations.init(opts)
await install.init(opts)
await setInterfaces({
...opts,
input: null,
utils: createUtils<Store, Vault>(opts.effects),
utils,
})
const { services, ui } = await setupExports({
...opts,
utils,
})
await opts.effects.exposeForDependents(services)
await opts.effects.exposeUi(ui)
},
uninit: async (opts) => {
await migrations.uninit(opts)