freestyle-sandboxes 0.0.4 → 0.0.6

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.cjs CHANGED
@@ -68,8 +68,12 @@ ${nodeModules.length > 0 ? `You can use the following node modules: ${nodeModule
68
68
  `)
69
69
  }),
70
70
  execute: async ({ files }) => {
71
+ const new_files = Object.keys(files).reduce((acc, key) => {
72
+ acc[key] = { content: files[key] };
73
+ return acc;
74
+ }, {});
71
75
  try {
72
- const res = await api.deployWeb(files, config);
76
+ const res = await api.deployWeb(new_files, config);
73
77
  return res;
74
78
  } catch (e) {
75
79
  console.log("ERROR: ", e.message);
@@ -1,5 +1,5 @@
1
1
  import * as ai from 'ai';
2
- import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecureScriptResultSuccess, c as FreestyleDeployWebSuccessResponse } from '../types.gen-CKNcEsUr.js';
2
+ import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecureScriptResultSuccess, c as FreestyleDeployWebSuccessResponse } from '../types.gen-DyY7Deri.js';
3
3
  import { z } from 'zod';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import * as ai from 'ai';
2
- import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecureScriptResultSuccess, c as FreestyleDeployWebSuccessResponse } from '../types.gen-CKNcEsUr.js';
2
+ import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecureScriptResultSuccess, c as FreestyleDeployWebSuccessResponse } from '../types.gen-DyY7Deri.js';
3
3
  import { z } from 'zod';
4
4
 
5
5
  /**
package/dist/ai/index.mjs CHANGED
@@ -66,8 +66,12 @@ ${nodeModules.length > 0 ? `You can use the following node modules: ${nodeModule
66
66
  `)
67
67
  }),
68
68
  execute: async ({ files }) => {
69
+ const new_files = Object.keys(files).reduce((acc, key) => {
70
+ acc[key] = { content: files[key] };
71
+ return acc;
72
+ }, {});
69
73
  try {
70
- const res = await api.deployWeb(files, config);
74
+ const res = await api.deployWeb(new_files, config);
71
75
  return res;
72
76
  } catch (e) {
73
77
  console.log("ERROR: ", e.message);
package/dist/index.cjs CHANGED
@@ -85,7 +85,13 @@ ${JSON.stringify(
85
85
  if (response.data) {
86
86
  return response.data;
87
87
  } else {
88
- throw new Error("Failed to deploy Web project");
88
+ throw new Error(
89
+ `Failed to deploy web project
90
+
91
+ Status: ${response.response.status}
92
+
93
+ Message: ${response.error?.message}`
94
+ );
89
95
  }
90
96
  }
91
97
  /**
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecureScriptResultSuccess, b as FreestyleDeployWebConfiguration, c as FreestyleDeployWebSuccessResponse, d as FreestyleCloudstateDeployRequest, e as FreestyleCloudstateDeploySuccessResponse, H as HandleBackupCloudstateResponse, f as HandleGetLogsResponse } from './types.gen-CKNcEsUr.js';
2
- export { g as FreestyleCloudstateDeployConfiguration, h as FreestyleCloudstateDeployErrorResponse, i as FreestyleDeployWebErrorResponse, j as FreestyleDeployWebPayload, k as FreestyleExecureScriptResultError, l as FreestyleExecuteScriptParams, m as FreestyleLogResponseObject, q as HandleBackupCloudstateError, n as HandleDeployCloudstateData, p as HandleDeployCloudstateError, o as HandleDeployCloudstateResponse, u as HandleDeployWebData, w as HandleDeployWebError, v as HandleDeployWebResponse, r as HandleExecuteScriptData, t as HandleExecuteScriptError, s as HandleExecuteScriptResponse, x as HandleGetLogsError } from './types.gen-CKNcEsUr.js';
1
+ import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecureScriptResultSuccess, b as FreestyleDeployWebConfiguration, c as FreestyleDeployWebSuccessResponse, d as FreestyleCloudstateDeployRequest, e as FreestyleCloudstateDeploySuccessResponse, H as HandleBackupCloudstateResponse, f as HandleGetLogsResponse } from './types.gen-DyY7Deri.js';
2
+ export { g as FreestyleCloudstateDeployConfiguration, h as FreestyleCloudstateDeployErrorResponse, i as FreestyleDeployWebErrorResponse, j as FreestyleDeployWebPayload, k as FreestyleExecureScriptResultError, l as FreestyleExecuteScriptParams, m as FreestyleFile, n as FreestyleLogResponseObject, r as HandleBackupCloudstateError, o as HandleDeployCloudstateData, q as HandleDeployCloudstateError, p as HandleDeployCloudstateResponse, v as HandleDeployWebData, x as HandleDeployWebError, w as HandleDeployWebResponse, s as HandleExecuteScriptData, u as HandleExecuteScriptError, t as HandleExecuteScriptResponse, y as HandleGetLogsError } from './types.gen-DyY7Deri.js';
3
3
 
4
4
  declare class FreestyleSandboxes {
5
5
  private client;
@@ -20,7 +20,10 @@ declare class FreestyleSandboxes {
20
20
  /**
21
21
  * Deploy a Web project to a sandbox.
22
22
  */
23
- deployWeb(files: Record<string, string>, config?: FreestyleDeployWebConfiguration): Promise<FreestyleDeployWebSuccessResponse>;
23
+ deployWeb(files: Record<string, {
24
+ content: string;
25
+ encoding?: string;
26
+ }>, config?: FreestyleDeployWebConfiguration): Promise<FreestyleDeployWebSuccessResponse>;
24
27
  /**
25
28
  * Deploy a Cloudstate project to a sandbox.
26
29
  */
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecureScriptResultSuccess, b as FreestyleDeployWebConfiguration, c as FreestyleDeployWebSuccessResponse, d as FreestyleCloudstateDeployRequest, e as FreestyleCloudstateDeploySuccessResponse, H as HandleBackupCloudstateResponse, f as HandleGetLogsResponse } from './types.gen-CKNcEsUr.js';
2
- export { g as FreestyleCloudstateDeployConfiguration, h as FreestyleCloudstateDeployErrorResponse, i as FreestyleDeployWebErrorResponse, j as FreestyleDeployWebPayload, k as FreestyleExecureScriptResultError, l as FreestyleExecuteScriptParams, m as FreestyleLogResponseObject, q as HandleBackupCloudstateError, n as HandleDeployCloudstateData, p as HandleDeployCloudstateError, o as HandleDeployCloudstateResponse, u as HandleDeployWebData, w as HandleDeployWebError, v as HandleDeployWebResponse, r as HandleExecuteScriptData, t as HandleExecuteScriptError, s as HandleExecuteScriptResponse, x as HandleGetLogsError } from './types.gen-CKNcEsUr.js';
1
+ import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecureScriptResultSuccess, b as FreestyleDeployWebConfiguration, c as FreestyleDeployWebSuccessResponse, d as FreestyleCloudstateDeployRequest, e as FreestyleCloudstateDeploySuccessResponse, H as HandleBackupCloudstateResponse, f as HandleGetLogsResponse } from './types.gen-DyY7Deri.js';
2
+ export { g as FreestyleCloudstateDeployConfiguration, h as FreestyleCloudstateDeployErrorResponse, i as FreestyleDeployWebErrorResponse, j as FreestyleDeployWebPayload, k as FreestyleExecureScriptResultError, l as FreestyleExecuteScriptParams, m as FreestyleFile, n as FreestyleLogResponseObject, r as HandleBackupCloudstateError, o as HandleDeployCloudstateData, q as HandleDeployCloudstateError, p as HandleDeployCloudstateResponse, v as HandleDeployWebData, x as HandleDeployWebError, w as HandleDeployWebResponse, s as HandleExecuteScriptData, u as HandleExecuteScriptError, t as HandleExecuteScriptResponse, y as HandleGetLogsError } from './types.gen-DyY7Deri.js';
3
3
 
4
4
  declare class FreestyleSandboxes {
5
5
  private client;
@@ -20,7 +20,10 @@ declare class FreestyleSandboxes {
20
20
  /**
21
21
  * Deploy a Web project to a sandbox.
22
22
  */
23
- deployWeb(files: Record<string, string>, config?: FreestyleDeployWebConfiguration): Promise<FreestyleDeployWebSuccessResponse>;
23
+ deployWeb(files: Record<string, {
24
+ content: string;
25
+ encoding?: string;
26
+ }>, config?: FreestyleDeployWebConfiguration): Promise<FreestyleDeployWebSuccessResponse>;
24
27
  /**
25
28
  * Deploy a Cloudstate project to a sandbox.
26
29
  */
package/dist/index.mjs CHANGED
@@ -83,7 +83,13 @@ ${JSON.stringify(
83
83
  if (response.data) {
84
84
  return response.data;
85
85
  } else {
86
- throw new Error("Failed to deploy Web project");
86
+ throw new Error(
87
+ `Failed to deploy web project
88
+
89
+ Status: ${response.response.status}
90
+
91
+ Message: ${response.error?.message}`
92
+ );
87
93
  }
88
94
  }
89
95
  /**
@@ -2,12 +2,12 @@ type FreestyleCloudstateDeployConfiguration = {
2
2
  /**
3
3
  * ID of the project to deploy, if not provided will create a new project
4
4
  */
5
- projectId?: string | null;
5
+ projectId?: (string) | null;
6
6
  /**
7
7
  * The environment variables that the cloudstate deploy can access
8
8
  */
9
9
  envVars?: {
10
- [key: string]: string;
10
+ [key: string]: (string);
11
11
  };
12
12
  };
13
13
  type FreestyleCloudstateDeployErrorResponse = {
@@ -27,27 +27,27 @@ type FreestyleDeployWebConfiguration = {
27
27
  /**
28
28
  * The entrypoint file for the website
29
29
  */
30
- entrypoint?: string | null;
30
+ entrypoint?: (string) | null;
31
31
  /**
32
32
  * The custom domains for the website, eg. [\"subdomain.yourwebsite.com\"]. You may not include *.style.dev domains here, those are reserved for projectIds
33
33
  */
34
- domains?: Array<string> | null;
34
+ domains?: Array<(string)> | null;
35
35
  /**
36
36
  * The project id to deploy to, if not provided will create a new project, may be used to provision a new project with a specific id if that id is available
37
37
  */
38
- projectId?: string | null;
38
+ projectId?: (string) | null;
39
39
  /**
40
40
  * 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.
41
41
  */
42
42
  nodeModules?: {
43
- [key: string]: string;
43
+ [key: string]: (string);
44
44
  } | null;
45
45
  /**
46
46
  * The environment variables that the website can access
47
47
  * e.g. { \"RESEND_API_KEY\": \"re_123456789\" }
48
48
  */
49
49
  envVars?: {
50
- [key: string]: string;
50
+ [key: string]: (string);
51
51
  } | null;
52
52
  };
53
53
  type FreestyleDeployWebErrorResponse = {
@@ -55,12 +55,12 @@ type FreestyleDeployWebErrorResponse = {
55
55
  };
56
56
  type FreestyleDeployWebPayload = {
57
57
  /**
58
- * The files to deploy, a map of file paths to file contents, e.g. { \"index.js\": \"your main", \"file2.js\": \"your helper\" }
58
+ * 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\" } }
59
59
  *
60
60
  * **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.
61
61
  */
62
62
  files: {
63
- [key: string]: string;
63
+ [key: string]: FreestyleFile;
64
64
  };
65
65
  config?: FreestyleDeployWebConfiguration;
66
66
  };
@@ -85,22 +85,32 @@ type FreestyleExecuteScriptParamsConfiguration = {
85
85
  * The environment variables to set for the script
86
86
  */
87
87
  envVars?: {
88
- [key: string]: string;
88
+ [key: string]: (string);
89
89
  };
90
90
  /**
91
91
  * The node modules to install for the script
92
92
  */
93
93
  nodeModules?: {
94
- [key: string]: string;
94
+ [key: string]: (string);
95
95
  };
96
96
  /**
97
97
  * Tags for you to organize your scripts, useful for tracking what you're running
98
98
  */
99
- tags?: Array<string>;
99
+ tags?: Array<(string)>;
100
100
  /**
101
101
  * The script timeout
102
102
  */
103
- timeout?: string | null;
103
+ timeout?: (string) | null;
104
+ };
105
+ type FreestyleFile = {
106
+ /**
107
+ * The content of the file
108
+ */
109
+ content: string;
110
+ /**
111
+ * The encoding of the file. Either **utf-8** or **base64**
112
+ */
113
+ encoding?: string;
104
114
  };
105
115
  type FreestyleLogResponseObject = {
106
116
  message: string;
@@ -108,21 +118,21 @@ type FreestyleLogResponseObject = {
108
118
  type HandleDeployCloudstateData = {
109
119
  body: FreestyleCloudstateDeployRequest;
110
120
  };
111
- type HandleDeployCloudstateResponse = FreestyleCloudstateDeploySuccessResponse;
112
- type HandleDeployCloudstateError = FreestyleCloudstateDeployErrorResponse;
113
- type HandleBackupCloudstateResponse = Array<number>;
114
- type HandleBackupCloudstateError = unknown;
121
+ type HandleDeployCloudstateResponse = (FreestyleCloudstateDeploySuccessResponse);
122
+ type HandleDeployCloudstateError = (FreestyleCloudstateDeployErrorResponse);
123
+ type HandleBackupCloudstateResponse = (Array<(number)>);
124
+ type HandleBackupCloudstateError = (unknown);
115
125
  type HandleExecuteScriptData = {
116
126
  body: FreestyleExecuteScriptParams;
117
127
  };
118
- type HandleExecuteScriptResponse = FreestyleExecureScriptResultSuccess;
119
- type HandleExecuteScriptError = FreestyleExecureScriptResultError;
128
+ type HandleExecuteScriptResponse = (FreestyleExecureScriptResultSuccess);
129
+ type HandleExecuteScriptError = (FreestyleExecureScriptResultError);
120
130
  type HandleDeployWebData = {
121
131
  body: FreestyleDeployWebPayload;
122
132
  };
123
- type HandleDeployWebResponse = FreestyleDeployWebSuccessResponse;
124
- type HandleDeployWebError = FreestyleDeployWebErrorResponse;
125
- type HandleGetLogsResponse = Array<FreestyleLogResponseObject>;
133
+ type HandleDeployWebResponse = (FreestyleDeployWebSuccessResponse);
134
+ type HandleDeployWebError = (FreestyleDeployWebErrorResponse);
135
+ type HandleGetLogsResponse = (Array<FreestyleLogResponseObject>);
126
136
  type HandleGetLogsError = unknown;
127
137
 
128
- export type { FreestyleExecuteScriptParamsConfiguration as F, HandleBackupCloudstateResponse as H, FreestyleExecureScriptResultSuccess as a, FreestyleDeployWebConfiguration as b, FreestyleDeployWebSuccessResponse as c, FreestyleCloudstateDeployRequest as d, FreestyleCloudstateDeploySuccessResponse as e, HandleGetLogsResponse as f, FreestyleCloudstateDeployConfiguration as g, FreestyleCloudstateDeployErrorResponse as h, FreestyleDeployWebErrorResponse as i, FreestyleDeployWebPayload as j, FreestyleExecureScriptResultError as k, FreestyleExecuteScriptParams as l, FreestyleLogResponseObject as m, HandleDeployCloudstateData as n, HandleDeployCloudstateResponse as o, HandleDeployCloudstateError as p, HandleBackupCloudstateError as q, HandleExecuteScriptData as r, HandleExecuteScriptResponse as s, HandleExecuteScriptError as t, HandleDeployWebData as u, HandleDeployWebResponse as v, HandleDeployWebError as w, HandleGetLogsError as x };
138
+ export type { FreestyleExecuteScriptParamsConfiguration as F, HandleBackupCloudstateResponse as H, FreestyleExecureScriptResultSuccess as a, FreestyleDeployWebConfiguration as b, FreestyleDeployWebSuccessResponse as c, FreestyleCloudstateDeployRequest as d, FreestyleCloudstateDeploySuccessResponse as e, HandleGetLogsResponse as f, FreestyleCloudstateDeployConfiguration as g, FreestyleCloudstateDeployErrorResponse as h, FreestyleDeployWebErrorResponse as i, FreestyleDeployWebPayload as j, FreestyleExecureScriptResultError as k, FreestyleExecuteScriptParams as l, FreestyleFile as m, FreestyleLogResponseObject as n, HandleDeployCloudstateData as o, HandleDeployCloudstateResponse as p, HandleDeployCloudstateError as q, HandleBackupCloudstateError as r, HandleExecuteScriptData as s, HandleExecuteScriptResponse as t, HandleExecuteScriptError as u, HandleDeployWebData as v, HandleDeployWebResponse as w, HandleDeployWebError as x, HandleGetLogsError as y };
@@ -1,155 +1,164 @@
1
1
  // This file is auto-generated by @hey-api/openapi-ts
2
2
 
3
3
  export type FreestyleCloudstateDeployConfiguration = {
4
- /**
5
- * ID of the project to deploy, if not provided will create a new project
6
- */
7
- projectId?: string | null;
8
- /**
9
- * The environment variables that the cloudstate deploy can access
10
- */
11
- envVars?: {
12
- [key: string]: string;
13
- };
4
+ /**
5
+ * ID of the project to deploy, if not provided will create a new project
6
+ */
7
+ projectId?: (string) | null;
8
+ /**
9
+ * The environment variables that the cloudstate deploy can access
10
+ */
11
+ envVars?: {
12
+ [key: string]: (string);
13
+ };
14
14
  };
15
15
 
16
16
  export type FreestyleCloudstateDeployErrorResponse = {
17
- message: string;
17
+ message: string;
18
18
  };
19
19
 
20
20
  export type FreestyleCloudstateDeployRequest = {
21
- classes: string;
22
- config?: FreestyleCloudstateDeployConfiguration;
21
+ classes: string;
22
+ config?: FreestyleCloudstateDeployConfiguration;
23
23
  };
24
24
 
25
25
  export type FreestyleCloudstateDeploySuccessResponse = {
26
- /**
27
- * The id of the project deployed to
28
- */
29
- projectId: string;
26
+ /**
27
+ * The id of the project deployed to
28
+ */
29
+ projectId: string;
30
30
  };
31
31
 
32
32
  export type FreestyleDeployWebConfiguration = {
33
- /**
34
- * The entrypoint file for the website
35
- */
36
- entrypoint?: string | null;
37
- /**
38
- * The custom domains for the website, eg. [\"subdomain.yourwebsite.com\"]. You may not include *.style.dev domains here, those are reserved for projectIds
39
- */
40
- domains?: Array<string> | null;
41
- /**
42
- * The project id to deploy to, if not provided will create a new project, may be used to provision a new project with a specific id if that id is available
43
- */
44
- projectId?: string | null;
45
- /**
46
- * 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.
47
- */
48
- nodeModules?: {
49
- [key: string]: string;
50
- } | null;
51
- /**
52
- * The environment variables that the website can access
53
- * e.g. { \"RESEND_API_KEY\": \"re_123456789\" }
54
- */
55
- envVars?: {
56
- [key: string]: string;
57
- } | null;
33
+ /**
34
+ * The entrypoint file for the website
35
+ */
36
+ entrypoint?: (string) | null;
37
+ /**
38
+ * The custom domains for the website, eg. [\"subdomain.yourwebsite.com\"]. You may not include *.style.dev domains here, those are reserved for projectIds
39
+ */
40
+ domains?: Array<(string)> | null;
41
+ /**
42
+ * The project id to deploy to, if not provided will create a new project, may be used to provision a new project with a specific id if that id is available
43
+ */
44
+ projectId?: (string) | null;
45
+ /**
46
+ * 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.
47
+ */
48
+ nodeModules?: {
49
+ [key: string]: (string);
50
+ } | null;
51
+ /**
52
+ * The environment variables that the website can access
53
+ * e.g. { \"RESEND_API_KEY\": \"re_123456789\" }
54
+ */
55
+ envVars?: {
56
+ [key: string]: (string);
57
+ } | null;
58
58
  };
59
59
 
60
60
  export type FreestyleDeployWebErrorResponse = {
61
- message: string;
61
+ message: string;
62
62
  };
63
63
 
64
64
  export type FreestyleDeployWebPayload = {
65
- /**
66
- * The files to deploy, a map of file paths to file contents, e.g. { \"index.js\": \"your main", \"file2.js\": \"your helper\" }
67
- *
68
- * **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.
69
- */
70
- files: {
71
- [key: string]: string;
72
- };
73
- config?: FreestyleDeployWebConfiguration;
65
+ /**
66
+ * 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\" } }
67
+ *
68
+ * **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.
69
+ */
70
+ files: {
71
+ [key: string]: FreestyleFile;
72
+ };
73
+ config?: FreestyleDeployWebConfiguration;
74
74
  };
75
75
 
76
76
  export type FreestyleDeployWebSuccessResponse = {
77
- projectId: string;
77
+ projectId: string;
78
78
  };
79
79
 
80
80
  export type FreestyleExecureScriptResultError = {
81
- error: string;
81
+ error: string;
82
82
  };
83
83
 
84
84
  export type FreestyleExecureScriptResultSuccess = {
85
- result: unknown;
85
+ result: unknown;
86
86
  };
87
87
 
88
88
  export type FreestyleExecuteScriptParams = {
89
- /**
90
- * The JavaScript or TypeScript script to execute
91
- */
92
- script: string;
93
- config?: FreestyleExecuteScriptParamsConfiguration;
89
+ /**
90
+ * The JavaScript or TypeScript script to execute
91
+ */
92
+ script: string;
93
+ config?: FreestyleExecuteScriptParamsConfiguration;
94
94
  };
95
95
 
96
96
  export type FreestyleExecuteScriptParamsConfiguration = {
97
- /**
98
- * The environment variables to set for the script
99
- */
100
- envVars?: {
101
- [key: string]: string;
102
- };
103
- /**
104
- * The node modules to install for the script
105
- */
106
- nodeModules?: {
107
- [key: string]: string;
108
- };
109
- /**
110
- * Tags for you to organize your scripts, useful for tracking what you're running
111
- */
112
- tags?: Array<string>;
113
- /**
114
- * The script timeout
115
- */
116
- timeout?: string | null;
97
+ /**
98
+ * The environment variables to set for the script
99
+ */
100
+ envVars?: {
101
+ [key: string]: (string);
102
+ };
103
+ /**
104
+ * The node modules to install for the script
105
+ */
106
+ nodeModules?: {
107
+ [key: string]: (string);
108
+ };
109
+ /**
110
+ * Tags for you to organize your scripts, useful for tracking what you're running
111
+ */
112
+ tags?: Array<(string)>;
113
+ /**
114
+ * The script timeout
115
+ */
116
+ timeout?: (string) | null;
117
+ };
118
+
119
+ export type FreestyleFile = {
120
+ /**
121
+ * The content of the file
122
+ */
123
+ content: string;
124
+ /**
125
+ * The encoding of the file. Either **utf-8** or **base64**
126
+ */
127
+ encoding?: string;
117
128
  };
118
129
 
119
130
  export type FreestyleLogResponseObject = {
120
- message: string;
131
+ message: string;
121
132
  };
122
133
 
123
134
  export type HandleDeployCloudstateData = {
124
- body: FreestyleCloudstateDeployRequest;
135
+ body: FreestyleCloudstateDeployRequest;
125
136
  };
126
137
 
127
- export type HandleDeployCloudstateResponse =
128
- FreestyleCloudstateDeploySuccessResponse;
138
+ export type HandleDeployCloudstateResponse = (FreestyleCloudstateDeploySuccessResponse);
129
139
 
130
- export type HandleDeployCloudstateError =
131
- FreestyleCloudstateDeployErrorResponse;
140
+ export type HandleDeployCloudstateError = (FreestyleCloudstateDeployErrorResponse);
132
141
 
133
- export type HandleBackupCloudstateResponse = Array<number>;
142
+ export type HandleBackupCloudstateResponse = (Array<(number)>);
134
143
 
135
- export type HandleBackupCloudstateError = unknown;
144
+ export type HandleBackupCloudstateError = (unknown);
136
145
 
137
146
  export type HandleExecuteScriptData = {
138
- body: FreestyleExecuteScriptParams;
147
+ body: FreestyleExecuteScriptParams;
139
148
  };
140
149
 
141
- export type HandleExecuteScriptResponse = FreestyleExecureScriptResultSuccess;
150
+ export type HandleExecuteScriptResponse = (FreestyleExecureScriptResultSuccess);
142
151
 
143
- export type HandleExecuteScriptError = FreestyleExecureScriptResultError;
152
+ export type HandleExecuteScriptError = (FreestyleExecureScriptResultError);
144
153
 
145
154
  export type HandleDeployWebData = {
146
- body: FreestyleDeployWebPayload;
155
+ body: FreestyleDeployWebPayload;
147
156
  };
148
157
 
149
- export type HandleDeployWebResponse = FreestyleDeployWebSuccessResponse;
158
+ export type HandleDeployWebResponse = (FreestyleDeployWebSuccessResponse);
150
159
 
151
- export type HandleDeployWebError = FreestyleDeployWebErrorResponse;
160
+ export type HandleDeployWebError = (FreestyleDeployWebErrorResponse);
152
161
 
153
- export type HandleGetLogsResponse = Array<FreestyleLogResponseObject>;
162
+ export type HandleGetLogsResponse = (Array<FreestyleLogResponseObject>);
154
163
 
155
- export type HandleGetLogsError = unknown;
164
+ export type HandleGetLogsError = unknown;
package/openapi.json CHANGED
@@ -1 +1,432 @@
1
- {"openapi":"3.1.0","info":{"title":"Freestyle Sandoxes","description":"\nFreestyle Sandboxes lets you deploy your users or AIs code.\n \nThey are broken up into 3 categories: [Web](#tag/web), [Execute](#tag/execute) and [Cloudstate](#tag/cloudstate).\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","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","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"}}}},"/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"}}}}}}},"/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"}}}}}}},"/web/v1/projects/:id/logs":{"get":{"tags":["Web"],"summary":"Get Website Logs","description":"Get the logs for a project","operationId":"handle_get_logs","responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/FreestyleLogResponseObject"}}}}}}}}},"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"}}},"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 not include *.style.dev domains here, those are reserved for projectIds","example":["subdomain.yourdomain.com"],"default":null},"projectId":{"type":["string","null"],"description":"The project id to deploy to, if not provided will create a new project, may be used to provision a new project with a specific id if that id is available","default":null},"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"}}}},"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\\\": \\\"your main\", \\\"file2.js\\\": \\\"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":{"type":"string"},"propertyNames":{"type":"string"},"example":{"index.js":"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":["projectId"],"properties":{"projectId":{"type":"string"}}},"FreestyleExecureScriptResultError":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}},"FreestyleExecureScriptResultSuccess":{"type":"object","required":["result"],"properties":{"result":{}}},"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}}},"FreestyleLogResponseObject":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}},"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."}]}
1
+ {
2
+ "openapi": "3.1.0",
3
+ "info": {
4
+ "title": "Freestyle Sandboxes",
5
+ "description": "\nFreestyle Sandboxes lets you deploy your users or AIs code.\n \nThey are broken up into 3 categories: [Web](#tag/web), [Execute](#tag/execute) and [Cloudstate](#tag/cloudstate).\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",
6
+ "contact": { "name": "Ben", "email": "ben@freestyle.sh" },
7
+ "license": { "name": "" },
8
+ "version": "0.1.0"
9
+ },
10
+ "servers": [
11
+ { "url": "https://api.freestyle.sh", "description": "Production" }
12
+ ],
13
+ "paths": {
14
+ "/cloudstate/v1/deploy": {
15
+ "post": {
16
+ "tags": ["Cloudstate"],
17
+ "summary": "Deploy Cloudstate Project",
18
+ "description": "Deploy a cloudstate project",
19
+ "operationId": "handle_deploy_cloudstate",
20
+ "requestBody": {
21
+ "content": {
22
+ "application/json": {
23
+ "schema": {
24
+ "$ref": "#/components/schemas/FreestyleCloudstateDeployRequest"
25
+ }
26
+ }
27
+ },
28
+ "required": true
29
+ },
30
+ "responses": {
31
+ "200": {
32
+ "description": "successfully deployed",
33
+ "content": {
34
+ "application/json": {
35
+ "schema": {
36
+ "$ref": "#/components/schemas/FreestyleCloudstateDeploySuccessResponse"
37
+ }
38
+ }
39
+ }
40
+ },
41
+ "500": {
42
+ "description": "failed to deploy",
43
+ "content": {
44
+ "application/json": {
45
+ "schema": {
46
+ "$ref": "#/components/schemas/FreestyleCloudstateDeployErrorResponse"
47
+ }
48
+ }
49
+ }
50
+ }
51
+ }
52
+ }
53
+ },
54
+ "/cloudstate/v1/projects/:id/backup": {
55
+ "get": {
56
+ "tags": ["Cloudstate"],
57
+ "summary": "Get Backup of Cloudstate Project",
58
+ "description": "Get a backup of a cloudstate project",
59
+ "operationId": "handle_backup_cloudstate",
60
+ "responses": {
61
+ "200": {
62
+ "description": "successfully backed up",
63
+ "content": {
64
+ "application/octet-stream": {
65
+ "schema": {
66
+ "type": "array",
67
+ "items": {
68
+ "type": "integer",
69
+ "format": "int32",
70
+ "minimum": 0
71
+ }
72
+ }
73
+ }
74
+ }
75
+ },
76
+ "500": { "description": "failed to backup" }
77
+ }
78
+ }
79
+ },
80
+ "/execute/v1/script": {
81
+ "post": {
82
+ "tags": ["Execute"],
83
+ "summary": "Execute Code",
84
+ "description": "Send a TypeScript or JavaScript module, get the result",
85
+ "operationId": "handle_execute_script",
86
+ "requestBody": {
87
+ "content": {
88
+ "application/json": {
89
+ "schema": {
90
+ "$ref": "#/components/schemas/FreestyleExecuteScriptParams"
91
+ }
92
+ }
93
+ },
94
+ "required": true
95
+ },
96
+ "responses": {
97
+ "200": {
98
+ "description": "Success",
99
+ "content": {
100
+ "application/json": {
101
+ "schema": {
102
+ "$ref": "#/components/schemas/FreestyleExecureScriptResultSuccess"
103
+ }
104
+ }
105
+ }
106
+ },
107
+ "400": {
108
+ "description": "Error in your Script",
109
+ "content": {
110
+ "application/json": {
111
+ "schema": {
112
+ "$ref": "#/components/schemas/FreestyleExecureScriptResultError"
113
+ }
114
+ }
115
+ }
116
+ },
117
+ "500": {
118
+ "description": "Internal Error",
119
+ "content": {
120
+ "application/json": {
121
+ "schema": {
122
+ "$ref": "#/components/schemas/FreestyleExecureScriptResultError"
123
+ }
124
+ }
125
+ }
126
+ }
127
+ },
128
+ "x-codeSamples": [
129
+ {
130
+ "label": "Human SDK",
131
+ "lang": "JavaScript",
132
+ "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);"
133
+ },
134
+ {
135
+ "label": "AI SDK",
136
+ "lang": "JavaScript",
137
+ "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});"
138
+ }
139
+ ]
140
+ }
141
+ },
142
+ "/web/v1/deploy": {
143
+ "post": {
144
+ "tags": ["Web"],
145
+ "summary": "Deploy a Website",
146
+ "description": "Deploy a website. Files is a map of file paths to file contents. Configuration is optional and contains additional information about the deployment.",
147
+ "operationId": "handle_deploy_web",
148
+ "requestBody": {
149
+ "content": {
150
+ "application/json": {
151
+ "schema": {
152
+ "$ref": "#/components/schemas/FreestyleDeployWebPayload"
153
+ }
154
+ }
155
+ },
156
+ "required": true
157
+ },
158
+ "responses": {
159
+ "200": {
160
+ "description": "successfully deployed",
161
+ "content": {
162
+ "application/json": {
163
+ "schema": {
164
+ "$ref": "#/components/schemas/FreestyleDeployWebSuccessResponse"
165
+ }
166
+ }
167
+ }
168
+ },
169
+ "400": {
170
+ "description": "failed to deploy",
171
+ "content": {
172
+ "application/json": {
173
+ "schema": {
174
+ "$ref": "#/components/schemas/FreestyleDeployWebErrorResponse"
175
+ }
176
+ }
177
+ }
178
+ }
179
+ },
180
+ "x-codeSamples": [
181
+ {
182
+ "label": "Human SDK",
183
+ "lang": "JavaScript",
184
+ "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 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.projectId);\n });\n"
185
+ },
186
+ {
187
+ "label": "AI SDK",
188
+ "lang": "JavaScript",
189
+ "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});"
190
+ }
191
+ ]
192
+ }
193
+ },
194
+ "/web/v1/projects/:id/logs": {
195
+ "get": {
196
+ "tags": ["Web"],
197
+ "summary": "Get Website Logs",
198
+ "description": "Get the logs for a project",
199
+ "operationId": "handle_get_logs",
200
+ "responses": {
201
+ "200": {
202
+ "description": "",
203
+ "content": {
204
+ "application/json": {
205
+ "schema": {
206
+ "type": "array",
207
+ "items": {
208
+ "$ref": "#/components/schemas/FreestyleLogResponseObject"
209
+ }
210
+ }
211
+ }
212
+ }
213
+ }
214
+ },
215
+ "x-codeSamples": [
216
+ {
217
+ "label": "Human SDK",
218
+ "lang": "JavaScript",
219
+ "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});"
220
+ }
221
+ ]
222
+ }
223
+ }
224
+ },
225
+ "components": {
226
+ "schemas": {
227
+ "FreestyleCloudstateDeployConfiguration": {
228
+ "type": "object",
229
+ "properties": {
230
+ "projectId": {
231
+ "type": ["string", "null"],
232
+ "description": "ID of the project to deploy, if not provided will create a new project",
233
+ "default": null
234
+ },
235
+ "envVars": {
236
+ "type": "object",
237
+ "description": "The environment variables that the cloudstate deploy can access",
238
+ "default": {},
239
+ "additionalProperties": { "type": "string" },
240
+ "propertyNames": { "type": "string" }
241
+ }
242
+ }
243
+ },
244
+ "FreestyleCloudstateDeployErrorResponse": {
245
+ "type": "object",
246
+ "required": ["message"],
247
+ "properties": { "message": { "type": "string" } }
248
+ },
249
+ "FreestyleCloudstateDeployRequest": {
250
+ "type": "object",
251
+ "required": ["classes"],
252
+ "properties": {
253
+ "classes": { "type": "string" },
254
+ "config": {
255
+ "$ref": "#/components/schemas/FreestyleCloudstateDeployConfiguration"
256
+ }
257
+ }
258
+ },
259
+ "FreestyleCloudstateDeploySuccessResponse": {
260
+ "type": "object",
261
+ "required": ["projectId"],
262
+ "properties": {
263
+ "projectId": {
264
+ "type": "string",
265
+ "description": "The id of the project deployed to"
266
+ }
267
+ }
268
+ },
269
+ "FreestyleDeployWebConfiguration": {
270
+ "type": "object",
271
+ "properties": {
272
+ "entrypoint": {
273
+ "type": ["string", "null"],
274
+ "description": "The entrypoint file for the website",
275
+ "default": "index.js"
276
+ },
277
+ "domains": {
278
+ "type": ["array", "null"],
279
+ "items": { "type": "string" },
280
+ "description": "The custom domains for the website, eg. [\\\"subdomain.yourwebsite.com\\\"]. You may not include *.style.dev domains here, those are reserved for projectIds",
281
+ "example": ["subdomain.yourdomain.com"],
282
+ "default": null
283
+ },
284
+ "projectId": {
285
+ "type": ["string", "null"],
286
+ "description": "The project id to deploy to, if not provided will create a new project, may be used to provision a new project with a specific id if that id is available",
287
+ "default": null
288
+ },
289
+ "nodeModules": {
290
+ "type": ["object", "null"],
291
+ "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.",
292
+ "default": null,
293
+ "additionalProperties": { "type": "string" },
294
+ "propertyNames": { "type": "string" },
295
+ "example": { "resend": "4.0.1" }
296
+ },
297
+ "envVars": {
298
+ "type": ["object", "null"],
299
+ "description": "The environment variables that the website can access\ne.g. { \\\"RESEND_API_KEY\\\": \\\"re_123456789\\\" }",
300
+ "default": null,
301
+ "additionalProperties": { "type": "string" },
302
+ "propertyNames": { "type": "string" },
303
+ "example": { "RESEND_API_KEY": "re_123456789" }
304
+ }
305
+ }
306
+ },
307
+ "FreestyleDeployWebErrorResponse": {
308
+ "type": "object",
309
+ "required": ["message"],
310
+ "properties": { "message": { "type": "string" } }
311
+ },
312
+ "FreestyleDeployWebPayload": {
313
+ "type": "object",
314
+ "required": ["files"],
315
+ "properties": {
316
+ "files": {
317
+ "type": "object",
318
+ "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.",
319
+ "additionalProperties": {
320
+ "$ref": "#/components/schemas/FreestyleFile"
321
+ },
322
+ "propertyNames": { "type": "string" },
323
+ "example": {
324
+ "index.js": {
325
+ "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});"
326
+ }
327
+ }
328
+ },
329
+ "config": {
330
+ "$ref": "#/components/schemas/FreestyleDeployWebConfiguration"
331
+ }
332
+ }
333
+ },
334
+ "FreestyleDeployWebSuccessResponse": {
335
+ "type": "object",
336
+ "required": ["projectId"],
337
+ "properties": { "projectId": { "type": "string" } }
338
+ },
339
+ "FreestyleExecureScriptResultError": {
340
+ "type": "object",
341
+ "required": ["error"],
342
+ "properties": { "error": { "type": "string" } }
343
+ },
344
+ "FreestyleExecureScriptResultSuccess": {
345
+ "type": "object",
346
+ "required": ["result"],
347
+ "properties": { "result": {} }
348
+ },
349
+ "FreestyleExecuteScriptParams": {
350
+ "type": "object",
351
+ "required": ["script"],
352
+ "properties": {
353
+ "script": {
354
+ "type": "string",
355
+ "description": "The JavaScript or TypeScript script to execute",
356
+ "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"
357
+ },
358
+ "config": {
359
+ "$ref": "#/components/schemas/FreestyleExecuteScriptParamsConfiguration"
360
+ }
361
+ }
362
+ },
363
+ "FreestyleExecuteScriptParamsConfiguration": {
364
+ "type": "object",
365
+ "properties": {
366
+ "envVars": {
367
+ "type": "object",
368
+ "description": "The environment variables to set for the script",
369
+ "default": {},
370
+ "additionalProperties": { "type": "string" },
371
+ "propertyNames": { "type": "string" },
372
+ "example": { "RESEND_API_KEY": "re_123456789" }
373
+ },
374
+ "nodeModules": {
375
+ "type": "object",
376
+ "description": "The node modules to install for the script",
377
+ "default": {},
378
+ "additionalProperties": { "type": "string" },
379
+ "propertyNames": { "type": "string" },
380
+ "example": { "resend": "4.0.1" }
381
+ },
382
+ "tags": {
383
+ "type": "array",
384
+ "items": { "type": "string" },
385
+ "description": "Tags for you to organize your scripts, useful for tracking what you're running",
386
+ "example": ["email"],
387
+ "default": []
388
+ },
389
+ "timeout": {
390
+ "type": ["string", "null"],
391
+ "description": "The script timeout",
392
+ "default": null
393
+ }
394
+ }
395
+ },
396
+ "FreestyleFile": {
397
+ "type": "object",
398
+ "required": ["content"],
399
+ "properties": {
400
+ "content": {
401
+ "type": "string",
402
+ "description": "The content of the file"
403
+ },
404
+ "encoding": {
405
+ "type": "string",
406
+ "description": "The encoding of the file. Either **utf-8** or **base64**"
407
+ }
408
+ }
409
+ },
410
+ "FreestyleLogResponseObject": {
411
+ "type": "object",
412
+ "required": ["message"],
413
+ "properties": { "message": { "type": "string" } }
414
+ }
415
+ },
416
+ "securitySchemes": { "bearerAuth": { "type": "http", "scheme": "bearer" } }
417
+ },
418
+ "tags": [
419
+ {
420
+ "name": "Web",
421
+ "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."
422
+ },
423
+ {
424
+ "name": "Execute",
425
+ "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."
426
+ },
427
+ {
428
+ "name": "Cloudstate",
429
+ "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."
430
+ }
431
+ ]
432
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "freestyle-sandboxes",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -42,6 +42,9 @@
42
42
  "dependencies": {
43
43
  "@hey-api/client-fetch": "^0.5.7",
44
44
  "ai": "^4.0.25",
45
+ "humanlayer": "^0.7.0",
46
+ "openai": "^4.77.3",
47
+ "openapi": "^1.0.1",
45
48
  "zod": "^3.24.1"
46
49
  }
47
50
  }
package/src/ai/index.ts CHANGED
@@ -99,8 +99,13 @@ export const deployWebTool = (
99
99
  `),
100
100
  }),
101
101
  execute: async ({ files }) => {
102
+ // map from record<string, string> to record<string, {content: string}>
103
+ const new_files = Object.keys(files).reduce((acc, key) => {
104
+ acc[key] = { content: files[key] };
105
+ return acc;
106
+ }, {} as Record<string, { content: string }>);
102
107
  try {
103
- const res = await api.deployWeb(files, config);
108
+ const res = await api.deployWeb(new_files, config);
104
109
  return res;
105
110
  } catch (e) {
106
111
  console.log("ERROR: ", e.message);
package/src/index.ts CHANGED
@@ -50,7 +50,13 @@ export class FreestyleSandboxes {
50
50
  * Deploy a Web project to a sandbox.
51
51
  */
52
52
  async deployWeb(
53
- files: Record<string, string>,
53
+ files: Record<
54
+ string,
55
+ {
56
+ content: string;
57
+ encoding?: string;
58
+ }
59
+ >,
54
60
  config?: sandbox_openapi.FreestyleDeployWebConfiguration
55
61
  ): Promise<sandbox_openapi.FreestyleDeployWebSuccessResponse> {
56
62
  const response = await sandbox_openapi.handleDeployWeb({
@@ -63,7 +69,9 @@ export class FreestyleSandboxes {
63
69
  if (response.data) {
64
70
  return response.data;
65
71
  } else {
66
- throw new Error("Failed to deploy Web project");
72
+ throw new Error(
73
+ `Failed to deploy web project\n\nStatus: ${response.response.status}\n\nMessage: ${response.error?.message}`
74
+ );
67
75
  }
68
76
  }
69
77
 
@@ -1,84 +0,0 @@
1
- type FreestyleCloudstateDeployConfiguration = {
2
- /**
3
- * ID of the project to deploy, if not provided will create a new project
4
- */
5
- projectId?: (string) | null;
6
- /**
7
- * The environment variables that the cloudstate deploy can access
8
- */
9
- envVars?: {
10
- [key: string]: (string);
11
- };
12
- };
13
- type FreestyleCloudstateDeployRequest = {
14
- classes: string;
15
- config?: FreestyleCloudstateDeployConfiguration;
16
- };
17
- type FreestyleCloudstateDeploySuccessResponse = {
18
- /**
19
- * The id of the project deployed to
20
- */
21
- projectId: string;
22
- };
23
- type FreestyleDeployWebConfiguration = {
24
- /**
25
- * The entrypoint file for the website
26
- */
27
- entrypoint?: (string) | null;
28
- /**
29
- * The custom domains for the website, eg. [\"subdomain.yourwebsite.com\"]. You may not include *.style.dev domains here, those are reserved for projectIds
30
- */
31
- domains?: Array<(string)> | null;
32
- /**
33
- * The project id to deploy to, if not provided will create a new project, may be used to provision a new project with a specific id if that id is available
34
- */
35
- projectId?: (string) | null;
36
- /**
37
- * 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.
38
- */
39
- nodeModules?: {
40
- [key: string]: (string);
41
- } | null;
42
- /**
43
- * The environment variables that the website can access
44
- * e.g. { \"RESEND_API_KEY\": \"re_123456789\" }
45
- */
46
- envVars?: {
47
- [key: string]: (string);
48
- } | null;
49
- };
50
- type FreestyleDeployWebSuccessResponse = {
51
- projectId: string;
52
- };
53
- type FreestyleExecureScriptResultSuccess = {
54
- result: unknown;
55
- };
56
- type FreestyleExecuteScriptParamsConfiguration = {
57
- /**
58
- * The environment variables to set for the script
59
- */
60
- envVars?: {
61
- [key: string]: (string);
62
- };
63
- /**
64
- * The node modules to install for the script
65
- */
66
- nodeModules?: {
67
- [key: string]: (string);
68
- };
69
- /**
70
- * Tags for you to organize your scripts, useful for tracking what you're running
71
- */
72
- tags?: Array<(string)>;
73
- /**
74
- * The script timeout
75
- */
76
- timeout?: (string) | null;
77
- };
78
- type FreestyleLogResponseObject = {
79
- message: string;
80
- };
81
- type HandleBackupCloudstateResponse = (Array<(number)>);
82
- type HandleGetLogsResponse = (Array<FreestyleLogResponseObject>);
83
-
84
- export type { FreestyleExecuteScriptParamsConfiguration as F, HandleBackupCloudstateResponse as H, FreestyleExecureScriptResultSuccess as a, FreestyleDeployWebConfiguration as b, FreestyleDeployWebSuccessResponse as c, FreestyleCloudstateDeployRequest as d, FreestyleCloudstateDeploySuccessResponse as e, HandleGetLogsResponse as f };