import { RpcException } from "@nestjs/microservices"; import type { PubSubClientLike } from "./options.js"; import type { IncomingMessage } from "./types.js"; /** * Raised by a handler for a message that is schema-valid but will never be processable by *this* * consumer — a referential integrity failure, or a business rule that will never become true. * * Such a message must not burn its retry budget: behind an ordering key it blocks every subsequent * event for that entity until it clears. */ export declare class TerminalEventError extends RpcException { readonly reason: string; readonly detail?: Record; constructor(reason: string, detail?: Record); } /** * Recognises a terminal failure in either form: * - the `TerminalEventError` itself, when a handler is invoked directly * - the unwrapped payload, when the throw passed through Nest's exception filter */ export declare function asTerminalFailure(error: unknown): { reason: string; detail?: Record; } | null; /** Which pipeline stage rejected the message. */ export type DeadLetterStage = "envelope" | "decode" | "handler" | "unhandled"; export interface DeadLetterRequest { readonly message: IncomingMessage; readonly reason: string; readonly stage: DeadLetterStage; readonly subscription: string; readonly timestamp: Date; readonly detail?: Record; } /** * Publishes to an explicitly configured dead-letter topic. * * Deliberately not the subscription's own dead-letter policy: exhausting that means the consumer * slowly grinds through every retry first, which is far too slow for a message we already know is * terminal. */ export interface DeadLetterPublisher { publish(request: DeadLetterRequest): Promise; } /** Provenance attributes added alongside the original message's own. */ export declare const DEAD_LETTER_ATTRIBUTES: { readonly reason: "werken-dl-reason"; readonly sourceSubscription: "werken-dl-source-subscription"; readonly timestamp: "werken-dl-timestamp"; readonly stage: "werken-dl-stage"; /** JSON of the structured `detail` a TerminalEventError carried, when there was any. */ readonly detail: "werken-dl-detail"; /** The original ordering key, so redrive tooling can restore per-entity order. */ readonly orderingKey: "werken-dl-ordering-key"; /** * How many of the original's own attributes had to be dropped to fit Pub/Sub's 100-attribute * limit. Absent when none were — which is every ordinary message. */ readonly droppedAttributes: "werken-dl-dropped-attributes"; }; /** Publishes terminal messages to an explicitly configured Pub/Sub topic. */ export declare class PubSubDeadLetterPublisher implements DeadLetterPublisher { private readonly client; private readonly topic; /** * Resolved once, for the same reason `createEventPublisher` keeps one Topic per destination: * every `client.topic()` call returns a Topic with its own publisher and batch queue, so one per * message means the SDK's batching never engages and each publish pays full overhead. Dead-letter * volume is normally low, and the moment it is not is a poison-message storm — which is when this * path should not also be at its slowest. * * Lazy rather than built in the constructor: the transport constructs this during startup, and * resolving a topic is the client's work to do when it is actually needed. */ private resolved?; constructor(client: PubSubClientLike, topic: string); publish(request: DeadLetterRequest): Promise; } //# sourceMappingURL=dead-letter.d.ts.map