import * as plugins from '../ts/plugins.js'; import { ProtocolV6DocumentMigration } from './v6_protocoldocumentmigration.js'; import { ProtocolV18ResourceLayoutMigration } from './v18_resourcelayoutmigration.js'; import { ProtocolV22ProjectFilesystemIdentityMigration } from './v22_projectfilesystemidentitymigration.js'; import { RuntimeConfigV23Migration } from './v23_runtimeconfig.js'; import { LegacyTerminalLayoutV24Migration } from './v24_legacyterminallayoutmigration.js'; import { ControllerIssuerIdentityV25Migration } from './v25_controllerissueridentitymigration.js'; import { ProtocolV27AccountIndependentModelMigration } from './v27_accountindependentmodelmigration.js'; import { SessionLayoutItemRefsV30Migration } from './v30_sessionlayoutitemrefsmigration.js'; import { ResourceAttachmentSetV31Migration } from './v31_resourceattachmentsetmigration.js'; import { ControllerLayoutV32Migration } from './v32_controllerlayoutmigration.js'; import type { IControllerIssuerIdentity } from '../ts/interfaces.identity.js'; interface IDocumentMigration { run(): Promise; } export class PostDatabaseDocumentMigrationRunner { private readonly migrations: IDocumentMigration[]; constructor(private readonly database: plugins.smartdata.SmartdataDb | undefined) { this.migrations = [ new RuntimeConfigV23Migration(this.database), new LegacyTerminalLayoutV24Migration(this.database), new ProtocolV27AccountIndependentModelMigration(this.database), new ProtocolV6DocumentMigration(this.database), new ProtocolV18ResourceLayoutMigration(this.database), // Last: each lifts the shape the migrations above normalize into. new SessionLayoutItemRefsV30Migration(this.database), // After v30: it merges exactly the per-project item-ref documents v30 produces. new ControllerLayoutV32Migration(this.database), new ResourceAttachmentSetV31Migration(this.database), ]; } public async run(): Promise { for (const migration of this.migrations) { await migration.run(); } } public async runProjectFilesystemIdentity(controllerIdArg: string): Promise { await new ProtocolV22ProjectFilesystemIdentityMigration( this.database, controllerIdArg, ).run(); } public async runControllerIssuerIdentity( dataRootDirectoryArg: string, ): Promise { return new ControllerIssuerIdentityV25Migration(this.database).run(dataRootDirectoryArg); } }