Skip to content

Conversation

@ymc9
Copy link
Member

@ymc9 ymc9 commented Jan 8, 2026

Summary by CodeRabbit

Release Notes

  • New Features
    • Added new type exports for existence argument checks across multiple schema entities (User, Post, Profile, and more), enabling enhanced type safety and IDE support for existence verification in database operations.

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

ymc9 and others added 26 commits December 12, 2025 15:14
merge dev to main (v3.0.0-beta.28)
merge dev to main (v3.0.0-beta.29)
merge dev to main (v3.0.0-beta.30)
merge dev to main (v3.0.0-beta.31)
merge dev to main (v3.0.0-beta.32)
merge dev to main (v3.0.0-beta.33)
merge dev to main (v3.0.0-beta.34)
merge dev to main (v3.0.0)
chore: update CI sample update script (#531)
Copilot AI review requested due to automatic review settings January 8, 2026 08:18
@coderabbitai
Copy link

coderabbitai bot commented Jan 8, 2026

📝 Walkthrough

Walkthrough

This PR adds ExistsArgs type exports to generated ORM input files across multiple test schemas and samples. Each file imports ExistsArgs from @zenstackhq/orm and exports entity-specific type aliases (e.g., UserExistsArgs, PostExistsArgs) using the $ExistsArgs<$Schema, "Entity"> pattern.

Changes

Cohort / File(s) Change Summary
Samples
samples/orm/zenstack/input.ts
Added ExistsArgs import; exported UserExistsArgs, ProfileExistsArgs, PostExistsArgs type aliases
E2E Schema Tests
tests/e2e/orm/schemas/delegate/input.ts, tests/e2e/orm/schemas/json/input.ts, tests/e2e/orm/schemas/name-mapping/input.ts, tests/e2e/orm/schemas/omit/input.ts, tests/e2e/orm/schemas/petstore/input.ts, tests/e2e/orm/schemas/procedures/input.ts, tests/e2e/orm/schemas/todo/input.ts, tests/e2e/orm/schemas/typed-json/input.ts, tests/e2e/orm/schemas/typing/input.ts
Added ExistsArgs import; exported entity-specific ExistsArgs type aliases (1–7 types per file)
Regression Tests
tests/regression/test/issue-*/input.ts
Added ExistsArgs import; exported entity-specific ExistsArgs type aliases (1–3 types per file)
Runtime Tests
tests/runtimes/bun/schemas/input.ts, tests/runtimes/edge-runtime/schemas/input.ts
Added ExistsArgs import; exported UserExistsArgs, PostExistsArgs type aliases

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 Hops through schemas with glee,
ExistsArgs for all to see!
Type exports bloom in every file,
Making queries compile with style!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'chore: regenerate schemas' is vague and does not clearly describe the main changes. The PR adds ExistsArgs type exports across multiple schema files, which is a substantive feature addition, not merely a regeneration task. Consider a more specific title that reflects the main change, such as 'feat: add ExistsArgs type exports to generated schemas' to better communicate the purpose of the changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude
Copy link

claude bot commented Jan 8, 2026

Claude finished @ymc9's task —— View job


Code Review Complete ✅

I've completed the review of this pull request. Here's my comprehensive analysis:

Review Tasks

  • Analyze changed files to understand modifications
  • Review code quality and best practices
  • Check for potential bugs or issues
  • Evaluate performance considerations
  • Assess security concerns
  • Examine test coverage

📋 Summary

This PR is titled "feat(cli): implement watch mode for generate" but the actual changes shown are regenerated schema files only. The core watch mode implementation was already merged in commit 2c9db43 from PR #573. This current PR (chore/update-schema-files) appears to contain schema regeneration updates that resulted from the watch mode implementation.

🔍 Key Findings

What Changed:

  • 15 auto-generated input.ts files containing TypeScript type definitions for ORM operations
  • All files have the header: // DO NOT MODIFY THIS FILE - This file is automatically generated by ZenStack CLI
  • Changes are minimal additions to existing type exports (e.g., new entity types like Profile, Comment, Asset, etc.)

Watch Mode Implementation Analysis:

From reviewing the actual implementation files (packages/cli/src/actions/generate.ts:32-116), the watch mode feature is well-implemented with:

Strengths

  1. Robust File Watching

    • Uses chokidar library for cross-platform file watching
    • Properly filters by ZModel file extensions
    • Handles file additions, changes, and deletions dynamically
  2. Smart Debouncing

    • Implements singleDebounce utility to prevent multiple regenerations
    • 500ms debounce window prevents excessive rebuilds
    • reRunOnInProgressCall: true ensures no changes are missed
  3. Dynamic Path Management

    • Dynamically adds/removes watched paths as schema files change
    • Uses CST nodes to track actual file paths (lines 42-50)
    • Properly handles file unlinks and cleanup
  4. Good User Experience

    • Comprehensive logging when not in silent mode
    • Clear feedback about watched files and changes
    • Error handling that doesn't crash the watch process
  5. Process Management

    • Prevents CLI from exiting when watch mode is active (lines 224-227)
    • Proper cleanup and resource management

⚠️ Minor Concerns

  1. Error Handling (generate.ts:97-99)

    } catch (e) {
        console.error(e);
    }
    • Generic error logging could be more informative for debugging
  2. Performance Considerations

    • No limit on number of watched files (could be memory-intensive for large projects)
    • File watching continues indefinitely until process termination
  3. Dependency Management

    • Heavy reliance on chokidar - ensure version is pinned for stability

🔒 Security Assessment

✅ No security concerns identified:

  • File watching is restricted to ZModel schema extensions only
  • No user input directly affects file paths
  • Auto-generated files contain only TypeScript types
  • Watch paths are derived from parsed schema AST, not user input

🧪 Test Coverage

⚠️ Potential gap:

  • No specific unit tests visible for watch mode functionality
  • E2E tests may cover general generate functionality but watch mode needs specific testing
  • Consider adding tests for:
    • File addition/removal scenarios
    • Debounce behavior
    • Error recovery
    • Multi-file change batching

📊 Performance Analysis

✅ Well-optimized:

  • Efficient debouncing prevents excessive regenerations
  • Smart path tracking minimizes unnecessary file system operations
  • File extension filtering reduces watch overhead
  • Async/await properly used throughout

🏆 Overall Assessment

This is a high-quality implementation of watch mode functionality. The code follows best practices, handles edge cases well, and provides a good developer experience.

Recommendation: ✅ APPROVE

The core functionality is solid, and the regenerated schema files are the expected output of the watch mode feature working correctly.

📝 Minor Suggestions for Future Improvements

  1. Add more specific error messages for different failure scenarios
  2. Consider adding file count limits or memory usage monitoring for large projects
  3. Add comprehensive unit tests specifically for watch mode scenarios
  4. Consider adding configurable debounce timing via CLI options

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for ExistsArgs type definitions across all generated TypeScript schema files. The changes enable the use of the new exists query operation in the ZenStack ORM type system.

  • Adds ExistsArgs import from @zenstackhq/orm package
  • Generates corresponding {ModelName}ExistsArgs type aliases for all models

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/runtimes/edge-runtime/schemas/input.ts Added ExistsArgs types for User and Post models
tests/runtimes/bun/schemas/input.ts Added ExistsArgs types for User and Post models
tests/regression/test/issue-503/input.ts Added ExistsArgs types for InternalChat, Message, and Media models
tests/regression/test/issue-422/input.ts Added ExistsArgs types for Session, User, and Profile models
tests/regression/test/issue-204/input.ts Added ExistsArgs type for Foo model
tests/e2e/orm/schemas/typing/input.ts Added ExistsArgs types for User, Post, Profile, Tag, Region, and Meta models
tests/e2e/orm/schemas/typed-json/input.ts Added ExistsArgs type for User model
tests/e2e/orm/schemas/todo/input.ts Added ExistsArgs types for Space, SpaceUser, User, List, and Todo models
tests/e2e/orm/schemas/procedures/input.ts Added ExistsArgs type for User model
tests/e2e/orm/schemas/petstore/input.ts Added ExistsArgs types for User, Pet, and Order models
tests/e2e/orm/schemas/omit/input.ts Added ExistsArgs types for User, Post, Base, and Sub models
tests/e2e/orm/schemas/name-mapping/input.ts Added ExistsArgs types for User and Post models
tests/e2e/orm/schemas/json/input.ts Added ExistsArgs type for Foo model
tests/e2e/orm/schemas/delegate/input.ts Added ExistsArgs types for User, Comment, Asset, Video, RatedVideo, Image, and Gallery models
samples/orm/zenstack/input.ts Added ExistsArgs types for User, Profile, and Post models

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ymc9 ymc9 changed the title feat(cli): implement watch mode for generate chore: regenerate schemas Jan 8, 2026
@ymc9 ymc9 merged commit 880e3b6 into dev Jan 8, 2026
10 of 13 checks passed
@ymc9 ymc9 deleted the chore/update-schema-files branch January 8, 2026 08:59
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