/** * SnapshotService — drizzle-bound capture and read of booking snapshot * graphs. * * One booking commit may produce multiple snapshot rows — one per * participating CatalogEntry (a TUI package booking captures the package, * the referenced hotel, each selected excursion, the chosen departure, the * selected flight). Snapshots are immutable once written and preserved * through source disconnection. * * Functions take an `AnyDrizzleDb` as their first parameter to match the * existing voyant convention. * * See `docs/architecture/catalog-architecture.md` §5.3 for the design. */ import type { CaptureSnapshotInput } from "@voyantjs/catalog-contracts/snapshot"; import type { AnyDrizzleDb } from "@voyantjs/db"; import type { ResolvedView } from "../overlay/resolver.js"; import { type PricingBasis, type SelectBookingCatalogSnapshot } from "../snapshot/schema.js"; export type { CaptureSnapshotInput }; /** * Capture a single booking-catalog-snapshot row. Idempotent on * `(booking_id, entity_module, entity_id)` — re-capturing the same entity * inside the same booking is a logic bug; this function lets the unique * constraint catch it rather than silently overwriting. */ export declare function captureSnapshot(db: AnyDrizzleDb, input: CaptureSnapshotInput): Promise; /** * Capture multiple snapshot rows for a single booking in one transaction. * Used by the booking-commit pipeline when a booking participates with * multiple CatalogEntries (composite packages, cruises with selected * cabins, flights with passengers). * * If any single capture fails, the whole transaction rolls back — the * booking's snapshot graph is all-or-nothing. */ export declare function captureSnapshotGraph(db: AnyDrizzleDb, bookingId: string, inputs: ReadonlyArray>): Promise; /** * Fetch all snapshot rows for a single booking. Returns the full snapshot * graph — one row per participating CatalogEntry. Used by refunds, audits, * post-book operations. */ export declare function fetchSnapshotsForBooking(db: AnyDrizzleDb, bookingId: string): Promise; /** * Fetch a specific entity's snapshot for a booking. Returns `null` if no * snapshot was captured for the entity. */ export declare function fetchEntitySnapshot(db: AnyDrizzleDb, bookingId: string, entityModule: string, entityId: string): Promise; /** * Converts a `ResolvedView`'s value Map into a plain object suitable for * storing as the JSONB `frozen_payload`. Field paths become keys. */ export declare function viewToFrozenPayload(view: ResolvedView): Record; /** * Converts a `ResolvedView`'s provenance Map into a plain object suitable * for storing as the JSONB `overlay_state_at_capture`. Records which * variant slice satisfied each overlayed field at capture time. Fields * with `null` provenance (no overlay applied) are omitted. */ export declare function viewToOverlayState(view: ResolvedView): Record; /** * Composition helper: turn a `ResolvedView` plus identity / provenance / * pricing context into a `CaptureSnapshotInput` ready to pass into * `captureSnapshot` or `captureSnapshotGraph`. * * Verticals' `buildXSnapshotInput` helpers wrap this with the vertical- * specific row fetching + resolution. */ export declare function buildSnapshotInputFromView(view: ResolvedView, context: { entityModule: string; entityId: string; sourceKind: string; sourceProvider?: string; sourceConnectionId?: string; sourceRef?: string; pricingBasis?: PricingBasis; }): Omit; //# sourceMappingURL=snapshot-service.d.ts.map