@suaveplan/booking - Universal JSON-configurable booking engine: pluggable availability resolution, conflict detection, pricing pipeline, rule evaluation, configurable status state machine, typed event bus, in-package data-transform Hooks pipeline, six domain presets (seats, accommodation, appointments, resources, activities, transport), Zod validation schemas, and typed BookingError hierarchy with stable BOOKING.* code registry.
Universal, JSON-configurable booking engine with pluggable strategies for availability resolution, conflict detection, pricing calculation, and rule evaluation. Ships six built-in domain presets (seats, accommodation, appointments, resources, activities, transport), a configurable status state machine, a typed lifecycle event bus, an in-package Hooks<TMap> data-transform pipeline, Zod validation schemas, and a typed BookingError hierarchy.
Documentation tree
- resolver — Pluggable availability-resolver registry. The booking engine asks "is this window available?" by delegating to a strate…
- resolver — Pluggable availability-resolver registry. The booking engine asks "is this window available?" by delegating to a strate…
- strategies — Three built-in
AvailabilityStrategyFn implementations covering the three most common booking semantics: `exactMatchSt…
- strategies — Three built-in
AvailabilityStrategyFn implementations covering the three most common booking semantics: `exactMatchSt…
- detector — Provides the pluggable conflict-detection registry used by the booking engine to decide whether a proposed window colli…
- detector — Provides the pluggable conflict-detection registry used by the booking engine to decide whether a proposed window colli…
- exact-match — Conflict-detection strategy for seat-style bookings where two reservations conflict only when their start AND end times…
- exact-match — Conflict-detection strategy for seat-style bookings where two reservations conflict only when their start AND end times…
- provider-overlap — Conflict-detection strategy for appointment-style bookings where the constraint is "this provider's calendar." Used for…
- provider-overlap — Conflict-detection strategy for appointment-style bookings where the constraint is "this provider's calendar." Used for…
- range-overlap — Conflict-detection strategy for accommodation-style bookings where any temporal overlap counts as a conflict. Models ho…
- range-overlap — Conflict-detection strategy for accommodation-style bookings where any temporal overlap counts as a conflict. Models ho…
- slot-capacity — Conflict-detection strategy for group bookings — meeting rooms, tour groups, activity classes, anything where multiple…
- slot-capacity — Conflict-detection strategy for group bookings — meeting rooms, tour groups, activity classes, anything where multiple…
- engine —
BookingEngine is the booking system's pipeline orchestrator. It composes the registry of bookables, the persistent ma…
- engine —
BookingEngine is the booking system's pipeline orchestrator. It composes the registry of bookables, the persistent ma…
- event-bus — Typed publish/subscribe event bus for booking lifecycle events. The engine emits the 15 standard
BookingEventType eve…
- event-bus — Typed publish/subscribe event bus for booking lifecycle events. The engine emits the 15 standard
BookingEventType eve…
- state-machine — Configurable booking-status state machine. Consumers pass an array of
StatusTransition rows (from `BookingSystemConfi…
- state-machine — Configurable booking-status state machine. Consumers pass an array of
StatusTransition rows (from `BookingSystemConfi…
- domains — Provides
createBaseConfig(tenantId, tenantName) — the canonical default BookingSystemConfig factory that every doma…
- accommodation — Factory for the accommodation booking domain — hotels, vacation rentals, hostels. Each bookable represents one bookable…
- accommodation — Factory for the accommodation booking domain — hotels, vacation rentals, hostels. Each bookable represents one bookable…
- activities — Factory for the activity/tour booking domain — group tours, classes, workshops, group events. Each bookable represents…
- activities — Factory for the activity/tour booking domain — group tours, classes, workshops, group events. Each bookable represents…
- appointments — Factory for the appointment booking domain — medical, dental, salon, consulting. Each bookable represents an appointmen…
- appointments — Factory for the appointment booking domain — medical, dental, salon, consulting. Each bookable represents an appointmen…
- resources — Factory for the resource booking domain — meeting rooms, equipment, shared vehicles. Each bookable represents a resourc…
- resources — Factory for the resource booking domain — meeting rooms, equipment, shared vehicles. Each bookable represents a resourc…
- seats — Factory for the seat-based booking domain — stadiums, theatres, cinemas, flights. Each bookable represents one physical…
- seats — Factory for the seat-based booking domain — stadiums, theatres, cinemas, flights. Each bookable represents one physical…
- transport — Factory for the transport booking domain — flights, trains, buses. Each bookable represents a single transport-seat on…
- transport — Factory for the transport booking domain — flights, trains, buses. Each bookable represents a single transport-seat on…
- shared — Provides
createBaseConfig(tenantId, tenantName) — the canonical default BookingSystemConfig factory that every doma…
- error-codes — Defines the stable error-code registry and typed
BookingError class for @suaveplan/booking. Every failure path the…
- error-codes — Defines the stable error-code registry and typed
BookingError class for @suaveplan/booking. Every failure path the…
- hooks — In-package data-transform pipeline used by
BookingEngine to give consumers a hook into the create-booking and cancel-…
- hooks — In-package data-transform pipeline used by
BookingEngine to give consumers a hook into the create-booking and cancel-…
- calculator — Implements the booking engine's price-calculation pipeline.
calculatePrice is the canonical entry point: it runs base…
- calculator — Implements the booking engine's price-calculation pipeline.
calculatePrice is the canonical entry point: it runs base…
- dynamic — Implements dynamic-pricing rule evaluation. Three trigger types are supported —
occupancy_threshold, advance_days,…
- dynamic — Implements dynamic-pricing rule evaluation. Three trigger types are supported —
occupancy_threshold, advance_days,…
- seasonal — Applies seasonal-rate multipliers to a base price based on month/day windows. Supports wrap-around-year intervals (e.g.…
- seasonal — Applies seasonal-rate multipliers to a base price based on month/day windows. Supports wrap-around-year intervals (e.g.…
- conditions — Pre-built
RuleCondition factories for the most common booking constraints — minimum/maximum duration, advance-booking…
- conditions — Pre-built
RuleCondition factories for the most common booking constraints — minimum/maximum duration, advance-booking…
- evaluator — The rules-engine evaluator walks a list of
BookingRule[] against an EvaluationContext (booking + bookable + window…
- evaluator — The rules-engine evaluator walks a list of
BookingRule[] against an EvaluationContext (booking + bookable + window…
- booking.schema — Zod validation schemas covering every entity at the booking engine's input boundary —
Bookable, Booking, `BookingRe…
- config.schema — Validates the full
BookingSystemConfig JSON tree at runtime. The schema mirrors the config.types.ts shape and is th…
- recurrence — Expands
RecurrenceRule definitions into concrete TimeWindow[] occurrences across a date range. Supports daily, week…
- recurrence — Expands
RecurrenceRule definitions into concrete TimeWindow[] occurrences across a date range. Supports daily, week…
- slots — Generates and manipulates
TimeSlot lists. generateTimeSlots produces fixed-interval slots covering a single `TimeWi…
- slots — Generates and manipulates
TimeSlot lists. generateTimeSlots produces fixed-interval slots covering a single `TimeWi…
- windows — Defines pure functions for reasoning about
TimeWindow intervals — overlap, merge, split, containment, adjacency, vali…
- windows — Defines pure functions for reasoning about
TimeWindow intervals — overlap, merge, split, containment, adjacency, vali…
- utils — Shared, dependency-free helpers used across
@suaveplan/booking. Every export here is pure, side-effect-free, and runs…
- utils — Shared, dependency-free helpers used across
@suaveplan/booking. Every export here is pure, side-effect-free, and runs…
Install
Quick start
Architecture
Every stage is pluggable via registries (registerDetector, registerAvailabilityStrategy) and the Hooks<BookingHookMap> accessor exposes pre-persistence transform points (booking:creating, booking:cancelling).
Modules
Foundation
Types
Temporal
Conflict detection
Pricing
Rules
Availability
Domains
Schemas
Core
Tree-shaking
Every feature module ships at its own subpath export:
License
MIT — © Suaveplan Team