{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://kashmos.com/v1/schema.json",
  "title": "Kashmos sky day, v1",
  "description": "Real sky events listed for one date. Events are those whose UTC time falls in the window [date-1 10:00Z, date+1 12:00Z), the span in which the date is the local date somewhere on Earth. Data licensed CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/): credit kashmos.com.",
  "type": "object",
  "required": [
    "schemaVersion",
    "date",
    "window",
    "moon",
    "events",
    "next"
  ],
  "properties": {
    "schemaVersion": {
      "const": 1
    },
    "date": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "window": {
      "type": "object",
      "required": [
        "start",
        "end"
      ],
      "properties": {
        "start": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}Z$"
        },
        "end": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}Z$"
        }
      }
    },
    "moon": {
      "description": "The Moon at 12:00 UTC on the date.",
      "type": "object",
      "required": [
        "phase",
        "illumination",
        "ageDays"
      ],
      "properties": {
        "phase": {
          "enum": [
            "new",
            "waxing crescent",
            "first quarter",
            "waxing gibbous",
            "full",
            "waning gibbous",
            "last quarter",
            "waning crescent"
          ]
        },
        "illumination": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "ageDays": {
          "type": "number",
          "minimum": 0,
          "maximum": 30
        },
        "eclipticLonDeg": {
          "type": "number",
          "minimum": 0,
          "exclusiveMaximum": 360,
          "description": "Added December 2026. Geocentric ecliptic longitude of date, degrees, 1 decimal; the frame tropical star signs use."
        }
      }
    },
    "moonTrack": {
      "description": "Added 5 December 2026. The Moon every stepHours from window.start to window.end, both included, so a client can show it for the current moment (interpolate between samples; the lit fraction changes by up to 12 points a day). Illumination 3 decimals; phase angle in degrees, 0 new, 180 full, 1 decimal.",
      "type": "object",
      "required": [
        "start",
        "stepHours",
        "illumination",
        "phaseAngleDeg"
      ],
      "properties": {
        "start": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}Z$"
        },
        "stepHours": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "illumination": {
          "type": "array",
          "items": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          }
        },
        "phaseAngleDeg": {
          "type": "array",
          "items": {
            "type": "number",
            "minimum": 0,
            "exclusiveMaximum": 360
          }
        }
      }
    },
    "planets": {
      "description": "Added December 2026. Heliocentric ecliptic longitude (J2000 ecliptic) of each body at 12:00 UTC, degrees, 1 decimal.",
      "type": "object",
      "required": [
        "mercury",
        "venus",
        "earth",
        "mars",
        "jupiter",
        "saturn"
      ],
      "properties": {
        "mercury": {
          "type": "number",
          "minimum": 0,
          "exclusiveMaximum": 360
        },
        "venus": {
          "type": "number",
          "minimum": 0,
          "exclusiveMaximum": 360
        },
        "earth": {
          "type": "number",
          "minimum": 0,
          "exclusiveMaximum": 360
        },
        "mars": {
          "type": "number",
          "minimum": 0,
          "exclusiveMaximum": 360
        },
        "jupiter": {
          "type": "number",
          "minimum": 0,
          "exclusiveMaximum": 360
        },
        "saturn": {
          "type": "number",
          "minimum": 0,
          "exclusiveMaximum": 360
        }
      }
    },
    "events": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/event"
      }
    },
    "next": {
      "$ref": "#/$defs/event",
      "description": "The first event at or after window.end."
    }
  },
  "$defs": {
    "event": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "kind",
            "time",
            "quarter"
          ],
          "properties": {
            "kind": {
              "const": "moonPhase"
            },
            "time": {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}Z$"
            },
            "quarter": {
              "enum": [
                "new",
                "first quarter",
                "full",
                "last quarter"
              ]
            }
          }
        },
        {
          "type": "object",
          "description": "Minimum geocentric separation of 6 degrees or less.",
          "required": [
            "kind",
            "time",
            "bodies",
            "separationDeg",
            "nearSun"
          ],
          "properties": {
            "kind": {
              "const": "approach"
            },
            "time": {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}Z$"
            },
            "bodies": {
              "type": "array",
              "prefixItems": [
                {
                  "enum": [
                    "moon",
                    "mercury",
                    "venus",
                    "mars",
                    "jupiter",
                    "saturn"
                  ]
                },
                {
                  "enum": [
                    "mercury",
                    "venus",
                    "mars",
                    "jupiter",
                    "saturn"
                  ]
                }
              ],
              "minItems": 2,
              "maxItems": 2
            },
            "separationDeg": {
              "type": "number",
              "minimum": 0,
              "maximum": 6
            },
            "nearSun": {
              "type": "boolean",
              "description": "A planet is within 15 degrees of the Sun."
            }
          }
        },
        {
          "type": "object",
          "description": "Time of greatest eclipse; where it is visible is not included.",
          "required": [
            "kind",
            "time",
            "body",
            "type"
          ],
          "properties": {
            "kind": {
              "const": "eclipse"
            },
            "time": {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}Z$"
            },
            "body": {
              "enum": [
                "moon",
                "sun"
              ]
            },
            "type": {
              "enum": [
                "penumbral",
                "partial",
                "annular",
                "total",
                "hybrid"
              ]
            }
          }
        },
        {
          "type": "object",
          "description": "Peak of a major meteor shower (IMO, zenithal hourly rate 10 or more).",
          "required": [
            "kind",
            "time",
            "name",
            "zhr"
          ],
          "properties": {
            "kind": {
              "const": "meteorShower"
            },
            "time": {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}Z$"
            },
            "name": {
              "type": "string"
            },
            "zhr": {
              "type": "integer",
              "minimum": 0
            }
          }
        }
      ]
    }
  }
}
