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.
- maleo_foundation/authentication.py +24 -13
- maleo_foundation/authorization.py +2 -1
- maleo_foundation/client/manager.py +22 -21
- maleo_foundation/client/services/__init__.py +16 -7
- maleo_foundation/client/services/encryption/__init__.py +13 -4
- maleo_foundation/client/services/encryption/aes.py +41 -36
- maleo_foundation/client/services/encryption/rsa.py +50 -50
- maleo_foundation/client/services/hash/__init__.py +19 -6
- maleo_foundation/client/services/hash/bcrypt.py +20 -18
- maleo_foundation/client/services/hash/hmac.py +20 -17
- maleo_foundation/client/services/hash/sha256.py +18 -15
- maleo_foundation/client/services/key.py +50 -42
- maleo_foundation/client/services/signature.py +46 -42
- maleo_foundation/client/services/token.py +49 -58
- maleo_foundation/constants.py +12 -19
- maleo_foundation/enums.py +14 -13
- maleo_foundation/expanded_types/__init__.py +2 -3
- maleo_foundation/expanded_types/client.py +30 -34
- maleo_foundation/expanded_types/encryption/__init__.py +2 -1
- maleo_foundation/expanded_types/encryption/aes.py +7 -5
- maleo_foundation/expanded_types/encryption/rsa.py +7 -5
- maleo_foundation/expanded_types/general.py +13 -11
- maleo_foundation/expanded_types/hash.py +7 -5
- maleo_foundation/expanded_types/key.py +8 -6
- maleo_foundation/expanded_types/service.py +30 -34
- maleo_foundation/expanded_types/signature.py +7 -5
- maleo_foundation/expanded_types/token.py +7 -5
- maleo_foundation/extended_types.py +4 -3
- maleo_foundation/managers/cache.py +2 -1
- maleo_foundation/managers/client/base.py +25 -12
- maleo_foundation/managers/client/google/base.py +11 -4
- maleo_foundation/managers/client/google/parameter.py +9 -11
- maleo_foundation/managers/client/google/secret.py +53 -35
- maleo_foundation/managers/client/google/storage.py +52 -22
- maleo_foundation/managers/client/google/subscription.py +37 -39
- maleo_foundation/managers/client/maleo.py +18 -23
- maleo_foundation/managers/configuration.py +5 -9
- maleo_foundation/managers/credential.py +14 -17
- maleo_foundation/managers/db.py +51 -40
- maleo_foundation/managers/middleware.py +9 -9
- maleo_foundation/managers/service.py +47 -54
- maleo_foundation/middlewares/authentication.py +29 -54
- maleo_foundation/middlewares/base.py +83 -72
- maleo_foundation/middlewares/cors.py +8 -7
- maleo_foundation/models/__init__.py +2 -1
- maleo_foundation/models/responses.py +57 -29
- maleo_foundation/models/schemas/__init__.py +2 -1
- maleo_foundation/models/schemas/encryption.py +5 -2
- maleo_foundation/models/schemas/general.py +38 -18
- maleo_foundation/models/schemas/hash.py +2 -1
- maleo_foundation/models/schemas/key.py +5 -2
- maleo_foundation/models/schemas/parameter.py +45 -15
- maleo_foundation/models/schemas/result.py +35 -20
- maleo_foundation/models/schemas/signature.py +5 -2
- maleo_foundation/models/schemas/token.py +5 -2
- maleo_foundation/models/table.py +33 -27
- maleo_foundation/models/transfers/__init__.py +2 -1
- maleo_foundation/models/transfers/general/__init__.py +2 -1
- maleo_foundation/models/transfers/general/configurations/__init__.py +10 -4
- maleo_foundation/models/transfers/general/configurations/cache/__init__.py +3 -2
- maleo_foundation/models/transfers/general/configurations/cache/redis.py +13 -5
- maleo_foundation/models/transfers/general/configurations/client/__init__.py +5 -1
- maleo_foundation/models/transfers/general/configurations/client/maleo.py +38 -12
- maleo_foundation/models/transfers/general/configurations/database.py +5 -2
- maleo_foundation/models/transfers/general/configurations/middleware.py +22 -15
- maleo_foundation/models/transfers/general/configurations/service.py +2 -1
- maleo_foundation/models/transfers/general/credentials.py +2 -1
- maleo_foundation/models/transfers/general/database.py +11 -4
- maleo_foundation/models/transfers/general/key.py +13 -4
- maleo_foundation/models/transfers/general/request.py +28 -9
- maleo_foundation/models/transfers/general/settings.py +12 -22
- maleo_foundation/models/transfers/general/signature.py +4 -2
- maleo_foundation/models/transfers/general/token.py +34 -27
- maleo_foundation/models/transfers/parameters/__init__.py +2 -1
- maleo_foundation/models/transfers/parameters/client.py +15 -19
- maleo_foundation/models/transfers/parameters/encryption/__init__.py +2 -1
- maleo_foundation/models/transfers/parameters/encryption/aes.py +7 -5
- maleo_foundation/models/transfers/parameters/encryption/rsa.py +7 -5
- maleo_foundation/models/transfers/parameters/general.py +15 -13
- maleo_foundation/models/transfers/parameters/hash/__init__.py +2 -1
- maleo_foundation/models/transfers/parameters/hash/bcrypt.py +5 -5
- maleo_foundation/models/transfers/parameters/hash/hmac.py +6 -6
- maleo_foundation/models/transfers/parameters/hash/sha256.py +5 -5
- maleo_foundation/models/transfers/parameters/key.py +9 -8
- maleo_foundation/models/transfers/parameters/service.py +42 -48
- maleo_foundation/models/transfers/parameters/signature.py +7 -4
- maleo_foundation/models/transfers/parameters/token.py +10 -10
- maleo_foundation/models/transfers/results/__init__.py +2 -1
- maleo_foundation/models/transfers/results/client/__init__.py +2 -1
- maleo_foundation/models/transfers/results/client/controllers/__init__.py +2 -1
- maleo_foundation/models/transfers/results/client/controllers/http.py +10 -7
- maleo_foundation/models/transfers/results/client/service.py +12 -6
- maleo_foundation/models/transfers/results/encryption/__init__.py +2 -1
- maleo_foundation/models/transfers/results/encryption/aes.py +13 -5
- maleo_foundation/models/transfers/results/encryption/rsa.py +12 -4
- maleo_foundation/models/transfers/results/hash.py +7 -3
- maleo_foundation/models/transfers/results/key.py +18 -6
- maleo_foundation/models/transfers/results/service/__init__.py +2 -3
- maleo_foundation/models/transfers/results/service/controllers/__init__.py +2 -1
- maleo_foundation/models/transfers/results/service/controllers/rest.py +14 -11
- maleo_foundation/models/transfers/results/service/general.py +16 -10
- maleo_foundation/models/transfers/results/signature.py +12 -4
- maleo_foundation/models/transfers/results/token.py +10 -4
- maleo_foundation/rest_controller_result.py +23 -21
- maleo_foundation/types.py +15 -14
- maleo_foundation/utils/__init__.py +2 -1
- maleo_foundation/utils/cache.py +10 -13
- maleo_foundation/utils/client.py +25 -12
- maleo_foundation/utils/controller.py +59 -37
- maleo_foundation/utils/dependencies/__init__.py +2 -1
- maleo_foundation/utils/dependencies/auth.py +5 -12
- maleo_foundation/utils/dependencies/context.py +3 -4
- maleo_foundation/utils/exceptions.py +50 -28
- maleo_foundation/utils/extractor.py +18 -6
- maleo_foundation/utils/formatter/__init__.py +2 -1
- maleo_foundation/utils/formatter/case.py +5 -4
- maleo_foundation/utils/loaders/__init__.py +2 -1
- maleo_foundation/utils/loaders/credential/__init__.py +2 -1
- maleo_foundation/utils/loaders/credential/google.py +29 -15
- maleo_foundation/utils/loaders/json.py +3 -2
- maleo_foundation/utils/loaders/key/__init__.py +2 -1
- maleo_foundation/utils/loaders/key/rsa.py +26 -13
- maleo_foundation/utils/loaders/yaml.py +2 -1
- maleo_foundation/utils/logging.py +70 -46
- maleo_foundation/utils/merger.py +7 -9
- maleo_foundation/utils/query.py +41 -34
- maleo_foundation/utils/repository.py +29 -16
- maleo_foundation/utils/searcher.py +4 -6
- {maleo_foundation-0.3.46.dist-info → maleo_foundation-0.3.48.dist-info}/METADATA +14 -1
- maleo_foundation-0.3.48.dist-info/RECORD +137 -0
- maleo_foundation/expanded_types/repository.py +0 -68
- maleo_foundation/models/transfers/results/service/repository.py +0 -39
- maleo_foundation-0.3.46.dist-info/RECORD +0 -139
- {maleo_foundation-0.3.46.dist-info → maleo_foundation-0.3.48.dist-info}/WHEEL +0 -0
- {maleo_foundation-0.3.46.dist-info → maleo_foundation-0.3.48.dist-info}/top_level.txt +0 -0
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|
2
2
|
from .service import BaseServiceResultsTransfers
|
3
3
|
from .client import BaseClientResultsTransfers
|
4
4
|
|
5
|
+
|
5
6
|
class BaseResultsTransfers:
|
6
7
|
Service = BaseServiceResultsTransfers
|
7
|
-
Client = BaseClientResultsTransfers
|
8
|
+
Client = BaseClientResultsTransfers
|
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|
2
2
|
from .service import BaseClientServiceResultsTransfers
|
3
3
|
from .controllers import BaseClientControllersResultsTransfers
|
4
4
|
|
5
|
+
|
5
6
|
class BaseClientResultsTransfers:
|
6
7
|
Service = BaseClientServiceResultsTransfers
|
7
|
-
Controller = BaseClientControllersResultsTransfers
|
8
|
+
Controller = BaseClientControllersResultsTransfers
|
@@ -3,32 +3,35 @@ from httpx import Response
|
|
3
3
|
from pydantic import BaseModel, ConfigDict, Field, model_validator
|
4
4
|
from typing import Any
|
5
5
|
|
6
|
+
|
6
7
|
class BaseClientHTTPControllerResults(BaseModel):
|
7
8
|
model_config = ConfigDict(arbitrary_types_allowed=True)
|
8
9
|
|
9
10
|
response: Response = Field(..., description="Client's HTTP Controller response")
|
10
|
-
status_code: int = Field(
|
11
|
+
status_code: int = Field(
|
12
|
+
..., description="Client's HTTP Controller response status code"
|
13
|
+
)
|
11
14
|
content: Any = Field(..., description="Client's HTTP Controller response content")
|
12
15
|
success: bool = Field(..., description="Client's HTTP Controller success status")
|
13
16
|
|
14
17
|
@model_validator(mode="before")
|
15
18
|
@classmethod
|
16
|
-
def process_response(cls, values:dict) -> dict:
|
19
|
+
def process_response(cls, values: dict) -> dict:
|
17
20
|
"""Process the response to set status_code, content, and success."""
|
18
|
-
response:Response = values.get("response")
|
21
|
+
response: Response = values.get("response")
|
19
22
|
|
20
23
|
if response:
|
21
24
|
values["status_code"] = response.status_code
|
22
25
|
values["success"] = response.is_success
|
23
26
|
|
24
|
-
|
25
|
-
content_type:str = response.headers.get("content-type", "")
|
27
|
+
# * Determine content type and parse accordingly
|
28
|
+
content_type: str = response.headers.get("content-type", "")
|
26
29
|
content_type = content_type.lower()
|
27
30
|
if "application/json" in content_type:
|
28
31
|
values["content"] = response.json()
|
29
32
|
elif "text/" in content_type or "application/xml" in content_type:
|
30
33
|
values["content"] = response.text
|
31
34
|
else:
|
32
|
-
values["content"] = response.content
|
35
|
+
values["content"] = response.content # * Raw bytes for unknown types
|
33
36
|
|
34
|
-
return values
|
37
|
+
return values
|
@@ -2,16 +2,22 @@ from __future__ import annotations
|
|
2
2
|
from pydantic import model_validator
|
3
3
|
from maleo_foundation.models.schemas.result import BaseResultSchemas
|
4
4
|
|
5
|
+
|
5
6
|
class BaseClientServiceResultsTransfers:
|
6
|
-
class Fail(BaseResultSchemas.Fail):
|
7
|
+
class Fail(BaseResultSchemas.Fail):
|
8
|
+
pass
|
7
9
|
|
8
|
-
class NotFound(BaseResultSchemas.NotFound):
|
10
|
+
class NotFound(BaseResultSchemas.NotFound):
|
11
|
+
pass
|
9
12
|
|
10
|
-
class NoData(BaseResultSchemas.NoData):
|
13
|
+
class NoData(BaseResultSchemas.NoData):
|
14
|
+
pass
|
11
15
|
|
12
|
-
class SingleData(BaseResultSchemas.SingleData):
|
16
|
+
class SingleData(BaseResultSchemas.SingleData):
|
17
|
+
pass
|
13
18
|
|
14
|
-
class UnpaginatedMultipleData(BaseResultSchemas.UnpaginatedMultipleData):
|
19
|
+
class UnpaginatedMultipleData(BaseResultSchemas.UnpaginatedMultipleData):
|
20
|
+
pass
|
15
21
|
|
16
22
|
class PaginatedMultipleData(BaseResultSchemas.PaginatedMultipleData):
|
17
23
|
@model_validator(mode="before")
|
@@ -26,4 +32,4 @@ class BaseClientServiceResultsTransfers:
|
|
26
32
|
values["limit"] = pagination.limit
|
27
33
|
values["total_data"] = pagination.total_data
|
28
34
|
|
29
|
-
return values
|
35
|
+
return values
|
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|
2
2
|
from .aes import MaleoFoundationAESEncryptionResultsTransfers
|
3
3
|
from .rsa import MaleoFoundationRSAEncryptionResultsTransfers
|
4
4
|
|
5
|
+
|
5
6
|
class BaseEncryptionResultsTransfers:
|
6
7
|
AES = MaleoFoundationAESEncryptionResultsTransfers
|
7
|
-
RSA = MaleoFoundationRSAEncryptionResultsTransfers
|
8
|
+
RSA = MaleoFoundationRSAEncryptionResultsTransfers
|
@@ -1,18 +1,26 @@
|
|
1
1
|
from pydantic import Field
|
2
|
-
from maleo_foundation.models.transfers.results.service.general import
|
2
|
+
from maleo_foundation.models.transfers.results.service.general import (
|
3
|
+
BaseServiceGeneralResultsTransfers,
|
4
|
+
)
|
3
5
|
from maleo_foundation.models.schemas.encryption import MaleoFoundationEncryptionSchemas
|
4
6
|
|
7
|
+
|
5
8
|
class EncryptData(
|
6
9
|
MaleoFoundationEncryptionSchemas.Ciphertext,
|
7
10
|
MaleoFoundationEncryptionSchemas.InitializationVector,
|
8
|
-
MaleoFoundationEncryptionSchemas.Key
|
9
|
-
):
|
11
|
+
MaleoFoundationEncryptionSchemas.Key,
|
12
|
+
):
|
13
|
+
pass
|
14
|
+
|
10
15
|
|
11
16
|
class MaleoFoundationAESEncryptionResultsTransfers:
|
12
|
-
class Fail(BaseServiceGeneralResultsTransfers.Fail):
|
17
|
+
class Fail(BaseServiceGeneralResultsTransfers.Fail):
|
18
|
+
pass
|
13
19
|
|
14
20
|
class Encrypt(BaseServiceGeneralResultsTransfers.SingleData):
|
15
21
|
data: EncryptData = Field(..., description="Single encryption data")
|
16
22
|
|
17
23
|
class Decrypt(BaseServiceGeneralResultsTransfers.SingleData):
|
18
|
-
data: MaleoFoundationEncryptionSchemas.Plaintext = Field(
|
24
|
+
data: MaleoFoundationEncryptionSchemas.Plaintext = Field(
|
25
|
+
..., description="Single decryption data"
|
26
|
+
)
|
@@ -1,12 +1,20 @@
|
|
1
1
|
from pydantic import Field
|
2
|
-
from maleo_foundation.models.transfers.results.service.general import
|
2
|
+
from maleo_foundation.models.transfers.results.service.general import (
|
3
|
+
BaseServiceGeneralResultsTransfers,
|
4
|
+
)
|
3
5
|
from maleo_foundation.models.schemas.encryption import MaleoFoundationEncryptionSchemas
|
4
6
|
|
7
|
+
|
5
8
|
class MaleoFoundationRSAEncryptionResultsTransfers:
|
6
|
-
class Fail(BaseServiceGeneralResultsTransfers.Fail):
|
9
|
+
class Fail(BaseServiceGeneralResultsTransfers.Fail):
|
10
|
+
pass
|
7
11
|
|
8
12
|
class Encrypt(BaseServiceGeneralResultsTransfers.SingleData):
|
9
|
-
data: MaleoFoundationEncryptionSchemas.Ciphertext = Field(
|
13
|
+
data: MaleoFoundationEncryptionSchemas.Ciphertext = Field(
|
14
|
+
..., description="Single encryption data"
|
15
|
+
)
|
10
16
|
|
11
17
|
class Decrypt(BaseServiceGeneralResultsTransfers.SingleData):
|
12
|
-
data: MaleoFoundationEncryptionSchemas.Plaintext = Field(
|
18
|
+
data: MaleoFoundationEncryptionSchemas.Plaintext = Field(
|
19
|
+
..., description="Single decryption data"
|
20
|
+
)
|
@@ -1,13 +1,17 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
from pydantic import Field
|
3
|
-
from maleo_foundation.models.transfers.results.service.general import
|
3
|
+
from maleo_foundation.models.transfers.results.service.general import (
|
4
|
+
BaseServiceGeneralResultsTransfers,
|
5
|
+
)
|
4
6
|
from maleo_foundation.models.schemas.hash import MaleoFoundationHashSchemas
|
5
7
|
|
8
|
+
|
6
9
|
class MaleoFoundationHashResultsTransfers:
|
7
|
-
class Fail(BaseServiceGeneralResultsTransfers.Fail):
|
10
|
+
class Fail(BaseServiceGeneralResultsTransfers.Fail):
|
11
|
+
pass
|
8
12
|
|
9
13
|
class Hash(BaseServiceGeneralResultsTransfers.SingleData):
|
10
14
|
data: MaleoFoundationHashSchemas.Hash = Field(..., description="Hash data")
|
11
15
|
|
12
16
|
class Verify(BaseServiceGeneralResultsTransfers.SingleData):
|
13
|
-
data: MaleoFoundationHashSchemas.IsValid = Field(..., description="Verify data")
|
17
|
+
data: MaleoFoundationHashSchemas.IsValid = Field(..., description="Verify data")
|
@@ -1,16 +1,28 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
from pydantic import Field
|
3
|
-
from maleo_foundation.models.transfers.results.service.general import
|
4
|
-
|
3
|
+
from maleo_foundation.models.transfers.results.service.general import (
|
4
|
+
BaseServiceGeneralResultsTransfers,
|
5
|
+
)
|
6
|
+
from maleo_foundation.models.transfers.general.key import (
|
7
|
+
MaleoFoundationKeyGeneralTransfers,
|
8
|
+
)
|
9
|
+
|
5
10
|
|
6
11
|
class MaleoFoundationKeyResultsTransfers:
|
7
|
-
class Fail(BaseServiceGeneralResultsTransfers.Fail):
|
12
|
+
class Fail(BaseServiceGeneralResultsTransfers.Fail):
|
13
|
+
pass
|
8
14
|
|
9
15
|
class CreatePrivate(BaseServiceGeneralResultsTransfers.SingleData):
|
10
|
-
data: MaleoFoundationKeyGeneralTransfers.PrivateKey = Field(
|
16
|
+
data: MaleoFoundationKeyGeneralTransfers.PrivateKey = Field(
|
17
|
+
..., description="Private key data"
|
18
|
+
)
|
11
19
|
|
12
20
|
class CreatePublic(BaseServiceGeneralResultsTransfers.SingleData):
|
13
|
-
data: MaleoFoundationKeyGeneralTransfers.PublicKey = Field(
|
21
|
+
data: MaleoFoundationKeyGeneralTransfers.PublicKey = Field(
|
22
|
+
..., description="Private key data"
|
23
|
+
)
|
14
24
|
|
15
25
|
class CreatePair(BaseServiceGeneralResultsTransfers.SingleData):
|
16
|
-
data: MaleoFoundationKeyGeneralTransfers.KeyPair = Field(
|
26
|
+
data: MaleoFoundationKeyGeneralTransfers.KeyPair = Field(
|
27
|
+
..., description="Key pair data"
|
28
|
+
)
|
@@ -1,9 +1,8 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
from .general import BaseServiceGeneralResultsTransfers
|
3
|
-
from .repository import BaseServiceRepositoryResultsTransfers
|
4
3
|
from .controllers import BaseServiceControllerResultsTransfers
|
5
4
|
|
5
|
+
|
6
6
|
class BaseServiceResultsTransfers:
|
7
7
|
General = BaseServiceGeneralResultsTransfers
|
8
|
-
|
9
|
-
Controller = BaseServiceControllerResultsTransfers
|
8
|
+
Controller = BaseServiceControllerResultsTransfers
|
@@ -1,21 +1,24 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
from fastapi import status, Response
|
3
3
|
from typing import Any
|
4
|
-
from pydantic import BaseModel, ConfigDict, Field
|
4
|
+
from pydantic import BaseModel, ConfigDict, Field
|
5
5
|
from maleo_foundation.enums import BaseEnums
|
6
6
|
|
7
|
+
|
7
8
|
class BaseServiceRESTControllerResults(BaseModel):
|
8
9
|
model_config = ConfigDict(arbitrary_types_allowed=True)
|
9
10
|
|
10
|
-
success:bool = Field(..., description="REST Controller's success status")
|
11
|
-
response_type:BaseEnums.RESTControllerResponseType = Field(
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
success: bool = Field(..., description="REST Controller's success status")
|
12
|
+
response_type: BaseEnums.RESTControllerResponseType = Field(
|
13
|
+
BaseEnums.RESTControllerResponseType.JSON,
|
14
|
+
description="REST Controller's response class",
|
15
|
+
)
|
16
|
+
content: Any = Field(..., description="REST Controller's response content")
|
17
|
+
status_code: int = Field(
|
18
|
+
status.HTTP_200_OK, description="REST Controller's response status code"
|
19
|
+
)
|
15
20
|
|
16
|
-
@
|
17
|
-
def
|
18
|
-
"""Dynamically creates a response based on response_type."""
|
21
|
+
@property
|
22
|
+
def response(self) -> Response:
|
19
23
|
response_cls = self.response_type.get_response_type()
|
20
|
-
|
21
|
-
return self
|
24
|
+
return response_cls(content=self.content, status_code=self.status_code)
|
@@ -2,16 +2,22 @@ from __future__ import annotations
|
|
2
2
|
from pydantic import model_validator
|
3
3
|
from maleo_foundation.models.schemas.result import BaseResultSchemas
|
4
4
|
|
5
|
+
|
5
6
|
class BaseServiceGeneralResultsTransfers:
|
6
|
-
class Fail(BaseResultSchemas.Fail):
|
7
|
+
class Fail(BaseResultSchemas.Fail):
|
8
|
+
pass
|
7
9
|
|
8
|
-
class NotFound(BaseResultSchemas.NotFound):
|
10
|
+
class NotFound(BaseResultSchemas.NotFound):
|
11
|
+
pass
|
9
12
|
|
10
|
-
class NoData(BaseResultSchemas.NoData):
|
13
|
+
class NoData(BaseResultSchemas.NoData):
|
14
|
+
pass
|
11
15
|
|
12
|
-
class SingleData(BaseResultSchemas.SingleData):
|
16
|
+
class SingleData(BaseResultSchemas.SingleData):
|
17
|
+
pass
|
13
18
|
|
14
|
-
class UnpaginatedMultipleData(BaseResultSchemas.UnpaginatedMultipleData):
|
19
|
+
class UnpaginatedMultipleData(BaseResultSchemas.UnpaginatedMultipleData):
|
20
|
+
pass
|
15
21
|
|
16
22
|
class PaginatedMultipleData(BaseResultSchemas.PaginatedMultipleData):
|
17
23
|
@model_validator(mode="before")
|
@@ -21,19 +27,19 @@ class BaseServiceGeneralResultsTransfers:
|
|
21
27
|
total_data = values.get("total_data", 0)
|
22
28
|
data = values.get("data", [])
|
23
29
|
|
24
|
-
|
30
|
+
# * Get pagination values from inherited SimplePagination
|
25
31
|
page = values.get("page", 1)
|
26
32
|
limit = values.get("limit", 10)
|
27
33
|
|
28
|
-
|
34
|
+
# * Calculate total pages
|
29
35
|
total_pages = (total_data // limit) + (1 if total_data % limit > 0 else 0)
|
30
36
|
|
31
|
-
|
37
|
+
# * Assign computed pagination object before validation
|
32
38
|
values["pagination"] = BaseResultSchemas.ExtendedPagination(
|
33
39
|
page=page,
|
34
40
|
limit=limit,
|
35
41
|
data_count=len(data),
|
36
42
|
total_data=total_data,
|
37
|
-
total_pages=total_pages
|
43
|
+
total_pages=total_pages,
|
38
44
|
)
|
39
|
-
return values
|
45
|
+
return values
|
@@ -1,12 +1,20 @@
|
|
1
1
|
from pydantic import Field
|
2
|
-
from maleo_foundation.models.transfers.results.service.general import
|
2
|
+
from maleo_foundation.models.transfers.results.service.general import (
|
3
|
+
BaseServiceGeneralResultsTransfers,
|
4
|
+
)
|
3
5
|
from maleo_foundation.models.schemas.signature import MaleoFoundationSignatureSchemas
|
4
6
|
|
7
|
+
|
5
8
|
class MaleoFoundationSignatureResultsTransfers:
|
6
|
-
class Fail(BaseServiceGeneralResultsTransfers.Fail):
|
9
|
+
class Fail(BaseServiceGeneralResultsTransfers.Fail):
|
10
|
+
pass
|
7
11
|
|
8
12
|
class Sign(BaseServiceGeneralResultsTransfers.SingleData):
|
9
|
-
data: MaleoFoundationSignatureSchemas.Signature = Field(
|
13
|
+
data: MaleoFoundationSignatureSchemas.Signature = Field(
|
14
|
+
..., description="Single signature data"
|
15
|
+
)
|
10
16
|
|
11
17
|
class Verify(BaseServiceGeneralResultsTransfers.SingleData):
|
12
|
-
data: MaleoFoundationSignatureSchemas.IsValid = Field(
|
18
|
+
data: MaleoFoundationSignatureSchemas.IsValid = Field(
|
19
|
+
..., description="Single verify data"
|
20
|
+
)
|
@@ -1,12 +1,18 @@
|
|
1
|
-
from maleo_foundation.models.transfers.results.service.general import
|
1
|
+
from maleo_foundation.models.transfers.results.service.general import (
|
2
|
+
BaseServiceGeneralResultsTransfers,
|
3
|
+
)
|
2
4
|
from maleo_foundation.models.schemas.token import MaleoFoundationTokenSchemas
|
3
|
-
from maleo_foundation.models.transfers.general.token import
|
5
|
+
from maleo_foundation.models.transfers.general.token import (
|
6
|
+
MaleoFoundationTokenGeneralTransfers,
|
7
|
+
)
|
8
|
+
|
4
9
|
|
5
10
|
class MaleoFoundationTokenResultsTransfers:
|
6
|
-
class Fail(BaseServiceGeneralResultsTransfers.Fail):
|
11
|
+
class Fail(BaseServiceGeneralResultsTransfers.Fail):
|
12
|
+
pass
|
7
13
|
|
8
14
|
class Encode(BaseServiceGeneralResultsTransfers.SingleData):
|
9
15
|
data: MaleoFoundationTokenSchemas.Token
|
10
16
|
|
11
17
|
class Decode(BaseServiceGeneralResultsTransfers.SingleData):
|
12
|
-
data: MaleoFoundationTokenGeneralTransfers.DecodePayload
|
18
|
+
data: MaleoFoundationTokenGeneralTransfers.DecodePayload
|
@@ -1,59 +1,61 @@
|
|
1
1
|
from fastapi import status
|
2
|
-
from maleo_foundation.models.transfers.results.service.controllers.rest
|
3
|
-
|
2
|
+
from maleo_foundation.models.transfers.results.service.controllers.rest import (
|
3
|
+
BaseServiceRESTControllerResults,
|
4
|
+
)
|
4
5
|
from maleo_foundation.models.responses import BaseResponses
|
5
6
|
|
7
|
+
|
6
8
|
class RESTControllerResultsConstants:
|
7
9
|
BAD_REQUEST = BaseServiceRESTControllerResults(
|
8
10
|
success=False,
|
9
|
-
content=BaseResponses.BadRequest().model_dump(),
|
10
|
-
status_code=status.HTTP_400_BAD_REQUEST
|
11
|
+
content=BaseResponses.BadRequest().model_dump(), # type: ignore
|
12
|
+
status_code=status.HTTP_400_BAD_REQUEST,
|
11
13
|
)
|
12
14
|
|
13
15
|
INVALID_EXPAND = BaseServiceRESTControllerResults(
|
14
16
|
success=False,
|
15
|
-
content=BaseResponses.InvalidExpand().model_dump(),
|
16
|
-
status_code=status.HTTP_400_BAD_REQUEST
|
17
|
+
content=BaseResponses.InvalidExpand().model_dump(), # type: ignore
|
18
|
+
status_code=status.HTTP_400_BAD_REQUEST,
|
17
19
|
)
|
18
20
|
|
19
21
|
UNAUTHORIZED = BaseServiceRESTControllerResults(
|
20
22
|
success=False,
|
21
|
-
content=BaseResponses.Unauthorized().model_dump(),
|
22
|
-
status_code=status.HTTP_401_UNAUTHORIZED
|
23
|
+
content=BaseResponses.Unauthorized().model_dump(), # type: ignore
|
24
|
+
status_code=status.HTTP_401_UNAUTHORIZED,
|
23
25
|
)
|
24
26
|
|
25
27
|
FORBIDDEN = BaseServiceRESTControllerResults(
|
26
28
|
success=False,
|
27
|
-
content=BaseResponses.Forbidden().model_dump(),
|
28
|
-
status_code=status.HTTP_403_FORBIDDEN
|
29
|
+
content=BaseResponses.Forbidden().model_dump(), # type: ignore
|
30
|
+
status_code=status.HTTP_403_FORBIDDEN,
|
29
31
|
)
|
30
32
|
|
31
33
|
METHOD_NOT_ALLOWED = BaseServiceRESTControllerResults(
|
32
34
|
success=False,
|
33
|
-
content=BaseResponses.MethodNotAllowed().model_dump(),
|
34
|
-
status_code=status.HTTP_405_METHOD_NOT_ALLOWED
|
35
|
+
content=BaseResponses.MethodNotAllowed().model_dump(), # type: ignore
|
36
|
+
status_code=status.HTTP_405_METHOD_NOT_ALLOWED,
|
35
37
|
)
|
36
38
|
|
37
39
|
VALIDATION_ERROR = BaseServiceRESTControllerResults(
|
38
40
|
success=False,
|
39
|
-
content=BaseResponses.ValidationError().model_dump(),
|
40
|
-
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY
|
41
|
+
content=BaseResponses.ValidationError().model_dump(), # type: ignore
|
42
|
+
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
41
43
|
)
|
42
44
|
|
43
45
|
RATE_LIMIT_EXCEEDED = BaseServiceRESTControllerResults(
|
44
46
|
success=False,
|
45
|
-
content=BaseResponses.RateLimitExceeded().model_dump(),
|
46
|
-
status_code=status.HTTP_429_TOO_MANY_REQUESTS
|
47
|
+
content=BaseResponses.RateLimitExceeded().model_dump(), # type: ignore
|
48
|
+
status_code=status.HTTP_429_TOO_MANY_REQUESTS,
|
47
49
|
)
|
48
50
|
|
49
51
|
SERVER_ERROR = BaseServiceRESTControllerResults(
|
50
52
|
success=False,
|
51
|
-
content=BaseResponses.ServerError().model_dump(),
|
52
|
-
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR
|
53
|
+
content=BaseResponses.ServerError().model_dump(), # type: ignore
|
54
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
53
55
|
)
|
54
56
|
|
55
57
|
NOT_IMPLEMENTED = BaseServiceRESTControllerResults(
|
56
58
|
success=False,
|
57
|
-
content=BaseResponses.NotImplemented().model_dump(),
|
58
|
-
status_code=status.HTTP_501_NOT_IMPLEMENTED
|
59
|
-
)
|
59
|
+
content=BaseResponses.NotImplemented().model_dump(), # type: ignore
|
60
|
+
status_code=status.HTTP_501_NOT_IMPLEMENTED,
|
61
|
+
)
|
maleo_foundation/types.py
CHANGED
@@ -3,39 +3,40 @@ from typing import Dict, Optional, Union, Literal, List, Any
|
|
3
3
|
from uuid import UUID
|
4
4
|
from maleo_foundation.enums import BaseEnums
|
5
5
|
|
6
|
+
|
6
7
|
class BaseTypes:
|
7
|
-
|
8
|
+
# * Any-related types
|
8
9
|
ListOfAny = List[Any]
|
9
10
|
OptionalAny = Optional[Any]
|
10
11
|
|
11
|
-
|
12
|
+
# * Boolean-related types
|
12
13
|
LiteralFalse = Literal[False]
|
13
14
|
LiteralTrue = Literal[True]
|
14
15
|
ListOfBools = List[bool]
|
15
16
|
OptionalBoolean = Optional[bool]
|
16
17
|
|
17
|
-
|
18
|
+
# * Float-related types
|
18
19
|
ListOfFloats = List[float]
|
19
20
|
OptionalFloat = Optional[float]
|
20
21
|
OptionalListOfFloats = Optional[List[float]]
|
21
22
|
|
22
|
-
|
23
|
+
# * Integer-related types
|
23
24
|
ListOfIntegers = List[int]
|
24
25
|
OptionalInteger = Optional[int]
|
25
26
|
OptionalListOfIntegers = Optional[List[int]]
|
26
27
|
|
27
|
-
|
28
|
+
# * String-related types
|
28
29
|
ListOfStrings = List[str]
|
29
30
|
OptionalString = Optional[str]
|
30
31
|
OptionalListOfStrings = Optional[List[str]]
|
31
32
|
|
32
|
-
|
33
|
+
# * Date-related types
|
33
34
|
OptionalDate = Optional[date]
|
34
35
|
|
35
|
-
|
36
|
+
# * Datetime-related types
|
36
37
|
OptionalDatetime = Optional[datetime]
|
37
38
|
|
38
|
-
|
39
|
+
# * Any Dict-related types
|
39
40
|
StringToAnyDict = Dict[str, Any]
|
40
41
|
OptionalStringToAnyDict = Optional[Dict[str, Any]]
|
41
42
|
ListOfStringToAnyDict = List[Dict[str, Any]]
|
@@ -45,7 +46,7 @@ class BaseTypes:
|
|
45
46
|
ListOfIntToAnyDict = List[Dict[int, Any]]
|
46
47
|
OptionalListOfIntToAnyDict = Optional[List[Dict[int, Any]]]
|
47
48
|
|
48
|
-
|
49
|
+
# * String Dict-related types
|
49
50
|
StringToStringDict = Dict[str, str]
|
50
51
|
OptionalStringToStringDict = Optional[Dict[str, str]]
|
51
52
|
ListOfStringToStringDict = List[Dict[str, str]]
|
@@ -55,19 +56,19 @@ class BaseTypes:
|
|
55
56
|
ListOfIntToStringDict = List[Dict[int, str]]
|
56
57
|
OptionalListOfIntToStringDict = Optional[List[Dict[int, str]]]
|
57
58
|
|
58
|
-
|
59
|
+
# * List Dict-related types
|
59
60
|
StringToListOfStringDict = Dict[str, List[str]]
|
60
61
|
OptionalStringToListOfStringDict = Optional[Dict[str, List[str]]]
|
61
62
|
|
62
|
-
|
63
|
+
# * UUID-related types
|
63
64
|
ListOfUUIDs = List[UUID]
|
64
65
|
OptionalUUID = Optional[UUID]
|
65
66
|
OptionalListOfUUIDs = Optional[List[UUID]]
|
66
67
|
|
67
|
-
|
68
|
+
# * Statuses-related types
|
68
69
|
ListOfStatuses = List[BaseEnums.StatusType]
|
69
70
|
OptionalListOfStatuses = Optional[List[BaseEnums.StatusType]]
|
70
71
|
|
71
|
-
|
72
|
+
# * Miscellanous types
|
72
73
|
IdentifierValue = Union[int, UUID, str]
|
73
|
-
ListOrDictOfAny = Union[List[Any], Dict[str, Any]]
|
74
|
+
ListOrDictOfAny = Union[List[Any], Dict[str, Any]]
|
@@ -5,9 +5,10 @@ from .loaders import BaseLoaders
|
|
5
5
|
from .controller import BaseControllerUtils
|
6
6
|
from .query import BaseQueryUtils
|
7
7
|
|
8
|
+
|
8
9
|
class BaseUtils:
|
9
10
|
Formatter = BaseFormatter
|
10
11
|
Exceptions = BaseExceptions
|
11
12
|
Loaders = BaseLoaders
|
12
13
|
Controller = BaseControllerUtils
|
13
|
-
Query = BaseQueryUtils
|
14
|
+
Query = BaseQueryUtils
|
maleo_foundation/utils/cache.py
CHANGED
@@ -3,11 +3,8 @@ from fastapi.encoders import jsonable_encoder
|
|
3
3
|
from pydantic import BaseModel
|
4
4
|
from typing import Callable
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
*args,
|
9
|
-
**kwargs
|
10
|
-
) -> str:
|
6
|
+
|
7
|
+
def key_builder(func: Callable, *args, **kwargs) -> str:
|
11
8
|
arg_values = []
|
12
9
|
for arg in args:
|
13
10
|
try:
|
@@ -21,7 +18,7 @@ def key_builder(
|
|
21
18
|
kwarg_values = {}
|
22
19
|
for k, v in kwargs.items():
|
23
20
|
try:
|
24
|
-
if isinstance(v, BaseModel) and hasattr(
|
21
|
+
if isinstance(v, BaseModel) and hasattr(v, "model_dump"):
|
25
22
|
kwarg_values[k] = v.model_dump(mode="json")
|
26
23
|
else:
|
27
24
|
kwarg_values[k] = jsonable_encoder(v)
|
@@ -30,11 +27,11 @@ def key_builder(
|
|
30
27
|
|
31
28
|
serialized_args = json.dumps(arg_values, sort_keys=True)
|
32
29
|
serialized_kwargs = json.dumps(kwarg_values, sort_keys=True)
|
33
|
-
|
34
|
-
return f"{func.__module__}:{func.__qualname__}({serialized_args}|{serialized_kwargs})"
|
35
30
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
31
|
+
return (
|
32
|
+
f"{func.__module__}:{func.__qualname__}({serialized_args}|{serialized_kwargs})"
|
33
|
+
)
|
34
|
+
|
35
|
+
|
36
|
+
def build_key(*ext: str, namespace: str):
|
37
|
+
return ":".join([namespace, *ext])
|