import type { PostgresJsDatabase } from "drizzle-orm/postgres-js"; import { type SqlExecutor } from "./service-allocation-sql.js"; export declare function listAllocationResources(db: PostgresJsDatabase, slotId: string): Promise<{ id: string; slotId: string; kind: string; refType: string | null; refId: string | null; label: string | null; capacity: number; flags: Record; parentId: string | null; sortOrder: number; createdAt: Date; updatedAt: Date; }[]>; /** * Per-resource availability summary for a single slot: capacity, how * many travelers are currently assigned to that resource (across all * live bookings on the slot), and the resulting remaining headroom. * The summary is consumer-facing -- `assigned` is the same DISTINCT- * traveler count `countResourceOccupants` uses internally, so the * read-side and the per-traveler assignment guardrail agree. * * Returned in (kind, sortOrder, createdAt) order so consumers can * render rooming grids without resorting. */ export interface SlotResourceAvailability { id: string; slotId: string; kind: string; label: string | null; refType: string | null; refId: string | null; parentId: string | null; capacity: number; assigned: number; available: number; flags: Record; sortOrder: number; } export declare function getSlotResourceAvailability(db: PostgresJsDatabase, slotId: string): Promise; export declare function getSlotsResourceAvailability(db: PostgresJsDatabase, slotIds: string[]): Promise>; export interface PlannedAllocation { /** Traveler id whose allocation is being planned. */ travelerId: string; /** Resource kind, e.g. "room" or "vehicle_seat". */ kind: string; /** Resource id the traveler is being assigned to. */ resourceId: string; } export interface ResourceCapacityViolation { slotId: string; resourceId: string; kind: string; capacity: number; existingAssigned: number; requested: number; } /** * Validate that a batch of planned traveler->resource assignments fits * inside the per-resource capacity of the given slot. Read-only -- * callers run this before persisting so they can surface * `resource_capacity_exhausted` with the offending resource cited. * * Travelers in `planned` are deduped per (kind, resourceId) so the * caller can pass the full booking payload (one row per traveler) * without inflating the count. Existing usage already credited to a * traveler being re-planned is excluded so re-saving the same payload * is idempotent. */ export declare function validateSlotAllocationCapacity(db: PostgresJsDatabase, slotId: string, planned: PlannedAllocation[]): Promise; export declare function countResourceOccupants(db: SqlExecutor, slotId: string, kind: string, resourceId: string, excludeTravelerId?: string): Promise; export declare function clearTravelerAllocationsForResource(db: PostgresJsDatabase, resourceId: string): Promise;