-
Notifications
You must be signed in to change notification settings - Fork 196
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
add integration with leadsquared #672
add integration with leadsquared #672
Conversation
Qovery can create a Preview Environment for this PR.
This comment has been generated from Qovery AI 🤖.
|
|
Warning Rate limit exceeded@Iamsidar07 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 3 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. WalkthroughWalkthroughThe integration of LeadSquared CRM enhances contact, deal, task, and engagement management with newly implemented service classes and mapping utilities. These components facilitate efficient addition and synchronization of entities, leveraging TypeScript for improved type safety and centralized error handling in API interactions. Changes
Assessment against linked issues
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 38
Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Files selected for processing (13)
- packages/api/src/crm/contact/services/leadsquared/index.ts (1 hunks)
- packages/api/src/crm/contact/services/leadsquared/mappers.ts (1 hunks)
- packages/api/src/crm/contact/services/leadsquared/types.ts (1 hunks)
- packages/api/src/crm/deal/services/leadsquared/index.ts (1 hunks)
- packages/api/src/crm/deal/services/leadsquared/mappers.ts (1 hunks)
- packages/api/src/crm/deal/services/leadsquared/types.ts (1 hunks)
- packages/api/src/crm/engagement/services/leadsquared/index.ts (1 hunks)
- packages/api/src/crm/engagement/services/leadsquared/mappers.ts (1 hunks)
- packages/api/src/crm/engagement/services/leadsquared/types.ts (1 hunks)
- packages/api/src/crm/task/services/leadsquared/index.ts (1 hunks)
- packages/api/src/crm/task/services/leadsquared/mappers.ts (1 hunks)
- packages/api/src/crm/task/services/leadsquared/types.ts (1 hunks)
- packages/shared/src/connectors/metadata.ts (15 hunks)
Additional context used
Biome
packages/api/src/crm/task/services/leadsquared/index.ts
[error] 23-23: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
packages/api/src/crm/deal/services/leadsquared/index.ts
[error] 23-23: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
packages/api/src/crm/contact/services/leadsquared/index.ts
[error] 27-27: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
packages/api/src/crm/contact/services/leadsquared/mappers.ts
[error] 44-44: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 112-112: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 123-123: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 129-129: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 135-135: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 141-141: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
packages/api/src/crm/engagement/services/leadsquared/index.ts
[error] 31-31: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
Additional comments not posted (14)
packages/api/src/crm/task/services/leadsquared/types.ts (1)
10-30
: Ensure consistency in date formats.The date fields like
DueDate
,CreatedOn
,ModifiedOn
, etc., are represented as strings. Ensure that the date format is consistent across the application and consider using a date library for parsing and formatting.Would you like assistance in implementing a date handling library?
packages/api/src/crm/deal/services/leadsquared/types.ts (1)
22-25
: Ensure required fields are validated.The
LeadSquaredDealInput
type requires at least one unique field inLeadDetails
and theAttribute 'SearchBy'
. Ensure that these requirements are validated in the application logic.Would you like assistance in implementing validation logic?
packages/api/src/crm/deal/services/leadsquared/index.ts (1)
28-83
: Ensure error handling covers all scenarios.The
addDeal
method handles errors usinghandle3rdPartyServiceError
. Ensure that all potential errors, including network issues and invalid responses, are covered.Verify error handling by checking the implementation of
handle3rdPartyServiceError
to ensure comprehensive coverage.packages/api/src/crm/contact/services/leadsquared/index.ts (1)
42-88
: Ensure error handling covers all scenarios.The
addContact
method handles errors usinghandle3rdPartyServiceError
. Ensure that all potential errors, including network issues and invalid responses, are covered.Verify error handling by checking the implementation of
handle3rdPartyServiceError
to ensure comprehensive coverage.Verification successful
Comprehensive Error Handling Verification
The error handling in the
addContact
method is generally robust. Thehandle3rdPartyServiceError
function captures errors and throws aThirdPartyApiServiceError
, which includes the original error as acause
. This approach allows for capturing detailed error information. However, ensure that thecause
property is populated with specific error details to differentiate between various error scenarios effectively.
- The
ThirdPartyApiServiceError
class is implemented inpackages/api/src/@core/utils/errors.ts
.- The
throwTypedError
function logs and throws the error, ensuring that error messages are recorded.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify error handling in `handle3rdPartyServiceError`. # Test: Search for the function implementation. Expect: Comprehensive error handling. ast-grep --lang typescript --pattern $'function handle3rdPartyServiceError($_, $_, $_, $_, $_) { $$$ }'Length of output: 1073
Script:
#!/bin/bash # Description: Verify the implementation of `ThirdPartyApiServiceError` and `throwTypedError`. # Search for the `ThirdPartyApiServiceError` class or function to understand its implementation. ast-grep --lang typescript --pattern $'class ThirdPartyApiServiceError extends $_ { $$$ }' # Search for the `throwTypedError` function to understand its implementation. ast-grep --lang typescript --pattern $'function throwTypedError($_, $_) { $$$ }'Length of output: 1231
packages/api/src/crm/deal/services/leadsquared/mappers.ts (1)
31-110
: Ensure all fields are mapped correctly indesunify
.Verify that all necessary fields from
UnifiedCrmDealInput
are correctly mapped toLeadSquaredDealInput
.Check the mapping logic for completeness and accuracy.
packages/api/src/crm/task/services/leadsquared/mappers.ts (1)
30-91
: Ensure all fields are mapped correctly indesunify
.Verify that all necessary fields from
UnifiedCrmTaskInput
are correctly mapped toLeadSquaredTaskInput
.Check the mapping logic for completeness and accuracy.
packages/api/src/crm/engagement/services/leadsquared/index.ts (2)
36-43
: Ensure date formatting consistency.The
formatDateForLeadSquared
method formats dates in a specific pattern. Ensure that this format is consistent with LeadSquared's API requirements.
173-211
: Validate API response structure.In the
addEmail
method, ensure that the API response structure is validated before accessing nested properties to avoid runtime errors.packages/api/src/crm/engagement/services/leadsquared/mappers.ts (4)
34-41
: Ensure consistency in date formatting.The
formatDateForLeadSquared
method should ensure that the date format aligns with LeadSquared's API requirements.
65-119
: Check for null or undefined values in desunifyEmail.Ensure that values like
source.subject
andsource.content
are not null or undefined before using them. This will prevent potential runtime errors.
271-312
: Ensure all fields are mapped in unifyMeeting.In
unifyMeeting
, ensure that all necessary fields fromLeadSquaredEngagementMeetingOutput
are mapped toUnifiedCrmEngagementOutput
.
314-362
: Ensure all fields are mapped in unifyEmail.In
unifyEmail
, ensure that all necessary fields fromLeadSquaredEngagementEmailOutput
are mapped toUnifiedCrmEngagementOutput
.packages/shared/src/connectors/metadata.ts (2)
372-394
: Verify LeadSquared connector configuration.Ensure that the LeadSquared connector configuration, including URLs and authentication strategy, aligns with the LeadSquared API documentation.
Line range hint
1-1089
: Formatting changes improve readability.The formatting adjustments throughout the file enhance readability and maintain consistency. No issues found.
packages/api/src/crm/engagement/services/leadsquared/mappers.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Files selected for processing (8)
- packages/api/src/crm/contact/services/leadsquared/index.ts (1 hunks)
- packages/api/src/crm/contact/services/leadsquared/types.ts (1 hunks)
- packages/api/src/crm/deal/services/leadsquared/index.ts (1 hunks)
- packages/api/src/crm/deal/services/leadsquared/mappers.ts (1 hunks)
- packages/api/src/crm/deal/services/leadsquared/types.ts (1 hunks)
- packages/api/src/crm/engagement/services/leadsquared/index.ts (1 hunks)
- packages/api/src/crm/engagement/services/leadsquared/mappers.ts (1 hunks)
- packages/api/src/crm/task/services/leadsquared/mappers.ts (1 hunks)
Additional context used
Learnings (3)
packages/api/src/crm/deal/services/leadsquared/types.ts (1)
Learnt from: Iamsidar07 PR: panoratech/Panora#672 File: packages/api/src/crm/engagement/services/leadsquared/types.ts:28-37 Timestamp: 2024-08-21T06:06:23.018Z Learning: The naming conventions for `RecipientType` in the LeadSquared integration should remain as specified in the documentation, even if they appear inconsistent with other naming conventions.
packages/api/src/crm/contact/services/leadsquared/types.ts (1)
Learnt from: Iamsidar07 PR: panoratech/Panora#672 File: packages/api/src/crm/engagement/services/leadsquared/types.ts:28-37 Timestamp: 2024-08-21T06:06:23.018Z Learning: The naming conventions for `RecipientType` in the LeadSquared integration should remain as specified in the documentation, even if they appear inconsistent with other naming conventions.
packages/api/src/crm/engagement/services/leadsquared/index.ts (1)
Learnt from: Iamsidar07 PR: panoratech/Panora#672 File: packages/api/src/crm/engagement/services/leadsquared/types.ts:28-37 Timestamp: 2024-08-21T06:06:23.018Z Learning: The naming conventions for `RecipientType` in the LeadSquared integration should remain as specified in the documentation, even if they appear inconsistent with other naming conventions.
Biome
packages/api/src/crm/deal/services/leadsquared/index.ts
[error] 23-23: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
packages/api/src/crm/contact/services/leadsquared/index.ts
[error] 27-27: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
packages/api/src/crm/engagement/services/leadsquared/index.ts
[error] 31-31: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
Additional comments not posted (40)
packages/api/src/crm/deal/services/leadsquared/types.ts (5)
1-4
: LGTM!The
LeadDetail
type is correctly defined.
6-9
: LGTM!The
Field
type is correctly defined.
11-20
: LGTM!The
Opportunity
type is well-structured and correctly defined.
22-25
: LGTM!The
LeadSquaredDealInput
type is correctly defined, and the comment provides useful information.
27-52
: LGTM!The
LeadSquaredDealOutput
type is comprehensive and correctly defined.packages/api/src/crm/contact/services/leadsquared/types.ts (3)
1-88
: LGTM!The
LeadSquaredContact
type is comprehensive and correctly defined.
99-99
: LGTM!The
LeadSquaredContactInput
type is correctly defined usingPartial
.
100-100
: LGTM!The
LeadSquaredContactOutput
type is correctly defined as equivalent toLeadSquaredContactInput
.packages/api/src/crm/deal/services/leadsquared/index.ts (3)
28-82
: LGTM!The
addDeal
method is well-structured and correctly handles errors.
85-127
: LGTM!The
sync
method is well-structured and correctly handles errors.
22-24
: Use template literals for string concatenation.Consider using template literals for better readability and maintainability.
- this.logger.setContext(CrmObject.deal.toUpperCase() + ':' + LeadSquaredService.name); + this.logger.setContext(`${CrmObject.deal.toUpperCase()}:${LeadSquaredService.name}`);Likely invalid or redundant comment.
Tools
Biome
[error] 23-23: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
packages/api/src/crm/contact/services/leadsquared/index.ts (3)
42-88
: LGTM!The
addContact
method is well-structured and correctly handles errors.
91-148
: LGTM!The
sync
method is well-structured and correctly handles errors.
26-28
: Use template literals for string concatenation.Consider using template literals for better readability and maintainability.
- this.logger.setContext(CrmObject.contact.toUpperCase() + ':' + LeadSquaredService.name); + this.logger.setContext(`${CrmObject.contact.toUpperCase()}:${LeadSquaredService.name}`);Likely invalid or redundant comment.
Tools
Biome
[error] 27-27: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
packages/api/src/crm/deal/services/leadsquared/mappers.ts (4)
12-20
: LGTM!The constructor is straightforward and correctly registers the service.
21-29
: LGTM!The
formatDateForLeadSquared
method is correctly implemented and uses zero-padding for consistency.
31-110
: LGTM!The
desunify
method is well-structured and correctly uses async/await.
112-172
: LGTM!The
unify
method is well-structured and correctly handles arrays and async/await.packages/api/src/crm/task/services/leadsquared/mappers.ts (5)
11-18
: Constructor registration looks good!The constructor correctly registers the service with the
mappersRegistry
.
20-28
: Date formatting is correctly implemented!The function correctly formats the date with zero-padded month and date.
30-90
: Desunify function is well-implemented!The function correctly maps the
UnifiedCrmTaskInput
toLeadSquaredTaskInput
, handling optional fields and ID conversion.
93-114
: Unify function is correctly implemented!The function handles both single and multiple
LeadSquaredTaskOutput
inputs, mapping them toUnifiedCrmTaskOutput
.
116-183
: mapSingleTaskToUnified function looks good!The function correctly maps a single
LeadSquaredTaskOutput
toUnifiedCrmTaskOutput
, handling field mappings and optional fields.packages/api/src/crm/engagement/services/leadsquared/index.ts (8)
36-44
: Date formatting is correctly implemented!The function correctly formats the date with zero-padded month and date.
46-80
: AddEngagement function is well-implemented!The function correctly handles different engagement types and error handling.
82-122
: AddCall function is correctly implemented!The function retrieves connection details, sets headers, and handles errors.
124-171
: AddMeeting function is correctly implemented!The function retrieves connection details, sets headers, and handles errors.
173-212
: AddEmail function is well-implemented!The function retrieves connection details, sets headers, and handles errors.
214-259
: SyncEmails function is correctly implemented!The function retrieves connection details, sets headers, and handles errors.
261-310
: SyncMeetings function is well-implemented!The function retrieves connection details, sets headers, and handles errors.
312-339
: Sync function is correctly implemented!The function handles different engagement types and error handling.
packages/api/src/crm/engagement/services/leadsquared/mappers.ts (9)
20-32
: Constructor registration looks good!The constructor correctly registers the service with the
mappersRegistry
.
34-42
: Date formatting is correctly implemented!The function correctly formats the date with zero-padded month and date.
44-63
: Desunify function is well-implemented!The function correctly maps the
UnifiedCrmEngagementInput
toLeadSquaredEngagementInput
, handling optional fields and ID conversion.
65-118
: DesunifyEmail function is well-implemented!The function correctly maps the
UnifiedCrmEngagementInput
toLeadSquaredEngagementEmailInput
, handling optional fields and ID conversion.
121-187
: DesunifyMeeting function is correctly implemented!The function maps the
UnifiedCrmEngagementInput
toLeadSquaredEngagementMeetingInput
, handling optional fields and ID conversion.
189-239
: DesunifyCall function is well-implemented!The function maps the
UnifiedCrmEngagementInput
toLeadSquaredEngagementCallInput
, handling optional fields and ID conversion.
241-269
: Unify function is correctly implemented!The function maps
LeadSquaredEngagementOutput
toUnifiedCrmEngagementOutput
, handling various engagement types.
271-312
: UnifyMeeting function is well-implemented!The function maps the
LeadSquaredEngagementMeetingOutput
toUnifiedCrmEngagementOutput
, handling field mappings and optional fields.
313-363
: UnifyEmail function is correctly implemented!The function maps the
LeadSquaredEngagementEmailOutput
toUnifiedCrmEngagementOutput
, handling field mappings and optional fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Files selected for processing (1)
- packages/api/src/crm/contact/services/leadsquared/index.ts (1 hunks)
Additional context used
Biome
packages/api/src/crm/contact/services/leadsquared/index.ts
[error] 27-27: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
Additional comments not posted (5)
packages/api/src/crm/contact/services/leadsquared/index.ts (5)
1-16
: Imports look good.The imported modules and services are relevant and necessary for the functionality provided in the file.
20-30
: Constructor is well-structured.The constructor initializes necessary services and sets the logger context. The service registration is also correctly implemented.
Tools
Biome
[error] 27-27: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
32-40
: Date formatting method is correct.The
formatDateForLeadSquared
method correctly formats aDate
object into the required string format.
42-89
: Verify connection object before proceeding.Ensure that the
connection
object is notnull
orundefined
before accessing its properties. This will prevent runtime errors.Consider adding a check like this:
if (!connection) { throw new Error('No connection found for the provided linkedUserId.'); }
91-154
: Sync method is well-structured.The method retrieves recently modified leads and logs the operation. Consider optimizing the mapping logic as suggested in the existing comment.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
fixes #649
Integrated Objects:
Task,
Contacts,
Engagements,
Deal
Summary by CodeRabbit
New Features
Type Definitions
Configuration Updates