orionis 0.405.0__py3-none-any.whl → 0.406.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 (154) 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/environment/helpers/functions.py +1 -2
  64. orionis/services/environment/key/__init__.py +0 -0
  65. orionis/services/environment/key/key_generator.py +37 -0
  66. orionis/support/entities/__init__.py +0 -0
  67. orionis/support/entities/base.py +104 -0
  68. orionis/support/facades/testing.py +15 -0
  69. orionis/support/facades/workers.py +1 -1
  70. orionis/test/cases/asynchronous.py +0 -11
  71. orionis/test/cases/synchronous.py +0 -9
  72. orionis/test/contracts/dumper.py +11 -4
  73. orionis/test/contracts/kernel.py +5 -110
  74. orionis/test/contracts/logs.py +27 -65
  75. orionis/test/contracts/printer.py +16 -128
  76. orionis/test/contracts/test_result.py +100 -0
  77. orionis/test/contracts/unit_test.py +87 -150
  78. orionis/test/core/unit_test.py +608 -554
  79. orionis/test/entities/result.py +22 -2
  80. orionis/test/enums/__init__.py +0 -2
  81. orionis/test/enums/status.py +14 -9
  82. orionis/test/exceptions/config.py +9 -1
  83. orionis/test/exceptions/failure.py +34 -11
  84. orionis/test/exceptions/persistence.py +10 -2
  85. orionis/test/exceptions/runtime.py +9 -1
  86. orionis/test/exceptions/value.py +13 -1
  87. orionis/test/kernel.py +87 -289
  88. orionis/test/output/dumper.py +82 -18
  89. orionis/test/output/printer.py +399 -156
  90. orionis/test/records/logs.py +203 -82
  91. orionis/test/validators/__init__.py +33 -0
  92. orionis/test/validators/base_path.py +45 -0
  93. orionis/test/validators/execution_mode.py +45 -0
  94. orionis/test/validators/fail_fast.py +37 -0
  95. orionis/test/validators/folder_path.py +34 -0
  96. orionis/test/validators/module_name.py +31 -0
  97. orionis/test/validators/name_pattern.py +40 -0
  98. orionis/test/validators/pattern.py +36 -0
  99. orionis/test/validators/persistent.py +42 -0
  100. orionis/test/validators/persistent_driver.py +43 -0
  101. orionis/test/validators/print_result.py +37 -0
  102. orionis/test/validators/tags.py +37 -0
  103. orionis/test/validators/throw_exception.py +39 -0
  104. orionis/test/validators/verbosity.py +37 -0
  105. orionis/test/validators/web_report.py +35 -0
  106. orionis/test/validators/workers.py +31 -0
  107. orionis/test/view/render.py +48 -54
  108. {orionis-0.405.0.dist-info → orionis-0.406.0.dist-info}/METADATA +1 -1
  109. {orionis-0.405.0.dist-info → orionis-0.406.0.dist-info}/RECORD +149 -98
  110. tests/container/__init__.py +0 -0
  111. tests/container/context/__init__.py +0 -0
  112. tests/container/context/test_manager.py +27 -0
  113. tests/container/context/test_scope.py +23 -0
  114. tests/container/entities/__init__.py +0 -0
  115. tests/container/entities/test_binding.py +133 -0
  116. tests/container/enums/__init__.py +0 -0
  117. tests/container/enums/test_lifetimes.py +63 -0
  118. tests/container/facades/__init__.py +0 -0
  119. tests/container/facades/test_facade.py +61 -0
  120. tests/container/mocks/__init__.py +0 -0
  121. tests/container/mocks/mock_complex_classes.py +482 -0
  122. tests/container/mocks/mock_simple_classes.py +32 -0
  123. tests/container/providers/__init__.py +0 -0
  124. tests/container/providers/test_providers.py +48 -0
  125. tests/container/resolver/__init__.py +0 -0
  126. tests/container/resolver/test_resolver.py +55 -0
  127. tests/container/test_container.py +254 -0
  128. tests/container/test_singleton.py +98 -0
  129. tests/container/test_thread_safety.py +217 -0
  130. tests/container/validators/__init__.py +0 -0
  131. tests/container/validators/test_implements.py +140 -0
  132. tests/container/validators/test_is_abstract_class.py +99 -0
  133. tests/container/validators/test_is_callable.py +73 -0
  134. tests/container/validators/test_is_concrete_class.py +97 -0
  135. tests/container/validators/test_is_instance.py +105 -0
  136. tests/container/validators/test_is_not_subclass.py +117 -0
  137. tests/container/validators/test_is_subclass.py +115 -0
  138. tests/container/validators/test_is_valid_alias.py +113 -0
  139. tests/container/validators/test_lifetime.py +75 -0
  140. tests/foundation/config/testing/test_foundation_config_testing.py +1 -1
  141. tests/metadata/test_metadata_framework.py +18 -18
  142. tests/testing/test_testing_result.py +117 -117
  143. tests/testing/test_testing_unit.py +209 -209
  144. orionis/foundation/config/base.py +0 -112
  145. orionis/test/arguments/parser.py +0 -187
  146. orionis/test/contracts/parser.py +0 -43
  147. orionis/test/entities/arguments.py +0 -38
  148. orionis/test/enums/execution_mode.py +0 -16
  149. /orionis/{test/arguments → console/base/contracts}/__init__.py +0 -0
  150. /orionis/foundation/config/testing/enums/{test_mode.py → mode.py} +0 -0
  151. {orionis-0.405.0.dist-info → orionis-0.406.0.dist-info}/WHEEL +0 -0
  152. {orionis-0.405.0.dist-info → orionis-0.406.0.dist-info}/licenses/LICENCE +0 -0
  153. {orionis-0.405.0.dist-info → orionis-0.406.0.dist-info}/top_level.txt +0 -0
  154. {orionis-0.405.0.dist-info → orionis-0.406.0.dist-info}/zip-safe +0 -0
@@ -1,9 +1,10 @@
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
+ from orionis.support.entities.base import BaseEntity
4
5
 
5
6
  @dataclass(unsafe_hash=True, kw_only=True)
6
- class S3:
7
+ class S3(BaseEntity):
7
8
  """
8
9
  Represents an AWS S3 storage configuration.
9
10
 
@@ -28,64 +29,64 @@ class S3:
28
29
  """
29
30
 
30
31
  key: str = field(
31
- default="",
32
- metadata={
32
+ default = "",
33
+ metadata = {
33
34
  "description": "AWS access key ID.",
34
35
  "default": ""
35
36
  }
36
37
  )
37
38
 
38
39
  secret: str = field(
39
- default="",
40
- metadata={
40
+ default = "",
41
+ metadata = {
41
42
  "description": "AWS secret access key.",
42
43
  "default": ""
43
44
  }
44
45
  )
45
46
 
46
47
  region: str = field(
47
- default="us-east-1",
48
- metadata={
48
+ default = "us-east-1",
49
+ metadata = {
49
50
  "description": "AWS region where the bucket is located.",
50
51
  "default": "us-east-1"
51
52
  }
52
53
  )
53
54
 
54
55
  bucket: str = field(
55
- default="",
56
- metadata={
56
+ default = "",
57
+ metadata = {
57
58
  "description": "The S3 bucket name.",
58
59
  "default": ""
59
60
  }
60
61
  )
61
62
 
62
63
  url: Optional[str] = field(
63
- default=None,
64
- metadata={
64
+ default = None,
65
+ metadata = {
65
66
  "description": "The URL endpoint for accessing the S3 bucket.",
66
67
  "default": None
67
68
  }
68
69
  )
69
70
 
70
71
  endpoint: Optional[str] = field(
71
- default=None,
72
- metadata={
72
+ default = None,
73
+ metadata = {
73
74
  "description": "The AWS S3 endpoint URL.",
74
75
  "default": None
75
76
  }
76
77
  )
77
78
 
78
79
  use_path_style_endpoint: bool = field(
79
- default=False,
80
- metadata={
80
+ default = False,
81
+ metadata = {
81
82
  "description": "Whether to use a path-style endpoint.",
82
83
  "default": False
83
84
  }
84
85
  )
85
86
 
86
87
  throw: bool = field(
87
- default=False,
88
- metadata={
88
+ default = False,
89
+ metadata = {
89
90
  "description": "Whether to raise an exception on errors.",
90
91
  "default": False
91
92
  }
@@ -101,56 +102,34 @@ class S3:
101
102
  Ensures that all required attributes are of the correct type and, where applicable, are non-empty.
102
103
  """
103
104
 
105
+ # Validate `key` attribute
104
106
  if not isinstance(self.key, str):
105
107
  raise OrionisIntegrityException("The 'key' attribute must be a string.")
106
108
 
109
+ # Validate `secret` attribute
107
110
  if not isinstance(self.secret, str):
108
111
  raise OrionisIntegrityException("The 'secret' attribute must be a string.")
109
112
 
113
+ # Validate `region` attribute
110
114
  if not isinstance(self.region, str) or not self.region:
111
115
  raise OrionisIntegrityException("The 'region' attribute must be a non-empty string.")
112
116
 
117
+ # Validate `bucket` attribute
113
118
  if not isinstance(self.bucket, str):
114
119
  raise OrionisIntegrityException("The 'bucket' attribute must be a string.")
115
120
 
121
+ # Validate `url` attribute
116
122
  if self.url is not None and not isinstance(self.url, str):
117
123
  raise OrionisIntegrityException("The 'url' attribute must be a string or None.")
118
124
 
125
+ # Validate `endpoint` attribute
119
126
  if self.endpoint is not None and not isinstance(self.endpoint, str):
120
127
  raise OrionisIntegrityException("The 'endpoint' attribute must be a string or None.")
121
128
 
129
+ # Validate `use_path_style_endpoint` attribute
122
130
  if not isinstance(self.use_path_style_endpoint, bool):
123
131
  raise OrionisIntegrityException("The 'use_path_style_endpoint' attribute must be a boolean.")
124
132
 
133
+ # Validate `throw` attribute
125
134
  if not isinstance(self.throw, bool):
126
- raise OrionisIntegrityException("The 'throw' attribute must be a boolean.")
127
-
128
- def toDict(self) -> dict:
129
- """
130
- Convert the object to a dictionary representation.
131
- Returns:
132
- dict: A dictionary representation of the Dataclass object.
133
- """
134
- return asdict(self)
135
-
136
- def getFields(self):
137
- """
138
- Retrieves a list of field information for the current dataclass instance.
139
-
140
- Returns:
141
- list: A list of dictionaries, each containing details about a field:
142
- - name (str): The name of the field.
143
- - type (type): The type of the field.
144
- - default: The default value of the field, if specified; otherwise, the value from metadata or None.
145
- - metadata (mapping): The metadata associated with the field.
146
- """
147
- __fields = []
148
- for field in fields(self):
149
- __metadata = dict(field.metadata) or {}
150
- __fields.append({
151
- "name": field.name,
152
- "type": field.type.__name__ if hasattr(field.type, '__name__') else str(field.type),
153
- "default": field.default if (field.default is not None and '_MISSING_TYPE' not in str(field.default)) else __metadata.get('default', None),
154
- "metadata": __metadata
155
- })
156
- return __fields
135
+ raise OrionisIntegrityException("The 'throw' attribute must be a boolean.")
@@ -1,11 +1,12 @@
1
- from dataclasses import asdict, dataclass, field, fields
1
+ from dataclasses import dataclass, field
2
2
  from orionis.foundation.exceptions import OrionisIntegrityException
3
3
  from orionis.foundation.config.filesystems.entitites.aws import S3
4
4
  from orionis.foundation.config.filesystems.entitites.public import Public
5
5
  from orionis.foundation.config.filesystems.entitites.local import Local
6
+ from orionis.support.entities.base import BaseEntity
6
7
 
7
8
  @dataclass(unsafe_hash=True, kw_only=True)
8
- class Disks:
9
+ class Disks(BaseEntity):
9
10
  """
10
11
  Represents the configuration for different filesystem disks.
11
12
  Attributes:
@@ -18,27 +19,27 @@ class Disks:
18
19
  Converts the Disks object into a dictionary representation.
19
20
  """
20
21
 
21
- local : Local = field(
22
- default_factory=Local,
22
+ local : Local | dict = field(
23
+ default_factory = lambda: Local(),
23
24
  metadata={
24
25
  "description": "The absolute or relative path where local files are stored.",
25
- "default": "Local()",
26
+ "default": Local().toDict()
26
27
  }
27
28
  )
28
29
 
29
- public : Public = field(
30
- default_factory=Public,
30
+ public : Public | dict = field(
31
+ default_factory = lambda: Public(),
31
32
  metadata={
32
33
  "description": "The absolute or relative path where public files are stored.",
33
- "default": "Public()",
34
+ "default": Public().toDict()
34
35
  }
35
36
  )
36
37
 
37
- aws : S3 = field(
38
- default_factory=S3,
38
+ aws : S3 | dict = field(
39
+ default_factory = lambda: S3(),
39
40
  metadata={
40
41
  "description": "The configuration for AWS S3 storage.",
41
- "default": "S3()",
42
+ "default": S3().toDict()
42
43
  }
43
44
  )
44
45
 
@@ -50,41 +51,20 @@ class Disks:
50
51
  ValueError: If the 'path' is empty after conversion.
51
52
  """
52
53
 
53
- if not isinstance(self.local, Local):
54
- raise OrionisIntegrityException("The 'local' attribute must be a Local object.")
54
+ # Validate the 'local' attribute
55
+ if not isinstance(self.local, (Local, dict)):
56
+ raise OrionisIntegrityException("The 'local' attribute must be a Local object or a dictionary.")
57
+ if isinstance(self.local, dict):
58
+ self.local = Local(**self.local)
55
59
 
56
- if not isinstance(self.public, Public):
57
- raise OrionisIntegrityException("The 'public' attribute must be a Public object.")
60
+ # Validate the 'public' attribute
61
+ if not isinstance(self.public, (Public, dict)):
62
+ raise OrionisIntegrityException("The 'public' attribute must be a Public object or a dictionary.")
63
+ if isinstance(self.public, dict):
64
+ self.public = Public(**self.public)
58
65
 
59
- if not isinstance(self.aws, S3):
60
- raise OrionisIntegrityException("The 'aws' attribute must be a S3 object.")
61
-
62
- def toDict(self) -> dict:
63
- """
64
- Convert the object to a dictionary representation.
65
- Returns:
66
- dict: A dictionary representation of the Dataclass object.
67
- """
68
- return asdict(self)
69
-
70
- def getFields(self):
71
- """
72
- Retrieves a list of field information for the current dataclass instance.
73
-
74
- Returns:
75
- list: A list of dictionaries, each containing details about a field:
76
- - name (str): The name of the field.
77
- - type (type): The type of the field.
78
- - default: The default value of the field, if specified; otherwise, the value from metadata or None.
79
- - metadata (mapping): The metadata associated with the field.
80
- """
81
- __fields = []
82
- for field in fields(self):
83
- __metadata = dict(field.metadata) or {}
84
- __fields.append({
85
- "name": field.name,
86
- "type": field.type.__name__ if hasattr(field.type, '__name__') else str(field.type),
87
- "default": field.default if (field.default is not None and '_MISSING_TYPE' not in str(field.default)) else __metadata.get('default', None),
88
- "metadata": __metadata
89
- })
90
- return __fields
66
+ # Validate the 'aws' attribute
67
+ if not isinstance(self.aws, (S3, dict)):
68
+ raise OrionisIntegrityException("The 'aws' attribute must be an S3 object or a dictionary.")
69
+ if isinstance(self.aws, dict):
70
+ self.aws = S3(**self.aws)
@@ -1,9 +1,10 @@
1
- from dataclasses import dataclass, field, asdict, fields
1
+ from dataclasses import dataclass, field, fields
2
2
  from orionis.foundation.config.filesystems.entitites.disks import Disks
3
3
  from orionis.foundation.exceptions import OrionisIntegrityException
4
+ from orionis.support.entities.base import BaseEntity
4
5
 
5
6
  @dataclass(unsafe_hash=True, kw_only=True)
6
- class Filesystems:
7
+ class Filesystems(BaseEntity):
7
8
  """
8
9
  Represents the filesystems configuration.
9
10
 
@@ -16,18 +17,18 @@ class Filesystems:
16
17
  """
17
18
 
18
19
  default: str = field(
19
- default="local",
20
- metadata={
20
+ default = "local",
21
+ metadata = {
21
22
  "description": "The default filesystem disk to use.",
22
23
  "default": "local",
23
24
  }
24
25
  )
25
26
 
26
- disks: Disks = field(
27
- default_factory=Disks,
27
+ disks: Disks | dict = field(
28
+ default_factory = lambda: Disks(),
28
29
  metadata={
29
30
  "description": "A collection of available filesystem disks.",
30
- "default": "Disks()",
31
+ "default": Disks().toDict()
31
32
  }
32
33
  )
33
34
 
@@ -35,41 +36,18 @@ class Filesystems:
35
36
  """
36
37
  Validates the types of the attributes after initialization.
37
38
  """
39
+
40
+ # Validate the 'default' property
38
41
  options = [f.name for f in fields(Disks)]
39
42
  if not isinstance(self.default, str) or self.default not in options:
40
43
  raise OrionisIntegrityException(
41
44
  f"The 'default' property must be a string and match one of the available options ({options})."
42
45
  )
43
46
 
44
- if not isinstance(self.disks, Disks):
47
+ # Validate the 'disks' property
48
+ if not isinstance(self.disks, (Disks, dict)):
45
49
  raise OrionisIntegrityException(
46
- "The 'disks' property must be an instance of Disks."
50
+ "The 'disks' property must be an instance of Disks or a dictionary."
47
51
  )
48
-
49
- def toDict(self) -> dict:
50
- """
51
- Converts the current instance into a dictionary representation.
52
- """
53
- return asdict(self)
54
-
55
- def getFields(self):
56
- """
57
- Retrieves a list of field information for the current dataclass instance.
58
-
59
- Returns:
60
- list: A list of dictionaries, each containing details about a field:
61
- - name (str): The name of the field.
62
- - type (type): The type of the field.
63
- - default: The default value of the field, if specified; otherwise, the value from metadata or None.
64
- - metadata (mapping): The metadata associated with the field.
65
- """
66
- __fields = []
67
- for field in fields(self):
68
- __metadata = dict(field.metadata) or {}
69
- __fields.append({
70
- "name": field.name,
71
- "type": field.type.__name__ if hasattr(field.type, '__name__') else str(field.type),
72
- "default": field.default if (field.default is not None and '_MISSING_TYPE' not in str(field.default)) else __metadata.get('default', None),
73
- "metadata": __metadata
74
- })
75
- return __fields
52
+ if isinstance(self.disks, dict):
53
+ self.disks = Disks(**self.disks)
@@ -1,8 +1,9 @@
1
- from dataclasses import asdict, dataclass, field, fields
1
+ from dataclasses import dataclass, field
2
2
  from orionis.foundation.exceptions import OrionisIntegrityException
3
+ from orionis.support.entities.base import BaseEntity
3
4
 
4
5
  @dataclass(unsafe_hash=True, kw_only=True)
5
- class Local:
6
+ class Local(BaseEntity):
6
7
  """
7
8
  Represents a local filesystem configuration.
8
9
 
@@ -12,8 +13,8 @@ class Local:
12
13
  The absolute or relative path where local files are stored.
13
14
  """
14
15
  path: str = field(
15
- default="storage/app/private",
16
- metadata={
16
+ default = "storage/app/private",
17
+ metadata = {
17
18
  "description": "The absolute or relative path where local files are stored.",
18
19
  "default": "storage/app/private",
19
20
  }
@@ -22,40 +23,13 @@ class Local:
22
23
  def __post_init__(self):
23
24
  """
24
25
  Post-initialization method to ensure the 'path' attribute is a non-empty string.
26
+
25
27
  - Raises:
26
28
  ValueError: If the 'path' is empty.
27
29
  """
30
+
31
+ # Validate the 'path' attribute
28
32
  if not isinstance(self.path, str):
29
33
  raise OrionisIntegrityException("The 'path' attribute must be a string.")
30
34
  if not self.path.strip():
31
- raise OrionisIntegrityException("The 'path' attribute cannot be empty.")
32
-
33
- def toDict(self) -> dict:
34
- """
35
- Convert the object to a dictionary representation.
36
- Returns:
37
- dict: A dictionary representation of the Dataclass object.
38
- """
39
- return asdict(self)
40
-
41
- def getFields(self):
42
- """
43
- Retrieves a list of field information for the current dataclass instance.
44
-
45
- Returns:
46
- list: A list of dictionaries, each containing details about a field:
47
- - name (str): The name of the field.
48
- - type (type): The type of the field.
49
- - default: The default value of the field, if specified; otherwise, the value from metadata or None.
50
- - metadata (mapping): The metadata associated with the field.
51
- """
52
- __fields = []
53
- for field in fields(self):
54
- __metadata = dict(field.metadata) or {}
55
- __fields.append({
56
- "name": field.name,
57
- "type": field.type.__name__ if hasattr(field.type, '__name__') else str(field.type),
58
- "default": field.default if (field.default is not None and '_MISSING_TYPE' not in str(field.default)) else __metadata.get('default', None),
59
- "metadata": __metadata
60
- })
61
- return __fields
35
+ raise OrionisIntegrityException("The 'path' attribute cannot be empty.")
@@ -1,8 +1,9 @@
1
- from dataclasses import asdict, dataclass, field, fields
1
+ from dataclasses import dataclass, field
2
2
  from orionis.foundation.exceptions import OrionisIntegrityException
3
+ from orionis.support.entities.base import BaseEntity
3
4
 
4
5
  @dataclass(unsafe_hash=True, kw_only=True)
5
- class Public:
6
+ class Public(BaseEntity):
6
7
  """
7
8
  Represents a local filesystem configuration.
8
9
 
@@ -12,63 +13,35 @@ class Public:
12
13
  The absolute or relative path where public files are stored.
13
14
  """
14
15
  path: str = field(
15
- default="storage/app/public",
16
- metadata={
16
+ default = "storage/app/public",
17
+ metadata = {
17
18
  "description": "The absolute or relative path where public files are stored.",
18
- "default": "storage/app/public",
19
+ "default": "storage/app/public"
19
20
  }
20
21
  )
21
22
 
22
23
  url: str = field(
23
- default="static",
24
- metadata={
24
+ default = "static",
25
+ metadata = {
25
26
  "description": "The URL where the public files can be accessed.",
26
- "default": "static",
27
+ "default": "static"
27
28
  }
28
29
  )
29
30
 
30
31
  def __post_init__(self):
31
32
  """
32
33
  Post-initialization method to ensure the 'path' attribute is a non-empty string.
33
- - Raises:
34
+
35
+ Raises:
34
36
  OrionisIntegrityException: If any of the attributes are not of the expected type or are empty.
35
37
  """
36
38
 
39
+ # Validate the 'path' attribute
37
40
  if not isinstance(self.path, str):
38
41
  raise OrionisIntegrityException("The 'path' attribute must be a string.")
39
42
 
43
+ # Validate the 'url' attribute
40
44
  if not isinstance(self.url, str):
41
45
  raise OrionisIntegrityException("The 'url' attribute must be a string.")
42
-
43
46
  if not self.path.strip() or not self.url.strip():
44
- raise OrionisIntegrityException("The 'path' and 'url' attributes cannot be empty.")
45
-
46
- def toDict(self) -> dict:
47
- """
48
- Convert the object to a dictionary representation.
49
- Returns:
50
- dict: A dictionary representation of the Dataclass object.
51
- """
52
- return asdict(self)
53
-
54
- def getFields(self):
55
- """
56
- Retrieves a list of field information for the current dataclass instance.
57
-
58
- Returns:
59
- list: A list of dictionaries, each containing details about a field:
60
- - name (str): The name of the field.
61
- - type (type): The type of the field.
62
- - default: The default value of the field, if specified; otherwise, the value from metadata or None.
63
- - metadata (mapping): The metadata associated with the field.
64
- """
65
- __fields = []
66
- for field in fields(self):
67
- __metadata = dict(field.metadata) or {}
68
- __fields.append({
69
- "name": field.name,
70
- "type": field.type.__name__ if hasattr(field.type, '__name__') else str(field.type),
71
- "default": field.default if (field.default is not None and '_MISSING_TYPE' not in str(field.default)) else __metadata.get('default', None),
72
- "metadata": __metadata
73
- })
74
- return __fields
47
+ raise OrionisIntegrityException("The 'path' and 'url' attributes cannot be empty.")