befly 3.2.0 → 3.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 (73) hide show
  1. package/bin/index.ts +138 -0
  2. package/checks/conflict.ts +35 -25
  3. package/checks/table.ts +6 -6
  4. package/commands/addon.ts +57 -0
  5. package/commands/build.ts +74 -0
  6. package/commands/dev.ts +94 -0
  7. package/commands/index.ts +252 -0
  8. package/commands/script.ts +308 -0
  9. package/commands/start.ts +80 -0
  10. package/commands/syncApi.ts +328 -0
  11. package/{scripts → commands}/syncDb/apply.ts +2 -2
  12. package/{scripts → commands}/syncDb/constants.ts +13 -7
  13. package/{scripts → commands}/syncDb/ddl.ts +7 -5
  14. package/{scripts → commands}/syncDb/helpers.ts +18 -18
  15. package/{scripts → commands}/syncDb/index.ts +37 -23
  16. package/{scripts → commands}/syncDb/sqlite.ts +1 -1
  17. package/{scripts → commands}/syncDb/state.ts +10 -4
  18. package/{scripts → commands}/syncDb/table.ts +7 -7
  19. package/{scripts → commands}/syncDb/tableCreate.ts +7 -6
  20. package/{scripts → commands}/syncDb/types.ts +5 -5
  21. package/{scripts → commands}/syncDb/version.ts +1 -1
  22. package/commands/syncDb.ts +35 -0
  23. package/commands/syncDev.ts +174 -0
  24. package/commands/syncMenu.ts +368 -0
  25. package/config/env.ts +4 -4
  26. package/config/menu.json +67 -0
  27. package/{utils/crypto.ts → lib/cipher.ts} +16 -67
  28. package/lib/database.ts +296 -0
  29. package/{utils → lib}/dbHelper.ts +102 -56
  30. package/{utils → lib}/jwt.ts +124 -151
  31. package/{utils → lib}/logger.ts +47 -24
  32. package/lib/middleware.ts +271 -0
  33. package/{utils → lib}/redisHelper.ts +4 -4
  34. package/{utils/validate.ts → lib/validator.ts} +101 -78
  35. package/lifecycle/bootstrap.ts +63 -0
  36. package/lifecycle/checker.ts +165 -0
  37. package/lifecycle/cluster.ts +241 -0
  38. package/lifecycle/lifecycle.ts +139 -0
  39. package/lifecycle/loader.ts +513 -0
  40. package/main.ts +14 -12
  41. package/package.json +21 -9
  42. package/paths.ts +34 -0
  43. package/plugins/cache.ts +187 -0
  44. package/plugins/db.ts +4 -4
  45. package/plugins/logger.ts +1 -1
  46. package/plugins/redis.ts +4 -4
  47. package/router/api.ts +155 -0
  48. package/router/root.ts +53 -0
  49. package/router/static.ts +76 -0
  50. package/types/api.d.ts +0 -36
  51. package/types/befly.d.ts +8 -6
  52. package/types/common.d.ts +1 -1
  53. package/types/context.d.ts +3 -3
  54. package/types/util.d.ts +45 -0
  55. package/util.ts +301 -0
  56. package/config/fields.ts +0 -55
  57. package/config/regexAliases.ts +0 -51
  58. package/config/reserved.ts +0 -96
  59. package/scripts/syncDb/tests/constants.test.ts +0 -105
  60. package/scripts/syncDb/tests/ddl.test.ts +0 -134
  61. package/scripts/syncDb/tests/helpers.test.ts +0 -70
  62. package/scripts/syncDb.ts +0 -10
  63. package/types/index.d.ts +0 -450
  64. package/types/index.ts +0 -438
  65. package/types/validator.ts +0 -43
  66. package/utils/colors.ts +0 -221
  67. package/utils/database.ts +0 -348
  68. package/utils/helper.ts +0 -812
  69. package/utils/index.ts +0 -33
  70. package/utils/requestContext.ts +0 -167
  71. /package/{scripts → commands}/syncDb/schema.ts +0 -0
  72. /package/{utils → lib}/sqlBuilder.ts +0 -0
  73. /package/{utils → lib}/xml.ts +0 -0
@@ -1,134 +0,0 @@
1
- /**
2
- * syncDb DDL 构建测试
3
- */
4
-
5
- import { describe, test, expect } from 'bun:test';
6
- import { buildIndexSQL, buildSystemColumnDefs, buildBusinessColumnDefs, generateDDLClause, isPgCompatibleTypeChange } from '../ddl.js';
7
- import { IS_MYSQL, IS_PG, IS_SQLITE } from '../constants.js';
8
-
9
- describe('syncDb/ddl', () => {
10
- describe('buildIndexSQL', () => {
11
- test('应生成创建索引 SQL', () => {
12
- const sql = buildIndexSQL('users', 'idx_email', 'email', 'create');
13
- expect(sql).toBeDefined();
14
- expect(sql.length).toBeGreaterThan(0);
15
-
16
- if (IS_MYSQL) {
17
- expect(sql).toContain('ADD INDEX');
18
- expect(sql).toContain('ALGORITHM=INPLACE');
19
- expect(sql).toContain('LOCK=NONE');
20
- } else if (IS_PG) {
21
- expect(sql).toContain('CREATE INDEX CONCURRENTLY');
22
- } else if (IS_SQLITE) {
23
- expect(sql).toContain('CREATE INDEX');
24
- }
25
- });
26
-
27
- test('应生成删除索引 SQL', () => {
28
- const sql = buildIndexSQL('users', 'idx_email', 'email', 'drop');
29
- expect(sql).toBeDefined();
30
-
31
- if (IS_MYSQL) {
32
- expect(sql).toContain('DROP INDEX');
33
- } else if (IS_PG) {
34
- expect(sql).toContain('DROP INDEX CONCURRENTLY');
35
- } else if (IS_SQLITE) {
36
- expect(sql).toContain('DROP INDEX');
37
- }
38
- });
39
- });
40
-
41
- describe('buildSystemColumnDefs', () => {
42
- test('应返回 5 个系统字段定义', () => {
43
- const defs = buildSystemColumnDefs();
44
- expect(defs).toHaveLength(5);
45
- });
46
-
47
- test('系统字段应包含 id, created_at, updated_at, deleted_at, state', () => {
48
- const defs = buildSystemColumnDefs();
49
- const combined = defs.join(' ');
50
-
51
- expect(combined).toContain('id');
52
- expect(combined).toContain('created_at');
53
- expect(combined).toContain('updated_at');
54
- expect(combined).toContain('deleted_at');
55
- expect(combined).toContain('state');
56
- });
57
-
58
- test('MySQL 应包含 COMMENT', () => {
59
- const defs = buildSystemColumnDefs();
60
- const combined = defs.join(' ');
61
-
62
- if (IS_MYSQL) {
63
- expect(combined).toContain('COMMENT');
64
- }
65
- });
66
- });
67
-
68
- describe('buildBusinessColumnDefs', () => {
69
- test('应处理空字段对象', () => {
70
- const defs = buildBusinessColumnDefs({});
71
- expect(defs).toHaveLength(0);
72
- });
73
-
74
- test('应生成字段定义', () => {
75
- const fields = {
76
- username: '用户名|string|1|50||1',
77
- age: '年龄|number|0|150|0|0'
78
- };
79
- const defs = buildBusinessColumnDefs(fields);
80
-
81
- expect(defs.length).toBeGreaterThan(0);
82
- expect(defs.join(' ')).toContain('username');
83
- expect(defs.join(' ')).toContain('age');
84
- });
85
- });
86
-
87
- describe('generateDDLClause', () => {
88
- test('应生成添加字段子句', () => {
89
- const clause = generateDDLClause('email', '邮箱|string|0|100||0', true);
90
- expect(clause).toBeDefined();
91
-
92
- if (IS_MYSQL) {
93
- expect(clause).toContain('ADD COLUMN');
94
- } else if (IS_PG) {
95
- expect(clause).toContain('ADD COLUMN');
96
- } else if (IS_SQLITE) {
97
- expect(clause).toContain('ADD COLUMN');
98
- }
99
- });
100
-
101
- test('应生成修改字段子句', () => {
102
- const clause = generateDDLClause('email', '邮箱|string|0|100||0', false);
103
- expect(clause).toBeDefined();
104
-
105
- if (IS_MYSQL) {
106
- expect(clause).toContain('MODIFY COLUMN');
107
- } else if (IS_PG) {
108
- expect(clause).toContain('ALTER COLUMN');
109
- }
110
- });
111
- });
112
-
113
- describe('isPgCompatibleTypeChange', () => {
114
- test('varchar -> text 应为兼容变更', () => {
115
- const result = isPgCompatibleTypeChange('character varying', 'text');
116
- expect(result).toBe(true);
117
- });
118
-
119
- test('text -> varchar 应为不兼容变更', () => {
120
- const result = isPgCompatibleTypeChange('text', 'character varying');
121
- expect(result).toBe(false);
122
- });
123
-
124
- test('相同类型应为不兼容变更(无需变更)', () => {
125
- const result = isPgCompatibleTypeChange('text', 'text');
126
- expect(result).toBe(false);
127
- });
128
-
129
- test('应处理大小写', () => {
130
- const result = isPgCompatibleTypeChange('CHARACTER VARYING', 'TEXT');
131
- expect(result).toBe(true);
132
- });
133
- });
134
- });
@@ -1,70 +0,0 @@
1
- /**
2
- * syncDb 辅助函数测试
3
- */
4
-
5
- import { describe, test, expect } from 'bun:test';
6
- import { quoteIdentifier, logFieldChange, formatFieldList } from '../helpers.js';
7
-
8
- describe('syncDb/helpers', () => {
9
- describe('quoteIdentifier', () => {
10
- test('应正确引用标识符', () => {
11
- const result = quoteIdentifier('user_table');
12
-
13
- // 根据当前数据库类型验证
14
- expect(typeof result).toBe('string');
15
- expect(result.length).toBeGreaterThan(0);
16
- });
17
-
18
- test('应处理特殊字符', () => {
19
- const result = quoteIdentifier('table_name_with_underscore');
20
- expect(result).toBeDefined();
21
- });
22
-
23
- test('应处理空字符串', () => {
24
- const result = quoteIdentifier('');
25
- expect(typeof result).toBe('string');
26
- });
27
- });
28
-
29
- describe('logFieldChange', () => {
30
- test('应不抛出错误', () => {
31
- expect(() => {
32
- logFieldChange('test_table', 'test_field', 'length', 100, 200, '长度');
33
- }).not.toThrow();
34
- });
35
-
36
- test('应处理各种变更类型', () => {
37
- expect(() => {
38
- logFieldChange('table1', 'field1', 'length', 100, 200, '长度');
39
- logFieldChange('table2', 'field2', 'datatype', 'INT', 'VARCHAR', '类型');
40
- logFieldChange('table3', 'field3', 'comment', 'old', 'new', '注释');
41
- logFieldChange('table4', 'field4', 'default', 0, 1, '默认值');
42
- }).not.toThrow();
43
- });
44
- });
45
-
46
- describe('formatFieldList', () => {
47
- test('应正确格式化单个字段', () => {
48
- const result = formatFieldList(['id']);
49
- expect(result).toBeDefined();
50
- expect(typeof result).toBe('string');
51
- });
52
-
53
- test('应正确格式化多个字段', () => {
54
- const result = formatFieldList(['id', 'name', 'email']);
55
- expect(result).toContain(',');
56
- expect(result.split(',').length).toBe(3);
57
- });
58
-
59
- test('应处理空数组', () => {
60
- const result = formatFieldList([]);
61
- expect(result).toBe('');
62
- });
63
-
64
- test('应正确引用字段名', () => {
65
- const result = formatFieldList(['user_id', 'user_name']);
66
- expect(result).toBeDefined();
67
- // 结果应包含引用符号(取决于数据库类型)
68
- });
69
- });
70
- });
package/scripts/syncDb.ts DELETED
@@ -1,10 +0,0 @@
1
- import { SyncDb } from './syncDb/index.js';
2
- import { Logger } from '../utils/logger.js';
3
-
4
- // 如果直接运行此脚本
5
- if (import.meta.main) {
6
- SyncDb().catch((error) => {
7
- Logger.error('数据库同步失败', error);
8
- process.exit(1);
9
- });
10
- }
package/types/index.d.ts DELETED
@@ -1,450 +0,0 @@
1
- /**
2
- * Befly 核心类型定义
3
- * 统一导出所有类型,简化导入路径
4
- *
5
- * @example
6
- * ```typescript
7
- * import type { ApiRoute, BeflyContext, Plugin } from 'befly/types';
8
- * ```
9
- */
10
-
11
- // 基础类型
12
- export * from './common.js';
13
- export * from './context.js';
14
-
15
- // 核心功能类型
16
- export * from './api.js';
17
- export * from './befly.js';
18
- export * from './plugin.js';
19
-
20
- // 功能模块类型
21
- export * from './database.js';
22
- export * from './crypto.js';
23
- export * from './jwt.js';
24
- export * from './validator.js';
25
- export * from './redis.js';
26
- export * from './logger.js';
27
-
28
- /**
29
- * API 请求上下文
30
- */
31
- export interface RequestContext {
32
- /** 原始请求对象 */
33
- req: Request;
34
- /** 解析后的 URL */
35
- url: URL;
36
- /** 路径名 */
37
- pathname: string;
38
- /** 查询参数 */
39
- query: URLSearchParams;
40
- /** 请求体数据 */
41
- body: any;
42
- /** 请求头 */
43
- headers: Headers;
44
- /** 路由参数 */
45
- params?: Record<string, string>;
46
- /** JWT 载荷(认证后) */
47
- jwt?: JwtPayload;
48
- }
49
-
50
- /**
51
- * API 响应格式
52
- */
53
- export interface ApiResponse<T = any> {
54
- /** 状态码:0=成功,1=失败 */
55
- code: 0 | 1;
56
- /** 提示信息 */
57
- msg: string;
58
- /** 响应数据 */
59
- data: T;
60
- }
61
-
62
- /**
63
- * API 处理函数
64
- */
65
- export type ApiHandler = (befly: BeflyContext, ctx: RequestContext, req: Request) => Promise<ApiResponse>;
66
-
67
- /**
68
- * API 路由定义
69
- */
70
- export interface ApiRoute {
71
- /** HTTP 方法 */
72
- method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS';
73
- /** 接口名称 */
74
- name: string;
75
- /** 认证要求:false=公开,true=需登录,['admin']=需特定角色 */
76
- auth: boolean | string[];
77
- /** 字段规则定义 */
78
- fields: Record<string, string>;
79
- /** 必填字段列表 */
80
- required: string[];
81
- /** 处理函数 */
82
- handler: ApiHandler;
83
- }
84
-
85
- /**
86
- * JWT 载荷
87
- */
88
- export interface JwtPayload {
89
- /** 用户 ID */
90
- userId?: string;
91
- /** 用户名 */
92
- username?: string;
93
- /** 角色 */
94
- role?: string;
95
- /** 权限列表 */
96
- permissions?: string[];
97
- /** 签发时间 */
98
- iat?: number;
99
- /** 过期时间 */
100
- exp?: number;
101
- /** 主题 */
102
- sub?: string;
103
- /** 签发者 */
104
- iss?: string;
105
- /** 受众 */
106
- aud?: string;
107
- /** JWT ID */
108
- jti?: string;
109
- /** 生效时间 */
110
- nbf?: number;
111
- /** 其他自定义字段 */
112
- [key: string]: any;
113
- }
114
-
115
- /**
116
- * JWT 签名选项
117
- */
118
- export interface JwtSignOptions {
119
- /** 密钥 */
120
- secret?: string;
121
- /** 算法 */
122
- algorithm?: string;
123
- /** 过期时间 */
124
- expiresIn?: string;
125
- /** 签发者 */
126
- issuer?: string;
127
- /** 受众 */
128
- audience?: string;
129
- /** 主题 */
130
- subject?: string;
131
- /** 生效时间 */
132
- notBefore?: string | number;
133
- /** JWT ID */
134
- jwtId?: string;
135
- }
136
-
137
- /**
138
- * Befly 上下文接口
139
- */
140
- export interface BeflyContext {
141
- /** 数据库管理器 */
142
- db: DbHelper;
143
- /** Redis 助手 */
144
- redis: typeof RedisHelper;
145
-
146
- /**
147
- * 插件定义
148
- */
149
- export interface Plugin {
150
- /** 插件名称 */
151
- name?: string;
152
- /** 依赖的插件列表 */
153
- after?: string[];
154
- /** 初始化函数 */
155
- onInit?: (befly: BeflyContext) => Promise<any>;
156
- }
157
-
158
- /**
159
- * 服务器配置
160
- */
161
- export interface ServerConfig {
162
- /** 服务名称 */
163
- name: string;
164
- /** 端口号 */
165
- port: number;
166
- /** 主机 */
167
- host?: string;
168
- /** 静态文件目录 */
169
- static?: string;
170
- /** 自定义插件 */
171
- plugins?: Plugin[];
172
- }
173
-
174
- /**
175
- * SQL 查询操作符
176
- */
177
- export interface WhereOperator {
178
- /** 大于 */
179
- $gt?: number;
180
- /** 大于等于 */
181
- $gte?: number;
182
- /** 小于 */
183
- $lt?: number;
184
- /** 小于等于 */
185
- $lte?: number;
186
- /** 不等于 */
187
- $ne?: any;
188
- /** 不等于($ne 的别名) */
189
- $not?: any;
190
- /** 在...之中 */
191
- $in?: any[];
192
- /** 不在...之中 */
193
- $nin?: any[];
194
- /** 不在...之中($nin 的别名) */
195
- $notIn?: any[];
196
- /** LIKE 模糊匹配 */
197
- $like?: string;
198
- /** NOT LIKE 模糊匹配 */
199
- $notLike?: string;
200
- /** BETWEEN...AND 范围查询 */
201
- $between?: [any, any];
202
- /** NOT BETWEEN...AND 范围查询 */
203
- $notBetween?: [any, any];
204
- /** IS NULL 空值检查 */
205
- $null?: boolean;
206
- /** IS NOT NULL 非空检查 */
207
- $notNull?: boolean;
208
- }
209
-
210
- /**
211
- * WHERE 条件
212
- * 支持两种格式:
213
- * 1. 嵌套格式:{ age: { $gt: 18 } }
214
- * 2. 一级属性格式:{ 'age$gt': 18 }(推荐)
215
- */
216
- export type WhereConditions = {
217
- /** 普通字段条件(支持一级属性格式:'field$operator') */
218
- [field: string]:
219
- | string
220
- | number
221
- | boolean
222
- | null
223
- | any[] // 支持 $in、$nin 的数组值
224
- | WhereOperator // 支持嵌套格式
225
- | WhereConditions[]; // 支持 $or、$and 的数组值
226
-
227
- /** OR 逻辑操作符 */
228
- $or?: WhereConditions[];
229
-
230
- /** AND 逻辑操作符 */
231
- $and?: WhereConditions[];
232
- };
233
-
234
- /**
235
- * SQL 查询选项
236
- */
237
- export interface QueryOptions {
238
- /** 表名 */
239
- table: string;
240
- /** 查询字段,默认 ['*'] */
241
- fields?: string[];
242
- /** WHERE 条件 */
243
- where?: WhereConditions;
244
- /** 排序(格式:["字段#ASC", "字段#DESC"]) */
245
- orderBy?: string[];
246
- /** 页码(从 1 开始) */
247
- page?: number;
248
- /** 每页数量 */
249
- limit?: number;
250
- }
251
-
252
- /**
253
- * 插入选项
254
- */
255
- export interface InsertOptions {
256
- /** 表名 */
257
- table: string;
258
- /** 插入数据(ID、时间戳、state 会自动生成) */
259
- data: Record<string, any>;
260
- }
261
-
262
- /**
263
- * 更新选项
264
- */
265
- export interface UpdateOptions {
266
- /** 表名 */
267
- table: string;
268
- /** 更新数据(updated_at 会自动更新) */
269
- data: Record<string, any>;
270
- /** WHERE 条件 */
271
- where: WhereConditions;
272
- /** 是否包含已删除数据,默认 false */
273
- includeDeleted?: boolean;
274
- }
275
-
276
- /**
277
- * 删除选项
278
- */
279
- export interface DeleteOptions {
280
- /** 表名 */
281
- table: string;
282
- /** WHERE 条件 */
283
- where: WhereConditions;
284
- }
285
-
286
- /**
287
- * 列表查询结果
288
- */
289
- export interface ListResult<T = any> {
290
- /** 数据列表 */
291
- list: T[];
292
- /** 总条数 */
293
- total: number;
294
- /** 当前页码 */
295
- page: number;
296
- /** 每页数量 */
297
- limit: number;
298
- /** 总页数 */
299
- pages: number;
300
- }
301
-
302
- /**
303
- * 事务回调函数
304
- */
305
- export type TransactionCallback<T = any> = (trans: DbHelper) => Promise<T>;
306
-
307
- /**
308
- * SQL 查询对象
309
- */
310
- export interface SqlQuery {
311
- /** SQL 语句 */
312
- sql: string;
313
- /** 参数列表 */
314
- params: any[];
315
- }
316
-
317
- /**
318
- * 数据库管理器接口
319
- */
320
- export interface DbHelper {
321
- /** 查询单条数据 */
322
- getOne<T = any>(options: QueryOptions): Promise<T | null>;
323
- /** 查询列表(带分页) */
324
- getList<T = any>(options: QueryOptions): Promise<ListResult<T>>;
325
- /** 查询所有数据 */
326
- getAll<T = any>(options: Omit<QueryOptions, 'page' | 'limit'>): Promise<T[]>;
327
- /** 插入数据 */
328
- insData(options: InsertOptions): Promise<number>;
329
- /** 更新数据 */
330
- updData(options: UpdateOptions): Promise<number>;
331
- /** 删除数据 */
332
- delData(options: DeleteOptions): Promise<number>;
333
- /** 执行事务 */
334
- trans<T = any>(callback: TransactionCallback<T>): Promise<T>;
335
- /** 执行原始 SQL */
336
- query(sql: string, params?: any[]): Promise<any>;
337
- }
338
-
339
- /**
340
- * Redis 助手接口
341
- */
342
- export interface RedisHelper {
343
- /** 设置对象到 Redis */
344
- setObject<T = any>(key: string, obj: T, ttl?: number | null): Promise<string | null>;
345
- /** 从 Redis 获取对象 */
346
- getObject<T = any>(key: string): Promise<T | null>;
347
- /** 从 Redis 删除对象 */
348
- delObject(key: string): Promise<void>;
349
- /** 生成基于时间的唯一 ID */
350
- genTimeID(): Promise<number>;
351
- /** 设置字符串值 */
352
- setString(key: string, value: string, ttl?: number | null): Promise<string | null>;
353
- /** 获取字符串值 */
354
- getString(key: string): Promise<string | null>;
355
- /** 检查键是否存在 */
356
- exists(key: string): Promise<number>;
357
- /** 设置过期时间 */
358
- expire(key: string, seconds: number): Promise<number>;
359
- /** 获取剩余过期时间 */
360
- ttl(key: string): Promise<number>;
361
- }
362
-
363
- /**
364
- * 日志记录器接口
365
- */
366
- export interface Logger {
367
- /** 记录信息日志 */
368
- info(message: string | object): void;
369
- /** 记录警告日志 */
370
- warn(message: string | object): void;
371
- /** 记录错误日志 */
372
- error(message: string | object): void;
373
- /** 记录调试日志 */
374
- debug(message: string | object): void;
375
- }
376
-
377
- /**
378
- * 工具类接口
379
- */
380
- export interface Tool {
381
- /** 处理更新数据 */
382
- updData(data: Record<string, any>, now?: number): Promise<Record<string, any>>;
383
- /** 处理插入数据 */
384
- insData(data: Record<string, any> | Record<string, any>[], now?: number): Promise<Record<string, any> | Record<string, any>[]>;
385
- /** 处理删除数据 */
386
- delData(now?: number): Promise<Record<string, any>>;
387
- /** 批量生成 ID */
388
- genIds(count: number): Promise<number[]>;
389
- /** 清理数据对象 */
390
- cleanData(data: Record<string, any>, removeNull?: boolean, removeEmptyString?: boolean): Record<string, any>;
391
- }
392
-
393
- /**
394
- * 验证结果
395
- */
396
- export interface ValidationResult {
397
- /** 是否有效 */
398
- valid: boolean;
399
- /** 处理后的值 */
400
- value: any;
401
- /** 错误列表 */
402
- errors: string[];
403
- }
404
-
405
- /**
406
- * 数据库类型
407
- */
408
- export type DbType = 'mysql' | 'postgresql' | 'sqlite';
409
-
410
- /**
411
- * 列信息
412
- */
413
- export interface ColumnInfo {
414
- /** 列名 */
415
- name: string;
416
- /** 数据类型 */
417
- type: string;
418
- /** 是否可空 */
419
- nullable: boolean;
420
- /** 默认值 */
421
- default: any;
422
- /** 注释 */
423
- comment: string;
424
- }
425
-
426
- /**
427
- * 索引信息
428
- */
429
- export interface IndexInfo {
430
- /** 索引名 */
431
- name: string;
432
- /** 列名 */
433
- column: string;
434
- /** 是否唯一 */
435
- unique: boolean;
436
- }
437
-
438
- /**
439
- * 同步统计
440
- */
441
- export interface SyncStats {
442
- /** 创建的表数 */
443
- created: number;
444
- /** 修改的表数 */
445
- modified: number;
446
- /** 创建的索引数 */
447
- indexesCreated: number;
448
- /** 删除的索引数 */
449
- indexesDropped: number;
450
- }