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

fix(application-system-api): Fix user-profile shared-api module #15439

Merged
merged 5 commits into from
Jul 5, 2024

Conversation

saevarma
Copy link
Member

@saevarma saevarma commented Jul 3, 2024

What

Fixing the api used from the user profile v2, so we use the Me version which gets user data based on user access token.
Reinstate the bankInfo and email validation error responses.

Why

To get user profile data from the new user profile database.

Screenshots / Gifs

N/A

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Enhanced user profile validation with new checks for bank information and email, including error handling.
  • Refactor

    • Transitioned from V2UsersApi to V2MeApi for user profile services.

Add validation error handling for bank account and email.
@saevarma saevarma requested a review from a team as a code owner July 3, 2024 22:11
Copy link
Contributor

coderabbitai bot commented Jul 3, 2024

Walkthrough

The changes introduce a shift from using V2UsersApi to V2MeApi from the @island.is/clients/user-profile package within the UserProfileService and UserProfileModule. This update enhances the method for fetching user profiles and includes additional validation checks for bank information and email, accompanied by appropriate error handling.

Changes

Files Change Summary
libs/.../shared/api/user-profile/user-profile.service.ts Replaced V2UsersApi with V2MeApi, updated method parameters, added validation checks for bank info and email with error handling.
libs/.../shared/api/user-profile/user-profile.module.ts Switched from V2UsersApi to V2MeApi for module configuration.

Sequence Diagram

sequenceDiagram
    participant Client
    participant UserProfileService
    participant V2MeApi
    
    Client->>UserProfileService: Request user profile
    UserProfileService->>V2MeApi: meUserProfileControllerFindUserProfile()
    V2MeApi-->>UserProfileService: Return user profile data
    UserProfileService->>UserProfileService: Validate bank and email info
    alt Valid data
        UserProfileService-->>Client: Return profile data
    else Invalid data
        UserProfileService-->>Client: Return error
    end
Loading

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:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 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 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 as 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.

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.
  • 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: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3b5aa34 and 3587acd.

Files selected for processing (1)
  • libs/application/template-api-modules/src/lib/modules/shared/api/user-profile/user-profile.service.ts (4 hunks)
Additional context used
Path-based instructions (1)
libs/application/template-api-modules/src/lib/modules/shared/api/user-profile/user-profile.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."
Biome
libs/application/template-api-modules/src/lib/modules/shared/api/user-profile/user-profile.service.ts

[error] 28-28: Decorators are not valid here.

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.

(parse)

Additional comments not posted (4)
libs/application/template-api-modules/src/lib/modules/shared/api/user-profile/user-profile.service.ts (4)

4-4: Imports look good.

The import statements for V2MeApi and TemplateApiError are appropriate for the new functionality and error handling.

Also applies to: 21-21


26-26: Constructor update aligns with new API usage.

The constructor now correctly injects V2MeApi instead of V2UsersApi, aligning with the updated API usage.


36-36: Method update to use V2MeApi is correct.

The userProfileApiWithAuth method now correctly returns V2MeApi instead of V2UsersApi, supporting the new API.


41-41: Enhancements to userProfile method are appropriate.

The userProfile method now uses meUserProfileControllerFindUserProfile instead of userProfileControllerFindUserProfile and includes validation checks for bank information and email. These changes enhance the robustness of the method.

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3587acd and b97e6ff.

Files selected for processing (1)
  • libs/application/template-api-modules/src/lib/modules/shared/api/user-profile/user-profile.module.ts (2 hunks)
Additional context used
Path-based instructions (1)
libs/application/template-api-modules/src/lib/modules/shared/api/user-profile/user-profile.module.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 not posted (3)
libs/application/template-api-modules/src/lib/modules/shared/api/user-profile/user-profile.module.ts (3)

4-4: LGTM!

The import statement correctly changes from V2UsersApi to V2MeApi as per the PR objectives.


20-20: LGTM!

The provider correctly changes from V2UsersApi to V2MeApi as per the PR objectives.


22-25: LGTM!

The factory function correctly creates an instance of V2MeApi with the required configuration.

@datadog-island-is
Copy link

datadog-island-is bot commented Jul 5, 2024

Datadog Report

All test runs 0c9e2b2 🔗

23 Total Test Services: 0 Failed, 23 Passed
⬆️ Test Sessions change in coverage: 1 increased (+0.11%), 88 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
air-discount-scheme-web 0 0 0 2 0 8.53s 1 no change Link
api 0 0 0 4 0 2.86s 1 no change Link
api-domains-mortgage-certificate 0 0 0 5 0 18.58s 1 no change Link
application-api-files 0 0 0 12 0 6.38s 1 no change Link
application-core 0 0 0 90 0 20.27s 1 increased (+0.11%) Link
application-system-api 0 0 0 111 2 3m 23.54s 1 no change Link
application-template-api-modules 0 0 0 109 0 1m 44.87s 1 no change Link
application-templates-accident-notification 0 0 0 98 0 20.02s 1 no change Link
application-templates-criminal-record 0 0 0 2 0 11.55s 1 no change Link
application-templates-driving-license 0 0 0 13 0 17.43s 1 no change Link

@Ballioli Ballioli added the automerge Merge this PR as soon as all checks pass label Jul 5, 2024
Copy link

codecov bot commented Jul 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 37.01%. Comparing base (3cde68d) to head (8945dcc).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #15439      +/-   ##
==========================================
- Coverage   37.01%   37.01%   -0.01%     
==========================================
  Files        6555     6542      -13     
  Lines      133959   133567     -392     
  Branches    38339    38233     -106     
==========================================
- Hits        49588    49442     -146     
+ Misses      84371    84125     -246     
Flag Coverage Δ
application-templates-parental-leave 28.44% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...les/shared/api/user-profile/user-profile.module.ts 100.00% <ø> (ø)
...es/shared/api/user-profile/user-profile.service.ts 36.84% <ø> (-5.02%) ⬇️

... and 65 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3cde68d...8945dcc. Read the comment docs.

@Ballioli Ballioli added automerge Merge this PR as soon as all checks pass and removed automerge Merge this PR as soon as all checks pass labels Jul 5, 2024
@kodiakhq kodiakhq bot merged commit 162ed23 into main Jul 5, 2024
79 checks passed
@kodiakhq kodiakhq bot deleted the as-user-profile branch July 5, 2024 10:56
oskarjs pushed a commit that referenced this pull request Aug 20, 2024
* Use V2MeApi from UserProfile V2.
Add validation error handling for bank account and email.

* updating module to match service

---------

Co-authored-by: Baldur Óli <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants