ag-common 0.0.77 → 0.0.78

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,11 +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, keys, breakOnError, pkName, }: {
14
+ export declare const batchDelete: ({ tableName, keys, breakOnError, pkName, rangeName, rangeValue, }: {
15
15
  pkName: string;
16
16
  breakOnError?: boolean | undefined;
17
17
  tableName: string;
18
18
  keys: string[];
19
+ rangeName?: string | undefined;
20
+ rangeValue?: string | undefined;
19
21
  }) => Promise<{
20
22
  error: string;
21
23
  } | {
@@ -106,7 +106,7 @@ const batchWrite = (tableName, itemsIn, breakOnError = false) => __awaiter(void
106
106
  return {};
107
107
  });
108
108
  exports.batchWrite = batchWrite;
109
- const batchDelete = ({ tableName, keys, breakOnError = true, pkName, }) => __awaiter(void 0, void 0, void 0, function* () {
109
+ const batchDelete = ({ tableName, keys, breakOnError = true, pkName, rangeName, rangeValue, }) => __awaiter(void 0, void 0, void 0, function* () {
110
110
  var _c, _d;
111
111
  (0, log_1.info)(`wipe keys dynamo:${tableName} - count=${keys.length}`);
112
112
  const error = [];
@@ -115,12 +115,14 @@ const batchDelete = ({ tableName, keys, breakOnError = true, pkName, }) => __awa
115
115
  if (breakV) {
116
116
  break;
117
117
  }
118
- const res = yield exports.dynamoDb
119
- .delete({
118
+ let params = {
120
119
  TableName: tableName,
121
- Key: { [`${pkName}`]: key },
122
- })
123
- .promise();
120
+ Key: { [pkName]: key },
121
+ };
122
+ if (rangeName) {
123
+ params.Key[rangeName] = rangeValue;
124
+ }
125
+ const res = yield exports.dynamoDb.delete(params).promise();
124
126
  const newError = (_d = (_c = res.$response) === null || _c === void 0 ? void 0 : _c.error) !== null && _d !== void 0 ? _d : null;
125
127
  if (newError) {
126
128
  error.push(newError);
@@ -12,8 +12,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.callOpenApi = void 0;
13
13
  const cookie_1 = require("./cookie");
14
14
  const sleep_1 = require("../../common/helpers/sleep");
15
+ const array_1 = require("../../common/helpers/array");
15
16
  const callOpenApi = ({ func, apiUrl, overrideAuth, refreshToken, logout, newDefaultApi, }) => __awaiter(void 0, void 0, void 0, function* () {
16
- var _a, _b, _c, _d, _e, _f;
17
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
17
18
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
19
  let error;
19
20
  let data;
@@ -49,11 +50,15 @@ const callOpenApi = ({ func, apiUrl, overrideAuth, refreshToken, logout, newDefa
49
50
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
51
  const ae = e;
51
52
  const status = (_c = ae.response) === null || _c === void 0 ? void 0 : _c.status;
52
- const errorMessage = (((_d = ae.response) === null || _d === void 0 ? void 0 : _d.data) ||
53
- ((_e = ae.response) === null || _e === void 0 ? void 0 : _e.statusText) ||
54
- ((_f = ae.response) === null || _f === void 0 ? void 0 : _f.status) ||
55
- ae.message ||
56
- 'ERROR');
53
+ const errorMessage = [
54
+ (_f = (_e = (_d = ae.response) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.toString()) !== null && _f !== void 0 ? _f : '',
55
+ (_j = (_h = (_g = ae.response) === null || _g === void 0 ? void 0 : _g.statusText) === null || _h === void 0 ? void 0 : _h.toString()) !== null && _j !== void 0 ? _j : '',
56
+ (_m = (_l = (_k = ae.response) === null || _k === void 0 ? void 0 : _k.status) === null || _l === void 0 ? void 0 : _l.toString()) !== null && _m !== void 0 ? _m : '',
57
+ (_p = (_o = ae.message) === null || _o === void 0 ? void 0 : _o.toString()) !== null && _p !== void 0 ? _p : '',
58
+ ]
59
+ .filter(array_1.notEmpty)
60
+ .sort((a, b) => (a.length < b.length ? -1 : 1))
61
+ .join('\n');
57
62
  if (status === 403 || status === 401) {
58
63
  logout();
59
64
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ag-common",
3
- "version": "0.0.77",
3
+ "version": "0.0.78",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Andrei Gec <@andreigec> (https://gec.dev/)",