asaihost-nodejs 0.0.2 → 0.0.4
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/asaihost-nodejs.cjs +267 -292
- package/dist/asaihost-nodejs.cjs.map +1 -1
- package/dist/asaihost-nodejs.es.js +20 -45
- package/dist/asaihost-nodejs.es.js.map +1 -1
- package/package.json +1 -1
package/dist/asaihost-nodejs.cjs
CHANGED
|
@@ -1847,12 +1847,6 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, setupHttpConnectionMonitor, "setupHttpConn
|
|
|
1847
1847
|
|
|
1848
1848
|
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
1849
1849
|
var OWN_PID = _process2.default.pid;
|
|
1850
|
-
function sleepMs(ms) {
|
|
1851
|
-
const deadline = Date.now() + ms;
|
|
1852
|
-
while (Date.now() < deadline) {
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
_chunkSMVZ3ZDJcjs.__name.call(void 0, sleepMs, "sleepMs");
|
|
1856
1850
|
function findListeningPids(port) {
|
|
1857
1851
|
if (!Number.isInteger(port) || port < 1 || port > 65535) return [];
|
|
1858
1852
|
try {
|
|
@@ -1888,32 +1882,20 @@ function findListeningPids(port) {
|
|
|
1888
1882
|
}
|
|
1889
1883
|
}
|
|
1890
1884
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, findListeningPids, "findListeningPids");
|
|
1891
|
-
function
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
if (_process2.default.platform === "win32") {
|
|
1895
|
-
_child_process.execSync.call(void 0, `taskkill /PID ${pid} /F`, { stdio: "ignore" });
|
|
1896
|
-
} else {
|
|
1897
|
-
_child_process.execSync.call(void 0, `kill -9 ${pid}`, { stdio: "ignore" });
|
|
1898
|
-
}
|
|
1899
|
-
return true;
|
|
1900
|
-
} catch (e32) {
|
|
1901
|
-
return false;
|
|
1902
|
-
}
|
|
1885
|
+
function formatOccupants(port, exclude) {
|
|
1886
|
+
const occupants = findListeningPids(port).filter((p) => p !== exclude && p !== OWN_PID);
|
|
1887
|
+
return [...new Set(occupants)].join(", ");
|
|
1903
1888
|
}
|
|
1904
|
-
_chunkSMVZ3ZDJcjs.__name.call(void 0,
|
|
1889
|
+
_chunkSMVZ3ZDJcjs.__name.call(void 0, formatOccupants, "formatOccupants");
|
|
1905
1890
|
function releasePort(port, opts) {
|
|
1906
1891
|
const exclude = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _197 => _197.excludePid]), () => ( OWN_PID));
|
|
1907
|
-
const occupants =
|
|
1908
|
-
if (!occupants
|
|
1892
|
+
const occupants = formatOccupants(port, exclude);
|
|
1893
|
+
if (!occupants) return true;
|
|
1909
1894
|
const label = _optionalChain([opts, 'optionalAccess', _198 => _198.label]) ? `[${opts.label}] ` : "";
|
|
1910
|
-
console.warn(
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
sleepMs(500);
|
|
1915
|
-
const remaining = findListeningPids(port).filter((p) => p !== exclude && p !== OWN_PID);
|
|
1916
|
-
return remaining.length === 0;
|
|
1895
|
+
console.warn(
|
|
1896
|
+
`[AsaiHostNodejs] ${label}\u7AEF\u53E3 ${port} \u88AB\u5360\u7528\uFF08PID: ${occupants}\uFF09\uFF0C\u8BF7\u624B\u52A8\u7ED3\u675F\u5360\u7528\u8FDB\u7A0B\u540E\u91CD\u8BD5`
|
|
1897
|
+
);
|
|
1898
|
+
return false;
|
|
1917
1899
|
}
|
|
1918
1900
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, releasePort, "releasePort");
|
|
1919
1901
|
function collectStartupPorts($asai) {
|
|
@@ -2066,7 +2048,6 @@ function startHTTPServer($asai, hostdir) {
|
|
|
2066
2048
|
${err.stack}` : err);
|
|
2067
2049
|
}
|
|
2068
2050
|
});
|
|
2069
|
-
releasePort(hostcfg.port, { excludePid: process.pid, label: hostdir });
|
|
2070
2051
|
if ($asai.hostconfig.ip === "asai" || !hostcfg.ip && !$asai.hostconfig.ip) {
|
|
2071
2052
|
server.listen(hostcfg.port, () => {
|
|
2072
2053
|
console.log(`[${hostdir}] Start At ${_chunkO6LVLSNBcjs.getNowTime.call(void 0, )}.`);
|
|
@@ -2122,15 +2103,9 @@ function asaiGuard($asai, failedHostdir = "asai") {
|
|
|
2122
2103
|
);
|
|
2123
2104
|
return;
|
|
2124
2105
|
}
|
|
2125
|
-
|
|
2106
|
+
releasePort(port, { excludePid: process.pid, label: failedHostdir });
|
|
2126
2107
|
$asai.hostconfig.asaiport = conflictPorts.filter((p) => p !== port);
|
|
2127
|
-
|
|
2128
|
-
console.warn(`[AsaiHostNodejs] \u7AEF\u53E3 ${port} \u5DF2\u91CA\u653E\uFF0C\u6B63\u5728\u91CD\u65B0\u542F\u52A8 [${failedHostdir}]`);
|
|
2129
|
-
scheduleHttpRetry($asai, failedHostdir);
|
|
2130
|
-
return;
|
|
2131
|
-
}
|
|
2132
|
-
console.error(`[AsaiHostNodejs] \u7AEF\u53E3 ${port} \u65E0\u6CD5\u91CA\u653E\uFF0C\u542F\u52A8\u5931\u8D25\uFF08netstat -ano | findstr :${port}\uFF09`);
|
|
2133
|
-
process.exit(1);
|
|
2108
|
+
scheduleHttpRetry($asai, failedHostdir);
|
|
2134
2109
|
}
|
|
2135
2110
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, asaiGuard, "asaiGuard");
|
|
2136
2111
|
|
|
@@ -2231,21 +2206,17 @@ function startProxyServer($asai, proxyhostdir) {
|
|
|
2231
2206
|
if (err.code === "EADDRINUSE") {
|
|
2232
2207
|
$asai.$log("PROXY", `\x1B[41mPort ${proxycfg.proxyport} is already start!\x1B[0m`);
|
|
2233
2208
|
_optionalChainDelete([$asai, 'access', _223 => _223.serversproxy, 'optionalAccess', _224 => delete _224[proxyhostdir]]);
|
|
2234
|
-
|
|
2209
|
+
releasePort(proxycfg.proxyport, {
|
|
2235
2210
|
excludePid: process.pid,
|
|
2236
2211
|
label: proxyhostdir
|
|
2237
2212
|
});
|
|
2238
|
-
|
|
2239
|
-
console.warn(`[AsaiHostNodejs] \u4EE3\u7406\u7AEF\u53E3 ${proxycfg.proxyport} \u5DF2\u91CA\u653E\uFF0C\u6B63\u5728\u91CD\u65B0\u542F\u52A8 [${proxyhostdir}]`);
|
|
2240
|
-
setTimeout(() => startProxyServer($asai, proxyhostdir), _optionalChain([$asai, 'access', _225 => _225.hostconfig, 'access', _226 => _226.tm, 'optionalAccess', _227 => _227.d]) || 2e3);
|
|
2241
|
-
}
|
|
2213
|
+
setTimeout(() => startProxyServer($asai, proxyhostdir), _optionalChain([$asai, 'access', _225 => _225.hostconfig, 'access', _226 => _226.tm, 'optionalAccess', _227 => _227.d]) || 2e3);
|
|
2242
2214
|
} else {
|
|
2243
2215
|
$asai.$log("PROXY", "Proxy server error:", err);
|
|
2244
2216
|
}
|
|
2245
2217
|
});
|
|
2246
2218
|
if (!$asai.serversproxy) $asai.serversproxy = {};
|
|
2247
2219
|
$asai.serversproxy[proxyhostdir] = proxyServer;
|
|
2248
|
-
releasePort(proxycfg.proxyport, { excludePid: process.pid, label: proxyhostdir });
|
|
2249
2220
|
const listenIp = getHostIP(proxycfg.proxyip, $asai);
|
|
2250
2221
|
const listenCallback = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, () => {
|
|
2251
2222
|
console.log(`[${proxyhostdir}] Start At ${_chunkO6LVLSNBcjs.getNowTime.call(void 0, )}.`);
|
|
@@ -2379,7 +2350,7 @@ async function attachServerUserLevel(req, $asai) {
|
|
|
2379
2350
|
} else {
|
|
2380
2351
|
req._serverUser = null;
|
|
2381
2352
|
}
|
|
2382
|
-
} catch (
|
|
2353
|
+
} catch (e32) {
|
|
2383
2354
|
req._serverUser = null;
|
|
2384
2355
|
}
|
|
2385
2356
|
}
|
|
@@ -2533,7 +2504,7 @@ function resolveApiCorsOrigin(req, hostcfg, getHeader) {
|
|
|
2533
2504
|
if (referer) {
|
|
2534
2505
|
try {
|
|
2535
2506
|
origin = new URL(referer).origin;
|
|
2536
|
-
} catch (
|
|
2507
|
+
} catch (e33) {
|
|
2537
2508
|
const parts = referer.split("/");
|
|
2538
2509
|
if (parts.length >= 3) origin = `${parts[0]}//${parts[2]}`;
|
|
2539
2510
|
}
|
|
@@ -2580,6 +2551,10 @@ function readRequestBody(req, maxBody) {
|
|
|
2580
2551
|
});
|
|
2581
2552
|
}
|
|
2582
2553
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, readRequestBody, "readRequestBody");
|
|
2554
|
+
function isRawUploadPost(url = "") {
|
|
2555
|
+
return /\/api\/asaifile\/manage\/up(?:base64|binary)(?:batch)?\//.test(url);
|
|
2556
|
+
}
|
|
2557
|
+
_chunkSMVZ3ZDJcjs.__name.call(void 0, isRawUploadPost, "isRawUploadPost");
|
|
2583
2558
|
function processPostPayload($asai, req, postdata, pm) {
|
|
2584
2559
|
let isAes = false;
|
|
2585
2560
|
let out = postdata;
|
|
@@ -2590,12 +2565,12 @@ function processPostPayload($asai, req, postdata, pm) {
|
|
|
2590
2565
|
if (_optionalChain([aesData, 'optionalAccess', _279 => _279.aes]) === 2 && typeof out === "string") {
|
|
2591
2566
|
try {
|
|
2592
2567
|
out = JSON.parse(out);
|
|
2593
|
-
} catch (
|
|
2568
|
+
} catch (e34) {
|
|
2594
2569
|
}
|
|
2595
2570
|
}
|
|
2596
2571
|
}
|
|
2597
2572
|
const plainJson = typeof out === "string" && out.trimStart().startsWith("{");
|
|
2598
|
-
if (_optionalChain([req, 'optionalAccess', _280 => _280.Userinfo, 'optionalAccess', _281 => _281[2]]) && !plainJson) {
|
|
2573
|
+
if (_optionalChain([req, 'optionalAccess', _280 => _280.Userinfo, 'optionalAccess', _281 => _281[2]]) && !plainJson && !isRawUploadPost(_optionalChain([req, 'optionalAccess', _282 => _282.url]))) {
|
|
2599
2574
|
pm = req.Userinfo[2];
|
|
2600
2575
|
out = $asai.$lib.AsCode.asdecode(out, pm);
|
|
2601
2576
|
}
|
|
@@ -2603,7 +2578,7 @@ function processPostPayload($asai, req, postdata, pm) {
|
|
|
2603
2578
|
}
|
|
2604
2579
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, processPostPayload, "processPostPayload");
|
|
2605
2580
|
var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, opt = {}) => {
|
|
2606
|
-
_optionalChain([opt, 'optionalAccess',
|
|
2581
|
+
_optionalChain([opt, 'optionalAccess', _283 => _283.fn, 'optionalCall', _284 => _284($asai)]);
|
|
2607
2582
|
function getHeader(req, key) {
|
|
2608
2583
|
return req.headers[key.toLowerCase()] || "";
|
|
2609
2584
|
}
|
|
@@ -2612,7 +2587,7 @@ var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2612
2587
|
let apiRouteCacheLen = -1;
|
|
2613
2588
|
function findApiHandler($asai2, pathname) {
|
|
2614
2589
|
const apis = $asai2.hostserverapis;
|
|
2615
|
-
if (!_optionalChain([apis, 'optionalAccess',
|
|
2590
|
+
if (!_optionalChain([apis, 'optionalAccess', _285 => _285.length])) return void 0;
|
|
2616
2591
|
if (!apiRouteCache || apiRouteCacheLen !== apis.length) {
|
|
2617
2592
|
apiRouteCache = apis.map((elp) => ({ key: elp, path: `/api/${elp}` }));
|
|
2618
2593
|
apiRouteCacheLen = apis.length;
|
|
@@ -2660,9 +2635,9 @@ var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2660
2635
|
pm: decodeURIComponent(urlParse.search.substring(4))
|
|
2661
2636
|
};
|
|
2662
2637
|
if (req.url.indexOf("binary") === -1) {
|
|
2663
|
-
if (_optionalChain([req, 'optionalAccess',
|
|
2638
|
+
if (_optionalChain([req, 'optionalAccess', _286 => _286.Userinfo]) && _optionalChain([req, 'optionalAccess', _287 => _287.Userinfo, 'access', _288 => _288[2]]) && _optionalChain([query, 'optionalAccess', _289 => _289.pm])) {
|
|
2664
2639
|
pm = req.Userinfo[2];
|
|
2665
|
-
query = $asai.$lib.AsCode.asdecode(_optionalChain([query, 'optionalAccess',
|
|
2640
|
+
query = $asai.$lib.AsCode.asdecode(_optionalChain([query, 'optionalAccess', _290 => _290.pm]), pm);
|
|
2666
2641
|
query = Object.fromEntries(new URLSearchParams("?" + query).entries());
|
|
2667
2642
|
}
|
|
2668
2643
|
}
|
|
@@ -2681,7 +2656,7 @@ var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2681
2656
|
const releaseSlot = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, () => releaseApiSlot(hostdir, clientIp), "releaseSlot");
|
|
2682
2657
|
res.once("finish", releaseSlot);
|
|
2683
2658
|
res.once("close", releaseSlot);
|
|
2684
|
-
const maxBody = _optionalChain([$asai, 'access',
|
|
2659
|
+
const maxBody = _optionalChain([$asai, 'access', _291 => _291.hostconfig, 'optionalAccess', _292 => _292.maxbody]) || 100 * 1024 * 1024;
|
|
2685
2660
|
const isTextPost = req.method === "POST" && req.url.indexOf("binary") === -1;
|
|
2686
2661
|
const bodyPromise = isTextPost ? readRequestBody(req, maxBody) : null;
|
|
2687
2662
|
void (async () => {
|
|
@@ -2694,16 +2669,16 @@ var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2694
2669
|
]);
|
|
2695
2670
|
} catch (err) {
|
|
2696
2671
|
releaseSlot();
|
|
2697
|
-
if (_optionalChain([err, 'optionalAccess',
|
|
2672
|
+
if (_optionalChain([err, 'optionalAccess', _293 => _293.message]) === "PAYLOAD_TOO_LARGE") {
|
|
2698
2673
|
return sendError(res, 413, "Payload Too Large");
|
|
2699
2674
|
}
|
|
2700
|
-
return sendError(res, 400, _optionalChain([err, 'optionalAccess',
|
|
2675
|
+
return sendError(res, 400, _optionalChain([err, 'optionalAccess', _294 => _294.message]) || "Bad Request");
|
|
2701
2676
|
}
|
|
2702
2677
|
if (!authResult.ok) {
|
|
2703
2678
|
releaseSlot();
|
|
2704
2679
|
return sendAuthError(res, authResult);
|
|
2705
2680
|
}
|
|
2706
|
-
let apiFn = _optionalChain([$asai, 'access',
|
|
2681
|
+
let apiFn = _optionalChain([$asai, 'access', _295 => _295.hostserverapi, 'access', _296 => _296[apiHandlerKey], 'optionalCall', _297 => _297($asai, query)]);
|
|
2707
2682
|
if (!apiFn) {
|
|
2708
2683
|
return sendError(res, 501, "Not Implemented");
|
|
2709
2684
|
}
|
|
@@ -2719,23 +2694,23 @@ var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2719
2694
|
postdata = processed.postdata;
|
|
2720
2695
|
pm = processed.pm;
|
|
2721
2696
|
isAes = processed.isAes;
|
|
2722
|
-
} catch (
|
|
2697
|
+
} catch (e35) {
|
|
2723
2698
|
return sendError(res, 400, "AES decrypt failed");
|
|
2724
2699
|
}
|
|
2725
|
-
if (_optionalChain([apiFn, 'optionalAccess',
|
|
2700
|
+
if (_optionalChain([apiFn, 'optionalAccess', _298 => _298.post]) && typeof _optionalChain([apiFn, 'optionalAccess', _299 => _299.post]) === "function") {
|
|
2726
2701
|
const optTmp = { qrdata, data: postdata, pm };
|
|
2727
|
-
if (isAes || _optionalChain([$asai, 'access',
|
|
2728
|
-
optTmp.resAES = _optionalChain([$asai, 'access',
|
|
2702
|
+
if (isAes || _optionalChain([$asai, 'access', _300 => _300.$lib, 'access', _301 => _301.aesfns, 'optionalAccess', _302 => _302.allaes])) {
|
|
2703
|
+
optTmp.resAES = _optionalChain([$asai, 'access', _303 => _303.$lib, 'access', _304 => _304.aesfns, 'optionalAccess', _305 => _305.resAES]);
|
|
2729
2704
|
}
|
|
2730
2705
|
apiFn.post(req, res, hostdir, optTmp);
|
|
2731
2706
|
} else {
|
|
2732
2707
|
res.end(typeof postdata === "string" ? postdata : JSON.stringify(_nullishCoalesce(postdata, () => ( ""))));
|
|
2733
2708
|
}
|
|
2734
2709
|
} else if (req.method === "GET") {
|
|
2735
|
-
if (_optionalChain([apiFn, 'optionalAccess',
|
|
2710
|
+
if (_optionalChain([apiFn, 'optionalAccess', _306 => _306.get]) && typeof _optionalChain([apiFn, 'optionalAccess', _307 => _307.get]) === "function") {
|
|
2736
2711
|
const optTmp = { qrdata, data: qrdata, pm };
|
|
2737
|
-
if (isAes || _optionalChain([$asai, 'access',
|
|
2738
|
-
optTmp.resAES = _optionalChain([$asai, 'access',
|
|
2712
|
+
if (isAes || _optionalChain([$asai, 'access', _308 => _308.$lib, 'access', _309 => _309.aesfns, 'optionalAccess', _310 => _310.allaes])) {
|
|
2713
|
+
optTmp.resAES = _optionalChain([$asai, 'access', _311 => _311.$lib, 'access', _312 => _312.aesfns, 'optionalAccess', _313 => _313.resAES]);
|
|
2739
2714
|
}
|
|
2740
2715
|
apiFn.get(req, res, hostdir, optTmp);
|
|
2741
2716
|
} else {
|
|
@@ -2743,12 +2718,12 @@ var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2743
2718
|
}
|
|
2744
2719
|
}
|
|
2745
2720
|
} else {
|
|
2746
|
-
if (_optionalChain([Object, 'access',
|
|
2721
|
+
if (_optionalChain([Object, 'access', _314 => _314.keys, 'call', _315 => _315(query), 'optionalAccess', _316 => _316.length])) {
|
|
2747
2722
|
qrdata = query;
|
|
2748
2723
|
}
|
|
2749
2724
|
if (req.method === "POST") {
|
|
2750
2725
|
$asai.$lib.AsNodeTool.upBinary(req).then((postdata2) => {
|
|
2751
|
-
if (_optionalChain([apiFn, 'optionalAccess',
|
|
2726
|
+
if (_optionalChain([apiFn, 'optionalAccess', _317 => _317.post]) && typeof _optionalChain([apiFn, 'optionalAccess', _318 => _318.post]) === "function") {
|
|
2752
2727
|
apiFn.post(req, res, hostdir, {
|
|
2753
2728
|
qrdata,
|
|
2754
2729
|
data: postdata2
|
|
@@ -2772,12 +2747,12 @@ var Api_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2772
2747
|
|
|
2773
2748
|
// src/common/server/Ws.ts
|
|
2774
2749
|
var Ws_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, opt = {}) => {
|
|
2775
|
-
_optionalChain([opt, 'optionalAccess',
|
|
2750
|
+
_optionalChain([opt, 'optionalAccess', _319 => _319.fn, 'optionalCall', _320 => _320($asai)]);
|
|
2776
2751
|
const wsHandlerCache = /* @__PURE__ */ new Map();
|
|
2777
2752
|
const routeIndex = ensureWsRouteIndex($asai);
|
|
2778
2753
|
function getWsHandler(handlerKey) {
|
|
2779
2754
|
if (!wsHandlerCache.has(handlerKey)) {
|
|
2780
|
-
wsHandlerCache.set(handlerKey, _optionalChain([$asai, 'access',
|
|
2755
|
+
wsHandlerCache.set(handlerKey, _optionalChain([$asai, 'access', _321 => _321.hostserverws, 'access', _322 => _322[handlerKey], 'optionalCall', _323 => _323($asai)]));
|
|
2781
2756
|
}
|
|
2782
2757
|
return wsHandlerCache.get(handlerKey);
|
|
2783
2758
|
}
|
|
@@ -2801,21 +2776,21 @@ var Ws_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, o
|
|
|
2801
2776
|
let reqdata = parseMessage(msg);
|
|
2802
2777
|
let handlerKey;
|
|
2803
2778
|
if (reqdata === "ping") {
|
|
2804
|
-
_optionalChain([ws2, 'access',
|
|
2779
|
+
_optionalChain([ws2, 'access', _324 => _324.send, 'optionalCall', _325 => _325("pong")]);
|
|
2805
2780
|
return;
|
|
2806
2781
|
} else {
|
|
2807
2782
|
const reqdataisobj = typeof reqdata === "object" && reqdata !== null;
|
|
2808
|
-
handlerKey = reqdataisobj ? routeIndex.matchTy(_optionalChain([reqdata, 'optionalAccess',
|
|
2809
|
-
if (!handlerKey && _optionalChain([$asai, 'access',
|
|
2783
|
+
handlerKey = reqdataisobj ? routeIndex.matchTy(_optionalChain([reqdata, 'optionalAccess', _326 => _326.ty])) : routeIndex.matchString(reqdata);
|
|
2784
|
+
if (!handlerKey && _optionalChain([$asai, 'access', _327 => _327.hostserverwss, 'optionalAccess', _328 => _328.length])) {
|
|
2810
2785
|
handlerKey = $asai.hostserverwss.find((elp) => {
|
|
2811
2786
|
if (reqdataisobj) {
|
|
2812
|
-
return _optionalChain([reqdata, 'optionalAccess',
|
|
2787
|
+
return _optionalChain([reqdata, 'optionalAccess', _329 => _329.ty, 'optionalAccess', _330 => _330.startsWith, 'call', _331 => _331(elp)]);
|
|
2813
2788
|
}
|
|
2814
2789
|
return typeof reqdata === "string" && reqdata.startsWith(elp);
|
|
2815
2790
|
});
|
|
2816
2791
|
}
|
|
2817
2792
|
if (!handlerKey) {
|
|
2818
|
-
_optionalChain([$asai, 'access',
|
|
2793
|
+
_optionalChain([$asai, 'access', _332 => _332.asaimock, 'optionalAccess', _333 => _333.wsWorkMock, 'call', _334 => _334({
|
|
2819
2794
|
msg,
|
|
2820
2795
|
ws: ws2,
|
|
2821
2796
|
hostdir,
|
|
@@ -2827,14 +2802,14 @@ var Ws_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, o
|
|
|
2827
2802
|
}
|
|
2828
2803
|
}
|
|
2829
2804
|
if (!handlerKey) return;
|
|
2830
|
-
_optionalChain([getWsHandler, 'call',
|
|
2805
|
+
_optionalChain([getWsHandler, 'call', _335 => _335(handlerKey), 'optionalAccess', _336 => _336.work, 'optionalCall', _337 => _337(reqdata, ws2, hostdir, req)]);
|
|
2831
2806
|
} catch (err) {
|
|
2832
|
-
_optionalChain([($asai.$log || console.error), 'optionalCall',
|
|
2807
|
+
_optionalChain([($asai.$log || console.error), 'optionalCall', _338 => _338("WS", "handler error", err instanceof Error ? err.message : err)]);
|
|
2833
2808
|
}
|
|
2834
2809
|
}
|
|
2835
2810
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, wsWork, "wsWork");
|
|
2836
2811
|
function _getMessage(msg) {
|
|
2837
|
-
if (_optionalChain([msg, 'optionalAccess',
|
|
2812
|
+
if (_optionalChain([msg, 'optionalAccess', _339 => _339.db, 'optionalAccess', _340 => _340.aes]) && _optionalChain([$asai, 'access', _341 => _341.$lib, 'optionalAccess', _342 => _342.aesfns, 'optionalAccess', _343 => _343.reqAES])) {
|
|
2838
2813
|
msg.db = $asai.$lib.aesfns.reqAES({ data: msg.db });
|
|
2839
2814
|
}
|
|
2840
2815
|
return msg;
|
|
@@ -2861,12 +2836,12 @@ var Ws_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, o
|
|
|
2861
2836
|
|
|
2862
2837
|
// src/common/server/Sys.ts
|
|
2863
2838
|
var Sys_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, opt = {}) => {
|
|
2864
|
-
_optionalChain([opt, 'optionalAccess',
|
|
2839
|
+
_optionalChain([opt, 'optionalAccess', _344 => _344.fn, 'optionalCall', _345 => _345($asai)]);
|
|
2865
2840
|
let sysRouteCache = null;
|
|
2866
2841
|
let sysRouteCacheLen = -1;
|
|
2867
2842
|
function findSystemHandler(req) {
|
|
2868
2843
|
const routes = $asai.hostserversyss;
|
|
2869
|
-
if (!_optionalChain([routes, 'optionalAccess',
|
|
2844
|
+
if (!_optionalChain([routes, 'optionalAccess', _346 => _346.length])) return void 0;
|
|
2870
2845
|
if (!sysRouteCache || sysRouteCacheLen !== routes.length) {
|
|
2871
2846
|
sysRouteCache = routes.map((elp) => ({ key: elp, route: `/${elp}` }));
|
|
2872
2847
|
sysRouteCacheLen = routes.length;
|
|
@@ -2899,11 +2874,11 @@ var Sys_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2899
2874
|
if (!authResult.ok) {
|
|
2900
2875
|
return sendAuthError(res, authResult);
|
|
2901
2876
|
}
|
|
2902
|
-
const handler = _optionalChain([$asai, 'access',
|
|
2877
|
+
const handler = _optionalChain([$asai, 'access', _347 => _347.hostserversys, 'access', _348 => _348[handlerKey], 'optionalCall', _349 => _349($asai)]);
|
|
2903
2878
|
if (!handler) {
|
|
2904
2879
|
return sendError(res, 500, "Handler Initialization Failed");
|
|
2905
2880
|
}
|
|
2906
|
-
if (_optionalChain([handler, 'optionalAccess',
|
|
2881
|
+
if (_optionalChain([handler, 'optionalAccess', _350 => _350.show]) && typeof _optionalChain([handler, 'optionalAccess', _351 => _351.show]) === "function") {
|
|
2907
2882
|
handler.show(req, res, hostdir);
|
|
2908
2883
|
} else {
|
|
2909
2884
|
res.end("postdata");
|
|
@@ -2923,14 +2898,14 @@ var Sys_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
2923
2898
|
|
|
2924
2899
|
// src/common/server/WsClient.ts
|
|
2925
2900
|
var WsClient_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, wsname) => {
|
|
2926
|
-
if (!_optionalChain([$asai, 'optionalAccess',
|
|
2901
|
+
if (!_optionalChain([$asai, 'optionalAccess', _352 => _352.clientws])) {
|
|
2927
2902
|
$asai.clientws = {};
|
|
2928
2903
|
}
|
|
2929
2904
|
if (!$asai.clientws[wsname]) {
|
|
2930
2905
|
$asai.clientws[wsname] = { tasks: /* @__PURE__ */ new Map() };
|
|
2931
2906
|
}
|
|
2932
2907
|
function getKeyByData(msgdata) {
|
|
2933
|
-
return _optionalChain([msgdata, 'optionalAccess',
|
|
2908
|
+
return _optionalChain([msgdata, 'optionalAccess', _353 => _353.id]) || _optionalChain([msgdata, 'optionalAccess', _354 => _354.ty]);
|
|
2934
2909
|
}
|
|
2935
2910
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getKeyByData, "getKeyByData");
|
|
2936
2911
|
function clientwsInit() {
|
|
@@ -2943,7 +2918,7 @@ var WsClient_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($a
|
|
|
2943
2918
|
};
|
|
2944
2919
|
$asai.clientws[wsname].socket.on("error", (err) => {
|
|
2945
2920
|
$asai.clientws[wsname].open = 0;
|
|
2946
|
-
_optionalChain([$asai, 'access',
|
|
2921
|
+
_optionalChain([$asai, 'access', _355 => _355.hostconfig, 'access', _356 => _356.logger, 'optionalAccess', _357 => _357.lv, 'optionalAccess', _358 => _358.view]) && console.error(
|
|
2947
2922
|
666.2203,
|
|
2948
2923
|
`${wsname}=${$asai.command.commandconfig.clientws[wsname]} is error.`,
|
|
2949
2924
|
err
|
|
@@ -2952,14 +2927,14 @@ var WsClient_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($a
|
|
|
2952
2927
|
});
|
|
2953
2928
|
$asai.clientws[wsname].socket.on("close", () => {
|
|
2954
2929
|
$asai.clientws[wsname].open = 0;
|
|
2955
|
-
_optionalChain([$asai, 'access',
|
|
2930
|
+
_optionalChain([$asai, 'access', _359 => _359.hostconfig, 'access', _360 => _360.logger, 'optionalAccess', _361 => _361.lv, 'optionalAccess', _362 => _362.view]) && console.error(
|
|
2956
2931
|
666.2205,
|
|
2957
2932
|
`${wsname}=${$asai.command.commandconfig.clientws[wsname]} is close.`
|
|
2958
2933
|
);
|
|
2959
2934
|
reject();
|
|
2960
2935
|
});
|
|
2961
2936
|
$asai.clientws[wsname].socket.onopen = () => {
|
|
2962
|
-
_optionalChain([$asai, 'access',
|
|
2937
|
+
_optionalChain([$asai, 'access', _363 => _363.hostconfig, 'access', _364 => _364.logger, 'optionalAccess', _365 => _365.lv, 'optionalAccess', _366 => _366.view]) && console.log(
|
|
2963
2938
|
666.2201,
|
|
2964
2939
|
`${wsname}=${$asai.command.commandconfig.clientws[wsname]} is open.`
|
|
2965
2940
|
);
|
|
@@ -2982,7 +2957,7 @@ var WsClient_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($a
|
|
|
2982
2957
|
const key = getKeyByData(messageData);
|
|
2983
2958
|
const task = $asai.clientws[wsname].tasks.get(key);
|
|
2984
2959
|
if (task) {
|
|
2985
|
-
_optionalChain([task, 'optionalAccess',
|
|
2960
|
+
_optionalChain([task, 'optionalAccess', _367 => _367.callback, 'call', _368 => _368(messageData)]);
|
|
2986
2961
|
if (messageData.ty && !messageData.id) {
|
|
2987
2962
|
} else {
|
|
2988
2963
|
$asai.clientws[wsname].tasks.delete(key);
|
|
@@ -3036,7 +3011,7 @@ var WsClient_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($a
|
|
|
3036
3011
|
}
|
|
3037
3012
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, clientwsWatch, "clientwsWatch");
|
|
3038
3013
|
function clientwsWatchOff(messageData) {
|
|
3039
|
-
if (_optionalChain([messageData, 'optionalAccess',
|
|
3014
|
+
if (_optionalChain([messageData, 'optionalAccess', _369 => _369.ty]) === "clear") {
|
|
3040
3015
|
$asai.clientws[wsname].tasks = /* @__PURE__ */ new Map();
|
|
3041
3016
|
} else {
|
|
3042
3017
|
const key = getKeyByData(messageData);
|
|
@@ -3077,7 +3052,7 @@ var ping_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai)
|
|
|
3077
3052
|
var web_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai) => {
|
|
3078
3053
|
function chatBoard(msgdata, ws2, hostdir, req) {
|
|
3079
3054
|
let room;
|
|
3080
|
-
if (_optionalChain([msgdata, 'access',
|
|
3055
|
+
if (_optionalChain([msgdata, 'access', _370 => _370.db, 'optionalAccess', _371 => _371.room]) && typeof msgdata.db.room === "string") {
|
|
3081
3056
|
room = msgdata.db.room;
|
|
3082
3057
|
delete msgdata.db.room;
|
|
3083
3058
|
} else {
|
|
@@ -3134,26 +3109,26 @@ var logmanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($
|
|
|
3134
3109
|
removeFile: removeFile2,
|
|
3135
3110
|
resolvePathUnderBase: resolvePathUnderBase2
|
|
3136
3111
|
} = $asai.$lib.AsFs;
|
|
3137
|
-
const { sendSuccess, sendFail, mnLog } = _optionalChain([$asai, 'access',
|
|
3112
|
+
const { sendSuccess, sendFail, mnLog } = _optionalChain([$asai, 'access', _372 => _372.$lib, 'optionalAccess', _373 => _373.reqWork, 'optionalCall', _374 => _374($asai)]);
|
|
3138
3113
|
function mgLog(...arg) {
|
|
3139
3114
|
mnLog("LOG", ...arg);
|
|
3140
3115
|
}
|
|
3141
3116
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, mgLog, "mgLog");
|
|
3142
3117
|
function getDir(opt) {
|
|
3143
|
-
let tmpDir = _optionalChain([opt, 'access',
|
|
3118
|
+
let tmpDir = _optionalChain([opt, 'access', _375 => _375.qrdata, 'optionalAccess', _376 => _376.dir]) || _optionalChain([opt, 'access', _377 => _377.data, 'optionalAccess', _378 => _378.dir]);
|
|
3144
3119
|
if (tmpDir) {
|
|
3145
3120
|
tmpDir = decodeURIComponent(tmpDir);
|
|
3146
3121
|
} else {
|
|
3147
|
-
tmpDir = _optionalChain([opt, 'access',
|
|
3122
|
+
tmpDir = _optionalChain([opt, 'access', _379 => _379.qrdata, 'optionalAccess', _380 => _380.ty]) || _optionalChain([opt, 'access', _381 => _381.data, 'optionalAccess', _382 => _382.ty]);
|
|
3148
3123
|
if (tmpDir) {
|
|
3149
3124
|
tmpDir = decodeURIComponent(tmpDir);
|
|
3150
3125
|
if (tmpDir === "access-clf" || tmpDir === "access-w3c") {
|
|
3151
|
-
tmpDir = _optionalChain([$asai, 'access',
|
|
3126
|
+
tmpDir = _optionalChain([$asai, 'access', _383 => _383.hostconfig, 'access', _384 => _384.logger, 'optionalAccess', _385 => _385.path, 'optionalAccess', _386 => _386.access]) || "";
|
|
3152
3127
|
} else {
|
|
3153
|
-
tmpDir = _optionalChain([$asai, 'access',
|
|
3128
|
+
tmpDir = _optionalChain([$asai, 'access', _387 => _387.hostconfig, 'access', _388 => _388.logger, 'optionalAccess', _389 => _389.path, 'optionalAccess', _390 => _390[tmpDir]]) || "";
|
|
3154
3129
|
}
|
|
3155
3130
|
} else {
|
|
3156
|
-
tmpDir = _optionalChain([$asai, 'access',
|
|
3131
|
+
tmpDir = _optionalChain([$asai, 'access', _391 => _391.hostconfig, 'access', _392 => _392.logger, 'optionalAccess', _393 => _393.path, 'optionalAccess', _394 => _394.client]) || "";
|
|
3157
3132
|
}
|
|
3158
3133
|
}
|
|
3159
3134
|
return tmpDir;
|
|
@@ -3185,7 +3160,7 @@ var logmanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($
|
|
|
3185
3160
|
if (!await ensureLv(req, $asai, 3)) return sendFail(res, "Forbidden", opt);
|
|
3186
3161
|
try {
|
|
3187
3162
|
const baseDir = getDir(opt);
|
|
3188
|
-
const relPath = decodeURIComponent(_optionalChain([opt, 'access',
|
|
3163
|
+
const relPath = decodeURIComponent(_optionalChain([opt, 'access', _395 => _395.qrdata, 'optionalAccess', _396 => _396.path]) || _optionalChain([opt, 'access', _397 => _397.data, 'optionalAccess', _398 => _398.path]));
|
|
3189
3164
|
const jsonpath = resolvePathUnderBase2(baseDir, relPath);
|
|
3190
3165
|
await ensureFile2(jsonpath);
|
|
3191
3166
|
mgLog("ENSURE", jsonpath);
|
|
@@ -3206,7 +3181,7 @@ var logmanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($
|
|
|
3206
3181
|
if (url.startsWith("/api/asailog/manage/selectlist/")) {
|
|
3207
3182
|
if (!await ensureLv(req, $asai, _chunkH3K33HBAcjs.getPermissionThreshold.call(void 0, $asai, "logRead"))) return sendFail(res, "Forbidden", opt);
|
|
3208
3183
|
try {
|
|
3209
|
-
const ty = decodeURIComponent(_optionalChain([opt, 'access',
|
|
3184
|
+
const ty = decodeURIComponent(_optionalChain([opt, 'access', _399 => _399.qrdata, 'optionalAccess', _400 => _400.ty]) || _optionalChain([opt, 'access', _401 => _401.data, 'optionalAccess', _402 => _402.ty]) || "client");
|
|
3210
3185
|
if (!_chunkTKJAHTPOcjs.prefersDiskLogAccess.call(void 0, $asai) && _chunkTKJAHTPOcjs.isLogStoreEnabled.call(void 0, $asai) && (ty === "client" || ty === "server" || ty === "sec")) {
|
|
3211
3186
|
const kind = ty === "sec" ? "sec" : "web";
|
|
3212
3187
|
const groups = await _chunkTKJAHTPOcjs.listUnifiedGroups.call(void 0, $asai, { kind, source: ty === "sec" ? "sec" : ty });
|
|
@@ -3234,8 +3209,8 @@ var logmanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($
|
|
|
3234
3209
|
if (url.startsWith("/api/asailog/manage/select/")) {
|
|
3235
3210
|
if (!await ensureLv(req, $asai, _chunkH3K33HBAcjs.getPermissionThreshold.call(void 0, $asai, "logRead"))) return sendFail(res, "Forbidden", opt);
|
|
3236
3211
|
try {
|
|
3237
|
-
const ty = decodeURIComponent(_optionalChain([opt, 'access',
|
|
3238
|
-
const relPath = decodeURIComponent(_optionalChain([opt, 'access',
|
|
3212
|
+
const ty = decodeURIComponent(_optionalChain([opt, 'access', _403 => _403.qrdata, 'optionalAccess', _404 => _404.ty]) || _optionalChain([opt, 'access', _405 => _405.data, 'optionalAccess', _406 => _406.ty]) || "client");
|
|
3213
|
+
const relPath = decodeURIComponent(_optionalChain([opt, 'access', _407 => _407.qrdata, 'optionalAccess', _408 => _408.path]) || _optionalChain([opt, 'access', _409 => _409.data, 'optionalAccess', _410 => _410.path]));
|
|
3239
3214
|
if (!_chunkTKJAHTPOcjs.prefersDiskLogAccess.call(void 0, $asai) && _chunkTKJAHTPOcjs.isLogStoreEnabled.call(void 0, $asai) && (ty === "client" || ty === "server" || ty === "sec")) {
|
|
3240
3215
|
const data2 = await _chunkTKJAHTPOcjs.readWebLogFromStore.call(void 0, $asai, ty, relPath);
|
|
3241
3216
|
if (data2) {
|
|
@@ -3263,7 +3238,7 @@ var logmanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($
|
|
|
3263
3238
|
if (!await ensureLv(req, $asai, 3)) return sendFail(res, "Forbidden", opt);
|
|
3264
3239
|
try {
|
|
3265
3240
|
const baseDir = getDir(opt);
|
|
3266
|
-
const relPath = decodeURIComponent(_optionalChain([opt, 'access',
|
|
3241
|
+
const relPath = decodeURIComponent(_optionalChain([opt, 'access', _411 => _411.qrdata, 'optionalAccess', _412 => _412.path]) || _optionalChain([opt, 'access', _413 => _413.data, 'optionalAccess', _414 => _414.path]));
|
|
3267
3242
|
const fileName = relPath.split(/[/\\]/).pop() || relPath;
|
|
3268
3243
|
if (_chunkTKJAHTPOcjs.isLogStoreEnabled.call(void 0, $asai)) {
|
|
3269
3244
|
await _chunkTKJAHTPOcjs.purgeStoreEntriesForFile.call(void 0, $asai, fileName).catch(() => void 0);
|
|
@@ -3286,14 +3261,14 @@ var logmanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($
|
|
|
3286
3261
|
|
|
3287
3262
|
// src/infra/siem-auth.ts
|
|
3288
3263
|
function isSiemEnabled($asai) {
|
|
3289
|
-
const cfg = _optionalChain([$asai, 'optionalAccess',
|
|
3290
|
-
return !!(_optionalChain([cfg, 'optionalAccess',
|
|
3264
|
+
const cfg = _optionalChain([$asai, 'optionalAccess', _415 => _415.hostconfig, 'optionalAccess', _416 => _416.logger, 'optionalAccess', _417 => _417.siem]);
|
|
3265
|
+
return !!(_optionalChain([cfg, 'optionalAccess', _418 => _418.enabled]) && getSiemToken($asai));
|
|
3291
3266
|
}
|
|
3292
3267
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, isSiemEnabled, "isSiemEnabled");
|
|
3293
3268
|
function getSiemToken($asai) {
|
|
3294
3269
|
const fromEnv = process.env.ASAI_SIEM_TOKEN;
|
|
3295
3270
|
if (typeof fromEnv === "string" && fromEnv.trim()) return fromEnv.trim();
|
|
3296
|
-
const fromCfg = _optionalChain([$asai, 'optionalAccess',
|
|
3271
|
+
const fromCfg = _optionalChain([$asai, 'optionalAccess', _419 => _419.hostconfig, 'optionalAccess', _420 => _420.logger, 'optionalAccess', _421 => _421.siem, 'optionalAccess', _422 => _422.token]);
|
|
3297
3272
|
return typeof fromCfg === "string" ? fromCfg.trim() : "";
|
|
3298
3273
|
}
|
|
3299
3274
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getSiemToken, "getSiemToken");
|
|
@@ -3301,9 +3276,9 @@ function isSiemTokenValid($asai, req) {
|
|
|
3301
3276
|
if (!isSiemEnabled($asai)) return false;
|
|
3302
3277
|
const expected = getSiemToken($asai);
|
|
3303
3278
|
if (!expected) return false;
|
|
3304
|
-
const header = _optionalChain([req, 'optionalAccess',
|
|
3279
|
+
const header = _optionalChain([req, 'optionalAccess', _423 => _423.headers, 'optionalAccess', _424 => _424["x-siem-token"]]) || _optionalChain([req, 'optionalAccess', _425 => _425.headers, 'optionalAccess', _426 => _426["x-api-key"]]);
|
|
3305
3280
|
if (typeof header === "string" && header === expected) return true;
|
|
3306
|
-
const q = _optionalChain([req, 'optionalAccess',
|
|
3281
|
+
const q = _optionalChain([req, 'optionalAccess', _427 => _427.query]) || {};
|
|
3307
3282
|
const qToken = q.siem_token || q.token;
|
|
3308
3283
|
return typeof qToken === "string" && qToken === expected;
|
|
3309
3284
|
}
|
|
@@ -3327,20 +3302,20 @@ function getNs(raw) {
|
|
|
3327
3302
|
}
|
|
3328
3303
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getNs, "getNs");
|
|
3329
3304
|
async function ensureServerUser(req, $asai) {
|
|
3330
|
-
if (Array.isArray(_optionalChain([req, 'optionalAccess',
|
|
3305
|
+
if (Array.isArray(_optionalChain([req, 'optionalAccess', _428 => _428.Userinfo])) && req.Userinfo[0]) {
|
|
3331
3306
|
await attachServerUserLevel(req, $asai);
|
|
3332
3307
|
}
|
|
3333
3308
|
}
|
|
3334
3309
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, ensureServerUser, "ensureServerUser");
|
|
3335
3310
|
var interventionlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai) => {
|
|
3336
|
-
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access',
|
|
3311
|
+
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access', _429 => _429.$lib, 'optionalAccess', _430 => _430.reqWork, 'optionalCall', _431 => _431($asai)]) || {};
|
|
3337
3312
|
const IL = $asai.$lib.InterventionLog;
|
|
3338
3313
|
async function get(req, res, hostdir, opt) {
|
|
3339
3314
|
const url = req.url || "";
|
|
3340
3315
|
if (url.startsWith("/api/asailog/intervention/selectlist/")) {
|
|
3341
3316
|
if (!await ensureLogReadAccess(req, $asai, _chunkH3K33HBAcjs.getPermissionThreshold.call(void 0, $asai, "logRead"))) return sendFail(res, "Forbidden", opt);
|
|
3342
3317
|
try {
|
|
3343
|
-
const ns = getNs(_optionalChain([opt, 'access',
|
|
3318
|
+
const ns = getNs(_optionalChain([opt, 'access', _432 => _432.qrdata, 'optionalAccess', _433 => _433.ns]) || _optionalChain([opt, 'access', _434 => _434.data, 'optionalAccess', _435 => _435.ns]));
|
|
3344
3319
|
let list = await IL.listInterventionFiles($asai, ns);
|
|
3345
3320
|
if (_chunkTKJAHTPOcjs.isLogStoreEnabled.call(void 0, $asai) && !_chunkTKJAHTPOcjs.prefersDiskLogAccess.call(void 0, $asai)) {
|
|
3346
3321
|
const groups = await _chunkTKJAHTPOcjs.listUnifiedGroups.call(void 0, $asai, { kind: "intervention", ns });
|
|
@@ -3352,19 +3327,19 @@ var interventionlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void
|
|
|
3352
3327
|
}
|
|
3353
3328
|
return sendSuccess(res, { ns, files: list }, opt);
|
|
3354
3329
|
} catch (err) {
|
|
3355
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3330
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _436 => _436.message]) || err, opt);
|
|
3356
3331
|
}
|
|
3357
3332
|
}
|
|
3358
3333
|
if (url.startsWith("/api/asailog/intervention/select/")) {
|
|
3359
3334
|
if (!await ensureLogReadAccess(req, $asai, _chunkH3K33HBAcjs.getPermissionThreshold.call(void 0, $asai, "logRead"))) return sendFail(res, "Forbidden", opt);
|
|
3360
3335
|
try {
|
|
3361
|
-
const name = decodeURIComponent(_optionalChain([opt, 'access',
|
|
3362
|
-
const ns = getNs(_optionalChain([opt, 'access',
|
|
3336
|
+
const name = decodeURIComponent(_optionalChain([opt, 'access', _437 => _437.qrdata, 'optionalAccess', _438 => _438.name]) || _optionalChain([opt, 'access', _439 => _439.data, 'optionalAccess', _440 => _440.name]) || "");
|
|
3337
|
+
const ns = getNs(_optionalChain([opt, 'access', _441 => _441.qrdata, 'optionalAccess', _442 => _442.ns]) || _optionalChain([opt, 'access', _443 => _443.data, 'optionalAccess', _444 => _444.ns]));
|
|
3363
3338
|
if (!name) return sendFail(res, "name required", opt);
|
|
3364
3339
|
const content = await IL.readInterventionFile($asai, name, ns);
|
|
3365
3340
|
return sendSuccess(res, { ns, ...content }, opt);
|
|
3366
3341
|
} catch (err) {
|
|
3367
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3342
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _445 => _445.message]) || err, opt);
|
|
3368
3343
|
}
|
|
3369
3344
|
}
|
|
3370
3345
|
if (url.startsWith("/api/asailog/intervention/types/")) {
|
|
@@ -3372,7 +3347,7 @@ var interventionlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void
|
|
|
3372
3347
|
try {
|
|
3373
3348
|
return sendSuccess(res, IL.getInterventionTaxonomy($asai), opt);
|
|
3374
3349
|
} catch (err) {
|
|
3375
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3350
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _446 => _446.message]) || err, opt);
|
|
3376
3351
|
}
|
|
3377
3352
|
}
|
|
3378
3353
|
}
|
|
@@ -3402,7 +3377,7 @@ var interventionlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void
|
|
|
3402
3377
|
);
|
|
3403
3378
|
return sendSuccess(res, { ns, ...result }, opt);
|
|
3404
3379
|
} catch (err) {
|
|
3405
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3380
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _447 => _447.message]) || err, opt);
|
|
3406
3381
|
}
|
|
3407
3382
|
}
|
|
3408
3383
|
}
|
|
@@ -3421,11 +3396,11 @@ function parseQuery(opt) {
|
|
|
3421
3396
|
}
|
|
3422
3397
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, parseQuery, "parseQuery");
|
|
3423
3398
|
function parseBody(opt) {
|
|
3424
|
-
if (!_optionalChain([opt, 'optionalAccess',
|
|
3399
|
+
if (!_optionalChain([opt, 'optionalAccess', _448 => _448.data])) return {};
|
|
3425
3400
|
if (typeof opt.data === "string") {
|
|
3426
3401
|
try {
|
|
3427
3402
|
return JSON.parse(opt.data);
|
|
3428
|
-
} catch (
|
|
3403
|
+
} catch (e36) {
|
|
3429
3404
|
return {};
|
|
3430
3405
|
}
|
|
3431
3406
|
}
|
|
@@ -3433,7 +3408,7 @@ function parseBody(opt) {
|
|
|
3433
3408
|
}
|
|
3434
3409
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, parseBody, "parseBody");
|
|
3435
3410
|
var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai) => {
|
|
3436
|
-
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access',
|
|
3411
|
+
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access', _449 => _449.$lib, 'optionalAccess', _450 => _450.reqWork, 'optionalCall', _451 => _451($asai)]) || {};
|
|
3437
3412
|
const IL = $asai.$lib.InterventionLog;
|
|
3438
3413
|
async function get(req, res, hostdir, opt) {
|
|
3439
3414
|
const url = req.url || "";
|
|
@@ -3443,7 +3418,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3443
3418
|
try {
|
|
3444
3419
|
return sendSuccess(res, _chunkTKJAHTPOcjs.getLogStoreMeta.call(void 0, $asai), opt);
|
|
3445
3420
|
} catch (err) {
|
|
3446
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3421
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _452 => _452.message]) || err, opt);
|
|
3447
3422
|
}
|
|
3448
3423
|
}
|
|
3449
3424
|
if (url.startsWith("/api/asailog/store/stats/")) {
|
|
@@ -3456,7 +3431,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3456
3431
|
const stats = await _chunkTKJAHTPOcjs.getUnifiedStats.call(void 0, $asai);
|
|
3457
3432
|
return sendSuccess(res, { store: storeType, stats, config: _chunkTKJAHTPOcjs.getLogStoreMeta.call(void 0, $asai) }, opt);
|
|
3458
3433
|
} catch (err) {
|
|
3459
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3434
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _453 => _453.message]) || err, opt);
|
|
3460
3435
|
}
|
|
3461
3436
|
}
|
|
3462
3437
|
if (url.startsWith("/api/asailog/store/compliance/")) {
|
|
@@ -3466,7 +3441,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3466
3441
|
const report = await _chunkTKJAHTPOcjs.getComplianceReport.call(void 0, $asai, ns);
|
|
3467
3442
|
return sendSuccess(res, report, opt);
|
|
3468
3443
|
} catch (err) {
|
|
3469
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3444
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _454 => _454.message]) || err, opt);
|
|
3470
3445
|
}
|
|
3471
3446
|
}
|
|
3472
3447
|
if (url.startsWith("/api/asailog/store/search/")) {
|
|
@@ -3488,7 +3463,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3488
3463
|
});
|
|
3489
3464
|
return sendSuccess(res, result, opt);
|
|
3490
3465
|
} catch (err) {
|
|
3491
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3466
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _455 => _455.message]) || err, opt);
|
|
3492
3467
|
}
|
|
3493
3468
|
}
|
|
3494
3469
|
if (url.startsWith("/api/asailog/store/export/")) {
|
|
@@ -3509,7 +3484,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3509
3484
|
});
|
|
3510
3485
|
return sendSuccess(res, payload, opt);
|
|
3511
3486
|
} catch (err) {
|
|
3512
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3487
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _456 => _456.message]) || err, opt);
|
|
3513
3488
|
}
|
|
3514
3489
|
}
|
|
3515
3490
|
if (url.startsWith("/api/asailog/store/taxonomy/")) {
|
|
@@ -3517,7 +3492,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3517
3492
|
try {
|
|
3518
3493
|
return sendSuccess(res, IL.getInterventionTaxonomy($asai), opt);
|
|
3519
3494
|
} catch (err) {
|
|
3520
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3495
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _457 => _457.message]) || err, opt);
|
|
3521
3496
|
}
|
|
3522
3497
|
}
|
|
3523
3498
|
if (url.startsWith("/api/asailog/store/formats/")) {
|
|
@@ -3526,7 +3501,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3526
3501
|
const { getLogFormatTaxonomy } = await Promise.resolve().then(() => _interopRequireWildcard(require("./log-formats-TUXGMCCU.cjs")));
|
|
3527
3502
|
return sendSuccess(res, getLogFormatTaxonomy($asai), opt);
|
|
3528
3503
|
} catch (err) {
|
|
3529
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3504
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _458 => _458.message]) || err, opt);
|
|
3530
3505
|
}
|
|
3531
3506
|
}
|
|
3532
3507
|
if (url.startsWith("/api/asailog/store/selectlist/")) {
|
|
@@ -3553,7 +3528,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3553
3528
|
}
|
|
3554
3529
|
return sendSuccess(res, { groups }, opt);
|
|
3555
3530
|
} catch (err) {
|
|
3556
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3531
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _459 => _459.message]) || err, opt);
|
|
3557
3532
|
}
|
|
3558
3533
|
}
|
|
3559
3534
|
if (url.startsWith("/api/asailog/store/select/")) {
|
|
@@ -3587,7 +3562,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3587
3562
|
});
|
|
3588
3563
|
return sendSuccess(res, { entries: rows }, opt);
|
|
3589
3564
|
} catch (err) {
|
|
3590
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3565
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _460 => _460.message]) || err, opt);
|
|
3591
3566
|
}
|
|
3592
3567
|
}
|
|
3593
3568
|
}
|
|
@@ -3609,7 +3584,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3609
3584
|
});
|
|
3610
3585
|
return sendSuccess(res, result, opt);
|
|
3611
3586
|
} catch (err) {
|
|
3612
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3587
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _461 => _461.message]) || err, opt);
|
|
3613
3588
|
}
|
|
3614
3589
|
}
|
|
3615
3590
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, post, "post");
|
|
@@ -3621,7 +3596,7 @@ var unifiedlog_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3621
3596
|
|
|
3622
3597
|
var registry = null;
|
|
3623
3598
|
function resolveFilePath($asai) {
|
|
3624
|
-
const root = _optionalChain([$asai, 'optionalAccess',
|
|
3599
|
+
const root = _optionalChain([$asai, 'optionalAccess', _462 => _462.serverRoot]) || process.cwd();
|
|
3625
3600
|
return nodePath3.join(root, "websys/sys/errorcodes.json");
|
|
3626
3601
|
}
|
|
3627
3602
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, resolveFilePath, "resolveFilePath");
|
|
@@ -3631,7 +3606,7 @@ function loadErrorCodes($asai) {
|
|
|
3631
3606
|
try {
|
|
3632
3607
|
const raw = fs8.readFileSync(filePath, "utf8");
|
|
3633
3608
|
registry = JSON.parse(raw);
|
|
3634
|
-
} catch (
|
|
3609
|
+
} catch (e37) {
|
|
3635
3610
|
registry = { version: "0", errors: {} };
|
|
3636
3611
|
}
|
|
3637
3612
|
if ($asai) $asai.errorcodes = registry;
|
|
@@ -3639,7 +3614,7 @@ function loadErrorCodes($asai) {
|
|
|
3639
3614
|
}
|
|
3640
3615
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, loadErrorCodes, "loadErrorCodes");
|
|
3641
3616
|
function getError(ec) {
|
|
3642
|
-
return _optionalChain([registry, 'optionalAccess',
|
|
3617
|
+
return _optionalChain([registry, 'optionalAccess', _463 => _463.errors, 'optionalAccess', _464 => _464[ec]]) || null;
|
|
3643
3618
|
}
|
|
3644
3619
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getError, "getError");
|
|
3645
3620
|
function hasError(ec) {
|
|
@@ -3648,11 +3623,11 @@ function hasError(ec) {
|
|
|
3648
3623
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, hasError, "hasError");
|
|
3649
3624
|
function logError($asai, ec, params) {
|
|
3650
3625
|
const entry = getError(ec);
|
|
3651
|
-
const logFn = _optionalChain([$asai, 'optionalAccess',
|
|
3626
|
+
const logFn = _optionalChain([$asai, 'optionalAccess', _465 => _465.$log]) || console.warn;
|
|
3652
3627
|
if (entry) {
|
|
3653
|
-
logFn(`[EC:${ec}]`, entry.id || "", entry.detail || "", _optionalChain([params, 'optionalAccess',
|
|
3628
|
+
logFn(`[EC:${ec}]`, entry.id || "", entry.detail || "", _optionalChain([params, 'optionalAccess', _466 => _466.length]) ? params : "");
|
|
3654
3629
|
} else {
|
|
3655
|
-
logFn(`[EC:${ec}]`, "(unregistered)", _optionalChain([params, 'optionalAccess',
|
|
3630
|
+
logFn(`[EC:${ec}]`, "(unregistered)", _optionalChain([params, 'optionalAccess', _467 => _467.length]) ? params : "");
|
|
3656
3631
|
}
|
|
3657
3632
|
}
|
|
3658
3633
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, logError, "logError");
|
|
@@ -3680,14 +3655,14 @@ var ErrorCode_default = {
|
|
|
3680
3655
|
|
|
3681
3656
|
// src/sysserver/api/common/errorcodes.ts
|
|
3682
3657
|
var errorcodes_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai) => {
|
|
3683
|
-
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access',
|
|
3658
|
+
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access', _468 => _468.$lib, 'optionalAccess', _469 => _469.reqWork, 'optionalCall', _470 => _470($asai)]) || {};
|
|
3684
3659
|
function get(req, res, _hostdir, opt) {
|
|
3685
3660
|
const url = req.url || "";
|
|
3686
3661
|
if (url.startsWith("/api/sys/errorcodes/")) {
|
|
3687
3662
|
try {
|
|
3688
3663
|
return sendSuccess(res, loadErrorCodes($asai), opt);
|
|
3689
3664
|
} catch (err) {
|
|
3690
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3665
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _471 => _471.message]) || err, opt);
|
|
3691
3666
|
}
|
|
3692
3667
|
}
|
|
3693
3668
|
}
|
|
@@ -3697,9 +3672,9 @@ var errorcodes_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (
|
|
|
3697
3672
|
|
|
3698
3673
|
// src/sysserver/api/common/sqlitemanage.ts
|
|
3699
3674
|
var sqlitemanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai) => {
|
|
3700
|
-
const { sendSuccess, sendFail, mnLog } = _optionalChain([$asai, 'optionalAccess',
|
|
3675
|
+
const { sendSuccess, sendFail, mnLog } = _optionalChain([$asai, 'optionalAccess', _472 => _472.$lib, 'optionalAccess', _473 => _473.reqWork, 'optionalCall', _474 => _474($asai)]) || {};
|
|
3701
3676
|
function mgLog(...arg) {
|
|
3702
|
-
_optionalChain([mnLog, 'optionalCall',
|
|
3677
|
+
_optionalChain([mnLog, 'optionalCall', _475 => _475("SQLite", ...arg)]);
|
|
3703
3678
|
}
|
|
3704
3679
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, mgLog, "mgLog");
|
|
3705
3680
|
return $asai.$lib.AsDb($asai, {
|
|
@@ -3717,7 +3692,7 @@ var sqlitemanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0,
|
|
|
3717
3692
|
if (req.url.startsWith("/api/asaisqlite/manage/post")) {
|
|
3718
3693
|
try {
|
|
3719
3694
|
mgLog("POST", "custom handler triggered");
|
|
3720
|
-
_optionalChain([sendSuccess, 'optionalCall',
|
|
3695
|
+
_optionalChain([sendSuccess, 'optionalCall', _476 => _476(res, { data: "post" }, opt)]);
|
|
3721
3696
|
} catch (err) {
|
|
3722
3697
|
mgLog("ERROR", "post handler", err);
|
|
3723
3698
|
}
|
|
@@ -3734,10 +3709,10 @@ var sqlitemanage_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0,
|
|
|
3734
3709
|
table: dataObj.table
|
|
3735
3710
|
});
|
|
3736
3711
|
mgLog("SELECT", "completed");
|
|
3737
|
-
_optionalChain([sendSuccess, 'optionalCall',
|
|
3712
|
+
_optionalChain([sendSuccess, 'optionalCall', _477 => _477(res, resdb, opt)]);
|
|
3738
3713
|
} catch (errdb) {
|
|
3739
3714
|
mgLog("ERROR", "select", errdb);
|
|
3740
|
-
_optionalChain([sendFail, 'optionalCall',
|
|
3715
|
+
_optionalChain([sendFail, 'optionalCall', _478 => _478(res, errdb, opt)]);
|
|
3741
3716
|
}
|
|
3742
3717
|
return "ok";
|
|
3743
3718
|
}
|
|
@@ -3753,7 +3728,7 @@ function promLine(name, value, labels) {
|
|
|
3753
3728
|
}
|
|
3754
3729
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, promLine, "promLine");
|
|
3755
3730
|
var health_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai) => {
|
|
3756
|
-
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access',
|
|
3731
|
+
const { sendSuccess, sendFail } = _optionalChain([$asai, 'access', _479 => _479.$lib, 'optionalAccess', _480 => _480.reqWork, 'optionalCall', _481 => _481($asai)]) || {};
|
|
3757
3732
|
async function get(req, res, _hostdir, opt) {
|
|
3758
3733
|
const url = req.url || "";
|
|
3759
3734
|
if (url.startsWith("/api/sys/health/metrics/")) {
|
|
@@ -3762,10 +3737,10 @@ var health_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asa
|
|
|
3762
3737
|
let httpTotal = 0;
|
|
3763
3738
|
let wsTotal = 0;
|
|
3764
3739
|
for (const set of Object.values($asai.connectionshttp || {})) {
|
|
3765
|
-
httpTotal += _optionalChain([set, 'optionalAccess',
|
|
3740
|
+
httpTotal += _optionalChain([set, 'optionalAccess', _482 => _482.size]) || 0;
|
|
3766
3741
|
}
|
|
3767
3742
|
for (const set of Object.values($asai.connectionsws || {})) {
|
|
3768
|
-
wsTotal += _optionalChain([set, 'optionalAccess',
|
|
3743
|
+
wsTotal += _optionalChain([set, 'optionalAccess', _483 => _483.size]) || 0;
|
|
3769
3744
|
}
|
|
3770
3745
|
const lines = [
|
|
3771
3746
|
"# HELP asai_uptime_seconds Process uptime",
|
|
@@ -3787,7 +3762,7 @@ var health_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asa
|
|
|
3787
3762
|
res.writeHead(200, { "Content-Type": "text/plain; charset=utf-8" });
|
|
3788
3763
|
return res.end(lines.join("\n") + "\n");
|
|
3789
3764
|
} catch (err) {
|
|
3790
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
3765
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _484 => _484.message]) || err, opt);
|
|
3791
3766
|
}
|
|
3792
3767
|
}
|
|
3793
3768
|
if (url.startsWith("/api/sys/health/status/")) {
|
|
@@ -3800,10 +3775,10 @@ var health_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asa
|
|
|
3800
3775
|
memory: process.memoryUsage(),
|
|
3801
3776
|
quota: {
|
|
3802
3777
|
http: Object.fromEntries(
|
|
3803
|
-
Object.entries($asai.connectionshttp || {}).map(([k, v]) => [k, _optionalChain([v, 'optionalAccess',
|
|
3778
|
+
Object.entries($asai.connectionshttp || {}).map(([k, v]) => [k, _optionalChain([v, 'optionalAccess', _485 => _485.size]) || 0])
|
|
3804
3779
|
),
|
|
3805
3780
|
ws: Object.fromEntries(
|
|
3806
|
-
Object.entries($asai.connectionsws || {}).map(([k, v]) => [k, _optionalChain([v, 'optionalAccess',
|
|
3781
|
+
Object.entries($asai.connectionsws || {}).map(([k, v]) => [k, _optionalChain([v, 'optionalAccess', _486 => _486.size]) || 0])
|
|
3807
3782
|
)
|
|
3808
3783
|
}
|
|
3809
3784
|
},
|
|
@@ -3844,7 +3819,7 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, sanitizeString, "sanitizeString");
|
|
|
3844
3819
|
// src/sysserver/api/login/service/session.ts
|
|
3845
3820
|
|
|
3846
3821
|
function getSessionTtlMs($asai) {
|
|
3847
|
-
const hours = _nullishCoalesce(_optionalChain([$asai, 'optionalAccess',
|
|
3822
|
+
const hours = _nullishCoalesce(_optionalChain([$asai, 'optionalAccess', _487 => _487.hostconfig, 'optionalAccess', _488 => _488.security, 'optionalAccess', _489 => _489.sessionTtlHours]), () => ( 24));
|
|
3848
3823
|
return Number(hours) * 3600 * 1e3;
|
|
3849
3824
|
}
|
|
3850
3825
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getSessionTtlMs, "getSessionTtlMs");
|
|
@@ -3861,7 +3836,7 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, generatePriKey, "generatePriKey");
|
|
|
3861
3836
|
function createSessionKeys($asai) {
|
|
3862
3837
|
const sessionId = _crypto.randomUUID.call(void 0, );
|
|
3863
3838
|
const pri = generatePriKey();
|
|
3864
|
-
const sn = _optionalChain([$asai, 'optionalAccess',
|
|
3839
|
+
const sn = _optionalChain([$asai, 'optionalAccess', _490 => _490.hostconfig, 'optionalAccess', _491 => _491.asaisn]);
|
|
3865
3840
|
if (!sn) throw new Error("[session] ASAI_ASAISN \u672A\u914D\u7F6E");
|
|
3866
3841
|
const pub = $asai.$lib.AsCode.asencode(pri, sn);
|
|
3867
3842
|
return { pri, pub, sessionId };
|
|
@@ -3911,20 +3886,20 @@ function unwrapJsonString(value) {
|
|
|
3911
3886
|
if (!text.startsWith("{") && !text.startsWith("[")) return value;
|
|
3912
3887
|
try {
|
|
3913
3888
|
return JSON.parse(text);
|
|
3914
|
-
} catch (
|
|
3889
|
+
} catch (e38) {
|
|
3915
3890
|
return value;
|
|
3916
3891
|
}
|
|
3917
3892
|
}
|
|
3918
3893
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, unwrapJsonString, "unwrapJsonString");
|
|
3919
3894
|
function parseAuthBody(opt) {
|
|
3920
|
-
let raw = _optionalChain([opt, 'optionalAccess',
|
|
3895
|
+
let raw = _optionalChain([opt, 'optionalAccess', _492 => _492.data]);
|
|
3921
3896
|
if (raw == null || raw === "") return {};
|
|
3922
3897
|
if (typeof raw === "string") {
|
|
3923
3898
|
const text = raw.trim();
|
|
3924
3899
|
if (!text) return {};
|
|
3925
3900
|
try {
|
|
3926
3901
|
raw = JSON.parse(text);
|
|
3927
|
-
} catch (
|
|
3902
|
+
} catch (e39) {
|
|
3928
3903
|
if (text.includes("=") && !text.startsWith("{") && !text.startsWith("[")) {
|
|
3929
3904
|
raw = Object.fromEntries(new URLSearchParams(text));
|
|
3930
3905
|
} else {
|
|
@@ -3993,7 +3968,7 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, purgeOfflineSessions, "purgeOfflineSession
|
|
|
3993
3968
|
|
|
3994
3969
|
// src/sysserver/api/login/index.ts
|
|
3995
3970
|
function getSecurity($asai) {
|
|
3996
|
-
return _optionalChain([$asai, 'optionalAccess',
|
|
3971
|
+
return _optionalChain([$asai, 'optionalAccess', _493 => _493.hostconfig, 'optionalAccess', _494 => _494.security]) || {};
|
|
3997
3972
|
}
|
|
3998
3973
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getSecurity, "getSecurity");
|
|
3999
3974
|
function getQuota2($asai) {
|
|
@@ -4006,7 +3981,7 @@ async function canLogin($asai, us, hostdir) {
|
|
|
4006
3981
|
if (!quota.enabled) return { ok: true };
|
|
4007
3982
|
const store = _chunkLXJMGLKWcjs.createUserStore.call(void 0, $asai);
|
|
4008
3983
|
const total = await countOnlineSessions($asai, hostdir, store);
|
|
4009
|
-
const maxLogin = _nullishCoalesce(_nullishCoalesce(quota.maxLoginSessions, () => ( _optionalChain([$asai, 'optionalAccess',
|
|
3984
|
+
const maxLogin = _nullishCoalesce(_nullishCoalesce(quota.maxLoginSessions, () => ( _optionalChain([$asai, 'optionalAccess', _495 => _495.hostconfig, 'optionalAccess', _496 => _496.hosts, 'optionalAccess', _497 => _497.default, 'optionalAccess', _498 => _498.maxonline]))), () => ( 100));
|
|
4010
3985
|
if (total >= maxLogin) {
|
|
4011
3986
|
return { ok: false, message: "LOGIN_QUOTA_FULL" };
|
|
4012
3987
|
}
|
|
@@ -4039,7 +4014,7 @@ function ensureReady($asai) {
|
|
|
4039
4014
|
}
|
|
4040
4015
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, ensureReady, "ensureReady");
|
|
4041
4016
|
var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai) => {
|
|
4042
|
-
const { sendSuccess, sendFail, sendErr } = _optionalChain([$asai, 'access',
|
|
4017
|
+
const { sendSuccess, sendFail, sendErr } = _optionalChain([$asai, 'access', _499 => _499.$lib, 'optionalAccess', _500 => _500.reqWork, 'optionalCall', _501 => _501($asai)]) || {};
|
|
4043
4018
|
const store = _chunkLXJMGLKWcjs.createUserStore.call(void 0, $asai);
|
|
4044
4019
|
async function checkAdmin(req, pathname, minOverride) {
|
|
4045
4020
|
await attachServerUserLevel(req, $asai);
|
|
@@ -4080,7 +4055,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4080
4055
|
logSecurityEvent($asai, { type: "AUTH_FAIL", path: url, method: "POST", user: us, ip, detail: "password_changed" });
|
|
4081
4056
|
return sendSuccess(res, { ok: true }, opt);
|
|
4082
4057
|
} catch (err) {
|
|
4083
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4058
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _502 => _502.message]) || err, opt);
|
|
4084
4059
|
}
|
|
4085
4060
|
}
|
|
4086
4061
|
if (url.startsWith("/api/user/login/register/")) {
|
|
@@ -4113,11 +4088,11 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4113
4088
|
logSecurityEvent($asai, { type: "AUTH_FAIL", path: url, method: "POST", user: us, ip, detail: "register_ok" });
|
|
4114
4089
|
return sendSuccess(res, { user: publicUser($asai, user) }, opt);
|
|
4115
4090
|
} catch (err) {
|
|
4116
|
-
const msg = _optionalChain([err, 'optionalAccess',
|
|
4091
|
+
const msg = _optionalChain([err, 'optionalAccess', _503 => _503.message]) || String(err);
|
|
4117
4092
|
if (msg.includes("exists") || msg.includes("\u5DF2\u5B58\u5728")) {
|
|
4118
4093
|
return sendErr(res, "USER_ALREADY_EXISTS", void 0, opt);
|
|
4119
4094
|
}
|
|
4120
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4095
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _504 => _504.message]) || err, opt);
|
|
4121
4096
|
}
|
|
4122
4097
|
}
|
|
4123
4098
|
if (url.startsWith("/api/user/login/auth/")) {
|
|
@@ -4151,7 +4126,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4151
4126
|
}
|
|
4152
4127
|
const policy = _chunkH3K33HBAcjs.getPasswordPolicy.call(void 0, $asai);
|
|
4153
4128
|
const mustChange = !!user.mustChangePassword || _chunkH3K33HBAcjs.isPasswordExpired.call(void 0, user.passwordChangedAt, policy.maxAgeDays);
|
|
4154
|
-
const hostcfg = _optionalChain([$asai, 'access',
|
|
4129
|
+
const hostcfg = _optionalChain([$asai, 'access', _505 => _505.getHost, 'optionalCall', _506 => _506(hostdir)]) || {};
|
|
4155
4130
|
if (hostcfg.ckws && isUserOnlineOnWs($asai, us, hostdir)) {
|
|
4156
4131
|
kickUserWs($asai, us, hostdir);
|
|
4157
4132
|
}
|
|
@@ -4176,18 +4151,18 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4176
4151
|
opt
|
|
4177
4152
|
);
|
|
4178
4153
|
} catch (err) {
|
|
4179
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4154
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _507 => _507.message]) || err, opt);
|
|
4180
4155
|
}
|
|
4181
4156
|
}
|
|
4182
4157
|
if (url.startsWith("/api/user/login/logout/")) {
|
|
4183
4158
|
try {
|
|
4184
4159
|
const bodySid = body.sessionId ? sanitizeString(body.sessionId, 64) : "";
|
|
4185
4160
|
if (bodySid) await store.removeSession(bodySid);
|
|
4186
|
-
const us = _optionalChain([req, 'optionalAccess',
|
|
4161
|
+
const us = _optionalChain([req, 'optionalAccess', _508 => _508.Userinfo, 'optionalAccess', _509 => _509[0]]);
|
|
4187
4162
|
if (us) logSecurityEvent($asai, { type: "AUTH_FAIL", path: url, method: "POST", user: String(us), ip, detail: "logout" });
|
|
4188
4163
|
return sendSuccess(res, "ok", opt);
|
|
4189
4164
|
} catch (err) {
|
|
4190
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4165
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _510 => _510.message]) || err, opt);
|
|
4191
4166
|
}
|
|
4192
4167
|
}
|
|
4193
4168
|
if (url.startsWith("/api/user/login/admin/kick/")) {
|
|
@@ -4205,7 +4180,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4205
4180
|
}
|
|
4206
4181
|
kickUserWs($asai, target.us, hostdir);
|
|
4207
4182
|
await store.removeSession(sessionId);
|
|
4208
|
-
const operator = String(_optionalChain([req, 'optionalAccess',
|
|
4183
|
+
const operator = String(_optionalChain([req, 'optionalAccess', _511 => _511.Userinfo, 'optionalAccess', _512 => _512[0]]) || "");
|
|
4209
4184
|
await _chunkRIRKIYETcjs.logSessionTerminate.call(void 0, $asai, {
|
|
4210
4185
|
operator,
|
|
4211
4186
|
sessionId,
|
|
@@ -4214,7 +4189,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4214
4189
|
});
|
|
4215
4190
|
return sendSuccess(res, { ok: true }, opt);
|
|
4216
4191
|
} catch (err) {
|
|
4217
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4192
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _513 => _513.message]) || err, opt);
|
|
4218
4193
|
}
|
|
4219
4194
|
}
|
|
4220
4195
|
if (url.startsWith("/api/user/login/admin/delete/")) {
|
|
@@ -4226,11 +4201,11 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4226
4201
|
if (!targetUs || targetUs === "admin") return sendErr(res, "AUTH_FORBIDDEN", void 0, opt);
|
|
4227
4202
|
const ok = await store.deleteUser(targetUs);
|
|
4228
4203
|
if (!ok) return sendErr(res, "AUTH_USER_NOT_FOUND", void 0, opt);
|
|
4229
|
-
const operator = String(_optionalChain([req, 'optionalAccess',
|
|
4204
|
+
const operator = String(_optionalChain([req, 'optionalAccess', _514 => _514.Userinfo, 'optionalAccess', _515 => _515[0]]) || "");
|
|
4230
4205
|
await _chunkRIRKIYETcjs.logAccountPurge.call(void 0, $asai, { operator, targetUs, ip });
|
|
4231
4206
|
return sendSuccess(res, { ok: true }, opt);
|
|
4232
4207
|
} catch (err) {
|
|
4233
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4208
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _516 => _516.message]) || err, opt);
|
|
4234
4209
|
}
|
|
4235
4210
|
}
|
|
4236
4211
|
if (url.startsWith("/api/user/login/admin/levels/")) {
|
|
@@ -4242,7 +4217,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4242
4217
|
const thresholds = body.thresholds && typeof body.thresholds === "object" ? body.thresholds : void 0;
|
|
4243
4218
|
const routeRights = Array.isArray(body.routeRights) ? body.routeRights : void 0;
|
|
4244
4219
|
const defaultResetPassword = typeof body.defaultResetPassword === "string" ? body.defaultResetPassword : void 0;
|
|
4245
|
-
const operator = String(_optionalChain([req, 'optionalAccess',
|
|
4220
|
+
const operator = String(_optionalChain([req, 'optionalAccess', _517 => _517.Userinfo, 'optionalAccess', _518 => _518[0]]) || "");
|
|
4246
4221
|
const cfg = await _chunkH3K33HBAcjs.saveUserLevelConfig.call(void 0,
|
|
4247
4222
|
$asai,
|
|
4248
4223
|
{
|
|
@@ -4255,13 +4230,13 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4255
4230
|
);
|
|
4256
4231
|
await _chunkRIRKIYETcjs.logSecurityConfigIntervention.call(void 0, $asai, {
|
|
4257
4232
|
section: "user_levels",
|
|
4258
|
-
detail: JSON.stringify({ levels: _optionalChain([levels, 'optionalAccess',
|
|
4233
|
+
detail: JSON.stringify({ levels: _optionalChain([levels, 'optionalAccess', _519 => _519.length]), thresholds: !!thresholds, routeRights: _optionalChain([routeRights, 'optionalAccess', _520 => _520.length]) }),
|
|
4259
4234
|
operator,
|
|
4260
4235
|
ip
|
|
4261
4236
|
});
|
|
4262
4237
|
return sendSuccess(res, cfg, opt);
|
|
4263
4238
|
} catch (err) {
|
|
4264
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4239
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _521 => _521.message]) || err, opt);
|
|
4265
4240
|
}
|
|
4266
4241
|
}
|
|
4267
4242
|
if (url.startsWith("/api/user/login/admin/resetpass/")) {
|
|
@@ -4295,7 +4270,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4295
4270
|
passHistory: "[]"
|
|
4296
4271
|
});
|
|
4297
4272
|
if (!updated) return sendErr(res, "AUTH_USER_NOT_FOUND", void 0, opt);
|
|
4298
|
-
const operator = String(_optionalChain([req, 'optionalAccess',
|
|
4273
|
+
const operator = String(_optionalChain([req, 'optionalAccess', _522 => _522.Userinfo, 'optionalAccess', _523 => _523[0]]) || "");
|
|
4299
4274
|
await _chunkRIRKIYETcjs.logUserRbacChange.call(void 0, $asai, {
|
|
4300
4275
|
operator,
|
|
4301
4276
|
targetUs,
|
|
@@ -4312,7 +4287,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4312
4287
|
});
|
|
4313
4288
|
return sendSuccess(res, { user: publicUser($asai, updated) }, opt);
|
|
4314
4289
|
} catch (err) {
|
|
4315
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4290
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _524 => _524.message]) || err, opt);
|
|
4316
4291
|
}
|
|
4317
4292
|
}
|
|
4318
4293
|
if (url.startsWith("/api/user/login/admin/update/")) {
|
|
@@ -4343,7 +4318,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4343
4318
|
if (!updated) return sendErr(res, "AUTH_USER_NOT_FOUND", void 0, opt);
|
|
4344
4319
|
if (Object.keys(patch).length) {
|
|
4345
4320
|
await _chunkRIRKIYETcjs.logUserRbacChange.call(void 0, $asai, {
|
|
4346
|
-
operator: String(_optionalChain([req, 'optionalAccess',
|
|
4321
|
+
operator: String(_optionalChain([req, 'optionalAccess', _525 => _525.Userinfo, 'optionalAccess', _526 => _526[0]]) || ""),
|
|
4347
4322
|
targetUs,
|
|
4348
4323
|
patch,
|
|
4349
4324
|
ip
|
|
@@ -4351,11 +4326,11 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4351
4326
|
}
|
|
4352
4327
|
return sendSuccess(res, { user: publicUser($asai, updated) }, opt);
|
|
4353
4328
|
} catch (err) {
|
|
4354
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4329
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _527 => _527.message]) || err, opt);
|
|
4355
4330
|
}
|
|
4356
4331
|
}
|
|
4357
4332
|
if (url.startsWith("/api/user/login/profile/")) {
|
|
4358
|
-
const us = _optionalChain([req, 'optionalAccess',
|
|
4333
|
+
const us = _optionalChain([req, 'optionalAccess', _528 => _528.Userinfo, 'optionalAccess', _529 => _529[0]]);
|
|
4359
4334
|
if (!us) return sendErr(res, "AUTH_UNAUTHORIZED", void 0, opt);
|
|
4360
4335
|
try {
|
|
4361
4336
|
const user = await store.findByUsername(String(us));
|
|
@@ -4389,7 +4364,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4389
4364
|
const fresh = await store.findByUsername(String(us));
|
|
4390
4365
|
return sendSuccess(res, { user: fresh ? publicUser($asai, fresh) : null }, opt);
|
|
4391
4366
|
} catch (err) {
|
|
4392
|
-
return sendFail(res, _optionalChain([err, 'optionalAccess',
|
|
4367
|
+
return sendFail(res, _optionalChain([err, 'optionalAccess', _530 => _530.message]) || err, opt);
|
|
4393
4368
|
}
|
|
4394
4369
|
}
|
|
4395
4370
|
}
|
|
@@ -4398,7 +4373,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4398
4373
|
const url = req.url || "";
|
|
4399
4374
|
const ip = getClientIp(req);
|
|
4400
4375
|
if (url.startsWith("/api/user/login/config/")) {
|
|
4401
|
-
const lang = String(_optionalChain([req, 'optionalAccess',
|
|
4376
|
+
const lang = String(_optionalChain([req, 'optionalAccess', _531 => _531.headers, 'optionalAccess', _532 => _532["accept-language"]]) || _optionalChain([opt, 'optionalAccess', _533 => _533.headers, 'optionalAccess', _534 => _534["accept-language"]]) || "zh-CN").split(",")[0];
|
|
4402
4377
|
await _chunkH3K33HBAcjs.loadUserLevelConfig.call(void 0, $asai);
|
|
4403
4378
|
return sendSuccess(res, _chunkH3K33HBAcjs.getPublicSecurityConfig.call(void 0, $asai, lang), opt);
|
|
4404
4379
|
}
|
|
@@ -4459,7 +4434,7 @@ var login_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4459
4434
|
);
|
|
4460
4435
|
}
|
|
4461
4436
|
if (url.startsWith("/api/user/login/profile/")) {
|
|
4462
|
-
const us = _optionalChain([req, 'optionalAccess',
|
|
4437
|
+
const us = _optionalChain([req, 'optionalAccess', _535 => _535.Userinfo, 'optionalAccess', _536 => _536[0]]);
|
|
4463
4438
|
if (!us) return sendErr(res, "AUTH_UNAUTHORIZED", void 0, opt);
|
|
4464
4439
|
const user = await store.findByUsername(String(us));
|
|
4465
4440
|
return sendSuccess(res, { user: user ? publicUser($asai, user) : null }, opt);
|
|
@@ -4501,16 +4476,16 @@ var As_default = {
|
|
|
4501
4476
|
return { code: 908, data: val };
|
|
4502
4477
|
},
|
|
4503
4478
|
ctxSuccess(val, opt = null) {
|
|
4504
|
-
if (typeof _optionalChain([opt, 'optionalAccess',
|
|
4479
|
+
if (typeof _optionalChain([opt, 'optionalAccess', _537 => _537.resAES]) === "function") {
|
|
4505
4480
|
val = opt.resAES(val);
|
|
4506
4481
|
}
|
|
4507
4482
|
return { code: 909, data: val };
|
|
4508
4483
|
},
|
|
4509
4484
|
getPath(str = "-") {
|
|
4510
|
-
return _optionalChain([str, 'optionalAccess',
|
|
4485
|
+
return _optionalChain([str, 'optionalAccess', _538 => _538.replace, 'call', _539 => _539(/[^a-zA-Z0-9.\-_\\\/]/g, "")]);
|
|
4511
4486
|
},
|
|
4512
4487
|
getName(str = "-") {
|
|
4513
|
-
return _optionalChain([str, 'optionalAccess',
|
|
4488
|
+
return _optionalChain([str, 'optionalAccess', _540 => _540.replace, 'call', _541 => _541(/[^a-zA-Z0-9.\-_]/g, "")]);
|
|
4514
4489
|
},
|
|
4515
4490
|
toDirPath(relativePath) {
|
|
4516
4491
|
const pathArr = relativePath.split("/");
|
|
@@ -4581,7 +4556,7 @@ var As_default = {
|
|
|
4581
4556
|
// immediate: false,
|
|
4582
4557
|
// });
|
|
4583
4558
|
dtImmediate(fn, opt) {
|
|
4584
|
-
if (_optionalChain([opt, 'optionalAccess',
|
|
4559
|
+
if (_optionalChain([opt, 'optionalAccess', _542 => _542.immediate])) {
|
|
4585
4560
|
fn();
|
|
4586
4561
|
opt.immediate = false;
|
|
4587
4562
|
}
|
|
@@ -4603,7 +4578,7 @@ var As_default = {
|
|
|
4603
4578
|
if (opt.endtime - opt.starttime < opt.wait) {
|
|
4604
4579
|
this.dtClearTimeout(opt);
|
|
4605
4580
|
}
|
|
4606
|
-
if (!_optionalChain([opt, 'optionalAccess',
|
|
4581
|
+
if (!_optionalChain([opt, 'optionalAccess', _543 => _543.timeout])) {
|
|
4607
4582
|
opt.starttime = opt.endtime;
|
|
4608
4583
|
opt.timeout = this.dtSetTimeout(fn, opt);
|
|
4609
4584
|
}
|
|
@@ -4611,7 +4586,7 @@ var As_default = {
|
|
|
4611
4586
|
// 节流:指定长度时间内有多次触发,只fn最后一次触发
|
|
4612
4587
|
throttle(fn, opt) {
|
|
4613
4588
|
this.dtImmediate(fn, opt);
|
|
4614
|
-
if (!_optionalChain([opt, 'optionalAccess',
|
|
4589
|
+
if (!_optionalChain([opt, 'optionalAccess', _544 => _544.timeout])) {
|
|
4615
4590
|
opt.timeout = this.dtSetTimeout(fn, opt);
|
|
4616
4591
|
}
|
|
4617
4592
|
},
|
|
@@ -4647,8 +4622,8 @@ var As_default = {
|
|
|
4647
4622
|
var AsCode_default = {
|
|
4648
4623
|
// 加密
|
|
4649
4624
|
asencode(str, keys) {
|
|
4650
|
-
const strlen = _optionalChain([str, 'optionalAccess',
|
|
4651
|
-
const keyslen = _optionalChain([keys, 'optionalAccess',
|
|
4625
|
+
const strlen = _optionalChain([str, 'optionalAccess', _545 => _545.length]) || 0;
|
|
4626
|
+
const keyslen = _optionalChain([keys, 'optionalAccess', _546 => _546.length]) || 0;
|
|
4652
4627
|
let newstr = "";
|
|
4653
4628
|
for (let i = 0; i < strlen; i++) {
|
|
4654
4629
|
const rnum = Math.round(Math.random() * 1e3) % keyslen;
|
|
@@ -4673,7 +4648,7 @@ var AsCode_default = {
|
|
|
4673
4648
|
const rnum = keys.indexOf(str[i + 3]);
|
|
4674
4649
|
const rnumx = Number(rnum.toString().slice(-1)) + 1;
|
|
4675
4650
|
const ylen = keyslen - rnumx;
|
|
4676
|
-
newstr += _optionalChain([String, 'optionalAccess',
|
|
4651
|
+
newstr += _optionalChain([String, 'optionalAccess', _547 => _547.fromCodePoint, 'call', _548 => _548(
|
|
4677
4652
|
(keys.indexOf(str[i++]) - rnumx) * ylen * ylen + (keys.indexOf(str[i++]) - rnumx) * ylen + (keys.indexOf(str[i++]) - rnumx)
|
|
4678
4653
|
)]);
|
|
4679
4654
|
}
|
|
@@ -4720,7 +4695,7 @@ var AsAES_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4720
4695
|
if (typeof value !== "string") return value;
|
|
4721
4696
|
try {
|
|
4722
4697
|
return JSON.parse(value);
|
|
4723
|
-
} catch (
|
|
4698
|
+
} catch (e40) {
|
|
4724
4699
|
return value;
|
|
4725
4700
|
}
|
|
4726
4701
|
}
|
|
@@ -4756,7 +4731,7 @@ var AsAES_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4756
4731
|
}
|
|
4757
4732
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, decrypt, "decrypt");
|
|
4758
4733
|
function validateFields(payload, fields) {
|
|
4759
|
-
return fields.every((key) => typeof _optionalChain([payload, 'optionalAccess',
|
|
4734
|
+
return fields.every((key) => typeof _optionalChain([payload, 'optionalAccess', _549 => _549[key]]) === "string" && payload[key].length > 0);
|
|
4760
4735
|
}
|
|
4761
4736
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, validateFields, "validateFields");
|
|
4762
4737
|
function reqAES(opt, fn = (data) => data) {
|
|
@@ -4764,7 +4739,7 @@ var AsAES_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4764
4739
|
try {
|
|
4765
4740
|
if (validateFields(reqData, ["data", "iv", "auth"])) {
|
|
4766
4741
|
let aesData = decrypt(reqData);
|
|
4767
|
-
if (_optionalChain([reqData, 'optionalAccess',
|
|
4742
|
+
if (_optionalChain([reqData, 'optionalAccess', _550 => _550.aes]) === 2) {
|
|
4768
4743
|
aesData = JSON.parse(aesData);
|
|
4769
4744
|
}
|
|
4770
4745
|
return fn(aesData);
|
|
@@ -4798,24 +4773,24 @@ var AsAES_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai
|
|
|
4798
4773
|
// src/sysserver/lib/common/AsDb.ts
|
|
4799
4774
|
var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai, cfg) => {
|
|
4800
4775
|
const DataServer = _chunk2BCIIKRGcjs.getDataServerForAsDb.call(void 0, $asai, {
|
|
4801
|
-
type: _optionalChain([cfg, 'optionalAccess',
|
|
4776
|
+
type: _optionalChain([cfg, 'optionalAccess', _551 => _551.type]) || "sqlite",
|
|
4802
4777
|
opt: {
|
|
4803
|
-
..._optionalChain([cfg, 'optionalAccess',
|
|
4778
|
+
..._optionalChain([cfg, 'optionalAccess', _552 => _552.opt]) || {
|
|
4804
4779
|
database: "./webdata/webdb/sqlite/asaisqlite.db",
|
|
4805
4780
|
create: 1
|
|
4806
4781
|
}
|
|
4807
4782
|
},
|
|
4808
|
-
storeKey: _optionalChain([cfg, 'optionalAccess',
|
|
4783
|
+
storeKey: _optionalChain([cfg, 'optionalAccess', _553 => _553.storeKey])
|
|
4809
4784
|
});
|
|
4810
4785
|
function reqwherestr(str) {
|
|
4811
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
4786
|
+
if (_optionalChain([cfg, 'optionalAccess', _554 => _554.type]) === "sqlite" || _optionalChain([cfg, 'optionalAccess', _555 => _555.type]) === "mysql") {
|
|
4812
4787
|
return `'${str}'`;
|
|
4813
4788
|
}
|
|
4814
4789
|
return str;
|
|
4815
4790
|
}
|
|
4816
4791
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, reqwherestr, "reqwherestr");
|
|
4817
4792
|
function reqfield(queryData) {
|
|
4818
|
-
if (_optionalChain([queryData, 'optionalAccess',
|
|
4793
|
+
if (_optionalChain([queryData, 'optionalAccess', _556 => _556.fd])) {
|
|
4819
4794
|
return queryData.fd.split("-");
|
|
4820
4795
|
}
|
|
4821
4796
|
return cfg.field.data;
|
|
@@ -4823,14 +4798,14 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4823
4798
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, reqfield, "reqfield");
|
|
4824
4799
|
function reqwhere(queryData) {
|
|
4825
4800
|
const wheretmp = [];
|
|
4826
|
-
if ((_optionalChain([cfg, 'optionalAccess',
|
|
4801
|
+
if ((_optionalChain([cfg, 'optionalAccess', _557 => _557.type]) === "sqlite" || _optionalChain([cfg, 'optionalAccess', _558 => _558.type]) === "mysql") && _optionalChain([queryData, 'optionalAccess', _559 => _559.wlv])) {
|
|
4827
4802
|
const wlvarr = queryData.wlv.split("-");
|
|
4828
4803
|
wheretmp.push([wlvarr[0], ">", Number(wlvarr[1] || 0)]);
|
|
4829
4804
|
}
|
|
4830
|
-
if (_optionalChain([queryData, 'optionalAccess',
|
|
4805
|
+
if (_optionalChain([queryData, 'optionalAccess', _560 => _560.fl])) {
|
|
4831
4806
|
wheretmp.push([cfg.field.class, "LIKE", reqwherestr(`${queryData.fl}%`)]);
|
|
4832
4807
|
}
|
|
4833
|
-
if (_optionalChain([queryData, 'optionalAccess',
|
|
4808
|
+
if (_optionalChain([queryData, 'optionalAccess', _561 => _561.ss]) && _optionalChain([queryData, 'optionalAccess', _562 => _562.ssty])) {
|
|
4834
4809
|
wheretmp.push([queryData.ssty, "LIKE", reqwherestr(`%${queryData.ss}%`)]);
|
|
4835
4810
|
}
|
|
4836
4811
|
if (wheretmp.length > 1) {
|
|
@@ -4841,16 +4816,16 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4841
4816
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, reqwhere, "reqwhere");
|
|
4842
4817
|
function reqorder(queryData) {
|
|
4843
4818
|
const ordertmp = [];
|
|
4844
|
-
if (_optionalChain([queryData, 'optionalAccess',
|
|
4845
|
-
ordertmp.push([queryData.sx, _optionalChain([queryData, 'optionalAccess',
|
|
4819
|
+
if (_optionalChain([queryData, 'optionalAccess', _563 => _563.sx])) {
|
|
4820
|
+
ordertmp.push([queryData.sx, _optionalChain([queryData, 'optionalAccess', _564 => _564.sxty]) == 1 ? "DESC" : "ASC"]);
|
|
4846
4821
|
}
|
|
4847
4822
|
return ordertmp;
|
|
4848
4823
|
}
|
|
4849
4824
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, reqorder, "reqorder");
|
|
4850
4825
|
function reqlimit(queryData) {
|
|
4851
4826
|
let limittmp = "";
|
|
4852
|
-
let limitps = _optionalChain([queryData, 'optionalAccess',
|
|
4853
|
-
if (_optionalChain([queryData, 'optionalAccess',
|
|
4827
|
+
let limitps = _optionalChain([queryData, 'optionalAccess', _565 => _565.ps]);
|
|
4828
|
+
if (_optionalChain([queryData, 'optionalAccess', _566 => _566.pg])) {
|
|
4854
4829
|
limitps = limitps || 20;
|
|
4855
4830
|
limittmp = `${(queryData.pg - 1) * limitps},${limitps}`;
|
|
4856
4831
|
} else if (limitps) {
|
|
@@ -4862,7 +4837,7 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4862
4837
|
function decodePathSegment(seg) {
|
|
4863
4838
|
try {
|
|
4864
4839
|
return decodeURIComponent(seg);
|
|
4865
|
-
} catch (
|
|
4840
|
+
} catch (e41) {
|
|
4866
4841
|
return seg;
|
|
4867
4842
|
}
|
|
4868
4843
|
}
|
|
@@ -4878,7 +4853,7 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4878
4853
|
if (typeof body === "string") {
|
|
4879
4854
|
try {
|
|
4880
4855
|
body = JSON.parse(body);
|
|
4881
|
-
} catch (
|
|
4856
|
+
} catch (e42) {
|
|
4882
4857
|
return { content: body };
|
|
4883
4858
|
}
|
|
4884
4859
|
}
|
|
@@ -4903,8 +4878,8 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4903
4878
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, fileKeyFromSegment, "fileKeyFromSegment");
|
|
4904
4879
|
function getSqlParamsByUrl(req, opt) {
|
|
4905
4880
|
let tmpSqlParams;
|
|
4906
|
-
const reqArr = _optionalChain([req, 'optionalAccess',
|
|
4907
|
-
const table = (_optionalChain([opt, 'optionalAccess',
|
|
4881
|
+
const reqArr = _optionalChain([req, 'optionalAccess', _567 => _567.url, 'optionalAccess', _568 => _568.split, 'call', _569 => _569("?"), 'access', _570 => _570[0], 'optionalAccess', _571 => _571.split, 'call', _572 => _572("/")]) || [];
|
|
4882
|
+
const table = (_optionalChain([opt, 'optionalAccess', _573 => _573.qrdata, 'optionalAccess', _574 => _574.table]) || _optionalChain([opt, 'optionalAccess', _575 => _575.data, 'optionalAccess', _576 => _576.table]) || reqArr[3]).replaceAll("_", "/");
|
|
4908
4883
|
if (!table) return tmpSqlParams;
|
|
4909
4884
|
tmpSqlParams = {
|
|
4910
4885
|
type: "select",
|
|
@@ -4913,7 +4888,7 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4913
4888
|
if (reqArr[5]) {
|
|
4914
4889
|
if (reqArr[4] === "insert") {
|
|
4915
4890
|
tmpSqlParams.type = reqArr[4];
|
|
4916
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
4891
|
+
if (_optionalChain([cfg, 'optionalAccess', _577 => _577.type]) === "file") {
|
|
4917
4892
|
const { name: bodyName, content } = parseFileBody(opt.data);
|
|
4918
4893
|
const fileKey = fileKeyFromSegment(reqArr[5], bodyName);
|
|
4919
4894
|
tmpSqlParams.field = cfg.field.data;
|
|
@@ -4937,11 +4912,11 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4937
4912
|
}
|
|
4938
4913
|
} else if (reqArr[4] === "update") {
|
|
4939
4914
|
tmpSqlParams.type = reqArr[4];
|
|
4940
|
-
const rowKey = _optionalChain([cfg, 'optionalAccess',
|
|
4915
|
+
const rowKey = _optionalChain([cfg, 'optionalAccess', _578 => _578.type]) === "file" ? fileKeyFromSegment(reqArr[5]) : decodePathSegment(reqArr[5]);
|
|
4941
4916
|
tmpSqlParams.where = [[cfg.field.key, "=", reqwherestr(rowKey)]];
|
|
4942
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
4917
|
+
if (_optionalChain([cfg, 'optionalAccess', _579 => _579.type]) === "file") {
|
|
4943
4918
|
const { content } = parseFileBody(opt.data);
|
|
4944
|
-
const contentField = _optionalChain([cfg, 'access',
|
|
4919
|
+
const contentField = _optionalChain([cfg, 'access', _580 => _580.field, 'access', _581 => _581.data, 'optionalAccess', _582 => _582[1]]) || "content";
|
|
4945
4920
|
tmpSqlParams.set = [[contentField, fileContentString(content)]];
|
|
4946
4921
|
} else {
|
|
4947
4922
|
tmpSqlParams.set = [];
|
|
@@ -4958,18 +4933,18 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4958
4933
|
}
|
|
4959
4934
|
} else if (reqArr[4] === "delete") {
|
|
4960
4935
|
tmpSqlParams.type = reqArr[4];
|
|
4961
|
-
const rowKey = _optionalChain([cfg, 'optionalAccess',
|
|
4936
|
+
const rowKey = _optionalChain([cfg, 'optionalAccess', _583 => _583.type]) === "file" ? fileKeyFromSegment(reqArr[5]) : decodePathSegment(reqArr[5]);
|
|
4962
4937
|
tmpSqlParams.where = [[cfg.field.key, "=", reqwherestr(rowKey)]];
|
|
4963
4938
|
} else {
|
|
4964
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
4939
|
+
if (_optionalChain([cfg, 'optionalAccess', _584 => _584.as]) > 1) {
|
|
4965
4940
|
tmpSqlParams.as = +cfg.as - 1;
|
|
4966
4941
|
}
|
|
4967
4942
|
tmpSqlParams.field = cfg.field.data;
|
|
4968
|
-
const rowKey = _optionalChain([cfg, 'optionalAccess',
|
|
4943
|
+
const rowKey = _optionalChain([cfg, 'optionalAccess', _585 => _585.type]) === "file" ? fileKeyFromSegment(reqArr[5]) : decodePathSegment(reqArr[5]);
|
|
4969
4944
|
tmpSqlParams.where = [[cfg.field.key, "=", reqwherestr(rowKey)]];
|
|
4970
4945
|
}
|
|
4971
4946
|
} else {
|
|
4972
|
-
tmpSqlParams.as = _optionalChain([cfg, 'optionalAccess',
|
|
4947
|
+
tmpSqlParams.as = _optionalChain([cfg, 'optionalAccess', _586 => _586.as]);
|
|
4973
4948
|
tmpSqlParams.field = reqfield(opt.data);
|
|
4974
4949
|
tmpSqlParams.where = reqwhere(opt.data);
|
|
4975
4950
|
tmpSqlParams.order = reqorder(opt.data);
|
|
@@ -4979,8 +4954,8 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
4979
4954
|
}
|
|
4980
4955
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getSqlParamsByUrl, "getSqlParamsByUrl");
|
|
4981
4956
|
function dbFresh(req, resdb) {
|
|
4982
|
-
if (_optionalChain([req, 'optionalAccess',
|
|
4983
|
-
const list = Array.isArray(resdb) ? resdb : _optionalChain([resdb, 'optionalAccess',
|
|
4957
|
+
if (_optionalChain([req, 'optionalAccess', _587 => _587.url, 'optionalAccess', _588 => _588.includes, 'call', _589 => _589("/selectlist/")])) {
|
|
4958
|
+
const list = Array.isArray(resdb) ? resdb : _optionalChain([resdb, 'optionalAccess', _590 => _590.data]);
|
|
4984
4959
|
if (Array.isArray(list)) {
|
|
4985
4960
|
const names = list.map((el) => {
|
|
4986
4961
|
if (typeof el === "string") {
|
|
@@ -5003,12 +4978,12 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
5003
4978
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, dbFresh, "dbFresh");
|
|
5004
4979
|
function normalizeSelectResult(params, resdb) {
|
|
5005
4980
|
let data = resdb;
|
|
5006
|
-
if (_optionalChain([params, 'optionalAccess',
|
|
4981
|
+
if (_optionalChain([params, 'optionalAccess', _591 => _591.where, 'optionalAccess', _592 => _592.length]) && Array.isArray(data) && data.length === 1) {
|
|
5007
4982
|
data = data[0];
|
|
5008
4983
|
}
|
|
5009
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
5010
|
-
const nameKey = _optionalChain([cfg, 'access',
|
|
5011
|
-
const contentKey = _optionalChain([cfg, 'access',
|
|
4984
|
+
if (_optionalChain([cfg, 'optionalAccess', _593 => _593.type]) === "file" && data && typeof data === "object" && !Array.isArray(data)) {
|
|
4985
|
+
const nameKey = _optionalChain([cfg, 'access', _594 => _594.field, 'optionalAccess', _595 => _595.data, 'optionalAccess', _596 => _596[0]]) || "name";
|
|
4986
|
+
const contentKey = _optionalChain([cfg, 'access', _597 => _597.field, 'optionalAccess', _598 => _598.data, 'optionalAccess', _599 => _599[1]]) || "content";
|
|
5012
4987
|
if (data[nameKey] != null) {
|
|
5013
4988
|
data[nameKey] = bareFileName(String(data[nameKey]));
|
|
5014
4989
|
}
|
|
@@ -5018,7 +4993,7 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
5018
4993
|
if (text.startsWith("{") || text.startsWith("[")) {
|
|
5019
4994
|
try {
|
|
5020
4995
|
data[contentKey] = JSON.parse(text);
|
|
5021
|
-
} catch (
|
|
4996
|
+
} catch (e43) {
|
|
5022
4997
|
}
|
|
5023
4998
|
}
|
|
5024
4999
|
}
|
|
@@ -5027,7 +5002,7 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
5027
5002
|
}
|
|
5028
5003
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, normalizeSelectResult, "normalizeSelectResult");
|
|
5029
5004
|
function dbCodePm(req, resdb) {
|
|
5030
|
-
if (_optionalChain([req, 'optionalAccess',
|
|
5005
|
+
if (_optionalChain([req, 'optionalAccess', _600 => _600.Userinfo]) && _optionalChain([req, 'optionalAccess', _601 => _601.Userinfo, 'access', _602 => _602[2]])) {
|
|
5031
5006
|
resdb.data = $asai.$lib.AsCode.asencode(JSON.stringify(resdb.data), req.Userinfo[2]);
|
|
5032
5007
|
}
|
|
5033
5008
|
return resdb;
|
|
@@ -5039,8 +5014,8 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
5039
5014
|
DataServer.sqlDb(params).then((resdb) => {
|
|
5040
5015
|
res.end(JSON.stringify($asai.$lib.As.ctxSuccess(dbCodePm(req, dbFresh(req, resdb)), opt)));
|
|
5041
5016
|
}).catch((errdb) => {
|
|
5042
|
-
const msg = String(_optionalChain([errdb, 'optionalAccess',
|
|
5043
|
-
if (_optionalChain([params, 'optionalAccess',
|
|
5017
|
+
const msg = String(_optionalChain([errdb, 'optionalAccess', _603 => _603.message]) || errdb || "");
|
|
5018
|
+
if (_optionalChain([params, 'optionalAccess', _604 => _604.type]) === "select" && msg.includes("no such table")) {
|
|
5044
5019
|
res.end(JSON.stringify($asai.$lib.As.ctxSuccess([], opt)));
|
|
5045
5020
|
return;
|
|
5046
5021
|
}
|
|
@@ -5057,29 +5032,29 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
5057
5032
|
try {
|
|
5058
5033
|
DataServer.sqlDb(params).then((resdb) => {
|
|
5059
5034
|
let resData = normalizeSelectResult(params, dbFresh(req, resdb));
|
|
5060
|
-
if (_optionalChain([params, 'optionalAccess',
|
|
5035
|
+
if (_optionalChain([params, 'optionalAccess', _605 => _605.as]) === 2 && _optionalChain([params, 'optionalAccess', _606 => _606.field, 'optionalAccess', _607 => _607.length]) > 1) {
|
|
5061
5036
|
let limitArr = [];
|
|
5062
|
-
if (_optionalChain([params, 'access',
|
|
5063
|
-
limitArr = [0, +_optionalChain([params, 'access',
|
|
5037
|
+
if (_optionalChain([params, 'access', _608 => _608.limit, 'optionalAccess', _609 => _609.split, 'call', _610 => _610(","), 'optionalAccess', _611 => _611.length]) < 2) {
|
|
5038
|
+
limitArr = [0, +_optionalChain([params, 'access', _612 => _612.limit, 'optionalAccess', _613 => _613.split, 'call', _614 => _614(","), 'optionalAccess', _615 => _615[0]])];
|
|
5064
5039
|
} else {
|
|
5065
5040
|
limitArr = params.limit.split(",");
|
|
5066
5041
|
limitArr = [+limitArr[0], +limitArr[0] + +limitArr[1]];
|
|
5067
5042
|
}
|
|
5068
|
-
if (_optionalChain([resData, 'access',
|
|
5043
|
+
if (_optionalChain([resData, 'access', _616 => _616.data, 'optionalAccess', _617 => _617.length])) {
|
|
5069
5044
|
resData.data = resData.data.slice(+limitArr[0], +limitArr[1]);
|
|
5070
5045
|
}
|
|
5071
5046
|
}
|
|
5072
5047
|
resData = dbCodePm(req, resData);
|
|
5073
5048
|
res.end(JSON.stringify($asai.$lib.As.ctxSuccess(resData, opt)));
|
|
5074
5049
|
}).catch((errdb) => {
|
|
5075
|
-
const msg = String(_optionalChain([errdb, 'optionalAccess',
|
|
5076
|
-
if (_optionalChain([params, 'optionalAccess',
|
|
5050
|
+
const msg = String(_optionalChain([errdb, 'optionalAccess', _618 => _618.message]) || errdb || "");
|
|
5051
|
+
if (_optionalChain([params, 'optionalAccess', _619 => _619.type]) === "select" && msg.includes("no such table")) {
|
|
5077
5052
|
res.end(JSON.stringify($asai.$lib.As.ctxSuccess([], opt)));
|
|
5078
5053
|
return;
|
|
5079
5054
|
}
|
|
5080
5055
|
res.end(JSON.stringify($asai.$lib.As.ctxFail(errdb)));
|
|
5081
5056
|
});
|
|
5082
|
-
} catch (
|
|
5057
|
+
} catch (e44) {
|
|
5083
5058
|
res.end(JSON.stringify({ code: 901 }));
|
|
5084
5059
|
}
|
|
5085
5060
|
} else {
|
|
@@ -5088,7 +5063,7 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
5088
5063
|
}
|
|
5089
5064
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, runDefaultGet, "runDefaultGet");
|
|
5090
5065
|
function post(req, res, hostdir, opt) {
|
|
5091
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
5066
|
+
if (_optionalChain([cfg, 'optionalAccess', _620 => _620.post]) && typeof cfg.post === "function") {
|
|
5092
5067
|
Promise.resolve(cfg.post(req, res, hostdir, opt, DataServer)).then((reqstat) => {
|
|
5093
5068
|
if (!reqstat) runDefaultPost(req, res, opt);
|
|
5094
5069
|
}).catch((errdb) => {
|
|
@@ -5100,7 +5075,7 @@ var AsDb_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($asai,
|
|
|
5100
5075
|
}
|
|
5101
5076
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, post, "post");
|
|
5102
5077
|
function get(req, res, hostdir, opt) {
|
|
5103
|
-
if (_optionalChain([cfg, 'optionalAccess',
|
|
5078
|
+
if (_optionalChain([cfg, 'optionalAccess', _621 => _621.get]) && typeof cfg.get === "function") {
|
|
5104
5079
|
Promise.resolve(cfg.get(req, res, hostdir, opt, DataServer)).then((reqstat) => {
|
|
5105
5080
|
if (!reqstat) runDefaultGet(req, res, opt);
|
|
5106
5081
|
}).catch((errdb) => {
|
|
@@ -5125,7 +5100,7 @@ var reqWork_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($as
|
|
|
5125
5100
|
}
|
|
5126
5101
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, hostDefault2, "hostDefault");
|
|
5127
5102
|
function getPathFromOpt(opt) {
|
|
5128
|
-
const rawPath = _optionalChain([opt, 'access',
|
|
5103
|
+
const rawPath = _optionalChain([opt, 'access', _622 => _622.qrdata, 'optionalAccess', _623 => _623.path]) || _optionalChain([opt, 'access', _624 => _624.data, 'optionalAccess', _625 => _625.path]);
|
|
5129
5104
|
return decodeURIComponent(rawPath);
|
|
5130
5105
|
}
|
|
5131
5106
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getPathFromOpt, "getPathFromOpt");
|
|
@@ -5135,18 +5110,18 @@ var reqWork_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($as
|
|
|
5135
5110
|
}
|
|
5136
5111
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, sendSuccess, "sendSuccess");
|
|
5137
5112
|
function sendErr(res, ec, params, opt) {
|
|
5138
|
-
const ErrorCode = _optionalChain([$asai, 'access',
|
|
5139
|
-
_optionalChain([ErrorCode, 'optionalAccess',
|
|
5140
|
-
_optionalChain([ErrorCode, 'optionalAccess',
|
|
5113
|
+
const ErrorCode = _optionalChain([$asai, 'access', _626 => _626.$lib, 'optionalAccess', _627 => _627.ErrorCode]);
|
|
5114
|
+
_optionalChain([ErrorCode, 'optionalAccess', _628 => _628.loadErrorCodes, 'optionalCall', _629 => _629($asai)]);
|
|
5115
|
+
_optionalChain([ErrorCode, 'optionalAccess', _630 => _630.logError, 'optionalCall', _631 => _631($asai, ec, Array.isArray(params) ? params.map(String) : params != null ? [String(params)] : void 0)]);
|
|
5141
5116
|
const response = $asai.$lib.As.ctxErr(ec, params, opt);
|
|
5142
5117
|
res.end(JSON.stringify(response));
|
|
5143
5118
|
}
|
|
5144
5119
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, sendErr, "sendErr");
|
|
5145
5120
|
function sendFail(res, err, opt) {
|
|
5146
|
-
const ErrorCode = _optionalChain([$asai, 'access',
|
|
5147
|
-
_optionalChain([ErrorCode, 'optionalAccess',
|
|
5148
|
-
const normalized = _optionalChain([ErrorCode, 'optionalAccess',
|
|
5149
|
-
if (_optionalChain([normalized, 'optionalAccess',
|
|
5121
|
+
const ErrorCode = _optionalChain([$asai, 'access', _632 => _632.$lib, 'optionalAccess', _633 => _633.ErrorCode]);
|
|
5122
|
+
_optionalChain([ErrorCode, 'optionalAccess', _634 => _634.loadErrorCodes, 'optionalCall', _635 => _635($asai)]);
|
|
5123
|
+
const normalized = _optionalChain([ErrorCode, 'optionalAccess', _636 => _636.normalizeErrPayload, 'optionalCall', _637 => _637(err)]);
|
|
5124
|
+
if (_optionalChain([normalized, 'optionalAccess', _638 => _638.ec])) {
|
|
5150
5125
|
return sendErr(res, normalized.ec, normalized.pm, opt);
|
|
5151
5126
|
}
|
|
5152
5127
|
const response = $asai.$lib.As.ctxFail(err);
|
|
@@ -5154,7 +5129,7 @@ var reqWork_default = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, ($as
|
|
|
5154
5129
|
}
|
|
5155
5130
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, sendFail, "sendFail");
|
|
5156
5131
|
function mnLog(...arg) {
|
|
5157
|
-
(_optionalChain([$asai, 'optionalAccess',
|
|
5132
|
+
(_optionalChain([$asai, 'optionalAccess', _639 => _639.$log]) || console.log)(...arg);
|
|
5158
5133
|
}
|
|
5159
5134
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, mnLog, "mnLog");
|
|
5160
5135
|
return { hostDefault: hostDefault2, getPathFromOpt, sendSuccess, sendFail, sendErr, mnLog };
|
|
@@ -5187,7 +5162,7 @@ async function pathExists(filePath) {
|
|
|
5187
5162
|
try {
|
|
5188
5163
|
await _promises2.default.access(nodePath2.default.normalize(filePath));
|
|
5189
5164
|
return true;
|
|
5190
|
-
} catch (
|
|
5165
|
+
} catch (e45) {
|
|
5191
5166
|
return false;
|
|
5192
5167
|
}
|
|
5193
5168
|
}
|
|
@@ -5254,7 +5229,7 @@ async function removeFile(filePath) {
|
|
|
5254
5229
|
try {
|
|
5255
5230
|
await _promises2.default.unlink(nodePath2.default.normalize(filePath));
|
|
5256
5231
|
} catch (err) {
|
|
5257
|
-
if (_optionalChain([err, 'optionalAccess',
|
|
5232
|
+
if (_optionalChain([err, 'optionalAccess', _640 => _640.code]) !== "ENOENT") throw err;
|
|
5258
5233
|
}
|
|
5259
5234
|
}
|
|
5260
5235
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, removeFile, "removeFile");
|
|
@@ -5292,7 +5267,7 @@ function isPkgRuntime() {
|
|
|
5292
5267
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, isPkgRuntime, "isPkgRuntime");
|
|
5293
5268
|
function getPkgSnapshotDir() {
|
|
5294
5269
|
if (!isPkgRuntime()) return void 0;
|
|
5295
|
-
const entry = _nullishCoalesce(_optionalChain([process, 'access',
|
|
5270
|
+
const entry = _nullishCoalesce(_optionalChain([process, 'access', _641 => _641.pkg, 'optionalAccess', _642 => _642.entrypoint]), () => ( _optionalChain([process, 'access', _643 => _643.pkg, 'optionalAccess', _644 => _644.defaultEntrypoint])));
|
|
5296
5271
|
if (!entry) return void 0;
|
|
5297
5272
|
return nodePath4.resolve(nodePath4.dirname(entry));
|
|
5298
5273
|
}
|
|
@@ -5341,7 +5316,7 @@ function getPrimaryServerRoot() {
|
|
|
5341
5316
|
if (fs10.statSync(nodePath4.join(base, "websys")).isDirectory()) {
|
|
5342
5317
|
return base;
|
|
5343
5318
|
}
|
|
5344
|
-
} catch (
|
|
5319
|
+
} catch (e46) {
|
|
5345
5320
|
}
|
|
5346
5321
|
}
|
|
5347
5322
|
if (isPkgRuntime()) {
|
|
@@ -5646,7 +5621,7 @@ function dbDriver(opt = {}) {
|
|
|
5646
5621
|
this.baseDirAbs = path6.resolve(process.cwd(), config.dir);
|
|
5647
5622
|
}
|
|
5648
5623
|
dbLog(...args) {
|
|
5649
|
-
(_optionalChain([this, 'access',
|
|
5624
|
+
(_optionalChain([this, 'access', _645 => _645.config, 'optionalAccess', _646 => _646.$asai, 'optionalAccess', _647 => _647.$log]) || console.log)("FILE", ...args);
|
|
5650
5625
|
}
|
|
5651
5626
|
checkFile(file) {
|
|
5652
5627
|
return fs11.existsSync(this.getAbsPath(file, false));
|
|
@@ -5712,7 +5687,7 @@ function dbDriver(opt = {}) {
|
|
|
5712
5687
|
}
|
|
5713
5688
|
getReadPath(file, sql) {
|
|
5714
5689
|
const candidates = [];
|
|
5715
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
5690
|
+
if (_optionalChain([sql, 'optionalAccess', _648 => _648.filename])) {
|
|
5716
5691
|
candidates.push({ dir: path6.join(file, sql.filename) });
|
|
5717
5692
|
candidates.push({ dir: path6.join(file + ".delete" + this.fileExt, sql.filename) });
|
|
5718
5693
|
} else {
|
|
@@ -5732,20 +5707,20 @@ function dbDriver(opt = {}) {
|
|
|
5732
5707
|
if (!read2.path) {
|
|
5733
5708
|
return { path: "", dir: read2.dir };
|
|
5734
5709
|
}
|
|
5735
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
5710
|
+
if (_optionalChain([sql, 'optionalAccess', _649 => _649.filename])) {
|
|
5736
5711
|
return { path: path6.dirname(read2.path), dir: path6.dirname(read2.dir) };
|
|
5737
5712
|
}
|
|
5738
5713
|
return { path: read2.path, dir: read2.dir };
|
|
5739
5714
|
}
|
|
5740
5715
|
getNewPath(file, sql) {
|
|
5741
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
5716
|
+
if (_optionalChain([sql, 'optionalAccess', _650 => _650.filename])) {
|
|
5742
5717
|
return this.getAbsPath(path6.join(file, sql.filename), true);
|
|
5743
5718
|
}
|
|
5744
5719
|
return this.getAbsPath(file, true);
|
|
5745
5720
|
}
|
|
5746
5721
|
write(file, data, sql) {
|
|
5747
5722
|
try {
|
|
5748
|
-
const filePath = _optionalChain([sql, 'optionalAccess',
|
|
5723
|
+
const filePath = _optionalChain([sql, 'optionalAccess', _651 => _651.type]) === "insert" ? this.getNewPath(file, sql) : this.getReadPath(file, sql).path || this.getNewPath(file, sql);
|
|
5749
5724
|
this.dbLog("write", "[WRITE]", filePath);
|
|
5750
5725
|
fs11.writeFileSync(filePath, data, "utf8");
|
|
5751
5726
|
return "ok";
|
|
@@ -5775,11 +5750,11 @@ function dbDriver(opt = {}) {
|
|
|
5775
5750
|
if (!del.path) {
|
|
5776
5751
|
return "";
|
|
5777
5752
|
}
|
|
5778
|
-
if (this.fileDel && _optionalChain([sql, 'optionalAccess',
|
|
5753
|
+
if (this.fileDel && _optionalChain([sql, 'optionalAccess', _652 => _652.deltrue])) {
|
|
5779
5754
|
const target = del.path + ".delete" + this.fileExt;
|
|
5780
5755
|
this.dbLog("soft delete", "[SOFT DELETE]", `${del.path} -> ${target}`);
|
|
5781
5756
|
fs11.renameSync(del.path, target);
|
|
5782
|
-
} else if (_optionalChain([sql, 'optionalAccess',
|
|
5757
|
+
} else if (_optionalChain([sql, 'optionalAccess', _653 => _653.filename])) {
|
|
5783
5758
|
this.deldir(del.dir);
|
|
5784
5759
|
} else {
|
|
5785
5760
|
this.dbLog("delete", "[DELETE]", del.path);
|
|
@@ -5821,8 +5796,8 @@ function dbDriver(opt = {}) {
|
|
|
5821
5796
|
let entries;
|
|
5822
5797
|
try {
|
|
5823
5798
|
entries = fs11.readdirSync(absDir, { withFileTypes: true });
|
|
5824
|
-
} catch (
|
|
5825
|
-
return _optionalChain([sql, 'optionalAccess',
|
|
5799
|
+
} catch (e47) {
|
|
5800
|
+
return _optionalChain([sql, 'optionalAccess', _654 => _654.list]) ? { open: [], delete: [] } : [];
|
|
5826
5801
|
}
|
|
5827
5802
|
const result = { open: [], delete: [] };
|
|
5828
5803
|
const deleteSuffix = ".delete" + this.fileExt;
|
|
@@ -5837,14 +5812,14 @@ function dbDriver(opt = {}) {
|
|
|
5837
5812
|
const data = fs11.readFileSync(fullPath, "utf8");
|
|
5838
5813
|
const entryData = { data, file: baseName };
|
|
5839
5814
|
if (isDelete) {
|
|
5840
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
5815
|
+
if (_optionalChain([sql, 'optionalAccess', _655 => _655.list])) result.delete.push(entryData);
|
|
5841
5816
|
} else {
|
|
5842
5817
|
result.open.push(entryData);
|
|
5843
5818
|
}
|
|
5844
|
-
} catch (
|
|
5819
|
+
} catch (e48) {
|
|
5845
5820
|
}
|
|
5846
5821
|
}
|
|
5847
|
-
return _optionalChain([sql, 'optionalAccess',
|
|
5822
|
+
return _optionalChain([sql, 'optionalAccess', _656 => _656.list]) ? result : result.open;
|
|
5848
5823
|
} catch (e) {
|
|
5849
5824
|
this.dbLog("list failed", "[LIST ERROR]", e);
|
|
5850
5825
|
return e;
|
|
@@ -5854,7 +5829,7 @@ function dbDriver(opt = {}) {
|
|
|
5854
5829
|
getFileNameFromWhere(where) {
|
|
5855
5830
|
if (!where || !Array.isArray(where)) return "";
|
|
5856
5831
|
const first = where.find((item) => Array.isArray(item));
|
|
5857
|
-
const raw = _optionalChain([first, 'optionalAccess',
|
|
5832
|
+
const raw = _optionalChain([first, 'optionalAccess', _657 => _657[2]]);
|
|
5858
5833
|
if (typeof raw === "string") {
|
|
5859
5834
|
return raw.replace(/^'+|'+$/g, "");
|
|
5860
5835
|
}
|
|
@@ -5879,22 +5854,22 @@ function dbDriver(opt = {}) {
|
|
|
5879
5854
|
const data = sql.set[0][1];
|
|
5880
5855
|
result = this.write(this.tableFilePath(sql.table, file), data, sql);
|
|
5881
5856
|
} else if (sql.type === "select") {
|
|
5882
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
5857
|
+
if (_optionalChain([sql, 'optionalAccess', _658 => _658.where, 'optionalAccess', _659 => _659.length]) && _optionalChain([sql, 'optionalAccess', _660 => _660.as]) !== 2) {
|
|
5883
5858
|
const file = this.getFileNameFromWhere(sql.where);
|
|
5884
5859
|
const readRes = this.read(this.tableFilePath(sql.table, file), sql);
|
|
5885
5860
|
const resObj = {};
|
|
5886
|
-
if (_optionalChain([readRes, 'optionalAccess',
|
|
5861
|
+
if (_optionalChain([readRes, 'optionalAccess', _661 => _661[0], 'optionalAccess', _662 => _662.file]) && !readRes.error) {
|
|
5887
5862
|
if (sql.as === 1) {
|
|
5888
5863
|
try {
|
|
5889
5864
|
const parsed = JSON.parse(readRes[0].data);
|
|
5890
|
-
if (_optionalChain([sql, 'access',
|
|
5865
|
+
if (_optionalChain([sql, 'access', _663 => _663.field, 'optionalAccess', _664 => _664.length])) {
|
|
5891
5866
|
sql.field.forEach((f) => {
|
|
5892
5867
|
resObj[f] = _nullishCoalesce(parsed[f], () => ( ""));
|
|
5893
5868
|
});
|
|
5894
5869
|
} else {
|
|
5895
5870
|
Object.assign(resObj, parsed);
|
|
5896
5871
|
}
|
|
5897
|
-
} catch (
|
|
5872
|
+
} catch (e49) {
|
|
5898
5873
|
}
|
|
5899
5874
|
} else {
|
|
5900
5875
|
const fields = sql.field;
|
|
@@ -5908,7 +5883,7 @@ function dbDriver(opt = {}) {
|
|
|
5908
5883
|
} else {
|
|
5909
5884
|
const listRes = this.list(tableDir, sql);
|
|
5910
5885
|
if (listRes && !listRes.error) {
|
|
5911
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
5886
|
+
if (_optionalChain([sql, 'optionalAccess', _665 => _665.list])) {
|
|
5912
5887
|
const mapEntry = /* @__PURE__ */ _chunkSMVZ3ZDJcjs.__name.call(void 0, (el) => {
|
|
5913
5888
|
const fields = sql.field;
|
|
5914
5889
|
const item = { [fields[0]]: el.file };
|
|
@@ -5919,9 +5894,9 @@ function dbDriver(opt = {}) {
|
|
|
5919
5894
|
if (listRes.delete) listRes.delete = listRes.delete.map(mapEntry);
|
|
5920
5895
|
result = listRes;
|
|
5921
5896
|
} else {
|
|
5922
|
-
if (_optionalChain([sql, 'optionalAccess',
|
|
5897
|
+
if (_optionalChain([sql, 'optionalAccess', _666 => _666.as]) === 2) {
|
|
5923
5898
|
let items = listRes;
|
|
5924
|
-
if (_optionalChain([sql, 'access',
|
|
5899
|
+
if (_optionalChain([sql, 'access', _667 => _667.where, 'optionalAccess', _668 => _668.length])) {
|
|
5925
5900
|
const where = sql.where;
|
|
5926
5901
|
const whereType = typeof where[0] === "string" ? where[0] : "and";
|
|
5927
5902
|
items = items.filter((el) => {
|
|
@@ -5935,7 +5910,7 @@ function dbDriver(opt = {}) {
|
|
|
5935
5910
|
let fieldVal = "";
|
|
5936
5911
|
try {
|
|
5937
5912
|
fieldVal = _nullishCoalesce(JSON.parse(el.data)[field], () => ( ""));
|
|
5938
|
-
} catch (
|
|
5913
|
+
} catch (e50) {
|
|
5939
5914
|
}
|
|
5940
5915
|
const condMatch = String(fieldVal).includes(searchVal);
|
|
5941
5916
|
if (whereType === "and") {
|
|
@@ -5953,18 +5928,18 @@ function dbDriver(opt = {}) {
|
|
|
5953
5928
|
const obj = {};
|
|
5954
5929
|
try {
|
|
5955
5930
|
const parsed = JSON.parse(el.data);
|
|
5956
|
-
if (_optionalChain([sql, 'access',
|
|
5931
|
+
if (_optionalChain([sql, 'access', _669 => _669.field, 'optionalAccess', _670 => _670.length])) {
|
|
5957
5932
|
sql.field.forEach((f) => {
|
|
5958
5933
|
obj[f] = _nullishCoalesce(parsed[f], () => ( ""));
|
|
5959
5934
|
});
|
|
5960
5935
|
} else {
|
|
5961
5936
|
Object.assign(obj, parsed);
|
|
5962
5937
|
}
|
|
5963
|
-
} catch (
|
|
5938
|
+
} catch (e51) {
|
|
5964
5939
|
}
|
|
5965
5940
|
return obj;
|
|
5966
5941
|
});
|
|
5967
|
-
if (_optionalChain([sql, 'access',
|
|
5942
|
+
if (_optionalChain([sql, 'access', _671 => _671.order, 'optionalAccess', _672 => _672.length])) {
|
|
5968
5943
|
const orderField = sql.order[0];
|
|
5969
5944
|
const orderFieldName = typeof orderField === "string" ? orderField : orderField[0];
|
|
5970
5945
|
const direction = typeof orderField === "string" ? "ASC" : String(orderField[1]).toUpperCase();
|
|
@@ -5985,7 +5960,7 @@ function dbDriver(opt = {}) {
|
|
|
5985
5960
|
}
|
|
5986
5961
|
}
|
|
5987
5962
|
} else {
|
|
5988
|
-
result = _optionalChain([sql, 'optionalAccess',
|
|
5963
|
+
result = _optionalChain([sql, 'optionalAccess', _673 => _673.list]) ? { open: [], delete: [] } : [];
|
|
5989
5964
|
}
|
|
5990
5965
|
}
|
|
5991
5966
|
}
|
|
@@ -6041,7 +6016,7 @@ function sysserver($asai, opt = {}) {
|
|
|
6041
6016
|
if (!$asai.$lib) $asai.$lib = {};
|
|
6042
6017
|
$asai.$lib = { ...lib_default, ...$asai.$lib, ...opt || {} };
|
|
6043
6018
|
$asai.dataserver = db_default;
|
|
6044
|
-
_optionalChain([$asai, 'access',
|
|
6019
|
+
_optionalChain([$asai, 'access', _674 => _674.$lib, 'access', _675 => _675.ErrorCode, 'optionalAccess', _676 => _676.loadErrorCodes, 'optionalCall', _677 => _677($asai)]);
|
|
6045
6020
|
if (!$asai.$lib.api) $asai.$lib.api = {};
|
|
6046
6021
|
$asai.$lib.api = { ...api_default, ...$asai.$lib.api };
|
|
6047
6022
|
if (!$asai.$lib.ws) $asai.$lib.ws = {};
|
|
@@ -6234,7 +6209,7 @@ function normalizeDataStoresConfig(cfg) {
|
|
|
6234
6209
|
}
|
|
6235
6210
|
if (userStore.opt.create == null) userStore.opt.create = 1;
|
|
6236
6211
|
}
|
|
6237
|
-
if (!stores.log && _optionalChain([cfg, 'access',
|
|
6212
|
+
if (!stores.log && _optionalChain([cfg, 'access', _678 => _678.logger, 'optionalAccess', _679 => _679.store])) {
|
|
6238
6213
|
const s = cfg.logger.store;
|
|
6239
6214
|
stores.log = {
|
|
6240
6215
|
type: s.type || "file",
|
|
@@ -6298,13 +6273,13 @@ function validateHostConfig(cfg) {
|
|
|
6298
6273
|
if (cfg.asaisn != null) {
|
|
6299
6274
|
errors.push("asaisn \u7981\u6B62\u5199\u5165 asaihost.json\uFF0C\u8BF7\u4F7F\u7528 ASAI_ASAISN");
|
|
6300
6275
|
}
|
|
6301
|
-
if (_optionalChain([cfg, 'access',
|
|
6276
|
+
if (_optionalChain([cfg, 'access', _680 => _680.aes, 'optionalAccess', _681 => _681.keybase64]) != null) {
|
|
6302
6277
|
errors.push("aes.keybase64 \u7981\u6B62\u5199\u5165 asaihost.json\uFF0C\u8BF7\u4F7F\u7528 ASAI_AES_KEYBASE64");
|
|
6303
6278
|
}
|
|
6304
|
-
if (_optionalChain([cfg, 'access',
|
|
6279
|
+
if (_optionalChain([cfg, 'access', _682 => _682.httpscert, 'optionalAccess', _683 => _683.key]) != null || _optionalChain([cfg, 'access', _684 => _684.httpscert, 'optionalAccess', _685 => _685.cert]) != null) {
|
|
6305
6280
|
errors.push("httpscert.key/cert \u7981\u6B62\u5185\u8054\u4E8E asaihost.json\uFF0C\u8BF7\u4F7F\u7528 keyPath/certPath \u6216\u73AF\u5883\u53D8\u91CF");
|
|
6306
6281
|
}
|
|
6307
|
-
if (_optionalChain([cfg, 'access',
|
|
6282
|
+
if (_optionalChain([cfg, 'access', _686 => _686.security, 'optionalAccess', _687 => _687.sessionSecret]) != null) {
|
|
6308
6283
|
errors.push("security.sessionSecret \u7981\u6B62\u5199\u5165 asaihost.json\uFF0C\u8BF7\u4F7F\u7528 ASAI_SESSION_SECRET");
|
|
6309
6284
|
}
|
|
6310
6285
|
if (Array.isArray(cfg.wssec) && typeof cfg.wssec[0] === "string" && cfg.wssec[0].length > 0) {
|
|
@@ -6359,10 +6334,10 @@ function validateHostConfig(cfg) {
|
|
|
6359
6334
|
validateHostSiteLimits(name, h, errors);
|
|
6360
6335
|
}
|
|
6361
6336
|
}
|
|
6362
|
-
if (_optionalChain([cfg, 'access',
|
|
6337
|
+
if (_optionalChain([cfg, 'access', _688 => _688.logger, 'optionalAccess', _689 => _689.sample]) && typeof cfg.logger.sample !== "object") {
|
|
6363
6338
|
errors.push('logger.sample \u5FC5\u987B\u4E3A\u5BF9\u8C61\uFF08\u5982 { "REQ_OTHER": 0.1 }\uFF09');
|
|
6364
6339
|
}
|
|
6365
|
-
if (_optionalChain([cfg, 'access',
|
|
6340
|
+
if (_optionalChain([cfg, 'access', _690 => _690.logger, 'optionalAccess', _691 => _691.skip]) != null && !Array.isArray(cfg.logger.skip)) {
|
|
6366
6341
|
errors.push('logger.skip \u5FC5\u987B\u4E3A\u5B57\u7B26\u4E32\u6570\u7EC4\uFF08\u5982 ["/sys/info/metrics"]\uFF09');
|
|
6367
6342
|
}
|
|
6368
6343
|
if (cfg.proxyhosts && typeof cfg.proxyhosts === "object") {
|
|
@@ -6396,7 +6371,7 @@ _chunkSMVZ3ZDJcjs.__name.call(void 0, validateHostSiteLimits, "validateHostSiteL
|
|
|
6396
6371
|
function validateProductionSecurity(cfg) {
|
|
6397
6372
|
const errors = [];
|
|
6398
6373
|
if (process.env.NODE_ENV !== "production") return errors;
|
|
6399
|
-
const sec = _optionalChain([cfg, 'optionalAccess',
|
|
6374
|
+
const sec = _optionalChain([cfg, 'optionalAccess', _692 => _692.security]);
|
|
6400
6375
|
if (!sec || typeof sec !== "object") {
|
|
6401
6376
|
errors.push("\u751F\u4EA7\u73AF\u5883\u5FC5\u987B\u914D\u7F6E security \u5BF9\u8C61");
|
|
6402
6377
|
return errors;
|
|
@@ -6407,7 +6382,7 @@ function validateProductionSecurity(cfg) {
|
|
|
6407
6382
|
if (sec.allowRegister === 1) {
|
|
6408
6383
|
errors.push("\u751F\u4EA7\u73AF\u5883 security.allowRegister \u5E94\u4E3A 0\uFF08CR 1.3 \u7981\u6B62\u5F00\u653E\u6CE8\u518C\uFF09");
|
|
6409
6384
|
}
|
|
6410
|
-
if (!_optionalChain([sec, 'access',
|
|
6385
|
+
if (!_optionalChain([sec, 'access', _693 => _693.quota, 'optionalAccess', _694 => _694.enabled])) {
|
|
6411
6386
|
errors.push("\u751F\u4EA7\u73AF\u5883 security.quota.enabled \u5E94\u4E3A 1\uFF08CR 7.1 \u8D44\u6E90\u9650\u5236\uFF09");
|
|
6412
6387
|
}
|
|
6413
6388
|
if (sec.csp !== 1) {
|
|
@@ -6416,7 +6391,7 @@ function validateProductionSecurity(cfg) {
|
|
|
6416
6391
|
if (typeof sec.minUserLevel !== "number" || sec.minUserLevel < 0) {
|
|
6417
6392
|
errors.push("\u751F\u4EA7\u73AF\u5883 security.minUserLevel \u5E94\u663E\u5F0F\u914D\u7F6E");
|
|
6418
6393
|
}
|
|
6419
|
-
if (sec.forceWss === 1 && !_optionalChain([cfg, 'optionalAccess',
|
|
6394
|
+
if (sec.forceWss === 1 && !_optionalChain([cfg, 'optionalAccess', _695 => _695.httpscert, 'optionalAccess', _696 => _696.keyPath]) && !_optionalChain([cfg, 'optionalAccess', _697 => _697.httpscert, 'optionalAccess', _698 => _698.key])) {
|
|
6420
6395
|
errors.push("\u751F\u4EA7\u73AF\u5883 security.forceWss=1 \u65F6\u9700\u914D\u7F6E HTTPS \u8BC1\u4E66");
|
|
6421
6396
|
}
|
|
6422
6397
|
return errors;
|
|
@@ -6435,12 +6410,12 @@ var DEFAULT_RECONNECT = {
|
|
|
6435
6410
|
rs485: { enabled: true, maxRetries: 60, initialDelay: 3e3, maxDelay: 3e4, factor: 2 }
|
|
6436
6411
|
};
|
|
6437
6412
|
function getTransportBlock(cfg, kind) {
|
|
6438
|
-
const block = _optionalChain([cfg, 'optionalAccess',
|
|
6413
|
+
const block = _optionalChain([cfg, 'optionalAccess', _699 => _699[kind]]);
|
|
6439
6414
|
return block && typeof block === "object" ? block : null;
|
|
6440
6415
|
}
|
|
6441
6416
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getTransportBlock, "getTransportBlock");
|
|
6442
6417
|
function getTransportDefault(cfg, kind) {
|
|
6443
|
-
const def = _optionalChain([getTransportBlock, 'call',
|
|
6418
|
+
const def = _optionalChain([getTransportBlock, 'call', _700 => _700(cfg, kind), 'optionalAccess', _701 => _701.default]);
|
|
6444
6419
|
return def && typeof def === "object" ? def : null;
|
|
6445
6420
|
}
|
|
6446
6421
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getTransportDefault, "getTransportDefault");
|
|
@@ -6450,7 +6425,7 @@ function hasTransportDefault(cfg, kind) {
|
|
|
6450
6425
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, hasTransportDefault, "hasTransportDefault");
|
|
6451
6426
|
function getDefaultConnId(cfg, kind) {
|
|
6452
6427
|
const def = getTransportDefault(cfg, kind);
|
|
6453
|
-
const id = _optionalChain([def, 'optionalAccess',
|
|
6428
|
+
const id = _optionalChain([def, 'optionalAccess', _702 => _702.id]);
|
|
6454
6429
|
return typeof id === "string" && id.length > 0 ? id : DEFAULT_CONN_ID[kind];
|
|
6455
6430
|
}
|
|
6456
6431
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, getDefaultConnId, "getDefaultConnId");
|
|
@@ -6461,14 +6436,14 @@ function shouldAutoConnect(def) {
|
|
|
6461
6436
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, shouldAutoConnect, "shouldAutoConnect");
|
|
6462
6437
|
function resolveReconnectOptions(def, kind, cfg) {
|
|
6463
6438
|
const base = DEFAULT_RECONNECT[kind];
|
|
6464
|
-
const rc = _optionalChain([def, 'optionalAccess',
|
|
6465
|
-
const tmMaxTry = _optionalChain([cfg, 'optionalAccess',
|
|
6439
|
+
const rc = _optionalChain([def, 'optionalAccess', _703 => _703.reconnect]);
|
|
6440
|
+
const tmMaxTry = _optionalChain([cfg, 'optionalAccess', _704 => _704.tm, 'optionalAccess', _705 => _705.maxtry]);
|
|
6466
6441
|
return {
|
|
6467
|
-
enabled: _optionalChain([rc, 'optionalAccess',
|
|
6468
|
-
maxRetries: _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess',
|
|
6469
|
-
initialDelay: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess',
|
|
6470
|
-
maxDelay: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess',
|
|
6471
|
-
factor: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess',
|
|
6442
|
+
enabled: _optionalChain([rc, 'optionalAccess', _706 => _706.enabled]) !== false && base.enabled !== false,
|
|
6443
|
+
maxRetries: _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess', _707 => _707.maxRetries]), () => ( tmMaxTry)), () => ( base.maxRetries)), () => ( 60)),
|
|
6444
|
+
initialDelay: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess', _708 => _708.initialDelay]), () => ( base.initialDelay)), () => ( 1e3)),
|
|
6445
|
+
maxDelay: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess', _709 => _709.maxDelay]), () => ( base.maxDelay)), () => ( 3e4)),
|
|
6446
|
+
factor: _nullishCoalesce(_nullishCoalesce(_optionalChain([rc, 'optionalAccess', _710 => _710.factor]), () => ( base.factor)), () => ( 2))
|
|
6472
6447
|
};
|
|
6473
6448
|
}
|
|
6474
6449
|
_chunkSMVZ3ZDJcjs.__name.call(void 0, resolveReconnectOptions, "resolveReconnectOptions");
|
|
@@ -6518,17 +6493,17 @@ function createTransportDataHandler($asai, manager) {
|
|
|
6518
6493
|
if (typeof event.data === "string") {
|
|
6519
6494
|
try {
|
|
6520
6495
|
event.data = JSON.parse(event.data);
|
|
6521
|
-
} catch (
|
|
6496
|
+
} catch (e52) {
|
|
6522
6497
|
}
|
|
6523
6498
|
}
|
|
6524
|
-
if (_optionalChain([event, 'access',
|
|
6499
|
+
if (_optionalChain([event, 'access', _711 => _711.data, 'optionalAccess', _712 => _712.id])) {
|
|
6525
6500
|
manager.watch(event.id, event.data);
|
|
6526
6501
|
return;
|
|
6527
6502
|
}
|
|
6528
6503
|
try {
|
|
6529
|
-
const wsKey = _optionalChain([$asai, 'optionalAccess',
|
|
6530
|
-
_optionalChain([$asai, 'access',
|
|
6531
|
-
} catch (
|
|
6504
|
+
const wsKey = _optionalChain([$asai, 'optionalAccess', _713 => _713.command, 'optionalAccess', _714 => _714.commandconfig, 'optionalAccess', _715 => _715.config, 'optionalAccess', _716 => _716.commandclient]);
|
|
6505
|
+
_optionalChain([$asai, 'access', _717 => _717.serversws, 'optionalAccess', _718 => _718[wsKey], 'optionalAccess', _719 => _719.broadws, 'optionalCall', _720 => _720(event.data)]);
|
|
6506
|
+
} catch (e53) {
|
|
6532
6507
|
}
|
|
6533
6508
|
};
|
|
6534
6509
|
}
|
|
@@ -6600,7 +6575,7 @@ var initAsaiHostNodejs2 = {
|
|
|
6600
6575
|
createTransportDataHandler,
|
|
6601
6576
|
wireTransportConnectionLogs
|
|
6602
6577
|
};
|
|
6603
|
-
var PLUGIN_VERSION = true ? "0.0.
|
|
6578
|
+
var PLUGIN_VERSION = true ? "0.0.4" : "0.0.1";
|
|
6604
6579
|
var index_default = initAsaiHostNodejs2;
|
|
6605
6580
|
|
|
6606
6581
|
|