Skip to content

Commit 1e68b4d

Browse files
updates
1 parent 66ef8ef commit 1e68b4d

9 files changed

Lines changed: 47 additions & 24 deletions

File tree

.github/workflows/stage-2-test.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
timeout-minutes: 5
4848
steps:
4949
- name: "Checkout code"
50-
uses: actions/checkout@v4
50+
uses: actions/checkout@v5
5151
- name: "Repo setup"
5252
run: |
5353
npm ci
@@ -61,7 +61,7 @@ jobs:
6161
timeout-minutes: 5
6262
steps:
6363
- name: "Checkout code"
64-
uses: actions/checkout@v4
64+
uses: actions/checkout@v5
6565
- name: "Repo setup"
6666
run: |
6767
npm ci
@@ -89,7 +89,7 @@ jobs:
8989
timeout-minutes: 5
9090
steps:
9191
- name: "Checkout code"
92-
uses: actions/checkout@v4
92+
uses: actions/checkout@v5
9393
- name: "Repo setup"
9494
run: |
9595
npm ci
@@ -105,7 +105,7 @@ jobs:
105105
timeout-minutes: 5
106106
steps:
107107
- name: "Checkout code"
108-
uses: actions/checkout@v4
108+
uses: actions/checkout@v5
109109
- name: "Repo setup"
110110
run: |
111111
npm ci

packages/event-builder/README.md

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,46 @@
1-
# CSV to Event Generator CLI
1+
# About
22

3-
## Usage
3+
CLI tool for client configuration using events.
44

5-
1. Place the CSV file in the `event-builder/inputs` folder e.g `sample.csv`. All headers must be provided with values:
6-
- `Client ID` - the ID of the client you want to create. This can be generated with an online UUID generator.
7-
- `Client Name` - the name of the client
8-
- `APIM ID` - the APIM Application ID for the client
5+
## Global Options
96

10-
Multiple rows can be added to process more than one client.
7+
- --environment - The name of the environment to run the command on e.g 'de2-', 'int'. Required.
8+
- --format - print data in JSON or tabular format. Default is JSON.
119

12-
2. From the `event-builder` folder, run:
10+
## Client Config Commands
11+
12+
- Create Client
13+
14+
## Create Client
15+
16+
- creates client using the most minimal client details required and defaults.
17+
18+
### Options
19+
20+
`--csv-file`: the path to the CSV file containing client details
21+
22+
**Note:** All headers in the CSV file must be provided with values:
23+
24+
- `Client ID` - the ID of the client you want to create. This can be generated with an online UUID generator.
25+
- `Client Name` - the name of the client.
26+
- `APIM ID` - the APIM Application ID for the client.
27+
28+
Multiple rows can be added to process more than one client.
29+
30+
### Usage
31+
32+
From the root folder i.e `nhs-notify-client-config`, run:
1333

1434
```bash
15-
npm run --workspace=nhs-notify-client-config-event-builder cli -- generate-event \
35+
npm run --workspace=nhs-notify-client-config-event-builder cli -- create-client \
1636
--csv-file <path to file> \
1737
--environment <<env>>
1838
```
1939
2040
## Example
2141
2242
```bash
23-
npm run --workspace=nhs-notify-client-config-event-builder cli -- generate-event \
24-
--csv-file ../inputs/sample.csv \
43+
npm run --workspace=nhs-notify-client-config-event-builder cli -- create-client \
44+
--csv-file inputs/sample.csv \
2545
--environment de2-aiyu1
2646
```
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1+
import path from "path";
12
import { convertCSV } from "../csv-to-client-input";
23

34
const invalidCases = [
4-
{ type: "invalid headers", path: "test-data/invalid-headers.csv", msg: "CSV headers do not match expected." },
5-
{ type: "empty rows", path: "test-data/empty-rows.csv", msg: "No client data provided." },
6-
{ type: "missing data in row", path: "test-data/missing-data.csv", msg: "Missing data in row for client ID: client-id-1." }
5+
{ type: "invalid headers", relativePath: "test-data/invalid-headers.csv", msg: "CSV headers do not match expected." },
6+
{ type: "empty rows", relativePath: "test-data/empty-rows.csv", msg: "No client data provided." },
7+
{ type: "missing data in row", relativePath: "test-data/missing-data.csv", msg: "Missing data in row for client ID: client-id-1." }
78
]
89

910
describe("test that csv inputs get parsed as expected", () => {
1011

1112
it("should successfully parse csv", () => {
12-
const filePath = "test-data/valid.csv";
13+
const filePath = path.join(__dirname, "test-data/valid.csv");
1314

1415
const result = convertCSV(filePath);
1516

@@ -19,8 +20,11 @@ describe("test that csv inputs get parsed as expected", () => {
1920
expect(result.map(item => item.clientId)).toEqual((["1","2","3","4"]));
2021
});
2122

22-
it.each(invalidCases)('should throw error: "%s" for case: %s:', ({ msg, type, path }) => {
23-
expect(() => convertCSV(path)).toThrow(msg);
23+
it.each(invalidCases)('should throw error: "%s" for case: %s:', ({ msg, type, relativePath }) => {
24+
25+
const filePath = path.join(__dirname, relativePath);
26+
27+
expect(() => convertCSV(filePath)).toThrow(msg);
2428
});
2529

2630
});

packages/event-builder/src/test-data/empty-rows.csv renamed to packages/event-builder/src/__tests__/test-data/empty-rows.csv

File renamed without changes.

packages/event-builder/src/test-data/invalid-headers.csv renamed to packages/event-builder/src/__tests__/test-data/invalid-headers.csv

File renamed without changes.

packages/event-builder/src/test-data/missing-data.csv renamed to packages/event-builder/src/__tests__/test-data/missing-data.csv

File renamed without changes.
File renamed without changes.

packages/event-builder/src/cli/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async function main() {
4141
})
4242
.middleware(setGlobals)
4343
.command(
44-
'generate-event',
44+
'create-client',
4545
'generates the client mutated event and saved onto a queue',
4646
{
4747
'csv-file': {

packages/event-builder/src/csv-to-client-input.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import fs from "fs";
2-
import path from "path";
32
import { parse } from "csv-parse/sync";
43
import { ClientInput } from './input'
54

@@ -16,7 +15,7 @@ const csvHeaders = [
1615
]
1716

1817
export const convertCSV = (filePath: string): ClientInput[] => {
19-
const csvFile = fs.readFileSync(path.join(__dirname, filePath), "utf-8");
18+
const csvFile = fs.readFileSync(filePath, "utf-8");
2019

2120
if(!validateHeaders(csvFile, csvHeaders)) {
2221
throw new Error("CSV headers do not match expected.");

0 commit comments

Comments
 (0)