export class TestDataVersion { private versions: Map = new Map(); private currentVersion: string = '1.0.0'; setCurrentVersion(version: string): void { this.currentVersion = version; } getCurrentVersion(): string { return this.currentVersion; } saveVersion(key: string, data: string): void { this.versions.set(`${this.currentVersion}-${key}`, data); } getVersion(key: string): string | undefined { return this.versions.get(`${this.currentVersion}-${key}`); } listVersions(): string[] { return Array.from(new Set(Array.from(this.versions.keys()).map(k => k.split('-')[0]))); } export(): string { return JSON.stringify({ currentVersion: this.currentVersion, versions: Object.fromEntries(this.versions) }, null, 2); } import(json: string): void { const imported = JSON.parse(json); this.currentVersion = imported.currentVersion; this.versions = new Map(Object.entries(imported.versions)); } }