orionis 0.405.0__py3-none-any.whl → 0.407.0__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 (175) hide show
  1. orionis/console/base/command.py +57 -50
  2. orionis/console/base/contracts/command.py +68 -0
  3. orionis/console/dynamic/contracts/progress_bar.py +3 -3
  4. orionis/console/dynamic/progress_bar.py +8 -8
  5. orionis/console/output/console.py +8 -2
  6. orionis/console/output/contracts/console.py +1 -1
  7. orionis/container/container.py +2 -2
  8. orionis/container/context/scope.py +4 -1
  9. orionis/container/contracts/service_provider.py +2 -2
  10. orionis/container/entities/binding.py +31 -44
  11. orionis/container/enums/lifetimes.py +22 -1
  12. orionis/container/facades/facade.py +1 -2
  13. orionis/container/providers/service_provider.py +2 -2
  14. orionis/foundation/application.py +542 -248
  15. orionis/foundation/config/app/entities/app.py +107 -90
  16. orionis/foundation/config/auth/entities/auth.py +4 -33
  17. orionis/foundation/config/cache/entities/cache.py +18 -41
  18. orionis/foundation/config/cache/entities/file.py +8 -35
  19. orionis/foundation/config/cache/entities/stores.py +17 -38
  20. orionis/foundation/config/cors/entities/cors.py +41 -54
  21. orionis/foundation/config/database/entities/connections.py +40 -56
  22. orionis/foundation/config/database/entities/database.py +11 -38
  23. orionis/foundation/config/database/entities/mysql.py +48 -76
  24. orionis/foundation/config/database/entities/oracle.py +30 -57
  25. orionis/foundation/config/database/entities/pgsql.py +45 -61
  26. orionis/foundation/config/database/entities/sqlite.py +26 -53
  27. orionis/foundation/config/filesystems/entitites/aws.py +28 -49
  28. orionis/foundation/config/filesystems/entitites/disks.py +27 -47
  29. orionis/foundation/config/filesystems/entitites/filesystems.py +15 -37
  30. orionis/foundation/config/filesystems/entitites/local.py +9 -35
  31. orionis/foundation/config/filesystems/entitites/public.py +14 -41
  32. orionis/foundation/config/logging/entities/channels.py +56 -86
  33. orionis/foundation/config/logging/entities/chunked.py +9 -9
  34. orionis/foundation/config/logging/entities/daily.py +8 -8
  35. orionis/foundation/config/logging/entities/hourly.py +6 -6
  36. orionis/foundation/config/logging/entities/logging.py +12 -18
  37. orionis/foundation/config/logging/entities/monthly.py +7 -7
  38. orionis/foundation/config/logging/entities/stack.py +5 -5
  39. orionis/foundation/config/logging/entities/weekly.py +6 -6
  40. orionis/foundation/config/mail/entities/file.py +9 -36
  41. orionis/foundation/config/mail/entities/mail.py +22 -40
  42. orionis/foundation/config/mail/entities/mailers.py +29 -44
  43. orionis/foundation/config/mail/entities/smtp.py +47 -48
  44. orionis/foundation/config/queue/entities/brokers.py +19 -41
  45. orionis/foundation/config/queue/entities/database.py +24 -46
  46. orionis/foundation/config/queue/entities/queue.py +28 -40
  47. orionis/foundation/config/roots/paths.py +272 -468
  48. orionis/foundation/config/session/entities/session.py +23 -53
  49. orionis/foundation/config/startup.py +165 -135
  50. orionis/foundation/config/testing/entities/testing.py +137 -122
  51. orionis/foundation/config/testing/enums/__init__.py +6 -2
  52. orionis/foundation/config/testing/enums/drivers.py +16 -0
  53. orionis/foundation/config/testing/enums/verbosity.py +18 -0
  54. orionis/foundation/contracts/application.py +152 -362
  55. orionis/foundation/providers/console_provider.py +24 -2
  56. orionis/foundation/providers/dumper_provider.py +24 -2
  57. orionis/foundation/providers/logger_provider.py +24 -2
  58. orionis/foundation/providers/path_resolver_provider.py +25 -2
  59. orionis/foundation/providers/progress_bar_provider.py +24 -2
  60. orionis/foundation/providers/testing_provider.py +39 -0
  61. orionis/foundation/providers/workers_provider.py +24 -2
  62. orionis/metadata/framework.py +1 -1
  63. orionis/services/asynchrony/contracts/coroutines.py +13 -5
  64. orionis/services/asynchrony/coroutines.py +33 -29
  65. orionis/services/asynchrony/exceptions/exception.py +9 -1
  66. orionis/services/environment/core/dot_env.py +46 -34
  67. orionis/services/environment/enums/__init__.py +0 -0
  68. orionis/services/environment/enums/cast_type.py +42 -0
  69. orionis/services/environment/helpers/functions.py +1 -2
  70. orionis/services/environment/key/__init__.py +0 -0
  71. orionis/services/environment/key/key_generator.py +37 -0
  72. orionis/services/environment/serializer/__init__.py +0 -0
  73. orionis/services/environment/serializer/values.py +21 -0
  74. orionis/services/environment/validators/__init__.py +0 -0
  75. orionis/services/environment/validators/key_name.py +46 -0
  76. orionis/services/environment/validators/types.py +45 -0
  77. orionis/services/system/contracts/imports.py +38 -18
  78. orionis/services/system/contracts/workers.py +29 -12
  79. orionis/services/system/imports.py +65 -25
  80. orionis/services/system/runtime/imports.py +18 -9
  81. orionis/services/system/workers.py +49 -16
  82. orionis/support/entities/__init__.py +0 -0
  83. orionis/support/entities/base.py +104 -0
  84. orionis/support/facades/testing.py +15 -0
  85. orionis/support/facades/workers.py +1 -1
  86. orionis/test/cases/asynchronous.py +0 -11
  87. orionis/test/cases/synchronous.py +0 -9
  88. orionis/test/contracts/dumper.py +11 -4
  89. orionis/test/contracts/kernel.py +5 -110
  90. orionis/test/contracts/logs.py +27 -65
  91. orionis/test/contracts/printer.py +16 -128
  92. orionis/test/contracts/test_result.py +100 -0
  93. orionis/test/contracts/unit_test.py +87 -150
  94. orionis/test/core/unit_test.py +608 -554
  95. orionis/test/entities/result.py +22 -2
  96. orionis/test/enums/__init__.py +0 -2
  97. orionis/test/enums/status.py +14 -9
  98. orionis/test/exceptions/config.py +9 -1
  99. orionis/test/exceptions/failure.py +34 -11
  100. orionis/test/exceptions/persistence.py +10 -2
  101. orionis/test/exceptions/runtime.py +9 -1
  102. orionis/test/exceptions/value.py +13 -1
  103. orionis/test/kernel.py +87 -289
  104. orionis/test/output/dumper.py +83 -18
  105. orionis/test/output/printer.py +399 -156
  106. orionis/test/records/logs.py +203 -82
  107. orionis/test/validators/__init__.py +33 -0
  108. orionis/test/validators/base_path.py +45 -0
  109. orionis/test/validators/execution_mode.py +45 -0
  110. orionis/test/validators/fail_fast.py +37 -0
  111. orionis/test/validators/folder_path.py +34 -0
  112. orionis/test/validators/module_name.py +31 -0
  113. orionis/test/validators/name_pattern.py +40 -0
  114. orionis/test/validators/pattern.py +36 -0
  115. orionis/test/validators/persistent.py +42 -0
  116. orionis/test/validators/persistent_driver.py +43 -0
  117. orionis/test/validators/print_result.py +37 -0
  118. orionis/test/validators/tags.py +37 -0
  119. orionis/test/validators/throw_exception.py +39 -0
  120. orionis/test/validators/verbosity.py +37 -0
  121. orionis/test/validators/web_report.py +35 -0
  122. orionis/test/validators/workers.py +31 -0
  123. orionis/test/view/render.py +48 -54
  124. {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/METADATA +1 -1
  125. {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/RECORD +170 -112
  126. tests/container/__init__.py +0 -0
  127. tests/container/context/__init__.py +0 -0
  128. tests/container/context/test_manager.py +27 -0
  129. tests/container/context/test_scope.py +23 -0
  130. tests/container/entities/__init__.py +0 -0
  131. tests/container/entities/test_binding.py +133 -0
  132. tests/container/enums/__init__.py +0 -0
  133. tests/container/enums/test_lifetimes.py +63 -0
  134. tests/container/facades/__init__.py +0 -0
  135. tests/container/facades/test_facade.py +61 -0
  136. tests/container/mocks/__init__.py +0 -0
  137. tests/container/mocks/mock_complex_classes.py +482 -0
  138. tests/container/mocks/mock_simple_classes.py +32 -0
  139. tests/container/providers/__init__.py +0 -0
  140. tests/container/providers/test_providers.py +48 -0
  141. tests/container/resolver/__init__.py +0 -0
  142. tests/container/resolver/test_resolver.py +55 -0
  143. tests/container/test_container.py +254 -0
  144. tests/container/test_singleton.py +98 -0
  145. tests/container/test_thread_safety.py +217 -0
  146. tests/container/validators/__init__.py +0 -0
  147. tests/container/validators/test_implements.py +140 -0
  148. tests/container/validators/test_is_abstract_class.py +99 -0
  149. tests/container/validators/test_is_callable.py +73 -0
  150. tests/container/validators/test_is_concrete_class.py +97 -0
  151. tests/container/validators/test_is_instance.py +105 -0
  152. tests/container/validators/test_is_not_subclass.py +117 -0
  153. tests/container/validators/test_is_subclass.py +115 -0
  154. tests/container/validators/test_is_valid_alias.py +113 -0
  155. tests/container/validators/test_lifetime.py +75 -0
  156. tests/example/test_example.py +2 -2
  157. tests/foundation/config/testing/test_foundation_config_testing.py +1 -1
  158. tests/metadata/test_metadata_framework.py +89 -24
  159. tests/metadata/test_metadata_package.py +55 -10
  160. tests/services/asynchrony/test_services_asynchrony_coroutine.py +52 -7
  161. tests/services/system/test_services_system_imports.py +119 -16
  162. tests/services/system/test_services_system_workers.py +71 -30
  163. tests/testing/test_testing_result.py +117 -117
  164. tests/testing/test_testing_unit.py +209 -209
  165. orionis/foundation/config/base.py +0 -112
  166. orionis/test/arguments/parser.py +0 -187
  167. orionis/test/contracts/parser.py +0 -43
  168. orionis/test/entities/arguments.py +0 -38
  169. orionis/test/enums/execution_mode.py +0 -16
  170. /orionis/{test/arguments → console/base/contracts}/__init__.py +0 -0
  171. /orionis/foundation/config/testing/enums/{test_mode.py → mode.py} +0 -0
  172. {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/WHEEL +0 -0
  173. {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/licenses/LICENCE +0 -0
  174. {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/top_level.txt +0 -0
  175. {orionis-0.405.0.dist-info → orionis-0.407.0.dist-info}/zip-safe +0 -0
@@ -1,12 +1,13 @@
1
- from dataclasses import asdict, dataclass, field, fields
1
+ from dataclasses import dataclass, field
2
2
  from typing import Optional
3
3
  from orionis.foundation.exceptions import OrionisIntegrityException
4
4
  from orionis.foundation.config.session.enums import SameSitePolicy
5
5
  from orionis.foundation.config.session.helpers.secret_key import SecretKey
6
6
  from orionis.services.environment.env import Env
7
+ from orionis.support.entities.base import BaseEntity
7
8
 
8
9
  @dataclass(unsafe_hash=True, kw_only=True)
9
- class Session:
10
+ class Session(BaseEntity):
10
11
  """
11
12
  Configuration for Starlette session middleware.
12
13
 
@@ -19,58 +20,58 @@ class Session:
19
20
  https_only (bool): Restrict cookies to HTTPS. Defaults to False.
20
21
  domain (Optional[str]): Cookie domain for cross-subdomain usage.
21
22
  """
23
+
22
24
  secret_key: str = field(
23
- default_factory=lambda: Env.get('APP_KEY', SecretKey.random()),
24
- metadata={
25
+ default = Env.get('APP_KEY', SecretKey.random()),
26
+ metadata = {
25
27
  "description": "Secret key for signing session cookies (required).",
26
- "default": "APP_KEY"
28
+ "default": SecretKey.random()
27
29
  }
28
30
  )
29
31
 
30
32
  session_cookie: str = field(
31
- default_factory=lambda: Env.get('SESSION_COOKIE_NAME', 'orionis_session'),
32
- metadata={
33
+ default = Env.get('SESSION_COOKIE_NAME', 'orionis_session'),
34
+ metadata = {
33
35
  "description": "Name of the session cookie.",
34
- "default": "orionis_session"
36
+ "default": 'orionis_session'
35
37
  }
36
38
  )
37
39
 
38
40
  max_age: Optional[int] = field(
39
- default_factory=lambda: Env.get('SESSION_MAX_AGE', 30*60),
40
- metadata={
41
+ default = Env.get('SESSION_MAX_AGE', 30 * 60),
42
+ metadata = {
41
43
  "description": "Session expiration in seconds. None for browser session.",
42
- "default": "1800 (30 minutes)"
44
+ "default": 30 * 60
43
45
  }
44
46
  )
45
47
 
46
48
  same_site: str | SameSitePolicy = field(
47
- default_factory=lambda: Env.get('SESSION_SAME_SITE', SameSitePolicy.LAX),
48
- metadata={
49
+ default = Env.get('SESSION_SAME_SITE', SameSitePolicy.LAX.value),
50
+ metadata = {
49
51
  "description": "SameSite cookie policy.",
50
- "options": ["lax", "strict", "none"],
51
- "default": "lax"
52
+ "default": SameSitePolicy.LAX.value
52
53
  }
53
54
  )
54
55
 
55
56
  path: str = field(
56
- default_factory=lambda: Env.get('SESSION_PATH', '/'),
57
- metadata={
57
+ default = Env.get('SESSION_PATH', '/'),
58
+ metadata = {
58
59
  "description": "Cookie path.",
59
60
  "default": "/"
60
61
  }
61
62
  )
62
63
 
63
64
  https_only: bool = field(
64
- default_factory=lambda: Env.get('SESSION_HTTPS_ONLY', False),
65
- metadata={
65
+ default = Env.get('SESSION_HTTPS_ONLY', False),
66
+ metadata = {
66
67
  "description": "Restrict cookies to HTTPS.",
67
68
  "default": False
68
69
  }
69
70
  )
70
71
 
71
72
  domain: Optional[str] = field(
72
- default_factory=lambda: Env.get('SESSION_DOMAIN'),
73
- metadata={
73
+ default = Env.get('SESSION_DOMAIN'),
74
+ metadata = {
74
75
  "description": "Cookie domain for cross-subdomain usage.",
75
76
  "default": None
76
77
  }
@@ -134,35 +135,4 @@ class Session:
134
135
  if self.domain.startswith('.') or self.domain.endswith('.'):
135
136
  raise OrionisIntegrityException("domain must not start or end with a dot")
136
137
  if '..' in self.domain:
137
- raise OrionisIntegrityException("domain must not contain consecutive dots")
138
-
139
- def toDict(self) -> dict:
140
- """
141
- Converts the Session entity instance into a dictionary.
142
-
143
- Returns:
144
- dict: A dictionary representation of the Session instance, with all fields serialized.
145
- """
146
- return asdict(self)
147
-
148
- def getFields(self):
149
- """
150
- Retrieves a list of field information for the current dataclass instance.
151
-
152
- Returns:
153
- list: A list of dictionaries, each containing details about a field:
154
- - name (str): The name of the field.
155
- - type (type): The type of the field.
156
- - default: The default value of the field, if specified; otherwise, the value from metadata or None.
157
- - metadata (mapping): The metadata associated with the field.
158
- """
159
- __fields = []
160
- for field in fields(self):
161
- __metadata = dict(field.metadata) or {}
162
- __fields.append({
163
- "name": field.name,
164
- "type": field.type.__name__ if hasattr(field.type, '__name__') else str(field.type),
165
- "default": field.default if (field.default is not None and '_MISSING_TYPE' not in str(field.default)) else __metadata.get('default', None),
166
- "metadata": __metadata
167
- })
168
- return __fields
138
+ raise OrionisIntegrityException("domain must not contain consecutive dots")
@@ -1,225 +1,255 @@
1
- from dataclasses import asdict, dataclass, field, fields
1
+ from dataclasses import dataclass, field
2
2
  from orionis.foundation.config.app.entities.app import App
3
3
  from orionis.foundation.config.auth.entities.auth import Auth
4
4
  from orionis.foundation.config.cache.entities.cache import Cache
5
5
  from orionis.foundation.config.cors.entities.cors import Cors
6
6
  from orionis.foundation.config.database.entities.database import Database
7
- from orionis.foundation.exceptions import OrionisIntegrityException
7
+ from orionis.foundation.config.roots.paths import Paths
8
+ from orionis.foundation.exceptions.integrity import OrionisIntegrityException
8
9
  from orionis.foundation.config.filesystems.entitites.filesystems import Filesystems
9
10
  from orionis.foundation.config.logging.entities.logging import Logging
10
11
  from orionis.foundation.config.mail.entities.mail import Mail
11
12
  from orionis.foundation.config.queue.entities.queue import Queue
12
- from orionis.foundation.config.roots.paths import Paths
13
13
  from orionis.foundation.config.session.entities.session import Session
14
14
  from orionis.foundation.config.testing.entities.testing import Testing
15
+ from orionis.support.entities.base import BaseEntity
15
16
 
16
- @dataclass
17
- class Configuration:
17
+ @dataclass(unsafe_hash=True, kw_only=True)
18
+ class Configuration(BaseEntity):
18
19
  """
19
- Configuration class encapsulates all major configuration sections for the application.
20
- Attributes:
21
- paths (Paths): Paths configuration settings.
22
- app (App): Application configuration settings.
23
- auth (Auth): Authentication configuration settings.
24
- cache (Cache): Cache configuration settings.
25
- cors (Cors): CORS configuration settings.
26
- database (Database): Database configuration settings.
27
- filesystems (Filesystems): Filesystem configuration settings.
28
- logging (Logging): Logging configuration settings.
29
- mail (Mail): Mail configuration settings.
30
- queue (Queue): Queue configuration settings.
31
- session (Session): Session configuration settings.
32
- testing (Testing): Testing configuration settings.
20
+ Main configuration dataclass for Orionis Framework startup.
21
+
22
+ Parameters
23
+ ----------
24
+ app : App or dict, optional
25
+ Application configuration settings.
26
+ auth : Auth or dict, optional
27
+ Authentication configuration settings.
28
+ cache : Cache or dict, optional
29
+ Cache configuration settings.
30
+ cors : Cors or dict, optional
31
+ CORS configuration settings.
32
+ database : Database or dict, optional
33
+ Database configuration settings.
34
+ filesystems : Filesystems or dict, optional
35
+ Filesystem configuration settings.
36
+ logging : Logging or dict, optional
37
+ Logging configuration settings.
38
+ mail : Mail or dict, optional
39
+ Mail configuration settings.
40
+ path : Paths or dict, optional
41
+ Path configuration settings.
42
+ queue : Queue or dict, optional
43
+ Queue configuration settings.
44
+ session : Session or dict, optional
45
+ Session configuration settings.
46
+ testing : Testing or dict, optional
47
+ Testing configuration settings.
48
+
49
+ Raises
50
+ ------
51
+ OrionisIntegrityException
52
+ If any configuration section is initialized with an invalid type.
33
53
  """
34
- paths : Paths = field(
35
- default_factory=Paths,
36
- metadata={
37
- "description": "Paths configuration settings."
54
+
55
+ app : App | dict = field(
56
+ default_factory = lambda: App(),
57
+ metadata = {
58
+ "description": "Application configuration settings.",
59
+ "default": App().toDict()
38
60
  }
39
61
  )
40
62
 
41
- app : App = field(
42
- default_factory=App,
43
- metadata={
44
- "description": "Application configuration settings."
63
+ auth : Auth | dict = field(
64
+ default_factory = lambda: Auth(),
65
+ metadata = {
66
+ "description": "Authentication configuration settings.",
67
+ "default": Auth().toDict()
45
68
  }
46
69
  )
47
70
 
48
- auth : Auth = field(
49
- default_factory=Auth,
50
- metadata={
51
- "description": "Authentication configuration settings."
71
+ cache : Cache | dict = field(
72
+ default_factory = lambda: Cache(),
73
+ metadata = {
74
+ "description": "Cache configuration settings.",
75
+ "default": Cache().toDict()
52
76
  }
53
77
  )
54
78
 
55
- cache : Cache = field(
56
- default_factory=Cache,
57
- metadata={
58
- "description": "Cache configuration settings."
79
+ cors : Cors | dict = field(
80
+ default_factory = lambda: Cors(),
81
+ metadata = {
82
+ "description": "CORS configuration settings.",
83
+ "default": Cors().toDict()
59
84
  }
60
85
  )
61
86
 
62
- cors : Cors = field(
63
- default_factory=Cors,
64
- metadata={
65
- "description": "CORS configuration settings."
87
+ database : Database | dict = field(
88
+ default_factory = lambda: Database(),
89
+ metadata = {
90
+ "description": "Database configuration settings.",
91
+ "default": Database().toDict()
66
92
  }
67
93
  )
68
94
 
69
- database : Database = field(
70
- default_factory=Database,
71
- metadata={
72
- "description": "Database configuration settings."
95
+ filesystems : Filesystems | dict = field(
96
+ default_factory = lambda: Filesystems(),
97
+ metadata = {
98
+ "description": "Filesystem configuration settings.",
99
+ "default": Filesystems().toDict()
73
100
  }
74
101
  )
75
102
 
76
- filesystems : Filesystems = field(
77
- default_factory=Filesystems,
78
- metadata={
79
- "description": "Filesystem configuration settings."
103
+ logging : Logging | dict = field(
104
+ default_factory = lambda: Logging(),
105
+ metadata = {
106
+ "description": "Logging configuration settings.",
107
+ "default": Logging().toDict()
80
108
  }
81
109
  )
82
110
 
83
- logging : Logging = field(
84
- default_factory=Logging,
85
- metadata={
86
- "description": "Logging configuration settings."
111
+ mail : Mail | dict = field(
112
+ default_factory = lambda: Mail(),
113
+ metadata = {
114
+ "description": "Mail configuration settings.",
115
+ "default": Mail().toDict()
87
116
  }
88
117
  )
89
118
 
90
- mail : Mail = field(
91
- default_factory=Mail,
119
+ path : Paths | dict = field(
120
+ default_factory = lambda: Paths(),
92
121
  metadata={
93
- "description": "Mail configuration settings."
122
+ "description": "Path configuration settings.",
123
+ "default": Paths().toDict()
94
124
  }
95
125
  )
96
126
 
97
- queue : Queue = field(
98
- default_factory=Queue,
99
- metadata={
100
- "description": "Queue configuration settings."
127
+ queue : Queue | dict = field(
128
+ default_factory = lambda: Queue(),
129
+ metadata = {
130
+ "description": "Queue configuration settings.",
131
+ "default": Queue().toDict()
101
132
  }
102
133
  )
103
134
 
104
- session : Session = field(
105
- default_factory=Session,
106
- metadata={
107
- "description": "Session configuration settings."
135
+ session : Session | dict = field(
136
+ default_factory = lambda: Session(),
137
+ metadata = {
138
+ "description": "Session configuration settings.",
139
+ "default": Session().toDict()
108
140
  }
109
141
  )
110
142
 
111
- testing : Testing = field(
112
- default_factory=Testing,
113
- metadata={
114
- "description": "Testing configuration settings."
143
+ testing : Testing | dict = field(
144
+ default_factory = lambda: Testing(),
145
+ metadata = {
146
+ "description": "Testing configuration settings.",
147
+ "default": Testing().toDict()
115
148
  }
116
149
  )
117
150
 
118
151
  def __post_init__(self):
119
152
  """
120
- Validates the types of the configuration attributes after initialization.
121
- Raises:
122
- OrionisIntegrityException: If any of the following attributes are not instances of their expected types:
123
- - paths (Paths)
124
- - app (App)
125
- - auth (Auth)
126
- - cache (Cache)
127
- - cors (Cors)
128
- - database (Database)
129
- - filesystems (Filesystems)
130
- - logging (Logging)
131
- - mail (Mail)
132
- - queue (Queue)
133
- - session (Session)
134
- - testing (Testing)
153
+ Validates and converts configuration attributes to their respective entity types.
154
+
155
+ Raises
156
+ ------
157
+ OrionisIntegrityException
158
+ If any attribute is not an instance of the expected type or a dictionary.
135
159
  """
136
160
 
137
- if not isinstance(self.paths, Paths):
161
+ # Validate `app` attribute
162
+ if not isinstance(self.app, (App, dict)):
138
163
  raise OrionisIntegrityException(
139
- f"Invalid type for 'paths': expected Paths, got {type(self.paths).__name__}"
164
+ f"Invalid type for 'app': expected App or dict, got {type(self.app).__name__}"
140
165
  )
166
+ if isinstance(self.app, dict):
167
+ self.app = App(**self.app)
141
168
 
142
- if not isinstance(self.app, App):
169
+ # Validate `auth` attribute
170
+ if not isinstance(self.auth, (Auth, dict)):
143
171
  raise OrionisIntegrityException(
144
- f"Invalid type for 'app': expected App, got {type(self.app).__name__}"
172
+ f"Invalid type for 'auth': expected Auth or dict, got {type(self.auth).__name__}"
145
173
  )
174
+ if isinstance(self.auth, dict):
175
+ self.auth = Auth(**self.auth)
146
176
 
147
- if not isinstance(self.auth, Auth):
177
+ # Validate `cache` attribute
178
+ if not isinstance(self.cache, (Cache, dict)):
148
179
  raise OrionisIntegrityException(
149
- f"Invalid type for 'auth': expected Auth, got {type(self.auth).__name__}"
180
+ f"Invalid type for 'cache': expected Cache or dict, got {type(self.cache).__name__}"
150
181
  )
182
+ if isinstance(self.cache, dict):
183
+ self.cache = Cache(**self.cache)
151
184
 
152
- if not isinstance(self.cache, Cache):
185
+ # Validate `cors` attribute
186
+ if not isinstance(self.cors, (Cors, dict)):
153
187
  raise OrionisIntegrityException(
154
- f"Invalid type for 'cache': expected Cache, got {type(self.cache).__name__}"
188
+ f"Invalid type for 'cors': expected Cors or dict, got {type(self.cors).__name__}"
155
189
  )
190
+ if isinstance(self.cors, dict):
191
+ self.cors = Cors(**self.cors)
156
192
 
157
- if not isinstance(self.cors, Cors):
193
+ # Validate `database` attribute
194
+ if not isinstance(self.database, (Database, dict)):
158
195
  raise OrionisIntegrityException(
159
- f"Invalid type for 'cors': expected Cors, got {type(self.cors).__name__}"
196
+ f"Invalid type for 'database': expected Database or dict, got {type(self.database).__name__}"
160
197
  )
198
+ if isinstance(self.database, dict):
199
+ self.database = Database(**self.database)
161
200
 
162
- if not isinstance(self.database, Database):
201
+ # Validate `filesystems` attribute
202
+ if not isinstance(self.filesystems, (Filesystems, dict)):
163
203
  raise OrionisIntegrityException(
164
- f"Invalid type for 'database': expected Database, got {type(self.database).__name__}"
204
+ f"Invalid type for 'filesystems': expected Filesystems or dict, got {type(self.filesystems).__name__}"
165
205
  )
206
+ if isinstance(self.filesystems, dict):
207
+ self.filesystems = Filesystems(**self.filesystems)
166
208
 
167
- if not isinstance(self.filesystems, Filesystems):
209
+ # Validate `logging` attribute
210
+ if not isinstance(self.logging, (Logging, dict)):
168
211
  raise OrionisIntegrityException(
169
- f"Invalid type for 'filesystems': expected Filesystems, got {type(self.filesystems).__name__}"
212
+ f"Invalid type for 'logging': expected Logging or dict, got {type(self.logging).__name__}"
170
213
  )
214
+ if isinstance(self.logging, dict):
215
+ self.logging = Logging(**self.logging)
171
216
 
172
- if not isinstance(self.logging, Logging):
217
+ # Validate `mail` attribute
218
+ if not isinstance(self.mail, (Mail, dict)):
173
219
  raise OrionisIntegrityException(
174
- f"Invalid type for 'logging': expected Logging, got {type(self.logging).__name__}"
220
+ f"Invalid type for 'mail': expected Mail or dict, got {type(self.mail).__name__}"
175
221
  )
222
+ if isinstance(self.mail, dict):
223
+ self.mail = Mail(**self.mail)
176
224
 
177
- if not isinstance(self.mail, Mail):
225
+ # Validate `path` attribute
226
+ if not isinstance(self.path, (Paths, dict)):
178
227
  raise OrionisIntegrityException(
179
- f"Invalid type for 'mail': expected Mail, got {type(self.mail).__name__}"
228
+ f"Invalid type for 'path': expected Paths or dict, got {type(self.path).__name__}"
180
229
  )
230
+ if isinstance(self.path, dict):
231
+ self.path = Paths(**self.path)
181
232
 
182
- if not isinstance(self.queue, Queue):
233
+ # Validate `queue` attribute
234
+ if not isinstance(self.queue, (Queue, dict)):
183
235
  raise OrionisIntegrityException(
184
- f"Invalid type for 'queue': expected Queue, got {type(self.queue).__name__}"
236
+ f"Invalid type for 'queue': expected Queue or dict, got {type(self.queue).__name__}"
185
237
  )
238
+ if isinstance(self.queue, dict):
239
+ self.queue = Queue(**self.queue)
186
240
 
187
- if not isinstance(self.session, Session):
241
+ # Validate `session` attribute
242
+ if not isinstance(self.session, (Session, dict)):
188
243
  raise OrionisIntegrityException(
189
- f"Invalid type for 'session': expected Session, got {type(self.session).__name__}"
244
+ f"Invalid type for 'session': expected Session or dict, got {type(self.session).__name__}"
190
245
  )
246
+ if isinstance(self.session, dict):
247
+ self.session = Session(**self.session)
191
248
 
192
- if not isinstance(self.testing, Testing):
249
+ # Validate `testing` attribute
250
+ if not isinstance(self.testing, (Testing, dict)):
193
251
  raise OrionisIntegrityException(
194
- f"Invalid type for 'testing': expected Testing, got {type(self.testing).__name__}"
252
+ f"Invalid type for 'testing': expected Testing or dict, got {type(self.testing).__name__}"
195
253
  )
196
-
197
- def toDict(self) -> dict:
198
- """
199
- Convert the object to a dictionary representation.
200
- Returns:
201
- dict: A dictionary representation of the Dataclass object.
202
- """
203
- return asdict(self)
204
-
205
- def getFields(self):
206
- """
207
- Retrieves a list of field information for the current dataclass instance.
208
-
209
- Returns:
210
- list: A list of dictionaries, each containing details about a field:
211
- - name (str): The name of the field.
212
- - type (type): The type of the field.
213
- - default: The default value of the field, if specified; otherwise, the value from metadata or None.
214
- - metadata (mapping): The metadata associated with the field.
215
- """
216
- __fields = []
217
- for field in fields(self):
218
- __metadata = dict(field.metadata) or {}
219
- __fields.append({
220
- "name": field.name,
221
- "type": field.type.__name__ if hasattr(field.type, '__name__') else str(field.type),
222
- "default": field.default if (field.default is not None and '_MISSING_TYPE' not in str(field.default)) else __metadata.get('default', None),
223
- "metadata": __metadata
224
- })
225
- return __fields
254
+ if isinstance(self.testing, dict):
255
+ self.testing = Testing(**self.testing)