Skip to content

feat: SDK streaming example + test [AMB-3017] - #48

Draft
bufo24 wants to merge 1 commit into
jesseva/amb-3016-sdk-streaming-client-methods-typesfrom
jesseva/amb-3017-sdk-streaming-example-test
Draft

feat: SDK streaming example + test [AMB-3017]#48
bufo24 wants to merge 1 commit into
jesseva/amb-3016-sdk-streaming-client-methods-typesfrom
jesseva/amb-3017-sdk-streaming-example-test

Conversation

@bufo24

@bufo24 bufo24 commented Aug 21, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds packages/payments/examples/watch.ts (+ watch.cts CJS type-check counterpart), a runnable example demonstrating transactions.watch(id): mints an invoice via createReceive when TRANSACTION_ID is unset (reusing the WALLET_ID flow from receive.ts), then iterates the AsyncIterable<PaymentEvent> and logs each event as it arrives. Follows the receive.ts/send.ts pattern — runs against the live API, type-checked in CI (typecheck:examples) but not executed there, since minting a real stream token + opening a real SSE connection needs a live backend.
  • Adds two offline, CI-safe regression tests to streaming.test.ts (pnpm test) covering behavior AMB-3016's own tests didn't exercise: a malformed-JSON event payload rejecting with an unwrapped NetworkError (pins the "outer catch doesn't double-wrap NetworkError" behavior), and a response body ReadableStream erroring after already yielding an event (pins the deliberate design decision, called out in AMB-3016's log, that mid-stream read-loop errors are funneled through AmbossClient.translateError the same as the pre-stream fetch). Did not duplicate AMB-3016's existing coverage (basic mint→yield, stream_closed, pre-stream 401, pre-stream abort — all already covered in streaming.test.ts/sseParser.test.ts).
  • Updates examples/.env.example with TRANSACTION_ID and AGENTS.md's Examples paragraph to mention the new files. Left the AGENTS.md resource table (.watch/.watchEvents row) to AMB-3018 per that ticket's scope.
  • No package.json script changes needed: typecheck:examples includes examples/*.cts via glob (auto-picks up watch.cts); test:examples only enumerates the offline webhook examples, and watch.ts is a live-API example like receive.ts/send.ts so it isn't added there.

Stacking note

This PR is stacked on jesseva/amb-3016-sdk-streaming-client-methods-types (sdk#46, still draft/unmerged) — base is that branch, not main, since this ticket's example/test build directly on the streaming client methods it adds. Once #46 merges to main, this PR will need retargeting to main.

Test plan

  • pnpm install
  • pnpm build
  • pnpm typecheck
  • pnpm typecheck:examples
  • pnpm test (67/67 passing, including the 2 new cases)
  • pnpm test:examples (unaffected, still passing)
  • pnpm format (no diffs beyond the new test formatting)

🤖 Generated with Claude Code

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