maleo-foundation 0.3.45__py3-none-any.whl → 0.3.47__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.
Files changed (135) hide show
  1. maleo_foundation/authentication.py +24 -13
  2. maleo_foundation/authorization.py +2 -1
  3. maleo_foundation/client/manager.py +22 -21
  4. maleo_foundation/client/services/__init__.py +16 -7
  5. maleo_foundation/client/services/encryption/__init__.py +13 -4
  6. maleo_foundation/client/services/encryption/aes.py +41 -36
  7. maleo_foundation/client/services/encryption/rsa.py +50 -50
  8. maleo_foundation/client/services/hash/__init__.py +19 -6
  9. maleo_foundation/client/services/hash/bcrypt.py +20 -18
  10. maleo_foundation/client/services/hash/hmac.py +20 -17
  11. maleo_foundation/client/services/hash/sha256.py +18 -15
  12. maleo_foundation/client/services/key.py +50 -42
  13. maleo_foundation/client/services/signature.py +46 -42
  14. maleo_foundation/client/services/token.py +49 -58
  15. maleo_foundation/constants.py +13 -14
  16. maleo_foundation/enums.py +14 -13
  17. maleo_foundation/expanded_types/__init__.py +2 -3
  18. maleo_foundation/expanded_types/client.py +30 -34
  19. maleo_foundation/expanded_types/encryption/__init__.py +2 -1
  20. maleo_foundation/expanded_types/encryption/aes.py +7 -5
  21. maleo_foundation/expanded_types/encryption/rsa.py +7 -5
  22. maleo_foundation/expanded_types/general.py +13 -11
  23. maleo_foundation/expanded_types/hash.py +7 -5
  24. maleo_foundation/expanded_types/key.py +8 -6
  25. maleo_foundation/expanded_types/service.py +30 -34
  26. maleo_foundation/expanded_types/signature.py +7 -5
  27. maleo_foundation/expanded_types/token.py +7 -5
  28. maleo_foundation/extended_types.py +4 -3
  29. maleo_foundation/managers/cache.py +2 -1
  30. maleo_foundation/managers/client/base.py +25 -12
  31. maleo_foundation/managers/client/google/base.py +11 -4
  32. maleo_foundation/managers/client/google/parameter.py +9 -11
  33. maleo_foundation/managers/client/google/secret.py +53 -35
  34. maleo_foundation/managers/client/google/storage.py +52 -22
  35. maleo_foundation/managers/client/google/subscription.py +37 -39
  36. maleo_foundation/managers/client/maleo.py +18 -23
  37. maleo_foundation/managers/configuration.py +5 -9
  38. maleo_foundation/managers/credential.py +14 -17
  39. maleo_foundation/managers/db.py +51 -40
  40. maleo_foundation/managers/middleware.py +9 -9
  41. maleo_foundation/managers/service.py +47 -54
  42. maleo_foundation/middlewares/authentication.py +29 -54
  43. maleo_foundation/middlewares/base.py +83 -72
  44. maleo_foundation/middlewares/cors.py +8 -7
  45. maleo_foundation/models/__init__.py +2 -1
  46. maleo_foundation/models/responses.py +57 -29
  47. maleo_foundation/models/schemas/__init__.py +2 -1
  48. maleo_foundation/models/schemas/encryption.py +5 -2
  49. maleo_foundation/models/schemas/general.py +38 -18
  50. maleo_foundation/models/schemas/hash.py +2 -1
  51. maleo_foundation/models/schemas/key.py +5 -2
  52. maleo_foundation/models/schemas/parameter.py +45 -15
  53. maleo_foundation/models/schemas/result.py +35 -20
  54. maleo_foundation/models/schemas/signature.py +5 -2
  55. maleo_foundation/models/schemas/token.py +5 -2
  56. maleo_foundation/models/table.py +33 -27
  57. maleo_foundation/models/transfers/__init__.py +2 -1
  58. maleo_foundation/models/transfers/general/__init__.py +2 -1
  59. maleo_foundation/models/transfers/general/configurations/__init__.py +10 -4
  60. maleo_foundation/models/transfers/general/configurations/cache/__init__.py +3 -2
  61. maleo_foundation/models/transfers/general/configurations/cache/redis.py +13 -5
  62. maleo_foundation/models/transfers/general/configurations/client/__init__.py +5 -1
  63. maleo_foundation/models/transfers/general/configurations/client/maleo.py +38 -12
  64. maleo_foundation/models/transfers/general/configurations/database.py +5 -2
  65. maleo_foundation/models/transfers/general/configurations/middleware.py +22 -15
  66. maleo_foundation/models/transfers/general/configurations/service.py +2 -1
  67. maleo_foundation/models/transfers/general/credentials.py +2 -1
  68. maleo_foundation/models/transfers/general/database.py +11 -4
  69. maleo_foundation/models/transfers/general/key.py +13 -4
  70. maleo_foundation/models/transfers/general/request.py +28 -9
  71. maleo_foundation/models/transfers/general/settings.py +12 -22
  72. maleo_foundation/models/transfers/general/signature.py +4 -2
  73. maleo_foundation/models/transfers/general/token.py +34 -27
  74. maleo_foundation/models/transfers/parameters/__init__.py +2 -1
  75. maleo_foundation/models/transfers/parameters/client.py +15 -19
  76. maleo_foundation/models/transfers/parameters/encryption/__init__.py +2 -1
  77. maleo_foundation/models/transfers/parameters/encryption/aes.py +7 -5
  78. maleo_foundation/models/transfers/parameters/encryption/rsa.py +7 -5
  79. maleo_foundation/models/transfers/parameters/general.py +15 -13
  80. maleo_foundation/models/transfers/parameters/hash/__init__.py +2 -1
  81. maleo_foundation/models/transfers/parameters/hash/bcrypt.py +5 -5
  82. maleo_foundation/models/transfers/parameters/hash/hmac.py +6 -6
  83. maleo_foundation/models/transfers/parameters/hash/sha256.py +5 -5
  84. maleo_foundation/models/transfers/parameters/key.py +9 -8
  85. maleo_foundation/models/transfers/parameters/service.py +42 -48
  86. maleo_foundation/models/transfers/parameters/signature.py +7 -4
  87. maleo_foundation/models/transfers/parameters/token.py +10 -10
  88. maleo_foundation/models/transfers/results/__init__.py +2 -1
  89. maleo_foundation/models/transfers/results/client/__init__.py +2 -1
  90. maleo_foundation/models/transfers/results/client/controllers/__init__.py +2 -1
  91. maleo_foundation/models/transfers/results/client/controllers/http.py +10 -7
  92. maleo_foundation/models/transfers/results/client/service.py +12 -6
  93. maleo_foundation/models/transfers/results/encryption/__init__.py +2 -1
  94. maleo_foundation/models/transfers/results/encryption/aes.py +13 -5
  95. maleo_foundation/models/transfers/results/encryption/rsa.py +12 -4
  96. maleo_foundation/models/transfers/results/hash.py +7 -3
  97. maleo_foundation/models/transfers/results/key.py +18 -6
  98. maleo_foundation/models/transfers/results/service/__init__.py +2 -3
  99. maleo_foundation/models/transfers/results/service/controllers/__init__.py +2 -1
  100. maleo_foundation/models/transfers/results/service/controllers/rest.py +14 -11
  101. maleo_foundation/models/transfers/results/service/general.py +16 -10
  102. maleo_foundation/models/transfers/results/signature.py +12 -4
  103. maleo_foundation/models/transfers/results/token.py +10 -4
  104. maleo_foundation/rest_controller_result.py +23 -21
  105. maleo_foundation/types.py +15 -14
  106. maleo_foundation/utils/__init__.py +2 -1
  107. maleo_foundation/utils/cache.py +10 -13
  108. maleo_foundation/utils/client.py +25 -12
  109. maleo_foundation/utils/controller.py +59 -37
  110. maleo_foundation/utils/dependencies/__init__.py +2 -1
  111. maleo_foundation/utils/dependencies/auth.py +5 -12
  112. maleo_foundation/utils/dependencies/context.py +3 -4
  113. maleo_foundation/utils/exceptions.py +50 -28
  114. maleo_foundation/utils/extractor.py +18 -6
  115. maleo_foundation/utils/formatter/__init__.py +2 -1
  116. maleo_foundation/utils/formatter/case.py +5 -4
  117. maleo_foundation/utils/loaders/__init__.py +2 -1
  118. maleo_foundation/utils/loaders/credential/__init__.py +2 -1
  119. maleo_foundation/utils/loaders/credential/google.py +29 -15
  120. maleo_foundation/utils/loaders/json.py +3 -2
  121. maleo_foundation/utils/loaders/key/__init__.py +2 -1
  122. maleo_foundation/utils/loaders/key/rsa.py +26 -13
  123. maleo_foundation/utils/loaders/yaml.py +2 -1
  124. maleo_foundation/utils/logging.py +70 -46
  125. maleo_foundation/utils/merger.py +7 -9
  126. maleo_foundation/utils/query.py +41 -34
  127. maleo_foundation/utils/repository.py +28 -13
  128. maleo_foundation/utils/searcher.py +4 -6
  129. {maleo_foundation-0.3.45.dist-info → maleo_foundation-0.3.47.dist-info}/METADATA +14 -1
  130. maleo_foundation-0.3.47.dist-info/RECORD +137 -0
  131. maleo_foundation/expanded_types/repository.py +0 -68
  132. maleo_foundation/models/transfers/results/service/repository.py +0 -39
  133. maleo_foundation-0.3.45.dist-info/RECORD +0 -139
  134. {maleo_foundation-0.3.45.dist-info → maleo_foundation-0.3.47.dist-info}/WHEEL +0 -0
  135. {maleo_foundation-0.3.45.dist-info → maleo_foundation-0.3.47.dist-info}/top_level.txt +0 -0
@@ -5,9 +5,13 @@ from typing import Dict, Type, Union
5
5
  from maleo_foundation.models.schemas.result import BaseResultSchemas
6
6
  from maleo_foundation.types import BaseTypes
7
7
 
8
+
8
9
  class BaseResponses:
9
10
  class Fail(BaseResultSchemas.Fail):
10
- other: BaseTypes.OptionalAny = Field("Please try again later or contact administrator.", description="Response's other information")
11
+ other: BaseTypes.OptionalAny = Field(
12
+ "Please try again later or contact administrator.",
13
+ description="Response's other information",
14
+ )
11
15
 
12
16
  class BadRequest(Fail):
13
17
  code: str = "MAL-BDR-001"
@@ -17,17 +21,23 @@ class BaseResponses:
17
21
  class InvalidExpand(BadRequest):
18
22
  code: str = "MAL-INE-001"
19
23
  message: str = "Invalid expand"
20
- description: str = "Invalid expand field(s) configuration are given. Check 'other' for more information."
24
+ description: str = (
25
+ "Invalid expand field(s) configuration are given. Check 'other' for more information."
26
+ )
21
27
 
22
28
  class InvalidParameter(BadRequest):
23
29
  code: str = "MAL-IPR-001"
24
30
  message: str = "Invalid parameters"
25
- description: str = "Invalid parameters and/or parameters combinations is given. Check 'other' for more information."
31
+ description: str = (
32
+ "Invalid parameters and/or parameters combinations is given. Check 'other' for more information."
33
+ )
26
34
 
27
35
  class InvalidSystemRole(BadRequest):
28
36
  code: str = "MAL-ISR-001"
29
37
  message: str = "Invalid system role"
30
- description: str = "Invalid system role is detected in authorization token. Check 'other' for more information."
38
+ description: str = (
39
+ "Invalid system role is detected in authorization token. Check 'other' for more information."
40
+ )
31
41
 
32
42
  class Unauthorized(Fail):
33
43
  code: str = "MAL-ATH-001"
@@ -47,12 +57,16 @@ class BaseResponses:
47
57
  class ValidationError(Fail):
48
58
  code: str = "MAL-VLD-001"
49
59
  message: str = "Validation Error"
50
- description: str = "Request validation failed due to missing or invalid fields. Check other for more info."
60
+ description: str = (
61
+ "Request validation failed due to missing or invalid fields. Check other for more info."
62
+ )
51
63
 
52
64
  class RateLimitExceeded(Fail):
53
65
  code: str = "MAL-RTL-001"
54
66
  message: str = "Rate Limit Exceeded"
55
- description: str = "This resource is requested too many times. Please try again later."
67
+ description: str = (
68
+ "This resource is requested too many times. Please try again later."
69
+ )
56
70
 
57
71
  class ServerError(Fail):
58
72
  code: str = "MAL-EXC-001"
@@ -64,17 +78,31 @@ class BaseResponses:
64
78
  message: str = "Not Implemented"
65
79
  description: str = "This request is not yet implemented by the system."
66
80
 
67
- class NotFound(BaseResultSchemas.NotFound): pass
81
+ class NotFound(Fail):
82
+ code: str = "MAL-NTF-001"
83
+ message: str = "Resource not found"
84
+ description: str = "The requested resource can not be found."
68
85
 
69
- class NoData(BaseResultSchemas.NoData): pass
86
+ class NoData(BaseResultSchemas.NoData):
87
+ pass
70
88
 
71
- class SingleData(BaseResultSchemas.SingleData): pass
89
+ class SingleData(BaseResultSchemas.SingleData):
90
+ pass
72
91
 
73
- class UnpaginatedMultipleData(BaseResultSchemas.UnpaginatedMultipleData): pass
92
+ class UnpaginatedMultipleData(BaseResultSchemas.UnpaginatedMultipleData):
93
+ pass
74
94
 
75
95
  class PaginatedMultipleData(BaseResultSchemas.PaginatedMultipleData):
76
- page: int = Field(1, ge=1, description="Page number, must be >= 1.", exclude=True)
77
- limit: int = Field(10, ge=1, le=100, description="Page size, must be 1 <= limit <= 100.", exclude=True)
96
+ page: int = Field(
97
+ 1, ge=1, description="Page number, must be >= 1.", exclude=True
98
+ )
99
+ limit: int = Field(
100
+ 10,
101
+ ge=1,
102
+ le=100,
103
+ description="Page size, must be 1 <= limit <= 100.",
104
+ exclude=True,
105
+ )
78
106
  total_data: int = Field(..., ge=0, description="Total data count", exclude=True)
79
107
 
80
108
  @model_validator(mode="before")
@@ -84,59 +112,59 @@ class BaseResponses:
84
112
  total_data = values.get("total_data", 0)
85
113
  data = values.get("data", [])
86
114
 
87
- #* Get pagination values from inherited SimplePagination
115
+ # * Get pagination values from inherited SimplePagination
88
116
  page = values.get("page", 1)
89
117
  limit = values.get("limit", 10)
90
118
 
91
- #* Calculate total pages
119
+ # * Calculate total pages
92
120
  total_pages = (total_data // limit) + (1 if total_data % limit > 0 else 0)
93
121
 
94
- #* Assign computed pagination object before validation
122
+ # * Assign computed pagination object before validation
95
123
  values["pagination"] = BaseResultSchemas.ExtendedPagination(
96
124
  page=page,
97
125
  limit=limit,
98
126
  data_count=len(data),
99
127
  total_data=total_data,
100
- total_pages=total_pages
128
+ total_pages=total_pages,
101
129
  )
102
130
  return values
103
131
 
104
- #* ----- ----- Responses Class ----- ----- *#
105
- other_responses:Dict[int, Dict[str, Union[str, Type[Fail]]]]={
132
+ # * ----- ----- Responses Class ----- ----- *#
133
+ other_responses: Dict[int, Dict[str, Union[str, Type[Fail]]]] = {
106
134
  status.HTTP_400_BAD_REQUEST: {
107
135
  "description": "Bad Request Response",
108
- "model": BadRequest
136
+ "model": BadRequest,
109
137
  },
110
138
  status.HTTP_401_UNAUTHORIZED: {
111
139
  "description": "Unauthorized Response",
112
- "model": Unauthorized
140
+ "model": Unauthorized,
113
141
  },
114
142
  status.HTTP_403_FORBIDDEN: {
115
143
  "description": "Forbidden Response",
116
- "model": Forbidden
144
+ "model": Forbidden,
117
145
  },
118
146
  status.HTTP_404_NOT_FOUND: {
119
147
  "description": "Not Found Response",
120
- "model": NotFound
148
+ "model": NotFound,
121
149
  },
122
150
  status.HTTP_405_METHOD_NOT_ALLOWED: {
123
151
  "description": "Method Not Allowed Response",
124
- "model": MethodNotAllowed
152
+ "model": MethodNotAllowed,
125
153
  },
126
154
  status.HTTP_422_UNPROCESSABLE_ENTITY: {
127
155
  "description": "Validation Error Response",
128
- "model": ValidationError
156
+ "model": ValidationError,
129
157
  },
130
158
  status.HTTP_429_TOO_MANY_REQUESTS: {
131
159
  "description": "Rate Limit Exceeded Response",
132
- "model": RateLimitExceeded
160
+ "model": RateLimitExceeded,
133
161
  },
134
162
  status.HTTP_500_INTERNAL_SERVER_ERROR: {
135
163
  "description": "Internal Server Error Response",
136
- "model": ServerError
164
+ "model": ServerError,
137
165
  },
138
166
  status.HTTP_501_NOT_IMPLEMENTED: {
139
167
  "description": "Not Implemented Response",
140
- "model": ServerError
141
- }
142
- }
168
+ "model": ServerError,
169
+ },
170
+ }
@@ -3,7 +3,8 @@ from .general import BaseGeneralSchemas
3
3
  from .parameter import BaseParameterSchemas
4
4
  from .result import BaseResultSchemas
5
5
 
6
+
6
7
  class BaseSchemas:
7
8
  General = BaseGeneralSchemas
8
9
  Parameter = BaseParameterSchemas
9
- Result = BaseResultSchemas
10
+ Result = BaseResultSchemas
@@ -1,12 +1,15 @@
1
1
  from pydantic import BaseModel, Field
2
2
  from maleo_foundation.types import BaseTypes
3
3
 
4
+
4
5
  class MaleoFoundationEncryptionSchemas:
5
6
  class Key(BaseModel):
6
7
  key: str = Field(..., description="Key")
7
8
 
8
9
  class Password(BaseModel):
9
- password: BaseTypes.OptionalString = Field(None, min_length=32, max_length=1024, description="password")
10
+ password: BaseTypes.OptionalString = Field(
11
+ None, min_length=32, max_length=1024, description="password"
12
+ )
10
13
 
11
14
  class InitializationVector(BaseModel):
12
15
  initialization_vector: str = Field(..., description="Initialization vector")
@@ -15,4 +18,4 @@ class MaleoFoundationEncryptionSchemas:
15
18
  plaintext: str = Field(..., description="Plaintext")
16
19
 
17
20
  class Ciphertext(BaseModel):
18
- ciphertext: str = Field(..., description="Ciphertext")
21
+ ciphertext: str = Field(..., description="Ciphertext")
@@ -5,6 +5,7 @@ from uuid import UUID
5
5
  from maleo_foundation.enums import BaseEnums
6
6
  from maleo_foundation.types import BaseTypes
7
7
 
8
+
8
9
  class BaseGeneralSchemas:
9
10
  class DateFilter(BaseModel):
10
11
  name: str = Field(..., description="Column name.")
@@ -17,9 +18,11 @@ class BaseGeneralSchemas:
17
18
 
18
19
  class SimplePagination(BaseModel):
19
20
  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
+ limit: int = Field(
22
+ 10, ge=1, le=100, description="Page size, must be 1 <= limit <= 100."
23
+ )
21
24
 
22
- #* ----- ----- ----- Data ----- ----- ----- *#
25
+ # * ----- ----- ----- Data ----- ----- ----- *#
23
26
  class Identifiers(BaseModel):
24
27
  id: int = Field(..., ge=1, description="Data's ID, must be >= 1.")
25
28
  uuid: UUID = Field(..., description="Data's UUID.")
@@ -29,33 +32,47 @@ class BaseGeneralSchemas:
29
32
  updated_at: datetime = Field(..., description="Data's updated_at timestamp")
30
33
 
31
34
  class StatusTimestamps(BaseModel):
32
- deleted_at: BaseTypes.OptionalDatetime = Field(..., description="Data's deleted_at timestamp")
33
- restored_at: BaseTypes.OptionalDatetime = Field(..., description="Data's restored_at timestamp")
34
- deactivated_at: BaseTypes.OptionalDatetime = Field(..., description="Data's deactivated_at timestamp")
35
+ deleted_at: BaseTypes.OptionalDatetime = Field(
36
+ ..., description="Data's deleted_at timestamp"
37
+ )
38
+ restored_at: BaseTypes.OptionalDatetime = Field(
39
+ ..., description="Data's restored_at timestamp"
40
+ )
41
+ deactivated_at: BaseTypes.OptionalDatetime = Field(
42
+ ..., description="Data's deactivated_at timestamp"
43
+ )
35
44
  activated_at: datetime = Field(..., description="Data's activated_at timestamp")
36
45
 
37
- class Timestamps(
38
- StatusTimestamps,
39
- EssentialTimestamps
40
- ): pass
46
+ class Timestamps(StatusTimestamps, EssentialTimestamps):
47
+ pass
41
48
 
42
49
  class Status(BaseModel):
43
50
  status: BaseEnums.StatusType = Field(..., description="Data's status")
44
51
 
45
52
  class IsDefault(BaseModel):
46
- is_default: BaseTypes.OptionalBoolean = Field(None, description="Whether data is default")
53
+ is_default: BaseTypes.OptionalBoolean = Field(
54
+ None, description="Whether data is default"
55
+ )
47
56
 
48
57
  class IsRoot(BaseModel):
49
- is_root: BaseTypes.OptionalBoolean = Field(None, description="Whether data is root")
58
+ is_root: BaseTypes.OptionalBoolean = Field(
59
+ None, description="Whether data is root"
60
+ )
50
61
 
51
62
  class IsParent(BaseModel):
52
- is_parent: BaseTypes.OptionalBoolean = Field(None, description="Whether data is parent")
63
+ is_parent: BaseTypes.OptionalBoolean = Field(
64
+ None, description="Whether data is parent"
65
+ )
53
66
 
54
67
  class IsChild(BaseModel):
55
- is_child: BaseTypes.OptionalBoolean = Field(None, description="Whether data is child")
68
+ is_child: BaseTypes.OptionalBoolean = Field(
69
+ None, description="Whether data is child"
70
+ )
56
71
 
57
72
  class IsLeaf(BaseModel):
58
- is_leaf: BaseTypes.OptionalBoolean = Field(None, description="Whether data is leaf")
73
+ is_leaf: BaseTypes.OptionalBoolean = Field(
74
+ None, description="Whether data is leaf"
75
+ )
59
76
 
60
77
  class Order(BaseModel):
61
78
  order: BaseTypes.OptionalInteger = Field(..., description="Data's order")
@@ -72,14 +89,15 @@ class BaseGeneralSchemas:
72
89
  class Secret(BaseModel):
73
90
  secret: UUID = Field(..., description="Data's secret")
74
91
 
75
- #* ----- ----- ----- RSA Key ----- ----- ----- *#
92
+ # * ----- ----- ----- RSA Key ----- ----- ----- *#
76
93
  class PrivateKey(BaseModel):
77
94
  private_key: str = Field(..., description="Private key in str format.")
78
95
 
79
96
  class PublicKey(BaseModel):
80
97
  public_key: str = Field(..., description="Public key in str format.")
81
98
 
82
- class KeyPair(PublicKey, PrivateKey): pass
99
+ class KeyPair(PublicKey, PrivateKey):
100
+ pass
83
101
 
84
102
  class RSAKeys(BaseModel):
85
103
  password: str = Field(..., description="Key's password")
@@ -87,7 +105,9 @@ class BaseGeneralSchemas:
87
105
  public: str = Field(..., description="Public key")
88
106
 
89
107
  class AccessedAt(BaseModel):
90
- accessed_at: datetime = Field(datetime.now(tz=timezone.utc), description="Accessed at")
108
+ accessed_at: datetime = Field(
109
+ datetime.now(tz=timezone.utc), description="Accessed at"
110
+ )
91
111
 
92
112
  class AccessedBy(BaseModel):
93
- accessed_by: int = Field(0, ge=0, description="Accessed by")
113
+ accessed_by: int = Field(0, ge=0, description="Accessed by")
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
  from pydantic import BaseModel, Field
3
3
 
4
+
4
5
  class MaleoFoundationHashSchemas:
5
6
  class Key(BaseModel):
6
7
  key: str = Field(..., description="Key")
@@ -12,4 +13,4 @@ class MaleoFoundationHashSchemas:
12
13
  hash: str = Field(..., description="Hash")
13
14
 
14
15
  class IsValid(BaseModel):
15
- is_valid: bool = Field(..., description="Is valid hash")
16
+ is_valid: bool = Field(..., description="Is valid hash")
@@ -3,13 +3,16 @@ from pydantic import BaseModel, Field
3
3
  from maleo_foundation.enums import BaseEnums
4
4
  from maleo_foundation.types import BaseTypes
5
5
 
6
+
6
7
  class BaseKeySchemas:
7
8
  class KeySize(BaseModel):
8
9
  key_size: int = Field(2048, ge=2048, le=16384, description="Key's size")
9
10
 
10
11
  class Password(BaseModel):
11
- password: BaseTypes.OptionalString = Field(None, min_length=32, max_length=1024, description="password")
12
+ password: BaseTypes.OptionalString = Field(
13
+ None, min_length=32, max_length=1024, description="password"
14
+ )
12
15
 
13
16
  class Key(BaseModel):
14
17
  type: BaseEnums.KeyType = Field(..., description="Key's type")
15
- value: str = Field(..., description="Key's value")
18
+ value: str = Field(..., description="Key's value")
@@ -7,12 +7,17 @@ from maleo_foundation.models.schemas.general import BaseGeneralSchemas
7
7
  from maleo_foundation.types import BaseTypes
8
8
  from maleo_foundation.extended_types import ExtendedTypes
9
9
 
10
+
10
11
  class BaseParameterSchemas:
11
12
  class IdentifierType(BaseModel):
12
- identifier: BaseEnums.IdentifierType = Field(..., description="Data's identifier type")
13
+ identifier: BaseEnums.IdentifierType = Field(
14
+ ..., description="Data's identifier type"
15
+ )
13
16
 
14
17
  class IdentifierValue(BaseModel):
15
- value: BaseTypes.IdentifierValue = Field(..., description="Data's identifier value")
18
+ value: BaseTypes.IdentifierValue = Field(
19
+ ..., description="Data's identifier value"
20
+ )
16
21
 
17
22
  class OptionalListOfIds(BaseModel):
18
23
  ids: BaseTypes.OptionalListOfIntegers = Field(None, description="Specific Ids")
@@ -21,42 +26,62 @@ class BaseParameterSchemas:
21
26
  uuids: BaseTypes.OptionalListOfUUIDs = Field(None, description="Specific Uuids")
22
27
 
23
28
  class Filters(BaseModel):
24
- filters: BaseTypes.ListOfStrings = Field([], description="Filters for date range, e.g. 'created_at|from::<ISO_DATETIME>|to::<ISO_DATETIME>'.")
29
+ filters: BaseTypes.ListOfStrings = Field(
30
+ [],
31
+ description="Filters for date range, e.g. 'created_at|from::<ISO_DATETIME>|to::<ISO_DATETIME>'.",
32
+ )
25
33
 
26
34
  @field_validator("filters")
27
35
  @classmethod
28
36
  def validate_date_filters(cls, values):
29
37
  if isinstance(values, list):
30
38
  decoded_values = [urllib.parse.unquote(value) for value in values]
31
- #* Replace space followed by 2 digits, colon, 2 digits with + and those digits
39
+ # * Replace space followed by 2 digits, colon, 2 digits with + and those digits
32
40
  fixed_values = []
33
41
  for value in decoded_values:
34
- #* Look for the pattern: space followed by 2 digits, colon, 2 digits
35
- 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)
42
+ # * Look for the pattern: space followed by 2 digits, colon, 2 digits
43
+ fixed_value = re.sub(
44
+ r"(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+) (\d{2}:\d{2})",
45
+ r"\1+\2",
46
+ value,
47
+ )
36
48
  fixed_values.append(fixed_value)
37
- final_values = [value for value in fixed_values if DATE_FILTER_PATTERN.match(value)]
49
+ final_values = [
50
+ value for value in fixed_values if DATE_FILTER_PATTERN.match(value)
51
+ ]
38
52
  return final_values
39
53
 
40
54
  class DateFilters(BaseModel):
41
- date_filters: ExtendedTypes.ListOfDateFilters = Field([], description="Date filters to be applied")
55
+ date_filters: ExtendedTypes.ListOfDateFilters = Field(
56
+ [], description="Date filters to be applied"
57
+ )
42
58
 
43
59
  class OptionalListOfStatuses(BaseModel):
44
- statuses: BaseTypes.OptionalListOfStatuses = Field(None, description="Data's status")
60
+ statuses: BaseTypes.OptionalListOfStatuses = Field(
61
+ None, description="Data's status"
62
+ )
45
63
 
46
64
  class OptionalListOfCodes(BaseModel):
47
- codes: BaseTypes.OptionalListOfStrings = Field(None, description="Specific Codes")
65
+ codes: BaseTypes.OptionalListOfStrings = Field(
66
+ None, description="Specific Codes"
67
+ )
48
68
 
49
69
  class OptionalListOfKeys(BaseModel):
50
70
  keys: BaseTypes.OptionalListOfStrings = Field(None, description="Specific Keys")
51
71
 
52
72
  class OptionalListOfNames(BaseModel):
53
- names: BaseTypes.OptionalListOfStrings = Field(None, description="Specific Names")
73
+ names: BaseTypes.OptionalListOfStrings = Field(
74
+ None, description="Specific Names"
75
+ )
54
76
 
55
77
  class Search(BaseModel):
56
78
  search: BaseTypes.OptionalString = Field(None, description="Search string.")
57
79
 
58
80
  class Sorts(BaseModel):
59
- sorts: BaseTypes.ListOfStrings = Field(["id.asc"], description="Sorting columns in 'column_name.asc' or 'column_name.desc' format.")
81
+ sorts: BaseTypes.ListOfStrings = Field(
82
+ ["id.asc"],
83
+ description="Sorting columns in 'column_name.asc' or 'column_name.desc' format.",
84
+ )
60
85
 
61
86
  @field_validator("sorts")
62
87
  @classmethod
@@ -64,10 +89,15 @@ class BaseParameterSchemas:
64
89
  return [value for value in values if SORT_COLUMN_PATTERN.match(value)]
65
90
 
66
91
  class SortColumns(BaseModel):
67
- sort_columns: ExtendedTypes.ListOfSortColumns = Field([BaseGeneralSchemas.SortColumn(name="id", order=BaseEnums.SortOrder.ASC)], description="List of columns to be sorted")
92
+ sort_columns: ExtendedTypes.ListOfSortColumns = Field(
93
+ [BaseGeneralSchemas.SortColumn(name="id", order=BaseEnums.SortOrder.ASC)],
94
+ description="List of columns to be sorted",
95
+ )
68
96
 
69
97
  class Expand(BaseModel):
70
- expand: BaseTypes.OptionalListOfStrings = Field(None, description="Expanded field(s)")
98
+ expand: BaseTypes.OptionalListOfStrings = Field(
99
+ None, description="Expanded field(s)"
100
+ )
71
101
 
72
102
  class Data(BaseModel):
73
- data: BaseTypes.StringToAnyDict = Field(..., description="Data")
103
+ data: BaseTypes.StringToAnyDict = Field(..., description="Data")
@@ -3,15 +3,22 @@ from typing import Dict, Optional, Union, Any
3
3
  from maleo_foundation.models.schemas.general import BaseGeneralSchemas
4
4
  from maleo_foundation.types import BaseTypes
5
5
 
6
+
6
7
  class FieldExpansionMetadata(BaseModel):
7
8
  success: bool = Field(..., description="Field expansion's success status")
8
9
  code: BaseTypes.OptionalString = Field(None, description="Optional result code")
9
10
  message: BaseTypes.OptionalString = Field(None, description="Optional message")
10
- description: BaseTypes.OptionalString = Field(None, description="Optional description")
11
+ description: BaseTypes.OptionalString = Field(
12
+ None, description="Optional description"
13
+ )
11
14
  other: BaseTypes.OptionalAny = Field(None, description="Optional other information")
12
15
 
16
+
13
17
  class ResultMetadata(BaseModel):
14
- field_expansion: Optional[Union[str, Dict[str, FieldExpansionMetadata]]] = Field(None, description="Field expansion metadata")
18
+ field_expansion: Optional[Union[str, Dict[str, FieldExpansionMetadata]]] = Field(
19
+ None, description="Field expansion metadata"
20
+ )
21
+
15
22
 
16
23
  class BaseResultSchemas:
17
24
  class ExtendedPagination(BaseGeneralSchemas.SimplePagination):
@@ -19,32 +26,38 @@ class BaseResultSchemas:
19
26
  total_data: int = Field(..., description="Total data count")
20
27
  total_pages: int = Field(..., description="Total pages count")
21
28
 
22
- #* ----- ----- ----- Base ----- ----- ----- *#
29
+ # * ----- ----- ----- Base ----- ----- ----- *#
23
30
  class Base(BaseModel):
24
31
  success: bool = Field(..., description="Success status")
25
32
  code: BaseTypes.OptionalString = Field(None, description="Optional result code")
26
33
  message: BaseTypes.OptionalString = Field(None, description="Optional message")
27
- description: BaseTypes.OptionalString = Field(None, description="Optional description")
34
+ description: BaseTypes.OptionalString = Field(
35
+ None, description="Optional description"
36
+ )
28
37
  data: Any = Field(..., description="Data")
29
- metadata: Optional[ResultMetadata] = Field(None, description="Optional metadata")
30
- other: BaseTypes.OptionalAny = Field(None, description="Optional other information")
38
+ metadata: Optional[ResultMetadata] = Field(
39
+ None, description="Optional metadata"
40
+ )
41
+ other: BaseTypes.OptionalAny = Field(
42
+ None, description="Optional other information"
43
+ )
31
44
 
32
- #* ----- ----- ----- Intermediary ----- ----- ----- *#
45
+ # * ----- ----- ----- Intermediary ----- ----- ----- *#
33
46
  class Fail(Base):
34
- code: str = "MAL-FAI-001"
35
- message: str = "Fail result"
36
- description: str = "Operation failed."
37
- success: BaseTypes.LiteralFalse = Field(False, description="Success status")
47
+ success: BaseTypes.LiteralFalse = Field(False, description="Success status") # type: ignore
48
+ code: str = "MAL-FAI-001" # type: ignore
49
+ message: str = "Fail result" # type: ignore
50
+ description: str = "Operation failed." # type: ignore
38
51
  data: None = Field(None, description="No data")
39
52
 
40
53
  class Success(Base):
41
- success: BaseTypes.LiteralTrue = Field(True, description="Success status")
42
- code: str = "MAL-SCS-001"
43
- message: str = "Success result"
44
- description: str = "Operation succeeded."
54
+ success: BaseTypes.LiteralTrue = Field(True, description="Success status") # type: ignore
55
+ code: str = "MAL-SCS-001" # type: ignore
56
+ message: str = "Success result" # type: ignore
57
+ description: str = "Operation succeeded." # type: ignore
45
58
  data: Any = Field(..., description="Data")
46
59
 
47
- #* ----- ----- ----- Derived ----- ----- ----- *#
60
+ # * ----- ----- ----- Derived ----- ----- ----- *#
48
61
  class NotFound(Fail):
49
62
  code: str = "MAL-NTF-001"
50
63
  message: str = "Resource not found"
@@ -70,13 +83,15 @@ class BaseResultSchemas:
70
83
  data: BaseTypes.ListOfAny = Field(..., description="Unpaginated multiple data")
71
84
 
72
85
  class PaginatedMultipleData(
73
- UnpaginatedMultipleData,
74
- BaseGeneralSchemas.SimplePagination
86
+ UnpaginatedMultipleData, BaseGeneralSchemas.SimplePagination
75
87
  ):
76
88
  code: str = "MAL-MTD-002"
77
89
  message: str = "Multiple paginated data found"
78
90
  description: str = "Requested paginated data found in database."
79
91
  total_data: int = Field(..., ge=0, description="Total data count")
80
- pagination: "BaseResultSchemas.ExtendedPagination" = Field(..., description="Pagination metadata")
92
+ pagination: "BaseResultSchemas.ExtendedPagination" = Field(
93
+ ..., description="Pagination metadata"
94
+ )
95
+
81
96
 
82
- BaseResultSchemas.PaginatedMultipleData.model_rebuild()
97
+ BaseResultSchemas.PaginatedMultipleData.model_rebuild()
@@ -1,12 +1,15 @@
1
1
  from pydantic import BaseModel, Field
2
2
  from maleo_foundation.types import BaseTypes
3
3
 
4
+
4
5
  class MaleoFoundationSignatureSchemas:
5
6
  class Key(BaseModel):
6
7
  key: str = Field(..., description="Key")
7
8
 
8
9
  class Password(BaseModel):
9
- password: BaseTypes.OptionalString = Field(None, min_length=32, max_length=1024, description="password")
10
+ password: BaseTypes.OptionalString = Field(
11
+ None, min_length=32, max_length=1024, description="password"
12
+ )
10
13
 
11
14
  class Message(BaseModel):
12
15
  message: str = Field(..., description="Message")
@@ -15,4 +18,4 @@ class MaleoFoundationSignatureSchemas:
15
18
  signature: str = Field(..., description="Signature")
16
19
 
17
20
  class IsValid(BaseModel):
18
- is_valid: bool = Field(..., description="Is valid signature")
21
+ is_valid: bool = Field(..., description="Is valid signature")
@@ -2,15 +2,18 @@ from __future__ import annotations
2
2
  from pydantic import BaseModel, Field
3
3
  from maleo_foundation.types import BaseTypes
4
4
 
5
+
5
6
  class MaleoFoundationTokenSchemas:
6
7
  class Key(BaseModel):
7
8
  key: str = Field(..., description="Key")
8
9
 
9
10
  class Password(BaseModel):
10
- password: BaseTypes.OptionalString = Field(None, min_length=32, max_length=1024, description="password")
11
+ password: BaseTypes.OptionalString = Field(
12
+ None, min_length=32, max_length=1024, description="password"
13
+ )
11
14
 
12
15
  class Token(BaseModel):
13
16
  token: str = Field(..., description="Token")
14
17
 
15
18
  class ExpIn(BaseModel):
16
- exp_in: int = Field(15, ge=1, description="Expires in (integer, minutes)")
19
+ exp_in: int = Field(15, ge=1, description="Expires in (integer, minutes)")