UNPKG

@goatlab/typesense

Version:

Modern TypeScript wrapper for Typesense search engine API

52 lines (51 loc) 1.8 kB
import type { KyInstance } from '@goatlab/js-utils'; export interface HttpClientOptions { prefixUrl: string; token: string; searchTimeout?: number; importTimeout?: number; defaultTimeout?: number; beforeRequest?: Array<(request: Request) => Request | Response | undefined | Promise<Request | Response | undefined>>; afterResponse?: any[]; beforeError?: Array<(error: any) => any | Promise<any>>; kyInstance?: KyInstance; enforceTLS?: boolean; } export declare class TypesenseHttpClient { private kyInstance; private readonly enforceTLS; private readonly options; constructor(options: HttpClientOptions); get importTimeout(): number | undefined; private createDefaultClient; private sanitizeHeaders; request<T>(endpoint: string, options?: { method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'; body?: any; searchParams?: Record<string, any>; timeout?: number; signal?: AbortSignal; }): Promise<T>; requestText(endpoint: string, options?: { method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'; body?: any; searchParams?: Record<string, any>; timeout?: number; signal?: AbortSignal; }): Promise<string>; requestTextWithRawBody(endpoint: string, options?: { method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'; body?: any; searchParams?: Record<string, any>; timeout?: number; signal?: AbortSignal; }): Promise<string>; stream(endpoint: string, options?: { method?: 'GET' | 'POST'; body?: any; searchParams?: Record<string, any>; signal?: AbortSignal; }): Promise<ReadableStream>; getClient(): KyInstance; getOptions(): HttpClientOptions; }