befly 3.10.17 → 3.10.18

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 (65) hide show
  1. package/befly.config.ts +3 -3
  2. package/checks/checkApi.ts +1 -1
  3. package/checks/checkHook.ts +1 -1
  4. package/checks/checkMenu.ts +5 -5
  5. package/checks/checkPlugin.ts +1 -1
  6. package/checks/checkTable.ts +3 -3
  7. package/docs/guide/quickstart.md +7 -7
  8. package/docs/reference/logger.md +4 -4
  9. package/docs/reference/sync.md +14 -14
  10. package/docs/reference/table.md +2 -2
  11. package/docs/reference/validator.md +3 -3
  12. package/hooks/auth.ts +2 -2
  13. package/hooks/cors.ts +3 -3
  14. package/hooks/parser.ts +3 -3
  15. package/hooks/permission.ts +4 -4
  16. package/hooks/validator.ts +3 -3
  17. package/lib/cacheHelper.ts +2 -2
  18. package/lib/cipher.ts +1 -1
  19. package/lib/connect.ts +2 -2
  20. package/lib/dbHelper.ts +13 -13
  21. package/lib/dbUtils.ts +3 -3
  22. package/lib/jwt.ts +2 -2
  23. package/lib/logger.ts +2 -2
  24. package/lib/redisHelper.ts +2 -2
  25. package/lib/sqlBuilder.ts +2 -2
  26. package/lib/validator.ts +2 -2
  27. package/loader/loadApis.ts +4 -4
  28. package/loader/loadHooks.ts +4 -4
  29. package/loader/loadPlugins.ts +5 -5
  30. package/main.ts +26 -26
  31. package/package.json +4 -7
  32. package/plugins/cache.ts +3 -3
  33. package/plugins/cipher.ts +2 -2
  34. package/plugins/config.ts +2 -2
  35. package/plugins/db.ts +6 -6
  36. package/plugins/jwt.ts +3 -3
  37. package/plugins/logger.ts +3 -3
  38. package/plugins/redis.ts +5 -5
  39. package/plugins/tool.ts +2 -2
  40. package/router/api.ts +9 -9
  41. package/router/static.ts +4 -4
  42. package/sync/syncApi.ts +3 -3
  43. package/sync/syncCache.ts +1 -1
  44. package/sync/syncDev.ts +3 -3
  45. package/sync/syncMenu.ts +6 -6
  46. package/sync/syncTable.ts +9 -9
  47. package/tsconfig.json +1 -47
  48. package/types/api.d.ts +4 -4
  49. package/types/befly.d.ts +11 -11
  50. package/types/cache.d.ts +1 -1
  51. package/types/context.d.ts +1 -1
  52. package/types/hook.d.ts +2 -2
  53. package/types/plugin.d.ts +1 -1
  54. package/utils/arrayKeysToCamel.ts +1 -1
  55. package/utils/cors.ts +1 -1
  56. package/utils/importDefault.ts +1 -1
  57. package/utils/loadMenuConfigs.ts +4 -4
  58. package/utils/processFields.ts +1 -1
  59. package/utils/response.ts +2 -2
  60. package/utils/scanAddons.ts +2 -2
  61. package/utils/scanConfig.ts +1 -1
  62. package/utils/scanFiles.ts +1 -1
  63. package/utils/scanSources.ts +5 -5
  64. package/utils/sortModules.ts +1 -1
  65. package/utils/sqlLog.ts +1 -1
package/befly.config.ts CHANGED
@@ -3,10 +3,10 @@
3
3
  * 自动加载 configs 目录下的配置文件并与默认配置合并
4
4
  * 支持环境分离:befly.common.json + befly.development/production.json
5
5
  */
6
- import type { BeflyOptions } from "./types/befly.js";
6
+ import type { BeflyOptions } from "./types/befly.ts";
7
7
 
8
- import { compileDisableMenuGlobRules } from "./utils/disableMenusGlob.js";
9
- import { scanConfig } from "./utils/scanConfig.js";
8
+ import { compileDisableMenuGlobRules } from "./utils/disableMenusGlob.ts";
9
+ import { scanConfig } from "./utils/scanConfig.ts";
10
10
 
11
11
  /** 默认配置 */
12
12
  const defaultOptions: BeflyOptions = {
@@ -1,7 +1,7 @@
1
1
  import { isPlainObject } from "es-toolkit/compat";
2
2
  import { omit } from "es-toolkit/object";
3
3
 
4
- import { Logger } from "../lib/logger.js";
4
+ import { Logger } from "../lib/logger.ts";
5
5
 
6
6
  export async function checkApi(apis: any[]): Promise<void> {
7
7
  let hasError = false;
@@ -1,7 +1,7 @@
1
1
  import { isPlainObject } from "es-toolkit/compat";
2
2
  import { omit } from "es-toolkit/object";
3
3
 
4
- import { Logger } from "../lib/logger.js";
4
+ import { Logger } from "../lib/logger.ts";
5
5
 
6
6
  export async function checkHook(hooks: any[]): Promise<void> {
7
7
  let hasError = false;
@@ -1,9 +1,9 @@
1
- import type { MenuConfig } from "../types/sync.js";
2
- import type { AddonInfo } from "../utils/scanAddons.js";
1
+ import type { MenuConfig } from "../types/sync.ts";
2
+ import type { AddonInfo } from "../utils/scanAddons.ts";
3
3
 
4
- import { Logger } from "../lib/logger.js";
5
- import { compileDisableMenuGlobRules, isMenuPathDisabledByGlobRules } from "../utils/disableMenusGlob.js";
6
- import { loadMenuConfigs } from "../utils/loadMenuConfigs.js";
4
+ import { Logger } from "../lib/logger.ts";
5
+ import { compileDisableMenuGlobRules, isMenuPathDisabledByGlobRules } from "../utils/disableMenusGlob.ts";
6
+ import { loadMenuConfigs } from "../utils/loadMenuConfigs.ts";
7
7
 
8
8
  function isValidMenuPath(path: string): { ok: boolean; reason: string } {
9
9
  if (!path) {
@@ -1,7 +1,7 @@
1
1
  import { isPlainObject } from "es-toolkit/compat";
2
2
  import { omit } from "es-toolkit/object";
3
3
 
4
- import { Logger } from "../lib/logger.js";
4
+ import { Logger } from "../lib/logger.ts";
5
5
 
6
6
  export async function checkPlugin(plugins: any[]): Promise<void> {
7
7
  let hasError = false;
@@ -1,7 +1,7 @@
1
- import type { FieldDefinition } from "../types/validate.js";
2
- import type { ScanFileResult } from "../utils/scanFiles.js";
1
+ import type { FieldDefinition } from "../types/validate.ts";
2
+ import type { ScanFileResult } from "../utils/scanFiles.ts";
3
3
 
4
- import { Logger } from "../lib/logger.js";
4
+ import { Logger } from "../lib/logger.ts";
5
5
 
6
6
  /**
7
7
  * 保留字段列表
@@ -225,13 +225,13 @@ CREATE DATABASE my_api CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
225
225
  如需手动触发,可在代码中调用(一般不建议在请求路径中调用):
226
226
 
227
227
  ```typescript
228
- import { syncTable } from "../sync/syncTable.js";
229
- import { syncApi } from "../sync/syncApi.js";
230
- import { syncMenu } from "../sync/syncMenu.js";
231
- import { syncDev } from "../sync/syncDev.js";
232
- import { syncCache } from "../sync/syncCache.js";
233
- import { checkMenu } from "../checks/checkMenu.js";
234
- import { scanSources } from "../utils/scanSources.js";
228
+ import { syncTable } from "../sync/syncTable.ts";
229
+ import { syncApi } from "../sync/syncApi.ts";
230
+ import { syncMenu } from "../sync/syncMenu.ts";
231
+ import { syncDev } from "../sync/syncDev.ts";
232
+ import { syncCache } from "../sync/syncCache.ts";
233
+ import { checkMenu } from "../checks/checkMenu.ts";
234
+ import { scanSources } from "../utils/scanSources.ts";
235
235
 
236
236
  // ctx:BeflyContext(需已具备 ctx.db / ctx.redis / ctx.cache / ctx.config)
237
237
  const sources = await scanSources();
@@ -87,7 +87,7 @@ interface LoggerConfig {
87
87
  ### 导入 Logger
88
88
 
89
89
  ```typescript
90
- import { Logger } from "../lib/logger.js";
90
+ import { Logger } from "../lib/logger.ts";
91
91
  ```
92
92
 
93
93
  ### 日志方法
@@ -297,7 +297,7 @@ export default {
297
297
 
298
298
  ```typescript
299
299
  // 直接导入使用
300
- import { Logger } from "../lib/logger.js";
300
+ import { Logger } from "../lib/logger.ts";
301
301
 
302
302
  Logger.info("直接使用");
303
303
  ```
@@ -311,7 +311,7 @@ Logger.info("直接使用");
311
311
  测试时可以设置 Mock 实例:
312
312
 
313
313
  ```typescript
314
- import { Logger, setMockLogger } from "../lib/logger.js";
314
+ import { Logger, setMockLogger } from "../lib/logger.ts";
315
315
  import pino from "pino";
316
316
 
317
317
  // 创建 mock logger
@@ -331,7 +331,7 @@ setMockLogger(null);
331
331
 
332
332
  ```typescript
333
333
  import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
334
- import { Logger, setMockLogger } from "../lib/logger.js";
334
+ import { Logger, setMockLogger } from "../lib/logger.ts";
335
335
  import pino from "pino";
336
336
 
337
337
  describe("Logger", () => {
@@ -53,8 +53,8 @@ Sync 同步系统用于将代码定义同步到数据库,包括:
53
53
  默认会在服务启动时自动执行(仅主进程)。如需在代码中手动执行:
54
54
 
55
55
  ```typescript
56
- import { syncTable } from "../sync/syncTable.js";
57
- import { scanSources } from "../utils/scanSources.js";
56
+ import { syncTable } from "../sync/syncTable.ts";
57
+ import { scanSources } from "../utils/scanSources.ts";
58
58
 
59
59
  // ctx:BeflyContext(需已具备 ctx.db / ctx.redis / ctx.cache / ctx.config)
60
60
  const sources = await scanSources();
@@ -120,8 +120,8 @@ await syncTable(ctx, sources.tables);
120
120
  如需在代码中手动调用:
121
121
 
122
122
  ```typescript
123
- import { syncApi } from "../sync/syncApi.js";
124
- import { scanSources } from "../utils/scanSources.js";
123
+ import { syncApi } from "../sync/syncApi.ts";
124
+ import { scanSources } from "../utils/scanSources.ts";
125
125
 
126
126
  const sources = await scanSources();
127
127
  await syncApi(ctx, sources.apis as any);
@@ -185,9 +185,9 @@ interface SyncApiStats {
185
185
  如需手动调用,需要先对菜单配置做校验/过滤(例如 disableMenus):
186
186
 
187
187
  ```typescript
188
- import { checkMenu } from "../checks/checkMenu.js";
189
- import { syncMenu } from "../sync/syncMenu.js";
190
- import { scanSources } from "../utils/scanSources.js";
188
+ import { checkMenu } from "../checks/checkMenu.ts";
189
+ import { syncMenu } from "../sync/syncMenu.ts";
190
+ import { scanSources } from "../utils/scanSources.ts";
191
191
 
192
192
  const sources = await scanSources();
193
193
  const checkedMenus = await checkMenu(sources.addons, { disableMenus: ctx.config.disableMenus || [] });
@@ -333,13 +333,13 @@ interface SyncMenuStats {
333
333
  ## 代码调用
334
334
 
335
335
  ```typescript
336
- import { syncTable } from "./sync/syncTable.js";
337
- import { syncApi } from "./sync/syncApi.js";
338
- import { syncCache } from "./sync/syncCache.js";
339
- import { syncDev } from "./sync/syncDev.js";
340
- import { syncMenu } from "./sync/syncMenu.js";
341
- import { scanSources } from "./utils/scanSources.js";
342
- import { checkMenu } from "./checks/checkMenu.js";
336
+ import { syncTable } from "./sync/syncTable.ts";
337
+ import { syncApi } from "./sync/syncApi.ts";
338
+ import { syncCache } from "./sync/syncCache.ts";
339
+ import { syncDev } from "./sync/syncDev.ts";
340
+ import { syncMenu } from "./sync/syncMenu.ts";
341
+ import { scanSources } from "./utils/scanSources.ts";
342
+ import { checkMenu } from "./checks/checkMenu.ts";
343
343
 
344
344
  // 启动前/启动中手动触发同步
345
345
  // ctx:BeflyContext(需已具备 ctx.db / ctx.redis / ctx.cache / ctx.config)
@@ -517,8 +517,8 @@ interface FieldDefinition {
517
517
  如需在代码中手动触发:
518
518
 
519
519
  ```typescript
520
- import { syncTable } from "../../sync/syncTable.js";
521
- import { scanSources } from "../../utils/scanSources.js";
520
+ import { syncTable } from "../../sync/syncTable.ts";
521
+ import { scanSources } from "../../utils/scanSources.ts";
522
522
 
523
523
  // ctx:BeflyContext(需已具备 ctx.db / ctx.redis / ctx.config)
524
524
  const sources = await scanSources();
@@ -33,7 +33,7 @@ Validator 是 Befly 的参数验证系统,提供:
33
33
  ### 基本结构
34
34
 
35
35
  ```typescript
36
- import { Validator } from "../lib/validator.js";
36
+ import { Validator } from "../lib/validator.ts";
37
37
 
38
38
  class Validator {
39
39
  // 验证数据对象
@@ -362,7 +362,7 @@ export default {
362
362
  可以引用表定义中的字段:
363
363
 
364
364
  ```typescript
365
- import { adminTable } from "../../../tables/admin.js";
365
+ import { adminTable } from "../../../tables/admin.ts";
366
366
 
367
367
  export default {
368
368
  name: "创建管理员",
@@ -381,7 +381,7 @@ export default {
381
381
  ### 使用公共字段
382
382
 
383
383
  ```typescript
384
- import { Fields } from "../../../config/fields.js";
384
+ import { Fields } from "../../../config/fields.ts";
385
385
 
386
386
  export default {
387
387
  name: "获取列表",
package/hooks/auth.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { Hook } from "../types/hook.js";
1
+ import type { Hook } from "../types/hook.ts";
2
2
 
3
- import { setCtxUser } from "../lib/asyncContext.js";
3
+ import { setCtxUser } from "../lib/asyncContext.ts";
4
4
 
5
5
  export default {
6
6
  deps: ["cors"],
package/hooks/cors.ts CHANGED
@@ -1,9 +1,9 @@
1
- import type { CorsConfig } from "../types/befly.js";
1
+ import type { CorsConfig } from "../types/befly.ts";
2
2
  // 类型导入
3
- import type { Hook } from "../types/hook.js";
3
+ import type { Hook } from "../types/hook.ts";
4
4
 
5
5
  // 相对导入
6
- import { setCorsOptions } from "../utils/cors.js";
6
+ import { setCorsOptions } from "../utils/cors.ts";
7
7
 
8
8
  /**
9
9
  * CORS 跨域处理钩子
package/hooks/parser.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  // 类型导入
2
- import type { Hook } from "../types/hook.js";
2
+ import type { Hook } from "../types/hook.ts";
3
3
 
4
4
  // 外部依赖
5
5
  import { isPlainObject, isEmpty } from "es-toolkit/compat";
6
6
  import { XMLParser } from "fast-xml-parser";
7
7
 
8
8
  // 相对导入
9
- import { pickFields } from "../utils/pickFields.js";
10
- import { ErrorResponse } from "../utils/response.js";
9
+ import { pickFields } from "../utils/pickFields.ts";
10
+ import { ErrorResponse } from "../utils/response.ts";
11
11
 
12
12
  const xmlParser = new XMLParser();
13
13
 
@@ -1,10 +1,10 @@
1
1
  // 类型导入
2
- import type { Hook } from "../types/hook.js";
2
+ import type { Hook } from "../types/hook.ts";
3
3
 
4
- import { CacheKeys } from "../lib/cacheKeys.js";
5
- import { Logger } from "../lib/logger.js";
4
+ import { CacheKeys } from "../lib/cacheKeys.ts";
5
+ import { Logger } from "../lib/logger.ts";
6
6
  // 相对导入
7
- import { ErrorResponse } from "../utils/response.js";
7
+ import { ErrorResponse } from "../utils/response.ts";
8
8
 
9
9
  /**
10
10
  * 权限检查钩子
@@ -1,9 +1,9 @@
1
1
  // 类型导入
2
- import type { Hook } from "../types/hook.js";
2
+ import type { Hook } from "../types/hook.ts";
3
3
 
4
4
  // 相对导入
5
- import { Validator } from "../lib/validator.js";
6
- import { ErrorResponse } from "../utils/response.js";
5
+ import { Validator } from "../lib/validator.ts";
6
+ import { ErrorResponse } from "../utils/response.ts";
7
7
 
8
8
  /**
9
9
  * 参数验证钩子
@@ -3,8 +3,8 @@
3
3
  * 负责在服务器启动时缓存接口、菜单和角色权限到 Redis
4
4
  */
5
5
 
6
- import { CacheKeys } from "./cacheKeys.js";
7
- import { Logger } from "./logger.js";
6
+ import { CacheKeys } from "./cacheKeys.ts";
7
+ import { Logger } from "./logger.ts";
8
8
 
9
9
  type CacheHelperDb = {
10
10
  tableExists(table: string): Promise<{ data: boolean }>;
package/lib/cipher.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * 提供各种哈希、HMAC、密码加密等功能
4
4
  */
5
5
 
6
- import type { EncodingType, HashAlgorithm, PasswordHashOptions } from "../types/crypto.js";
6
+ import type { EncodingType, HashAlgorithm, PasswordHashOptions } from "../types/crypto.ts";
7
7
 
8
8
  import { createSign } from "node:crypto";
9
9
 
package/lib/connect.ts CHANGED
@@ -3,11 +3,11 @@
3
3
  * 统一管理 SQL 和 Redis 连接
4
4
  */
5
5
 
6
- import type { DatabaseConfig, RedisConfig } from "../types/befly.js";
6
+ import type { DatabaseConfig, RedisConfig } from "../types/befly.ts";
7
7
 
8
8
  import { SQL, RedisClient } from "bun";
9
9
 
10
- import { Logger } from "./logger.js";
10
+ import { Logger } from "./logger.ts";
11
11
 
12
12
  /**
13
13
  * 数据库连接管理器
package/lib/dbHelper.ts CHANGED
@@ -3,22 +3,22 @@
3
3
  * 提供数据库 CRUD 操作的封装
4
4
  */
5
5
 
6
- import type { WhereConditions, JoinOption } from "../types/common.js";
7
- import type { QueryOptions, InsertOptions, UpdateOptions, DeleteOptions, ListResult, AllResult, TransactionCallback, DbResult, SqlInfo, ListSql } from "../types/database.js";
8
- import type { DbDialect } from "./dbDialect.js";
6
+ import type { WhereConditions, JoinOption } from "../types/common.ts";
7
+ import type { QueryOptions, InsertOptions, UpdateOptions, DeleteOptions, ListResult, AllResult, TransactionCallback, DbResult, SqlInfo, ListSql } from "../types/database.ts";
8
+ import type { DbDialect } from "./dbDialect.ts";
9
9
 
10
10
  import { snakeCase } from "es-toolkit/string";
11
11
 
12
- import { arrayKeysToCamel } from "../utils/arrayKeysToCamel.js";
13
- import { convertBigIntFields } from "../utils/convertBigIntFields.js";
14
- import { fieldClear } from "../utils/fieldClear.js";
15
- import { keysToCamel } from "../utils/keysToCamel.js";
16
- import { CacheKeys } from "./cacheKeys.js";
17
- import { MySqlDialect } from "./dbDialect.js";
18
- import { DbUtils } from "./dbUtils.js";
19
- import { Logger } from "./logger.js";
20
- import { SqlBuilder } from "./sqlBuilder.js";
21
- import { SqlCheck } from "./sqlCheck.js";
12
+ import { arrayKeysToCamel } from "../utils/arrayKeysToCamel.ts";
13
+ import { convertBigIntFields } from "../utils/convertBigIntFields.ts";
14
+ import { fieldClear } from "../utils/fieldClear.ts";
15
+ import { keysToCamel } from "../utils/keysToCamel.ts";
16
+ import { CacheKeys } from "./cacheKeys.ts";
17
+ import { MySqlDialect } from "./dbDialect.ts";
18
+ import { DbUtils } from "./dbUtils.ts";
19
+ import { Logger } from "./logger.ts";
20
+ import { SqlBuilder } from "./sqlBuilder.ts";
21
+ import { SqlCheck } from "./sqlCheck.ts";
22
22
 
23
23
  const TABLE_COLUMNS_CACHE_TTL_SECONDS = 3600;
24
24
 
package/lib/dbUtils.ts CHANGED
@@ -1,9 +1,9 @@
1
- import type { WhereConditions } from "../types/common.js";
1
+ import type { WhereConditions } from "../types/common.ts";
2
2
 
3
3
  import { snakeCase } from "es-toolkit/string";
4
4
 
5
- import { fieldClear } from "../utils/fieldClear.js";
6
- import { keysToSnake } from "../utils/keysToSnake.js";
5
+ import { fieldClear } from "../utils/fieldClear.ts";
6
+ import { keysToSnake } from "../utils/keysToSnake.ts";
7
7
 
8
8
  export class DbUtils {
9
9
  static parseTableRef(tableRef: string): { schema: string | null; table: string; alias: string | null } {
package/lib/jwt.ts CHANGED
@@ -2,8 +2,8 @@
2
2
  * JWT 工具类 - 基于 fast-jwt 实现
3
3
  */
4
4
 
5
- import type { AuthConfig } from "../types/befly.js";
6
- import type { JwtPayload, JwtSignOptions, JwtVerifyOptions, JwtDecoded, JwtHeader } from "../types/jwt.js";
5
+ import type { AuthConfig } from "../types/befly.ts";
6
+ import type { JwtPayload, JwtSignOptions, JwtVerifyOptions, JwtDecoded, JwtHeader } from "../types/jwt.ts";
7
7
  import type { Algorithm as FastJwtAlgorithm } from "fast-jwt";
8
8
 
9
9
  import { createSigner, createVerifier, createDecoder } from "fast-jwt";
package/lib/logger.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * 日志系统 - 基于 pino 实现
3
3
  */
4
4
 
5
- import type { LoggerConfig } from "../types/logger.js";
5
+ import type { LoggerConfig } from "../types/logger.ts";
6
6
 
7
7
  import { existsSync, mkdirSync } from "node:fs";
8
8
  import { readdir, stat, unlink } from "node:fs/promises";
@@ -13,7 +13,7 @@ import { escapeRegExp } from "es-toolkit/string";
13
13
  import { join } from "pathe";
14
14
  import pino from "pino";
15
15
 
16
- import { getCtx } from "./asyncContext.js";
16
+ import { getCtx } from "./asyncContext.ts";
17
17
 
18
18
  // 注意:Logger 可能在运行时/测试中被 process.chdir() 影响。
19
19
  // 为避免相对路径的 logs 目录随着 cwd 变化,使用模块加载时的初始 cwd 作为锚点。
@@ -5,8 +5,8 @@
5
5
 
6
6
  import { RedisClient } from "bun";
7
7
 
8
- import { Connect } from "./connect.js";
9
- import { Logger } from "./logger.js";
8
+ import { Connect } from "./connect.ts";
9
+ import { Logger } from "./logger.ts";
10
10
 
11
11
  /**
12
12
  * Redis 助手类
package/lib/sqlBuilder.ts CHANGED
@@ -3,9 +3,9 @@
3
3
  * 提供链式 API 构建 SQL 查询
4
4
  */
5
5
 
6
- import type { WhereConditions, WhereOperator, OrderDirection, SqlQuery, InsertData, UpdateData, SqlValue } from "../types/common.js";
6
+ import type { WhereConditions, WhereOperator, OrderDirection, SqlQuery, InsertData, UpdateData, SqlValue } from "../types/common.ts";
7
7
 
8
- import { SqlCheck } from "./sqlCheck.js";
8
+ import { SqlCheck } from "./sqlCheck.ts";
9
9
 
10
10
  const SqlBuilderError = {
11
11
  QUOTE_IDENT_NEED_STRING: (identifier: unknown) => `quoteIdent 需要字符串类型标识符 (identifier: ${String(identifier)})`,
package/lib/validator.ts CHANGED
@@ -3,9 +3,9 @@
3
3
  * 纯静态类设计,简洁易用
4
4
  */
5
5
 
6
- import type { TableDefinition, FieldDefinition, ValidateResult, SingleResult } from "../types/validate.js";
6
+ import type { TableDefinition, FieldDefinition, ValidateResult, SingleResult } from "../types/validate.ts";
7
7
 
8
- import { RegexAliases, getCompiledRegex } from "../configs/presetRegexp.js";
8
+ import { RegexAliases, getCompiledRegex } from "../configs/presetRegexp.ts";
9
9
 
10
10
  /**
11
11
  * 验证器类
@@ -4,11 +4,11 @@
4
4
  */
5
5
 
6
6
  // 类型导入
7
- import type { ApiRoute } from "../types/api.js";
8
- import type { ScanFileResult } from "../utils/scanFiles.js";
7
+ import type { ApiRoute } from "../types/api.ts";
8
+ import type { ScanFileResult } from "../utils/scanFiles.ts";
9
9
 
10
- import { Logger } from "../lib/logger.js";
11
- import { processFields } from "../utils/processFields.js";
10
+ import { Logger } from "../lib/logger.ts";
11
+ import { processFields } from "../utils/processFields.ts";
12
12
 
13
13
  /**
14
14
  * 加载所有 API 路由
@@ -5,11 +5,11 @@
5
5
  */
6
6
 
7
7
  // 类型导入
8
- import type { Hook } from "../types/hook.js";
9
- import type { ScanFileResult } from "../utils/scanFiles.js";
8
+ import type { Hook } from "../types/hook.ts";
9
+ import type { ScanFileResult } from "../utils/scanFiles.ts";
10
10
 
11
- import { Logger } from "../lib/logger.js";
12
- import { sortModules } from "../utils/sortModules.js";
11
+ import { Logger } from "../lib/logger.ts";
12
+ import { sortModules } from "../utils/sortModules.ts";
13
13
 
14
14
  export async function loadHooks(hooks: ScanFileResult[], disableHooks: string[] = []): Promise<Hook[]> {
15
15
  const hooksMap: Hook[] = [];
@@ -3,12 +3,12 @@
3
3
  * 负责扫描和初始化所有插件(核心、组件、项目)
4
4
  */
5
5
 
6
- import type { BeflyContext } from "../types/befly.js";
7
- import type { Plugin } from "../types/plugin.js";
8
- import type { ScanFileResult } from "../utils/scanFiles.js";
6
+ import type { BeflyContext } from "../types/befly.ts";
7
+ import type { Plugin } from "../types/plugin.ts";
8
+ import type { ScanFileResult } from "../utils/scanFiles.ts";
9
9
 
10
- import { Logger } from "../lib/logger.js";
11
- import { sortModules } from "../utils/sortModules.js";
10
+ import { Logger } from "../lib/logger.ts";
11
+ import { sortModules } from "../utils/sortModules.ts";
12
12
 
13
13
  export async function loadPlugins(plugins: ScanFileResult[], context: BeflyContext, disablePlugins: string[] = []): Promise<Plugin[]> {
14
14
  const pluginsMap: Plugin[] = [];
package/main.ts CHANGED
@@ -4,37 +4,37 @@
4
4
  */
5
5
 
6
6
  // ========== 类型导入 ==========
7
- import type { ApiRoute } from "./types/api.js";
8
- import type { BeflyContext, BeflyOptions } from "./types/befly.js";
9
- import type { Hook } from "./types/hook.js";
10
- import type { Plugin } from "./types/plugin.js";
11
-
12
- import { checkApi } from "./checks/checkApi.js";
13
- import { checkHook } from "./checks/checkHook.js";
14
- import { checkMenu } from "./checks/checkMenu.js";
15
- import { checkPlugin } from "./checks/checkPlugin.js";
16
- import { checkTable } from "./checks/checkTable.js";
7
+ import type { ApiRoute } from "./types/api.ts";
8
+ import type { BeflyContext, BeflyOptions } from "./types/befly.ts";
9
+ import type { Hook } from "./types/hook.ts";
10
+ import type { Plugin } from "./types/plugin.ts";
11
+
12
+ import { checkApi } from "./checks/checkApi.ts";
13
+ import { checkHook } from "./checks/checkHook.ts";
14
+ import { checkMenu } from "./checks/checkMenu.ts";
15
+ import { checkPlugin } from "./checks/checkPlugin.ts";
16
+ import { checkTable } from "./checks/checkTable.ts";
17
17
  // ========== 相对导入(项目内部文件) ==========
18
18
  // 基础设施
19
- import { Connect } from "./lib/connect.js";
20
- import { Logger } from "./lib/logger.js";
19
+ import { Connect } from "./lib/connect.ts";
20
+ import { Logger } from "./lib/logger.ts";
21
21
  // 加载器
22
- import { loadApis } from "./loader/loadApis.js";
23
- import { loadHooks } from "./loader/loadHooks.js";
24
- import { loadPlugins } from "./loader/loadPlugins.js";
22
+ import { loadApis } from "./loader/loadApis.ts";
23
+ import { loadHooks } from "./loader/loadHooks.ts";
24
+ import { loadPlugins } from "./loader/loadPlugins.ts";
25
25
  // 路由处理
26
- import { apiHandler } from "./router/api.js";
27
- import { staticHandler } from "./router/static.js";
26
+ import { apiHandler } from "./router/api.ts";
27
+ import { staticHandler } from "./router/static.ts";
28
28
  // 同步
29
- import { syncApi } from "./sync/syncApi.js";
30
- import { syncCache } from "./sync/syncCache.js";
31
- import { syncDev } from "./sync/syncDev.js";
32
- import { syncMenu } from "./sync/syncMenu.js";
33
- import { syncTable } from "./sync/syncTable.js";
29
+ import { syncApi } from "./sync/syncApi.ts";
30
+ import { syncCache } from "./sync/syncCache.ts";
31
+ import { syncDev } from "./sync/syncDev.ts";
32
+ import { syncMenu } from "./sync/syncMenu.ts";
33
+ import { syncTable } from "./sync/syncTable.ts";
34
34
  // 工具
35
- import { calcPerfTime } from "./utils/calcPerfTime.js";
36
- import { getProcessRole } from "./utils/process.js";
37
- import { scanSources } from "./utils/scanSources.js";
35
+ import { calcPerfTime } from "./utils/calcPerfTime.ts";
36
+ import { getProcessRole } from "./utils/process.ts";
37
+ import { scanSources } from "./utils/scanSources.ts";
38
38
 
39
39
  /**
40
40
  * Befly 框架核心类
@@ -65,7 +65,7 @@ export class Befly {
65
65
  const serverStartTime = Bun.nanoseconds();
66
66
 
67
67
  // 0. 延迟加载配置(避免循环依赖)
68
- const { loadBeflyConfig } = await import("./befly.config.js");
68
+ const { loadBeflyConfig } = await import("./befly.config.ts");
69
69
  this.config = await loadBeflyConfig();
70
70
 
71
71
  // 将配置注入到 ctx,供插件/Hook/sync 等按需读取
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "befly",
3
- "version": "3.10.17",
4
- "gitHead": "f3285b9ba4e510e6e903fbf800c96480d56ce36b",
3
+ "version": "3.10.18",
4
+ "gitHead": "1fb1ccce3a69fb6a57f42a1e269c307ed159ae9a",
5
5
  "private": false,
6
6
  "description": "Befly - 为 Bun 专属打造的 TypeScript API 接口框架核心引擎",
7
7
  "keywords": [
@@ -59,10 +59,10 @@
59
59
  },
60
60
  "scripts": {
61
61
  "test": "bun test",
62
- "typecheck": "tsc --noEmit"
62
+ "typecheck": "bunx tsgo -p tsconfig.json --noEmit"
63
63
  },
64
64
  "dependencies": {
65
- "befly-shared": "^1.3.9",
65
+ "befly-shared": "^1.3.10",
66
66
  "chalk": "^5.6.2",
67
67
  "es-toolkit": "^1.43.0",
68
68
  "fast-jwt": "^6.1.0",
@@ -72,9 +72,6 @@
72
72
  "pino": "^10.1.0",
73
73
  "pino-roll": "^4.0.0"
74
74
  },
75
- "devDependencies": {
76
- "typescript": "^5.9.3"
77
- },
78
75
  "engines": {
79
76
  "bun": ">=1.3.0"
80
77
  }
package/plugins/cache.ts CHANGED
@@ -3,10 +3,10 @@
3
3
  * 负责在服务器启动时缓存接口、菜单和角色权限到 Redis
4
4
  */
5
5
 
6
- import type { BeflyContext } from "../types/befly.js";
7
- import type { Plugin } from "../types/plugin.js";
6
+ import type { BeflyContext } from "../types/befly.ts";
7
+ import type { Plugin } from "../types/plugin.ts";
8
8
 
9
- import { CacheHelper } from "../lib/cacheHelper.js";
9
+ import { CacheHelper } from "../lib/cacheHelper.ts";
10
10
 
11
11
  /**
12
12
  * 缓存插件
package/plugins/cipher.ts CHANGED
@@ -3,9 +3,9 @@
3
3
  * 提供加密解密功能
4
4
  */
5
5
 
6
- import type { Plugin } from "../types/plugin.js";
6
+ import type { Plugin } from "../types/plugin.ts";
7
7
 
8
- import { Cipher } from "../lib/cipher.js";
8
+ import { Cipher } from "../lib/cipher.ts";
9
9
 
10
10
  export default {
11
11
  deps: [],
package/plugins/config.ts CHANGED
@@ -2,8 +2,8 @@
2
2
  * 配置插件
3
3
  * 提供访问项目配置的能力
4
4
  */
5
- import type { BeflyContext } from "../types/befly.js";
6
- import type { Plugin } from "../types/plugin.js";
5
+ import type { BeflyContext } from "../types/befly.ts";
6
+ import type { Plugin } from "../types/plugin.ts";
7
7
 
8
8
  export default {
9
9
  deps: [],
package/plugins/db.ts CHANGED
@@ -3,13 +3,13 @@
3
3
  * 初始化数据库连接和 SQL 管理器
4
4
  */
5
5
 
6
- import type { BeflyContext } from "../types/befly.js";
7
- import type { Plugin } from "../types/plugin.js";
6
+ import type { BeflyContext } from "../types/befly.ts";
7
+ import type { Plugin } from "../types/plugin.ts";
8
8
 
9
- import { Connect } from "../lib/connect.js";
10
- import { getDialectByName } from "../lib/dbDialect.js";
11
- import { DbHelper } from "../lib/dbHelper.js";
12
- import { Logger } from "../lib/logger.js";
9
+ import { Connect } from "../lib/connect.ts";
10
+ import { getDialectByName } from "../lib/dbDialect.ts";
11
+ import { DbHelper } from "../lib/dbHelper.ts";
12
+ import { Logger } from "../lib/logger.ts";
13
13
 
14
14
  /**
15
15
  * 数据库插件
package/plugins/jwt.ts CHANGED
@@ -2,10 +2,10 @@
2
2
  * JWT 插件
3
3
  */
4
4
 
5
- import type { BeflyContext } from "../types/befly.js";
6
- import type { Plugin } from "../types/plugin.js";
5
+ import type { BeflyContext } from "../types/befly.ts";
6
+ import type { Plugin } from "../types/plugin.ts";
7
7
 
8
- import { Jwt } from "../lib/jwt.js";
8
+ import { Jwt } from "../lib/jwt.ts";
9
9
 
10
10
  export default {
11
11
  deps: [],
package/plugins/logger.ts CHANGED
@@ -3,10 +3,10 @@
3
3
  * 提供全局日志功能
4
4
  */
5
5
 
6
- import type { BeflyContext } from "../types/befly.js";
7
- import type { Plugin } from "../types/plugin.js";
6
+ import type { BeflyContext } from "../types/befly.ts";
7
+ import type { Plugin } from "../types/plugin.ts";
8
8
 
9
- import { Logger } from "../lib/logger.js";
9
+ import { Logger } from "../lib/logger.ts";
10
10
 
11
11
  /**
12
12
  * 日志插件
package/plugins/redis.ts CHANGED
@@ -3,12 +3,12 @@
3
3
  * 初始化 Redis 连接和助手工具
4
4
  */
5
5
 
6
- import type { BeflyContext } from "../types/befly.js";
7
- import type { Plugin } from "../types/plugin.js";
6
+ import type { BeflyContext } from "../types/befly.ts";
7
+ import type { Plugin } from "../types/plugin.ts";
8
8
 
9
- import { Connect } from "../lib/connect.js";
10
- import { Logger } from "../lib/logger.js";
11
- import { RedisHelper } from "../lib/redisHelper.js";
9
+ import { Connect } from "../lib/connect.ts";
10
+ import { Logger } from "../lib/logger.ts";
11
+ import { RedisHelper } from "../lib/redisHelper.ts";
12
12
 
13
13
  /**
14
14
  * Redis 插件
package/plugins/tool.ts CHANGED
@@ -3,9 +3,9 @@
3
3
  * 提供常用的工具函数
4
4
  */
5
5
 
6
- import type { RequestContext } from "../types/context.js";
6
+ import type { RequestContext } from "../types/context.ts";
7
7
  // 类型导入
8
- import type { Plugin } from "../types/plugin.js";
8
+ import type { Plugin } from "../types/plugin.ts";
9
9
 
10
10
  /**
11
11
  * 成功响应
package/router/api.ts CHANGED
@@ -3,18 +3,18 @@
3
3
  * 处理 /api/* 路径的请求
4
4
  */
5
5
 
6
- import type { ApiRoute } from "../types/api.js";
7
- import type { BeflyContext } from "../types/befly.js";
6
+ import type { ApiRoute } from "../types/api.ts";
7
+ import type { BeflyContext } from "../types/befly.ts";
8
8
  // 类型导入
9
- import type { RequestContext } from "../types/context.js";
10
- import type { Hook } from "../types/hook.js";
9
+ import type { RequestContext } from "../types/context.ts";
10
+ import type { Hook } from "../types/hook.ts";
11
11
 
12
- import { withCtx } from "../lib/asyncContext.js";
13
- import { Logger } from "../lib/logger.js";
12
+ import { withCtx } from "../lib/asyncContext.ts";
13
+ import { Logger } from "../lib/logger.ts";
14
14
  // 相对导入
15
- import { genShortId } from "../utils/genShortId.js";
16
- import { getClientIp } from "../utils/getClientIp.js";
17
- import { FinalResponse } from "../utils/response.js";
15
+ import { genShortId } from "../utils/genShortId.ts";
16
+ import { getClientIp } from "../utils/getClientIp.ts";
17
+ import { FinalResponse } from "../utils/response.ts";
18
18
 
19
19
  /**
20
20
  * API处理器工厂函数
package/router/static.ts CHANGED
@@ -4,15 +4,15 @@
4
4
  */
5
5
 
6
6
  // 类型导入
7
- import type { CorsConfig } from "../types/befly.js";
7
+ import type { CorsConfig } from "../types/befly.ts";
8
8
 
9
9
  // 外部依赖
10
10
  import { join } from "pathe";
11
11
 
12
- import { Logger } from "../lib/logger.js";
12
+ import { Logger } from "../lib/logger.ts";
13
13
  // 相对导入
14
- import { appDir } from "../paths.js";
15
- import { setCorsOptions } from "../utils/cors.js";
14
+ import { appDir } from "../paths.ts";
15
+ import { setCorsOptions } from "../utils/cors.ts";
16
16
 
17
17
  /**
18
18
  * 静态文件处理器工厂
package/sync/syncApi.ts CHANGED
@@ -1,9 +1,9 @@
1
- import type { BeflyContext } from "../types/befly.js";
2
- import type { SyncApiItem } from "../types/sync.js";
1
+ import type { BeflyContext } from "../types/befly.ts";
2
+ import type { SyncApiItem } from "../types/sync.ts";
3
3
 
4
4
  import { keyBy } from "es-toolkit/array";
5
5
 
6
- import { Logger } from "../lib/logger.js";
6
+ import { Logger } from "../lib/logger.ts";
7
7
 
8
8
  export async function syncApi(ctx: Pick<BeflyContext, "db" | "cache">, apis: SyncApiItem[]): Promise<void> {
9
9
  const tableName = "addon_admin_api";
package/sync/syncCache.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { BeflyContext } from "../types/befly.js";
1
+ import type { BeflyContext } from "../types/befly.ts";
2
2
 
3
3
  export async function syncCache(ctx: Pick<BeflyContext, "cache">): Promise<void> {
4
4
  if (!ctx.cache) {
package/sync/syncDev.ts CHANGED
@@ -1,7 +1,7 @@
1
- import type { BeflyContext } from "../types/befly.js";
1
+ import type { BeflyContext } from "../types/befly.ts";
2
2
 
3
- import { Cipher } from "../lib/cipher.js";
4
- import { Logger } from "../lib/logger.js";
3
+ import { Cipher } from "../lib/cipher.ts";
4
+ import { Logger } from "../lib/logger.ts";
5
5
 
6
6
  export type SyncDevConfig = {
7
7
  devEmail?: string;
package/sync/syncMenu.ts CHANGED
@@ -1,9 +1,9 @@
1
- import type { BeflyContext } from "../types/befly.js";
2
- import type { MenuConfig } from "../types/sync.js";
1
+ import type { BeflyContext } from "../types/befly.ts";
2
+ import type { MenuConfig } from "../types/sync.ts";
3
3
 
4
- import { Logger } from "../lib/logger.js";
5
- import { compileDisableMenuGlobRules, isMenuPathDisabledByGlobRules } from "../utils/disableMenusGlob.js";
6
- import { getParentPath } from "../utils/loadMenuConfigs.js";
4
+ import { Logger } from "../lib/logger.ts";
5
+ import { compileDisableMenuGlobRules, isMenuPathDisabledByGlobRules } from "../utils/disableMenusGlob.ts";
6
+ import { getParentPath } from "../utils/loadMenuConfigs.ts";
7
7
 
8
8
  type MenuDef = {
9
9
  path: string;
@@ -298,7 +298,7 @@ export async function syncMenu(ctx: BeflyContext, mergedMenus: MenuConfig[]): Pr
298
298
  // 仅测试用(避免将内部扫描逻辑变成稳定 API)
299
299
  export const __test__ = {
300
300
  scanViewsDir: async (viewsDir: string, prefix: string, parentPath: string = "") => {
301
- const mod = await import("../utils/loadMenuConfigs.js");
301
+ const mod = await import("../utils/loadMenuConfigs.ts");
302
302
  return await mod.scanViewsDirToMenuConfigs(viewsDir, prefix, parentPath);
303
303
  },
304
304
  flattenMenusToDefMap: (mergedMenus: MenuConfig[]) => {
package/sync/syncTable.ts CHANGED
@@ -6,18 +6,18 @@
6
6
  * - 现在按项目要求,将所有实现合并到本文件(目录 packages/core/sync/syncTable/ 已删除)
7
7
  */
8
8
 
9
- import type { DbDialectName } from "../lib/dbDialect.js";
10
- import type { BeflyContext } from "../types/befly.js";
11
- import type { DbResult, SqlInfo } from "../types/database.js";
12
- import type { ColumnInfo, FieldChange, IndexInfo, TablePlan } from "../types/sync.js";
13
- import type { FieldDefinition } from "../types/validate.js";
14
- import type { ScanFileResult } from "../utils/scanFiles.js";
9
+ import type { DbDialectName } from "../lib/dbDialect.ts";
10
+ import type { BeflyContext } from "../types/befly.ts";
11
+ import type { DbResult, SqlInfo } from "../types/database.ts";
12
+ import type { ColumnInfo, FieldChange, IndexInfo, TablePlan } from "../types/sync.ts";
13
+ import type { FieldDefinition } from "../types/validate.ts";
14
+ import type { ScanFileResult } from "../utils/scanFiles.ts";
15
15
 
16
16
  import { snakeCase } from "es-toolkit/string";
17
17
 
18
- import { CacheKeys } from "../lib/cacheKeys.js";
19
- import { getDialectByName, getSyncTableColumnsInfoQuery, getSyncTableIndexesQuery } from "../lib/dbDialect.js";
20
- import { Logger } from "../lib/logger.js";
18
+ import { CacheKeys } from "../lib/cacheKeys.ts";
19
+ import { getDialectByName, getSyncTableColumnsInfoQuery, getSyncTableIndexesQuery } from "../lib/dbDialect.ts";
20
+ import { Logger } from "../lib/logger.ts";
21
21
 
22
22
  type SqlExecutor = {
23
23
  unsafe<T = any>(sqlStr: string, params?: unknown[]): Promise<DbResult<T, SqlInfo>>;
package/tsconfig.json CHANGED
@@ -1,53 +1,7 @@
1
1
  {
2
2
  "extends": "../../tsconfig.base.json",
3
3
  "compilerOptions": {
4
- // 基础配置
5
- "target": "ESNext",
6
- "module": "ESNext",
7
- "lib": ["ESNext"],
8
- "moduleResolution": "bundler",
9
-
10
- // 类型检查
11
- "strict": true,
12
- "noImplicitAny": true,
13
- "strictNullChecks": true,
14
- "strictFunctionTypes": true,
15
- "strictBindCallApply": true,
16
- "strictPropertyInitialization": true,
17
- "noImplicitThis": true,
18
- "alwaysStrict": true,
19
-
20
- // 额外检查
21
- "noUnusedLocals": false,
22
- "noUnusedParameters": false,
23
- "noImplicitReturns": true,
24
- "noFallthroughCasesInSwitch": true,
25
- "noUncheckedIndexedAccess": false,
26
- "noImplicitOverride": true,
27
- "noPropertyAccessFromIndexSignature": false,
28
-
29
- // 模块
30
- "esModuleInterop": true,
31
- "allowSyntheticDefaultImports": true,
32
- "forceConsistentCasingInFileNames": true,
33
- "resolveJsonModule": true,
34
- "isolatedModules": true,
35
-
36
- // 输出
37
- "noEmit": true,
38
- "removeComments": false,
39
- "importHelpers": false,
40
-
41
- // 高级
42
- "skipLibCheck": true,
43
- "allowJs": false,
44
- // Bun 特定
45
- "types": ["bun"],
46
-
47
- // 路径
48
- "paths": {
49
- "@/*": ["./*"]
50
- }
4
+ "types": ["bun"]
51
5
  },
52
6
  "include": ["**/*.ts"],
53
7
  "exclude": ["node_modules", "dist", "logs", "temp", "tests"]
package/types/api.d.ts CHANGED
@@ -2,10 +2,10 @@
2
2
  * Befly API 类型定义
3
3
  */
4
4
 
5
- import type { BeflyContext } from "./befly.js";
6
- import type { KeyValue } from "./common.js";
7
- import type { RequestContext } from "./context.js";
8
- import type { TableDefinition } from "./validate.js";
5
+ import type { BeflyContext } from "./befly.ts";
6
+ import type { KeyValue } from "./common.ts";
7
+ import type { RequestContext } from "./context.ts";
8
+ import type { TableDefinition } from "./validate.ts";
9
9
 
10
10
  /**
11
11
  * HTTP 方法类型
package/types/befly.d.ts CHANGED
@@ -2,17 +2,17 @@
2
2
  * Befly 核心框架类型定义
3
3
  */
4
4
 
5
- import type { CacheHelper } from "../lib/cacheHelper.js";
6
- import type { Cipher } from "../lib/cipher.js";
7
- import type { DbHelper } from "../lib/dbHelper.js";
8
- import type { Jwt } from "../lib/jwt.js";
9
- import type { Logger } from "../lib/logger.js";
10
- import type { RedisHelper } from "../lib/redisHelper.js";
11
- import type { Validator } from "../lib/validator.js";
12
- import type { ApiRoute, HttpMethod } from "./api.js";
13
- import type { KeyValue } from "./common.js";
14
- import type { LoggerConfig } from "./logger.js";
15
- import type { Plugin } from "./plugin.js";
5
+ import type { CacheHelper } from "../lib/cacheHelper.ts";
6
+ import type { Cipher } from "../lib/cipher.ts";
7
+ import type { DbHelper } from "../lib/dbHelper.ts";
8
+ import type { Jwt } from "../lib/jwt.ts";
9
+ import type { Logger } from "../lib/logger.ts";
10
+ import type { RedisHelper } from "../lib/redisHelper.ts";
11
+ import type { Validator } from "../lib/validator.ts";
12
+ import type { ApiRoute, HttpMethod } from "./api.ts";
13
+ import type { KeyValue } from "./common.ts";
14
+ import type { LoggerConfig } from "./logger.ts";
15
+ import type { Plugin } from "./plugin.ts";
16
16
  import type { Database } from "bun:sqlite";
17
17
 
18
18
  export type { LoggerConfig };
package/types/cache.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * 缓存助手类型定义
3
3
  */
4
4
 
5
- import type { BeflyContext } from "./befly.js";
5
+ import type { BeflyContext } from "./befly.ts";
6
6
 
7
7
  /**
8
8
  * 缓存助手类
@@ -2,7 +2,7 @@
2
2
  * 请求上下文类型定义
3
3
  */
4
4
 
5
- import type { ApiRoute } from "./api.js";
5
+ import type { ApiRoute } from "./api.ts";
6
6
 
7
7
  /**
8
8
  * 请求上下文接口
package/types/hook.d.ts CHANGED
@@ -2,8 +2,8 @@
2
2
  * Befly 钩子系统类型定义
3
3
  */
4
4
 
5
- import type { BeflyContext } from "./befly.js";
6
- import type { RequestContext } from "./context.js";
5
+ import type { BeflyContext } from "./befly.ts";
6
+ import type { RequestContext } from "./context.ts";
7
7
 
8
8
  /**
9
9
  * 钩子处理函数类型(串联模式,无 next 参数)
package/types/plugin.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Befly 插件系统类型定义
3
3
  */
4
4
 
5
- import type { BeflyContext } from "./befly.js";
5
+ import type { BeflyContext } from "./befly.ts";
6
6
 
7
7
  /**
8
8
  * 插件配置类型
@@ -1,4 +1,4 @@
1
- import { keysToCamel } from "./keysToCamel.js";
1
+ import { keysToCamel } from "./keysToCamel.ts";
2
2
 
3
3
  /**
4
4
  * 数组对象字段名批量转小驼峰
package/utils/cors.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CorsConfig } from "../types/befly.js";
1
+ import type { CorsConfig } from "../types/befly.ts";
2
2
 
3
3
  /**
4
4
  * 设置 CORS 响应头
@@ -4,7 +4,7 @@
4
4
  * - import() 报错:返回 defaultValue
5
5
  * - default 导出为 null/undefined:返回 defaultValue
6
6
  */
7
- import { Logger } from "../lib/logger.js";
7
+ import { Logger } from "../lib/logger.ts";
8
8
 
9
9
  export async function importDefault<T>(file: string, defaultValue: T): Promise<T> {
10
10
  try {
@@ -1,5 +1,5 @@
1
- import type { MenuConfig } from "../types/sync.js";
2
- import type { AddonInfo } from "./scanAddons.js";
1
+ import type { MenuConfig } from "../types/sync.ts";
2
+ import type { AddonInfo } from "./scanAddons.ts";
3
3
  import type { ViewDirMeta } from "befly-shared/utils/scanViewsDir";
4
4
 
5
5
  import { existsSync } from "node:fs";
@@ -8,8 +8,8 @@ import { readdir, readFile } from "node:fs/promises";
8
8
  import { cleanDirName, extractDefinePageMetaFromScriptSetup, extractScriptSetupBlock } from "befly-shared/utils/scanViewsDir";
9
9
  import { join } from "pathe";
10
10
 
11
- import { Logger } from "../lib/logger.js";
12
- import { isDirentDirectory } from "./isDirentDirectory.js";
11
+ import { Logger } from "../lib/logger.ts";
12
+ import { isDirentDirectory } from "./isDirentDirectory.ts";
13
13
 
14
14
  export async function scanViewsDirToMenuConfigs(viewsDir: string, prefix: string, parentPath: string = ""): Promise<MenuConfig[]> {
15
15
  if (!existsSync(viewsDir)) {
@@ -1,4 +1,4 @@
1
- import { presetFields } from "../configs/presetFields.js";
1
+ import { presetFields } from "../configs/presetFields.ts";
2
2
 
3
3
  /**
4
4
  * 处理字段定义:将 @ 符号引用替换为实际字段定义
package/utils/response.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { RequestContext } from "../types/context.js";
1
+ import type { RequestContext } from "../types/context.ts";
2
2
 
3
- import { Logger } from "../lib/logger.js";
3
+ import { Logger } from "../lib/logger.ts";
4
4
 
5
5
  /**
6
6
  * 创建错误响应(专用于 Hook 中间件)
@@ -3,8 +3,8 @@ import { existsSync, readdirSync } from "node:fs";
3
3
  import { camelCase } from "es-toolkit/string";
4
4
  import { join, resolve } from "pathe";
5
5
 
6
- import { appAddonsDir, appDir } from "../paths.js";
7
- import { isDirentDirectory } from "./isDirentDirectory.js";
6
+ import { appAddonsDir, appDir } from "../paths.ts";
7
+ import { isDirentDirectory } from "./isDirentDirectory.ts";
8
8
 
9
9
  export type AddonSource = "addon" | "app";
10
10
 
@@ -38,7 +38,7 @@ export async function scanConfig(options: LoadConfigOptions): Promise<Record<str
38
38
  cwd = process.cwd(),
39
39
  dirs,
40
40
  files,
41
- extensions = [".js", ".ts", ".json"],
41
+ extensions = [".ts", ".ts", ".json"],
42
42
  mode = "first",
43
43
  paths,
44
44
  defaults = {}
@@ -4,7 +4,7 @@ import { forOwn } from "es-toolkit/compat";
4
4
  import { camelCase } from "es-toolkit/string";
5
5
  import { relative, normalize, parse, join } from "pathe";
6
6
 
7
- import { importDefault } from "./importDefault.js";
7
+ import { importDefault } from "./importDefault.ts";
8
8
 
9
9
  export type ScanFileSource = "app" | "addon" | "core";
10
10
 
@@ -1,11 +1,11 @@
1
- import type { AddonInfo } from "./scanAddons.js";
2
- import type { ScanFileResult } from "./scanFiles.js";
1
+ import type { AddonInfo } from "./scanAddons.ts";
2
+ import type { ScanFileResult } from "./scanFiles.ts";
3
3
 
4
4
  import { join } from "pathe";
5
5
 
6
- import { coreDir, appDir } from "../paths.js";
7
- import { scanAddons } from "./scanAddons.js";
8
- import { scanFiles } from "./scanFiles.js";
6
+ import { coreDir, appDir } from "../paths.ts";
7
+ import { scanAddons } from "./scanAddons.ts";
8
+ import { scanFiles } from "./scanFiles.ts";
9
9
 
10
10
  export type ScanSourcesResult = {
11
11
  hooks: ScanFileResult[];
@@ -1,6 +1,6 @@
1
1
  import { camelCase } from "es-toolkit/string";
2
2
 
3
- import { Logger } from "../lib/logger.js";
3
+ import { Logger } from "../lib/logger.ts";
4
4
 
5
5
  export type SortModulesByDepsOptions<T> = {
6
6
  /**
package/utils/sqlLog.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ListSql, SqlInfo } from "../types/database.js";
1
+ import type { ListSql, SqlInfo } from "../types/database.ts";
2
2
 
3
3
  export function toSqlLogFields(sqlInfo: SqlInfo): { sqlPreview: string; sqlParams: any[]; sqlDurationMs: number } {
4
4
  return {