{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://dta.martinprinz.dev/schemas/dta.token.schema.json",
  "title": "dta token --format json",
  "description": "Output of dta token get, find and list with --format json (version dta.token/1).",
  "oneOf": [
    {
      "title": "dta token get",
      "type": "object",
      "required": [
        "schema",
        "kind",
        "name",
        "type",
        "collection",
        "readings"
      ],
      "additionalProperties": false,
      "properties": {
        "schema": {
          "const": "dta.token/1"
        },
        "kind": {
          "const": "token"
        },
        "name": {
          "type": "string"
        },
        "type": {
          "enum": [
            "color",
            "dimension",
            "fontFamily",
            "fontWeight",
            "duration",
            "cubicBezier",
            "number",
            "strokeStyle",
            "border",
            "transition",
            "shadow",
            "gradient",
            "typography",
            "string",
            "boolean"
          ]
        },
        "collection": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "readings": {
          "type": "array",
          "description": "One reading per distinct mode combination the alias chain goes through",
          "items": {
            "type": "object",
            "required": [
              "modes",
              "chain"
            ],
            "additionalProperties": false,
            "properties": {
              "modes": {
                "type": "object",
                "description": "The modes of multi-mode collections the resolution went through, e.g. {\"Brand(Alias)\": \"BrandB\"}; empty when none",
                "additionalProperties": {
                  "type": "string"
                }
              },
              "raw": {
                "type": [
                  "string",
                  "number",
                  "boolean",
                  "array",
                  "object"
                ],
                "description": "The value as written, a value or an {alias}"
              },
              "value": {
                "type": [
                  "string",
                  "number",
                  "boolean",
                  "array",
                  "object"
                ],
                "description": "The resolved value; references inside composite values resolved too"
              },
              "parts": {
                "type": "array",
                "description": "References inside the raw value (a shadow from colour and size tokens), in order",
                "items": {
                  "type": "object",
                  "required": [
                    "at",
                    "reference"
                  ],
                  "additionalProperties": false,
                  "properties": {
                    "at": {
                      "type": "string",
                      "description": "Where in the value, e.g. \"offsetY\" or \"0.color\""
                    },
                    "reference": {
                      "type": "string",
                      "description": "As written: {alias} or $ref \"#/…\""
                    }
                  }
                }
              },
              "chain": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Token names along the alias chain, the token itself first"
              },
              "error": {
                "type": "string",
                "description": "Why the token did not resolve"
              }
            }
          }
        },
        "code": {
          "type": "object",
          "description": "The names `dta build` gives the token in code; missing when the build does not write the token (a multi-mode collection with no mode in `brands`)",
          "required": [
            "css"
          ],
          "additionalProperties": false,
          "properties": {
            "css": {
              "type": "string",
              "description": "CSS custom property, e.g. --colors-brand-primary"
            },
            "tailwind": {
              "type": "string",
              "description": "Tailwind v4 theme variable, when the token maps to a utility namespace"
            }
          }
        }
      }
    },
    {
      "title": "dta token get, unknown name (exit code 1)",
      "type": "object",
      "required": [
        "schema",
        "kind",
        "name",
        "suggestions"
      ],
      "additionalProperties": false,
      "properties": {
        "schema": {
          "const": "dta.token/1"
        },
        "kind": {
          "const": "unknown"
        },
        "name": {
          "type": "string"
        },
        "suggestions": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    {
      "title": "dta token find",
      "type": "object",
      "required": [
        "schema",
        "kind",
        "query",
        "matches"
      ],
      "additionalProperties": false,
      "properties": {
        "schema": {
          "const": "dta.token/1"
        },
        "kind": {
          "const": "matches"
        },
        "query": {
          "type": "string"
        },
        "matches": {
          "type": "array",
          "description": "Tokens that have the value at every breakpoint first, then deepest alias chain first: component and semantic tokens before primitives",
          "items": {
            "type": "object",
            "required": [
              "name",
              "type",
              "collection",
              "modes",
              "value",
              "depth"
            ],
            "additionalProperties": false,
            "properties": {
              "name": {
                "type": "string"
              },
              "type": {
                "enum": [
                  "color",
                  "dimension",
                  "fontFamily",
                  "fontWeight",
                  "duration",
                  "cubicBezier",
                  "number",
                  "strokeStyle",
                  "border",
                  "transition",
                  "shadow",
                  "gradient",
                  "typography",
                  "string",
                  "boolean"
                ]
              },
              "collection": {
                "type": "string"
              },
              "modes": {
                "type": "object",
                "description": "The modes of multi-mode collections the resolution went through, e.g. {\"Brand(Alias)\": \"BrandB\"}; empty when none",
                "additionalProperties": {
                  "type": "string"
                }
              },
              "value": {
                "type": [
                  "string",
                  "number",
                  "boolean",
                  "array",
                  "object"
                ],
                "description": "A scalar, or a DTCG 2025.10 object or list (a colour object, { value, unit }, a shadow …)"
              },
              "depth": {
                "type": "integer",
                "description": "Alias steps to the value; 0 holds it"
              },
              "breakpoint": {
                "enum": [
                  "default",
                  "other"
                ],
                "description": "With `breakpoints` in the config, a token without the value at every breakpoint: `default` has it at the default breakpoint, `other` only at others. Listed after the tokens that have it at every breakpoint."
              },
              "code": {
                "type": "object",
                "description": "The names `dta build` gives the token in code; missing when the build does not write the token (a multi-mode collection with no mode in `brands`)",
                "required": [
                  "css"
                ],
                "additionalProperties": false,
                "properties": {
                  "css": {
                    "type": "string",
                    "description": "CSS custom property, e.g. --colors-brand-primary"
                  },
                  "tailwind": {
                    "type": "string",
                    "description": "Tailwind v4 theme variable, when the token maps to a utility namespace"
                  }
                }
              }
            }
          }
        }
      }
    },
    {
      "title": "dta token list",
      "type": "object",
      "required": [
        "schema",
        "kind",
        "tokens"
      ],
      "additionalProperties": false,
      "properties": {
        "schema": {
          "const": "dta.token/1"
        },
        "kind": {
          "const": "list"
        },
        "tokens": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "name",
              "type",
              "collection",
              "alias"
            ],
            "additionalProperties": false,
            "properties": {
              "name": {
                "type": "string"
              },
              "type": {
                "enum": [
                  "color",
                  "dimension",
                  "fontFamily",
                  "fontWeight",
                  "duration",
                  "cubicBezier",
                  "number",
                  "strokeStyle",
                  "border",
                  "transition",
                  "shadow",
                  "gradient",
                  "typography",
                  "string",
                  "boolean"
                ]
              },
              "collection": {
                "type": "string"
              },
              "alias": {
                "type": "boolean",
                "description": "The value is an alias in every mode"
              }
            }
          }
        }
      }
    }
  ]
}
