maleo-foundation 0.3.46__py3-none-any.whl → 0.3.48__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. maleo_foundation/authentication.py +24 -13
  2. maleo_foundation/authorization.py +2 -1
  3. maleo_foundation/client/manager.py +22 -21
  4. maleo_foundation/client/services/__init__.py +16 -7
  5. maleo_foundation/client/services/encryption/__init__.py +13 -4
  6. maleo_foundation/client/services/encryption/aes.py +41 -36
  7. maleo_foundation/client/services/encryption/rsa.py +50 -50
  8. maleo_foundation/client/services/hash/__init__.py +19 -6
  9. maleo_foundation/client/services/hash/bcrypt.py +20 -18
  10. maleo_foundation/client/services/hash/hmac.py +20 -17
  11. maleo_foundation/client/services/hash/sha256.py +18 -15
  12. maleo_foundation/client/services/key.py +50 -42
  13. maleo_foundation/client/services/signature.py +46 -42
  14. maleo_foundation/client/services/token.py +49 -58
  15. maleo_foundation/constants.py +12 -19
  16. maleo_foundation/enums.py +14 -13
  17. maleo_foundation/expanded_types/__init__.py +2 -3
  18. maleo_foundation/expanded_types/client.py +30 -34
  19. maleo_foundation/expanded_types/encryption/__init__.py +2 -1
  20. maleo_foundation/expanded_types/encryption/aes.py +7 -5
  21. maleo_foundation/expanded_types/encryption/rsa.py +7 -5
  22. maleo_foundation/expanded_types/general.py +13 -11
  23. maleo_foundation/expanded_types/hash.py +7 -5
  24. maleo_foundation/expanded_types/key.py +8 -6
  25. maleo_foundation/expanded_types/service.py +30 -34
  26. maleo_foundation/expanded_types/signature.py +7 -5
  27. maleo_foundation/expanded_types/token.py +7 -5
  28. maleo_foundation/extended_types.py +4 -3
  29. maleo_foundation/managers/cache.py +2 -1
  30. maleo_foundation/managers/client/base.py +25 -12
  31. maleo_foundation/managers/client/google/base.py +11 -4
  32. maleo_foundation/managers/client/google/parameter.py +9 -11
  33. maleo_foundation/managers/client/google/secret.py +53 -35
  34. maleo_foundation/managers/client/google/storage.py +52 -22
  35. maleo_foundation/managers/client/google/subscription.py +37 -39
  36. maleo_foundation/managers/client/maleo.py +18 -23
  37. maleo_foundation/managers/configuration.py +5 -9
  38. maleo_foundation/managers/credential.py +14 -17
  39. maleo_foundation/managers/db.py +51 -40
  40. maleo_foundation/managers/middleware.py +9 -9
  41. maleo_foundation/managers/service.py +47 -54
  42. maleo_foundation/middlewares/authentication.py +29 -54
  43. maleo_foundation/middlewares/base.py +83 -72
  44. maleo_foundation/middlewares/cors.py +8 -7
  45. maleo_foundation/models/__init__.py +2 -1
  46. maleo_foundation/models/responses.py +57 -29
  47. maleo_foundation/models/schemas/__init__.py +2 -1
  48. maleo_foundation/models/schemas/encryption.py +5 -2
  49. maleo_foundation/models/schemas/general.py +38 -18
  50. maleo_foundation/models/schemas/hash.py +2 -1
  51. maleo_foundation/models/schemas/key.py +5 -2
  52. maleo_foundation/models/schemas/parameter.py +45 -15
  53. maleo_foundation/models/schemas/result.py +35 -20
  54. maleo_foundation/models/schemas/signature.py +5 -2
  55. maleo_foundation/models/schemas/token.py +5 -2
  56. maleo_foundation/models/table.py +33 -27
  57. maleo_foundation/models/transfers/__init__.py +2 -1
  58. maleo_foundation/models/transfers/general/__init__.py +2 -1
  59. maleo_foundation/models/transfers/general/configurations/__init__.py +10 -4
  60. maleo_foundation/models/transfers/general/configurations/cache/__init__.py +3 -2
  61. maleo_foundation/models/transfers/general/configurations/cache/redis.py +13 -5
  62. maleo_foundation/models/transfers/general/configurations/client/__init__.py +5 -1
  63. maleo_foundation/models/transfers/general/configurations/client/maleo.py +38 -12
  64. maleo_foundation/models/transfers/general/configurations/database.py +5 -2
  65. maleo_foundation/models/transfers/general/configurations/middleware.py +22 -15
  66. maleo_foundation/models/transfers/general/configurations/service.py +2 -1
  67. maleo_foundation/models/transfers/general/credentials.py +2 -1
  68. maleo_foundation/models/transfers/general/database.py +11 -4
  69. maleo_foundation/models/transfers/general/key.py +13 -4
  70. maleo_foundation/models/transfers/general/request.py +28 -9
  71. maleo_foundation/models/transfers/general/settings.py +12 -22
  72. maleo_foundation/models/transfers/general/signature.py +4 -2
  73. maleo_foundation/models/transfers/general/token.py +34 -27
  74. maleo_foundation/models/transfers/parameters/__init__.py +2 -1
  75. maleo_foundation/models/transfers/parameters/client.py +15 -19
  76. maleo_foundation/models/transfers/parameters/encryption/__init__.py +2 -1
  77. maleo_foundation/models/transfers/parameters/encryption/aes.py +7 -5
  78. maleo_foundation/models/transfers/parameters/encryption/rsa.py +7 -5
  79. maleo_foundation/models/transfers/parameters/general.py +15 -13
  80. maleo_foundation/models/transfers/parameters/hash/__init__.py +2 -1
  81. maleo_foundation/models/transfers/parameters/hash/bcrypt.py +5 -5
  82. maleo_foundation/models/transfers/parameters/hash/hmac.py +6 -6
  83. maleo_foundation/models/transfers/parameters/hash/sha256.py +5 -5
  84. maleo_foundation/models/transfers/parameters/key.py +9 -8
  85. maleo_foundation/models/transfers/parameters/service.py +42 -48
  86. maleo_foundation/models/transfers/parameters/signature.py +7 -4
  87. maleo_foundation/models/transfers/parameters/token.py +10 -10
  88. maleo_foundation/models/transfers/results/__init__.py +2 -1
  89. maleo_foundation/models/transfers/results/client/__init__.py +2 -1
  90. maleo_foundation/models/transfers/results/client/controllers/__init__.py +2 -1
  91. maleo_foundation/models/transfers/results/client/controllers/http.py +10 -7
  92. maleo_foundation/models/transfers/results/client/service.py +12 -6
  93. maleo_foundation/models/transfers/results/encryption/__init__.py +2 -1
  94. maleo_foundation/models/transfers/results/encryption/aes.py +13 -5
  95. maleo_foundation/models/transfers/results/encryption/rsa.py +12 -4
  96. maleo_foundation/models/transfers/results/hash.py +7 -3
  97. maleo_foundation/models/transfers/results/key.py +18 -6
  98. maleo_foundation/models/transfers/results/service/__init__.py +2 -3
  99. maleo_foundation/models/transfers/results/service/controllers/__init__.py +2 -1
  100. maleo_foundation/models/transfers/results/service/controllers/rest.py +14 -11
  101. maleo_foundation/models/transfers/results/service/general.py +16 -10
  102. maleo_foundation/models/transfers/results/signature.py +12 -4
  103. maleo_foundation/models/transfers/results/token.py +10 -4
  104. maleo_foundation/rest_controller_result.py +23 -21
  105. maleo_foundation/types.py +15 -14
  106. maleo_foundation/utils/__init__.py +2 -1
  107. maleo_foundation/utils/cache.py +10 -13
  108. maleo_foundation/utils/client.py +25 -12
  109. maleo_foundation/utils/controller.py +59 -37
  110. maleo_foundation/utils/dependencies/__init__.py +2 -1
  111. maleo_foundation/utils/dependencies/auth.py +5 -12
  112. maleo_foundation/utils/dependencies/context.py +3 -4
  113. maleo_foundation/utils/exceptions.py +50 -28
  114. maleo_foundation/utils/extractor.py +18 -6
  115. maleo_foundation/utils/formatter/__init__.py +2 -1
  116. maleo_foundation/utils/formatter/case.py +5 -4
  117. maleo_foundation/utils/loaders/__init__.py +2 -1
  118. maleo_foundation/utils/loaders/credential/__init__.py +2 -1
  119. maleo_foundation/utils/loaders/credential/google.py +29 -15
  120. maleo_foundation/utils/loaders/json.py +3 -2
  121. maleo_foundation/utils/loaders/key/__init__.py +2 -1
  122. maleo_foundation/utils/loaders/key/rsa.py +26 -13
  123. maleo_foundation/utils/loaders/yaml.py +2 -1
  124. maleo_foundation/utils/logging.py +70 -46
  125. maleo_foundation/utils/merger.py +7 -9
  126. maleo_foundation/utils/query.py +41 -34
  127. maleo_foundation/utils/repository.py +29 -16
  128. maleo_foundation/utils/searcher.py +4 -6
  129. {maleo_foundation-0.3.46.dist-info → maleo_foundation-0.3.48.dist-info}/METADATA +14 -1
  130. maleo_foundation-0.3.48.dist-info/RECORD +137 -0
  131. maleo_foundation/expanded_types/repository.py +0 -68
  132. maleo_foundation/models/transfers/results/service/repository.py +0 -39
  133. maleo_foundation-0.3.46.dist-info/RECORD +0 -139
  134. {maleo_foundation-0.3.46.dist-info → maleo_foundation-0.3.48.dist-info}/WHEEL +0 -0
  135. {maleo_foundation-0.3.46.dist-info → maleo_foundation-0.3.48.dist-info}/top_level.txt +0 -0
@@ -1,72 +1,78 @@
1
1
  from sqlalchemy import Column, Integer, UUID, TIMESTAMP, Enum, func
2
- from sqlalchemy.orm import declared_attr
2
+ from sqlalchemy.orm import declared_attr, DeclarativeBase
3
3
  from uuid import uuid4
4
4
  from maleo_foundation.enums import BaseEnums
5
5
  from maleo_foundation.utils.formatter.case import CaseFormatter
6
6
 
7
- class BaseTable:
7
+
8
+ class Base(DeclarativeBase):
9
+ """Base class for all SQLAlchemy models in the application.
10
+
11
+ This class provides a common base for all models, including
12
+ automatic table name generation and common data fields.
13
+ """
14
+
15
+ pass
16
+
17
+
18
+ class BaseTable(Base):
8
19
  __abstract__ = True
9
20
 
10
- @declared_attr
21
+ @declared_attr.directive
11
22
  def __tablename__(cls) -> str:
12
23
  return CaseFormatter.to_snake_case(cls.__name__)
13
24
 
25
+
14
26
  class DataMixin:
15
- #* Timestamps
27
+ # * Timestamps
16
28
  created_at = Column(
17
- TIMESTAMP(timezone=True),
18
- server_default=func.now(),
19
- nullable=False
29
+ TIMESTAMP(timezone=True), server_default=func.now(), nullable=False
20
30
  )
21
31
  updated_at = Column(
22
32
  TIMESTAMP(timezone=True),
23
33
  server_default=func.now(),
24
34
  onupdate=func.now(),
25
- nullable=False
35
+ nullable=False,
26
36
  )
27
37
  deleted_at = Column(TIMESTAMP(timezone=True))
28
38
  restored_at = Column(TIMESTAMP(timezone=True))
29
39
  deactivated_at = Column(TIMESTAMP(timezone=True))
30
40
  activated_at = Column(
31
- TIMESTAMP(timezone=True),
32
- server_default=func.now(),
33
- nullable=False
41
+ TIMESTAMP(timezone=True), server_default=func.now(), nullable=False
34
42
  )
35
43
 
36
- #* Statuses
44
+ # * Statuses
37
45
  status = Column(
38
46
  Enum(BaseEnums.StatusType, name="statustype"),
39
47
  default=BaseEnums.StatusType.ACTIVE,
40
- nullable=False
48
+ nullable=False,
41
49
  )
42
50
 
51
+
43
52
  class DataIdentifiers:
44
- #* Identifiers
53
+ # * Identifiers
45
54
  id = Column(Integer, primary_key=True)
46
55
  uuid = Column(UUID, default=uuid4, unique=True, nullable=False)
47
56
 
48
- class DataTable(
49
- DataMixin,
50
- DataIdentifiers
51
- ): pass
57
+
58
+ class DataTable(DataMixin, DataIdentifiers):
59
+ pass
60
+
52
61
 
53
62
  class AccessIdentifiers:
54
- #* Identifiers
63
+ # * Identifiers
55
64
  access_id = Column(Integer, primary_key=True)
56
65
  access_uuid = Column(UUID, default=uuid4, unique=True, nullable=False)
57
66
  accessed_at = Column(
58
- TIMESTAMP(timezone=True),
59
- server_default=func.now(),
60
- nullable=False
67
+ TIMESTAMP(timezone=True), server_default=func.now(), nullable=False
61
68
  )
62
69
  accessed_by = Column(Integer, default=0, nullable=False)
63
70
 
71
+
64
72
  class AccessMixin:
65
73
  id = Column(Integer)
66
74
  uuid = Column(UUID)
67
75
 
68
- class AccessTable(
69
- DataMixin,
70
- AccessMixin,
71
- AccessIdentifiers
72
- ): pass
76
+
77
+ class AccessTable(DataMixin, AccessMixin, AccessIdentifiers):
78
+ pass
@@ -3,7 +3,8 @@ from .general import BaseGeneralTransfers
3
3
  from .parameters import BaseParametersTransfers
4
4
  from .results import BaseResultsTransfers
5
5
 
6
+
6
7
  class BaseTransfers:
7
8
  General = BaseGeneralTransfers
8
9
  Parameters = BaseParametersTransfers
9
- Results = BaseResultsTransfers
10
+ Results = BaseResultsTransfers
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
  from .token import MaleoFoundationTokenGeneralTransfers
3
3
 
4
+
4
5
  class BaseGeneralTransfers:
5
- Token = MaleoFoundationTokenGeneralTransfers
6
+ Token = MaleoFoundationTokenGeneralTransfers
@@ -5,7 +5,7 @@ from maleo_foundation.utils.logging import (
5
5
  DatabaseLogger,
6
6
  MiddlewareLogger,
7
7
  RepositoryLogger,
8
- ServiceLogger
8
+ ServiceLogger,
9
9
  )
10
10
  from .cache import CacheConfigurations
11
11
  from .client import ClientConfigurations
@@ -13,15 +13,21 @@ from .database import DatabaseConfigurations
13
13
  from .middleware import MiddlewareConfigurations
14
14
  from .service import ServiceConfigurations
15
15
 
16
+
16
17
  class Configurations(BaseModel):
17
18
  model_config = ConfigDict(arbitrary_types_allowed=True)
18
19
 
19
20
  cache: CacheConfigurations = Field(..., description="Cache's configurations")
20
21
  client: ClientConfigurations = Field(..., description="Client's configurations")
21
- database: DatabaseConfigurations = Field(..., description="Database's configurations")
22
- middleware: MiddlewareConfigurations = Field(..., description="Middleware's configurations")
22
+ database: DatabaseConfigurations = Field(
23
+ ..., description="Database's configurations"
24
+ )
25
+ middleware: MiddlewareConfigurations = Field(
26
+ ..., description="Middleware's configurations"
27
+ )
23
28
  service: ServiceConfigurations = Field(..., description="Service's configurations")
24
29
 
30
+
25
31
  class Loggers(BaseModel):
26
32
  model_config = ConfigDict(arbitrary_types_allowed=True)
27
33
 
@@ -30,4 +36,4 @@ class Loggers(BaseModel):
30
36
  database: DatabaseLogger = Field(..., description="Database logger")
31
37
  middleware: MiddlewareLogger = Field(..., description="Middleware logger")
32
38
  repository: RepositoryLogger = Field(..., description="Repository logger")
33
- service: ServiceLogger = Field(..., description="Service logger")
39
+ service: ServiceLogger = Field(..., description="Service logger")
@@ -2,7 +2,8 @@ from __future__ import annotations
2
2
  from pydantic import BaseModel, Field
3
3
  from .redis import RedisCacheConfigurations
4
4
 
5
- SKIP_CACHE_FUNC = lambda x: x is None
6
5
 
7
6
  class CacheConfigurations(BaseModel):
8
- redis:RedisCacheConfigurations = Field(..., description="Redis cache's configurations")
7
+ redis: RedisCacheConfigurations = Field(
8
+ ..., description="Redis cache's configurations"
9
+ )
@@ -3,6 +3,7 @@ from typing import Union
3
3
  from maleo_foundation.types import BaseTypes
4
4
  from maleo_foundation.enums import BaseEnums
5
5
 
6
+
6
7
  class RedisCacheNamespaces(BaseModel):
7
8
  base: str = Field(..., description="Base's redis namespace")
8
9
 
@@ -10,16 +11,23 @@ class RedisCacheNamespaces(BaseModel):
10
11
  self,
11
12
  *ext: str,
12
13
  layer: BaseEnums.CacheLayer,
13
- base_override: BaseTypes.OptionalString = None
14
+ base_override: BaseTypes.OptionalString = None,
14
15
  ) -> str:
15
- return ":".join([self.base if base_override is None else base_override, layer, *ext])
16
+ return ":".join(
17
+ [self.base if base_override is None else base_override, layer, *ext]
18
+ )
19
+
16
20
 
17
21
  class RedisCacheConfigurations(BaseModel):
18
- ttl: Union[int, float] = Field(BaseEnums.Expiration.EXP_5MN, description="Default TTL")
19
- namespaces: RedisCacheNamespaces = Field(..., description="Redis cache's namepsaces")
22
+ ttl: Union[int, float] = Field(
23
+ BaseEnums.Expiration.EXP_5MN, description="Default TTL"
24
+ )
25
+ namespaces: RedisCacheNamespaces = Field(
26
+ ..., description="Redis cache's namepsaces"
27
+ )
20
28
  host: str = Field(..., description="Redis instance's host")
21
29
  port: int = Field(6379, description="Redis instance's port")
22
30
  db: int = Field(0, description="Redis instance's db")
23
31
  password: BaseTypes.OptionalString = Field(None, description="AUTH password")
24
32
  decode_responses: bool = Field(True, description="Whether to decode responses")
25
- health_check_interval: int = Field(30, description="Health check interval")
33
+ health_check_interval: int = Field(30, description="Health check interval")
@@ -1,7 +1,11 @@
1
1
  from pydantic import BaseModel, ConfigDict, Field
2
2
  from .maleo import MaleoClientsConfigurations
3
3
 
4
+
4
5
  class ClientConfigurations(BaseModel):
5
6
  model_config = ConfigDict(arbitrary_types_allowed=True)
6
7
 
7
- maleo: MaleoClientsConfigurations = Field(default_factory=MaleoClientsConfigurations, description="Maleo client's configurations")
8
+ maleo: MaleoClientsConfigurations = Field(
9
+ default_factory=MaleoClientsConfigurations,
10
+ description="Maleo client's configurations",
11
+ )
@@ -1,23 +1,49 @@
1
1
  from pydantic import BaseModel, ConfigDict, Field
2
2
  from typing import Optional
3
3
 
4
+
4
5
  class MaleoClientConfigurations(BaseModel):
5
6
  key: str = Field(..., description="Client's key")
6
7
  name: str = Field(..., description="Client's name")
7
8
  url: str = Field(..., description="Client's URL")
8
9
 
10
+
9
11
  class MaleoClientsConfigurations(BaseModel):
10
12
  model_config = ConfigDict(arbitrary_types_allowed=True)
11
13
 
12
- telemetry: Optional[MaleoClientConfigurations] = Field(None, description="MaleoTelemetry client's configuration")
13
- metadata: Optional[MaleoClientConfigurations] = Field(None, description="MaleoMetadata client's configuration")
14
- identity: Optional[MaleoClientConfigurations] = Field(None, description="MaleoIdentity client's configuration")
15
- access: Optional[MaleoClientConfigurations] = Field(None, description="MaleoAccess client's configuration")
16
- workshop: Optional[MaleoClientConfigurations] = Field(None, description="MaleoWorkshop client's configuration")
17
- soapie: Optional[MaleoClientConfigurations] = Field(None, description="MaleoSOAPIE client's configuration")
18
- medix: Optional[MaleoClientConfigurations] = Field(None, description="MaleoMedix client's configuration")
19
- dicom: Optional[MaleoClientConfigurations] = Field(None, description="MaleoDICOM client's configuration")
20
- scribe: Optional[MaleoClientConfigurations] = Field(None, description="MaleoScribe client's configuration")
21
- cds: Optional[MaleoClientConfigurations] = Field(None, description="MaleoCDS client's configuration")
22
- imaging: Optional[MaleoClientConfigurations] = Field(None, description="MaleoImaging client's configuration")
23
- mcu: Optional[MaleoClientConfigurations] = Field(None, description="MaleoMCU client's configuration")
14
+ telemetry: Optional[MaleoClientConfigurations] = Field(
15
+ None, description="MaleoTelemetry client's configuration"
16
+ )
17
+ metadata: Optional[MaleoClientConfigurations] = Field(
18
+ None, description="MaleoMetadata client's configuration"
19
+ )
20
+ identity: Optional[MaleoClientConfigurations] = Field(
21
+ None, description="MaleoIdentity client's configuration"
22
+ )
23
+ access: Optional[MaleoClientConfigurations] = Field(
24
+ None, description="MaleoAccess client's configuration"
25
+ )
26
+ workshop: Optional[MaleoClientConfigurations] = Field(
27
+ None, description="MaleoWorkshop client's configuration"
28
+ )
29
+ soapie: Optional[MaleoClientConfigurations] = Field(
30
+ None, description="MaleoSOAPIE client's configuration"
31
+ )
32
+ medix: Optional[MaleoClientConfigurations] = Field(
33
+ None, description="MaleoMedix client's configuration"
34
+ )
35
+ dicom: Optional[MaleoClientConfigurations] = Field(
36
+ None, description="MaleoDICOM client's configuration"
37
+ )
38
+ scribe: Optional[MaleoClientConfigurations] = Field(
39
+ None, description="MaleoScribe client's configuration"
40
+ )
41
+ cds: Optional[MaleoClientConfigurations] = Field(
42
+ None, description="MaleoCDS client's configuration"
43
+ )
44
+ imaging: Optional[MaleoClientConfigurations] = Field(
45
+ None, description="MaleoImaging client's configuration"
46
+ )
47
+ mcu: Optional[MaleoClientConfigurations] = Field(
48
+ None, description="MaleoMCU client's configuration"
49
+ )
@@ -1,8 +1,11 @@
1
1
  from pydantic import BaseModel, Field
2
2
  from maleo_foundation.enums import BaseEnums
3
3
 
4
+
4
5
  class DatabaseConfigurations(BaseModel):
5
- environment: BaseEnums.EnvironmentType = Field(..., description="Database's environment")
6
+ environment: BaseEnums.EnvironmentType = Field(
7
+ ..., description="Database's environment"
8
+ )
6
9
  username: str = Field("postgres", description="Database user's username")
7
10
  password: str = Field(..., description="Database user's password")
8
11
  host: str = Field(..., description="Database's host")
@@ -11,4 +14,4 @@ class DatabaseConfigurations(BaseModel):
11
14
 
12
15
  @property
13
16
  def url(self) -> str:
14
- return f"postgresql://{self.username}:{self.password}@{self.host}:{self.port}/{self.database}"
17
+ return f"postgresql://{self.username}:{self.password}@{self.host}:{self.port}/{self.database}"
@@ -1,20 +1,13 @@
1
1
  from pydantic import BaseModel, Field
2
2
  from typing import List
3
3
 
4
- _ALLOW_METHODS: List[str] = [
5
- "GET",
6
- "POST",
7
- "PUT",
8
- "PATCH",
9
- "DELETE",
10
- "OPTIONS"
11
- ]
4
+ _ALLOW_METHODS: List[str] = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"]
12
5
  _ALLOW_HEADERS: List[str] = [
13
6
  "Authorization",
14
7
  "Content-Type",
15
8
  "X-Request-Id",
16
9
  "X-Requested-At",
17
- "X-Signature"
10
+ "X-Signature",
18
11
  ]
19
12
  _EXPOSE_HEADERS: List[str] = [
20
13
  "X-New-Authorization",
@@ -22,25 +15,39 @@ _EXPOSE_HEADERS: List[str] = [
22
15
  "X-Request-Id",
23
16
  "X-Requested-At",
24
17
  "X-Responded-At",
25
- "X-Signature"
18
+ "X-Signature",
26
19
  ]
27
20
 
21
+
28
22
  class GeneralMiddlewareConfigurations(BaseModel):
29
- allow_origins: List[str] = Field(default_factory=list, description="Allowed origins")
23
+ allow_origins: List[str] = Field(
24
+ default_factory=list, description="Allowed origins"
25
+ )
30
26
  allow_methods: List[str] = Field(_ALLOW_METHODS, description="Allowed methods")
31
27
  allow_headers: list[str] = Field(_ALLOW_HEADERS, description="Allowed headers")
32
28
  allow_credentials: bool = Field(True, description="Allowed credentials")
33
29
 
30
+
34
31
  class CORSMiddlewareConfigurations(BaseModel):
35
32
  expose_headers: List[str] = Field(_EXPOSE_HEADERS, description="Exposed headers")
36
33
 
34
+
37
35
  class BaseMiddlewareConfigurations(BaseModel):
38
36
  limit: int = Field(10, description="Request limit (per 'window' seconds)")
39
37
  window: int = Field(1, description="Request limit window (seconds)")
40
- cleanup_interval: int = Field(60, description="Interval for middleware cleanup (seconds)")
38
+ cleanup_interval: int = Field(
39
+ 60, description="Interval for middleware cleanup (seconds)"
40
+ )
41
41
  ip_timeout: int = Field(300, description="Idle IP's timeout (seconds)")
42
42
 
43
+
43
44
  class MiddlewareConfigurations(BaseModel):
44
- general: GeneralMiddlewareConfigurations = Field(..., description="Middleware's general configurations")
45
- cors: CORSMiddlewareConfigurations = Field(..., description="CORS middleware's configurations")
46
- base: BaseMiddlewareConfigurations = Field(..., description="Base middleware's configurations")
45
+ general: GeneralMiddlewareConfigurations = Field(
46
+ ..., description="Middleware's general configurations"
47
+ )
48
+ cors: CORSMiddlewareConfigurations = Field(
49
+ ..., description="CORS middleware's configurations"
50
+ )
51
+ base: BaseMiddlewareConfigurations = Field(
52
+ ..., description="Base middleware's configurations"
53
+ )
@@ -1,7 +1,8 @@
1
1
  from pydantic import BaseModel, Field
2
2
 
3
+
3
4
  class ServiceConfigurations(BaseModel):
4
5
  key: str = Field(..., description="Service's key")
5
6
  name: str = Field(..., description="Service's name")
6
7
  host: str = Field(..., description="Service's host")
7
- port: int = Field(..., description="Service's port")
8
+ port: int = Field(..., description="Service's port")
@@ -1,9 +1,10 @@
1
1
  from pydantic import BaseModel, Field
2
2
  from uuid import UUID
3
3
 
4
+
4
5
  class MaleoCredentials(BaseModel):
5
6
  id: int = Field(..., description="ID")
6
7
  uuid: UUID = Field(..., description="UUID")
7
8
  username: str = Field(..., description="Username")
8
9
  email: str = Field(..., description="Email")
9
- password: str = Field(..., description="Password")
10
+ password: str = Field(..., description="Password")
@@ -7,15 +7,22 @@ from .token import MaleoFoundationTokenGeneralTransfers
7
7
  from maleo_foundation.enums import BaseEnums
8
8
  from maleo_foundation.types import BaseTypes
9
9
 
10
+
10
11
  class DatabaseAccess(BaseModel):
11
- accessed_at: datetime = Field(datetime.now(tz=timezone.utc), description="Accessed at timestamp")
12
+ accessed_at: datetime = Field(
13
+ datetime.now(tz=timezone.utc), description="Accessed at timestamp"
14
+ )
12
15
  request_id: UUID = Field(..., description="Request Id")
13
16
  request_context: RequestContext = Field(..., description="Request context")
14
- organization_id: BaseTypes.OptionalInteger = Field(None, ge=1, description="Organization Id")
17
+ organization_id: BaseTypes.OptionalInteger = Field(
18
+ None, ge=1, description="Organization Id"
19
+ )
15
20
  user_id: int = Field(0, ge=0, description="User Id")
16
21
  token_string: BaseTypes.OptionalString = Field(None, description="Token string")
17
- token_payload: Optional[MaleoFoundationTokenGeneralTransfers.DecodePayload] = Field(None, description="Token payload")
22
+ token_payload: Optional[MaleoFoundationTokenGeneralTransfers.DecodePayload] = Field(
23
+ None, description="Token payload"
24
+ )
18
25
  service: BaseEnums.Service = Field(..., description="Service key")
19
26
  table: str = Field(..., description="Table name")
20
27
  data_id: int = Field(..., ge=1, description="Data Id")
21
- data: BaseTypes.StringToAnyDict = Field(..., description="Data")
28
+ data: BaseTypes.StringToAnyDict = Field(..., description="Data")
@@ -3,13 +3,22 @@ from pydantic import BaseModel, Field
3
3
  from maleo_foundation.enums import BaseEnums
4
4
  from maleo_foundation.models.schemas.key import BaseKeySchemas
5
5
 
6
+
6
7
  class MaleoFoundationKeyGeneralTransfers:
7
8
  class PrivateKey(BaseKeySchemas.Key):
8
- type: BaseEnums.KeyType = Field(BaseEnums.KeyType.PRIVATE, description="Private key's type")
9
+ type: BaseEnums.KeyType = Field(
10
+ BaseEnums.KeyType.PRIVATE, description="Private key's type"
11
+ )
9
12
 
10
13
  class PublicKey(BaseKeySchemas.Key):
11
- type: BaseEnums.KeyType = Field(BaseEnums.KeyType.PUBLIC, description="Public key's type")
14
+ type: BaseEnums.KeyType = Field(
15
+ BaseEnums.KeyType.PUBLIC, description="Public key's type"
16
+ )
12
17
 
13
18
  class KeyPair(BaseModel):
14
- private: MaleoFoundationKeyGeneralTransfers.PrivateKey = Field(..., description="Private key's data")
15
- public: MaleoFoundationKeyGeneralTransfers.PublicKey = Field(..., description="Public key's data")
19
+ private: MaleoFoundationKeyGeneralTransfers.PrivateKey = Field(
20
+ ..., description="Private key's data"
21
+ )
22
+ public: MaleoFoundationKeyGeneralTransfers.PublicKey = Field(
23
+ ..., description="Public key's data"
24
+ )
@@ -4,23 +4,42 @@ from pydantic import BaseModel, ConfigDict, Field
4
4
  from uuid import UUID
5
5
  from maleo_foundation.types import BaseTypes
6
6
 
7
+
7
8
  class RequestContext(BaseModel):
8
9
  model_config = ConfigDict(arbitrary_types_allowed=True)
9
10
 
10
- request_id: UUID = Field(..., description="Unique identifier for tracing the request")
11
- requested_at: datetime = Field(datetime.now(tz=timezone.utc), description="Request timestamp")
11
+ request_id: UUID = Field(
12
+ ..., description="Unique identifier for tracing the request"
13
+ )
14
+ requested_at: datetime = Field(
15
+ datetime.now(tz=timezone.utc), description="Request timestamp"
16
+ )
12
17
  method: str = Field(..., description="Request's method")
13
18
  url: str = Field(..., description="Request's URL")
14
- path_params: BaseTypes.OptionalStringToAnyDict = Field(None, description="Request's path parameters")
15
- query_params: BaseTypes.OptionalString = Field(None, description="Request's query parameters")
19
+ path_params: BaseTypes.OptionalStringToAnyDict = Field(
20
+ None, description="Request's path parameters"
21
+ )
22
+ query_params: BaseTypes.OptionalString = Field(
23
+ None, description="Request's query parameters"
24
+ )
16
25
  ip_address: str = Field("unknown", description="Client's IP address")
17
- is_internal: BaseTypes.OptionalBoolean = Field(None, description="True if IP is internal")
26
+ is_internal: BaseTypes.OptionalBoolean = Field(
27
+ None, description="True if IP is internal"
28
+ )
18
29
  user_agent: BaseTypes.OptionalString = Field(None, description="User-Agent string")
19
- ua_browser: BaseTypes.OptionalString = Field(None, description="Browser info from sec-ch-ua")
30
+ ua_browser: BaseTypes.OptionalString = Field(
31
+ None, description="Browser info from sec-ch-ua"
32
+ )
20
33
  ua_mobile: BaseTypes.OptionalString = Field(None, description="Is mobile device?")
21
- platform: BaseTypes.OptionalString = Field(None, description="Client platform or OS")
34
+ platform: BaseTypes.OptionalString = Field(
35
+ None, description="Client platform or OS"
36
+ )
22
37
  referer: BaseTypes.OptionalString = Field(None, description="Referrer URL")
23
38
  origin: BaseTypes.OptionalString = Field(None, description="Origin of the request")
24
39
  host: BaseTypes.OptionalString = Field(None, description="Host header from request")
25
- forwarded_proto: BaseTypes.OptionalString = Field(None, description="Forwarded protocol (http/https)")
26
- language: BaseTypes.OptionalString = Field(None, description="Accepted languages from client")
40
+ forwarded_proto: BaseTypes.OptionalString = Field(
41
+ None, description="Forwarded protocol (http/https)"
42
+ )
43
+ language: BaseTypes.OptionalString = Field(
44
+ None, description="Accepted languages from client"
45
+ )
@@ -4,43 +4,33 @@ from typing import Self
4
4
  from maleo_foundation.enums import BaseEnums
5
5
  from maleo_foundation.types import BaseTypes
6
6
 
7
+
7
8
  class Settings(BaseSettings):
8
9
  ENVIRONMENT: BaseEnums.EnvironmentType = Field(..., description="Environment")
9
10
  SERVICE_KEY: str = Field(..., description="Service's key")
10
11
  ROOT_PATH: str = Field("", description="Application's root path")
11
12
  GOOGLE_CREDENTIALS_PATH: str = Field(
12
13
  "/credentials/maleo-google-service-account.json",
13
- description="Internal credential's file path"
14
+ description="Internal credential's file path",
14
15
  )
15
16
  USE_LOCAL_CONFIGURATIONS: bool = Field(
16
- False,
17
- description="Whether to use local configurations"
17
+ False, description="Whether to use local configurations"
18
18
  )
19
19
  CONFIGURATIONS_PATH: BaseTypes.OptionalString = Field(
20
- None,
21
- description="Configurations path"
22
- )
23
- KEY_PASSWORD: BaseTypes.OptionalString = Field(
24
- None,
25
- description="Key's password"
26
- )
27
- PRIVATE_KEY: BaseTypes.OptionalString = Field(
28
- None,
29
- description="Private key"
30
- )
31
- PUBLIC_KEY: BaseTypes.OptionalString = Field(
32
- None,
33
- description="Public key"
20
+ None, description="Configurations path"
34
21
  )
22
+ KEY_PASSWORD: BaseTypes.OptionalString = Field(None, description="Key's password")
23
+ PRIVATE_KEY: BaseTypes.OptionalString = Field(None, description="Private key")
24
+ PUBLIC_KEY: BaseTypes.OptionalString = Field(None, description="Public key")
35
25
 
36
26
  @model_validator(mode="after")
37
27
  def validate_configurations_path(self) -> Self:
38
28
  if self.USE_LOCAL_CONFIGURATIONS and self.CONFIGURATIONS_PATH is None:
39
- self.CONFIGURATIONS_PATH = (
40
- f"/configurations/{self.SERVICE_KEY}-configurations-{self.ENVIRONMENT}.yaml"
41
- )
29
+ self.CONFIGURATIONS_PATH = f"/configurations/{self.SERVICE_KEY}-configurations-{self.ENVIRONMENT}.yaml"
42
30
 
43
31
  if self.USE_LOCAL_CONFIGURATIONS and self.CONFIGURATIONS_PATH is None:
44
- raise ValueError("Configurations path must exist if use local configurations is set to true")
32
+ raise ValueError(
33
+ "Configurations path must exist if use local configurations is set to true"
34
+ )
45
35
 
46
- return self
36
+ return self
@@ -1,8 +1,10 @@
1
1
  from __future__ import annotations
2
2
  from maleo_foundation.models.schemas.signature import MaleoFoundationSignatureSchemas
3
3
 
4
+
4
5
  class BaseSignatureGeneralTransfers:
5
6
  class SignaturePackage(
6
7
  MaleoFoundationSignatureSchemas.Message,
7
- MaleoFoundationSignatureSchemas.Signature
8
- ): pass
8
+ MaleoFoundationSignatureSchemas.Signature,
9
+ ):
10
+ pass