@actually-colab/editor-client
Version:
API Client for Actually Colab's editor
79 lines (78 loc) • 3.1 kB
TypeScript
import type { DCell, DNotebookAccessLevel, DUser, Notebook, NotebookContents, Workshop } from '@actually-colab/editor-types';
export declare class ActuallyColabRESTClient {
private axiosInstance;
/**
* Initializes a new client wrapper for the Actually Colab API.
*
* @param baseURL Actually Colab API basename
*/
constructor(baseURL: string);
/**Sets the authorization header for all requests.
*
* @param sessionToken the actually colab token for the user
*/
setSessionToken: (sessionToken: string) => void;
private login;
/**
* Attempts to login. On success, stores the token.
*
* @param email the user's email address
* @param name optional, sets the name of the user
*/
devLogin: (email: DUser['email'], name?: string | undefined) => Promise<{
sessionToken: string;
user: DUser;
}>;
/**
* Attempts to login with Google ID Token. On success, stores the token.
*
* @param idToken from Google Auth
*/
loginWithGoogleIdToken: (idToken: string) => Promise<{
sessionToken: string;
user: DUser;
}>;
/**
* Attempts to refresh session token. On success, stores the token.
*
* @param sessionToken JWT from Actually Colab service
*/
refreshSessionToken: (sessionToken: string) => Promise<{
sessionToken: string;
user: DUser;
}>;
/**Fetches all notebooks that this user has access to. */
getNotebooksForUser: () => Promise<Notebook[]>;
/**
* Fetches cells and outputs for a specific notebook.
*
* @param nb_id id of the notebook to fetch
*/
getNotebookContents: (nb_id: Notebook['nb_id']) => Promise<NotebookContents>;
/**
* Creates the metadata for a new notebook.
*
* @param name human-readable name of the notebook
* @param language runtime language for the notebook
*/
createNotebook: (name: Notebook['name'], language?: Notebook['language'], cells?: Pick<DCell, "language" | "contents">[] | undefined) => Promise<Notebook>;
/**
* Shares a notebook with another user. The requesting user must have
* Full Access to share the notebook.
*
* @param email user to share with
* @param nb_id id of the notebook to share
* @param access_level permissions level for the user that the notebook is being shared with
*/
shareNotebook: (email: DUser['email'], nb_id: DNotebookAccessLevel['nb_id'], access_level: DNotebookAccessLevel['access_level']) => Promise<Notebook>;
/**
* Creates the metadata for a new workshop.
*
* @param name human-readable name of the workshop
* @param description human-readable description of the workshop
* @param cells cell contents to pre-insert
*/
createWorkshop: (name: Workshop['name'], description: Workshop['description'], cells?: Pick<DCell, "language" | "contents">[] | undefined) => Promise<Workshop>;
/**Fetches all workshops that this user has access to. */
getWorkshopsForUser: () => Promise<Workshop[]>;
}