orionis 0.579.0__py3-none-any.whl → 0.581.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.
- orionis/console/core/reactor.py +5 -5
- orionis/console/kernel.py +2 -2
- orionis/console/tasks/schedule.py +2 -2
- orionis/container/container.py +6 -11
- orionis/container/exceptions/__init__.py +4 -4
- orionis/foundation/application.py +116 -91
- orionis/foundation/config/database/entities/sqlite.py +1 -1
- orionis/foundation/config/roots/paths.py +8 -0
- orionis/foundation/config/startup.py +1 -1
- orionis/foundation/config/testing/entities/testing.py +0 -14
- orionis/foundation/contracts/application.py +4 -4
- orionis/foundation/exceptions/__init__.py +6 -4
- orionis/foundation/exceptions/application.py +11 -0
- orionis/foundation/providers/catch_provider.py +1 -1
- orionis/foundation/providers/cli_request_provider.py +1 -1
- orionis/foundation/providers/console_provider.py +1 -1
- orionis/foundation/providers/directory_provider.py +1 -1
- orionis/foundation/providers/dumper_provider.py +1 -1
- orionis/foundation/providers/executor_provider.py +1 -1
- orionis/foundation/providers/inspirational_provider.py +1 -1
- orionis/foundation/providers/logger_provider.py +1 -1
- orionis/foundation/providers/performance_counter_provider.py +1 -1
- orionis/foundation/providers/progress_bar_provider.py +1 -1
- orionis/foundation/providers/reactor_provider.py +1 -2
- orionis/foundation/providers/scheduler_provider.py +1 -1
- orionis/foundation/providers/testing_provider.py +1 -1
- orionis/foundation/providers/workers_provider.py +1 -1
- orionis/metadata/framework.py +1 -1
- orionis/services/asynchrony/exceptions/__init__.py +1 -1
- orionis/services/asynchrony/exceptions/asynchrony.py +11 -0
- orionis/services/environment/core/dot_env.py +3 -2
- orionis/services/environment/dynamic/caster.py +8 -8
- orionis/services/environment/exceptions/__init__.py +11 -3
- orionis/services/environment/exceptions/environment.py +125 -0
- orionis/services/environment/key/key_generator.py +25 -21
- orionis/services/environment/validators/key_name.py +1 -1
- orionis/services/environment/validators/types.py +1 -1
- orionis/services/file/contracts/directory.py +12 -0
- orionis/services/file/directory.py +12 -1
- orionis/services/introspection/dataclass/{attributes.py → extractor.py} +2 -2
- orionis/services/introspection/exceptions/__init__.py +5 -3
- orionis/services/introspection/exceptions/introspection.py +76 -0
- orionis/services/log/exceptions/__init__.py +1 -1
- orionis/support/facades/application.py +3 -2
- orionis/support/facades/console.py +3 -2
- orionis/support/facades/directory.py +3 -2
- orionis/support/facades/dumper.py +3 -2
- orionis/support/facades/executor.py +3 -2
- orionis/support/facades/inspire.py +3 -2
- orionis/support/facades/logger.py +3 -2
- orionis/support/facades/performance_counter.py +3 -2
- orionis/support/facades/progress_bar.py +3 -2
- orionis/support/facades/reactor.py +3 -2
- orionis/support/facades/testing.py +3 -2
- orionis/support/facades/workers.py +5 -4
- orionis/support/standard/exceptions/__init__.py +1 -1
- orionis/support/standard/exceptions/standard.py +23 -0
- orionis/test/core/unit_test.py +10 -1
- orionis/test/kernel.py +22 -20
- orionis/test/output/printer.py +37 -9
- {orionis-0.579.0.dist-info → orionis-0.581.0.dist-info}/METADATA +1 -1
- {orionis-0.579.0.dist-info → orionis-0.581.0.dist-info}/RECORD +67 -73
- orionis/foundation/exceptions/integrity.py +0 -19
- orionis/foundation/exceptions/runtime.py +0 -19
- orionis/foundation/exceptions/type.py +0 -19
- orionis/foundation/exceptions/value.py +0 -19
- orionis/services/asynchrony/exceptions/exception.py +0 -27
- orionis/services/environment/exceptions/exception.py +0 -23
- orionis/services/environment/exceptions/value.py +0 -23
- orionis/services/introspection/exceptions/attribute.py +0 -20
- orionis/services/introspection/exceptions/type.py +0 -19
- orionis/services/introspection/exceptions/value.py +0 -19
- orionis/support/standard/exceptions/value.py +0 -19
- /orionis/container/exceptions/{container_exceptions.py → container.py} +0 -0
- /orionis/services/log/exceptions/{runtime.py → log.py} +0 -0
- {orionis-0.579.0.dist-info → orionis-0.581.0.dist-info}/WHEEL +0 -0
- {orionis-0.579.0.dist-info → orionis-0.581.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.579.0.dist-info → orionis-0.581.0.dist-info}/top_level.txt +0 -0
@@ -692,7 +692,7 @@ class IApplication(IContainer):
|
|
692
692
|
@abstractmethod
|
693
693
|
def setBasePath(
|
694
694
|
self,
|
695
|
-
basePath:
|
695
|
+
basePath: Path
|
696
696
|
) -> 'IApplication':
|
697
697
|
"""
|
698
698
|
Set the base path for the application.
|
@@ -703,7 +703,7 @@ class IApplication(IContainer):
|
|
703
703
|
|
704
704
|
Parameters
|
705
705
|
----------
|
706
|
-
basePath :
|
706
|
+
basePath : Path
|
707
707
|
The base path to set for the application. It can be a string or a Path object.
|
708
708
|
|
709
709
|
Returns
|
@@ -716,7 +716,7 @@ class IApplication(IContainer):
|
|
716
716
|
@abstractmethod
|
717
717
|
def getBasePath(
|
718
718
|
self
|
719
|
-
) ->
|
719
|
+
) -> Path:
|
720
720
|
"""
|
721
721
|
Get the base path of the application.
|
722
722
|
|
@@ -725,7 +725,7 @@ class IApplication(IContainer):
|
|
725
725
|
|
726
726
|
Returns
|
727
727
|
-------
|
728
|
-
|
728
|
+
Path
|
729
729
|
The base path of the application as a string or Path object, or None if not set.
|
730
730
|
"""
|
731
731
|
pass
|
@@ -1,7 +1,9 @@
|
|
1
|
-
from .
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
from .application import (
|
2
|
+
OrionisIntegrityException,
|
3
|
+
OrionisValueError,
|
4
|
+
OrionisTypeError,
|
5
|
+
OrionisRuntimeError
|
6
|
+
)
|
5
7
|
|
6
8
|
__all__ = [
|
7
9
|
"OrionisIntegrityException",
|
@@ -30,7 +30,7 @@ class CathcProvider(ServiceProvider):
|
|
30
30
|
"""
|
31
31
|
|
32
32
|
# Bind ICatch to Catch as a singleton with a specific alias
|
33
|
-
self.app.singleton(ICatch, Catch, alias="x-
|
33
|
+
self.app.singleton(ICatch, Catch, alias=f"x-{ICatch.__module__}.{ICatch.__name__}")
|
34
34
|
|
35
35
|
def boot(self) -> None:
|
36
36
|
"""
|
@@ -25,7 +25,7 @@ class CLRequestProvider(ServiceProvider):
|
|
25
25
|
"""
|
26
26
|
# Register CLIRequest as a transient service bound to ICLIRequest interface
|
27
27
|
# Transient services create a new instance each time they are resolved
|
28
|
-
self.app.transient(ICLIRequest, CLIRequest, alias="x-
|
28
|
+
self.app.transient(ICLIRequest, CLIRequest, alias=f"x-{ICLIRequest.__module__}.{ICLIRequest.__name__}")
|
29
29
|
|
30
30
|
def boot(self) -> None:
|
31
31
|
"""
|
@@ -37,7 +37,7 @@ class ConsoleProvider(ServiceProvider):
|
|
37
37
|
modifying the application's service container.
|
38
38
|
"""
|
39
39
|
|
40
|
-
self.app.transient(IConsole, Console, alias="x-
|
40
|
+
self.app.transient(IConsole, Console, alias=f"x-{IConsole.__module__}.{IConsole.__name__}")
|
41
41
|
|
42
42
|
def boot(self) -> None:
|
43
43
|
"""
|
@@ -37,7 +37,7 @@ class DirectoryProvider(ServiceProvider):
|
|
37
37
|
This method does not return any value.
|
38
38
|
"""
|
39
39
|
# Bind IDirectory to Directory as a singleton with a specific alias
|
40
|
-
self.app.singleton(IDirectory, Directory, alias="x-
|
40
|
+
self.app.singleton(IDirectory, Directory, alias=f"x-{IDirectory.__module__}.{IDirectory.__name__}")
|
41
41
|
|
42
42
|
def boot(self) -> None:
|
43
43
|
"""
|
@@ -54,7 +54,7 @@ class DumperProvider(ServiceProvider):
|
|
54
54
|
modifying the application container's service registry.
|
55
55
|
"""
|
56
56
|
|
57
|
-
self.app.transient(IDebug, Debug, alias="x-
|
57
|
+
self.app.transient(IDebug, Debug, alias=f"x-{IDebug.__module__}.{IDebug.__name__}")
|
58
58
|
|
59
59
|
def boot(self) -> None:
|
60
60
|
"""
|
@@ -54,7 +54,7 @@ class ConsoleExecuteProvider(ServiceProvider):
|
|
54
54
|
registering the executor service binding in the application container.
|
55
55
|
"""
|
56
56
|
|
57
|
-
self.app.transient(IExecutor, Executor, alias="x-
|
57
|
+
self.app.transient(IExecutor, Executor, alias=f"x-{IExecutor.__module__}.{IExecutor.__name__}")
|
58
58
|
|
59
59
|
def boot(self) -> None:
|
60
60
|
"""
|
@@ -50,7 +50,7 @@ class InspirationalProvider(ServiceProvider):
|
|
50
50
|
return any value.
|
51
51
|
"""
|
52
52
|
|
53
|
-
self.app.transient(IInspire, Inspire, alias="x-
|
53
|
+
self.app.transient(IInspire, Inspire, alias=f"x-{IInspire.__module__}.{IInspire.__name__}")
|
54
54
|
|
55
55
|
def boot(self) -> None:
|
56
56
|
"""
|
@@ -54,7 +54,7 @@ class LoggerProvider(ServiceProvider):
|
|
54
54
|
logger_service = Logger(logging_config)
|
55
55
|
|
56
56
|
# Register the service instance in the container with interface binding and alias
|
57
|
-
self.app.instance(ILogger, logger_service, alias="x-
|
57
|
+
self.app.instance(ILogger, logger_service, alias=f"x-{ILogger.__module__}.{ILogger.__name__}")
|
58
58
|
|
59
59
|
def boot(self) -> None:
|
60
60
|
"""
|
@@ -34,7 +34,7 @@ class PerformanceCounterProvider(ServiceProvider):
|
|
34
34
|
|
35
35
|
# Register the IPerformanceCounter interface to the PerformanceCounter implementation
|
36
36
|
# with a transient lifetime and assign an alias for alternative resolution.
|
37
|
-
self.app.transient(IPerformanceCounter, PerformanceCounter, alias="x-
|
37
|
+
self.app.transient(IPerformanceCounter, PerformanceCounter, alias=f"x-{IPerformanceCounter.__module__}.{IPerformanceCounter.__name__}")
|
38
38
|
|
39
39
|
def boot(self) -> None:
|
40
40
|
"""
|
@@ -58,7 +58,7 @@ class ProgressBarProvider(ServiceProvider):
|
|
58
58
|
as a side effect on the application container.
|
59
59
|
"""
|
60
60
|
|
61
|
-
self.app.transient(IProgressBar, ProgressBar, alias="x-
|
61
|
+
self.app.transient(IProgressBar, ProgressBar, alias=f"x-{IProgressBar.__module__}.{IProgressBar.__name__}")
|
62
62
|
|
63
63
|
def boot(self) -> None:
|
64
64
|
"""
|
@@ -57,8 +57,7 @@ class ReactorProvider(ServiceProvider):
|
|
57
57
|
|
58
58
|
# Register the Reactor service with the application container
|
59
59
|
# as a singleton, allowing it to be resolved throughout the application lifecycle
|
60
|
-
self.app.singleton(IReactor, Reactor, alias="x-
|
61
|
-
|
60
|
+
self.app.singleton(IReactor, Reactor, alias=f"x-{IReactor.__module__}.{IReactor.__name__}")
|
62
61
|
def boot(self) -> None:
|
63
62
|
"""
|
64
63
|
Perform post-registration initialization for the reactor management service.
|
@@ -33,7 +33,7 @@ class ScheduleProvider(ServiceProvider):
|
|
33
33
|
This method does not return any value.
|
34
34
|
"""
|
35
35
|
# Bind Scheduler as a singleton to the ISchedule interface with an alias
|
36
|
-
self.app.singleton(ISchedule, Schedule, alias="x-
|
36
|
+
self.app.singleton(ISchedule, Schedule, alias=f"x-{ISchedule.__module__}.{ISchedule.__name__}")
|
37
37
|
|
38
38
|
def boot(self) -> None:
|
39
39
|
"""
|
@@ -59,7 +59,7 @@ class TestingProvider(ServiceProvider):
|
|
59
59
|
|
60
60
|
# Register the UnitTest service as a singleton in the application container.
|
61
61
|
# The service is bound to the IUnitTest interface and can be resolved using the alias.
|
62
|
-
self.app.singleton(IUnitTest, UnitTest, alias="x-
|
62
|
+
self.app.singleton(IUnitTest, UnitTest, alias=f"x-{IUnitTest.__module__}.{IUnitTest.__name__}")
|
63
63
|
|
64
64
|
def boot(self) -> None:
|
65
65
|
"""
|
@@ -57,7 +57,7 @@ class WorkersProvider(ServiceProvider):
|
|
57
57
|
- Suitable for stateless or short-lived worker operations
|
58
58
|
"""
|
59
59
|
|
60
|
-
self.app.transient(IWorkers, Workers, alias="x-
|
60
|
+
self.app.transient(IWorkers, Workers, alias=f"x-{IWorkers.__module__}.{IWorkers.__name__}")
|
61
61
|
|
62
62
|
def boot(self) -> None:
|
63
63
|
"""
|
orionis/metadata/framework.py
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
class OrionisCoroutineException(Exception):
|
2
|
+
"""
|
3
|
+
Exception raised for errors that occur within Orionis coroutines.
|
4
|
+
|
5
|
+
This exception serves as a base for coroutine-related errors in the Orionis framework,
|
6
|
+
allowing for more specific exception handling in asynchronous operations.
|
7
|
+
|
8
|
+
Attributes:
|
9
|
+
message (str): Optional error message describing the exception.
|
10
|
+
"""
|
11
|
+
pass
|
@@ -5,6 +5,7 @@ from pathlib import Path
|
|
5
5
|
from typing import Any, Optional, Union
|
6
6
|
from dotenv import dotenv_values, load_dotenv, set_key, unset_key
|
7
7
|
from orionis.services.environment.enums import EnvironmentValueType
|
8
|
+
from orionis.services.environment.exceptions.environment import OrionisEnvironmentException, OrionisOperatingSystemError
|
8
9
|
from orionis.services.environment.validators import ValidateKeyName, ValidateTypes
|
9
10
|
from orionis.support.patterns.singleton import Singleton
|
10
11
|
from orionis.services.environment.dynamic.caster import EnvironmentCaster
|
@@ -59,12 +60,12 @@ class DotEnv(metaclass=Singleton):
|
|
59
60
|
except OSError as e:
|
60
61
|
|
61
62
|
# Raise an error if the .env file cannot be created or accessed
|
62
|
-
raise
|
63
|
+
raise OrionisOperatingSystemError(f"Failed to create or access the .env file at {self.__resolved_path}: {e}")
|
63
64
|
|
64
65
|
except Exception as e:
|
65
66
|
|
66
67
|
# Raise a general error for any other exceptions during initialization
|
67
|
-
raise
|
68
|
+
raise OrionisEnvironmentException(f"An unexpected error occurred while initializing DotEnv: {e}")
|
68
69
|
|
69
70
|
def set(
|
70
71
|
self,
|
@@ -658,12 +658,12 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
658
658
|
|
659
659
|
# Ensure the evaluated object is a list
|
660
660
|
if not isinstance(parsed, list):
|
661
|
-
raise
|
661
|
+
raise OrionisEnvironmentValueError("Value is not a list")
|
662
662
|
|
663
663
|
# Return the parsed list if successful
|
664
664
|
return parsed
|
665
665
|
|
666
|
-
except (ValueError, SyntaxError) as e:
|
666
|
+
except (OrionisEnvironmentValueError, ValueError, SyntaxError) as e:
|
667
667
|
|
668
668
|
# Raise a custom exception if conversion fails
|
669
669
|
raise OrionisEnvironmentValueException(f"Cannot convert '{value}' to list: {str(e)}")
|
@@ -735,12 +735,12 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
735
735
|
|
736
736
|
# Ensure the evaluated object is a dictionary
|
737
737
|
if not isinstance(parsed, dict):
|
738
|
-
raise
|
738
|
+
raise OrionisEnvironmentValueError("Value is not a dict")
|
739
739
|
|
740
740
|
# Return the parsed dictionary if successful
|
741
741
|
return parsed
|
742
742
|
|
743
|
-
except (ValueError, SyntaxError) as e:
|
743
|
+
except (OrionisEnvironmentValueError, ValueError, SyntaxError) as e:
|
744
744
|
|
745
745
|
# Raise a custom exception if conversion fails
|
746
746
|
raise OrionisEnvironmentValueException(f"Cannot convert '{value}' to dict: {str(e)}")
|
@@ -806,12 +806,12 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
806
806
|
|
807
807
|
# Ensure the evaluated object is a tuple
|
808
808
|
if not isinstance(parsed, tuple):
|
809
|
-
raise
|
809
|
+
raise OrionisEnvironmentValueError("Value is not a tuple")
|
810
810
|
|
811
811
|
# Return the parsed tuple if successful
|
812
812
|
return parsed
|
813
813
|
|
814
|
-
except (ValueError, SyntaxError) as e:
|
814
|
+
except (OrionisEnvironmentValueError, ValueError, SyntaxError) as e:
|
815
815
|
|
816
816
|
# Raise a custom exception if conversion fails
|
817
817
|
raise OrionisEnvironmentValueException(f"Cannot convert '{value}' to tuple: {str(e)}")
|
@@ -877,12 +877,12 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
877
877
|
|
878
878
|
# Ensure the evaluated object is a set
|
879
879
|
if not isinstance(parsed, set):
|
880
|
-
raise
|
880
|
+
raise OrionisEnvironmentValueError("Value is not a set")
|
881
881
|
|
882
882
|
# Return the parsed set if successful
|
883
883
|
return parsed
|
884
884
|
|
885
|
-
except (ValueError, SyntaxError) as e:
|
885
|
+
except (OrionisEnvironmentValueError, ValueError, SyntaxError) as e:
|
886
886
|
|
887
887
|
# Raise a custom exception if conversion fails
|
888
888
|
raise OrionisEnvironmentValueException(f"Cannot convert '{value}' to set: {str(e)}")
|
@@ -1,7 +1,15 @@
|
|
1
|
-
from .
|
2
|
-
|
1
|
+
from .environment import (
|
2
|
+
OrionisEnvironmentValueException,
|
3
|
+
OrionisEnvironmentValueError,
|
4
|
+
OrionisEnvironmentTypeException,
|
5
|
+
OrionisOperatingSystemError,
|
6
|
+
OrionisEnvironmentException
|
7
|
+
)
|
3
8
|
|
4
9
|
__all__ = [
|
5
10
|
"OrionisEnvironmentValueException",
|
6
|
-
"OrionisEnvironmentValueError"
|
11
|
+
"OrionisEnvironmentValueError",
|
12
|
+
"OrionisEnvironmentTypeException",
|
13
|
+
"OrionisOperatingSystemError",
|
14
|
+
"OrionisEnvironmentException"
|
7
15
|
]
|
@@ -0,0 +1,125 @@
|
|
1
|
+
class OrionisEnvironmentValueException(Exception):
|
2
|
+
"""
|
3
|
+
Exception raised for invalid or unexpected values in the Orionis environment configuration.
|
4
|
+
|
5
|
+
This exception is used to indicate that an environment variable or configuration setting
|
6
|
+
within the Orionis framework does not conform to the expected value constraints.
|
7
|
+
|
8
|
+
Parameters
|
9
|
+
----------
|
10
|
+
message : str, optional
|
11
|
+
Explanation of the error.
|
12
|
+
|
13
|
+
Returns
|
14
|
+
-------
|
15
|
+
OrionisEnvironmentValueException
|
16
|
+
An instance of this exception is raised when an invalid environment value is encountered.
|
17
|
+
|
18
|
+
Attributes
|
19
|
+
----------
|
20
|
+
message : str
|
21
|
+
Optional explanation of the error.
|
22
|
+
"""
|
23
|
+
# No additional implementation; inherits from Exception
|
24
|
+
pass
|
25
|
+
|
26
|
+
class OrionisEnvironmentTypeException(Exception):
|
27
|
+
"""
|
28
|
+
Exception raised for invalid or unsupported environment types in the Orionis framework.
|
29
|
+
|
30
|
+
This exception signals that an environment type provided to the framework is not recognized
|
31
|
+
or is not supported according to the framework's requirements.
|
32
|
+
|
33
|
+
Parameters
|
34
|
+
----------
|
35
|
+
message : str, optional
|
36
|
+
Description of the error.
|
37
|
+
|
38
|
+
Returns
|
39
|
+
-------
|
40
|
+
OrionisEnvironmentTypeException
|
41
|
+
An instance of this exception is raised when an invalid environment type is encountered.
|
42
|
+
|
43
|
+
Attributes
|
44
|
+
----------
|
45
|
+
message : str
|
46
|
+
Optional error message describing the exception.
|
47
|
+
"""
|
48
|
+
# No additional implementation; inherits from Exception
|
49
|
+
pass
|
50
|
+
|
51
|
+
class OrionisEnvironmentValueError(Exception):
|
52
|
+
"""
|
53
|
+
Exception raised when a value does not meet the required criteria in the Orionis environment configuration.
|
54
|
+
|
55
|
+
This exception is typically used to indicate that a provided value violates constraints or
|
56
|
+
requirements defined by the environment settings in the Orionis framework.
|
57
|
+
|
58
|
+
Parameters
|
59
|
+
----------
|
60
|
+
message : str, optional
|
61
|
+
Explanation of the error.
|
62
|
+
|
63
|
+
Returns
|
64
|
+
-------
|
65
|
+
OrionisEnvironmentValueError
|
66
|
+
An instance of this exception is raised when a value fails validation.
|
67
|
+
|
68
|
+
Attributes
|
69
|
+
----------
|
70
|
+
message : str
|
71
|
+
Optional explanation of the error.
|
72
|
+
"""
|
73
|
+
# No additional implementation; inherits from Exception
|
74
|
+
pass
|
75
|
+
|
76
|
+
class OrionisOperatingSystemError(OSError):
|
77
|
+
"""
|
78
|
+
Exception raised when a value or parameter in the Orionis environment configuration has an incorrect type.
|
79
|
+
|
80
|
+
This exception is used to signal that a provided value does not match the expected type as required by
|
81
|
+
the Orionis framework's environment settings, which may lead to misconfiguration or runtime errors.
|
82
|
+
|
83
|
+
Parameters
|
84
|
+
----------
|
85
|
+
message : str, optional
|
86
|
+
Description of the type mismatch error.
|
87
|
+
|
88
|
+
Returns
|
89
|
+
-------
|
90
|
+
OrionisOperatingSystemError
|
91
|
+
An instance of this exception is raised when a type mismatch is detected in the environment configuration.
|
92
|
+
|
93
|
+
Attributes
|
94
|
+
----------
|
95
|
+
message : str
|
96
|
+
Optional error message describing the exception.
|
97
|
+
"""
|
98
|
+
# No additional implementation; inherits from OSError
|
99
|
+
pass
|
100
|
+
|
101
|
+
class OrionisEnvironmentException(Exception):
|
102
|
+
"""
|
103
|
+
General exception for errors related to the Orionis environment configuration.
|
104
|
+
|
105
|
+
This exception serves as a base class for more specific environment-related exceptions
|
106
|
+
within the Orionis framework. It can be used to catch all environment-related errors
|
107
|
+
in a single exception handler.
|
108
|
+
|
109
|
+
Parameters
|
110
|
+
----------
|
111
|
+
message : str, optional
|
112
|
+
Description of the error.
|
113
|
+
|
114
|
+
Returns
|
115
|
+
-------
|
116
|
+
OrionisEnvironmentException
|
117
|
+
An instance of this exception is raised for general environment-related errors.
|
118
|
+
|
119
|
+
Attributes
|
120
|
+
----------
|
121
|
+
message : str
|
122
|
+
Optional error message describing the exception.
|
123
|
+
"""
|
124
|
+
# No additional implementation; inherits from Exception
|
125
|
+
pass
|
@@ -1,29 +1,25 @@
|
|
1
1
|
import os
|
2
2
|
import base64
|
3
|
+
from orionis.foundation.config.app.enums.ciphers import Cipher
|
3
4
|
|
4
5
|
class SecureKeyGenerator:
|
5
|
-
"""
|
6
|
-
Utility class for generating Laravel-compatible APP_KEY values.
|
7
|
-
|
8
|
-
Laravel expects keys in Base64 format, prefixed with 'base64:'.
|
9
|
-
Supported ciphers: AES-128-CBC, AES-256-CBC, AES-128-GCM, AES-256-GCM.
|
10
|
-
"""
|
11
6
|
|
7
|
+
# Mapping of cipher modes to their respective key sizes in bytes
|
12
8
|
KEY_SIZES = {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
9
|
+
Cipher.AES_128_CBC: 16,
|
10
|
+
Cipher.AES_256_CBC: 32,
|
11
|
+
Cipher.AES_128_GCM: 16,
|
12
|
+
Cipher.AES_256_GCM: 32
|
17
13
|
}
|
18
14
|
|
19
15
|
@staticmethod
|
20
|
-
def generate(cipher: str =
|
16
|
+
def generate(cipher: str | Cipher = Cipher.AES_256_CBC) -> str:
|
21
17
|
"""
|
22
18
|
Generate a Laravel-compatible APP_KEY.
|
23
19
|
|
24
20
|
Parameters
|
25
21
|
----------
|
26
|
-
cipher : str
|
22
|
+
cipher : str | Cipher
|
27
23
|
The cipher algorithm. Options: AES-128-CBC, AES-256-CBC,
|
28
24
|
AES-128-GCM, AES-256-GCM. Default is AES-256-CBC.
|
29
25
|
|
@@ -32,16 +28,24 @@ class SecureKeyGenerator:
|
|
32
28
|
str
|
33
29
|
A string formatted like Laravel's APP_KEY (e.g., base64:xxxx).
|
34
30
|
"""
|
35
|
-
|
31
|
+
# Normalize cipher input to Cipher enum if string is provided
|
32
|
+
if isinstance(cipher, str):
|
33
|
+
try:
|
34
|
+
cipher_enum = Cipher(cipher)
|
35
|
+
except ValueError:
|
36
|
+
raise ValueError(
|
37
|
+
f"Cipher '{cipher}' is not supported. "
|
38
|
+
f"Options: {', '.join(c.value for c in SecureKeyGenerator.KEY_SIZES.keys())}"
|
39
|
+
)
|
40
|
+
else:
|
41
|
+
cipher_enum = cipher
|
42
|
+
|
43
|
+
if cipher_enum not in SecureKeyGenerator.KEY_SIZES:
|
36
44
|
raise ValueError(
|
37
|
-
f"Cipher '{
|
38
|
-
f"
|
45
|
+
f"Cipher '{cipher_enum}' is not supported. "
|
46
|
+
f"Options: {', '.join(c.value for c in SecureKeyGenerator.KEY_SIZES.keys())}"
|
39
47
|
)
|
40
48
|
|
41
|
-
key_length = SecureKeyGenerator.KEY_SIZES[
|
42
|
-
|
43
|
-
# Generate secure random bytes
|
49
|
+
key_length = SecureKeyGenerator.KEY_SIZES[cipher_enum]
|
44
50
|
key = os.urandom(key_length)
|
45
|
-
|
46
|
-
# Encode in Base64 and prepend 'base64:'
|
47
|
-
return "base64:" + base64.b64encode(key).decode("utf-8")
|
51
|
+
return f"base64:{base64.b64encode(key).decode('utf-8')}"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from typing import Union
|
2
2
|
from orionis.services.environment.enums.value_type import EnvironmentValueType
|
3
|
-
from orionis.services.environment.exceptions
|
3
|
+
from orionis.services.environment.exceptions import OrionisEnvironmentValueError
|
4
4
|
|
5
5
|
class __ValidateTypes:
|
6
6
|
|
@@ -349,4 +349,16 @@ class IDirectory(ABC):
|
|
349
349
|
Path
|
350
350
|
The path to the storage directory.
|
351
351
|
"""
|
352
|
+
pass
|
353
|
+
|
354
|
+
@abstractmethod
|
355
|
+
def tests(self) -> Path:
|
356
|
+
"""
|
357
|
+
Get the tests directory path.
|
358
|
+
|
359
|
+
Returns
|
360
|
+
-------
|
361
|
+
Path
|
362
|
+
The path to the tests directory.
|
363
|
+
"""
|
352
364
|
pass
|
@@ -343,4 +343,15 @@ class Directory(IDirectory):
|
|
343
343
|
Path
|
344
344
|
The path to the storage directory.
|
345
345
|
"""
|
346
|
-
return Path(self.__app.path('storage'))
|
346
|
+
return Path(self.__app.path('storage'))
|
347
|
+
|
348
|
+
def tests(self) -> Path:
|
349
|
+
"""
|
350
|
+
Get the tests directory path.
|
351
|
+
|
352
|
+
Returns
|
353
|
+
-------
|
354
|
+
Path
|
355
|
+
The path to the tests directory.
|
356
|
+
"""
|
357
|
+
return Path(self.__app.path('tests'))
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class DataclassInspector:
|
2
2
|
|
3
3
|
def __call__(self, dataclass_type: type) -> dict:
|
4
4
|
"""
|
@@ -42,4 +42,4 @@ class DataclassValues:
|
|
42
42
|
raise TypeError("The provided argument is not a valid dataclass type.")
|
43
43
|
|
44
44
|
# Instantiate the DataclassValues callable
|
45
|
-
|
45
|
+
extractor = DataclassInspector()
|
@@ -1,6 +1,8 @@
|
|
1
|
-
from .
|
2
|
-
|
3
|
-
|
1
|
+
from .introspection import (
|
2
|
+
ReflectionAttributeError,
|
3
|
+
ReflectionValueError,
|
4
|
+
ReflectionTypeError
|
5
|
+
)
|
4
6
|
|
5
7
|
__all__ = [
|
6
8
|
"ReflectionValueError",
|