@eresearchqut/ddb-repository 1.5.7 → 1.13.4

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/package.json CHANGED
@@ -1,14 +1,27 @@
1
1
  {
2
2
  "name": "@eresearchqut/ddb-repository",
3
- "version": "1.5.7",
3
+ "version": "1.13.4",
4
+ "type": "module",
4
5
  "description": "A TypeScript library providing a generic repository pattern implementation for AWS DynamoDB, simplifying CRUD operations and common database interactions.",
5
- "type": "commonjs",
6
- "main": "dist/index.js",
6
+ "main": "./dist/index.cjs",
7
+ "types": "./dist/index.d.cts",
8
+ "module": "./dist/index.mjs",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.cjs"
13
+ },
14
+ "./package.json": "./package.json"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
7
19
  "publishConfig": {
8
- "access": "public"
20
+ "access": "public",
21
+ "registry": "https://registry.npmjs.org"
9
22
  },
10
23
  "scripts": {
11
- "build": "tsc",
24
+ "build": "tsdown",
12
25
  "test": "jest",
13
26
  "test:watch": "jest --watch",
14
27
  "test:coverage": "jest --coverage",
@@ -16,32 +29,32 @@
16
29
  "lint:fix": "eslint . --ext .ts --fix"
17
30
  },
18
31
  "devDependencies": {
19
- "@aws-sdk/client-dynamodb": "^3.948.0",
20
- "@aws-sdk/util-dynamodb": "^3.948.0",
21
- "@eslint/js": "^9.39.1",
32
+ "@aws-sdk/client-dynamodb": "^3.993.0",
33
+ "@aws-sdk/util-dynamodb": "^3.993.0",
34
+ "@eslint/js": "^9.39.2",
22
35
  "@semantic-release/changelog": "^6.0.3",
23
36
  "@semantic-release/git": "^10.0.1",
24
37
  "@semantic-release/github": "^12.0.2",
25
38
  "@semantic-release/npm": "^13.1.2",
26
- "@smithy/types": "^4.9.0",
27
- "@testcontainers/localstack": "^11.10.0",
39
+ "@smithy/types": "^4.12.0",
28
40
  "@types/jest": "^30.0.0",
29
- "@types/lodash": "^4.17.21",
30
- "@types/node": "^25.0.0",
31
- "eslint": "^9.39.1",
32
- "eslint-plugin-jest": "^29.2.1",
41
+ "@types/lodash": "^4.17.23",
42
+ "@types/node": "^25.3.0",
43
+ "eslint": "^9.39.2",
44
+ "eslint-plugin-jest": "^29.15.0",
33
45
  "jest": "^30.2.0",
34
- "semantic-release": "^25.0.2",
35
- "testcontainers": "^11.10.0",
46
+ "semantic-release": "^25.0.3",
47
+ "testcontainers": "^11.12.0",
36
48
  "ts-jest": "^29.4.6",
37
49
  "ts-node": "^10.9.2",
50
+ "tsdown": "^0.20.3",
38
51
  "typescript": "^5.9.3",
39
- "typescript-eslint": "^8.49.0"
52
+ "typescript-eslint": "^8.56.0"
40
53
  },
41
54
  "peerDependencies": {
42
- "@aws-sdk/client-dynamodb": ">= 3.49.0",
43
- "@aws-sdk/util-dynamodb": ">= 3.49.0",
44
- "lodash": "^4.17.20"
55
+ "@aws-sdk/client-dynamodb": ">= 3.993.0",
56
+ "@aws-sdk/util-dynamodb": ">= 3.993.0",
57
+ "lodash": ">= 4.17.23"
45
58
  },
46
59
  "repository": {
47
60
  "type": "git",
@@ -1,61 +0,0 @@
1
- name: Build
2
-
3
- on:
4
- push:
5
- branches: [ main, develop ]
6
- pull_request:
7
- branches: [ main, develop ]
8
-
9
- jobs:
10
- build:
11
- runs-on: ubuntu-latest
12
- steps:
13
- - name: Checkout code
14
- uses: actions/checkout@v4
15
-
16
- - name: Setup Node.js
17
- uses: actions/setup-node@v4
18
- with:
19
- node-version: 'lts/*'
20
- registry-url: 'https://registry.npmjs.org'
21
-
22
- - name: Install dependencies
23
- run: npm ci
24
-
25
- - name: Run linter
26
- run: npm run lint
27
-
28
- - name: Run tests with coverage
29
- run: npm run test:coverage
30
-
31
- - name: Upload coverage reports to Codecov
32
- uses: codecov/codecov-action@v4
33
- with:
34
- file: ./coverage/lcov.info
35
- flags: unittests
36
- name: codecov-umbrella
37
- fail_ci_if_error: false
38
-
39
- - name: Upload coverage to Coveralls
40
- uses: coverallsapp/github-action@v2
41
- with:
42
- github-token: ${{ secrets.GITHUB_TOKEN }}
43
- path-to-lcov: ./coverage/lcov.info
44
- continue-on-error: true
45
-
46
- - name: Build package
47
- run: npm run build
48
-
49
- - name: Upload build artifacts
50
- uses: actions/upload-artifact@v4
51
- with:
52
- name: dist
53
- path: dist/
54
- retention-days: 7
55
-
56
- - name: Upload coverage artifacts
57
- uses: actions/upload-artifact@v4
58
- with:
59
- name: coverage-report
60
- path: coverage/
61
- retention-days: 7
@@ -1,34 +0,0 @@
1
- name: Release
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
-
8
- jobs:
9
- release:
10
- runs-on: ubuntu-latest
11
- permissions:
12
- contents: write
13
- issues: write
14
- pull-requests: write
15
- id-token: write
16
- steps:
17
- - name: Checkout
18
- uses: actions/checkout@v4
19
- with:
20
- fetch-depth: 0
21
- - name: Setup Node.js
22
- uses: actions/setup-node@v4
23
- with:
24
- node-version: 'lts/*'
25
- - name: Install dependencies
26
- run: npm clean-install
27
- - name: Build package
28
- run: npm run build
29
- - name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
30
- run: npm audit signatures
31
- - name: Semantic Release
32
- env:
33
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34
- run: npx semantic-release
package/.releaserc.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "branches": ["main"],
3
- "plugins": [
4
- "@semantic-release/commit-analyzer",
5
- "@semantic-release/release-notes-generator",
6
- "@semantic-release/changelog",
7
- "@semantic-release/npm",
8
- [
9
- "@semantic-release/git",
10
- {
11
- "assets": ["package.json", "package-lock.json", "CHANGELOG.md"],
12
- "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
13
- }
14
- ],
15
- "@semantic-release/github"
16
- ]
17
- }
package/CHANGELOG.md DELETED
@@ -1,93 +0,0 @@
1
- ## [1.5.7](https://github.com/eresearchqut/ddb-repository/compare/v1.5.6...v1.5.7) (2025-12-11)
2
-
3
-
4
- ### Bug Fixes
5
-
6
- * Publish to github ([e08ecfc](https://github.com/eresearchqut/ddb-repository/commit/e08ecfcf6bd01561ceb22191d7a264b630c0da95))
7
- * Publish to npm ([15dea85](https://github.com/eresearchqut/ddb-repository/commit/15dea854f65a00cbffd44e3984a96e8462c7c128))
8
-
9
- ## [1.5.6](https://github.com/eresearchqut/ddb-repository/compare/v1.5.5...v1.5.6) (2025-12-11)
10
-
11
-
12
- ### Bug Fixes
13
-
14
- * Adding NPM Publish ([6112d68](https://github.com/eresearchqut/ddb-repository/commit/6112d680e693114315ebfe63b6f542760098c76d))
15
-
16
- ## [1.5.5](https://github.com/eresearchqut/ddb-repository/compare/v1.5.4...v1.5.5) (2025-12-11)
17
-
18
-
19
- ### Bug Fixes
20
-
21
- * Adding NPM Publish ([8246366](https://github.com/eresearchqut/ddb-repository/commit/824636610a803b8a0bc07f4b1227f9ddde997de7))
22
-
23
- ## [1.5.4](https://github.com/eresearchqut/ddb-repository/compare/v1.5.3...v1.5.4) (2025-12-11)
24
-
25
-
26
- ### Bug Fixes
27
-
28
- * adding build to release action ([a396d9f](https://github.com/eresearchqut/ddb-repository/commit/a396d9f507ec7da3ebac7664f1d0641f8897280d))
29
-
30
- ## [1.5.3](https://github.com/eresearchqut/ddb-repository/compare/v1.5.2...v1.5.3) (2025-12-10)
31
-
32
-
33
- ### Bug Fixes
34
-
35
- * adding repository to package.json ([94961d2](https://github.com/eresearchqut/ddb-repository/commit/94961d22bd371742b4ed4309cfe118e95ea09958))
36
-
37
- ## [1.5.2](https://github.com/eresearchqut/ddb-repository/compare/v1.5.1...v1.5.2) (2025-12-10)
38
-
39
-
40
- ### Bug Fixes
41
-
42
- * release to npm ([274ef77](https://github.com/eresearchqut/ddb-repository/commit/274ef77b079d644571066e5c05a9edf3e4cf7396))
43
-
44
- ## [1.5.1](https://github.com/eresearchqut/ddb-repository/compare/v1.5.0...v1.5.1) (2025-12-10)
45
-
46
-
47
- ### Bug Fixes
48
-
49
- * Module type ([52a2a07](https://github.com/eresearchqut/ddb-repository/commit/52a2a07295bafcfa8b621fd59d085d7dfd567402))
50
- * package updates ([79d5672](https://github.com/eresearchqut/ddb-repository/commit/79d56725628a6ea0216b86a5c2d8f158fc008de6))
51
- * Updated installation instructions ([282e1fd](https://github.com/eresearchqut/ddb-repository/commit/282e1fd0d6ffe24a3caefa5e2c1e7067a348a3ce))
52
-
53
- # [1.5.0](https://github.com/eresearchqut/ddb-repository/compare/v1.4.1...v1.5.0) (2025-11-21)
54
-
55
-
56
- ### Features
57
-
58
- * Initialise the repository using options ([e3a2f46](https://github.com/eresearchqut/ddb-repository/commit/e3a2f46d3a8fb0ca467409369eef505d0451b6b0))
59
-
60
- ## [1.4.1](https://github.com/eresearchqut/ddb-repository/compare/v1.4.0...v1.4.1) (2025-11-21)
61
-
62
-
63
- ### Bug Fixes
64
-
65
- * Fix scope of internal methods ([c652753](https://github.com/eresearchqut/ddb-repository/commit/c652753156662fa08b818e0df068fbb2702881c9))
66
-
67
- # [1.4.0](https://github.com/eresearchqut/ddb-repository/compare/v1.3.0...v1.4.0) (2025-11-20)
68
-
69
-
70
- ### Features
71
-
72
- * Add test for the tracking of the consumed capacity and rename test class ([d113a5a](https://github.com/eresearchqut/ddb-repository/commit/d113a5a948a7dffc80e9d3a65a11203c2249ed26))
73
-
74
- # [1.3.0](https://github.com/eresearchqut/ddb-repository/compare/v1.2.0...v1.3.0) (2025-11-20)
75
-
76
-
77
- ### Features
78
-
79
- * Add test for the tracking of the consumed capacity ([4a1b23c](https://github.com/eresearchqut/ddb-repository/commit/4a1b23cadadbbb02d78507ca9d34715219fc952c))
80
-
81
- # [1.2.0](https://github.com/eresearchqut/ddb-repository/compare/v1.1.0...v1.2.0) (2025-11-19)
82
-
83
-
84
- ### Features
85
-
86
- * return the consumed capacity for each operation ([3910953](https://github.com/eresearchqut/ddb-repository/commit/391095398381a950c3393f9103d97d355c119538))
87
-
88
- # [1.1.0](https://github.com/eresearchqut/ddb-repository/compare/v1.0.2...v1.1.0) (2025-11-19)
89
-
90
-
91
- ### Features
92
-
93
- * NPM Package Badge ([fecd958](https://github.com/eresearchqut/ddb-repository/commit/fecd958d0d3725e0fc19f43f36e00eb7e5437716))
@@ -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; } });
package/eslint.config.mjs DELETED
@@ -1,13 +0,0 @@
1
- import eslint from '@eslint/js';
2
- import { defineConfig, globalIgnores } from 'eslint/config';
3
-
4
- import tseslint from 'typescript-eslint';
5
-
6
- export default defineConfig([
7
- globalIgnores([
8
- "node_modules/*", // ignore its content
9
- "dist/*",
10
- ])],
11
- eslint.configs.recommended,
12
- tseslint.configs.recommended,
13
- );
package/jest.config.ts DELETED
@@ -1,28 +0,0 @@
1
- import type { Config } from '@jest/types';
2
-
3
- const config: Config.InitialOptions = {
4
- preset: 'ts-jest',
5
- testEnvironment: 'node',
6
- roots: ['<rootDir>/src', '<rootDir>/test'],
7
- testMatch: ['**/*.test.ts', '**/*.spec.ts'],
8
- collectCoverage: false, // Set to true by default if you want coverage on every run
9
- collectCoverageFrom: [
10
- 'src/**/*.ts',
11
- '!src/**/*.d.ts',
12
- '!src/**/*.interface.ts',
13
- '!src/**/index.ts', // Typically just exports, can be excluded
14
- ],
15
- coverageDirectory: 'coverage',
16
- coverageReporters: [
17
- 'text', // Console output
18
- 'text-summary', // Summary in console
19
- 'html', // HTML report in coverage/
20
- 'lcov', // For CI/CD tools
21
- 'json', // JSON format
22
- ],
23
- moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
24
- verbose: true,
25
- testTimeout: 60000
26
- };
27
-
28
- export default config;