| 17 | |
| 18 | /** Unified sync backend interface */ |
| 19 | export interface ISyncBackend { |
| 20 | /** Backend type identifier */ |
| 21 | readonly type: SyncBackendType; |
| 22 | |
| 23 | /** Test if the backend is reachable and credentials are valid */ |
| 24 | testConnection(): Promise<boolean>; |
| 25 | |
| 26 | /** Ensure the remote directory structure exists */ |
| 27 | ensureDirectories(): Promise<void>; |
| 28 | |
| 29 | /** Upload data to a path */ |
| 30 | put(path: string, data: Uint8Array): Promise<void>; |
| 31 | |
| 32 | /** Download data from a path */ |
| 33 | get(path: string): Promise<Uint8Array>; |
| 34 | |
| 35 | /** Download data with progress reporting (optional — falls back to get() if not implemented) */ |
| 36 | getWithProgress?( |
| 37 | path: string, |
| 38 | onProgress?: (loaded: number, total: number) => void, |
| 39 | ): Promise<Uint8Array>; |
| 40 | |
| 41 | /** Upload a local file directly when the platform/backend supports native file transfer. */ |
| 42 | putFile?( |
| 43 | path: string, |
| 44 | localFilePath: string, |
| 45 | onProgress?: (loaded: number, total: number) => void, |
| 46 | ): Promise<void>; |
| 47 | |
| 48 | /** Download directly into a local file when the platform/backend supports native file transfer. */ |
| 49 | getFileToPath?( |
| 50 | path: string, |
| 51 | localFilePath: string, |
| 52 | onProgress?: (loaded: number, total: number) => void, |
| 53 | ): Promise<void>; |
| 54 | |
| 55 | /** Get JSON data from a path, returns null if not found */ |
| 56 | getJSON<T>(path: string): Promise<T | null>; |
| 57 | |
| 58 | /** Upload JSON data to a path */ |
| 59 | putJSON<T>(path: string, data: T): Promise<void>; |
| 60 | |
| 61 | /** List directory contents */ |
| 62 | listDir(path: string): Promise<RemoteFile[]>; |
| 63 | |
| 64 | /** Delete a file at the given path */ |
| 65 | delete(path: string): Promise<void>; |
| 66 | |
| 67 | /** Check if a file exists */ |
| 68 | exists(path: string): Promise<boolean>; |
| 69 | |
| 70 | /** |
| 71 | * Move/rename a file from `fromPath` to `toPath`. |
| 72 | * Implementations should create intermediate directories on the destination side. |
| 73 | * Should be atomic where the backend supports it; otherwise copy + delete. |
| 74 | * Throws if the source does not exist or if the destination already exists. |
| 75 | */ |
| 76 | move(fromPath: string, toPath: string): Promise<void>; |
no outgoing calls
no test coverage detected