freestyle-sandboxes 0.0.27 → 0.0.29

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
@@ -43,11 +43,10 @@ const executeTool = (config) => {
43
43
  return res;
44
44
  } catch (e) {
45
45
  console.log("ERROR: ", e.message);
46
- return `Error executing script:
47
-
48
- ${script}
49
-
50
- Error: ${e.message}`;
46
+ return {
47
+ message: e.message,
48
+ error: e.error
49
+ };
51
50
  }
52
51
  }
53
52
  });
@@ -26,10 +26,16 @@ declare const executeTool: (config: FreestyleExecuteScriptParamsConfiguration &
26
26
  script?: string;
27
27
  }, {
28
28
  script?: string;
29
- }>, string | FreestyleExecuteScriptResultSuccess> & {
29
+ }>, FreestyleExecuteScriptResultSuccess | {
30
+ message: any;
31
+ error: any;
32
+ }> & {
30
33
  execute: (args: {
31
34
  script?: string;
32
- }, options: ai.ToolExecutionOptions) => PromiseLike<string | FreestyleExecuteScriptResultSuccess>;
35
+ }, options: ai.ToolExecutionOptions) => PromiseLike<FreestyleExecuteScriptResultSuccess | {
36
+ message: any;
37
+ error: any;
38
+ }>;
33
39
  };
34
40
  /**
35
41
  * Deploy a Web project
@@ -26,10 +26,16 @@ declare const executeTool: (config: FreestyleExecuteScriptParamsConfiguration &
26
26
  script?: string;
27
27
  }, {
28
28
  script?: string;
29
- }>, string | FreestyleExecuteScriptResultSuccess> & {
29
+ }>, FreestyleExecuteScriptResultSuccess | {
30
+ message: any;
31
+ error: any;
32
+ }> & {
30
33
  execute: (args: {
31
34
  script?: string;
32
- }, options: ai.ToolExecutionOptions) => PromiseLike<string | FreestyleExecuteScriptResultSuccess>;
35
+ }, options: ai.ToolExecutionOptions) => PromiseLike<FreestyleExecuteScriptResultSuccess | {
36
+ message: any;
37
+ error: any;
38
+ }>;
33
39
  };
34
40
  /**
35
41
  * Deploy a Web project
package/dist/ai/index.mjs CHANGED
@@ -41,11 +41,10 @@ const executeTool = (config) => {
41
41
  return res;
42
42
  } catch (e) {
43
43
  console.log("ERROR: ", e.message);
44
- return `Error executing script:
45
-
46
- ${script}
47
-
48
- Error: ${e.message}`;
44
+ return {
45
+ message: e.message,
46
+ error: e.error
47
+ };
49
48
  }
50
49
  }
51
50
  });
package/dist/index.cjs CHANGED
@@ -169,6 +169,18 @@ const handleListWebDeploys = (options) => {
169
169
  class FreestyleSandboxes {
170
170
  client;
171
171
  constructor(options) {
172
+ if (typeof Deno !== "undefined") {
173
+ class FreestyleRequest extends Request {
174
+ constructor(input, init) {
175
+ if (init.client !== void 0) {
176
+ console.warn("Unsupported client detected, using default client");
177
+ delete init.client;
178
+ }
179
+ super(input, init);
180
+ }
181
+ }
182
+ Request = FreestyleRequest;
183
+ }
172
184
  this.client = clientFetch.createClient({
173
185
  baseUrl: options.baseUrl ?? "https://api.freestyle.sh",
174
186
  headers: {
@@ -191,8 +203,8 @@ class FreestyleSandboxes {
191
203
  if (response.data) {
192
204
  return response.data;
193
205
  }
194
- throw new Error(
195
- `Failed to execute script:
206
+ throw {
207
+ message: `Failed to execute script:
196
208
 
197
209
  ${script}
198
210
 
@@ -200,8 +212,9 @@ Error:
200
212
 
201
213
  ${JSON.stringify(
202
214
  response
203
- )}`
204
- );
215
+ )}`,
216
+ error: response.error
217
+ };
205
218
  }
206
219
  /**
207
220
  * Deploy a Web project to a sandbox.
package/dist/index.mjs CHANGED
@@ -167,6 +167,18 @@ const handleListWebDeploys = (options) => {
167
167
  class FreestyleSandboxes {
168
168
  client;
169
169
  constructor(options) {
170
+ if (typeof Deno !== "undefined") {
171
+ class FreestyleRequest extends Request {
172
+ constructor(input, init) {
173
+ if (init.client !== void 0) {
174
+ console.warn("Unsupported client detected, using default client");
175
+ delete init.client;
176
+ }
177
+ super(input, init);
178
+ }
179
+ }
180
+ Request = FreestyleRequest;
181
+ }
170
182
  this.client = createClient({
171
183
  baseUrl: options.baseUrl ?? "https://api.freestyle.sh",
172
184
  headers: {
@@ -189,8 +201,8 @@ class FreestyleSandboxes {
189
201
  if (response.data) {
190
202
  return response.data;
191
203
  }
192
- throw new Error(
193
- `Failed to execute script:
204
+ throw {
205
+ message: `Failed to execute script:
194
206
 
195
207
  ${script}
196
208
 
@@ -198,8 +210,9 @@ Error:
198
210
 
199
211
  ${JSON.stringify(
200
212
  response
201
- )}`
202
- );
213
+ )}`,
214
+ error: response.error
215
+ };
203
216
  }
204
217
  /**
205
218
  * Deploy a Web project to a sandbox.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "freestyle-sandboxes",
3
- "version": "0.0.27",
3
+ "version": "0.0.29",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
package/src/ai/index.ts CHANGED
@@ -62,7 +62,10 @@ export const executeTool = (
62
62
  return res;
63
63
  } catch (e) {
64
64
  console.log("ERROR: ", e.message);
65
- return `Error executing script:\n\n${script}\n\nError: ${e.message}`;
65
+ return {
66
+ message: e.message,
67
+ error: e.error,
68
+ };
66
69
  }
67
70
  },
68
71
  });
package/src/index.ts CHANGED
@@ -77,6 +77,20 @@ export class FreestyleSandboxes {
77
77
  */
78
78
  headers?: Record<string, string>;
79
79
  }) {
80
+ //@ts-expect-error Deno has a weird behavior thats patched here
81
+ if (typeof Deno !== "undefined") {
82
+ class FreestyleRequest extends Request {
83
+ constructor(input, init) {
84
+ if (init.client !== undefined) {
85
+ console.warn("Unsupported client detected, using default client");
86
+ delete init.client;
87
+ }
88
+ super(input, init);
89
+ }
90
+ }
91
+
92
+ Request = FreestyleRequest;
93
+ }
80
94
  this.client = createClient({
81
95
  baseUrl: options.baseUrl ?? "https://api.freestyle.sh",
82
96
  headers: {
@@ -91,7 +105,7 @@ export class FreestyleSandboxes {
91
105
  */
92
106
  async executeScript(
93
107
  script: string,
94
- config?: FreestyleExecuteScriptParamsConfiguration,
108
+ config?: FreestyleExecuteScriptParamsConfiguration
95
109
  ): Promise<FreestyleExecuteScriptResultSuccess> {
96
110
  const response = await sandbox_openapi.handleExecuteScript({
97
111
  client: this.client,
@@ -104,11 +118,15 @@ export class FreestyleSandboxes {
104
118
  if (response.data) {
105
119
  return response.data;
106
120
  }
107
- throw new Error(
108
- `Failed to execute script: \n\n${script}\n\nError:\n\n${JSON.stringify(
109
- response,
121
+ throw {
122
+ message: `Failed to execute script: \n\n${script}\n\nError:\n\n${JSON.stringify(
123
+ response
110
124
  )}`,
111
- );
125
+ error: response.error,
126
+ };
127
+ // `Failed to execute script: \n\n${script}\n\nError:\n\n${JSON.stringify(
128
+ // response
129
+ // )}`
112
130
  }
113
131
 
114
132
  /**
@@ -122,7 +140,7 @@ export class FreestyleSandboxes {
122
140
  encoding?: string;
123
141
  }
124
142
  >,
125
- config?: FreestyleDeployWebConfiguration,
143
+ config?: FreestyleDeployWebConfiguration
126
144
  ): Promise<FreestyleDeployWebSuccessResponse> {
127
145
  const response = await sandbox_openapi.handleDeployWeb({
128
146
  client: this.client,
@@ -135,7 +153,7 @@ export class FreestyleSandboxes {
135
153
  return response.data;
136
154
  }
137
155
  throw new Error(
138
- `Failed to deploy web project\n\nStatus: ${response.response.status}\n\nMessage: ${response.error?.message}`,
156
+ `Failed to deploy web project\n\nStatus: ${response.response.status}\n\nMessage: ${response.error?.message}`
139
157
  );
140
158
  }
141
159
 
@@ -143,7 +161,7 @@ export class FreestyleSandboxes {
143
161
  * Deploy a Cloudstate project to a sandbox.
144
162
  */
145
163
  async deployCloudstate(
146
- body: FreestyleCloudstateDeployRequest,
164
+ body: FreestyleCloudstateDeployRequest
147
165
  ): Promise<FreestyleCloudstateDeploySuccessResponse> {
148
166
  const response = await sandbox_openapi.handleDeployCloudstate({
149
167
  client: this.client,
@@ -206,7 +224,7 @@ export class FreestyleSandboxes {
206
224
  * @returns The domain verification token.
207
225
  */
208
226
  async createDomainVerificationRequest(
209
- domain: string,
227
+ domain: string
210
228
  ): Promise<HandleCreateDomainVerificationResponse> {
211
229
  const response = await sandbox_openapi.handleCreateDomainVerification({
212
230
  client: this.client,
@@ -227,7 +245,7 @@ export class FreestyleSandboxes {
227
245
  * @returns The domain verification request.
228
246
  */
229
247
  async verifyDomain(
230
- domain: string,
248
+ domain: string
231
249
  ): Promise<HandleVerifyDomainResponse | HandleVerifyDomainError> {
232
250
  const response = await sandbox_openapi.handleVerifyDomain({
233
251
  client: this.client,
@@ -239,7 +257,7 @@ export class FreestyleSandboxes {
239
257
  return response.data;
240
258
  }
241
259
  throw new Error(
242
- `Failed to verify domain ${domain}: ${response.error.message}`,
260
+ `Failed to verify domain ${domain}: ${response.error.message}`
243
261
  );
244
262
  }
245
263
 
@@ -258,20 +276,20 @@ export class FreestyleSandboxes {
258
276
  const response = await sandbox_openapi.handleListDomainVerificationRequests(
259
277
  {
260
278
  client: this.client,
261
- },
279
+ }
262
280
  );
263
281
  if (response.data) {
264
282
  return response.data;
265
283
  }
266
284
 
267
285
  throw new Error(
268
- `Failed to list domain verification requests\n${response.error.message}`,
286
+ `Failed to list domain verification requests\n${response.error.message}`
269
287
  );
270
288
  }
271
289
 
272
290
  async deleteDomainVerificationRequest(
273
291
  domain: string,
274
- verificationCode: string,
292
+ verificationCode: string
275
293
  ): Promise<HandleDeleteDomainVerificationResponse> {
276
294
  const response = await sandbox_openapi.handleDeleteDomainVerification({
277
295
  client: this.client,
@@ -285,13 +303,13 @@ export class FreestyleSandboxes {
285
303
  }
286
304
 
287
305
  throw new Error(
288
- `Failed to delete domain verification request for domain ${domain}: ${response.error.message}`,
306
+ `Failed to delete domain verification request for domain ${domain}: ${response.error.message}`
289
307
  );
290
308
  }
291
309
 
292
310
  async listWebDeployments(
293
311
  limit?: number,
294
- offset?: number,
312
+ offset?: number
295
313
  ): Promise<HandleListWebDeploysResponse> {
296
314
  const response = await sandbox_openapi.handleListWebDeploys({
297
315
  client: this.client,
@@ -306,13 +324,13 @@ export class FreestyleSandboxes {
306
324
  }
307
325
 
308
326
  throw new Error(
309
- `Failed to list web deployments\n${response.error.message}`,
327
+ `Failed to list web deployments\n${response.error.message}`
310
328
  );
311
329
  }
312
330
 
313
331
  async listExecuteRuns(
314
332
  limit?: number,
315
- offset?: number,
333
+ offset?: number
316
334
  ): Promise<HandleListExecuteRunsResponse> {
317
335
  const response = await sandbox_openapi.handleListExecuteRuns({
318
336
  client: this.client,
@@ -340,7 +358,7 @@ export class FreestyleSandboxes {
340
358
  }
341
359
 
342
360
  throw new Error(
343
- `Failed to get execute run with ID ${id}: ${response.error.message}`,
361
+ `Failed to get execute run with ID ${id}: ${response.error.message}`
344
362
  );
345
363
  }
346
364
 
@@ -358,7 +376,7 @@ export class FreestyleSandboxes {
358
376
  }
359
377
 
360
378
  throw new Error(
361
- `Failed to provision wildcard for domain ${domain}: ${response.error.message}`,
379
+ `Failed to provision wildcard for domain ${domain}: ${response.error.message}`
362
380
  );
363
381
  }
364
382
 
@@ -368,7 +386,7 @@ export class FreestyleSandboxes {
368
386
  * @param name The name of the repository.
369
387
  */
370
388
  async createGitRepository(
371
- name: string,
389
+ name: string
372
390
  ): Promise<CreateRepositoryResponseSuccess> {
373
391
  const response = await sandbox_openapi.handleCreateRepo({
374
392
  client: this.client,
@@ -382,7 +400,7 @@ export class FreestyleSandboxes {
382
400
  }
383
401
 
384
402
  throw new Error(
385
- `Failed to create git repository ${name}: ${response.error}`,
403
+ `Failed to create git repository ${name}: ${response.error}`
386
404
  );
387
405
  }
388
406
 
@@ -394,7 +412,7 @@ export class FreestyleSandboxes {
394
412
  */
395
413
  async listGitRepositories(
396
414
  limit?: number,
397
- offset?: number,
415
+ offset?: number
398
416
  ): Promise<HandleListRepositoriesResponse> {
399
417
  const response = await sandbox_openapi.handleListRepositories({
400
418
  client: this.client,
@@ -417,7 +435,7 @@ export class FreestyleSandboxes {
417
435
  * @param repositoryId The ID of the repository to delete.
418
436
  */
419
437
  async deleteGitRepository(
420
- repositoryId: string,
438
+ repositoryId: string
421
439
  ): Promise<HandleDeleteRepoResponse> {
422
440
  const response = await sandbox_openapi.handleDeleteRepo({
423
441
  client: this.client,
@@ -431,7 +449,7 @@ export class FreestyleSandboxes {
431
449
  }
432
450
 
433
451
  throw new Error(
434
- `Failed to delete git repository ${repositoryId}: ${response.error}`,
452
+ `Failed to delete git repository ${repositoryId}: ${response.error}`
435
453
  );
436
454
  }
437
455
 
@@ -456,7 +474,7 @@ export class FreestyleSandboxes {
456
474
  * @param identityId The ID of the identity to delete.
457
475
  */
458
476
  async deleteGitIdentity(
459
- identityId: string,
477
+ identityId: string
460
478
  ): Promise<HandleDeleteIdentityResponse> {
461
479
  const response = await sandbox_openapi.handleDeleteIdentity({
462
480
  client: this.client,
@@ -482,7 +500,7 @@ export class FreestyleSandboxes {
482
500
  async grantGitPermission(
483
501
  repoId: string,
484
502
  identityId: string,
485
- permission: AccessLevel,
503
+ permission: AccessLevel
486
504
  ) {
487
505
  const response = await sandbox_openapi.handleGrantPermission({
488
506
  client: this.client,
@@ -500,7 +518,7 @@ export class FreestyleSandboxes {
500
518
  }
501
519
 
502
520
  throw new Error(
503
- `Failed to grant access to git identity ${identityId} for repository ${repoId}: ${response.error}`,
521
+ `Failed to grant access to git identity ${identityId} for repository ${repoId}: ${response.error}`
504
522
  );
505
523
  }
506
524
 
@@ -514,7 +532,7 @@ export class FreestyleSandboxes {
514
532
  async updateGitPermission(
515
533
  repoId: string,
516
534
  identityId: string,
517
- permission: AccessLevel,
535
+ permission: AccessLevel
518
536
  ): Promise<void> {
519
537
  const response = await sandbox_openapi.handleUpdatePermission({
520
538
  client: this.client,
@@ -532,7 +550,7 @@ export class FreestyleSandboxes {
532
550
  }
533
551
 
534
552
  throw new Error(
535
- `Failed to update permission for git identity ${identityId} for repository ${repoId}: ${response.error}`,
553
+ `Failed to update permission for git identity ${identityId} for repository ${repoId}: ${response.error}`
536
554
  );
537
555
  }
538
556
 
@@ -556,7 +574,7 @@ export class FreestyleSandboxes {
556
574
  }
557
575
 
558
576
  throw new Error(
559
- `Failed to revoke access to git identity ${identityId} for repository ${repoId}: ${response.error}`,
577
+ `Failed to revoke access to git identity ${identityId} for repository ${repoId}: ${response.error}`
560
578
  );
561
579
  }
562
580
 
@@ -566,7 +584,7 @@ export class FreestyleSandboxes {
566
584
  * @param identityId The ID of the identity to list permissions for.
567
585
  */
568
586
  async listGitPermissions(
569
- identityId: string,
587
+ identityId: string
570
588
  ): Promise<ListPermissionResponseSuccess> {
571
589
  const response = await sandbox_openapi.handleListPermissions({
572
590
  client: this.client,
@@ -580,7 +598,7 @@ export class FreestyleSandboxes {
580
598
  }
581
599
 
582
600
  throw new Error(
583
- `Failed to list permissions for git identity ${identityId}: ${response.error}`,
601
+ `Failed to list permissions for git identity ${identityId}: ${response.error}`
584
602
  );
585
603
  }
586
604
 
@@ -592,7 +610,7 @@ export class FreestyleSandboxes {
592
610
  */
593
611
  async getGitPermission(
594
612
  repoId: string,
595
- identityId: string,
613
+ identityId: string
596
614
  ): Promise<DescribePermissionResponseSuccess> {
597
615
  const response = await sandbox_openapi.handleDescribePermission({
598
616
  client: this.client,
@@ -607,7 +625,7 @@ export class FreestyleSandboxes {
607
625
  }
608
626
 
609
627
  throw new Error(
610
- `Failed to get permission for git identity ${identityId} on repository ${repoId}: ${response.error}`,
628
+ `Failed to get permission for git identity ${identityId} on repository ${repoId}: ${response.error}`
611
629
  );
612
630
  }
613
631
 
@@ -629,7 +647,7 @@ export class FreestyleSandboxes {
629
647
  }
630
648
 
631
649
  throw new Error(
632
- `Failed to create git access token: ${response.error.message}`,
650
+ `Failed to create git access token: ${response.error.message}`
633
651
  );
634
652
  }
635
653
 
@@ -641,7 +659,7 @@ export class FreestyleSandboxes {
641
659
  */
642
660
  async revokeGitAccessToken(
643
661
  identityId: string,
644
- tokenId: string,
662
+ tokenId: string
645
663
  ): Promise<void> {
646
664
  const response = await sandbox_openapi.handleRevokeGitToken({
647
665
  client: this.client,
@@ -658,7 +676,7 @@ export class FreestyleSandboxes {
658
676
  }
659
677
 
660
678
  throw new Error(
661
- `Failed to revoke git access token ${tokenId}: ${response.error.message}`,
679
+ `Failed to revoke git access token ${tokenId}: ${response.error.message}`
662
680
  );
663
681
  }
664
682
 
@@ -668,7 +686,7 @@ export class FreestyleSandboxes {
668
686
  * @param identityId The ID of the identity to list tokens for.
669
687
  */
670
688
  async listGitAccessTokens(
671
- identityId: string,
689
+ identityId: string
672
690
  ): Promise<ListGitTokensResponseSuccess> {
673
691
  const response = await sandbox_openapi.handleListGitTokens({
674
692
  client: this.client,
@@ -682,7 +700,7 @@ export class FreestyleSandboxes {
682
700
  }
683
701
 
684
702
  throw new Error(
685
- `Failed to list git access tokens: ${response.error.message}`,
703
+ `Failed to list git access tokens: ${response.error.message}`
686
704
  );
687
705
  }
688
706
  }