export type GetApiApiResourceJsResourceIdDownloadArgs = {resourceId: string, 'If-None-Match'?: string | undefined}; export type GetApiApiResourceJsResourceIdDownloadOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download JS Resource (downloadJsResourceIfChanged) * * GET /api/resource/js/{resourceId}/download */ export const getApiApiResourceJsResourceIdDownload = async (args: GetApiApiResourceJsResourceIdDownloadArgs, options?: GetApiApiResourceJsResourceIdDownloadOptions) => { const {baseUrl = "https://demo.thingsboard.io", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/javascript") if (args['If-None-Match'] != null) headers.set("If-None-Match", String(args['If-None-Match'])) const url = `${baseUrl.replace(/\/+$/, '')}/api/resource/js/${encodeURIComponent(String(args.resourceId))}/download${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() };