import { type Address, type CalculationResult, type CapabilitiesResponse, type HealthResponse, type LineItem, type RateStack, type ShippingInput, type StatesResponse } from './models.js'; /** A `fetch`-shaped function. Injected for unit tests. */ export type FetchFn = (input: string | URL, init?: RequestInit) => Promise; export interface OpenSalesTaxClientOptions { /** Base URL of the engine, e.g. `"http://10.32.161.126:8080"`. */ baseUrl: string; /** Optional API key; sent as `Authorization: Bearer `. */ apiKey?: string | null; /** Per-request timeout in milliseconds. Default 10_000. */ timeoutMs?: number; /** Suffix appended to the SDK's default User-Agent header. */ userAgent?: string | null; /** When false, skip TLS verification (dev only — engine self-signed cert). Default true. */ verify?: boolean; /** * Permit loopback / RFC-1918 / link-local engine URLs. Default false. * Set to true for dev or merchants running the engine on a private * network (e.g. inside the same Docker compose stack). */ allowPrivate?: boolean; /** * Inject a `fetch` implementation. Defaults to `globalThis.fetch`. * Useful for unit tests, polyfills, and HTTP instrumentation. */ fetch?: FetchFn; } interface HealthCheckSuccess { ok: true; version: string; databaseConnected: boolean; rttMs: number; } interface HealthCheckFailure { ok: false; rttMs: number; error: string; } /** * Result of the convenience `healthCheck()` wrapper — never throws. * Used by connector startup probes that want to log-and-continue * rather than crash on engine-unreachable. */ export type HealthCheckResult = HealthCheckSuccess | HealthCheckFailure; export declare class OpenSalesTaxClient { private readonly baseUrl; private readonly apiKey; private readonly timeoutMs; private readonly userAgent; private readonly fetchImpl; /** * Per-instance cache for `capabilitiesCached()`. `null` until the * first call resolves; subsequent calls return the same Promise. * Invalidate by creating a new client. */ private cachedCapabilities; constructor(options: OpenSalesTaxClientOptions); /** No-op close hook for parity with the Python SDK's context-manager API. */ close(): void; /** GET /v1/health — liveness + DB-connection check. */ health(): Promise; /** GET /v1/states — coverage tier per state. */ states(): Promise; /** GET /v1/rates?zip5=...&zip4=... — rate stack only (no calculation). */ rates(zip5: string, zip4?: string | null): Promise; /** * GET /v1/capabilities — engine version, endpoint manifest, feature flags. * * Always fetches fresh. For connector tier code that wants a single * fetch per client lifetime, use {@link capabilitiesCached}. */ capabilities(): Promise; /** * Same as {@link capabilities} but memoized per-client-instance. * Resolves with the same `CapabilitiesResponse` for every call * after the first; suitable for connector setup-time checks where * the capability snapshot will not change within the process * lifetime. * * Cache invalidation: create a new `OpenSalesTaxClient` instance. * (Long-running processes that need to detect engine version * bumps should bypass this and call {@link capabilities} directly.) */ capabilitiesCached(): Promise; /** * POST /v1/calculate — full per-line, per-jurisdiction calculation. * * @param address Destination address (US ZIP). * @param lineItems Pre-tax product line items. * @param shipping Optional top-level shipping segment. Engine v0.59.0+ * applies per-state shipping-taxability rules; older engines silently * ignore the field. Pass `undefined` (or omit) for product-only carts. */ calculate(address: Address, lineItems: LineItem[], shipping?: ShippingInput | null): Promise; /** * Liveness probe wrapper with RTT measurement and never-throws * contract. Used by connector startup probes that want to log a * warning and continue booting rather than crash on engine-down. */ healthCheck(): Promise; private buildHeaders; private sendRequest; private handleErrorResponse; private parseSuccessBody; private requestJSON; } export {}; //# sourceMappingURL=client.d.ts.map