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.d.mts
CHANGED
|
@@ -3279,11 +3279,6 @@ declare class Sandbox {
|
|
|
3279
3279
|
* Get file metadata (without content)
|
|
3280
3280
|
*/
|
|
3281
3281
|
getFile(path: string): Promise<FileResponse>;
|
|
3282
|
-
/**
|
|
3283
|
-
* Encode a file path for use in URLs
|
|
3284
|
-
* Strips leading slash and encodes each segment separately to preserve path structure
|
|
3285
|
-
*/
|
|
3286
|
-
private encodeFilePath;
|
|
3287
3282
|
/**
|
|
3288
3283
|
* Read file content
|
|
3289
3284
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -3279,11 +3279,6 @@ declare class Sandbox {
|
|
|
3279
3279
|
* Get file metadata (without content)
|
|
3280
3280
|
*/
|
|
3281
3281
|
getFile(path: string): Promise<FileResponse>;
|
|
3282
|
-
/**
|
|
3283
|
-
* Encode a file path for use in URLs
|
|
3284
|
-
* Strips leading slash and encodes each segment separately to preserve path structure
|
|
3285
|
-
*/
|
|
3286
|
-
private encodeFilePath;
|
|
3287
3282
|
/**
|
|
3288
3283
|
* Read file content
|
|
3289
3284
|
*/
|
package/dist/index.js
CHANGED
|
@@ -2122,6 +2122,12 @@ function isCommandExitError(error) {
|
|
|
2122
2122
|
|
|
2123
2123
|
// src/client/index.ts
|
|
2124
2124
|
var MAX_TUNNEL_TIMEOUT_SECONDS = 300;
|
|
2125
|
+
function encodeFilePath(path) {
|
|
2126
|
+
const isAbsolute = path.startsWith("/");
|
|
2127
|
+
const segments = path.split("/").filter((s) => s !== "");
|
|
2128
|
+
const encoded = segments.map((s) => encodeURIComponent(s)).join("/");
|
|
2129
|
+
return isAbsolute ? "/" + encoded : encoded;
|
|
2130
|
+
}
|
|
2125
2131
|
var Sandbox = class {
|
|
2126
2132
|
constructor(config) {
|
|
2127
2133
|
this._token = null;
|
|
@@ -2660,16 +2666,7 @@ API request failed (${response.status}): ${error}`
|
|
|
2660
2666
|
* Get file metadata (without content)
|
|
2661
2667
|
*/
|
|
2662
2668
|
async getFile(path) {
|
|
2663
|
-
return this.request(`/files/${
|
|
2664
|
-
}
|
|
2665
|
-
/**
|
|
2666
|
-
* Encode a file path for use in URLs
|
|
2667
|
-
* Strips leading slash and encodes each segment separately to preserve path structure
|
|
2668
|
-
*/
|
|
2669
|
-
encodeFilePath(path) {
|
|
2670
|
-
const pathWithoutLeadingSlash = path.startsWith("/") ? path.slice(1) : path;
|
|
2671
|
-
const segments = pathWithoutLeadingSlash.split("/");
|
|
2672
|
-
return segments.map((s) => encodeURIComponent(s)).join("/");
|
|
2669
|
+
return this.request(`/files/${encodeFilePath(path)}`);
|
|
2673
2670
|
}
|
|
2674
2671
|
/**
|
|
2675
2672
|
* Read file content
|
|
@@ -2677,7 +2674,7 @@ API request failed (${response.status}): ${error}`
|
|
|
2677
2674
|
async readFile(path) {
|
|
2678
2675
|
const params = new URLSearchParams({ content: "true" });
|
|
2679
2676
|
const response = await this.request(
|
|
2680
|
-
`/files/${
|
|
2677
|
+
`/files/${encodeFilePath(path)}?${params}`
|
|
2681
2678
|
);
|
|
2682
2679
|
return response.data.content || "";
|
|
2683
2680
|
}
|
|
@@ -2694,7 +2691,7 @@ API request failed (${response.status}): ${error}`
|
|
|
2694
2691
|
* Delete a file or directory
|
|
2695
2692
|
*/
|
|
2696
2693
|
async deleteFile(path) {
|
|
2697
|
-
return this.request(`/files/${
|
|
2694
|
+
return this.request(`/files/${encodeFilePath(path)}`, {
|
|
2698
2695
|
method: "DELETE"
|
|
2699
2696
|
});
|
|
2700
2697
|
}
|
|
@@ -2713,7 +2710,7 @@ API request failed (${response.status}): ${error}`
|
|
|
2713
2710
|
headers["Authorization"] = `Bearer ${this._token}`;
|
|
2714
2711
|
}
|
|
2715
2712
|
const response = await fetch(
|
|
2716
|
-
`${this.config.sandboxUrl}/files/${
|
|
2713
|
+
`${this.config.sandboxUrl}/files/${encodeFilePath(path)}`,
|
|
2717
2714
|
{
|
|
2718
2715
|
method: "HEAD",
|
|
2719
2716
|
headers,
|