/**
 * JSON-RPC error infrastructure for fuz_app routes.
 *
 * Provides error types, named constructors, and HTTP status mapping
 * for the throw/catch error pattern used by `apply_route_specs`.
 * Core error codes (5 standard + 10 general application). Domain-specific
 * codes stay in consumers — add by casting `as JsonrpcErrorCode`.
 *
 * `JsonrpcErrorCode` and `JsonrpcErrorObject` types are Zod-inferred
 * from `http/jsonrpc.ts` — this module re-uses those as the single source
 * of truth.
 *
 * Complementary to `http/error_schemas.ts`: that module is declarative
 * (Zod schemas for surface introspection), this one is runtime
 * (throw + catch + map).
 *
 * @module
 */
import type { ContentfulStatusCode } from 'hono/utils/http-status';
import { type JsonrpcErrorCode, type JsonrpcErrorObject } from './jsonrpc.js';
/** Default message for unknown errors. */
export declare const UNKNOWN_ERROR_MESSAGE = "unknown error";
/** Names of standard and general application JSON-RPC error codes. */
export type JsonrpcErrorName = 'parse_error' | 'invalid_request' | 'method_not_found' | 'invalid_params' | 'internal_error' | 'unauthenticated' | 'forbidden' | 'not_found' | 'conflict' | 'validation_error' | 'rate_limited' | 'service_unavailable' | 'timeout' | 'queue_overflow' | 'request_cancelled';
/**
 * Standard JSON-RPC error codes (5) plus general application codes (10).
 *
 * Extensible — consumers add domain-specific codes to their own objects
 * by casting `as JsonrpcErrorCode`. Application codes use the -32000 to
 * -32099 range reserved by the JSON-RPC spec.
 *
 * Frozen with `Object.freeze` to convert accidental mutation (test
 * cross-contamination, cast escapes) into loud TypeErrors. Spread into
 * a fresh object to extend.
 */
export declare const JSONRPC_ERROR_CODES: Readonly<Record<JsonrpcErrorName, JsonrpcErrorCode>>;
/**
 * Named constructors for `JsonrpcErrorObject` values.
 *
 * Each function creates a JSON-RPC error object with the correct
 * code and a sensible default message. Used by the catch layer in
 * `apply_route_specs` to build response bodies.
 *
 * Frozen so tests must compose new objects rather than monkey-patch.
 */
export declare const jsonrpc_error_messages: Readonly<Record<JsonrpcErrorName, (...args: Array<any>) => JsonrpcErrorObject>>;
/**
 * Error class carrying a JSON-RPC error code — thrown by handlers,
 * caught by `apply_route_specs` and mapped to HTTP status + JSON-RPC error response.
 *
 * Named for what it is: an error with a JSON-RPC error code that gets thrown.
 */
export declare class ThrownJsonrpcError extends Error {
    code: JsonrpcErrorCode;
    data?: unknown;
    constructor(code: JsonrpcErrorCode, message: string, data?: unknown, options?: ErrorOptions);
}
/**
 * Named constructors for `ThrownJsonrpcError`.
 *
 * Usage: `throw jsonrpc_errors.not_found('user')` or `throw jsonrpc_errors.forbidden()`.
 */
export declare const jsonrpc_errors: {
    readonly parse_error: (...args: any[]) => ThrownJsonrpcError;
    readonly invalid_request: (...args: any[]) => ThrownJsonrpcError;
    readonly method_not_found: (...args: any[]) => ThrownJsonrpcError;
    readonly invalid_params: (...args: any[]) => ThrownJsonrpcError;
    readonly internal_error: (...args: any[]) => ThrownJsonrpcError;
    readonly unauthenticated: (...args: any[]) => ThrownJsonrpcError;
    readonly forbidden: (...args: any[]) => ThrownJsonrpcError;
    readonly not_found: (...args: any[]) => ThrownJsonrpcError;
    readonly conflict: (...args: any[]) => ThrownJsonrpcError;
    readonly validation_error: (...args: any[]) => ThrownJsonrpcError;
    readonly rate_limited: (...args: any[]) => ThrownJsonrpcError;
    readonly service_unavailable: (...args: any[]) => ThrownJsonrpcError;
    readonly timeout: (...args: any[]) => ThrownJsonrpcError;
    readonly queue_overflow: (...args: any[]) => ThrownJsonrpcError;
    readonly request_cancelled: (...args: any[]) => ThrownJsonrpcError;
};
/**
 * Maps JSON-RPC error codes to HTTP status codes.
 *
 * Extensible — consumers with domain-specific error codes assign directly
 * (`JSONRPC_ERROR_CODE_TO_HTTP_STATUS[-32020] = 502`) at module load. The
 * lookup function reads at call time, so mutation is the supported
 * extension mechanism.
 */
export declare const JSONRPC_ERROR_CODE_TO_HTTP_STATUS: Record<number, number>;
/**
 * Maps HTTP status codes to JSON-RPC error codes (reverse mapping).
 *
 * When multiple error codes map to the same HTTP status (e.g. parse_error
 * and invalid_request both map to 400), the last one wins. Use for
 * best-effort HTTP → JSON-RPC translation.
 */
export declare const HTTP_STATUS_TO_JSONRPC_ERROR_CODE: Record<number, JsonrpcErrorCode>;
/**
 * Map a JSON-RPC error code to an HTTP status code.
 *
 * Returns 500 for unrecognized codes (consumer-defined codes
 * without a mapping default to internal server error). The return
 * is narrowed to Hono's `ContentfulStatusCode` so call sites can
 * pass the result to `c.json(body, status)` without `as any` —
 * 499 (nginx "client closed request") is non-standard and gets
 * absorbed by the cast here rather than at every dispatcher branch.
 */
export declare const jsonrpc_error_code_to_http_status: (code: JsonrpcErrorCode) => ContentfulStatusCode;
/**
 * Map an HTTP status code to a JSON-RPC error code.
 *
 * Returns `internal_error` (-32603) for unrecognized status codes.
 */
export declare const http_status_to_jsonrpc_error_code: (status: number) => JsonrpcErrorCode;
/**
 * Reverse map of `JSONRPC_ERROR_CODES` — JSON-RPC error code → name.
 *
 * Used by REST emitters that need a stable string identifier for the
 * code in their flat-shape error body (`{error: '<name>', ...}`)
 * without inventing a separate vocabulary. Built once at module load
 * from the canonical `JSONRPC_ERROR_CODES` map so the two cannot drift.
 *
 * Consumer-defined codes outside the standard taxonomy are not present;
 * `jsonrpc_error_code_to_name` falls back to `'internal_error'` so the
 * REST shape always carries some reason rather than `undefined`.
 */
export declare const JSONRPC_ERROR_CODE_TO_NAME: Readonly<Record<number, JsonrpcErrorName>>;
/**
 * Map a JSON-RPC error code to its canonical name (`'not_found'`,
 * `'forbidden'`, etc.). Falls back to `'internal_error'` for codes
 * outside the standard taxonomy so REST emitters that read this for
 * their `error` field always have a stable string to emit.
 */
export declare const jsonrpc_error_code_to_name: (code: JsonrpcErrorCode) => JsonrpcErrorName;
//# sourceMappingURL=jsonrpc_errors.d.ts.map