Skip to content

Conversation

@sethconve
Copy link
Contributor

@sethconve sethconve commented Dec 4, 2025

This is merging the already approved template branch into main

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Summary by CodeRabbit

  • New Features

    • Introduced email template support with customizable dynamic variables
    • Unified API now accepts template-based or traditional HTML/text payloads
    • Optional subject line override capability for template emails
    • Template delivery tracking and status monitoring
  • Tests

    • Comprehensive test coverage for template functionality and validation logic

✏️ Tip: You can customize this high-level summary in your review settings.

- Introduced `sendWithTemplate` action to handle sending emails with templates.
- Updated `sendEmail` function to accept both traditional and template-based email formats.
- Enhanced validation to ensure either content or template is provided, but not both.
- Added tests for template email functionality, including acceptance and rejection scenarios.
- Updated schema and shared types to include template-related fields.
Add support for template-based emails in sendEmail function
@coderabbitai
Copy link

coderabbitai bot commented Dec 4, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

A new email template feature is being added to the email client library, enabling users to send templated emails with variable substitution. The changes introduce a Template type with id and variables, update the SendEmailOptions to a discriminated union supporting both traditional and template-based payloads, make the subject optional when using templates, and include validation to enforce template and content constraints.

Changes

Cohort / File(s) Summary
Template core types
src/component/shared.ts
Added Template type and vTemplate validator for structured template objects with id and variables (string or number)
Schema updates
src/component/schema.ts
Made subject field optional, added optional template field to emails table
Client API
src/client/index.ts
Updated SendEmailOptions to discriminated union supporting traditional email or template-based payloads; extended EmailStatus return to include optional template; refined sendEmailManually signature
Implementation logic
src/component/lib.ts
Extended sendEmail mutation to accept optional template field, updated validation to enforce mutually exclusive template/content, modified batch payload construction to conditionally include template or html/text
Tests
src/component/lib.test.ts
Added test suite for template-based emails validating template fields, variables, subject overrides, and rejecting conflicting content types (note: suite appears duplicated)
Example
example/convex/example.ts
Added sendWithTemplate internalAction demonstrating template-based email sending with delivery status polling

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Discriminated union in SendEmailOptions requires careful verification of both variants
  • Validation logic in lib.ts enforces multiple constraints (mutually exclusive template/content, conditional subject requirement)
  • Batch payload construction conditional logic needs verification for both code paths
  • Test suite appears to have a duplicated "sendEmail with templates" describe block that should be consolidated

Suggested reviewers

  • mikecann
  • ianmacartney

Poem

🐰 A template so fine, with variables in place,
No more repetitive content we must face!
Discriminated unions keep payloads so tight,
Subject's now optional—what a delight!
Hippity-hop, emails now dance with great flair! 📧✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch seth/to-arrays

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between be2b3ed and 3ac4d4d.

⛔ Files ignored due to path filters (1)
  • src/component/_generated/component.ts is excluded by !**/_generated/**
📒 Files selected for processing (6)
  • example/convex/example.ts (1 hunks)
  • src/client/index.ts (7 hunks)
  • src/component/lib.test.ts (2 hunks)
  • src/component/lib.ts (5 hunks)
  • src/component/schema.ts (2 hunks)
  • src/component/shared.ts (1 hunks)

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 4, 2025

Open in StackBlitz

npm i https://pkg.pr.new/get-convex/resend/@convex-dev/resend@49

commit: 3ac4d4d

@sethconve sethconve merged commit c0cf8c6 into main Dec 4, 2025
2 of 3 checks passed
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.

2 participants