maleo-foundation 0.0.33__py3-none-any.whl → 0.0.35__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.
@@ -30,7 +30,7 @@ class BaseEnums:
30
30
  CREATE = "create"
31
31
  UPDATE = "update"
32
32
 
33
- class UniqueIdentifiers(StrEnum):
33
+ class IdentifierTypes(StrEnum):
34
34
  ID = "id"
35
35
  UUID = "uuid"
36
36
 
@@ -4,36 +4,61 @@ from maleo_foundation.models.transfers.parameters.client import BaseClientParame
4
4
  from maleo_foundation.models.transfers.results.client.service import BaseClientServiceResultsTransfers
5
5
 
6
6
  class ExpandedClientTypes:
7
- GetMultipleParameter = BaseClientParametersTransfers.GetMultiple
7
+ #* Unpaginated multiple data
8
+ GetUnpaginatedMultipleParameter = BaseClientParametersTransfers.GetUnpaginatedMultiple
9
+ GetUnpaginatedMultipleResult = Union[
10
+ BaseClientServiceResultsTransfers.Fail,
11
+ BaseClientServiceResultsTransfers.NoData,
12
+ BaseClientServiceResultsTransfers.UnpaginatedMultipleData
13
+ ]
14
+ SyncGetUnpaginatedMultipleFunction = Callable[
15
+ [GetUnpaginatedMultipleParameter],
16
+ GetUnpaginatedMultipleResult
17
+ ]
18
+ AsyncGetUnpaginatedMultipleFunction = Callable[
19
+ [GetUnpaginatedMultipleParameter],
20
+ Awaitable[GetUnpaginatedMultipleResult]
21
+ ]
8
22
 
9
- GetMultipleResult = Union[
23
+ #* Paginated multiple data
24
+ GetPaginatedMultipleParameter = BaseClientParametersTransfers.GetPaginatedMultiple
25
+ GetPaginatedMultipleResult = Union[
10
26
  BaseClientServiceResultsTransfers.Fail,
11
27
  BaseClientServiceResultsTransfers.NoData,
12
- BaseClientServiceResultsTransfers.UnpaginatedMultipleData,
13
28
  BaseClientServiceResultsTransfers.PaginatedMultipleData
14
29
  ]
30
+ SyncGetPaginatedMultipleFunction = Callable[
31
+ [GetPaginatedMultipleParameter],
32
+ GetPaginatedMultipleResult
33
+ ]
34
+ AsyncGetPaginatedMultipleFunction = Callable[
35
+ [GetPaginatedMultipleParameter],
36
+ Awaitable[GetPaginatedMultipleResult]
37
+ ]
15
38
 
16
- SyncGetMultipleFunction = Callable[[GetMultipleParameter], GetMultipleResult]
17
-
18
- AsyncGetMultipleFunction = Callable[[GetMultipleParameter], Awaitable[GetMultipleResult]]
19
-
39
+ #* Single data
20
40
  GetSingleParameter = BaseGeneralParametersTransfers.GetSingle
21
-
22
41
  GetSingleResult = Union[
23
42
  BaseClientServiceResultsTransfers.Fail,
24
43
  BaseClientServiceResultsTransfers.NoData,
25
44
  BaseClientServiceResultsTransfers.SingleData
26
45
  ]
46
+ SyncGetSingleFunction = Callable[
47
+ [GetSingleParameter],
48
+ GetSingleResult
49
+ ]
50
+ AsyncGetSingleFunction = Callable[
51
+ [GetSingleParameter],
52
+ Awaitable[GetSingleResult]
53
+ ]
27
54
 
28
- SyncGetSingleFunction = Callable[[GetSingleParameter], GetSingleResult]
29
-
30
- AsyncGetSingleFunction = Callable[[GetSingleParameter], Awaitable[GetSingleResult]]
31
-
55
+ #* Create or Update
32
56
  CreateOrUpdateResult = Union[
33
57
  BaseClientServiceResultsTransfers.Fail,
34
58
  BaseClientServiceResultsTransfers.SingleData
35
59
  ]
36
60
 
61
+ #* Status Update
37
62
  StatusUpdateResult = Union[
38
63
  BaseClientServiceResultsTransfers.Fail,
39
64
  BaseClientServiceResultsTransfers.SingleData
@@ -4,36 +4,61 @@ from maleo_foundation.models.transfers.parameters.service import BaseServicePara
4
4
  from maleo_foundation.models.transfers.results.service.query import BaseServiceQueryResultsTransfers
5
5
 
6
6
  class ExpandedQueryTypes:
7
- GetMultipleParameter = BaseServiceParametersTransfers.GetMultiple
7
+ #* Unpaginated multiple data
8
+ GetUnpaginatedMultipleParameter = BaseServiceParametersTransfers.GetUnpaginatedMultiple
9
+ GetUnpaginatedMultipleResult = Union[
10
+ BaseServiceQueryResultsTransfers.Fail,
11
+ BaseServiceQueryResultsTransfers.NoData,
12
+ BaseServiceQueryResultsTransfers.UnpaginatedMultipleData
13
+ ]
14
+ SyncGetUnpaginatedMultipleFunction = Callable[
15
+ [GetUnpaginatedMultipleParameter],
16
+ GetUnpaginatedMultipleResult
17
+ ]
18
+ AsyncGetUnpaginatedMultipleFunction = Callable[
19
+ [GetUnpaginatedMultipleParameter],
20
+ Awaitable[GetUnpaginatedMultipleResult]
21
+ ]
8
22
 
9
- GetMultipleResult = Union[
23
+ #* Paginated multiple data
24
+ GetPaginatedMultipleParameter = BaseServiceParametersTransfers.GetPaginatedMultiple
25
+ GetPaginatedMultipleResult = Union[
10
26
  BaseServiceQueryResultsTransfers.Fail,
11
27
  BaseServiceQueryResultsTransfers.NoData,
12
- BaseServiceQueryResultsTransfers.UnpaginatedMultipleData,
13
28
  BaseServiceQueryResultsTransfers.PaginatedMultipleData
14
29
  ]
30
+ SyncGetPaginatedMultipleFunction = Callable[
31
+ [GetPaginatedMultipleParameter],
32
+ GetPaginatedMultipleResult
33
+ ]
34
+ AsyncGetPaginatedMultipleFunction = Callable[
35
+ [GetPaginatedMultipleParameter],
36
+ Awaitable[GetPaginatedMultipleResult]
37
+ ]
15
38
 
16
- SyncGetMultipleFunction = Callable[[GetMultipleParameter], GetMultipleResult]
17
-
18
- AsyncGetMultipleFunction = Callable[[GetMultipleParameter], Awaitable[GetMultipleResult]]
19
-
39
+ #* Single data
20
40
  GetSingleParameter = BaseGeneralParametersTransfers.GetSingle
21
-
22
41
  GetSingleResult = Union[
23
42
  BaseServiceQueryResultsTransfers.Fail,
24
43
  BaseServiceQueryResultsTransfers.NoData,
25
44
  BaseServiceQueryResultsTransfers.SingleData
26
45
  ]
46
+ SyncGetSingleFunction = Callable[
47
+ [GetSingleParameter],
48
+ GetSingleResult
49
+ ]
50
+ AsyncGetSingleFunction = Callable[
51
+ [GetSingleParameter],
52
+ Awaitable[GetSingleResult]
53
+ ]
27
54
 
28
- SyncGetSingleFunction = Callable[[GetSingleParameter], GetSingleResult]
29
-
30
- AsyncGetSingleFunction = Callable[[GetSingleParameter], Awaitable[GetSingleResult]]
31
-
55
+ #* Create or Update
32
56
  CreateOrUpdateResult = Union[
33
57
  BaseServiceQueryResultsTransfers.Fail,
34
58
  BaseServiceQueryResultsTransfers.SingleData
35
59
  ]
36
60
 
61
+ #* Status update
37
62
  StatusUpdateResult = Union[
38
63
  BaseServiceQueryResultsTransfers.Fail,
39
64
  BaseServiceQueryResultsTransfers.SingleData
@@ -4,36 +4,61 @@ from maleo_foundation.models.transfers.parameters.service import BaseServicePara
4
4
  from maleo_foundation.models.transfers.results.service.general import BaseServiceGeneralResultsTransfers
5
5
 
6
6
  class ExpandedServiceTypes:
7
- GetMultipleParameter = BaseServiceParametersTransfers.GetMultiple
7
+ #* Unpaginated multiple data
8
+ GetUnpaginatedMultipleParameter = BaseServiceParametersTransfers.GetUnpaginatedMultiple
9
+ GetUnpaginatedMultipleResult = Union[
10
+ BaseServiceGeneralResultsTransfers.Fail,
11
+ BaseServiceGeneralResultsTransfers.NoData,
12
+ BaseServiceGeneralResultsTransfers.UnpaginatedMultipleData
13
+ ]
14
+ SyncGetUnpaginatedMultipleFunction = Callable[
15
+ [GetUnpaginatedMultipleParameter],
16
+ GetUnpaginatedMultipleResult
17
+ ]
18
+ AsyncGetUnpaginatedMultipleFunction = Callable[
19
+ [GetUnpaginatedMultipleParameter],
20
+ Awaitable[GetUnpaginatedMultipleResult]
21
+ ]
8
22
 
9
- GetMultipleResult = Union[
23
+ #* Paginated multiple data
24
+ GetPaginatedMultipleParameter = BaseServiceParametersTransfers.GetPaginatedMultiple
25
+ GetPaginatedMultipleResult = Union[
10
26
  BaseServiceGeneralResultsTransfers.Fail,
11
27
  BaseServiceGeneralResultsTransfers.NoData,
12
- BaseServiceGeneralResultsTransfers.UnpaginatedMultipleData,
13
28
  BaseServiceGeneralResultsTransfers.PaginatedMultipleData
14
29
  ]
30
+ SyncGetPaginatedMultipleFunction = Callable[
31
+ [GetPaginatedMultipleParameter],
32
+ GetPaginatedMultipleResult
33
+ ]
34
+ AsyncGetPaginatedMultipleFunction = Callable[
35
+ [GetPaginatedMultipleParameter],
36
+ Awaitable[GetPaginatedMultipleResult]
37
+ ]
15
38
 
16
- SyncGetMultipleFunction = Callable[[GetMultipleParameter], GetMultipleResult]
17
-
18
- AsyncGetMultipleFunction = Callable[[GetMultipleParameter], Awaitable[GetMultipleResult]]
19
-
39
+ #* Single data
20
40
  GetSingleParameter = BaseGeneralParametersTransfers.GetSingle
21
-
22
41
  GetSingleResult = Union[
23
42
  BaseServiceGeneralResultsTransfers.Fail,
24
43
  BaseServiceGeneralResultsTransfers.NoData,
25
44
  BaseServiceGeneralResultsTransfers.SingleData
26
45
  ]
46
+ SyncGetSingleFunction = Callable[
47
+ [GetSingleParameter],
48
+ GetSingleResult
49
+ ]
50
+ AsyncGetSingleFunction = Callable[
51
+ [GetSingleParameter],
52
+ Awaitable[GetSingleResult]
53
+ ]
27
54
 
28
- SyncGetSingleFunction = Callable[[GetSingleParameter], GetSingleResult]
29
-
30
- AsyncGetSingleFunction = Callable[[GetSingleParameter], Awaitable[GetSingleResult]]
31
-
55
+ #* Create or Update
32
56
  CreateOrUpdateResult = Union[
33
57
  BaseServiceGeneralResultsTransfers.Fail,
34
58
  BaseServiceGeneralResultsTransfers.SingleData
35
59
  ]
36
60
 
61
+ #* Status update
37
62
  StatusUpdateResult = Union[
38
63
  BaseServiceGeneralResultsTransfers.Fail,
39
64
  BaseServiceGeneralResultsTransfers.SingleData
@@ -1,13 +1,13 @@
1
1
  from __future__ import annotations
2
2
  from fastapi import status
3
3
  from pydantic import Field, model_validator
4
- from typing import Optional, Any
5
4
  from maleo_foundation.models.schemas.general import BaseGeneralSchemas
6
5
  from maleo_foundation.models.schemas.result import BaseResultSchemas
6
+ from maleo_foundation.models.types import BaseTypes
7
7
 
8
8
  class BaseResponses:
9
9
  class Fail(BaseResultSchemas.Fail):
10
- other:Optional[Any] = Field("Please try again later or contact administrator.", description="Response's other information")
10
+ other:BaseTypes.OptionalAny = Field("Please try again later or contact administrator.", description="Response's other information")
11
11
 
12
12
  class Unauthorized(Fail):
13
13
  code:str = "MAL-ATH-001"
@@ -1,4 +1,7 @@
1
- from pydantic import BaseModel, Field
1
+ import re
2
+ import urllib.parse
3
+ from pydantic import BaseModel, Field, field_validator
4
+ from maleo_foundation.constants import SORT_COLUMN_PATTERN, DATE_FILTER_PATTERN
2
5
  from maleo_foundation.models.enums import BaseEnums
3
6
  from maleo_foundation.models.schemas.general import BaseGeneralSchemas
4
7
  from maleo_foundation.models.types import BaseTypes
@@ -8,11 +11,30 @@ class BaseParameterSchemas:
8
11
  class Filters(BaseModel):
9
12
  filters:BaseTypes.ListOfStrings = Field([], description="Filters for date range, e.g. 'created_at|from::<ISO_DATETIME>|to::<ISO_DATETIME>'.")
10
13
 
14
+ @field_validator("filters")
15
+ @classmethod
16
+ def validate_date_filters(cls, values):
17
+ if isinstance(values, list):
18
+ decoded_values = [urllib.parse.unquote(value) for value in values]
19
+ #* Replace space followed by 2 digits, colon, 2 digits with + and those digits
20
+ fixed_values = []
21
+ for value in decoded_values:
22
+ #* Look for the pattern: space followed by 2 digits, colon, 2 digits
23
+ fixed_value = re.sub(r'(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+) (\d{2}:\d{2})', r'\1+\2', value)
24
+ fixed_values.append(fixed_value)
25
+ final_values = [value for value in fixed_values if DATE_FILTER_PATTERN.match(value)]
26
+ return final_values
27
+
11
28
  class DateFilters(BaseModel):
12
29
  date_filters:ExtendedTypes.ListOfDateFilters = Field([], description="Date filters to be applied")
13
30
 
14
31
  class Sorts(BaseModel):
15
32
  sorts:BaseTypes.ListOfStrings = Field(["id.asc"], description="Sorting columns in 'column_name.asc' or 'column_name.desc' format.")
16
33
 
34
+ @field_validator("sorts")
35
+ @classmethod
36
+ def validate_sorts(cls, values):
37
+ return [value for value in values if SORT_COLUMN_PATTERN.match(value)]
38
+
17
39
  class SortColumns(BaseModel):
18
40
  sort_columns:ExtendedTypes.ListOfSortColumns = Field([BaseGeneralSchemas.SortColumn(name="id", order=BaseEnums.SortOrder.ASC)], description="List of columns to be sorted")
@@ -6,8 +6,7 @@ from maleo_foundation.models.schemas.general import BaseGeneralSchemas
6
6
  from maleo_foundation.models.schemas.parameter import BaseParameterSchemas
7
7
 
8
8
  class BaseClientParametersTransfers:
9
- class GetMultiple(
10
- BaseGeneralSchemas.SimplePagination,
9
+ class GetUnpaginatedMultiple(
11
10
  BaseParameterSchemas.SortColumns,
12
11
  BaseGeneralSchemas.Search,
13
12
  BaseGeneralSchemas.Statuses,
@@ -16,10 +15,63 @@ class BaseClientParametersTransfers:
16
15
  ):
17
16
  pass
18
17
 
19
- class GetMultipleQuery(
18
+ class GetUnpaginatedMultipleQuery(
19
+ BaseParameterSchemas.Sorts,
20
+ BaseParameterSchemas.Filters,
21
+ GetUnpaginatedMultiple
22
+ ):
23
+ @model_validator(mode="after")
24
+ def set_sort(self) -> Self:
25
+ #* Process sort_columns parameters
26
+ sort = []
27
+ for item in self.sort_columns:
28
+ sort.append(f"{item.name}.{item.order.value}")
29
+
30
+ #* Only update if we have valid sort, otherwise keep the default
31
+ if sort:
32
+ self.sorts = sort
33
+
34
+ return self
35
+
36
+ @model_validator(mode="after")
37
+ def set_filter(self) -> Self:
38
+ #* Process filter parameters
39
+ filter = []
40
+ for item in self.date_filters:
41
+ if item.from_date or item.to_date:
42
+ filter_string = item.name
43
+ if item.from_date:
44
+ filter_string += f"|from::{item.from_date.isoformat()}"
45
+ if item.to_date:
46
+ filter_string += f"|to::{item.to_date.isoformat()}"
47
+ filter.append(filter_string)
48
+
49
+ #* Only update if we have valid filter, otherwise keep the default
50
+ if filter:
51
+ self.filters = filter
52
+
53
+ return self
54
+
55
+ def to_query_params(self) -> dict[str, Any]:
56
+ params = {
57
+ "search": self.search,
58
+ "sorts": self.sorts,
59
+ "filters": self.filters,
60
+ }
61
+ if hasattr(self, "statuses") and self.statuses is not None:
62
+ params["statuses"] = self.statuses
63
+ return params
64
+
65
+ class GetPaginatedMultiple(
66
+ BaseGeneralSchemas.SimplePagination,
67
+ GetUnpaginatedMultiple
68
+ ):
69
+ pass
70
+
71
+ class GetPaginatedMultipleQuery(
20
72
  BaseParameterSchemas.Sorts,
21
73
  BaseParameterSchemas.Filters,
22
- GetMultiple
74
+ GetPaginatedMultiple
23
75
  ):
24
76
  @model_validator(mode="after")
25
77
  def set_sort(self) -> Self:
@@ -1,13 +1,12 @@
1
1
  from __future__ import annotations
2
2
  from pydantic import Field
3
- from typing import Union
4
- from uuid import UUID
5
3
  from maleo_foundation.models.enums import BaseEnums
6
4
  from maleo_foundation.models.schemas.general import BaseGeneralSchemas
5
+ from maleo_foundation.models.types import BaseTypes
7
6
 
8
7
  class BaseGeneralParametersTransfers:
9
8
  class GetSingleQuery(BaseGeneralSchemas.Statuses): pass
10
9
 
11
10
  class GetSingle(BaseGeneralSchemas.Statuses):
12
- identifier:BaseEnums.UniqueIdentifiers = Field(..., description="Identifier")
13
- value:Union[int, UUID] = Field(..., description="Value")
11
+ identifier:BaseEnums.IdentifierTypes = Field(..., description="Identifier")
12
+ value:BaseTypes.IdentifierValue = Field(..., description="Value")
@@ -1,48 +1,86 @@
1
1
  from __future__ import annotations
2
- import re
3
- import urllib.parse
4
2
  from datetime import datetime
5
- from pydantic import BaseModel, Field, field_validator, model_validator
6
- from typing import Optional, Self, Any
3
+ from pydantic import BaseModel, Field, model_validator
4
+ from typing import Optional, Self
7
5
  from maleo_foundation.models.enums import BaseEnums
8
6
  from maleo_foundation.models.schemas.general import BaseGeneralSchemas
9
7
  from maleo_foundation.models.schemas.parameter import BaseParameterSchemas
10
- from maleo_foundation.constants import SORT_COLUMN_PATTERN, DATE_FILTER_PATTERN
8
+ from maleo_foundation.models.types import BaseTypes
11
9
 
12
10
  class BaseServiceParametersTransfers:
13
- class GetMultipleQuery(
14
- BaseGeneralSchemas.SimplePagination,
11
+ class GetUnpaginatedMultipleQuery(
15
12
  BaseParameterSchemas.Sorts,
16
13
  BaseGeneralSchemas.Search,
17
14
  BaseGeneralSchemas.Statuses,
18
15
  BaseParameterSchemas.Filters,
19
16
  BaseGeneralSchemas.IDs
17
+ ): pass
18
+
19
+ class GetUnpaginatedMultiple(
20
+ BaseParameterSchemas.SortColumns,
21
+ BaseParameterSchemas.DateFilters,
22
+ GetUnpaginatedMultipleQuery
20
23
  ):
21
- @field_validator("sorts")
22
- @classmethod
23
- def validate_sorts(cls, values):
24
- if not isinstance(values, list):
25
- return ["id.asc"]
26
- return [value for value in values if SORT_COLUMN_PATTERN.match(value)]
27
-
28
- @field_validator("filters")
29
- @classmethod
30
- def validate_date_filters(cls, values):
31
- if isinstance(values, list):
32
- decoded_values = [urllib.parse.unquote(value) for value in values]
33
- #* Replace space followed by 2 digits, colon, 2 digits with + and those digits
34
- fixed_values = []
35
- for value in decoded_values:
36
- #* Look for the pattern: space followed by 2 digits, colon, 2 digits
37
- fixed_value = re.sub(r'(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+) (\d{2}:\d{2})', r'\1+\2', value)
38
- fixed_values.append(fixed_value)
39
- final_values = [value for value in fixed_values if DATE_FILTER_PATTERN.match(value)]
40
- return final_values
41
-
42
- class GetMultiple(
24
+ @model_validator(mode="after")
25
+ def set_sort_columns(self) -> Self:
26
+ #* Process sort parameters
27
+ sort_columns = []
28
+ for item in self.sorts:
29
+ parts = item.split('.')
30
+ if len(parts) == 2 and parts[1].lower() in ["asc", "desc"]:
31
+ try:
32
+ sort_columns.append(BaseGeneralSchemas.SortColumn(name=parts[0], order=BaseEnums.SortOrder(parts[1].lower())))
33
+ except ValueError:
34
+ continue
35
+
36
+ #* Only update if we have valid sort columns, otherwise keep the default
37
+ if sort_columns:
38
+ self.sort_columns = sort_columns
39
+ return self
40
+
41
+ @model_validator(mode="after")
42
+ def set_date_filters(self) -> Self:
43
+ #* Process filter parameters
44
+ date_filters = []
45
+ for filter_item in self.filters:
46
+ parts = filter_item.split('|')
47
+ if len(parts) >= 2 and parts[0]:
48
+ name = parts[0]
49
+ from_date = None
50
+ to_date = None
51
+
52
+ #* Process each part to extract from and to dates
53
+ for part in parts[1:]:
54
+ if part.startswith('from::'):
55
+ try:
56
+ from_date_str = part.replace('from::', '')
57
+ from_date = datetime.fromisoformat(from_date_str)
58
+ except ValueError:
59
+ continue
60
+ elif part.startswith('to::'):
61
+ try:
62
+ to_date_str = part.replace('to::', '')
63
+ to_date = datetime.fromisoformat(to_date_str)
64
+ except ValueError:
65
+ continue
66
+
67
+ #* Only add filter if at least one date is specified
68
+ if from_date or to_date:
69
+ date_filters.append(BaseGeneralSchemas.DateFilter(name=name, from_date=from_date, to_date=to_date))
70
+
71
+ #* Update date_filters
72
+ self.date_filters = date_filters
73
+ return self
74
+
75
+ class GetPaginatedMultipleQuery(
76
+ BaseGeneralSchemas.SimplePagination,
77
+ GetUnpaginatedMultipleQuery
78
+ ): pass
79
+
80
+ class GetPaginatedMultiple(
43
81
  BaseParameterSchemas.SortColumns,
44
82
  BaseParameterSchemas.DateFilters,
45
- GetMultipleQuery
83
+ GetPaginatedMultipleQuery
46
84
  ):
47
85
  @model_validator(mode="after")
48
86
  def set_sort_columns(self) -> Self:
@@ -97,11 +135,11 @@ class BaseServiceParametersTransfers:
97
135
 
98
136
  class UniqueFieldCheck(BaseModel):
99
137
  operation:BaseEnums.OperationType = Field(..., description="Operation to be conducted")
100
- field:BaseEnums.UniqueIdentifiers = Field(..., description="Field to be checked")
101
- new_value:Optional[Any] = Field(..., description="New field's value")
102
- old_value:Optional[Any] = Field(None, description="Old field's value")
138
+ field:BaseEnums.IdentifierTypes = Field(..., description="Field to be checked")
139
+ new_value:BaseTypes.OptionalAny = Field(..., description="New field's value")
140
+ old_value:BaseTypes.OptionalAny = Field(None, description="Old field's value")
103
141
  nullable:bool = Field(False, description="Whether to allow null field's value")
104
- suggestion:Optional[str] = Field(None, description="Suggestion on discrepancy")
142
+ suggestion:BaseTypes.OptionalString = Field(None, description="Suggestion on discrepancy")
105
143
 
106
144
  UniqueFieldChecks = list[UniqueFieldCheck]
107
145
 
maleo_foundation/query.py CHANGED
@@ -3,14 +3,14 @@ from sqlalchemy.orm import Query
3
3
  from sqlalchemy.orm.attributes import InstrumentedAttribute
4
4
  from sqlalchemy.sql.expression import or_, asc, cast, desc
5
5
  from sqlalchemy.types import DATE, String, TEXT, TIMESTAMP
6
- from typing import Optional, Type
6
+ from typing import Type
7
7
  from maleo_foundation.db import DatabaseManager
8
- from maleo_foundation.models.enums import BaseEnums
9
- from maleo_foundation.models.schemas.general import BaseGeneralSchemas
8
+ from maleo_foundation.models.types import BaseTypes
9
+ from maleo_foundation.models.extended_types import ExtendedTypes
10
10
 
11
11
  class BaseQuery:
12
12
  @staticmethod
13
- def filter_ids(query:Query, table:Type[DatabaseManager.Base], column:str, ids:Optional[list[int]]) -> Query:
13
+ def filter_ids(query:Query, table:Type[DatabaseManager.Base], column:str, ids:BaseTypes.OptionalListOfIntegers) -> Query:
14
14
  if ids is not None:
15
15
  column_attr = getattr(table, column, None)
16
16
  if column_attr:
@@ -19,7 +19,7 @@ class BaseQuery:
19
19
  return query
20
20
 
21
21
  @staticmethod
22
- def filter_timestamps(query:Query, table:Type[DatabaseManager.Base], date_filters:list[BaseGeneralSchemas.DateFilter]) -> Query:
22
+ def filter_timestamps(query:Query, table:Type[DatabaseManager.Base], date_filters:ExtendedTypes.ListOfDateFilters) -> Query:
23
23
  if date_filters and len(date_filters) > 0:
24
24
  for date_filter in date_filters:
25
25
  try:
@@ -38,14 +38,14 @@ class BaseQuery:
38
38
  return query
39
39
 
40
40
  @staticmethod
41
- def filter_statuses(query:Query, table:Type[DatabaseManager.Base], statuses:Optional[list[BaseEnums.StatusType]]) -> Query:
41
+ def filter_statuses(query:Query, table:Type[DatabaseManager.Base], statuses:BaseTypes.OptionalListOfStatuses) -> Query:
42
42
  if statuses is not None:
43
43
  status_filters = [table.status == status for status in statuses]
44
44
  query = query.filter(or_(*status_filters))
45
45
  return query
46
46
 
47
47
  @staticmethod
48
- def filter_search(query:Query, table:Type[DatabaseManager.Base], search:Optional[str]) -> Query:
48
+ def filter_search(query:Query, table:Type[DatabaseManager.Base], search:BaseTypes.OptionalString) -> Query:
49
49
  if search:
50
50
  search_term = f"%{search}%" #* Use wildcard for partial matching
51
51
  search_filters = []
@@ -64,7 +64,7 @@ class BaseQuery:
64
64
  return query
65
65
 
66
66
  @staticmethod
67
- def sort(query:Query, table:Type[DatabaseManager.Base], sort_columns:list[BaseGeneralSchemas.SortColumn]) -> Query:
67
+ def sort(query:Query, table:Type[DatabaseManager.Base], sort_columns:ExtendedTypes.ListOfSortColumns) -> Query:
68
68
  for sort_column in sort_columns:
69
69
  try:
70
70
  sort_col = getattr(table, sort_column.name)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.0.33
3
+ Version: 0.0.35
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -1,7 +1,7 @@
1
1
  maleo_foundation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  maleo_foundation/constants.py,sha256=l6WQp0nu2y4Ucs8bFcEdzVUJfR1dRM_nveuHGMhe3rY,424
3
3
  maleo_foundation/controller.py,sha256=Z5WbsrkTFYqC7GrnXR-gsqTN6IC_jz-wrOK3mU4GaU0,3005
4
- maleo_foundation/query.py,sha256=Wv9smUNuAa8ZMvb9KiG_sUqyNFG9KXFo3JX6kpxjWQ4,3868
4
+ maleo_foundation/query.py,sha256=theAgfJy88CsNeloApotzTsJMSG8j2v3CykMGrVR2PI,3864
5
5
  maleo_foundation/clients/__init__.py,sha256=W8vydJYeDEi6gdmOZSBFSSDsfZJtb8C05CHErZgsZ30,188
6
6
  maleo_foundation/clients/general/__init__.py,sha256=l9eQrBeLW4aXtGU5aK3i6fD-msVR4526W7D9V8WCXIg,91
7
7
  maleo_foundation/clients/general/http.py,sha256=Awvs470hgdhZSZW_uoIFJGcJ5hcfDEIX0A2yUaP9UCA,1353
@@ -18,23 +18,23 @@ maleo_foundation/middlewares/__init__.py,sha256=bqE2EIFC3rWcR2AwFPR0fk2kSFfeTRzg
18
18
  maleo_foundation/middlewares/base.py,sha256=KcpODNs0DQXX8Cwc6T9dC6aiZIqxTLtuJjVAGWXPSKk,11633
19
19
  maleo_foundation/middlewares/cors.py,sha256=9uvBvY2N6Vxa9RP_YtESxcWo6Doi6uS0lzAG9iLY7Uc,2288
20
20
  maleo_foundation/models/__init__.py,sha256=HTiSh5eRZ6_iBR2fmylLw_UZNE82GsmzHG3HFBqH2uE,500
21
- maleo_foundation/models/enums.py,sha256=Ob2v312JxypHEq7hTKZKOV462FEeLkIjIhpx-YF6Jdw,2203
21
+ maleo_foundation/models/enums.py,sha256=skLmbrD7DqL1CJN2BCRfWYu5QU1XZVIa_SoJnZbZcrs,2201
22
22
  maleo_foundation/models/extended_types.py,sha256=pIKt-_9tby4rmune3fmWcCW_mohaNRh_1lywBmdc-L4,301
23
- maleo_foundation/models/responses.py,sha256=1Rs3EflBJdsTC8PSbaOFbbTyxwRwK031eU3qLEj21sU,4215
23
+ maleo_foundation/models/responses.py,sha256=pAHlRzbLJtlu9TwMtLBK7nbtjsvKnV0cJtbvtQH2l8E,4242
24
24
  maleo_foundation/models/types.py,sha256=rg9AoNwwECJ2BhYdoz3DiUMlBgFRWVEl4KGrfTCntnI,1213
25
25
  maleo_foundation/models/expanded_types/__init__.py,sha256=RohoIQCiMvo2g6Jacq2dlqNXg3WLmRc-TD8nvMsyDKs,275
26
- maleo_foundation/models/expanded_types/client.py,sha256=FlZnuPmYmjexXe8afxKXUzWX2Eq7Xw4tsyekZbVAHts,1582
27
- maleo_foundation/models/expanded_types/query.py,sha256=0rNLdaqKL-QGzd5EX1RRphJQpXb1XCZQfEfVFIIdBUc,1571
28
- maleo_foundation/models/expanded_types/service.py,sha256=N-HT6DXah839YefCHuLUB63Zpl1YUogzcHbVwdW2vXA,1599
26
+ maleo_foundation/models/expanded_types/client.py,sha256=To0kRXp3QTmuSu5rWKaCiTsMK9qkYiyYKYbHfw-y1fY,2396
27
+ maleo_foundation/models/expanded_types/query.py,sha256=0yUG-JIVsanzB7KAkrRz_OsrhP6J0bRqD9Q3l3atQnk,2384
28
+ maleo_foundation/models/expanded_types/service.py,sha256=q8jpKdbCbLWwH1UPQavKpVE14rC5rveduk2cFWzuhGw,2416
29
29
  maleo_foundation/models/schemas/__init__.py,sha256=Xj8Ahsqyra-fmEaVcGPok5GOOsPQlKcknHYMvbjvENA,277
30
30
  maleo_foundation/models/schemas/general.py,sha256=JwsAP-rLO_o4lgPUi9gYHGhwzV7KVzsg8axAJZNyxlw,6680
31
- maleo_foundation/models/schemas/parameter.py,sha256=LN-MNuvACMYTCZoxojC-Bqo4YYMmAYCriVnLy85dH6c,1012
31
+ maleo_foundation/models/schemas/parameter.py,sha256=YixHZXszx9dtmiSGypf9cNxaHw7NS78VJcrTDhGlBpg,2121
32
32
  maleo_foundation/models/schemas/result.py,sha256=69JsTor9gNTVhUErFsFWN8CC9SZ9aXUO08kziGbXxsY,1754
33
33
  maleo_foundation/models/transfers/__init__.py,sha256=B8oCZHE3NTsrJ_rviSXaDsuc-gc25jpjuhJO40lpQiE,222
34
34
  maleo_foundation/models/transfers/parameters/__init__.py,sha256=oKW4RPIEISISRjsJzD8lsCGY1HhZRTzshPpWHcJu86k,353
35
- maleo_foundation/models/transfers/parameters/client.py,sha256=Q43A-Z7JPXcxb_v7iUKoA1_WV8AMdEaeSl9Z39WSF_8,2287
36
- maleo_foundation/models/transfers/parameters/general.py,sha256=TDDUAc7GsKA9jhpan5BqoGVpOcwJPHpV34atXEd0D60,532
37
- maleo_foundation/models/transfers/parameters/service.py,sha256=4_khFthR0JD5FklRYQNCG_8gMJmLTfAno7kQFEK1An4,5358
35
+ maleo_foundation/models/transfers/parameters/client.py,sha256=GjRYMDO9I0ZEfFPFJTn1CIFHYX1tvEF6kY5olD2xqR0,4059
36
+ maleo_foundation/models/transfers/parameters/general.py,sha256=Doyr_T_2JvsqDc4r00iB2dqAtBErHMM8RZz6ItyZZ7o,544
37
+ maleo_foundation/models/transfers/parameters/service.py,sha256=8pcUR7bGMepC5G35Jr-iXlfLVyXxahb2erfIEFs6ebE,6771
38
38
  maleo_foundation/models/transfers/results/__init__.py,sha256=0_8uJ1IQW87RZ4nIxzWkQVi3Fxb7B8myZTngXfoxgNc,241
39
39
  maleo_foundation/models/transfers/results/client/__init__.py,sha256=xBRuY0NUIPpQEGQ2qoBnqLZGX4W1YSrQ0VnDf5OYJBo,290
40
40
  maleo_foundation/models/transfers/results/client/service.py,sha256=TO_U53vmUEnFWiiyuu33ao3BUidt6KFxvk3GC9uo8JE,1108
@@ -50,7 +50,7 @@ maleo_foundation/utils/exceptions.py,sha256=mcvBwHm6uWpVQkPtO1T2j-GaTYEiyPOeGxiD
50
50
  maleo_foundation/utils/logger.py,sha256=ICrFi0MxuAjDy8KTRL7pex1miwzZqZX-HHArgN3niJM,2453
51
51
  maleo_foundation/utils/formatter/__init__.py,sha256=iKf5YCbEdg1qKnFHyKqqcQbqAqEeRUf8mhI3v3dQoj8,78
52
52
  maleo_foundation/utils/formatter/case.py,sha256=TmvvlfzGdC_omMTB5vAa40TZBxQ3hnr-SYeo0M52Rlg,1352
53
- maleo_foundation-0.0.33.dist-info/METADATA,sha256=fGpHuBcoyjtBsKgInq1DNYKzuZ-N4pmxwaCzqzF74Fo,3160
54
- maleo_foundation-0.0.33.dist-info/WHEEL,sha256=lTU6B6eIfYoiQJTZNc-fyaR6BpL6ehTzU3xGYxn2n8k,91
55
- maleo_foundation-0.0.33.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
56
- maleo_foundation-0.0.33.dist-info/RECORD,,
53
+ maleo_foundation-0.0.35.dist-info/METADATA,sha256=bCqkcVTKxZPsoWXF9_W3EMuu_0-70cSue03N2CYq7PQ,3160
54
+ maleo_foundation-0.0.35.dist-info/WHEEL,sha256=lTU6B6eIfYoiQJTZNc-fyaR6BpL6ehTzU3xGYxn2n8k,91
55
+ maleo_foundation-0.0.35.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
56
+ maleo_foundation-0.0.35.dist-info/RECORD,,