{
  "schemaVersion": 1,
  "id": "6f1d2a3b-4c5d-4e6f-8a9b-0c1d2e3f4a5b",
  "name": "Привет, Tulpar",
  "description": "Переменные, лог, условие, цикл и обработка ошибок — без внешних приложений",
  "variables": [
    { "name": "greeting", "type": "string", "default": "Привет, Tulpar!", "isArgument": true },
    { "name": "total", "type": "number", "default": 0, "isArgument": false },
    { "name": "numbers", "type": "list", "default": [], "isArgument": false }
  ],
  "steps": [
    {
      "id": "s_hello001",
      "type": "control.log",
      "props": { "level": "info", "message": "{{ greeting }}" }
    },
    {
      "id": "s_assign01",
      "type": "control.assign",
      "displayName": "Список чисел",
      "props": { "variable": "numbers", "value": "[1, 2, 3, 4, 5]" }
    },
    {
      "id": "s_loop0001",
      "type": "control.forEach",
      "props": { "items": "numbers", "itemVariable": "n", "indexVariable": "i" },
      "children": {
        "body": [
          {
            "id": "s_sum00001",
            "type": "control.assign",
            "props": { "variable": "total", "value": "total + n" }
          },
          {
            "id": "s_logn0001",
            "type": "control.log",
            "props": { "level": "info", "message": "Элемент {{ i + 1 }}: {{ n }}, сумма {{ total }}" }
          }
        ]
      }
    },
    {
      "id": "s_check001",
      "type": "control.if",
      "props": { "condition": "total === 15" },
      "children": {
        "then": [
          { "id": "s_logok001", "type": "control.log", "props": { "level": "info", "message": "Сумма верна: {{ total }}" } }
        ],
        "else": [
          { "id": "s_throw001", "type": "control.throw", "props": { "message": "Неверная сумма: {{ total }}" } }
        ]
      }
    },
    {
      "id": "s_try00001",
      "type": "control.tryCatch",
      "props": { "errorVariable": "error" },
      "children": {
        "try": [
          { "id": "s_throw002", "type": "control.throw", "props": { "message": "Тестовая ошибка" } }
        ],
        "catch": [
          { "id": "s_logerr01", "type": "control.log", "props": { "level": "warn", "message": "Поймано: {{ error.message }} (код {{ error.code }})" } }
        ],
        "finally": [
          { "id": "s_logfin01", "type": "control.log", "props": { "level": "info", "message": "Блок finally выполнен" } }
        ]
      }
    },
    {
      "id": "s_done0001",
      "type": "control.log",
      "props": { "level": "info", "message": "Готово: {{ formatDate(now(), 'dd.MM.yyyy') }}" }
    }
  ]
}
