@ixiam/n8n-nodes-civicrm 1.1.18 → 1.1.19
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/LICENSE +21 -0
- package/README.md +101 -0
- package/credentials/CiviCrmApi.credentials.ts +58 -0
- package/dist/credentials/CiviCrmApi.credentials.d.ts +30 -0
- package/dist/credentials/CiviCrmApi.credentials.js +27 -24
- package/dist/nodes/CiviCrm/CiviCrm.node.d.ts +14 -0
- package/dist/nodes/CiviCrm/CiviCrm.node.js +8 -9
- package/dist/nodes/CiviCrm/descriptions/generic.d.ts +3 -0
- package/dist/nodes/CiviCrm/descriptions/resources.d.ts +3 -0
- package/dist/nodes/transport/GenericFunctions.d.ts +10 -0
- package/dist/nodes/transport/GenericFunctions.js +4 -4
- package/nodes/CiviCrm/CiviCrm.node.ts +664 -0
- package/nodes/CiviCrm/civicrm.svg +28 -0
- package/nodes/CiviCrm/descriptions/generic.ts +9 -0
- package/nodes/CiviCrm/descriptions/resources.ts +41 -0
- package/nodes/transport/GenericFunctions.ts +51 -0
- package/package.json +64 -1
- package/src/credentials/CiviCrmApi.credentials.ts +2 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 iXiam Global Solutions
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# n8n-nodes-civicrm
|
|
2
|
+
<<<<<<< HEAD
|
|
2
3
|
|
|
3
4
|

|
|
4
5
|

|
|
@@ -21,10 +22,21 @@ Download: https://civicrm.org/download
|
|
|
21
22
|
## Installation
|
|
22
23
|
|
|
23
24
|
1. In your n8n instance, open:
|
|
25
|
+
=======
|
|
26
|
+
Community Node for **CiviCRM API v4** (Civi-Go compatible)
|
|
27
|
+
Developed and maintained by **Ixiam Global Solutions**.
|
|
28
|
+
|
|
29
|
+
This node enables full integration between **n8n** and **CiviCRM API v4**, supporting create/update/delete operations, smart field mapping, dynamic location types, and advanced filtering on GET operations.
|
|
30
|
+
|
|
31
|
+
## 🚀 Installation
|
|
32
|
+
|
|
33
|
+
1. In your n8n instance, go to:
|
|
34
|
+
>>>>>>> 03f29e40d265531031a602d4bdcf4724e39bd809
|
|
24
35
|
**Settings → Community Nodes → Install**
|
|
25
36
|
2. Enter the package name:
|
|
26
37
|
|
|
27
38
|
```
|
|
39
|
+
<<<<<<< HEAD
|
|
28
40
|
@ixiam/n8n-nodes-civicrm
|
|
29
41
|
```
|
|
30
42
|
|
|
@@ -85,6 +97,81 @@ home.phone.phone_type_id = 2
|
|
|
85
97
|
### GET MANY with JSON filters
|
|
86
98
|
Example:
|
|
87
99
|
```json
|
|
100
|
+
=======
|
|
101
|
+
n8n-nodes-civicrm
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
3. Approve installation and enable Community Nodes.
|
|
105
|
+
|
|
106
|
+
## 🔐 Credentials
|
|
107
|
+
|
|
108
|
+
The node uses **Bearer Token Authentication**.
|
|
109
|
+
|
|
110
|
+
| Field | Description |
|
|
111
|
+
|-------|-------------|
|
|
112
|
+
| **Base URL** | The root URL of your CiviCRM instance (without trailing slash). Example: `https://crm.example.org` |
|
|
113
|
+
| **API Token** | Sent as header `X-Civi-Auth: Bearer <token>` |
|
|
114
|
+
|
|
115
|
+
After entering credentials, click **Save** to validate the connection.
|
|
116
|
+
|
|
117
|
+
## 📦 Supported Entities
|
|
118
|
+
|
|
119
|
+
The node includes full API v4 support for the following entities:
|
|
120
|
+
|
|
121
|
+
| Entity | Operations |
|
|
122
|
+
|--------|------------|
|
|
123
|
+
| **Contact** | get, getMany, create, update, delete |
|
|
124
|
+
| **Membership** | get, getMany, create, update, delete |
|
|
125
|
+
| **Group** | get, getMany, create, update, delete |
|
|
126
|
+
| **Relationship** | get, getMany, create, update, delete |
|
|
127
|
+
| **Activity** | get, getMany, create, update, delete |
|
|
128
|
+
| **Custom API Call** | full custom API4 request |
|
|
129
|
+
|
|
130
|
+
## 🧩 Key Features
|
|
131
|
+
|
|
132
|
+
### **1. Dynamic Field Mapping**
|
|
133
|
+
Supports any standard or custom field:
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
first_name = John
|
|
137
|
+
last_name = Doe
|
|
138
|
+
custom_45 = Blue
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### **2. Smart Email, Phone & Address Mapping**
|
|
142
|
+
Two ways to set location-aware fields:
|
|
143
|
+
|
|
144
|
+
**(A) Simple fields**
|
|
145
|
+
```
|
|
146
|
+
email = test@example.org
|
|
147
|
+
phone.mobile = 600123456
|
|
148
|
+
address.city = Barcelona
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
**(B) Dynamic prefixes matched to CiviCRM Location Types**
|
|
152
|
+
```
|
|
153
|
+
work.email = user@company.org
|
|
154
|
+
billing.address.postal_code = 80331
|
|
155
|
+
home.phone.phone_type_id = 2
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### **3. Default Location Type selectors**
|
|
159
|
+
If no prefix is used, default types are applied.
|
|
160
|
+
|
|
161
|
+
### **4. Birth Date Normalization**
|
|
162
|
+
Accepted input formats:
|
|
163
|
+
|
|
164
|
+
- YYYY-MM-DD
|
|
165
|
+
- DD/MM/YYYY
|
|
166
|
+
- DD-MM-YYYY
|
|
167
|
+
- YYYY/MM/DD
|
|
168
|
+
- YYYY.MM.DD
|
|
169
|
+
|
|
170
|
+
Auto-normalized to `YYYY-MM-DD`.
|
|
171
|
+
|
|
172
|
+
### **5. GET MANY with JSON Filters**
|
|
173
|
+
```
|
|
174
|
+
>>>>>>> 03f29e40d265531031a602d4bdcf4724e39bd809
|
|
88
175
|
[
|
|
89
176
|
["first_name", "LIKE", "Ju%"],
|
|
90
177
|
["birth_date", ">", "1990-01-01"],
|
|
@@ -92,6 +179,7 @@ Example:
|
|
|
92
179
|
]
|
|
93
180
|
```
|
|
94
181
|
|
|
182
|
+
<<<<<<< HEAD
|
|
95
183
|
### Birth date normalization
|
|
96
184
|
Accepted input formats:
|
|
97
185
|
- YYYY-MM-DD
|
|
@@ -105,6 +193,10 @@ Normalized to `YYYY-MM-DD`.
|
|
|
105
193
|
### Custom API Call
|
|
106
194
|
Example:
|
|
107
195
|
```json
|
|
196
|
+
=======
|
|
197
|
+
### **6. Custom API Call Mode**
|
|
198
|
+
```
|
|
199
|
+
>>>>>>> 03f29e40d265531031a602d4bdcf4724e39bd809
|
|
108
200
|
{
|
|
109
201
|
"entity": "Contact",
|
|
110
202
|
"action": "get",
|
|
@@ -112,6 +204,7 @@ Example:
|
|
|
112
204
|
}
|
|
113
205
|
```
|
|
114
206
|
|
|
207
|
+
<<<<<<< HEAD
|
|
115
208
|
---
|
|
116
209
|
|
|
117
210
|
## Compatibility
|
|
@@ -152,5 +245,13 @@ Email: info@ixiam.com
|
|
|
152
245
|
---
|
|
153
246
|
|
|
154
247
|
## License
|
|
248
|
+
=======
|
|
249
|
+
## 🧑💻 About Ixiam Global Solutions
|
|
250
|
+
|
|
251
|
+
Website: **https://www.ixiam.com**
|
|
252
|
+
Contact: **info@ixiam.com**
|
|
253
|
+
|
|
254
|
+
## 📄 License
|
|
255
|
+
>>>>>>> 03f29e40d265531031a602d4bdcf4724e39bd809
|
|
155
256
|
|
|
156
257
|
MIT License
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ICredentialType,
|
|
3
|
+
INodeProperties,
|
|
4
|
+
IHttpRequestMethods,
|
|
5
|
+
} from 'n8n-workflow';
|
|
6
|
+
|
|
7
|
+
export class CiviCrmApi implements ICredentialType {
|
|
8
|
+
name = 'civiCrmApi';
|
|
9
|
+
displayName = 'CiviCRM API';
|
|
10
|
+
documentationUrl = 'https://docs.civicrm.org/dev/en/latest/api/';
|
|
11
|
+
|
|
12
|
+
authenticate = {
|
|
13
|
+
type: 'generic' as const,
|
|
14
|
+
properties: {
|
|
15
|
+
headers: {
|
|
16
|
+
'X-Civi-Auth': '={{"Bearer " + $credentials.apiToken}}',
|
|
17
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// Credential test button
|
|
23
|
+
test = {
|
|
24
|
+
request: {
|
|
25
|
+
method: 'POST' as IHttpRequestMethods,
|
|
26
|
+
url: '={{$credentials.baseUrl.replace(/\\/$/, "")}}/civicrm/ajax/api4/Contact/get',
|
|
27
|
+
headers: {
|
|
28
|
+
'X-Civi-Auth': '={{"Bearer " + $credentials.apiToken}}',
|
|
29
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
30
|
+
},
|
|
31
|
+
body: {
|
|
32
|
+
params: '={"limit":1}', // API4 compatible
|
|
33
|
+
},
|
|
34
|
+
json: true,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
properties: INodeProperties[] = [
|
|
39
|
+
{
|
|
40
|
+
displayName: 'Base URL',
|
|
41
|
+
name: 'baseUrl',
|
|
42
|
+
type: 'string',
|
|
43
|
+
default: '',
|
|
44
|
+
required: true,
|
|
45
|
+
placeholder: 'https://crm.example.org',
|
|
46
|
+
description: 'Base URL without a trailing slash.',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
displayName: 'API Token',
|
|
50
|
+
name: 'apiToken',
|
|
51
|
+
type: 'string',
|
|
52
|
+
typeOptions: { password: true },
|
|
53
|
+
default: '',
|
|
54
|
+
required: true,
|
|
55
|
+
description: 'Sent as "X-Civi-Auth: Bearer <token>"',
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ICredentialType, INodeProperties, IHttpRequestMethods } from 'n8n-workflow';
|
|
2
|
+
export declare class CiviCrmApi implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
documentationUrl: string;
|
|
6
|
+
authenticate: {
|
|
7
|
+
type: "generic";
|
|
8
|
+
properties: {
|
|
9
|
+
headers: {
|
|
10
|
+
'X-Civi-Auth': string;
|
|
11
|
+
'Content-Type': string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
test: {
|
|
16
|
+
request: {
|
|
17
|
+
method: IHttpRequestMethods;
|
|
18
|
+
url: string;
|
|
19
|
+
headers: {
|
|
20
|
+
'X-Civi-Auth': string;
|
|
21
|
+
'Content-Type': string;
|
|
22
|
+
};
|
|
23
|
+
body: {
|
|
24
|
+
params: string;
|
|
25
|
+
};
|
|
26
|
+
json: boolean;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
properties: INodeProperties[];
|
|
30
|
+
}
|
|
@@ -6,6 +6,30 @@ class CiviCrmApi {
|
|
|
6
6
|
this.name = 'civiCrmApi';
|
|
7
7
|
this.displayName = 'CiviCRM API';
|
|
8
8
|
this.documentationUrl = 'https://docs.civicrm.org/dev/en/latest/api/';
|
|
9
|
+
this.authenticate = {
|
|
10
|
+
type: 'generic',
|
|
11
|
+
properties: {
|
|
12
|
+
headers: {
|
|
13
|
+
'X-Civi-Auth': '={{"Bearer " + $credentials.apiToken}}',
|
|
14
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
// Credential test button
|
|
19
|
+
this.test = {
|
|
20
|
+
request: {
|
|
21
|
+
method: 'POST',
|
|
22
|
+
url: '={{$credentials.baseUrl.replace(/\\/$/, "")}}/civicrm/ajax/api4/Contact/get',
|
|
23
|
+
headers: {
|
|
24
|
+
'X-Civi-Auth': '={{"Bearer " + $credentials.apiToken}}',
|
|
25
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
26
|
+
},
|
|
27
|
+
body: {
|
|
28
|
+
params: '={"limit":1}', // API4 compatible
|
|
29
|
+
},
|
|
30
|
+
json: true,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
9
33
|
this.properties = [
|
|
10
34
|
{
|
|
11
35
|
displayName: 'Base URL',
|
|
@@ -13,6 +37,8 @@ class CiviCrmApi {
|
|
|
13
37
|
type: 'string',
|
|
14
38
|
default: '',
|
|
15
39
|
required: true,
|
|
40
|
+
placeholder: 'https://crm.example.org',
|
|
41
|
+
description: 'Base URL without a trailing slash.',
|
|
16
42
|
},
|
|
17
43
|
{
|
|
18
44
|
displayName: 'API Token',
|
|
@@ -21,32 +47,9 @@ class CiviCrmApi {
|
|
|
21
47
|
typeOptions: { password: true },
|
|
22
48
|
default: '',
|
|
23
49
|
required: true,
|
|
50
|
+
description: 'Sent as "X-Civi-Auth: Bearer <token>"',
|
|
24
51
|
},
|
|
25
52
|
];
|
|
26
|
-
// ← ESTA ES LA PARTE CRÍTICA
|
|
27
|
-
this.authenticate = {
|
|
28
|
-
type: 'generic',
|
|
29
|
-
properties: {
|
|
30
|
-
headers: {
|
|
31
|
-
'X-Civi-Auth': '={{ "Bearer " + $credentials.apiToken }}',
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
this.test = {
|
|
36
|
-
request: {
|
|
37
|
-
baseURL: '={{ $credentials.baseUrl.replace(/\\/$/, "") }}',
|
|
38
|
-
url: '/civicrm/ajax/api4/Contact/get',
|
|
39
|
-
method: 'POST',
|
|
40
|
-
headers: {
|
|
41
|
-
'X-Civi-Auth': '={{ "Bearer " + $credentials.apiToken }}',
|
|
42
|
-
'Content-Type': 'application/json',
|
|
43
|
-
},
|
|
44
|
-
body: {
|
|
45
|
-
limit: 1,
|
|
46
|
-
select: ['id']
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
exports.CiviCrmApi = CiviCrmApi;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IExecuteFunctions, ILoadOptionsFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class CiviCrm implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
methods: {
|
|
5
|
+
loadOptions: {
|
|
6
|
+
loadOptionValues(this: ILoadOptionsFunctions): Promise<{
|
|
7
|
+
name: string;
|
|
8
|
+
value: number;
|
|
9
|
+
}[]>;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
13
|
+
}
|
|
14
|
+
export default CiviCrm;
|
|
@@ -29,7 +29,7 @@ async function getLocationTypeMap() {
|
|
|
29
29
|
limit: 0,
|
|
30
30
|
});
|
|
31
31
|
const map = {};
|
|
32
|
-
const values = (
|
|
32
|
+
const values = (res?.values || []);
|
|
33
33
|
for (const v of values) {
|
|
34
34
|
const name = v.name || '';
|
|
35
35
|
const label = v.label || '';
|
|
@@ -169,7 +169,7 @@ class CiviCrm {
|
|
|
169
169
|
body: { params: JSON.stringify({ limit: 50, select: ['id', 'label'] }) },
|
|
170
170
|
json: true,
|
|
171
171
|
});
|
|
172
|
-
const values = (
|
|
172
|
+
const values = (res?.values || []);
|
|
173
173
|
return values.map((v) => ({
|
|
174
174
|
name: v.label,
|
|
175
175
|
value: v.id,
|
|
@@ -182,7 +182,6 @@ class CiviCrm {
|
|
|
182
182
|
EXECUTE
|
|
183
183
|
============================================================================ */
|
|
184
184
|
async execute() {
|
|
185
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
186
185
|
const items = this.getInputData();
|
|
187
186
|
const out = [];
|
|
188
187
|
const resource = this.getNodeParameter('resource', 0);
|
|
@@ -227,7 +226,7 @@ class CiviCrm {
|
|
|
227
226
|
select: ['id', 'name', 'title', 'subject', 'display_name'],
|
|
228
227
|
};
|
|
229
228
|
const res = await GenericFunctions_1.civicrmApiRequest.call(this, 'POST', `/civicrm/ajax/api4/${entity}/get`, params);
|
|
230
|
-
out.push({ json:
|
|
229
|
+
out.push({ json: res?.values?.[0] ?? {} });
|
|
231
230
|
continue;
|
|
232
231
|
}
|
|
233
232
|
/* ======================================================
|
|
@@ -279,7 +278,7 @@ class CiviCrm {
|
|
|
279
278
|
const page = 500;
|
|
280
279
|
while (true) {
|
|
281
280
|
const r = await GenericFunctions_1.civicrmApiRequest.call(this, 'POST', `/civicrm/ajax/api4/${entity}/get`, { ...params, limit: page, offset });
|
|
282
|
-
const vals =
|
|
281
|
+
const vals = r?.values ?? [];
|
|
283
282
|
for (const v of vals)
|
|
284
283
|
out.push({ json: v });
|
|
285
284
|
if (vals.length < page)
|
|
@@ -289,7 +288,7 @@ class CiviCrm {
|
|
|
289
288
|
}
|
|
290
289
|
else {
|
|
291
290
|
const r = await GenericFunctions_1.civicrmApiRequest.call(this, 'POST', `/civicrm/ajax/api4/${entity}/get`, { ...params, limit });
|
|
292
|
-
const vals =
|
|
291
|
+
const vals = r?.values ?? [];
|
|
293
292
|
for (const v of vals)
|
|
294
293
|
out.push({ json: v });
|
|
295
294
|
}
|
|
@@ -441,7 +440,7 @@ class CiviCrm {
|
|
|
441
440
|
let contactId = id;
|
|
442
441
|
if (isCreate) {
|
|
443
442
|
const r = await GenericFunctions_1.civicrmApiRequest.call(this, 'POST', '/civicrm/ajax/api4/Contact/create', { values });
|
|
444
|
-
contactId =
|
|
443
|
+
contactId = r?.values?.[0]?.id;
|
|
445
444
|
if (!contactId)
|
|
446
445
|
throw new Error('Failed to create contact.');
|
|
447
446
|
}
|
|
@@ -527,7 +526,7 @@ class CiviCrm {
|
|
|
527
526
|
}
|
|
528
527
|
: {}),
|
|
529
528
|
});
|
|
530
|
-
out.push({ json:
|
|
529
|
+
out.push({ json: res?.values?.[0] ?? {} });
|
|
531
530
|
}
|
|
532
531
|
return [out];
|
|
533
532
|
}
|
|
@@ -537,7 +536,7 @@ exports.CiviCrm = CiviCrm;
|
|
|
537
536
|
UTILS
|
|
538
537
|
============================================================================ */
|
|
539
538
|
function convertValue(val) {
|
|
540
|
-
const t = String(val
|
|
539
|
+
const t = String(val ?? '').trim();
|
|
541
540
|
if (t === '')
|
|
542
541
|
return '';
|
|
543
542
|
if (t === 'true')
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IExecuteFunctions } from 'n8n-workflow';
|
|
2
|
+
/**
|
|
3
|
+
* Ejecuta una llamada a la API de CiviCRM v4 (Civi-Go)
|
|
4
|
+
* Usa form-urlencoded con el campo "params" serializado
|
|
5
|
+
*/
|
|
6
|
+
export declare function civicrmApiRequest(this: IExecuteFunctions, method: 'POST', path: string, body: Record<string, unknown>): Promise<any>;
|
|
7
|
+
/**
|
|
8
|
+
* Devuelve el cuerpo estándar para las llamadas API4 (plano)
|
|
9
|
+
*/
|
|
10
|
+
export declare function api4(entity: string, action: string, params?: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.civicrmApiRequest =
|
|
4
|
-
exports.api4 = api4;
|
|
3
|
+
exports.api4 = exports.civicrmApiRequest = void 0;
|
|
5
4
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
6
5
|
/**
|
|
7
6
|
* Ejecuta una llamada a la API de CiviCRM v4 (Civi-Go)
|
|
8
7
|
* Usa form-urlencoded con el campo "params" serializado
|
|
9
8
|
*/
|
|
10
9
|
async function civicrmApiRequest(method, path, body) {
|
|
11
|
-
var _a;
|
|
12
10
|
const { baseUrl, apiToken } = (await this.getCredentials('civiCrmApi'));
|
|
13
11
|
const options = {
|
|
14
12
|
method,
|
|
@@ -19,7 +17,7 @@ async function civicrmApiRequest(method, path, body) {
|
|
|
19
17
|
},
|
|
20
18
|
// cuerpo plano como espera Civi-Go
|
|
21
19
|
body: {
|
|
22
|
-
params: JSON.stringify(
|
|
20
|
+
params: JSON.stringify(body.params ?? body),
|
|
23
21
|
},
|
|
24
22
|
json: true,
|
|
25
23
|
};
|
|
@@ -31,6 +29,7 @@ async function civicrmApiRequest(method, path, body) {
|
|
|
31
29
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
|
|
32
30
|
}
|
|
33
31
|
}
|
|
32
|
+
exports.civicrmApiRequest = civicrmApiRequest;
|
|
34
33
|
/**
|
|
35
34
|
* Devuelve el cuerpo estándar para las llamadas API4 (plano)
|
|
36
35
|
*/
|
|
@@ -38,3 +37,4 @@ function api4(entity, action, params = {}) {
|
|
|
38
37
|
// devolvemos los parámetros planos, no anidados
|
|
39
38
|
return params;
|
|
40
39
|
}
|
|
40
|
+
exports.api4 = api4;
|