Skip to content

Commit e0910d2

Browse files
authored
15625 bug update pipedrive components to latest sdk api version (#15651)
* [BUG] Update Pipedrive components to latest SDK / API version #15625 All sources and actions refactored * pnpm update * update package.json version * pnpm update * pnpm update * some adjusts * remove yarn.lock * some adjusts * pnpm update
1 parent 1e69e81 commit e0910d2

File tree

25 files changed

+1231
-1163
lines changed

25 files changed

+1231
-1163
lines changed
Lines changed: 87 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
import { ConfigurationError } from "@pipedream/platform";
12
import constants from "../../common/constants.mjs";
2-
import utils from "../../common/utils.mjs";
3+
import { parseObject } from "../../common/utils.mjs";
34
import pipedriveApp from "../../pipedrive.app.mjs";
45

56
export default {
67
key: "pipedrive-add-activity",
78
name: "Add Activity",
89
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)",
9-
version: "0.1.6",
10+
version: "0.1.7",
1011
type: "action",
1112
props: {
1213
pipedriveApp,
@@ -15,22 +16,6 @@ export default {
1516
label: "Subject",
1617
description: "Subject of the activity",
1718
},
18-
done: {
19-
type: "string",
20-
label: "Done",
21-
description: "Whether the activity is done or not. 0 = Not done, 1 = Done",
22-
optional: true,
23-
options: [
24-
{
25-
label: "Not done",
26-
value: "0",
27-
},
28-
{
29-
label: "Done",
30-
value: "1",
31-
},
32-
],
33-
},
3419
type: {
3520
type: "string",
3621
label: "Type",
@@ -45,25 +30,7 @@ export default {
4530
}));
4631
},
4732
},
48-
dueDate: {
49-
type: "string",
50-
label: "Due Date",
51-
description: "Due date of the activity. Format: `YYYY-MM-DD`",
52-
optional: true,
53-
},
54-
dueTime: {
55-
type: "string",
56-
label: "Due Time",
57-
description: "Due time of the activity in UTC. Format: `HH:MM`",
58-
optional: true,
59-
},
60-
duration: {
61-
type: "string",
62-
label: "Duration",
63-
description: "Duration of the activity. Format: `HH:MM`",
64-
optional: true,
65-
},
66-
userId: {
33+
ownerId: {
6734
propDefinition: [
6835
pipedriveApp,
6936
"userId",
@@ -76,148 +43,159 @@ export default {
7643
"dealId",
7744
],
7845
},
79-
personId: {
46+
leadId: {
8047
propDefinition: [
8148
pipedriveApp,
82-
"personId",
49+
"leadId",
8350
],
84-
description: "ID of the person this activity will be associated with",
8551
},
86-
participants: {
87-
type: "string[]",
88-
label: "Participants",
89-
description: "List of multiple persons (participants) this activity will be associated with. If omitted, single participant from `person_id` field is used. It requires a structure as follows: `[{\"person_id\":1,\"primary_flag\":true}]`",
90-
optional: true,
52+
orgId: {
9153
propDefinition: [
9254
pipedriveApp,
93-
"personId",
55+
"organizationId",
9456
],
57+
description: "ID of the organization this activity will be associated with",
9558
},
96-
organizationId: {
59+
projectId: {
9760
propDefinition: [
9861
pipedriveApp,
99-
"organizationId",
62+
"projectId",
10063
],
101-
description: "ID of the organization this activity will be associated with",
64+
description: "ID of the project this activity will be associated with",
10265
},
103-
note: {
66+
dueDate: {
10467
type: "string",
105-
label: "Note",
106-
description: "Note of the activity (HTML format)",
68+
label: "Due Date",
69+
description: "Due date of the activity. Format: `YYYY-MM-DD`",
10770
optional: true,
10871
},
109-
location: {
72+
dueTime: {
11073
type: "string",
111-
label: "Location",
112-
description: "The address of the activity. Pipedrive will automatically check if the location matches a geo-location on Google maps.",
74+
label: "Due Time",
75+
description: "Due time of the activity in UTC. Format: `HH:MM`",
11376
optional: true,
11477
},
115-
publicDescription: {
78+
duration: {
11679
type: "string",
117-
label: "Public Description",
118-
description: "Additional details about the activity that will be synced to your external calendar. Unlike the note added to the activity, the description will be publicly visible to any guests added to the activity.",
80+
label: "Duration",
81+
description: "Duration of the activity. Format: `HH:MM`",
11982
optional: true,
12083
},
121-
busyFlag: {
84+
busy: {
12285
type: "boolean",
123-
label: "Busy Flag",
86+
label: "Busy",
12487
description: "Set the activity as 'Busy' or 'Free'. If the flag is set to true, your customers will not be able to book that time slot through any Scheduler links",
12588
optional: true,
12689
},
90+
done: {
91+
type: "boolean",
92+
label: "Done",
93+
description: "Whether the activity is done or not.",
94+
optional: true,
95+
},
96+
location: {
97+
type: "object",
98+
label: "Location",
99+
description: "The address of the activity. Pipedrive will automatically check if the location matches a geo-location on Google maps.",
100+
optional: true,
101+
},
102+
participants: {
103+
type: "string[]",
104+
label: "Participants",
105+
description: "List of multiple persons (participants) this activity will be associated with. If omitted, single participant from `person_id` field is used. It requires a structure as follows: `[{\"person_id\":1,\"primary\":true}]`",
106+
optional: true,
107+
propDefinition: [
108+
pipedriveApp,
109+
"personId",
110+
],
111+
},
127112
attendees: {
128113
type: "string[]",
129114
label: "Attendees",
130-
description: "Attendees of the activity. This can be either your existing Pipedrive contacts or an external email address. It requires a structure as follows: `[{\"email_address\":\"[email protected]\"}]` or `[{\"person_id\":1, \"email_address\":\"[email protected]\"}]`",
115+
description: "Attendees of the activity. This can be either your existing Pipedrive contacts or an external email address. It requires a structure as follows: `[{\"email\":\"[email protected]\"}]`",
131116
optional: true,
132117
async options({ prevContext }) {
133-
const {
134-
moreItemsInCollection,
135-
start,
136-
} = prevContext;
137-
138-
if (moreItemsInCollection === false) {
118+
if (prevContext?.cursor === false) {
139119
return [];
140120
}
141-
142121
const {
143122
data: persons,
144123
additional_data: additionalData,
145124
} = await this.pipedriveApp.getPersons({
146-
start,
125+
cursor: prevContext.cursor,
147126
limit: constants.DEFAULT_PAGE_LIMIT,
148127
});
149128

150-
const options =
151-
persons?.flatMap(({
152-
name, email,
153-
}) => email?.map(({ value }) => ({
129+
return {
130+
options: persons?.flatMap(({
131+
name, emails,
132+
}) => emails?.map(({ value }) => ({
154133
label: name,
155134
value,
156-
})).filter((option) => option?.value));
157-
158-
return {
159-
options,
135+
})).filter((option) => option?.value)),
160136
context: {
161-
moreItemsInCollection: additionalData.pagination.more_items_in_collection,
162-
start: additionalData.pagination.next_start,
137+
cursor: additionalData.next_cursor,
163138
},
164139
};
165140
},
166141
},
142+
publicDescription: {
143+
type: "string",
144+
label: "Public Description",
145+
description: "Additional details about the activity that will be synced to your external calendar. Unlike the note added to the activity, the description will be publicly visible to any guests added to the activity.",
146+
optional: true,
147+
},
148+
note: {
149+
type: "string",
150+
label: "Note",
151+
description: "Note of the activity (HTML format)",
152+
optional: true,
153+
},
167154
},
168155
async run({ $ }) {
169156
const {
170-
subject,
171-
type,
157+
pipedriveApp,
172158
dueDate,
173159
dueTime,
174-
duration,
175-
userId,
160+
ownerId,
176161
dealId,
177-
personId,
178-
organizationId,
179-
note,
162+
leadId,
163+
orgId,
164+
projectId,
180165
location,
166+
participants,
167+
attendees,
181168
publicDescription,
182-
busyFlag,
169+
...data
183170
} = this;
184171

185-
const participants = utils.parseOrUndefined(this.participants);
186-
const attendees = utils.parseOrUndefined(this.attendees);
187-
const done = utils.parseOrUndefined(this.done);
188-
189172
try {
190173
const resp =
191-
await this.pipedriveApp.addActivity({
192-
subject,
193-
done,
194-
type,
174+
await pipedriveApp.addActivity({
195175
due_date: dueDate,
196176
due_time: dueTime,
197-
duration,
198-
user_id: userId,
177+
owner_id: ownerId,
199178
deal_id: dealId,
200-
person_id: personId,
201-
participants: participants?.map((value, idx) => ({
179+
lead_id: leadId,
180+
participants: parseObject(participants)?.map((value, idx) => ({
202181
person_id: value,
203-
primary_flag: !idx,
182+
primary: !idx,
204183
})),
205-
org_id: organizationId,
206-
note,
207-
location,
184+
org_id: orgId,
185+
project_id: projectId,
186+
location: parseObject(location),
208187
public_description: publicDescription,
209-
busy_flag: busyFlag,
210-
attendees: attendees?.map((value) => ({
211-
email_address: value,
188+
attendees: parseObject(attendees)?.map((value) => ({
189+
email: value,
212190
})),
191+
...data,
213192
});
214193

215194
$.export("$summary", "Successfully added activity");
216195

217196
return resp;
218-
} catch (error) {
219-
console.error(error.context?.body || error);
220-
throw error.context?.body?.error || "Failed to add activity";
197+
} catch ({ error }) {
198+
throw new ConfigurationError(error);
221199
}
222200
},
223201
};

0 commit comments

Comments
 (0)