fix(types)!: align send() response with real server contract ({ emails: [...], timestamp })#3
Merged
Merged
Conversation
…t ({ emails: [...], timestamp })
POST /api/emails has always returned
`data = { emails: [{ contact: { id, email }, email }], timestamp }` — one
`emails` entry per recipient (an array `to` fans out to several), where the
nested `email` is the id of the queued email record. The OpenAPI spec and the
generated types instead declared a FLAT `{ contact, email, timestamp }` and
typed `emails.send()` as `SendEmailData | SendEmailData[]`, so every caller
doing `const { email } = await sendly.emails.send(...)` got `undefined`.
The platform owner ruled the server shape canonical; the monorepo spec is
already corrected (DevinoSolutions/sendly main@ee407438). This regenerates the
SDK from that corrected `openapi.json`:
- openapi.json: byte-copied from the corrected monorepo spec
(SendEmailData -> { emails: SendEmailRecipientResult[], timestamp };
SendEmailResponse.data -> SendEmailData; the single|array union is gone).
- types.generated.ts: regenerated via `pnpm build:types`.
- emails.send(): return type is now the single corrected `SendEmailData`.
- tests: assert send unwraps to `{ emails: [...], timestamp }`.
- README / CHANGELOG: document the corrected shape and the breaking type change.
- package.json + SDK_VERSION: 0.1.0 -> 0.2.0.
- dist/: rebuilt (the consuming monorepo pins the GitHub tarball / uses dist).
Runtime was already correct — `send()` returns the response's unwrapped `data`
verbatim — so this is a TYPE-only breaking change; no runtime behavior changed.
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.
The drift
POST /api/emailshas always returned:{ "success": true, "data": { "emails": [{ "contact": { "id": "…", "email": "…" }, "email": "<email-record-uuid>" }], "timestamp": "…" } }i.e.
data.emailshas one entry per recipient (an arraytofans out to several), and each entry is{ contact: { id, email }, email }where the nestedemailis the id of the queued email record for that recipient.The OpenAPI spec and this SDK's generated types instead declared a flat
{ contact, email, timestamp }and typedemails.send()asPromise<SendEmailData | SendEmailData[]>. So every TS user doingconst { email } = await sendly.emails.send(...)gotundefined.Decision
The platform owner ruled the server shape canonical. The monorepo OpenAPI spec is already fixed and merged (
DevinoSolutions/sendlymain@ee407438). This PR regenerates the SDK from that corrected contract. Runtime SDK behavior was already correct —send()returns the response's unwrappeddataverbatim — so only the types / spec / docs were stale.What changed
openapi.json— byte-copied from the corrected monorepo spec.SendEmailDatais now{ emails: SendEmailRecipientResult[], timestamp };SendEmailRecipientResult={ contact: { id, email }, email };SendEmailResponse.data=SendEmailData(the oldsingle | arrayunion is gone). Batch keepsBatchSendResponse/BatchEntryResult(rows''data=SendEmailData).src/types.generated.ts— regenerated viapnpm build:types(never hand-edited).src/resources/emails.ts—send()return type is now the single correctedSendEmailData(wasSendEmailData | SendEmailData[]); JSDoc updated.src/__tests__/emails.test.ts— send tests now genuinely assert the unwrapped{ emails: [...], timestamp }shape.README.md— send example shows readingresult.emails[0].email+result.timestamp.CHANGELOG.md— 0.2.0 entry: breaking type change, runtime unchanged, spec corrected to match server.package.json+SDK_VERSION— 0.1.0 → 0.2.0 (breaking type change; not yet published to npm).dist/— rebuilt and committed (the consuming monorepo pins the GitHub tarball and usesdistdirectly).Verification (all run locally, no
--no-verify)pnpm lint(--max-warnings=0) — passpnpm check-types— passpnpm test— 74 passed (11 files)pnpm build— regenerated committeddist/pnpm format:check— passdist/index.d.tsconfirmed:send(body, opts?): Promise<SendEmailData>withSendEmailData = { emails: SendEmailRecipientResult[]; timestamp }; no remainingSendEmailData | SendEmailData[]union.pnpm check-spec-driftwill WARN vs live prod (prod not yet redeployed) — expected and non-blocking.