export type GetApiApiViewArgs = {filename: string, subfolder?: string | undefined, type?: string | undefined, fullpath?: string | undefined, format?: string | undefined, frame_rate?: number | undefined, workflow?: string | undefined, timestamp?: number | undefined, channel?: string | undefined}; export type GetApiApiViewOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * View a file * * GET /api/view */ export const getApiApiView = async (args: GetApiApiViewArgs, options?: GetApiApiViewOptions) => { const {baseUrl = "https://api.comfy.org", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/png") if (args.filename != null) query.append("filename", String(args.filename)) if (args.subfolder != null) query.append("subfolder", String(args.subfolder)) if (args.type != null) query.append("type", String(args.type)) if (args.fullpath != null) query.append("fullpath", String(args.fullpath)) if (args.format != null) query.append("format", String(args.format)) if (args.frame_rate != null) query.append("frame_rate", String(args.frame_rate)) if (args.workflow != null) query.append("workflow", String(args.workflow)) if (args.timestamp != null) query.append("timestamp", String(args.timestamp)) if (args.channel != null) query.append("channel", String(args.channel)) const url = `${baseUrl.replace(/\/+$/, '')}/api/view${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 res.blob() };