n8n-nodes-skodecrm 0.1.4 → 0.1.9
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/nodes/SkodeCrm/SkodeCrm.node.d.ts +6 -17
- package/dist/nodes/SkodeCrm/SkodeCrm.node.js +119 -83
- package/dist/nodes/SkodeCrm/SkodeCrm.node.js.map +1 -1
- package/dist/nodes/SkodeCrm/SkodeCrmTrigger.node.js +4 -1
- package/dist/nodes/SkodeCrm/SkodeCrmTrigger.node.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
import type { INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
-
/**
|
|
3
|
-
* Skode CRM — declarative node.
|
|
4
|
-
*
|
|
5
|
-
* Talks to the CRM's PARTNER integration surface — deliberately NOT the Zapier
|
|
6
|
-
* one, which is owner-locked, shares Zapier's throttle bucket, and stamps every
|
|
7
|
-
* webhook it creates as 'zapier':
|
|
8
|
-
* POST /api/partner/v1/leads/
|
|
9
|
-
* PATCH /api/partner/v1/leads/<id>/
|
|
10
|
-
* GET /api/partner/v1/leads/
|
|
11
|
-
* GET /api/partner/v1/leads/search/
|
|
12
|
-
* GET /api/partner/v1/leads/fields/
|
|
13
|
-
* Connection test hits GET /api/partner/v1/me/.
|
|
14
|
-
*
|
|
15
|
-
* Declarative style = no runtime dependencies (a verification requirement):
|
|
16
|
-
* all HTTP is expressed through `routing` and n8n's built-in request helper.
|
|
17
|
-
*/
|
|
1
|
+
import type { INodeType, INodeTypeDescription, ILoadOptionsFunctions, ResourceMapperFields } from 'n8n-workflow';
|
|
18
2
|
export declare class SkodeCrm implements INodeType {
|
|
19
3
|
description: INodeTypeDescription;
|
|
4
|
+
methods: {
|
|
5
|
+
resourceMapping: {
|
|
6
|
+
getLeadFields(this: ILoadOptionsFunctions): Promise<ResourceMapperFields>;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
20
9
|
}
|
|
@@ -15,9 +15,40 @@ const n8n_workflow_1 = require("n8n-workflow");
|
|
|
15
15
|
* GET /api/partner/v1/leads/fields/
|
|
16
16
|
* Connection test hits GET /api/partner/v1/me/.
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* Fields are NOT hardcoded. Create/Update use an n8n resource mapper that loads
|
|
19
|
+
* the connected organization's real lead schema from /leads/fields/ — so each
|
|
20
|
+
* org sees its own Field Editor fields (labels, required flags, select options,
|
|
21
|
+
* custom fields), exactly as configured in the CRM. See getLeadFields() below.
|
|
20
22
|
*/
|
|
23
|
+
// The partner /leads/fields/ endpoint returns the same wire types the CRM's
|
|
24
|
+
// Zapier surface uses. Map them to n8n resource-mapper column types. Anything
|
|
25
|
+
// not listed falls through to 'string', which the CRM accepts for text values.
|
|
26
|
+
// A field that carries `choices` becomes an 'options' column regardless of type.
|
|
27
|
+
const CRM_TYPE_TO_N8N = {
|
|
28
|
+
string: 'string',
|
|
29
|
+
text: 'string',
|
|
30
|
+
number: 'number',
|
|
31
|
+
boolean: 'boolean',
|
|
32
|
+
datetime: 'dateTime',
|
|
33
|
+
date: 'dateTime',
|
|
34
|
+
// document_url etc. arrive as strings; a file URL is still just a string.
|
|
35
|
+
file: 'string',
|
|
36
|
+
};
|
|
37
|
+
/** The CRM stores select options as a JSON list of either bare strings or
|
|
38
|
+
* {value,label}/{value,name} objects. Normalise both to n8n's option shape. */
|
|
39
|
+
function normaliseOptions(options) {
|
|
40
|
+
if (!Array.isArray(options))
|
|
41
|
+
return [];
|
|
42
|
+
return options.map((o) => {
|
|
43
|
+
if (o && typeof o === 'object') {
|
|
44
|
+
const rec = o;
|
|
45
|
+
const value = String(rec.value ?? rec.name ?? rec.label ?? '');
|
|
46
|
+
const name = String(rec.label ?? rec.name ?? rec.value ?? value);
|
|
47
|
+
return { name, value };
|
|
48
|
+
}
|
|
49
|
+
return { name: String(o), value: String(o) };
|
|
50
|
+
});
|
|
51
|
+
}
|
|
21
52
|
class SkodeCrm {
|
|
22
53
|
constructor() {
|
|
23
54
|
this.description = {
|
|
@@ -54,6 +85,10 @@ class SkodeCrm {
|
|
|
54
85
|
},
|
|
55
86
|
},
|
|
56
87
|
properties: [
|
|
88
|
+
// NOTE: there is deliberately NO "Organization ID" field. The CRM
|
|
89
|
+
// binds the target workspace to the OAuth token at the consent
|
|
90
|
+
// screen (you pick the org when you click Connect), and the partner
|
|
91
|
+
// API resolves it from that binding server-side.
|
|
57
92
|
{
|
|
58
93
|
displayName: 'Resource',
|
|
59
94
|
name: 'resource',
|
|
@@ -109,7 +144,7 @@ class SkodeCrm {
|
|
|
109
144
|
],
|
|
110
145
|
default: 'create',
|
|
111
146
|
},
|
|
112
|
-
// ──
|
|
147
|
+
// ── Update: which lead ─────────────────────────────────────────
|
|
113
148
|
{
|
|
114
149
|
displayName: 'Lead ID',
|
|
115
150
|
name: 'leadId',
|
|
@@ -119,92 +154,39 @@ class SkodeCrm {
|
|
|
119
154
|
displayOptions: { show: { resource: ['lead'], operation: ['update'] } },
|
|
120
155
|
description: 'Numeric ID of the lead to update',
|
|
121
156
|
},
|
|
157
|
+
// ── Create / Update fields — loaded from THIS org's Field Editor ──
|
|
122
158
|
{
|
|
123
|
-
displayName: '
|
|
124
|
-
name: '
|
|
125
|
-
type: '
|
|
126
|
-
|
|
127
|
-
default: '',
|
|
128
|
-
|
|
129
|
-
routing: { send: { type: 'body', property: 'email' } },
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
displayName: 'Additional Fields',
|
|
133
|
-
name: 'additionalFields',
|
|
134
|
-
type: 'collection',
|
|
135
|
-
placeholder: 'Add Field',
|
|
136
|
-
default: {},
|
|
159
|
+
displayName: 'Fields',
|
|
160
|
+
name: 'leadFields',
|
|
161
|
+
type: 'resourceMapper',
|
|
162
|
+
noDataExpression: true,
|
|
163
|
+
default: { mappingMode: 'defineBelow', value: null },
|
|
164
|
+
required: true,
|
|
137
165
|
displayOptions: {
|
|
138
166
|
show: { resource: ['lead'], operation: ['create', 'update'] },
|
|
139
167
|
},
|
|
140
|
-
description:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
type: 'string',
|
|
153
|
-
default: '',
|
|
154
|
-
routing: { send: { type: 'body', property: 'contact_name' } },
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
displayName: 'Custom Fields (JSON)',
|
|
158
|
-
name: 'customFieldsJson',
|
|
159
|
-
type: 'json',
|
|
160
|
-
default: '{}',
|
|
161
|
-
description: 'Any additional field keys as a JSON object, merged into the request body',
|
|
162
|
-
routing: { send: { type: 'body', value: '={{ JSON.parse($value || "{}") }}' } },
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
displayName: 'First Name',
|
|
166
|
-
name: 'first_name',
|
|
167
|
-
type: 'string',
|
|
168
|
-
default: '',
|
|
169
|
-
routing: { send: { type: 'body', property: 'first_name' } },
|
|
168
|
+
description: "The lead's fields, loaded live from your organization's Field Editor — including custom fields",
|
|
169
|
+
typeOptions: {
|
|
170
|
+
loadOptionsDependsOn: ['resource', 'operation'],
|
|
171
|
+
resourceMapper: {
|
|
172
|
+
resourceMapperMethod: 'getLeadFields',
|
|
173
|
+
mode: 'add',
|
|
174
|
+
fieldWords: { singular: 'field', plural: 'fields' },
|
|
175
|
+
// Show ONLY required fields by default; every optional field
|
|
176
|
+
// is added on demand via the "Add field to send" picker.
|
|
177
|
+
addAllFields: false,
|
|
178
|
+
multiKeyMatch: false,
|
|
179
|
+
supportAutoMap: true,
|
|
170
180
|
},
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
{
|
|
179
|
-
displayName: 'Phone',
|
|
180
|
-
name: 'phone',
|
|
181
|
-
type: 'string',
|
|
182
|
-
default: '',
|
|
183
|
-
routing: { send: { type: 'body', property: 'phone' } },
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
displayName: 'Project',
|
|
187
|
-
name: 'projects',
|
|
188
|
-
type: 'string',
|
|
189
|
-
default: '',
|
|
190
|
-
description: 'Project name (created if it does not exist)',
|
|
191
|
-
routing: { send: { type: 'body', property: 'projects' } },
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
displayName: 'Source',
|
|
195
|
-
name: 'lead_source',
|
|
196
|
-
type: 'string',
|
|
197
|
-
default: '',
|
|
198
|
-
routing: { send: { type: 'body', property: 'lead_source' } },
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
displayName: 'Status',
|
|
202
|
-
name: 'status',
|
|
203
|
-
type: 'string',
|
|
204
|
-
default: '',
|
|
205
|
-
routing: { send: { type: 'body', property: 'status' } },
|
|
181
|
+
},
|
|
182
|
+
// The mapped {key: value} object IS the request body for both the
|
|
183
|
+
// POST (create) and PATCH (update). Empty values are omitted by
|
|
184
|
+
// the mapper, so PATCH stays a partial update.
|
|
185
|
+
routing: {
|
|
186
|
+
request: {
|
|
187
|
+
body: '={{ $value.value || {} }}',
|
|
206
188
|
},
|
|
207
|
-
|
|
189
|
+
},
|
|
208
190
|
},
|
|
209
191
|
// ── Search / Get Many params ───────────────────────────────────
|
|
210
192
|
{
|
|
@@ -238,6 +220,60 @@ class SkodeCrm {
|
|
|
238
220
|
},
|
|
239
221
|
],
|
|
240
222
|
};
|
|
223
|
+
this.methods = {
|
|
224
|
+
resourceMapping: {
|
|
225
|
+
// Loads the connected org's lead schema so the mapper shows that
|
|
226
|
+
// org's actual fields. On Update every field is optional (PATCH is
|
|
227
|
+
// partial); on Create the CRM's required flags are honoured.
|
|
228
|
+
async getLeadFields() {
|
|
229
|
+
const credentials = await this.getCredentials('skodeCrmOAuth2Api');
|
|
230
|
+
const baseUrl = String(credentials.baseUrl).replace(/\/$/, '');
|
|
231
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
232
|
+
let response;
|
|
233
|
+
try {
|
|
234
|
+
response = await this.helpers.httpRequestWithAuthentication.call(this, 'skodeCrmOAuth2Api', {
|
|
235
|
+
method: 'GET',
|
|
236
|
+
url: `${baseUrl}/api/partner/v1/leads/fields/`,
|
|
237
|
+
headers: { 'X-Skode-Partner': 'n8n' },
|
|
238
|
+
json: true,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
catch {
|
|
242
|
+
// A schema lookup failure must not brick the node — fall back
|
|
243
|
+
// to a free-form mapper so the user can still send raw keys.
|
|
244
|
+
return { fields: [] };
|
|
245
|
+
}
|
|
246
|
+
const raw = Array.isArray(response?.fields) ? response.fields : [];
|
|
247
|
+
const fields = [];
|
|
248
|
+
for (const f of raw) {
|
|
249
|
+
const key = String(f.key ?? '');
|
|
250
|
+
if (!key)
|
|
251
|
+
continue;
|
|
252
|
+
// A field with `choices` (status, priority, team member,
|
|
253
|
+
// country, select) is a dropdown; everything else maps by type.
|
|
254
|
+
const hasChoices = Array.isArray(f.choices) && f.choices.length > 0;
|
|
255
|
+
const type = hasChoices
|
|
256
|
+
? 'options'
|
|
257
|
+
: CRM_TYPE_TO_N8N[String(f.type ?? 'string')] ?? 'string';
|
|
258
|
+
const column = {
|
|
259
|
+
id: key,
|
|
260
|
+
displayName: String(f.label ?? key),
|
|
261
|
+
required: operation === 'create' ? f.required === true : false,
|
|
262
|
+
defaultMatch: false,
|
|
263
|
+
canBeUsedToMatch: false,
|
|
264
|
+
display: true,
|
|
265
|
+
type,
|
|
266
|
+
readOnly: false,
|
|
267
|
+
};
|
|
268
|
+
if (type === 'options') {
|
|
269
|
+
column.options = normaliseOptions(f.choices);
|
|
270
|
+
}
|
|
271
|
+
fields.push(column);
|
|
272
|
+
}
|
|
273
|
+
return { fields };
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
};
|
|
241
277
|
}
|
|
242
278
|
}
|
|
243
279
|
exports.SkodeCrm = SkodeCrm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SkodeCrm.node.js","sourceRoot":"","sources":["../../../nodes/SkodeCrm/SkodeCrm.node.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"SkodeCrm.node.js","sourceRoot":"","sources":["../../../nodes/SkodeCrm/SkodeCrm.node.ts"],"names":[],"mappings":";;;AAQA,+CAAmD;AAEnD;;;;;;;;;;;;;;;;;GAiBG;AAEH,4EAA4E;AAC5E,8EAA8E;AAC9E,+EAA+E;AAC/E,iFAAiF;AACjF,MAAM,eAAe,GAAgD;IACpE,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,UAAU;IAChB,0EAA0E;IAC1E,IAAI,EAAE,QAAQ;CACd,CAAC;AAEF;gFACgF;AAChF,SAAS,gBAAgB,CAAC,OAAgB;IACzC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,EAAE,CAAC;IACvC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACxB,IAAI,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;YAChC,MAAM,GAAG,GAAG,CAA4B,CAAC;YACzC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;YAC/D,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC;YACjE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QACxB,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC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CAAC,CAAC,CAAC,KAAK;4BAC9D,YAAY,EAAE,KAAK;4BACnB,gBAAgB,EAAE,KAAK;4BACvB,OAAO,EAAE,IAAI;4BACb,IAAI;4BACJ,QAAQ,EAAE,KAAK;yBACf,CAAC;wBACF,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;4BACxB,MAAM,CAAC,OAAO,GAAG,gBAAgB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;wBAC9C,CAAC;wBACD,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBACrB,CAAC;oBAED,OAAO,EAAE,MAAM,EAAE,CAAC;gBACnB,CAAC;aACD;SACD,CAAC;IACH,CAAC;CAAA;AA9OD,4BA8OC"}
|
|
@@ -42,6 +42,8 @@ class SkodeCrmTrigger {
|
|
|
42
42
|
},
|
|
43
43
|
],
|
|
44
44
|
properties: [
|
|
45
|
+
// No "Organization ID" field — the workspace is bound to the OAuth
|
|
46
|
+
// token at consent and resolved server-side. See SkodeCrm.node.ts.
|
|
45
47
|
{
|
|
46
48
|
displayName: 'Event',
|
|
47
49
|
name: 'event',
|
|
@@ -69,11 +71,12 @@ class SkodeCrmTrigger {
|
|
|
69
71
|
const event = this.getNodeParameter('event');
|
|
70
72
|
const credentials = await this.getCredentials('skodeCrmOAuth2Api');
|
|
71
73
|
const baseUrl = credentials.baseUrl.replace(/\/$/, '');
|
|
74
|
+
const headers = { 'X-Skode-Partner': 'n8n' };
|
|
72
75
|
const response = await this.helpers.httpRequestWithAuthentication.call(this, 'skodeCrmOAuth2Api', {
|
|
73
76
|
method: 'POST',
|
|
74
77
|
url: `${baseUrl}/api/partner/v1/hooks/`,
|
|
75
78
|
body: { target_url: webhookUrl, event },
|
|
76
|
-
headers
|
|
79
|
+
headers,
|
|
77
80
|
json: true,
|
|
78
81
|
});
|
|
79
82
|
const id = response?.id;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SkodeCrmTrigger.node.js","sourceRoot":"","sources":["../../../n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