{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/clment-com/json-schema/clment-com-insights-schema.json",
  "title": "Insights",
  "description": "Dashboard KPI summary for a window.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/clment-com-insights-api-openapi.yml#/components/schemas/Insights",
  "type": "object",
  "properties": {
    "range": {
      "type": "string",
      "description": "The window requested, e.g. \"30d\"."
    },
    "scope": {
      "type": "string",
      "description": "Whose contracts the numbers cover."
    },
    "windowStart": {
      "type": "string",
      "format": "date-time"
    },
    "windowEnd": {
      "type": "string",
      "format": "date-time"
    },
    "kpis": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "description": "Stable identifier for the metric. New keys appear as the dashboard grows, so treat an unrecognised one as data rather than an error."
          },
          "value": {
            "type": "number"
          },
          "priorValue": {
            "type": "number",
            "description": "The same metric over the preceding window, for comparison."
          },
          "percentChange": {
            "type": [
              "number",
              "null"
            ]
          },
          "sparkline": {
            "type": "array",
            "description": "Per-day values across the window, oldest first.",
            "items": {
              "type": "object",
              "properties": {
                "date": {
                  "type": "string",
                  "format": "date-time"
                },
                "value": {
                  "type": "number"
                }
              }
            }
          }
        }
      }
    }
  }
}