@ixiam/n8n-nodes-civicrm 0.2.1 → 0.2.2

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.
@@ -30,6 +30,33 @@ class CiviCrm {
30
30
  properties: [
31
31
  resources_1.resourceProp,
32
32
  resources_1.operationProp,
33
+ // GET MANY controls
34
+ {
35
+ displayName: 'Return All',
36
+ name: 'returnAll',
37
+ type: 'boolean',
38
+ default: false,
39
+ description: 'Whether to return all results (ignores Limit)',
40
+ displayOptions: { show: { operation: ['getMany'] } },
41
+ },
42
+ {
43
+ displayName: 'Limit',
44
+ name: 'limit',
45
+ type: 'number',
46
+ default: 100,
47
+ description: 'Max number of records to return',
48
+ typeOptions: { minValue: 1, maxValue: 500 },
49
+ displayOptions: { show: { operation: ['getMany'], returnAll: [false] } },
50
+ },
51
+ {
52
+ displayName: 'Where (JSON)',
53
+ name: 'whereJson',
54
+ type: 'string',
55
+ default: '',
56
+ placeholder: '[["first_name","=","Alice"]] or {"contact_type":"Individual"}',
57
+ description: 'API4 where clause as JSON (array of conditions or simple object)',
58
+ displayOptions: { show: { operation: ['getMany'] } },
59
+ },
33
60
  {
34
61
  displayName: 'ID',
35
62
  name: 'id',
@@ -40,23 +67,6 @@ class CiviCrm {
40
67
  },
41
68
  ...generic_1.genericFields,
42
69
  ...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
70
  ],
61
71
  };
62
72
  this.methods = {
@@ -89,15 +99,6 @@ class CiviCrm {
89
99
  const resource = this.getNodeParameter('resource', 0);
90
100
  const operation = this.getNodeParameter('operation', 0);
91
101
  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
102
  const entity = ENTITY_MAP[resource];
102
103
  // GET
103
104
  if (operation === 'get') {
@@ -110,7 +111,16 @@ class CiviCrm {
110
111
  const returnAll = this.getNodeParameter('returnAll', i, false);
111
112
  const limit = this.getNodeParameter('limit', i, 100);
112
113
  const whereJson = this.getNodeParameter('whereJson', i, '');
113
- const where = whereJson ? JSON.parse(whereJson) : undefined;
114
+ let where = whereJson ? JSON.parse(whereJson) : undefined;
115
+ // Normalize where: allow object or array; API4 accepts both
116
+ if (where && typeof where === 'object' && !Array.isArray(where)) {
117
+ where = where;
118
+ }
119
+ if (Array.isArray(where)) {
120
+ // leave as-is; expected [[field, op, value], ...]
121
+ }
122
+ // Cap limit to a reasonable page size
123
+ const cappedLimit = Math.max(1, Math.min(limit, 500));
114
124
  if (returnAll) {
115
125
  let offset = 0;
116
126
  const page = 500;
@@ -125,7 +135,7 @@ class CiviCrm {
125
135
  }
126
136
  }
127
137
  else {
128
- const res = await GenericFunctions_1.civicrmApiRequest.call(this, 'POST', `/civicrm/ajax/api4/${entity}/get`, (0, GenericFunctions_1.api4)(entity, 'get', { where, limit }));
138
+ const res = await GenericFunctions_1.civicrmApiRequest.call(this, 'POST', `/civicrm/ajax/api4/${entity}/get`, (0, GenericFunctions_1.api4)(entity, 'get', { where, limit: cappedLimit }));
129
139
  const vals = (res?.values ?? []);
130
140
  for (const v of vals)
131
141
  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.2",
4
4
  "description": "CiviCRM API v4 for n8n",
5
5
  "license": "MIT",
6
6
  "keywords": [