Skip to content
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.9.4) #1892

Merged
merged 4 commits into from
Nov 27, 2024
Merged

merge dev to main (v2.9.4) #1892

merged 4 commits into from
Nov 27, 2024

Conversation

ymc9
Copy link
Member

@ymc9 ymc9 commented Nov 26, 2024

No description provided.

Copy link
Contributor

coderabbitai bot commented Nov 26, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

This pull request includes updates to the JetBrains plugin's build.gradle.kts file, incrementing the version from 2.9.3 to 2.9.4 and configuring the Gradle IntelliJ Plugin for compatibility with IDE version 2023.3.2. It also modifies the RESTfulOpenAPIGenerator to enhance OpenAPI specification generation, particularly for models with compound IDs. Additionally, the RequestHandler class in the REST API is updated to support upsert operations, and corresponding tests are added to validate these functionalities.

Changes

File Path Change Summary
packages/ide/jetbrains/build.gradle.kts Version updated from 2.9.3 to 2.9.4. Configured target IDE version and added additional plugins.
packages/plugins/openapi/src/rest-generator.ts Modified generateModelEntity to handle fields for compound IDs, retaining all fields for read operations.
packages/server/src/api/rest/index.ts Enhanced RequestHandler for upsert operations; added upsertMetaSchema and processUpsert methods.
packages/server/tests/api/rest.test.ts Added tests for upsert operations, including new and existing entities, and error handling for non-unique match fields.
packages/plugins/tanstack-query/tests/react-hooks-v5.test.tsx Enhanced tests for optimistic updates, nested relationships, and custom optimistic data providers.
packages/plugins/tanstack-query/tests/test-model-meta.ts Updated isOptional property for category field in modelMeta, making it required.

Possibly related PRs


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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. 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 testing code 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (3)
packages/ide/jetbrains/build.gradle.kts (1)

Resource paths need adjustment in prepareSandbox task

The verification revealed mismatches between the configured paths and actual file locations:

  • The language server's main.js path (packages/schema/bundle/language-server/main.js) is incorrect. The language server is actually located in packages/schema/src/language-server/.
  • The TextMate bundle path exists at the specified location: packages/ide/jetbrains/src/main/textMate/zmodel.tmbundle/
  • The stdlib.zmodel and zmodel.tmLanguage files exist in their respective locations.

Please update the language server path in the prepareSandbox task to match the actual project structure:

from("${project.projectDir}/../../schema/src/language-server/main.js")
🔗 Analysis chain

Line range hint 35-54: Verify resource paths existence

The prepareSandbox task copies multiple resources. Let's verify that all source paths exist to prevent build failures.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify existence of required resource files
# Expected: All source paths should exist

echo "Checking language server main.js:"
fd main.js --type f --full-path --base-directory "packages/schema/bundle/language-server"

echo -e "\nChecking stdlib.zmodel:"
fd stdlib.zmodel --type f --base-directory "packages/schema/src/res"

echo -e "\nChecking TextMate bundle:"
fd "zmodel.t?mbundle|zmodel.tmLanguage" --type f

Length of output: 626


Script:

#!/bin/bash
# Let's verify the existence of the language server directory and main.js file
echo "Checking language server path structure:"
fd --type d "language-server" --full-path
fd "main.js" --type f

echo -e "\nChecking complete directory structure for schema bundle:"
fd . --type d --max-depth 3 packages/schema

echo -e "\nChecking zmodel.tmbundle in IDE directory:"
fd "zmodel.tmbundle" --type d packages/ide

Length of output: 1282

packages/plugins/openapi/src/rest-generator.ts (1)

912-913: LGTM! Consider fixing indentation.

The logic for handling ID requirements in create operations is correct. The code properly checks for single ID fields without default values.

The indentation appears to be inconsistent with the surrounding code. Consider adjusting it to match the file's indentation style:

-            if (idFields.length === 1 && !hasAttribute(idFields[0], '@default')) {
-                properties = { id: { type: 'string' }, ...properties };
+        if (idFields.length === 1 && !hasAttribute(idFields[0], '@default')) {
+            properties = { id: { type: 'string' }, ...properties };
packages/server/tests/api/rest.test.ts (1)

1875-1910: Enhance the test by asserting specific error details

To make the test more robust, consider adding assertions to verify the exact error code and message returned. This ensures the test not only checks the status code but also the correctness of the error response.

Apply this diff to enhance the test:

 expect(r.status).toBe(400);
+ expect(r.body.errors[0].code).toBe('invalid-payload');
+ expect(r.body.errors[0].title).toBe('Invalid payload');
+ expect(r.body.errors[0].reason).toContain('Unique constraint validation failed');
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f5e4e7c and 39f13e7.

⛔ Files ignored due to path filters (15)
  • 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/rest-3.0.0.baseline.yaml is excluded by !**/*.yaml
  • packages/plugins/openapi/tests/baseline/rest-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/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 (4)
  • packages/ide/jetbrains/build.gradle.kts (1 hunks)
  • packages/plugins/openapi/src/rest-generator.ts (2 hunks)
  • packages/server/src/api/rest/index.ts (5 hunks)
  • packages/server/tests/api/rest.test.ts (2 hunks)
🔇 Additional comments (11)
packages/ide/jetbrains/build.gradle.kts (3)

Line range hint 69-77: Security configuration looks good

The plugin signing and publishing configuration properly uses environment variables for sensitive data (CERTIFICATE_CHAIN, PRIVATE_KEY, PRIVATE_KEY_PASSWORD, PUBLISH_TOKEN).


12-12: Verify version bump consistency across the project

The version bump from 2.9.3 to 2.9.4 should be reflected in other relevant project files.

✅ Verification successful

Version bump is consistent across the project

The version 2.9.4 is correctly reflected in all relevant project files:

  • All main package.json files in the packages directory show version 2.9.4
  • The build.gradle.kts version matches at 2.9.4
  • The only 2.9.3 references found are in pnpm-lock.yaml for an unrelated dependency (colord)
  • Other version numbers found (0.1.0, 1.0.0) belong to independent packages
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for version references across the project
# Expected: All version references should be updated to 2.9.4

# Search for version strings
echo "Searching for version strings:"
rg -g '!{*.lock,package-lock.json,yarn.lock}' '2\.9\.[34]' 

# Check package.json files specifically
echo -e "\nChecking package.json files:"
fd package.json --exec jq -r '. | select(.version != null) | .version'

Length of output: 1315


Line range hint 20-24: Verify IDE compatibility range

The plugin is configured for IntelliJ IDEA Ultimate 2023.3.2 with JavaScript support. The compatibility range (233.2 - 251.*) looks appropriate for the current version.

✅ Verification successful

IDE compatibility range is correctly configured and consistent

The verification confirms that the IDE compatibility range is properly set and consistent across configuration files:

  • In plugin.xml: since-build="233.2" is set
  • In build.gradle.kts:
    • IDE version is set to "2023.3.2"
    • Compatibility range is set to sinceBuild.set("233.2") and untilBuild.set("251.*")
  • Required dependencies are properly declared: IntelliJ Ultimate, JavaScript, and TextMate plugins
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the changelog contains appropriate compatibility notes
# Expected: Changelog should mention IDE compatibility requirements

# Check changelog entries for IDE compatibility notes
rg -i "compatibility|ide version|intellij" "CHANGELOG.md"

Length of output: 57


Script:

#!/bin/bash
# Let's check if CHANGELOG.md exists and its content
fd -t f "CHANGELOG.md"

# Check the plugin.xml file for IDE compatibility settings
fd -t f "plugin.xml" -x cat {}

# Check build.gradle.kts files for IDE version configurations
fd -t f "build.gradle.kts" -x cat {}

Length of output: 6754

packages/plugins/openapi/src/rest-generator.ts (1)

860-861: LGTM! Verify compound ID handling consistency.

The change correctly exposes all fields for models with compound IDs, which is the expected behavior for handling composite keys in REST APIs.

Let's verify the compound ID handling across the codebase:

✅ Verification successful

Compound ID handling is correctly implemented and verified

The code change is consistent with the codebase's handling of compound IDs. Evidence from the codebase shows:

  • The isIdField utility function properly identifies both single and compound ID fields
  • Extensive test coverage for compound ID scenarios in REST API endpoints
  • Consistent handling across the codebase, including:
    • REST parameter generation
    • URL path handling with custom separators
    • Proper serialization and deserialization of compound IDs
    • Support in CRUD operations (create, read, update, delete)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for models with compound IDs and their usage
# Expected: Find models with multiple @id fields to ensure consistent handling

# Search for model definitions with multiple @id fields
ast-grep --pattern 'model $MODEL {
  $$$
  @id
  $$$
  @id
  $$$
}'

Length of output: 69


Script:

#!/bin/bash
# Let's try a different approach to find compound ID handling
# First, let's look for the isIdField function definition and its usage
ast-grep --pattern 'function isIdField($_) {
  $$$
}'

# Also search for any references to compound IDs in comments or code
rg -i "compound.?id|multiple.?id" -A 2 -B 2

Length of output: 14478

packages/server/src/api/rest/index.ts (3)

212-217: 'upsertMetaSchema' is properly defined

The upsertMetaSchema correctly validates the meta field for upsert operations, ensuring that the operation is 'upsert' and that matchFields is a non-empty array of strings.


319-341: Logical handling of upsert and create operations

The code correctly differentiates between upsert and create operations by using upsertMetaSchema.safeParse(body). If parsing succeeds, it proceeds with processUpsert; otherwise, it defaults to processCreate.


1074-1077: Correctly updating relationships with 'connect'

The code accurately updates single relationships by using the connect operation with the appropriate identifier key.

packages/server/tests/api/rest.test.ts (4)

1803-1839: Well-structured test for upserting a new entity

The test accurately simulates the upsert of a new user entity and verifies the expected response.


1842-1872: Well-structured test for upserting an existing entity

The test correctly checks that upserting an existing user updates the entity as expected.


1913-1935: Well-structured test for upserting with a compound ID

The test effectively verifies that upsert operations work correctly with entities that have compound IDs.


2144-2166: Test accurately updates the ID of an item with a compound ID

The test correctly checks the ability to update the ID of an item with a compound ID, ensuring relationships are maintained properly.

packages/server/src/api/rest/index.ts Show resolved Hide resolved
packages/server/src/api/rest/index.ts Show resolved Hide resolved
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.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
packages/plugins/tanstack-query/tests/react-hooks-v5.test.tsx (1)

Line range hint 470-488: Address the TODO: Include the category object in the assertion

The test contains a TODO comment questioning whether the category object should be included in the assertion. To ensure the test accurately reflects the expected behavior, consider updating the assertion to include the category object if it should be present in the cached data.

Would you like assistance in updating the assertion to include the category object?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 39f13e7 and a747d95.

📒 Files selected for processing (2)
  • packages/plugins/tanstack-query/tests/react-hooks-v5.test.tsx (2 hunks)
  • packages/plugins/tanstack-query/tests/test-model-meta.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • packages/plugins/tanstack-query/tests/test-model-meta.ts
🔇 Additional comments (2)
packages/plugins/tanstack-query/tests/react-hooks-v5.test.tsx (2)

Line range hint 504-581: Test for optimistic update with optional one-to-many relationship is correctly implemented

The test correctly verifies that an optimistic update works as expected when the related optional one-to-many relationship is null. The cache update and assertions are properly handled.


Line range hint 425-430: Verify server response data in nock mocks returning { data: null }

In the nock mock for the POST request to create a Post, the server response is mocked to return { data: null }. Please ensure that this aligns with the expected server behavior. If the server is expected to return the created data, consider returning the created post data to more accurately simulate real-world scenarios.

Run the following script to find all nock mocks that reply with { data: null }:

This script searches for instances where nock mocks for POST, PUT, or DELETE requests reply with { data: null }. Verify whether these responses are intentional and align with the expected server behavior.

✅ Verification successful

After examining the test file, I can now generate the final response:

The mock response of { data: null } is intentional and correct for optimistic updates

The test file shows that returning { data: null } in the nock mock is intentional and correct for the optimistic update test cases. This is because these tests are specifically verifying that the optimistic updates work correctly without waiting for the actual server response. The tests verify that:

  1. The cache is updated optimistically before the server responds
  2. The optimistic update works even when the server returns null
  3. The optimistic flag ($optimistic: true) is properly set on the updated data

This pattern is consistently used across multiple test cases in the file, including:

  • optimistic create single
  • optimistic create updating nested query
  • optimistic create updating deeply nested query
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all nock mocks that reply with { data: null }

rg -A 5 'nock\(.*\)\.(post|put|delete)\(.*\)\s*\.reply\(200,.*\{\s*data:\s*null\s*\}\)'

Length of output: 89


Script:

#!/bin/bash
# Let's first find the specific test file and examine the nock mock setup
cat "packages/plugins/tanstack-query/tests/react-hooks-v5.test.tsx"

Length of output: 62295

@ymc9 ymc9 merged commit 251c699 into main Nov 27, 2024
16 checks passed
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.

3 participants