{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://beyond10x.github.io/schema/b10x.docs.v3.json",
  "title": "b10x unified documentation source v3",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "repository",
    "delivery",
    "surfaces"
  ],
  "properties": {
    "schema": {
      "const": "b10x-docs/v3"
    },
    "repository": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "url",
        "displayName"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "url": {
          "type": "string",
          "format": "uri",
          "pattern": "^https://github\\.com/beyond10x/"
        },
        "displayName": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        }
      }
    },
    "delivery": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "publisher",
        "repository",
        "origin"
      ],
      "properties": {
        "publisher": {
          "const": "website"
        },
        "repository": {
          "const": "beyond10x.github.io"
        },
        "origin": {
          "const": "https://beyond10x.github.io"
        }
      }
    },
    "journeyPaths": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "understand": {
          "$ref": "#/$defs/surfaceKeys"
        },
        "plan-work": {
          "$ref": "#/$defs/surfaceKeys"
        },
        "specify": {
          "$ref": "#/$defs/surfaceKeys"
        },
        "build-agents": {
          "$ref": "#/$defs/surfaceKeys"
        },
        "operate-services": {
          "$ref": "#/$defs/surfaceKeys"
        }
      }
    },
    "surfaces": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/surface"
      }
    }
  },
  "$defs": {
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9-]*$"
    },
    "safePath": {
      "type": "string",
      "minLength": 1,
      "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\).+$"
    },
    "route": {
      "type": "string",
      "pattern": "^/(?:[A-Za-z0-9._~-]+/)*$"
    },
    "journey": {
      "enum": [
        "understand",
        "plan-work",
        "specify",
        "build-agents",
        "operate-services"
      ]
    },
    "surfaceKeys": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "pattern": "^[a-z0-9][a-z0-9-]*/[a-z0-9][a-z0-9-]*$"
      }
    },
    "link": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "label",
        "url"
      ],
      "properties": {
        "label": {
          "type": "string",
          "minLength": 1
        },
        "url": {
          "type": "string",
          "format": "uri",
          "pattern": "^https://"
        },
        "kind": {
          "enum": [
            "docs",
            "quickstart",
            "guide",
            "api",
            "source",
            "security",
            "status",
            "feed",
            "reference"
          ]
        }
      }
    },
    "feed": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "label",
        "url",
        "format",
        "scope"
      ],
      "properties": {
        "label": {
          "type": "string",
          "minLength": 1
        },
        "url": {
          "type": "string",
          "format": "uri",
          "pattern": "^https://"
        },
        "kind": {
          "const": "feed"
        },
        "format": {
          "enum": [
            "rss",
            "json-feed",
            "json"
          ]
        },
        "scope": {
          "enum": [
            "impact",
            "releases",
            "all"
          ]
        }
      }
    },
    "relationship": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "target",
        "kind"
      ],
      "properties": {
        "target": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9-]*/[a-z0-9][a-z0-9-]*$"
        },
        "kind": {
          "enum": [
            "introduces",
            "informs",
            "specifies",
            "implements",
            "hosts",
            "drives",
            "executes-in",
            "uses",
            "supports"
          ]
        },
        "label": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "adoption": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "label",
        "url",
        "mode",
        "estimatedMinutes",
        "outcome"
      ],
      "properties": {
        "label": {
          "type": "string",
          "minLength": 1
        },
        "url": {
          "type": "string",
          "format": "uri",
          "pattern": "^https://"
        },
        "mode": {
          "enum": [
            "browser",
            "install",
            "download",
            "source-build",
            "container",
            "hosted"
          ]
        },
        "estimatedMinutes": {
          "type": "integer",
          "minimum": 1,
          "maximum": 240
        },
        "prerequisites": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "uniqueItems": true
        },
        "outcome": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        }
      }
    },
    "selection": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "include"
      ],
      "properties": {
        "include": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "$ref": "#/$defs/safePath"
          }
        },
        "exclude": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "$ref": "#/$defs/safePath"
          }
        }
      }
    },
    "specification": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "format",
        "path",
        "route"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "format": {
          "enum": [
            "openapi",
            "json-schema"
          ]
        },
        "path": {
          "$ref": "#/$defs/safePath"
        },
        "route": {
          "$ref": "#/$defs/route"
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        }
      }
    },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "root"
      ],
      "properties": {
        "root": {
          "$ref": "#/$defs/safePath"
        },
        "documents": {
          "$ref": "#/$defs/selection"
        },
        "data": {
          "$ref": "#/$defs/selection"
        },
        "assets": {
          "$ref": "#/$defs/selection"
        },
        "blog": {
          "$ref": "#/$defs/selection"
        },
        "specifications": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/specification"
          }
        },
        "navigation": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "sidebar"
          ],
          "properties": {
            "label": {
              "type": "string",
              "minLength": 1,
              "maxLength": 80
            },
            "group": {
              "type": "string",
              "minLength": 1,
              "maxLength": 80
            },
            "order": {
              "type": "integer",
              "minimum": 0
            },
            "sidebar": {
              "enum": [
                "autogenerated",
                "flat"
              ]
            }
          }
        },
        "components": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "enum": [
              "AdoptionCard",
              "BoundaryNotice",
              "Callout",
              "CardGrid",
              "CodeExample",
              "CodeTabs",
              "CommandExample",
              "ContentCard",
              "DataCatalog",
              "DependencyGraph",
              "Diagram",
              "EcosystemFamilyGateway",
              "EcosystemSwitcher",
              "FactGrid",
              "FilterChipGroup",
              "JsonSchemaViewer",
              "OpenApiReference",
              "PageHeader",
              "ProjectCard",
              "SearchField",
              "SectionHeader",
              "StatusBadge"
            ]
          }
        }
      },
      "anyOf": [
        {
          "properties": {
            "documents": true
          },
          "required": [
            "documents"
          ]
        },
        {
          "properties": {
            "data": true
          },
          "required": [
            "data"
          ]
        },
        {
          "properties": {
            "assets": true
          },
          "required": [
            "assets"
          ]
        },
        {
          "properties": {
            "blog": true
          },
          "required": [
            "blog"
          ]
        },
        {
          "properties": {
            "specifications": true
          },
          "required": [
            "specifications"
          ]
        }
      ]
    },
    "surface": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "name",
        "summary",
        "kind",
        "canonicalUrl",
        "maturity",
        "availability",
        "discoverability",
        "audiences",
        "primaryJourney",
        "journeys",
        "capabilities",
        "sections",
        "routeBase",
        "source"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "summary": {
          "type": "string",
          "minLength": 1,
          "maxLength": 240
        },
        "kind": {
          "enum": [
            "front-door",
            "documentation",
            "research",
            "service-docs",
            "reference",
            "updates"
          ]
        },
        "canonicalUrl": {
          "type": "string",
          "format": "uri",
          "pattern": "^https://beyond10x\\.github\\.io/"
        },
        "maturity": {
          "enum": [
            "stable",
            "development",
            "experimental"
          ]
        },
        "availability": {
          "enum": [
            "published",
            "local-only",
            "planned"
          ]
        },
        "discoverability": {
          "enum": [
            "public",
            "unlisted",
            "internal"
          ]
        },
        "audiences": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "enum": [
              "evaluator",
              "adopter",
              "developer",
              "operator",
              "researcher"
            ]
          }
        },
        "primaryJourney": {
          "$ref": "#/$defs/journey"
        },
        "journeys": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "$ref": "#/$defs/journey"
          }
        },
        "capabilities": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/id"
          },
          "uniqueItems": true
        },
        "sections": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/link"
          }
        },
        "relationships": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/relationship"
          }
        },
        "feeds": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/feed"
          }
        },
        "adoption": {
          "$ref": "#/$defs/adoption"
        },
        "accent": {
          "type": "string",
          "pattern": "^#[0-9a-fA-F]{6}$"
        },
        "mark": {
          "$ref": "#/$defs/safePath"
        },
        "routeBase": {
          "$ref": "#/$defs/route"
        },
        "source": {
          "$ref": "#/$defs/source"
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "discoverability": {
                "const": "public"
              },
              "availability": {
                "const": "published"
              }
            },
            "required": [
              "discoverability",
              "availability"
            ]
          },
          "then": {
            "required": [
              "adoption"
            ],
            "properties": {
              "adoption": true,
              "audiences": {
                "type": "array",
                "minItems": 1
              }
            }
          }
        }
      ]
    }
  }
}
