Skip to content

New Components - companyhub #16661

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

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

New Components - companyhub #16661

wants to merge 2 commits into from

Conversation

michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented May 14, 2025

Resolves #13300

Summary by CodeRabbit

  • New Features

    • Added actions to create companies, contacts, and deals within the CompanyHub integration.
    • Introduced event sources to emit notifications when new companies, deals, or custom records are created in CompanyHub.
    • Enhanced selection options for company and contact fields with dynamic loading.
    • Included sample event data for easier setup and testing of new event sources.
  • Chores

    • Updated the CompanyHub integration version to 0.7.0.

Copy link

vercel bot commented May 14, 2025

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 May 14, 2025 5:21pm
pipedream-docs ⬜️ Ignored (Inspect) May 14, 2025 5:21pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) May 14, 2025 5:21pm

Copy link
Contributor

coderabbitai bot commented May 14, 2025

Walkthrough

This update introduces a new integration for CompanyHub, adding comprehensive support for creating companies, contacts, and deals, as well as polling sources for new companies, deals, and custom records. It implements reusable base logic, prop definitions, paginated API methods, and sample event data for testing.

Changes

Files/Groups Change Summary
components/companyhub/actions/create-company/create-company.mjs Added a new action to create a company, accepting company details and address fields, and calling the CompanyHub API.
components/companyhub/actions/create-contact/create-contact.mjs Added a new action to create a contact, accepting personal, company, and address details, and calling the CompanyHub API.
components/companyhub/actions/create-deal/create-deal.mjs Added a new action to create a deal, accepting deal name, stage, company, contact, amount, and close date, and calling the CompanyHub API.
components/companyhub/companyhub.app.mjs Implemented the CompanyHub app integration, including prop definitions, paginated option loaders, generic request logic, CRUD methods for companies, deals, and contacts, and a pagination generator.
components/companyhub/package.json Bumped the package version from 0.6.0 to 0.7.0.
components/companyhub/sources/common/base.mjs Added a reusable base source module for polling CompanyHub resources, including methods for timestamp tracking, event processing, and lifecycle hooks.
components/companyhub/sources/new-company-created/new-company-created.mjs Added a polling source for new companies, extending the base source, and providing company-specific summary and resource methods.
components/companyhub/sources/new-company-created/test-event.mjs Added a test event fixture representing a newly created company.
components/companyhub/sources/new-deal-created/new-deal-created.mjs Added a polling source for new deals, extending the base source, and providing deal-specific summary and resource methods.
components/companyhub/sources/new-deal-created/test-event.mjs Added a test event fixture representing a newly created deal.
components/companyhub/sources/new-record-created/new-record-created.mjs Added a polling source for new records in a custom table, extending the base source, and accepting a table name prop.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Action
    participant CompanyHubApp
    participant CompanyHubAPI

    User->>Action: Provide input data
    Action->>CompanyHubApp: Call createCompany/createDeal/createContact
    CompanyHubApp->>CompanyHubAPI: Send POST request with data
    CompanyHubAPI-->>CompanyHubApp: Return response
    CompanyHubApp-->>Action: Return result
    Action-->>User: Output summary and API response
Loading
sequenceDiagram
    participant Source
    participant CompanyHubApp
    participant CompanyHubAPI
    participant DB

    Source->>DB: Get last processed timestamp
    loop Until no more new items
        Source->>CompanyHubApp: Call listCompanies/listDeals/listRecords
        CompanyHubApp->>CompanyHubAPI: Fetch paginated data
        CompanyHubAPI-->>CompanyHubApp: Return items
        CompanyHubApp-->>Source: Return items
        Source->>DB: Update last processed timestamp (if new items)
        Source-->>Source: Emit new events
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Polling sources: new-company, new-deal, new-record (no props except table for new-record) (#13300)
Actions: create-company (required: name, address, phone; optional: fax, website, email) (#13300) Fax and email are not present as props in create-company action; address fields are included but email/fax missing.
Actions: create-deal (required: name, value, company; optional: close date, owner, stage) (#13300) Owner is not present as a prop; amount (value) is optional; stage is included as optional with options.
Actions: create-contact (required: name, company, email; optional: phone, job title, address) (#13300) Email is optional (not required); job title (designation) is present; required email missing.

Suggested labels

ai-assisted

Poem

A hop and a leap, new code in the field,
CompanyHub’s secrets, now fully revealed!
Companies, deals, and contacts galore,
With polling and actions, integrations soar.
The rabbit approves, with a twitch of his nose—
0.7.0 hops in, and onward it goes!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

components/companyhub/actions/create-deal/create-deal.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between dc5d12e and 45b5465.

📒 Files selected for processing (1)
  • components/companyhub/actions/create-deal/create-deal.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/companyhub/actions/create-deal/create-deal.mjs
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Lint Code Base
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

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

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

🧹 Nitpick comments (6)
components/companyhub/actions/create-contact/create-contact.mjs (2)

21-26: Consider adding email validation

While the email field is optional, it might be helpful to add validation to ensure it follows a valid email format when provided.


63-68: Enhance date format guidance

The nextFollowUpDate field requires a specific format (as shown in the example), but there's no validation to ensure users provide dates in the correct format.

Consider adding more explicit format validation or updating the description to emphasize the required format more clearly.

components/companyhub/sources/new-record-created/new-record-created.mjs (1)

1-33: Consider adding a sample emit for testing.

The component is well structured but missing a sampleEmit property which is present in the other source components (new-deal-created.mjs and new-company-created.mjs). This could impact the ability to preview example events in the UI or in testing.

import common from "../common/base.mjs";
+import sampleEmit from "./test-event.mjs";

export default {
  ...common,
  key: "companyhub-new-record-created",
  // ...other properties...
  methods: {
    // ...methods...
  },
+  sampleEmit,
};
components/companyhub/actions/create-deal/create-deal.mjs (1)

55-71: Consider validating the response shape.

The code assumes that response.Success and response.Id will be present in the response. Consider adding additional validation or error handling if these fields might not be present.

components/companyhub/companyhub.app.mjs (1)

126-137: Potential infinite loop when HasMore is true but Data is empty

If the API erroneously returns HasMore = true with an empty Data array, paginate loops forever. Add a guard:

-        for (const item of response.Data) {
+        if (!response.Data?.length) break;
+        for (const item of response.Data) {

This protects the polling sources from runaway execution.

components/companyhub/sources/common/base.mjs (1)

61-62: lastTs should store the newest timestamp, not the first item in API order

items[0] represents the most recent record only if the API returns results in descending order. If the API ever switches to ascending order, you’d persist the oldest timestamp and re-emit duplicates.

Safer:

-this._setLastTs(Date.parse(items[0][tsField]));
+const newestTs = Math.max(...items.map(i => Date.parse(i[tsField])));
+this._setLastTs(newestTs);

This is order-agnostic.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cbe2297 and dc5d12e.

📒 Files selected for processing (11)
  • components/companyhub/actions/create-company/create-company.mjs (1 hunks)
  • components/companyhub/actions/create-contact/create-contact.mjs (1 hunks)
  • components/companyhub/actions/create-deal/create-deal.mjs (1 hunks)
  • components/companyhub/companyhub.app.mjs (1 hunks)
  • components/companyhub/package.json (1 hunks)
  • components/companyhub/sources/common/base.mjs (1 hunks)
  • components/companyhub/sources/new-company-created/new-company-created.mjs (1 hunks)
  • components/companyhub/sources/new-company-created/test-event.mjs (1 hunks)
  • components/companyhub/sources/new-deal-created/new-deal-created.mjs (1 hunks)
  • components/companyhub/sources/new-deal-created/test-event.mjs (1 hunks)
  • components/companyhub/sources/new-record-created/new-record-created.mjs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: pnpm publish
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Lint Code Base
🔇 Additional comments (10)
components/companyhub/package.json (1)

3-3: Version bump is appropriate

The version increment from 0.6.0 to 0.7.0 correctly follows semantic versioning for the addition of new features (new actions and sources for CompanyHub).

components/companyhub/sources/new-company-created/test-event.mjs (1)

1-36: Test event data looks good

The structure provides appropriate sample data for a company object with all necessary fields. The dates are set to 2025, which is fine for sample data to avoid expiration in examples.

components/companyhub/sources/new-deal-created/test-event.mjs (1)

1-35: Test event data is well-structured

The sample deal object contains realistic values and all necessary fields for testing the source component. The "Closed Won" stage and $10,000 amount provide clear, illustrative examples.

components/companyhub/actions/create-contact/create-contact.mjs (3)

3-8: Component metadata is well-defined

The component key, name, description, and version are appropriately set. The documentation link is included and the initial version is correctly set to 0.0.1.


51-62: Source options look good

The predefined options for the contact source field provide good guidance to users while maintaining flexibility with the "Other" option.


106-131: Run method implementation is solid

The implementation correctly maps component props to API fields and handles the response appropriately. The summary message provides clear feedback about the created contact.

components/companyhub/sources/new-deal-created/new-deal-created.mjs (1)

1-22: LGTM! Well-structured component for New Deal events.

The component properly extends the common base, specifies the correct resource function, and provides a sensible summary method. The inclusion of a sample emit is good for testing.

components/companyhub/sources/new-company-created/new-company-created.mjs (1)

1-22: LGTM! Well-structured component for New Company events.

The component properly extends the common base, specifies the correct resource function, and provides a sensible summary method. The inclusion of a sample emit is good for testing.

components/companyhub/actions/create-deal/create-deal.mjs (1)

3-72: Well-structured action component with good props definition.

The component defines a comprehensive set of properties for creating a deal, including both required and optional fields with good descriptions and appropriate types.

components/companyhub/companyhub.app.mjs (1)

52-67: _makeRequest may log against the wrong step context

When $ isn’t explicitly supplied, you default to this (the app object).
@pipedream/platform/axios expects the component (action/source) context to enable logging, retries, etc. Passing the app object loses that context and can break log output.

Consider:

-async _makeRequest({ $ = this, path, ...otherOpts }) {
+async _makeRequest({ $, path, ...otherOpts }) {
+  // fall back to the calling component (`this.$`) if no `$` passed
+  if (!$ && this.$) $ = this.$;
+  if (!$) throw new Error("Step context `$` is required");

Or enforce $ as a required argument from every caller.

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.

[Components] companyhub
1 participant