ag-common 0.0.840 → 0.0.841

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.
@@ -92,21 +92,31 @@ const executeScan = (tableName, options, exclusiveStartKey) => __awaiter(void 0,
92
92
  });
93
93
  });
94
94
  const getItemsDynamo = (params) => __awaiter(void 0, void 0, void 0, function* () {
95
- var _a, _b;
96
95
  try {
97
- const batchGetParams = {
98
- RequestItems: {
99
- [params.tableName]: {
100
- Keys: params.items.map(({ pkName, pkValue }) => ({
101
- [pkName]: pkValue,
102
- })),
96
+ const BATCH_SIZE = 100;
97
+ const chunks = [];
98
+ for (let i = 0; i < params.items.length; i += BATCH_SIZE) {
99
+ chunks.push(params.items.slice(i, i + BATCH_SIZE));
100
+ }
101
+ const responses = yield Promise.all(chunks.map((chunk) => {
102
+ const batchGetParams = {
103
+ RequestItems: {
104
+ [params.tableName]: {
105
+ Keys: chunk.map(({ pkName, pkValue }) => ({
106
+ [pkName]: pkValue,
107
+ })),
108
+ },
103
109
  },
104
- },
105
- };
106
- const result = yield (0, withRetry_1.withRetry)(() => _1.dynamoDb.send(new lib_dynamodb_1.BatchGetCommand(batchGetParams)), 'getItemsDynamo:' + JSON.stringify(params));
107
- return {
108
- data: (_b = (_a = result.Responses) === null || _a === void 0 ? void 0 : _a[params.tableName]) !== null && _b !== void 0 ? _b : [],
109
- };
110
+ };
111
+ return (0, withRetry_1.withRetry)(() => _1.dynamoDb.send(new lib_dynamodb_1.BatchGetCommand(batchGetParams)), 'getItemsDynamo:' + JSON.stringify(params));
112
+ }));
113
+ const allItems = [];
114
+ responses.forEach((result) => {
115
+ var _a, _b;
116
+ const items = (_b = (_a = result.Responses) === null || _a === void 0 ? void 0 : _a[params.tableName]) !== null && _b !== void 0 ? _b : [];
117
+ allItems.push(...items);
118
+ });
119
+ return { data: allItems };
110
120
  }
111
121
  catch (e) {
112
122
  return { error: e.toString() };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.840",
2
+ "version": "0.0.841",
3
3
  "name": "ag-common",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",