-
-
Notifications
You must be signed in to change notification settings - Fork 125
merge dev to main (v2.5.0) #1680
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
WalkthroughWalkthroughThe changes involve updates across various files in the project, focusing on enhancing error handling, improving type safety, and introducing new functionalities related to the tRPC framework. Key modifications include version upgrades, schema adjustments, and the addition of new utility functions for better plugin management and validation processes. These changes collectively refine the project's structure and functionality, ensuring compatibility with newer versions and improving overall code quality. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Client
participant Server
participant Database
User->>Client: Request to create a post
Client->>Server: Send create post request
Server->>Database: Insert new post
Database-->>Server: Confirm post creation
Server-->>Client: Return success response
Client-->>User: Display post creation success
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 1
Outside diff range, codebase verification and nitpick comments (7)
packages/schema/src/cli/actions/check.ts (1)
10-14: LGTM! Consider removing the unused_projectPathparameter.The code changes in the
checkfunction are approved. The function is well-structured and follows best practices.However, the
_projectPathparameter is not used in the function. Consider removing it to improve code quality.Apply this diff to remove the unused
_projectPathparameter:-export async function check(_projectPath: string, options: Options) { +export async function check(options: Options) { const schema = options.schema ?? getDefaultSchemaLocation(); await loadDocument(schema); console.log('The schema is valid.'); }packages/plugins/trpc/tests/projects/t3-trpc-v11/src/trpc/query-client.ts (1)
1-25: LGTM!The code changes are approved. The use of
SuperJSONfor serialization and deserialization is a good choice, and the customshouldDehydrateQueryoption is a nice addition.A few additional suggestions:
Consider adding a comment to explain the purpose of the
shouldDehydrateQueryoption and why pending queries are also dehydrated.The
staleTimeof 30 seconds is a reasonable default value, but it may need to be adjusted based on the specific use case. Consider adding a comment to explain the reasoning behind this value and how it can be adjusted if needed.packages/plugins/trpc/res/client/v11/next.ts (1)
1-2: Consider enabling ESLint and addressing specific rules if needed.Disabling ESLint for the entire file is generally not recommended as it can lead to potential issues and inconsistencies in the codebase.
Consider enabling ESLint and addressing any specific rules that need to be disabled using inline comments or by configuring the rules in the ESLint configuration file.
packages/plugins/trpc/tests/projects/t3-trpc-v11/src/env.js (1)
20-22: Consider adding client-side environment variables if needed.The
clientsection is currently empty, but it's good to have it in place for future additions. If your application requires any client-side environment variables, you can define them here using Zod schemas and prefix them withNEXT_PUBLIC_to expose them to the client.packages/plugins/trpc/tests/projects/t3-trpc-v11/src/app/page.tsx (1)
7-35: Consider adding accessibility attributes to the links.The
Linkcomponents used for external links should havearia-labelattributes to improve accessibility for users with assistive technologies. For example:-<Link className={styles.card} href="https://create.t3.gg/en/usage/first-steps" target="_blank"> +<Link className={styles.card} href="https://create.t3.gg/en/usage/first-steps" target="_blank" aria-label="First Steps">packages/runtime/src/types.ts (1)
26-26: Approve the addition of thestreammethod to theDbOperationsinterface.The addition of the
streammethod expands the functionality of theDbOperationsinterface, which is consistent with the AI-generated summary.A few suggestions:
- Consider adding documentation or comments to explain the purpose and usage of the
streammethod. This will help other developers understand how to use it correctly.- If possible, consider using a more specific return type instead of
Promise<any>. This will provide better type safety and make it easier to understand what the method returns. However, if the actual return type is not known or can vary, thenPromise<any>may be acceptable.tests/integration/tests/enhancements/with-policy/prisma-pulse.test.ts (1)
8-373: The test suite looks good overall. Great job!A few minor suggestions for improvement:
Consider extracting the common setup code (e.g., loading the schema, creating the Prisma client, etc.) into a separate function or a
beforeEachhook to avoid duplication across test cases.Consider adding more descriptive names for the
produceandconsumefunctions to better convey their purpose (e.g.,produceEventsandconsumeEvents).Consider adding comments to explain the purpose of each test case and the expected behavior to improve the readability and maintainability of the test suite.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (31)
package.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/openapi/tests/baseline/rpc-3.0.0.baseline.yamlis excluded by!**/*.yamlpackages/plugins/openapi/tests/baseline/rpc-3.1.0.baseline.yamlis excluded by!**/*.yamlpackages/plugins/openapi/tests/baseline/rpc-type-coverage-3.0.0.baseline.yamlis excluded by!**/*.yamlpackages/plugins/openapi/tests/baseline/rpc-type-coverage-3.1.0.baseline.yamlis excluded by!**/*.yamlpackages/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/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/public/favicon.icois excluded by!**/*.ico,!**/*.icopackages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/routers/generated/client/react.tsis excluded by!**/generated/**packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/routers/generated/client/utils.tsis excluded by!**/generated/**packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/routers/generated/helper.tsis excluded by!**/generated/**packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/routers/generated/routers/Post.router.tsis excluded by!**/generated/**packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/routers/generated/routers/User.router.tsis excluded by!**/generated/**packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/routers/generated/routers/index.tsis excluded by!**/generated/**packages/plugins/trpc/tests/projects/t3-trpc-v11/tsconfig.jsonis excluded by!**/*.jsonpackages/runtime/package.jsonis excluded by!**/*.jsonpackages/schema/package.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 (68)
- packages/ide/jetbrains/.idea/misc.xml (1 hunks)
- packages/ide/jetbrains/CHANGELOG.md (1 hunks)
- packages/ide/jetbrains/build.gradle.kts (1 hunks)
- packages/misc/redwood/src/graphql.ts (2 hunks)
- packages/plugins/openapi/src/rpc-generator.ts (1 hunks)
- packages/plugins/trpc/res/client/v11/next.ts (1 hunks)
- packages/plugins/trpc/res/client/v11/react.ts (1 hunks)
- packages/plugins/trpc/res/client/v11/utils.ts (1 hunks)
- packages/plugins/trpc/src/generator.ts (10 hunks)
- packages/plugins/trpc/src/helpers.ts (3 hunks)
- packages/plugins/trpc/tests/projects/t3-trpc-v11/.eslintrc.cjs (1 hunks)
- packages/plugins/trpc/tests/projects/t3-trpc-v11/.gitignore (1 hunks)
- packages/plugins/trpc/tests/projects/t3-trpc-v11/README.md (1 hunks)
- packages/plugins/trpc/tests/projects/t3-trpc-v11/next.config.js (1 hunks)
- packages/plugins/trpc/tests/projects/t3-trpc-v11/prisma/schema.prisma (1 hunks)
- packages/plugins/trpc/tests/projects/t3-trpc-v11/schema.zmodel (1 hunks)
- packages/plugins/trpc/tests/projects/t3-trpc-v11/src/app/_components/post.tsx (1 hunks)
- packages/plugins/trpc/tests/projects/t3-trpc-v11/src/app/api/trpc/[trpc]/route.ts (1 hunks)
- packages/plugins/trpc/tests/projects/t3-trpc-v11/src/app/index.module.css (1 hunks)
- packages/plugins/trpc/tests/projects/t3-trpc-v11/src/app/layout.tsx (1 hunks)
- packages/plugins/trpc/tests/projects/t3-trpc-v11/src/app/page.tsx (1 hunks)
- packages/plugins/trpc/tests/projects/t3-trpc-v11/src/env.js (1 hunks)
- packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/root.ts (1 hunks)
- packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/routers/generated-router-helper.ts (1 hunks)
- packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/trpc.ts (1 hunks)
- packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/db.ts (1 hunks)
- packages/plugins/trpc/tests/projects/t3-trpc-v11/src/styles/globals.css (1 hunks)
- packages/plugins/trpc/tests/projects/t3-trpc-v11/src/trpc/query-client.ts (1 hunks)
- packages/plugins/trpc/tests/projects/t3-trpc-v11/src/trpc/react.tsx (1 hunks)
- packages/plugins/trpc/tests/projects/t3-trpc-v11/src/trpc/server.ts (1 hunks)
- packages/plugins/trpc/tests/t3.test.ts (1 hunks)
- packages/runtime/src/browser/serialization.ts (1 hunks)
- packages/runtime/src/constants.ts (1 hunks)
- packages/runtime/src/enhancements/delegate.ts (2 hunks)
- packages/runtime/src/enhancements/omit.ts (1 hunks)
- packages/runtime/src/enhancements/policy/handler.ts (1 hunks)
- packages/runtime/src/enhancements/policy/policy-utils.ts (7 hunks)
- packages/runtime/src/enhancements/proxy.ts (4 hunks)
- packages/runtime/src/types.ts (1 hunks)
- packages/schema/src/cli/actions/check.ts (1 hunks)
- packages/schema/src/cli/actions/generate.ts (3 hunks)
- packages/schema/src/cli/actions/index.ts (1 hunks)
- packages/schema/src/cli/cli-util.ts (2 hunks)
- packages/schema/src/cli/index.ts (3 hunks)
- packages/schema/src/cli/plugin-runner.ts (7 hunks)
- packages/schema/src/plugins/enhancer/enhance/index.ts (3 hunks)
- packages/schema/src/plugins/enhancer/policy/expression-writer.ts (3 hunks)
- packages/schema/src/plugins/plugin-utils.ts (2 hunks)
- packages/schema/src/plugins/zod/utils/schema-gen.ts (4 hunks)
- packages/schema/src/res/stdlib.zmodel (1 hunks)
- packages/sdk/src/model-meta-generator.ts (1 hunks)
- packages/server/src/api/rest/index.ts (1 hunks)
- packages/server/src/api/rpc/index.ts (1 hunks)
- packages/testtools/src/schema.ts (5 hunks)
- script/test-scaffold.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/policy-interaction.test.ts (1 hunks)
- tests/integration/tests/enhancements/with-policy/create-many-and-return.test.ts (1 hunks)
- tests/integration/tests/enhancements/with-policy/post-update.test.ts (1 hunks)
- tests/integration/tests/enhancements/with-policy/prisma-pulse.test.ts (1 hunks)
- tests/integration/tests/plugins/zod.test.ts (5 hunks)
- tests/regression/tests/issue-1642.test.ts (1 hunks)
- tests/regression/tests/issue-1644.test.ts (1 hunks)
- tests/regression/tests/issue-1645.test.ts (1 hunks)
- tests/regression/tests/issue-1648.test.ts (1 hunks)
- tests/regression/tests/issue-1667.test.ts (1 hunks)
- tests/regression/tests/issue-1674.test.ts (1 hunks)
Files skipped from review due to trivial changes (10)
- packages/ide/jetbrains/build.gradle.kts
- packages/plugins/trpc/tests/projects/t3-trpc-v11/.gitignore
- packages/plugins/trpc/tests/projects/t3-trpc-v11/next.config.js
- packages/plugins/trpc/tests/projects/t3-trpc-v11/prisma/schema.prisma
- packages/plugins/trpc/tests/projects/t3-trpc-v11/src/app/index.module.css
- packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/routers/generated-router-helper.ts
- packages/plugins/trpc/tests/projects/t3-trpc-v11/src/styles/globals.css
- packages/runtime/src/constants.ts
- packages/schema/src/cli/actions/index.ts
- tests/integration/tests/cli/plugins.test.ts
Additional context used
Biome
packages/plugins/trpc/res/client/v11/utils.ts
[error] 5-5: Don't use 'Function' as a type.
Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.
(lint/complexity/noBannedTypes)
[error] 5-5: Don't use 'Symbol' as a type.
Use lowercase primitives for consistency.
Safe fix: Use 'symbol' instead(lint/complexity/noBannedTypes)
packages/plugins/trpc/tests/projects/t3-trpc-v11/src/trpc/react.tsx
[error] 20-20: The assignment should not be in an expression.
The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.(lint/suspicious/noAssignInExpressions)
packages/schema/src/cli/plugin-runner.ts
[error] 395-396: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
LanguageTool
packages/plugins/trpc/tests/projects/t3-trpc-v11/README.md
[uncategorized] ~9-~9: These words/punctuation marks might seem a little out of order. For clarity and coherence, try switching them around.
Context: ...se refer to the respective docs. If you still are in the wind, please join our [Discord](...(AI_EN_LECTOR_REPLACEMENT_WORD_ORDER)
[style] ~23-~23: Consider using a more formal and expressive alternative to ‘awesome’.
Context: ...-currently-available) — Check out these awesome tutorials You can check out the [creat...(AWESOME)
GitHub Check: CodeQL
packages/testtools/src/schema.ts
[warning] 237-237: Unsafe shell command constructed from library input
This string concatenation which depends on library input is later used in a shell command.
This string concatenation which depends on library input is later used in a shell command.
This string concatenation which depends on library input is later used in a shell command.
This string concatenation which depends on library input is later used in a shell command.
This string concatenation which depends on library input is later used in a shell command.
Additional comments not posted (133)
packages/ide/jetbrains/.idea/misc.xml (1)
7-7: LGTM!The change to upgrade the Java language level from JDK 20 to JDK 21 in the IDE configuration is approved.
This change suggests a shift towards utilizing features and enhancements introduced in JDK 21, potentially impacting the development environment and code compatibility. However, as this is a configuration change in the IDE settings, it is unlikely to cause any issues.
packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/db.ts (1)
1-17: LGTM!The code is following best practices by:
- Creating a single Prisma client instance and exporting it.
- Using
globalThisto ensure that only one instance is created.- Enabling logging based on the
NODE_ENV.- Using a custom
envmodule.The code changes are approved.
packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/root.ts (3)
1-2: LGTM!The import statements are correct and necessary for the file.
4-12: LGTM!The
appRouteris correctly created using thecreateRouterfunction and theAppRoutertype is correctly exported as the type ofappRouter.
14-21: LGTM!The
createCallerfunction is correctly created using thecreateCallerFactoryfunction and is correctly exported. The JSDoc comment provides a clear example of how to use thecreateCallerfunction.packages/plugins/trpc/tests/projects/t3-trpc-v11/src/app/layout.tsx (3)
1-6: LGTM!The imports are correctly used and follow the best practices.
8-12: LGTM!The
metadataobject is correctly defined and follows the Next.js conventions.
14-24: LGTM!The
RootLayoutcomponent is correctly implemented and follows the React best practices. The usage ofTRPCReactProviderand the font class name is correct.script/test-scaffold.ts (1)
22-22: LGTM!The code changes are approved.
packages/plugins/trpc/res/client/v11/next.ts (2)
3-7: LGTM!The code changes are approved.
9-16: LGTM!The code changes are approved.
packages/plugins/trpc/res/client/v11/react.ts (1)
1-16: LGTM!The code changes are approved. The file is well-structured, follows best practices, and ensures type safety.
packages/ide/jetbrains/CHANGELOG.md (1)
6-9: LGTM!The changes made in the unreleased section of the changelog are clear and well-documented. The entries provide a concise description of the updates made to the
uuid()function and the addition of the newcheck()policy rule function.packages/plugins/trpc/tests/projects/t3-trpc-v11/src/trpc/server.ts (4)
1-9: LGTM!The import statements are correctly used to bring in the required dependencies for tRPC server setup and hydration helpers.
11-22: LGTM!The
createContextfunction correctly wraps thecreateTRPCContexthelper and provides the required context for tRPC calls from React Server Components. The custom headerx-trpc-sourceis set torscto indicate the source of the tRPC call.
24-25: LGTM!The
getQueryClientandcallervariables are correctly set up to create a query client and a caller for the tRPC API. ThecreateQueryClientandcreateCallerfunctions are used appropriately.
27-30: LGTM!The exported
apiandHydrateClientvariables are correctly set up using thecreateHydrationHelpersfunction from the@trpc/react-query/rscpackage. ThecallerandgetQueryClientfunctions are passed as arguments to enable hydration of tRPC queries in React Server Components. TheAppRoutertype is used appropriately to specify the type of the tRPC router.tests/regression/tests/issue-1644.test.ts (1)
1-23: LGTM!The test case is well-structured and follows best practices:
- It has a clear description of the issue being tested.
- It loads a minimal schema required for the test case.
- It creates test data before performing assertions.
- It uses the
enhancefunction to create a scoped Prisma client with specific permissions.- It performs multiple assertions to verify the expected behavior.
The code changes are approved.
packages/plugins/trpc/tests/projects/t3-trpc-v11/schema.zmodel (4)
4-11: LGTM!The Prisma generator and datasource are correctly configured.
13-20: LGTM!The trpc plugin is correctly configured.
22-28: LGTM!The User model is correctly defined.
30-41: LGTM!The Post model is correctly defined.
packages/plugins/trpc/tests/projects/t3-trpc-v11/src/app/api/trpc/[trpc]/route.ts (4)
1-6: LGTM!The import statements are correctly used to bring in the required dependencies and modules.
12-16: LGTM!The
createContextfunction is correctly implemented to provide the required context for the tRPC API.
18-32: LGTM!The
handlerfunction is correctly implemented to handle HTTP requests for the/api/trpcendpoint.
34-34: LGTM!The export statement is correctly used to export the
handlerfunction for bothGETandPOSTmethods.packages/plugins/trpc/tests/projects/t3-trpc-v11/.eslintrc.cjs (1)
1-42: LGTM!The ESLint configuration looks good and follows best practices:
- It uses the
@typescript-eslintparser for parsing TypeScript code.- It enables type checking by setting
parserOptions.projecttotrue.- It extends recommended configurations from well-known and reputable sources.
- It defines custom rules to enforce consistent coding style and catch potential issues.
packages/runtime/src/browser/serialization.ts (2)
3-3: LGTM!The change to import
Decimalfromdecimal.js-lightinstead ofdecimal.jsis approved.
8-11: LGTM!The updated
isApplicablemethod that checks if the valuevis an instance ofDecimalor if it has atoStringTagproperty equal to'[object Decimal]'is approved. This change improves interoperability with objects from thedecimal.jslibrary and allows for greater flexibility in handling different decimal representations during serialization and deserialization processes.packages/plugins/trpc/res/client/v11/utils.ts (2)
10-18: LGTM!The
DeepOverridetype definition looks good and handles the recursive merging correctly.
24-32: LGTM!The
DeepOverrideAtPathtype definition looks good. It correctly traverses to the specified path in the type and recursively merges from there usingDeepOverride.tests/regression/tests/issue-1642.test.ts (1)
1-40: LGTM!The test case is well-structured and tests the expected behavior based on the defined access policies:
- The User model has read access for all and full access for user with id 1.
- The Post model delegates all access policies to the author and has a future update policy.
- The test case creates a user and a post, and then performs two update operations on the post.
- The first update operation is expected to be rejected by policy, while the second is expected to resolve.
The test case should catch any regressions related to the access policies.
packages/plugins/trpc/tests/t3.test.ts (1)
31-42: LGTM!The new test case
project test trpc v11is well-structured and follows a similar pattern to the existing test case for version 10. It ensures that the correct versions of dependencies are installed and validates the setup and functionality of version 11 in a specific project context.The code changes are approved.
packages/plugins/trpc/tests/projects/t3-trpc-v11/README.md (1)
1-29: LGTM!The new README.md file looks great! It provides a clear overview of the T3 Stack and links to relevant documentation. The deployment guides are also a nice addition.
Some key highlights:
- The file is well-structured and easy to follow.
- The content is clear and concise.
- The links to relevant documentation are helpful.
- The deployment guides are a nice addition.
Overall, the changes are approved.
Tools
LanguageTool
[uncategorized] ~9-~9: These words/punctuation marks might seem a little out of order. For clarity and coherence, try switching them around.
Context: ...se refer to the respective docs. If you still are in the wind, please join our [Discord](...(AI_EN_LECTOR_REPLACEMENT_WORD_ORDER)
[style] ~23-~23: Consider using a more formal and expressive alternative to ‘awesome’.
Context: ...-currently-available) — Check out these awesome tutorials You can check out the [creat...(AWESOME)
packages/plugins/trpc/tests/projects/t3-trpc-v11/src/env.js (1)
1-42: Overall assessment: The file follows best practices for environment configuration in a Next.js application.The file is well-structured and uses the
createEnvfunction from@t3-oss/env-nextjsto create an environment configuration object. The use of Zod for schema validation ensures type safety and helps catch invalid environment variables during build time. The comments provide clear explanations for each section and configuration option.packages/plugins/trpc/tests/projects/t3-trpc-v11/src/app/page.tsx (2)
1-5: LGTM!The imports are properly used and follow the correct syntax. The use of CSS modules is a good practice for scoping styles to the component. The
HydrateClientimport suggests that the component is using tRPC for data fetching, which is a valid approach.
37-37: LGTM!The use of
'force-dynamic'for thedynamicexport is appropriate for this page since it seems to be fetching data using tRPC. This ensures that the page is always rendered on the server and never statically generated, which is suitable for pages with dynamic data or server-side logic.tests/regression/tests/issue-1648.test.ts (1)
1-43: LGTM!The test case is well-structured and covers the regression scenario for issue 1648. It tests the expected behavior based on the deny policy in the Post model.
- The schema and test data setup look correct.
- Updating Post1 should be allowed because the associated user's profile someText is "canUpdate".
- Updating Post2 should be rejected by the policy because the associated user's profile someText is not "canUpdate".
The assertions are testing the expected behavior correctly.
packages/misc/redwood/src/graphql.ts (2)
1-1: LGTM!The addition of
ValidationErrorto the import statement is approved. This change enhances the error handling capabilities of the application.
Line range hint
49-59: LGTM!The modification in the error handling logic within the
transformErrorfunction is approved. The change ensures that the correct error code (PrismaErrorCode.CONSTRAINT_FAILED) is being evaluated and that specific error cases are handled appropriately by returning the corresponding RedwoodJS errors.tests/regression/tests/issue-1667.test.ts (3)
4-28: LGTM!The test case for custom enhancer with standard Zod output looks good. The
loadSchemafunction is called with the correct options to get the Prisma schema and preserve TS files.
30-59: LGTM!The test case for custom enhancer with custom Zod output looks good. The
loadSchemafunction is called with the correct options to get the Prisma schema, generate without compiling, and then compile.
61-85: LGTM!The test case for standard enhancer with custom Zod output looks good. The
loadSchemafunction is called with the correct options to get the Prisma schema and compile.packages/plugins/trpc/tests/projects/t3-trpc-v11/src/app/_components/post.tsx (5)
1-7: LGTM!The code segment imports necessary dependencies and styles. The code changes are approved.
8-24: LGTM!The code segment defines a
LatestPostcomponent that fetches the latest post using bothuseQueryanduseSuspenseQueryhooks. TheuseSuspenseQueryhook is used correctly to fetch the latest post and log the author's email. The code changes are approved.
26-37: LGTM!The code segment uses
api.post.findManyto fetch posts using theuseInfiniteQueryhook. ThegetNextPageParamoption is used correctly to fetch the next page of posts. The code changes are approved.
39-46: LGTM!The code segment uses
api.useUtilsto get the utils object and defines acreatePostmutation usingapi.post.create.useMutation. TheonSuccesscallback is used correctly to invalidate thepostquery and reset thenamestate. The code changes are approved.
48-78: LGTM!The code segment returns JSX for the
LatestPostcomponent. The component displays the latest post if it exists, otherwise it displays a message saying there are no posts yet. The component also renders a form to create a new post. The code changes are approved.packages/plugins/trpc/tests/projects/t3-trpc-v11/src/trpc/react.tsx (10)
1-2: LGTM!The
'use client'directive is correctly placed at the top of the file to indicate that the file is a client component in Next.js 13.
3-7: LGTM!The imports are correctly named, typed, and used in the file.
9-11: LGTM!The imports are correctly named, typed, and used in the file.
13-21: LGTM!The
getQueryClientfunction is correctly implemented using the singleton pattern to create a query client in the browser. The function correctly uses thecreateQueryClientfunction from the./query-clientmodule.Tools
Biome
[error] 20-20: The assignment should not be in an expression.
The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.(lint/suspicious/noAssignInExpressions)
23-23: LGTM!The
apiconstant is correctly exported and created using thecreateTRPCReactfunction from the../server/api/routers/generated/client/reactmodule. ThecreateTRPCReactfunction is correctly typed with theAppRoutertype from the~/server/api/rootmodule.
25-30: LGTM!The
RouterInputstype is correctly defined and exported using theinferRouterInputsfunction from the@trpc/serverlibrary. TheinferRouterInputsfunction is correctly typed with theAppRoutertype from the~/server/api/rootmodule.
32-37: LGTM!The
RouterOutputstype is correctly defined and exported using theinferRouterOutputsfunction from the@trpc/serverlibrary. TheinferRouterOutputsfunction is correctly typed with theAppRoutertype from the~/server/api/rootmodule.
39-70: LGTM!The
TRPCReactProvidercomponent is correctly implemented using thegetQueryClientfunction to create a query client, theuseStatehook to create a tRPC client, theapiconstant to create a tRPC client, theloggerLinkandunstable_httpBatchStreamLinkfunctions from the@trpc/clientlibrary to create a tRPC client, theSuperJSONlibrary for serialization, thegetBaseUrlfunction to get the base URL for the tRPC client, theQueryClientProvidercomponent from the@tanstack/react-querylibrary to provide the query client to the child components, and theapi.Providercomponent to provide the tRPC client to the child components.
72-76: LGTM!The
getBaseUrlfunction is correctly implemented using thewindow.location.originproperty to get the base URL in the browser, theVERCEL_URLenvironment variable to get the base URL in a Vercel environment, and thePORTenvironment variable to get the base URL in a local environment.
20-20: SkippedThe hint from the Biome static analysis tool about a suspicious assignment in an expression at line 20 is a false positive. The assignment in the expression at line 20 is intentional and is used to implement the singleton pattern for creating a query client in the browser. The assignment in the expression at line 20 is not confusing and does not violate the side-effect free nature of expressions.
Tools
Biome
[error] 20-20: The assignment should not be in an expression.
The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.(lint/suspicious/noAssignInExpressions)
packages/schema/src/cli/actions/generate.ts (4)
22-23: LGTM!The changes to the
Optionstype are approved. The addition of thewithPluginsandwithoutPluginsproperties provides more control over plugin management during the execution of the CLI actions.
63-70: LGTM!The changes to the
runPluginsfunction are approved. The iteration over the combined list of plugins from bothwithPluginsandwithoutPlugins, along with the check for the existence of specified plugins in the schema, enhances error handling and provides more control over plugin management.
74-75: LGTM!The changes to the
PluginRunnerOptionsobject are approved. The inclusion of thewithPluginsandwithoutPluginsproperties ensures that the specified plugin options are passed to thePluginRunnerfor execution.
2-2: LGTM!The change to the import statement is approved. Importing the
isPluginfunction from@zenstackhq/sdk/astensures that it is imported from the correct location.tests/regression/tests/issue-1674.test.ts (1)
1-87: LGTM!The regression test for issue 1674 looks good:
- The schema and test data setup are correct.
- The test expectation is correct based on the defined policies.
- The test is well-structured and follows best practices.
- The test name and description clearly indicate the purpose of the test.
Great job adding this regression test!
packages/runtime/src/enhancements/omit.ts (1)
Line range hint
29-65: LGTM!The changes to the
processResultEntitymethod are well-structured and enhance its functionality by providing tailored processing based on the operation type. The method now handles various data scenarios, improving its versatility and robustness.A few observations:
- The method assumes that the
dataparameter is of the correct type and structure for each scenario. This assumption is safe as the calling code is responsible for providing the correct data.- The method doesn't handle any other
actionvalues apart from 'create', 'update', and 'delete' for Prisma Pulse results. This is acceptable as these are the only valid actions currently.Overall, the changes look good to me.
tests/integration/tests/enhancements/with-policy/create-many-and-return.test.ts (1)
95-106: LGTM!The test case is well-structured and follows the AAA (Arrange-Act-Assert) pattern. It tests the behavior of the
createManyAndReturnmethod with field-level policies and expects the method to be rejected by policy, which is the correct behavior. The additional check to confirm that the posts are indeed created is also a good addition.The code changes are approved.
packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/trpc.ts (5)
1-12: LGTM!The import statements are correct and necessary for the tRPC setup.
15-32: LGTM!The
createTRPCContextfunction is correctly implemented and follows the tRPC documentation for creating the API context.
34-52: LGTM!The tRPC initialization code is correctly implemented and follows the tRPC documentation. The use of
superjsonand parsing ofZodErrors are good practices for ensuring type safety and better error handling.
54-74: LGTM!The exported functions are correctly implemented and follow the tRPC documentation for creating server-side callers and routers.
75-105: LGTM!The
timingMiddlewareis a useful addition for catching unwanted waterfalls by simulating network latency in development. ThepublicProcedurefunction is correctly implemented and follows the tRPC documentation for building queries and mutations.packages/schema/src/plugins/plugin-utils.ts (1)
122-132: LGTM!The new function
getPluginCustomOutputFolderlooks good:
- It follows a clear logic flow and handles edge cases appropriately.
- It uses appropriate type guards and utility functions.
- The function is well-structured, properly typed, and doesn't have any performance issues, code smells, security vulnerabilities, or potential bugs.
- The function has a clear purpose and is appropriately named.
The code changes are approved.
tests/integration/tests/cli/generate.test.ts (1)
115-124: LGTM!The changes to the test case and plugin definitions align with the updated testing strategy and look good to me.
packages/schema/src/cli/index.ts (3)
63-71: LGTM!The new
checkActionfunction is implemented correctly and follows the same pattern as other action functions in the file.
123-124: LGTM!The new
--with-pluginsand--without-pluginsoptions are correctly added to thegeneratecommand and provide additional flexibility to users.
146-150: LGTM!The new
checkcommand is correctly added to the program and linked to thecheckActionfunction.tests/regression/tests/issue-1645.test.ts (1)
1-203: LGTM!The regression test for issue 1645 is well-structured and follows the AAA (Arrange, Act, Assert) pattern. It creates the necessary test data and verifies the expected behavior.
The test is using the
loadSchemafunction from@zenstackhq/testtoolsto load the schema and theenhancefunction to create a database client. It is using thecreateandupdatemethods to create and update data and theexpectfunction to verify the expected behavior.The test code changes are approved.
packages/schema/src/plugins/zod/utils/schema-gen.ts (4)
226-226: Improved formatting of themessagevariable.The change removes the leading comma from the string interpolation, improving the formatting of the
messagevariable.
228-229: Introduced a newpathvariable for validation refinements.The change introduces a new
pathvariable to specify the path for validation refinements:
- It retrieves the 'path' attribute using the
getAttributeArgfunction.- It checks if the attribute is an array expression using the
isArrayExprfunction.- If valid, it constructs a string representation of the path using
getLiteralArray.This enhances the flexibility of the validation refinements by allowing path specification.
231-231: Introduced a newoptionsvariable to encapsulatemessageandpath.The change introduces a new
optionsvariable that encapsulates both themessageandpathvariables, formatted as an object. This modifies the output structure of the refinement function.
245-245: Modified the return statement to use the newoptionsvariable.The change modifies the return statement of the function by replacing the previous concatenation of
messagewith the newoptionsvariable. This alters the output structure of the refinement function to include both themessageandpathoptions.packages/server/src/api/rpc/index.ts (1)
21-21: LGTM!The change corrects a typo in the error code name, improving the readability and maintainability of the code without affecting the functionality.
tests/integration/tests/enhancements/with-delegate/policy-interaction.test.ts (1)
212-270: LGTM!The test case is well-structured and covers various scenarios to validate the policy enforcement logic in a polymorphic context. It ensures that the system behaves correctly when managing relationships between different asset types and their associated comments.
packages/runtime/src/enhancements/proxy.ts (4)
58-58: LGTM!The addition of the
streammethod to thePrismaProxyHandlerinterface is approved. It appropriately extends the interface to support streaming operations.
196-196: LGTM!The addition of the
_methodparameter to theprocessResultEntitymethod is approved. It allows for flexibility to customize result processing per Prisma method if needed in the future.
203-203: LGTM!The addition of the
_methodparameter to thepreprocessArgsmethod is approved. It enables flexibility to customize argument preprocessing per Prisma method if required in the future.
166-190: LGTM!The refactoring of the
subscribemethod to call the newdoSubscribeStreammethod is approved. ThedoSubscribeStreammethod consolidates the logic for handling bothsubscribeandstreamoperations effectively.It appropriately processes the async iterable returned by Prisma's methods and wraps the iteration results using
processResultEntityfor consistent result processing.packages/testtools/src/schema.ts (5)
138-138: LGTM!The code change is approved.
150-150: LGTM!The code change is approved.
230-233: LGTM!The code change enhances the functionality by providing users with more control over the schema generation process.
276-279: LGTM!The code change improves the modularity and maintainability of the code by encapsulating the module loading logic.
237-237: Security issue: Unsafe shell command construction from library input.The command string is constructed by concatenating user input without proper sanitization or escaping. This can lead to command injection vulnerabilities if the user input contains malicious characters or commands.
To fix the issue, use a safe method to construct the command string, such as using an array of arguments instead of string concatenation. For example:
-run( - `npx zenstack generate --no-version-check --schema ${zmodelPath} --no-dependency-check${outputArg}${otherArgs}`, - { - NODE_PATH: './node_modules', - } -); +const args = [ + 'npx', + 'zenstack', + 'generate', + '--no-version-check', + '--schema', + zmodelPath, + '--no-dependency-check', + ...outputArg.split(' ').filter(Boolean), + ...otherArgs.split(' ').filter(Boolean), +]; +run(args.join(' '), { + NODE_PATH: './node_modules', +});This ensures that the user input is treated as separate arguments and not interpreted as part of the command.
Tools
GitHub Check: CodeQL
[warning] 237-237: Unsafe shell command constructed from library input
This string concatenation which depends on library input is later used in a shell command.
This string concatenation which depends on library input is later used in a shell command.
This string concatenation which depends on library input is later used in a shell command.
This string concatenation which depends on library input is later used in a shell command.
This string concatenation which depends on library input is later used in a shell command.packages/schema/src/cli/cli-util.ts (1)
30-30: LGTM!The changes to the
loadDocumentfunction are approved:
- The new optional parameter
validateOnlyallows users to validate the document structure without performing additional processing, thereby improving the utility of the function for scenarios where only validation is required.- The control flow has been correctly altered to include a conditional check for the
validateOnlyparameter immediately after the model is parsed.- If
validateOnlyis true, the function exits early, returning the parsed model directly, thereby bypassing subsequent operations that would normally merge declarations into the main document.Also applies to: 96-99
tests/integration/tests/enhancements/with-policy/prisma-pulse.test.ts (2)
1-4: LGTM!The code changes are approved.
5-7: LGTM!The code changes are approved.
packages/plugins/trpc/src/helpers.ts (2)
Line range hint
187-243: LGTM!The changes to the
generateRouterTypingfunction look good:
- The addition of the
versionparameter allows the function to generate different typing based on the TRPC version.- The conditional logic in the function body is correctly implemented to handle the different versions.
- The changes are not breaking as the function is still backward compatible.
261-276: LGTM!The changes to the
generateRouterTypingImportsfunction look good:
- The addition of the
versionparameter allows the function to generate different imports based on the TRPC version.- The conditional logic in the function body is correctly implemented to handle the different versions.
- The changes are not breaking as the function is still backward compatible.
packages/schema/src/cli/plugin-runner.ts (10)
43-44: LGTM!The addition of the
withPluginsandwithoutPluginsproperties to thePluginRunnerOptionstype enhances the flexibility of the plugin system by enabling more granular control over which plugins are activated.
142-152: LGTM!The addition of the
isCorePluginparameter to therunPluginmethod and the corresponding changes to the method's logic enhance the plugin management capabilities by conditionally skipping the execution of non-core plugins if they are not enabled.
177-187: LGTM!The changes to the
runPluginmethod, which pass theisCorePluginparameter to theisPluginEnabledmethod, are consistent with the previous modifications and ensure that theisPluginEnabledmethod receives the necessary information to determine whether a plugin should be executed.
205-206: LGTM!The simplification of the logic in the
calculateAllPluginsmethod ensures that core plugins are always included when thedefaultPluginsoption is set to true, improving the consistency of the plugin management system.
239-240: LGTM!The changes to the
calculateAllPluginsmethod improve the consistency and reliability of the plugin management system by ensuring that the@core/zodplugin is enabled when necessary, based on the presence of the@core/enhancerplugin and validation rules.
344-345: LGTM!The addition of the
projectparameter to therunPluginmethod and the corresponding changes to pass theprojectobject to therunfunction allow plugins to access and modify the project's source files and configuration.
347-350: LGTM!The changes to the
runPluginmethod, which allow it to skip the execution of non-core plugins that are not enabled, enhance the plugin management capabilities by improving performance and reducing unnecessary processing.
354-354: LGTM!The introduction of the
titleconstant and its usage in theoraspinner improves the user experience by providing more informative messages during the plugin execution process, making it easier for users to understand which plugin is currently running.
390-400: LGTM!The introduction of the
isPluginEnabledmethod improves the modularity and maintainability of the plugin management system by encapsulating the logic for determining whether a plugin should be executed based on the user-provided options.Tools
Biome
[error] 395-396: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
395-396: Skipping the hint from the static analysis tool.The current code is safe and does not require the use of an optional chain. The static analysis tool's suggestion is a false positive and can be ignored.
Tools
Biome
[error] 395-396: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
tests/integration/tests/enhancements/with-policy/post-update.test.ts (1)
556-597: LGTM!The new test case "deep member access" is well-structured and enhances the testing coverage for the policy enforcement logic, particularly in scenarios involving nested relationships and conditions. The test case is correctly implemented and there are no issues or areas for improvement.
packages/sdk/src/model-meta-generator.ts (1)
301-302: LGTM!The code changes are approved. The use of the nullish coalescing operator (
??) ensures that the correct base delegate model is referenced in case of polymorphism, improving the logic and control flow of the function.packages/plugins/trpc/src/generator.ts (6)
53-56: LGTM!The code changes to introduce the
versionvariable and validate its value are approved.
58-69: LGTM!The code changes to enforce the required options for tRPC v11 are approved.
121-147: LGTM!The code changes to conditionally add import declarations based on the tRPC version are approved.
Line range hint
157-177: LGTM!The code changes to conditionally add type declarations and import declarations based on the tRPC version are approved.
Line range hint
193-234: LGTM!The code changes to conditionally set the name, parameters, and function calls in the
createRouterfunction based on the tRPC version are approved.
257-280: LGTM!The code changes to update the
createClientHelpersfunction to handle different versions of the tRPC framework are approved.packages/schema/src/res/stdlib.zmodel (1)
636-636: Attribute signature update looks good! This will allow for more granular control over the validation process.The addition of the optional
pathparameter to the@@validateattribute enhances the validation functionality by allowing the inclusion of a path to specify the context or location of the validation within a nested structure.This change may impact how validation is performed and how validation errors are reported, as it allows for more granular control over the validation process by providing a way to reference the path of the entity being validated.
packages/schema/src/plugins/enhancer/enhance/index.ts (2)
41-41: LGTM!The import statement looks good.
134-159: ThegetZodImportmethod looks good!The method correctly determines the appropriate import path for Zod based on the presence of custom output options. It handles the following scenarios:
- If neither Zod nor the enhancer have custom output, it uses the default import path.
- If only the enhancer has custom output, it imports from the runtime.
- If only Zod has custom output, it still imports from the default output as the CLI will generate a copy there.
- If both Zod and the enhancer have custom output, it resolves the relative path and imports from there.
The logic is well-structured and covers all the necessary cases.
tests/integration/tests/plugins/zod.test.ts (4)
461-500: LGTM!The new test case
refinement with pathis well-structured and covers various scenarios to validate the refinement conditions on the array field. It uses thesafeParsemethod to check for specific validation errors and thepathoption to specify the error paths. The test expectations are clearly defined and match the corresponding validation rules.
791-794: Configuration for the newenhancerplugin looks good.The
enhancerplugin is added to the Prisma schema with its own provider and output path. Assuming it's a necessary addition to the project, the configuration looks correct.
809-809: Verify the impact and alignment of thegetPrismaOnlyandgenerateNoCompileoptions.The
loadSchemafunction call is updated with thegetPrismaOnlyandgenerateNoCompileoptions. It's important to ensure that these options align with the intended behavior and don't introduce any unintended consequences. Please verify that they meet the project requirements and confirm their impact on the Prisma client's interaction with the database and code generation.
831-834: Theenhancerplugin is properly included in the test configuration.The
enhancerplugin is consistently added to both the model and the generator sections of the test configuration, ensuring its proper integration into the test environment.packages/schema/src/plugins/enhancer/policy/expression-writer.ts (3)
Line range hint
1-1:
467-498: LGTM!The
stripFutureCallmethod looks good:
- It correctly handles the case when
fieldAccessis not a future member access.- It processes future member access expressions to create a reference expression while preserving the member access chain.
- The logic is clear and well-structured.
- The type annotations and JSDoc comments are appropriate.
The code changes are approved.
843-851: LGTM!The changes in the
writeRelationCheckmethod look good:
- Using a constant
falsefor'postUpdate'operation ensures that the policy is not delegated to relations, as expected.- For other operations, using the target guard function is the correct behavior.
The code changes are approved.
packages/plugins/openapi/src/rpc-generator.ts (1)
640-646: LGTM!The changes to the
_Metaschema definition look good:
- Adding a
descriptionproperty enhances clarity.- Removing the nested
metaobject and directly including theserializationproperty simplifies the structure.The changes are valid and improve the schema definition.
packages/runtime/src/enhancements/delegate.ts (2)
156-158: LGTM!The added check to continue the loop if
fieldInfois falsy looks good. It prevents accessing properties onundefinedand skips further processing for that field.
160-169: LGTM!The changes to the delegate model handling logic look good:
- Checking if
fieldInfo.typeis a delegate or descendant of a delegate before injecting the select/include hierarchy ensures only valid delegate types are processed.- Transforming
args[kind][field]value oftrueto an empty object enforces a consistent structure for the payload.These enhancements improve the robustness of the delegate handling and ensure proper structure of the processed data.
packages/runtime/src/enhancements/policy/policy-utils.ts (4)
476-480: Approved: The changes generalize the logic for injecting read guards.The
buildReadGuardForFieldsmethod now handles injecting read guards for both relation and regular fields, improving code maintainability.
Line range hint
489-534: Approved: ThebuildReadGuardForFieldsmethod generalizes the logic for building read guards.The method now handles building read guards for both relation and regular fields. It combines the field-level read guards with the model-level guard and recursively injects read guards into nested payloads for relation fields. This improves code reusability and maintainability.
599-619: Approved: The changes leverage the generalizedbuildReadGuardForFieldsmethod.The code now uses the
buildReadGuardForFieldsmethod to inject read guards for both relation and regular fields. It then merges the injected guard with the user-provided where clause, ensuring that read policies are enforced while preserving the user's query conditions.
1223-1223: Approved: The typo in the error code is fixed.The error code is changed from
CONSTRAINED_FAILEDtoCONSTRAINT_FAILED, aligning it with the standard error naming convention. This improves code clarity and consistency.packages/server/src/api/rest/index.ts (1)
1592-1592: LGTM!The code change corrects the typo in the Prisma error code being checked, aligning it with the correct value
PrismaErrorCode.CONSTRAINT_FAILED. This improves the accuracy of error handling for Prisma client request errors related to data validation violations.packages/runtime/src/enhancements/policy/handler.ts (1)
1540-1635: LGTM!The refactoring of the
subscribeandstreammethods to delegate their functionality to the newhandleSubscribeStreammethod enhances code readability and maintainability. The changes introduce a more structured approach to processing subscription arguments, injecting read guards, and post-processing iteration results. The code segment improves the overall structure and clarity while maintaining the same functionality.
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
Outside diff range, codebase verification and nitpick comments (1)
packages/schema/src/cli/cli-util.ts (1)
372-400: Nicely done! Just a suggestion to improve error handling.The new
showNotificationfunction is implemented correctly:
- It fetches the configuration data using the
fetchAPI with a timeout for better reliability.- The fetched data is validated against a defined
zodschema to ensure type safety and data integrity.- It logs a random active notification link to the console if available.
Consider improving the error handling:
- Catch specific errors (e.g.,
TimeoutError,FetchError,ZodError) and log them with meaningful messages for better debugging.- Avoid using a generic catch block that does nothing, as it can make debugging harder.
For example:
try { // ... } catch { - // noop + console.error('Failed to fetch or validate notification data:', error); }
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (2)
packages/schema/package.jsonis excluded by!**/*.jsonpnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!**/*.yaml
Files selected for processing (3)
- packages/schema/src/cli/actions/generate.ts (4 hunks)
- packages/schema/src/cli/cli-util.ts (4 hunks)
- packages/schema/src/cli/index.ts (4 hunks)
Files skipped from review as they are similar to previous changes (2)
- packages/schema/src/cli/actions/generate.ts
- packages/schema/src/cli/index.ts
Additional comments not posted (4)
packages/schema/src/cli/cli-util.ts (4)
9-9: LGTM!The code changes are approved.
12-12: LGTM!The code changes are approved.
25-26: LGTM!The code changes are approved.
Line range hint
34-103: LGTM!The code changes to the
loadDocumentfunction are approved:
- The new optional
validateOnlyparameter is a useful enhancement that allows users to validate the document structure without performing additional processing.- The control flow changes to include a conditional check for
validateOnlyand return early are correctly implemented.
…untime compatibility (#1684)
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: 10
Outside diff range, codebase verification and nitpick comments (3)
packages/schema/src/plugins/plugin-utils.ts (2)
Line range hint
22-58: Suggest adding error handling for file operations.The
ensureDefaultOutputFolderfunction performs file operations without explicit error handling. Consider adding try-catch blocks around file operations to handle potential I/O errors gracefully.
Line range hint
60-86: Consider improving documentation or simplifying the function.The
getDefaultOutputFolderfunction handles multiple scenarios and path resolutions, which makes it complex. Enhancing documentation or simplifying the logic could improve maintainability and readability.packages/runtime/src/enhancements/node/create-enhancement.ts (1)
Line range hint
11-67: Approve changes tocreateEnhancementand suggest documenting API changes.The modifications to
createEnhancementreflect a simplification of the API and enhance its functionality by dynamically applying different enhancements based on the model metadata and specified kinds. The Prisma version check is a good practice to ensure compatibility. Consider documenting these API changes to help developers understand the new configuration and utilization methods.Would you like assistance in documenting these changes?
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (4)
packages/plugins/trpc/tests/projects/t3-trpc-v10/package.jsonis excluded by!**/*.jsonpackages/runtime/package.jsonis excluded by!**/*.jsonpackages/server/package.jsonis excluded by!**/*.jsonpnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!**/*.yaml
Files selected for processing (44)
- packages/plugins/trpc/tests/projects/t3-trpc-v10/src/pages/index.tsx (1 hunks)
- packages/runtime/res/enhance-edge.d.ts (1 hunks)
- packages/runtime/res/enhance-edge.js (1 hunks)
- packages/runtime/src/edge.ts (1 hunks)
- packages/runtime/src/enhance-edge.d.ts (1 hunks)
- packages/runtime/src/enhancements/edge/create-enhancement.ts (1 hunks)
- packages/runtime/src/enhancements/edge/default-auth.ts (1 hunks)
- packages/runtime/src/enhancements/edge/delegate.ts (1 hunks)
- packages/runtime/src/enhancements/edge/index.ts (1 hunks)
- packages/runtime/src/enhancements/edge/logger.ts (1 hunks)
- packages/runtime/src/enhancements/edge/omit.ts (1 hunks)
- packages/runtime/src/enhancements/edge/password.ts (1 hunks)
- packages/runtime/src/enhancements/edge/policy/check-utils.ts (1 hunks)
- packages/runtime/src/enhancements/edge/policy/handler.ts (1 hunks)
- packages/runtime/src/enhancements/edge/policy/index.ts (1 hunks)
- packages/runtime/src/enhancements/edge/policy/policy-utils.ts (1 hunks)
- packages/runtime/src/enhancements/edge/promise.ts (1 hunks)
- packages/runtime/src/enhancements/edge/proxy.ts (1 hunks)
- packages/runtime/src/enhancements/edge/query-utils.ts (1 hunks)
- packages/runtime/src/enhancements/edge/types.ts (1 hunks)
- packages/runtime/src/enhancements/edge/utils.ts (1 hunks)
- packages/runtime/src/enhancements/edge/where-visitor.ts (1 hunks)
- packages/runtime/src/enhancements/node/create-enhancement.ts (2 hunks)
- packages/runtime/src/enhancements/node/default-auth.ts (1 hunks)
- packages/runtime/src/enhancements/node/delegate.ts (4 hunks)
- packages/runtime/src/enhancements/node/index.ts (1 hunks)
- packages/runtime/src/enhancements/node/omit.ts (2 hunks)
- packages/runtime/src/enhancements/node/password.ts (1 hunks)
- packages/runtime/src/enhancements/node/policy/check-utils.ts (1 hunks)
- packages/runtime/src/enhancements/node/policy/handler.ts (5 hunks)
- packages/runtime/src/enhancements/node/policy/index.ts (1 hunks)
- packages/runtime/src/enhancements/node/policy/policy-utils.ts (9 hunks)
- packages/runtime/src/enhancements/node/promise.ts (1 hunks)
- packages/runtime/src/enhancements/node/proxy.ts (6 hunks)
- packages/runtime/src/enhancements/node/query-utils.ts (1 hunks)
- packages/runtime/src/enhancements/node/types.ts (2 hunks)
- packages/runtime/src/enhancements/node/utils.ts (1 hunks)
- packages/runtime/src/enhancements/node/where-visitor.ts (1 hunks)
- packages/runtime/src/index.ts (1 hunks)
- packages/runtime/src/types.ts (3 hunks)
- packages/schema/src/plugins/enhancer/enhance/index.ts (3 hunks)
- packages/schema/src/plugins/enhancer/policy/policy-guard-generator.ts (1 hunks)
- packages/schema/src/plugins/plugin-utils.ts (3 hunks)
- packages/testtools/src/schema.ts (6 hunks)
Files skipped from review due to trivial changes (22)
- packages/runtime/res/enhance-edge.d.ts
- packages/runtime/src/edge.ts
- packages/runtime/src/enhance-edge.d.ts
- packages/runtime/src/enhancements/edge/create-enhancement.ts
- packages/runtime/src/enhancements/edge/delegate.ts
- packages/runtime/src/enhancements/edge/index.ts
- packages/runtime/src/enhancements/edge/logger.ts
- packages/runtime/src/enhancements/edge/omit.ts
- packages/runtime/src/enhancements/edge/policy/handler.ts
- packages/runtime/src/enhancements/edge/policy/index.ts
- packages/runtime/src/enhancements/edge/promise.ts
- packages/runtime/src/enhancements/edge/proxy.ts
- packages/runtime/src/enhancements/edge/query-utils.ts
- packages/runtime/src/enhancements/edge/types.ts
- packages/runtime/src/enhancements/edge/utils.ts
- packages/runtime/src/enhancements/node/default-auth.ts
- packages/runtime/src/enhancements/node/password.ts
- packages/runtime/src/enhancements/node/policy/index.ts
- packages/runtime/src/enhancements/node/promise.ts
- packages/runtime/src/enhancements/node/query-utils.ts
- packages/runtime/src/enhancements/node/utils.ts
- packages/runtime/src/enhancements/node/where-visitor.ts
Files skipped from review as they are similar to previous changes (3)
- packages/runtime/src/types.ts
- packages/schema/src/plugins/enhancer/enhance/index.ts
- packages/testtools/src/schema.ts
Additional context used
Biome
packages/runtime/res/enhance-edge.js
[error] 1-1: Redundant use strict directive.
The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.(lint/suspicious/noRedundantUseStrict)
Additional comments not posted (21)
packages/runtime/src/enhancements/node/index.ts (1)
1-1: Verify the new export path.The change in the export path from
'../cross'to'../../cross'needs to be verified to ensure it correctly points to the intended module and does not introduce any module resolution issues.Run the following script to verify the new export path:
Verification successful
The new export path is valid.
The export path
'../../cross'is correctly used in multiple TypeScript files, indicating that it is a valid path and does not introduce any module resolution issues. The change is consistent with the codebase structure.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the new export path for the module. # Test: Search for the module usage. Expect: Only occurrences of the new path. rg --type typescript -A 5 $'../../cross'Length of output: 74
Script:
#!/bin/bash # Description: Verify the new export path for the module. # Find all TypeScript files and search for the new export path within them. fd --extension ts --exec rg '../../cross' {}Length of output: 1404
packages/runtime/src/index.ts (1)
2-2: Verify the new export path.The change in the export path from
./enhancementsto./crossneeds to be verified to ensure it aligns with the intended functionality and does not affect other parts of the application.Run the following script to verify the new export path:
packages/plugins/trpc/tests/projects/t3-trpc-v10/src/pages/index.tsx (1)
7-23: Approve enhancements in data handling and rendering logic.The modifications in the
Homecomponent enhance both the structure and functionality:
- Data Transformation: The update in the
postsTransformedquery to include theidalongside thetitleimproves data handling and is crucial for any operations that might manipulate or reference specific posts.- Rendering Logic: Adding
keyattributes to<p>elements is a best practice in React for optimizing rendering performance and managing component state effectively.These changes collectively enhance the component's functionality and performance.
packages/schema/src/plugins/plugin-utils.ts (2)
2-2: Verify new imports for necessity and correct usage.The new imports
getLiteralandisPluginare crucial for the functionality of the newly added functiongetPluginCustomOutputFolder. Please ensure that these utilities are used appropriately and only imported if necessary.Also applies to: 6-6
Line range hint
10-20: Well-implemented function for finding node_modules.The
getNodeModulesFolderfunction is correctly implemented with comprehensive checks and recursion to handle various cases effectively.packages/runtime/src/enhancements/edge/default-auth.ts (2)
Line range hint
1-14: FunctionwithDefaultAuthis correctly implemented.The function properly sets up a proxy around the provided Prisma client to handle default authentication values. It uses generics effectively to ensure type safety and flexibility.
Line range hint
16-183: ClassDefaultAuthHandleris well-implemented.The class effectively overrides necessary methods to inject authentication-based defaults into CRUD operations. It maintains good OOP practices and handles async operations correctly.
packages/runtime/src/enhancements/node/proxy.ts (1)
Line range hint
52-184: Refactoring and new methods inDefaultPrismaProxyHandlerare well-implemented.The centralization of stream handling into
doSubscribeStreamand the explicit inclusion of the method name inprocessResultEntityenhance clarity and maintainability. The newstreammethod is correctly implemented to handle asynchronous data streams.packages/schema/src/plugins/enhancer/policy/policy-guard-generator.ts (1)
103-112: Updated import paths inPolicyGeneratorare correctly implemented.The changes in import paths for
allFieldsEqual,PolicyDef, andPermissionCheckerConstraintreflect an improved organization of dependencies. The class methods have been updated accordingly without affecting the core functionality.packages/runtime/src/enhancements/node/delegate.ts (3)
Line range hint
5-17: Update import paths to reflect new directory structure.The import paths have been updated to reflect changes in the directory structure, moving from relative paths that reference the parent directory to paths that reference the grandparent directory. This change is necessary for the correct resolution of modules due to the reorganization of the project's directory structure.
6-7: Refactor to enhance delegate model handling.The logic for handling delegate models within the
DelegateProxyHandlerclass has been significantly altered. The original check forfieldInfohas been inverted, which now continues to the next iteration iffieldInfois not found. This change emphasizes the importance offieldInfoin the subsequent logic, enhancing the robustness of the delegate handling process.
160-169: Ensure robust handling of delegate types and payload structures.The handling of delegate models now includes a check for whether the
fieldInfo.typeis a delegate or a descendant of a delegate. If it is, and if a value exists, the code ensures that the payload is an object before invoking theinjectSelectIncludeHierarchymethod. This change introduces more robust handling of delegate models, ensuring that the hierarchy is correctly injected based on the type.packages/runtime/src/enhancements/edge/policy/policy-utils.ts (2)
Line range hint
4-34: Update import paths to reflect new directory structure.The import paths have been updated to adjust to the restructuring of the project’s directory layout. This includes changes to the imports from
../../constantsand../../crossto../../../constantsand../../../cross, respectively, which may suggest a deeper nesting of the file structure.
Line range hint
1225-1225: Correct the typo in the error code.The error code
PrismaErrorCode.CONSTRAINED_FAILEDhas been corrected toPrismaErrorCode.CONSTRAINT_FAILED. This correction fixes a potential bug in error handling where the incorrect error code might not have been recognized by the system.packages/runtime/src/enhancements/node/policy/policy-utils.ts (1)
Line range hint
478-621: Method renaming and comment updates enhance clarity.The renaming of
injectReadGuardForRelationFieldstobuildReadGuardForFieldsand the updates to the comments clarify the method's purpose and scope. These changes make it clear that the method now handles both relation fields and regular fields, providing a more comprehensive guard injection process.packages/runtime/src/enhancements/node/policy/handler.ts (3)
1533-1628: Refactor: Consolidation of Subscription and Stream HandlingThe refactoring of
subscribeandstreammethods to use a shared methodhandleSubscribeStreamis a positive change, enhancing code reusability and clarity. This method centralizes the logic for handling subscriptions and streams, making the code easier to maintain and modify.
- Correctness: The method correctly checks if
argsis provided and sets default values if not. It also validates thatargsis an object, throwing an error otherwise.- Performance: By centralizing the logic, the performance implications remain consistent across both methods without duplicating code.
- Security: The method ensures that permissions are injected correctly based on the operation type, which is crucial for maintaining the security integrity of the application.
- Maintainability: Centralizing common logic into a single method reduces the risk of bugs related to code duplication and makes future modifications easier.
Overall, this change is approved as it follows best practices in software development by promoting code reuse and reducing complexity.
1641-1641: Simplification of Permission CheckingThe simplification of the
checkmethod by delegating the permission checking to thecheckPermissionfunction is a good practice. It reduces the complexity within thePolicyProxyHandlerclass and isolates permission checking to a dedicated function, enhancing both maintainability and testability.
- Correctness: Assuming
checkPermissionis correctly implemented, this change should maintain the correctness of permission checks.- Maintainability: Reducing the complexity of the
checkmethod by offloading detailed logic tocheckPermissionmakes the class cleaner and easier to understand.- Security: As long as
checkPermissionhandles all security checks robustly, this change does not introduce new security concerns.This change is approved, provided that
checkPermissionis thoroughly tested and verified to handle all edge cases correctly.
Line range hint
8-28: Adjustment of Import Statements and Type DefinitionsThe adjustments in import statements and the removal of
PermissionCheckArgsfrom the local scope to reference it from thetypesmodule is a structural improvement. It aligns with best practices of managing type definitions in a centralized location, which aids in maintainability and reduces the likelihood of inconsistencies.
- Maintainability: Centralizing type definitions helps in managing changes to these definitions more effectively.
- Correctness: This change should not affect the correctness of the application as long as all references to
PermissionCheckArgsare updated accordingly.- Readability: Having a central location for types improves the readability and organization of the codebase.
This change is approved as it enhances the project structure and maintainability.
packages/runtime/src/enhancements/edge/password.ts (2)
Line range hint
12-17: FunctionwithPasswordimplementation is correct.The function correctly sets up a proxy for handling password attributes in a Prisma client, using appropriate generics and type constraints.
Line range hint
22-49: Review the use of dynamic hash function import and approve password preprocessing logic.The dynamic import of
hashFuncbased on the runtime environment (EdgeRuntime) should be reviewed for security implications, especially considering the different behavior in environments like Vercel Edge. The logic inpreprocessWritePayloadfor hashing passwords is correctly implemented, considering configurable salt and handling password fields appropriately.Consider a security review for the dynamic import of
hashFuncto ensure it meets security standards across different environments.packages/runtime/src/enhancements/node/types.ts (1)
Line range hint
2-264: Enhanced type safety and alignment with PR objectives.The updates to the import statements and the introduction of
PermissionCheckArgsenhance type safety and clarify the API for permission checks. These changes are well-aligned with the PR objectives of improving error handling and introducing new functionalities related to the tRPC framework. The shift from a validation-centric approach to a permission-oriented model is a significant improvement.
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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- packages/runtime/src/browser/serialization.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- packages/runtime/src/browser/serialization.ts
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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- packages/ide/jetbrains/CHANGELOG.md (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- packages/ide/jetbrains/CHANGELOG.md
No description provided.