import { RouteMetadata, HeaderMethods, LogApiCall } from '@webpieces/http-api'; import { ContextMgr } from './ContextMgr'; /** * Type representing a class constructor whose prototype is T. * Used as the apiPrototype parameter for createApiClient. */ type ApiPrototype = Function & { prototype: T; }; /** * Configuration options for HTTP client. */ export declare class ClientConfig { /** Base URL for all requests (e.g., 'http://localhost:3000') */ baseUrl: string; /** * Optional context manager for automatic header propagation. * When provided, headers will be read from the ContextReader and added to requests. */ contextMgr?: ContextMgr; constructor(baseUrl: string, contextMgr?: ContextMgr); } /** * Creates a type-safe HTTP client from an API prototype with @ApiPath/@Endpoint decorators. * * This is the client-side equivalent of ApiRoutingFactory. * - Server: ApiRoutingFactory reads decorators -> routes HTTP requests to controllers * - Client: createApiClient reads decorators -> generates HTTP requests from method calls * * Usage: * ```typescript * const config = new ClientConfig('http://localhost:3000'); * const client = createApiClient(SaveApi, config); * const response = await client.save({ query: 'test' }); // Type-safe! * ``` * * @param apiPrototype - The API prototype class with @ApiPath/@Endpoint decorators * @param config - Client configuration with baseUrl * @param contextMgr - Optional context manager for header propagation * @returns A proxy object that implements the API interface */ export declare function createApiClient(apiPrototype: ApiPrototype, config: ClientConfig, contextMgr?: ContextMgr): T; /** * ProxyClient - HTTP client implementation with logging. * * This class handles: * - Making HTTP requests based on route metadata * - Header propagation via ContextMgr * - Logging via LogApiCall * - Error translation via ClientErrorTranslator * * LogApiCall is injected for consistent logging across the framework. */ export declare class ProxyClient { private config; private logApiCall; private headerMethods; private contextMgr?; private routeMap; constructor(config: ClientConfig, logApiCall: LogApiCall, headerMethods: HeaderMethods, routes: RouteMetadata[], contextMgr?: ContextMgr | undefined); /** * Check if a route exists for the given method name. */ hasRoute(methodName: string): boolean; /** * Get route metadata for a method name. * @throws Error if no route found */ getRoute(methodName: string): RouteMetadata; /** * Make an HTTP request based on route metadata and arguments. * * All endpoints are POST-only. The request body is the first argument. */ makeRequest(route: RouteMetadata, args: any[]): Promise; /** * Execute the fetch request and handle response. */ private executeFetch; } export {};