export type GetApiFilesIdContentsPathArgs = {id: string, path: string, version?: string | undefined}; export type GetApiFilesIdContentsPathOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get contents of a file within a package * * GET /files/{id}/contents/{path} */ export const getApiFilesIdContentsPath = async (args: GetApiFilesIdContentsPathArgs, options?: GetApiFilesIdContentsPathOptions) => { const {baseUrl = "https://api.webscale.com/v2", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.version != null) query.append("version", String(args.version)) const url = `${baseUrl.replace(/\/+$/, '')}/files/${encodeURIComponent(String(args.id))}/contents/${encodeURIComponent(String(args.path))}${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 };