maleo-foundation 0.2.50__py3-none-any.whl → 0.2.52__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/responses.py +1 -2
- maleo_foundation/models/schemas/general.py +0 -68
- maleo_foundation/models/schemas/parameter.py +46 -1
- maleo_foundation/models/schemas/result.py +38 -1
- maleo_foundation/models/transfers/parameters/client.py +2 -2
- maleo_foundation/models/transfers/parameters/general.py +7 -6
- maleo_foundation/models/transfers/parameters/service.py +2 -2
- maleo_foundation/models/transfers/results/client/service.py +1 -2
- maleo_foundation/models/transfers/results/service/general.py +1 -2
- maleo_foundation/models/transfers/results/service/repository.py +1 -2
- maleo_foundation/types.py +1 -0
- maleo_foundation/utils/query.py +100 -18
- {maleo_foundation-0.2.50.dist-info → maleo_foundation-0.2.52.dist-info}/METADATA +1 -1
- {maleo_foundation-0.2.50.dist-info → maleo_foundation-0.2.52.dist-info}/RECORD +16 -16
- {maleo_foundation-0.2.50.dist-info → maleo_foundation-0.2.52.dist-info}/WHEEL +0 -0
- {maleo_foundation-0.2.50.dist-info → maleo_foundation-0.2.52.dist-info}/top_level.txt +0 -0
@@ -2,7 +2,6 @@ from __future__ import annotations
|
|
2
2
|
from fastapi import status
|
3
3
|
from pydantic import Field, model_validator
|
4
4
|
from typing import Dict, Type, Union
|
5
|
-
from maleo_foundation.models.schemas.general import BaseGeneralSchemas
|
6
5
|
from maleo_foundation.models.schemas.result import BaseResultSchemas
|
7
6
|
from maleo_foundation.types import BaseTypes
|
8
7
|
|
@@ -83,7 +82,7 @@ class BaseResponses:
|
|
83
82
|
total_pages = (total_data // limit) + (1 if total_data % limit > 0 else 0)
|
84
83
|
|
85
84
|
#* Assign computed pagination object before validation
|
86
|
-
values["pagination"] =
|
85
|
+
values["pagination"] = BaseResultSchemas.ExtendedPagination(
|
87
86
|
page=page,
|
88
87
|
limit=limit,
|
89
88
|
data_count=len(data),
|
@@ -6,38 +6,11 @@ from maleo_foundation.enums import BaseEnums
|
|
6
6
|
from maleo_foundation.types import BaseTypes
|
7
7
|
|
8
8
|
class BaseGeneralSchemas:
|
9
|
-
class IdentifierType(BaseModel):
|
10
|
-
identifier:BaseEnums.IdentifierTypes = Field(..., description="Data's identifier type")
|
11
|
-
|
12
|
-
class IdentifierValue(BaseModel):
|
13
|
-
value:BaseTypes.IdentifierValue = Field(..., description="Data's identifier value")
|
14
|
-
|
15
|
-
class Ids(BaseModel):
|
16
|
-
ids:BaseTypes.OptionalListOfIntegers = Field(None, description="Specific Ids")
|
17
|
-
|
18
|
-
class Uuids(BaseModel):
|
19
|
-
uuids:BaseTypes.OptionalListOfUUIDs = Field(None, description="Specific Uuids")
|
20
|
-
|
21
|
-
class Codes(BaseModel):
|
22
|
-
codes:BaseTypes.OptionalListOfStrings = Field(None, description="Specific Codes")
|
23
|
-
|
24
|
-
class Keys(BaseModel):
|
25
|
-
keys:BaseTypes.OptionalListOfStrings = Field(None, description="Specific Keys")
|
26
|
-
|
27
|
-
class Names(BaseModel):
|
28
|
-
names:BaseTypes.OptionalListOfStrings = Field(None, description="Specific Names")
|
29
|
-
|
30
|
-
class Search(BaseModel):
|
31
|
-
search:BaseTypes.OptionalString = Field(None, description="Search parameter string.")
|
32
|
-
|
33
9
|
class DateFilter(BaseModel):
|
34
10
|
name:str = Field(..., description="Column name.")
|
35
11
|
from_date:BaseTypes.OptionalDatetime = Field(None, description="From date.")
|
36
12
|
to_date:BaseTypes.OptionalDatetime = Field(None, description="To date.")
|
37
13
|
|
38
|
-
class Statuses(BaseModel):
|
39
|
-
statuses:BaseTypes.OptionalListOfStatuses = Field(None, description="Data's status")
|
40
|
-
|
41
14
|
class SortColumn(BaseModel):
|
42
15
|
name:str = Field(..., description="Column name.")
|
43
16
|
order:BaseEnums.SortOrder = Field(..., description="Sort order.")
|
@@ -46,17 +19,6 @@ class BaseGeneralSchemas:
|
|
46
19
|
page:int = Field(1, ge=1, description="Page number, must be >= 1.")
|
47
20
|
limit:int = Field(10, ge=1, le=100, description="Page size, must be 1 <= limit <= 100.")
|
48
21
|
|
49
|
-
class ExtendedPagination(SimplePagination):
|
50
|
-
data_count:int = Field(..., description="Fetched data count")
|
51
|
-
total_data:int = Field(..., description="Total data count")
|
52
|
-
total_pages:int = Field(..., description="Total pages count")
|
53
|
-
|
54
|
-
class Status(BaseModel):
|
55
|
-
status:BaseEnums.StatusType = Field(..., description="Status")
|
56
|
-
|
57
|
-
class Expand(BaseModel):
|
58
|
-
expand:BaseTypes.OptionalListOfStrings = Field(None, description="Expanded field(s)")
|
59
|
-
|
60
22
|
class PrivateKey(BaseModel):
|
61
23
|
private_key:str = Field(..., description="Private key in str format.")
|
62
24
|
|
@@ -65,39 +27,9 @@ class BaseGeneralSchemas:
|
|
65
27
|
|
66
28
|
class KeyPair(PublicKey, PrivateKey): pass
|
67
29
|
|
68
|
-
class Identifiers(BaseModel):
|
69
|
-
id:int = Field(..., ge=1, description="Data's ID, must be >= 1.")
|
70
|
-
uuid:UUID = Field(..., description="Data's UUID.")
|
71
|
-
|
72
|
-
class Timestamps(BaseModel):
|
73
|
-
created_at:datetime = Field(..., description="Data's created_at timestamp")
|
74
|
-
updated_at:datetime = Field(..., description="Data's updated_at timestamp")
|
75
|
-
deleted_at:BaseTypes.OptionalDatetime = Field(..., description="Data's deleted_at timestamp")
|
76
|
-
restored_at:BaseTypes.OptionalDatetime = Field(..., description="Data's restored_at timestamp")
|
77
|
-
deactivated_at:BaseTypes.OptionalDatetime = Field(..., description="Data's deactivated_at timestamp")
|
78
|
-
activated_at:datetime = Field(..., description="Data's activated_at timestamp")
|
79
|
-
|
80
30
|
class Status(BaseModel):
|
81
31
|
status:BaseEnums.StatusType = Field(..., description="Data's status")
|
82
32
|
|
83
|
-
class Order(BaseModel):
|
84
|
-
order:BaseTypes.OptionalInteger = Field(..., description="Data's order")
|
85
|
-
|
86
|
-
class Code(BaseModel):
|
87
|
-
code:str = Field(..., description="Data's code")
|
88
|
-
|
89
|
-
class Key(BaseModel):
|
90
|
-
key:str = Field(..., description="Data's key")
|
91
|
-
|
92
|
-
class Name(BaseModel):
|
93
|
-
name:str = Field(..., description="Data's name")
|
94
|
-
|
95
|
-
class Secret(BaseModel):
|
96
|
-
secret:UUID = Field(..., description="Data's secret")
|
97
|
-
|
98
|
-
class Data(BaseModel):
|
99
|
-
data:BaseTypes.StringToAnyDict = Field(..., description="Data")
|
100
|
-
|
101
33
|
class RSAKeys(BaseModel):
|
102
34
|
password:str = Field(..., description="Key's password")
|
103
35
|
private:str = Field(..., description="Private key")
|
@@ -8,6 +8,18 @@ from maleo_foundation.types import BaseTypes
|
|
8
8
|
from maleo_foundation.extended_types import ExtendedTypes
|
9
9
|
|
10
10
|
class BaseParameterSchemas:
|
11
|
+
class IdentifierType(BaseModel):
|
12
|
+
identifier:BaseEnums.IdentifierTypes = Field(..., description="Data's identifier type")
|
13
|
+
|
14
|
+
class IdentifierValue(BaseModel):
|
15
|
+
value:BaseTypes.IdentifierValue = Field(..., description="Data's identifier value")
|
16
|
+
|
17
|
+
class OptionalListOfIds(BaseModel):
|
18
|
+
ids:BaseTypes.OptionalListOfIntegers = Field(None, description="Specific Ids")
|
19
|
+
|
20
|
+
class OptionalListOfUuids(BaseModel):
|
21
|
+
uuids:BaseTypes.OptionalListOfUUIDs = Field(None, description="Specific Uuids")
|
22
|
+
|
11
23
|
class Filters(BaseModel):
|
12
24
|
filters:BaseTypes.ListOfStrings = Field([], description="Filters for date range, e.g. 'created_at|from::<ISO_DATETIME>|to::<ISO_DATETIME>'.")
|
13
25
|
|
@@ -28,6 +40,33 @@ class BaseParameterSchemas:
|
|
28
40
|
class DateFilters(BaseModel):
|
29
41
|
date_filters:ExtendedTypes.ListOfDateFilters = Field([], description="Date filters to be applied")
|
30
42
|
|
43
|
+
class OptionalListOfStatuses(BaseModel):
|
44
|
+
statuses:BaseTypes.OptionalListOfStatuses = Field(None, description="Data's status")
|
45
|
+
|
46
|
+
class IsRoot(BaseModel):
|
47
|
+
is_root:BaseTypes.OptionalBoolean = Field(None, description="Whether data is root")
|
48
|
+
|
49
|
+
class IsParent(BaseModel):
|
50
|
+
is_parent:BaseTypes.OptionalBoolean = Field(None, description="Whether data is parent")
|
51
|
+
|
52
|
+
class IsChild(BaseModel):
|
53
|
+
is_child:BaseTypes.OptionalBoolean = Field(None, description="Whether data is child")
|
54
|
+
|
55
|
+
class IsLeaf(BaseModel):
|
56
|
+
is_leaf:BaseTypes.OptionalBoolean = Field(None, description="Whether data is leaf")
|
57
|
+
|
58
|
+
class OptionalListOfCodes(BaseModel):
|
59
|
+
codes:BaseTypes.OptionalListOfStrings = Field(None, description="Specific Codes")
|
60
|
+
|
61
|
+
class OptionalListOfKeys(BaseModel):
|
62
|
+
keys:BaseTypes.OptionalListOfStrings = Field(None, description="Specific Keys")
|
63
|
+
|
64
|
+
class OptionalListOfNames(BaseModel):
|
65
|
+
names:BaseTypes.OptionalListOfStrings = Field(None, description="Specific Names")
|
66
|
+
|
67
|
+
class Search(BaseModel):
|
68
|
+
search:BaseTypes.OptionalString = Field(None, description="Search string.")
|
69
|
+
|
31
70
|
class Sorts(BaseModel):
|
32
71
|
sorts:BaseTypes.ListOfStrings = Field(["id.asc"], description="Sorting columns in 'column_name.asc' or 'column_name.desc' format.")
|
33
72
|
|
@@ -37,4 +76,10 @@ class BaseParameterSchemas:
|
|
37
76
|
return [value for value in values if SORT_COLUMN_PATTERN.match(value)]
|
38
77
|
|
39
78
|
class SortColumns(BaseModel):
|
40
|
-
sort_columns:ExtendedTypes.ListOfSortColumns = Field([BaseGeneralSchemas.SortColumn(name="id", order=BaseEnums.SortOrder.ASC)], description="List of columns to be sorted")
|
79
|
+
sort_columns:ExtendedTypes.ListOfSortColumns = Field([BaseGeneralSchemas.SortColumn(name="id", order=BaseEnums.SortOrder.ASC)], description="List of columns to be sorted")
|
80
|
+
|
81
|
+
class Expand(BaseModel):
|
82
|
+
expand:BaseTypes.OptionalListOfStrings = Field(None, description="Expanded field(s)")
|
83
|
+
|
84
|
+
class Data(BaseModel):
|
85
|
+
data:BaseTypes.StringToAnyDict = Field(..., description="Data")
|
@@ -1,5 +1,7 @@
|
|
1
1
|
from pydantic import BaseModel, Field
|
2
|
+
from datetime import datetime
|
2
3
|
from typing import Dict, Optional, Union, Any
|
4
|
+
from uuid import UUID
|
3
5
|
from maleo_foundation.models.schemas.general import BaseGeneralSchemas
|
4
6
|
from maleo_foundation.types import BaseTypes
|
5
7
|
|
@@ -14,6 +16,39 @@ class ResultMetadata(BaseModel):
|
|
14
16
|
field_expansion:Optional[Union[str, Dict[str, FieldExpansionMetadata]]] = Field(None, description="Field expansion metadata")
|
15
17
|
|
16
18
|
class BaseResultSchemas:
|
19
|
+
class Identifiers(BaseModel):
|
20
|
+
id:int = Field(..., ge=1, description="Data's ID, must be >= 1.")
|
21
|
+
uuid:UUID = Field(..., description="Data's UUID.")
|
22
|
+
|
23
|
+
class Timestamps(BaseModel):
|
24
|
+
created_at:datetime = Field(..., description="Data's created_at timestamp")
|
25
|
+
updated_at:datetime = Field(..., description="Data's updated_at timestamp")
|
26
|
+
deleted_at:BaseTypes.OptionalDatetime = Field(..., description="Data's deleted_at timestamp")
|
27
|
+
restored_at:BaseTypes.OptionalDatetime = Field(..., description="Data's restored_at timestamp")
|
28
|
+
deactivated_at:BaseTypes.OptionalDatetime = Field(..., description="Data's deactivated_at timestamp")
|
29
|
+
activated_at:datetime = Field(..., description="Data's activated_at timestamp")
|
30
|
+
|
31
|
+
class Order(BaseModel):
|
32
|
+
order:BaseTypes.OptionalInteger = Field(..., description="Data's order")
|
33
|
+
|
34
|
+
class Code(BaseModel):
|
35
|
+
code:str = Field(..., description="Data's code")
|
36
|
+
|
37
|
+
class Key(BaseModel):
|
38
|
+
key:str = Field(..., description="Data's key")
|
39
|
+
|
40
|
+
class Name(BaseModel):
|
41
|
+
name:str = Field(..., description="Data's name")
|
42
|
+
|
43
|
+
class Secret(BaseModel):
|
44
|
+
secret:UUID = Field(..., description="Data's secret")
|
45
|
+
|
46
|
+
class ExtendedPagination(BaseGeneralSchemas.SimplePagination):
|
47
|
+
data_count:int = Field(..., description="Fetched data count")
|
48
|
+
total_data:int = Field(..., description="Total data count")
|
49
|
+
total_pages:int = Field(..., description="Total pages count")
|
50
|
+
|
51
|
+
#* ----- ----- ----- Base ----- ----- ----- *#
|
17
52
|
class Base(BaseModel):
|
18
53
|
success:bool = Field(..., description="Success status")
|
19
54
|
code:BaseTypes.OptionalString = Field(None, description="Optional result code")
|
@@ -71,4 +106,6 @@ class BaseResultSchemas:
|
|
71
106
|
message:str = "Multiple paginated data found"
|
72
107
|
description:str = "Requested paginated data found in database."
|
73
108
|
total_data:int = Field(..., ge=0, description="Total data count")
|
74
|
-
pagination:
|
109
|
+
pagination:"BaseResultSchemas.ExtendedPagination" = Field(..., description="Pagination metadata")
|
110
|
+
|
111
|
+
BaseResultSchemas.PaginatedMultipleData.model_rebuild()
|
@@ -8,8 +8,8 @@ from maleo_foundation.models.schemas.parameter import BaseParameterSchemas
|
|
8
8
|
class BaseClientParametersTransfers:
|
9
9
|
class GetUnpaginatedMultiple(
|
10
10
|
BaseParameterSchemas.SortColumns,
|
11
|
-
|
12
|
-
|
11
|
+
BaseParameterSchemas.Search,
|
12
|
+
BaseParameterSchemas.Statuses,
|
13
13
|
BaseParameterSchemas.DateFilters
|
14
14
|
):
|
15
15
|
pass
|
@@ -1,20 +1,21 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
from maleo_foundation.models.schemas.general import BaseGeneralSchemas
|
3
|
+
from maleo_foundation.models.schemas.parameter import BaseParameterSchemas
|
3
4
|
|
4
5
|
class BaseGeneralParametersTransfers:
|
5
6
|
class FieldExpansionProcessor(
|
6
|
-
|
7
|
-
|
7
|
+
BaseParameterSchemas.Expand,
|
8
|
+
BaseParameterSchemas.Data
|
8
9
|
): pass
|
9
10
|
|
10
|
-
class GetSingleQuery(
|
11
|
+
class GetSingleQuery(BaseParameterSchemas.Statuses): pass
|
11
12
|
|
12
13
|
class BaseGetSingle(
|
13
|
-
|
14
|
-
|
14
|
+
BaseParameterSchemas.IdentifierValue,
|
15
|
+
BaseParameterSchemas.IdentifierType
|
15
16
|
):
|
16
17
|
pass
|
17
18
|
|
18
|
-
class GetSingle(
|
19
|
+
class GetSingle(BaseParameterSchemas.Statuses, BaseGetSingle): pass
|
19
20
|
|
20
21
|
class StatusUpdate(BaseGeneralSchemas.Status): pass
|
@@ -9,8 +9,8 @@ from maleo_foundation.models.schemas.parameter import BaseParameterSchemas
|
|
9
9
|
class BaseServiceParametersTransfers:
|
10
10
|
class GetUnpaginatedMultipleQuery(
|
11
11
|
BaseParameterSchemas.Sorts,
|
12
|
-
|
13
|
-
|
12
|
+
BaseParameterSchemas.Search,
|
13
|
+
BaseParameterSchemas.Statuses,
|
14
14
|
BaseParameterSchemas.Filters
|
15
15
|
): pass
|
16
16
|
|
@@ -1,6 +1,5 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
from pydantic import model_validator
|
3
|
-
from maleo_foundation.models.schemas.general import BaseGeneralSchemas
|
4
3
|
from maleo_foundation.models.schemas.result import BaseResultSchemas
|
5
4
|
|
6
5
|
class BaseClientServiceResultsTransfers:
|
@@ -22,7 +21,7 @@ class BaseClientServiceResultsTransfers:
|
|
22
21
|
pagination = values.get("pagination")
|
23
22
|
if pagination is None:
|
24
23
|
raise ValueError("Pagination field did not exists")
|
25
|
-
pagination =
|
24
|
+
pagination = BaseResultSchemas.ExtendedPagination.model_validate(pagination)
|
26
25
|
values["page"] = pagination.page
|
27
26
|
values["limit"] = pagination.limit
|
28
27
|
values["total_data"] = pagination.total_data
|
@@ -1,6 +1,5 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
from pydantic import model_validator
|
3
|
-
from maleo_foundation.models.schemas.general import BaseGeneralSchemas
|
4
3
|
from maleo_foundation.models.schemas.result import BaseResultSchemas
|
5
4
|
|
6
5
|
class BaseServiceGeneralResultsTransfers:
|
@@ -30,7 +29,7 @@ class BaseServiceGeneralResultsTransfers:
|
|
30
29
|
total_pages = (total_data // limit) + (1 if total_data % limit > 0 else 0)
|
31
30
|
|
32
31
|
#* Assign computed pagination object before validation
|
33
|
-
values["pagination"] =
|
32
|
+
values["pagination"] = BaseResultSchemas.ExtendedPagination(
|
34
33
|
page=page,
|
35
34
|
limit=limit,
|
36
35
|
data_count=len(data),
|
@@ -1,6 +1,5 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
from pydantic import model_validator
|
3
|
-
from maleo_foundation.models.schemas.general import BaseGeneralSchemas
|
4
3
|
from maleo_foundation.models.schemas.result import BaseResultSchemas
|
5
4
|
|
6
5
|
class BaseServiceRepositoryResultsTransfers:
|
@@ -30,7 +29,7 @@ class BaseServiceRepositoryResultsTransfers:
|
|
30
29
|
total_pages = (total_data // limit) + (1 if total_data % limit > 0 else 0)
|
31
30
|
|
32
31
|
#* Assign computed pagination object before validation
|
33
|
-
values["pagination"] =
|
32
|
+
values["pagination"] = BaseResultSchemas.ExtendedPagination(
|
34
33
|
page=page,
|
35
34
|
limit=limit,
|
36
35
|
data_count=len(data),
|
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
|
@@ -50,15 +50,15 @@ maleo_foundation/middlewares/authentication.py,sha256=UL6kL65SvqrzemlIDopoO9N1C0
|
|
50
50
|
maleo_foundation/middlewares/base.py,sha256=0vHU0CJEj9s3slGE3fxCQwL0_hqXW-xvhu82WRVpkpg,14551
|
51
51
|
maleo_foundation/middlewares/cors.py,sha256=9uvBvY2N6Vxa9RP_YtESxcWo6Doi6uS0lzAG9iLY7Uc,2288
|
52
52
|
maleo_foundation/models/__init__.py,sha256=AaKehO7c1HyKhoTGRmNHDddSeBXkW-_YNrpOGBu8Ms8,246
|
53
|
-
maleo_foundation/models/responses.py,sha256=
|
53
|
+
maleo_foundation/models/responses.py,sha256=ab-DOERSqbhO25qTvQlVFmuroqsVcLAGaMDSLm4rwUk,5151
|
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=
|
57
|
+
maleo_foundation/models/schemas/general.py,sha256=SbepP6NWTt7zlZTn9Sqhx0QQWWK_oUEfAQpePlTUT-A,1469
|
58
58
|
maleo_foundation/models/schemas/hash.py,sha256=db2uyCeUzvF2zDCcbiZMh1MxIOGOGezOMOx-M1ta4zI,441
|
59
59
|
maleo_foundation/models/schemas/key.py,sha256=7FZxVqTL5qRK48AXL1odrMNhAwhwtCwSkBUPsJwuBII,594
|
60
|
-
maleo_foundation/models/schemas/parameter.py,sha256=
|
61
|
-
maleo_foundation/models/schemas/result.py,sha256=
|
60
|
+
maleo_foundation/models/schemas/parameter.py,sha256=WO0HCdmolhwdkU92BZh1Vh-6XeUeusg5MqPogprBPdQ,3994
|
61
|
+
maleo_foundation/models/schemas/result.py,sha256=Iu9ZWlX5_V3McEVNsDhOX17_5zdWI9C9_f0LhAXWnfs,5216
|
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
|
@@ -67,10 +67,10 @@ maleo_foundation/models/transfers/general/key.py,sha256=tLKkXbwNu7Oc1MdKa8-Y7TlB
|
|
67
67
|
maleo_foundation/models/transfers/general/signature.py,sha256=J9xQy2HjpCQOnES7RJqsUnDgjFPuakQ1mxyfdTdstSE,297
|
68
68
|
maleo_foundation/models/transfers/general/token.py,sha256=O_U6dQS7oMScJzqufl6Pe21pTxMsYhOzKH8aFLxjblQ,2895
|
69
69
|
maleo_foundation/models/transfers/parameters/__init__.py,sha256=oKW4RPIEISISRjsJzD8lsCGY1HhZRTzshPpWHcJu86k,353
|
70
|
-
maleo_foundation/models/transfers/parameters/client.py,sha256=
|
71
|
-
maleo_foundation/models/transfers/parameters/general.py,sha256=
|
70
|
+
maleo_foundation/models/transfers/parameters/client.py,sha256=whGJzEXX72knAmFmND799dNPoWlS6roEIqZHQH_Oz6M,4055
|
71
|
+
maleo_foundation/models/transfers/parameters/general.py,sha256=HrxShFacxXFjLeEvBLYhZDA8NKasiRcYy4ipOhIMeuE,666
|
72
72
|
maleo_foundation/models/transfers/parameters/key.py,sha256=ZhWcbPJZvl8AF_qlecG-4-9_Ym6EbU7nngRo3AtbScY,432
|
73
|
-
maleo_foundation/models/transfers/parameters/service.py,sha256=
|
73
|
+
maleo_foundation/models/transfers/parameters/service.py,sha256=a0TSxLiW_9-W0B67iymtaLxXT4oCIeUNYWoWE_tTSqg,6270
|
74
74
|
maleo_foundation/models/transfers/parameters/signature.py,sha256=ysYkALwqNXn13HP8xUOnPlboL9pgFLmQ9f7OpZe9dDw,483
|
75
75
|
maleo_foundation/models/transfers/parameters/token.py,sha256=kIUhz86-9qEiWxZXIva33-iIdHDS9ca-_7SDvgOxitw,623
|
76
76
|
maleo_foundation/models/transfers/parameters/encryption/__init__.py,sha256=w1-J_cVp8vPUVaAkTEpTTZ5S6R2wKxpqKj1Eu2cj-w0,322
|
@@ -86,15 +86,15 @@ maleo_foundation/models/transfers/results/key.py,sha256=H5U8LBodcpCCJmPRw7zkO6sD
|
|
86
86
|
maleo_foundation/models/transfers/results/signature.py,sha256=lj89dDcQNotM0uWqkz_uXUplGoKXgE4NbaXJfN2m0GI,663
|
87
87
|
maleo_foundation/models/transfers/results/token.py,sha256=4V3UjfrKY1CnCMGlJgwLW-7brHb1_5I7ndY3k0zuL7o,629
|
88
88
|
maleo_foundation/models/transfers/results/client/__init__.py,sha256=xBRuY0NUIPpQEGQ2qoBnqLZGX4W1YSrQ0VnDf5OYJBo,290
|
89
|
-
maleo_foundation/models/transfers/results/client/service.py,sha256=
|
89
|
+
maleo_foundation/models/transfers/results/client/service.py,sha256=7BsyJVUotOz7Ew_EoXwcMpIcU2DdQQh5rOBOOlHbG2k,1192
|
90
90
|
maleo_foundation/models/transfers/results/client/controllers/__init__.py,sha256=x5pcJ33rsG8SqecwL1g762DFoySisTLbZqOqKqKoaKU,173
|
91
91
|
maleo_foundation/models/transfers/results/client/controllers/http.py,sha256=vhjfjchvlTq347mLY2mcE84n_xYMpLkALi_ecQNOAGY,1499
|
92
92
|
maleo_foundation/models/transfers/results/encryption/__init__.py,sha256=Uo8lKBcjlvtCjgPk4sz44GY_fjG3QooatbVYBDFwF8g,307
|
93
93
|
maleo_foundation/models/transfers/results/encryption/aes.py,sha256=yx3hZNhge2lfj8qNM-u9poFs1Ex926ZItOPZJUCFa4c,828
|
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
|
-
maleo_foundation/models/transfers/results/service/general.py,sha256
|
97
|
-
maleo_foundation/models/transfers/results/service/repository.py,sha256=
|
96
|
+
maleo_foundation/models/transfers/results/service/general.py,sha256=RfxzBNZQhMNwNGYnDOygueK_x-xcYmqmkF3VgiX3SUA,1468
|
97
|
+
maleo_foundation/models/transfers/results/service/repository.py,sha256=djITRZh2jrncxd19MyCYBux8C7u906u224U2DPgAQI8,1471
|
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.52.dist-info/METADATA,sha256=WIKB7TkhEdyNXnkLQ8VP8UH-fA55Xj-Rm3tIMQlm1p4,3598
|
121
|
+
maleo_foundation-0.2.52.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
122
|
+
maleo_foundation-0.2.52.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
|
123
|
+
maleo_foundation-0.2.52.dist-info/RECORD,,
|
File without changes
|
File without changes
|