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(auth-api-lib): Use company registry api to get company name on custom delegations. #15199

Merged

Conversation

saevarma
Copy link
Member

@saevarma saevarma commented Jun 11, 2024

What

Use company registry api to get company names to get up-to-date name.

Why

Companies can change names and then all old delegations will display the old name.

** BUT ** we can either manually update delegations in the DB or communicate to the users to remove the delegation and grant it again.

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 delegations handling to accommodate both individual and company information.
    • Improved error handling for more robust data processing.

@saevarma saevarma requested review from a team as code owners June 11, 2024 22:22
Copy link
Contributor

coderabbitai bot commented Jun 11, 2024

Walkthrough

The DelegationsIncomingCustomService has been updated to include company information alongside individual data. This involves introducing a new type FromNameInfo, integrating CompanyRegistryClientService, and modifying methods to handle both individual and company data. Error handling and data processing logic have also been adjusted to accommodate these changes.

Changes

File Path Change Summary
libs/auth-api-lib/src/lib/delegations/delegations-incoming-custom.service.ts Added CompanyExtendedInfo and CompanyRegistryClientService imports, new type FromNameInfo, updated methods to handle company info, changed return types, and modified error handling.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant DelegationsIncomingCustomService
    participant CompanyRegistryClientService
    participant IndividualService

    Client->>DelegationsIncomingCustomService: getDelegations()
    alt Fetching Company Info
        DelegationsIncomingCustomService->>CompanyRegistryClientService: getCompanyInfo()
        CompanyRegistryClientService-->>DelegationsIncomingCustomService: Company Info
    end
    alt Fetching Individual Info
        DelegationsIncomingCustomService->>IndividualService: getIndividualInfo()
        IndividualService-->>DelegationsIncomingCustomService: Individual Info
    end
    DelegationsIncomingCustomService-->>Client: { delegations, fromNameInfo }
Loading
sequenceDiagram
    participant Client
    participant DelegationsIncomingCustomService
    participant CompanyRegistryClientService
    participant IndividualService

    Client->>DelegationsIncomingCustomService: getDelegationsByNationalIds()
    alt Fetching Company Info
        DelegationsIncomingCustomService->>CompanyRegistryClientService: getCompanyInfo()
        CompanyRegistryClientService-->>DelegationsIncomingCustomService: Company Info
    end
    alt Fetching Individual Info
        DelegationsIncomingCustomService->>IndividualService: getIndividualInfo()
        IndividualService-->>DelegationsIncomingCustomService: Individual Info
    end
    DelegationsIncomingCustomService-->>Client: { aliveDelegations, deceasedDelegations, fromNameInfo }
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 4862a0a and 13d2445.

Files selected for processing (1)
  • libs/auth-api-lib/src/lib/delegations/delegations-incoming-custom.service.ts (9 hunks)
Additional context used
Path-based instructions (1)
libs/auth-api-lib/src/lib/delegations/delegations-incoming-custom.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/auth-api-lib/src/lib/delegations/delegations-incoming-custom.service.ts

[error] 50-51: Decorators are not valid here. (parse)

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.


[error] 52-53: Decorators are not valid here. (parse)

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.


[error] 56-57: Decorators are not valid here. (parse)

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.

Additional comments not posted (8)
libs/auth-api-lib/src/lib/delegations/delegations-incoming-custom.service.ts (8)

11-14: Added imports for CompanyExtendedInfo and CompanyRegistryClientService to support the new functionality of fetching company data.


38-41: Introduced a new type FromNameInfo to standardize the structure of name information returned by methods. This is a good practice as it enhances code readability and maintainability.


255-255: The method getLiveStatusFromDelegations now also returns FromNameInfo[], which is consistent with the new data handling strategy. This is a good update for maintaining a uniform interface across related methods.
[APROVED]


267-287: The error handling in the getLiveStatusFromDelegations method has been updated to catch errors from both companyRegistryClient and nationalRegistryClient. This is crucial for robustness, especially given the different data sources involved.


324-324: The method handlerGetError is used to handle errors uniformly across different service calls. This centralization of error handling is a good practice as it simplifies maintenance and ensures consistency.


339-342: The method getPersonByNationalId efficiently finds a person's information by their national ID from a list of FromNameInfo. This utility function is well-implemented and crucial for the functionality of the service.


55-55: Added companyRegistryClient to the constructor to facilitate company data retrieval. Ensure that this service is properly instantiated and injected where this class is used.


160-160: The method findAllIncoming now returns FromNameInfo[] instead of IndividualDto[], aligning with the new data structure. This change should be reflected wherever this method's output is consumed.

Copy link
Contributor

@Herdismaria Herdismaria left a comment

Choose a reason for hiding this comment

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

saevarma added 2 commits June 25, 2024 21:21
Add infra to auth apis using the delegation module -> companyregistryclientmodule
@saevarma saevarma force-pushed the delegation-system/get-company-name-on-custom-delegation branch from 13d2445 to 02c30be Compare June 25, 2024 21:50
@saevarma saevarma requested review from a team as code owners June 25, 2024 21:50
@saevarma saevarma requested review from programm-ingovals and removed request for programm-ingovals June 25, 2024 21:50
Copy link

codecov bot commented Jun 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 37.04%. Comparing base (ab2522d) to head (3e387c6).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #15199      +/-   ##
==========================================
- Coverage   37.04%   37.04%   -0.01%     
==========================================
  Files        6538     6538              
  Lines      133124   133117       -7     
  Branches    38128    38124       -4     
==========================================
- Hits        49318    49311       -7     
  Misses      83806    83806              
Flag Coverage Δ
api 3.44% <ø> (ø)
api-domains-auth-admin 54.29% <ø> (ø)

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

Files Coverage Δ
...services/auth/delegation-api/src/app/app.module.ts 100.00% <ø> (ø)
...auth/personal-representative/src/app/app.module.ts 100.00% <ø> (ø)
...pps/services/auth/public-api/src/app/app.module.ts 100.00% <ø> (ø)
...delegations/delegations-incoming-custom.service.ts 97.24% <ø> (-0.17%) ⬇️
...-api-lib/src/lib/delegations/delegations.module.ts 100.00% <ø> (ø)

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 ab2522d...3e387c6. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Jun 25, 2024

Datadog Report

All test runs 24d77e6 🔗

16 Total Test Services: 0 Failed, 16 Passed
🔻 Test Sessions change in coverage: 7 decreased, 2 increased, 22 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
api 0 0 0 4 0 3.99s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 15s 1 no change Link
application-system-api 0 0 0 111 2 2m 48.84s 1 no change Link
application-template-api-modules 0 0 0 109 0 2m 19.26s 1 no change Link
application-ui-shell 0 0 0 74 0 1m 4.87s 1 no change Link
auth-api-lib 0 0 0 20 0 54.69s 1 decreased (-0.03%) Link
judicial-system-web 0 0 0 317 0 56.9s 1 no change Link
portals-admin-regulations-admin 0 0 0 24 0 14.88s 1 no change Link
services-auth-admin-api 0 0 0 105 0 3m 10.27s 1 decreased (-0.76%) Link
services-auth-delegation-api 0 0 0 254 0 3m 13.75s 1 decreased (-0.71%) Link

🔻 Code Coverage Decreases vs Default Branch (7)

This report shows up to 5 code coverage decreases.

  • services-auth-admin-api - jest 51.19% (-0.76%) - Details
  • services-auth-delegation-api - jest 60.36% (-0.71%) - Details
  • services-auth-personal-representative-public - jest 46.42% (-0.63%) - Details
  • services-auth-personal-representative - jest 50.58% (-0.56%) - Details
  • services-user-profile - jest 52.51% (-0.04%) - Details

Copy link
Member

@lodmfjord lodmfjord left a comment

Choose a reason for hiding this comment

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

LGTM

@saevarma saevarma added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Jun 26, 2024
@kodiakhq kodiakhq bot merged commit b729e64 into main Jun 26, 2024
56 checks passed
@kodiakhq kodiakhq bot deleted the delegation-system/get-company-name-on-custom-delegation branch June 26, 2024 14:41
sigruntg pushed a commit that referenced this pull request Jun 27, 2024
…stom delegations. (#15199)

* Use company registry api to get company name on custom delegations.

* Add dependency on CompanyRegstiryClientModule.
Add infra to auth apis using the delegation module -> companyregistryclientmodule

* Fix name property on þjóðskrá identity.

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
snaerseljan pushed a commit that referenced this pull request Jul 2, 2024
…stom delegations. (#15199)

* Use company registry api to get company name on custom delegations.

* Add dependency on CompanyRegstiryClientModule.
Add infra to auth apis using the delegation module -> companyregistryclientmodule

* Fix name property on þjóðskrá identity.

---------

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
deprecated:automerge (Disabled) Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants