# Scénario: Liste des projets (arborescence)
name: projects_list
version: "1.0"
description: Retourne tous les projets de l'utilisateur en arborescence

steps:
  - id: get_projects
    service: db
    action: query
    params:
      query: |
        SELECT p.*,
               GROUP_CONCAT(t.id) as tag_ids,
               GROUP_CONCAT(t.name) as tag_names
        FROM projects p
        LEFT JOIN project_tags pt ON p.id = pt.project_id
        LEFT JOIN tags t ON pt.tag_id = t.id
        WHERE p.user_id = ?
        GROUP BY p.id
        ORDER BY p.parent_id ASC, p.position ASC, p.name ASC
      args: ["{{auth.user_id}}"]

output:
  status: 200
  body:
    success: true
    data: "{{steps.get_projects.result | tree}}"
