You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AGENTS.md
+49-5Lines changed: 49 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,9 +8,13 @@ This is a monorepo containing:
8
8
9
9
-**packages/events** - Event schemas and domain models using Zod
10
10
-**packages/event-builder** - CloudEvent builders for domain objects
11
+
-**packages/file-store** - Loads on-disk config stores and validates records against the Zod schemas
12
+
-**packages/ddb-publisher** - CLI and release bundle for auditing and publishing config-store records into DynamoDB
11
13
-**lambdas/** - Lambda function implementations
12
14
-**infrastructure/** - Terraform infrastructure as code
13
15
-**docs/** - Documentation site
16
+
-**actions/ddb-publish** - Composite GitHub Action wrapper around the bundled DynamoDB publisher
17
+
-**tests/example-config-store** - Minimal end-to-end config-store fixture used by CLI and integration tests
14
18
15
19
## Event Builder Package
16
20
@@ -46,6 +50,8 @@ The event-builder package provides functions to build CloudEvents from domain ob
46
50
47
51
All functions accept domain objects and a starting counter, returning an array of CloudEvents.
48
52
53
+
The package also exports single-record builders (`buildLetterVariantEvent()`, `buildPackSpecificationEvent()`, `buildSupplierEvent()`, `buildVolumeGroupEvent()`, `buildSupplierAllocationEvent()`, `buildSupplierPackEvent()`), plus `configFromEnv()`, `buildEventSource()`, and `buildBaseEventEnvelope()` from `packages/event-builder/src/index.ts`.
1. Update domain schema in `packages/events/src/domain/`
96
102
2. Update event builder if needed in `packages/event-builder/src/`
97
-
3. Update test files in `__tests__/` directories
98
-
4. Run tests: `npm test`
103
+
3. If the persisted JSON shape or entity folders change, update `packages/file-store/src/`, `packages/ddb-publisher/src/`, and sample records in `tests/example-config-store/`
104
+
4. Update test files in `packages/events/src/**/__tests__/`, `packages/event-builder/src/__tests__/`, `packages/file-store/src/__tests__/`, and `packages/ddb-publisher/src/__tests__/` / `src/__integration__/` as needed
105
+
5. Regenerate schema artefacts from `packages/events` when required: `npm run gen:jsonschema`, `npm run gen:asyncapi`, `npm run gen:erd`
106
+
6. Run tests: `npm run test:unit`
107
+
108
+
### Working with the Config Store and DDB Publisher
109
+
110
+
1. Persisted entity directories are fixed to: `volume-group`, `letter-variant`, `pack-specification`, `supplier`, `supplier-allocation`, `supplier-pack`
111
+
2. Use `loadConfigStore()` from `packages/file-store/src/loader/config-store-loader.ts` to read JSON records and `validateConfigStore()` from `packages/file-store/src/validation/config-store-validator.ts` to collect schema issues
112
+
3. Record filenames matter: `supplier/sup-1.json` must contain `"id": "sup-1"`, or validation fails
113
+
4. For local validation without AWS calls, run:
114
+
115
+
```bash
116
+
npm run cli --workspace @supplier-config/ddb-publisher -- \
117
+
--source tests/example-config-store \
118
+
--env draft \
119
+
--table supplier-config-draft \
120
+
--dry-run
121
+
```
99
122
100
123
### Adding Metadata to Schema Fields
101
124
@@ -139,16 +162,29 @@ Common markdown rules to follow:
139
162
# Install all dependencies
140
163
npm install
141
164
142
-
# Run tests for specific workspace
143
-
npm test --workspace=packages/events
144
-
npm test --workspace=packages/event-builder
165
+
# Run unit tests for all workspaces
166
+
npm run test:unit
167
+
168
+
# Run tests for specific workspaces
169
+
npm run test:unit --workspace @nhsdigital/nhs-notify-event-schemas-supplier-config
170
+
npm run test:unit --workspace @supplier-config/event-builder
171
+
172
+
# Run integration tests for the DynamoDB publisher
173
+
npm run test:integration --workspace @supplier-config/ddb-publisher
145
174
146
175
# Build all packages
147
176
npm run build --workspaces
148
177
149
178
# Lint all code
150
179
npm run lint
151
180
181
+
# Type check all workspaces
182
+
npm run typecheck
183
+
184
+
# Check/fix dependency version drift across workspaces
@@ -173,9 +209,17 @@ Check the error output for specific Zod validation failures. Common issues:
173
209
- Wrong data types (string vs number)
174
210
- Invalid date formats
175
211
212
+
### Local DynamoDB and Testcontainers
213
+
214
+
-`SUPPLIER_CONFIG_DDB_ENDPOINT_URL=http://localhost:8000` points `ddb-publisher` at DynamoDB Local; when the endpoint is localhost-based, the CLI supplies default fake AWS credentials if they are unset
215
+
-`packages/ddb-publisher/src/__integration__/publish-action.integration.test.ts` uses Testcontainers; if Docker startup fails under Colima, retry with `TESTCONTAINERS_RYUK_DISABLED=true` or `TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock`
216
+
176
217
## Agent Notes
177
218
178
219
- The project uses Zod 4.x for schema validation
179
220
- Metadata is stored in Zod's global registry via `.meta()`
180
221
- Test files should be updated whenever domain models change
181
222
- Always run markdown linter when editing `.md` files to catch formatting issues
223
+
-`tests/example-config-store/` is the shared fixture for local CLI runs and `ddb-publisher` integration tests
224
+
- Persisted entity directory names are enforced by `packages/file-store/src/types.ts` and `packages/file-store/src/loader/config-store-loader.ts`
225
+
- Root automation entry points are `npm run test:unit`, `npm run test:integration`, and `npm run typecheck`
0 commit comments