import functools

from snek.mapper.channel import ChannelMapper
from snek.mapper.channel_member import ChannelMemberMapper
from snek.mapper.channel_message import ChannelMessageMapper
from snek.mapper.notification import NotificationMapper
from snek.mapper.user import UserMapper
from snek.mapper.drive import DriveMapper 
from snek.mapper.drive_item import DriveItemMapper
from snek.system.object import Object


@functools.cache
def get_mappers(app=None):
    return Object(
        **{
            "user": UserMapper(app=app),
            "channel_member": ChannelMemberMapper(app=app),
            "channel": ChannelMapper(app=app),
            "channel_message": ChannelMessageMapper(app=app),
            "notification": NotificationMapper(app=app),
            "drive_item": DriveItemMapper(app=app),
            "drive": DriveMapper(app=app),
        }
    )


def get_mapper(name, app=None):
    return get_mappers(app=app)[name]
