{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:coos:schema:Document",
  "title": "Document",
  "description": "A record held by or for the strata corporation, such as minutes, bylaws, financial statements, contracts or reports.",
  "type": "object",
  "x-domain": "documents",
  "x-status": "proposed",
  "x-since": "0.1.0-draft",
  "x-relationships": [
    {
      "field": "strataCorporationId",
      "target": "StrataCorporation",
      "cardinality": "one",
      "required": true
    },
    {
      "field": "supersedesDocumentId",
      "target": "Document",
      "cardinality": "one",
      "required": false
    }
  ],
  "x-validationRules": [
    "uri must not be publicly accessible when accessLevel is anything other than public.",
    "supersedesDocumentId must not reference this document."
  ],
  "x-legalReviewNotes": [
    "Records retention and owner access rights are defined by legislation; accessLevel is a hint for systems, not a legal classification."
  ],
  "required": [
    "id",
    "strataCorporationId",
    "title",
    "category"
  ],
  "additionalProperties": false,
  "properties": {
    "id": {
      "$ref": "urn:coos:schema:common#/$defs/Identifier",
      "description": "Stable identifier of this Document record."
    },
    "strataCorporationId": {
      "$ref": "urn:coos:schema:common#/$defs/Identifier",
      "description": "The strata corporation this record belongs to.",
      "x-references": "StrataCorporation"
    },
    "title": {
      "type": "string",
      "description": "Document title.",
      "minLength": 1,
      "maxLength": 300
    },
    "category": {
      "type": "string",
      "description": "Document category.",
      "enum": [
        "minutes",
        "bylawsAndRules",
        "financialStatement",
        "budget",
        "insurance",
        "depreciationReport",
        "engineeringReport",
        "contract",
        "correspondence",
        "plan",
        "other"
      ],
      "x-enumDescriptions": {
        "minutes": "Meeting minutes.",
        "bylawsAndRules": "Bylaws and rules.",
        "financialStatement": "Financial statements.",
        "budget": "Budget.",
        "insurance": "Insurance policy, certificate or summary.",
        "depreciationReport": "Depreciation report.",
        "engineeringReport": "Engineering, inspection or building report.",
        "contract": "Contract or agreement.",
        "correspondence": "Correspondence.",
        "plan": "Strata plan or other registered plan.",
        "other": "Other."
      }
    },
    "documentDate": {
      "$ref": "urn:coos:schema:common#/$defs/Date",
      "description": "Date of the document (for example, the meeting date for minutes)."
    },
    "version": {
      "type": "string",
      "description": "Version label assigned by the publisher.",
      "maxLength": 32
    },
    "supersedesDocumentId": {
      "$ref": "urn:coos:schema:common#/$defs/Identifier",
      "description": "Earlier version this document replaces.",
      "x-references": "Document"
    },
    "mediaType": {
      "type": "string",
      "description": "IANA media type of the file (for example application/pdf).",
      "pattern": "^[a-z]+/[a-z0-9.+-]+$"
    },
    "uri": {
      "type": "string",
      "description": "Location from which an authorized recipient can retrieve the file.",
      "format": "uri"
    },
    "sha256": {
      "type": "string",
      "description": "SHA-256 checksum of the file, hex encoded.",
      "pattern": "^[a-f0-9]{64}$"
    },
    "accessLevel": {
      "type": "string",
      "description": "Intended audience. Describes intent; it does not grant access.",
      "enum": [
        "public",
        "owners",
        "council",
        "restricted"
      ],
      "x-enumDescriptions": {
        "public": "May be published.",
        "owners": "Owners (and others entitled to records).",
        "council": "Council and management only.",
        "restricted": "Restricted (for example, legal or personal information)."
      }
    },
    "extensions": {
      "$ref": "urn:coos:schema:common#/$defs/Extensions",
      "description": "Implementation-specific data, namespaced by reverse domain."
    }
  }
}
