freestyle-sandboxes 0.0.79 → 0.0.81

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 +1 -15
  6. package/dist/index.d.cts +0 -1
  7. package/dist/index.d.mts +0 -1
  8. package/dist/index.mjs +1 -15
  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 +133 -2
  15. package/openapi.json +1 -1
  16. package/package.json +1 -1
  17. package/src/index.ts +143 -5
  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.79",
3
+ "version": "0.0.81",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
package/src/index.ts CHANGED
@@ -123,11 +123,6 @@ export class FreestyleSandboxes {
123
123
  if (!options?.apiKey) {
124
124
  this.options.apiKey = process.env.FREESTYLE_API_KEY;
125
125
  }
126
- if (this.options.apiKey === undefined) {
127
- throw new Error(
128
- "No API key provided. Please set the FREESTYLE_API_KEY environment variable or configure apiKey when constructing FreestyleSandboxes."
129
- );
130
- }
131
126
 
132
127
  //@ts-expect-error Deno has a weird behavior thats patched here
133
128
  if (typeof Deno !== "undefined") {
@@ -859,6 +854,149 @@ export class FreestyleSandboxes {
859
854
  );
860
855
  }
861
856
 
857
+ /**
858
+ * Set the default branch for a git repository.
859
+ */
860
+ async setGitRepoDefaultBranch({
861
+ repoId,
862
+ defaultBranch,
863
+ }: sandbox_openapi.SetDefaultBranchRequest & {
864
+ repoId: string;
865
+ }): Promise<void> {
866
+ const response = await sandbox_openapi.handleSetDefaultBranch({
867
+ client: this.client,
868
+ path: {
869
+ repo_id: repoId,
870
+ },
871
+ body: {
872
+ defaultBranch,
873
+ },
874
+ });
875
+
876
+ if (response.error) {
877
+ throw new Error(`Failed to set default branch: ${response.error}`);
878
+ }
879
+ }
880
+
881
+ /**
882
+ * Get the default branch for a git repository.
883
+ */
884
+ async getGitRepoDefaultBranch({
885
+ repoId,
886
+ }: {
887
+ repoId: string;
888
+ }): Promise<string> {
889
+ const response = await sandbox_openapi.handleGetDefaultBranch({
890
+ client: this.client,
891
+ path: { repo_id: repoId },
892
+ });
893
+
894
+ if (response.data) {
895
+ return response.data.defaultBranch;
896
+ }
897
+
898
+ throw new Error(
899
+ `Failed to get default branch for repository ${repoId}: ${response.error}`,
900
+ );
901
+ }
902
+
903
+ /**
904
+ * Get the contents of a git repository at the given path.
905
+ */
906
+ async getGitRepoContents({
907
+ repoId,
908
+ path,
909
+ ref,
910
+ }: {
911
+ repoId: string;
912
+ path?: string;
913
+ ref?: string;
914
+ }): Promise<sandbox_openapi.HandleGetContentsResponse> {
915
+ const response = await sandbox_openapi.handleGetContents({
916
+ client: this.client,
917
+ path: {
918
+ repo: repoId,
919
+ "*path": path ?? null,
920
+ },
921
+ query: {
922
+ ref: ref,
923
+ },
924
+ });
925
+
926
+ if (response.data) {
927
+ return response.data;
928
+ }
929
+
930
+ throw new Error(
931
+ `Failed to get git repository contents: ${response.error.message}`,
932
+ );
933
+ }
934
+
935
+ /**
936
+ * Configure a git repository to sync with GitHub.
937
+ */
938
+ async configureGitRepoGitHubSync({
939
+ repoId,
940
+ githubRepoName,
941
+ }: {
942
+ repoId: string;
943
+ githubRepoName: string;
944
+ }): Promise<void> {
945
+ const response = await sandbox_openapi.configureGithubSync({
946
+ client: this.client,
947
+ path: {
948
+ repo_id: repoId,
949
+ },
950
+ body: {
951
+ githubRepoName,
952
+ },
953
+ });
954
+
955
+ if (response.error) {
956
+ throw new Error(`Failed to configure GitHub sync: ${response.error}`);
957
+ }
958
+ }
959
+
960
+ /**
961
+ * Remove the GitHub sync configuration for a git repository.
962
+ */
963
+ async removeGitRepoGitHubSync({ repoId }: { repoId: string }): Promise<void> {
964
+ const response = await sandbox_openapi.removeGithubSync({
965
+ client: this.client,
966
+ path: {
967
+ repo_id: repoId,
968
+ },
969
+ });
970
+
971
+ if (response.error) {
972
+ throw new Error(`Failed to remove GitHub sync: ${response.error}`);
973
+ }
974
+ }
975
+
976
+ /**
977
+ * Get the GitHub sync configuration for a git repository.
978
+ */
979
+ async getGitRepoGitHubSyncConfig({
980
+ repoId,
981
+ }): Promise<sandbox_openapi.GetGithubSyncResponse | null> {
982
+ const response = await sandbox_openapi.getGithubSync({
983
+ client: this.client,
984
+ path: {
985
+ repo_id: repoId,
986
+ },
987
+ });
988
+
989
+ if (response.response.status === 404) {
990
+ return null;
991
+ }
992
+
993
+ if (response.error) {
994
+ throw new Error(`Failed to get GitHub sync config: ${response.error}`);
995
+ }
996
+
997
+ return response.data ?? null;
998
+ }
999
+
862
1000
  /**
863
1001
  * Request a dev server for a repository. If a dev server is already running
864
1002
  * for that repository, it will return a url to that server. Dev servers are