Skip to content

refactor(rpc): extract RPC schemas to dedicated schema file#185

Merged
ryoppippi merged 2 commits into
mainfrom
refactor/extract-rpc-schemas
Dec 9, 2025
Merged

refactor(rpc): extract RPC schemas to dedicated schema file#185
ryoppippi merged 2 commits into
mainfrom
refactor/extract-rpc-schemas

Conversation

@ryoppippi

@ryoppippi ryoppippi commented Dec 9, 2025

Copy link
Copy Markdown
Contributor

Summary

  • Extract RPC-related Zod schemas and types from src/rpc-client.ts to a new dedicated src/schemas/rpc.ts file
  • Update rpc-client.ts to import schemas from the new location
  • Add explicit type annotation for type portability

Changes

  • New file src/schemas/rpc.ts: Contains all RPC-related schemas and types:

    • rpcActionRequestSchema / RpcActionRequest
    • rpcActionResponseSchema / RpcActionResponse
    • rpcClientConfigSchema / RpcClientConfig
    • rpcActionResponseDataSchema (internal, not exported)
  • Updated src/rpc-client.ts:

    • Imports schemas and types from new location
    • Re-exports RpcActionResponse for consumers
    • Added explicit type annotation to actions property for type portability

Benefits

  1. Separation of concerns - Schema definitions are separate from RpcClient implementation
  2. Reusability - Schemas can be imported independently without bringing in RpcClient class
  3. Testability - Schemas can be tested in isolation
  4. Documentation - Schema file serves as a clear API contract reference

Test Plan

  • All existing tests pass (pnpm run test:root)
  • Lint checks pass (pnpm run lint)
  • Root typecheck passes (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.

  • Refactors
    • New src/schemas/rpc.ts exporting: rpcActionRequestSchema/RpcActionRequest, rpcActionResponseSchema/RpcActionResponse, rpcClientConfigSchema/RpcClientConfig.
    • rpcActionResponseDataSchema remains internal (not exported).

Written for commit 097494d. Summary will update automatically on new commits.

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
@ryoppippi ryoppippi requested a review from a team as a code owner December 9, 2025 14:27
Copilot AI review requested due to automatic review settings December 9, 2025 14:27
@pkg-pr-new

pkg-pr-new Bot commented Dec 9, 2025

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/StackOneHQ/stackone-ai-node/@stackone/ai@185

commit: 097494d

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts file containing all RPC schema definitions
  • Updates src/rpc-client.ts to import from the new schema file
  • Adds explicit type annotation to the actions property 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.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

- 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
@ryoppippi ryoppippi merged commit c53c441 into main Dec 9, 2025
7 checks passed
@ryoppippi ryoppippi deleted the refactor/extract-rpc-schemas branch December 9, 2025 15:51
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.

Extract RPC schemas to dedicated schema file

3 participants