{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://gxplex.com/api/v1/schema/definitions.json",
  "title": "Term entry of quoted definitions document",
  "description": "The document served at /api/v1/definitions.json. Items are carried under `items`.",
  "type": "object",
  "allOf": [
    {
      "$ref": "https://gxplex.com/api/v1/schema/envelope.json"
    }
  ],
  "properties": {
    "collection": {
      "const": "definitions"
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/item"
      },
      "description": "Every term entry of quoted definitions this document carries."
    }
  },
  "required": [
    "items"
  ],
  "additionalProperties": true,
  "$defs": {
    "item": {
      "type": "object",
      "title": "Term entry of quoted definitions",
      "description": "One key (a term as printed, case-folded, whitespace collapsed) and, under it, every definition read in a tracked row's current text in that text's own defining form, each its own entry. The derivation, its rules and its version ride in the envelope under `derivation`.",
      "properties": {
        "key": {
          "type": "string",
          "description": "The term as printed, case-folded, its whitespace collapsed; the envelope's `key_rule` states it."
        },
        "rows_defining": {
          "type": "integer",
          "description": "The number of distinct rows among `definitions`."
        },
        "definitions": {
          "type": "array",
          "items": {
            "type": "object",
            "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."
              }
            },
            "additionalProperties": true
          },
          "description": "One per term printed in a defining form: `instrument_id`, `content_hash` (the text read), `first_observed` (the day that text was first observed), `url` (the row's address on this site), `term` (the publisher's words as printed), `form` (which rule read it), `point` (the number printed directly before it, as printed, or null), `clause` (a clause-anchor id, as the envelope's `derivation.rule_text` D5 states, or null) with `clause_why` stating a null, `at`, `text_at` and `text_end` (offsets, as the envelope's `offset_rule` states them; `text_end` is null where the end is not delimited), `quote` (the text from `text_at` to `text_end`, whole, or null) and `text_withheld` (why the text is not quoted, or null). Each carries the four rights fields of the row it names."
        }
      },
      "required": [
        "key",
        "rows_defining",
        "definitions"
      ],
      "additionalProperties": true
    }
  }
}
