mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-26 18:31:54 +00:00
29 lines
719 B
TypeScript
29 lines
719 B
TypeScript
import { Effects, ExpectedExports } from "../types"
|
|
import { Utils, utils } from "../util/utils"
|
|
|
|
export type UninstallFn<Store, Vault> = (opts: {
|
|
effects: Effects
|
|
utils: Utils<Store, Vault>
|
|
}) => Promise<void>
|
|
export class Uninstall<Store, Vault> {
|
|
private constructor(readonly fn: UninstallFn<Store, Vault>) {}
|
|
static of<Store, Vault>(fn: UninstallFn<Store, Vault>) {
|
|
return new Uninstall(fn)
|
|
}
|
|
|
|
async uninit({
|
|
effects,
|
|
nextVersion,
|
|
}: Parameters<ExpectedExports.uninit>[0]) {
|
|
if (!nextVersion)
|
|
await this.fn({
|
|
effects,
|
|
utils: utils(effects),
|
|
})
|
|
}
|
|
}
|
|
|
|
export function setupUninstall<Store, Vault>(fn: UninstallFn<Store, Vault>) {
|
|
return Uninstall.of(fn)
|
|
}
|