Skip to content

Commit b32ca36

Browse files
authored
Return all custom fields in Pipedrive trigger updated-lead-instant (#19003)
* format custom lead fields * versions * format previous custom fields * fix * include undefined custom fields * update * update updated-person-instant source
1 parent e82deb1 commit b32ca36

File tree

11 files changed

+57
-16
lines changed

11 files changed

+57
-16
lines changed

components/pipedrive/actions/add-activity/add-activity.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "pipedrive-add-activity",
88
name: "Add Activity",
99
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)",
10-
version: "0.1.17",
10+
version: "0.1.18",
1111
annotations: {
1212
destructiveHint: false,
1313
openWorldHint: true,

components/pipedrive/actions/add-deal/add-deal.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "pipedrive-add-deal",
77
name: "Add Deal",
88
description: "Adds a new deal. See the Pipedrive API docs for Deals [here](https://developers.pipedrive.com/docs/api/v1/Deals#addDeal)",
9-
version: "0.1.18",
9+
version: "0.1.19",
1010
annotations: {
1111
destructiveHint: false,
1212
openWorldHint: true,

components/pipedrive/actions/add-lead/add-lead.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "pipedrive-add-lead",
77
name: "Add Lead",
88
description: "Create a new lead in Pipedrive. [See the documentation](https://developers.pipedrive.com/docs/api/v1/Leads#addLead)",
9-
version: "0.0.11",
9+
version: "0.0.12",
1010
annotations: {
1111
destructiveHint: false,
1212
openWorldHint: true,

components/pipedrive/actions/add-person/add-person.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "pipedrive-add-person",
77
name: "Add Person",
88
description: "Adds a new person. See the Pipedrive API docs for People [here](https://developers.pipedrive.com/docs/api/v1/Persons#addPerson)",
9-
version: "0.1.17",
9+
version: "0.1.18",
1010
annotations: {
1111
destructiveHint: false,
1212
openWorldHint: true,

components/pipedrive/actions/search-persons/search-persons.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
key: "pipedrive-search-persons",
99
name: "Search persons",
1010
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)",
11-
version: "0.1.17",
11+
version: "0.1.18",
1212
annotations: {
1313
destructiveHint: false,
1414
openWorldHint: true,

components/pipedrive/actions/update-person/update-person.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "pipedrive-update-person",
77
name: "Update Person",
88
description: "Updates an existing person in Pipedrive. [See the documentation](https://developers.pipedrive.com/docs/api/v1/Persons#updatePerson)",
9-
version: "0.0.9",
9+
version: "0.0.10",
1010
annotations: {
1111
destructiveHint: true,
1212
openWorldHint: true,

components/pipedrive/common/utils.mjs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,42 @@ export const formatCustomFields = async (resp, getResourcesFn, getFieldsFn) => {
9090
};
9191
});
9292
};
93+
94+
export const formatCustomFieldDataFromSource = async ({
95+
body, customFieldFn, resourceFn,
96+
}) => {
97+
const customFieldNames = await getCustomFieldNames(customFieldFn);
98+
const { data } = await resourceFn(body.data.id);
99+
const formattedCustomFields = {};
100+
for (const [
101+
key,
102+
value,
103+
] of Object.entries(customFieldNames)) {
104+
formattedCustomFields[value] = data[key] ?? data?.custom_fields?.[key] ?? null;
105+
}
106+
107+
const formattedPreviousCustomFields = {};
108+
if (body?.previous?.custom_fields) {
109+
for (const [
110+
key,
111+
value,
112+
] of Object.entries(customFieldNames)) {
113+
if (body.previous.custom_fields[key]) {
114+
formattedPreviousCustomFields[value] = body.previous.custom_fields[key];
115+
}
116+
}
117+
}
118+
return {
119+
...body,
120+
data: {
121+
...body.data,
122+
custom_fields: formattedCustomFields,
123+
},
124+
...(body.previous?.custom_fields && {
125+
previous: {
126+
...body.previous,
127+
custom_fields: formattedPreviousCustomFields,
128+
},
129+
}),
130+
};
131+
};

components/pipedrive/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/pipedrive",
3-
"version": "0.10.4",
3+
"version": "0.10.5",
44
"description": "Pipedream Pipedrive Components",
55
"main": "pipedrive.app.mjs",
66
"keywords": [

components/pipedrive/sources/updated-deal-instant/updated-deal-instant.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "pipedrive-updated-deal-instant",
88
name: "Deal Updated (Instant)",
99
description: "Emit new event when a deal is updated.",
10-
version: "0.1.6",
10+
version: "0.1.7",
1111
type: "source",
1212
dedupe: "unique",
1313
methods: {

components/pipedrive/sources/updated-lead-instant/updated-lead-instant.mjs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { parseData } from "../../common/utils.mjs";
1+
import { formatCustomFieldDataFromSource } from "../../common/utils.mjs";
22
import common from "../common/base.mjs";
33
import sampleEmit from "./test-event.mjs";
44

@@ -7,7 +7,7 @@ export default {
77
key: "pipedrive-updated-lead-instant",
88
name: "Lead Updated (Instant)",
99
description: "Emit new event when a lead is updated.",
10-
version: "0.1.6",
10+
version: "0.1.7",
1111
type: "source",
1212
dedupe: "unique",
1313
methods: {
@@ -22,9 +22,10 @@ export default {
2222
return `Lead successfully updated: ${body.data.id}`;
2323
},
2424
async parseData(body) {
25-
return await parseData({
26-
fn: this.pipedrive.getDealCustomFields,
25+
return await formatCustomFieldDataFromSource({
2726
body,
27+
customFieldFn: this.pipedrive.getDealCustomFields,
28+
resourceFn: this.pipedrive.getLead,
2829
});
2930
},
3031
},

0 commit comments

Comments
 (0)