Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/conat/project/api/system.ts
1453 views
1
import type {
2
ExecuteCodeOutput,
3
ExecuteCodeOptions,
4
} from "@cocalc/util/types/execute-code";
5
import type { DirectoryListingEntry } from "@cocalc/util/types";
6
import type {
7
Configuration,
8
ConfigurationAspect,
9
} from "@cocalc/comm/project-configuration";
10
import { type ProjectJupyterApiOptions } from "@cocalc/util/jupyter/api-types";
11
12
export const system = {
13
terminate: true,
14
15
version: true,
16
17
listing: true,
18
deleteFiles: true,
19
moveFiles: true,
20
renameFile: true,
21
realpath: true,
22
canonicalPaths: true,
23
24
// these should be deprecated -- the new streaming writeFile and readFile in conat/files are better.
25
writeTextFileToProject: true,
26
readTextFileFromProject: true,
27
28
configuration: true,
29
30
ping: true,
31
exec: true,
32
33
signal: true,
34
35
// jupyter stateless API
36
jupyterExecute: true,
37
};
38
39
export interface System {
40
// stop the api service
41
terminate: () => Promise<void>;
42
43
version: () => Promise<number>;
44
45
listing: (opts: {
46
path: string;
47
hidden?: boolean;
48
}) => Promise<DirectoryListingEntry[]>;
49
deleteFiles: (opts: { paths: string[] }) => Promise<void>;
50
moveFiles: (opts: { paths: string[]; dest: string }) => Promise<void>;
51
renameFile: (opts: { src: string; dest: string }) => Promise<void>;
52
realpath: (path: string) => Promise<string>;
53
canonicalPaths: (paths: string[]) => Promise<string[]>;
54
55
writeTextFileToProject: (opts: {
56
path: string;
57
content: string;
58
}) => Promise<void>;
59
readTextFileFromProject: (opts: { path: string }) => Promise<string>;
60
61
configuration: (
62
aspect: ConfigurationAspect,
63
no_cache?,
64
) => Promise<Configuration>;
65
66
ping: () => Promise<{ now: number }>;
67
68
exec: (opts: ExecuteCodeOptions) => Promise<ExecuteCodeOutput>;
69
70
signal: (opts: {
71
signal: number;
72
pids?: number[];
73
pid?: number;
74
}) => Promise<void>;
75
76
jupyterExecute: (opts: ProjectJupyterApiOptions) => Promise<object[]>;
77
}
78
79