@adobe/helix-admin-support 3.0.2 → 3.0.3

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 CHANGED
@@ -1,3 +1,10 @@
1
+ ## [3.0.3](https://github.com/adobe/helix-admin-support/compare/v3.0.2...v3.0.3) (2024-11-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * return message IDs from send ([#332](https://github.com/adobe/helix-admin-support/issues/332)) ([4fc95ea](https://github.com/adobe/helix-admin-support/commit/4fc95ea727925f553182ac65de9ca1a24460f2fa))
7
+
1
8
  ## [3.0.2](https://github.com/adobe/helix-admin-support/compare/v3.0.1...v3.0.2) (2024-11-10)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-admin-support",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "Helix Admin Support Library",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -73,9 +73,9 @@ export declare class BatchedQueueClient {
73
73
  /**
74
74
  * Sends a batch of messages to the `outQueue`.
75
75
  * @param {Message[]} messages
76
- * @returns {Promise<void>}
76
+ * @returns {Promise<String[]>} Message IDs of messages sent successfully
77
77
  */
78
- send(messages:Message[]): Promise<void>;
78
+ send(messages:Message[]): Promise<String[]>;
79
79
 
80
80
  /**
81
81
  * Closes this client and destroys the underlying datastructures
@@ -204,15 +204,17 @@ export class BatchedQueueClient {
204
204
  /**
205
205
  * Sends a batch of messages to the `outQueue`.
206
206
  * @param {Message[]} messages
207
- * @returns {Promise<void>}
207
+ * @returns {Promise<String[]>} Message IDs of messages sent successfully
208
208
  */
209
209
  async send(messages) {
210
210
  const { log, sqs } = this;
211
211
  const total = messages.length;
212
+ const messageIds = [];
212
213
  let sent = 0;
213
214
  let batchSize = 0;
214
215
  let batch = [];
215
216
  let send = false;
217
+
216
218
  while (messages.length) {
217
219
  let msg = messages.shift();
218
220
  let size = JSON.stringify(msg).length;
@@ -221,7 +223,7 @@ export class BatchedQueueClient {
221
223
  batchSize += size;
222
224
  } else if (batch.length === 0) {
223
225
  // message doesn't fit in any batch - serializing to s3
224
- log.info(`[${msg.MessageGroupId}] message to big: ${hsize(size)}. serializing to s3...`);
226
+ log.info(`[${msg.MessageGroupId}] message too big: ${hsize(size)}. serializing to s3...`);
225
227
  // eslint-disable-next-line no-await-in-loop
226
228
  msg = await this.serialize(msg);
227
229
  size = JSON.stringify(msg).length;
@@ -229,7 +231,7 @@ export class BatchedQueueClient {
229
231
  batchSize += size;
230
232
  } else {
231
233
  // put message back
232
- log.info(`[${msg.MessageGroupId}] message to big: ${hsize(size)}. sending current batch...`);
234
+ log.info(`[${msg.MessageGroupId}] message too big: ${hsize(size)}. sending current batch...`);
233
235
  messages.unshift(msg);
234
236
  send = true;
235
237
  }
@@ -250,12 +252,14 @@ export class BatchedQueueClient {
250
252
  log.warn(`failed to send ${Failed.length} to queue.`);
251
253
  }
252
254
  sent += Successful.length;
255
+ messageIds.push(...Successful.map(({ MessageId }) => MessageId));
253
256
  log.info(`sent. ${sent}/${total} (${hsize(batchSize)} to ${this.outQueue} done.`);
254
257
  batch = [];
255
258
  batchSize = 0;
256
259
  send = false;
257
260
  }
258
261
  }
262
+ return messageIds;
259
263
  }
260
264
 
261
265
  /**