ag-common 0.0.78 → 0.0.79
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.
|
@@ -11,13 +11,13 @@ export declare const batchWrite: <T extends {}>(tableName: string, itemsIn: T[],
|
|
|
11
11
|
} | {
|
|
12
12
|
error?: undefined;
|
|
13
13
|
}>;
|
|
14
|
-
export declare const batchDelete: ({ tableName,
|
|
14
|
+
export declare const batchDelete: ({ tableName, breakOnError, pkName, keys, rangeName, rangeKeys, }: {
|
|
15
15
|
pkName: string;
|
|
16
16
|
breakOnError?: boolean | undefined;
|
|
17
17
|
tableName: string;
|
|
18
18
|
keys: string[];
|
|
19
19
|
rangeName?: string | undefined;
|
|
20
|
-
|
|
20
|
+
rangeKeys?: string[] | undefined;
|
|
21
21
|
}) => Promise<{
|
|
22
22
|
error: string;
|
|
23
23
|
} | {
|
|
@@ -17,6 +17,7 @@ const aws_sdk_1 = __importDefault(require("aws-sdk"));
|
|
|
17
17
|
const log_1 = require("../../common/helpers/log");
|
|
18
18
|
const array_1 = require("../../common/helpers/array");
|
|
19
19
|
const sleep_1 = require("../../common/helpers/sleep");
|
|
20
|
+
const async_1 = require("../../common/helpers/async");
|
|
20
21
|
// eslint-disable-next-line import/no-mutable-exports
|
|
21
22
|
exports.dynamoDb = new aws_sdk_1.default.DynamoDB.DocumentClient();
|
|
22
23
|
const setDynamo = (region) => {
|
|
@@ -106,21 +107,24 @@ const batchWrite = (tableName, itemsIn, breakOnError = false) => __awaiter(void
|
|
|
106
107
|
return {};
|
|
107
108
|
});
|
|
108
109
|
exports.batchWrite = batchWrite;
|
|
109
|
-
const batchDelete = ({ tableName,
|
|
110
|
-
var _c, _d;
|
|
110
|
+
const batchDelete = ({ tableName, breakOnError = true, pkName, keys, rangeName, rangeKeys, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
111
111
|
(0, log_1.info)(`wipe keys dynamo:${tableName} - count=${keys.length}`);
|
|
112
112
|
const error = [];
|
|
113
113
|
let breakV = false;
|
|
114
|
-
|
|
114
|
+
yield (0, async_1.asyncForEach)(keys, (key, i) => __awaiter(void 0, void 0, void 0, function* () {
|
|
115
|
+
var _c, _d;
|
|
115
116
|
if (breakV) {
|
|
116
|
-
|
|
117
|
+
return;
|
|
117
118
|
}
|
|
118
119
|
let params = {
|
|
119
120
|
TableName: tableName,
|
|
120
121
|
Key: { [pkName]: key },
|
|
121
122
|
};
|
|
122
123
|
if (rangeName) {
|
|
123
|
-
|
|
124
|
+
let rangeValue = rangeKeys === null || rangeKeys === void 0 ? void 0 : rangeKeys[i];
|
|
125
|
+
if (rangeValue) {
|
|
126
|
+
params.Key[rangeName] = rangeValue;
|
|
127
|
+
}
|
|
124
128
|
}
|
|
125
129
|
const res = yield exports.dynamoDb.delete(params).promise();
|
|
126
130
|
const newError = (_d = (_c = res.$response) === null || _c === void 0 ? void 0 : _c.error) !== null && _d !== void 0 ? _d : null;
|
|
@@ -130,7 +134,7 @@ const batchDelete = ({ tableName, keys, breakOnError = true, pkName, rangeName,
|
|
|
130
134
|
breakV = true;
|
|
131
135
|
}
|
|
132
136
|
}
|
|
133
|
-
}
|
|
137
|
+
}));
|
|
134
138
|
if ((error === null || error === void 0 ? void 0 : error.length) > 0) {
|
|
135
139
|
const me = error.join('\n');
|
|
136
140
|
(0, log_1.error)(`batch write error=${me}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ag-common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.79",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"author": "Andrei Gec <@andreigec> (https://gec.dev/)",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"react-dom": "17.0.2",
|
|
25
25
|
"react-hot-toast": "2.2.0",
|
|
26
26
|
"styled-components": "5.3.3",
|
|
27
|
-
"typescript": "4.5.
|
|
27
|
+
"typescript": "4.5.5"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/jsonwebtoken": "8.5.8",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"@types/react": "17.0.38",
|
|
33
33
|
"@types/react-dom": "17.0.11",
|
|
34
34
|
"@types/styled-components": "5.1.20",
|
|
35
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
36
|
-
"@typescript-eslint/parser": "5.
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "5.10.0",
|
|
36
|
+
"@typescript-eslint/parser": "5.10.0",
|
|
37
37
|
"eslint": "8.7.0",
|
|
38
38
|
"eslint-config-airbnb-typescript": "16.1.0",
|
|
39
39
|
"eslint-config-prettier": "8.3.0",
|