Skip to content

Conversation

@eluce2
Copy link
Collaborator

@eluce2 eluce2 commented Jul 21, 2025

typgen strict numbers

Refactor type generation functions for improved usability and cleanup. Update strict number handling in buildSchema and enhance test structure in typegen tests.

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of strict number fields to coerce values and gracefully handle parsing errors.
  • Tests

    • Refactored and modularized test utilities for type generation.
    • Added a new test case to verify strict number handling.
    • Updated and cleaned up test output directories for better isolation.
    • Added a new snapshot file reflecting updated schema outputs.
  • Chores

    • Removed obsolete and auto-generated test files and exports to streamline the codebase.
    • Added a changeset documenting the patch update.

eluce2 added 2 commits July 21, 2025 13:03
…. Update strict number handling in buildSchema and enhance test structure in typegen tests.
@vercel
Copy link

vercel bot commented Jul 21, 2025

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

Name Status Preview Updated (UTC)
proofkit-docs 🔄 Building (Inspect) Visit Preview Jul 21, 2025 6:14pm

@eluce2 eluce2 requested a review from chriscors July 21, 2025 18:14
Copy link
Collaborator Author

eluce2 commented Jul 21, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@eluce2 eluce2 marked this pull request as ready for review July 21, 2025 18:14
@chriscors chriscors merged commit 05e63e7 into main Jul 21, 2025
2 of 4 checks passed
@coderabbitai
Copy link

coderabbitai bot commented Jul 21, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This change set removes several auto-generated TypeScript client and schema files related to test layouts, updates the Zod schema generation logic for strict number handling to use coercion and fallback, adds a new snapshot test for strict number schemas, and refactors the type generation test suite for better modularity and clarity.

Changes

File(s) Change Summary
.changeset/brown-dogs-nail.md Added changeset documenting a patch for strict number coercion in @proofkit/typegen.
packages/typegen/src/buildSchema.ts Modified strict number Zod schema generation to use z.coerce.number().nullable().catch(null).
packages/typegen/tests/snapshots/strict-numbers.snap.ts Added new auto-generated snapshot file with Zod schemas and inferred types for strict number handling.
packages/typegen/tests/typegen.test.ts Refactored test utilities into reusable exports, unified path handling, added strictNumbers test, improved isolation.
.../tests/typegen-output/config1/client/index.ts Removed export of client as testLayoutLayout.
.../tests/typegen-output/config1/client/testLayout.ts Deleted auto-generated client configuration file.
.../tests/typegen-output/config1/testLayout.ts Deleted user-customizable schema/type overrides file.
.../tests/typegen-output/config2/client/index.ts Deleted file re-exporting client as testLayoutClient.
.../tests/typegen-output/config2/client/testLayout.ts Deleted auto-generated client configuration file.
.../tests/typegen-output/config2/testLayout.ts Deleted user-customizable type overrides file.

Sequence Diagram(s)

sequenceDiagram
    participant TestRunner
    participant TypeGen
    participant FileSystem
    participant Zod

    TestRunner->>TypeGen: generateTypes(config)
    TypeGen->>FileSystem: Create output directory
    TypeGen->>TypeGen: generateTypedClients()
    TypeGen->>FileSystem: Write generated files
    TypeGen->>Zod: Generate schemas (with z.coerce.number().nullable().catch(null) for strict numbers)
    TestRunner->>FileSystem: Run type check on generated files
    TestRunner->>FileSystem: Read generated TypeScript file
    TestRunner->>TestRunner: Assert file matches snapshot
Loading

Estimated code review effort

2 (~15 minutes)

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.

packages/typegen/src/buildSchema.ts

Oops! Something went wrong! :(

ESLint: 9.27.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

packages/typegen/tests/typegen.test.ts

Oops! Something went wrong! :(

ESLint: 9.27.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

packages/typegen/tests/__snapshots__/strict-numbers.snap.ts

Oops! Something went wrong! :(

ESLint: 9.27.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fd1a9f6 and 56270f6.

📒 Files selected for processing (10)
  • .changeset/brown-dogs-nail.md (1 hunks)
  • packages/typegen/Users/ericluce/Documents/Code/work/proofkit/packages/typegen/tests/typegen-output/config1/client/index.ts (0 hunks)
  • packages/typegen/Users/ericluce/Documents/Code/work/proofkit/packages/typegen/tests/typegen-output/config1/client/testLayout.ts (0 hunks)
  • packages/typegen/Users/ericluce/Documents/Code/work/proofkit/packages/typegen/tests/typegen-output/config1/testLayout.ts (0 hunks)
  • packages/typegen/Users/ericluce/Documents/Code/work/proofkit/packages/typegen/tests/typegen-output/config2/client/index.ts (0 hunks)
  • packages/typegen/Users/ericluce/Documents/Code/work/proofkit/packages/typegen/tests/typegen-output/config2/client/testLayout.ts (0 hunks)
  • packages/typegen/Users/ericluce/Documents/Code/work/proofkit/packages/typegen/tests/typegen-output/config2/testLayout.ts (0 hunks)
  • packages/typegen/src/buildSchema.ts (1 hunks)
  • packages/typegen/tests/__snapshots__/strict-numbers.snap.ts (1 hunks)
  • packages/typegen/tests/typegen.test.ts (6 hunks)
✨ 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.
    • 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.

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.

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.

3 participants