maleo-foundation 0.2.49__py3-none-any.whl → 0.2.51__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/models/schemas/result.py +0 -4
- maleo_foundation/models/transfers/results/service/repository.py +2 -13
- maleo_foundation/types.py +1 -0
- maleo_foundation/utils/query.py +100 -18
- {maleo_foundation-0.2.49.dist-info → maleo_foundation-0.2.51.dist-info}/METADATA +1 -1
- {maleo_foundation-0.2.49.dist-info → maleo_foundation-0.2.51.dist-info}/RECORD +8 -8
- {maleo_foundation-0.2.49.dist-info → maleo_foundation-0.2.51.dist-info}/WHEEL +0 -0
- {maleo_foundation-0.2.49.dist-info → maleo_foundation-0.2.51.dist-info}/top_level.txt +0 -0
@@ -14,10 +14,6 @@ class ResultMetadata(BaseModel):
|
|
14
14
|
field_expansion:Optional[Union[str, Dict[str, FieldExpansionMetadata]]] = Field(None, description="Field expansion metadata")
|
15
15
|
|
16
16
|
class BaseResultSchemas:
|
17
|
-
class BaseRow(BaseModel):
|
18
|
-
class Config:
|
19
|
-
from_attributes=True
|
20
|
-
|
21
17
|
class Base(BaseModel):
|
22
18
|
success:bool = Field(..., description="Success status")
|
23
19
|
code:BaseTypes.OptionalString = Field(None, description="Optional result code")
|
@@ -4,28 +4,17 @@ from maleo_foundation.models.schemas.general import BaseGeneralSchemas
|
|
4
4
|
from maleo_foundation.models.schemas.result import BaseResultSchemas
|
5
5
|
|
6
6
|
class BaseServiceRepositoryResultsTransfers:
|
7
|
-
class Row(
|
8
|
-
BaseGeneralSchemas.Status,
|
9
|
-
BaseGeneralSchemas.Timestamps,
|
10
|
-
BaseGeneralSchemas.Identifiers,
|
11
|
-
BaseResultSchemas.BaseRow
|
12
|
-
): pass
|
13
|
-
|
14
7
|
class Fail(BaseResultSchemas.Fail): pass
|
15
8
|
|
16
9
|
class NotFound(BaseResultSchemas.NotFound): pass
|
17
10
|
|
18
11
|
class NoData(BaseResultSchemas.NoData): pass
|
19
12
|
|
20
|
-
class SingleData(BaseResultSchemas.SingleData):
|
21
|
-
data:BaseServiceRepositoryResultsTransfers.Row
|
13
|
+
class SingleData(BaseResultSchemas.SingleData): pass
|
22
14
|
|
23
|
-
class UnpaginatedMultipleData(BaseResultSchemas.UnpaginatedMultipleData):
|
24
|
-
data:list[BaseServiceRepositoryResultsTransfers.Row]
|
15
|
+
class UnpaginatedMultipleData(BaseResultSchemas.UnpaginatedMultipleData): pass
|
25
16
|
|
26
17
|
class PaginatedMultipleData(BaseResultSchemas.PaginatedMultipleData):
|
27
|
-
data:list[BaseServiceRepositoryResultsTransfers.Row]
|
28
|
-
|
29
18
|
@model_validator(mode="before")
|
30
19
|
@classmethod
|
31
20
|
def calculate_pagination(cls, values: dict) -> dict:
|
maleo_foundation/types.py
CHANGED
maleo_foundation/utils/query.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
from sqlalchemy import Column, Table
|
2
2
|
from sqlalchemy.ext.declarative import DeclarativeMeta
|
3
|
-
from sqlalchemy.orm import Query
|
3
|
+
from sqlalchemy.orm import Query, Session
|
4
4
|
from sqlalchemy.orm.attributes import InstrumentedAttribute
|
5
5
|
from sqlalchemy.sql.expression import or_, asc, cast, desc
|
6
6
|
from sqlalchemy.types import DATE, String, TEXT, TIMESTAMP
|
@@ -14,18 +14,22 @@ class BaseQueryUtils:
|
|
14
14
|
query:Query,
|
15
15
|
table:Type[DeclarativeMeta],
|
16
16
|
column:str,
|
17
|
-
value:BaseTypes.OptionalAny
|
17
|
+
value:BaseTypes.OptionalAny = None,
|
18
|
+
include_null:bool = False
|
18
19
|
) -> Query:
|
19
|
-
if not value:
|
20
|
-
return query
|
21
20
|
column_attr = getattr(table, column, None)
|
22
|
-
if not column_attr:
|
21
|
+
if column_attr is None or not isinstance(column_attr, InstrumentedAttribute):
|
23
22
|
return query
|
24
|
-
|
25
|
-
|
23
|
+
|
24
|
+
value_filters = []
|
25
|
+
if value is not None:
|
26
|
+
value_filters.extend([column_attr == val for val in value])
|
27
|
+
if include_null:
|
28
|
+
value_filters.append(column_attr.is_(None))
|
29
|
+
|
30
|
+
if value_filters:
|
26
31
|
query = query.filter(or_(*value_filters))
|
27
|
-
|
28
|
-
query = query.filter(column_attr == value)
|
32
|
+
|
29
33
|
return query
|
30
34
|
|
31
35
|
@staticmethod
|
@@ -33,15 +37,24 @@ class BaseQueryUtils:
|
|
33
37
|
query:Query,
|
34
38
|
table:Type[DeclarativeMeta],
|
35
39
|
column:str,
|
36
|
-
ids:BaseTypes.OptionalListOfIntegers
|
40
|
+
ids:BaseTypes.OptionalListOfIntegers = None,
|
41
|
+
include_null:bool = False
|
37
42
|
) -> Query:
|
43
|
+
column_attr = getattr(table, column, None)
|
44
|
+
if column_attr is None or not isinstance(column_attr, InstrumentedAttribute):
|
45
|
+
return query
|
46
|
+
|
47
|
+
id_filters = []
|
38
48
|
if ids is not None:
|
39
|
-
column_attr
|
40
|
-
|
41
|
-
|
42
|
-
|
49
|
+
id_filters.extend([column_attr == id for id in ids])
|
50
|
+
if include_null:
|
51
|
+
id_filters.append(column_attr.is_(None))
|
52
|
+
|
53
|
+
if id_filters:
|
54
|
+
query = query.filter(or_(*id_filters))
|
55
|
+
|
43
56
|
return query
|
44
|
-
|
57
|
+
|
45
58
|
@staticmethod
|
46
59
|
def filter_timestamps(
|
47
60
|
query:Query,
|
@@ -69,7 +82,7 @@ class BaseQueryUtils:
|
|
69
82
|
except KeyError:
|
70
83
|
continue
|
71
84
|
return query
|
72
|
-
|
85
|
+
|
73
86
|
@staticmethod
|
74
87
|
def filter_statuses(
|
75
88
|
query:Query,
|
@@ -80,7 +93,75 @@ class BaseQueryUtils:
|
|
80
93
|
status_filters = [table.status == status for status in statuses]
|
81
94
|
query = query.filter(or_(*status_filters))
|
82
95
|
return query
|
83
|
-
|
96
|
+
|
97
|
+
@staticmethod
|
98
|
+
def filter_is_root(
|
99
|
+
query:Query,
|
100
|
+
table:Type[DeclarativeMeta],
|
101
|
+
parent_column:str="parent_id",
|
102
|
+
is_root:BaseTypes.OptionalBoolean=None
|
103
|
+
) -> Query:
|
104
|
+
parent_attr = getattr(table, parent_column, None)
|
105
|
+
if parent_attr is None or not isinstance(parent_attr, InstrumentedAttribute):
|
106
|
+
return query
|
107
|
+
if is_root is not None:
|
108
|
+
query = query.filter(parent_attr.is_(None) if is_root else parent_attr.is_not(None))
|
109
|
+
return query
|
110
|
+
|
111
|
+
@staticmethod
|
112
|
+
def filter_is_parent(
|
113
|
+
session:Session,
|
114
|
+
query:Query,
|
115
|
+
table:Type[DeclarativeMeta],
|
116
|
+
id_column:str="id",
|
117
|
+
parent_column:str="parent_id",
|
118
|
+
is_parent:BaseTypes.OptionalBoolean=None
|
119
|
+
) -> Query:
|
120
|
+
id_attr = getattr(table, id_column, None)
|
121
|
+
if id_attr is None or not isinstance(id_attr, InstrumentedAttribute):
|
122
|
+
return query
|
123
|
+
parent_attr = getattr(table, parent_column, None)
|
124
|
+
if parent_attr is None or not isinstance(parent_attr, InstrumentedAttribute):
|
125
|
+
return query
|
126
|
+
if is_parent is not None:
|
127
|
+
subq = session.query(table).filter(parent_attr == id_attr).exists()
|
128
|
+
query = query.filter(subq if is_parent else ~subq)
|
129
|
+
return query
|
130
|
+
|
131
|
+
@staticmethod
|
132
|
+
def filter_is_children(
|
133
|
+
query:Query,
|
134
|
+
table:Type[DeclarativeMeta],
|
135
|
+
parent_column:str = "parent_id",
|
136
|
+
is_children:BaseTypes.OptionalBoolean = None
|
137
|
+
) -> Query:
|
138
|
+
parent_attr = getattr(table, parent_column, None)
|
139
|
+
if parent_attr is None or not isinstance(parent_attr, InstrumentedAttribute):
|
140
|
+
return query
|
141
|
+
if is_children is not None:
|
142
|
+
query = query.filter(parent_attr.is_not(None) if is_children else parent_attr.is_(None))
|
143
|
+
return query
|
144
|
+
|
145
|
+
@staticmethod
|
146
|
+
def filter_is_leaf(
|
147
|
+
session:Session,
|
148
|
+
query:Query,
|
149
|
+
table:Type[DeclarativeMeta],
|
150
|
+
id_column:str="id",
|
151
|
+
parent_column:str="parent_id",
|
152
|
+
is_leaf:BaseTypes.OptionalBoolean=None
|
153
|
+
) -> Query:
|
154
|
+
id_attr = getattr(table, id_column, None)
|
155
|
+
if id_attr is None or not isinstance(id_attr, InstrumentedAttribute):
|
156
|
+
return query
|
157
|
+
parent_attr = getattr(table, parent_column, None)
|
158
|
+
if parent_attr is None or not isinstance(parent_attr, InstrumentedAttribute):
|
159
|
+
return query
|
160
|
+
if is_leaf is not None:
|
161
|
+
subq = session.query(table).filter(parent_attr == id_attr).exists()
|
162
|
+
query = query.filter(~subq if is_leaf else subq)
|
163
|
+
return query
|
164
|
+
|
84
165
|
@staticmethod
|
85
166
|
def filter_search(
|
86
167
|
query:Query,
|
@@ -103,7 +184,8 @@ class BaseQueryUtils:
|
|
103
184
|
if search_filters:
|
104
185
|
query = query.filter(or_(*search_filters))
|
105
186
|
return query
|
106
|
-
|
187
|
+
|
188
|
+
|
107
189
|
@staticmethod
|
108
190
|
def sort(
|
109
191
|
query:Query,
|
@@ -5,7 +5,7 @@ maleo_foundation/constants.py,sha256=aBmEfWlBqZxi0k-n6h2NM1YRLOjMnheEiLyQcjP-zCQ
|
|
5
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/rest_controller_result.py,sha256=4KbCmk70IEHj1L1bNJfFg1Y3ifnRSnmvK6dYyVJddok,2014
|
8
|
-
maleo_foundation/types.py,sha256=
|
8
|
+
maleo_foundation/types.py,sha256=bUcCR-qRlxxttMxJQnVmtBic3EXEd_urcC2P55evWPc,2451
|
9
9
|
maleo_foundation/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
10
|
maleo_foundation/client/manager.py,sha256=pFWLFYW4eE9MLyFmFS05IgnMBdqqUHbdyTkSbnBtm5E,2620
|
11
11
|
maleo_foundation/client/services/__init__.py,sha256=uIBnAeQ9a2otQbUAbKBQfYrkEUugXjxXoV8W5QYHuic,1051
|
@@ -58,7 +58,7 @@ maleo_foundation/models/schemas/general.py,sha256=PCnGRV_WL8xiBuECDlt7E0Mg_pEVrM
|
|
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
|
61
|
-
maleo_foundation/models/schemas/result.py,sha256=
|
61
|
+
maleo_foundation/models/schemas/result.py,sha256=uYVV5MHeK2aKEWmbmI8azDuD4_xG3MKmo3_wDAl5i6E,3551
|
62
62
|
maleo_foundation/models/schemas/signature.py,sha256=-5ldTnJsjwqPRbHw7PFcLKITqEXJ_qKDdRHShK75NVA,620
|
63
63
|
maleo_foundation/models/schemas/token.py,sha256=RYq8v1T_WZIu8lcjwyV6Pp7ZjFkr_lW9x6QyDmXBsfw,563
|
64
64
|
maleo_foundation/models/transfers/__init__.py,sha256=oJLJ3Geeme6vBw7R2Dhvdvg4ziVvzEYAGJaP-tm_90w,299
|
@@ -94,7 +94,7 @@ maleo_foundation/models/transfers/results/encryption/aes.py,sha256=yx3hZNhge2lfj
|
|
94
94
|
maleo_foundation/models/transfers/results/encryption/rsa.py,sha256=hlCtiT1TZwmMBEn-sgGs-WocNEmJ4qxWcHS5y9m7Voc,683
|
95
95
|
maleo_foundation/models/transfers/results/service/__init__.py,sha256=qKCJTtuLJeda-xrRL99OVdZR91PLFK1JyYVItjreLbQ,410
|
96
96
|
maleo_foundation/models/transfers/results/service/general.py,sha256=-4VE7mV103nQIRRxIy_dGIU6XDe_wiMgrCFJJ6eXUMM,1540
|
97
|
-
maleo_foundation/models/transfers/results/service/repository.py,sha256=
|
97
|
+
maleo_foundation/models/transfers/results/service/repository.py,sha256=Ach5lLjEC4IB_fEJPMEYgwBWNKq-TYLzbsHuc6e1vsw,1543
|
98
98
|
maleo_foundation/models/transfers/results/service/controllers/__init__.py,sha256=HZJWMy2dskzOCzLmp_UaL9rjbQ-sDMI7sd2bXb-4QOU,175
|
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
|
@@ -104,7 +104,7 @@ maleo_foundation/utils/exceptions.py,sha256=kDLTWiUauvc-fSKrEyxlGvIi2NtZIAhJ9bV3
|
|
104
104
|
maleo_foundation/utils/extractor.py,sha256=SZXVYDHWGaA-Dd1BUydwF2HHdZqexEielS4CjL0Ceng,814
|
105
105
|
maleo_foundation/utils/logging.py,sha256=W5Fhk_xAXVqSujaY8mv3hRH4wlQSpUn4ReuMoiKcQa4,7759
|
106
106
|
maleo_foundation/utils/mergers.py,sha256=DniUu3Ot4qkYH_YSw4uD1cn9cfirum4S_Opp8fMkQwA,702
|
107
|
-
maleo_foundation/utils/query.py,sha256=
|
107
|
+
maleo_foundation/utils/query.py,sha256=fLPUZQx8JuFpt8joLq-bfbuKnTKrLQAaQlRLS7WSpKY,7718
|
108
108
|
maleo_foundation/utils/repository.py,sha256=knBi3xOLlhBIEtChvqbZh4wXmgrFCB3rDwQXy41d7_c,2852
|
109
109
|
maleo_foundation/utils/dependencies/__init__.py,sha256=0KKGrdfj8Cc5A4SRk_ZBAxzOP795Mizdb4zIBh07KC4,122
|
110
110
|
maleo_foundation/utils/dependencies/auth.py,sha256=wS9qnmd1n2WsFhiSfyq_3Io3wwZKTENVPv4rMwxJslE,727
|
@@ -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.
|
121
|
-
maleo_foundation-0.2.
|
122
|
-
maleo_foundation-0.2.
|
123
|
-
maleo_foundation-0.2.
|
120
|
+
maleo_foundation-0.2.51.dist-info/METADATA,sha256=KUPBDR3c1SUqEkjF-p9hwN5HRhUsRpb9PE9tRdW4V2Q,3598
|
121
|
+
maleo_foundation-0.2.51.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
122
|
+
maleo_foundation-0.2.51.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
|
123
|
+
maleo_foundation-0.2.51.dist-info/RECORD,,
|
File without changes
|
File without changes
|