{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://peoplenotnumbers.org/schemas/banned-books-dataset.v1.json",
  "$comment": "Root validates the compact deduplicated public JSON projection. definitions.richDataset validates the nested TypeScript projection.",
  "title": "Inside Michigan banned-books compact public dataset",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "meta",
    "codeDefinitions",
    "entries",
    "analysis",
    "history"
  ],
  "properties": {
    "meta": {
      "$ref": "#/definitions/meta"
    },
    "codeDefinitions": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "label",
          "family"
        ],
        "properties": {
          "label": {
            "type": [
              "string",
              "null"
            ]
          },
          "family": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      }
    },
    "entries": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/definitions/publicEntry"
      }
    },
    "analysis": {
      "$ref": "#/definitions/analysis"
    },
    "history": {
      "$ref": "#/definitions/history"
    }
  },
  "definitions": {
    "snapshot": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "editionDate",
        "retrievedAt",
        "sourceUrl",
        "sourceSha256",
        "pageCount",
        "rowCount",
        "parserVersion"
      ],
      "properties": {
        "id": {
          "type": "integer"
        },
        "editionDate": {
          "type": "string",
          "format": "date"
        },
        "retrievedAt": {
          "type": "string"
        },
        "sourceUrl": {
          "type": "string"
        },
        "sourceSha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "pageCount": {
          "type": "integer",
          "minimum": 1
        },
        "rowCount": {
          "type": "integer",
          "minimum": 1
        },
        "parserVersion": {
          "type": "string"
        }
      }
    },
    "meta": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "title",
        "listDate",
        "sourceSha256",
        "sourceUrl",
        "localPdfPath",
        "fixture",
        "snapshot",
        "caveats"
      ],
      "properties": {
        "title": {
          "type": "string"
        },
        "listDate": {
          "type": "string",
          "format": "date"
        },
        "sourceSha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "sourceUrl": {
          "type": "string"
        },
        "localPdfPath": {
          "type": "string"
        },
        "fixture": {
          "type": "boolean"
        },
        "snapshot": {
          "$ref": "#/definitions/snapshot"
        },
        "caveats": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "denominator": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "label",
        "value"
      ],
      "properties": {
        "label": {
          "type": "string"
        },
        "value": {
          "type": [
            "integer",
            "null"
          ]
        },
        "secondary": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "label",
              "value"
            ],
            "properties": {
              "label": {
                "type": "string"
              },
              "value": {
                "type": "integer"
              }
            }
          }
        }
      }
    },
    "codingMatrix": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "code-and-narrative",
        "code-only",
        "narrative-only",
        "neither",
        "total"
      ],
      "properties": {
        "code-and-narrative": {
          "type": "integer"
        },
        "code-only": {
          "type": "integer"
        },
        "narrative-only": {
          "type": "integer"
        },
        "neither": {
          "type": "integer"
        },
        "total": {
          "type": "integer"
        }
      }
    },
    "verification": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "status",
        "strategy",
        "resultSha256"
      ],
      "properties": {
        "status": {
          "enum": [
            "passed",
            "not_run"
          ]
        },
        "strategy": {
          "type": "string"
        },
        "resultSha256": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[0-9a-f]{64}$"
        }
      }
    },
    "analysisFragment": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "key",
        "status",
        "unit",
        "denominator",
        "data",
        "method",
        "caveat",
        "verification"
      ],
      "properties": {
        "key": {
          "type": "string"
        },
        "status": {
          "enum": [
            "available",
            "unavailable"
          ]
        },
        "unit": {
          "type": "string"
        },
        "denominator": {
          "$ref": "#/definitions/denominator"
        },
        "data": {},
        "method": {
          "type": "string",
          "minLength": 1
        },
        "caveat": {
          "type": "string",
          "minLength": 1
        },
        "projection": {
          "type": "string"
        },
        "verification": {
          "$ref": "#/definitions/verification"
        }
      }
    },
    "analysis": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schemaVersion",
        "inputSha256",
        "fragmentCount",
        "codingMatrix",
        "fragments"
      ],
      "properties": {
        "schemaVersion": {
          "type": "string"
        },
        "inputSha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "fragmentCount": {
          "type": "integer",
          "minimum": 1
        },
        "codingMatrix": {
          "$ref": "#/definitions/codingMatrix"
        },
        "fragments": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/definitions/analysisFragment"
          }
        }
      }
    },
    "historySnapshot": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "edition",
        "disposition",
        "rowCount",
        "sha256",
        "promotionCompatible"
      ],
      "properties": {
        "edition": {
          "type": "string",
          "format": "date"
        },
        "disposition": {
          "type": "string"
        },
        "rowCount": {
          "type": [
            "integer",
            "null"
          ]
        },
        "sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "promotionCompatible": {
          "type": "boolean"
        }
      }
    },
    "historyCounts": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "added",
        "changed",
        "removed",
        "unchanged"
      ],
      "properties": {
        "added": {
          "type": "integer"
        },
        "changed": {
          "type": "integer"
        },
        "removed": {
          "type": "integer"
        },
        "unchanged": {
          "type": "integer"
        }
      }
    },
    "historyComparison": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "olderEdition",
        "newerEdition",
        "status",
        "confidence",
        "publishable",
        "counts",
        "reason"
      ],
      "properties": {
        "olderEdition": {
          "type": "string",
          "format": "date"
        },
        "newerEdition": {
          "type": "string",
          "format": "date"
        },
        "status": {
          "type": "string"
        },
        "confidence": {
          "type": "string"
        },
        "publishable": {
          "type": "boolean"
        },
        "counts": {
          "oneOf": [
            {
              "$ref": "#/definitions/historyCounts"
            },
            {
              "type": "null"
            }
          ]
        },
        "reason": {
          "type": "string"
        }
      }
    },
    "history": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "status",
        "schemaVersion",
        "artifactSha256",
        "snapshots",
        "comparisons",
        "limitations"
      ],
      "properties": {
        "status": {
          "enum": [
            "complete",
            "partial",
            "unavailable"
          ]
        },
        "schemaVersion": {
          "type": [
            "string",
            "null"
          ]
        },
        "artifactSha256": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[0-9a-f]{64}$"
        },
        "scope": {
          "type": [
            "string",
            "null"
          ]
        },
        "snapshots": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/historySnapshot"
          }
        },
        "comparisons": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/historyComparison"
          }
        },
        "limitations": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "publicIdentifier": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kind",
        "normalized"
      ],
      "properties": {
        "kind": {
          "enum": [
            "isbn13",
            "isbn10",
            "asin",
            "other"
          ]
        },
        "normalized": {
          "type": "string"
        },
        "raw": {
          "type": "string"
        },
        "isDerived": {
          "const": true
        }
      }
    },
    "publicSource": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "page",
        "row"
      ],
      "properties": {
        "page": {
          "type": "integer",
          "minimum": 1
        },
        "row": {
          "type": "integer",
          "minimum": 1
        }
      }
    },
    "publicEntry": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "titleDisplay",
        "authorRaw",
        "formatRaw",
        "format",
        "dateAdded",
        "identifiers",
        "codeRaw",
        "codes",
        "narrativeRaw",
        "source"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "titleRaw": {
          "type": "string",
          "minLength": 1
        },
        "titleDisplay": {
          "type": "string",
          "minLength": 1
        },
        "authorRaw": {
          "type": [
            "string",
            "null"
          ]
        },
        "formatRaw": {
          "type": "string"
        },
        "format": {
          "enum": [
            "book",
            "periodical",
            "publication",
            "unknown"
          ]
        },
        "dateAdded": {
          "type": "string",
          "format": "date"
        },
        "identifiers": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/publicIdentifier"
          }
        },
        "codeRaw": {
          "type": [
            "string",
            "null"
          ]
        },
        "codes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "narrativeRaw": {
          "type": [
            "string",
            "null"
          ]
        },
        "source": {
          "$ref": "#/definitions/publicSource"
        },
        "warnings": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "richIdentifier": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kind",
        "raw",
        "normalized",
        "validity",
        "isDerived"
      ],
      "properties": {
        "kind": {
          "enum": [
            "isbn13",
            "isbn10",
            "asin",
            "other"
          ]
        },
        "raw": {
          "type": "string"
        },
        "normalized": {
          "type": "string"
        },
        "validity": {
          "enum": [
            "valid",
            "invalid",
            "unchecked"
          ]
        },
        "isDerived": {
          "type": "boolean"
        }
      }
    },
    "richCode": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "raw",
        "normalized",
        "labelRaw",
        "family"
      ],
      "properties": {
        "raw": {
          "type": "string"
        },
        "normalized": {
          "type": "string"
        },
        "labelRaw": {
          "type": "string"
        },
        "family": {
          "type": "string"
        }
      }
    },
    "richRejection": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "codeRaw",
        "codes",
        "narrativeRaw",
        "hasStandardCode",
        "hasNarrative"
      ],
      "properties": {
        "codeRaw": {
          "type": [
            "string",
            "null"
          ]
        },
        "codes": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/richCode"
          }
        },
        "narrativeRaw": {
          "type": [
            "string",
            "null"
          ]
        },
        "hasStandardCode": {
          "type": "boolean"
        },
        "hasNarrative": {
          "type": "boolean"
        }
      }
    },
    "richSource": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "snapshotId",
        "page",
        "row",
        "ordinal"
      ],
      "properties": {
        "snapshotId": {
          "type": "string"
        },
        "page": {
          "type": "integer",
          "minimum": 1
        },
        "row": {
          "type": "integer",
          "minimum": 1
        },
        "ordinal": {
          "type": "integer",
          "minimum": 1
        }
      }
    },
    "richEntry": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "slug",
        "titleRaw",
        "titleDisplay",
        "authorRaw",
        "formatRaw",
        "format",
        "dateAdded",
        "identifiers",
        "rejection",
        "source",
        "warnings"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "slug": {
          "type": "string"
        },
        "titleRaw": {
          "type": "string",
          "minLength": 1
        },
        "titleDisplay": {
          "type": "string",
          "minLength": 1
        },
        "authorRaw": {
          "type": [
            "string",
            "null"
          ]
        },
        "formatRaw": {
          "type": "string"
        },
        "format": {
          "enum": [
            "book",
            "periodical",
            "publication",
            "unknown"
          ]
        },
        "dateAdded": {
          "type": "string",
          "format": "date"
        },
        "identifiers": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/richIdentifier"
          }
        },
        "rejection": {
          "$ref": "#/definitions/richRejection"
        },
        "source": {
          "$ref": "#/definitions/richSource"
        },
        "warnings": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "richDataset": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "meta",
        "entries",
        "analysis",
        "history"
      ],
      "properties": {
        "meta": {
          "$ref": "#/definitions/meta"
        },
        "entries": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/definitions/richEntry"
          }
        },
        "analysis": {
          "$ref": "#/definitions/analysis"
        },
        "history": {
          "$ref": "#/definitions/history"
        }
      }
    }
  }
}
