forked from toeverything/AFFiNE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
137 lines (124 loc) · 4.87 KB
/
index.d.ts
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/* auto-generated by NAPI-RS */
/* eslint-disable */
export declare class DocStoragePool {
constructor()
/** Initialize the database and run migrations. */
connect(universalId: string, path: string): Promise<void>
disconnect(universalId: string): Promise<void>
setSpaceId(universalId: string, spaceId: string): Promise<void>
pushUpdate(universalId: string, docId: string, update: Uint8Array): Promise<Date>
getDocSnapshot(universalId: string, docId: string): Promise<DocRecord | null>
setDocSnapshot(universalId: string, snapshot: DocRecord): Promise<boolean>
getDocUpdates(universalId: string, docId: string): Promise<Array<DocUpdate>>
markUpdatesMerged(universalId: string, docId: string, updates: Array<Date>): Promise<number>
deleteDoc(universalId: string, docId: string): Promise<void>
getDocClocks(universalId: string, after?: Date | undefined | null): Promise<Array<DocClock>>
getDocClock(universalId: string, docId: string): Promise<DocClock | null>
getBlob(universalId: string, key: string): Promise<Blob | null>
setBlob(universalId: string, blob: SetBlob): Promise<void>
deleteBlob(universalId: string, key: string, permanently: boolean): Promise<void>
releaseBlobs(universalId: string): Promise<void>
listBlobs(universalId: string): Promise<Array<ListedBlob>>
getPeerRemoteClocks(universalId: string, peer: string): Promise<Array<DocClock>>
getPeerRemoteClock(universalId: string, peer: string, docId: string): Promise<DocClock | null>
setPeerRemoteClock(universalId: string, peer: string, docId: string, clock: Date): Promise<void>
getPeerPulledRemoteClocks(universalId: string, peer: string): Promise<Array<DocClock>>
getPeerPulledRemoteClock(universalId: string, peer: string, docId: string): Promise<DocClock | null>
setPeerPulledRemoteClock(universalId: string, peer: string, docId: string, clock: Date): Promise<void>
getPeerPushedClocks(universalId: string, peer: string): Promise<Array<DocClock>>
getPeerPushedClock(universalId: string, peer: string, docId: string): Promise<DocClock | null>
setPeerPushedClock(universalId: string, peer: string, docId: string, clock: Date): Promise<void>
clearClocks(universalId: string): Promise<void>
}
export declare class SqliteConnection {
constructor(path: string)
connect(): Promise<void>
addBlob(key: string, blob: Uint8Array): Promise<void>
getBlob(key: string): Promise<BlobRow | null>
deleteBlob(key: string): Promise<void>
getBlobKeys(): Promise<Array<string>>
getUpdates(docId?: string | undefined | null): Promise<Array<UpdateRow>>
deleteUpdates(docId?: string | undefined | null): Promise<void>
getUpdatesCount(docId?: string | undefined | null): Promise<number>
getAllUpdates(): Promise<Array<UpdateRow>>
insertUpdates(updates: Array<InsertRow>): Promise<void>
replaceUpdates(docId: string | undefined | null, updates: Array<InsertRow>): Promise<void>
getServerClock(key: string): Promise<BlobRow | null>
setServerClock(key: string, data: Uint8Array): Promise<void>
getServerClockKeys(): Promise<Array<string>>
clearServerClock(): Promise<void>
delServerClock(key: string): Promise<void>
getSyncMetadata(key: string): Promise<BlobRow | null>
setSyncMetadata(key: string, data: Uint8Array): Promise<void>
getSyncMetadataKeys(): Promise<Array<string>>
clearSyncMetadata(): Promise<void>
delSyncMetadata(key: string): Promise<void>
initVersion(): Promise<void>
setVersion(version: number): Promise<void>
getMaxVersion(): Promise<number>
close(): Promise<void>
get isClose(): boolean
static validate(path: string): Promise<ValidationResult>
migrateAddDocId(): Promise<void>
/**
* Flush the WAL file to the database file.
* See https://www.sqlite.org/pragma.html#pragma_wal_checkpoint:~:text=PRAGMA%20schema.wal_checkpoint%3B
*/
checkpoint(): Promise<void>
}
export interface Blob {
key: string
data: Uint8Array
mime: string
size: number
createdAt: Date
}
export interface BlobRow {
key: string
data: Buffer
timestamp: Date
}
export interface DocClock {
docId: string
timestamp: Date
}
export interface DocRecord {
docId: string
bin: Uint8Array
timestamp: Date
}
export interface DocUpdate {
docId: string
timestamp: Date
bin: Uint8Array
}
export interface InsertRow {
docId?: string
data: Uint8Array
}
export interface ListedBlob {
key: string
size: number
mime: string
createdAt: Date
}
export declare function mintChallengeResponse(resource: string, bits?: number | undefined | null): Promise<string>
export interface SetBlob {
key: string
data: Uint8Array
mime: string
}
export interface UpdateRow {
id: number
timestamp: Date
data: Buffer
docId?: string
}
export declare enum ValidationResult {
MissingTables = 0,
MissingDocIdColumn = 1,
MissingVersionColumn = 2,
GeneralError = 3,
Valid = 4
}
export declare function verifyChallengeResponse(response: string, bits: number, resource: string): Promise<boolean>