{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://gxplex.com/api/v1/schema/archive.json",
  "title": "Retained version document",
  "description": "The document served at /api/v1/archive.json. Items are carried under `items`.",
  "type": "object",
  "allOf": [
    {
      "$ref": "https://gxplex.com/api/v1/schema/envelope.json"
    }
  ],
  "properties": {
    "collection": {
      "const": "archive"
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/item"
      },
      "description": "Every retained version this document carries."
    }
  },
  "required": [
    "items"
  ],
  "additionalProperties": true,
  "$defs": {
    "item": {
      "type": "object",
      "title": "Retained version",
      "description": "One retained version of a document, with the digest of the bytes retained.",
      "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 archive entry."
        },
        "instrument_id": {
          "type": "string",
          "description": "The document this version belongs to."
        },
        "document_title": {
          "type": "string",
          "description": "The title as printed on the retained version."
        },
        "version_label": {
          "type": "string",
          "description": "The publisher label for this version."
        },
        "version_slug": {
          "type": "string",
          "description": "The label reduced to an address-safe form."
        },
        "published_date": {
          "type": [
            "string",
            "null"
          ],
          "format": "date",
          "description": "The day the publisher dates this version."
        },
        "retrieved_date": {
          "type": [
            "string",
            "null"
          ],
          "format": "date",
          "description": "The day this archive retrieved it."
        },
        "original_url": {
          "type": "string",
          "description": "The address it was retrieved from."
        },
        "archive_url": {
          "type": [
            "string",
            "null"
          ],
          "description": "A third-party archive copy, where one exists."
        },
        "sha256": {
          "type": [
            "string",
            "null"
          ],
          "description": "The digest of the retained bytes."
        },
        "file_size": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Bytes retained. Null where the entry holds no retained file."
        },
        "mime_type": {
          "type": "string",
          "description": "The content type served."
        },
        "still_live": {
          "type": "boolean",
          "description": "Whether the original address still answers."
        },
        "last_checked": {
          "type": [
            "string",
            "null"
          ],
          "format": "date",
          "description": "The day still_live was last measured."
        },
        "url": {
          "type": "string",
          "description": "The page this version is published at."
        }
      },
      "required": [
        "id",
        "instrument_id",
        "original_url",
        "url",
        "licence_class",
        "text_retained",
        "quote_allowed",
        "snapshot_available",
        "rights_of"
      ],
      "additionalProperties": true
    }
  }
}
