ag-common 0.0.9 → 0.0.10
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.
|
@@ -28,7 +28,7 @@ const putDynamo = (item, tableName) => __awaiter(void 0, void 0, void 0, functio
|
|
|
28
28
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
29
|
Item: item,
|
|
30
30
|
};
|
|
31
|
-
(0, log_1.info)(`running dynamo put=${JSON.stringify(params)}`);
|
|
31
|
+
(0, log_1.info)(`running dynamo put=${JSON.stringify(params, null, 2)}`);
|
|
32
32
|
// write the todo to the database
|
|
33
33
|
const put = yield exports.dynamoDb.put(params).promise();
|
|
34
34
|
if (put.$response.error &&
|
|
@@ -138,7 +138,7 @@ const getItemDynamo = ({ tableName, pkName, pkValue, }) => __awaiter(void 0, voi
|
|
|
138
138
|
try {
|
|
139
139
|
const res = yield exports.dynamoDb.get(params).promise();
|
|
140
140
|
const ret = res.Item;
|
|
141
|
-
(0, log_1.debug)(`got dynamo getitem=${JSON.stringify(params)}`);
|
|
141
|
+
(0, log_1.debug)(`got dynamo getitem=${JSON.stringify(params, null, 2)}`);
|
|
142
142
|
return ret;
|
|
143
143
|
}
|
|
144
144
|
catch (e) {
|
|
@@ -158,14 +158,19 @@ const getItemsDynamo = ({ tableName, items, }) => __awaiter(void 0, void 0, void
|
|
|
158
158
|
},
|
|
159
159
|
},
|
|
160
160
|
};
|
|
161
|
+
const dbRaw = new aws_sdk_1.default.DynamoDB({ apiVersion: '2012-10-08' });
|
|
161
162
|
try {
|
|
162
|
-
const res = yield
|
|
163
|
-
(0, log_1.debug)(`got dynamo getitems=${JSON.stringify(res)}`);
|
|
164
|
-
let ret = ((_f = (_e = res.Responses) === null || _e === void 0 ? void 0 : _e[tableName]) === null || _f === void 0 ? void 0 : _f.map((s) => s)) || [];
|
|
163
|
+
const res = yield dbRaw.batchGetItem(params).promise();
|
|
164
|
+
(0, log_1.debug)(`got dynamo getitems=${JSON.stringify(res, null, 2)}`);
|
|
165
|
+
let ret = ((_f = (_e = res.Responses) === null || _e === void 0 ? void 0 : _e[tableName]) === null || _f === void 0 ? void 0 : _f.map((s) => aws_sdk_1.default.DynamoDB.Converter.unmarshall(s))) || [];
|
|
165
166
|
return ret;
|
|
166
167
|
}
|
|
167
168
|
catch (e) {
|
|
168
|
-
|
|
169
|
+
let msg = `error with getitems query:` +
|
|
170
|
+
JSON.stringify(params, null, 2) +
|
|
171
|
+
'\n' +
|
|
172
|
+
e.toString();
|
|
173
|
+
(0, log_1.error)(msg);
|
|
169
174
|
throw e;
|
|
170
175
|
}
|
|
171
176
|
});
|
|
@@ -73,7 +73,7 @@ const getAndValidateToken = ({ tokenRaw, COGNITO_USER_POOL_ID, }) => __awaiter(v
|
|
|
73
73
|
try {
|
|
74
74
|
yield jwtVerify({ token, COGNITO_USER_POOL_ID });
|
|
75
75
|
const decoded = (0, jsonwebtoken_1.decode)(token);
|
|
76
|
-
(0, log_1.debug)(`decoded=${JSON.stringify(decoded)}`);
|
|
76
|
+
(0, log_1.debug)(`decoded=${JSON.stringify(decoded, null, 2)}`);
|
|
77
77
|
subject = decoded === null || decoded === void 0 ? void 0 : decoded.sub;
|
|
78
78
|
if (!subject) {
|
|
79
79
|
const mess = 'user should have responded with subject (sub) field';
|
|
@@ -27,10 +27,8 @@ const chunk = (array, max) => {
|
|
|
27
27
|
let row = [];
|
|
28
28
|
for (const k in array) {
|
|
29
29
|
const item = array[k];
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
30
|
+
row.push(item);
|
|
31
|
+
if (row.length >= max) {
|
|
34
32
|
rows.push(row);
|
|
35
33
|
row = [];
|
|
36
34
|
}
|