@bowlos/reservations 0.21.0 → 0.22.1

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 CHANGED
@@ -135,6 +135,16 @@ const selectedAddons = Object.entries(qty).filter(([, q]) => q > 0).map(([addonI
135
135
  // Show priceCents with a rate suffix (/ person, / unit, flat) + a quantity stepper per addon.
136
136
  ```
137
137
 
138
+ **Included shoes are NOT a priced add-on.** The product read exposes
139
+ `shoeMode` + `defaultShoeAddonId` (also on `listProducts` rows), and a
140
+ reservation-mode event offer exposes `pricePlanShoeIncluded`. When
141
+ `product.shoeMode === "included"` — or, in an event funnel,
142
+ `offer.pricePlanShoeIncluded === true` — the engine charges $0 for the shoe
143
+ add-on no matter what quantity is sent. Do NOT render the shoe add-on
144
+ (`defaultShoeAddonId`) as a priced stepper in that case: show a static
145
+ "Shoe rental — included" note instead and send no quantity. Rendering a
146
+ priced stepper that doesn't change the total misleads the customer.
147
+
138
148
  ### 7. Review step — an order summary before payment
139
149
 
140
150
  Match the branded portal: selection → **review** → payment. After the customer
@@ -354,7 +364,10 @@ read the full offer with `useEventOffer({ slug })`.
354
364
  For `purchaseMode: "reservation"`, start the normal booking flow with the
355
365
  offer's `productId`, preselect `date`, `startMinuteOfDay`, and duration
356
366
  (`endMinuteOfDay - startMinuteOfDay`) when present, and preselect
357
- `includedAddons`. Pass `eventOfferSlug: offer.slug` into both
367
+ `includedAddons` — these are the offer's PRE-SELECTED add-ons, charged at
368
+ their normal add-on price on top of the event plan rate (they are not
369
+ free); initialize each add-on's quantity to the configured amount and let
370
+ the customer adjust. Pass `eventOfferSlug: offer.slug` into both
358
371
  `useBookingPreview` and the booking hold/create call (`useBookingFlow.startHold`
359
372
  or `createBooking`). The server uses that slug to bind the quote to the offer's
360
373
  event price plan, tax override, and Center fee override/inheritance. Then
@@ -711,6 +724,36 @@ Headless function twins (non-React):
711
724
  `createMembershipSubscriptionOrder(client, { templateId })`. (No status twin —
712
725
  subscriptions materialize via webhook; read `getMyMemberships(client, { brandId })`.)
713
726
 
727
+ ## Booking a flash-sale item at the sale price (headless)
728
+
729
+ A flash-sale reservation item books through a **purpose-built path** — never
730
+ the regular booking calendar (the sale price only exists on the sale's own
731
+ dates/blocks). All reads/creates are signed-in only.
732
+
733
+ 1. **List + landing**: `useFlashSales({ brandId })` for the index,
734
+ `useFlashSale({ slug })` for the sale page (anonymous gets the locked
735
+ view; members see prices).
736
+ 2. **Options**: `useFlashSaleBookingOptions({ slug, itemId })` (twin:
737
+ `getFlashSaleBookingOptions`) returns the bookable date/time-block
738
+ options **with the per-option sale price** for one reservation item
739
+ (`kind: "ok"` → `options[]`; handle `"signin_required"` /
740
+ `"unavailable"`). Render ONLY these options.
741
+ 3. **Book at the sale price** (v0.22.1): `createFlashSaleBooking(client,
742
+ { slug, itemId, dateISO, startMinuteOfDay, durationMinutes, units,
743
+ idempotencyKey })` — the flash analog of `eventOfferSlug`: the server
744
+ binds the item's SALE price, holds the inventory, and opens a checkout.
745
+ Returns `{ refToken, amountDueCents, holdExpiresAt, breakdown }` where
746
+ `breakdown` itemizes base (at the sale price) + tax + the Center fee —
747
+ render it as the static Review.
748
+ 4. **Pay + materialize** — the standard checkout pair:
749
+ `createCheckoutPaymentIntent(client, { refToken })` → confirm with your
750
+ Elements or `<BowlosPaymentForm>` → poll
751
+ `getCheckoutStatus(client, refToken)` to `"confirmed"` for the
752
+ reservation id. `abandonCheckout(client, refToken)` on back-out.
753
+
754
+ Never self-serve a flash booking through `bookingPreview`/`createBooking` —
755
+ those quote the REGULAR rate.
756
+
714
757
  ## The canonical catalog (visibility-aware) — `useCatalog`
715
758
 
716
759
  `<BookingCatalog>` assembles the catalog from five per-category reads
@@ -762,9 +805,9 @@ after login. The framework-agnostic twin is `listCatalog(client, args)`.
762
805
 
763
806
  `useCatalog` keeps the SDK custom site consistent with the white-label web and
764
807
  mobile surfaces (all three consume the same backend read) and honors the admin
765
- Public Catalog toggles. `<BookingCatalog>` itself still uses the per-category
766
- hooks; migrating it to `useCatalog` (a breaking `onSelect` shape change) is a
767
- future coordinated release.
808
+ Public Catalog toggles. As of **v0.22.0** the drop-in `<BookingCatalog>` is
809
+ built on this same read — its `onSelect` hands off a `CatalogItem`, so the
810
+ drop-in and a headless site route identically (table above).
768
811
 
769
812
  ## Adopting changes by version
770
813
 
@@ -788,5 +831,9 @@ Headless sites do **not** get these from a version bump — apply them by hand.
788
831
  | **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
832
  | **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
833
 
834
+ | **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". |
835
+
836
+ | **0.22.1** | **Pay-button mount race fixed** (`<BowlosPaymentForm>` submit disabled until BOTH Stripe.js and the PaymentElement are mounted — a click during mount was a silent no-op) · **headless flash-sale checkout** — new `createFlashSaleBooking` (+ exported `CreateFlashSaleBookingArgs`/`FlashSaleBookingResult`) completing the options → book-at-sale-price → pay → poll path · docs: "Booking a flash-sale item" section; §6 included-shoes rule (`shoeMode`/`defaultShoeAddonId` + `offer.pricePlanShoeIncluded` — render "Included", never a priced stepper); event `includedAddons` are pre-selected AND charged | Custom payment UIs: mirror the disabled rule (`!stripe \|\| !elements \|\| submitting`). Flash funnels: adopt the new section (stop handing off / blocking). Event + bowling funnels: adopt the included-shoes rule in §6. |
837
+
791
838
  When you add the next release here, add its row **and** any new capability-map
792
839
  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?" It lists everything the center sells online under
199
- category headings (**Bowling**, **Other attractions**, **Events**, **Packages**,
200
- **Memberships**, **Game passes**) and hands off each pick via `onSelect`: a
201
- `product` or `event` → your `<BookingFlow>` (preset the event's date); a
202
- `package` / `membership` / `gamecard` → its buy page.
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,20 +209,25 @@ import { BookingCatalog } from "@bowlos/reservations/components";
207
209
  <BookingCatalog
208
210
  brandId="brand_…"
209
211
  centerId="center_…"
210
- onSelect={(o) =>
211
- o.kind === "product" || o.kind === "event"
212
- ? router.push(`/book?productId=${o.id}`)
213
- : router.push(`/buy?kind=${o.kind}&id=${o.id}`)
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
 
218
- For a **visibility-aware** catalog (the Center admin's per-surface Public Catalog
219
- toggles applied, consistent with the white-label web + mobile surfaces), build
220
- your own listing from the **`useCatalog({ brandId, centerId, surface })`** hook
221
- (framework-agnostic twin: `listCatalog`) instead of the per-category hooks. It
222
- returns the six categories grouped; route each item by `action.type`. See
223
- HEADLESS.md → "The canonical catalog".
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`.
224
231
 
225
232
  The drop-in surfaces cover a center site end to end:
226
233
 
@@ -0,0 +1,90 @@
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
+ type CreateFlashSaleBookingArgs = {
54
+ slug: string;
55
+ itemId: string;
56
+ dateISO: string;
57
+ startMinuteOfDay: number;
58
+ durationMinutes: number;
59
+ units: number;
60
+ /** Per-attempt key; replays return the original checkout. */
61
+ idempotencyKey: string;
62
+ };
63
+ interface FlashSaleBookingResult {
64
+ /** Handle for the rest of the checkout: mint the PaymentIntent with
65
+ * `createCheckoutPaymentIntent(client, { refToken })`, then poll
66
+ * `getCheckoutStatus(client, refToken)` to materialization. */
67
+ refToken: string;
68
+ /** The SALE-priced total the PaymentIntent charges (base at the flash
69
+ * price + tax + the Center fee). */
70
+ amountDueCents: number;
71
+ holdExpiresAt: number;
72
+ breakdown: {
73
+ baseSubtotalCents: number;
74
+ reservationFeeCents: number;
75
+ reservationFeeLabel: string | null;
76
+ taxAddedCents: number;
77
+ taxIncludedCents: number;
78
+ totalCents: number;
79
+ };
80
+ }
81
+ /**
82
+ * v0.22.1 — book a flash-sale reservation item at its SALE price (the flash
83
+ * analog of `eventOfferSlug`: the server binds the item's sale price, holds
84
+ * the inventory, and opens a checkout). Signed-in customers only. Pick the
85
+ * date/time from `getFlashSaleBookingOptions` — the purpose-built option
86
+ * list — never the regular booking calendar.
87
+ */
88
+ declare function createFlashSaleBooking(client: BowlosClient, args: CreateFlashSaleBookingArgs): Promise<FlashSaleBookingResult>;
89
+
90
+ export { type BrandScoped as B, type CreateFlashSaleBookingArgs as C, type EventOrderDetailArgs as E, type FlashBookingOptionsArgs as F, type MembershipDetailArgs as M, type ReservationDetailArgs as R, type FlashSaleArgs as a, type FlashSaleBookingResult as b, type FlashSalesArgs as c, createFlashSaleBooking as d, getFlashSaleBookingOptions as e, getFlashSales as f, getFlashSale as g, getMyCredits as h, getMyEventOrder as i, getMyEventOrders as j, getMyLoyalty as k, getMyMembershipDetail as l, getMyMemberships as m, getMyPasses as n, getMyReservationDetail as o, getMyReservations as p };
@@ -0,0 +1,90 @@
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
+ type CreateFlashSaleBookingArgs = {
54
+ slug: string;
55
+ itemId: string;
56
+ dateISO: string;
57
+ startMinuteOfDay: number;
58
+ durationMinutes: number;
59
+ units: number;
60
+ /** Per-attempt key; replays return the original checkout. */
61
+ idempotencyKey: string;
62
+ };
63
+ interface FlashSaleBookingResult {
64
+ /** Handle for the rest of the checkout: mint the PaymentIntent with
65
+ * `createCheckoutPaymentIntent(client, { refToken })`, then poll
66
+ * `getCheckoutStatus(client, refToken)` to materialization. */
67
+ refToken: string;
68
+ /** The SALE-priced total the PaymentIntent charges (base at the flash
69
+ * price + tax + the Center fee). */
70
+ amountDueCents: number;
71
+ holdExpiresAt: number;
72
+ breakdown: {
73
+ baseSubtotalCents: number;
74
+ reservationFeeCents: number;
75
+ reservationFeeLabel: string | null;
76
+ taxAddedCents: number;
77
+ taxIncludedCents: number;
78
+ totalCents: number;
79
+ };
80
+ }
81
+ /**
82
+ * v0.22.1 — book a flash-sale reservation item at its SALE price (the flash
83
+ * analog of `eventOfferSlug`: the server binds the item's sale price, holds
84
+ * the inventory, and opens a checkout). Signed-in customers only. Pick the
85
+ * date/time from `getFlashSaleBookingOptions` — the purpose-built option
86
+ * list — never the regular booking calendar.
87
+ */
88
+ declare function createFlashSaleBooking(client: BowlosClient, args: CreateFlashSaleBookingArgs): Promise<FlashSaleBookingResult>;
89
+
90
+ export { type BrandScoped as B, type CreateFlashSaleBookingArgs as C, type EventOrderDetailArgs as E, type FlashBookingOptionsArgs as F, type MembershipDetailArgs as M, type ReservationDetailArgs as R, type FlashSaleArgs as a, type FlashSaleBookingResult as b, type FlashSalesArgs as c, createFlashSaleBooking as d, getFlashSaleBookingOptions as e, getFlashSales as f, getFlashSale as g, getMyCredits as h, getMyEventOrder as i, getMyEventOrders as j, getMyLoyalty as k, getMyMembershipDetail as l, getMyMemberships as m, getMyPasses as n, getMyReservationDetail as o, getMyReservations as p };
@@ -1,55 +1,57 @@
1
1
  import { g as BowlosClient } from './data-BKlgn8Ln.js';
2
2
 
3
3
  /**
4
- * Typed account + flash reads for @bowlos/reservations.
4
+ * Error model for the BowlOS Reservations SDK.
5
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`.
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
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;
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";
29
33
  };
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>;
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
+ }
53
55
 
54
56
  /**
55
57
  * Public catalog reads for @bowlos/reservations — the "what can I book/buy here"
@@ -155,4 +157,4 @@ declare function listPublicMemberships<T = unknown>(client: BowlosClient, args:
155
157
  /** Purchasable game cards / passes at a Brand. */
156
158
  declare function listGameCards<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
157
159
 
158
- export { getPackage as A, type BrandCatalogArgs as B, type CatalogActionType as C, listCatalog as D, type EventOrderDetailArgs as E, type FlashBookingOptionsArgs as F, listEventOffers as G, listEvents as H, listGameCards as I, listPackages as J, listProducts as K, listPublicMemberships as L, type MembershipDetailArgs as M, type PackageDetailArgs as P, type ReservationDetailArgs as R, type BrandScoped as a, type CatalogArgs as b, type CatalogCategory as c, type CatalogItem as d, type CatalogResult as e, type CatalogSection as f, type CatalogSourceTable as g, type CenterHoursArgs as h, type CenterScoped as i, type FlashSaleArgs as j, type FlashSalesArgs as k, type PublicSurface as l, getCenterHours as m, getEventOffer as n, getFlashSale as o, getFlashSaleBookingOptions as p, getFlashSales as q, getMyCredits as r, getMyEventOrder as s, getMyEventOrders as t, getMyLoyalty as u, getMyMembershipDetail as v, getMyMemberships as w, getMyPasses as x, getMyReservationDetail as y, getMyReservations as z };
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 };
@@ -1,55 +1,57 @@
1
1
  import { g as BowlosClient } from './data-BKlgn8Ln.cjs';
2
2
 
3
3
  /**
4
- * Typed account + flash reads for @bowlos/reservations.
4
+ * Error model for the BowlOS Reservations SDK.
5
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`.
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
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;
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";
29
33
  };
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>;
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
+ }
53
55
 
54
56
  /**
55
57
  * Public catalog reads for @bowlos/reservations — the "what can I book/buy here"
@@ -155,4 +157,4 @@ declare function listPublicMemberships<T = unknown>(client: BowlosClient, args:
155
157
  /** Purchasable game cards / passes at a Brand. */
156
158
  declare function listGameCards<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
157
159
 
158
- export { getPackage as A, type BrandCatalogArgs as B, type CatalogActionType as C, listCatalog as D, type EventOrderDetailArgs as E, type FlashBookingOptionsArgs as F, listEventOffers as G, listEvents as H, listGameCards as I, listPackages as J, listProducts as K, listPublicMemberships as L, type MembershipDetailArgs as M, type PackageDetailArgs as P, type ReservationDetailArgs as R, type BrandScoped as a, type CatalogArgs as b, type CatalogCategory as c, type CatalogItem as d, type CatalogResult as e, type CatalogSection as f, type CatalogSourceTable as g, type CenterHoursArgs as h, type CenterScoped as i, type FlashSaleArgs as j, type FlashSalesArgs as k, type PublicSurface as l, getCenterHours as m, getEventOffer as n, getFlashSale as o, getFlashSaleBookingOptions as p, getFlashSales as q, getMyCredits as r, getMyEventOrder as s, getMyEventOrders as t, getMyLoyalty as u, getMyMembershipDetail as v, getMyMemberships as w, getMyPasses as x, getMyReservationDetail as y, getMyReservations as z };
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 };