Panora icon indicating copy to clipboard operation
Panora copied to clipboard

Add Affinity CRM

Open mit-27 opened this issue 1 year ago • 6 comments

Objects

Third party object Name -> Unified Object

  • [x] Person -> Contact
  • [x] Organization -> Company
  • [x] Opportunity -> Deal
  • [x] Note -> Note
  • [x] User

closes #448

/claim #448

Summary by CodeRabbit

  • New Features

    • Introduced the AffinityService for managing company, contact, deal, note, and user data integration with the Affinity CRM system.
    • Added methods for adding and synchronizing companies, contacts, deals, notes, and users.
    • Implemented data mapping capabilities through new mapper classes for companies, contacts, deals, and notes.
    • Expanded the available CRM connectors to include Affinity.
  • Enhancements

    • Extended existing data types to include new Affinity variants for better integration with the Affinity service.
    • Added a new column crm_affinity to the connector_sets table for improved CRM integration capabilities.
  • Bug Fixes

    • Improved error handling during API interactions for better reliability and traceability.
  • Documentation

    • Updated type definitions and interfaces to enhance clarity and maintainability.

mit-27 avatar Jun 14 '24 10:06 mit-27

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 :robot:. Below, a word from its wisdom :

Don’t Sacrifice Readability, you are going to debug it in 6 months

rflihxyz avatar Jun 14 '24 10:06 rflihxyz

⚠️ No Changeset found

Latest commit: 9cbd82316ae922818d58667c338421e235229f63

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

changeset-bot[bot] avatar Jun 14 '24 10:06 changeset-bot[bot]

@mit-27 is attempting to deploy a commit to the Panora Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Jun 14 '24 10:06 vercel[bot]

Walkthrough

Walkthrough

The changes introduce a comprehensive integration with the Affinity CRM system, adding new services, mappers, and data types for managing contacts, deals, companies, notes, and users. This integration enhances the CRM's ability to interact with Affinity's API, allowing for the addition and synchronization of various entities while maintaining backward compatibility with existing functionalities.

Changes

Files Change Summary
packages/api/src/@core/utils/types/original/original.crm.ts Added new input and output types prefixed with "Affinity" for contacts, deals, companies, engagements, notes, and users.
packages/api/src/crm/company/company.module.ts, packages/api/src/crm/contact/contact.module.ts, packages/api/src/crm/deal/deal.module.ts, packages/api/src/crm/note/note.module.ts, packages/api/src/crm/user/user.module.ts Added AffinityService and related mappers to the list of providers and exports in respective module files.
packages/api/scripts/init.sql, packages/api/scripts/seed.sql Introduced a new column crm_affinity to the connector_sets table and modified the seed script to accommodate this new column.
packages/shared/src/connectors/enum.ts Added AFFINITY to the CrmConnectors enum to support integration with the Affinity platform.

Assessment against linked issues

Objective Addressed Explanation
Add integration with Affinity (CRM) (#448)
Manage contacts through Affinity API (#448)
Manage deals through Affinity API (#448)
Manage companies through Affinity API (#448)
Manage notes through Affinity API (#448)

Possibly related PRs

  • #484: The changes in this PR involve adding new types and integrations related to the "Close" CRM, which includes modifications to the original.crm.ts file, similar to the main PR's focus on enhancing type definitions for "Affinity" entities in the same file.
  • #482: This PR includes changes to the original.crm.ts file, which may relate to the type definitions and structures being modified in the main PR, indicating a potential overlap in the type system enhancements for CRM integrations.

[!TIP]

OpenAI O1 model for chat
  • We have deployed OpenAI's latest O1 model for chat.
  • OpenAI claims that this model has superior reasoning capabilities than their GPT-4o model.
  • Please share any feedback with us in the discussions post.

Recent review details

Configuration used: CodeRabbit UI Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 5a6090301dfb86467fcdd1c7afad6a7ee4fa33e6 and 9cbd82316ae922818d58667c338421e235229f63.

Files selected for processing (8)
  • packages/api/scripts/init.sql (1 hunks)
  • packages/api/scripts/seed.sql (1 hunks)
  • packages/api/src/@core/utils/types/original/original.crm.ts (11 hunks)
  • packages/api/src/crm/company/company.module.ts (3 hunks)
  • packages/api/src/crm/contact/contact.module.ts (2 hunks)
  • packages/api/src/crm/deal/deal.module.ts (2 hunks)
  • packages/api/src/crm/note/note.module.ts (2 hunks)
  • packages/shared/src/connectors/enum.ts (1 hunks)
Additional comments not posted (24)
packages/shared/src/connectors/enum.ts (1)

9-9: LGTM!

The addition of the AFFINITY entry to the CrmConnectors enum is a valid and consistent change. It expands the set of available CRM connectors without affecting the functionality of other connectors. The naming convention and enum structure remain intact.

packages/api/scripts/seed.sql (2)

5-8: LGTM!

The changes to the INSERT INTO connector_sets statement are consistent with the addition of the new crm_affinity column. The values being inserted for the new column are set to TRUE for all rows, which seems appropriate. The modified statement has no syntax errors or logical issues.


5-5: Verify the schema change.

The addition of the crm_affinity column to the connector_sets table is necessary to match the values being inserted. The column name suggests that it is related to the Affinity CRM integration, which aligns with the PR objectives.

To ensure the schema change has been properly applied, please run the following script:

Verification successful

Schema change verified successfully.

The crm_affinity column has been properly added to the connector_sets table. This change is reflected in both the table definition and the insert statement:

  • The column is defined in packages/api/scripts/init.sql as crm_affinity boolean NULL,.
  • It's included in the INSERT INTO statement in packages/api/scripts/seed.sql.

The schema change has been implemented correctly and consistently across the SQL files.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the `crm_affinity` column in the `connector_sets` table.

# Test: Check if the `crm_affinity` column exists in the `connector_sets` table.
# Expect: The column should be present in the table schema.
echo "SELECT column_name FROM information_schema.columns WHERE table_name='connector_sets' AND column_name='crm_affinity';" | psql <database_name>

Length of output: 289


Script:

#!/bin/bash
# Search for the connector_sets table definition in SQL files
rg -t sql "CREATE TABLE.*connector_sets" -A 50

# Search for any ALTER TABLE statements that might have added the crm_affinity column
rg -t sql "ALTER TABLE.*connector_sets.*ADD.*crm_affinity"

# Search for INSERT statements into connector_sets that include crm_affinity
rg -t sql "INSERT INTO connector_sets.*crm_affinity"

Length of output: 3954

packages/api/src/crm/note/note.module.ts (2)

25-26: LGTM!

The imports for AffinityNoteMapper and AffinityService are correctly added, which is a necessary step for integrating with Affinity CRM.


54-55: LGTM!

The AffinityService and AffinityNoteMapper are correctly added to the providers array, making them available for dependency injection within the NoteModule. This is consistent with the imports and necessary for integrating with Affinity CRM.

packages/api/src/crm/deal/deal.module.ts (2)

25-26: LGTM!

The imports for AffinityDealMapper and AffinityService are correctly placed and follow the existing import structure. They suggest a new integration with Affinity CRM is being added.


55-56: LGTM!

Adding the AffinityService and AffinityDealMapper to the list of providers is a necessary step for integrating the Affinity CRM functionality into the existing system. The providers are correctly added and follow the existing structure.

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

25-26: LGTM!

The imports for AffinityCompanyMapper and AffinityService are correctly specified and follow the existing import pattern in the file. They are necessary for integrating the Affinity CRM functionality into the module.


56-57: Looks good!

Adding AffinityService and AffinityCompanyMapper to the list of providers in the module is necessary for making them available for dependency injection. The additions follow the existing pattern of providing services and mappers for other CRM platforms and are consistent with the import statements and the overall module structure.

packages/api/src/crm/contact/contact.module.ts (2)

26-27: LGTM!

The imports for AffinityContactMapper and AffinityService are correctly specified and follow the existing import pattern in the file.


57-58: LGTM!

The addition of AffinityService and AffinityContactMapper to the providers array is consistent with the existing pattern in the module and indicates that the ContactModule is being extended to support integration with the Affinity CRM system.

The AffinityService is likely responsible for interacting with the Affinity API, while the AffinityContactMapper is likely responsible for mapping Affinity contact data to the internal contact data structure.

packages/api/src/@core/utils/types/original/original.crm.ts (12)

2-6: LGTM!

The imports for the new "Affinity" related types are correctly structured and follow the existing pattern. The imported types are used later in the file to expand the existing type unions.


173-179: Looks good!

The addition of AffinityCompanyInput and CloseContactInput types to the OriginalContactInput union type is consistent with the overall pattern of the file. This change expands the union to accommodate new input types related to "Affinity" and "Close" CRM systems without introducing any type mismatches or conflicts.


185-191: Approved.

The addition of AffinityDealInput type to the OriginalDealInput union type is consistent with the overall pattern of the file. This change expands the union to accommodate new input type related to "Affinity" CRM system without introducing any type mismatches or conflicts.


Line range hint 197-203: Change looks good.

The addition of AffinityCompanyInput type to the OriginalCompanyInput union type is consistent with the overall pattern of the file. This change expands the union to accommodate new input type related to "Affinity" CRM system without introducing any type mismatches or conflicts.


Line range hint 215-222: Looks good to me.

The addition of AffinityNoteInput type to the OriginalNoteInput union type is consistent with the overall pattern of the file. This change expands the union to accommodate new input type related to "Affinity" CRM system without introducing any type mismatches or conflicts.


230-231: LGTM.

The addition of AttioTaskInput type to the OriginalTaskInput union type is consistent with the overall pattern of the file. This change expands the union to accommodate new input type related to "Attio" CRM system without introducing any type mismatches or conflicts.


244-249: Approved.

The addition of AffinityUserInput type to the OriginalUserInput union type is consistent with the overall pattern of the file. This change expands the union to accommodate new input type related to "Affinity" CRM system without introducing any type mismatches or conflicts.


Line range hint 264-270: Looks good.

The addition of AffinityContactInput type to the OriginalContactOutput union type is consistent with the overall pattern of the file. This change expands the union to accommodate new output type related to "Affinity" CRM system without introducing any type mismatches or conflicts.


Line range hint 274-280: Change looks good.

The addition of AffinityDealOutput type to the OriginalDealOutput union type is consistent with the overall pattern of the file. This change expands the union to accommodate new output type related to "Affinity" CRM system without introducing any type mismatches or conflicts.


Line range hint 284-290: LGTM.

The addition of AffinityCompanyOutput type to the OriginalCompanyOutput union type is consistent with the overall pattern of the file. This change expands the union to accommodate new output type related to "Affinity" CRM system without introducing any type mismatches or conflicts.


302-308: Approved.

The addition of AffinityNoteOutput type to the OriginalNoteOutput union type is consistent with the overall pattern of the file. This change expands the union to accommodate new output type related to "Affinity" CRM system without introducing any type mismatches or conflicts.


331-337: Looks good to me.

The addition of AffinityUserOutput type to the OriginalUserOutput union type is consistent with the overall pattern of the file. This change expands the union to accommodate new output type related to "Affinity" CRM system without introducing any type mismatches or conflicts.

packages/api/scripts/init.sql (1)

559-559: LGTM!

The new crm_affinity column is appropriately named and typed. Allowing NULL values provides flexibility.


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 using PR comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

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.

coderabbitai[bot] avatar Jun 14 '24 10:06 coderabbitai[bot]

Hello @naelob and @rflihxyz, I cannot sign in to Affinity CRM (Every time I try to log in it always sends me a 'request to demo' link not the sign-in link ). Can I get credentials so I can test the connector?

mit-27 avatar Jun 19 '24 21:06 mit-27

⚠️ GitGuardian has uncovered 1 secret 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.

Since your pull request originates from a forked repository, GitGuardian is not able to associate the secrets uncovered with secret incidents on your GitGuardian dashboard. Skipping this check run and merging your pull request will create secret incidents on your GitGuardian dashboard.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
9198067 Triggered Generic Password 5a6090301dfb86467fcdd1c7afad6a7ee4fa33e6 .env.example 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 secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  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.

gitguardian[bot] avatar Sep 14 '24 00:09 gitguardian[bot]