{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Nimbus MCC License",
  "type": "object",
  "required": [
    "product",
    "edition",
    "mode",
    "license_id",
    "license_code",
    "customer",
    "capacity",
    "features",
    "support_tier",
    "valid_from",
    "valid_until",
    "integrity"
  ],
  "properties": {
    "schema_version": {
      "type": "string"
    },
    "generated_at": {
      "type": "string",
      "format": "date-time"
    },
    "product": {
      "const": "Nimbus_MCC"
    },
    "edition": {
      "enum": ["Core", "Professional", "Enterprise", "MSP"]
    },
    "mode": {
      "enum": ["online", "offline", "blacksite"]
    },
    "license_id": {
      "type": "string",
      "minLength": 8
    },
    "license_code": {
      "type": "string",
      "minLength": 8
    },
    "customer": {
      "type": "object",
      "required": ["name", "code"],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "code": {
          "type": "string",
          "minLength": 1
        },
        "contact_email": {
          "type": "string"
        },
        "contract_reference": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "capacity": {
      "type": "object",
      "required": ["sites", "managed_nodes", "relay_endpoints", "tenants"],
      "properties": {
        "sites": {
          "type": "integer",
          "minimum": 1
        },
        "managed_nodes": {
          "type": "integer",
          "minimum": 1
        },
        "relay_endpoints": {
          "type": "integer",
          "minimum": 0
        },
        "tenants": {
          "type": "integer",
          "minimum": 1
        }
      },
      "additionalProperties": false
    },
    "features": {
      "type": "array",
      "items": {
        "enum": [
          "migration-control",
          "metrics",
          "config-management",
          "scheduler",
          "remote-actions",
          "api-access",
          "order-integrations",
          "advanced-audit",
          "sso",
          "mfa",
          "secure-relay",
          "offline-blacksite",
          "multi-tenant"
        ]
      },
      "uniqueItems": true
    },
    "support_tier": {
      "enum": ["standard", "business", "mission-critical"]
    },
    "valid_from": {
      "type": "string",
      "format": "date"
    },
    "valid_until": {
      "type": "string",
      "format": "date"
    },
    "grace": {
      "type": "object",
      "properties": {
        "online_check_hours": {
          "type": "integer",
          "minimum": 1
        },
        "offline_refresh_days": {
          "type": "integer",
          "minimum": 1
        }
      },
      "additionalProperties": false
    },
    "binding": {
      "type": "object",
      "properties": {
        "deployment_mode": {
          "type": "string"
        },
        "allowed_domains": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "tenant_ids": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "instance_fingerprint": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "connectivity": {
      "type": "object",
      "properties": {
        "endpoint": {
          "type": "string"
        },
        "heartbeat_hours": {
          "type": "integer",
          "minimum": 1
        },
        "transport_method": {
          "type": "string"
        },
        "host_fingerprints": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": false
    },
    "issuer": {
      "type": "object",
      "properties": {
        "issued_by": {
          "type": "string"
        },
        "issued_via": {
          "type": "string"
        },
        "issued_at": {
          "type": "string",
          "format": "date-time"
        }
      },
      "additionalProperties": false
    },
    "metadata": {
      "type": "object",
      "properties": {
        "note": {
          "type": "string"
        },
        "deployment_notes": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "integrity": {
      "type": "object",
      "required": ["algorithm", "digest"],
      "properties": {
        "algorithm": {
          "const": "SHA-256"
        },
        "digest": {
          "type": "string",
          "minLength": 32
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
