# Path: djangoevents/domain.py
# class BaseAggregate(EventSourcedEntity):
# class BaseEntity(BaseAggregate):
#     def is_abstract_class(cls):
#     def mutate(cls, aggregate=None, event=None):
#     def create_for_event(cls, event):
#     def is_abstract_class(cls):
#     def mutate(cls, entity=None, event=None):
# 
# Path: djangoevents/schema.py
# def get_event_version(event_cls):
#     return getattr(event_cls, 'version', None) or 1
# 
# Path: djangoevents/settings.py
# def adds_schema_version_to_event_data():
#     config = get_config()
#     return config.get('ADDS_SCHEMA_VERSION_TO_EVENT_DATA', False)
# 
# Path: djangoevents/utils.py
# def camel_case_to_snake_case(text):
# 
#     def repl(match):
#         sep = match.group().lower()
#         if match.start() > 0:
#             sep = '_%s' % sep
#         return sep
# 
#     return re.sub(r'[A-Z][a-z]', repl, text).lower()


from .domain import DomainEvent
from .schema import get_event_version
from .settings import adds_schema_version_to_event_data
from .utils import camel_case_to_snake_case
from collections import namedtuple
from datetime import datetime
from eventsourcing.domain.model.events import resolve_attr
from eventsourcing.domain.services.transcoding import AbstractTranscoder
from eventsourcing.domain.services.transcoding import ObjectJSONDecoder
from eventsourcing.domain.services.transcoding import id_prefix_from_event
from eventsourcing.domain.services.transcoding import make_stored_entity_id
from eventsourcing.utils.time import timestamp_from_uuid
from inspect import isclass
import importlib
import json
            event_data=self._json_encode(event_data),
            aggregate_id=domain_event.entity_id,
            aggregate_type=get_aggregate_type(domain_event),
            aggregate_version=domain_event.entity_version,
            create_date=datetime.fromtimestamp(timestamp_from_uuid(domain_event.domain_event_id)),
            metadata=self._json_encode(getattr(domain_event, 'metadata', None)),
            module_name=domain_event_class.__module__,
            class_name=domain_event_class.__qualname__,
            # have to have stored_entity_id because of the lib
            stored_entity_id=make_stored_entity_id(id_prefix_from_event(domain_event), domain_event.entity_id),
        )

    def deserialize(self, stored_event):
        """
        Recreates original domain event from stored event topic and event attrs.
        """
        assert isinstance(stored_event, UnifiedStoredEvent)
        # Get the domain event class from the topic.
        domain_event_class = self._get_domain_event_class(stored_event.module_name, stored_event.class_name)

        # Deserialize event attributes from JSON
        event_attrs = self._json_decode(stored_event.event_data)

        # Reinstantiate and return the domain event object.
        defaults = {
            'entity_id': stored_event.aggregate_id,
            'entity_version': stored_event.aggregate_version,
            'domain_event_id': stored_event.event_id,
        }


# Path: djangoevents/domain.py
# class BaseAggregate(EventSourcedEntity):
# class BaseEntity(BaseAggregate):
#     def is_abstract_class(cls):
#     def mutate(cls, aggregate=None, event=None):
#     def create_for_event(cls, event):
#     def is_abstract_class(cls):
#     def mutate(cls, entity=None, event=None):
# 
# Path: djangoevents/schema.py
# def get_event_version(event_cls):
#     return getattr(event_cls, 'version', None) or 1
# 
# Path: djangoevents/settings.py
# def adds_schema_version_to_event_data():
#     config = get_config()
#     return config.get('ADDS_SCHEMA_VERSION_TO_EVENT_DATA', False)
# 
# Path: djangoevents/utils.py
# def camel_case_to_snake_case(text):
# 
#     def repl(match):
#         sep = match.group().lower()
#         if match.start() > 0:
#             sep = '_%s' % sep
#         return sep
# 
#     return re.sub(r'[A-Z][a-z]', repl, text).lower()


# Path: djangoevents/unifiedtranscoder.py
from .domain import DomainEvent
from .schema import get_event_version
from .settings import adds_schema_version_to_event_data
from .utils import camel_case_to_snake_case
from collections import namedtuple
from datetime import datetime
from eventsourcing.domain.model.events import resolve_attr
from eventsourcing.domain.services.transcoding import AbstractTranscoder
from eventsourcing.domain.services.transcoding import ObjectJSONDecoder
from eventsourcing.domain.services.transcoding import id_prefix_from_event
from eventsourcing.domain.services.transcoding import make_stored_entity_id
from eventsourcing.utils.time import timestamp_from_uuid
from inspect import isclass
import importlib
import json

            event_data=self._json_encode(event_data),
            aggregate_id=domain_event.entity_id,
            aggregate_type=get_aggregate_type(domain_event),
            aggregate_version=domain_event.entity_version,
            create_date=datetime.fromtimestamp(timestamp_from_uuid(domain_event.domain_event_id)),
            metadata=self._json_encode(getattr(domain_event, 'metadata', None)),
            module_name=domain_event_class.__module__,
            class_name=domain_event_class.__qualname__,
            # have to have stored_entity_id because of the lib
            stored_entity_id=make_stored_entity_id(id_prefix_from_event(domain_event), domain_event.entity_id),
        )

    def deserialize(self, stored_event):
        """
        Recreates original domain event from stored event topic and event attrs.
        """
        assert isinstance(stored_event, UnifiedStoredEvent)
        # Get the domain event class from the topic.
        domain_event_class = self._get_domain_event_class(stored_event.module_name, stored_event.class_name)

        # Deserialize event attributes from JSON
        event_attrs = self._json_decode(stored_event.event_data)

        # Reinstantiate and return the domain event object.
        defaults = {
            'entity_id': stored_event.aggregate_id,
            'entity_version': stored_event.aggregate_version,
            'domain_event_id': stored_event.event_id,
        }


        if adds_schema_version_to_event_data():