@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.
Files changed (66) hide show
  1. package/package.json +8 -6
  2. package/src/index.js +39 -5
  3. package/src/index.js.map +1 -1
  4. package/src/lib/actions/add-label-to-person.d.ts +4 -0
  5. package/src/lib/actions/add-label-to-person.js +46 -0
  6. package/src/lib/actions/add-label-to-person.js.map +1 -0
  7. package/src/lib/actions/add-product-to-deal.d.ts +12 -0
  8. package/src/lib/actions/add-product-to-deal.js +106 -0
  9. package/src/lib/actions/add-product-to-deal.js.map +1 -0
  10. package/src/lib/actions/create-deal.d.ts +17 -0
  11. package/src/lib/actions/create-deal.js +66 -0
  12. package/src/lib/actions/create-deal.js.map +1 -0
  13. package/src/lib/actions/create-lead.d.ts +13 -0
  14. package/src/lib/actions/create-lead.js +72 -0
  15. package/src/lib/actions/create-lead.js.map +1 -0
  16. package/src/lib/actions/create-organization.d.ts +8 -0
  17. package/src/lib/actions/create-organization.js +57 -0
  18. package/src/lib/actions/create-organization.js.map +1 -0
  19. package/src/lib/actions/create-person.d.ts +13 -0
  20. package/src/lib/actions/create-person.js +68 -0
  21. package/src/lib/actions/create-person.js.map +1 -0
  22. package/src/lib/actions/create-product.d.ts +15 -0
  23. package/src/lib/actions/create-product.js +109 -0
  24. package/src/lib/actions/create-product.js.map +1 -0
  25. package/src/lib/actions/update-deal.d.ts +18 -0
  26. package/src/lib/actions/update-deal.js +66 -0
  27. package/src/lib/actions/update-deal.js.map +1 -0
  28. package/src/lib/actions/update-lead.d.ts +14 -0
  29. package/src/lib/actions/update-lead.js +69 -0
  30. package/src/lib/actions/update-lead.js.map +1 -0
  31. package/src/lib/actions/update-organization.d.ts +9 -0
  32. package/src/lib/actions/update-organization.js +58 -0
  33. package/src/lib/actions/update-organization.js.map +1 -0
  34. package/src/lib/actions/update-person.d.ts +14 -0
  35. package/src/lib/actions/update-person.js +68 -0
  36. package/src/lib/actions/update-person.js.map +1 -0
  37. package/src/lib/common/index.d.ts +13 -0
  38. package/src/lib/common/index.js +92 -0
  39. package/src/lib/common/index.js.map +1 -1
  40. package/src/lib/common/props.d.ts +69 -0
  41. package/src/lib/common/props.js +738 -0
  42. package/src/lib/common/props.js.map +1 -0
  43. package/src/lib/common/types.d.ts +44 -3
  44. package/src/lib/trigger/new-deal.js +34 -18
  45. package/src/lib/trigger/new-deal.js.map +1 -1
  46. package/src/lib/trigger/new-lead.d.ts +2 -0
  47. package/src/lib/trigger/new-lead.js +124 -0
  48. package/src/lib/trigger/new-lead.js.map +1 -0
  49. package/src/lib/trigger/new-organization.d.ts +2 -0
  50. package/src/lib/trigger/new-organization.js +160 -0
  51. package/src/lib/trigger/new-organization.js.map +1 -0
  52. package/src/lib/trigger/new-person.js +35 -11
  53. package/src/lib/trigger/new-person.js.map +1 -1
  54. package/src/lib/trigger/updated-deal-stage.d.ts +8 -0
  55. package/src/lib/trigger/updated-deal-stage.js +288 -0
  56. package/src/lib/trigger/updated-deal-stage.js.map +1 -0
  57. package/src/lib/trigger/updated-deal.js +47 -20
  58. package/src/lib/trigger/updated-deal.js.map +1 -1
  59. package/src/lib/trigger/updated-organization.d.ts +2 -0
  60. package/src/lib/trigger/updated-organization.js +160 -0
  61. package/src/lib/trigger/updated-organization.js.map +1 -0
  62. package/src/lib/trigger/updated-person.js +35 -11
  63. package/src/lib/trigger/updated-person.js.map +1 -1
  64. package/src/lib/actions/add-person.action/add-person.action.d.ts +0 -8
  65. package/src/lib/actions/add-person.action/add-person.action.js +0 -179
  66. package/src/lib/actions/add-person.action/add-person.action.js.map +0 -1
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPersonAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const index_1 = require("../../index");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const props_1 = require("../common/props");
8
+ const common_1 = require("../common");
9
+ const pieces_common_1 = require("@activepieces/pieces-common");
10
+ exports.createPersonAction = (0, pieces_framework_1.createAction)({
11
+ auth: index_1.pipedriveAuth,
12
+ name: 'create-person',
13
+ displayName: 'Create Person',
14
+ description: 'Creates a new person.',
15
+ props: Object.assign({ name: pieces_framework_1.Property.ShortText({
16
+ displayName: 'Name',
17
+ required: true,
18
+ }) }, props_1.personCommonProps),
19
+ run(context) {
20
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
21
+ var _a, _b, _c, _d;
22
+ const { name, ownerId, organizationId, marketing_status, visibleTo, firstName, lastName } = context.propsValue;
23
+ const phone = (_a = context.propsValue.phone) !== null && _a !== void 0 ? _a : [];
24
+ const email = (_b = context.propsValue.email) !== null && _b !== void 0 ? _b : [];
25
+ const labelIds = (_c = context.propsValue.labelIds) !== null && _c !== void 0 ? _c : [];
26
+ const customFields = (_d = context.propsValue.customfields) !== null && _d !== void 0 ? _d : {};
27
+ const personDefaultFields = {
28
+ name: name,
29
+ owner_id: ownerId,
30
+ org_id: organizationId,
31
+ marketing_status: marketing_status,
32
+ visible_to: visibleTo,
33
+ first_name: firstName,
34
+ last_name: lastName,
35
+ };
36
+ if (phone.length > 0) {
37
+ personDefaultFields.phone = phone;
38
+ }
39
+ if (email.length > 0) {
40
+ personDefaultFields.email = email;
41
+ }
42
+ if (labelIds.length > 0) {
43
+ personDefaultFields.label_ids = labelIds;
44
+ }
45
+ const personCustomFiels = {};
46
+ Object.entries(customFields).forEach(([key, value]) => {
47
+ // Format values if they are arrays
48
+ personCustomFiels[key] = Array.isArray(value) ? value.join(',') : value;
49
+ });
50
+ const createdPersonResponse = yield (0, common_1.pipedriveApiCall)({
51
+ accessToken: context.auth.access_token,
52
+ apiDomain: context.auth.data['api_domain'],
53
+ method: pieces_common_1.HttpMethod.POST,
54
+ resourceUri: '/persons',
55
+ body: Object.assign(Object.assign({}, personDefaultFields), personCustomFiels),
56
+ });
57
+ const customFieldsResponse = yield (0, common_1.pipedrivePaginatedApiCall)({
58
+ accessToken: context.auth.access_token,
59
+ apiDomain: context.auth.data['api_domain'],
60
+ method: pieces_common_1.HttpMethod.GET,
61
+ resourceUri: '/personFields',
62
+ });
63
+ const updatedPersonProperties = (0, common_1.pipedriveTransformCustomFields)(customFieldsResponse, createdPersonResponse.data);
64
+ return Object.assign(Object.assign({}, createdPersonResponse), { data: updatedPersonProperties });
65
+ });
66
+ },
67
+ });
68
+ //# sourceMappingURL=create-person.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-person.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pipedrive/src/lib/actions/create-person.ts"],"names":[],"mappings":";;;;AAAA,uCAA4C;AAC5C,qEAAwE;AACxE,2CAAoD;AACpD,sCAImB;AAEnB,+DAAyD;AAE5C,QAAA,kBAAkB,GAAG,IAAA,+BAAY,EAAC;IAC9C,IAAI,EAAE,qBAAa;IACnB,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,eAAe;IAC5B,WAAW,EAAE,uBAAuB;IACpC,KAAK,kBACJ,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,MAAM;YACnB,QAAQ,EAAE,IAAI;SACd,CAAC,IACC,yBAAiB,CACpB;IACK,GAAG,CAAC,OAAO;;;YAChB,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,GACxF,OAAO,CAAC,UAAU,CAAC;YACpB,MAAM,KAAK,GAAG,MAAC,OAAO,CAAC,UAAU,CAAC,KAAkB,mCAAI,EAAE,CAAC;YAC3D,MAAM,KAAK,GAAG,MAAC,OAAO,CAAC,UAAU,CAAC,KAAkB,mCAAI,EAAE,CAAC;YAC3D,MAAM,QAAQ,GAAG,MAAC,OAAO,CAAC,UAAU,CAAC,QAAqB,mCAAI,EAAE,CAAC;YACjE,MAAM,YAAY,GAAG,MAAA,OAAO,CAAC,UAAU,CAAC,YAAY,m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,MAAM,oBAAoB,GAAG,MAAM,IAAA,kCAAyB,EAAW;gBACtE,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,YAAY;gBACtC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;gBAC1C,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,WAAW,EAAE,eAAe;aAC5B,CAAC,CAAC;YAEH,MAAM,uBAAuB,GAAG,IAAA,uCAA8B,EAC7D,oBAAoB,EACpB,qBAAqB,CAAC,IAAI,CAC1B,CAAC;YAEF,uCACI,qBAAqB,KACxB,IAAI,EAAE,uBAAuB,IAC5B;QACH,CAAC;KAAA;CACD,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ export declare const createProductAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
2
+ name: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ code: import("@activepieces/pieces-framework").ShortTextProperty<false>;
4
+ description: import("@activepieces/pieces-framework").LongTextProperty<false>;
5
+ unit: import("@activepieces/pieces-framework").ShortTextProperty<false>;
6
+ tax: import("@activepieces/pieces-framework").NumberProperty<false>;
7
+ isActive: import("@activepieces/pieces-framework").CheckboxProperty<false>;
8
+ ownerId: import("@activepieces/pieces-framework").DropdownProperty<number, false> | import("@activepieces/pieces-framework").DropdownProperty<number, true>;
9
+ currency: import("@activepieces/pieces-framework").ShortTextProperty<false>;
10
+ price: import("@activepieces/pieces-framework").NumberProperty<false>;
11
+ cost: import("@activepieces/pieces-framework").NumberProperty<false>;
12
+ overheadCost: import("@activepieces/pieces-framework").NumberProperty<false>;
13
+ visibleTo: import("@activepieces/pieces-framework").StaticDropdownProperty<number, false>;
14
+ customfields: import("@activepieces/pieces-framework").DynamicProperties<false>;
15
+ }>;
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createProductAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const index_1 = require("../../index");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const props_1 = require("../common/props");
8
+ const common_1 = require("../common");
9
+ const pieces_common_1 = require("@activepieces/pieces-common");
10
+ exports.createProductAction = (0, pieces_framework_1.createAction)({
11
+ auth: index_1.pipedriveAuth,
12
+ name: 'create-product',
13
+ displayName: 'Create Product',
14
+ description: 'Creates a new product.',
15
+ props: {
16
+ name: pieces_framework_1.Property.ShortText({
17
+ displayName: 'Name',
18
+ required: true,
19
+ }),
20
+ code: pieces_framework_1.Property.ShortText({
21
+ displayName: 'Code',
22
+ required: false,
23
+ }),
24
+ description: pieces_framework_1.Property.LongText({
25
+ displayName: 'Description',
26
+ required: false,
27
+ }),
28
+ unit: pieces_framework_1.Property.ShortText({
29
+ displayName: 'Unit',
30
+ required: false,
31
+ }),
32
+ tax: pieces_framework_1.Property.Number({
33
+ displayName: 'Tax percentage',
34
+ required: false,
35
+ }),
36
+ isActive: pieces_framework_1.Property.Checkbox({
37
+ displayName: 'Is Active ?',
38
+ required: false,
39
+ }),
40
+ ownerId: (0, props_1.ownerIdProp)(false),
41
+ currency: pieces_framework_1.Property.ShortText({
42
+ displayName: 'Currency',
43
+ required: false,
44
+ description: 'Please enter currency code.',
45
+ }),
46
+ price: pieces_framework_1.Property.Number({
47
+ displayName: 'Price',
48
+ required: false,
49
+ }),
50
+ cost: pieces_framework_1.Property.Number({
51
+ displayName: 'Cost',
52
+ required: false,
53
+ }),
54
+ overheadCost: pieces_framework_1.Property.Number({
55
+ displayName: 'Overhead Cost',
56
+ required: false,
57
+ }),
58
+ visibleTo: props_1.visibleToProp,
59
+ customfields: (0, props_1.customFieldsProp)('product'),
60
+ },
61
+ run(context) {
62
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
63
+ var _a;
64
+ const { name, code, description, unit, tax, isActive, ownerId, currency, price, cost, overheadCost, visibleTo, } = context.propsValue;
65
+ const customFields = (_a = context.propsValue.customfields) !== null && _a !== void 0 ? _a : {};
66
+ const productDefaultFields = {
67
+ name,
68
+ code,
69
+ description,
70
+ unit,
71
+ tax,
72
+ active_flag: isActive,
73
+ prices: [
74
+ {
75
+ price: price !== null && price !== void 0 ? price : 0,
76
+ currency: currency !== null && currency !== void 0 ? currency : 'USD',
77
+ cost: cost !== null && cost !== void 0 ? cost : 0,
78
+ overhead_cost: overheadCost !== null && overheadCost !== void 0 ? overheadCost : 0,
79
+ },
80
+ ],
81
+ visible_to: visibleTo,
82
+ };
83
+ if (ownerId) {
84
+ productDefaultFields.owner_id = ownerId;
85
+ }
86
+ const productCustomFields = {};
87
+ Object.entries(customFields).forEach(([key, value]) => {
88
+ // Format values if they are arrays
89
+ productCustomFields[key] = Array.isArray(value) ? value.join(',') : value;
90
+ });
91
+ const createdProductResponse = yield (0, common_1.pipedriveApiCall)({
92
+ accessToken: context.auth.access_token,
93
+ apiDomain: context.auth.data['api_domain'],
94
+ method: pieces_common_1.HttpMethod.POST,
95
+ resourceUri: '/products',
96
+ body: Object.assign(Object.assign({}, productDefaultFields), productCustomFields),
97
+ });
98
+ const customFieldsResponse = yield (0, common_1.pipedrivePaginatedApiCall)({
99
+ accessToken: context.auth.access_token,
100
+ apiDomain: context.auth.data['api_domain'],
101
+ method: pieces_common_1.HttpMethod.GET,
102
+ resourceUri: '/productFields',
103
+ });
104
+ const updatedProductProperties = (0, common_1.pipedriveTransformCustomFields)(customFieldsResponse, createdProductResponse.data);
105
+ return Object.assign(Object.assign({}, createdProductResponse), { data: updatedProductProperties });
106
+ });
107
+ },
108
+ });
109
+ //# sourceMappingURL=create-product.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-product.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pipedrive/src/lib/actions/create-product.ts"],"names":[],"mappings":";;;;AAAA,uCAA4C;AAC5C,qEAAwE;AACxE,2CAA+E;AAC/E,sCAImB;AAEnB,+DAAyD;AAE5C,QAAA,mBAAmB,GAAG,I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AG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YAC3E,CAAC,CAAC,CAAC;YAEH,MAAM,sBAAsB,GAAG,MAAM,IAAA,yBAAgB,EAA6B;gBACjF,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,YAAY;gBACtC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;gBAC1C,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,WAAW,EAAE,WAAW;gBACxB,IAAI,kCACA,oBAAoB,GACpB,mBAAmB,CACtB;aACD,CAAC,CAAC;YAEH,MAAM,oBAAoB,GAAG,MAAM,IAAA,kCAAyB,EAAW;gBACtE,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,YAAY;gBACtC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;gBAC1C,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,WAAW,EAAE,gBAAgB;aAC7B,CAAC,CAAC;YAEH,MAAM,wBAAwB,GAAG,IAAA,uCAA8B,EAC9D,oBAAoB,EACpB,sBAAsB,CAAC,IAAI,CAC3B,CAAC;YAEF,uCACI,sBAAsB,KACzB,IAAI,EAAE,wBAAwB,IAC7B;QACH,CAAC;KAAA;CACD,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ export declare const updateDealAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
2
+ creationTime: import("@activepieces/pieces-framework").DateTimeProperty<false>;
3
+ status: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
4
+ stageId: import("@activepieces/pieces-framework").DropdownProperty<number, false> | import("@activepieces/pieces-framework").DropdownProperty<number, true>;
5
+ pipelineId: import("@activepieces/pieces-framework").DropdownProperty<number, false> | import("@activepieces/pieces-framework").DropdownProperty<number, true>;
6
+ ownerId: import("@activepieces/pieces-framework").DropdownProperty<number, false> | import("@activepieces/pieces-framework").DropdownProperty<number, true>;
7
+ organizationId: import("@activepieces/pieces-framework").DropdownProperty<number, false> | import("@activepieces/pieces-framework").DropdownProperty<number, true>;
8
+ personId: import("@activepieces/pieces-framework").DropdownProperty<number, false> | import("@activepieces/pieces-framework").DropdownProperty<number, true>;
9
+ labelIds: import("@activepieces/pieces-framework").MultiSelectDropdownProperty<number, false> | import("@activepieces/pieces-framework").MultiSelectDropdownProperty<number, true>;
10
+ probability: import("@activepieces/pieces-framework").NumberProperty<false>;
11
+ expectedCloseDate: import("@activepieces/pieces-framework").ShortTextProperty<false>;
12
+ dealValue: import("@activepieces/pieces-framework").NumberProperty<false>;
13
+ dealValueCurrency: import("@activepieces/pieces-framework").ShortTextProperty<false>;
14
+ visibleTo: import("@activepieces/pieces-framework").StaticDropdownProperty<number, false>;
15
+ customfields: import("@activepieces/pieces-framework").DynamicProperties<false>;
16
+ dealId: import("@activepieces/pieces-framework").DropdownProperty<number, false> | import("@activepieces/pieces-framework").DropdownProperty<number, true>;
17
+ title: import("@activepieces/pieces-framework").ShortTextProperty<false>;
18
+ }>;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateDealAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const index_1 = require("../../index");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const props_1 = require("../common/props");
8
+ const common_1 = require("../common");
9
+ const pieces_common_1 = require("@activepieces/pieces-common");
10
+ exports.updateDealAction = (0, pieces_framework_1.createAction)({
11
+ auth: index_1.pipedriveAuth,
12
+ name: 'update-deal',
13
+ displayName: 'Update Deal',
14
+ description: 'Updates an existing deal.',
15
+ props: Object.assign({ dealId: (0, props_1.dealIdProp)(true), title: pieces_framework_1.Property.ShortText({
16
+ displayName: 'Title',
17
+ required: false,
18
+ }) }, props_1.dealCommonProps),
19
+ run(context) {
20
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
21
+ var _a, _b;
22
+ const { dealId, title, dealValue, dealValueCurrency, expectedCloseDate, visibleTo, probability, stageId, status, pipelineId, ownerId, organizationId, personId, creationTime, } = context.propsValue;
23
+ const labelIds = (_a = context.propsValue.labelIds) !== null && _a !== void 0 ? _a : [];
24
+ const customFields = (_b = context.propsValue.customfields) !== null && _b !== void 0 ? _b : {};
25
+ const dealDefaultFields = {
26
+ title,
27
+ pipeline_id: pipelineId,
28
+ stage_id: stageId,
29
+ status,
30
+ add_time: creationTime,
31
+ probability,
32
+ expected_close_date: expectedCloseDate,
33
+ visible_to: visibleTo,
34
+ user_id: ownerId,
35
+ org_id: organizationId,
36
+ person_id: personId,
37
+ value: dealValue,
38
+ currency: dealValueCurrency,
39
+ };
40
+ if (labelIds.length > 0) {
41
+ dealDefaultFields.label = labelIds;
42
+ }
43
+ const dealCustomFields = {};
44
+ Object.entries(customFields).forEach(([key, value]) => {
45
+ // Format values if they are arrays
46
+ dealCustomFields[key] = Array.isArray(value) && value.length > 0 ? value.join(',') : value;
47
+ });
48
+ const updatedDealResponse = yield (0, common_1.pipedriveApiCall)({
49
+ accessToken: context.auth.access_token,
50
+ apiDomain: context.auth.data['api_domain'],
51
+ method: pieces_common_1.HttpMethod.PUT,
52
+ resourceUri: `/deals/${dealId}`,
53
+ body: Object.assign(Object.assign({}, dealDefaultFields), dealCustomFields),
54
+ });
55
+ const customFieldsResponse = yield (0, common_1.pipedrivePaginatedApiCall)({
56
+ accessToken: context.auth.access_token,
57
+ apiDomain: context.auth.data['api_domain'],
58
+ method: pieces_common_1.HttpMethod.GET,
59
+ resourceUri: '/dealFields',
60
+ });
61
+ const updatedLeadProperties = (0, common_1.pipedriveTransformCustomFields)(customFieldsResponse, updatedDealResponse.data);
62
+ return Object.assign(Object.assign({}, updatedDealResponse), { data: updatedLeadProperties });
63
+ });
64
+ },
65
+ });
66
+ //# sourceMappingURL=update-deal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-deal.js","sourceRoot":"","sources":["../../../../../../../../packages/p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,14 @@
1
+ export declare const updateLeadAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
2
+ ownerId: import("@activepieces/pieces-framework").DropdownProperty<number, false> | import("@activepieces/pieces-framework").DropdownProperty<number, true>;
3
+ organizationId: import("@activepieces/pieces-framework").DropdownProperty<number, false> | import("@activepieces/pieces-framework").DropdownProperty<number, true>;
4
+ personId: import("@activepieces/pieces-framework").DropdownProperty<number, false> | import("@activepieces/pieces-framework").DropdownProperty<number, true>;
5
+ labelIds: import("@activepieces/pieces-framework").MultiSelectDropdownProperty<string, false> | import("@activepieces/pieces-framework").MultiSelectDropdownProperty<string, true>;
6
+ expectedCloseDate: import("@activepieces/pieces-framework").ShortTextProperty<false>;
7
+ visibleTo: import("@activepieces/pieces-framework").StaticDropdownProperty<number, false>;
8
+ channel: import("@activepieces/pieces-framework").MultiSelectDropdownProperty<number, false>;
9
+ leadValue: import("@activepieces/pieces-framework").NumberProperty<false>;
10
+ leadValueCurrency: import("@activepieces/pieces-framework").ShortTextProperty<false>;
11
+ customfields: import("@activepieces/pieces-framework").DynamicProperties<false>;
12
+ leadId: import("@activepieces/pieces-framework").DropdownProperty<number, false> | import("@activepieces/pieces-framework").DropdownProperty<number, true>;
13
+ title: import("@activepieces/pieces-framework").ShortTextProperty<false>;
14
+ }>;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateLeadAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const index_1 = require("../../index");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const props_1 = require("../common/props");
8
+ const common_1 = require("../common");
9
+ const pieces_common_1 = require("@activepieces/pieces-common");
10
+ exports.updateLeadAction = (0, pieces_framework_1.createAction)({
11
+ auth: index_1.pipedriveAuth,
12
+ name: 'update-lead',
13
+ displayName: 'Update Lead',
14
+ description: 'Updates an existing lead.',
15
+ props: Object.assign({ leadId: (0, props_1.leadIdProp)(true), title: pieces_framework_1.Property.ShortText({
16
+ displayName: 'Title',
17
+ required: false,
18
+ }) }, props_1.leadCommonProps),
19
+ run(context) {
20
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
21
+ var _a, _b;
22
+ const { title, ownerId, leadId, channel, organizationId, personId, expectedCloseDate, visibleTo, leadValue, leadValueCurrency, } = context.propsValue;
23
+ const labelIds = (_a = context.propsValue.labelIds) !== null && _a !== void 0 ? _a : [];
24
+ const customFields = (_b = context.propsValue.customfields) !== null && _b !== void 0 ? _b : {};
25
+ const leadDefaultFields = {
26
+ title,
27
+ owner_id: ownerId,
28
+ organization_id: organizationId,
29
+ person_id: personId,
30
+ channel: channel,
31
+ expected_close_date: expectedCloseDate,
32
+ visible_to: visibleTo,
33
+ };
34
+ if (labelIds.length > 0) {
35
+ leadDefaultFields.label_ids = labelIds;
36
+ }
37
+ if (leadValue) {
38
+ if (!leadValueCurrency) {
39
+ throw new Error('lead Value Currency is required when lead Value is provided');
40
+ }
41
+ leadDefaultFields.value = {
42
+ amount: leadValue,
43
+ currency: leadValueCurrency,
44
+ };
45
+ }
46
+ const leadCustomFields = {};
47
+ Object.entries(customFields).forEach(([key, value]) => {
48
+ // Format values if they are arrays
49
+ leadCustomFields[key] = Array.isArray(value) && value.length > 0 ? value.join(',') : value;
50
+ });
51
+ const updatedLeadResponse = yield (0, common_1.pipedriveApiCall)({
52
+ accessToken: context.auth.access_token,
53
+ apiDomain: context.auth.data['api_domain'],
54
+ method: pieces_common_1.HttpMethod.PATCH,
55
+ resourceUri: `/leads/${leadId}`,
56
+ body: Object.assign(Object.assign({}, leadDefaultFields), leadCustomFields),
57
+ });
58
+ const customFieldsResponse = yield (0, common_1.pipedrivePaginatedApiCall)({
59
+ accessToken: context.auth.access_token,
60
+ apiDomain: context.auth.data['api_domain'],
61
+ method: pieces_common_1.HttpMethod.GET,
62
+ resourceUri: '/dealFields',
63
+ });
64
+ const updatedLeadProperties = (0, common_1.pipedriveTransformCustomFields)(customFieldsResponse, updatedLeadResponse.data);
65
+ return Object.assign(Object.assign({}, updatedLeadResponse), { data: updatedLeadProperties });
66
+ });
67
+ },
68
+ });
69
+ //# sourceMappingURL=update-lead.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-lead.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pipedrive/src/lib/actions/update-lead.ts"],"names":[],"mappings":";;;;AAAA,uCAA4C;AAC5C,qEAAwE;AACxE,2CAA8D;AAC9D,sCAImB;AAEnB,+DAAyD;AAE5C,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC5C,IAAI,EAAE,qBAAa;IACnB,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,2BAA2B;IACxC,KAAK,kBACJ,MAAM,EAAE,IAAA,kBAAU,EAAC,IAAI,CAAC,EACxB,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACzB,WAAW,EAAE,OAAO;YACpB,QAAQ,EAAE,KAAK;SACf,CAAC,IACC,uBAAe,CAClB;IACK,GAAG,CAAC,OAAO;;;YAChB,MAAM,EACL,KAAK,EACL,OAAO,EACP,MAAM,EACN,OAAO,EACP,cAAc,EACd,QAAQ,EACR,iBAAiB,EACjB,SAAS,EACT,SAAS,EACT,iBAAiB,GACjB,GAAG,OAAO,CAAC,UAAU,CAAC;YAEvB,MAAM,QAAQ,GAAG,MAAC,OAAO,CAAC,UAAU,CAAC,QAAqB,mCAAI,EAAE,CAAC;YACjE,MAAM,YAAY,GAAG,MAAA,OAAO,CAAC,UAAU,CAAC,YAAY,mCAAI,EAAE,CAAC;YAE3D,MAAM,iBAAiB,GAAwB;gBAC9C,KAAK;gBACL,QAAQ,EAAE,OAAO;gBACjB,eAAe,EAAE,cAAc;gBAC/B,SAAS,EAAE,QAAQ;gBACnB,OAAO,EAAE,OAAO;gBAChB,mBAAmB,EAAE,iBAAiB;gBACtC,UAAU,EAAE,SA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YAAY,CAAC;gBAC1C,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,WAAW,EAAE,aAAa;aAC1B,CAAC,CAAC;YAEH,MAAM,qBAAqB,GAAG,IAAA,uCAA8B,EAC3D,oBAAoB,EACpB,mBAAmB,CAAC,IAAI,CACxB,CAAC;YAEF,uCACI,mBAAmB,KACtB,IAAI,EAAE,qBAAqB,IAC1B;QACH,CAAC;KAAA;CACD,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare const updateOrganizationAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
2
+ ownerId: import("@activepieces/pieces-framework").DropdownProperty<number, false> | import("@activepieces/pieces-framework").DropdownProperty<number, true>;
3
+ visibleTo: import("@activepieces/pieces-framework").StaticDropdownProperty<number, false>;
4
+ labelIds: import("@activepieces/pieces-framework").MultiSelectDropdownProperty<number, false> | import("@activepieces/pieces-framework").MultiSelectDropdownProperty<number, true>;
5
+ address: import("@activepieces/pieces-framework").LongTextProperty<false>;
6
+ customfields: import("@activepieces/pieces-framework").DynamicProperties<false>;
7
+ organizationId: import("@activepieces/pieces-framework").DropdownProperty<number, false> | import("@activepieces/pieces-framework").DropdownProperty<number, true>;
8
+ name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
9
+ }>;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateOrganizationAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const index_1 = require("../../index");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const props_1 = require("../common/props");
8
+ const common_1 = require("../common");
9
+ const pieces_common_1 = require("@activepieces/pieces-common");
10
+ exports.updateOrganizationAction = (0, pieces_framework_1.createAction)({
11
+ auth: index_1.pipedriveAuth,
12
+ name: 'update-organization',
13
+ displayName: 'Update Organization',
14
+ description: 'Updates an existing organization.',
15
+ props: Object.assign({ organizationId: (0, props_1.organizationIdProp)(true), name: pieces_framework_1.Property.ShortText({
16
+ displayName: 'Name',
17
+ required: false,
18
+ }) }, props_1.organizationCommonProps),
19
+ run(context) {
20
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
21
+ var _a, _b;
22
+ const { name, ownerId, address, visibleTo, organizationId } = context.propsValue;
23
+ const labelIds = (_a = context.propsValue.labelIds) !== null && _a !== void 0 ? _a : [];
24
+ const customFields = (_b = context.propsValue.customfields) !== null && _b !== void 0 ? _b : {};
25
+ const organizationDefaultFields = {
26
+ name: name,
27
+ owner_id: ownerId,
28
+ visible_to: visibleTo,
29
+ address: address,
30
+ };
31
+ if (labelIds.length > 0) {
32
+ organizationDefaultFields.label_ids = labelIds;
33
+ }
34
+ const organizationCustomFiels = {};
35
+ Object.entries(customFields).forEach(([key, value]) => {
36
+ // Format values if they are arrays
37
+ organizationCustomFiels[key] =
38
+ Array.isArray(value) && value.length > 0 ? value.join(',') : value;
39
+ });
40
+ const updatedOrganizationResponse = yield (0, common_1.pipedriveApiCall)({
41
+ accessToken: context.auth.access_token,
42
+ apiDomain: context.auth.data['api_domain'],
43
+ method: pieces_common_1.HttpMethod.PUT,
44
+ resourceUri: `/organizations/${organizationId}`,
45
+ body: Object.assign(Object.assign({}, organizationDefaultFields), organizationCustomFiels),
46
+ });
47
+ const customFieldsResponse = yield (0, common_1.pipedrivePaginatedApiCall)({
48
+ accessToken: context.auth.access_token,
49
+ apiDomain: context.auth.data['api_domain'],
50
+ method: pieces_common_1.HttpMethod.GET,
51
+ resourceUri: '/organizationFields',
52
+ });
53
+ const updatedOrganizationProperties = (0, common_1.pipedriveTransformCustomFields)(customFieldsResponse, updatedOrganizationResponse.data);
54
+ return Object.assign(Object.assign({}, updatedOrganizationResponse), { data: updatedOrganizationProperties });
55
+ });
56
+ },
57
+ });
58
+ //# sourceMappingURL=update-organization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-organization.js","sourceRoot":"","sources":["../../../../../../../../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AK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YACrE,CAAC,CAAC,CAAC;YAEH,MAAM,2BAA2B,GAAG,MAAM,IAAA,yBAAgB,EAA6B;gBACtF,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,YAAY;gBACtC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;gBAC1C,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,WAAW,EAAE,kBAAkB,cAAc,EAAE;gBAC/C,IAAI,kCACA,yBAAyB,GACzB,uBAAuB,CAC1B;aACD,CAAC,CAAC;YAEH,MAAM,oBAAoB,GAAG,MAAM,IAAA,kCAAyB,EAAW;gBACtE,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,YAAY;gBACtC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;gBAC1C,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,WAAW,EAAE,qBAAqB;aAClC,CAAC,CAAC;YAEH,MAAM,6BAA6B,GAAG,IAAA,uCAA8B,EACnE,oBAAoB,EACpB,2BAA2B,CAAC,IAAI,CAChC,CAAC;YAEF,uCACI,2BAA2B,KAC9B,IAAI,EAAE,6BAA6B,IAClC;QACH,CAAC;KAAA;CACD,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ export declare const updatePersonAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
2
+ ownerId: import("@activepieces/pieces-framework").DropdownProperty<number, false> | import("@activepieces/pieces-framework").DropdownProperty<number, true>;
3
+ organizationId: import("@activepieces/pieces-framework").DropdownProperty<number, false> | import("@activepieces/pieces-framework").DropdownProperty<number, true>;
4
+ email: import("@activepieces/pieces-framework").ArrayProperty<false>;
5
+ phone: import("@activepieces/pieces-framework").ArrayProperty<false>;
6
+ labelIds: import("@activepieces/pieces-framework").MultiSelectDropdownProperty<number, false> | import("@activepieces/pieces-framework").MultiSelectDropdownProperty<number, true>;
7
+ firstName: import("@activepieces/pieces-framework").ShortTextProperty<false>;
8
+ lastName: import("@activepieces/pieces-framework").ShortTextProperty<false>;
9
+ visibleTo: import("@activepieces/pieces-framework").StaticDropdownProperty<number, false>;
10
+ marketing_status: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false> | import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
11
+ customfields: import("@activepieces/pieces-framework").DynamicProperties<false>;
12
+ personId: import("@activepieces/pieces-framework").DropdownProperty<number, false> | import("@activepieces/pieces-framework").DropdownProperty<number, true>;
13
+ name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
14
+ }>;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updatePersonAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const index_1 = require("../../index");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const props_1 = require("../common/props");
8
+ const common_1 = require("../common");
9
+ const pieces_common_1 = require("@activepieces/pieces-common");
10
+ exports.updatePersonAction = (0, pieces_framework_1.createAction)({
11
+ auth: index_1.pipedriveAuth,
12
+ name: 'update-person',
13
+ displayName: 'Update Person',
14
+ description: 'Updates an existing person.',
15
+ props: Object.assign({ personId: (0, props_1.personIdProp)(true), name: pieces_framework_1.Property.ShortText({
16
+ displayName: 'Name',
17
+ required: false,
18
+ }) }, props_1.personCommonProps),
19
+ run(context) {
20
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
21
+ var _a, _b, _c, _d;
22
+ const { name, ownerId, personId, organizationId, marketing_status, visibleTo, firstName, lastName, } = context.propsValue;
23
+ const phone = (_a = context.propsValue.phone) !== null && _a !== void 0 ? _a : [];
24
+ const email = (_b = context.propsValue.email) !== null && _b !== void 0 ? _b : [];
25
+ const labelIds = (_c = context.propsValue.labelIds) !== null && _c !== void 0 ? _c : [];
26
+ const customFields = (_d = context.propsValue.customfields) !== null && _d !== void 0 ? _d : {};
27
+ const personDefaultFields = {
28
+ name: name,
29
+ owner_id: ownerId,
30
+ org_id: organizationId,
31
+ marketing_status: marketing_status,
32
+ visible_to: visibleTo,
33
+ first_name: firstName,
34
+ last_name: lastName,
35
+ };
36
+ if (phone.length > 0) {
37
+ personDefaultFields.phone = phone;
38
+ }
39
+ if (email.length > 0) {
40
+ personDefaultFields.email = email;
41
+ }
42
+ if (labelIds.length > 0) {
43
+ personDefaultFields.label_ids = labelIds;
44
+ }
45
+ const personCustomFiels = {};
46
+ Object.entries(customFields).forEach(([key, value]) => {
47
+ // Format values if they are arrays
48
+ personCustomFiels[key] = Array.isArray(value) && value.length > 0 ? value.join(',') : value;
49
+ });
50
+ const updatedPersonResponse = yield (0, common_1.pipedriveApiCall)({
51
+ accessToken: context.auth.access_token,
52
+ apiDomain: context.auth.data['api_domain'],
53
+ method: pieces_common_1.HttpMethod.PUT,
54
+ resourceUri: `/persons/${personId}`,
55
+ body: Object.assign(Object.assign({}, personDefaultFields), personCustomFiels),
56
+ });
57
+ const customFieldsResponse = yield (0, common_1.pipedrivePaginatedApiCall)({
58
+ accessToken: context.auth.access_token,
59
+ apiDomain: context.auth.data['api_domain'],
60
+ method: pieces_common_1.HttpMethod.GET,
61
+ resourceUri: '/personFields',
62
+ });
63
+ const updatedPersonProperties = (0, common_1.pipedriveTransformCustomFields)(customFieldsResponse, updatedPersonResponse.data);
64
+ return Object.assign(Object.assign({}, updatedPersonResponse), { data: updatedPersonProperties });
65
+ });
66
+ },
67
+ });
68
+ //# sourceMappingURL=update-person.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-person.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pipedrive/src/lib/actions/update-person.ts"],"names":[],"mappings":";;;;AAAA,uCAA4C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B,qBAAqB,CAAC,IAAI,CAC1B,CAAC;YAEF,uCACI,qBAAqB,KACxB,IAAI,EAAE,uBAAuB,IAC5B;QACH,CAAC;KAAA;CACD,CAAC,CAAC"}
@@ -1,3 +1,5 @@
1
+ import { HttpMessageBody, HttpMethod } from '@activepieces/pieces-common';
2
+ import { GetField, RequestParams } from './types';
1
3
  export declare const pipedriveCommon: {
2
4
  subscribeWebhook: (object: string, action: string, webhookUrl: string, apiDomain: string, accessToken: string) => Promise<{
3
5
  data: {
@@ -6,3 +8,14 @@ export declare const pipedriveCommon: {
6
8
  }>;
7
9
  unsubscribeWebhook: (webhookId: string, apiDomain: string, accessToken: string) => Promise<import("@activepieces/pieces-common").HttpResponse<any>>;
8
10
  };
11
+ export type PipedriveApiCallParams = {
12
+ accessToken: string;
13
+ apiDomain: string;
14
+ method: HttpMethod;
15
+ resourceUri: string;
16
+ query?: RequestParams;
17
+ body?: any;
18
+ };
19
+ export declare function pipedriveApiCall<T extends HttpMessageBody>({ accessToken, apiDomain, method, resourceUri, query, body, }: PipedriveApiCallParams): Promise<T>;
20
+ export declare function pipedrivePaginatedApiCall<T extends HttpMessageBody>({ accessToken, apiDomain, method, resourceUri, query, body, }: PipedriveApiCallParams): Promise<T[]>;
21
+ export declare function pipedriveTransformCustomFields(CustomFields: GetField[], responseData: Record<string, any>): Record<string, any>;