@adobe/spacecat-shared-utils 1.23.5 → 1.23.7
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/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/src/sqs.js +12 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-utils-v1.23.7](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.23.6...@adobe/spacecat-shared-utils-v1.23.7) (2024-12-13)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **sqs:** Support both standard and FIFO SQS queues ([#490](https://github.com/adobe/spacecat-shared/issues/490)) ([4a975b0](https://github.com/adobe/spacecat-shared/commit/4a975b0994d2df9fc296cfe900b1500aeb34e44f)), closes [#489](https://github.com/adobe/spacecat-shared/issues/489)
|
|
7
|
+
|
|
8
|
+
# [@adobe/spacecat-shared-utils-v1.23.6](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.23.5...@adobe/spacecat-shared-utils-v1.23.6) (2024-12-10)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **sqs-wrapper:** decrease error log level ([#483](https://github.com/adobe/spacecat-shared/issues/483)) ([2c7bc99](https://github.com/adobe/spacecat-shared/commit/2c7bc998d0d137b24ca84356a4445a76e63053e3))
|
|
14
|
+
|
|
1
15
|
# [@adobe/spacecat-shared-utils-v1.23.5](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.23.4...@adobe/spacecat-shared-utils-v1.23.5) (2024-12-07)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
package/src/sqs.js
CHANGED
|
@@ -25,6 +25,15 @@ class SQS {
|
|
|
25
25
|
this.log = log;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Check if the queue is a FIFO queue by examining its URL.
|
|
30
|
+
* @param {string} queueUrl - the URL of the SQS queue
|
|
31
|
+
* @returns {boolean} true if the queue is a FIFO queue, false otherwise
|
|
32
|
+
*/
|
|
33
|
+
static #isFifoQueue(queueUrl) {
|
|
34
|
+
return hasText(queueUrl) && queueUrl.toLowerCase().endsWith('.fifo');
|
|
35
|
+
}
|
|
36
|
+
|
|
28
37
|
/**
|
|
29
38
|
* Send a message to an SQS queue. For FIFO queues, messageGroupId is required.
|
|
30
39
|
* @param {string} queueUrl - The URL of the SQS queue.
|
|
@@ -43,8 +52,8 @@ class SQS {
|
|
|
43
52
|
QueueUrl: queueUrl,
|
|
44
53
|
};
|
|
45
54
|
|
|
46
|
-
if
|
|
47
|
-
|
|
55
|
+
// Only include MessageGroupId if the queue is a FIFO queue
|
|
56
|
+
if (SQS.#isFifoQueue(queueUrl) && hasText(messageGroupId)) {
|
|
48
57
|
params.MessageGroupId = messageGroupId;
|
|
49
58
|
}
|
|
50
59
|
|
|
@@ -96,7 +105,7 @@ export function sqsEventAdapter(fn) {
|
|
|
96
105
|
message = JSON.parse(records[0]?.body);
|
|
97
106
|
log.info(`Received message with id: ${records[0]?.messageId}`);
|
|
98
107
|
} catch (e) {
|
|
99
|
-
log.
|
|
108
|
+
log.warn('Function was not invoked properly, message body is not a valid JSON', e);
|
|
100
109
|
return new Response('', {
|
|
101
110
|
status: 400,
|
|
102
111
|
headers: {
|