freestyle-sandboxes 0.0.80 → 0.0.82

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.
Files changed (39) hide show
  1. package/dist/inde.d.cts +0 -1
  2. package/dist/inde.d.mts +0 -1
  3. package/dist/{index-BBXyg0JQ.cjs → index-CGc0kRd_.cjs} +9 -5
  4. package/dist/{index-DCF70Xbq.mjs → index-jh-93svX.mjs} +9 -5
  5. package/dist/index.cjs +5 -14
  6. package/dist/index.d.cts +0 -1
  7. package/dist/index.d.mts +0 -1
  8. package/dist/index.mjs +5 -14
  9. package/dist/{types.gen-BVXmFV7d.d.ts → types.gen-0bQ5Wn0o.d.ts} +18 -17
  10. package/dist/{types.gen-CIf3ciN7.d.ts → types.gen-BJArgpto.d.ts} +2 -5
  11. package/dist/{types.gen-DLYohMJT.d.ts → types.gen-CfrGF-JI.d.ts} +1 -1
  12. package/dist/{types.gen-CZUnqmzP.d.ts → types.gen-DxZanGNF.d.ts} +9 -6
  13. package/openapi/sdk.gen.ts +57 -2
  14. package/openapi/types.gen.ts +134 -2
  15. package/openapi.json +1 -1
  16. package/package.json +1 -1
  17. package/src/index.ts +184 -40
  18. package/dist/index-BQHqnjZK.mjs +0 -3231
  19. package/dist/index-CEEa9WHp.cjs +0 -3238
  20. package/dist/types.gen-1sd31qLV.d.ts +0 -172
  21. package/dist/types.gen-627pxroW.d.ts +0 -830
  22. package/dist/types.gen-BCdfx7yt.d.ts +0 -760
  23. package/dist/types.gen-BaMKzqxQ.d.ts +0 -233
  24. package/dist/types.gen-BbekD8Sd.d.ts +0 -1119
  25. package/dist/types.gen-BqN1t03N.d.ts +0 -842
  26. package/dist/types.gen-BtK6PMQy.d.ts +0 -195
  27. package/dist/types.gen-C03gaIPq.d.ts +0 -297
  28. package/dist/types.gen-CMuCas4r.d.ts +0 -183
  29. package/dist/types.gen-CnEkmbco.d.ts +0 -314
  30. package/dist/types.gen-DDYpuDzZ.d.ts +0 -764
  31. package/dist/types.gen-DHmdEOOa.d.ts +0 -172
  32. package/dist/types.gen-DbTb_SrD.d.ts +0 -156
  33. package/dist/types.gen-DkQ-Dbs1.d.ts +0 -764
  34. package/dist/types.gen-DyY7Deri.d.ts +0 -138
  35. package/dist/types.gen-MBZCvIhE.d.ts +0 -311
  36. package/dist/types.gen-YhJAHBw8.d.ts +0 -233
  37. package/dist/types.gen-cCnnhnB6.d.ts +0 -182
  38. package/dist/types.gen-mg_JNXrq.d.ts +0 -830
  39. package/dist/types.gen-uDTr6v-7.d.ts +0 -731
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "freestyle-sandboxes",
3
- "version": "0.0.80",
3
+ "version": "0.0.82",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
package/src/index.ts CHANGED
@@ -152,7 +152,7 @@ export class FreestyleSandboxes {
152
152
  */
153
153
  async executeScript(
154
154
  script: string,
155
- config?: FreestyleExecuteScriptParamsConfiguration
155
+ config?: FreestyleExecuteScriptParamsConfiguration,
156
156
  ): Promise<FreestyleExecuteScriptResultSuccess> {
157
157
  const response = await sandbox_openapi.handleExecuteScript({
158
158
  client: this.client,
@@ -167,7 +167,7 @@ export class FreestyleSandboxes {
167
167
  }
168
168
  throw {
169
169
  message: `Failed to execute script: \n\n${script}\n\nError:\n\n${JSON.stringify(
170
- response
170
+ response,
171
171
  )}`,
172
172
  error: response.error,
173
173
  };
@@ -181,7 +181,7 @@ export class FreestyleSandboxes {
181
181
  */
182
182
  async deployWeb(
183
183
  source: sandbox_openapi.DeploymentSource,
184
- config?: FreestyleDeployWebConfiguration
184
+ config?: FreestyleDeployWebConfiguration,
185
185
  ): Promise<FreestyleDeployWebSuccessResponseV2> {
186
186
  const response = await sandbox_openapi.handleDeployWebV2({
187
187
  client: this.client,
@@ -194,7 +194,7 @@ export class FreestyleSandboxes {
194
194
  return response.data;
195
195
  }
196
196
  throw new Error(
197
- `Failed to deploy web project\n\nStatus: ${response.response.status}\n\nMessage: ${response.error?.message}`
197
+ `Failed to deploy web project\n\nStatus: ${response.response.status}\n\nMessage: ${response.error?.message}`,
198
198
  );
199
199
  }
200
200
 
@@ -202,7 +202,7 @@ export class FreestyleSandboxes {
202
202
  * Deploy a Cloudstate project to a sandbox.
203
203
  */
204
204
  async deployCloudstate(
205
- body: FreestyleCloudstateDeployRequest
205
+ body: FreestyleCloudstateDeployRequest,
206
206
  ): Promise<FreestyleCloudstateDeploySuccessResponse> {
207
207
  const response = await sandbox_openapi.handleDeployCloudstate({
208
208
  client: this.client,
@@ -265,7 +265,7 @@ export class FreestyleSandboxes {
265
265
  * @returns The domain verification token.
266
266
  */
267
267
  async createDomainVerificationRequest(
268
- domain: string
268
+ domain: string,
269
269
  ): Promise<HandleCreateDomainVerificationResponse> {
270
270
  const response = await sandbox_openapi.handleCreateDomainVerification({
271
271
  client: this.client,
@@ -281,7 +281,7 @@ export class FreestyleSandboxes {
281
281
  }
282
282
 
283
283
  async verifyDomainVerificationRequest(
284
- id: string
284
+ id: string,
285
285
  ): Promise<HandleVerifyDomainResponse> {
286
286
  const response = await sandbox_openapi.handleVerifyDomain({
287
287
  client: this.client,
@@ -294,7 +294,7 @@ export class FreestyleSandboxes {
294
294
  return response.data;
295
295
  }
296
296
  throw new Error(
297
- `Failed to verify domain verification request with ID ${id}: ${response.error.message}`
297
+ `Failed to verify domain verification request with ID ${id}: ${response.error.message}`,
298
298
  );
299
299
  }
300
300
 
@@ -304,7 +304,7 @@ export class FreestyleSandboxes {
304
304
  * @returns The domain verification request.
305
305
  */
306
306
  async verifyDomain(
307
- domain: string
307
+ domain: string,
308
308
  ): Promise<HandleVerifyDomainResponse | HandleVerifyDomainError> {
309
309
  const response = await sandbox_openapi.handleVerifyDomain({
310
310
  client: this.client,
@@ -316,7 +316,7 @@ export class FreestyleSandboxes {
316
316
  return response.data;
317
317
  }
318
318
  throw new Error(
319
- `Failed to verify domain ${domain}: ${response.error.message}`
319
+ `Failed to verify domain ${domain}: ${response.error.message}`,
320
320
  );
321
321
  }
322
322
 
@@ -335,20 +335,20 @@ export class FreestyleSandboxes {
335
335
  const response = await sandbox_openapi.handleListDomainVerificationRequests(
336
336
  {
337
337
  client: this.client,
338
- }
338
+ },
339
339
  );
340
340
  if (response.data) {
341
341
  return response.data;
342
342
  }
343
343
 
344
344
  throw new Error(
345
- `Failed to list domain verification requests\n${response.error.message}`
345
+ `Failed to list domain verification requests\n${response.error.message}`,
346
346
  );
347
347
  }
348
348
 
349
349
  async deleteDomainVerificationRequest(
350
350
  domain: string,
351
- verificationCode: string
351
+ verificationCode: string,
352
352
  ): Promise<HandleDeleteDomainVerificationResponse> {
353
353
  const response = await sandbox_openapi.handleDeleteDomainVerification({
354
354
  client: this.client,
@@ -362,13 +362,13 @@ export class FreestyleSandboxes {
362
362
  }
363
363
 
364
364
  throw new Error(
365
- `Failed to delete domain verification request for domain ${domain}: ${response.error.message}`
365
+ `Failed to delete domain verification request for domain ${domain}: ${response.error.message}`,
366
366
  );
367
367
  }
368
368
 
369
369
  async listWebDeployments(
370
370
  limit?: number,
371
- offset?: number
371
+ offset?: number,
372
372
  ): Promise<HandleListWebDeploysResponse> {
373
373
  const response = await sandbox_openapi.handleListWebDeploys({
374
374
  client: this.client,
@@ -383,13 +383,13 @@ export class FreestyleSandboxes {
383
383
  }
384
384
 
385
385
  throw new Error(
386
- `Failed to list web deployments\n${response.error.message}`
386
+ `Failed to list web deployments\n${response.error.message}`,
387
387
  );
388
388
  }
389
389
 
390
390
  async listExecuteRuns(
391
391
  limit?: number,
392
- offset?: number
392
+ offset?: number,
393
393
  ): Promise<HandleListExecuteRunsResponse> {
394
394
  const response = await sandbox_openapi.handleListExecuteRuns({
395
395
  client: this.client,
@@ -417,7 +417,7 @@ export class FreestyleSandboxes {
417
417
  }
418
418
 
419
419
  throw new Error(
420
- `Failed to get execute run with ID ${id}: ${response.error.message}`
420
+ `Failed to get execute run with ID ${id}: ${response.error.message}`,
421
421
  );
422
422
  }
423
423
 
@@ -435,7 +435,7 @@ export class FreestyleSandboxes {
435
435
  }
436
436
 
437
437
  throw new Error(
438
- `Failed to provision wildcard for domain ${domain}: ${response.error.message}`
438
+ `Failed to provision wildcard for domain ${domain}: ${response.error.message}`,
439
439
  );
440
440
  }
441
441
 
@@ -450,6 +450,7 @@ export class FreestyleSandboxes {
450
450
  }: {
451
451
  name?: string;
452
452
  public?: boolean;
453
+ defaultBranch?: string;
453
454
  } & (
454
455
  | CreateGitRepositorySource
455
456
  | CreateGitRepositoryImport
@@ -469,7 +470,7 @@ export class FreestyleSandboxes {
469
470
  }
470
471
 
471
472
  throw new Error(
472
- `Failed to create git repository ${name}: ${response.error}`
473
+ `Failed to create git repository ${name}: ${response.error}`,
473
474
  );
474
475
  }
475
476
 
@@ -518,7 +519,7 @@ export class FreestyleSandboxes {
518
519
  }
519
520
 
520
521
  throw new Error(
521
- `Failed to delete git repository ${repoId}: ${response.error}`
522
+ `Failed to delete git repository ${repoId}: ${response.error}`,
522
523
  );
523
524
  }
524
525
 
@@ -587,7 +588,7 @@ export class FreestyleSandboxes {
587
588
  }
588
589
 
589
590
  throw new Error(
590
- `Failed to grant access to git identity ${identityId} for repository ${repoId}: ${response.error}`
591
+ `Failed to grant access to git identity ${identityId} for repository ${repoId}: ${response.error}`,
591
592
  );
592
593
  }
593
594
 
@@ -619,7 +620,7 @@ export class FreestyleSandboxes {
619
620
  }
620
621
 
621
622
  throw new Error(
622
- `Failed to update permission for git identity ${identityId} for repository ${repoId}: ${response.error}`
623
+ `Failed to update permission for git identity ${identityId} for repository ${repoId}: ${response.error}`,
623
624
  );
624
625
  }
625
626
 
@@ -646,7 +647,7 @@ export class FreestyleSandboxes {
646
647
  }
647
648
 
648
649
  throw new Error(
649
- `Failed to revoke access to git identity ${identityId} for repository ${repoId}: ${response.error}`
650
+ `Failed to revoke access to git identity ${identityId} for repository ${repoId}: ${response.error}`,
650
651
  );
651
652
  }
652
653
 
@@ -670,7 +671,7 @@ export class FreestyleSandboxes {
670
671
  }
671
672
 
672
673
  throw new Error(
673
- `Failed to list permissions for git identity ${identityId}: ${response.error}`
674
+ `Failed to list permissions for git identity ${identityId}: ${response.error}`,
674
675
  );
675
676
  }
676
677
 
@@ -697,7 +698,7 @@ export class FreestyleSandboxes {
697
698
  }
698
699
 
699
700
  throw new Error(
700
- `Failed to get permission for git identity ${identityId} on repository ${repoId}: ${response.error}`
701
+ `Failed to get permission for git identity ${identityId} on repository ${repoId}: ${response.error}`,
701
702
  );
702
703
  }
703
704
 
@@ -721,7 +722,7 @@ export class FreestyleSandboxes {
721
722
  }
722
723
 
723
724
  throw new Error(
724
- `Failed to create git access token: ${response.error.message}`
725
+ `Failed to create git access token: ${response.error.message}`,
725
726
  );
726
727
  }
727
728
 
@@ -750,7 +751,7 @@ export class FreestyleSandboxes {
750
751
  }
751
752
 
752
753
  throw new Error(
753
- `Failed to revoke git access token ${tokenId}: ${response.error.message}`
754
+ `Failed to revoke git access token ${tokenId}: ${response.error.message}`,
754
755
  );
755
756
  }
756
757
 
@@ -774,7 +775,7 @@ export class FreestyleSandboxes {
774
775
  }
775
776
 
776
777
  throw new Error(
777
- `Failed to list git access tokens: ${response.error.message}`
778
+ `Failed to list git access tokens: ${response.error.message}`,
778
779
  );
779
780
  }
780
781
 
@@ -798,7 +799,7 @@ export class FreestyleSandboxes {
798
799
  }
799
800
 
800
801
  throw new Error(
801
- `Failed to list git triggers for repository ${repoId}: ${response.error.message}`
802
+ `Failed to list git triggers for repository ${repoId}: ${response.error.message}`,
802
803
  );
803
804
  }
804
805
 
@@ -830,7 +831,7 @@ export class FreestyleSandboxes {
830
831
  }
831
832
 
832
833
  throw new Error(
833
- `Failed to create git trigger for repository ${repoId}: ${response.error.message}`
834
+ `Failed to create git trigger for repository ${repoId}: ${response.error.message}`,
834
835
  );
835
836
  }
836
837
 
@@ -850,10 +851,153 @@ export class FreestyleSandboxes {
850
851
  }
851
852
 
852
853
  throw new Error(
853
- `Failed to delete git trigger ${triggerId}: ${response.error.message}`
854
+ `Failed to delete git trigger ${triggerId}: ${response.error.message}`,
854
855
  );
855
856
  }
856
857
 
858
+ /**
859
+ * Set the default branch for a git repository.
860
+ */
861
+ async setGitRepoDefaultBranch({
862
+ repoId,
863
+ defaultBranch,
864
+ }: sandbox_openapi.SetDefaultBranchRequest & {
865
+ repoId: string;
866
+ }): Promise<void> {
867
+ const response = await sandbox_openapi.handleSetDefaultBranch({
868
+ client: this.client,
869
+ path: {
870
+ repo_id: repoId,
871
+ },
872
+ body: {
873
+ defaultBranch,
874
+ },
875
+ });
876
+
877
+ if (response.error) {
878
+ throw new Error(`Failed to set default branch: ${response.error}`);
879
+ }
880
+ }
881
+
882
+ /**
883
+ * Get the default branch for a git repository.
884
+ */
885
+ async getGitRepoDefaultBranch({
886
+ repoId,
887
+ }: {
888
+ repoId: string;
889
+ }): Promise<string> {
890
+ const response = await sandbox_openapi.handleGetDefaultBranch({
891
+ client: this.client,
892
+ path: { repo_id: repoId },
893
+ });
894
+
895
+ if (response.data) {
896
+ return response.data.defaultBranch;
897
+ }
898
+
899
+ throw new Error(
900
+ `Failed to get default branch for repository ${repoId}: ${response.error}`,
901
+ );
902
+ }
903
+
904
+ /**
905
+ * Get the contents of a git repository at the given path.
906
+ */
907
+ async getGitRepoContents({
908
+ repoId,
909
+ path,
910
+ ref,
911
+ }: {
912
+ repoId: string;
913
+ path?: string;
914
+ ref?: string;
915
+ }): Promise<sandbox_openapi.HandleGetContentsResponse> {
916
+ const response = await sandbox_openapi.handleGetContents({
917
+ client: this.client,
918
+ path: {
919
+ repo: repoId,
920
+ "*path": path ?? null,
921
+ },
922
+ query: {
923
+ ref: ref,
924
+ },
925
+ });
926
+
927
+ if (response.data) {
928
+ return response.data;
929
+ }
930
+
931
+ throw new Error(
932
+ `Failed to get git repository contents: ${response.error.message}`,
933
+ );
934
+ }
935
+
936
+ /**
937
+ * Configure a git repository to sync with GitHub.
938
+ */
939
+ async configureGitRepoGitHubSync({
940
+ repoId,
941
+ githubRepoName,
942
+ }: {
943
+ repoId: string;
944
+ githubRepoName: string;
945
+ }): Promise<void> {
946
+ const response = await sandbox_openapi.configureGithubSync({
947
+ client: this.client,
948
+ path: {
949
+ repo_id: repoId,
950
+ },
951
+ body: {
952
+ githubRepoName,
953
+ },
954
+ });
955
+
956
+ if (response.error) {
957
+ throw new Error(`Failed to configure GitHub sync: ${response.error}`);
958
+ }
959
+ }
960
+
961
+ /**
962
+ * Remove the GitHub sync configuration for a git repository.
963
+ */
964
+ async removeGitRepoGitHubSync({ repoId }: { repoId: string }): Promise<void> {
965
+ const response = await sandbox_openapi.removeGithubSync({
966
+ client: this.client,
967
+ path: {
968
+ repo_id: repoId,
969
+ },
970
+ });
971
+
972
+ if (response.error) {
973
+ throw new Error(`Failed to remove GitHub sync: ${response.error}`);
974
+ }
975
+ }
976
+
977
+ /**
978
+ * Get the GitHub sync configuration for a git repository.
979
+ */
980
+ async getGitRepoGitHubSyncConfig({
981
+ repoId,
982
+ }): Promise<sandbox_openapi.GetGithubSyncResponse | null> {
983
+ const response = await sandbox_openapi.getGithubSync({
984
+ client: this.client,
985
+ path: {
986
+ repo_id: repoId,
987
+ },
988
+ });
989
+
990
+ if (response.response.status === 404) {
991
+ return null;
992
+ }
993
+
994
+ if (response.error) {
995
+ throw new Error(`Failed to get GitHub sync config: ${response.error}`);
996
+ }
997
+
998
+ return response.data ?? null;
999
+ }
1000
+
857
1001
  /**
858
1002
  * Request a dev server for a repository. If a dev server is already running
859
1003
  * for that repository, it will return a url to that server. Dev servers are
@@ -897,7 +1041,7 @@ export class FreestyleSandboxes {
897
1041
  if (response.error) {
898
1042
  throw new Error(
899
1043
  // @ts-ignore
900
- `Failed to request dev server: ${response.error.message}`
1044
+ `Failed to request dev server: ${response.error.message}`,
901
1045
  );
902
1046
  }
903
1047
 
@@ -909,7 +1053,7 @@ export class FreestyleSandboxes {
909
1053
  action: {
910
1054
  endpoint: formatHook(
911
1055
  response.data?.url!,
912
- options.repoUrl || `https://git.freestyle.sh/${rId}`
1056
+ options.repoUrl || `https://git.freestyle.sh/${rId}`,
913
1057
  ),
914
1058
  action: "webhook",
915
1059
  },
@@ -1041,12 +1185,12 @@ export class FreestyleSandboxes {
1041
1185
  kind: devServerInstance.kind,
1042
1186
  },
1043
1187
  }),
1044
- }
1188
+ },
1045
1189
  );
1046
1190
 
1047
1191
  if (!response.ok) {
1048
1192
  throw new Error(
1049
- `Failed to fetch stream: ${response.status} ${response.statusText}`
1193
+ `Failed to fetch stream: ${response.status} ${response.statusText}`,
1050
1194
  );
1051
1195
  }
1052
1196
 
@@ -1116,7 +1260,7 @@ export class FreestyleSandboxes {
1116
1260
  async writeFile(
1117
1261
  path: string,
1118
1262
  content: string | ArrayBuffer,
1119
- encoding: BufferEncoding = "utf-8"
1263
+ encoding: BufferEncoding = "utf-8",
1120
1264
  ) {
1121
1265
  const contentStr =
1122
1266
  typeof content === "string"
@@ -1138,7 +1282,7 @@ export class FreestyleSandboxes {
1138
1282
 
1139
1283
  if (response.error) {
1140
1284
  throw new Error(
1141
- `Failed to write file: ${JSON.stringify(response.error)}`
1285
+ `Failed to write file: ${JSON.stringify(response.error)}`,
1142
1286
  );
1143
1287
  }
1144
1288
  },
@@ -1154,7 +1298,7 @@ export class FreestyleSandboxes {
1154
1298
  command: cmd,
1155
1299
  background,
1156
1300
  },
1157
- }
1301
+ },
1158
1302
  );
1159
1303
 
1160
1304
  if (response.error) {
@@ -1191,7 +1335,7 @@ export class FreestyleSandboxes {
1191
1335
 
1192
1336
  const url = new URL(
1193
1337
  path,
1194
- this.options.baseUrl ?? "https://api.freestyle.sh"
1338
+ this.options.baseUrl ?? "https://api.freestyle.sh",
1195
1339
  );
1196
1340
 
1197
1341
  return fetch(url, {