-
-
Notifications
You must be signed in to change notification settings - Fork 93
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
merge dev to main (v2.5.0) #1680
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_projectPath
parameter.The code changes in the
check
function are approved. The function is well-structured and follows best practices.However, the
_projectPath
parameter is not used in the function. Consider removing it to improve code quality.Apply this diff to remove the unused
_projectPath
parameter:-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
SuperJSON
for serialization and deserialization is a good choice, and the customshouldDehydrateQuery
option is a nice addition.A few additional suggestions:
Consider adding a comment to explain the purpose of the
shouldDehydrateQuery
option and why pending queries are also dehydrated.The
staleTime
of 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
client
section 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
Link
components used for external links should havearia-label
attributes 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 thestream
method to theDbOperations
interface.The addition of the
stream
method expands the functionality of theDbOperations
interface, which is consistent with the AI-generated summary.A few suggestions:
- Consider adding documentation or comments to explain the purpose and usage of the
stream
method. 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
beforeEach
hook to avoid duplication across test cases.Consider adding more descriptive names for the
produce
andconsume
functions to better convey their purpose (e.g.,produceEvents
andconsumeEvents
).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.json
is excluded by!**/*.json
packages/ide/jetbrains/package.json
is excluded by!**/*.json
packages/language/package.json
is excluded by!**/*.json
packages/misc/redwood/package.json
is excluded by!**/*.json
packages/plugins/openapi/package.json
is excluded by!**/*.json
packages/plugins/openapi/tests/baseline/rpc-3.0.0.baseline.yaml
is excluded by!**/*.yaml
packages/plugins/openapi/tests/baseline/rpc-3.1.0.baseline.yaml
is excluded by!**/*.yaml
packages/plugins/openapi/tests/baseline/rpc-type-coverage-3.0.0.baseline.yaml
is excluded by!**/*.yaml
packages/plugins/openapi/tests/baseline/rpc-type-coverage-3.1.0.baseline.yaml
is excluded by!**/*.yaml
packages/plugins/swr/package.json
is excluded by!**/*.json
packages/plugins/tanstack-query/package.json
is excluded by!**/*.json
packages/plugins/trpc/package.json
is excluded by!**/*.json
packages/plugins/trpc/tests/projects/t3-trpc-v11/package-lock.json
is excluded by!**/package-lock.json
,!**/*.json
packages/plugins/trpc/tests/projects/t3-trpc-v11/package.json
is excluded by!**/*.json
packages/plugins/trpc/tests/projects/t3-trpc-v11/public/favicon.ico
is excluded by!**/*.ico
,!**/*.ico
packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/routers/generated/client/react.ts
is excluded by!**/generated/**
packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/routers/generated/client/utils.ts
is excluded by!**/generated/**
packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/routers/generated/helper.ts
is excluded by!**/generated/**
packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/routers/generated/routers/Post.router.ts
is excluded by!**/generated/**
packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/routers/generated/routers/User.router.ts
is excluded by!**/generated/**
packages/plugins/trpc/tests/projects/t3-trpc-v11/src/server/api/routers/generated/routers/index.ts
is excluded by!**/generated/**
packages/plugins/trpc/tests/projects/t3-trpc-v11/tsconfig.json
is excluded by!**/*.json
packages/runtime/package.json
is excluded by!**/*.json
packages/schema/package.json
is excluded by!**/*.json
packages/sdk/package.json
is excluded by!**/*.json
packages/server/package.json
is excluded by!**/*.json
packages/testtools/package.json
is excluded by!**/*.json
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
,!**/*.yaml
tests/integration/test-run/package.json
is excluded by!**/*.json
tests/integration/tests/frameworks/nextjs/test-project/package.json
is excluded by!**/*.json
tests/integration/tests/frameworks/trpc/test-project/package.json
is 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
globalThis
to ensure that only one instance is created.- Enabling logging based on the
NODE_ENV
.- Using a custom
env
module.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
appRouter
is correctly created using thecreateRouter
function and theAppRouter
type is correctly exported as the type ofappRouter
.
14-21
: LGTM!The
createCaller
function is correctly created using thecreateCallerFactory
function and is correctly exported. The JSDoc comment provides a clear example of how to use thecreateCaller
function.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
metadata
object is correctly defined and follows the Next.js conventions.
14-24
: LGTM!The
RootLayout
component is correctly implemented and follows the React best practices. The usage ofTRPCReactProvider
and 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
createContext
function correctly wraps thecreateTRPCContext
helper and provides the required context for tRPC calls from React Server Components. The custom headerx-trpc-source
is set torsc
to indicate the source of the tRPC call.
24-25
: LGTM!The
getQueryClient
andcaller
variables are correctly set up to create a query client and a caller for the tRPC API. ThecreateQueryClient
andcreateCaller
functions are used appropriately.
27-30
: LGTM!The exported
api
andHydrateClient
variables are correctly set up using thecreateHydrationHelpers
function from the@trpc/react-query/rsc
package. Thecaller
andgetQueryClient
functions are passed as arguments to enable hydration of tRPC queries in React Server Components. TheAppRouter
type 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
enhance
function 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
createContext
function is correctly implemented to provide the required context for the tRPC API.
18-32
: LGTM!The
handler
function is correctly implemented to handle HTTP requests for the/api/trpc
endpoint.
34-34
: LGTM!The export statement is correctly used to export the
handler
function for bothGET
andPOST
methods.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-eslint
parser for parsing TypeScript code.- It enables type checking by setting
parserOptions.project
totrue
.- 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
Decimal
fromdecimal.js-light
instead ofdecimal.js
is approved.
8-11
: LGTM!The updated
isApplicable
method that checks if the valuev
is an instance ofDecimal
or if it has atoStringTag
property equal to'[object Decimal]'
is approved. This change improves interoperability with objects from thedecimal.js
library 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
DeepOverride
type definition looks good and handles the recursive merging correctly.
24-32
: LGTM!The
DeepOverrideAtPath
type 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 v11
is 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
createEnv
function from@t3-oss/env-nextjs
to 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
HydrateClient
import suggests that the component is using tRPC for data fetching, which is a valid approach.
37-37
: LGTM!The use of
'force-dynamic'
for thedynamic
export 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
ValidationError
to 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
transformError
function 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
loadSchema
function 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
loadSchema
function 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
loadSchema
function 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
LatestPost
component that fetches the latest post using bothuseQuery
anduseSuspenseQuery
hooks. TheuseSuspenseQuery
hook 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.findMany
to fetch posts using theuseInfiniteQuery
hook. ThegetNextPageParam
option is used correctly to fetch the next page of posts. The code changes are approved.
39-46
: LGTM!The code segment uses
api.useUtils
to get the utils object and defines acreatePost
mutation usingapi.post.create.useMutation
. TheonSuccess
callback is used correctly to invalidate thepost
query and reset thename
state. The code changes are approved.
48-78
: LGTM!The code segment returns JSX for the
LatestPost
component. 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
getQueryClient
function is correctly implemented using the singleton pattern to create a query client in the browser. The function correctly uses thecreateQueryClient
function from the./query-client
module.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
api
constant is correctly exported and created using thecreateTRPCReact
function from the../server/api/routers/generated/client/react
module. ThecreateTRPCReact
function is correctly typed with theAppRouter
type from the~/server/api/root
module.
25-30
: LGTM!The
RouterInputs
type is correctly defined and exported using theinferRouterInputs
function from the@trpc/server
library. TheinferRouterInputs
function is correctly typed with theAppRouter
type from the~/server/api/root
module.
32-37
: LGTM!The
RouterOutputs
type is correctly defined and exported using theinferRouterOutputs
function from the@trpc/server
library. TheinferRouterOutputs
function is correctly typed with theAppRouter
type from the~/server/api/root
module.
39-70
: LGTM!The
TRPCReactProvider
component is correctly implemented using thegetQueryClient
function to create a query client, theuseState
hook to create a tRPC client, theapi
constant to create a tRPC client, theloggerLink
andunstable_httpBatchStreamLink
functions from the@trpc/client
library to create a tRPC client, theSuperJSON
library for serialization, thegetBaseUrl
function to get the base URL for the tRPC client, theQueryClientProvider
component from the@tanstack/react-query
library to provide the query client to the child components, and theapi.Provider
component to provide the tRPC client to the child components.
72-76
: LGTM!The
getBaseUrl
function is correctly implemented using thewindow.location.origin
property to get the base URL in the browser, theVERCEL_URL
environment variable to get the base URL in a Vercel environment, and thePORT
environment 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
Options
type are approved. The addition of thewithPlugins
andwithoutPlugins
properties provides more control over plugin management during the execution of the CLI actions.
63-70
: LGTM!The changes to the
runPlugins
function are approved. The iteration over the combined list of plugins from bothwithPlugins
andwithoutPlugins
, 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
PluginRunnerOptions
object are approved. The inclusion of thewithPlugins
andwithoutPlugins
properties ensures that the specified plugin options are passed to thePluginRunner
for execution.
2-2
: LGTM!The change to the import statement is approved. Importing the
isPlugin
function from@zenstackhq/sdk/ast
ensures 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
processResultEntity
method 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
data
parameter 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
action
values 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
createManyAndReturn
method 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
createTRPCContext
function 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
superjson
and parsing ofZodError
s 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
timingMiddleware
is a useful addition for catching unwanted waterfalls by simulating network latency in development. ThepublicProcedure
function 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
getPluginCustomOutputFolder
looks 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
checkAction
function is implemented correctly and follows the same pattern as other action functions in the file.
123-124
: LGTM!The new
--with-plugins
and--without-plugins
options are correctly added to thegenerate
command and provide additional flexibility to users.
146-150
: LGTM!The new
check
command is correctly added to the program and linked to thecheckAction
function.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
loadSchema
function from@zenstackhq/testtools
to load the schema and theenhance
function to create a database client. It is using thecreate
andupdate
methods to create and update data and theexpect
function 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 themessage
variable.The change removes the leading comma from the string interpolation, improving the formatting of the
message
variable.
228-229
: Introduced a newpath
variable for validation refinements.The change introduces a new
path
variable to specify the path for validation refinements:
- It retrieves the 'path' attribute using the
getAttributeArg
function.- It checks if the attribute is an array expression using the
isArrayExpr
function.- 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 newoptions
variable to encapsulatemessage
andpath
.The change introduces a new
options
variable that encapsulates both themessage
andpath
variables, formatted as an object. This modifies the output structure of the refinement function.
245-245
: Modified the return statement to use the newoptions
variable.The change modifies the return statement of the function by replacing the previous concatenation of
message
with the newoptions
variable. This alters the output structure of the refinement function to include both themessage
andpath
options.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
stream
method to thePrismaProxyHandler
interface is approved. It appropriately extends the interface to support streaming operations.
196-196
: LGTM!The addition of the
_method
parameter to theprocessResultEntity
method 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
_method
parameter to thepreprocessArgs
method is approved. It enables flexibility to customize argument preprocessing per Prisma method if required in the future.
166-190
: LGTM!The refactoring of the
subscribe
method to call the newdoSubscribeStream
method is approved. ThedoSubscribeStream
method consolidates the logic for handling bothsubscribe
andstream
operations effectively.It appropriately processes the async iterable returned by Prisma's methods and wraps the iteration results using
processResultEntity
for 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
loadDocument
function are approved:
- The new optional parameter
validateOnly
allows 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
validateOnly
parameter immediately after the model is parsed.- If
validateOnly
is 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
generateRouterTyping
function look good:
- The addition of the
version
parameter 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
generateRouterTypingImports
function look good:
- The addition of the
version
parameter 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
withPlugins
andwithoutPlugins
properties to thePluginRunnerOptions
type enhances the flexibility of the plugin system by enabling more granular control over which plugins are activated.
142-152
: LGTM!The addition of the
isCorePlugin
parameter to therunPlugin
method 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
runPlugin
method, which pass theisCorePlugin
parameter to theisPluginEnabled
method, are consistent with the previous modifications and ensure that theisPluginEnabled
method receives the necessary information to determine whether a plugin should be executed.
205-206
: LGTM!The simplification of the logic in the
calculateAllPlugins
method ensures that core plugins are always included when thedefaultPlugins
option is set to true, improving the consistency of the plugin management system.
239-240
: LGTM!The changes to the
calculateAllPlugins
method improve the consistency and reliability of the plugin management system by ensuring that the@core/zod
plugin is enabled when necessary, based on the presence of the@core/enhancer
plugin and validation rules.
344-345
: LGTM!The addition of the
project
parameter to therunPlugin
method and the corresponding changes to pass theproject
object to therun
function allow plugins to access and modify the project's source files and configuration.
347-350
: LGTM!The changes to the
runPlugin
method, 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
title
constant and its usage in theora
spinner 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
isPluginEnabled
method 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
version
variable 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
createRouter
function based on the tRPC version are approved.
257-280
: LGTM!The code changes to update the
createClientHelpers
function 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
path
parameter to the@@validate
attribute 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
: ThegetZodImport
method 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 path
is well-structured and covers various scenarios to validate the refinement conditions on the array field. It uses thesafeParse
method to check for specific validation errors and thepath
option to specify the error paths. The test expectations are clearly defined and match the corresponding validation rules.
791-794
: Configuration for the newenhancer
plugin looks good.The
enhancer
plugin 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 thegetPrismaOnly
andgenerateNoCompile
options.The
loadSchema
function call is updated with thegetPrismaOnly
andgenerateNoCompile
options. 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
: Theenhancer
plugin is properly included in the test configuration.The
enhancer
plugin 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
stripFutureCall
method looks good:
- It correctly handles the case when
fieldAccess
is 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
writeRelationCheck
method look good:
- Using a constant
false
for'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
_Meta
schema definition look good:
- Adding a
description
property enhances clarity.- Removing the nested
meta
object and directly including theserialization
property 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
fieldInfo
is falsy looks good. It prevents accessing properties onundefined
and skips further processing for that field.
160-169
: LGTM!The changes to the delegate model handling logic look good:
- Checking if
fieldInfo.type
is 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 oftrue
to 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
buildReadGuardForFields
method now handles injecting read guards for both relation and regular fields, improving code maintainability.
Line range hint
489-534
: Approved: ThebuildReadGuardForFields
method 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 generalizedbuildReadGuardForFields
method.The code now uses the
buildReadGuardForFields
method 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_FAILED
toCONSTRAINT_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
subscribe
andstream
methods to delegate their functionality to the newhandleSubscribeStream
method 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
showNotification
function is implemented correctly:
- It fetches the configuration data using the
fetch
API with a timeout for better reliability.- The fetched data is validated against a defined
zod
schema 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.json
is excluded by!**/*.json
pnpm-lock.yaml
is 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
loadDocument
function are approved:
- The new optional
validateOnly
parameter 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
validateOnly
and 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
ensureDefaultOutputFolder
function 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
getDefaultOutputFolder
function 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 tocreateEnhancement
and suggest documenting API changes.The modifications to
createEnhancement
reflect 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.json
is excluded by!**/*.json
packages/runtime/package.json
is excluded by!**/*.json
packages/server/package.json
is excluded by!**/*.json
pnpm-lock.yaml
is 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
./enhancements
to./cross
needs 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
Home
component enhance both the structure and functionality:
- Data Transformation: The update in the
postsTransformed
query to include theid
alongside thetitle
improves data handling and is crucial for any operations that might manipulate or reference specific posts.- Rendering Logic: Adding
key
attributes 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
getLiteral
andisPlugin
are 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
getNodeModulesFolder
function 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
: FunctionwithDefaultAuth
is 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
: ClassDefaultAuthHandler
is 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 inDefaultPrismaProxyHandler
are well-implemented.The centralization of stream handling into
doSubscribeStream
and the explicit inclusion of the method name inprocessResultEntity
enhance clarity and maintainability. The newstream
method is correctly implemented to handle asynchronous data streams.packages/schema/src/plugins/enhancer/policy/policy-guard-generator.ts (1)
103-112
: Updated import paths inPolicyGenerator
are correctly implemented.The changes in import paths for
allFieldsEqual
,PolicyDef
, andPermissionCheckerConstraint
reflect 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
DelegateProxyHandler
class has been significantly altered. The original check forfieldInfo
has been inverted, which now continues to the next iteration iffieldInfo
is not found. This change emphasizes the importance offieldInfo
in 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.type
is 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 theinjectSelectIncludeHierarchy
method. 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
../../constants
and../../cross
to../../../constants
and../../../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_FAILED
has 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
injectReadGuardForRelationFields
tobuildReadGuardForFields
and 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
subscribe
andstream
methods to use a shared methodhandleSubscribeStream
is 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
args
is provided and sets default values if not. It also validates thatargs
is 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
check
method by delegating the permission checking to thecheckPermission
function is a good practice. It reduces the complexity within thePolicyProxyHandler
class and isolates permission checking to a dedicated function, enhancing both maintainability and testability.
- Correctness: Assuming
checkPermission
is correctly implemented, this change should maintain the correctness of permission checks.- Maintainability: Reducing the complexity of the
check
method by offloading detailed logic tocheckPermission
makes the class cleaner and easier to understand.- Security: As long as
checkPermission
handles all security checks robustly, this change does not introduce new security concerns.This change is approved, provided that
checkPermission
is 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
PermissionCheckArgs
from the local scope to reference it from thetypes
module 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
PermissionCheckArgs
are 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
: FunctionwithPassword
implementation 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
hashFunc
based on the runtime environment (EdgeRuntime
) should be reviewed for security implications, especially considering the different behavior in environments like Vercel Edge. The logic inpreprocessWritePayload
for hashing passwords is correctly implemented, considering configurable salt and handling password fields appropriately.Consider a security review for the dynamic import of
hashFunc
to 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
PermissionCheckArgs
enhance 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.