{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://weardash.app/schema/weardash-config.schema.json",
  "title": "WearDash config",
  "description": "Dashboard config for the WearDash Wear OS app: screens, tiles and complications rendered from this document. Format version 1.",
  "type": "object",
  "properties": {
    "version": {
      "type": "integer",
      "minimum": 1,
      "description": "Config format version (current: 1). Optional."
    },
    "title": {
      "type": "string"
    },
    "vars": {
      "type": "object",
      "additionalProperties": {
        "type": [
          "string",
          "number",
          "boolean"
        ]
      }
    },
    "secrets": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[A-Za-z_]\\w*$"
      },
      "description": "Secret NAMES only — values are typed on the watch or pushed end-to-end encrypted."
    },
    "connectors": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "type": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "url": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "token": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          }
        },
        "required": [
          "type"
        ],
        "additionalProperties": true
      }
    },
    "sources": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "url": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "headers": {
            "type": "object",
            "additionalProperties": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            }
          },
          "refresh": {
            "type": [
              "number",
              "string"
            ]
          },
          "entity": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "connector": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "method": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "body": {},
          "extract": {
            "type": "object",
            "additionalProperties": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            }
          }
        },
        "additionalProperties": true
      }
    },
    "actions": {
      "type": "object",
      "additionalProperties": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "method": {
                "type": [
                  "string",
                  "number",
                  "boolean"
                ]
              },
              "url": {
                "type": [
                  "string",
                  "number",
                  "boolean"
                ]
              },
              "headers": {
                "type": "object",
                "additionalProperties": {
                  "type": [
                    "string",
                    "number",
                    "boolean"
                  ]
                }
              },
              "body": {},
              "then_refresh": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "url"
            ],
            "additionalProperties": true
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "const": "atv"
              },
              "connector": {
                "type": [
                  "string",
                  "number",
                  "boolean"
                ]
              },
              "key": {
                "type": [
                  "string",
                  "number",
                  "boolean"
                ]
              },
              "app_link": {
                "type": [
                  "string",
                  "number",
                  "boolean"
                ]
              },
              "then_refresh": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "additionalProperties": true
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "const": "ha"
              },
              "connector": {
                "type": [
                  "string",
                  "number",
                  "boolean"
                ]
              },
              "service": {
                "type": [
                  "string",
                  "number",
                  "boolean"
                ]
              },
              "data": {},
              "then_refresh": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "service"
            ],
            "additionalProperties": true
          }
        ]
      }
    },
    "screens": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "root": {},
          "id": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "label": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          }
        },
        "required": [
          "id",
          "root"
        ],
        "additionalProperties": true
      }
    },
    "tiles": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "root": {},
          "id": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "label": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "screen": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          }
        },
        "required": [
          "id"
        ],
        "additionalProperties": true
      }
    },
    "complications": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "type": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "id": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "label": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "value": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "title": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "icon": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "screen": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "min": {
            "type": [
              "number",
              "string"
            ]
          },
          "max": {
            "type": [
              "number",
              "string"
            ]
          }
        },
        "required": [
          "id"
        ],
        "additionalProperties": true
      }
    },
    "tls": {
      "type": "object",
      "description": "Per-host TLS: custom CA (PEM) and/or mTLS client .p12 (secret name).",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "ca": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "client_p12": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          }
        },
        "additionalProperties": true
      }
    }
  },
  "additionalProperties": true,
  "$defs": {
    "component": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "column"
            },
            "condition": {
              "type": "string",
              "description": "Expression — hidden when falsy. `is_tile` selects the surface."
            },
            "children": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/component"
              }
            }
          },
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "row"
            },
            "condition": {
              "type": "string",
              "description": "Expression — hidden when falsy. `is_tile` selects the surface."
            },
            "children": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/component"
              }
            }
          },
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "box"
            },
            "condition": {
              "type": "string",
              "description": "Expression — hidden when falsy. `is_tile` selects the surface."
            },
            "children": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/component"
              }
            }
          },
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "text"
            },
            "condition": {
              "type": "string",
              "description": "Expression — hidden when falsy. `is_tile` selects the surface."
            },
            "value": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "size": {
              "type": [
                "number",
                "string"
              ]
            },
            "color": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "icon": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "icon_color": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "icon_bg": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            }
          },
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "spacer"
            },
            "condition": {
              "type": "string",
              "description": "Expression — hidden when falsy. `is_tile` selects the surface."
            },
            "width": {
              "type": [
                "number",
                "string"
              ]
            },
            "height": {
              "type": [
                "number",
                "string"
              ]
            }
          },
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "button"
            },
            "condition": {
              "type": "string",
              "description": "Expression — hidden when falsy. `is_tile` selects the surface."
            },
            "label": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "action": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "long_action": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "color": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "size": {
              "type": [
                "number",
                "string"
              ]
            },
            "icon": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "icon_color": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "icon_bg": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            }
          },
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "arc"
            },
            "condition": {
              "type": "string",
              "description": "Expression — hidden when falsy. `is_tile` selects the surface."
            },
            "value": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "max": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "color": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "thickness": {
              "type": [
                "number",
                "string"
              ]
            }
          },
          "required": [
            "value"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "image"
            },
            "condition": {
              "type": "string",
              "description": "Expression — hidden when falsy. `is_tile` selects the surface."
            },
            "url": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "headers": {
              "type": "object",
              "additionalProperties": {
                "type": [
                  "string",
                  "number",
                  "boolean"
                ]
              }
            },
            "height": {
              "type": [
                "number",
                "string"
              ]
            },
            "width": {
              "type": [
                "number",
                "string"
              ]
            },
            "refresh": {
              "type": [
                "number",
                "string"
              ]
            }
          },
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "slider"
            },
            "condition": {
              "type": "string",
              "description": "Expression — hidden when falsy. `is_tile` selects the surface."
            },
            "source": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "value": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "min": {
              "type": [
                "number",
                "string"
              ]
            },
            "max": {
              "type": [
                "number",
                "string"
              ]
            },
            "step": {
              "type": [
                "number",
                "string"
              ]
            },
            "action": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "param": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            }
          },
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "graph"
            },
            "condition": {
              "type": "string",
              "description": "Expression — hidden when falsy. `is_tile` selects the surface."
            },
            "source": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "path": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "height": {
              "type": [
                "number",
                "string"
              ]
            },
            "color": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            }
          },
          "required": [
            "source"
          ],
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "mic"
            },
            "condition": {
              "type": "string",
              "description": "Expression — hidden when falsy. `is_tile` selects the surface."
            },
            "connector": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "size": {
              "type": [
                "number",
                "string"
              ]
            }
          },
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "toggle"
            },
            "condition": {
              "type": "string",
              "description": "Expression — hidden when falsy. `is_tile` selects the surface."
            },
            "label": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "value": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "on": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "action": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "icon": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "icon_color": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "icon_bg": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            }
          },
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "stepper"
            },
            "condition": {
              "type": "string",
              "description": "Expression — hidden when falsy. `is_tile` selects the surface."
            },
            "label": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "value": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "min": {
              "type": [
                "number",
                "string"
              ]
            },
            "max": {
              "type": [
                "number",
                "string"
              ]
            },
            "step": {
              "type": [
                "number",
                "string"
              ]
            },
            "action": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "param": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "unit": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            }
          },
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "input"
            },
            "condition": {
              "type": "string",
              "description": "Expression — hidden when falsy. `is_tile` selects the surface."
            },
            "label": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "action": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "param": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "icon": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "icon_color": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "icon_bg": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            }
          },
          "additionalProperties": true
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "voice"
            },
            "condition": {
              "type": "string",
              "description": "Expression — hidden when falsy. `is_tile` selects the surface."
            },
            "label": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "mode": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "action": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "param": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "icon": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "icon_color": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "icon_bg": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "size": {
              "type": [
                "number",
                "string"
              ]
            },
            "max_duration": {
              "type": [
                "number",
                "string"
              ]
            },
            "confirm": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            }
          },
          "additionalProperties": true
        }
      ],
      "description": "One UI block. Voice modes: transcript, raw."
    }
  }
}
