Skip to content

Add createWSApi - WebSocket API definition layer#220

Merged
paribaker merged 5 commits into
mainfrom
feature/create-ws-api
Mar 9, 2026
Merged

Add createWSApi - WebSocket API definition layer#220
paribaker merged 5 commits into
mainfrom
feature/create-ws-api

Conversation

@paribaker

Copy link
Copy Markdown
Contributor

Summary

  • Add WSClientLike type defining the minimal transport-agnostic WebSocket client interface (send, on, off)
  • Exported from src/api/types.ts, src/api/index.ts, and src/index.ts
  • Foundation type for the upcoming createWSApi function that mirrors createApi for event-driven APIs

Test Plan

  • All tests pass (npm test — 140 passing)
  • TypeScript compiles cleanly (tsc --noEmit)
  • Spec parser continues to function (spekk next)
  • New test file: src/api/tests/ws-client-like.test.ts

Specs Addressed

  • Assertion: specs/create-ws-api/assertions/ws-client-like-type.md
  • Parent Spec: specs/create-ws-api/create-ws-api.md

Implementation Notes

  • WSClientLike is intentionally minimal — no pings, pongs, reconnection, or heartbeats
  • Compatible with native WebSocket wrappers, Socket.IO clients, and Phoenix Channel clients
  • Follows the same AxiosLike pattern used for HTTP client abstraction in createApi

Pari Work Temp and others added 5 commits February 28, 2026 12:13
Assign all 10 assertions to branch feature/create-ws-api with dependency tree:
- ws-client-like-type (root, no deps)
- create-ws-api-function (depends-on: ws-client-like-type)
- 8 leaf assertions (all depend-on: create-ws-api-function, parallelizable)
Add WSClientLike type to src/api/types.ts defining the minimal
transport-agnostic WebSocket client interface (send, on, off).
Export from src/api/index.ts and src/index.ts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implement createWSApi in src/api/create-ws-api.ts with full TypeScript
inference from Zod shapes. Returns typed send/on/off methods, supports
send-only and receive-only APIs, empty payloads, snake_case conversion
on send, and camelCase conversion on receive with parseResponse validation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@paribaker paribaker merged commit 558368d into main Mar 9, 2026
1 check passed
@paribaker paribaker deleted the feature/create-ws-api branch March 9, 2026 00:20
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