maleo-foundation 0.2.46__py3-none-any.whl → 0.2.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.
@@ -18,6 +18,9 @@ class BaseGeneralSchemas:
18
18
  class Uuids(BaseModel):
19
19
  uuids:BaseTypes.OptionalListOfUUIDs = Field(None, description="Specific Uuids")
20
20
 
21
+ class Codes(BaseModel):
22
+ codes:BaseTypes.OptionalListOfStrings = Field(None, description="Specific Codes")
23
+
21
24
  class Keys(BaseModel):
22
25
  keys:BaseTypes.OptionalListOfStrings = Field(None, description="Specific Keys")
23
26
 
@@ -1,7 +1,7 @@
1
1
  import inspect
2
2
  from fastapi import status
3
3
  from functools import wraps
4
- from typing import Awaitable, Callable, Dict, List
4
+ from typing import Awaitable, Callable, Dict, List, Union
5
5
  from maleo_foundation.types import BaseTypes
6
6
  from maleo_foundation.models.responses import BaseResponses
7
7
  from maleo_foundation.models.transfers.parameters.general \
@@ -53,34 +53,71 @@ class BaseControllerUtils:
53
53
  if not isinstance(result.content, Dict):
54
54
  return result
55
55
 
56
- #* Process the fields if needed
57
- if (result.success
56
+ #* Recursive function to apply expansion processors
57
+ def recursive_expand(data:Union[Dict, List], expand:List[str]):
58
+ if isinstance(data, list):
59
+ for idx, item in enumerate(data):
60
+ data[idx] = recursive_expand(item, expand)
61
+ return data
62
+ elif isinstance(data, dict):
63
+ #* Apply each processor to current dict
64
+ for processor in field_expansion_processors or []:
65
+ raw_parameters = {"data": data, "expand": expand}
66
+ parameters = (
67
+ BaseGeneralParametersTransfers
68
+ .FieldExpansionProcessor
69
+ .model_validate(raw_parameters)
70
+ )
71
+ data = processor(parameters)
72
+
73
+ #* Now recursively apply to nested fields if they are in expand
74
+ for key in expand:
75
+ if key in data and isinstance(data[key], (dict, list)):
76
+ #* Recursively expand nested field with same expand
77
+ data[key] = recursive_expand(data[key], expand)
78
+
79
+ return data
80
+ else:
81
+ return data
82
+
83
+ #* Process expansions recursively if needed
84
+ if (
85
+ result.success
58
86
  and result.content.get("data", None) is not None
59
87
  and field_expansion_processors is not None
88
+ and expand is not None
60
89
  ):
61
90
  data = result.content["data"]
62
- if isinstance(data, List):
63
- for idx, dt in enumerate(data):
64
- for processor in field_expansion_processors:
65
- raw_parameters = {"data": dt, "expand": expand}
66
- parameters = (
67
- BaseGeneralParametersTransfers
68
- .FieldExpansionProcessor
69
- .model_validate(raw_parameters)
70
- )
71
- dt = processor(parameters)
72
- data[idx] = dt
73
- elif isinstance(data, Dict):
74
- raw_parameters = {"data": data, "expand": expand}
75
- parameters = (
76
- BaseGeneralParametersTransfers
77
- .FieldExpansionProcessor
78
- .model_validate(raw_parameters)
79
- )
80
- for processor in field_expansion_processors:
81
- data = processor(parameters)
82
- result.content["data"] = data
83
- result.process_response()
91
+ result.content["data"] = recursive_expand(data, expand)
92
+
93
+ # #* Process the fields if needed
94
+ # if (result.success
95
+ # and result.content.get("data", None) is not None
96
+ # and field_expansion_processors is not None
97
+ # ):
98
+ # data = result.content["data"]
99
+ # if isinstance(data, List):
100
+ # for idx, dt in enumerate(data):
101
+ # for processor in field_expansion_processors:
102
+ # raw_parameters = {"data": dt, "expand": expand}
103
+ # parameters = (
104
+ # BaseGeneralParametersTransfers
105
+ # .FieldExpansionProcessor
106
+ # .model_validate(raw_parameters)
107
+ # )
108
+ # dt = processor(parameters)
109
+ # data[idx] = dt
110
+ # elif isinstance(data, Dict):
111
+ # raw_parameters = {"data": data, "expand": expand}
112
+ # parameters = (
113
+ # BaseGeneralParametersTransfers
114
+ # .FieldExpansionProcessor
115
+ # .model_validate(raw_parameters)
116
+ # )
117
+ # for processor in field_expansion_processors:
118
+ # data = processor(parameters)
119
+ # result.content["data"] = data
120
+ # result.process_response()
84
121
 
85
122
  return result
86
123
  return wrapper
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.2.46
3
+ Version: 0.2.48
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -54,7 +54,7 @@ maleo_foundation/models/responses.py,sha256=nszxzni_Q_42bzjrKvUVGeB3GSn4Ba9g-Nqj
54
54
  maleo_foundation/models/table.py,sha256=tcOwj_Heqi6ode8rbD4eeSiixEYsAtUaUyJyqrYaMAw,1327
55
55
  maleo_foundation/models/schemas/__init__.py,sha256=Xj8Ahsqyra-fmEaVcGPok5GOOsPQlKcknHYMvbjvENA,277
56
56
  maleo_foundation/models/schemas/encryption.py,sha256=KYs2P57AqWpEROuqTuSuyt1Zk-jsIUKFeRWIfSwem74,658
57
- maleo_foundation/models/schemas/general.py,sha256=9Uvm7ckq0lAa9fv6S7_lore0_LLXvMCkRB2YbTr-lkM,4259
57
+ maleo_foundation/models/schemas/general.py,sha256=PCnGRV_WL8xiBuECDlt7E0Mg_pEVrM7T28bwOxqcLdI,4378
58
58
  maleo_foundation/models/schemas/hash.py,sha256=db2uyCeUzvF2zDCcbiZMh1MxIOGOGezOMOx-M1ta4zI,441
59
59
  maleo_foundation/models/schemas/key.py,sha256=7FZxVqTL5qRK48AXL1odrMNhAwhwtCwSkBUPsJwuBII,594
60
60
  maleo_foundation/models/schemas/parameter.py,sha256=K47z2NzmTEhUiOfRiRLyRPXoQurbWsKBL7ObXAxIWRY,2100
@@ -99,7 +99,7 @@ maleo_foundation/models/transfers/results/service/controllers/__init__.py,sha256
99
99
  maleo_foundation/models/transfers/results/service/controllers/rest.py,sha256=wCuFyOTQkuBs2cqjPsWnPy0XIsCfMqGByhrSy57qp7Y,1107
100
100
  maleo_foundation/utils/__init__.py,sha256=SRPEVoqjZoO6W8rtF_Ti8VIangg6Auwm6eHbZMdOthY,520
101
101
  maleo_foundation/utils/client.py,sha256=F5X9TUxWQgeOHjwsMpPoSRhZANQYZ_iFv0RJDTUVhrw,2820
102
- maleo_foundation/utils/controller.py,sha256=JppDEjXu4Ktlwr-0N497AEyihlRQbbn_ttOcQVGVwXw,4322
102
+ maleo_foundation/utils/controller.py,sha256=n8_-BG3EJuQCKI5aHf-WMhpxNsnM2veeuvEZLtSVcv8,6242
103
103
  maleo_foundation/utils/exceptions.py,sha256=kDLTWiUauvc-fSKrEyxlGvIi2NtZIAhJ9bV3OXnpTyo,6253
104
104
  maleo_foundation/utils/extractor.py,sha256=SZXVYDHWGaA-Dd1BUydwF2HHdZqexEielS4CjL0Ceng,814
105
105
  maleo_foundation/utils/logging.py,sha256=W5Fhk_xAXVqSujaY8mv3hRH4wlQSpUn4ReuMoiKcQa4,7759
@@ -117,7 +117,7 @@ maleo_foundation/utils/loaders/credential/__init__.py,sha256=qopTKvcMVoTFwyRijeg
117
117
  maleo_foundation/utils/loaders/credential/google.py,sha256=SKsqPuFnAiCcYLf24CxKnMybhVHpgqnq1gGSlThqjts,994
118
118
  maleo_foundation/utils/loaders/key/__init__.py,sha256=hVygcC2ImHc_aVrSrOmyedR8tMUZokWUKCKOSh5ctbo,106
119
119
  maleo_foundation/utils/loaders/key/rsa.py,sha256=gDhyX6iTFtHiluuhFCozaZ3pOLKU2Y9TlrNMK_GVyGU,3796
120
- maleo_foundation-0.2.46.dist-info/METADATA,sha256=T_WXO_R8TqC0bL3EGJzphpDS4u8Ht9P_gdSyqyi5BhU,3598
121
- maleo_foundation-0.2.46.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
122
- maleo_foundation-0.2.46.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
123
- maleo_foundation-0.2.46.dist-info/RECORD,,
120
+ maleo_foundation-0.2.48.dist-info/METADATA,sha256=PwEMHPB56vLw8qCtJeywYE7td7_7d0gpnQbrMhEF5aI,3598
121
+ maleo_foundation-0.2.48.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
122
+ maleo_foundation-0.2.48.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
123
+ maleo_foundation-0.2.48.dist-info/RECORD,,