@sandbox-engine/sdk 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +25 -1
- package/dist/index.d.ts +25 -1
- package/dist/index.js +32 -1
- package/dist/index.mjs +32 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -31,6 +31,11 @@ interface SandboxOptions {
|
|
|
31
31
|
dockerfile?: string;
|
|
32
32
|
timeout?: number;
|
|
33
33
|
}
|
|
34
|
+
interface ProxyEnvResult {
|
|
35
|
+
proxyBase: string;
|
|
36
|
+
expiresAt: string;
|
|
37
|
+
env: Record<string, string>;
|
|
38
|
+
}
|
|
34
39
|
interface ExecOptions {
|
|
35
40
|
args?: string[];
|
|
36
41
|
cwd?: string;
|
|
@@ -49,6 +54,18 @@ interface FileEntry {
|
|
|
49
54
|
isDirectory: boolean;
|
|
50
55
|
isFile: boolean;
|
|
51
56
|
}
|
|
57
|
+
interface FileWriteEntry {
|
|
58
|
+
path: string;
|
|
59
|
+
content: string;
|
|
60
|
+
encoding?: BufferEncoding;
|
|
61
|
+
}
|
|
62
|
+
interface FileWriteManyResult {
|
|
63
|
+
results: Array<{
|
|
64
|
+
path: string;
|
|
65
|
+
success: boolean;
|
|
66
|
+
error?: string;
|
|
67
|
+
}>;
|
|
68
|
+
}
|
|
52
69
|
interface PortMapping {
|
|
53
70
|
containerPort: number;
|
|
54
71
|
hostPort: number;
|
|
@@ -70,6 +87,8 @@ declare class Filesystem {
|
|
|
70
87
|
read(filePath: string): Promise<string>;
|
|
71
88
|
write(filePath: string, content: string): Promise<void>;
|
|
72
89
|
list(dirPath: string): Promise<FileEntry[]>;
|
|
90
|
+
writeMany(files: FileWriteEntry[]): Promise<FileWriteManyResult>;
|
|
91
|
+
rename(oldPath: string, newPath: string): Promise<void>;
|
|
73
92
|
delete(filePath: string): Promise<void>;
|
|
74
93
|
}
|
|
75
94
|
|
|
@@ -108,11 +127,16 @@ declare class Sandbox {
|
|
|
108
127
|
stream: true;
|
|
109
128
|
}): Promise<Process>;
|
|
110
129
|
terminal(): Promise<Terminal>;
|
|
130
|
+
readonly secrets: {
|
|
131
|
+
getProxyEnv: (secretNames: string[]) => Promise<ProxyEnvResult>;
|
|
132
|
+
};
|
|
111
133
|
readonly ports: {
|
|
112
134
|
list: () => Promise<PortMapping[]>;
|
|
135
|
+
expose: (containerPort: number) => Promise<void>;
|
|
136
|
+
unexpose: (containerPort: number) => Promise<void>;
|
|
113
137
|
};
|
|
114
138
|
info(): Promise<SandboxApiResponse>;
|
|
115
139
|
close(): Promise<void>;
|
|
116
140
|
}
|
|
117
141
|
|
|
118
|
-
export { type ExecOptions, type ExecResult, type FileEntry, Filesystem, type PortMapping, Process, Sandbox, type SandboxOptions, Terminal, type WsMessage, type WsMessageType };
|
|
142
|
+
export { type ExecOptions, type ExecResult, type FileEntry, type FileWriteEntry, type FileWriteManyResult, Filesystem, type PortMapping, Process, type ProxyEnvResult, Sandbox, type SandboxOptions, Terminal, type WsMessage, type WsMessageType };
|
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,11 @@ interface SandboxOptions {
|
|
|
31
31
|
dockerfile?: string;
|
|
32
32
|
timeout?: number;
|
|
33
33
|
}
|
|
34
|
+
interface ProxyEnvResult {
|
|
35
|
+
proxyBase: string;
|
|
36
|
+
expiresAt: string;
|
|
37
|
+
env: Record<string, string>;
|
|
38
|
+
}
|
|
34
39
|
interface ExecOptions {
|
|
35
40
|
args?: string[];
|
|
36
41
|
cwd?: string;
|
|
@@ -49,6 +54,18 @@ interface FileEntry {
|
|
|
49
54
|
isDirectory: boolean;
|
|
50
55
|
isFile: boolean;
|
|
51
56
|
}
|
|
57
|
+
interface FileWriteEntry {
|
|
58
|
+
path: string;
|
|
59
|
+
content: string;
|
|
60
|
+
encoding?: BufferEncoding;
|
|
61
|
+
}
|
|
62
|
+
interface FileWriteManyResult {
|
|
63
|
+
results: Array<{
|
|
64
|
+
path: string;
|
|
65
|
+
success: boolean;
|
|
66
|
+
error?: string;
|
|
67
|
+
}>;
|
|
68
|
+
}
|
|
52
69
|
interface PortMapping {
|
|
53
70
|
containerPort: number;
|
|
54
71
|
hostPort: number;
|
|
@@ -70,6 +87,8 @@ declare class Filesystem {
|
|
|
70
87
|
read(filePath: string): Promise<string>;
|
|
71
88
|
write(filePath: string, content: string): Promise<void>;
|
|
72
89
|
list(dirPath: string): Promise<FileEntry[]>;
|
|
90
|
+
writeMany(files: FileWriteEntry[]): Promise<FileWriteManyResult>;
|
|
91
|
+
rename(oldPath: string, newPath: string): Promise<void>;
|
|
73
92
|
delete(filePath: string): Promise<void>;
|
|
74
93
|
}
|
|
75
94
|
|
|
@@ -108,11 +127,16 @@ declare class Sandbox {
|
|
|
108
127
|
stream: true;
|
|
109
128
|
}): Promise<Process>;
|
|
110
129
|
terminal(): Promise<Terminal>;
|
|
130
|
+
readonly secrets: {
|
|
131
|
+
getProxyEnv: (secretNames: string[]) => Promise<ProxyEnvResult>;
|
|
132
|
+
};
|
|
111
133
|
readonly ports: {
|
|
112
134
|
list: () => Promise<PortMapping[]>;
|
|
135
|
+
expose: (containerPort: number) => Promise<void>;
|
|
136
|
+
unexpose: (containerPort: number) => Promise<void>;
|
|
113
137
|
};
|
|
114
138
|
info(): Promise<SandboxApiResponse>;
|
|
115
139
|
close(): Promise<void>;
|
|
116
140
|
}
|
|
117
141
|
|
|
118
|
-
export { type ExecOptions, type ExecResult, type FileEntry, Filesystem, type PortMapping, Process, Sandbox, type SandboxOptions, Terminal, type WsMessage, type WsMessageType };
|
|
142
|
+
export { type ExecOptions, type ExecResult, type FileEntry, type FileWriteEntry, type FileWriteManyResult, Filesystem, type PortMapping, Process, type ProxyEnvResult, Sandbox, type SandboxOptions, Terminal, type WsMessage, type WsMessageType };
|
package/dist/index.js
CHANGED
|
@@ -126,6 +126,18 @@ var Filesystem = class {
|
|
|
126
126
|
);
|
|
127
127
|
return res.files;
|
|
128
128
|
}
|
|
129
|
+
async writeMany(files) {
|
|
130
|
+
return this.client.post(
|
|
131
|
+
`/api/sandboxes/${this.sandboxId}/files/batch`,
|
|
132
|
+
{ files }
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
async rename(oldPath, newPath) {
|
|
136
|
+
await this.client.post(`/api/sandboxes/${this.sandboxId}/files/rename`, {
|
|
137
|
+
from: oldPath,
|
|
138
|
+
to: newPath
|
|
139
|
+
});
|
|
140
|
+
}
|
|
129
141
|
async delete(filePath) {
|
|
130
142
|
await this.client.delete(`/api/sandboxes/${this.sandboxId}/files`, { path: filePath });
|
|
131
143
|
}
|
|
@@ -246,7 +258,8 @@ var Sandbox = class _Sandbox {
|
|
|
246
258
|
type: "input",
|
|
247
259
|
cmd,
|
|
248
260
|
args,
|
|
249
|
-
cwd
|
|
261
|
+
cwd,
|
|
262
|
+
env
|
|
250
263
|
};
|
|
251
264
|
ws.send(JSON.stringify(req));
|
|
252
265
|
resolve();
|
|
@@ -271,12 +284,30 @@ var Sandbox = class _Sandbox {
|
|
|
271
284
|
});
|
|
272
285
|
return new Terminal(ws);
|
|
273
286
|
}
|
|
287
|
+
secrets = {
|
|
288
|
+
getProxyEnv: async (secretNames) => {
|
|
289
|
+
return this.client.post(`/api/sandboxes/${this.id}/proxy-env`, {
|
|
290
|
+
secrets: secretNames
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
};
|
|
274
294
|
ports = {
|
|
275
295
|
list: async () => {
|
|
276
296
|
const res = await this.client.get(
|
|
277
297
|
`/api/sandboxes/${this.id}/ports`
|
|
278
298
|
);
|
|
279
299
|
return res.ports;
|
|
300
|
+
},
|
|
301
|
+
expose: async (containerPort) => {
|
|
302
|
+
await this.client.post(
|
|
303
|
+
`/api/sandboxes/${this.id}/ports/${containerPort}/expose`,
|
|
304
|
+
{}
|
|
305
|
+
);
|
|
306
|
+
},
|
|
307
|
+
unexpose: async (containerPort) => {
|
|
308
|
+
await this.client.delete(
|
|
309
|
+
`/api/sandboxes/${this.id}/ports/${containerPort}/expose`
|
|
310
|
+
);
|
|
280
311
|
}
|
|
281
312
|
};
|
|
282
313
|
async info() {
|
package/dist/index.mjs
CHANGED
|
@@ -87,6 +87,18 @@ var Filesystem = class {
|
|
|
87
87
|
);
|
|
88
88
|
return res.files;
|
|
89
89
|
}
|
|
90
|
+
async writeMany(files) {
|
|
91
|
+
return this.client.post(
|
|
92
|
+
`/api/sandboxes/${this.sandboxId}/files/batch`,
|
|
93
|
+
{ files }
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
async rename(oldPath, newPath) {
|
|
97
|
+
await this.client.post(`/api/sandboxes/${this.sandboxId}/files/rename`, {
|
|
98
|
+
from: oldPath,
|
|
99
|
+
to: newPath
|
|
100
|
+
});
|
|
101
|
+
}
|
|
90
102
|
async delete(filePath) {
|
|
91
103
|
await this.client.delete(`/api/sandboxes/${this.sandboxId}/files`, { path: filePath });
|
|
92
104
|
}
|
|
@@ -207,7 +219,8 @@ var Sandbox = class _Sandbox {
|
|
|
207
219
|
type: "input",
|
|
208
220
|
cmd,
|
|
209
221
|
args,
|
|
210
|
-
cwd
|
|
222
|
+
cwd,
|
|
223
|
+
env
|
|
211
224
|
};
|
|
212
225
|
ws.send(JSON.stringify(req));
|
|
213
226
|
resolve();
|
|
@@ -232,12 +245,30 @@ var Sandbox = class _Sandbox {
|
|
|
232
245
|
});
|
|
233
246
|
return new Terminal(ws);
|
|
234
247
|
}
|
|
248
|
+
secrets = {
|
|
249
|
+
getProxyEnv: async (secretNames) => {
|
|
250
|
+
return this.client.post(`/api/sandboxes/${this.id}/proxy-env`, {
|
|
251
|
+
secrets: secretNames
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
};
|
|
235
255
|
ports = {
|
|
236
256
|
list: async () => {
|
|
237
257
|
const res = await this.client.get(
|
|
238
258
|
`/api/sandboxes/${this.id}/ports`
|
|
239
259
|
);
|
|
240
260
|
return res.ports;
|
|
261
|
+
},
|
|
262
|
+
expose: async (containerPort) => {
|
|
263
|
+
await this.client.post(
|
|
264
|
+
`/api/sandboxes/${this.id}/ports/${containerPort}/expose`,
|
|
265
|
+
{}
|
|
266
|
+
);
|
|
267
|
+
},
|
|
268
|
+
unexpose: async (containerPort) => {
|
|
269
|
+
await this.client.delete(
|
|
270
|
+
`/api/sandboxes/${this.id}/ports/${containerPort}/expose`
|
|
271
|
+
);
|
|
241
272
|
}
|
|
242
273
|
};
|
|
243
274
|
async info() {
|
package/package.json
CHANGED