{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": ".auDO published uses manifest",
  "description": "Schema for substantive published work that cites, interprets, visualises or otherwise uses public .auDO observations.",
  "type": "object",
  "required": [
    "schema_version",
    "schema_url",
    "updated_at",
    "collection",
    "items"
  ],
  "properties": {
    "schema_version": {
      "const": 1
    },
    "schema_url": {
      "const": "/data/uses/schema-v1.json"
    },
    "updated_at": {
      "type": "string"
    },
    "collection": {
      "type": "object",
      "required": [
        "title",
        "description"
      ],
      "properties": {
        "title": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/item"
      }
    }
  },
  "additionalProperties": false,
  "$defs": {
    "date": {
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
    },
    "person": {
      "type": "object",
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "url": {
          "type": "string",
          "format": "uri"
        }
      },
      "additionalProperties": false
    },
    "reference": {
      "type": "object",
      "required": [
        "label",
        "url"
      ],
      "properties": {
        "label": {
          "type": "string",
          "minLength": 1
        },
        "url": {
          "type": "string",
          "pattern": "^/"
        }
      },
      "additionalProperties": false
    },
    "item": {
      "type": "object",
      "required": [
        "id",
        "type",
        "title",
        "summary",
        "published_at",
        "included_at",
        "canonical_url",
        "authors",
        "publisher",
        "relationship",
        "audo_basis",
        "tags",
        "status",
        "last_verified_at"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
        },
        "type": {
          "enum": [
            "analysis",
            "research",
            "policy",
            "media",
            "presentation",
            "visualisation",
            "tool"
          ]
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "summary": {
          "type": "string",
          "minLength": 1
        },
        "published_at": {
          "$ref": "#/$defs/date"
        },
        "included_at": {
          "$ref": "#/$defs/date"
        },
        "canonical_url": {
          "type": "string",
          "format": "uri"
        },
        "language": {
          "type": "string"
        },
        "authors": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/person"
          }
        },
        "publisher": {
          "type": "object",
          "required": [
            "name"
          ],
          "properties": {
            "name": {
              "type": "string",
              "minLength": 1
            },
            "url": {
              "type": "string",
              "format": "uri"
            },
            "domain": {
              "type": "string",
              "minLength": 1
            }
          },
          "additionalProperties": false
        },
        "relationship": {
          "enum": [
            "independent_third_party",
            "founder_authored_external",
            "collaborative"
          ]
        },
        "disclosure": {
          "type": "string",
          "minLength": 1
        },
        "audo_basis": {
          "type": "object",
          "required": [
            "panel",
            "surfaces",
            "references"
          ],
          "properties": {
            "observation_date": {
              "anyOf": [
                {
                  "$ref": "#/$defs/date"
                },
                {
                  "type": "null"
                }
              ]
            },
            "observation_window": {
              "type": [
                "string",
                "null"
              ]
            },
            "panel": {
              "type": "string",
              "minLength": 1
            },
            "evidence_note": {
              "type": "string",
              "minLength": 1
            },
            "surfaces": {
              "type": "array",
              "minItems": 1,
              "uniqueItems": true,
              "items": {
                "type": "string",
                "minLength": 1
              }
            },
            "references": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/reference"
              }
            }
          },
          "additionalProperties": false
        },
        "tags": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "status": {
          "enum": [
            "available",
            "archived",
            "unavailable",
            "superseded"
          ]
        },
        "last_verified_at": {
          "$ref": "#/$defs/date"
        }
      },
      "additionalProperties": false
    }
  }
}
