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

feat(user-profile): Remove user-profile V1 from api layer #17249

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

GunnlaugurG
Copy link
Member

@GunnlaugurG GunnlaugurG commented Dec 16, 2024

What

Remove v1 from user-profile graphql and only reference v2 and remove feature flag that switched between them

Why

V1 has become redundant

Screenshots / Gifs

Attach Screenshots / Gifs to help reviewers understand the scope of the pull request

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

    • Introduced a method for deleting user profile values.
  • Bug Fixes

    • Removed outdated methods related to SMS and email verification, simplifying error handling.
  • Chores

    • Removed unnecessary state management related to user profile versioning in the UI component.
  • Documentation

    • Updated exports to reflect the removal of email verification functionalities.

@GunnlaugurG GunnlaugurG requested review from a team as code owners December 16, 2024 12:48
Copy link
Contributor

coderabbitai bot commented Dec 16, 2024

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

warning eslint@8.57.0: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/config-array@0.11.14: Use @eslint/config-array instead
warning eslint > @humanwhocodes/config-array > @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning jest > @jest/core > jest-config > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > jest-runtime > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/reporters > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/transform > babel-plugin-istanbul > test-exclude > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > puppeteer-core > rimraf@2.7.1: Rimraf versions prior to v4 are no longer supported
warning storybook > @storybook/cli > puppeteer-core > rimraf > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > jscodeshift > temp > rimraf@2.6.3: Rimraf versions prior to v4 are no longer supported
warning storybook > @storybook/cli > jscodeshift > temp > rimraf > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > jscodeshift > @babel/plugin-proposal-class-properties@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning storybook > @storybook/cli > jscodeshift > @babel/plugin-proposal-optional-chaining@7.21.0: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning storybook > @storybook/cli > jscodeshift > @babel/plugin-proposal-nullish-coalescing-operator@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning storybook > @storybook/cli > tempy > del > rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
warning react-native > @react-native/codegen > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning react-native > @react-native/community-cli-plugin > querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
warning react-native > @react-native/community-cli-plugin > @react-native/dev-middleware > @rnx-kit/chromium-edge-launcher > rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/plugin-proposal-class-properties@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/plugin-proposal-optional-chaining@7.21.0: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/plugin-proposal-nullish-coalescing-operator@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/plugin-proposal-numeric-separator@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/plugin-proposal-async-generator-functions@7.20.7: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/plugin-proposal-object-rest-spread@7.20.7: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/plugin-proposal-optional-catch-binding@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-catch-binding instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/plugin-proposal-logical-assignment-operators@7.20.7: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-logical-assignment-operators instead.
warning next-auth > querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
warning next-auth > jose@1.28.2: this version is no longer supported
warning next-auth > @next-auth/typeorm-legacy-adapter > typeorm > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning @nx/next > @nx/webpack > stylus > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning @nx/next > @nx/webpack > webpack-dev-server > rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
warning @nx/next > @nx/webpack > fork-ts-checker-webpack-plugin > memfs@3.6.0: this will be v4
warning @nx/next > @nx/webpack > webpack-dev-server > webpack-dev-middleware > memfs@3.6.0: this will be v4
warning workspace-aggregator-2656f552-c18e-44f4-83f3-d3a48d5c55df > eslint@8.57.0: This version is no longer supported. Please see https://eslint.org/version-support for other options.

Walkthrough

This pull request involves significant refactoring of user profile management services and components. The changes primarily focus on removing version 1 (V1) of the user profile service, simplifying verification processes, and streamlining the user profile functionality. Key modifications include deleting specific verification-related methods, removing DTOs for SMS and email verification, and updating the service and resolver to work exclusively with version 2 (V2) of the user profile service.

Changes

File Path Change Summary
libs/api/domains/user-profile/src/lib/V1/userProfile.service.ts Entire file deleted, removing V1 user profile service
libs/api/domains/user-profile/src/lib/V2/userProfile.service.ts Added deleteIslykillValue method, removed verification-related methods
libs/api/domains/user-profile/src/lib/dto/confirmEmailVerificationInput.ts Deleted input DTO for email verification
libs/api/domains/user-profile/src/lib/dto/confirmSmsVerificationInput.ts Deleted input DTO for SMS verification
libs/api/domains/user-profile/src/lib/userProfile.module.ts Removed UserProfileServiceV1 from providers
libs/api/domains/user-profile/src/lib/userProfile.resolver.ts Removed methods for email and SMS verification
libs/api/domains/user-profile/src/lib/userProfile.service.ts Refactored to use only userProfileServiceV2
libs/portals/my-pages/graphql/src/hooks/profile/useResendEmailVerification.ts Deleted hook for resending email verification
libs/portals/my-pages/graphql/src/index.ts Removed exports for email verification
libs/portals/my-pages/graphql/src/lib/mutations/resendEmailVerification.ts Deleted GraphQL mutation for email verification
libs/portals/my-pages/information/src/components/PersonalInformation/Forms/ProfileForm/ProfileForm.tsx Removed v2 user profile feature flag logic

Sequence Diagram

sequenceDiagram
    participant User
    participant ProfileService
    participant UserProfileServiceV2
    
    User->>ProfileService: Request user profile
    ProfileService->>UserProfileServiceV2: Get user profile
    UserProfileServiceV2-->>ProfileService: Return user profile
    ProfileService-->>User: Display user profile
Loading

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • thordurhhh
  • disaerna
  • rafnarnason

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request.


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>, please review it.
    • 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 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

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

🧹 Nitpick comments (4)
libs/portals/my-pages/information/src/components/PersonalInformation/Forms/ProfileForm/ProfileForm.tsx (1)

Line range hint 1-324: Consider breaking down this large component

The ProfileForm component has grown quite large and handles multiple responsibilities (email, phone, bank info, paper mail, modals). Consider splitting it into smaller, more focused components to improve maintainability.

Suggested structure:

// CompanyProfileForm.tsx
const CompanyProfileForm = () => {
  // Company-specific logic and editable inputs
}

// IndividualProfileForm.tsx
const IndividualProfileForm = () => {
  // Individual-specific logic and read-only inputs
}

// ProfileForm.tsx
const ProfileForm = () => {
  const isCompany = userInfo?.profile?.subjectType === 'legalEntity'
  return isCompany ? <CompanyProfileForm /> : <IndividualProfileForm />
}
libs/api/domains/user-profile/src/lib/userProfile.service.ts (1)

4-5: Unused import Auth from @island.is/auth-nest-tools

The imported Auth is not used within the userProfile.service.ts file. Unused imports can lead to unnecessary code bloat.

Consider removing the unused import:

-import { Auth, AuthMiddleware, User } from '@island.is/auth-nest-tools'
+import { AuthMiddleware, User } from '@island.is/auth-nest-tools'
libs/api/domains/user-profile/src/lib/userProfile.resolver.ts (1)

16-18: Review the necessity of imported models and inputs

The imports for UpdateUserProfileInput, UserDeviceTokenInput, and DeleteIslykillSettings should be used within the resolver. Ensure that these are utilized; otherwise, consider removing unused imports to keep the code clean.

libs/api/domains/user-profile/src/lib/V2/userProfile.service.ts (1)

3-6: Optimize imports from @island.is/clients/user-profile

Consider importing all necessary enums and classes in a single import statement to enhance readability.

 import { Auth, AuthMiddleware, User } from '@island.is/auth-nest-tools'
-import {
-  PostNudgeDtoNudgeTypeEnum,
-  UserProfileControllerFindUserProfileClientTypeEnum,
-  V2MeApi,
-  V2UsersApi,
-} from '@island.is/clients/user-profile'
+import * as UserProfileClient from '@island.is/clients/user-profile'

...

+    private v2MeApi: UserProfileClient.V2MeApi,
+    private v2UserProfileApi: UserProfileClient.V2UsersApi,
...

+          nudgeType: UserProfileClient.PostNudgeDtoNudgeTypeEnum.NUDGE,
...

+          clientType: UserProfileClient.UserProfileControllerFindUserProfileClientTypeEnum.FirstParty,
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8aa0e52 and cee9d9a.

📒 Files selected for processing (11)
  • libs/api/domains/user-profile/src/lib/V1/userProfile.service.ts (0 hunks)
  • libs/api/domains/user-profile/src/lib/V2/userProfile.service.ts (2 hunks)
  • libs/api/domains/user-profile/src/lib/dto/confirmEmailVerificationInput.ts (0 hunks)
  • libs/api/domains/user-profile/src/lib/dto/confirmSmsVerificationInput.ts (0 hunks)
  • libs/api/domains/user-profile/src/lib/userProfile.module.ts (0 hunks)
  • libs/api/domains/user-profile/src/lib/userProfile.resolver.ts (2 hunks)
  • libs/api/domains/user-profile/src/lib/userProfile.service.ts (2 hunks)
  • libs/portals/my-pages/graphql/src/hooks/profile/useResendEmailVerification.ts (0 hunks)
  • libs/portals/my-pages/graphql/src/index.ts (0 hunks)
  • libs/portals/my-pages/graphql/src/lib/mutations/resendEmailVerification.ts (0 hunks)
  • libs/portals/my-pages/information/src/components/PersonalInformation/Forms/ProfileForm/ProfileForm.tsx (2 hunks)
💤 Files with no reviewable changes (7)
  • libs/portals/my-pages/graphql/src/index.ts
  • libs/portals/my-pages/graphql/src/lib/mutations/resendEmailVerification.ts
  • libs/api/domains/user-profile/src/lib/userProfile.module.ts
  • libs/api/domains/user-profile/src/lib/dto/confirmSmsVerificationInput.ts
  • libs/api/domains/user-profile/src/lib/dto/confirmEmailVerificationInput.ts
  • libs/portals/my-pages/graphql/src/hooks/profile/useResendEmailVerification.ts
  • libs/api/domains/user-profile/src/lib/V1/userProfile.service.ts
🧰 Additional context used
📓 Path-based instructions (4)
libs/portals/my-pages/information/src/components/PersonalInformation/Forms/ProfileForm/ProfileForm.tsx (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/api/domains/user-profile/src/lib/userProfile.resolver.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/api/domains/user-profile/src/lib/V2/userProfile.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/api/domains/user-profile/src/lib/userProfile.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 (11)
libs/portals/my-pages/information/src/components/PersonalInformation/Forms/ProfileForm/ProfileForm.tsx (3)

Line range hint 195-224: LGTM: Email input section changes align with V1 removal

The conditional rendering now correctly differentiates between company and individual users, providing appropriate input components for each case. Companies can edit directly while individuals use the IDS user profile system.


Line range hint 254-283: LGTM: Phone input section changes align with V1 removal

Similar to the email section, the phone number management has been updated to use the isCompany check for determining edit permissions.


Line range hint 1-324: Verify the impact of V1 removal on feature flags

Since we're removing the V1 user profile feature flag, let's verify there are no remaining references to it.

libs/api/domains/user-profile/src/lib/userProfile.service.ts (4)

69-70: Ensure consistent return types for getUserProfile

The method getUserProfile returns a value from userProfileServiceV2.getUserProfile(user). Verify that the returned value aligns with the UserProfile type defined in your models, ensuring type safety and consistency.


95-100: ⚠️ Potential issue

Missing user parameter in createSmsVerification method signature

The method createSmsVerification calls this.userProfileServiceV2.createSmsVerification(input, user) but user is not defined in the method scope due to the missing parameter.

Add user to the method parameters:

 async createSmsVerification(
   input: CreateSmsVerificationInput,
+  user: User,
 ): Promise<void> {
   return this.userProfileServiceV2.createSmsVerification(input, user)
 }

Likely invalid or redundant comment.


73-77: ⚠️ Potential issue

Missing user parameter in createUserProfile method signature

The createUserProfile method uses the user object but does not include it in the method's parameters. This will cause a ReferenceError since user is undefined within the method scope.

Please update the method signature to include the user parameter:

 async createUserProfile(
   input: CreateUserProfileInput,
+  user: User,
 ): Promise<UserProfile> {
   return this.userProfileServiceV2.createUserProfile(input, user)
 }

Likely invalid or redundant comment.


87-92: ⚠️ Potential issue

Missing user parameter in updateUserProfile method signature

The updateUserProfile method references user but does not include it in its parameters. This will result in a ReferenceError at runtime.

Include the user parameter in the method signature:

 async updateUserProfile(
   nationalId: string,
   input: UpdateUserProfileInput,
+  user: User,
 ): Promise<UserProfile> {
   return this.userProfileServiceV2.updateUserProfile(input, user, nationalId)
 }

Likely invalid or redundant comment.

libs/api/domains/user-profile/src/lib/userProfile.resolver.ts (3)

2-2: Correct import path for Args, Mutation, Query, and Resolver

Ensure that the import path for @nestjs/graphql is correct and that these imports are necessary for the resolver's functionality.


12-12: Verify the import of CreateSmsVerificationInput

Confirm that CreateSmsVerificationInput is correctly defined in the specified path and that it matches the expected structure for the input.


20-22: Confirm the usage of imported models

Verify that Response, UserDeviceToken, and UserProfile are correctly used in the resolver methods and correspond to the GraphQL schema definitions.

libs/api/domains/user-profile/src/lib/V2/userProfile.service.ts (1)

172-192: Ensure proper error handling and response in deleteIslykillValue method

The deleteIslykillValue method updates the user profile and checks for the presence of nationalId. Ensure that:

  • The updateMeUserProfile method returns an object containing nationalId.
  • The error handling correctly captures scenarios where the update might fail.
  • The returned DeleteIslykillSettings object aligns with the expected structure.

Copy link
Contributor

@magnearun magnearun left a comment

Choose a reason for hiding this comment

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

LGTM :)

Copy link

codecov bot commented Dec 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.74%. Comparing base (e9edeb3) to head (769ce7b).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #17249      +/-   ##
==========================================
+ Coverage   35.71%   35.74%   +0.03%     
==========================================
  Files        6944     6935       -9     
  Lines      148537   148093     -444     
  Branches    42405    42208     -197     
==========================================
- Hits        53047    52935     -112     
+ Misses      95490    95158     -332     
Flag Coverage Δ
api 3.33% <ø> (ø)

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

see 68 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 ab48b56...769ce7b. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Dec 16, 2024

Datadog Report

Branch report: feat/cleanup-user-profile-v1
Commit report: d4c02a8
Test service: api

✅ 0 Failed, 4 Passed, 0 Skipped, 2.57s Total Time
➡️ Test Sessions change in coverage: 1 no change

@GunnlaugurG GunnlaugurG added the automerge Merge this PR as soon as all checks pass label Dec 18, 2024
@kodiakhq kodiakhq bot merged commit e558168 into main Dec 18, 2024
41 checks passed
@kodiakhq kodiakhq bot deleted the feat/cleanup-user-profile-v1 branch December 18, 2024 13:41
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