Skip to content

Conversation

@ymc9
Copy link
Member

@ymc9 ymc9 commented Aug 15, 2025

Summary by CodeRabbit

  • New Features

    • Improved nested relation queries: filtering, ordering, pagination, cursor, and distinct on to-many relations; conditional filtering on optional to-one relations.
    • Query hooks now recognize additional find operations (improved hook coverage).
  • Refactor

    • Consolidated relation selection/include/omit handling for consistent behavior.
  • Tests

    • Added extensive tests for nested relation queries, counts, and updated error expectations.
  • Chores

    • Bumped workspace package versions to 3.0.0-alpha.26.

github-actions bot and others added 2 commits August 15, 2025 18:01
* fix: relation selection input validation issue

* update

* fix test
Copilot AI review requested due to automatic review settings August 15, 2025 10:29
@coderabbitai
Copy link

coderabbitai bot commented Aug 15, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Version bumps across many package.json files to 3.0.0-alpha.26. Runtime FindArgs type moves Distinct/Cursor into the collection branch. Validator refactors relation select/include schema via a helper to add filtering/pagination for relations. Extensive nested-relation tests added and an error expectation updated.

Changes

Cohort / File(s) Summary
Root & packages version bumps
package.json, packages/*/package.json (cli, common-helpers, create-zenstack, dialects/sql.js, eslint-config, ide/vscode, language, runtime, sdk, tanstack-query, testtools, typescript-config, vitest-config, zod), samples/blog/package.json, tests/e2e/package.json
Bump versions from 3.0.0-alpha.25 to 3.0.0-alpha.26. No other changes.
Runtime types
packages/runtime/src/client/crud-types.ts
Moves Distinct<...> and Cursor<...> into the Collection extends true branch of FindArgs; trailing tail now ends with SelectIncludeOmit<...> only.
Validator relation schema & helpers
packages/runtime/src/client/crud/validator.ts
Adds makeRelationSelectIncludeSchema helper; gates addition of cursor/distinct/pagination by !options.unique; enables where for to-many and optional to-one relations and consolidates select/include/omit schemas.
Client API tests
packages/runtime/test/client-api/find.test.ts
Adds extensive tests for nested relation select/include with filtering, ordering, pagination, distinct, counts, $expr, and updates an error expectation to “Invalid find args”.
Operations/plugin types
packages/runtime/src/client/crud/operations/base.ts, packages/runtime/src/client/plugin.ts
Adds AllCrudOperation (adds 'findUniqueOrThrow' and 'findFirstOrThrow') and updates plugin hook context to use AllCrudOperation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

A twitch of whiskers, versions rise,
Distinct and Cursor reorganize.
Relations learn to filter, glide—
skip and take along the ride.
Tests burrow deep, the burrow's neat;
now queries hop on nimble feet. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@claude
Copy link

claude bot commented Aug 15, 2025

Claude finished @ymc9's task —— View job


Code Review Complete ✅

I've reviewed PR #177 (dev → main merge) and here's my comprehensive analysis:

Overall Assessment

This is a well-structured release PR that bumps version from 3.0.0-alpha.25 to 3.0.0-alpha.26 across all packages, along with important runtime validation improvements.

Key Changes

📦 Version Bumps (20 files)

  • Consistent version bump to 3.0.0-alpha.26 across all packages
  • All package.json files properly updated

🔧 Runtime Validation Improvements

  • Fixed relation selection validation: Improved validation logic for relation includes with filtering
  • Enhanced test coverage: Added 92 lines of comprehensive tests for relation filtering scenarios
  • Type refinements: Cleaned up type definitions for better developer experience

Code Quality Analysis

✅ Strengths:

  1. Consistent versioning - All 20 packages properly versioned
  2. Comprehensive testing - New tests thoroughly cover relation filtering edge cases
  3. Type safety - Changes maintain strong TypeScript inference
  4. Clean validation logic - Improved input validation with better error handling
  5. Backward compatibility - No breaking changes detected

🔍 Key Technical Improvements:

validator.ts (packages/runtime/src/client/crud/validator.ts:629-653):

  • Enhanced makeRelationSelectIncludeSchema to properly validate relation filtering
  • Fixed issue where where clauses in relation includes weren't properly validated
  • Better separation of concerns between to-many and to-one relations

find.test.ts (packages/runtime/test/client-api/find.test.ts:867-872):

  • Added critical test case for invalid relation filtering scenarios
  • Tests now properly validate that non-filterable relations throw appropriate errors
  • Improved error message validation

Security & Performance

  • No security concerns - Changes are limited to validation improvements
  • No performance regressions - Validation improvements should be minimal overhead
  • Input validation enhanced - Better protection against malformed queries

Test Coverage

  • Excellent test coverage - New tests specifically target the fixed functionality
  • Regression protection - Tests prevent future validation issues
  • Error scenarios covered - Invalid usage patterns properly tested

Recommendations

  1. Ready for merge - This is a solid release with important bug fixes
  2. Consider integration testing - Run full test suite to ensure cross-package compatibility
  3. Monitor post-merge - Watch for any issues with the validation improvements in production

Summary

This PR represents a quality release that:

  • Fixes a real validation issue with relation filtering
  • Maintains full backward compatibility
  • Adds proper test coverage
  • Follows consistent versioning practices

Approval Status: ✅ APPROVED - Well-executed release with important improvements.


@ymc9 ymc9 changed the title merge dev to main merge dev to main (v3.0.0-alpha.26) Aug 15, 2025
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 merges development branch changes to main, primarily involving a version bump from 3.0.0-alpha.25 to 3.0.0-alpha.26 across all packages, along with significant improvements to relation filtering and query validation.

  • Version bump across all packages from 3.0.0-alpha.25 to 3.0.0-alpha.26
  • Enhanced relation filtering capabilities for optional to-one and to-many relations
  • Improved query validation with more specific error messages and comprehensive test coverage

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
package.json (root) Version bump to 3.0.0-alpha.26
packages/*/package.json Version bump across all packages
packages/runtime/src/client/crud/validator.ts Refactored relation schema validation with new filtering capabilities
packages/runtime/src/client/crud-types.ts Restructured type definitions for better query argument organization
packages/runtime/test/client-api/find.test.ts Added comprehensive tests for new relation filtering features

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

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: 2

🧹 Nitpick comments (4)
packages/testtools/package.json (1)

3-3: Test tools version bump approved

Looks consistent with the monorepo release. Since this is a published package, ensure CHANGELOG/release notes reflect the new pre-release if applicable.

package.json (1)

3-3: Root version bump confirmed.

Matches the monorepo release plan. Consider tagging the release and updating release notes when merging dev to main.

packages/runtime/test/client-api/find.test.ts (2)

640-659: Solid coverage: nested to-many selection with where/orderBy/distinct in select/include.

These tests validate the extended nested relation args well and mirror both select and include paths. Consider adding one negative test asserting that nested objects cannot have both select and include once the validator enforces that rule.

I can add a failing test now and follow up with the validator refinement. Want me to open a PR with both?

Also applies to: 661-680


872-873: Assertion updated to new validation message; consider asserting on error type for stability.

The message "Invalid find args" is fine, but string-based matching can be brittle. If feasible, assert on InputValidationError to make the test less sensitive to message changes.

For example:

await expect(
  client.post.findFirstOrThrow({
    // @ts-expect-error
    include: { author: { where: { email: user.email } } },
  })
).rejects.toThrow(InputValidationError);
📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between acbd2ae and f2199db.

📒 Files selected for processing (20)
  • package.json (1 hunks)
  • packages/cli/package.json (1 hunks)
  • packages/common-helpers/package.json (1 hunks)
  • packages/create-zenstack/package.json (1 hunks)
  • packages/dialects/sql.js/package.json (1 hunks)
  • packages/eslint-config/package.json (1 hunks)
  • packages/ide/vscode/package.json (1 hunks)
  • packages/language/package.json (1 hunks)
  • packages/runtime/package.json (1 hunks)
  • packages/runtime/src/client/crud-types.ts (1 hunks)
  • packages/runtime/src/client/crud/validator.ts (3 hunks)
  • packages/runtime/test/client-api/find.test.ts (2 hunks)
  • packages/sdk/package.json (1 hunks)
  • packages/tanstack-query/package.json (1 hunks)
  • packages/testtools/package.json (1 hunks)
  • packages/typescript-config/package.json (1 hunks)
  • packages/vitest-config/package.json (1 hunks)
  • packages/zod/package.json (1 hunks)
  • samples/blog/package.json (1 hunks)
  • tests/e2e/package.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
tests/e2e/**

📄 CodeRabbit Inference Engine (CLAUDE.md)

E2E tests are in tests/e2e/ directory

Files:

  • tests/e2e/package.json
{packages,samples,tests}/**

📄 CodeRabbit Inference Engine (CLAUDE.md)

Packages are located in packages/, samples/, and tests/

Files:

  • tests/e2e/package.json
  • samples/blog/package.json
  • packages/ide/vscode/package.json
  • packages/eslint-config/package.json
  • packages/tanstack-query/package.json
  • packages/zod/package.json
  • packages/create-zenstack/package.json
  • packages/dialects/sql.js/package.json
  • packages/sdk/package.json
  • packages/runtime/package.json
  • packages/cli/package.json
  • packages/language/package.json
  • packages/vitest-config/package.json
  • packages/common-helpers/package.json
  • packages/testtools/package.json
  • packages/runtime/test/client-api/find.test.ts
  • packages/typescript-config/package.json
  • packages/runtime/src/client/crud/validator.ts
  • packages/runtime/src/client/crud-types.ts
🧠 Learnings (2)
📚 Learning: 2025-08-04T08:43:33.161Z
Learnt from: CR
PR: zenstackhq/zenstack-v3#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-04T08:43:33.161Z
Learning: `zenstack generate` compiles ZModel to TypeScript schema (`schema.ts`)

Applied to files:

  • packages/language/package.json
📚 Learning: 2025-08-04T08:43:33.161Z
Learnt from: CR
PR: zenstackhq/zenstack-v3#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-04T08:43:33.161Z
Learning: Schema-first approach with ZModel DSL extension of Prisma schema language

Applied to files:

  • packages/runtime/src/client/crud/validator.ts
🧬 Code Graph Analysis (1)
packages/runtime/src/client/crud/validator.ts (1)
packages/sdk/src/schema/schema.ts (1)
  • FieldDef (59-74)
⏰ 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: claude-review
  • GitHub Check: build-test (20.x)
🔇 Additional comments (21)
packages/cli/package.json (2)

6-6: LGTM: version bumped to 3.0.0-alpha.26

Monorepo CLI package metadata-only change looks good.


6-6: Monorepo versions & internal deps verified — no action required

I ran the checks: every package.json version is 3.0.0-alpha.26, there are no occurrences of 3.0.0-alpha.25, and all @zenstackhq/* dependencies are set to "workspace:*".

packages/sdk/package.json (1)

3-3: LGTM: version bumped to 3.0.0-alpha.26

SDK package version-only change; exports and dependencies unchanged. No concerns.

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

3-3: LGTM: version bumped to 3.0.0-alpha.26

No functional changes. Peer dependency range for @tanstack/react-query remains ^5, which matches current package intent.

packages/zod/package.json (1)

3-3: LGTM: version bumped to 3.0.0-alpha.26

Metadata-only update; dependencies and exports intact.

packages/ide/vscode/package.json (1)

4-4: LGTM: version bumped to 3.0.0-alpha.26

VS Code extension manifest version updated; no other changes. Scripts and engine constraints unchanged.

tests/e2e/package.json (1)

3-3: Version bump aligns with the release train

Looks good. This keeps e2e package in sync with the repo-wide 3.0.0-alpha.26 release.

packages/runtime/package.json (1)

3-3: Runtime version bump verified — all packages updated to 3.0.0-alpha.26

Ran the provided script: every package.json with a version field is 3.0.0-alpha.26 and no references to "3.0.0-alpha.25" were found.

packages/vitest-config/package.json (1)

4-4: LGTM: metadata-only version bump

No behavior changes here; keeping in lockstep with the rest of the repo is good.

packages/typescript-config/package.json (1)

3-3: Typescript config version bump is consistent

Private package; safe and aligned with the release train.

packages/create-zenstack/package.json (1)

3-3: Version bump to 3.0.0-alpha.26 looks good.

No API or config changes; aligns with the repo-wide release bump.

packages/eslint-config/package.json (1)

3-3: Version bump acknowledged.

Private package; safe metadata-only change.

samples/blog/package.json (1)

3-3: Sample app version updated correctly.

Dependencies reference workspace and catalog; no action needed.

package.json (1)

1-41: All package.json files have been bumped to 3.0.0-alpha.26 — no action required.

I ran the verification script; every package.json in the repo (root, packages/*, samples, tests) reports version 3.0.0-alpha.26.

packages/language/package.json (1)

4-4: Language package version bump is consistent.

No other changes in scripts/exports; nothing else to verify here.

packages/common-helpers/package.json (1)

3-3: LGTM: version bump only.

Version updated to 3.0.0-alpha.26 with no other changes. No issues.

packages/dialects/sql.js/package.json (1)

3-3: LGTM: version bump only.

Version updated to 3.0.0-alpha.26 with no other changes. No issues.

packages/runtime/src/client/crud/validator.ts (2)

592-592: Good reuse: relation select/include shape now centralized.

Replacing inline unions with makeRelationSelectIncludeSchema reduces duplication and keeps relation args consistent across select/include.


675-675: Consistent application: include schema switched to centralized relation helper.

Keeps select/include relation shapes in sync and easier to evolve.

packages/runtime/test/client-api/find.test.ts (2)

682-696: Good: nested to-one relation projection.

Covers selecting author.email via both select and include on a to-one relation. This aligns with the new relation helper.


714-730: Great: optional to-one filtering semantics verified.

Asserting profile is object/null based on where filters demonstrates the conditional where support added for optional to-one relations.

@ymc9 ymc9 enabled auto-merge August 15, 2025 10:57
@claude
Copy link

claude bot commented Aug 15, 2025

Claude finished @ymc9's task —— View job


Code Review Complete ✅

I've thoroughly reviewed PR #177 (dev → main merge for v3.0.0-alpha.26). Here's my comprehensive analysis:

Overall Assessment

This is a well-structured release PR that properly bumps version across all packages while introducing important runtime validation improvements for relation filtering. The changes are backward-compatible and enhance the developer experience.

Key Changes Summary

📦 Version Management (20 files)

  • Consistent version bump from 3.0.0-alpha.25 to 3.0.0-alpha.26 across all packages
  • All package.json files properly synchronized

🔧 Core Runtime Improvements

  • Enhanced relation validation: New makeRelationSelectIncludeSchema helper consolidates relation schema logic
  • Expanded filtering capabilities: Optional to-one and to-many relations now support where clauses
  • Type refinements: FindArgs type moved distinct/cursor into collection-specific branch
  • Improved test coverage: 92 new lines of comprehensive relation filtering tests

Code Quality & Best Practices ✅

Strengths:

  1. DRY Principle: The new makeRelationSelectIncludeSchema helper eliminates code duplication between select and include schemas
  2. Type Safety: Changes maintain strong TypeScript inference and add more precise typing
  3. Consistent Conventions: All changes follow existing codebase patterns and naming conventions
  4. Clear Documentation: Comments accurately describe the new filtering capabilities

Minor Improvements Needed:

  • Consider adding refinements to prevent select/include/omit mutual exclusivity in nested relations (validator.ts:629-653)
  • Comment on line 644 should mention distinct in the list of to-many operations

Potential Issues 🔍

Type/Validation Alignment Concern:

  • FindArgs type now restricts distinct/cursor to collection queries only (crud-types.ts:634-635)
  • However, validateFindArgs always passes collection: true to the validator (validator.ts:47)
  • This creates a mismatch where validation allows distinct/cursor on non-collection queries while types prevent it

Recommendation: Update validateFindArgs to accept a collection parameter and gate distinct/cursor validation accordingly.

Nested Relation Validation Gap:

  • The new relation schema allows select + include combinations in nested relations
  • Top-level queries properly prevent this, but nested relations don't have the same refinements

Performance Considerations ✅

Positive:

  • Schema caching prevents recomputation of validation schemas
  • Lazy evaluation for recursive relation schemas maintains performance
  • New filtering capabilities are implemented efficiently

No Concerns:

  • No performance regressions detected
  • Validation overhead is minimal and appropriate for the added functionality

Security Assessment ✅

No Security Issues:

  • All changes are focused on validation and type improvements
  • No exposure of sensitive data or injection vulnerabilities
  • Input validation is enhanced, not weakened
  • Proper error handling maintains security boundaries

Test Coverage Assessment ✅

Excellent Coverage:

  • 92 new test lines comprehensively cover the new relation filtering features
  • Tests include both positive and negative scenarios
  • Error cases are properly validated with updated expectations
  • Both select and include paths are tested for consistency

Key Test Scenarios Covered:

  • Nested to-many relation filtering with where, orderBy, distinct (find.test.ts:640-680)
  • Optional to-one relation conditional filtering (find.test.ts:714-730)
  • Proper error handling for invalid relation filters (find.test.ts:867-872)

Specific File Analysis

packages/runtime/src/client/crud/validator.ts:

  • ✅ Well-refactored with new helper method
  • ✅ Proper separation of to-many vs to-one relation capabilities
  • ⚠️ Missing mutual exclusivity refinements for nested relations

packages/runtime/src/client/crud-types.ts:

  • ✅ Logical reorganization of FindArgs structure
  • ✅ Better type safety for collection-specific operations
  • ⚠️ Potential validation alignment issue (see above)

packages/runtime/test/client-api/find.test.ts:

  • ✅ Comprehensive test coverage for new features
  • ✅ Proper error expectation updates
  • ✅ Both positive and negative test scenarios

Recommendations

  1. Ready for Merge: This PR represents solid progress with important improvements

  2. Follow-up Tasks (can be addressed in subsequent PRs):

    • Fix the distinct/cursor validation alignment issue
    • Add nested relation mutual exclusivity refinements
    • Consider adding more edge case tests for complex nested scenarios
  3. Post-Merge Monitoring: Watch for any validation issues in production, particularly around nested relation filtering


Final Verdict: ✅ APPROVED

This is a quality release that:

  • Maintains backward compatibility
  • Introduces valuable new functionality
  • Follows proper versioning practices
  • Includes comprehensive test coverage
  • Contains no security concerns

The identified issues are minor and can be addressed in follow-up PRs without blocking this release.


**

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: 2

♻️ Duplicate comments (1)
packages/runtime/src/client/crud/validator.ts (1)

629-655: Enforce nested select/include/omit mutual exclusivity and update comment to include 'distinct'

Currently, nested relation objects allow select+include or select+omit together. Add local refinements so nested relations follow top-level rules. Also, the comment omits distinct though it’s supported.

 private makeRelationSelectIncludeSchema(fieldDef: FieldDef) {
-    return z.union([
-        z.boolean(),
-        z.strictObject({
+    const relObject = z.strictObject({
             ...(fieldDef.array || fieldDef.optional
                 ? {
                       // to-many relations and optional to-one relations are filterable
                       where: z.lazy(() => this.makeWhereSchema(fieldDef.type, false)).optional(),
                   }
                 : {}),
             select: z.lazy(() => this.makeSelectSchema(fieldDef.type)).optional(),
             include: z.lazy(() => this.makeIncludeSchema(fieldDef.type)).optional(),
             omit: z.lazy(() => this.makeOmitSchema(fieldDef.type)).optional(),
             ...(fieldDef.array
                 ? {
-                      // to-many relations can be ordered, skipped, taken, and cursor-located
+                      // to-many relations can be ordered, skipped, taken, cursor-located, and distinct-selected
                       orderBy: z.lazy(() => this.makeOrderBySchema(fieldDef.type, true, false)).optional(),
                       skip: this.makeSkipSchema().optional(),
                       take: this.makeTakeSchema().optional(),
                       cursor: this.makeCursorSchema(fieldDef.type).optional(),
                       distinct: this.makeDistinctSchema(fieldDef.type).optional(),
                   }
                 : {}),
-        }),
-    ]);
+    })
+        .refine((v) => !(v.select && v.include), '"select" and "include" cannot be used together')
+        .refine((v) => !(v.select && v.omit), '"select" and "omit" cannot be used together');
+    return z.union([z.boolean(), relObject]);
 }
🧹 Nitpick comments (1)
packages/runtime/src/client/plugin.ts (1)

49-49: Consider re-exporting AllCrudOperation from this module for plugin authors

You already re-export CrudOperation here. Re-exporting AllCrudOperation avoids deep import paths for consumers.

Apply at Line 49:

-export { type CrudOperation } from './crud/operations/base';
+export { type CrudOperation, type AllCrudOperation } from './crud/operations/base';

Also applies to: 64-64

📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f2199db and 1b5b5a1.

📒 Files selected for processing (3)
  • packages/runtime/src/client/crud/operations/base.ts (1 hunks)
  • packages/runtime/src/client/crud/validator.ts (6 hunks)
  • packages/runtime/src/client/plugin.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
{packages,samples,tests}/**

📄 CodeRabbit Inference Engine (CLAUDE.md)

Packages are located in packages/, samples/, and tests/

Files:

  • packages/runtime/src/client/crud/operations/base.ts
  • packages/runtime/src/client/plugin.ts
  • packages/runtime/src/client/crud/validator.ts
🧠 Learnings (2)
📚 Learning: 2025-08-04T08:43:33.161Z
Learnt from: CR
PR: zenstackhq/zenstack-v3#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-04T08:43:33.161Z
Learning: Schema is used to instantiate `ZenStackClient` with type-safe CRUD operations

Applied to files:

  • packages/runtime/src/client/plugin.ts
📚 Learning: 2025-08-04T08:43:33.161Z
Learnt from: CR
PR: zenstackhq/zenstack-v3#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-04T08:43:33.161Z
Learning: Schema-first approach with ZModel DSL extension of Prisma schema language

Applied to files:

  • packages/runtime/src/client/crud/validator.ts
🧬 Code Graph Analysis (3)
packages/runtime/src/client/crud/operations/base.ts (1)
packages/runtime/src/client/plugin.ts (1)
  • CrudOperation (49-49)
packages/runtime/src/client/plugin.ts (1)
packages/runtime/src/client/crud/operations/base.ts (1)
  • AllCrudOperation (71-71)
packages/runtime/src/client/crud/validator.ts (3)
packages/runtime/src/client/crud/operations/base.ts (1)
  • options (94-96)
packages/runtime/src/client/executor/zenstack-query-executor.ts (1)
  • options (54-56)
packages/sdk/src/schema/schema.ts (1)
  • FieldDef (59-74)
⏰ 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: build-test (20.x)
  • GitHub Check: claude-review
🔇 Additional comments (5)
packages/runtime/src/client/plugin.ts (1)

5-5: Switch to AllCrudOperation import — LGTM

This aligns the plugin surface with the extended operation union.

packages/runtime/src/client/crud/validator.ts (4)

199-228: Move cursor/distinct under collection (!unique) — LGTM and consistent with types

Gating skip/take/orderBy/cursor/distinct on !options.unique correctly reflects collection-only semantics.


592-597: Select: unified relation schema helper usage — LGTM

Replacing inline unions with makeRelationSelectIncludeSchema reduces duplication and keeps select/include/omit consistent.


674-675: Include: unified relation schema helper usage — LGTM

Keeps select/include/omit parity for relation fields and centralizes future adjustments.


47-49: validateFindArgs narrowed to { unique } — callers verified

The only caller is FindOperationHandler which passes operation === 'findUnique' as the unique flag. client-impl maps the *OrThrow variants to the same internal operation strings, so unique=true is used for findUnique/findUniqueOrThrow and unique=false for findMany/findFirst/findFirstOrThrow.

  • packages/runtime/src/client/crud/operations/find.ts — validateFindArgs(this.model, operation === 'findUnique', normalizedArgs)
  • packages/runtime/src/client/client-impl.ts — createPromise(...) uses 'findUnique' for both findUnique and findUniqueOrThrow, and 'findFirst' for findFirst and findFirstOrThrow (findMany uses 'findMany')
  • packages/runtime/src/client/crud/validator.ts — makeFindSchema(model, { unique }) (schema respects unique)

No change required.

@ymc9 ymc9 added this pull request to the merge queue Aug 15, 2025
Merged via the queue into main with commit 6262b76 Aug 15, 2025
10 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.

2 participants