Skip to content

feat(server): .$input#218

Merged
dinwwwh merged 3 commits into
mainfrom
feat/server/dollar-input
Mar 10, 2025
Merged

feat(server): .$input#218
dinwwwh merged 3 commits into
mainfrom
feat/server/dollar-input

Conversation

@dinwwwh
Copy link
Copy Markdown
Member

@dinwwwh dinwwwh commented Mar 10, 2025

Initial Configuration

Customize the initial input schema using .$input:

const base = os.$input(z.void())
const base = os.$input<Schema<void, unknown>>()

Unlike .input, the .$input method lets you redefine the input schema after its initial configuration. This is useful when you need to enforce a void input when no .input is specified.

Summary by CodeRabbit

  • New Features

    • Added enhanced input configuration capability, allowing users to flexibly redefine their initial input schema.
  • Documentation

    • Clarified configuration terminology by renaming "Default Configuration" to "Initial Configuration."
    • Introduced a new section with practical examples to guide users in customizing input schemas.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
orpc ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 10, 2025 1:22pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 10, 2025

Walkthrough

This pull request updates documentation terminology by renaming several sections from "Default Configuration" to "Initial Configuration" and revising associated text. A new section in the procedure documentation explains how to customize input schemas using a newly introduced .$input method. Additionally, new tests have been added for this method in the builder class. Finally, a new $input method has been implemented in the Builder class to allow users to reset the input schema.

Changes

File(s) Change Summary
apps/content/docs/openapi/input-output-structure.md
apps/content/docs/openapi/routing.md
Renamed section title from "Default Configuration" to "Initial Configuration".
Updated terminology from "default oRPC ... settings" to "initial oRPC ... settings".
apps/content/docs/procedure.md Added a new section "Initial Configuration" with examples of using os.$input(z.void()) and os.$input<Schema<void, unknown>>() to illustrate how to redefine the input schema post initial configuration.
packages/server/src/builder.test-d.ts
packages/server/src/builder.test.ts
Introduced new test suites for the $input method, validating its behavior with both an actual schema and type parameters, including TypeScript error expectations for invalid inputs; added necessary imports for schema validation.
packages/server/src/builder.ts Added a new $input method in the Builder class that accepts an optional input schema, returns a new Builder instance with the updated inputSchema, while preserving other existing properties.
packages/server/src/builder-variants.test-d.ts
packages/server/src/implementer-procedure.test-d.ts
Updated type definitions to include $input in backward compatibility tests across various builder classes, ensuring consistent type handling.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant B as Builder
    participant S as Schema
    U->>B: Call $input(schema or type)
    B->>B: Create new Builder instance with updated inputSchema
    B-->>U: Return new Builder instance with the new configuration
Loading

Poem

I'm a little rabbit in the code field,
Hopping through changes with joy revealed.
"Default" became "Initial" with a gentle tap,
New $input methods bridge the schema gap.
Tests all pass with a nudge and a smile —
Code assured, I'll hop another mile! 🐇✨

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

 ERR_PNPM_OPTIONAL_DEPS_REQUIRE_PROD_DEPS  Optional dependencies cannot be installed without production dependencies


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9782ecf and 4d42ed8.

📒 Files selected for processing (2)
  • packages/server/src/builder-variants.test-d.ts (6 hunks)
  • packages/server/src/implementer-procedure.test-d.ts (1 hunks)
🔇 Additional comments (7)
packages/server/src/builder-variants.test-d.ts (6)

37-37: LGTM: Correctly added $input to the BuilderWithMiddlewares type omission list.

The addition of '$input' to the list of properties being omitted in the OmitChainMethodDeep type is consistent with the new functionality introduced in this PR. This change ensures backward compatibility tests will properly account for the new $input method.


282-282: LGTM: Correctly added $input to the ProcedureBuilder type omission list.

The addition of '$input' here properly maintains backward compatibility for the ProcedureBuilder type by including the new method in the omitted properties list.


461-461: LGTM: Correctly added $input to the ProcedureBuilderWithInput type omission list.

The addition of '$input' in this omission list ensures that backward compatibility tests for ProcedureBuilderWithInput account for the new method.


676-676: LGTM: Correctly added $input to the ProcedureBuilderWithOutput type omission list.

The addition of '$input' to the omitted properties for the ProcedureBuilderWithOutput type is consistent with the changes made to other builder variants.


842-842: LGTM: Correctly added $input to the ProcedureBuilderWithInputOutput type omission list.

The addition of '$input' maintains backward compatibility for ProcedureBuilderWithInputOutput by accounting for the new method in type testing.


1042-1042: LGTM: Correctly added $input to the RouterBuilder type omission list.

The addition of '$input' to the RouterBuilder's omitted properties list completes the consistent application of this change across all builder variants.

packages/server/src/implementer-procedure.test-d.ts (1)

193-193: LGTM: Correctly added $input to the ProcedureImplementer type omission list.

The addition of '$input' to the omitted properties for ProcedureImplementer ensures that backward compatibility tests properly account for the new method, maintaining consistency with the changes made to other builder variants.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 10, 2025

Open in Stackblitz

More templates

@orpc/client

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

@orpc/contract

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

@orpc/openapi-client

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

@orpc/openapi

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

@orpc/react-query

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

@orpc/server

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

@orpc/shared

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

@orpc/standard-server

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

@orpc/standard-server-fetch

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

@orpc/standard-server-node

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

@orpc/vue-colada

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

@orpc/vue-query

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

@orpc/zod

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

commit: 4d42ed8

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