npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bondsports/online-booking

v1.0.0

Published

Bond Sports online booking package

Readme

@bondsports/online-booking

Validation and settings-resolution utilities for online booking flows.

The package answers two questions:

  1. What booking settings apply to this user right now?resolveBookingSettings merges the default product-category settings with the most favorable overrides from the user's active memberships.
  2. Are the slots the user wants to book actually allowed?validateBookingSlots checks the requested slots (combined with the user's already-booked slots) against the resolved settings and returns a typed validation result.

Installation

npm install @bondsports/online-booking

Usage

resolveBookingSettings

Pick the effective IBookingSettings for a user. If the user has no active memberships (or none of them override the category settings), the default is returned. Otherwise the lowest minimumBookingNotice and the highest advanceBookingWindow across matching membership overrides win.

import { resolveBookingSettings } from '@bondsports/online-booking';

const settings = resolveBookingSettings(productCategory.onlineBookingSettings, user.activeMemberships);
  • productCategory.onlineBookingSettingsTProductCategoryOnlineBookingSettings ({ default, memberships })
  • user.activeMemberships{ membershipId: number }[] (optional; pass undefined or [] for guests)

validateBookingSlots

Validate a list of requested time slots against the resolved settings.

import { validateBookingSlots } from '@bondsports/online-booking';

const result = validateBookingSlots(requestedSlots, userBookedSlots, settings, facilityTimezone);

if (!result.success) {
	// result.error is a ValidationError with a stable `code` (see ONLINE_BOOKING_ERRORS)
	throw result.error;
}

The validator:

  • merges requested slots with the user's existing bookings (clamped to the booking window),
  • enforces maxBookingHours per calendar day (in the facility timezone),
  • enforces maxSequentialBookings on each continuous block,
  • enforces minimumBookingNotice and advanceBookingWindow against "now".

Error handling

All failures return { success: false, error } where error is a ValidationError subclass carrying a stable code from ONLINE_BOOKING_ERRORS:

| Error class | Code | Meaning | | ------------------------- |------------------------|----------------------------------------------------------| | InvalidTimesError | INVALID_TIMES | Start date is not strictly before end date | | MinimumNoticeError | MINIMUM_NOTICE_DATE | Start date is before now + minimumBookingNotice | | AdvanceBookingError | ADVANCE_BOOKING_DATE | Start date extends beyond now + advanceBookingWindow | | MaxSequentialHoursError | MAX_SEQUENTIAL_HOURS | A contiguous block exceeds maxSequentialBookings | | MaxBookingHoursError | MAX_BOOKING_HOURS | Total booked duration on a day exceeds maxBookingHours |

import { ONLINE_BOOKING_ERRORS, ValidationError } from '@bondsports/online-booking';

if (!result.success && result.error.code === ONLINE_BOOKING_ERRORS.MINIMUM_NOTICE_DATE) {
	// show "book at least N hours in advance" message
}

API

import {
	validateBookingSlots,
	resolveBookingSettings,
	ONLINE_BOOKING_ERRORS,
	ValidationError,
	InvalidTimesError,
	MinimumNoticeError,
	AdvanceBookingError,
	MaxSequentialHoursError,
	MaxBookingHoursError,
	IBookingValidation,
	IBookingSettings,
	IMembershipBookingSettings,
	TProductCategoryOnlineBookingSettings,
} from '@bondsports/online-booking';

Scripts

npm run build      # compile to ./dist
npm test           # run jest
npm run lint       # eslint + prettier check
npm run lint:fix   # autofix