{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hollerit.app/holler-report.schema.json",
  "title": "Holler report",
  "description": "The holler.json file attached to every email sent from the Holler app. Documentation: https://hollerit.app/report-format.html",
  "type": "object",
  "required": ["format", "formatVersion", "id", "subject", "place", "severity", "createdAt", "composedAt", "attachments", "app"],
  "properties": {
    "format": {
      "const": "holler.report",
      "description": "Identifies the file as a Holler report."
    },
    "formatVersion": {
      "type": "integer",
      "minimum": 1,
      "description": "Version of this format. Raised only for changes that are not purely additive."
    },
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "Unique for each email. Sending the same holler again produces a new id."
    },
    "subject": {
      "type": "string",
      "description": "The email's subject line: the category and the place when a category other than other is set (\"Downed tree, Alt Loop\"), else a short title written on the phone and the place, otherwise the note, or \"Holler: \" followed by the place when there is no note. Read the note from note, not from the subject."
    },
    "place": {
      "type": "string",
      "description": "Where the problem is, as shown on the Place line of the email: the sender's label, a nearby trail name, or Apple's place name."
    },
    "note": {
      "type": "string",
      "minLength": 1,
      "description": "What's wrong, in the sender's words, or translated on the sender's phone when the destination has a language set. Omitted when the sender left it empty."
    },
    "severity": {
      "enum": ["low", "medium", "high"],
      "description": "How serious the sender says the problem is."
    },
    "category": {
      "type": "string",
      "examples": ["downed_tree", "washout", "erosion", "signage", "trash", "flooding", "structure", "other"],
      "description": "What kind of problem it is, as chosen by the sender (Holler may suggest one): one of the examples. Omitted when not set. New values may be added, so treat an unknown one as \"other\"."
    },
    "trailPosition": {
      "type": "string",
      "minLength": 1,
      "description": "Where the spot is from the nearest junction on the trail it's on, in the sender's language and units, e.g. \"About 200 feet north of the junction with Tower Trail\". From OpenStreetMap trails on the sender's phone; omitted when there is no trail or junction nearby."
    },
    "facing": {
      "type": "string",
      "minLength": 1,
      "description": "Which way the main photo looks, in the sender's language, e.g. \"Facing south along Alt Loop, toward the junction with Snowbird\", or just \"Facing northeast\" off a trail. From the photo's compass heading and OpenStreetMap trails on the sender's phone; omitted when the photo has no heading."
    },
    "passable": {
      "enum": ["yes", "with_difficulty", "no"],
      "description": "The sender's answer to \"Can people get past?\" Holler may suggest one from the note and photo. Omitted when not answered."
    },
    "fixEffort": {
      "enum": ["one_person", "crew", "equipment"],
      "description": "The sender's answer to \"What will it take?\" (to fix it). Holler may suggest one from the note and photo. Omitted when not answered."
    },
    "location": {
      "type": "object",
      "description": "Where the holler was made, in WGS 84 decimal degrees. Omitted when the location was unavailable.",
      "required": ["latitude", "longitude"],
      "properties": {
        "latitude": { "type": "number", "minimum": -90, "maximum": 90 },
        "longitude": { "type": "number", "minimum": -180, "maximum": 180 }
      },
      "additionalProperties": false
    },
    "sender": {
      "type": "object",
      "description": "The name and email the sender entered in Holler's Settings. Omitted when both are empty; each field is omitted when empty. Not verified.",
      "properties": {
        "name": { "type": "string", "minLength": 1 },
        "email": { "type": "string", "minLength": 1 }
      },
      "additionalProperties": false
    },
    "createdAt": {
      "type": "string",
      "format": "date-time",
      "description": "When the holler was started, in UTC (ISO 8601)."
    },
    "composedAt": {
      "type": "string",
      "format": "date-time",
      "description": "When the sender tapped Send and the email was prepared, in UTC (ISO 8601)."
    },
    "attachments": {
      "type": "array",
      "description": "The other files attached to the same email, in order: photos first, then the map.",
      "items": {
        "type": "object",
        "required": ["filename", "kind", "mediaType"],
        "properties": {
          "filename": { "type": "string", "examples": ["holler-1.jpg", "holler-map.png"] },
          "kind": { "enum": ["photo", "map"] },
          "mediaType": { "type": "string", "examples": ["image/jpeg", "image/png"] }
        },
        "additionalProperties": false
      }
    },
    "app": {
      "type": "object",
      "description": "The Holler build that sent the email.",
      "required": ["name", "version", "build"],
      "properties": {
        "name": { "const": "Holler" },
        "version": { "type": "string" },
        "build": { "type": "string" }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": true
}
