befly-shared 1.2.8 → 1.3.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.
- package/package.json +13 -30
- package/utils/arrayToTree.ts +135 -0
- package/utils/buildTreeByParentPath.ts +127 -0
- package/utils/scanViewsDir.ts +148 -0
- package/README.md +0 -439
- package/dist/addonHelper.js +0 -83
- package/dist/arrayKeysToCamel.js +0 -18
- package/dist/arrayToTree.js +0 -23
- package/dist/calcPerfTime.js +0 -13
- package/dist/configTypes.js +0 -1
- package/dist/constants.js +0 -46
- package/dist/deepTransformKeys.js +0 -139
- package/dist/fieldClear.js +0 -57
- package/dist/genShortId.js +0 -12
- package/dist/hashPassword.js +0 -22
- package/dist/index.js +0 -26
- package/dist/keysToCamel.js +0 -21
- package/dist/keysToSnake.js +0 -21
- package/dist/layouts.js +0 -59
- package/dist/pickFields.js +0 -16
- package/dist/redisKeys.js +0 -34
- package/dist/regex.js +0 -202
- package/dist/scanConfig.js +0 -83
- package/dist/scanFiles.js +0 -39
- package/dist/scanViews.js +0 -48
- package/dist/withDefaultColumns.js +0 -32
- package/src/addonHelper.ts +0 -88
- package/src/arrayKeysToCamel.ts +0 -18
- package/src/arrayToTree.ts +0 -31
- package/src/calcPerfTime.ts +0 -13
- package/src/configTypes.ts +0 -29
- package/src/constants.ts +0 -60
- package/src/deepTransformKeys.ts +0 -172
- package/src/fieldClear.ts +0 -75
- package/src/genShortId.ts +0 -12
- package/src/hashPassword.ts +0 -27
- package/src/index.ts +0 -29
- package/src/keysToCamel.ts +0 -22
- package/src/keysToSnake.ts +0 -22
- package/src/layouts.ts +0 -90
- package/src/pickFields.ts +0 -19
- package/src/redisKeys.ts +0 -44
- package/src/regex.ts +0 -225
- package/src/scanConfig.ts +0 -106
- package/src/scanFiles.ts +0 -49
- package/src/scanViews.ts +0 -55
- package/src/withDefaultColumns.ts +0 -36
- package/tests/addonHelper.test.ts +0 -55
- package/tests/arrayKeysToCamel.test.ts +0 -21
- package/tests/arrayToTree.test.ts +0 -98
- package/tests/calcPerfTime.test.ts +0 -19
- package/tests/deepTransformKeys.test.ts +0 -466
- package/tests/fieldClear.test.ts +0 -39
- package/tests/keysToCamel.test.ts +0 -22
- package/tests/keysToSnake.test.ts +0 -22
- package/tests/layouts.test.ts +0 -93
- package/tests/pickFields.test.ts +0 -22
- package/tests/regex.test.ts +0 -308
- package/tests/scanFiles.test.ts +0 -58
- package/tests/types.test.ts +0 -289
- package/types/addon.d.ts +0 -50
- package/types/addonConfigMerge.d.ts +0 -17
- package/types/addonHelper.d.ts +0 -24
- package/types/api.d.ts +0 -63
- package/types/arrayKeysToCamel.d.ts +0 -13
- package/types/arrayToTree.d.ts +0 -8
- package/types/calcPerfTime.d.ts +0 -4
- package/types/common.d.ts +0 -8
- package/types/configMerge.d.ts +0 -49
- package/types/configTypes.d.ts +0 -28
- package/types/constants.d.ts +0 -48
- package/types/context.d.ts +0 -38
- package/types/crypto.d.ts +0 -23
- package/types/database.d.ts +0 -55
- package/types/deepTransformKeys.d.ts +0 -84
- package/types/fieldClear.d.ts +0 -16
- package/types/genShortId.d.ts +0 -10
- package/types/hashPassword.d.ts +0 -11
- package/types/index.d.ts +0 -23
- package/types/jwt.d.ts +0 -99
- package/types/keysToCamel.d.ts +0 -10
- package/types/keysToSnake.d.ts +0 -10
- package/types/layouts.d.ts +0 -29
- package/types/loadAndMergeConfig.d.ts +0 -7
- package/types/logger.d.ts +0 -22
- package/types/menu.d.ts +0 -49
- package/types/mergeConfig.d.ts +0 -7
- package/types/pickFields.d.ts +0 -4
- package/types/redisKeys.d.ts +0 -34
- package/types/regex.d.ts +0 -145
- package/types/scanConfig.d.ts +0 -7
- package/types/scanFiles.d.ts +0 -12
- package/types/scanViews.d.ts +0 -11
- package/types/table.d.ts +0 -49
- package/types/tool.d.ts +0 -67
- package/types/types.d.ts +0 -44
- package/types/validate.d.ts +0 -69
- package/types/withDefaultColumns.d.ts +0 -7
package/types/jwt.d.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JWT 相关类型定义
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* JWT 算法类型
|
|
7
|
-
*/
|
|
8
|
-
export type JwtAlgorithm = 'HS256' | 'HS384' | 'HS512';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* JWT Header 接口
|
|
12
|
-
*/
|
|
13
|
-
export interface JwtHeader {
|
|
14
|
-
alg: JwtAlgorithm;
|
|
15
|
-
typ: 'JWT';
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* JWT 完整解码结果
|
|
20
|
-
*/
|
|
21
|
-
export interface JwtDecoded {
|
|
22
|
-
header: JwtHeader;
|
|
23
|
-
payload: JwtPayload;
|
|
24
|
-
signature: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* JWT 载荷
|
|
29
|
-
*/
|
|
30
|
-
export interface JwtPayload {
|
|
31
|
-
/** 用户 ID */
|
|
32
|
-
userId?: string;
|
|
33
|
-
/** 用户名 */
|
|
34
|
-
username?: string;
|
|
35
|
-
/** 角色 */
|
|
36
|
-
role?: string;
|
|
37
|
-
/** 角色列表 */
|
|
38
|
-
roles?: string[];
|
|
39
|
-
/** 权限列表 */
|
|
40
|
-
permissions?: string[];
|
|
41
|
-
/** 签发时间 */
|
|
42
|
-
iat?: number;
|
|
43
|
-
/** 过期时间 */
|
|
44
|
-
exp?: number;
|
|
45
|
-
/** 主题 */
|
|
46
|
-
sub?: string;
|
|
47
|
-
/** 签发者 */
|
|
48
|
-
iss?: string;
|
|
49
|
-
/** 受众 */
|
|
50
|
-
aud?: string | string[];
|
|
51
|
-
/** JWT ID */
|
|
52
|
-
jti?: string;
|
|
53
|
-
/** 生效时间 */
|
|
54
|
-
nbf?: number;
|
|
55
|
-
/** 其他自定义字段 */
|
|
56
|
-
[key: string]: any;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* JWT 签名选项
|
|
61
|
-
*/
|
|
62
|
-
export interface JwtSignOptions {
|
|
63
|
-
/** 密钥 */
|
|
64
|
-
secret?: string;
|
|
65
|
-
/** 算法 */
|
|
66
|
-
algorithm?: JwtAlgorithm;
|
|
67
|
-
/** 过期时间 */
|
|
68
|
-
expiresIn?: string | number;
|
|
69
|
-
/** 签发者 */
|
|
70
|
-
issuer?: string;
|
|
71
|
-
/** 受众 */
|
|
72
|
-
audience?: string;
|
|
73
|
-
/** 主题 */
|
|
74
|
-
subject?: string;
|
|
75
|
-
/** 生效时间 */
|
|
76
|
-
notBefore?: string | number;
|
|
77
|
-
/** JWT ID */
|
|
78
|
-
jwtId?: string;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* JWT 验证选项
|
|
83
|
-
*/
|
|
84
|
-
export interface JwtVerifyOptions {
|
|
85
|
-
/** 密钥 */
|
|
86
|
-
secret?: string;
|
|
87
|
-
/** 算法列表 */
|
|
88
|
-
algorithms?: JwtAlgorithm[];
|
|
89
|
-
/** 签发者 */
|
|
90
|
-
issuer?: string;
|
|
91
|
-
/** 受众 */
|
|
92
|
-
audience?: string;
|
|
93
|
-
/** 主题 */
|
|
94
|
-
subject?: string;
|
|
95
|
-
/** 是否忽略过期 */
|
|
96
|
-
ignoreExpiration?: boolean;
|
|
97
|
-
/** 是否忽略生效时间 */
|
|
98
|
-
ignoreNotBefore?: boolean;
|
|
99
|
-
}
|
package/types/keysToCamel.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 对象字段名转小驼峰
|
|
3
|
-
* @param obj - 源对象
|
|
4
|
-
* @returns 字段名转为小驼峰格式的新对象
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* keysToCamel({ user_id: 123, user_name: 'John' }) // { userId: 123, userName: 'John' }
|
|
8
|
-
* keysToCamel({ created_at: 1697452800000 }) // { createdAt: 1697452800000 }
|
|
9
|
-
*/
|
|
10
|
-
export declare const keysToCamel: <T = any>(obj: Record<string, any>) => T;
|
package/types/keysToSnake.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 对象字段名转下划线
|
|
3
|
-
* @param obj - 源对象
|
|
4
|
-
* @returns 字段名转为下划线格式的新对象
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* keysToSnake({ userId: 123, userName: 'John' }) // { user_id: 123, user_name: 'John' }
|
|
8
|
-
* keysToSnake({ createdAt: 1697452800000 }) // { created_at: 1697452800000 }
|
|
9
|
-
*/
|
|
10
|
-
export declare const keysToSnake: <T = any>(obj: Record<string, any>) => T;
|
package/types/layouts.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 路由配置接口
|
|
3
|
-
*/
|
|
4
|
-
export interface RouteConfig {
|
|
5
|
-
path?: string;
|
|
6
|
-
component?: any;
|
|
7
|
-
children?: RouteConfig[];
|
|
8
|
-
meta?: Record<string, any>;
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* 布局配置接口
|
|
13
|
-
*/
|
|
14
|
-
export interface LayoutConfig {
|
|
15
|
-
path: string;
|
|
16
|
-
layoutName: string;
|
|
17
|
-
component: any;
|
|
18
|
-
children?: LayoutConfig[];
|
|
19
|
-
meta?: Record<string, any>;
|
|
20
|
-
[key: string]: any;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* 自定义布局处理函数
|
|
24
|
-
* 根据文件名后缀判断使用哪个布局
|
|
25
|
-
* @param routes - 原始路由配置
|
|
26
|
-
* @param inheritLayout - 继承的布局名称(来自父级目录)
|
|
27
|
-
* @returns 处理后的布局配置(不包含实际的布局组件导入)
|
|
28
|
-
*/
|
|
29
|
-
export declare function Layouts(routes: RouteConfig[], inheritLayout?: string): LayoutConfig[];
|
package/types/logger.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 日志相关类型定义
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 日志级别
|
|
7
|
-
*/
|
|
8
|
-
export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* 日志配置
|
|
12
|
-
*/
|
|
13
|
-
export interface LoggerConfig {
|
|
14
|
-
/** 是否开启调试模式 (0: 关闭, 1: 开启) @default 0 */
|
|
15
|
-
debug?: number;
|
|
16
|
-
/** 日志目录 @default './logs' */
|
|
17
|
-
dir?: string;
|
|
18
|
-
/** 是否输出到控制台 (0: 关闭, 1: 开启) @default 1 */
|
|
19
|
-
console?: number;
|
|
20
|
-
/** 单个日志文件最大大小 (MB) @default 10 */
|
|
21
|
-
maxSize?: number;
|
|
22
|
-
}
|
package/types/menu.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 菜单权限相关类型定义
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 菜单项类型
|
|
7
|
-
*/
|
|
8
|
-
export interface MenuItem {
|
|
9
|
-
/** 菜单 ID */
|
|
10
|
-
id: number;
|
|
11
|
-
/** 父级 ID */
|
|
12
|
-
pid: number;
|
|
13
|
-
/** 菜单名称 */
|
|
14
|
-
name: string;
|
|
15
|
-
/** 菜单路径 */
|
|
16
|
-
path: string;
|
|
17
|
-
/** 菜单图标 */
|
|
18
|
-
icon?: string;
|
|
19
|
-
/** 排序 */
|
|
20
|
-
sort: number;
|
|
21
|
-
/** 是否隐藏 */
|
|
22
|
-
hidden?: boolean;
|
|
23
|
-
/** 子菜单 */
|
|
24
|
-
children?: MenuItem[];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* 权限项类型
|
|
29
|
-
*/
|
|
30
|
-
export interface PermissionItem {
|
|
31
|
-
/** API 路由(如 POST/api/user/list) */
|
|
32
|
-
route: string;
|
|
33
|
-
/** 权限名称 */
|
|
34
|
-
name: string;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* 角色信息类型
|
|
39
|
-
*/
|
|
40
|
-
export interface RoleInfo {
|
|
41
|
-
/** 角色 ID */
|
|
42
|
-
id: number;
|
|
43
|
-
/** 角色代码 */
|
|
44
|
-
code: string;
|
|
45
|
-
/** 角色名称 */
|
|
46
|
-
name: string;
|
|
47
|
-
/** 角色描述 */
|
|
48
|
-
desc?: string;
|
|
49
|
-
}
|
package/types/mergeConfig.d.ts
DELETED
package/types/pickFields.d.ts
DELETED
package/types/redisKeys.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Redis Key 统一管理
|
|
3
|
-
* 所有 Redis 缓存键在此统一定义,避免硬编码分散
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Redis Key 生成函数集合
|
|
7
|
-
*/
|
|
8
|
-
export declare const RedisKeys: {
|
|
9
|
-
/** 所有接口缓存 */
|
|
10
|
-
readonly apisAll: () => string;
|
|
11
|
-
/** 所有菜单缓存 */
|
|
12
|
-
readonly menusAll: () => string;
|
|
13
|
-
/** 角色信息缓存(完整角色对象) */
|
|
14
|
-
readonly roleInfo: (roleCode: string) => string;
|
|
15
|
-
/** 角色接口权限缓存(Set 集合) */
|
|
16
|
-
readonly roleApis: (roleCode: string) => string;
|
|
17
|
-
/** 表结构缓存 */
|
|
18
|
-
readonly tableColumns: (table: string) => string;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Redis TTL(过期时间)常量配置(单位:秒)
|
|
22
|
-
*/
|
|
23
|
-
export declare const RedisTTL: {
|
|
24
|
-
/** 表结构缓存 - 1小时 */
|
|
25
|
-
readonly tableColumns: 3600;
|
|
26
|
-
/** 角色接口权限 - 24小时 */
|
|
27
|
-
readonly roleApis: 86400;
|
|
28
|
-
/** 角色信息 - 24小时 */
|
|
29
|
-
readonly roleInfo: 86400;
|
|
30
|
-
/** 接口列表 - 永久(不过期) */
|
|
31
|
-
readonly apisAll: null;
|
|
32
|
-
/** 菜单列表 - 永久(不过期) */
|
|
33
|
-
readonly menusAll: null;
|
|
34
|
-
};
|
package/types/regex.d.ts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 内置正则表达式别名
|
|
3
|
-
* 用于表单验证和数据校验
|
|
4
|
-
* 命名规范:小驼峰格式
|
|
5
|
-
*/
|
|
6
|
-
export declare const RegexAliases: {
|
|
7
|
-
/** 正整数(不含0) */
|
|
8
|
-
readonly number: "^\\d+$";
|
|
9
|
-
/** 整数(含负数) */
|
|
10
|
-
readonly integer: "^-?\\d+$";
|
|
11
|
-
/** 浮点数 */
|
|
12
|
-
readonly float: "^-?\\d+(\\.\\d+)?$";
|
|
13
|
-
/** 正整数(不含0) */
|
|
14
|
-
readonly positive: "^[1-9]\\d*$";
|
|
15
|
-
/** 负整数 */
|
|
16
|
-
readonly negative: "^-\\d+$";
|
|
17
|
-
/** 零 */
|
|
18
|
-
readonly zero: "^0$";
|
|
19
|
-
/** 纯字母 */
|
|
20
|
-
readonly word: "^[a-zA-Z]+$";
|
|
21
|
-
/** 字母和数字 */
|
|
22
|
-
readonly alphanumeric: "^[a-zA-Z0-9]+$";
|
|
23
|
-
/** 字母、数字和下划线 */
|
|
24
|
-
readonly alphanumeric_: "^[a-zA-Z0-9_]+$";
|
|
25
|
-
/** 字母、数字、下划线和短横线 */
|
|
26
|
-
readonly alphanumericDash_: "^[a-zA-Z0-9_-]+$";
|
|
27
|
-
/** 小写字母 */
|
|
28
|
-
readonly lowercase: "^[a-z]+$";
|
|
29
|
-
/** 大写字母 */
|
|
30
|
-
readonly uppercase: "^[A-Z]+$";
|
|
31
|
-
/** 纯中文 */
|
|
32
|
-
readonly chinese: "^[\\u4e00-\\u9fa5]+$";
|
|
33
|
-
/** 中文和字母 */
|
|
34
|
-
readonly chineseWord: "^[\\u4e00-\\u9fa5a-zA-Z]+$";
|
|
35
|
-
/** 邮箱地址 */
|
|
36
|
-
readonly email: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$";
|
|
37
|
-
/** 中国大陆手机号 */
|
|
38
|
-
readonly phone: "^1[3-9]\\d{9}$";
|
|
39
|
-
/** 固定电话(区号-号码) */
|
|
40
|
-
readonly telephone: "^0\\d{2,3}-?\\d{7,8}$";
|
|
41
|
-
/** URL 地址 */
|
|
42
|
-
readonly url: "^https?://";
|
|
43
|
-
/** IPv4 地址 */
|
|
44
|
-
readonly ip: "^((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$";
|
|
45
|
-
/** IPv6 地址 */
|
|
46
|
-
readonly ipv6: "^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$";
|
|
47
|
-
/** 域名 */
|
|
48
|
-
readonly domain: "^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,}$";
|
|
49
|
-
/** UUID */
|
|
50
|
-
readonly uuid: "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
|
|
51
|
-
/** 十六进制字符串 */
|
|
52
|
-
readonly hex: "^[0-9a-fA-F]+$";
|
|
53
|
-
/** Base64 编码 */
|
|
54
|
-
readonly base64: "^[A-Za-z0-9+/=]+$";
|
|
55
|
-
/** MD5 哈希 */
|
|
56
|
-
readonly md5: "^[a-f0-9]{32}$";
|
|
57
|
-
/** SHA1 哈希 */
|
|
58
|
-
readonly sha1: "^[a-f0-9]{40}$";
|
|
59
|
-
/** SHA256 哈希 */
|
|
60
|
-
readonly sha256: "^[a-f0-9]{64}$";
|
|
61
|
-
/** 日期 YYYY-MM-DD */
|
|
62
|
-
readonly date: "^\\d{4}-\\d{2}-\\d{2}$";
|
|
63
|
-
/** 时间 HH:MM:SS */
|
|
64
|
-
readonly time: "^\\d{2}:\\d{2}:\\d{2}$";
|
|
65
|
-
/** ISO 日期时间 */
|
|
66
|
-
readonly datetime: "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}";
|
|
67
|
-
/** 年份 */
|
|
68
|
-
readonly year: "^\\d{4}$";
|
|
69
|
-
/** 月份 01-12 */
|
|
70
|
-
readonly month: "^(0[1-9]|1[0-2])$";
|
|
71
|
-
/** 日期 01-31 */
|
|
72
|
-
readonly day: "^(0[1-9]|[12]\\d|3[01])$";
|
|
73
|
-
/** 变量名 */
|
|
74
|
-
readonly variable: "^[a-zA-Z_][a-zA-Z0-9_]*$";
|
|
75
|
-
/** 常量名(全大写) */
|
|
76
|
-
readonly constant: "^[A-Z][A-Z0-9_]*$";
|
|
77
|
-
/** 包名(小写+连字符) */
|
|
78
|
-
readonly package: "^[a-z][a-z0-9-]*$";
|
|
79
|
-
/** 中国身份证号(18位) */
|
|
80
|
-
readonly idCard: "^\\d{17}[\\dXx]$";
|
|
81
|
-
/** 护照号 */
|
|
82
|
-
readonly passport: "^[a-zA-Z0-9]{5,17}$";
|
|
83
|
-
/** 银行卡号(16-19位数字) */
|
|
84
|
-
readonly bankCard: "^\\d{16,19}$";
|
|
85
|
-
/** 微信号(6-20位,字母开头,可包含字母、数字、下划线、减号) */
|
|
86
|
-
readonly wechat: "^[a-zA-Z][a-zA-Z0-9_-]{5,19}$";
|
|
87
|
-
/** QQ号(5-11位数字,首位非0) */
|
|
88
|
-
readonly qq: "^[1-9]\\d{4,10}$";
|
|
89
|
-
/** 支付宝账号(手机号或邮箱) */
|
|
90
|
-
readonly alipay: "^(1[3-9]\\d{9}|[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,})$";
|
|
91
|
-
/** 用户名(4-20位,字母开头,可包含字母、数字、下划线) */
|
|
92
|
-
readonly username: "^[a-zA-Z][a-zA-Z0-9_]{3,19}$";
|
|
93
|
-
/** 昵称(2-20位,支持中文、字母、数字) */
|
|
94
|
-
readonly nickname: "^[\\u4e00-\\u9fa5a-zA-Z0-9]{2,20}$";
|
|
95
|
-
/** 弱密码(至少6位) */
|
|
96
|
-
readonly passwordWeak: "^.{6,}$";
|
|
97
|
-
/** 中等密码(至少8位,包含字母和数字) */
|
|
98
|
-
readonly passwordMedium: "^(?=.*[a-zA-Z])(?=.*\\d).{8,}$";
|
|
99
|
-
/** 强密码(至少8位,包含大小写字母、数字和特殊字符) */
|
|
100
|
-
readonly passwordStrong: "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[!@#$%^&*]).{8,}$";
|
|
101
|
-
/** 车牌号(新能源+普通) */
|
|
102
|
-
readonly licensePlate: "^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]$";
|
|
103
|
-
/** 邮政编码 */
|
|
104
|
-
readonly postalCode: "^\\d{6}$";
|
|
105
|
-
/** 版本号(语义化版本) */
|
|
106
|
-
readonly semver: "^\\d+\\.\\d+\\.\\d+(-[a-zA-Z0-9.]+)?(\\+[a-zA-Z0-9.]+)?$";
|
|
107
|
-
/** 颜色值(十六进制) */
|
|
108
|
-
readonly colorHex: "^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$";
|
|
109
|
-
/** 空字符串 */
|
|
110
|
-
readonly empty: "^$";
|
|
111
|
-
/** 非空 */
|
|
112
|
-
readonly notempty: ".+";
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* 正则别名类型
|
|
116
|
-
*/
|
|
117
|
-
export type RegexAliasName = keyof typeof RegexAliases;
|
|
118
|
-
/**
|
|
119
|
-
* 获取正则表达式字符串
|
|
120
|
-
* @param name 正则别名(以 @ 开头)或自定义正则字符串
|
|
121
|
-
* @returns 正则表达式字符串
|
|
122
|
-
*/
|
|
123
|
-
export declare function getRegex(name: string): string;
|
|
124
|
-
/**
|
|
125
|
-
* 获取编译后的正则表达式对象(带缓存)
|
|
126
|
-
* @param pattern 正则别名或正则字符串
|
|
127
|
-
* @param flags 正则标志(如 'i', 'g')
|
|
128
|
-
* @returns 编译后的 RegExp 对象
|
|
129
|
-
*/
|
|
130
|
-
export declare function getCompiledRegex(pattern: string, flags?: string): RegExp;
|
|
131
|
-
/**
|
|
132
|
-
* 验证值是否匹配正则(使用缓存)
|
|
133
|
-
* @param value 要验证的值
|
|
134
|
-
* @param pattern 正则别名或正则字符串
|
|
135
|
-
* @returns 是否匹配
|
|
136
|
-
*/
|
|
137
|
-
export declare function matchRegex(value: string, pattern: string): boolean;
|
|
138
|
-
/**
|
|
139
|
-
* 清除正则缓存
|
|
140
|
-
*/
|
|
141
|
-
export declare function clearRegexCache(): void;
|
|
142
|
-
/**
|
|
143
|
-
* 获取缓存大小
|
|
144
|
-
*/
|
|
145
|
-
export declare function getRegexCacheSize(): number;
|
package/types/scanConfig.d.ts
DELETED
package/types/scanFiles.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface ScanFileResult {
|
|
2
|
-
filePath: string;
|
|
3
|
-
relativePath: string;
|
|
4
|
-
fileName: string;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* 扫描指定目录下的文件
|
|
8
|
-
* @param dir 目录路径
|
|
9
|
-
* @param pattern Glob 模式
|
|
10
|
-
* @param ignoreUnderline 是否忽略下划线开头的文件/目录
|
|
11
|
-
*/
|
|
12
|
-
export declare function scanFiles(dir: string, pattern?: string, ignoreUnderline?: boolean): Promise<ScanFileResult[]>;
|
package/types/scanViews.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 扫描项目和所有 @befly-addon 包的 views 目录
|
|
3
|
-
* 用于 unplugin-vue-router 的 routesFolder 配置
|
|
4
|
-
* 注意:此函数只能在 vite.config.js 中使用(Node.js 环境),不能在浏览器中使用
|
|
5
|
-
* @returns 路由文件夹配置数组
|
|
6
|
-
*/
|
|
7
|
-
export declare function scanViews(): {
|
|
8
|
-
src: string;
|
|
9
|
-
path: string;
|
|
10
|
-
exclude: string[];
|
|
11
|
-
}[];
|
package/types/table.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 表结构相关类型定义
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 保留字段(系统自动管理)
|
|
7
|
-
*/
|
|
8
|
-
export type ReservedFields = 'id' | 'created_at' | 'updated_at' | 'deleted_at' | 'state';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* 系统字段(所有表都有的字段)
|
|
12
|
-
*/
|
|
13
|
-
export interface SystemFields {
|
|
14
|
-
/** 主键 ID(雪花 ID) */
|
|
15
|
-
id: number;
|
|
16
|
-
/** 状态:0=已删除, 1=正常, 2=禁用 */
|
|
17
|
-
state: number;
|
|
18
|
-
/** 创建时间(毫秒时间戳) */
|
|
19
|
-
createdAt: number;
|
|
20
|
-
/** 更新时间(毫秒时间戳) */
|
|
21
|
-
updatedAt: number;
|
|
22
|
-
/** 删除时间(毫秒时间戳,软删除时设置) */
|
|
23
|
-
deletedAt: number | null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* 基础表类型(包含系统字段)
|
|
28
|
-
*/
|
|
29
|
-
export type BaseTable<T extends Record<string, any>> = T & SystemFields;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 插入类型:排除系统自动生成的字段
|
|
33
|
-
*/
|
|
34
|
-
export type InsertType<T> = Omit<T, keyof SystemFields>;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* 更新类型:所有字段可选,排除不可修改的系统字段
|
|
38
|
-
*/
|
|
39
|
-
export type UpdateType<T> = Partial<Omit<T, 'id' | 'createdAt' | 'updatedAt' | 'deletedAt'>>;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* 查询结果类型:完整的表记录
|
|
43
|
-
*/
|
|
44
|
-
export type SelectType<T> = T;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* 排除保留字段
|
|
48
|
-
*/
|
|
49
|
-
export type ExcludeReserved<T> = Omit<T, ReservedFields>;
|
package/types/tool.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 工具函数相关类型定义
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 日期格式化类型
|
|
7
|
-
*/
|
|
8
|
-
export type DateFormat = 'YYYY-MM-DD' | 'YYYY-MM-DD HH:mm:ss' | 'HH:mm:ss' | 'YYYY/MM/DD' | 'MM-DD' | string;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* 颜色代码
|
|
12
|
-
*/
|
|
13
|
-
export type ColorCode = 'reset' | 'bright' | 'dim' | 'underscore' | 'blink' | 'reverse' | 'hidden' | 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 分页参数
|
|
17
|
-
*/
|
|
18
|
-
export interface PaginationParams {
|
|
19
|
-
/** 页码(从 1 开始) */
|
|
20
|
-
page?: number;
|
|
21
|
-
/** 每页数量 */
|
|
22
|
-
limit?: number;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* 分页结果
|
|
27
|
-
*/
|
|
28
|
-
export interface PaginationResult<T = any> {
|
|
29
|
-
/** 数据列表 */
|
|
30
|
-
list: T[];
|
|
31
|
-
/** 总条数 */
|
|
32
|
-
total: number;
|
|
33
|
-
/** 当前页码 */
|
|
34
|
-
page: number;
|
|
35
|
-
/** 每页数量 */
|
|
36
|
-
limit: number;
|
|
37
|
-
/** 总页数 */
|
|
38
|
-
pages: number;
|
|
39
|
-
/** 是否有下一页 */
|
|
40
|
-
hasNext: boolean;
|
|
41
|
-
/** 是否有上一页 */
|
|
42
|
-
hasPrev: boolean;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* 文件类型
|
|
47
|
-
*/
|
|
48
|
-
export type FileType = 'image' | 'video' | 'audio' | 'document' | 'archive' | 'other';
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* MIME 类型
|
|
52
|
-
*/
|
|
53
|
-
export type MimeType = string;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* 文件上传选项
|
|
57
|
-
*/
|
|
58
|
-
export interface FileUploadOptions {
|
|
59
|
-
/** 允许的文件类型 */
|
|
60
|
-
allowedTypes?: string[];
|
|
61
|
-
/** 最大文件大小(字节) */
|
|
62
|
-
maxSize?: number;
|
|
63
|
-
/** 保存目录 */
|
|
64
|
-
saveDir?: string;
|
|
65
|
-
/** 文件名生成函数 */
|
|
66
|
-
filename?: (originalName: string) => string;
|
|
67
|
-
}
|
package/types/types.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Befly 共享类型定义 - 统一导出入口
|
|
3
|
-
* 这些类型可以在 core、tpl、admin 等多个包中复用
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// 常量(从 constants 导出)
|
|
7
|
-
export { ApiCode, ErrorMessages } from './constants';
|
|
8
|
-
export type { ApiCodeType, ErrorMessageType } from './constants';
|
|
9
|
-
|
|
10
|
-
// 验证相关
|
|
11
|
-
export type { FieldType, FieldDefinition, TableDefinition, ValidateResult, SingleResult } from './validate';
|
|
12
|
-
|
|
13
|
-
// API 相关
|
|
14
|
-
export type { HttpMethod, ResponseResult, PaginatedResult, BaseApiRoute } from './api';
|
|
15
|
-
|
|
16
|
-
// 数据库相关
|
|
17
|
-
export type { SqlValue, SqlParams, OrderDirection, DatabaseType, DatabaseConfig, RedisConfig } from './database';
|
|
18
|
-
|
|
19
|
-
// 上下文相关
|
|
20
|
-
export type { UserInfo, BaseRequestContext } from './context';
|
|
21
|
-
|
|
22
|
-
// 菜单权限相关
|
|
23
|
-
export type { MenuItem, PermissionItem, RoleInfo } from './menu';
|
|
24
|
-
|
|
25
|
-
// 通用类型
|
|
26
|
-
export type { KeyValue } from './common';
|
|
27
|
-
|
|
28
|
-
// Addon 相关
|
|
29
|
-
export type { AddonAuthor, AddonConfig } from './addon';
|
|
30
|
-
|
|
31
|
-
// 日志相关
|
|
32
|
-
export type { LogLevel, LoggerConfig } from './logger';
|
|
33
|
-
|
|
34
|
-
// 加密相关
|
|
35
|
-
export type { EncodingType, HashAlgorithm, PasswordHashOptions } from './crypto';
|
|
36
|
-
|
|
37
|
-
// JWT 相关
|
|
38
|
-
export type { JwtAlgorithm, JwtHeader, JwtDecoded, JwtPayload, JwtSignOptions, JwtVerifyOptions } from './jwt';
|
|
39
|
-
|
|
40
|
-
// 工具相关
|
|
41
|
-
export type { DateFormat, ColorCode, PaginationParams, PaginationResult, FileType, MimeType, FileUploadOptions } from './tool';
|
|
42
|
-
|
|
43
|
-
// 表结构相关
|
|
44
|
-
export type { ReservedFields, SystemFields, BaseTable, InsertType, UpdateType, SelectType, ExcludeReserved } from './table';
|