@aws-sdk/lib-sqs 0.0.0-stage → 3.1158.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,92 @@
1
+ import type { PollerConfig, PollerStats, SerializablePollerStats, SQSPollerEvents, SQSPollerEventName, PollerMessage } from "./types";
2
+ /**
3
+ * Managed long-polling loop for SQS queues with auto-delete, backoff,
4
+ * visibility heartbeat, and graceful shutdown.
5
+ *
6
+ * Two consumption models (mutually exclusive):
7
+ * 1. Event-based: `poller.on("message", handler); poller.start();`
8
+ * 2. Async iteration: `for await (const msg of poller) { ... }`
9
+ *
10
+ * In async iteration, each message is auto-deleted when the loop advances. Exiting
11
+ * early (`break`, `return`, or a throw) leaves the current message undeleted; call
12
+ * `msg.enqueueDelete()` first if it was processed.
13
+ *
14
+ * @public
15
+ */
16
+ export declare class SQSPoller implements AsyncIterable<PollerMessage> {
17
+ private readonly _client;
18
+ private readonly _config;
19
+ private readonly _stats;
20
+ private _run;
21
+ private readonly _externalSignal?;
22
+ private _deleteBatch;
23
+ private _deleteTimer;
24
+ private _pendingFlushes;
25
+ private readonly _heartbeatTimers;
26
+ private readonly _heartbeatsInFlight;
27
+ private readonly _listeners;
28
+ constructor(config: PollerConfig);
29
+ get running(): boolean;
30
+ get inFlight(): number;
31
+ getStats(): Readonly<PollerStats>;
32
+ toJSON(): SerializablePollerStats;
33
+ toString(): string;
34
+ /** Register a listener. Returns a function that removes it. */
35
+ on<K extends SQSPollerEventName>(event: K, listener: SQSPollerEvents[K]): () => void;
36
+ /** Remove a listener, or all listeners for an event if `listener` is omitted. */
37
+ off<K extends SQSPollerEventName>(event: K, listener?: SQSPollerEvents[K]): this;
38
+ /** Start polling. Non-blocking. */
39
+ start(): void;
40
+ /**
41
+ * Stop polling, and resolve once this run has shut down.
42
+ *
43
+ * @param graceful - When `true`, waits up to `shutdownTimeoutMs` for in-flight work (handlers
44
+ * in event mode, or the current loop body in async iteration), then flushes pending deletes.
45
+ * When `false`, stops without waiting; calling it during a graceful shutdown cuts that short.
46
+ * Don't `await` this from inside a `message` handler or a `for await` body, since shutdown
47
+ * waits for that work to finish. Use `void poller.stop()`, or `break`, instead.
48
+ * @returns The final stats. Does nothing if the poller isn't running.
49
+ */
50
+ stop(graceful?: boolean): Promise<PollerStats>;
51
+ /**
52
+ * Exiting the loop early (`break`, `return`, or a throw) does not auto-delete the
53
+ * current message, since the three are indistinguishable here. Call
54
+ * `msg.enqueueDelete()` before exiting if the message was processed.
55
+ */
56
+ [Symbol.asyncIterator](): AsyncGenerator<PollerMessage, void, undefined>;
57
+ private _iterate;
58
+ private _assertCanStart;
59
+ /** A run started while the previous one is still shutting down waits for it to finish. */
60
+ private _beginRun;
61
+ private _teardown;
62
+ /** Resolves with how `work` ended: finished, timed out after shutdownTimeoutMs, or cut short by stop(false). */
63
+ private _waitFor;
64
+ private _waitForDrain;
65
+ private _emitShutdownTimeout;
66
+ private _pollLoop;
67
+ private _processMessage;
68
+ /** Returns false if `beforeRequest` threw or rejected, which stops the run. */
69
+ private _runBeforeRequest;
70
+ /** Returns true if the idle timeout was reached, which stops the run. */
71
+ private _handleEmpty;
72
+ private _handlePollError;
73
+ private _recordReceived;
74
+ private _receiveMessages;
75
+ private _enqueueDelete;
76
+ private _flushDeleteBatch;
77
+ private _trackFlush;
78
+ private _awaitPendingFlushes;
79
+ private _startHeartbeat;
80
+ /** Resolves once any extension request already in flight for this message settles. */
81
+ private _stopHeartbeat;
82
+ /** Stops this run's heartbeats only, and waits out their in-flight extensions so none land after `stopped`. */
83
+ private _stopHeartbeats;
84
+ private _wrapMessage;
85
+ private _isAborted;
86
+ private _checkIdleTimeout;
87
+ private _effectiveIdlePollInterval;
88
+ private _backoff;
89
+ private _delay;
90
+ private _emit;
91
+ private _emitAsync;
92
+ }
@@ -0,0 +1,45 @@
1
+ import type { BatchResultErrorEntry } from "@aws-sdk/client-sqs";
2
+ /**
3
+ * Base error class for all poller errors.
4
+ * @public
5
+ */
6
+ export declare class PollerError extends Error {
7
+ readonly name: string;
8
+ constructor(message: string, options?: {
9
+ cause?: Error;
10
+ });
11
+ }
12
+ /**
13
+ * Thrown when a poller operation exceeds its time limit.
14
+ * @public
15
+ */
16
+ export declare class TimeoutError extends PollerError {
17
+ readonly name: string;
18
+ readonly timeoutMs: number;
19
+ constructor(message: string, timeoutMs: number, options?: {
20
+ cause?: Error;
21
+ });
22
+ }
23
+ /**
24
+ * Thrown when `DeleteMessageBatch` reports failures.
25
+ * @public
26
+ */
27
+ export declare class DeleteError extends PollerError {
28
+ readonly name: string;
29
+ readonly failures: BatchResultErrorEntry[];
30
+ readonly messageIds: string[];
31
+ constructor(message: string, failures: BatchResultErrorEntry[], messageIds?: string[], options?: {
32
+ cause?: Error;
33
+ });
34
+ }
35
+ /**
36
+ * Thrown when extending a message's visibility timeout fails.
37
+ * @public
38
+ */
39
+ export declare class VisibilityExtensionError extends PollerError {
40
+ readonly name: string;
41
+ readonly messageId: string;
42
+ constructor(message: string, messageId: string, options?: {
43
+ cause?: Error;
44
+ });
45
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * SQS message poller with auto-delete, backoff, and graceful shutdown.
3
+ *
4
+ * @example Event-based
5
+ * ```typescript
6
+ * const poller = new SQSPoller({ queueUrl: "https://sqs.us-east-1.amazonaws.com/1/q" });
7
+ * const unsub = poller.on("message", async (msg) => console.log(msg.body));
8
+ * poller.on("error", (err) => console.error(err));
9
+ * poller.start();
10
+ * ```
11
+ *
12
+ * @example Async iteration
13
+ * ```typescript
14
+ * for await (const msg of poller) {
15
+ * console.log(msg.body);
16
+ * if (msg.body === "last") {
17
+ * msg.enqueueDelete(); // exiting early skips auto-delete for this message
18
+ * break;
19
+ * }
20
+ * }
21
+ * ```
22
+ *
23
+ * @packageDocumentation
24
+ */
25
+ export { SQSPoller } from "./SQSPoller";
26
+ export { Message } from "./Message";
27
+ export { PollerError, DeleteError, TimeoutError, VisibilityExtensionError } from "./errors";
28
+ export type { PollerConfig, PollerStats, SerializablePollerStats, SQSPollerEvents, SQSPollerEventName, PollerMessage, } from "./types";
@@ -0,0 +1,29 @@
1
+ import {
2
+ Message as SQSMessage,
3
+ MessageAttributeValue,
4
+ MessageSystemAttributeName,
5
+ } from "@aws-sdk/client-sqs";
6
+ import { PollerMessage } from "./types";
7
+ export interface MessageCallbacks {
8
+ enqueueDelete: (msg: Message) => void;
9
+ keep: (receiptHandle: string) => void;
10
+ release: (receiptHandle: string) => Promise<void>;
11
+ changeVisibility: (receiptHandle: string, timeoutMs: number) => Promise<void>;
12
+ }
13
+ export declare class Message implements PollerMessage {
14
+ readonly raw: SQSMessage;
15
+ readonly body: string | undefined;
16
+ readonly messageId: string;
17
+ readonly receiptHandle: string;
18
+ readonly attributes: Partial<Record<MessageSystemAttributeName, string>>;
19
+ readonly messageAttributes: Record<string, MessageAttributeValue>;
20
+ readonly receivedAt: Date;
21
+ private readonly _callbacks;
22
+ private _handled;
23
+ constructor(raw: SQSMessage, callbacks: MessageCallbacks);
24
+ readonly handled: boolean;
25
+ enqueueDelete(): void;
26
+ keep(): void;
27
+ release(): Promise<void>;
28
+ changeVisibility(timeoutMs: number): Promise<void>;
29
+ }
@@ -0,0 +1,61 @@
1
+ import {
2
+ PollerConfig,
3
+ PollerStats,
4
+ SerializablePollerStats,
5
+ SQSPollerEvents,
6
+ SQSPollerEventName,
7
+ PollerMessage,
8
+ } from "./types";
9
+ export declare class SQSPoller implements AsyncIterable<PollerMessage> {
10
+ private readonly _client;
11
+ private readonly _config;
12
+ private readonly _stats;
13
+ private _run;
14
+ private readonly _externalSignal?;
15
+ private _deleteBatch;
16
+ private _deleteTimer;
17
+ private _pendingFlushes;
18
+ private readonly _heartbeatTimers;
19
+ private readonly _heartbeatsInFlight;
20
+ private readonly _listeners;
21
+ constructor(config: PollerConfig);
22
+ readonly running: boolean;
23
+ readonly inFlight: number;
24
+ getStats(): Readonly<PollerStats>;
25
+ toJSON(): SerializablePollerStats;
26
+ toString(): string;
27
+ on<K extends SQSPollerEventName>(event: K, listener: SQSPollerEvents[K]): () => void;
28
+ off<K extends SQSPollerEventName>(event: K, listener?: SQSPollerEvents[K]): this;
29
+ start(): void;
30
+ stop(graceful?: boolean): Promise<PollerStats>;
31
+ [Symbol.asyncIterator](): AsyncGenerator<PollerMessage, void, undefined>;
32
+ private _iterate;
33
+ private _assertCanStart;
34
+ private _beginRun;
35
+ private _teardown;
36
+ private _waitFor;
37
+ private _waitForDrain;
38
+ private _emitShutdownTimeout;
39
+ private _pollLoop;
40
+ private _processMessage;
41
+ private _runBeforeRequest;
42
+ private _handleEmpty;
43
+ private _handlePollError;
44
+ private _recordReceived;
45
+ private _receiveMessages;
46
+ private _enqueueDelete;
47
+ private _flushDeleteBatch;
48
+ private _trackFlush;
49
+ private _awaitPendingFlushes;
50
+ private _startHeartbeat;
51
+ private _stopHeartbeat;
52
+ private _stopHeartbeats;
53
+ private _wrapMessage;
54
+ private _isAborted;
55
+ private _checkIdleTimeout;
56
+ private _effectiveIdlePollInterval;
57
+ private _backoff;
58
+ private _delay;
59
+ private _emit;
60
+ private _emitAsync;
61
+ }
@@ -0,0 +1,45 @@
1
+ import { BatchResultErrorEntry } from "@aws-sdk/client-sqs";
2
+ export declare class PollerError extends Error {
3
+ readonly name: string;
4
+ constructor(
5
+ message: string,
6
+ options?: {
7
+ cause?: Error;
8
+ },
9
+ );
10
+ }
11
+ export declare class TimeoutError extends PollerError {
12
+ readonly name: string;
13
+ readonly timeoutMs: number;
14
+ constructor(
15
+ message: string,
16
+ timeoutMs: number,
17
+ options?: {
18
+ cause?: Error;
19
+ },
20
+ );
21
+ }
22
+ export declare class DeleteError extends PollerError {
23
+ readonly name: string;
24
+ readonly failures: BatchResultErrorEntry[];
25
+ readonly messageIds: string[];
26
+ constructor(
27
+ message: string,
28
+ failures: BatchResultErrorEntry[],
29
+ messageIds?: string[],
30
+ options?: {
31
+ cause?: Error;
32
+ },
33
+ );
34
+ }
35
+ export declare class VisibilityExtensionError extends PollerError {
36
+ readonly name: string;
37
+ readonly messageId: string;
38
+ constructor(
39
+ message: string,
40
+ messageId: string,
41
+ options?: {
42
+ cause?: Error;
43
+ },
44
+ );
45
+ }
@@ -0,0 +1,11 @@
1
+ export { SQSPoller } from "./SQSPoller";
2
+ export { Message } from "./Message";
3
+ export { PollerError, DeleteError, TimeoutError, VisibilityExtensionError } from "./errors";
4
+ export {
5
+ PollerConfig,
6
+ PollerStats,
7
+ SerializablePollerStats,
8
+ SQSPollerEvents,
9
+ SQSPollerEventName,
10
+ PollerMessage,
11
+ } from "./types";
@@ -0,0 +1,83 @@
1
+ import {
2
+ SQSClient,
3
+ SQSClientConfig,
4
+ Message as SQSMessage,
5
+ MessageAttributeValue,
6
+ MessageSystemAttributeName,
7
+ BatchResultErrorEntry,
8
+ } from "@aws-sdk/client-sqs";
9
+ export {
10
+ SQSClient,
11
+ SQSClientConfig,
12
+ SQSMessage,
13
+ MessageAttributeValue,
14
+ MessageSystemAttributeName,
15
+ BatchResultErrorEntry,
16
+ };
17
+ export interface PollerConfig {
18
+ queueUrl: string;
19
+ client?: SQSClient;
20
+ clientConfig?: SQSClientConfig;
21
+ receiveWaitTimeMs?: number;
22
+ receiveBatchSize?: number;
23
+ activePollIntervalMs?: number;
24
+ idlePollIntervalMs?: number;
25
+ idleTimeoutMs?: number;
26
+ maxConcurrency?: number;
27
+ visibilityTimeoutMs?: number;
28
+ extendTimeout?: boolean;
29
+ extendTimeoutAdvanceMs?: number;
30
+ maxTimeoutExtensionMs?: number;
31
+ deleteMessages?: boolean;
32
+ deleteBatchSize?: number;
33
+ deleteWaitMs?: number;
34
+ systemAttributeNames?: MessageSystemAttributeName[];
35
+ messageAttributeNames?: string[];
36
+ backoffMs?: number;
37
+ maxBackoffMs?: number;
38
+ abortSignal?: AbortSignal;
39
+ shutdownTimeoutMs?: number;
40
+ beforeRequest?: (stats: PollerStats) => void | Promise<void>;
41
+ }
42
+ export interface PollerStats {
43
+ requestCount: number;
44
+ receivedMessageCount: number;
45
+ deletedMessageCount: number;
46
+ errorCount: number;
47
+ lastMessageReceivedAt: Date | null;
48
+ pollingStartedAt: Date | null;
49
+ pollingStoppedAt: Date | null;
50
+ }
51
+ export interface SerializablePollerStats {
52
+ requestCount: number;
53
+ receivedMessageCount: number;
54
+ deletedMessageCount: number;
55
+ errorCount: number;
56
+ lastMessageReceivedAt: string | null;
57
+ pollingStartedAt: string | null;
58
+ pollingStoppedAt: string | null;
59
+ pollingDurationMs: number;
60
+ }
61
+ export interface SQSPollerEvents {
62
+ message: (message: PollerMessage) => void | Promise<void>;
63
+ empty: () => void;
64
+ idle: () => void;
65
+ stopped: (stats: PollerStats) => void;
66
+ error: (error: Error) => void;
67
+ timeoutExtended: (message: PollerMessage) => void;
68
+ heartbeatExpired: (message: PollerMessage) => void;
69
+ }
70
+ export type SQSPollerEventName = keyof SQSPollerEvents;
71
+ export interface PollerMessage {
72
+ readonly raw: SQSMessage;
73
+ readonly body: string | undefined;
74
+ readonly messageId: string;
75
+ readonly receiptHandle: string;
76
+ readonly attributes: Partial<Record<MessageSystemAttributeName, string>>;
77
+ readonly messageAttributes: Record<string, MessageAttributeValue>;
78
+ readonly receivedAt: Date;
79
+ enqueueDelete(): void;
80
+ keep(): void;
81
+ release(): Promise<void>;
82
+ changeVisibility(timeoutMs: number): Promise<void>;
83
+ }
@@ -0,0 +1,236 @@
1
+ /**
2
+ * Timing options are milliseconds with an `Ms` suffix; the poller converts to
3
+ * seconds when calling SQS.
4
+ */
5
+ import type { SQSClient, SQSClientConfig, Message as SQSMessage, MessageAttributeValue, MessageSystemAttributeName, BatchResultErrorEntry } from "@aws-sdk/client-sqs";
6
+ export type { SQSClient, SQSClientConfig, SQSMessage, MessageAttributeValue, MessageSystemAttributeName, BatchResultErrorEntry, };
7
+ /**
8
+ * Config options for {@link SQSPoller}.
9
+ * @public
10
+ */
11
+ export interface PollerConfig {
12
+ /**
13
+ * The URL of the SQS queue to poll.
14
+ * @example "https://sqs.us-east-1.amazonaws.com/123456789/my-queue"
15
+ */
16
+ queueUrl: string;
17
+ /**
18
+ * Pre-configured SQS client instance.
19
+ * If provided, `clientConfig` is ignored.
20
+ */
21
+ client?: SQSClient;
22
+ /**
23
+ * Config forwarded to a new `SQSClient` when `client` is not provided.
24
+ * Uses the standard `SQSClientConfig` from `@aws-sdk/client-sqs`.
25
+ */
26
+ clientConfig?: SQSClientConfig;
27
+ /**
28
+ * Long-poll wait time (0–20_000).
29
+ * Converted to whole seconds for the SQS `ReceiveMessage` API.
30
+ * Use 0 for short polling (not recommended).
31
+ * @defaultValue 20_000
32
+ */
33
+ receiveWaitTimeMs?: number;
34
+ /**
35
+ * Messages to request per `ReceiveMessage` call (1–10).
36
+ * @defaultValue 10
37
+ */
38
+ receiveBatchSize?: number;
39
+ /**
40
+ * Extra delay between polls when the previous poll returned messages.
41
+ * 0 means the next poll starts immediately.
42
+ * @defaultValue 0
43
+ */
44
+ activePollIntervalMs?: number;
45
+ /**
46
+ * Extra delay between polls when the previous poll returned no messages.
47
+ * @defaultValue 0
48
+ */
49
+ idlePollIntervalMs?: number;
50
+ /**
51
+ * Stop polling after this long without receiving a message.
52
+ * `undefined` polls indefinitely.
53
+ * @defaultValue undefined
54
+ */
55
+ idleTimeoutMs?: number;
56
+ /**
57
+ * Max messages processed concurrently.
58
+ * The poller pauses `ReceiveMessage` calls when this limit is reached
59
+ * and resumes when in-flight count drops below it.
60
+ * @defaultValue 10
61
+ */
62
+ maxConcurrency?: number;
63
+ /**
64
+ * Visibility timeout override, rounded up to whole seconds for SQS.
65
+ * When omitted, the queue's default `VisibilityTimeout` applies.
66
+ */
67
+ visibilityTimeoutMs?: number;
68
+ /**
69
+ * Auto-extend the visibility timeout while a message is being processed.
70
+ * The call is made `extendTimeoutAdvanceMs` before the current timeout expires.
71
+ * @defaultValue false
72
+ */
73
+ extendTimeout?: boolean;
74
+ /**
75
+ * How far ahead of expiry to make the extension call.
76
+ * Only used when `extendTimeout` is `true`.
77
+ * @defaultValue 5_000
78
+ */
79
+ extendTimeoutAdvanceMs?: number;
80
+ /**
81
+ * Max total time to keep extending the visibility timeout.
82
+ * After this the poller stops extending.
83
+ * Only used when `extendTimeout` is `true`.
84
+ * @defaultValue 43_200_000 (12 hours)
85
+ */
86
+ maxTimeoutExtensionMs?: number;
87
+ /**
88
+ * When `true` (default), messages are deleted automatically after the
89
+ * `message` handler resolves. Set to `false` for manual deletion via
90
+ * `message.enqueueDelete()`.
91
+ * @defaultValue true
92
+ */
93
+ deleteMessages?: boolean;
94
+ /**
95
+ * Batch size for `DeleteMessageBatch` calls (1–10).
96
+ * @defaultValue 10
97
+ */
98
+ deleteBatchSize?: number;
99
+ /**
100
+ * Max wait for a delete batch to fill before flushing.
101
+ * Lower reduces latency; higher improves batching.
102
+ * @defaultValue 2_000
103
+ */
104
+ deleteWaitMs?: number;
105
+ /**
106
+ * System attribute names to request with each message.
107
+ * @defaultValue []
108
+ * @example ["All"] or ["ApproximateReceiveCount", "SentTimestamp"]
109
+ */
110
+ systemAttributeNames?: MessageSystemAttributeName[];
111
+ /**
112
+ * Custom message attribute names to request.
113
+ * @defaultValue []
114
+ * @example ["All"] or ["myAttribute.*"]
115
+ */
116
+ messageAttributeNames?: string[];
117
+ /**
118
+ * Initial backoff delay after a `ReceiveMessage` error.
119
+ * Doubles on consecutive errors up to `maxBackoffMs`.
120
+ * @defaultValue 1_000
121
+ */
122
+ backoffMs?: number;
123
+ /**
124
+ * Max backoff ceiling.
125
+ * @defaultValue 30_000
126
+ */
127
+ maxBackoffMs?: number;
128
+ /**
129
+ * `AbortSignal` for graceful shutdown. When aborted the poller
130
+ * finishes in-flight handlers, flushes pending deletes, then stops.
131
+ */
132
+ abortSignal?: AbortSignal;
133
+ /**
134
+ * Max wait for in-flight messages to complete during shutdown.
135
+ * @defaultValue 30_000
136
+ */
137
+ shutdownTimeoutMs?: number;
138
+ /**
139
+ * Callback invoked before each `ReceiveMessage` call. May be async.
140
+ * Throwing (or rejecting) stops the polling loop and emits the error via the
141
+ * `error` event. The poller will not make another request.
142
+ */
143
+ beforeRequest?: (stats: PollerStats) => void | Promise<void>;
144
+ }
145
+ /**
146
+ * Live stats tracked by the poller.
147
+ * @public
148
+ */
149
+ export interface PollerStats {
150
+ /** Total `ReceiveMessage` requests sent. */
151
+ requestCount: number;
152
+ /** Total messages received. */
153
+ receivedMessageCount: number;
154
+ /** Total messages successfully deleted. */
155
+ deletedMessageCount: number;
156
+ /** Total errors encountered (receive, delete, extend). */
157
+ errorCount: number;
158
+ /** Timestamp of last received message, or `null`. */
159
+ lastMessageReceivedAt: Date | null;
160
+ /** Timestamp when `start()` was called. */
161
+ pollingStartedAt: Date | null;
162
+ /** Timestamp when the poller stopped, or `null` if still running. */
163
+ pollingStoppedAt: Date | null;
164
+ }
165
+ /**
166
+ * JSON-serializable snapshot of {@link PollerStats}.
167
+ * Dates are converted to ISO-8601 strings.
168
+ * @public
169
+ */
170
+ export interface SerializablePollerStats {
171
+ requestCount: number;
172
+ receivedMessageCount: number;
173
+ deletedMessageCount: number;
174
+ errorCount: number;
175
+ lastMessageReceivedAt: string | null;
176
+ pollingStartedAt: string | null;
177
+ pollingStoppedAt: string | null;
178
+ pollingDurationMs: number;
179
+ }
180
+ /**
181
+ * Events emitted by {@link SQSPoller}.
182
+ * @public
183
+ */
184
+ export interface SQSPollerEvents {
185
+ /** A message was received. */
186
+ message: (message: PollerMessage) => void | Promise<void>;
187
+ /** The last `ReceiveMessage` returned no messages. */
188
+ empty: () => void;
189
+ /** The poller stopped due to `idleTimeoutMs` expiring. */
190
+ idle: () => void;
191
+ /** The poller finished shutting down. Fires once per run, however it stopped. */
192
+ stopped: (stats: PollerStats) => void;
193
+ /** A non-fatal error occurred (receive, delete, extend). */
194
+ error: (error: Error) => void;
195
+ /** A message's visibility timeout was extended. */
196
+ timeoutExtended: (message: PollerMessage) => void;
197
+ /** A message's heartbeat expired after `maxTimeoutExtensionMs`. The message may become visible to other consumers. */
198
+ heartbeatExpired: (message: PollerMessage) => void;
199
+ }
200
+ /**
201
+ * Event name literals for {@link SQSPollerEvents}.
202
+ * @public
203
+ */
204
+ export type SQSPollerEventName = keyof SQSPollerEvents;
205
+ /**
206
+ * A received SQS message with convenience methods.
207
+ *
208
+ * This interface describes the public surface. The concrete class
209
+ * is in `./Message.ts`.
210
+ *
211
+ * @public
212
+ */
213
+ export interface PollerMessage {
214
+ /** Raw SQS `Message` object. */
215
+ readonly raw: SQSMessage;
216
+ /** Message body string. */
217
+ readonly body: string | undefined;
218
+ /** Unique message ID. */
219
+ readonly messageId: string;
220
+ /** Receipt handle for delete / visibility operations. */
221
+ readonly receiptHandle: string;
222
+ /** System attributes (e.g. `ApproximateReceiveCount`). */
223
+ readonly attributes: Partial<Record<MessageSystemAttributeName, string>>;
224
+ /** Custom message attributes. */
225
+ readonly messageAttributes: Record<string, MessageAttributeValue>;
226
+ /** Timestamp when the poller received this message. */
227
+ readonly receivedAt: Date;
228
+ /** Queue this message for batch deletion. */
229
+ enqueueDelete(): void;
230
+ /** Acknowledge the message without deleting it. */
231
+ keep(): void;
232
+ /** Release the message back to the queue immediately (visibility → 0). */
233
+ release(): Promise<void>;
234
+ /** Change the visibility timeout of this message. */
235
+ changeVisibility(timeoutMs: number): Promise<void>;
236
+ }