mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
chore: Remove the utils
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { ManifestVersion, SDKManifest } from "../../manifest/ManifestTypes"
|
||||
import { Effects } from "../../types"
|
||||
import { Utils } from "../../util/utils"
|
||||
|
||||
export class Migration<
|
||||
Manifest extends SDKManifest,
|
||||
@@ -10,14 +9,8 @@ export class Migration<
|
||||
constructor(
|
||||
readonly options: {
|
||||
version: Version
|
||||
up: (opts: {
|
||||
effects: Effects
|
||||
utils: Utils<Manifest, Store>
|
||||
}) => Promise<void>
|
||||
down: (opts: {
|
||||
effects: Effects
|
||||
utils: Utils<Manifest, Store>
|
||||
}) => Promise<void>
|
||||
up: (opts: { effects: Effects }) => Promise<void>
|
||||
down: (opts: { effects: Effects }) => Promise<void>
|
||||
},
|
||||
) {}
|
||||
static of<
|
||||
@@ -26,23 +19,17 @@ export class Migration<
|
||||
Version extends ManifestVersion,
|
||||
>(options: {
|
||||
version: Version
|
||||
up: (opts: {
|
||||
effects: Effects
|
||||
utils: Utils<Manifest, Store>
|
||||
}) => Promise<void>
|
||||
down: (opts: {
|
||||
effects: Effects
|
||||
utils: Utils<Manifest, Store>
|
||||
}) => Promise<void>
|
||||
up: (opts: { effects: Effects }) => Promise<void>
|
||||
down: (opts: { effects: Effects }) => Promise<void>
|
||||
}) {
|
||||
return new Migration<Manifest, Store, Version>(options)
|
||||
}
|
||||
|
||||
async up(opts: { effects: Effects; utils: Utils<Manifest, Store> }) {
|
||||
async up(opts: { effects: Effects }) {
|
||||
this.up(opts)
|
||||
}
|
||||
|
||||
async down(opts: { effects: Effects; utils: Utils<Manifest, Store> }) {
|
||||
async down(opts: { effects: Effects }) {
|
||||
this.down(opts)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { EmVer } from "../../emverLite/mod"
|
||||
import { SDKManifest } from "../../manifest/ManifestTypes"
|
||||
import { ExpectedExports } from "../../types"
|
||||
import { createUtils } from "../../util"
|
||||
import { once } from "../../util/once"
|
||||
import { Migration } from "./Migration"
|
||||
|
||||
@@ -32,13 +31,12 @@ export class Migrations<Manifest extends SDKManifest, Store> {
|
||||
effects,
|
||||
previousVersion,
|
||||
}: Parameters<ExpectedExports.init>[0]) {
|
||||
const utils = createUtils<Manifest, Store>(effects)
|
||||
if (!!previousVersion) {
|
||||
const previousVersionEmVer = EmVer.parse(previousVersion)
|
||||
for (const [_, migration] of this.sortedMigrations()
|
||||
.filter((x) => x[0].greaterThan(previousVersionEmVer))
|
||||
.filter((x) => x[0].lessThanOrEqual(this.currentVersion()))) {
|
||||
await migration.up({ effects, utils })
|
||||
await migration.up({ effects })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,14 +44,13 @@ export class Migrations<Manifest extends SDKManifest, Store> {
|
||||
effects,
|
||||
nextVersion,
|
||||
}: Parameters<ExpectedExports.uninit>[0]) {
|
||||
const utils = createUtils<Manifest, Store>(effects)
|
||||
if (!!nextVersion) {
|
||||
const nextVersionEmVer = EmVer.parse(nextVersion)
|
||||
const reversed = [...this.sortedMigrations()].reverse()
|
||||
for (const [_, migration] of reversed
|
||||
.filter((x) => x[0].greaterThan(nextVersionEmVer))
|
||||
.filter((x) => x[0].lessThanOrEqual(this.currentVersion()))) {
|
||||
await migration.down({ effects, utils })
|
||||
await migration.down({ effects })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import { Effects, ExposeServicePaths, ExposeUiPaths } from "../types"
|
||||
import { Utils } from "../util/utils"
|
||||
|
||||
export type SetupExports<Store> = (opts: {
|
||||
effects: Effects
|
||||
utils: Utils<any, Store>
|
||||
}) =>
|
||||
export type SetupExports<Store> = (opts: { effects: Effects }) =>
|
||||
| {
|
||||
ui: { [k: string]: ExposeUiPaths<Store> }
|
||||
services: ExposeServicePaths<Store>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { SetInterfaces } from "../interfaces/setupInterfaces"
|
||||
import { SDKManifest } from "../manifest/ManifestTypes"
|
||||
import { ExpectedExports, ExposeUiPaths, ExposeUiPathsAll } from "../types"
|
||||
import { createUtils } from "../util"
|
||||
import { Migrations } from "./migrations/setupMigrations"
|
||||
import { SetupExports } from "./setupExports"
|
||||
import { Install } from "./setupInstall"
|
||||
@@ -19,18 +18,13 @@ export function setupInit<Manifest extends SDKManifest, Store>(
|
||||
} {
|
||||
return {
|
||||
init: async (opts) => {
|
||||
const utils = createUtils<Manifest, Store>(opts.effects)
|
||||
await migrations.init(opts)
|
||||
await install.init(opts)
|
||||
await setInterfaces({
|
||||
...opts,
|
||||
input: null,
|
||||
utils,
|
||||
})
|
||||
const { services, ui } = await setupExports({
|
||||
...opts,
|
||||
utils,
|
||||
})
|
||||
const { services, ui } = await setupExports(opts)
|
||||
await opts.effects.exposeForDependents(services)
|
||||
await opts.effects.exposeUi(
|
||||
forExpose({
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import { SDKManifest } from "../manifest/ManifestTypes"
|
||||
import { Effects, ExpectedExports } from "../types"
|
||||
import { Utils, createUtils } from "../util/utils"
|
||||
|
||||
export type InstallFn<Manifest extends SDKManifest, Store> = (opts: {
|
||||
effects: Effects
|
||||
utils: Utils<Manifest, Store>
|
||||
}) => Promise<void>
|
||||
export class Install<Manifest extends SDKManifest, Store> {
|
||||
private constructor(readonly fn: InstallFn<Manifest, Store>) {}
|
||||
@@ -21,7 +19,6 @@ export class Install<Manifest extends SDKManifest, Store> {
|
||||
if (!previousVersion)
|
||||
await this.fn({
|
||||
effects,
|
||||
utils: createUtils(effects),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import { SDKManifest } from "../manifest/ManifestTypes"
|
||||
import { Effects, ExpectedExports } from "../types"
|
||||
import { Utils, createUtils } from "../util/utils"
|
||||
|
||||
export type UninstallFn<Manifest extends SDKManifest, Store> = (opts: {
|
||||
effects: Effects
|
||||
utils: Utils<Manifest, Store>
|
||||
}) => Promise<void>
|
||||
export class Uninstall<Manifest extends SDKManifest, Store> {
|
||||
private constructor(readonly fn: UninstallFn<Manifest, Store>) {}
|
||||
@@ -21,7 +19,6 @@ export class Uninstall<Manifest extends SDKManifest, Store> {
|
||||
if (!nextVersion)
|
||||
await this.fn({
|
||||
effects,
|
||||
utils: createUtils(effects),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user