maleo-foundation 0.2.98__tar.gz → 0.2.99__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 (134) hide show
  1. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/PKG-INFO +1 -1
  2. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/middlewares/base.py +11 -11
  3. maleo_foundation-0.2.99/maleo_foundation/models/transfers/general/pubsub.py +37 -0
  4. maleo_foundation-0.2.99/maleo_foundation/models/transfers/general/request.py +70 -0
  5. maleo_foundation-0.2.99/maleo_foundation/utils/dependencies/context.py +9 -0
  6. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/utils/extractor.py +3 -3
  7. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation.egg-info/PKG-INFO +1 -1
  8. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation.egg-info/SOURCES.txt +2 -0
  9. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/pyproject.toml +1 -1
  10. maleo_foundation-0.2.98/maleo_foundation/utils/dependencies/context.py +0 -9
  11. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/README.md +0 -0
  12. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/__init__.py +0 -0
  13. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/authentication.py +0 -0
  14. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/authorization.py +0 -0
  15. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/client/__init__.py +0 -0
  16. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/client/manager.py +0 -0
  17. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/client/services/__init__.py +0 -0
  18. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/client/services/encryption/__init__.py +0 -0
  19. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/client/services/encryption/aes.py +0 -0
  20. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/client/services/encryption/rsa.py +0 -0
  21. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/client/services/hash/__init__.py +0 -0
  22. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/client/services/hash/bcrypt.py +0 -0
  23. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/client/services/hash/hmac.py +0 -0
  24. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/client/services/hash/sha256.py +0 -0
  25. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/client/services/key.py +0 -0
  26. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/client/services/signature.py +0 -0
  27. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/client/services/token.py +0 -0
  28. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/constants.py +0 -0
  29. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/enums.py +0 -0
  30. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/expanded_types/__init__.py +0 -0
  31. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/expanded_types/client.py +0 -0
  32. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/expanded_types/encryption/__init__.py +0 -0
  33. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/expanded_types/encryption/aes.py +0 -0
  34. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/expanded_types/encryption/rsa.py +0 -0
  35. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/expanded_types/general.py +0 -0
  36. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/expanded_types/hash.py +0 -0
  37. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/expanded_types/key.py +0 -0
  38. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/expanded_types/repository.py +0 -0
  39. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/expanded_types/service.py +0 -0
  40. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/expanded_types/signature.py +0 -0
  41. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/expanded_types/token.py +0 -0
  42. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/extended_types.py +0 -0
  43. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/managers/__init__.py +0 -0
  44. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/managers/cache/__init__.py +0 -0
  45. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/managers/cache/base.py +0 -0
  46. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/managers/cache/redis.py +0 -0
  47. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/managers/client/__init__.py +0 -0
  48. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/managers/client/base.py +0 -0
  49. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/managers/client/google/__init__.py +0 -0
  50. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/managers/client/google/base.py +0 -0
  51. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/managers/client/google/parameter.py +0 -0
  52. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/managers/client/google/secret.py +0 -0
  53. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/managers/client/google/storage.py +0 -0
  54. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/managers/client/maleo.py +0 -0
  55. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/managers/db.py +0 -0
  56. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/managers/middleware.py +0 -0
  57. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/managers/service.py +0 -0
  58. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/middlewares/authentication.py +0 -0
  59. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/middlewares/cors.py +0 -0
  60. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/__init__.py +0 -0
  61. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/responses.py +0 -0
  62. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/schemas/__init__.py +0 -0
  63. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/schemas/encryption.py +0 -0
  64. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/schemas/general.py +0 -0
  65. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/schemas/hash.py +0 -0
  66. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/schemas/key.py +0 -0
  67. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/schemas/parameter.py +0 -0
  68. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/schemas/result.py +0 -0
  69. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/schemas/signature.py +0 -0
  70. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/schemas/token.py +0 -0
  71. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/table.py +0 -0
  72. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/__init__.py +0 -0
  73. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/general/__init__.py +0 -0
  74. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/general/key.py +0 -0
  75. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/general/signature.py +0 -0
  76. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/general/token.py +0 -0
  77. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/parameters/__init__.py +0 -0
  78. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/parameters/client.py +0 -0
  79. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/parameters/encryption/__init__.py +0 -0
  80. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/parameters/encryption/aes.py +0 -0
  81. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/parameters/encryption/rsa.py +0 -0
  82. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/parameters/general.py +0 -0
  83. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/parameters/hash/__init__.py +0 -0
  84. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/parameters/hash/bcrypt.py +0 -0
  85. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/parameters/hash/hmac.py +0 -0
  86. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/parameters/hash/sha256.py +0 -0
  87. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/parameters/key.py +0 -0
  88. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/parameters/service.py +0 -0
  89. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/parameters/signature.py +0 -0
  90. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/parameters/token.py +0 -0
  91. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/results/__init__.py +0 -0
  92. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/results/client/__init__.py +0 -0
  93. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/results/client/controllers/__init__.py +0 -0
  94. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/results/client/controllers/http.py +0 -0
  95. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/results/client/service.py +0 -0
  96. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/results/encryption/__init__.py +0 -0
  97. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/results/encryption/aes.py +0 -0
  98. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/results/encryption/rsa.py +0 -0
  99. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/results/hash.py +0 -0
  100. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/results/key.py +0 -0
  101. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/results/service/__init__.py +0 -0
  102. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/results/service/controllers/__init__.py +0 -0
  103. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/results/service/controllers/rest.py +0 -0
  104. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/results/service/general.py +0 -0
  105. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/results/service/repository.py +0 -0
  106. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/results/signature.py +0 -0
  107. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/models/transfers/results/token.py +0 -0
  108. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/rest_controller_result.py +0 -0
  109. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/types.py +0 -0
  110. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/utils/__init__.py +0 -0
  111. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/utils/cleaner.py +0 -0
  112. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/utils/client.py +0 -0
  113. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/utils/controller.py +0 -0
  114. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/utils/dependencies/__init__.py +0 -0
  115. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/utils/dependencies/auth.py +0 -0
  116. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/utils/exceptions.py +0 -0
  117. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/utils/formatter/__init__.py +0 -0
  118. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/utils/formatter/case.py +0 -0
  119. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/utils/loaders/__init__.py +0 -0
  120. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/utils/loaders/credential/__init__.py +0 -0
  121. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/utils/loaders/credential/google.py +0 -0
  122. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/utils/loaders/json.py +0 -0
  123. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/utils/loaders/key/__init__.py +0 -0
  124. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/utils/loaders/key/rsa.py +0 -0
  125. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/utils/loaders/yaml.py +0 -0
  126. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/utils/logging.py +0 -0
  127. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/utils/merger.py +0 -0
  128. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/utils/query.py +0 -0
  129. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/utils/repository.py +0 -0
  130. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation/utils/searcher.py +0 -0
  131. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation.egg-info/dependency_links.txt +0 -0
  132. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation.egg-info/requires.txt +0 -0
  133. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/maleo_foundation.egg-info/top_level.txt +0 -0
  134. {maleo_foundation-0.2.98 → maleo_foundation-0.2.99}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.2.98
3
+ Version: 0.2.99
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -18,7 +18,7 @@ from maleo_foundation.models.responses import BaseResponses
18
18
  from maleo_foundation.models.transfers.general.token import MaleoFoundationTokenGeneralTransfers
19
19
  from maleo_foundation.models.transfers.parameters.token import MaleoFoundationTokenParametersTransfers
20
20
  from maleo_foundation.models.transfers.parameters.signature import MaleoFoundationSignatureParametersTransfers
21
- from maleo_foundation.models.transfers.general import RequestContextTransfers
21
+ from maleo_foundation.models.transfers.general.request import RequestContext
22
22
  from maleo_foundation.utils.extractor import extract_request_context
23
23
  from maleo_foundation.utils.logging import MiddlewareLogger
24
24
 
@@ -46,7 +46,7 @@ class RateLimiter:
46
46
 
47
47
  def is_rate_limited(
48
48
  self,
49
- request_context: RequestContextTransfers
49
+ request_context: RequestContext
50
50
  ) -> bool:
51
51
  """Check if client IP is rate limited and record the request."""
52
52
  with self._lock:
@@ -117,7 +117,7 @@ class ResponseBuilder:
117
117
  self,
118
118
  authentication: Authentication,
119
119
  response: Response,
120
- request_context: RequestContextTransfers,
120
+ request_context: RequestContext,
121
121
  responded_at: datetime,
122
122
  process_time: float
123
123
  ) -> Response:
@@ -139,7 +139,7 @@ class ResponseBuilder:
139
139
  def _add_signature_header(
140
140
  self,
141
141
  response: Response,
142
- request_context: RequestContextTransfers,
142
+ request_context: RequestContext,
143
143
  responded_at: datetime,
144
144
  process_time: float
145
145
  ) -> None:
@@ -161,7 +161,7 @@ class ResponseBuilder:
161
161
 
162
162
  def _add_new_authorization_header(
163
163
  self,
164
- request_context:RequestContextTransfers,
164
+ request_context:RequestContext,
165
165
  authentication:Authentication,
166
166
  response:Response
167
167
  ) -> None:
@@ -185,7 +185,7 @@ class ResponseBuilder:
185
185
 
186
186
  def _should_regenerate_auth(
187
187
  self,
188
- request_context: RequestContextTransfers,
188
+ request_context: RequestContext,
189
189
  authentication: Authentication,
190
190
  response: Response
191
191
  ) -> bool:
@@ -207,7 +207,7 @@ class RequestLogger:
207
207
  self,
208
208
  authentication: Authentication,
209
209
  response: Response,
210
- request_context: RequestContextTransfers,
210
+ request_context: RequestContext,
211
211
  log_level: str = "info"
212
212
  ) -> None:
213
213
  """Log request and response details."""
@@ -225,7 +225,7 @@ class RequestLogger:
225
225
  self,
226
226
  authentication: Authentication,
227
227
  error: Exception,
228
- request_context: RequestContextTransfers
228
+ request_context: RequestContext
229
229
  ) -> None:
230
230
  """Log exception details."""
231
231
  authentication_info = self._get_authentication_info(authentication)
@@ -338,7 +338,7 @@ class BaseMiddleware(BaseHTTPMiddleware):
338
338
  def _create_rate_limit_response(
339
339
  self,
340
340
  authentication: Authentication,
341
- request_context: RequestContextTransfers,
341
+ request_context: RequestContext,
342
342
  start_time: float
343
343
  ) -> Response:
344
344
  """Create rate limit exceeded response."""
@@ -355,7 +355,7 @@ class BaseMiddleware(BaseHTTPMiddleware):
355
355
  self,
356
356
  authentication: Authentication,
357
357
  response: Response,
358
- request_context: RequestContextTransfers,
358
+ request_context: RequestContext,
359
359
  start_time: float,
360
360
  log_level: str = "info"
361
361
  ) -> Response:
@@ -379,7 +379,7 @@ class BaseMiddleware(BaseHTTPMiddleware):
379
379
  self,
380
380
  authentication: Authentication,
381
381
  error: Exception,
382
- request_context: RequestContextTransfers,
382
+ request_context: RequestContext,
383
383
  start_time: float
384
384
  ) -> Response:
385
385
  """Handle exceptions and create error response."""
@@ -0,0 +1,37 @@
1
+ from datetime import datetime, timezone
2
+ from uuid import UUID
3
+ from pydantic import BaseModel, Field, model_validator
4
+ from typing import Dict, Optional, Any
5
+ from .request import RequestContext
6
+ from .token import MaleoFoundationTokenGeneralTransfers
7
+ from maleo_foundation.types import BaseTypes
8
+
9
+ class DatabaseAccess(BaseModel):
10
+ accessed_at: datetime = Field(datetime.now(tz=timezone.utc), description="Accessed at timestamp")
11
+ request_id: UUID = Field(..., description="Request Id")
12
+ request_context: RequestContext = Field(..., description="Request context")
13
+ organization_id: BaseTypes.OptionalInteger = Field(None, ge=1, description="Organization Id")
14
+ user_id: int = Field(0, ge=0, description="User Id")
15
+ token_string: BaseTypes.OptionalString = Field(None, description="Token string")
16
+ token_payload: Optional[MaleoFoundationTokenGeneralTransfers.DecodePayload] = Field(None, description="Token payload")
17
+ service: str = Field(..., description="Service key")
18
+ table: str = Field(..., description="Table name")
19
+ data_id: int = Field(..., ge=1, description="Data Id")
20
+ data: BaseTypes.StringToAnyDict = Field(..., description="Data")
21
+
22
+ def to_google_pubsub_object(self) -> BaseTypes.StringToAnyDict:
23
+ result = {
24
+ "accessed_at": self.accessed_at.isoformat(),
25
+ "request_id": str(self.request_id),
26
+ "request_context": self.request_context.to_google_pubsub_object(),
27
+ "organization_id": None if self.organization_id is None else {"int": self.organization_id},
28
+ "user_id": self.user_id,
29
+ "token_string": None if self.token_string is None else {"string": self.token_string},
30
+ "token_payload": None if self.token_payload is None else self.token_payload.to_google_pubsub_object(),
31
+ "service": self.service,
32
+ "table": self.table,
33
+ "data_id": self.data_id,
34
+ "data": self.data
35
+ }
36
+
37
+ return result
@@ -0,0 +1,70 @@
1
+ from __future__ import annotations
2
+ from datetime import datetime, timezone
3
+ from pydantic import BaseModel, Field
4
+ from typing import Dict, Any
5
+ from uuid import UUID
6
+ from maleo_foundation.types import BaseTypes
7
+
8
+ class RequestContext(BaseModel):
9
+ request_id: UUID = Field(..., description="Unique identifier for tracing the request")
10
+ requested_at: datetime = Field(datetime.now(tz=timezone.utc), description="Request timestamp")
11
+ method: str = Field(..., description="Request's method")
12
+ url: str = Field(..., description="Request's URL")
13
+ path_params: Dict = Field(..., description="Request's path parameters")
14
+ query_params: Dict = Field(..., description="Request's query parameters")
15
+ ip_address: str = Field("unknown", description="Client's IP address")
16
+ is_internal: BaseTypes.OptionalBoolean = Field(None, description="True if IP is internal")
17
+ user_agent: BaseTypes.OptionalString = Field(None, description="User-Agent string")
18
+ ua_browser: BaseTypes.OptionalString = Field(None, description="Browser info from sec-ch-ua")
19
+ ua_mobile: BaseTypes.OptionalString = Field(None, description="Is mobile device?")
20
+ platform: BaseTypes.OptionalString = Field(None, description="Client platform or OS")
21
+ referer: BaseTypes.OptionalString = Field(None, description="Referrer URL")
22
+ origin: BaseTypes.OptionalString = Field(None, description="Origin of the request")
23
+ host: BaseTypes.OptionalString = Field(None, description="Host header from request")
24
+ forwarded_proto: BaseTypes.OptionalString = Field(None, description="Forwarded protocol (http/https)")
25
+ language: BaseTypes.OptionalString = Field(None, description="Accepted languages from client")
26
+
27
+ def to_google_pubsub_object(self) -> Dict[str, Any]:
28
+ result = {
29
+ "request_id": str(self.request_id),
30
+ "requested_at": self.requested_at.isoformat(),
31
+ "method": self.method,
32
+ "url": self.url,
33
+ "path_params": {"map": self.path_params},
34
+ "query_params": {"map": self.query_params},
35
+ "ip_address": self.ip_address,
36
+ "is_internal": None if self.is_internal is None else {"boolean": self.is_internal},
37
+ "user_agent": None if self.user_agent is None else {"string": self.user_agent},
38
+ "ua_browser": None if self.ua_browser is None else {"string": self.ua_browser},
39
+ "ua_mobile": None if self.ua_mobile is None else {"string": self.ua_mobile},
40
+ "platform": None if self.platform is None else {"string": self.platform},
41
+ "referer": None if self.referer is None else {"array": self.referer},
42
+ "origin": None if self.origin is None else {"array": self.origin},
43
+ "host": None if self.host is None else {"array": self.host},
44
+ "forwarded_proto": None if self.forwarded_proto is None else {"array": self.forwarded_proto},
45
+ "language": None if self.language is None else {"array": self.language}
46
+ }
47
+
48
+ return result
49
+
50
+ @classmethod
51
+ def from_google_pubsub_object(cls, obj:Dict[str, Any]):
52
+ return cls(
53
+ request_id = UUID(obj["request_id"]),
54
+ requested_at = datetime.fromisoformat(obj["requested_at"]),
55
+ method = obj["method"],
56
+ url = obj["url"],
57
+ path_params = obj["path_params"]["map"] or {},
58
+ query_params = obj["query_params"]["map"] or {},
59
+ ip_address = obj["ip_address"],
60
+ is_internal = None if obj["is_internal"] is None else bool(obj["is_internal"]["boolean"]),
61
+ user_agent = None if obj["user_agent"] is None else obj["user_agent"]["string"],
62
+ ua_browser = None if obj["ua_browser"] is None else obj["ua_browser"]["string"],
63
+ ua_mobile = None if obj["ua_mobile"] is None else obj["ua_mobile"]["string"],
64
+ platform = None if obj["platform"] is None else obj["platform"]["string"],
65
+ referer = None if obj["referer"] is None else obj["referer"]["string"],
66
+ origin = None if obj["origin"] is None else obj["origin"]["string"],
67
+ host = None if obj["host"] is None else obj["host"]["string"],
68
+ forwarded_proto = None if obj["forwarded_proto"] is None else obj["forwarded_proto"]["string"],
69
+ language = None if obj["language"] is None else obj["language"]["string"],
70
+ )
@@ -0,0 +1,9 @@
1
+ from fastapi.requests import Request
2
+ from maleo_foundation.models.transfers.general.request import RequestContext
3
+
4
+ class ContextDependencies:
5
+ @staticmethod
6
+ def get_request_context(
7
+ request: Request
8
+ ) -> RequestContext:
9
+ return request.state.request_context
@@ -2,7 +2,7 @@ from datetime import datetime, timezone
2
2
  from fastapi import Request
3
3
  from starlette.requests import HTTPConnection
4
4
  from uuid import uuid4
5
- from maleo_foundation.models.transfers.general import RequestContextTransfers
5
+ from maleo_foundation.models.transfers.general.request import RequestContext
6
6
 
7
7
  def extract_client_ip(conn: HTTPConnection) -> str:
8
8
  """Extract client IP with more robust handling of proxies"""
@@ -21,7 +21,7 @@ def extract_client_ip(conn: HTTPConnection) -> str:
21
21
  #* Fall back to direct client connection
22
22
  return conn.client.host if conn.client else "unknown"
23
23
 
24
- def extract_request_context(request: Request) -> RequestContextTransfers:
24
+ def extract_request_context(request: Request) -> RequestContext:
25
25
  headers = request.headers
26
26
 
27
27
  request_id = headers.get("x-request-id")
@@ -34,7 +34,7 @@ def extract_request_context(request: Request) -> RequestContextTransfers:
34
34
  if ua_browser:
35
35
  ua_browser = ua_browser.replace('"', "").split(",")[0].strip()
36
36
 
37
- return RequestContextTransfers(
37
+ return RequestContext(
38
38
  request_id=request_id,
39
39
  requested_at=datetime.now(tz=timezone.utc),
40
40
  method=request.method,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.2.98
3
+ Version: 0.2.99
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -71,6 +71,8 @@ maleo_foundation/models/schemas/token.py
71
71
  maleo_foundation/models/transfers/__init__.py
72
72
  maleo_foundation/models/transfers/general/__init__.py
73
73
  maleo_foundation/models/transfers/general/key.py
74
+ maleo_foundation/models/transfers/general/pubsub.py
75
+ maleo_foundation/models/transfers/general/request.py
74
76
  maleo_foundation/models/transfers/general/signature.py
75
77
  maleo_foundation/models/transfers/general/token.py
76
78
  maleo_foundation/models/transfers/parameters/__init__.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "maleo_foundation"
7
- version = "0.2.98"
7
+ version = "0.2.99"
8
8
  description = "Foundation package for Maleo"
9
9
  authors = [
10
10
  { name = "Agra Bima Yuda", email = "agra@nexmedis.com" }
@@ -1,9 +0,0 @@
1
- from fastapi.requests import Request
2
- from maleo_foundation.models.transfers.general import RequestContextTransfers
3
-
4
- class ContextDependencies:
5
- @staticmethod
6
- def get_request_context(
7
- request: Request
8
- ) -> RequestContextTransfers:
9
- return request.state.request_context