@ixiam/n8n-nodes-civicrm 0.2.1 → 0.2.3

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.
@@ -40,23 +40,6 @@ class CiviCrm {
40
40
  },
41
41
  ...generic_1.genericFields,
42
42
  ...generic_1.upsertFields,
43
- {
44
- displayName: 'Processor Name',
45
- name: 'processor',
46
- type: 'string',
47
- default: '',
48
- placeholder: 'fp_volunteer_registration',
49
- description: 'Technical name after FormProcessor_',
50
- displayOptions: { show: { resource: ['formProcessor'], operation: ['execute'] } },
51
- },
52
- {
53
- displayName: 'Records (JSON)',
54
- name: 'recordsJson',
55
- type: 'string',
56
- default: '',
57
- placeholder: `[{"first_name":"Alice"}]`,
58
- displayOptions: { show: { resource: ['formProcessor'], operation: ['execute'] } },
59
- },
60
43
  ],
61
44
  };
62
45
  this.methods = {
@@ -89,15 +72,6 @@ class CiviCrm {
89
72
  const resource = this.getNodeParameter('resource', 0);
90
73
  const operation = this.getNodeParameter('operation', 0);
91
74
  for (let i = 0; i < items.length; i++) {
92
- // FORM PROCESSOR
93
- if (resource === 'formProcessor' && operation === 'execute') {
94
- const processor = this.getNodeParameter('processor', i);
95
- const recordsJson = this.getNodeParameter('recordsJson', i, '');
96
- const records = recordsJson ? JSON.parse(recordsJson) : [];
97
- const res = await GenericFunctions_1.civicrmApiRequest.call(this, 'POST', `/civicrm/ajax/api4/FormProcessor_${processor}/save`, { params: { records } });
98
- out.push({ json: res });
99
- continue;
100
- }
101
75
  const entity = ENTITY_MAP[resource];
102
76
  // GET
103
77
  if (operation === 'get') {
@@ -110,7 +84,24 @@ class CiviCrm {
110
84
  const returnAll = this.getNodeParameter('returnAll', i, false);
111
85
  const limit = this.getNodeParameter('limit', i, 100);
112
86
  const whereJson = this.getNodeParameter('whereJson', i, '');
113
- const where = whereJson ? JSON.parse(whereJson) : undefined;
87
+ let where;
88
+ if (whereJson) {
89
+ try {
90
+ where = JSON.parse(whereJson);
91
+ }
92
+ catch (e) {
93
+ throw new Error('Where (JSON) debe ser JSON válido: usa un objeto o un array de condiciones.');
94
+ }
95
+ }
96
+ // Normalize where: allow object or array; API4 accepts both
97
+ if (where && typeof where === 'object' && !Array.isArray(where)) {
98
+ where = where;
99
+ }
100
+ if (Array.isArray(where)) {
101
+ // leave as-is; expected [[field, op, value], ...]
102
+ }
103
+ // Cap limit to a reasonable page size
104
+ const cappedLimit = Math.max(1, Math.min(limit, 500));
114
105
  if (returnAll) {
115
106
  let offset = 0;
116
107
  const page = 500;
@@ -125,7 +116,7 @@ class CiviCrm {
125
116
  }
126
117
  }
127
118
  else {
128
- const res = await GenericFunctions_1.civicrmApiRequest.call(this, 'POST', `/civicrm/ajax/api4/${entity}/get`, (0, GenericFunctions_1.api4)(entity, 'get', { where, limit }));
119
+ const res = await GenericFunctions_1.civicrmApiRequest.call(this, 'POST', `/civicrm/ajax/api4/${entity}/get`, (0, GenericFunctions_1.api4)(entity, 'get', { where, limit: cappedLimit }));
129
120
  const vals = (res?.values ?? []);
130
121
  for (const v of vals)
131
122
  out.push({ json: v });
@@ -7,7 +7,6 @@ const RESOURCE_OPTIONS = [
7
7
  { name: 'Case', value: 'case' },
8
8
  { name: 'Contribution', value: 'contribution' },
9
9
  { name: 'Membership', value: 'membership' },
10
- { name: 'Form Processor', value: 'formProcessor' },
11
10
  ];
12
11
  exports.resourceProp = {
13
12
  displayName: 'Resource',
@@ -21,7 +20,7 @@ exports.operationProp = {
21
20
  name: 'operation',
22
21
  type: 'options',
23
22
  displayOptions: {
24
- show: { resource: ['contact', 'event', 'case', 'contribution', 'membership', 'formProcessor'] },
23
+ show: { resource: ['contact', 'event', 'case', 'contribution', 'membership'] },
25
24
  },
26
25
  default: 'get',
27
26
  options: [
@@ -30,7 +29,5 @@ exports.operationProp = {
30
29
  { name: 'Create', value: 'create' },
31
30
  { name: 'Update', value: 'update' },
32
31
  { name: 'Delete', value: 'delete' },
33
- // Solo para formProcessor
34
- { name: 'Execute', value: 'execute', action: 'Execute FormProcessor', description: 'Run a FormProcessor', },
35
32
  ], // tipo mutable
36
33
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ixiam/n8n-nodes-civicrm",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "CiviCRM API v4 for n8n",
5
5
  "license": "MIT",
6
6
  "keywords": [