export interface DriveLsEntry { path: string type: "dir" | "file" lastmod: number blob: string | null size: number | null author: string } export interface DriveTreeNode { path: string name: string type: "dir" | "file" lastmod: number blob: string | null size: number | null author: string children?: DriveTreeNode[] // Only for directories } export interface DriveTreeResponse { root: DriveTreeNode[] } // Base interface for all log entries with common fields export interface DriveLogEntryBase { timestamp: number revision: number // Changed from log_id to match Rust OperationHeader email: string } // Specific log entry types based on Rust OperationData variants export interface DriveLogEntryCreateFile extends DriveLogEntryBase { action: "create_file" path: string blob_id: string size: number } export interface DriveLogEntryCreateDir extends DriveLogEntryBase { action: "create_dir" path: string } export interface DriveLogEntryRemove extends DriveLogEntryBase { action: "remove" path: string } export interface DriveLogEntryRename extends DriveLogEntryBase { action: "rename" old_path: string new_path: string } // Discriminated union of all possible log entry types export type DriveLogEntry = | DriveLogEntryCreateFile | DriveLogEntryCreateDir | DriveLogEntryRemove | DriveLogEntryRename // Type guards for working with discriminated unions export function isCreateFileEntry(entry: DriveLogEntry): entry is DriveLogEntryCreateFile { return entry.action === "create_file" } export function isCreateDirEntry(entry: DriveLogEntry): entry is DriveLogEntryCreateDir { return entry.action === "create_dir" } export function isRemoveEntry(entry: DriveLogEntry): entry is DriveLogEntryRemove { return entry.action === "remove" } export function isRenameEntry(entry: DriveLogEntry): entry is DriveLogEntryRename { return entry.action === "rename" }