export type GetApiExportTableIdArgs = {tableId: string, viewId?: string | undefined, ignoreViewQuery?: (string | boolean) | undefined, filter?: string | undefined, orderBy?: string | undefined, groupBy?: string | undefined, projection?: Array | undefined, columnMeta?: string | undefined}; export type GetApiExportTableIdOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * export csv from table * * GET /export/{tableId} */ export const getApiExportTableId = async (args: GetApiExportTableIdArgs, options?: GetApiExportTableIdOptions) => { const {baseUrl = "https://app.teable.ai/api", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.viewId != null) query.append("viewId", String(args.viewId)) if (args.ignoreViewQuery != null) query.append("ignoreViewQuery", String(args.ignoreViewQuery)) if (args.filter != null) query.append("filter", String(args.filter)) if (args.orderBy != null) query.append("orderBy", String(args.orderBy)) if (args.groupBy != null) query.append("groupBy", String(args.groupBy)) for (const item of args.projection ?? []) query.append("projection", String(item)) if (args.columnMeta != null) query.append("columnMeta", String(args.columnMeta)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/export/${encodeURIComponent(String(args.tableId))}${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 };