{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://gxplex.com/api/v1/schema/diffs.json",
  "title": "Version difference document",
  "description": "The document served at /api/v1/diffs.json. Items are carried under `items`.",
  "type": "object",
  "allOf": [
    {
      "$ref": "https://gxplex.com/api/v1/schema/envelope.json"
    }
  ],
  "properties": {
    "collection": {
      "const": "diffs"
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/item"
      },
      "description": "Every version difference this document carries."
    }
  },
  "required": [
    "items"
  ],
  "additionalProperties": true,
  "$defs": {
    "item": {
      "type": "object",
      "title": "Version difference",
      "description": "What differs between two retained versions of one document. Present only where the licence class this record records for the text is open.",
      "properties": {
        "licence_class": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "open",
            "restricted",
            "unknown",
            null
          ],
          "description": "What this archive recorded of the terms the source states. Null where no reading exists for this object. See `rights` on the envelope."
        },
        "text_retained": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "Whether normalised prose of the document is held here for a quotation to be checked against. Held, never served. Null where no reading exists."
        },
        "quote_allowed": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "Whether a quotation from the document appears in this record's own published output. A fact about this record's handling, not a reading of what the publisher permits, and not a grant. Null where no reading exists."
        },
        "snapshot_available": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "Whether a retained snapshot of an observed retrieval is still held here for a digest to be re-checked against. No snapshot is served. Null where no reading exists."
        },
        "rights_of": {
          "type": [
            "string",
            "null"
          ],
          "description": "The tracked entry id the four fields above are the rights OF. Null where the object names no entry."
        },
        "rights_unresolved": {
          "type": [
            "string",
            "null"
          ],
          "description": "Present only where the four fields are null, naming which absence it is: an id this record does not hold, or an object that names no entry."
        },
        "id": {
          "type": "string",
          "description": "The identifier of this difference."
        },
        "instrument_id": {
          "type": "string",
          "description": "The document."
        },
        "from_version": {
          "type": "string",
          "description": "The earlier version label."
        },
        "to_version": {
          "type": "string",
          "description": "The later version label."
        },
        "from_date": {
          "type": [
            "string",
            "null"
          ],
          "format": "date",
          "description": "The earlier version date."
        },
        "to_date": {
          "type": [
            "string",
            "null"
          ],
          "format": "date",
          "description": "The later version date."
        },
        "from_url": {
          "type": "string",
          "description": "Where the earlier version was retrieved."
        },
        "to_url": {
          "type": "string",
          "description": "Where the later version was retrieved."
        },
        "change_summary": {
          "type": "string",
          "description": "What changed, described without evaluation."
        },
        "changes": {
          "type": "array",
          "items": {
            "type": "object"
          },
          "description": "The individual differences."
        },
        "url": {
          "type": "string",
          "description": "The page this difference is published at."
        }
      },
      "required": [
        "id",
        "instrument_id",
        "url",
        "licence_class",
        "text_retained",
        "quote_allowed",
        "snapshot_available",
        "rights_of"
      ],
      "additionalProperties": true
    }
  }
}
