{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://rehearse.kurvball.ca/schema/v1/services.schema.json",
  "title": "Rehearse v1: rehearse services --json",
  "description": "What can come up, how Rehearse knows it is ready, and what is running now.",
  "type": "object",
  "required": ["v", "services"],
  "properties": {
    "v": { "$ref": "common.schema.json#/$defs/v" },
    "services": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["name", "up", "running"],
        "properties": {
          "name": { "type": "string" },
          "describe": { "type": ["string", "null"] },
          "up": {
            "description": "The command that brings it up, before placeholders are filled.",
            "type": "string"
          },
          "cwd": { "type": ["string", "null"] },
          "url": { "type": ["string", "null"] },
          "port": { "oneOf": [{ "type": "integer" }, { "const": "auto" }, { "type": "null" }] },
          "ready": {
            "oneOf": [
              { "type": "null" },
              { "type": "object", "required": ["http"], "properties": { "http": { "type": "string" } } },
              {
                "type": "object",
                "required": ["command"],
                "properties": { "command": { "type": "string" } }
              },
              { "type": "object", "required": ["log"], "properties": { "log": { "type": "string" } } }
            ]
          },
          "down": { "type": ["string", "null"] },
          "isolate": {
            "oneOf": [
              { "type": "null" },
              { "type": "object", "required": ["env"], "properties": { "env": { "type": "string" } } }
            ]
          },
          "drive": {
            "description": "The service's own driver for flows and rehearse drive, when it has one.",
            "type": ["string", "null"]
          },
          "standins": {
            "description": "The stand-ins that apply to it.",
            "type": "array",
            "items": { "type": "string" }
          },
          "running": {
            "description": "Copies of it up now, one per checkout.",
            "type": "array",
            "items": {
              "type": "object",
              "required": ["checkout", "pid"],
              "properties": {
                "checkout": { "type": "string" },
                "url": { "type": ["string", "null"] },
                "port": { "type": ["integer", "null"] },
                "pid": { "type": "integer" },
                "since": { "type": "string", "format": "date-time" }
              }
            }
          }
        }
      }
    }
  }
}
