Skip to content

Conversation

jcortes
Copy link
Collaborator

@jcortes jcortes commented Sep 9, 2025

WHY

Resolves #18235

Summary by CodeRabbit

  • New Features

    • Add Deal now supports additional deal fields (status timestamps, expected close date, archived/deleted flags, labels, custom fields).
    • Optionally attach a note automatically to a newly created deal.
    • Improved label selection with dynamic options.
  • Chores

    • Patch version updates across multiple Pipedrive actions and instant sources (e.g., Add Activity, Add Lead, Add Note, Add Organization, Add Person, Update Deal/Person, search/merge utilities, and event sources).
    • Package version bumped to 0.10.1.

@jcortes jcortes self-assigned this Sep 9, 2025
Copy link

vercel bot commented Sep 9, 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 9, 2025 4:40pm
pipedream-docs-redirect-do-not-edit Ignored Ignored Sep 9, 2025 4:40pm

Copy link
Contributor

coderabbitai bot commented Sep 9, 2025

Walkthrough

Most files in Pipedrive components received patch version bumps. The Add Deal action switched to a generic app instance, added multiple new optional deal fields, and introduced optional post-create note attachment. The Pipedrive app added new propDefinitions for those fields, including async label options. Package version bumped.

Changes

Cohort / File(s) Summary of changes
Add Deal enhancements
components/pipedrive/actions/add-deal/add-deal.mjs
Switched prop providers from pipedriveApp to app; added new optional props (isDeleted, isArchived, archiveTime, closeTime, wonTime, lostTime, expectedCloseDate, labelIds, customFields, note); parseObject support; run now calls app.addDeal with new fields; optionally calls app.addNote; version 0.1.13 → 0.1.14.
App propDefinitions update
components/pipedrive/pipedrive.app.mjs
Added propDefinitions for isDeleted, isArchived, archiveTime, closeTime, wonTime, lostTime, expectedCloseDate, customFields, labelIds; labelIds options resolver fetches deal custom fields and maps label options.
Version bumps — actions
components/pipedrive/actions/add-activity/add-activity.mjs, components/pipedrive/actions/add-lead/add-lead.mjs, components/pipedrive/actions/add-note/add-note.mjs, components/pipedrive/actions/add-organization/add-organization.mjs, components/pipedrive/actions/add-person/add-person.mjs, components/pipedrive/actions/merge-deals/merge-deals.mjs, components/pipedrive/actions/merge-persons/merge-persons.mjs, components/pipedrive/actions/remove-duplicate-notes/remove-duplicate-notes.mjs, components/pipedrive/actions/search-leads/search-leads.mjs, components/pipedrive/actions/search-notes/search-notes.mjs, components/pipedrive/actions/search-persons/search-persons.mjs, components/pipedrive/actions/update-deal/update-deal.mjs, components/pipedrive/actions/update-person/update-person.mjs
Patch version increments only; no functional changes.
Version bumps — sources
components/pipedrive/sources/new-deal-instant/new-deal-instant.mjs, components/pipedrive/sources/new-event-instant/new-event-instant.mjs, components/pipedrive/sources/new-person-instant/new-person-instant.mjs, components/pipedrive/sources/updated-deal-instant/updated-deal-instant.mjs, components/pipedrive/sources/updated-lead-instant/updated-lead-instant.mjs, components/pipedrive/sources/updated-person-instant/updated-person-instant.mjs
Patch version increments only; no functional changes.
Package metadata
components/pipedrive/package.json
Version bumped 0.10.0 → 0.10.1.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant AddDeal Action as AddDeal Action
  participant Pipedrive App as Pipedrive App
  participant Pipedrive API as Pipedrive API

  User->>AddDeal Action: Provide deal data (+ optional note)
  AddDeal Action->>Pipedrive App: addDeal(payload with new fields)
  Pipedrive App->>Pipedrive API: POST /deals
  Pipedrive API-->>Pipedrive App: 201 Created (deal_id)
  Pipedrive App-->>AddDeal Action: deal response

  alt Note provided
    AddDeal Action->>Pipedrive App: addNote({ deal_id, content })
    Pipedrive App->>Pipedrive API: POST /notes
    Pipedrive API-->>Pipedrive App: 201 Created (note_id)
    Pipedrive App-->>AddDeal Action: note response
  else No note
    Note over AddDeal Action: Skip note creation
  end

  AddDeal Action-->>User: Return deal (and note if created)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

User submitted

Suggested reviewers

  • michelle0927

Pre-merge checks (3 passed, 2 warnings)

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning The pull request introduces extensive changes beyond the scope of issue [#18235], including a global switch from pipedriveApp to a generic app import, addition of parseObject support, and new public app fields for archival and timestamp properties as well as customFields and labelIds. These enhancements extend the Pipedrive app’s data model and affect multiple actions beyond simply adding a note to a deal, which diverges from the single issue objective. Bundling these unrelated modifications complicates the review process and risks unintended side effects. The inclusion of broad app-level updates alongside the note feature indicates that unrelated improvements are mixed in with the targeted change. Please refactor the PR to isolate the note prop addition into its own pull request and split out the unrelated app-level and action enhancements into separate, focused changes.
Description Check ⚠️ Warning Although the description includes the template header and references issue #18235, it does not explain the motivation, context, or expected impact of adding the note property as required by the repository’s template. The ## WHY section should detail why this enhancement is needed and how it addresses the issue. Currently, reviewers lack key background information and a summary of the change’s objectives. This omission makes the PR description incomplete relative to the required template. The ## WHY section should be expanded to articulate the motivation and expected impact of adding the note prop, including relevant implementation and testing details per the repository’s description template.
✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly identifies the component and the specific enhancement by stating “add note prop to add deal action,” which accurately summarizes the primary change introduced in this pull request. It is concise, free of extraneous details, and would be immediately understandable to a teammate scanning the history.
Linked Issues Check ✅ Passed The pull request fully implements the core request from issue [#18235] by introducing a new optional note property in the Pipedrive Add Deal action, updating its propDefinitions, and extending the run logic to call app.addNote when a note is provided. These changes directly address the requirement to support notes at deal creation without leaving any coding requirements unfulfilled. All relevant modifications are localized to components/pipedrive/actions/add-deal/add-deal.mjs and align with the outlined objectives. No required code changes from the linked issue are missing.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Poem

A nibble of notes on a fresh-dealed day,
I tap my paws and hop away—hooray!
New fields bloom where pipelines flow,
Labels sprout, custom carrots grow.
If you whisper a note, I’ll tuck it inside—
A deal with a tale for the burrow’s pride. 🥕🐇

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch pipedrive-improve-add-deal-with-optional-note-prop

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
components/pipedrive/actions/add-lead/add-lead.mjs (1)

94-120: Shield addNote errors and align error handling with other actions

add-lead currently lacks the try/catch pattern used elsewhere and will fail the whole step if note creation throws after a successful lead create. Wrap run in try/catch and isolate addNote errors so the lead creation still succeeds.

   async run({ $ }) {
-    if (!this.organizationId && !this.personId) {
-      throw new ConfigurationError("Either organizationId or personId is required");
-    }
-
-    const response = await this.pipedrive.addLead({
-      title: this.title,
-      person_id: this.personId,
-      organization_id: this.organizationId,
-      owner_id: this.ownerId,
-      label_ids: this.leadLabelIds,
-      value: parseObject(this.value),
-      expected_close_date: this.expectedCloseDate,
-      visible_to: this.visibleTo,
-      was_seen: this.wasSeen,
-    });
-
-    if (this.note) {
-      await this.pipedrive.addNote({
-        content: this.note,
-        lead_id: response.data?.id,
-      });
-    }
-
-    $.export("$summary", `Successfully created lead: ${response.data?.title || response.data?.id}`);
-    return response;
+    try {
+      if (!this.organizationId && !this.personId) {
+        throw new ConfigurationError("Either organizationId or personId is required");
+      }
+
+      const response = await this.pipedrive.addLead({
+        title: this.title,
+        person_id: this.personId,
+        organization_id: this.organizationId,
+        owner_id: this.ownerId,
+        label_ids: this.leadLabelIds,
+        value: parseObject(this.value),
+        expected_close_date: this.expectedCloseDate,
+        visible_to: this.visibleTo,
+        was_seen: this.wasSeen,
+      });
+
+      const leadId = response?.data?.id;
+      if (this.note && leadId) {
+        try {
+          await this.pipedrive.addNote({
+            content: this.note,
+            lead_id: leadId,
+          });
+        } catch (err) {
+          $.export("noteError", err?.message ?? "Failed to add note");
+        }
+      }
+
+      $.export("$summary", `Successfully created lead: ${response.data?.title || response.data?.id}`);
+      return response;
+    } catch ({ error }) {
+      throw new ConfigurationError(error);
+    }
   },
🧹 Nitpick comments (5)
components/pipedrive/actions/get-person-details/get-person-details.mjs (1)

21-31: Return shape consistency: return data instead of raw resp

Other actions typically return the response data (e.g., get-lead-by-id). Consider returning resp.data for consistency.

-      return resp;
+      return resp?.data ?? resp;
components/pipedrive/actions/update-deal/update-deal.mjs (1)

119-124: Isolate note failures so deal updates don’t fail post-update

Mirror the add-lead pattern by catching addNote errors; avoid failing after a successful update.

-      if (this.note) {
-        await this.pipedriveApp.addNote({
-          content: this.note,
-          deal_id: this.dealId,
-        });
-      }
+      if (this.note) {
+        try {
+          await this.pipedriveApp.addNote({
+            content: this.note,
+            deal_id: this.dealId,
+          });
+        } catch (err) {
+          $.export("noteError", err?.message ?? "Failed to add note");
+        }
+      }
components/pipedrive/actions/add-deal/add-deal.mjs (2)

2-4: Avoid shadowing the imported app and align naming with other actions

import app ... is shadowed by const { app } = this; which is easy to confuse with the imported module. Other actions use pipedriveApp. Recommend renaming the import to pipedriveApp and reference it in propDefinitions; keep the prop named app if you want, but avoid same identifier for two meanings.

Minimal illustration (apply similarly to all propDefinition entries referencing app):

-import app from "../../pipedrive.app.mjs";
+import pipedriveApp from "../../pipedrive.app.mjs";

 props: {
-  app,
+  app,
   title: {
     propDefinition: [
-      app,
+      pipedriveApp,
       "dealTitle",
     ],
   },
   ownerId: {
     propDefinition: [
-      app,
+      pipedriveApp,
       "userId",
     ],
   },
   // ...repeat for every propDefinition currently using `app`
 },

 async run({ $ }) {
-  const {
-    app,
+  const {
+    app,
     title,
     // ...
   } = this;

Also applies to: 12-18, 20-24, 26-30, 32-36, 38-43, 45-49, 51-55, 57-61, 63-67, 69-73, 75-79, 81-85, 86-91, 92-97, 98-103, 104-109, 110-115, 116-121, 122-127, 128-133, 134-139, 148-153


86-127: Enforce status constraints for lifecycle props on addDeal

  • Pipedrive API v2 supports isDeleted, isArchived, archiveTime, and expectedCloseDate on create, but closeTime only when status is "won" or "lost", wonTime only when status is "won", and lostTime only when status is "lost".
  • Gate or strip these fields in components/pipedrive/actions/add-deal/add-deal.mjs (lines 86–127) to prevent API rejections.
components/pipedrive/pipedrive.app.mjs (1)

321-350: Timestamp format guidance is inconsistent with other props

These props document YYYY-MM-DD HH:MM:SS while addTime uses ISO8601 with T/Z. Unify guidance (ideally ISO8601) to reduce user input errors.

- description: "The optional date and time of archiving the deal in UTC. Format: `YYYY-MM-DD HH:MM:SS`....
+ description: "The optional date and time of archiving the deal in UTC. Recommended format: `YYYY-MM-DDTHH:MM:SSZ` (ISO 8601). ...

(Apply similarly to Close/Won/Lost Time.)

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between db457a5 and f781332.

📒 Files selected for processing (24)
  • components/pipedrive/actions/add-activity/add-activity.mjs (1 hunks)
  • components/pipedrive/actions/add-deal/add-deal.mjs (1 hunks)
  • components/pipedrive/actions/add-lead/add-lead.mjs (1 hunks)
  • components/pipedrive/actions/add-note/add-note.mjs (1 hunks)
  • components/pipedrive/actions/add-organization/add-organization.mjs (1 hunks)
  • components/pipedrive/actions/add-person/add-person.mjs (1 hunks)
  • components/pipedrive/actions/get-lead-by-id/get-lead-by-id.mjs (1 hunks)
  • components/pipedrive/actions/get-person-details/get-person-details.mjs (1 hunks)
  • components/pipedrive/actions/merge-deals/merge-deals.mjs (1 hunks)
  • components/pipedrive/actions/merge-persons/merge-persons.mjs (1 hunks)
  • components/pipedrive/actions/remove-duplicate-notes/remove-duplicate-notes.mjs (1 hunks)
  • components/pipedrive/actions/search-leads/search-leads.mjs (1 hunks)
  • components/pipedrive/actions/search-notes/search-notes.mjs (1 hunks)
  • components/pipedrive/actions/search-persons/search-persons.mjs (1 hunks)
  • components/pipedrive/actions/update-deal/update-deal.mjs (1 hunks)
  • components/pipedrive/actions/update-person/update-person.mjs (1 hunks)
  • components/pipedrive/package.json (1 hunks)
  • components/pipedrive/pipedrive.app.mjs (1 hunks)
  • components/pipedrive/sources/new-deal-instant/new-deal-instant.mjs (1 hunks)
  • components/pipedrive/sources/new-event-instant/new-event-instant.mjs (1 hunks)
  • components/pipedrive/sources/new-person-instant/new-person-instant.mjs (1 hunks)
  • components/pipedrive/sources/updated-deal-instant/updated-deal-instant.mjs (1 hunks)
  • components/pipedrive/sources/updated-lead-instant/updated-lead-instant.mjs (1 hunks)
  • components/pipedrive/sources/updated-person-instant/updated-person-instant.mjs (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
components/pipedrive/pipedrive.app.mjs (1)
components/pipedrive/actions/add-activity/add-activity.mjs (1)
  • data (156-170)
components/pipedrive/actions/add-deal/add-deal.mjs (2)
components/pipedrive/actions/add-note/add-note.mjs (1)
  • resp (89-102)
components/pipedrive/common/utils.mjs (2)
  • parseObject (1-24)
  • parseObject (1-24)
⏰ 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 (23)
components/pipedrive/actions/add-lead/add-lead.mjs (1)

111-116: Confirmed: Pipedrive Notes API supports lead_id
No changes needed—the lead_id parameter (string, UUID) is valid on POST /v1/notes.

components/pipedrive/package.json (1)

3-3: Version bump looks good

0.10.1 aligns with action/source version bumps in this release.

components/pipedrive/sources/updated-person-instant/updated-person-instant.mjs (1)

10-10: LGTM on version bump

No functional changes; metadata update only.

components/pipedrive/actions/get-lead-by-id/get-lead-by-id.mjs (1)

7-7: LGTM on version bump

Action remains unchanged functionally.

components/pipedrive/actions/get-person-details/get-person-details.mjs (1)

8-8: LGTM on version bump

components/pipedrive/actions/add-activity/add-activity.mjs (1)

10-10: LGTM on version bump

components/pipedrive/actions/merge-deals/merge-deals.mjs (1)

7-7: LGTM on version bump

components/pipedrive/actions/search-leads/search-leads.mjs (1)

8-8: Version bump only — OK

No functional changes detected. Safe to publish.

components/pipedrive/actions/merge-persons/merge-persons.mjs (1)

7-7: Version bump only — OK

No behavior changes in merge logic. Good to release.

components/pipedrive/actions/remove-duplicate-notes/remove-duplicate-notes.mjs (1)

8-8: Version bump only — OK

Logic unchanged. Proceed.

components/pipedrive/actions/add-person/add-person.mjs (1)

9-9: Version bump only — OK

No runtime changes; existing error handling remains intact.

components/pipedrive/actions/search-notes/search-notes.mjs (1)

7-7: Version bump only — OK

Filter/sort behavior unchanged.

components/pipedrive/actions/add-note/add-note.mjs (1)

8-8: Version bump only — OK

No changes to add-note behavior. Compatible with upstream usage.

components/pipedrive/sources/new-event-instant/new-event-instant.mjs (1)

8-8: Version bump only — OK

Source interface and webhook handling unchanged.

components/pipedrive/actions/add-organization/add-organization.mjs (1)

8-8: Version bump only — OK

No functional differences; safe increment.

components/pipedrive/actions/add-deal/add-deal.mjs (1)

128-139: Ignore case conversion comment
The code correctly uses camelCase inputs (labelIds, customFields), and the Pipedrive Node SDK automatically serializes these to the required snake_case (label_ids, custom_fields) in the HTTP payload, so no changes are needed.

Likely an incorrect or invalid review comment.

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

357-372: Async label options resolution looks solid

Fetching Deal fields and mapping the label field options to {label, value} is correct and defensive with a safe fallback.

components/pipedrive/sources/updated-deal-instant/updated-deal-instant.mjs (1)

10-10: Version bump only — OK

No functional changes detected.

components/pipedrive/sources/updated-lead-instant/updated-lead-instant.mjs (1)

10-10: Version bump only — OK

No functional changes detected.

components/pipedrive/sources/new-deal-instant/new-deal-instant.mjs (1)

9-9: Version bump only — OK

No functional changes detected.

components/pipedrive/sources/new-person-instant/new-person-instant.mjs (1)

9-9: Version bump only — OK

No functional changes detected.

components/pipedrive/actions/search-persons/search-persons.mjs (1)

10-10: Version bump only — OK

No functional changes detected.

components/pipedrive/actions/update-person/update-person.mjs (1)

9-9: Version bump only — OK

No functional changes detected.

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!

@jcortes jcortes merged commit c2c646a into master Sep 10, 2025
10 checks passed
@jcortes jcortes deleted the pipedrive-improve-add-deal-with-optional-note-prop branch September 10, 2025 14:08
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.

Pipedrive
2 participants