-
-
Couldn't load subscription status.
- Fork 126
merge dev to main (v2.20.0) #2271
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
Co-authored-by: = <=>
📝 WalkthroughPre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
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: 6
🧹 Nitpick comments (8)
packages/plugins/trpc/tests/trpc.test.ts (1)
60-411: Clarify tRPC version support and documentation
- The plugin’s package.json doesn’t pin any
@trpc/*versions (peerDependencies only includeszod), and dedicated test projects cover both v10 and v11 RC releases.- Main
trpc.test.tsuses v10, while separate fixtures validate v11 compatibility.- Ensure the README (or docs) explicitly states support for both tRPC v10 and v11 and outlines any migration steps.
packages/schema/src/plugins/enhancer/enhance/index.ts (1)
132-145: Good improvement: Conditional json-types export.The change to only export json-types when TypeDefs exist is a good optimization that reduces the public API surface and avoids generating unnecessary exports.
Minor suggestion: Consider extracting the TypeDef check into a helper method for reusability:
private hasTypeDefinitions(): boolean { return this.model.declarations.some(isTypeDef); }Then use it consistently:
const modelsTsContent = [`export * from '${resultPrismaBaseImport}/models';`]; if (this.hasTypeDefinitions()) { modelsTsContent.push(`export * from './json-types';`); }.devcontainer/.env (1)
1-11: Tidy .env (ordering/newline) and avoid committing real creds
- Fix dotenv-linter warnings (order keys, add trailing newline).
- Keep these credentials strictly dev-only; consider .env.example or local overrides to avoid committing actual secrets.
Apply this reordering and add a blank line at EOF:
-POSTGRES_USER=postgres -POSTGRES_PASSWORD=abc123 -POSTGRES_DB=postgres -POSTGRES_HOST=postgres -POSTGRES_PORT=5432 - -ZENSTACK_TEST_DB_USER=postgres -ZENSTACK_TEST_DB_PASS=abc123 -ZENSTACK_TEST_DB_NAME=postgres -ZENSTACK_TEST_DB_HOST=postgres -ZENSTACK_TEST_DB_PORT=5432 +POSTGRES_DB=postgres +POSTGRES_HOST=postgres +POSTGRES_PASSWORD=abc123 +POSTGRES_PORT=5432 +POSTGRES_USER=postgres + +ZENSTACK_TEST_DB_HOST=postgres +ZENSTACK_TEST_DB_NAME=postgres +ZENSTACK_TEST_DB_PASS=abc123 +ZENSTACK_TEST_DB_PORT=5432 +ZENSTACK_TEST_DB_USER=postgres +tests/integration/tests/cli/generate.test.ts (1)
48-49: Install @types/node as a devDependency for consistencyMove @types/node@20 to dev deps (like plugins.test.ts), keeping runtime deps clean.
Apply:
- installPackage('prisma @prisma/client zod@^3.25.0 @types/node@20'); + installPackage('prisma @prisma/client zod@^3.25.0'); + installPackage('@types/node@20', true);packages/server/tests/adapter/hono.test.ts (1)
85-87: Prefer conditional skip to retain local coverageGate the skip to CI and link a tracking issue so this doesn’t become permanent.
Apply:
-// TODO: investigate failure in CI -// eslint-disable-next-line jest/no-disabled-tests -it.skip('custom load path', async () => { +// TODO(issues/xxxx): investigate failure in CI +const maybeIt = process.env.CI ? it.skip : it; +maybeIt('custom load path', async () => {packages/server/tests/adapter/sveltekit.test.ts (1)
84-86: Conditionally skip in CI and track with an issueKeep the test running locally; skip only on CI.
Apply:
-// TODO: investigate failure in CI -// eslint-disable-next-line jest/no-disabled-tests -it.skip('custom load path', async () => { +// TODO(issues/xxxx): investigate failure in CI +const maybeIt = process.env.CI ? it.skip : it; +maybeIt('custom load path', async () => {packages/server/src/tanstack-start/index.ts (1)
18-22: API surface looks solidHandler delegation and options shape are clear and consistent. Consider also exporting a type alias for the handler for consumer ergonomics (optional).
Example:
export type TanStackStartFetchHandler = ReturnType<typeof Handler>;packages/server/src/tanstack-start/handler.ts (1)
24-29: Consider extracting a response helper to reduce duplication.The JSON response creation pattern is repeated four times with identical structure. Extract a helper function to improve maintainability.
Add a helper function at the top of the file:
function createJsonResponse(body: unknown, status: number): Response { return new Response(JSON.stringify(body), { status, headers: { 'Content-Type': 'application/json', }, }); }Then refactor the response creation calls:
if (!prisma) { - return new Response(JSON.stringify({ message: 'unable to get prisma from request context' }), { - status: 500, - headers: { - 'Content-Type': 'application/json', - }, - }); + return createJsonResponse({ message: 'unable to get prisma from request context' }, 500); }Apply similar changes to the other three response creation sites (lines 39-44, 67-72, 74-79).
Also applies to: 39-44, 67-72, 74-79
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (56)
.devcontainer/devcontainer.jsonis excluded by!**/*.json.devcontainer/docker-compose.ymlis excluded by!**/*.ymlpackage.jsonis excluded by!**/*.jsonpackages/ide/jetbrains/package.jsonis excluded by!**/*.jsonpackages/language/package.jsonis excluded by!**/*.jsonpackages/misc/redwood/package.jsonis excluded by!**/*.jsonpackages/plugins/openapi/package.jsonis excluded by!**/*.jsonpackages/plugins/swr/package.jsonis excluded by!**/*.jsonpackages/plugins/tanstack-query/package.jsonis excluded by!**/*.jsonpackages/plugins/trpc/package.jsonis excluded by!**/*.jsonpackages/plugins/trpc/tests/projects/nuxt-trpc-v10/package.jsonis excluded by!**/*.jsonpackages/plugins/trpc/tests/projects/nuxt-trpc-v10/server/trpc/routers/generated/client/Post.nuxt.type.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/nuxt-trpc-v10/server/trpc/routers/generated/client/User.nuxt.type.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/nuxt-trpc-v10/server/trpc/routers/generated/client/nuxt.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/nuxt-trpc-v10/server/trpc/routers/generated/client/utils.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/nuxt-trpc-v10/server/trpc/routers/generated/helper.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/nuxt-trpc-v10/server/trpc/routers/generated/routers/Post.router.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/nuxt-trpc-v10/server/trpc/routers/generated/routers/User.router.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/nuxt-trpc-v10/server/trpc/routers/generated/routers/index.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/nuxt-trpc-v11/package.jsonis excluded by!**/*.jsonpackages/plugins/trpc/tests/projects/nuxt-trpc-v11/server/trpc/routers/generated/client/Post.nuxt.type.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/nuxt-trpc-v11/server/trpc/routers/generated/client/User.nuxt.type.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/nuxt-trpc-v11/server/trpc/routers/generated/client/nuxt.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/nuxt-trpc-v11/server/trpc/routers/generated/client/utils.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/nuxt-trpc-v11/server/trpc/routers/generated/helper.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/nuxt-trpc-v11/server/trpc/routers/generated/routers/Post.router.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/nuxt-trpc-v11/server/trpc/routers/generated/routers/User.router.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/nuxt-trpc-v11/server/trpc/routers/generated/routers/index.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/client/Post.next.type.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/client/User.next.type.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/client/next.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/client/utils.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/helper.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/routers/Post.router.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/routers/User.router.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/routers/index.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/t3-trpc-v11/package-lock.jsonis excluded by!**/package-lock.json,!**/*.jsonpackages/plugins/trpc/tests/projects/t3-trpc-v11/package.jsonis excluded by!**/*.jsonpackages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/routers/generated/client/Post.react.type.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/routers/generated/client/User.react.type.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/routers/generated/client/react.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/routers/generated/client/utils.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/routers/generated/helper.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/routers/generated/routers/Post.router.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/routers/generated/routers/User.router.tsis excluded by!**/generated/**,!**/generated/**packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/routers/generated/routers/index.tsis excluded by!**/generated/**,!**/generated/**packages/runtime/package.jsonis excluded by!**/*.jsonpackages/schema/package.jsonis excluded by!**/*.jsonpackages/schema/tsconfig.vscode.jsonis excluded by!**/*.jsonpackages/sdk/package.jsonis excluded by!**/*.jsonpackages/server/package.jsonis excluded by!**/*.jsonpackages/testtools/package.jsonis excluded by!**/*.jsonpnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!**/*.yamltests/integration/test-run/package.jsonis excluded by!**/*.jsontests/integration/tests/frameworks/nextjs/test-project/package.jsonis excluded by!**/*.jsontests/integration/tests/frameworks/trpc/test-project/package.jsonis excluded by!**/*.json
📒 Files selected for processing (22)
.devcontainer/.env(1 hunks).gitignore(1 hunks)packages/ide/jetbrains/CHANGELOG.md(1 hunks)packages/ide/jetbrains/build.gradle.kts(2 hunks)packages/plugins/tanstack-query/src/generator.ts(1 hunks)packages/plugins/tanstack-query/tests/plugin.test.ts(2 hunks)packages/plugins/trpc/tests/trpc.test.ts(10 hunks)packages/schema/src/plugins/enhancer/enhance/index.ts(3 hunks)packages/schema/src/plugins/enhancer/index.ts(2 hunks)packages/schema/src/plugins/zod/utils/schema-gen.ts(2 hunks)packages/schema/src/vscode/vscode-telemetry.ts(1 hunks)packages/sdk/src/code-gen.ts(1 hunks)packages/sdk/src/typescript-expression-transformer.ts(2 hunks)packages/sdk/src/utils.ts(1 hunks)packages/server/src/tanstack-start/handler.ts(1 hunks)packages/server/src/tanstack-start/index.ts(1 hunks)packages/server/tests/adapter/hono.test.ts(1 hunks)packages/server/tests/adapter/sveltekit.test.ts(1 hunks)packages/server/tests/adapter/tanstack-start.test.ts(1 hunks)tests/integration/tests/cli/generate.test.ts(1 hunks)tests/integration/tests/cli/plugins.test.ts(2 hunks)tests/integration/tests/enhancements/with-delegate/plugin-interaction.test.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (9)
packages/server/src/tanstack-start/handler.ts (4)
packages/server/src/tanstack-start/index.ts (1)
TanStackStartOptions(7-12)packages/server/src/types.ts (1)
Response(19-22)packages/server/src/shared.ts (1)
loadAssets(5-21)packages/runtime/src/types.ts (1)
DbClientContract(91-93)
packages/server/src/tanstack-start/index.ts (1)
packages/server/src/types.ts (1)
AdapterBaseOptions(32-56)
packages/sdk/src/utils.ts (1)
packages/language/src/generated/ast.ts (14)
DataModel(277-287)DataModel(289-289)TypeDef(639-646)TypeDef(648-648)DataModelField(308-315)DataModelField(317-317)TypeDefField(654-661)TypeDefField(663-663)Enum(365-372)Enum(374-374)FunctionDecl(407-415)FunctionDecl(417-417)Attribute(141-148)Attribute(150-150)
packages/schema/src/plugins/enhancer/index.ts (1)
packages/sdk/src/utils.ts (1)
getPrismaClientGenerator(709-732)
packages/server/tests/adapter/tanstack-start.test.ts (4)
packages/plugins/tanstack-query/src/runtime/common.ts (1)
unmarshal(222-230)packages/server/src/types.ts (1)
Response(19-22)packages/server/src/tanstack-start/index.ts (2)
TanStackStartOptions(7-12)TanStackStartHandler(18-20)packages/testtools/src/schema.ts (1)
loadSchema(172-248)
packages/schema/src/plugins/enhancer/enhance/index.ts (2)
packages/language/src/generated/ast.ts (1)
isTypeDef(650-652)packages/sdk/src/code-gen.ts (1)
saveSourceFile(25-37)
tests/integration/tests/cli/generate.test.ts (1)
packages/testtools/src/schema.ts (1)
installPackage(68-70)
packages/sdk/src/typescript-expression-transformer.ts (1)
packages/language/src/generated/ast.ts (2)
isLiteralExpr(69-71)isInvocationExpr(486-488)
packages/schema/src/plugins/zod/utils/schema-gen.ts (1)
packages/sdk/src/utils.ts (1)
hasAttribute(134-148)
🪛 dotenv-linter (3.3.0)
.devcontainer/.env
[warning] 2-2: [UnorderedKey] The POSTGRES_PASSWORD key should go before the POSTGRES_USER key
(UnorderedKey)
[warning] 3-3: [UnorderedKey] The POSTGRES_DB key should go before the POSTGRES_PASSWORD key
(UnorderedKey)
[warning] 4-4: [UnorderedKey] The POSTGRES_HOST key should go before the POSTGRES_PASSWORD key
(UnorderedKey)
[warning] 5-5: [UnorderedKey] The POSTGRES_PORT key should go before the POSTGRES_USER key
(UnorderedKey)
[warning] 8-8: [UnorderedKey] The ZENSTACK_TEST_DB_PASS key should go before the ZENSTACK_TEST_DB_USER key
(UnorderedKey)
[warning] 9-9: [UnorderedKey] The ZENSTACK_TEST_DB_NAME key should go before the ZENSTACK_TEST_DB_PASS key
(UnorderedKey)
[warning] 10-10: [UnorderedKey] The ZENSTACK_TEST_DB_HOST key should go before the ZENSTACK_TEST_DB_NAME key
(UnorderedKey)
[warning] 11-11: [EndingBlankLine] No blank line at the end of the file
(EndingBlankLine)
[warning] 11-11: [UnorderedKey] The ZENSTACK_TEST_DB_PORT key should go before the ZENSTACK_TEST_DB_USER key
(UnorderedKey)
⏰ 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). (5)
- GitHub Check: OSSAR-Scan
- GitHub Check: build-test (20.x)
- GitHub Check: build-test (20.x)
- GitHub Check: dependency-review
- GitHub Check: build-test (20.x)
🔇 Additional comments (21)
.gitignore (1)
11-11: Good call on ignoring the pnpm storeKeeping
.pnpm-storeout of version control prevents committing large cache artifacts and keeps the repo clean.packages/schema/src/vscode/vscode-telemetry.ts (1)
70-70: LGTM! Token usage is now consistent.The change to use
VSCODE_TELEMETRY_TRACKING_TOKENaligns with the token used for mixpanel initialization at line 32, improving consistency across the class.packages/sdk/src/utils.ts (1)
134-148: LGTM! Signature expansion aligns withgetAttribute.The addition of
TypeDefFieldto the union type is consistent with thegetAttributefunction signature (lines 150-166) and enables broader applicability for schema generation logic that inspects field attributes.TypeDefFieldhas the sameattributesstructure asDataModelField, so the implementation remains correct.packages/schema/src/plugins/zod/utils/schema-gen.ts (2)
1-2: LGTM! Import consolidation and relocation.The imports have been restructured appropriately:
upperCaseFirstrelocated to@zenstackhq/runtime/local-helpershasAttributeconsolidated into the@zenstackhq/sdkimportThis aligns with the expanded
hasAttributesignature inpackages/sdk/src/utils.tsthat now supportsTypeDefField.
238-244: LGTM! Correct handling for JSON field defaults.The new logic correctly prevents double-stringification of JSON string defaults:
- JSON fields (
field.type.type === 'Json') or fields with the@jsonattribute already contain JSON strings- Returning
arg.value.valueas-is for these fields is correct- Non-JSON string fields continue to use
JSON.stringify(arg.value.value)as beforepackages/plugins/tanstack-query/src/generator.ts (1)
164-164: LGTM! Angular target correctly added to v5 infinite query handling.The extension of infinite query support to include Angular is appropriate and aligns with the v5-only Angular support constraint established earlier in the file (lines 44-47). This ensures that Angular infinite queries receive the required
getNextPageParamdefault option in TanStack Query v5.packages/plugins/tanstack-query/tests/plugin.test.ts (1)
306-312: LGTM! Test correctly reflects Angular Query API shape.The removal of
queryKeyfrom destructuring in the Angular tests accurately reflects the Angular Query experimental API, which uses Angular signals and has a different return shape compared to React/Vue/Svelte adapters. This change aligns with the generator updates that extend v5 infinite query support to Angular.packages/sdk/src/typescript-expression-transformer.ts (1)
19-19: LGTM: Import necessary for new functionality.The
isInvocationExprimport is correctly added and used in the new compile-time comparison optimization logic below.tests/integration/tests/enhancements/with-delegate/plugin-interaction.test.ts (1)
55-55: LGTM! Verify that version 10 is the intended target.The dependency pinning to tRPC v10 is clear and consistent. Since tRPC v11 is the current major release, please confirm that pinning to v10 is intentional—for example, if the plugin or generated code specifically targets v10 APIs, or if a v11 migration is planned for a future release.
packages/plugins/trpc/tests/trpc.test.ts (4)
60-60: LGTM! Consistent dependency pinning.The dependency specifications for
@trpc/client@10and@trpc/server@10are consistently applied across multiple test cases. The changes are mechanical and maintain test structure.Also applies to: 102-102, 132-132, 157-157, 187-187
235-237: LGTM! Appropriate transitive dependency.The inclusion of
@trpc/react-query@10alongside core tRPC packages is appropriate for this test case that generates React Query client helpers.
258-263: LGTM! Appropriate Next.js dependency.The inclusion of
@trpc/next@10is appropriate for testing Next.js client helper generation. The formatting across multiple lines improves readability.
293-293: LGTM! Comprehensive test coverage with pinned dependencies.The dependency pinning is consistently applied across diverse test scenarios (mixed casing, selective model generation, Zod plugin interaction), ensuring uniform version control.
Also applies to: 340-340, 411-411
packages/sdk/src/code-gen.ts (2)
25-37: Add static type-check for generated filesIntegration tests execute generators but don’t enforce TypeScript compilation after dropping
@ts-nocheck. Add atsc --noEmit(or equivalent) check against every generator’s output (e.g.packages/sdk/src/code-gen.tsand plugin generators) in CI or a dedicated test so no type errors go unnoticed.
19-19: Approve Node.js type definitions addition
Adding'node'to thetypesarray aligns with the removal of@ts-nocheckand introduces no new type errors—generated outputs contain no untyped Node.js globals.packages/schema/src/plugins/enhancer/enhance/index.ts (2)
602-608: Good improvement: Conditional json-types.ts file creation.Only creating the
json-types.tsfile when TypeDefs exist is a sensible optimization that avoids generating empty or unnecessary files. This aligns well with the conditional export inmodels.ts.
167-167: Confirm removal of edge target in new Prisma generator
The new generator only invokesgenerateEnhance(..., 'node'), whereas the old generator emits bothenhance.tsandenhance-edge.ts. This drops support for edge runtimes and may break deployments (Cloudflare Workers, Vercel Edge, etc.). Please confirm:
- Was edge runtime support intentionally removed?
- Are there technical limitations preventing edge support with the new generator?
- If intentional, has migration guidance been provided for existing edge-runtime users?
packages/schema/src/plugins/enhancer/index.ts (1)
39-40: Approve conditional Prisma client path fallback
Switching to'client'for new generators and retaining'models'for legacy mirrors the Prisma plugin’s preBuild output paths and preserves backward compatibility; no hardcoded downstream imports to the old structure were found.tests/integration/tests/cli/plugins.test.ts (1)
88-90: Dev dependency pins look goodUpgrading prisma to 6.17.x and pinning @types/node@20 under devDeps aligns with the rest of the test setup.
Confirm CI runs on Node >=18 so global fetch/Request are available without polyfills.
packages/server/tests/adapter/tanstack-start.test.ts (1)
8-16: Ensure Node runtime provides global fetch/RequestThis suite relies on Web Fetch globals. If CI uses Node <18, add a polyfill (e.g., isomorphic-fetch) or bump CI Node. Given other tests pin @types/node@20, prefer ensuring CI Node >=18.
If needed, minimally polyfill for tests:
+// Only needed if CI Node < 18 +import 'isomorphic-fetch';packages/server/src/tanstack-start/handler.ts (1)
35-45: No changes needed for_splat–_splatis the documented TanStack Start catch-all parameter, as confirmed by the handler implementation and adapter tests.
No description provided.