CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/client/project-collaborators.ts
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import * as message from "@cocalc/util/message";
7
import { AsyncCall } from "./client";
8
9
export class ProjectCollaborators {
10
private async_call: AsyncCall;
11
12
constructor(async_call: AsyncCall) {
13
this.async_call = async_call;
14
}
15
16
private async call(message: object): Promise<any> {
17
return await this.async_call({ message });
18
}
19
20
public async invite_noncloud(opts: {
21
project_id: string;
22
title: string;
23
link2proj: string;
24
replyto?: string;
25
replyto_name?: string;
26
to: string;
27
email: string; // body in HTML format
28
subject?: string;
29
}): Promise<any> {
30
return await this.call(message.invite_noncloud_collaborators(opts));
31
}
32
33
public async invite(opts: {
34
project_id: string;
35
account_id: string;
36
title?: string;
37
link2proj?: string;
38
replyto?: string;
39
replyto_name?: string;
40
email?: string;
41
subject?: string;
42
}): Promise<any> {
43
return await this.call(message.invite_collaborator(opts));
44
}
45
46
public async remove(opts: {
47
project_id: string;
48
account_id: string;
49
}): Promise<any> {
50
return await this.call(message.remove_collaborator(opts));
51
}
52
53
// Directly add one (or more) collaborators to (one or more) projects via
54
// a single API call. There is no invite process, etc.
55
public async add_collaborator(
56
opts:
57
| {
58
project_id: string;
59
account_id: string;
60
}
61
| {
62
token_id: string;
63
account_id: string;
64
}
65
| { project_id: string[]; account_id: string[] } // for adding more than one at once
66
| { account_id: string[]; token_id: string[] } // for adding more than one at once
67
): Promise<{ event: "error" | "ok"; project_id?: string | string[] }> {
68
// project_id is a single string or an array of project id's in case of a token.
69
return await this.call(message.add_collaborator(opts));
70
}
71
}
72
73