Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/conat/hub/api/db.ts
1453 views
1
import { authFirst, requireAccount } from "./util";
2
3
export const db = {
4
userQuery: authFirst,
5
touch: authFirst,
6
getLegacyTimeTravelInfo: authFirst,
7
getLegacyTimeTravelPatches: authFirst,
8
fileUseTimes: authFirst,
9
removeBlobTtls: requireAccount,
10
};
11
12
export interface DB {
13
userQuery: (opts: {
14
project_id?: string;
15
account_id?: string;
16
query: any;
17
options?: any[];
18
}) => Promise<any>;
19
20
touch: (opts: {
21
account_id?: string;
22
project_id?: string;
23
path?: string;
24
action?: string;
25
}) => Promise<void>;
26
27
getLegacyTimeTravelInfo: (opts: {
28
account_id?: string;
29
project_id: string;
30
path: string;
31
}) => Promise<{ uuid: string; users?: string[] }>;
32
33
// returns JSON.stringify({patches:[patch0,patch1,...]})
34
getLegacyTimeTravelPatches: (opts: {
35
account_id?: string;
36
uuid: string;
37
// also, make this bigger:
38
timeout?: number;
39
}) => Promise<string>;
40
41
fileUseTimes: (opts: FileUseTimesOptions) => Promise<FileUseTimesResponse>;
42
43
removeBlobTtls: (opts: { uuids: string[] }) => Promise<void>;
44
}
45
46
export interface FileUseTimesOptions {
47
account_id?: string; // filled in automatically with user doing the request
48
project_id: string;
49
path: string;
50
target_account_id: string; // who the request is about (default: account_id)
51
limit?: number; // at most this many timestamps
52
access_times?: boolean; // (default:true) if true, include access times
53
edit_times?: boolean; // (default:false) if true, return edit times.
54
timeout?: number;
55
}
56
57
export interface FileUseTimesResponse {
58
target_account_id: string;
59
access_times?: number[];
60
edit_times?: (number | undefined)[];
61
}
62
63