maleo-foundation 0.1.39__py3-none-any.whl → 0.1.41__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.
@@ -15,13 +15,14 @@ from maleo_foundation.managers.client.google.secret import GoogleSecretManager
15
15
  from maleo_foundation.managers.client.google.storage import GoogleCloudStorage
16
16
  from maleo_foundation.managers.client.maleo import MaleoClientManager
17
17
  from maleo_foundation.managers.db import DatabaseManager
18
- from maleo_foundation.managers.middleware import MiddlewareConfigurations, MiddlewareLoggers, MiddlewareManager
18
+ from maleo_foundation.managers.middleware import MiddlewareConfigurations, BaseMiddlewareConfigurations, CORSMiddlewareConfigurations, GeneralMiddlewareConfigurations, MiddlewareLoggers, MiddlewareManager
19
19
  from maleo_foundation.middlewares.base import RequestProcessor
20
20
  from maleo_foundation.services.token import BaseTokenService
21
21
  from maleo_foundation.types import BaseTypes
22
22
  from maleo_foundation.utils.exceptions import BaseExceptions
23
23
  from maleo_foundation.utils.loaders.json import JSONLoader
24
24
  from maleo_foundation.utils.loaders.key import KeyLoader
25
+ from maleo_foundation.utils.loaders.yaml import YAMLLoader
25
26
  from maleo_foundation.utils.logging import GoogleCloudLogging, ServiceLogger, MiddlewareLogger
26
27
 
27
28
  class LogConfig(BaseModel):
@@ -33,12 +34,13 @@ class LogConfig(BaseModel):
33
34
 
34
35
  class Settings(BaseSettings):
35
36
  ENVIRONMENT:BaseEnums.EnvironmentType = Field(..., description="Environment")
36
- GOOGLE_CREDENTIALS_PATH:str = Field("/creds/maleo-google-service-account.json", description="Internal credential's file path")
37
- INTERNAL_CREDENTIALS_PATH:str = Field("/creds/maleo-internal-service-account.json", description="Internal credential's file path")
38
- PRIVATE_KEY_PATH:str = Field("/keys/maleo-private-key.pem", description="Maleo's private key path")
39
- PUBLIC_KEY_PATH:str = Field("/keys/maleo-public-key.pem", description="Maleo's public key path")
37
+ GOOGLE_CREDENTIALS_PATH:str = Field("credentials/maleo-google-service-account.json", description="Internal credential's file path")
38
+ INTERNAL_CREDENTIALS_PATH:str = Field("credentials/maleo-internal-service-account.json", description="Internal credential's file path")
39
+ PRIVATE_KEY_PATH:str = Field("keys/maleo-private-key.pem", description="Maleo's private key path")
40
+ PUBLIC_KEY_PATH:str = Field("keys/maleo-public-key.pem", description="Maleo's public key path")
40
41
  KEY_PASSWORD:str = Field(..., description="Maleo key's password")
41
- CONFIGURATIONS_PATH:str = Field(..., description="Service's configuration file path")
42
+ STATIC_CONFIGURATIONS_PATH:str = Field("configs/static.yaml", description="Maleo's static configurations path")
43
+ RUNTIME_CONFIGURATIONS_PATH:str = Field("configs/runtime.yaml", description="Service's runtime configurations path")
42
44
  DB_PASSWORD:str = Field(..., description="Database's password")
43
45
 
44
46
  class Keys(BaseModel):
@@ -72,6 +74,12 @@ class Credentials(BaseModel):
72
74
  class Config:
73
75
  arbitrary_types_allowed=True
74
76
 
77
+ class MiddlewareRuntimeConfigurations(BaseModel):
78
+ base:BaseMiddlewareConfigurations = Field(..., description="Base middleware's configurations")
79
+
80
+ class Config:
81
+ arbitrary_types_allowed=True
82
+
75
83
  class ServiceConfigurations(BaseModel):
76
84
  key:str = Field(..., description="Service's key")
77
85
  name:str = Field(..., description="Service's name")
@@ -80,7 +88,6 @@ class ServiceConfigurations(BaseModel):
80
88
 
81
89
  class DatabaseConfigurations(BaseModel):
82
90
  username:str = Field("postgres", description="Database user's username")
83
- password_env:str = Field("DB_PASSWORD", description="Database user's password .env")
84
91
  password:str = Field(..., description="Database user's password")
85
92
  host:str = Field(..., description="Database's host")
86
93
  port:int = Field(5432, description="Database's port")
@@ -89,12 +96,9 @@ class DatabaseConfigurations(BaseModel):
89
96
  @model_validator(mode='before')
90
97
  @classmethod
91
98
  def populate_password(cls, values:Dict):
92
- env_name = values.get("password_env")
93
- if not env_name:
94
- raise ValueError("password_env is required to fetch password from environment.")
95
- env_value = os.getenv(env_name)
99
+ env_value = os.getenv("DB_PASSWORD")
96
100
  if env_value is None:
97
- raise ValueError(f"'{env_name}' must be set.")
101
+ raise ValueError("'DB_PASSWORD' environmet variable must be set.")
98
102
  values["password"] = env_value
99
103
  return values
100
104
 
@@ -102,6 +106,21 @@ class DatabaseConfigurations(BaseModel):
102
106
  def url(self) -> str:
103
107
  return f"postgresql://{self.username}:{self.password}@{self.host}:{self.port}/{self.database}"
104
108
 
109
+ class RuntimeConfigurations(BaseModel):
110
+ service:ServiceConfigurations = Field(..., description="Service's configurations")
111
+ middleware:MiddlewareRuntimeConfigurations = Field(..., description="Middleware's runtime configurations")
112
+ database:DatabaseConfigurations = Field(..., description="Database's configurations")
113
+
114
+ class Config:
115
+ arbitrary_types_allowed=True
116
+
117
+ class MiddlewareStaticConfigurations(BaseModel):
118
+ general:GeneralMiddlewareConfigurations = Field(..., description="Middleware's general configurations")
119
+ cors:CORSMiddlewareConfigurations = Field(..., description="CORS middleware's configurations")
120
+
121
+ class Config:
122
+ arbitrary_types_allowed=True
123
+
105
124
  class GoogleCloudStorageConfigurations(BaseModel):
106
125
  bucket_name:str = Field(..., description="Bucket's name")
107
126
 
@@ -137,11 +156,18 @@ class ClientConfigurations(BaseModel):
137
156
  class Config:
138
157
  arbitrary_types_allowed=True
139
158
 
159
+ class StaticConfigurations(BaseModel):
160
+ middleware:MiddlewareStaticConfigurations = Field(..., description="Middleware's static configurations")
161
+ client:ClientConfigurations = Field(..., description="Client's configurations")
162
+
163
+ class Config:
164
+ arbitrary_types_allowed=True
165
+
140
166
  class Configurations(BaseModel):
141
167
  service:ServiceConfigurations = Field(..., description="Service's configurations")
142
168
  middleware:MiddlewareConfigurations = Field(..., description="Middleware's configurations")
143
169
  database:DatabaseConfigurations = Field(..., description="Database's configurations")
144
- client:ClientConfigurations = Field(..., description="Service's configurations")
170
+ client:ClientConfigurations = Field(..., description="Client's configurations")
145
171
 
146
172
  class Config:
147
173
  arbitrary_types_allowed=True
@@ -269,8 +295,11 @@ class ServiceManager:
269
295
  return self._settings
270
296
 
271
297
  def _load_configs(self) -> None:
272
- data = JSONLoader.load(self._settings.CONFIGURATIONS_PATH)
273
- self._configs = Configurations.model_validate(data)
298
+ static_configurations = YAMLLoader.load(self._settings.STATIC_CONFIGURATIONS_PATH)
299
+ self._static_configs = StaticConfigurations.model_validate(static_configurations)
300
+ runtime_configurations = YAMLLoader.load(self._settings.RUNTIME_CONFIGURATIONS_PATH)
301
+ self._runtime_configs = RuntimeConfigurations.model_validate(runtime_configurations)
302
+ self._configs = Configurations.model_validate(self._static_configs.model_dump() | self._runtime_configs)
274
303
 
275
304
  @property
276
305
  def configs(self) -> Configurations:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.1.39
3
+ Version: 0.1.41
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -13,6 +13,7 @@ Requires-Dist: cachetools>=5.5.2
13
13
  Requires-Dist: certifi>=2025.1.31
14
14
  Requires-Dist: cffi>=1.17.1
15
15
  Requires-Dist: charset-normalizer>=3.4.1
16
+ Requires-Dist: click>=8.1.8
16
17
  Requires-Dist: cryptography>=44.0.2
17
18
  Requires-Dist: Deprecated>=1.2.18
18
19
  Requires-Dist: docutils>=0.21.2
@@ -55,10 +56,13 @@ Requires-Dist: pyasn1>=0.6.1
55
56
  Requires-Dist: pyasn1_modules>=0.4.2
56
57
  Requires-Dist: pycparser>=2.22
57
58
  Requires-Dist: pydantic>=2.11.3
59
+ Requires-Dist: pydantic-settings>=2.9.1
58
60
  Requires-Dist: pydantic_core>=2.33.1
59
61
  Requires-Dist: Pygments>=2.19.1
60
62
  Requires-Dist: PyJWT>=2.10.1
61
63
  Requires-Dist: pyproject_hooks>=1.2.0
64
+ Requires-Dist: python-dotenv>=1.1.0
65
+ Requires-Dist: PyYAML>=6.0.2
62
66
  Requires-Dist: readme_renderer>=44.0
63
67
  Requires-Dist: requests>=2.32.3
64
68
  Requires-Dist: requests-toolbelt>=1.0.0
@@ -73,6 +77,7 @@ Requires-Dist: twine>=6.1.0
73
77
  Requires-Dist: typing-inspection>=0.4.0
74
78
  Requires-Dist: typing_extensions>=4.13.2
75
79
  Requires-Dist: urllib3>=2.4.0
80
+ Requires-Dist: uvicorn>=0.34.2
76
81
  Requires-Dist: wrapt>=1.17.2
77
82
  Requires-Dist: zipp>=3.21.0
78
83
 
@@ -13,7 +13,7 @@ maleo_foundation/expanded_types/token.py,sha256=4fRTJw6W5MYq71NksNrWNi7qYHQ4_lQw
13
13
  maleo_foundation/managers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  maleo_foundation/managers/db.py,sha256=ZN0b43OgqQtk2WHKMJQ0E2TeaSEyVJ0-l4FEkrSG0Qo,4645
15
15
  maleo_foundation/managers/middleware.py,sha256=7CDXPMb28AR7J72TWOeKFxOlMypKezEtO9mr53a88B0,4032
16
- maleo_foundation/managers/service.py,sha256=XTbsV11JEGqfiHJwra5MSJ1l7rqP3IUTvMtLwnJZ5yM,21005
16
+ maleo_foundation/managers/service.py,sha256=sjYtF9hq00IwSE2FQiWJFKZ-e-vuCSEfe4zeE6swEQg,22629
17
17
  maleo_foundation/managers/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  maleo_foundation/managers/client/base.py,sha256=lYREmEoTLShlPPXOKKiAopjefJ8nIWHCi7IvWkXXKeY,1465
19
19
  maleo_foundation/managers/client/maleo.py,sha256=NibYGdiN3EXUw5nx-tL48QAZym14GcA4BDZihGJNQ-g,4254
@@ -66,7 +66,7 @@ maleo_foundation/utils/loaders/__init__.py,sha256=Dnuv7BWyglSddnbsFb96s-b3KaW7UK
66
66
  maleo_foundation/utils/loaders/json.py,sha256=NsXLq3VZSgzmEf99tV1VtrmiudWdQ8Pzh_hI4Rm0cM8,397
67
67
  maleo_foundation/utils/loaders/key.py,sha256=GZ4h1ONfp6Xx8-E8AWoGP4ajAZrwPhZRtidjn_u82Qg,2562
68
68
  maleo_foundation/utils/loaders/yaml.py,sha256=jr8v3BlgmRCMTzdNgKhIYt1tnubaJXcDSSGkKVR8pbw,362
69
- maleo_foundation-0.1.39.dist-info/METADATA,sha256=DDXV3R3FbXZHl3RgmRVm380Xf4CFog-qdb8Kddf9ndM,3190
70
- maleo_foundation-0.1.39.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
71
- maleo_foundation-0.1.39.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
72
- maleo_foundation-0.1.39.dist-info/RECORD,,
69
+ maleo_foundation-0.1.41.dist-info/METADATA,sha256=MTlHe5GTh13IsZigYvJa1qjqqBnaX2cw6-4_4nz_2CI,3354
70
+ maleo_foundation-0.1.41.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
71
+ maleo_foundation-0.1.41.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
72
+ maleo_foundation-0.1.41.dist-info/RECORD,,