{
  "oneOf": [
    {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "key": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,100}$"
        },
        "name": {
          "type": "string",
          "maxLength": 200,
          "minLength": 1
        },
        "protocol": {
          "const": "commentary-tracker-v1"
        },
        "operations": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "getSchema",
              "getPermissions",
              "queryRecords",
              "getRecord",
              "createRecord",
              "patchRecord",
              "archiveRecord",
              "bulk",
              "reorder",
              "listViews",
              "getView",
              "changes",
              "openResource",
              "openReview"
            ]
          },
          "maxItems": 14,
          "minItems": 0,
          "uniqueItems": true
        },
        "trackerId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,100}$"
        },
        "packageId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,100}$"
        },
        "packageRevisionId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,100}$"
        },
        "anchors": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]{1,100}$"
              },
              "pageId": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]{1,100}$"
              },
              "blockId": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]{1,100}$"
              }
            },
            "required": [
              "id",
              "pageId"
            ]
          },
          "maxItems": 100,
          "minItems": 0
        },
        "kind": {
          "const": "hosted"
        },
        "uploadId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,100}$"
        },
        "entry": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1024,
          "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.?(?:/|$))[^\\\\\\u0000]+$"
        }
      },
      "required": [
        "key",
        "name",
        "protocol",
        "operations",
        "kind",
        "uploadId",
        "entry"
      ],
      "allOf": [
        {
          "anyOf": [
            {
              "required": [
                "trackerId"
              ]
            },
            {
              "required": [
                "packageId",
                "packageRevisionId"
              ]
            }
          ]
        },
        {
          "dependentRequired": {
            "packageId": [
              "packageRevisionId"
            ],
            "packageRevisionId": [
              "packageId"
            ]
          }
        },
        {
          "if": {
            "not": {
              "required": [
                "trackerId"
              ]
            }
          },
          "then": {
            "properties": {
              "operations": {
                "maxItems": 0
              }
            }
          }
        }
      ]
    },
    {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "key": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,100}$"
        },
        "name": {
          "type": "string",
          "maxLength": 200,
          "minLength": 1
        },
        "protocol": {
          "const": "commentary-tracker-v1"
        },
        "operations": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "getSchema",
              "getPermissions",
              "queryRecords",
              "getRecord",
              "createRecord",
              "patchRecord",
              "archiveRecord",
              "bulk",
              "reorder",
              "listViews",
              "getView",
              "changes",
              "openResource",
              "openReview"
            ]
          },
          "maxItems": 14,
          "minItems": 0,
          "uniqueItems": true
        },
        "trackerId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,100}$"
        },
        "packageId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,100}$"
        },
        "packageRevisionId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,100}$"
        },
        "anchors": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]{1,100}$"
              },
              "pageId": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]{1,100}$"
              },
              "blockId": {
                "type": "string",
                "pattern": "^[A-Za-z0-9_-]{1,100}$"
              }
            },
            "required": [
              "id",
              "pageId"
            ]
          },
          "maxItems": 100,
          "minItems": 0
        },
        "kind": {
          "const": "external"
        },
        "externalUrl": {
          "type": "string",
          "maxLength": 2048,
          "format": "uri"
        }
      },
      "required": [
        "key",
        "name",
        "protocol",
        "operations",
        "kind",
        "externalUrl"
      ],
      "allOf": [
        {
          "anyOf": [
            {
              "required": [
                "trackerId"
              ]
            },
            {
              "required": [
                "packageId",
                "packageRevisionId"
              ]
            }
          ]
        },
        {
          "dependentRequired": {
            "packageId": [
              "packageRevisionId"
            ],
            "packageRevisionId": [
              "packageId"
            ]
          }
        },
        {
          "if": {
            "not": {
              "required": [
                "trackerId"
              ]
            }
          },
          "then": {
            "properties": {
              "operations": {
                "maxItems": 0
              }
            }
          }
        }
      ]
    }
  ]
}