-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
base: master
Are you sure you want to change the base?
New Components - companyhub #16661
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
WalkthroughThis 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
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
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
Assessment against linked issues
Suggested labels
Poem
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
components/companyhub/actions/create-deal/create-deal.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
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: 5
🧹 Nitpick comments (6)
components/companyhub/actions/create-contact/create-contact.mjs (2)
21-26
: Consider adding email validationWhile 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 guidanceThe 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
andnew-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
andresponse.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 whenHasMore
is true butData
is emptyIf the API erroneously returns
HasMore = true
with an emptyData
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
📒 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 appropriateThe 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 goodThe 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-structuredThe 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-definedThe 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 goodThe 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 solidThe 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 contextWhen
$
isn’t explicitly supplied, you default tothis
(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.
Resolves #13300
Summary by CodeRabbit
New Features
Chores