{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://abizrecord.org/schema/abiz-business-record-v1.schema.json",
  "title": "ABIZ Business Record (protocol family abiz1)",
  "description": "Normative structural schema for the ABIZ 1.1 public-review draft; independent DNS and registry checks are required for full conformance.",
  "type": "object",
  "required": [
    "record-version",
    "business-name",
    "country",
    "identity-host",
    "domains"
  ],
  "additionalProperties": false,
  "properties": {
    "record-version": {
      "const": "abiz1",
      "description": "Wire protocol family; the specification document may have a later draft revision."
    },
    "business-name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 240,
      "pattern": "\\S"
    },
    "country": {
      "type": "string",
      "pattern": "^[A-Z]{2}$",
      "description": "ISO 3166-1 alpha-2 country code; validator must check assigned codes."
    },
    "identity-host": {
      "type": "string",
      "minLength": 4,
      "maxLength": 512,
      "pattern": "^[A-Za-z0-9][A-Za-z0-9.-]*(?:/[^\\s?#]*)?$",
      "description": "DNS h value: lowercase DNS hostname with optional path; never includes https://"
    },
    "domains": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "format": "hostname",
        "minLength": 4,
        "maxLength": 253
      },
      "description": "Business-controlled domain names this record claims. DNS cross-check must confirm control."
    },
    "business-key": {
      "type": "string",
      "pattern": "^[a-z]{2}-[A-Za-z0-9][A-Za-z0-9._-]*$",
      "maxLength": 128
    },
    "registration-number": {
      "type": "string",
      "minLength": 1,
      "maxLength": 96,
      "pattern": "\\S"
    },
    "mcp-server-url": {
      "type": "string",
      "format": "uri",
      "pattern": "^https://",
      "maxLength": 2048,
      "description": "Optional. No conformance requirement to operate an MCP server."
    },
    "description": {
      "type": "string",
      "minLength": 1,
      "maxLength": 4000
    },
    "website": {
      "type": "string",
      "format": "uri",
      "pattern": "^https://",
      "maxLength": 2048
    },
    "contact-email": {
      "type": "string",
      "format": "email",
      "maxLength": 320
    },
    "contact-phone": {
      "type": "string",
      "maxLength": 64
    },
    "logo-url": {
      "type": "string",
      "format": "uri",
      "pattern": "^https://",
      "maxLength": 2048
    },
    "last-updated": {
      "type": "string",
      "format": "date-time"
    },
    "services": {
      "type": "array",
      "maxItems": 200,
      "items": {
        "type": "object",
        "required": [
          "name"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 180
          },
          "description": {
            "type": "string",
            "maxLength": 2000
          },
          "url": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://"
          }
        }
      }
    },
    "locations": {
      "type": "array",
      "maxItems": 100,
      "items": {
        "type": "object",
        "required": [
          "country",
          "city"
        ],
        "additionalProperties": false,
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "registered-office",
              "trading",
              "other"
            ]
          },
          "name": {
            "type": "string",
            "maxLength": 180
          },
          "city": {
            "type": "string",
            "minLength": 1
          },
          "region": {
            "type": "string"
          },
          "country": {
            "type": "string",
            "pattern": "^[A-Z]{2}$"
          },
          "street": {
            "type": "string"
          },
          "postal-code": {
            "type": "string"
          },
          "public": {
            "type": "boolean"
          }
        }
      }
    },
    "opening-hours": {
      "type": "array",
      "maxItems": 50,
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 160
      }
    },
    "links": {
      "type": "array",
      "maxItems": 100,
      "items": {
        "type": "object",
        "required": [
          "label",
          "url"
        ],
        "additionalProperties": false,
        "properties": {
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 140
          },
          "url": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://"
          }
        }
      }
    },
    "extensions": {
      "type": "object",
      "propertyNames": {
        "pattern": "^[a-z0-9-]+(?:\\.[a-z0-9-]+)+$"
      },
      "additionalProperties": true,
      "description": "Vendor-namespaced extensions; consumers may ignore unfamiliar extensions."
    }
  },
  "dependentRequired": {
    "business-key": [
      "registration-number"
    ],
    "registration-number": [
      "business-key"
    ]
  }
}
