{
  "$id": "https://uape.dev/schemas/sub-entity-1.0.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Sub-Entity",
  "description": "Declarative definition of a logical sub-record nested within an Entity. Lets manifests describe rich shapes without coupling to physical tables.",
  "type": "object",
  "additionalProperties": false,
  "required": ["name", "fields"],
  "properties": {
    "name": { "type": "string", "pattern": "^[A-Z][A-Za-z0-9]+$" },
    "description": { "type": "string", "maxLength": 1024 },
    "fields": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": {
        "type": "object",
        "additionalProperties": false,
        "required": ["type"],
        "properties": {
          "type": {
            "type": "string",
            "enum": ["string", "u32", "u64", "i64", "bool", "decimal", "bytes", "uuid", "timestamp_ms"]
          },
          "required": { "type": "boolean", "default": true },
          "indexed":  { "type": "boolean", "default": false },
          "max_len":  { "type": "integer", "minimum": 1, "maximum": 1048576 },
          "default":  {}
        }
      }
    }
  }
}
