This repository has been archived by the owner on Sep 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
adb-api.d.ts
114 lines (91 loc) · 2.57 KB
/
adb-api.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
/*
id: atek.cloud/adb-api
type: api
title: Atek Database API
*/
export default interface AdbApi {
// Get metadata and information about a database.
describe (dbId: string): Promise<DbDescription>
// Register a table's schema and metadata.
table (dbId: string, tableId: string, desc: TableSettings): Promise<TableDescription>
// List records in a table.
list (dbId: string, tableId: string, opts?: ListOpts): Promise<{records: Record[]}>
// Get a record in a table.
get (dbId: string, tableId: string, key: string): Promise<Record>
// Add a record to a table.
create (dbId: string, tableId: string, value: object, blobs?: BlobMap): Promise<Record>
// Write a record to a table.
put (dbId: string, tableId: string, key: string, value: object): Promise<Record>
// Delete a record from a table.
delete (dbId: string, tableId: string, key: string): Promise<void>
// Enumerate the differences between two versions of the database.
diff (dbId: string, opts: {left: number, right?: number, tableIds?: string[]}): Promise<Diff[]>
// Get a blob of a record.
getBlob (dbId: string, tableId: string, key: string, blobName: string): Promise<Blob>
// Write a blob of a record.
putBlob (dbId: string, tableId: string, key: string, blobName: string, blobValue: BlobDesc): Promise<void>
// Delete a blob of a record.
delBlob (dbId: string, tableId: string, key: string, blobName: string): Promise<void>
// Listen for changes to a database.
subscribe (dbId: string, opts?: {tableIds?: string[]}): DbSubscription
}
export interface DbSubscription {
emit (name: 'change', evt: Diff)
}
export interface DbDescription {
dbId: string
dbType: string
displayName?: string
tables: TableDescription[]
}
export interface TableTemplates {
table?: {
title?: string
description?: string
},
record?: {
key?: string
title?: string
description?: string
}
}
export interface TableSettings {
revision?: number
templates?: TableTemplates
definition?: object
}
export interface TableDescription extends TableSettings {
tableId: string
}
export interface Record {
key: string
path: string
url: string
seq?: number
value: object
}
export interface BlobMap {
[blobName: string]: BlobDesc
}
export interface BlobDesc {
mimeType?: string
buf: Uint8Array
}
export interface Blob {
start: number
end: number
mimeType?: string
buf: Uint8Array
}
export interface Diff {
left: Record
right: Record
}
export interface ListOpts {
lt?: string
lte?: string
gt?: string
gte?: string
limit?: number
reverse?: boolean
}