@aiteza/n8n-nodes-aiteza 0.2.0 → 0.2.1
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/Aiteza/Aiteza.node.js +41 -22
- package/package.json +4 -1
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.Aiteza = void 0;
|
|
4
7
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
8
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
5
9
|
const GenericFunctions_1 = require("./GenericFunctions");
|
|
6
10
|
class Aiteza {
|
|
7
11
|
description = {
|
|
@@ -1391,6 +1395,12 @@ class Aiteza {
|
|
|
1391
1395
|
const uploadRequest = async (reqOpts) => {
|
|
1392
1396
|
if (authCtx?.triggerToken) {
|
|
1393
1397
|
reqOpts.headers = { ...(reqOpts.headers ?? {}), Authorization: `Bearer ${authCtx.triggerToken}` };
|
|
1398
|
+
}
|
|
1399
|
+
// If body is FormData, merge its headers (boundary etc.)
|
|
1400
|
+
if (reqOpts.body instanceof form_data_1.default) {
|
|
1401
|
+
reqOpts.headers = { ...(reqOpts.headers ?? {}), ...reqOpts.body.getHeaders() };
|
|
1402
|
+
}
|
|
1403
|
+
if (authCtx?.triggerToken) {
|
|
1394
1404
|
return this.helpers.httpRequest(reqOpts);
|
|
1395
1405
|
}
|
|
1396
1406
|
return this.helpers.httpRequestWithAuthentication.call(this, 'aitezaOAuth2Api', reqOpts);
|
|
@@ -1408,18 +1418,15 @@ class Aiteza {
|
|
|
1408
1418
|
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', idx);
|
|
1409
1419
|
const binaryData = this.helpers.assertBinaryData(idx, binaryPropertyName);
|
|
1410
1420
|
const buffer = await this.helpers.getBinaryDataBuffer(idx, binaryPropertyName);
|
|
1421
|
+
const form = new form_data_1.default();
|
|
1422
|
+
form.append(fieldName, buffer, {
|
|
1423
|
+
filename: binaryData.fileName ?? defaultFileName,
|
|
1424
|
+
contentType: binaryData.mimeType,
|
|
1425
|
+
});
|
|
1411
1426
|
return uploadRequest({
|
|
1412
1427
|
method: 'POST',
|
|
1413
1428
|
url,
|
|
1414
|
-
|
|
1415
|
-
[fieldName]: {
|
|
1416
|
-
value: buffer,
|
|
1417
|
-
options: {
|
|
1418
|
-
filename: binaryData.fileName ?? defaultFileName,
|
|
1419
|
-
contentType: binaryData.mimeType,
|
|
1420
|
-
},
|
|
1421
|
-
},
|
|
1422
|
-
},
|
|
1429
|
+
body: form,
|
|
1423
1430
|
});
|
|
1424
1431
|
};
|
|
1425
1432
|
const buildFileUploadUrl = async (idx, basePath) => {
|
|
@@ -1821,22 +1828,26 @@ class Aiteza {
|
|
|
1821
1828
|
const prompt = this.getNodeParameter('prompt', i);
|
|
1822
1829
|
const model = this.getNodeParameter('model', i);
|
|
1823
1830
|
const additionalFields = this.getNodeParameter('additionalFields', i, {});
|
|
1824
|
-
const
|
|
1831
|
+
const form = new form_data_1.default();
|
|
1832
|
+
form.append('prompt', prompt);
|
|
1833
|
+
form.append('model', model);
|
|
1825
1834
|
for (const key of ['connectedDatarooms', 'fileIds', 'imageIds']) {
|
|
1826
1835
|
if (additionalFields[key]) {
|
|
1827
|
-
|
|
1836
|
+
for (const val of splitCsv(additionalFields[key])) {
|
|
1837
|
+
form.append(key, val);
|
|
1838
|
+
}
|
|
1828
1839
|
}
|
|
1829
1840
|
}
|
|
1830
1841
|
for (const key of ['parentDatarooms', 'subDatarooms', 'webSearchEnabled', 'agenticMode', 'workflowId']) {
|
|
1831
1842
|
if (additionalFields[key] !== undefined && additionalFields[key] !== '')
|
|
1832
|
-
|
|
1843
|
+
form.append(key, String(additionalFields[key]));
|
|
1833
1844
|
}
|
|
1834
1845
|
const baseUrl = await getBaseUrl();
|
|
1835
1846
|
const response = await uploadRequest({
|
|
1836
1847
|
method: 'POST',
|
|
1837
1848
|
url: `${baseUrl}/api/chat/${chatId}/generate`,
|
|
1838
|
-
|
|
1839
|
-
|
|
1849
|
+
body: form,
|
|
1850
|
+
returnFullResponse: true,
|
|
1840
1851
|
});
|
|
1841
1852
|
responseData = typeof response === 'object' && response.body !== undefined ? response.body : response;
|
|
1842
1853
|
const xChatId = response?.headers?.['x-chat-id'];
|
|
@@ -1848,42 +1859,50 @@ class Aiteza {
|
|
|
1848
1859
|
const prompt = this.getNodeParameter('prompt', i);
|
|
1849
1860
|
const model = this.getNodeParameter('model', i);
|
|
1850
1861
|
const additionalFields = this.getNodeParameter('additionalFields', i, {});
|
|
1851
|
-
const
|
|
1862
|
+
const form = new form_data_1.default();
|
|
1863
|
+
form.append('prompt', prompt);
|
|
1864
|
+
form.append('model', model);
|
|
1852
1865
|
for (const key of ['connectedDatarooms', 'fileIds', 'imageIds']) {
|
|
1853
1866
|
if (additionalFields[key]) {
|
|
1854
|
-
|
|
1867
|
+
for (const val of splitCsv(additionalFields[key])) {
|
|
1868
|
+
form.append(key, val);
|
|
1869
|
+
}
|
|
1855
1870
|
}
|
|
1856
1871
|
}
|
|
1857
1872
|
for (const key of ['parentDatarooms', 'subDatarooms', 'webSearchEnabled', 'agenticMode', 'workflowId']) {
|
|
1858
1873
|
if (additionalFields[key] !== undefined && additionalFields[key] !== '')
|
|
1859
|
-
|
|
1874
|
+
form.append(key, String(additionalFields[key]));
|
|
1860
1875
|
}
|
|
1861
1876
|
const baseUrl = await getBaseUrl();
|
|
1862
1877
|
responseData = await uploadRequest({
|
|
1863
1878
|
method: 'POST',
|
|
1864
1879
|
url: `${baseUrl}/api/chat/estimate`,
|
|
1865
|
-
|
|
1880
|
+
body: form,
|
|
1866
1881
|
});
|
|
1867
1882
|
}
|
|
1868
1883
|
else if (operation === 'tempChat') {
|
|
1869
1884
|
const prompt = this.getNodeParameter('prompt', i);
|
|
1870
1885
|
const model = this.getNodeParameter('model', i);
|
|
1871
1886
|
const additionalFields = this.getNodeParameter('additionalFields', i, {});
|
|
1872
|
-
const
|
|
1887
|
+
const form = new form_data_1.default();
|
|
1888
|
+
form.append('prompt', prompt);
|
|
1889
|
+
form.append('model', model);
|
|
1873
1890
|
for (const key of ['connectedDatarooms', 'fileIds', 'imageIds']) {
|
|
1874
1891
|
if (additionalFields[key]) {
|
|
1875
|
-
|
|
1892
|
+
for (const val of splitCsv(additionalFields[key])) {
|
|
1893
|
+
form.append(key, val);
|
|
1894
|
+
}
|
|
1876
1895
|
}
|
|
1877
1896
|
}
|
|
1878
1897
|
for (const key of ['webSearchEnabled', 'subDatarooms', 'parentDatarooms', 'workflowId']) {
|
|
1879
1898
|
if (additionalFields[key] !== undefined && additionalFields[key] !== '')
|
|
1880
|
-
|
|
1899
|
+
form.append(key, String(additionalFields[key]));
|
|
1881
1900
|
}
|
|
1882
1901
|
const baseUrl = await getBaseUrl();
|
|
1883
1902
|
responseData = await uploadRequest({
|
|
1884
1903
|
method: 'POST',
|
|
1885
1904
|
url: `${baseUrl}/api/chat/temp`,
|
|
1886
|
-
|
|
1905
|
+
body: form,
|
|
1887
1906
|
});
|
|
1888
1907
|
if (typeof responseData === 'string') {
|
|
1889
1908
|
responseData = { result: responseData };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiteza/n8n-nodes-aiteza",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "n8n Community Node for the AITEZA REST API (Datarooms, Files, Chat, Search, Workflows)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package",
|
|
@@ -37,6 +37,9 @@
|
|
|
37
37
|
"dist/nodes/Aiteza/AitezaTrigger.node.js"
|
|
38
38
|
]
|
|
39
39
|
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"form-data": "^4.0.0"
|
|
42
|
+
},
|
|
40
43
|
"devDependencies": {
|
|
41
44
|
"@typescript-eslint/parser": "~7.18.0",
|
|
42
45
|
"eslint": "~8.57.0",
|