export type ReindexAllCollectionsSchema = {collection_ids: Array | null, realms?: (Array | null) | undefined}; export type CreateApiV1CollectionsReindexArgs = {'App-ID': string, 'Auth-Token': string, low_priority_indexing?: boolean | undefined, body: ReindexAllCollectionsSchema}; export type CreateApiV1CollectionsReindexOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Trigger reindexing of all collections * * POST /v1/collections/reindex/ */ export const createApiV1CollectionsReindex = async (args: CreateApiV1CollectionsReindexArgs, options: CreateApiV1CollectionsReindexOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['App-ID'] != null) headers.set("App-ID", String(args['App-ID'])) if (args['Auth-Token'] != null) headers.set("Auth-Token", String(args['Auth-Token'])) if (args.low_priority_indexing != null) query.append("low_priority_indexing", String(args.low_priority_indexing)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/collections/reindex/${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };