-
Notifications
You must be signed in to change notification settings - Fork 61
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
chore(signature-collection): Swap out old endpoints for new ones #16260
Conversation
WalkthroughThe pull request introduces significant changes to the OpenAPI specification of the MedmaeliRestAPI, including the addition of new endpoints, updates to existing endpoint descriptions, and modifications to request and response schemas. Additionally, the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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 using PR comments)
Other keywords and placeholders
Documentation and Community
|
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: 13
🧹 Outside diff range and nitpick comments (8)
libs/clients/signature-collection/src/clientConfig.json (4)
180-181
: Improved endpoint description, but consider clarifying theshouldToggle
parameter.The updated summary and description provide better context for the endpoint's functionality. However, there are a few points to consider:
- The description mentions "Hægt að opna aftur fyrir úrvinnslu," but it's not clear how this relates to the
shouldToggle
parameter.- The
shouldToggle
parameter's description states it's "Optional. Sjálfkrafa true," which might be confusing. Consider clarifying if it means the default value is true.Consider updating the description to explicitly mention how the
shouldToggle
parameter affects the action, especially when set to false.Also applies to: 184-189
302-302
: Improved endpoint description, but consider enhancing the response details.The updates to this endpoint are beneficial:
- The summary now clearly explains the purpose of the endpoint.
- The
ID
parameter description is more specific.- A description for the request body has been added.
These changes improve the API's clarity. However, to further enhance the documentation:
Consider adding a description for the response body in the "responses" section. This could include details about the structure of the returned
MedmaeliDTO
objects and any potential error responses.Also applies to: 307-307, 313-313
453-453
: New comparison endpoint added, but consider enhancing the documentation.The new
/Admin/Medmaelasofnun/{ID}/Compare
endpoint is a useful addition:
- It provides a way to compare recommendations across an entire collection.
- The summary clearly states the purpose of the endpoint.
However, there are opportunities to improve the documentation:
- Consider adding a more detailed description of how the comparison works and what criteria are used.
- Clarify the format of the kennitala strings in the request body (e.g., any specific format requirements).
- Provide more information about the structure of the
MedmaeliDTO
objects returned in the response.- Include details about possible error responses and their meanings.
These additions would make the API more user-friendly and reduce potential misunderstandings.
Also applies to: 458-458, 464-464
Line range hint
1-2500
: Overall improvements to the API, with some suggestions for further enhancement.The changes to the MedmaeliRestAPI specification bring several improvements:
- New endpoints have been added, expanding the API's functionality.
- Existing endpoint descriptions have been clarified and enhanced.
- New parameters have been introduced to provide more flexibility.
These changes will likely improve the usability and understanding of the API for consumers. However, there are some general suggestions for further improvement:
- Consistency: Ensure that all endpoints follow the same pattern for parameter descriptions, response details, and error handling.
- Error Responses: Consider adding more detailed error response descriptions for each endpoint, especially for the new ones.
- Authentication and Authorization: While the API uses bearer token authentication, consider documenting any specific authorization requirements for different endpoints, especially the admin ones.
- Versioning: As the API evolves, consider implementing and documenting a versioning strategy to manage future changes without breaking existing integrations.
- Rate Limiting: If applicable, add information about any rate limiting applied to the API endpoints.
Implementing these suggestions would further enhance the robustness and user-friendliness of the API documentation.
libs/clients/signature-collection/src/lib/signature-collection-admin.service.ts (4)
Line range hint
135-154
: Add error handling for creating lists increateListsAdmin
.The API call to
adminFrambodPost
lacks error handling. Enclose it in a try-catch block to manage exceptions and handle cases where the API call may fail.Apply this diff to add error handling:
+ try { const candidacy = await this.getApiWithAuth( this.adminApi, auth, ).adminFrambodPost({ frambodRequestDTO: { sofnunID: parseInt(id), kennitala: owner.nationalId, simi: owner.phone, netfang: owner.email, medmaelalistar: filteredAreas.map((area) => ({ svaediID: parseInt(area.id), listiNafn: `${owner.name} - ${area.name}`, })), }, }) return { slug: getSlug( candidacy.id ?? '', candidacy.medmaelasofnun?.kosningTegund ?? '', ), } + } catch (error) { + // Handle the error appropriately + throw new Error('Failed to create lists: ' + error.message) + }
Line range hint
324-332
: Add error handling for the API call ingetAreaSummaryReport
.Although a try-catch block is present, returning an empty
AreaSummaryReport
could mask underlying issues. Consider logging the error or providing more informative feedback.
Line range hint
339-350
: Add error handling forsignatureLookup
.Wrap the API call to
adminMedmaelasofnunIDComparePost
in a try-catch block to handle potential errors and ensure consistent error management.
Line range hint
356-364
: Add error handling for the API call inlockList
.Enclose the API call to
adminMedmaelalistiIDLockListPatch
within a try-catch block to manage possible exceptions and provide meaningful feedback.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (4)
- libs/clients/signature-collection/src/clientConfig.json (5 hunks)
- libs/clients/signature-collection/src/lib/signature-collection-admin.service.ts (11 hunks)
- libs/clients/signature-collection/src/lib/signature-collection.service.spec.ts (5 hunks)
- libs/clients/signature-collection/src/lib/signature-collection.service.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
libs/clients/signature-collection/src/clientConfig.json (1)
Pattern
libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
libs/clients/signature-collection/src/lib/signature-collection-admin.service.ts (1)
Pattern
libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
libs/clients/signature-collection/src/lib/signature-collection.service.spec.ts (1)
Pattern
libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
libs/clients/signature-collection/src/lib/signature-collection.service.ts (1)
Pattern
libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
🔇 Additional comments (16)
libs/clients/signature-collection/src/clientConfig.json (1)
261-262
: Improved endpoint description and parameter clarity.The updates to this endpoint are beneficial:
- The summary now clearly states the purpose of the endpoint.
- The description provides important context about when the endpoint can be used.
- The
newEndDate
parameter description is more precise.These changes enhance the API's usability and help prevent misuse of the endpoint.
Also applies to: 267-267, 274-274
libs/clients/signature-collection/src/lib/signature-collection-admin.service.ts (2)
10-16
: Imports are correctly updated.The addition of
getSlug
to the imports from./types/list.dto
is appropriate and aligns with its usage within the code.
303-306
: Proper error handling implemented inremoveCandidate
.Wrapping the API call in a try-catch block effectively manages potential errors.
libs/clients/signature-collection/src/lib/signature-collection.service.spec.ts (6)
10-10
: LGTM!The import of
FrambodDTO
is correct and necessary for usage in the code.
267-268
: LGTM!The test correctly mocks
frambodApi.frambodPost
to return the expectedcandidacy
object.
272-272
: LGTM!The mock for
getApiWithAuth
correctly returnsframbodApi
on the second call.
300-301
: LGTM!The test correctly mocks
frambodApi.frambodIDDelete
to resolve successfully.
350-350
: LGTM!The test correctly mocks
listarApi.medmaelalistarIDMedmaeliPost
to return the expected response.
267-268
: Verify that all API method updates are applied consistently throughout the codebaseGiven the method signature updates outlined in the pull request, ensure that all occurrences of the old API methods have been replaced with the new ones. This includes:
medmaelalistarAddListarPost
→frambodPost
medmaeliIDRemoveMedmaeliUserPost
→medmaeliIDDelete
medmaelalistarIDAddMedmaeliPost
→medmaelalistarIDMedmaeliPost
Run the following script to check for any remaining references to the old methods:
Also applies to: 300-301, 350-350, 396-396
✅ Verification successful
Please run the following script to verify that all old API method references have been removed:
All old API method references have been successfully removed from the codebase.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Search for any remaining references to old API methods. # Test: Search for old method names in the codebase. rg --type typescript 'medmaelalistarAddListarPost|medmaeliIDRemoveMedmaeliUserPost|medmaelalistarIDAddMedmaeliPost'Length of output: 152
Script:
#!/bin/bash # Description: Search for any remaining references to old API methods in TypeScript files. rg 'medmaelalistarAddListarPost|medmaeliIDRemoveMedmaeliUserPost|medmaelalistarIDAddMedmaeliPost' --glob '*.ts' --glob '*.tsx'Length of output: 128
libs/clients/signature-collection/src/lib/signature-collection.service.ts (7)
139-142
: Validatecandidacy
properties before using themEnsure that
candidacy.id
andcandidacy.medmaelasofnun?.kosningTegund
are notundefined
ornull
to prevent potential runtime errors.Consider adding validation checks before returning the slug.
123-142
: Confirm API endpoint and request structureThe change to use
frambodPost
and the new request structure appears appropriate. Ensure that this aligns with the updated API specifications.
264-266
: Update to new API method looks correctThe switch to
medmaelalistarIDMedmaeliPost
seems consistent with the API changes.
312-314
: Change to delete signature usingmedmaeliIDDelete
is appropriateThe update aligns with the new endpoint for removing signatures.
334-337
: Removal of candidacy usingframbodIDDelete
is correctThis change correctly updates the method for deleting a candidacy.
127-127
:⚠️ Potential issueSpecify radix parameter in
parseInt
to ensure correct number parsingWhen using
parseInt
, it's best practice to specify the radix to avoid unexpected results due to different number formats.Apply this diff to fix the issue:
- sofnunID: parseInt(id), + sofnunID: parseInt(id, 10),Likely invalid or redundant comment.
134-134
:⚠️ Potential issueSpecify radix parameter in
parseInt
when parsingarea.id
To ensure consistent parsing of numerical strings, explicitly specify the radix.
Apply this diff to fix the issue:
- svaediID: parseInt(area.id), + svaediID: parseInt(area.id, 10),Likely invalid or redundant comment.
libs/clients/signature-collection/src/lib/signature-collection-admin.service.ts
Show resolved
Hide resolved
libs/clients/signature-collection/src/lib/signature-collection-admin.service.ts
Show resolved
Hide resolved
libs/clients/signature-collection/src/lib/signature-collection-admin.service.ts
Show resolved
Hide resolved
libs/clients/signature-collection/src/lib/signature-collection-admin.service.ts
Show resolved
Hide resolved
libs/clients/signature-collection/src/lib/signature-collection-admin.service.ts
Show resolved
Hide resolved
libs/clients/signature-collection/src/lib/signature-collection.service.spec.ts
Show resolved
Hide resolved
libs/clients/signature-collection/src/lib/signature-collection.service.ts
Show resolved
Hide resolved
libs/clients/signature-collection/src/lib/signature-collection.service.ts
Show resolved
Hide resolved
libs/clients/signature-collection/src/lib/signature-collection.service.ts
Show resolved
Hide resolved
Datadog ReportAll test runs ✅ 4 Total Test Services: 0 Failed, 4 Passed Test Services
🔻 Code Coverage Decreases vs Default Branch (1)
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16260 +/- ##
=======================================
Coverage 36.92% 36.93%
=======================================
Files 6781 6781
Lines 140030 139997 -33
Branches 39815 39803 -12
=======================================
- Hits 51705 51703 -2
+ Misses 88325 88294 -31
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 4 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
...
Attach a link to issue if relevant
What
Specify what you're trying to achieve
Why
Specify why you need to achieve this
Screenshots / Gifs
Attach Screenshots / Gifs to help reviewers understand the scope of the pull request
Checklist:
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Tests