computesdk 2.2.0 → 2.2.1
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 +0 -5
- package/dist/index.d.ts +0 -5
- package/dist/index.js +10 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2067,6 +2067,12 @@ function isCommandExitError(error) {
|
|
|
2067
2067
|
|
|
2068
2068
|
// src/client/index.ts
|
|
2069
2069
|
var MAX_TUNNEL_TIMEOUT_SECONDS = 300;
|
|
2070
|
+
function encodeFilePath(path) {
|
|
2071
|
+
const isAbsolute = path.startsWith("/");
|
|
2072
|
+
const segments = path.split("/").filter((s) => s !== "");
|
|
2073
|
+
const encoded = segments.map((s) => encodeURIComponent(s)).join("/");
|
|
2074
|
+
return isAbsolute ? "/" + encoded : encoded;
|
|
2075
|
+
}
|
|
2070
2076
|
var Sandbox = class {
|
|
2071
2077
|
constructor(config) {
|
|
2072
2078
|
this._token = null;
|
|
@@ -2605,16 +2611,7 @@ API request failed (${response.status}): ${error}`
|
|
|
2605
2611
|
* Get file metadata (without content)
|
|
2606
2612
|
*/
|
|
2607
2613
|
async getFile(path) {
|
|
2608
|
-
return this.request(`/files/${
|
|
2609
|
-
}
|
|
2610
|
-
/**
|
|
2611
|
-
* Encode a file path for use in URLs
|
|
2612
|
-
* Strips leading slash and encodes each segment separately to preserve path structure
|
|
2613
|
-
*/
|
|
2614
|
-
encodeFilePath(path) {
|
|
2615
|
-
const pathWithoutLeadingSlash = path.startsWith("/") ? path.slice(1) : path;
|
|
2616
|
-
const segments = pathWithoutLeadingSlash.split("/");
|
|
2617
|
-
return segments.map((s) => encodeURIComponent(s)).join("/");
|
|
2614
|
+
return this.request(`/files/${encodeFilePath(path)}`);
|
|
2618
2615
|
}
|
|
2619
2616
|
/**
|
|
2620
2617
|
* Read file content
|
|
@@ -2622,7 +2619,7 @@ API request failed (${response.status}): ${error}`
|
|
|
2622
2619
|
async readFile(path) {
|
|
2623
2620
|
const params = new URLSearchParams({ content: "true" });
|
|
2624
2621
|
const response = await this.request(
|
|
2625
|
-
`/files/${
|
|
2622
|
+
`/files/${encodeFilePath(path)}?${params}`
|
|
2626
2623
|
);
|
|
2627
2624
|
return response.data.content || "";
|
|
2628
2625
|
}
|
|
@@ -2639,7 +2636,7 @@ API request failed (${response.status}): ${error}`
|
|
|
2639
2636
|
* Delete a file or directory
|
|
2640
2637
|
*/
|
|
2641
2638
|
async deleteFile(path) {
|
|
2642
|
-
return this.request(`/files/${
|
|
2639
|
+
return this.request(`/files/${encodeFilePath(path)}`, {
|
|
2643
2640
|
method: "DELETE"
|
|
2644
2641
|
});
|
|
2645
2642
|
}
|
|
@@ -2658,7 +2655,7 @@ API request failed (${response.status}): ${error}`
|
|
|
2658
2655
|
headers["Authorization"] = `Bearer ${this._token}`;
|
|
2659
2656
|
}
|
|
2660
2657
|
const response = await fetch(
|
|
2661
|
-
`${this.config.sandboxUrl}/files/${
|
|
2658
|
+
`${this.config.sandboxUrl}/files/${encodeFilePath(path)}`,
|
|
2662
2659
|
{
|
|
2663
2660
|
method: "HEAD",
|
|
2664
2661
|
headers,
|