{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hydro-look.vercel.app/api/schema/status.schema.json",
  "title": "status.json",
  "description": "Feed freshness, table sizes and open quality findings.",
  "type": "object",
  "required": [
    "schema_version",
    "generated_at",
    "data_date",
    "as_of",
    "ok",
    "status",
    "feeds",
    "tables",
    "findings",
    "license",
    "attribution",
    "see_also"
  ],
  "properties": {
    "schema_version": {
      "type": "integer",
      "const": 1,
      "description": "The format version. Changes only when a field is removed, renamed or retyped; added fields do not change it."
    },
    "generated_at": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$",
      "description": "When the document was written, UTC."
    },
    "data_date": {
      "type": [
        "string",
        "null"
      ],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
      "description": "The Ecuadorian calendar day the document's readings describe."
    },
    "as_of": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
      "deprecated": true,
      "description": "Deprecated: the day the check ran. Use data_date. Removed in schema_version 2."
    },
    "ok": {
      "type": "boolean"
    },
    "status": {
      "type": "string",
      "enum": [
        "pass",
        "info",
        "warn",
        "fail"
      ]
    },
    "feeds": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9_]+$"
          },
          "label_es": {
            "type": "string"
          },
          "feed": {
            "type": "string",
            "deprecated": true,
            "description": "Deprecated English label. Use id and label_es."
          },
          "latest": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "limit_days": {
            "type": "integer"
          },
          "state": {
            "type": "string",
            "enum": [
              "current",
              "stale",
              "not_ingested"
            ]
          }
        },
        "required": [
          "id",
          "label_es",
          "feed",
          "latest",
          "limit_days",
          "state"
        ]
      }
    },
    "tables": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "rows": {
            "type": "integer"
          }
        },
        "required": [
          "rows"
        ]
      }
    },
    "findings": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "check": {
            "type": "string"
          },
          "level": {
            "type": "string",
            "enum": [
              "info",
              "warn",
              "fail"
            ]
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "check",
          "level",
          "message"
        ]
      }
    },
    "counts": {
      "type": "object",
      "additionalProperties": {
        "type": "integer"
      }
    },
    "deprecated": {
      "$ref": "#/$defs/deprecated"
    },
    "license": {
      "$ref": "#/$defs/license"
    },
    "attribution": {
      "$ref": "#/$defs/attribution"
    },
    "see_also": {
      "$ref": "#/$defs/see_also"
    }
  },
  "$defs": {
    "license": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "const": "MIT"
        },
        "code_url": {
          "type": "string",
          "pattern": "^https?://"
        },
        "data": {
          "type": "string"
        },
        "data_es": {
          "type": "string"
        }
      },
      "required": [
        "code",
        "code_url",
        "data",
        "data_es"
      ]
    },
    "attribution": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "provides": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "pattern": "^https?://"
          },
          "terms": {
            "type": "string"
          },
          "terms_es": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "provides",
          "url",
          "terms",
          "terms_es"
        ]
      }
    },
    "see_also": {
      "type": "object",
      "required": [
        "schema",
        "documentation"
      ],
      "description": "Absolute URLs to the other documents, this document's schema and the documentation page.",
      "additionalProperties": {
        "type": "string",
        "pattern": "^https?://"
      }
    },
    "deprecated": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      },
      "description": "Fields kept for one more schema version, each with what replaces it."
    }
  }
}
