export type Identifier = string; export type CreateApiV3IndexNameDocumentsIdentifierReIndexArgs = {name: string, identifier: Identifier}; export type CreateApiV3IndexNameDocumentsIdentifierReIndexOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Re-index a document * * POST /v3/index/{name}/documents/{identifier}/re_index */ export const createApiV3IndexNameDocumentsIdentifierReIndex = async (args: CreateApiV3IndexNameDocumentsIdentifierReIndexArgs, options?: CreateApiV3IndexNameDocumentsIdentifierReIndexOptions) => { const {baseUrl = "https://api.affinda.com", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (ApiKeyAuth !== undefined) headers.set('authorization', `Bearer ${ApiKeyAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v3/index/${encodeURIComponent(String(args.name))}/documents/${encodeURIComponent(String(args.identifier))}/re_index${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };