-
-
Notifications
You must be signed in to change notification settings - Fork 90
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.4.0) #1635
Conversation
…ithout user context (#1618)
…alidating update input (#1625)
…xplicitly configured in ZModel (#1632)
… from its origin (#1633)
Co-authored-by: Yiming <[email protected]> Co-authored-by: ymc9 <[email protected]>
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-expect
can 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
, andzodSchemas
are still being used in various parts of the codebase, including tests and other packages. Their removal frompackages/testtools/src/schema.ts
might affect the logic in those places.
packages/testtools/src/schema.ts
: Lines wherepolicy
,modelMeta
, andzodSchemas
were 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
, andzodSchemas
from 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
values
could 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.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/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/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
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=hoisted
specifies 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 PrismaClient
enhances 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: true
improves 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
shortNameMap
parameter is correctly passed and utilized within thegenerateModelMeta
function.Verification successful
The
shortNameMap
parameter is correctly utilized within thewriteShortNameMap
function.
- The
writeShortNameMap
function checks for the presence ofshortNameMap
in 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
: ModelVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongModelNameA
looks good.The model is correctly defined and integrated.
52-54
: ModelVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongModelNameB
looks 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.output
orglobalOptions?.output
enhances the flexibility in specifying the output path.
31-31
: Verify the correctness of path resolution.Ensure that the path resolution using
outDir
is correct and does not introduce any issues.Verification successful
Path resolution using
outDir
is correctly implemented.The
resolvePath
function ensures that theoutDir
is correctly resolved relative to the directory ofoptions.schemaPath
if it is not an absolute path.
resolvePath
implementation inpackages/sdk/src/utils.ts
correctly 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
shortNameMap
property enhances the functionality ofPluginOptions
by providing a mechanism for name abbreviation.
82-87
: Enhanced functionality withshortNameMap
.The addition of the optional
shortNameMap
property enhances the functionality ofPluginResult
by 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
reduce
function ensures various query reduction scenarios are handled correctly.packages/runtime/src/cross/model-meta.ts (1)
164-168
: LGTM! The addition ofshortNameMap
is straightforward.The new property
shortNameMap
is 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 ofPluginOptions
improves type safety.The explicit import and utilization of
PluginOptions
ensures that the options passed to thePrismaSchemaGenerator
are correctly typed.
78-78
: LGTM! The expansion of the return value enhances functionality.The inclusion of
shortNameMap
in the returned object from therun
function 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
prismaClientValidationError
instead of a genericError
is approved.However, ensure that
prismaClientValidationError
is used correctly and consistently throughout the codebase.Verification successful
LGTM!
The change to throw
prismaClientValidationError
instead of a genericError
is approved. The usage ofprismaClientValidationError
is consistent and correct throughout the codebase.
- Verified in the following files:
packages/runtime/src/enhancements/default-auth.ts
packages/runtime/src/enhancements/query-utils.ts
packages/runtime/src/enhancements/delegate.ts
packages/runtime/src/enhancements/policy/handler.ts
Scripts 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
normalizePath
to ensure POSIX path separators inpackage.json
improves 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-generate
in thepushDb
command can improve performance by preventing the generation of client code during the push.packages/schema/src/cli/plugin-runner.ts (3)
148-151
: EnsureshortNameMap
is updated correctly.The code correctly updates
shortNameMap
if it is returned by the plugin.
321-321
: UpdaterunPlugin
method signature.The method signature now includes
shortNameMap
, which is necessary for the plugin execution.
336-340
: IncludeshortNameMap
in plugin options.The
shortNameMap
is correctly included in the options passed to the plugin's run function.packages/sdk/src/model-meta-generator.ts (3)
57-61
: AddshortNameMap
toModelMetaGeneratorOptions
.The addition of
shortNameMap
enhances the flexibility of handling extra fields and relations.
92-92
: CallwriteShortNameMap
ingenerateModelMetadata
.The function correctly integrates the call to
writeShortNameMap
to handle theshortNameMap
option.
540-550
: AddwriteShortNameMap
function.The function correctly handles the
shortNameMap
option, 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
omitDiscriminators
variable to exclude discriminator fields from mutation schemas.
440-440
: UseomitDiscriminators
inprismaCreateSchema
.The
prismaCreateSchema
correctly incorporates theomitDiscriminators
variable to exclude discriminator fields.
456-456
: Filter out discriminator fields inprismaUpdateSchema
.The
prismaUpdateSchema
correctly filters out discriminator fields, ensuring they are not included in updates.
481-481
: UseomitDiscriminators
increateSchema
.The
createSchema
correctly incorporates theomitDiscriminators
variable to exclude discriminator fields.packages/schema/src/plugins/enhancer/enhance/index.ts (8)
10-10
: EnsureisDiscriminatorField
is used correctly.Verify that
isDiscriminatorField
is used appropriately in the code to handle discriminator fields.
130-132
: LGTM!The addition of
PrismaClient
to the exports is correct and necessary.
156-156
: LGTM!The addition of
PrismaClient
to 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
ModelCreateUpdateInputRegex
property is correct and improves maintainability.
506-529
: LGTM!The use of the class property
ModelCreateUpdateInputRegex
improves maintainability.
546-548
: LGTM!The addition of the
CreateUpdateWithoutDelegateRelationRegex
property is correct and improves maintainability.
Line range hint
549-560
:
LGTM!The use of the class property
CreateUpdateWithoutDelegateRelationRegex
improves 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
create
andupdate
methods are correct and necessary.
952-952
: LGTM!The changes to the validation logic for the
update
method 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
isDiscriminatorField
function properly identifies discriminator fields and that thefields
variable is correctly updated.packages/schema/src/plugins/prisma/schema-generator.ts (3)
163-163
: Ensure theshortNameMap
is correctly populated.The
shortNameMap
now maps full names to shortened names. Verify that the map is correctly populated and used throughout the codebase.
321-321
: Verify thetruncate
method usage.The
truncate
method 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 thetruncate
method usage.The
truncate
method 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 theskipLibCheck
option is necessary.Setting
skipLibCheck
totrue
can 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
shortNameMap
is correctly populated and used throughout the codebase.Verification successful
Let's re-run the search for
shortNameMap
without specifying the file type to ensure we capture all relevant occurrences in the codebase.
LGTM!
The
shortNameMap
is correctly populated and used throughout the codebase, enhancing the functionality by allowing for more flexible name resolution.
packages/runtime/src/enhancements/delegate.ts
packages/schema/src/cli/plugin-runner.ts
packages/schema/src/plugins/prisma/schema-generator.ts
packages/sdk/src/types.ts
packages/sdk/src/model-meta-generator.ts
packages/runtime/src/cross/model-meta.ts
Scripts 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! ThesingleKey
method correctly handles null and undefined values.The changes ensure that the method returns
false
fornull
andundefined
values, improving robustness.
119-144
: LGTM! TheisTrue
method correctly handles null, undefined, and non-plain objects.The changes ensure that the method returns
false
for these cases and includes comprehensive checks for various conditions.
147-167
: LGTM! TheisFalse
method correctly handles null, undefined, and non-plain objects.The changes ensure that the method returns
false
for these cases and includes comprehensive checks for various conditions.packages/server/src/api/rest/index.ts (2)
1537-1537
: Ensureop
isundefined
check is necessary.The check for
op
beingundefined
is 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
buildFilter
andbuildSort
methods 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.