-
Notifications
You must be signed in to change notification settings - Fork 3
CCM-12896: Automatically Generate Typescript Types and Validator Code from Event JSON Schemas #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gareth-allan
merged 41 commits into
main
from
feature/CCM-12896_ts_event_type_generation
Dec 8, 2025
Merged
Changes from 38 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
974bf71
CCM-12896: Generate JSON schemas during make config
gareth-allan 09fd304
CCM-12896: Initial application to generate TS event types
gareth-allan 36462b0
CCM-12896: Generate validation code from JSON schema using ajv
gareth-allan c770db9
CCM-12896: Dependency updates for security
gareth-allan 742c4f2
CCM-12896: Use generated type to build an event
gareth-allan fa1220a
CCM-12896: Properly set dev dependencies for typescript-schema-generator
gareth-allan bc5a1b1
CCM-12896: Initial version of script to generate types
gareth-allan f14c68c
CCM:12896: Initial version of script to generate validators
gareth-allan 7158fab
CCM-12896: Update generate-validators to use the real event schemas#
gareth-allan de2a8ac
CCM-12896: Tidy up type and validator generation code
gareth-allan 7a5f24d
CCM-12896: Add npm clean to Makefile clean target
gareth-allan c55cf6e
CCM-12896: Reorganise Makefiles to make code generation run only what…
gareth-allan ecbec10
CCM-12896: Make flattened schemas dereference properties too
gareth-allan e7efe5f
CCM-12896: Removed unnecessary ESLint ignore
gareth-allan 9d58fc0
CCM-12896: Optimise schema generation done as part of code generation
gareth-allan 2b21473
CCM-12896: Use make generate command to generate code when deploying …
gareth-allan 9863588
CCM-12896: Schema fixes
gareth-allan fe69993
CCM-12896: Use make generate in workflow
gareth-allan a6643bc
CCM-12896: Try setting up Node before generating dependencies
gareth-allan 6f015c3
CCM-12896: Use tsx instead of ts-node for doc generation
gareth-allan 531d53d
CCM-12896: Remove unnecessary dependency from typescript-schema-gener…
gareth-allan b45c516
CCM-12896: Fix test error
gareth-allan dc25973
CCM-12896: Revert doc test change to tsx
gareth-allan 808b248
CCM-12896: Extend mesh-poll test coverage
gareth-allan 56b64ff
Revert "CCM-12896: Revert doc test change to tsx"
gareth-allan dfc8173
CCM-12896: Small post-self-review changes
gareth-allan ade615d
CCM-12896: Temporarily disable coverage checks for typescript-schema-…
gareth-allan 08299ea
CCM-12896: Fix make build command
gareth-allan 429d12c
CCM-12896: Add temporary debug to pre.sh
gareth-allan 38fd969
CCM-12896: Test running make via NPM
gareth-allan 4d8f672
CCM-12896: Use NPM to generate dependencies, instead of Makefile
gareth-allan 50b5bc7
CCM-12896: Remove commented-out code
gareth-allan 54a90df
CCM-12896: Added a README.md to typescript-schema-generator
gareth-allan f7f51fc
CCM-12896: Added a note on generated code to main README.md
gareth-allan 0bb868b
CCM-12896: Add unit tests for typescript-schema-generator
gareth-allan 5a3ed70
Merge branch 'main' into feature/CCM-12896_ts_event_type_generation
gareth-allan 597f791
CCM-12896: Resolve CodeQL issues
gareth-allan 248659c
CCM-12896: Make test more explicit about type files generated
gareth-allan e84bd02
CCM-12896: Move generated code to a digital-letters-events package
gareth-allan 26f2746
CCM-12896: Fix linting and unit tests after package change
gareth-allan 0dfc912
CCM-12896: Fix path for output directory
gareth-allan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,55 @@ | ||
| import type { Context } from 'aws-lambda'; | ||
| import { mockDeep } from 'jest-mock-extended'; | ||
| import { PDMResourceSubmitted } from 'typescript-schema-generator'; | ||
| import { handler } from '..'; | ||
|
|
||
| const context = mockDeep<Context>(); | ||
| const callback = jest.fn(); | ||
|
|
||
| describe('event-logging Lambda', () => { | ||
| it('logs the input event and returns 200', async () => { | ||
| const event = { foo: 'bar' }; | ||
| const context = mockDeep<Context>(); | ||
| const callback = jest.fn(); | ||
| const event: PDMResourceSubmitted = { | ||
| type: 'uk.nhs.notify.digital.letters.pdm.resource.submitted.v1', | ||
| source: | ||
| '/nhs/england/notify/staging/dev-647563337/data-plane/digitalletters/pdm', | ||
| dataschema: | ||
| 'https://notify.nhs.uk/cloudevents/schemas/digital-letters/2025-10-draft/data/digital-letters-pdm-resource-submitted-data.schema.json', | ||
| specversion: '1.0', | ||
| id: '0249e529-f947-4012-819e-b634eb71be79', | ||
| subject: | ||
| 'customer/7ff8ed41-cd5f-20e4-ef4e-34f96d8cc8ac/75027ace-9b8c-bcfe-866e-6c24242cffc3/q58dnxk5e/4cbek805wwx/yiaw7bl0d/her/1ccb7eb8-c6fe-0a42-279a-2a0e48ff1ca9/zk', | ||
| time: '2025-11-21T16:01:52.268Z', | ||
| datacontenttype: 'application/json', | ||
| traceparent: '00-ee4790eb6821064c645406abe918b3da-3a4e6957ce2a15de-01', | ||
| tracestate: 'nisi quis', | ||
| partitionkey: 'customer-7ff8ed41', | ||
| recordedtime: '2025-11-21T16:01:53.268Z', | ||
| sampledrate: 1, | ||
| sequence: '00000000000350773861', | ||
| severitytext: 'INFO', | ||
| severitynumber: 2, | ||
| dataclassification: 'restricted', | ||
| dataregulation: 'ISO-27001', | ||
| datacategory: 'non-sensitive', | ||
| data: { | ||
| messageReference: 'incididunt Ut aute laborum', | ||
| senderId: 'officia voluptate culpa Ut dolor', | ||
| resourceId: 'a2bcbb42-ab7e-42b6-88d6-74f8d3ca4a09', | ||
| retryCount: 97_903_257, | ||
| }, | ||
| }; | ||
|
|
||
| const result = await handler(event, context, callback); | ||
|
|
||
| expect(result).toEqual({ | ||
| statusCode: 200, | ||
| body: 'Event logged', | ||
| }); | ||
| }); | ||
|
|
||
| it('throws an error if an invalid event is provided', async () => { | ||
| const invalidEvent = { foo: 'bar' }; | ||
|
|
||
| await expect(handler(invalidEvent, context, callback)).rejects.toThrow(); | ||
| }); | ||
| }); |
|
gareth-allan marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.