{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://designlasagna.recipes/v0.3/utilities.json",
  "title": "Design System Utilities Manifest",
  "description": "Schema for resolved utility manifests consumed by language servers and tooling.",
  "type": "object",
  "required": ["schemaVersion"],
  "properties": {
    "$schema": { "type": "string" },
    "schemaVersion": {
      "type": "string",
      "description": "Schema version (semver)"
    },
    "generatedAt": {
      "type": "string",
      "format": "date-time",
      "description": "ISO timestamp of when this manifest was generated"
    },
    "designSystem": { "$ref": "#/definitions/DesignSystemMeta" },
    "variantPatterns": { "$ref": "#/definitions/VariantPatterns" },
    "categories": {
      "type": "array",
      "items": { "$ref": "#/definitions/Category" }
    },
    "utilities": {
      "type": "array",
      "items": { "$ref": "#/definitions/UtilityClass" }
    }
  },
  "oneOf": [
    { "required": ["schemaVersion", "categories"] },
    { "required": ["schemaVersion", "utilities"] }
  ],
  "definitions": {
    "DesignSystemMeta": {
      "type": "object",
      "description": "Identity of the design system that produced this manifest.",
      "properties": {
        "name": { "type": "string" },
        "version": { "type": "string" },
        "documentation": { "type": "string", "format": "uri" },
        "package": { "type": "string" },
        "docsTemplates": {
          "type": "object",
          "description": "URL templates for generating documentation links.",
          "properties": {
            "url": { "type": "string" },
            "figma": { "type": "string" },
            "storybook": { "type": "string" }
          },
          "additionalProperties": { "type": "string" }
        }
      }
    },
    "Category": {
      "type": "object",
      "required": ["name", "utilities"],
      "properties": {
        "name": {
          "type": "string",
          "description": "Human-readable category name"
        },
        "description": {
          "type": "string",
          "description": "Category description for documentation"
        },
        "prefix": {
          "type": "string",
          "description": "Common utility name prefix for this category"
        },
        "utilities": {
          "type": "array",
          "items": { "$ref": "#/definitions/UtilityClass" }
        }
      }
    },
    "UtilityClass": {
      "type": "object",
      "required": ["name"],
      "properties": {
        "name": {
          "type": "string",
          "description": "Utility identifier"
        },
        "description": {
          "type": "string",
          "description": "Human-readable description"
        },
        "status": {
          "type": "string",
          "description": "Lifecycle status. Common values: 'draft', 'experimental', 'beta', 'rc', 'stable', 'deprecated', 'removed'. Any string is allowed."
        },
        "exclusiveGroup": {
          "type": "string",
          "description": "Utilities sharing the same exclusiveGroup are mutually exclusive."
        },
        "variants": { "$ref": "#/definitions/UtilityVariants" },
        "priority": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100,
          "description": "Sort weight for autocomplete (0 lowest, 100 highest)."
        },
        "keywords": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Natural-language synonyms and search terms."
        },
        "since": {
          "type": "string",
          "description": "Version or date when this utility was introduced."
        },
        "docs": { "$ref": "#/definitions/Docs" },
        "platforms": {
          "type": "object",
          "description": "Platform-specific implementations. Keys are platform identifiers.",
          "additionalProperties": { "$ref": "#/definitions/PlatformUtility" }
        },
        "properties": {
          "type": "object",
          "description": "DEPRECATED in v0.3 — use platforms.web.properties instead.",
          "additionalProperties": { "type": "string" }
        },
        "tokens": {
          "type": "array",
          "description": "Token IDs referenced by this utility",
          "items": { "type": "string" }
        },
        "deprecated": {
          "oneOf": [
            { "type": "null" },
            { "$ref": "#/definitions/Deprecated" }
          ]
        }
      }
    },
    "UtilityVariants": {
      "type": "object",
      "properties": {
        "states": {
          "oneOf": [
            {
              "type": "boolean",
              "description": "true = supports all declared state variants"
            },
            {
              "type": "array",
              "description": "Subset of state names this utility supports",
              "items": { "type": "string" }
            }
          ]
        },
        "responsive": {
          "type": "boolean",
          "description": "Whether this utility supports responsive breakpoint variants"
        }
      },
      "additionalProperties": false
    },
    "VariantPatterns": {
      "type": "object",
      "properties": {
        "states": {
          "type": "object",
          "description": "Available pseudo-state variants. Keys are state names.",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "format": {
                "type": "string",
                "description": "Pattern for generating variant names. Use {utility} placeholder."
              },
              "description": { "type": "string" }
            }
          }
        },
        "responsive": {
          "type": "object",
          "properties": {
            "breakpoints": {
              "type": "array",
              "items": { "type": "string" }
            },
            "format": {
              "type": "string",
              "description": "Pattern for generating responsive variants"
            }
          }
        }
      }
    },
    "PlatformUtility": {
      "type": "object",
      "description": "How a utility is expressed on a specific platform.",
      "properties": {
        "className": { "type": "string" },
        "modifier": { "type": "string" },
        "style": { "type": "string" },
        "properties": {
          "type": "object",
          "additionalProperties": { "type": "string" }
        }
      },
      "additionalProperties": true
    },
    "Docs": {
      "type": "object",
      "description": "Documentation links for this item.",
      "properties": {
        "url": { "type": "string", "format": "uri" },
        "figma": { "type": "string", "format": "uri" },
        "storybook": { "type": "string", "format": "uri" }
      },
      "additionalProperties": { "type": "string", "format": "uri" }
    },
    "Deprecated": {
      "type": "object",
      "required": ["message"],
      "properties": {
        "message": {
          "type": "string",
          "description": "Human-readable deprecation reason and migration guidance"
        },
        "removal": {
          "type": "string",
          "description": "When the item will be removed"
        },
        "replacement": {
          "type": "string",
          "description": "Machine-readable replacement"
        }
      }
    }
  }
}
