{
 "type": "object",
 "required": [
  "meta",
  "sources",
  "places",
  "levels",
  "sections",
  "items",
  "layers",
  "glossary",
  "tour",
  "narration"
 ],
 "properties": {
  "meta": {
   "type": "object",
   "required": [
    "id",
    "title"
   ],
   "properties": {
    "id": {
     "type": "string"
    },
    "title": {
     "type": "string"
    },
    "generated": {
     "type": "string"
    }
   }
  },
  "sources": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "id",
     "title"
    ]
   }
  },
  "places": {
   "type": "array"
  },
  "levels": {
   "type": "array"
  },
  "sections": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "id",
     "level",
     "rooms"
    ]
   }
  },
  "items": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "id",
     "name",
     "class",
     "layer",
     "status",
     "known"
    ],
    "properties": {
     "id": {
      "type": "string"
     },
     "name": {
      "type": "string"
     },
     "class": {
      "type": "string"
     },
     "layer": {
      "type": "string"
     },
     "status": {
      "enum": [
       "record",
       "estimate",
       "concept",
       "proposed",
       "confirmed",
       "open",
       "illustrative",
       "simulated"
      ]
     },
     "known": {
      "enum": [
       "measured",
       "seen",
       "read",
       "inferred",
       "simulated"
      ]
     },
     "pos": {
      "type": [
       "array",
       "null"
      ]
     },
     "shape": {
      "type": "object",
      "required": [
       "type"
      ]
     },
     "record": {
      "type": "object",
      "required": [
       "identity",
       "where",
       "why",
       "cost",
       "maintain",
       "vendor",
       "connect",
       "provenance"
      ],
      "properties": {
       "identity": {
        "type": "object",
        "properties": {
         "codes": {
          "type": "array",
          "items": {
           "type": "object",
           "required": [
            "code",
            "value"
           ],
           "properties": {
            "code": {
             "type": "string"
            },
            "value": {
             "type": [
              "string",
              "number"
             ]
            },
            "owner": {
             "type": "string"
            }
           }
          }
         }
        }
       },
       "where": {
        "type": "object"
       },
       "why": {
        "type": [
         "object",
         "string"
        ]
       },
       "cost": {
        "type": "object"
       },
       "maintain": {
        "type": "object"
       },
       "vendor": {
        "type": "object"
       },
       "connect": {
        "type": "object",
        "required": [
         "class"
        ],
        "properties": {
         "class": {
          "enum": [
           "can connect now",
           "needs a gateway",
           "no interface",
           "not stated"
          ]
         }
        }
       },
       "provenance": {
        "type": "object"
       }
      }
     },
     "links": {
      "type": "object",
      "required": [
       "roles",
       "maintenance",
       "sensing",
       "prediction"
      ],
      "properties": {
       "roles": {
        "type": "array",
        "items": {
         "type": "object",
         "required": [
          "role"
         ],
         "properties": {
          "role": {
           "enum": [
            "purpose",
            "owner",
            "maintainer",
            "installer",
            "operator",
            "observes"
           ]
          }
         }
        }
       },
       "maintenance": {
        "type": "object",
        "required": [
         "plan",
         "work_orders",
         "spares"
        ],
        "properties": {
         "plan": {
          "type": "string"
         },
         "checklist": {
          "type": [
           "string",
           "null"
          ]
         },
         "round_stops": {
          "type": "array"
         },
         "work_orders": {
          "type": "string"
         },
         "spares": {
          "type": "string"
         }
        }
       },
       "sensing": {
        "type": "array",
        "items": {
         "type": "object",
         "required": [
          "point",
          "tag",
          "type",
          "event_types"
         ],
         "properties": {
          "type": {
           "type": "string",
           "pattern": "^sensor\\."
          },
          "event_types": {
           "type": "array",
           "items": {
            "type": "string"
           }
          }
         }
        }
       },
       "prediction": {
        "type": "array",
        "items": {
         "type": "object",
         "required": [
          "mode",
          "indicators",
          "normal_band",
          "trigger",
          "lead_time",
          "action",
          "evidence",
          "basis"
         ],
         "properties": {
          "evidence": {
           "type": "array",
           "minItems": 1
          }
         }
        }
       }
      }
     },
     "rfid": {
      "type": "object",
      "required": [
       "id",
       "state"
      ],
      "properties": {
       "id": {
        "type": "string",
        "pattern": "^SFB-[A-Z0-9]+-[0-9]{3}$"
       },
       "state": {
        "type": "string"
       }
      }
     },
     "target_asset": {
      "type": "string"
     },
     "target_id": {
      "type": "string"
     },
     "pass": {
      "type": "integer"
     },
     "review": {
      "type": "object",
      "required": [
       "decision",
       "by",
       "at"
      ]
     }
    },
    "if": {
     "required": [
      "target_id"
     ]
    },
    "then": {
     "required": [
      "target_asset",
      "target_class"
     ]
    }
   }
  },
  "layers": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "id",
     "name"
    ]
   }
  },
  "glossary": {
   "$ref": "urn:exploder-kit:glossary:1"
  },
  "tour": {
   "type": "object",
   "required": [
    "chapters"
   ]
  },
  "narration": {
   "type": "object",
   "required": [
    "lines"
   ]
  },
  "checklists": {
   "type": "array",
   "items": {
    "$ref": "urn:exploder-kit:checklist:1"
   }
  },
  "rounds": {
   "type": "array"
  }
 },
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "urn:exploder-kit:exploder:1",
 "title": "An Exploder",
 "description": "exploder.json: everything the kit draws, with its record and its links."
}