n8n-nodes-idb2b 2.0.8 → 2.0.10
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/README.md +2 -2
- package/dist/nodes/IDB2B/IDB2B.node.js +6 -3
- package/package.json +5 -1
- package/dist/nodes/IDB2B/descriptions/leadProperties.d.ts +0 -3
- package/dist/nodes/IDB2B/descriptions/leadProperties.js +0 -278
- package/dist/nodes/IDB2B/descriptions/sharedProperties.d.ts +0 -5
- package/dist/nodes/IDB2B/descriptions/sharedProperties.js +0 -95
- package/dist/nodes/IDB2B/handlers/LeadOperations.d.ts +0 -24
- package/dist/nodes/IDB2B/handlers/LeadOperations.js +0 -198
- package/dist/nodes/IDB2B/interfaces/IDB2BAuth.d.ts +0 -56
- package/dist/nodes/IDB2B/interfaces/IDB2BAuth.js +0 -2
- package/dist/nodes/IDB2B/interfaces/IDB2BCallLog.d.ts +0 -13
- package/dist/nodes/IDB2B/interfaces/IDB2BCallLog.js +0 -2
- package/dist/nodes/IDB2B/interfaces/IDB2BImport.d.ts +0 -23
- package/dist/nodes/IDB2B/interfaces/IDB2BImport.js +0 -2
- package/dist/nodes/IDB2B/interfaces/IDB2BLeadActivity.d.ts +0 -13
- package/dist/nodes/IDB2B/interfaces/IDB2BLeadActivity.js +0 -2
- package/dist/nodes/IDB2B/methods/authentication.d.ts +0 -21
- package/dist/nodes/IDB2B/methods/authentication.js +0 -158
- package/dist/nodes/IDB2B/methods/requests.d.ts +0 -10
- package/dist/nodes/IDB2B/methods/requests.js +0 -35
- package/dist/nodes/IDB2B/methods/utils.d.ts +0 -3
- package/dist/nodes/IDB2B/methods/utils.js +0 -50
- package/dist/nodes/IDB2B/methods/validation.d.ts +0 -4
- package/dist/nodes/IDB2B/methods/validation.js +0 -44
- package/dist/nodes/IDB2B/services/LeadService.d.ts +0 -77
- package/dist/nodes/IDB2B/services/LeadService.js +0 -241
package/README.md
CHANGED
|
@@ -59,14 +59,14 @@ npm install n8n-nodes-idb2b
|
|
|
59
59
|
|
|
60
60
|
### Get All Contacts
|
|
61
61
|
|
|
62
|
-
- **Limit**: Number of contacts per page (default:
|
|
62
|
+
- **Limit**: Number of contacts per page (default: 50)
|
|
63
63
|
- **Page**: Page number (default: 1)
|
|
64
64
|
- **Fields to Return**: Optionally select specific fields (id, name, email, phone_number, tags, etc.)
|
|
65
65
|
- **Query Parameters**: Add any extra filters supported by the API
|
|
66
66
|
|
|
67
67
|
### Get All Companies
|
|
68
68
|
|
|
69
|
-
- **Limit**: Number of companies per page (default:
|
|
69
|
+
- **Limit**: Number of companies per page (default: 50)
|
|
70
70
|
- **Page**: Page number (default: 1)
|
|
71
71
|
- **Fields to Return**: Optionally select specific fields
|
|
72
72
|
- **Query Parameters**: Add any extra filters
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.IDB2B = void 0;
|
|
4
4
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
5
|
const node_crypto_1 = require("node:crypto");
|
|
6
|
-
const node_timers_1 = require("node:timers");
|
|
7
6
|
const contactProperties_1 = require("./descriptions/contactProperties");
|
|
8
7
|
const companyProperties_1 = require("./descriptions/companyProperties");
|
|
9
8
|
class SecureTokenCache {
|
|
@@ -130,12 +129,12 @@ async function makeRequestWithRetry(executeFunctions, options, maxRetries = 3, i
|
|
|
130
129
|
if (((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) === 429) {
|
|
131
130
|
const retryAfter = (_c = error.response.headers) === null || _c === void 0 ? void 0 : _c['retry-after'];
|
|
132
131
|
const delay = retryAfter ? parseInt(retryAfter) * 1000 : initialDelay * Math.pow(2, attempt);
|
|
133
|
-
await
|
|
132
|
+
await (0, n8n_workflow_1.sleep)(Math.min(delay, 30000));
|
|
134
133
|
}
|
|
135
134
|
else {
|
|
136
135
|
// Exponential backoff for other errors
|
|
137
136
|
const delay = initialDelay * Math.pow(2, attempt);
|
|
138
|
-
await
|
|
137
|
+
await (0, n8n_workflow_1.sleep)(Math.min(delay, 10000));
|
|
139
138
|
}
|
|
140
139
|
}
|
|
141
140
|
}
|
|
@@ -485,6 +484,10 @@ class IDB2B {
|
|
|
485
484
|
if (operation === 'create' && response.message === 'success' && response.data === null) {
|
|
486
485
|
processedResponse = Object.assign(Object.assign({}, response), { data: Object.assign(Object.assign({}, body), { created: true, status: 'success', _note: 'Server did not return the created entity. Fields like id and timestamps are unavailable.' }) });
|
|
487
486
|
}
|
|
487
|
+
// Return standardized response for delete operations (n8n UX guideline)
|
|
488
|
+
if (operation === 'delete') {
|
|
489
|
+
processedResponse = { deleted: true };
|
|
490
|
+
}
|
|
488
491
|
// Apply field filtering for contact getAll operation
|
|
489
492
|
if (resource === 'contact' && operation === 'getAll') {
|
|
490
493
|
const fieldsToReturn = this.getNodeParameter('fields', i, []);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-idb2b",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.10",
|
|
4
4
|
"description": "n8n community node for IDB2B - WhatsApp AI Agents",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -30,6 +30,10 @@
|
|
|
30
30
|
"idb2b",
|
|
31
31
|
"api"
|
|
32
32
|
],
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/pipeline-id/idb2b-n8n"
|
|
36
|
+
},
|
|
33
37
|
"author": "christmantoro <christmantoro@gmail.com>",
|
|
34
38
|
"license": "MIT",
|
|
35
39
|
"devDependencies": {
|
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.leadFields = exports.leadOperations = void 0;
|
|
4
|
-
exports.leadOperations = {
|
|
5
|
-
displayName: 'Operation',
|
|
6
|
-
name: 'operation',
|
|
7
|
-
type: 'options',
|
|
8
|
-
noDataExpression: true,
|
|
9
|
-
displayOptions: {
|
|
10
|
-
show: {
|
|
11
|
-
resource: ['lead'],
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
options: [
|
|
15
|
-
{
|
|
16
|
-
name: 'Get All',
|
|
17
|
-
value: 'getAll',
|
|
18
|
-
action: 'Get all leads',
|
|
19
|
-
description: 'Retrieve all leads',
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
name: 'Get',
|
|
23
|
-
value: 'get',
|
|
24
|
-
action: 'Get a lead',
|
|
25
|
-
description: 'Get a single lead by ID',
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: 'Create',
|
|
29
|
-
value: 'create',
|
|
30
|
-
action: 'Create a lead',
|
|
31
|
-
description: 'Create a new lead',
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
name: 'Update',
|
|
35
|
-
value: 'update',
|
|
36
|
-
action: 'Update a lead',
|
|
37
|
-
description: 'Update an existing lead',
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: 'Delete',
|
|
41
|
-
value: 'delete',
|
|
42
|
-
action: 'Delete a lead',
|
|
43
|
-
description: 'Delete a lead by ID',
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
default: 'getAll',
|
|
47
|
-
};
|
|
48
|
-
exports.leadFields = [
|
|
49
|
-
// Lead ID field for operations that require it
|
|
50
|
-
{
|
|
51
|
-
displayName: 'Lead ID',
|
|
52
|
-
name: 'leadId',
|
|
53
|
-
type: 'string',
|
|
54
|
-
default: '',
|
|
55
|
-
required: true,
|
|
56
|
-
displayOptions: {
|
|
57
|
-
show: {
|
|
58
|
-
resource: ['lead'],
|
|
59
|
-
operation: ['get', 'update', 'delete'],
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
description: 'ID of the lead',
|
|
63
|
-
},
|
|
64
|
-
// Name field for create and update operations
|
|
65
|
-
{
|
|
66
|
-
displayName: 'Name',
|
|
67
|
-
name: 'name',
|
|
68
|
-
type: 'string',
|
|
69
|
-
default: '',
|
|
70
|
-
required: true,
|
|
71
|
-
displayOptions: {
|
|
72
|
-
show: {
|
|
73
|
-
resource: ['lead'],
|
|
74
|
-
operation: ['create'],
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
description: 'Lead name (company name)',
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
displayName: 'Name',
|
|
81
|
-
name: 'name',
|
|
82
|
-
type: 'string',
|
|
83
|
-
default: '',
|
|
84
|
-
displayOptions: {
|
|
85
|
-
show: {
|
|
86
|
-
resource: ['lead'],
|
|
87
|
-
operation: ['update'],
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
description: 'Lead name (leave empty to keep current value)',
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
displayName: 'Additional Fields',
|
|
94
|
-
name: 'additionalFields',
|
|
95
|
-
type: 'collection',
|
|
96
|
-
placeholder: 'Add Field',
|
|
97
|
-
default: {},
|
|
98
|
-
displayOptions: {
|
|
99
|
-
show: {
|
|
100
|
-
resource: ['lead'],
|
|
101
|
-
operation: ['create', 'update'],
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
options: [
|
|
105
|
-
{
|
|
106
|
-
displayName: 'Website',
|
|
107
|
-
name: 'website',
|
|
108
|
-
type: 'string',
|
|
109
|
-
default: '',
|
|
110
|
-
description: 'Company website URL',
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
displayName: 'Description',
|
|
114
|
-
name: 'description',
|
|
115
|
-
type: 'string',
|
|
116
|
-
default: '',
|
|
117
|
-
description: 'Company description',
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
displayName: 'Industry ID',
|
|
121
|
-
name: 'industry_id',
|
|
122
|
-
type: 'string',
|
|
123
|
-
default: '',
|
|
124
|
-
description: 'Industry category ID',
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
displayName: 'Size ID',
|
|
128
|
-
name: 'size_id',
|
|
129
|
-
type: 'string',
|
|
130
|
-
default: '',
|
|
131
|
-
description: 'Company size category ID',
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
displayName: 'Status ID',
|
|
135
|
-
name: 'status_id',
|
|
136
|
-
type: 'string',
|
|
137
|
-
default: '',
|
|
138
|
-
description: 'Lead status ID',
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
displayName: 'Source ID',
|
|
142
|
-
name: 'source_id',
|
|
143
|
-
type: 'string',
|
|
144
|
-
default: '',
|
|
145
|
-
description: 'Lead source ID',
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
displayName: 'Owner ID',
|
|
149
|
-
name: 'owner_id',
|
|
150
|
-
type: 'string',
|
|
151
|
-
default: '',
|
|
152
|
-
description: 'ID of the user who owns this lead',
|
|
153
|
-
},
|
|
154
|
-
],
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
displayName: 'Limit',
|
|
158
|
-
name: 'limit',
|
|
159
|
-
type: 'number',
|
|
160
|
-
default: 50,
|
|
161
|
-
description: 'Maximum number of leads to return',
|
|
162
|
-
displayOptions: {
|
|
163
|
-
show: {
|
|
164
|
-
resource: ['lead'],
|
|
165
|
-
operation: ['getAll'],
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
displayName: 'Page',
|
|
171
|
-
name: 'page',
|
|
172
|
-
type: 'number',
|
|
173
|
-
default: 1,
|
|
174
|
-
description: 'Page number to retrieve',
|
|
175
|
-
displayOptions: {
|
|
176
|
-
show: {
|
|
177
|
-
resource: ['lead'],
|
|
178
|
-
operation: ['getAll'],
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
displayName: 'Fields to Return',
|
|
184
|
-
name: 'fields',
|
|
185
|
-
type: 'multiOptions',
|
|
186
|
-
default: [],
|
|
187
|
-
description: 'Select specific fields to return (leave empty for all fields)',
|
|
188
|
-
displayOptions: {
|
|
189
|
-
show: {
|
|
190
|
-
resource: ['lead'],
|
|
191
|
-
operation: ['getAll'],
|
|
192
|
-
},
|
|
193
|
-
},
|
|
194
|
-
options: [
|
|
195
|
-
{
|
|
196
|
-
name: 'ID',
|
|
197
|
-
value: 'id',
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
name: 'Name',
|
|
201
|
-
value: 'name',
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
name: 'Website',
|
|
205
|
-
value: 'website',
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
name: 'Description',
|
|
209
|
-
value: 'description',
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
name: 'Owner ID',
|
|
213
|
-
value: 'owner_id',
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
name: 'Status ID',
|
|
217
|
-
value: 'status_id',
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
name: 'Source ID',
|
|
221
|
-
value: 'source_id',
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
name: 'Size ID',
|
|
225
|
-
value: 'size_id',
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
name: 'Industry ID',
|
|
229
|
-
value: 'industry_id',
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
name: 'Created At',
|
|
233
|
-
value: 'created_at',
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
name: 'Updated At',
|
|
237
|
-
value: 'updated_at',
|
|
238
|
-
},
|
|
239
|
-
],
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
displayName: 'Query Parameters',
|
|
243
|
-
name: 'queryParameters',
|
|
244
|
-
type: 'fixedCollection',
|
|
245
|
-
typeOptions: {
|
|
246
|
-
multipleValues: true,
|
|
247
|
-
},
|
|
248
|
-
default: {},
|
|
249
|
-
placeholder: 'Add Parameter',
|
|
250
|
-
description: 'Additional query parameters',
|
|
251
|
-
displayOptions: {
|
|
252
|
-
show: {
|
|
253
|
-
resource: ['lead'],
|
|
254
|
-
operation: ['getAll'],
|
|
255
|
-
},
|
|
256
|
-
},
|
|
257
|
-
options: [
|
|
258
|
-
{
|
|
259
|
-
name: 'parameter',
|
|
260
|
-
displayName: 'Parameter',
|
|
261
|
-
values: [
|
|
262
|
-
{
|
|
263
|
-
displayName: 'Name',
|
|
264
|
-
name: 'name',
|
|
265
|
-
type: 'string',
|
|
266
|
-
default: '',
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
displayName: 'Value',
|
|
270
|
-
name: 'value',
|
|
271
|
-
type: 'string',
|
|
272
|
-
default: '',
|
|
273
|
-
},
|
|
274
|
-
],
|
|
275
|
-
},
|
|
276
|
-
],
|
|
277
|
-
},
|
|
278
|
-
];
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { INodeProperties } from 'n8n-workflow';
|
|
2
|
-
export declare const resourceProperty: INodeProperties;
|
|
3
|
-
export declare const customEndpointProperty: INodeProperties;
|
|
4
|
-
export declare const customJsonBodyProperty: INodeProperties;
|
|
5
|
-
export declare const customQueryParametersProperty: INodeProperties;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.customQueryParametersProperty = exports.customJsonBodyProperty = exports.customEndpointProperty = exports.resourceProperty = void 0;
|
|
4
|
-
exports.resourceProperty = {
|
|
5
|
-
displayName: 'Resource',
|
|
6
|
-
name: 'resource',
|
|
7
|
-
type: 'options',
|
|
8
|
-
noDataExpression: true,
|
|
9
|
-
options: [
|
|
10
|
-
{
|
|
11
|
-
name: 'Contact',
|
|
12
|
-
value: 'contact',
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
name: 'Lead',
|
|
16
|
-
value: 'lead',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
name: 'Custom',
|
|
20
|
-
value: 'custom',
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
default: 'contact',
|
|
24
|
-
};
|
|
25
|
-
exports.customEndpointProperty = {
|
|
26
|
-
displayName: 'Endpoint',
|
|
27
|
-
name: 'endpoint',
|
|
28
|
-
type: 'string',
|
|
29
|
-
default: '/api/v1/',
|
|
30
|
-
placeholder: '/api/v1/resource',
|
|
31
|
-
description: 'The endpoint to call',
|
|
32
|
-
displayOptions: {
|
|
33
|
-
show: {
|
|
34
|
-
resource: ['custom'],
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
routing: {
|
|
38
|
-
request: {
|
|
39
|
-
url: '={{$value}}',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
exports.customJsonBodyProperty = {
|
|
44
|
-
displayName: 'JSON Body',
|
|
45
|
-
name: 'jsonBody',
|
|
46
|
-
type: 'json',
|
|
47
|
-
default: '{}',
|
|
48
|
-
description: 'JSON body for POST/PUT requests',
|
|
49
|
-
displayOptions: {
|
|
50
|
-
show: {
|
|
51
|
-
operation: ['post', 'put'],
|
|
52
|
-
resource: ['custom'],
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
routing: {
|
|
56
|
-
request: {
|
|
57
|
-
body: '={{JSON.parse($value)}}',
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
exports.customQueryParametersProperty = {
|
|
62
|
-
displayName: 'Query Parameters',
|
|
63
|
-
name: 'queryParameters',
|
|
64
|
-
type: 'fixedCollection',
|
|
65
|
-
typeOptions: {
|
|
66
|
-
multipleValues: true,
|
|
67
|
-
},
|
|
68
|
-
default: {},
|
|
69
|
-
placeholder: 'Add Parameter',
|
|
70
|
-
displayOptions: {
|
|
71
|
-
show: {
|
|
72
|
-
resource: ['custom'],
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
options: [
|
|
76
|
-
{
|
|
77
|
-
name: 'parameter',
|
|
78
|
-
displayName: 'Parameter',
|
|
79
|
-
values: [
|
|
80
|
-
{
|
|
81
|
-
displayName: 'Name',
|
|
82
|
-
name: 'name',
|
|
83
|
-
type: 'string',
|
|
84
|
-
default: '',
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
displayName: 'Value',
|
|
88
|
-
name: 'value',
|
|
89
|
-
type: 'string',
|
|
90
|
-
default: '',
|
|
91
|
-
},
|
|
92
|
-
],
|
|
93
|
-
},
|
|
94
|
-
],
|
|
95
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { IExecuteFunctions } from 'n8n-workflow';
|
|
2
|
-
import { LeadService } from '../services/LeadService';
|
|
3
|
-
export declare class LeadOperations {
|
|
4
|
-
private leadService;
|
|
5
|
-
private executeFunctions;
|
|
6
|
-
private itemIndex;
|
|
7
|
-
constructor(leadService: LeadService, executeFunctions: IExecuteFunctions, itemIndex: number);
|
|
8
|
-
execute(operation: string): Promise<any>;
|
|
9
|
-
private handleGetAll;
|
|
10
|
-
private handleGet;
|
|
11
|
-
private handleCreate;
|
|
12
|
-
private handleUpdate;
|
|
13
|
-
private handleDelete;
|
|
14
|
-
private handleCreateMultiple;
|
|
15
|
-
private handleDeleteMultiple;
|
|
16
|
-
private handleGetCallLogs;
|
|
17
|
-
private handleAssignNewContact;
|
|
18
|
-
private handleAssignContacts;
|
|
19
|
-
private handleRemoveContact;
|
|
20
|
-
private handleImport;
|
|
21
|
-
private handleGetImportTemplate;
|
|
22
|
-
private handleGeocode;
|
|
23
|
-
private handleSearchNearby;
|
|
24
|
-
}
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LeadOperations = void 0;
|
|
4
|
-
const utils_1 = require("../methods/utils");
|
|
5
|
-
class LeadOperations {
|
|
6
|
-
constructor(leadService, executeFunctions, itemIndex) {
|
|
7
|
-
this.leadService = leadService;
|
|
8
|
-
this.executeFunctions = executeFunctions;
|
|
9
|
-
this.itemIndex = itemIndex;
|
|
10
|
-
}
|
|
11
|
-
async execute(operation) {
|
|
12
|
-
switch (operation) {
|
|
13
|
-
case 'getAll':
|
|
14
|
-
return this.handleGetAll();
|
|
15
|
-
case 'get':
|
|
16
|
-
return this.handleGet();
|
|
17
|
-
case 'create':
|
|
18
|
-
return this.handleCreate();
|
|
19
|
-
case 'update':
|
|
20
|
-
return this.handleUpdate();
|
|
21
|
-
case 'delete':
|
|
22
|
-
return this.handleDelete();
|
|
23
|
-
case 'createMultiple':
|
|
24
|
-
return this.handleCreateMultiple();
|
|
25
|
-
case 'deleteMultiple':
|
|
26
|
-
return this.handleDeleteMultiple();
|
|
27
|
-
case 'getCallLogs':
|
|
28
|
-
return this.handleGetCallLogs();
|
|
29
|
-
case 'assignNewContact':
|
|
30
|
-
return this.handleAssignNewContact();
|
|
31
|
-
case 'assignContacts':
|
|
32
|
-
return this.handleAssignContacts();
|
|
33
|
-
case 'removeContact':
|
|
34
|
-
return this.handleRemoveContact();
|
|
35
|
-
case 'import':
|
|
36
|
-
return this.handleImport();
|
|
37
|
-
case 'getImportTemplate':
|
|
38
|
-
return this.handleGetImportTemplate();
|
|
39
|
-
case 'geocode':
|
|
40
|
-
return this.handleGeocode();
|
|
41
|
-
case 'searchNearby':
|
|
42
|
-
return this.handleSearchNearby();
|
|
43
|
-
default:
|
|
44
|
-
throw new Error(`Unknown operation: ${operation}`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
async handleGetAll() {
|
|
48
|
-
const limit = this.executeFunctions.getNodeParameter('limit', this.itemIndex, 50);
|
|
49
|
-
const page = this.executeFunctions.getNodeParameter('page', this.itemIndex, 1);
|
|
50
|
-
const fields = this.executeFunctions.getNodeParameter('fields', this.itemIndex, []);
|
|
51
|
-
const queryParameters = this.executeFunctions.getNodeParameter('queryParameters', this.itemIndex, {});
|
|
52
|
-
// Build query parameters
|
|
53
|
-
const queryParams = {};
|
|
54
|
-
if (queryParameters === null || queryParameters === void 0 ? void 0 : queryParameters.parameter) {
|
|
55
|
-
queryParameters.parameter.forEach((param) => {
|
|
56
|
-
if (param.name && param.value !== undefined) {
|
|
57
|
-
queryParams[param.name] = param.value;
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return await this.leadService.getAll({
|
|
62
|
-
limit,
|
|
63
|
-
page,
|
|
64
|
-
fields,
|
|
65
|
-
queryParams,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
async handleGet() {
|
|
69
|
-
const leadId = this.executeFunctions.getNodeParameter('leadId', this.itemIndex);
|
|
70
|
-
return await this.leadService.getById(leadId);
|
|
71
|
-
}
|
|
72
|
-
async handleCreate() {
|
|
73
|
-
const name = this.executeFunctions.getNodeParameter('name', this.itemIndex);
|
|
74
|
-
const additionalFields = this.executeFunctions.getNodeParameter('additionalFields', this.itemIndex, {});
|
|
75
|
-
const leadData = {
|
|
76
|
-
name: name.trim(),
|
|
77
|
-
};
|
|
78
|
-
// Add additional fields
|
|
79
|
-
const optionalFields = [
|
|
80
|
-
'owner_id', 'website', 'description', 'status_id', 'source_id',
|
|
81
|
-
'size_id', 'industry_id', 'main_contact_id', 'contact_name',
|
|
82
|
-
'contact_email', 'contact_phone_number'
|
|
83
|
-
];
|
|
84
|
-
optionalFields.forEach(field => {
|
|
85
|
-
if (additionalFields[field] !== undefined) {
|
|
86
|
-
leadData[field] = additionalFields[field];
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
return await this.leadService.create(leadData);
|
|
90
|
-
}
|
|
91
|
-
async handleUpdate() {
|
|
92
|
-
const leadId = this.executeFunctions.getNodeParameter('leadId', this.itemIndex);
|
|
93
|
-
const name = this.executeFunctions.getNodeParameter('name', this.itemIndex, '');
|
|
94
|
-
const additionalFields = this.executeFunctions.getNodeParameter('additionalFields', this.itemIndex, {});
|
|
95
|
-
const updateData = {};
|
|
96
|
-
// Add name if provided
|
|
97
|
-
if (name && name.trim()) {
|
|
98
|
-
updateData.name = name.trim();
|
|
99
|
-
}
|
|
100
|
-
// Add additional fields
|
|
101
|
-
const optionalFields = [
|
|
102
|
-
'owner_id', 'website', 'description', 'status_id', 'source_id',
|
|
103
|
-
'size_id', 'industry_id', 'main_contact_id', 'contact_name',
|
|
104
|
-
'contact_email', 'contact_phone_number'
|
|
105
|
-
];
|
|
106
|
-
optionalFields.forEach(field => {
|
|
107
|
-
if (additionalFields[field] !== undefined) {
|
|
108
|
-
updateData[field] = additionalFields[field];
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
return await this.leadService.update(leadId, updateData);
|
|
112
|
-
}
|
|
113
|
-
async handleDelete() {
|
|
114
|
-
const leadId = this.executeFunctions.getNodeParameter('leadId', this.itemIndex);
|
|
115
|
-
return await this.leadService.delete(leadId);
|
|
116
|
-
}
|
|
117
|
-
async handleCreateMultiple() {
|
|
118
|
-
const leadsDataString = this.executeFunctions.getNodeParameter('leadsData', this.itemIndex);
|
|
119
|
-
const leadsData = (0, utils_1.safeJsonParse)(leadsDataString, 'Leads Data');
|
|
120
|
-
if (!Array.isArray(leadsData)) {
|
|
121
|
-
throw new Error('Leads data must be an array');
|
|
122
|
-
}
|
|
123
|
-
return await this.leadService.bulkCreate(leadsData);
|
|
124
|
-
}
|
|
125
|
-
async handleDeleteMultiple() {
|
|
126
|
-
const leadIdsString = this.executeFunctions.getNodeParameter('leadIds', this.itemIndex);
|
|
127
|
-
const leadIds = leadIdsString.split(',').map(id => id.trim()).filter(id => id);
|
|
128
|
-
if (leadIds.length === 0) {
|
|
129
|
-
throw new Error('At least one lead ID is required');
|
|
130
|
-
}
|
|
131
|
-
return await this.leadService.bulkDelete(leadIds);
|
|
132
|
-
}
|
|
133
|
-
async handleGetCallLogs() {
|
|
134
|
-
const leadId = this.executeFunctions.getNodeParameter('leadId', this.itemIndex);
|
|
135
|
-
const limit = this.executeFunctions.getNodeParameter('limit', this.itemIndex, 50);
|
|
136
|
-
const page = this.executeFunctions.getNodeParameter('page', this.itemIndex, 1);
|
|
137
|
-
return await this.leadService.getCallLogs(leadId, { limit, page });
|
|
138
|
-
}
|
|
139
|
-
async handleAssignNewContact() {
|
|
140
|
-
const leadId = this.executeFunctions.getNodeParameter('leadId', this.itemIndex);
|
|
141
|
-
const newContactData = this.executeFunctions.getNodeParameter('newContactData', this.itemIndex, {});
|
|
142
|
-
return await this.leadService.assignNewContact(leadId, newContactData);
|
|
143
|
-
}
|
|
144
|
-
async handleAssignContacts() {
|
|
145
|
-
const leadId = this.executeFunctions.getNodeParameter('leadId', this.itemIndex);
|
|
146
|
-
const contactIdsString = this.executeFunctions.getNodeParameter('contactIds', this.itemIndex);
|
|
147
|
-
const contactIds = contactIdsString.split(',').map(id => id.trim()).filter(id => id);
|
|
148
|
-
if (contactIds.length === 0) {
|
|
149
|
-
throw new Error('At least one contact ID is required');
|
|
150
|
-
}
|
|
151
|
-
return await this.leadService.assignContacts(leadId, contactIds);
|
|
152
|
-
}
|
|
153
|
-
async handleRemoveContact() {
|
|
154
|
-
const leadId = this.executeFunctions.getNodeParameter('leadId', this.itemIndex);
|
|
155
|
-
const contactId = this.executeFunctions.getNodeParameter('contactId', this.itemIndex);
|
|
156
|
-
return await this.leadService.removeContact(leadId, contactId);
|
|
157
|
-
}
|
|
158
|
-
async handleImport() {
|
|
159
|
-
const importData = this.executeFunctions.getNodeParameter('importData', this.itemIndex, {});
|
|
160
|
-
const data = {};
|
|
161
|
-
if (importData.file) {
|
|
162
|
-
data.file = importData.file;
|
|
163
|
-
}
|
|
164
|
-
if (importData.mapping) {
|
|
165
|
-
data.mapping = (0, utils_1.safeJsonParse)(importData.mapping, 'Field Mapping');
|
|
166
|
-
}
|
|
167
|
-
return await this.leadService.import(data);
|
|
168
|
-
}
|
|
169
|
-
async handleGetImportTemplate() {
|
|
170
|
-
return await this.leadService.getImportTemplate();
|
|
171
|
-
}
|
|
172
|
-
async handleGeocode() {
|
|
173
|
-
const leadId = this.executeFunctions.getNodeParameter('leadId', this.itemIndex);
|
|
174
|
-
const geocodeData = this.executeFunctions.getNodeParameter('geocodeData', this.itemIndex, {});
|
|
175
|
-
return await this.leadService.geocode(leadId, geocodeData);
|
|
176
|
-
}
|
|
177
|
-
async handleSearchNearby() {
|
|
178
|
-
const latitude = this.executeFunctions.getNodeParameter('latitude', this.itemIndex);
|
|
179
|
-
const longitude = this.executeFunctions.getNodeParameter('longitude', this.itemIndex);
|
|
180
|
-
const limit = this.executeFunctions.getNodeParameter('limit', this.itemIndex, 50);
|
|
181
|
-
const page = this.executeFunctions.getNodeParameter('page', this.itemIndex, 1);
|
|
182
|
-
const searchOptions = this.executeFunctions.getNodeParameter('searchOptions', this.itemIndex, {});
|
|
183
|
-
const params = {
|
|
184
|
-
latitude,
|
|
185
|
-
longitude,
|
|
186
|
-
limit,
|
|
187
|
-
page,
|
|
188
|
-
};
|
|
189
|
-
if (searchOptions.radius !== undefined) {
|
|
190
|
-
params.radius = searchOptions.radius;
|
|
191
|
-
}
|
|
192
|
-
if (searchOptions.unit) {
|
|
193
|
-
params.unit = searchOptions.unit;
|
|
194
|
-
}
|
|
195
|
-
return await this.leadService.searchNearby(params);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
exports.LeadOperations = LeadOperations;
|