Skip to content

feat(v1): add campaigns, segments, workflows, analytics, usage and v1 events with RFC 9457 errors - #4

Merged
BSalaeddin merged 12 commits into
mainfrom
feat/v1-surface
Aug 18, 2026
Merged

BSalaeddin merged 12 commits into
mainfrom
feat/v1-surface

Conversation

@BSalaeddin

Copy link
Copy Markdown
Contributor

Extends the SDK to Sendly's new `/api/v1` surface (33 operations) plus the two legacy list-subscription ops the re-synced spec surfaced. Additive only — zero breaking changes; 0.2.0 → 0.3.0.

What's new

  • Resources: `campaigns` (10 ops incl. send/cancel/pause/resume/stats), `segments` (6), `workflows` (9 incl. executions), `analytics` (3), `usage` (1), v1 methods on `events` (`list`/`record`/`listNames`/`stats` — legacy `track` untouched), and legacy `lists.subscribe`/`unsubscribe` (double-opt-in PENDING/confirmToken and allowResubscribe/409 semantics documented from the spec's own operation descriptions).
  • RFC 9457 errors: `/api/v1/*` failures (`application/problem+json`) map onto the same `SendlyError` subclasses as the legacy envelope, with additive `requestId` and `fieldErrors` members; `ProblemDocument`/`ProblemFieldError`/`asProblemDocument` exported. Detection trusts the media type and falls back to document shape — the legacy envelope can never match.
  • Cursor auto-pagination: async-generator `*All` companions on the 6 cursor-enveloped list ops, with repeated-cursor loop protection; a contract test derives the cursor-shaped op set from the spec so a future spec change fails closed.
  • Idempotency: `IdempotencyOptions` on exactly the two spec-declared v1 ops — `campaigns.create` and `campaigns.send` (the spec deliberately omits the header elsewhere; `events.record` takes none).
  • v1 deletes return the typed `{id, deleted}` body; `campaigns.send(id, body?)` supports `{scheduled_for}` scheduling.
  • Spec-defect workarounds documented in `src/types.ts` aliases only (map-value narrowing and default-implies-required from the generator) — platform-side fix tracked separately.

Verification

140 tests (18 files) · contract suite green with NOT_YET_IMPLEMENTED empty (all 72 spec ops mapped) · lint 0 warnings · tsc clean · format:check clean · committed dist rebuilt and byte-identical to a fresh build · built-bundle assertions on method arities. Webhook verifier untouched. Release path: tag `v0.3.0` after merge — the tag workflow re-runs the gate and publishes via npm OIDC trusted publishing.

Mirrors DevinoSolutions/sendly-python#3 (same surface contract, cross-language parity reviewed).

🤖 Generated with Claude Code

@BSalaeddin
BSalaeddin merged commit a4ac04f into main Aug 18, 2026
1 check passed
@BSalaeddin
BSalaeddin deleted the feat/v1-surface branch August 18, 2026 19:34
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.

1 participant