befly 3.10.4 → 3.10.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/cacheHelper.ts +25 -3
  2. package/package.json +3 -3
@@ -67,14 +67,36 @@ export class CacheHelper {
67
67
  private assertApiPathList(value: unknown, roleCode: string): string[] {
68
68
  if (value === null || value === undefined) return [];
69
69
 
70
- if (!Array.isArray(value)) {
71
- throw new Error(`角色权限数据不合法:addon_admin_role.apis 必须是字符串数组,roleCode=${roleCode}`);
70
+ let list: unknown = value;
71
+
72
+ // 兼容历史/手工数据:apis 可能被存成 JSON 字符串或 "null"
73
+ if (typeof list === "string") {
74
+ const trimmed = list.trim();
75
+
76
+ // TEXT 字段常见历史值:"null"(表示空)
77
+ if (trimmed === "" || trimmed === "null") {
78
+ return [];
79
+ }
80
+
81
+ if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
82
+ try {
83
+ list = JSON.parse(trimmed);
84
+ } catch {
85
+ throw new Error(`角色权限数据不合法:addon_admin_role.apis JSON 解析失败,roleCode=${roleCode}`);
86
+ }
87
+ }
88
+ }
89
+
90
+ if (!Array.isArray(list)) {
91
+ const typeLabel = typeof list;
92
+ throw new Error(`角色权限数据不合法:addon_admin_role.apis 必须是字符串数组或 JSON 数组字符串,roleCode=${roleCode},type=${typeLabel}`);
72
93
  }
73
94
 
74
95
  const out: string[] = [];
75
- for (const item of value) {
96
+ for (const item of list) {
76
97
  out.push(this.assertApiPathname(item, `角色权限数据不合法:addon_admin_role.apis 元素,roleCode=${roleCode}`));
77
98
  }
99
+
78
100
  return out;
79
101
  }
80
102
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "befly",
3
- "version": "3.10.4",
4
- "gitHead": "a281633b6f8be7c941aa7e6a3f677bfc18b65ddc",
3
+ "version": "3.10.6",
4
+ "gitHead": "564115664323c9d73351945129aa7d57d440eb58",
5
5
  "private": false,
6
6
  "description": "Befly - 为 Bun 专属打造的 TypeScript API 接口框架核心引擎",
7
7
  "keywords": [
@@ -62,7 +62,7 @@
62
62
  "typecheck": "bunx tsgo --noEmit"
63
63
  },
64
64
  "dependencies": {
65
- "befly-shared": "1.3.2",
65
+ "befly-shared": "1.3.4",
66
66
  "chalk": "^5.6.2",
67
67
  "es-toolkit": "^1.43.0",
68
68
  "fast-jwt": "^6.1.0",