"""Query-time filtering — convert authorization policies into database filters.

The filtering module provides an AST-based approach to answering the question:
"Give me all resources this user can access." Instead of checking each resource
individually (N+1), it compiles applicable policies into a FilterExpression
that can be translated to SQL WHERE clauses, Django Q objects, or raw SQL.

Example:
    filter_expr = rp.authorized_filter(user, "documents:read")

    # SQLAlchemy
    from pyauthz.filtering.sql import to_sqlalchemy_filter
    query = session.query(Document).filter(to_sqlalchemy_filter(filter_expr, Document))

    # Django ORM
    from pyauthz.filtering.django import to_django_q
    queryset = Document.objects.filter(to_django_q(filter_expr))

    # Raw SQL
    from pyauthz.filtering.raw_sql import to_raw_sql
    where_clause, params = to_raw_sql(filter_expr, table="documents")
"""

from pyauthz.filtering.expressions import (
    AllowAll,
    And,
    Compare,
    DenyAll,
    FilterExpression,
    Not,
    Or,
)

__all__ = [
    "FilterExpression",
    "AllowAll",
    "DenyAll",
    "Compare",
    "And",
    "Or",
    "Not",
]
