Skip to content

refactor(event)!: replace event streams with a tree-shakeable parser - #4

Open
suisanka wants to merge 6 commits into
mainfrom
next
Open

suisanka wants to merge 6 commits into
mainfrom
next

Conversation

@suisanka

@suisanka suisanka commented Aug 1, 2026

Copy link
Copy Markdown
Member

Summary

  • remove the SDK-managed SSE/WebSocket event source, reconnect loop, event emitter, and async iterator
  • add resolveMilkyEvent(obj) at the root and @saltify/milky-tea/event
  • split self-hosted Zod schemas into common, API-only, and event-only lazy chunks
  • remove mitt and eventsource, and mark the package side-effect free
  • update documentation and replace connection tests with parser and bundle-boundary coverage

Why

The previous event subsystem duplicated connection state and transport forwarding while making consumers pay for code they may not use. Event delivery belongs to the host application; this package now focuses on validating and typing an already received Milky event.

The generated schema split keeps API validation and event parsing independently loadable. The event subpath avoids loading client metadata, while shared schemas remain deduplicated.

Breaking impact

  • client.event(), createMilkyEventSource(), and all MilkyEventSource* types are removed
  • consumers must own their SSE, WebSocket, or WebHook transport
  • received objects should be passed to resolveMilkyEvent()
  • validation results are cloned and unknown fields are stripped, but returned objects are not frozen

Validation

  • pnpm typecheck
  • pnpm test — 38 tests passed
  • pnpm test:coverage — 97% statements, 89.92% branches
  • pnpm exec eslint .
  • pnpm check:bundle
  • package root/subpath import smoke test
  • pnpm pack --dry-run

Bundle output now separates the 1.20 kB event entry, 11.81 kB event schema, 8.91 kB shared schema, and 41.55 kB API schema; the root runtime is reduced from 21.96 kB to 8.54 kB.

@suisanka suisanka changed the title Replace event streams with a tree-shakeable event parser refactor(event)!: replace event streams with a tree-shakeable parser Aug 2, 2026
@suisanka
suisanka marked this pull request as ready for review August 2, 2026 10:12
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