@ixiam/n8n-nodes-civicrm 1.1.26 → 1.1.28
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/.release-it.json +6 -0
- package/dist/credentials/CiviCrmApi.credentials.js +19 -9
- package/dist/nodes/CiviCrm/CiviCrm.node.js +3 -3
- package/dist/nodes/transport/GenericFunctions.js +4 -4
- package/eslint.config.mjs +3 -0
- package/package.json +17 -19
- package/src/credentials/CiviCrmApi.credentials.ts +19 -9
- package/src/nodes/CiviCrm/CiviCrm.node.ts +5 -5
- package/src/nodes/transport/GenericFunctions.ts +8 -7
- package/temp_civigo/package/LICENSE.md +19 -0
- package/temp_civigo/package/README.md +34 -0
- package/temp_civigo/package/package.json +59 -0
- package/.eslintignore +0 -1
- package/.eslintrc.cjs +0 -12
package/.release-it.json
ADDED
|
@@ -5,20 +5,23 @@ class CiviCrmApi {
|
|
|
5
5
|
constructor() {
|
|
6
6
|
this.name = 'civiCrmApi';
|
|
7
7
|
this.displayName = 'CiviCRM API';
|
|
8
|
-
this.documentationUrl = 'https://docs.civicrm.org/dev/en/latest/api/';
|
|
8
|
+
this.documentationUrl = 'https://docs.civicrm.org/dev/en/latest/api/v4/usage/#auth';
|
|
9
9
|
this.properties = [
|
|
10
10
|
{
|
|
11
|
-
displayName: '
|
|
12
|
-
name: '
|
|
11
|
+
displayName: 'URL',
|
|
12
|
+
name: 'url',
|
|
13
13
|
type: 'string',
|
|
14
14
|
default: '',
|
|
15
|
+
placeholder: 'https://example.org/civicrm',
|
|
15
16
|
required: true,
|
|
16
17
|
},
|
|
17
18
|
{
|
|
18
|
-
displayName: 'API
|
|
19
|
-
name: '
|
|
19
|
+
displayName: 'API Key',
|
|
20
|
+
name: 'apiKey',
|
|
20
21
|
type: 'string',
|
|
21
|
-
typeOptions: {
|
|
22
|
+
typeOptions: {
|
|
23
|
+
password: true,
|
|
24
|
+
},
|
|
22
25
|
default: '',
|
|
23
26
|
required: true,
|
|
24
27
|
},
|
|
@@ -27,14 +30,21 @@ class CiviCrmApi {
|
|
|
27
30
|
type: 'generic',
|
|
28
31
|
properties: {
|
|
29
32
|
headers: {
|
|
30
|
-
|
|
33
|
+
Authorization: 'Bearer ={{$credentials.apiKey}}',
|
|
31
34
|
},
|
|
32
35
|
},
|
|
33
36
|
};
|
|
34
37
|
this.test = {
|
|
35
38
|
request: {
|
|
36
|
-
baseURL: '={{
|
|
37
|
-
url: '',
|
|
39
|
+
baseURL: '={{$credentials.url}}',
|
|
40
|
+
url: '/civicrm/ajax/api4/Contact/get',
|
|
41
|
+
method: 'POST',
|
|
42
|
+
body: {
|
|
43
|
+
version: 4,
|
|
44
|
+
select: ['id'],
|
|
45
|
+
limit: 1,
|
|
46
|
+
},
|
|
47
|
+
ignoreHttpStatusErrors: false,
|
|
38
48
|
},
|
|
39
49
|
};
|
|
40
50
|
}
|
|
@@ -195,12 +195,12 @@ class CiviCrm {
|
|
|
195
195
|
this.methods = {
|
|
196
196
|
loadOptions: {
|
|
197
197
|
async loadOptionValues() {
|
|
198
|
-
const {
|
|
198
|
+
const { url, apiKey } = (await this.getCredentials('civiCrmApi'));
|
|
199
199
|
const res = await this.helpers.httpRequest({
|
|
200
200
|
method: 'POST',
|
|
201
|
-
url: `${
|
|
201
|
+
url: `${url.replace(/\/$/, '')}/civicrm/ajax/api4/OptionValue/get`,
|
|
202
202
|
headers: {
|
|
203
|
-
|
|
203
|
+
Authorization: `Bearer ${apiKey}`,
|
|
204
204
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
205
205
|
},
|
|
206
206
|
body: { params: JSON.stringify({ limit: 50, select: ['id', 'label'] }) },
|
|
@@ -9,13 +9,13 @@ const n8n_workflow_1 = require("n8n-workflow");
|
|
|
9
9
|
*/
|
|
10
10
|
async function civicrmApiRequest(method, path, body) {
|
|
11
11
|
var _a;
|
|
12
|
-
const
|
|
12
|
+
const credentials = await this.getCredentials('civiCrmApi');
|
|
13
|
+
const baseUrl = credentials.url.replace(/\/$/, '');
|
|
13
14
|
const options = {
|
|
14
15
|
method,
|
|
15
|
-
url: `${baseUrl
|
|
16
|
+
url: `${baseUrl}${path}`,
|
|
16
17
|
headers: {
|
|
17
18
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
18
|
-
'X-Civi-Auth': `Bearer ${apiToken}`,
|
|
19
19
|
},
|
|
20
20
|
// cuerpo plano como espera Civi-Go
|
|
21
21
|
body: {
|
|
@@ -24,7 +24,7 @@ async function civicrmApiRequest(method, path, body) {
|
|
|
24
24
|
json: true,
|
|
25
25
|
};
|
|
26
26
|
try {
|
|
27
|
-
const response = await this.helpers.
|
|
27
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, 'civiCrmApi', options);
|
|
28
28
|
return response;
|
|
29
29
|
}
|
|
30
30
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ixiam/n8n-nodes-civicrm",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.28",
|
|
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": [
|
|
@@ -33,6 +33,8 @@
|
|
|
33
33
|
"node": ">=18"
|
|
34
34
|
},
|
|
35
35
|
"n8n": {
|
|
36
|
+
"n8nNodesApiVersion": 1,
|
|
37
|
+
"strict": true,
|
|
36
38
|
"nodes": [
|
|
37
39
|
"dist/nodes/CiviCrm/CiviCrm.node.js"
|
|
38
40
|
],
|
|
@@ -41,23 +43,19 @@
|
|
|
41
43
|
]
|
|
42
44
|
},
|
|
43
45
|
"devDependencies": {
|
|
44
|
-
"@n8n/node-cli": "0.
|
|
46
|
+
"@n8n/node-cli": "^0.17.0",
|
|
45
47
|
"@types/node": "^20.11.30",
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"
|
|
53
|
-
},
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"change-case": "4.1.2"
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
"packageManager": "pnpm@10.18.2+sha512.9fb969fa749b3ade6035e0f109f0b8a60b5d08a1a87fdf72e337da90dcc93336e2280ca4e44f2358a649b83c17959e9993e777c2080879f3801e6f0d999ad3dd"
|
|
48
|
+
"eslint": "9.32.0",
|
|
49
|
+
"prettier": "3.6.2",
|
|
50
|
+
"release-it": "^19.0.6",
|
|
51
|
+
"typescript": "5.9.2"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"n8n-workflow": "*"
|
|
55
|
+
},
|
|
56
|
+
"overrides": {
|
|
57
|
+
"eslint": "9.32.0",
|
|
58
|
+
"change-case": "4.1.2"
|
|
59
|
+
},
|
|
60
|
+
"packageManager": "pnpm@10.24.0+sha512.01ff8ae71b4419903b65c60fb2dc9d34cf8bb6e06d03bde112ef38f7a34d6904c424ba66bea5cdcf12890230bf39f9580473140ed9c946fef328b6e5238a345a"
|
|
63
61
|
}
|
|
@@ -8,21 +8,24 @@ export class CiviCrmApi implements ICredentialType {
|
|
|
8
8
|
|
|
9
9
|
name = 'civiCrmApi';
|
|
10
10
|
displayName = 'CiviCRM API';
|
|
11
|
-
documentationUrl = 'https://docs.civicrm.org/dev/en/latest/api/';
|
|
11
|
+
documentationUrl = 'https://docs.civicrm.org/dev/en/latest/api/v4/usage/#auth';
|
|
12
12
|
|
|
13
13
|
properties: INodeProperties[] = [
|
|
14
14
|
{
|
|
15
|
-
displayName: '
|
|
16
|
-
name: '
|
|
15
|
+
displayName: 'URL',
|
|
16
|
+
name: 'url',
|
|
17
17
|
type: 'string',
|
|
18
18
|
default: '',
|
|
19
|
+
placeholder: 'https://example.org/civicrm',
|
|
19
20
|
required: true,
|
|
20
21
|
},
|
|
21
22
|
{
|
|
22
|
-
displayName: 'API
|
|
23
|
-
name: '
|
|
23
|
+
displayName: 'API Key',
|
|
24
|
+
name: 'apiKey',
|
|
24
25
|
type: 'string',
|
|
25
|
-
typeOptions: {
|
|
26
|
+
typeOptions: {
|
|
27
|
+
password: true,
|
|
28
|
+
},
|
|
26
29
|
default: '',
|
|
27
30
|
required: true,
|
|
28
31
|
},
|
|
@@ -32,15 +35,22 @@ export class CiviCrmApi implements ICredentialType {
|
|
|
32
35
|
type: 'generic' as const,
|
|
33
36
|
properties: {
|
|
34
37
|
headers: {
|
|
35
|
-
|
|
38
|
+
Authorization: 'Bearer ={{$credentials.apiKey}}',
|
|
36
39
|
},
|
|
37
40
|
},
|
|
38
41
|
};
|
|
39
42
|
|
|
40
43
|
test: ICredentialTestRequest = {
|
|
41
44
|
request: {
|
|
42
|
-
baseURL: '={{
|
|
43
|
-
url: '',
|
|
45
|
+
baseURL: '={{$credentials.url}}',
|
|
46
|
+
url: '/civicrm/ajax/api4/Contact/get',
|
|
47
|
+
method: 'POST',
|
|
48
|
+
body: {
|
|
49
|
+
version: 4,
|
|
50
|
+
select: ['id'],
|
|
51
|
+
limit: 1,
|
|
52
|
+
},
|
|
53
|
+
ignoreHttpStatusErrors: false,
|
|
44
54
|
},
|
|
45
55
|
};
|
|
46
56
|
}
|
|
@@ -236,16 +236,16 @@ export class CiviCrm implements INodeType {
|
|
|
236
236
|
methods = {
|
|
237
237
|
loadOptions: {
|
|
238
238
|
async loadOptionValues(this: ILoadOptionsFunctions) {
|
|
239
|
-
const {
|
|
240
|
-
|
|
241
|
-
|
|
239
|
+
const { url, apiKey } = (await this.getCredentials('civiCrmApi')) as {
|
|
240
|
+
url: string;
|
|
241
|
+
apiKey: string;
|
|
242
242
|
};
|
|
243
243
|
|
|
244
244
|
const res = await this.helpers.httpRequest({
|
|
245
245
|
method: 'POST',
|
|
246
|
-
url: `${
|
|
246
|
+
url: `${url.replace(/\/$/, '')}/civicrm/ajax/api4/OptionValue/get`,
|
|
247
247
|
headers: {
|
|
248
|
-
|
|
248
|
+
Authorization: `Bearer ${apiKey}`,
|
|
249
249
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
250
250
|
},
|
|
251
251
|
body: { params: JSON.stringify({ limit: 50, select: ['id', 'label'] }) },
|
|
@@ -11,17 +11,14 @@ export async function civicrmApiRequest(
|
|
|
11
11
|
path: string,
|
|
12
12
|
body: Record<string, unknown>,
|
|
13
13
|
) {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
apiToken: string;
|
|
17
|
-
};
|
|
14
|
+
const credentials = await this.getCredentials('civiCrmApi');
|
|
15
|
+
const baseUrl = (credentials.url as string).replace(/\/$/, '');
|
|
18
16
|
|
|
19
17
|
const options: IHttpRequestOptions = {
|
|
20
18
|
method,
|
|
21
|
-
url: `${baseUrl
|
|
19
|
+
url: `${baseUrl}${path}`,
|
|
22
20
|
headers: {
|
|
23
21
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
24
|
-
'X-Civi-Auth': `Bearer ${apiToken}`,
|
|
25
22
|
},
|
|
26
23
|
// cuerpo plano como espera Civi-Go
|
|
27
24
|
body: {
|
|
@@ -31,7 +28,11 @@ export async function civicrmApiRequest(
|
|
|
31
28
|
};
|
|
32
29
|
|
|
33
30
|
try {
|
|
34
|
-
const response = await this.helpers.
|
|
31
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(
|
|
32
|
+
this,
|
|
33
|
+
'civiCrmApi',
|
|
34
|
+
options,
|
|
35
|
+
);
|
|
35
36
|
return response;
|
|
36
37
|
} catch (error: unknown) {
|
|
37
38
|
throw new NodeApiError(this.getNode(), error as JsonObject);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright 2022 n8n
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
5
|
+
the Software without restriction, including without limitation the rights to
|
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
8
|
+
so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# n8n-nodes-civigo
|
|
2
|
+
|
|
3
|
+
This is an n8n community node. It lets you use CiviCRM in your n8n workflows.
|
|
4
|
+
|
|
5
|
+
[n8n](https://n8n.io/) is a fair-code licensed workflow automation platform.
|
|
6
|
+
|
|
7
|
+
[Installation](#installation)
|
|
8
|
+
[Operations](#operations)
|
|
9
|
+
[Credentials](#credentials)
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
Follow the [installation guide](https://docs.n8n.io/integrations/creating-nodes/test/run-node-locally/) in the n8n documentation.
|
|
14
|
+
|
|
15
|
+
## Operations
|
|
16
|
+
|
|
17
|
+
### Contact
|
|
18
|
+
* Create
|
|
19
|
+
* Get
|
|
20
|
+
* Get Many
|
|
21
|
+
* Update
|
|
22
|
+
|
|
23
|
+
### Generic
|
|
24
|
+
* Perform any CiviCRM API v4 action by specifying Entity, Action and Parameters.
|
|
25
|
+
|
|
26
|
+
## Credentials
|
|
27
|
+
|
|
28
|
+
### CiviCRM API
|
|
29
|
+
* **URL**: The base URL of your CiviCRM instance (e.g. `https://example.org`).
|
|
30
|
+
* **Site Key**: Defined in `civicrm.settings.php`.
|
|
31
|
+
* **API Key**: The API key of the user.
|
|
32
|
+
|
|
33
|
+
## Compatibility
|
|
34
|
+
tested with n8n v0.200+ and CiviCRM 5.x.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "n8n-nodes-civigo",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "n8n node for CiviCRM (Civigo)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"n8n-community-node-package"
|
|
9
|
+
],
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "ixiam global solutions",
|
|
12
|
+
"email": "j.reartes@ixiam.com"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/soyjulen/n8n-nodes-civigo.git"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "n8n-node build",
|
|
20
|
+
"build:watch": "tsc --watch",
|
|
21
|
+
"dev": "n8n-node dev",
|
|
22
|
+
"lint": "n8n-node lint",
|
|
23
|
+
"lint:fix": "n8n-node lint --fix",
|
|
24
|
+
"release": "n8n-node release",
|
|
25
|
+
"prepublishOnly": "n8n-node prerelease"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"n8n": {
|
|
31
|
+
"n8nNodesApiVersion": 1,
|
|
32
|
+
"strict": true,
|
|
33
|
+
"credentials": [
|
|
34
|
+
"dist/credentials/CiviCrmApi.credentials.js"
|
|
35
|
+
],
|
|
36
|
+
"nodes": [
|
|
37
|
+
"dist/nodes/CiviCrm/CiviCrm.node.js"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@n8n/node-cli": "^0.17.0",
|
|
42
|
+
"@types/node": "^25.0.3",
|
|
43
|
+
"@types/request": "^2.48.13",
|
|
44
|
+
"eslint": "9.32.0",
|
|
45
|
+
"prettier": "3.6.2",
|
|
46
|
+
"release-it": "^19.0.4",
|
|
47
|
+
"typescript": "5.9.2"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"n8n-workflow": "*"
|
|
51
|
+
},
|
|
52
|
+
"overrides": {
|
|
53
|
+
"change-case": "4.1.2",
|
|
54
|
+
"ora": "5.4.1",
|
|
55
|
+
"string-width": "4.2.3",
|
|
56
|
+
"wrap-ansi": "7.0.0",
|
|
57
|
+
"strip-ansi": "6.0.1"
|
|
58
|
+
}
|
|
59
|
+
}
|
package/.eslintignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
dist/
|
package/.eslintrc.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
parser: '@typescript-eslint/parser',
|
|
3
|
-
plugins: ['@typescript-eslint'],
|
|
4
|
-
extends: [
|
|
5
|
-
'eslint:recommended',
|
|
6
|
-
'plugin:@typescript-eslint/recommended',
|
|
7
|
-
],
|
|
8
|
-
rules: {
|
|
9
|
-
'@typescript-eslint/no-unused-vars': 'off',
|
|
10
|
-
'@typescript-eslint/no-explicit-any': 'off',
|
|
11
|
-
},
|
|
12
|
-
};
|