freestyle-sandboxes 0.0.73 → 0.0.75-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.cjs +7 -14
- package/dist/index.mjs +7 -14
- package/package.json +1 -1
- package/src/index.ts +22 -9
package/dist/index.cjs
CHANGED
|
@@ -63,12 +63,6 @@ const handleExecOnEphemeralDevServer = (options) => {
|
|
|
63
63
|
url: "/ephemeral/v1/dev-servers/exec"
|
|
64
64
|
});
|
|
65
65
|
};
|
|
66
|
-
const handleWriteFileFromEphemeralDevServer = (options) => {
|
|
67
|
-
return (options?.client ?? client).put({
|
|
68
|
-
...options,
|
|
69
|
-
url: "/ephemeral/v1/dev-servers/files/{*filepath}"
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
66
|
const handleReadFileFromEphemeralDevServer = (options) => {
|
|
73
67
|
return (options?.client ?? client).post({
|
|
74
68
|
...options,
|
|
@@ -1000,21 +994,20 @@ ${response.error.message}`);
|
|
|
1000
994
|
return response2.data.content.content;
|
|
1001
995
|
},
|
|
1002
996
|
async writeFile(path, content, encoding = "utf-8") {
|
|
1003
|
-
const contentStr = typeof content === "string" ? content :
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
path: {
|
|
1007
|
-
filepath: path
|
|
1008
|
-
},
|
|
997
|
+
const contentStr = typeof content === "string" ? content : Buffer.from(content).toString(encoding);
|
|
998
|
+
await client.put({
|
|
999
|
+
url: `/ephemeral/v1/dev-servers/files/${path}`,
|
|
1009
1000
|
body: {
|
|
1010
1001
|
devServer: devServerInstance,
|
|
1011
1002
|
content: contentStr,
|
|
1012
1003
|
encoding
|
|
1013
1004
|
}
|
|
1005
|
+
}).then((response2) => {
|
|
1006
|
+
console.log("Request PATH: ", response2.request.url);
|
|
1014
1007
|
});
|
|
1015
|
-
if (
|
|
1008
|
+
if (response.error) {
|
|
1016
1009
|
throw new Error(
|
|
1017
|
-
`Failed to write file: ${JSON.stringify(
|
|
1010
|
+
`Failed to write file: ${JSON.stringify(response.error)}`
|
|
1018
1011
|
);
|
|
1019
1012
|
}
|
|
1020
1013
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -61,12 +61,6 @@ const handleExecOnEphemeralDevServer = (options) => {
|
|
|
61
61
|
url: "/ephemeral/v1/dev-servers/exec"
|
|
62
62
|
});
|
|
63
63
|
};
|
|
64
|
-
const handleWriteFileFromEphemeralDevServer = (options) => {
|
|
65
|
-
return (options?.client ?? client).put({
|
|
66
|
-
...options,
|
|
67
|
-
url: "/ephemeral/v1/dev-servers/files/{*filepath}"
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
64
|
const handleReadFileFromEphemeralDevServer = (options) => {
|
|
71
65
|
return (options?.client ?? client).post({
|
|
72
66
|
...options,
|
|
@@ -998,21 +992,20 @@ ${response.error.message}`);
|
|
|
998
992
|
return response2.data.content.content;
|
|
999
993
|
},
|
|
1000
994
|
async writeFile(path, content, encoding = "utf-8") {
|
|
1001
|
-
const contentStr = typeof content === "string" ? content :
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
path: {
|
|
1005
|
-
filepath: path
|
|
1006
|
-
},
|
|
995
|
+
const contentStr = typeof content === "string" ? content : Buffer.from(content).toString(encoding);
|
|
996
|
+
await client.put({
|
|
997
|
+
url: `/ephemeral/v1/dev-servers/files/${path}`,
|
|
1007
998
|
body: {
|
|
1008
999
|
devServer: devServerInstance,
|
|
1009
1000
|
content: contentStr,
|
|
1010
1001
|
encoding
|
|
1011
1002
|
}
|
|
1003
|
+
}).then((response2) => {
|
|
1004
|
+
console.log("Request PATH: ", response2.request.url);
|
|
1012
1005
|
});
|
|
1013
|
-
if (
|
|
1006
|
+
if (response.error) {
|
|
1014
1007
|
throw new Error(
|
|
1015
|
-
`Failed to write file: ${JSON.stringify(
|
|
1008
|
+
`Failed to write file: ${JSON.stringify(response.error)}`
|
|
1016
1009
|
);
|
|
1017
1010
|
}
|
|
1018
1011
|
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1076,24 +1076,37 @@ export class FreestyleSandboxes {
|
|
|
1076
1076
|
async writeFile(
|
|
1077
1077
|
path: string,
|
|
1078
1078
|
content: string | ArrayBuffer,
|
|
1079
|
-
encoding = "utf-8"
|
|
1079
|
+
encoding: BufferEncoding = "utf-8"
|
|
1080
1080
|
) {
|
|
1081
1081
|
const contentStr =
|
|
1082
1082
|
typeof content === "string"
|
|
1083
1083
|
? content
|
|
1084
|
-
:
|
|
1085
|
-
|
|
1086
|
-
const response =
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1084
|
+
: Buffer.from(content).toString(encoding);
|
|
1085
|
+
|
|
1086
|
+
// const response =
|
|
1087
|
+
// await sandbox_openapi.handleWriteFileFromEphemeralDevServer({
|
|
1088
|
+
// client,
|
|
1089
|
+
|
|
1090
|
+
// path: {
|
|
1091
|
+
// filepath: path,
|
|
1092
|
+
// },
|
|
1093
|
+
// body: {
|
|
1094
|
+
// devServer: devServerInstance,
|
|
1095
|
+
// content: contentStr,
|
|
1096
|
+
// encoding,
|
|
1097
|
+
// },
|
|
1098
|
+
// });
|
|
1099
|
+
await client
|
|
1100
|
+
.put({
|
|
1101
|
+
url: `/ephemeral/v1/dev-servers/files/${path}`,
|
|
1092
1102
|
body: {
|
|
1093
1103
|
devServer: devServerInstance,
|
|
1094
1104
|
content: contentStr,
|
|
1095
1105
|
encoding,
|
|
1096
1106
|
},
|
|
1107
|
+
})
|
|
1108
|
+
.then((response) => {
|
|
1109
|
+
console.log("Request PATH: ", response.request.url);
|
|
1097
1110
|
});
|
|
1098
1111
|
|
|
1099
1112
|
if (response.error) {
|