import { ElevaError, ElevaErrorArgs, ElevaErrorJSON } from './errors'; import { ErrorCode } from './catalog'; /** * Context about the outgoing call that triggered a remote error. All fields are optional. * `M` types the transport-level `metadata` (e.g. `Record` for HTTP headers). */ export type RemoteRequest = Record> = { /** Operation type or name (e.g. HTTP method, gRPC method, message type). */ operation?: string; /** Target resource identifier (e.g. URL path, topic name, procedure). */ resource?: string; /** Transport-level metadata sent with the call (e.g. HTTP headers, gRPC metadata). */ metadata?: M; /** Data sent with the call (request body, message payload, etc.). */ payload?: unknown; }; /** * Context about the response received from a remote call. All fields are optional. * `M` types the transport-level `metadata` (e.g. `Record` for HTTP headers). */ export type RemoteResponse = Record> = { /** Status code returned by the remote system (e.g. HTTP status, gRPC status). */ statusCode?: number; /** Transport-level metadata received with the response (e.g. HTTP response headers). */ metadata?: M; /** Data received from the remote system. */ payload?: unknown; }; /** `ElevaErrorJSON` extended with the originating remote call context. */ export type RemoteElevaErrorJSON = Record, ResM extends Record = Record> = ElevaErrorJSON & { request: RemoteRequest; response: RemoteResponse; }; /** * An `ElevaError` enriched with the context of a failed remote call. * Not tied to HTTP — covers any outbound call (HTTP, gRPC, message queues, etc.) * where capturing the outgoing request and incoming response aids debugging. * * `ReqM` / `ResM` type the transport metadata for the request and response respectively; * both default to `Record` for untyped usage. * * @example * type HttpHeaders = Record * const err = RemoteElevaError.from(body, req, res) * err.request.metadata?.['authorization'] // string */ export declare class RemoteElevaError = Record, ResM extends Record = Record> extends ElevaError { /** Context about the outgoing call that produced this error. */ readonly request: RemoteRequest; /** Context about the response that contained or triggered the error. */ readonly response: RemoteResponse; constructor(args: ElevaErrorArgs & { request: RemoteRequest; response: RemoteResponse; }); /** Full serialisation including remote call request and response context. */ toJSON(): RemoteElevaErrorJSON; /** Narrows to `RemoteElevaError`, preserving metadata types on the narrowed type. */ is(code: K | string): this is RemoteElevaError; /** * Builds a `RemoteElevaError` from a raw response payload and remote call context. * Delegates payload parsing to `ElevaError._parsePayload()`; malformed payloads become `INTERNAL_SERVER_ERROR`. * `cause` takes precedence over any cause inferred from the payload. */ static from = Record, ResM extends Record = Record>(body: unknown, request: RemoteRequest, response: RemoteResponse, cause?: unknown): RemoteElevaError; } //# sourceMappingURL=errors_remote.d.ts.map