{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/peakcam-io/json-schema/peakcam-io-resort-score-history-schema.json",
  "title": "ResortScoreHistory",
  "x-generated": "2026-11-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/peakcam-io-openapi.json#/components/schemas/ResortScoreHistory",
  "type": "object",
  "properties": {
    "slug": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "canonicalUrl": {
      "type": "string"
    },
    "apiUrl": {
      "type": "string",
      "description": "This document."
    },
    "pageUrl": {
      "type": "string",
      "description": "Where the score ring and sparkline render."
    },
    "available": {
      "type": "boolean",
      "description": "False when the scorer has not written a row for this resort yet (or the table is not served)."
    },
    "today": {
      "anyOf": [
        {
          "$ref": "#/$defs/ResortScore"
        },
        {
          "type": "null"
        }
      ],
      "description": "The newest score at most 3 days old, else null."
    },
    "history": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ScoreLight"
      },
      "description": "One point per scored day over the trailing window, oldest first."
    },
    "days": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991,
      "description": "The history window, days."
    },
    "weights": {
      "type": "object",
      "properties": {
        "depthVsNormal": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "recentSnow7d": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "forecast7d": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "snowQuality": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "operatingStatus": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "depthVsNormal",
        "recentSnow7d",
        "forecast7d",
        "snowQuality",
        "operatingStatus"
      ],
      "additionalProperties": false
    },
    "ladder": {
      "type": "object",
      "properties": {
        "great": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "good": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "fair": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "great",
        "good",
        "fair"
      ],
      "additionalProperties": false,
      "description": "Score at or above each cutoff earns the label; below `fair` is `poor`."
    },
    "sentence": {
      "type": "string",
      "description": "The dated tagline, or why there is no score."
    },
    "scoredBy": {
      "type": "string",
      "const": "algorithmic"
    },
    "version": {
      "type": "string"
    },
    "methodologyUrl": {
      "type": "string"
    },
    "attribution": {
      "type": "string"
    },
    "license": {
      "type": "string"
    },
    "generatedAt": {
      "type": "string"
    }
  },
  "required": [
    "slug",
    "name",
    "canonicalUrl",
    "apiUrl",
    "pageUrl",
    "available",
    "today",
    "history",
    "days",
    "weights",
    "ladder",
    "sentence",
    "scoredBy",
    "version",
    "methodologyUrl",
    "attribution",
    "license",
    "generatedAt"
  ],
  "additionalProperties": false,
  "$defs": {
    "ResortScore": {
      "type": "object",
      "properties": {
        "date": {
          "type": "string",
          "description": "YYYY-MM-DD the score is for (Mountain-time day of the scoring run)."
        },
        "score": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "rating": {
          "type": "string",
          "enum": [
            "great",
            "good",
            "fair",
            "poor"
          ],
          "description": "The score's four-tier label: great ≥ 75, good ≥ 55, fair ≥ 35, else poor."
        },
        "tagline": {
          "type": "string",
          "description": "Dated sentence to quote: the score, its rating and the components strongest first."
        },
        "components": {
          "$ref": "#/$defs/ScoreComponents"
        },
        "scoredBy": {
          "type": "string",
          "const": "algorithmic",
          "description": "Always `algorithmic`: a fixed function of measured and modelled inputs, never an editorial call."
        },
        "version": {
          "type": "string",
          "description": "Formula version, e.g. `score-v1`; a change re-scores the history."
        }
      },
      "required": [
        "date",
        "score",
        "rating",
        "tagline",
        "components",
        "scoredBy",
        "version"
      ],
      "additionalProperties": false
    },
    "ScoreComponent": {
      "type": "object",
      "properties": {
        "points": {
          "type": "number",
          "minimum": 0,
          "description": "Points earned, one decimal."
        },
        "max": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991,
          "description": "The component's weight; the five maximums add to 100."
        },
        "basis": {
          "type": "string",
          "description": "One line saying what the points rest on, quotable as is."
        },
        "source": {
          "$ref": "#/$defs/ScoreSource"
        }
      },
      "required": [
        "points",
        "max",
        "basis",
        "source"
      ],
      "additionalProperties": false
    },
    "ScoreComponents": {
      "type": "object",
      "properties": {
        "depthVsNormal": {
          "description": "30: snowpack against the station's 1991–2020 median (SWE); without a normal, base depth on a fixed scale capped at 27.",
          "$ref": "#/$defs/ScoreComponent"
        },
        "recentSnow7d": {
          "description": "25: measured or modelled new snow over the last 7 days (24 in is full marks).",
          "$ref": "#/$defs/ScoreComponent"
        },
        "forecast7d": {
          "description": "20: the blended next-7-day forecast total (20 in is full marks).",
          "$ref": "#/$defs/ScoreComponent"
        },
        "snowQuality": {
          "description": "15: days since the last snow day × the 3-day high temperature × the engine's surface tags.",
          "$ref": "#/$defs/ScoreComponent"
        },
        "operatingStatus": {
          "description": "10: OPEN full, PRE_SEASON and CLOSED_TODAY half, OFF_SEASON and UNKNOWN none.",
          "$ref": "#/$defs/ScoreComponent"
        }
      },
      "required": [
        "depthVsNormal",
        "recentSnow7d",
        "forecast7d",
        "snowQuality",
        "operatingStatus"
      ],
      "additionalProperties": false
    },
    "ScoreLight": {
      "type": "object",
      "properties": {
        "date": {
          "type": "string",
          "description": "YYYY-MM-DD."
        },
        "score": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "rating": {
          "type": "string",
          "enum": [
            "great",
            "good",
            "fair",
            "poor"
          ]
        }
      },
      "required": [
        "date",
        "score",
        "rating"
      ],
      "additionalProperties": false
    },
    "ScoreSource": {
      "type": "string",
      "enum": [
        "snotel",
        "model",
        "operator",
        "profile",
        "derived",
        "none"
      ]
    }
  }
}