feat: SDK streaming example + test [AMB-3017] - #48
Draft
bufo24 wants to merge 1 commit into
Draft
Conversation
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.
Summary
packages/payments/examples/watch.ts(+watch.ctsCJS type-check counterpart), a runnable example demonstratingtransactions.watch(id): mints an invoice viacreateReceivewhenTRANSACTION_IDis unset (reusing theWALLET_IDflow fromreceive.ts), then iterates theAsyncIterable<PaymentEvent>and logs each event as it arrives. Follows thereceive.ts/send.tspattern — 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.streaming.test.ts(pnpm test) covering behavior AMB-3016's own tests didn't exercise: a malformed-JSON event payload rejecting with an unwrappedNetworkError(pins the "outer catch doesn't double-wrapNetworkError" behavior), and a response bodyReadableStreamerroring 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 throughAmbossClient.translateErrorthe 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 instreaming.test.ts/sseParser.test.ts).examples/.env.examplewithTRANSACTION_IDandAGENTS.md's Examples paragraph to mention the new files. Left the AGENTS.md resource table (.watch/.watchEventsrow) to AMB-3018 per that ticket's scope.package.jsonscript changes needed:typecheck:examplesincludesexamples/*.ctsvia glob (auto-picks upwatch.cts);test:examplesonly enumerates the offline webhook examples, andwatch.tsis a live-API example likereceive.ts/send.tsso 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, notmain, since this ticket's example/test build directly on the streaming client methods it adds. Once #46 merges tomain, this PR will need retargeting tomain.Test plan
pnpm installpnpm buildpnpm typecheckpnpm typecheck:examplespnpm 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