{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Atelier public coverage ledger",
  "type": "object",
  "required": [
    "schema_version",
    "site",
    "scope",
    "as_of",
    "records",
    "counts"
  ],
  "properties": {
    "schema_version": {
      "const": 1
    },
    "site": {
      "enum": [
        "nada",
        "nour"
      ]
    },
    "scope": {
      "type": "string"
    },
    "as_of": {
      "type": "string",
      "format": "date"
    },
    "counts": {
      "type": "object",
      "required": [
        "expanded_library_article_entries",
        "unique_subjects",
        "linked_article_studies"
      ],
      "additionalProperties": {
        "type": "integer",
        "minimum": 0
      }
    },
    "records": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "entity_id",
          "name",
          "entity_type",
          "status",
          "aliases",
          "article_ids",
          "routes",
          "facets",
          "sources",
          "images"
        ],
        "properties": {
          "entity_id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "entity_type": {
            "type": "string"
          },
          "status": {
            "enum": [
              "covered",
              "verified"
            ]
          },
          "aliases": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "article_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "routes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "facets": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "required": [
                "status",
                "evidence"
              ],
              "properties": {
                "status": {
                  "enum": [
                    "documented",
                    "partial",
                    "not_documented",
                    "not_applicable"
                  ]
                },
                "evidence": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "article_id",
                      "section_id",
                      "source_ids"
                    ],
                    "properties": {
                      "article_id": {
                        "type": "string"
                      },
                      "section_id": {
                        "type": "string"
                      },
                      "source_ids": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "sources": {
            "type": "array"
          },
          "images": {
            "type": "array"
          },
          "sourced_properties": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/sourced_statement"
            }
          },
          "material_profile": {
            "anyOf": [
              {
                "$ref": "#/$defs/material_profile"
              },
              {
                "type": "null"
              }
            ]
          },
          "house_profile": {
            "anyOf": [
              {
                "$ref": "#/$defs/house_profile"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      }
    }
  },
  "$defs": {
    "sourced_statement": {
      "type": "object",
      "required": [
        "label",
        "value",
        "scope",
        "source_ids"
      ],
      "properties": {
        "label": {
          "type": "string"
        },
        "value": {},
        "scope": {
          "type": "string",
          "minLength": 1
        },
        "units": {
          "type": [
            "string",
            "null"
          ]
        },
        "conditions": {
          "type": [
            "string",
            "null"
          ]
        },
        "source_ids": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string"
          }
        },
        "source_url": {
          "type": "string",
          "format": "uri"
        },
        "uncertainty": {
          "type": [
            "string",
            "null"
          ]
        },
        "date_type": {
          "type": [
            "string",
            "null"
          ]
        },
        "checked_at": {
          "type": "string",
          "format": "date"
        }
      }
    },
    "sourced_place": {
      "type": "object",
      "required": [
        "name",
        "scope",
        "source_ids"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "scope": {
          "type": "string"
        },
        "source_ids": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string"
          }
        },
        "source_url": {
          "type": "string",
          "format": "uri"
        },
        "representative": {
          "type": "boolean"
        }
      }
    },
    "material_profile": {
      "type": "object",
      "required": [
        "identity_kind",
        "properties",
        "representative_localities",
        "growth_origin_scope"
      ],
      "properties": {
        "identity_kind": {
          "type": "string"
        },
        "properties": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/sourced_statement"
          }
        },
        "representative_localities": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/sourced_place"
          }
        },
        "growth_origin_scope": {
          "type": "string"
        }
      }
    },
    "house_profile": {
      "type": "object",
      "required": [
        "identity_people",
        "dated_properties_and_milestones",
        "current_legal_entity",
        "current_owner",
        "model_or_calibre_scope"
      ],
      "properties": {
        "identity_people": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "name",
              "scope",
              "source_ids"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "scope": {
                "type": "string"
              },
              "source_ids": {
                "type": "array",
                "minItems": 1,
                "items": {
                  "type": "string"
                }
              }
            }
          }
        },
        "dated_properties_and_milestones": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/sourced_statement"
          }
        },
        "current_legal_entity": {
          "type": [
            "string",
            "null"
          ]
        },
        "current_owner": {
          "type": [
            "string",
            "null"
          ]
        },
        "model_or_calibre_scope": {
          "type": "string"
        }
      }
    }
  }
}
