@eresearchqut/ddb-repository 1.5.7 → 1.5.8
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/dist/DynamoDbRepository.d.ts +50 -0
- package/dist/consumed-capacity-middleware.d.ts +10 -0
- package/dist/index.d.ts +2 -0
- package/package.json +6 -3
- package/.github/workflows/build.yml +0 -61
- package/.github/workflows/release.yml +0 -34
- package/.releaserc.json +0 -17
- package/CHANGELOG.md +0 -93
- package/eslint.config.mjs +0 -13
- package/jest.config.ts +0 -28
- package/src/DynamoDbRepository.ts +0 -379
- package/src/consumed-capacity-middleware.ts +0 -41
- package/src/index.ts +0 -4
- package/test/DynamoDbRepository.test.ts +0 -1216
- package/tsconfig.json +0 -12
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { DynamoDBClient, ReturnConsumedCapacity } from "@aws-sdk/client-dynamodb";
|
|
2
|
+
export declare enum FilterOperator {
|
|
3
|
+
EQUALS = "=",
|
|
4
|
+
NOT_EQUALS = "<>",
|
|
5
|
+
GREATER_THAN_OR_EQUALS = ">=",
|
|
6
|
+
GREATER_THAN = ">",
|
|
7
|
+
LESS_THAN = "<",
|
|
8
|
+
LESS_THAN_OR_EQUALS = "<=",
|
|
9
|
+
IN = "IN",
|
|
10
|
+
BETWEEN = "BETWEEN"
|
|
11
|
+
}
|
|
12
|
+
export interface FilterExpression {
|
|
13
|
+
attribute: string;
|
|
14
|
+
value: string | number | boolean | Array<string | number> | [string, string] | [number, number];
|
|
15
|
+
operator: FilterOperator;
|
|
16
|
+
negate?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface FilterableQuery {
|
|
19
|
+
filterExpressions: Array<FilterExpression>;
|
|
20
|
+
}
|
|
21
|
+
export interface ProjectedQuery {
|
|
22
|
+
projectedAttributes: string[];
|
|
23
|
+
}
|
|
24
|
+
export interface IndexedQuery {
|
|
25
|
+
index: string;
|
|
26
|
+
}
|
|
27
|
+
export interface Query extends Partial<FilterableQuery>, Partial<ProjectedQuery>, Partial<IndexedQuery> {
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
}
|
|
30
|
+
export interface DynamoDbRepositoryOptions {
|
|
31
|
+
client: DynamoDBClient;
|
|
32
|
+
tableName: string;
|
|
33
|
+
hashKey: string;
|
|
34
|
+
rangeKey?: string;
|
|
35
|
+
returnConsumedCapacity?: ReturnConsumedCapacity;
|
|
36
|
+
}
|
|
37
|
+
export declare class DynamoDbRepository<K, T> {
|
|
38
|
+
private readonly dynamoDBClient;
|
|
39
|
+
private readonly tableName;
|
|
40
|
+
private readonly hashKey;
|
|
41
|
+
private readonly rangKey?;
|
|
42
|
+
private readonly returnConsumedCapacity;
|
|
43
|
+
constructor(options: DynamoDbRepositoryOptions);
|
|
44
|
+
getItem: (key: K) => Promise<T | undefined>;
|
|
45
|
+
putItem: (key: K, record: T) => Promise<T>;
|
|
46
|
+
deleteItem: (key: K) => Promise<Record<string, any> | undefined>;
|
|
47
|
+
updateItem: (key: K, updates: Partial<T>, remove?: string[]) => Promise<T | undefined>;
|
|
48
|
+
getItems: (query: Query) => Promise<Array<T> | undefined>;
|
|
49
|
+
batchGetItems: (keys: K[], projectedQuery?: ProjectedQuery) => Promise<Array<T | undefined>>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ConsumedCapacity, ReturnConsumedCapacity } from "@aws-sdk/client-dynamodb";
|
|
2
|
+
import { HandlerExecutionContext, InitializeHandler, MetadataBearer } from "@smithy/types";
|
|
3
|
+
export interface ConsumedCapacityDetail {
|
|
4
|
+
ReturnConsumedCapacity: ReturnConsumedCapacity | undefined;
|
|
5
|
+
ConsumedCapacity: ConsumedCapacity | ConsumedCapacity[] | undefined;
|
|
6
|
+
}
|
|
7
|
+
export interface ConsumedCapacityMiddlewareConfig {
|
|
8
|
+
onConsumedCapacity: (consumedCapacity: ConsumedCapacityDetail) => Promise<unknown>;
|
|
9
|
+
}
|
|
10
|
+
export declare const consumedCapacityMiddleware: (consumedCapacityMiddlewareConfig: ConsumedCapacityMiddlewareConfig) => <Output extends MetadataBearer = MetadataBearer>(next: InitializeHandler<any, Output>, context: HandlerExecutionContext) => InitializeHandler<any, Output>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { Query, IndexedQuery, ProjectedQuery, FilterableQuery, FilterExpression, FilterOperator, DynamoDbRepository } from "./DynamoDbRepository";
|
|
2
|
+
export { consumedCapacityMiddleware, ConsumedCapacityDetail, ConsumedCapacityMiddlewareConfig } from "./consumed-capacity-middleware";
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eresearchqut/ddb-repository",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.8",
|
|
4
4
|
"description": "A TypeScript library providing a generic repository pattern implementation for AWS DynamoDB, simplifying CRUD operations and common database interactions.",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"main": "dist/index",
|
|
6
|
+
"types": "dist/index",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
7
10
|
"publishConfig": {
|
|
8
11
|
"access": "public"
|
|
9
12
|
},
|
|
@@ -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))
|
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;
|