{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/storelift-net/json-schema/storelift-net-hive-keyword-metrics-schema.json",
  "title": "HiveKeywordMetrics",
  "x-generated": "2026-11-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/storelift-net-openapi.yml#/components/schemas/HiveKeywordMetrics",
  "type": "object",
  "required": [
    "metricReadVersion",
    "country",
    "platform",
    "term",
    "rows",
    "pending",
    "metrics",
    "measurementStarted",
    "complete"
  ],
  "properties": {
    "metricReadVersion": {
      "const": 1
    },
    "country": {
      "type": "string",
      "pattern": "^[a-z]{2}$"
    },
    "platform": {
      "const": "ios"
    },
    "term": {
      "type": "string"
    },
    "rows": {
      "type": "array",
      "minItems": 1,
      "maxItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": true
      },
      "description": "Existing Research row fields are retained for compatibility."
    },
    "pending": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "metrics": {
      "$ref": "#/$defs/HiveMetricPair"
    },
    "measurementStarted": {
      "const": false
    },
    "complete": {
      "type": "boolean"
    }
  },
  "$defs": {
    "HiveMetricObservation": {
      "type": "object",
      "required": [
        "status",
        "kind",
        "value",
        "current",
        "source",
        "sourceObservedAt",
        "observedAtPrecision",
        "checkedAt",
        "period",
        "modelVersion",
        "evidence",
        "lastAttempt"
      ],
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "fresh",
            "stale",
            "pending",
            "absent",
            "error",
            "unmeasured",
            "restricted"
          ]
        },
        "kind": {
          "type": "string",
          "enum": [
            "observed",
            "estimated"
          ]
        },
        "value": {
          "type": [
            "number",
            "null"
          ],
          "minimum": 0,
          "maximum": 100
        },
        "current": {
          "type": "boolean"
        },
        "source": {
          "type": [
            "string",
            "null"
          ]
        },
        "sourceObservedAt": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "string",
              "format": "date"
            },
            {
              "type": "null"
            }
          ],
          "description": "Original source observation time; a read or model calculation does not update it."
        },
        "observedAtPrecision": {
          "enum": [
            "instant",
            "day",
            null
          ]
        },
        "checkedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "period": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "kind": {
              "enum": [
                "week",
                "day"
              ]
            },
            "start": {
              "type": "string",
              "format": "date"
            }
          }
        },
        "modelVersion": {
          "type": [
            "string",
            "null"
          ]
        },
        "evidence": {
          "type": [
            "object",
            "null"
          ],
          "additionalProperties": true,
          "description": "Source-bound evidence and available hashes. `observationId` is an opaque identifier scoped to your workspace: stable across your requests, never comparable with another workspace's identifiers. parsed_json_v1 describes a hash of parsed JSON, not raw response bytes."
        },
        "lastAttempt": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "status": {
              "enum": [
                "pending",
                "error"
              ]
            },
            "checkedAt": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time"
            },
            "attemptId": {
              "type": "string"
            }
          },
          "description": "Independent from a retained observation: a retry error does not erase an earlier valid value."
        }
      }
    },
    "HiveMetricPair": {
      "type": "object",
      "required": [
        "popularity",
        "difficulty"
      ],
      "properties": {
        "popularity": {
          "allOf": [
            {
              "$ref": "#/$defs/HiveMetricObservation"
            },
            {
              "properties": {
                "kind": {
                  "const": "observed"
                },
                "value": {
                  "type": [
                    "integer",
                    "null"
                  ],
                  "minimum": 1,
                  "maximum": 100
                }
              }
            }
          ]
        },
        "difficulty": {
          "allOf": [
            {
              "$ref": "#/$defs/HiveMetricObservation"
            },
            {
              "properties": {
                "kind": {
                  "const": "estimated"
                }
              }
            }
          ]
        }
      }
    }
  }
}