Source code for cadrumo.adapters.persistence.profile.notification_documents
"""The canonical secure repository for notification documents in custody.One definition, because two entrypoints need it. The CLI composes it to fetchand store documents behind a notificación; the TUI reads it to count what isalready in custody, which is how AEAT Sync tells "nothing has been pulled"apart from "nothing is there". Building it a second time in the TUI would putthe namespace, object key and two error factories in two places, and adivergence between them would be a read pointed at a store nothing writes."""from__future__importannotationsfromtypingimportTYPE_CHECKINGfrom....application.live.errorsimportLiveApplicationInputErrorfrom....application.live.notification_documentsimport(NotificationDocumentNotFoundError,NotificationDocumentRecord,notification_document_object_key,)from..storage.runtime_repositoryimportsecure_object_repository_for_bucketfrom..storage.secure_object_namespacesimportLIVE_NOTIFICATION_DOCUMENT_NAMESPACEfrom.snapshotsimportSecureSnapshotRepositoryifTYPE_CHECKING:from....core.configimportSettings
[docs]defnotification_document_repository(bucket_id:str,settings:Settings,)->SecureSnapshotRepository[NotificationDocumentRecord]:"""Return the secure repository holding one bucket's notification documents."""returnSecureSnapshotRepository(bucket_id=bucket_id,payload_model=NotificationDocumentRecord,namespace_definition=LIVE_NOTIFICATION_DOCUMENT_NAMESPACE,object_key=notification_document_object_key,not_found_factory=lambdacertificado_id:NotificationDocumentNotFoundError(translated_message="application.live.notifications.errors.document_not_found",context={"certificado_id":certificado_id},),ambiguous_prefix_factory=lambdacertificado_id,full_ids:NotificationDocumentNotFoundError(translated_message="application.live.notifications.errors.document_prefix_ambiguous",context={"certificado_id":certificado_id,"match_count":len(full_ids)},),domain_label="notification-document",input_error_cls=LiveApplicationInputError,objects=secure_object_repository_for_bucket(bucket_id,settings),)