{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openeik.org/schemas/0.1/proposed/review/terms-predicate.schema.json",
  "$comment": "Proposed for OpenEik 0.2: Part XVIII, review and issue. Written by hand from Part XVIII, not generated: tools/generate-schemas.mjs keeps this folder and lists none of it in index.json. A validator applies it to the predicate of a statement, decoded from its DSSE envelope; a validator applies it only when asked for the proposal (@openeik/tools: proposals [\"review\"], which applies the proposal drawings too).",
  "title": "Terms accepted predicate",
  "description": "The predicate of a record that a person accepted named terms, https://openeik.org/attestation/terms-accepted/v0.1 (Part XVIII, 6.1, proposed for 0.2): the person, a person of the registry; the terms by the SHA-256 of their text, with their title and version; the building, by its project's id, and the issue where they are an issue's; whether the person signed it with their own key or a host attests it; and when. Personal data, kept in every version that holds it.",
  "type": "object",
  "properties": {
    "person": {
      "$ref": "../drawings/defs.schema.json#/$defs/person"
    },
    "terms": {
      "$ref": "../drawings/issue.schema.json#/$defs/terms"
    },
    "for": {
      "description": "What the terms were accepted for: the building, and the issue where they are an issue's.",
      "type": "object",
      "properties": {
        "project": {
          "description": "The building, by its project's id (Part II, 2).",
          "type": "string",
          "minLength": 1
        },
        "issue": {
          "description": "The issue, by its id and its record's hash.",
          "type": "object",
          "properties": {
            "id": {
              "$ref": "../drawings/defs.schema.json#/$defs/id"
            },
            "hash": {
              "description": "The issue record's hash (Part III, 6), which is also the statement's subject's digest.",
              "$ref": "../drawings/defs.schema.json#/$defs/hash"
            }
          },
          "required": [
            "id",
            "hash"
          ],
          "x-eik-closed": true
        }
      },
      "required": [
        "project"
      ],
      "x-eik-closed": true
    },
    "by": {
      "type": "string",
      "enum": [
        "person",
        "host"
      ]
    },
    "host": {
      "description": "The host, as people know it: never its URL.",
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120
        }
      },
      "required": [
        "name"
      ],
      "x-eik-closed": true
    },
    "at": {
      "$ref": "../drawings/defs.schema.json#/$defs/time"
    }
  },
  "required": [
    "person",
    "terms",
    "for",
    "by",
    "at"
  ],
  "allOf": [
    {
      "if": {
        "properties": {
          "by": {
            "const": "host"
          }
        },
        "required": [
          "by"
        ]
      },
      "then": {
        "required": [
          "host"
        ]
      },
      "else": {
        "not": {
          "required": [
            "host"
          ]
        }
      }
    }
  ],
  "x-eik-closed": true
}
