befly 3.74.3 → 3.75.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/apis/dashboard/systemResources.js +3 -1
  2. package/apis/dict/_dict.js +1 -1
  3. package/apis/role/_role.js +2 -2
  4. package/apis/tongJi/dailyStats.js +2 -2
  5. package/apis/tongJi/dailyStatsDistribution.js +3 -3
  6. package/apis/tongJi/errorList.js +2 -2
  7. package/apis/tongJi/errorStats.js +6 -6
  8. package/checks/api.js +14 -8
  9. package/checks/config.js +4 -3
  10. package/checks/items.js +65 -0
  11. package/checks/menu.js +4 -3
  12. package/checks/table.js +7 -7
  13. package/configs/beflyConfig.json +5 -10
  14. package/configs/constConfig.js +44 -3
  15. package/hooks/auth.js +3 -2
  16. package/hooks/parser.js +15 -4
  17. package/hooks/permission.js +3 -2
  18. package/hooks/rateLimit.js +16 -3
  19. package/hooks/validator.js +2 -1
  20. package/index.js +72 -28
  21. package/lib/cacheHelper.js +83 -229
  22. package/lib/connect.js +3 -13
  23. package/lib/dbHelper.js +57 -142
  24. package/lib/dbParse.js +65 -248
  25. package/lib/dbUtil.js +19 -63
  26. package/lib/logger.js +45 -22
  27. package/lib/redisHelper.js +186 -420
  28. package/lib/smtpText.js +7 -18
  29. package/lib/sqlBuilder.js +22 -51
  30. package/lib/xmlParse.js +15 -59
  31. package/package.json +1 -1
  32. package/plugins/cache.js +2 -3
  33. package/plugins/config.js +3 -1
  34. package/plugins/cron.js +2 -2
  35. package/plugins/email.js +3 -1
  36. package/plugins/logger.js +2 -2
  37. package/plugins/mysql.js +5 -10
  38. package/plugins/redis.js +4 -11
  39. package/plugins/tool.js +3 -3
  40. package/plugins/xmlParse.js +3 -1
  41. package/router/api.js +2 -6
  42. package/router/static.js +9 -10
  43. package/schemas/config.js +4 -4
  44. package/scripts/syncDb/context.js +4 -7
  45. package/scripts/syncDb/diff.js +2 -1
  46. package/scripts/syncDb/index.js +2 -6
  47. package/sync/api.js +7 -8
  48. package/sync/cache.js +3 -1
  49. package/sync/dev.js +28 -65
  50. package/sync/menu.js +5 -6
  51. package/sync/syncUtil.js +25 -0
  52. package/utils/calcPerfTime.js +2 -3
  53. package/utils/crypto.js +0 -40
  54. package/utils/deepMerge.js +2 -6
  55. package/utils/error.js +64 -0
  56. package/utils/fieldClear.js +13 -56
  57. package/utils/importDefault.js +11 -12
  58. package/utils/is.js +3 -180
  59. package/utils/loggerUtils.js +3 -1
  60. package/utils/response.js +12 -8
  61. package/utils/scanFiles.js +2 -53
  62. package/utils/scanSources.js +9 -0
  63. package/utils/util.js +25 -222
  64. package/checks/hook.js +0 -39
  65. package/checks/plugin.js +0 -39
  66. 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
- }
@@ -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
- }