import { z } from "@hono/zod-openapi"; import { HTTPException } from "hono/http-exception"; //#region src/utils/error.d.ts /** * Builds structured fields from an error chain (Drizzle → pg DatabaseError / Doltgres). * Outer wrappers often omit SQLSTATE and server detail; those live on nested `.cause`. */ declare function getDatabaseErrorLogContext(error: unknown): Record; declare const ErrorCode: z.ZodEnum<{ unauthorized: "unauthorized"; bad_request: "bad_request"; payment_required: "payment_required"; forbidden: "forbidden"; not_found: "not_found"; conflict: "conflict"; too_many_requests: "too_many_requests"; internal_server_error: "internal_server_error"; unprocessable_entity: "unprocessable_entity"; bad_gateway: "bad_gateway"; service_unavailable: "service_unavailable"; }>; declare const ERROR_DOCS_BASE_URL = "https://docs.inkeep.com/agents-api/errors"; declare const problemDetailsSchema: z.ZodObject<{ title: z.ZodString; status: z.ZodNumber; detail: z.ZodString; instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodEnum<{ unauthorized: "unauthorized"; bad_request: "bad_request"; payment_required: "payment_required"; forbidden: "forbidden"; not_found: "not_found"; conflict: "conflict"; too_many_requests: "too_many_requests"; internal_server_error: "internal_server_error"; unprocessable_entity: "unprocessable_entity"; bad_gateway: "bad_gateway"; service_unavailable: "service_unavailable"; }>; }, z.core.$strip>; type ProblemDetails = z.infer; type ErrorCodes = z.infer; declare const errorResponseSchema: z.ZodObject<{ error: z.ZodObject<{ code: z.ZodEnum<{ unauthorized: "unauthorized"; bad_request: "bad_request"; payment_required: "payment_required"; forbidden: "forbidden"; not_found: "not_found"; conflict: "conflict"; too_many_requests: "too_many_requests"; internal_server_error: "internal_server_error"; unprocessable_entity: "unprocessable_entity"; bad_gateway: "bad_gateway"; service_unavailable: "service_unavailable"; }>; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; type ErrorResponse = z.infer; declare function createApiError({ code, message, instance, requestId, extensions }: { code: ErrorCodes; message: string; instance?: string; requestId?: string; extensions?: Record; }): HTTPException; declare function handleApiError(error: unknown, requestId?: string): Promise; declare const errorSchemaFactory: (code: ErrorCodes, description: string) => { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; declare function isUniqueConstraintError(error: unknown): boolean; declare function throwIfUniqueConstraintError(error: unknown, message: string): void; declare const commonCreateErrorResponses: { readonly 400: { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; readonly 401: { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; readonly 403: { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; readonly 422: { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; readonly 500: { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; }; declare const commonUpdateErrorResponses: { readonly 400: { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; readonly 401: { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; readonly 403: { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; readonly 404: { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; readonly 422: { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; readonly 500: { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; }; declare const commonGetErrorResponses: { readonly 400: { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; readonly 401: { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; readonly 403: { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; readonly 404: { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; readonly 422: { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; readonly 500: { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; }; declare const commonDeleteErrorResponses: { readonly 400: { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; readonly 401: { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; readonly 403: { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; readonly 404: { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; readonly 422: { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; readonly 500: { description: string; content: { 'application/problem+json': { schema: z.ZodObject<{ instance: z.ZodOptional; requestId: z.ZodOptional; code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; detail: z.ZodString; title: z.ZodString; status: z.ZodNumber; error: z.ZodObject<{ code: z.ZodLiteral<"unauthorized" | "bad_request" | "payment_required" | "forbidden" | "not_found" | "conflict" | "too_many_requests" | "internal_server_error" | "unprocessable_entity" | "bad_gateway" | "service_unavailable">; message: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; }; }; }; }; type CommonCreateErrorResponses = typeof commonCreateErrorResponses; type CommonUpdateErrorResponses = typeof commonUpdateErrorResponses; type CommonGetErrorResponses = typeof commonGetErrorResponses; type CommonDeleteErrorResponses = typeof commonDeleteErrorResponses; //#endregion export { CommonCreateErrorResponses, CommonDeleteErrorResponses, CommonGetErrorResponses, CommonUpdateErrorResponses, ERROR_DOCS_BASE_URL, ErrorCode, ErrorCodes, ErrorResponse, ProblemDetails, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, createApiError, errorResponseSchema, errorSchemaFactory, getDatabaseErrorLogContext, handleApiError, isUniqueConstraintError, problemDetailsSchema, throwIfUniqueConstraintError };