refactor(rpc): extract RPC schemas to dedicated schema file#185
Merged
Conversation
Move Zod schemas and their inferred types from rpc-client.ts to a new src/schemas/rpc.ts file for improved separation of concerns. Changes: - Create src/schemas/rpc.ts with exported schemas and types: - rpcActionRequestSchema/RpcActionRequest - rpcActionResponseSchema/RpcActionResponse - rpcClientConfigSchema/RpcClientConfig - Update rpc-client.ts to import schemas from new location - Add explicit type annotation to actions property for type portability - Keep rpcActionResponseDataSchema as internal (not exported) - Re-export RpcActionResponse from rpc-client.ts for consumers Benefits: - Schema definitions are separate from RpcClient implementation - Schemas can be imported independently without bringing in RpcClient - Schemas can be tested in isolation - Schema file serves as clear API contract reference Closes #171
commit: |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extracts RPC-related Zod schemas and types from the RPC client implementation into a dedicated schema file, improving code organization and reusability.
- Creates new
src/schemas/rpc.tsfile containing all RPC schema definitions - Updates
src/rpc-client.tsto import from the new schema file - Adds explicit type annotation to the
actionsproperty for improved type portability
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/schemas/rpc.ts |
New file containing all RPC-related Zod schemas (rpcActionRequestSchema, rpcActionResponseSchema, rpcClientConfigSchema) and their corresponding TypeScript types, with comprehensive documentation |
src/rpc-client.ts |
Refactored to import schemas and types from the new dedicated schema file, with a re-export of RpcActionResponse for backward compatibility and an explicit type annotation on the actions property |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
NicolasBelissent
approved these changes
Dec 9, 2025
- Update schemas/rpc.ts to use zod/mini syntax (z.looseObject, z.optional() wrapper, z.record(z.string(), z.unknown())) - Maintain schema extraction to dedicated file structure - Preserve import-based approach in rpc-client.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/rpc-client.tsto a new dedicatedsrc/schemas/rpc.tsfilerpc-client.tsto import schemas from the new locationChanges
New file
src/schemas/rpc.ts: Contains all RPC-related schemas and types:rpcActionRequestSchema/RpcActionRequestrpcActionResponseSchema/RpcActionResponserpcClientConfigSchema/RpcClientConfigrpcActionResponseDataSchema(internal, not exported)Updated
src/rpc-client.ts:RpcActionResponsefor consumersactionsproperty for type portabilityBenefits
Test Plan
pnpm run test:root)pnpm run lint)pnpm run typecheck:root)Closes #171
Summary by cubic
Moved all RPC Zod schemas and types from src/rpc-client.ts to src/schemas/rpc.ts for clearer separation and reuse, addressing #171. rpc-client.ts now imports the schemas and re-exports RpcActionResponse, with an explicit type on actions for portability.
Written for commit 097494d. Summary will update automatically on new commits.