2023-09-19 20:50:32 +08:00
|
|
|
const tableSchema = {
|
|
|
|
type: "object",
|
|
|
|
properties: {
|
|
|
|
id: { type: "integer" },
|
|
|
|
name: { type: "string" },
|
|
|
|
x: { type: "number" },
|
|
|
|
y: { type: "number" },
|
|
|
|
fields: {
|
|
|
|
type: "array",
|
|
|
|
items: {
|
|
|
|
type: "object",
|
|
|
|
properties: {
|
|
|
|
name: { type: "string" },
|
|
|
|
type: { type: "string" },
|
|
|
|
default: { type: "string" },
|
|
|
|
check: { type: "string" },
|
|
|
|
primary: { type: "boolean" },
|
|
|
|
unique: { type: "boolean" },
|
|
|
|
notNull: { type: "boolean" },
|
|
|
|
increment: { type: "boolean" },
|
|
|
|
comment: { type: "string" },
|
2023-12-20 08:57:29 +08:00
|
|
|
size: { type: ["string", "number"] },
|
2023-09-19 20:50:44 +08:00
|
|
|
values: { type: "array", items: { type: "string" } },
|
2023-09-19 20:50:32 +08:00
|
|
|
},
|
|
|
|
required: [
|
|
|
|
"name",
|
|
|
|
"type",
|
|
|
|
"default",
|
|
|
|
"check",
|
|
|
|
"primary",
|
|
|
|
"unique",
|
|
|
|
"notNull",
|
|
|
|
"increment",
|
|
|
|
"comment",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
comment: { type: "string" },
|
|
|
|
indices: {
|
|
|
|
type: "array",
|
|
|
|
items: {
|
|
|
|
type: "object",
|
|
|
|
properties: {
|
|
|
|
name: { type: "string" },
|
2023-09-19 20:50:45 +08:00
|
|
|
unique: { type: "boolean" },
|
2023-09-19 20:50:32 +08:00
|
|
|
fields: {
|
|
|
|
type: "array",
|
|
|
|
items: { type: "string" },
|
|
|
|
},
|
|
|
|
},
|
2023-09-19 20:50:45 +08:00
|
|
|
required: ["name", "unique", "fields"],
|
2023-09-19 20:50:32 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$" },
|
|
|
|
},
|
|
|
|
required: ["id", "name", "x", "y", "fields", "comment", "indices", "color"],
|
|
|
|
};
|
|
|
|
|
|
|
|
const areaSchema = {
|
|
|
|
type: "object",
|
|
|
|
properties: {
|
|
|
|
id: { type: "integer" },
|
|
|
|
name: { type: "string" },
|
|
|
|
x: { type: "number" },
|
|
|
|
y: { type: "number" },
|
|
|
|
width: { type: "number" },
|
|
|
|
height: { type: "number" },
|
|
|
|
color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$" },
|
|
|
|
},
|
|
|
|
required: ["id", "name", "x", "y", "width", "height", "color"],
|
|
|
|
};
|
|
|
|
|
|
|
|
const noteSchema = {
|
|
|
|
type: "object",
|
|
|
|
properties: {
|
|
|
|
id: { type: "integer" },
|
|
|
|
x: { type: "number" },
|
|
|
|
y: { type: "number" },
|
|
|
|
title: { type: "string" },
|
|
|
|
content: { type: "string" },
|
|
|
|
color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$" },
|
|
|
|
height: { type: "number" },
|
|
|
|
},
|
|
|
|
required: ["id", "x", "y", "title", "content", "color", "height"],
|
|
|
|
};
|
|
|
|
|
2023-09-19 20:51:29 +08:00
|
|
|
const typeSchema = {
|
|
|
|
type: "object",
|
|
|
|
properties: {
|
|
|
|
name: { type: "string" },
|
|
|
|
fields: {
|
|
|
|
type: "array",
|
|
|
|
items: {
|
|
|
|
type: "object",
|
|
|
|
properties: {
|
|
|
|
name: { type: "string" },
|
|
|
|
type: { type: "string" },
|
|
|
|
values: {
|
|
|
|
type: "array",
|
|
|
|
items: { type: "string" },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
required: ["name", "type"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
comment: { type: "string" },
|
|
|
|
},
|
|
|
|
required: ["name", "fields", "comment"],
|
|
|
|
};
|
|
|
|
|
2023-09-19 20:49:28 +08:00
|
|
|
const jsonSchema = {
|
|
|
|
type: "object",
|
|
|
|
properties: {
|
|
|
|
tables: {
|
|
|
|
type: "array",
|
2023-09-19 20:50:44 +08:00
|
|
|
items: { ...tableSchema },
|
2023-09-19 20:49:28 +08:00
|
|
|
},
|
|
|
|
relationships: {
|
|
|
|
type: "array",
|
|
|
|
items: {
|
|
|
|
type: "object",
|
|
|
|
properties: {
|
|
|
|
startTableId: { type: "integer" },
|
|
|
|
startFieldId: { type: "integer" },
|
|
|
|
endTableId: { type: "integer" },
|
|
|
|
endFieldId: { type: "integer" },
|
|
|
|
startX: { type: "number" },
|
|
|
|
startY: { type: "number" },
|
|
|
|
endX: { type: "number" },
|
|
|
|
endY: { type: "number" },
|
|
|
|
name: { type: "string" },
|
|
|
|
cardinality: { type: "string" },
|
|
|
|
updateConstraint: { type: "string" },
|
|
|
|
deleteConstraint: { type: "string" },
|
|
|
|
mandatory: { type: "boolean" },
|
|
|
|
id: { type: "integer" },
|
|
|
|
},
|
|
|
|
required: [
|
|
|
|
"startTableId",
|
|
|
|
"startFieldId",
|
|
|
|
"endTableId",
|
|
|
|
"endFieldId",
|
|
|
|
"startX",
|
|
|
|
"startY",
|
|
|
|
"endX",
|
|
|
|
"endY",
|
|
|
|
"name",
|
|
|
|
"cardinality",
|
|
|
|
"updateConstraint",
|
|
|
|
"deleteConstraint",
|
|
|
|
"mandatory",
|
|
|
|
"id",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
notes: {
|
|
|
|
type: "array",
|
2023-09-19 20:50:44 +08:00
|
|
|
items: { ...noteSchema },
|
2023-09-19 20:49:28 +08:00
|
|
|
},
|
|
|
|
subjectAreas: {
|
|
|
|
type: "array",
|
2023-09-19 20:50:44 +08:00
|
|
|
items: { ...areaSchema },
|
2023-09-19 20:49:28 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
required: ["tables", "relationships", "notes", "subjectAreas"],
|
|
|
|
};
|
|
|
|
|
2023-09-19 20:49:31 +08:00
|
|
|
const ddbSchema = {
|
|
|
|
type: "object",
|
|
|
|
properties: {
|
|
|
|
author: { type: "string" },
|
|
|
|
project: { type: "string" },
|
|
|
|
filename: { type: "string" },
|
|
|
|
date: { type: "string" },
|
|
|
|
...jsonSchema.properties,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2023-09-19 20:51:29 +08:00
|
|
|
export {
|
|
|
|
jsonSchema,
|
|
|
|
ddbSchema,
|
|
|
|
tableSchema,
|
|
|
|
noteSchema,
|
|
|
|
areaSchema,
|
|
|
|
typeSchema,
|
|
|
|
};
|