Source code for cadrumo.adapters.persistence.profile.justificante
"""Governed-persistence repository for parsed justificante metadata.Justificante metadata captures AEAT verification identifiers, operatoridentity, timestamps, and verification URLs. The structured metadata isstored as encrypted byte objects in the primary SQL backend at:class:`~core.classification.policies.SensitivityClass` ``AUDIT``sensitivity; no plaintext metadata JSON or envelope file lands on disk.This concrete repository is the persistence adapter for the:class:`~domain.justificante.schema.Justificante` audit-sink record. It lives inthe persistence adapter (not in :mod:`~domain.justificante`) because itsbase :class:`~adapters.persistence.storage.envelope.secure_bound_repository.SecureBoundRepository` isSQL/crypto-coupled; the domain package owns the pure record and the:class:`~domain.justificante.protocols.JustificanteRepositoryProtocol` port.See Also: :class:`~domain.justificante.schema.Justificante` Payload model encrypted by this repository. :class:`~adapters.persistence.storage.sql.secure_objects.SecureObjectRepository` SQL object store underlying the bound repository."""from__future__importannotationsfromcollections.abcimportIteratorfromtypingimportClassVar,overridefrom....core.classification.policiesimportSensitivityClassfrom....domain.justificante.schemaimportJustificantefrom..storage.envelope.secure_bound_repositoryimportSecureBoundRepositoryfrom..storage.secure_object_namespacesimportJUSTIFICANTE_METADATA_NAMESPACE
[docs]classJustificanteRepository(SecureBoundRepository[Justificante]):"""Encrypted AUDIT repository for :class:`Justificante` metadata. The :class:`~adapters.persistence.storage.envelope.secure_bound_repository.SecureBoundRepository` base stores each :class:`Justificante` in a :class:`~adapters.persistence.storage.envelope.contract.Envelope` row under the AUDIT justificante-metadata namespace. The AEAT CSV is the natural key, so list and iteration APIs expose persisted receipt metadata without reading plaintext metadata from disk. """namespace:ClassVar[str]=JUSTIFICANTE_METADATA_NAMESPACE.namespacesensitivity:ClassVar[SensitivityClass]=JUSTIFICANTE_METADATA_NAMESPACE.sensitivityschema_version:ClassVar[int]=JUSTIFICANTE_METADATA_NAMESPACE.schema_version
[docs]defiter_justificantes(self)->Iterator[Justificante]:"""Yield every persisted justificante, in lexicographic CSV order. Returns: Iterator over :class:`Justificante` records. """yield fromsorted(self.iter_records(),key=self.extract_identifier)