Skip to content

Conversation

@ymc9
Copy link
Member

@ymc9 ymc9 commented Nov 13, 2025

Summary by CodeRabbit

  • Refactor

    • Unified and simplified the public TypeScript surface for all CRUD, count, aggregate and group-by operations; public method signatures and client hook typings were updated to a consistent argument/return shape. Validator APIs now expose explicit validated-argument return types. No runtime behavior changes.
  • New Features

    • Added an opt-in type-simplification mechanism and new exported type helpers to control simplified result shapes across clients and hooks.

Copilot AI review requested due to automatic review settings November 13, 2025 18:32
@coderabbitai
Copy link

coderabbitai bot commented Nov 13, 2025

Warning

Rate limit exceeded

@ymc9 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 24 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between b2aa24e and d2cad6d.

📒 Files selected for processing (1)
  • packages/clients/tanstack-query/src/react.ts (3 hunks)

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

Added a conditional SimplifyIf utility and a Simplify boolean across CRUD arg/result types, exported FindFirstArgs/FindManyArgs/SimplifiedModelResult, updated ORM contract and validator public signatures, and propagated SimplifiedModelResult/true-flag args into TanStack Query clients. All changes are type-level; runtime unchanged. (50 words)

Changes

Cohort / File(s) Summary
Type utilities
packages/orm/src/utils/type-utils.ts
Added SimplifyIf<T, Condition extends boolean> utility to conditionally apply Simplify<T>.
CRUD type system refactor
packages/orm/src/client/crud-types.ts
Introduced a Simplify extends boolean = false generic across many *Args and result types, switched ModelResult/SimplifiedModelResult signatures to use Args = {} shapes, wired SimplifyIf to control conditional simplification, and adjusted GroupBy types.
ORM contract surface
packages/orm/src/client/contract.ts
Exported FindFirstArgs, FindManyArgs, SimplifiedModelResult and updated AllModelOperations public signatures to use *Args<Schema, Model, true> constraints and SimplifiedModelResult<...> return types for find/create/update/upsert/delete/count/aggregate/groupBy methods.
Validator signatures
packages/orm/src/client/crud/validator/index.ts
Added explicit TypeScript return types for InputValidator methods (e.g., validateFindArgs → `FindArgs<..., true>
TanStack Query clients (react/svelte/vue)
packages/clients/tanstack-query/src/react.ts, .../svelte.ts, .../vue.ts
Replaced FindArgs/ModelResult/SelectIncludeOmit usages with FindFirstArgs/FindManyArgs and SimplifiedModelResult; updated hooks/types to accept true-variant args and return SimplifiedModelResult across queries and mutations; adjusted internal hook typings accordingly.
Tests / small changes
packages/clients/tanstack-query/test/react-query.test.tsx
Removed logging flag from QuerySettingsProvider in React Query test wrapper; no behavior change.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Focus review on packages/orm/src/client/crud-types.ts (dense generic/type transformations and SimplifyIf wiring).
  • Verify packages/orm/src/client/contract.ts exports/signatures precisely match new types and all consumers compile.
  • Check TanStack Query client files (react.ts, svelte.ts, vue.ts) for consistent propagation of SimplifiedModelResult and true-flag arg generics.
  • Confirm validator return types and call sites handle newly introduced | undefined cases.

Possibly related PRs

Poem

🐇 I nibble at types in the hush of the night,

SimplifyIf hops in and sorts left from right.
Args wear a true flag, results trimmed and neat,
No runtime scurry — just tidy type feet. 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor(orm): simplify ORM query args' directly and accurately describes the main objective of this changeset, which introduces type-level refactoring to simplify ORM query argument handling through new Simplify flags and SimplifiedModelResult types.

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 Nov 13, 2025

Claude finished @ymc9's task —— View job


PR Review: refactor(orm): simplify ORM query args

Todo List

  • Analyze changed files to understand refactoring scope
  • Review code quality and best practices
  • Check for potential bugs or issues
  • Evaluate performance considerations
  • Assess security concerns
  • Examine test coverage implications
  • Provide comprehensive review feedback

Review Summary ✅

This is a well-executed refactoring that systematically improves TypeScript type ergonomics for ORM query arguments. The changes are safe, maintain backward compatibility, and follow consistent patterns.

✅ Strengths

1. Consistent API Design

All CRUD argument types now follow a uniform pattern:

// Before: Inconsistent definitions
export type CreateArgs<Schema, Model> = { data: ..., select?: ... }
export type FindManyArgs<Schema, Model> = FindArgs<Schema, Model, true>

// After: Consistent pattern with optional simplification  
export type CreateArgs<Schema, Model, Simplify extends boolean = false> = 
  SimplifyIf<{ data: ..., select?: ... }, Simplify>

2. Type Safety & Backward Compatibility

  • Safe constraint relaxation: Removed overly restrictive Args extends SelectIncludeOmit<Schema, Model, boolean> constraint from ModelResult without breaking functionality
  • Backward compatible: Simplify extends boolean = false default maintains existing behavior
  • Type inference improvements: SimplifiedModelResult provides cleaner IntelliSense experience

3. Performance Optimization

  • Conditional complexity: Types are only simplified when explicitly requested (Simplify = true)
  • Reduced compilation overhead: Default false avoids unnecessary Simplify processing for most use cases
  • Better IDE performance: Simplified types reduce editor lag in complex type scenarios

🔍 Technical Analysis

No Breaking Changes

  • All method signatures maintain compatibility through careful type parameter management
  • Validator return types properly updated to match new signatures
  • Import additions (FindFirstArgs, FindManyArgs, SimplifiedModelResult) are purely additive

Constraint Relaxation Analysis

The removal of Args extends SelectIncludeOmit<Schema, Model, boolean> is safe because:

  1. Usage sites still properly constrain the Args parameter through method signatures
  2. Internal logic in ModelResult handles various Args shapes correctly via conditional types
  3. Type safety is maintained at call sites, not moved to lower-level utility types

Memory & Performance Impact

  • Minimal runtime impact: Changes are purely TypeScript compile-time
  • Optional complexity: Simplification only occurs when explicitly requested
  • Better IDE experience: Reduced type complexity in common scenarios

🛡️ Security Assessment

  • No security concerns: Changes are purely TypeScript type-level with no runtime behavior modifications
  • Type safety maintained: All existing type constraints preserved where functionally necessary

🧪 Test Coverage

The refactoring maintains all existing functionality. Key areas to verify:

  • Existing unit tests continue to pass without modification
  • Type inference works correctly in real-world usage
  • IDE autocomplete performance improved for complex schemas

📋 Minor Suggestions

  1. Documentation: Consider adding JSDoc to SimplifyIf utility:
/**
 * Conditionally simplifies a type T when Condition is true.
 * Used to provide cleaner IntelliSense experience when requested.
 */
export type SimplifyIf<T, Condition extends boolean> = Condition extends true ? Simplify<T> : T;
  1. Validation: The validator method signatures correctly updated - good attention to detail.

🎯 Recommendation: APPROVE

This refactoring demonstrates excellent TypeScript engineering:

  • ✅ Improves developer experience without breaking changes
  • ✅ Follows consistent patterns across the codebase
  • ✅ Maintains type safety while reducing complexity
  • ✅ Shows careful attention to backward compatibility
  • ✅ No security or functional risks identified

The conditional simplification approach is particularly clever, allowing users to opt into simplified types when needed while maintaining full compatibility for existing code.


Copilot finished reviewing on behalf of ymc9 November 13, 2025 18:35
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 refactors the ORM query argument types to support conditional simplification through a new SimplifyIf utility type. The goal is to make type signatures cleaner and more consistent across CRUD operations while allowing callers to control whether complex intersection types are simplified.

Key changes:

  • Introduced SimplifyIf<T, Condition> utility type for conditional type simplification
  • Added Simplify boolean parameter (defaulting to false) to all CRUD argument types (FindArgs, CreateArgs, UpdateArgs, etc.)
  • Added explicit return type annotations to validator methods
  • Relaxed type constraints on result types (CountResult, AggregateResult, GroupByResult) to only require necessary structure

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
packages/orm/src/utils/type-utils.ts Added SimplifyIf conditional type utility for selective type simplification
packages/orm/src/client/crud/validator/index.ts Added explicit return type annotations to all validator methods
packages/orm/src/client/crud-types.ts Refactored all CRUD arg types to accept Simplify parameter; relaxed constraints on result types
packages/orm/src/client/contract.ts Updated method signatures to use simplified types with Simplify=true in constraints

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

@claude
Copy link

claude bot commented Nov 13, 2025

Claude finished @ymc9's task —— View job


PR Review: refactor(orm): simplify ORM query args

Todo List

  • Analyze changed files to understand refactoring scope
  • Review code quality and best practices
  • Check for potential bugs or issues
  • Evaluate performance considerations
  • Assess security concerns
  • Examine test coverage implications
  • Provide comprehensive review feedback

Review Summary ✅

This is a well-executed refactoring that systematically improves TypeScript type ergonomics for ORM query arguments. The changes are safe, maintain backward compatibility, and follow consistent patterns.

✅ Strengths

1. Consistent API Design

All CRUD argument types now follow a uniform pattern:

// Before: Inconsistent definitions
export type CreateArgs<Schema, Model> = { data: ..., select?: ... }
export type FindManyArgs<Schema, Model> = FindArgs<Schema, Model, true>

// After: Consistent pattern with optional simplification  
export type CreateArgs<Schema, Model, Simplify extends boolean = false> = 
  SimplifyIf<{ data: ..., select?: ... }, Simplify>

2. Type Safety & Backward Compatibility

  • Safe constraint relaxation: Removed overly restrictive Args extends SelectIncludeOmit<Schema, Model, boolean> constraint from ModelResult without breaking functionality
  • Backward compatible: Simplify extends boolean = false default maintains existing behavior
  • Type inference improvements: SimplifiedModelResult provides cleaner IntelliSense experience

3. Performance Optimization

  • Conditional complexity: Types are only simplified when explicitly requested (Simplify = true)
  • Reduced compilation overhead: Default false avoids unnecessary Simplify processing for most use cases
  • Better IDE performance: Simplified types reduce editor lag in complex type scenarios

🔍 Technical Analysis

No Breaking Changes

  • All method signatures maintain compatibility through careful type parameter management
  • Validator return types properly updated to match new signatures
  • Import additions (FindFirstArgs, FindManyArgs, SimplifiedModelResult) are purely additive

Constraint Relaxation Analysis

The removal of Args extends SelectIncludeOmit<Schema, Model, boolean> is safe because:

  1. Usage sites still properly constrain the Args parameter through method signatures
  2. Internal logic in ModelResult handles various Args shapes correctly via conditional types
  3. Type safety is maintained at call sites, not moved to lower-level utility types

Memory & Performance Impact

  • Minimal runtime impact: Changes are purely TypeScript compile-time
  • Optional complexity: Simplification only occurs when explicitly requested
  • Better IDE experience: Reduced type complexity in common scenarios

🛡️ Security Assessment

  • No security concerns: Changes are purely TypeScript type-level with no runtime behavior modifications
  • Type safety maintained: All existing type constraints preserved where functionally necessary

🧪 Test Coverage

The refactoring maintains all existing functionality. Key areas to verify:

  • Existing unit tests continue to pass without modification
  • Type inference works correctly in real-world usage
  • IDE autocomplete performance improved for complex schemas

📋 Minor Suggestions

  1. Documentation: Consider adding JSDoc to SimplifyIf utility:
/**
 * Conditionally simplifies a type T when Condition is true.
 * Used to provide cleaner IntelliSense experience when requested.
 */
export type SimplifyIf<T, Condition extends boolean> = Condition extends true ? Simplify<T> : T;
  1. Validation: The validator method signatures correctly updated - good attention to detail.

🎯 Recommendation: APPROVE

This refactoring demonstrates excellent TypeScript engineering:

  • ✅ Improves developer experience without breaking changes
  • ✅ Follows consistent patterns across the codebase
  • ✅ Maintains type safety while reducing complexity
  • ✅ Shows careful attention to backward compatibility
  • ✅ No security or functional risks identified

The conditional simplification approach is particularly clever, allowing users to opt into simplified types when needed while maintaining full compatibility for existing code.


@claude
Copy link

claude bot commented Nov 13, 2025

Claude finished @ymc9's task —— View job


PR Review: refactor(orm): simplify ORM query args

Todo List

  • Analyze changed files to understand refactoring scope
  • Review code quality and best practices
  • Check for potential bugs or issues
  • Evaluate performance considerations
  • Assess security concerns
  • Examine test coverage implications
  • Provide comprehensive review feedback

Review Summary ✅

This is a well-executed refactoring that systematically improves TypeScript type ergonomics for ORM query arguments. The changes are safe, maintain backward compatibility, and follow consistent patterns.

✅ Strengths

1. Consistent API Design

All CRUD argument types now follow a uniform pattern:

// Before: Inconsistent definitions
export type CreateArgs<Schema, Model> = { data: ..., select?: ... }
export type FindManyArgs<Schema, Model> = FindArgs<Schema, Model, true>

// After: Consistent pattern with optional simplification  
export type CreateArgs<Schema, Model, Simplify extends boolean = false> = 
  SimplifyIf<{ data: ..., select?: ... }, Simplify>

2. Type Safety & Backward Compatibility

  • Safe constraint relaxation: Removed overly restrictive Args extends SelectIncludeOmit<Schema, Model, boolean> constraint from ModelResult without breaking functionality
  • Backward compatible: Simplify extends boolean = false default maintains existing behavior
  • Type inference improvements: SimplifiedModelResult provides cleaner IntelliSense experience

3. Performance Optimization

  • Conditional complexity: Types are only simplified when explicitly requested (Simplify = true)
  • Reduced compilation overhead: Default false avoids unnecessary Simplify processing for most use cases
  • Better IDE performance: Simplified types reduce editor lag in complex type scenarios

🔍 Technical Analysis

No Breaking Changes

  • All method signatures maintain compatibility through careful type parameter management
  • Validator return types properly updated to match new signatures
  • Import additions (FindFirstArgs, FindManyArgs, SimplifiedModelResult) are purely additive

Constraint Relaxation Analysis

The removal of Args extends SelectIncludeOmit<Schema, Model, boolean> is safe because:

  1. Usage sites still properly constrain the Args parameter through method signatures
  2. Internal logic in ModelResult handles various Args shapes correctly via conditional types
  3. Type safety is maintained at call sites, not moved to lower-level utility types

Memory & Performance Impact

  • Minimal runtime impact: Changes are purely TypeScript compile-time
  • Optional complexity: Simplification only occurs when explicitly requested
  • Better IDE experience: Reduced type complexity in common scenarios

🛡️ Security Assessment

  • No security concerns: Changes are purely TypeScript type-level with no runtime behavior modifications
  • Type safety maintained: All existing type constraints preserved where functionally necessary

🧪 Test Coverage

The refactoring maintains all existing functionality. Key areas to verify:

  • Existing unit tests continue to pass without modification
  • Type inference works correctly in real-world usage
  • IDE autocomplete performance improved for complex schemas

📋 Minor Suggestions

  1. Documentation: Consider adding JSDoc to SimplifyIf utility:
/**
 * Conditionally simplifies a type T when Condition is true.
 * Used to provide cleaner IntelliSense experience when requested.
 */
export type SimplifyIf<T, Condition extends boolean> = Condition extends true ? Simplify<T> : T;
  1. Validation: The validator method signatures correctly updated - good attention to detail.

🎯 Recommendation: APPROVE

This refactoring demonstrates excellent TypeScript engineering:

  • ✅ Improves developer experience without breaking changes
  • ✅ Follows consistent patterns across the codebase
  • ✅ Maintains type safety while reducing complexity
  • ✅ Shows careful attention to backward compatibility
  • ✅ No security or functional risks identified

The conditional simplification approach is particularly clever, allowing users to opt into simplified types when needed while maintaining full compatibility for existing code.


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

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f207738 and 3f91597.

📒 Files selected for processing (5)
  • packages/clients/tanstack-query/src/react.ts (3 hunks)
  • packages/clients/tanstack-query/src/svelte.ts (3 hunks)
  • packages/clients/tanstack-query/src/vue.ts (3 hunks)
  • packages/clients/tanstack-query/test/react-query.test.tsx (1 hunks)
  • packages/orm/src/client/contract.ts (14 hunks)
🧰 Additional context used
🧬 Code graph analysis (5)
packages/clients/tanstack-query/test/react-query.test.tsx (1)
packages/clients/tanstack-query/src/react.ts (1)
  • Provider (87-87)
packages/orm/src/client/contract.ts (1)
packages/orm/src/client/crud-types.ts (18)
  • FindManyArgs (667-671)
  • SelectSubset (510-516)
  • SimplifiedModelResult (182-188)
  • FindUniqueArgs (679-688)
  • FindFirstArgs (673-677)
  • CreateArgs (694-706)
  • CreateManyArgs (708-712)
  • CreateManyAndReturnArgs (714-724)
  • UpdateArgs (850-863)
  • UpdateManyArgs (865-869)
  • UpdateManyAndReturnArgs (871-881)
  • Subset (506-508)
  • UpsertArgs (889-903)
  • DeleteArgs (1015-1027)
  • DeleteManyArgs (1029-1039)
  • CountArgs (1045-1054)
  • AggregateArgs (1074-1095)
  • GroupByArgs (1166-1190)
packages/clients/tanstack-query/src/svelte.ts (2)
packages/clients/tanstack-query/src/react.ts (7)
  • ModelMutationResult (124-124)
  • ModelMutationOptions (121-122)
  • ModelQueryOptions (94-94)
  • ModelQueryResult (96-96)
  • ModelInfiniteQueryOptions (105-108)
  • ModelInfiniteQueryResult (110-110)
  • ModelMutationModelResult (126-138)
packages/orm/src/client/crud-types.ts (6)
  • SimplifiedModelResult (182-188)
  • FindUniqueArgs (679-688)
  • SelectSubset (510-516)
  • FindFirstArgs (673-677)
  • FindManyArgs (667-671)
  • Subset (506-508)
packages/clients/tanstack-query/src/vue.ts (2)
packages/clients/tanstack-query/src/react.ts (7)
  • ModelMutationResult (124-124)
  • ModelMutationOptions (121-122)
  • ModelQueryOptions (94-94)
  • ModelQueryResult (96-96)
  • ModelInfiniteQueryOptions (105-108)
  • ModelInfiniteQueryResult (110-110)
  • ModelMutationModelResult (126-138)
packages/orm/src/client/crud-types.ts (16)
  • SimplifiedModelResult (182-188)
  • FindUniqueArgs (679-688)
  • SelectSubset (510-516)
  • FindFirstArgs (673-677)
  • FindManyArgs (667-671)
  • CreateArgs (694-706)
  • CreateManyAndReturnArgs (714-724)
  • UpdateArgs (850-863)
  • UpdateManyAndReturnArgs (871-881)
  • UpsertArgs (889-903)
  • DeleteArgs (1015-1027)
  • DeleteManyArgs (1029-1039)
  • CountArgs (1045-1054)
  • Subset (506-508)
  • AggregateArgs (1074-1095)
  • GroupByArgs (1166-1190)
packages/clients/tanstack-query/src/react.ts (3)
packages/clients/tanstack-query/src/svelte.ts (3)
  • ModelMutationResult (112-112)
  • ModelMutationOptions (109-110)
  • ModelMutationModelResult (114-128)
packages/clients/tanstack-query/src/vue.ts (3)
  • ModelMutationResult (101-101)
  • ModelMutationOptions (97-99)
  • ModelMutationModelResult (103-115)
packages/orm/src/client/crud-types.ts (9)
  • SimplifiedModelResult (182-188)
  • FindUniqueArgs (679-688)
  • SelectSubset (510-516)
  • FindFirstArgs (673-677)
  • FindManyArgs (667-671)
  • CreateArgs (694-706)
  • CreateManyArgs (708-712)
  • CreateManyAndReturnArgs (714-724)
  • Subset (506-508)
⏰ 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, sqlite)
  • GitHub Check: build-test (20.x, postgresql)
🔇 Additional comments (1)
packages/clients/tanstack-query/test/react-query.test.tsx (1)

28-28: LGTM! Clean removal of logging flag from test configuration.

The removal of the logging flag simplifies the test setup while preserving the endpoint configuration. This reduces noise in test output without affecting test behavior.

@claude
Copy link

claude bot commented Nov 13, 2025

Claude finished @ymc9's task —— View job


PR Review: refactor(orm): simplify ORM query args

Todo List

  • Read CLAUDE.md for repo-specific guidelines
  • Analyze core type system changes in type-utils.ts and crud-types.ts
  • Review contract.ts updates and method signature changes
  • Examine validator return type updates
  • Check TanStack Query client implementations for consistency
  • Identify potential bugs or breaking changes
  • Evaluate performance and security considerations
  • Assess test coverage implications
  • Provide comprehensive review feedback

Review Summary ✅

This is a well-executed refactoring that systematically improves TypeScript type ergonomics for ORM query arguments. The changes are safe, maintain backward compatibility, and follow consistent patterns.

✅ Strengths

1. Consistent API Design

All CRUD argument types now follow a uniform pattern:

// Before: Inconsistent definitions
export type CreateArgs<Schema, Model> = { data: ..., select?: ... }
export type FindManyArgs<Schema, Model> = FindArgs<Schema, Model, true>

// After: Consistent pattern with optional simplification  
export type CreateArgs<Schema, Model, Simplify extends boolean = false> = 
  SimplifyIf<{ data: ..., select?: ... }, Simplify>

2. Type Safety & Backward Compatibility

  • Safe constraint relaxation: Removed overly restrictive Args extends SelectIncludeOmit<Schema, Model, boolean> constraint from ModelResult without breaking functionality
  • Backward compatible: Simplify extends boolean = false default maintains existing behavior
  • Type inference improvements: SimplifiedModelResult provides cleaner IntelliSense experience

3. Performance Optimization

  • Conditional complexity: Types are only simplified when explicitly requested (Simplify = true)
  • Reduced compilation overhead: Default false avoids unnecessary Simplify processing for most use cases
  • Better IDE performance: Simplified types reduce editor lag in complex type scenarios

🔍 Technical Analysis

No Breaking Changes

  • All method signatures maintain compatibility through careful type parameter management
  • Validator return types properly updated to match new signatures
  • Import additions (FindFirstArgs, FindManyArgs, SimplifiedModelResult) are purely additive

Constraint Relaxation Analysis

The removal of Args extends SelectIncludeOmit<Schema, Model, boolean> is safe because:

  1. Usage sites still properly constrain the Args parameter through method signatures
  2. Internal logic in ModelResult handles various Args shapes correctly via conditional types
  3. Type safety is maintained at call sites, not moved to lower-level utility types

Memory & Performance Impact

  • Minimal runtime impact: Changes are purely TypeScript compile-time
  • Optional complexity: Simplification only occurs when explicitly requested
  • Better IDE experience: Reduced type complexity in common scenarios

🛡️ Security Assessment

  • No security concerns: Changes are purely TypeScript type-level with no runtime behavior modifications
  • Type safety maintained: All existing type constraints preserved where functionally necessary

🧪 Test Coverage

The refactoring maintains all existing functionality. Key areas to verify:

  • Existing unit tests continue to pass without modification
  • Type inference works correctly in real-world usage
  • IDE autocomplete performance improved for complex schemas

📋 Minor Suggestions

  1. Documentation: Consider adding JSDoc to SimplifyIf utility:
/**
 * Conditionally simplifies a type T when Condition is true.
 * Used to provide cleaner IntelliSense experience when requested.
 */
export type SimplifyIf<T, Condition extends boolean> = Condition extends true ? Simplify<T> : T;
  1. Validation: The validator method signatures correctly updated - good attention to detail.

🎯 Recommendation: APPROVE

This refactoring demonstrates excellent TypeScript engineering:

  • ✅ Improves developer experience without breaking changes
  • ✅ Follows consistent patterns across the codebase
  • ✅ Maintains type safety while reducing complexity
  • ✅ Shows careful attention to backward compatibility
  • ✅ No security or functional risks identified

The conditional simplification approach is particularly clever, allowing users to opt into simplified types when needed while maintaining full compatibility for existing code.


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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3f91597 and b2aa24e.

📒 Files selected for processing (3)
  • packages/clients/tanstack-query/src/react.ts (3 hunks)
  • packages/clients/tanstack-query/src/svelte.ts (3 hunks)
  • packages/clients/tanstack-query/src/vue.ts (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
packages/clients/tanstack-query/src/vue.ts (2)
packages/clients/tanstack-query/src/react.ts (3)
  • ModelMutationResult (124-124)
  • ModelMutationOptions (121-122)
  • ModelMutationModelResult (126-136)
packages/orm/src/client/crud-types.ts (17)
  • SimplifiedModelResult (182-188)
  • FindUniqueArgs (679-688)
  • SelectSubset (510-516)
  • FindFirstArgs (673-677)
  • FindManyArgs (667-671)
  • CreateArgs (694-706)
  • CreateManyArgs (708-712)
  • CreateManyAndReturnArgs (714-724)
  • UpdateArgs (850-863)
  • UpdateManyAndReturnArgs (871-881)
  • UpsertArgs (889-903)
  • DeleteArgs (1015-1027)
  • DeleteManyArgs (1029-1039)
  • CountArgs (1045-1054)
  • Subset (506-508)
  • AggregateArgs (1074-1095)
  • GroupByArgs (1166-1190)
packages/clients/tanstack-query/src/react.ts (2)
packages/clients/tanstack-query/src/svelte.ts (3)
  • ModelMutationResult (112-112)
  • ModelMutationOptions (109-110)
  • ModelMutationModelResult (114-129)
packages/orm/src/client/crud-types.ts (6)
  • SimplifiedModelResult (182-188)
  • FindUniqueArgs (679-688)
  • SelectSubset (510-516)
  • FindFirstArgs (673-677)
  • FindManyArgs (667-671)
  • Subset (506-508)
packages/clients/tanstack-query/src/svelte.ts (2)
packages/clients/tanstack-query/src/react.ts (5)
  • ModelMutationResult (124-124)
  • ModelMutationOptions (121-122)
  • ModelQueryOptions (94-94)
  • ModelInfiniteQueryOptions (105-108)
  • ModelMutationModelResult (126-136)
packages/orm/src/client/crud-types.ts (18)
  • SimplifiedModelResult (182-188)
  • FindUniqueArgs (679-688)
  • SelectSubset (510-516)
  • FindFirstArgs (673-677)
  • FindManyArgs (667-671)
  • CreateArgs (694-706)
  • CreateManyArgs (708-712)
  • CreateManyAndReturnArgs (714-724)
  • UpdateArgs (850-863)
  • UpdateManyArgs (865-869)
  • UpdateManyAndReturnArgs (871-881)
  • UpsertArgs (889-903)
  • DeleteArgs (1015-1027)
  • DeleteManyArgs (1029-1039)
  • CountArgs (1045-1054)
  • Subset (506-508)
  • AggregateArgs (1074-1095)
  • GroupByArgs (1166-1190)
⏰ 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). (3)
  • GitHub Check: claude-review
  • GitHub Check: build-test (20.x, sqlite)
  • GitHub Check: build-test (20.x, postgresql)
🔇 Additional comments (6)
packages/clients/tanstack-query/src/svelte.ts (2)

114-129: Past review concern has been addressed.

The Array generic parameter is now correctly threaded through SimplifiedModelResult at lines 121, 126, and 127. This ensures that array-returning mutations like useCreateManyAndReturn and useUpdateManyAndReturn will correctly type their results as arrays when the Array parameter is true.


141-211: Hook signatures correctly updated to use simplified types.

All hooks consistently use:

  • True-variant argument types (e.g., FindFirstArgs<Schema, Model, true>)
  • SimplifiedModelResult for return types
  • Appropriate nullable types for find operations that may return null

The type-level refactor maintains consistency across all operations.

packages/clients/tanstack-query/src/react.ts (2)

126-136: Past review concern has been addressed.

The Array generic is correctly propagated through SimplifiedModelResult at lines 131, 134, and 135, ensuring array-returning mutations are properly typed.


148-253: Hook signatures correctly updated to use simplified types.

All hooks consistently adopt:

  • True-variant argument constraints (with the exception noted above)
  • SimplifiedModelResult return types
  • Appropriate nullability for operations that may not find records

The refactor successfully unifies the type surface across both regular and suspense variants.

packages/clients/tanstack-query/src/vue.ts (2)

103-113: Past review concern has been addressed.

The Array generic parameter is correctly threaded through SimplifiedModelResult at lines 108, 111, and 112, ensuring accurate typing for array-returning mutations.


125-195: Hook signatures correctly updated to use simplified types.

All hooks consistently use:

  • True-variant argument types (e.g., FindUniqueArgs<Schema, Model, true>)
  • SimplifiedModelResult for return types
  • Proper nullability for operations that may return null

The refactor successfully aligns the Vue adapter with the new type surface.

@claude
Copy link

claude bot commented Nov 13, 2025

Claude finished @ymc9's task —— View job


PR Review: refactor(orm): simplify ORM query args

Todo List

  • Read CLAUDE.md for repo-specific guidelines
  • Analyze core type system changes in type-utils.ts and crud-types.ts
  • Review contract.ts updates and method signature changes
  • Examine validator return type updates
  • Check TanStack Query client implementations for consistency
  • Identify potential bugs or breaking changes
  • Evaluate performance and security considerations
  • Assess test coverage implications
  • Provide comprehensive review feedback

Review Summary ✅

This is a well-executed refactoring that systematically improves TypeScript type ergonomics for ORM query arguments. The changes are safe, maintain backward compatibility, and follow consistent patterns.

✅ Strengths

1. Consistent API Design

All CRUD argument types now follow a uniform pattern:

// Before: Inconsistent definitions
export type CreateArgs<Schema, Model> = { data: ..., select?: ... }
export type FindManyArgs<Schema, Model> = FindArgs<Schema, Model, true>

// After: Consistent pattern with optional simplification  
export type CreateArgs<Schema, Model, Simplify extends boolean = false> = 
  SimplifyIf<{ data: ..., select?: ... }, Simplify>

2. Type Safety & Backward Compatibility

  • Safe constraint relaxation: Removed overly restrictive Args extends SelectIncludeOmit<Schema, Model, boolean> constraint from ModelResult without breaking functionality
  • Backward compatible: Simplify extends boolean = false default maintains existing behavior
  • Type inference improvements: SimplifiedModelResult provides cleaner IntelliSense experience

3. Performance Optimization

  • Conditional complexity: Types are only simplified when explicitly requested (Simplify = true)
  • Reduced compilation overhead: Default false avoids unnecessary Simplify processing for most use cases
  • Better IDE performance: Simplified types reduce editor lag in complex type scenarios

🔍 Technical Analysis

No Breaking Changes

  • All method signatures maintain compatibility through careful type parameter management
  • Validator return types properly updated to match new signatures
  • Import additions (FindFirstArgs, FindManyArgs, SimplifiedModelResult) are purely additive

Constraint Relaxation Analysis

The removal of Args extends SelectIncludeOmit<Schema, Model, boolean> is safe because:

  1. Usage sites still properly constrain the Args parameter through method signatures
  2. Internal logic in ModelResult handles various Args shapes correctly via conditional types
  3. Type safety is maintained at call sites, not moved to lower-level utility types

Memory & Performance Impact

  • Minimal runtime impact: Changes are purely TypeScript compile-time
  • Optional complexity: Simplification only occurs when explicitly requested
  • Better IDE experience: Reduced type complexity in common scenarios

🛡️ Security Assessment

  • No security concerns: Changes are purely TypeScript type-level with no runtime behavior modifications
  • Type safety maintained: All existing type constraints preserved where functionally necessary

⚠️ Issues Found

1. Minor Validator Inconsistency (packages/orm/src/client/crud/validator/index.ts:135)

The validateUpdateManyAndReturnArgs method is missing | undefined in its return type, while other similar methods include it:

// Inconsistent: 
): UpdateManyAndReturnArgs<Schema, GetModels<Schema>> {

// Should be (like other methods):
): UpdateManyAndReturnArgs<Schema, GetModels<Schema>> | undefined {

🧪 Test Coverage

The refactoring maintains all existing functionality. Key areas to verify:

  • Existing unit tests continue to pass without modification
  • Type inference works correctly in real-world usage
  • IDE autocomplete performance improved for complex schemas

📋 Minor Suggestions

  1. Documentation: Consider adding JSDoc to SimplifyIf utility:
/**
 * Conditionally simplifies a type T when Condition is true.
 * Used to provide cleaner IntelliSense experience when requested.
 */
export type SimplifyIf<T, Condition extends boolean> = Condition extends true ? Simplify<T> : T;
  1. Fix validator consistency: Update validateUpdateManyAndReturnArgs return type to include | undefined

🎯 Recommendation: APPROVE

This refactoring demonstrates excellent TypeScript engineering:

  • ✅ Improves developer experience without breaking changes
  • ✅ Follows consistent patterns across the codebase
  • ✅ Maintains type safety while reducing complexity
  • ✅ Shows careful attention to backward compatibility
  • ✅ No security or functional risks identified

The conditional simplification approach is particularly clever, allowing users to opt into simplified types when needed while maintaining full compatibility for existing code.


@ymc9 ymc9 merged commit e0117f2 into dev Nov 13, 2025
5 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