{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://ordinis.nstart.cloud/schemas/cuod/spacecraft/1.0.0",
  "title": "Spacecraft (КА)",
  "description": "Космический аппарат ДЗЗ. Идентифицируется designator'ом (международное обозначение COSPAR/NORAD ID).",
  "type": "object",
  "required": ["designator", "name", "satellite_type_code", "status"],
  "additionalProperties": false,
  "properties": {
    "designator": {
      "type": "string",
      "description": "Международное обозначение (COSPAR designator), например 1998-067A",
      "pattern": "^[0-9]{4}-[0-9]{3}[A-Z]+$"
    },
    "norad_id": {
      "type": "integer",
      "description": "NORAD catalog number",
      "minimum": 1
    },
    "name": {
      "type": "object",
      "x-localized": true,
      "description": "Наименование аппарата",
      "patternProperties": {
        "^[a-z]{2}-[A-Z]{2}$": { "type": "string", "minLength": 1 }
      },
      "required": ["ru-RU"]
    },
    "operator": {
      "type": "object",
      "x-localized": true,
      "description": "Оператор/владелец КА",
      "patternProperties": {
        "^[a-z]{2}-[A-Z]{2}$": { "type": "string" }
      }
    },
    "country": {
      "type": "string",
      "description": "ISO 3166-1 alpha-2 код страны-оператора",
      "pattern": "^[A-Z]{2}$"
    },
    "satellite_type_code": {
      "type": "string",
      "description": "FK на satellite_type.code. Phase 4 pilot: x-references-on-close: warn — закрытие satellite_type не блокируется, spacecraft остаётся orphan; orphan scanner подхватит на metric (data steward потом repoints).",
      "x-references": "satellite_type.code",
      "x-references-on-close": "warn"
    },
    "mass_kg": {
      "type": "number",
      "description": "Масса КА на старте, кг",
      "minimum": 0
    },
    "launch_date": {
      "type": "string",
      "format": "date"
    },
    "decay_date": {
      "type": "string",
      "format": "date",
      "description": "Дата схода с орбиты (если применимо)"
    },
    "status": {
      "type": "string",
      "description": "FK на spacecraft_status.code",
      "pattern": "^[A-Z][A-Z0-9_]{1,31}$",
      "x-references": "spacecraft_status.code"
    },
    "orbit": {
      "type": "object",
      "description": "Параметры орбиты на эпоху",
      "additionalProperties": false,
      "properties": {
        "type": {
          "type": "string",
          "enum": ["LEO", "MEO", "GEO", "HEO", "SSO", "OTHER"]
        },
        "semimajor_axis_km": { "type": "number", "minimum": 0 },
        "eccentricity": { "type": "number", "minimum": 0, "maximum": 1 },
        "inclination_deg": { "type": "number", "minimum": 0, "maximum": 180 },
        "raan_deg": { "type": "number", "minimum": 0, "maximum": 360 },
        "argument_of_perigee_deg": { "type": "number", "minimum": 0, "maximum": 360 },
        "epoch": { "type": "string", "format": "date-time" }
      }
    },
    "spectrum_bands": {
      "type": "array",
      "description": "Спектральные диапазоны полезной нагрузки",
      "items": {
        "type": "string",
        "enum": ["VIS", "NIR", "SWIR", "MWIR", "LWIR", "TIR", "L_BAND", "S_BAND", "C_BAND", "X_BAND", "KU_BAND", "KA_BAND"]
      },
      "uniqueItems": true
    },
    "mission": {
      "type": "object",
      "x-localized": true,
      "description": "Краткое описание миссии",
      "patternProperties": {
        "^[a-z]{2}-[A-Z]{2}$": { "type": "string" }
      }
    }
  }
}
