befly 3.15.26 → 3.16.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/dist/befly.config.js +25 -4
- package/dist/befly.js +497 -215
- package/dist/befly.min.js +18 -17
- package/dist/checks/checkConfig.js +145 -24
- package/dist/checks/checkTable.js +70 -56
- package/dist/index.js +39 -31
- package/dist/lib/logger.d.ts +1 -0
- package/dist/lib/logger.js +28 -21
- package/dist/lib/validator.js +3 -5
- package/dist/loader/loadHooks.js +6 -1
- package/dist/loader/loadPlugins.js +6 -1
- package/dist/sync/syncDev.js +13 -2
- package/dist/sync/syncTable.d.ts +1 -1
- package/dist/sync/syncTable.js +59 -10
- package/dist/types/coreError.d.ts +4 -0
- package/dist/types/coreError.js +3 -0
- package/dist/types/logger.d.ts +9 -4
- package/dist/types/validate.d.ts +1 -1
- package/dist/utils/dbFieldRules.d.ts +31 -0
- package/dist/utils/dbFieldRules.js +94 -0
- package/dist/utils/normalizeFieldDefinition.js +3 -33
- package/dist/utils/util.js +6 -1
- package/package.json +2 -2
package/dist/befly.config.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
+
import { CoreError } from "./types/coreError";
|
|
2
3
|
import { importDefault } from "./utils/importDefault";
|
|
3
4
|
import { mergeAndConcat } from "./utils/mergeAndConcat";
|
|
4
5
|
/** 默认配置 */
|
|
@@ -74,7 +75,12 @@ const defaultOptions = {
|
|
|
74
75
|
};
|
|
75
76
|
export async function loadBeflyConfig(nodeEnv) {
|
|
76
77
|
if (nodeEnv !== "development" && nodeEnv !== "production") {
|
|
77
|
-
throw new
|
|
78
|
+
throw new CoreError({
|
|
79
|
+
message: `配置错误:NODE_ENV 只能是 'development' 或 'production',当前值=${String(nodeEnv)}`,
|
|
80
|
+
kind: "validation",
|
|
81
|
+
noLog: true,
|
|
82
|
+
meta: { subsystem: "config", operation: "loadBeflyConfig" }
|
|
83
|
+
});
|
|
78
84
|
}
|
|
79
85
|
// 使用 importDefault 加载 configs 目录下的配置文件。2222
|
|
80
86
|
// 合并顺序:defaultOptions ← befly.common.json ← befly.development/production.json
|
|
@@ -92,16 +98,31 @@ export async function loadBeflyConfig(nodeEnv) {
|
|
|
92
98
|
if (typeof redisPrefix === "string") {
|
|
93
99
|
const trimmedPrefix = redisPrefix.trim();
|
|
94
100
|
if (trimmedPrefix.includes(":")) {
|
|
95
|
-
throw new
|
|
101
|
+
throw new CoreError({
|
|
102
|
+
message: `配置错误:redis.prefix 不允许包含 ':'(RedisHelper 会自动拼接分隔符 ':'),请改为不带冒号的前缀,例如 'befly_demo',当前值=${redisPrefix}`,
|
|
103
|
+
kind: "validation",
|
|
104
|
+
noLog: true,
|
|
105
|
+
meta: { subsystem: "config", operation: "loadBeflyConfig" }
|
|
106
|
+
});
|
|
96
107
|
}
|
|
97
108
|
}
|
|
98
109
|
const idMode = config.db?.idMode;
|
|
99
110
|
if (idMode !== undefined && idMode !== "timeId" && idMode !== "autoId") {
|
|
100
|
-
throw new
|
|
111
|
+
throw new CoreError({
|
|
112
|
+
message: `配置错误:db.idMode 只能是 'timeId' 或 'autoId',当前值=${String(idMode)}`,
|
|
113
|
+
kind: "validation",
|
|
114
|
+
noLog: true,
|
|
115
|
+
meta: { subsystem: "config", operation: "loadBeflyConfig" }
|
|
116
|
+
});
|
|
101
117
|
}
|
|
102
118
|
const strict = config.strict;
|
|
103
119
|
if (strict !== undefined && typeof strict !== "boolean") {
|
|
104
|
-
throw new
|
|
120
|
+
throw new CoreError({
|
|
121
|
+
message: `配置错误:strict 必须为 boolean,当前值=${String(strict)}`,
|
|
122
|
+
kind: "validation",
|
|
123
|
+
noLog: true,
|
|
124
|
+
meta: { subsystem: "config", operation: "loadBeflyConfig" }
|
|
125
|
+
});
|
|
105
126
|
}
|
|
106
127
|
return config;
|
|
107
128
|
}
|