freestyle-sandboxes 0.0.52 → 0.0.53

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/inde.d.cts CHANGED
@@ -180,12 +180,12 @@ declare class FreestyleSandboxes {
180
180
  * ephemeral so you should call this function every time you need a url. Do
181
181
  * not store the url in your database!
182
182
  */
183
- requestDevServer(repo: {
184
- repoId: string;
185
- } | {
186
- repoUrl: string;
183
+ requestDevServer({ repo, repoUrl, repoId, }: {
184
+ repoUrl?: string;
185
+ repoId?: string;
186
+ repo?: string;
187
187
  }): Promise<{
188
- mcpEphemeralUrl: unknown;
188
+ mcpEphemeralUrl: any;
189
189
  ephemeralUrl: any;
190
190
  url: string;
191
191
  isNew: boolean;
package/dist/inde.d.mts CHANGED
@@ -180,12 +180,12 @@ declare class FreestyleSandboxes {
180
180
  * ephemeral so you should call this function every time you need a url. Do
181
181
  * not store the url in your database!
182
182
  */
183
- requestDevServer(repo: {
184
- repoId: string;
185
- } | {
186
- repoUrl: string;
183
+ requestDevServer({ repo, repoUrl, repoId, }: {
184
+ repoUrl?: string;
185
+ repoId?: string;
186
+ repo?: string;
187
187
  }): Promise<{
188
- mcpEphemeralUrl: unknown;
188
+ mcpEphemeralUrl: any;
189
189
  ephemeralUrl: any;
190
190
  url: string;
191
191
  isNew: boolean;
package/dist/index.cjs CHANGED
@@ -777,39 +777,38 @@ ${response.error.message}`);
777
777
  * ephemeral so you should call this function every time you need a url. Do
778
778
  * not store the url in your database!
779
779
  */
780
- async requestDevServer(repo) {
780
+ async requestDevServer({
781
+ repo,
782
+ repoUrl,
783
+ repoId
784
+ }) {
781
785
  function formatHook(serverUrl, repoUrl2) {
782
786
  const hook = serverUrl + "/__freestyle_dev_server/update/git?repo=" + encodeURIComponent(repoUrl2);
783
- console.log(hook);
784
787
  return hook;
785
788
  }
786
- let repoId;
787
- if ("repoId" in repo) {
788
- repoId = repo.repoId;
789
- } else if ("repoUrl" in repo) {
790
- const parts = repo.repoUrl.split("/");
791
- repoId = parts[parts.length - 1];
792
- } else {
793
- throw new Error("Either repoId or repoUrl must be provided");
794
- }
795
- const repoUrl = (process.env.GIT_URL ?? "https://git.freestyle.sh/") + repoId;
796
789
  const response = await handleEphemeralDevServer({
797
790
  client: this.client,
798
791
  body: {
792
+ // @ts-ignore
793
+ repo: repo || repoUrl,
799
794
  repoId
800
795
  }
801
796
  });
802
797
  if (response.data.isNew) {
798
+ const rId = repoId || repoUrl.split("/").at(-1);
803
799
  await this.createGitTrigger({
804
- repoId,
800
+ repoId: rId,
805
801
  action: {
806
- endpoint: formatHook(response.data?.url, repoUrl),
802
+ endpoint: formatHook(
803
+ response.data?.url,
804
+ repoUrl || repo || `https://git.freestyle.sh/${rId}`
805
+ ),
807
806
  action: "webhook"
808
807
  },
809
808
  trigger: {
810
809
  event: "push"
811
810
  }
812
- }).then(console.log);
811
+ });
813
812
  }
814
813
  if (!response.data) {
815
814
  throw new Error(`Failed to request dev server: ${response.error}`);
package/dist/index.d.cts CHANGED
@@ -180,12 +180,12 @@ declare class FreestyleSandboxes {
180
180
  * ephemeral so you should call this function every time you need a url. Do
181
181
  * not store the url in your database!
182
182
  */
183
- requestDevServer(repo: {
184
- repoId: string;
185
- } | {
186
- repoUrl: string;
183
+ requestDevServer({ repo, repoUrl, repoId, }: {
184
+ repoUrl?: string;
185
+ repoId?: string;
186
+ repo?: string;
187
187
  }): Promise<{
188
- mcpEphemeralUrl: unknown;
188
+ mcpEphemeralUrl: any;
189
189
  ephemeralUrl: any;
190
190
  url: string;
191
191
  isNew: boolean;
package/dist/index.d.mts CHANGED
@@ -180,12 +180,12 @@ declare class FreestyleSandboxes {
180
180
  * ephemeral so you should call this function every time you need a url. Do
181
181
  * not store the url in your database!
182
182
  */
183
- requestDevServer(repo: {
184
- repoId: string;
185
- } | {
186
- repoUrl: string;
183
+ requestDevServer({ repo, repoUrl, repoId, }: {
184
+ repoUrl?: string;
185
+ repoId?: string;
186
+ repo?: string;
187
187
  }): Promise<{
188
- mcpEphemeralUrl: unknown;
188
+ mcpEphemeralUrl: any;
189
189
  ephemeralUrl: any;
190
190
  url: string;
191
191
  isNew: boolean;
package/dist/index.mjs CHANGED
@@ -775,39 +775,38 @@ ${response.error.message}`);
775
775
  * ephemeral so you should call this function every time you need a url. Do
776
776
  * not store the url in your database!
777
777
  */
778
- async requestDevServer(repo) {
778
+ async requestDevServer({
779
+ repo,
780
+ repoUrl,
781
+ repoId
782
+ }) {
779
783
  function formatHook(serverUrl, repoUrl2) {
780
784
  const hook = serverUrl + "/__freestyle_dev_server/update/git?repo=" + encodeURIComponent(repoUrl2);
781
- console.log(hook);
782
785
  return hook;
783
786
  }
784
- let repoId;
785
- if ("repoId" in repo) {
786
- repoId = repo.repoId;
787
- } else if ("repoUrl" in repo) {
788
- const parts = repo.repoUrl.split("/");
789
- repoId = parts[parts.length - 1];
790
- } else {
791
- throw new Error("Either repoId or repoUrl must be provided");
792
- }
793
- const repoUrl = (process.env.GIT_URL ?? "https://git.freestyle.sh/") + repoId;
794
787
  const response = await handleEphemeralDevServer({
795
788
  client: this.client,
796
789
  body: {
790
+ // @ts-ignore
791
+ repo: repo || repoUrl,
797
792
  repoId
798
793
  }
799
794
  });
800
795
  if (response.data.isNew) {
796
+ const rId = repoId || repoUrl.split("/").at(-1);
801
797
  await this.createGitTrigger({
802
- repoId,
798
+ repoId: rId,
803
799
  action: {
804
- endpoint: formatHook(response.data?.url, repoUrl),
800
+ endpoint: formatHook(
801
+ response.data?.url,
802
+ repoUrl || repo || `https://git.freestyle.sh/${rId}`
803
+ ),
805
804
  action: "webhook"
806
805
  },
807
806
  trigger: {
808
807
  event: "push"
809
808
  }
810
- }).then(console.log);
809
+ });
811
810
  }
812
811
  if (!response.data) {
813
812
  throw new Error(`Failed to request dev server: ${response.error}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "freestyle-sandboxes",
3
- "version": "0.0.52",
3
+ "version": "0.0.53",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
package/src/index.ts CHANGED
@@ -797,60 +797,58 @@ export class FreestyleSandboxes {
797
797
  * ephemeral so you should call this function every time you need a url. Do
798
798
  * not store the url in your database!
799
799
  */
800
- async requestDevServer(repo: { repoId: string } | { repoUrl: string }) {
800
+ async requestDevServer({
801
+ repo,
802
+ repoUrl,
803
+ repoId,
804
+ }: {
805
+ repoUrl?: string;
806
+ repoId?: string;
807
+ repo?: string;
808
+ }) {
801
809
  function formatHook(serverUrl: string, repoUrl: string) {
802
810
  const hook =
803
811
  serverUrl +
804
812
  "/__freestyle_dev_server/update/git?repo=" +
805
813
  encodeURIComponent(repoUrl);
806
-
807
- console.log(hook);
808
814
  return hook;
809
815
  }
810
816
 
811
- let repoId: string;
812
- if ("repoId" in repo) {
813
- repoId = repo.repoId;
814
- } else if ("repoUrl" in repo) {
815
- const parts = repo.repoUrl.split("/");
816
- repoId = parts[parts.length - 1]; // Get the last part of the URL path
817
- } else {
818
- throw new Error("Either repoId or repoUrl must be provided");
819
- }
820
-
821
- const repoUrl =
822
- (process.env.GIT_URL ?? "https://git.freestyle.sh/") + repoId;
823
-
824
817
  const response = await sandbox_openapi.handleEphemeralDevServer({
825
818
  client: this.client,
826
819
  body: {
820
+ // @ts-ignore
821
+ repo: repo || repoUrl,
827
822
  repoId: repoId,
828
823
  },
829
824
  });
830
825
 
831
826
  if (response.data.isNew) {
827
+ const rId = repoId || repoUrl.split("/").at(-1)!;
828
+
832
829
  await this.createGitTrigger({
833
- repoId: repoId,
830
+ repoId: rId,
834
831
  action: {
835
- endpoint: formatHook(response.data?.url!, repoUrl),
832
+ endpoint: formatHook(
833
+ response.data?.url!,
834
+ repoUrl || repo || `https://git.freestyle.sh/${rId}`
835
+ ),
836
836
  action: "webhook",
837
837
  },
838
838
  trigger: {
839
839
  event: "push",
840
840
  },
841
- }).then(console.log);
841
+ });
842
842
  }
843
843
 
844
844
  if (!response.data) {
845
845
  throw new Error(`Failed to request dev server: ${response.error}`);
846
846
  }
847
-
848
847
  return {
849
848
  ...response.data,
850
849
  // @ts-ignore
851
850
  mcpEphemeralUrl:
852
- (response.data as unknown as Record<string, unknown>).mcpEphemeralUrl ||
853
- response.data.url + "/mcp",
851
+ (response.data as any).mcpEphemeralUrl || response.data.url + "/mcp",
854
852
  // @ts-ignore
855
853
  ephemeralUrl: response.data.ephemeralUrl ?? response.data.url,
856
854
  };