{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://designlasagna.recipes/v0.3/tokens.json",
  "title": "Design System Tokens Manifest",
  "description": "Schema for resolved design token manifests consumed by language servers and tooling.",
  "type": "object",
  "required": ["schemaVersion", "tokens"],
  "properties": {
    "$schema": { "type": "string" },
    "schemaVersion": { "type": "string", "description": "Schema version (semver)" },
    "generatedAt": { "type": "string", "format": "date-time" },
    "extends": {
      "type": "array",
      "description": "Other manifests that should be loaded alongside this one.",
      "items": { "type": "string" }
    },
    "designSystem": { "$ref": "#/definitions/DesignSystemMeta" },
    "source": {
      "type": "object",
      "properties": {
        "files": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "file": { "type": "string" },
              "mode": { "type": "string" }
            }
          }
        }
      }
    },
    "counts": { "$ref": "#/definitions/Counts" },
    "conditions": { "$ref": "#/definitions/Conditions" },
    "collections": { "$ref": "#/definitions/Collections" },
    "tokenRelations": {
      "type": "array",
      "items": { "$ref": "#/definitions/TokenRelation" }
    },
    "tokens": {
      "type": "array",
      "items": { "$ref": "#/definitions/Token" }
    }
  },
  "definitions": {
    "DesignSystemMeta": {
      "type": "object",
      "properties": {
        "name": { "type": "string" },
        "version": { "type": "string" },
        "documentation": { "type": "string", "format": "uri" },
        "package": { "type": "string" },
        "docsTemplates": {
          "type": "object",
          "properties": {
            "url": { "type": "string" },
            "figma": { "type": "string" },
            "storybook": { "type": "string" }
          },
          "additionalProperties": { "type": "string" }
        }
      }
    },
    "Counts": {
      "type": "object",
      "properties": {
        "total": { "type": "integer" },
        "by": {
          "type": "object",
          "description": "Token counts by any grouping dimension.",
          "additionalProperties": {
            "type": "object",
            "additionalProperties": { "type": "integer" }
          }
        }
      }
    },
    "Conditions": {
      "type": "object",
      "description": "Condition dimensions and possible values.",
      "additionalProperties": {
        "type": "object",
        "required": ["values"],
        "properties": {
          "description": { "type": "string" },
          "type": {
            "type": "string",
            "description": "Condition type. Common values: colorScheme, viewport, motion, contrast, density, brand."
          },
          "values": {
            "type": "array",
            "items": { "type": "string" }
          },
          "default": { "type": "string" }
        }
      }
    },
    "Collections": {
      "type": "object",
      "description": "Named token collections.",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "name": { "type": "string" },
          "description": { "type": "string" },
          "conditions": {
            "type": "array",
            "items": { "type": "string" }
          },
          "defaults": {
            "type": "object",
            "properties": {
              "tier": { "type": "string" },
              "priority": { "type": "integer", "minimum": 0, "maximum": 100 },
              "usage": { "$ref": "#/definitions/Usage" },
              "format": { "$ref": "#/definitions/Format" },
              "a11y": { "$ref": "#/definitions/A11y" }
            }
          }
        }
      }
    },
    "TokenRelation": {
      "type": "object",
      "required": ["type", "tokens"],
      "properties": {
        "type": { "type": "string" },
        "tokens": {
          "type": "array",
          "items": { "type": "string" }
        },
        "description": { "type": "string" }
      }
    },
    "Token": {
      "type": "object",
      "required": ["id", "resolved"],
      "properties": {
        "id": { "type": "string", "description": "Token identifier" },
        "path": { "type": "array", "items": { "type": "string" } },
        "originalPath": { "type": "array", "items": { "type": "string" } },
        "label": {
          "type": "string",
          "description": "Human-facing display label for docs. Unrelated to DTCG group nesting, which is carried by `path` and `id`."
        },
        "category": { "type": "string" },
        "subCategory": { "type": ["string", "null"] },
        "collection": {
          "type": "string",
          "description": "Collection key this token belongs to."
        },
        "tier": {
          "type": "string",
          "description": "Token tier. Common values: primitive, semantic, component."
        },
        "type": {
          "type": ["string", "null"],
          "description": "Token type. Prefer specific values (e.g. color, spacing, borderRadius, fontSize)."
        },
        "description": { "type": ["string", "null"] },
        "cssVariable": {
          "type": ["string", "null"],
          "description": "DEPRECATED in v0.3 — use platforms.web.reference instead."
        },
        "platforms": {
          "type": "object",
          "additionalProperties": { "$ref": "#/definitions/PlatformMapping" }
        },
        "resolved": {
          "type": "object",
          "description": "Resolved values per condition key.",
          "additionalProperties": {
            "oneOf": [
              { "type": "string" },
              { "type": "number" },
              { "$ref": "#/definitions/CompositeValue" }
            ]
          }
        },
        "modes": {
          "type": "object",
          "description": "Authored values per condition key (may contain unresolved aliases such as `{color.blue.500}`). Together with `resolved` this is the sole source of alias information \u2014 `aliasChain` was removed in v0.3.",
          "additionalProperties": true
        },
        "format": { "$ref": "#/definitions/Format" },
        "usage": { "$ref": "#/definitions/Usage" },
        "a11y": { "$ref": "#/definitions/A11y" },
        "priority": { "type": "integer", "minimum": 0, "maximum": 100 },
        "since": { "type": "string" },
        "keywords": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Search synonyms. For finding the token, not for selecting it."
        },
        "docs": { "$ref": "#/definitions/Docs" },
        "deprecated": {
          "oneOf": [
            { "type": "null" },
            { "$ref": "#/definitions/Deprecated" }
          ]
        },
        "tags": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Arbitrary classification labels. Selectable — a lint rule can target a tag."
        },
        "sourceFiles": { "type": "array", "items": { "type": "string" } },
        "metadata": { "type": "object", "additionalProperties": true }
      }
    },
    "PlatformMapping": {
      "type": "object",
      "required": ["reference"],
      "properties": {
        "reference": { "type": "string" },
        "usage": { "type": "string" }
      },
      "additionalProperties": true
    },
    "CompositeValue": {
      "type": "object",
      "description": "Structured value for composite tokens (typography, border, shadow, etc.).",
      "additionalProperties": true
    },
    "Format": {
      "type": "object",
      "properties": {
        "colorSpace": { "type": "string" },
        "unit": { "type": "string" }
      }
    },
    "Usage": {
      "type": "object",
      "properties": {
        "allowedProperties": {
          "type": "array",
          "items": { "type": "string" }
        },
        "context": { "type": "string" },
        "doNot": {
          "type": "array",
          "items": { "type": "string" }
        }
      }
    },
    "A11y": {
      "type": "object",
      "properties": {
        "wcagContrast": {
          "oneOf": [
            { "$ref": "#/definitions/ContrastInfo" },
            {
              "type": "object",
              "additionalProperties": { "$ref": "#/definitions/ContrastInfo" }
            }
          ]
        },
        "minTargetSize": { "type": "string" },
        "motionSafe": { "type": "boolean" }
      }
    },
    "ContrastInfo": {
      "type": "object",
      "required": ["ratio"],
      "additionalProperties": false,
      "description": "`ratio` is required and additional properties are forbidden so that the single-value form stays distinguishable from the per-condition map form in A11y.wcagContrast's oneOf.",
      "properties": {
        "ratio": { "type": "number" },
        "against": { "type": "string" },
        "level": { "type": "string" }
      }
    },
    "Docs": {
      "type": "object",
      "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" },
        "removal": { "type": "string" },
        "replacement": { "type": "string" }
      }
    }
  }
}
