Skip to content

CCM-13675: Event code generation improvements#254

Merged
simonlabarere merged 18 commits intomainfrom
feature/CCM-13675_event_code_generation_improvements
Mar 31, 2026
Merged

CCM-13675: Event code generation improvements#254
simonlabarere merged 18 commits intomainfrom
feature/CCM-13675_event_code_generation_improvements

Conversation

@simonlabarere
Copy link
Copy Markdown
Contributor

@simonlabarere simonlabarere commented Mar 23, 2026

Description

Generation of guard functions to assist in reducing boiler plate code and avoiding type casting. The behaviour of the whole app should remain unchanged with the exception of the normalisation of some logs.

Example of a generated guard function:

export function validateMESHInboxMessageDownloaded(
  event: unknown,
  logger: Logger,
): asserts event is MESHInboxMessageDownloaded {
  if (!eventMESHInboxMessageDownloadedValidator(event)) {
    logger.error({
      err: eventMESHInboxMessageDownloadedValidator.errors,
      description: 'Error parsing MESHInboxMessageDownloaded event',
    });
    throw new InvalidEvent(eventMESHInboxMessageDownloadedValidator.errors);
  }
}

Which can be used like this:

const event: any = getSomeEvent();

validateMESHInboxMessageDownloaded(event, logger);

// event is now detected with a type of MESHInboxMessageDownloaded without any casting

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.

@simonlabarere simonlabarere requested a review from a team as a code owner March 23, 2026 13:45
@simonlabarere simonlabarere force-pushed the feature/CCM-13675_event_code_generation_improvements branch 2 times, most recently from edf7a6f to d45e448 Compare March 23, 2026 13:53
@simonlabarere simonlabarere changed the title CCM-14616: POC CCM-13675: Event code generation improvements Mar 24, 2026
Comment thread lambdas/print-analyser/src/__tests__/apis/sqs-handler.test.ts
@simonlabarere simonlabarere force-pushed the feature/CCM-13675_event_code_generation_improvements branch from 504a803 to 8c42a94 Compare March 24, 2026 16:12
Comment thread utils/utils/src/logger.ts
Comment thread lambdas/file-scanner-lambda/src/apis/sqs-handler.ts
@Ian-Hodges Ian-Hodges self-assigned this Mar 25, 2026
Comment thread lambdas/pdm-poll-lambda/src/apis/sqs-handler.ts Outdated
Comment thread lambdas/print-sender-lambda/src/app/print-sender.ts Outdated
Ian-Hodges
Ian-Hodges previously approved these changes Mar 26, 2026
Copy link
Copy Markdown
Contributor

@Ian-Hodges Ian-Hodges left a comment

Choose a reason for hiding this comment

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

I'm liking it. Just the one comment about an error log potentially triggering duplicate alarms.

@simonlabarere simonlabarere force-pushed the feature/CCM-13675_event_code_generation_improvements branch from d09080e to d69745d Compare March 27, 2026 10:31
@gareth-allan gareth-allan self-assigned this Mar 27, 2026
Comment thread src/digital-letters-events/package.json
Comment thread src/digital-letters-events/errors/index.ts
Comment thread src/typescript-schema-generator/src/generate-types.ts
Comment thread src/typescript-schema-generator/src/generate-guard-functions.ts Outdated
Comment thread src/typescript-schema-generator/src/generate-guard-functions.ts Outdated
Comment thread src/typescript-schema-generator/src/generate-guard-functions.ts Outdated
Comment thread lambdas/print-analyser/src/__tests__/apis/sqs-handler.test.ts
gareth-allan
gareth-allan previously approved these changes Mar 27, 2026
@simonlabarere simonlabarere force-pushed the feature/CCM-13675_event_code_generation_improvements branch from f7ceaa8 to ee7a2b7 Compare March 30, 2026 12:54
@simonlabarere simonlabarere force-pushed the feature/CCM-13675_event_code_generation_improvements branch from b216f80 to a43fd07 Compare March 30, 2026 13:38
@simonlabarere simonlabarere merged commit 51d6819 into main Mar 31, 2026
34 checks passed
@simonlabarere simonlabarere deleted the feature/CCM-13675_event_code_generation_improvements branch March 31, 2026 08:43
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.

5 participants