@connectorx/n8n-nodes-cortex 0.1.9 → 0.1.11
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.
|
@@ -4,7 +4,7 @@ exports.Cortex = void 0;
|
|
|
4
4
|
class Cortex {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.description = {
|
|
7
|
-
displayName: 'Cortex v1.
|
|
7
|
+
displayName: 'Cortex v1.2',
|
|
8
8
|
name: 'cortex',
|
|
9
9
|
icon: 'file:cortex.png',
|
|
10
10
|
group: ['input'],
|
|
@@ -40,6 +40,17 @@ class Cortex {
|
|
|
40
40
|
],
|
|
41
41
|
default: 'message',
|
|
42
42
|
},
|
|
43
|
+
{
|
|
44
|
+
displayName: 'Tenant Name',
|
|
45
|
+
name: 'tenantId',
|
|
46
|
+
type: 'options',
|
|
47
|
+
typeOptions: {
|
|
48
|
+
loadOptionsMethod: 'getTenants',
|
|
49
|
+
},
|
|
50
|
+
default: '',
|
|
51
|
+
required: true,
|
|
52
|
+
description: 'The Tenant to interact with',
|
|
53
|
+
},
|
|
43
54
|
{
|
|
44
55
|
displayName: 'Operation',
|
|
45
56
|
name: 'operation',
|
|
@@ -229,6 +240,7 @@ class Cortex {
|
|
|
229
240
|
type: 'options',
|
|
230
241
|
typeOptions: {
|
|
231
242
|
loadOptionsMethod: 'getColumns',
|
|
243
|
+
loadOptionsDependsOn: ['tenantId'],
|
|
232
244
|
},
|
|
233
245
|
displayOptions: {
|
|
234
246
|
show: {
|
|
@@ -245,6 +257,7 @@ class Cortex {
|
|
|
245
257
|
type: 'options',
|
|
246
258
|
typeOptions: {
|
|
247
259
|
loadOptionsMethod: 'getUsers',
|
|
260
|
+
loadOptionsDependsOn: ['tenantId'],
|
|
248
261
|
},
|
|
249
262
|
displayOptions: {
|
|
250
263
|
show: {
|
|
@@ -278,10 +291,37 @@ class Cortex {
|
|
|
278
291
|
};
|
|
279
292
|
this.methods = {
|
|
280
293
|
loadOptions: {
|
|
294
|
+
async getTenants() {
|
|
295
|
+
const credentials = await this.getCredentials('cortexApi');
|
|
296
|
+
const baseUrl = credentials.apiBaseUrl.replace(/\/$/, '');
|
|
297
|
+
const options = {
|
|
298
|
+
headers: {
|
|
299
|
+
'Content-Type': 'application/json',
|
|
300
|
+
'Authorization': `Bearer ${credentials.accessToken}`,
|
|
301
|
+
},
|
|
302
|
+
method: 'GET',
|
|
303
|
+
uri: `${baseUrl}/user-tenants`,
|
|
304
|
+
json: true,
|
|
305
|
+
};
|
|
306
|
+
try {
|
|
307
|
+
const response = await this.helpers.request(options);
|
|
308
|
+
return response.map((t) => ({
|
|
309
|
+
name: t.name || t.tenant_id,
|
|
310
|
+
value: t.tenant_id
|
|
311
|
+
}));
|
|
312
|
+
}
|
|
313
|
+
catch (error) {
|
|
314
|
+
console.error('getTenants error:', error);
|
|
315
|
+
return [];
|
|
316
|
+
}
|
|
317
|
+
},
|
|
281
318
|
async getColumns() {
|
|
282
319
|
const credentials = await this.getCredentials('cortexApi');
|
|
283
320
|
const baseUrl = credentials.apiBaseUrl.replace(/\/$/, '');
|
|
284
|
-
const tenantId =
|
|
321
|
+
const tenantId = this.getNodeParameter('tenantId');
|
|
322
|
+
if (!tenantId) {
|
|
323
|
+
return [];
|
|
324
|
+
}
|
|
285
325
|
const options = {
|
|
286
326
|
headers: {
|
|
287
327
|
'Content-Type': 'application/json',
|
|
@@ -302,7 +342,10 @@ class Cortex {
|
|
|
302
342
|
async getUsers() {
|
|
303
343
|
const credentials = await this.getCredentials('cortexApi');
|
|
304
344
|
const baseUrl = credentials.apiBaseUrl.replace(/\/$/, '');
|
|
305
|
-
const tenantId =
|
|
345
|
+
const tenantId = this.getNodeParameter('tenantId');
|
|
346
|
+
if (!tenantId) {
|
|
347
|
+
return [];
|
|
348
|
+
}
|
|
306
349
|
const options = {
|
|
307
350
|
headers: {
|
|
308
351
|
'Content-Type': 'application/json',
|
|
@@ -314,7 +357,10 @@ class Cortex {
|
|
|
314
357
|
};
|
|
315
358
|
try {
|
|
316
359
|
const response = await this.helpers.request(options);
|
|
317
|
-
return response
|
|
360
|
+
return response.map((u) => ({
|
|
361
|
+
name: u.name || u.user_id,
|
|
362
|
+
value: u.user_id
|
|
363
|
+
}));
|
|
318
364
|
}
|
|
319
365
|
catch (error) {
|
|
320
366
|
return [];
|
|
@@ -330,9 +376,9 @@ class Cortex {
|
|
|
330
376
|
const operation = this.getNodeParameter('operation', 0);
|
|
331
377
|
const credentials = await this.getCredentials('cortexApi');
|
|
332
378
|
const baseUrl = credentials.apiBaseUrl.replace(/\/$/, '');
|
|
333
|
-
const tenantId = credentials.tenantId;
|
|
334
379
|
for (let i = 0; i < items.length; i++) {
|
|
335
380
|
try {
|
|
381
|
+
const tenantId = this.getNodeParameter('tenantId', i);
|
|
336
382
|
const conversationId = this.getNodeParameter('conversation_id', i);
|
|
337
383
|
let responseData;
|
|
338
384
|
const options = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@connectorx/n8n-nodes-cortex",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "n8n nodes for Cortex API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package"
|
|
@@ -44,4 +44,4 @@
|
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"n8n-workflow": "*"
|
|
46
46
|
}
|
|
47
|
-
}
|
|
47
|
+
}
|