{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://library.mrm.org/schema/common.schema.json",
  "title": "MRM Library shared definitions",
  "description": "Definitions referenced by the other schemas.",
  "$defs": {
    "slug": {
      "type": "string",
      "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
      "maxLength": 48
    },
    "date": {
      "type": "string",
      "pattern": "^[0-9]{4}(-[0-9]{2}(-[0-9]{2})?)?$",
      "description": "ISO date: YYYY, YYYY-MM or YYYY-MM-DD."
    },
    "people": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "minLength": 1
      },
      "description": "Author slugs from data/authors.json, or a plain name ('Last, First') when the person has no author record."
    },
    "page": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "string",
          "minLength": 1
        }
      ],
      "description": "A printed page number (Roman numerals allowed)."
    },
    "rights": {
      "type": "object",
      "required": [
        "status",
        "basis",
        "source"
      ],
      "additionalProperties": false,
      "properties": {
        "status": {
          "enum": [
            "public-domain",
            "permission",
            "cc-by",
            "cc-by-sa",
            "other"
          ]
        },
        "basis": {
          "type": "string",
          "minLength": 3,
          "description": "Why the status holds, e.g. '1867 US publication'."
        },
        "source": {
          "type": "string",
          "format": "uri",
          "description": "Where the status can be checked."
        },
        "note": {
          "type": "string"
        },
        "publication_year": {
          "type": "integer",
          "minimum": 1400,
          "description": "Year of first/US publication of the edition used. For public-domain works the build requires 1930 or earlier."
        }
      }
    },
    "source": {
      "type": "object",
      "required": [
        "url"
      ],
      "additionalProperties": false,
      "properties": {
        "url": {
          "type": "string",
          "format": "uri"
        },
        "identifier": {
          "type": "string"
        },
        "scan": {
          "type": "string"
        },
        "transcription": {
          "type": "string"
        }
      }
    }
  }
}
