Path: blob/master/src/packages/conat/hub/api/projects.ts
5751 views
import { authFirstRequireAccount } from "./util";1import { type CreateProjectOptions } from "@cocalc/util/db-schema/projects";2import { type UserCopyOptions } from "@cocalc/util/db-schema/projects";3import { type UserGroup } from "@cocalc/util/project-ownership";4import {5type ProjectState,6type ProjectStatus,7} from "@cocalc/util/db-schema/projects";89export const projects = {10createProject: authFirstRequireAccount,11copyPathBetweenProjects: authFirstRequireAccount,12removeCollaborator: authFirstRequireAccount,13addCollaborator: authFirstRequireAccount,14inviteCollaborator: authFirstRequireAccount,15inviteCollaboratorWithoutAccount: authFirstRequireAccount,16changeUserType: authFirstRequireAccount,17setQuotas: authFirstRequireAccount,18start: authFirstRequireAccount,19stop: authFirstRequireAccount,20deleteProject: authFirstRequireAccount,21touch: authFirstRequireAccount,22state: authFirstRequireAccount,23status: authFirstRequireAccount,24};2526export type AddCollaborator =27| {28project_id: string;29account_id: string;30token_id?: undefined;31}32| {33token_id: string;34account_id: string;35project_id?: undefined;36}37| { project_id: string[]; account_id: string[]; token_id?: undefined } // for adding more than one at once38| { account_id: string[]; token_id: string[]; project_id?: undefined };3940export interface Projects {41// request to have conat permissions to project subjects.42createProject: (opts: CreateProjectOptions) => Promise<string>;4344copyPathBetweenProjects: (opts: UserCopyOptions) => Promise<void>;4546removeCollaborator: ({47account_id,48opts,49}: {50account_id?: string;51opts: {52account_id;53project_id;54};55}) => Promise<void>;5657addCollaborator: ({58account_id,59opts,60}: {61account_id?: string;62opts: AddCollaborator;63}) => Promise<{ project_id?: string | string[] }>;6465inviteCollaborator: ({66account_id,67opts,68}: {69account_id?: string;70opts: {71project_id: string;72account_id: string;73title?: string;74link2proj?: string;75replyto?: string;76replyto_name?: string;77email?: string;78subject?: string;79};80}) => Promise<void>;8182inviteCollaboratorWithoutAccount: ({83account_id,84opts,85}: {86account_id?: string;87opts: {88project_id: string;89title: string;90link2proj: string;91replyto?: string;92replyto_name?: string;93to: string;94email: string; // body in HTML format95subject?: string;96};97}) => Promise<void>;9899changeUserType: ({100account_id,101opts,102}: {103account_id?: string;104opts: {105project_id: string;106target_account_id: string;107new_group: UserGroup;108};109}) => Promise<void>;110111setQuotas: (opts: {112account_id?: string;113project_id: string;114memory?: number;115memory_request?: number;116cpu_shares?: number;117cores?: number;118disk_quota?: number;119mintime?: number;120network?: number;121member_host?: number;122always_running?: number;123}) => Promise<void>;124125start: (opts: { account_id: string; project_id: string }) => Promise<void>;126stop: (opts: { account_id: string; project_id: string }) => Promise<void>;127deleteProject: (opts: {128account_id: string;129project_id: string;130}) => Promise<void>;131132touch: (opts: { account_id: string; project_id: string }) => Promise<void>;133state: (opts: {134account_id: string;135project_id: string;136}) => Promise<ProjectState>;137status: (opts: {138account_id: string;139project_id: string;140}) => Promise<ProjectStatus>;141}142143144