UNPKG

@future-agi/sdk

Version:

We help GenAI teams maintain high-accuracy for their Models in production.

108 lines 3.19 kB
import { AxiosInstance, AxiosResponse } from 'axios'; import { BoundedExecutor } from '../utils/executor'; import { RequestConfig } from './types'; /** * Generic response handler for parsing and validating HTTP responses */ export declare abstract class ResponseHandler<T = any, U = any> { /** * Parse the response into the expected type */ static parse<T, U>(response: AxiosResponse, handlerClass: typeof ResponseHandler): T | U; /** * Parse successful response - to be implemented by subclasses */ static _parseSuccess(response: AxiosResponse): any; /** * Handle error responses - to be implemented by subclasses */ static _handleError(response: AxiosResponse): never; } /** * Configuration options for HttpClient */ export interface HttpClientConfig { baseUrl?: string; defaultHeaders?: Record<string, string>; timeout?: number; maxQueue?: number; maxWorkers?: number; retryAttempts?: number; retryDelay?: number; } /** * Base HTTP client with improved request handling, connection pooling, and async execution */ export declare class HttpClient { protected readonly _baseUrl: string; protected readonly _axiosInstance: AxiosInstance; protected readonly _executor: BoundedExecutor; protected readonly _defaultTimeout: number; protected readonly _defaultRetryAttempts: number; protected readonly _defaultRetryDelay: number; constructor(config?: HttpClientConfig); /** * Setup request and response interceptors */ private _setupInterceptors; /** * Make an HTTP request with retries and response handling */ request<T = any>(config: RequestConfig, responseHandler?: typeof ResponseHandler): Promise<T | AxiosResponse>; /** * Helper method for sleep/delay */ private _sleep; /** * Close the client and cleanup resources */ close(): Promise<void>; /** * Get the base URL */ get baseUrl(): string; /** * Get the default timeout */ get defaultTimeout(): number; } /** * Configuration for API Key authentication */ export interface APIKeyAuthConfig extends HttpClientConfig { fiApiKey?: string; fiSecretKey?: string; fiBaseUrl?: string; } /** * HTTP client with API key authentication */ export declare class APIKeyAuth extends HttpClient { protected _fiApiKey?: string; protected _fiSecretKey?: string; constructor(config?: APIKeyAuthConfig); /** * Get the current API key */ get fiApiKey(): string | undefined; /** * Get the current secret key */ get fiSecretKey(): string | undefined; /** * Get authentication headers */ get headers(): Record<string, string>; } /** * Factory function to create authenticated HTTP client */ export declare function createAuthenticatedClient(config?: APIKeyAuthConfig): APIKeyAuth; declare const _default: { ResponseHandler: typeof ResponseHandler; HttpClient: typeof HttpClient; APIKeyAuth: typeof APIKeyAuth; createAuthenticatedClient: typeof createAuthenticatedClient; }; export default _default; //# sourceMappingURL=auth.d.ts.map