Skip to content

feat: support ws.link connection transform#2742

Open
raashish1601 wants to merge 1 commit into
mswjs:mainfrom
raashish1601:codex/2481-transform-websocket-connection-on-the-ws-link-level
Open

feat: support ws.link connection transform#2742
raashish1601 wants to merge 1 commit into
mswjs:mainfrom
raashish1601:codex/2481-transform-websocket-connection-on-the-ws-link-level

Conversation

@raashish1601
Copy link
Copy Markdown

Implemented optional transform callback support for ws.link() and wired it into WebSocketHandler.run() so listeners receive transformed connection objects. Added focused unit coverage for runtime behavior and typings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 404aca95-e59a-4537-9fcb-db0ad10cbbbf

📥 Commits

Reviewing files that changed from the base of the PR and between 2befc51 and b7d82ec.

📒 Files selected for processing (4)
  • src/core/handlers/WebSocketHandler.ts
  • src/core/ws.test.ts
  • src/core/ws.ts
  • test/typings/ws.test-d.ts

📝 Walkthrough

Walkthrough

This PR adds optional connection transformation support to WebSocket handlers. A new WebSocketHandlerConnectionTransformer type enables custom functions to modify resolved connection objects. The WebSocketHandler constructor and createWebSocketLinkHandler factory are updated to accept and use these transformers. Tests validate the transformation flow with params population and type correctness.

Changes

WebSocket Handler Transform Support

Layer / File(s) Summary
Type Definitions & Contracts
src/core/handlers/WebSocketHandler.ts, src/core/ws.ts
New WebSocketHandlerConnectionTransformer type allows functions to transform WebSocketHandlerConnection objects. New WebSocketLinkOptions interface exports an optional transform field.
WebSocketHandler Implementation
src/core/handlers/WebSocketHandler.ts
Constructor now accepts optional transform callback. run() method applies the transformer to the resolved connection (with populated params) if provided, otherwise returns connection unchanged.
Link Factory Integration
src/core/ws.ts
createWebSocketLinkHandler() signature updated to accept optional options parameter with default empty object. Handler instantiation passes options.transform to WebSocketHandler constructor.
Tests & Type Coverage
src/core/ws.test.ts, test/typings/ws.test-d.ts
New runtime test verifies ws.link() with transform option correctly applies transformation and passes transformed connection to event listeners. New type-level test asserts transformer maintains WebSocketHandlerConnection type.

🎯 2 (Simple) | ⏱️ ~12 minutes

🐰 A rabbit hops through a link so fine,
With transforms in tow, connections align!
Params get populated with care,
Custom shapes float through the air,
Type-safe hops from here to there! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: support ws.link connection transform' clearly and concisely describes the main feature added: connection transformation support for ws.link.
Description check ✅ Passed The description directly relates to the changeset, explaining the implementation of optional transform callback support for ws.link() and its integration with WebSocketHandler.run(), along with test coverage.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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