mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
wip: Adding in properties and nested path
This commit is contained in:
@@ -1,14 +1,9 @@
|
||||
import { DependenciesReceipt } from "../config/setupConfig"
|
||||
import { SetInterfaces } from "../interfaces/setupInterfaces"
|
||||
import { SDKManifest } from "../manifest/ManifestTypes"
|
||||
import {
|
||||
Effects,
|
||||
ExpectedExports,
|
||||
ExposeUiPaths,
|
||||
ExposeUiPathsAll,
|
||||
} from "../types"
|
||||
import { ExposedStorePaths } from "../store/setupExposeStore"
|
||||
import { Effects, ExpectedExports } from "../types"
|
||||
import { Migrations } from "./migrations/setupMigrations"
|
||||
import { SetupExports } from "./setupExports"
|
||||
import { Install } from "./setupInstall"
|
||||
import { Uninstall } from "./setupUninstall"
|
||||
|
||||
@@ -17,11 +12,11 @@ export function setupInit<Manifest extends SDKManifest, Store>(
|
||||
install: Install<Manifest, Store>,
|
||||
uninstall: Uninstall<Manifest, Store>,
|
||||
setInterfaces: SetInterfaces<Manifest, Store, any, any>,
|
||||
setupExports: SetupExports<Store>,
|
||||
setDependencies: (options: {
|
||||
effects: Effects
|
||||
input: any
|
||||
}) => Promise<DependenciesReceipt>,
|
||||
exposedStore: ExposedStorePaths,
|
||||
): {
|
||||
init: ExpectedExports.init
|
||||
uninit: ExpectedExports.uninit
|
||||
@@ -34,9 +29,7 @@ export function setupInit<Manifest extends SDKManifest, Store>(
|
||||
...opts,
|
||||
input: null,
|
||||
})
|
||||
const { services, ui } = await setupExports(opts)
|
||||
await opts.effects.exposeForDependents({ paths: services })
|
||||
await opts.effects.exposeUi(forExpose(ui))
|
||||
await opts.effects.exposeForDependents({ paths: exposedStore })
|
||||
await setDependencies({ effects: opts.effects, input: null })
|
||||
},
|
||||
uninit: async (opts) => {
|
||||
@@ -45,30 +38,3 @@ export function setupInit<Manifest extends SDKManifest, Store>(
|
||||
},
|
||||
}
|
||||
}
|
||||
function forExpose<Store>(ui: { [key: string]: ExposeUiPaths<Store> }) {
|
||||
return Object.fromEntries(
|
||||
Object.entries(ui).map(([key, value]) => [key, forExpose_(value)]),
|
||||
)
|
||||
}
|
||||
|
||||
function forExpose_<Store>(ui: ExposeUiPaths<Store>): ExposeUiPathsAll {
|
||||
if (ui.type === ("object" as const)) {
|
||||
return {
|
||||
type: "object" as const,
|
||||
value: Object.fromEntries(
|
||||
Object.entries(ui.value).map(([key, value]) => [
|
||||
key,
|
||||
forExpose_(value),
|
||||
]),
|
||||
),
|
||||
description: ui.description ?? null,
|
||||
}
|
||||
}
|
||||
return {
|
||||
description: null,
|
||||
|
||||
copyable: null,
|
||||
qr: null,
|
||||
...ui,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user