chore: Remove the utils

This commit is contained in:
J H
2024-03-18 14:31:01 -06:00
parent 8e2dc8b3ee
commit 5f40fd6038
28 changed files with 424 additions and 543 deletions

View File

@@ -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 })
}
}
}