{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://dss.overbits.luz.uy/schemas/tokens.schema.json",
  "title": "Design Tokens Schema",
  "description": "Schema for design tokens in DSS format",
  "version": "2.0.0",
  "x-immutable-notice": {
    "protected": true,
    "reason": "Design token format specification - ensures consistency across projects",
    "lastModified": "2025-12-09",
    "bypassMethod": "Use 'DSS_IMMUTABLE_BYPASS=1 git commit' or commit message '[IMMUTABLE-UPDATE] reason'"
  },
  "type": "object",
  "properties": {
    "tokens": {
      "type": "object",
      "description": "Design token collection",
      "additionalProperties": {
        "oneOf": [
          {"$ref": "#/definitions/tokenValue"},
          {"$ref": "#/definitions/tokenGroup"}
        ]
      }
    },
    "metadata": {
      "type": "object",
      "properties": {
        "source": {
          "type": "string",
          "enum": ["figma", "css", "scss", "tailwind", "json", "manual"],
          "description": "Token source type"
        },
        "version": {
          "type": "string",
          "description": "Token collection version"
        },
        "lastUpdated": {
          "type": "string",
          "format": "date-time"
        },
        "projectId": {
          "type": "string",
          "description": "Associated project identifier"
        }
      }
    }
  },
  "definitions": {
    "tokenValue": {
      "type": "object",
      "required": ["value", "type"],
      "properties": {
        "value": {
          "description": "Token value (color, size, etc.)"
        },
        "type": {
          "type": "string",
          "enum": ["color", "dimension", "fontFamily", "fontWeight", "duration", "cubicBezier", "number", "string"],
          "description": "Token type"
        },
        "description": {
          "type": "string",
          "description": "Human-readable description"
        },
        "alias": {
          "type": "string",
          "description": "Reference to another token"
        },
        "source": {
          "type": "object",
          "properties": {
            "file": {"type": "string"},
            "line": {"type": "integer"},
            "figmaId": {"type": "string"}
          }
        }
      }
    },
    "tokenGroup": {
      "type": "object",
      "description": "Nested token group",
      "additionalProperties": {
        "oneOf": [
          {"$ref": "#/definitions/tokenValue"},
          {"$ref": "#/definitions/tokenGroup"}
        ]
      }
    }
  }
}
