Repository navigation
Conversation
Move the module from lettermint@^2 to lettermint@^3.0.0.
sendEmail() and sendEmails() now go through the stateless emails.send()
and emails.sendBatch(), with the idempotency key passed per call, so no
message state lives on any client. useLettermint() and useLettermintApi()
return the SDK 3 client with every configured credential, and
useLettermintEmail() returns the immutable SDK 3 builder. Configured
tokens are trimmed, as fetch did for SDK 2.
The re-exported error classes follow SDK 3 (LettermintApiError and its
subclasses, LettermintConnectionError, LettermintConfigError, ...), and
toLettermintFailure() maps them onto the same { statusCode, message, data }
shape as before. Tags the SDK refuses become a LettermintPayloadError, so
the endpoint answers them with 400.
Tests cover concurrent sends end to end (through the endpoint and the
mock API) and never reach the real API.
BREAKING CHANGE: useLettermint() and useLettermintApi() return the SDK 3
client (`emails` instead of `email`, typed query objects, some team API
methods moved), useLettermintEmail() returns the immutable SDK 3 builder,
LettermintClientError is removed and SDK errors read `status`/`body`
instead of `statusCode`/`responseBody`, and SendEmailResponse is a union
on `status`. See UPGRADE.md.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
The module now depends on
lettermint@^3.0.0(SDK 2.x no longer gets fixes).Unchanged for users: module options, runtime config keys and env vars (
NUXT_LETTERMINT_API_KEY,NUXT_LETTERMINT_API_TOKEN,NUXT_LETTERMINT_BASE_URL,NUXT_LETTERMINT_TIMEOUT), the clientuseLettermint()composable,sendEmail()/sendEmails()signatures and payload mapping, the/api/lettermint/sendrequest and response shapes,toLettermintFailure()'s{ statusCode, message, data }shape, andLettermintPayloadError.Sending is stateless end to end.
sendEmail()/sendEmails()callemails.send()/emails.sendBatch()with the idempotency key passed per call. No message state lives on any client. v2 already built a fresh SDK instance per call to work around the 2.x shared builder; SDK 3 removes that hazard at the source. New tests send two concurrent messages with different recipients, bodies, tags, attachments and idempotency keys, answered in reverse order, both throughsendEmail()with stubbed fetch and through the real Nitro endpoint against the mock API. Each request and each answer stays with its own message.What users can see:
useLettermint()anduseLettermintApi()(server) return the SDK 3Lettermintclient:emailsinstead ofemail, typed query objects,iterate(), and some team API methods moved (routes.list(projectId),team.members.list(), ...). Both clients carry every configured credential. Each part uses its own token, and the SDK never falls back to the other one.useLettermintEmail()returns the immutable SDK 3EmailBuilder. Chains work as before. Code that builds a message over several statements has to keep each setter's return value..idempotencyKey(k).send()becomes.send({ idempotencyKey: k }), andattach()takes an object.LettermintApiError,LettermintAuthenticationError,LettermintPermissionError,LettermintNotFoundError,LettermintConflictError,LettermintRateLimitError,LettermintServerError,LettermintConnectionError,LettermintUnexpectedResponseError,LettermintRedirectErrorandLettermintConfigErrorare new.LettermintValidationError(422) andLettermintTimeoutErrorkeep their meaning.LettermintHttpRequestErrorstays as a deprecated alias ofLettermintApiError.LettermintClientError(400-only) is removed because SDK 3 has no equivalent. Error properties are nowstatus/body/codeinstead ofstatusCode/responseBody/errorType.LettermintValidationError(for example malformed tags) is a different class from the module's 422 export with the same name.sendEmail()/sendEmails()turn it intoLettermintPayloadError, so the endpoint now answers bad tags with 400. In v2 they hit a plainTypeErrorand got a 500.toLettermintFailure()now also maps connection, invalid-response, redirect, pre-send-validation and config errors (it returnednullfor the first two in v2). A misconfigured client gets a generic 500 message and the detail goes to the log only.SendEmailResponseis SDK 3'sSendMailResponse, a union onstatus, so readingscheduled_atneedsstatus === 'scheduled'first.MessageStatus/TlsPolicyare open enums.Webhook.verify(rawBody, headers)and the now-requiredX-Lettermint-Deliveryheader for apps that verify webhooks themselves.Breaking for the module?
Yes, so this should be released as nuxt-lettermint 3.0.0. The module hands out SDK objects as they are (
useLettermint(),useLettermintApi(),useLettermintEmail()) and re-exports SDK error classes and types, so the SDK's breaking changes reach users directly. The commit isfeat!:with aBREAKING CHANGE:footer, so semantic-release will cut a major.package.json's version is not bumped, following the repo's convention. Apps that only use the config,sendEmail()/sendEmails(), the endpoint and the client composable should need no code changes beyond theSendEmailResponsenarrowing. UPGRADE.md has a new "Upgrade to v3" section with before and after examples. The README covers the new error classes, the immutable builder and typed team-API queries.Verification
npm ci+npm install lettermint@^3.0.0(lockfile: 2.7.0 → 3.0.0)npm run lint: cleannpm run dev:prepare && npm run test:types(module, tests and playground): cleannpm run test: 9 files, 137 tests passed. All tests use stubbedfetchor the local mock Lettermint server, so none reach the real API or send email.npm run prepack(nuxt-module-build build): succeedsnpm run dev:build(playground Nitro build with SDK 3): succeeds with no bundler warnings🤖 Generated with Claude Code