import type { AxiosRequestConfig, AxiosResponse, Method } from "axios"; import { Logger } from "loglevel"; import Configuration from "./Configuration"; import type { NodeConfiguration, StreamConfig } from "./Configuration"; import TypesenseError from "./Errors/TypesenseError"; import type { DocumentSchema } from "./Documents"; interface Node extends NodeConfiguration { isHealthy: boolean; index: string | number; } export interface HttpClient { get(endpoint: string, queryParameters: Record, { abortSignal, responseType, streamConfig, isStreamingRequest, }: { abortSignal?: AbortSignal | null; responseType?: AxiosRequestConfig["responseType"] | undefined; streamConfig?: StreamConfig | undefined; isStreamingRequest: boolean | undefined; }): Promise; delete(endpoint: string, queryParameters: Record): Promise; post(endpoint: string, bodyParameters: unknown, queryParameters: Record, additionalHeaders: Record, { abortSignal, responseType, streamConfig, isStreamingRequest, }: { abortSignal?: AbortSignal | null; responseType?: AxiosRequestConfig["responseType"] | undefined; streamConfig?: StreamConfig | undefined; isStreamingRequest: boolean | undefined; }): Promise; put(endpoint: string, bodyParameters: unknown, queryParameters: Record): Promise; patch(endpoint: string, bodyParameters: unknown, queryParameters: Record): Promise; } export default class ApiCall implements HttpClient { private configuration; private readonly apiKey; private readonly nodes; private readonly nearestNode; private readonly connectionTimeoutSeconds; private readonly healthcheckIntervalSeconds; private readonly retryIntervalSeconds; private readonly sendApiKeyAsQueryParam?; private readonly numRetriesPerRequest; private readonly additionalUserHeaders?; readonly logger: Logger; private currentNodeIndex; constructor(configuration: Configuration); get(endpoint: string, queryParameters?: any, { abortSignal, responseType, streamConfig, isStreamingRequest, }?: { abortSignal?: any; responseType?: AxiosRequestConfig["responseType"] | undefined; streamConfig?: StreamConfig | undefined; isStreamingRequest?: boolean | undefined; }): Promise; delete(endpoint: string, queryParameters?: any): Promise; post(endpoint: string, bodyParameters?: any, queryParameters?: any, additionalHeaders?: any, { abortSignal, responseType, streamConfig, isStreamingRequest, }?: { abortSignal?: AbortSignal | null; responseType?: AxiosRequestConfig["responseType"] | undefined; streamConfig?: StreamConfig | undefined; isStreamingRequest?: boolean | undefined; }): Promise; put(endpoint: string, bodyParameters?: any, queryParameters?: any): Promise; patch(endpoint: string, bodyParameters?: any, queryParameters?: any): Promise; private getAdapter; performRequest(requestType: Method, endpoint: string, { queryParameters, bodyParameters, additionalHeaders, abortSignal, responseType, skipConnectionTimeout, enableKeepAlive, streamConfig, isStreamingRequest, }: { queryParameters?: any; bodyParameters?: any; additionalHeaders?: any; abortSignal?: any; responseType?: AxiosRequestConfig["responseType"] | undefined; skipConnectionTimeout?: boolean; enableKeepAlive?: boolean | undefined; streamConfig?: StreamConfig | undefined; isStreamingRequest?: boolean | undefined; }): Promise; private processStreamingLine; private processDataLine; private handleStreamingResponse; private handleNodeStreaming; private handleBrowserStreaming; private handleBrowserReadableStream; private handleBrowserStringResponse; private processStreamLines; private finalizeStreamResult; /** * Combines multiple streaming chunks into a single coherent result * This is critical for ensuring we return the complete data rather than just the last chunk */ private combineStreamingChunks; private getMessageChunks; private isChunkMessage; private combineMessageChunks; private isCompleteSearchResponse; getNextNode(requestNumber?: number): Node; nodeDueForHealthcheck(node: any, requestNumber?: number): boolean; initializeMetadataForNodes(): void; setNodeHealthcheck(node: any, isHealthy: any): void; uriFor(endpoint: string, node: any): string; defaultHeaders(): any; timer(seconds: any): Promise; customErrorForResponse(response: AxiosResponse, messageFromServer: string, httpBody?: string): TypesenseError; private invokeOnChunkCallback; private invokeOnCompleteCallback; private invokeOnErrorCallback; } export {};