@resolveio/server-lib 20.15.4 → 20.15.6
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/methods/ai-terminal.js +561 -254
- package/methods/ai-terminal.js.map +1 -1
- package/package.json +1 -1
- package/server-app.js +71 -52
- package/server-app.js.map +1 -1
package/package.json
CHANGED
package/server-app.js
CHANGED
|
@@ -1606,12 +1606,13 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
1606
1606
|
};
|
|
1607
1607
|
ResolveIOMainServer.prototype.handleClientMessage = function (ws, msg) {
|
|
1608
1608
|
return __awaiter(this, void 0, void 0, function () {
|
|
1609
|
-
var messageRoute_1, messageDate, messageId, type, subType, pub, serverRes, offlineUpdates, i, update, data, updateRoute, updateDate, updateMessageId, updateType, method, serverResMethod, err_2,
|
|
1609
|
+
var messageRoute_1, messageDate, messageId, type, subType, pub, serverRes, offlineUpdates, i, update, data, updateRoute, updateDate, updateMessageId, updateType, method, serverResMethod, err_2, dataCopy_1, date, msgId_1, msgType, methodName_1, ack, method, forceWorker, targetWorkerIndex, hasWorkerForMethod, isExcludedFromWorker, errorRes, shouldDispatchToWorker, errorRes, err_3;
|
|
1610
1610
|
var _a;
|
|
1611
|
+
var _this = this;
|
|
1611
1612
|
return __generator(this, function (_b) {
|
|
1612
1613
|
switch (_b.label) {
|
|
1613
1614
|
case 0:
|
|
1614
|
-
_b.trys.push([0,
|
|
1615
|
+
_b.trys.push([0, 25, , 26]);
|
|
1615
1616
|
messageRoute_1 = msg[0];
|
|
1616
1617
|
messageDate = msg[1];
|
|
1617
1618
|
messageId = msg[2];
|
|
@@ -1639,7 +1640,7 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
1639
1640
|
case 2:
|
|
1640
1641
|
this._subscriptionManager.unsubscribe(messageRoute_1, messageDate, ws, messageId, pub, msg.slice(6));
|
|
1641
1642
|
_b.label = 3;
|
|
1642
|
-
case 3: return [3 /*break*/,
|
|
1643
|
+
case 3: return [3 /*break*/, 24];
|
|
1643
1644
|
case 4:
|
|
1644
1645
|
if (!(!this.publicProgram && type === 'offline')) return [3 /*break*/, 16];
|
|
1645
1646
|
serverRes = {
|
|
@@ -1739,19 +1740,19 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
1739
1740
|
return [3 /*break*/, 5];
|
|
1740
1741
|
case 15:
|
|
1741
1742
|
this._offlineUpdates.splice(this._offlineUpdates.map(function (a) { return a['id_socket']; }).indexOf(ws['id_socket']), 1);
|
|
1742
|
-
return [3 /*break*/,
|
|
1743
|
+
return [3 /*break*/, 24];
|
|
1743
1744
|
case 16:
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
date =
|
|
1747
|
-
|
|
1748
|
-
msgType =
|
|
1749
|
-
if (!(msgType === 'method')) return [3 /*break*/,
|
|
1750
|
-
|
|
1745
|
+
dataCopy_1 = __spreadArray([], __read(msg), false);
|
|
1746
|
+
dataCopy_1.shift();
|
|
1747
|
+
date = dataCopy_1.shift();
|
|
1748
|
+
msgId_1 = dataCopy_1.shift();
|
|
1749
|
+
msgType = dataCopy_1.shift();
|
|
1750
|
+
if (!(msgType === 'method')) return [3 /*break*/, 24];
|
|
1751
|
+
methodName_1 = dataCopy_1.shift();
|
|
1751
1752
|
if (ws['user_readonly']) {
|
|
1752
1753
|
return [2 /*return*/];
|
|
1753
1754
|
}
|
|
1754
|
-
if (!(
|
|
1755
|
+
if (!(methodName_1 !== 'reportBuilderGetResults' && methodName_1 !== 'reportBuilderGetDistinctValue' && methodName_1 !== 'reportBuilderBuildTree' && methodName_1 !== 'generatePDF' && methodName_1 !== 'getWOOfflineData' && methodName_1 !== 'countQuery' && methodName_1 !== 'countWithQuery' && methodName_1 !== 'countCollectionWithQuery' && methodName_1 !== 'find' && methodName_1 !== 'findOne' && methodName_1 !== 'findWithOptions' && methodName_1 !== 'getDrivers' && methodName_1 !== 'processAirdropDistribution')) return [3 /*break*/, 19];
|
|
1755
1756
|
if (!(resolveio_server_app_1.ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'
|
|
1756
1757
|
&& resolveio_server_app_1.ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200')) return [3 /*break*/, 17];
|
|
1757
1758
|
resolveio_server_app_1.ResolveIOServer.getLocalLogManager().writeLog({
|
|
@@ -1762,8 +1763,8 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
1762
1763
|
type: 'client-request',
|
|
1763
1764
|
collection: '',
|
|
1764
1765
|
id_document: '',
|
|
1765
|
-
payload: (0, common_1.getBinarySize)(JSON.stringify([
|
|
1766
|
-
method:
|
|
1766
|
+
payload: (0, common_1.getBinarySize)(JSON.stringify([dataCopy_1])) < 1000000 ? JSON.stringify([dataCopy_1], null, 2) : 'Too Big',
|
|
1767
|
+
method: methodName_1,
|
|
1767
1768
|
id_user: ws['id_user'] || '',
|
|
1768
1769
|
user: ws['user'] || '',
|
|
1769
1770
|
messageId: messageId,
|
|
@@ -1777,8 +1778,8 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
1777
1778
|
type: 'client-request',
|
|
1778
1779
|
collection: '',
|
|
1779
1780
|
id_document: '',
|
|
1780
|
-
payload: (0, common_1.getBinarySize)(JSON.stringify([
|
|
1781
|
-
method:
|
|
1781
|
+
payload: (0, common_1.getBinarySize)(JSON.stringify([dataCopy_1])) < 1000000 ? JSON.stringify([dataCopy_1], null, 2) : 'Too Big',
|
|
1782
|
+
method: methodName_1,
|
|
1782
1783
|
id_user: ws['id_user'] || '',
|
|
1783
1784
|
user: ws['user'] || '',
|
|
1784
1785
|
messageId: messageId,
|
|
@@ -1792,39 +1793,39 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
1792
1793
|
_b.label = 19;
|
|
1793
1794
|
case 19:
|
|
1794
1795
|
ack = {
|
|
1795
|
-
messageId:
|
|
1796
|
+
messageId: msgId_1,
|
|
1796
1797
|
hasError: false,
|
|
1797
1798
|
data: 'ACK'
|
|
1798
1799
|
};
|
|
1799
1800
|
if (ws && ws.readyState === WebSocket.OPEN) {
|
|
1800
1801
|
this._websocketManager.send(ws, ack);
|
|
1801
1802
|
}
|
|
1802
|
-
method = this._methodManager.getMethod(
|
|
1803
|
+
method = this._methodManager.getMethod(methodName_1);
|
|
1803
1804
|
forceWorker = this._isWorkersEnabled && !!(method === null || method === void 0 ? void 0 : method.forceWorker);
|
|
1804
1805
|
targetWorkerIndex = this._isWorkersEnabled && method ? method.targetWorkerIndex : null;
|
|
1805
|
-
hasWorkerForMethod = this._workerDispatcherManager ? this._workerDispatcherManager.hasWorkersForMethod(
|
|
1806
|
-
isExcludedFromWorker = (
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1806
|
+
hasWorkerForMethod = this._workerDispatcherManager ? this._workerDispatcherManager.hasWorkersForMethod(methodName_1) : false;
|
|
1807
|
+
isExcludedFromWorker = (methodName_1 === 'find' ||
|
|
1808
|
+
methodName_1 === 'insertDocument' ||
|
|
1809
|
+
methodName_1 === 'countWithQuery' ||
|
|
1810
|
+
methodName_1 === 'findOne' ||
|
|
1811
|
+
methodName_1 === 'updateDocumentProps' ||
|
|
1812
|
+
methodName_1 === 'findWithOptions' ||
|
|
1813
|
+
methodName_1 === 'updateDocument' ||
|
|
1814
|
+
methodName_1 === 'insertErrorLog' ||
|
|
1815
|
+
methodName_1 === 'removeDocument' ||
|
|
1816
|
+
methodName_1 === 'supportCreateBillingUser' ||
|
|
1817
|
+
methodName_1 === 'getSignedUrl' ||
|
|
1818
|
+
methodName_1 === 'getSignedUrls' ||
|
|
1819
|
+
methodName_1 === 'getSignedUrlWithId' ||
|
|
1820
|
+
methodName_1 === 'incorrectUser' ||
|
|
1821
|
+
methodName_1 === 'reloadWS' ||
|
|
1822
|
+
methodName_1 === 'reconnectWS' ||
|
|
1823
|
+
methodName_1 === 'disconnectWS');
|
|
1823
1824
|
if (targetWorkerIndex && this._isWorkersEnabled && !hasWorkerForMethod) {
|
|
1824
1825
|
errorRes = {
|
|
1825
|
-
messageId:
|
|
1826
|
+
messageId: msgId_1,
|
|
1826
1827
|
hasError: true,
|
|
1827
|
-
data: "Target worker ".concat(targetWorkerIndex, " not available for method ").concat(
|
|
1828
|
+
data: "Target worker ".concat(targetWorkerIndex, " not available for method ").concat(methodName_1)
|
|
1828
1829
|
};
|
|
1829
1830
|
if (ws && ws.readyState === WebSocket.OPEN) {
|
|
1830
1831
|
this._websocketManager.send(ws, errorRes);
|
|
@@ -1838,35 +1839,53 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
1838
1839
|
(hasWorkerForMethod || forceWorker) &&
|
|
1839
1840
|
(forceWorker || !isExcludedFromWorker));
|
|
1840
1841
|
if (!shouldDispatchToWorker) return [3 /*break*/, 20];
|
|
1841
|
-
this._workerDispatcherManager.sendClientTask(
|
|
1842
|
+
this._workerDispatcherManager.sendClientTask(msgId_1, methodName_1, dataCopy_1, {
|
|
1842
1843
|
id_user: ws['id_user'],
|
|
1843
1844
|
user: ws['user'],
|
|
1844
1845
|
id_ws: ws['id_socket']
|
|
1845
1846
|
});
|
|
1846
|
-
return [3 /*break*/,
|
|
1847
|
+
return [3 /*break*/, 24];
|
|
1847
1848
|
case 20:
|
|
1848
1849
|
if (!(forceWorker && this._isWorkersEnabled)) return [3 /*break*/, 21];
|
|
1849
1850
|
errorRes = {
|
|
1850
|
-
messageId:
|
|
1851
|
+
messageId: msgId_1,
|
|
1851
1852
|
hasError: true,
|
|
1852
|
-
data: "Worker dispatch required for method ".concat(
|
|
1853
|
+
data: "Worker dispatch required for method ".concat(methodName_1, ", but no worker dispatcher is available.")
|
|
1853
1854
|
};
|
|
1854
1855
|
if (ws && ws.readyState === WebSocket.OPEN) {
|
|
1855
1856
|
this._websocketManager.send(ws, errorRes);
|
|
1856
1857
|
}
|
|
1857
|
-
return [3 /*break*/,
|
|
1858
|
-
case 21:
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1858
|
+
return [3 /*break*/, 24];
|
|
1859
|
+
case 21:
|
|
1860
|
+
if (!(methodName_1 === 'aiCoderTerminalRunCodex')) return [3 /*break*/, 22];
|
|
1861
|
+
setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1862
|
+
var error_4;
|
|
1863
|
+
return __generator(this, function (_a) {
|
|
1864
|
+
switch (_a.label) {
|
|
1865
|
+
case 0:
|
|
1866
|
+
_a.trys.push([0, 2, , 3]);
|
|
1867
|
+
return [4 /*yield*/, this.callMethodLocally(ws, msgId_1, methodName_1, dataCopy_1)];
|
|
1868
|
+
case 1:
|
|
1869
|
+
_a.sent();
|
|
1870
|
+
return [3 /*break*/, 3];
|
|
1871
|
+
case 2:
|
|
1872
|
+
error_4 = _a.sent();
|
|
1873
|
+
console.error(new Date(), 'aiCoderTerminalRunCodex failed:', error_4);
|
|
1874
|
+
return [3 /*break*/, 3];
|
|
1875
|
+
case 3: return [2 /*return*/];
|
|
1876
|
+
}
|
|
1877
|
+
});
|
|
1878
|
+
}); }, 0);
|
|
1879
|
+
return [3 /*break*/, 24];
|
|
1880
|
+
case 22: return [4 /*yield*/, this.callMethodLocally(ws, msgId_1, methodName_1, dataCopy_1)];
|
|
1881
|
+
case 23:
|
|
1863
1882
|
_b.sent();
|
|
1864
|
-
_b.label =
|
|
1865
|
-
case
|
|
1866
|
-
case
|
|
1883
|
+
_b.label = 24;
|
|
1884
|
+
case 24: return [3 /*break*/, 26];
|
|
1885
|
+
case 25:
|
|
1867
1886
|
err_3 = _b.sent();
|
|
1868
1887
|
throw err_3;
|
|
1869
|
-
case
|
|
1888
|
+
case 26: return [2 /*return*/];
|
|
1870
1889
|
}
|
|
1871
1890
|
});
|
|
1872
1891
|
});
|