cadrumo.application.storage.calc_sheets.export_service module¶
Application-layer orchestration for the Sheets calc-sheets export surface.
The workbook export completes inside the CLI handler, which called the outbound Google adapter directly with no application-layer function between them. That left the export surface with no legal place to persist last-sync provenance from: persisting at the entrypoint would make it the first CLI site writing to a secure-object namespace, and persisting from the adapter would have an outbound adapter reach back into application storage, inverting the dependency direction.
This module is that missing seam. export_modelo_to_sheets() builds the
plan, applies it through the outbound adapter, and records the completed run’s
provenance – on success AND on failure, because the write path RAISES rather
than returns, and a partial failure is exactly the state a reader most needs
to see.
See also
record_sync_run()The shared co-write primitive this module calls on both completion paths.
apply_export_plan()The outbound write this module wraps with provenance.
- export_modelo_to_sheets(plan, *, credentials, root_folder_id, sync_run_repository, apply_export_plan)[source]¶
Apply an already-built export plan to Sheets and record the run’s provenance.
Takes the plan already built by
build_export_plan()rather than building one itself: the CLI’s dry-run branch needs the SAME plan for its preview, and building it twice would let the two branches drift on what they describe. This function owns only the write-plus-provenance half.On a raised failure the run’s sync-run record is still persisted, with
succeeded=Falseand zero units reached, and the original exception is re-raised unchanged for the caller’s existing refusal handling.- Parameters:
plan (
SheetExportPlan) – TheSheetExportPlanto materialise.credentials (
object) – Google API credentials, forwarded toapply_export_planunchanged.root_folder_id (
str) – The operator’s Drive root folder id.sync_run_repository (
SyncRunRecordRepositoryProtocol) – Persistence port for the completed-run provenance record, co-written with its bucket event.apply_export_plan (
Callable[...,_CalcSheetsApplyResult]) – Outbound apply callable supplied by the composing entrypoint.
- Return type:
_CalcSheetsApplyResult- Returns:
The adapter’s
CalcSheetsApplyResult.- Raises:
Whatever apply_export_plan raises, – after the failed run’s provenance has been persisted.