"""
Utility functions for standardizing API responses
"""
from typing import Any, Dict, Optional

def success_response(
    data: Any = None,
    message: Optional[str] = None,
    **kwargs
) -> Dict[str, Any]:
    """
    Create a standardized success response.
    Returns both 'success' (boolean) and 'status' (string) for backward compatibility.
    """
    response: Dict[str, Any] = {
        'success': True,
        'status': 'success'
    }
    
    if data is not None:
        response['data'] = data
    
    if message:
        response['message'] = message
    
    # Add any additional fields
    response.update(kwargs)
    
    return response

def error_response(
    message: str,
    errors: Optional[list] = None,
    **kwargs
) -> Dict[str, Any]:
    """
    Create a standardized error response.
    """
    response: Dict[str, Any] = {
        'success': False,
        'status': 'error',
        'message': message
    }
    
    if errors:
        response['errors'] = errors
    
    response.update(kwargs)
    
    return response

