/** * Catalog-backed trip-component orchestration — owned by `@voyant-travel/trips`. * * Trips owns the reserve/checkout flow for catalog-backed components, so the * orchestration that turns a `TripComponent` into a catalog booking-engine * quote / cancellation lives here rather than in any deployment: * - offer validation (`quote`) + customer-facing tax recompute hand-off, * - fail-closed reservation while Catalog has no durable admitted command, * - hold release (compensation) + cancellation preview + cancel, * - checkout hand-off. * * WHY SOME PIECES ARE INJECTED (not imported): * * Trips depends acyclically on `@voyant-travel/catalog` (booking-engine) and * `@voyant-travel/bookings` (origin upsert), so those are imported directly. * Three things stay deployment-supplied and are injected via `options`: * * 1. The `SourceAdapterRegistry` / `OwnedBookingHandlerRegistry` — these are * process-local registries assembled from a deployment's installed source * adapters + owned vertical handlers. They live in the deployment. * 2. The promotion evaluator — `createCatalogPromotionEvaluator` lives in * `@voyant-travel/commerce`, and `commerce → quotes → trips` would make a * package cycle. So the evaluator is injected. * 3. The customer-facing tax recompute (`transformQuoteResult`) — the operator * resolves its own tax settings (a deployment reader) and the transform is * shared with the catalog-booking route module, so it stays in the * deployment and is injected. * 4. The checkout starter (`startCatalogCheckout`) — deployment-specific * payment-provider wiring. * * Catalog booking creation is intentionally unavailable. */ import { type CancelEntityResult, type OwnedBookingHandlerRegistry, type QuoteEntityDeps, type QuoteEntityResult, type QuoteResponseV1, type SourceAdapterRegistry } from "@voyant-travel/catalog/booking-engine"; import type { AnyDrizzleDb } from "@voyant-travel/db"; import type { CancelComponentInput, CancelComponentResult, CatalogComponentQuoteInput, ComponentCancellationPreview, ComponentCancellationPreviewInput, ComponentCheckoutInput, ComponentCheckoutResult, ReleaseReservedComponentInput, ReleaseReservedComponentResult, ReserveComponentInput, ReserveComponentResult } from "./service-types.js"; /** Per-request adapter context propagated to the catalog source adapters. */ export interface CatalogAdapterContext { connection_id: string; correlation_id: string; } /** Deployment-specific checkout hand-off for a reserved component. */ export type StartComponentCheckout = (input: ComponentCheckoutInput) => Promise; /** * Deployment-supplied, request-scoped readers + registries for the catalog * component adapter. These cross the boundaries trips must not import * statically (process-local registries, commerce promotions, the deployment's * tax recompute + checkout wiring) and so are injected. */ export interface CatalogComponentAdapterOptions { /** The per-request drizzle handle. */ db: AnyDrizzleDb; /** Process-local source-adapter registry (deployment-assembled). */ registry: SourceAdapterRegistry; /** Process-local owned-handler registry (deployment-assembled). */ ownedHandlers: OwnedBookingHandlerRegistry; /** * Promotion evaluator for the quote path. Injected because * `createCatalogPromotionEvaluator` lives in commerce, which transitively * (optionally) depends on quotes → trips. */ evaluatePromotions: QuoteEntityDeps["evaluatePromotions"]; /** * Customer-facing tax recompute applied to a quote result. Injected because * the deployment resolves its own tax settings (a deployment reader) and the * transform is shared with the catalog-booking route module. */ transformQuoteResult: (result: QuoteEntityResult, entityModule: string, entityId: string, sourceKind: string) => Promise; /** Builds the per-request adapter context (correlation id, connection id). */ adapterContext: (connectionId: string | null | undefined) => CatalogAdapterContext; /** Deployment-specific checkout hand-off (payment-provider wiring). */ startCheckout: StartComponentCheckout; } /** The catalog component orchestration surface produced by the factory. */ export interface CatalogComponentAdapter { quote(input: CatalogComponentQuoteInput): Promise; reserve(input: ReserveComponentInput): Promise; release(input: ReleaseReservedComponentInput): Promise; previewCancellation(input: ComponentCancellationPreviewInput): Promise; cancel(input: CancelComponentInput): Promise; startCheckout(input: ComponentCheckoutInput): Promise; } /** * Build the catalog-backed trip-component orchestration bound to a request's * db + deployment registries/readers. */ export declare function createCatalogComponentAdapter(options: CatalogComponentAdapterOptions): CatalogComponentAdapter; /** * Pure catalog-component cancellation preview. Has no db / registry reads — * supplier cancellation previews aren't available, so the cancellation result * itself is authoritative. Exported standalone so deployments can preview * without constructing a request-scoped adapter. */ export declare function previewCancellation(input: ComponentCancellationPreviewInput): Promise; export type { CancelEntityResult };