Skip to content

Commit d65f78a

Browse files
committed
Refactor: Load configuration into dynamodb
1 parent 261a594 commit d65f78a

10 files changed

Lines changed: 3398 additions & 80 deletions

File tree

package-lock.json

Lines changed: 2709 additions & 79 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# DynamoDB Load CLI
2+
3+
A command-line tool for populating a DynamoDB table with NHS Notify supplier configuration data from an Excel file.
4+
5+
## Installation
6+
7+
This package is part of the nhs-notify-supplier-config monorepo. Install dependencies from the root:
8+
9+
```bash
10+
npm install
11+
```
12+
13+
## Usage
14+
15+
```bash
16+
# From the package directory
17+
npm run cli -- -f specs.xlsx -t my-config-table -r eu-west-2
18+
19+
# Dry run (preview items without writing)
20+
npm run cli -- -f specs.xlsx -t my-table --dry-run
21+
```
22+
23+
### Options
24+
25+
| Option | Alias | Description | Required |
26+
|--------|-------|-------------|----------|
27+
| `--file` | `-f` | Excel file path | No (default: specifications.xlsx) |
28+
| `--table` | `-t` | DynamoDB table name | Yes |
29+
| `--region` | `-r` | AWS region (fallback: AWS_REGION env) | No |
30+
| `--dry-run` | | Preview items without writing | No |
31+
32+
## DynamoDB Table Design
33+
34+
This tool uses a single-table design with the following PK/SK patterns:
35+
36+
| Entity | PK | SK |
37+
|--------|----|----|
38+
| VolumeGroup | `VOLUME_GROUP` | `<volumeGroupId>` |
39+
| Supplier | `SUPPLIER` | `<supplierId>` |
40+
| PackSpecification | `PACK_SPECIFICATION` | `<packSpecificationId>` |
41+
| LetterVariant | `LETTER_VARIANT` | `<letterVariantId>` |
42+
| SupplierAllocation | `SUPPLIER_ALLOCATION` | `<allocationId>` |
43+
| SupplierPack | `SUPPLIER_PACK` | `<supplierPackId>` |
44+
45+
## Dependencies
46+
47+
- `@nhs-notify/excel-parser` - For parsing Excel files
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import type { Config } from "jest";
2+
3+
const config: Config = {
4+
moduleNameMapper: {
5+
"^@supplier-config/cli-dynamodb-load/(.*)$": "<rootDir>/src/$1",
6+
},
7+
preset: "ts-jest",
8+
setupFiles: ["<rootDir>/src/__tests__/testcontainers-setup.ts"],
9+
testEnvironment: "node",
10+
testMatch: ["**/__tests__/**/*.test.ts"],
11+
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
12+
transform: {
13+
"^.+\\.tsx?$": [
14+
"@swc/jest",
15+
{
16+
jsc: {
17+
parser: {
18+
syntax: "typescript",
19+
tsx: false,
20+
},
21+
target: "es2022",
22+
},
23+
},
24+
],
25+
},
26+
};
27+
28+
export default config;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"bin": {
3+
"dynamodb-load": "dist/cli.js"
4+
},
5+
"dependencies": {
6+
"@aws-sdk/client-dynamodb": "^3.969.0",
7+
"@aws-sdk/util-dynamodb": "^3.969.0",
8+
"@supplier-config/excel-parser": "*",
9+
"yargs": "^17.7.2"
10+
},
11+
"devDependencies": {
12+
"@swc/core": "^1.11.13",
13+
"@swc/jest": "^0.2.37",
14+
"@tsconfig/node22": "^22.0.2",
15+
"@types/jest": "^29.5.14",
16+
"@types/yargs": "^17.0.32",
17+
"jest": "^29.7.0",
18+
"jest-mock-extended": "^3.0.7",
19+
"testcontainers": "^11.11.0",
20+
"typescript": "^5.9.3"
21+
},
22+
"name": "@supplier-config/cli-dynamodb-load",
23+
"private": true,
24+
"scripts": {
25+
"build": "tsc",
26+
"cli": "ts-node src/cli.ts",
27+
"lint": "eslint .",
28+
"lint:fix": "eslint . --fix",
29+
"test": "jest",
30+
"test:integration": "TESTCONTAINERS_RYUK_DISABLED=true jest --testPathPatterns=integration",
31+
"test:unit": "jest --testPathIgnorePatterns=integration",
32+
"typecheck": "tsc --noEmit"
33+
},
34+
"version": "0.0.1"
35+
}

0 commit comments

Comments
 (0)