Path: blob/master/src/packages/conat/project/api/index.ts
1453 views
import { type System, system } from "./system";1import { type Editor, editor } from "./editor";2import { type Sync, sync } from "./sync";3import { handleErrorMessage } from "@cocalc/conat/util";45export interface ProjectApi {6system: System;7editor: Editor;8sync: Sync;9}1011const ProjectApiStructure = {12system,13editor,14sync,15} as const;1617export function initProjectApi(callProjectApi): ProjectApi {18const projectApi: any = {};19for (const group in ProjectApiStructure) {20if (projectApi[group] == null) {21projectApi[group] = {};22}23for (const functionName in ProjectApiStructure[group]) {24projectApi[group][functionName] = async (...args) =>25handleErrorMessage(26await callProjectApi({27name: `${group}.${functionName}`,28args,29}),30);31}32}33return projectApi as ProjectApi;34}353637