{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ekspertiz.bumba.tr/standart/0.1/rapor.schema.json",
  "title": "Ekspertiz raporu (taslak 0.1.0)",
  "description": "Bir ekspertiz raporunun makinece okunur biçimi. Kodların adları ve puanlama standart.json'dadır. Taslaktır; değişebilir.",
  "type": "object",
  "required": ["standardVersion", "reportId", "issuedAt", "issuer", "vehicle", "body", "structure", "sections", "photos"],
  "additionalProperties": false,
  "properties": {
    "standardVersion": { "const": "0.1.0" },
    "sample": { "type": "boolean", "description": "Örnek (gerçek olmayan) rapor ise true." },
    "reportId": { "type": "string", "minLength": 1, "maxLength": 64, "description": "Raporu düzenleyen merkezin rapor numarası." },
    "issuedAt": { "type": "string", "format": "date-time", "description": "Düzenlenme anı, UTC (ör. 2026-11-28T09:30:00Z)." },
    "language": { "enum": ["tr", "en"] },
    "verification": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "url": { "type": "string", "format": "uri", "description": "Raporun aslını gösteren adres." },
        "nationalSystemId": { "type": "string", "maxLength": 64, "description": "Ülkenin resmî rapor sistemindeki numara (Türkiye: taslak yönetmelikteki Taşıt Ekspertiz Bilgi Sistemi; yürürlükte değil)." }
      }
    },
    "issuer": {
      "type": "object",
      "required": ["name", "country"],
      "additionalProperties": false,
      "properties": {
        "name": { "type": "string", "minLength": 1, "maxLength": 200 },
        "country": { "type": "string", "pattern": "^[A-Z]{2}$", "description": "ISO 3166-1 alfa-2." },
        "city": { "type": "string", "maxLength": 100 },
        "registryId": { "type": "string", "maxLength": 64, "description": "Ticari sicil numarası (Türkiye: MERSİS ya da ESBİS)." },
        "accreditations": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["scheme", "number"],
            "additionalProperties": false,
            "properties": {
              "scheme": { "type": "string", "maxLength": 64, "description": "Ör. 'TS 13805' (Türkiye, TSE hizmet yeterlilik belgesi)." },
              "number": { "type": "string", "maxLength": 64 },
              "validUntil": { "type": "string", "format": "date" }
            }
          }
        },
        "technicalLead": { "type": "string", "maxLength": 200, "description": "Raporu onaylayan teknik sorumlunun unvanı ya da adı; paylaşılan kayıtta yazılmayabilir." }
      }
    },
    "vehicle": {
      "type": "object",
      "required": ["vin", "make", "model", "modelYear", "odometer"],
      "additionalProperties": false,
      "properties": {
        "vin": { "type": "string", "pattern": "^[A-HJ-NPR-Z0-9]{17}$", "description": "ISO 3779 şasi numarası, 17 karakter, I, O ve Q yok." },
        "make": { "type": "string", "minLength": 1, "maxLength": 64 },
        "model": { "type": "string", "minLength": 1, "maxLength": 64 },
        "variant": { "type": "string", "maxLength": 128 },
        "category": { "enum": ["M1", "M1G", "N1", "N1G"] },
        "modelYear": { "type": "integer", "minimum": 1900, "maximum": 2100 },
        "fuel": { "enum": ["petrol", "diesel", "lpg", "cng", "hybrid", "plug_in_hybrid", "electric", "hydrogen", "other"] },
        "transmission": { "enum": ["manual", "automatic", "semi_automatic", "cvt", "single_speed"] },
        "colour": { "type": "string", "maxLength": 64 },
        "plate": { "type": "string", "maxLength": 16, "description": "İsteğe bağlı; paylaşılan görünümde maskelenir." },
        "odometer": {
          "type": "object",
          "required": ["value", "unit"],
          "additionalProperties": false,
          "properties": {
            "value": { "type": "integer", "minimum": 0 },
            "unit": { "enum": ["km", "mi"] }
          }
        }
      }
    },
    "body": {
      "type": "array",
      "description": "Her kaporta parçası bir kez yazılır.",
      "items": {
        "type": "object",
        "required": ["part", "state"],
        "additionalProperties": false,
        "properties": {
          "part": { "enum": ["front_bumper", "hood", "front_left_fender", "front_right_fender", "front_left_door", "front_right_door", "rear_left_door", "rear_right_door", "left_sill", "right_sill", "rear_left_quarter", "rear_right_quarter", "roof", "trunk_lid", "rear_bumper"] },
          "state": { "enum": ["original", "paintless_repair", "local_paint", "painted", "removed_refitted", "replaced", "not_inspected"] },
          "paintMicrons": {
            "type": "object",
            "additionalProperties": false,
            "properties": { "min": { "type": "integer", "minimum": 0 }, "max": { "type": "integer", "minimum": 0 } }
          },
          "wrapped": { "type": "boolean", "description": "Folyo ya da kaplama varsa true; boya ölçümü güvenilmez." },
          "note": { "type": "string", "maxLength": 500 }
        }
      }
    },
    "structure": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["part", "state"],
        "additionalProperties": false,
        "properties": {
          "part": { "enum": ["front_panel", "left_front_rail", "right_front_rail", "left_strut_tower", "right_strut_tower", "left_a_pillar", "right_a_pillar", "left_b_pillar", "right_b_pillar", "left_c_pillar", "right_c_pillar", "floor_pan", "left_rear_rail", "right_rear_rail", "trunk_floor"] },
          "state": { "enum": ["original", "repaired", "replaced", "damaged", "not_inspected"] },
          "note": { "type": "string", "maxLength": 500 }
        }
      }
    },
    "sections": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["section", "checks"],
        "additionalProperties": false,
        "properties": {
          "section": { "enum": ["engine", "transmission", "suspension_steering", "brakes", "tires", "electrical", "interior", "underbody", "traction_battery"] },
          "checks": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["point", "result"],
              "additionalProperties": false,
              "properties": {
                "point": { "type": "string", "pattern": "^[a-z_]+$" },
                "result": { "enum": ["ok", "attention", "defect", "not_inspected", "not_applicable"] },
                "note": { "type": "string", "maxLength": 500 },
                "treadMm": { "type": "number", "minimum": 0, "maximum": 20, "description": "Lastikte diş derinliği." },
                "dot": { "type": "string", "pattern": "^[0-9]{4}$", "description": "Lastikte üretim haftası ve yılı (HHYY)." },
                "faultCodes": { "type": "array", "items": { "type": "string", "pattern": "^[PCBU][0-9A-F]{4}$" } },
                "sohPercent": { "type": "number", "minimum": 0, "maximum": 100 }
              }
            }
          }
        }
      }
    },
    "photos": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["angle"],
        "additionalProperties": false,
        "properties": {
          "angle": { "enum": ["front", "front_left_34", "left", "rear_left_34", "rear", "rear_right_34", "right", "front_right_34", "odometer", "vin", "engine_bay", "interior_front", "interior_rear", "trunk", "tire_front_left", "tire_front_right", "tire_rear_left", "tire_rear_right", "underbody", "finding"] },
          "part": { "type": "string", "pattern": "^[a-z_]+$", "description": "Bulgu fotoğrafının bağlı olduğu parça kodu." },
          "uri": { "type": "string", "format": "uri-reference" },
          "sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
          "takenAt": { "type": "string", "format": "date-time" }
        }
      }
    },
    "roadTest": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "done": { "type": "boolean" },
        "distanceKm": { "type": "number", "minimum": 0 },
        "note": { "type": "string", "maxLength": 1000 }
      }
    },
    "summary": { "type": "string", "maxLength": 2000, "description": "Merkezin genel notu." }
  }
}
