Skip to content

feat(sse): add @apimatic/sse package for Server-Sent Events#321

Merged
asadali214 merged 2 commits into
masterfrom
feat/sse-package
Jul 9, 2026
Merged

feat(sse): add @apimatic/sse package for Server-Sent Events#321
asadali214 merged 2 commits into
masterfrom
feat/sse-package

Conversation

@asadali214

@asadali214 asadali214 commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

Adds the @apimatic/sse package. #322 (core + release infra) is merged and @apimatic/core@0.10.30 has shipped via OIDC, so this PR is rebased onto master and its diff is now sse-only.

Contents

  • @apimatic/sse: spec-compliant SSE parser, single-use async-iterable SseStream<T> (read-timeout, typed errors), and createEventStream — the factory that core's RequestBuilder.callAsEventStream hook delegates to. Works in both Node and the browser (duck-typed body handling; no Node built-ins).
  • Root README package-table row + tsconfig.monorepo.json reference.
  • sonar-project.properties: classify all test/** files as tests (so SSE test helpers don't count as coverable source).

Release plan

package.json version is intentionally 0.0.0. After merge, dispatch the Release workflow with minor@apimatic/sse 0.0.0 → 0.1.0 via OIDC. (A 0.0.0 placeholder is already on npm with trusted publishing configured; it can be unpublished cleanly until 2026-07-12 09:35 PKT — publish 0.1.0 first, then unpublish 0.0.0.)

🤖 Generated with Claude Code

Comment thread packages/sse/src/sseStream.ts Fixed
asadali214 added a commit that referenced this pull request Jul 8, 2026
Fix the two reliability bugs and raise new-code coverage above the 80%
gate on PR #321.

- createEventStream: rename the `JSON` const (S2137) so it no longer
  shadows the global
- requestBuilder.test: await the rejects assertion (S8780) and give the
  three "should not update ..." cases explicit spy assertions (S2699)
- sseStream.test: cover drainBodyToText, the web-ReadableStream/Blob/
  string body branches, close(), and unsupported body/chunk errors
  (sseStream.ts 61% -> 97% lines)
- createEventStream.test: cover later-abort forwarding and the non-2xx
  error-body buffering interceptor (createEventStream.ts -> 100% lines)
- sonar-project.properties: classify all packages/*/test/** files as
  tests so helpers (setup.js, sseTestKit.ts) stop counting as coverable
  production source

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@asadali214
asadali214 changed the base branch from master to feat/core-event-stream-hook July 9, 2026 05:06
@asadali214 asadali214 changed the title feat(sse): add @apimatic/sse package for Server-Sent Events support feat(sse): add @apimatic/sse package for Server-Sent Events Jul 9, 2026
@asadali214 asadali214 self-assigned this Jul 9, 2026
@asadali214
asadali214 requested a review from hamzamahmood July 9, 2026 05:09
Base automatically changed from feat/core-event-stream-hook to master July 9, 2026 06:33
Spec-compliant incremental SSE parser, single-use async-iterable
SseStream<T> with read-timeout and typed errors, and a createEventStream
factory that core's RequestBuilder.callAsEventStream hook delegates to.

Version starts at 0.0.0 so the first release (`minor`) lands it at 0.1.0;
a 0.0.0 placeholder is already published on npm to enable OIDC trusted
publishing for the real release.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Shield-Jaguar
Shield-Jaguar previously approved these changes Jul 9, 2026

@Shield-Jaguar Shield-Jaguar left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to make sure that this is the right solution. that we need a dedicated package for that. if you can do without separate package that should be better.

- schemaSseDecoder: retry validation with the raw text when the
  JSON-parsed form fails a non-string schema, so plain-text frames
  that happen to be valid JSON (123, true, null) decode as strings
  instead of aborting the stream.
- createEventStream: abort the controller when callAsStream rejects
  so the user-signal abort-forwarding listener is always detached.
- package.json: point "module" at es/index.js (the ESM build) to
  match sibling packages; lib/ is the CJS build.
- rollup.config.js: mark dependencies as external, matching siblings.

Adds regression tests for the JSON-lookalike decode and the
listener-cleanup-on-failure paths.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019U1ScRb4izn5axBgMyjHiP

@Shield-Jaguar Shield-Jaguar left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, see my pervious comment

@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

@asadali214
asadali214 merged commit 22d0700 into master Jul 9, 2026
7 checks passed
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.

3 participants