{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://gxplex.com/api/v1/schema/revisions.json",
  "title": "Detected revision document",
  "description": "The document served at /api/v1/revisions.json. Items are carried under `items`.",
  "type": "object",
  "allOf": [
    {
      "$ref": "https://gxplex.com/api/v1/schema/envelope.json"
    }
  ],
  "properties": {
    "collection": {
      "const": "revisions"
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/item"
      },
      "description": "Every detected revision this document carries."
    }
  },
  "required": [
    "items"
  ],
  "additionalProperties": true,
  "$defs": {
    "item": {
      "type": "object",
      "title": "Detected revision",
      "description": "A change detected in the normalised text of a document. `silent_revision` is the class this archive exists to detect: a change with no version bump declared alongside it. Withdrawn entries are not served here.",
      "properties": {
        "licence_class": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "open",
            "restricted",
            "unknown"
          ],
          "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 revision."
        },
        "instrument_id": {
          "type": "string",
          "description": "The document."
        },
        "detected_at": {
          "type": "string",
          "format": "date",
          "description": "The day the difference was detected."
        },
        "previous_observed_at": {
          "type": "string",
          "format": "date",
          "description": "The day of the observation it was detected against."
        },
        "change_class": {
          "type": "string",
          "description": "The class of change, one of the closed set of values the source schema enumerates."
        },
        "bytes_changed": {
          "type": "integer",
          "description": "How many bytes of normalised text differ."
        },
        "hash_before": {
          "type": [
            "string",
            "null"
          ],
          "description": "The digest before."
        },
        "hash_after": {
          "type": [
            "string",
            "null"
          ],
          "description": "The digest after."
        },
        "sections_affected": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Sections the difference falls in, where they are derivable."
        },
        "diff_available": {
          "type": "boolean",
          "description": "False where the text is not openly licensed. Change is then reported by digest and byte delta, and no text is reproduced."
        },
        "summary": {
          "type": "string",
          "description": "What differs, described without evaluation."
        },
        "confirmed_by_human": {
          "type": "boolean",
          "description": "Whether a person confirmed the revision. False is not a denial: it is the absence of a confirmation."
        }
      },
      "required": [
        "id",
        "instrument_id",
        "detected_at",
        "change_class",
        "licence_class",
        "text_retained",
        "quote_allowed",
        "snapshot_available",
        "rights_of"
      ],
      "additionalProperties": true
    }
  }
}
