doc: update interface

This commit is contained in:
criyle 2024-02-06 12:57:36 +00:00
parent 581b925450
commit 39b603575b
2 changed files with 62 additions and 2 deletions

View File

@ -56,12 +56,20 @@ interface Symlink {
symlink: string; // 符号连接目标 (v1.6.0+)
}
interface StreamIn {
streamIn: boolean; // 流式输入 (v1.8.1+)
}
interface StreamOut {
streamOut: boolean; // 流式输出 (v1.8.1+)
}
interface Cmd {
args: string[]; // 程序命令行参数
env?: string[]; // 程序环境变量
// 指定 标准输入、标准输出和标准错误的文件
files?: (LocalFile | MemoryFile | PreparedFile | Collector)[];
files?: (LocalFile | MemoryFile | PreparedFile | Collector | StreamIn | StreamOut)[];
tty?: boolean; // 开启 TTY (需要保证标准输出和标准错误为同一文件)同时需要指定 TERM 环境变量 (例如 TERM=xterm
// 资源限制
@ -167,6 +175,28 @@ interface WSResult {
results: Result[];
error?: string;
}
// 流式请求 / 响应
interface Resize {
index: number;
fd: number;
rows: number;
cols: number;
x: number;
y: number;
}
interface Input {
index: number;
fd: number;
content: Buffer;
}
interface Output {
index: number;
fd: number;
content: Buffer;
}
```
### 示例

View File

@ -57,12 +57,20 @@ interface Symlink {
symlink: string; // symlink destination (v1.6.0+)
}
interface StreamIn {
streamIn: boolean; // stream input (v1.8.1+)
}
interface StreamOut {
streamOut: boolean; // stream output (v1.8.1+)
}
interface Cmd {
args: string[]; // command line argument
env?: string[]; // environment
// specifies file input / pipe collector for program file descriptors
files?: (LocalFile | MemoryFile | PreparedFile | Collector)[];
files?: (LocalFile | MemoryFile | PreparedFile | Collector | StreamIn | StreamOut)[];
tty?: boolean; // enables tty on the input and output pipes (should have just one input & one output)
// Notice: must have TERM environment variables (e.g. TERM=xterm)
@ -173,6 +181,28 @@ interface WSResult {
results: Result[];
error?: string;
}
// Stream request & responses
interface Resize {
index: number;
fd: number;
rows: number;
cols: number;
x: number;
y: number;
}
interface Input {
index: number;
fd: number;
content: Buffer;
}
interface Output {
index: number;
fd: number;
content: Buffer;
}
```
### Example Request & Response