Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/conat/project/api/system.ts
5707 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
test: true,
32
exec: true,
33
34
signal: true,
35
36
// jupyter stateless API
37
jupyterExecute: true,
38
39
// jupyter kernel management
40
listJupyterKernels: true,
41
stopJupyterKernel: true,
42
};
43
44
export interface System {
45
// stop the api service
46
terminate: () => Promise<void>;
47
48
version: () => Promise<number>;
49
50
listing: (opts: {
51
path: string;
52
hidden?: boolean;
53
}) => Promise<DirectoryListingEntry[]>;
54
deleteFiles: (opts: { paths: string[] }) => Promise<void>;
55
moveFiles: (opts: { paths: string[]; dest: string }) => Promise<void>;
56
renameFile: (opts: { src: string; dest: string }) => Promise<void>;
57
realpath: (path: string) => Promise<string>;
58
canonicalPaths: (paths: string[]) => Promise<string[]>;
59
60
writeTextFileToProject: (opts: {
61
path: string;
62
content: string;
63
}) => Promise<void>;
64
readTextFileFromProject: (opts: { path: string }) => Promise<string>;
65
66
configuration: (
67
aspect: ConfigurationAspect,
68
no_cache?,
69
) => Promise<Configuration>;
70
71
ping: () => Promise<{ now: number }>;
72
73
test: () => Promise<{ project_id: string; server_time: number }>;
74
75
exec: (opts: ExecuteCodeOptions) => Promise<ExecuteCodeOutput>;
76
77
signal: (opts: {
78
signal: number;
79
pids?: number[];
80
pid?: number;
81
}) => Promise<void>;
82
83
jupyterExecute: (opts: ProjectJupyterApiOptions) => Promise<object[]>;
84
85
listJupyterKernels: () => Promise<
86
{ pid: number; connectionFile: string; kernel_name?: string }[]
87
>;
88
stopJupyterKernel: (opts: { pid: number }) => Promise<{ success: boolean }>;
89
}
90
91