shared: implementazione package identity
Continuous Integration / Quality Assurance (push) Canceled after 0s

This commit is contained in:
2026-08-06 17:01:45 +02:00
parent 3bf84e4163
commit 575deedaa2
18 changed files with 718 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
"""
SMAVS Shared Kernel.
Provides shared components used across the framework.
"""
__all__: list[str] = []
+23
View File
@@ -0,0 +1,23 @@
"""
SMAVS Shared Kernel - Identity.
Provides the public interface for the identity package.
"""
from shared.identity.artifact_id import ArtifactId
from shared.identity.blueprint_id import BlueprintId
from shared.identity.execution_id import ExecutionId
from shared.identity.identifier import Identifier
from shared.identity.module_id import ModuleId
from shared.identity.request_id import RequestId
from shared.identity.session_id import SessionId
__all__ = [
"ArtifactId",
"BlueprintId",
"ExecutionId",
"Identifier",
"ModuleId",
"RequestId",
"SessionId",
]
+23
View File
@@ -0,0 +1,23 @@
"""
SMAVS Shared Kernel - Artifact Identifier.
Defines the unique identifier for an Artifact.
"""
from __future__ import annotations
from dataclasses import dataclass
from shared.identity.identifier import Identifier
__all__ = ["ArtifactId"]
@dataclass(frozen=True, slots=True)
class ArtifactId(Identifier):
"""
Unique identifier of an Artifact.
This identifier is used to uniquely identify an Artifact
within the SMAVS framework.
"""
+23
View File
@@ -0,0 +1,23 @@
"""
SMAVS Shared Kernel - Blueprint Identifier.
Defines the unique identifier for a Blueprint.
"""
from __future__ import annotations
from dataclasses import dataclass
from shared.identity.identifier import Identifier
__all__ = ["BlueprintId"]
@dataclass(frozen=True, slots=True)
class BlueprintId(Identifier):
"""
Unique identifier of a Blueprint.
This identifier is used to uniquely identify a Blueprint
within the SMAVS framework.
"""
+23
View File
@@ -0,0 +1,23 @@
"""
SMAVS Shared Kernel - Execution Identifier.
Defines the unique identifier for an Execution.
"""
from __future__ import annotations
from dataclasses import dataclass
from shared.identity.identifier import Identifier
__all__ = ["ExecutionId"]
@dataclass(frozen=True, slots=True)
class ExecutionId(Identifier):
"""
Unique identifier of an Execution.
This identifier is used to uniquely identify an Execution
within the SMAVS framework.
"""
+97
View File
@@ -0,0 +1,97 @@
"""
SMAVS Shared Kernel - Identifier
Defines the base Value Object used to uniquely identify every
domain element inside the framework.
All domain-specific identifiers inherit from this class.
"""
from __future__ import annotations
from dataclasses import dataclass
from uuid import UUID, uuid4
__all__ = ["Identifier"]
@dataclass(frozen=True, slots=True)
class Identifier:
"""
Base immutable identifier.
An Identifier represents the identity of a domain object.
Internally it stores a UUID while exposing a strongly typed
Value Object to the rest of the domain.
"""
value: UUID
@classmethod
def new(cls) -> Identifier:
"""
Create a new identifier.
Returns:
A newly generated identifier.
"""
return cls(uuid4())
@classmethod
def from_string(cls, value: str) -> Identifier:
"""
Create an identifier from its string representation.
Args:
value:
UUID string.
Returns:
The corresponding identifier.
Raises:
ValueError:
If the provided string is not a valid UUID.
"""
return cls(UUID(value))
@classmethod
def from_uuid(cls, value: UUID) -> Identifier:
"""
Create an identifier from an existing UUID.
Args:
value:
UUID instance.
Returns:
The corresponding identifier.
"""
return cls(value)
def __str__(self) -> str:
"""
Return the canonical string representation.
"""
return str(self.value)
def __repr__(self) -> str:
"""
Return the developer representation.
"""
return f"{self.__class__.__name__}('{self.value}')"
@property
def hex(self) -> str:
"""
Return the hexadecimal representation.
"""
return self.value.hex
@property
def urn(self) -> str:
"""
Return the UUID URN representation.
"""
return self.value.urn
+23
View File
@@ -0,0 +1,23 @@
"""
SMAVS Shared Kernel - Module Identifier.
Defines the unique identifier for a Module.
"""
from __future__ import annotations
from dataclasses import dataclass
from shared.identity.identifier import Identifier
__all__ = ["ModuleId"]
@dataclass(frozen=True, slots=True)
class ModuleId(Identifier):
"""
Unique identifier of a Module.
This identifier is used to uniquely identify a Module
within the SMAVS framework.
"""
+23
View File
@@ -0,0 +1,23 @@
"""
SMAVS Shared Kernel - Request Identifier.
Defines the unique identifier for a Request.
"""
from __future__ import annotations
from dataclasses import dataclass
from shared.identity.identifier import Identifier
__all__ = ["RequestId"]
@dataclass(frozen=True, slots=True)
class RequestId(Identifier):
"""
Unique identifier of a Request.
This identifier is used to uniquely identify a Request
within the SMAVS framework.
"""
+23
View File
@@ -0,0 +1,23 @@
"""
SMAVS Shared Kernel - Session Identifier.
Defines the unique identifier for a Session.
"""
from __future__ import annotations
from dataclasses import dataclass
from shared.identity.identifier import Identifier
__all__ = ["SessionId"]
@dataclass(frozen=True, slots=True)
class SessionId(Identifier):
"""
Unique identifier of a Session.
This identifier is used to uniquely identify a Session
within the SMAVS framework.
"""