n8n-nodes-idb2b 1.1.2 → 1.1.4

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.
@@ -308,6 +308,10 @@ class IDB2B {
308
308
  name: 'Lead',
309
309
  value: 'lead',
310
310
  },
311
+ {
312
+ name: 'Lead Activities',
313
+ value: 'leadActivities',
314
+ },
311
315
  {
312
316
  name: 'Custom',
313
317
  value: 'custom',
@@ -367,6 +371,32 @@ class IDB2B {
367
371
  ],
368
372
  default: 'getAll',
369
373
  },
374
+ {
375
+ displayName: 'Operation',
376
+ name: 'operation',
377
+ type: 'options',
378
+ noDataExpression: true,
379
+ displayOptions: {
380
+ show: {
381
+ resource: ['leadActivities'],
382
+ },
383
+ },
384
+ options: [
385
+ {
386
+ name: 'Get All',
387
+ value: 'getAll',
388
+ action: 'Get all activities for a lead',
389
+ description: 'Retrieve all activities for a specific lead',
390
+ },
391
+ {
392
+ name: 'Create',
393
+ value: 'create',
394
+ action: 'Create a lead activity',
395
+ description: 'Create a new activity for a lead',
396
+ },
397
+ ],
398
+ default: 'getAll',
399
+ },
370
400
  {
371
401
  displayName: 'Operation',
372
402
  name: 'operation',
@@ -768,6 +798,248 @@ class IDB2B {
768
798
  },
769
799
  ],
770
800
  },
801
+ {
802
+ displayName: 'Lead ID',
803
+ name: 'lead_id',
804
+ type: 'string',
805
+ default: '',
806
+ required: true,
807
+ displayOptions: {
808
+ show: {
809
+ resource: ['leadActivities'],
810
+ operation: ['create', 'getAll'],
811
+ },
812
+ },
813
+ description: 'ID of the lead to get activities for or add activity to',
814
+ },
815
+ {
816
+ displayName: 'Subject',
817
+ name: 'subject',
818
+ type: 'string',
819
+ default: '',
820
+ required: true,
821
+ displayOptions: {
822
+ show: {
823
+ resource: ['leadActivities'],
824
+ operation: ['create'],
825
+ },
826
+ },
827
+ description: 'Subject of the activity',
828
+ },
829
+ {
830
+ displayName: 'Additional Fields',
831
+ name: 'additionalFields',
832
+ type: 'collection',
833
+ placeholder: 'Add Field',
834
+ default: {},
835
+ displayOptions: {
836
+ show: {
837
+ resource: ['leadActivities'],
838
+ operation: ['create'],
839
+ },
840
+ },
841
+ options: [
842
+ {
843
+ displayName: 'Icon',
844
+ name: 'icon',
845
+ type: 'string',
846
+ default: '',
847
+ description: 'Icon for the activity',
848
+ },
849
+ {
850
+ displayName: 'Description',
851
+ name: 'description',
852
+ type: 'string',
853
+ default: '',
854
+ description: 'Description of the activity',
855
+ },
856
+ {
857
+ displayName: 'Date and Time',
858
+ name: 'datetime',
859
+ type: 'string',
860
+ default: '',
861
+ placeholder: '2025-10-13T10:00:00Z',
862
+ description: 'Date and time of the activity (ISO format)',
863
+ },
864
+ {
865
+ displayName: 'User ID',
866
+ name: 'user_id',
867
+ type: 'string',
868
+ default: '',
869
+ description: 'User ID associated with the activity',
870
+ },
871
+ {
872
+ displayName: 'Attachments',
873
+ name: 'attachments',
874
+ type: 'fixedCollection',
875
+ typeOptions: {
876
+ multipleValues: true,
877
+ },
878
+ default: {},
879
+ placeholder: 'Add Attachment',
880
+ description: 'Attachment files for the activity',
881
+ options: [
882
+ {
883
+ name: 'attachment',
884
+ displayName: 'Attachment',
885
+ values: [
886
+ {
887
+ displayName: 'File Path/URL',
888
+ name: 'file',
889
+ type: 'string',
890
+ default: '',
891
+ required: true,
892
+ },
893
+ ],
894
+ },
895
+ ],
896
+ },
897
+ {
898
+ displayName: 'Attachments to Delete',
899
+ name: 'attachments_to_delete',
900
+ type: 'fixedCollection',
901
+ typeOptions: {
902
+ multipleValues: true,
903
+ },
904
+ default: {},
905
+ placeholder: 'Add Attachment ID',
906
+ description: 'Array of attachment IDs to delete (for updates)',
907
+ options: [
908
+ {
909
+ name: 'attachment_id',
910
+ displayName: 'Attachment ID',
911
+ values: [
912
+ {
913
+ displayName: 'ID',
914
+ name: 'id',
915
+ type: 'string',
916
+ default: '',
917
+ required: true,
918
+ },
919
+ ],
920
+ },
921
+ ],
922
+ },
923
+ ],
924
+ },
925
+ {
926
+ displayName: 'Limit',
927
+ name: 'limit',
928
+ type: 'number',
929
+ default: 50,
930
+ description: 'Maximum number of activities to return',
931
+ displayOptions: {
932
+ show: {
933
+ resource: ['leadActivities'],
934
+ operation: ['getAll'],
935
+ },
936
+ },
937
+ },
938
+ {
939
+ displayName: 'Page',
940
+ name: 'page',
941
+ type: 'number',
942
+ default: 1,
943
+ description: 'Page number to retrieve',
944
+ displayOptions: {
945
+ show: {
946
+ resource: ['leadActivities'],
947
+ operation: ['getAll'],
948
+ },
949
+ },
950
+ },
951
+ {
952
+ displayName: 'Fields to Return',
953
+ name: 'fields',
954
+ type: 'multiOptions',
955
+ default: [],
956
+ description: 'Select specific fields to return (leave empty for all fields)',
957
+ displayOptions: {
958
+ show: {
959
+ resource: ['leadActivities'],
960
+ operation: ['getAll'],
961
+ },
962
+ },
963
+ options: [
964
+ {
965
+ name: 'ID',
966
+ value: 'id',
967
+ },
968
+ {
969
+ name: 'Lead ID',
970
+ value: 'lead_id',
971
+ },
972
+ {
973
+ name: 'Icon',
974
+ value: 'icon',
975
+ },
976
+ {
977
+ name: 'Subject',
978
+ value: 'subject',
979
+ },
980
+ {
981
+ name: 'Description',
982
+ value: 'description',
983
+ },
984
+ {
985
+ name: 'Date and Time',
986
+ value: 'datetime',
987
+ },
988
+ {
989
+ name: 'User ID',
990
+ value: 'user_id',
991
+ },
992
+ {
993
+ name: 'Attachments',
994
+ value: 'attachments',
995
+ },
996
+ {
997
+ name: 'Created At',
998
+ value: 'created_at',
999
+ },
1000
+ {
1001
+ name: 'Updated At',
1002
+ value: 'updated_at',
1003
+ },
1004
+ ],
1005
+ },
1006
+ {
1007
+ displayName: 'Query Parameters',
1008
+ name: 'queryParameters',
1009
+ type: 'fixedCollection',
1010
+ typeOptions: {
1011
+ multipleValues: true,
1012
+ },
1013
+ default: {},
1014
+ placeholder: 'Add Parameter',
1015
+ description: 'Additional query parameters',
1016
+ displayOptions: {
1017
+ show: {
1018
+ resource: ['leadActivities'],
1019
+ operation: ['getAll'],
1020
+ },
1021
+ },
1022
+ options: [
1023
+ {
1024
+ name: 'parameter',
1025
+ displayName: 'Parameter',
1026
+ values: [
1027
+ {
1028
+ displayName: 'Name',
1029
+ name: 'name',
1030
+ type: 'string',
1031
+ default: '',
1032
+ },
1033
+ {
1034
+ displayName: 'Value',
1035
+ name: 'value',
1036
+ type: 'string',
1037
+ default: '',
1038
+ },
1039
+ ],
1040
+ },
1041
+ ],
1042
+ },
771
1043
  {
772
1044
  displayName: 'Endpoint',
773
1045
  name: 'endpoint',
@@ -1090,6 +1362,65 @@ class IDB2B {
1090
1362
  }
1091
1363
  }
1092
1364
  }
1365
+ else if (resource === 'leadActivities') {
1366
+ if (operation === 'getAll') {
1367
+ method = 'GET';
1368
+ const leadId = this.getNodeParameter('lead_id', i);
1369
+ // Validate required fields
1370
+ if (!leadId || typeof leadId !== 'string' || leadId.trim().length === 0) {
1371
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Lead ID is required and must be a non-empty string', { itemIndex: i });
1372
+ }
1373
+ endpoint = `/leads/${leadId.trim()}/activities`;
1374
+ // Add pagination parameters
1375
+ const limit = this.getNodeParameter('limit', i, 50);
1376
+ const page = this.getNodeParameter('page', i, 1);
1377
+ qs.limit = limit;
1378
+ qs.page = page;
1379
+ // Add additional query parameters
1380
+ const queryParameters = this.getNodeParameter('queryParameters', i, {});
1381
+ const additionalQs = buildQueryString(queryParameters);
1382
+ qs = Object.assign(Object.assign({}, qs), additionalQs);
1383
+ }
1384
+ else if (operation === 'create') {
1385
+ method = 'POST';
1386
+ const leadId = this.getNodeParameter('lead_id', i);
1387
+ const subject = this.getNodeParameter('subject', i);
1388
+ const additionalFields = this.getNodeParameter('additionalFields', i, {});
1389
+ // Validate required fields
1390
+ if (!leadId || typeof leadId !== 'string' || leadId.trim().length === 0) {
1391
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Lead ID is required and must be a non-empty string', { itemIndex: i });
1392
+ }
1393
+ if (!subject || typeof subject !== 'string' || subject.trim().length === 0) {
1394
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Subject is required and must be a non-empty string', { itemIndex: i });
1395
+ }
1396
+ endpoint = `/leads/${leadId.trim()}/activities`;
1397
+ // Build activity data object
1398
+ body = {
1399
+ subject: subject.trim(),
1400
+ };
1401
+ // Add additional fields if provided
1402
+ if (additionalFields.icon) {
1403
+ body.icon = additionalFields.icon;
1404
+ }
1405
+ if (additionalFields.description) {
1406
+ body.description = additionalFields.description;
1407
+ }
1408
+ if (additionalFields.datetime) {
1409
+ body.datetime = additionalFields.datetime;
1410
+ }
1411
+ if (additionalFields.user_id) {
1412
+ body.user_id = additionalFields.user_id;
1413
+ }
1414
+ // Process attachments if provided
1415
+ if (additionalFields.attachments && additionalFields.attachments.attachment) {
1416
+ body.attachments = additionalFields.attachments.attachment.map((attachment) => attachment.file);
1417
+ }
1418
+ // Process attachments to delete if provided
1419
+ if (additionalFields.attachments_to_delete && additionalFields.attachments_to_delete.attachment_id) {
1420
+ body.attachments_to_delete = additionalFields.attachments_to_delete.attachment_id.map((attachment) => attachment.id);
1421
+ }
1422
+ }
1423
+ }
1093
1424
  else if (resource === 'custom') {
1094
1425
  endpoint = this.getNodeParameter('endpoint', i);
1095
1426
  // Validate endpoint
@@ -1122,7 +1453,19 @@ class IDB2B {
1122
1453
  });
1123
1454
  let processedResponse = response;
1124
1455
  // Enhance response for create operations
1125
- if (operation === 'create' && response.message === 'success' && response.data === null) {
1456
+ if (operation === 'create' && (resource === 'lead' || resource === 'leadActivities')) {
1457
+ // For lead and leadActivities creation, ensure the response includes the data with ID
1458
+ if (response.message === 'success' && response.data) {
1459
+ // API returned actual data - use it
1460
+ processedResponse = response;
1461
+ }
1462
+ else if (response.message === 'success' && response.data === null) {
1463
+ // Fallback: create synthetic response but try to include any ID from headers or other sources
1464
+ processedResponse = Object.assign(Object.assign({}, response), { data: Object.assign(Object.assign({}, body), { created: true, status: 'success' }) });
1465
+ }
1466
+ }
1467
+ else if (operation === 'create' && response.message === 'success' && response.data === null) {
1468
+ // Original logic for other create operations
1126
1469
  processedResponse = Object.assign(Object.assign({}, response), { data: Object.assign(Object.assign({}, body), { created: true, status: 'success' }) });
1127
1470
  }
1128
1471
  // Apply field filtering for contact getAll operation
@@ -1155,6 +1498,21 @@ class IDB2B {
1155
1498
  }) });
1156
1499
  }
1157
1500
  }
1501
+ // Apply field filtering for leadActivities getAll operation
1502
+ if (resource === 'leadActivities' && operation === 'getAll') {
1503
+ const fieldsToReturn = this.getNodeParameter('fields', i, []);
1504
+ if (fieldsToReturn.length > 0 && Array.isArray(response.data)) {
1505
+ processedResponse = Object.assign(Object.assign({}, response), { data: response.data.map((activity) => {
1506
+ const filteredActivity = {};
1507
+ fieldsToReturn.forEach(field => {
1508
+ if (field in activity) {
1509
+ filteredActivity[field] = activity[field];
1510
+ }
1511
+ });
1512
+ return filteredActivity;
1513
+ }) });
1514
+ }
1515
+ }
1158
1516
  returnData.push({
1159
1517
  json: processedResponse,
1160
1518
  pairedItem: { item: i },
@@ -0,0 +1,13 @@
1
+ export interface IDB2BLeadActivity {
2
+ id?: string;
3
+ lead_id?: string;
4
+ icon?: string;
5
+ subject: string;
6
+ description?: string;
7
+ datetime?: string;
8
+ user_id?: string;
9
+ attachments?: string[];
10
+ attachments_to_delete?: string[];
11
+ created_at?: string;
12
+ updated_at?: string;
13
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-idb2b",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "n8n community node for IDB2B CRM",
5
5
  "main": "index.js",
6
6
  "scripts": {