from __future__ import annotations

from typing import Any


def ok(result: Any, metadata: dict[str, Any] | None = None) -> dict[str, Any]:
    return {
        "success": True,
        "result": result,
        "error": None,
        "metadata": metadata,
    }


def error(code: str, message: str, details: dict[str, Any] | None = None) -> dict[str, Any]:
    return {
        "success": False,
        "result": None,
        "error": {
            "code": code,
            "message": message,
            "details": details,
        },
        "metadata": None,
    }
