Skip to content

Commit

Permalink
Limit exports to necessary APIs and elements only
Browse files Browse the repository at this point in the history
  • Loading branch information
subhashb committed Jul 25, 2024
1 parent 1c80cdf commit 3b4face
Show file tree
Hide file tree
Showing 211 changed files with 541 additions and 353 deletions.
3 changes: 2 additions & 1 deletion docs/guides/domain-definition/value-objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,11 @@ are not applicable to Value Objects.
For example, trying to mark a Value Object field with `unique = True` or
`identifier = True` will throw a `IncorrectUsageError` exception.

<!-- FIXME Remove usage of `BaseValueObject` in the below code snippet -->
```shell
In [1]: from protean.fields import Float, String

In [2]: from protean import BaseValueObject
In [2]: from protean.core.value_object import BaseValueObject

In [3]: class Balance(BaseValueObject):
...: currency = String(max_length=3, unique=True)
Expand Down
30 changes: 2 additions & 28 deletions src/protean/__init__.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,18 @@
__version__ = "0.12.1"

from .core.aggregate import BaseAggregate, apply, atomic_change
from .core.application_service import BaseApplicationService
from .core.command import BaseCommand
from .core.command_handler import BaseCommandHandler
from .core.domain_service import BaseDomainService
from .core.email import BaseEmail
from .core.entity import BaseEntity, invariant
from .core.event import BaseEvent
from .core.event_handler import BaseEventHandler
from .core.aggregate import apply, atomic_change
from .core.entity import invariant
from .core.model import BaseModel
from .core.queryset import Q, QuerySet
from .core.repository import BaseRepository
from .core.serializer import BaseSerializer
from .core.subscriber import BaseSubscriber
from .core.unit_of_work import UnitOfWork
from .core.value_object import BaseValueObject
from .core.view import BaseView
from .domain import Domain
from .server import Engine
from .utils import get_version
from .utils.globals import current_domain, current_uow, g
from .utils.mixins import handle

__all__ = [
"BaseAggregate",
"BaseApplicationService",
"BaseCommand",
"BaseCommandHandler",
"BaseDomainService",
"BaseEmail",
"BaseEntity",
"BaseEvent",
"BaseEventHandler",
"BaseModel",
"BaseRepository",
"BaseSerializer",
"BaseSubscriber",
"BaseValueObject",
"BaseView",
"Domain",
"Engine",
"Q",
Expand Down
3 changes: 2 additions & 1 deletion src/protean/adapters/event_store/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
from collections import defaultdict
from typing import TYPE_CHECKING, DefaultDict, List, Optional, Set, Type

from protean import BaseEvent, BaseEventHandler
from protean.core.command import BaseCommand
from protean.core.command_handler import BaseCommandHandler
from protean.core.event import BaseEvent
from protean.core.event_handler import BaseEventHandler
from protean.core.event_sourced_repository import (
BaseEventSourcedRepository,
event_sourced_repository_factory,
Expand Down
2 changes: 1 addition & 1 deletion src/protean/core/domain_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from functools import wraps
from typing import List, Union

from protean import BaseAggregate
from protean.core.aggregate import BaseAggregate
from protean.exceptions import IncorrectUsageError, NotSupportedError, ValidationError
from protean.utils import DomainObjects, derive_element_class
from protean.utils.container import Element, OptionsMixin
Expand Down
3 changes: 2 additions & 1 deletion src/protean/core/event_sourced_repository.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging

from protean import BaseAggregate, UnitOfWork
from protean.core.aggregate import BaseAggregate
from protean.core.unit_of_work import UnitOfWork
from protean.exceptions import (
IncorrectUsageError,
NotSupportedError,
Expand Down
4 changes: 3 additions & 1 deletion src/protean/port/event_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
from collections import deque
from typing import Any, Dict, List, Optional, Type, Union

from protean import BaseAggregate, BaseCommand, BaseEvent
from protean.core.aggregate import BaseAggregate
from protean.core.command import BaseCommand
from protean.core.event import BaseEvent
from protean.fields import Identifier
from protean.utils.mixins import Message

Expand Down
3 changes: 2 additions & 1 deletion src/protean/server/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import logging
from typing import List, Union

from protean import BaseCommandHandler, BaseEventHandler
from protean.core.command_handler import BaseCommandHandler
from protean.core.event_handler import BaseEventHandler
from protean.port.event_store import BaseEventStore
from protean.utils.mixins import Message, MessageType

Expand Down
4 changes: 3 additions & 1 deletion tests/adapters/broker/celery_broker/elements.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from protean import BaseAggregate, BaseEvent, BaseSubscriber
from protean.core.aggregate import BaseAggregate
from protean.core.event import BaseEvent
from protean.core.subscriber import BaseSubscriber
from protean.fields import Auto, Integer, String
from protean.utils.globals import current_domain

Expand Down
4 changes: 3 additions & 1 deletion tests/adapters/broker/redis_broker/elements.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from protean import BaseAggregate, BaseEvent, BaseSubscriber
from protean.core.aggregate import BaseAggregate
from protean.core.event import BaseEvent
from protean.core.subscriber import BaseSubscriber
from protean.fields import Auto, Integer, String
from protean.utils.globals import current_domain

Expand Down
2 changes: 1 addition & 1 deletion tests/adapters/cache/redis_cache/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import pytest
from redis import Redis

from protean import BaseView
from protean.adapters.cache.redis import RedisCache
from protean.core.view import BaseView
from protean.fields import Identifier, String


Expand Down
5 changes: 4 additions & 1 deletion tests/adapters/email/sendgrid_email/elements.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from protean import BaseAggregate, BaseEmail, BaseEvent, BaseSubscriber
from protean.core.aggregate import BaseAggregate
from protean.core.email import BaseEmail
from protean.core.event import BaseEvent
from protean.core.subscriber import BaseSubscriber
from protean.exceptions import InsufficientDataError, InvalidDataError
from protean.fields import Integer, String
from protean.utils.globals import current_domain
Expand Down
6 changes: 5 additions & 1 deletion tests/adapters/model/dict_model/elements.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import re
from typing import List

from protean import BaseAggregate, BaseModel, BaseRepository, BaseValueObject, invariant
from protean.core.aggregate import BaseAggregate
from protean.core.entity import invariant
from protean.core.model import BaseModel
from protean.core.repository import BaseRepository
from protean.core.value_object import BaseValueObject
from protean.exceptions import ValidationError
from protean.fields import Integer, String, Text, ValueObject
from protean.utils.globals import current_domain
Expand Down
4 changes: 3 additions & 1 deletion tests/adapters/model/elasticsearch_model/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

from elasticsearch_dsl import Keyword, Text

from protean import BaseAggregate, BaseValueObject, invariant
from protean.core.aggregate import BaseAggregate
from protean.core.entity import invariant
from protean.core.model import BaseModel
from protean.core.value_object import BaseValueObject
from protean.exceptions import ValidationError
from protean.fields import DateTime, Integer, String, ValueObject
from protean.fields import Text as ProteanText
Expand Down
2 changes: 1 addition & 1 deletion tests/adapters/model/elasticsearch_model/tests.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest
from elasticsearch_dsl import Keyword, Text

from protean import BaseAggregate
from protean.adapters.repository.elasticsearch import ElasticsearchModel
from protean.core.aggregate import BaseAggregate
from protean.fields import String

from .elements import (
Expand Down
5 changes: 4 additions & 1 deletion tests/adapters/model/sqlalchemy_model/postgresql/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

from sqlalchemy import Column, Text

from protean import BaseAggregate, BaseModel, BaseValueObject, invariant
from protean.core.aggregate import BaseAggregate
from protean.core.entity import invariant
from protean.core.model import BaseModel
from protean.core.value_object import BaseValueObject
from protean.exceptions import ValidationError
from protean.fields import DateTime, Integer, List, String, ValueObject

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest
from sqlalchemy import types as sa_types

from protean import BaseAggregate
from protean.core.aggregate import BaseAggregate
from protean.exceptions import ValidationError
from protean.fields import (
Auto,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from sqlalchemy import types as sa_types

from protean import BaseAggregate
from protean.core.aggregate import BaseAggregate
from protean.fields import DateTime, Dict, String
from protean.utils import utcnow_func
from protean.utils.globals import current_domain
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from protean import BaseAggregate
from protean.adapters.repository.sqlalchemy import Any, Contains, In, Overlap
from protean.core.aggregate import BaseAggregate
from protean.fields import List, String


Expand Down
5 changes: 4 additions & 1 deletion tests/adapters/model/sqlalchemy_model/sqlite/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

from sqlalchemy import Column, Text

from protean import BaseAggregate, BaseModel, BaseValueObject, invariant
from protean.core.aggregate import BaseAggregate
from protean.core.entity import invariant
from protean.core.model import BaseModel
from protean.core.value_object import BaseValueObject
from protean.exceptions import ValidationError
from protean.fields import DateTime, Integer, String, ValueObject

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest
from sqlalchemy import types as sa_types

from protean import BaseAggregate
from protean.core.aggregate import BaseAggregate
from protean.exceptions import ValidationError
from protean.fields import (
Auto,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from sqlalchemy import types as sa_types

from protean import BaseAggregate
from protean.core.aggregate import BaseAggregate
from protean.fields import DateTime, Dict, String
from protean.utils import utcnow_func

Expand Down
5 changes: 4 additions & 1 deletion tests/adapters/repository/elasticsearch_repo/elements.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import re
from datetime import datetime

from protean import BaseAggregate, BaseRepository, BaseValueObject, invariant
from protean.core.aggregate import BaseAggregate
from protean.core.entity import invariant
from protean.core.repository import BaseRepository
from protean.core.value_object import BaseValueObject
from protean.exceptions import ValidationError
from protean.fields import DateTime, Integer, String, ValueObject

Expand Down
2 changes: 1 addition & 1 deletion tests/adapters/repository/memory/test_any_operator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from protean import BaseAggregate
from protean.core.aggregate import BaseAggregate
from protean.fields import List
from protean.utils.globals import current_domain

Expand Down
2 changes: 1 addition & 1 deletion tests/adapters/repository/memory/test_in_operator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from protean import BaseAggregate
from protean.core.aggregate import BaseAggregate
from protean.fields.basic import String
from protean.utils.globals import current_domain

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime

from protean import BaseAggregate
from protean.core.aggregate import BaseAggregate
from protean.fields import Date, Integer, String
from protean.utils.globals import current_domain

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import re
from datetime import datetime

from protean import BaseAggregate, BaseRepository, BaseValueObject, invariant
from protean.core.aggregate import BaseAggregate
from protean.core.entity import invariant
from protean.core.repository import BaseRepository
from protean.core.value_object import BaseValueObject
from protean.exceptions import ValidationError
from protean.fields import DateTime, Integer, String, ValueObject

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import pytest

from protean import BaseAggregate, BaseEntity, BaseValueObject, UnitOfWork
from protean.core.aggregate import BaseAggregate
from protean.core.entity import BaseEntity
from protean.core.unit_of_work import UnitOfWork
from protean.core.value_object import BaseValueObject
from protean.fields import DateTime, Dict, HasMany, Reference, Text, ValueObject


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from protean import BaseAggregate
from protean.core.aggregate import BaseAggregate
from protean.fields import DateTime, Dict, String


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import pytest

from protean import BaseAggregate, BaseEntity, BaseValueObject
from protean.core.aggregate import BaseAggregate
from protean.core.entity import BaseEntity
from protean.core.value_object import BaseValueObject
from protean.fields import HasOne, List, String, ValueObject


Expand Down
5 changes: 4 additions & 1 deletion tests/adapters/repository/sqlalchemy_repo/sqlite/elements.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import re
from datetime import datetime

from protean import BaseAggregate, BaseRepository, BaseValueObject, invariant
from protean.core.aggregate import BaseAggregate
from protean.core.entity import invariant
from protean.core.repository import BaseRepository
from protean.core.value_object import BaseValueObject
from protean.exceptions import ValidationError
from protean.fields import DateTime, Integer, String, ValueObject

Expand Down
4 changes: 3 additions & 1 deletion tests/adapters/repository/test_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import pytest

from protean import BaseAggregate, Q, QuerySet
from protean.core.aggregate import BaseAggregate
from protean.core.queryset import QuerySet
from protean.exceptions import ObjectNotFoundError, TooManyObjectsError, ValidationError
from protean.fields import DateTime, Integer, String
from protean.utils.query import Q


class Person(BaseAggregate):
Expand Down
12 changes: 5 additions & 7 deletions tests/adapters/repository/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@

import pytest

from protean import (
BaseAggregate,
BaseRepository,
BaseValueObject,
UnitOfWork,
invariant,
)
from protean.core.aggregate import BaseAggregate
from protean.core.entity import invariant
from protean.core.repository import BaseRepository
from protean.core.unit_of_work import UnitOfWork
from protean.core.value_object import BaseValueObject
from protean.exceptions import ExpectedVersionError, ValidationError
from protean.fields import Integer, String, ValueObject
from protean.utils.globals import current_domain
Expand Down
3 changes: 2 additions & 1 deletion tests/aggregate/aggregate_elements.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import datetime

from protean import BaseAggregate, BaseEntity
from protean.core.aggregate import BaseAggregate
from protean.core.entity import BaseEntity
from protean.fields import DateTime, HasMany, HasOne, Integer, Reference, String, Text


Expand Down
3 changes: 2 additions & 1 deletion tests/aggregate/aggregate_elements_with_value_objects.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from enum import Enum

from protean import BaseAggregate, BaseValueObject
from protean.core.aggregate import BaseAggregate
from protean.core.value_object import BaseValueObject
from protean.fields import String, ValueObject


Expand Down
4 changes: 3 additions & 1 deletion tests/aggregate/elements.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from datetime import datetime
from typing import List

from protean import BaseAggregate, BaseEntity, BaseRepository
from protean.core.aggregate import BaseAggregate
from protean.core.entity import BaseEntity
from protean.core.repository import BaseRepository
from protean.fields import (
Auto,
DateTime,
Expand Down
Loading

0 comments on commit 3b4face

Please sign in to comment.