import { FileDownloadProgress } from '../Types/FileDownloadProgress' import { FileBackupsMapping } from './FileBackupsMapping' type PlaintextNoteRecord = { tag?: string path: string } type UuidString = string export type PlaintextBackupsMapping = { version: string files: Record } export interface FileBackupsDevice extends FileBackupsMethods, LegacyBackupsMethods, PlaintextBackupsMethods, TextBackupsMethods { openLocation(path: string): Promise joinPaths(...paths: string[]): Promise /** * The reason we combine presenting a directory picker and transfering old files to the new location * in one function is so we don't have to expose a general `transferDirectories` function to the web app, * which would give it too much power. * @param appendPath The path to append to the selected directory. */ presentDirectoryPickerForLocationChangeAndTransferOld( appendPath: string, oldLocation?: string, ): Promise monitorPlaintextBackupsLocationForChanges(backupsDirectory: string): Promise } export type FileBackupReadToken = string export type FileBackupReadChunkResponse = { chunk: Uint8Array; isLast: boolean; progress: FileDownloadProgress } interface FileBackupsMethods { getFilesBackupsMappingFile(location: string): Promise saveFilesBackupsFile( location: string, uuid: string, metaFile: string, downloadRequest: { chunkSizes: number[] valetToken: string url: string }, ): Promise<'success' | 'failed'> getFileBackupReadToken(filePath: string): Promise readNextChunk(token: string): Promise } interface PlaintextBackupsMethods { getPlaintextBackupsMappingFile(location: string): Promise persistPlaintextBackupsMappingFile(location: string): Promise savePlaintextNoteBackup(location: string, uuid: string, name: string, tags: string[], data: string): Promise } interface TextBackupsMethods { getTextBackupsCount(location: string): Promise saveTextBackupData(location: string, data: string): Promise getUserDocumentsDirectory(): Promise } interface LegacyBackupsMethods { migrateLegacyFileBackupsToNewStructure(newPath: string): Promise isLegacyFilesBackupsEnabled(): Promise getLegacyFilesBackupsLocation(): Promise wasLegacyTextBackupsExplicitlyDisabled(): Promise getLegacyTextBackupsLocation(): Promise }