Skip to content

feat(zod): adapt zod 4 stable#520

Merged
dinwwwh merged 1 commit intomainfrom
feat/zod/adapt-zod-4-stable
May 20, 2025
Merged

feat(zod): adapt zod 4 stable#520
dinwwwh merged 1 commit intomainfrom
feat/zod/adapt-zod-4-stable

Conversation

@dinwwwh
Copy link
Copy Markdown
Member

@dinwwwh dinwwwh commented May 20, 2025

Summary by CodeRabbit

  • Chores
    • Updated the "zod" package from a beta version to a stable release across all relevant packages and playgrounds, allowing for future minor and patch updates.
  • Tests
    • Adjusted test case names and input patterns for improved clarity and accuracy.
  • Refactor
    • Improved runtime type checks and metadata handling for schema conversion, enhancing type safety and schema validation behavior.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 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 May 20, 2025 2:33am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2025

Walkthrough

This update replaces the zod package dependency across multiple project and playground package.json files, moving from a fixed beta version to a stable caret range (^3.25.7). Additionally, the Zod-to-JSON-schema converter logic is refactored to use runtime type checks for metadata extraction, and two related test files are updated to reflect minor test case changes.

Changes

Files Change Summary
packages/*/package.json, playgrounds/*/package.json Updated zod in devDependencies from "3.25.0-beta.20250516T005923" to "^3.25.7" (stable caret range) in all relevant packages.
packages/zod/src/zod4/converter.ts Refactored metadata extraction: replaced type assertions with runtime checks, adjusted handling of exclusive/inclusive number bounds.
packages/zod/src/zod4/converter.native.test.ts Renamed a test case from 'file().mime(["*/*"])' to 'file()'; no logic changes.
packages/zod/src/zod4/converter.string.test.ts Simplified the regex pattern for the base64url schema test case to only check allowed characters, not length or padding.

Poem

🐇
From beta to stable, we hop with delight,
Caret and numbers now shining so bright.
With runtime checks, our schemas are neat,
And tests, like carrots, are simple and sweet.
A garden of code, all tidy and sound—
Zod’s latest version now hops all around!

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 262a4c9 and 4218efd.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (20)
  • packages/client/package.json (1 hunks)
  • packages/contract/package.json (1 hunks)
  • packages/nest/package.json (1 hunks)
  • packages/openapi/package.json (1 hunks)
  • packages/react-query/package.json (1 hunks)
  • packages/react/package.json (1 hunks)
  • packages/solid-query/package.json (1 hunks)
  • packages/svelte-query/package.json (1 hunks)
  • packages/zod/package.json (1 hunks)
  • packages/zod/src/zod4/converter.native.test.ts (1 hunks)
  • packages/zod/src/zod4/converter.string.test.ts (1 hunks)
  • packages/zod/src/zod4/converter.ts (6 hunks)
  • playgrounds/astro/package.json (1 hunks)
  • playgrounds/contract-first/package.json (1 hunks)
  • playgrounds/nest/package.json (1 hunks)
  • playgrounds/next/package.json (1 hunks)
  • playgrounds/nuxt/package.json (1 hunks)
  • playgrounds/solid-start/package.json (1 hunks)
  • playgrounds/svelte-kit/package.json (1 hunks)
  • playgrounds/tanstack-start/package.json (1 hunks)
🔇 Additional comments (16)
packages/client/package.json (1)

67-67: Update to stable Zod version in devDependencies
Replacing the beta pre-release with ^3.25.7 ensures you’re on the official stable release and can receive minor/patch updates within 3.25.x.

packages/zod/package.json (1)

54-54: Switch to stable Zod release
Upgrading the devDependency to ^3.25.7 aligns with the rest of the monorepo and ensures tests and build tooling target the official stable Zod build.

playgrounds/svelte-kit/package.json (1)

28-28: Use stable Zod version in playground
Moving from the beta tag to ^3.25.7 in devDependencies helps keep the SvelteKit playground synchronized with the stable Zod API.

packages/solid-query/package.json (1)

49-49: Upgrade Zod to stable version
Updating the devDependency to ^3.25.7 ensures your Solid Query adapters and tests rely on the latest stable Zod.

packages/nest/package.json (1)

74-74: Bump Zod devDependency to stable release
Switching from the beta pre-release to ^3.25.7 secures a stable API surface for your NestJS codegen and tests.

playgrounds/contract-first/package.json (1)

22-22:

Details

✅ Verification successful

Update Zod dependency to stable caret range
The zod devDependency was updated from a pre-release beta to ^3.25.7, allowing patch-level updates. Since the PR’s intent is to “adapt Zod 4 stable,” please confirm that this is the correct target version (e.g., if Zod v4 is desired, you may need to bump to ^4.x), and verify there are no remaining beta references in the repo:


🏁 Script executed:

#!/bin/bash
# 1. Find any leftover beta Zod entries
rg -l '"zod": ".*beta'
# 2. Fetch latest stable Zod version from npm
curl -s https://registry.npmjs.org/zod/latest | jq .version

Length of output: 95


Zod version is up-to-date and no beta references remain

  • No occurrences of "zod": ".*beta" found in the repo.
  • npm registry reports latest stable Zod version is 3.25.7, matching playgrounds/contract-first/package.json.

Since Zod v4 stable isn’t available yet, using ^3.25.7 is correct for now.

packages/react-query/package.json (1)

50-50:

Details

❓ Verification inconclusive

Verify intended Zod major version upgrade
The zod dependency has been updated to ^3.25.7, which is a stable v3 release, yet the PR title suggests migrating to Zod v4 stable. Please confirm if you intend to remain on v3 or upgrade to v4. If v4 is desired, adjust the version accordingly.

You can inspect available versions with:


🏁 Script executed:

npm view zod versions --json

Length of output: 11568


Zod v4 stable not available — verify your intended upgrade
The dependency "zod": "^3.25.7" is the latest stable v3 release; there is no stable v4 published on npm.
• If you meant to stick with v3, confirm that ^3.25.7 is correct.
• If you’re ready to try v4 today, switch to a beta (e.g. "zod": "^4.0.0-beta.20250505T001445").

  • packages/react-query/package.json: line 50
packages/openapi/package.json (1)

72-72: LGTM - Updating to stable zod version

The change from a beta version to the stable caret range ^3.25.7 is appropriate and aligns with the other packages in the repository.

playgrounds/astro/package.json (1)

28-28: LGTM - Consistent dependency version

The update to a stable zod version ^3.25.7 maintains consistency with other packages in the project.

packages/zod/src/zod4/converter.native.test.ts (1)

101-101: LGTM - Simplified test case name

The test case name has been simplified to 'file()' which better reflects the actual schema being tested. The actual test schema and input validation remain unchanged.

packages/zod/src/zod4/converter.string.test.ts (1)

134-134: LGTM - Simplified base64url pattern

The expected pattern for base64url has been simplified to ^[A-Za-z0-9_-]*$, which correctly matches the base64url character set without enforcing specific padding rules.

packages/zod/src/zod4/converter.ts (5)

127-152: LGTM - Improved type safety for string schema metadata

Replaced _zod.computed with _zod.bag and added explicit runtime type checks before accessing metadata properties, enhancing type safety and preventing potential runtime errors.


166-190: LGTM - Enhanced number schema handling with exclusive bounds support

Updated to use _zod.bag with proper runtime type checks and added explicit support for exclusiveMinimum and exclusiveMaximum properties in the JSON Schema output.


232-240: LGTM - Improved type safety for array schema metadata

Updated to use _zod.bag with proper runtime type checks for minimum and maximum properties.


335-343: LGTM - Improved type safety for tuple schema metadata

Updated to use _zod.bag with proper runtime type checks for minimum and maximum properties.


417-426: LGTM - Enhanced file schema handling with improved type checking

Updated to use _zod.bag and added thorough type checking for the mime property, ensuring it's either undefined or an array of strings before constructing the JSON Schema with contentMediaType.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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 May 20, 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 May 20, 2025

More templates

@orpc/arktype

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

@orpc/client

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

@orpc/contract

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

@orpc/nest

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

@orpc/openapi

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

@orpc/openapi-client

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

@orpc/react

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

@orpc/react-query

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

@orpc/server

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

@orpc/shared

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

@orpc/solid-query

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

@orpc/standard-server

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

@orpc/standard-server-fetch

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

@orpc/standard-server-node

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

@orpc/standard-server-peer

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

@orpc/svelte-query

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

@orpc/valibot

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

@orpc/vue-colada

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

@orpc/vue-query

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

@orpc/zod

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

commit: 4218efd

@dinwwwh dinwwwh merged commit a9447ff into main May 20, 2025
8 checks passed
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