from typing import Optional

from api_graphql.abc.collection_filter_abc import CollectionFilterABC, FilterOperator
from api_graphql.abc.filter.collection.bool_collection_filter import (
    BoolCollectionFilter,
)
from api_graphql.abc.filter.collection.date_collection_filter import (
    DateCollectionFilter,
)
from api_graphql.abc.filter.collection.int_collection_filter import IntCollectionFilter


class DbModelCollectionFilterABC[T](CollectionFilterABC):
    def __init__(
        self,
        obj: Optional[dict],
        op: Optional[FilterOperator] = None,
        source_value: Optional[T] = None,
    ):
        CollectionFilterABC.__init__(self, obj, op, source_value)
        self._obj = obj

        self.add_field("id", IntCollectionFilter)
        self.add_field("deleted", BoolCollectionFilter)
        self.add_field("editor", IntCollectionFilter)
        self.add_field("created", DateCollectionFilter)
        self.add_field("updated", DateCollectionFilter)
