@ixiam/n8n-nodes-civicrm 1.1.40 → 1.1.41

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.
@@ -604,7 +604,10 @@ class CiviCrm {
604
604
  }
605
605
  const res = await GenericFunctions_1.civicrmApiRequest.call(this, 'POST', `/civicrm/ajax/api4/${entity}/${action}`, params);
606
606
  // Return the raw API4 response so advanced users can work with values and metadata
607
- out.push({ json: res });
607
+ out.push({
608
+ json: res,
609
+ pairedItem: { item: 0 },
610
+ });
608
611
  return [out];
609
612
  }
610
613
  const entity = ENTITY_MAP[resource];
@@ -651,7 +654,10 @@ class CiviCrm {
651
654
  select: ['id', 'name', 'title', 'subject', 'display_name'],
652
655
  };
653
656
  const res = await GenericFunctions_1.civicrmApiRequest.call(this, 'POST', `/civicrm/ajax/api4/${entity}/get`, params);
654
- out.push({ json: (_b = (_a = res === null || res === void 0 ? void 0 : res.values) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : {} });
657
+ out.push({
658
+ json: (_b = (_a = res === null || res === void 0 ? void 0 : res.values) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : {},
659
+ pairedItem: { item: i },
660
+ });
655
661
  continue;
656
662
  }
657
663
  /* ======================================================
@@ -707,8 +713,12 @@ class CiviCrm {
707
713
  while (hasMore) {
708
714
  const r = await GenericFunctions_1.civicrmApiRequest.call(this, 'POST', `/civicrm/ajax/api4/${entity}/get`, { ...params, limit: page, offset });
709
715
  const vals = (_c = r === null || r === void 0 ? void 0 : r.values) !== null && _c !== void 0 ? _c : [];
710
- for (const v of vals)
711
- out.push({ json: v });
716
+ for (const v of vals) {
717
+ out.push({
718
+ json: v,
719
+ pairedItem: { item: i },
720
+ });
721
+ }
712
722
  if (vals.length < page) {
713
723
  hasMore = false;
714
724
  }
@@ -720,8 +730,12 @@ class CiviCrm {
720
730
  else {
721
731
  const r = await GenericFunctions_1.civicrmApiRequest.call(this, 'POST', `/civicrm/ajax/api4/${entity}/get`, { ...params, limit });
722
732
  const vals = (_d = r === null || r === void 0 ? void 0 : r.values) !== null && _d !== void 0 ? _d : [];
723
- for (const v of vals)
724
- out.push({ json: v });
733
+ for (const v of vals) {
734
+ out.push({
735
+ json: v,
736
+ pairedItem: { item: i },
737
+ });
738
+ }
725
739
  }
726
740
  continue;
727
741
  }
@@ -740,6 +754,7 @@ class CiviCrm {
740
754
  deleted_id: id,
741
755
  api_response: r,
742
756
  },
757
+ pairedItem: { item: i },
743
758
  });
744
759
  continue;
745
760
  }
@@ -1059,7 +1074,10 @@ class CiviCrm {
1059
1074
  }
1060
1075
  : {}),
1061
1076
  });
1062
- out.push({ json: (_p = (_o = res === null || res === void 0 ? void 0 : res.values) === null || _o === void 0 ? void 0 : _o[0]) !== null && _p !== void 0 ? _p : {} });
1077
+ out.push({
1078
+ json: (_p = (_o = res === null || res === void 0 ? void 0 : res.values) === null || _o === void 0 ? void 0 : _o[0]) !== null && _p !== void 0 ? _p : {},
1079
+ pairedItem: { item: i },
1080
+ });
1063
1081
  }
1064
1082
  return [out];
1065
1083
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ixiam/n8n-nodes-civicrm",
3
- "version": "1.1.40",
4
- "description": "Full-featured CiviCRM API v4 integration for n8n with support for Contacts, Memberships, Groups, Relationships, Activities and structured sub-entities like Email, Phone, and Address.",
3
+ "version": "1.1.41",
4
+ "description": "Full-featured CiviCRM API v4 integration for n8n",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "n8n-community-node-package",
@@ -664,7 +664,10 @@ export class CiviCrm implements INodeType {
664
664
  );
665
665
 
666
666
  // Return the raw API4 response so advanced users can work with values and metadata
667
- out.push({ json: res as IDataObject });
667
+ out.push({
668
+ json: res as IDataObject,
669
+ pairedItem: { item: 0 },
670
+ });
668
671
  return [out];
669
672
  }
670
673
 
@@ -724,7 +727,10 @@ export class CiviCrm implements INodeType {
724
727
  params,
725
728
  );
726
729
 
727
- out.push({ json: res?.values?.[0] ?? {} });
730
+ out.push({
731
+ json: res?.values?.[0] ?? {},
732
+ pairedItem: { item: i },
733
+ });
728
734
  continue;
729
735
  }
730
736
 
@@ -791,7 +797,12 @@ export class CiviCrm implements INodeType {
791
797
  );
792
798
 
793
799
  const vals = r?.values ?? [];
794
- for (const v of vals) out.push({ json: v });
800
+ for (const v of vals) {
801
+ out.push({
802
+ json: v,
803
+ pairedItem: { item: i },
804
+ });
805
+ }
795
806
 
796
807
  if (vals.length < page) {
797
808
  hasMore = false;
@@ -808,7 +819,12 @@ export class CiviCrm implements INodeType {
808
819
  );
809
820
 
810
821
  const vals = r?.values ?? [];
811
- for (const v of vals) out.push({ json: v });
822
+ for (const v of vals) {
823
+ out.push({
824
+ json: v,
825
+ pairedItem: { item: i },
826
+ });
827
+ }
812
828
  }
813
829
 
814
830
  continue;
@@ -836,6 +852,7 @@ export class CiviCrm implements INodeType {
836
852
  deleted_id: id,
837
853
  api_response: r,
838
854
  },
855
+ pairedItem: { item: i },
839
856
  });
840
857
 
841
858
  continue;
@@ -1068,36 +1085,8 @@ export class CiviCrm implements INodeType {
1068
1085
  }
1069
1086
  }
1070
1087
 
1071
- if (Object.keys(phoneData).length) {
1072
- if (isCreate) {
1073
- await civicrmApiRequest.call(this, 'POST', '/civicrm/ajax/api4/Phone/create', {
1074
- values: {
1075
- ...phoneData,
1076
- contact_id: contactId,
1077
- is_primary: isPrimaryPhone,
1078
- 'location_type_id:name': phoneLocationName,
1079
- },
1080
- });
1081
- } else {
1082
- const existingPhone = await civicrmApiRequest.call(this, 'POST', '/civicrm/ajax/api4/Phone/get', {
1083
- where: [
1084
- ['contact_id', '=', contactId],
1085
- ['location_type_id:name', '=', phoneLocationName],
1086
- ],
1087
- limit: 1,
1088
- select: ['id'],
1089
- });
1090
- const existingPhoneId = existingPhone?.values?.[0]?.id as number | undefined;
1091
- if (existingPhoneId) {
1092
- await civicrmApiRequest.call(this, 'POST', '/civicrm/ajax/api4/Phone/update', {
1093
- values: {
1094
- id: existingPhoneId,
1095
- ...phoneData,
1096
- contact_id: contactId,
1097
- is_primary: isPrimaryPhone,
1098
- },
1099
- });
1100
- } else {
1088
+ if (Object.keys(phoneData).length) {
1089
+ if (isCreate) {
1101
1090
  await civicrmApiRequest.call(this, 'POST', '/civicrm/ajax/api4/Phone/create', {
1102
1091
  values: {
1103
1092
  ...phoneData,
@@ -1106,9 +1095,37 @@ export class CiviCrm implements INodeType {
1106
1095
  'location_type_id:name': phoneLocationName,
1107
1096
  },
1108
1097
  });
1098
+ } else {
1099
+ const existingPhone = await civicrmApiRequest.call(this, 'POST', '/civicrm/ajax/api4/Phone/get', {
1100
+ where: [
1101
+ ['contact_id', '=', contactId],
1102
+ ['location_type_id:name', '=', phoneLocationName],
1103
+ ],
1104
+ limit: 1,
1105
+ select: ['id'],
1106
+ });
1107
+ const existingPhoneId = existingPhone?.values?.[0]?.id as number | undefined;
1108
+ if (existingPhoneId) {
1109
+ await civicrmApiRequest.call(this, 'POST', '/civicrm/ajax/api4/Phone/update', {
1110
+ values: {
1111
+ id: existingPhoneId,
1112
+ ...phoneData,
1113
+ contact_id: contactId,
1114
+ is_primary: isPrimaryPhone,
1115
+ },
1116
+ });
1117
+ } else {
1118
+ await civicrmApiRequest.call(this, 'POST', '/civicrm/ajax/api4/Phone/create', {
1119
+ values: {
1120
+ ...phoneData,
1121
+ contact_id: contactId,
1122
+ is_primary: isPrimaryPhone,
1123
+ 'location_type_id:name': phoneLocationName,
1124
+ },
1125
+ });
1126
+ }
1109
1127
  }
1110
1128
  }
1111
- }
1112
1129
 
1113
1130
 
1114
1131
  if (Object.keys(addressData).length) {
@@ -1185,7 +1202,10 @@ export class CiviCrm implements INodeType {
1185
1202
  },
1186
1203
  );
1187
1204
 
1188
- out.push({ json: res?.values?.[0] ?? {} });
1205
+ out.push({
1206
+ json: res?.values?.[0] ?? {},
1207
+ pairedItem: { item: i },
1208
+ });
1189
1209
  }
1190
1210
 
1191
1211
  return [out];