@ixiam/n8n-nodes-civicrm 1.0.12 → 1.0.13
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/dist/credentials/CiviCrmApi.credentials.js +3 -6
- package/dist/index.js +14 -0
- package/dist/nodes/CiviCrm/CiviCrm.node.js +9 -8
- package/dist/nodes/transport/GenericFunctions.js +2 -1
- package/package.json +1 -1
- package/{credentials → src/credentials}/CiviCrmApi.credentials.ts +15 -19
- package/src/index.ts +12 -0
- package/tsconfig.json +5 -6
- package/dist/credentials/CiviCrmApi.credentials.d.ts +0 -28
- package/dist/nodes/CiviCrm/CiviCrm.node.d.ts +0 -14
- package/dist/nodes/CiviCrm/descriptions/generic.d.ts +0 -3
- package/dist/nodes/CiviCrm/descriptions/resources.d.ts +0 -3
- package/dist/nodes/transport/GenericFunctions.d.ts +0 -10
- /package/dist/{nodes → src/nodes}/CiviCrm/civicrm.svg +0 -0
- /package/{nodes → src/nodes}/CiviCrm/CiviCrm.node.ts +0 -0
- /package/{nodes → src/nodes}/CiviCrm/civicrm.svg +0 -0
- /package/{nodes → src/nodes}/CiviCrm/descriptions/generic.ts +0 -0
- /package/{nodes → src/nodes}/CiviCrm/descriptions/resources.ts +0 -0
- /package/{nodes → src/nodes}/transport/GenericFunctions.ts +0 -0
|
@@ -23,26 +23,23 @@ class CiviCrmApi {
|
|
|
23
23
|
required: true,
|
|
24
24
|
},
|
|
25
25
|
];
|
|
26
|
-
// ✔ Autenticación genérica (esto sí es válido)
|
|
27
26
|
this.authenticate = {
|
|
28
27
|
type: 'generic',
|
|
29
28
|
properties: {
|
|
30
29
|
headers: {
|
|
31
|
-
'X-Civi-Auth': '={{"Bearer " + $credentials.apiToken}}',
|
|
30
|
+
'X-Civi-Auth': '={{ "Bearer " + $credentials.apiToken }}',
|
|
32
31
|
},
|
|
33
32
|
},
|
|
34
33
|
};
|
|
35
34
|
this.test = {
|
|
36
|
-
|
|
35
|
+
request: {
|
|
37
36
|
method: 'POST',
|
|
38
37
|
url: '={{ $credentials.baseUrl.replace(/\\/$/, "") }}/civicrm/ajax/api4/Contact/get',
|
|
39
38
|
headers: {
|
|
40
39
|
'X-Civi-Auth': '={{ "Bearer " + $credentials.apiToken }}',
|
|
41
40
|
'Content-Type': 'application/json',
|
|
42
41
|
},
|
|
43
|
-
body: {
|
|
44
|
-
limit: 1,
|
|
45
|
-
},
|
|
42
|
+
body: { limit: 1 },
|
|
46
43
|
},
|
|
47
44
|
};
|
|
48
45
|
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.credentials = exports.nodes = void 0;
|
|
7
|
+
const CiviCrm_node_1 = __importDefault(require("./nodes/CiviCrm/CiviCrm.node"));
|
|
8
|
+
const CiviCrmApi_credentials_1 = require("./credentials/CiviCrmApi.credentials");
|
|
9
|
+
exports.nodes = [
|
|
10
|
+
new CiviCrm_node_1.default(),
|
|
11
|
+
];
|
|
12
|
+
exports.credentials = [
|
|
13
|
+
new CiviCrmApi_credentials_1.CiviCrmApi(),
|
|
14
|
+
];
|
|
@@ -29,7 +29,7 @@ async function getLocationTypeMap() {
|
|
|
29
29
|
limit: 0,
|
|
30
30
|
});
|
|
31
31
|
const map = {};
|
|
32
|
-
const values = (res
|
|
32
|
+
const values = ((res === null || res === void 0 ? void 0 : 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 = (res
|
|
172
|
+
const values = ((res === null || res === void 0 ? void 0 : res.values) || []);
|
|
173
173
|
return values.map((v) => ({
|
|
174
174
|
name: v.label,
|
|
175
175
|
value: v.id,
|
|
@@ -182,6 +182,7 @@ class CiviCrm {
|
|
|
182
182
|
EXECUTE
|
|
183
183
|
============================================================================ */
|
|
184
184
|
async execute() {
|
|
185
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
185
186
|
const items = this.getInputData();
|
|
186
187
|
const out = [];
|
|
187
188
|
const resource = this.getNodeParameter('resource', 0);
|
|
@@ -226,7 +227,7 @@ class CiviCrm {
|
|
|
226
227
|
select: ['id', 'name', 'title', 'subject', 'display_name'],
|
|
227
228
|
};
|
|
228
229
|
const res = await GenericFunctions_1.civicrmApiRequest.call(this, 'POST', `/civicrm/ajax/api4/${entity}/get`, params);
|
|
229
|
-
out.push({ json: res
|
|
230
|
+
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 : {} });
|
|
230
231
|
continue;
|
|
231
232
|
}
|
|
232
233
|
/* ======================================================
|
|
@@ -278,7 +279,7 @@ class CiviCrm {
|
|
|
278
279
|
const page = 500;
|
|
279
280
|
while (true) {
|
|
280
281
|
const r = await GenericFunctions_1.civicrmApiRequest.call(this, 'POST', `/civicrm/ajax/api4/${entity}/get`, { ...params, limit: page, offset });
|
|
281
|
-
const vals = r
|
|
282
|
+
const vals = (_c = r === null || r === void 0 ? void 0 : r.values) !== null && _c !== void 0 ? _c : [];
|
|
282
283
|
for (const v of vals)
|
|
283
284
|
out.push({ json: v });
|
|
284
285
|
if (vals.length < page)
|
|
@@ -288,7 +289,7 @@ class CiviCrm {
|
|
|
288
289
|
}
|
|
289
290
|
else {
|
|
290
291
|
const r = await GenericFunctions_1.civicrmApiRequest.call(this, 'POST', `/civicrm/ajax/api4/${entity}/get`, { ...params, limit });
|
|
291
|
-
const vals = r
|
|
292
|
+
const vals = (_d = r === null || r === void 0 ? void 0 : r.values) !== null && _d !== void 0 ? _d : [];
|
|
292
293
|
for (const v of vals)
|
|
293
294
|
out.push({ json: v });
|
|
294
295
|
}
|
|
@@ -440,7 +441,7 @@ class CiviCrm {
|
|
|
440
441
|
let contactId = id;
|
|
441
442
|
if (isCreate) {
|
|
442
443
|
const r = await GenericFunctions_1.civicrmApiRequest.call(this, 'POST', '/civicrm/ajax/api4/Contact/create', { values });
|
|
443
|
-
contactId = r
|
|
444
|
+
contactId = (_f = (_e = r === null || r === void 0 ? void 0 : r.values) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.id;
|
|
444
445
|
if (!contactId)
|
|
445
446
|
throw new Error('Failed to create contact.');
|
|
446
447
|
}
|
|
@@ -526,7 +527,7 @@ class CiviCrm {
|
|
|
526
527
|
}
|
|
527
528
|
: {}),
|
|
528
529
|
});
|
|
529
|
-
out.push({ json: res
|
|
530
|
+
out.push({ json: (_h = (_g = res === null || res === void 0 ? void 0 : res.values) === null || _g === void 0 ? void 0 : _g[0]) !== null && _h !== void 0 ? _h : {} });
|
|
530
531
|
}
|
|
531
532
|
return [out];
|
|
532
533
|
}
|
|
@@ -536,7 +537,7 @@ exports.CiviCrm = CiviCrm;
|
|
|
536
537
|
UTILS
|
|
537
538
|
============================================================================ */
|
|
538
539
|
function convertValue(val) {
|
|
539
|
-
const t = String(val
|
|
540
|
+
const t = String(val !== null && val !== void 0 ? val : '').trim();
|
|
540
541
|
if (t === '')
|
|
541
542
|
return '';
|
|
542
543
|
if (t === 'true')
|
|
@@ -7,6 +7,7 @@ const n8n_workflow_1 = require("n8n-workflow");
|
|
|
7
7
|
* Usa form-urlencoded con el campo "params" serializado
|
|
8
8
|
*/
|
|
9
9
|
async function civicrmApiRequest(method, path, body) {
|
|
10
|
+
var _a;
|
|
10
11
|
const { baseUrl, apiToken } = (await this.getCredentials('civiCrmApi'));
|
|
11
12
|
const options = {
|
|
12
13
|
method,
|
|
@@ -17,7 +18,7 @@ async function civicrmApiRequest(method, path, body) {
|
|
|
17
18
|
},
|
|
18
19
|
// cuerpo plano como espera Civi-Go
|
|
19
20
|
body: {
|
|
20
|
-
params: JSON.stringify(body.params
|
|
21
|
+
params: JSON.stringify((_a = body.params) !== null && _a !== void 0 ? _a : body),
|
|
21
22
|
},
|
|
22
23
|
json: true,
|
|
23
24
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ixiam/n8n-nodes-civicrm",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
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.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
ICredentialTestFunctions,
|
|
4
|
-
ICredentialsDecrypted,
|
|
2
|
+
ICredentialType,
|
|
5
3
|
INodeProperties,
|
|
4
|
+
ICredentialTestRequest,
|
|
6
5
|
} from 'n8n-workflow';
|
|
7
6
|
|
|
8
|
-
export class CiviCrmApi {
|
|
7
|
+
export class CiviCrmApi implements ICredentialType {
|
|
9
8
|
|
|
10
9
|
name = 'civiCrmApi';
|
|
11
10
|
displayName = 'CiviCRM API';
|
|
@@ -29,27 +28,24 @@ export class CiviCrmApi {
|
|
|
29
28
|
},
|
|
30
29
|
];
|
|
31
30
|
|
|
32
|
-
// ✔ Autenticación genérica (esto sí es válido)
|
|
33
31
|
authenticate = {
|
|
34
|
-
type: 'generic',
|
|
32
|
+
type: 'generic' as const,
|
|
35
33
|
properties: {
|
|
36
34
|
headers: {
|
|
37
|
-
'X-Civi-Auth': '={{"Bearer " + $credentials.apiToken}}',
|
|
35
|
+
'X-Civi-Auth': '={{ "Bearer " + $credentials.apiToken }}',
|
|
38
36
|
},
|
|
39
37
|
},
|
|
40
38
|
};
|
|
41
39
|
|
|
42
|
-
test = {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
limit: 1,
|
|
40
|
+
test: ICredentialTestRequest = {
|
|
41
|
+
request: {
|
|
42
|
+
method: 'POST',
|
|
43
|
+
url: '={{ $credentials.baseUrl.replace(/\\/$/, "") }}/civicrm/ajax/api4/Contact/get',
|
|
44
|
+
headers: {
|
|
45
|
+
'X-Civi-Auth': '={{ "Bearer " + $credentials.apiToken }}',
|
|
46
|
+
'Content-Type': 'application/json',
|
|
47
|
+
},
|
|
48
|
+
body: { limit: 1 },
|
|
52
49
|
},
|
|
53
|
-
}
|
|
54
|
-
};
|
|
50
|
+
};
|
|
55
51
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { INodeType, ICredentialType } from 'n8n-workflow';
|
|
2
|
+
|
|
3
|
+
import CiviCrmNode from './nodes/CiviCrm/CiviCrm.node';
|
|
4
|
+
import { CiviCrmApi } from './credentials/CiviCrmApi.credentials';
|
|
5
|
+
|
|
6
|
+
export const nodes: INodeType[] = [
|
|
7
|
+
new CiviCrmNode(),
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
export const credentials: ICredentialType[] = [
|
|
11
|
+
new CiviCrmApi(),
|
|
12
|
+
];
|
package/tsconfig.json
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"declaration": true,
|
|
3
|
+
"module": "CommonJS",
|
|
4
|
+
"target": "ES2019",
|
|
5
|
+
"lib": ["ES2020"],
|
|
7
6
|
"outDir": "dist",
|
|
8
|
-
"rootDir": "
|
|
7
|
+
"rootDir": "src",
|
|
9
8
|
"strict": true,
|
|
10
9
|
"esModuleInterop": true,
|
|
11
10
|
"resolveJsonModule": true,
|
|
12
11
|
"skipLibCheck": true
|
|
13
12
|
},
|
|
14
|
-
"include": ["
|
|
13
|
+
"include": ["src/**/*"],
|
|
15
14
|
"exclude": ["node_modules", "dist"]
|
|
16
15
|
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { INodeProperties } from 'n8n-workflow';
|
|
2
|
-
export declare class CiviCrmApi {
|
|
3
|
-
name: string;
|
|
4
|
-
displayName: string;
|
|
5
|
-
documentationUrl: string;
|
|
6
|
-
properties: INodeProperties[];
|
|
7
|
-
authenticate: {
|
|
8
|
-
type: string;
|
|
9
|
-
properties: {
|
|
10
|
-
headers: {
|
|
11
|
-
'X-Civi-Auth': string;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
test: {
|
|
16
|
-
httpRequest: {
|
|
17
|
-
method: string;
|
|
18
|
-
url: string;
|
|
19
|
-
headers: {
|
|
20
|
-
'X-Civi-Auth': string;
|
|
21
|
-
'Content-Type': string;
|
|
22
|
-
};
|
|
23
|
-
body: {
|
|
24
|
-
limit: number;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
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;
|
|
@@ -1,10 +0,0 @@
|
|
|
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>;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|