@activepieces/piece-pipedrive 0.6.3 → 0.7.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.
- package/package.json +10 -8
- package/src/i18n/de.json +18 -15
- package/src/i18n/es.json +18 -15
- package/src/i18n/fr.json +18 -15
- package/src/i18n/ja.json +18 -15
- package/src/i18n/nl.json +18 -15
- package/src/i18n/pt.json +18 -15
- package/src/i18n/translation.json +18 -15
- package/src/i18n/zh.json +18 -15
- package/src/index.js +1 -1
- package/src/index.js.map +1 -1
- package/src/lib/actions/add-follower.js +1 -1
- package/src/lib/actions/add-follower.js.map +1 -1
- package/src/lib/actions/add-label-to-person.js +10 -10
- package/src/lib/actions/add-label-to-person.js.map +1 -1
- package/src/lib/actions/add-product-to-deal.js +3 -3
- package/src/lib/actions/add-product-to-deal.js.map +1 -1
- package/src/lib/actions/create-activity.d.ts +2 -2
- package/src/lib/actions/create-activity.js +13 -11
- package/src/lib/actions/create-activity.js.map +1 -1
- package/src/lib/actions/create-deal.js +19 -19
- package/src/lib/actions/create-deal.js.map +1 -1
- package/src/lib/actions/create-lead.d.ts +1 -1
- package/src/lib/actions/create-lead.js +5 -5
- package/src/lib/actions/create-lead.js.map +1 -1
- package/src/lib/actions/create-note.js +4 -4
- package/src/lib/actions/create-note.js.map +1 -1
- package/src/lib/actions/create-organization.js +21 -17
- package/src/lib/actions/create-organization.js.map +1 -1
- package/src/lib/actions/create-person.d.ts +1 -1
- package/src/lib/actions/create-person.js +47 -29
- package/src/lib/actions/create-person.js.map +1 -1
- package/src/lib/actions/create-product.js +18 -17
- package/src/lib/actions/create-product.js.map +1 -1
- package/src/lib/actions/find-activity.js +24 -10
- package/src/lib/actions/find-activity.js.map +1 -1
- package/src/lib/actions/find-deal.js +12 -10
- package/src/lib/actions/find-deal.js.map +1 -1
- package/src/lib/actions/find-deals-associated-with-person.js +12 -6
- package/src/lib/actions/find-deals-associated-with-person.js.map +1 -1
- package/src/lib/actions/find-notes.js +3 -3
- package/src/lib/actions/find-notes.js.map +1 -1
- package/src/lib/actions/find-organization.js +9 -7
- package/src/lib/actions/find-organization.js.map +1 -1
- package/src/lib/actions/find-person.js +9 -6
- package/src/lib/actions/find-person.js.map +1 -1
- package/src/lib/actions/find-product.js +14 -10
- package/src/lib/actions/find-product.js.map +1 -1
- package/src/lib/actions/find-products.js +20 -12
- package/src/lib/actions/find-products.js.map +1 -1
- package/src/lib/actions/find-user.js +4 -4
- package/src/lib/actions/find-user.js.map +1 -1
- package/src/lib/actions/get-note.js +6 -5
- package/src/lib/actions/get-note.js.map +1 -1
- package/src/lib/actions/get-product.js +5 -5
- package/src/lib/actions/get-product.js.map +1 -1
- package/src/lib/actions/update-activity.d.ts +2 -2
- package/src/lib/actions/update-activity.js +15 -12
- package/src/lib/actions/update-activity.js.map +1 -1
- package/src/lib/actions/update-deal.js +19 -20
- package/src/lib/actions/update-deal.js.map +1 -1
- package/src/lib/actions/update-lead.d.ts +1 -1
- package/src/lib/actions/update-lead.js +5 -5
- package/src/lib/actions/update-lead.js.map +1 -1
- package/src/lib/actions/update-organization.js +21 -18
- package/src/lib/actions/update-organization.js.map +1 -1
- package/src/lib/actions/update-person.js +37 -26
- package/src/lib/actions/update-person.js.map +1 -1
- package/src/lib/common/constants.d.ts +3 -0
- package/src/lib/common/constants.js +64 -0
- package/src/lib/common/constants.js.map +1 -0
- package/src/lib/common/index.d.ts +5 -2
- package/src/lib/common/index.js +127 -10
- package/src/lib/common/index.js.map +1 -1
- package/src/lib/common/props.d.ts +62 -7
- package/src/lib/common/props.js +138 -81
- package/src/lib/common/props.js.map +1 -1
- package/src/lib/common/types.d.ts +319 -36
- package/src/lib/trigger/activity-matching-filter.js +10 -9
- package/src/lib/trigger/activity-matching-filter.js.map +1 -1
- package/src/lib/trigger/deal-matching-filter.js +15 -58
- package/src/lib/trigger/deal-matching-filter.js.map +1 -1
- package/src/lib/trigger/new-activity.js +51 -62
- package/src/lib/trigger/new-activity.js.map +1 -1
- package/src/lib/trigger/new-deal.js +37 -113
- package/src/lib/trigger/new-deal.js.map +1 -1
- package/src/lib/trigger/new-lead.js +13 -10
- package/src/lib/trigger/new-lead.js.map +1 -1
- package/src/lib/trigger/new-note.js +17 -23
- package/src/lib/trigger/new-note.js.map +1 -1
- package/src/lib/trigger/new-organization.js +35 -61
- package/src/lib/trigger/new-organization.js.map +1 -1
- package/src/lib/trigger/new-person.js +34 -81
- package/src/lib/trigger/new-person.js.map +1 -1
- package/src/lib/trigger/organization-matching-filter.js +46 -69
- package/src/lib/trigger/organization-matching-filter.js.map +1 -1
- package/src/lib/trigger/person-matching-filter.js +39 -84
- package/src/lib/trigger/person-matching-filter.js.map +1 -1
- package/src/lib/trigger/updated-deal-stage.js +50 -123
- package/src/lib/trigger/updated-deal-stage.js.map +1 -1
- package/src/lib/trigger/updated-deal.js +38 -128
- package/src/lib/trigger/updated-deal.js.map +1 -1
- package/src/lib/trigger/updated-organization.js +39 -68
- package/src/lib/trigger/updated-organization.js.map +1 -1
- package/src/lib/trigger/updated-person.js +39 -89
- package/src/lib/trigger/updated-person.js.map +1 -1
|
@@ -8,6 +8,7 @@ const props_1 = require("../common/props");
|
|
|
8
8
|
const common_1 = require("../common");
|
|
9
9
|
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
10
10
|
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
11
|
+
const shared_1 = require("@activepieces/shared");
|
|
11
12
|
exports.updateDealAction = (0, pieces_framework_1.createAction)({
|
|
12
13
|
auth: index_1.pipedriveAuth,
|
|
13
14
|
name: 'update-deal',
|
|
@@ -20,49 +21,47 @@ exports.updateDealAction = (0, pieces_framework_1.createAction)({
|
|
|
20
21
|
run(context) {
|
|
21
22
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
23
|
var _a, _b;
|
|
23
|
-
const { dealId, title, dealValue, dealValueCurrency, expectedCloseDate, visibleTo, probability, stageId, status, pipelineId, ownerId, organizationId, personId,
|
|
24
|
+
const { dealId, title, dealValue, dealValueCurrency, expectedCloseDate, visibleTo, probability, stageId, status, pipelineId, ownerId, organizationId, personId, } = context.propsValue;
|
|
24
25
|
const labelIds = (_a = context.propsValue.labelIds) !== null && _a !== void 0 ? _a : [];
|
|
25
26
|
const customFields = (_b = context.propsValue.customfields) !== null && _b !== void 0 ? _b : {};
|
|
26
|
-
const
|
|
27
|
+
const dealPayload = {
|
|
27
28
|
title,
|
|
28
29
|
pipeline_id: pipelineId,
|
|
29
30
|
stage_id: stageId,
|
|
30
31
|
status,
|
|
31
|
-
add_time: creationTime,
|
|
32
32
|
probability,
|
|
33
33
|
visible_to: visibleTo,
|
|
34
|
-
|
|
34
|
+
owner_id: ownerId,
|
|
35
35
|
org_id: organizationId,
|
|
36
36
|
person_id: personId,
|
|
37
37
|
value: dealValue,
|
|
38
38
|
currency: dealValueCurrency,
|
|
39
39
|
};
|
|
40
40
|
if (labelIds.length > 0) {
|
|
41
|
-
|
|
41
|
+
dealPayload.label_ids = labelIds;
|
|
42
42
|
}
|
|
43
43
|
if (expectedCloseDate) {
|
|
44
|
-
|
|
44
|
+
dealPayload.expected_close_date = (0, dayjs_1.default)(expectedCloseDate).format('YYYY-MM-DD');
|
|
45
45
|
}
|
|
46
|
-
const
|
|
47
|
-
Object.entries(customFields).forEach(([key, value]) => {
|
|
48
|
-
// Format values if they are arrays
|
|
49
|
-
dealCustomFields[key] = Array.isArray(value) && value.length > 0 ? value.join(',') : value;
|
|
50
|
-
});
|
|
51
|
-
const updatedDealResponse = yield (0, common_1.pipedriveApiCall)({
|
|
46
|
+
const customFieldsResponse = yield (0, common_1.pipedrivePaginatedV1ApiCall)({
|
|
52
47
|
accessToken: context.auth.access_token,
|
|
53
48
|
apiDomain: context.auth.data['api_domain'],
|
|
54
|
-
method: pieces_common_1.HttpMethod.
|
|
55
|
-
resourceUri:
|
|
56
|
-
body: Object.assign(Object.assign({}, dealDefaultFields), dealCustomFields),
|
|
49
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
50
|
+
resourceUri: '/v1/dealFields',
|
|
57
51
|
});
|
|
58
|
-
const
|
|
52
|
+
const personCustomFields = (0, common_1.pipedriveParseCustomFields)(customFieldsResponse, customFields);
|
|
53
|
+
if (!(0, shared_1.isEmpty)(personCustomFields)) {
|
|
54
|
+
dealPayload.custom_fields = personCustomFields;
|
|
55
|
+
}
|
|
56
|
+
const updatedDealResponse = yield (0, common_1.pipedriveApiCall)({
|
|
59
57
|
accessToken: context.auth.access_token,
|
|
60
58
|
apiDomain: context.auth.data['api_domain'],
|
|
61
|
-
method: pieces_common_1.HttpMethod.
|
|
62
|
-
resourceUri:
|
|
59
|
+
method: pieces_common_1.HttpMethod.PATCH,
|
|
60
|
+
resourceUri: `/v2/deals/${dealId}`,
|
|
61
|
+
body: dealPayload,
|
|
63
62
|
});
|
|
64
|
-
const
|
|
65
|
-
return Object.assign(Object.assign({}, updatedDealResponse), { data:
|
|
63
|
+
const transformedDealProperties = (0, common_1.pipedriveTransformCustomFields)(customFieldsResponse, updatedDealResponse.data);
|
|
64
|
+
return Object.assign(Object.assign({}, updatedDealResponse), { data: transformedDealProperties });
|
|
66
65
|
});
|
|
67
66
|
},
|
|
68
67
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-deal.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pipedrive/src/lib/actions/update-deal.ts"],"names":[],"mappings":";;;;AAAA,uCAA4C;AAC5C,qEAAwE;AACxE,2CAA8D;AAC9D,
|
|
1
|
+
{"version":3,"file":"update-deal.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pipedrive/src/lib/actions/update-deal.ts"],"names":[],"mappings":";;;;AAAA,uCAA4C;AAC5C,qEAAwE;AACxE,2CAA8D;AAC9D,sCAKmB;AACnB,+DAAyD;AAEzD,0DAA0B;AAC1B,iDAA+C;AAElC,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC5C,IAAI,EAAE,qBAAa;IAC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AAW;gBACxE,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,kBAAkB,GAAG,IAAA,mCAA0B,EAAC,oBAAoB,EAAE,YAAY,CAAC,CAAC;YAE1F,IAAI,CAAC,IAAA,gBAAO,EAAC,kBAAkB,CAAC,EAAE,CAAC;gBAClC,WAAW,CAAC,aAAa,GAAG,kBAAkB,CAAC;YAChD,CAAC;YAED,MAAM,mBAAmB,GAAG,MAAM,IAAA,yBAAgB,EAAkB;gBACnE,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,YAAY;gBACtC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;gBAC1C,MAAM,EAAE,0BAAU,CAAC,KAAK;gBACxB,WAAW,EAAE,aAAa,MAAM,EAAE;gBAClC,IAAI,EAAE,WAAW;aACjB,CAAC,CAAC;YAEH,MAAM,yBAAyB,GAAG,IAAA,uCAA8B,EAC/D,oBAAoB,EACpB,mBAAmB,CAAC,IAAI,CACxB,CAAC;YAEF,uCACI,mBAAmB,KACtB,IAAI,EAAE,yBAAyB,IAC9B;QACH,CAAC;KAAA;CACD,CAAC,CAAC"}
|
|
@@ -5,7 +5,7 @@ export declare const updateLeadAction: import("@activepieces/pieces-framework").
|
|
|
5
5
|
labelIds: import("@activepieces/pieces-framework").MultiSelectDropdownProperty<string, false> | import("@activepieces/pieces-framework").MultiSelectDropdownProperty<string, true>;
|
|
6
6
|
expectedCloseDate: import("@activepieces/pieces-framework").DateTimeProperty<false>;
|
|
7
7
|
visibleTo: import("@activepieces/pieces-framework").StaticDropdownProperty<number, false>;
|
|
8
|
-
channel: import("@activepieces/pieces-framework").
|
|
8
|
+
channel: import("@activepieces/pieces-framework").DropdownProperty<number, false>;
|
|
9
9
|
leadValue: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
10
10
|
leadValueCurrency: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
11
11
|
customfields: import("@activepieces/pieces-framework").DynamicProperties<false>;
|
|
@@ -55,17 +55,17 @@ exports.updateLeadAction = (0, pieces_framework_1.createAction)({
|
|
|
55
55
|
accessToken: context.auth.access_token,
|
|
56
56
|
apiDomain: context.auth.data['api_domain'],
|
|
57
57
|
method: pieces_common_1.HttpMethod.PATCH,
|
|
58
|
-
resourceUri: `/leads/${leadId}`,
|
|
58
|
+
resourceUri: `/v1/leads/${leadId}`,
|
|
59
59
|
body: Object.assign(Object.assign({}, leadDefaultFields), leadCustomFields),
|
|
60
60
|
});
|
|
61
|
-
const customFieldsResponse = yield (0, common_1.
|
|
61
|
+
const customFieldsResponse = yield (0, common_1.pipedrivePaginatedV1ApiCall)({
|
|
62
62
|
accessToken: context.auth.access_token,
|
|
63
63
|
apiDomain: context.auth.data['api_domain'],
|
|
64
64
|
method: pieces_common_1.HttpMethod.GET,
|
|
65
|
-
resourceUri: '/dealFields',
|
|
65
|
+
resourceUri: '/v1/dealFields',
|
|
66
66
|
});
|
|
67
|
-
const
|
|
68
|
-
return Object.assign(Object.assign({}, updatedLeadResponse), { data:
|
|
67
|
+
const transformedLeadProperties = (0, common_1.pipedriveTransformV1CustomFields)(customFieldsResponse, updatedLeadResponse.data);
|
|
68
|
+
return Object.assign(Object.assign({}, updatedLeadResponse), { data: transformedLeadProperties });
|
|
69
69
|
});
|
|
70
70
|
},
|
|
71
71
|
});
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"update-lead.js","sourceRoot":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BAAgB;aAC7B,CAAC,CAAC;YAEH,MAAM,yBAAyB,GAAG,IAAA,yCAAgC,EACjE,oBAAoB,EACpB,mBAAmB,CAAC,IAAI,CACxB,CAAC;YAEF,uCACI,mBAAmB,KACtB,IAAI,EAAE,yBAAyB,IAC9B;QACH,CAAC;KAAA;CACD,CAAC,CAAC"}
|
|
@@ -7,6 +7,7 @@ const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
|
7
7
|
const props_1 = require("../common/props");
|
|
8
8
|
const common_1 = require("../common");
|
|
9
9
|
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
10
|
+
const shared_1 = require("@activepieces/shared");
|
|
10
11
|
exports.updateOrganizationAction = (0, pieces_framework_1.createAction)({
|
|
11
12
|
auth: index_1.pipedriveAuth,
|
|
12
13
|
name: 'update-organization',
|
|
@@ -22,36 +23,38 @@ exports.updateOrganizationAction = (0, pieces_framework_1.createAction)({
|
|
|
22
23
|
const { name, ownerId, address, visibleTo, organizationId } = context.propsValue;
|
|
23
24
|
const labelIds = (_a = context.propsValue.labelIds) !== null && _a !== void 0 ? _a : [];
|
|
24
25
|
const customFields = (_b = context.propsValue.customfields) !== null && _b !== void 0 ? _b : {};
|
|
25
|
-
const
|
|
26
|
+
const organizationPayload = {
|
|
26
27
|
name: name,
|
|
27
28
|
owner_id: ownerId,
|
|
28
29
|
visible_to: visibleTo,
|
|
29
|
-
address: address,
|
|
30
30
|
};
|
|
31
|
+
if (address) {
|
|
32
|
+
if (typeof address === 'string') {
|
|
33
|
+
organizationPayload.address = { value: address };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
31
36
|
if (labelIds.length > 0) {
|
|
32
|
-
|
|
37
|
+
organizationPayload.label_ids = labelIds;
|
|
33
38
|
}
|
|
34
|
-
const
|
|
35
|
-
Object.entries(customFields).forEach(([key, value]) => {
|
|
36
|
-
// Format values if they are arrays
|
|
37
|
-
organizationCustomFields[key] =
|
|
38
|
-
Array.isArray(value) && value.length > 0 ? value.join(',') : value;
|
|
39
|
-
});
|
|
40
|
-
const updatedOrganizationResponse = yield (0, common_1.pipedriveApiCall)({
|
|
39
|
+
const customFieldsResponse = yield (0, common_1.pipedrivePaginatedV1ApiCall)({
|
|
41
40
|
accessToken: context.auth.access_token,
|
|
42
41
|
apiDomain: context.auth.data['api_domain'],
|
|
43
|
-
method: pieces_common_1.HttpMethod.
|
|
44
|
-
resourceUri:
|
|
45
|
-
body: Object.assign(Object.assign({}, organizationDefaultFields), organizationCustomFields),
|
|
42
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
43
|
+
resourceUri: '/v1/organizationFields',
|
|
46
44
|
});
|
|
47
|
-
const
|
|
45
|
+
const orgCustomFields = (0, common_1.pipedriveParseCustomFields)(customFieldsResponse, customFields);
|
|
46
|
+
if (!(0, shared_1.isEmpty)(orgCustomFields)) {
|
|
47
|
+
organizationPayload.custom_fields = orgCustomFields;
|
|
48
|
+
}
|
|
49
|
+
const updatedOrganizationResponse = yield (0, common_1.pipedriveApiCall)({
|
|
48
50
|
accessToken: context.auth.access_token,
|
|
49
51
|
apiDomain: context.auth.data['api_domain'],
|
|
50
|
-
method: pieces_common_1.HttpMethod.
|
|
51
|
-
resourceUri:
|
|
52
|
+
method: pieces_common_1.HttpMethod.PATCH,
|
|
53
|
+
resourceUri: `/v2/organizations/${organizationId}`,
|
|
54
|
+
body: organizationPayload,
|
|
52
55
|
});
|
|
53
|
-
const
|
|
54
|
-
return Object.assign(Object.assign({}, updatedOrganizationResponse), { data:
|
|
56
|
+
const transformedOrganizationProperties = (0, common_1.pipedriveTransformCustomFields)(customFieldsResponse, updatedOrganizationResponse.data);
|
|
57
|
+
return Object.assign(Object.assign({}, updatedOrganizationResponse), { data: transformedOrganizationProperties });
|
|
55
58
|
});
|
|
56
59
|
},
|
|
57
60
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-organization.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pipedrive/src/lib/actions/update-organization.ts"],"names":[],"mappings":";;;;AAAA,uCAA4C;AAC5C,qEAAwE;AACxE,2CAA8E;AAC9E,
|
|
1
|
+
{"version":3,"file":"update-organization.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pipedrive/src/lib/actions/update-organization.ts"],"names":[],"mappings":";;;;AAAA,uCAA4C;AAC5C,qEAAwE;AACxE,2CAA8E;AAC9E,sCAKmB;AAEnB,+DAAyD;AACzD,iDAA+C;AAElC,QAAA,wBAAwB,GAAG,IAAA,+BAAY,EAAC;IACpD,IAAI,EAAE,qBAAa;IACnB,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,qBAAqB;IAClC,WAAW,EAAE,mCAAmC;IAChD,KAAK,kBACJ,cAAc,EAAE,IAAA,0BAAkB,EAAC,IAAI,CAAC,EACxC,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,MAAM;YACnB,QAAQ,EAAE,KAAK;SACf,CAAC,IACC,+BAAuB,CAC1B;IACK,GAAG,CAAC,OAAO;;;YAChB,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAEjF,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,mBAAmB,GAAwB;gBAChD,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,OAAO;gBACjB,UAAU,EAAE,SAAS;aACrB,CAAC;YAEF,IAAI,OAAO,EAAE,CAAC;gBACb,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;oBACjC,mBAAmB,CAAC,OAAO,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;gBAClD,CAAC;YACF,CAAC;YAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACzB,mBAAmB,CAAC,SAAS,GAAG,QAAQ,CAAC;YAC1C,CAAC;YAED,MAAM,oBAAoB,GAAG,MAAM,IAAA,oCAA2B,EAAW;gBACxE,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,wBAAwB;aACrC,CAAC,CAAC;YAEH,MAAM,eAAe,GAAG,IAAA,mCAA0B,EAAC,oBAAoB,EAAE,YAAY,CAAC,CAAC;YAEvF,IAAI,CAAC,IAAA,gBAAO,EAAC,eAAe,CAAC,EAAE,CAAC;gBAC/B,mBAAmB,CAAC,aAAa,GAAG,eAAe,CAAC;YACrD,CAAC;YAED,MAAM,2BAA2B,GAAG,MAAM,IAAA,yBAAgB,EAA0B;gBACnF,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,YAAY;gBACtC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;gBAC1C,MAAM,EAAE,0BAAU,CAAC,KAAK;gBACxB,WAAW,EAAE,qBAAqB,cAAc,EAAE;gBAClD,IAAI,EAAE,mBAAmB;aACzB,CAAC,CAAC;YAEH,MAAM,iCAAiC,GAAG,IAAA,uCAA8B,EACvE,oBAAoB,EACpB,2BAA2B,CAAC,IAAI,CAChC,CAAC;YAEF,uCACI,2BAA2B,KAC9B,IAAI,EAAE,iCAAiC,IACtC;QACH,CAAC;KAAA;CACD,CAAC,CAAC"}
|
|
@@ -7,6 +7,7 @@ const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
|
7
7
|
const props_1 = require("../common/props");
|
|
8
8
|
const common_1 = require("../common");
|
|
9
9
|
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
10
|
+
const shared_1 = require("@activepieces/shared");
|
|
10
11
|
exports.updatePersonAction = (0, pieces_framework_1.createAction)({
|
|
11
12
|
auth: index_1.pipedriveAuth,
|
|
12
13
|
name: 'update-person',
|
|
@@ -20,11 +21,24 @@ exports.updatePersonAction = (0, pieces_framework_1.createAction)({
|
|
|
20
21
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
22
|
var _a, _b, _c, _d;
|
|
22
23
|
const { name, ownerId, personId, organizationId, marketing_status, visibleTo, firstName, lastName, } = context.propsValue;
|
|
23
|
-
const
|
|
24
|
-
const
|
|
24
|
+
const rawPhones = (_a = context.propsValue.phone) !== null && _a !== void 0 ? _a : [];
|
|
25
|
+
const rawEmails = (_b = context.propsValue.email) !== null && _b !== void 0 ? _b : [];
|
|
25
26
|
const labelIds = (_c = context.propsValue.labelIds) !== null && _c !== void 0 ? _c : [];
|
|
26
27
|
const customFields = (_d = context.propsValue.customfields) !== null && _d !== void 0 ? _d : {};
|
|
27
|
-
|
|
28
|
+
if ((firstName && !lastName) || (!firstName && lastName)) {
|
|
29
|
+
throw new Error('If First Name is provided, Last Name must be provided as well.');
|
|
30
|
+
}
|
|
31
|
+
const phones = rawPhones.map((value, index) => ({
|
|
32
|
+
value,
|
|
33
|
+
label: 'work',
|
|
34
|
+
primary: index === 0,
|
|
35
|
+
}));
|
|
36
|
+
const emails = rawEmails.map((value, index) => ({
|
|
37
|
+
value,
|
|
38
|
+
label: 'work',
|
|
39
|
+
primary: index === 0,
|
|
40
|
+
}));
|
|
41
|
+
const personPayload = {
|
|
28
42
|
name: name,
|
|
29
43
|
owner_id: ownerId,
|
|
30
44
|
org_id: organizationId,
|
|
@@ -33,35 +47,32 @@ exports.updatePersonAction = (0, pieces_framework_1.createAction)({
|
|
|
33
47
|
first_name: firstName,
|
|
34
48
|
last_name: lastName,
|
|
35
49
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
const personCustomFields = {};
|
|
46
|
-
Object.entries(customFields).forEach(([key, value]) => {
|
|
47
|
-
// Format values if they are arrays
|
|
48
|
-
personCustomFields[key] = Array.isArray(value) && value.length > 0 ? value.join(',') : value;
|
|
49
|
-
});
|
|
50
|
-
const updatedPersonResponse = yield (0, common_1.pipedriveApiCall)({
|
|
50
|
+
// Phones and emails
|
|
51
|
+
if (phones.length)
|
|
52
|
+
personPayload.phones = phones;
|
|
53
|
+
if (emails.length)
|
|
54
|
+
personPayload.emails = emails;
|
|
55
|
+
if (labelIds.length)
|
|
56
|
+
personPayload.label_ids = labelIds;
|
|
57
|
+
const customFieldsResponse = yield (0, common_1.pipedrivePaginatedV1ApiCall)({
|
|
51
58
|
accessToken: context.auth.access_token,
|
|
52
59
|
apiDomain: context.auth.data['api_domain'],
|
|
53
|
-
method: pieces_common_1.HttpMethod.
|
|
54
|
-
resourceUri:
|
|
55
|
-
body: Object.assign(Object.assign({}, personDefaultFields), personCustomFields),
|
|
60
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
61
|
+
resourceUri: '/v1/personFields',
|
|
56
62
|
});
|
|
57
|
-
const
|
|
63
|
+
const personCustomFields = (0, common_1.pipedriveParseCustomFields)(customFieldsResponse, customFields);
|
|
64
|
+
if (!(0, shared_1.isEmpty)(personCustomFields)) {
|
|
65
|
+
personPayload.custom_fields = personCustomFields;
|
|
66
|
+
}
|
|
67
|
+
const updatedPersonResponse = yield (0, common_1.pipedriveApiCall)({
|
|
58
68
|
accessToken: context.auth.access_token,
|
|
59
69
|
apiDomain: context.auth.data['api_domain'],
|
|
60
|
-
method: pieces_common_1.HttpMethod.
|
|
61
|
-
resourceUri:
|
|
70
|
+
method: pieces_common_1.HttpMethod.PATCH,
|
|
71
|
+
resourceUri: `/v2/persons/${personId}`,
|
|
72
|
+
body: personPayload,
|
|
62
73
|
});
|
|
63
|
-
const
|
|
64
|
-
return Object.assign(Object.assign({}, updatedPersonResponse), { data:
|
|
74
|
+
const transformedPersonProperties = (0, common_1.pipedriveTransformCustomFields)(customFieldsResponse, updatedPersonResponse.data);
|
|
75
|
+
return Object.assign(Object.assign({}, updatedPersonResponse), { data: transformedPersonProperties });
|
|
65
76
|
});
|
|
66
77
|
},
|
|
67
78
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-person.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pipedrive/src/lib/actions/update-person.ts"],"names":[],"mappings":";;;;AAAA,uCAA4C;AAC5C,qEAAwE;AACxE,
|
|
1
|
+
{"version":3,"file":"update-person.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pipedrive/src/lib/actions/update-person.ts"],"names":[],"mappings":";;;;AAAA,uCAA4C;AAC5C,qEAAwE;AACxE,2CAAoF;AACpF,sCAKmB;AAEnB,+DAAyD;AACzD,iDAA+C;AAElC,QAAA,kBAAkB,GAAG,IAAA,+BAAY,EAAC;IAC9C,IAAI,EAAE,qBAAa;IACnB,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,eAAe;IAC5B,WAAW,EAAE,6BAA6B;IAC1C,KAAK,kBACJ,QAAQ,EAAE,IAAA,oBAAY,EAAC,IAAI,CAAC,EAC5B,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,MAAM;YACnB,QAAQ,EAAE,KAAK;SACf,CAAC,IACC,yBAAiB,CACpB;IACK,GAAG,CAAC,OAAO;;;YAChB,MAAM,EACL,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,QAAQ,GACR,GAAG,OAAO,CAAC,UAAU,CAAC;YAEvB,MAAM,SAAS,GAAG,MAAC,OAAO,CAAC,UAAU,CAAC,KAAkB,mCAAI,EAAE,CAAC;YAC/D,MAAM,SAAS,GAAG,MAAC,OAAO,CAAC,UAAU,CAAC,KAAkB,mCAAI,EAAE,CAAC;YAC/D,MAAM,QAAQ,GAAG,MAAC,OAAO,CAAC,UA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YAAY;gBACtC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;gBAC1C,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,WAAW,EAAE,kBAAkB;aAC/B,CAAC,CAAC;YAEH,MAAM,kBAAkB,GAAG,IAAA,mCAA0B,EAAC,oBAAoB,EAAE,YAAY,CAAC,CAAC;YAE1F,IAAI,CAAC,IAAA,gBAAO,EAAC,kBAAkB,CAAC,EAAE,CAAC;gBAClC,aAAa,CAAC,aAAa,GAAG,kBAAkB,CAAC;YAClD,CAAC;YAED,MAAM,qBAAqB,GAAG,MAAM,IAAA,yBAAgB,EAAoB;gBACvE,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,YAAY;gBACtC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;gBAC1C,MAAM,EAAE,0BAAU,CAAC,KAAK;gBACxB,WAAW,EAAE,eAAe,QAAQ,EAAE;gBACtC,IAAI,EAAE,aAAa;aACnB,CAAC,CAAC;YAEH,MAAM,2BAA2B,GAAG,IAAA,uCAA8B,EACjE,oBAAoB,EACpB,qBAAqB,CAAC,IAAI,CAC1B,CAAC;YAEF,uCACI,qBAAqB,KACxB,IAAI,EAAE,2BAA2B,IAChC;QACH,CAAC;KAAA;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ORGANIZATION_OPTIONAL_FIELDS = exports.DEAL_OPTIONAL_FIELDS = exports.PERSON_OPTIONAL_FIELDS = void 0;
|
|
4
|
+
exports.PERSON_OPTIONAL_FIELDS = [
|
|
5
|
+
'next_activity_id',
|
|
6
|
+
'last_activity_id',
|
|
7
|
+
'open_deals_count',
|
|
8
|
+
'related_open_deals_count',
|
|
9
|
+
'closed_deals_count',
|
|
10
|
+
'related_closed_deals_count',
|
|
11
|
+
'participant_open_deals_count',
|
|
12
|
+
'participant_closed_deals_count',
|
|
13
|
+
'email_messages_count',
|
|
14
|
+
'activities_count',
|
|
15
|
+
'done_activities_count',
|
|
16
|
+
'undone_activities_count',
|
|
17
|
+
'files_count',
|
|
18
|
+
'notes_count',
|
|
19
|
+
'followers_count',
|
|
20
|
+
'related_won_deals_count',
|
|
21
|
+
'lost_deals_count',
|
|
22
|
+
'related_lost_deals_count',
|
|
23
|
+
'last_incoming_mail_time',
|
|
24
|
+
'last_outgoing_mail_time',
|
|
25
|
+
'won_deals_count',
|
|
26
|
+
];
|
|
27
|
+
exports.DEAL_OPTIONAL_FIELDS = [
|
|
28
|
+
'next_activity_id',
|
|
29
|
+
'last_activity_id',
|
|
30
|
+
'first_won_time',
|
|
31
|
+
'products_count',
|
|
32
|
+
'files_count',
|
|
33
|
+
'notes_count',
|
|
34
|
+
'followers_count',
|
|
35
|
+
'email_messages_count',
|
|
36
|
+
'activities_count',
|
|
37
|
+
'done_activities_count',
|
|
38
|
+
'undone_activities_count',
|
|
39
|
+
'participants_count',
|
|
40
|
+
'last_incoming_mail_time',
|
|
41
|
+
'last_outgoing_mail_time',
|
|
42
|
+
'smart_bcc_email',
|
|
43
|
+
];
|
|
44
|
+
exports.ORGANIZATION_OPTIONAL_FIELDS = [
|
|
45
|
+
'next_activity_id',
|
|
46
|
+
'last_activity_id',
|
|
47
|
+
'open_deals_count',
|
|
48
|
+
'related_open_deals_count',
|
|
49
|
+
'closed_deals_count',
|
|
50
|
+
'related_closed_deals_count',
|
|
51
|
+
'email_messages_count',
|
|
52
|
+
'people_count',
|
|
53
|
+
'activities_count',
|
|
54
|
+
'done_activities_count',
|
|
55
|
+
'undone_activities_count',
|
|
56
|
+
'files_count',
|
|
57
|
+
'notes_count',
|
|
58
|
+
'followers_count',
|
|
59
|
+
'won_deals_count',
|
|
60
|
+
'related_won_deals_count',
|
|
61
|
+
'lost_deals_count',
|
|
62
|
+
'related_lost_deals_count',
|
|
63
|
+
];
|
|
64
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/pipedrive/src/lib/common/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG;IACrC,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;IAClB,0BAA0B;IAC1B,oBAAoB;IACpB,4BAA4B;IAC5B,8BAA8B;IAC9B,gCAAgC;IAChC,sBAAsB;IACtB,kBAAkB;IAClB,uBAAuB;IACvB,yBAAyB;IACzB,aAAa;IACb,aAAa;IACb,iBAAiB;IACjB,yBAAyB;IACzB,kBAAkB;IAClB,0BAA0B;IAC1B,yBAAyB;IACzB,yBAAyB;IACzB,iBAAiB;CACjB,CAAC;AAEW,QAAA,oBAAoB,GAAG;IACnC,kBAAkB;IAClB,kBAAkB;IAClB,gBAAgB;IAChB,gBAAgB;IAChB,aAAa;IACb,aAAa;IACb,iBAAiB;IACjB,sBAAsB;IACtB,kBAAkB;IAClB,uBAAuB;IACvB,yBAAyB;IACzB,oBAAoB;IACpB,yBAAyB;IACzB,yBAAyB;IACzB,iBAAiB;CACjB,CAAC;AAEW,QAAA,4BAA4B,GAAG;IAC3C,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;IAClB,0BAA0B;IAC1B,oBAAoB;IACpB,4BAA4B;IAC5B,sBAAsB;IACtB,cAAc;IACd,kBAAkB;IAClB,uBAAuB;IACvB,yBAAyB;IACzB,aAAa;IACb,aAAa;IACb,iBAAiB;IACjB,iBAAiB;IACjB,yBAAyB;IACzB,kBAAkB;IAClB,0BAA0B;CAC1B,CAAC"}
|
|
@@ -17,5 +17,8 @@ export type PipedriveApiCallParams = {
|
|
|
17
17
|
body?: any;
|
|
18
18
|
};
|
|
19
19
|
export declare function pipedriveApiCall<T extends HttpMessageBody>({ accessToken, apiDomain, method, resourceUri, query, body, }: PipedriveApiCallParams): Promise<T>;
|
|
20
|
-
export declare function
|
|
21
|
-
export declare function
|
|
20
|
+
export declare function pipedrivePaginatedV1ApiCall<T extends HttpMessageBody>({ accessToken, apiDomain, method, resourceUri, query, body, }: PipedriveApiCallParams): Promise<T[]>;
|
|
21
|
+
export declare function pipedrivePaginatedV2ApiCall<T extends HttpMessageBody>({ accessToken, apiDomain, method, resourceUri, query, body, }: PipedriveApiCallParams): Promise<T[]>;
|
|
22
|
+
export declare function pipedriveParseCustomFields(customFieldsDefinitions: GetField[], inputData: Record<string, any>): Record<string, any>;
|
|
23
|
+
export declare function pipedriveTransformCustomFields(customFieldsDefinitions: GetField[], responseData: Record<string, any>): Record<string, any>;
|
|
24
|
+
export declare function pipedriveTransformV1CustomFields(CustomFields: GetField[], responseData: Record<string, any>): Record<string, any>;
|
package/src/lib/common/index.js
CHANGED
|
@@ -2,11 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.pipedriveCommon = void 0;
|
|
4
4
|
exports.pipedriveApiCall = pipedriveApiCall;
|
|
5
|
-
exports.
|
|
5
|
+
exports.pipedrivePaginatedV1ApiCall = pipedrivePaginatedV1ApiCall;
|
|
6
|
+
exports.pipedrivePaginatedV2ApiCall = pipedrivePaginatedV2ApiCall;
|
|
7
|
+
exports.pipedriveParseCustomFields = pipedriveParseCustomFields;
|
|
6
8
|
exports.pipedriveTransformCustomFields = pipedriveTransformCustomFields;
|
|
9
|
+
exports.pipedriveTransformV1CustomFields = pipedriveTransformV1CustomFields;
|
|
7
10
|
const tslib_1 = require("tslib");
|
|
8
11
|
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
9
12
|
const shared_1 = require("@activepieces/shared");
|
|
13
|
+
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
10
14
|
exports.pipedriveCommon = {
|
|
11
15
|
subscribeWebhook: (object, action, webhookUrl, apiDomain, accessToken) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
12
16
|
const request = {
|
|
@@ -16,7 +20,7 @@ exports.pipedriveCommon = {
|
|
|
16
20
|
event_object: object,
|
|
17
21
|
event_action: action,
|
|
18
22
|
subscription_url: webhookUrl,
|
|
19
|
-
version: '
|
|
23
|
+
version: '2.0',
|
|
20
24
|
},
|
|
21
25
|
authentication: {
|
|
22
26
|
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
@@ -41,18 +45,18 @@ exports.pipedriveCommon = {
|
|
|
41
45
|
};
|
|
42
46
|
function pipedriveApiCall(_a) {
|
|
43
47
|
return tslib_1.__awaiter(this, arguments, void 0, function* ({ accessToken, apiDomain, method, resourceUri, query, body, }) {
|
|
44
|
-
const
|
|
48
|
+
const url = `${apiDomain}/api${resourceUri}`;
|
|
45
49
|
const qs = {};
|
|
46
|
-
let data;
|
|
47
50
|
if (query) {
|
|
48
51
|
for (const [key, value] of Object.entries(query)) {
|
|
49
52
|
if (value !== null && value !== undefined) {
|
|
50
|
-
qs[key] = String(value);
|
|
53
|
+
qs[key] = Array.isArray(value) ? value.map(String).join(',') : String(value);
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
}
|
|
57
|
+
let requestBody;
|
|
54
58
|
if (body) {
|
|
55
|
-
|
|
59
|
+
requestBody = Object.entries(body).reduce((acc, [key, value]) => {
|
|
56
60
|
if (!(0, shared_1.isNil)(value)) {
|
|
57
61
|
acc[key] = value;
|
|
58
62
|
}
|
|
@@ -61,13 +65,13 @@ function pipedriveApiCall(_a) {
|
|
|
61
65
|
}
|
|
62
66
|
const request = {
|
|
63
67
|
method,
|
|
64
|
-
url
|
|
68
|
+
url,
|
|
65
69
|
authentication: {
|
|
66
70
|
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
67
71
|
token: accessToken,
|
|
68
72
|
},
|
|
69
73
|
queryParams: qs,
|
|
70
|
-
body:
|
|
74
|
+
body: requestBody,
|
|
71
75
|
};
|
|
72
76
|
try {
|
|
73
77
|
const response = yield pieces_common_1.httpClient.sendRequest(request);
|
|
@@ -83,7 +87,7 @@ function pipedriveApiCall(_a) {
|
|
|
83
87
|
}
|
|
84
88
|
});
|
|
85
89
|
}
|
|
86
|
-
function
|
|
90
|
+
function pipedrivePaginatedV1ApiCall(_a) {
|
|
87
91
|
return tslib_1.__awaiter(this, arguments, void 0, function* ({ accessToken, apiDomain, method, resourceUri, query, body, }) {
|
|
88
92
|
const qs = query ? query : {};
|
|
89
93
|
qs.start = 0;
|
|
@@ -109,7 +113,120 @@ function pipedrivePaginatedApiCall(_a) {
|
|
|
109
113
|
return resultData;
|
|
110
114
|
});
|
|
111
115
|
}
|
|
112
|
-
function
|
|
116
|
+
function pipedrivePaginatedV2ApiCall(_a) {
|
|
117
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ accessToken, apiDomain, method, resourceUri, query, body, }) {
|
|
118
|
+
var _b, _c;
|
|
119
|
+
const qs = query ? Object.assign({}, query) : {};
|
|
120
|
+
let cursor = undefined;
|
|
121
|
+
const resultData = [];
|
|
122
|
+
let hasMoreItems = true;
|
|
123
|
+
do {
|
|
124
|
+
const currentQuery = Object.assign({}, qs);
|
|
125
|
+
if (cursor) {
|
|
126
|
+
currentQuery.cursor = cursor;
|
|
127
|
+
}
|
|
128
|
+
currentQuery.limit = 500;
|
|
129
|
+
const response = yield pipedriveApiCall({
|
|
130
|
+
accessToken,
|
|
131
|
+
apiDomain,
|
|
132
|
+
method,
|
|
133
|
+
resourceUri,
|
|
134
|
+
query: currentQuery,
|
|
135
|
+
body,
|
|
136
|
+
});
|
|
137
|
+
if ((0, shared_1.isNil)(response.data)) {
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
if (Array.isArray(response.data)) {
|
|
141
|
+
resultData.push(...response.data);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
resultData.push(response.data);
|
|
145
|
+
}
|
|
146
|
+
hasMoreItems = ((_b = response.additional_data) === null || _b === void 0 ? void 0 : _b.next_cursor) != null;
|
|
147
|
+
cursor = (_c = response.additional_data) === null || _c === void 0 ? void 0 : _c.next_cursor;
|
|
148
|
+
} while (hasMoreItems && cursor);
|
|
149
|
+
return resultData;
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
function formatDateIfValid(val) {
|
|
153
|
+
return (0, dayjs_1.default)(val).isValid() ? (0, dayjs_1.default)(val).format('YYYY-MM-DD') : val;
|
|
154
|
+
}
|
|
155
|
+
function pipedriveParseCustomFields(customFieldsDefinitions, inputData) {
|
|
156
|
+
const fieldTypeMap = customFieldsDefinitions.reduce((acc, field) => {
|
|
157
|
+
acc[field.key] = field;
|
|
158
|
+
return acc;
|
|
159
|
+
}, {});
|
|
160
|
+
const parsedFields = {};
|
|
161
|
+
for (const [key, value] of Object.entries(inputData)) {
|
|
162
|
+
if ((0, shared_1.isEmpty)(value))
|
|
163
|
+
continue;
|
|
164
|
+
const matchedField = fieldTypeMap[key];
|
|
165
|
+
if (!matchedField)
|
|
166
|
+
continue;
|
|
167
|
+
// https://pipedrive.readme.io/docs/pipedrive-api-v2-migration-guide#custom-fields
|
|
168
|
+
if (matchedField.is_subfield) {
|
|
169
|
+
const parentField = key.split('_')[0];
|
|
170
|
+
parsedFields[parentField] = Object.assign(Object.assign({}, parsedFields[parentField]), { [matchedField.id_suffix]: matchedField.field_type === "date" ? formatDateIfValid(value) : value });
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
switch (matchedField.field_type) {
|
|
174
|
+
case 'monetary':
|
|
175
|
+
parsedFields[key] = Object.assign(Object.assign({}, parsedFields[key]), { value: Number(value) });
|
|
176
|
+
break;
|
|
177
|
+
case 'address':
|
|
178
|
+
case 'daterange':
|
|
179
|
+
case 'timerange':
|
|
180
|
+
case 'time':
|
|
181
|
+
parsedFields[key] = Object.assign(Object.assign({}, parsedFields[key]), { value: formatDateIfValid(value) });
|
|
182
|
+
break;
|
|
183
|
+
case 'date':
|
|
184
|
+
parsedFields[key] = formatDateIfValid(value);
|
|
185
|
+
break;
|
|
186
|
+
default:
|
|
187
|
+
parsedFields[key] = value;
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return parsedFields;
|
|
192
|
+
}
|
|
193
|
+
function pipedriveTransformCustomFields(customFieldsDefinitions, responseData) {
|
|
194
|
+
var _a, _b;
|
|
195
|
+
const updatedResponseData = Object.assign({}, responseData);
|
|
196
|
+
const rawCustomFields = responseData.custom_fields || {};
|
|
197
|
+
for (const field of customFieldsDefinitions) {
|
|
198
|
+
if (!field.edit_flag) {
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
const oldKey = field.key;
|
|
202
|
+
const newKey = field.name;
|
|
203
|
+
const fieldType = field.field_type;
|
|
204
|
+
if (oldKey in rawCustomFields) {
|
|
205
|
+
const value = rawCustomFields[oldKey];
|
|
206
|
+
if ((0, shared_1.isNil)(value)) {
|
|
207
|
+
updatedResponseData[newKey] = null;
|
|
208
|
+
}
|
|
209
|
+
else if (fieldType === 'enum') {
|
|
210
|
+
updatedResponseData[newKey] =
|
|
211
|
+
((_b = (_a = field.options) === null || _a === void 0 ? void 0 : _a.find((option) => option.id === value)) === null || _b === void 0 ? void 0 : _b.label) || null;
|
|
212
|
+
}
|
|
213
|
+
else if (fieldType === 'set') {
|
|
214
|
+
if (Array.isArray(value)) {
|
|
215
|
+
updatedResponseData[newKey] = value.map((item) => { var _a, _b; return ((_b = (_a = field.options) === null || _a === void 0 ? void 0 : _a.find((option) => option.id === item)) === null || _b === void 0 ? void 0 : _b.label) || null; });
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
updatedResponseData[newKey] = value;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
updatedResponseData[newKey] = value;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
delete updatedResponseData.custom_fields;
|
|
227
|
+
return updatedResponseData;
|
|
228
|
+
}
|
|
229
|
+
function pipedriveTransformV1CustomFields(CustomFields, responseData) {
|
|
113
230
|
var _a, _b;
|
|
114
231
|
const updatedResponseData = Object.assign({}, responseData);
|
|
115
232
|
for (const field of CustomFields) {
|