@aglyn/plugins-bookings
The Bookings plugin for Aglyn: bookable services, open time slots, and free or paid appointments taken on a published site and managed in the console. Install it if you are running or building on the Aglyn platform and want its booking feature.
Published to npm from the Aglyn monorepo. Versions follow semantic versioning.
Install
npm install @aglyn/plugins-bookings
Peer dependencies:
@mui/materialfirebasefirebase-adminnextreact
None is optional. firebase-admin and next are used by the server half (@aglyn/plugins-bookings/server).
What's in it
This package is a first-party Aglyn plugin. It is loaded through Aglyn's plugin manager: the apps read its entry in the monorepo's plugins.config.json, import the module each surface names, and call the registrar declared for that surface. It is not a standalone library; installing it on its own loads nothing.
On a published site
- One canvas component,
booking: a service and time picker that books an appointment. It is placed in Besigner like any other element and registered byregisterBookingsPlugin().
In the console
registerBookingsConsole() registers:
- A Bookings nav item and page at
/bookings, behind thebookingsfeature flag. The page is code-split and loads when opened. - A "Book a meeting" widget in the
crmRecordBookingslot. The CRM plugin hosts that zone on a record; this plugin draws the control in it, so neither package imports the other. - A plugin config schema (
BOOKINGS_CONFIG_SCHEMA) with two settings:maxDaysAhead(the booking horizon in days) andbookingPath(the page on the site that holds the Booking block, used to build booking links). - A record count source for
booking(plugin-record-counts): how many bookings a site took, which a campaign's conversion report divides by.
On the server
@aglyn/plugins-bookings/server imports firebase-admin and is kept out of the client entry point.
registerBookingsApi()(thetenantApisurface) registers the site-facing routesbookings/slots(open slots for a service, a page ofBOOKING_SLOT_PAGE_DAYSwhole days at a time;fromasks for the page itsnextFromMsnamed) andbookings/book(take a booking; a paid service goes through Stripe Checkout).registerBookingsConsoleApi()(theconsoleApisurface) registersbookings/reminders,bookings/refund,bookings/check-in,bookings/reschedule,bookings/cancel(a booking with no money on it, raisingbooking.canceled),bookings/in-person-payment(a booking paid at the counter on the native Aglyn POS app's card reader) andbookings/booking-analytics, a handler on the platform billing webhook that confirms paid bookings, and a bookings-by-service figure reader.registerBookingsConsoleServerDeclarations()(theconsoleServerDeclarationssurface) serves a site's bookings read-only on the customer REST API at/v1/sites/{siteId}/bookings(bookings:read, and thebookingsplan feature), and declares the booking events.- The booking events go through core's domain-event outbox, each carrying
{ booking }in the API's shape:booking.createdwhen a booking is confirmed (a free one as it is made, a paid one when its payment lands),booking.rescheduledonce per move, andbooking.canceledwhen the cancel route or a full refund ends it. Another plugin subscribes by name and never imports this one. - Loading the module registers two scheduled plugin jobs:
expire-stale-holdsandbooking-reminders(a reminder email about a day before a confirmed booking). This is whypackage.jsonlists./src/lib/server.*undersideEffects.
Routes are served by the host app's API dispatcher under /api/, for example /api/bookings/slots.
Entry points
| import | contents |
|---|---|
@aglyn/plugins-bookings | BUNDLE_ID, registerBookingsConsole, the site half, and the pure model (computeOpenSlots, computeOpenSlotPage, isSlotOpen, bookingLinkFor, normalizeBookingPath, the HostBookingService and BookingSlot types) |
@aglyn/plugins-bookings/site | registerBookingsPlugin and BOOKINGS_BUNDLE only. This is what a published page loads, so it carries no console code |
@aglyn/plugins-bookings/server | registerBookingsApi, registerBookingsConsoleApi, slotsHandler, bookHandler, scanBookingReminders |
@aglyn/plugins-bookings/* | any module under src/lib/ |
Usage
The registrars are normally called by Aglyn's generated plugin loaders, not by hand. Called directly they look like this:
// Published site (canvas half only)
import { registerBookingsPlugin } from '@aglyn/plugins-bookings/site'
registerBookingsPlugin()
// Console app
import { registerBookingsConsole } from '@aglyn/plugins-bookings'
registerBookingsConsole()
// Server-only API dispatcher
import {
registerBookingsApi,
registerBookingsConsoleApi,
} from '@aglyn/plugins-bookings/server'
registerBookingsApi()
How it fits
A plugin may import the tenant runtime, the renderer, the Besigner logic, the core and the shared packages. It never imports another plugin, and the core never imports a plugin. Bookings depends on @aglyn/aglyn (the core and its plugin-manager seams), @aglyn/tenant-runtime, @aglyn/tenant-data-admin, @aglyn/tenant-feature-instance and several @aglyn/shared-* packages. What it shares with other plugins goes through core seams: tax on a paid booking is asked of the core's plugin tax profile, and the CRM control is drawn in a zone the CRM hosts.
License
Apache-2.0. Source: https://github.com/aglyn/aglyn/tree/main/libs/plugins/bookings