n8n-nodes-innotes 1.0.0
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/README.md +305 -0
- package/dist/credentials/InNotesApi.credentials.js +108 -0
- package/dist/credentials/InNotesApi.credentials.js.map +1 -0
- package/dist/credentials/InNotesApi.credentials.ts +111 -0
- package/dist/credentials/Logo_128.png +0 -0
- package/dist/descriptions/ContactDescription.js +291 -0
- package/dist/descriptions/ContactDescription.js.map +1 -0
- package/dist/descriptions/JobDescription.js +413 -0
- package/dist/descriptions/JobDescription.js.map +1 -0
- package/dist/descriptions/NoteDescription.js +130 -0
- package/dist/descriptions/NoteDescription.js.map +1 -0
- package/dist/descriptions/StatusDescription.js +78 -0
- package/dist/descriptions/StatusDescription.js.map +1 -0
- package/dist/descriptions/TagDescription.js +34 -0
- package/dist/descriptions/TagDescription.js.map +1 -0
- package/dist/descriptions/UserDescription.js +40 -0
- package/dist/descriptions/UserDescription.js.map +1 -0
- package/dist/icons/Logo_128.png +0 -0
- package/dist/nodes/InNotes/InNotes.node.js +679 -0
- package/dist/nodes/InNotes/InNotes.node.js.map +1 -0
- package/dist/nodes/InNotes/Logo_128.png +0 -0
- package/dist/package.json +70 -0
- package/dist/test/InNotes.node.test.js +144 -0
- package/dist/test/InNotes.node.test.js.map +1 -0
- package/dist/test/setup.js +38 -0
- package/dist/test/setup.js.map +1 -0
- package/dist/types/InNotesTypes.js +8 -0
- package/dist/types/InNotesTypes.js.map +1 -0
- package/dist/utils/helpers.js +172 -0
- package/dist/utils/helpers.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,679 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @author Marco Visin
|
|
4
|
+
* @date 2025-06-02
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.InNotes = void 0;
|
|
8
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
9
|
+
const ContactDescription_1 = require("../../descriptions/ContactDescription");
|
|
10
|
+
const NoteDescription_1 = require("../../descriptions/NoteDescription");
|
|
11
|
+
const JobDescription_1 = require("../../descriptions/JobDescription");
|
|
12
|
+
const StatusDescription_1 = require("../../descriptions/StatusDescription");
|
|
13
|
+
const TagDescription_1 = require("../../descriptions/TagDescription");
|
|
14
|
+
const UserDescription_1 = require("../../descriptions/UserDescription");
|
|
15
|
+
class InNotes {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.description = {
|
|
18
|
+
displayName: 'InNotes',
|
|
19
|
+
name: 'inNotes',
|
|
20
|
+
icon: 'file:Logo_128.png',
|
|
21
|
+
group: ['output'],
|
|
22
|
+
version: 1,
|
|
23
|
+
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
24
|
+
description: 'Consume InNotes CRM API',
|
|
25
|
+
defaults: {
|
|
26
|
+
name: 'InNotes',
|
|
27
|
+
},
|
|
28
|
+
inputs: ["main" /* NodeConnectionType.Main */],
|
|
29
|
+
outputs: ["main" /* NodeConnectionType.Main */],
|
|
30
|
+
credentials: [
|
|
31
|
+
{
|
|
32
|
+
name: 'inNotesApi',
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
properties: [
|
|
37
|
+
{
|
|
38
|
+
displayName: 'Resource',
|
|
39
|
+
name: 'resource',
|
|
40
|
+
type: 'options',
|
|
41
|
+
noDataExpression: true,
|
|
42
|
+
options: [
|
|
43
|
+
{
|
|
44
|
+
name: 'Contact',
|
|
45
|
+
value: 'contact',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'Note',
|
|
49
|
+
value: 'note',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'Job',
|
|
53
|
+
value: 'job',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'Status',
|
|
57
|
+
value: 'status',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: 'Tag',
|
|
61
|
+
value: 'tag',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'User',
|
|
65
|
+
value: 'user',
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
default: 'contact',
|
|
69
|
+
},
|
|
70
|
+
...ContactDescription_1.contactOperations,
|
|
71
|
+
...NoteDescription_1.noteOperations,
|
|
72
|
+
...JobDescription_1.jobOperations,
|
|
73
|
+
...StatusDescription_1.statusOperations,
|
|
74
|
+
...TagDescription_1.tagOperations,
|
|
75
|
+
...UserDescription_1.userOperations,
|
|
76
|
+
...ContactDescription_1.contactFields,
|
|
77
|
+
...NoteDescription_1.noteFields,
|
|
78
|
+
...JobDescription_1.jobFields,
|
|
79
|
+
...StatusDescription_1.statusFields,
|
|
80
|
+
...TagDescription_1.tagFields,
|
|
81
|
+
...UserDescription_1.userFields,
|
|
82
|
+
],
|
|
83
|
+
};
|
|
84
|
+
this.methods = {
|
|
85
|
+
loadOptions: {
|
|
86
|
+
async jobStatuses() {
|
|
87
|
+
try {
|
|
88
|
+
const credentials = await this.getCredentials('inNotesApi');
|
|
89
|
+
const baseUrl = credentials.baseUrl;
|
|
90
|
+
const response = await this.helpers.httpRequestWithAuthentication.call(this, 'inNotesApi', {
|
|
91
|
+
method: 'GET',
|
|
92
|
+
url: `${baseUrl}/api/statuses`,
|
|
93
|
+
qs: { type: 'job' },
|
|
94
|
+
headers: {
|
|
95
|
+
Accept: 'application/json',
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
const statuses = Array.isArray(response) ? response : [response];
|
|
99
|
+
return statuses.map((status) => ({
|
|
100
|
+
name: status.name,
|
|
101
|
+
value: status.name,
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), {
|
|
106
|
+
message: `Failed to load job statuses: ${error.message}`,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
async execute() {
|
|
114
|
+
const items = this.getInputData();
|
|
115
|
+
const returnData = [];
|
|
116
|
+
const resource = this.getNodeParameter('resource', 0);
|
|
117
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
118
|
+
// Create a node instance to access the methods
|
|
119
|
+
const nodeInstance = new InNotes();
|
|
120
|
+
for (let i = 0; i < items.length; i++) {
|
|
121
|
+
try {
|
|
122
|
+
let responseData = {};
|
|
123
|
+
if (resource === 'contact') {
|
|
124
|
+
responseData = await nodeInstance.executeContactOperation(this, i, operation);
|
|
125
|
+
}
|
|
126
|
+
else if (resource === 'note') {
|
|
127
|
+
responseData = await nodeInstance.executeNoteOperation(this, i, operation);
|
|
128
|
+
}
|
|
129
|
+
else if (resource === 'job') {
|
|
130
|
+
responseData = await nodeInstance.executeJobOperation(this, i, operation);
|
|
131
|
+
}
|
|
132
|
+
else if (resource === 'status') {
|
|
133
|
+
responseData = await nodeInstance.executeStatusOperation(this, i, operation);
|
|
134
|
+
}
|
|
135
|
+
else if (resource === 'tag') {
|
|
136
|
+
responseData = await nodeInstance.executeTagOperation(this, i, operation);
|
|
137
|
+
}
|
|
138
|
+
else if (resource === 'user') {
|
|
139
|
+
responseData = await nodeInstance.executeUserOperation(this, i, operation);
|
|
140
|
+
}
|
|
141
|
+
if (Array.isArray(responseData)) {
|
|
142
|
+
returnData.push(...responseData);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
returnData.push(responseData);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
if (this.continueOnFail()) {
|
|
150
|
+
returnData.push({ error: error.message });
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
throw error;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return [this.helpers.returnJsonArray(returnData)];
|
|
157
|
+
}
|
|
158
|
+
async executeContactOperation(executeFunctions, itemIndex, operation) {
|
|
159
|
+
const credentials = await executeFunctions.getCredentials('inNotesApi');
|
|
160
|
+
const baseUrl = credentials.baseUrl;
|
|
161
|
+
if (operation === 'create') {
|
|
162
|
+
const name = executeFunctions.getNodeParameter('name', itemIndex);
|
|
163
|
+
const linkedin_key = executeFunctions.getNodeParameter('linkedin_key', itemIndex);
|
|
164
|
+
const linkedin_user = executeFunctions.getNodeParameter('linkedin_user', itemIndex, '');
|
|
165
|
+
const location = executeFunctions.getNodeParameter('location', itemIndex, '');
|
|
166
|
+
const current_company = executeFunctions.getNodeParameter('current_company', itemIndex, '');
|
|
167
|
+
const picture_url = executeFunctions.getNodeParameter('picture_url', itemIndex, '');
|
|
168
|
+
const tags = executeFunctions.getNodeParameter('tags', itemIndex, '');
|
|
169
|
+
const status_id = executeFunctions.getNodeParameter('status_id', itemIndex, '');
|
|
170
|
+
const body = {
|
|
171
|
+
name,
|
|
172
|
+
linkedin_key,
|
|
173
|
+
...(linkedin_user && { linkedin_user }),
|
|
174
|
+
...(location && { location }),
|
|
175
|
+
...(current_company && { current_company }),
|
|
176
|
+
...(picture_url && { picture_url }),
|
|
177
|
+
...(tags && { tags: tags.split(',').map((tag) => tag.trim()) }),
|
|
178
|
+
...(status_id && { status_id }),
|
|
179
|
+
};
|
|
180
|
+
const response = await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
181
|
+
method: 'POST',
|
|
182
|
+
url: `${baseUrl}/api/contacts`,
|
|
183
|
+
body,
|
|
184
|
+
headers: {
|
|
185
|
+
Accept: 'application/json',
|
|
186
|
+
'Content-Type': 'application/json',
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
return response;
|
|
190
|
+
}
|
|
191
|
+
if (operation === 'get') {
|
|
192
|
+
const contactId = executeFunctions.getNodeParameter('contactId', itemIndex);
|
|
193
|
+
const response = await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
194
|
+
method: 'GET',
|
|
195
|
+
url: `${baseUrl}/api/contacts/${contactId}`,
|
|
196
|
+
headers: {
|
|
197
|
+
Accept: 'application/json',
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
return response;
|
|
201
|
+
}
|
|
202
|
+
if (operation === 'getAll') {
|
|
203
|
+
const returnAll = executeFunctions.getNodeParameter('returnAll', itemIndex, false);
|
|
204
|
+
const search = executeFunctions.getNodeParameter('search', itemIndex, '');
|
|
205
|
+
const tags = executeFunctions.getNodeParameter('tags', itemIndex, '');
|
|
206
|
+
const qs = {};
|
|
207
|
+
if (search)
|
|
208
|
+
qs.search = search;
|
|
209
|
+
if (tags)
|
|
210
|
+
qs.tags = tags;
|
|
211
|
+
if (!returnAll) {
|
|
212
|
+
const limit = executeFunctions.getNodeParameter('limit', itemIndex, 24);
|
|
213
|
+
qs.pageSize = limit;
|
|
214
|
+
qs.page = 1;
|
|
215
|
+
}
|
|
216
|
+
const response = await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
217
|
+
method: 'GET',
|
|
218
|
+
url: `${baseUrl}/api/contacts`,
|
|
219
|
+
qs,
|
|
220
|
+
headers: {
|
|
221
|
+
Accept: 'application/json',
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
return Array.isArray(response) ? response : [response];
|
|
225
|
+
}
|
|
226
|
+
if (operation === 'update') {
|
|
227
|
+
const contactId = executeFunctions.getNodeParameter('contactId', itemIndex);
|
|
228
|
+
const updateFields = executeFunctions.getNodeParameter('updateFields', itemIndex);
|
|
229
|
+
const response = await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
230
|
+
method: 'PUT',
|
|
231
|
+
url: `${baseUrl}/api/contacts/${contactId}`,
|
|
232
|
+
body: updateFields,
|
|
233
|
+
headers: {
|
|
234
|
+
Accept: 'application/json',
|
|
235
|
+
'Content-Type': 'application/json',
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
return response;
|
|
239
|
+
}
|
|
240
|
+
if (operation === 'delete') {
|
|
241
|
+
const contactId = executeFunctions.getNodeParameter('contactId', itemIndex);
|
|
242
|
+
await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
243
|
+
method: 'DELETE',
|
|
244
|
+
url: `${baseUrl}/api/contacts/${contactId}`,
|
|
245
|
+
headers: {
|
|
246
|
+
Accept: 'application/json',
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
return { success: true };
|
|
250
|
+
}
|
|
251
|
+
throw new n8n_workflow_1.NodeApiError(executeFunctions.getNode(), {
|
|
252
|
+
message: `The operation "${operation}" is not supported for resource "contact"!`,
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
async executeNoteOperation(executeFunctions, itemIndex, operation) {
|
|
256
|
+
const credentials = await executeFunctions.getCredentials('inNotesApi');
|
|
257
|
+
const baseUrl = credentials.baseUrl;
|
|
258
|
+
if (operation === 'create') {
|
|
259
|
+
const content = executeFunctions.getNodeParameter('content', itemIndex);
|
|
260
|
+
const contactId = executeFunctions.getNodeParameter('contactId', itemIndex);
|
|
261
|
+
const visibility = executeFunctions.getNodeParameter('visibility', itemIndex, '');
|
|
262
|
+
const ext_table_name = executeFunctions.getNodeParameter('ext_table_name', itemIndex, '');
|
|
263
|
+
const body = {
|
|
264
|
+
content,
|
|
265
|
+
contact_id: contactId,
|
|
266
|
+
...(visibility && { visibility }),
|
|
267
|
+
...(ext_table_name && { ext_table_name }),
|
|
268
|
+
};
|
|
269
|
+
const response = await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
270
|
+
method: 'POST',
|
|
271
|
+
url: `${baseUrl}/api/note`,
|
|
272
|
+
body,
|
|
273
|
+
headers: {
|
|
274
|
+
Accept: 'application/json',
|
|
275
|
+
'Content-Type': 'application/json',
|
|
276
|
+
},
|
|
277
|
+
});
|
|
278
|
+
return response;
|
|
279
|
+
}
|
|
280
|
+
if (operation === 'get') {
|
|
281
|
+
const noteId = executeFunctions.getNodeParameter('noteId', itemIndex);
|
|
282
|
+
const response = await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
283
|
+
method: 'GET',
|
|
284
|
+
url: `${baseUrl}/api/note/${noteId}`,
|
|
285
|
+
headers: {
|
|
286
|
+
Accept: 'application/json',
|
|
287
|
+
},
|
|
288
|
+
});
|
|
289
|
+
return response;
|
|
290
|
+
}
|
|
291
|
+
if (operation === 'getAll') {
|
|
292
|
+
const contactId = executeFunctions.getNodeParameter('contactId', itemIndex);
|
|
293
|
+
const returnAll = executeFunctions.getNodeParameter('returnAll', itemIndex, false);
|
|
294
|
+
const qs = {
|
|
295
|
+
contact_id: contactId,
|
|
296
|
+
};
|
|
297
|
+
if (!returnAll) {
|
|
298
|
+
const limit = executeFunctions.getNodeParameter('limit', itemIndex, 24);
|
|
299
|
+
qs.pageSize = limit;
|
|
300
|
+
qs.page = 1;
|
|
301
|
+
}
|
|
302
|
+
const response = await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
303
|
+
method: 'GET',
|
|
304
|
+
url: `${baseUrl}/api/note`,
|
|
305
|
+
qs,
|
|
306
|
+
headers: {
|
|
307
|
+
Accept: 'application/json',
|
|
308
|
+
},
|
|
309
|
+
});
|
|
310
|
+
return Array.isArray(response) ? response : [response];
|
|
311
|
+
}
|
|
312
|
+
if (operation === 'update') {
|
|
313
|
+
const noteId = executeFunctions.getNodeParameter('noteId', itemIndex);
|
|
314
|
+
const updateFields = executeFunctions.getNodeParameter('updateFields', itemIndex);
|
|
315
|
+
const response = await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
316
|
+
method: 'PUT',
|
|
317
|
+
url: `${baseUrl}/api/note/${noteId}`,
|
|
318
|
+
body: updateFields,
|
|
319
|
+
headers: {
|
|
320
|
+
Accept: 'application/json',
|
|
321
|
+
'Content-Type': 'application/json',
|
|
322
|
+
},
|
|
323
|
+
});
|
|
324
|
+
return response;
|
|
325
|
+
}
|
|
326
|
+
if (operation === 'delete') {
|
|
327
|
+
const noteId = executeFunctions.getNodeParameter('noteId', itemIndex);
|
|
328
|
+
await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
329
|
+
method: 'DELETE',
|
|
330
|
+
url: `${baseUrl}/api/note/${noteId}`,
|
|
331
|
+
headers: {
|
|
332
|
+
Accept: 'application/json',
|
|
333
|
+
},
|
|
334
|
+
});
|
|
335
|
+
return { success: true };
|
|
336
|
+
}
|
|
337
|
+
throw new n8n_workflow_1.NodeApiError(executeFunctions.getNode(), {
|
|
338
|
+
message: `The operation "${operation}" is not supported for resource "note"!`,
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
async executeJobOperation(executeFunctions, itemIndex, operation) {
|
|
342
|
+
const credentials = await executeFunctions.getCredentials('inNotesApi');
|
|
343
|
+
const baseUrl = credentials.baseUrl;
|
|
344
|
+
if (operation === 'create') {
|
|
345
|
+
const title = executeFunctions.getNodeParameter('title', itemIndex);
|
|
346
|
+
const contactId = executeFunctions.getNodeParameter('contactId', itemIndex);
|
|
347
|
+
const company = executeFunctions.getNodeParameter('company', itemIndex);
|
|
348
|
+
const status = executeFunctions.getNodeParameter('status', itemIndex, '');
|
|
349
|
+
const description = executeFunctions.getNodeParameter('description', itemIndex, '');
|
|
350
|
+
const location = executeFunctions.getNodeParameter('location', itemIndex, '');
|
|
351
|
+
const remote_setting = executeFunctions.getNodeParameter('remote_setting', itemIndex, '');
|
|
352
|
+
const company_url = executeFunctions.getNodeParameter('company_url', itemIndex, '');
|
|
353
|
+
const ext_id = executeFunctions.getNodeParameter('ext_id', itemIndex, '');
|
|
354
|
+
const picture_url = executeFunctions.getNodeParameter('picture_url', itemIndex, '');
|
|
355
|
+
const tags = executeFunctions.getNodeParameter('tags', itemIndex, '');
|
|
356
|
+
let status_id;
|
|
357
|
+
// If status is provided, lookup the status ID
|
|
358
|
+
if (status) {
|
|
359
|
+
try {
|
|
360
|
+
// Get all job statuses
|
|
361
|
+
const statusResponse = await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
362
|
+
method: 'GET',
|
|
363
|
+
url: `${baseUrl}/api/statuses`,
|
|
364
|
+
qs: { type: 'job' },
|
|
365
|
+
headers: {
|
|
366
|
+
Accept: 'application/json',
|
|
367
|
+
},
|
|
368
|
+
});
|
|
369
|
+
// Find matching status by name (case-insensitive)
|
|
370
|
+
const statuses = Array.isArray(statusResponse) ? statusResponse : [statusResponse];
|
|
371
|
+
const matchingStatus = statuses.find((s) => s.name && s.name.toLowerCase() === status.toLowerCase());
|
|
372
|
+
if (matchingStatus) {
|
|
373
|
+
status_id = matchingStatus.id.toString();
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
throw new n8n_workflow_1.NodeApiError(executeFunctions.getNode(), {
|
|
377
|
+
message: `Status "${status}" not found. Available statuses: ${statuses.map((s) => s.name).join(', ')}`,
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
catch (error) {
|
|
382
|
+
if (error instanceof n8n_workflow_1.NodeApiError) {
|
|
383
|
+
throw error;
|
|
384
|
+
}
|
|
385
|
+
throw new n8n_workflow_1.NodeApiError(executeFunctions.getNode(), {
|
|
386
|
+
message: `Failed to lookup status "${status}": ${error.message}`,
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
const body = {
|
|
391
|
+
title,
|
|
392
|
+
contact_id: contactId,
|
|
393
|
+
company,
|
|
394
|
+
status,
|
|
395
|
+
...(description && { description }),
|
|
396
|
+
...(location && { location }),
|
|
397
|
+
...(remote_setting && { remote_setting }),
|
|
398
|
+
...(company_url && { company_url }),
|
|
399
|
+
...(status_id && { status_id }),
|
|
400
|
+
...(ext_id && { ext_id }),
|
|
401
|
+
...(picture_url && { picture_url }),
|
|
402
|
+
...(tags && { tags: tags.split(',').map((tag) => tag.trim()) }),
|
|
403
|
+
};
|
|
404
|
+
const response = await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
405
|
+
method: 'POST',
|
|
406
|
+
url: `${baseUrl}/api/job`,
|
|
407
|
+
body,
|
|
408
|
+
headers: {
|
|
409
|
+
Accept: 'application/json',
|
|
410
|
+
'Content-Type': 'application/json',
|
|
411
|
+
},
|
|
412
|
+
});
|
|
413
|
+
return response;
|
|
414
|
+
}
|
|
415
|
+
if (operation === 'get') {
|
|
416
|
+
const jobId = executeFunctions.getNodeParameter('jobId', itemIndex);
|
|
417
|
+
const response = await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
418
|
+
method: 'GET',
|
|
419
|
+
url: `${baseUrl}/api/job/${jobId}`,
|
|
420
|
+
headers: {
|
|
421
|
+
Accept: 'application/json',
|
|
422
|
+
},
|
|
423
|
+
});
|
|
424
|
+
return response;
|
|
425
|
+
}
|
|
426
|
+
if (operation === 'getAll') {
|
|
427
|
+
const returnAll = executeFunctions.getNodeParameter('returnAll', itemIndex, false);
|
|
428
|
+
const search = executeFunctions.getNodeParameter('search', itemIndex, '');
|
|
429
|
+
const tags = executeFunctions.getNodeParameter('tags', itemIndex, '');
|
|
430
|
+
const qs = {};
|
|
431
|
+
if (search)
|
|
432
|
+
qs.search = search;
|
|
433
|
+
if (tags)
|
|
434
|
+
qs.tags = tags;
|
|
435
|
+
if (!returnAll) {
|
|
436
|
+
const limit = executeFunctions.getNodeParameter('limit', itemIndex, 24);
|
|
437
|
+
qs.pageSize = limit;
|
|
438
|
+
qs.page = 1;
|
|
439
|
+
}
|
|
440
|
+
const response = await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
441
|
+
method: 'GET',
|
|
442
|
+
url: `${baseUrl}/api/job`,
|
|
443
|
+
qs,
|
|
444
|
+
headers: {
|
|
445
|
+
Accept: 'application/json',
|
|
446
|
+
},
|
|
447
|
+
});
|
|
448
|
+
return Array.isArray(response) ? response : [response];
|
|
449
|
+
}
|
|
450
|
+
if (operation === 'update') {
|
|
451
|
+
const jobId = executeFunctions.getNodeParameter('jobId', itemIndex);
|
|
452
|
+
const updateFields = executeFunctions.getNodeParameter('updateFields', itemIndex);
|
|
453
|
+
// Handle status string lookup if provided
|
|
454
|
+
if (updateFields.status && typeof updateFields.status === 'string') {
|
|
455
|
+
try {
|
|
456
|
+
// Get all job statuses
|
|
457
|
+
const statusResponse = await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
458
|
+
method: 'GET',
|
|
459
|
+
url: `${baseUrl}/api/statuses`,
|
|
460
|
+
qs: { type: 'job' },
|
|
461
|
+
headers: {
|
|
462
|
+
Accept: 'application/json',
|
|
463
|
+
},
|
|
464
|
+
});
|
|
465
|
+
// Find matching status by name (case-insensitive)
|
|
466
|
+
const statuses = Array.isArray(statusResponse) ? statusResponse : [statusResponse];
|
|
467
|
+
const matchingStatus = statuses.find((s) => s.name && s.name.toLowerCase() === updateFields.status.toLowerCase());
|
|
468
|
+
if (matchingStatus) {
|
|
469
|
+
// Replace status with status_id and remove status field
|
|
470
|
+
updateFields.status_id = matchingStatus.id.toString();
|
|
471
|
+
delete updateFields.status;
|
|
472
|
+
}
|
|
473
|
+
else {
|
|
474
|
+
throw new n8n_workflow_1.NodeApiError(executeFunctions.getNode(), {
|
|
475
|
+
message: `Status "${updateFields.status}" not found. Available statuses: ${statuses.map((s) => s.name).join(', ')}`,
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
catch (error) {
|
|
480
|
+
if (error instanceof n8n_workflow_1.NodeApiError) {
|
|
481
|
+
throw error;
|
|
482
|
+
}
|
|
483
|
+
throw new n8n_workflow_1.NodeApiError(executeFunctions.getNode(), {
|
|
484
|
+
message: `Failed to lookup status "${updateFields.status}": ${error.message}`,
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
// Process tags if provided as comma-separated string
|
|
489
|
+
if (updateFields.tags && typeof updateFields.tags === 'string') {
|
|
490
|
+
updateFields.tags = (updateFields.tags).split(',').map((tag) => tag.trim());
|
|
491
|
+
}
|
|
492
|
+
const response = await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
493
|
+
method: 'PUT',
|
|
494
|
+
url: `${baseUrl}/api/job/${jobId}`,
|
|
495
|
+
body: updateFields,
|
|
496
|
+
headers: {
|
|
497
|
+
Accept: 'application/json',
|
|
498
|
+
'Content-Type': 'application/json',
|
|
499
|
+
},
|
|
500
|
+
});
|
|
501
|
+
return response;
|
|
502
|
+
}
|
|
503
|
+
if (operation === 'delete') {
|
|
504
|
+
const jobId = executeFunctions.getNodeParameter('jobId', itemIndex);
|
|
505
|
+
await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
506
|
+
method: 'DELETE',
|
|
507
|
+
url: `${baseUrl}/api/job/${jobId}`,
|
|
508
|
+
headers: {
|
|
509
|
+
Accept: 'application/json',
|
|
510
|
+
},
|
|
511
|
+
});
|
|
512
|
+
return { success: true };
|
|
513
|
+
}
|
|
514
|
+
if (operation === 'search') {
|
|
515
|
+
const searchQuery = executeFunctions.getNodeParameter('searchQuery', itemIndex);
|
|
516
|
+
const searchOptions = executeFunctions.getNodeParameter('searchOptions', itemIndex, {});
|
|
517
|
+
const qs = {
|
|
518
|
+
search: searchQuery,
|
|
519
|
+
};
|
|
520
|
+
// Add optional search parameters
|
|
521
|
+
if (searchOptions.location)
|
|
522
|
+
qs.location = searchOptions.location;
|
|
523
|
+
if (searchOptions.company)
|
|
524
|
+
qs.company = searchOptions.company;
|
|
525
|
+
if (searchOptions.remote_setting)
|
|
526
|
+
qs.remote_setting = searchOptions.remote_setting;
|
|
527
|
+
if (searchOptions.status)
|
|
528
|
+
qs.status = searchOptions.status;
|
|
529
|
+
if (searchOptions.tags)
|
|
530
|
+
qs.tags = searchOptions.tags;
|
|
531
|
+
// Set limit with default value
|
|
532
|
+
const limit = searchOptions.limit || 24;
|
|
533
|
+
qs.pageSize = limit;
|
|
534
|
+
qs.page = 1;
|
|
535
|
+
const response = await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
536
|
+
method: 'GET',
|
|
537
|
+
url: `${baseUrl}/api/job`,
|
|
538
|
+
qs,
|
|
539
|
+
headers: {
|
|
540
|
+
Accept: 'application/json',
|
|
541
|
+
},
|
|
542
|
+
});
|
|
543
|
+
return Array.isArray(response) ? response : [response];
|
|
544
|
+
}
|
|
545
|
+
throw new n8n_workflow_1.NodeApiError(executeFunctions.getNode(), {
|
|
546
|
+
message: `The operation "${operation}" is not supported for resource "job"!`,
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
async executeStatusOperation(executeFunctions, itemIndex, operation) {
|
|
550
|
+
const credentials = await executeFunctions.getCredentials('inNotesApi');
|
|
551
|
+
const baseUrl = credentials.baseUrl;
|
|
552
|
+
if (operation === 'create') {
|
|
553
|
+
const name = executeFunctions.getNodeParameter('name', itemIndex);
|
|
554
|
+
const type = executeFunctions.getNodeParameter('type', itemIndex);
|
|
555
|
+
const color = executeFunctions.getNodeParameter('color', itemIndex, '');
|
|
556
|
+
const body = {
|
|
557
|
+
name,
|
|
558
|
+
type,
|
|
559
|
+
...(color && { color }),
|
|
560
|
+
};
|
|
561
|
+
const response = await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
562
|
+
method: 'POST',
|
|
563
|
+
url: `${baseUrl}/api/statuses`,
|
|
564
|
+
body,
|
|
565
|
+
headers: {
|
|
566
|
+
Accept: 'application/json',
|
|
567
|
+
'Content-Type': 'application/json',
|
|
568
|
+
},
|
|
569
|
+
});
|
|
570
|
+
return response;
|
|
571
|
+
}
|
|
572
|
+
if (operation === 'getAll') {
|
|
573
|
+
const type = executeFunctions.getNodeParameter('type', itemIndex, 'contact');
|
|
574
|
+
const response = await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
575
|
+
method: 'GET',
|
|
576
|
+
url: `${baseUrl}/api/statuses`,
|
|
577
|
+
qs: { type },
|
|
578
|
+
headers: {
|
|
579
|
+
Accept: 'application/json',
|
|
580
|
+
},
|
|
581
|
+
});
|
|
582
|
+
return Array.isArray(response) ? response : [response];
|
|
583
|
+
}
|
|
584
|
+
if (operation === 'update') {
|
|
585
|
+
const statusId = executeFunctions.getNodeParameter('statusId', itemIndex);
|
|
586
|
+
const updateFields = executeFunctions.getNodeParameter('updateFields', itemIndex);
|
|
587
|
+
const response = await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
588
|
+
method: 'PUT',
|
|
589
|
+
url: `${baseUrl}/api/statuses/${statusId}`,
|
|
590
|
+
body: updateFields,
|
|
591
|
+
headers: {
|
|
592
|
+
Accept: 'application/json',
|
|
593
|
+
'Content-Type': 'application/json',
|
|
594
|
+
},
|
|
595
|
+
});
|
|
596
|
+
return response;
|
|
597
|
+
}
|
|
598
|
+
if (operation === 'delete') {
|
|
599
|
+
const statusId = executeFunctions.getNodeParameter('statusId', itemIndex);
|
|
600
|
+
await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
601
|
+
method: 'DELETE',
|
|
602
|
+
url: `${baseUrl}/api/statuses/${statusId}`,
|
|
603
|
+
headers: {
|
|
604
|
+
Accept: 'application/json',
|
|
605
|
+
},
|
|
606
|
+
});
|
|
607
|
+
return { success: true };
|
|
608
|
+
}
|
|
609
|
+
throw new n8n_workflow_1.NodeApiError(executeFunctions.getNode(), {
|
|
610
|
+
message: `The operation "${operation}" is not supported for resource "status"!`,
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
async executeTagOperation(executeFunctions, _itemIndex, operation) {
|
|
614
|
+
const credentials = await executeFunctions.getCredentials('inNotesApi');
|
|
615
|
+
const baseUrl = credentials.baseUrl;
|
|
616
|
+
if (operation === 'getAll') {
|
|
617
|
+
const response = await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
618
|
+
method: 'GET',
|
|
619
|
+
url: `${baseUrl}/api/tags`,
|
|
620
|
+
headers: {
|
|
621
|
+
Accept: 'application/json',
|
|
622
|
+
},
|
|
623
|
+
});
|
|
624
|
+
return Array.isArray(response) ? response : [response];
|
|
625
|
+
}
|
|
626
|
+
throw new n8n_workflow_1.NodeApiError(executeFunctions.getNode(), {
|
|
627
|
+
message: `The operation "${operation}" is not supported for resource "tag"! Supported operations: getAll`,
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
async executeUserOperation(executeFunctions, itemIndex, operation) {
|
|
631
|
+
const credentials = await executeFunctions.getCredentials('inNotesApi');
|
|
632
|
+
const baseUrl = credentials.baseUrl;
|
|
633
|
+
if (operation === 'get') {
|
|
634
|
+
const response = await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
635
|
+
method: 'GET',
|
|
636
|
+
url: `${baseUrl}/api/user`,
|
|
637
|
+
headers: {
|
|
638
|
+
Accept: 'application/json',
|
|
639
|
+
},
|
|
640
|
+
});
|
|
641
|
+
return response;
|
|
642
|
+
}
|
|
643
|
+
if (operation === 'getCv') {
|
|
644
|
+
const response = await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
645
|
+
method: 'GET',
|
|
646
|
+
url: `${baseUrl}/api/user`,
|
|
647
|
+
headers: {
|
|
648
|
+
Accept: 'application/json',
|
|
649
|
+
},
|
|
650
|
+
});
|
|
651
|
+
// Return only CV-related fields
|
|
652
|
+
const { cv, job_preferences, cv_updated_at } = response;
|
|
653
|
+
return {
|
|
654
|
+
cv,
|
|
655
|
+
job_preferences,
|
|
656
|
+
cv_updated_at,
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
if (operation === 'update') {
|
|
660
|
+
const updateFields = executeFunctions.getNodeParameter('updateFields', itemIndex);
|
|
661
|
+
const response = await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'inNotesApi', {
|
|
662
|
+
method: 'PUT',
|
|
663
|
+
url: `${baseUrl}/api/user`,
|
|
664
|
+
body: updateFields,
|
|
665
|
+
headers: {
|
|
666
|
+
Accept: 'application/json',
|
|
667
|
+
'Content-Type': 'application/json',
|
|
668
|
+
},
|
|
669
|
+
});
|
|
670
|
+
return response;
|
|
671
|
+
}
|
|
672
|
+
throw new n8n_workflow_1.NodeApiError(executeFunctions.getNode(), {
|
|
673
|
+
message: `The operation "${operation}" is not supported for resource "user"! Supported operations: get, getCv, update`,
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
exports.InNotes = InNotes;
|
|
678
|
+
|
|
679
|
+
//# sourceMappingURL=InNotes.node.js.map
|