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(license-service): Use smart-solutions-v2 client #15960

Closed
wants to merge 17 commits into from

Conversation

thorkellmani
Copy link
Member

@thorkellmani thorkellmani commented Sep 11, 2024

What

  • Use the smartSolutions client in the license service / license api

Why

  • It utilizes the enhancedFetch, we want that.

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 factory function for streamlined configuration of Smart Solutions modules across various license clients.
    • Enhanced flexibility in data handling with updated return types for several methods, allowing for partial representations of Pass objects.
  • Bug Fixes

    • Improved robustness by implementing optional chaining in method calls to prevent runtime errors.
  • Refactor

    • Simplified module imports and configurations, enhancing maintainability and readability across multiple license client modules.
    • Updated import paths to reflect the transition to a new version of the Smart Solutions API client.
    • Added new exports for configuration-related types in the Smart Solutions module.

@thorkellmani thorkellmani added the deploy-feature Deploys features to dev label Sep 11, 2024
Copy link
Contributor

coderabbitai bot commented Sep 11, 2024

Walkthrough

The changes introduced in the pull request primarily involve updates to the return types of various methods across multiple services related to license handling. The return types have been modified to allow for more flexible structures, specifically changing from Promise<Result<Pass | undefined>> to Promise<Result<Partial<Pass> | undefined>>. Additionally, there is a shift in the import statements for the SmartSolutions client, moving from an older version to a new version, which may indicate enhancements in functionality. The registration of modules has also been refactored to utilize a factory function for configuration.

Changes

File Path Change Summary
apps/services/license-api/src/app/modules/license/license.service.ts Updated return types of updateLicense and pullLicense methods from `Promise<Result<Pass
libs/clients/license-client/src/lib/clients/adr-license-client/adrLicenseClient.module.ts Refactored registration of SmartSolutionsApiClientModule to use smartSolutionsModuleFactory.
libs/clients/license-client/src/lib/clients/adr-license-client/adrLicenseClient.service.ts Changed import from SmartSolutionsApi to SmartSolutionsService and updated return type of getPkPass.
libs/clients/license-client/src/lib/clients/baseLicenseUpdateClient.ts Updated return types of pushUpdate and pullUpdate methods to `Promise<Result<Partial
libs/clients/license-client/src/lib/clients/disability-license-client/modules/disabilityLicenseClient.module.ts Refactored registration of SmartSolutionsApiClientModule to use smartSolutionsModuleFactory.
libs/clients/license-client/src/lib/clients/disability-license-client/services/disabilityLicenseClient.service.ts Changed import from SmartSolutionsApi to SmartSolutionsService and updated return type of getPkPass.
libs/clients/license-client/src/lib/clients/driving-license-client/modules/drivingLicenseClient.module.ts Refactored registration of SmartSolutionsApiClientModule to use smartSolutionsModuleFactory.
libs/clients/license-client/src/lib/clients/driving-license-client/services/drivingLicenseClient.service.ts Changed import from SmartSolutionsApi to SmartSolutionsService and updated return type of getPkPass.
libs/clients/license-client/src/lib/clients/firearm-license-client/modules/firearmLicenseClient.module.ts Refactored registration of SmartSolutionsFirearmModule to use smartSolutionsModuleFactory.
libs/clients/license-client/src/lib/clients/firearm-license-client/services/firearmLicenseClient.service.ts Changed import from SmartSolutionsApi to SmartSolutionsService and updated return type of getPkPass.
libs/clients/license-client/src/lib/clients/hunting-license-client/huntingLicenseClient.module.ts Refactored registration of SmartSolutionsApiClientModule to use smartSolutionsModuleFactory.
libs/clients/license-client/src/lib/clients/hunting-license-client/huntingLicenseClient.service.ts Changed import from SmartSolutionsApi to SmartSolutionsService and updated return type of getPkPass.
libs/clients/license-client/src/lib/clients/machine-license-client/machineLicenseClient.module.ts Refactored registration of SmartSolutionsApiClientModule to use smartSolutionsModuleFactory.
libs/clients/license-client/src/lib/clients/machine-license-client/machineLicenseClient.service.ts Changed import from SmartSolutionsApi to SmartSolutionsService and updated return type of getPkPass.
libs/clients/license-client/src/lib/factories/clientConfigFactory.ts Updated import of SmartSolutionsApiConfigSchema to source from @island.is/clients/smart-solutions-v2.
libs/clients/license-client/src/lib/factories/smartSolutionsModuleFactory.ts Added new factory function smartSolutionsModuleFactory for module registration.
libs/clients/license-client/src/lib/licenseClient.module.ts Reordered import statements for better organization.
libs/clients/smart-solutions-v2/src/index.ts Added exports for SmartSolutionsConfig and SmartSolutionsApiConfigSchema.
libs/clients/smart-solutions-v2/src/lib/smartSolutions.service.ts Minor modifications to imports and logging functionality in SmartSolutionsService.
libs/clients/firearm-license-client/modules/smartSolutionsFirearm.module.ts Removed the SmartSolutionsFirearmModule.

Possibly related PRs

Suggested labels

automerge


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 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

codecov bot commented Sep 11, 2024

Codecov Report

Attention: Patch coverage is 77.77778% with 12 lines in your changes missing coverage. Please review.

Project coverage is 36.80%. Comparing base (9ef986b) to head (89edd13).
Report is 70 commits behind head on main.

Files with missing lines Patch % Lines
...ine-license-client/machineLicenseClient.service.ts 25.00% 3 Missing ⚠️
...se-client/services/drivingLicenseClient.service.ts 33.33% 2 Missing ⚠️
...nts/adr-license-client/adrLicenseClient.service.ts 66.66% 1 Missing ⚠️
...client/services/disabilityLicenseClient.service.ts 66.66% 1 Missing ⚠️
.../services/disabilityLicenseUpdateClient.service.ts 66.66% 1 Missing ⚠️
...ent/services/drivingLicenseUpdateClient.service.ts 50.00% 1 Missing ⚠️
...se-client/services/firearmLicenseClient.service.ts 50.00% 1 Missing ⚠️
...ent/services/firearmLicenseUpdateClient.service.ts 50.00% 1 Missing ⚠️
...ing-license-client/huntingLicenseClient.service.ts 50.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #15960      +/-   ##
==========================================
+ Coverage   36.76%   36.80%   +0.03%     
==========================================
  Files        6785     6743      -42     
  Lines      139900   137588    -2312     
  Branches    39772    39051     -721     
==========================================
- Hits        51435    50639     -796     
+ Misses      88465    86949    -1516     
Flag Coverage Δ
api 3.39% <ø> (ø)
clients-license-client 1.84% <0.00%> (+0.01%) ⬆️
license-api 43.17% <77.77%> (+0.49%) ⬆️

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

Files with missing lines Coverage Δ
...nse-api/src/app/modules/license/license.service.ts 82.30% <ø> (ø)
...cense-api/src/app/modules/license/license.types.ts 100.00% <ø> (ø)
...ents/adr-license-client/adrLicenseClient.module.ts 100.00% <100.00%> (+33.33%) ⬆️
...ients/adr-license-client/adrLicenseClientMapper.ts 15.62% <ø> (ø)
...-client/src/lib/clients/baseLicenseUpdateClient.ts 100.00% <100.00%> (ø)
...e-client/modules/disabilityLicenseClient.module.ts 100.00% <100.00%> (+14.28%) ⬆️
...nt/modules/disabilityLicenseUpdateClient.module.ts 100.00% <100.00%> (ø)
...nts/driving-license-client/drivingLicenseMapper.ts 17.30% <ø> (ø)
...ense-client/modules/drivingLicenseClient.module.ts 100.00% <100.00%> (+12.50%) ⬆️
...lient/modules/drivingLicenseUpdateClient.module.ts 100.00% <100.00%> (ø)
... and 22 more

... and 275 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 9ef986b...89edd13. Read the comment docs.

Copy link
Contributor

Affected services are: api,license-api,
Feature deployment of your services will begin shortly. Your feature will be accessible here:
https://featuse-smart-solutions-v2-api-catalogue.dev01.devland.is/api
https://featuse-smart-solutions-v2-beta.dev01.devland.is/
https://featuse-smart-solutions-v2-beta.dev01.devland.is/api
https://featuse-smart-solutions-v2-beta.dev01.devland.is/samradsgatt
https://featuse-smart-solutions-v2-license-api-xrd.internal.dev01.devland.is/

Deployed services: api,license-api,consultation-portal,web.
Excluded services: ``

@datadog-island-is
Copy link

datadog-island-is bot commented Sep 11, 2024

Datadog Report

All test runs fd044b5 🔗

3 Total Test Services: 0 Failed, 2 Passed
⬆️ Test Sessions change in coverage: 2 increased, 4 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 2.8s 1 no change Link
api-domains-license-service 0 0 0 0 0 538.5ms 1 no change Link
license-api 0 0 0 80 0 27.49s 1 increased (+0.29%) Link

Copy link
Contributor

@thoreyjona thoreyjona left a comment

Choose a reason for hiding this comment

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

LGTM. I tested the app and the licenses worked and looked as before (no. Gervimaður with firearm license so I did not try that license)

@thorkellmani thorkellmani marked this pull request as ready for review September 17, 2024 11:20
@thorkellmani thorkellmani requested review from a team as code owners September 17, 2024 11:20
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: 9

Outside diff range and nitpick comments (6)
libs/clients/license-client/src/lib/clients/disability-license-client/modules/disabilityLicenseUpdateClient.module.ts (1)

9-9: Inconsistent Naming of Module Class

The module class is named DisabilityUpdateClientModule, whereas the service it provides is DisabilityLicenseUpdateClient. For consistency and clarity, consider renaming the module class to DisabilityLicenseUpdateClientModule.

libs/clients/license-client/src/lib/clients/driving-license-client/modules/drivingLicenseUpdateClient.module.ts (1)

5-10: Ensure adherence to effective tree-shaking and bundling practices

When introducing new imports and modules, confirm that they are designed to support effective tree-shaking so unused code is not included in the final bundle. Verify that the module's exports are optimized for bundling and that any unnecessary code is eliminated during the build process.

libs/clients/smart-solutions-v2/src/lib/smartSolutions.service.ts (1)

29-32: Consider separating type imports for clarity

While importing types using the type modifier within an import statement is valid, separating type-only imports using import type can enhance readability and maintain consistency across the codebase.

Apply this diff to separate the type import:

-import {
-  LOG_CATEGORY,
-  type SmartSolutionsModuleOptions,
-} from './types/config.type'
+import { LOG_CATEGORY } from './types/config.type'
+import type { SmartSolutionsModuleOptions } from './types/config.type'
libs/clients/license-client/src/lib/clients/adr-license-client/adrLicenseClient.service.ts (1)

20-24: Confirm Effective Tree-Shaking and Bundling Practices

By importing specific members from '@island.is/clients/smart-solutions-v2', you help ensure that unused code is excluded during the bundling process. Confirm that the build setup correctly supports tree-shaking for this module to optimize the application size.

You might want to verify the bundle analysis to ensure that no unnecessary code is included from the smart-solutions-v2 client.

libs/clients/license-client/src/lib/clients/firearm-license-client/services/firearmLicenseClient.service.ts (1)

33-33: Consider Renaming smartApi for Clarity and Consistency

For improved clarity and consistency, consider renaming the smartApi property to smartSolutionsApi or smartSolutionsService. This aligns with the class name SmartSolutionsService and follows the naming convention used for firearmApi.

libs/clients/license-client/src/lib/clients/driving-license-client/services/drivingLicenseClient.service.ts (1)

342-342: Validate Access to passInputField Properties

The optional chaining in accessing passInputField.identifier suggests that passInputField might be undefined. Consider adding validation to handle cases where passInputField or its properties may not exist to prevent potential runtime errors.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e8480d9 and 75f499c.

Files selected for processing (26)
  • apps/services/license-api/src/app/modules/license/license.service.ts (4 hunks)
  • libs/clients/license-client/src/lib/clients/adr-license-client/adrLicenseClient.module.ts (1 hunks)
  • libs/clients/license-client/src/lib/clients/adr-license-client/adrLicenseClient.service.ts (3 hunks)
  • libs/clients/license-client/src/lib/clients/baseLicenseUpdateClient.ts (1 hunks)
  • libs/clients/license-client/src/lib/clients/disability-license-client/modules/disabilityLicenseClient.module.ts (1 hunks)
  • libs/clients/license-client/src/lib/clients/disability-license-client/modules/disabilityLicenseUpdateClient.module.ts (1 hunks)
  • libs/clients/license-client/src/lib/clients/disability-license-client/services/disabilityLicenseClient.service.ts (3 hunks)
  • libs/clients/license-client/src/lib/clients/disability-license-client/services/disabilityLicenseUpdateClient.service.ts (1 hunks)
  • libs/clients/license-client/src/lib/clients/driving-license-client/modules/drivingLicenseClient.module.ts (1 hunks)
  • libs/clients/license-client/src/lib/clients/driving-license-client/modules/drivingLicenseUpdateClient.module.ts (1 hunks)
  • libs/clients/license-client/src/lib/clients/driving-license-client/services/drivingLicenseClient.service.ts (4 hunks)
  • libs/clients/license-client/src/lib/clients/driving-license-client/services/drivingLicenseUpdateClient.service.ts (5 hunks)
  • libs/clients/license-client/src/lib/clients/firearm-license-client/modules/firearmLicenseClient.module.ts (1 hunks)
  • libs/clients/license-client/src/lib/clients/firearm-license-client/modules/firearmLicenseUpdateClient.module.ts (1 hunks)
  • libs/clients/license-client/src/lib/clients/firearm-license-client/modules/smartSolutionsFirearm.module.ts (0 hunks)
  • libs/clients/license-client/src/lib/clients/firearm-license-client/services/firearmLicenseClient.service.ts (3 hunks)
  • libs/clients/license-client/src/lib/clients/firearm-license-client/services/firearmLicenseUpdateClient.service.ts (5 hunks)
  • libs/clients/license-client/src/lib/clients/hunting-license-client/huntingLicenseClient.module.ts (1 hunks)
  • libs/clients/license-client/src/lib/clients/hunting-license-client/huntingLicenseClient.service.ts (3 hunks)
  • libs/clients/license-client/src/lib/clients/machine-license-client/machineLicenseClient.module.ts (1 hunks)
  • libs/clients/license-client/src/lib/clients/machine-license-client/machineLicenseClient.service.ts (3 hunks)
  • libs/clients/license-client/src/lib/factories/clientConfigFactory.ts (1 hunks)
  • libs/clients/license-client/src/lib/factories/smartSolutionsModuleFactory.ts (1 hunks)
  • libs/clients/license-client/src/lib/licenseClient.module.ts (1 hunks)
  • libs/clients/smart-solutions-v2/src/index.ts (1 hunks)
  • libs/clients/smart-solutions-v2/src/lib/smartSolutions.service.ts (1 hunks)
Files not reviewed due to no reviewable changes (1)
  • libs/clients/license-client/src/lib/clients/firearm-license-client/modules/smartSolutionsFirearm.module.ts
Files skipped from review due to trivial changes (1)
  • libs/clients/license-client/src/lib/licenseClient.module.ts
Additional context used
Path-based instructions (24)
libs/clients/smart-solutions-v2/src/index.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/license-client/src/lib/clients/disability-license-client/modules/disabilityLicenseUpdateClient.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."
libs/clients/license-client/src/lib/clients/adr-license-client/adrLicenseClient.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."
libs/clients/license-client/src/lib/clients/hunting-license-client/huntingLicenseClient.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."
libs/clients/license-client/src/lib/clients/machine-license-client/machineLicenseClient.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."
libs/clients/license-client/src/lib/clients/firearm-license-client/modules/firearmLicenseClient.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."
libs/clients/license-client/src/lib/clients/driving-license-client/modules/drivingLicenseUpdateClient.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."
libs/clients/license-client/src/lib/clients/disability-license-client/modules/disabilityLicenseClient.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."
libs/clients/license-client/src/lib/clients/firearm-license-client/modules/firearmLicenseUpdateClient.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."
libs/clients/license-client/src/lib/clients/driving-license-client/modules/drivingLicenseClient.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."
libs/clients/license-client/src/lib/factories/clientConfigFactory.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/license-client/src/lib/factories/smartSolutionsModuleFactory.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/license-client/src/lib/clients/baseLicenseUpdateClient.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/license-client/src/lib/clients/disability-license-client/services/disabilityLicenseUpdateClient.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/smart-solutions-v2/src/lib/smartSolutions.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/license-client/src/lib/clients/firearm-license-client/services/firearmLicenseUpdateClient.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/license-client/src/lib/clients/disability-license-client/services/disabilityLicenseClient.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/license-client/src/lib/clients/hunting-license-client/huntingLicenseClient.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/license-client/src/lib/clients/machine-license-client/machineLicenseClient.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/license-client/src/lib/clients/adr-license-client/adrLicenseClient.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/license-client/src/lib/clients/driving-license-client/services/drivingLicenseUpdateClient.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/license-client/src/lib/clients/firearm-license-client/services/firearmLicenseClient.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/license-client/src/lib/clients/driving-license-client/services/drivingLicenseClient.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."
apps/services/license-api/src/app/modules/license/license.service.ts (2)

Pattern apps/services/**/*: "Confirm that the code adheres to the following:

  • NestJS architecture, including modules, services, and controllers.
  • Dependency injection patterns and service encapsulation.
  • Integration and unit testing coverage and practices."

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
Additional comments not posted (51)
libs/clients/smart-solutions-v2/src/index.ts (1)

5-8: Great job exporting configuration types for reusability

Exporting SmartSolutionsConfig and SmartSolutionsApiConfigSchema enhances the reusability of configuration types across different NextJS apps. This aligns with TypeScript best practices for defining and exporting types, and it facilitates effective configuration management throughout the application.

libs/clients/license-client/src/lib/clients/disability-license-client/modules/disabilityLicenseUpdateClient.module.ts (2)

4-4: Importing smartSolutionsModuleFactory Correctly

The import statement for smartSolutionsModuleFactory is correctly implemented and points to the appropriate path.


7-7: Simplified Module Configuration with Factory Function

Using smartSolutionsModuleFactory(DisabilityDigitalLicenseClientConfig) in the imports array simplifies the module configuration and aligns with NestJS best practices for module initialization.

libs/clients/license-client/src/lib/clients/adr-license-client/adrLicenseClient.module.ts (1)

10-10: Verify that smartSolutionsModuleFactory correctly configures the module

Ensure that smartSolutionsModuleFactory(AdrDigitalLicenseClientConfig) properly sets up the Smart Solutions module with all necessary configurations. Since the asynchronous registration method has been replaced, it's important to confirm that parameters like apiKey, apiUrl, and passTemplateId are still correctly handled.

Run the following script to verify the factory function implementation and its usage:

libs/clients/license-client/src/lib/clients/hunting-license-client/huntingLicenseClient.module.ts (2)

5-5: Use of smartSolutionsModuleFactory enhances modularity and reusability.

Introducing smartSolutionsModuleFactory promotes better modularity and reusability across different modules, aligning with best practices for scalable codebases. This change also supports effective tree-shaking and bundling practices within the libs directory.


10-10: Confirm correct configuration passed to smartSolutionsModuleFactory.

Please ensure that HuntingDigitalLicenseClientConfig includes all necessary configuration parameters required by smartSolutionsModuleFactory to initialize the module properly. This verification will help prevent potential runtime issues.

To confirm that HuntingDigitalLicenseClientConfig provides the necessary properties, you can run the following script:

libs/clients/license-client/src/lib/clients/machine-license-client/machineLicenseClient.module.ts (1)

5-10: Simplified module configuration enhances maintainability

Great job refactoring the module to use smartSolutionsModuleFactory. This change improves readability and maintainability by streamlining the import process and encapsulating the configuration logic within a dedicated factory function.

libs/clients/license-client/src/lib/clients/firearm-license-client/modules/firearmLicenseClient.module.ts (2)

4-5: Imports updated to use smartSolutionsModuleFactory

The imports have been correctly updated to include smartSolutionsModuleFactory and FirearmDigitalLicenseClientConfig, aligning with the integration of the new smartSolutions client.


8-11: Ensure FirearmDigitalLicenseClientConfig is compatible with the factory

Please verify that FirearmDigitalLicenseClientConfig provides all the necessary configuration parameters required by smartSolutionsModuleFactory. This ensures proper instantiation of the module and prevents potential runtime issues.

You can confirm the structure of FirearmDigitalLicenseClientConfig with the following script:

Verification successful

FirearmDigitalLicenseClientConfig is compatible with smartSolutionsModuleFactory

After thorough examination of the relevant files, we can confirm that FirearmDigitalLicenseClientConfig is indeed compatible with smartSolutionsModuleFactory. Here's why:

  1. The smartSolutionsModuleFactory expects a configuration with apiKey, apiUrl, and passTemplateId.
  2. The clientConfigFactory creates a configuration object with these exact properties.
  3. FirearmLicenseClientModule correctly uses smartSolutionsModuleFactory with FirearmDigitalLicenseClientConfig.
  4. Both the smartSolutionsModuleFactory and clientConfigFactory use the same SmartSolutionsApiConfigSchema, ensuring type compatibility.

This setup ensures that the necessary configuration parameters are provided for proper instantiation of the module, preventing potential runtime issues.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the structure of FirearmDigitalLicenseClientConfig.

# Test: Find the definition of FirearmDigitalLicenseClientConfig.
# Expect: An interface or class with the necessary configuration properties.

ast-grep --lang typescript --pattern $'export interface FirearmDigitalLicenseClientConfig {
  $$$
}' --type ts

# Alternatively, display where FirearmDigitalLicenseClientConfig is defined.
rg --type ts 'export .* FirearmDigitalLicenseClientConfig' -A 10

Length of output: 1475


Script:

#!/bin/bash
# Search for clientConfigFactory definition
ast-grep --lang typescript --pattern 'export const clientConfigFactory = $$$'

# Look for smartSolutionsModuleFactory implementation
ast-grep --lang typescript --pattern 'export function smartSolutionsModuleFactory($$$) {
  $$$
}'

# If ast-grep doesn't find the implementations, use rg as a fallback
rg --type ts 'export const clientConfigFactory' -A 10
rg --type ts 'export function smartSolutionsModuleFactory' -A 10

Length of output: 5348


Script:

#!/bin/bash
# Search for smartSolutionsModuleFactory with a more flexible pattern
rg --type ts 'function.*smartSolutions.*Factory' -i -A 10

# Look for any factory function related to smart solutions or modules
rg --type ts 'function.*Factory.*smartSolutions' -i -A 10
rg --type ts 'function.*Module.*Factory' -i -A 10

# Search for files that might contain the factory function
fd -e ts | xargs grep -l "smartSolutions" | xargs grep -l "Factory"

Length of output: 1548


Script:

#!/bin/bash
# Examine smartSolutionsModuleFactory.ts
cat libs/clients/license-client/src/lib/factories/smartSolutionsModuleFactory.ts

# Review FirearmLicenseClientModule
cat libs/clients/license-client/src/lib/clients/firearm-license-client/modules/firearmLicenseClient.module.ts

# Review clientConfigFactory.ts (for comparison)
cat libs/clients/license-client/src/lib/factories/clientConfigFactory.ts

Length of output: 2263

libs/clients/license-client/src/lib/clients/driving-license-client/modules/drivingLicenseUpdateClient.module.ts (2)

5-5: Verify the import path for smartSolutionsModuleFactory

Ensure that the relative import path '../../../factories/smartSolutionsModuleFactory' is correct and that smartSolutionsModuleFactory is properly exported from that location. Incorrect import paths or missing exports can lead to module resolution errors.

Run the following script to confirm the export of smartSolutionsModuleFactory:

Verification successful

To complete the verification, I need to confirm the exact location of the importing file. I'll generate a shell script to find this information.


Import path for smartSolutionsModuleFactory is correct

The relative import path '../../../factories/smartSolutionsModuleFactory' in the file drivingLicenseUpdateClient.module.ts is correct. It properly points to the location where smartSolutionsModuleFactory is exported from libs/clients/license-client/src/lib/factories/smartSolutionsModuleFactory.ts.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that 'smartSolutionsModuleFactory' is exported from the expected module

# Test: Search for the export statement of 'smartSolutionsModuleFactory'
# Expect: The export statement should be found in the codebase

rg --type ts 'export.*smartSolutionsModuleFactory'

Length of output: 174


Script:

#!/bin/bash
# Find the exact location of the importing file
fd -t f drivingLicenseUpdateClient.module.ts

Length of output: 158


10-10: Confirm configuration compatibility with smartSolutionsModuleFactory

Verify that DrivingDigitalLicenseClientConfig provides all the necessary configuration properties expected by smartSolutionsModuleFactory. Ensure that the types are correctly defined and compatible to prevent runtime issues and to leverage TypeScript's type checking.

Run the following script to check the definition of DrivingDigitalLicenseClientConfig:

Verification successful

Configuration compatibility with smartSolutionsModuleFactory confirmed

The DrivingDigitalLicenseClientConfig is fully compatible with the smartSolutionsModuleFactory. Both use the same set of properties (apiKey, apiUrl, passTemplateId), ensuring that all necessary configuration properties are provided. The types are correctly defined and compatible, leveraging TypeScript's type checking and preventing potential runtime issues.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find the definition of 'DrivingDigitalLicenseClientConfig' and verify its properties

# Test: Locate the interface or type definition
# Expect: The type definition is found and matches expected properties

ast-grep --lang typescript --pattern $'export interface DrivingDigitalLicenseClientConfig {\n  $$$\n}'

Length of output: 101


Script:

#!/bin/bash
# Search for DrivingDigitalLicenseClientConfig definition
rg "interface DrivingDigitalLicenseClientConfig" -A 10

# Search for similar interface names in case of typos
rg "interface Driving.*LicenseClientConfig" -A 10

# Look for imports of DrivingDigitalLicenseClientConfig
rg "import.*DrivingDigitalLicenseClientConfig"

# Search for any mention of DrivingDigitalLicenseClientConfig
rg "DrivingDigitalLicenseClientConfig"

Length of output: 3289


Script:

#!/bin/bash
# Check the implementation of clientConfigFactory
rg "const clientConfigFactory = " -A 20

# Look for smartSolutionsModuleFactory definition or usage
rg "function smartSolutionsModuleFactory" -A 10
rg "const smartSolutionsModuleFactory = " -A 10

# Check for any comments or documentation about smartSolutionsModuleFactory requirements
rg "smartSolutionsModuleFactory" -B 5 -A 5

Length of output: 25157

libs/clients/license-client/src/lib/clients/disability-license-client/modules/disabilityLicenseClient.module.ts (2)

5-5: Import of 'smartSolutionsModuleFactory' is correct

The import statement for smartSolutionsModuleFactory is accurate, and the relative path is correctly specified.


10-10: Verify configuration passed to 'smartSolutionsModuleFactory'

The use of smartSolutionsModuleFactory(DisabilityDigitalLicenseClientConfig) in the module's imports effectively changes the integration approach. Please ensure that DisabilityDigitalLicenseClientConfig provides all necessary configuration options required by the Smart Solutions client.

Run the following script to confirm that DisabilityDigitalLicenseClientConfig includes all required configurations:

Verification successful

Verification of 'smartSolutionsModuleFactory' configuration successful

The DisabilityDigitalLicenseClientConfig passed to smartSolutionsModuleFactory does indeed provide all necessary configuration options required by the Smart Solutions client. The configuration includes:

  • apiKey: Loaded from the TR_PKPASS_API_KEY environment variable.
  • apiUrl: Loaded from the SMART_SOLUTIONS_API_URL environment variable, with a default value if not set.
  • passTemplateId: Loaded from the DISABILITY_LICENSE_PASS_TEMPLATE_ID environment variable.

These properties are correctly structured to meet the requirements of the SmartSolutionsConfig interface used by smartSolutionsModuleFactory.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that DisabilityDigitalLicenseClientConfig contains necessary configurations.

# Search for the definition of DisabilityDigitalLicenseClientConfig
rg 'export interface DisabilityDigitalLicenseClientConfig' --type ts

# Search for usage of configurations in smartSolutionsModuleFactory
rg 'smartSolutionsModuleFactory' --type ts -A 10

# Compare the required configuration properties with those provided by DisabilityDigitalLicenseClientConfig

Length of output: 15059


Script:

#!/bin/bash
# Search for DisabilityDigitalLicenseClientConfig definition or import
rg "DisabilityDigitalLicenseClientConfig" --type ts

# Search for any disability-related configuration files
fd -e ts -e js disability.*config

# If the above doesn't yield results, search for any config files in the disability license client directory
fd -e ts -e js config libs/clients/license-client/src/lib/clients/disability-license-client

Length of output: 2364


Script:

#!/bin/bash
# Display the contents of disabilityLicenseClient.config.ts
cat libs/clients/license-client/src/lib/clients/disability-license-client/disabilityLicenseClient.config.ts

# Search for the definition or usage of clientConfigFactory
rg "clientConfigFactory" --type ts

# Search for apiKey, apiUrl, and passTemplateId in disability-related config files
rg "apiKey|apiUrl|passTemplateId" libs/clients/license-client/src/lib/clients/disability-license-client/disabilityLicenseClient.config.ts

Length of output: 4910


Script:

#!/bin/bash
# Display the contents of clientConfigFactory.ts
cat libs/clients/license-client/src/lib/factories/clientConfigFactory.ts

# Search for apiKey, apiUrl, and passTemplateId in the clientConfigFactory.ts file
rg "apiKey|apiUrl|passTemplateId" libs/clients/license-client/src/lib/factories/clientConfigFactory.ts

Length of output: 1027

libs/clients/license-client/src/lib/clients/firearm-license-client/modules/firearmLicenseUpdateClient.module.ts (2)

4-5: Imports added appropriately

The imports for smartSolutionsModuleFactory and FirearmDigitalLicenseClientConfig are correctly added, and the paths appear accurate.


8-11: Module imports updated to use factory function

The imports array now includes smartSolutionsModuleFactory(FirearmDigitalLicenseClientConfig), which replaces the previous module import. This change aligns with the PR objective to integrate the smartSolutions client using the factory function.

libs/clients/license-client/src/lib/clients/driving-license-client/modules/drivingLicenseClient.module.ts (2)

6-6: Effective use of factory function for module configuration

Importing smartSolutionsModuleFactory enhances the modularity and reusability of the configuration setup.


12-12: Streamlined module registration

Replacing the asynchronous registration with smartSolutionsModuleFactory(DrivingDigitalLicenseClientConfig) simplifies the module imports and improves maintainability.

libs/clients/license-client/src/lib/factories/smartSolutionsModuleFactory.ts (1)

1-21: LGTM!

The smartSolutionsModuleFactory is correctly implemented. It utilizes TypeScript effectively by defining and exporting types, ensuring strong typing throughout. The factory function enhances reusability and can be integrated across different NextJS applications. Additionally, it adheres to effective tree-shaking and bundling practices.

libs/clients/license-client/src/lib/clients/baseLicenseUpdateClient.ts (3)

3-3: Import statement updated correctly

The addition of PassVerificationData and Result from '../licenseClient.type' ensures that the necessary types are available for the class functionality.


8-9: Imported SmartSolutionsService appropriately

Including SmartSolutionsService from '@island.is/clients/smart-solutions-v2' aligns with the integration of the new smart solutions client, as per the PR objectives.


22-22: Updated return types to Partial<Pass> increase flexibility

Changing the return types of pushUpdate and pullUpdate to Promise<Result<Partial<Pass> | undefined>> allows for partial updates and provides greater flexibility in handling Pass objects. This modification is appropriate and aligns with the goal of enhancing the license service.

Also applies to: 27-27

libs/clients/license-client/src/lib/clients/disability-license-client/services/disabilityLicenseUpdateClient.service.ts (4)

10-15: Updated imports to use SmartSolutionsService

The imports have been correctly updated to use the new SmartSolutionsService from @island.is/clients/smart-solutions-v2, aligning with the updated client.


21-21: Ensure compatibility with BaseLicenseUpdateClient

The constructor now accepts smartApi: SmartSolutionsService. Please verify that this change is compatible with the BaseLicenseUpdateClient and that any overridden methods function correctly with the new service.

To check for compatibility issues, you can search for usages of smartApi in the base class methods:

Verification successful

Change is compatible with BaseLicenseUpdateClient

The addition of smartApi: SmartSolutionsService to the DisabilityLicenseUpdateClient constructor is compatible with BaseLicenseUpdateClient. The base class already includes smartApi in its constructor, so this change maintains consistency.

  • DisabilityLicenseUpdateClient correctly extends BaseLicenseUpdateClient
  • BaseLicenseUpdateClient constructor includes protected smartApi: SmartSolutionsService
  • No compatibility issues were found related to the smartApi addition

Ensure that the abstract methods (pushUpdate, pullUpdate, revoke, and verify) are properly implemented in DisabilityLicenseUpdateClient.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for `smartApi` usages in BaseLicenseUpdateClient to verify compatibility.

# Command: Find all references to `smartApi` in BaseLicenseUpdateClient
ast-grep --lang typescript --pattern 'this.smartApi.$$$' libs/clients/license-client/src/lib/clients/baseLicenseUpdateClient.ts

Length of output: 129


Script:

#!/bin/bash

# 1. Verify the existence of BaseLicenseUpdateClient
echo "Checking for BaseLicenseUpdateClient:"
fd baseLicenseUpdateClient.ts

# 2. Check the content of BaseLicenseUpdateClient
echo -e "\nContent of BaseLicenseUpdateClient:"
cat $(fd baseLicenseUpdateClient.ts) 2>/dev/null || echo "File not found"

# 3. Verify the inheritance relationship
echo -e "\nChecking inheritance relationship:"
rg "class DisabilityLicenseUpdateClient extends BaseLicenseUpdateClient" libs/clients/license-client/src/lib/clients/disability-license-client/services/disabilityLicenseUpdateClient.service.ts

# 4. Look for abstract methods in BaseLicenseUpdateClient
echo -e "\nAbstract methods in BaseLicenseUpdateClient:"
rg "abstract \w+\(.*\):" $(fd baseLicenseUpdateClient.ts)

Length of output: 1912


29-29: Verify correct handling of updated return type in pushUpdate

The return type of pushUpdate has changed to Promise<Result<Partial<Pass> | undefined>>. Ensure that all callers of pushUpdate are updated to handle Partial<Pass> and the possible undefined return value to prevent runtime errors.

Run the following script to find all calls to pushUpdate:

Review the call sites to ensure they handle Partial<Pass> appropriately.


33-33: Verify correct handling of updated return type in pullUpdate

The return type of pullUpdate has changed to Promise<Result<Partial<Pass>>>. Please ensure that any code consuming this method correctly handles a Result<Partial<Pass>> to avoid unexpected behavior.

Run the following script to find all calls to pullUpdate:

Check the call sites to confirm they correctly process Partial<Pass>.

Verification successful

Verified: pullUpdate return type change is correctly implemented

The pullUpdate method in DisabilityLicenseUpdateClient has been correctly updated to return Promise<Result<Partial<Pass>>>. This change is consistent with the abstract declaration and other implementations.

However, for complete assurance:

  • Manually review apps/services/license-api/src/app/modules/license/license.service.ts, particularly the pullUpdateLicense method, to ensure it correctly handles the Partial<Pass> return type.

This manual check will confirm that the change doesn't introduce any unexpected behavior in the license update process.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all calls to `pullUpdate` and display their context.

# Command: Search for function calls to `pullUpdate`
ast-grep --lang typescript --pattern '$_.pullUpdate($$)' --no-color

Length of output: 320


Script:

#!/bin/bash
# Description: Find all calls to `pullUpdate` and display their context.

# Command: Search for function calls to `pullUpdate`
ast-grep --lang typescript --pattern '$_.pullUpdate($$)'

# If no results are found, search for the method definition
if [ $? -ne 0 ]; then
  echo "No calls to pullUpdate found. Searching for method definition:"
  ast-grep --lang typescript --pattern 'async pullUpdate(): Promise<Result<Partial<Pass>>> {
    $$$
  }'
fi

Length of output: 76


Script:

#!/bin/bash
# Description: Verify pullUpdate method and search for related references

# 1. Verify pullUpdate method in the specified file
echo "Checking for pullUpdate method in the specified file:"
cat libs/clients/license-client/src/lib/clients/disability-license-client/services/disabilityLicenseUpdateClient.service.ts | grep -n "pullUpdate"

# 2. Search for partial matches of "pullUpdate"
echo -e "\nSearching for partial matches of pullUpdate:"
rg "pullUpdate" -i

# 3. Search for references to DisabilityLicenseUpdateClient
echo -e "\nSearching for references to DisabilityLicenseUpdateClient:"
rg "DisabilityLicenseUpdateClient" -i

Length of output: 3209

libs/clients/license-client/src/lib/clients/firearm-license-client/services/firearmLicenseUpdateClient.service.ts (5)

10-11: Updated import to use SmartSolutionsService from the new client library

The import statement has been updated to use SmartSolutionsService from @island.is/clients/smart-solutions-v2, aligning with the PR's objective to integrate the new smart solutions client.


33-33: Injected SmartSolutionsService into the constructor

The constructor now injects SmartSolutionsService, which is consistent with the updated import and supports the integration of the new client.


205-205: Added optional chaining to prevent runtime errors

The use of optional chaining (?.) in accessing verifyRes.data.pass?.inputFieldValues ensures that the code gracefully handles cases where pass or inputFieldValues might be undefined, preventing potential runtime errors.


65-65: Updated return type of pullUpdate method

The return type of pullUpdate has been changed to Promise<Result<Partial<Pass>>>, reflecting that it returns a partial Pass object. Confirm that any code consuming this method is compatible with this change.

Run the following script to verify all usages of pullUpdate:

Verification successful

Return type change is safe, but inconsistency exists across implementations

The updated return type Promise<Result<Partial<Pass>>> in firearmLicenseUpdateClient.service.ts is consistent with its implementation and doesn't introduce immediate issues in its usage in license.service.ts. However, there's an inconsistency in return types across different implementations:

  • baseLicenseUpdateClient.ts and drivingLicenseUpdateClient.service.ts use Promise<Result<Partial<Pass> | undefined>>
  • firearmLicenseUpdateClient.service.ts and disabilityLicenseUpdateClient.service.ts use Promise<Result<Partial<Pass>>>

To ensure long-term maintainability and prevent potential issues:

  • Consider standardizing the return type across all implementations of pullUpdate.
  • Update the abstract method in baseLicenseUpdateClient.ts to match the more specific return type if undefined is never actually returned.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all usages of `pullUpdate` to ensure they handle the updated return type.

rg --type ts 'pullUpdate\(' -A 5

Length of output: 3678


Script:

#!/bin/bash
# Check the implementation of pullUpdate in firearmLicenseUpdateClient.service.ts
echo "firearmLicenseUpdateClient.service.ts implementation:"
rg --type ts -A 20 'async pullUpdate\(' libs/clients/license-client/src/lib/clients/firearm-license-client/services/firearmLicenseUpdateClient.service.ts

echo "\n\nlicense.service.ts usage:"
# Check how pullUpdate is used in license.service.ts
rg --type ts -A 10 -B 5 'service\.pullUpdate' apps/services/license-api/src/app/modules/license/license.service.ts

Length of output: 1455


42-42: Adjusted return type of pushUpdate method

The return type of pushUpdate has been modified to Promise<Result<Partial<Pass> | undefined>>, allowing it to return a partial Pass object or undefined. Ensure that all consumers of this method handle the updated return type correctly.

Run the following script to verify that all usages of pushUpdate handle the new return type:

libs/clients/license-client/src/lib/clients/disability-license-client/services/disabilityLicenseClient.service.ts (2)

20-24: Update imports to use 'smart-solutions-v2' client

The import statements have been updated to import from @island.is/clients/smart-solutions-v2, aligning with the PR objective to integrate the new smart-solutions client with enhanced fetch functionality.


36-36: Ensure 'SmartSolutionsService' is properly injected

The constructor now injects SmartSolutionsService as private smartApi. Please verify that SmartSolutionsService is registered in the module's providers to ensure proper dependency injection.

If not already done, add SmartSolutionsService to the module's providers in the corresponding module file.

libs/clients/license-client/src/lib/clients/hunting-license-client/huntingLicenseClient.service.ts (3)

9-10: LGTM: Updated import to SmartSolutionsService

The import statement has been updated to use SmartSolutionsService from '@island.is/clients/smart-solutions-v2', aligning with the new client library.


35-35: LGTM: Updated smartApi to SmartSolutionsService

The type of smartApi has been updated to SmartSolutionsService, reflecting the change to the new client.


154-154: LGTM: Updated return type to Partial<Pass>

Changing the return type of getPkPass to Promise<Result<Partial<Pass>>> allows for more flexibility. The subsequent methods handle potential undefined properties appropriately.

libs/clients/license-client/src/lib/clients/machine-license-client/machineLicenseClient.service.ts (2)

17-18: Approved: Updated import statement for SmartSolutionsService

The import of SmartSolutionsService from @island.is/clients/smart-solutions-v2 correctly reflects the integration of the new smartSolutions client.


157-160: Verify handling of 'Partial' return type in 'getPkPass'

The return type of getPkPass has changed to Promise<Result<Partial<Pass>>>. Ensure that all consumers of this method properly handle the possibility of partial Pass data, checking for the presence of required properties before usage.

Run the following script to locate all usages of getPkPass and verify correct handling:

Verification successful

Proper handling of 'Partial' return type confirmed

The verification process has confirmed that all consumers of the getPkPass method are correctly handling the Promise<Result<Partial<Pass>>> return type. The code consistently checks for the success of the operation and the presence of required properties before usage. No issues were found in the implementation.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all instances where 'getPkPass' is called to ensure proper handling of 'Partial<Pass>'.

# Search for all calls to 'getPkPass' in TypeScript files
rg --type ts 'getPkPass\('

Length of output: 2772


Script:

#!/bin/bash
# Description: Find usages of 'res' variable after 'getPkPass' calls to verify proper handling of 'Result<Partial<Pass>>'.

# Search for 'res' usage after 'getPkPass' calls
rg --type ts -A 10 'const res = await this\.getPkPass\('

Length of output: 16681

libs/clients/license-client/src/lib/clients/adr-license-client/adrLicenseClient.service.ts (2)

158-158: Handle Partial Pass in getPkPass Return Type

The return type of the getPkPass method has changed from Promise<Result<Pass>> to Promise<Result<Partial<Pass>>>. This indicates that some properties of Pass may be missing in the returned result. Ensure that downstream code handles the possibility of missing properties to prevent runtime errors.

To verify how getPkPass results are used, run the following script:

Verification successful

Partial Pass Handling Verified in getPkPass Usage

The change to Promise<Result<Partial<Pass>>> has been consistently implemented across all license client services. The code using getPkPass results appears to handle the possibility of missing properties correctly by checking res.ok before proceeding. There are no direct accesses to properties that might not exist, suggesting that the partial nature of the result is being handled appropriately.

  • The change is consistently applied in ADR, Hunting, Disability, Driving, Machine, and Firearm license client services.
  • All usages of getPkPass check the ok status before accessing any data.
  • No instances of unsafe property access were found after getPkPass calls.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all usages of getPkPass and check for assumptions about complete Pass data.

# Search for all usages of getPkPass and display context lines.
rg --type typescript 'getPkPass\(' -A 5

# Specifically look for accesses to properties that may not exist.
rg --type typescript 'getPkPass\(' -A 5 | rg '\.data\.\w+'

Length of output: 172


Script:

#!/bin/bash
# Description: Find all usages of getPkPass and check for assumptions about complete Pass data in TypeScript files.

# Search for all usages of getPkPass in .ts files and display context lines.
rg 'getPkPass\(' -g '*.ts' -A 5

# Specifically look for accesses to properties that may not exist after getPkPass calls.
rg 'getPkPass\(' -g '*.ts' -A 5 | rg '\.(data|result)\.\w+'

Length of output: 13731


20-24: Update Imports to Reflect New Smart Solutions Client

The import statement has been updated to import SmartSolutionsService from @island.is/clients/smart-solutions-v2. Ensure that all functionalities previously provided by SmartSolutionsApi are fully supported by SmartSolutionsService, and adjust any method calls if necessary.

To confirm that all references to SmartSolutionsApi have been replaced and no deprecated methods are being used, run the following script:

Verification successful

Update to SmartSolutionsService Implemented Correctly

The migration from SmartSolutionsApi to SmartSolutionsService has been successfully implemented in the license-client module and related files. All relevant imports and method calls have been updated to use the new SmartSolutionsService.

  • The libs/clients/license-client/ directory now uses SmartSolutionsService consistently.
  • Method calls (e.g., generatePkPass, verifyPkPass) appear to be compatible with the new service.

Note: SmartSolutionsApi still exists in the libs/clients/smartsolutions/ module, possibly for backward compatibility. This may require attention in future updates.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that no references to SmartSolutionsApi remain and identify any deprecated methods.

# Test 1: Search for any remaining references to SmartSolutionsApi.
rg --type typescript 'SmartSolutionsApi'

# Test 2: Search for deprecated methods that might be used from SmartSolutionsService.
rg --type typescript 'this\.smartApi\.\(deprecatedMethod1|deprecatedMethod2\)'

Length of output: 191


Script:

#!/bin/bash
# Description: Search for SmartSolutionsApi, SmartSolutionsService, and potential deprecated method calls in TypeScript files

# Find TypeScript files and search for SmartSolutionsApi
echo "Searching for SmartSolutionsApi:"
fd -e ts -e tsx | xargs grep -n "SmartSolutionsApi" || echo "No occurrences found."

echo -e "\nSearching for SmartSolutionsService:"
fd -e ts -e tsx | xargs grep -n "SmartSolutionsService" || echo "No occurrences found."

echo -e "\nSearching for potential deprecated method calls (this.smartApi):"
fd -e ts -e tsx | xargs grep -n "this\.smartApi\." || echo "No occurrences found."

Length of output: 10334

libs/clients/license-client/src/lib/clients/driving-license-client/services/drivingLicenseUpdateClient.service.ts (4)

9-10: Updated import to use SmartSolutionsService from smart-solutions-v2

The import statement now imports SmartSolutionsService from @island.is/clients/smart-solutions-v2, aligning with the updated version of the Smart Solutions client.


35-35: Changed smartApi type to SmartSolutionsService

Updating the smartApi type to SmartSolutionsService ensures compatibility with the new client version. All interactions with smartApi should now conform to the SmartSolutionsService interface.


224-224: Added optional chaining to safely access inputFieldValues

The optional chaining operator ?. has been added to verifyRes.data.pass?.inputFieldValues?.find(...), preventing potential runtime errors if inputFieldValues is undefined.


44-44: Modified return type of pushUpdate to Partial<Pass>

The return type has been changed to Promise<Result<Partial<Pass> | undefined>>, which means the method may return a partial Pass object. Verify that all consumers of pushUpdate handle the Partial<Pass> appropriately to avoid issues with missing properties.

You can run the following script to find all usages of pushUpdate and check for proper handling:

libs/clients/license-client/src/lib/clients/firearm-license-client/services/firearmLicenseClient.service.ts (2)

10-11: Updated Import to SmartSolutionsService V2

The import statement has been correctly updated to SmartSolutionsService from @island.is/clients/smart-solutions-v2, aligning with the integration of the new smartSolutions client as per the PR objectives.


188-188: Verify Changes to getPkPass Return Type

The return type of getPkPass has been changed from Promise<Result<Pass>> to Promise<Result<Partial<Pass>>>. Please ensure that all consumers of this method are updated to handle the Partial<Pass> type to prevent potential type mismatches or runtime errors.

Run the following script to locate all usages of getPkPass and verify they are compatible with the new return type:

Verification successful

Changes to getPkPass Return Type Verified

The modification of the getPkPass return type to Promise<Result<Partial<Pass>>> has been correctly implemented and handled across the codebase. All license client services have adapted their getPkPassQRCode and getPkPassUrl methods to work with the new return type, and appropriate error handling is in place for potentially missing data. The licenseService is not directly affected by this change as it uses getPkPassQRCode and getPkPassUrl methods, which have been updated accordingly.

  • All license client services (machine, disability, driving, adr, firearm, hunting) have correctly implemented the change.
  • Error handling for missing distributionQRCode and distributionUrl is consistent across all implementations.
  • The licenseService continues to function correctly with the updated methods.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all TypeScript files using getPkPass to check for type compatibility.

# Search for all instances where getPkPass is used
rg --type ts 'getPkPass' -r '$0 at $FILE:$LINE' 

# Optional: Use ast-grep to find all function calls to getPkPass
ast-grep --lang typescript --pattern '$_.getPkPass($_$)' 

Length of output: 7009


Script:

#!/bin/bash
# Description: Check implementation of getPkPassQRCode and getPkPassUrl, and their usage in licenseService

# Check implementation in license client services
echo "Checking getPkPassQRCode and getPkPassUrl implementations:"
rg --type ts 'async getPkPassQRCode|async getPkPassUrl' -A 10 libs/clients/license-client/src/lib/clients

# Check usage in licenseService
echo "\nChecking usage in licenseService:"
rg --type ts 'getPkPassQRCode|getPkPassUrl' -A 5 libs/api/domains/license-service/src/lib/licenseService.service.ts

Length of output: 19016

libs/clients/license-client/src/lib/clients/driving-license-client/services/drivingLicenseClient.service.ts (3)

11-12: Ensure Compatibility with SmartSolutionsService from smart-solutions-v2

The import has been updated to use SmartSolutionsService from @island.is/clients/smart-solutions-v2. Verify that all usages of smartApi are compatible with the new service and that any differences between the old and new versions are properly handled.


39-39: Confirm Proper Injection of SmartSolutionsService

In the constructor, smartApi is now injected as SmartSolutionsService. Ensure that the dependency injection is correctly configured and that SmartSolutionsService is properly provided in the module's providers array.


174-174: Update Method Signature Handling for getPkPass

The return type of getPkPass has changed from Promise<Result<Pass>> to Promise<Result<Partial<Pass>>>. Verify that all consumers of this method handle the partial Pass object correctly and adjust their implementations to account for potentially missing properties.

apps/services/license-api/src/app/modules/license/license.service.ts (3)

216-216: Verify handling of 'updateRes' as 'Result<Partial | undefined>'

The variable updateRes now has the type Result<Partial<Pass> | undefined>. Verify that subsequent code correctly handles Partial<Pass>, considering that properties may be missing.


146-146: Verify handling of 'Partial' return type in 'pushUpdateLicense'

The return type of pushUpdateLicense has been changed to Promise<Result<Partial<Pass> | undefined>>. Ensure that any code consuming this method correctly handles the Partial<Pass> type, considering that some properties of Pass may be missing.

Run the following script to find and review all usages of pushUpdateLicense:

Verification successful

Return type change in 'pushUpdateLicense' is correctly handled

The usage of 'pushUpdateLicense' in the license.service.ts file appears to be consistent with the new return type Promise<Result<Partial<Pass> | undefined>>. The code correctly checks for success using updateRes.ok and uses updateRes.data without making assumptions about specific properties, which is appropriate for handling a Partial<Pass> or undefined result.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all usages of 'pushUpdateLicense' in TypeScript files.

# Test: Search for function calls to 'pushUpdateLicense'
rg --type typescript 'pushUpdateLicense\('

Length of output: 79


Script:

#!/bin/bash
# Description: Find declaration and usages of 'pushUpdateLicense' in TypeScript files

# Find TypeScript files and search for 'pushUpdateLicense' declaration
echo "Searching for pushUpdateLicense declaration:"
fd -e ts -e tsx | xargs rg 'function\s+pushUpdateLicense'

echo -e "\nSearching for pushUpdateLicense usage:"
fd -e ts -e tsx | xargs rg 'pushUpdateLicense\('

echo -e "\nSearching for pushUpdateLicense as a property or method:"
fd -e ts -e tsx | xargs rg '\.pushUpdateLicense'

Length of output: 820


Script:

#!/bin/bash
# Description: Examine the context around pushUpdateLicense usage

echo "Examining context around pushUpdateLicense usage:"
rg -A 10 -B 5 'updateRes = await this.pushUpdateLicense' apps/services/license-api/src/app/modules/license/license.service.ts

Length of output: 613


Script:

#!/bin/bash
# Description: Examine the larger context around updateRes usage

echo "Examining larger context around updateRes usage:"
rg -A 20 -B 10 'updateRes = await this.pushUpdateLicense' apps/services/license-api/src/app/modules/license/license.service.ts

Length of output: 999


185-185: Verify handling of 'Partial' return type in 'pullUpdateLicense'

The return type of pullUpdateLicense has been updated to Promise<Result<Partial<Pass> | undefined>>. Please verify that all consumers of this method correctly handle Partial<Pass>, accounting for possibly undefined properties.

Run the following script to find and review all usages of pullUpdateLicense:

Verification successful

Handling of 'Partial' return type in 'pullUpdateLicense' appears correct

The codebase correctly handles the new return type Promise<Result<Partial<Pass> | undefined>> for the pullUpdateLicense method. The result is properly typed, and both success and error cases are handled appropriately.

However, for improved clarity, consider explicitly handling the 'undefined' case:

  • In the success case, you could check if updateRes.data is defined before returning it.

Example:

if (updateRes.ok) {
  return {
    updateSuccess: true,
    data: updateRes.data !== undefined ? updateRes.data : null,
  };
}

This change would make the handling of the 'undefined' case more explicit, although the current implementation is functionally correct.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all usages of 'pullUpdateLicense' in TypeScript files.

# Test: Search for function calls to 'pullUpdateLicense'
rg --type typescript 'pullUpdateLicense\('

Length of output: 79


Script:

#!/bin/bash
# Description: Find all usages of 'pullUpdateLicense' in TypeScript files.

# Find TypeScript files and search for 'pullUpdateLicense(' in them
fd -e ts -x rg 'pullUpdateLicense\('

Length of output: 152


Script:

#!/bin/bash
# Description: Find usages of 'updateRes' and surrounding context in TypeScript files.

# Search for 'updateRes' with 5 lines of context before and after
fd -e ts -x rg -C 5 'updateRes'

Length of output: 3047

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

Outside diff range and nitpick comments (4)
libs/clients/license-client/src/lib/clients/hunting-license-client/huntingLicenseClientMapper.ts (3)

Line range hint 8-18: Nitpick: Add braces to the if statement for clarity

Enclosing the return null statement within braces improves readability and prevents potential issues if additional code is added to the if block in the future.

Apply this diff to add braces:

  if (
    !license ||
    !license.holderName ||
    !license.holderNationalId ||
    !license.holderAddress ||
    !license.number ||
    !license.validFrom ||
    !license.category ||
    !license.validTo ||
    !license.permitFor
-  )
+  ) {
    return null
+  }

Line range hint 44-46: Suggestion: Ensure consistent handling of license.permitFor

Since license.permitFor is validated in the if condition, the optional chaining (?.) may be unnecessary. Removing it can simplify the code and make the intent clearer.

Apply this diff to remove the optional chaining:

{
  identifier: 'gildir_fyrir',
- value: license.permitFor?.join(', '),
+ value: license.permitFor.join(', '),
},

Line range hint 54-57: Issue: Handle potential undefined license.benefits to prevent unexpected values

If license.benefits is undefined, the expression license.benefits?.map(...).join(' ,') will result in undefined, which might lead to issues when setting the value field. Consider providing a default value or handling this case explicitly.

Apply this diff to provide a default empty string if license.benefits is undefined:

{
  identifier: 'hljord',
- value: license.benefits?.map((b) => capitalize(b.land)).join(' ,'),
+ value: license.benefits
+   ? license.benefits.map((b) => capitalize(b.land)).join(' ,')
+   : '',
},
libs/clients/license-client/src/lib/clients/firearm-license-client/firearmLicenseMapper.ts (1)

Line range hint 1-76: Enhance reusability and bundling practices.

  • Reusability: Functions like formatNationalId and formatDateString could be useful in other parts of the codebase or across different Next.js applications. Consider exporting these utility functions to a shared utilities module to promote reusability.

  • TypeScript Usage: The code effectively uses TypeScript for defining function parameters and return types, enhancing type safety and code readability.

  • Tree-Shaking and Bundling: When importing from libraries like date-fns and kennitala, ensure that you're importing only the required functions to optimize the bundle size. For example, instead of importing the entire module, import specific functions:

    import format from 'date-fns/format'
    import { format as formatSsn } from 'kennitala'

    Verify that these imports are indeed optimized for tree-shaking by your bundler to prevent unnecessary code from being included in the final bundle.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 75f499c and 3e8c53c.

Files selected for processing (8)
  • apps/services/license-api/src/app/modules/license/license.types.ts (1 hunks)
  • apps/services/license-api/src/app/modules/license/test/license.service.spec.ts (1 hunks)
  • libs/clients/license-client/src/lib/clients/adr-license-client/adrLicenseClientMapper.ts (0 hunks)
  • libs/clients/license-client/src/lib/clients/driving-license-client/drivingLicenseMapper.ts (1 hunks)
  • libs/clients/license-client/src/lib/clients/firearm-license-client/firearmLicenseMapper.ts (1 hunks)
  • libs/clients/license-client/src/lib/clients/hunting-license-client/huntingLicenseClientMapper.ts (1 hunks)
  • libs/clients/license-client/src/lib/constants.ts (1 hunks)
  • libs/clients/license-client/src/lib/licenseUpdateClient.service.ts (1 hunks)
Files not reviewed due to no reviewable changes (1)
  • libs/clients/license-client/src/lib/clients/adr-license-client/adrLicenseClientMapper.ts
Files skipped from review due to trivial changes (4)
  • apps/services/license-api/src/app/modules/license/license.types.ts
  • libs/clients/license-client/src/lib/clients/driving-license-client/drivingLicenseMapper.ts
  • libs/clients/license-client/src/lib/constants.ts
  • libs/clients/license-client/src/lib/licenseUpdateClient.service.ts
Additional context used
Path-based instructions (3)
libs/clients/license-client/src/lib/clients/hunting-license-client/huntingLicenseClientMapper.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/license-client/src/lib/clients/firearm-license-client/firearmLicenseMapper.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."
apps/services/license-api/src/app/modules/license/test/license.service.spec.ts (2)

Pattern apps/services/**/*: "Confirm that the code adheres to the following:

  • NestJS architecture, including modules, services, and controllers.
  • Dependency injection patterns and service encapsulation.
  • Integration and unit testing coverage and practices."

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
Additional comments not posted (5)
libs/clients/license-client/src/lib/clients/hunting-license-client/huntingLicenseClientMapper.ts (2)

4-4: Approved: Updated import to smart-solutions-v2

The import statement has been correctly updated to use @island.is/clients/smart-solutions-v2, aligning with the project's objective to integrate the new smart solutions client.


4-4: Verify: Ensure type compatibility with PassInputFieldValueDataInput

Please verify that PassInputFieldValueDataInput from @island.is/clients/smart-solutions-v2 is compatible with the existing usage, as there might be changes in the type definitions between versions.

Run the following script to identify any differences in the type definitions:

Verification successful

Verification successful: PassInputFieldValueDataInput appears compatible

The PassInputFieldValueDataInput type from @island.is/clients/smart-solutions-v2 is being used consistently across various parts of the codebase, including different license types (hunting, firearm, and driving). The structure and usage of the type remain consistent, suggesting that it is compatible with the existing implementation. No issues or incompatibilities were found during the verification process.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Compare the type definitions of PassInputFieldValueDataInput between versions.

# Test: Fetch the type definitions from both versions and compare them.
echo "Fetching old type definition..."
yarn add @island.is/clients/smartsolutions@latest
cat node_modules/@island.is/clients/smartsolutions/src/types.ts | grep 'export type PassInputFieldValueDataInput'

echo "Fetching new type definition..."
yarn add @island.is/clients/smart-solutions-v2@latest
cat node_modules/@island.is/clients/smart-solutions-v2/src/types.ts | grep 'export type PassInputFieldValueDataInput'

Length of output: 822


Script:

#!/bin/bash
# Search for usage of PassInputFieldValueDataInput
echo "Searching for PassInputFieldValueDataInput usage:"
ast-grep --lang typescript --pattern 'PassInputFieldValueDataInput'

echo "\nSearching for comments or documentation about PassInputFieldValueDataInput:"
rg -i "PassInputFieldValueDataInput" -g "!*.{json,md}" -C 2

Length of output: 17035

libs/clients/license-client/src/lib/clients/firearm-license-client/firearmLicenseMapper.ts (2)

Line range hint 38-76: Validate the data structure returned by createPkPassDataInput.

The createPkPassDataInput function constructs an array of objects that should conform to the expected input for the Smart Solutions API. With the client update to smart-solutions-v2, ensure that the constructed data aligns with any changes in the API's expected input format.

Consider reviewing the API documentation for smart-solutions-v2 to confirm that all required fields are provided and correctly formatted.


6-6: Ensure compatibility with the updated PassInputFieldValueDataInput import.

The PassInputFieldValueDataInput type is now imported from @island.is/clients/smart-solutions-v2 instead of @island.is/clients/smartsolutions. Please verify that the new version of this type is compatible with the existing code. There might be changes in the type's structure or properties that could affect how it's used in this file.

To confirm the compatibility, run the following script to compare the type definitions:

apps/services/license-api/src/app/modules/license/test/license.service.spec.ts (1)

13-13: Ensure compatibility with Smart Solutions v2 client in tests.

The import path for SmartSolutionsApi has been updated to use the v2 client. Please verify that the mocked implementations and any usage in the test cases are compatible with the new client API and do not require further modifications.

Run the following script to verify that all imports have been updated:

Verification successful

Update to Smart Solutions v2 client verified successfully.

The verification process confirms that the import from '@island.is/clients/smart-solutions-v2' has been correctly updated in the test file (apps/services/license-api/src/app/modules/license/test/license.service.spec.ts) and consistently applied across the entire codebase. The old import from '@island.is/clients/smartsolutions' has been completely removed.

SmartSolutionsApi is still being used in the test file, which suggests that the mocked implementations and test cases are likely compatible with the new client API. No further modifications appear to be necessary for the test cases.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all usages of `SmartSolutionsApi` have been updated to import from `@island.is/clients/smart-solutions-v2`.

# Test: Search for files importing from the old client.
# Expect: No occurrences of `@island.is/clients/smartsolutions`.

rg --type=typescript --fixed-strings "from '@island.is/clients/smartsolutions'"

Length of output: 122


Script:

#!/bin/bash

# Approach 1: Using rg with file extension filter
echo "Approach 1: Using rg with file extension filter"
rg --glob '*.{ts,tsx}' --fixed-strings "from '@island.is/clients/smartsolutions'"

# Approach 2: Using fd and grep
echo "Approach 2: Using fd and grep"
fd -e ts -e tsx | xargs grep -n "from '@island.is/clients/smartsolutions'"

# Approach 3: Using ast-grep for import statements
echo "Approach 3: Using ast-grep for import statements"
ast-grep --lang typescript --pattern 'import $_ from "@island.is/clients/smartsolutions"'

Length of output: 641


Script:

#!/bin/bash

echo "Searching for updated v2 client imports"
rg --glob '*.{ts,tsx}' --fixed-strings "from '@island.is/clients/smart-solutions-v2'"

echo "Searching for SmartSolutionsApi usage"
ast-grep --lang typescript --pattern 'SmartSolutionsApi'

Length of output: 3962

@thorkellmani thorkellmani requested a review from a team as a code owner September 17, 2024 14:21
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: 1

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3e8c53c and 2bc72e7.

Files selected for processing (2)
  • apps/services/license-api/src/app/modules/license/test/license.service.spec.ts (4 hunks)
  • libs/clients/smart-solutions-v2/src/index.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • libs/clients/smart-solutions-v2/src/index.ts
Additional context used
Path-based instructions (1)
apps/services/license-api/src/app/modules/license/test/license.service.spec.ts (2)

Pattern apps/services/**/*: "Confirm that the code adheres to the following:

  • NestJS architecture, including modules, services, and controllers.
  • Dependency injection patterns and service encapsulation.
  • Integration and unit testing coverage and practices."

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
Additional comments not posted (1)
apps/services/license-api/src/app/modules/license/test/license.service.spec.ts (1)

11-13: Migration to SmartSolutionsService is correct

The import statements have been successfully updated to use SmartSolutionsService from @island.is/clients/smart-solutions-v2, aligning with the PR objective to integrate the new client.

@thorkellmani
Copy link
Member Author

Continued here ##16231

Implementing versioning for safer testing there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy-feature Deploys features to dev
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants