@blaxel/core 0.2.43-preview.93 → 0.2.43
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/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/common/settings.js +2 -2
- package/dist/cjs/sandbox/filesystem/filesystem.js +12 -13
- package/dist/cjs/sandbox/sandbox.js +2 -2
- package/dist/cjs/types/sandbox/filesystem/filesystem.d.ts +6 -2
- package/dist/cjs-browser/.tsbuildinfo +1 -1
- package/dist/cjs-browser/common/settings.js +2 -2
- package/dist/cjs-browser/sandbox/filesystem/filesystem.js +12 -13
- package/dist/cjs-browser/sandbox/sandbox.js +2 -2
- package/dist/cjs-browser/types/sandbox/filesystem/filesystem.d.ts +6 -2
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/common/settings.js +2 -2
- package/dist/esm/sandbox/filesystem/filesystem.js +13 -14
- package/dist/esm/sandbox/sandbox.js +2 -2
- package/dist/esm-browser/.tsbuildinfo +1 -1
- package/dist/esm-browser/common/settings.js +2 -2
- package/dist/esm-browser/sandbox/filesystem/filesystem.js +13 -14
- package/dist/esm-browser/sandbox/sandbox.js +2 -2
- package/package.json +2 -2
|
@@ -5,8 +5,11 @@ const settings_js_1 = require("../../common/settings.js");
|
|
|
5
5
|
const action_js_1 = require("../action.js");
|
|
6
6
|
const index_js_1 = require("../client/index.js");
|
|
7
7
|
class SandboxFileSystem extends action_js_1.SandboxAction {
|
|
8
|
-
|
|
8
|
+
process;
|
|
9
|
+
constructor(sandbox, process) {
|
|
9
10
|
super(sandbox);
|
|
11
|
+
this.process = process;
|
|
12
|
+
this.process = process;
|
|
10
13
|
}
|
|
11
14
|
async mkdir(path, permissions = "0755") {
|
|
12
15
|
path = this.formatPath(path);
|
|
@@ -83,7 +86,7 @@ class SandboxFileSystem extends action_js_1.SandboxAction {
|
|
|
83
86
|
baseUrl: this.url,
|
|
84
87
|
client: this.client,
|
|
85
88
|
};
|
|
86
|
-
const path = destinationPath ?? "";
|
|
89
|
+
const path = this.formatPath(destinationPath ?? "");
|
|
87
90
|
const { response, data, error } = await this.client.put({
|
|
88
91
|
url: `/filesystem/tree/${path}`,
|
|
89
92
|
...options,
|
|
@@ -131,18 +134,14 @@ class SandboxFileSystem extends action_js_1.SandboxAction {
|
|
|
131
134
|
}
|
|
132
135
|
return data;
|
|
133
136
|
}
|
|
134
|
-
async cp(source, destination) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const process = {
|
|
138
|
-
command: `cp -r ${source} ${destination}`
|
|
139
|
-
};
|
|
140
|
-
const { response, data, error } = await (0, index_js_1.postProcess)({
|
|
141
|
-
body: process,
|
|
142
|
-
baseUrl: this.url,
|
|
143
|
-
client: this.client,
|
|
137
|
+
async cp(source, destination, { maxWait = 180000 } = {}) {
|
|
138
|
+
let process = await this.process.exec({
|
|
139
|
+
command: `cp -r ${source} ${destination}`,
|
|
144
140
|
});
|
|
145
|
-
this.
|
|
141
|
+
process = await this.process.wait(process.pid, { maxWait, interval: 100 });
|
|
142
|
+
if (process.status === "failed") {
|
|
143
|
+
throw new Error(`Could not copy ${source} to ${destination} cause: ${process.logs}`);
|
|
144
|
+
}
|
|
146
145
|
return {
|
|
147
146
|
message: "Files copied",
|
|
148
147
|
source,
|
|
@@ -20,9 +20,9 @@ class SandboxInstance {
|
|
|
20
20
|
sessions;
|
|
21
21
|
constructor(sandbox) {
|
|
22
22
|
this.sandbox = sandbox;
|
|
23
|
-
this.fs = new index_js_2.SandboxFileSystem(sandbox);
|
|
24
|
-
this.network = new index_js_3.SandboxNetwork(sandbox);
|
|
25
23
|
this.process = new index_js_4.SandboxProcess(sandbox);
|
|
24
|
+
this.fs = new index_js_2.SandboxFileSystem(sandbox, this.process);
|
|
25
|
+
this.network = new index_js_3.SandboxNetwork(sandbox);
|
|
26
26
|
this.previews = new preview_js_1.SandboxPreviews(sandbox);
|
|
27
27
|
this.sessions = new session_js_1.SandboxSessions(sandbox);
|
|
28
28
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Sandbox } from "../../client/types.gen.js";
|
|
2
2
|
import { SandboxAction } from "../action.js";
|
|
3
3
|
import { Directory, SuccessResponse } from "../client/index.js";
|
|
4
|
+
import { SandboxProcess } from "../process/index.js";
|
|
4
5
|
import { CopyResponse, SandboxFilesystemFile, WatchEvent } from "./types.js";
|
|
5
6
|
export declare class SandboxFileSystem extends SandboxAction {
|
|
6
|
-
|
|
7
|
+
private process;
|
|
8
|
+
constructor(sandbox: Sandbox, process: SandboxProcess);
|
|
7
9
|
mkdir(path: string, permissions?: string): Promise<SuccessResponse>;
|
|
8
10
|
write(path: string, content: string): Promise<SuccessResponse>;
|
|
9
11
|
writeBinary(path: string, content: Buffer | Blob | File | Uint8Array): Promise<unknown>;
|
|
@@ -11,7 +13,9 @@ export declare class SandboxFileSystem extends SandboxAction {
|
|
|
11
13
|
read(path: string): Promise<string>;
|
|
12
14
|
rm(path: string, recursive?: boolean): Promise<SuccessResponse>;
|
|
13
15
|
ls(path: string): Promise<Directory>;
|
|
14
|
-
cp(source: string, destination: string
|
|
16
|
+
cp(source: string, destination: string, { maxWait }?: {
|
|
17
|
+
maxWait?: number;
|
|
18
|
+
}): Promise<CopyResponse>;
|
|
15
19
|
watch(path: string, callback: (fileEvent: WatchEvent) => void | Promise<void>, options?: {
|
|
16
20
|
onError?: (error: Error) => void;
|
|
17
21
|
withContent: boolean;
|