sqs-consumer 10.2.0 → 10.2.1
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.
- package/.github/DISCUSSION_TEMPLATE/help.yml +1 -1
- package/.github/ISSUE_TEMPLATE/bug-report.yml +1 -1
- package/CHANGELOG.md +6 -6
- package/dist/cjs/consumer.d.ts +137 -0
- package/dist/cjs/emitter.d.ts +22 -0
- package/dist/esm/errors.d.ts +44 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/logger.d.ts +3 -0
- package/dist/esm/types.d.ts +279 -0
- package/dist/esm/validation.d.ts +16 -0
- package/package.json +10 -6
- package/tsconfig.cjs.json +2 -1
- package/tsconfig.esm.json +2 -1
- package/tsconfig.json +1 -2
- /package/dist/{types → cjs}/errors.d.ts +0 -0
- /package/dist/{types → cjs}/index.d.ts +0 -0
- /package/dist/{types → cjs}/logger.d.ts +0 -0
- /package/dist/{types → cjs}/types.d.ts +0 -0
- /package/dist/{types → cjs}/validation.d.ts +0 -0
- /package/dist/{types → esm}/consumer.d.ts +0 -0
- /package/dist/{types → esm}/emitter.d.ts +0 -0
|
@@ -8,6 +8,6 @@ body:
|
|
|
8
8
|
- type: input
|
|
9
9
|
attributes:
|
|
10
10
|
label: Example
|
|
11
|
-
description: A link to a minimal reproduction is helpful for debugging! You can
|
|
11
|
+
description: A link to a minimal reproduction is helpful for debugging! You can use one of our [existing examples](https://github.com/bbc/sqs-consumer-starter/tree/main/examples) to get a reproduction setup quickly.
|
|
12
12
|
validations:
|
|
13
13
|
required: false
|
|
@@ -32,7 +32,7 @@ body:
|
|
|
32
32
|
Please add a link to a minimal reproduction.
|
|
33
33
|
Note:
|
|
34
34
|
- Please keep your example as simple and reproduceable as possible, try leaving out dependencies that are not required for reproduction.
|
|
35
|
-
- To create a shareable code example for web, you can use
|
|
35
|
+
- To create a shareable code example for web, you can use one of our existing examples: (https://github.com/bbc/sqs-consumer-starter/tree/main/examples).
|
|
36
36
|
- Please make sure the example is complete and runnable - e.g. avoid localhost URLs.
|
|
37
37
|
placeholder: |
|
|
38
38
|
e.g. Code Sandbox, Stackblitz, Expo Snack or TypeScript playground
|
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
## [10.2.
|
|
1
|
+
## [10.2.1](https://github.com/bbc/sqs-consumer/compare/v10.2.0...v10.2.1) (2024-04-30)
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
###
|
|
4
|
+
### Bug Fixes
|
|
5
5
|
|
|
6
|
-
*
|
|
6
|
+
* build exclusive type files ([65008eb](https://github.com/bbc/sqs-consumer/commit/65008ebaab8aecbe806b8e7ab9be809de58518a9))
|
|
7
|
+
* default extension for cjs ([bd9855b](https://github.com/bbc/sqs-consumer/commit/bd9855babedee1ea6506d8fc2901228e1cd31468))
|
|
8
|
+
* types extension for cjs ([8bc6239](https://github.com/bbc/sqs-consumer/commit/8bc62396badf30bcf508309110a782aa6f4b9d8c))
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
### Chores
|
|
10
12
|
|
|
11
|
-
*
|
|
12
|
-
* don't add package.json for types dir ([6084f28](https://github.com/bbc/sqs-consumer/commit/6084f28c1c3efeb87978e2c0de76427029b57af5))
|
|
13
|
-
* **release:** v10.1.0 ([244d6b5](https://github.com/bbc/sqs-consumer/commit/244d6b5c3f606e730ecb1cd748d7c8d567c5f2dc))
|
|
13
|
+
* updating repro links ([48f452e](https://github.com/bbc/sqs-consumer/commit/48f452ee935a563b3d0c1043b552947da84886ea))
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ConsumerOptions, StopOptions, UpdatableOptions } from "./types.js";
|
|
3
|
+
import { TypedEventEmitter } from "./emitter.js";
|
|
4
|
+
/**
|
|
5
|
+
* [Usage](https://bbc.github.io/sqs-consumer/index.html#usage)
|
|
6
|
+
*/
|
|
7
|
+
export declare class Consumer extends TypedEventEmitter {
|
|
8
|
+
private pollingTimeoutId;
|
|
9
|
+
private stopped;
|
|
10
|
+
private queueUrl;
|
|
11
|
+
private handleMessage;
|
|
12
|
+
private handleMessageBatch;
|
|
13
|
+
private preReceiveMessageCallback?;
|
|
14
|
+
private postReceiveMessageCallback?;
|
|
15
|
+
private sqs;
|
|
16
|
+
private handleMessageTimeout;
|
|
17
|
+
private attributeNames;
|
|
18
|
+
private messageAttributeNames;
|
|
19
|
+
private shouldDeleteMessages;
|
|
20
|
+
private alwaysAcknowledge;
|
|
21
|
+
private batchSize;
|
|
22
|
+
private visibilityTimeout;
|
|
23
|
+
private terminateVisibilityTimeout;
|
|
24
|
+
private waitTimeSeconds;
|
|
25
|
+
private authenticationErrorTimeout;
|
|
26
|
+
private pollingWaitTimeMs;
|
|
27
|
+
private pollingCompleteWaitTimeMs;
|
|
28
|
+
private heartbeatInterval;
|
|
29
|
+
private isPolling;
|
|
30
|
+
private stopRequestedAtTimestamp;
|
|
31
|
+
abortController: AbortController;
|
|
32
|
+
constructor(options: ConsumerOptions);
|
|
33
|
+
/**
|
|
34
|
+
* Creates a new SQS consumer.
|
|
35
|
+
*/
|
|
36
|
+
static create(options: ConsumerOptions): Consumer;
|
|
37
|
+
/**
|
|
38
|
+
* Start polling the queue for messages.
|
|
39
|
+
*/
|
|
40
|
+
start(): void;
|
|
41
|
+
/**
|
|
42
|
+
* A reusable options object for sqs.send that's used to avoid duplication.
|
|
43
|
+
*/
|
|
44
|
+
private get sqsSendOptions();
|
|
45
|
+
/**
|
|
46
|
+
* Stop polling the queue for messages (pre existing requests will still be made until concluded).
|
|
47
|
+
*/
|
|
48
|
+
stop(options?: StopOptions): void;
|
|
49
|
+
/**
|
|
50
|
+
* Wait for final poll and in flight messages to complete.
|
|
51
|
+
* @private
|
|
52
|
+
*/
|
|
53
|
+
private waitForPollingToComplete;
|
|
54
|
+
/**
|
|
55
|
+
* Returns the current status of the consumer.
|
|
56
|
+
* This includes whether it is running or currently polling.
|
|
57
|
+
*/
|
|
58
|
+
get status(): {
|
|
59
|
+
isRunning: boolean;
|
|
60
|
+
isPolling: boolean;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Validates and then updates the provided option to the provided value.
|
|
64
|
+
* @param option The option to validate and then update
|
|
65
|
+
* @param value The value to set the provided option to
|
|
66
|
+
*/
|
|
67
|
+
updateOption(option: UpdatableOptions, value: ConsumerOptions[UpdatableOptions]): void;
|
|
68
|
+
/**
|
|
69
|
+
* Emit one of the consumer's error events depending on the error received.
|
|
70
|
+
* @param err The error object to forward on
|
|
71
|
+
* @param message The message that the error occurred on
|
|
72
|
+
*/
|
|
73
|
+
private emitError;
|
|
74
|
+
/**
|
|
75
|
+
* Poll for new messages from SQS
|
|
76
|
+
*/
|
|
77
|
+
private poll;
|
|
78
|
+
/**
|
|
79
|
+
* Send a request to SQS to retrieve messages
|
|
80
|
+
* @param params The required params to receive messages from SQS
|
|
81
|
+
*/
|
|
82
|
+
private receiveMessage;
|
|
83
|
+
/**
|
|
84
|
+
* Handles the response from AWS SQS, determining if we should proceed to
|
|
85
|
+
* the message handler.
|
|
86
|
+
* @param response The output from AWS SQS
|
|
87
|
+
*/
|
|
88
|
+
private handleSqsResponse;
|
|
89
|
+
/**
|
|
90
|
+
* Process a message that has been received from SQS. This will execute the message
|
|
91
|
+
* handler and delete the message once complete.
|
|
92
|
+
* @param message The message that was delivered from SQS
|
|
93
|
+
*/
|
|
94
|
+
private processMessage;
|
|
95
|
+
/**
|
|
96
|
+
* Process a batch of messages from the SQS queue.
|
|
97
|
+
* @param messages The messages that were delivered from SQS
|
|
98
|
+
*/
|
|
99
|
+
private processMessageBatch;
|
|
100
|
+
/**
|
|
101
|
+
* Trigger a function on a set interval
|
|
102
|
+
* @param heartbeatFn The function that should be triggered
|
|
103
|
+
*/
|
|
104
|
+
private startHeartbeat;
|
|
105
|
+
/**
|
|
106
|
+
* Change the visibility timeout on a message
|
|
107
|
+
* @param message The message to change the value of
|
|
108
|
+
* @param timeout The new timeout that should be set
|
|
109
|
+
*/
|
|
110
|
+
private changeVisibilityTimeout;
|
|
111
|
+
/**
|
|
112
|
+
* Change the visibility timeout on a batch of messages
|
|
113
|
+
* @param messages The messages to change the value of
|
|
114
|
+
* @param timeout The new timeout that should be set
|
|
115
|
+
*/
|
|
116
|
+
private changeVisibilityTimeoutBatch;
|
|
117
|
+
/**
|
|
118
|
+
* Trigger the applications handleMessage function
|
|
119
|
+
* @param message The message that was received from SQS
|
|
120
|
+
*/
|
|
121
|
+
private executeHandler;
|
|
122
|
+
/**
|
|
123
|
+
* Execute the application's message batch handler
|
|
124
|
+
* @param messages The messages that should be forwarded from the SQS queue
|
|
125
|
+
*/
|
|
126
|
+
private executeBatchHandler;
|
|
127
|
+
/**
|
|
128
|
+
* Delete a single message from SQS
|
|
129
|
+
* @param message The message to delete from the SQS queue
|
|
130
|
+
*/
|
|
131
|
+
private deleteMessage;
|
|
132
|
+
/**
|
|
133
|
+
* Delete a batch of messages from the SQS queue.
|
|
134
|
+
* @param messages The messages that should be deleted from SQS
|
|
135
|
+
*/
|
|
136
|
+
private deleteMessageBatch;
|
|
137
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from "node:events";
|
|
3
|
+
import { Events } from "./types.js";
|
|
4
|
+
export declare class TypedEventEmitter extends EventEmitter {
|
|
5
|
+
/**
|
|
6
|
+
* Trigger a listener on all emitted events
|
|
7
|
+
* @param event The name of the event to listen to
|
|
8
|
+
* @param listener A function to trigger when the event is emitted
|
|
9
|
+
*/
|
|
10
|
+
on<E extends keyof Events>(event: E, listener: (...args: Events[E]) => void): this;
|
|
11
|
+
/**
|
|
12
|
+
* Trigger a listener only once for an emitted event
|
|
13
|
+
* @param event The name of the event to listen to
|
|
14
|
+
* @param listener A function to trigger when the event is emitted
|
|
15
|
+
*/
|
|
16
|
+
once<E extends keyof Events>(event: E, listener: (...args: Events[E]) => void): this;
|
|
17
|
+
/**
|
|
18
|
+
* Emits an event with the provided arguments
|
|
19
|
+
* @param event The name of the event to emit
|
|
20
|
+
*/
|
|
21
|
+
emit<E extends keyof Events>(event: E, ...args: Events[E]): boolean;
|
|
22
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AWSError } from "./types.js";
|
|
2
|
+
declare class SQSError extends Error {
|
|
3
|
+
code: string;
|
|
4
|
+
statusCode: number;
|
|
5
|
+
service: string;
|
|
6
|
+
time: Date;
|
|
7
|
+
retryable: boolean;
|
|
8
|
+
fault: "client" | "server";
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
11
|
+
declare class TimeoutError extends Error {
|
|
12
|
+
cause: Error;
|
|
13
|
+
time: Date;
|
|
14
|
+
constructor(message?: string);
|
|
15
|
+
}
|
|
16
|
+
declare class StandardError extends Error {
|
|
17
|
+
cause: Error;
|
|
18
|
+
time: Date;
|
|
19
|
+
constructor(message?: string);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Checks if the error provided should be treated as a connection error.
|
|
23
|
+
* @param err The error that was received.
|
|
24
|
+
*/
|
|
25
|
+
declare function isConnectionError(err: Error): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Formats an AWSError the the SQSError type.
|
|
28
|
+
* @param err The error object that was received.
|
|
29
|
+
* @param message The message to send with the error.
|
|
30
|
+
*/
|
|
31
|
+
declare function toSQSError(err: AWSError, message: string): SQSError;
|
|
32
|
+
/**
|
|
33
|
+
* Formats an Error to the StandardError type.
|
|
34
|
+
* @param err The error object that was received.
|
|
35
|
+
* @param message The message to send with the error.
|
|
36
|
+
*/
|
|
37
|
+
declare function toStandardError(err: Error, message: string): StandardError;
|
|
38
|
+
/**
|
|
39
|
+
* Formats an Error to the TimeoutError type.
|
|
40
|
+
* @param err The error object that was received.
|
|
41
|
+
* @param message The message to send with the error.
|
|
42
|
+
*/
|
|
43
|
+
declare function toTimeoutError(err: TimeoutError, message: string): TimeoutError;
|
|
44
|
+
export { SQSError, TimeoutError, isConnectionError, toSQSError, toStandardError, toTimeoutError, };
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { SQSClient, Message, QueueAttributeName } from "@aws-sdk/client-sqs";
|
|
2
|
+
/**
|
|
3
|
+
* The options for the consumer.
|
|
4
|
+
*/
|
|
5
|
+
export interface ConsumerOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The SQS queue URL.
|
|
8
|
+
*/
|
|
9
|
+
queueUrl: string;
|
|
10
|
+
/**
|
|
11
|
+
* List of queue attributes to retrieve, see [AWS docs](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-sqs/Variable/QueueAttributeName/).
|
|
12
|
+
* @defaultvalue `[]`
|
|
13
|
+
*/
|
|
14
|
+
attributeNames?: QueueAttributeName[];
|
|
15
|
+
/**
|
|
16
|
+
* List of message attributes to retrieve (i.e. `['name', 'address']`).
|
|
17
|
+
* @defaultvalue `[]`
|
|
18
|
+
*/
|
|
19
|
+
messageAttributeNames?: string[];
|
|
20
|
+
/** @hidden */
|
|
21
|
+
stopped?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* The number of messages to request from SQS when polling (default `1`).
|
|
24
|
+
*
|
|
25
|
+
* This cannot be higher than the
|
|
26
|
+
* [AWS limit of 10](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/quotas-messages.html).
|
|
27
|
+
* @defaultvalue `1`
|
|
28
|
+
*/
|
|
29
|
+
batchSize?: number;
|
|
30
|
+
/**
|
|
31
|
+
* The duration (in seconds) that the received messages are hidden from subsequent
|
|
32
|
+
* retrieve requests after being retrieved by a ReceiveMessage request.
|
|
33
|
+
*/
|
|
34
|
+
visibilityTimeout?: number;
|
|
35
|
+
/**
|
|
36
|
+
* The duration (in seconds) for which the call will wait for a message to arrive in
|
|
37
|
+
* the queue before returning.
|
|
38
|
+
* @defaultvalue `20`
|
|
39
|
+
*/
|
|
40
|
+
waitTimeSeconds?: number;
|
|
41
|
+
/**
|
|
42
|
+
* The duration (in milliseconds) to wait before retrying after an authentication error.
|
|
43
|
+
* @defaultvalue `10000`
|
|
44
|
+
*/
|
|
45
|
+
authenticationErrorTimeout?: number;
|
|
46
|
+
/**
|
|
47
|
+
* The duration (in milliseconds) to wait before repolling the queue.
|
|
48
|
+
* @defaultvalue `0`
|
|
49
|
+
*/
|
|
50
|
+
pollingWaitTimeMs?: number;
|
|
51
|
+
/**
|
|
52
|
+
* If you want the stop action to wait for the final poll to complete and in-flight messages
|
|
53
|
+
* to be processed before emitting 'stopped' set this to the max amount of time to wait.
|
|
54
|
+
* @defaultvalue `0`
|
|
55
|
+
*/
|
|
56
|
+
pollingCompleteWaitTimeMs?: number;
|
|
57
|
+
/**
|
|
58
|
+
* If true, sets the message visibility timeout to 0 after a `processing_error`.
|
|
59
|
+
* @defaultvalue `false`
|
|
60
|
+
*/
|
|
61
|
+
terminateVisibilityTimeout?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* The interval (in seconds) between requests to extend the message visibility timeout.
|
|
64
|
+
*
|
|
65
|
+
* On each heartbeat the visibility is extended by adding `visibilityTimeout` to
|
|
66
|
+
* the number of seconds since the start of the handler function.
|
|
67
|
+
*
|
|
68
|
+
* This value must less than `visibilityTimeout`.
|
|
69
|
+
*/
|
|
70
|
+
heartbeatInterval?: number;
|
|
71
|
+
/**
|
|
72
|
+
* An optional [SQS Client](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-sqs/classes/sqsclient.html)
|
|
73
|
+
* object to use if you need to configure the client manually.
|
|
74
|
+
*/
|
|
75
|
+
sqs?: SQSClient;
|
|
76
|
+
/**
|
|
77
|
+
* The AWS region.
|
|
78
|
+
* @defaultValue process.env.AWS_REGION || `eu-west-1`
|
|
79
|
+
*/
|
|
80
|
+
region?: string;
|
|
81
|
+
/**
|
|
82
|
+
* If false uses the QueueUrl hostname as the endpoint.
|
|
83
|
+
* @defaultValue `true`
|
|
84
|
+
*/
|
|
85
|
+
useQueueUrlAsEndpoint?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Time in ms to wait for `handleMessage` to process a message before timing out.
|
|
88
|
+
*
|
|
89
|
+
* Emits `timeout_error` on timeout. By default, if `handleMessage` times out,
|
|
90
|
+
* the unprocessed message returns to the end of the queue.
|
|
91
|
+
*/
|
|
92
|
+
handleMessageTimeout?: number;
|
|
93
|
+
/**
|
|
94
|
+
* Default to `true`, if you don't want the package to delete messages from sqs
|
|
95
|
+
* set this to `false`.
|
|
96
|
+
* @defaultvalue `true`
|
|
97
|
+
*/
|
|
98
|
+
shouldDeleteMessages?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* By default, the consumer will treat an empty object or array from either of the
|
|
101
|
+
* handlers as a acknowledgement of no messages and will not delete those messages as
|
|
102
|
+
* a result. Set this to `true` to always acknowledge all messages no matter the returned
|
|
103
|
+
* value.
|
|
104
|
+
* @defaultvalue `false`
|
|
105
|
+
*/
|
|
106
|
+
alwaysAcknowledge?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* An `async` function (or function that returns a `Promise`) to be called whenever
|
|
109
|
+
* a message is received.
|
|
110
|
+
*
|
|
111
|
+
* In the case that you need to acknowledge the message, return an object containing
|
|
112
|
+
* the MessageId that you'd like to acknowledge.
|
|
113
|
+
*/
|
|
114
|
+
handleMessage?(message: Message): Promise<Message | void>;
|
|
115
|
+
/**
|
|
116
|
+
* An `async` function (or function that returns a `Promise`) to be called whenever
|
|
117
|
+
* a batch of messages is received. Similar to `handleMessage` but will receive the
|
|
118
|
+
* list of messages, not each message individually.
|
|
119
|
+
*
|
|
120
|
+
* **If both are set, `handleMessageBatch` overrides `handleMessage`**.
|
|
121
|
+
*
|
|
122
|
+
* In the case that you need to ack only some of the messages, return an array with
|
|
123
|
+
* the successful messages only.
|
|
124
|
+
*/
|
|
125
|
+
handleMessageBatch?(messages: Message[]): Promise<Message[] | void>;
|
|
126
|
+
/**
|
|
127
|
+
* An `async` function (or function that returns a `Promise`) to be called right
|
|
128
|
+
* before the SQS Client sends a receive message command.
|
|
129
|
+
*
|
|
130
|
+
* This function is usefull if SQS Client module exports have been modified, for
|
|
131
|
+
* example to add middlewares.
|
|
132
|
+
*/
|
|
133
|
+
preReceiveMessageCallback?(): Promise<void>;
|
|
134
|
+
/**
|
|
135
|
+
* An `async` function (or function that returns a `Promise`) to be called right
|
|
136
|
+
* after the SQS Client sends a receive message command.
|
|
137
|
+
*
|
|
138
|
+
* This function is usefull if SQS Client module exports have been modified, for
|
|
139
|
+
* example to add middlewares.
|
|
140
|
+
*/
|
|
141
|
+
postReceiveMessageCallback?(): Promise<void>;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* A subset of the ConsumerOptions that can be updated at runtime.
|
|
145
|
+
*/
|
|
146
|
+
export type UpdatableOptions = "visibilityTimeout" | "batchSize" | "waitTimeSeconds" | "pollingWaitTimeMs";
|
|
147
|
+
/**
|
|
148
|
+
* The options for the stop method.
|
|
149
|
+
*/
|
|
150
|
+
export interface StopOptions {
|
|
151
|
+
/**
|
|
152
|
+
* Default to `false`, if you want the stop action to also abort requests to SQS
|
|
153
|
+
* set this to `true`.
|
|
154
|
+
* @defaultvalue `false`
|
|
155
|
+
*/
|
|
156
|
+
abort?: boolean;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* These are the events that the consumer emits.
|
|
160
|
+
*/
|
|
161
|
+
export interface Events {
|
|
162
|
+
/**
|
|
163
|
+
* Fired after one batch of items (up to `batchSize`) has been successfully processed.
|
|
164
|
+
*/
|
|
165
|
+
response_processed: [];
|
|
166
|
+
/**
|
|
167
|
+
* Fired when the queue is empty (All messages have been consumed).
|
|
168
|
+
*/
|
|
169
|
+
empty: [];
|
|
170
|
+
/**
|
|
171
|
+
* Fired when a message is received.
|
|
172
|
+
*/
|
|
173
|
+
message_received: [Message];
|
|
174
|
+
/**
|
|
175
|
+
* Fired when a message is successfully processed and removed from the queue.
|
|
176
|
+
*/
|
|
177
|
+
message_processed: [Message];
|
|
178
|
+
/**
|
|
179
|
+
* Fired when an error occurs interacting with the queue.
|
|
180
|
+
*
|
|
181
|
+
* If the error correlates to a message, that message is included in Params
|
|
182
|
+
*/
|
|
183
|
+
error: [Error, void | Message | Message[]];
|
|
184
|
+
/**
|
|
185
|
+
* Fired when `handleMessageTimeout` is supplied as an option and if
|
|
186
|
+
* `handleMessage` times out.
|
|
187
|
+
*/
|
|
188
|
+
timeout_error: [Error, Message];
|
|
189
|
+
/**
|
|
190
|
+
* Fired when an error occurs processing the message.
|
|
191
|
+
*/
|
|
192
|
+
processing_error: [Error, Message];
|
|
193
|
+
/**
|
|
194
|
+
* Fired when requests to SQS were aborted.
|
|
195
|
+
*/
|
|
196
|
+
aborted: [];
|
|
197
|
+
/**
|
|
198
|
+
* Fired when the consumer starts its work..
|
|
199
|
+
*/
|
|
200
|
+
started: [];
|
|
201
|
+
/**
|
|
202
|
+
* Fired when the consumer finally stops its work.
|
|
203
|
+
*/
|
|
204
|
+
stopped: [];
|
|
205
|
+
/**
|
|
206
|
+
* Fired when an option is updated
|
|
207
|
+
*/
|
|
208
|
+
option_updated: [UpdatableOptions, ConsumerOptions[UpdatableOptions]];
|
|
209
|
+
/**
|
|
210
|
+
* Fired when the Consumer is waiting for polling to complete before stopping.
|
|
211
|
+
*/
|
|
212
|
+
waiting_for_polling_to_complete: [];
|
|
213
|
+
/**
|
|
214
|
+
* Fired when the Consumer has waited for polling to complete and is stopping due to a timeout.
|
|
215
|
+
*/
|
|
216
|
+
waiting_for_polling_to_complete_timeout_exceeded: [];
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* The error object that is emitted with error events from AWS.
|
|
220
|
+
*/
|
|
221
|
+
export type AWSError = {
|
|
222
|
+
/**
|
|
223
|
+
* Name, eg. ConditionalCheckFailedException
|
|
224
|
+
*/
|
|
225
|
+
name: string;
|
|
226
|
+
/**
|
|
227
|
+
* Human-readable error response message
|
|
228
|
+
*/
|
|
229
|
+
message: string;
|
|
230
|
+
/**
|
|
231
|
+
* Non-standard stacktrace
|
|
232
|
+
*/
|
|
233
|
+
stack?: string;
|
|
234
|
+
/**
|
|
235
|
+
* Whether the client or server are at fault.
|
|
236
|
+
*/
|
|
237
|
+
readonly $fault?: "client" | "server";
|
|
238
|
+
/**
|
|
239
|
+
* The service that encountered the exception.
|
|
240
|
+
*/
|
|
241
|
+
readonly $service?: string;
|
|
242
|
+
/**
|
|
243
|
+
* Indicates that an error MAY be retried by the client.
|
|
244
|
+
*/
|
|
245
|
+
readonly $retryable?: {
|
|
246
|
+
/**
|
|
247
|
+
* Indicates that the error is a retryable throttling error.
|
|
248
|
+
*/
|
|
249
|
+
readonly throttling?: boolean;
|
|
250
|
+
};
|
|
251
|
+
$metadata?: {
|
|
252
|
+
/**
|
|
253
|
+
* The status code of the last HTTP response received for this operation.
|
|
254
|
+
*/
|
|
255
|
+
httpStatusCode?: number;
|
|
256
|
+
/**
|
|
257
|
+
* A unique identifier for the last request sent for this operation. Often
|
|
258
|
+
* requested by AWS service teams to aid in debugging.
|
|
259
|
+
*/
|
|
260
|
+
requestId?: string;
|
|
261
|
+
/**
|
|
262
|
+
* A secondary identifier for the last request sent. Used for debugging.
|
|
263
|
+
*/
|
|
264
|
+
extendedRequestId?: string;
|
|
265
|
+
/**
|
|
266
|
+
* A tertiary identifier for the last request sent. Used for debugging.
|
|
267
|
+
*/
|
|
268
|
+
cfId?: string;
|
|
269
|
+
/**
|
|
270
|
+
* The number of times this operation was attempted.
|
|
271
|
+
*/
|
|
272
|
+
attempts?: number;
|
|
273
|
+
/**
|
|
274
|
+
* The total amount of time (in milliseconds) that was spent waiting between
|
|
275
|
+
* retry attempts.
|
|
276
|
+
*/
|
|
277
|
+
totalRetryDelay?: number;
|
|
278
|
+
};
|
|
279
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ReceiveMessageCommandOutput } from "@aws-sdk/client-sqs";
|
|
2
|
+
import { ConsumerOptions } from "./types.js";
|
|
3
|
+
declare function validateOption(option: string, value: any, allOptions: {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
}, strict?: boolean): void;
|
|
6
|
+
/**
|
|
7
|
+
* Ensure that the required options have been set.
|
|
8
|
+
* @param options The options that have been set by the application.
|
|
9
|
+
*/
|
|
10
|
+
declare function assertOptions(options: ConsumerOptions): void;
|
|
11
|
+
/**
|
|
12
|
+
* Determine if the response from SQS has messages in it.
|
|
13
|
+
* @param response The response from SQS.
|
|
14
|
+
*/
|
|
15
|
+
declare function hasMessages(response: ReceiveMessageCommandOutput): boolean;
|
|
16
|
+
export { hasMessages, assertOptions, validateOption };
|
package/package.json
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sqs-consumer",
|
|
3
|
-
"version": "10.2.
|
|
3
|
+
"version": "10.2.1",
|
|
4
4
|
"description": "Build SQS-based Node applications without the boilerplate",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
7
|
-
"types": "dist/
|
|
7
|
+
"types": "dist/cjs/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./dist/esm/index.d.ts",
|
|
12
|
+
"default": "./dist/esm/index.js"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/cjs/index.d.ts",
|
|
16
|
+
"default": "./dist/cjs/index.js"
|
|
17
|
+
}
|
|
14
18
|
}
|
|
15
19
|
},
|
|
16
20
|
"engines": {
|
package/tsconfig.cjs.json
CHANGED
package/tsconfig.esm.json
CHANGED
package/tsconfig.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|