// eslint-disable-next-line import/no-restricted-paths -- Needed to print log messages import { LogService } from "../platform/abstractions/log.service"; // eslint-disable-next-line import/no-restricted-paths -- Needed to interface with storage locations import { AbstractStorageService } from "../platform/abstractions/storage.service"; export class MigrationHelper { constructor( public currentVersion: number, private storageService: AbstractStorageService, public logService: LogService ) {} get(key: string): Promise { return this.storageService.get(key); } set(key: string, value: T): Promise { this.logService.info(`Setting ${key}`); return this.storageService.save(key, value); } info(message: string): void { this.logService.info(message); } async getAccounts(): Promise< { userId: string; account: ExpectedAccountType }[] > { const userIds = (await this.get("authenticatedAccounts")) ?? []; return Promise.all( userIds.map(async (userId) => ({ userId, account: await this.get(userId), })) ); } }