Skip to content

CCM-15259 - Improve client subscription management script#57

Open
rhyscoxnhs wants to merge 29 commits intofeature/CCM-15215from
feature/CCM-15259
Open

CCM-15259 - Improve client subscription management script#57
rhyscoxnhs wants to merge 29 commits intofeature/CCM-15215from
feature/CCM-15259

Conversation

@rhyscoxnhs
Copy link
Contributor

@rhyscoxnhs rhyscoxnhs commented Mar 16, 2026

Description

Context

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
  • If I have used the 'skip-trivy-package' label I have done so responsibly and in the knowledge that this is being fixed as part of a separate ticket/PR.

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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the client subscriptions management tooling and updates the shared config model + the client-transform-filter lambda to a new (breaking) configuration shape that separates subscriptions from targets and links them by targetIds.

Changes:

  • Refactor ClientSubscriptionConfiguration to { clientId, subscriptions, targets } with targetIds references (breaking change), and update lambda validation/filtering accordingly.
  • Replace the old “deploy/put-*” scripts with CRUD-style CLI commands plus a new interactive mode for managing clients/subscriptions/targets.
  • Add/adjust unit tests across the tool and lambda to cover the new config shape and commands.

Reviewed changes

Copilot reviewed 63 out of 64 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
tools/client-subscriptions-management/src/repository/s3.ts Add S3 key listing helper
tools/client-subscriptions-management/src/repository/client-subscriptions.ts New repo API for config CRUD
tools/client-subscriptions-management/src/entrypoint/interactive/targets.ts Interactive targets flows
tools/client-subscriptions-management/src/entrypoint/interactive/subscriptions.ts Interactive subscriptions flows
tools/client-subscriptions-management/src/entrypoint/interactive/shared.ts Shared interactive prompts/utilities
tools/client-subscriptions-management/src/entrypoint/interactive/index.ts Interactive mode menu/dispatcher
tools/client-subscriptions-management/src/entrypoint/interactive/clients.ts Interactive client flows + terraform prompt
tools/client-subscriptions-management/src/entrypoint/cli/validate-config.ts Zod validation for new config
tools/client-subscriptions-management/src/entrypoint/cli/targets-list.ts List targets CLI command
tools/client-subscriptions-management/src/entrypoint/cli/targets-del.ts Delete target CLI command
tools/client-subscriptions-management/src/entrypoint/cli/targets-add.ts Add target CLI command
tools/client-subscriptions-management/src/entrypoint/cli/subscriptions-set-states.ts Update subscription status sets
tools/client-subscriptions-management/src/entrypoint/cli/subscriptions-list.ts List subscriptions CLI command
tools/client-subscriptions-management/src/entrypoint/cli/subscriptions-del.ts Delete subscription CLI command
tools/client-subscriptions-management/src/entrypoint/cli/subscriptions-add.ts Add subscription CLI command
tools/client-subscriptions-management/src/entrypoint/cli/helper.ts New formatting + terraform plan/apply
tools/client-subscriptions-management/src/entrypoint/cli/deploy.ts Remove legacy deploy entrypoint
tools/client-subscriptions-management/src/entrypoint/cli/clients-put.ts Replace full client config CLI
tools/client-subscriptions-management/src/entrypoint/cli/clients-list.ts List clients CLI command
tools/client-subscriptions-management/src/entrypoint/cli/clients-get.ts Get full client config CLI
tools/client-subscriptions-management/src/domain/client-subscription-builder.ts Builders for targets/subscriptions
tools/client-subscriptions-management/src/container.ts Simplify repository wiring
tools/client-subscriptions-management/src/tests/repository/client-subscriptions.test.ts Update repo tests for new model
tools/client-subscriptions-management/src/tests/entrypoint/interactive/targets.test.ts Add interactive targets tests
tools/client-subscriptions-management/src/tests/entrypoint/interactive/subscriptions.test.ts Add interactive subscriptions tests
tools/client-subscriptions-management/src/tests/entrypoint/interactive/shared.test.ts Add shared prompt tests
tools/client-subscriptions-management/src/tests/entrypoint/interactive/index.test.ts Add interactive dispatcher tests
tools/client-subscriptions-management/src/tests/entrypoint/interactive/clients.test.ts Add interactive clients tests
tools/client-subscriptions-management/src/tests/entrypoint/cli/validate-config.test.ts Add config validation tests
tools/client-subscriptions-management/src/tests/entrypoint/cli/targets-list.test.ts Add targets-list tests
tools/client-subscriptions-management/src/tests/entrypoint/cli/targets-del.test.ts Add targets-del tests
tools/client-subscriptions-management/src/tests/entrypoint/cli/targets-add.test.ts Add targets-add tests
tools/client-subscriptions-management/src/tests/entrypoint/cli/subscriptions-set-states.test.ts Update set-states tests
tools/client-subscriptions-management/src/tests/entrypoint/cli/subscriptions-list.test.ts Add subscriptions-list tests
tools/client-subscriptions-management/src/tests/entrypoint/cli/subscriptions-del.test.ts Add subscriptions-del tests
tools/client-subscriptions-management/src/tests/entrypoint/cli/subscriptions-add.test.ts Add subscriptions-add tests
tools/client-subscriptions-management/src/tests/entrypoint/cli/put-message-status.test.ts Remove legacy CLI tests
tools/client-subscriptions-management/src/tests/entrypoint/cli/put-channel-status.test.ts Remove legacy CLI tests
tools/client-subscriptions-management/src/tests/entrypoint/cli/helper.test.ts Update helper formatting + terraform tests
tools/client-subscriptions-management/src/tests/entrypoint/cli/clients-put.test.ts Add clients-put tests
tools/client-subscriptions-management/src/tests/entrypoint/cli/clients-list.test.ts Add clients-list tests
tools/client-subscriptions-management/src/tests/entrypoint/cli/clients-get.test.ts Update clients-get tests
tools/client-subscriptions-management/src/tests/domain/client-subscription-builder.test.ts Update builder tests for new output
tools/client-subscriptions-management/src/tests/container.test.ts Update container wiring test
tools/client-subscriptions-management/package.json Add interactive + new CLI scripts/deps
src/models/src/index.ts Export new config-related types
src/models/src/client-config.ts Breaking config model redesign
package.json Update top-level scripts/overrides
lambdas/client-transform-filter-lambda/src/services/validators/config-validator.ts Update validation schema to new model
lambdas/client-transform-filter-lambda/src/services/filters/message-status-filter.ts Update filtering for new model
lambdas/client-transform-filter-lambda/src/services/filters/channel-status-filter.ts Update filtering for new model
lambdas/client-transform-filter-lambda/src/services/config-loader.ts Fix logging for new structure
lambdas/client-transform-filter-lambda/src/handler.ts Read apiKey/targets from new structure
lambdas/client-transform-filter-lambda/src/tests/validators/config-validator.test.ts Update validator tests for new model
lambdas/client-transform-filter-lambda/src/tests/services/subscription-filter.test.ts Update filter tests for new model
lambdas/client-transform-filter-lambda/src/tests/services/filters/message-status-filter.test.ts Update message filter tests
lambdas/client-transform-filter-lambda/src/tests/services/filters/channel-status-filter.test.ts Update channel filter tests
lambdas/client-transform-filter-lambda/src/tests/services/config-update.component.test.ts Update cache refresh component test
lambdas/client-transform-filter-lambda/src/tests/services/config-loader.test.ts Update loader tests for new model
lambdas/client-transform-filter-lambda/src/tests/services/config-cache.test.ts Update cache tests (needs fixes)
lambdas/client-transform-filter-lambda/src/tests/index.test.ts Update handler tests config shape
lambdas/client-transform-filter-lambda/src/tests/index.component.test.ts Update integration-ish handler test data
docs/adr/assets/ADR-003/examples/python/requirements.txt Bump PyJWT in ADR example
Comments suppressed due to low confidence (1)

tools/client-subscriptions-management/src/entrypoint/cli/clients-get.ts:51

  • clients-get supports deriving the bucket via --environment, but it doesn’t expose a --project option or pass it through to resolveBucketName. Other commands in this tool do support --project, so this one will derive the wrong bucket name for non-default projects. Add a project option (defaulting to "nhs") and pass it to resolveBucketName.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +11 to +53
export const parseArgs = (args: string[]) =>
yargs(hideBin(args))
.options({
"bucket-name": {
type: "string",
demandOption: false,
description: "Explicit S3 bucket name (overrides derived name)",
},
environment: {
type: "string",
demandOption: false,
description:
"Environment name, used to derive infrastructure resource names when not explicitly provided",
},
"client-id": {
type: "string",
demandOption: true,
description: "Client identifier",
},
region: {
type: "string",
demandOption: false,
description: "AWS region (defaults to AWS_REGION or eu-west-2)",
},
profile: {
type: "string",
demandOption: false,
description: "AWS profile to use (overrides AWS_PROFILE)",
},
})
.parseSync();

export async function main(args: string[] = process.argv) {
const argv = parseArgs(args);
const region = resolveRegion(argv.region);
const profile = resolveProfile(argv.profile);
const bucketName = await resolveBucketName(
argv["bucket-name"],
argv.environment,
region,
profile,
);
const repository = createClientSubscriptionRepository({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

project is hardcoded across the board now

@mjewildnhs mjewildnhs requested a review from a team as a code owner March 17, 2026 16:33
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check coverage for this and some of the other files in this dir as they are a little low

const targetIds = config?.flatMap((s) =>
s.Targets.map((t) => t.TargetId),
);
const targetIds = config?.targets?.map((t) => t.targetId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't right - needs to be the actual targetIds from matching subs

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.

4 participants