UNPKG

@relayplane/sdk

Version:

RelayPlane SDK with zero-config AI access, intelligent model selection, built-in examples, and contextual error handling. The easiest way to add AI to your app with automatic optimization and fallback.

57 lines 1.9 kB
/** * Universal HTTP Client * * This module provides a unified HTTP client that works across different environments: * - Serverless/Edge: Uses fetch API * - Node.js: Uses fetch API (Node 18+) or axios fallback * - Browser: Uses fetch API */ export interface HttpRequest { url: string; method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'; headers?: Record<string, string>; body?: any; timeout?: number; } export interface HttpResponse { data: any; status: number; statusText: string; headers: Record<string, string>; } export declare class HttpError extends Error { status: number; response?: any | undefined; constructor(message: string, status: number, response?: any | undefined); } export declare class HttpTimeoutError extends Error { timeout: number; constructor(message: string, timeout: number); } /** * Universal HTTP client that automatically selects the best implementation */ export declare function httpClient(request: HttpRequest): Promise<HttpResponse>; /** * Environment information for debugging */ export declare const environment: { isNode: string | false; isEdge: boolean; isBrowser: boolean; isServerless: string | false | undefined; hasFetch: boolean; nodeVersion: string | null; runtimeInfo: string; }; /** * Convenience methods for common HTTP operations */ export declare const http: { get: (url: string, options?: Partial<HttpRequest>) => Promise<HttpResponse>; post: (url: string, body?: any, options?: Partial<HttpRequest>) => Promise<HttpResponse>; put: (url: string, body?: any, options?: Partial<HttpRequest>) => Promise<HttpResponse>; delete: (url: string, options?: Partial<HttpRequest>) => Promise<HttpResponse>; patch: (url: string, body?: any, options?: Partial<HttpRequest>) => Promise<HttpResponse>; }; //# sourceMappingURL=http-client.d.ts.map