@activepieces/piece-pipedrive 0.3.6 → 0.4.1

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.
Files changed (124) hide show
  1. package/package.json +6 -4
  2. package/src/index.js +89 -5
  3. package/src/index.js.map +1 -1
  4. package/src/lib/actions/add-follower.d.ts +5 -0
  5. package/src/lib/actions/add-follower.js +119 -0
  6. package/src/lib/actions/add-follower.js.map +1 -0
  7. package/src/lib/actions/add-label-to-person.d.ts +4 -0
  8. package/src/lib/actions/add-label-to-person.js +46 -0
  9. package/src/lib/actions/add-label-to-person.js.map +1 -0
  10. package/src/lib/actions/add-product-to-deal.d.ts +12 -0
  11. package/src/lib/actions/add-product-to-deal.js +106 -0
  12. package/src/lib/actions/add-product-to-deal.js.map +1 -0
  13. package/src/lib/actions/attach-file.d.ts +9 -0
  14. package/src/lib/actions/attach-file.js +62 -0
  15. package/src/lib/actions/attach-file.js.map +1 -0
  16. package/src/lib/actions/create-activity.d.ts +16 -0
  17. package/src/lib/actions/create-activity.js +54 -0
  18. package/src/lib/actions/create-activity.js.map +1 -0
  19. package/src/lib/actions/create-deal.d.ts +17 -0
  20. package/src/lib/actions/create-deal.js +69 -0
  21. package/src/lib/actions/create-deal.js.map +1 -0
  22. package/src/lib/actions/create-lead.d.ts +13 -0
  23. package/src/lib/actions/create-lead.js +75 -0
  24. package/src/lib/actions/create-lead.js.map +1 -0
  25. package/src/lib/actions/create-note.d.ts +11 -0
  26. package/src/lib/actions/create-note.js +73 -0
  27. package/src/lib/actions/create-note.js.map +1 -0
  28. package/src/lib/actions/create-organization.d.ts +8 -0
  29. package/src/lib/actions/create-organization.js +57 -0
  30. package/src/lib/actions/create-organization.js.map +1 -0
  31. package/src/lib/actions/create-person.d.ts +13 -0
  32. package/src/lib/actions/create-person.js +68 -0
  33. package/src/lib/actions/create-person.js.map +1 -0
  34. package/src/lib/actions/create-product.d.ts +15 -0
  35. package/src/lib/actions/create-product.js +109 -0
  36. package/src/lib/actions/create-product.js.map +1 -0
  37. package/src/lib/actions/find-activity.d.ts +8 -0
  38. package/src/lib/actions/find-activity.js +85 -0
  39. package/src/lib/actions/find-activity.js.map +1 -0
  40. package/src/lib/actions/find-deal.d.ts +4 -0
  41. package/src/lib/actions/find-deal.js +104 -0
  42. package/src/lib/actions/find-deal.js.map +1 -0
  43. package/src/lib/actions/find-deals-associated-with-person.d.ts +3 -0
  44. package/src/lib/actions/find-deals-associated-with-person.js +53 -0
  45. package/src/lib/actions/find-deals-associated-with-person.js.map +1 -0
  46. package/src/lib/actions/find-notes.d.ts +4 -0
  47. package/src/lib/actions/find-notes.js +70 -0
  48. package/src/lib/actions/find-notes.js.map +1 -0
  49. package/src/lib/actions/find-organization.d.ts +4 -0
  50. package/src/lib/actions/find-organization.js +104 -0
  51. package/src/lib/actions/find-organization.js.map +1 -0
  52. package/src/lib/actions/find-person.d.ts +4 -0
  53. package/src/lib/actions/find-person.js +104 -0
  54. package/src/lib/actions/find-person.js.map +1 -0
  55. package/src/lib/actions/find-product.d.ts +3 -0
  56. package/src/lib/actions/find-product.js +59 -0
  57. package/src/lib/actions/find-product.js.map +1 -0
  58. package/src/lib/actions/find-products.d.ts +4 -0
  59. package/src/lib/actions/find-products.js +73 -0
  60. package/src/lib/actions/find-products.js.map +1 -0
  61. package/src/lib/actions/find-user.d.ts +4 -0
  62. package/src/lib/actions/find-user.js +57 -0
  63. package/src/lib/actions/find-user.js.map +1 -0
  64. package/src/lib/actions/get-note.d.ts +3 -0
  65. package/src/lib/actions/get-note.js +39 -0
  66. package/src/lib/actions/get-note.js.map +1 -0
  67. package/src/lib/actions/get-product.d.ts +3 -0
  68. package/src/lib/actions/get-product.js +50 -0
  69. package/src/lib/actions/get-product.js.map +1 -0
  70. package/src/lib/actions/update-activity.d.ts +17 -0
  71. package/src/lib/actions/update-activity.js +57 -0
  72. package/src/lib/actions/update-activity.js.map +1 -0
  73. package/src/lib/actions/update-deal.d.ts +18 -0
  74. package/src/lib/actions/update-deal.js +69 -0
  75. package/src/lib/actions/update-deal.js.map +1 -0
  76. package/src/lib/actions/update-lead.d.ts +14 -0
  77. package/src/lib/actions/update-lead.js +72 -0
  78. package/src/lib/actions/update-lead.js.map +1 -0
  79. package/src/lib/actions/update-organization.d.ts +9 -0
  80. package/src/lib/actions/update-organization.js +58 -0
  81. package/src/lib/actions/update-organization.js.map +1 -0
  82. package/src/lib/actions/update-person.d.ts +14 -0
  83. package/src/lib/actions/update-person.js +68 -0
  84. package/src/lib/actions/update-person.js.map +1 -0
  85. package/src/lib/common/index.js +26 -3
  86. package/src/lib/common/index.js.map +1 -1
  87. package/src/lib/common/props.d.ts +92 -0
  88. package/src/lib/common/props.js +988 -0
  89. package/src/lib/common/props.js.map +1 -0
  90. package/src/lib/common/types.d.ts +24 -2
  91. package/src/lib/trigger/activity-matching-filter.d.ts +8 -0
  92. package/src/lib/trigger/activity-matching-filter.js +178 -0
  93. package/src/lib/trigger/activity-matching-filter.js.map +1 -0
  94. package/src/lib/trigger/deal-matching-filter.d.ts +11 -0
  95. package/src/lib/trigger/deal-matching-filter.js +287 -0
  96. package/src/lib/trigger/deal-matching-filter.js.map +1 -0
  97. package/src/lib/trigger/new-deal.js +1 -1
  98. package/src/lib/trigger/new-deal.js.map +1 -1
  99. package/src/lib/trigger/new-lead.d.ts +2 -0
  100. package/src/lib/trigger/new-lead.js +124 -0
  101. package/src/lib/trigger/new-lead.js.map +1 -0
  102. package/src/lib/trigger/new-note.d.ts +2 -0
  103. package/src/lib/trigger/new-note.js +113 -0
  104. package/src/lib/trigger/new-note.js.map +1 -0
  105. package/src/lib/trigger/new-organization.d.ts +2 -0
  106. package/src/lib/trigger/new-organization.js +160 -0
  107. package/src/lib/trigger/new-organization.js.map +1 -0
  108. package/src/lib/trigger/new-person.js.map +1 -1
  109. package/src/lib/trigger/organization-matching-filter.d.ts +8 -0
  110. package/src/lib/trigger/organization-matching-filter.js +174 -0
  111. package/src/lib/trigger/organization-matching-filter.js.map +1 -0
  112. package/src/lib/trigger/person-matching-filter.d.ts +8 -0
  113. package/src/lib/trigger/person-matching-filter.js +203 -0
  114. package/src/lib/trigger/person-matching-filter.js.map +1 -0
  115. package/src/lib/trigger/updated-deal-stage.d.ts +8 -0
  116. package/src/lib/trigger/updated-deal-stage.js +288 -0
  117. package/src/lib/trigger/updated-deal-stage.js.map +1 -0
  118. package/src/lib/trigger/updated-organization.d.ts +2 -0
  119. package/src/lib/trigger/updated-organization.js +160 -0
  120. package/src/lib/trigger/updated-organization.js.map +1 -0
  121. package/src/lib/trigger/updated-person.js.map +1 -1
  122. package/src/lib/actions/add-person.action/add-person.action.d.ts +0 -8
  123. package/src/lib/actions/add-person.action/add-person.action.js +0 -179
  124. package/src/lib/actions/add-person.action/add-person.action.js.map +0 -1
@@ -0,0 +1,988 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.activityCommonProps = exports.personCommonProps = exports.organizationCommonProps = exports.leadCommonProps = exports.dealCommonProps = exports.activityTypeIdProp = exports.leadIdProp = exports.visibleToProp = exports.productIdProp = exports.dealIdProp = exports.leadlabeIdsProp = exports.labelIdsProp = exports.personIdProp = exports.dealStageIdProp = exports.dealPipelineIdProp = exports.organizationIdProp = exports.filterIdProp = exports.ownerIdProp = exports.customFieldsProp = exports.searchFieldValueProp = exports.searchFieldProp = void 0;
4
+ exports.fetchFiltersOptions = fetchFiltersOptions;
5
+ exports.fetchProductsOptions = fetchProductsOptions;
6
+ exports.fetchDealsOptions = fetchDealsOptions;
7
+ exports.fetchLeadsOptions = fetchLeadsOptions;
8
+ exports.fetchActivityTypesOptions = fetchActivityTypesOptions;
9
+ exports.fetchPipelinesOptions = fetchPipelinesOptions;
10
+ exports.fetchPersonsOptions = fetchPersonsOptions;
11
+ exports.fetchOwnersOptions = fetchOwnersOptions;
12
+ exports.fetchOrganizationsOptions = fetchOrganizationsOptions;
13
+ exports.createPropertyDefinition = createPropertyDefinition;
14
+ exports.retrieveObjectCustomProperties = retrieveObjectCustomProperties;
15
+ const tslib_1 = require("tslib");
16
+ const pieces_common_1 = require("@activepieces/pieces-common");
17
+ const _1 = require(".");
18
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
19
+ const shared_1 = require("@activepieces/shared");
20
+ function fetchFiltersOptions(auth, type) {
21
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
22
+ const filters = yield (0, _1.pipedriveApiCall)({
23
+ accessToken: auth.access_token,
24
+ apiDomain: auth.data['api_domain'],
25
+ method: pieces_common_1.HttpMethod.GET,
26
+ resourceUri: '/filters',
27
+ query: {
28
+ type: type,
29
+ },
30
+ });
31
+ const options = [];
32
+ for (const filter of filters.data) {
33
+ options.push({
34
+ label: filter.name,
35
+ value: filter.id,
36
+ });
37
+ }
38
+ return options;
39
+ });
40
+ }
41
+ function fetchProductsOptions(auth) {
42
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
43
+ const products = yield (0, _1.pipedrivePaginatedApiCall)({
44
+ accessToken: auth.access_token,
45
+ apiDomain: auth.data['api_domain'],
46
+ method: pieces_common_1.HttpMethod.GET,
47
+ resourceUri: '/products',
48
+ query: {
49
+ sort: 'update_time DESC',
50
+ },
51
+ });
52
+ const options = [];
53
+ for (const product of products) {
54
+ options.push({
55
+ label: product.name,
56
+ value: product.id,
57
+ });
58
+ }
59
+ return options;
60
+ });
61
+ }
62
+ function fetchDealsOptions(auth) {
63
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
64
+ const deals = yield (0, _1.pipedrivePaginatedApiCall)({
65
+ accessToken: auth.access_token,
66
+ apiDomain: auth.data['api_domain'],
67
+ method: pieces_common_1.HttpMethod.GET,
68
+ resourceUri: '/deals',
69
+ query: {
70
+ sort: 'update_time DESC',
71
+ },
72
+ });
73
+ const options = [];
74
+ for (const deal of deals) {
75
+ options.push({
76
+ label: deal.title,
77
+ value: deal.id,
78
+ });
79
+ }
80
+ return options;
81
+ });
82
+ }
83
+ function fetchLeadsOptions(auth) {
84
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
85
+ const leads = yield (0, _1.pipedrivePaginatedApiCall)({
86
+ accessToken: auth.access_token,
87
+ apiDomain: auth.data['api_domain'],
88
+ method: pieces_common_1.HttpMethod.GET,
89
+ resourceUri: '/leads',
90
+ query: {
91
+ sort: 'update_time DESC',
92
+ },
93
+ });
94
+ const options = [];
95
+ for (const lead of leads) {
96
+ options.push({
97
+ label: lead.title,
98
+ value: lead.id,
99
+ });
100
+ }
101
+ return options;
102
+ });
103
+ }
104
+ function fetchActivityTypesOptions(auth) {
105
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
106
+ const activityTypes = yield (0, _1.pipedriveApiCall)({
107
+ accessToken: auth.access_token,
108
+ apiDomain: auth.data['api_domain'],
109
+ method: pieces_common_1.HttpMethod.GET,
110
+ resourceUri: '/activityTypes:(key_string,name)',
111
+ });
112
+ const options = [];
113
+ for (const type of activityTypes.data) {
114
+ options.push({
115
+ label: type.name,
116
+ value: type.key_string,
117
+ });
118
+ }
119
+ return options;
120
+ });
121
+ }
122
+ function fetchPipelinesOptions(auth) {
123
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
124
+ const pipelines = yield (0, _1.pipedriveApiCall)({
125
+ accessToken: auth.access_token,
126
+ apiDomain: auth.data['api_domain'],
127
+ method: pieces_common_1.HttpMethod.GET,
128
+ resourceUri: '/pipelines:(id,name)',
129
+ });
130
+ const options = [];
131
+ for (const pipeline of pipelines.data) {
132
+ options.push({
133
+ label: pipeline.name,
134
+ value: pipeline.id,
135
+ });
136
+ }
137
+ return options;
138
+ });
139
+ }
140
+ function fetchPersonsOptions(auth) {
141
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
142
+ const persons = yield (0, _1.pipedriveApiCall)({
143
+ accessToken: auth.access_token,
144
+ apiDomain: auth.data['api_domain'],
145
+ method: pieces_common_1.HttpMethod.GET,
146
+ resourceUri: '/persons:(id,name)',
147
+ query: {
148
+ sort: 'update_time DESC',
149
+ },
150
+ });
151
+ const options = [];
152
+ for (const person of persons.data) {
153
+ options.push({
154
+ label: person.name,
155
+ value: person.id,
156
+ });
157
+ }
158
+ return options;
159
+ });
160
+ }
161
+ function fetchOwnersOptions(auth) {
162
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
163
+ const users = yield (0, _1.pipedriveApiCall)({
164
+ accessToken: auth.access_token,
165
+ apiDomain: auth.data['api_domain'],
166
+ method: pieces_common_1.HttpMethod.GET,
167
+ resourceUri: '/users:(id,email)',
168
+ query: {
169
+ sort: 'update_time DESC',
170
+ },
171
+ });
172
+ const options = [];
173
+ for (const user of users.data) {
174
+ options.push({
175
+ label: user.email,
176
+ value: user.id,
177
+ });
178
+ }
179
+ return options;
180
+ });
181
+ }
182
+ function fetchOrganizationsOptions(auth) {
183
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
184
+ const organizations = yield (0, _1.pipedrivePaginatedApiCall)({
185
+ accessToken: auth.access_token,
186
+ apiDomain: auth.data['api_domain'],
187
+ method: pieces_common_1.HttpMethod.GET,
188
+ resourceUri: '/organizations:(id,name)',
189
+ query: {
190
+ sort: 'update_time DESC',
191
+ },
192
+ });
193
+ const options = [];
194
+ for (const org of organizations) {
195
+ options.push({
196
+ label: org.name,
197
+ value: org.id,
198
+ });
199
+ }
200
+ return options;
201
+ });
202
+ }
203
+ function createPropertyDefinition(property) {
204
+ switch (property.field_type) {
205
+ case 'varchar':
206
+ case 'varchar_auto':
207
+ return pieces_framework_1.Property.ShortText({
208
+ displayName: property.name,
209
+ required: false,
210
+ });
211
+ case 'text':
212
+ case 'address':
213
+ return pieces_framework_1.Property.LongText({
214
+ displayName: property.name,
215
+ required: false,
216
+ });
217
+ case 'enum':
218
+ return pieces_framework_1.Property.StaticDropdown({
219
+ displayName: property.name,
220
+ required: false,
221
+ options: {
222
+ disabled: false,
223
+ options: property.options
224
+ ? property.options.map((option) => {
225
+ return {
226
+ label: option.label,
227
+ value: option.id.toString(),
228
+ };
229
+ })
230
+ : [],
231
+ },
232
+ });
233
+ case 'set':
234
+ return pieces_framework_1.Property.StaticMultiSelectDropdown({
235
+ displayName: property.name,
236
+ required: false,
237
+ options: {
238
+ disabled: false,
239
+ options: property.options
240
+ ? property.options.map((option) => {
241
+ return {
242
+ label: option.label,
243
+ value: option.id.toString(),
244
+ };
245
+ })
246
+ : [],
247
+ },
248
+ });
249
+ case 'double':
250
+ case 'monetary':
251
+ return pieces_framework_1.Property.Number({
252
+ displayName: property.name,
253
+ required: false,
254
+ });
255
+ case 'time':
256
+ case 'timerange':
257
+ return pieces_framework_1.Property.ShortText({
258
+ displayName: property.name,
259
+ description: 'Please enter time in HH:mm:ss format.',
260
+ required: false,
261
+ });
262
+ case 'int':
263
+ return pieces_framework_1.Property.Number({
264
+ displayName: property.name,
265
+ required: false,
266
+ });
267
+ case 'date':
268
+ case 'daterange':
269
+ return pieces_framework_1.Property.DateTime({
270
+ displayName: property.name,
271
+ description: 'Please enter date in YYYY-MM-DD format.',
272
+ required: false,
273
+ });
274
+ default:
275
+ return null;
276
+ }
277
+ }
278
+ function retrieveObjectCustomProperties(auth, objectType) {
279
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
280
+ let endpoint = '';
281
+ switch (objectType) {
282
+ case 'person':
283
+ endpoint = '/personFields';
284
+ break;
285
+ case 'deal':
286
+ case 'lead':
287
+ endpoint = '/dealFields';
288
+ break;
289
+ case 'organization':
290
+ endpoint = '/organizationFields';
291
+ break;
292
+ case 'product':
293
+ endpoint = '/productFields';
294
+ break;
295
+ }
296
+ const customFields = yield (0, _1.pipedrivePaginatedApiCall)({
297
+ accessToken: auth.access_token,
298
+ apiDomain: auth.data['api_domain'],
299
+ method: pieces_common_1.HttpMethod.GET,
300
+ resourceUri: endpoint,
301
+ });
302
+ const props = {};
303
+ for (const field of customFields) {
304
+ if (!field.edit_flag) {
305
+ continue;
306
+ }
307
+ const propertyDefinition = createPropertyDefinition(field);
308
+ if (propertyDefinition) {
309
+ props[field.key] = propertyDefinition;
310
+ }
311
+ }
312
+ return props;
313
+ });
314
+ }
315
+ const searchFieldProp = (objectType) => pieces_framework_1.Property.Dropdown({
316
+ displayName: 'Field to search by',
317
+ required: true,
318
+ refreshers: [],
319
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
320
+ if (!auth) {
321
+ return {
322
+ disabled: true,
323
+ options: [],
324
+ placeholder: 'Please connect your account.',
325
+ };
326
+ }
327
+ const authValue = auth;
328
+ let endpoint = '';
329
+ switch (objectType) {
330
+ case 'person':
331
+ endpoint = '/personFields';
332
+ break;
333
+ case 'deal':
334
+ case 'lead':
335
+ endpoint = '/dealFields';
336
+ break;
337
+ case 'organization':
338
+ endpoint = '/organizationFields';
339
+ break;
340
+ case 'product':
341
+ endpoint = '/productFields';
342
+ break;
343
+ }
344
+ const response = yield (0, _1.pipedrivePaginatedApiCall)({
345
+ accessToken: authValue.access_token,
346
+ apiDomain: authValue.data['api_domain'],
347
+ method: pieces_common_1.HttpMethod.GET,
348
+ resourceUri: endpoint,
349
+ });
350
+ const options = [];
351
+ for (const field of response) {
352
+ if (!(0, shared_1.isNil)(field.id)) {
353
+ options.push({
354
+ label: field.name,
355
+ value: field.id,
356
+ });
357
+ }
358
+ }
359
+ return {
360
+ disabled: false,
361
+ options,
362
+ };
363
+ }),
364
+ });
365
+ exports.searchFieldProp = searchFieldProp;
366
+ const searchFieldValueProp = (objectType) => pieces_framework_1.Property.DynamicProperties({
367
+ displayName: 'Field Value',
368
+ required: true,
369
+ refreshers: ['searchField'],
370
+ props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, searchField }) {
371
+ if (!auth || !searchField)
372
+ return {};
373
+ const authValue = auth;
374
+ const props = {};
375
+ let endpoint = '';
376
+ switch (objectType) {
377
+ case 'person':
378
+ endpoint = '/personFields';
379
+ break;
380
+ case 'deal':
381
+ case 'lead':
382
+ endpoint = '/dealFields';
383
+ break;
384
+ case 'organization':
385
+ endpoint = '/organizationFields';
386
+ break;
387
+ case 'product':
388
+ endpoint = '/productFields';
389
+ break;
390
+ }
391
+ const response = yield (0, _1.pipedriveApiCall)({
392
+ accessToken: authValue.access_token,
393
+ apiDomain: authValue.data['api_domain'],
394
+ method: pieces_common_1.HttpMethod.GET,
395
+ resourceUri: `${endpoint}/${searchField}`,
396
+ });
397
+ const propertyDefinition = response.data.field_type === 'set'
398
+ ? pieces_framework_1.Property.StaticDropdown({
399
+ displayName: response.data.name,
400
+ required: false,
401
+ options: {
402
+ disabled: false,
403
+ options: response.data.options
404
+ ? response.data.options.map((option) => {
405
+ return {
406
+ label: option.label,
407
+ value: option.id.toString(),
408
+ };
409
+ })
410
+ : [],
411
+ },
412
+ })
413
+ : createPropertyDefinition(response.data);
414
+ if (propertyDefinition) {
415
+ props['field_value'] = propertyDefinition;
416
+ }
417
+ else {
418
+ props['field_value'] = pieces_framework_1.Property.ShortText({
419
+ displayName: response.data.name,
420
+ required: false,
421
+ });
422
+ }
423
+ return props;
424
+ }),
425
+ });
426
+ exports.searchFieldValueProp = searchFieldValueProp;
427
+ const customFieldsProp = (objectType) => pieces_framework_1.Property.DynamicProperties({
428
+ displayName: 'Custom Fields',
429
+ refreshers: [],
430
+ required: false,
431
+ props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
432
+ if (!auth)
433
+ return {};
434
+ const authValue = auth;
435
+ return yield retrieveObjectCustomProperties(authValue, objectType);
436
+ }),
437
+ });
438
+ exports.customFieldsProp = customFieldsProp;
439
+ const ownerIdProp = (displayName, required = false) => pieces_framework_1.Property.Dropdown({
440
+ displayName,
441
+ refreshers: [],
442
+ required,
443
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
444
+ if (!auth) {
445
+ return {
446
+ disabled: true,
447
+ options: [],
448
+ placeholder: 'Please connect your account.',
449
+ };
450
+ }
451
+ const authValue = auth;
452
+ const options = yield fetchOwnersOptions(authValue);
453
+ return {
454
+ disabled: false,
455
+ options,
456
+ };
457
+ }),
458
+ });
459
+ exports.ownerIdProp = ownerIdProp;
460
+ const filterIdProp = (type, required = false) => pieces_framework_1.Property.Dropdown({
461
+ displayName: 'Filter',
462
+ refreshers: [],
463
+ required,
464
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
465
+ if (!auth) {
466
+ return {
467
+ disabled: true,
468
+ options: [],
469
+ placeholder: 'Please connect your account.',
470
+ };
471
+ }
472
+ const authValue = auth;
473
+ const options = yield fetchFiltersOptions(authValue, type);
474
+ return {
475
+ disabled: false,
476
+ options,
477
+ };
478
+ }),
479
+ });
480
+ exports.filterIdProp = filterIdProp;
481
+ const organizationIdProp = (required = false) => pieces_framework_1.Property.Dropdown({
482
+ displayName: 'Organization',
483
+ refreshers: [],
484
+ required,
485
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
486
+ if (!auth) {
487
+ return {
488
+ disabled: true,
489
+ options: [],
490
+ placeholder: 'Please connect your account.',
491
+ };
492
+ }
493
+ const authValue = auth;
494
+ const options = yield fetchOrganizationsOptions(authValue);
495
+ return {
496
+ disabled: false,
497
+ options,
498
+ };
499
+ }),
500
+ });
501
+ exports.organizationIdProp = organizationIdProp;
502
+ const dealPipelineIdProp = (required = false) => pieces_framework_1.Property.Dropdown({
503
+ displayName: 'Pipeline',
504
+ refreshers: [],
505
+ required,
506
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
507
+ if (!auth) {
508
+ return {
509
+ disabled: true,
510
+ options: [],
511
+ placeholder: 'Please connect your account.',
512
+ };
513
+ }
514
+ const authValue = auth;
515
+ const options = yield fetchPipelinesOptions(authValue);
516
+ return {
517
+ disabled: false,
518
+ options,
519
+ };
520
+ }),
521
+ });
522
+ exports.dealPipelineIdProp = dealPipelineIdProp;
523
+ const dealStageIdProp = (required = false) => pieces_framework_1.Property.Dropdown({
524
+ displayName: 'Stage',
525
+ description: 'If a stage is chosen above, the pipeline field will be ignored.',
526
+ required,
527
+ refreshers: [],
528
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
529
+ if (!auth) {
530
+ return {
531
+ placeholder: 'Please connect your account.',
532
+ disabled: true,
533
+ options: [],
534
+ };
535
+ }
536
+ const authValue = auth;
537
+ const response = yield (0, _1.pipedrivePaginatedApiCall)({
538
+ accessToken: authValue.access_token,
539
+ apiDomain: authValue.data['api_domain'],
540
+ method: pieces_common_1.HttpMethod.GET,
541
+ resourceUri: '/stages',
542
+ });
543
+ const options = [];
544
+ for (const stage of response) {
545
+ options.push({
546
+ label: `${stage.name} (${stage.pipeline_name})`,
547
+ value: stage.id,
548
+ });
549
+ }
550
+ return {
551
+ disabled: false,
552
+ options,
553
+ };
554
+ }),
555
+ });
556
+ exports.dealStageIdProp = dealStageIdProp;
557
+ const personIdProp = (required = false) => pieces_framework_1.Property.Dropdown({
558
+ displayName: 'Person',
559
+ refreshers: [],
560
+ required,
561
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
562
+ if (!auth) {
563
+ return {
564
+ disabled: true,
565
+ options: [],
566
+ placeholder: 'Please connect your account.',
567
+ };
568
+ }
569
+ const authValue = auth;
570
+ const options = yield fetchPersonsOptions(authValue);
571
+ return {
572
+ disabled: false,
573
+ options,
574
+ };
575
+ }),
576
+ });
577
+ exports.personIdProp = personIdProp;
578
+ const labelIdsProp = (objectType, labelFieldName, required = false) => pieces_framework_1.Property.MultiSelectDropdown({
579
+ displayName: 'Label',
580
+ required,
581
+ refreshers: [],
582
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
583
+ var _b;
584
+ if (!auth) {
585
+ return {
586
+ disabled: true,
587
+ options: [],
588
+ placeholder: 'Please connect your account.',
589
+ };
590
+ }
591
+ const authValue = auth;
592
+ let endpoint = '';
593
+ switch (objectType) {
594
+ case 'person':
595
+ endpoint = '/personFields:(key,name,options)';
596
+ break;
597
+ case 'deal':
598
+ endpoint = '/dealFields:(key,name,options)';
599
+ break;
600
+ case 'organization':
601
+ endpoint = '/organizationFields:(key,name,options)';
602
+ break;
603
+ }
604
+ const customFieldsResponse = yield (0, _1.pipedrivePaginatedApiCall)({
605
+ accessToken: authValue.access_token,
606
+ apiDomain: authValue.data['api_domain'],
607
+ method: pieces_common_1.HttpMethod.GET,
608
+ resourceUri: endpoint,
609
+ });
610
+ const labelField = customFieldsResponse.find((field) => field.key === labelFieldName);
611
+ const options = [];
612
+ if (labelField) {
613
+ for (const option of (_b = labelField.options) !== null && _b !== void 0 ? _b : []) {
614
+ options.push({
615
+ label: option.label,
616
+ value: option.id,
617
+ });
618
+ }
619
+ }
620
+ return {
621
+ disabled: false,
622
+ options,
623
+ };
624
+ }),
625
+ });
626
+ exports.labelIdsProp = labelIdsProp;
627
+ const leadlabeIdsProp = (required = false) => pieces_framework_1.Property.MultiSelectDropdown({
628
+ displayName: 'Label',
629
+ required,
630
+ refreshers: [],
631
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
632
+ if (!auth) {
633
+ return {
634
+ disabled: true,
635
+ options: [],
636
+ placeholder: 'Please connect your account.',
637
+ };
638
+ }
639
+ const authValue = auth;
640
+ const customFieldsResponse = yield (0, _1.pipedriveApiCall)({
641
+ accessToken: authValue.access_token,
642
+ apiDomain: authValue.data['api_domain'],
643
+ method: pieces_common_1.HttpMethod.GET,
644
+ resourceUri: '/leadLabels',
645
+ });
646
+ const options = [];
647
+ for (const option of customFieldsResponse.data) {
648
+ options.push({
649
+ label: `${option.name} (${option.color})`,
650
+ value: option.id,
651
+ });
652
+ }
653
+ return {
654
+ disabled: false,
655
+ options,
656
+ };
657
+ }),
658
+ });
659
+ exports.leadlabeIdsProp = leadlabeIdsProp;
660
+ const dealIdProp = (required = false) => pieces_framework_1.Property.Dropdown({
661
+ displayName: 'Deal',
662
+ refreshers: [],
663
+ required,
664
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
665
+ if (!auth) {
666
+ return {
667
+ disabled: true,
668
+ options: [],
669
+ placeholder: 'Please connect your account.',
670
+ };
671
+ }
672
+ const authValue = auth;
673
+ const options = yield fetchDealsOptions(authValue);
674
+ return {
675
+ disabled: false,
676
+ options,
677
+ };
678
+ }),
679
+ });
680
+ exports.dealIdProp = dealIdProp;
681
+ const productIdProp = (required = false) => pieces_framework_1.Property.Dropdown({
682
+ displayName: 'Product',
683
+ refreshers: [],
684
+ required,
685
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
686
+ if (!auth) {
687
+ return {
688
+ disabled: true,
689
+ options: [],
690
+ placeholder: 'Please connect your account.',
691
+ };
692
+ }
693
+ const authValue = auth;
694
+ const options = yield fetchProductsOptions(authValue);
695
+ return {
696
+ disabled: false,
697
+ options,
698
+ };
699
+ }),
700
+ });
701
+ exports.productIdProp = productIdProp;
702
+ exports.visibleToProp = pieces_framework_1.Property.StaticDropdown({
703
+ displayName: 'Visible To',
704
+ required: false,
705
+ options: {
706
+ disabled: false,
707
+ options: [
708
+ {
709
+ label: 'Item Owner',
710
+ value: 1,
711
+ },
712
+ {
713
+ label: 'All Users',
714
+ value: 3,
715
+ },
716
+ ],
717
+ },
718
+ });
719
+ const leadIdProp = (required = false) => pieces_framework_1.Property.Dropdown({
720
+ displayName: 'Lead',
721
+ refreshers: [],
722
+ required,
723
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
724
+ if (!auth) {
725
+ return {
726
+ disabled: true,
727
+ options: [],
728
+ placeholder: 'Please connect your account.',
729
+ };
730
+ }
731
+ const authValue = auth;
732
+ const options = yield fetchLeadsOptions(authValue);
733
+ return {
734
+ disabled: false,
735
+ options,
736
+ };
737
+ }),
738
+ });
739
+ exports.leadIdProp = leadIdProp;
740
+ const activityTypeIdProp = (required = false) => pieces_framework_1.Property.Dropdown({
741
+ displayName: 'Activity Type',
742
+ refreshers: [],
743
+ required,
744
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
745
+ if (!auth) {
746
+ return {
747
+ disabled: true,
748
+ options: [],
749
+ placeholder: 'Please connect your account.',
750
+ };
751
+ }
752
+ const authValue = auth;
753
+ const options = yield fetchActivityTypesOptions(authValue);
754
+ return {
755
+ disabled: false,
756
+ options,
757
+ };
758
+ }),
759
+ });
760
+ exports.activityTypeIdProp = activityTypeIdProp;
761
+ exports.dealCommonProps = {
762
+ creationTime: pieces_framework_1.Property.DateTime({
763
+ displayName: 'Creation Time',
764
+ required: false,
765
+ }),
766
+ status: pieces_framework_1.Property.StaticDropdown({
767
+ displayName: 'Status',
768
+ required: false,
769
+ options: {
770
+ disabled: false,
771
+ options: [
772
+ {
773
+ label: 'Open',
774
+ value: 'open',
775
+ },
776
+ {
777
+ label: 'Won',
778
+ value: 'won',
779
+ },
780
+ {
781
+ label: 'Lost',
782
+ value: 'lost',
783
+ },
784
+ {
785
+ label: 'Deleted',
786
+ value: 'deleted',
787
+ },
788
+ ],
789
+ },
790
+ }),
791
+ stageId: (0, exports.dealStageIdProp)(false),
792
+ pipelineId: (0, exports.dealPipelineIdProp)(false),
793
+ ownerId: (0, exports.ownerIdProp)('Owner', false),
794
+ organizationId: (0, exports.organizationIdProp)(false),
795
+ personId: (0, exports.personIdProp)(false),
796
+ labelIds: (0, exports.labelIdsProp)('deal', 'label', false),
797
+ probability: pieces_framework_1.Property.Number({
798
+ displayName: 'Probability',
799
+ required: false,
800
+ }),
801
+ expectedCloseDate: pieces_framework_1.Property.DateTime({
802
+ displayName: 'Expected Close Date',
803
+ required: false,
804
+ description: 'Please enter date in YYYY-MM-DD format.',
805
+ }),
806
+ dealValue: pieces_framework_1.Property.Number({
807
+ displayName: 'Value',
808
+ required: false,
809
+ }),
810
+ dealValueCurrency: pieces_framework_1.Property.ShortText({
811
+ displayName: 'Currency',
812
+ required: false,
813
+ description: 'Please enter currency code.',
814
+ }),
815
+ visibleTo: exports.visibleToProp,
816
+ customfields: (0, exports.customFieldsProp)('deal'),
817
+ };
818
+ exports.leadCommonProps = {
819
+ ownerId: (0, exports.ownerIdProp)('Owner', false),
820
+ organizationId: (0, exports.organizationIdProp)(false),
821
+ personId: (0, exports.personIdProp)(false),
822
+ labelIds: (0, exports.leadlabeIdsProp)(false),
823
+ expectedCloseDate: pieces_framework_1.Property.DateTime({
824
+ displayName: 'Expected Close Date',
825
+ required: false,
826
+ description: 'Please enter date in YYYY-MM-DD format.',
827
+ }),
828
+ visibleTo: exports.visibleToProp,
829
+ channel: pieces_framework_1.Property.MultiSelectDropdown({
830
+ displayName: 'Channel',
831
+ required: false,
832
+ refreshers: [],
833
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
834
+ var _b;
835
+ if (!auth) {
836
+ return {
837
+ disabled: true,
838
+ options: [],
839
+ placeholder: 'Please connect your account.',
840
+ };
841
+ }
842
+ const authValue = auth;
843
+ const customFieldsResponse = yield (0, _1.pipedrivePaginatedApiCall)({
844
+ accessToken: authValue.access_token,
845
+ apiDomain: authValue.data['api_domain'],
846
+ method: pieces_common_1.HttpMethod.GET,
847
+ resourceUri: '/dealFields:(key,name,options)',
848
+ });
849
+ const channelField = customFieldsResponse.find((field) => field.key === 'channel');
850
+ const options = [];
851
+ if (channelField) {
852
+ for (const option of (_b = channelField.options) !== null && _b !== void 0 ? _b : []) {
853
+ options.push({
854
+ label: option.label,
855
+ value: option.id,
856
+ });
857
+ }
858
+ }
859
+ return {
860
+ disabled: false,
861
+ options,
862
+ };
863
+ }),
864
+ }),
865
+ leadValue: pieces_framework_1.Property.Number({
866
+ displayName: 'Lead Value',
867
+ required: false,
868
+ }),
869
+ leadValueCurrency: pieces_framework_1.Property.ShortText({
870
+ displayName: 'Lead Value Currency',
871
+ required: false,
872
+ description: 'Please enter currency code.',
873
+ }),
874
+ customfields: (0, exports.customFieldsProp)('lead'),
875
+ };
876
+ exports.organizationCommonProps = {
877
+ ownerId: (0, exports.ownerIdProp)('Owner', false),
878
+ visibleTo: exports.visibleToProp,
879
+ labelIds: (0, exports.labelIdsProp)('organization', 'label_ids', false),
880
+ address: pieces_framework_1.Property.LongText({
881
+ displayName: 'Address',
882
+ required: false,
883
+ }),
884
+ customfields: (0, exports.customFieldsProp)('organization'),
885
+ };
886
+ exports.personCommonProps = {
887
+ ownerId: (0, exports.ownerIdProp)('Owner', false),
888
+ organizationId: (0, exports.organizationIdProp)(false),
889
+ email: pieces_framework_1.Property.Array({
890
+ displayName: 'Email',
891
+ required: false,
892
+ }),
893
+ phone: pieces_framework_1.Property.Array({
894
+ displayName: 'Phone',
895
+ required: false,
896
+ }),
897
+ labelIds: (0, exports.labelIdsProp)('person', 'label_ids', false),
898
+ firstName: pieces_framework_1.Property.ShortText({
899
+ displayName: 'First Name',
900
+ required: false,
901
+ }),
902
+ lastName: pieces_framework_1.Property.ShortText({
903
+ displayName: 'Last Name',
904
+ required: false,
905
+ }),
906
+ visibleTo: exports.visibleToProp,
907
+ marketing_status: pieces_framework_1.Property.StaticDropdown({
908
+ displayName: 'Marketing Status',
909
+ description: 'Marketing opt-in status',
910
+ required: false,
911
+ options: {
912
+ disabled: false,
913
+ options: [
914
+ {
915
+ label: 'No Consent',
916
+ value: 'no_consent',
917
+ },
918
+ {
919
+ label: 'Unsubscribed',
920
+ value: 'unsubscribed',
921
+ },
922
+ {
923
+ label: 'Subscribed',
924
+ value: 'subscribed',
925
+ },
926
+ {
927
+ label: 'Archived',
928
+ value: 'archived',
929
+ },
930
+ ],
931
+ },
932
+ }),
933
+ customfields: (0, exports.customFieldsProp)('person'),
934
+ };
935
+ exports.activityCommonProps = {
936
+ organizationId: (0, exports.organizationIdProp)(false),
937
+ personId: (0, exports.personIdProp)(false),
938
+ dealId: (0, exports.dealIdProp)(false),
939
+ leadId: (0, exports.leadIdProp)(false),
940
+ assignTo: (0, exports.ownerIdProp)('Assign To', false),
941
+ type: (0, exports.activityTypeIdProp)(false),
942
+ dueDate: pieces_framework_1.Property.DateTime({
943
+ displayName: 'Due Date',
944
+ required: false,
945
+ description: 'Please enter date in YYYY-MM-DD format.',
946
+ }),
947
+ dueTime: pieces_framework_1.Property.ShortText({
948
+ displayName: 'Due Time',
949
+ required: false,
950
+ description: 'Please enter time in HH:MM format.',
951
+ }),
952
+ duration: pieces_framework_1.Property.ShortText({
953
+ displayName: 'Duration',
954
+ required: false,
955
+ description: 'Please enter time in HH:MM format.',
956
+ }),
957
+ idDone: pieces_framework_1.Property.Checkbox({
958
+ displayName: 'Mark as Done?',
959
+ required: false,
960
+ defaultValue: false,
961
+ }),
962
+ isBusy: pieces_framework_1.Property.StaticDropdown({
963
+ displayName: 'Free or Busy',
964
+ required: false,
965
+ options: {
966
+ disabled: false,
967
+ options: [
968
+ {
969
+ label: 'Free',
970
+ value: 'free',
971
+ },
972
+ {
973
+ label: 'Busy',
974
+ value: 'busy',
975
+ },
976
+ ],
977
+ },
978
+ }),
979
+ note: pieces_framework_1.Property.LongText({
980
+ displayName: 'Note',
981
+ required: false,
982
+ }),
983
+ publicDescription: pieces_framework_1.Property.LongText({
984
+ displayName: 'Public Description',
985
+ required: false,
986
+ }),
987
+ };
988
+ //# sourceMappingURL=props.js.map