Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/conat/hub/api/projects.ts
1712 views
1
import { authFirstRequireAccount } from "./util";
2
import { type CreateProjectOptions } from "@cocalc/util/db-schema/projects";
3
import { type UserCopyOptions } from "@cocalc/util/db-schema/projects";
4
5
export const projects = {
6
createProject: authFirstRequireAccount,
7
copyPathBetweenProjects: authFirstRequireAccount,
8
removeCollaborator: authFirstRequireAccount,
9
addCollaborator: authFirstRequireAccount,
10
inviteCollaborator: authFirstRequireAccount,
11
inviteCollaboratorWithoutAccount: authFirstRequireAccount,
12
setQuotas: authFirstRequireAccount,
13
start: authFirstRequireAccount,
14
stop: authFirstRequireAccount,
15
};
16
17
export type AddCollaborator =
18
| {
19
project_id: string;
20
account_id: string;
21
token_id?: undefined;
22
}
23
| {
24
token_id: string;
25
account_id: string;
26
project_id?: undefined;
27
}
28
| { project_id: string[]; account_id: string[]; token_id?: undefined } // for adding more than one at once
29
| { account_id: string[]; token_id: string[]; project_id?: undefined };
30
31
export interface Projects {
32
// request to have conat permissions to project subjects.
33
createProject: (opts: CreateProjectOptions) => Promise<string>;
34
35
copyPathBetweenProjects: (opts: UserCopyOptions) => Promise<void>;
36
37
removeCollaborator: ({
38
account_id,
39
opts,
40
}: {
41
account_id?: string;
42
opts: {
43
account_id;
44
project_id;
45
};
46
}) => Promise<void>;
47
48
addCollaborator: ({
49
account_id,
50
opts,
51
}: {
52
account_id?: string;
53
opts: AddCollaborator;
54
}) => Promise<{ project_id?: string | string[] }>;
55
56
inviteCollaborator: ({
57
account_id,
58
opts,
59
}: {
60
account_id?: string;
61
opts: {
62
project_id: string;
63
account_id: string;
64
title?: string;
65
link2proj?: string;
66
replyto?: string;
67
replyto_name?: string;
68
email?: string;
69
subject?: string;
70
};
71
}) => Promise<void>;
72
73
inviteCollaboratorWithoutAccount: ({
74
account_id,
75
opts,
76
}: {
77
account_id?: string;
78
opts: {
79
project_id: string;
80
title: string;
81
link2proj: string;
82
replyto?: string;
83
replyto_name?: string;
84
to: string;
85
email: string; // body in HTML format
86
subject?: string;
87
};
88
}) => Promise<void>;
89
90
setQuotas: (opts: {
91
account_id?: string;
92
project_id: string;
93
memory?: number;
94
memory_request?: number;
95
cpu_shares?: number;
96
cores?: number;
97
disk_quota?: number;
98
mintime?: number;
99
network?: number;
100
member_host?: number;
101
always_running?: number;
102
}) => Promise<void>;
103
104
start: (opts: { account_id: string; project_id: string }) => Promise<void>;
105
stop: (opts: { account_id: string; project_id: string }) => Promise<void>;
106
}
107
108