forked from sheepzh/time-tracker-4-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackup.d.ts
More file actions
116 lines (105 loc) · 2.65 KB
/
backup.d.ts
File metadata and controls
116 lines (105 loc) · 2.65 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/**
* @since 1.2.0
*/
declare namespace timer.backup {
type Client = {
id: string
name: string
minDate?: string
maxDate?: string
}
type LoginInfo = {
acc?: string
psw?: string
}
type Auth = {
token?: string
login?: LoginInfo
}
interface CoordinatorContext<Cache> {
cid: string
cname: string
type: timer.backup.Type
auth?: Auth
ext?: TypeExt
cache: Cache
handleCacheChanged: () => Promise<void>
}
/**
* timer.backup.Coordinator of data synchronizer
*/
interface Coordinator<Cache> {
/**
* Register for client
*/
updateClients(context: timer.backup.CoordinatorContext<Cache>, clients: Client[]): Promise<void>
/**
* List all clients
*/
listAllClients(context: timer.backup.CoordinatorContext<Cache>): Promise<Client[]>
/**
* Download fragmented data from cloud
*
* @param targetCid The client id, default value is the local one in context
*/
download(context: timer.backup.CoordinatorContext<Cache>, dateStart: Date, dateEnd: Date, targetCid?: string): Promise<timer.stat.RowBase[]>
/**
* Upload fragmented data to cloud
* @param rows
*/
upload(context: timer.backup.CoordinatorContext<Cache>, rows: timer.stat.RowBase[]): Promise<void>
/**
* Test auth
*
* @returns errorMsg or null/undefined
*/
testAuth(auth: Auth, ext: timer.backup.TypeExt): Promise<string>
/**
* Clear data
*/
clear(context: timer.backup.CoordinatorContext<Cache>, client: timer.backup.Client): Promise<void>
}
type Type =
| 'none'
| 'gist'
// Sync into Obsidian via its plugin Local REST API
// @since 1.9.4
| 'obsidian_local_rest_api'
// @since 2.4.5
| 'web_dav'
// @since 3.0.0
| 'quantified_resume'
type AuthType =
| 'token'
| 'password'
type TypeExt = {
/**
* The vault of obsidian
*
* @since 2.4.4
*/
bucket?: string
endpoint?: string
dirPath?: string
}
/**
* Snapshot of last backup
*/
type Snapshot = {
/**
* Timestamp
*/
ts: number
/**
* The date of the ts
*/
date: string
}
/**
* Snapshot cache
*/
type SnapshotCache = Partial<{
[type in Type]: Snapshot
}>
type MetaCache = Partial<Record<Type, unknown>>
}