{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:hayat:schema:capability:vNEXT-D",
  "title": "HAYAT capability \u2014 vNEXT-D draft",
  "type": "object",
  "properties": {
    "protocol_version": {
      "const": "vNEXT-D"
    },
    "project_id": {
      "type": "string",
      "format": "uuid"
    },
    "artifact_id": {
      "type": "string",
      "format": "uuid"
    },
    "record_type": {
      "const": "capability"
    },
    "author_id": {
      "type": "string",
      "format": "uuid"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "pattern": "Z$"
    },
    "visibility": {
      "enum": [
        "local-example",
        "public",
        "shared",
        "private"
      ]
    },
    "source_refs": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "artifact_id": {
            "type": "string",
            "format": "uuid"
          },
          "sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "location": {
            "type": "string",
            "minLength": 1,
            "pattern": "^(?!/)(?!.*(?:\\.\\.|:)).+$"
          }
        },
        "required": [
          "artifact_id",
          "sha256"
        ],
        "additionalProperties": false
      },
      "minItems": 0,
      "uniqueItems": true
    },
    "content_sha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "payload_location": {
      "type": "string",
      "minLength": 1
    },
    "provenance_limitation": {
      "type": "string"
    },
    "simulation": {
      "type": "boolean"
    },
    "adapter_id": {
      "type": "string",
      "format": "uuid"
    },
    "version": {
      "type": "string",
      "minLength": 1
    },
    "checked_at": {
      "type": "string",
      "format": "date-time",
      "pattern": "Z$"
    },
    "status": {
      "enum": [
        "verified",
        "unverified",
        "unavailable"
      ]
    },
    "operations": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "minItems": 0,
      "uniqueItems": true
    },
    "resource_version_policies": {
      "type": "object",
      "additionalProperties": {
        "enum": [
          "required",
          "inapplicable"
        ]
      }
    },
    "authentication_method": {
      "type": "string",
      "minLength": 1
    },
    "resource_scope": {
      "type": "string",
      "minLength": 1
    },
    "content_types": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "minItems": 1,
      "uniqueItems": true
    },
    "limits": {
      "type": "object",
      "properties": {
        "remote_writes": {
          "type": "integer",
          "minimum": 0
        }
      },
      "required": [
        "remote_writes"
      ],
      "additionalProperties": false
    },
    "idempotency": {
      "type": "string",
      "minLength": 1
    },
    "receipt_semantics": {
      "type": "string",
      "minLength": 1
    }
  },
  "required": [
    "protocol_version",
    "project_id",
    "artifact_id",
    "record_type",
    "author_id",
    "created_at",
    "visibility",
    "source_refs",
    "content_sha256",
    "payload_location",
    "provenance_limitation",
    "simulation",
    "adapter_id",
    "version",
    "checked_at",
    "status",
    "operations",
    "resource_version_policies",
    "authentication_method",
    "resource_scope",
    "content_types",
    "limits",
    "idempotency",
    "receipt_semantics"
  ],
  "additionalProperties": false,
  "allOf": [
    {
      "if": {
        "properties": {
          "source_refs": {
            "maxItems": 0
          }
        }
      },
      "then": {
        "properties": {
          "provenance_limitation": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    }
  ]
}
