maleo-foundation 0.2.24__py3-none-any.whl → 0.2.26__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/enums.py +3 -2
- maleo_foundation/expanded_types/__init__.py +2 -2
- maleo_foundation/expanded_types/query.py +16 -16
- maleo_foundation/expanded_types/repository.py +0 -0
- maleo_foundation/models/transfers/results/service/__init__.py +0 -2
- maleo_foundation/utils/exceptions.py +0 -31
- {maleo_foundation-0.2.24.dist-info → maleo_foundation-0.2.26.dist-info}/METADATA +1 -1
- {maleo_foundation-0.2.24.dist-info → maleo_foundation-0.2.26.dist-info}/RECORD +10 -10
- maleo_foundation/models/transfers/results/service/query.py +0 -51
- {maleo_foundation-0.2.24.dist-info → maleo_foundation-0.2.26.dist-info}/WHEEL +0 -0
- {maleo_foundation-0.2.24.dist-info → maleo_foundation-0.2.26.dist-info}/top_level.txt +0 -0
maleo_foundation/enums.py
CHANGED
@@ -120,6 +120,7 @@ class BaseEnums:
|
|
120
120
|
TTL_6HR = int(6*60*60)
|
121
121
|
TTL_12HR = int(12*60*60)
|
122
122
|
TTL_1DY = int(1*24*60*60)
|
123
|
-
|
123
|
+
TTL_3DY = int(3*24*60*60)
|
124
124
|
TTL_1WK = int(1*24*60*60)
|
125
|
-
|
125
|
+
TTL_2WK = int(2*24*60*60)
|
126
|
+
TTL_1MO = int(1*30*24*60*60)
|
@@ -1,11 +1,11 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
from .general import BaseGeneralExpandedTypes
|
3
|
-
from .
|
3
|
+
from .repository import ExpandedRepositoryTypes
|
4
4
|
from .service import ExpandedServiceTypes
|
5
5
|
from .client import ExpandedClientTypes
|
6
6
|
|
7
7
|
class BaseExpandedTypes:
|
8
8
|
General = BaseGeneralExpandedTypes
|
9
|
-
|
9
|
+
Repository = ExpandedRepositoryTypes
|
10
10
|
Service = ExpandedServiceTypes
|
11
11
|
Client = ExpandedClientTypes
|
@@ -3,16 +3,16 @@ from maleo_foundation.models.transfers.parameters.general \
|
|
3
3
|
import BaseGeneralParametersTransfers
|
4
4
|
from maleo_foundation.models.transfers.parameters.service \
|
5
5
|
import BaseServiceParametersTransfers
|
6
|
-
from maleo_foundation.models.transfers.results.service.
|
7
|
-
import
|
6
|
+
from maleo_foundation.models.transfers.results.service.repository \
|
7
|
+
import BaseServiceRepositoryResultsTransfers
|
8
8
|
|
9
|
-
class
|
9
|
+
class ExpandedRepositoryTypes:
|
10
10
|
#* Unpaginated multiple data
|
11
11
|
GetUnpaginatedMultipleParameter = BaseServiceParametersTransfers.GetUnpaginatedMultiple
|
12
12
|
GetUnpaginatedMultipleResult = Union[
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
BaseServiceRepositoryResultsTransfers.Fail,
|
14
|
+
BaseServiceRepositoryResultsTransfers.NoData,
|
15
|
+
BaseServiceRepositoryResultsTransfers.UnpaginatedMultipleData
|
16
16
|
]
|
17
17
|
SyncGetUnpaginatedMultipleFunction = Callable[
|
18
18
|
[GetUnpaginatedMultipleParameter],
|
@@ -26,9 +26,9 @@ class ExpandedQueryTypes:
|
|
26
26
|
#* Paginated multiple data
|
27
27
|
GetPaginatedMultipleParameter = BaseServiceParametersTransfers.GetPaginatedMultiple
|
28
28
|
GetPaginatedMultipleResult = Union[
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
BaseServiceRepositoryResultsTransfers.Fail,
|
30
|
+
BaseServiceRepositoryResultsTransfers.NoData,
|
31
|
+
BaseServiceRepositoryResultsTransfers.PaginatedMultipleData
|
32
32
|
]
|
33
33
|
SyncGetPaginatedMultipleFunction = Callable[
|
34
34
|
[GetPaginatedMultipleParameter],
|
@@ -42,9 +42,9 @@ class ExpandedQueryTypes:
|
|
42
42
|
#* Single data
|
43
43
|
GetSingleParameter = BaseGeneralParametersTransfers.GetSingle
|
44
44
|
GetSingleResult = Union[
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
BaseServiceRepositoryResultsTransfers.Fail,
|
46
|
+
BaseServiceRepositoryResultsTransfers.NoData,
|
47
|
+
BaseServiceRepositoryResultsTransfers.SingleData
|
48
48
|
]
|
49
49
|
SyncGetSingleFunction = Callable[
|
50
50
|
[GetSingleParameter],
|
@@ -57,12 +57,12 @@ class ExpandedQueryTypes:
|
|
57
57
|
|
58
58
|
#* Create or Update
|
59
59
|
CreateOrUpdateResult = Union[
|
60
|
-
|
61
|
-
|
60
|
+
BaseServiceRepositoryResultsTransfers.Fail,
|
61
|
+
BaseServiceRepositoryResultsTransfers.SingleData
|
62
62
|
]
|
63
63
|
|
64
64
|
#* Status update
|
65
65
|
StatusUpdateResult = Union[
|
66
|
-
|
67
|
-
|
66
|
+
BaseServiceRepositoryResultsTransfers.Fail,
|
67
|
+
BaseServiceRepositoryResultsTransfers.SingleData
|
68
68
|
]
|
File without changes
|
@@ -1,11 +1,9 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
from .general import BaseServiceGeneralResultsTransfers
|
3
|
-
from .query import BaseServiceQueryResultsTransfers
|
4
3
|
from .repository import BaseServiceRepositoryResultsTransfers
|
5
4
|
from .controllers import BaseServiceControllerResultsTransfers
|
6
5
|
|
7
6
|
class BaseServiceResultsTransfers:
|
8
7
|
General = BaseServiceGeneralResultsTransfers
|
9
|
-
Query = BaseServiceQueryResultsTransfers
|
10
8
|
Repository = BaseServiceRepositoryResultsTransfers
|
11
9
|
Controller = BaseServiceControllerResultsTransfers
|
@@ -10,8 +10,6 @@ from typing import Optional
|
|
10
10
|
from maleo_foundation.models.responses import BaseResponses
|
11
11
|
from maleo_foundation.models.transfers.results.service.general \
|
12
12
|
import BaseServiceGeneralResultsTransfers
|
13
|
-
from maleo_foundation.models.transfers.results.service.query \
|
14
|
-
import BaseServiceQueryResultsTransfers
|
15
13
|
from maleo_foundation.models.transfers.results.service.repository \
|
16
14
|
import BaseServiceRepositoryResultsTransfers
|
17
15
|
from maleo_foundation.utils.logging import BaseLogger
|
@@ -44,35 +42,6 @@ class BaseExceptions:
|
|
44
42
|
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR
|
45
43
|
)
|
46
44
|
|
47
|
-
@staticmethod
|
48
|
-
def database_exception_handler(
|
49
|
-
operation:str,
|
50
|
-
logger:Optional[BaseLogger] = None,
|
51
|
-
fail_result_class:type[BaseServiceQueryResultsTransfers.Fail] = BaseServiceQueryResultsTransfers.Fail
|
52
|
-
):
|
53
|
-
"""Decorator to handle database-related exceptions consistently."""
|
54
|
-
def decorator(func):
|
55
|
-
@wraps(func)
|
56
|
-
def wrapper(*args, **kwargs):
|
57
|
-
try:
|
58
|
-
return func(*args, **kwargs)
|
59
|
-
except SQLAlchemyError as e:
|
60
|
-
logger.error("Database error occurred while %s: '%s'", operation, str(e), exc_info=True)
|
61
|
-
return fail_result_class(
|
62
|
-
message=f"Failed {operation}",
|
63
|
-
description=f"A database error occurred while {operation}. Please try again later or contact administrator.",
|
64
|
-
other="Database operation failed"
|
65
|
-
)
|
66
|
-
except Exception as e:
|
67
|
-
logger.error("Unexpected error occurred while %s: '%s'", operation, str(e), exc_info=True)
|
68
|
-
return fail_result_class(
|
69
|
-
message=f"Failed {operation}",
|
70
|
-
description=f"An unexpected error occurred while {operation}. Please try again later or contact administrator.",
|
71
|
-
other="Internal processing error"
|
72
|
-
)
|
73
|
-
return wrapper
|
74
|
-
return decorator
|
75
|
-
|
76
45
|
@staticmethod
|
77
46
|
def repository_exception_handler(
|
78
47
|
operation:str,
|
@@ -2,7 +2,7 @@ maleo_foundation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
|
|
2
2
|
maleo_foundation/authentication.py,sha256=kJfuRKgQY5cjmn0r36z4a4jF4bg7UifZ9D9mgMMnTsw,1840
|
3
3
|
maleo_foundation/authorization.py,sha256=euq24UEhTaimmM24Ies-kZF1zqVwM_x0Zox_6k7zyqI,281
|
4
4
|
maleo_foundation/constants.py,sha256=aBmEfWlBqZxi0k-n6h2NM1YRLOjMnheEiLyQcjP-zCQ,1164
|
5
|
-
maleo_foundation/enums.py,sha256=
|
5
|
+
maleo_foundation/enums.py,sha256=OLVgb0rKk2gfG19FEyq9YGrQcmovr_FgtGFUcIu23Lo,3596
|
6
6
|
maleo_foundation/extended_types.py,sha256=pIKt-_9tby4rmune3fmWcCW_mohaNRh_1lywBmdc-L4,301
|
7
7
|
maleo_foundation/types.py,sha256=aKXnIgEhYGSfFqNMGLc4qIKGkINBRpkOo9R9cb2CbwI,2414
|
8
8
|
maleo_foundation/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -18,12 +18,13 @@ maleo_foundation/client/services/hash/__init__.py,sha256=A4Olb-RpeNFQEfToU9t8LfZ
|
|
18
18
|
maleo_foundation/client/services/hash/bcrypt.py,sha256=Lc2FGR2oQj5yuq4mHer5NnFjhw-IuPuBp_EijLsOaCk,2231
|
19
19
|
maleo_foundation/client/services/hash/hmac.py,sha256=-L0sTv5tcmfu-UyBD_InpxFJ2w738M76HYmeRg30Yao,2358
|
20
20
|
maleo_foundation/client/services/hash/sha256.py,sha256=af08036kkEZ61IY_ktxwHmQnAACd6hWXYA_ZC9S1-tg,2142
|
21
|
-
maleo_foundation/expanded_types/__init__.py,sha256=
|
21
|
+
maleo_foundation/expanded_types/__init__.py,sha256=Jz2NoY9609QIM84UonmJU-10CMUR9t9fkk9ZFLnU7Js,384
|
22
22
|
maleo_foundation/expanded_types/client.py,sha256=WvT911cDsfWtCCYVaDeQ90ba_eCYnzC-CRSXCHtLIuo,2414
|
23
23
|
maleo_foundation/expanded_types/general.py,sha256=_nSG5jgMgA1ntjBdVjQqkg0h1WNytLsIqkUrsKDmrfU,832
|
24
24
|
maleo_foundation/expanded_types/hash.py,sha256=QOH_HczGY7CRUZJ5gC84RunCAiUzNSt7DYXI7uqtwkM,416
|
25
25
|
maleo_foundation/expanded_types/key.py,sha256=qopQcO6V82RxiCtixe--IBce5MRT4buOun4RSA-LLm0,573
|
26
|
-
maleo_foundation/expanded_types/query.py,sha256=
|
26
|
+
maleo_foundation/expanded_types/query.py,sha256=hemtQGDqSQO8N4_y7pktXqBlrcDacs4EiUZ3hFk4n2o,2482
|
27
|
+
maleo_foundation/expanded_types/repository.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
27
28
|
maleo_foundation/expanded_types/service.py,sha256=9LxwJHSBTgqOGD2CiV3gsRp1EbLB793jrTNGgCtrbjk,2434
|
28
29
|
maleo_foundation/expanded_types/signature.py,sha256=RgMU7MHADfVwSlGezjBcHXJiPwfnJb5ovuJ93qFRps0,451
|
29
30
|
maleo_foundation/expanded_types/token.py,sha256=xsy2F8Mzba1sPztBHL9J3DWv79QP8P3vqPwXahEG5mA,427
|
@@ -90,15 +91,14 @@ maleo_foundation/models/transfers/results/client/controllers/http.py,sha256=vhjf
|
|
90
91
|
maleo_foundation/models/transfers/results/encryption/__init__.py,sha256=Uo8lKBcjlvtCjgPk4sz44GY_fjG3QooatbVYBDFwF8g,307
|
91
92
|
maleo_foundation/models/transfers/results/encryption/aes.py,sha256=yx3hZNhge2lfj8qNM-u9poFs1Ex926ZItOPZJUCFa4c,828
|
92
93
|
maleo_foundation/models/transfers/results/encryption/rsa.py,sha256=hlCtiT1TZwmMBEn-sgGs-WocNEmJ4qxWcHS5y9m7Voc,683
|
93
|
-
maleo_foundation/models/transfers/results/service/__init__.py,sha256=
|
94
|
+
maleo_foundation/models/transfers/results/service/__init__.py,sha256=qKCJTtuLJeda-xrRL99OVdZR91PLFK1JyYVItjreLbQ,410
|
94
95
|
maleo_foundation/models/transfers/results/service/general.py,sha256=-4VE7mV103nQIRRxIy_dGIU6XDe_wiMgrCFJJ6eXUMM,1540
|
95
|
-
maleo_foundation/models/transfers/results/service/query.py,sha256=xHHPWCYx6NrKK9I88S2T-PKOndsWib4GWiiTKheLzZo,1867
|
96
96
|
maleo_foundation/models/transfers/results/service/repository.py,sha256=xz9RakOBEbtdGnnK0fM4KVZOL-AjRsaIE9J3TQqkIBo,1887
|
97
97
|
maleo_foundation/models/transfers/results/service/controllers/__init__.py,sha256=HZJWMy2dskzOCzLmp_UaL9rjbQ-sDMI7sd2bXb-4QOU,175
|
98
98
|
maleo_foundation/models/transfers/results/service/controllers/rest.py,sha256=wCuFyOTQkuBs2cqjPsWnPy0XIsCfMqGByhrSy57qp7Y,1107
|
99
99
|
maleo_foundation/utils/__init__.py,sha256=SRPEVoqjZoO6W8rtF_Ti8VIangg6Auwm6eHbZMdOthY,520
|
100
100
|
maleo_foundation/utils/controller.py,sha256=3n9HcWHqywLhfpgTkzd_NrjWNJgTwGBSokqGgJKeBAU,4132
|
101
|
-
maleo_foundation/utils/exceptions.py,sha256=
|
101
|
+
maleo_foundation/utils/exceptions.py,sha256=kDLTWiUauvc-fSKrEyxlGvIi2NtZIAhJ9bV3OXnpTyo,6253
|
102
102
|
maleo_foundation/utils/extractor.py,sha256=SZXVYDHWGaA-Dd1BUydwF2HHdZqexEielS4CjL0Ceng,814
|
103
103
|
maleo_foundation/utils/logging.py,sha256=W5Fhk_xAXVqSujaY8mv3hRH4wlQSpUn4ReuMoiKcQa4,7759
|
104
104
|
maleo_foundation/utils/mergers.py,sha256=DniUu3Ot4qkYH_YSw4uD1cn9cfirum4S_Opp8fMkQwA,702
|
@@ -115,7 +115,7 @@ maleo_foundation/utils/loaders/credential/__init__.py,sha256=qopTKvcMVoTFwyRijeg
|
|
115
115
|
maleo_foundation/utils/loaders/credential/google.py,sha256=SKsqPuFnAiCcYLf24CxKnMybhVHpgqnq1gGSlThqjts,994
|
116
116
|
maleo_foundation/utils/loaders/key/__init__.py,sha256=hVygcC2ImHc_aVrSrOmyedR8tMUZokWUKCKOSh5ctbo,106
|
117
117
|
maleo_foundation/utils/loaders/key/rsa.py,sha256=gDhyX6iTFtHiluuhFCozaZ3pOLKU2Y9TlrNMK_GVyGU,3796
|
118
|
-
maleo_foundation-0.2.
|
119
|
-
maleo_foundation-0.2.
|
120
|
-
maleo_foundation-0.2.
|
121
|
-
maleo_foundation-0.2.
|
118
|
+
maleo_foundation-0.2.26.dist-info/METADATA,sha256=X-3GBxwmqjzuox2JY4zR_DIlzLBwrdMSPZVoOZDL18g,3598
|
119
|
+
maleo_foundation-0.2.26.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
120
|
+
maleo_foundation-0.2.26.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
|
121
|
+
maleo_foundation-0.2.26.dist-info/RECORD,,
|
@@ -1,51 +0,0 @@
|
|
1
|
-
from __future__ import annotations
|
2
|
-
from pydantic import model_validator
|
3
|
-
from maleo_foundation.models.schemas.general import BaseGeneralSchemas
|
4
|
-
from maleo_foundation.models.schemas.result import BaseResultSchemas
|
5
|
-
|
6
|
-
class BaseServiceQueryResultsTransfers:
|
7
|
-
class Row(
|
8
|
-
BaseGeneralSchemas.Status,
|
9
|
-
BaseGeneralSchemas.Timestamps,
|
10
|
-
BaseGeneralSchemas.Identifiers,
|
11
|
-
BaseResultSchemas.BaseRow
|
12
|
-
): pass
|
13
|
-
|
14
|
-
class Fail(BaseResultSchemas.Fail): pass
|
15
|
-
|
16
|
-
class NotFound(BaseResultSchemas.NotFound): pass
|
17
|
-
|
18
|
-
class NoData(BaseResultSchemas.NoData): pass
|
19
|
-
|
20
|
-
class SingleData(BaseResultSchemas.SingleData):
|
21
|
-
data:BaseServiceQueryResultsTransfers.Row
|
22
|
-
|
23
|
-
class UnpaginatedMultipleData(BaseResultSchemas.UnpaginatedMultipleData):
|
24
|
-
data:list[BaseServiceQueryResultsTransfers.Row]
|
25
|
-
|
26
|
-
class PaginatedMultipleData(BaseResultSchemas.PaginatedMultipleData):
|
27
|
-
data:list[BaseServiceQueryResultsTransfers.Row]
|
28
|
-
|
29
|
-
@model_validator(mode="before")
|
30
|
-
@classmethod
|
31
|
-
def calculate_pagination(cls, values: dict) -> dict:
|
32
|
-
"""Calculates pagination metadata before validation."""
|
33
|
-
total_data = values.get("total_data", 0)
|
34
|
-
data = values.get("data", [])
|
35
|
-
|
36
|
-
#* Get pagination values from inherited SimplePagination
|
37
|
-
page = values.get("page", 1)
|
38
|
-
limit = values.get("limit", 10)
|
39
|
-
|
40
|
-
#* Calculate total pages
|
41
|
-
total_pages = (total_data // limit) + (1 if total_data % limit > 0 else 0)
|
42
|
-
|
43
|
-
#* Assign computed pagination object before validation
|
44
|
-
values["pagination"] = BaseGeneralSchemas.ExtendedPagination(
|
45
|
-
page=page,
|
46
|
-
limit=limit,
|
47
|
-
data_count=len(data),
|
48
|
-
total_data=total_data,
|
49
|
-
total_pages=total_pages
|
50
|
-
)
|
51
|
-
return values
|
File without changes
|
File without changes
|