Skip to content

Conversation

@michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Sep 3, 2025

Resolves #17906

Summary by CodeRabbit

  • New Features

    • Added Lawmatics “Create Contact” and “Update Contact” actions.
    • Added “New Contact Added” source to emit events for newly created contacts (with initial deploy seeding).
    • Enhanced integration: selectable contact fields, contact picker, improved pagination, and notes parsing for richer payloads.
  • Chores

    • Bumped Lawmatics package to 0.7.0 and updated platform dependency.

@vercel
Copy link

vercel bot commented Sep 3, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
pipedream-docs Ignored Ignored Sep 4, 2025 2:31pm
pipedream-docs-redirect-do-not-edit Ignored Ignored Sep 4, 2025 2:31pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 3, 2025

Walkthrough

Adds Lawmatics integration: create/update contact actions, a poll-based "new contact added" source, a parseObject utility, expanded app propDefinitions and HTTP helper methods (including pagination), and a package version/dependency bump.

Changes

Cohort / File(s) Summary
Lawmatics App integration
components/lawmatics/lawmatics.app.mjs
Adds propDefinitions for contact fields, async options for contacts, axios import, centralized _makeRequest with Authorization, CRUD methods (listContacts, createContact, updateContact), and an async generator paginate; removes authKeys().
Actions: Contacts
components/lawmatics/actions/create-contact/create-contact.mjs, components/lawmatics/actions/update-contact/update-contact.mjs
New Create Contact and Update Contact action modules. Both use app propDefinitions, call app.createContact/updateContact, parse notes via parseObject, set run summaries, and return API response data.
Source: New Contact Added
components/lawmatics/sources/new-contact-added/new-contact-added.mjs
New polling source that paginates listContacts, emits newly created contacts using persisted lastTs, seeds initial events on deploy, and runs on timer.
Common Utils
components/lawmatics/common/utils.mjs
Adds parseObject(obj) to recursively parse JSON strings in strings/arrays/objects, returning undefined for falsy inputs.
Package metadata
components/lawmatics/package.json
Bumps package version to 0.7.0 and updates @pipedream/platform dependency to ^3.1.0.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant CreateAction as Action: Create Contact
  participant App as Lawmatics App
  participant API as Lawmatics API

  User->>CreateAction: Provide firstName, lastName, email, phone, notes
  CreateAction->>App: createContact({ first_name, last_name, email, phone, notes* })
  note right of CreateAction: *notes parsed via parseObject
  App->>API: POST /contacts (JSON payload)
  API-->>App: 201 Created (contact data)
  App-->>CreateAction: contact data
  CreateAction-->>User: Summary: "Successfully created contact: {id}"
Loading
sequenceDiagram
  autonumber
  actor User
  participant UpdateAction as Action: Update Contact
  participant App as Lawmatics App
  participant API as Lawmatics API

  User->>UpdateAction: Provide contactId and updated fields
  UpdateAction->>App: updateContact({ contactId, data })
  App->>API: PUT /contacts/{contactId}
  API-->>App: 200 OK (updated contact)
  App-->>UpdateAction: contact data
  UpdateAction-->>User: Summary: "Successfully updated contact: {id}"
Loading
sequenceDiagram
  autonumber
  participant Timer as Timer
  participant Source as Source: New Contact Added
  participant App as Lawmatics App
  participant API as Lawmatics API
  participant DB as Source DB

  Timer->>Source: run() / deploy()
  Source->>DB: read lastTs
  loop paginate (created_at desc)
    Source->>App: listContacts({ page })
    App->>API: GET /contacts
    API-->>App: contacts page
    App-->>Source: contacts[]
    alt contact.created_at > lastTs
      Source-->>Source: generateMeta(contact)
      Source-->>Source: track newLastTs (first new)
      Source-->>Timer: emit(contact, meta)
    else old or equal
      Source-->>Source: break loop
    end
  end
  Source->>DB: write newLastTs (if any)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Assessment against linked issues

Objective Addressed Explanation
Trigger: new contact added (#17906)
Action: update contact (#17906)
Action: add/create contact (#17906)

Poem

I hop through pages, nose to the breeze,
Parsing notes and planting keys.
I create, update, and softly tread,
New contacts bloom where carrots led.
Version bumped — a rabbit's head. 🥕

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch issue-17906

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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: 6

🧹 Nitpick comments (6)
components/lawmatics/lawmatics.app.mjs (3)

11-27: Consider more robust contact label generation

The label construction could result in awkward spacing if firstName or lastName is missing but email exists. Consider filtering out falsy values before joining.

-          label: `${firstName} ${lastName} ${email}`.trim() || value,
+          label: [firstName, lastName, email].filter(Boolean).join(' ') || value,

53-53: Fix typo and clarify JSON format in notes description

The description contains "Example:" but should show valid JSON format for clarity.

-      description: "An array of notes for the contact. Each note is an object with properties `name` and `body`. Example: `[{ name: 'Note 1', body: 'This is a note' }, { name: 'Note 2', body: 'This is another note' }]`",
+      description: "An array of notes for the contact. Each note is an object with properties `name` and `body`. Example: `[{ \"name\": \"Note 1\", \"body\": \"This is a note\" }, { \"name\": \"Note 2\", \"body\": \"This is another note\" }]`",

85-93: HTTP method should be uppercase for consistency

While lowercase HTTP methods work with axios, uppercase is the standard convention.

     updateContact({
       contactId, ...opts
     }) {
       return this._makeRequest({
         path: `/contacts/${contactId}`,
-        method: "put",
+        method: "PUT",
         ...opts,
       });
     },

Also apply to the createContact method:

     createContact(opts = {}) {
       return this._makeRequest({
         path: "/contacts",
-        method: "post",
+        method: "POST",
         ...opts,
       });
     },
components/lawmatics/sources/new-contact-added/new-contact-added.mjs (1)

30-30: Improve contact summary generation to handle missing fields

Similar to the app file, the summary generation could produce awkward results when some fields are missing.

-        summary: `${contact.attributes.first_name} ${contact.attributes.last_name} ${contact.attributes.email}`.trim() || contact.id,
+        summary: [contact.attributes.first_name, contact.attributes.last_name, contact.attributes.email].filter(Boolean).join(' ') || contact.id,
components/lawmatics/actions/create-contact/create-contact.mjs (1)

46-53: Build payload dynamically to avoid sending undefineds.

Some APIs reject fields explicitly set to undefined; better to omit them.

Apply:

-    const { data } = await this.lawmatics.createContact({
-      $,
-      data: {
-        first_name: this.firstName,
-        last_name: this.lastName,
-        email: this.email,
-        phone: this.phone,
-        notes: parseObject(this.notes),
-      },
-    });
+    const payload = {
+      first_name: this.firstName,
+      last_name: this.lastName,
+      email: this.email,
+      phone: this.phone,
+      notes: parseObject(this.notes),
+    };
+    Object.keys(payload).forEach((k) => payload[k] === undefined && delete payload[k]);
+    const { data } = await this.lawmatics.createContact({ $, data: payload });
components/lawmatics/actions/update-contact/update-contact.mjs (1)

50-60: Also omit undefineds in update payload to prevent accidental field clearing.

Many CRMs interpret explicit null/undefined as “clear this field.”

Apply:

-    const { data } = await this.lawmatics.updateContact({
-      $,
-      contactId: this.contactId,
-      data: {
-        first_name: this.firstName,
-        last_name: this.lastName,
-        email: this.email,
-        phone: this.phone,
-        notes: parseObject(this.notes),
-      },
-    });
+    const payload = {
+      first_name: this.firstName,
+      last_name: this.lastName,
+      email: this.email,
+      phone: this.phone,
+      notes: parseObject(this.notes),
+    };
+    Object.keys(payload).forEach((k) => payload[k] === undefined && delete payload[k]);
+    const { data } = await this.lawmatics.updateContact({
+      $,
+      contactId: this.contactId,
+      data: payload,
+    });
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6aeaea6 and 7165ab2.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • components/lawmatics/actions/create-contact/create-contact.mjs (1 hunks)
  • components/lawmatics/actions/update-contact/update-contact.mjs (1 hunks)
  • components/lawmatics/common/utils.mjs (1 hunks)
  • components/lawmatics/lawmatics.app.mjs (1 hunks)
  • components/lawmatics/package.json (2 hunks)
  • components/lawmatics/sources/new-contact-added/new-contact-added.mjs (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
components/lawmatics/common/utils.mjs (2)
components/lawmatics/actions/create-contact/create-contact.mjs (1)
  • parseObject (44-53)
components/lawmatics/actions/update-contact/update-contact.mjs (1)
  • parseObject (50-60)
components/lawmatics/actions/create-contact/create-contact.mjs (2)
components/lawmatics/actions/update-contact/update-contact.mjs (1)
  • parseObject (50-60)
components/lawmatics/common/utils.mjs (2)
  • parseObject (1-27)
  • parseObject (1-27)
components/lawmatics/actions/update-contact/update-contact.mjs (2)
components/lawmatics/actions/create-contact/create-contact.mjs (1)
  • parseObject (44-53)
components/lawmatics/common/utils.mjs (2)
  • parseObject (1-27)
  • parseObject (1-27)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: pnpm publish
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Lint Code Base
🔇 Additional comments (6)
components/lawmatics/package.json (1)

3-3: Version bump looks appropriate for new features

The version bump from 0.6.0 to 0.7.0 and the @pipedream/platform dependency update to ^3.1.0 are appropriate for adding new components and leveraging axios functionality.

Also applies to: 16-16

components/lawmatics/sources/new-contact-added/new-contact-added.mjs (1)

47-55: Verify and normalize Lawmatics created_at timestamps
Ensure the API returns contact.attributes.created_at as a UTC-offset ISO 8601 string (e.g. ending in “Z”); if it omits the timezone, explicitly normalize to UTC (for example, append “Z” before calling Date.parse) to avoid local-timezone parsing discrepancies.

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

12-14: LGTM: non‑mutating deep map for arrays.

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

4-42: Props wiring looks consistent with app propDefinitions.

components/lawmatics/actions/update-contact/update-contact.mjs (2)

10-48: Props are consistent; contactId presence handled by propDefinition.


61-62: Verify update response includes id. Ensure lawmatics.updateContact returns a defined data.id (or adjust to the actual property path) before using it in $summary.

GTFalcao
GTFalcao previously approved these changes Sep 3, 2025
Copy link
Collaborator

@GTFalcao GTFalcao left a comment

Choose a reason for hiding this comment

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

LGTM!

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

♻️ Duplicate comments (1)
components/lawmatics/lawmatics.app.mjs (1)

90-111: Fix pagination: metadata read from response, not data array

data?.meta?.total_pages is incorrect since data is the items array. Read meta from the response.

Apply this diff:

-        const { data } = await fn({
-          params,
-        });
+        const { data, meta } = await fn({ params });
@@
-        totalPages = data?.meta?.total_pages;
+        totalPages = meta?.total_pages ?? totalPages ?? 1;
         params.page++;
       } while (params.page <= totalPages);
🧹 Nitpick comments (2)
components/lawmatics/lawmatics.app.mjs (2)

11-22: Safer option labels: fall back when email is missing

Some contacts may lack email; add a fallback to name or id to avoid blank labels.

Apply this diff:

-        return data.map(({
-          id: value, attributes: { email },
-        }) => ({
-          value,
-          label: email,
-        }));
+        return data.map(({
+          id: value, attributes: { email, first_name, last_name },
+        }) => ({
+          value,
+          label: email || [first_name, last_name].filter(Boolean).join(" ") || String(value),
+        }));

60-66: Add a client timeout to avoid hanging requests

Set a sensible timeout to fail fast on network issues.

Apply this diff:

       return axios($, {
         url: `${this._baseUrl()}${path}`,
         headers: {
           Authorization: `Bearer ${this.$auth.oauth_access_token}`,
         },
+        timeout: 10000,
         ...opts,
       });
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7165ab2 and 7c2fa0a.

📒 Files selected for processing (1)
  • components/lawmatics/lawmatics.app.mjs (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-04T17:52:05.780Z
Learnt from: GTFalcao
PR: PipedreamHQ/pipedream#16954
File: components/salesloft/salesloft.app.mjs:14-23
Timestamp: 2025-06-04T17:52:05.780Z
Learning: In the Salesloft API integration (components/salesloft/salesloft.app.mjs), the _makeRequest method returns response.data which directly contains arrays for list endpoints like listPeople, listCadences, listUsers, and listAccounts. The propDefinitions correctly call .map() directly on these responses without needing to destructure a nested data property.

Applied to files:

  • components/lawmatics/lawmatics.app.mjs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Lint Code Base
  • GitHub Check: pnpm publish
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Publish TypeScript components
🔇 Additional comments (5)
components/lawmatics/lawmatics.app.mjs (5)

1-1: LGTM on axios import

Importing axios from @pipedream/platform is correct for authenticated requests via $.


57-67: Authorization token usage is correct
Pipedream’s Lawmatics app uses OAuth2 and exposes the access token as $auth.oauth_access_token, so the existing header code is valid.


74-80: Use flat JSON payload for createContact
Lawmatics’ Contacts endpoint accepts a plain JSON object with contact properties (e.g., firstName, lastName, email)—no data.type/data.attributes envelope.

Likely an incorrect or invalid review comment.


81-89: Confirmed correct use of PUT
The Lawmatics API supports a PUT request to /v1/contacts/{id} for updating contacts, so no change to PATCH is needed.


68-73: Confirm pagination parameters for GET /v1/contacts
GET /v1/contacts is correct (help.lawmatics.com); verify supported pagination query parameters (e.g. page, per_page/limit or page[size]) and update opts to include the appropriate params for consistent paging. Ensure the client handles the actual JSON response envelope and metadata shape.

@michelle0927
Copy link
Collaborator Author

/approve

@michelle0927 michelle0927 merged commit 1725ae6 into master Sep 6, 2025
10 checks passed
@michelle0927 michelle0927 deleted the issue-17906 branch September 6, 2025 17:55
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.

[ACTION] Lawmatics

3 participants