maleo-foundation 0.2.50__tar.gz → 0.2.52__tar.gz

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.
Files changed (130) hide show
  1. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/PKG-INFO +1 -1
  2. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/responses.py +1 -2
  3. maleo_foundation-0.2.52/maleo_foundation/models/schemas/general.py +36 -0
  4. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/schemas/parameter.py +46 -1
  5. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/schemas/result.py +38 -1
  6. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/parameters/client.py +2 -2
  7. maleo_foundation-0.2.52/maleo_foundation/models/transfers/parameters/general.py +21 -0
  8. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/parameters/service.py +2 -2
  9. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/results/client/service.py +1 -2
  10. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/results/service/general.py +1 -2
  11. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/results/service/repository.py +1 -2
  12. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/types.py +1 -0
  13. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/utils/query.py +100 -18
  14. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation.egg-info/PKG-INFO +1 -1
  15. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/pyproject.toml +1 -1
  16. maleo_foundation-0.2.50/maleo_foundation/models/schemas/general.py +0 -104
  17. maleo_foundation-0.2.50/maleo_foundation/models/transfers/parameters/general.py +0 -20
  18. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/README.md +0 -0
  19. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/__init__.py +0 -0
  20. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/authentication.py +0 -0
  21. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/authorization.py +0 -0
  22. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/client/__init__.py +0 -0
  23. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/client/manager.py +0 -0
  24. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/client/services/__init__.py +0 -0
  25. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/client/services/encryption/__init__.py +0 -0
  26. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/client/services/encryption/aes.py +0 -0
  27. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/client/services/encryption/rsa.py +0 -0
  28. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/client/services/hash/__init__.py +0 -0
  29. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/client/services/hash/bcrypt.py +0 -0
  30. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/client/services/hash/hmac.py +0 -0
  31. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/client/services/hash/sha256.py +0 -0
  32. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/client/services/key.py +0 -0
  33. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/client/services/signature.py +0 -0
  34. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/client/services/token.py +0 -0
  35. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/constants.py +0 -0
  36. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/enums.py +0 -0
  37. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/expanded_types/__init__.py +0 -0
  38. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/expanded_types/client.py +0 -0
  39. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/expanded_types/encryption/__init__.py +0 -0
  40. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/expanded_types/encryption/aes.py +0 -0
  41. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/expanded_types/encryption/rsa.py +0 -0
  42. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/expanded_types/general.py +0 -0
  43. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/expanded_types/hash.py +0 -0
  44. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/expanded_types/key.py +0 -0
  45. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/expanded_types/repository.py +0 -0
  46. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/expanded_types/service.py +0 -0
  47. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/expanded_types/signature.py +0 -0
  48. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/expanded_types/token.py +0 -0
  49. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/extended_types.py +0 -0
  50. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/managers/__init__.py +0 -0
  51. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/managers/cache/__init__.py +0 -0
  52. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/managers/cache/base.py +0 -0
  53. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/managers/cache/redis.py +0 -0
  54. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/managers/client/__init__.py +0 -0
  55. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/managers/client/base.py +0 -0
  56. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/managers/client/google/__init__.py +0 -0
  57. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/managers/client/google/base.py +0 -0
  58. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/managers/client/google/parameter.py +0 -0
  59. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/managers/client/google/secret.py +0 -0
  60. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/managers/client/google/storage.py +0 -0
  61. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/managers/client/maleo.py +0 -0
  62. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/managers/db.py +0 -0
  63. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/managers/middleware.py +0 -0
  64. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/managers/service.py +0 -0
  65. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/middlewares/authentication.py +0 -0
  66. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/middlewares/base.py +0 -0
  67. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/middlewares/cors.py +0 -0
  68. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/__init__.py +0 -0
  69. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/schemas/__init__.py +0 -0
  70. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/schemas/encryption.py +0 -0
  71. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/schemas/hash.py +0 -0
  72. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/schemas/key.py +0 -0
  73. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/schemas/signature.py +0 -0
  74. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/schemas/token.py +0 -0
  75. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/table.py +0 -0
  76. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/__init__.py +0 -0
  77. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/general/__init__.py +0 -0
  78. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/general/key.py +0 -0
  79. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/general/signature.py +0 -0
  80. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/general/token.py +0 -0
  81. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/parameters/__init__.py +0 -0
  82. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/parameters/encryption/__init__.py +0 -0
  83. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/parameters/encryption/aes.py +0 -0
  84. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/parameters/encryption/rsa.py +0 -0
  85. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/parameters/hash/__init__.py +0 -0
  86. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/parameters/hash/bcrypt.py +0 -0
  87. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/parameters/hash/hmac.py +0 -0
  88. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/parameters/hash/sha256.py +0 -0
  89. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/parameters/key.py +0 -0
  90. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/parameters/signature.py +0 -0
  91. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/parameters/token.py +0 -0
  92. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/results/__init__.py +0 -0
  93. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/results/client/__init__.py +0 -0
  94. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/results/client/controllers/__init__.py +0 -0
  95. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/results/client/controllers/http.py +0 -0
  96. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/results/encryption/__init__.py +0 -0
  97. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/results/encryption/aes.py +0 -0
  98. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/results/encryption/rsa.py +0 -0
  99. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/results/hash.py +0 -0
  100. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/results/key.py +0 -0
  101. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/results/service/__init__.py +0 -0
  102. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/results/service/controllers/__init__.py +0 -0
  103. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/results/service/controllers/rest.py +0 -0
  104. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/results/signature.py +0 -0
  105. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/models/transfers/results/token.py +0 -0
  106. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/rest_controller_result.py +0 -0
  107. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/utils/__init__.py +0 -0
  108. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/utils/client.py +0 -0
  109. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/utils/controller.py +0 -0
  110. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/utils/dependencies/__init__.py +0 -0
  111. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/utils/dependencies/auth.py +0 -0
  112. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/utils/exceptions.py +0 -0
  113. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/utils/extractor.py +0 -0
  114. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/utils/formatter/__init__.py +0 -0
  115. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/utils/formatter/case.py +0 -0
  116. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/utils/loaders/__init__.py +0 -0
  117. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/utils/loaders/credential/__init__.py +0 -0
  118. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/utils/loaders/credential/google.py +0 -0
  119. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/utils/loaders/json.py +0 -0
  120. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/utils/loaders/key/__init__.py +0 -0
  121. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/utils/loaders/key/rsa.py +0 -0
  122. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/utils/loaders/yaml.py +0 -0
  123. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/utils/logging.py +0 -0
  124. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/utils/mergers.py +0 -0
  125. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation/utils/repository.py +0 -0
  126. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation.egg-info/SOURCES.txt +0 -0
  127. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation.egg-info/dependency_links.txt +0 -0
  128. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation.egg-info/requires.txt +0 -0
  129. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/maleo_foundation.egg-info/top_level.txt +0 -0
  130. {maleo_foundation-0.2.50 → maleo_foundation-0.2.52}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.2.50
3
+ Version: 0.2.52
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -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"] = BaseGeneralSchemas.ExtendedPagination(
85
+ values["pagination"] = BaseResultSchemas.ExtendedPagination(
87
86
  page=page,
88
87
  limit=limit,
89
88
  data_count=len(data),
@@ -0,0 +1,36 @@
1
+ from __future__ import annotations
2
+ from datetime import datetime
3
+ from pydantic import BaseModel, Field
4
+ from uuid import UUID
5
+ from maleo_foundation.enums import BaseEnums
6
+ from maleo_foundation.types import BaseTypes
7
+
8
+ class BaseGeneralSchemas:
9
+ class DateFilter(BaseModel):
10
+ name:str = Field(..., description="Column name.")
11
+ from_date:BaseTypes.OptionalDatetime = Field(None, description="From date.")
12
+ to_date:BaseTypes.OptionalDatetime = Field(None, description="To date.")
13
+
14
+ class SortColumn(BaseModel):
15
+ name:str = Field(..., description="Column name.")
16
+ order:BaseEnums.SortOrder = Field(..., description="Sort order.")
17
+
18
+ class SimplePagination(BaseModel):
19
+ page:int = Field(1, ge=1, description="Page number, must be >= 1.")
20
+ limit:int = Field(10, ge=1, le=100, description="Page size, must be 1 <= limit <= 100.")
21
+
22
+ class PrivateKey(BaseModel):
23
+ private_key:str = Field(..., description="Private key in str format.")
24
+
25
+ class PublicKey(BaseModel):
26
+ public_key:str = Field(..., description="Public key in str format.")
27
+
28
+ class KeyPair(PublicKey, PrivateKey): pass
29
+
30
+ class Status(BaseModel):
31
+ status:BaseEnums.StatusType = Field(..., description="Data's status")
32
+
33
+ class RSAKeys(BaseModel):
34
+ password:str = Field(..., description="Key's password")
35
+ private:str = Field(..., description="Private key")
36
+ public:str = Field(..., description="Public 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:BaseGeneralSchemas.ExtendedPagination = Field(..., description="Pagination metadata")
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
- BaseGeneralSchemas.Search,
12
- BaseGeneralSchemas.Statuses,
11
+ BaseParameterSchemas.Search,
12
+ BaseParameterSchemas.Statuses,
13
13
  BaseParameterSchemas.DateFilters
14
14
  ):
15
15
  pass
@@ -0,0 +1,21 @@
1
+ from __future__ import annotations
2
+ from maleo_foundation.models.schemas.general import BaseGeneralSchemas
3
+ from maleo_foundation.models.schemas.parameter import BaseParameterSchemas
4
+
5
+ class BaseGeneralParametersTransfers:
6
+ class FieldExpansionProcessor(
7
+ BaseParameterSchemas.Expand,
8
+ BaseParameterSchemas.Data
9
+ ): pass
10
+
11
+ class GetSingleQuery(BaseParameterSchemas.Statuses): pass
12
+
13
+ class BaseGetSingle(
14
+ BaseParameterSchemas.IdentifierValue,
15
+ BaseParameterSchemas.IdentifierType
16
+ ):
17
+ pass
18
+
19
+ class GetSingle(BaseParameterSchemas.Statuses, BaseGetSingle): pass
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
- BaseGeneralSchemas.Search,
13
- BaseGeneralSchemas.Statuses,
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 = BaseGeneralSchemas.ExtendedPagination.model_validate(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"] = BaseGeneralSchemas.ExtendedPagination(
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"] = BaseGeneralSchemas.ExtendedPagination(
32
+ values["pagination"] = BaseResultSchemas.ExtendedPagination(
34
33
  page=page,
35
34
  limit=limit,
36
35
  data_count=len(data),
@@ -12,6 +12,7 @@ class BaseTypes:
12
12
  LiteralFalse = Literal[False]
13
13
  LiteralTrue = Literal[True]
14
14
  ListOfBools = List[bool]
15
+ OptionalBoolean = Optional[bool]
15
16
 
16
17
  #* Float-related types
17
18
  ListOfFloats = List[float]
@@ -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
- if isinstance(value, list):
25
- value_filters = [column_attr == val for val in value]
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
- return query
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 = getattr(table, column, None)
40
- if column_attr:
41
- id_filters = [column_attr == id for id in ids]
42
- query = query.filter(or_(*id_filters))
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,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.2.50
3
+ Version: 0.2.52
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "maleo_foundation"
7
- version = "0.2.50"
7
+ version = "0.2.52"
8
8
  description = "Foundation package for Maleo"
9
9
  authors = [
10
10
  { name = "Agra Bima Yuda", email = "agra@nexmedis.com" }
@@ -1,104 +0,0 @@
1
- from __future__ import annotations
2
- from datetime import datetime
3
- from pydantic import BaseModel, Field
4
- from uuid import UUID
5
- from maleo_foundation.enums import BaseEnums
6
- from maleo_foundation.types import BaseTypes
7
-
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
- class DateFilter(BaseModel):
34
- name:str = Field(..., description="Column name.")
35
- from_date:BaseTypes.OptionalDatetime = Field(None, description="From date.")
36
- to_date:BaseTypes.OptionalDatetime = Field(None, description="To date.")
37
-
38
- class Statuses(BaseModel):
39
- statuses:BaseTypes.OptionalListOfStatuses = Field(None, description="Data's status")
40
-
41
- class SortColumn(BaseModel):
42
- name:str = Field(..., description="Column name.")
43
- order:BaseEnums.SortOrder = Field(..., description="Sort order.")
44
-
45
- class SimplePagination(BaseModel):
46
- page:int = Field(1, ge=1, description="Page number, must be >= 1.")
47
- limit:int = Field(10, ge=1, le=100, description="Page size, must be 1 <= limit <= 100.")
48
-
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
- class PrivateKey(BaseModel):
61
- private_key:str = Field(..., description="Private key in str format.")
62
-
63
- class PublicKey(BaseModel):
64
- public_key:str = Field(..., description="Public key in str format.")
65
-
66
- class KeyPair(PublicKey, PrivateKey): pass
67
-
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
- class Status(BaseModel):
81
- status:BaseEnums.StatusType = Field(..., description="Data's status")
82
-
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
- class RSAKeys(BaseModel):
102
- password:str = Field(..., description="Key's password")
103
- private:str = Field(..., description="Private key")
104
- public:str = Field(..., description="Public key")
@@ -1,20 +0,0 @@
1
- from __future__ import annotations
2
- from maleo_foundation.models.schemas.general import BaseGeneralSchemas
3
-
4
- class BaseGeneralParametersTransfers:
5
- class FieldExpansionProcessor(
6
- BaseGeneralSchemas.Expand,
7
- BaseGeneralSchemas.Data
8
- ): pass
9
-
10
- class GetSingleQuery(BaseGeneralSchemas.Statuses): pass
11
-
12
- class BaseGetSingle(
13
- BaseGeneralSchemas.IdentifierValue,
14
- BaseGeneralSchemas.IdentifierType
15
- ):
16
- pass
17
-
18
- class GetSingle(BaseGeneralSchemas.Statuses, BaseGetSingle): pass
19
-
20
- class StatusUpdate(BaseGeneralSchemas.Status): pass