CCM-15259 - Improve client subscription management script#57
CCM-15259 - Improve client subscription management script#57rhyscoxnhs wants to merge 29 commits intofeature/CCM-15215from
Conversation
There was a problem hiding this comment.
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
ClientSubscriptionConfigurationto{ clientId, subscriptions, targets }withtargetIdsreferences (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-getsupports deriving the bucket via--environment, but it doesn’t expose a--projectoption or pass it through toresolveBucketName. Other commands in this tool do support--project, so this one will derive the wrong bucket name for non-default projects. Add aprojectoption (defaulting to "nhs") and pass it toresolveBucketName.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lambdas/client-transform-filter-lambda/src/__tests__/services/config-cache.test.ts
Show resolved
Hide resolved
tools/client-subscriptions-management/src/entrypoint/cli/clients-list.ts
Outdated
Show resolved
Hide resolved
tools/client-subscriptions-management/src/repository/client-subscriptions.ts
Show resolved
Hide resolved
tools/client-subscriptions-management/src/repository/client-subscriptions.ts
Show resolved
Hide resolved
tools/client-subscriptions-management/src/entrypoint/cli/subscriptions-list.ts
Outdated
Show resolved
Hide resolved
| 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({ |
There was a problem hiding this comment.
project is hardcoded across the board now
3a27a43 to
1e7b8f5
Compare
945a6bf to
61641c1
Compare
8c12526 to
5ff8589
Compare
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
This isn't right - needs to be the actual targetIds from matching subs
Description
Context
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.