freestyle-sandboxes 0.0.8 → 0.0.10

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.
@@ -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-DbTb_SrD.js';
2
+ import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecureScriptResultSuccess, c as FreestyleDeployWebSuccessResponse } from '../types.gen-1sd31qLV.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-DbTb_SrD.js';
2
+ import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecureScriptResultSuccess, c as FreestyleDeployWebSuccessResponse } from '../types.gen-1sd31qLV.js';
3
3
  import { z } from 'zod';
4
4
 
5
5
  /**
package/dist/index.cjs CHANGED
@@ -15,12 +15,24 @@ const handleBackupCloudstate = (options) => {
15
15
  url: "/cloudstate/v1/projects/:id/backup"
16
16
  });
17
17
  };
18
+ const handleListDomains = (options) => {
19
+ return (options?.client ?? client).get({
20
+ ...options,
21
+ url: "/domains/v1/domains"
22
+ });
23
+ };
18
24
  const handleVerifyDomain = (options) => {
19
25
  return (options?.client ?? client).put({
20
26
  ...options,
21
27
  url: "/domains/v1/verifications"
22
28
  });
23
29
  };
30
+ const handleCreateDomainVerification = (options) => {
31
+ return (options?.client ?? client).post({
32
+ ...options,
33
+ url: "/domains/v1/verifications"
34
+ });
35
+ };
24
36
  const handleExecuteScript = (options) => {
25
37
  return (options?.client ?? client).post({
26
38
  ...options,
@@ -159,7 +171,7 @@ Message: ${response.error?.message}`
159
171
  * @returns The domain verification token.
160
172
  */
161
173
  async createDomainVerificationRequest(domain) {
162
- const response = await handleVerifyDomain({
174
+ const response = await handleCreateDomainVerification({
163
175
  client: this.client,
164
176
  body: {
165
177
  domain
@@ -193,6 +205,16 @@ Message: ${response.error?.message}`
193
205
  );
194
206
  }
195
207
  }
208
+ async listDomains() {
209
+ const response = await handleListDomains({
210
+ client: this.client
211
+ });
212
+ if (response.data) {
213
+ return response.data;
214
+ } else {
215
+ throw new Error("Failed to list domains");
216
+ }
217
+ }
196
218
  }
197
219
 
198
220
  exports.FreestyleSandboxes = FreestyleSandboxes;
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, g as HandleVerifyDomainResponse } from './types.gen-DbTb_SrD.js';
2
- export { h as FreestyleCloudstateDeployConfiguration, i as FreestyleCloudstateDeployErrorResponse, j as FreestyleDeployWebErrorResponse, k as FreestyleDeployWebPayload, l as FreestyleDomainVerificationRequest, m as FreestyleExecureScriptResultError, n as FreestyleExecuteScriptParams, o as FreestyleFile, p as FreestyleLogResponseObject, q as FreestyleVerifyDomainRequest, u as HandleBackupCloudstateError, x as HandleCreateDomainVerificationData, r as HandleDeployCloudstateData, t as HandleDeployCloudstateError, s as HandleDeployCloudstateResponse, B as HandleDeployWebData, D as HandleDeployWebError, C as HandleDeployWebResponse, y as HandleExecuteScriptData, A as HandleExecuteScriptError, z as HandleExecuteScriptResponse, E as HandleGetLogsError, v as HandleVerifyDomainData, w as HandleVerifyDomainError } from './types.gen-DbTb_SrD.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, g as HandleCreateDomainVerificationResponse, h as HandleVerifyDomainResponse, i as HandleListDomainsResponse } from './types.gen-1sd31qLV.js';
2
+ export { j as FreestyleCloudstateDeployConfiguration, k as FreestyleCloudstateDeployErrorResponse, l as FreestyleDeployWebErrorResponse, m as FreestyleDeployWebPayload, n as FreestyleDomainVerificationRequest, o as FreestyleExecureScriptResultError, p as FreestyleExecuteScriptParams, q as FreestyleFile, r as FreestyleLogResponseObject, s as FreestyleVerifyDomainRequest, w as HandleBackupCloudstateError, A as HandleCreateDomainVerificationData, B as HandleCreateDomainVerificationError, t as HandleDeployCloudstateData, v as HandleDeployCloudstateError, u as HandleDeployCloudstateResponse, G as HandleDeployWebData, J as HandleDeployWebError, I as HandleDeployWebResponse, C as HandleExecuteScriptData, E as HandleExecuteScriptError, D as HandleExecuteScriptResponse, K as HandleGetLogsError, x as HandleListDomainsError, y as HandleVerifyDomainData, z as HandleVerifyDomainError } from './types.gen-1sd31qLV.js';
3
3
 
4
4
  declare class FreestyleSandboxes {
5
5
  private client;
@@ -51,13 +51,14 @@ declare class FreestyleSandboxes {
51
51
  * @param domain The domain to verify.
52
52
  * @returns The domain verification token.
53
53
  */
54
- createDomainVerificationRequest(domain: string): Promise<HandleVerifyDomainResponse>;
54
+ createDomainVerificationRequest(domain: string): Promise<HandleCreateDomainVerificationResponse>;
55
55
  /**
56
56
  * Verify a domain. Note, this requires the domain verification token to be already set up.
57
57
  * @param domain The domain to verify.
58
58
  * @returns The domain verification request.
59
59
  */
60
60
  verifyDomain(domain: string): Promise<HandleVerifyDomainResponse>;
61
+ listDomains(): Promise<HandleListDomainsResponse>;
61
62
  }
62
63
 
63
- export { FreestyleCloudstateDeployRequest, FreestyleCloudstateDeploySuccessResponse, FreestyleDeployWebConfiguration, FreestyleDeployWebSuccessResponse, FreestyleExecureScriptResultSuccess, FreestyleExecuteScriptParamsConfiguration, FreestyleSandboxes, HandleBackupCloudstateResponse, HandleGetLogsResponse, HandleVerifyDomainResponse };
64
+ export { FreestyleCloudstateDeployRequest, FreestyleCloudstateDeploySuccessResponse, FreestyleDeployWebConfiguration, FreestyleDeployWebSuccessResponse, FreestyleExecureScriptResultSuccess, FreestyleExecuteScriptParamsConfiguration, FreestyleSandboxes, HandleBackupCloudstateResponse, HandleCreateDomainVerificationResponse, HandleGetLogsResponse, HandleListDomainsResponse, HandleVerifyDomainResponse };
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, g as HandleVerifyDomainResponse } from './types.gen-DbTb_SrD.js';
2
- export { h as FreestyleCloudstateDeployConfiguration, i as FreestyleCloudstateDeployErrorResponse, j as FreestyleDeployWebErrorResponse, k as FreestyleDeployWebPayload, l as FreestyleDomainVerificationRequest, m as FreestyleExecureScriptResultError, n as FreestyleExecuteScriptParams, o as FreestyleFile, p as FreestyleLogResponseObject, q as FreestyleVerifyDomainRequest, u as HandleBackupCloudstateError, x as HandleCreateDomainVerificationData, r as HandleDeployCloudstateData, t as HandleDeployCloudstateError, s as HandleDeployCloudstateResponse, B as HandleDeployWebData, D as HandleDeployWebError, C as HandleDeployWebResponse, y as HandleExecuteScriptData, A as HandleExecuteScriptError, z as HandleExecuteScriptResponse, E as HandleGetLogsError, v as HandleVerifyDomainData, w as HandleVerifyDomainError } from './types.gen-DbTb_SrD.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, g as HandleCreateDomainVerificationResponse, h as HandleVerifyDomainResponse, i as HandleListDomainsResponse } from './types.gen-1sd31qLV.js';
2
+ export { j as FreestyleCloudstateDeployConfiguration, k as FreestyleCloudstateDeployErrorResponse, l as FreestyleDeployWebErrorResponse, m as FreestyleDeployWebPayload, n as FreestyleDomainVerificationRequest, o as FreestyleExecureScriptResultError, p as FreestyleExecuteScriptParams, q as FreestyleFile, r as FreestyleLogResponseObject, s as FreestyleVerifyDomainRequest, w as HandleBackupCloudstateError, A as HandleCreateDomainVerificationData, B as HandleCreateDomainVerificationError, t as HandleDeployCloudstateData, v as HandleDeployCloudstateError, u as HandleDeployCloudstateResponse, G as HandleDeployWebData, J as HandleDeployWebError, I as HandleDeployWebResponse, C as HandleExecuteScriptData, E as HandleExecuteScriptError, D as HandleExecuteScriptResponse, K as HandleGetLogsError, x as HandleListDomainsError, y as HandleVerifyDomainData, z as HandleVerifyDomainError } from './types.gen-1sd31qLV.js';
3
3
 
4
4
  declare class FreestyleSandboxes {
5
5
  private client;
@@ -51,13 +51,14 @@ declare class FreestyleSandboxes {
51
51
  * @param domain The domain to verify.
52
52
  * @returns The domain verification token.
53
53
  */
54
- createDomainVerificationRequest(domain: string): Promise<HandleVerifyDomainResponse>;
54
+ createDomainVerificationRequest(domain: string): Promise<HandleCreateDomainVerificationResponse>;
55
55
  /**
56
56
  * Verify a domain. Note, this requires the domain verification token to be already set up.
57
57
  * @param domain The domain to verify.
58
58
  * @returns The domain verification request.
59
59
  */
60
60
  verifyDomain(domain: string): Promise<HandleVerifyDomainResponse>;
61
+ listDomains(): Promise<HandleListDomainsResponse>;
61
62
  }
62
63
 
63
- export { FreestyleCloudstateDeployRequest, FreestyleCloudstateDeploySuccessResponse, FreestyleDeployWebConfiguration, FreestyleDeployWebSuccessResponse, FreestyleExecureScriptResultSuccess, FreestyleExecuteScriptParamsConfiguration, FreestyleSandboxes, HandleBackupCloudstateResponse, HandleGetLogsResponse, HandleVerifyDomainResponse };
64
+ export { FreestyleCloudstateDeployRequest, FreestyleCloudstateDeploySuccessResponse, FreestyleDeployWebConfiguration, FreestyleDeployWebSuccessResponse, FreestyleExecureScriptResultSuccess, FreestyleExecuteScriptParamsConfiguration, FreestyleSandboxes, HandleBackupCloudstateResponse, HandleCreateDomainVerificationResponse, HandleGetLogsResponse, HandleListDomainsResponse, HandleVerifyDomainResponse };
package/dist/index.mjs CHANGED
@@ -13,12 +13,24 @@ const handleBackupCloudstate = (options) => {
13
13
  url: "/cloudstate/v1/projects/:id/backup"
14
14
  });
15
15
  };
16
+ const handleListDomains = (options) => {
17
+ return (options?.client ?? client).get({
18
+ ...options,
19
+ url: "/domains/v1/domains"
20
+ });
21
+ };
16
22
  const handleVerifyDomain = (options) => {
17
23
  return (options?.client ?? client).put({
18
24
  ...options,
19
25
  url: "/domains/v1/verifications"
20
26
  });
21
27
  };
28
+ const handleCreateDomainVerification = (options) => {
29
+ return (options?.client ?? client).post({
30
+ ...options,
31
+ url: "/domains/v1/verifications"
32
+ });
33
+ };
22
34
  const handleExecuteScript = (options) => {
23
35
  return (options?.client ?? client).post({
24
36
  ...options,
@@ -157,7 +169,7 @@ Message: ${response.error?.message}`
157
169
  * @returns The domain verification token.
158
170
  */
159
171
  async createDomainVerificationRequest(domain) {
160
- const response = await handleVerifyDomain({
172
+ const response = await handleCreateDomainVerification({
161
173
  client: this.client,
162
174
  body: {
163
175
  domain
@@ -191,6 +203,16 @@ Message: ${response.error?.message}`
191
203
  );
192
204
  }
193
205
  }
206
+ async listDomains() {
207
+ const response = await handleListDomains({
208
+ client: this.client
209
+ });
210
+ if (response.data) {
211
+ return response.data;
212
+ } else {
213
+ throw new Error("Failed to list domains");
214
+ }
215
+ }
194
216
  }
195
217
 
196
218
  export { FreestyleSandboxes };
@@ -0,0 +1,172 @@
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 FreestyleCloudstateDeployErrorResponse = {
14
+ message: string;
15
+ };
16
+ type FreestyleCloudstateDeployRequest = {
17
+ classes: string;
18
+ config?: FreestyleCloudstateDeployConfiguration;
19
+ };
20
+ type FreestyleCloudstateDeploySuccessResponse = {
21
+ /**
22
+ * The id of the project deployed to
23
+ */
24
+ projectId: string;
25
+ };
26
+ type FreestyleDeployWebConfiguration = {
27
+ /**
28
+ * The entrypoint file for the website
29
+ */
30
+ entrypoint?: (string) | null;
31
+ /**
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
+ */
34
+ domains?: Array<(string)> | null;
35
+ /**
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
+ */
38
+ projectId?: (string) | null;
39
+ /**
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
+ */
42
+ nodeModules?: {
43
+ [key: string]: (string);
44
+ } | null;
45
+ /**
46
+ * The environment variables that the website can access
47
+ * e.g. { \"RESEND_API_KEY\": \"re_123456789\" }
48
+ */
49
+ envVars?: {
50
+ [key: string]: (string);
51
+ } | null;
52
+ };
53
+ type FreestyleDeployWebErrorResponse = {
54
+ message: string;
55
+ };
56
+ type FreestyleDeployWebPayload = {
57
+ /**
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
+ *
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
+ */
62
+ files: {
63
+ [key: string]: FreestyleFile;
64
+ };
65
+ config?: FreestyleDeployWebConfiguration;
66
+ };
67
+ type FreestyleDeployWebSuccessResponse = {
68
+ projectId: string;
69
+ };
70
+ type FreestyleDomainVerificationRequest = {
71
+ /**
72
+ * The domain to create a verification code for
73
+ */
74
+ domain: string;
75
+ };
76
+ type FreestyleExecureScriptResultError = {
77
+ error: string;
78
+ };
79
+ type FreestyleExecureScriptResultSuccess = {
80
+ result: unknown;
81
+ };
82
+ type FreestyleExecuteScriptParams = {
83
+ /**
84
+ * The JavaScript or TypeScript script to execute
85
+ */
86
+ script: string;
87
+ config?: FreestyleExecuteScriptParamsConfiguration;
88
+ };
89
+ type FreestyleExecuteScriptParamsConfiguration = {
90
+ /**
91
+ * The environment variables to set for the script
92
+ */
93
+ envVars?: {
94
+ [key: string]: (string);
95
+ };
96
+ /**
97
+ * The node modules to install for the script
98
+ */
99
+ nodeModules?: {
100
+ [key: string]: (string);
101
+ };
102
+ /**
103
+ * Tags for you to organize your scripts, useful for tracking what you're running
104
+ */
105
+ tags?: Array<(string)>;
106
+ /**
107
+ * The script timeout
108
+ */
109
+ timeout?: (string) | null;
110
+ };
111
+ type FreestyleFile = {
112
+ /**
113
+ * The content of the file
114
+ */
115
+ content: string;
116
+ /**
117
+ * The encoding of the file. Either **utf-8** or **base64**
118
+ */
119
+ encoding?: string;
120
+ };
121
+ type FreestyleLogResponseObject = {
122
+ message: string;
123
+ };
124
+ type FreestyleVerifyDomainRequest = {
125
+ domain: string;
126
+ };
127
+ type HandleDeployCloudstateData = {
128
+ body: FreestyleCloudstateDeployRequest;
129
+ };
130
+ type HandleDeployCloudstateResponse = (FreestyleCloudstateDeploySuccessResponse);
131
+ type HandleDeployCloudstateError = (FreestyleCloudstateDeployErrorResponse);
132
+ type HandleBackupCloudstateResponse = (Array<(number)>);
133
+ type HandleBackupCloudstateError = (unknown);
134
+ type HandleListDomainsResponse = ({
135
+ domains: Array<(string)>;
136
+ });
137
+ type HandleListDomainsError = ({
138
+ message: string;
139
+ });
140
+ type HandleVerifyDomainData = {
141
+ body: FreestyleVerifyDomainRequest;
142
+ };
143
+ type HandleVerifyDomainResponse = ({
144
+ domain: string;
145
+ });
146
+ type HandleVerifyDomainError = ({
147
+ message: string;
148
+ });
149
+ type HandleCreateDomainVerificationData = {
150
+ body: FreestyleDomainVerificationRequest;
151
+ };
152
+ type HandleCreateDomainVerificationResponse = ({
153
+ verification_code: string;
154
+ domain: string;
155
+ });
156
+ type HandleCreateDomainVerificationError = ({
157
+ message: string;
158
+ });
159
+ type HandleExecuteScriptData = {
160
+ body: FreestyleExecuteScriptParams;
161
+ };
162
+ type HandleExecuteScriptResponse = (FreestyleExecureScriptResultSuccess);
163
+ type HandleExecuteScriptError = (FreestyleExecureScriptResultError);
164
+ type HandleDeployWebData = {
165
+ body: FreestyleDeployWebPayload;
166
+ };
167
+ type HandleDeployWebResponse = (FreestyleDeployWebSuccessResponse);
168
+ type HandleDeployWebError = (FreestyleDeployWebErrorResponse);
169
+ type HandleGetLogsResponse = (Array<FreestyleLogResponseObject>);
170
+ type HandleGetLogsError = unknown;
171
+
172
+ export type { HandleCreateDomainVerificationData as A, HandleCreateDomainVerificationError as B, HandleExecuteScriptData as C, HandleExecuteScriptResponse as D, HandleExecuteScriptError as E, FreestyleExecuteScriptParamsConfiguration as F, HandleDeployWebData as G, HandleBackupCloudstateResponse as H, HandleDeployWebResponse as I, HandleDeployWebError as J, HandleGetLogsError as K, FreestyleExecureScriptResultSuccess as a, FreestyleDeployWebConfiguration as b, FreestyleDeployWebSuccessResponse as c, FreestyleCloudstateDeployRequest as d, FreestyleCloudstateDeploySuccessResponse as e, HandleGetLogsResponse as f, HandleCreateDomainVerificationResponse as g, HandleVerifyDomainResponse as h, HandleListDomainsResponse as i, FreestyleCloudstateDeployConfiguration as j, FreestyleCloudstateDeployErrorResponse as k, FreestyleDeployWebErrorResponse as l, FreestyleDeployWebPayload as m, FreestyleDomainVerificationRequest as n, FreestyleExecureScriptResultError as o, FreestyleExecuteScriptParams as p, FreestyleFile as q, FreestyleLogResponseObject as r, FreestyleVerifyDomainRequest as s, HandleDeployCloudstateData as t, HandleDeployCloudstateResponse as u, HandleDeployCloudstateError as v, HandleBackupCloudstateError as w, HandleListDomainsError as x, HandleVerifyDomainData as y, HandleVerifyDomainError as z };
@@ -0,0 +1,172 @@
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 FreestyleCloudstateDeployErrorResponse = {
14
+ message: string;
15
+ };
16
+ type FreestyleCloudstateDeployRequest = {
17
+ classes: string;
18
+ config?: FreestyleCloudstateDeployConfiguration;
19
+ };
20
+ type FreestyleCloudstateDeploySuccessResponse = {
21
+ /**
22
+ * The id of the project deployed to
23
+ */
24
+ projectId: string;
25
+ };
26
+ type FreestyleDeployWebConfiguration = {
27
+ /**
28
+ * The entrypoint file for the website
29
+ */
30
+ entrypoint?: (string) | null;
31
+ /**
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
+ */
34
+ domains?: Array<(string)> | null;
35
+ /**
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
+ */
38
+ projectId?: (string) | null;
39
+ /**
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
+ */
42
+ nodeModules?: {
43
+ [key: string]: (string);
44
+ } | null;
45
+ /**
46
+ * The environment variables that the website can access
47
+ * e.g. { \"RESEND_API_KEY\": \"re_123456789\" }
48
+ */
49
+ envVars?: {
50
+ [key: string]: (string);
51
+ } | null;
52
+ };
53
+ type FreestyleDeployWebErrorResponse = {
54
+ message: string;
55
+ };
56
+ type FreestyleDeployWebPayload = {
57
+ /**
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
+ *
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
+ */
62
+ files: {
63
+ [key: string]: FreestyleFile;
64
+ };
65
+ config?: FreestyleDeployWebConfiguration;
66
+ };
67
+ type FreestyleDeployWebSuccessResponse = {
68
+ projectId: string;
69
+ };
70
+ type FreestyleDomainVerificationRequest = {
71
+ /**
72
+ * The domain to create a verification code for
73
+ */
74
+ domain: string;
75
+ };
76
+ type FreestyleExecureScriptResultError = {
77
+ error: string;
78
+ };
79
+ type FreestyleExecureScriptResultSuccess = {
80
+ result: unknown;
81
+ };
82
+ type FreestyleExecuteScriptParams = {
83
+ /**
84
+ * The JavaScript or TypeScript script to execute
85
+ */
86
+ script: string;
87
+ config?: FreestyleExecuteScriptParamsConfiguration;
88
+ };
89
+ type FreestyleExecuteScriptParamsConfiguration = {
90
+ /**
91
+ * The environment variables to set for the script
92
+ */
93
+ envVars?: {
94
+ [key: string]: (string);
95
+ };
96
+ /**
97
+ * The node modules to install for the script
98
+ */
99
+ nodeModules?: {
100
+ [key: string]: (string);
101
+ };
102
+ /**
103
+ * Tags for you to organize your scripts, useful for tracking what you're running
104
+ */
105
+ tags?: Array<(string)>;
106
+ /**
107
+ * The script timeout
108
+ */
109
+ timeout?: (string) | null;
110
+ };
111
+ type FreestyleFile = {
112
+ /**
113
+ * The content of the file
114
+ */
115
+ content: string;
116
+ /**
117
+ * The encoding of the file. Either **utf-8** or **base64**
118
+ */
119
+ encoding?: string;
120
+ };
121
+ type FreestyleLogResponseObject = {
122
+ message: string;
123
+ };
124
+ type FreestyleVerifyDomainRequest = {
125
+ domain: string;
126
+ };
127
+ type HandleDeployCloudstateData = {
128
+ body: FreestyleCloudstateDeployRequest;
129
+ };
130
+ type HandleDeployCloudstateResponse = (FreestyleCloudstateDeploySuccessResponse);
131
+ type HandleDeployCloudstateError = (FreestyleCloudstateDeployErrorResponse);
132
+ type HandleBackupCloudstateResponse = (Array<(number)>);
133
+ type HandleBackupCloudstateError = (unknown);
134
+ type HandleListDomainsResponse = ({
135
+ domains: Array<(string)>;
136
+ });
137
+ type HandleListDomainsError = ({
138
+ message: string;
139
+ });
140
+ type HandleVerifyDomainData = {
141
+ body: FreestyleVerifyDomainRequest;
142
+ };
143
+ type HandleVerifyDomainResponse = ({
144
+ domain: string;
145
+ });
146
+ type HandleVerifyDomainError = ({
147
+ message: string;
148
+ });
149
+ type HandleCreateDomainVerificationData = {
150
+ body: FreestyleDomainVerificationRequest;
151
+ };
152
+ type HandleCreateDomainVerificationResponse = ({
153
+ verification_code: string;
154
+ domain: string;
155
+ });
156
+ type HandleCreateDomainVerificationError = ({
157
+ message: string;
158
+ });
159
+ type HandleExecuteScriptData = {
160
+ body: FreestyleExecuteScriptParams;
161
+ };
162
+ type HandleExecuteScriptResponse = (FreestyleExecureScriptResultSuccess);
163
+ type HandleExecuteScriptError = (FreestyleExecureScriptResultError);
164
+ type HandleDeployWebData = {
165
+ body: FreestyleDeployWebPayload;
166
+ };
167
+ type HandleDeployWebResponse = (FreestyleDeployWebSuccessResponse);
168
+ type HandleDeployWebError = (FreestyleDeployWebErrorResponse);
169
+ type HandleGetLogsResponse = (Array<FreestyleLogResponseObject>);
170
+ type HandleGetLogsError = unknown;
171
+
172
+ export type { HandleCreateDomainVerificationResponse as A, HandleCreateDomainVerificationError as B, HandleExecuteScriptData as C, HandleExecuteScriptResponse as D, HandleExecuteScriptError as E, FreestyleExecuteScriptParamsConfiguration as F, HandleDeployWebData as G, HandleBackupCloudstateResponse as H, HandleDeployWebResponse as I, HandleDeployWebError as J, HandleGetLogsError as K, FreestyleExecureScriptResultSuccess as a, FreestyleDeployWebConfiguration as b, FreestyleDeployWebSuccessResponse as c, FreestyleCloudstateDeployRequest as d, FreestyleCloudstateDeploySuccessResponse as e, HandleGetLogsResponse as f, HandleVerifyDomainResponse as g, HandleListDomainsResponse as h, FreestyleCloudstateDeployConfiguration as i, FreestyleCloudstateDeployErrorResponse as j, FreestyleDeployWebErrorResponse as k, FreestyleDeployWebPayload as l, FreestyleDomainVerificationRequest as m, FreestyleExecureScriptResultError as n, FreestyleExecuteScriptParams as o, FreestyleFile as p, FreestyleLogResponseObject as q, FreestyleVerifyDomainRequest as r, HandleDeployCloudstateData as s, HandleDeployCloudstateResponse as t, HandleDeployCloudstateError as u, HandleBackupCloudstateError as v, HandleListDomainsError as w, HandleVerifyDomainData as x, HandleVerifyDomainError as y, HandleCreateDomainVerificationData as z };
@@ -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, HandleBackupCloudstateError, HandleBackupCloudstateResponse, HandleVerifyDomainData, HandleVerifyDomainError, HandleVerifyDomainResponse, HandleCreateDomainVerificationData, HandleExecuteScriptData, HandleExecuteScriptError, HandleExecuteScriptResponse, HandleDeployWebData, HandleDeployWebError, HandleDeployWebResponse, HandleGetLogsError, HandleGetLogsResponse } from './types.gen';
4
+ import type { HandleDeployCloudstateData, HandleDeployCloudstateError, HandleDeployCloudstateResponse, HandleBackupCloudstateError, HandleBackupCloudstateResponse, HandleListDomainsError, HandleListDomainsResponse, HandleVerifyDomainData, HandleVerifyDomainError, HandleVerifyDomainResponse, HandleCreateDomainVerificationData, HandleCreateDomainVerificationError, HandleCreateDomainVerificationResponse, HandleExecuteScriptData, HandleExecuteScriptError, HandleExecuteScriptResponse, HandleDeployWebData, HandleDeployWebError, HandleDeployWebResponse, HandleGetLogsError, HandleGetLogsResponse } from './types.gen';
5
5
 
6
6
  export const client = createClient(createConfig());
7
7
 
@@ -27,6 +27,19 @@ export const handleBackupCloudstate = <ThrowOnError extends boolean = false>(opt
27
27
  });
28
28
  };
29
29
 
30
+ /**
31
+ * List domains for an account
32
+ */
33
+ export const handleListDomains = <ThrowOnError extends boolean = false>(options?: OptionsLegacyParser<unknown, ThrowOnError>) => {
34
+ return (options?.client ?? client).get<HandleListDomainsResponse, HandleListDomainsError, ThrowOnError>({
35
+ ...options,
36
+ url: '/domains/v1/domains'
37
+ });
38
+ };
39
+
40
+ /**
41
+ * Verify a domain
42
+ */
30
43
  export const handleVerifyDomain = <ThrowOnError extends boolean = false>(options: OptionsLegacyParser<HandleVerifyDomainData, ThrowOnError>) => {
31
44
  return (options?.client ?? client).put<HandleVerifyDomainResponse, HandleVerifyDomainError, ThrowOnError>({
32
45
  ...options,
@@ -38,7 +51,7 @@ export const handleVerifyDomain = <ThrowOnError extends boolean = false>(options
38
51
  * Create a domain verification request
39
52
  */
40
53
  export const handleCreateDomainVerification = <ThrowOnError extends boolean = false>(options: OptionsLegacyParser<HandleCreateDomainVerificationData, ThrowOnError>) => {
41
- return (options?.client ?? client).post<void, unknown, ThrowOnError>({
54
+ return (options?.client ?? client).post<HandleCreateDomainVerificationResponse, HandleCreateDomainVerificationError, ThrowOnError>({
42
55
  ...options,
43
56
  url: '/domains/v1/verifications'
44
57
  });
@@ -78,6 +78,9 @@ export type FreestyleDeployWebSuccessResponse = {
78
78
  };
79
79
 
80
80
  export type FreestyleDomainVerificationRequest = {
81
+ /**
82
+ * The domain to create a verification code for
83
+ */
81
84
  domain: string;
82
85
  };
83
86
 
@@ -151,6 +154,14 @@ export type HandleBackupCloudstateResponse = (Array<(number)>);
151
154
 
152
155
  export type HandleBackupCloudstateError = (unknown);
153
156
 
157
+ export type HandleListDomainsResponse = ({
158
+ domains: Array<(string)>;
159
+ });
160
+
161
+ export type HandleListDomainsError = ({
162
+ message: string;
163
+ });
164
+
154
165
  export type HandleVerifyDomainData = {
155
166
  body: FreestyleVerifyDomainRequest;
156
167
  };
@@ -167,6 +178,15 @@ export type HandleCreateDomainVerificationData = {
167
178
  body: FreestyleDomainVerificationRequest;
168
179
  };
169
180
 
181
+ export type HandleCreateDomainVerificationResponse = ({
182
+ verification_code: string;
183
+ domain: string;
184
+ });
185
+
186
+ export type HandleCreateDomainVerificationError = ({
187
+ message: string;
188
+ });
189
+
170
190
  export type HandleExecuteScriptData = {
171
191
  body: FreestyleExecuteScriptParams;
172
192
  };
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.\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"}}}},"/domains/v1/verifications":{"put":{"tags":["Domains"],"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"}}}}}},"400":{"description":"Failed to verify domain","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}}},"post":{"tags":["Domains"],"summary":"Create a domain verification request","operationId":"handle_create_domain_verification","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FreestyleDomainVerificationRequest"}}},"required":true},"responses":{}}},"/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":"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});"}]}},"/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.projectId);\n });\n"},{"label":"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","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"}}},"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\\\": {\\\"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":["projectId"],"properties":{"projectId":{"type":"string"}}},"FreestyleDomainVerificationRequest":{"type":"object","required":["domain"],"properties":{"domain":{"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}}},"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"}}}},"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
+ {"openapi":"3.1.0","info":{"title":"Freestyle Sandboxes","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"}}}},"/domains/v1/domains":{"get":{"tags":["Domains"],"summary":"List domains for an account","operationId":"handle_list_domains","responses":{"200":{"description":"List of domains","content":{"application/json":{"schema":{"type":"object","required":["domains"],"properties":{"domains":{"type":"array","items":{"type":"string"}}}}}}},"400":{"description":"Failed to get domains","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}}}}}}}},"/domains/v1/verifications":{"put":{"tags":["Domains"],"summary":"Verify a domain","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"}}}}}}}},"post":{"tags":["Domains"],"summary":"Create a domain verification request","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":["verification_code","domain"],"properties":{"verification_code":{"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":"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});"}]}},"/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.projectId);\n });\n"},{"label":"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","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"}}},"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\\\": {\\\"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":["projectId"],"properties":{"projectId":{"type":"string"}}},"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"],"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}}},"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"}}}},"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."}]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "freestyle-sandboxes",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
package/src/index.ts CHANGED
@@ -146,8 +146,8 @@ export class FreestyleSandboxes {
146
146
  */
147
147
  async createDomainVerificationRequest(
148
148
  domain: string
149
- ): Promise<sandbox_openapi.HandleVerifyDomainResponse> {
150
- const response = await sandbox_openapi.handleVerifyDomain({
149
+ ): Promise<sandbox_openapi.HandleCreateDomainVerificationResponse> {
150
+ const response = await sandbox_openapi.handleCreateDomainVerification({
151
151
  client: this.client,
152
152
  body: {
153
153
  domain: domain,
@@ -184,6 +184,17 @@ export class FreestyleSandboxes {
184
184
  );
185
185
  }
186
186
  }
187
+
188
+ async listDomains(): Promise<sandbox_openapi.HandleListDomainsResponse> {
189
+ const response = await sandbox_openapi.handleListDomains({
190
+ client: this.client,
191
+ });
192
+ if (response.data) {
193
+ return response.data;
194
+ } else {
195
+ throw new Error("Failed to list domains");
196
+ }
197
+ }
187
198
  }
188
199
 
189
200
  export * from "../openapi/types.gen.ts";