mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-29 00:05:01 +00:00
239 lines
6.7 KiB
JSON
239 lines
6.7 KiB
JSON
{
|
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
"$id": "https://metabuilder.dev/schemas/entities.schema.json",
|
|
"title": "Entity Schema Definition",
|
|
"description": "Database entity definitions for MetaBuilder packages",
|
|
"type": "object",
|
|
"required": ["entities"],
|
|
"properties": {
|
|
"entities": {
|
|
"type": "array",
|
|
"description": "Array of entity definitions",
|
|
"items": {
|
|
"$ref": "#/definitions/entity"
|
|
}
|
|
}
|
|
},
|
|
"definitions": {
|
|
"entity": {
|
|
"type": "object",
|
|
"required": ["name", "version", "fields"],
|
|
"properties": {
|
|
"name": {
|
|
"type": "string",
|
|
"description": "Entity name in PascalCase",
|
|
"pattern": "^[A-Z][a-zA-Z0-9]*$"
|
|
},
|
|
"version": {
|
|
"type": "string",
|
|
"description": "Entity schema version",
|
|
"pattern": "^\\d+\\.\\d+$"
|
|
},
|
|
"description": {
|
|
"type": "string",
|
|
"description": "Entity description"
|
|
},
|
|
"checksum": {
|
|
"type": ["string", "null"],
|
|
"description": "Entity checksum for migration tracking"
|
|
},
|
|
"fields": {
|
|
"type": "object",
|
|
"description": "Entity field definitions",
|
|
"additionalProperties": {
|
|
"$ref": "#/definitions/field"
|
|
},
|
|
"minProperties": 1
|
|
},
|
|
"indexes": {
|
|
"type": "array",
|
|
"description": "Index definitions",
|
|
"items": {
|
|
"$ref": "#/definitions/index"
|
|
}
|
|
},
|
|
"relations": {
|
|
"type": "array",
|
|
"description": "Relationship definitions",
|
|
"items": {
|
|
"$ref": "#/definitions/relation"
|
|
}
|
|
},
|
|
"acl": {
|
|
"type": "object",
|
|
"description": "Access control rules",
|
|
"properties": {
|
|
"create": {
|
|
"type": "array",
|
|
"items": { "type": "string" },
|
|
"description": "Roles allowed to create"
|
|
},
|
|
"read": {
|
|
"type": "array",
|
|
"items": { "type": "string" },
|
|
"description": "Roles allowed to read"
|
|
},
|
|
"update": {
|
|
"type": "array",
|
|
"items": { "type": "string" },
|
|
"description": "Roles allowed to update"
|
|
},
|
|
"delete": {
|
|
"type": "array",
|
|
"items": { "type": "string" },
|
|
"description": "Roles allowed to delete"
|
|
},
|
|
"rowLevel": {
|
|
"type": "string",
|
|
"description": "Row-level security expression"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"field": {
|
|
"type": "object",
|
|
"required": ["type"],
|
|
"properties": {
|
|
"type": {
|
|
"type": "string",
|
|
"enum": [
|
|
"string",
|
|
"int",
|
|
"bigint",
|
|
"float",
|
|
"double",
|
|
"boolean",
|
|
"json",
|
|
"date",
|
|
"datetime",
|
|
"timestamp",
|
|
"cuid",
|
|
"uuid",
|
|
"text",
|
|
"blob"
|
|
],
|
|
"description": "Field data type"
|
|
},
|
|
"primary": {
|
|
"type": "boolean",
|
|
"description": "Whether this is a primary key"
|
|
},
|
|
"generated": {
|
|
"type": "boolean",
|
|
"description": "Whether this field is auto-generated"
|
|
},
|
|
"required": {
|
|
"type": "boolean",
|
|
"description": "Whether this field is required"
|
|
},
|
|
"nullable": {
|
|
"type": "boolean",
|
|
"description": "Whether this field can be null"
|
|
},
|
|
"unique": {
|
|
"type": "boolean",
|
|
"description": "Whether this field must be unique"
|
|
},
|
|
"index": {
|
|
"type": "boolean",
|
|
"description": "Whether to create an index on this field"
|
|
},
|
|
"default": {
|
|
"description": "Default value for this field"
|
|
},
|
|
"maxLength": {
|
|
"type": "integer",
|
|
"description": "Maximum length for string fields"
|
|
},
|
|
"minLength": {
|
|
"type": "integer",
|
|
"description": "Minimum length for string fields"
|
|
},
|
|
"min": {
|
|
"type": "number",
|
|
"description": "Minimum value for numeric fields"
|
|
},
|
|
"max": {
|
|
"type": "number",
|
|
"description": "Maximum value for numeric fields"
|
|
},
|
|
"enum": {
|
|
"type": "array",
|
|
"items": { "type": "string" },
|
|
"description": "Allowed enum values"
|
|
},
|
|
"pattern": {
|
|
"type": "string",
|
|
"description": "Regex pattern for validation"
|
|
},
|
|
"description": {
|
|
"type": "string",
|
|
"description": "Field description"
|
|
}
|
|
}
|
|
},
|
|
"index": {
|
|
"type": "object",
|
|
"required": ["fields"],
|
|
"properties": {
|
|
"fields": {
|
|
"type": "array",
|
|
"items": { "type": "string" },
|
|
"description": "Fields to include in this index",
|
|
"minItems": 1
|
|
},
|
|
"unique": {
|
|
"type": "boolean",
|
|
"description": "Whether this is a unique index"
|
|
},
|
|
"name": {
|
|
"type": "string",
|
|
"description": "Index name"
|
|
}
|
|
}
|
|
},
|
|
"relation": {
|
|
"type": "object",
|
|
"required": ["name", "type", "entity"],
|
|
"properties": {
|
|
"name": {
|
|
"type": "string",
|
|
"description": "Relation name"
|
|
},
|
|
"type": {
|
|
"type": "string",
|
|
"enum": ["belongsTo", "hasMany", "hasOne", "manyToMany"],
|
|
"description": "Relationship type"
|
|
},
|
|
"entity": {
|
|
"type": "string",
|
|
"description": "Related entity name"
|
|
},
|
|
"field": {
|
|
"type": "string",
|
|
"description": "Foreign key field (for belongsTo)"
|
|
},
|
|
"foreignKey": {
|
|
"type": "string",
|
|
"description": "Foreign key field on related entity (for hasMany/hasOne)"
|
|
},
|
|
"through": {
|
|
"type": "string",
|
|
"description": "Junction table (for manyToMany)"
|
|
},
|
|
"onDelete": {
|
|
"type": "string",
|
|
"enum": ["Cascade", "SetNull", "Restrict", "NoAction"],
|
|
"description": "Action on delete"
|
|
},
|
|
"onUpdate": {
|
|
"type": "string",
|
|
"enum": ["Cascade", "SetNull", "Restrict", "NoAction"],
|
|
"description": "Action on update"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|