Add panel feature updates across API, daemon, and web

This commit is contained in:
2026-03-02 21:53:54 +00:00
parent 6b463c2b1a
commit afc64b83c1
49 changed files with 7040 additions and 305 deletions
+18 -3
View File
@@ -9,6 +9,21 @@ interface RequestOptions extends RequestInit {
params?: Record<string, string>;
}
function toRequestBody(body: unknown): BodyInit | undefined {
if (body === undefined || body === null) return undefined;
if (
body instanceof FormData ||
body instanceof Blob ||
body instanceof URLSearchParams ||
body instanceof ArrayBuffer
) {
return body;
}
return JSON.stringify(body);
}
class ApiError extends Error {
constructor(
public status: number,
@@ -102,19 +117,19 @@ export const api = {
post: <T>(path: string, body?: unknown) =>
request<T>(path, {
method: 'POST',
body: body ? JSON.stringify(body) : undefined,
body: toRequestBody(body),
}),
put: <T>(path: string, body?: unknown) =>
request<T>(path, {
method: 'PUT',
body: body ? JSON.stringify(body) : undefined,
body: toRequestBody(body),
}),
patch: <T>(path: string, body?: unknown) =>
request<T>(path, {
method: 'PATCH',
body: body ? JSON.stringify(body) : undefined,
body: toRequestBody(body),
}),
delete: <T>(path: string) =>