feat(server): support chaining after .callable and .actionable#223
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe changes update the type expectations in tests and the implementation of the Changes
Sequence Diagram(s)sequenceDiagram
participant Client as User/Caller
participant DP as DecoratedProcedure
participant Proxy as Dynamic Proxy
Client->>DP: Invoke callable()
DP->>Proxy: Return Proxy with get & has traps
Client->>Proxy: Access property (e.g., route)
Proxy->>DP: Check if property exists on instance (this)
alt Property exists
DP-->>Proxy: Return property value
else
Proxy-->>Client: Fallback to target property value
end
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 ESLint
ERR_PNPM_OPTIONAL_DEPS_REQUIRE_PROD_DEPS Optional dependencies cannot be installed without production dependencies 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🔇 Additional comments (4)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know! |
More templates
@orpc/client
@orpc/contract
@orpc/openapi-client
@orpc/openapi
@orpc/react-query
@orpc/shared
@orpc/standard-server
@orpc/server
@orpc/standard-server-fetch
@orpc/standard-server-node
@orpc/vue-colada
@orpc/vue-query
@orpc/zod
commit: |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/server/src/procedure-decorated.test.ts (2)
110-122: Good test coverage over function property interception
These assertions confirm that the returned function (.callable) properly intercepts property existence and retrieval through the Proxy, verifying that route, meta, etc. are accessible. You might also add a test scenario for potential naming collisions, so future property expansions in the procedure or the client do not inadvertently overshadow each other.
134-146: Test duplication for .actionable
The checks for.actionablemirror those for.callable. If these blocks become more intricate, consider extracting a shared test helper to keep your tests DRY and more maintainable.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/server/src/procedure-decorated.test-d.ts(2 hunks)packages/server/src/procedure-decorated.test.ts(1 hunks)packages/server/src/procedure-decorated.ts(2 hunks)
🔇 Additional comments (3)
packages/server/src/procedure-decorated.test-d.ts (1)
177-177: Align type expectations with updated DecoratedProcedure
Switching fromProcedureto the more specificDecoratedProceduretype aligns the tests with the new return types and ensures correctness of chained method calls.Also applies to: 195-195
packages/server/src/procedure-decorated.ts (2)
120-120: Proxy usage ensures dynamic property interception
Returning a Proxy object allows unified access to both the originalDecoratedProcedureproperties and the client’s function behavior, which is a flexible design. Keep an eye on potential naming collisions between the procedure instance and the procedure client in future expansions.Also applies to: 122-129
147-147: Improved return type for .actionable
IncludingDecoratedProcedure<...>in the return type properly enables further chaining after invoking.actionable, matching the updated chaining logic.
Summary by CodeRabbit
Refactor
callableandactionablemethods to ensure they return specific procedure types.Tests
appliedobject in test cases.