Skip to content

use zod/v4#748

Merged
philiplehmann merged 1 commit intomainfrom
zod-v4
Jul 13, 2025
Merged

use zod/v4#748
philiplehmann merged 1 commit intomainfrom
zod-v4

Conversation

@philiplehmann
Copy link
Owner

@philiplehmann philiplehmann commented Jul 13, 2025

Summary by CodeRabbit

  • Refactor

    • Updated type imports and usage to use explicit versioned imports from Zod v4 for improved type safety and consistency.
    • Adjusted function and method signatures in validation utilities to align with updated Zod v4 typings, affecting type annotations for schemas and outputs.
    • Modified enum validation methods in schemas for consistency.
  • Style

    • Cleaned up and simplified import statements across several files.
  • Tests

    • Updated test files to use Zod v4 imports and removed unused imports for clarity.

@coderabbitai
Copy link

coderabbitai bot commented Jul 13, 2025

Walkthrough

The changes update import statements across multiple files to use zod/v4 instead of the generic zod path, and adjust type usages to the new Zod v4 API (output, ZodType, ZodObject). Several function signatures and type annotations are updated accordingly, particularly in HTTP validation utilities, to align with the updated Zod typings. Enum validation methods in some schemas are changed from nativeEnum to enum. No runtime logic or control flow is altered.

Changes

File(s) Change Summary
apps/pdftk/src/schema.ts, libs/binary/pdftk/src/lib/decrypt.ts, libs/binary/pdftk/src/lib/encrypt.ts, libs/binary/pdftk/src/lib/form-fill.ts, libs/http/body/src/lib/request-to-json.ts, libs/http/body/src/lib/request-to-multipart-form-data/request-to-multipart-form-data.ts, libs/http/body/src/lib/request-to-text.ts, libs/http/multipart-form-data/src/lib/http-multipart-form-data.ts Changed Zod import path from 'zod' to 'zod/v4'. No logic changes.
libs/http/body/src/lib/validate-request-headers.ts Changed type import from ZodType to ZodObject from 'zod/v4'; updated function parameter type accordingly. No logic changes.
libs/binary/puppeteer/src/lib/body-schema.ts Changed Zod imports to 'zod/v4'; updated function parameter type from RawCreateParams to core.$ZodUnionParams.
libs/binary/puppeteer/src/lib/query-schema.ts Changed Zod import to 'zod/v4'; replaced z.nativeEnum with z.enum for schema validation.
libs/binary/puppeteer/src/lib/render-to.ts Changed type import from TypeOf to output from 'zod/v4'; updated method parameter type accordingly.
libs/http/validate/src/lib/body.ts Updated all Zod type references to use ZodType and output from 'zod/v4'; updated function signatures and type annotations.
libs/http/validate/src/lib/query.ts Updated Zod type references to use ZodType and output from 'zod/v4'; updated function signatures and type annotations.
libs/http/validate/src/lib/validate-combo.spec.ts, libs/http/validate/src/lib/validate-single.spec.ts Cleaned up unused imports; changed Zod import to 'zod/v4'. No logic or test changes.
libs/binary/unoserver/src/lib/schema.ts Changed Zod import to 'zod/v4'; replaced z.nativeEnum with z.enum for the convertTo property in schema.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant HTTP Layer
    participant Validation Middleware
    participant Zod v4 Schema

    User->>HTTP Layer: Sends request
    HTTP Layer->>Validation Middleware: Passes request data
    Validation Middleware->>Zod v4 Schema: Validates input (body/query)
    Zod v4 Schema-->>Validation Middleware: Returns parsed/validated data
    Validation Middleware-->>HTTP Layer: Passes validated data
    HTTP Layer-->>User: Returns response
Loading

Poem

🐇
A hop to Zod v4, so spry and neat,
Imports updated, type signatures meet.
Schemas now fresher, with output in tow,
The codebase is ready for data to flow!
With every request, validation shines bright—
Hooray for the upgrade, all code feels just right!

✨ 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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (4)
libs/http/body/src/lib/request-to-multipart-form-data/request-to-multipart-form-data.ts (1)

3-3: Same resolution concern as above

This file has the identical import-path change; see previous comment.

libs/http/body/src/lib/request-to-json.ts (1)

4-4: Same resolution concern as above

This file has the identical import-path change; see previous comment.

libs/http/body/src/lib/request-to-text.ts (1)

3-3: Same resolution concern as above

This file has the identical import-path change; see previous comment.

libs/binary/pdftk/src/lib/form-fill.ts (1)

6-6: Same resolver caveat for zod/v4

See comment in decrypt.ts; ensure the sub-path works for this package too (especially when pdftk is used from other runtimes like AWS Lambda layers).

🧹 Nitpick comments (1)
libs/http/validate/src/lib/validate-single.spec.ts (1)

1-4: Cleaned imports & switched to zod/v4 – nice cleanup

Unused imports were removed and the test file now mirrors the new Zod import path. Reads cleaner and avoids tslint/ESLint warnings.

You could sort the remaining imports alphabetically to match the repo style, but that’s purely cosmetic.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3601232 and 6f44830.

📒 Files selected for processing (16)
  • apps/pdftk/src/schema.ts (1 hunks)
  • libs/binary/pdftk/src/lib/decrypt.ts (1 hunks)
  • libs/binary/pdftk/src/lib/encrypt.ts (1 hunks)
  • libs/binary/pdftk/src/lib/form-fill.ts (1 hunks)
  • libs/binary/puppeteer/src/lib/body-schema.ts (1 hunks)
  • libs/binary/puppeteer/src/lib/query-schema.ts (1 hunks)
  • libs/binary/puppeteer/src/lib/render-to.ts (2 hunks)
  • libs/http/body/src/lib/request-to-json.ts (1 hunks)
  • libs/http/body/src/lib/request-to-multipart-form-data/request-to-multipart-form-data.ts (1 hunks)
  • libs/http/body/src/lib/request-to-text.ts (1 hunks)
  • libs/http/body/src/lib/validate-request-headers.ts (1 hunks)
  • libs/http/multipart-form-data/src/lib/http-multipart-form-data.ts (1 hunks)
  • libs/http/validate/src/lib/body.ts (3 hunks)
  • libs/http/validate/src/lib/query.ts (3 hunks)
  • libs/http/validate/src/lib/validate-combo.spec.ts (1 hunks)
  • libs/http/validate/src/lib/validate-single.spec.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
libs/binary/puppeteer/src/lib/render-to.ts (2)
libs/binary/unoserver/src/lib/schema.ts (1)
  • schema (4-6)
libs/binary/puppeteer/src/lib/body-schema.ts (1)
  • bodySchema (58-61)
libs/http/validate/src/lib/query.ts (2)
libs/http/route/src/lib/http-route.ts (2)
  • ReqRes (28-31)
  • Next (39-41)
libs/http/route/src/lib/route.ts (1)
  • Prefix (9-9)
🔇 Additional comments (19)
libs/http/multipart-form-data/src/lib/http-multipart-form-data.ts (1)

3-3: Verify that the zod/v4 sub-path is correctly resolved by every runtime (Node, bundler, Jest, etc.)

The official Zod package only exposes versioned entry points if you install the exact matching major version.
Before merging, double-check:

  1. package.json actually pins "zod": "^4.x" (or contains an exports map exposing ./v4).
  2. Your tsconfig / Jest / Webpack/Rollup config doesn’t still alias plain "zod" elsewhere – mixed import paths will lead to duplicate copies or runtime “module not found” errors.

If any consumer still relies on the bare "zod" path, consider re-exporting once from a local wrapper (e.g. src/zod.ts) to avoid churn.

libs/binary/pdftk/src/lib/decrypt.ts (1)

3-3: Confirm zod/v4 sub-path is resolvable in all build targets

Using the sub-path export ('zod/v4') is fine with Node ≥16 and bundlers that respect the "exports" field, but older tooling (Jest <29, ts-node <10.9, some Webpack configs) may not resolve it without extra configuration.
Please verify that every consumer (tests, CLIs, lambdas, etc.) runs on a resolver that supports package exports; otherwise fall back to import { z } from 'zod' or add the necessary resolver upgrade.

libs/binary/pdftk/src/lib/encrypt.ts (1)

3-3: Import path update looks good – just double-check compatibility

No logic changes; once the resolver compatibility is confirmed, this is 👍.

apps/pdftk/src/schema.ts (1)

1-1: Schema file aligned with zod/v4

Consistent with the rest of the refactor; no issues spotted beyond the resolver note already mentioned.

libs/http/validate/src/lib/validate-combo.spec.ts (1)

4-4: LGTM! Clean import path update for zod v4 migration.

The import change is consistent with the PR objective and maintains the same functionality.

libs/binary/puppeteer/src/lib/query-schema.ts (2)

1-1: LGTM! Import path updated for zod v4.

The import change aligns with the migration to zod/v4.


5-5: z.enum() usage is correct
Verified that ScreenshotType is defined as a TypeScript enum in libs/binary/puppeteer/src/lib/screenshot-type.ts:

export enum ScreenshotType {
  png = 'png',
  jpeg = 'jpeg',
  webp = 'webp',
}

Using z.enum(ScreenshotType) is therefore valid and no further changes are needed.

libs/binary/puppeteer/src/lib/render-to.ts (2)

4-4: LGTM! Correct type import update for zod v4.

The change from TypeOf to output is the correct migration path for zod v4.


46-46: LGTM! Parameter type correctly updated.

The type annotation correctly uses the new output type from zod v4, maintaining the same functionality.

libs/binary/puppeteer/src/lib/body-schema.ts (2)

2-2: LGTM! Import updated for zod v4 with correct core type access.

The import change correctly accesses the core types needed for the union parameters.


4-7: LGTM! Function signature and type correctly updated.

The parameter type change from RawCreateParams to core.$ZodUnionParams is the correct migration path for zod v4, and the multi-line formatting improves readability.

libs/http/validate/src/lib/body.ts (4)

4-4: LGTM! Imports correctly updated for zod v4.

The change from ZodSchema and TypeOf to ZodType and output is the correct migration path for zod v4.


6-8: LGTM! Function signature correctly updated.

The generic constraint and return type are properly updated to use ZodType and output from zod v4.


23-24: LGTM! Overload signatures correctly updated.

All the nextBody function overloads properly use the new zod v4 types while maintaining the same functionality.

Also applies to: 29-31, 36-36


53-53: LGTM! Middleware function types correctly updated.

The middlewareBody function generic constraints and return types are properly migrated to use zod v4 types.

Also applies to: 61-63

libs/http/validate/src/lib/query.ts (4)

3-3: LGTM: Correct import update for zod v4.

The import statement correctly updates to use the version-specific path and imports the appropriate types for zod v4.


23-24: LGTM: Consistent type updates in nextQuery overloads.

All overload signatures correctly update the generic constraints from ZodSchema to ZodObject and return types from TypeOf to output, maintaining consistency across the function declarations.

Also applies to: 29-30, 34-34, 40-40


58-58: LGTM: Proper type updates in middlewareQuery.

The function signature and return type annotations are correctly updated to use ZodObject and output respectively, consistent with the zod v4 migration.

Also applies to: 65-65, 67-67


5-7: No breaking change detected for validateQuery

Our search found no calls to validateQuery with non‐object schemas anywhere in the repository. Since every usage passes an object schema, tightening the parameter type from ZodSchema to ZodObject introduces no breaking changes.

@philiplehmann philiplehmann force-pushed the zod-v4 branch 5 times, most recently from bc11b9b to f55e3ab Compare July 13, 2025 17:00
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f55e3ab and 6c419b1.

📒 Files selected for processing (17)
  • apps/pdftk/src/schema.ts (1 hunks)
  • libs/binary/pdftk/src/lib/decrypt.ts (1 hunks)
  • libs/binary/pdftk/src/lib/encrypt.ts (1 hunks)
  • libs/binary/pdftk/src/lib/form-fill.ts (1 hunks)
  • libs/binary/puppeteer/src/lib/body-schema.ts (1 hunks)
  • libs/binary/puppeteer/src/lib/query-schema.ts (1 hunks)
  • libs/binary/puppeteer/src/lib/render-to.ts (2 hunks)
  • libs/binary/unoserver/src/lib/schema.ts (1 hunks)
  • libs/http/body/src/lib/request-to-json.ts (1 hunks)
  • libs/http/body/src/lib/request-to-multipart-form-data/request-to-multipart-form-data.ts (1 hunks)
  • libs/http/body/src/lib/request-to-text.ts (1 hunks)
  • libs/http/body/src/lib/validate-request-headers.ts (1 hunks)
  • libs/http/multipart-form-data/src/lib/http-multipart-form-data.ts (1 hunks)
  • libs/http/validate/src/lib/body.ts (3 hunks)
  • libs/http/validate/src/lib/query.ts (3 hunks)
  • libs/http/validate/src/lib/validate-combo.spec.ts (1 hunks)
  • libs/http/validate/src/lib/validate-single.spec.ts (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • libs/binary/pdftk/src/lib/encrypt.ts
  • libs/binary/pdftk/src/lib/form-fill.ts
🚧 Files skipped from review as they are similar to previous changes (14)
  • libs/http/body/src/lib/request-to-multipart-form-data/request-to-multipart-form-data.ts
  • libs/binary/pdftk/src/lib/decrypt.ts
  • libs/http/multipart-form-data/src/lib/http-multipart-form-data.ts
  • apps/pdftk/src/schema.ts
  • libs/http/body/src/lib/request-to-json.ts
  • libs/http/body/src/lib/request-to-text.ts
  • libs/binary/puppeteer/src/lib/render-to.ts
  • libs/http/validate/src/lib/validate-combo.spec.ts
  • libs/binary/puppeteer/src/lib/body-schema.ts
  • libs/binary/puppeteer/src/lib/query-schema.ts
  • libs/http/body/src/lib/validate-request-headers.ts
  • libs/http/validate/src/lib/validate-single.spec.ts
  • libs/http/validate/src/lib/query.ts
  • libs/http/validate/src/lib/body.ts
⏰ 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). (2)
  • GitHub Check: test (ubuntu-24.04, arm64)
  • GitHub Check: test (ubuntu-24.04, amd64)
🔇 Additional comments (1)
libs/binary/unoserver/src/lib/schema.ts (1)

1-1: LGTM! Import update aligns with Zod v4 migration.

The explicit import from zod/v4 is consistent with the broader codebase migration mentioned in the PR summary.

@philiplehmann philiplehmann merged commit c4bb27e into main Jul 13, 2025
5 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jan 22, 2026
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