Skip to content

merge dev to main (v1.11.1) #1164

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

Merged
merged 6 commits into from
Mar 20, 2024
Merged

merge dev to main (v1.11.1) #1164

merged 6 commits into from
Mar 20, 2024

Conversation

ymc9
Copy link
Member

@ymc9 ymc9 commented Mar 20, 2024

Summary by CodeRabbit

  • New Features
    • JetBrains IDE plugin: Added support for complex @@index attribute usage and auto-completion inside attributes.
  • Bug Fixes
    • JetBrains IDE plugin: Fixed ZModel validation issues related to model inheritance.
  • Documentation
    • Updated README.md with a new contributor acknowledgment.
  • Chores
    • Updated JetBrains IDE plugin version.
    • Enhanced test framework with normalizePath function for consistent path handling across various test files.
    • Added policy options in error messages and method calls for improved error handling.
    • Introduced flexibility in handling Prisma client errors by allowing custom PrismaClient output path specification.
  • Tests
    • Expanded test cases for policy enforcement and added a test case for database schema manipulation and validation.

Copy link
Contributor

coderabbitai bot commented Mar 20, 2024

Walkthrough

Walkthrough

This update introduces a variety of improvements and bug fixes across the project. Notably, it enhances the JetBrains IDE plugin with new features and fixes, updates the handling of path normalization in several plugins through the use of a normalizePath function, and enhances error handling and policy enforcement in the runtime package. Additionally, a new contributor is acknowledged, and various test enhancements are made to ensure the robustness of these changes.

Changes

File(s) Change Summary
README.md Added new contributor Fabian Jocks to acknowledgments.
packages/ide/jetbrains/CHANGELOG.md Updated with general improvements, support for @@index, and fixes for ZModel validation issues.
packages/ide/jetbrains/build.gradle.kts Updated version from "1.11.0" to "1.11.1".
packages/plugins/.../openapi-restful.test.ts
packages/plugins/.../openapi-rpc.test.ts
packages/plugins/.../swr.test.ts
packages/plugins/.../plugin.test.ts
packages/plugins/.../trpc.test.ts
Imported and utilized normalizePath for enhanced path handling.
packages/runtime/src/enhancements/policy/handler.ts
packages/runtime/src/enhancements/policy/policy-utils.ts
Enhanced policy options handling in error messages and method calls.
packages/runtime/src/enhancements/types.ts Added prismaModule property for custom PrismaClient path specification.
packages/runtime/src/enhancements/utils.ts Modified error handling functions to accept an options parameter for flexibility.
packages/testtools/src/schema.ts Exported normalizePath and installPackage; improved path normalization in schema loading.
tests/integration/tests/enhancements/with-policy/options.test.ts
tests/integration/tests/regression/issue-1162.test.ts
Updated tests for policy enforcement and added a regression test for issue 1162.

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?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

Note: Auto-reply has been disabled for this repository by the repository owner. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 599444c and fef6e83.
Files ignored due to path filters (13)
  • 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
Files selected for processing (15)
  • README.md (1 hunks)
  • packages/ide/jetbrains/CHANGELOG.md (1 hunks)
  • packages/ide/jetbrains/build.gradle.kts (1 hunks)
  • packages/plugins/openapi/tests/openapi-restful.test.ts (8 hunks)
  • packages/plugins/openapi/tests/openapi-rpc.test.ts (12 hunks)
  • packages/plugins/swr/tests/swr.test.ts (3 hunks)
  • packages/plugins/tanstack-query/tests/plugin.test.ts (7 hunks)
  • packages/plugins/trpc/tests/trpc.test.ts (11 hunks)
  • packages/runtime/src/enhancements/policy/handler.ts (14 hunks)
  • packages/runtime/src/enhancements/policy/policy-utils.ts (3 hunks)
  • packages/runtime/src/enhancements/types.ts (1 hunks)
  • packages/runtime/src/enhancements/utils.ts (2 hunks)
  • packages/testtools/src/schema.ts (3 hunks)
  • tests/integration/tests/enhancements/with-policy/options.test.ts (3 hunks)
  • tests/integration/tests/regression/issue-1162.test.ts (1 hunks)
Files not reviewed due to errors (7)
  • (no review received)
  • (no review received)
  • (no review received)
  • (no review received)
  • (no review received)
  • (no review received)
  • (no review received)
Additional comments: 39
packages/ide/jetbrains/CHANGELOG.md (2)
  • 7-7: LGTM! The addition under the "Unreleased" section is clear and follows the changelog's format.
  • 23-23: LGTM! The addition under version 1.7.0 is clear and follows the changelog's format.
README.md (1)
  • 238-239: The addition of Fabian Jocks to the acknowledgments section is correctly formatted and consistent with the rest of the section.
packages/plugins/openapi/tests/openapi-restful.test.ts (2)
  • 7-7: The import of normalizePath from @zenstackhq/testtools is correctly added.
  • 19-19: The usage of normalizePath for the provider field in the plugin openapi block is correctly implemented across various test cases. This ensures consistent path handling.

Also applies to: 117-117, 154-154, 201-201, 233-233, 254-254, 287-287

packages/testtools/src/schema.ts (2)
  • 57-57: Exporting the normalizePath function is a good practice, allowing for consistent path handling across different OS environments.
  • 178-178: The introduction of the normalizedProjectRoot variable to replace $projectRoot placeholders in the schema file ensures consistent path normalization. This is a good improvement for handling paths in a cross-platform manner.
packages/plugins/trpc/tests/trpc.test.ts (11)
  • 3-3: The import of normalizePath alongside loadSchema is a good practice for ensuring consistent path handling across different operating systems and environments.
  • 22-22: Using normalizePath for the provider path in the tRPC plugin configuration ensures that the path is correctly formatted across different environments. This is a crucial improvement for cross-platform compatibility.
  • 70-70: Consistent application of normalizePath for path resolution in the tRPC plugin configuration. This consistency is key for maintainability and readability of the test suite.
  • 113-113: The use of normalizePath in a non-standard ZModel location test case demonstrates the flexibility and utility of the function in handling various path scenarios within the project.
  • 144-144: Applying normalizePath in the context of specifying model actions to generate demonstrates a good practice of ensuring path consistency even in more complex configurations.
  • 174-174: Continued use of normalizePath in various configurations within the test suite reinforces the importance of consistent path handling. This consistency aids in the reliability of the tests across environments.
  • 223-223: The application of normalizePath in generating client helpers for react-query within the tRPC plugin tests shows the adaptability of the function for different use cases, further enhancing the test suite's robustness.
  • 248-248: Utilizing normalizePath for client helper generation in a Next.js context within the tRPC plugin tests. This demonstrates the function's broad applicability and its role in ensuring consistent path handling across various testing scenarios.
  • 268-268: The use of normalizePath in tests involving mixed casing in model names. This highlights the function's effectiveness in handling paths in diverse and potentially challenging naming conventions.
  • 307-307: Employing normalizePath in the context of generating routers for selected models and actions. This use case underscores the function's importance in maintaining path consistency across different parts of the test suite.
  • 378-378: The consistent use of normalizePath across various test scenarios, including when the Zod plugin is declared, showcases the function's versatility and its critical role in ensuring path consistency throughout the test suite.
packages/plugins/openapi/tests/openapi-rpc.test.ts (12)
  • 7-7: The import of normalizePath alongside loadZModelAndDmmf is a good practice for ensuring consistent path handling across different operating systems and environments.
  • 19-19: Using normalizePath for the provider path in the OpenAPI plugin configuration ensures that the path is correctly formatted across different environments. This is a crucial improvement for cross-platform compatibility.
  • 130-130: Consistent application of normalizePath for path resolution in the OpenAPI plugin configuration. This consistency is key for maintainability and readability of the test suite.
  • 167-167: The use of normalizePath in configuring security schemes within the OpenAPI plugin tests demonstrates the flexibility and utility of the function in handling various path scenarios within the project.
  • 201-201: Applying normalizePath in the context of specifying invalid security schemes. While the focus here is on testing error handling, the consistent use of normalizePath reinforces the importance of path consistency across all test scenarios.
  • 222-222: Utilizing normalizePath in tests involving security model level overrides. This highlights the function's effectiveness in handling paths in diverse testing scenarios, including those involving security configurations.
  • 250-250: The application of normalizePath in security operation level overrides within the OpenAPI plugin tests. This demonstrates the function's broad applicability and its role in ensuring consistent path handling across various testing scenarios.
  • 283-283: Employing normalizePath in the context of inferred security within the OpenAPI plugin tests. This use case underscores the function's importance in maintaining path consistency across different parts of the test suite.
  • 309-309: The consistent use of normalizePath across various test scenarios, including when testing OpenAPI v3.1.0 fields. This showcases the function's versatility and its critical role in ensuring path consistency throughout the test suite.
  • 333-333: Utilizing normalizePath in tests involving ignored models used as relations. This highlights the function's effectiveness in handling paths in complex model relationships and testing scenarios.
  • 365-365: The application of normalizePath in field type coverage tests within the OpenAPI plugin. This demonstrates the function's broad applicability and its role in ensuring consistent path handling across various testing scenarios, including those involving diverse field types.
  • 411-411: Employing normalizePath in the context of full-text search feature testing within the OpenAPI plugin. This use case underscores the function's importance in maintaining path consistency across different parts of the test suite, including those involving advanced database features.
packages/runtime/src/enhancements/policy/policy-utils.ts (5)
  • 52-52: The addition of the options parameter of type EnhancementOptions | undefined to the constructor of the PolicyUtil class is a significant change. It's important to ensure that all usages of PolicyUtil throughout the codebase have been updated to pass this new parameter where necessary.
Verification successful

Given the limitations of the initial script and the importance of ensuring that all instances of PolicyUtil instantiation have been correctly updated to include the new options parameter, a more comprehensive verification is necessary. Let's adjust the verification strategy to search for instances of PolicyUtil instantiation that include the new options parameter, which would imply searching for instances with seven parameters instead.


The verification process has identified at least one instance in the codebase (./packages/runtime/src/enhancements/policy/handler.ts) where the PolicyUtil constructor is correctly instantiated with the new options parameter, indicating that the necessary updates to accommodate this change have been made in this part of the codebase. Without evidence of incorrect usage or missing updates elsewhere, it's reasonable to conclude that the addition of the options parameter to the PolicyUtil constructor has been successfully integrated where identified.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for usages of PolicyUtil constructor without the new options parameter.
ast-grep --lang typescript --pattern $'new PolicyUtil($_, $_, $_, $_, $_, $_)'

Length of output: 79



Script:

#!/bin/bash
# Search for usages of PolicyUtil constructor with the new options parameter, indicating correct usage.
ast-grep --lang typescript --pattern $'new PolicyUtil($_, $_, $_, $_, $_, $_, $_)'

Length of output: 832

* 1103-1103: The `options` parameter is correctly utilized in the `deniedByPolicy` method to pass enhancement options to the error handling utilities. This is a good use of the newly added parameter to customize error responses based on the provided options. * 1110-1110: The `options` parameter is also correctly utilized in the `notFound` method. This consistency in using the `options` parameter across different error handling methods enhances the flexibility and configurability of error responses. * 1117-1117: The `options` parameter is used in the `validationError` method. This is consistent with its usage in other error handling methods, ensuring that enhancement options are considered when generating validation errors. * 1121-1121: The `options` parameter is utilized in the `unknownError` method. This consistent application of the `options` parameter across all error handling methods in the `PolicyUtil` class is commendable, as it allows for enhanced error customization based on the provided options.
packages/runtime/src/enhancements/policy/handler.ts (4)
  • 7-7: The import of WithPolicyOptions is correctly added to support enhanced policy options in error messages and method calls. This aligns with the PR objectives to improve error handling and policy options in the runtime package.
  • 61-61: The addition of this.options as a parameter to the PolicyUtil constructor is a good practice, ensuring that policy options are correctly passed and utilized within utility methods. This change enhances the flexibility and configurability of policy enforcement.
  • 81-84: The consistent use of prismaClientValidationError across various methods to throw errors when required arguments are missing is a good practice. It ensures that the error messages are standardized and informative, aiding in debugging and error handling. However, ensure that the error messages are clear and specific to the context of each method for better user understanding.

Also applies to: 91-94, 224-227, 480-483, 600-606, 1078-1081, 1137-1146, 1190-1193, 1246-1246, 1262-1262, 1306-1306

  • 738-741: The logic to check for duplicate unique constraints before proceeding with createMany operations is crucial for data integrity and avoiding unnecessary database errors. This preemptive check enhances the robustness of the create operations. However, ensure that the performance impact of these checks is minimal, especially in scenarios with large datasets.

### Added
- Added support to complex usage of `@@index` attribute like `@@index([content(ops: raw("gin_trgm_ops"))], type: Gin)`.

- Added support to complex usage of `@@index` attribute like `@@index([content(ops: raw("gin_trgm_ops"))], type: Gin)`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider changing the preposition "to" to "for" for better clarity in describing the support added.

-   Added support to complex usage of `@@index` attribute like `@@index([content(ops: raw("gin_trgm_ops"))], type: Gin)`.
+   Added support for complex usage of `@@index` attribute like `@@index([content(ops: raw("gin_trgm_ops"))], type: Gin)`.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
- Added support to complex usage of `@@index` attribute like `@@index([content(ops: raw("gin_trgm_ops"))], type: Gin)`.

@ymc9 ymc9 added this pull request to the merge queue Mar 20, 2024
Merged via the queue into main with commit 242ed43 Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants