{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "schemaVersion": {
      "const": "1.0.0"
    },
    "catalogVersion": {
      "type": "string"
    },
    "source": {
      "const": "huggingface"
    },
    "scope": {
      "type": "string"
    },
    "startedAt": {
      "type": "string",
      "format": "date-time"
    },
    "retrievedAt": {
      "type": "string",
      "format": "date-time"
    },
    "modelCount": {
      "type": "integer",
      "minimum": 0
    },
    "models": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/model"
      }
    }
  },
  "required": [
    "schemaVersion",
    "catalogVersion",
    "source",
    "scope",
    "startedAt",
    "retrievedAt",
    "modelCount",
    "models"
  ],
  "$defs": {
    "model": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "sourceObjectId": {
          "type": [
            "string",
            "null"
          ]
        },
        "revision": {
          "type": [
            "string",
            "null"
          ]
        },
        "taskId": {
          "type": [
            "string",
            "null"
          ]
        },
        "libraryId": {
          "type": [
            "string",
            "null"
          ]
        },
        "architectureType": {
          "type": [
            "string",
            "null"
          ]
        },
        "baseRelation": {
          "type": [
            "string",
            "null"
          ]
        },
        "baseRelationEvidence": {
          "type": [
            "string",
            "null"
          ]
        },
        "newVersionRepoId": {
          "type": [
            "string",
            "null"
          ]
        },
        "parameterCountEvidence": {
          "type": [
            "string",
            "null"
          ]
        },
        "licenseEvidence": {
          "type": [
            "string",
            "null"
          ]
        },
        "createdAt": {
          "type": [
            "string",
            "null"
          ]
        },
        "updatedAt": {
          "type": [
            "string",
            "null"
          ]
        },
        "architectures": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "formatTags": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "languages": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "licenseIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "baseModelRepoIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "id": {
          "type": "string",
          "pattern": "^hf:[^/]+/[^/]+$"
        },
        "source": {
          "const": "huggingface"
        },
        "repoId": {
          "type": "string",
          "pattern": "^[^/]+/[^/]+$"
        },
        "displayName": {
          "type": "string"
        },
        "publisherNamespace": {
          "type": "string"
        },
        "creatorVerified": {
          "const": false
        },
        "sourceUrl": {
          "type": "string",
          "format": "uri"
        },
        "customLicense": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "name": {
              "type": [
                "string",
                "null"
              ]
            },
            "url": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "name",
            "url"
          ]
        },
        "parameterCount": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0
        },
        "quantization": {
          "type": [
            "object",
            "null"
          ]
        },
        "gated": {
          "enum": [
            false,
            true,
            "auto",
            "manual",
            null
          ]
        },
        "private": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "disabled": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "availabilityObservation": {
          "enum": [
            "mapping_returned",
            "no_mapping_returned",
            "unknown"
          ]
        },
        "providerOfferings": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "providerId": {
                "type": "string"
              },
              "providerModelId": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "task": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "status": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "isModelAuthor": {
                "type": [
                  "boolean",
                  "null"
                ]
              },
              "source": {
                "const": "inferenceProviderMapping"
              },
              "observedAt": {
                "type": "string",
                "format": "date-time"
              }
            },
            "required": [
              "providerId",
              "providerModelId",
              "task",
              "status",
              "isModelAuthor",
              "source",
              "observedAt"
            ]
          }
        },
        "metrics": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "downloads": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0
            },
            "likes": {
              "type": [
                "integer",
                "null"
              ],
              "minimum": 0
            },
            "observedAt": {
              "type": "string",
              "format": "date-time"
            }
          },
          "required": [
            "downloads",
            "likes",
            "observedAt"
          ]
        },
        "retrievedAt": {
          "type": "string",
          "format": "date-time"
        },
        "selectionEvidence": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "query": {
                "type": "string"
              },
              "rankInResponse": {
                "type": "integer",
                "minimum": 1
              }
            },
            "required": [
              "query",
              "rankInResponse"
            ]
          }
        },
        "selectionStatus": {
          "const": "reference_candidate"
        },
        "qualityEndorsement": {
          "const": false
        }
      },
      "required": [
        "sourceObjectId",
        "revision",
        "taskId",
        "libraryId",
        "architectureType",
        "baseRelation",
        "baseRelationEvidence",
        "newVersionRepoId",
        "parameterCountEvidence",
        "licenseEvidence",
        "createdAt",
        "updatedAt",
        "architectures",
        "formatTags",
        "languages",
        "licenseIds",
        "baseModelRepoIds",
        "id",
        "source",
        "repoId",
        "displayName",
        "publisherNamespace",
        "creatorVerified",
        "sourceUrl",
        "customLicense",
        "parameterCount",
        "quantization",
        "gated",
        "private",
        "disabled",
        "availabilityObservation",
        "providerOfferings",
        "metrics",
        "retrievedAt",
        "selectionEvidence",
        "selectionStatus",
        "qualityEndorsement"
      ]
    }
  }
}
