{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:bbe:kldy:resource:0.1",
  "properties": {
    "kldyVersion": {
      "const": "0.1"
    }
  },
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "resourceType": {
          "const": "SoftwareCapability"
        },
        "kldyVersion": {
          "const": "0.1"
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80,
          "pattern": "^[a-zA-Z0-9_.:-]+$"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120
        },
        "description": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1000
        },
        "license": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40
          },
          "maxItems": 16,
          "minItems": 0,
          "uniqueItems": true
        },
        "platforms": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40
          },
          "maxItems": 8,
          "minItems": 1,
          "uniqueItems": true
        },
        "capabilities": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80,
                "pattern": "^[a-zA-Z0-9_.:-]+$"
              },
              "summary": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "inputs": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 80,
                  "pattern": "^[a-zA-Z0-9_.:-]+$"
                },
                "maxItems": 16,
                "minItems": 0,
                "uniqueItems": true
              },
              "outputs": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 80,
                  "pattern": "^[a-zA-Z0-9_.:-]+$"
                },
                "maxItems": 16,
                "minItems": 0,
                "uniqueItems": true
              },
              "requires_auth": {
                "type": "boolean"
              },
              "side_effects": {
                "type": "boolean"
              },
              "dependencies": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 80,
                  "pattern": "^[a-zA-Z0-9_.:-]+$"
                },
                "maxItems": 16,
                "minItems": 0,
                "uniqueItems": true
              }
            },
            "required": [
              "id",
              "summary",
              "inputs",
              "outputs",
              "requires_auth",
              "side_effects",
              "dependencies"
            ],
            "additionalProperties": false
          },
          "maxItems": 16,
          "minItems": 1,
          "uniqueItems": true
        }
      },
      "required": [
        "resourceType",
        "kldyVersion",
        "id",
        "name",
        "description",
        "license",
        "tags",
        "platforms",
        "capabilities"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "resourceType": {
          "const": "BusinessService"
        },
        "kldyVersion": {
          "const": "0.1"
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80,
          "pattern": "^[a-zA-Z0-9_.:-]+$"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 120
        },
        "description": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1000
        },
        "website": {
          "type": "string",
          "minLength": 1,
          "maxLength": 512
        },
        "categories": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40
          },
          "maxItems": 16,
          "minItems": 1,
          "uniqueItems": true
        },
        "service_areas": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "maxItems": 16,
          "minItems": 0,
          "uniqueItems": true
        },
        "interaction_mode": {
          "enum": [
            "informational_only",
            "actionable"
          ]
        },
        "capabilities": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80,
                "pattern": "^[a-zA-Z0-9_.:-]+$"
              },
              "summary": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "inputs": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 80,
                  "pattern": "^[a-zA-Z0-9_.:-]+$"
                },
                "maxItems": 16,
                "minItems": 0,
                "uniqueItems": true
              },
              "outputs": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 80,
                  "pattern": "^[a-zA-Z0-9_.:-]+$"
                },
                "maxItems": 16,
                "minItems": 0,
                "uniqueItems": true
              },
              "requires_auth": {
                "type": "boolean"
              },
              "side_effects": {
                "type": "boolean"
              },
              "dependencies": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 80,
                  "pattern": "^[a-zA-Z0-9_.:-]+$"
                },
                "maxItems": 16,
                "minItems": 0,
                "uniqueItems": true
              }
            },
            "required": [
              "id",
              "summary",
              "inputs",
              "outputs",
              "requires_auth",
              "side_effects",
              "dependencies"
            ],
            "additionalProperties": false
          },
          "maxItems": 16,
          "minItems": 0,
          "uniqueItems": true
        }
      },
      "required": [
        "resourceType",
        "kldyVersion",
        "id",
        "name",
        "description",
        "website",
        "categories",
        "service_areas",
        "interaction_mode",
        "capabilities"
      ],
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "interaction_mode": {
                "const": "actionable"
              }
            }
          },
          "then": {
            "properties": {
              "capabilities": {
                "minItems": 1
              }
            }
          }
        }
      ]
    }
  ]
}
