import { a as MessageCodec } from './codec-DpE_UP1B.cjs'; /** * Standard API response envelope for cross-system communication. * * Separates transport errors from application errors and carries * machine-readable codes with positional format arguments for * client-side localization. * * Wire format mirrors the Go `protowire/envelope` package: field tags * 1..N on each struct map to a binary protobuf wire format. The binary * codec lives in the `pb` module; this file defines the data shapes, * builders, and queries. */ declare class FieldError { field: string; code: string; message: string; args: string[]; constructor(field: string, code: string, message?: string, args?: string[]); } declare class AppError { code: string; message: string; args: string[]; details: FieldError[]; metadata: Record; constructor(code: string, message?: string, args?: string[]); withField(field: string, code: string, message?: string, ...args: string[]): this; withMeta(key: string, value: string): this; } declare class Envelope { status: number; transportError: string; data: Uint8Array; error: AppError | null; constructor(opts?: { status?: number; transportError?: string; data?: Uint8Array; error?: AppError | null; }); static ok(status: number, data: Uint8Array): Envelope; static err(status: number, code: string, message?: string, ...args: string[]): Envelope; static transportErr(message: string): Envelope; isOk(): boolean; isTransportError(): boolean; isAppError(): boolean; errorCode(): string; /** * Returns field errors indexed by field name, or null when there are none. * * Mirrors the Go API which returns nil for both "no app error" and * "app error has no details" — callers should treat null as empty. */ fieldErrors(): Record | null; } declare function newAppError(code: string, message?: string, ...args: string[]): AppError; /** * Binary protobuf codecs for Envelope/AppError/FieldError, driven by the * schema-free `pb` module. * * Field numbers and types match `proto/envelope/v1/envelope.proto` from the * canonical Go module. One wire-format caveat: `pb` encodes signed integer * fields with zigzag varint (proto3 `sint32` semantics), not plain varint * (proto3 `int32`). For non-negative values like HTTP status codes the bytes * are identical, so this matters only for negative integers — which the * envelope shape does not use. */ declare const FieldErrorPb: MessageCodec; declare const AppErrorPb: MessageCodec; declare const EnvelopePb: MessageCodec; type index_AppError = AppError; declare const index_AppError: typeof AppError; declare const index_AppErrorPb: typeof AppErrorPb; type index_Envelope = Envelope; declare const index_Envelope: typeof Envelope; declare const index_EnvelopePb: typeof EnvelopePb; type index_FieldError = FieldError; declare const index_FieldError: typeof FieldError; declare const index_FieldErrorPb: typeof FieldErrorPb; declare const index_newAppError: typeof newAppError; declare namespace index { export { index_AppError as AppError, index_AppErrorPb as AppErrorPb, index_Envelope as Envelope, index_EnvelopePb as EnvelopePb, index_FieldError as FieldError, index_FieldErrorPb as FieldErrorPb, index_newAppError as newAppError }; } export { AppError as A, Envelope as E, FieldError as F, AppErrorPb as a, EnvelopePb as b, FieldErrorPb as c, index as i, newAppError as n };