Source code for aeat.application.filing._history_repository
"""Governed-persistence repository for filing-history records.This repository persists lightweight :class:`application.filing.ModeloHistory`payloads keyed by modelo. Each payload contains submitted modelos, typedperiods, timestamps, and recorded status strings; richer current /superseded filing lifecycle records live in:class:`domain.modelos.ModeloRecordCatalogue`.Records are stored as encrypted byte objects in the primary SQL backend at``AUDIT`` :class:`~adapters.persistence.storage.SensitivityClass` via a:class:`~adapters.persistence.storage.SecureObjectRepository`; noplaintext filing-history JSON or envelope file lands on disk.See Also: :class:`application.filing.ModeloHistory` Strict payload persisted by this repository. :mod:`application.filing._runtime_repository` Active-profile bucket resolution and runtime secure-object creation. :class:`domain.modelos.ModeloRecordCatalogueRepository` FINANCIAL-class repository for authoritative work-unit filing records. :data:`adapters.persistence.storage.APPLICATION_FILING_HISTORY_NAMESPACE` Namespace, sensitivity, schema-version, and object-key contract for these secure objects."""from__future__importannotationsfromcollections.abcimportIteratorfromtypingimportClassVar,overridefrompydanticimportBaseModelfrom...adapters.persistence.storageimport(APPLICATION_FILING_HISTORY_NAMESPACE,ClassificationError,EnvelopeVersionError,SecureBoundRepository,SecureObjectRepository,SensitivityClass,)from._history_modelsimportModeloHistoryfrom._runtime_repositoryimport(resolve_application_filing_bucket_id,secure_objects_for_application_filing_bucket,)
[docs]classModeloHistoryRepository(SecureBoundRepository[ModeloHistory]):"""Encrypted filing-history store for bucket-local :class:`ModeloHistory`. The :class:`~adapters.persistence.storage.SecureBoundRepository` base wraps each payload in an :class:`~adapters.persistence.storage.Envelope` and binds it to :data:`adapters.persistence.storage.APPLICATION_FILING_HISTORY_NAMESPACE`. The modelo identifier is the natural object key, so list and iteration APIs expose one lightweight history per modelo rather than the authoritative work-unit filing catalogue. The namespace definition supplies the ``AUDIT`` :class:`~adapters.persistence.storage.SensitivityClass`, schema version, bucket-local scope, ``{modelo}`` key grammar, and custody contract. See Also: :class:`ModeloHistory` Strict payload stored by this repository. :class:`domain.modelos.ModeloRecordCatalogueRepository` FINANCIAL-class filing-record catalogue for current and superseded work-unit lifecycle records. """namespace:ClassVar[str]=APPLICATION_FILING_HISTORY_NAMESPACE.namespacesensitivity:ClassVar[SensitivityClass]=APPLICATION_FILING_HISTORY_NAMESPACE.sensitivityschema_version:ClassVar[int]=APPLICATION_FILING_HISTORY_NAMESPACE.schema_versionpayload_type:ClassVar[type[BaseModel]]=ModeloHistorydef__init__(self,*,bucket_id:str|None=None,objects:SecureObjectRepository|None=None)->None:self._bucket_id=bucket_id.strip()ifbucket_idisnotNoneelseNoneifobjectsisNone:self._bucket_id=resolve_application_filing_bucket_id(bucket_id)objects=secure_objects_for_application_filing_bucket(self._bucket_id)super().__init__(objects=objects)@propertydefbucket_id(self)->str|None:"""Return the profile bucket id when this repository resolved one."""returnself._bucket_id
[docs]deflist_modelos(self)->tuple[str,...]:"""Return every modelo persisted in this repository, sorted."""returntuple(sorted(self.iter_ids()))
[docs]defiter_histories(self)->Iterator[tuple[str,ModeloHistory]]:"""Yield ``(modelo, history)`` tuples of :class:`ModeloHistory` for every persisted modelo."""forhistoryinself.iter_records():yieldstr(history.modelo),history