import type { Either } from '@lokalise/node-core'; import { z } from 'zod/v4'; import { AbstractPubSubConsumer, type PubSubConsumerDependencies, type PubSubConsumerOptions } from './AbstractPubSubConsumer.ts'; import type { PubSubCreationConfig, PubSubQueueLocatorType } from './AbstractPubSubService.ts'; /** * Message type used for DLQ consumers. All DLQ messages are treated as this type. */ export declare const DLQ_MESSAGE_TYPE = "dlq.message"; /** * Base schema for DLQ messages. * Uses passthrough() to accept any message structure while ensuring basic fields exist. * The 'id' field is required for handler spy functionality. */ export declare const DLQ_MESSAGE_SCHEMA: z.ZodObject<{ id: z.ZodString; }, z.core.$loose>; export type DlqMessage = z.infer; /** * Handler function type for processing DLQ messages. */ export type DlqMessageHandler = (message: DlqMessage, context: ExecutionContext) => Promise>; /** * Options for AbstractPubSubDlqConsumer. * Omits messageTypeResolver and handlers since DLQ consumers handle all message types uniformly. */ export type PubSubDlqConsumerOptions = Omit, 'messageTypeResolver' | 'handlers'> & { /** * Handler function to process DLQ messages. * Receives the raw message payload with passthrough fields. */ handler: DlqMessageHandler; }; /** * Abstract base class for Dead Letter Queue (DLQ) consumers. * * This class is specifically designed for consuming messages from a DLQ topic. * Unlike regular consumers that route messages by type, DLQ consumers accept * any message structure since DLQ messages can come from various failed processing scenarios. * * Key differences from AbstractPubSubConsumer: * - Does NOT use messageTypeResolver routing (accepts all message types) * - Uses a passthrough schema that accepts any message with an 'id' field * - Simplified handler configuration (single handler for all messages) * * @example * ```typescript * class MyDlqConsumer extends AbstractPubSubDlqConsumer { * constructor(dependencies: PubSubConsumerDependencies) { * super( * dependencies, * { * creationConfig: { * topic: { name: 'my-dlq-topic' }, * subscription: { name: 'my-dlq-subscription' }, * }, * handler: async (message, context) => { * console.log('DLQ message received:', message) * // Process or log the dead letter message * return { result: 'success' } * }, * }, * myExecutionContext, * ) * } * } * ``` */ export declare abstract class AbstractPubSubDlqConsumer, CreationConfigType extends PubSubCreationConfig = PubSubCreationConfig, QueueLocatorType extends PubSubQueueLocatorType = PubSubQueueLocatorType> extends AbstractPubSubConsumer { constructor(dependencies: PubSubConsumerDependencies, options: PubSubDlqConsumerOptions, executionContext: ExecutionContext); }