@segment/action-destinations 3.28.1-alpha.1 → 3.30.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 (115) hide show
  1. package/dist/destinations/index.js +0 -1
  2. package/dist/destinations/index.js.map +1 -1
  3. package/dist/destinations/mixpanel/groupIdentifyUser/generated-types.d.ts +1 -1
  4. package/dist/destinations/mixpanel/groupIdentifyUser/index.d.ts +1 -1
  5. package/dist/destinations/mixpanel/groupIdentifyUser/index.js +10 -8
  6. package/dist/destinations/mixpanel/groupIdentifyUser/index.js.map +1 -1
  7. package/dist/destinations/pipedrive/createUpdateActivity/generated-types.d.ts +17 -0
  8. package/dist/destinations/{facebook-conversions-api/addToCart → pipedrive/createUpdateActivity}/generated-types.js +0 -0
  9. package/dist/destinations/pipedrive/createUpdateActivity/generated-types.js.map +1 -0
  10. package/dist/destinations/{facebook-conversions-api/custom → pipedrive/createUpdateActivity}/index.d.ts +1 -1
  11. package/dist/destinations/pipedrive/createUpdateActivity/index.js +157 -0
  12. package/dist/destinations/pipedrive/createUpdateActivity/index.js.map +1 -0
  13. package/dist/destinations/pipedrive/createUpdateDeal/generated-types.d.ts +18 -0
  14. package/dist/destinations/{facebook-conversions-api/custom → pipedrive/createUpdateDeal}/generated-types.js +0 -0
  15. package/dist/destinations/pipedrive/createUpdateDeal/generated-types.js.map +1 -0
  16. package/dist/destinations/{facebook-conversions-api/pageView → pipedrive/createUpdateDeal}/index.d.ts +1 -1
  17. package/dist/destinations/pipedrive/createUpdateDeal/index.js +174 -0
  18. package/dist/destinations/pipedrive/createUpdateDeal/index.js.map +1 -0
  19. package/dist/destinations/pipedrive/createUpdateLead/generated-types.d.ts +15 -0
  20. package/dist/destinations/{facebook-conversions-api → pipedrive/createUpdateLead}/generated-types.js +0 -0
  21. package/dist/destinations/pipedrive/createUpdateLead/generated-types.js.map +1 -0
  22. package/dist/destinations/{facebook-conversions-api/initiateCheckout → pipedrive/createUpdateLead}/index.d.ts +1 -1
  23. package/dist/destinations/pipedrive/createUpdateLead/index.js +129 -0
  24. package/dist/destinations/pipedrive/createUpdateLead/index.js.map +1 -0
  25. package/dist/destinations/pipedrive/createUpdateNote/generated-types.d.ts +11 -0
  26. package/dist/destinations/{facebook-conversions-api/initiateCheckout → pipedrive/createUpdateNote}/generated-types.js +0 -0
  27. package/dist/destinations/pipedrive/createUpdateNote/generated-types.js.map +1 -0
  28. package/dist/destinations/{facebook-conversions-api/addToCart → pipedrive/createUpdateNote}/index.d.ts +1 -1
  29. package/dist/destinations/pipedrive/createUpdateNote/index.js +115 -0
  30. package/dist/destinations/pipedrive/createUpdateNote/index.js.map +1 -0
  31. package/dist/destinations/pipedrive/createUpdateOrganization/generated-types.d.ts +5 -4
  32. package/dist/destinations/pipedrive/createUpdateOrganization/index.js +38 -30
  33. package/dist/destinations/pipedrive/createUpdateOrganization/index.js.map +1 -1
  34. package/dist/destinations/pipedrive/createUpdatePerson/generated-types.d.ts +6 -5
  35. package/dist/destinations/pipedrive/createUpdatePerson/index.js +39 -55
  36. package/dist/destinations/pipedrive/createUpdatePerson/index.js.map +1 -1
  37. package/dist/destinations/pipedrive/generated-types.d.ts +3 -0
  38. package/dist/destinations/pipedrive/index.js +31 -2
  39. package/dist/destinations/pipedrive/index.js.map +1 -1
  40. package/dist/destinations/pipedrive/pipedriveApi/activities.d.ts +17 -0
  41. package/dist/destinations/pipedrive/pipedriveApi/activities.js +11 -0
  42. package/dist/destinations/pipedrive/pipedriveApi/activities.js.map +1 -0
  43. package/dist/destinations/pipedrive/pipedriveApi/deals.d.ts +18 -0
  44. package/dist/destinations/pipedrive/pipedriveApi/deals.js +8 -0
  45. package/dist/destinations/pipedrive/pipedriveApi/deals.js.map +1 -0
  46. package/dist/destinations/pipedrive/pipedriveApi/domain.d.ts +19 -0
  47. package/dist/destinations/pipedrive/pipedriveApi/domain.js +3 -0
  48. package/dist/destinations/pipedrive/pipedriveApi/domain.js.map +1 -0
  49. package/dist/destinations/pipedrive/pipedriveApi/leads.d.ts +12 -0
  50. package/dist/destinations/pipedrive/pipedriveApi/leads.js +8 -0
  51. package/dist/destinations/pipedrive/pipedriveApi/leads.js.map +1 -0
  52. package/dist/destinations/pipedrive/pipedriveApi/notes.d.ts +11 -0
  53. package/dist/destinations/pipedrive/pipedriveApi/notes.js +8 -0
  54. package/dist/destinations/pipedrive/pipedriveApi/notes.js.map +1 -0
  55. package/dist/destinations/pipedrive/pipedriveApi/organizations.d.ts +8 -0
  56. package/dist/destinations/pipedrive/pipedriveApi/organizations.js +19 -0
  57. package/dist/destinations/pipedrive/pipedriveApi/organizations.js.map +1 -0
  58. package/dist/destinations/pipedrive/pipedriveApi/persons.d.ts +10 -0
  59. package/dist/destinations/pipedrive/pipedriveApi/persons.js +19 -0
  60. package/dist/destinations/pipedrive/pipedriveApi/persons.js.map +1 -0
  61. package/dist/destinations/pipedrive/pipedriveApi/pipedrive-client.d.ts +29 -0
  62. package/dist/destinations/pipedrive/pipedriveApi/pipedrive-client.js +118 -0
  63. package/dist/destinations/pipedrive/pipedriveApi/pipedrive-client.js.map +1 -0
  64. package/dist/lib/test-data.js +9 -2
  65. package/dist/lib/test-data.js.map +1 -1
  66. package/package.json +3 -4
  67. package/dist/destinations/facebook-conversions-api/addToCart/generated-types.d.ts +0 -37
  68. package/dist/destinations/facebook-conversions-api/addToCart/generated-types.js.map +0 -1
  69. package/dist/destinations/facebook-conversions-api/addToCart/index.js +0 -84
  70. package/dist/destinations/facebook-conversions-api/addToCart/index.js.map +0 -1
  71. package/dist/destinations/facebook-conversions-api/constants.d.ts +0 -4
  72. package/dist/destinations/facebook-conversions-api/constants.js +0 -485
  73. package/dist/destinations/facebook-conversions-api/constants.js.map +0 -1
  74. package/dist/destinations/facebook-conversions-api/custom/generated-types.d.ts +0 -30
  75. package/dist/destinations/facebook-conversions-api/custom/generated-types.js.map +0 -1
  76. package/dist/destinations/facebook-conversions-api/custom/index.js +0 -58
  77. package/dist/destinations/facebook-conversions-api/custom/index.js.map +0 -1
  78. package/dist/destinations/facebook-conversions-api/fb-capi-properties.d.ts +0 -13
  79. package/dist/destinations/facebook-conversions-api/fb-capi-properties.js +0 -100
  80. package/dist/destinations/facebook-conversions-api/fb-capi-properties.js.map +0 -1
  81. package/dist/destinations/facebook-conversions-api/fb-capi-user-data.d.ts +0 -7
  82. package/dist/destinations/facebook-conversions-api/fb-capi-user-data.js +0 -227
  83. package/dist/destinations/facebook-conversions-api/fb-capi-user-data.js.map +0 -1
  84. package/dist/destinations/facebook-conversions-api/generated-types.d.ts +0 -3
  85. package/dist/destinations/facebook-conversions-api/generated-types.js.map +0 -1
  86. package/dist/destinations/facebook-conversions-api/index.d.ts +0 -4
  87. package/dist/destinations/facebook-conversions-api/index.js +0 -51
  88. package/dist/destinations/facebook-conversions-api/index.js.map +0 -1
  89. package/dist/destinations/facebook-conversions-api/initiateCheckout/generated-types.d.ts +0 -37
  90. package/dist/destinations/facebook-conversions-api/initiateCheckout/generated-types.js.map +0 -1
  91. package/dist/destinations/facebook-conversions-api/initiateCheckout/index.js +0 -89
  92. package/dist/destinations/facebook-conversions-api/initiateCheckout/index.js.map +0 -1
  93. package/dist/destinations/facebook-conversions-api/pageView/generated-types.d.ts +0 -26
  94. package/dist/destinations/facebook-conversions-api/pageView/generated-types.js +0 -3
  95. package/dist/destinations/facebook-conversions-api/pageView/generated-types.js.map +0 -1
  96. package/dist/destinations/facebook-conversions-api/pageView/index.js +0 -43
  97. package/dist/destinations/facebook-conversions-api/pageView/index.js.map +0 -1
  98. package/dist/destinations/facebook-conversions-api/purchase/generated-types.d.ts +0 -38
  99. package/dist/destinations/facebook-conversions-api/purchase/generated-types.js +0 -3
  100. package/dist/destinations/facebook-conversions-api/purchase/generated-types.js.map +0 -1
  101. package/dist/destinations/facebook-conversions-api/purchase/index.d.ts +0 -5
  102. package/dist/destinations/facebook-conversions-api/purchase/index.js +0 -92
  103. package/dist/destinations/facebook-conversions-api/purchase/index.js.map +0 -1
  104. package/dist/destinations/facebook-conversions-api/search/generated-types.d.ts +0 -37
  105. package/dist/destinations/facebook-conversions-api/search/generated-types.js +0 -3
  106. package/dist/destinations/facebook-conversions-api/search/generated-types.js.map +0 -1
  107. package/dist/destinations/facebook-conversions-api/search/index.d.ts +0 -5
  108. package/dist/destinations/facebook-conversions-api/search/index.js +0 -91
  109. package/dist/destinations/facebook-conversions-api/search/index.js.map +0 -1
  110. package/dist/destinations/facebook-conversions-api/viewContent/generated-types.d.ts +0 -38
  111. package/dist/destinations/facebook-conversions-api/viewContent/generated-types.js +0 -3
  112. package/dist/destinations/facebook-conversions-api/viewContent/generated-types.js.map +0 -1
  113. package/dist/destinations/facebook-conversions-api/viewContent/index.d.ts +0 -5
  114. package/dist/destinations/facebook-conversions-api/viewContent/index.js +0 -85
  115. package/dist/destinations/facebook-conversions-api/viewContent/index.js.map +0 -1
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const pipedrive_client_1 = __importDefault(require("../pipedriveApi/pipedrive-client"));
7
+ const leads_1 = require("../pipedriveApi/leads");
8
+ const actions_core_1 = require("@segment/actions-core");
9
+ const fieldHandler = pipedrive_client_1.default.fieldHandler;
10
+ const action = {
11
+ title: 'Create or Update a Lead',
12
+ description: "Update a Lead in Pipedrive or create it if it doesn't exist yet.",
13
+ defaultSubscription: 'type = "identify"',
14
+ fields: {
15
+ lead_id: {
16
+ label: 'Lead ID',
17
+ description: 'ID of Lead in Pipedrive to Update. If left empty, a new one will be created',
18
+ type: 'integer',
19
+ required: false
20
+ },
21
+ person_match_field: {
22
+ label: 'Person match field',
23
+ description: 'If present, used instead of field in settings to find existing person in Pipedrive.',
24
+ type: 'string',
25
+ required: false,
26
+ dynamic: true,
27
+ default: 'id'
28
+ },
29
+ person_match_value: {
30
+ label: 'Person match value',
31
+ description: 'Value to find existing person by. Required unless organization_match_value present',
32
+ type: 'string',
33
+ required: false,
34
+ default: {
35
+ '@path': '$.userId'
36
+ }
37
+ },
38
+ organization_match_field: {
39
+ label: 'Organization match field',
40
+ description: 'If present, used instead of field in settings to find existing organization in Pipedrive.',
41
+ type: 'string',
42
+ required: false,
43
+ dynamic: true,
44
+ default: 'id'
45
+ },
46
+ organization_match_value: {
47
+ label: 'Organization match value',
48
+ description: 'Value to find existing organization by. Required unless person_match_value present',
49
+ type: 'string',
50
+ required: false,
51
+ default: {
52
+ '@path': '$.userId'
53
+ }
54
+ },
55
+ title: {
56
+ label: 'Title',
57
+ description: 'The name of the Lead',
58
+ type: 'string',
59
+ required: true
60
+ },
61
+ value: {
62
+ type: 'object',
63
+ label: 'Value',
64
+ description: 'Potential value of the lead',
65
+ properties: {
66
+ amount: {
67
+ label: 'Amount',
68
+ type: 'number'
69
+ },
70
+ currency: {
71
+ label: 'Currency',
72
+ description: 'Three-letter code of the currency, e.g. USD',
73
+ type: 'string'
74
+ }
75
+ }
76
+ },
77
+ expected_close_date: {
78
+ label: 'Expected Close Date',
79
+ description: 'The date of when the Deal which will be created from the Lead is expected to be closed. In ISO 8601 format: YYYY-MM-DD.',
80
+ type: 'string',
81
+ required: false
82
+ },
83
+ visible_to: {
84
+ label: 'Visible To',
85
+ description: 'Visibility of the Lead. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.',
86
+ type: 'integer',
87
+ choices: [
88
+ { label: 'Owner & followers (private)', value: 1 },
89
+ { label: 'Entire company (shared)', value: 3 }
90
+ ],
91
+ required: false
92
+ },
93
+ add_time: {
94
+ label: 'Created At',
95
+ description: 'If the lead is created, use this timestamp as the creation timestamp. Format: YYY-MM-DD HH:MM:SS',
96
+ type: 'datetime',
97
+ required: false
98
+ }
99
+ },
100
+ dynamicFields: {
101
+ person_match_field: fieldHandler('person'),
102
+ organization_match_field: fieldHandler('organization')
103
+ },
104
+ perform: async (request, { payload, settings }) => {
105
+ const client = new pipedrive_client_1.default(settings, request);
106
+ const personSearchField = payload.person_match_field || settings.personField || 'id';
107
+ const organizationSearchField = payload.organization_match_field || settings.organizationField || 'id';
108
+ const [personId, organizationId] = await Promise.all([
109
+ client.getId('person', personSearchField, payload.person_match_value),
110
+ client.getId('organization', organizationSearchField, payload.organization_match_value)
111
+ ]);
112
+ const lead = {
113
+ id: payload.lead_id,
114
+ title: payload.title,
115
+ expected_close_date: payload.expected_close_date,
116
+ visible_to: payload.visible_to,
117
+ person_id: personId || undefined,
118
+ organization_id: organizationId || undefined,
119
+ value: payload.value,
120
+ add_time: payload.add_time ? `${payload.add_time}` : undefined
121
+ };
122
+ if (!lead.id && !lead.person_id && !lead.organization_id) {
123
+ throw new actions_core_1.IntegrationError('No related organization or person, unable to create lead!', 'INVALID_REQUEST_DATA', 400);
124
+ }
125
+ return leads_1.createUpdateLead(client, lead);
126
+ }
127
+ };
128
+ exports.default = action;
129
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/pipedrive/createUpdateLead/index.ts"],"names":[],"mappings":";;;;;AAGA,wFAA8D;AAC9D,iDAA8D;AAC9D,wDAAwD;AAExD,MAAM,YAAY,GAAG,0BAAe,CAAC,YAAY,CAAA;AAEjD,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,yBAAyB;IAChC,WAAW,EAAE,kEAAkE;IAC/E,mBAAmB,EAAE,mBAAmB;IACxC,MAAM,EAAE;QACN,OAAO,EAAE;YACP,KAAK,EAAE,SAAS;YAChB,WAAW,EAAE,6EAA6E;YAC1F,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,KAAK;SAChB;QACD,kBAAkB,EAAE;YAClB,KAAK,EAAE,oBAAoB;YAC3B,WAAW,EAAE,qFAAqF;YAClG,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;SACd;QACD,kBAAkB,EAAE;YACl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,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS;SAC/D,CAAA;QAED,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACxD,MAAM,IAAI,+BAAgB,CACxB,2DAA2D,EAC3D,sBAAsB,EACtB,GAAG,CACJ,CAAA;SACF;QAED,OAAO,wBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACvC,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -0,0 +1,11 @@
1
+ export interface Payload {
2
+ note_id?: number;
3
+ lead_id?: number;
4
+ person_match_field?: string;
5
+ person_match_value?: string;
6
+ organization_match_field?: string;
7
+ organization_match_value?: string;
8
+ deal_match_field?: string;
9
+ deal_match_value?: string;
10
+ content: string;
11
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/pipedrive/createUpdateNote/generated-types.ts"],"names":[],"mappings":""}
@@ -1,4 +1,4 @@
1
- import { ActionDefinition } from '@segment/actions-core';
1
+ import type { ActionDefinition } from '@segment/actions-core';
2
2
  import type { Settings } from '../generated-types';
3
3
  import type { Payload } from './generated-types';
4
4
  declare const action: ActionDefinition<Settings, Payload>;
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const notes_1 = require("../pipedriveApi/notes");
7
+ const pipedrive_client_1 = __importDefault(require("../pipedriveApi/pipedrive-client"));
8
+ const actions_core_1 = require("@segment/actions-core");
9
+ const fieldHandler = pipedrive_client_1.default.fieldHandler;
10
+ const action = {
11
+ title: 'Create or Update a Note',
12
+ description: "Update a Note in Pipedrive or create it if it doesn't exist yet.",
13
+ defaultSubscription: 'type = "track"',
14
+ fields: {
15
+ note_id: {
16
+ label: 'Note ID',
17
+ description: 'ID of Note in Pipedrive to Update. If left empty, a new one will be created',
18
+ type: 'integer',
19
+ required: false
20
+ },
21
+ lead_id: {
22
+ label: 'Lead ID',
23
+ description: 'ID of Lead in Pipedrive to link to. One of Lead, Person, Organization or Deal must be linked!',
24
+ type: 'integer',
25
+ required: false
26
+ },
27
+ person_match_field: {
28
+ label: 'Person match field',
29
+ description: 'If present, used instead of field in settings to find existing person in Pipedrive.',
30
+ type: 'string',
31
+ required: false,
32
+ dynamic: true,
33
+ default: 'id'
34
+ },
35
+ person_match_value: {
36
+ label: 'Person match value',
37
+ description: 'Value to find existing person by. One of Lead, Person, Organization or Deal must be linked!',
38
+ type: 'string',
39
+ required: false,
40
+ default: {
41
+ '@path': '$.userId'
42
+ }
43
+ },
44
+ organization_match_field: {
45
+ label: 'Organization match field',
46
+ description: 'If present, used instead of field in settings to find existing organization in Pipedrive.',
47
+ type: 'string',
48
+ required: false,
49
+ dynamic: true,
50
+ default: 'id'
51
+ },
52
+ organization_match_value: {
53
+ label: 'Organization match value',
54
+ description: 'Value to find existing organization by. One of Lead, Person, Organization or Deal must be linked!',
55
+ type: 'string',
56
+ required: false,
57
+ default: {
58
+ '@path': '$.userId'
59
+ }
60
+ },
61
+ deal_match_field: {
62
+ label: 'Deal match field',
63
+ description: 'If present, used instead of field in settings to find existing deal in Pipedrive.',
64
+ type: 'string',
65
+ required: false,
66
+ dynamic: true,
67
+ default: 'id'
68
+ },
69
+ deal_match_value: {
70
+ label: 'Deal match value',
71
+ description: 'Value to find existing deal by. One of Lead, Person, Organization or Deal must be linked!',
72
+ type: 'string',
73
+ required: false,
74
+ default: {
75
+ '@path': '$.userId'
76
+ }
77
+ },
78
+ content: {
79
+ label: 'Note Content',
80
+ description: 'Content of the note in HTML format. Subject to sanitization on the back-end.',
81
+ type: 'string',
82
+ required: true
83
+ }
84
+ },
85
+ dynamicFields: {
86
+ person_match_field: fieldHandler('person'),
87
+ organization_match_field: fieldHandler('organization'),
88
+ deal_match_field: fieldHandler('deal')
89
+ },
90
+ perform: async (request, { payload, settings }) => {
91
+ const client = new pipedrive_client_1.default(settings, request);
92
+ const personSearchField = payload.person_match_field || settings.personField || 'id';
93
+ const organizationSearchField = payload.organization_match_field || settings.organizationField || 'id';
94
+ const dealSearchField = payload.deal_match_field || settings.dealField || 'id';
95
+ const [personId, organizationId, dealId] = await Promise.all([
96
+ client.getId('person', personSearchField, payload.person_match_value),
97
+ client.getId('organization', organizationSearchField, payload.organization_match_value),
98
+ client.getId('deal', dealSearchField, payload.deal_match_value)
99
+ ]);
100
+ const note = {
101
+ id: payload.note_id,
102
+ content: payload.content,
103
+ lead_id: payload.lead_id,
104
+ person_id: personId || undefined,
105
+ org_id: organizationId || undefined,
106
+ deal_id: dealId || undefined
107
+ };
108
+ if ([note.id, note.lead_id, note.person_id, note.org_id, note.deal_id].every((v) => v === undefined)) {
109
+ throw new actions_core_1.IntegrationError('No related organization or person, unable to create/update note!', 'INVALID_REQUEST_DATA', 400);
110
+ }
111
+ return notes_1.createNote(client, note);
112
+ }
113
+ };
114
+ exports.default = action;
115
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/pipedrive/createUpdateNote/index.ts"],"names":[],"mappings":";;;;;AAEA,iDAAwD;AACxD,wFAA8D;AAE9D,wDAAwD;AAExD,MAAM,YAAY,GAAG,0BAAe,CAAC,YAAY,CAAA;AAEjD,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,yBAAyB;IAChC,WAAW,EAAE,kEAAkE;IAC/E,mBAAmB,EAAE,gBAAgB;IACrC,MAAM,EAAE;QACN,OAAO,EAAE;YACP,KAAK,EAAE,SAAS;YAChB,WAAW,EAAE,6EAA6E;YAC1F,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,KAAK;SAChB;QACD,OAAO,EAAE;YACP,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AA;QAED,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,EAAE;YACpG,MAAM,IAAI,+BAAgB,CACxB,kEAAkE,EAClE,sBAAsB,EACtB,GAAG,CACJ,CAAA;SACF;QAED,OAAO,kBAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACjC,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -1,6 +1,7 @@
1
1
  export interface Payload {
2
- identifier: string;
3
- name: string;
4
- owner_id?: number;
5
- add_time?: string;
2
+ match_field?: string;
3
+ match_value: string;
4
+ name?: string;
5
+ visible_to?: number;
6
+ add_time?: string | number;
6
7
  }
@@ -3,58 +3,66 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const dayjs_1 = __importDefault(require("../../../lib/dayjs"));
7
- const actions_core_1 = require("@segment/actions-core");
6
+ const pipedrive_client_1 = __importDefault(require("../pipedriveApi/pipedrive-client"));
7
+ const organizations_1 = require("../pipedriveApi/organizations");
8
+ const fieldHandler = pipedrive_client_1.default.fieldHandler;
8
9
  const action = {
9
10
  title: 'Create or Update Organization',
10
11
  description: "Update an organization in Pipedrive or create it if it doesn't exist yet.",
11
12
  defaultSubscription: 'type = "group"',
12
13
  fields: {
13
- identifier: {
14
- label: 'Organization ID',
15
- description: 'Identifier used to find existing organization in Pipedrive. Typically this is the name but it can also be a custom field value. Custom organization fields may be included by using the long hash keys of the custom fields. These look like "33595c732cd7a027c458ea115a48a7f8a254fa86".',
14
+ match_field: {
15
+ label: 'Match field',
16
+ description: 'If present, used instead of field in settings to find existing organization in Pipedrive.',
16
17
  type: 'string',
17
- required: true
18
+ required: false,
19
+ dynamic: true,
20
+ default: 'id'
21
+ },
22
+ match_value: {
23
+ label: 'Match value',
24
+ description: 'Value to find existing organization by',
25
+ type: 'string',
26
+ required: true,
27
+ default: {
28
+ '@path': '$.userId'
29
+ }
18
30
  },
19
31
  name: {
20
32
  label: 'Organization Name',
21
33
  description: 'Name of the organization',
22
34
  type: 'string',
23
- required: true
35
+ required: false
24
36
  },
25
- owner_id: {
26
- label: 'Owner ID',
27
- description: 'ID of the user who will be marked as the owner of this organization. Default is the user who ownes the API token.',
28
- type: 'number'
37
+ visible_to: {
38
+ label: 'Visible To',
39
+ description: 'Visibility of the Organization. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.',
40
+ type: 'integer',
41
+ choices: [
42
+ { label: 'Owner & followers (private)', value: 1 },
43
+ { label: 'Entire company (shared)', value: 3 }
44
+ ],
45
+ required: false
29
46
  },
30
47
  add_time: {
31
48
  label: 'Created At',
32
49
  description: 'If the organization is created, use this timestamp as the creation timestamp. Format: YYY-MM-DD HH:MM:SS',
33
- type: 'string'
50
+ type: 'datetime'
34
51
  }
35
52
  },
53
+ dynamicFields: {
54
+ match_field: fieldHandler('organization')
55
+ },
36
56
  perform: async (request, { payload, settings }) => {
37
- const search = await request(`https://${settings.domain}.pipedrive.com/api/v1/organizations/search`, {
38
- searchParams: { term: payload.identifier }
39
- });
40
- const organizationId = actions_core_1.get(search.data, 'data.items[0].item.id');
57
+ const searchField = payload.match_field || settings.personField || 'id';
58
+ const client = new pipedrive_client_1.default(settings, request);
59
+ const organizationId = await client.getId('organization', searchField, payload.match_value);
41
60
  const organization = {
42
61
  name: payload.name,
43
- owner_id: payload.owner_id
62
+ add_time: payload.add_time ? `${payload.add_time}` : undefined,
63
+ visible_to: payload.visible_to
44
64
  };
45
- if (organizationId === undefined || organizationId === null) {
46
- return request(`https://${settings.domain}.pipedrive.com/api/v1/organizations`, {
47
- method: 'post',
48
- json: {
49
- ...organization,
50
- add_time: payload.add_time ? dayjs_1.default.utc(payload.add_time).format('YYYY-MM-DD HH:MM:SS') : undefined
51
- }
52
- });
53
- }
54
- return request(`https://${settings.domain}.pipedrive.com/api/v1/organizations/${organizationId}`, {
55
- method: 'put',
56
- json: organization
57
- });
65
+ return organizations_1.createOrUpdateOrganizationById(request, settings.domain, organizationId, organization);
58
66
  }
59
67
  };
60
68
  exports.default = action;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/pipedrive/createUpdateOrganization/index.ts"],"names":[],"mappings":";;;;;AAAA,+DAAsC;AACtC,wDAA2C;AAK3C,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,+BAA+B;IACtC,WAAW,EAAE,2EAA2E;IACxF,mBAAmB,EAAE,gBAAgB;IACrC,MAAM,EAAE;QACN,UAAU,EAAE;YACV,KAAK,EAAE,iBAAiB;YACxB,WAAW,EACT,0RAA0R;YAC5R,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;SACf;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,mBAAmB;YAC1B,WAAW,EAAE,0BAA0B;YACvC,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;SACf;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,UAAU;YACjB,WAAW,EACT,mHAAmH;YACrH,IAAI,EAAE,QAAQ;SACf;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,YAAY;YACnB,WAAW,EACT,0GAA0G;YAC5G,IAAI,EAAE,QAAQ;SACf;KACF;IAED,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;QAChD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,WAAW,QAAQ,CAAC,MAAM,4CAA4C,EAAE;YACnG,YAAY,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE;SAC3C,CAAC,CAAA;QAEF,MAAM,cAAc,GAAG,kBAAG,CAAC,MAAM,CAAC,IAAI,EAAE,uBAAuB,CAAC,CAAA;QAEhE,MAAM,YAAY,GAAG;YACnB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,QAAQ,EAAE,OAAO,CAAC,QAAQ;SAC3B,CAAA;QAED,IAAI,cAAc,KAAK,SAAS,IAAI,cAAc,KAAK,IAAI,EAAE;YAC3D,OAAO,OAAO,CAAC,WAAW,QAAQ,CAAC,MAAM,qCAAqC,EAAE;gBAC9E,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE;oBACJ,GAAG,YAAY;oBACf,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,eAAK,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,SAAS;iBACnG;aACF,CAAC,CAAA;SACH;QAED,OAAO,OAAO,CAAC,WAAW,QAAQ,CAAC,MAAM,uCAAuC,cAAc,EAAE,EAAE;YAChG,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,YAAY;SACnB,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/pipedrive/createUpdateOrganization/index.ts"],"names":[],"mappings":";;;;;AAGA,wFAA8D;AAC9D,iEAA4F;AAE5F,MAAM,YAAY,GAAG,0BAAe,CAAC,YAAY,CAAA;AAEjD,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,+BAA+B;IACtC,WAAW,EAAE,2EAA2E;IACxF,mBAAmB,EAAE,gBAAgB;IACrC,MAAM,EAAE;QACN,WAAW,EAAE;YACX,KAAK,EAAE,aAAa;YACpB,WAAW,EAAE,2FAA2F;YACxG,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;SACd;QACD,WAAW,EAAE;YACX,KAAK,EAAE,a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,UAAU,EAAE,OAAO,CAAC,UAAU;SAC/B,CAAA;QAED,OAAO,8CAA8B,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,EAAE,cAAc,EAAE,YAAY,CAAC,CAAA;IAC/F,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -1,8 +1,9 @@
1
1
  export interface Payload {
2
- identifier: string;
3
- name: string;
4
- org_id?: number;
2
+ match_field?: string;
3
+ match_value: string;
4
+ name?: string;
5
5
  email?: string[];
6
- phone?: string;
7
- add_time?: string;
6
+ phone?: string[];
7
+ visible_to?: number;
8
+ add_time?: string | number;
8
9
  }
@@ -3,16 +3,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const dayjs_1 = __importDefault(require("../../../lib/dayjs"));
7
- const actions_core_1 = require("@segment/actions-core");
6
+ const pipedrive_client_1 = __importDefault(require("../pipedriveApi/pipedrive-client"));
7
+ const persons_1 = require("../pipedriveApi/persons");
8
+ const fieldHandler = pipedrive_client_1.default.fieldHandler;
8
9
  const action = {
9
10
  title: 'Create or Update Person',
10
11
  description: "Update a person in Pipedrive or create them if they don't exist yet.",
11
12
  defaultSubscription: 'type = "identify"',
12
13
  fields: {
13
- identifier: {
14
- label: 'Person ID',
15
- description: 'Identifier used to find existing person in Pipedrive. Can be an email, name, phone number, or custom field value. Custom person fields may be included by using the long hash keys of the custom fields. These look like "33595c732cd7a027c458ea115a48a7f8a254fa86".',
14
+ match_field: {
15
+ label: 'Match field',
16
+ description: 'If present, used instead of field in settings to find existing person in Pipedrive.',
17
+ type: 'string',
18
+ required: false,
19
+ dynamic: true,
20
+ default: 'id'
21
+ },
22
+ match_value: {
23
+ label: 'Match value',
24
+ description: 'Value to find existing person by',
16
25
  type: 'string',
17
26
  required: true,
18
27
  default: {
@@ -23,78 +32,53 @@ const action = {
23
32
  label: 'Person Name',
24
33
  description: 'Name of the person',
25
34
  type: 'string',
26
- required: true
27
- },
28
- org_id: {
29
- label: 'Organization ID',
30
- description: 'ID of the organization this person will belong to.',
31
- type: 'number',
32
- dynamic: true
35
+ required: false
33
36
  },
34
37
  email: {
35
38
  label: 'Email Address',
36
39
  description: 'Email addresses for this person.',
37
40
  type: 'string',
41
+ required: false,
38
42
  multiple: true
39
43
  },
40
44
  phone: {
41
45
  label: 'Phone Number',
42
- description: 'Phone number for the person.',
43
- type: 'string'
46
+ description: 'Phone numbers for the person.',
47
+ type: 'string',
48
+ required: false,
49
+ multiple: true
50
+ },
51
+ visible_to: {
52
+ label: 'Visible To',
53
+ description: 'Visibility of the Person. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.',
54
+ type: 'integer',
55
+ choices: [
56
+ { label: 'Owner & followers (private)', value: 1 },
57
+ { label: 'Entire company (shared)', value: 3 }
58
+ ],
59
+ required: false
44
60
  },
45
61
  add_time: {
46
62
  label: 'Created At',
47
63
  description: 'If the person is created, use this timestamp as the creation timestamp. Format: YYY-MM-DD HH:MM:SS',
48
- type: 'string'
64
+ type: 'datetime'
49
65
  }
50
66
  },
51
67
  dynamicFields: {
52
- org_id: async (request, { page, settings }) => {
53
- const searchParams = {};
54
- if (typeof page === 'string') {
55
- searchParams.start = Number(page);
56
- }
57
- const response = await request(`https://${settings.domain}.pipedrive.com/api/v1/organizations`, {
58
- searchParams
59
- });
60
- const body = response.data;
61
- const items = body.data.map((organization) => ({
62
- label: organization.name,
63
- value: organization.id
64
- }));
65
- let nextPage;
66
- if (typeof body.additional_data.pagination.next_start === 'number') {
67
- nextPage = String(body.additional_data.pagination.next_start);
68
- }
69
- return {
70
- body: {
71
- data: items,
72
- pagination: { nextPage }
73
- }
74
- };
75
- }
68
+ match_field: fieldHandler('person')
76
69
  },
77
70
  perform: async (request, { payload, settings }) => {
78
- const search = await request(`https://${settings.domain}.pipedrive.com/api/v1/persons/search`, {
79
- searchParams: { term: payload.identifier }
80
- });
81
- const personId = actions_core_1.get(search.data, 'data.items[0].item.id');
71
+ const searchField = payload.match_field || settings.personField || 'id';
72
+ const client = new pipedrive_client_1.default(settings, request);
73
+ const personId = await client.getId('person', searchField, payload.match_value);
82
74
  const person = {
83
75
  name: payload.name,
84
- org_id: payload.org_id,
85
76
  email: payload.email,
86
- phone: payload.phone
77
+ phone: payload.phone,
78
+ add_time: payload.add_time ? `${payload.add_time}` : undefined,
79
+ visible_to: payload.visible_to
87
80
  };
88
- if (personId === undefined || personId === null) {
89
- if (payload.add_time) {
90
- person.add_time = dayjs_1.default.utc(person.add_time).format('YYYY-MM-DD HH:MM:SS');
91
- }
92
- return request(`https://${settings.domain}.pipedrive.com/api/v1/persons`, { method: 'post', json: person });
93
- }
94
- return request(`https://${settings.domain}.pipedrive.com/api/v1/persons/${personId}`, {
95
- method: 'put',
96
- json: person
97
- });
81
+ return persons_1.createOrUpdatePersonById(request, settings.domain, personId, person);
98
82
  }
99
83
  };
100
84
  exports.default = action;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/pipedrive/createUpdatePerson/index.ts"],"names":[],"mappings":";;;;;AAAA,+DAAsC;AACtC,wDAA2C;AA2B3C,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,yBAAyB;IAChC,WAAW,EAAE,sEAAsE;IACnF,mBAAmB,EAAE,mBAAmB;IACxC,MAAM,EAAE;QACN,UAAU,EAAE;YACV,KAAK,EAAE,WAAW;YAClB,WAAW,EACT,sQAAsQ;YACxQ,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,UAAU;aACpB;SACF;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,aAAa;YACpB,WAAW,EAAE,oBAAoB;YACjC,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;SACf;QACD,MAAM,EAAE;YACN,KAAK,EAAE,iBAAiB;YACxB,WAAW,EAAE,oDAAoD;YAC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QAAQ,EAAE;YACR,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,oGAAoG;YACjH,IAAI,EAAE,UAAU;SACjB;KACF;IAED,aAAa,EAAE;QACb,WAAW,EAAE,YAAY,CAAC,QAAQ,CAAC;KACpC;IAED,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;QAChD,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,QAAQ,CAAC,WAAW,IAAI,IAAI,CAAA;QAEvE,MAAM,MAAM,GAAG,IAAI,0BAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QAErD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;QAE/E,MAAM,MAAM,GAAW;YACrB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS;YAC9D,UAAU,EAAE,OAAO,CAAC,UAAU;SAC/B,CAAA;QAED,OAAO,kCAAwB,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;IAC7E,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -1,4 +1,7 @@
1
1
  export interface Settings {
2
2
  domain: string;
3
3
  apiToken: string;
4
+ personField?: string;
5
+ organizationField?: string;
6
+ dealField?: string;
4
7
  }
@@ -5,8 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const createUpdateOrganization_1 = __importDefault(require("./createUpdateOrganization"));
7
7
  const createUpdatePerson_1 = __importDefault(require("./createUpdatePerson"));
8
+ const createUpdateActivity_1 = __importDefault(require("./createUpdateActivity"));
9
+ const createUpdateDeal_1 = __importDefault(require("./createUpdateDeal"));
10
+ const createUpdateLead_1 = __importDefault(require("./createUpdateLead"));
11
+ const createUpdateNote_1 = __importDefault(require("./createUpdateNote"));
8
12
  const destination = {
9
- name: 'Pipedrive',
13
+ name: 'Actions Pipedrive',
10
14
  mode: 'cloud',
11
15
  authentication: {
12
16
  scheme: 'custom',
@@ -22,6 +26,27 @@ const destination = {
22
26
  description: 'Pipedrive API token. This is found in Pipedrive in Settings > Personal preferences > API > Your personal API token.',
23
27
  type: 'string',
24
28
  required: true
29
+ },
30
+ personField: {
31
+ label: 'External ID field for a Person in Pipedrive',
32
+ description: 'This is a key by which a Person in Pipedrive will be searched. It can be either Person id or has of a custom field containing external id. Default value is `person_id`.',
33
+ type: 'string',
34
+ default: 'id',
35
+ required: false
36
+ },
37
+ organizationField: {
38
+ label: 'External ID field for an Organization in Pipedrive',
39
+ description: 'This is a key by which an Organization in Pipedrive will be searched. It can be either Organization id or has of a custom field containing external id. Default value is `org_id`.',
40
+ type: 'string',
41
+ default: 'id',
42
+ required: false
43
+ },
44
+ dealField: {
45
+ label: 'External ID field for a Deal in Pipedrive',
46
+ description: 'This is a key by which a Deal in Pipedrive will be searched. It can be either Deal id or has of a custom field containing external id. Default value is `deal_id`.',
47
+ type: 'string',
48
+ default: 'id',
49
+ required: false
25
50
  }
26
51
  },
27
52
  testAuthentication: (request, { settings }) => {
@@ -37,7 +62,11 @@ const destination = {
37
62
  },
38
63
  actions: {
39
64
  createUpdateOrganization: createUpdateOrganization_1.default,
40
- createUpdatePerson: createUpdatePerson_1.default
65
+ createUpdatePerson: createUpdatePerson_1.default,
66
+ createUpdateActivity: createUpdateActivity_1.default,
67
+ createUpdateDeal: createUpdateDeal_1.default,
68
+ createUpdateLead: createUpdateLead_1.default,
69
+ createUpdateNote: createUpdateNote_1.default
41
70
  }
42
71
  };
43
72
  exports.default = destination;