@activepieces/piece-pipedrive 0.3.5 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -6
- package/src/index.js +39 -5
- package/src/index.js.map +1 -1
- package/src/lib/actions/add-label-to-person.d.ts +4 -0
- package/src/lib/actions/add-label-to-person.js +46 -0
- package/src/lib/actions/add-label-to-person.js.map +1 -0
- package/src/lib/actions/add-product-to-deal.d.ts +12 -0
- package/src/lib/actions/add-product-to-deal.js +106 -0
- package/src/lib/actions/add-product-to-deal.js.map +1 -0
- package/src/lib/actions/create-deal.d.ts +17 -0
- package/src/lib/actions/create-deal.js +66 -0
- package/src/lib/actions/create-deal.js.map +1 -0
- package/src/lib/actions/create-lead.d.ts +13 -0
- package/src/lib/actions/create-lead.js +72 -0
- package/src/lib/actions/create-lead.js.map +1 -0
- package/src/lib/actions/create-organization.d.ts +8 -0
- package/src/lib/actions/create-organization.js +57 -0
- package/src/lib/actions/create-organization.js.map +1 -0
- package/src/lib/actions/create-person.d.ts +13 -0
- package/src/lib/actions/create-person.js +68 -0
- package/src/lib/actions/create-person.js.map +1 -0
- package/src/lib/actions/create-product.d.ts +15 -0
- package/src/lib/actions/create-product.js +109 -0
- package/src/lib/actions/create-product.js.map +1 -0
- package/src/lib/actions/update-deal.d.ts +18 -0
- package/src/lib/actions/update-deal.js +66 -0
- package/src/lib/actions/update-deal.js.map +1 -0
- package/src/lib/actions/update-lead.d.ts +14 -0
- package/src/lib/actions/update-lead.js +69 -0
- package/src/lib/actions/update-lead.js.map +1 -0
- package/src/lib/actions/update-organization.d.ts +9 -0
- package/src/lib/actions/update-organization.js +58 -0
- package/src/lib/actions/update-organization.js.map +1 -0
- package/src/lib/actions/update-person.d.ts +14 -0
- package/src/lib/actions/update-person.js +68 -0
- package/src/lib/actions/update-person.js.map +1 -0
- package/src/lib/common/index.d.ts +13 -0
- package/src/lib/common/index.js +92 -0
- package/src/lib/common/index.js.map +1 -1
- package/src/lib/common/props.d.ts +69 -0
- package/src/lib/common/props.js +738 -0
- package/src/lib/common/props.js.map +1 -0
- package/src/lib/common/types.d.ts +44 -3
- package/src/lib/trigger/new-deal.js +34 -18
- package/src/lib/trigger/new-deal.js.map +1 -1
- package/src/lib/trigger/new-lead.d.ts +2 -0
- package/src/lib/trigger/new-lead.js +124 -0
- package/src/lib/trigger/new-lead.js.map +1 -0
- package/src/lib/trigger/new-organization.d.ts +2 -0
- package/src/lib/trigger/new-organization.js +160 -0
- package/src/lib/trigger/new-organization.js.map +1 -0
- package/src/lib/trigger/new-person.js +35 -11
- package/src/lib/trigger/new-person.js.map +1 -1
- package/src/lib/trigger/updated-deal-stage.d.ts +8 -0
- package/src/lib/trigger/updated-deal-stage.js +288 -0
- package/src/lib/trigger/updated-deal-stage.js.map +1 -0
- package/src/lib/trigger/updated-deal.js +47 -20
- package/src/lib/trigger/updated-deal.js.map +1 -1
- package/src/lib/trigger/updated-organization.d.ts +2 -0
- package/src/lib/trigger/updated-organization.js +160 -0
- package/src/lib/trigger/updated-organization.js.map +1 -0
- package/src/lib/trigger/updated-person.js +35 -11
- package/src/lib/trigger/updated-person.js.map +1 -1
- package/src/lib/actions/add-person.action/add-person.action.d.ts +0 -8
- package/src/lib/actions/add-person.action/add-person.action.js +0 -179
- package/src/lib/actions/add-person.action/add-person.action.js.map +0 -1
|
@@ -0,0 +1,738 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.personCommonProps = exports.organizationCommonProps = exports.leadCommonProps = exports.dealCommonProps = exports.leadIdProp = exports.visibleToProp = exports.productIdProp = exports.dealIdProp = exports.leadLableIdsProp = exports.labelIdsProp = exports.personIdProp = exports.dealStageIdProp = exports.dealPipelineIdProp = exports.organizationIdProp = exports.ownerIdProp = exports.customFieldsProp = void 0;
|
|
4
|
+
exports.fetchProductsOptions = fetchProductsOptions;
|
|
5
|
+
exports.fetchDealsOptions = fetchDealsOptions;
|
|
6
|
+
exports.fetchLeadsOptions = fetchLeadsOptions;
|
|
7
|
+
exports.fetchPipelinesOptions = fetchPipelinesOptions;
|
|
8
|
+
exports.fetchPersonsOptions = fetchPersonsOptions;
|
|
9
|
+
exports.fetchOwnersOptions = fetchOwnersOptions;
|
|
10
|
+
exports.fetchOrganizationsOptions = fetchOrganizationsOptions;
|
|
11
|
+
exports.retriveObjectCustomProperties = retriveObjectCustomProperties;
|
|
12
|
+
const tslib_1 = require("tslib");
|
|
13
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
14
|
+
const _1 = require(".");
|
|
15
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
16
|
+
function fetchProductsOptions(auth) {
|
|
17
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const products = yield (0, _1.pipedrivePaginatedApiCall)({
|
|
19
|
+
accessToken: auth.access_token,
|
|
20
|
+
apiDomain: auth.data['api_domain'],
|
|
21
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
22
|
+
resourceUri: '/products',
|
|
23
|
+
query: {
|
|
24
|
+
sort: 'update_time DESC',
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
const options = [];
|
|
28
|
+
for (const product of products) {
|
|
29
|
+
options.push({
|
|
30
|
+
label: product.name,
|
|
31
|
+
value: product.id,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return options;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function fetchDealsOptions(auth) {
|
|
38
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const deals = yield (0, _1.pipedrivePaginatedApiCall)({
|
|
40
|
+
accessToken: auth.access_token,
|
|
41
|
+
apiDomain: auth.data['api_domain'],
|
|
42
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
43
|
+
resourceUri: '/deals',
|
|
44
|
+
query: {
|
|
45
|
+
sort: 'update_time DESC',
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
const options = [];
|
|
49
|
+
for (const deal of deals) {
|
|
50
|
+
options.push({
|
|
51
|
+
label: deal.title,
|
|
52
|
+
value: deal.id,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return options;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function fetchLeadsOptions(auth) {
|
|
59
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
const leads = yield (0, _1.pipedrivePaginatedApiCall)({
|
|
61
|
+
accessToken: auth.access_token,
|
|
62
|
+
apiDomain: auth.data['api_domain'],
|
|
63
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
64
|
+
resourceUri: '/leads',
|
|
65
|
+
query: {
|
|
66
|
+
sort: 'update_time DESC',
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
const options = [];
|
|
70
|
+
for (const lead of leads) {
|
|
71
|
+
options.push({
|
|
72
|
+
label: lead.title,
|
|
73
|
+
value: lead.id,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return options;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function fetchPipelinesOptions(auth) {
|
|
80
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
const pipelines = yield (0, _1.pipedriveApiCall)({
|
|
82
|
+
accessToken: auth.access_token,
|
|
83
|
+
apiDomain: auth.data['api_domain'],
|
|
84
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
85
|
+
resourceUri: '/pipelines:(id,name)',
|
|
86
|
+
});
|
|
87
|
+
const options = [];
|
|
88
|
+
for (const pipeline of pipelines.data) {
|
|
89
|
+
options.push({
|
|
90
|
+
label: pipeline.name,
|
|
91
|
+
value: pipeline.id,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return options;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function fetchPersonsOptions(auth) {
|
|
98
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const persons = yield (0, _1.pipedriveApiCall)({
|
|
100
|
+
accessToken: auth.access_token,
|
|
101
|
+
apiDomain: auth.data['api_domain'],
|
|
102
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
103
|
+
resourceUri: '/persons:(id,name)',
|
|
104
|
+
query: {
|
|
105
|
+
sort: 'update_time DESC',
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
const options = [];
|
|
109
|
+
for (const person of persons.data) {
|
|
110
|
+
options.push({
|
|
111
|
+
label: person.name,
|
|
112
|
+
value: person.id,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return options;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function fetchOwnersOptions(auth) {
|
|
119
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
const users = yield (0, _1.pipedriveApiCall)({
|
|
121
|
+
accessToken: auth.access_token,
|
|
122
|
+
apiDomain: auth.data['api_domain'],
|
|
123
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
124
|
+
resourceUri: '/users:(id,email)',
|
|
125
|
+
query: {
|
|
126
|
+
sort: 'update_time DESC',
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
const options = [];
|
|
130
|
+
for (const user of users.data) {
|
|
131
|
+
options.push({
|
|
132
|
+
label: user.email,
|
|
133
|
+
value: user.id,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return options;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function fetchOrganizationsOptions(auth) {
|
|
140
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
const organizations = yield (0, _1.pipedrivePaginatedApiCall)({
|
|
142
|
+
accessToken: auth.access_token,
|
|
143
|
+
apiDomain: auth.data['api_domain'],
|
|
144
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
145
|
+
resourceUri: '/organizations:(id,name)',
|
|
146
|
+
query: {
|
|
147
|
+
sort: 'update_time DESC',
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
const options = [];
|
|
151
|
+
for (const org of organizations) {
|
|
152
|
+
options.push({
|
|
153
|
+
label: org.name,
|
|
154
|
+
value: org.id,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
return options;
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
function createPropertyDefinition(property) {
|
|
161
|
+
switch (property.field_type) {
|
|
162
|
+
case 'varchar':
|
|
163
|
+
case 'varchar_auto':
|
|
164
|
+
return pieces_framework_1.Property.ShortText({
|
|
165
|
+
displayName: property.name,
|
|
166
|
+
required: false,
|
|
167
|
+
});
|
|
168
|
+
case 'text':
|
|
169
|
+
case 'address':
|
|
170
|
+
return pieces_framework_1.Property.LongText({
|
|
171
|
+
displayName: property.name,
|
|
172
|
+
required: false,
|
|
173
|
+
});
|
|
174
|
+
case 'enum':
|
|
175
|
+
return pieces_framework_1.Property.StaticDropdown({
|
|
176
|
+
displayName: property.name,
|
|
177
|
+
required: false,
|
|
178
|
+
options: {
|
|
179
|
+
disabled: false,
|
|
180
|
+
options: property.options
|
|
181
|
+
? property.options.map((option) => {
|
|
182
|
+
return {
|
|
183
|
+
label: option.label,
|
|
184
|
+
value: option.id.toString(),
|
|
185
|
+
};
|
|
186
|
+
})
|
|
187
|
+
: [],
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
case 'set':
|
|
191
|
+
return pieces_framework_1.Property.StaticMultiSelectDropdown({
|
|
192
|
+
displayName: property.name,
|
|
193
|
+
required: false,
|
|
194
|
+
options: {
|
|
195
|
+
disabled: false,
|
|
196
|
+
options: property.options
|
|
197
|
+
? property.options.map((option) => {
|
|
198
|
+
return {
|
|
199
|
+
label: option.label,
|
|
200
|
+
value: option.id.toString(),
|
|
201
|
+
};
|
|
202
|
+
})
|
|
203
|
+
: [],
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
case 'double':
|
|
207
|
+
case 'monetary':
|
|
208
|
+
return pieces_framework_1.Property.Number({
|
|
209
|
+
displayName: property.name,
|
|
210
|
+
required: false,
|
|
211
|
+
});
|
|
212
|
+
case 'time':
|
|
213
|
+
case 'timerange':
|
|
214
|
+
return pieces_framework_1.Property.ShortText({
|
|
215
|
+
displayName: property.name,
|
|
216
|
+
description: 'Please enter time in HH:mm:ss format.',
|
|
217
|
+
required: false,
|
|
218
|
+
});
|
|
219
|
+
case 'int':
|
|
220
|
+
return pieces_framework_1.Property.Number({
|
|
221
|
+
displayName: property.name,
|
|
222
|
+
required: false,
|
|
223
|
+
});
|
|
224
|
+
case 'date':
|
|
225
|
+
case 'daterange':
|
|
226
|
+
return pieces_framework_1.Property.DateTime({
|
|
227
|
+
displayName: property.name,
|
|
228
|
+
description: 'Please enter date in YYYY-MM-DD format.',
|
|
229
|
+
required: false,
|
|
230
|
+
});
|
|
231
|
+
default:
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function retriveObjectCustomProperties(auth, objectType) {
|
|
236
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
237
|
+
let endpoint = '';
|
|
238
|
+
switch (objectType) {
|
|
239
|
+
case 'person':
|
|
240
|
+
endpoint = '/personFields';
|
|
241
|
+
break;
|
|
242
|
+
case 'deal':
|
|
243
|
+
case 'lead':
|
|
244
|
+
endpoint = '/dealFields';
|
|
245
|
+
break;
|
|
246
|
+
case 'organization':
|
|
247
|
+
endpoint = '/organizationFields';
|
|
248
|
+
break;
|
|
249
|
+
case 'product':
|
|
250
|
+
endpoint = '/productFields';
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
const customFields = yield (0, _1.pipedrivePaginatedApiCall)({
|
|
254
|
+
accessToken: auth.access_token,
|
|
255
|
+
apiDomain: auth.data['api_domain'],
|
|
256
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
257
|
+
resourceUri: endpoint,
|
|
258
|
+
});
|
|
259
|
+
const props = {};
|
|
260
|
+
for (const field of customFields) {
|
|
261
|
+
if (!field.edit_flag) {
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
const propertyDefinition = createPropertyDefinition(field);
|
|
265
|
+
if (propertyDefinition) {
|
|
266
|
+
props[field.key] = propertyDefinition;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return props;
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
const customFieldsProp = (objectType) => pieces_framework_1.Property.DynamicProperties({
|
|
273
|
+
displayName: 'Custom Fields',
|
|
274
|
+
refreshers: [],
|
|
275
|
+
required: false,
|
|
276
|
+
props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
277
|
+
if (!auth)
|
|
278
|
+
return {};
|
|
279
|
+
const authValue = auth;
|
|
280
|
+
return yield retriveObjectCustomProperties(authValue, objectType);
|
|
281
|
+
}),
|
|
282
|
+
});
|
|
283
|
+
exports.customFieldsProp = customFieldsProp;
|
|
284
|
+
const ownerIdProp = (required = false) => pieces_framework_1.Property.Dropdown({
|
|
285
|
+
displayName: 'Owner',
|
|
286
|
+
refreshers: [],
|
|
287
|
+
required,
|
|
288
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
289
|
+
if (!auth) {
|
|
290
|
+
return {
|
|
291
|
+
disabled: true,
|
|
292
|
+
options: [],
|
|
293
|
+
placeholder: 'Please connect your account.',
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
const authValue = auth;
|
|
297
|
+
const options = yield fetchOwnersOptions(authValue);
|
|
298
|
+
return {
|
|
299
|
+
disabled: false,
|
|
300
|
+
options,
|
|
301
|
+
};
|
|
302
|
+
}),
|
|
303
|
+
});
|
|
304
|
+
exports.ownerIdProp = ownerIdProp;
|
|
305
|
+
const organizationIdProp = (required = false) => pieces_framework_1.Property.Dropdown({
|
|
306
|
+
displayName: 'Organization',
|
|
307
|
+
refreshers: [],
|
|
308
|
+
required,
|
|
309
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
310
|
+
if (!auth) {
|
|
311
|
+
return {
|
|
312
|
+
disabled: true,
|
|
313
|
+
options: [],
|
|
314
|
+
placeholder: 'Please connect your account.',
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
const authValue = auth;
|
|
318
|
+
const options = yield fetchOrganizationsOptions(authValue);
|
|
319
|
+
return {
|
|
320
|
+
disabled: false,
|
|
321
|
+
options,
|
|
322
|
+
};
|
|
323
|
+
}),
|
|
324
|
+
});
|
|
325
|
+
exports.organizationIdProp = organizationIdProp;
|
|
326
|
+
const dealPipelineIdProp = (required = false) => pieces_framework_1.Property.Dropdown({
|
|
327
|
+
displayName: 'Pipeline',
|
|
328
|
+
refreshers: [],
|
|
329
|
+
required,
|
|
330
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
331
|
+
if (!auth) {
|
|
332
|
+
return {
|
|
333
|
+
disabled: true,
|
|
334
|
+
options: [],
|
|
335
|
+
placeholder: 'Please connect your account.',
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
const authValue = auth;
|
|
339
|
+
const options = yield fetchPipelinesOptions(authValue);
|
|
340
|
+
return {
|
|
341
|
+
disabled: false,
|
|
342
|
+
options,
|
|
343
|
+
};
|
|
344
|
+
}),
|
|
345
|
+
});
|
|
346
|
+
exports.dealPipelineIdProp = dealPipelineIdProp;
|
|
347
|
+
const dealStageIdProp = (required = false) => pieces_framework_1.Property.Dropdown({
|
|
348
|
+
displayName: 'Stage',
|
|
349
|
+
description: 'If a stage is chosen above, the pipeline field will be ignored.',
|
|
350
|
+
required,
|
|
351
|
+
refreshers: [],
|
|
352
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
353
|
+
if (!auth) {
|
|
354
|
+
return {
|
|
355
|
+
placeholder: 'Please connect your account.',
|
|
356
|
+
disabled: true,
|
|
357
|
+
options: [],
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
const authValue = auth;
|
|
361
|
+
const response = yield (0, _1.pipedrivePaginatedApiCall)({
|
|
362
|
+
accessToken: authValue.access_token,
|
|
363
|
+
apiDomain: authValue.data['api_domain'],
|
|
364
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
365
|
+
resourceUri: '/stages',
|
|
366
|
+
});
|
|
367
|
+
const options = [];
|
|
368
|
+
for (const stage of response) {
|
|
369
|
+
options.push({
|
|
370
|
+
label: `${stage.name} (${stage.pipeline_name})`,
|
|
371
|
+
value: stage.id,
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
return {
|
|
375
|
+
disabled: false,
|
|
376
|
+
options,
|
|
377
|
+
};
|
|
378
|
+
}),
|
|
379
|
+
});
|
|
380
|
+
exports.dealStageIdProp = dealStageIdProp;
|
|
381
|
+
const personIdProp = (required = false) => pieces_framework_1.Property.Dropdown({
|
|
382
|
+
displayName: 'Person',
|
|
383
|
+
refreshers: [],
|
|
384
|
+
required,
|
|
385
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
386
|
+
if (!auth) {
|
|
387
|
+
return {
|
|
388
|
+
disabled: true,
|
|
389
|
+
options: [],
|
|
390
|
+
placeholder: 'Please connect your account.',
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
const authValue = auth;
|
|
394
|
+
const options = yield fetchPersonsOptions(authValue);
|
|
395
|
+
return {
|
|
396
|
+
disabled: false,
|
|
397
|
+
options,
|
|
398
|
+
};
|
|
399
|
+
}),
|
|
400
|
+
});
|
|
401
|
+
exports.personIdProp = personIdProp;
|
|
402
|
+
const labelIdsProp = (objectType, labelFieldName, required = false) => pieces_framework_1.Property.MultiSelectDropdown({
|
|
403
|
+
displayName: 'Label',
|
|
404
|
+
required,
|
|
405
|
+
refreshers: [],
|
|
406
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
407
|
+
var _b;
|
|
408
|
+
if (!auth) {
|
|
409
|
+
return {
|
|
410
|
+
disabled: true,
|
|
411
|
+
options: [],
|
|
412
|
+
placeholder: 'Please connect your account.',
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
const authValue = auth;
|
|
416
|
+
let endpoint = '';
|
|
417
|
+
switch (objectType) {
|
|
418
|
+
case 'person':
|
|
419
|
+
endpoint = '/personFields:(key,name,options)';
|
|
420
|
+
break;
|
|
421
|
+
case 'deal':
|
|
422
|
+
endpoint = '/dealFields:(key,name,options)';
|
|
423
|
+
break;
|
|
424
|
+
case 'organization':
|
|
425
|
+
endpoint = '/organizationFields:(key,name,options)';
|
|
426
|
+
break;
|
|
427
|
+
}
|
|
428
|
+
const customFieldsResponse = yield (0, _1.pipedrivePaginatedApiCall)({
|
|
429
|
+
accessToken: authValue.access_token,
|
|
430
|
+
apiDomain: authValue.data['api_domain'],
|
|
431
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
432
|
+
resourceUri: endpoint,
|
|
433
|
+
});
|
|
434
|
+
const labelField = customFieldsResponse.find((field) => field.key === labelFieldName);
|
|
435
|
+
const options = [];
|
|
436
|
+
if (labelField) {
|
|
437
|
+
for (const option of (_b = labelField.options) !== null && _b !== void 0 ? _b : []) {
|
|
438
|
+
options.push({
|
|
439
|
+
label: option.label,
|
|
440
|
+
value: option.id,
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
return {
|
|
445
|
+
disabled: false,
|
|
446
|
+
options,
|
|
447
|
+
};
|
|
448
|
+
}),
|
|
449
|
+
});
|
|
450
|
+
exports.labelIdsProp = labelIdsProp;
|
|
451
|
+
const leadLableIdsProp = (required = false) => pieces_framework_1.Property.MultiSelectDropdown({
|
|
452
|
+
displayName: 'Label',
|
|
453
|
+
required,
|
|
454
|
+
refreshers: [],
|
|
455
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
456
|
+
if (!auth) {
|
|
457
|
+
return {
|
|
458
|
+
disabled: true,
|
|
459
|
+
options: [],
|
|
460
|
+
placeholder: 'Please connect your account.',
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
const authValue = auth;
|
|
464
|
+
const customFieldsResponse = yield (0, _1.pipedriveApiCall)({
|
|
465
|
+
accessToken: authValue.access_token,
|
|
466
|
+
apiDomain: authValue.data['api_domain'],
|
|
467
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
468
|
+
resourceUri: '/leadLabels',
|
|
469
|
+
});
|
|
470
|
+
const options = [];
|
|
471
|
+
for (const option of customFieldsResponse.data) {
|
|
472
|
+
options.push({
|
|
473
|
+
label: `${option.name} (${option.color})`,
|
|
474
|
+
value: option.id,
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
return {
|
|
478
|
+
disabled: false,
|
|
479
|
+
options,
|
|
480
|
+
};
|
|
481
|
+
}),
|
|
482
|
+
});
|
|
483
|
+
exports.leadLableIdsProp = leadLableIdsProp;
|
|
484
|
+
const dealIdProp = (required = false) => pieces_framework_1.Property.Dropdown({
|
|
485
|
+
displayName: 'Deal',
|
|
486
|
+
refreshers: [],
|
|
487
|
+
required,
|
|
488
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
489
|
+
if (!auth) {
|
|
490
|
+
return {
|
|
491
|
+
disabled: true,
|
|
492
|
+
options: [],
|
|
493
|
+
placeholder: 'Please connect your account.',
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
const authValue = auth;
|
|
497
|
+
const options = yield fetchDealsOptions(authValue);
|
|
498
|
+
return {
|
|
499
|
+
disabled: false,
|
|
500
|
+
options,
|
|
501
|
+
};
|
|
502
|
+
}),
|
|
503
|
+
});
|
|
504
|
+
exports.dealIdProp = dealIdProp;
|
|
505
|
+
const productIdProp = (required = false) => pieces_framework_1.Property.Dropdown({
|
|
506
|
+
displayName: 'Product',
|
|
507
|
+
refreshers: [],
|
|
508
|
+
required,
|
|
509
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
510
|
+
if (!auth) {
|
|
511
|
+
return {
|
|
512
|
+
disabled: true,
|
|
513
|
+
options: [],
|
|
514
|
+
placeholder: 'Please connect your account.',
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
const authValue = auth;
|
|
518
|
+
const options = yield fetchProductsOptions(authValue);
|
|
519
|
+
return {
|
|
520
|
+
disabled: false,
|
|
521
|
+
options,
|
|
522
|
+
};
|
|
523
|
+
}),
|
|
524
|
+
});
|
|
525
|
+
exports.productIdProp = productIdProp;
|
|
526
|
+
exports.visibleToProp = pieces_framework_1.Property.StaticDropdown({
|
|
527
|
+
displayName: 'Visible To',
|
|
528
|
+
required: false,
|
|
529
|
+
options: {
|
|
530
|
+
disabled: false,
|
|
531
|
+
options: [
|
|
532
|
+
{
|
|
533
|
+
label: 'Item Owner',
|
|
534
|
+
value: 1,
|
|
535
|
+
},
|
|
536
|
+
{
|
|
537
|
+
label: 'All Users',
|
|
538
|
+
value: 3,
|
|
539
|
+
},
|
|
540
|
+
],
|
|
541
|
+
},
|
|
542
|
+
});
|
|
543
|
+
const leadIdProp = (required = false) => pieces_framework_1.Property.Dropdown({
|
|
544
|
+
displayName: 'Lead',
|
|
545
|
+
refreshers: [],
|
|
546
|
+
required,
|
|
547
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
548
|
+
if (!auth) {
|
|
549
|
+
return {
|
|
550
|
+
disabled: true,
|
|
551
|
+
options: [],
|
|
552
|
+
placeholder: 'Please connect your account.',
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
const authValue = auth;
|
|
556
|
+
const options = yield fetchLeadsOptions(authValue);
|
|
557
|
+
return {
|
|
558
|
+
disabled: false,
|
|
559
|
+
options,
|
|
560
|
+
};
|
|
561
|
+
}),
|
|
562
|
+
});
|
|
563
|
+
exports.leadIdProp = leadIdProp;
|
|
564
|
+
exports.dealCommonProps = {
|
|
565
|
+
creationTime: pieces_framework_1.Property.DateTime({
|
|
566
|
+
displayName: 'Creation Time',
|
|
567
|
+
required: false,
|
|
568
|
+
}),
|
|
569
|
+
status: pieces_framework_1.Property.StaticDropdown({
|
|
570
|
+
displayName: 'Status',
|
|
571
|
+
required: false,
|
|
572
|
+
options: {
|
|
573
|
+
disabled: false,
|
|
574
|
+
options: [
|
|
575
|
+
{
|
|
576
|
+
label: 'Open',
|
|
577
|
+
value: 'open',
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
label: 'Won',
|
|
581
|
+
value: 'won',
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
label: 'Lost',
|
|
585
|
+
value: 'lost',
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
label: 'Deleted',
|
|
589
|
+
value: 'deleted',
|
|
590
|
+
},
|
|
591
|
+
],
|
|
592
|
+
},
|
|
593
|
+
}),
|
|
594
|
+
stageId: (0, exports.dealStageIdProp)(false),
|
|
595
|
+
pipelineId: (0, exports.dealPipelineIdProp)(false),
|
|
596
|
+
ownerId: (0, exports.ownerIdProp)(false),
|
|
597
|
+
organizationId: (0, exports.organizationIdProp)(false),
|
|
598
|
+
personId: (0, exports.personIdProp)(false),
|
|
599
|
+
labelIds: (0, exports.labelIdsProp)('deal', 'label', false),
|
|
600
|
+
probability: pieces_framework_1.Property.Number({
|
|
601
|
+
displayName: 'Probability',
|
|
602
|
+
required: false,
|
|
603
|
+
}),
|
|
604
|
+
expectedCloseDate: pieces_framework_1.Property.ShortText({
|
|
605
|
+
displayName: 'Expected Close Date',
|
|
606
|
+
required: false,
|
|
607
|
+
description: 'Please enter date in YYYY-MM-DD format.',
|
|
608
|
+
}),
|
|
609
|
+
dealValue: pieces_framework_1.Property.Number({
|
|
610
|
+
displayName: 'Value',
|
|
611
|
+
required: false,
|
|
612
|
+
}),
|
|
613
|
+
dealValueCurrency: pieces_framework_1.Property.ShortText({
|
|
614
|
+
displayName: 'Currency',
|
|
615
|
+
required: false,
|
|
616
|
+
description: 'Please enter currency code.',
|
|
617
|
+
}),
|
|
618
|
+
visibleTo: exports.visibleToProp,
|
|
619
|
+
customfields: (0, exports.customFieldsProp)('deal'),
|
|
620
|
+
};
|
|
621
|
+
exports.leadCommonProps = {
|
|
622
|
+
ownerId: (0, exports.ownerIdProp)(false),
|
|
623
|
+
organizationId: (0, exports.organizationIdProp)(false),
|
|
624
|
+
personId: (0, exports.personIdProp)(false),
|
|
625
|
+
labelIds: (0, exports.leadLableIdsProp)(false),
|
|
626
|
+
expectedCloseDate: pieces_framework_1.Property.ShortText({
|
|
627
|
+
displayName: 'Expected Close Date',
|
|
628
|
+
required: false,
|
|
629
|
+
description: 'Please enter date in YYYY-MM-DD format.',
|
|
630
|
+
}),
|
|
631
|
+
visibleTo: exports.visibleToProp,
|
|
632
|
+
channel: pieces_framework_1.Property.MultiSelectDropdown({
|
|
633
|
+
displayName: 'Channel',
|
|
634
|
+
required: false,
|
|
635
|
+
refreshers: [],
|
|
636
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
637
|
+
var _b;
|
|
638
|
+
if (!auth) {
|
|
639
|
+
return {
|
|
640
|
+
disabled: true,
|
|
641
|
+
options: [],
|
|
642
|
+
placeholder: 'Please connect your account.',
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
const authValue = auth;
|
|
646
|
+
const customFieldsResponse = yield (0, _1.pipedrivePaginatedApiCall)({
|
|
647
|
+
accessToken: authValue.access_token,
|
|
648
|
+
apiDomain: authValue.data['api_domain'],
|
|
649
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
650
|
+
resourceUri: '/dealFields:(key,name,options)',
|
|
651
|
+
});
|
|
652
|
+
const channelField = customFieldsResponse.find((field) => field.key === 'channel');
|
|
653
|
+
const options = [];
|
|
654
|
+
if (channelField) {
|
|
655
|
+
for (const option of (_b = channelField.options) !== null && _b !== void 0 ? _b : []) {
|
|
656
|
+
options.push({
|
|
657
|
+
label: option.label,
|
|
658
|
+
value: option.id,
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
return {
|
|
663
|
+
disabled: false,
|
|
664
|
+
options,
|
|
665
|
+
};
|
|
666
|
+
}),
|
|
667
|
+
}),
|
|
668
|
+
leadValue: pieces_framework_1.Property.Number({
|
|
669
|
+
displayName: 'Lead Value',
|
|
670
|
+
required: false,
|
|
671
|
+
}),
|
|
672
|
+
leadValueCurrency: pieces_framework_1.Property.ShortText({
|
|
673
|
+
displayName: 'Lead Value Currency',
|
|
674
|
+
required: false,
|
|
675
|
+
description: 'Please enter currency code.',
|
|
676
|
+
}),
|
|
677
|
+
customfields: (0, exports.customFieldsProp)('lead'),
|
|
678
|
+
};
|
|
679
|
+
exports.organizationCommonProps = {
|
|
680
|
+
ownerId: (0, exports.ownerIdProp)(false),
|
|
681
|
+
visibleTo: exports.visibleToProp,
|
|
682
|
+
labelIds: (0, exports.labelIdsProp)('organization', 'label_ids', false),
|
|
683
|
+
address: pieces_framework_1.Property.LongText({
|
|
684
|
+
displayName: 'Address',
|
|
685
|
+
required: false,
|
|
686
|
+
}),
|
|
687
|
+
customfields: (0, exports.customFieldsProp)('organization'),
|
|
688
|
+
};
|
|
689
|
+
exports.personCommonProps = {
|
|
690
|
+
ownerId: (0, exports.ownerIdProp)(false),
|
|
691
|
+
organizationId: (0, exports.organizationIdProp)(false),
|
|
692
|
+
email: pieces_framework_1.Property.Array({
|
|
693
|
+
displayName: 'Email',
|
|
694
|
+
required: false,
|
|
695
|
+
}),
|
|
696
|
+
phone: pieces_framework_1.Property.Array({
|
|
697
|
+
displayName: 'Phone',
|
|
698
|
+
required: false,
|
|
699
|
+
}),
|
|
700
|
+
labelIds: (0, exports.labelIdsProp)('person', 'label_ids', false),
|
|
701
|
+
firstName: pieces_framework_1.Property.ShortText({
|
|
702
|
+
displayName: 'First Name',
|
|
703
|
+
required: false,
|
|
704
|
+
}),
|
|
705
|
+
lastName: pieces_framework_1.Property.ShortText({
|
|
706
|
+
displayName: 'Last Name',
|
|
707
|
+
required: false,
|
|
708
|
+
}),
|
|
709
|
+
visibleTo: exports.visibleToProp,
|
|
710
|
+
marketing_status: pieces_framework_1.Property.StaticDropdown({
|
|
711
|
+
displayName: 'Marketing Status',
|
|
712
|
+
description: 'Marketing opt-in status',
|
|
713
|
+
required: false,
|
|
714
|
+
options: {
|
|
715
|
+
disabled: false,
|
|
716
|
+
options: [
|
|
717
|
+
{
|
|
718
|
+
label: 'No Consent',
|
|
719
|
+
value: 'no_consent',
|
|
720
|
+
},
|
|
721
|
+
{
|
|
722
|
+
label: 'Unsubscribed',
|
|
723
|
+
value: 'unsubscribed',
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
label: 'Subscribed',
|
|
727
|
+
value: 'subscribed',
|
|
728
|
+
},
|
|
729
|
+
{
|
|
730
|
+
label: 'Archived',
|
|
731
|
+
value: 'archived',
|
|
732
|
+
},
|
|
733
|
+
],
|
|
734
|
+
},
|
|
735
|
+
}),
|
|
736
|
+
customfields: (0, exports.customFieldsProp)('person')
|
|
737
|
+
};
|
|
738
|
+
//# sourceMappingURL=props.js.map
|