maleo-foundation 0.2.13__py3-none-any.whl → 0.2.15__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.
@@ -15,6 +15,12 @@ class BaseGeneralSchemas:
15
15
  class Ids(BaseModel):
16
16
  ids:BaseTypes.OptionalListOfIntegers = Field(None, description="Specific Ids")
17
17
 
18
+ class Keys(BaseModel):
19
+ keys:BaseTypes.OptionalListOfStrings = Field(None, description="Specific Keys")
20
+
21
+ class Names(BaseModel):
22
+ names:BaseTypes.OptionalListOfStrings = Field(None, description="Specific Names")
23
+
18
24
  class Search(BaseModel):
19
25
  search:BaseTypes.OptionalString = Field(None, description="Search parameter string.")
20
26
 
@@ -1,58 +1,13 @@
1
1
  from fastapi import status
2
2
  from functools import wraps
3
- from typing import Awaitable, Callable, Dict, List, Type, Any
3
+ from typing import Awaitable, Callable, Dict, List
4
4
  from maleo_foundation.types import BaseTypes
5
- from maleo_foundation.enums import BaseEnums
6
5
  from maleo_foundation.models.responses import BaseResponses
7
6
  from maleo_foundation.models.transfers.parameters.general import BaseGeneralParametersTransfers
8
- from maleo_foundation.models.transfers.parameters.service import BaseServiceParametersTransfers
9
7
  from maleo_foundation.models.transfers.results.service.controllers.rest import BaseServiceRESTControllerResults
10
8
  from maleo_foundation.expanded_types.general import BaseGeneralExpandedTypes
11
- from maleo_foundation.expanded_types.service import ExpandedServiceTypes
12
9
 
13
10
  class BaseControllerUtils:
14
- @staticmethod
15
- def check_unique_existence(
16
- check:BaseServiceParametersTransfers.UniqueFieldCheck,
17
- get_single_parameters_class:Type[ExpandedServiceTypes.GetSingleParameter],
18
- get_single_service_function:ExpandedServiceTypes.SyncGetSingleFunction,
19
- create_failed_response_class:Type[BaseResponses.Fail],
20
- update_failed_response_class:Type[BaseResponses.Fail],
21
- **additional_get_parameters:Any
22
- ) -> BaseServiceRESTControllerResults:
23
- """Generic helper function to check if a unique value exists in the database."""
24
-
25
- #* Return early if nullable and no new value
26
- if check.nullable and check.new_value is None:
27
- return BaseServiceRESTControllerResults(success=True, content=None)
28
-
29
- #* Return early if values are unchanged on update
30
- if check.operation == BaseEnums.OperationType.UPDATE and check.old_value == check.new_value:
31
- return BaseServiceRESTControllerResults(success=True, content=None)
32
-
33
- #* Prepare parameters to query for existing data
34
- get_single_parameters = get_single_parameters_class(identifier=check.field, value=check.new_value)
35
-
36
- #* Query the existing data using provided function
37
- service_result:ExpandedServiceTypes.GetSingleResult = get_single_service_function(parameters=get_single_parameters, **additional_get_parameters)
38
- if not service_result.success:
39
- content = BaseResponses.ServerError.model_validate(service_result.model_dump(exclude_unset=True)).model_dump()
40
- return BaseServiceRESTControllerResults(success=False, content=content, status_code=status.HTTP_500_INTERNAL_SERVER_ERROR)
41
-
42
- #* Handle case if duplicate is found
43
- if service_result.data:
44
- description = f"External error: {check.field} of '{check.new_value}' already exists in the database"
45
- other = check.suggestion or f"Select another {check.field} value"
46
- if check.operation == BaseEnums.OperationType.CREATE:
47
- content = create_failed_response_class(description=description, other=other).model_dump()
48
- elif check.operation == BaseEnums.OperationType.UPDATE:
49
- content = update_failed_response_class(description=description, other=other).model_dump()
50
-
51
- return BaseServiceRESTControllerResults(success=False, content=content, status_code=status.HTTP_400_BAD_REQUEST)
52
-
53
- #* No duplicates found
54
- return BaseServiceRESTControllerResults(success=True, content=None)
55
-
56
11
  @staticmethod
57
12
  def field_expansion_handler(
58
13
  expandable_fields_dependencies_map:BaseTypes.OptionalStringToListOfStringDict = None,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.2.13
3
+ Version: 0.2.15
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -49,7 +49,7 @@ maleo_foundation/models/responses.py,sha256=iKJs9EFemCuUOc-IxEUwjX9RgNnPf-mw7yGh
49
49
  maleo_foundation/models/table.py,sha256=Dk5GXeO0gbBBPN2PJtZhlUx2x3vMbT4dxTBc3YLBbuc,1199
50
50
  maleo_foundation/models/schemas/__init__.py,sha256=Xj8Ahsqyra-fmEaVcGPok5GOOsPQlKcknHYMvbjvENA,277
51
51
  maleo_foundation/models/schemas/encryption.py,sha256=KYs2P57AqWpEROuqTuSuyt1Zk-jsIUKFeRWIfSwem74,658
52
- maleo_foundation/models/schemas/general.py,sha256=KGPP67ciKeL8cvOS3kYrVwmRx3kD33OcS88UmMn1JPE,3822
52
+ maleo_foundation/models/schemas/general.py,sha256=YXuvg55fukeKky9jVYAva9mzrpoaNjc-XQ_hFvEx9ag,4057
53
53
  maleo_foundation/models/schemas/hash.py,sha256=db2uyCeUzvF2zDCcbiZMh1MxIOGOGezOMOx-M1ta4zI,441
54
54
  maleo_foundation/models/schemas/key.py,sha256=7FZxVqTL5qRK48AXL1odrMNhAwhwtCwSkBUPsJwuBII,594
55
55
  maleo_foundation/models/schemas/parameter.py,sha256=K47z2NzmTEhUiOfRiRLyRPXoQurbWsKBL7ObXAxIWRY,2100
@@ -93,7 +93,7 @@ maleo_foundation/models/transfers/results/service/query.py,sha256=xHHPWCYx6NrKK9
93
93
  maleo_foundation/models/transfers/results/service/controllers/__init__.py,sha256=HZJWMy2dskzOCzLmp_UaL9rjbQ-sDMI7sd2bXb-4QOU,175
94
94
  maleo_foundation/models/transfers/results/service/controllers/rest.py,sha256=wCuFyOTQkuBs2cqjPsWnPy0XIsCfMqGByhrSy57qp7Y,1107
95
95
  maleo_foundation/utils/__init__.py,sha256=SRPEVoqjZoO6W8rtF_Ti8VIangg6Auwm6eHbZMdOthY,520
96
- maleo_foundation/utils/controller.py,sha256=ECzPzpw36zBAjKcWcDbUAhIJGbc6UpeypdUUX6ipXBg,6396
96
+ maleo_foundation/utils/controller.py,sha256=rzuWJVbR0eNxKpzrIGbglFAUjqBHrQ8eNCqGq-oLXr0,3643
97
97
  maleo_foundation/utils/exceptions.py,sha256=YKQ2hwVHUFlLAeup9FmCGptGIgdAuxTmTrD8A3gqURA,4078
98
98
  maleo_foundation/utils/extractor.py,sha256=SZXVYDHWGaA-Dd1BUydwF2HHdZqexEielS4CjL0Ceng,814
99
99
  maleo_foundation/utils/logging.py,sha256=W5Fhk_xAXVqSujaY8mv3hRH4wlQSpUn4ReuMoiKcQa4,7759
@@ -110,7 +110,7 @@ maleo_foundation/utils/loaders/credential/__init__.py,sha256=qopTKvcMVoTFwyRijeg
110
110
  maleo_foundation/utils/loaders/credential/google.py,sha256=deksZXT5wPhEsSMHbZ3x05WHXxCjLDt76Ns-1Tmhp7g,948
111
111
  maleo_foundation/utils/loaders/key/__init__.py,sha256=hVygcC2ImHc_aVrSrOmyedR8tMUZokWUKCKOSh5ctbo,106
112
112
  maleo_foundation/utils/loaders/key/rsa.py,sha256=gDhyX6iTFtHiluuhFCozaZ3pOLKU2Y9TlrNMK_GVyGU,3796
113
- maleo_foundation-0.2.13.dist-info/METADATA,sha256=wK3PlGk86D86G3yybnLnCm3UBhY_4ENQ8V3P7GIGaNw,3419
114
- maleo_foundation-0.2.13.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
115
- maleo_foundation-0.2.13.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
116
- maleo_foundation-0.2.13.dist-info/RECORD,,
113
+ maleo_foundation-0.2.15.dist-info/METADATA,sha256=M_iQUf0A9bcZM07TtlRG1YhELbqFs21zs85k4l0jL6s,3419
114
+ maleo_foundation-0.2.15.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
115
+ maleo_foundation-0.2.15.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
116
+ maleo_foundation-0.2.15.dist-info/RECORD,,