freestyle-sandboxes 0.0.16 → 0.0.17
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/ai/index.d.cts +3 -3
- package/dist/ai/index.d.mts +3 -3
- package/dist/index.cjs +85 -6
- package/dist/index.d.cts +10 -6
- package/dist/index.d.mts +10 -6
- package/dist/index.mjs +85 -6
- package/dist/mastra/index.d.cts +1 -1
- package/dist/mastra/index.d.mts +1 -1
- package/dist/types.gen-C03gaIPq.d.ts +297 -0
- package/openapi/sdk.gen.ts +56 -6
- package/openapi/types.gen.ts +110 -33
- package/openapi.json +1 -1
- package/package.json +1 -1
- package/src/index.ts +68 -5
package/dist/ai/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as ai from 'ai';
|
|
2
|
-
import { F as FreestyleExecuteScriptParamsConfiguration, a as
|
|
2
|
+
import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecuteScriptResultSuccess, c as FreestyleDeployWebSuccessResponse } from '../types.gen-C03gaIPq.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
declare const executeCodeSchema: z.ZodObject<{
|
|
@@ -26,10 +26,10 @@ declare const executeTool: (config: FreestyleExecuteScriptParamsConfiguration &
|
|
|
26
26
|
script?: string;
|
|
27
27
|
}, {
|
|
28
28
|
script?: string;
|
|
29
|
-
}>, string |
|
|
29
|
+
}>, string | FreestyleExecuteScriptResultSuccess> & {
|
|
30
30
|
execute: (args: {
|
|
31
31
|
script?: string;
|
|
32
|
-
}, options: ai.ToolExecutionOptions) => PromiseLike<string |
|
|
32
|
+
}, options: ai.ToolExecutionOptions) => PromiseLike<string | FreestyleExecuteScriptResultSuccess>;
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
35
35
|
* Deploy a Web project
|
package/dist/ai/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as ai from 'ai';
|
|
2
|
-
import { F as FreestyleExecuteScriptParamsConfiguration, a as
|
|
2
|
+
import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecuteScriptResultSuccess, c as FreestyleDeployWebSuccessResponse } from '../types.gen-C03gaIPq.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
declare const executeCodeSchema: z.ZodObject<{
|
|
@@ -26,10 +26,10 @@ declare const executeTool: (config: FreestyleExecuteScriptParamsConfiguration &
|
|
|
26
26
|
script?: string;
|
|
27
27
|
}, {
|
|
28
28
|
script?: string;
|
|
29
|
-
}>, string |
|
|
29
|
+
}>, string | FreestyleExecuteScriptResultSuccess> & {
|
|
30
30
|
execute: (args: {
|
|
31
31
|
script?: string;
|
|
32
|
-
}, options: ai.ToolExecutionOptions) => PromiseLike<string |
|
|
32
|
+
}, options: ai.ToolExecutionOptions) => PromiseLike<string | FreestyleExecuteScriptResultSuccess>;
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
35
35
|
* Deploy a Web project
|
package/dist/index.cjs
CHANGED
|
@@ -15,6 +15,12 @@ const handleBackupCloudstate = (options) => {
|
|
|
15
15
|
url: "/cloudstate/v1/projects/{id}/backup"
|
|
16
16
|
});
|
|
17
17
|
};
|
|
18
|
+
const handleVerifyWildcard = (options) => {
|
|
19
|
+
return (options?.client ?? client).post({
|
|
20
|
+
...options,
|
|
21
|
+
url: "/domains/v1/certs/{domain}/wildcard"
|
|
22
|
+
});
|
|
23
|
+
};
|
|
18
24
|
const handleListDomains = (options) => {
|
|
19
25
|
return (options?.client ?? client).get({
|
|
20
26
|
...options,
|
|
@@ -45,22 +51,40 @@ const handleDeleteDomainVerification = (options) => {
|
|
|
45
51
|
url: "/domains/v1/verifications"
|
|
46
52
|
});
|
|
47
53
|
};
|
|
54
|
+
const handleListExecuteRuns = (options) => {
|
|
55
|
+
return (options?.client ?? client).get({
|
|
56
|
+
...options,
|
|
57
|
+
url: "/execute/v1/deployments"
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
const handleGetExecuteRun = (options) => {
|
|
61
|
+
return (options?.client ?? client).get({
|
|
62
|
+
...options,
|
|
63
|
+
url: "/execute/v1/deployments/{deployment}"
|
|
64
|
+
});
|
|
65
|
+
};
|
|
48
66
|
const handleExecuteScript = (options) => {
|
|
49
67
|
return (options?.client ?? client).post({
|
|
50
68
|
...options,
|
|
51
69
|
url: "/execute/v1/script"
|
|
52
70
|
});
|
|
53
71
|
};
|
|
72
|
+
const handleGetLogs = (options) => {
|
|
73
|
+
return (options?.client ?? client).get({
|
|
74
|
+
...options,
|
|
75
|
+
url: "/observability/v1/logs"
|
|
76
|
+
});
|
|
77
|
+
};
|
|
54
78
|
const handleDeployWeb = (options) => {
|
|
55
79
|
return (options?.client ?? client).post({
|
|
56
80
|
...options,
|
|
57
81
|
url: "/web/v1/deploy"
|
|
58
82
|
});
|
|
59
83
|
};
|
|
60
|
-
const
|
|
84
|
+
const handleListWebDeploys = (options) => {
|
|
61
85
|
return (options?.client ?? client).get({
|
|
62
86
|
...options,
|
|
63
|
-
url: "/web/v1/
|
|
87
|
+
url: "/web/v1/deployments"
|
|
64
88
|
});
|
|
65
89
|
};
|
|
66
90
|
|
|
@@ -159,17 +183,20 @@ Message: ${response.error?.message}`
|
|
|
159
183
|
}
|
|
160
184
|
}
|
|
161
185
|
/**
|
|
162
|
-
* Get logs for
|
|
186
|
+
* Get logs for an execute run, or web deployment.
|
|
163
187
|
* @param id The ID of the sandbox.
|
|
164
188
|
* @returns The logs for the sandbox.
|
|
165
189
|
* @throws An error if the logs could not be retrieved.
|
|
166
190
|
*/
|
|
167
|
-
async
|
|
191
|
+
async getLogs(id) {
|
|
168
192
|
const response = await handleGetLogs({
|
|
169
193
|
client: this.client,
|
|
170
|
-
|
|
171
|
-
id
|
|
194
|
+
query: {
|
|
195
|
+
deploymentId: id
|
|
172
196
|
}
|
|
197
|
+
// path: {
|
|
198
|
+
// id: id,
|
|
199
|
+
// },
|
|
173
200
|
});
|
|
174
201
|
if (response.data) {
|
|
175
202
|
return response.data;
|
|
@@ -257,6 +284,58 @@ Message: ${response.error?.message}`
|
|
|
257
284
|
);
|
|
258
285
|
}
|
|
259
286
|
}
|
|
287
|
+
async listWebDeployments() {
|
|
288
|
+
const response = await handleListWebDeploys({
|
|
289
|
+
client: this.client
|
|
290
|
+
});
|
|
291
|
+
if (response.data) {
|
|
292
|
+
return response.data;
|
|
293
|
+
} else {
|
|
294
|
+
throw new Error(
|
|
295
|
+
"Failed to list web deployments\n" + response.error.message
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
async listExecuteRuns() {
|
|
300
|
+
const response = await handleListExecuteRuns({
|
|
301
|
+
client: this.client
|
|
302
|
+
});
|
|
303
|
+
if (response.data) {
|
|
304
|
+
return response.data;
|
|
305
|
+
} else {
|
|
306
|
+
throw new Error("Failed to list execute runs\n" + response.error.message);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
async getExecuteRun(id) {
|
|
310
|
+
const response = await handleGetExecuteRun({
|
|
311
|
+
client: this.client,
|
|
312
|
+
path: {
|
|
313
|
+
deployment: id
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
if (response.data) {
|
|
317
|
+
return response.data;
|
|
318
|
+
} else {
|
|
319
|
+
throw new Error(
|
|
320
|
+
`Failed to get execute run with ID ${id}: ${response.error.message}`
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
async provisionWildcard(domain) {
|
|
325
|
+
const response = await handleVerifyWildcard({
|
|
326
|
+
client: this.client,
|
|
327
|
+
path: {
|
|
328
|
+
domain
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
if (response.data) {
|
|
332
|
+
return response.data;
|
|
333
|
+
} else {
|
|
334
|
+
throw new Error(
|
|
335
|
+
`Failed to provision wildcard for domain ${domain}: ${response.error.message}`
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
260
339
|
}
|
|
261
340
|
|
|
262
341
|
exports.FreestyleSandboxes = FreestyleSandboxes;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FreestyleExecuteScriptParamsConfiguration, a as
|
|
2
|
-
export {
|
|
1
|
+
import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecuteScriptResultSuccess, b as FreestyleDeployWebConfiguration, c as FreestyleDeployWebSuccessResponse, d as FreestyleCloudstateDeployRequest, e as FreestyleCloudstateDeploySuccessResponse, H as HandleBackupCloudstateResponse, f as HandleGetLogsResponse, g as HandleCreateDomainVerificationResponse, h as HandleVerifyDomainResponse, i as HandleVerifyDomainError, j as HandleListDomainsResponse, k as HandleListDomainVerificationRequestsResponse, l as HandleDeleteDomainVerificationResponse, m as HandleListWebDeploysResponse, n as HandleListExecuteRunsResponse, o as HandleGetExecuteRunResponse, p as HandleVerifyWildcardResponse } from './types.gen-C03gaIPq.js';
|
|
2
|
+
export { D as DeploymentLogEntry, q as DeploymentState, E as ExecuteLogEntry, r as ExecuteRunState, s as FreestyleCloudstateDeployConfiguration, t as FreestyleCloudstateDeployErrorResponse, u as FreestyleDeleteDomainVerificationRequest, v as FreestyleDeployWebErrorResponse, w as FreestyleDeployWebPayload, x as FreestyleDomainVerificationRequest, y as FreestyleExecuteScriptParams, z as FreestyleFile, A as FreestyleJavaScriptLog, B as FreestyleLogResponseObject, C as FreestyleVerifyDomainRequest, K as HandleBackupCloudstateData, L as HandleBackupCloudstateError, Q as HandleCreateDomainVerificationData, R as HandleCreateDomainVerificationError, S as HandleDeleteDomainVerificationData, T as HandleDeleteDomainVerificationError, G as HandleDeployCloudstateData, J as HandleDeployCloudstateError, I as HandleDeployCloudstateResponse, a1 as HandleDeployWebData, a3 as HandleDeployWebError, a2 as HandleDeployWebResponse, Y as HandleExecuteScriptData, _ as HandleExecuteScriptError, Z as HandleExecuteScriptResponse, W as HandleGetExecuteRunData, X as HandleGetExecuteRunError, $ as HandleGetLogsData, a0 as HandleGetLogsError, O as HandleListDomainVerificationRequestsError, N as HandleListDomainsError, U as HandleListExecuteRunsData, V as HandleListExecuteRunsError, a4 as HandleListWebDeploysError, P as HandleVerifyDomainData, M as HandleVerifyWildcardError } from './types.gen-C03gaIPq.js';
|
|
3
3
|
|
|
4
4
|
declare class FreestyleSandboxes {
|
|
5
5
|
private client;
|
|
@@ -20,7 +20,7 @@ declare class FreestyleSandboxes {
|
|
|
20
20
|
/**
|
|
21
21
|
* Execute a script in a sandbox.
|
|
22
22
|
*/
|
|
23
|
-
executeScript(script: string, config?: FreestyleExecuteScriptParamsConfiguration): Promise<
|
|
23
|
+
executeScript(script: string, config?: FreestyleExecuteScriptParamsConfiguration): Promise<FreestyleExecuteScriptResultSuccess>;
|
|
24
24
|
/**
|
|
25
25
|
* Deploy a Web project to a sandbox.
|
|
26
26
|
*/
|
|
@@ -40,12 +40,12 @@ declare class FreestyleSandboxes {
|
|
|
40
40
|
*/
|
|
41
41
|
backupCloudstate(id: string): Promise<HandleBackupCloudstateResponse>;
|
|
42
42
|
/**
|
|
43
|
-
* Get logs for
|
|
43
|
+
* Get logs for an execute run, or web deployment.
|
|
44
44
|
* @param id The ID of the sandbox.
|
|
45
45
|
* @returns The logs for the sandbox.
|
|
46
46
|
* @throws An error if the logs could not be retrieved.
|
|
47
47
|
*/
|
|
48
|
-
|
|
48
|
+
getLogs(id: string): Promise<HandleGetLogsResponse>;
|
|
49
49
|
/**
|
|
50
50
|
* Create a a domain verification request.
|
|
51
51
|
* @param domain The domain to verify.
|
|
@@ -61,6 +61,10 @@ declare class FreestyleSandboxes {
|
|
|
61
61
|
listDomains(): Promise<HandleListDomainsResponse>;
|
|
62
62
|
listDomainVerificationRequests(): Promise<HandleListDomainVerificationRequestsResponse>;
|
|
63
63
|
deleteDomainVerificationRequest(domain: string, verificationCode: string): Promise<HandleDeleteDomainVerificationResponse>;
|
|
64
|
+
listWebDeployments(): Promise<HandleListWebDeploysResponse>;
|
|
65
|
+
listExecuteRuns(): Promise<HandleListExecuteRunsResponse>;
|
|
66
|
+
getExecuteRun(id: string): Promise<HandleGetExecuteRunResponse>;
|
|
67
|
+
provisionWildcard(domain: string): Promise<HandleVerifyWildcardResponse>;
|
|
64
68
|
}
|
|
65
69
|
|
|
66
|
-
export { FreestyleCloudstateDeployRequest, FreestyleCloudstateDeploySuccessResponse, FreestyleDeployWebConfiguration, FreestyleDeployWebSuccessResponse,
|
|
70
|
+
export { FreestyleCloudstateDeployRequest, FreestyleCloudstateDeploySuccessResponse, FreestyleDeployWebConfiguration, FreestyleDeployWebSuccessResponse, FreestyleExecuteScriptParamsConfiguration, FreestyleExecuteScriptResultSuccess, FreestyleSandboxes, HandleBackupCloudstateResponse, HandleCreateDomainVerificationResponse, HandleDeleteDomainVerificationResponse, HandleGetExecuteRunResponse, HandleGetLogsResponse, HandleListDomainVerificationRequestsResponse, HandleListDomainsResponse, HandleListExecuteRunsResponse, HandleListWebDeploysResponse, HandleVerifyDomainError, HandleVerifyDomainResponse, HandleVerifyWildcardResponse };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FreestyleExecuteScriptParamsConfiguration, a as
|
|
2
|
-
export {
|
|
1
|
+
import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecuteScriptResultSuccess, b as FreestyleDeployWebConfiguration, c as FreestyleDeployWebSuccessResponse, d as FreestyleCloudstateDeployRequest, e as FreestyleCloudstateDeploySuccessResponse, H as HandleBackupCloudstateResponse, f as HandleGetLogsResponse, g as HandleCreateDomainVerificationResponse, h as HandleVerifyDomainResponse, i as HandleVerifyDomainError, j as HandleListDomainsResponse, k as HandleListDomainVerificationRequestsResponse, l as HandleDeleteDomainVerificationResponse, m as HandleListWebDeploysResponse, n as HandleListExecuteRunsResponse, o as HandleGetExecuteRunResponse, p as HandleVerifyWildcardResponse } from './types.gen-C03gaIPq.js';
|
|
2
|
+
export { D as DeploymentLogEntry, q as DeploymentState, E as ExecuteLogEntry, r as ExecuteRunState, s as FreestyleCloudstateDeployConfiguration, t as FreestyleCloudstateDeployErrorResponse, u as FreestyleDeleteDomainVerificationRequest, v as FreestyleDeployWebErrorResponse, w as FreestyleDeployWebPayload, x as FreestyleDomainVerificationRequest, y as FreestyleExecuteScriptParams, z as FreestyleFile, A as FreestyleJavaScriptLog, B as FreestyleLogResponseObject, C as FreestyleVerifyDomainRequest, K as HandleBackupCloudstateData, L as HandleBackupCloudstateError, Q as HandleCreateDomainVerificationData, R as HandleCreateDomainVerificationError, S as HandleDeleteDomainVerificationData, T as HandleDeleteDomainVerificationError, G as HandleDeployCloudstateData, J as HandleDeployCloudstateError, I as HandleDeployCloudstateResponse, a1 as HandleDeployWebData, a3 as HandleDeployWebError, a2 as HandleDeployWebResponse, Y as HandleExecuteScriptData, _ as HandleExecuteScriptError, Z as HandleExecuteScriptResponse, W as HandleGetExecuteRunData, X as HandleGetExecuteRunError, $ as HandleGetLogsData, a0 as HandleGetLogsError, O as HandleListDomainVerificationRequestsError, N as HandleListDomainsError, U as HandleListExecuteRunsData, V as HandleListExecuteRunsError, a4 as HandleListWebDeploysError, P as HandleVerifyDomainData, M as HandleVerifyWildcardError } from './types.gen-C03gaIPq.js';
|
|
3
3
|
|
|
4
4
|
declare class FreestyleSandboxes {
|
|
5
5
|
private client;
|
|
@@ -20,7 +20,7 @@ declare class FreestyleSandboxes {
|
|
|
20
20
|
/**
|
|
21
21
|
* Execute a script in a sandbox.
|
|
22
22
|
*/
|
|
23
|
-
executeScript(script: string, config?: FreestyleExecuteScriptParamsConfiguration): Promise<
|
|
23
|
+
executeScript(script: string, config?: FreestyleExecuteScriptParamsConfiguration): Promise<FreestyleExecuteScriptResultSuccess>;
|
|
24
24
|
/**
|
|
25
25
|
* Deploy a Web project to a sandbox.
|
|
26
26
|
*/
|
|
@@ -40,12 +40,12 @@ declare class FreestyleSandboxes {
|
|
|
40
40
|
*/
|
|
41
41
|
backupCloudstate(id: string): Promise<HandleBackupCloudstateResponse>;
|
|
42
42
|
/**
|
|
43
|
-
* Get logs for
|
|
43
|
+
* Get logs for an execute run, or web deployment.
|
|
44
44
|
* @param id The ID of the sandbox.
|
|
45
45
|
* @returns The logs for the sandbox.
|
|
46
46
|
* @throws An error if the logs could not be retrieved.
|
|
47
47
|
*/
|
|
48
|
-
|
|
48
|
+
getLogs(id: string): Promise<HandleGetLogsResponse>;
|
|
49
49
|
/**
|
|
50
50
|
* Create a a domain verification request.
|
|
51
51
|
* @param domain The domain to verify.
|
|
@@ -61,6 +61,10 @@ declare class FreestyleSandboxes {
|
|
|
61
61
|
listDomains(): Promise<HandleListDomainsResponse>;
|
|
62
62
|
listDomainVerificationRequests(): Promise<HandleListDomainVerificationRequestsResponse>;
|
|
63
63
|
deleteDomainVerificationRequest(domain: string, verificationCode: string): Promise<HandleDeleteDomainVerificationResponse>;
|
|
64
|
+
listWebDeployments(): Promise<HandleListWebDeploysResponse>;
|
|
65
|
+
listExecuteRuns(): Promise<HandleListExecuteRunsResponse>;
|
|
66
|
+
getExecuteRun(id: string): Promise<HandleGetExecuteRunResponse>;
|
|
67
|
+
provisionWildcard(domain: string): Promise<HandleVerifyWildcardResponse>;
|
|
64
68
|
}
|
|
65
69
|
|
|
66
|
-
export { FreestyleCloudstateDeployRequest, FreestyleCloudstateDeploySuccessResponse, FreestyleDeployWebConfiguration, FreestyleDeployWebSuccessResponse,
|
|
70
|
+
export { FreestyleCloudstateDeployRequest, FreestyleCloudstateDeploySuccessResponse, FreestyleDeployWebConfiguration, FreestyleDeployWebSuccessResponse, FreestyleExecuteScriptParamsConfiguration, FreestyleExecuteScriptResultSuccess, FreestyleSandboxes, HandleBackupCloudstateResponse, HandleCreateDomainVerificationResponse, HandleDeleteDomainVerificationResponse, HandleGetExecuteRunResponse, HandleGetLogsResponse, HandleListDomainVerificationRequestsResponse, HandleListDomainsResponse, HandleListExecuteRunsResponse, HandleListWebDeploysResponse, HandleVerifyDomainError, HandleVerifyDomainResponse, HandleVerifyWildcardResponse };
|
package/dist/index.mjs
CHANGED
|
@@ -13,6 +13,12 @@ const handleBackupCloudstate = (options) => {
|
|
|
13
13
|
url: "/cloudstate/v1/projects/{id}/backup"
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
|
+
const handleVerifyWildcard = (options) => {
|
|
17
|
+
return (options?.client ?? client).post({
|
|
18
|
+
...options,
|
|
19
|
+
url: "/domains/v1/certs/{domain}/wildcard"
|
|
20
|
+
});
|
|
21
|
+
};
|
|
16
22
|
const handleListDomains = (options) => {
|
|
17
23
|
return (options?.client ?? client).get({
|
|
18
24
|
...options,
|
|
@@ -43,22 +49,40 @@ const handleDeleteDomainVerification = (options) => {
|
|
|
43
49
|
url: "/domains/v1/verifications"
|
|
44
50
|
});
|
|
45
51
|
};
|
|
52
|
+
const handleListExecuteRuns = (options) => {
|
|
53
|
+
return (options?.client ?? client).get({
|
|
54
|
+
...options,
|
|
55
|
+
url: "/execute/v1/deployments"
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
const handleGetExecuteRun = (options) => {
|
|
59
|
+
return (options?.client ?? client).get({
|
|
60
|
+
...options,
|
|
61
|
+
url: "/execute/v1/deployments/{deployment}"
|
|
62
|
+
});
|
|
63
|
+
};
|
|
46
64
|
const handleExecuteScript = (options) => {
|
|
47
65
|
return (options?.client ?? client).post({
|
|
48
66
|
...options,
|
|
49
67
|
url: "/execute/v1/script"
|
|
50
68
|
});
|
|
51
69
|
};
|
|
70
|
+
const handleGetLogs = (options) => {
|
|
71
|
+
return (options?.client ?? client).get({
|
|
72
|
+
...options,
|
|
73
|
+
url: "/observability/v1/logs"
|
|
74
|
+
});
|
|
75
|
+
};
|
|
52
76
|
const handleDeployWeb = (options) => {
|
|
53
77
|
return (options?.client ?? client).post({
|
|
54
78
|
...options,
|
|
55
79
|
url: "/web/v1/deploy"
|
|
56
80
|
});
|
|
57
81
|
};
|
|
58
|
-
const
|
|
82
|
+
const handleListWebDeploys = (options) => {
|
|
59
83
|
return (options?.client ?? client).get({
|
|
60
84
|
...options,
|
|
61
|
-
url: "/web/v1/
|
|
85
|
+
url: "/web/v1/deployments"
|
|
62
86
|
});
|
|
63
87
|
};
|
|
64
88
|
|
|
@@ -157,17 +181,20 @@ Message: ${response.error?.message}`
|
|
|
157
181
|
}
|
|
158
182
|
}
|
|
159
183
|
/**
|
|
160
|
-
* Get logs for
|
|
184
|
+
* Get logs for an execute run, or web deployment.
|
|
161
185
|
* @param id The ID of the sandbox.
|
|
162
186
|
* @returns The logs for the sandbox.
|
|
163
187
|
* @throws An error if the logs could not be retrieved.
|
|
164
188
|
*/
|
|
165
|
-
async
|
|
189
|
+
async getLogs(id) {
|
|
166
190
|
const response = await handleGetLogs({
|
|
167
191
|
client: this.client,
|
|
168
|
-
|
|
169
|
-
id
|
|
192
|
+
query: {
|
|
193
|
+
deploymentId: id
|
|
170
194
|
}
|
|
195
|
+
// path: {
|
|
196
|
+
// id: id,
|
|
197
|
+
// },
|
|
171
198
|
});
|
|
172
199
|
if (response.data) {
|
|
173
200
|
return response.data;
|
|
@@ -255,6 +282,58 @@ Message: ${response.error?.message}`
|
|
|
255
282
|
);
|
|
256
283
|
}
|
|
257
284
|
}
|
|
285
|
+
async listWebDeployments() {
|
|
286
|
+
const response = await handleListWebDeploys({
|
|
287
|
+
client: this.client
|
|
288
|
+
});
|
|
289
|
+
if (response.data) {
|
|
290
|
+
return response.data;
|
|
291
|
+
} else {
|
|
292
|
+
throw new Error(
|
|
293
|
+
"Failed to list web deployments\n" + response.error.message
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
async listExecuteRuns() {
|
|
298
|
+
const response = await handleListExecuteRuns({
|
|
299
|
+
client: this.client
|
|
300
|
+
});
|
|
301
|
+
if (response.data) {
|
|
302
|
+
return response.data;
|
|
303
|
+
} else {
|
|
304
|
+
throw new Error("Failed to list execute runs\n" + response.error.message);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
async getExecuteRun(id) {
|
|
308
|
+
const response = await handleGetExecuteRun({
|
|
309
|
+
client: this.client,
|
|
310
|
+
path: {
|
|
311
|
+
deployment: id
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
if (response.data) {
|
|
315
|
+
return response.data;
|
|
316
|
+
} else {
|
|
317
|
+
throw new Error(
|
|
318
|
+
`Failed to get execute run with ID ${id}: ${response.error.message}`
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
async provisionWildcard(domain) {
|
|
323
|
+
const response = await handleVerifyWildcard({
|
|
324
|
+
client: this.client,
|
|
325
|
+
path: {
|
|
326
|
+
domain
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
if (response.data) {
|
|
330
|
+
return response.data;
|
|
331
|
+
} else {
|
|
332
|
+
throw new Error(
|
|
333
|
+
`Failed to provision wildcard for domain ${domain}: ${response.error.message}`
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
258
337
|
}
|
|
259
338
|
|
|
260
339
|
export { FreestyleSandboxes };
|
package/dist/mastra/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _mastra_core from '@mastra/core';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { F as FreestyleExecuteScriptParamsConfiguration } from '../types.gen-
|
|
3
|
+
import { F as FreestyleExecuteScriptParamsConfiguration } from '../types.gen-C03gaIPq.js';
|
|
4
4
|
|
|
5
5
|
declare const executeTool: (config: FreestyleExecuteScriptParamsConfiguration & {
|
|
6
6
|
apiKey: string;
|
package/dist/mastra/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _mastra_core from '@mastra/core';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { F as FreestyleExecuteScriptParamsConfiguration } from '../types.gen-
|
|
3
|
+
import { F as FreestyleExecuteScriptParamsConfiguration } from '../types.gen-C03gaIPq.js';
|
|
4
4
|
|
|
5
5
|
declare const executeTool: (config: FreestyleExecuteScriptParamsConfiguration & {
|
|
6
6
|
apiKey: string;
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
type DeploymentLogEntry = {
|
|
2
|
+
deploymentId: string;
|
|
3
|
+
accountId: string;
|
|
4
|
+
provisionedAt: string;
|
|
5
|
+
timeout: string;
|
|
6
|
+
state: DeploymentState;
|
|
7
|
+
deployedAt?: (string) | null;
|
|
8
|
+
domains: Array<(string)>;
|
|
9
|
+
envVars: {
|
|
10
|
+
[key: string]: (string);
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
type DeploymentState = 'provisioning' | 'deployed' | 'failed';
|
|
14
|
+
type ExecuteLogEntry = {
|
|
15
|
+
deployment: string;
|
|
16
|
+
account_id: string;
|
|
17
|
+
provisioned_at: string;
|
|
18
|
+
started_at?: (string) | null;
|
|
19
|
+
duration?: (string) | null;
|
|
20
|
+
state: ExecuteRunState;
|
|
21
|
+
env_vars: {
|
|
22
|
+
[key: string]: (string);
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
type ExecuteRunState = 'starting' | 'running' | 'complete';
|
|
26
|
+
type FreestyleCloudstateDeployConfiguration = {
|
|
27
|
+
/**
|
|
28
|
+
* ID of the project to deploy, if not provided will create a new project
|
|
29
|
+
*/
|
|
30
|
+
domains?: Array<(string)> | null;
|
|
31
|
+
/**
|
|
32
|
+
* The environment variables that the cloudstate deploy can access
|
|
33
|
+
*/
|
|
34
|
+
envVars?: {
|
|
35
|
+
[key: string]: (string);
|
|
36
|
+
};
|
|
37
|
+
cloudstateDatabaseId?: (string) | null;
|
|
38
|
+
};
|
|
39
|
+
type FreestyleCloudstateDeployErrorResponse = {
|
|
40
|
+
message: string;
|
|
41
|
+
};
|
|
42
|
+
type FreestyleCloudstateDeployRequest = {
|
|
43
|
+
classes: string;
|
|
44
|
+
config?: FreestyleCloudstateDeployConfiguration;
|
|
45
|
+
};
|
|
46
|
+
type FreestyleCloudstateDeploySuccessResponse = {
|
|
47
|
+
deploymentId: string;
|
|
48
|
+
cloudstateDatabaseId: string;
|
|
49
|
+
};
|
|
50
|
+
type FreestyleDeleteDomainVerificationRequest = {
|
|
51
|
+
/**
|
|
52
|
+
* The domain to create a verification code for
|
|
53
|
+
*/
|
|
54
|
+
domain: string;
|
|
55
|
+
/**
|
|
56
|
+
* The verification code
|
|
57
|
+
*/
|
|
58
|
+
verificationCode: string;
|
|
59
|
+
};
|
|
60
|
+
type FreestyleDeployWebConfiguration = {
|
|
61
|
+
/**
|
|
62
|
+
* The entrypoint file for the website
|
|
63
|
+
*/
|
|
64
|
+
entrypoint?: (string) | null;
|
|
65
|
+
/**
|
|
66
|
+
* The custom domains for the website, eg. [\"subdomain.yourwebsite.com\"]. You may include a single *.style.dev domain here.
|
|
67
|
+
*/
|
|
68
|
+
domains?: Array<(string)> | null;
|
|
69
|
+
/**
|
|
70
|
+
* Project ID was our original way of tracking deployments together, it is now deprecated and will be removed in the future. Please use the domains field to specify the domains for your project.
|
|
71
|
+
* @deprecated
|
|
72
|
+
*/
|
|
73
|
+
projectId?: (string) | null;
|
|
74
|
+
/**
|
|
75
|
+
* Node Modules to install for the website, a map of package names to versions, e.g. { \"express\": \"4.17.1\" }. If this and a package-lock.json are provided, the package-lock.json, bun.lockb, pnpm-lock.yaml, or yarn.lock is also provided, the versions here will override the versions in those lock files.
|
|
76
|
+
*/
|
|
77
|
+
nodeModules?: {
|
|
78
|
+
[key: string]: (string);
|
|
79
|
+
} | null;
|
|
80
|
+
/**
|
|
81
|
+
* The environment variables that the website can access
|
|
82
|
+
* e.g. { \"RESEND_API_KEY\": \"re_123456789\" }
|
|
83
|
+
*/
|
|
84
|
+
envVars?: {
|
|
85
|
+
[key: string]: (string);
|
|
86
|
+
} | null;
|
|
87
|
+
serverStartCheck?: boolean;
|
|
88
|
+
};
|
|
89
|
+
type FreestyleDeployWebErrorResponse = {
|
|
90
|
+
message: string;
|
|
91
|
+
};
|
|
92
|
+
type FreestyleDeployWebPayload = {
|
|
93
|
+
/**
|
|
94
|
+
* The files to deploy, a map of file paths to file contents, e.g. { \"index.js\": {\"content\": \"your main\", \"encoding\": \"utf-8\"}, \"file2.js\": {\"content\": \"your helper\" } }
|
|
95
|
+
*
|
|
96
|
+
* **Do not include node modules in this bundle, they will not work**. Instead, includes a package-lock.json, bun.lockb, pnpm-lock.yaml, or yarn.lock, the node modules for the project will be installed from that lock file, or use the node_modules field in the configuration to specify the node modules to install.
|
|
97
|
+
*/
|
|
98
|
+
files: {
|
|
99
|
+
[key: string]: FreestyleFile;
|
|
100
|
+
};
|
|
101
|
+
config?: FreestyleDeployWebConfiguration;
|
|
102
|
+
};
|
|
103
|
+
type FreestyleDeployWebSuccessResponse = {
|
|
104
|
+
deploymentId: string;
|
|
105
|
+
domains?: Array<(string)> | null;
|
|
106
|
+
/**
|
|
107
|
+
* @deprecated
|
|
108
|
+
*/
|
|
109
|
+
projectId?: (string) | null;
|
|
110
|
+
};
|
|
111
|
+
type FreestyleDomainVerificationRequest = {
|
|
112
|
+
/**
|
|
113
|
+
* The domain to create a verification code for
|
|
114
|
+
*/
|
|
115
|
+
domain: string;
|
|
116
|
+
};
|
|
117
|
+
type FreestyleExecuteScriptParams = {
|
|
118
|
+
/**
|
|
119
|
+
* The JavaScript or TypeScript script to execute
|
|
120
|
+
*/
|
|
121
|
+
script: string;
|
|
122
|
+
config?: FreestyleExecuteScriptParamsConfiguration;
|
|
123
|
+
};
|
|
124
|
+
type FreestyleExecuteScriptParamsConfiguration = {
|
|
125
|
+
/**
|
|
126
|
+
* The environment variables to set for the script
|
|
127
|
+
*/
|
|
128
|
+
envVars?: {
|
|
129
|
+
[key: string]: (string);
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* The node modules to install for the script
|
|
133
|
+
*/
|
|
134
|
+
nodeModules?: {
|
|
135
|
+
[key: string]: (string);
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Tags for you to organize your scripts, useful for tracking what you're running
|
|
139
|
+
*/
|
|
140
|
+
tags?: Array<(string)>;
|
|
141
|
+
/**
|
|
142
|
+
* The script timeout
|
|
143
|
+
*/
|
|
144
|
+
timeout?: (string) | null;
|
|
145
|
+
/**
|
|
146
|
+
* If false, we'll not resolve peer dependencies for the packages given, this can speed up execute performance, but will break packages with peers unless the peers are manually specified.
|
|
147
|
+
*/
|
|
148
|
+
peerDependencyResolution?: boolean;
|
|
149
|
+
};
|
|
150
|
+
type FreestyleExecuteScriptResultSuccess = {
|
|
151
|
+
result: unknown;
|
|
152
|
+
logs: Array<FreestyleJavaScriptLog>;
|
|
153
|
+
};
|
|
154
|
+
type FreestyleFile = {
|
|
155
|
+
/**
|
|
156
|
+
* The content of the file
|
|
157
|
+
*/
|
|
158
|
+
content: string;
|
|
159
|
+
/**
|
|
160
|
+
* The encoding of the file. Either **utf-8** or **base64**
|
|
161
|
+
*/
|
|
162
|
+
encoding?: string;
|
|
163
|
+
};
|
|
164
|
+
type FreestyleJavaScriptLog = {
|
|
165
|
+
/**
|
|
166
|
+
* The log message
|
|
167
|
+
*/
|
|
168
|
+
message: string;
|
|
169
|
+
/**
|
|
170
|
+
* The log level
|
|
171
|
+
*/
|
|
172
|
+
type: string;
|
|
173
|
+
};
|
|
174
|
+
type FreestyleLogResponseObject = {
|
|
175
|
+
message: string;
|
|
176
|
+
timestamp: string;
|
|
177
|
+
};
|
|
178
|
+
type FreestyleVerifyDomainRequest = {
|
|
179
|
+
domain: string;
|
|
180
|
+
};
|
|
181
|
+
type HandleDeployCloudstateData = {
|
|
182
|
+
body: FreestyleCloudstateDeployRequest;
|
|
183
|
+
};
|
|
184
|
+
type HandleDeployCloudstateResponse = (FreestyleCloudstateDeploySuccessResponse);
|
|
185
|
+
type HandleDeployCloudstateError = (FreestyleCloudstateDeployErrorResponse);
|
|
186
|
+
type HandleBackupCloudstateData = {
|
|
187
|
+
path: {
|
|
188
|
+
id: string;
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
type HandleBackupCloudstateResponse = (Array<(number)>);
|
|
192
|
+
type HandleBackupCloudstateError = (unknown);
|
|
193
|
+
type HandleVerifyWildcardResponse = ({
|
|
194
|
+
domain: string;
|
|
195
|
+
});
|
|
196
|
+
type HandleVerifyWildcardError = ({
|
|
197
|
+
message: string;
|
|
198
|
+
});
|
|
199
|
+
type HandleListDomainsResponse = (Array<{
|
|
200
|
+
domain: string;
|
|
201
|
+
createdAt: number;
|
|
202
|
+
}>);
|
|
203
|
+
type HandleListDomainsError = ({
|
|
204
|
+
message: string;
|
|
205
|
+
});
|
|
206
|
+
type HandleListDomainVerificationRequestsResponse = (Array<{
|
|
207
|
+
verificationCode: string;
|
|
208
|
+
domain: string;
|
|
209
|
+
createdAt: number;
|
|
210
|
+
}>);
|
|
211
|
+
type HandleListDomainVerificationRequestsError = ({
|
|
212
|
+
message: string;
|
|
213
|
+
});
|
|
214
|
+
type HandleVerifyDomainData = {
|
|
215
|
+
body: FreestyleVerifyDomainRequest;
|
|
216
|
+
};
|
|
217
|
+
type HandleVerifyDomainResponse = ({
|
|
218
|
+
domain: string;
|
|
219
|
+
});
|
|
220
|
+
type HandleVerifyDomainError = ({
|
|
221
|
+
message: string;
|
|
222
|
+
});
|
|
223
|
+
type HandleCreateDomainVerificationData = {
|
|
224
|
+
body: FreestyleDomainVerificationRequest;
|
|
225
|
+
};
|
|
226
|
+
type HandleCreateDomainVerificationResponse = ({
|
|
227
|
+
verificationCode: string;
|
|
228
|
+
domain: string;
|
|
229
|
+
});
|
|
230
|
+
type HandleCreateDomainVerificationError = ({
|
|
231
|
+
message: string;
|
|
232
|
+
});
|
|
233
|
+
type HandleDeleteDomainVerificationData = {
|
|
234
|
+
body: FreestyleDeleteDomainVerificationRequest;
|
|
235
|
+
};
|
|
236
|
+
type HandleDeleteDomainVerificationResponse = ({
|
|
237
|
+
verificationCode: string;
|
|
238
|
+
domain: string;
|
|
239
|
+
});
|
|
240
|
+
type HandleDeleteDomainVerificationError = ({
|
|
241
|
+
message: string;
|
|
242
|
+
});
|
|
243
|
+
type HandleListExecuteRunsData = {
|
|
244
|
+
query?: {
|
|
245
|
+
limit?: (number) | null;
|
|
246
|
+
offset?: (number) | null;
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
type HandleListExecuteRunsResponse = ({
|
|
250
|
+
entries: Array<ExecuteLogEntry>;
|
|
251
|
+
total: number;
|
|
252
|
+
offset: number;
|
|
253
|
+
});
|
|
254
|
+
type HandleListExecuteRunsError = ({
|
|
255
|
+
message: string;
|
|
256
|
+
});
|
|
257
|
+
type HandleGetExecuteRunData = {
|
|
258
|
+
path: {
|
|
259
|
+
deployment: string;
|
|
260
|
+
};
|
|
261
|
+
};
|
|
262
|
+
type HandleGetExecuteRunResponse = (ExecuteLogEntry);
|
|
263
|
+
type HandleGetExecuteRunError = ({
|
|
264
|
+
message: string;
|
|
265
|
+
});
|
|
266
|
+
type HandleExecuteScriptData = {
|
|
267
|
+
body: FreestyleExecuteScriptParams;
|
|
268
|
+
};
|
|
269
|
+
type HandleExecuteScriptResponse = ({
|
|
270
|
+
result: unknown;
|
|
271
|
+
logs: Array<FreestyleJavaScriptLog>;
|
|
272
|
+
});
|
|
273
|
+
type HandleExecuteScriptError = ({
|
|
274
|
+
error: string;
|
|
275
|
+
});
|
|
276
|
+
type HandleGetLogsData = {
|
|
277
|
+
query: {
|
|
278
|
+
deploymentId: string;
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
type HandleGetLogsResponse = (Array<FreestyleLogResponseObject>);
|
|
282
|
+
type HandleGetLogsError = unknown;
|
|
283
|
+
type HandleDeployWebData = {
|
|
284
|
+
body: FreestyleDeployWebPayload;
|
|
285
|
+
};
|
|
286
|
+
type HandleDeployWebResponse = (FreestyleDeployWebSuccessResponse);
|
|
287
|
+
type HandleDeployWebError = (FreestyleDeployWebErrorResponse);
|
|
288
|
+
type HandleListWebDeploysResponse = ({
|
|
289
|
+
entries: Array<DeploymentLogEntry>;
|
|
290
|
+
total: number;
|
|
291
|
+
offset: number;
|
|
292
|
+
});
|
|
293
|
+
type HandleListWebDeploysError = ({
|
|
294
|
+
message: string;
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
export type { HandleGetLogsData as $, FreestyleJavaScriptLog as A, FreestyleLogResponseObject as B, FreestyleVerifyDomainRequest as C, DeploymentLogEntry as D, ExecuteLogEntry as E, FreestyleExecuteScriptParamsConfiguration as F, HandleDeployCloudstateData as G, HandleBackupCloudstateResponse as H, HandleDeployCloudstateResponse as I, HandleDeployCloudstateError as J, HandleBackupCloudstateData as K, HandleBackupCloudstateError as L, HandleVerifyWildcardError as M, HandleListDomainsError as N, HandleListDomainVerificationRequestsError as O, HandleVerifyDomainData as P, HandleCreateDomainVerificationData as Q, HandleCreateDomainVerificationError as R, HandleDeleteDomainVerificationData as S, HandleDeleteDomainVerificationError as T, HandleListExecuteRunsData as U, HandleListExecuteRunsError as V, HandleGetExecuteRunData as W, HandleGetExecuteRunError as X, HandleExecuteScriptData as Y, HandleExecuteScriptResponse as Z, HandleExecuteScriptError as _, FreestyleExecuteScriptResultSuccess as a, HandleGetLogsError as a0, HandleDeployWebData as a1, HandleDeployWebResponse as a2, HandleDeployWebError as a3, HandleListWebDeploysError as a4, FreestyleDeployWebConfiguration as b, FreestyleDeployWebSuccessResponse as c, FreestyleCloudstateDeployRequest as d, FreestyleCloudstateDeploySuccessResponse as e, HandleGetLogsResponse as f, HandleCreateDomainVerificationResponse as g, HandleVerifyDomainResponse as h, HandleVerifyDomainError as i, HandleListDomainsResponse as j, HandleListDomainVerificationRequestsResponse as k, HandleDeleteDomainVerificationResponse as l, HandleListWebDeploysResponse as m, HandleListExecuteRunsResponse as n, HandleGetExecuteRunResponse as o, HandleVerifyWildcardResponse as p, DeploymentState as q, ExecuteRunState as r, FreestyleCloudstateDeployConfiguration as s, FreestyleCloudstateDeployErrorResponse as t, FreestyleDeleteDomainVerificationRequest as u, FreestyleDeployWebErrorResponse as v, FreestyleDeployWebPayload as w, FreestyleDomainVerificationRequest as x, FreestyleExecuteScriptParams as y, FreestyleFile as z };
|
package/openapi/sdk.gen.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
2
|
|
|
3
3
|
import { createClient, createConfig, type OptionsLegacyParser } from '@hey-api/client-fetch';
|
|
4
|
-
import type { HandleDeployCloudstateData, HandleDeployCloudstateError, HandleDeployCloudstateResponse, HandleBackupCloudstateData, HandleBackupCloudstateError, HandleBackupCloudstateResponse, HandleListDomainsError, HandleListDomainsResponse, HandleListDomainVerificationRequestsError, HandleListDomainVerificationRequestsResponse, HandleVerifyDomainData, HandleVerifyDomainError, HandleVerifyDomainResponse, HandleCreateDomainVerificationData, HandleCreateDomainVerificationError, HandleCreateDomainVerificationResponse, HandleDeleteDomainVerificationData, HandleDeleteDomainVerificationError, HandleDeleteDomainVerificationResponse, HandleExecuteScriptData, HandleExecuteScriptError, HandleExecuteScriptResponse, HandleDeployWebData, HandleDeployWebError, HandleDeployWebResponse,
|
|
4
|
+
import type { HandleDeployCloudstateData, HandleDeployCloudstateError, HandleDeployCloudstateResponse, HandleBackupCloudstateData, HandleBackupCloudstateError, HandleBackupCloudstateResponse, HandleVerifyWildcardError, HandleVerifyWildcardResponse, HandleListDomainsError, HandleListDomainsResponse, HandleListDomainVerificationRequestsError, HandleListDomainVerificationRequestsResponse, HandleVerifyDomainData, HandleVerifyDomainError, HandleVerifyDomainResponse, HandleCreateDomainVerificationData, HandleCreateDomainVerificationError, HandleCreateDomainVerificationResponse, HandleDeleteDomainVerificationData, HandleDeleteDomainVerificationError, HandleDeleteDomainVerificationResponse, HandleListExecuteRunsData, HandleListExecuteRunsError, HandleListExecuteRunsResponse, HandleGetExecuteRunData, HandleGetExecuteRunError, HandleGetExecuteRunResponse, HandleExecuteScriptData, HandleExecuteScriptError, HandleExecuteScriptResponse, HandleGetLogsData, HandleGetLogsError, HandleGetLogsResponse, HandleDeployWebData, HandleDeployWebError, HandleDeployWebResponse, HandleListWebDeploysError, HandleListWebDeploysResponse } from './types.gen';
|
|
5
5
|
|
|
6
6
|
export const client = createClient(createConfig());
|
|
7
7
|
|
|
@@ -27,6 +27,23 @@ export const handleBackupCloudstate = <ThrowOnError extends boolean = false>(opt
|
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Provision a wildcard certificate
|
|
32
|
+
* Provisions a wildcard certificate for a verified domain
|
|
33
|
+
*
|
|
34
|
+
*
|
|
35
|
+
* This speeds up deploys on all subdomains of the domain. In order to use it, you must add the following record to your DNS config:
|
|
36
|
+
*
|
|
37
|
+
* `_acme-challenge.yourdomain.com` NS `dns.freestyle.sh`
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
export const handleVerifyWildcard = <ThrowOnError extends boolean = false>(options?: OptionsLegacyParser<unknown, ThrowOnError>) => {
|
|
41
|
+
return (options?.client ?? client).post<HandleVerifyWildcardResponse, HandleVerifyWildcardError, ThrowOnError>({
|
|
42
|
+
...options,
|
|
43
|
+
url: '/domains/v1/certs/{domain}/wildcard'
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
30
47
|
/**
|
|
31
48
|
* List domains for an account
|
|
32
49
|
* This lists the domains that an account has verified ownership of. This includes the *.style.dev domains the account has claimed.
|
|
@@ -82,6 +99,28 @@ export const handleDeleteDomainVerification = <ThrowOnError extends boolean = fa
|
|
|
82
99
|
});
|
|
83
100
|
};
|
|
84
101
|
|
|
102
|
+
/**
|
|
103
|
+
* List execute runs
|
|
104
|
+
* List execute runs.
|
|
105
|
+
*/
|
|
106
|
+
export const handleListExecuteRuns = <ThrowOnError extends boolean = false>(options?: OptionsLegacyParser<HandleListExecuteRunsData, ThrowOnError>) => {
|
|
107
|
+
return (options?.client ?? client).get<HandleListExecuteRunsResponse, HandleListExecuteRunsError, ThrowOnError>({
|
|
108
|
+
...options,
|
|
109
|
+
url: '/execute/v1/deployments'
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Get information on execute run
|
|
115
|
+
* Get information on execute run
|
|
116
|
+
*/
|
|
117
|
+
export const handleGetExecuteRun = <ThrowOnError extends boolean = false>(options: OptionsLegacyParser<HandleGetExecuteRunData, ThrowOnError>) => {
|
|
118
|
+
return (options?.client ?? client).get<HandleGetExecuteRunResponse, HandleGetExecuteRunError, ThrowOnError>({
|
|
119
|
+
...options,
|
|
120
|
+
url: '/execute/v1/deployments/{deployment}'
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
|
|
85
124
|
/**
|
|
86
125
|
* Execute Code
|
|
87
126
|
* Send a TypeScript or JavaScript module, get the result
|
|
@@ -93,6 +132,17 @@ export const handleExecuteScript = <ThrowOnError extends boolean = false>(option
|
|
|
93
132
|
});
|
|
94
133
|
};
|
|
95
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Deployment Logs
|
|
137
|
+
* Get the logs for a deployment
|
|
138
|
+
*/
|
|
139
|
+
export const handleGetLogs = <ThrowOnError extends boolean = false>(options: OptionsLegacyParser<HandleGetLogsData, ThrowOnError>) => {
|
|
140
|
+
return (options?.client ?? client).get<HandleGetLogsResponse, HandleGetLogsError, ThrowOnError>({
|
|
141
|
+
...options,
|
|
142
|
+
url: '/observability/v1/logs'
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
|
|
96
146
|
/**
|
|
97
147
|
* Deploy a Website
|
|
98
148
|
* Deploy a website. Files is a map of file paths to file contents. Configuration is optional and contains additional information about the deployment.
|
|
@@ -105,12 +155,12 @@ export const handleDeployWeb = <ThrowOnError extends boolean = false>(options: O
|
|
|
105
155
|
};
|
|
106
156
|
|
|
107
157
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
158
|
+
* List web deploys
|
|
159
|
+
* List web deploys.
|
|
110
160
|
*/
|
|
111
|
-
export const
|
|
112
|
-
return (options?.client ?? client).get<
|
|
161
|
+
export const handleListWebDeploys = <ThrowOnError extends boolean = false>(options?: OptionsLegacyParser<unknown, ThrowOnError>) => {
|
|
162
|
+
return (options?.client ?? client).get<HandleListWebDeploysResponse, HandleListWebDeploysError, ThrowOnError>({
|
|
113
163
|
...options,
|
|
114
|
-
url: '/web/v1/
|
|
164
|
+
url: '/web/v1/deployments'
|
|
115
165
|
});
|
|
116
166
|
};
|
package/openapi/types.gen.ts
CHANGED
|
@@ -1,16 +1,46 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
2
|
|
|
3
|
+
export type DeploymentLogEntry = {
|
|
4
|
+
deploymentId: string;
|
|
5
|
+
accountId: string;
|
|
6
|
+
provisionedAt: string;
|
|
7
|
+
timeout: string;
|
|
8
|
+
state: DeploymentState;
|
|
9
|
+
deployedAt?: (string) | null;
|
|
10
|
+
domains: Array<(string)>;
|
|
11
|
+
envVars: {
|
|
12
|
+
[key: string]: (string);
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type DeploymentState = 'provisioning' | 'deployed' | 'failed';
|
|
17
|
+
|
|
18
|
+
export type ExecuteLogEntry = {
|
|
19
|
+
deployment: string;
|
|
20
|
+
account_id: string;
|
|
21
|
+
provisioned_at: string;
|
|
22
|
+
started_at?: (string) | null;
|
|
23
|
+
duration?: (string) | null;
|
|
24
|
+
state: ExecuteRunState;
|
|
25
|
+
env_vars: {
|
|
26
|
+
[key: string]: (string);
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type ExecuteRunState = 'starting' | 'running' | 'complete';
|
|
31
|
+
|
|
3
32
|
export type FreestyleCloudstateDeployConfiguration = {
|
|
4
33
|
/**
|
|
5
34
|
* ID of the project to deploy, if not provided will create a new project
|
|
6
35
|
*/
|
|
7
|
-
|
|
36
|
+
domains?: Array<(string)> | null;
|
|
8
37
|
/**
|
|
9
38
|
* The environment variables that the cloudstate deploy can access
|
|
10
39
|
*/
|
|
11
40
|
envVars?: {
|
|
12
41
|
[key: string]: (string);
|
|
13
42
|
};
|
|
43
|
+
cloudstateDatabaseId?: (string) | null;
|
|
14
44
|
};
|
|
15
45
|
|
|
16
46
|
export type FreestyleCloudstateDeployErrorResponse = {
|
|
@@ -23,10 +53,8 @@ export type FreestyleCloudstateDeployRequest = {
|
|
|
23
53
|
};
|
|
24
54
|
|
|
25
55
|
export type FreestyleCloudstateDeploySuccessResponse = {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*/
|
|
29
|
-
projectId: string;
|
|
56
|
+
deploymentId: string;
|
|
57
|
+
cloudstateDatabaseId: string;
|
|
30
58
|
};
|
|
31
59
|
|
|
32
60
|
export type FreestyleDeleteDomainVerificationRequest = {
|
|
@@ -102,15 +130,6 @@ export type FreestyleDomainVerificationRequest = {
|
|
|
102
130
|
domain: string;
|
|
103
131
|
};
|
|
104
132
|
|
|
105
|
-
export type FreestyleExecureScriptResultError = {
|
|
106
|
-
error: string;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export type FreestyleExecureScriptResultSuccess = {
|
|
110
|
-
result: unknown;
|
|
111
|
-
logs: Array<JavaScriptLog>;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
133
|
export type FreestyleExecuteScriptParams = {
|
|
115
134
|
/**
|
|
116
135
|
* The JavaScript or TypeScript script to execute
|
|
@@ -146,6 +165,11 @@ export type FreestyleExecuteScriptParamsConfiguration = {
|
|
|
146
165
|
peerDependencyResolution?: boolean;
|
|
147
166
|
};
|
|
148
167
|
|
|
168
|
+
export type FreestyleExecuteScriptResultSuccess = {
|
|
169
|
+
result: unknown;
|
|
170
|
+
logs: Array<FreestyleJavaScriptLog>;
|
|
171
|
+
};
|
|
172
|
+
|
|
149
173
|
export type FreestyleFile = {
|
|
150
174
|
/**
|
|
151
175
|
* The content of the file
|
|
@@ -157,15 +181,7 @@ export type FreestyleFile = {
|
|
|
157
181
|
encoding?: string;
|
|
158
182
|
};
|
|
159
183
|
|
|
160
|
-
export type
|
|
161
|
-
message: string;
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
export type FreestyleVerifyDomainRequest = {
|
|
165
|
-
domain: string;
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
export type JavaScriptLog = {
|
|
184
|
+
export type FreestyleJavaScriptLog = {
|
|
169
185
|
/**
|
|
170
186
|
* The log message
|
|
171
187
|
*/
|
|
@@ -176,6 +192,15 @@ export type JavaScriptLog = {
|
|
|
176
192
|
type: string;
|
|
177
193
|
};
|
|
178
194
|
|
|
195
|
+
export type FreestyleLogResponseObject = {
|
|
196
|
+
message: string;
|
|
197
|
+
timestamp: string;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export type FreestyleVerifyDomainRequest = {
|
|
201
|
+
domain: string;
|
|
202
|
+
};
|
|
203
|
+
|
|
179
204
|
export type HandleDeployCloudstateData = {
|
|
180
205
|
body: FreestyleCloudstateDeployRequest;
|
|
181
206
|
};
|
|
@@ -194,6 +219,14 @@ export type HandleBackupCloudstateResponse = (Array<(number)>);
|
|
|
194
219
|
|
|
195
220
|
export type HandleBackupCloudstateError = (unknown);
|
|
196
221
|
|
|
222
|
+
export type HandleVerifyWildcardResponse = ({
|
|
223
|
+
domain: string;
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
export type HandleVerifyWildcardError = ({
|
|
227
|
+
message: string;
|
|
228
|
+
});
|
|
229
|
+
|
|
197
230
|
export type HandleListDomainsResponse = (Array<{
|
|
198
231
|
domain: string;
|
|
199
232
|
createdAt: number;
|
|
@@ -251,13 +284,57 @@ export type HandleDeleteDomainVerificationError = ({
|
|
|
251
284
|
message: string;
|
|
252
285
|
});
|
|
253
286
|
|
|
287
|
+
export type HandleListExecuteRunsData = {
|
|
288
|
+
query?: {
|
|
289
|
+
limit?: (number) | null;
|
|
290
|
+
offset?: (number) | null;
|
|
291
|
+
};
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
export type HandleListExecuteRunsResponse = ({
|
|
295
|
+
entries: Array<ExecuteLogEntry>;
|
|
296
|
+
total: number;
|
|
297
|
+
offset: number;
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
export type HandleListExecuteRunsError = ({
|
|
301
|
+
message: string;
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
export type HandleGetExecuteRunData = {
|
|
305
|
+
path: {
|
|
306
|
+
deployment: string;
|
|
307
|
+
};
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
export type HandleGetExecuteRunResponse = (ExecuteLogEntry);
|
|
311
|
+
|
|
312
|
+
export type HandleGetExecuteRunError = ({
|
|
313
|
+
message: string;
|
|
314
|
+
});
|
|
315
|
+
|
|
254
316
|
export type HandleExecuteScriptData = {
|
|
255
317
|
body: FreestyleExecuteScriptParams;
|
|
256
318
|
};
|
|
257
319
|
|
|
258
|
-
export type HandleExecuteScriptResponse = (
|
|
320
|
+
export type HandleExecuteScriptResponse = ({
|
|
321
|
+
result: unknown;
|
|
322
|
+
logs: Array<FreestyleJavaScriptLog>;
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
export type HandleExecuteScriptError = ({
|
|
326
|
+
error: string;
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
export type HandleGetLogsData = {
|
|
330
|
+
query: {
|
|
331
|
+
deploymentId: string;
|
|
332
|
+
};
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
export type HandleGetLogsResponse = (Array<FreestyleLogResponseObject>);
|
|
259
336
|
|
|
260
|
-
export type
|
|
337
|
+
export type HandleGetLogsError = unknown;
|
|
261
338
|
|
|
262
339
|
export type HandleDeployWebData = {
|
|
263
340
|
body: FreestyleDeployWebPayload;
|
|
@@ -267,12 +344,12 @@ export type HandleDeployWebResponse = (FreestyleDeployWebSuccessResponse);
|
|
|
267
344
|
|
|
268
345
|
export type HandleDeployWebError = (FreestyleDeployWebErrorResponse);
|
|
269
346
|
|
|
270
|
-
export type
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
export type HandleGetLogsResponse = (Array<FreestyleLogResponseObject>);
|
|
347
|
+
export type HandleListWebDeploysResponse = ({
|
|
348
|
+
entries: Array<DeploymentLogEntry>;
|
|
349
|
+
total: number;
|
|
350
|
+
offset: number;
|
|
351
|
+
});
|
|
277
352
|
|
|
278
|
-
export type
|
|
353
|
+
export type HandleListWebDeploysError = ({
|
|
354
|
+
message: string;
|
|
355
|
+
});
|
package/openapi.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"openapi":"3.1.0","info":{"title":"Freestyle Sandboxes","description":"\nFreestyle Sandboxes lets you deploy your users or AIs code. **Get your API Key at [admin.freestyle.sh](https://admin.freestyle.sh)**\n\nThey are broken up into 4 categories: [Web](#tag/web), [Execute](#tag/execute), [Cloudstate](#tag/cloudstate), and [Domains](#tag/domains).\n\n[Web](#tag/web): Send us the code for the website, we'll provision the certificates and get it hosted\n\n[Execute](#tag/execute): Send us a function, we'll run it and send you the output\n\n[Cloudstate](#tag/cloudstate): Our Opensource JavaScript Runtime used for cloud functions with persistent state\n\n[Domains](#tag/domains): Manage your domains, including verification and listing\n","contact":{"name":"Ben","email":"ben@freestyle.sh"},"license":{"name":""},"version":"0.1.0"},"servers":[{"url":"https://api.freestyle.sh","description":"Production"}],"paths":{"/cloudstate/v1/deploy":{"post":{"tags":["Cloudstate"],"summary":"Deploy Cloudstate Project","description":"Deploy a cloudstate project","operationId":"handle_deploy_cloudstate","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleCloudstateDeployRequest"}}},"required":true},"responses":{"200":{"description":"successfully deployed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleCloudstateDeploySuccessResponse"}}}},"500":{"description":"failed to deploy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleCloudstateDeployErrorResponse"}}}}}}},"/cloudstate/v1/projects/{id}/backup":{"get":{"tags":["Cloudstate"],"summary":"Get Backup of Cloudstate Project","description":"Get a backup of a cloudstate project","operationId":"handle_backup_cloudstate","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"successfully backed up","content":{"application/octet-stream":{"schema":{"type":"array","items":{"type":"integer","format":"int32","minimum":0}}}}},"500":{"description":"failed to backup"}}}},"/domains/v1/domains":{"get":{"tags":["Domains"],"summary":"List domains for an account","description":"This lists the domains that an account has verified ownership of. This includes the *.style.dev domains the account has claimed.","operationId":"handle_list_domains","responses":{"200":{"description":"List of domains","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","required":["domain","createdAt"],"properties":{"domain":{"type":"string","example":"example.yourdomain.com"},"createdAt":{"type":"integer","format":"int64"}}}}}}},"400":{"description":"Failed to get domains","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}},"x-codeSamples":[{"label":"Human SDK","lang":"JavaScript","source":"import { FreestyleSandboxes } from 'freestyle-sandboxes';\n\nconst sandboxes = new FreestyleSandboxes({\n apiKey: 'your-api-key',\n});\n\nsandboxes.listDomains().then((response) => {\n console.log(response);\n});"}]}},"/domains/v1/verifications":{"get":{"tags":["Domains"],"summary":"List domain verification requests for an account","description":"Lists domain verification requests for the current account.","operationId":"handle_list_domain_verification_requests","responses":{"200":{"description":"List of verification codes","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","required":["verificationCode","domain","createdAt"],"properties":{"verificationCode":{"type":"string"},"domain":{"type":"string"},"createdAt":{"type":"integer","format":"int64"}}}}}}},"400":{"description":"Failed to get verification codes","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}}},"put":{"tags":["Domains"],"summary":"Verify a domain","description":"This checks a pre-existing verification request for a domain. To create a verification request, call the [create domain verification](/#tag/domains/POST/domains/v1/verifications) endpoint. This endpoint will check if the domain has a TXT record with the verification code. If it does, the domain will be verified.","operationId":"handle_verify_domain","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleVerifyDomainRequest"}}},"required":true},"responses":{"200":{"description":"Domain verified","content":{"application/json":{"schema":{"type":"object","required":["domain"],"properties":{"domain":{"type":"string","example":"example.com"}}}}}},"400":{"description":"Failed to verify domain","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}},"x-codeSamples":[{"label":"Human SDK","lang":"JavaScript","source":"import { FreestyleSandboxes } from 'freestyle-sandboxes';\n\nconst api = new FreestyleSandboxes({\n apiKey: process.env.FREESTYLE_API_KEY!,\n});\n\napi\n .verifyDomain('example.com')\n .then((result) => {\n console.log('Successfully Verified Domain!');\n })\n .catch((error) => {\n console.error('Failed to verify domain: ', error);\n });"}]},"post":{"tags":["Domains"],"summary":"Create a domain verification request","description":"This creates a Freestyle Domain Verification Request. It returns a `verificationCode` for your domain. You need to place this code in a TXT record at `_freestyle_custom_hostname.thedomain.com`, then call the [verify domain](/#tag/domains/PUT/domains/v1/verifications) endpoint with the domain to verify it.","operationId":"handle_create_domain_verification","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleDomainVerificationRequest"}}},"required":true},"responses":{"200":{"description":"Verification code created","content":{"application/json":{"schema":{"type":"object","required":["verificationCode","domain"],"properties":{"verificationCode":{"type":"string"},"domain":{"type":"string","example":"example.com"}}}}}},"400":{"description":"Failed to create verification code","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}},"x-codeSamples":[{"label":"Human SDK","lang":"JavaScript","source":"import { FreestyleSandboxes } from 'freestyle-sandboxes';\n\nconst api = new FreestyleSandboxes({\n apiKey: process.env.FREESTYLE_API_KEY!,\n});\n\napi.createDomainVerificationRequest('example.com').then((result) => {\n const verificationCode = result.verificationCode;\n // put this at a TXT record at _freestyle_custom_hostname.example.com\n});"}]},"delete":{"tags":["Domains"],"summary":"Delete a domain verification request","description":"This deletes a Freestyle Domain Verification Request. This does not remove the domain from the account if it has already been verified, however the verification code will no longer be valid.","operationId":"handle_delete_domain_verification","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleDeleteDomainVerificationRequest"}}},"required":true},"responses":{"200":{"description":"Verification code created","content":{"application/json":{"schema":{"type":"object","required":["verificationCode","domain"],"properties":{"verificationCode":{"type":"string"},"domain":{"type":"string","example":"example.com"}}}}}},"400":{"description":"Failed to create verification code","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}}}},"/execute/v1/script":{"post":{"tags":["Execute"],"summary":"Execute Code","description":"Send a TypeScript or JavaScript module, get the result","operationId":"handle_execute_script","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleExecuteScriptParams"}}},"required":true},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleExecureScriptResultSuccess"}}}},"400":{"description":"Error in your Script","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleExecureScriptResultError"}}}},"500":{"description":"Internal Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleExecureScriptResultError"}}}}},"x-codeSamples":[{"label":"Human SDK","lang":"JavaScript","source":"import { FreestyleSandboxes } from 'freestyle-sandboxes';\n\nconst sandboxes = new FreestyleSandboxes({\n apiKey: 'your-api-key',\n});\n\nsandboxes.executeScript(\n `export default () => {\n let set1 = [1, 2, 3, 4, 5];\n let set2 = [4, 5, 6, 7, 8];\n\n // find the sum of every value of each set multiplied by every value of the other set\n\n let sum = 0;\n for (let i = 0; i < set1.length; i++) {\n for (let j = 0; j < set2.length; j++) {\n sum += set1[i] * set2[j];\n }\n }\n\n return sum;\n};`\n);"},{"label":"Vercel AI SDK","lang":"JavaScript","source":"import { executeTool } from 'freestyle-sandboxes/ai';\nimport { generateText } from 'ai';\n\nconst codeExecutor = executeTool({\n apiKey: 'your-api-key',\n});\n\nconst { text, steps } = await generateText({\n model: yourModel,\n tools: {\n codeExecutor,\n },\n maxSteps: 2,\n prompt:\n 'What is the sum of every number between 1 and 12 multiplied by itself?',\n});"},{"label":"Mastra AI SDK","lang":"JavaScript","source":"import { executeTool } from 'freestyle-sandboxes/mastra';\n\nconst mastra = new Mastra();\n\nconst modelConfig: ModelConfig = {\n provider: 'OPEN_AI',\n name: 'gpt-4',\n};\n\nconst llm = mastra.LLM(modelConfig);\n\nconst response = await llm.generate(\n 'Calculate the sum of every number between 13 and 19 divided by the sum of every number between 8 and 13',\n {\n tools: {\n executor: executeTool({\n apiKey: process.env.FREESTYLE_API_KEY!,\n }),\n },\n }\n);\n\nconsole.log('Response Steps:', response.steps);\nconsole.log('Response:', response.text);"}]}},"/web/v1/deploy":{"post":{"tags":["Web"],"summary":"Deploy a Website","description":"Deploy a website. Files is a map of file paths to file contents. Configuration is optional and contains additional information about the deployment.","operationId":"handle_deploy_web","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleDeployWebPayload"}}},"required":true},"responses":{"200":{"description":"successfully deployed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleDeployWebSuccessResponse"}}}},"400":{"description":"failed to deploy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleDeployWebErrorResponse"}}}}},"x-codeSamples":[{"label":"Human SDK","lang":"JavaScript","source":"import { FreestyleSandboxes } from 'freestyle-sandboxes';\nimport 'dotenv/config';\n\nconst api = new FreestyleSandboxes({\n apiKey: process.env.FREESTYLE_API_KEY!,\n});\n\napi\n .deployWeb({\n 'index.js': {\n content:`\n import http from 'node:http';\n console.log('starting server');\n\n const server = http.createServer(async(req, res) => {\n // wait 5 seconds before responding\n // await new Promise((resolve) => setTimeout(resolve, 5000));\n res.writeHead(200, { 'Content-Type': 'text/plain' });\n res.end('Welcome to New York its been waiting for you');\n });\n\n server.listen(3000, () => {\n console.log('Server is running at http://localhost:3000');\n });`,\n })\n .then((result) => {\n console.log('Deployed website @ ', result.deploymentId);\n });\n"},{"label":"Vercel AI SDK","lang":"JavaScript","source":"import { deployWebTool } from 'freestyle-sandboxes/ai';\nimport { generateText } from 'ai';\n\nconst deployer = deployWebTool({\n apiKey: 'your-api-key',\n});\n\nconst { text, steps } = await generateText({\n model: yourModel,\n tools: {\n deployer,\n },\n maxSteps: 2,\n prompt:\n 'Deploy a website to subdomain.yourdomain.com that has all the lyrics to Sandstorm by Darude on the homepage',\n});"}]}},"/web/v1/projects/{id}/logs":{"get":{"tags":["Web"],"summary":"Get Website Logs","description":"Get the logs for a project","operationId":"handle_get_logs","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/FreestyleLogResponseObject"}}}}}},"x-codeSamples":[{"label":"Human SDK","lang":"JavaScript","source":"import { FreestyleSandboxes } from 'freestyle-sandboxes';\nimport 'dotenv/config';\n\nconst api = new FreestyleSandboxes({\n apiKey: process.env.FREESTYLE_API_KEY!,\n});\n\napi.getWebLogs('1234abcd-5678-efgh-ijkl-9012mnop3456').then((logs) => {\n console.log('Logs for project 1234abcd-5678-efgh-ijkl-9012mnop3456: ', logs);\n});"}]}}},"components":{"schemas":{"FreestyleCloudstateDeployConfiguration":{"type":"object","properties":{"projectId":{"type":["string","null"],"description":"ID of the project to deploy, if not provided will create a new project","default":null},"envVars":{"type":"object","description":"The environment variables that the cloudstate deploy can access","default":{},"additionalProperties":{"type":"string"},"propertyNames":{"type":"string"}}}},"FreestyleCloudstateDeployErrorResponse":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}},"FreestyleCloudstateDeployRequest":{"type":"object","required":["classes"],"properties":{"classes":{"type":"string"},"config":{"$ref":"#/components/schemas/FreestyleCloudstateDeployConfiguration"}}},"FreestyleCloudstateDeploySuccessResponse":{"type":"object","required":["projectId"],"properties":{"projectId":{"type":"string","description":"The id of the project deployed to"}}},"FreestyleDeleteDomainVerificationRequest":{"type":"object","required":["domain","verificationCode"],"properties":{"domain":{"type":"string","description":"The domain to create a verification code for","example":"example.com"},"verificationCode":{"type":"string","description":"The verification code"}}},"FreestyleDeployWebConfiguration":{"type":"object","properties":{"entrypoint":{"type":["string","null"],"description":"The entrypoint file for the website","default":"index.js"},"domains":{"type":["array","null"],"items":{"type":"string"},"description":"The custom domains for the website, eg. [\\\"subdomain.yourwebsite.com\\\"]. You may include a single *.style.dev domain here.","example":["subdomain.yourdomain.com"],"default":null},"projectId":{"type":["string","null"],"description":"Project ID was our original way of tracking deployments together, it is now deprecated and will be removed in the future. Please use the domains field to specify the domains for your project.","default":null,"deprecated":true},"nodeModules":{"type":["object","null"],"description":"Node Modules to install for the website, a map of package names to versions, e.g. { \\\"express\\\": \\\"4.17.1\\\" }. If this and a package-lock.json are provided, the package-lock.json, bun.lockb, pnpm-lock.yaml, or yarn.lock is also provided, the versions here will override the versions in those lock files.","default":null,"additionalProperties":{"type":"string"},"propertyNames":{"type":"string"},"example":{"resend":"4.0.1"}},"envVars":{"type":["object","null"],"description":"The environment variables that the website can access\ne.g. { \\\"RESEND_API_KEY\\\": \\\"re_123456789\\\" }","default":null,"additionalProperties":{"type":"string"},"propertyNames":{"type":"string"},"example":{"RESEND_API_KEY":"re_123456789"}},"serverStartCheck":{"type":"boolean","default":false}}},"FreestyleDeployWebErrorResponse":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}},"FreestyleDeployWebPayload":{"type":"object","required":["files"],"properties":{"files":{"type":"object","description":"The files to deploy, a map of file paths to file contents, e.g. { \\\"index.js\\\": {\\\"content\\\": \\\"your main\\\", \\\"encoding\\\": \\\"utf-8\\\"}, \\\"file2.js\\\": {\\\"content\\\": \\\"your helper\\\" } }\n\n**Do not include node modules in this bundle, they will not work**. Instead, includes a package-lock.json, bun.lockb, pnpm-lock.yaml, or yarn.lock, the node modules for the project will be installed from that lock file, or use the node_modules field in the configuration to specify the node modules to install.","additionalProperties":{"$ref":"#/components/schemas/FreestyleFile"},"propertyNames":{"type":"string"},"example":{"index.js":{"content":"import http from 'node:http';\\n// import { resolver } from './file2.js';\\n\\nconsole.log('starting server');\\n\\nconst server = http.createServer(async(req, res) => {\\n // wait 5 seconds before responding\\n // await new Promise((resolve) => setTimeout(resolve, 5000));\\n res.writeHead(200, { 'Content-Type': 'text/plain' });\\n res.end('Welcome to New York its been waiting for you');\\n});\\n\\nserver.listen(3000, () => {\\n console.log('Server is running at http://localhost:3000');\\n});"}}},"config":{"$ref":"#/components/schemas/FreestyleDeployWebConfiguration"}}},"FreestyleDeployWebSuccessResponse":{"type":"object","required":["deploymentId"],"properties":{"deploymentId":{"type":"string"},"domains":{"type":["array","null"],"items":{"type":"string"}},"projectId":{"type":["string","null"],"deprecated":true}}},"FreestyleDomainVerificationRequest":{"type":"object","required":["domain"],"properties":{"domain":{"type":"string","description":"The domain to create a verification code for","example":"example.com"}}},"FreestyleExecureScriptResultError":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}},"FreestyleExecureScriptResultSuccess":{"type":"object","required":["result","logs"],"properties":{"result":{},"logs":{"type":"array","items":{"$ref":"#/components/schemas/JavaScriptLog"}}}},"FreestyleExecuteScriptParams":{"type":"object","required":["script"],"properties":{"script":{"type":"string","description":"The JavaScript or TypeScript script to execute","example":"export default () => {\n // get the value of the factorials of the numbers from 1 to 10 combined\n const a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n\n function factorial(n) {\n if (n === 0) {\n return 1;\n }\n return n * factorial(n - 1);\n }\n\n const b = a.map(factorial);\n\n return b.reduce((a, b) => a + b);\n};\n"},"config":{"$ref":"#/components/schemas/FreestyleExecuteScriptParamsConfiguration"}}},"FreestyleExecuteScriptParamsConfiguration":{"type":"object","properties":{"envVars":{"type":"object","description":"The environment variables to set for the script","default":{},"additionalProperties":{"type":"string"},"propertyNames":{"type":"string"},"example":{"RESEND_API_KEY":"re_123456789"}},"nodeModules":{"type":"object","description":"The node modules to install for the script","default":{},"additionalProperties":{"type":"string"},"propertyNames":{"type":"string"},"example":{"resend":"4.0.1"}},"tags":{"type":"array","items":{"type":"string"},"description":"Tags for you to organize your scripts, useful for tracking what you're running","example":["email"],"default":[]},"timeout":{"type":["string","null"],"description":"The script timeout","default":null},"peerDependencyResolution":{"type":"boolean","description":"If false, we'll not resolve peer dependencies for the packages given, this can speed up execute performance, but will break packages with peers unless the peers are manually specified.","default":"true"}}},"FreestyleFile":{"type":"object","required":["content"],"properties":{"content":{"type":"string","description":"The content of the file"},"encoding":{"type":"string","description":"The encoding of the file. Either **utf-8** or **base64**"}}},"FreestyleLogResponseObject":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}},"FreestyleVerifyDomainRequest":{"type":"object","required":["domain"],"properties":{"domain":{"type":"string","example":"example.com"}}},"JavaScriptLog":{"type":"object","required":["message","type"],"properties":{"message":{"type":"string","description":"The log message"},"type":{"type":"string","description":"The log level"}}}},"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}}},"tags":[{"name":"Web","description":"APIs for deploying websites. We handle node modules caching, scaling, certificates and the whole end to end process. Send the code using the [deploy](#tag/web/POST/web/v1/deploy) endpoint, and you'll get a full hosted website back. Works with any TypeScript or JavaScript codebase."},{"name":"Execute","description":"APIs for running code. Send the code using the [execute](#tag/execute/POST/execute/v1/execute) endpoint, and you'll get the output back. Works with any TypeScript or JavaScript code + handles any node modules and environment variables you want."},{"name":"Cloudstate","description":"APIs for running cloud functions with persistent state. [Cloudstate](https://github.com/freestyle-sh/cloudstate/) is an opensource, durable JavaScript runtime maintained by the Freestyle Team."},{"name":"Domains","description":"APIs for managing domains. This is only relevant when you want to start to deploy to custom domains."}]}
|
|
1
|
+
{"openapi":"3.1.0","info":{"title":"Freestyle Sandboxes","description":"\nFreestyle Sandboxes lets you deploy your users or AIs code. **Get your API Key at [admin.freestyle.sh](https://admin.freestyle.sh)**\n\nThey are broken up into 4 categories: [Web](#tag/web), [Execute](#tag/execute), [Cloudstate](#tag/cloudstate), and [Domains](#tag/domains).\n\n[Web](#tag/web): Send us the code for the website, we'll provision the certificates and get it hosted\n\n[Execute](#tag/execute): Send us a function, we'll run it and send you the output\n\n[Cloudstate](#tag/cloudstate): Our Opensource JavaScript Runtime used for cloud functions with persistent state\n\n[Domains](#tag/domains): Manage your domains, including verification and listing\n","contact":{"name":"Ben","email":"ben@freestyle.sh"},"license":{"name":""},"version":"0.1.0"},"servers":[{"url":"https://api.freestyle.sh","description":"Production"}],"paths":{"/cloudstate/v1/deploy":{"post":{"tags":["Cloudstate"],"summary":"Deploy Cloudstate Project","description":"Deploy a cloudstate project","operationId":"handle_deploy_cloudstate","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleCloudstateDeployRequest"}}},"required":true},"responses":{"200":{"description":"successfully deployed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleCloudstateDeploySuccessResponse"}}}},"500":{"description":"failed to deploy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleCloudstateDeployErrorResponse"}}}}}}},"/cloudstate/v1/projects/{id}/backup":{"get":{"tags":["Cloudstate"],"summary":"Get Backup of Cloudstate Project","description":"Get a backup of a cloudstate project","operationId":"handle_backup_cloudstate","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"successfully backed up","content":{"application/octet-stream":{"schema":{"type":"array","items":{"type":"integer","format":"int32","minimum":0}}}}},"500":{"description":"failed to backup"}}}},"/domains/v1/certs/{domain}/wildcard":{"post":{"tags":["Certs","Domains"],"summary":"Provision a wildcard certificate","description":"Provisions a wildcard certificate for a verified domain\n\n\nThis speeds up deploys on all subdomains of the domain. In order to use it, you must add the following record to your DNS config:\n\n`_acme-challenge.yourdomain.com` NS `dns.freestyle.sh`\n","operationId":"handle_verify_wildcard","responses":{"200":{"description":"Domain verified","content":{"application/json":{"schema":{"type":"object","required":["domain"],"properties":{"domain":{"type":"string","example":"example.com"}}}}}},"400":{"description":"Failed to preverify domain","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}}}},"/domains/v1/domains":{"get":{"tags":["Domains"],"summary":"List domains for an account","description":"This lists the domains that an account has verified ownership of. This includes the *.style.dev domains the account has claimed.","operationId":"handle_list_domains","responses":{"200":{"description":"List of domains","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","required":["domain","createdAt"],"properties":{"domain":{"type":"string","example":"example.yourdomain.com"},"createdAt":{"type":"integer","format":"int64"}}}}}}},"400":{"description":"Failed to get domains","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}},"x-codeSamples":[{"label":"Human SDK","lang":"JavaScript","source":"import { FreestyleSandboxes } from 'freestyle-sandboxes';\n\nconst sandboxes = new FreestyleSandboxes({\n apiKey: 'your-api-key',\n});\n\nsandboxes.listDomains().then((response) => {\n console.log(response);\n});"}]}},"/domains/v1/verifications":{"get":{"tags":["Domains"],"summary":"List domain verification requests for an account","description":"Lists domain verification requests for the current account.","operationId":"handle_list_domain_verification_requests","responses":{"200":{"description":"List of verification codes","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","required":["verificationCode","domain","createdAt"],"properties":{"verificationCode":{"type":"string"},"domain":{"type":"string"},"createdAt":{"type":"integer","format":"int64"}}}}}}},"400":{"description":"Failed to get verification codes","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}}},"put":{"tags":["Domains"],"summary":"Verify a domain","description":"This checks a pre-existing verification request for a domain. To create a verification request, call the [create domain verification](/#tag/domains/POST/domains/v1/verifications) endpoint. This endpoint will check if the domain has a TXT record with the verification code. If it does, the domain will be verified.","operationId":"handle_verify_domain","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleVerifyDomainRequest"}}},"required":true},"responses":{"200":{"description":"Domain verified","content":{"application/json":{"schema":{"type":"object","required":["domain"],"properties":{"domain":{"type":"string","example":"example.com"}}}}}},"400":{"description":"Failed to verify domain","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}},"x-codeSamples":[{"label":"Human SDK","lang":"JavaScript","source":"import { FreestyleSandboxes } from 'freestyle-sandboxes';\n\nconst api = new FreestyleSandboxes({\n apiKey: process.env.FREESTYLE_API_KEY!,\n});\n\napi\n .verifyDomain('example.com')\n .then((result) => {\n console.log('Successfully Verified Domain!');\n })\n .catch((error) => {\n console.error('Failed to verify domain: ', error);\n });"}]},"post":{"tags":["Domains"],"summary":"Create a domain verification request","description":"This creates a Freestyle Domain Verification Request. It returns a `verificationCode` for your domain. You need to place this code in a TXT record at `_freestyle_custom_hostname.thedomain.com`, then call the [verify domain](/#tag/domains/PUT/domains/v1/verifications) endpoint with the domain to verify it.","operationId":"handle_create_domain_verification","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleDomainVerificationRequest"}}},"required":true},"responses":{"200":{"description":"Verification code created","content":{"application/json":{"schema":{"type":"object","required":["verificationCode","domain"],"properties":{"verificationCode":{"type":"string"},"domain":{"type":"string","example":"example.com"}}}}}},"400":{"description":"Failed to create verification code","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}},"x-codeSamples":[{"label":"Human SDK","lang":"JavaScript","source":"import { FreestyleSandboxes } from 'freestyle-sandboxes';\n\nconst api = new FreestyleSandboxes({\n apiKey: process.env.FREESTYLE_API_KEY!,\n});\n\napi.createDomainVerificationRequest('example.com').then((result) => {\n const verificationCode = result.verificationCode;\n // put this at a TXT record at _freestyle_custom_hostname.example.com\n});"}]},"delete":{"tags":["Domains"],"summary":"Delete a domain verification request","description":"This deletes a Freestyle Domain Verification Request. This does not remove the domain from the account if it has already been verified, however the verification code will no longer be valid.","operationId":"handle_delete_domain_verification","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleDeleteDomainVerificationRequest"}}},"required":true},"responses":{"200":{"description":"Verification code created","content":{"application/json":{"schema":{"type":"object","required":["verificationCode","domain"],"properties":{"verificationCode":{"type":"string"},"domain":{"type":"string","example":"example.com"}}}}}},"400":{"description":"Failed to create verification code","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}}}},"/execute/v1/deployments":{"get":{"tags":["Execute"],"summary":"List execute runs","description":"List execute runs.","operationId":"handle_list_execute_runs","parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":["integer","null"],"minimum":0}},{"name":"offset","in":"query","required":false,"schema":{"type":["integer","null"],"minimum":0}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","required":["entries","total","offset"],"properties":{"entries":{"type":"array","items":{"$ref":"#/components/schemas/ExecuteLogEntry"}},"total":{"type":"integer","format":"int64","minimum":0},"offset":{"type":"integer","format":"int64","minimum":0}}}}}},"500":{"description":"","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}}}},"/execute/v1/deployments/{deployment}":{"get":{"tags":["Execute"],"summary":"Get information on execute run","description":"Get information on execute run","operationId":"handle_get_execute_run","parameters":[{"name":"deployment","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExecuteLogEntry"}}}},"401":{"description":"Unauthorized access","content":{"application/json":{"schema":{"type":"object","description":"Unauthorized access","required":["message"],"properties":{"message":{"type":"string"}}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","description":"Not found","required":["message"],"properties":{"message":{"type":"string"}}}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"type":"object","description":"Internal server error","required":["message"],"properties":{"message":{"type":"string"}}}}}}}}},"/execute/v1/script":{"post":{"tags":["Execute"],"summary":"Execute Code","description":"Send a TypeScript or JavaScript module, get the result","operationId":"handle_execute_script","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleExecuteScriptParams"}}},"required":true},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","required":["result","logs"],"properties":{"result":{},"logs":{"type":"array","items":{"$ref":"#/components/schemas/FreestyleJavaScriptLog"}}}}}}},"400":{"description":"Error","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}}}}}},"x-codeSamples":[{"label":"Human SDK","lang":"JavaScript","source":"import { FreestyleSandboxes } from 'freestyle-sandboxes';\n\nconst sandboxes = new FreestyleSandboxes({\n apiKey: 'your-api-key',\n});\n\nsandboxes.executeScript(\n `export default () => {\n let set1 = [1, 2, 3, 4, 5];\n let set2 = [4, 5, 6, 7, 8];\n\n // find the sum of every value of each set multiplied by every value of the other set\n\n let sum = 0;\n for (let i = 0; i < set1.length; i++) {\n for (let j = 0; j < set2.length; j++) {\n sum += set1[i] * set2[j];\n }\n }\n\n return sum;\n};`\n);"},{"label":"Vercel AI SDK","lang":"JavaScript","source":"import { executeTool } from 'freestyle-sandboxes/ai';\nimport { generateText } from 'ai';\n\nconst codeExecutor = executeTool({\n apiKey: 'your-api-key',\n});\n\nconst { text, steps } = await generateText({\n model: yourModel,\n tools: {\n codeExecutor,\n },\n maxSteps: 2,\n prompt:\n 'What is the sum of every number between 1 and 12 multiplied by itself?',\n});"},{"label":"Mastra AI SDK","lang":"JavaScript","source":"import { executeTool } from 'freestyle-sandboxes/mastra';\n\nconst mastra = new Mastra();\n\nconst modelConfig: ModelConfig = {\n provider: 'OPEN_AI',\n name: 'gpt-4',\n};\n\nconst llm = mastra.LLM(modelConfig);\n\nconst response = await llm.generate(\n 'Calculate the sum of every number between 13 and 19 divided by the sum of every number between 8 and 13',\n {\n tools: {\n executor: executeTool({\n apiKey: process.env.FREESTYLE_API_KEY!,\n }),\n },\n }\n);\n\nconsole.log('Response Steps:', response.steps);\nconsole.log('Response:', response.text);"}]}},"/observability/v1/logs":{"get":{"tags":["Observability"],"summary":"Deployment Logs","description":"Get the logs for a deployment","operationId":"handle_get_logs","parameters":[{"name":"deploymentId","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/FreestyleLogResponseObject"}}}}}}}},"/web/v1/deploy":{"post":{"tags":["Web"],"summary":"Deploy a Website","description":"Deploy a website. Files is a map of file paths to file contents. Configuration is optional and contains additional information about the deployment.","operationId":"handle_deploy_web","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleDeployWebPayload"}}},"required":true},"responses":{"200":{"description":"successfully deployed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleDeployWebSuccessResponse"}}}},"400":{"description":"failed to deploy","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleDeployWebErrorResponse"}}}}},"x-codeSamples":[{"label":"Human SDK","lang":"JavaScript","source":"import { FreestyleSandboxes } from 'freestyle-sandboxes';\nimport 'dotenv/config';\n\nconst api = new FreestyleSandboxes({\n apiKey: process.env.FREESTYLE_API_KEY!,\n});\n\napi\n .deployWeb({\n 'index.js': {\n content:`\n import http from 'node:http';\n console.log('starting server');\n\n const server = http.createServer(async(req, res) => {\n // wait 5 seconds before responding\n // await new Promise((resolve) => setTimeout(resolve, 5000));\n res.writeHead(200, { 'Content-Type': 'text/plain' });\n res.end('Welcome to New York its been waiting for you');\n });\n\n server.listen(3000, () => {\n console.log('Server is running at http://localhost:3000');\n });`,\n })\n .then((result) => {\n console.log('Deployed website @ ', result.deploymentId);\n });\n"},{"label":"Vercel AI SDK","lang":"JavaScript","source":"import { deployWebTool } from 'freestyle-sandboxes/ai';\nimport { generateText } from 'ai';\n\nconst deployer = deployWebTool({\n apiKey: 'your-api-key',\n});\n\nconst { text, steps } = await generateText({\n model: yourModel,\n tools: {\n deployer,\n },\n maxSteps: 2,\n prompt:\n 'Deploy a website to subdomain.yourdomain.com that has all the lyrics to Sandstorm by Darude on the homepage',\n});"}]}},"/web/v1/deployments":{"get":{"tags":["Web"],"summary":"List web deploys","description":"List web deploys.","operationId":"handle_list_web_deploys","responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","required":["entries","total","offset"],"properties":{"entries":{"type":"array","items":{"$ref":"#/components/schemas/DeploymentLogEntry"}},"total":{"type":"integer","format":"int64","minimum":0},"offset":{"type":"integer","format":"int64","minimum":0}}}}}},"500":{"description":"","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}}}}},"components":{"schemas":{"DeploymentLogEntry":{"type":"object","required":["deploymentId","accountId","provisionedAt","timeout","state","domains","envVars"],"properties":{"deploymentId":{"type":"string","format":"uuid"},"accountId":{"type":"string"},"provisionedAt":{"type":"string","format":"date-time"},"timeout":{"type":"string"},"state":{"$ref":"#/components/schemas/DeploymentState"},"deployedAt":{"type":["string","null"],"format":"date-time"},"domains":{"type":"array","items":{"type":"string"}},"envVars":{"type":"object","additionalProperties":{"type":"string"},"propertyNames":{"type":"string"}}}},"DeploymentState":{"type":"string","enum":["provisioning","deployed","failed"]},"ExecuteLogEntry":{"type":"object","required":["deployment","account_id","provisioned_at","state","env_vars"],"properties":{"deployment":{"type":"string","format":"uuid"},"account_id":{"type":"string"},"provisioned_at":{"type":"string","format":"date-time"},"started_at":{"type":["string","null"],"format":"date-time"},"duration":{"type":["string","null"]},"state":{"$ref":"#/components/schemas/ExecuteRunState"},"env_vars":{"type":"object","additionalProperties":{"type":"string"},"propertyNames":{"type":"string"}}}},"ExecuteRunState":{"type":"string","enum":["starting","running","complete"]},"FreestyleCloudstateDeployConfiguration":{"type":"object","properties":{"domains":{"type":["array","null"],"items":{"type":"string"},"description":"ID of the project to deploy, if not provided will create a new project","default":null},"envVars":{"type":"object","description":"The environment variables that the cloudstate deploy can access","default":{},"additionalProperties":{"type":"string"},"propertyNames":{"type":"string"}},"cloudstateDatabaseId":{"type":["string","null"],"default":null}}},"FreestyleCloudstateDeployErrorResponse":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}},"FreestyleCloudstateDeployRequest":{"type":"object","required":["classes"],"properties":{"classes":{"type":"string"},"config":{"$ref":"#/components/schemas/FreestyleCloudstateDeployConfiguration"}}},"FreestyleCloudstateDeploySuccessResponse":{"type":"object","required":["deploymentId","cloudstateDatabaseId"],"properties":{"deploymentId":{"type":"string"},"cloudstateDatabaseId":{"type":"string"}}},"FreestyleDeleteDomainVerificationRequest":{"type":"object","required":["domain","verificationCode"],"properties":{"domain":{"type":"string","description":"The domain to create a verification code for","example":"example.com"},"verificationCode":{"type":"string","description":"The verification code"}}},"FreestyleDeployWebConfiguration":{"type":"object","properties":{"entrypoint":{"type":["string","null"],"description":"The entrypoint file for the website","default":"index.js"},"domains":{"type":["array","null"],"items":{"type":"string"},"description":"The custom domains for the website, eg. [\\\"subdomain.yourwebsite.com\\\"]. You may include a single *.style.dev domain here.","example":["subdomain.yourdomain.com"],"default":null},"projectId":{"type":["string","null"],"description":"Project ID was our original way of tracking deployments together, it is now deprecated and will be removed in the future. Please use the domains field to specify the domains for your project.","default":null,"deprecated":true},"nodeModules":{"type":["object","null"],"description":"Node Modules to install for the website, a map of package names to versions, e.g. { \\\"express\\\": \\\"4.17.1\\\" }. If this and a package-lock.json are provided, the package-lock.json, bun.lockb, pnpm-lock.yaml, or yarn.lock is also provided, the versions here will override the versions in those lock files.","default":null,"additionalProperties":{"type":"string"},"propertyNames":{"type":"string"},"example":{"resend":"4.0.1"}},"envVars":{"type":["object","null"],"description":"The environment variables that the website can access\ne.g. { \\\"RESEND_API_KEY\\\": \\\"re_123456789\\\" }","default":null,"additionalProperties":{"type":"string"},"propertyNames":{"type":"string"},"example":{"RESEND_API_KEY":"re_123456789"}},"serverStartCheck":{"type":"boolean","default":false}}},"FreestyleDeployWebErrorResponse":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}},"FreestyleDeployWebPayload":{"type":"object","required":["files"],"properties":{"files":{"type":"object","description":"The files to deploy, a map of file paths to file contents, e.g. { \\\"index.js\\\": {\\\"content\\\": \\\"your main\\\", \\\"encoding\\\": \\\"utf-8\\\"}, \\\"file2.js\\\": {\\\"content\\\": \\\"your helper\\\" } }\n\n**Do not include node modules in this bundle, they will not work**. Instead, includes a package-lock.json, bun.lockb, pnpm-lock.yaml, or yarn.lock, the node modules for the project will be installed from that lock file, or use the node_modules field in the configuration to specify the node modules to install.","additionalProperties":{"$ref":"#/components/schemas/FreestyleFile"},"propertyNames":{"type":"string"},"example":{"index.js":{"content":"import http from 'node:http';\\n// import { resolver } from './file2.js';\\n\\nconsole.log('starting server');\\n\\nconst server = http.createServer(async(req, res) => {\\n // wait 5 seconds before responding\\n // await new Promise((resolve) => setTimeout(resolve, 5000));\\n res.writeHead(200, { 'Content-Type': 'text/plain' });\\n res.end('Welcome to New York its been waiting for you');\\n});\\n\\nserver.listen(3000, () => {\\n console.log('Server is running at http://localhost:3000');\\n});"}}},"config":{"$ref":"#/components/schemas/FreestyleDeployWebConfiguration"}}},"FreestyleDeployWebSuccessResponse":{"type":"object","required":["deploymentId"],"properties":{"deploymentId":{"type":"string"},"domains":{"type":["array","null"],"items":{"type":"string"}},"projectId":{"type":["string","null"],"deprecated":true}}},"FreestyleDomainVerificationRequest":{"type":"object","required":["domain"],"properties":{"domain":{"type":"string","description":"The domain to create a verification code for","example":"example.com"}}},"FreestyleExecuteScriptParams":{"type":"object","required":["script"],"properties":{"script":{"type":"string","description":"The JavaScript or TypeScript script to execute","example":"export default () => {\n // get the value of the factorials of the numbers from 1 to 10 combined\n const a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n\n function factorial(n) {\n if (n === 0) {\n return 1;\n }\n return n * factorial(n - 1);\n }\n\n const b = a.map(factorial);\n\n return b.reduce((a, b) => a + b);\n};\n"},"config":{"$ref":"#/components/schemas/FreestyleExecuteScriptParamsConfiguration"}}},"FreestyleExecuteScriptParamsConfiguration":{"type":"object","properties":{"envVars":{"type":"object","description":"The environment variables to set for the script","default":{},"additionalProperties":{"type":"string"},"propertyNames":{"type":"string"},"example":{"RESEND_API_KEY":"re_123456789"}},"nodeModules":{"type":"object","description":"The node modules to install for the script","default":{},"additionalProperties":{"type":"string"},"propertyNames":{"type":"string"},"example":{"resend":"4.0.1"}},"tags":{"type":"array","items":{"type":"string"},"description":"Tags for you to organize your scripts, useful for tracking what you're running","example":["email"],"default":[]},"timeout":{"type":["string","null"],"description":"The script timeout","default":null},"peerDependencyResolution":{"type":"boolean","description":"If false, we'll not resolve peer dependencies for the packages given, this can speed up execute performance, but will break packages with peers unless the peers are manually specified.","default":true}}},"FreestyleExecuteScriptResultSuccess":{"type":"object","required":["result","logs"],"properties":{"result":{},"logs":{"type":"array","items":{"$ref":"#/components/schemas/FreestyleJavaScriptLog"}}}},"FreestyleFile":{"type":"object","required":["content"],"properties":{"content":{"type":"string","description":"The content of the file"},"encoding":{"type":"string","description":"The encoding of the file. Either **utf-8** or **base64**"}}},"FreestyleJavaScriptLog":{"type":"object","required":["message","type"],"properties":{"message":{"type":"string","description":"The log message"},"type":{"type":"string","description":"The log level"}}},"FreestyleLogResponseObject":{"type":"object","required":["message","timestamp"],"properties":{"message":{"type":"string"},"timestamp":{"type":"string"}}},"FreestyleVerifyDomainRequest":{"type":"object","required":["domain"],"properties":{"domain":{"type":"string","example":"example.com"}}}},"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}}},"tags":[{"name":"Web","description":"APIs for deploying websites. We handle node modules caching, scaling, certificates and the whole end to end process. Send the code using the [deploy](#tag/web/POST/web/v1/deploy) endpoint, and you'll get a full hosted website back. Works with any TypeScript or JavaScript codebase."},{"name":"Execute","description":"APIs for running code. Send the code using the [execute](#tag/execute/POST/execute/v1/execute) endpoint, and you'll get the output back. Works with any TypeScript or JavaScript code + handles any node modules and environment variables you want."},{"name":"Cloudstate","description":"APIs for running cloud functions with persistent state. [Cloudstate](https://github.com/freestyle-sh/cloudstate/) is an opensource, durable JavaScript runtime maintained by the Freestyle Team."},{"name":"Domains","description":"APIs for managing domains. This is only relevant when you want to start to deploy to custom domains."}]}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -32,7 +32,7 @@ export class FreestyleSandboxes {
|
|
|
32
32
|
async executeScript(
|
|
33
33
|
script: string,
|
|
34
34
|
config?: sandbox_openapi.FreestyleExecuteScriptParamsConfiguration
|
|
35
|
-
): Promise<sandbox_openapi.
|
|
35
|
+
): Promise<sandbox_openapi.FreestyleExecuteScriptResultSuccess> {
|
|
36
36
|
const response = await sandbox_openapi.handleExecuteScript({
|
|
37
37
|
client: this.client,
|
|
38
38
|
body: {
|
|
@@ -121,17 +121,20 @@ export class FreestyleSandboxes {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
/**
|
|
124
|
-
* Get logs for
|
|
124
|
+
* Get logs for an execute run, or web deployment.
|
|
125
125
|
* @param id The ID of the sandbox.
|
|
126
126
|
* @returns The logs for the sandbox.
|
|
127
127
|
* @throws An error if the logs could not be retrieved.
|
|
128
128
|
*/
|
|
129
|
-
async
|
|
129
|
+
async getLogs(id: string): Promise<sandbox_openapi.HandleGetLogsResponse> {
|
|
130
130
|
const response = await sandbox_openapi.handleGetLogs({
|
|
131
131
|
client: this.client,
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
query: {
|
|
133
|
+
deploymentId: id,
|
|
134
134
|
},
|
|
135
|
+
// path: {
|
|
136
|
+
// id: id,
|
|
137
|
+
// },
|
|
135
138
|
});
|
|
136
139
|
if (response.data) {
|
|
137
140
|
return response.data;
|
|
@@ -234,6 +237,66 @@ export class FreestyleSandboxes {
|
|
|
234
237
|
);
|
|
235
238
|
}
|
|
236
239
|
}
|
|
240
|
+
|
|
241
|
+
async listWebDeployments(): Promise<sandbox_openapi.HandleListWebDeploysResponse> {
|
|
242
|
+
const response = await sandbox_openapi.handleListWebDeploys({
|
|
243
|
+
client: this.client,
|
|
244
|
+
});
|
|
245
|
+
if (response.data) {
|
|
246
|
+
return response.data;
|
|
247
|
+
} else {
|
|
248
|
+
throw new Error(
|
|
249
|
+
"Failed to list web deployments\n" + response.error.message
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
async listExecuteRuns(): Promise<sandbox_openapi.HandleListExecuteRunsResponse> {
|
|
255
|
+
const response = await sandbox_openapi.handleListExecuteRuns({
|
|
256
|
+
client: this.client,
|
|
257
|
+
});
|
|
258
|
+
if (response.data) {
|
|
259
|
+
return response.data;
|
|
260
|
+
} else {
|
|
261
|
+
throw new Error("Failed to list execute runs\n" + response.error.message);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
async getExecuteRun(
|
|
266
|
+
id: string
|
|
267
|
+
): Promise<sandbox_openapi.HandleGetExecuteRunResponse> {
|
|
268
|
+
const response = await sandbox_openapi.handleGetExecuteRun({
|
|
269
|
+
client: this.client,
|
|
270
|
+
path: {
|
|
271
|
+
deployment: id,
|
|
272
|
+
},
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
if (response.data) {
|
|
276
|
+
return response.data;
|
|
277
|
+
} else {
|
|
278
|
+
throw new Error(
|
|
279
|
+
`Failed to get execute run with ID ${id}: ${response.error.message}`
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
async provisionWildcard(domain: string) {
|
|
285
|
+
const response = await sandbox_openapi.handleVerifyWildcard({
|
|
286
|
+
client: this.client,
|
|
287
|
+
path: {
|
|
288
|
+
domain,
|
|
289
|
+
},
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
if (response.data) {
|
|
293
|
+
return response.data;
|
|
294
|
+
} else {
|
|
295
|
+
throw new Error(
|
|
296
|
+
`Failed to provision wildcard for domain ${domain}: ${response.error.message}`
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
237
300
|
}
|
|
238
301
|
|
|
239
302
|
export * from "../openapi/types.gen.ts";
|