CCM-22997: Shared utilities - #249
Open
rhyscoxnhs wants to merge 8 commits into
Open
Conversation
rhyscoxnhs
force-pushed
the
feature/CCM-22997
branch
2 times, most recently
from
August 19, 2026 11:37
7c9b84c to
829fcaf
Compare
rhyscoxnhs
force-pushed
the
feature/CCM-22997
branch
from
August 19, 2026 11:45
829fcaf to
30176ec
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Introduces a new publishable package,
@nhsdigital/nhs-notify-shared-utils, in a newpackages/workspace. It holds generic, technical-only utilities for reuse across NHSNotify bounded contexts.
Each module is a subpath export, so a consumer imports only what it needs and Lambda
bundles never pull in unused code:
./logger— a generic pino-backedLogger. Redaction is fully opt-in: the classdeclares no redact paths of its own; each bounded context supplies its own via
redactPaths../lambda-utils—parseEnv/EnvValidationError, a pureformatZodIssuesformatter, and SQS string-attribute readers.
parseEnvvalidatesprocess.env(or asupplied source) against a Zod object schema, so callers get coercion (numbers,
booleans, etc.) and format assertions rather than every variable being read as an
untyped string; issues are thrown as a single formatted
EnvValidationError. Neitherhelper takes a hard dependency on Zod —
EnvSchema<T>andFormattableZodIssuedeclare the minimal structural shape needed, so any Zod schema/error is accepted
without coupling the package to a Zod version. No AWS SDK dependency.
./s3-json— a get-JSON-from-S3-and-optionally-validate helper.Integration test-support helpers (AWS client factories, polling primitives, event-factory
fixtures) were deliberately not included — they're boilerplate enough to copy into
each repo's tests rather than maintain as a shared dependency, per review feedback.
Dependency and build contract:
pinoand@aws-sdk/client-s3are peer dependencies (the S3 client optional),preventing duplicate copies in consumer bundles.
tscwith a split tooling/buildtsconfig;filesrestricted todist. Every module ships a README with usage.Workspace and release wiring:
packages/*workspace glob,awsandruntimepnpm catalogs, acache-correct turbo
buildtask, and ESLint coverage for the new package.publish-packages.yaml) to GitHub Packages under@nhsdigital, triggered only byshared-utils-v*tags and decoupled from theTerraform module release. It fails unless the pushed tag version matches
package.jsonversion. Least-privilege permissions (contents: read,packages: write),GITHUB_TOKENauth only.tag-shared-utils-release.yamlworkflow that automatically creates and pushesthe
shared-utils-vX.Y.Ztag once the main CI/CD pipeline completes successfully onmain, reading the version straight frompackage.json. This removes the manual,error-prone step of a developer creating a tag that must match the package version by
hand — bumping
versionin a merged PR is now the only manual step required torelease.
jestentry intypesand use of deprecatedbaseUrlproperties.Context
The app-response and client-callbacks bounded contexts independently built
near-identical technical utilities — structured logging, environment-variable
validation, and error formatting. Maintaining two copies causes drift and doubled
effort. This extracts the generic, technical-only utilities into a single versioned
package so bounded contexts can depend on one shared implementation, keeping the
dependency one-way (bounded context → shared) and leaving all domain logic in its own
context. Integration test-support helpers were intentionally left out of the shared
package — they're low-risk boilerplate best copied per repo rather than centrally
maintained. Consumers adopt the package on their own cadence in follow-up work; this
change only introduces the package in the host repository.
Ref: CCM-22997.
Type of changes
Checklist
Sensitive Information Declaration
To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.