orionis 0.8.0__tar.gz → 0.9.0__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 (150) hide show
  1. {orionis-0.8.0/orionis.egg-info → orionis-0.9.0}/PKG-INFO +1 -1
  2. {orionis-0.8.0 → orionis-0.9.0}/orionis/framework.py +1 -1
  3. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/container/container.py +97 -12
  4. orionis-0.9.0/orionis/luminate/container/types.py +25 -0
  5. orionis-0.9.0/orionis/luminate/contracts/container/container_interface.py +152 -0
  6. orionis-0.9.0/orionis/luminate/contracts/container/types_interface.py +16 -0
  7. {orionis-0.8.0 → orionis-0.9.0/orionis.egg-info}/PKG-INFO +1 -1
  8. {orionis-0.8.0 → orionis-0.9.0}/orionis.egg-info/SOURCES.txt +3 -0
  9. {orionis-0.8.0 → orionis-0.9.0}/LICENCE +0 -0
  10. {orionis-0.8.0 → orionis-0.9.0}/MANIFEST.in +0 -0
  11. {orionis-0.8.0 → orionis-0.9.0}/README.md +0 -0
  12. {orionis-0.8.0 → orionis-0.9.0}/orionis/__init__.py +0 -0
  13. {orionis-0.8.0 → orionis-0.9.0}/orionis/cli_manager.py +0 -0
  14. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/__init__.py +0 -0
  15. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/app.py +0 -0
  16. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/bootstrap/__init__.py +0 -0
  17. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/bootstrap/parser.py +0 -0
  18. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/bootstrap/register.py +0 -0
  19. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/cache/__init__.py +0 -0
  20. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/cache/app/__init__.py +0 -0
  21. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/cache/app/config.py +0 -0
  22. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/cache/console/__init__.py +0 -0
  23. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/cache/console/commands.py +0 -0
  24. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/config/__init__.py +0 -0
  25. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/config/dataclass/__init__.py +0 -0
  26. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/config/dataclass/app.py +0 -0
  27. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/config/dataclass/auth.py +0 -0
  28. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/config/dataclass/cache.py +0 -0
  29. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/config/dataclass/cors.py +0 -0
  30. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/config/dataclass/database.py +0 -0
  31. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/config/dataclass/filesystems.py +0 -0
  32. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/config/dataclass/logging.py +0 -0
  33. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/config/dataclass/mail.py +0 -0
  34. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/config/dataclass/queue.py +0 -0
  35. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/config/dataclass/session.py +0 -0
  36. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/config/environment.py +0 -0
  37. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/config/sections.py +0 -0
  38. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/__init__.py +0 -0
  39. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/base/__init__.py +0 -0
  40. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/base/command.py +0 -0
  41. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/cache.py +0 -0
  42. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/command.py +0 -0
  43. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/command_filter.py +0 -0
  44. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/commands/__init__.py +0 -0
  45. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/commands/cache_clear.py +0 -0
  46. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/commands/help.py +0 -0
  47. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/commands/schedule_work.py +0 -0
  48. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/commands/tests.py +0 -0
  49. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/commands/version.py +0 -0
  50. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/exceptions/__init__.py +0 -0
  51. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/exceptions/cli_exception.py +0 -0
  52. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/kernel.py +0 -0
  53. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/output/__init__.py +0 -0
  54. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/output/console.py +0 -0
  55. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/output/executor.py +0 -0
  56. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/output/progress_bar.py +0 -0
  57. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/output/styles.py +0 -0
  58. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/parser.py +0 -0
  59. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/register.py +0 -0
  60. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/runner.py +0 -0
  61. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/scripts/__init__.py +0 -0
  62. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/scripts/management.py +0 -0
  63. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/tasks/__init__.py +0 -0
  64. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/console/tasks/scheduler.py +0 -0
  65. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/container/exception.py +0 -0
  66. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/__init__.py +0 -0
  67. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/bootstrap/parser_interface.py +0 -0
  68. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/cache/__init__.py +0 -0
  69. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/cache/cache_commands_interface.py +0 -0
  70. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/config/__init__.py +0 -0
  71. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/config/config_interface.py +0 -0
  72. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/config/environment_interface.py +0 -0
  73. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/console/__init__.py +0 -0
  74. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/console/base_command_interface.py +0 -0
  75. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/console/cli_cache_interface.py +0 -0
  76. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/console/command_filter_interface.py +0 -0
  77. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/console/command_interface.py +0 -0
  78. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/console/console_interface.py +0 -0
  79. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/console/executor_interface.py +0 -0
  80. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/console/kernel_interface.py +0 -0
  81. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/console/management_interface.py +0 -0
  82. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/console/parser_interface.py +0 -0
  83. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/console/progress_bar_interface.py +0 -0
  84. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/console/register_interface.py +0 -0
  85. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/console/runner_interface.py +0 -0
  86. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/console/schedule_interface.py +0 -0
  87. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/console/task_manager_interface.py +0 -0
  88. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/facades/__init__.py +0 -0
  89. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/facades/env_interface.py +0 -0
  90. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/facades/log_interface.py +0 -0
  91. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/facades/paths_interface.py +0 -0
  92. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/facades/tests_interface.py +0 -0
  93. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/files/__init__.py +0 -0
  94. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/files/paths_interface.py +0 -0
  95. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/installer/__init__.py +0 -0
  96. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/installer/output_interface.py +0 -0
  97. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/installer/setup_interface.py +0 -0
  98. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/installer/upgrade_interface.py +0 -0
  99. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/log/__init__.py +0 -0
  100. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/log/logger_interface.py +0 -0
  101. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/pipelines/cli_pipeline_interface.py +0 -0
  102. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/publisher/__init__.py +0 -0
  103. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/publisher/pypi_publisher_interface.py +0 -0
  104. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/test/__init__.py +0 -0
  105. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/test/unit_test_interface.py +0 -0
  106. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/tools/__init__.py +0 -0
  107. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/tools/reflection_interface.py +0 -0
  108. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/contracts/tools/std_interface.py +0 -0
  109. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/facades/__init__.py +0 -0
  110. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/facades/environment.py +0 -0
  111. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/facades/log.py +0 -0
  112. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/facades/paths.py +0 -0
  113. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/facades/tests.py +0 -0
  114. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/files/__init__.py +0 -0
  115. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/files/paths.py +0 -0
  116. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/installer/__init__.py +0 -0
  117. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/installer/icon.ascii +0 -0
  118. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/installer/info.ascii +0 -0
  119. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/installer/output.py +0 -0
  120. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/installer/setup.py +0 -0
  121. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/installer/upgrade.py +0 -0
  122. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/log/__init__.py +0 -0
  123. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/log/logger.py +0 -0
  124. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/pipelines/__init__.py +0 -0
  125. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/pipelines/cli_pipeline.py +0 -0
  126. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/publisher/__init__.py +0 -0
  127. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/publisher/pypi.py +0 -0
  128. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/static/bg/galaxy.jpg +0 -0
  129. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/static/favicon/OrionisFrameworkFavicon.png +0 -0
  130. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/static/logos/OrionisFramework.jpg +0 -0
  131. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/static/logos/OrionisFramework.png +0 -0
  132. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/static/logos/OrionisFramework.psd +0 -0
  133. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/static/logos/OrionisFramework2.png +0 -0
  134. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/static/logos/OrionisFramework3.png +0 -0
  135. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/test/__init__.py +0 -0
  136. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/test/exception.py +0 -0
  137. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/test/unit_test.py +0 -0
  138. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/tools/__init__.py +0 -0
  139. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/tools/reflection.py +0 -0
  140. {orionis-0.8.0 → orionis-0.9.0}/orionis/luminate/tools/std.py +0 -0
  141. {orionis-0.8.0 → orionis-0.9.0}/orionis.egg-info/dependency_links.txt +0 -0
  142. {orionis-0.8.0 → orionis-0.9.0}/orionis.egg-info/entry_points.txt +0 -0
  143. {orionis-0.8.0 → orionis-0.9.0}/orionis.egg-info/requires.txt +0 -0
  144. {orionis-0.8.0 → orionis-0.9.0}/orionis.egg-info/top_level.txt +0 -0
  145. {orionis-0.8.0 → orionis-0.9.0}/setup.cfg +0 -0
  146. {orionis-0.8.0 → orionis-0.9.0}/setup.py +0 -0
  147. {orionis-0.8.0 → orionis-0.9.0}/tests/__init__.py +0 -0
  148. {orionis-0.8.0 → orionis-0.9.0}/tests/tools/__init__.py +0 -0
  149. {orionis-0.8.0 → orionis-0.9.0}/tests/tools/class_example.py +0 -0
  150. {orionis-0.8.0 → orionis-0.9.0}/tests/tools/test_reflection.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: orionis
3
- Version: 0.8.0
3
+ Version: 0.9.0
4
4
  Summary: Orionis Framework – Elegant, Fast, and Powerful.
5
5
  Home-page: https://github.com/orionis-framework/framework
6
6
  Author: Raul Mauricio Uñate Castro
@@ -5,7 +5,7 @@
5
5
  NAME = "orionis"
6
6
 
7
7
  # Current version of the framework
8
- VERSION = "0.8.0"
8
+ VERSION = "0.9.0"
9
9
 
10
10
  # Full name of the author or maintainer of the project
11
11
  AUTHOR = "Raul Mauricio Uñate Castro"
@@ -1,8 +1,10 @@
1
1
  import inspect
2
2
  from typing import Any, Callable
3
+ from orionis.luminate.container.types import Types
4
+ from orionis.luminate.contracts.container.container_interface import IContainer
3
5
  from orionis.luminate.container.exception import OrionisContainerException, OrionisContainerValueError
4
6
 
5
- class Container:
7
+ class Container(IContainer):
6
8
  """Service container and dependency injection."""
7
9
 
8
10
  _instance = None
@@ -18,6 +20,8 @@ class Container:
18
20
  cls._instance._aliases = {}
19
21
  cls._instance._scoped_instances = {}
20
22
  cls._instance._conditional_bindings = {}
23
+ # Initialize the PrimitiveTypes validator
24
+ cls._instance._primitive_types_validator = Types()
21
25
  return cls._instance
22
26
 
23
27
  def bind(self, abstract: str, concrete: Callable[..., Any]) -> None:
@@ -31,6 +35,10 @@ class Container:
31
35
  OrionisContainerException: If the service is already registered.
32
36
  TypeError: If the implementation is not a callable or instantiable class.
33
37
  """
38
+
39
+ # Validate that the abstract name is not a primitive type
40
+ self._primitiveTypeValidator(abstract)
41
+
34
42
  if self.has(abstract):
35
43
  raise OrionisContainerException(f"The service '{abstract}' is already registered in the container.")
36
44
 
@@ -50,6 +58,10 @@ class Container:
50
58
  OrionisContainerException: If the service is already registered.
51
59
  TypeError: If the implementation is not a callable or instantiable class.
52
60
  """
61
+
62
+ # Validate that the abstract name is not a primitive type
63
+ self._primitiveTypeValidator(abstract)
64
+
53
65
  if self.has(abstract):
54
66
  raise OrionisContainerException(f"The service '{abstract}' is already registered in the container.")
55
67
 
@@ -69,6 +81,10 @@ class Container:
69
81
  OrionisContainerException: If the service is already registered.
70
82
  TypeError: If the implementation is not a callable or instantiable class.
71
83
  """
84
+
85
+ # Validate that the abstract name is not a primitive type
86
+ self._primitiveTypeValidator(abstract)
87
+
72
88
  if self.has(abstract):
73
89
  raise OrionisContainerException(f"The service '{abstract}' is already registered in the container.")
74
90
 
@@ -88,6 +104,10 @@ class Container:
88
104
  OrionisContainerException: If the service is already registered.
89
105
  TypeError: If the implementation is not a callable or instantiable class.
90
106
  """
107
+
108
+ # Validate that the abstract name is not a primitive type
109
+ self._primitiveTypeValidator(abstract)
110
+
91
111
  if self.has(abstract):
92
112
  raise OrionisContainerException(f"The service '{abstract}' is already registered in the container.")
93
113
 
@@ -107,6 +127,10 @@ class Container:
107
127
  OrionisContainerException: If the instance is already registered.
108
128
  ValueError: If the provided instance is of an unexpected or invalid type.
109
129
  """
130
+
131
+ # Validate that the abstract name is not a primitive type
132
+ self._primitiveTypeValidator(abstract)
133
+
110
134
  if abstract in self._instances:
111
135
  raise OrionisContainerException(f"The instance '{abstract}' is already registered in the container.")
112
136
 
@@ -151,6 +175,10 @@ class Container:
151
175
  OrionisContainerException: If the original service is not registered.
152
176
  ValueError: If the alias is not a valid string or is already in use.
153
177
  """
178
+
179
+ # Validate that the abstract name is not a primitive type
180
+ self._primitiveTypeValidator(abstract)
181
+
154
182
  # Validate alias type
155
183
  if not isinstance(alias, str) or not alias:
156
184
  raise ValueError("The alias must be a non-empty string.")
@@ -214,6 +242,57 @@ class Container:
214
242
 
215
243
  raise OrionisContainerValueError(f"No definition found for '{abstract}'. Ensure the service is registered.")
216
244
 
245
+ def call(self, instance: Any, method_name: str, **overrides):
246
+ """Llama a un método del objeto resolviendo automáticamente las dependencias registradas.
247
+
248
+ Args:
249
+ instance (Any): Instancia del objeto en el cual se ejecutará el método.
250
+ method_name (str): Nombre del método a llamar.
251
+ **overrides: Argumentos que se deben pasar manualmente en lugar de resolverlos automáticamente.
252
+
253
+ Returns:
254
+ Any: El resultado de ejecutar el método con las dependencias resueltas.
255
+
256
+ Raises:
257
+ AttributeError: Si el método no existe en la instancia.
258
+ """
259
+ if not hasattr(instance, method_name):
260
+ raise AttributeError(f"'{instance.__class__.__name__}' has no method '{method_name}'")
261
+
262
+ method = getattr(instance, method_name)
263
+ signature = inspect.signature(method)
264
+ dependencies = {}
265
+
266
+ for name, param in signature.parameters.items():
267
+ if name in overrides:
268
+ dependencies[name] = overrides[name]
269
+ elif param.annotation != inspect.Parameter.empty:
270
+ # Check if the type is primitive
271
+ if isinstance(param.annotation, type):
272
+ # It is a primitive type like str, int, etc.
273
+ dependencies[name] = param.default if param.default != inspect.Parameter.empty else param.annotation()
274
+ else:
275
+ dependencies[name] = self.make(param.annotation.__name__)
276
+ elif param.default != inspect.Parameter.empty:
277
+ dependencies[name] = param.default
278
+ else:
279
+ raise OrionisContainerValueError(f"Cannot resolve parameter '{name}' in method '{method_name}'")
280
+
281
+ return method(**dependencies)
282
+
283
+
284
+ def _primitiveTypeValidator(self, abstract: str) -> None:
285
+ """Validates that the abstract name is not a primitive type.
286
+
287
+ Args:
288
+ abstract (str): Name of the service to validate.
289
+
290
+ Raises:
291
+ OrionisContainerException: If the service name matches a primitive type.
292
+ """
293
+ if self._primitive_types_validator.isPrimitive(abstract):
294
+ raise OrionisContainerException(f"Cannot register a service with a name equal to a primitive type: '{abstract}'.")
295
+
217
296
  def _resolve(self, concrete: Callable[..., Any]):
218
297
  """Automatically resolves the dependencies of a service, handling its constructor dependencies.
219
298
 
@@ -242,25 +321,31 @@ class Container:
242
321
  if name == "self" or param.kind in (param.VAR_POSITIONAL, param.VAR_KEYWORD):
243
322
  continue
244
323
 
245
- # If the parameter has a default value, use it directly
246
324
  param_type = param.annotation
247
325
 
248
- # If the parameter type is not specified, try to resolve it by name
326
+ # If the parameter has a default value, use it directly
249
327
  if param_type == param.empty:
250
328
  if param.default != param.empty:
251
329
  # Use the default value if available
330
+ dependencies[name] = param.default
252
331
  continue
332
+ else:
333
+ raise OrionisContainerValueError(f"Parameter type {name} not specified in {concrete.__name__}")
253
334
 
254
- raise OrionisContainerValueError(f"Parameter type {name} not specified in {concrete.__name__}")
255
-
256
- # If the parameter type is a primitive, use it directly
257
- dep_name = param_type.__name__
258
-
259
- # Conditional resolution of dependencies, if registered
260
- if concrete in self._conditional_bindings and dep_name in self._conditional_bindings[concrete]:
261
- dependencies[name] = self.make(self._conditional_bindings[concrete][dep_name])
335
+ # If the parameter type is a primitive (str, int, etc.), pass it as is
336
+ if isinstance(param_type, type):
337
+ if param.default != param.empty:
338
+ dependencies[name] = param.default if param.default != param.empty else param_type()
339
+ else:
340
+ dependencies[name] = param_type() # Provide default value for primitive types if not specified
262
341
  else:
263
- dependencies[name] = self.make(dep_name)
342
+ dep_name = param_type.__name__
343
+
344
+ # Conditional resolution of dependencies, if registered
345
+ if concrete in self._conditional_bindings and dep_name in self._conditional_bindings[concrete]:
346
+ dependencies[name] = self.make(self._conditional_bindings[concrete][dep_name])
347
+ else:
348
+ dependencies[name] = self.make(dep_name)
264
349
 
265
350
  return concrete(**dependencies)
266
351
 
@@ -0,0 +1,25 @@
1
+ from orionis.luminate.contracts.container.types_interface import ITypes
2
+
3
+ class Types(ITypes):
4
+ """A class that handles validation of primitive types to prevent registering services with primitive-type names."""
5
+
6
+ # A set of common primitive types in Python
7
+ _primitive_types = {
8
+ int, float, str, bool, bytes, type(None), complex,
9
+ list, tuple, dict, set, frozenset,
10
+ "int", "float", "str", "bool", "bytes", "None", "complex",
11
+ "list", "tuple", "dict", "set", "frozenset"
12
+ }
13
+
14
+ def isPrimitive(self, name: str) -> None:
15
+ """Checks if the provided name corresponds to a primitive type.
16
+
17
+ Args:
18
+ name (str): The name of the service or alias to check.
19
+
20
+ Raises:
21
+ OrionisContainerException: If the name matches a primitive type.
22
+ """
23
+ if name in self._primitive_types:
24
+ return True
25
+ return False
@@ -0,0 +1,152 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Any, Callable
3
+
4
+ class IContainer(ABC):
5
+ """Service container and dependency injection."""
6
+
7
+ @abstractmethod
8
+ def bind(self, abstract: str, concrete: Callable[..., Any]) -> None:
9
+ """Registers a service with a specific implementation.
10
+
11
+ Args:
12
+ abstract (str): Name or key of the service to register.
13
+ concrete (Callable[..., Any]): Concrete implementation of the service.
14
+
15
+ Raises:
16
+ OrionisContainerException: If the service is already registered.
17
+ TypeError: If the implementation is not a callable or instantiable class.
18
+ """
19
+ pass
20
+
21
+ @abstractmethod
22
+ def transient(self, abstract: str, concrete: Callable[..., Any]) -> None:
23
+ """Registers a service as Transient, creating a new instance on each request.
24
+
25
+ Args:
26
+ abstract (str): Name or key of the service to register.
27
+ concrete (Callable[..., Any]): Concrete implementation of the service.
28
+
29
+ Raises:
30
+ OrionisContainerException: If the service is already registered.
31
+ TypeError: If the implementation is not a callable or instantiable class.
32
+ """
33
+ pass
34
+
35
+ @abstractmethod
36
+ def singleton(self, abstract: str, concrete: Callable[..., Any]) -> None:
37
+ """Registers a service as Singleton, ensuring a single shared instance.
38
+
39
+ Args:
40
+ abstract (str): Name or key of the service to register.
41
+ concrete (Callable[..., Any]): Concrete implementation of the service.
42
+
43
+ Raises:
44
+ OrionisContainerException: If the service is already registered.
45
+ TypeError: If the implementation is not a callable or instantiable class.
46
+ """
47
+ pass
48
+
49
+ @abstractmethod
50
+ def scoped(self, abstract: str, concrete: Callable[..., Any]) -> None:
51
+ """Registers a service as Scoped, shared within the same request.
52
+
53
+ Args:
54
+ abstract (str): Name or key of the service to register.
55
+ concrete (Callable[..., Any]): Concrete implementation of the service.
56
+
57
+ Raises:
58
+ OrionisContainerException: If the service is already registered.
59
+ TypeError: If the implementation is not a callable or instantiable class.
60
+ """
61
+ pass
62
+
63
+ @abstractmethod
64
+ def instance(self, abstract: str, instance: Any) -> None:
65
+ """Registers a specific instance in the container, allowing it to be reused.
66
+
67
+ Args:
68
+ abstract (str): Name or key of the service to register.
69
+ instance (Any): Specific instance of the service to register.
70
+
71
+ Raises:
72
+ OrionisContainerException: If the instance is already registered.
73
+ ValueError: If the provided instance is of an unexpected or invalid type.
74
+ """
75
+ pass
76
+
77
+ @abstractmethod
78
+ def has(self, abstract: str) -> bool:
79
+ """Checks if a service is registered in the container.
80
+
81
+ Args:
82
+ abstract (str): Name or key of the service to check.
83
+
84
+ Returns:
85
+ bool: True if the service is registered, False otherwise.
86
+
87
+ Raises:
88
+ ValueError: If the service name (abstract) is not a valid string.
89
+ """
90
+ pass
91
+
92
+ @abstractmethod
93
+ def alias(self, abstract: str, alias: str) -> None:
94
+ """Creates an alias for a registered service, allowing access to the service using an alternative name.
95
+
96
+ Args:
97
+ abstract (str): Name or key of the original service.
98
+ alias (str): The alias to assign to the service.
99
+
100
+ Raises:
101
+ OrionisContainerException: If the original service is not registered.
102
+ ValueError: If the alias is not a valid string or is already in use.
103
+ """
104
+ pass
105
+
106
+ @abstractmethod
107
+ def make(self, abstract: str):
108
+ """Automatically resolves a dependency, handling instances, singletons, scoped, transients, and aliases.
109
+
110
+ This method resolves the dependencies of a service and handles the following service types:
111
+ 1. **Instances**: Returns a specific instance.
112
+ 2. **Singletons**: Returns the same unique instance each time.
113
+ 3. **Scoped**: Returns a shared instance within the same request.
114
+ 4. **Transients**: Creates a new instance each time.
115
+ 5. **Aliases**: Resolves an alias to the original service.
116
+
117
+ Args:
118
+ abstract (str): Name or key of the service to resolve.
119
+
120
+ Returns:
121
+ Any: The resolved instance or service.
122
+
123
+ Raises:
124
+ OrionisContainerException: If the service is not found.
125
+ """
126
+ pass
127
+
128
+ @abstractmethod
129
+ def call(self, instance: Any, method_name: str, **overrides):
130
+ """Llama a un método del objeto resolviendo automáticamente las dependencias registradas.
131
+
132
+ Args:
133
+ instance (Any): Instancia del objeto en el cual se ejecutará el método.
134
+ method_name (str): Nombre del método a llamar.
135
+ **overrides: Argumentos que se deben pasar manualmente en lugar de resolverlos automáticamente.
136
+
137
+ Returns:
138
+ Any: El resultado de ejecutar el método con las dependencias resueltas.
139
+
140
+ Raises:
141
+ AttributeError: Si el método no existe en la instancia.
142
+ """
143
+ pass
144
+
145
+ @abstractmethod
146
+ def startRequest(self):
147
+ """Starts a new request and clears the Scoped instances.
148
+
149
+ This method should be called at the beginning of each request to ensure that
150
+ scoped services do not persist between requests.
151
+ """
152
+ pass
@@ -0,0 +1,16 @@
1
+ from abc import ABC, abstractmethod
2
+
3
+ class ITypes(ABC):
4
+ """A class that handles validation of primitive types to prevent registering services with primitive-type names."""
5
+
6
+ @abstractmethod
7
+ def isPrimitive(self, name: str) -> None:
8
+ """Checks if the provided name corresponds to a primitive type.
9
+
10
+ Args:
11
+ name (str): The name of the service or alias to check.
12
+
13
+ Raises:
14
+ OrionisContainerException: If the name matches a primitive type.
15
+ """
16
+ pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: orionis
3
- Version: 0.8.0
3
+ Version: 0.9.0
4
4
  Summary: Orionis Framework – Elegant, Fast, and Powerful.
5
5
  Home-page: https://github.com/orionis-framework/framework
6
6
  Author: Raul Mauricio Uñate Castro
@@ -64,6 +64,7 @@ orionis/luminate/console/tasks/__init__.py
64
64
  orionis/luminate/console/tasks/scheduler.py
65
65
  orionis/luminate/container/container.py
66
66
  orionis/luminate/container/exception.py
67
+ orionis/luminate/container/types.py
67
68
  orionis/luminate/contracts/__init__.py
68
69
  orionis/luminate/contracts/bootstrap/parser_interface.py
69
70
  orionis/luminate/contracts/cache/__init__.py
@@ -86,6 +87,8 @@ orionis/luminate/contracts/console/register_interface.py
86
87
  orionis/luminate/contracts/console/runner_interface.py
87
88
  orionis/luminate/contracts/console/schedule_interface.py
88
89
  orionis/luminate/contracts/console/task_manager_interface.py
90
+ orionis/luminate/contracts/container/container_interface.py
91
+ orionis/luminate/contracts/container/types_interface.py
89
92
  orionis/luminate/contracts/facades/__init__.py
90
93
  orionis/luminate/contracts/facades/env_interface.py
91
94
  orionis/luminate/contracts/facades/log_interface.py
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes