From 7a143a30e0f926e826fdfc74a891a82af3ced157 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Mon, 10 Nov 2025 15:59:01 -0500 Subject: [PATCH 1/7] format custom lead fields --- components/pipedrive/common/utils.mjs | 23 +++++++++++++++++++ components/pipedrive/package.json | 2 +- .../updated-lead-instant.mjs | 9 ++++---- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/components/pipedrive/common/utils.mjs b/components/pipedrive/common/utils.mjs index 963c93243e7e5..cfc4ce8d2b57a 100644 --- a/components/pipedrive/common/utils.mjs +++ b/components/pipedrive/common/utils.mjs @@ -90,3 +90,26 @@ export const formatCustomFields = async (resp, getResourcesFn, getFieldsFn) => { }; }); }; + +export const formatLeadDataFromSource = async ({ + body, customFieldFn, resourceFn, +}) => { + const customFieldNames = await getCustomFieldNames(customFieldFn); + const { data: lead } = await resourceFn(body.data.id); + const formattedCustomFields = {}; + for (const [ + key, + value, + ] of Object.entries(customFieldNames)) { + if (lead[key]) { + formattedCustomFields[value] = lead[key]; + } + } + return { + ...body, + data: { + ...body.data, + custom_fields: formattedCustomFields, + }, + }; +}; diff --git a/components/pipedrive/package.json b/components/pipedrive/package.json index 861c42446b582..a06dae961e3eb 100644 --- a/components/pipedrive/package.json +++ b/components/pipedrive/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/pipedrive", - "version": "0.10.4", + "version": "0.10.5", "description": "Pipedream Pipedrive Components", "main": "pipedrive.app.mjs", "keywords": [ diff --git a/components/pipedrive/sources/updated-lead-instant/updated-lead-instant.mjs b/components/pipedrive/sources/updated-lead-instant/updated-lead-instant.mjs index 60618a73c521b..0e53bf39ac46b 100644 --- a/components/pipedrive/sources/updated-lead-instant/updated-lead-instant.mjs +++ b/components/pipedrive/sources/updated-lead-instant/updated-lead-instant.mjs @@ -1,4 +1,4 @@ -import { parseData } from "../../common/utils.mjs"; +import { formatLeadDataFromSource } from "../../common/utils.mjs"; import common from "../common/base.mjs"; import sampleEmit from "./test-event.mjs"; @@ -7,7 +7,7 @@ export default { key: "pipedrive-updated-lead-instant", name: "Lead Updated (Instant)", description: "Emit new event when a lead is updated.", - version: "0.1.6", + version: "0.1.7", type: "source", dedupe: "unique", methods: { @@ -22,9 +22,10 @@ export default { return `Lead successfully updated: ${body.data.id}`; }, async parseData(body) { - return await parseData({ - fn: this.pipedrive.getDealCustomFields, + return await formatLeadDataFromSource({ body, + customFieldFn: this.pipedrive.getDealCustomFields, + resourceFn: this.pipedrive.getLead, }); }, }, From c4d4eb5ade5565261935bbb3ef0b53e3e3e04237 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Mon, 10 Nov 2025 16:02:14 -0500 Subject: [PATCH 2/7] versions --- components/pipedrive/actions/add-activity/add-activity.mjs | 2 +- components/pipedrive/actions/add-deal/add-deal.mjs | 2 +- components/pipedrive/actions/add-lead/add-lead.mjs | 2 +- components/pipedrive/actions/add-person/add-person.mjs | 2 +- components/pipedrive/actions/search-persons/search-persons.mjs | 2 +- components/pipedrive/actions/update-person/update-person.mjs | 2 +- .../sources/updated-deal-instant/updated-deal-instant.mjs | 2 +- .../sources/updated-person-instant/updated-person-instant.mjs | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/components/pipedrive/actions/add-activity/add-activity.mjs b/components/pipedrive/actions/add-activity/add-activity.mjs index 1cfc915786aee..d7d2f94044867 100644 --- a/components/pipedrive/actions/add-activity/add-activity.mjs +++ b/components/pipedrive/actions/add-activity/add-activity.mjs @@ -7,7 +7,7 @@ export default { key: "pipedrive-add-activity", name: "Add Activity", description: "Adds a new activity. Includes `more_activities_scheduled_in_context` property in response's `additional_data` which indicates whether there are more undone activities scheduled with the same deal, person or organization (depending on the supplied data). See the Pipedrive API docs for Activities [here](https://developers.pipedrive.com/docs/api/v1/#!/Activities). For info on [adding an activity in Pipedrive](https://developers.pipedrive.com/docs/api/v1/Activities#addActivity)", - version: "0.1.17", + version: "0.1.18", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/pipedrive/actions/add-deal/add-deal.mjs b/components/pipedrive/actions/add-deal/add-deal.mjs index c31429cb2071c..a93bc36b7bb0d 100644 --- a/components/pipedrive/actions/add-deal/add-deal.mjs +++ b/components/pipedrive/actions/add-deal/add-deal.mjs @@ -6,7 +6,7 @@ export default { key: "pipedrive-add-deal", name: "Add Deal", description: "Adds a new deal. See the Pipedrive API docs for Deals [here](https://developers.pipedrive.com/docs/api/v1/Deals#addDeal)", - version: "0.1.18", + version: "0.1.19", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/pipedrive/actions/add-lead/add-lead.mjs b/components/pipedrive/actions/add-lead/add-lead.mjs index ed6ae3cc19343..2d30cb55cd8d5 100644 --- a/components/pipedrive/actions/add-lead/add-lead.mjs +++ b/components/pipedrive/actions/add-lead/add-lead.mjs @@ -6,7 +6,7 @@ export default { key: "pipedrive-add-lead", name: "Add Lead", description: "Create a new lead in Pipedrive. [See the documentation](https://developers.pipedrive.com/docs/api/v1/Leads#addLead)", - version: "0.0.11", + version: "0.0.12", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/pipedrive/actions/add-person/add-person.mjs b/components/pipedrive/actions/add-person/add-person.mjs index 03621655ec7f5..8ebbbf1f05564 100644 --- a/components/pipedrive/actions/add-person/add-person.mjs +++ b/components/pipedrive/actions/add-person/add-person.mjs @@ -6,7 +6,7 @@ export default { key: "pipedrive-add-person", name: "Add Person", description: "Adds a new person. See the Pipedrive API docs for People [here](https://developers.pipedrive.com/docs/api/v1/Persons#addPerson)", - version: "0.1.17", + version: "0.1.18", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/pipedrive/actions/search-persons/search-persons.mjs b/components/pipedrive/actions/search-persons/search-persons.mjs index 1906e863c4b40..35fd12a6d064b 100644 --- a/components/pipedrive/actions/search-persons/search-persons.mjs +++ b/components/pipedrive/actions/search-persons/search-persons.mjs @@ -8,7 +8,7 @@ export default { key: "pipedrive-search-persons", name: "Search persons", description: "Searches all Persons by `name`, `email`, `phone`, `notes` and/or custom fields. This endpoint is a wrapper of `/v1/itemSearch` with a narrower OAuth scope. Found Persons can be filtered by Organization ID. See the Pipedrive API docs [here](https://developers.pipedrive.com/docs/api/v1/Persons#searchPersons)", - version: "0.1.17", + version: "0.1.18", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/pipedrive/actions/update-person/update-person.mjs b/components/pipedrive/actions/update-person/update-person.mjs index 05896d5ebe140..6e7b57f07e000 100644 --- a/components/pipedrive/actions/update-person/update-person.mjs +++ b/components/pipedrive/actions/update-person/update-person.mjs @@ -6,7 +6,7 @@ export default { key: "pipedrive-update-person", name: "Update Person", description: "Updates an existing person in Pipedrive. [See the documentation](https://developers.pipedrive.com/docs/api/v1/Persons#updatePerson)", - version: "0.0.9", + version: "0.0.10", annotations: { destructiveHint: true, openWorldHint: true, diff --git a/components/pipedrive/sources/updated-deal-instant/updated-deal-instant.mjs b/components/pipedrive/sources/updated-deal-instant/updated-deal-instant.mjs index 8e3976ed1ddfb..3ad1da0bcd976 100644 --- a/components/pipedrive/sources/updated-deal-instant/updated-deal-instant.mjs +++ b/components/pipedrive/sources/updated-deal-instant/updated-deal-instant.mjs @@ -7,7 +7,7 @@ export default { key: "pipedrive-updated-deal-instant", name: "Deal Updated (Instant)", description: "Emit new event when a deal is updated.", - version: "0.1.6", + version: "0.1.7", type: "source", dedupe: "unique", methods: { diff --git a/components/pipedrive/sources/updated-person-instant/updated-person-instant.mjs b/components/pipedrive/sources/updated-person-instant/updated-person-instant.mjs index c55819bd77518..b69df6b92ed0a 100644 --- a/components/pipedrive/sources/updated-person-instant/updated-person-instant.mjs +++ b/components/pipedrive/sources/updated-person-instant/updated-person-instant.mjs @@ -7,7 +7,7 @@ export default { key: "pipedrive-updated-person-instant", name: "Person Updated (Instant)", description: "Emit new event when a person is updated.", - version: "0.1.6", + version: "0.1.7", type: "source", dedupe: "unique", methods: { From 1fae8706d3f1f08486fc12bd6cc6c5f1bde93eda Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Mon, 10 Nov 2025 16:20:26 -0500 Subject: [PATCH 3/7] format previous custom fields --- components/pipedrive/common/utils.mjs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/components/pipedrive/common/utils.mjs b/components/pipedrive/common/utils.mjs index cfc4ce8d2b57a..54e48bb6c16b7 100644 --- a/components/pipedrive/common/utils.mjs +++ b/components/pipedrive/common/utils.mjs @@ -105,11 +105,29 @@ export const formatLeadDataFromSource = async ({ formattedCustomFields[value] = lead[key]; } } + + const formattedPreviousCustomFields = {}; + if (body.previous) { + for (const [ + key, + value, + ] of Object.entries(customFieldNames)) { + if (body.previous.custom_fields[key]) { + formattedPreviousCustomFields[value] = body.previous.custom_fields[key]; + } + } + } return { ...body, data: { ...body.data, custom_fields: formattedCustomFields, }, + ...(body.previous?.custom_fields && { + previous: { + ...body.previous, + custom_fields: formattedPreviousCustomFields, + }, + }), }; }; From 91f7b95dbee2a865304c4d7c84ac0644312c8052 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Tue, 11 Nov 2025 15:14:21 -0500 Subject: [PATCH 4/7] fix --- components/pipedrive/common/utils.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/pipedrive/common/utils.mjs b/components/pipedrive/common/utils.mjs index 54e48bb6c16b7..94c2056a91f76 100644 --- a/components/pipedrive/common/utils.mjs +++ b/components/pipedrive/common/utils.mjs @@ -107,7 +107,7 @@ export const formatLeadDataFromSource = async ({ } const formattedPreviousCustomFields = {}; - if (body.previous) { + if (body?.previous?.custom_fields) { for (const [ key, value, From 3a2e37e1126116360c5d8e73e8cdb16ae2848e98 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Wed, 12 Nov 2025 13:33:28 -0500 Subject: [PATCH 5/7] include undefined custom fields --- components/pipedrive/common/utils.mjs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/components/pipedrive/common/utils.mjs b/components/pipedrive/common/utils.mjs index 94c2056a91f76..09cd6cd0fb9a8 100644 --- a/components/pipedrive/common/utils.mjs +++ b/components/pipedrive/common/utils.mjs @@ -101,9 +101,7 @@ export const formatLeadDataFromSource = async ({ key, value, ] of Object.entries(customFieldNames)) { - if (lead[key]) { - formattedCustomFields[value] = lead[key]; - } + formattedCustomFields[value] = lead[key] || null; } const formattedPreviousCustomFields = {}; From df7ad291818e140fec134168f6bd3d1e16efe252 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Wed, 12 Nov 2025 13:41:00 -0500 Subject: [PATCH 6/7] update --- components/pipedrive/common/utils.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/pipedrive/common/utils.mjs b/components/pipedrive/common/utils.mjs index 09cd6cd0fb9a8..589ed40c419d9 100644 --- a/components/pipedrive/common/utils.mjs +++ b/components/pipedrive/common/utils.mjs @@ -101,7 +101,7 @@ export const formatLeadDataFromSource = async ({ key, value, ] of Object.entries(customFieldNames)) { - formattedCustomFields[value] = lead[key] || null; + formattedCustomFields[value] = lead[key] ?? null; } const formattedPreviousCustomFields = {}; From f39e247b77d7338c28afcf6b37866dd1031d1d65 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Wed, 12 Nov 2025 14:07:58 -0500 Subject: [PATCH 7/7] update updated-person-instant source --- components/pipedrive/common/utils.mjs | 6 +++--- .../sources/updated-lead-instant/updated-lead-instant.mjs | 4 ++-- .../updated-person-instant/updated-person-instant.mjs | 7 ++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/components/pipedrive/common/utils.mjs b/components/pipedrive/common/utils.mjs index 589ed40c419d9..a57086226eeed 100644 --- a/components/pipedrive/common/utils.mjs +++ b/components/pipedrive/common/utils.mjs @@ -91,17 +91,17 @@ export const formatCustomFields = async (resp, getResourcesFn, getFieldsFn) => { }); }; -export const formatLeadDataFromSource = async ({ +export const formatCustomFieldDataFromSource = async ({ body, customFieldFn, resourceFn, }) => { const customFieldNames = await getCustomFieldNames(customFieldFn); - const { data: lead } = await resourceFn(body.data.id); + const { data } = await resourceFn(body.data.id); const formattedCustomFields = {}; for (const [ key, value, ] of Object.entries(customFieldNames)) { - formattedCustomFields[value] = lead[key] ?? null; + formattedCustomFields[value] = data[key] ?? data?.custom_fields?.[key] ?? null; } const formattedPreviousCustomFields = {}; diff --git a/components/pipedrive/sources/updated-lead-instant/updated-lead-instant.mjs b/components/pipedrive/sources/updated-lead-instant/updated-lead-instant.mjs index 0e53bf39ac46b..c2fae9d8e5c03 100644 --- a/components/pipedrive/sources/updated-lead-instant/updated-lead-instant.mjs +++ b/components/pipedrive/sources/updated-lead-instant/updated-lead-instant.mjs @@ -1,4 +1,4 @@ -import { formatLeadDataFromSource } from "../../common/utils.mjs"; +import { formatCustomFieldDataFromSource } from "../../common/utils.mjs"; import common from "../common/base.mjs"; import sampleEmit from "./test-event.mjs"; @@ -22,7 +22,7 @@ export default { return `Lead successfully updated: ${body.data.id}`; }, async parseData(body) { - return await formatLeadDataFromSource({ + return await formatCustomFieldDataFromSource({ body, customFieldFn: this.pipedrive.getDealCustomFields, resourceFn: this.pipedrive.getLead, diff --git a/components/pipedrive/sources/updated-person-instant/updated-person-instant.mjs b/components/pipedrive/sources/updated-person-instant/updated-person-instant.mjs index b69df6b92ed0a..4453742271caf 100644 --- a/components/pipedrive/sources/updated-person-instant/updated-person-instant.mjs +++ b/components/pipedrive/sources/updated-person-instant/updated-person-instant.mjs @@ -1,4 +1,4 @@ -import { parseData } from "../../common/utils.mjs"; +import { formatCustomFieldDataFromSource } from "../../common/utils.mjs"; import common from "../common/base.mjs"; import sampleEmit from "./test-event.mjs"; @@ -22,9 +22,10 @@ export default { return `Person successfully updated: ${body.data.id}`; }, async parseData(body) { - return await parseData({ - fn: this.pipedrive.getPersonCustomFields, + return await formatCustomFieldDataFromSource({ body, + customFieldFn: this.pipedrive.getPersonCustomFields, + resourceFn: this.pipedrive.getPerson, }); }, },