-
-
Couldn't load subscription status.
- Fork 126
merge dev to main (v2.4.0) #1635
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 recent changes enhance the project's overall functionality and maintainability by introducing new configurations, updating existing versions, and refining code structures across multiple files. Key updates include the addition of a Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant System
participant Database
User->>System: Request to create a user
System->>Database: Validate user data
Database-->>System: Return validation result
alt Validation successful
System->>Database: Create user record
Database-->>System: Confirm user created
System-->>User: Respond with success
else Validation failed
System-->>User: Respond with error
end
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 as PR comments)
Additionally, you can add 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: 2
Outside diff range, codebase verification and nitpick comments (3)
tests/regression/tests/issue-1596.test.ts (1)
27-30: Consider restructuring the test to avoid the ESLint directive.The ESLint directive
// eslint-disable-next-line jest/no-conditional-expectcan be avoided by restructuring the test to useawait expect(...).rejects.toThrow(...).- try { - await db.post.create({ data: { title: 'Post1' } }); - } catch (e) { - // eslint-disable-next-line jest/no-conditional-expect - expect(isPrismaClientValidationError(e)).toBe(true); - return; - } - throw new Error('Expected error'); + await expect(db.post.create({ data: { title: 'Post1' } })) + .rejects + .toThrow(expect.objectContaining({ + name: 'PrismaClientValidationError' + }));packages/testtools/src/schema.ts (1)
240-240: Verify the impact of removed parameters.The parameters
policy,modelMeta, andzodSchemasare still being used in various parts of the codebase, including tests and other packages. Their removal frompackages/testtools/src/schema.tsmight affect the logic in those places.
packages/testtools/src/schema.ts: Lines wherepolicy,modelMeta, andzodSchemaswere previously used.Please review these locations to ensure that the removal of these parameters does not affect the subsequent logic.
Analysis chain
Verify the impact of removed parameters.
The removal of
policy,modelMeta, andzodSchemasfrom the object destructuring suggests a simplification of the logic. Ensure that these parameters are no longer necessary for the subsequent logic.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the impact of the removed parameters `policy`, `modelMeta`, and `zodSchemas`. # Test: Search for the usage of `policy`, `modelMeta`, and `zodSchemas` in the codebase. Expect: No longer necessary for the logic. rg --type ts 'policy|modelMeta|zodSchemas'Length of output: 91911
packages/server/src/api/rest/index.ts (1)
1544-1544: Use descriptive variable names.The variable
valuescould be more descriptive to indicate its purpose, such ascoercedValues.- return values.length > 1 ? { in: values } : { equals: values[0] }; + return coercedValues.length > 1 ? { in: coercedValues } : { equals: coercedValues[0] };
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (14)
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/swr/package.jsonis excluded by!**/*.jsonpackages/plugins/tanstack-query/package.jsonis excluded by!**/*.jsonpackages/plugins/trpc/package.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,!**/*.yaml
Files selected for processing (38)
- .npmrc (1 hunks)
- packages/ide/jetbrains/build.gradle.kts (1 hunks)
- packages/misc/redwood/src/commands/setup.ts (4 hunks)
- packages/plugins/trpc/src/project.ts (1 hunks)
- packages/runtime/jest.config.ts (1 hunks)
- packages/runtime/res/enhance.d.ts (1 hunks)
- packages/runtime/src/cross/model-meta.ts (1 hunks)
- packages/runtime/src/enhancements/default-auth.ts (2 hunks)
- packages/runtime/src/enhancements/delegate.ts (1 hunks)
- packages/runtime/src/enhancements/policy/policy-utils.ts (5 hunks)
- packages/runtime/tests/policy/reduction.test.ts (1 hunks)
- packages/schema/README.md (1 hunks)
- packages/schema/src/cli/plugin-runner.ts (6 hunks)
- packages/schema/src/plugins/enhancer/enhance/index.ts (8 hunks)
- packages/schema/src/plugins/enhancer/index.ts (1 hunks)
- packages/schema/src/plugins/enhancer/model-meta/index.ts (1 hunks)
- packages/schema/src/plugins/prisma/index.ts (3 hunks)
- packages/schema/src/plugins/prisma/schema-generator.ts (9 hunks)
- packages/schema/src/plugins/zod/generator.ts (7 hunks)
- packages/schema/src/plugins/zod/transformer.ts (2 hunks)
- packages/schema/src/res/stdlib.zmodel (1 hunks)
- packages/schema/tests/generator/expression-writer.test.ts (1 hunks)
- packages/sdk/src/model-meta-generator.ts (4 hunks)
- packages/sdk/src/types.ts (2 hunks)
- packages/server/src/api/rest/index.ts (1 hunks)
- packages/server/tests/api/rest.test.ts (1 hunks)
- packages/testtools/src/schema.ts (2 hunks)
- tests/integration/tests/enhancements/with-delegate/enhanced-client.test.ts (1 hunks)
- tests/integration/tests/enhancements/with-delegate/plugin-interaction.test.ts (1 hunks)
- tests/integration/tests/enhancements/with-delegate/utils.ts (1 hunks)
- tests/integration/tests/enhancements/with-policy/field-validation.test.ts (2 hunks)
- tests/regression/tests/issue-1466.test.ts (2 hunks)
- tests/regression/tests/issue-1551.test.ts (1 hunks)
- tests/regression/tests/issue-1562.test.ts (1 hunks)
- tests/regression/tests/issue-1563.test.ts (1 hunks)
- tests/regression/tests/issue-1596.test.ts (1 hunks)
- tests/regression/tests/issue-1610.test.ts (1 hunks)
- tests/regression/tests/issue-1627.test.ts (1 hunks)
Files skipped from review due to trivial changes (3)
- packages/ide/jetbrains/build.gradle.kts
- packages/runtime/jest.config.ts
- tests/regression/tests/issue-1466.test.ts
Additional comments not posted (62)
.npmrc (1)
3-3: New configuration added:node-linker=hoisted.The addition of
node-linker=hoistedspecifies the linking strategy for Node.js modules, potentially improving compatibility and reducing issues related to module resolution.packages/runtime/res/enhance.d.ts (1)
1-1: New export added:type PrismaClient.The addition of
type PrismaClientenhances the module's interface, facilitating better type-checking and integration with Prisma ORM.packages/plugins/trpc/src/project.ts (1)
9-9: New property added:skipLibCheck.The addition of
skipLibCheck: trueimproves compilation speed and reduces errors related to type definitions in third-party libraries.packages/schema/src/plugins/enhancer/model-meta/index.ts (1)
16-16: Verify the usage of the new parametershortNameMap.Ensure that the
shortNameMapparameter is correctly passed and utilized within thegenerateModelMetafunction.Verification successful
The
shortNameMapparameter is correctly utilized within thewriteShortNameMapfunction.
- The
writeShortNameMapfunction checks for the presence ofshortNameMapin the options and correctly writes its entries.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the new parameter `shortNameMap` in the `generateModelMeta` function. # Test: Search for the function implementation. Expect: Correct handling of the `shortNameMap` parameter. rg --type ts -A 10 $'function generateModelMeta'Length of output: 884
Script:
#!/bin/bash # Description: Verify the implementation of the `writeShortNameMap` function to ensure it handles the `shortNameMap` parameter correctly. # Search for the implementation of the `writeShortNameMap` function. rg --type ts 'function writeShortNameMap'Length of output: 174
Script:
#!/bin/bash # Description: Extract the full implementation of the `writeShortNameMap` function to verify the usage of the `shortNameMap` parameter. # Extract the full implementation of the `writeShortNameMap` function. rg --type ts -A 20 'function writeShortNameMap' packages/sdk/src/model-meta-generator.tsLength of output: 491
tests/regression/tests/issue-1551.test.ts (1)
1-25: LGTM! Ensure the test case execution.The test case correctly loads the schema and verifies the regression scenario for issue 1551.
However, ensure that the test case is executed and passes successfully.
tests/regression/tests/issue-1563.test.ts (1)
1-29: LGTM! Ensure the test case execution.The test case correctly loads the schema and verifies the regression scenario for issue 1563.
However, ensure that the test case is executed and passes successfully.
tests/regression/tests/issue-1562.test.ts (1)
1-44: LGTM!The test case is well-structured and effectively validates the policy rejection.
tests/regression/tests/issue-1627.test.ts (1)
1-49: LGTM!The test case is well-structured and effectively validates the handling of gym memberships.
packages/schema/README.md (1)
3-3: Improved clarity and appeal.The rephrased description accurately reflects the functionality and value proposition of the toolkit.
tests/regression/tests/issue-1610.test.ts (3)
3-18: Test case for regular Prisma client looks good.The schema is correctly defined and the test case is properly implemented.
21-36: Test case for logical Prisma client looks good.The schema is correctly defined and the test case is properly implemented.
39-54: Test case for no custom output looks good.The schema is correctly defined and the test case is properly implemented.
tests/integration/tests/enhancements/with-delegate/utils.ts (2)
48-50: ModelVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongModelNameAlooks good.The model is correctly defined and integrated.
52-54: ModelVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongModelNameBlooks good.The model is correctly defined and integrated.
packages/schema/src/plugins/enhancer/index.ts (2)
27-29: Enhanced flexibility in output path specification.The updated conditional check for
options.outputorglobalOptions?.outputenhances the flexibility in specifying the output path.
31-31: Verify the correctness of path resolution.Ensure that the path resolution using
outDiris correct and does not introduce any issues.Verification successful
Path resolution using
outDiris correctly implemented.The
resolvePathfunction ensures that theoutDiris correctly resolved relative to the directory ofoptions.schemaPathif it is not an absolute path.
resolvePathimplementation inpackages/sdk/src/utils.tscorrectly handles both absolute and relative paths.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the correctness of path resolution using `outDir`. # Test: Search for the usage of `outDir` and ensure it is correctly resolved. rg --type python -A 5 $'outDir'Length of output: 61
Script:
#!/bin/bash # Description: Verify the correctness of path resolution using `outDir` in TypeScript files. # Test: Search for the usage of `outDir` in TypeScript files and ensure it is correctly resolved. rg --type ts -A 5 'outDir'Length of output: 21561
Script:
#!/bin/bash # Description: Verify the implementation of `resolvePath` used for resolving `outDir`. # Test: Search for the definition and implementation of `resolvePath`. rg 'function resolvePath' -A 10Length of output: 724
packages/sdk/src/types.ts (2)
33-38: Enhanced functionality withshortNameMap.The addition of the optional
shortNameMapproperty enhances the functionality ofPluginOptionsby providing a mechanism for name abbreviation.
82-87: Enhanced functionality withshortNameMap.The addition of the optional
shortNameMapproperty enhances the functionality ofPluginResultby providing a mechanism for name abbreviation.packages/runtime/tests/policy/reduction.test.ts (1)
1-67: Comprehensive test cases for query reduction.The addition of comprehensive test cases for the
reducefunction ensures various query reduction scenarios are handled correctly.packages/runtime/src/cross/model-meta.ts (1)
164-168: LGTM! The addition ofshortNameMapis straightforward.The new property
shortNameMapis an optionalRecord<string, string>which enhances the metadata capabilities of the model.packages/schema/src/plugins/prisma/index.ts (2)
1-1: LGTM! Explicit import ofPluginOptionsimproves type safety.The explicit import and utilization of
PluginOptionsensures that the options passed to thePrismaSchemaGeneratorare correctly typed.
78-78: LGTM! The expansion of the return value enhances functionality.The inclusion of
shortNameMapin the returned object from therunfunction enhances the usability or functionality of the generated Prisma schema.tests/integration/tests/enhancements/with-delegate/plugin-interaction.test.ts (1)
59-147: LGTM! The new test case enhances schema validation.The new test case for validating various Zod schemas related to
Asset,Video, and their respective creation and update operations enhances the robustness of the schema validation process.packages/runtime/src/enhancements/default-auth.ts (1)
153-157: LGTM! But verify the usage ofprismaClientValidationError.The change to throw
prismaClientValidationErrorinstead of a genericErroris approved.However, ensure that
prismaClientValidationErroris used correctly and consistently throughout the codebase.Verification successful
LGTM!
The change to throw
prismaClientValidationErrorinstead of a genericErroris approved. The usage ofprismaClientValidationErroris consistent and correct throughout the codebase.
- Verified in the following files:
packages/runtime/src/enhancements/default-auth.tspackages/runtime/src/enhancements/query-utils.tspackages/runtime/src/enhancements/delegate.tspackages/runtime/src/enhancements/policy/handler.tsScripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `prismaClientValidationError` in the codebase. # Test: Search for the usage of `prismaClientValidationError`. Expect: Consistent usage across the codebase. rg --type ts 'prismaClientValidationError'Length of output: 7903
packages/misc/redwood/src/commands/setup.ts (2)
51-52: LGTM!The use of
normalizePathto ensure POSIX path separators inpackage.jsonimproves cross-platform compatibility.
153-157: LGTM!The logic to determine the correct module to import based on the installed version of Redwood enhances flexibility and compatibility.
packages/testtools/src/schema.ts (1)
240-240: LGTM!The modification to include
--skip-generatein thepushDbcommand can improve performance by preventing the generation of client code during the push.packages/schema/src/cli/plugin-runner.ts (3)
148-151: EnsureshortNameMapis updated correctly.The code correctly updates
shortNameMapif it is returned by the plugin.
321-321: UpdaterunPluginmethod signature.The method signature now includes
shortNameMap, which is necessary for the plugin execution.
336-340: IncludeshortNameMapin plugin options.The
shortNameMapis correctly included in the options passed to the plugin's run function.packages/sdk/src/model-meta-generator.ts (3)
57-61: AddshortNameMaptoModelMetaGeneratorOptions.The addition of
shortNameMapenhances the flexibility of handling extra fields and relations.
92-92: CallwriteShortNameMapingenerateModelMetadata.The function correctly integrates the call to
writeShortNameMapto handle theshortNameMapoption.
540-550: AddwriteShortNameMapfunction.The function correctly handles the
shortNameMapoption, formatting and writing the mappings if they exist.packages/schema/src/plugins/zod/generator.ts (4)
372-378: Handle discriminator fields ingenerateModelSchema.The function correctly integrates the
omitDiscriminatorsvariable to exclude discriminator fields from mutation schemas.
440-440: UseomitDiscriminatorsinprismaCreateSchema.The
prismaCreateSchemacorrectly incorporates theomitDiscriminatorsvariable to exclude discriminator fields.
456-456: Filter out discriminator fields inprismaUpdateSchema.The
prismaUpdateSchemacorrectly filters out discriminator fields, ensuring they are not included in updates.
481-481: UseomitDiscriminatorsincreateSchema.The
createSchemacorrectly incorporates theomitDiscriminatorsvariable to exclude discriminator fields.packages/schema/src/plugins/enhancer/enhance/index.ts (8)
10-10: EnsureisDiscriminatorFieldis used correctly.Verify that
isDiscriminatorFieldis used appropriately in the code to handle discriminator fields.
130-132: LGTM!The addition of
PrismaClientto the exports is correct and necessary.
156-156: LGTM!The addition of
PrismaClientto the exports is correct and necessary.
489-494: LGTM!The use of the class property for the regex pattern improves maintainability.
502-502: LGTM!The addition of the
ModelCreateUpdateInputRegexproperty is correct and improves maintainability.
506-529: LGTM!The use of the class property
ModelCreateUpdateInputRegeximproves maintainability.
546-548: LGTM!The addition of the
CreateUpdateWithoutDelegateRelationRegexproperty is correct and improves maintainability.
Line range hint
549-560:
LGTM!The use of the class property
CreateUpdateWithoutDelegateRelationRegeximproves maintainability.packages/schema/src/res/stdlib.zmodel (1)
405-408: LGTM!The changes to make the parameters nullable for the attributes related to string types are correct and enhance flexibility.
tests/integration/tests/enhancements/with-policy/field-validation.test.ts (2)
649-651: LGTM!The changes to the validation logic for the
createandupdatemethods are correct and necessary.
952-952: LGTM!The changes to the validation logic for the
updatemethod are correct and necessary.packages/schema/src/plugins/zod/transformer.ts (2)
93-93: Ensure the regex pattern is correct.The regex pattern
/(\S+)(Unchecked)?(Create|Update).*Input/is used to identify create/update input types. Ensure this pattern correctly matches all intended input types.
98-115: Verify the logic for excluding discriminator fields.The logic to exclude discriminator fields from create/update input schemas looks correct. Ensure that the
isDiscriminatorFieldfunction properly identifies discriminator fields and that thefieldsvariable is correctly updated.packages/schema/src/plugins/prisma/schema-generator.ts (3)
163-163: Ensure theshortNameMapis correctly populated.The
shortNameMapnow maps full names to shortened names. Verify that the map is correctly populated and used throughout the codebase.
321-321: Verify thetruncatemethod usage.The
truncatemethod is used to ensure auxiliary relation names conform to the expected naming conventions. Verify that the method correctly truncates names and handles conflicts.
342-342: Verify thetruncatemethod usage.The
truncatemethod is used to ensure relation field names conform to the expected naming conventions. Verify that the method correctly truncates names and handles conflicts.packages/schema/tests/generator/expression-writer.test.ts (1)
1335-1337: Ensure theskipLibCheckoption is necessary.Setting
skipLibChecktotruecan improve performance and reduce compilation errors related to type definitions in external libraries. Ensure this option is necessary and does not hide important type errors.packages/runtime/src/enhancements/delegate.ts (1)
1043-1046: LGTM! Verify the usage ofshortNameMap.The changes enhance the functionality by allowing for more flexible name resolution. Ensure that the
shortNameMapis correctly populated and used throughout the codebase.Verification successful
Let's re-run the search for
shortNameMapwithout specifying the file type to ensure we capture all relevant occurrences in the codebase.
LGTM!
The
shortNameMapis correctly populated and used throughout the codebase, enhancing the functionality by allowing for more flexible name resolution.
packages/runtime/src/enhancements/delegate.tspackages/schema/src/cli/plugin-runner.tspackages/schema/src/plugins/prisma/schema-generator.tspackages/sdk/src/types.tspackages/sdk/src/model-meta-generator.tspackages/runtime/src/cross/model-meta.tsScripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `shortNameMap` in the codebase. # Test: Search for the usage of `shortNameMap`. Expect: Relevant occurrences of `shortNameMap`. rg --type typescript 'shortNameMap'Length of output: 70
Script:
#!/bin/bash # Description: Verify the usage of `shortNameMap` in the codebase. # Test: Search for the usage of `shortNameMap`. Expect: Relevant occurrences of `shortNameMap`. rg 'shortNameMap'Length of output: 2438
tests/integration/tests/enhancements/with-delegate/enhanced-client.test.ts (1)
1199-1241: LGTM!The new test case effectively validates the handling of very long model names in the database, ensuring robustness.
packages/runtime/src/enhancements/policy/policy-utils.ts (3)
111-115: LGTM! ThesingleKeymethod correctly handles null and undefined values.The changes ensure that the method returns
falsefornullandundefinedvalues, improving robustness.
119-144: LGTM! TheisTruemethod correctly handles null, undefined, and non-plain objects.The changes ensure that the method returns
falsefor these cases and includes comprehensive checks for various conditions.
147-167: LGTM! TheisFalsemethod correctly handles null, undefined, and non-plain objects.The changes ensure that the method returns
falsefor these cases and includes comprehensive checks for various conditions.packages/server/src/api/rest/index.ts (2)
1537-1537: Ensureopisundefinedcheck is necessary.The check for
opbeingundefinedis crucial for the new logic. Ensure that this condition is necessary and correctly handled.
1545-1546: Ensure proper handling of filter and sort errors.The method should handle errors from the
buildFilterandbuildSortmethods appropriately. Ensure that these errors are correctly propagated and managed.packages/server/tests/api/rest.test.ts (1)
371-380: Ensure comprehensive test coverage for multi-ID filters.The test case should cover various scenarios, including edge cases such as empty IDs, invalid IDs, and mixed valid/invalid IDs. Ensure that these cases are tested to verify the robustness of the filter handling.
No description provided.