@socket.tech/dl-common 1.0.3-test.38 → 1.0.3-test.39

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.
@@ -1,10 +1,10 @@
1
1
  export declare const initQueue: (region: string) => void;
2
2
  export declare const sendStandardSqsMessage: (queueUrl: string, data: any, DelaySeconds?: number) => Promise<import("@aws-sdk/client-sqs").SendMessageCommandOutput>;
3
- export declare const sendStandardBatchMessages: (QueueUrl: string, dataArray: any[], DelaySecondsArray?: number[]) => Promise<import("@aws-sdk/client-sqs").SendMessageBatchCommandOutput>;
3
+ export declare const sendStandardBatchMessages: (QueueUrl: string, dataArray: any[], DelaySecondsArray?: number[]) => Promise<void>;
4
4
  export declare const sendFifoSqsMessage: (queueUrl: string, data: any, MessageGroupId: string) => Promise<import("@aws-sdk/client-sqs").SendMessageCommandOutput>;
5
5
  declare const _default: {
6
6
  sendStandardSqsMessage: (queueUrl: string, data: any, DelaySeconds?: number) => Promise<import("@aws-sdk/client-sqs").SendMessageCommandOutput>;
7
7
  sendFifoSqsMessage: (queueUrl: string, data: any, MessageGroupId: string) => Promise<import("@aws-sdk/client-sqs").SendMessageCommandOutput>;
8
- sendStandardBatchMessages: (QueueUrl: string, dataArray: any[], DelaySecondsArray?: number[]) => Promise<import("@aws-sdk/client-sqs").SendMessageBatchCommandOutput>;
8
+ sendStandardBatchMessages: (QueueUrl: string, dataArray: any[], DelaySecondsArray?: number[]) => Promise<void>;
9
9
  };
10
10
  export default _default;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sendFifoSqsMessage = exports.sendStandardBatchMessages = exports.sendStandardSqsMessage = exports.initQueue = void 0;
4
4
  const client_sqs_1 = require("@aws-sdk/client-sqs");
5
+ const utils_1 = require("../utils");
5
6
  let client;
6
7
  const initQueue = (region) => {
7
8
  client = new client_sqs_1.SQSClient({ region });
@@ -19,21 +20,28 @@ const sendStandardSqsMessage = async (queueUrl, data, DelaySeconds = 0) => {
19
20
  };
20
21
  exports.sendStandardSqsMessage = sendStandardSqsMessage;
21
22
  const sendStandardBatchMessages = async (QueueUrl, dataArray, DelaySecondsArray = []) => {
22
- let Entries = [];
23
- for (let i = 0; i < dataArray.length; i++) {
24
- Entries.push({
25
- MessageBody: JSON.stringify(dataArray[i]),
26
- Id: i,
27
- DelaySeconds: DelaySecondsArray[i] ? DelaySecondsArray[i] : 0,
28
- });
23
+ var _a;
24
+ const dataChunks = [...(0, utils_1.chunks)(dataArray, 10)];
25
+ const delayChunks = [...(0, utils_1.chunks)(DelaySecondsArray, 10)];
26
+ for (let i = 0; i < dataChunks.length; i++) {
27
+ let Entries = [];
28
+ let currentDataArray = dataChunks[i];
29
+ let currentDelayArray = delayChunks[i];
30
+ for (let j = 0; j < currentDataArray.length; j++) {
31
+ Entries.push({
32
+ MessageBody: JSON.stringify(currentDataArray[j]),
33
+ Id: String(i) + "-" + String(j),
34
+ DelaySeconds: (_a = currentDelayArray[j]) !== null && _a !== void 0 ? _a : 0,
35
+ });
36
+ }
37
+ let sqsOrderData = {
38
+ Entries,
39
+ QueueUrl,
40
+ };
41
+ // Send the order data to the SQS queue
42
+ const command = new client_sqs_1.SendMessageBatchCommand(sqsOrderData);
43
+ await client.send(command);
29
44
  }
30
- let sqsOrderData = {
31
- Entries,
32
- QueueUrl,
33
- };
34
- // Send the order data to the SQS queue
35
- const command = new client_sqs_1.SendMessageBatchCommand(sqsOrderData);
36
- return await client.send(command);
37
45
  };
38
46
  exports.sendStandardBatchMessages = sendStandardBatchMessages;
39
47
  const sendFifoSqsMessage = async (queueUrl, data, MessageGroupId) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socket.tech/dl-common",
3
- "version": "1.0.3-test.38",
3
+ "version": "1.0.3-test.39",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "description": "common utilities for socket data layer.",