{
  "$id": "urn:statement",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Statements",
  "description": "An array of Statements.",
  "version": "0.4",
  "type": "array",
  "items": {
    "$ref": "#/$defs/Statement"
  },
  "$defs": {
    "Statement": {
      "title": "Statement",
      "description": "A claim about a person, entity or relationship, made at a particular point in time.",
      "type": "object",
      "properties": {
        "statementId": {
          "title": "Statement Identifier",
          "description": "A persistent globally unique identifier for this Statement. Length MUST be 32 - 64 characters (inclusive).",
          "type": "string",
          "minLength": 32,
          "maxLength": 64
        },
        "statementDate": {
          "title": "Statement Date",
          "description": "The date on which this statement was declared by the source, in full-date (YYYY-MM-DD) or date-time (e.g. YYYY-MM-DDTHH:MM:SSZ) format. See the IETF RFC3339 standard, section 5.6.",
          "type": "string",
          "anyOf": [
            {
              "format": "date"
            },
            {
              "format": "date-time"
            }
          ]
        },
        "annotations": {
          "title": "Annotations",
          "description": "Annotations about this Statement or parts of this Statement",
          "type": "array",
          "items": {
            "$ref": "#/$defs/Annotation"
          }
        },
        "publicationDetails": {
          "title": "Publication Details",
          "description": "Information concerning the publication of this Statement.",
          "type": "object",
          "properties": {
            "publicationDate": {
              "title": "Publication date",
              "description": "The date on which this statement was published, in full-date (YYYY-MM-DD) or date-time (e.g. YYYY-MM-DDTHH:MM:SSZ) format. See the IETF RFC3339 standard, section 5.6.",
              "type": "string",
              "anyOf": [
                {
                  "format": "date"
                },
                {
                  "format": "date-time"
                }
              ]
            },
            "bodsVersion": {
              "title": "BODS Version",
              "description": "The version of the Beneficial Ownership Data Standard to which this Statement conforms, expressed as major.minor (e.g. 0.2 or 1.0). In a published BODS dataset, all Statements MUST have the same major version number.",
              "type": "string",
              "pattern": "^(\\d+\\.)(\\d+)$"
            },
            "license": {
              "title": "License URL",
              "description": "A link to the license that applies to this Statement. The canonical URI of the license SHOULD be used. Publishers are encouraged to use a Public Domain Dedication or Open Definition Conformant (http://opendefinition.org/licenses/) license.",
              "type": "string",
              "format": "uri"
            },
            "publisher": {
              "type": "object",
              "title": "Publisher",
              "description": "Details of the organisation or person publishing a Statement.",
              "properties": {
                "name": {
                  "title": "Name",
                  "description": "The name of the publisher.",
                  "type": "string"
                },
                "url": {
                  "title": "URL",
                  "description": "The URL where details of the full dataset, or of the publisher, can be found.",
                  "type": "string",
                  "format": "uri"
                }
              },
              "anyOf": [
                {
                  "required": [
                    "name"
                  ]
                },
                {
                  "required": [
                    "url"
                  ]
                }
              ]
            }
          },
          "required": [
            "publicationDate",
            "bodsVersion",
            "publisher"
          ]
        },
        "source": {
          "title": "Source",
          "description": "The source of information in this statement. Each statement SHOULD contain source information.",
          "$ref": "urn:components#/$defs/Source"
        },
        "declaration": {
          "title": "Declaration Reference",
          "description": "An identifier or reference for a declaration within the publisher’s system. Where a Statement is a claim from a particular declaration (made at a point in time by a `source` about a `declarationSubject`) this field identifies the declaration.",
          "type": "string"
        },
        "declarationSubject": {
          "title": "Declaration Subject",
          "description": "A `recordId` value for the subject of a beneficial ownership network (always an entity or person).",
          "type": "string"
        },
        "recordId": {
          "title": "Record Identifier",
          "description": "A unique identifier for the record (within the publisher's system) to which this Statement relates. (A record captures information about an entity, natural person or relationship within the beneficial ownership network of a particular declaration subject.)",
          "type": "string"
        },
        "recordType": {
          "title": "Record Type",
          "description": "The type of record (within the publisher's system) to which this Statement relates: entity, person, or relationship.",
          "type": "string",
          "enum": [
            "entity",
            "person",
            "relationship"
          ],
          "codelist": "recordType.csv",
          "openCodelist": false
        },
        "recordStatus": {
          "title": "Record Status",
          "description": "The lifecycle status of the record (within the publisher's system) to which this Statement relates, using the recordStatus codelist.",
          "type": "string",
          "enum": [
            "new",
            "updated",
            "closed"
          ],
          "codelist": "recordStatus.csv",
          "openCodelist": false
        },
        "recordDetails": {
          "title": "Record Details",
          "description": "The details of the entity, person or relationship as declared on the Statement Date.",
          "type": "object"
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "recordType": {
                "const": "entity"
              }
            }
          },
          "then": {
            "properties": {
              "recordDetails": {
                "$ref": "urn:entity"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "recordType": {
                "const": "person"
              }
            }
          },
          "then": {
            "properties": {
              "recordDetails": {
                "$ref": "urn:person"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "recordType": {
                "const": "relationship"
              }
            }
          },
          "then": {
            "properties": {
              "recordDetails": {
                "$ref": "urn:relationship"
              }
            }
          }
        }
      ],
      "required": [
        "statementId",
        "declarationSubject",
        "recordId",
        "recordType",
        "recordDetails",
        "statementDate"
      ]
    },
    "Annotation": {
      "title": "Annotation",
      "description": "Additional information about the data contained in this Statement. Annotations can apply to a whole statement, an object or a single field. Custom properties can be included within the Annotation object to provide structured data where required.",
      "type": "object",
      "properties": {
        "statementPointerTarget": {
          "title": "Statement Fragment Pointer",
          "description": "An RFC6901 JSON Pointer (https://tools.ietf.org/html/rfc6901) describing the target fragment of the statement that this Annotation applies to, starting from the root of the Statement. An empty string (\"\") indicates that the Annotation applies to the whole Statement.",
          "type": "string"
        },
        "creationDate": {
          "title": "Creation Date",
          "description": "The date on which this Annotation was created, in full-date (YYYY-MM-DD) or date-time (e.g. YYYY-MM-DDTHH:MM:SSZ) format. See the IETF RFC3339 standard, section 5.6.",
          "type": "string",
          "anyOf": [
            {
              "format": "date"
            },
            {
              "format": "date-time"
            }
          ]
        },
        "createdBy": {
          "title": "Created By",
          "description": "The person, organisation or agent that created this Annotation.",
          "type": "object",
          "properties": {
            "name": {
              "title": "Name",
              "description": "The name of the person, organisation or agent that created this Annotation.",
              "type": "string"
            },
            "uri": {
              "title": "URI",
              "description": "An optional URI to identify the person, organisation or agent that created this Annotation.",
              "type": "string",
              "format": "uri"
            }
          }
        },
        "motivation": {
          "title": "Motivation",
          "description": "The reason for this Annotation, using the annotationMotivation codelist.",
          "type": "string",
          "enum": [
            "commenting",
            "correcting",
            "identifying",
            "linking",
            "transformation"
          ],
          "codelist": "annotationMotivation.csv",
          "openCodelist": false
        },
        "description": {
          "title": "Description",
          "description": "A free text description providing extra information about part of this Statement.",
          "type": "string"
        },
        "transformedContent": {
          "type": "string",
          "title": "Transformed Content",
          "description": "A representation of the Annotation target after the transformation in the `description` field has been applied. This field MUST only be used when the `motivation` is 'transformation'."
        },
        "url": {
          "title": "URL",
          "description": "A linked resource that annotates, provides context for or enhances this Statement. The content of the resource, or the relationship to the statement, MAY be described in the `description` field. This field is REQUIRED if the value of `motivation` is 'linking'.",
          "type": "string",
          "format": "uri"
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "motivation": {
                "const": "linking"
              }
            }
          },
          "then": {
            "required": [
              "statementPointerTarget",
              "motivation",
              "url"
            ]
          },
          "else": {
            "required": [
              "statementPointerTarget",
              "motivation"
            ]
          }
        },
        {
          "if": {
            "not": {
              "properties": {
                "motivation": {
                  "const": "transformation"
                }
              }
            }
          },
          "then": {
            "properties": {
              "transformedContent": {
                "const": ""
              }
            }
          }
        }
      ]
    }
  }
}
