@adobe/spacecat-shared-utils 1.21.0 → 1.22.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.
Files changed (3) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/package.json +4 -4
  3. package/src/sqs.js +18 -3
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [@adobe/spacecat-shared-utils-v1.22.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.21.1...@adobe/spacecat-shared-utils-v1.22.0) (2024-10-31)
2
+
3
+
4
+ ### Features
5
+
6
+ * support FIFO queues with the SQS sendMessage helper ([#417](https://github.com/adobe/spacecat-shared/issues/417)) ([f9df606](https://github.com/adobe/spacecat-shared/commit/f9df606d62b9e23c89b9944f7042b4804cef0599))
7
+
8
+ # [@adobe/spacecat-shared-utils-v1.21.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.21.0...@adobe/spacecat-shared-utils-v1.21.1) (2024-10-26)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update external fixes ([#413](https://github.com/adobe/spacecat-shared/issues/413)) ([ee2c715](https://github.com/adobe/spacecat-shared/commit/ee2c715e08034bea8fb88b4f7166d40b18e107c4))
14
+
1
15
  # [@adobe/spacecat-shared-utils-v1.21.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.20.8...@adobe/spacecat-shared-utils-v1.21.0) (2024-10-23)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-utils",
3
- "version": "1.21.0",
3
+ "version": "1.22.0",
4
4
  "description": "Shared modules of the Spacecat Services - utils",
5
5
  "type": "module",
6
6
  "engines": {
@@ -36,7 +36,7 @@
36
36
  "devDependencies": {
37
37
  "@adobe/helix-shared-wrap": "2.0.2",
38
38
  "@adobe/spacecat-shared-data-access": "file:../spacecat-shared-data-access",
39
- "chai": "5.1.1",
39
+ "chai": "5.1.2",
40
40
  "chai-as-promised": "8.0.0",
41
41
  "husky": "9.1.6",
42
42
  "nock": "13.5.5",
@@ -45,8 +45,8 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@adobe/fetch": "4.1.9",
48
- "@aws-sdk/client-s3": "3.675.0",
49
- "@aws-sdk/client-sqs": "3.675.0",
48
+ "@aws-sdk/client-s3": "3.679.0",
49
+ "@aws-sdk/client-sqs": "3.679.0",
50
50
  "@json2csv/plainjs": "7.0.6",
51
51
  "aws-xray-sdk": "3.10.1"
52
52
  }
package/src/sqs.js CHANGED
@@ -12,6 +12,7 @@
12
12
 
13
13
  import { SendMessageCommand, SQSClient } from '@aws-sdk/client-sqs';
14
14
  import AWSXray from 'aws-xray-sdk';
15
+ import { hasText } from './functions.js';
15
16
 
16
17
  /**
17
18
  * @class SQS utility to send messages to SQS
@@ -24,16 +25,30 @@ class SQS {
24
25
  this.log = log;
25
26
  }
26
27
 
27
- async sendMessage(queueUrl, message) {
28
+ /**
29
+ * Send a message to an SQS queue. For FIFO queues, messageGroupId is required.
30
+ * @param {string} queueUrl - The URL of the SQS queue.
31
+ * @param {object} message - The message body to send.
32
+ * @param {string} messageGroupId - (Optional) The message group ID for FIFO queues.
33
+ * @return {Promise<void>}
34
+ */
35
+ async sendMessage(queueUrl, message, messageGroupId = undefined) {
28
36
  const body = {
29
37
  ...message,
30
38
  timestamp: new Date().toISOString(),
31
39
  };
32
40
 
33
- const msgCommand = new SendMessageCommand({
41
+ const params = {
34
42
  MessageBody: JSON.stringify(body),
35
43
  QueueUrl: queueUrl,
36
- });
44
+ };
45
+
46
+ if (hasText(messageGroupId)) {
47
+ // MessageGroupId is required for FIFO queues
48
+ params.MessageGroupId = messageGroupId;
49
+ }
50
+
51
+ const msgCommand = new SendMessageCommand(params);
37
52
 
38
53
  try {
39
54
  const data = await this.sqsClient.send(msgCommand);