mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
* create version graph to handle migrations * Fix some version alpha test * connect dataVersion api * rename init fns * improve types and add tests * set data version after backup restore * chore: Add some types tests for version info * wip: More changes to versionInfo tests * wip: fix my stupid * update mocks * update runtime * chore: Fix the loop --------- Co-authored-by: Jade <2364004+Blu-J@users.noreply.github.com> Co-authored-by: J H <dragondef@gmail.com>
30 lines
710 B
TypeScript
30 lines
710 B
TypeScript
import * as T from "../types"
|
|
|
|
export type UninstallFn<Manifest extends T.Manifest, Store> = (opts: {
|
|
effects: T.Effects
|
|
}) => Promise<void>
|
|
export class Uninstall<Manifest extends T.Manifest, Store> {
|
|
private constructor(readonly fn: UninstallFn<Manifest, Store>) {}
|
|
static of<Manifest extends T.Manifest, Store>(
|
|
fn: UninstallFn<Manifest, Store>,
|
|
) {
|
|
return new Uninstall(fn)
|
|
}
|
|
|
|
async uninstall({
|
|
effects,
|
|
nextVersion,
|
|
}: Parameters<T.ExpectedExports.uninit>[0]) {
|
|
if (!nextVersion)
|
|
await this.fn({
|
|
effects,
|
|
})
|
|
}
|
|
}
|
|
|
|
export function setupUninstall<Manifest extends T.Manifest, Store>(
|
|
fn: UninstallFn<Manifest, Store>,
|
|
) {
|
|
return Uninstall.of(fn)
|
|
}
|