@bowlos/reservations 0.20.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HEADLESS.md +205 -6
- package/README.md +24 -10
- package/dist/account-CO8xzUs_.d.ts +54 -0
- package/dist/account-SqT7et4C.d.cts +54 -0
- package/dist/catalog-BxyPJdBL.d.ts +160 -0
- package/dist/catalog-D1VoVaNe.d.cts +160 -0
- package/dist/{chunk-3GAXATYP.js → chunk-FV6SROO2.js} +22 -4
- package/dist/chunk-FV6SROO2.js.map +1 -0
- package/dist/{chunk-32FTBLXQ.js → chunk-S5T4OCBY.js} +25 -3
- package/dist/chunk-S5T4OCBY.js.map +1 -0
- package/dist/components.cjs +32 -91
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +36 -57
- package/dist/components.d.ts +36 -57
- package/dist/components.js +32 -79
- package/dist/components.js.map +1 -1
- package/dist/{data-ymW_rWbz.d.cts → data-BKlgn8Ln.d.cts} +72 -1
- package/dist/{data-ymW_rWbz.d.ts → data-BKlgn8Ln.d.ts} +72 -1
- package/dist/index.cjs +45 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +18 -3
- package/dist/index.js.map +1 -1
- package/dist/payments.d.cts +1 -1
- package/dist/payments.d.ts +1 -1
- package/dist/{react-Bh0z-Lnb.d.ts → react-B1uSOozS.d.ts} +2 -2
- package/dist/{react-DHvo_ZHf.d.cts → react-Bc_6yi9q.d.cts} +2 -2
- package/dist/react.cjs +73 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +36 -6
- package/dist/react.d.ts +36 -6
- package/dist/react.js +37 -4
- package/dist/react.js.map +1 -1
- package/package.json +2 -2
- package/templates/center-site/package.json +1 -1
- package/dist/catalog-BGPCoIOm.d.ts +0 -93
- package/dist/catalog-eofYl46p.d.cts +0 -93
- package/dist/chunk-32FTBLXQ.js.map +0 -1
- package/dist/chunk-3GAXATYP.js.map +0 -1
- package/dist/errors-IIK7xibp.d.cts +0 -54
- package/dist/errors-IIK7xibp.d.ts +0 -54
package/HEADLESS.md
CHANGED
|
@@ -151,19 +151,26 @@ const chosen = (addons.data ?? [])
|
|
|
151
151
|
.map((a) => ({ ...a, quantity: qty[a.id] ?? 0 }))
|
|
152
152
|
.filter((a) => a.quantity > 0);
|
|
153
153
|
const addonsSubtotal = chosen.reduce((s, a) => s + a.priceCents * a.quantity, 0);
|
|
154
|
-
//
|
|
155
|
-
//
|
|
154
|
+
// TAX and the reservation FEE are both folded into the quote total — itemize
|
|
155
|
+
// each so neither vanishes, and subtract them from the base line below so they
|
|
156
|
+
// aren't double-counted. Tax lives in taxLinesPerPlan (NOT inside the base):
|
|
157
|
+
const plan = preview.data?.totalCentsPerPlan?.[0]; // headline plan
|
|
158
|
+
const taxLines = preview.data?.taxLinesPerPlan?.find((t) => t.pricePlanId === plan?.pricePlanId)?.taxLines ?? [];
|
|
159
|
+
const taxCents = taxLines.reduce((s, t) => s + t.taxCents, 0); // each line: { label, taxCents }
|
|
156
160
|
const fee = preview.data?.reservationFee; // { amountCents, label } | null
|
|
157
161
|
const feeCents = (fee?.amountCents as number) ?? 0;
|
|
158
|
-
const reservationCents = quoteCents != null ? quoteCents - addonsSubtotal - feeCents : null; // base
|
|
162
|
+
const reservationCents = quoteCents != null ? quoteCents - addonsSubtotal - taxCents - feeCents : null; // base only
|
|
159
163
|
// Summary rows: the reservation ({count} {label} · {date} · {start–end}) + each add-on
|
|
160
|
-
// ({name} × {qty}) +
|
|
161
|
-
//
|
|
164
|
+
// ({name} × {qty}) + one row per taxLine ({label} → {taxCents}) + a "{fee.label}" line
|
|
165
|
+
// (feeCents) when feeCents > 0 + Total = quoteCents. "Continue to payment" →
|
|
166
|
+
// flow.startHold(bookingArgs); "Edit order" → setReviewing(false).
|
|
162
167
|
```
|
|
163
168
|
|
|
164
169
|
The total shown **must** be the quote's `totalCents` — it already includes tax
|
|
165
170
|
**and** the reservation fee, so the review matches what the customer is charged.
|
|
166
|
-
Itemize `
|
|
171
|
+
Itemize **each `taxLinesPerPlan[plan].taxLines[]` row** and
|
|
172
|
+
`preview.data.reservationFee` as their own lines so neither the tax nor the fee
|
|
173
|
+
is hidden inside the reservation line (see the [Static purchase summary](#static-purchase-summary--tax--center-fee--setup-fee-every-category) field map).
|
|
167
174
|
|
|
168
175
|
### 8. Hold → pay → confirm, and pay-to-confirm
|
|
169
176
|
|
|
@@ -278,6 +285,140 @@ hold during the review step — hold on "Continue to payment" only (§7).
|
|
|
278
285
|
|
|
279
286
|
---
|
|
280
287
|
|
|
288
|
+
## Static purchase summary — tax · center fee · setup fee (every category)
|
|
289
|
+
|
|
290
|
+
Every BowlOS funnel ends in a **static, non-editable summary** the customer
|
|
291
|
+
reads before paying: itemized **tax**, the **center/booking fee**, and — for
|
|
292
|
+
memberships — the one-time **setup/joining fee**. This is the single most
|
|
293
|
+
common headless gap, so here is the exact field map. **Read it from the
|
|
294
|
+
server-computed preview; never compute tax, fee, or totals yourself** — the
|
|
295
|
+
preview is the same engine the PaymentIntent uses, so the summary and the charge
|
|
296
|
+
can never disagree.
|
|
297
|
+
|
|
298
|
+
| Category | Review hook (preview) | Base line(s) | Tax lines | Center / booking fee | Setup fee | Total(s) |
|
|
299
|
+
|---|---|---|---|---|---|---|
|
|
300
|
+
| **Bowling / other attractions** | `useBookingPreview` | reservation (count × rate, add-ons, less discount) | `taxLinesPerPlan[plan].taxLines[]` → `{ label, taxCents }` | `reservationFee` → `{ amountCents, label }` | — (n/a) | `totalCentsPerPlan[plan].totalCents` (already includes tax + fee) |
|
|
301
|
+
| **Events (ticket mode)** | `useEventTicketPreview` | `subtotalCents` ("Tickets") | `taxLines[]` → `{ label, taxCents }` | `reservationFeeCents` / `reservationFeeLabel` | — (n/a) | `grandTotalCents` |
|
|
302
|
+
| **Game passes** | `useGameCardPreview` | `subtotalCents` | `taxLines[]` | `reservationFeeCents` / `reservationFeeLabel` | — (n/a) | `grandTotalCents` |
|
|
303
|
+
| **Packages** | `usePackagePreview` | `baseTotalCents` + `addons[]` (`{ name, quantity, lineCents }`) | `taxLines[]` | `reservationFeeCents` / `reservationFeeLabel` | — (n/a) | `grandTotalCents` |
|
|
304
|
+
| **Membership (one-time)** | `useMembershipPreview` | `duesCents` | `taxLines[]` | `reservationFeeCents` / `reservationFeeLabel` | `setupFeeCents` | `grandTotalCents` |
|
|
305
|
+
| **Membership (recurring)** | `useMembershipSubscriptionPreview` | `duesCents` | `taxLines[]` | `reservationFeeCents` / `reservationFeeLabel` | `setupFeeCents` (today only) | **Due today** `grandTotalCents` **and** **Auto-renews at** `recurringTotalCents` / `cadence` |
|
|
306
|
+
|
|
307
|
+
Rules that make the summary match the charge:
|
|
308
|
+
|
|
309
|
+
- **Static, not editable.** The summary re-states the customer's choices and the
|
|
310
|
+
server's numbers; the only actions are "Continue to payment" and "Edit order"
|
|
311
|
+
(which returns to the form). No price/qty inputs live on the summary.
|
|
312
|
+
- **Show every tax line.** Each `taxLine` is `{ label, taxCents, mode, … }`.
|
|
313
|
+
Render one row per line using `label` + `taxCents`. `mode: "included"` lines
|
|
314
|
+
are informational (tax is inside the price); `"none"`/exempt → there are no
|
|
315
|
+
lines, so render nothing. Never collapse tax into the base line — for bowling
|
|
316
|
+
in particular the tax is in `taxLinesPerPlan`, **not** inside the reservation
|
|
317
|
+
line (see §7).
|
|
318
|
+
- **Show the center fee when present.** Render `reservationFeeLabel` (the
|
|
319
|
+
operator's own wording, e.g. "Facility fee") + the amount **only when**
|
|
320
|
+
`reservationFeeCents > 0` (bowling: `reservationFee != null`). It is already
|
|
321
|
+
folded into the total — itemize it so it doesn't look like a hidden add-on.
|
|
322
|
+
- **Setup fee = per-purchase joining fee.** `setupFeeCents` is a **one-time**
|
|
323
|
+
charge applied on the **first payment of every membership purchase** whose
|
|
324
|
+
template has one configured — it is **not** waived for repeat buyers. Render
|
|
325
|
+
the "Joining fee" / "Setup fee" row **only when `setupFeeCents > 0`** (a
|
|
326
|
+
template with no setup fee returns `0`) and never fabricate it. On a recurring
|
|
327
|
+
membership it is part of **Due today** but is **excluded from**
|
|
328
|
+
`recurringTotalCents` (renewals charge dues + tax/fee only).
|
|
329
|
+
- **Trust the total.** `grandTotalCents` (or bowling's `totalCentsPerPlan[].totalCents`)
|
|
330
|
+
already = base + tax + center fee (+ setup fee for a first membership). Display
|
|
331
|
+
it verbatim; do not re-sum the rows yourself.
|
|
332
|
+
|
|
333
|
+
Each category's full funnel (config, auth gate, payment) is in its section below.
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
## Event offers in the catalog
|
|
338
|
+
|
|
339
|
+
Use `useEventOffers({ centerId })` for public event lineup cards and event
|
|
340
|
+
landing-page links. `useEvents()` is the legacy pricing-event/date-preset list;
|
|
341
|
+
it does **not** carry the commerce controls (lineup toggle, landing-page slug,
|
|
342
|
+
purchase mode, included add-ons, tax/fee config).
|
|
343
|
+
|
|
344
|
+
```tsx
|
|
345
|
+
const events = useEventOffers({ centerId });
|
|
346
|
+
// rows include:
|
|
347
|
+
// { id, slug, title, subtitle, description, date, startMinuteOfDay,
|
|
348
|
+
// endMinuteOfDay, purchaseMode, productId, pricePlanId, priceCents }
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
Route catalog picks by `offer.slug` to your event landing page. On that page,
|
|
352
|
+
read the full offer with `useEventOffer({ slug })`.
|
|
353
|
+
|
|
354
|
+
For `purchaseMode: "reservation"`, start the normal booking flow with the
|
|
355
|
+
offer's `productId`, preselect `date`, `startMinuteOfDay`, and duration
|
|
356
|
+
(`endMinuteOfDay - startMinuteOfDay`) when present, and preselect
|
|
357
|
+
`includedAddons`. Pass `eventOfferSlug: offer.slug` into both
|
|
358
|
+
`useBookingPreview` and the booking hold/create call (`useBookingFlow.startHold`
|
|
359
|
+
or `createBooking`). The server uses that slug to bind the quote to the offer's
|
|
360
|
+
event price plan, tax override, and Center fee override/inheritance. Then
|
|
361
|
+
continue through the same [Review step](#7-review-step--an-order-summary-before-payment)
|
|
362
|
+
and `useBookingFlow` lifecycle above. That keeps event reservations on the same
|
|
363
|
+
pricing, hold, tax, fee, credit, and Stripe Connect path as regular bookings.
|
|
364
|
+
`useBookingPreview` returns `taxLinesPerPlan` alongside `totalCentsPerPlan`;
|
|
365
|
+
render the entry matching the selected/headline price plan so event tax appears
|
|
366
|
+
as its own Review row instead of being hidden inside the base reservation line.
|
|
367
|
+
|
|
368
|
+
```tsx
|
|
369
|
+
const eventArgs = offer.purchaseMode === "reservation"
|
|
370
|
+
? { eventOfferSlug: offer.slug }
|
|
371
|
+
: {};
|
|
372
|
+
|
|
373
|
+
const preview = useBookingPreview(
|
|
374
|
+
{ centerId, productId: offer.productId!, dateISO, startMinuteOfDay, endMinuteOfDay, mode: pricingMode, ...countField(count), addons: selectedAddons, ...eventArgs },
|
|
375
|
+
{ enabled: offer.purchaseMode === "reservation" && signedIn },
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
// Later, after your Review step:
|
|
379
|
+
flow.startHold({
|
|
380
|
+
centerId,
|
|
381
|
+
productId: offer.productId!,
|
|
382
|
+
dateISO,
|
|
383
|
+
startMinuteOfDay,
|
|
384
|
+
endMinuteOfDay,
|
|
385
|
+
mode: pricingMode,
|
|
386
|
+
...countField(count),
|
|
387
|
+
addons: selectedAddons,
|
|
388
|
+
customer,
|
|
389
|
+
...eventArgs,
|
|
390
|
+
});
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
For `purchaseMode: "ticket"`, route the customer to the hosted tenant ticket
|
|
394
|
+
checkout at `/tenant/<slug>/events/<eventSlug>/tickets`, or mirror that flow in
|
|
395
|
+
a first-party surface with `previewEventTicket(client, { eventOfferId, quantity })`
|
|
396
|
+
or `useEventTicketPreview` → Review → `createEventTicketOrder(client, { eventOfferId, quantity })`
|
|
397
|
+
or `useEventTicketPurchase().start({ eventOfferId, quantity })` (gateway action:
|
|
398
|
+
`createEventTicketPaymentIntent`). The preview returns the itemized base, tax
|
|
399
|
+
lines, Center event fee, and `grandTotalCents`; the PaymentIntent action uses
|
|
400
|
+
the same server-side snapshot and writes an `event_orders` row. Do not charge
|
|
401
|
+
tickets from `priceCents` alone.
|
|
402
|
+
|
|
403
|
+
Headless function twins (non-React): `listEventOffers(client, { centerId })`,
|
|
404
|
+
`getEventOffer(client, { slug })`.
|
|
405
|
+
|
|
406
|
+
After payment, re-query the signed-in account reads:
|
|
407
|
+
|
|
408
|
+
- `useMyEventOrders({ brandId })` / `getMyEventOrders(client, { brandId })`
|
|
409
|
+
lists the customer's event ticket purchases for account dashboards.
|
|
410
|
+
- `useMyEventOrder({ brandId, orderId })` / `getMyEventOrder(client, { brandId, orderId })`
|
|
411
|
+
returns the frozen receipt snapshot: ticket subtotal, tax lines, Center fee,
|
|
412
|
+
included add-ons, `grandTotalCents`, and refund fields (`refundedCents`,
|
|
413
|
+
`refundedAt`, `refundReason`) when staff have refunded the ticket order.
|
|
414
|
+
|
|
415
|
+
Paid ticket orders write `transaction_ledger.source === "event"` rows, so
|
|
416
|
+
finance/reporting surfaces can break event revenue out separately from
|
|
417
|
+
reservations and packages. Stripe card refunds for those PaymentIntents reverse
|
|
418
|
+
the same ledger row and preserve the `eventOrderId` back-reference.
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
|
|
281
422
|
## Buying a game pass (memberships follow)
|
|
282
423
|
|
|
283
424
|
Game passes are a **direct purchase** — no inventory hold, no date/time. The buy
|
|
@@ -570,6 +711,61 @@ Headless function twins (non-React):
|
|
|
570
711
|
`createMembershipSubscriptionOrder(client, { templateId })`. (No status twin —
|
|
571
712
|
subscriptions materialize via webhook; read `getMyMemberships(client, { brandId })`.)
|
|
572
713
|
|
|
714
|
+
## The canonical catalog (visibility-aware) — `useCatalog`
|
|
715
|
+
|
|
716
|
+
`<BookingCatalog>` assembles the catalog from five per-category reads
|
|
717
|
+
(`useProducts` / `useEventOffers` / `usePackages` / `usePublicMemberships` /
|
|
718
|
+
`useGameCards`). Those reads do **not** apply the Center admin's per-surface
|
|
719
|
+
visibility settings — a category or offer the operator hid for a surface still
|
|
720
|
+
comes back.
|
|
721
|
+
|
|
722
|
+
For a visibility-aware catalog, use **`useCatalog`** (v0.21.0):
|
|
723
|
+
|
|
724
|
+
```tsx
|
|
725
|
+
import { useCatalog } from "@bowlos/reservations/react";
|
|
726
|
+
|
|
727
|
+
const { data, loading } = useCatalog({
|
|
728
|
+
brandId: "brand_…",
|
|
729
|
+
centerId: "center_…",
|
|
730
|
+
surface: "sdk_custom_site", // your surface — the backend applies its rules
|
|
731
|
+
});
|
|
732
|
+
|
|
733
|
+
// data.sections: { key, label, items: CatalogItem[] }[] (six categories, in order)
|
|
734
|
+
// Render only sections with items (empty categories are hidden on customer surfaces).
|
|
735
|
+
data?.sections
|
|
736
|
+
.filter((s) => s.items.length > 0)
|
|
737
|
+
.map((section) => (
|
|
738
|
+
<section key={section.key}>
|
|
739
|
+
<h2>{section.label}</h2>
|
|
740
|
+
{section.items.map((item) => (
|
|
741
|
+
<button key={item.id} onClick={() => route(item)}>
|
|
742
|
+
{item.title} — {item.priceLabel ?? "See times & pricing"}
|
|
743
|
+
</button>
|
|
744
|
+
))}
|
|
745
|
+
</section>
|
|
746
|
+
));
|
|
747
|
+
```
|
|
748
|
+
|
|
749
|
+
Routing — switch on `item.action.type` and use the IDs in `action.payload`:
|
|
750
|
+
|
|
751
|
+
| `action.type` | payload | route to |
|
|
752
|
+
|---|---|---|
|
|
753
|
+
| `book_reservation` | `{ productId }` | your `<BookingFlow>` for that product |
|
|
754
|
+
| `view_event` | `{ slug, purchaseMode }` | the event landing/booking by `slug` (fetch detail with `getEventOffer({ slug })` for reservation-mode presets) |
|
|
755
|
+
| `buy_package` | `{ packageId }` | your headless package buy (see "Buying a package") |
|
|
756
|
+
| `buy_membership` | `{ templateId }` | your membership buy (see "Buying a … membership") |
|
|
757
|
+
| `buy_game_pass` | `{ templateId }` | your game-pass buy (see "Buying a game pass") |
|
|
758
|
+
|
|
759
|
+
`priceLabel` is an indicative **"from $X"** only (null for products → show
|
|
760
|
+
"See times & pricing"); the binding price comes from the per-category preview
|
|
761
|
+
after login. The framework-agnostic twin is `listCatalog(client, args)`.
|
|
762
|
+
|
|
763
|
+
`useCatalog` keeps the SDK custom site consistent with the white-label web and
|
|
764
|
+
mobile surfaces (all three consume the same backend read) and honors the admin
|
|
765
|
+
Public Catalog toggles. As of **v0.22.0** the drop-in `<BookingCatalog>` is
|
|
766
|
+
built on this same read — its `onSelect` hands off a `CatalogItem`, so the
|
|
767
|
+
drop-in and a headless site route identically (table above).
|
|
768
|
+
|
|
573
769
|
## Adopting changes by version
|
|
574
770
|
|
|
575
771
|
What each SDK release changed in `<BookingFlow>` and the headless steps to match.
|
|
@@ -590,6 +786,9 @@ Headless sites do **not** get these from a version bump — apply them by hand.
|
|
|
590
786
|
| **0.18.0** | **Itemized package Review** — `usePackagePreview` (server-computed quote) | "Buying a package" §3. Insert a Review step between config and pay: `usePackagePreview({ packageId, centerId, quantity, optionalAddons })` returns the itemized breakdown (base, add-ons, tax lines, booking fee, `grandTotalCents`). Render it before `usePackagePurchase.start`. Same engine as the PaymentIntent, so it never diverges. (Auth required — applies tax exemptions.) |
|
|
591
787
|
| **0.19.0** | **Itemized game-pass Review** — `useGameCardPreview` (server-computed quote) | "Buying a game pass" §2. Insert a Review step before pay: `useGameCardPreview({ templateId })` returns the itemized breakdown (base, tax lines, booking fee, `grandTotalCents`). Render it before `useGameCardPurchase.start` — stop showing the bare `priceCents`, since the customer now pays base + tax + the selling Center's booking fee. Same engine as the PaymentIntent, so it never diverges. (Auth required — applies tax exemptions + resolves the home Center.) |
|
|
592
788
|
| **0.20.0** | **Membership buy hooks (one-time + recurring)** — `useMembershipPreview` / `useMembershipPurchase` and `useMembershipSubscriptionPreview` / `useMembershipSubscriptionCheckout` | "Buying a one-time membership" + "Buying a recurring membership" sections. One-time mirrors the game-pass buy (`useMembershipPreview` → `useMembershipPurchase`, poll `resultId` = membership). Recurring: `useMembershipSubscriptionPreview` shows **Due today** (`grandTotalCents`) *and* **Auto-renews at** (`recurringTotalCents` / `cadence`), then `useMembershipSubscriptionCheckout` confirms the first invoice — **no refToken poll; re-query `useMyMemberships` after payment** (the subscription materializes via webhook). Route the catalog's `membership` pick in-app, not to the portal. (Charges the operator's connected account.) |
|
|
789
|
+
| **0.21.0** | **Sellable event offers + ticket receipts** *and* **canonical visibility-aware catalog** — headless adds `useEventOffers` / `useEventOffer`, `useEventTicketPreview`, `createEventTicketOrder`, `useEventTicketPurchase`, signed-in event-order account reads, **and** `useCatalog` / `listCatalog` (one read, six categories, per-surface admin visibility applied); a consolidated [Static purchase summary](#static-purchase-summary--tax--center-fee--setup-fee-every-category) field map | "Event offers in the catalog" + "The canonical catalog" sections. Route `event` picks to an event landing page by `slug`. For reservation-mode events, preselect the event date/window/add-ons and pass `eventOfferSlug: offer.slug` into preview + hold/create so the server applies the event plan and tax/fee policy. For ticket-mode events, route to the hosted tenant ticket checkout or mirror `previewEventTicket` → Review → `createEventTicketOrder` / `useEventTicketPurchase`. After pay, re-query `useMyEventOrders` / `useMyEventOrder`. Prefer `useCatalog({ brandId, centerId, surface })` over the per-category hooks for the full, admin-controlled catalog (route each `CatalogItem` by `action.type`). `<BookingCatalog>` is unchanged. |
|
|
790
|
+
|
|
791
|
+
| **0.22.0** | **BREAKING: `<BookingCatalog>` is visibility-aware** — rebuilt on `useCatalog`/`listPublicCatalog`; `onSelect` hands off a `CatalogItem` (was the per-kind `CatalogOffer` union); section labels come from the backend (override via `sectionLabels`); new optional `surface` prop (default `"sdk_custom_site"`) | Headless sites need no change — `useCatalog` is unchanged. Sites using the drop-in update `onSelect` to route by `item.action.type` + `item.action.payload` (the routing table in "The canonical catalog"), and drop any `CatalogOffer` imports (`CatalogItem`/`CatalogSection`/`CatalogResult` are exported from `/components` too). Offers an admin hides for `sdk_custom_site` stop rendering in the drop-in — audit the admin Public Catalog page if something "disappears". |
|
|
593
792
|
|
|
594
793
|
When you add the next release here, add its row **and** any new capability-map
|
|
595
794
|
section in the same PR.
|
package/README.md
CHANGED
|
@@ -195,11 +195,13 @@ import { BookingFlow, BowlosTheme } from "@bowlos/reservations/components";
|
|
|
195
195
|
```
|
|
196
196
|
|
|
197
197
|
**`<BookingCatalog brandId centerId onSelect>`** is the catalog landing — "what
|
|
198
|
-
would you like to book?"
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
`
|
|
198
|
+
would you like to book?" Since **v0.22.0** it renders the **canonical
|
|
199
|
+
visibility-aware catalog** (`useCatalog` / `listPublicCatalog`) — the same read
|
|
200
|
+
the white-label web and mobile surfaces use — so the Center admin's per-surface
|
|
201
|
+
Public Catalog toggles apply to the drop-in too. Each pick hands off a
|
|
202
|
+
`CatalogItem` via `onSelect`; route by `item.action.type` with the IDs in
|
|
203
|
+
`item.action.payload` (same routing table as a headless site — HEADLESS.md →
|
|
204
|
+
"The canonical catalog").
|
|
203
205
|
|
|
204
206
|
```tsx
|
|
205
207
|
import { BookingCatalog } from "@bowlos/reservations/components";
|
|
@@ -207,14 +209,26 @@ import { BookingCatalog } from "@bowlos/reservations/components";
|
|
|
207
209
|
<BookingCatalog
|
|
208
210
|
brandId="brand_…"
|
|
209
211
|
centerId="center_…"
|
|
210
|
-
onSelect={(
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
: router.push(`/
|
|
214
|
-
|
|
212
|
+
onSelect={(item) => {
|
|
213
|
+
const p = item.action.payload;
|
|
214
|
+
switch (item.action.type) {
|
|
215
|
+
case "book_reservation": return router.push(`/book?productId=${p.productId}`);
|
|
216
|
+
case "view_event":
|
|
217
|
+
case "buy_ticket": return router.push(`/events/${p.slug}`);
|
|
218
|
+
case "buy_package": return router.push(`/buy/package/${p.packageId}`);
|
|
219
|
+
case "buy_membership": return router.push(`/buy/membership/${p.templateId}`);
|
|
220
|
+
case "buy_game_pass": return router.push(`/buy/game-pass/${p.templateId}`);
|
|
221
|
+
}
|
|
222
|
+
}}
|
|
215
223
|
/>;
|
|
216
224
|
```
|
|
217
225
|
|
|
226
|
+
> **Breaking (v0.22.0):** `onSelect` previously received a per-kind
|
|
227
|
+
> `CatalogOffer` union (`o.kind` / `o.id`); it now receives a `CatalogItem`.
|
|
228
|
+
> Section headings come from the backend (override with `sectionLabels`), and
|
|
229
|
+
> hidden categories/offers no longer render. Headless sites use the same data
|
|
230
|
+
> via `useCatalog({ brandId, centerId, surface })` / `listCatalog`.
|
|
231
|
+
|
|
218
232
|
The drop-in surfaces cover a center site end to end:
|
|
219
233
|
|
|
220
234
|
**`<BookingFlow>`** runs the whole funnel (availability + price → **review** → pay
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { g as BowlosClient } from './data-BKlgn8Ln.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Typed account + flash reads for @bowlos/reservations.
|
|
5
|
+
*
|
|
6
|
+
* Session-scoped account reads (require a signed-in customer) and the
|
|
7
|
+
* session-aware flash-sale reads. Args are typed precisely — every account read
|
|
8
|
+
* is brand-scoped. Results are generic (`<T = unknown>`): parameterize with your
|
|
9
|
+
* own shape, or read `unknown` and narrow. (The backend return shapes are rich
|
|
10
|
+
* and evolving; the SDK doesn't pin them here.) Each read has a framework-agnostic
|
|
11
|
+
* function here and a React hook in `hooks.tsx`.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** Every account read is scoped to the customer's Brand. */
|
|
15
|
+
type BrandScoped = {
|
|
16
|
+
brandId: string;
|
|
17
|
+
};
|
|
18
|
+
type ReservationDetailArgs = {
|
|
19
|
+
brandId: string;
|
|
20
|
+
displayId: string;
|
|
21
|
+
};
|
|
22
|
+
type EventOrderDetailArgs = {
|
|
23
|
+
brandId: string;
|
|
24
|
+
orderId: string;
|
|
25
|
+
};
|
|
26
|
+
type MembershipDetailArgs = {
|
|
27
|
+
brandId: string;
|
|
28
|
+
membershipId: string;
|
|
29
|
+
};
|
|
30
|
+
type FlashSaleArgs = {
|
|
31
|
+
slug: string;
|
|
32
|
+
};
|
|
33
|
+
type FlashBookingOptionsArgs = {
|
|
34
|
+
slug: string;
|
|
35
|
+
itemId: string;
|
|
36
|
+
};
|
|
37
|
+
type FlashSalesArgs = {
|
|
38
|
+
brandId: string;
|
|
39
|
+
};
|
|
40
|
+
declare function getMyReservations<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
41
|
+
declare function getMyReservationDetail<T = unknown>(client: BowlosClient, args: ReservationDetailArgs): Promise<T>;
|
|
42
|
+
declare function getMyEventOrders<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
43
|
+
declare function getMyEventOrder<T = unknown>(client: BowlosClient, args: EventOrderDetailArgs): Promise<T>;
|
|
44
|
+
declare function getMyMemberships<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
45
|
+
declare function getMyMembershipDetail<T = unknown>(client: BowlosClient, args: MembershipDetailArgs): Promise<T>;
|
|
46
|
+
declare function getMyLoyalty<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
47
|
+
declare function getMyCredits<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
48
|
+
declare function getMyPasses<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
49
|
+
declare function getFlashSale<T = unknown>(client: BowlosClient, args: FlashSaleArgs): Promise<T>;
|
|
50
|
+
/** The public flash-sale index for a Brand (live + upcoming; no prices). Public. */
|
|
51
|
+
declare function getFlashSales<T = unknown>(client: BowlosClient, args: FlashSalesArgs): Promise<T>;
|
|
52
|
+
declare function getFlashSaleBookingOptions<T = unknown>(client: BowlosClient, args: FlashBookingOptionsArgs): Promise<T>;
|
|
53
|
+
|
|
54
|
+
export { type BrandScoped as B, type EventOrderDetailArgs as E, type FlashBookingOptionsArgs as F, type MembershipDetailArgs as M, type ReservationDetailArgs as R, type FlashSaleArgs as a, type FlashSalesArgs as b, getFlashSaleBookingOptions as c, getFlashSales as d, getMyCredits as e, getMyEventOrder as f, getFlashSale as g, getMyEventOrders as h, getMyLoyalty as i, getMyMembershipDetail as j, getMyMemberships as k, getMyPasses as l, getMyReservationDetail as m, getMyReservations as n };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { g as BowlosClient } from './data-BKlgn8Ln.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Typed account + flash reads for @bowlos/reservations.
|
|
5
|
+
*
|
|
6
|
+
* Session-scoped account reads (require a signed-in customer) and the
|
|
7
|
+
* session-aware flash-sale reads. Args are typed precisely — every account read
|
|
8
|
+
* is brand-scoped. Results are generic (`<T = unknown>`): parameterize with your
|
|
9
|
+
* own shape, or read `unknown` and narrow. (The backend return shapes are rich
|
|
10
|
+
* and evolving; the SDK doesn't pin them here.) Each read has a framework-agnostic
|
|
11
|
+
* function here and a React hook in `hooks.tsx`.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** Every account read is scoped to the customer's Brand. */
|
|
15
|
+
type BrandScoped = {
|
|
16
|
+
brandId: string;
|
|
17
|
+
};
|
|
18
|
+
type ReservationDetailArgs = {
|
|
19
|
+
brandId: string;
|
|
20
|
+
displayId: string;
|
|
21
|
+
};
|
|
22
|
+
type EventOrderDetailArgs = {
|
|
23
|
+
brandId: string;
|
|
24
|
+
orderId: string;
|
|
25
|
+
};
|
|
26
|
+
type MembershipDetailArgs = {
|
|
27
|
+
brandId: string;
|
|
28
|
+
membershipId: string;
|
|
29
|
+
};
|
|
30
|
+
type FlashSaleArgs = {
|
|
31
|
+
slug: string;
|
|
32
|
+
};
|
|
33
|
+
type FlashBookingOptionsArgs = {
|
|
34
|
+
slug: string;
|
|
35
|
+
itemId: string;
|
|
36
|
+
};
|
|
37
|
+
type FlashSalesArgs = {
|
|
38
|
+
brandId: string;
|
|
39
|
+
};
|
|
40
|
+
declare function getMyReservations<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
41
|
+
declare function getMyReservationDetail<T = unknown>(client: BowlosClient, args: ReservationDetailArgs): Promise<T>;
|
|
42
|
+
declare function getMyEventOrders<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
43
|
+
declare function getMyEventOrder<T = unknown>(client: BowlosClient, args: EventOrderDetailArgs): Promise<T>;
|
|
44
|
+
declare function getMyMemberships<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
45
|
+
declare function getMyMembershipDetail<T = unknown>(client: BowlosClient, args: MembershipDetailArgs): Promise<T>;
|
|
46
|
+
declare function getMyLoyalty<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
47
|
+
declare function getMyCredits<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
48
|
+
declare function getMyPasses<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
49
|
+
declare function getFlashSale<T = unknown>(client: BowlosClient, args: FlashSaleArgs): Promise<T>;
|
|
50
|
+
/** The public flash-sale index for a Brand (live + upcoming; no prices). Public. */
|
|
51
|
+
declare function getFlashSales<T = unknown>(client: BowlosClient, args: FlashSalesArgs): Promise<T>;
|
|
52
|
+
declare function getFlashSaleBookingOptions<T = unknown>(client: BowlosClient, args: FlashBookingOptionsArgs): Promise<T>;
|
|
53
|
+
|
|
54
|
+
export { type BrandScoped as B, type EventOrderDetailArgs as E, type FlashBookingOptionsArgs as F, type MembershipDetailArgs as M, type ReservationDetailArgs as R, type FlashSaleArgs as a, type FlashSalesArgs as b, getFlashSaleBookingOptions as c, getFlashSales as d, getMyCredits as e, getMyEventOrder as f, getFlashSale as g, getMyEventOrders as h, getMyLoyalty as i, getMyMembershipDetail as j, getMyMemberships as k, getMyPasses as l, getMyReservationDetail as m, getMyReservations as n };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { g as BowlosClient } from './data-BKlgn8Ln.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Error model for the BowlOS Reservations SDK.
|
|
5
|
+
*
|
|
6
|
+
* Every failed gateway call surfaces as a single `BowlosApiError` carrying a
|
|
7
|
+
* stable `code` (string), the HTTP `status`, and — for rate limits — a
|
|
8
|
+
* `retryAfterSeconds`. The gateway normalizes the backend's two error
|
|
9
|
+
* conventions (thrown ConvexError + `{ ok:false }` envelopes) into one JSON
|
|
10
|
+
* shape; this class is the client-side mirror of that shape, so consumers
|
|
11
|
+
* branch on `error.code`, never on message text.
|
|
12
|
+
*/
|
|
13
|
+
/** Stable error codes the gateway / backend can return. Open set — treat
|
|
14
|
+
* `code` as a string and match against these for known cases. */
|
|
15
|
+
declare const BOWLOS_ERROR_CODES: {
|
|
16
|
+
readonly API_KEY_MISSING: "API_KEY_MISSING";
|
|
17
|
+
readonly API_KEY_INVALID: "API_KEY_INVALID";
|
|
18
|
+
readonly ORIGIN_NOT_ALLOWED: "ORIGIN_NOT_ALLOWED";
|
|
19
|
+
readonly RATE_LIMITED: "RATE_LIMITED";
|
|
20
|
+
readonly INVALID_CREDENTIALS: "INVALID_CREDENTIALS";
|
|
21
|
+
readonly SIGNUP_FAILED: "SIGNUP_FAILED";
|
|
22
|
+
readonly VALIDATION_FAILED: "VALIDATION_FAILED";
|
|
23
|
+
readonly PERMISSION_DENIED: "PERMISSION_DENIED";
|
|
24
|
+
readonly SCOPE_REVOKED: "SCOPE_REVOKED";
|
|
25
|
+
readonly NOT_FOUND: "NOT_FOUND";
|
|
26
|
+
readonly VERSION_CONFLICT: "VERSION_CONFLICT";
|
|
27
|
+
readonly PRICING_SNAPSHOT_STALE: "PRICING_SNAPSHOT_STALE";
|
|
28
|
+
readonly PAYMENTS_NOT_CONNECTED: "PAYMENTS_NOT_CONNECTED";
|
|
29
|
+
readonly CONNECT_ACCOUNT_RESTRICTED: "CONNECT_ACCOUNT_RESTRICTED";
|
|
30
|
+
readonly CHECKOUT_EXPIRED: "CHECKOUT_EXPIRED";
|
|
31
|
+
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
32
|
+
readonly UNKNOWN: "ERROR";
|
|
33
|
+
};
|
|
34
|
+
type BowlosErrorCode = (typeof BOWLOS_ERROR_CODES)[keyof typeof BOWLOS_ERROR_CODES] | (string & {});
|
|
35
|
+
interface BowlosApiErrorOptions {
|
|
36
|
+
retryAfterSeconds?: number;
|
|
37
|
+
cause?: unknown;
|
|
38
|
+
}
|
|
39
|
+
declare class BowlosApiError extends Error {
|
|
40
|
+
/** Stable, machine-readable code. Branch on this, not on `message`. */
|
|
41
|
+
readonly code: BowlosErrorCode;
|
|
42
|
+
/** HTTP status (0 for a network failure before any response). */
|
|
43
|
+
readonly status: number;
|
|
44
|
+
/** Seconds to wait before retrying — present only on `RATE_LIMITED`. */
|
|
45
|
+
readonly retryAfterSeconds?: number;
|
|
46
|
+
constructor(code: BowlosErrorCode, message: string, status: number, options?: BowlosApiErrorOptions);
|
|
47
|
+
/** Too many requests — caller should back off `retryAfterSeconds`. */
|
|
48
|
+
get isRateLimited(): boolean;
|
|
49
|
+
/** Bad/expired login. The session could not be established or has lapsed. */
|
|
50
|
+
get isAuthError(): boolean;
|
|
51
|
+
/** Wrong/missing API key or a disallowed origin — a site-config problem,
|
|
52
|
+
* not something the end customer can fix. */
|
|
53
|
+
get isConfigError(): boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Public catalog reads for @bowlos/reservations — the "what can I book/buy here"
|
|
58
|
+
* surface that powers `<BookingCatalog>`. All anonymous (no customer login).
|
|
59
|
+
* Products + events + memberships are Center-scoped; packages + game cards are
|
|
60
|
+
* Brand-scoped (with an optional Center filter). Results are generic (`<T>`);
|
|
61
|
+
* the component types the display fields it needs.
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
type CenterScoped = {
|
|
65
|
+
centerId: string;
|
|
66
|
+
};
|
|
67
|
+
type BrandCatalogArgs = {
|
|
68
|
+
brandId: string;
|
|
69
|
+
centerId?: string;
|
|
70
|
+
};
|
|
71
|
+
/** Which public surface is asking — the backend applies that surface's
|
|
72
|
+
* per-category + per-offer visibility before returning. */
|
|
73
|
+
type PublicSurface = "sdk_custom_site" | "white_label_web" | "mobile_app";
|
|
74
|
+
type CatalogCategory = "bowling" | "other_attractions" | "events" | "packages" | "memberships" | "game_passes";
|
|
75
|
+
type CatalogActionType = "book_reservation" | "view_event" | "buy_ticket" | "buy_package" | "buy_membership" | "buy_game_pass";
|
|
76
|
+
type CatalogSourceTable = "products" | "event_offers" | "packages" | "membership_templates" | "game_card_templates";
|
|
77
|
+
/** A normalized, surface-agnostic catalog item. Route by `action.type`, using
|
|
78
|
+
* the IDs in `action.payload` (e.g. `productId`, `slug`, `packageId`,
|
|
79
|
+
* `templateId`). `priceLabel` is an indicative "from $X" only (null for
|
|
80
|
+
* products — show "See times & pricing"); the binding price comes from the
|
|
81
|
+
* per-category preview after login. */
|
|
82
|
+
interface CatalogItem {
|
|
83
|
+
id: string;
|
|
84
|
+
category: CatalogCategory;
|
|
85
|
+
sourceTable: CatalogSourceTable;
|
|
86
|
+
sourceId: string;
|
|
87
|
+
title: string;
|
|
88
|
+
subtitle?: string | null;
|
|
89
|
+
description?: string | null;
|
|
90
|
+
priceLabel?: string | null;
|
|
91
|
+
imageUrl?: string | null;
|
|
92
|
+
badgeLabel?: string | null;
|
|
93
|
+
action: {
|
|
94
|
+
type: CatalogActionType;
|
|
95
|
+
payload: Record<string, string>;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
interface CatalogSection {
|
|
99
|
+
key: CatalogCategory;
|
|
100
|
+
label: string;
|
|
101
|
+
items: CatalogItem[];
|
|
102
|
+
}
|
|
103
|
+
interface CatalogResult {
|
|
104
|
+
sections: CatalogSection[];
|
|
105
|
+
}
|
|
106
|
+
/** Args for the canonical catalog read. `surface` selects which visibility
|
|
107
|
+
* rules the backend applies. */
|
|
108
|
+
type CatalogArgs = {
|
|
109
|
+
brandId: string;
|
|
110
|
+
centerId: string;
|
|
111
|
+
surface: PublicSurface;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* The canonical public catalog for a surface — every active, public,
|
|
115
|
+
* bookable/sellable item grouped into the six first-class categories, with the
|
|
116
|
+
* Center admin's per-surface category + offer visibility already applied.
|
|
117
|
+
* Anonymous. This is the recommended way to list "everything bookable here":
|
|
118
|
+
* one call, all categories, visibility-aware, consistent with the white-label
|
|
119
|
+
* web + mobile surfaces.
|
|
120
|
+
*/
|
|
121
|
+
declare function listCatalog<T = CatalogResult>(client: BowlosClient, args: CatalogArgs): Promise<T>;
|
|
122
|
+
/** One package's full detail. `shareToken` reveals a hidden/unlisted package. */
|
|
123
|
+
type PackageDetailArgs = {
|
|
124
|
+
packageId: string;
|
|
125
|
+
shareToken?: string;
|
|
126
|
+
};
|
|
127
|
+
/** Args for a Center's operating-hours window on a date, across attraction types. */
|
|
128
|
+
type CenterHoursArgs = {
|
|
129
|
+
centerId: string;
|
|
130
|
+
attractionTypeKeys: string[];
|
|
131
|
+
dateISO: string;
|
|
132
|
+
};
|
|
133
|
+
/** Bookable products at a Center (each carries its attraction + `attractionTypeKey`). */
|
|
134
|
+
declare function listProducts<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
135
|
+
/** Upcoming pricing events (NYE Bash, tournaments…) at a Center. */
|
|
136
|
+
declare function listEvents<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
137
|
+
/** Sellable event offers at a Center. These are the public lineup + event
|
|
138
|
+
* landing-page records; use this instead of `listEvents` when routing a
|
|
139
|
+
* customer to an event purchase flow. */
|
|
140
|
+
declare function listEventOffers<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
141
|
+
/** One sellable event offer by landing-page slug. */
|
|
142
|
+
declare function getEventOffer<T = unknown>(client: BowlosClient, args: {
|
|
143
|
+
slug: string;
|
|
144
|
+
}): Promise<T>;
|
|
145
|
+
/** Purchasable packages at a Brand. */
|
|
146
|
+
declare function listPackages<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
|
|
147
|
+
/** Full detail for one package — components, optional add-ons, allowed start
|
|
148
|
+
* times, duration, and quantity bounds. Drives the headless package config UI
|
|
149
|
+
* (see HEADLESS.md → "Buying a package"). */
|
|
150
|
+
declare function getPackage<T = unknown>(client: BowlosClient, args: PackageDetailArgs): Promise<T>;
|
|
151
|
+
/** A Center's combined open/close window (minutes-from-midnight) for the given
|
|
152
|
+
* attraction types on a date — the intersection across types; `null` if closed.
|
|
153
|
+
* Bound a package's start times with its component attraction-type keys. */
|
|
154
|
+
declare function getCenterHours<T = unknown>(client: BowlosClient, args: CenterHoursArgs): Promise<T>;
|
|
155
|
+
/** Purchasable memberships at a Center. */
|
|
156
|
+
declare function listPublicMemberships<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
157
|
+
/** Purchasable game cards / passes at a Brand. */
|
|
158
|
+
declare function listGameCards<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
|
|
159
|
+
|
|
160
|
+
export { BOWLOS_ERROR_CODES as B, type CatalogActionType as C, type PackageDetailArgs as P, BowlosApiError as a, type BowlosApiErrorOptions as b, type BowlosErrorCode as c, type BrandCatalogArgs as d, type CatalogArgs as e, type CatalogCategory as f, type CatalogItem as g, type CatalogResult as h, type CatalogSection as i, type CatalogSourceTable as j, type CenterHoursArgs as k, type CenterScoped as l, type PublicSurface as m, getCenterHours as n, getEventOffer as o, getPackage as p, listCatalog as q, listEventOffers as r, listEvents as s, listGameCards as t, listPackages as u, listProducts as v, listPublicMemberships as w };
|