@eresearchqut/ddb-repository 1.5.0 → 1.5.3
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/.github/workflows/release.yml +3 -13
- package/CHANGELOG.md +23 -0
- package/README.md +1 -1
- package/package.json +18 -14
- package/dist/DynamoDbRepository.js +0 -244
- package/dist/consumed-capacity-middleware.js +0 -25
- package/dist/index.js +0 -8
|
@@ -18,25 +18,15 @@ jobs:
|
|
|
18
18
|
uses: actions/checkout@v4
|
|
19
19
|
with:
|
|
20
20
|
fetch-depth: 0
|
|
21
|
-
persist-credentials: false
|
|
22
|
-
|
|
23
21
|
- name: Setup Node.js
|
|
24
22
|
uses: actions/setup-node@v4
|
|
25
23
|
with:
|
|
26
24
|
node-version: 'lts/*'
|
|
27
|
-
|
|
28
25
|
- name: Install dependencies
|
|
29
|
-
run: npm
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
run: npm test
|
|
33
|
-
|
|
34
|
-
- name: Build
|
|
35
|
-
run: npm run build
|
|
36
|
-
|
|
26
|
+
run: npm clean-install
|
|
27
|
+
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
|
|
28
|
+
run: npm audit signatures
|
|
37
29
|
- name: Release
|
|
38
30
|
env:
|
|
39
31
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
40
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
41
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
42
32
|
run: npx semantic-release
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
## [1.5.3](https://github.com/eresearchqut/ddb-repository/compare/v1.5.2...v1.5.3) (2025-12-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* adding repository to package.json ([94961d2](https://github.com/eresearchqut/ddb-repository/commit/94961d22bd371742b4ed4309cfe118e95ea09958))
|
|
7
|
+
|
|
8
|
+
## [1.5.2](https://github.com/eresearchqut/ddb-repository/compare/v1.5.1...v1.5.2) (2025-12-10)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* release to npm ([274ef77](https://github.com/eresearchqut/ddb-repository/commit/274ef77b079d644571066e5c05a9edf3e4cf7396))
|
|
14
|
+
|
|
15
|
+
## [1.5.1](https://github.com/eresearchqut/ddb-repository/compare/v1.5.0...v1.5.1) (2025-12-10)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* Module type ([52a2a07](https://github.com/eresearchqut/ddb-repository/commit/52a2a07295bafcfa8b621fd59d085d7dfd567402))
|
|
21
|
+
* package updates ([79d5672](https://github.com/eresearchqut/ddb-repository/commit/79d56725628a6ea0216b86a5c2d8f158fc008de6))
|
|
22
|
+
* Updated installation instructions ([282e1fd](https://github.com/eresearchqut/ddb-repository/commit/282e1fd0d6ffe24a3caefa5e2c1e7067a348a3ce))
|
|
23
|
+
|
|
1
24
|
# [1.5.0](https://github.com/eresearchqut/ddb-repository/compare/v1.4.1...v1.5.0) (2025-11-21)
|
|
2
25
|
|
|
3
26
|
|
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eresearchqut/ddb-repository",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.3",
|
|
4
4
|
"description": "",
|
|
5
|
-
"type": "
|
|
5
|
+
"type": "commonjs",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
@@ -16,31 +16,35 @@
|
|
|
16
16
|
"lint:fix": "eslint . --ext .ts --fix"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@aws-sdk/client-dynamodb": "^3.
|
|
20
|
-
"@aws-sdk/util-dynamodb": "^3.
|
|
19
|
+
"@aws-sdk/client-dynamodb": "^3.948.0",
|
|
20
|
+
"@aws-sdk/util-dynamodb": "^3.948.0",
|
|
21
21
|
"@eslint/js": "^9.39.1",
|
|
22
22
|
"@semantic-release/changelog": "^6.0.3",
|
|
23
23
|
"@semantic-release/git": "^10.0.1",
|
|
24
24
|
"@semantic-release/github": "^12.0.2",
|
|
25
25
|
"@semantic-release/npm": "^13.1.2",
|
|
26
26
|
"@smithy/types": "^4.9.0",
|
|
27
|
-
"@testcontainers/localstack": "^10.
|
|
28
|
-
"@types/jest": "^
|
|
29
|
-
"@types/lodash": "^4.17.
|
|
30
|
-
"@types/node": "^
|
|
27
|
+
"@testcontainers/localstack": "^11.10.0",
|
|
28
|
+
"@types/jest": "^30.0.0",
|
|
29
|
+
"@types/lodash": "^4.17.21",
|
|
30
|
+
"@types/node": "^25.0.0",
|
|
31
31
|
"eslint": "^9.39.1",
|
|
32
|
-
"eslint-plugin-jest": "^29.1
|
|
33
|
-
"jest": "^
|
|
32
|
+
"eslint-plugin-jest": "^29.2.1",
|
|
33
|
+
"jest": "^30.2.0",
|
|
34
34
|
"semantic-release": "^25.0.2",
|
|
35
|
-
"testcontainers": "^10.
|
|
36
|
-
"ts-jest": "^29.
|
|
35
|
+
"testcontainers": "^11.10.0",
|
|
36
|
+
"ts-jest": "^29.4.6",
|
|
37
37
|
"ts-node": "^10.9.2",
|
|
38
|
-
"typescript": "^5.
|
|
39
|
-
"typescript-eslint": "^8.
|
|
38
|
+
"typescript": "^5.9.3",
|
|
39
|
+
"typescript-eslint": "^8.49.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@aws-sdk/client-dynamodb": ">= 3.49.0",
|
|
43
43
|
"@aws-sdk/util-dynamodb": ">= 3.49.0",
|
|
44
44
|
"lodash": "^4.17.20"
|
|
45
|
+
},
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "git+https://github.com/eresearchqut/ddb-repository.git"
|
|
45
49
|
}
|
|
46
50
|
}
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
|
-
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
23
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
24
|
-
var m = o[Symbol.asyncIterator], i;
|
|
25
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
26
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
27
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
28
|
-
};
|
|
29
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.DynamoDbRepository = exports.FilterOperator = void 0;
|
|
31
|
-
const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
|
|
32
|
-
const util_dynamodb_1 = require("@aws-sdk/util-dynamodb");
|
|
33
|
-
const lodash_1 = require("lodash");
|
|
34
|
-
var FilterOperator;
|
|
35
|
-
(function (FilterOperator) {
|
|
36
|
-
FilterOperator["EQUALS"] = "=";
|
|
37
|
-
FilterOperator["NOT_EQUALS"] = "<>";
|
|
38
|
-
FilterOperator["GREATER_THAN_OR_EQUALS"] = ">=";
|
|
39
|
-
FilterOperator["GREATER_THAN"] = ">";
|
|
40
|
-
FilterOperator["LESS_THAN"] = "<";
|
|
41
|
-
FilterOperator["LESS_THAN_OR_EQUALS"] = "<=";
|
|
42
|
-
FilterOperator["IN"] = "IN";
|
|
43
|
-
FilterOperator["BETWEEN"] = "BETWEEN";
|
|
44
|
-
})(FilterOperator || (exports.FilterOperator = FilterOperator = {}));
|
|
45
|
-
const expressionAttributeKey = (key) => (0, lodash_1.replace)(key, /-/g, "_");
|
|
46
|
-
const mapInKeys = (filterExpression) => Array.isArray(filterExpression.value)
|
|
47
|
-
? filterExpression.value.map((_, index) => `:${filterExpression.attribute}${index}`)
|
|
48
|
-
: `:${filterExpression.attribute}`;
|
|
49
|
-
const mapFilterExpression = (filterExpression) => {
|
|
50
|
-
switch (filterExpression.operator) {
|
|
51
|
-
case FilterOperator.IN:
|
|
52
|
-
return (`#${expressionAttributeKey(filterExpression.attribute)} ${filterExpression.operator} ` +
|
|
53
|
-
`(${mapInKeys(filterExpression)})`);
|
|
54
|
-
case FilterOperator.BETWEEN:
|
|
55
|
-
return (`#${expressionAttributeKey(filterExpression.attribute)} ${filterExpression.operator} ` +
|
|
56
|
-
`:${expressionAttributeKey(filterExpression.attribute)}0 AND :${expressionAttributeKey(filterExpression.attribute)}1`);
|
|
57
|
-
default:
|
|
58
|
-
return (`#${expressionAttributeKey(filterExpression.attribute)} ${filterExpression.operator} ` +
|
|
59
|
-
`:${expressionAttributeKey(filterExpression.attribute)}`);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
const mapFilterExpressions = (filterExpressions) => filterExpressions
|
|
63
|
-
.map((filterExpression) => filterExpression.negate
|
|
64
|
-
? `NOT ${mapFilterExpression(filterExpression)}`
|
|
65
|
-
: mapFilterExpression(filterExpression))
|
|
66
|
-
.join(" AND ");
|
|
67
|
-
const mapFilterExpressionValues = (filterExpression) => Array.isArray(filterExpression.value)
|
|
68
|
-
? filterExpression.value.reduce((reduction, value, index) => (Object.assign(Object.assign({}, reduction), { [`:${expressionAttributeKey(filterExpression.attribute)}${index}`]: value })), Object.assign({}))
|
|
69
|
-
: {
|
|
70
|
-
[`:${expressionAttributeKey(filterExpression.attribute)}`]: filterExpression.value,
|
|
71
|
-
};
|
|
72
|
-
const paginate = (array, pageSize) => {
|
|
73
|
-
return array.reduce((acc, val, i) => {
|
|
74
|
-
const idx = Math.floor(i / pageSize);
|
|
75
|
-
const page = acc[idx] || (acc[idx] = []);
|
|
76
|
-
page.push(val);
|
|
77
|
-
return acc;
|
|
78
|
-
}, []);
|
|
79
|
-
};
|
|
80
|
-
class DynamoDbRepository {
|
|
81
|
-
constructor(options) {
|
|
82
|
-
var _a;
|
|
83
|
-
this.getItem = (key) => __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
return this.dynamoDBClient
|
|
85
|
-
.send(new client_dynamodb_1.GetItemCommand({
|
|
86
|
-
TableName: this.tableName,
|
|
87
|
-
Key: (0, util_dynamodb_1.marshall)(key, { removeUndefinedValues: true }),
|
|
88
|
-
ReturnConsumedCapacity: this.returnConsumedCapacity,
|
|
89
|
-
}))
|
|
90
|
-
.then((result) => result.Item ? (0, util_dynamodb_1.unmarshall)(result.Item) : undefined);
|
|
91
|
-
});
|
|
92
|
-
this.putItem = (key, record) => __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
const Item = (0, util_dynamodb_1.marshall)(Object.assign(Object.assign({}, record), key), { removeUndefinedValues: true });
|
|
94
|
-
return this.dynamoDBClient
|
|
95
|
-
.send(new client_dynamodb_1.PutItemCommand({
|
|
96
|
-
TableName: this.tableName,
|
|
97
|
-
ReturnConsumedCapacity: this.returnConsumedCapacity,
|
|
98
|
-
Item,
|
|
99
|
-
}))
|
|
100
|
-
.then(() => this.getItem(key));
|
|
101
|
-
});
|
|
102
|
-
this.deleteItem = (key) => __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
return this.dynamoDBClient.send(new client_dynamodb_1.DeleteItemCommand({
|
|
104
|
-
TableName: this.tableName,
|
|
105
|
-
Key: (0, util_dynamodb_1.marshall)(key),
|
|
106
|
-
})).then((result) => result.Attributes ?
|
|
107
|
-
(0, util_dynamodb_1.unmarshall)(result.Attributes) : undefined);
|
|
108
|
-
});
|
|
109
|
-
this.updateItem = (key, updates, remove) => __awaiter(this, void 0, void 0, function* () {
|
|
110
|
-
const hasUpdates = Object.keys(updates).length > 0;
|
|
111
|
-
const setAttributesExpression = hasUpdates ? `SET ${Object.entries(updates)
|
|
112
|
-
.filter(([, value]) => value !== undefined)
|
|
113
|
-
.map(([key]) => `#${expressionAttributeKey(key)} = :${expressionAttributeKey(key)}`)
|
|
114
|
-
.join(", ")}` : '';
|
|
115
|
-
const removeAttributesExpression = remove
|
|
116
|
-
? ` REMOVE ${remove.map((key) => `#${expressionAttributeKey(key)}`).join(", ")}`
|
|
117
|
-
: "";
|
|
118
|
-
const removeAttributeNames = remove
|
|
119
|
-
? remove.map(expressionAttributeKey).reduce((acc, key) => (Object.assign(Object.assign({}, acc), { [`#${expressionAttributeKey(key)}`]: key })), {})
|
|
120
|
-
: {};
|
|
121
|
-
const updateItemCommandInput = {
|
|
122
|
-
TableName: this.tableName,
|
|
123
|
-
Key: (0, util_dynamodb_1.marshall)(key),
|
|
124
|
-
UpdateExpression: `${setAttributesExpression}${removeAttributesExpression}`,
|
|
125
|
-
ExpressionAttributeNames: Object.entries(updates)
|
|
126
|
-
.filter(([, value]) => value !== undefined)
|
|
127
|
-
.reduce((acc, [key]) => (Object.assign(Object.assign({}, acc), { [`#${expressionAttributeKey(key)}`]: key })), Object.assign(removeAttributeNames)),
|
|
128
|
-
ExpressionAttributeValues: hasUpdates ? (0, util_dynamodb_1.marshall)(Object.entries(updates).reduce((acc, [key, value]) => (Object.assign(Object.assign({}, acc), { [`:${expressionAttributeKey(key)}`]: value })), Object.assign({})), { removeUndefinedValues: true }) : undefined,
|
|
129
|
-
ReturnConsumedCapacity: this.returnConsumedCapacity,
|
|
130
|
-
};
|
|
131
|
-
return this.dynamoDBClient
|
|
132
|
-
.send(new client_dynamodb_1.UpdateItemCommand(updateItemCommandInput))
|
|
133
|
-
.then(() => this.getItem(key));
|
|
134
|
-
});
|
|
135
|
-
this.getItems = (query) => __awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
var _a, e_1, _b, _c, _d, e_2, _e, _f;
|
|
137
|
-
var _g;
|
|
138
|
-
const { index, filterExpressions, projectedAttributes } = query, keys = __rest(query, ["index", "filterExpressions", "projectedAttributes"]);
|
|
139
|
-
const KeyConditionExpression = Object.keys(keys)
|
|
140
|
-
.map((key) => `#${expressionAttributeKey(key)} = :${expressionAttributeKey(key)}`).join(' AND ');
|
|
141
|
-
const keyExpressionAttributeNames = Object.keys(keys)
|
|
142
|
-
.reduce((acc, key) => (Object.assign(Object.assign({}, acc), { [`#${expressionAttributeKey(key)}`]: key })), Object.assign({}));
|
|
143
|
-
const keyExpressionAttributeValues = Object.entries(keys)
|
|
144
|
-
.reduce((acc, [key, value]) => (Object.assign(Object.assign({}, acc), { [`:${expressionAttributeKey(key)}`]: value })), Object.assign({}));
|
|
145
|
-
const ProjectionExpression = !index && projectedAttributes
|
|
146
|
-
? projectedAttributes.map((attribute) => `#${expressionAttributeKey(attribute)}`).join(',')
|
|
147
|
-
: undefined;
|
|
148
|
-
const projectionAttributeNames = !index && projectedAttributes ? projectedAttributes.reduce((reduction, attribute) => (Object.assign(Object.assign({}, reduction), { [`#${expressionAttributeKey(attribute)}`]: attribute })), Object.assign({})) : {};
|
|
149
|
-
const hasFilterExpressions = Array.isArray(filterExpressions) && filterExpressions.length > 0;
|
|
150
|
-
const FilterExpression = hasFilterExpressions
|
|
151
|
-
? mapFilterExpressions(filterExpressions)
|
|
152
|
-
: undefined;
|
|
153
|
-
const filterAttributeNames = hasFilterExpressions
|
|
154
|
-
? filterExpressions.reduce((reduction, filterExpression) => (Object.assign(Object.assign({}, reduction), { [`#${expressionAttributeKey(filterExpression.attribute)}`]: filterExpression.attribute })), Object.assign({}))
|
|
155
|
-
: {};
|
|
156
|
-
const filterAttributeValues = filterExpressions
|
|
157
|
-
? filterExpressions.reduce((reduction, filterExpression) => (Object.assign(Object.assign({}, reduction), mapFilterExpressionValues(filterExpression))), Object.assign({}))
|
|
158
|
-
: {};
|
|
159
|
-
const queryCommandInput = {
|
|
160
|
-
TableName: this.tableName,
|
|
161
|
-
ReturnConsumedCapacity: this.returnConsumedCapacity,
|
|
162
|
-
IndexName: index,
|
|
163
|
-
KeyConditionExpression,
|
|
164
|
-
FilterExpression,
|
|
165
|
-
ProjectionExpression,
|
|
166
|
-
ExpressionAttributeNames: Object.assign(Object.assign(Object.assign({}, keyExpressionAttributeNames), filterAttributeNames), projectionAttributeNames),
|
|
167
|
-
ExpressionAttributeValues: (0, util_dynamodb_1.marshall)(Object.assign(Object.assign({}, keyExpressionAttributeValues), filterAttributeValues), { removeUndefinedValues: true }),
|
|
168
|
-
};
|
|
169
|
-
const paginator = (0, client_dynamodb_1.paginateQuery)({ client: this.dynamoDBClient, pageSize: 100 }, queryCommandInput);
|
|
170
|
-
if (index) {
|
|
171
|
-
const keys = [];
|
|
172
|
-
try {
|
|
173
|
-
for (var _h = true, paginator_1 = __asyncValues(paginator), paginator_1_1; paginator_1_1 = yield paginator_1.next(), _a = paginator_1_1.done, !_a; _h = true) {
|
|
174
|
-
_c = paginator_1_1.value;
|
|
175
|
-
_h = false;
|
|
176
|
-
const page = _c;
|
|
177
|
-
if (page.Items) {
|
|
178
|
-
keys.push(...(page.Items.map((item) => (0, util_dynamodb_1.unmarshall)(item))
|
|
179
|
-
.map((item) => (0, lodash_1.pickBy)(item, (_, key) => (key === this.hashKey || key === this.rangKey)))));
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
184
|
-
finally {
|
|
185
|
-
try {
|
|
186
|
-
if (!_h && !_a && (_b = paginator_1.return)) yield _b.call(paginator_1);
|
|
187
|
-
}
|
|
188
|
-
finally { if (e_1) throw e_1.error; }
|
|
189
|
-
}
|
|
190
|
-
const items = yield this.batchGetItems(keys, query);
|
|
191
|
-
return items;
|
|
192
|
-
}
|
|
193
|
-
const items = [];
|
|
194
|
-
try {
|
|
195
|
-
for (var _j = true, paginator_2 = __asyncValues(paginator), paginator_2_1; paginator_2_1 = yield paginator_2.next(), _d = paginator_2_1.done, !_d; _j = true) {
|
|
196
|
-
_f = paginator_2_1.value;
|
|
197
|
-
_j = false;
|
|
198
|
-
const page = _f;
|
|
199
|
-
if (page.Items) {
|
|
200
|
-
items.push(...(((_g = page.Items) === null || _g === void 0 ? void 0 : _g.map((item) => (0, util_dynamodb_1.unmarshall)(item))) || []));
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
205
|
-
finally {
|
|
206
|
-
try {
|
|
207
|
-
if (!_j && !_d && (_e = paginator_2.return)) yield _e.call(paginator_2);
|
|
208
|
-
}
|
|
209
|
-
finally { if (e_2) throw e_2.error; }
|
|
210
|
-
}
|
|
211
|
-
return items;
|
|
212
|
-
});
|
|
213
|
-
this.batchGetItems = (keys, projectedQuery) => __awaiter(this, void 0, void 0, function* () {
|
|
214
|
-
const uniqueKeys = (0, lodash_1.uniqWith)(keys, lodash_1.isEqual);
|
|
215
|
-
const keyPages = paginate(uniqueKeys, 100);
|
|
216
|
-
const { projectedAttributes } = projectedQuery || {};
|
|
217
|
-
const ProjectionExpression = projectedAttributes
|
|
218
|
-
? projectedAttributes.map((attribute) => `#${expressionAttributeKey(attribute)}`).join(',')
|
|
219
|
-
: undefined;
|
|
220
|
-
const ExpressionAttributeNames = projectedAttributes ?
|
|
221
|
-
projectedAttributes.reduce((reduction, attribute) => (Object.assign(Object.assign({}, reduction), { [`#${expressionAttributeKey(attribute)}`]: attribute })), Object.assign({})) : undefined;
|
|
222
|
-
return Promise.all((keyPages.map((keyPage) => __awaiter(this, void 0, void 0, function* () {
|
|
223
|
-
const batchRequest = {
|
|
224
|
-
RequestItems: {
|
|
225
|
-
[this.tableName]: {
|
|
226
|
-
Keys: keyPage.map((key) => ((0, util_dynamodb_1.marshall)(key))),
|
|
227
|
-
ProjectionExpression,
|
|
228
|
-
ExpressionAttributeNames,
|
|
229
|
-
}
|
|
230
|
-
},
|
|
231
|
-
ReturnConsumedCapacity: this.returnConsumedCapacity,
|
|
232
|
-
};
|
|
233
|
-
return this.dynamoDBClient.send(new client_dynamodb_1.BatchGetItemCommand(batchRequest)).then(result => { var _a; return (_a = result.Responses) === null || _a === void 0 ? void 0 : _a[this.tableName].map((item) => (0, util_dynamodb_1.unmarshall)(item)); });
|
|
234
|
-
}))))
|
|
235
|
-
.then((itemSets) => itemSets.flat());
|
|
236
|
-
});
|
|
237
|
-
this.dynamoDBClient = options.client;
|
|
238
|
-
this.tableName = options.tableName;
|
|
239
|
-
this.hashKey = options.hashKey;
|
|
240
|
-
this.rangKey = options.rangeKey;
|
|
241
|
-
this.returnConsumedCapacity = (_a = options.returnConsumedCapacity) !== null && _a !== void 0 ? _a : client_dynamodb_1.ReturnConsumedCapacity.TOTAL;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
exports.DynamoDbRepository = DynamoDbRepository;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.consumedCapacityMiddleware = void 0;
|
|
13
|
-
const lodash_1 = require("lodash");
|
|
14
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
15
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
16
|
-
const consumedCapacityMiddleware = (consumedCapacityMiddlewareConfig) => (next, context) => (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
-
const { input } = args;
|
|
18
|
-
const { ReturnConsumedCapacity } = input;
|
|
19
|
-
const response = yield next(args);
|
|
20
|
-
const { output } = response;
|
|
21
|
-
const consumedCapacity = (0, lodash_1.get)(output, "ConsumedCapacity");
|
|
22
|
-
yield consumedCapacityMiddlewareConfig.onConsumedCapacity({ ReturnConsumedCapacity, ConsumedCapacity: consumedCapacity });
|
|
23
|
-
return response;
|
|
24
|
-
});
|
|
25
|
-
exports.consumedCapacityMiddleware = consumedCapacityMiddleware;
|
package/dist/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.consumedCapacityMiddleware = exports.DynamoDbRepository = exports.FilterOperator = void 0;
|
|
4
|
-
var DynamoDbRepository_1 = require("./DynamoDbRepository");
|
|
5
|
-
Object.defineProperty(exports, "FilterOperator", { enumerable: true, get: function () { return DynamoDbRepository_1.FilterOperator; } });
|
|
6
|
-
Object.defineProperty(exports, "DynamoDbRepository", { enumerable: true, get: function () { return DynamoDbRepository_1.DynamoDbRepository; } });
|
|
7
|
-
var consumed_capacity_middleware_1 = require("./consumed-capacity-middleware");
|
|
8
|
-
Object.defineProperty(exports, "consumedCapacityMiddleware", { enumerable: true, get: function () { return consumed_capacity_middleware_1.consumedCapacityMiddleware; } });
|