Skip to content

Commit b3a9e77

Browse files
committed
Refactor: Publish configuration to eventbus
1 parent aeea68f commit b3a9e77

5 files changed

Lines changed: 190 additions & 176 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# EventBus Publish CLI
2+
3+
A command-line tool for publishing NHS Notify supplier configuration events to AWS EventBridge.
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+
# Parse an Excel file and output JSON
17+
npm run cli -- parse -f specs.xlsx
18+
19+
# Publish events to EventBridge
20+
npm run cli -- publish -f specs.xlsx -b my-bus -r eu-west-2
21+
22+
# Dry run (build events without sending)
23+
npm run cli -- publish -f specs.xlsx -b my-bus --dry-run
24+
```
25+
26+
### Commands
27+
28+
#### `parse`
29+
30+
Parse an Excel file and output the parsed data as JSON.
31+
32+
| Option | Alias | Description | Default |
33+
|--------|-------|-------------|---------|
34+
| `--file` | `-f` | Excel file path | specifications.xlsx |
35+
36+
#### `publish`
37+
38+
Build and publish events to EventBridge.
39+
40+
| Option | Alias | Description | Required |
41+
|--------|-------|-------------|----------|
42+
| `--file` | `-f` | Excel file path | No (default: specifications.xlsx) |
43+
| `--bus` | `-b` | EventBridge event bus name | Yes |
44+
| `--region` | `-r` | AWS region (fallback: AWS_REGION env) | No |
45+
| `--dry-run` | | Build events without sending | No |
46+
47+
## Event Types Published
48+
49+
Events are published in the following order:
50+
51+
1. VolumeGroup events
52+
2. Supplier events
53+
3. PackSpecification events
54+
4. SupplierPack events
55+
5. LetterVariant events
56+
6. SupplierAllocation events
57+
58+
Each event is assigned a sequence number to maintain ordering.
59+
60+
## Dependencies
61+
62+
- `@nhs-notify/event-builder` - For building events from domain objects
63+
- `@nhs-notify/excel-parser` - For parsing Excel files
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import type { Config } from "jest";
2+
3+
const config: Config = {
4+
moduleNameMapper: {
5+
"^@supplier-config/cli-eventbus-publish/(.*)$": "<rootDir>/src/$1",
6+
},
7+
preset: "ts-jest",
8+
testEnvironment: "node",
9+
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
10+
transform: {
11+
"^.+\\.tsx?$": [
12+
"@swc/jest",
13+
{
14+
jsc: {
15+
parser: {
16+
syntax: "typescript",
17+
tsx: false,
18+
},
19+
target: "es2022",
20+
},
21+
},
22+
],
23+
},
24+
};
25+
26+
export default config;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"bin": {
3+
"eventbus-publish": "dist/cli.js"
4+
},
5+
"dependencies": {
6+
"@aws-sdk/client-eventbridge": "^3.592.0",
7+
"@nhs-notify/event-builder": "workspace:*",
8+
"@nhs-notify/excel-parser": "workspace:*",
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+
"typescript": "^5.9.3"
20+
},
21+
"name": "@supplier-config/cli-eventbus-publish",
22+
"private": true,
23+
"scripts": {
24+
"build": "tsc",
25+
"cli": "ts-node src/cli.ts",
26+
"lint": "eslint .",
27+
"lint:fix": "eslint . --fix",
28+
"test": "jest",
29+
"test:unit": "jest",
30+
"typecheck": "tsc --noEmit"
31+
},
32+
"version": "0.0.1"
33+
}

0 commit comments

Comments
 (0)