Add Inbound Email v2 API support#145
Conversation
Email Log messages now expose the RFC threading headers (rfc_message_id, in_reply_to, references) and thread_id. Sending domains expose inbound_enabled and inbound_verified. Types and test fixtures updated to match the OpenAPI spec.
Folder, Inbox, Message/MessageDetails, Thread/ThreadMessage and the send (reply/forward) request+response shapes, matched to the inbound OpenAPI spec.
Folders, Inboxes, Messages (incl. reply/reply_all/forward) and Threads resources under a new InboundAPI aggregator, exposed as client.inbound. The getter needs no accountId - inbound paths are scoped to the token's account.
Full HTTP coverage (URL, method, body, response) for folders, inboxes, messages and threads, plus an InboundAPI aggregator presence test.
Per-resource runnable examples (folders, inboxes, messages incl. reply/reply_all/forward, threads) importing from the published mailtrap package, linked from the README.
Import from the published mailtrap package instead of the local source, matching the convention used by every other example.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughAdds token-scoped inbound email APIs for folders, inboxes, messages, and threads, with TypeScript contracts, Axios clients, tests, documentation links, and executable examples. Email log and sending-domain types include inbound-related metadata. ChangesInbound Email
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant Application
participant MailtrapClient
participant InboundAPI
participant InboundResource
participant MailtrapAPI
Application->>MailtrapClient: access client.inbound
MailtrapClient->>InboundAPI: construct with Axios client
InboundAPI->>InboundResource: expose folders, inboxes, messages, and threads
Application->>InboundResource: invoke inbound operation
InboundResource->>MailtrapAPI: send typed HTTP request
MailtrapAPI-->>InboundResource: return inbound response
InboundResource-->>Application: return typed result
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@examples/inbound/messages.ts`:
- Around line 28-55: The inbound examples must not mutate arbitrary existing
data: in examples/inbound/messages.ts lines 28-55, replace selection of
list.data[0].id with a user-supplied message ID and require explicit opt-in
before reply, replyAll, forward, or delete; in examples/inbound/threads.ts lines
28-36, require a user-supplied thread ID and explicit opt-in before delete,
preserving read-only behavior by default.
In `@src/lib/api/resources/inbound/Folders.ts`:
- Around line 54-57: Update the delete methods in Folders.delete
(src/lib/api/resources/inbound/Folders.ts:54-57), Inboxes.delete
(src/lib/api/resources/inbound/Inboxes.ts:66-69), Messages.delete
(src/lib/api/resources/inbound/Messages.ts:55-58), and Threads.delete
(src/lib/api/resources/inbound/Threads.ts:53-56) to return Promise<void> and
call the client delete operation with void response and data types via
delete<void, void>(...).
In `@src/types/api/inbound/messages.ts`:
- Around line 72-88: Introduce a ForwardMessageParams type with a required
non-empty to tuple ([Address, ...Address[]]), preserving the applicable
SendMessageParams fields, and update MessagesApi.forward to accept it instead of
SendMessageParams. Ensure forward calls cannot type-check without at least one
recipient while other message operations retain their existing parameter type.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6c1b00f3-5b46-45ac-8d4f-bd372aeef332
📒 Files selected for processing (25)
README.mdexamples/inbound/folders.tsexamples/inbound/inboxes.tsexamples/inbound/messages.tsexamples/inbound/threads.tsexamples/sending-domains/everything.tssrc/__tests__/lib/api/Inbound.test.tssrc/__tests__/lib/api/resources/EmailLogs.test.tssrc/__tests__/lib/api/resources/SendingDomains.test.tssrc/__tests__/lib/api/resources/inbound/Folders.test.tssrc/__tests__/lib/api/resources/inbound/Inboxes.test.tssrc/__tests__/lib/api/resources/inbound/Messages.test.tssrc/__tests__/lib/api/resources/inbound/Threads.test.tssrc/lib/MailtrapClient.tssrc/lib/api/Inbound.tssrc/lib/api/resources/inbound/Folders.tssrc/lib/api/resources/inbound/Inboxes.tssrc/lib/api/resources/inbound/Messages.tssrc/lib/api/resources/inbound/Threads.tssrc/types/api/email-logs.tssrc/types/api/inbound/folders.tssrc/types/api/inbound/inboxes.tssrc/types/api/inbound/messages.tssrc/types/api/inbound/threads.tssrc/types/api/sending-domains.ts
Inbound message/thread examples are read-only by default; reply, reply-all, forward and delete are gated behind an explicit opt-in id, so running an example never sends mail or deletes data unprompted. forward() now takes ForwardMessageParams requiring a non-empty `to`, so a recipient-less forward fails to compile.
Motivation
Add SDK support for the Inbound Email v2 API, and surface the inbound-related additions that shipped on existing endpoints. Mirrors the OpenAPI spec in
mailtrap-openapi.Changes
Inbound Email API — new
client.inboundaggregator exposing:folders— list, create, get, update, deleteinboxes(folder-scoped) — list, create (hosted & custom-domain), get, update, deletemessages(inbox-scoped) — list (cursor-paginated), get, delete,reply,replyAll,forwardthreads(inbox-scoped) — list (cursor-paginated), get, deleteScoped to the token's account, so
client.inboundneeds noaccountId.Email Logs —
EmailLogMessagenow exposesrfc_message_id,in_reply_to,references, andthread_id.Sending Domains —
SendingDomainnow exposesinbound_enabledandinbound_verified.Full HTTP test coverage for every new resource + an aggregator presence test.
Per-resource runnable examples under
examples/inbound/and README entries.Aligned the
sending-domainsexample to import from the publishedmailtrappackage (every example now does).Split into reviewable commits: existing-endpoint fields, inbound types, resources + client wiring, tests, examples + README.
How to test
yarn lint && yarn test— 49 suites / 383 tests green.Images and GIFs
N/A — SDK/API change.
Summary by CodeRabbit