-
Notifications
You must be signed in to change notification settings - Fork 1
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
π·οΈ Export discriminated interfaces for SchemaRestPullRequestActivity #17
Conversation
π WalkthroughWalkthroughThe pull request introduces several changes primarily focused on transitioning the codebase from JavaScript to TypeScript. Key modifications include updating import paths in multiple test and source files to reflect Changes
Possibly related PRs
Suggested labels
πͺ§ 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 and nitpick comments (2)
src/cloud/index.ts (1)
1-2
: Ensure comprehensive testing after TypeScript migration.The changes in this file are part of the larger TypeScript migration effort. While the modifications are correct, it's crucial to conduct thorough testing across the entire codebase to ensure that these changes haven't introduced any unintended side effects, particularly in how types are imported and used in other modules.
src/server/webhooks/events/pr/event.test.ts (1)
2-3
: LGTM! The import path changes look good.The modification of import paths from
.js
to.ts
is consistent with the transition to TypeScript and follows best practices. These changes improve type safety and maintain consistency across the codebase.As a suggestion for future improvements, consider expanding the test suite to cover more edge cases and potential scenarios for the
isPrEventKey
andisPrEvent
functions. This could include testing with invalid input types or unexpected event keys to ensure robust error handling.
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
β Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
π Files selected for processing (54)
- package.json (2 hunks)
- src/base64.test.ts (1 hunks)
- src/cloud/client.test.ts (1 hunks)
- src/cloud/client.ts (1 hunks)
- src/cloud/index.ts (1 hunks)
- src/cloud/openapi/index.ts (1 hunks)
- src/index.test.ts (1 hunks)
- src/index.ts (1 hunks)
- src/server/client.test.ts (1 hunks)
- src/server/client.ts (1 hunks)
- src/server/index.ts (1 hunks)
- src/server/interfaces/index.ts (1 hunks)
- src/server/interfaces/schema_rest_pull_request_activity.ts (1 hunks)
- src/server/openapi/index.ts (1 hunks)
- src/server/webhooks/events/event.ts (1 hunks)
- src/server/webhooks/events/index.ts (1 hunks)
- src/server/webhooks/events/pr/comment_added.ts (1 hunks)
- src/server/webhooks/events/pr/comment_deleted.ts (1 hunks)
- src/server/webhooks/events/pr/comment_edited.ts (1 hunks)
- src/server/webhooks/events/pr/declined.ts (1 hunks)
- src/server/webhooks/events/pr/deleted.ts (1 hunks)
- src/server/webhooks/events/pr/event.test.ts (1 hunks)
- src/server/webhooks/events/pr/event.ts (1 hunks)
- src/server/webhooks/events/pr/from_ref_updated.ts (1 hunks)
- src/server/webhooks/events/pr/index.ts (1 hunks)
- src/server/webhooks/events/pr/merged.ts (1 hunks)
- src/server/webhooks/events/pr/modified.ts (1 hunks)
- src/server/webhooks/events/pr/opened.ts (1 hunks)
- src/server/webhooks/events/pr/reviewer_approved.ts (1 hunks)
- src/server/webhooks/events/pr/reviewer_changes_requested.ts (1 hunks)
- src/server/webhooks/events/pr/reviewer_unapproved.ts (1 hunks)
- src/server/webhooks/events/pr/reviewer_updated.ts (1 hunks)
- src/server/webhooks/events/project/event.test.ts (1 hunks)
- src/server/webhooks/events/project/event.ts (1 hunks)
- src/server/webhooks/events/project/index.ts (1 hunks)
- src/server/webhooks/events/repo/comment_added.ts (1 hunks)
- src/server/webhooks/events/repo/comment_deleted.ts (1 hunks)
- src/server/webhooks/events/repo/comment_edited.ts (1 hunks)
- src/server/webhooks/events/repo/event.test.ts (1 hunks)
- src/server/webhooks/events/repo/event.ts (1 hunks)
- src/server/webhooks/events/repo/forked.ts (1 hunks)
- src/server/webhooks/events/repo/index.ts (1 hunks)
- src/server/webhooks/events/repo/modified.ts (1 hunks)
- src/server/webhooks/events/repo/refs_changed.ts (1 hunks)
- src/server/webhooks/events/repo/secret_detected.ts (1 hunks)
- src/server/webhooks/events/repo/synchronized.ts (1 hunks)
- src/server/webhooks/headers.ts (1 hunks)
- src/server/webhooks/index.ts (1 hunks)
- tests/cloud/client.ts (1 hunks)
- tests/cloud/repositories.test.ts (1 hunks)
- tests/server/client.ts (1 hunks)
- tests/server/projects.test.ts (1 hunks)
- tests/server/repositories.test.ts (1 hunks)
- tsconfig.json (1 hunks)
β Files skipped from review due to trivial changes (44)
- src/base64.test.ts
- src/cloud/client.test.ts
- src/cloud/client.ts
- src/cloud/openapi/index.ts
- src/index.test.ts
- src/server/client.test.ts
- src/server/client.ts
- src/server/interfaces/index.ts
- src/server/openapi/index.ts
- src/server/webhooks/events/event.ts
- src/server/webhooks/events/index.ts
- src/server/webhooks/events/pr/comment_added.ts
- src/server/webhooks/events/pr/comment_edited.ts
- src/server/webhooks/events/pr/declined.ts
- src/server/webhooks/events/pr/deleted.ts
- src/server/webhooks/events/pr/event.ts
- src/server/webhooks/events/pr/from_ref_updated.ts
- src/server/webhooks/events/pr/index.ts
- src/server/webhooks/events/pr/merged.ts
- src/server/webhooks/events/pr/modified.ts
- src/server/webhooks/events/pr/opened.ts
- src/server/webhooks/events/pr/reviewer_approved.ts
- src/server/webhooks/events/pr/reviewer_changes_requested.ts
- src/server/webhooks/events/pr/reviewer_unapproved.ts
- src/server/webhooks/events/pr/reviewer_updated.ts
- src/server/webhooks/events/project/event.test.ts
- src/server/webhooks/events/project/event.ts
- src/server/webhooks/events/project/index.ts
- src/server/webhooks/events/repo/comment_added.ts
- src/server/webhooks/events/repo/comment_deleted.ts
- src/server/webhooks/events/repo/comment_edited.ts
- src/server/webhooks/events/repo/event.test.ts
- src/server/webhooks/events/repo/event.ts
- src/server/webhooks/events/repo/forked.ts
- src/server/webhooks/events/repo/index.ts
- src/server/webhooks/events/repo/modified.ts
- src/server/webhooks/events/repo/refs_changed.ts
- src/server/webhooks/events/repo/secret_detected.ts
- src/server/webhooks/events/repo/synchronized.ts
- src/server/webhooks/index.ts
- tests/cloud/client.ts
- tests/cloud/repositories.test.ts
- tests/server/client.ts
- tests/server/projects.test.ts
π§° Additional context used
π Additional comments (21)
src/cloud/index.ts (2)
1-1
: LGTM! Proper TypeScript file extension used.The change from
.js
to.ts
for the client import is correct and aligns with the project's transition to TypeScript.
2-2
: Verify impact of OpenApi namespace import.The change to use a namespace import for
OpenApi
and the update to the.ts
file extension are appropriate. However, it's crucial to ensure that this modification doesn't adversely affect existing type imports throughout the codebase.Please run the following script to verify the impact of this change:
β Verification successful
Impact of OpenApi namespace import verified.
The namespace import forOpenApi
and the.ts
file extension updates do not adversely affect existing type imports.π Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for potential breaking changes in OpenApi type imports # Test: Search for OpenApi type imports that might be affected rg -i 'import.*OpenApi.*from.*openapi/index' # Test: Look for any remaining .js extensions in import statements rg 'from.*\.js["\']'Length of output: 140
Script:
#!/bin/bash # Description: Check for potential breaking changes in OpenApi type imports # Test: Search for OpenApi type imports that might be affected rg -i 'import.*OpenApi.*from.*openapi/index.ts' # Test: Look for any remaining .js extensions in import statements rg 'from.*\.js["\']'Length of output: 143
Script:
#!/bin/bash # Description: Check for potential breaking changes in OpenApi type imports # Test: Search for OpenApi type imports that might be affected rg -i 'import.*OpenApi.*from\ "./openapi/index\.ts"' # Test: Look for any remaining .js extensions in import statements rg 'from\ ".*\.js"'Length of output: 293
Script:
#!/bin/bash # Description: Check for potential breaking changes in OpenApi type imports # Test: Search for OpenApi type imports that might be affected rg -i 'import.*OpenApi.*from "./openapi/index\.ts"' # Test: Look for any remaining .js extensions in import statements rg 'from ".*\.js"'Length of output: 184
src/index.ts (4)
1-1
: LGTM: Updated export statement for base64 moduleThe export statement has been correctly updated to use the TypeScript file extension (.ts). This change is consistent with the transition from JavaScript to TypeScript.
1-3
: Overall assessment: Excellent updates to export statementsThe changes in this file successfully transition the exports to TypeScript and improve naming conventions by using more specific Bitbucket-related names. These updates align well with the PR objectives and enhance the overall clarity of the module structure.
3-3
: LGTM: Updated and renamed server module exportThe export statement has been correctly updated to use the TypeScript file extension (.ts) and renamed from 'server' to 'BitbucketServer'. This change improves clarity and aligns with the Bitbucket branding.
Please verify that all import statements in other files have been updated to use 'BitbucketServer' instead of 'server'. You can use the following script to check for any remaining 'server' imports:
#!/bin/bash # Description: Search for any remaining 'server' imports that might need updating rg -i "import.*server.*from.*['\"]\.\.?/index" --type ts
2-2
: LGTM: Updated and renamed cloud module exportThe export statement has been correctly updated to use the TypeScript file extension (.ts) and renamed from 'cloud' to 'BitbucketCloud'. This change improves clarity and aligns with the Bitbucket branding.
Please verify that all import statements in other files have been updated to use 'BitbucketCloud' instead of 'cloud'. You can use the following script to check for any remaining 'cloud' imports:
src/server/index.ts (4)
2-2
: LGTM! Verify the new interfaces exportThe addition of the interfaces export enhances the module's capabilities.
Run the following script to verify the new interfaces export:
#!/bin/bash # Description: Verify the new interfaces export # Test: Check if the file exists if fd -p "src/server/interfaces/index.ts"; then echo "File ./interfaces/index.ts exists." else echo "Error: File ./interfaces/index.ts does not exist." fi # Test: Check the contents of the file if fd -p "src/server/interfaces/index.ts" --exec cat; then echo "Contents of ./interfaces/index.ts:" else echo "Error: Could not read ./interfaces/index.ts" fi # Test: Check for any usage of these interfaces if rg -q "interfaces/index" src/; then echo "Found usage of interfaces/index in the src/ directory:" rg "interfaces/index" src/ else echo "No usage of interfaces/index found in the src/ directory." fi
4-4
: Verify if webhooks export should be updated to TypeScriptThe export for webhooks still uses the ".js" extension, which is inconsistent with the other exports in this file.
Run the following script to verify the webhooks export:
#!/bin/bash # Description: Verify webhooks export # Test: Check if a TypeScript version of the file exists if fd -p "src/server/webhooks/index.ts"; then echo "A TypeScript version (./webhooks/index.ts) exists. Consider updating the import." elif fd -p "src/server/webhooks/index.js"; then echo "Only a JavaScript version (./webhooks/index.js) exists. Consider migrating this file to TypeScript." else echo "Error: Neither ./webhooks/index.ts nor ./webhooks/index.js exist." fi # Test: Check for any usage of webhooks if rg -q "from ['\"].*webhooks/index['\"]" src/; then echo "Found usage of webhooks in the src/ directory:" rg "from ['\"].*webhooks/index['\"]" src/ else echo "No usage of webhooks found in the src/ directory." fiIf a TypeScript version of the webhooks file exists or if it's appropriate to migrate this file to TypeScript, consider updating this export statement to use the ".ts" extension for consistency.
3-3
: LGTM! Verify OpenApi export usageThe change to a namespace-like syntax for OpenApi types is appropriate. This modification allows for better organization and potential conflict resolution of the exported types.
Run the following script to verify the OpenApi export usage:
#!/bin/bash # Description: Verify OpenApi export usage # Test: Check if the file exists if fd -p "src/server/openapi/index.ts"; then echo "File ./openapi/index.ts exists." else echo "Error: File ./openapi/index.ts does not exist." fi # Test: Check for any usage of OpenApi types if rg -q "OpenApi\." src/; then echo "Found usage of OpenApi namespace in the src/ directory:" rg "OpenApi\." src/ else echo "No usage of OpenApi namespace found in the src/ directory." fi # Test: Check for any remaining type imports from openapi/index if rg -q "from ['\"].*openapi/index['\"]" src/; then echo "Warning: Found direct type imports from openapi/index in the src/ directory:" rg "from ['\"].*openapi/index['\"]" src/ else echo "No direct type imports from openapi/index found in the src/ directory." fi
1-1
: LGTM! Verify the existence of "./client.ts"The update from ".js" to ".ts" extension is correct for the TypeScript transition.
Run the following script to verify the existence of the "./client.ts" file:
β Verification successful
Further Verification Required: Verify the existence of "./client.ts"
Please run the following script to ensure that "./client.ts" exists and that there are no remaining references to "./client.js":
Verified: Export statement correctly updated.
No references to "./client.js" found in the src/ directory.
π Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the existence of "./client.ts" file # Test: Check if the file exists if fd -p "src/server/client.ts"; then echo "File ./client.ts exists." else echo "Error: File ./client.ts does not exist." fi # Test: Check for any remaining references to "./client.js" if rg -q "client\.js" src/; then echo "Warning: Found references to client.js in the src/ directory." rg "client\.js" src/ else echo "No references to client.js found in the src/ directory." fiLength of output: 489
Script:
#!/bin/bash # Description: Verify the existence of "./client.ts" file and check for references to "./client.js" # Test: Check if the file exists if fd -p "src/server/client.ts"; then echo "File ./client.ts exists." else echo "Error: File ./client.ts does not exist." fi # Test: Check for any remaining references to "./client.js" if rg -q "client\.js" src/; then echo "Warning: Found references to client.js in the src/ directory." rg "client\.js" src/ else echo "No references to client.js found in the src/ directory." fiLength of output: 255
tsconfig.json (1)
18-18
: Approval: Good addition to support ESM compatibilityThe new compiler option
"rewriteRelativeImportExtensions": true
is a valuable addition to your TypeScript configuration. This option allows TypeScript to automatically rewrite relative import paths to include file extensions, which aligns well with your use of the "NodeNext" module system.Benefits of this change include:
- Improved compatibility with the Node.js ESM loader.
- Simplified development process by allowing omission of file extensions in imports.
- Enhanced consistency between development and production environments.
Keep in mind that this might require minor adjustments to existing import statements if they explicitly included extensions. Overall, this change supports better ESM compatibility and is a positive step for your project's TypeScript configuration.
To ensure this change doesn't cause unexpected issues, you may want to run the following verification:
β Verification successful
Verification Successful: No issues detected with relative imports
All relative import statements in the codebase include explicit file extensions, ensuring compatibility with the newly added
"rewriteRelativeImportExtensions": true
compiler option. This change effectively supports ESM compatibility without necessitating any further modifications.π Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for any relative imports that might be affected by the new compiler option # Test: Search for relative imports in TypeScript files echo "Checking for relative imports that might be affected:" rg -t ts '(from|import) [\'"]\.\.?/' srcLength of output: 210
Script:
#!/bin/bash # Description: Check for any relative imports that might be affected by the new compiler option # Test: Search for relative imports in TypeScript files echo "Checking for relative imports that might be affected:" rg -t ts "(from|import) ['\"]\.\.?/" srcLength of output: 9987
tests/server/repositories.test.ts (3)
Line range hint
1-63
: Summary: Import statements updated for TypeScript transition.The changes in this file are limited to updating import statements from ".js" to ".ts" extensions. These modifications align with the project's transition from JavaScript to TypeScript. The test suite structure and logic remain unchanged, which is appropriate as the functionality being tested hasn't been altered.
6-6
: LGTM! Verify the existence of "./client.ts".The update of the import statement from ".js" to ".ts" is consistent with the transition to TypeScript.
Run the following script to verify the existence of the "./client.ts" file:
#!/bin/bash # Description: Verify the existence of "./client.ts" relative to the current file. # Test: Check if "./client.ts" exists relative to the current file fd -p 'tests/server/client.ts' --type f
5-5
: LGTM! Verify the existence of "../env.ts".The update of the import statement from ".js" to ".ts" is consistent with the transition to TypeScript.
Run the following script to verify the existence of the "../env.ts" file:
β Verification successful
Import Statement Verified Successfully
The "../env.ts" file exists in the repository. The update to the import statement is correct.
π Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the existence of "../env.ts" relative to the current file. # Test: Check if "../env.ts" exists relative to the current file fd -p 'tests/server/../env.ts' --type fLength of output: 62
Script:
#!/bin/bash # Description: Verify the existence of "../env.ts" relative to the repository root. # Test: Check if "env.ts" exists in the repository fd 'env.ts' --type fLength of output: 33
src/server/webhooks/events/pr/comment_deleted.ts (1)
1-4
: LGTM! Consistent transition to TypeScript.The change from
.js
to.ts
in the import statement is appropriate and aligns with the transition to TypeScript. This modification enhances type safety and consistency in the codebase.Let's verify if this change is consistent across the codebase:
β Verification successful
.js Imports from openapi-typescript Successfully Replaced with .ts
All import statements from
openapi-typescript
have been updated to use.ts
extensions across the codebase, ensuring consistency and type safety.π Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for any remaining .js imports from openapi-typescript # Test: Search for .js imports from openapi-typescript. Expect: No results. rg -g '*.ts' 'from.*openapi-typescript\.js' # Test: Confirm all imports are now using .ts extension. Expect: Multiple results, all using .ts. rg -g '*.ts' 'from.*openapi-typescript\.ts'Length of output: 2222
src/server/webhooks/headers.ts (1)
2-2
: Approved: Import statement updated to TypeScript extensionThe change from
.js
to.ts
in the import statement is correct and aligns with the project's transition to TypeScript. This modification enhances type safety and consistency across the codebase.To ensure all imports have been updated consistently, please run the following script:
package.json (4)
Line range hint
67-91
: Summary: Changes align with PR objectives, but consider TypeScript version choice.The additions to the
exports
section for./cloud/openapi
and./server/openapi
align well with the PR objectives of exporting discriminated interfaces for SchemaRestPullRequestActivity. These changes enhance the module's capabilities by providing access to both cloud and server openapi functionality.However, the update to TypeScript version
5.7.0-beta
might introduce potential risks. Consider using a stable version instead to ensure reliability in production environments.Overall, the changes improve the project's structure and export capabilities, supporting the goals of the pull request.
#!/bin/bash # Description: Verify the overall project structure and build process # Test: Check the project structure echo "Verifying the project structure:" fd -t d -d 2 . src # Test: Ensure the build script is updated to handle new exports echo "Checking the build script for new exports:" grep -A 10 "build" package.json # Test: Verify TypeScript configuration echo "Checking TypeScript configuration:" cat tsconfig.json
81-84
: LGTM! Verify the correctness of the new export paths.The addition of the
./cloud/openapi
export enhances the module's capabilities by providing access to cloud openapi functionality. The paths follow the project's convention for the dist folder structure.Please ensure that the specified paths (
./dist/cloud/openapi/index.d.ts
and./dist/cloud/openapi/index.js
) are correct and that the corresponding files will be generated during the build process.#!/bin/bash # Description: Verify the existence of cloud openapi files # Test: Check if the TypeScript source file exists echo "Checking for the existence of the cloud openapi TypeScript source file:" fd -t f "index.ts" src/cloud/openapi # Test: Verify the build script generates the correct files echo "Verifying the build script generates the correct files:" grep -A 5 "build" package.json
89-91
: LGTM! Verify the correctness of the new export paths.The addition of the
./server/openapi
export enhances the module's capabilities by providing access to server openapi functionality. The paths follow the project's convention for the dist folder structure and are consistent with the previously added cloud/openapi export.Please ensure that the specified paths (
./dist/server/openapi/index.d.ts
and./dist/server/openapi/index.js
) are correct and that the corresponding files will be generated during the build process.#!/bin/bash # Description: Verify the existence of server openapi files # Test: Check if the TypeScript source file exists echo "Checking for the existence of the server openapi TypeScript source file:" fd -t f "index.ts" src/server/openapi # Test: Verify the build script generates the correct files echo "Verifying the build script generates the correct files:" grep -A 5 "build" package.json
67-67
: Consider using a stable TypeScript version instead of beta.Updating to a beta version (
5.7.0-beta
) might introduce instability or breaking changes. Beta versions are generally not recommended for production use. Additionally, removing the caret (^
) means it won't automatically update to newer patch versions.Consider using the latest stable version of TypeScript instead, such as
^5.6.3
or the most recent stable release.src/server/interfaces/schema_rest_pull_request_activity.ts (1)
1-29
: ApprovedThe declarations and interfaces are well-defined and accurately represent the pull request activities.
Clone and split SchemaRestPullRequestActivity
π Description
SchemaRestPullRequestActivity
is missing some information.This adds an easy way to deal with it.
rewriteRelativeImportExtensions
π References
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
tsconfig.json
to improve TypeScript configuration, including new compiler options for handling module imports.Chores