n8n-nodes-skodecrm 0.1.5 → 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 -100
- package/dist/nodes/SkodeCrm/SkodeCrm.node.js.map +1 -1
- package/dist/nodes/SkodeCrm/SkodeCrmTrigger.node.js +3 -17
- 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,23 +85,10 @@ class SkodeCrm {
|
|
|
54
85
|
},
|
|
55
86
|
},
|
|
56
87
|
properties: [
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
default: '',
|
|
62
|
-
description: 'Which Skode CRM workspace to act in. Required only if your account belongs to more than one organization — leave blank for single-org accounts. Find it in the CRM under Settings, or in the address bar as ?org=. Sent as the X-Skode-Org-ID header.',
|
|
63
|
-
routing: {
|
|
64
|
-
// Sent as a header, and only when filled ($value || undefined
|
|
65
|
-
// makes n8n omit it entirely for single-org accounts). Never
|
|
66
|
-
// touches the request body.
|
|
67
|
-
request: {
|
|
68
|
-
headers: {
|
|
69
|
-
'X-Skode-Org-Id': '={{ $value || undefined }}',
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
},
|
|
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.
|
|
74
92
|
{
|
|
75
93
|
displayName: 'Resource',
|
|
76
94
|
name: 'resource',
|
|
@@ -126,7 +144,7 @@ class SkodeCrm {
|
|
|
126
144
|
],
|
|
127
145
|
default: 'create',
|
|
128
146
|
},
|
|
129
|
-
// ──
|
|
147
|
+
// ── Update: which lead ─────────────────────────────────────────
|
|
130
148
|
{
|
|
131
149
|
displayName: 'Lead ID',
|
|
132
150
|
name: 'leadId',
|
|
@@ -136,92 +154,39 @@ class SkodeCrm {
|
|
|
136
154
|
displayOptions: { show: { resource: ['lead'], operation: ['update'] } },
|
|
137
155
|
description: 'Numeric ID of the lead to update',
|
|
138
156
|
},
|
|
157
|
+
// ── Create / Update fields — loaded from THIS org's Field Editor ──
|
|
139
158
|
{
|
|
140
|
-
displayName: '
|
|
141
|
-
name: '
|
|
142
|
-
type: '
|
|
143
|
-
|
|
144
|
-
default: '',
|
|
145
|
-
|
|
146
|
-
routing: { send: { type: 'body', property: 'email' } },
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
displayName: 'Additional Fields',
|
|
150
|
-
name: 'additionalFields',
|
|
151
|
-
type: 'collection',
|
|
152
|
-
placeholder: 'Add Field',
|
|
153
|
-
default: {},
|
|
159
|
+
displayName: 'Fields',
|
|
160
|
+
name: 'leadFields',
|
|
161
|
+
type: 'resourceMapper',
|
|
162
|
+
noDataExpression: true,
|
|
163
|
+
default: { mappingMode: 'defineBelow', value: null },
|
|
164
|
+
required: true,
|
|
154
165
|
displayOptions: {
|
|
155
166
|
show: { resource: ['lead'], operation: ['create', 'update'] },
|
|
156
167
|
},
|
|
157
|
-
description:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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,
|
|
165
180
|
},
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
{
|
|
174
|
-
displayName: 'Custom Fields (JSON)',
|
|
175
|
-
name: 'customFieldsJson',
|
|
176
|
-
type: 'json',
|
|
177
|
-
default: '{}',
|
|
178
|
-
description: 'Any additional field keys as a JSON object, merged into the request body',
|
|
179
|
-
routing: { send: { type: 'body', value: '={{ JSON.parse($value || "{}") }}' } },
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
displayName: 'First Name',
|
|
183
|
-
name: 'first_name',
|
|
184
|
-
type: 'string',
|
|
185
|
-
default: '',
|
|
186
|
-
routing: { send: { type: 'body', property: 'first_name' } },
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
displayName: 'Last Name',
|
|
190
|
-
name: 'last_name',
|
|
191
|
-
type: 'string',
|
|
192
|
-
default: '',
|
|
193
|
-
routing: { send: { type: 'body', property: 'last_name' } },
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
displayName: 'Phone',
|
|
197
|
-
name: 'phone',
|
|
198
|
-
type: 'string',
|
|
199
|
-
default: '',
|
|
200
|
-
routing: { send: { type: 'body', property: 'phone' } },
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
displayName: 'Project',
|
|
204
|
-
name: 'projects',
|
|
205
|
-
type: 'string',
|
|
206
|
-
default: '',
|
|
207
|
-
description: 'Project name (created if it does not exist)',
|
|
208
|
-
routing: { send: { type: 'body', property: 'projects' } },
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
displayName: 'Source',
|
|
212
|
-
name: 'lead_source',
|
|
213
|
-
type: 'string',
|
|
214
|
-
default: '',
|
|
215
|
-
routing: { send: { type: 'body', property: 'lead_source' } },
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
displayName: 'Status',
|
|
219
|
-
name: 'status',
|
|
220
|
-
type: 'string',
|
|
221
|
-
default: '',
|
|
222
|
-
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 || {} }}',
|
|
223
188
|
},
|
|
224
|
-
|
|
189
|
+
},
|
|
225
190
|
},
|
|
226
191
|
// ── Search / Get Many params ───────────────────────────────────
|
|
227
192
|
{
|
|
@@ -255,6 +220,60 @@ class SkodeCrm {
|
|
|
255
220
|
},
|
|
256
221
|
],
|
|
257
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
|
+
};
|
|
258
277
|
}
|
|
259
278
|
}
|
|
260
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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AAK,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;wBACpE,MAAM,IAAI,GAAgC,UAAU;4BACnD,CAAC,CAAC,SAAS;4BACX,CAAC,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,QAAQ,CAAC,CAAC,IAAI,QAAQ,CAAC;wBAE3D,MAAM,MAAM,GAAwB;4BACnC,EAAE,EAAE,GAAG;4BACP,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC;4BACnC,QAAQ,EAAE,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,IAAI,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,13 +42,8 @@ class SkodeCrmTrigger {
|
|
|
42
42
|
},
|
|
43
43
|
],
|
|
44
44
|
properties: [
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
name: 'organizationId',
|
|
48
|
-
type: 'string',
|
|
49
|
-
default: '',
|
|
50
|
-
description: 'Which Skode CRM workspace this trigger belongs to. Required only if your account belongs to more than one organization. Sent as X-Skode-Org-ID when registering the webhook.',
|
|
51
|
-
},
|
|
45
|
+
// No "Organization ID" field — the workspace is bound to the OAuth
|
|
46
|
+
// token at consent and resolved server-side. See SkodeCrm.node.ts.
|
|
52
47
|
{
|
|
53
48
|
displayName: 'Event',
|
|
54
49
|
name: 'event',
|
|
@@ -74,12 +69,9 @@ class SkodeCrmTrigger {
|
|
|
74
69
|
async create() {
|
|
75
70
|
const webhookUrl = this.getNodeWebhookUrl('default');
|
|
76
71
|
const event = this.getNodeParameter('event');
|
|
77
|
-
const orgId = this.getNodeParameter('organizationId', '') || '';
|
|
78
72
|
const credentials = await this.getCredentials('skodeCrmOAuth2Api');
|
|
79
73
|
const baseUrl = credentials.baseUrl.replace(/\/$/, '');
|
|
80
74
|
const headers = { 'X-Skode-Partner': 'n8n' };
|
|
81
|
-
if (orgId)
|
|
82
|
-
headers['X-Skode-Org-Id'] = orgId;
|
|
83
75
|
const response = await this.helpers.httpRequestWithAuthentication.call(this, 'skodeCrmOAuth2Api', {
|
|
84
76
|
method: 'POST',
|
|
85
77
|
url: `${baseUrl}/api/partner/v1/hooks/`,
|
|
@@ -106,13 +98,7 @@ class SkodeCrmTrigger {
|
|
|
106
98
|
await this.helpers.httpRequestWithAuthentication.call(this, 'skodeCrmOAuth2Api', {
|
|
107
99
|
method: 'DELETE',
|
|
108
100
|
url: `${baseUrl}/api/partner/v1/hooks/${webhookData.subscriptionId}/`,
|
|
109
|
-
headers:
|
|
110
|
-
const h = { 'X-Skode-Partner': 'n8n' };
|
|
111
|
-
const orgId = this.getNodeParameter('organizationId', '') || '';
|
|
112
|
-
if (orgId)
|
|
113
|
-
h['X-Skode-Org-Id'] = orgId;
|
|
114
|
-
return h;
|
|
115
|
-
})(),
|
|
101
|
+
headers: { 'X-Skode-Partner': 'n8n' },
|
|
116
102
|
json: true,
|
|
117
103
|
});
|
|
118
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SkodeCrmTrigger.node.js","sourceRoot":"","sources":["../../../nodes/SkodeCrm/SkodeCrmTrigger.node.ts"],"names":[],"mappings":";;;AAOA,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