blob: a168a725aa13563b040cd86455b83309614c0f14 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
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"
}
|