"""Common dependencies for REST API.

⚠️ AUTO-GENERATED BY PRISM - DO NOT EDIT
"""

from __future__ import annotations

from typing import Annotated, AsyncGenerator

from fastapi import Depends, Query
from sqlalchemy.ext.asyncio import AsyncSession

from {{ project_name }}.database import get_db


class PaginationParams:
    """Common pagination parameters."""

    def __init__(
        self,
        page: Annotated[int, Query(ge=1, description="Page number")] = 1,
        page_size: Annotated[int, Query(ge=1, le=100, description="Items per page")] = 20,
    ) -> None:
        self.page = page
        self.page_size = page_size
        self.skip = (page - 1) * page_size
        self.limit = page_size


class SortParams:
    """Common sorting parameters."""

    def __init__(
        self,
        sort_by: Annotated[str | None, Query(description="Field to sort by")] = None,
        sort_order: Annotated[str, Query(pattern="^(asc|desc)$", description="Sort order")] = "asc",
    ) -> None:
        self.sort_by = sort_by
        self.sort_order = sort_order


# Type aliases for dependency injection
DbSession = Annotated[AsyncSession, Depends(get_db)]
Pagination = Annotated[PaginationParams, Depends()]
Sorting = Annotated[SortParams, Depends()]


__all__ = [
    "DbSession",
    "Pagination",
    "PaginationParams",
    "Sorting",
    "SortParams",
    "get_db",
]
