Skip to content

CCM-22997: Shared utilities - #249

Open
rhyscoxnhs wants to merge 4 commits into
mainfrom
feature/CCM-22997
Open

CCM-22997: Shared utilities#249
rhyscoxnhs wants to merge 4 commits into
mainfrom
feature/CCM-22997

Conversation

@rhyscoxnhs

@rhyscoxnhs rhyscoxnhs commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Description

Introduces a new publishable package, @nhsdigital/nhs-notify-shared-utils, in a new
packages/ workspace. It holds generic, technical-only utilities for reuse across NHS
Notify bounded contexts.

Each module is a subpath export, so a consumer imports only what it needs and Lambda
bundles never pull in test-only code:

  • ./logger — a generic pino-backed Logger. Redaction is fully opt-in: the class
    declares no redact paths of its own; each bounded context supplies its own via
    redactPaths.
  • ./lambda-utilsrequireEnv / MissingEnvironmentVariableError, a pure
    formatZodIssues formatter, and SQS string-attribute readers. No AWS SDK dependency.
  • ./test-support — integration test helpers: deployment/naming helpers, polling
    primitives, and an override-based event-factory base. AWS client factories are split
    per service under ./test-support/{cloudwatch,sqs,s3,dynamodb,eventbridge}, so
    importing one service does not load the others' AWS SDK packages; the barrel itself is
    AWS-SDK-free.
  • ./s3-json — a get-JSON-from-S3-and-optionally-validate helper.

Dependency and build contract:

  • pino and the AWS SDK v3 clients are peer dependencies (AWS SDK peers optional),
    preventing duplicate copies in consumer bundles.
  • CommonJS build via tsc with a split tooling/build tsconfig; files restricted to
    dist. Every module ships a README with usage.

Workspace and release wiring:

  • Adds the packages/* workspace glob, aws and runtime pnpm catalogs, a
    cache-correct turbo build task, and ESLint coverage for the new package.
  • Adds a tag-driven publish workflow (publish-packages.yaml) to GitHub Packages under
    @nhsdigital, triggered only by shared-utils-v* tags and decoupled from the
    Terraform module release. It fails unless the pushed tag version matches package.json
    version. Least-privilege permissions (contents: read, packages: write),
    GITHUB_TOKEN auth only.
  • Updates existing tsconfigs to resolve typecheck / unit test failures due to missing jest entry in types and use of deprecated baseUrl properties
  • 100% unit-test coverage; lint, typecheck, tests and build are green.

Context

The app-response and client-callbacks bounded contexts independently built
near-identical technical utilities — structured logging, environment-variable
validation, AWS SDK client factories, and integration test-support helpers. 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. Consumers adopt it on their own cadence in
follow-up work; this change only introduces the package in the host repository.

Ref: CCM-22997.

Type of changes

  • Refactoring (non-breaking change)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I am familiar with the contributing guidelines
  • I have followed the code style of the project
  • I have added tests to cover my changes
  • I have updated the documentation accordingly
  • This PR is a result of pair or mob programming

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.

  • I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.

@rhyscoxnhs
rhyscoxnhs requested a review from a team as a code owner August 19, 2026 10:46
@rhyscoxnhs
rhyscoxnhs force-pushed the feature/CCM-22997 branch 2 times, most recently from 7c9b84c to 829fcaf Compare August 19, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant