{
    "$schema": "../meta-schema.json",
    "name": "conditional-branching",
    "description": "Demonstrates conditional execution with nested transforms and requests",
    "steps": [
        {
            "name": "checkInventory",
            "request": {
                "method": "inventory.check",
                "params": {
                    "productId": 123
                }
            }
        },
        {
            "name": "processOrder",
            "condition": {
                "if": "${checkInventory.result.length} > 0 && ${checkInventory.result[0].quantity} >= 10",
                "then": {
                    "name": "createBulkOrder",
                    "transform": {
                        "input": "${checkInventory.result}",
                        "operations": [
                            {
                                "type": "map",
                                "using": "{orderId: null, quantity: ${item.quantity}}"
                            }
                        ]
                    }
                },
                "else": {
                    "name": "createRegularOrder",
                    "request": {
                        "method": "orders.create",
                        "params": {
                            "productId": 123,
                            "quantity": "${checkInventory.result.quantity}",
                            "backorderAllowed": true
                        }
                    }
                }
            }
        },
        {
            "name": "notifyResult",
            "request": {
                "method": "notification.send",
                "params": {
                    "type": "order_confirmation",
                    "orderId": "${processOrder.result.result[0].orderId}"
                }
            }
        }
    ]
}
