/**
 * @fileoverview Shared error classification constants used by the error handler.
 * Enhanced with regex caching for performance and provider-specific error patterns.
 * @module src/utils/internal/error-handler/mappings
 */
import { JsonRpcErrorCode } from '../../../types-global/errors.js';
import type { BaseErrorMapping } from './types.js';
/**
 * Compiles and caches a regex pattern for repeated use without re-compilation overhead.
 *
 * - String patterns are compiled with the `i` (case-insensitive) flag.
 * - `RegExp` patterns are re-compiled without the `g` flag (global flag is removed to prevent
 *   stateful `lastIndex` bugs when the same pattern is reused across multiple `.test()` calls)
 *   and with `i` added if absent.
 * - Cache key for `RegExp` inputs is `source + flags`; for strings it is the string itself.
 *
 * @param pattern - A string or `RegExp` to compile and cache.
 * @returns The compiled, cached `RegExp` instance.
 *
 * @example
 * ```ts
 * const re = getCompiledPattern('not found');
 * re.test('Resource not found'); // → true
 *
 * const re2 = getCompiledPattern(/ThrottlingException/i);
 * re2.test('ThrottlingException: rate exceeded'); // → true
 * ```
 */
export declare function getCompiledPattern(pattern: string | RegExp): RegExp;
/**
 * Extended error mapping interface that includes pre-compiled regex pattern.
 * @private
 */
interface CompiledErrorMapping extends BaseErrorMapping {
    /** Pre-compiled regex pattern for efficient matching */
    compiledPattern: RegExp;
}
/**
 * Maps standard JavaScript error constructor names to `JsonRpcErrorCode` values.
 *
 * Consulted by `ErrorHandler.determineErrorCode` as the first pattern-match step after
 * checking for `McpError` instances. Constructor names are matched via `getErrorName()`.
 *
 * | Constructor | Mapped Code |
 * |-------------|-------------|
 * | `SyntaxError` | `ValidationError` |
 * | `RangeError` | `ValidationError` |
 * | `URIError` | `ValidationError` |
 * | `ReferenceError` | `InternalError` |
 * | `EvalError` | `InternalError` |
 * | `AggregateError` | `InternalError` |
 *
 * Note: `TypeError` is intentionally excluded. Runtime TypeErrors (e.g. "Cannot read
 * properties of undefined") are programming errors, not validation failures. Letting them
 * fall through to message-pattern matching or the `InternalError` fallback is more accurate.
 *
 * @example
 * ```ts
 * ERROR_TYPE_MAPPINGS['SyntaxError']; // → JsonRpcErrorCode.ValidationError
 * ```
 */
export declare const ERROR_TYPE_MAPPINGS: Readonly<Record<string, JsonRpcErrorCode>>;
/**
 * Pre-compiled common error patterns used by `ErrorHandler.determineErrorCode`.
 *
 * Derived from `COMMON_ERROR_PATTERNS` — each entry has its `pattern` compiled via
 * `getCompiledPattern` at module initialization. Checked after `COMPILED_PROVIDER_PATTERNS`
 * (provider patterns are more specific and take priority).
 *
 * Patterns cover: auth/unauthorized, forbidden, not-found, validation, conflict,
 * rate-limit, timeout/abort, service-unavailable, and Zod schema errors.
 */
export declare const COMPILED_ERROR_PATTERNS: ReadonlyArray<Readonly<CompiledErrorMapping>>;
/**
 * Pre-compiled provider-specific error patterns used by `ErrorHandler.determineErrorCode`.
 *
 * Derived from `PROVIDER_ERROR_PATTERNS` — each entry has its `pattern` compiled via
 * `getCompiledPattern` at module initialization. Checked before `COMPILED_ERROR_PATTERNS`
 * because provider patterns are more specific (e.g. `status code 429` is more precise than
 * the generic `rate limit` common pattern).
 *
 * Covers: AWS service errors, HTTP status codes (401/403/404/409/429/5xx),
 * database connection/constraint errors, Supabase JWT/RLS, OpenRouter/LLM quota errors,
 * and low-level network errors (ECONNREFUSED, ECONNRESET, ENOTFOUND, ETIMEDOUT).
 */
export declare const COMPILED_PROVIDER_PATTERNS: ReadonlyArray<Readonly<CompiledErrorMapping>>;
/** Broad error category derived from a classified JSON-RPC error code. */
export type ErrorCategory = 'upstream' | 'server' | 'client';
/**
 * Maps a classified JSON-RPC error code to a broad error category.
 *
 * - `upstream` — external API failures: service unavailable, rate-limited, timeout.
 * - `server` — internal bugs or infrastructure issues.
 * - `client` — bad input, auth failures, not-found: problems with the request itself.
 */
export declare function getErrorCategory(code: JsonRpcErrorCode): ErrorCategory;
export {};
//# sourceMappingURL=mappings.d.ts.map