robodev 0.17.0 → 0.19.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "robodev",
3
- "version": "0.17.0",
3
+ "version": "0.19.0",
4
4
  "description": "CLI for Robodev Starbase — create, auth, link, and deploy hosted apps",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -2,8 +2,8 @@ const authCustomJWT = {
2
2
  enableMagicLink: import.meta.env.VITE_PUBLIC_AUTH_CUSTOM_JWT_ENABLE_MAGIC_LINK === "true",
3
3
  };
4
4
 
5
- const apiUrl = import.meta.env.VITE_PUBLIC_API_URL ?? "http://localhost:4000";
6
- const apiOrigin = apiUrl.replace(/\/+$/, "") || "/";
5
+ const rawApiUrl = import.meta.env.VITE_PUBLIC_API_URL?.trim() ?? "";
6
+ const apiOrigin = /^https?:\/\//i.test(rawApiUrl) ? rawApiUrl.replace(/\/+$/, "") : "";
7
7
  const apiMode = import.meta.env.VITE_PUBLIC_API_MODE ?? "real";
8
8
  export const AppConfig = {
9
9
  isProduction: import.meta.env.NODE_ENV === "production",
@@ -11,7 +11,7 @@
11
11
  "@robodev-ai/sdk": "^0.6.0"
12
12
  },
13
13
  "devDependencies": {
14
- "robodev": "^0.17.0",
14
+ "robodev": "^0.19.0",
15
15
  "rulesync": "^8.18.0",
16
16
  "typescript": "^5.9.2"
17
17
  }
@@ -10,7 +10,7 @@
10
10
  "@robodev-ai/sdk": "^0.6.0"
11
11
  },
12
12
  "devDependencies": {
13
- "robodev": "^0.17.0",
13
+ "robodev": "^0.19.0",
14
14
  "typescript": "^5.9.2"
15
15
  }
16
16
  }
@@ -10,7 +10,7 @@
10
10
  "@robodev-ai/sdk": "^0.6.0"
11
11
  },
12
12
  "devDependencies": {
13
- "robodev": "^0.17.0",
13
+ "robodev": "^0.19.0",
14
14
  "typescript": "^5.9.2"
15
15
  }
16
16
  }
@@ -2,8 +2,8 @@ const authCustomJWT = {
2
2
  enableMagicLink: import.meta.env.VITE_PUBLIC_AUTH_CUSTOM_JWT_ENABLE_MAGIC_LINK === "true",
3
3
  };
4
4
 
5
- const apiUrl = import.meta.env.VITE_PUBLIC_API_URL ?? "http://localhost:4000";
6
- const apiOrigin = apiUrl.replace(/\/+$/, "") || "/";
5
+ const rawApiUrl = import.meta.env.VITE_PUBLIC_API_URL?.trim() ?? "";
6
+ const apiOrigin = /^https?:\/\//i.test(rawApiUrl) ? rawApiUrl.replace(/\/+$/, "") : "";
7
7
  const apiMode = import.meta.env.VITE_PUBLIC_API_MODE ?? "real";
8
8
  export const AppConfig = {
9
9
  isProduction: import.meta.env.NODE_ENV === "production",
@@ -0,0 +1,8 @@
1
+ /** Raw FormData upload headers. Never set Content-Type — the browser must add the multipart boundary. */
2
+ export function mediaUploadHeaders(accessToken: string | null): Headers {
3
+ const headers = new Headers();
4
+ if (accessToken) {
5
+ headers.set("Authorization", `Bearer ${accessToken}`);
6
+ }
7
+ return headers;
8
+ }
@@ -0,0 +1,19 @@
1
+ import { describe, expect, it } from "vitest";
2
+
3
+ import { mediaUploadHeaders } from "./media-upload-headers";
4
+
5
+ describe("raw FormData upload headers", () => {
6
+ it("sends Bearer when a token exists and does not set Content-Type", () => {
7
+ const headers = mediaUploadHeaders("test-access-token");
8
+
9
+ expect(headers.get("Authorization")).toBe("Bearer test-access-token");
10
+ expect(headers.get("Content-Type")).toBeNull();
11
+ });
12
+
13
+ it("omits Authorization when no token exists and still does not set Content-Type", () => {
14
+ const headers = mediaUploadHeaders(null);
15
+
16
+ expect(headers.get("Authorization")).toBeNull();
17
+ expect(headers.get("Content-Type")).toBeNull();
18
+ });
19
+ });
@@ -1,8 +1,10 @@
1
1
  import type { FileUploadRequest } from "@povio/ui";
2
2
 
3
+ import { authTokenStore } from "@/clients/auth-token-store";
3
4
  import { AppConfig } from "@/config/app.config";
4
5
  import type { MediaModels } from "@/openapi/media/media.models";
5
6
  import { MediaQueries } from "@/openapi/media/media.queries";
7
+ import { mediaUploadHeaders } from "@/utils/media-upload-headers";
6
8
 
7
9
  interface UseMediaUploadHandlerOptions {
8
10
  resourceName: MediaModels.MediaResourceName;
@@ -40,13 +42,20 @@ export function useMediaUploadHandler({ resourceName, method, onUploaded }: UseM
40
42
  });
41
43
  formData.append("file", file);
42
44
 
43
- const uploadUrl = instructions.url.startsWith("http")
44
- ? instructions.url
45
- : `${AppConfig.api.url.replace(/\/+$/, "")}${instructions.url}`;
45
+ const origin = AppConfig.api.url.replace(/\/+$/, "");
46
+ const path = instructions.url;
47
+ const uploadUrl = /^https?:\/\//i.test(path)
48
+ ? path
49
+ : origin
50
+ ? `${origin}${path}`
51
+ : path.startsWith("/")
52
+ ? path
53
+ : `/${path}`;
46
54
 
47
55
  const response = await fetch(uploadUrl, {
48
56
  method: instructions.method.toUpperCase(),
49
57
  body: formData,
58
+ headers: mediaUploadHeaders(authTokenStore.getAccessToken()),
50
59
  signal: options?.abortController?.signal,
51
60
  });
52
61
 
@@ -11,7 +11,7 @@
11
11
  "@robodev-ai/sdk": "^0.6.0"
12
12
  },
13
13
  "devDependencies": {
14
- "robodev": "^0.17.0",
14
+ "robodev": "^0.19.0",
15
15
  "rulesync": "^8.18.0",
16
16
  "typescript": "^5.9.2"
17
17
  }