Skip to content

Highlevel Oauth - New Components #16462

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 4 commits into
base: master
Choose a base branch
from
Open

Highlevel Oauth - New Components #16462

wants to merge 4 commits into from

Conversation

michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Apr 28, 2025

Resolves #16290

FYI, the record related components are untested.

Summary by CodeRabbit

  • New Features

    • Introduced actions to create and update custom object records and notes.
    • Added sources to emit events when contacts, notes, or records are updated.
    • Added dynamic option loading for notes, users, objects, and records.
    • Enhanced app capabilities to manage notes, users, custom objects, and records.
  • Bug Fixes

    • Improved handling of empty input values for object parsing.
  • Chores

    • Updated version numbers for several actions and sources.
    • Added a new dependency for hashing functionality.

Copy link

vercel bot commented Apr 28, 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) Apr 28, 2025 3:54pm
pipedream-docs ⬜️ Ignored (Inspect) Apr 28, 2025 3:54pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Apr 28, 2025 3:54pm

Copy link
Contributor

coderabbitai bot commented Apr 28, 2025

Walkthrough

This update introduces several new actions and sources to the HighLevel OAuth integration, including the ability to create and update custom object records, update notes, and detect updates to contacts, notes, and records via polling sources. The HighLevel app module is expanded with new property definitions and API methods to support these features. Several existing actions and sources have their version numbers incremented. Utility functions are improved for safer parsing, and new test event files are added for source testing. The package version is incremented and a new dependency (md5) is added.

Changes

File(s) Change Summary
components/highlevel_oauth/actions/add-contact-to-campaign/add-contact-to-campaign.mjs, components/highlevel_oauth/actions/create-contact/create-contact.mjs, components/highlevel_oauth/actions/update-contact/update-contact.mjs, components/highlevel_oauth/actions/upsert-contact/upsert-contact.mjs, components/highlevel_oauth/sources/new-contact-created/new-contact-created.mjs, components/highlevel_oauth/sources/new-form-submission/new-form-submission.mjs Version numbers incremented; no logic or control flow changes.
components/highlevel_oauth/actions/create-record/create-record.mjs New action: Create custom object record with schemaKey, ownerId, followerIds, and properties.
components/highlevel_oauth/actions/update-note/update-note.mjs New action: Update a note for a contact using contactId, noteId, and body.
components/highlevel_oauth/actions/update-record/update-record.mjs New action: Update a custom object record with schemaKey, recordId, ownerId, followerIds, and properties.
components/highlevel_oauth/common/utils.mjs Improved parseObjectEntries to return undefined for falsy input, preventing unnecessary parsing.
components/highlevel_oauth/highlevel_oauth.app.mjs Added property definitions and API methods for notes, users, objects, records, and CRUD operations.
components/highlevel_oauth/package.json Package version bumped to 0.3.0; added md5 as a dependency.
components/highlevel_oauth/sources/contact-updated/contact-updated.mjs, components/highlevel_oauth/sources/contact-updated/test-event.mjs New source: Contact Updated; emits events on contact updates using hash comparison; added test event.
components/highlevel_oauth/sources/note-updated/note-updated.mjs, components/highlevel_oauth/sources/note-updated/test-event.mjs New source: Note Updated; emits events on note updates using hash comparison; added test event.
components/highlevel_oauth/sources/record-updated/record-updated.mjs New source: Record Updated; emits events on record creation or update using hash comparison.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Action
    participant App
    participant HighLevelAPI

    User->>Action: Trigger (e.g., Create Record, Update Note)
    Action->>App: Call corresponding method (e.g., createRecord, updateNote)
    App->>HighLevelAPI: Make HTTP request (POST/PUT)
    HighLevelAPI-->>App: Respond with result
    App-->>Action: Return response
    Action-->>User: Output result/summary
Loading
sequenceDiagram
    participant Source (Polling)
    participant App
    participant HighLevelAPI
    participant Store

    loop On schedule
        Source->>App: Fetch entities (contacts, notes, records)
        App->>HighLevelAPI: GET/POST for entities
        HighLevelAPI-->>App: Return entities
        App-->>Source: Return data
        Source->>Store: Retrieve previous hashes
        Source->>Source: Compare hashes for changes
        alt If change detected
            Source->>User: Emit event with metadata
        end
        Source->>Store: Update hashes
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Implement HighLevel triggers: Contact Updated, Notes Updated, Records created or updated (#16290)
Implement HighLevel actions: Contact Updated, Notes Updated, Records created or updated (#16290)

Possibly related PRs

Suggested labels

User submitted

Poem

In the land of HighLevel, new features abound,
Records and notes now easily found.
With hashes and triggers, events leap and hop,
Actions for contacts—no reason to stop!
Version bumps here, new sources appear,
This rabbit is thrilled—let’s give a big cheer!
🐇✨

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/highlevel_oauth/actions/add-contact-to-campaign/add-contact-to-campaign.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)

components/highlevel_oauth/actions/create-contact/create-contact.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)

components/highlevel_oauth/actions/create-record/create-record.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)

  • 13 others
✨ 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.
    • 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.
  • @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.

@michelle0927 michelle0927 marked this pull request as ready for review April 28, 2025 16:06
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: 7

🧹 Nitpick comments (8)
components/highlevel_oauth/sources/note-updated/note-updated.mjs (2)

39-61: Improve the update detection logic

The current implementation detects updates by comparing MD5 hashes of the entire note object, which works but has limitations.

Consider enhancing the update detection to be more specific:

  1. Only calculate hash on relevant fields that indicate an update (like body, updatedAt)
  2. Add a debug log to show which notes were updated and what changed
- const hash = md5(JSON.stringify(note));
+ // Only hash the relevant fields to detect meaningful updates
+ const hashData = {
+   body: note.body,
+   updatedAt: note.updatedAt,
+ };
+ const hash = md5(JSON.stringify(hashData));

  if (noteValues[note.id] && noteValues[note.id] !== hash) {
+   console.log(`Note ${note.id} was updated`);
    results.push(note);
  }

This would make the update detection more precise and easier to debug.


23-38: Add protection against undefined DB values

The method for getting note values doesn't protect against the possibility of the DB not being initialized yet.

Consider adding a default parameter to ensure _getNoteValues always returns an object:

_getNoteValues() {
-  return this.db.get("noteValues") || {};
+  return this.db.get("noteValues") ?? {};
}

Using the nullish coalescing operator (??) is slightly better than || as it only returns the right-hand side when the left is null or undefined, not any falsy value.

components/highlevel_oauth/sources/contact-updated/contact-updated.mjs (2)

7-9: Update source name to follow component guidelines.

According to Pipedream's component guidelines, source names should start with "New". Consider renaming from "Contact Updated" to "New Contact Updated" to comply with the guidelines.

-  name: "Contact Updated",
+  name: "New Contact Updated",
🧰 Tools
🪛 GitHub Check: Lint Code Base

[warning] 8-8:
Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name


24-26: Enhance ID uniqueness for better deduplication.

The current ID generation uses contact ID + timestamp. While this works for deduplication within a single run, it might be better to include more context for better debugging and traceability.

      return {
-        id: `${contact.id}${ts}`,
+        id: `${contact.id}-${ts}`,
        summary: `Contact Updated w/ ID: ${contact.id}`,
        ts,
      };
components/highlevel_oauth/sources/record-updated/record-updated.mjs (2)

7-9: Update source name to follow component guidelines.

According to Pipedream's component guidelines, source names should start with "New". Consider renaming from "Record Updated" to "New Record Updated" to comply with the guidelines.

-  name: "Record Updated",
+  name: "New Record Updated",
🧰 Tools
🪛 GitHub Check: Lint Code Base

[warning] 7-7:
Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name


32-35: Enhance ID uniqueness for better deduplication.

The current ID generation uses record ID + timestamp. While this works for deduplication within a single run, it might be better to include more context for better debugging and traceability.

      return {
-        id: `${record.id}${ts}`,
+        id: `${record.id}-${ts}`,
        summary: `Record ${createdOrUpdated} w/ ID: ${record.id}`,
        ts,
      };
components/highlevel_oauth/highlevel_oauth.app.mjs (2)

56-65: Enhance note options with more context for better selection.

The current implementation displays only the first 50 characters of the note body as the label, which might not provide enough context for users to select the correct note, especially if notes have similar beginnings.

        return notes?.map(({
-          id: value, body,
+          id: value, body, createdAt,
        }) => ({
-          label: body.slice(0, 50),
+          label: `${body.slice(0, 40)}... (${new Date(createdAt).toLocaleString() || 'No date'})`,
          value,
        })) || [];

121-126: Enhance properties documentation with schema reference.

The current description provides an example but lacks information about what properties are available or required for different schema types. Consider adding a reference to how users can discover the expected properties for their specific schema.

    properties: {
      type: "object",
      label: "Properties",
-      description: "Properties of the record as key/value pairs. Example: `{\"customer_number\":1424,\"ticket_name\":\"Customer not able login\",\"phone_number\":\"+917000000000\"}`",
+      description: "Properties of the record as key/value pairs. The available properties depend on the selected Object Schema. You can view required and optional properties in the HighLevel UI under Settings > Custom Objects. Example: `{\"customer_number\":1424,\"ticket_name\":\"Customer not able login\",\"phone_number\":\"+917000000000\"}`",
      optional: true,
    },
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1d7ea34 and 7288b0c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (17)
  • components/highlevel_oauth/actions/add-contact-to-campaign/add-contact-to-campaign.mjs (1 hunks)
  • components/highlevel_oauth/actions/create-contact/create-contact.mjs (1 hunks)
  • components/highlevel_oauth/actions/create-record/create-record.mjs (1 hunks)
  • components/highlevel_oauth/actions/update-contact/update-contact.mjs (1 hunks)
  • components/highlevel_oauth/actions/update-note/update-note.mjs (1 hunks)
  • components/highlevel_oauth/actions/update-record/update-record.mjs (1 hunks)
  • components/highlevel_oauth/actions/upsert-contact/upsert-contact.mjs (1 hunks)
  • components/highlevel_oauth/common/utils.mjs (1 hunks)
  • components/highlevel_oauth/highlevel_oauth.app.mjs (3 hunks)
  • components/highlevel_oauth/package.json (2 hunks)
  • components/highlevel_oauth/sources/contact-updated/contact-updated.mjs (1 hunks)
  • components/highlevel_oauth/sources/contact-updated/test-event.mjs (1 hunks)
  • components/highlevel_oauth/sources/new-contact-created/new-contact-created.mjs (1 hunks)
  • components/highlevel_oauth/sources/new-form-submission/new-form-submission.mjs (1 hunks)
  • components/highlevel_oauth/sources/note-updated/note-updated.mjs (1 hunks)
  • components/highlevel_oauth/sources/note-updated/test-event.mjs (1 hunks)
  • components/highlevel_oauth/sources/record-updated/record-updated.mjs (1 hunks)
🧰 Additional context used
🪛 GitHub Check: Lint Code Base
components/highlevel_oauth/sources/contact-updated/contact-updated.mjs

[warning] 8-8:
Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name

components/highlevel_oauth/sources/record-updated/record-updated.mjs

[warning] 7-7:
Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name

components/highlevel_oauth/sources/note-updated/note-updated.mjs

[warning] 8-8:
Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: pnpm publish
🔇 Additional comments (11)
components/highlevel_oauth/sources/note-updated/test-event.mjs (1)

1-9: Approve test-event schema for Note Updated source.
The exported sample event includes all required fields (id, body, userId, dateAdded, contactId, businessId, relations) and follows the expected structure for the polling source.

components/highlevel_oauth/sources/contact-updated/test-event.mjs (1)

1-41: Approve test-event schema for Contact Updated source.
The sample event covers a comprehensive set of contact attributes and metadata, matching the contract used by the contact-updated source component.

components/highlevel_oauth/package.json (1)

3-4: Verify package version and new dependency.
Version bump to 0.3.0 and addition of md5@^2.3.0 look correct. Please confirm that all new source modules import and utilize md5, and that this dependency upgrade does not introduce compatibility issues.

Also applies to: 16-17

components/highlevel_oauth/actions/update-contact/update-contact.mjs (1)

14-14: Approve version bump for Update Contact action.
The version has been updated from 0.0.2 to 0.0.3 without changes to the logic. This aligns with the coordinated release versioning.

components/highlevel_oauth/sources/new-contact-created/new-contact-created.mjs (1)

9-9: Approve version bump for New Contact Created source.
Updated version from 0.0.1 to 0.0.2, consistent with other source component releases.

components/highlevel_oauth/actions/create-contact/create-contact.mjs (1)

14-14: Version bump looks good.

The increment from "0.0.3" is consistent with the version updates in other contact-related actions in this PR. This coordination helps maintain version alignment across the HighLevel OAuth integration components.

components/highlevel_oauth/actions/add-contact-to-campaign/add-contact-to-campaign.mjs (1)

8-8: Version bump is appropriate.

The increment from "0.0.1" to "0.0.2" aligns with the version updates across other HighLevel OAuth components in this PR, maintaining consistent versioning throughout the integration.

components/highlevel_oauth/actions/upsert-contact/upsert-contact.mjs (1)

14-14: Version update is consistent with related components.

The version increment to "0.0.3" maintains consistency with other contact management actions in this PR (like create-contact.mjs), ensuring synchronized versioning across the HighLevel OAuth integration.

components/highlevel_oauth/sources/new-form-submission/new-form-submission.mjs (1)

9-9: Version increment is appropriate.

The version update from "0.0.1" to "0.0.2" is in line with the versioning strategy across the HighLevel OAuth integration. This source component's version is appropriately incremented as part of the broader enhancement to the component suite.

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

10-12: Good defensive programming enhancement.

Adding an early return for falsy values is an excellent improvement that prevents potential errors when parsing null or undefined inputs. This makes the utility function more robust when handling optional fields like properties in the newly added record management actions.

This change follows best practices for error handling in API integrations where input data quality can vary. It ensures the function gracefully handles edge cases rather than attempting to parse invalid inputs.

components/highlevel_oauth/actions/update-note/update-note.mjs (1)

1-46: Clean implementation for note updates

The action component is well-structured and follows the common pattern. The dynamic filtering of noteId options based on contactId is a good UX enhancement.

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.

[TRIGGER] Highlevel Triggers
2 participants