Source code for cadrumo.application.filing.draft_review_ports

"""Application-owned capabilities for draft approval and stale detection.

The draft-review lifecycle fingerprints several persisted authorities.  This
module keeps that use case independent from the encrypted-storage adapters and
gives composition roots one cohesive bundle to bind for a profile bucket.

Core types:
:class:`~cadrumo.domain.filing.schema.ModeloDraft`.
"""

from __future__ import annotations

from collections.abc import Iterator, Mapping
from dataclasses import dataclass
from pathlib import Path
from typing import Protocol

from ...domain.filing.schema import ModeloDraft
from ...domain.invoices.protocols import InvoiceCatalogueRepositoryProtocol
from ...domain.transactions.protocols import TransactionCatalogueRepositoryProtocol
from ..calculations.observations_repository import CalculationObservationRepositoryProtocol


[docs] class DraftReviewProfileRepositoryProtocol(Protocol): """Read-only profile projection used by the approval-basis fingerprint."""
[docs] def load_path_values(self, *, bucket_id: str) -> Mapping[str, str] | None: """Return canonical profile path values, or ``None`` when absent.""" ...
[docs] class DraftReviewDraftRepositoryProtocol(Protocol): """Read-only draft store capability used by the review queue."""
[docs] def iter_drafts(self) -> Iterator[ModeloDraft]: """Yield the bucket's persisted drafts.""" ...
[docs] def envelope_path_for(self, identifier: str) -> Path: """Return the non-secret logical path marker for one draft.""" ...
[docs] @dataclass(frozen=True, slots=True) class DraftReviewPorts: """Required persisted authorities for one draft-review invocation.""" transaction_repository: TransactionCatalogueRepositoryProtocol invoice_repository: InvoiceCatalogueRepositoryProtocol observation_repository: CalculationObservationRepositoryProtocol profile_repository: DraftReviewProfileRepositoryProtocol draft_repository: DraftReviewDraftRepositoryProtocol
[docs] class DraftReviewPortsFactory(Protocol): """Construct the draft-review authorities for one profile bucket.""" def __call__(self, *, bucket_id: str) -> DraftReviewPorts: """Return all capabilities required for ``bucket_id``.""" ...
__all__ = [ "DraftReviewDraftRepositoryProtocol", "DraftReviewPorts", "DraftReviewPortsFactory", "DraftReviewProfileRepositoryProtocol", ]