feat!: 去掉 json 类型(object 取代) + 版本统一 0.7.0
- object 字段已能声明式表达嵌套结构,freeform 的 json 类型不再需要: 删 ShrimpFieldTypes.Json + defaultTypeHandlers[Json](reqFilter/resFilter)。 - 源码无任何 type:json 使用,安全移除。 - 前后端版本自此统一:一起推的版本用相同版本号,本批 = 0.7.0。
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "shrimp-server",
|
||||
"version": "0.6.11",
|
||||
"version": "0.7.0",
|
||||
"description": "Shrimp 框架后端 — 声明式字段驱动的 Node.js 管理后台框架(Express + Mongoose + JWT)",
|
||||
"main": "dist/main/index.js",
|
||||
"types": "dist/main/index.d.ts",
|
||||
|
||||
@@ -235,7 +235,6 @@ export const ShrimpFieldTypes = {
|
||||
Textarea: "textarea" as ShrimpFieldType,
|
||||
Password: "password" as ShrimpFieldType,
|
||||
Relation: "relation" as ShrimpFieldType,
|
||||
Json: "json" as ShrimpFieldType,
|
||||
Tab: "tab" as ShrimpFieldType,
|
||||
Object: "object" as ShrimpFieldType,
|
||||
Array: "array" as ShrimpFieldType,
|
||||
|
||||
@@ -27,26 +27,6 @@ export const defaultTypeHandlers: Record<string, IFieldTypeHandler> = {
|
||||
[ShrimpFieldTypes.Boolean]: {
|
||||
defaultValue: false,
|
||||
},
|
||||
[ShrimpFieldTypes.Json]: {
|
||||
reqFilter: (value) => {
|
||||
if (value == null || value === "") return undefined
|
||||
if (typeof value === "string") {
|
||||
try {
|
||||
return JSON.parse(value)
|
||||
} catch {
|
||||
throw new ShrimpError({ t: 'shrimp.invalidJson' })
|
||||
}
|
||||
}
|
||||
return value
|
||||
},
|
||||
resFilter: (value) => {
|
||||
if (value == null) return value
|
||||
if (typeof value === "object") {
|
||||
return JSON.stringify(value)
|
||||
}
|
||||
return value
|
||||
},
|
||||
},
|
||||
[ShrimpFieldTypes.Tab]: {
|
||||
// tab 是结构化字段:库里/响应/编辑全程是对象,只在"给人看"的边界(import/export/label)走字符串。
|
||||
reqFilter: (value, field) => {
|
||||
|
||||
Reference in New Issue
Block a user