import type { QueueHandlerSpec, QueueSpec } from "./internal/service-spec.js"; import { DurationSchedule } from "./schedule.js"; import type { ServiceContext } from "./service.js"; export declare const DEFAULT_QUEUE_VISIBILITY_TIMEOUT: { type: "Duration"; dur: number; unit: "second" | "seconds" | "minute" | "minutes" | "hour" | "hours" | "day" | "days" | "year" | "years"; }; /** * Context passed to the handler. */ export interface QueueHandlerContext { /** * Information about the queue. */ queue: { queueName: string; fifo: boolean; }; /** * Information about the containing service. */ service: ServiceContext; } export interface FifoQueueHandlerMessageItem extends StandardQueueHandlerMessageItem { messageGroupId: string; sequenceNumber: string; messageDeduplicationId: string; } export interface StandardQueueHandlerMessageItem { id: string; receiptHandle: string; message: Message; sent: Date; receiveCount: number; } export interface QueueBatchHandlerFunctionBase = StandardQueueHandlerMessageItem> { /** * Provides the keys, new value */ (items: MessageItem[], context: QueueHandlerContext): Promise | void | { failedMessageIds?: string[]; }; } export type QueueBatchHandlerFunction = Fifo extends true ? FifoQueueBatchHandlerFunction : StandardQueueBatchHandlerFunction; export type StandardQueueBatchHandlerFunction = QueueBatchHandlerFunctionBase>; export type FifoQueueBatchHandlerFunction = QueueBatchHandlerFunctionBase>; export type QueueBatchHandler> = QueueHandlerSpec & { handler: Handler; }; export interface StandardQueueSendMessageOptions { delay?: DurationSchedule; } export type QueueSendMessageOptions = FifoQueueSendMessageOptions | StandardQueueSendMessageOptions; export interface FifoQueueSendMessageOptions extends StandardQueueSendMessageOptions { group?: string; dedupeId?: string; } export interface QueueSendMessageBatchEntry { /** * ID of the message. Will be returned if the message fails to send. */ id: string; message: Message; options?: Options; } export interface QueueBatchResponse { failed?: { id: string; message?: string; }[]; } export interface QueueDeleteBatchEntry { id: string; receiptHandle: string; } interface QueueBase extends Omit, "handler" | "message"> { kind: "Queue"; fifo: boolean; changeMessageVisibility(receiptHandle: string, timeout: DurationSchedule): Promise; deleteMessage(receiptHandle: string): Promise; deleteMessageBatch(entries: QueueDeleteBatchEntry[]): Promise; } export interface StandardQueue extends QueueBase { fifo: false; handler: QueueBatchHandler>; sendMessage(message: Message, options?: StandardQueueSendMessageOptions): Promise; sendMessageBatch(entries: QueueSendMessageBatchEntry[]): Promise; } export interface FifoQueue extends QueueBase { fifo: true; handler: QueueBatchHandler>; groupBy?: FifoQueueMessagePropertyReference; dedupe?: FifoQueueMessagePropertyReference | FifoContentBasedDeduplication; sendMessage(message: Message, options?: FifoQueueSendMessageOptions): Promise; sendMessageBatch(entries: QueueSendMessageBatchEntry[]): Promise; } export declare function isFifoQueue(queue: Queue): queue is FifoQueue; export type Queue = FifoQueue | StandardQueue; export type MessageIdField = { [K in keyof Message]: K extends string ? Message[K] extends string ? K : never : never; }[keyof Message]; export type FifoQueueMessagePropertyReference = MessageIdField | ((message: Message) => string); interface QueueOptionsBase { /** * Amount of time to delay the delivery of messages in the queue to consumers. * * @default 0 seconds */ delay?: DurationSchedule; /** * When true, the contents of the messages are encrypted server side with a managed key. * * @default true */ encryption?: boolean; fifo?: Fifo; handlerOptions?: QueueHandlerSpec; /** * The default visibility timeout for messages in the queue. * * @default Schedule.duration(30, "seconds") */ visibilityTimeout?: DurationSchedule; } export type QueueOptions = FifoQueueOptions | QueueOptionsBase; export interface FifoQueueOptions extends QueueOptionsBase { fifo: true; groupBy?: FifoQueueMessagePropertyReference; dedupe?: FifoQueueMessagePropertyReference | FifoContentBasedDeduplication; } export declare function queue(...args: [ name: Name, options: FifoQueueOptions, handler: FifoQueueBatchHandlerFunction ]): FifoQueue; export declare function queue(...args: [ name: Name, options: QueueOptions, handler: StandardQueueBatchHandlerFunction ]): StandardQueue; /** * Assertion that content based deduplication is on. * * Can be overridden when calling `sendMessage`. */ export interface FifoContentBasedDeduplication { contentBasedDeduplication: true; } export declare function isFifoContentBasedDeduplication(value: any): value is FifoContentBasedDeduplication; export {}; //# sourceMappingURL=queue.d.ts.map