befly 3.15.3 → 3.15.4
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 +9 -0
- package/dist/befly.js +96 -41
- package/dist/befly.min.js +11 -11
- package/dist/checks/checkConfig.js +47 -0
- package/dist/checks/checkTable.d.ts +2 -1
- package/dist/checks/checkTable.js +41 -40
- package/dist/index.js +1 -1
- package/dist/types/befly.d.ts +8 -0
- package/package.json +2 -2
package/dist/befly.config.js
CHANGED
|
@@ -12,6 +12,7 @@ const defaultOptions = {
|
|
|
12
12
|
devPassword: "beflydev123456",
|
|
13
13
|
bodyLimit: 1048576, // 1MB
|
|
14
14
|
tz: "Asia/Shanghai",
|
|
15
|
+
strict: true,
|
|
15
16
|
// ========== 日志配置 ==========
|
|
16
17
|
logger: {
|
|
17
18
|
debug: 1,
|
|
@@ -98,5 +99,13 @@ export async function loadBeflyConfig(nodeEnv) {
|
|
|
98
99
|
if (idMode !== undefined && idMode !== "timeId" && idMode !== "autoId") {
|
|
99
100
|
throw new Error(`配置错误:db.idMode 只能是 'timeId' 或 'autoId',当前值=${String(idMode)}`);
|
|
100
101
|
}
|
|
102
|
+
const strict = config.strict;
|
|
103
|
+
if (strict !== undefined && typeof strict !== "boolean") {
|
|
104
|
+
throw new Error(`配置错误:strict 必须为 boolean,当前值=${String(strict)}`);
|
|
105
|
+
}
|
|
106
|
+
const legacyCheckTable = config.checkTable;
|
|
107
|
+
if (legacyCheckTable !== undefined) {
|
|
108
|
+
throw new Error(`配置错误:checkTable 配置已废弃,请使用根属性 strict(例如 { "strict": false }),当前值=${String(legacyCheckTable)}`);
|
|
109
|
+
}
|
|
101
110
|
return config;
|
|
102
111
|
}
|
package/dist/befly.js
CHANGED
|
@@ -7537,6 +7537,7 @@ var defaultOptions = {
|
|
|
7537
7537
|
devPassword: "beflydev123456",
|
|
7538
7538
|
bodyLimit: 1048576,
|
|
7539
7539
|
tz: "Asia/Shanghai",
|
|
7540
|
+
strict: true,
|
|
7540
7541
|
logger: {
|
|
7541
7542
|
debug: 1,
|
|
7542
7543
|
excludeFields: ["password", "token", "secret"],
|
|
@@ -7607,6 +7608,14 @@ async function loadBeflyConfig(nodeEnv) {
|
|
|
7607
7608
|
if (idMode !== undefined && idMode !== "timeId" && idMode !== "autoId") {
|
|
7608
7609
|
throw new Error(`\u914D\u7F6E\u9519\u8BEF\uFF1Adb.idMode \u53EA\u80FD\u662F 'timeId' \u6216 'autoId'\uFF0C\u5F53\u524D\u503C=${String(idMode)}`);
|
|
7609
7610
|
}
|
|
7611
|
+
const strict = config2.strict;
|
|
7612
|
+
if (strict !== undefined && typeof strict !== "boolean") {
|
|
7613
|
+
throw new Error(`\u914D\u7F6E\u9519\u8BEF\uFF1Astrict \u5FC5\u987B\u4E3A boolean\uFF0C\u5F53\u524D\u503C=${String(strict)}`);
|
|
7614
|
+
}
|
|
7615
|
+
const legacyCheckTable = config2.checkTable;
|
|
7616
|
+
if (legacyCheckTable !== undefined) {
|
|
7617
|
+
throw new Error(`\u914D\u7F6E\u9519\u8BEF\uFF1AcheckTable \u914D\u7F6E\u5DF2\u5E9F\u5F03\uFF0C\u8BF7\u4F7F\u7528\u6839\u5C5E\u6027 strict\uFF08\u4F8B\u5982 { "strict": false }\uFF09\uFF0C\u5F53\u524D\u503C=${String(legacyCheckTable)}`);
|
|
7618
|
+
}
|
|
7610
7619
|
return config2;
|
|
7611
7620
|
}
|
|
7612
7621
|
|
|
@@ -7730,6 +7739,19 @@ function isValidPort(value) {
|
|
|
7730
7739
|
function isValidNonNegativeInt(value) {
|
|
7731
7740
|
return typeof value === "number" && Number.isFinite(value) && value >= 0 && Math.floor(value) === value;
|
|
7732
7741
|
}
|
|
7742
|
+
function isValidPositiveInt(value) {
|
|
7743
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 1 && Math.floor(value) === value;
|
|
7744
|
+
}
|
|
7745
|
+
function isValidTimeZone(value) {
|
|
7746
|
+
if (!isNonEmptyString(value))
|
|
7747
|
+
return false;
|
|
7748
|
+
try {
|
|
7749
|
+
new Intl.DateTimeFormat("en-US", { timeZone: value }).format(0);
|
|
7750
|
+
return true;
|
|
7751
|
+
} catch {
|
|
7752
|
+
return false;
|
|
7753
|
+
}
|
|
7754
|
+
}
|
|
7733
7755
|
function validateDbConfig(db) {
|
|
7734
7756
|
if (!db) {
|
|
7735
7757
|
throw new Error("\u914D\u7F6E\u9519\u8BEF\uFF1A\u7F3A\u5C11 db \u914D\u7F6E\uFF08config.db\uFF09");
|
|
@@ -7785,6 +7807,11 @@ async function checkConfig(config2) {
|
|
|
7785
7807
|
if (config2.nodeEnv !== "development" && config2.nodeEnv !== "production") {
|
|
7786
7808
|
throw new Error(`\u914D\u7F6E\u9519\u8BEF\uFF1AnodeEnv \u53EA\u80FD\u662F development/production\uFF0C\u5F53\u524D\u503C=${String(config2.nodeEnv)}`);
|
|
7787
7809
|
}
|
|
7810
|
+
if (config2.appName !== undefined) {
|
|
7811
|
+
if (!isNonEmptyString(config2.appName)) {
|
|
7812
|
+
throw new Error(`\u914D\u7F6E\u9519\u8BEF\uFF1AappName \u5FC5\u987B\u4E3A\u975E\u7A7A\u5B57\u7B26\u4E32\uFF0C\u5F53\u524D\u503C=${String(config2.appName)}`);
|
|
7813
|
+
}
|
|
7814
|
+
}
|
|
7788
7815
|
if (config2.appPort !== undefined) {
|
|
7789
7816
|
if (!isValidPort(config2.appPort)) {
|
|
7790
7817
|
throw new Error(`\u914D\u7F6E\u9519\u8BEF\uFF1AappPort \u5FC5\u987B\u4E3A 1..65535 \u7684\u6570\u5B57\uFF0C\u5F53\u524D\u503C=${String(config2.appPort)}`);
|
|
@@ -7795,6 +7822,33 @@ async function checkConfig(config2) {
|
|
|
7795
7822
|
throw new Error(`\u914D\u7F6E\u9519\u8BEF\uFF1AappHost \u5FC5\u987B\u4E3A\u975E\u7A7A\u5B57\u7B26\u4E32\uFF0C\u5F53\u524D\u503C=${String(config2.appHost)}`);
|
|
7796
7823
|
}
|
|
7797
7824
|
}
|
|
7825
|
+
if (config2.devEmail !== undefined) {
|
|
7826
|
+
if (typeof config2.devEmail !== "string") {
|
|
7827
|
+
throw new Error(`\u914D\u7F6E\u9519\u8BEF\uFF1AdevEmail \u5FC5\u987B\u4E3A\u5B57\u7B26\u4E32\uFF08\u5141\u8BB8\u4E3A\u7A7A\u5B57\u7B26\u4E32\uFF09\uFF0C\u5F53\u524D\u503C=${String(config2.devEmail)}`);
|
|
7828
|
+
}
|
|
7829
|
+
const trimmedDevEmail = config2.devEmail.trim();
|
|
7830
|
+
if (trimmedDevEmail.length > 0 && !trimmedDevEmail.includes("@")) {
|
|
7831
|
+
throw new Error(`\u914D\u7F6E\u9519\u8BEF\uFF1AdevEmail \u683C\u5F0F\u9519\u8BEF\uFF08\u5FC5\u987B\u5305\u542B '@'\uFF0C\u6216\u7F6E\u4E3A\u7A7A\u5B57\u7B26\u4E32\u4EE5\u7981\u7528 syncDev\uFF09\uFF0C\u5F53\u524D\u503C=${String(config2.devEmail)}`);
|
|
7832
|
+
}
|
|
7833
|
+
}
|
|
7834
|
+
if (config2.devPassword !== undefined) {
|
|
7835
|
+
if (typeof config2.devPassword !== "string") {
|
|
7836
|
+
throw new Error(`\u914D\u7F6E\u9519\u8BEF\uFF1AdevPassword \u5FC5\u987B\u4E3A\u5B57\u7B26\u4E32\uFF08\u5141\u8BB8\u4E3A\u7A7A\u5B57\u7B26\u4E32\uFF09\uFF0C\u5F53\u524D\u503C=${String(config2.devPassword)}`);
|
|
7837
|
+
}
|
|
7838
|
+
}
|
|
7839
|
+
if (config2.bodyLimit !== undefined) {
|
|
7840
|
+
if (!isValidPositiveInt(config2.bodyLimit)) {
|
|
7841
|
+
throw new Error(`\u914D\u7F6E\u9519\u8BEF\uFF1AbodyLimit \u5FC5\u987B\u4E3A\u6B63\u6574\u6570\uFF08\u5B57\u8282\uFF09\uFF0C\u5F53\u524D\u503C=${String(config2.bodyLimit)}`);
|
|
7842
|
+
}
|
|
7843
|
+
}
|
|
7844
|
+
if (config2.tz !== undefined) {
|
|
7845
|
+
if (!isValidTimeZone(config2.tz)) {
|
|
7846
|
+
throw new Error(`\u914D\u7F6E\u9519\u8BEF\uFF1Atz \u5FC5\u987B\u4E3A\u6709\u6548\u7684 IANA \u65F6\u533A\u5B57\u7B26\u4E32\uFF08\u4F8B\u5982 'Asia/Shanghai'\uFF09\uFF0C\u5F53\u524D\u503C=${String(config2.tz)}`);
|
|
7847
|
+
}
|
|
7848
|
+
}
|
|
7849
|
+
if (typeof config2.strict !== "boolean") {
|
|
7850
|
+
throw new Error(`\u914D\u7F6E\u9519\u8BEF\uFF1Astrict \u5FC5\u987B\u4E3A true \u6216 false\uFF0C\u5F53\u524D\u503C=${String(config2.strict)}`);
|
|
7851
|
+
}
|
|
7798
7852
|
validateDbConfig(config2.db);
|
|
7799
7853
|
validateRedisConfig(config2.redis);
|
|
7800
7854
|
}
|
|
@@ -8201,7 +8255,7 @@ var FIELD_NAME_REGEX = /^[\u4e00-\u9fa5a-zA-Z0-9 _-]+$/;
|
|
|
8201
8255
|
var MAX_VARCHAR_LENGTH = 16383;
|
|
8202
8256
|
var MAX_INDEX_STRING_LENGTH_FOR_INDEX = 500;
|
|
8203
8257
|
var MAX_INDEX_STRING_LENGTH_FOR_UNIQUE = 180;
|
|
8204
|
-
async function checkTable(tables) {
|
|
8258
|
+
async function checkTable(tables, config2) {
|
|
8205
8259
|
let hasError = false;
|
|
8206
8260
|
for (const item of tables) {
|
|
8207
8261
|
if (item.type !== "table") {
|
|
@@ -8290,87 +8344,88 @@ async function checkTable(tables) {
|
|
|
8290
8344
|
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u5B57\u6BB5 default \u7C7B\u578B\u9519\u8BEF\uFF0C\u5FC5\u987B\u4E3A\u53EF JSON \u5E8F\u5217\u5316\u7684\u503C\u6216 null` + `\uFF08typeof=${typeof field.default}\uFF0Cvalue=${formatValuePreview(field.default)}\uFF09`);
|
|
8291
8345
|
hasError = true;
|
|
8292
8346
|
}
|
|
8293
|
-
|
|
8294
|
-
|
|
8295
|
-
|
|
8296
|
-
|
|
8347
|
+
if (config2.strict) {
|
|
8348
|
+
if (!FIELD_NAME_REGEX.test(field.name)) {
|
|
8349
|
+
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u5B57\u6BB5\u540D\u79F0 "${field.name}" \u683C\u5F0F\u9519\u8BEF\uFF0C` + `\u5FC5\u987B\u4E3A\u4E2D\u6587\u3001\u6570\u5B57\u3001\u5B57\u6BCD\u3001\u4E0B\u5212\u7EBF\u3001\u77ED\u6A2A\u7EBF\u3001\u7A7A\u683C`);
|
|
8350
|
+
hasError = true;
|
|
8351
|
+
}
|
|
8297
8352
|
}
|
|
8298
|
-
if (!FIELD_TYPE_SET.has(
|
|
8299
|
-
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u5B57\u6BB5\u7C7B\u578B "${
|
|
8353
|
+
if (!FIELD_TYPE_SET.has(field.type)) {
|
|
8354
|
+
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u5B57\u6BB5\u7C7B\u578B "${field.type}" \u683C\u5F0F\u9519\u8BEF\uFF0C` + `\u5FC5\u987B\u4E3A${FIELD_TYPES.join("\u3001")}\u4E4B\u4E00`);
|
|
8300
8355
|
hasError = true;
|
|
8301
8356
|
}
|
|
8302
|
-
if (
|
|
8303
|
-
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u5B57\u6BB5\u7C7B\u578B\u4E3A ${
|
|
8357
|
+
if (field.type !== "number" && field.unsigned !== undefined) {
|
|
8358
|
+
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u5B57\u6BB5\u7C7B\u578B\u4E3A ${field.type}\uFF0C\u4E0D\u5141\u8BB8\u8BBE\u7F6E unsigned\uFF08\u4EC5 number \u7C7B\u578B\u6709\u6548\uFF09`);
|
|
8304
8359
|
hasError = true;
|
|
8305
8360
|
}
|
|
8306
8361
|
if (field.unique === true && field.index === true) {
|
|
8307
8362
|
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u540C\u65F6\u8BBE\u7F6E\u4E86 unique=true \u548C index=true\uFF0C` + `unique \u548C index \u4E0D\u80FD\u540C\u65F6\u8BBE\u7F6E\uFF0C\u8BF7\u5220\u9664\u5176\u4E00\uFF08\u5426\u5219\u4F1A\u521B\u5EFA\u91CD\u590D\u7D22\u5F15\uFF09`);
|
|
8308
8363
|
hasError = true;
|
|
8309
8364
|
}
|
|
8310
|
-
if (
|
|
8311
|
-
if (
|
|
8312
|
-
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u6700\u5C0F\u503C "${
|
|
8365
|
+
if (field.min !== undefined && field.max !== undefined && field.min !== null && field.max !== null) {
|
|
8366
|
+
if (field.min > field.max) {
|
|
8367
|
+
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u6700\u5C0F\u503C "${field.min}" \u4E0D\u80FD\u5927\u4E8E\u6700\u5927\u503C "${field.max}"`);
|
|
8313
8368
|
hasError = true;
|
|
8314
8369
|
}
|
|
8315
8370
|
}
|
|
8316
|
-
if (
|
|
8317
|
-
if (
|
|
8318
|
-
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u7684 ${
|
|
8371
|
+
if (field.type === "text" || field.type === "array_text" || field.type === "array_number_text") {
|
|
8372
|
+
if (field.min !== undefined && field.min !== null) {
|
|
8373
|
+
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u7684 ${field.type} \u7C7B\u578B\u6700\u5C0F\u503C\u5E94\u4E3A null\uFF0C\u5F53\u524D\u4E3A "${field.min}"`);
|
|
8319
8374
|
hasError = true;
|
|
8320
8375
|
}
|
|
8321
|
-
if (
|
|
8322
|
-
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u7684 ${
|
|
8376
|
+
if (field.max !== undefined && field.max !== null) {
|
|
8377
|
+
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u7684 ${field.type} \u7C7B\u578B\u6700\u5927\u957F\u5EA6\u5E94\u4E3A null\uFF0C\u5F53\u524D\u4E3A "${field.max}"`);
|
|
8323
8378
|
hasError = true;
|
|
8324
8379
|
}
|
|
8325
|
-
if (
|
|
8326
|
-
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A ${
|
|
8380
|
+
if (field.default !== undefined && field.default !== null) {
|
|
8381
|
+
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A ${field.type} \u7C7B\u578B\uFF0C\u9ED8\u8BA4\u503C\u5FC5\u987B\u4E3A null\uFF0C\u5F53\u524D\u4E3A "${field.default}"`);
|
|
8327
8382
|
hasError = true;
|
|
8328
8383
|
}
|
|
8329
8384
|
if (field.index === true) {
|
|
8330
|
-
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A ${
|
|
8385
|
+
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A ${field.type} \u7C7B\u578B\uFF0C\u4E0D\u652F\u6301\u521B\u5EFA\u7D22\u5F15\uFF08index=true \u65E0\u6548\uFF09`);
|
|
8331
8386
|
hasError = true;
|
|
8332
8387
|
}
|
|
8333
8388
|
if (field.unique === true) {
|
|
8334
|
-
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A ${
|
|
8389
|
+
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A ${field.type} \u7C7B\u578B\uFF0C\u4E0D\u652F\u6301\u552F\u4E00\u7EA6\u675F\uFF08unique=true \u65E0\u6548\uFF09`);
|
|
8335
8390
|
hasError = true;
|
|
8336
8391
|
}
|
|
8337
|
-
} else if (
|
|
8338
|
-
if (
|
|
8339
|
-
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A ${
|
|
8392
|
+
} else if (field.type === "string" || field.type === "array_string" || field.type === "array_number_string") {
|
|
8393
|
+
if (field.max === undefined || field.max === null || typeof field.max !== "number") {
|
|
8394
|
+
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A ${field.type} \u7C7B\u578B\uFF0C` + `\u5FC5\u987B\u8BBE\u7F6E max \u4E14\u7C7B\u578B\u4E3A\u6570\u5B57\uFF1B\u5176\u4E2D array_*_string \u7684 max \u8868\u793A\u5355\u4E2A\u5143\u7D20\u957F\u5EA6\uFF0C\u5F53\u524D\u4E3A "${field.max}"`);
|
|
8340
8395
|
hasError = true;
|
|
8341
|
-
} else if (
|
|
8342
|
-
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u6700\u5927\u957F\u5EA6 ${
|
|
8396
|
+
} else if (field.max > MAX_VARCHAR_LENGTH) {
|
|
8397
|
+
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u6700\u5927\u957F\u5EA6 ${field.max} \u8D8A\u754C\uFF0C` + `${field.type} \u7C7B\u578B\u957F\u5EA6\u5FC5\u987B\u5728 1..${MAX_VARCHAR_LENGTH} \u8303\u56F4\u5185`);
|
|
8343
8398
|
hasError = true;
|
|
8344
8399
|
} else {
|
|
8345
|
-
if (field.index === true &&
|
|
8346
|
-
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u8BBE\u7F6E\u4E86 index=true\uFF0C` + `\u4F46 max=${
|
|
8400
|
+
if (field.index === true && field.max > MAX_INDEX_STRING_LENGTH_FOR_INDEX) {
|
|
8401
|
+
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u8BBE\u7F6E\u4E86 index=true\uFF0C` + `\u4F46 max=${field.max} \u8D85\u51FA\u5141\u8BB8\u8303\u56F4\uFF08\u8981\u6C42 <= ${MAX_INDEX_STRING_LENGTH_FOR_INDEX}\uFF09`);
|
|
8347
8402
|
hasError = true;
|
|
8348
8403
|
}
|
|
8349
|
-
if (field.unique === true &&
|
|
8350
|
-
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u8BBE\u7F6E\u4E86 unique=true\uFF0C` + `\u4F46 max=${
|
|
8404
|
+
if (field.unique === true && field.max > MAX_INDEX_STRING_LENGTH_FOR_UNIQUE) {
|
|
8405
|
+
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u8BBE\u7F6E\u4E86 unique=true\uFF0C` + `\u4F46 max=${field.max} \u8D85\u51FA\u5141\u8BB8\u8303\u56F4\uFF08\u8981\u6C42 <= ${MAX_INDEX_STRING_LENGTH_FOR_UNIQUE}\uFF09`);
|
|
8351
8406
|
hasError = true;
|
|
8352
8407
|
}
|
|
8353
8408
|
}
|
|
8354
|
-
if (
|
|
8355
|
-
if (typeof
|
|
8356
|
-
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A ${
|
|
8409
|
+
if (field.default !== undefined && field.default !== null) {
|
|
8410
|
+
if (typeof field.default !== "string") {
|
|
8411
|
+
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A ${field.type} \u7C7B\u578B\uFF0C\u9ED8\u8BA4\u503C\u5FC5\u987B\u4E3A\u5B57\u7B26\u4E32\u6216 null` + `\uFF08typeof=${typeof field.default}\uFF0Cvalue=${formatValuePreview(field.default)}\uFF09`);
|
|
8357
8412
|
hasError = true;
|
|
8358
|
-
} else if (
|
|
8413
|
+
} else if (field.type !== "string") {
|
|
8359
8414
|
try {
|
|
8360
|
-
const parsed = JSON.parse(
|
|
8415
|
+
const parsed = JSON.parse(field.default);
|
|
8361
8416
|
if (!Array.isArray(parsed)) {
|
|
8362
|
-
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A ${
|
|
8417
|
+
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A ${field.type} \u7C7B\u578B\uFF0C\u9ED8\u8BA4\u503C\u5E94\u4E3A JSON \u6570\u7EC4\u5B57\u7B26\u4E32\uFF08\u4F8B\u5982 "[]"\uFF09` + `\uFF08value=${formatValuePreview(field.default)}\uFF09`);
|
|
8363
8418
|
hasError = true;
|
|
8364
8419
|
}
|
|
8365
8420
|
} catch {
|
|
8366
|
-
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A ${
|
|
8421
|
+
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A ${field.type} \u7C7B\u578B\uFF0C\u9ED8\u8BA4\u503C\u5E94\u4E3A JSON \u6570\u7EC4\u5B57\u7B26\u4E32\uFF08\u4F8B\u5982 "[]"\uFF09` + `\uFF08value=${formatValuePreview(field.default)}\uFF09`);
|
|
8367
8422
|
hasError = true;
|
|
8368
8423
|
}
|
|
8369
8424
|
}
|
|
8370
8425
|
}
|
|
8371
|
-
} else if (
|
|
8372
|
-
if (
|
|
8373
|
-
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A number \u7C7B\u578B\uFF0C\u9ED8\u8BA4\u503C\u5FC5\u987B\u4E3A\u6570\u5B57\u6216 null` + `\uFF08typeof=${typeof
|
|
8426
|
+
} else if (field.type === "number") {
|
|
8427
|
+
if (field.default !== undefined && field.default !== null && typeof field.default !== "number") {
|
|
8428
|
+
Logger.warn(`${tablePrefix}${fileName} \u6587\u4EF6 ${colKey} \u4E3A number \u7C7B\u578B\uFF0C\u9ED8\u8BA4\u503C\u5FC5\u987B\u4E3A\u6570\u5B57\u6216 null` + `\uFF08typeof=${typeof field.default}\uFF0Cvalue=${formatValuePreview(field.default)}\uFF09`);
|
|
8374
8429
|
hasError = true;
|
|
8375
8430
|
}
|
|
8376
8431
|
}
|
|
@@ -15578,7 +15633,7 @@ class Befly {
|
|
|
15578
15633
|
const { apis, tables, plugins, hooks, addons } = await scanSources();
|
|
15579
15634
|
this.context["addons"] = addons;
|
|
15580
15635
|
await checkApi(apis);
|
|
15581
|
-
await checkTable(tables);
|
|
15636
|
+
await checkTable(tables, this.config);
|
|
15582
15637
|
await checkPlugin(plugins);
|
|
15583
15638
|
await checkHook(hooks);
|
|
15584
15639
|
const checkedMenus = await checkMenu(addons);
|