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
maleo_foundation/constants.py
CHANGED
@@ -5,14 +5,15 @@ from maleo_foundation.enums import BaseEnums
|
|
5
5
|
from maleo_foundation.types import BaseTypes
|
6
6
|
|
7
7
|
EMAIL_REGEX: str = r"^[^\s@]+@[^\s@]+\.[^\s@]+$"
|
8
|
-
TOKEN_COOKIE_KEY_NAME="token"
|
8
|
+
TOKEN_COOKIE_KEY_NAME = "token"
|
9
9
|
REFRESH_TOKEN_DURATION_DAYS: int = 7
|
10
10
|
ACCESS_TOKEN_DURATION_MINUTES: int = 5
|
11
|
-
SORT_COLUMN_PATTERN = re.compile(r
|
12
|
-
DATE_FILTER_PATTERN = re.compile(
|
11
|
+
SORT_COLUMN_PATTERN = re.compile(r"^[a-z_]+\.(asc|desc)$")
|
12
|
+
DATE_FILTER_PATTERN = re.compile(
|
13
|
+
r"^[a-z_]+(?:\|from::\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2}))?(?:\|to::\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2}))?$"
|
14
|
+
)
|
13
15
|
STATUS_UPDATE_CRITERIAS: dict[
|
14
|
-
BaseEnums.StatusUpdateType,
|
15
|
-
BaseTypes.OptionalListOfStatuses
|
16
|
+
BaseEnums.StatusUpdateType, BaseTypes.OptionalListOfStatuses
|
16
17
|
] = {
|
17
18
|
BaseEnums.StatusUpdateType.DELETE: None,
|
18
19
|
BaseEnums.StatusUpdateType.RESTORE: None,
|
@@ -23,27 +24,19 @@ STATUS_UPDATE_CRITERIAS: dict[
|
|
23
24
|
BaseEnums.StatusUpdateType.ACTIVATE: [
|
24
25
|
BaseEnums.StatusType.INACTIVE,
|
25
26
|
BaseEnums.StatusType.ACTIVE,
|
26
|
-
]
|
27
|
+
],
|
27
28
|
}
|
28
|
-
IDENTIFIER_TYPE_VALUE_TYPE_MAP: dict[
|
29
|
-
BaseEnums.IdentifierType,
|
30
|
-
object
|
31
|
-
] = {
|
29
|
+
IDENTIFIER_TYPE_VALUE_TYPE_MAP: dict[BaseEnums.IdentifierType, object] = {
|
32
30
|
BaseEnums.IdentifierType.ID: int,
|
33
|
-
BaseEnums.IdentifierType.UUID: UUID
|
31
|
+
BaseEnums.IdentifierType.UUID: UUID,
|
34
32
|
}
|
35
33
|
ALL_STATUSES: List[BaseEnums.StatusType] = [
|
36
34
|
BaseEnums.StatusType.ACTIVE,
|
37
35
|
BaseEnums.StatusType.INACTIVE,
|
38
|
-
BaseEnums.StatusType.DELETED
|
36
|
+
BaseEnums.StatusType.DELETED,
|
39
37
|
]
|
40
38
|
VISIBLE_STATUSES: List[BaseEnums.StatusType] = [
|
41
39
|
BaseEnums.StatusType.ACTIVE,
|
42
|
-
BaseEnums.StatusType.INACTIVE
|
40
|
+
BaseEnums.StatusType.INACTIVE,
|
43
41
|
]
|
44
|
-
VOLATILE_TOKEN_FIELDS: BaseTypes.ListOfStrings = [
|
45
|
-
"iat",
|
46
|
-
"iat_dt",
|
47
|
-
"exp",
|
48
|
-
"exp_dt"
|
49
|
-
]
|
42
|
+
VOLATILE_TOKEN_FIELDS: BaseTypes.ListOfStrings = ["iat", "iat_dt", "exp", "exp_dt"]
|
maleo_foundation/enums.py
CHANGED
@@ -2,6 +2,7 @@ import logging
|
|
2
2
|
from enum import IntEnum, StrEnum, Enum
|
3
3
|
from fastapi import responses
|
4
4
|
|
5
|
+
|
5
6
|
class BaseEnums:
|
6
7
|
class EnvironmentType(StrEnum):
|
7
8
|
LOCAL = "local"
|
@@ -153,16 +154,16 @@ class BaseEnums:
|
|
153
154
|
class Expiration(IntEnum):
|
154
155
|
EXP_15SC = int(15)
|
155
156
|
EXP_30SC = int(30)
|
156
|
-
EXP_1MN = int(1*60)
|
157
|
-
EXP_5MN = int(5*60)
|
158
|
-
EXP_10MN = int(10*60)
|
159
|
-
EXP_15MN = int(15*60)
|
160
|
-
EXP_30MN = int(30*60)
|
161
|
-
EXP_1HR = int(1*60*60)
|
162
|
-
EXP_6HR = int(6*60*60)
|
163
|
-
EXP_12HR = int(12*60*60)
|
164
|
-
EXP_1DY = int(1*24*60*60)
|
165
|
-
EXP_3DY = int(3*24*60*60)
|
166
|
-
EXP_1WK = int(1*7*24*60*60)
|
167
|
-
EXP_2WK = int(2*7*24*60*60)
|
168
|
-
EXP_1MO = int(1*30*24*60*60)
|
157
|
+
EXP_1MN = int(1 * 60)
|
158
|
+
EXP_5MN = int(5 * 60)
|
159
|
+
EXP_10MN = int(10 * 60)
|
160
|
+
EXP_15MN = int(15 * 60)
|
161
|
+
EXP_30MN = int(30 * 60)
|
162
|
+
EXP_1HR = int(1 * 60 * 60)
|
163
|
+
EXP_6HR = int(6 * 60 * 60)
|
164
|
+
EXP_12HR = int(12 * 60 * 60)
|
165
|
+
EXP_1DY = int(1 * 24 * 60 * 60)
|
166
|
+
EXP_3DY = int(3 * 24 * 60 * 60)
|
167
|
+
EXP_1WK = int(1 * 7 * 24 * 60 * 60)
|
168
|
+
EXP_2WK = int(2 * 7 * 24 * 60 * 60)
|
169
|
+
EXP_1MO = int(1 * 30 * 24 * 60 * 60)
|
@@ -1,11 +1,10 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
from .general import BaseGeneralExpandedTypes
|
3
|
-
from .repository import ExpandedRepositoryTypes
|
4
3
|
from .service import ExpandedServiceTypes
|
5
4
|
from .client import ExpandedClientTypes
|
6
5
|
|
6
|
+
|
7
7
|
class BaseExpandedTypes:
|
8
8
|
General = BaseGeneralExpandedTypes
|
9
|
-
Repository = ExpandedRepositoryTypes
|
10
9
|
Service = ExpandedServiceTypes
|
11
|
-
Client = ExpandedClientTypes
|
10
|
+
Client = ExpandedClientTypes
|
@@ -1,68 +1,64 @@
|
|
1
1
|
from typing import Awaitable, Callable, Union
|
2
|
-
from maleo_foundation.models.transfers.parameters.general
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
from maleo_foundation.models.transfers.parameters.general import (
|
3
|
+
BaseGeneralParametersTransfers,
|
4
|
+
)
|
5
|
+
from maleo_foundation.models.transfers.parameters.client import (
|
6
|
+
BaseClientParametersTransfers,
|
7
|
+
)
|
8
|
+
from maleo_foundation.models.transfers.results.client.service import (
|
9
|
+
BaseClientServiceResultsTransfers,
|
10
|
+
)
|
11
|
+
|
8
12
|
|
9
13
|
class ExpandedClientTypes:
|
10
|
-
|
11
|
-
GetUnpaginatedMultipleParameter =
|
14
|
+
# * Unpaginated multiple data
|
15
|
+
GetUnpaginatedMultipleParameter = (
|
16
|
+
BaseClientParametersTransfers.GetUnpaginatedMultiple
|
17
|
+
)
|
12
18
|
GetUnpaginatedMultipleResult = Union[
|
13
19
|
BaseClientServiceResultsTransfers.Fail,
|
14
20
|
BaseClientServiceResultsTransfers.NoData,
|
15
|
-
BaseClientServiceResultsTransfers.UnpaginatedMultipleData
|
21
|
+
BaseClientServiceResultsTransfers.UnpaginatedMultipleData,
|
16
22
|
]
|
17
23
|
SyncGetUnpaginatedMultipleFunction = Callable[
|
18
|
-
[GetUnpaginatedMultipleParameter],
|
19
|
-
GetUnpaginatedMultipleResult
|
24
|
+
[GetUnpaginatedMultipleParameter], GetUnpaginatedMultipleResult
|
20
25
|
]
|
21
26
|
AsyncGetUnpaginatedMultipleFunction = Callable[
|
22
|
-
[GetUnpaginatedMultipleParameter],
|
23
|
-
Awaitable[GetUnpaginatedMultipleResult]
|
27
|
+
[GetUnpaginatedMultipleParameter], Awaitable[GetUnpaginatedMultipleResult]
|
24
28
|
]
|
25
29
|
|
26
|
-
|
30
|
+
# * Paginated multiple data
|
27
31
|
GetPaginatedMultipleParameter = BaseClientParametersTransfers.GetPaginatedMultiple
|
28
32
|
GetPaginatedMultipleResult = Union[
|
29
33
|
BaseClientServiceResultsTransfers.Fail,
|
30
34
|
BaseClientServiceResultsTransfers.NoData,
|
31
|
-
BaseClientServiceResultsTransfers.PaginatedMultipleData
|
35
|
+
BaseClientServiceResultsTransfers.PaginatedMultipleData,
|
32
36
|
]
|
33
37
|
SyncGetPaginatedMultipleFunction = Callable[
|
34
|
-
[GetPaginatedMultipleParameter],
|
35
|
-
GetPaginatedMultipleResult
|
38
|
+
[GetPaginatedMultipleParameter], GetPaginatedMultipleResult
|
36
39
|
]
|
37
40
|
AsyncGetPaginatedMultipleFunction = Callable[
|
38
|
-
[GetPaginatedMultipleParameter],
|
39
|
-
Awaitable[GetPaginatedMultipleResult]
|
41
|
+
[GetPaginatedMultipleParameter], Awaitable[GetPaginatedMultipleResult]
|
40
42
|
]
|
41
43
|
|
42
|
-
|
44
|
+
# * Single data
|
43
45
|
GetSingleParameter = BaseGeneralParametersTransfers.GetSingle
|
44
46
|
GetSingleResult = Union[
|
45
47
|
BaseClientServiceResultsTransfers.Fail,
|
46
48
|
BaseClientServiceResultsTransfers.NoData,
|
47
|
-
BaseClientServiceResultsTransfers.SingleData
|
48
|
-
]
|
49
|
-
SyncGetSingleFunction = Callable[
|
50
|
-
[GetSingleParameter],
|
51
|
-
GetSingleResult
|
52
|
-
]
|
53
|
-
AsyncGetSingleFunction = Callable[
|
54
|
-
[GetSingleParameter],
|
55
|
-
Awaitable[GetSingleResult]
|
49
|
+
BaseClientServiceResultsTransfers.SingleData,
|
56
50
|
]
|
51
|
+
SyncGetSingleFunction = Callable[[GetSingleParameter], GetSingleResult]
|
52
|
+
AsyncGetSingleFunction = Callable[[GetSingleParameter], Awaitable[GetSingleResult]]
|
57
53
|
|
58
|
-
|
54
|
+
# * Create or Update
|
59
55
|
CreateOrUpdateResult = Union[
|
60
56
|
BaseClientServiceResultsTransfers.Fail,
|
61
|
-
BaseClientServiceResultsTransfers.SingleData
|
57
|
+
BaseClientServiceResultsTransfers.SingleData,
|
62
58
|
]
|
63
59
|
|
64
|
-
|
60
|
+
# * Status Update
|
65
61
|
StatusUpdateResult = Union[
|
66
62
|
BaseClientServiceResultsTransfers.Fail,
|
67
|
-
BaseClientServiceResultsTransfers.SingleData
|
68
|
-
]
|
63
|
+
BaseClientServiceResultsTransfers.SingleData,
|
64
|
+
]
|
@@ -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 BaseEncryptionResultsTypes:
|
6
7
|
AES = MaleoFoundationAESEncryptionResultsTransfers
|
7
|
-
RSA = MaleoFoundationRSAEncryptionResultsTransfers
|
8
|
+
RSA = MaleoFoundationRSAEncryptionResultsTransfers
|
@@ -1,14 +1,16 @@
|
|
1
1
|
from typing import Union
|
2
|
-
from maleo_foundation.models.transfers.results.encryption.aes
|
3
|
-
|
2
|
+
from maleo_foundation.models.transfers.results.encryption.aes import (
|
3
|
+
MaleoFoundationAESEncryptionResultsTransfers,
|
4
|
+
)
|
5
|
+
|
4
6
|
|
5
7
|
class MaleoFoundationAESEncryptionResultsTypes:
|
6
8
|
Encrypt = Union[
|
7
9
|
MaleoFoundationAESEncryptionResultsTransfers.Fail,
|
8
|
-
MaleoFoundationAESEncryptionResultsTransfers.Encrypt
|
10
|
+
MaleoFoundationAESEncryptionResultsTransfers.Encrypt,
|
9
11
|
]
|
10
12
|
|
11
13
|
Decrypt = Union[
|
12
14
|
MaleoFoundationAESEncryptionResultsTransfers.Fail,
|
13
|
-
MaleoFoundationAESEncryptionResultsTransfers.Decrypt
|
14
|
-
]
|
15
|
+
MaleoFoundationAESEncryptionResultsTransfers.Decrypt,
|
16
|
+
]
|
@@ -1,14 +1,16 @@
|
|
1
1
|
from typing import Union
|
2
|
-
from maleo_foundation.models.transfers.results.encryption.rsa
|
3
|
-
|
2
|
+
from maleo_foundation.models.transfers.results.encryption.rsa import (
|
3
|
+
MaleoFoundationRSAEncryptionResultsTransfers,
|
4
|
+
)
|
5
|
+
|
4
6
|
|
5
7
|
class MaleoFoundationRSAEncryptionResultsTypes:
|
6
8
|
Encrypt = Union[
|
7
9
|
MaleoFoundationRSAEncryptionResultsTransfers.Fail,
|
8
|
-
MaleoFoundationRSAEncryptionResultsTransfers.Encrypt
|
10
|
+
MaleoFoundationRSAEncryptionResultsTransfers.Encrypt,
|
9
11
|
]
|
10
12
|
|
11
13
|
Decrypt = Union[
|
12
14
|
MaleoFoundationRSAEncryptionResultsTransfers.Fail,
|
13
|
-
MaleoFoundationRSAEncryptionResultsTransfers.Decrypt
|
14
|
-
]
|
15
|
+
MaleoFoundationRSAEncryptionResultsTransfers.Decrypt,
|
16
|
+
]
|
@@ -1,19 +1,21 @@
|
|
1
1
|
from typing import Callable, List, Optional
|
2
2
|
from maleo_foundation.types import BaseTypes
|
3
|
-
from maleo_foundation.models.transfers.parameters.general
|
4
|
-
|
3
|
+
from maleo_foundation.models.transfers.parameters.general import (
|
4
|
+
BaseGeneralParametersTransfers,
|
5
|
+
)
|
6
|
+
|
5
7
|
|
6
8
|
class BaseGeneralExpandedTypes:
|
7
|
-
|
9
|
+
# * Expansion processor related types
|
8
10
|
FieldExpansionProcessor = Callable[
|
9
11
|
[BaseGeneralParametersTransfers.FieldExpansionProcessor],
|
10
|
-
BaseTypes.ListOrDictOfAny
|
12
|
+
BaseTypes.ListOrDictOfAny,
|
11
13
|
]
|
12
14
|
|
13
15
|
ListOfFieldExpansionProcessor = List[
|
14
16
|
Callable[
|
15
17
|
[BaseGeneralParametersTransfers.FieldExpansionProcessor],
|
16
|
-
BaseTypes.ListOrDictOfAny
|
18
|
+
BaseTypes.ListOrDictOfAny,
|
17
19
|
]
|
18
20
|
]
|
19
21
|
|
@@ -21,21 +23,21 @@ class BaseGeneralExpandedTypes:
|
|
21
23
|
List[
|
22
24
|
Callable[
|
23
25
|
[BaseGeneralParametersTransfers.FieldExpansionProcessor],
|
24
|
-
BaseTypes.ListOrDictOfAny
|
26
|
+
BaseTypes.ListOrDictOfAny,
|
25
27
|
]
|
26
28
|
]
|
27
29
|
]
|
28
30
|
|
29
|
-
|
31
|
+
# * Modification processor related types
|
30
32
|
FieldModificationProcessor = Callable[
|
31
33
|
[BaseGeneralParametersTransfers.FieldModificationProcessor],
|
32
|
-
BaseTypes.ListOrDictOfAny
|
34
|
+
BaseTypes.ListOrDictOfAny,
|
33
35
|
]
|
34
36
|
|
35
37
|
ListOfFieldModificationProcessor = List[
|
36
38
|
Callable[
|
37
39
|
[BaseGeneralParametersTransfers.FieldModificationProcessor],
|
38
|
-
BaseTypes.ListOrDictOfAny
|
40
|
+
BaseTypes.ListOrDictOfAny,
|
39
41
|
]
|
40
42
|
]
|
41
43
|
|
@@ -43,7 +45,7 @@ class BaseGeneralExpandedTypes:
|
|
43
45
|
List[
|
44
46
|
Callable[
|
45
47
|
[BaseGeneralParametersTransfers.FieldModificationProcessor],
|
46
|
-
BaseTypes.ListOrDictOfAny
|
48
|
+
BaseTypes.ListOrDictOfAny,
|
47
49
|
]
|
48
50
|
]
|
49
|
-
]
|
51
|
+
]
|
@@ -1,14 +1,16 @@
|
|
1
1
|
from typing import Union
|
2
|
-
from maleo_foundation.models.transfers.results.hash
|
3
|
-
|
2
|
+
from maleo_foundation.models.transfers.results.hash import (
|
3
|
+
MaleoFoundationHashResultsTransfers,
|
4
|
+
)
|
5
|
+
|
4
6
|
|
5
7
|
class MaleoFoundationHashResultsTypes:
|
6
8
|
Hash = Union[
|
7
9
|
MaleoFoundationHashResultsTransfers.Fail,
|
8
|
-
MaleoFoundationHashResultsTransfers.Hash
|
10
|
+
MaleoFoundationHashResultsTransfers.Hash,
|
9
11
|
]
|
10
12
|
|
11
13
|
Verify = Union[
|
12
14
|
MaleoFoundationHashResultsTransfers.Fail,
|
13
|
-
MaleoFoundationHashResultsTransfers.Verify
|
14
|
-
]
|
15
|
+
MaleoFoundationHashResultsTransfers.Verify,
|
16
|
+
]
|
@@ -1,19 +1,21 @@
|
|
1
1
|
from typing import Union
|
2
|
-
from maleo_foundation.models.transfers.results.key
|
3
|
-
|
2
|
+
from maleo_foundation.models.transfers.results.key import (
|
3
|
+
MaleoFoundationKeyResultsTransfers,
|
4
|
+
)
|
5
|
+
|
4
6
|
|
5
7
|
class MaleoFoundationKeyResultsTypes:
|
6
8
|
CreatePrivate = Union[
|
7
9
|
MaleoFoundationKeyResultsTransfers.Fail,
|
8
|
-
MaleoFoundationKeyResultsTransfers.CreatePrivate
|
10
|
+
MaleoFoundationKeyResultsTransfers.CreatePrivate,
|
9
11
|
]
|
10
12
|
|
11
13
|
CreatePublic = Union[
|
12
14
|
MaleoFoundationKeyResultsTransfers.Fail,
|
13
|
-
MaleoFoundationKeyResultsTransfers.CreatePublic
|
15
|
+
MaleoFoundationKeyResultsTransfers.CreatePublic,
|
14
16
|
]
|
15
17
|
|
16
18
|
CreatePair = Union[
|
17
19
|
MaleoFoundationKeyResultsTransfers.Fail,
|
18
|
-
MaleoFoundationKeyResultsTransfers.CreatePair
|
19
|
-
]
|
20
|
+
MaleoFoundationKeyResultsTransfers.CreatePair,
|
21
|
+
]
|
@@ -1,68 +1,64 @@
|
|
1
1
|
from typing import Awaitable, Callable, Union
|
2
|
-
from maleo_foundation.models.transfers.parameters.general
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
from maleo_foundation.models.transfers.parameters.general import (
|
3
|
+
BaseGeneralParametersTransfers,
|
4
|
+
)
|
5
|
+
from maleo_foundation.models.transfers.parameters.service import (
|
6
|
+
BaseServiceParametersTransfers,
|
7
|
+
)
|
8
|
+
from maleo_foundation.models.transfers.results.service.general import (
|
9
|
+
BaseServiceGeneralResultsTransfers,
|
10
|
+
)
|
11
|
+
|
8
12
|
|
9
13
|
class ExpandedServiceTypes:
|
10
|
-
|
11
|
-
GetUnpaginatedMultipleParameter =
|
14
|
+
# * Unpaginated multiple data
|
15
|
+
GetUnpaginatedMultipleParameter = (
|
16
|
+
BaseServiceParametersTransfers.GetUnpaginatedMultiple
|
17
|
+
)
|
12
18
|
GetUnpaginatedMultipleResult = Union[
|
13
19
|
BaseServiceGeneralResultsTransfers.Fail,
|
14
20
|
BaseServiceGeneralResultsTransfers.NoData,
|
15
|
-
BaseServiceGeneralResultsTransfers.UnpaginatedMultipleData
|
21
|
+
BaseServiceGeneralResultsTransfers.UnpaginatedMultipleData,
|
16
22
|
]
|
17
23
|
SyncGetUnpaginatedMultipleFunction = Callable[
|
18
|
-
[GetUnpaginatedMultipleParameter],
|
19
|
-
GetUnpaginatedMultipleResult
|
24
|
+
[GetUnpaginatedMultipleParameter], GetUnpaginatedMultipleResult
|
20
25
|
]
|
21
26
|
AsyncGetUnpaginatedMultipleFunction = Callable[
|
22
|
-
[GetUnpaginatedMultipleParameter],
|
23
|
-
Awaitable[GetUnpaginatedMultipleResult]
|
27
|
+
[GetUnpaginatedMultipleParameter], Awaitable[GetUnpaginatedMultipleResult]
|
24
28
|
]
|
25
29
|
|
26
|
-
|
30
|
+
# * Paginated multiple data
|
27
31
|
GetPaginatedMultipleParameter = BaseServiceParametersTransfers.GetPaginatedMultiple
|
28
32
|
GetPaginatedMultipleResult = Union[
|
29
33
|
BaseServiceGeneralResultsTransfers.Fail,
|
30
34
|
BaseServiceGeneralResultsTransfers.NoData,
|
31
|
-
BaseServiceGeneralResultsTransfers.PaginatedMultipleData
|
35
|
+
BaseServiceGeneralResultsTransfers.PaginatedMultipleData,
|
32
36
|
]
|
33
37
|
SyncGetPaginatedMultipleFunction = Callable[
|
34
|
-
[GetPaginatedMultipleParameter],
|
35
|
-
GetPaginatedMultipleResult
|
38
|
+
[GetPaginatedMultipleParameter], GetPaginatedMultipleResult
|
36
39
|
]
|
37
40
|
AsyncGetPaginatedMultipleFunction = Callable[
|
38
|
-
[GetPaginatedMultipleParameter],
|
39
|
-
Awaitable[GetPaginatedMultipleResult]
|
41
|
+
[GetPaginatedMultipleParameter], Awaitable[GetPaginatedMultipleResult]
|
40
42
|
]
|
41
43
|
|
42
|
-
|
44
|
+
# * Single data
|
43
45
|
GetSingleParameter = BaseGeneralParametersTransfers.GetSingle
|
44
46
|
GetSingleResult = Union[
|
45
47
|
BaseServiceGeneralResultsTransfers.Fail,
|
46
48
|
BaseServiceGeneralResultsTransfers.NoData,
|
47
|
-
BaseServiceGeneralResultsTransfers.SingleData
|
48
|
-
]
|
49
|
-
SyncGetSingleFunction = Callable[
|
50
|
-
[GetSingleParameter],
|
51
|
-
GetSingleResult
|
52
|
-
]
|
53
|
-
AsyncGetSingleFunction = Callable[
|
54
|
-
[GetSingleParameter],
|
55
|
-
Awaitable[GetSingleResult]
|
49
|
+
BaseServiceGeneralResultsTransfers.SingleData,
|
56
50
|
]
|
51
|
+
SyncGetSingleFunction = Callable[[GetSingleParameter], GetSingleResult]
|
52
|
+
AsyncGetSingleFunction = Callable[[GetSingleParameter], Awaitable[GetSingleResult]]
|
57
53
|
|
58
|
-
|
54
|
+
# * Create or Update
|
59
55
|
CreateOrUpdateResult = Union[
|
60
56
|
BaseServiceGeneralResultsTransfers.Fail,
|
61
|
-
BaseServiceGeneralResultsTransfers.SingleData
|
57
|
+
BaseServiceGeneralResultsTransfers.SingleData,
|
62
58
|
]
|
63
59
|
|
64
|
-
|
60
|
+
# * Status update
|
65
61
|
StatusUpdateResult = Union[
|
66
62
|
BaseServiceGeneralResultsTransfers.Fail,
|
67
|
-
BaseServiceGeneralResultsTransfers.SingleData
|
68
|
-
]
|
63
|
+
BaseServiceGeneralResultsTransfers.SingleData,
|
64
|
+
]
|
@@ -1,14 +1,16 @@
|
|
1
1
|
from typing import Union
|
2
|
-
from maleo_foundation.models.transfers.results.signature
|
3
|
-
|
2
|
+
from maleo_foundation.models.transfers.results.signature import (
|
3
|
+
MaleoFoundationSignatureResultsTransfers,
|
4
|
+
)
|
5
|
+
|
4
6
|
|
5
7
|
class MaleoFoundationSignatureResultsTypes:
|
6
8
|
Sign = Union[
|
7
9
|
MaleoFoundationSignatureResultsTransfers.Fail,
|
8
|
-
MaleoFoundationSignatureResultsTransfers.Sign
|
10
|
+
MaleoFoundationSignatureResultsTransfers.Sign,
|
9
11
|
]
|
10
12
|
|
11
13
|
Verify = Union[
|
12
14
|
MaleoFoundationSignatureResultsTransfers.Fail,
|
13
|
-
MaleoFoundationSignatureResultsTransfers.Verify
|
14
|
-
]
|
15
|
+
MaleoFoundationSignatureResultsTransfers.Verify,
|
16
|
+
]
|
@@ -1,14 +1,16 @@
|
|
1
1
|
from typing import Union
|
2
|
-
from maleo_foundation.models.transfers.results.token
|
3
|
-
|
2
|
+
from maleo_foundation.models.transfers.results.token import (
|
3
|
+
MaleoFoundationTokenResultsTransfers,
|
4
|
+
)
|
5
|
+
|
4
6
|
|
5
7
|
class MaleoFoundationTokenResultsTypes:
|
6
8
|
Encode = Union[
|
7
9
|
MaleoFoundationTokenResultsTransfers.Fail,
|
8
|
-
MaleoFoundationTokenResultsTransfers.Encode
|
10
|
+
MaleoFoundationTokenResultsTransfers.Encode,
|
9
11
|
]
|
10
12
|
|
11
13
|
Decode = Union[
|
12
14
|
MaleoFoundationTokenResultsTransfers.Fail,
|
13
|
-
MaleoFoundationTokenResultsTransfers.Decode
|
14
|
-
]
|
15
|
+
MaleoFoundationTokenResultsTransfers.Decode,
|
16
|
+
]
|
@@ -1,9 +1,10 @@
|
|
1
1
|
from typing import List
|
2
2
|
from maleo_foundation.models.schemas.general import BaseGeneralSchemas
|
3
3
|
|
4
|
+
|
4
5
|
class ExtendedTypes:
|
5
|
-
|
6
|
+
# * DateFilter-related types
|
6
7
|
ListOfDateFilters = List[BaseGeneralSchemas.DateFilter]
|
7
8
|
|
8
|
-
|
9
|
-
ListOfSortColumns = List[BaseGeneralSchemas.SortColumn]
|
9
|
+
# * SortColumn-related types
|
10
|
+
ListOfSortColumns = List[BaseGeneralSchemas.SortColumn]
|
@@ -2,7 +2,8 @@ from __future__ import annotations
|
|
2
2
|
from pydantic import BaseModel, ConfigDict, Field
|
3
3
|
from redis.asyncio.client import Redis
|
4
4
|
|
5
|
+
|
5
6
|
class CacheManagers(BaseModel):
|
6
7
|
model_config = ConfigDict(arbitrary_types_allowed=True)
|
7
8
|
|
8
|
-
redis:Redis = Field(..., description="Redis client")
|
9
|
+
redis: Redis = Field(..., description="Redis client")
|
@@ -5,17 +5,21 @@ from typing import AsyncGenerator, Generator
|
|
5
5
|
from maleo_foundation.types import BaseTypes
|
6
6
|
from maleo_foundation.utils.logging import ClientLogger, SimpleConfig
|
7
7
|
|
8
|
+
|
8
9
|
class BearerAuth(httpx.Auth):
|
9
10
|
def __init__(self, token: str) -> None:
|
10
11
|
self._auth_header = self._build_auth_header(token)
|
11
12
|
|
12
|
-
def auth_flow(
|
13
|
+
def auth_flow(
|
14
|
+
self, request: httpx.Request
|
15
|
+
) -> Generator[httpx.Request, httpx.Response, None]:
|
13
16
|
request.headers["Authorization"] = self._auth_header
|
14
17
|
yield request
|
15
18
|
|
16
19
|
def _build_auth_header(self, token: str) -> str:
|
17
20
|
return f"Bearer {token}"
|
18
21
|
|
22
|
+
|
19
23
|
class ClientHTTPControllerManager:
|
20
24
|
def __init__(self, url: str) -> None:
|
21
25
|
self._client = httpx.AsyncClient()
|
@@ -23,7 +27,9 @@ class ClientHTTPControllerManager:
|
|
23
27
|
|
24
28
|
async def _client_handler(self) -> AsyncGenerator[httpx.AsyncClient, None]:
|
25
29
|
"""Reusable generator for client handling."""
|
26
|
-
if self._client is None or (
|
30
|
+
if self._client is None or (
|
31
|
+
self._client is not None and self._client.is_closed
|
32
|
+
):
|
27
33
|
self._client = httpx.AsyncClient()
|
28
34
|
yield self._client
|
29
35
|
|
@@ -50,30 +56,35 @@ class ClientHTTPControllerManager:
|
|
50
56
|
async def dispose(self) -> None:
|
51
57
|
await self._client.aclose()
|
52
58
|
|
59
|
+
|
53
60
|
class ClientControllerManagers(BaseModel):
|
54
61
|
model_config = ConfigDict(arbitrary_types_allowed=True)
|
55
62
|
|
56
|
-
http:ClientHTTPControllerManager = Field(..., description="HTTP Client Controller")
|
63
|
+
http: ClientHTTPControllerManager = Field(..., description="HTTP Client Controller")
|
64
|
+
|
57
65
|
|
58
66
|
class ClientHTTPController:
|
59
|
-
def __init__(self, manager:ClientHTTPControllerManager):
|
67
|
+
def __init__(self, manager: ClientHTTPControllerManager):
|
60
68
|
self._manager = manager
|
61
69
|
|
62
70
|
@property
|
63
71
|
def manager(self) -> ClientHTTPControllerManager:
|
64
72
|
return self._manager
|
65
73
|
|
74
|
+
|
66
75
|
class ClientServiceControllers(BaseModel):
|
67
76
|
model_config = ConfigDict(arbitrary_types_allowed=True)
|
68
77
|
|
69
|
-
http:ClientHTTPController = Field(..., description="HTTP Client Controller")
|
78
|
+
http: ClientHTTPController = Field(..., description="HTTP Client Controller")
|
79
|
+
|
70
80
|
|
71
81
|
class ClientControllers(BaseModel):
|
72
82
|
model_config = ConfigDict(arbitrary_types_allowed=True)
|
73
|
-
|
83
|
+
# * Reuse this class while also adding all controllers of the client
|
84
|
+
|
74
85
|
|
75
86
|
class ClientService:
|
76
|
-
def __init__(self, logger:ClientLogger):
|
87
|
+
def __init__(self, logger: ClientLogger):
|
77
88
|
self._logger = logger
|
78
89
|
|
79
90
|
@property
|
@@ -84,9 +95,11 @@ class ClientService:
|
|
84
95
|
def logger(self) -> ClientLogger:
|
85
96
|
return self._logger
|
86
97
|
|
98
|
+
|
87
99
|
class ClientServices(BaseModel):
|
88
100
|
model_config = ConfigDict(arbitrary_types_allowed=True)
|
89
|
-
|
101
|
+
# * Reuse this class while also adding all the services of the client
|
102
|
+
|
90
103
|
|
91
104
|
class ClientManager:
|
92
105
|
def __init__(
|
@@ -94,7 +107,7 @@ class ClientManager:
|
|
94
107
|
key: str,
|
95
108
|
name: str,
|
96
109
|
log_config: SimpleConfig,
|
97
|
-
service_key: BaseTypes.OptionalString = None
|
110
|
+
service_key: BaseTypes.OptionalString = None,
|
98
111
|
) -> None:
|
99
112
|
self._key = key
|
100
113
|
self._name = name
|
@@ -107,7 +120,7 @@ class ClientManager:
|
|
107
120
|
self._logger = ClientLogger(
|
108
121
|
client_key=self._key,
|
109
122
|
service_key=self._service_key,
|
110
|
-
**self._log_config.model_dump()
|
123
|
+
**self._log_config.model_dump(),
|
111
124
|
)
|
112
125
|
|
113
126
|
@property
|
@@ -123,7 +136,7 @@ class ClientManager:
|
|
123
136
|
return self._logger
|
124
137
|
|
125
138
|
def _initialize_services(self) -> None:
|
126
|
-
|
139
|
+
# * Initialize services
|
127
140
|
#! This initialied an empty services. Extend this function in the actual class to initialize all services.
|
128
141
|
self._services = ClientServices()
|
129
142
|
|
@@ -137,4 +150,4 @@ class ClientManager:
|
|
137
150
|
|
138
151
|
@property
|
139
152
|
def client(self):
|
140
|
-
raise NotImplementedError()
|
153
|
+
raise NotImplementedError()
|