befly 3.74.2 → 3.75.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apis/dashboard/systemResources.js +3 -1
- package/apis/dict/_dict.js +1 -1
- package/apis/role/_role.js +2 -2
- package/apis/tongJi/dailyStats.js +2 -2
- package/apis/tongJi/dailyStatsDistribution.js +3 -3
- package/apis/tongJi/errorList.js +2 -2
- package/apis/tongJi/errorStats.js +6 -6
- package/checks/api.js +11 -6
- package/checks/items.js +56 -0
- package/checks/menu.js +1 -1
- package/checks/table.js +4 -5
- package/configs/beflyConfig.json +5 -10
- package/configs/constConfig.js +44 -3
- package/hooks/auth.js +3 -2
- package/hooks/parser.js +15 -4
- package/hooks/permission.js +3 -2
- package/hooks/rateLimit.js +16 -3
- package/hooks/validator.js +2 -1
- package/index.js +53 -24
- package/lib/cacheHelper.js +83 -229
- package/lib/connect.js +3 -13
- package/lib/dbHelper.js +57 -142
- package/lib/dbParse.js +65 -248
- package/lib/dbUtil.js +19 -63
- package/lib/logger.js +45 -22
- package/lib/redisHelper.js +186 -420
- package/lib/smtpText.js +7 -18
- package/lib/sqlBuilder.js +22 -51
- package/lib/xmlParse.js +15 -59
- package/package.json +1 -1
- package/plugins/cache.js +2 -3
- package/plugins/config.js +3 -1
- package/plugins/cron.js +2 -2
- package/plugins/email.js +3 -1
- package/plugins/logger.js +2 -2
- package/plugins/mysql.js +5 -10
- package/plugins/redis.js +4 -11
- package/plugins/tool.js +3 -3
- package/plugins/xmlParse.js +3 -1
- package/router/api.js +2 -6
- package/router/static.js +9 -10
- package/schemas/config.js +4 -4
- package/scripts/syncDb/context.js +4 -7
- package/scripts/syncDb/diff.js +2 -1
- package/scripts/syncDb/index.js +2 -6
- package/sync/api.js +7 -8
- package/sync/cache.js +3 -1
- package/sync/dev.js +28 -65
- package/sync/menu.js +5 -6
- package/sync/syncUtil.js +25 -0
- package/utils/calcPerfTime.js +2 -3
- package/utils/crypto.js +0 -40
- package/utils/deepMerge.js +2 -6
- package/utils/error.js +64 -0
- package/utils/fieldClear.js +13 -56
- package/utils/importDefault.js +11 -12
- package/utils/is.js +5 -182
- package/utils/loggerUtils.js +3 -1
- package/utils/response.js +12 -8
- package/utils/scanFiles.js +2 -53
- package/utils/scanSources.js +9 -0
- package/utils/util.js +25 -222
- package/checks/hook.js +0 -39
- package/checks/plugin.js +0 -39
- package/utils/processInfo.js +0 -39
package/checks/plugin.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Logger } from "../lib/logger.js";
|
|
2
|
-
import { formatValidationIssues } from "../utils/formatValidationIssues.js";
|
|
3
|
-
import { isFunction, isFiniteNumber, isPlainObject, isString } from "../utils/is.js";
|
|
4
|
-
|
|
5
|
-
const pluginKeys = new Set(["source", "type", "filePath", "relativePath", "fileName", "apiPath", "handler", "order"]);
|
|
6
|
-
|
|
7
|
-
function checkPluginItem(plugin) {
|
|
8
|
-
const issues = [];
|
|
9
|
-
if (!isPlainObject(plugin)) {
|
|
10
|
-
issues.push({ path: [], message: "必须是对象格式" });
|
|
11
|
-
return issues;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
for (const key of Object.keys(plugin)) {
|
|
15
|
-
if (!pluginKeys.has(key)) issues.push({ path: [key], message: "不允许出现" });
|
|
16
|
-
}
|
|
17
|
-
for (const key of ["source", "type", "filePath", "relativePath", "fileName", "apiPath"]) {
|
|
18
|
-
if (!isString(plugin[key]) || plugin[key].length === 0 || plugin[key].trim() !== plugin[key]) issues.push({ path: [key], message: "必须是非空且无首尾空格的字符串" });
|
|
19
|
-
}
|
|
20
|
-
if (!isFunction(plugin.handler)) issues.push({ path: ["handler"], message: "必须是函数" });
|
|
21
|
-
if (!isFiniteNumber(plugin.order)) issues.push({ path: ["order"], message: "必须是有限数字" });
|
|
22
|
-
return issues;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export async function checkPlugin(plugins) {
|
|
26
|
-
if (!Array.isArray(plugins)) {
|
|
27
|
-
Logger.warn("插件校验失败", { errors: formatValidationIssues([{ path: [], message: "必须是数组" }], { item: plugins, itemLabel: "plugin" }) }, false);
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
let hasError = false;
|
|
32
|
-
for (const plugin of plugins) {
|
|
33
|
-
const issues = checkPluginItem(plugin);
|
|
34
|
-
if (issues.length === 0) continue;
|
|
35
|
-
Logger.warn("插件校验失败", { errors: formatValidationIssues(issues, { item: plugin, itemLabel: "plugin" }) }, false);
|
|
36
|
-
hasError = true;
|
|
37
|
-
}
|
|
38
|
-
return hasError;
|
|
39
|
-
}
|
package/utils/processInfo.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 进程角色信息
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 获取当前进程角色信息
|
|
7
|
-
* @returns 进程角色、实例 ID 和运行环境
|
|
8
|
-
*/
|
|
9
|
-
export function getProcessRole(env) {
|
|
10
|
-
const runtimeEnv = env || {};
|
|
11
|
-
|
|
12
|
-
const bunWorkerId = runtimeEnv["BUN_WORKER_ID"];
|
|
13
|
-
const pm2InstanceId = runtimeEnv["PM2_INSTANCE_ID"];
|
|
14
|
-
|
|
15
|
-
// Bun 集群模式
|
|
16
|
-
if (bunWorkerId !== undefined) {
|
|
17
|
-
return {
|
|
18
|
-
role: bunWorkerId === "" ? "primary" : "worker",
|
|
19
|
-
instanceId: bunWorkerId || "0",
|
|
20
|
-
env: "bun-cluster"
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// PM2 集群模式
|
|
25
|
-
if (pm2InstanceId !== undefined) {
|
|
26
|
-
return {
|
|
27
|
-
role: pm2InstanceId === "0" ? "primary" : "worker",
|
|
28
|
-
instanceId: pm2InstanceId,
|
|
29
|
-
env: "pm2-cluster"
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// 单进程模式
|
|
34
|
-
return {
|
|
35
|
-
role: "primary",
|
|
36
|
-
instanceId: null,
|
|
37
|
-
env: "standalone"
|
|
38
|
-
};
|
|
39
|
-
}
|