import type { Context, Span, SpanOptions } from '@opentelemetry/api'; import type { SpanProcessor } from '@opentelemetry/sdk-trace-node'; import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node'; import type { EmptyObject } from '../core/types/EmptyObject.js'; import type { Logger } from '../core/types/Logger.js'; import type { AuthCredentials } from './types/AuthCredentials.js'; import type { HttpClientConfig } from './types/HttpClientConfig.js'; import type { HttpClientRequestOptions } from './types/HttpClientRequestOptions.js'; import type { RestClient } from './types/RestClient.js'; /** * HTTP client with JSON helpers, timeout handling, tracing, metrics, and normalized errors. * * Request bodies are serialized as JSON unless a string payload is provided. * The client records low-cardinality HTTP metrics and OpenTelemetry spans; it * does not include request/response payloads in metric attributes. Avoid * placing secrets in URLs or custom headers that may be captured by external * telemetry processors. * * @example * ```typescript * const client = new HttpClient({baseUrl: 'http://localhost/api}) * * // GET http://localhost/api/v1/orders * const result = await client.get('v1/orders') * ``` */ export declare class HttpClient = EmptyObject> implements RestClient { /** Client name used in logs, spans, and metrics. */ name: string; /** Logger scoped to this client. */ logger: Logger; /** Resolved client configuration. */ config: HttpClientConfig; /** Default request timeout in milliseconds. */ timeout: number; /** Parsed base URL, when configured. */ baseUrl: URL | undefined; /** Optional OpenTelemetry span processor configured for this client. */ spanProcessor: SpanProcessor | undefined; /** Node tracer provider owned by this client instance. */ traceProvider: NodeTracerProvider; private readonly metricsRecorder; protected auth: AuthCredentials; constructor(config: HttpClientConfig); /** * Returns OpenTelemetry tracer of this client. * * @returns Tracer */ getTracer(): import("@opentelemetry/api").Tracer; /** * Start a child span for OpenTelemetry tracking. * * Exceptions are recorded on the span and re-thrown unchanged. * * @param name name of span * @param opts span options * @param context optional context * @param fn function to be executed within the span * @returns return value of fn */ startActiveSpan(name: string, opts: SpanOptions, context: Context | undefined, fn: (span: Span) => Promise): Promise; private recordHttpClientDuration; protected getUrlAndHeader(path: string, options?: HttpClientRequestOptions): { url: URL; headers: Record; }; /** * Set the bearer token for all following requests. * * The token is stored in memory only and sent as an `Authorization` header. * Do not pass it through logs, query strings, or metric attributes. * * @param token the bearer token */ setBearerToken(token: string | undefined): void; /** * Helper method * @param method * @param path * @param options * @param payload * @throws UnhandledError * @returns */ protected execute(method: string, path: string, options?: HttpClientRequestOptions, payload?: unknown): Promise; /** * GET request. * * Parses JSON responses when the response content type starts with * `application/json`; otherwise returns response text. * * @param path * @param options * @returns */ get(path: string, options?: HttpClientRequestOptions): Promise; /** * POST request with an optional JSON payload. * * @param path * @param payload * @param options * @returns */ post(path: string, payload: unknown, options?: HttpClientRequestOptions): Promise; /** * PUT request with an optional JSON payload. * * @param path * @param payload * @param options * @returns */ put(path: string, payload: unknown, options?: HttpClientRequestOptions): Promise; /** * PATCH request with an optional JSON payload. * * @param path * @param payload * @param options * @returns */ patch(path: string, payload: unknown, options?: HttpClientRequestOptions): Promise; /** * DELETE request. * * @param path * @param options * @param payload optional request body for APIs that accept DELETE bodies * @returns */ delete(path: string, options?: HttpClientRequestOptions, payload?: unknown): Promise; } //# sourceMappingURL=HttpClient.impl.d.ts.map