befly 3.18.2 → 3.18.3
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/checks/api.js +1 -1
- package/checks/menu.js +2 -2
- package/package.json +2 -2
- package/sync/api.js +3 -2
package/checks/api.js
CHANGED
|
@@ -8,7 +8,7 @@ z.config(z.locales.zhCN());
|
|
|
8
8
|
|
|
9
9
|
const noTrimString = z.string().refine(isNoTrimStringAllowEmpty, "不允许首尾空格");
|
|
10
10
|
const lowerCamelRegex = /^_?[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$/;
|
|
11
|
-
const apiPathRegex = /^\/api\/(core
|
|
11
|
+
const apiPathRegex = /^\/api\/(?:core\/[a-z][a-zA-Z0-9]*(?:\/[a-z][a-zA-Z0-9]*)*|(?!app(?:\/|$))[a-z][a-zA-Z0-9]*(?:\/[a-z][a-zA-Z0-9]*)*)$/;
|
|
12
12
|
|
|
13
13
|
const fieldSchema = z
|
|
14
14
|
.object({
|
package/checks/menu.js
CHANGED
|
@@ -5,7 +5,7 @@ import { formatZodIssues } from "../utils/formatZodIssues.js";
|
|
|
5
5
|
|
|
6
6
|
z.config(z.locales.zhCN());
|
|
7
7
|
|
|
8
|
-
const fullMenuPathRegex = /^\/(?:core(?:\/[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*)*|(?:
|
|
8
|
+
const fullMenuPathRegex = /^\/(?:core(?:\/[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*)*|(?:[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*(?:\/[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*)*)?)$/;
|
|
9
9
|
const childMenuPathRegex = /^\/[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$/;
|
|
10
10
|
|
|
11
11
|
const childMenuSchema = z
|
|
@@ -36,7 +36,7 @@ const menuListSchema = z.array(menuSchema).superRefine((menuList, refineCtx) =>
|
|
|
36
36
|
if (!fullMenuPathRegex.test(childFullPath)) {
|
|
37
37
|
refineCtx.addIssue({
|
|
38
38
|
code: z.ZodIssueCode.custom,
|
|
39
|
-
message: "菜单完整路径必须是 /core/xxx
|
|
39
|
+
message: "菜单完整路径必须是 /core/xxx 或无前缀路径",
|
|
40
40
|
path: [menuIndex, "children", childIndex, "path"]
|
|
41
41
|
});
|
|
42
42
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "befly",
|
|
3
|
-
"version": "3.18.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "3.18.3",
|
|
4
|
+
"gitHead": "0f432ea71a42ecbd584ca6baa7e57a00b902891e",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Befly - 为 Bun 专属打造的 JavaScript API 接口框架核心引擎",
|
|
7
7
|
"keywords": [
|
package/sync/api.js
CHANGED
|
@@ -7,8 +7,9 @@ const getApiParentPath = (apiPath) => {
|
|
|
7
7
|
.filter((s) => s.length > 0);
|
|
8
8
|
|
|
9
9
|
// segments 示例:
|
|
10
|
-
// - /api/
|
|
11
|
-
|
|
10
|
+
// - /api/core/test/hi -> ["api","core","test","hi"]
|
|
11
|
+
// - /api/test/hi -> ["api","test","hi"]
|
|
12
|
+
const take = segments[1] === "core" ? 3 : 2;
|
|
12
13
|
const parentSegments = segments.slice(0, Math.min(take, segments.length));
|
|
13
14
|
if (parentSegments.length === 0) return "";
|
|
14
15
|
return `/${parentSegments.join("/")}`;
|