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.
- 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/fieldClear.js +0 -57
- package/dist/genShortId.js +0 -12
- package/dist/hashPassword.js +0 -22
- package/dist/index.js +0 -25
- 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/fieldClear.ts +0 -75
- package/src/genShortId.ts +0 -12
- package/src/hashPassword.ts +0 -27
- package/src/index.ts +0 -28
- 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/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/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 -22
- 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/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';
|
package/types/validate.d.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 验证相关类型定义
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 字段类型
|
|
7
|
-
*/
|
|
8
|
-
export type FieldType = 'string' | 'number' | 'text' | 'array_string' | 'array_text';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* 字段定义类型(对象格式)
|
|
12
|
-
*/
|
|
13
|
-
export interface FieldDefinition {
|
|
14
|
-
/** 字段标签/描述 */
|
|
15
|
-
name: string;
|
|
16
|
-
/** 字段详细说明 */
|
|
17
|
-
detail: string;
|
|
18
|
-
/** 字段类型 */
|
|
19
|
-
type: FieldType;
|
|
20
|
-
/** 最小值/最小长度 */
|
|
21
|
-
min: number | null;
|
|
22
|
-
/** 最大值/最大长度 */
|
|
23
|
-
max: number | null;
|
|
24
|
-
/** 默认值 */
|
|
25
|
-
default: any;
|
|
26
|
-
/** 是否创建索引 */
|
|
27
|
-
index: boolean;
|
|
28
|
-
/** 是否唯一 */
|
|
29
|
-
unique: boolean;
|
|
30
|
-
/** 是否允许为空 */
|
|
31
|
-
nullable: boolean;
|
|
32
|
-
/** 是否无符号(仅 number 类型) */
|
|
33
|
-
unsigned: boolean;
|
|
34
|
-
/** 正则验证 */
|
|
35
|
-
regexp: string | null;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* 表定义类型(对象格式)
|
|
40
|
-
*/
|
|
41
|
-
export type TableDefinition = Record<string, FieldDefinition>;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* 验证结果类型
|
|
45
|
-
*/
|
|
46
|
-
export interface ValidateResult {
|
|
47
|
-
/** 状态码:0=通过,1=失败 */
|
|
48
|
-
code: 0 | 1;
|
|
49
|
-
/** 是否失败 */
|
|
50
|
-
failed: boolean;
|
|
51
|
-
/** 第一个错误 */
|
|
52
|
-
firstError: string | null;
|
|
53
|
-
/** 所有错误 */
|
|
54
|
-
errors: string[];
|
|
55
|
-
/** 错误字段列表 */
|
|
56
|
-
errorFields: string[];
|
|
57
|
-
/** 字段错误映射 */
|
|
58
|
-
fieldErrors: Record<string, string>;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* 单值验证结果
|
|
63
|
-
*/
|
|
64
|
-
export interface SingleResult {
|
|
65
|
-
/** 转换后的值 */
|
|
66
|
-
value: any;
|
|
67
|
-
/** 错误信息(null 表示通过) */
|
|
68
|
-
error: string | null;
|
|
69
|
-
}
|