export type GetApiApiContentIndexcountQueryArgs = {query: string, type?: string | undefined, callback?: string | undefined}; export type GetApiApiContentIndexcountQueryOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Count content matching a Lucene query * * GET /api/content/indexcount/{query} */ export const getApiApiContentIndexcountQuery = async (args: GetApiApiContentIndexcountQueryArgs, options: GetApiApiContentIndexcountQueryOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/plain") if (args.type != null) query.append("type", String(args.type)) if (args.callback != null) query.append("callback", String(args.callback)) const url = `${baseUrl.replace(/\/+$/, '')}/api/content/indexcount/${encodeURIComponent(String(args.query))}${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.text() };