export type GetApiCatalogDatabaseArgs = {catalog_path?: string | undefined}; export type GetApiCatalogDatabaseOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Get database information from catalog editor. * * GET /catalog/database */ export const getApiCatalogDatabase = async (args: GetApiCatalogDatabaseArgs, options: GetApiCatalogDatabaseOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.catalog_path != null) query.append("catalog_path", String(args.catalog_path)) const url = `${baseUrl.replace(/\/+$/, '')}/catalog/database${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 };