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/common/utils.mjs b/components/pipedrive/common/utils.mjs index 963c93243e7e5..a57086226eeed 100644 --- a/components/pipedrive/common/utils.mjs +++ b/components/pipedrive/common/utils.mjs @@ -90,3 +90,42 @@ export const formatCustomFields = async (resp, getResourcesFn, getFieldsFn) => { }; }); }; + +export const formatCustomFieldDataFromSource = async ({ + body, customFieldFn, resourceFn, +}) => { + const customFieldNames = await getCustomFieldNames(customFieldFn); + const { data } = await resourceFn(body.data.id); + const formattedCustomFields = {}; + for (const [ + key, + value, + ] of Object.entries(customFieldNames)) { + formattedCustomFields[value] = data[key] ?? data?.custom_fields?.[key] ?? null; + } + + const formattedPreviousCustomFields = {}; + if (body?.previous?.custom_fields) { + 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, + }, + }), + }; +}; 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-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-lead-instant/updated-lead-instant.mjs b/components/pipedrive/sources/updated-lead-instant/updated-lead-instant.mjs index 60618a73c521b..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 { parseData } from "../../common/utils.mjs"; +import { formatCustomFieldDataFromSource } 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 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 c55819bd77518..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"; @@ -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: { @@ -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, }); }, },