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

New Components - lusha #14994

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

New Components - lusha #14994

wants to merge 7 commits into from

Conversation

luancazarine
Copy link
Collaborator

@luancazarine luancazarine commented Dec 16, 2024

Resolves #14992.

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced actions for enriching company and contact information based on IDs.
    • Added a contact search action with various filter options.
    • Enhanced company search functionality with multiple filters.
    • Implemented a new utility function for parsing input objects.
  • Bug Fixes

    • Improved error handling for search actions.
  • Documentation

    • Updated property definitions for enhanced input parameters in the Lusha application.
  • Chores

    • Updated version and dependencies in the package configuration.

@luancazarine luancazarine added the ai-assisted Content generated by AI, with human refinement and modification label Dec 16, 2024
Copy link

vercel bot commented Dec 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Dec 18, 2024 1:30pm
pipedream-docs ⬜️ Ignored (Inspect) Dec 18, 2024 1:30pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Dec 18, 2024 1:30pm

Copy link
Contributor

coderabbitai bot commented Dec 16, 2024

Walkthrough

This pull request introduces comprehensive updates to the Lusha component, adding new actions for company and contact search, enrichment, and related utilities. The changes include creating new modules for searching and enriching companies and contacts, removing legacy find-company and find-contact modules, and enhancing the Lusha application component with expanded property definitions and new API interaction methods. A utility function for parsing objects has also been added to support these new functionalities.

Changes

File Change Summary
components/lusha/actions/company-enrich/company-enrich.mjs New module for enriching company information with requestId and companiesIds properties.
components/lusha/actions/company-search/company-search.mjs New module for searching companies with multiple filter properties like names, domains, locations, etc.
components/lusha/actions/contact-enrich/contact-enrich.mjs New module for enriching contacts with requestId and contactIds properties.
components/lusha/actions/contact-search/contact-search.mjs New module for searching contacts with multiple filter properties.
components/lusha/actions/find-company/find-company.mjs Removed legacy module.
components/lusha/actions/find-contact/find-contact.mjs Removed legacy module.
components/lusha/common/utils.mjs Added parseObject utility function for parsing various input types.
components/lusha/lusha.app.mjs Extensive updates to prop definitions, added new API methods for searching and enriching.
components/lusha/package.json Version bumped to 0.1.0, platform dependency updated.

Assessment against linked issues

Objective Addressed Explanation
Contact Search [#14992]
Company Search [#14992]
Contact Enrich [#14992]
Company Enrich [#14992]

Possibly related PRs

  • New Components - waitlist #12846: The changes in the main PR introduce a new module for enriching company information, which is related to the functionality of searching and enriching data in the company-search module.
  • New Components - peach #12856: The main PR's new action for enriching company data aligns with the contact enrichment functionality in the contact-enrich module, as both involve enriching data based on provided identifiers.
  • New Components - talenthr #14078: The main PR's focus on enriching company information is conceptually related to the employee management features introduced in the talenthr components, as both involve managing and enhancing data related to entities (companies and employees).
  • New Components - flexisign #14552: The main PR's action for enriching company data can be seen as complementary to the actions introduced in the flexisign components, which also involve processing and managing data related to documents and signatures.
  • New Components - zendesk_sell #14583: The main PR's enrichment functionality can be related to the creation of contacts and leads in the zendesk_sell components, as both involve managing and enhancing data related to business entities.

Suggested reviewers

  • michelle0927

Poem

🐰 Hop, hop, hooray! Data's on its way!
Lusha's magic, search and enrich today
Contacts, companies, filters galore
With CodeRabbit's touch, we explore!
APIs dancing, information bright
A rabbit's delight! 🔍✨


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

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

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

CodeRabbit Commands (Invoked using PR comments)

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

Other keywords and placeholders

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

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.

@luancazarine luancazarine marked this pull request as ready for review December 17, 2024 21:03
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 9

🧹 Nitpick comments (1)
components/lusha/actions/company-search/company-search.mjs (1)

1-105: Ensure consistency across search implementations

The company-search and contact-search implementations should follow the same patterns for better maintainability. Consider extracting common functionality into a shared utility.

Create a new utility file components/lusha/common/search.mjs to share common search functionality:

export const createSearchAction = ({
  key,
  name,
  description,
  parseFilters,
  searchFn,
}) => ({
  key,
  name,
  description,
  version: "0.0.1",
  type: "action",
  props: {
    lusha,
    limit: {
      type: "string",
      label: "Limit",
      description: "The maximum number of results to return.",
      validate: (value) => {
        const num = parseInt(value, 10);
        if (isNaN(num) || num <= 0) {
          throw new Error("Limit must be a positive integer");
        }
        return true;
      },
    },
  },
  async run({ $ }) {
    try {
      const filters = parseFilters(this);
      const maxResults = parseInt(this.limit, 10);
      
      const response = this.lusha.paginate({
        $,
        maxResults,
        fn: searchFn,
        data: filters,
      });

      const responseArray = [];
      for await (const item of response) {
        if (responseArray.length >= maxResults) break;
        responseArray.push(item);
      }

      $.export("$summary", `Successfully retrieved ${responseArray.length} results`);
      return responseArray;
    } catch (error) {
      $.export("$summary", "Failed to search");
      throw error;
    }
  },
});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 101db92 and d84ba76.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (9)
  • components/lusha/actions/company-enrich/company-enrich.mjs (1 hunks)
  • components/lusha/actions/company-search/company-search.mjs (1 hunks)
  • components/lusha/actions/contact-enrich/contact-enrich.mjs (1 hunks)
  • components/lusha/actions/contact-search/contact-search.mjs (1 hunks)
  • components/lusha/actions/find-company/find-company.mjs (0 hunks)
  • components/lusha/actions/find-contact/find-contact.mjs (0 hunks)
  • components/lusha/common/utils.mjs (1 hunks)
  • components/lusha/lusha.app.mjs (1 hunks)
  • components/lusha/package.json (2 hunks)
💤 Files with no reviewable changes (2)
  • components/lusha/actions/find-contact/find-contact.mjs
  • components/lusha/actions/find-company/find-company.mjs
🔇 Additional comments (5)
components/lusha/lusha.app.mjs (1)

104-104: Verify the HTTP header for API key

Ensure that the API key is passed in the headers according to the Lusha API requirements. Confirm whether the header should be "api_key" or if it should be "Authorization" with a specific format.

components/lusha/package.json (1)

17-17: Verify compatibility with updated platform dependency

The @pipedream/platform dependency has been updated from ^0.10.0 to ^3.0.3. Ensure that your code is compatible with any changes or breaking changes introduced in the new major version.

components/lusha/common/utils.mjs (1)

1-24: Implementation of parseObject function looks good

The parseObject function is well-written and handles various input types effectively, including arrays and strings with appropriate error handling.

components/lusha/actions/contact-enrich/contact-enrich.mjs (1)

1-37: Overall implementation looks correct

The action for enriching contacts is implemented correctly, utilizing the enrichContacts method and appropriate properties.

components/lusha/actions/company-enrich/company-enrich.mjs (1)

11-18: Validate requestId format

Consider adding a validation pattern for the requestId to ensure it matches the expected format from company search responses.

components/lusha/actions/company-enrich/company-enrich.mjs Outdated Show resolved Hide resolved
components/lusha/actions/contact-enrich/contact-enrich.mjs Outdated Show resolved Hide resolved
components/lusha/actions/contact-enrich/contact-enrich.mjs Outdated Show resolved Hide resolved
components/lusha/lusha.app.mjs Outdated Show resolved Hide resolved
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: 2

♻️ Duplicate comments (1)
components/lusha/actions/company-enrich/company-enrich.mjs (1)

26-36: 🛠️ Refactor suggestion

Add error handling for the API call

The run method should include a try-catch block to handle potential API errors gracefully.

 async run({ $ }) {
+  try {
     const response = await this.lusha.enrichCompanies({
       $,
       data: {
         requestId: this.requestId,
         companiesIds: this.companiesIds,
       },
     });
     $.export("$summary", `Successfully enriched ${this.companiesIds.length} companies`);
     return response;
+  } catch (error) {
+    $.export("$summary", "Failed to enrich companies");
+    throw error;
+  }
 },
🧹 Nitpick comments (3)
components/lusha/lusha.app.mjs (3)

102-106: Enhance API key security

The current implementation exposes the API key in headers without additional security measures.

 _headers() {
   return {
-    "api_key": `${this.$auth.api_key}`,
+    "Authorization": `Bearer ${this.$auth.api_key}`,
+    "Content-Type": "application/json",
   };
 },

82-86: Update requestId property description

The property description should be generic as it's used for both contact and company enrichment.

 requestId: {
   type: "string",
-  label: "Enrich Contact Request ID",
-  description: "The request ID generated from the contact search response.",
+  label: "Request ID",
+  description: "The request ID generated from the search response.",
 },

107-115: Add request timeout and validation

The _makeRequest method should include timeout and basic validation.

 _makeRequest({
   $ = this, path, ...opts
 }) {
+  if (!path) {
+    throw new Error('Path is required for API requests');
+  }
   return axios($, {
     url: `${this._baseUrl()}${path}`,
     headers: this._headers(),
+    timeout: 30000, // 30 seconds timeout
+    validateStatus: (status) => status >= 200 && status < 300,
     ...opts,
   });
 },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d84ba76 and 2933934.

📒 Files selected for processing (3)
  • components/lusha/actions/company-enrich/company-enrich.mjs (1 hunks)
  • components/lusha/actions/contact-enrich/contact-enrich.mjs (1 hunks)
  • components/lusha/lusha.app.mjs (1 hunks)

components/lusha/lusha.app.mjs Show resolved Hide resolved
Copy link
Collaborator

@michelle0927 michelle0927 left a comment

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai-assisted Content generated by AI, with human refinement and modification
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ACTION] Lusha: Prospecting APIs
2 participants