befly-shared 1.2.7 → 1.3.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.
Files changed (94) hide show
  1. package/package.json +13 -30
  2. package/utils/arrayToTree.ts +135 -0
  3. package/utils/buildTreeByParentPath.ts +127 -0
  4. package/utils/scanViewsDir.ts +148 -0
  5. package/README.md +0 -439
  6. package/dist/addonHelper.js +0 -83
  7. package/dist/arrayKeysToCamel.js +0 -18
  8. package/dist/arrayToTree.js +0 -23
  9. package/dist/calcPerfTime.js +0 -13
  10. package/dist/configTypes.js +0 -1
  11. package/dist/constants.js +0 -46
  12. package/dist/fieldClear.js +0 -57
  13. package/dist/genShortId.js +0 -12
  14. package/dist/hashPassword.js +0 -22
  15. package/dist/index.js +0 -25
  16. package/dist/keysToCamel.js +0 -21
  17. package/dist/keysToSnake.js +0 -21
  18. package/dist/layouts.js +0 -59
  19. package/dist/pickFields.js +0 -16
  20. package/dist/redisKeys.js +0 -34
  21. package/dist/regex.js +0 -202
  22. package/dist/scanConfig.js +0 -83
  23. package/dist/scanFiles.js +0 -39
  24. package/dist/scanViews.js +0 -48
  25. package/dist/withDefaultColumns.js +0 -32
  26. package/src/addonHelper.ts +0 -88
  27. package/src/arrayKeysToCamel.ts +0 -18
  28. package/src/arrayToTree.ts +0 -31
  29. package/src/calcPerfTime.ts +0 -13
  30. package/src/configTypes.ts +0 -29
  31. package/src/constants.ts +0 -60
  32. package/src/fieldClear.ts +0 -75
  33. package/src/genShortId.ts +0 -12
  34. package/src/hashPassword.ts +0 -27
  35. package/src/index.ts +0 -28
  36. package/src/keysToCamel.ts +0 -22
  37. package/src/keysToSnake.ts +0 -22
  38. package/src/layouts.ts +0 -90
  39. package/src/pickFields.ts +0 -19
  40. package/src/redisKeys.ts +0 -44
  41. package/src/regex.ts +0 -225
  42. package/src/scanConfig.ts +0 -106
  43. package/src/scanFiles.ts +0 -49
  44. package/src/scanViews.ts +0 -55
  45. package/src/withDefaultColumns.ts +0 -36
  46. package/tests/addonHelper.test.ts +0 -55
  47. package/tests/arrayKeysToCamel.test.ts +0 -21
  48. package/tests/arrayToTree.test.ts +0 -98
  49. package/tests/calcPerfTime.test.ts +0 -19
  50. package/tests/fieldClear.test.ts +0 -39
  51. package/tests/keysToCamel.test.ts +0 -22
  52. package/tests/keysToSnake.test.ts +0 -22
  53. package/tests/layouts.test.ts +0 -93
  54. package/tests/pickFields.test.ts +0 -22
  55. package/tests/regex.test.ts +0 -308
  56. package/tests/scanFiles.test.ts +0 -58
  57. package/tests/types.test.ts +0 -289
  58. package/types/addon.d.ts +0 -50
  59. package/types/addonConfigMerge.d.ts +0 -17
  60. package/types/addonHelper.d.ts +0 -24
  61. package/types/api.d.ts +0 -63
  62. package/types/arrayKeysToCamel.d.ts +0 -13
  63. package/types/arrayToTree.d.ts +0 -8
  64. package/types/calcPerfTime.d.ts +0 -4
  65. package/types/common.d.ts +0 -8
  66. package/types/configMerge.d.ts +0 -49
  67. package/types/configTypes.d.ts +0 -28
  68. package/types/constants.d.ts +0 -48
  69. package/types/context.d.ts +0 -38
  70. package/types/crypto.d.ts +0 -23
  71. package/types/database.d.ts +0 -55
  72. package/types/fieldClear.d.ts +0 -16
  73. package/types/genShortId.d.ts +0 -10
  74. package/types/hashPassword.d.ts +0 -11
  75. package/types/index.d.ts +0 -22
  76. package/types/jwt.d.ts +0 -99
  77. package/types/keysToCamel.d.ts +0 -10
  78. package/types/keysToSnake.d.ts +0 -10
  79. package/types/layouts.d.ts +0 -29
  80. package/types/loadAndMergeConfig.d.ts +0 -7
  81. package/types/logger.d.ts +0 -22
  82. package/types/menu.d.ts +0 -49
  83. package/types/mergeConfig.d.ts +0 -7
  84. package/types/pickFields.d.ts +0 -4
  85. package/types/redisKeys.d.ts +0 -34
  86. package/types/regex.d.ts +0 -145
  87. package/types/scanConfig.d.ts +0 -7
  88. package/types/scanFiles.d.ts +0 -12
  89. package/types/scanViews.d.ts +0 -11
  90. package/types/table.d.ts +0 -49
  91. package/types/tool.d.ts +0 -67
  92. package/types/types.d.ts +0 -44
  93. package/types/validate.d.ts +0 -69
  94. package/types/withDefaultColumns.d.ts +0 -7
@@ -1,55 +0,0 @@
1
- /**
2
- * 数据库相关类型定义
3
- */
4
-
5
- /**
6
- * SQL 值类型
7
- */
8
- export type SqlValue = string | number | boolean | null | Date;
9
-
10
- /**
11
- * SQL 参数数组类型
12
- */
13
- export type SqlParams = SqlValue[];
14
-
15
- /**
16
- * 排序方向
17
- */
18
- export type OrderDirection = 'ASC' | 'DESC' | 'asc' | 'desc';
19
-
20
- /**
21
- * 数据库类型
22
- */
23
- export type DatabaseType = 'mysql' | 'postgresql' | 'sqlite';
24
-
25
- /**
26
- * 数据库配置类型
27
- */
28
- export interface DatabaseConfig {
29
- /** 数据库类型 */
30
- type: DatabaseType;
31
- /** 主机地址 */
32
- host: string;
33
- /** 端口号 */
34
- port: number;
35
- /** 用户名 */
36
- user: string;
37
- /** 密码 */
38
- password: string;
39
- /** 数据库名 */
40
- database: string;
41
- }
42
-
43
- /**
44
- * Redis 配置类型
45
- */
46
- export interface RedisConfig {
47
- /** 主机地址 */
48
- host: string;
49
- /** 端口号 */
50
- port: number;
51
- /** 密码 */
52
- password?: string;
53
- /** 数据库索引 */
54
- db?: number;
55
- }
@@ -1,16 +0,0 @@
1
- export interface FieldClearOptions {
2
- pickKeys?: string[];
3
- omitKeys?: string[];
4
- keepValues?: any[];
5
- excludeValues?: any[];
6
- keepMap?: Record<string, any>;
7
- }
8
- export type FieldClearResult<T> =
9
- T extends Array<infer U>
10
- ? Array<FieldClearResult<U>>
11
- : T extends object
12
- ? {
13
- [K in keyof T]?: T[K];
14
- }
15
- : T;
16
- export declare function fieldClear<T = any>(data: T | T[], options?: FieldClearOptions): FieldClearResult<T>;
@@ -1,10 +0,0 @@
1
- /**
2
- * 生成短 ID
3
- * 由时间戳(base36)+ 随机字符组成,约 13 位
4
- * - 前 8 位:时间戳(可排序)
5
- * - 后 5 位:随机字符(防冲突)
6
- * @returns 短 ID 字符串
7
- * @example
8
- * genShortId() // "lxyz1a2b3c4"
9
- */
10
- export declare function genShortId(): string;
@@ -1,11 +0,0 @@
1
- /**
2
- * 密码哈希工具
3
- * 使用 SHA-256 + 盐值对密码进行单向哈希
4
- */
5
- /**
6
- * 使用 SHA-256 对密码进行哈希
7
- * @param password - 原始密码
8
- * @param salt - 盐值,默认为 befly
9
- * @returns 哈希后的密码(十六进制字符串)
10
- */
11
- export declare function hashPassword(password: string, salt?: string): Promise<string>;
package/types/index.d.ts DELETED
@@ -1,22 +0,0 @@
1
- /**
2
- * Befly Shared 统一导出
3
- * 跨包共享的工具函数、常量、类型定义
4
- */
5
- export * from './constants.js';
6
- export * from './redisKeys.js';
7
- export * from './regex.js';
8
- export * from './addonHelper.js';
9
- export * from './arrayKeysToCamel.js';
10
- export * from './arrayToTree.js';
11
- export * from './calcPerfTime.js';
12
- export * from './configTypes.js';
13
- export * from './genShortId.js';
14
- export * from './scanConfig.js';
15
- export * from './fieldClear.js';
16
- export * from './keysToCamel.js';
17
- export * from './keysToSnake.js';
18
- export * from './layouts.js';
19
- export * from './pickFields.js';
20
- export * from './scanFiles.js';
21
- export * from './scanViews.js';
22
- export * from './withDefaultColumns.js';
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
- }
@@ -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;
@@ -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;
@@ -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[];
@@ -1,7 +0,0 @@
1
- import type { LoadConfigOptions } from './configTypes.js';
2
- /**
3
- * 加载并合并配置文件(矩阵搜索:dirs × files)
4
- * @param options - 加载选项
5
- * @returns 合并后的配置对象
6
- */
7
- export declare function loadAndMergeConfig(options: LoadConfigOptions): Promise<Record<string, any>>;
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
- }
@@ -1,7 +0,0 @@
1
- import type { LoadConfigOptions } from './configTypes.js';
2
- /**
3
- * 加载并合并配置文件(矩阵搜索:dirs × files)
4
- * @param options - 加载选项
5
- * @returns 合并后的配置对象
6
- */
7
- export declare function mergeConfig(options: LoadConfigOptions): Promise<Record<string, any>>;
@@ -1,4 +0,0 @@
1
- /**
2
- * 挑选指定字段
3
- */
4
- export declare const pickFields: <T extends Record<string, any>>(obj: T, keys: string[]) => Partial<T>;
@@ -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;
@@ -1,7 +0,0 @@
1
- import type { LoadConfigOptions } from './configTypes.js';
2
- /**
3
- * 扫描并合并配置文件(矩阵搜索:dirs × files)
4
- * @param options - 加载选项
5
- * @returns 合并后的配置对象(或第一个找到的配置)
6
- */
7
- export declare function scanConfig(options: LoadConfigOptions): Promise<Record<string, any>>;
@@ -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[]>;
@@ -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>;