Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/conat/hub/api/projects.ts
5751 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
import { type UserGroup } from "@cocalc/util/project-ownership";
5
import {
6
type ProjectState,
7
type ProjectStatus,
8
} from "@cocalc/util/db-schema/projects";
9
10
export const projects = {
11
createProject: authFirstRequireAccount,
12
copyPathBetweenProjects: authFirstRequireAccount,
13
removeCollaborator: authFirstRequireAccount,
14
addCollaborator: authFirstRequireAccount,
15
inviteCollaborator: authFirstRequireAccount,
16
inviteCollaboratorWithoutAccount: authFirstRequireAccount,
17
changeUserType: authFirstRequireAccount,
18
setQuotas: authFirstRequireAccount,
19
start: authFirstRequireAccount,
20
stop: authFirstRequireAccount,
21
deleteProject: authFirstRequireAccount,
22
touch: authFirstRequireAccount,
23
state: authFirstRequireAccount,
24
status: authFirstRequireAccount,
25
};
26
27
export type AddCollaborator =
28
| {
29
project_id: string;
30
account_id: string;
31
token_id?: undefined;
32
}
33
| {
34
token_id: string;
35
account_id: string;
36
project_id?: undefined;
37
}
38
| { project_id: string[]; account_id: string[]; token_id?: undefined } // for adding more than one at once
39
| { account_id: string[]; token_id: string[]; project_id?: undefined };
40
41
export interface Projects {
42
// request to have conat permissions to project subjects.
43
createProject: (opts: CreateProjectOptions) => Promise<string>;
44
45
copyPathBetweenProjects: (opts: UserCopyOptions) => Promise<void>;
46
47
removeCollaborator: ({
48
account_id,
49
opts,
50
}: {
51
account_id?: string;
52
opts: {
53
account_id;
54
project_id;
55
};
56
}) => Promise<void>;
57
58
addCollaborator: ({
59
account_id,
60
opts,
61
}: {
62
account_id?: string;
63
opts: AddCollaborator;
64
}) => Promise<{ project_id?: string | string[] }>;
65
66
inviteCollaborator: ({
67
account_id,
68
opts,
69
}: {
70
account_id?: string;
71
opts: {
72
project_id: string;
73
account_id: string;
74
title?: string;
75
link2proj?: string;
76
replyto?: string;
77
replyto_name?: string;
78
email?: string;
79
subject?: string;
80
};
81
}) => Promise<void>;
82
83
inviteCollaboratorWithoutAccount: ({
84
account_id,
85
opts,
86
}: {
87
account_id?: string;
88
opts: {
89
project_id: string;
90
title: string;
91
link2proj: string;
92
replyto?: string;
93
replyto_name?: string;
94
to: string;
95
email: string; // body in HTML format
96
subject?: string;
97
};
98
}) => Promise<void>;
99
100
changeUserType: ({
101
account_id,
102
opts,
103
}: {
104
account_id?: string;
105
opts: {
106
project_id: string;
107
target_account_id: string;
108
new_group: UserGroup;
109
};
110
}) => Promise<void>;
111
112
setQuotas: (opts: {
113
account_id?: string;
114
project_id: string;
115
memory?: number;
116
memory_request?: number;
117
cpu_shares?: number;
118
cores?: number;
119
disk_quota?: number;
120
mintime?: number;
121
network?: number;
122
member_host?: number;
123
always_running?: number;
124
}) => Promise<void>;
125
126
start: (opts: { account_id: string; project_id: string }) => Promise<void>;
127
stop: (opts: { account_id: string; project_id: string }) => Promise<void>;
128
deleteProject: (opts: {
129
account_id: string;
130
project_id: string;
131
}) => Promise<void>;
132
133
touch: (opts: { account_id: string; project_id: string }) => Promise<void>;
134
state: (opts: {
135
account_id: string;
136
project_id: string;
137
}) => Promise<ProjectState>;
138
status: (opts: {
139
account_id: string;
140
project_id: string;
141
}) => Promise<ProjectStatus>;
142
}
143
144