/** * Travel Composer ("trips") routes — the dynamic-packaging envelope/component/ * requirement lifecycle. The `createTripsRoutes` factory is mounted on BOTH the * admin (`/v1/admin/...`) and public (`/v1/public/...`) surfaces by * `createTripsApiModule`; admin-only operations return 403 on the public * surface but are still documented on both (intentional — the same factory * produces both specs). * * Migrated to `@hono/zod-openapi` for the OpenAPI admin backfill (voyant#2114 / * voyant#2208). Request schemas reuse the existing `validation.ts` schemas the * handlers already parse; response schemas are authored from the service return * types (§17: `Date`/timestamp columns serialize to strings over the wire). * Travel Composer results are deeply composed — the top-level envelope / * component / requirement / snapshot row shapes are modeled faithfully, while * deeply-nested composed/opaque sub-objects (pricing/candidate payloads, * frozen snapshot blobs) are documented pass-throughs typed as `z.unknown()`. * * The 20 legs are split across per-resource `OpenAPIHono` sub-chains * (envelopes / snapshots / components / requirements / lifecycle / health), * each composed onto the parent `OpenAPIHono` via `.route("/", subApp)`. * Mounting an `OpenAPIHono` child with `.route("/")` DOES propagate the child's * `.openapi()` registry definitions into the parent's generated spec (proven by * `commerce/src/pricing/routes-rules.ts` and `distribution/src/suppliers/routes.ts`), * so all trips operations still reach the composed operator OpenAPI document and * the emitted paths are unchanged. The split keeps per-chain type-inference cost * bounded — one flat multi-leg `.openapi()` chain has O(n²) inference cost and * OOMed CI's typecheck at its 8 GB heap. See voyant#2114 / voyant#2208. * * agent-quality: file-size exception — intentional: 20 Travel Composer legs * (envelope/snapshot/component/requirement CRUD + checkout/cancel lifecycle) * authored as `createRoute` objects co-located with their * handlers, grouped into per-resource `OpenAPIHono` sub-chains composed onto a * single parent. See voyant#2114 / voyant#2208. */ import { OpenAPIHono } from "@hono/zod-openapi"; import type { AnyDrizzleDb } from "@voyant-travel/db"; import type { Context } from "hono"; import { type CancelTripComponentsDeps, type StartCheckoutDeps } from "./service.js"; type Env = { Bindings: Record; Variables: { db: AnyDrizzleDb; organizationId?: string | null; }; }; export interface TripsRoutesOptions { surface?: "admin" | "public"; startCheckoutDeps?: TripsRouteDeps; cancelTripComponentsDeps?: TripsRouteDeps; } export type TripsRouteDeps = T | ((c: Context) => T | Promise | undefined); export type TripsRoutesOptionsProvider = () => TripsRoutesOptions | Promise; export type TripsRoutesOptionsInput = TripsRoutesOptions | TripsRoutesOptionsProvider; export declare function createTripsRoutes(options?: TripsRoutesOptionsInput): OpenAPIHono; export declare const tripsRoutes: OpenAPIHono; export type TripsRoutes = ReturnType; export {};