{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://the-internet-of-value-spec.netlify.app/schemas/registered-expression",
  "title": "The Internet of Value Registered Expression Manifest",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "id",
    "expression",
    "normalizedName",
    "slug",
    "version",
    "status",
    "handler",
    "modalities",
    "identityPolicy",
    "creatorPolicy",
    "protocolTrace",
    "wordWalletId"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "expression": {
      "type": "string",
      "pattern": "^~[^~\\r\\n]+~$",
      "minLength": 3,
      "maxLength": 130
    },
    "normalizedName": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128
    },
    "slug": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",
      "maxLength": 80
    },
    "version": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(?:-[0-9A-Za-z.-]+)?$"
    },
    "status": {
      "type": "string",
      "enum": [
        "draft",
        "submitted",
        "protocol-validated",
        "reviewed",
        "registered",
        "active",
        "deprecated",
        "archived"
      ]
    },
    "handler": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "contractVersion"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
        },
        "contractVersion": {
          "type": "string"
        }
      }
    },
    "modalities": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "enum": [
          "text",
          "image",
          "video"
        ]
      }
    },
    "identityPolicy": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "customInvocationRequiresIdentity",
        "consentScope"
      ],
      "properties": {
        "customInvocationRequiresIdentity": {
          "type": "boolean"
        },
        "consentScope": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "creatorPolicy": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "creationRequiresCompletedWellbeingIdentity",
        "acceptedCredentialType"
      ],
      "properties": {
        "creationRequiresCompletedWellbeingIdentity": {
          "const": true
        },
        "acceptedCredentialType": {
          "const": "WellbeingIdentityWorkshopCompletionCredential"
        }
      }
    },
    "creatorAttribution": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "did",
        "eligibilityCredentialId",
        "publicationConsented"
      ],
      "properties": {
        "did": {
          "type": "string",
          "pattern": "^did:iov:member:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
        },
        "eligibilityCredentialId": {
          "type": "string",
          "format": "uuid"
        },
        "publicationConsented": {
          "type": "boolean"
        }
      }
    },
    "protocolTrace": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "pattern": "^~{1,4}[A-Za-z0-9_]+$"
      }
    },
    "wordWalletId": {
      "type": "string",
      "format": "uuid"
    }
  }
}
