Skip to content

Conversation

@unnoq
Copy link
Member

@unnoq unnoq commented Dec 17, 2025

Summary by CodeRabbit

  • New Features

    • Added a new $input method on ContractBuilder to set/configure input schemas with type-safe behavior.
  • Tests

    • Added runtime and type-level tests for $input, updated type expectations across builder variants, and extended existing tests to assert chaining/instance behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Dec 17, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 17, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds a new public ContractBuilder.$input(initialInputSchema?) method to set/override the builder's input schema and updates runtime and type-level tests to validate its typing and behavior.

Changes

Cohort / File(s) Summary
$input API
packages/contract/src/builder.ts
Adds ContractBuilder.$input<U extends AnySchema>(initialInputSchema?: U) which returns a new ContractBuilder typed with input U and sets inputSchema on the internal descriptor.
Runtime tests
packages/contract/src/builder.test.ts
Adds a test asserting builder.$input(generalSchema) returns a new ContractBuilder and that the returned builder's internal object contains inputSchema: generalSchema; also asserts . $route returns a different instance than the original.
Type declaration tests
packages/contract/src/builder.test-d.ts, packages/contract/src/builder-variants.test-d.ts
Adds a type-level test ensuring builder.$input(generalSchema) yields the expected ContractBuilder type and that invalid schema usage triggers a type error; updates variant tests to omit '$input' from chain-method expectation sets.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Inspect ContractBuilder.$input generic propagation and that other type parameters are preserved.
  • Verify runtime test checks the returned instance identity and inputSchema assignment.
  • Validate updated declaration tests correctly express expected type omissions and errors.

Possibly related PRs

  • unnoq/orpc#218 — Adds a .$input builder method and matching tests; directly overlaps the same API addition and type-test updates.

Poem

🐰 I nudged the builder, schema snug and neat,
With tiny paws I set the input sweet,
Types hummed in chorus, errors kept at bay,
Builders bounce forward, ready for the day,
A rabbit applauds this tidy feat.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly matches the main change: adding the missing $input builder method to ContractBuilder as shown across test and implementation files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/contract/missing--builder-method

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7f12146 and dd50fe6.

📒 Files selected for processing (1)
  • packages/contract/src/builder-variants.test-d.ts (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: lint
  • GitHub Check: publish-commit
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (1)
packages/contract/src/builder-variants.test-d.ts (1)

17-17: LGTM! Consistent exclusion of the new $input method.

The addition of '$input' to all backward compatibility test exclusions is correct and consistent across all builder variants. This properly accounts for the new $input builder method being added to ContractBuilder, ensuring that these type-level backward compatibility tests exclude the new method from their expected surfaces.

Also applies to: 98-98, 165-165, 232-232, 285-285


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.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @unnoq, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a missing feature by adding the .$input builder method to the ContractBuilder class. This enhancement provides greater flexibility in defining contract input schemas, ensuring that developers can explicitly configure them. The change is thoroughly tested with both runtime and type-safety checks to guarantee correctness and maintain strong typing throughout the application.

Highlights

  • New Builder Method: Introduced the .$input builder method to the ContractBuilder class, allowing explicit setting or overriding of the initial input schema for a contract.
  • Runtime Tests: Added comprehensive unit tests for the new .$input method in builder.test.ts to ensure its correct runtime behavior, including instance creation and schema assignment.
  • Type-Safety Tests: Implemented type-definition tests for the .$input method in builder.test-d.ts to verify its type-safety and proper generic type inference.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the missing .$input method to the ContractBuilder, allowing for the setting or overriding of the initial input schema. The implementation correctly follows the immutable builder pattern by returning a new instance, and it's well-tested with both runtime and type-definition tests. I've provided a couple of suggestions to improve code clarity and test consistency.


it('.$input', () => {
const applied = builder.$input(generalSchema)
expect(applied).toBeInstanceOf(ContractBuilder)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For consistency with other tests in this file (e.g., for .meta, .errors, .input), it would be good to also assert that the .$input method returns a new ContractBuilder instance and does not mutate the original one. This ensures the immutability of the builder is properly tested.

    expect(applied).toBeInstanceOf(ContractBuilder)
    expect(applied).not.toBe(builder)

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 17, 2025

Deploying orpc with  Cloudflare Pages  Cloudflare Pages

Latest commit: dd50fe6
Status: ✅  Deploy successful!
Preview URL: https://60ad7f1d.orpc-1qh.pages.dev
Branch Preview URL: https://fix-contract-missing--builde.orpc-1qh.pages.dev

View logs

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 17, 2025

More templates

@orpc/ai-sdk

npm i https://pkg.pr.new/@orpc/ai-sdk@1304

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@1304

@orpc/client

npm i https://pkg.pr.new/@orpc/client@1304

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@1304

@orpc/experimental-durable-iterator

npm i https://pkg.pr.new/@orpc/experimental-durable-iterator@1304

@orpc/hey-api

npm i https://pkg.pr.new/@orpc/hey-api@1304

@orpc/interop

npm i https://pkg.pr.new/@orpc/interop@1304

@orpc/json-schema

npm i https://pkg.pr.new/@orpc/json-schema@1304

@orpc/nest

npm i https://pkg.pr.new/@orpc/nest@1304

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@1304

@orpc/openapi-client

npm i https://pkg.pr.new/@orpc/openapi-client@1304

@orpc/otel

npm i https://pkg.pr.new/@orpc/otel@1304

@orpc/experimental-pino

npm i https://pkg.pr.new/@orpc/experimental-pino@1304

@orpc/experimental-publisher

npm i https://pkg.pr.new/@orpc/experimental-publisher@1304

@orpc/experimental-publisher-durable-object

npm i https://pkg.pr.new/@orpc/experimental-publisher-durable-object@1304

@orpc/experimental-ratelimit

npm i https://pkg.pr.new/@orpc/experimental-ratelimit@1304

@orpc/react

npm i https://pkg.pr.new/@orpc/react@1304

@orpc/react-query

npm i https://pkg.pr.new/@orpc/react-query@1304

@orpc/experimental-react-swr

npm i https://pkg.pr.new/@orpc/experimental-react-swr@1304

@orpc/server

npm i https://pkg.pr.new/@orpc/server@1304

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@1304

@orpc/solid-query

npm i https://pkg.pr.new/@orpc/solid-query@1304

@orpc/standard-server

npm i https://pkg.pr.new/@orpc/standard-server@1304

@orpc/standard-server-aws-lambda

npm i https://pkg.pr.new/@orpc/standard-server-aws-lambda@1304

@orpc/standard-server-fastify

npm i https://pkg.pr.new/@orpc/standard-server-fastify@1304

@orpc/standard-server-fetch

npm i https://pkg.pr.new/@orpc/standard-server-fetch@1304

@orpc/standard-server-node

npm i https://pkg.pr.new/@orpc/standard-server-node@1304

@orpc/standard-server-peer

npm i https://pkg.pr.new/@orpc/standard-server-peer@1304

@orpc/svelte-query

npm i https://pkg.pr.new/@orpc/svelte-query@1304

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@1304

@orpc/trpc

npm i https://pkg.pr.new/@orpc/trpc@1304

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@1304

@orpc/vue-colada

npm i https://pkg.pr.new/@orpc/vue-colada@1304

@orpc/vue-query

npm i https://pkg.pr.new/@orpc/vue-query@1304

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@1304

commit: dd50fe6

@codecov
Copy link

codecov bot commented Dec 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@unnoq unnoq merged commit b81d47f into main Dec 18, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants