export type GetApiWsLogsArgs = {Upgrade: 'websocket', Connection: 'Upgrade'}; export type GetApiWsLogsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * WebSocket Log Stream * * GET /ws/logs */ export const getApiWsLogs = async (args: GetApiWsLogsArgs, options?: GetApiWsLogsOptions) => { const {baseUrl = "http://localhost:8080", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.Upgrade != null) headers.set("Upgrade", String(args.Upgrade)) if (args.Connection != null) headers.set("Connection", String(args.Connection)) const url = `${baseUrl.replace(/\/+$/, '')}/ws/logs${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };