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

✨ Deel + sage hris integrations #663

Merged
merged 5 commits into from
Aug 16, 2024
Merged

✨ Deel + sage hris integrations #663

merged 5 commits into from
Aug 16, 2024

Conversation

naelob
Copy link
Contributor

@naelob naelob commented Aug 16, 2024

Summary by CodeRabbit

  • New Features

    • Integrated Sage and Deel services for improved HRIS connectivity.
    • Added new mapping functionalities for employees and companies between Deel, Sage, and existing systems.
    • Introduced OAuth2 authentication and passthrough capabilities for Sage HRIS API.
    • Enhanced utility functions for retrieving group UUIDs and supporting location data transformations.
  • Bug Fixes

    • Updated naming conventions for API URLs to standardize across connectors.
  • Documentation

    • Improved metadata for connectors, including new documentation URLs and configurations.
  • Chores

    • Refined connector configurations to enhance integration readiness and operational clarity.

@rflihxyz
Copy link
Contributor

Qovery Preview

Qovery can create a Preview Environment for this PR.
To trigger its creation, please post a comment with one of the following command.

Command Blueprint environment
/qovery preview 783d0240-ec38-4387-a9a9-8e225f1bd3e1 dev
/qovery preview {all|UUID1,UUID2,...} To preview multiple environments

This comment has been generated from Qovery AI 🤖.
Below, a word from its wisdom :

Write comments that add new information that doesn’t exist in the code

Copy link

changeset-bot bot commented Aug 16, 2024

⚠️ No Changeset found

Latest commit: 61fd0f7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

coderabbitai bot commented Aug 16, 2024

Warning

Rate limit exceeded

@naelob has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 8 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between aef9526 and 61fd0f7.

Walkthrough

Walkthrough

The recent changes significantly enhance the HRIS API by integrating new services and mappers for the Sage and Deel platforms across various modules. Key additions include OAuth2 support, improved type definitions for Gusto, Sage, and Deel, and enhanced utilities for managing employee, company, group, and location data. This expansion boosts the API's capabilities, enabling better interoperability and more efficient data management.

Changes

File(s) Change Summary
packages/api/src/@core/connections/hris/hris.connection.module.ts Added SageConnectionService for Sage integration.
packages/api/src/@core/connections/hris/services/sage/sage.service.ts Introduced SageConnectionService with methods for OAuth2 and passthrough requests.
packages/api/src/@core/utils/types/original/original.hris.ts Expanded type definitions to include Deel and Sage outputs alongside Gusto types.
packages/api/src/hris/@lib/@utils/index.ts Added method getGroupUuidFromRemoteId for fetching group UUIDs from the database.
packages/api/src/hris/company/company.module.ts Integrated DeelService and DeelCompanyMapper for handling Deel operations.
packages/api/src/hris/company/services/deel/index.ts Introduced DeelService for managing company data from Deel.
packages/api/src/hris/company/services/deel/mappers.ts Created DeelCompanyMapper for data transformation between Deel and HRIS formats.
packages/api/src/hris/company/services/deel/types.ts Defined DeelCompanyOutput interface for structured company data representation.
packages/api/src/hris/employee/employee.module.ts Added SageEmployeeMapper and DeelEmployeeMapper to expand employee module capabilities.
packages/api/src/hris/employee/services/deel/index.ts Created DeelService for synchronizing employee data from Deel.
packages/api/src/hris/employee/services/deel/mappers.ts Introduced DeelEmployeeMapper for transforming employee data.
packages/api/src/hris/employee/services/deel/types.ts Defined multiple interfaces for Deel employee-related data.
packages/api/src/hris/employee/services/sage/index.ts Introduced SageService for synchronizing employee data from Sage.
packages/api/src/hris/employee/services/sage/mappers.ts Created SageEmployeeMapper for transforming employee data between formats.
packages/api/src/hris/employee/services/sage/types.ts Defined several new interfaces for Sage employee data.
packages/api/src/hris/employment/employment.module.ts Added DeelEmploymentMapper for managing Deel employment data.
packages/api/src/hris/employment/services/deel/mappers.ts Introduced DeelEmploymentMapper for transforming employment data.
packages/api/src/hris/group/group.module.ts Integrated new services and mappers for Sage and Deel into the group module.
packages/api/src/hris/group/services/deel/index.ts Added DeelService for managing group-related data from Deel.
packages/api/src/hris/group/services/deel/mappers.ts Created DeelGroupMapper for transforming group data.
packages/api/src/hris/location/location.module.ts Added DeelLocationMapper to enhance location management.
packages/api/src/hris/location/services/deel/mappers.ts Introduced DeelLocationMapper for mapping location data.
packages/api/src/hris/timeoff/services/sage/index.ts Implemented SageService for synchronizing time-off requests from Sage.
packages/api/src/hris/timeoff/services/sage/mappers.ts Created SageTimeoffMapper for transforming time-off data.
packages/api/src/hris/timeoff/timeoff.module.ts Integrated SageTimeoffMapper and SageService for better time-off management.
packages/api/src/hris/timeoffbalance/services/sage/index.ts Added SageService for synchronizing time-off balance data from Sage.
packages/api/src/hris/timeoffbalance/services/sage/mappers.ts Created SageTimeoffbalanceMapper for mapping time-off balance data.
packages/api/src/hris/timeoffbalance/timeoffbalance.module.ts Integrated SageTimeoffbalanceMapper and SageService for managing time-off balances.
packages/shared/src/connectors/metadata.ts Enhanced CONNECTORS_METADATA with new connector for Apollo and updates for existing connectors like BambooHR and Sage.
packages/shared/src/categories.ts Added Cybersecurity category to ConnectorCategory enum.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant API
    participant SageService
    participant DeelService
    
    User->>API: Request Employee Data
    API->>SageService: Sync Employee Data
    SageService-->>API: Return Employee Data
    API->>DeelService: Sync Employee Data
    DeelService-->>API: Return Employee Data
    API-->>User: Provide Combined Employee Data
Loading
sequenceDiagram
    participant User
    participant API
    participant DeelLocationMapper

    User->>API: Request Location Data
    API->>DeelLocationMapper: Transform Location Data
    DeelLocationMapper-->>API: Return Transformed Location Data
    API-->>User: Provide Location Data
Loading

The diagrams illustrate the interaction between users and the system for synchronizing employee and location data from external services.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 40

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 6dcb65f and 2e62b82.

Files selected for processing (37)
  • packages/api/src/@core/connections/hris/hris.connection.module.ts (2 hunks)
  • packages/api/src/@core/connections/hris/services/sage/sage.service.ts (1 hunks)
  • packages/api/src/@core/utils/types/original/original.hris.ts (4 hunks)
  • packages/api/src/hris/@lib/@utils/index.ts (1 hunks)
  • packages/api/src/hris/company/company.module.ts (2 hunks)
  • packages/api/src/hris/company/services/deel/index.ts (1 hunks)
  • packages/api/src/hris/company/services/deel/mappers.ts (1 hunks)
  • packages/api/src/hris/company/services/deel/types.ts (1 hunks)
  • packages/api/src/hris/employee/employee.module.ts (2 hunks)
  • packages/api/src/hris/employee/services/deel/index.ts (1 hunks)
  • packages/api/src/hris/employee/services/deel/mappers.ts (1 hunks)
  • packages/api/src/hris/employee/services/deel/types.ts (1 hunks)
  • packages/api/src/hris/employee/services/sage/index.ts (1 hunks)
  • packages/api/src/hris/employee/services/sage/mappers.ts (1 hunks)
  • packages/api/src/hris/employee/services/sage/types.ts (1 hunks)
  • packages/api/src/hris/employment/employment.module.ts (2 hunks)
  • packages/api/src/hris/employment/services/deel/mappers.ts (1 hunks)
  • packages/api/src/hris/employment/services/deel/types.ts (1 hunks)
  • packages/api/src/hris/group/group.module.ts (2 hunks)
  • packages/api/src/hris/group/services/deel/index.ts (1 hunks)
  • packages/api/src/hris/group/services/deel/mappers.ts (1 hunks)
  • packages/api/src/hris/group/services/deel/types.ts (1 hunks)
  • packages/api/src/hris/group/services/sage/index.ts (1 hunks)
  • packages/api/src/hris/group/services/sage/mappers.ts (1 hunks)
  • packages/api/src/hris/group/services/sage/types.ts (1 hunks)
  • packages/api/src/hris/location/location.module.ts (2 hunks)
  • packages/api/src/hris/location/services/deel/mappers.ts (1 hunks)
  • packages/api/src/hris/location/services/deel/types.ts (1 hunks)
  • packages/api/src/hris/timeoff/services/sage/index.ts (1 hunks)
  • packages/api/src/hris/timeoff/services/sage/mappers.ts (1 hunks)
  • packages/api/src/hris/timeoff/services/sage/types.ts (1 hunks)
  • packages/api/src/hris/timeoff/timeoff.module.ts (2 hunks)
  • packages/api/src/hris/timeoffbalance/services/sage/index.ts (1 hunks)
  • packages/api/src/hris/timeoffbalance/services/sage/mappers.ts (1 hunks)
  • packages/api/src/hris/timeoffbalance/services/sage/types.ts (1 hunks)
  • packages/api/src/hris/timeoffbalance/timeoffbalance.module.ts (2 hunks)
  • packages/shared/src/connectors/metadata.ts (5 hunks)
Additional context used
Biome
packages/api/src/hris/@lib/@utils/index.ts

[error] 49-49: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

packages/api/src/hris/employee/services/sage/index.ts

[error] 24-24: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 55-55: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

packages/api/src/hris/employee/services/deel/index.ts

[error] 24-24: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 57-57: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

packages/api/src/hris/group/services/sage/index.ts

[error] 26-26: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 63-63: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

packages/api/src/hris/group/services/deel/index.ts

[error] 26-26: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 63-63: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

packages/api/src/hris/timeoff/services/sage/index.ts

[error] 26-26: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 66-66: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

packages/api/src/hris/timeoffbalance/services/sage/index.ts

[error] 24-24: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 69-69: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

packages/api/src/hris/company/services/deel/index.ts

[error] 26-26: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 69-69: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

packages/api/src/@core/connections/hris/services/sage/sage.service.ts

[error] 74-74: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)


[error] 136-136: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

Additional comments not posted (70)
packages/api/src/hris/group/services/deel/types.ts (1)

1-4: Type definition looks good.

The DeelGroupOutput type is well-defined with appropriate property types.

packages/api/src/hris/timeoffbalance/services/sage/types.ts (1)

1-5: Type definition looks good.

The SageTimeoffbalanceOutput type is well-defined with optional properties using Partial.

packages/api/src/hris/group/services/sage/types.ts (1)

1-6: Type definition looks good.

The SageGroupOutput type is well-defined with appropriate property types for IDs and names.

packages/api/src/hris/company/services/deel/types.ts (1)

1-7: LGTM! The interface is well-defined.

The DeelCompanyOutput interface is correctly structured and uses appropriate types for each property. The use of a union type for entity_type allows for flexibility.

packages/api/src/hris/location/services/deel/types.ts (1)

1-8: LGTM! The type definition is appropriate.

The DeelLocationOutput type is well-structured, with Partial allowing for optional properties. The choice of fields aligns with standard address components.

packages/api/src/hris/timeoff/services/sage/types.ts (3)

1-4: LGTM! The interface is clear and concise.

The SageTimeoffReplacement interface correctly captures the necessary details for a replacement entity.


6-9: LGTM! The interface is well-defined.

The SageTimeoffField interface appropriately represents a field with a title and answer, suitable for use in forms or questionnaires.


11-30: LGTM! The type definition is comprehensive and flexible.

The SageTimeoffOutput type is well-structured, with Partial allowing for optional properties. The fields cover a wide range of attributes needed for time-off management.

packages/api/src/hris/timeoff/timeoff.module.ts (2)

22-24: Confirm integration of Sage services into the module.

The addition of SageTimeoffMapper and SageService to the providers suggests enhanced functionality. Ensure these services are integrated and utilized effectively in the module.


10-11: Ensure correct implementation of Sage services.

The imports for SageTimeoffMapper and SageService indicate new functionalities. Verify that these services are correctly implemented and utilized within the module.

Verification successful

Sage Services are Correctly Implemented and Utilized

The SageTimeoffMapper and SageService classes are correctly implemented and utilized within the module. They are registered as providers and are part of the module's architecture, indicating proper integration and usage.

  • SageTimeoffMapper is implemented in packages/api/src/hris/timeoff/services/sage/mappers.ts.
  • SageService is implemented in various contexts, such as packages/api/src/hris/timeoffbalance/services/sage/index.ts and others, each implementing relevant interfaces.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation and usage of SageTimeoffMapper and SageService.

# Test: Check for the implementation of SageTimeoffMapper and SageService. Expect: Definitions of these classes.
ast-grep --lang typescript --pattern $'class SageTimeoffMapper { $$$ }'
ast-grep --lang typescript --pattern $'class SageService { $$$ }'

Length of output: 139


Script:

#!/bin/bash
# Search for any references to SageTimeoffMapper and SageService in the codebase.

# Find all occurrences of SageTimeoffMapper in the codebase.
rg 'SageTimeoffMapper' -A 5

# Find all occurrences of SageService in the codebase.
rg 'SageService' -A 5

Length of output: 9237

packages/api/src/hris/employment/employment.module.ts (2)

11-11: Verify the DeelEmploymentMapper implementation.

The import of DeelEmploymentMapper indicates new functionality. Ensure that this service is correctly implemented and used within the module.

Verification successful

DeelEmploymentMapper Implementation Verified

The DeelEmploymentMapper class is correctly implemented in packages/api/src/hris/employment/services/deel/mappers.ts and is used as a provider in the employment.module.ts. Its integration and implementation appear to be correctly set up.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation and usage of DeelEmploymentMapper.

# Test: Check for the implementation of DeelEmploymentMapper. Expect: Definition of this class.
ast-grep --lang typescript --pattern $'class DeelEmploymentMapper { $$$ }'

Length of output: 75


Script:

#!/bin/bash
# Search for DeelEmploymentMapper definition or export in the codebase
rg 'DeelEmploymentMapper' --type=ts -A 3

# Check for usage of DeelEmploymentMapper in the codebase
rg 'DeelEmploymentMapper' --type=ts -A 3

Length of output: 2153


23-23: Check integration of DeelEmploymentMapper into the module.

The addition of DeelEmploymentMapper to the providers suggests enhanced functionality. Ensure this service is integrated and utilized effectively in the module.

packages/api/src/hris/timeoffbalance/timeoffbalance.module.ts (2)

10-11: Ensure correct implementation of Sage services.

The imports for SageTimeoffbalanceMapper and SageService indicate new functionalities. Verify that these services are correctly implemented and utilized within the module.

Verification successful

Sage Services are Implemented and Utilized Correctly

The SageTimeoffbalanceMapper and SageService classes are defined and utilized within the module as expected. Here are the relevant details:

  • SageTimeoffbalanceMapper is implemented in packages/api/src/hris/timeoffbalance/services/sage/mappers.ts and is correctly imported and used in the module.
  • SageService is implemented in packages/api/src/hris/timeoffbalance/services/sage/index.ts and is also correctly imported and used in the module.

These services are included in the providers of the TimeoffBalanceModule, indicating proper integration.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation and usage of SageTimeoffbalanceMapper and SageService.

# Test: Check for the implementation of SageTimeoffbalanceMapper and SageService. Expect: Definitions of these classes.
ast-grep --lang typescript --pattern $'class SageTimeoffbalanceMapper { $$$ }'
ast-grep --lang typescript --pattern $'class SageService { $$$ }'

Length of output: 146


Script:

#!/bin/bash
# Search for any definition of SageTimeoffbalanceMapper and SageService in the codebase.
rg 'SageTimeoffbalanceMapper' -t typescript -A 5
rg 'SageService' -t typescript -A 5

Length of output: 154


Script:

#!/bin/bash
# Search for any definition of SageTimeoffbalanceMapper and SageService in the codebase without specifying a file type.
rg 'SageTimeoffbalanceMapper' -A 5
rg 'SageService' -A 5

Length of output: 9496


22-24: Confirm integration of Sage services into the module.

The addition of SageTimeoffbalanceMapper and SageService to the providers suggests enhanced functionality. Ensure these services are integrated and utilized effectively in the module.

Verification successful

Integration of Sage services confirmed. The SageTimeoffbalanceMapper and SageService are integrated into the module, with SageTimeoffbalanceMapper implementing ITimeoffBalanceMapper and SageService implementing multiple interfaces. This suggests they are effectively utilized for their intended functionalities.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of SageTimeoffbalanceMapper and SageService in the module.

# Test: Search for the usage of SageTimeoffbalanceMapper and SageService in the module. Expect: References to these services.
rg --type typescript 'SageTimeoffbalanceMapper|SageService'

Length of output: 96


Script:

#!/bin/bash
# Description: Verify the integration of SageTimeoffbalanceMapper and SageService in the module.

# Find all TypeScript files and search for references to SageTimeoffbalanceMapper and SageService.
fd --extension ts --exec rg 'SageTimeoffbalanceMapper|SageService'

Length of output: 983

packages/api/src/hris/location/location.module.ts (2)

12-12: Ensure consistency with existing mappers.

The addition of DeelLocationMapper is consistent with the existing pattern for handling location data from multiple sources. Verify that this mapper is correctly implemented and used within the application.


24-24: Verify dependency injection setup.

The inclusion of DeelLocationMapper in the providers array ensures it is available for dependency injection. Confirm that all necessary dependencies for the mapper are correctly configured.

packages/api/src/hris/company/company.module.ts (2)

12-13: Ensure compatibility with existing services.

The addition of DeelService and DeelCompanyMapper aligns with the module's structure. Verify that these components are correctly implemented and integrated with existing services.


25-28: Verify dependency injection setup for new services.

The inclusion of DeelCompanyMapper and DeelService in the providers array ensures they are available for dependency injection. Confirm that all dependencies are correctly configured and that these services are utilized effectively.

Verification successful

Dependency Injection Setup Verified for DeelService and DeelCompanyMapper

The DeelService and DeelCompanyMapper are correctly implemented and utilized within the codebase, ensuring proper dependency injection setup in company.module.ts.

  • DeelService is implemented in multiple contexts and is correctly imported and used.
  • DeelCompanyMapper is implemented and used in the company context.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the DeelService and DeelCompanyMapper implementation and usage.

# Test: Check for DeelService implementation. Expect: Correct implementation and usage.
ast-grep --lang typescript --pattern $'class DeelService {
  $$$
}'

# Test: Check for DeelCompanyMapper implementation. Expect: Correct implementation and usage.
ast-grep --lang typescript --pattern $'class DeelCompanyMapper {
  $$$
}'

Length of output: 143


Script:

#!/bin/bash
# Description: Search for DeelService and DeelCompanyMapper class implementations and their usage.

# Search for DeelService class or any similar named class
rg 'class DeelService|class .*Deel.*Service' -A 10 --type=typescript

# Search for DeelCompanyMapper class or any similar named class
rg 'class DeelCompanyMapper|class .*Deel.*Mapper' -A 10 --type=typescript

# Check for DeelService usage in the codebase
rg 'DeelService' --type=typescript

# Check for DeelCompanyMapper usage in the codebase
rg 'DeelCompanyMapper' --type=typescript

Length of output: 362


Script:

#!/bin/bash
# Description: Search for DeelService and DeelCompanyMapper class implementations and their usage.

# Search for DeelService class or any similar named class in TypeScript files
rg 'class DeelService|class .*Deel.*Service' -A 10 --glob='*.ts'

# Search for DeelCompanyMapper class or any similar named class in TypeScript files
rg 'class DeelCompanyMapper|class .*Deel.*Mapper' -A 10 --glob='*.ts'

# Check for DeelService usage in the codebase
rg 'DeelService' --glob='*.ts'

# Check for DeelCompanyMapper usage in the codebase
rg 'DeelCompanyMapper' --glob='*.ts'

Length of output: 10505

packages/api/src/hris/employment/services/deel/types.ts (5)

1-28: Review type definitions for completeness and accuracy.

The DeelEmploymentOutput type is defined as a Partial object. Ensure that all fields are necessary and accurately reflect the data structure used by Deel. Consider documenting any non-obvious fields for clarity.


30-33: Ensure interface consistency.

The DeelTeam interface is straightforward. Verify that it aligns with the data provided by Deel and is used consistently throughout the codebase.


35-40: Review currency and scale fields.

The DeelPayment interface includes scale and currency fields. Ensure these fields are validated and correctly handled in the application logic.


41-45: Verify hierarchical data handling.

The DeelDepartment interface includes a parent field, indicating hierarchical data. Ensure that the application logic correctly handles department hierarchies.


47-50: Ensure legal entity data integrity.

The DeelClientLegalEntity interface is simple but crucial. Verify that data integrity is maintained when handling client legal entities.

packages/api/src/hris/group/group.module.ts (2)

12-15: New imports for Sage and Deel integrations.

The imports for SageService, SageGroupMapper, DeelService, and DeelGroupMapper have been added. These are necessary for the new functionalities provided by the Sage and Deel integrations.


27-32: Providers updated with Sage and Deel services and mappers.

The providers list now includes SageGroupMapper, DeelGroupMapper, SageService, and DeelService. This expands the module's capabilities to handle data from Sage and Deel platforms.

packages/api/src/hris/employee/employee.module.ts (2)

12-15: New imports for Sage and Deel employee integrations.

The imports for SageEmployeeMapper, SageService, DeelService, and DeelEmployeeMapper have been added. These are essential for the new functionalities related to employee data management.


27-32: Providers updated with Sage and Deel employee services and mappers.

The providers list now includes SageEmployeeMapper, DeelEmployeeMapper, SageService, and DeelService. This enhances the module's ability to manage employee data from Sage and Deel platforms.

packages/api/src/hris/employee/services/sage/types.ts (1)

1-55: Comprehensive type definitions for Sage employee data.

The types defined for SageEmployeeOutput, SageTeamHistory, SageEmploymentStatusHistory, and SagePositionHistory are comprehensive and cover necessary employee attributes and histories. This structure will facilitate effective data management and integration with the Sage platform.

packages/api/src/hris/@lib/@utils/index.ts (1)

38-51: Pattern consistency is good.

The getGroupUuidFromRemoteId method is consistent with other similar methods in the class.

Tools
Biome

[error] 49-49: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

packages/api/src/@core/connections/hris/hris.connection.module.ts (1)

Line range hint 16-34:
Integration of SageConnectionService is well-structured.

The addition of SageConnectionService to the providers array is consistent with the module's structure and enhances its functionality.

packages/api/src/hris/group/services/deel/mappers.ts (3)

13-21: Registration of the mapper is appropriate.

The DeelGroupMapper correctly registers itself with the MappersRegistry, ensuring it can be utilized as intended.


31-48: Efficient handling of multiple group inputs.

The unify method efficiently handles both single and multiple group inputs using Promise.all, which is a good practice for asynchronous operations.


50-60: Mapping logic is clear and concise.

The mapSingleGroupToUnified method provides a straightforward mapping from DeelGroupOutput to UnifiedHrisGroupOutput.

packages/api/src/hris/group/services/sage/mappers.ts (1)

13-61: LGTM!

The rest of the SageGroupMapper class is well-structured and follows good practices.

packages/api/src/hris/location/services/deel/mappers.ts (1)

15-22: Constructor: Ensure registration logic is correct.

The constructor registers the service with the mappersRegistry. Ensure that this registration logic aligns with the rest of the application and that the service is correctly initialized.

Verification successful

Constructor registration logic is correctly implemented.

The DeelLocationMapper service is registered using a pattern consistent with other similar services in the codebase, indicating proper initialization and usage. No issues found with the registration logic.

  • packages/api/src/hris/location/services/deel/mappers.ts: Registration logic is consistent.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the registration of `DeelLocationMapper` in the mappers registry.

# Test: Search for the registration logic in the codebase. Expect: Proper initialization and usage.
rg --type ts 'registerService\(.+\'deel\''

Length of output: 93


Script:

#!/bin/bash
# Description: Verify the registration of `DeelLocationMapper` in the mappers registry.

# Test: Search for the registration logic in the codebase. Expect: Proper initialization and usage.
rg --type ts "registerService(.+'deel'"

Length of output: 138


Script:

#!/bin/bash
# Description: Verify the registration of `DeelLocationMapper` in the mappers registry.

# Test: Search for the registration logic in the codebase. Expect: Proper initialization and usage.
rg --type ts "registerService\(.+'deel'"

Length of output: 704

packages/api/src/hris/timeoffbalance/services/sage/mappers.ts (1)

15-27: Constructor: Verify service registration.

The constructor registers the SageTimeoffbalanceMapper with the mappersRegistry. Ensure that this registration is consistent with the application's architecture and that the service is correctly initialized.

Verification successful

Registration of SageTimeoffbalanceMapper is consistent.

The SageTimeoffbalanceMapper is correctly registered with the mappersRegistry using the 'sage' parameter. This registration aligns with the application's architecture, as similar registrations are found in other mapper files.

  • packages/api/src/hris/timeoff/services/sage/mappers.ts: this.mappersRegistry.registerService('hris', 'timeoff', 'sage', this);
  • Other similar registrations for 'sage' are found in related services.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the registration of `SageTimeoffbalanceMapper` in the mappers registry.

# Test: Search for the registration logic in the codebase. Expect: Proper initialization and usage.
rg --type ts 'registerService\(.+\'sage\''

Length of output: 93


Script:

#!/bin/bash
# Description: Verify the registration of `SageTimeoffbalanceMapper` in the mappers registry.

# Test: Search for the registration logic in the codebase. Expect: Proper initialization and usage.
rg --type ts "registerService(.+'sage'"

Length of output: 138


Script:

#!/bin/bash
# Description: Verify the registration of `SageTimeoffbalanceMapper` in the mappers registry.

# Test: Search for the registration logic in the codebase. Expect: Proper initialization and usage.
rg --type ts "registerService\(.+'sage'"

Length of output: 436

packages/api/src/hris/group/services/deel/index.ts (1)

62-63: Remove redundant catch block.

The catch block that only rethrows the error is unnecessary and can be removed for cleaner code.

-    } catch (error) {
-      throw error;
-    }
Verification successful

Remove redundant catch block in sync method of DeelService.

The sync method calls are already wrapped in a try-catch block in IngestDataService, ensuring proper error handling. Thus, the catch block in the sync method of DeelService is unnecessary and can be removed for cleaner code.

  • File: packages/api/src/hris/group/services/deel/index.ts
  • Lines: 62-63
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify error handling for the sync method in the calling code.

# Test: Search for the DeelService sync method usage. Expect: Proper error handling in the calling code.
rg --type ts -A 5 $'deelService.sync'

Length of output: 36


Script:

#!/bin/bash
# Step 1: Find where DeelService is imported or instantiated.
rg --type ts 'DeelService' -A 5

# Step 2: Search for sync method calls on instances of DeelService.
rg --type ts '\.sync\(' -A 5

Length of output: 6494


Script:

#!/bin/bash
# Search for try-catch blocks around the sync method calls in ingest-data.service.ts
rg --type ts 'try' -A 10 -B 10 packages/api/src/@core/@core-services/unification/ingest-data.service.ts

Length of output: 3162

Tools
Biome

[error] 63-63: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

packages/api/src/hris/company/services/deel/mappers.ts (2)

15-22: Constructor implementation looks good.

The constructor correctly registers the mapper with the registry.


32-69: Mapping methods are well-implemented.

The unify and mapSingleCompanyToUnified methods effectively handle data mapping for single and multiple companies.

packages/api/src/hris/timeoff/services/sage/index.ts (1)

66-67: Remove redundant catch block.

The catch block that only rethrows the error is unnecessary and can be removed for cleaner code.

-    } catch (error) {
-      throw error;
-    }
Tools
Biome

[error] 66-66: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

packages/api/src/hris/timeoffbalance/services/sage/index.ts (1)

1-12: Review imports for correctness and necessity.

The imports look correct and necessary for the functionality of the SageService class. Ensure that all imported modules are available and correctly configured in the project.

packages/api/src/hris/employee/services/deel/types.ts (2)

1-29: Ensure date strings are consistently formatted.

The DeelEmployeeOutput type includes several date fields as strings. Ensure that a consistent date format is used across the application to avoid parsing issues.


31-99: Review interface structure for completeness and consistency.

The interfaces appear well-structured and consistent. Ensure that these definitions align with the actual data structure returned by the Deel API.

packages/api/src/hris/company/services/deel/index.ts (1)

1-15: Review imports for correctness and necessity.

The imports look correct and necessary for the functionality of the DeelService class. Ensure that all imported modules are available and correctly configured in the project.

packages/api/src/hris/timeoff/services/sage/mappers.ts (2)

15-24: Ensure proper registration of the service.

The SageTimeoffMapper class registers itself in the MappersRegistry. Ensure that the registry is correctly initialized and that there are no conflicts with other services registering similar keys.

Verification successful

Proper Registration of SageTimeoffMapper Verified

The SageTimeoffMapper service is correctly registered in the MappersRegistry with the keys 'hris', 'timeoff', 'sage'. There are no indications of conflicts with other services registering similar keys.

  • Verified registration in packages/api/src/hris/timeoff/services/sage/mappers.ts.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the registration of the SageTimeoffMapper service.

# Test: Search for the registration of services in MappersRegistry. Expect: Correct initialization and no conflicts.
rg --type typescript 'registerService\(.*\'hris\', \'timeoff\', \'sage\''

Length of output: 93


Script:

#!/bin/bash
# Description: Verify the registration of the SageTimeoffMapper service.

# Test: Search for the registration of services in MappersRegistry. Expect: Correct initialization and no conflicts.
rg --type typescript "registerService\(.*'hris', 'timeoff', 'sage'"

Length of output: 122


Script:

#!/bin/bash
# Description: Verify the registration of the SageTimeoffMapper service.

# Test: Search for the registration of services in MappersRegistry without specifying file type.
rg "registerService\(.*'hris', 'timeoff', 'sage'"

Length of output: 199


81-94: Ensure all status codes are covered in mapStatus.

The mapStatus method defaults to 'REQUESTED' for unknown status codes. Ensure that all possible status codes from the source are covered or documented.

packages/api/src/hris/employee/services/sage/mappers.ts (3)

95-104: Ensure all marital status values are covered in mapMaritalStatus.

The mapMaritalStatus method defaults to 'SINGLE' for unknown values. Ensure that all possible marital status values from the source are covered or documented.


106-114: Ensure all employment status values are covered in mapEmploymentStatus.

The mapEmploymentStatus method defaults to 'INACTIVE' for unknown values. Ensure that all possible employment status values from the source are covered or documented.


16-25: Ensure proper registration of the service.

The SageEmployeeMapper class registers itself in the MappersRegistry. Ensure that the registry is correctly initialized and that there are no conflicts with other services registering similar keys.

Verification successful

Proper registration of SageEmployeeMapper confirmed. The SageEmployeeMapper is registered in the MappersRegistry using the key 'hris', 'employee', 'sage', and no other services are registered with the same key, ensuring no conflicts.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the registration of the SageEmployeeMapper service.

# Test: Search for the registration of services in MappersRegistry. Expect: Correct initialization and no conflicts.
rg --type typescript 'registerService\(.*\'hris\', \'employee\', \'sage\''

Length of output: 93


Script:

#!/bin/bash
# Description: Verify the registration of the SageEmployeeMapper service.

# Test: Search for the registration of services in MappersRegistry. Expect: Correct initialization and no conflicts.
rg --type typescript "registerService\(.*'hris', 'employee', 'sage'"

Length of output: 123


Script:

#!/bin/bash
# Description: Verify the registration of the SageEmployeeMapper service.

# Test: Search for the registration of services in MappersRegistry. Expect: Correct initialization and no conflicts.
rg --type ts "registerService\(.*'hris', 'employee', 'sage'"

Length of output: 212


Script:

#!/bin/bash
# Description: Check for any other services registered with the same key in MappersRegistry to ensure no conflicts.

# Test: Search for any other registrations using the same key in the codebase.
rg --type ts "registerService\(.*'hris', 'employee', 'sage'"

Length of output: 212

packages/api/src/@core/utils/types/original/original.hris.ts (8)

91-91: Verify the expanded OriginalCompanyOutput type.

The OriginalCompanyOutput type now includes DeelCompanyOutput. Ensure that this expansion aligns with the intended functionality and that all necessary mappings are updated.


97-100: Verify the expanded OriginalEmployeeOutput type.

The OriginalEmployeeOutput type now includes SageEmployeeOutput and DeelEmployeeOutput. Ensure that this expansion aligns with the intended functionality and that all necessary mappings are updated.


132-132: Verify the simplified OriginalTimeoffBalanceOutput type.

The OriginalTimeoffBalanceOutput type now exclusively references SageTimeoffbalanceOutput. Ensure that this simplification aligns with the intended functionality and that all necessary mappings are updated.

Verification successful

Simplification of OriginalTimeoffBalanceOutput Verified

The OriginalTimeoffBalanceOutput type, now referencing SageTimeoffbalanceOutput, is consistently used across the codebase. This simplification aligns with the intended functionality, and all necessary mappings appear to be updated correctly.

  • Files Involved:
    • packages/api/src/hris/timeoffbalance/types/index.ts
    • packages/api/src/hris/timeoffbalance/sync/sync.service.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage and mapping of the simplified OriginalTimeoffBalanceOutput type.

# Test: Search for the usage of OriginalTimeoffBalanceOutput. Expect: All necessary mappings are updated.
rg --type typescript 'OriginalTimeoffBalanceOutput'

Length of output: 86


Script:

#!/bin/bash
# Description: Verify the usage and mapping of the simplified OriginalTimeoffBalanceOutput type.

# Test: Search for the usage of OriginalTimeoffBalanceOutput. Expect: All necessary mappings are updated.
rg 'OriginalTimeoffBalanceOutput' --glob '*.ts'

Length of output: 915


114-117: Verify the expanded OriginalGroupOutput type.

The OriginalGroupOutput type now includes DeelGroupOutput and SageGroupOutput. Ensure that this expansion aligns with the intended functionality and that all necessary mappings are updated.


4-18: Ensure new imports are necessary and used.

The file imports several new types from Deel and Sage services. Ensure that all imported types are necessary and used in the type definitions.

Verification successful

All imported types are necessary and used.

The imported types from Deel and Sage services are utilized in type definitions within the original.hris.ts file, confirming their necessity.

  • DeelCompanyOutput, DeelEmployeeOutput, SageEmployeeOutput, DeelEmploymentOutput, SageGroupOutput, DeelLocationOutput, SageTimeoffOutput, SageTimeoffbalanceOutput are all used in type definitions.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all imported types are necessary and used.

# Test: Search for the usage of each imported type. Expect: All types are used in the file.
rg --type typescript 'DeelCompanyOutput|DeelEmployeeOutput|SageEmployeeOutput|DeelEmploymentOutput|SageGroupOutput|DeelLocationOutput|SageTimeoffOutput|SageTimeoffbalanceOutput'

Length of output: 214


Script:

#!/bin/bash
# Description: Verify all imported types are necessary and used.

# Test: Search for the usage of each imported type. Expect: All types are used in the file.
rg --type ts 'DeelCompanyOutput|DeelEmployeeOutput|SageEmployeeOutput|DeelEmploymentOutput|SageGroupOutput|DeelLocationOutput|SageTimeoffOutput|SageTimeoffbalanceOutput'

Length of output: 7115


129-129: Verify the simplified OriginalTimeoffOutput type.

The OriginalTimeoffOutput type now exclusively references SageTimeoffOutput. Ensure that this simplification aligns with the intended functionality and that all necessary mappings are updated.

Verification successful

Simplification of OriginalTimeoffOutput Verified

The OriginalTimeoffOutput type, now referencing SageTimeoffOutput, is consistently used across the codebase in various modules. This simplification aligns with the intended functionality, and all necessary mappings appear to be updated. No issues were found.

  • Files where OriginalTimeoffOutput is used:
    • packages/api/src/hris/timeoff/types/index.ts
    • packages/api/src/hris/timeoff/services/timeoff.service.ts
    • packages/api/src/hris/timeoff/sync/sync.service.ts
    • packages/api/src/hris/timeoff/services/sage/index.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage and mapping of the simplified OriginalTimeoffOutput type.

# Test: Search for the usage of OriginalTimeoffOutput. Expect: All necessary mappings are updated.
rg --type typescript 'OriginalTimeoffOutput'

Length of output: 79


Script:

#!/bin/bash
# Description: Verify the usage and mapping of the simplified OriginalTimeoffOutput type.

# Test: Search for the usage of OriginalTimeoffOutput in TypeScript files.
rg 'OriginalTimeoffOutput' --glob '*.ts' -A 3

Length of output: 4669


109-111: Verify the expanded OriginalEmploymentOutput type.

The OriginalEmploymentOutput type now includes DeelEmploymentOutput. Ensure that this expansion aligns with the intended functionality and that all necessary mappings are updated.

Verification successful

The expansion of OriginalEmploymentOutput to include DeelEmploymentOutput is correctly integrated. The usage of DeelEmploymentOutput across the codebase, particularly in mapping and service logic, aligns with the intended functionality. No further updates are necessary.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage and mapping of the expanded OriginalEmploymentOutput type.

# Test: Search for the usage of OriginalEmploymentOutput. Expect: All necessary mappings are updated.
rg --type typescript 'OriginalEmploymentOutput'

Length of output: 82


Script:

#!/bin/bash
# Corrected script to search for the usage of OriginalEmploymentOutput in TypeScript files.

# Test: Search for the usage of OriginalEmploymentOutput. Expect: All necessary mappings are updated.
rg --type ts 'OriginalEmploymentOutput'

Length of output: 829


Script:

#!/bin/bash
# Search for the usage of DeelEmploymentOutput to verify its integration.

rg --type ts 'DeelEmploymentOutput'

Length of output: 898


120-120: Verify the expanded OriginalLocationOutput type.

The OriginalLocationOutput type now includes DeelLocationOutput. Ensure that this expansion aligns with the intended functionality and that all necessary mappings are updated.

packages/api/src/hris/employment/services/deel/mappers.ts (6)

18-27: Constructor Implementation Looks Good.

The constructor correctly initializes dependencies and registers the service with the MappersRegistry.


37-58: Efficient Handling of Employment Data in unify Method.

The unify method efficiently handles both single and multiple employment records and maps them to a unified format.


60-78: Well-Structured Mapping in mapSingleEmploymentToUnified Method.

The method effectively maps individual employment details to a unified format, covering various attributes.


81-96: Correct Mapping in mapPayPeriod Method.

The method correctly maps pay scales to pay periods using a switch statement.


98-113: Assumptions Noted in mapPayFrequency Method.

The method maps pay scales to frequencies, with assumptions for daily and hourly scales clearly noted.


115-135: Correct Mapping in mapFlsaStatus and mapEmploymentType Methods.

Both methods correctly map employment types and FLSA statuses using switch statements.

packages/api/src/@core/connections/hris/services/sage/sage.service.ts (1)

24-41: Constructor Implementation Looks Good.

The constructor correctly initializes dependencies and registers the service with the ServiceRegistry.

packages/api/src/hris/employee/services/deel/mappers.ts (4)

18-27: Constructor Implementation Looks Good.

The constructor correctly initializes dependencies and registers the service with the MappersRegistry.


37-58: Efficient Handling of Employee Data in unify Method.

The unify method efficiently handles both single and multiple employee records and maps them to a unified format.


60-155: Well-Structured Mapping in mapSingleEmployeeToUnified Method.

The method effectively maps individual employee details to a unified format, covering various attributes.


158-169: Correct Mapping in mapEmploymentStatus Method.

The method correctly maps employment statuses using a switch statement.

packages/shared/src/connectors/metadata.ts (2)

2466-2472: Connector Updated: Payfit

The payfit connector has been updated with a new logo path and is now active. Ensure that the logo path is correct and accessible.

Verify the accessibility of the logo path to ensure it displays correctly.

Verification successful

Logo Path Verified: Payfit Connector

The logo path for the payfit connector is accessible and correctly configured, returning a valid image. No further action is needed regarding this update.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the accessibility of the logo path for the `payfit` connector.

# Test: Check if the logo URL is accessible.
curl -I https://play-lh.googleusercontent.com/EMobDJKabP1eY_63QHgPS_-TK3eRfxXaeOnERbcRaWAw573iaV74pXS9xOv997dRZtM

Length of output: 871


2568-2581: Connector Renamed and Updated: Sage

The connector has been renamed from sage_hr to sage with updated URLs, logo path, and active status. Ensure that the renaming is consistent across the codebase.

Verify the operational status and the correctness of the URLs.

Verification successful

URLs for Sage Connector are Operational and Correct

The URLs for the sage connector are functioning as expected:

  • The documentation URL is accessible.
  • The API URL redirects appropriately, indicating the service is active.

No further issues found regarding the operational status and URL correctness.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the operational status and URLs for the `sage` connector.

# Test: Check if the documentation and API URLs are accessible.
curl -I https://sagehr.docs.apiary.io/#reference
curl -I https://example.sage.hr # Replace 'example' with a valid subdomain for testing

Length of output: 2241

Comment on lines +38 to +51
async getGroupUuidFromRemoteId(id: string, connection_id: string) {
try {
const res = await this.prisma.hris_groups.findFirst({
where: {
remote_id: id,
id_connection: connection_id,
},
});
if (!res) return;
return res.id_hris_group;
} catch (error) {
throw error;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove redundant catch block.

The catch block that only rethrows the original error is unnecessary and can be removed for clarity.

-    } catch (error) {
-      throw error;
-    }
+    }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async getGroupUuidFromRemoteId(id: string, connection_id: string) {
try {
const res = await this.prisma.hris_groups.findFirst({
where: {
remote_id: id,
id_connection: connection_id,
},
});
if (!res) return;
return res.id_hris_group;
} catch (error) {
throw error;
}
}
async getGroupUuidFromRemoteId(id: string, connection_id: string) {
try {
const res = await this.prisma.hris_groups.findFirst({
where: {
remote_id: id,
id_connection: connection_id,
},
});
if (!res) return;
return res.id_hris_group;
}
}
Tools
Biome

[error] 49-49: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

employment_status_id: number;
start_date: string;
end_date: string;
employment_statu_name: string; // Note: This seems to be a typo in the original data
Copy link
Contributor

Choose a reason for hiding this comment

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

Correct the typo in the field name.

There is a typo in the field name employment_statu_name. It should be corrected to employment_status_name.

-  employment_statu_name: string; // Note: This seems to be a typo in the original data
+  employment_status_name: string; // Corrected typo
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
employment_statu_name: string; // Note: This seems to be a typo in the original data
employment_status_name: string; // Corrected typo

Comment on lines +24 to +29
async desunify(
source: UnifiedHrisGroupInput,
customFieldMappings?: { slug: string; remote_id: string }[],
): Promise<any> {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider implementing the desunify method.

The desunify method currently returns nothing. If this is intentional, consider adding a comment explaining why it's not implemented.

+    // TODO: Implement desunify logic or explain why it's not needed.
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async desunify(
source: UnifiedHrisGroupInput,
customFieldMappings?: { slug: string; remote_id: string }[],
): Promise<any> {
return;
}
async desunify(
source: UnifiedHrisGroupInput,
customFieldMappings?: { slug: string; remote_id: string }[],
): Promise<any> {
// TODO: Implement desunify logic or explain why it's not needed.
return;
}

Comment on lines +24 to +29
async desunify(
source: UnifiedHrisGroupInput,
customFieldMappings?: { slug: string; remote_id: string }[],
): Promise<any> {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Implement the desunify method.

The desunify method currently returns nothing. Consider implementing it or adding a comment explaining why it's not implemented.

Would you like assistance in implementing this method or opening a GitHub issue to track it?

Comment on lines +54 to +56
} catch (error) {
throw error;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove redundant catch block.

The catch block that only rethrows the error is unnecessary and can be removed to simplify the code.

-    } catch (error) {
-      throw error;
-    }
+    }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} catch (error) {
throw error;
}
}
Tools
Biome

[error] 55-55: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

Comment on lines +58 to +81
private async mapSingleEmployeeToUnified(
employee: SageEmployeeOutput,
connectionId: string,
customFieldMappings?: { slug: string; remote_id: string }[],
): Promise<UnifiedHrisEmployeeOutput> {
return {
remote_id: employee.id.toString(),
remote_data: employee,
first_name: employee.first_name,
last_name: employee.last_name,
display_full_name: `${employee.first_name} ${employee.last_name}`,
work_email: employee.email,
mobile_phone_number: employee.mobile_phone,
employments: [], // We would need to process employment history to populate this
groups: [employee.team],
start_date: new Date(employee.employment_start_date),
employment_status: this.mapEmploymentStatus(employee.employment_status),
date_of_birth: new Date(employee.date_of_birth),
gender: this.mapGender(employee.gender),
marital_status: this.mapMaritalStatus(employee.marital_status),
avatar_url: employee.picture_url,
ssn: employee.personal_identification_number,
employee_number: employee.employee_number,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider handling missing or optional fields in mapSingleEmployeeToUnified.

The mapSingleEmployeeToUnified method assumes all fields are present. Consider handling cases where fields like employee.email or employee.mobile_phone might be missing.

return {
  remote_id: employee.id.toString(),
  remote_data: employee,
  first_name: employee.first_name || '',
  last_name: employee.last_name || '',
  display_full_name: `${employee.first_name || ''} ${employee.last_name || ''}`,
  work_email: employee.email || '',
  mobile_phone_number: employee.mobile_phone || '',
  // Rest of the code...
};

Comment on lines +30 to +35
addGroup(
groupData: DesunifyReturnType,
linkedUserId: string,
): Promise<ApiResponse<OriginalGroupOutput>> {
throw new Error('Method not implemented.');
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Implement the addGroup method.

The addGroup method is not implemented and throws an error. Ensure this method is implemented to handle group addition logic.

Would you like assistance in implementing the addGroup method?

Comment on lines +25 to +28
this.logger.setContext(
HrisObject.group.toUpperCase() + ':' + SageService.name,
);
this.registry.registerService('sage', this);
Copy link
Contributor

Choose a reason for hiding this comment

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

Use template literals for string concatenation.

Replace string concatenation with template literals for better readability and performance.

-    this.logger.setContext(
-      HrisObject.group.toUpperCase() + ':' + SageService.name,
-    );
+    this.logger.setContext(
+      `${HrisObject.group.toUpperCase()}:${SageService.name}`,
+    );
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
this.logger.setContext(
HrisObject.group.toUpperCase() + ':' + SageService.name,
);
this.registry.registerService('sage', this);
this.logger.setContext(
`${HrisObject.group.toUpperCase()}:${SageService.name}`,
);
this.registry.registerService('sage', this);
Tools
Biome

[error] 26-26: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)

Comment on lines +37 to +65
async sync(data: SyncParam): Promise<ApiResponse<SageGroupOutput[]>> {
try {
const { linkedUserId } = data;

const connection = await this.prisma.connections.findFirst({
where: {
id_linked_user: linkedUserId,
provider_slug: 'sage',
vertical: 'hris',
},
});

const resp = await axios.get(`${connection.account_url}/api/teams`, {
headers: {
'Content-Type': 'application/json',
'X-Auth-Token': this.cryptoService.decrypt(connection.access_token),
},
});
this.logger.log(`Synced sage groups !`);

return {
data: resp.data.data,
message: 'Sage groups retrieved',
statusCode: 200,
};
} catch (error) {
throw error;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove redundant catch block in sync method.

The catch block rethrows the original error without any additional handling, which is redundant. Consider removing it to simplify the code.

-    } catch (error) {
-      throw error;
-    }
+    }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async sync(data: SyncParam): Promise<ApiResponse<SageGroupOutput[]>> {
try {
const { linkedUserId } = data;
const connection = await this.prisma.connections.findFirst({
where: {
id_linked_user: linkedUserId,
provider_slug: 'sage',
vertical: 'hris',
},
});
const resp = await axios.get(`${connection.account_url}/api/teams`, {
headers: {
'Content-Type': 'application/json',
'X-Auth-Token': this.cryptoService.decrypt(connection.access_token),
},
});
this.logger.log(`Synced sage groups !`);
return {
data: resp.data.data,
message: 'Sage groups retrieved',
statusCode: 200,
};
} catch (error) {
throw error;
}
}
async sync(data: SyncParam): Promise<ApiResponse<SageGroupOutput[]>> {
try {
const { linkedUserId } = data;
const connection = await this.prisma.connections.findFirst({
where: {
id_linked_user: linkedUserId,
provider_slug: 'sage',
vertical: 'hris',
},
});
const resp = await axios.get(`${connection.account_url}/api/teams`, {
headers: {
'Content-Type': 'application/json',
'X-Auth-Token': this.cryptoService.decrypt(connection.access_token),
},
});
this.logger.log(`Synced sage groups !`);
return {
data: resp.data.data,
message: 'Sage groups retrieved',
statusCode: 200,
};
}
}
Tools
Biome

[error] 63-63: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

Comment on lines +84 to +93
private mapGender(sageGender: string): Gender {
switch (sageGender.toLowerCase()) {
case 'male':
return 'MALE';
case 'female':
return 'FEMALE';
default:
return 'OTHER';
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Expand mapGender to include all defined gender values.

The mapGender method currently maps only 'male' and 'female', defaulting to 'OTHER' for any other values. However, the codebase defines additional gender options such as 'NON_BINARY' and 'DECLINE_TO_SELF_IDENTIFY'. Consider updating the mapGender method to handle these cases explicitly.

  • Check the type definition in packages/api/src/ats/eeocs/types/model.unified.ts for all possible gender values.
Analysis chain

Ensure all gender values are covered in mapGender.

The mapGender method defaults to 'OTHER' for unknown gender values. Ensure that all possible gender values from the source are covered or documented.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all gender values are covered in mapGender.

# Test: Search for all gender values used in the source. Expect: All values are mapped correctly.
rg --type typescript 'gender'

Length of output: 64


Script:

#!/bin/bash
# Description: Verify all gender values are covered in mapGender.

# Test: Search for all gender values used in TypeScript files. Expect: All values are mapped correctly.
rg --type ts '(gender|sageGender)' -A 2

Length of output: 5827

Copy link

gitguardian bot commented Aug 16, 2024

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
13351813 Triggered Generic Password aef9526 packages/shared/src/connectors/metadata.ts View secret
13422060 Triggered Generic Password aef9526 packages/shared/src/connectors/metadata.ts View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

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

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 2e62b82 and aef9526.

Files selected for processing (14)
  • packages/api/src/@core/connections/connections.module.ts (3 hunks)
  • packages/api/src/@core/connections/cybersecurity/cybersecurity.connection.module.ts (1 hunks)
  • packages/api/src/@core/connections/cybersecurity/services/crowdstrike/crowdstrike.service.ts (1 hunks)
  • packages/api/src/@core/connections/cybersecurity/services/cybersecurity.connection.service.ts (1 hunks)
  • packages/api/src/@core/connections/cybersecurity/services/microsoftdefender/microsoftdefender.service.ts (1 hunks)
  • packages/api/src/@core/connections/cybersecurity/services/qualys/qualys.service.ts (1 hunks)
  • packages/api/src/@core/connections/cybersecurity/services/rapid7insightvm/rapid7.service.ts (1 hunks)
  • packages/api/src/@core/connections/cybersecurity/services/registry.service.ts (1 hunks)
  • packages/api/src/@core/connections/cybersecurity/services/semgrep/semgrep.service.ts (1 hunks)
  • packages/api/src/@core/connections/cybersecurity/services/sentinelone/sentinelone.service.ts (1 hunks)
  • packages/api/src/@core/connections/cybersecurity/services/snyk/snyk.service.ts (1 hunks)
  • packages/api/src/@core/connections/cybersecurity/services/tenable/tenable.service.ts (1 hunks)
  • packages/shared/src/categories.ts (1 hunks)
  • packages/shared/src/connectors/metadata.ts (6 hunks)
Additional context used
Biome
packages/api/src/@core/connections/cybersecurity/services/semgrep/semgrep.service.ts

[error] 75-75: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)


[error] 136-136: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

packages/api/src/@core/connections/cybersecurity/services/cybersecurity.connection.service.ts

[error] 80-80: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)


[error] 105-105: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)


[error] 126-126: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

packages/api/src/@core/connections/cybersecurity/services/rapid7insightvm/rapid7.service.ts

[error] 75-75: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)


[error] 138-138: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

packages/api/src/@core/connections/cybersecurity/services/sentinelone/sentinelone.service.ts

[error] 79-79: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)


[error] 142-142: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

packages/api/src/@core/connections/cybersecurity/services/tenable/tenable.service.ts

[error] 79-79: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)


[error] 140-140: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

packages/api/src/@core/connections/cybersecurity/services/qualys/qualys.service.ts

[error] 82-82: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)


[error] 149-149: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

packages/api/src/@core/connections/cybersecurity/services/snyk/snyk.service.ts

[error] 86-86: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)


[error] 181-181: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 184-184: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

packages/api/src/@core/connections/cybersecurity/services/crowdstrike/crowdstrike.service.ts

[error] 90-90: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)


[error] 185-185: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 188-188: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

packages/api/src/@core/connections/cybersecurity/services/microsoftdefender/microsoftdefender.service.ts

[error] 90-90: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)


[error] 189-189: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 192-192: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

Additional comments not posted (23)
packages/shared/src/categories.ts (1)

10-11: Addition of Cybersecurity category is appropriate.

The addition of the Cybersecurity category to the ConnectorCategory enum is a straightforward enhancement that aligns with the PR's objectives. Ensure that this new category is properly utilized in the codebase.

packages/api/src/@core/connections/cybersecurity/services/registry.service.ts (1)

1-24: Service Registry implementation is well-structured.

The ServiceRegistry class provides a clear and efficient way to manage connection services using a map. The error handling for missing services is appropriate. Ensure that this service registry is correctly integrated and utilized in the broader system.

packages/api/src/@core/connections/cybersecurity/cybersecurity.connection.module.ts (1)

1-38: Cybersecurity Connections Module is comprehensive and well-structured.

The module is well-defined with appropriate imports and a comprehensive list of providers for various cybersecurity services. Ensure that each service is correctly implemented and thoroughly tested.

packages/api/src/@core/connections/connections.module.ts (3)

15-15: Import statement is correct.

The import statement for CybersecurityConnectionsModule is correctly added and follows the existing structure.


29-29: Addition to imports is correct.

The CybersecurityConnectionsModule is correctly added to the imports array, enhancing the module's functionality.


45-45: Addition to exports is correct.

The CybersecurityConnectionsModule is correctly added to the exports array, making its functionalities available to other modules.

packages/api/src/@core/connections/cybersecurity/services/semgrep/semgrep.service.ts (2)

1-22: Import statements are appropriate.

The import statements correctly bring in necessary services and types for the SemgrepConnectionService.


24-41: Class declaration and constructor are correct.

The SemgrepConnectionService class is well-structured, extending AbstractBaseConnectionService and initializing necessary services.

packages/api/src/@core/connections/cybersecurity/services/cybersecurity.connection.service.ts (2)

1-15: Import statements are appropriate.

The import statements correctly bring in necessary services and types for the CybersecurityConnectionsService.


17-28: Class declaration and constructor are correct.

The CybersecurityConnectionsService class is well-structured, implementing IConnectionCategory and initializing necessary services.

packages/api/src/@core/connections/cybersecurity/services/rapid7insightvm/rapid7.service.ts (2)

142-144: LGTM: Method not implemented.

The handleTokenRefresh method correctly throws an error indicating it is not implemented, which is acceptable if this functionality is not required.


56-62: Verify the authorization header construction.

Ensure that using Basic authentication with an empty username and the access token as the password is the correct approach for this integration.

packages/api/src/@core/connections/cybersecurity/services/sentinelone/sentinelone.service.ts (2)

146-148: LGTM: Method not implemented.

The handleTokenRefresh method correctly throws an error indicating it is not implemented, which is acceptable if this functionality is not required.


60-65: Verify the authorization header construction.

Ensure that using the APIToken scheme with the decrypted access token is the correct approach for this integration.

packages/api/src/@core/connections/cybersecurity/services/tenable/tenable.service.ts (2)

144-146: LGTM: Method not implemented.

The handleTokenRefresh method correctly throws an error indicating it is not implemented, which is acceptable if this functionality is not required.


62-66: Verify the custom header construction.

Ensure that using the X-ApiKeys header with the secret key is the correct approach for this integration.

packages/api/src/@core/connections/cybersecurity/services/microsoftdefender/microsoftdefender.service.ts (1)

36-54: Constructor logic is well-structured.

The constructor effectively uses dependency injection and sets up necessary configurations.

packages/shared/src/connectors/metadata.ts (6)

1113-1125: Verify the documentation URL for Apollo.

The documentation URL for the Apollo connector (https://apolloio.github.io/apollo-api-docs/?shell#introduction) is returning a 404 Not Found error. Please verify and update the URL to ensure it points to a valid documentation page.


1268-1276: Ensure consistent parameter naming for BambooHR.

The parameter name subdomain has been updated, but there are still occurrences of company_subdomain in the codebase, particularly in the BambooHR service files. Please review the following locations to ensure consistent parameter naming.


2466-2472: Verify the logo URL for Payfit.

The logo path for the Payfit connector has been updated. Ensure that the URL is correct and accessible.

Verification successful

Logo URL for Payfit is correct and accessible.

The logo URL for the Payfit connector is valid and accessible, as confirmed by the HTTP 200 response. No further action is needed regarding this update.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the logo URL for the Payfit connector.

# Test: Check if the logo URL is accessible.
curl -I https://assets.wheelhouse.com/media/_solution_logo_04042023_58844144.png

Length of output: 913


2972-2984: Verify the documentation URL for Semgrep.

Ensure that the documentation URL for the Semgrep connector (https://semgrep.dev/api/v1/docs/#section/Introduction) is valid and accessible.

Verification successful

The documentation URL for Semgrep is valid and accessible.

The URL https://semgrep.dev/api/v1/docs/#section/Introduction returned a successful HTTP 200 status code, confirming its validity.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the documentation URL for the Semgrep connector.

# Test: Check if the documentation URL is accessible.
curl -I https://semgrep.dev/api/v1/docs/#section/Introduction

Length of output: 821


2568-2581: Verify the renaming and updates for Sage connector.

The "sage_hr" connector has been renamed to "sage." Ensure that this renaming is consistently applied across the codebase. Additionally, verify the new documentation URL https://sagehr.docs.apiary.io/#reference and the API URL format.

Verification successful

Renaming and Updates for Sage Connector Verified

The renaming of the "sage_hr" connector to "sage" has been consistently applied across the codebase. Additionally, the new documentation URL is accessible and returns a 200 status code. No issues were found.

  • The term "sage_hr" is no longer present in the codebase.
  • The documentation URL https://sagehr.docs.apiary.io/#reference is valid.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the renaming and updates for the Sage connector.

# Test: Search for occurrences of "sage_hr" to ensure consistent renaming.
rg --type ts --type js 'sage_hr'

# Test: Verify the new documentation URL for accessibility.
curl -I https://sagehr.docs.apiary.io/#reference

Length of output: 973


2986-3002: Verify the documentation URL for Snyk.

Ensure that the documentation URL for the Snyk connector (https://docs.snyk.io/snyk-api/) is valid and accessible.

Verification successful

Update the Snyk documentation URL to avoid redirects.

The current documentation URL for the Snyk connector (https://docs.snyk.io/snyk-api/) results in a permanent redirect. Consider updating it to the final destination to avoid unnecessary redirects.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the documentation URL for the Snyk connector.

# Test: Check if the documentation URL is accessible.
curl -I https://docs.snyk.io/snyk-api/

Length of output: 951

Comment on lines +196 to +198
async handleTokenRefresh(opts: RefreshParams) {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Document or implement the handleTokenRefresh method.

The method is currently a placeholder. If it's intended for future work, consider adding a TODO comment.

Would you like me to generate a GitHub issue to track the implementation of this method?

Comment on lines +191 to +193
} catch (error) {
throw error;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove redundant catch block.

The catch block that only rethrows the error is unnecessary and can be removed to simplify the code.

-  } catch (error) {
-    throw error;
-  }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} catch (error) {
throw error;
}
Tools
Biome

[error] 192-192: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

},
});
}
this.logger.log('Successfully added tokens inside DB ' + db_res);
Copy link
Contributor

Choose a reason for hiding this comment

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

Use template literals for logging.

Replace string concatenation with template literals for better readability.

- this.logger.log('Successfully added tokens inside DB ' + db_res);
+ this.logger.log(`Successfully added tokens inside DB ${db_res}`);
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
this.logger.log('Successfully added tokens inside DB ' + db_res);
this.logger.log(`Successfully added tokens inside DB ${db_res}`);
Tools
Biome

[error] 189-189: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)

Comment on lines +56 to +92
async passthrough(
input: PassthroughInput,
connectionId: string,
): Promise<PassthroughResponse> {
try {
const { headers } = input;
const config = await this.constructPassthrough(input, connectionId);

const connection = await this.prisma.connections.findUnique({
where: {
id_connection: connectionId,
},
});

const access_token = JSON.parse(
this.cryptoService.decrypt(connection.access_token),
);
config.headers = {
...config.headers,
...headers,
Authorization: `Bearer ${access_token}`,
};

return await this.retryService.makeRequest(
{
method: config.method,
url: config.url,
data: config.data,
headers: config.headers,
},
'cybersecurity.microsoftdefender.passthrough',
config.linkedUserId,
);
} catch (error) {
throw error;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove redundant catch block.

The catch block that only rethrows the error is unnecessary and can be removed to simplify the code.

-  } catch (error) {
-    throw error;
-  }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async passthrough(
input: PassthroughInput,
connectionId: string,
): Promise<PassthroughResponse> {
try {
const { headers } = input;
const config = await this.constructPassthrough(input, connectionId);
const connection = await this.prisma.connections.findUnique({
where: {
id_connection: connectionId,
},
});
const access_token = JSON.parse(
this.cryptoService.decrypt(connection.access_token),
);
config.headers = {
...config.headers,
...headers,
Authorization: `Bearer ${access_token}`,
};
return await this.retryService.makeRequest(
{
method: config.method,
url: config.url,
data: config.data,
headers: config.headers,
},
'cybersecurity.microsoftdefender.passthrough',
config.linkedUserId,
);
} catch (error) {
throw error;
}
}
async passthrough(
input: PassthroughInput,
connectionId: string,
): Promise<PassthroughResponse> {
try {
const { headers } = input;
const config = await this.constructPassthrough(input, connectionId);
const connection = await this.prisma.connections.findUnique({
where: {
id_connection: connectionId,
},
});
const access_token = JSON.parse(
this.cryptoService.decrypt(connection.access_token),
);
config.headers = {
...config.headers,
...headers,
Authorization: `Bearer ${access_token}`,
};
return await this.retryService.makeRequest(
{
method: config.method,
url: config.url,
data: config.data,
headers: config.headers,
},
'cybersecurity.microsoftdefender.passthrough',
config.linkedUserId,
);
}
}
Tools
Biome

[error] 90-90: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

Comment on lines +153 to +155
handleTokenRefresh?(opts: RefreshParams): Promise<any> {
throw new Error('Method not implemented.');
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Clarify or implement the handleTokenRefresh method.

The method currently throws a "not implemented" error. Consider implementing it or documenting why it is not supported.

Comment on lines +43 to +82
async handleCallBack(
providerName: string,
callbackOpts: CallbackParams,
type_strategy: 'oauth2' | 'apikey' | 'basic',
) {
try {
const serviceName = providerName.toLowerCase();

const service = this.serviceRegistry.getService(serviceName);

if (!service) {
throw new ReferenceError(`Unknown provider, found ${providerName}`);
}
const data: Connection = await service.handleCallback(callbackOpts);
const event = await this.prisma.events.create({
data: {
id_connection: data.id_connection,
id_project: data.id_project,
id_event: uuidv4(),
status: 'success',
type: 'connection.created',
method: 'GET',
url: `/${type_strategy}/callback`,
provider: providerName.toLowerCase(),
direction: '0',
timestamp: new Date(),
id_linked_user: callbackOpts.linkedUserId,
},
});
//directly send the webhook
await this.webhook.dispatchWebhook(
data,
'connection.created',
callbackOpts.projectId,
event.id_event,
);
} catch (error) {
throw error;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove redundant catch clause in handleCallBack.

The catch clause that only rethrows the error is unnecessary and can be removed for clarity.

    } catch (error) {
-     throw error;
    }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async handleCallBack(
providerName: string,
callbackOpts: CallbackParams,
type_strategy: 'oauth2' | 'apikey' | 'basic',
) {
try {
const serviceName = providerName.toLowerCase();
const service = this.serviceRegistry.getService(serviceName);
if (!service) {
throw new ReferenceError(`Unknown provider, found ${providerName}`);
}
const data: Connection = await service.handleCallback(callbackOpts);
const event = await this.prisma.events.create({
data: {
id_connection: data.id_connection,
id_project: data.id_project,
id_event: uuidv4(),
status: 'success',
type: 'connection.created',
method: 'GET',
url: `/${type_strategy}/callback`,
provider: providerName.toLowerCase(),
direction: '0',
timestamp: new Date(),
id_linked_user: callbackOpts.linkedUserId,
},
});
//directly send the webhook
await this.webhook.dispatchWebhook(
data,
'connection.created',
callbackOpts.projectId,
event.id_event,
);
} catch (error) {
throw error;
}
}
async handleCallBack(
providerName: string,
callbackOpts: CallbackParams,
type_strategy: 'oauth2' | 'apikey' | 'basic',
) {
try {
const serviceName = providerName.toLowerCase();
const service = this.serviceRegistry.getService(serviceName);
if (!service) {
throw new ReferenceError(`Unknown provider, found ${providerName}`);
}
const data: Connection = await service.handleCallback(callbackOpts);
const event = await this.prisma.events.create({
data: {
id_connection: data.id_connection,
id_project: data.id_project,
id_event: uuidv4(),
status: 'success',
type: 'connection.created',
method: 'GET',
url: `/${type_strategy}/callback`,
provider: providerName.toLowerCase(),
direction: '0',
timestamp: new Date(),
id_linked_user: callbackOpts.linkedUserId,
},
});
//directly send the webhook
await this.webhook.dispatchWebhook(
data,
'connection.created',
callbackOpts.projectId,
event.id_event,
);
}
Tools
Biome

[error] 80-80: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

Comment on lines +47 to +81
async passthrough(
input: PassthroughInput,
connectionId: string,
): Promise<PassthroughResponse> {
try {
const { headers } = input;
const config = await this.constructPassthrough(input, connectionId);

const connection = await this.prisma.connections.findUnique({
where: {
id_connection: connectionId,
},
});
config.headers = {
...config.headers,
...headers,
Authorization: `APIToken ${this.cryptoService.decrypt(
connection.access_token,
)}`,
};

return await this.retryService.makeRequest(
{
method: config.method,
url: config.url,
data: config.data,
headers: config.headers,
},
'cybersecurity.sentinelone.passthrough',
config.linkedUserId,
);
} catch (error) {
throw error;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove redundant catch block.

The catch block that only rethrows the original error is unnecessary and can be removed to simplify the code.

-   try {
      ...
-   } catch (error) {
-     throw error;
-   }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async passthrough(
input: PassthroughInput,
connectionId: string,
): Promise<PassthroughResponse> {
try {
const { headers } = input;
const config = await this.constructPassthrough(input, connectionId);
const connection = await this.prisma.connections.findUnique({
where: {
id_connection: connectionId,
},
});
config.headers = {
...config.headers,
...headers,
Authorization: `APIToken ${this.cryptoService.decrypt(
connection.access_token,
)}`,
};
return await this.retryService.makeRequest(
{
method: config.method,
url: config.url,
data: config.data,
headers: config.headers,
},
'cybersecurity.sentinelone.passthrough',
config.linkedUserId,
);
} catch (error) {
throw error;
}
}
async passthrough(
input: PassthroughInput,
connectionId: string,
): Promise<PassthroughResponse> {
const { headers } = input;
const config = await this.constructPassthrough(input, connectionId);
const connection = await this.prisma.connections.findUnique({
where: {
id_connection: connectionId,
},
});
config.headers = {
...config.headers,
...headers,
Authorization: `APIToken ${this.cryptoService.decrypt(
connection.access_token,
)}`,
};
return await this.retryService.makeRequest(
{
method: config.method,
url: config.url,
data: config.data,
headers: config.headers,
},
'cybersecurity.sentinelone.passthrough',
config.linkedUserId,
);
}
Tools
Biome

[error] 79-79: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

Comment on lines +83 to +143
async handleCallback(opts: OAuthCallbackParams) {
try {
const { linkedUserId, projectId, body } = opts;
const { api_key, host } = body;
const isNotUnique = await this.prisma.connections.findFirst({
where: {
id_linked_user: linkedUserId,
provider_slug: 'sentinelone',
vertical: 'cybersecurity',
},
});

let db_res;
const connection_token = uuidv4();
const BASE_API_URL = (
CONNECTORS_METADATA['cybersecurity']['sentinelone'].urls
.apiUrl as DynamicApiUrl
)(host);

if (isNotUnique) {
db_res = await this.prisma.connections.update({
where: {
id_connection: isNotUnique.id_connection,
},
data: {
access_token: this.cryptoService.encrypt(api_key),
account_url: BASE_API_URL,
status: 'valid',
created_at: new Date(),
},
});
} else {
db_res = await this.prisma.connections.create({
data: {
id_connection: uuidv4(),
connection_token: connection_token,
provider_slug: 'sentinelone',
vertical: 'cybersecurity',
token_type: 'basic',
account_url: BASE_API_URL,
access_token: this.cryptoService.encrypt(api_key),
status: 'valid',
created_at: new Date(),
projects: {
connect: { id_project: projectId },
},
linked_users: {
connect: {
id_linked_user: await this.connectionUtils.getLinkedUserId(
projectId,
linkedUserId,
),
},
},
},
});
}
return db_res;
} catch (error) {
throw error;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove redundant catch block.

The catch block that only rethrows the original error is unnecessary and can be removed to simplify the code.

-   try {
      ...
-   } catch (error) {
-     throw error;
-   }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async handleCallback(opts: OAuthCallbackParams) {
try {
const { linkedUserId, projectId, body } = opts;
const { api_key, host } = body;
const isNotUnique = await this.prisma.connections.findFirst({
where: {
id_linked_user: linkedUserId,
provider_slug: 'sentinelone',
vertical: 'cybersecurity',
},
});
let db_res;
const connection_token = uuidv4();
const BASE_API_URL = (
CONNECTORS_METADATA['cybersecurity']['sentinelone'].urls
.apiUrl as DynamicApiUrl
)(host);
if (isNotUnique) {
db_res = await this.prisma.connections.update({
where: {
id_connection: isNotUnique.id_connection,
},
data: {
access_token: this.cryptoService.encrypt(api_key),
account_url: BASE_API_URL,
status: 'valid',
created_at: new Date(),
},
});
} else {
db_res = await this.prisma.connections.create({
data: {
id_connection: uuidv4(),
connection_token: connection_token,
provider_slug: 'sentinelone',
vertical: 'cybersecurity',
token_type: 'basic',
account_url: BASE_API_URL,
access_token: this.cryptoService.encrypt(api_key),
status: 'valid',
created_at: new Date(),
projects: {
connect: { id_project: projectId },
},
linked_users: {
connect: {
id_linked_user: await this.connectionUtils.getLinkedUserId(
projectId,
linkedUserId,
),
},
},
},
});
}
return db_res;
} catch (error) {
throw error;
}
async handleCallback(opts: OAuthCallbackParams) {
const { linkedUserId, projectId, body } = opts;
const { api_key, host } = body;
const isNotUnique = await this.prisma.connections.findFirst({
where: {
id_linked_user: linkedUserId,
provider_slug: 'sentinelone',
vertical: 'cybersecurity',
},
});
let db_res;
const connection_token = uuidv4();
const BASE_API_URL = (
CONNECTORS_METADATA['cybersecurity']['sentinelone'].urls
.apiUrl as DynamicApiUrl
)(host);
if (isNotUnique) {
db_res = await this.prisma.connections.update({
where: {
id_connection: isNotUnique.id_connection,
},
data: {
access_token: this.cryptoService.encrypt(api_key),
account_url: BASE_API_URL,
status: 'valid',
created_at: new Date(),
},
});
} else {
db_res = await this.prisma.connections.create({
data: {
id_connection: uuidv4(),
connection_token: connection_token,
provider_slug: 'sentinelone',
vertical: 'cybersecurity',
token_type: 'basic',
account_url: BASE_API_URL,
access_token: this.cryptoService.encrypt(api_key),
status: 'valid',
created_at: new Date(),
projects: {
connect: { id_project: projectId },
},
linked_users: {
connect: {
id_linked_user: await this.connectionUtils.getLinkedUserId(
projectId,
linkedUserId,
),
},
},
},
});
}
return db_res;
}
Tools
Biome

[error] 142-142: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

Comment on lines +47 to +81
try {
const { headers } = input;
const config = await this.constructPassthrough(input, connectionId);

const connection = await this.prisma.connections.findUnique({
where: {
id_connection: connectionId,
},
});
const decryptedData = JSON.parse(
this.cryptoService.decrypt(connection.access_token),
);

const { access_key, secret_key } = decryptedData; // todo

config.headers = {
...config.headers,
...headers,
'X-ApiKeys': `${secret_key}`,
};

return await this.retryService.makeRequest(
{
method: config.method,
url: config.url,
data: config.data,
headers: config.headers,
},
'cybersecurity.tenable.passthrough',
config.linkedUserId,
);
} catch (error) {
throw error;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove redundant catch block.

The catch block that only rethrows the original error is unnecessary and can be removed to simplify the code.

-   try {
      ...
-   } catch (error) {
-     throw error;
-   }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
try {
const { headers } = input;
const config = await this.constructPassthrough(input, connectionId);
const connection = await this.prisma.connections.findUnique({
where: {
id_connection: connectionId,
},
});
const decryptedData = JSON.parse(
this.cryptoService.decrypt(connection.access_token),
);
const { access_key, secret_key } = decryptedData; // todo
config.headers = {
...config.headers,
...headers,
'X-ApiKeys': `${secret_key}`,
};
return await this.retryService.makeRequest(
{
method: config.method,
url: config.url,
data: config.data,
headers: config.headers,
},
'cybersecurity.tenable.passthrough',
config.linkedUserId,
);
} catch (error) {
throw error;
}
}
const { headers } = input;
const config = await this.constructPassthrough(input, connectionId);
const connection = await this.prisma.connections.findUnique({
where: {
id_connection: connectionId,
},
});
const decryptedData = JSON.parse(
this.cryptoService.decrypt(connection.access_token),
);
const { access_key, secret_key } = decryptedData; // todo
config.headers = {
...config.headers,
...headers,
'X-ApiKeys': `${secret_key}`,
};
return await this.retryService.makeRequest(
{
method: config.method,
url: config.url,
data: config.data,
headers: config.headers,
},
'cybersecurity.tenable.passthrough',
config.linkedUserId,
);
Tools
Biome

[error] 79-79: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

Comment on lines +83 to +142
async handleCallback(opts: OAuthCallbackParams) {
try {
const { linkedUserId, projectId, body } = opts;
const { access_key, secret_key } = body;
const isNotUnique = await this.prisma.connections.findFirst({
where: {
id_linked_user: linkedUserId,
provider_slug: 'tenable',
vertical: 'cybersecurity',
},
});

let db_res;
const connection_token = uuidv4();
const BASE_API_URL = CONNECTORS_METADATA['cybersecurity']['tenable'].urls
.apiUrl as string;

if (isNotUnique) {
db_res = await this.prisma.connections.update({
where: {
id_connection: isNotUnique.id_connection,
},
data: {
access_token: this.cryptoService.encrypt(secret_key),
account_url: BASE_API_URL,
status: 'valid',
created_at: new Date(),
},
});
} else {
db_res = await this.prisma.connections.create({
data: {
id_connection: uuidv4(),
connection_token: connection_token,
provider_slug: 'tenable',
vertical: 'cybersecurity',
token_type: 'basic',
account_url: BASE_API_URL,
access_token: this.cryptoService.encrypt(secret_key),
status: 'valid',
created_at: new Date(),
projects: {
connect: { id_project: projectId },
},
linked_users: {
connect: {
id_linked_user: await this.connectionUtils.getLinkedUserId(
projectId,
linkedUserId,
),
},
},
},
});
}
return db_res;
} catch (error) {
throw error;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove redundant catch block.

The catch block that only rethrows the original error is unnecessary and can be removed to simplify the code.

-   try {
      ...
-   } catch (error) {
-     throw error;
-   }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async handleCallback(opts: OAuthCallbackParams) {
try {
const { linkedUserId, projectId, body } = opts;
const { access_key, secret_key } = body;
const isNotUnique = await this.prisma.connections.findFirst({
where: {
id_linked_user: linkedUserId,
provider_slug: 'tenable',
vertical: 'cybersecurity',
},
});
let db_res;
const connection_token = uuidv4();
const BASE_API_URL = CONNECTORS_METADATA['cybersecurity']['tenable'].urls
.apiUrl as string;
if (isNotUnique) {
db_res = await this.prisma.connections.update({
where: {
id_connection: isNotUnique.id_connection,
},
data: {
access_token: this.cryptoService.encrypt(secret_key),
account_url: BASE_API_URL,
status: 'valid',
created_at: new Date(),
},
});
} else {
db_res = await this.prisma.connections.create({
data: {
id_connection: uuidv4(),
connection_token: connection_token,
provider_slug: 'tenable',
vertical: 'cybersecurity',
token_type: 'basic',
account_url: BASE_API_URL,
access_token: this.cryptoService.encrypt(secret_key),
status: 'valid',
created_at: new Date(),
projects: {
connect: { id_project: projectId },
},
linked_users: {
connect: {
id_linked_user: await this.connectionUtils.getLinkedUserId(
projectId,
linkedUserId,
),
},
},
},
});
}
return db_res;
} catch (error) {
throw error;
}
}
async handleCallback(opts: OAuthCallbackParams) {
const { linkedUserId, projectId, body } = opts;
const { access_key, secret_key } = body;
const isNotUnique = await this.prisma.connections.findFirst({
where: {
id_linked_user: linkedUserId,
provider_slug: 'tenable',
vertical: 'cybersecurity',
},
});
let db_res;
const connection_token = uuidv4();
const BASE_API_URL = CONNECTORS_METADATA['cybersecurity']['tenable'].urls
.apiUrl as string;
if (isNotUnique) {
db_res = await this.prisma.connections.update({
where: {
id_connection: isNotUnique.id_connection,
},
data: {
access_token: this.cryptoService.encrypt(secret_key),
account_url: BASE_API_URL,
status: 'valid',
created_at: new Date(),
},
});
} else {
db_res = await this.prisma.connections.create({
data: {
id_connection: uuidv4(),
connection_token: connection_token,
provider_slug: 'tenable',
vertical: 'cybersecurity',
token_type: 'basic',
account_url: BASE_API_URL,
access_token: this.cryptoService.encrypt(secret_key),
status: 'valid',
created_at: new Date(),
projects: {
connect: { id_project: projectId },
},
linked_users: {
connect: {
id_linked_user: await this.connectionUtils.getLinkedUserId(
projectId,
linkedUserId,
),
},
},
},
});
}
return db_res;
}
Tools
Biome

[error] 140-140: The catch clause that only rethrows the original error is redundant.

These unnecessary catch clauses can be confusing. It is recommended to remove them.

(lint/complexity/noUselessCatch)

@naelob naelob merged commit 1bf3cad into main Aug 16, 2024
9 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants