ag-common 0.0.839 → 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.
- package/dist/api/helpers/dynamo/get.js +23 -13
- package/package.json +1 -5
|
@@ -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
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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.
|
|
2
|
+
"version": "0.0.841",
|
|
3
3
|
"name": "ag-common",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
@@ -9,10 +9,6 @@
|
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/andreigec/ag-common.git"
|
|
11
11
|
},
|
|
12
|
-
"publishConfig": {
|
|
13
|
-
"access": "public",
|
|
14
|
-
"provenance": false
|
|
15
|
-
},
|
|
16
12
|
"dependencies": {
|
|
17
13
|
"eslint": "^9.37.0",
|
|
18
14
|
"eslint-config-e7npm": "^0.1.25",
|