-
-
Notifications
You must be signed in to change notification settings - Fork 17
refactor: extract client-helpers package, update svelte-query to v6 #535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Warning Rate limit exceeded@ymc9 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 8 minutes and 27 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughAdds a new Changes
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
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. Comment |
|
Claude finished @ymc9's task —— View job Comprehensive Pull Request ReviewI've conducted a thorough review of this major refactoring PR. Here are my findings and recommendations: Review Checklist:
🎯 Overall AssessmentThis is a well-executed major refactoring that successfully extracts shared client functionality into a dedicated ✅ Strengths1. Excellent Package Architecture
2. Comprehensive Test Coverage
3. Robust Error Handling
4. Framework Integration Excellence
🔧 Code Quality & Best PracticesExcellent Serialization Handling
Type Safety
Performance Optimizations
🔍 Security AssessmentNo Major Security Concerns Found
📈 Performance ConsiderationsWell Optimized
🚀 Sample ApplicationsExcellent Examples
📝 Minor Suggestions1. Documentation Enhancement// Consider adding JSDoc examples for complex functions like:
// packages/clients/client-helpers/src/fetch.ts:42
/**
* Makes a URL for the given endpoint, model, operation, and args
* @example makeUrl('/api', 'User', 'findMany', { where: { id: 1 } })
* @returns '/api/user/findMany?q=...'
*/2. Logging ConsistencyThe logging in 3. Type NarrowingConsider more specific return types for some mutation functions to improve IntelliSense. 🎉 ConclusionThis is an exceptional refactoring that demonstrates:
Recommendation: APPROVE - This PR successfully achieves its goals with high code quality, comprehensive testing, and excellent architectural decisions. The extraction of client helpers and Svelte Query v6 migration are both well-executed. |
There was a problem hiding this 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 pull request performs a major refactoring to extract shared client logic into a new @zenstackhq/client-helpers package and upgrades @tanstack/svelte-query from v5 to v6. The changes include:
- Creation of a new
client-helperspackage to centralize query analysis, optimistic updates, and invalidation logic - Update of Svelte Query to v6 with corresponding API changes (Svelte 5 runes-based reactivity)
- Addition of new sample applications for SvelteKit and Nuxt
- Refactoring of the tanstack-query package to use the extracted helpers
- Updates to server adapters to support SvelteKit route handlers
Key Changes
- Extracted common client logic (query analysis, optimistic updates, invalidation) into
@zenstackhq/client-helperspackage - Updated
@tanstack/svelte-queryto v6.0.10 with API changes for Svelte 5 compatibility - Added comprehensive sample applications demonstrating integration with SvelteKit and Nuxt
- Refactored React, Vue, and Svelte query hooks to use shared helpers
Reviewed changes
Copilot reviewed 93 out of 100 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| vitest.config.ts | Updated project glob pattern to specifically target vitest config files |
| samples/sveltekit/* | New SvelteKit sample application with database, API routes, and UI |
| samples/nuxt/* | New Nuxt sample application demonstrating Vue integration |
| samples/next.js/* | Updated port configuration and added optimistic update features |
| pnpm-workspace.yaml | Updated TanStack Query versions across frameworks |
| packages/server/src/adapter/sveltekit/* | Added new route handler and deprecated old handler |
| packages/common-helpers/src/tiny-invariant.ts | Added process environment check for browser compatibility |
| packages/clients/tanstack-query/* | Major refactoring to extract common code and update Svelte to v6 |
| packages/clients/client-helpers/* | New package with shared client logic and comprehensive tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 15
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
samples/next.js/app/page.tsx (1)
39-57: Guard against emptyuserswhen creating a post
onCreatePostcurrently only checks for a truthyusersvalue:if (!users) { return; } const forUser = users[Math.floor(Math.random() * users.length)];If the query has resolved to an empty array (or if the user clicks “New Post” before users are fetched but
usershas been initialized as[]),usersis truthy,users.lengthis0, andMath.floor(Math.random() * 0)yieldsNaN, soforUserbecomesundefinedand you’ll sendauthorId: undefined.You already render an early “No users found” state once
isUsersFetched && users.length === 0, but the button is still clickable before that condition flips. It’d be safer to also check length here, e.g.:if (!users || users.length === 0) { return; }or by disabling the button until you have at least one user.
packages/clients/tanstack-query/src/svelte/index.svelte.ts (2)
265-268: Bug:useInfiniteFindManymissingrootOptionsmerge.Unlike other query methods (lines 254-263),
useInfiniteFindManypassesoptionsdirectly without merging withrootOptions. This means infinite queries won't inherit context settings likeendpoint,fetch, orloggingfromuseClientQueries.🔎 Proposed fix
useInfiniteFindMany: (args: any, options?: any) => { - return useInternalInfiniteQuery(schema, modelName, 'findMany', args, options); + return useInternalInfiniteQuery(schema, modelName, 'findMany', args, merge(rootOptions, options)); },
270-316: Multiple hooks missingrootOptionsmerge.Similar to
useInfiniteFindMany, the following hooks pass options directly without mergingrootOptions:
useCreate,useCreateMany,useCreateManyAndReturn(lines 270-279)useUpdate,useUpdateMany,useUpdateManyAndReturn(lines 281-291)useUpsert,useDelete,useDeleteMany(lines 293-303)useCount,useAggregate,useGroupBy(lines 305-315)Compare with the React adapter where all hooks spread
rootOptions:// React adapter pattern (packages/clients/tanstack-query/src/react.ts) useCreate: (options?: any) => { return useInternalMutation(schema, modelName, 'POST', 'create', { ...rootOptions, ...options }); },🔎 Proposed fix pattern
Apply the merge pattern consistently:
useCreate: (options?: any) => { - return useInternalMutation(schema, modelName, 'POST', 'create', options); + return useInternalMutation(schema, modelName, 'POST', 'create', merge(rootOptions, options)); },Apply similarly to all mutation and remaining query hooks.
🧹 Nitpick comments (19)
samples/sveltekit/src/routes/layout.css (1)
20-24: LGTM! Body styling is correct.The body styles correctly apply the theme variables for background and color. The font stack is functional for a sample application.
Optional: Consider a modern system font stack
For a more polished appearance, you could use a modern system font stack:
body { background: var(--background); color: var(--foreground); - font-family: Arial, Helvetica, sans-serif; + font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; }This is purely cosmetic and not required for the sample.
packages/clients/client-helpers/vitest.config.ts (1)
1-4: Consider simplifying if no customization is needed.Since you're merging the base config with an empty configuration, you could simplify this to:
-import base from '@zenstackhq/vitest-config/base'; -import { defineConfig, mergeConfig } from 'vitest/config'; - -export default mergeConfig(base, defineConfig({})); +export { default } from '@zenstackhq/vitest-config/base';However, the current pattern does provide a clear extension point for future customizations.
packages/clients/tanstack-query/src/common/query-key.ts (2)
1-4: Update comment to reflect multi-framework usage.The comment says "Prefix for react-query keys" but this module is used across React, Vue, and Svelte integrations. Consider updating to "Prefix for TanStack Query keys" for accuracy.
🔎 Suggested fix
/** - * Prefix for react-query keys. + * Prefix for TanStack Query keys. */ export const QUERY_KEY_PREFIX = 'zenstack';
34-34: Remove unnecessary non-null assertion.The
operation!non-null assertion is redundant sinceoperationis already typed asstring(notstring | null | undefined).🔎 Suggested fix
- return [QUERY_KEY_PREFIX, model, operation!, args, { infinite, optimisticUpdate }]; + return [QUERY_KEY_PREFIX, model, operation, args, { infinite, optimisticUpdate }];samples/nuxt/zenstack/seed.ts (1)
23-23: Add error handling to main() invocation.The async
main()function is invoked without error handling, which could result in unhandled promise rejections if database operations fail.🔎 Proposed fix
-main(); +main().catch((error) => { + console.error('Failed to seed database:', error); + process.exit(1); +});samples/sveltekit/src/lib/db.ts (1)
6-10: Consider using an absolute path or process.cwd()-relative path for the database.The database path
"./src/zenstack/dev.db"is relative and will resolve differently depending on where the process is started from. If this script is executed from the monorepo root versus the package directory, it could fail to find the database file.🔎 Suggested approaches for more robust path resolution
Option 1: Use import.meta or __dirname equivalent
+import { fileURLToPath } from 'url'; +import { dirname, join } from 'path'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + export const db = new ZenStackClient(schema, { dialect: new SqliteDialect({ - database: new SQLite("./src/zenstack/dev.db"), + database: new SQLite(join(__dirname, "../zenstack/dev.db")), }), });Option 2: Use environment variable or configuration
export const db = new ZenStackClient(schema, { dialect: new SqliteDialect({ - database: new SQLite("./src/zenstack/dev.db"), + database: new SQLite(process.env.DATABASE_PATH || "./src/zenstack/dev.db"), }), });Note: The Nuxt sample uses
"./zenstack/dev.db"(line 8 insamples/nuxt/server/utils/db.ts), which is a different relative path pattern. Consider aligning these for consistency across samples.samples/nuxt/server/utils/db.ts (1)
6-10: Consider using an absolute path for the database and align with SvelteKit sample.The database path
"./zenstack/dev.db"is relative and may resolve incorrectly depending on the process working directory. Additionally, this path pattern differs from the SvelteKit sample which uses"./src/zenstack/dev.db".🔎 Suggested approaches for more robust path resolution
Option 1: Use absolute path resolution
+import { join } from 'path'; + export const db = new ZenStackClient(schema, { dialect: new SqliteDialect({ - database: new SQLite('./zenstack/dev.db'), + database: new SQLite(join(process.cwd(), 'zenstack/dev.db')), }), });Option 2: Use environment variable
export const db = new ZenStackClient(schema, { dialect: new SqliteDialect({ - database: new SQLite('./zenstack/dev.db'), + database: new SQLite(process.env.DATABASE_PATH || './zenstack/dev.db'), }), });Note: Consider establishing a consistent database path convention across samples. The SvelteKit sample uses
"./src/zenstack/dev.db"while this uses"./zenstack/dev.db".packages/clients/client-helpers/test/fetch.test.ts (1)
200-208: Minor inconsistency in fetch mocking.Line 202 saves
globalThis.fetchbut line 202 assigns toglobal.fetch. While they typically refer to the same object in Node test environments, for consistency you should use the same reference:- global.fetch = mockFetch as typeof global.fetch; + globalThis.fetch = mockFetch as typeof globalThis.fetch;samples/sveltekit/src/routes/api/model/[...path]/+server.ts (1)
6-9: Consider request-scoped database client for production usage.The
getClientcallback returns a singletondbinstance for all requests. While this is acceptable for a sample application, production applications typically need request-scoped clients that include user authentication context for proper access control.For production usage, consider creating a per-request client with user context:
const handler = SvelteKitRouteHandler({ apiHandler: new RPCApiHandler({ schema }), getClient: (event) => { // Get user from session/auth const user = await event.locals.getUser(); return db.withUser(user); }, });Since this is a sample app demonstrating the API structure, the current implementation is acceptable. Just ensure developers understand this pattern needs modification for production.
samples/nuxt/app/app.vue (1)
36-54: Consider adding null check for array element access.Line 45 accesses
users.value[Math.floor(Math.random() * users.value.length)]!with a non-null assertion operator. While the check on line 37 ensuresusers.valueexists and is an array, ifusers.valueis an empty array, the random access could still theoretically produce issues (thoughMath.random() * 0would be 0, resulting inundefined).Consider adding an additional check:
🔎 More defensive array access
const onCreatePost = () => { - if (!users.value) { + if (!users.value || users.value.length === 0) { return; }samples/sveltekit/src/routes/+page.svelte (1)
36-54: Consider adding empty array check.Line 45 performs array access using
users.data[Math.floor(Math.random() * users.data.length)]without an explicit check for empty array. While line 37 checks!users.data, if the array is empty, this would returnundefined.🔎 More defensive array access
function onCreatePost() { - if (!users.data) { + if (!users.data || users.data.length === 0) { return; }packages/clients/tanstack-query/src/common/client.ts (1)
17-41: Remove redundant optional chaining.Lines 27-29 use optional chaining (
parsed?.model,parsed?.operation,parsed?.args) after already filtering out undefinedparsedvalues on lines 22-25. This is redundant.🔎 Simplify property access
return { - model: parsed?.model, - operation: parsed?.operation, - args: parsed?.args, + model: parsed.model, + operation: parsed.operation, + args: parsed.args, data: state.data, optimisticUpdate: !!parsed.flags.optimisticUpdate,packages/clients/client-helpers/test/query-analysis.test.ts (1)
1-1396: Comprehensive coverage ofgetReadModels/getMutatedModelsbehaviorThe suite does a good job pinning down the intended contract (relations, nested writes, cascades, inheritance, edge cases). The expectations are order-agnostic where it matters, and use the shared schema helpers correctly. If you find yourself evolving this further, you might consider extracting a couple of the repeated User/Post/Comment schema shapes into small factory helpers to keep the tests easier to maintain, but it’s not required.
packages/clients/client-helpers/test/nested-write-visitor.test.ts (2)
77-114: Array-order assertions are a bit brittle forcreatewith arraysHere you assert that
createCallbackis called 3 times and then pin exact call order for the twoCommentcreates (the 3rd call isComment 1, 2nd call isComment 2). That effectively bakes in a particular traversal order of the input array.If the visitor implementation ever changes traversal (e.g., from reverse to forward, or vice versa) while still visiting exactly the same payloads, these tests will start failing for reasons that aren’t semantically important.
Consider loosening the expectations to something like “one call for Post and two calls for Comment with the expected payloads”, without relying on their exact sequencing.
625-648: Clarify the delete callback comment vs expectationThe comment says “For top-level delete, the callback receives the full args object including where”, but the assertion checks that the callback gets just
{ id: '1' }rather than{ where: { id: '1' } }.Whichever shape you intend as the public contract for the delete callback, it’d be good to align the comment with the actual expectation (or adjust the expectation if the comment describes the desired behavior).
samples/next.js/app/page.tsx (1)
17-23: Consider lifting the customfetchwrapper out of the componentThe artificial-delay
fetchwrapper is re-created on every render and passed intouseClientQueries(schema, { fetch }). Depending on howuseClientQueriesmemoizes its inputs, this could cause unnecessary re-instantiation of its internal helpers.Since this wrapper doesn’t depend on component state or props, you could move it to module scope (or wrap it in
useCallbackwith an empty dependency array) so its identity stays stable across renders:const delayedFetch: FetchFn = async (url, init) => { await new Promise((resolve) => setTimeout(resolve, 1000)); return globalThis.fetch(url, init); }; // ... const clientQueries = useClientQueries(schema, { fetch: delayedFetch });This keeps the example a bit cleaner and avoids any accidental re-creation cost.
packages/clients/tanstack-query/src/react.ts (1)
560-567: Query snapshot timing consideration.Similar to the Vue adapter,
getAllQueries(queryClient)is called whenuseInternalMutationruns, capturing a snapshot. In React, hooks re-run on each render, but TanStack Query'suseMutationmay cache its options.For consistency with the Vue fix and to ensure the latest query list is used at mutation time, consider the same callback pattern:
const optimisticUpdater = createOptimisticUpdater( model, operation, schema, { optimisticDataProvider: finalOptions.optimisticDataProvider }, - getAllQueries(queryClient), + () => getAllQueries(queryClient), logging, );packages/server/src/adapter/sveltekit/handler.ts (1)
22-23: Consider expanding the deprecation notice with usage guidance.The deprecation points to
SvelteKitRouteHandlerbut doesn't explain the key difference: this handler is for global request handling inhooks.server.ts(with URL prefix matching), whileSvelteKitRouteHandleris for route-specific+server.tsfiles (using route parameters). Adding this context would help users choose the right handler.📋 Suggested JSDoc enhancement
/** * SvelteKit server hooks handler for handling CRUD requests. This handler is to be used in `hooks.server.ts`. - * @deprecated use `SvelteKitRouteHandler` instead. + * @deprecated Prefer `SvelteKitRouteHandler` for route-specific handlers in `+server.ts` files. + * Use this handler only if you need global request handling in `hooks.server.ts` with URL prefix matching. */packages/server/src/adapter/sveltekit/route-handler.ts (1)
16-19: Document the required route parameter structure.The handler expects a route parameter named
path(line 37), but this requirement isn't documented. Users need to know they should create a catch-all route likesrc/routes/api/[...path]/+server.tsfor this handler to work correctly.📋 Suggested JSDoc enhancement
/** - * SvelteKit server route handler for handling CRUD requests. This handler is to be used in a `+server.ts` - * API route file. + * SvelteKit server route handler for handling CRUD requests. + * + * This handler should be used in a `+server.ts` file with a catch-all route parameter named `path`. + * For example: `src/routes/api/[...path]/+server.ts` + * + * @example + * ```typescript + * // src/routes/api/[...path]/+server.ts + * import { SvelteKitRouteHandler } from '@zenstackhq/server/sveltekit'; + * + * export const GET = SvelteKitRouteHandler({ + * apiHandler: myApiHandler, + * getClient: (event) => getClient(event) + * }); + * + * export const POST = GET; + * export const PUT = GET; + * export const DELETE = GET; + * ``` */
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (5)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlsamples/nuxt/public/favicon.icois excluded by!**/*.icosamples/nuxt/public/nuxt.svgis excluded by!**/*.svgsamples/sveltekit/src/lib/assets/favicon.svgis excluded by!**/*.svgsamples/sveltekit/static/svelte.pngis excluded by!**/*.png
📒 Files selected for processing (95)
.gitignoreCONTRIBUTING.mdpackage.jsonpackages/cli/package.jsonpackages/clients/client-helpers/eslint.config.jspackages/clients/client-helpers/package.jsonpackages/clients/client-helpers/src/constants.tspackages/clients/client-helpers/src/fetch.tspackages/clients/client-helpers/src/index.tspackages/clients/client-helpers/src/invalidation.tspackages/clients/client-helpers/src/logging.tspackages/clients/client-helpers/src/mutator.tspackages/clients/client-helpers/src/nested-read-visitor.tspackages/clients/client-helpers/src/nested-write-visitor.tspackages/clients/client-helpers/src/optimistic.tspackages/clients/client-helpers/src/query-analysis.tspackages/clients/client-helpers/src/types.tspackages/clients/client-helpers/test/fetch.test.tspackages/clients/client-helpers/test/invalidation.test.tspackages/clients/client-helpers/test/mutator.test.tspackages/clients/client-helpers/test/nested-read-visitor.test.tspackages/clients/client-helpers/test/nested-write-visitor.test.tspackages/clients/client-helpers/test/optimistic.test.tspackages/clients/client-helpers/test/query-analysis.test.tspackages/clients/client-helpers/test/test-helpers.tspackages/clients/client-helpers/tsconfig.jsonpackages/clients/client-helpers/tsconfig.test.jsonpackages/clients/client-helpers/tsup.config.tspackages/clients/client-helpers/vitest.config.tspackages/clients/tanstack-query/.gitignorepackages/clients/tanstack-query/package.jsonpackages/clients/tanstack-query/src/common/.gitignorepackages/clients/tanstack-query/src/common/client.tspackages/clients/tanstack-query/src/common/query-key.tspackages/clients/tanstack-query/src/common/types.tspackages/clients/tanstack-query/src/react.tspackages/clients/tanstack-query/src/svelte/index.svelte.tspackages/clients/tanstack-query/src/utils/common.tspackages/clients/tanstack-query/src/utils/serialization.tspackages/clients/tanstack-query/src/utils/types.tspackages/clients/tanstack-query/src/vue.tspackages/clients/tanstack-query/test/react-query.test.tsxpackages/clients/tanstack-query/test/svelte-typing-test.tspackages/clients/tanstack-query/tsconfig.general.jsonpackages/clients/tanstack-query/tsconfig.jsonpackages/clients/tanstack-query/tsconfig.svelte.jsonpackages/common-helpers/src/tiny-invariant.tspackages/server/package.jsonpackages/server/src/adapter/sveltekit/handler.tspackages/server/src/adapter/sveltekit/index.tspackages/server/src/adapter/sveltekit/route-handler.tspnpm-workspace.yamlsamples/next.js/app/page.tsxsamples/next.js/app/providers.tsxsamples/next.js/next.config.tssamples/next.js/package.jsonsamples/nuxt/.gitignoresamples/nuxt/README.mdsamples/nuxt/app/app.vuesamples/nuxt/app/assets/css/main.csssamples/nuxt/app/plugins/tanstack-query.tssamples/nuxt/nuxt.config.tssamples/nuxt/package.jsonsamples/nuxt/public/robots.txtsamples/nuxt/server/api/model/[...].tssamples/nuxt/server/utils/db.tssamples/nuxt/tsconfig.jsonsamples/nuxt/zenstack/input.tssamples/nuxt/zenstack/models.tssamples/nuxt/zenstack/schema-lite.tssamples/nuxt/zenstack/schema.tssamples/nuxt/zenstack/schema.zmodelsamples/nuxt/zenstack/seed.tssamples/sveltekit/.gitignoresamples/sveltekit/.prettierrcsamples/sveltekit/README.mdsamples/sveltekit/package.jsonsamples/sveltekit/src/app.d.tssamples/sveltekit/src/app.htmlsamples/sveltekit/src/lib/db.tssamples/sveltekit/src/lib/index.tssamples/sveltekit/src/routes/+layout.sveltesamples/sveltekit/src/routes/+page.sveltesamples/sveltekit/src/routes/api/model/[...path]/+server.tssamples/sveltekit/src/routes/layout.csssamples/sveltekit/src/zenstack/input.tssamples/sveltekit/src/zenstack/models.tssamples/sveltekit/src/zenstack/schema-lite.tssamples/sveltekit/src/zenstack/schema.tssamples/sveltekit/src/zenstack/schema.zmodelsamples/sveltekit/src/zenstack/seed.tssamples/sveltekit/svelte.config.jssamples/sveltekit/tsconfig.jsonsamples/sveltekit/vite.config.tsvitest.config.ts
💤 Files with no reviewable changes (4)
- packages/clients/tanstack-query/src/utils/serialization.ts
- packages/clients/tanstack-query/src/utils/types.ts
- packages/clients/client-helpers/src/query-analysis.ts
- packages/clients/tanstack-query/src/utils/common.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.zmodel
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.zmodel: Always runzenstack generateafter modifying ZModel schemas
ZModel schema files should define database structure and policies that compile to TypeScript viazenstack generate
Files:
samples/nuxt/zenstack/schema.zmodelsamples/sveltekit/src/zenstack/schema.zmodel
🧠 Learnings (14)
📓 Common learnings
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Use Kysely as the query builder interface for low-level database queries, avoiding raw SQL when possible
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.test.{ts,tsx} : ORM package tests should include comprehensive client API tests and policy tests
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Implement plugin hooks at ORM, Kysely, and entity mutation levels for query interception and customization
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.test.{ts,tsx} : ORM package tests should include comprehensive client API tests and policy tests
Applied to files:
packages/clients/client-helpers/src/types.tssamples/nuxt/zenstack/seed.tssamples/sveltekit/src/zenstack/seed.tspackages/clients/client-helpers/test/optimistic.test.tspackages/clients/client-helpers/test/mutator.test.tspackages/clients/client-helpers/test/fetch.test.tspackages/clients/client-helpers/src/invalidation.tspackages/clients/client-helpers/test/invalidation.test.tspackages/clients/client-helpers/src/optimistic.tspackages/clients/client-helpers/test/nested-read-visitor.test.tspackages/clients/client-helpers/test/test-helpers.tspackages/clients/client-helpers/src/mutator.tspackages/clients/client-helpers/test/query-analysis.test.tspackages/clients/client-helpers/package.jsonpackages/clients/tanstack-query/test/svelte-typing-test.tspackages/clients/client-helpers/test/nested-write-visitor.test.tssamples/sveltekit/src/zenstack/input.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Implement plugin hooks at ORM, Kysely, and entity mutation levels for query interception and customization
Applied to files:
packages/clients/client-helpers/src/types.tspackages/clients/tanstack-query/tsconfig.general.jsonsamples/nuxt/server/api/model/[...].tssamples/nuxt/zenstack/models.tssamples/nuxt/zenstack/seed.tspackages/clients/tanstack-query/src/common/query-key.tssamples/sveltekit/src/zenstack/seed.tspackages/clients/client-helpers/test/optimistic.test.tspackages/clients/client-helpers/test/mutator.test.tssamples/nuxt/README.mdpackages/clients/client-helpers/src/invalidation.tssamples/sveltekit/src/zenstack/schema.tspackages/clients/client-helpers/test/invalidation.test.tspackages/clients/client-helpers/src/optimistic.tssamples/nuxt/zenstack/schema.tssamples/nuxt/zenstack/input.tssamples/sveltekit/src/zenstack/models.tspackages/clients/client-helpers/src/mutator.tssamples/sveltekit/src/lib/db.tspackages/clients/tanstack-query/src/react.tssamples/sveltekit/src/zenstack/schema-lite.tspackages/clients/client-helpers/test/query-analysis.test.tssamples/nuxt/server/utils/db.tssamples/nuxt/app/plugins/tanstack-query.tspackages/clients/tanstack-query/src/common/types.tspackages/clients/tanstack-query/src/vue.tspackages/clients/tanstack-query/src/svelte/index.svelte.tspackages/clients/tanstack-query/test/svelte-typing-test.tssamples/sveltekit/src/zenstack/input.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Use Kysely as the query builder interface for low-level database queries, avoiding raw SQL when possible
Applied to files:
packages/clients/client-helpers/src/types.tspackages/clients/tanstack-query/tsconfig.general.jsonpackages/clients/tanstack-query/src/common/client.tssamples/nuxt/zenstack/models.tspackages/clients/tanstack-query/test/react-query.test.tsxsamples/nuxt/zenstack/seed.tspackages/clients/tanstack-query/src/common/query-key.tssamples/sveltekit/src/zenstack/seed.tssamples/nuxt/README.mdsamples/nuxt/zenstack/schema-lite.tssamples/sveltekit/src/zenstack/schema.tspackages/clients/client-helpers/src/optimistic.tssamples/nuxt/zenstack/schema.tssamples/nuxt/zenstack/input.tspnpm-workspace.yamlsamples/sveltekit/src/zenstack/models.tspackages/clients/tanstack-query/package.jsonpackages/clients/client-helpers/src/mutator.tssamples/sveltekit/src/lib/db.tspackages/clients/tanstack-query/src/react.tssamples/sveltekit/src/zenstack/schema-lite.tspackages/clients/tanstack-query/tsconfig.svelte.jsonpackages/clients/client-helpers/test/query-analysis.test.tssamples/nuxt/server/utils/db.tssamples/nuxt/app/plugins/tanstack-query.tspackages/clients/tanstack-query/src/common/types.tspackages/clients/tanstack-query/src/vue.tspackages/clients/tanstack-query/src/svelte/index.svelte.tspackages/clients/tanstack-query/test/svelte-typing-test.tssamples/sveltekit/src/zenstack/input.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to **/*.zmodel : ZModel schema files should define database structure and policies that compile to TypeScript via `zenstack generate`
Applied to files:
packages/clients/tanstack-query/tsconfig.general.jsonsamples/nuxt/server/api/model/[...].tssamples/nuxt/zenstack/models.tssamples/nuxt/zenstack/seed.tspackages/clients/tanstack-query/src/common/.gitignoresamples/sveltekit/src/zenstack/seed.tssamples/nuxt/README.mdsamples/nuxt/zenstack/schema.zmodelsamples/nuxt/zenstack/schema-lite.tspackages/clients/client-helpers/tsconfig.test.jsonsamples/sveltekit/src/zenstack/schema.tspackages/clients/client-helpers/tsconfig.jsonsamples/nuxt/zenstack/schema.tssamples/nuxt/zenstack/input.tssamples/sveltekit/src/zenstack/models.tspackages/clients/client-helpers/test/test-helpers.tspackages/clients/client-helpers/src/mutator.tssamples/sveltekit/src/lib/db.tssamples/sveltekit/src/zenstack/schema-lite.tssamples/sveltekit/src/zenstack/schema.zmodelsamples/nuxt/server/utils/db.tspackages/clients/tanstack-query/tsconfig.jsonsamples/sveltekit/package.jsonsamples/sveltekit/src/zenstack/input.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to **/*.zmodel : Always run `zenstack generate` after modifying ZModel schemas
Applied to files:
samples/nuxt/zenstack/models.tssamples/nuxt/zenstack/schema.zmodelsamples/nuxt/zenstack/schema.tssamples/sveltekit/src/zenstack/models.ts
📚 Learning: 2025-10-21T16:09:31.218Z
Learnt from: ymc9
Repo: zenstackhq/zenstack-v3 PR: 319
File: packages/runtime/src/client/executor/zenstack-query-executor.ts:63-72
Timestamp: 2025-10-21T16:09:31.218Z
Learning: In ZenStack, TypeDefs can be inherited by models. When a TypeDef contains fields with `map` attributes, those mapped field names need to be processed by the QueryNameMapper since they become part of the inheriting model's schema. Therefore, when checking if a schema has mapped names (e.g., in `schemaHasMappedNames`), both `schema.models` and `schema.typeDefs` must be inspected for `@map` and `map` attributes.
Applied to files:
samples/nuxt/zenstack/models.tssamples/nuxt/zenstack/schema.zmodelsamples/nuxt/zenstack/schema-lite.tssamples/sveltekit/src/zenstack/schema.tssamples/nuxt/zenstack/schema.tspackages/clients/client-helpers/test/test-helpers.tssamples/sveltekit/src/zenstack/schema-lite.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to tests/**/type*.{ts,tsx} : Ensure TypeScript inference and type coverage are validated through type coverage tests
Applied to files:
samples/nuxt/tsconfig.jsonpackages/clients/tanstack-query/src/common/.gitignorepackages/clients/client-helpers/test/optimistic.test.tspackages/clients/client-helpers/test/mutator.test.tspackages/clients/client-helpers/tsconfig.test.jsonpackages/clients/client-helpers/test/fetch.test.tspackages/clients/client-helpers/test/invalidation.test.tspackages/clients/client-helpers/tsconfig.jsonpackages/clients/client-helpers/test/nested-read-visitor.test.ts.gitignorepackage.jsonpackages/clients/client-helpers/test/query-analysis.test.tsvitest.config.tspackages/clients/tanstack-query/test/svelte-typing-test.tspackages/clients/client-helpers/test/nested-write-visitor.test.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Database migrations should use Prisma CLI under the hood via ZenStack commands
Applied to files:
samples/nuxt/zenstack/seed.tssamples/sveltekit/src/zenstack/seed.tssamples/sveltekit/src/lib/db.tssamples/sveltekit/src/zenstack/schema.zmodelsamples/nuxt/server/utils/db.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to tests/e2e/**/*.{ts,tsx} : E2E tests should validate real-world schema compatibility with established projects
Applied to files:
packages/clients/tanstack-query/src/common/.gitignorepackages/clients/client-helpers/test/optimistic.test.tspackages/clients/client-helpers/test/mutator.test.tssamples/nuxt/zenstack/schema-lite.tspackages/clients/client-helpers/tsconfig.test.jsonpackages/clients/client-helpers/test/fetch.test.tsCONTRIBUTING.mdsamples/sveltekit/src/zenstack/schema.tspackages/clients/client-helpers/test/invalidation.test.tssamples/nuxt/zenstack/schema.tspackages/clients/client-helpers/test/nested-read-visitor.test.tspackages/clients/client-helpers/test/test-helpers.tspackages/clients/client-helpers/test/query-analysis.test.tsvitest.config.tspackages/clients/tanstack-query/test/svelte-typing-test.tspackages/clients/client-helpers/test/nested-write-visitor.test.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/cli/**/*.test.{ts,tsx} : CLI package tests should focus on action-specific tests for each command
Applied to files:
packages/clients/client-helpers/test/mutator.test.tspackages/clients/tanstack-query/package.jsonpackages/clients/client-helpers/package.jsonvitest.config.tspackages/clients/tanstack-query/test/svelte-typing-test.tspackages/clients/client-helpers/test/nested-write-visitor.test.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Support only SQLite (better-sqlite3) and PostgreSQL (pg) as database adapters
Applied to files:
CONTRIBUTING.md
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Use `pnpm` with workspaces for package management, pinned to version `pnpm10.12.1`
Applied to files:
pnpm-workspace.yamlpackages/cli/package.json
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Use Turbo for build orchestration and run `pnpm build`, `pnpm watch`, `pnpm lint`, and `pnpm test` for development tasks
Applied to files:
packages/clients/tanstack-query/package.json
🧬 Code graph analysis (31)
packages/clients/tanstack-query/src/common/client.ts (3)
packages/clients/client-helpers/src/invalidation.ts (1)
InvalidationPredicate(9-9)packages/clients/tanstack-query/src/common/query-key.ts (1)
parseQueryKey(40-46)packages/clients/client-helpers/src/types.ts (1)
QueryInfo(48-82)
samples/nuxt/server/api/model/[...].ts (2)
samples/nuxt/server/utils/db.ts (1)
db(6-10)samples/sveltekit/src/lib/db.ts (1)
db(6-10)
samples/sveltekit/src/app.d.ts (1)
tests/e2e/github-repos/cal.com/models.ts (1)
App(46-46)
samples/nuxt/zenstack/models.ts (1)
samples/sveltekit/src/zenstack/models.ts (2)
User(13-13)Post(17-17)
samples/nuxt/zenstack/seed.ts (7)
samples/nuxt/server/utils/db.ts (1)
db(6-10)samples/sveltekit/src/lib/db.ts (1)
db(6-10)samples/nuxt/zenstack/schema-lite.ts (1)
schema(106-106)samples/nuxt/zenstack/schema.ts (1)
schema(115-115)samples/sveltekit/src/zenstack/schema-lite.ts (1)
schema(106-106)samples/sveltekit/src/zenstack/schema.ts (1)
schema(115-115)packages/orm/src/dialects/sqlite.ts (1)
SqliteDialect(1-1)
samples/sveltekit/src/routes/api/model/[...path]/+server.ts (3)
packages/server/src/adapter/sveltekit/index.ts (1)
SvelteKitRouteHandler(2-2)samples/nuxt/server/utils/db.ts (1)
db(6-10)samples/sveltekit/src/lib/db.ts (1)
db(6-10)
packages/server/src/adapter/sveltekit/route-handler.ts (3)
packages/schema/src/schema.ts (1)
SchemaDef(11-19)packages/server/src/adapter/common.ts (2)
CommonAdapterOptions(8-13)logInternalError(15-21)packages/orm/src/client/contract.ts (1)
ClientContract(63-197)
samples/next.js/app/providers.tsx (1)
packages/clients/tanstack-query/src/react.ts (1)
QuerySettingsProvider(80-80)
samples/sveltekit/src/zenstack/seed.ts (3)
samples/sveltekit/src/lib/db.ts (1)
db(6-10)samples/sveltekit/src/zenstack/schema-lite.ts (1)
schema(106-106)samples/sveltekit/src/zenstack/schema.ts (1)
schema(115-115)
packages/clients/client-helpers/test/optimistic.test.ts (4)
packages/clients/client-helpers/test/test-helpers.ts (3)
createSchema(6-12)createField(17-23)createRelationField(28-37)packages/clients/client-helpers/src/types.ts (1)
QueryInfo(48-82)packages/clients/client-helpers/src/optimistic.ts (1)
createOptimisticUpdater(68-139)packages/clients/client-helpers/src/logging.ts (1)
Logger(4-4)
packages/clients/client-helpers/test/mutator.test.ts (3)
packages/clients/client-helpers/test/test-helpers.ts (2)
createSchema(6-12)createField(17-23)packages/clients/client-helpers/src/mutator.ts (1)
applyMutation(20-40)packages/clients/client-helpers/src/logging.ts (1)
Logger(4-4)
samples/nuxt/zenstack/schema-lite.ts (3)
samples/sveltekit/src/zenstack/schema.ts (2)
SchemaType(9-114)schema(115-115)packages/schema/src/schema.ts (1)
SchemaDef(11-19)packages/schema/src/expression-utils.ts (1)
ExpressionUtils(19-123)
packages/clients/client-helpers/test/fetch.test.ts (1)
packages/clients/client-helpers/src/fetch.ts (6)
serialize(71-74)deserialize(79-81)marshal(86-93)unmarshal(99-107)makeUrl(42-54)fetcher(15-37)
packages/clients/client-helpers/test/invalidation.test.ts (3)
packages/clients/client-helpers/test/test-helpers.ts (3)
createSchema(6-12)createField(17-23)createRelationField(28-37)packages/clients/client-helpers/src/invalidation.ts (1)
createInvalidator(26-44)packages/clients/client-helpers/src/logging.ts (1)
Logger(4-4)
packages/clients/client-helpers/src/optimistic.ts (4)
packages/schema/src/schema.ts (1)
SchemaDef(11-19)packages/clients/client-helpers/src/types.ts (2)
QueryInfo(48-82)ORMWriteActionType(28-28)packages/clients/client-helpers/src/logging.ts (2)
Logger(4-4)log(9-15)packages/clients/client-helpers/src/mutator.ts (1)
applyMutation(20-40)
samples/nuxt/zenstack/schema.ts (2)
packages/schema/src/schema.ts (1)
SchemaDef(11-19)packages/schema/src/expression-utils.ts (1)
ExpressionUtils(19-123)
samples/nuxt/zenstack/input.ts (1)
samples/sveltekit/src/zenstack/input.ts (40)
UserFindManyArgs(11-11)UserFindUniqueArgs(12-12)UserFindFirstArgs(13-13)UserCreateArgs(14-14)UserCreateManyArgs(15-15)UserCreateManyAndReturnArgs(16-16)UserUpdateArgs(17-17)UserUpdateManyArgs(18-18)UserUpdateManyAndReturnArgs(19-19)UserUpsertArgs(20-20)UserDeleteArgs(21-21)UserDeleteManyArgs(22-22)UserCountArgs(23-23)UserAggregateArgs(24-24)UserGroupByArgs(25-25)UserWhereInput(26-26)UserSelect(27-27)UserInclude(28-28)UserOmit(29-29)UserGetPayload(30-30)PostFindManyArgs(31-31)PostFindUniqueArgs(32-32)PostFindFirstArgs(33-33)PostCreateArgs(34-34)PostCreateManyArgs(35-35)PostCreateManyAndReturnArgs(36-36)PostUpdateArgs(37-37)PostUpdateManyArgs(38-38)PostUpdateManyAndReturnArgs(39-39)PostUpsertArgs(40-40)PostDeleteArgs(41-41)PostDeleteManyArgs(42-42)PostCountArgs(43-43)PostAggregateArgs(44-44)PostGroupByArgs(45-45)PostWhereInput(46-46)PostSelect(47-47)PostInclude(48-48)PostOmit(49-49)PostGetPayload(50-50)
packages/server/src/adapter/sveltekit/handler.ts (3)
packages/server/src/adapter/sveltekit/route-handler.ts (1)
createHandler(59-59)packages/schema/src/schema.ts (1)
SchemaDef(11-19)packages/server/src/adapter/sveltekit/index.ts (1)
SvelteKitHandlerOptions(1-1)
packages/clients/client-helpers/src/fetch.ts (2)
packages/clients/client-helpers/src/types.ts (1)
QueryError(33-43)packages/common-helpers/src/lower-case-first.ts (1)
lowerCaseFirst(1-3)
packages/clients/client-helpers/src/nested-read-visitor.ts (1)
packages/schema/src/schema.ts (1)
FieldDef(62-78)
packages/clients/client-helpers/test/nested-read-visitor.test.ts (2)
packages/clients/client-helpers/test/test-helpers.ts (3)
createSchema(6-12)createField(17-23)createRelationField(28-37)packages/clients/client-helpers/src/nested-read-visitor.ts (2)
NestedReadVisitor(22-68)NestedReadVisitorCallback(6-17)
packages/clients/client-helpers/test/test-helpers.ts (1)
packages/schema/src/schema.ts (2)
SchemaDef(11-19)FieldDef(62-78)
packages/clients/client-helpers/src/mutator.ts (1)
packages/clients/client-helpers/src/logging.ts (2)
Logger(4-4)log(9-15)
packages/clients/client-helpers/src/constants.ts (2)
packages/clients/tanstack-query/src/react.ts (1)
DEFAULT_QUERY_ENDPOINT(67-67)packages/clients/tanstack-query/src/svelte/index.svelte.ts (1)
DEFAULT_QUERY_ENDPOINT(65-65)
packages/clients/tanstack-query/src/react.ts (3)
packages/clients/tanstack-query/src/common/types.ts (1)
QueryContext(9-24)packages/clients/client-helpers/src/invalidation.ts (1)
createInvalidator(26-44)packages/clients/tanstack-query/src/common/client.ts (2)
invalidateQueriesMatchingPredicate(5-15)getAllQueries(17-41)
samples/sveltekit/src/zenstack/schema-lite.ts (4)
samples/nuxt/zenstack/schema-lite.ts (2)
SchemaType(9-105)schema(106-106)samples/nuxt/zenstack/schema.ts (2)
SchemaType(9-114)schema(115-115)packages/schema/src/schema.ts (1)
SchemaDef(11-19)packages/schema/src/expression-utils.ts (1)
ExpressionUtils(19-123)
samples/nuxt/app/plugins/tanstack-query.ts (1)
packages/clients/tanstack-query/src/vue.ts (1)
provideQuerySettingsContext(76-78)
packages/clients/tanstack-query/src/common/types.ts (5)
packages/clients/client-helpers/src/fetch.ts (1)
FetchFn(9-9)packages/clients/client-helpers/src/logging.ts (1)
Logger(4-4)packages/clients/client-helpers/src/optimistic.ts (1)
OptimisticDataProvider(17-23)packages/orm/src/client/contract.ts (1)
OperationsIneligibleForDelegateModels(833-833)packages/schema/src/schema.ts (3)
SchemaDef(11-19)GetModels(121-121)IsDelegateModel(296-299)
packages/clients/tanstack-query/src/vue.ts (6)
packages/clients/tanstack-query/src/common/types.ts (1)
QueryContext(9-24)packages/clients/tanstack-query/src/common/query-key.ts (2)
QueryKey(6-15)getQueryKey(25-35)packages/clients/client-helpers/src/fetch.ts (2)
makeUrl(42-54)fetcher(15-37)packages/clients/client-helpers/src/invalidation.ts (2)
createInvalidator(26-44)InvalidationPredicate(9-9)packages/clients/tanstack-query/src/common/client.ts (2)
invalidateQueriesMatchingPredicate(5-15)getAllQueries(17-41)packages/clients/client-helpers/src/optimistic.ts (1)
createOptimisticUpdater(68-139)
packages/clients/tanstack-query/test/svelte-typing-test.ts (2)
packages/clients/tanstack-query/src/svelte/index.svelte.ts (1)
useClientQueries(213-228)packages/clients/tanstack-query/src/vue.ts (1)
useClientQueries(214-229)
samples/sveltekit/src/zenstack/input.ts (1)
samples/nuxt/zenstack/input.ts (40)
UserFindManyArgs(11-11)UserFindUniqueArgs(12-12)UserFindFirstArgs(13-13)UserCreateArgs(14-14)UserCreateManyArgs(15-15)UserCreateManyAndReturnArgs(16-16)UserUpdateArgs(17-17)UserUpdateManyArgs(18-18)UserUpdateManyAndReturnArgs(19-19)UserUpsertArgs(20-20)UserDeleteArgs(21-21)UserDeleteManyArgs(22-22)UserCountArgs(23-23)UserAggregateArgs(24-24)UserGroupByArgs(25-25)UserWhereInput(26-26)UserSelect(27-27)UserInclude(28-28)UserOmit(29-29)UserGetPayload(30-30)PostFindManyArgs(31-31)PostFindUniqueArgs(32-32)PostFindFirstArgs(33-33)PostCreateArgs(34-34)PostCreateManyArgs(35-35)PostCreateManyAndReturnArgs(36-36)PostUpdateArgs(37-37)PostUpdateManyArgs(38-38)PostUpdateManyAndReturnArgs(39-39)PostUpsertArgs(40-40)PostDeleteArgs(41-41)PostDeleteManyArgs(42-42)PostCountArgs(43-43)PostAggregateArgs(44-44)PostGroupByArgs(45-45)PostWhereInput(46-46)PostSelect(47-47)PostInclude(48-48)PostOmit(49-49)PostGetPayload(50-50)
🪛 markdownlint-cli2 (0.18.1)
samples/nuxt/README.md
30-30: Bare URL used
(MD034, no-bare-urls)
⏰ 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: Agent
- GitHub Check: CodeQL analysis (javascript-typescript)
- GitHub Check: claude-review
|
Claude finished @ymc9's task —— View job Comprehensive Pull Request ReviewI've conducted a thorough review of this major refactoring that extracts client-helpers and updates to Svelte Query v6. Review Checklist:
🎯 Overall AssessmentThis is a well-executed major refactoring that successfully extracts shared client functionality into a dedicated ✅ Strengths1. Excellent Package Architecture
2. Comprehensive Test Coverage
3. Robust Error Handling
4. Framework Integration Excellence
🔧 Code Quality & Best PracticesExcellent Serialization Handling
Type Safety
Performance Optimizations
🔍 Security AssessmentNo Major Security Concerns Found
📈 Performance ConsiderationsWell Optimized
🚨 Issues Found1. Critical: Svelte Query Hooks Missing rootOptions MergeIn
This means these hooks won't inherit context settings like 2. Major: Stale Query Snapshot in Vue AdapterIn 3. Major: Svelte Query v6 Breaking ChangesThe bump from v5 to v6 in
🚀 Sample ApplicationsExcellent Examples
📝 Minor Suggestions1. Documentation EnhancementConsider adding JSDoc examples for complex functions like 2. Logging ConsistencyThe logging in 3. Database Path HandlingBoth sample apps use relative database paths that could fail in different working directories. Consider absolute path resolution. 🎉 ConclusionThis is an exceptional refactoring that demonstrates:
Recommendation: APPROVE - This PR successfully achieves its goals with high code quality, comprehensive testing, and excellent architectural decisions. The extraction of client helpers and Svelte Query v6 migration are both well-executed. The identified issues are primarily around missing options merging in the Svelte adapter and should be addressed before release, but they don't fundamentally compromise the excellent work done here. |
|
Claude finished @ymc9's task —— View job Comprehensive Pull Request ReviewI've conducted a thorough review of this major refactoring that extracts client-helpers and updates to Svelte Query v6. Review Checklist:
🎯 Overall AssessmentThis is a well-executed major refactoring that successfully extracts shared client functionality into a dedicated ✅ Strengths1. Excellent Package Architecture
2. Comprehensive Test Coverage
3. Robust Error Handling
4. Framework Integration Excellence
🔧 Code Quality & Best PracticesExcellent Serialization Handling
Type Safety
Performance Optimizations
🔍 Security AssessmentNo Major Security Concerns Found
📈 Performance ConsiderationsWell Optimized
🚨 Issues Found1. Critical: Svelte Query Hooks Missing rootOptions MergeIn
This means these hooks won't inherit context settings like 2. Major: Stale Query Snapshot in Vue AdapterIn 3. Major: Svelte Query v6 Breaking ChangesThe bump from v5 to v6 in
🚀 Sample ApplicationsExcellent Examples
📝 Minor Suggestions1. Documentation EnhancementConsider adding JSDoc examples for complex functions like 2. Logging ConsistencyThe logging in 3. Database Path HandlingBoth sample apps use relative database paths that could fail in different working directories. Consider absolute path resolution. 🎉 ConclusionThis is an exceptional refactoring that demonstrates:
Recommendation: APPROVE - This PR successfully achieves its goals with high code quality, comprehensive testing, and excellent architectural decisions. The extraction of client helpers and Svelte Query v6 migration are both well-executed. The identified issues are primarily around missing options merging in the Svelte adapter and should be addressed before release, but they don't fundamentally compromise the excellent work done here. |
|
Claude finished @ymc9's task —— View job Comprehensive Pull Request ReviewI've conducted a thorough review of this major refactoring that extracts client-helpers and updates to Svelte Query v6. Review Checklist:
🎯 Overall AssessmentThis is a well-executed major refactoring that successfully extracts shared client functionality into a dedicated ✅ Strengths1. Excellent Package Architecture
2. Comprehensive Test Coverage
3. Robust Error Handling
4. Framework Integration Excellence
🔧 Code Quality & Best PracticesExcellent Serialization Handling
Type Safety
Performance Optimizations
🔍 Security AssessmentNo Major Security Concerns Found
📈 Performance ConsiderationsWell Optimized
🚨 Issues Found1. Critical: Svelte Query Hooks Missing rootOptions MergeIn
This means these hooks won't inherit context settings like 2. Major: Stale Query Snapshot in Vue AdapterIn 3. Major: Svelte Query v6 Breaking ChangesThe bump from v5 to v6 in
🚀 Sample ApplicationsExcellent Examples
📝 Minor Suggestions1. Documentation EnhancementConsider adding JSDoc examples for complex functions like 2. Logging ConsistencyThe logging in 3. Database Path HandlingBoth sample apps use relative database paths that could fail in different working directories. Consider absolute path resolution. 🎉 ConclusionThis is an exceptional refactoring that demonstrates:
Recommendation: APPROVE - This PR successfully achieves its goals with high code quality, comprehensive testing, and excellent architectural decisions. The extraction of client helpers and Svelte Query v6 migration are both well-executed. The identified issues are primarily around missing options merging in the Svelte adapter and should be addressed before release, but they don't fundamentally compromise the excellent work done here. |
There was a problem hiding this 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/clients/tanstack-query/src/svelte/index.svelte.ts (2)
252-315: Critical: Incomplete rootOptions merging for infinite queries and mutations.The
useModelQueriesimplementation only mergesrootOptionsfor regular query hooks (lines 253, 257, 261) but not for infinite queries (line 265) or mutations (lines 269-301). This is inconsistent with the React implementation, where all hooks mergerootOptions.Impact: Users cannot configure
endpoint,fetch, orloggingfor infinite queries and mutations viarootOptions- these operations will only use context settings.🔎 Proposed fix
Update infinite query and mutation hooks to merge rootOptions:
useInfiniteFindMany: (args: any, options?: any) => { - return useInternalInfiniteQuery(schema, modelName, 'findMany', args, options); + return useInternalInfiniteQuery(schema, modelName, 'findMany', args, merge(rootOptions, options)); }, useCreate: (options?: any) => { - return useInternalMutation(schema, modelName, 'POST', 'create', options); + return useInternalMutation(schema, modelName, 'POST', 'create', merge(rootOptions, options)); },Apply the same pattern to all mutation hooks:
useCreateMany,useCreateManyAndReturn,useUpdate,useUpdateMany,useUpdateManyAndReturn,useUpsert,useDelete, anduseDeleteMany.
408-432: Critical: Mutations don't respect per-call options.Line 415 calls
useQuerySettings()instead ofuseFetchOptions(options), which means per-callendpoint,fetch, andloggingsettings fromrootOptionsor hook-level options are ignored. This is inconsistent with the React implementation and prevents users from configuring mutations viarootOptions.🔎 Proposed fix
Update line 415 to extract options from the Accessor and use
useFetchOptions:export function useInternalMutation<TArgs, R = any>( schema: SchemaDef, model: string, method: 'POST' | 'PUT' | 'DELETE', operation: string, options?: Accessor<Omit<CreateMutationOptions<R, DefaultError, TArgs>, 'mutationFn'> & ExtraMutationOptions>, ) { - const { endpoint, fetch, logging } = useQuerySettings(); + const { endpoint, fetch, logging } = useFetchOptions(() => options?.());Note: You may need to adjust the helper to handle the double Accessor wrapping, or pass
optionsdirectly ifuseFetchOptionsalready handles Accessors.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
packages/clients/tanstack-query/.gitignorepackages/clients/tanstack-query/src/react.tspackages/clients/tanstack-query/src/svelte/index.svelte.tssamples/nuxt/server/api/model/[...].ts
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/clients/tanstack-query/.gitignore
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Implement plugin hooks at ORM, Kysely, and entity mutation levels for query interception and customization
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.test.{ts,tsx} : ORM package tests should include comprehensive client API tests and policy tests
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Use Kysely as the query builder interface for low-level database queries, avoiding raw SQL when possible
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/cli/**/*.test.{ts,tsx} : CLI package tests should focus on action-specific tests for each command
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Implement plugin hooks at ORM, Kysely, and entity mutation levels for query interception and customization
Applied to files:
samples/nuxt/server/api/model/[...].tspackages/clients/tanstack-query/src/react.tspackages/clients/tanstack-query/src/svelte/index.svelte.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to **/*.zmodel : ZModel schema files should define database structure and policies that compile to TypeScript via `zenstack generate`
Applied to files:
samples/nuxt/server/api/model/[...].ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Use Kysely as the query builder interface for low-level database queries, avoiding raw SQL when possible
Applied to files:
samples/nuxt/server/api/model/[...].tspackages/clients/tanstack-query/src/react.tspackages/clients/tanstack-query/src/svelte/index.svelte.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.test.{ts,tsx} : ORM package tests should include comprehensive client API tests and policy tests
Applied to files:
samples/nuxt/server/api/model/[...].tspackages/clients/tanstack-query/src/react.ts
🧬 Code graph analysis (2)
samples/nuxt/server/api/model/[...].ts (1)
samples/nuxt/server/utils/db.ts (1)
db(6-10)
packages/clients/tanstack-query/src/svelte/index.svelte.ts (11)
packages/clients/tanstack-query/src/common/types.ts (3)
QueryContext(9-24)ExtraQueryOptions(29-34)WithOptimistic(78-78)packages/clients/client-helpers/src/constants.ts (1)
DEFAULT_QUERY_ENDPOINT(4-4)packages/clients/tanstack-query/src/vue.ts (2)
ModelQueryOptions(89-91)ModelQueryResult(93-93)packages/clients/tanstack-query/src/common/query-key.ts (2)
QueryKey(6-15)getQueryKey(25-35)packages/orm/src/client/crud-types.ts (1)
SimplifiedResult(220-227)packages/common-helpers/src/lower-case-first.ts (1)
lowerCaseFirst(1-3)packages/schema/src/schema.ts (2)
GetModels(121-121)SchemaDef(11-19)packages/clients/client-helpers/src/fetch.ts (1)
fetcher(15-37)packages/clients/client-helpers/src/invalidation.ts (2)
createInvalidator(26-44)InvalidationPredicate(9-9)packages/clients/tanstack-query/src/common/client.ts (2)
invalidateQueriesMatchingPredicate(5-15)getAllQueries(17-41)packages/clients/client-helpers/src/optimistic.ts (1)
createOptimisticUpdater(68-139)
⏰ 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). (1)
- GitHub Check: claude-review
🔇 Additional comments (17)
samples/nuxt/server/api/model/[...].ts (2)
1-4: LGTM! The missing import has been resolved.All necessary imports are present and correctly structured. The
dbimport on line 3 addresses the previous review comment about the missing database client import.
6-13: Well-structured handler setup with appropriate security documentation.The handler configuration correctly wires the RPC API handler with the database client. The comment on lines 8-9 appropriately warns about access policies for production use, which is good practice for sample code.
packages/clients/tanstack-query/src/react.ts (7)
22-62: LGTM! Clean modularization of client helpers.The refactoring correctly extracts fetch utilities, invalidation, and optimistic update logic into the
@zenstackhq/client-helperspackage. The re-export ofFetchFnprovides a clean public API for users to type custom fetch implementations.
258-277: LGTM! Centralized query configuration.The addition of the
optionsparameter allows users to configure endpoint, fetch, and logging settings for all model queries at once. This is a good ergonomic improvement.
286-393: LGTM! Consistent rootOptions merging across all hooks.The spread-based merging pattern
{ ...rootOptions, ...options }correctly gives precedence to per-call options while maintaining centralized defaults. This is applied consistently across all query and mutation hooks.
395-439: LGTM! Clean query implementation with centralized fetch configuration.Both
useInternalQueryanduseInternalSuspenseQuerycorrectly useuseFetchOptionsto resolve endpoint and fetch settings, with proper precedence given to per-call options.
441-493: LGTM! Infinite query hooks follow the same pattern.The infinite query implementations correctly integrate
QueryContextand useuseFetchOptionsfor configuration resolution, maintaining consistency with the regular query hooks.
506-593: LGTM! Robust mutation lifecycle with optimistic updates and invalidation.The mutation implementation correctly handles both optimistic and non-optimistic update paths:
- Non-optimistic path: Invalidates queries on success, preserving user's
onSuccesscallback- Optimistic path: Applies optimistic updates in
onMutate, then invalidates inonSettledto sync with server stateThe callback wrapping logic properly:
- Executes internal logic (invalidation/optimistic updates) before user callbacks
- Preserves return values (e.g., context from
onMutatefor rollback)- Uses optional chaining to handle undefined user callbacks
- Properly awaits all async operations
595-603: LGTM! Clean helper for option resolution.The
useFetchOptionshelper correctly merges context-provided defaults with per-call options, giving proper precedence to the latter. This centralized logic ensures consistent configuration resolution across all hooks.packages/clients/tanstack-query/src/svelte/index.svelte.ts (8)
18-63: LGTM! Consistent imports with React implementation.The Svelte integration uses the same client helpers as the React version, with the addition of Svelte-specific
Accessortype for reactivity. This maintains consistency across framework integrations.
86-89: LGTM! Proper Svelte context usage.The
useQuerySettingsfunction correctly uses Svelte'sgetContextAPI to retrieve query settings with appropriate fallbacks.
137-204: LGTM! Consistent Accessor-based API for Svelte reactivity.All hook signatures correctly use
Accessorwrappers for parameters, enabling Svelte's fine-grained reactivity. The pattern is consistently applied across query and mutation hooks.
243-249: LGTM! Smart merge helper preserving Svelte reactivity.The
mergehelper elegantly handles both function and value inputs, returning anAccessorthat reactively computes the merged options. The spread operator correctly gives precedence to per-call options.
318-348: LGTM! Proper Svelte-specific implementation with derived state.The
useInternalQuerycorrectly uses Svelte's$derivedfor reactive query key computation and returns a proxied result with thequeryKeyattached. ThefinalOptionsfunction pattern aligns with Svelte Query's API.
383-395: LGTM! Clean Proxy pattern for adding queryKey.The
createQueryResulthelper elegantly uses a Proxy to add thequeryKeyproperty while preserving Svelte reactivity through getter forwarding. This pattern is appropriate for the use case.
432-509: LGTM! Correct mutation lifecycle implementation.The lifecycle callback wrapping correctly implements both optimistic and non-optimistic update paths, matching the React implementation:
- Non-optimistic: Invalidates queries on success
- Optimistic: Applies updates in
onMutate, invalidates inonSettledAll callbacks properly await internal logic before user callbacks and preserve return values.
513-522: LGTM! Proper Accessor handling in option resolution.The
useFetchOptionshelper correctly unwraps theAccessorand merges options with context settings, maintaining consistency with the React implementation.
|
Claude finished @ymc9's task —— View job Comprehensive Pull Request ReviewI've conducted a thorough review of this major refactoring that extracts client-helpers and updates to Svelte Query v6. Review Checklist:
🎯 Overall AssessmentThis is a well-executed major refactoring that successfully extracts shared client functionality into a dedicated ✅ Strengths1. Excellent Package Architecture
2. Comprehensive Test Coverage
3. Robust Error Handling
4. Framework Integration Excellence
🔧 Code Quality & Best PracticesExcellent Serialization Handling
Type Safety
Performance Optimizations
🔍 Security AssessmentNo Major Security Concerns Found
📈 Performance ConsiderationsWell Optimized
🚨 Issues Found1. Critical: Svelte Query Hooks Missing rootOptions MergeIn
This means these hooks won't inherit context settings like 2. Major: Stale Query Snapshot in Vue AdapterIn 3. Major: Svelte Query v6 Breaking ChangesThe bump from v5 to v6 in
🚀 Sample ApplicationsExcellent Examples
📝 Minor Suggestions1. Documentation EnhancementConsider adding JSDoc examples for complex functions like 2. Logging ConsistencyThe logging in 3. Database Path HandlingBoth sample apps use relative database paths that could fail in different working directories. Consider absolute path resolution. 🎉 ConclusionThis is an exceptional refactoring that demonstrates:
Recommendation: APPROVE - This PR successfully achieves its goals with high code quality, comprehensive testing, and excellent architectural decisions. The extraction of client helpers and Svelte Query v6 migration are both well-executed. The identified issues are primarily around missing options merging in the Svelte adapter and should be addressed before release, but they don't fundamentally compromise the excellent work done here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/clients/tanstack-query/src/svelte/index.svelte.ts (1)
409-432: Inconsistent options handling in mutations.Line 416 uses
useQuerySettings()instead ofuseFetchOptions(options), which means mutations ignore per-callendpoint,fetch, andloggingsettings from theoptionsparameter. This is inconsistent withuseInternalQuery(line 325) anduseInternalInfiniteQuery(line 363), which both useuseFetchOptions.🔎 Proposed fix
export function useInternalMutation<TArgs, R = any>( schema: SchemaDef, model: string, method: 'POST' | 'PUT' | 'DELETE', operation: string, options?: Accessor<Omit<CreateMutationOptions<R, DefaultError, TArgs>, 'mutationFn'> & ExtraMutationOptions>, ) { - const { endpoint, fetch, logging } = useQuerySettings(); + const { endpoint, fetch, logging } = useFetchOptions(options); const queryClient = useQueryClient(); const mutationFn = (data: any) => {
♻️ Duplicate comments (4)
packages/clients/tanstack-query/package.json (1)
77-78: Breaking change: @tanstack/svelte-query v6 requires consumer migration.This issue was previously identified. The upgrade to v6 introduces breaking changes that require Svelte 5.25+ and code changes in consumer applications.
packages/clients/tanstack-query/src/svelte/index.svelte.ts (3)
450-450: Type assertion needed for QueryClient compatibility.This
@ts-ignoresuppression was previously flagged and requires resolution via explicit type casting or dependency alignment.
468-470: Type assertion needed for QueryClient compatibility.This
@ts-ignoresuppression was previously flagged and requires resolution via explicit type casting or dependency alignment.
490-492: Type assertion needed for QueryClient compatibility.This
@ts-ignoresuppression was previously flagged and requires resolution via explicit type casting or dependency alignment.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
.github/workflows/build-test.yml.github/workflows/bump-version.yml.github/workflows/publish-release.yml.github/workflows/update-samples.ymlpackage.jsonpackages/clients/tanstack-query/package.jsonpackages/clients/tanstack-query/src/svelte/index.svelte.tspackages/config/vitest-config/base.config.js
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Implement plugin hooks at ORM, Kysely, and entity mutation levels for query interception and customization
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Use Kysely as the query builder interface for low-level database queries, avoiding raw SQL when possible
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.test.{ts,tsx} : ORM package tests should include comprehensive client API tests and policy tests
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to tests/**/type*.{ts,tsx} : Ensure TypeScript inference and type coverage are validated through type coverage tests
Applied to files:
packages/config/vitest-config/base.config.jspackage.json
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Use `pnpm` with workspaces for package management, pinned to version `pnpm10.12.1`
Applied to files:
.github/workflows/bump-version.ymlpackage.json
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Use Kysely as the query builder interface for low-level database queries, avoiding raw SQL when possible
Applied to files:
packages/clients/tanstack-query/src/svelte/index.svelte.tspackages/clients/tanstack-query/package.json
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/orm/**/*.{ts,tsx} : Implement plugin hooks at ORM, Kysely, and entity mutation levels for query interception and customization
Applied to files:
packages/clients/tanstack-query/src/svelte/index.svelte.ts
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Use Turbo for build orchestration and run `pnpm build`, `pnpm watch`, `pnpm lint`, and `pnpm test` for development tasks
Applied to files:
packages/clients/tanstack-query/package.jsonpackage.json
📚 Learning: 2025-11-26T01:55:04.540Z
Learnt from: CR
Repo: zenstackhq/zenstack-v3 PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-26T01:55:04.540Z
Learning: Applies to packages/zenstackhq/cli/**/*.test.{ts,tsx} : CLI package tests should focus on action-specific tests for each command
Applied to files:
packages/clients/tanstack-query/package.json
🧬 Code graph analysis (1)
packages/clients/tanstack-query/src/svelte/index.svelte.ts (9)
packages/clients/tanstack-query/src/common/types.ts (4)
QueryContext(9-24)ExtraQueryOptions(29-34)WithOptimistic(78-78)ExtraMutationOptions(39-54)packages/clients/client-helpers/src/constants.ts (1)
DEFAULT_QUERY_ENDPOINT(4-4)packages/clients/tanstack-query/src/common/query-key.ts (1)
QueryKey(6-15)packages/orm/src/client/crud-types.ts (1)
SimplifiedResult(220-227)packages/schema/src/schema.ts (2)
GetModels(121-121)SchemaDef(11-19)packages/clients/client-helpers/src/fetch.ts (2)
makeUrl(42-54)fetcher(15-37)packages/clients/client-helpers/src/invalidation.ts (2)
createInvalidator(26-44)InvalidationPredicate(9-9)packages/clients/tanstack-query/src/common/client.ts (2)
invalidateQueriesMatchingPredicate(5-15)getAllQueries(17-41)packages/clients/client-helpers/src/optimistic.ts (1)
createOptimisticUpdater(68-139)
⏰ 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 (22.x, postgresql)
- GitHub Check: build-test (22.x, sqlite)
🔇 Additional comments (21)
.github/workflows/bump-version.yml (1)
29-29: LGTM!The Node.js version update is consistent with other workflow changes in this PR.
.github/workflows/update-samples.yml (1)
68-68: LGTM!The Node.js version update aligns with the repository-wide migration to Node.js 22.x.
.github/workflows/publish-release.yml (1)
31-31: LGTM!The Node.js version update is consistent with other CI workflows in this PR. The release process should benefit from the latest Node.js runtime.
.github/workflows/build-test.yml (1)
36-36: Node.js 22.x update is compatible with project tooling.Verification confirms pnpm 10.12.1 fully supports Node.js 22, meeting the project's runtime requirements. No engine constraints in package.json conflict with this change.
packages/config/vitest-config/base.config.js (1)
11-13: LGTM! Coverage configuration added.The V8 coverage provider is correctly configured and aligns with the new
test:coveragescript added to the root package.json.package.json (4)
15-15: LGTM! Test coverage script added.The script correctly invokes Vitest with coverage reporting, utilizing the V8 provider configured in the base Vitest config.
30-30: LGTM! Coverage tooling dependency added.The
@vitest/coverage-v8package is the required peer dependency for the V8 coverage provider.
33-33: LGTM! Build orchestration utility added.The
npm-run-allpackage enables parallel script execution (e.g.,run-p watch:*in tanstack-query package).
46-49: LGTM! Built dependencies expanded appropriately.The additions (
@parcel/watcher,esbuild,vue-demi) are commonly problematic native or environment-specific modules that benefit from controlled builds.packages/clients/tanstack-query/package.json (3)
7-12: LGTM! Build orchestration updated for multi-framework output.The split into
build:generalandbuild:sveltewith parallel watch scripts correctly handles framework-specific build requirements. The@sveltejs/packagetool is appropriate for Svelte component library packaging.
28-30: LGTM! Files field restricts published artifacts.Limiting publication to the
distdirectory prevents accidental inclusion of source files and build artifacts.
32-46: LGTM! Exports restructured for framework-specific entry points.The modular export structure correctly separates React, Vue, and Svelte adapters with appropriate TypeScript declarations and conditional exports for Svelte's dual nature (types vs. runtime).
packages/clients/tanstack-query/src/svelte/index.svelte.ts (9)
1-63: LGTM! Imports updated for client-helpers extraction.The import restructuring correctly references the new
@zenstackhq/client-helperspackage and adds Svelte 5'sAccessortype for reactive primitives.
75-89: LGTM! Context functions updated to QueryContext.The context setup correctly uses the new
QueryContexttype and provides appropriate defaults, aligning with the centralized context resolution pattern.
91-122: LGTM! Type definitions updated for enhanced API surface.The addition of
queryKeyto result types provides consumers with cache key visibility for debugging and manual cache operations. Types correctly incorporateQueryContextandAccessorpatterns.
137-226: LGTM! Hook signatures updated for Svelte 5 reactivity.The
Accessorpattern throughout hook signatures correctly enables reactive tracking of arguments and options, aligning with Svelte 5's runes-based reactivity model.
243-249: LGTM! Option merging correctly implemented.The
mergefunction properly handles both function-based and static accessors, with per-call options taking precedence over root options as expected.
318-348: LGTM! Query implementation correctly uses option resolution.The
useInternalQueryfunction properly:
- Uses
useFetchOptionsto merge context and per-call options- Employs
$derivedfor reactive query key computation- Wraps options in a function for Svelte 5's reactive tracking
- Attaches
queryKeyto results via the Proxy-based helper
350-382: LGTM! Infinite query correctly handles per-call options.The previously flagged issue (using
useQuerySettingsinstead ofuseFetchOptions) has been resolved. Line 363 correctly usesuseFetchOptions(options)to respect per-call endpoint, fetch, and logging settings.
384-396: Proxy approach works but warrants verification.The Proxy-based solution correctly preserves Svelte Query's reactive getters while adding
queryKey. However, the developer comment suggests uncertainty about this approach. While functionally correct, Proxies have performance overhead in hot paths.Consider verifying whether Svelte 5's
$derivedor a simpler object spread with explicit getters would suffice:function createQueryResult<T>(query: T, queryKey: QueryKey): T & { queryKey: QueryKey } { return { ...query, get queryKey() { return queryKey; } }; }If the Proxy is necessary to preserve internal reactivity, document why simpler approaches don't work.
514-523: LGTM! Option merging helper correctly prioritizes per-call options.The
useFetchOptionshelper properly unwraps accessors and applies the correct precedence (per-call options override context settings).
|
Claude finished @ymc9's task —— View job Comprehensive Pull Request ReviewI've conducted a thorough review of this major refactoring that extracts client-helpers and updates to Svelte Query v6. Review Checklist:
🎯 Overall AssessmentThis is a well-executed major refactoring that successfully extracts shared client functionality into a dedicated ✅ Strengths1. Excellent Package Architecture
2. Comprehensive Test Coverage
3. Robust Error Handling
4. Framework Integration Excellence
🔧 Code Quality & Best PracticesExcellent Serialization Handling
Type Safety
Performance Optimizations
🔍 Security AssessmentNo Major Security Concerns Found
📈 Performance ConsiderationsWell Optimized
🚨 Issues Found1. Critical: Svelte Query Hooks Missing rootOptions MergeIn
This means these hooks won't inherit context settings like 2. Major: Stale Query Snapshot in Vue AdapterIn 3. Major: Svelte Query v6 Breaking ChangesThe bump from v5 to v6 in
🚀 Sample ApplicationsExcellent Examples
📝 Minor Suggestions1. Documentation EnhancementConsider adding JSDoc examples for complex functions like 2. Logging ConsistencyThe logging in 3. Database Path HandlingBoth sample apps use relative database paths that could fail in different working directories. Consider absolute path resolution. 🎉 ConclusionThis is an exceptional refactoring that demonstrates:
Recommendation: APPROVE - This PR successfully achieves its goals with high code quality, comprehensive testing, and excellent architectural decisions. The extraction of client helpers and Svelte Query v6 migration are both well-executed. The identified issues are primarily around missing options merging in the Svelte adapter and should be addressed before release, but they don't fundamentally compromise the excellent work done here. |
|
fixes #527 |
|
Claude finished @ymc9's task —— View job Comprehensive Pull Request ReviewI've conducted a thorough review of this major refactoring that extracts client-helpers and updates to Svelte Query v6. Review Checklist:
🎯 Overall AssessmentThis is a well-executed major refactoring that successfully extracts shared client functionality into a dedicated ✅ Strengths1. Excellent Package Architecture
2. Comprehensive Test Coverage
3. Robust Error Handling
4. Framework Integration Excellence
🔧 Code Quality & Best PracticesExcellent Serialization Handling
Type Safety
Performance Optimizations
🔍 Security AssessmentNo Major Security Concerns Found
📈 Performance ConsiderationsWell Optimized
🚨 Issues Found1. Critical: Svelte Query Hooks Missing rootOptions MergeIn
This means these hooks won't inherit context settings like 2. Major: Stale Query Snapshot in Vue AdapterIn 3. Major: Svelte Query v6 Breaking ChangesThe bump from v5 to v6 in
🚀 Sample ApplicationsExcellent Examples
📝 Minor Suggestions1. Documentation EnhancementConsider adding JSDoc examples for complex functions like 2. Logging ConsistencyThe logging in 3. Database Path HandlingBoth sample apps use relative database paths that could fail in different working directories. Consider absolute path resolution. 🎉 ConclusionThis is an exceptional refactoring that demonstrates:
Recommendation: APPROVE - This PR successfully achieves its goals with high code quality, comprehensive testing, and excellent architectural decisions. The extraction of client helpers and Svelte Query v6 migration are both well-executed. The identified issues are primarily around missing options merging in the Svelte adapter and should be addressed before release, but they don't fundamentally compromise the excellent work done here. |
|
Claude finished @ymc9's task —— View job Comprehensive Pull Request ReviewI'll conduct a thorough review of this major refactoring that extracts client-helpers and updates to Svelte Query v6. Review Checklist:
🎯 Overall AssessmentThis is a well-executed major refactoring that successfully extracts shared client functionality into a dedicated ✅ Strengths1. Excellent Package Architecture
2. Comprehensive Test Coverage
3. Robust Error Handling
4. Framework Integration Excellence
🔧 Code Quality & Best PracticesExcellent Serialization Handling
Type Safety
Performance Optimizations
🔍 Security AssessmentNo Major Security Concerns Found
📈 Performance ConsiderationsWell Optimized
🚨 Issues Found1. Critical: Svelte Query Hooks Missing rootOptions MergeIn
This means these hooks won't inherit context settings like 2. Major: Stale Query Snapshot in Vue AdapterIn 3. Major: Svelte Query v6 Breaking ChangesThe bump from v5 to v6 in
🚀 Sample ApplicationsExcellent Examples
📝 Minor Suggestions1. Documentation EnhancementConsider adding JSDoc examples for complex functions like 2. Logging ConsistencyThe logging in 3. Database Path HandlingBoth sample apps use relative database paths that could fail in different working directories. Consider absolute path resolution. 🎉 ConclusionThis is an exceptional refactoring that demonstrates:
Recommendation: APPROVE - This PR successfully achieves its goals with high code quality, comprehensive testing, and excellent architectural decisions. The extraction of client helpers and Svelte Query v6 migration are both well-executed. The identified issues are primarily around missing options merging in the Svelte adapter and should be addressed before release, but they don't fundamentally compromise the excellent work done here. |

Summary by CodeRabbit
New Features
Improvements
Documentation
Chores
Tests
✏️ Tip: You can customize this high-level summary in your review settings.