vendure icon indicating copy to clipboard operation
vendure copied to clipboard

feat: Add support for asynchronous email generators

Open twlite opened this issue 5 months ago โ€ข 3 comments

Description

This PR adds support for asynchronous email generators.

Breaking changes

This change is backwards compatible and should not break existing projects.

Screenshots

You can add screenshots here if applicable.

Checklist

๐Ÿ“Œ Always:

  • [x] I have set a clear title
  • [x] My PR is small and contains a single feature
  • [x] I have checked my own PR

๐Ÿ‘ Most of the time:

  • [ ] I have added or updated test cases
  • [ ] I have updated the README if needed

Summary by CodeRabbit

  • Refactor
    • Improved email generation to support both synchronous and asynchronous operations, enabling more efficient processing.
    • Simplified template configuration handling to reduce code duplication in the email generator.

twlite avatar Nov 15 '25 14:11 twlite

Walkthrough

The changes make the email generator asynchronous-capable by updating the generator interface to return either a synchronous or Promise-based result. The processor now awaits the generator output, and template options are refactored for code reuse in the Handlebars implementation.

Changes

Cohort / File(s) Summary
Async generator support
packages/email-plugin/src/email-processor.ts, packages/email-plugin/src/generator/email-generator.ts
Added await to generator.generate call in processor; introduced EmailGeneratorResult type alias; updated generate method signature to return EmailGeneratorResult | Promise<EmailGeneratorResult> to support both sync and async implementations.
Template options refactoring
packages/email-plugin/src/generator/handlebars-mjml-generator.ts
Extracted repeated templateOptions object (allowProtoPropertiesByDefault: true) into a single reusable variable instead of creating inline objects for each Handlebars compilation.

Estimated code review effort

๐ŸŽฏ 2 (Simple) | โฑ๏ธ ~8 minutes

  • Small, focused change set affecting three files with consistent patterns
  • Straightforward async/await addition with no error-handling complexity
  • Template refactoring is a simple deduplication without behavioral changes

Pre-merge checks and finishing touches

โœ… Passed checks (3 passed)
Check name Status Explanation
Title check โœ… Passed The title clearly and specifically describes the main change: adding support for asynchronous email generators, which aligns with the core functionality added across multiple generator files.
Description check โœ… Passed The description covers the main change and breaks down checklist items, though test coverage details and README updates are not completed as noted in the unchecked items.
Docstring Coverage โœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
โœจ Finishing touches
  • [ ] ๐Ÿ“ Generate docstrings
๐Ÿงช Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

โค๏ธ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Nov 15 '25 14:11 coderabbitai[bot]

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
docs Ready Ready Preview, Comment Dec 18, 2025 4:14pm
vendure-storybook Ready Ready Preview, Comment Dec 18, 2025 4:14pm

vercel[bot] avatar Nov 15 '25 14:11 vercel[bot]