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