{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://mlprep.iwase.dev/schema/item.json",
  "title": "ML preparation item",
  "type": "object",
  "required": ["id", "area", "topic", "origin", "title", "skills", "priority", "difficulty", "estimated_minutes", "prerequisites"],
  "properties": {
    "id": {"type": "string", "pattern": "^[a-z0-9][a-z0-9.-]*$"},
    "area": {"enum": ["mathematics", "programming", "machine-learning"]},
    "topic": {"type": "string"},
    "origin": {"enum": ["external", "original"]},
    "title": {"type": "string"},
    "skills": {"type": "array", "minItems": 1, "items": {"type": "string"}},
    "priority": {"enum": ["foundation", "core", "stretch", "supplementary"]},
    "difficulty": {"enum": ["easy", "medium", "hard"]},
    "estimated_minutes": {"type": "integer", "minimum": 1},
    "prerequisites": {"type": "array", "items": {"type": "string"}},

    "source_id": {"type": "string"},
    "locator": {"type": "object"},
    "links": {"type": "object", "required": ["problem"], "properties": {"problem": {"type": "string", "format": "uri"}, "solution": {"type": "string", "format": "uri"}}},
    "selection_note": {"type": "string"},
    "answer_status": {"enum": ["official-solution", "official-answer", "official-interactive-feedback", "no-official-solution"]},

    "prompt": {"type": "string"},
    "answer": {"type": "string"},
    "starter_code": {"type": "string"},
    "reference_solution": {"type": "string"},
    "tests": {"type": "array"},
    "check": {"type": "object"}
  },
  "allOf": [
    {
      "if": {"properties": {"origin": {"const": "external"}}},
      "then": {"required": ["source_id", "locator", "links", "selection_note", "answer_status"]}
    },
    {
      "if": {"properties": {"origin": {"const": "original"}}},
      "then": {"required": ["prompt"]}
    }
  ],
  "additionalProperties": true
}
