@bowlos/reservations 0.22.0 → 0.23.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 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
@@ -233,6 +243,15 @@ const bookingArgs = {
233
243
  Either way: it's the **platform** key scoped to `connectedAccountId`, and saved
234
244
  cards require `customerSessionClientSecret`.
235
245
 
246
+ > **`merchantDisplayName` (2026-06-20):** the PaymentIntent actions now also
247
+ > return `merchantDisplayName` — the white-label name of the selling Center (or
248
+ > Brand for brand-scoped buys), never "BowlOS". This exists for the **native
249
+ > mobile** `PaymentSheet` header. Web **Stripe Elements has no
250
+ > `merchantDisplayName`** concept (the merchant shown on the card mandate comes
251
+ > from the connected account), so a **headless web site can ignore this field** —
252
+ > no change required. It's documented here only so you know what the new
253
+ > response key is.
254
+
236
255
  ---
237
256
 
238
257
  ## Flow lifecycle, reset & error handling — required for a clean install
@@ -354,7 +373,10 @@ read the full offer with `useEventOffer({ slug })`.
354
373
  For `purchaseMode: "reservation"`, start the normal booking flow with the
355
374
  offer's `productId`, preselect `date`, `startMinuteOfDay`, and duration
356
375
  (`endMinuteOfDay - startMinuteOfDay`) when present, and preselect
357
- `includedAddons`. Pass `eventOfferSlug: offer.slug` into both
376
+ `includedAddons` — these are the offer's PRE-SELECTED add-ons, charged at
377
+ their normal add-on price on top of the event plan rate (they are not
378
+ free); initialize each add-on's quantity to the configured amount and let
379
+ the customer adjust. Pass `eventOfferSlug: offer.slug` into both
358
380
  `useBookingPreview` and the booking hold/create call (`useBookingFlow.startHold`
359
381
  or `createBooking`). The server uses that slug to bind the quote to the offer's
360
382
  event price plan, tax override, and Center fee override/inheritance. Then
@@ -711,6 +733,36 @@ Headless function twins (non-React):
711
733
  `createMembershipSubscriptionOrder(client, { templateId })`. (No status twin —
712
734
  subscriptions materialize via webhook; read `getMyMemberships(client, { brandId })`.)
713
735
 
736
+ ## Booking a flash-sale item at the sale price (headless)
737
+
738
+ A flash-sale reservation item books through a **purpose-built path** — never
739
+ the regular booking calendar (the sale price only exists on the sale's own
740
+ dates/blocks). All reads/creates are signed-in only.
741
+
742
+ 1. **List + landing**: `useFlashSales({ brandId })` for the index,
743
+ `useFlashSale({ slug })` for the sale page (anonymous gets the locked
744
+ view; members see prices).
745
+ 2. **Options**: `useFlashSaleBookingOptions({ slug, itemId })` (twin:
746
+ `getFlashSaleBookingOptions`) returns the bookable date/time-block
747
+ options **with the per-option sale price** for one reservation item
748
+ (`kind: "ok"` → `options[]`; handle `"signin_required"` /
749
+ `"unavailable"`). Render ONLY these options.
750
+ 3. **Book at the sale price** (v0.22.1): `createFlashSaleBooking(client,
751
+ { slug, itemId, dateISO, startMinuteOfDay, durationMinutes, units,
752
+ idempotencyKey })` — the flash analog of `eventOfferSlug`: the server
753
+ binds the item's SALE price, holds the inventory, and opens a checkout.
754
+ Returns `{ refToken, amountDueCents, holdExpiresAt, breakdown }` where
755
+ `breakdown` itemizes base (at the sale price) + tax + the Center fee —
756
+ render it as the static Review.
757
+ 4. **Pay + materialize** — the standard checkout pair:
758
+ `createCheckoutPaymentIntent(client, { refToken })` → confirm with your
759
+ Elements or `<BowlosPaymentForm>` → poll
760
+ `getCheckoutStatus(client, refToken)` to `"confirmed"` for the
761
+ reservation id. `abandonCheckout(client, refToken)` on back-out.
762
+
763
+ Never self-serve a flash booking through `bookingPreview`/`createBooking` —
764
+ those quote the REGULAR rate.
765
+
714
766
  ## The canonical catalog (visibility-aware) — `useCatalog`
715
767
 
716
768
  `<BookingCatalog>` assembles the catalog from five per-category reads
@@ -766,6 +818,77 @@ Public Catalog toggles. As of **v0.22.0** the drop-in `<BookingCatalog>` is
766
818
  built on this same read — its `onSelect` hands off a `CatalogItem`, so the
767
819
  drop-in and a headless site route identically (table above).
768
820
 
821
+ ## Self-serve cancel (v0.23.0)
822
+
823
+ Headless parity for the four self-serve cancels the BowlOS portal already has:
824
+ **reservation, event order, package order, game card**. Each is a
825
+ **preview → confirm → cancel** flow. Build the screen in your own design.
826
+
827
+ **Money rule (locked):** a self-serve cancel returns **store credit** per the
828
+ Center's cancellation policy (more credit the earlier you cancel). **Card refunds
829
+ are staff-only** — never promise money back to the card. **Game cards** are
830
+ cancellable **only while fully unused** (no games redeemed, not expired) → full
831
+ credit; a used/expired card is not customer-cancellable (tell them to contact the
832
+ venue). The previewed amount is **advisory** (computed when you read it); the
833
+ cancel re-computes authoritatively at confirm, so **re-read the preview right
834
+ before confirming** if the page has been open a while.
835
+
836
+ **Hooks (React):**
837
+
838
+ | Type | Preview hook | Cancel hook |
839
+ |---|---|---|
840
+ | Reservation | `useReservationCancelPreview({ brandId, reservationId })` | `useCancelMyReservation()` |
841
+ | Event order | `useEventOrderCancelPreview({ brandId, orderId })` | `useCancelMyEventOrder()` |
842
+ | Package order | `usePackageOrderCancelPreview({ brandId, orderId })` | `useCancelMyPackageOrder()` |
843
+ | Game card | `useGameCardCancelPreview({ brandId, cardId })` | `useCancelMyGameCard()` |
844
+
845
+ Plus `useMyGameCards({ brandId })` to list the customer's cards (each row carries
846
+ a `cancellable` flag = the unused-only rule). Reservations/event/package orders
847
+ come from the existing `useMyReservations` / `useMyEventOrders` /
848
+ `useMyPackageOrders` reads. For a reservation cancel, pass the reservation's
849
+ `version` (now returned by `listMyReservations`) as `expectedVersion`.
850
+
851
+ ```tsx
852
+ function CancelGameCard({ brandId, cardId }: { brandId: string; cardId: string }) {
853
+ const preview = useGameCardCancelPreview({ brandId, cardId });
854
+ const cancel = useCancelMyGameCard();
855
+ if (!preview.data) return null;
856
+ if (!preview.data.cancellable) {
857
+ return <p>This card can't be cancelled online: {preview.data.reason}. Contact the venue.</p>;
858
+ }
859
+ return (
860
+ <div>
861
+ <p>You'll get {formatCents(preview.data.creditCents)} as store credit.</p>
862
+ <button
863
+ disabled={cancel.loading}
864
+ onClick={async () => {
865
+ await cancel.run({ brandId, cardId }); // hook supplies the idempotency key
866
+ // re-read useMyGameCards / show cancel.data.creditCents
867
+ }}
868
+ >
869
+ {cancel.loading ? "Cancelling…" : "Cancel for store credit"}
870
+ </button>
871
+ {cancel.error && <p role="alert">{cancel.error.message}</p>}
872
+ </div>
873
+ );
874
+ }
875
+ ```
876
+
877
+ Reservation/event/package read the same way — the preview returns `bucket`
878
+ (e.g. `full_credit` / `partial_credit` / `forfeit`), `hoursBeforeStart`,
879
+ `creditCents`, and `forfeitCents`; show the bucket so the customer understands a
880
+ late cancel returns less.
881
+
882
+ **Idempotency / retries.** The cancel hooks generate a fresh key per attempt, so
883
+ a double-click can't double-cancel. Retrying an already-cancelled item returns an
884
+ error (the credit ledger dedupes — no double credit); treat "already cancelled"
885
+ as done and re-read the list.
886
+
887
+ **Non-React.** Use the core functions with a `BowlosClient`:
888
+ `previewGameCardCancellation(client, …)`, `cancelMyGameCard(client, { …, idempotencyKey })`,
889
+ `getMyGameCards(client, { brandId })`, etc. (generate the key with
890
+ `generateIdempotencyKey()`).
891
+
769
892
  ## Adopting changes by version
770
893
 
771
894
  What each SDK release changed in `<BookingFlow>` and the headless steps to match.
@@ -790,5 +913,9 @@ Headless sites do **not** get these from a version bump — apply them by hand.
790
913
 
791
914
  | **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". |
792
915
 
916
+ | **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. |
917
+
918
+ | **0.23.0** | **Self-serve cancel parity** — preview + cancel hooks for all four types (`useReservationCancelPreview`/`useCancelMyReservation`, `useEventOrderCancelPreview`/`useCancelMyEventOrder`, `usePackageOrderCancelPreview`/`useCancelMyPackageOrder`, `useGameCardCancelPreview`/`useCancelMyGameCard`) + `useMyGameCards`; framework-free core fns mirror them. `listMyReservations` now returns `version`. | New "Self-serve cancel" section. Build a preview → confirm → cancel screen per type in your own design. Store credit only (card refunds stay staff-only); game cards cancel only while fully unused. Pass the reservation `version` as `expectedVersion`. Re-read the preview right before confirming. |
919
+
793
920
  When you add the next release here, add its row **and** any new capability-map
794
921
  section in the same PR.
package/README.md CHANGED
@@ -156,10 +156,17 @@ a one-time membership" / "Buying a recurring membership"**.
156
156
  ## Account + flash sales
157
157
 
158
158
  Signed-in reads (require a customer session): `useMyReservations`,
159
- `useMyMemberships`, `useMyLoyalty`, `useMyCredits`, `useMyPasses`, plus details.
159
+ `useMyMemberships`, `useMyLoyalty`, `useMyCredits`, `useMyPasses`,
160
+ `useMyGameCards`, plus details.
160
161
  Session-aware flash sales: `useFlashSale`, `useFlashSaleBookingOptions`. Manage
161
162
  the session with `useAccount` (`signIn` / `signUp` / `link` / `signOut`).
162
163
 
164
+ **Self-serve cancel (v0.23.0):** preview → confirm → cancel for reservations,
165
+ event orders, package orders, and game cards — e.g. `useGameCardCancelPreview`
166
+ + `useCancelMyGameCard`. Returns **store credit** per the Center's policy (card
167
+ refunds stay staff-only); game cards cancel only while fully unused. See the
168
+ "Self-serve cancel" section of `HEADLESS.md`.
169
+
163
170
  Every read also has a framework-agnostic function in the core entry
164
171
  (`checkAvailability`, `bookingPreview`, `getMyReservations`, `runDoctor`, …) for
165
172
  non-React or server use.
@@ -0,0 +1,165 @@
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 getMyGameCards<T = MyGameCard[]>(client: BowlosClient, args: BrandScoped): Promise<T>;
50
+ /** Outcome preview shared by all four cancel types. `bucket`/`hoursBeforeStart`/
51
+ * `forfeitCents` are inert (null/0) for game cards (no time policy). */
52
+ interface CancelPreview {
53
+ cancellable: boolean;
54
+ reason: string | null;
55
+ bucket: string | null;
56
+ hoursBeforeStart: number;
57
+ creditCents: number;
58
+ forfeitCents: number;
59
+ paidCents: number;
60
+ }
61
+ interface CancelResult {
62
+ id: string;
63
+ status: string;
64
+ creditCents: number;
65
+ bucket?: string | null;
66
+ hoursBeforeStart?: number;
67
+ forfeitCents?: number;
68
+ version?: number;
69
+ }
70
+ interface MyGameCard {
71
+ id: string;
72
+ displayId: string;
73
+ cardName: string;
74
+ status: "active" | "depleted" | "expired" | "cancelled" | "refunded";
75
+ totalGames: number;
76
+ remainingGames: number;
77
+ shoesIncluded: boolean;
78
+ purchasedAt: number;
79
+ expiresAt: number;
80
+ paidCents: number;
81
+ /** Precomputed unused-only rule; the per-card preview is the source of truth. */
82
+ cancellable: boolean;
83
+ }
84
+ type ReservationCancelArgs = {
85
+ brandId: string;
86
+ reservationId: string;
87
+ expectedVersion: number;
88
+ reason?: string;
89
+ /** Per-attempt key; safe to retry. */
90
+ idempotencyKey: string;
91
+ };
92
+ type OrderCancelArgs = {
93
+ brandId: string;
94
+ orderId: string;
95
+ reason?: string;
96
+ idempotencyKey: string;
97
+ };
98
+ type GameCardCancelArgs = {
99
+ brandId: string;
100
+ cardId: string;
101
+ reason?: string;
102
+ idempotencyKey: string;
103
+ };
104
+ declare function previewReservationCancellation<T = CancelPreview>(client: BowlosClient, args: {
105
+ brandId: string;
106
+ reservationId: string;
107
+ }): Promise<T>;
108
+ declare function previewEventOrderCancellation<T = CancelPreview>(client: BowlosClient, args: {
109
+ brandId: string;
110
+ orderId: string;
111
+ }): Promise<T>;
112
+ declare function previewPackageOrderCancellation<T = CancelPreview>(client: BowlosClient, args: {
113
+ brandId: string;
114
+ orderId: string;
115
+ }): Promise<T>;
116
+ declare function previewGameCardCancellation<T = CancelPreview>(client: BowlosClient, args: {
117
+ brandId: string;
118
+ cardId: string;
119
+ }): Promise<T>;
120
+ declare function cancelMyReservation<T = CancelResult>(client: BowlosClient, args: ReservationCancelArgs): Promise<T>;
121
+ declare function cancelMyEventOrder<T = CancelResult>(client: BowlosClient, args: OrderCancelArgs): Promise<T>;
122
+ declare function cancelMyPackageOrder<T = CancelResult>(client: BowlosClient, args: OrderCancelArgs): Promise<T>;
123
+ declare function cancelMyGameCard<T = CancelResult>(client: BowlosClient, args: GameCardCancelArgs): Promise<T>;
124
+ declare function getFlashSale<T = unknown>(client: BowlosClient, args: FlashSaleArgs): Promise<T>;
125
+ /** The public flash-sale index for a Brand (live + upcoming; no prices). Public. */
126
+ declare function getFlashSales<T = unknown>(client: BowlosClient, args: FlashSalesArgs): Promise<T>;
127
+ declare function getFlashSaleBookingOptions<T = unknown>(client: BowlosClient, args: FlashBookingOptionsArgs): Promise<T>;
128
+ type CreateFlashSaleBookingArgs = {
129
+ slug: string;
130
+ itemId: string;
131
+ dateISO: string;
132
+ startMinuteOfDay: number;
133
+ durationMinutes: number;
134
+ units: number;
135
+ /** Per-attempt key; replays return the original checkout. */
136
+ idempotencyKey: string;
137
+ };
138
+ interface FlashSaleBookingResult {
139
+ /** Handle for the rest of the checkout: mint the PaymentIntent with
140
+ * `createCheckoutPaymentIntent(client, { refToken })`, then poll
141
+ * `getCheckoutStatus(client, refToken)` to materialization. */
142
+ refToken: string;
143
+ /** The SALE-priced total the PaymentIntent charges (base at the flash
144
+ * price + tax + the Center fee). */
145
+ amountDueCents: number;
146
+ holdExpiresAt: number;
147
+ breakdown: {
148
+ baseSubtotalCents: number;
149
+ reservationFeeCents: number;
150
+ reservationFeeLabel: string | null;
151
+ taxAddedCents: number;
152
+ taxIncludedCents: number;
153
+ totalCents: number;
154
+ };
155
+ }
156
+ /**
157
+ * v0.22.1 — book a flash-sale reservation item at its SALE price (the flash
158
+ * analog of `eventOfferSlug`: the server binds the item's sale price, holds
159
+ * the inventory, and opens a checkout). Signed-in customers only. Pick the
160
+ * date/time from `getFlashSaleBookingOptions` — the purpose-built option
161
+ * list — never the regular booking calendar.
162
+ */
163
+ declare function createFlashSaleBooking(client: BowlosClient, args: CreateFlashSaleBookingArgs): Promise<FlashSaleBookingResult>;
164
+
165
+ export { previewGameCardCancellation as A, type BrandScoped as B, type CancelPreview as C, previewPackageOrderCancellation as D, type EventOrderDetailArgs as E, type FlashBookingOptionsArgs as F, type GameCardCancelArgs as G, previewReservationCancellation as H, type MembershipDetailArgs as M, type OrderCancelArgs as O, type ReservationCancelArgs as R, type CancelResult as a, type CreateFlashSaleBookingArgs as b, type FlashSaleArgs as c, type FlashSaleBookingResult as d, type FlashSalesArgs as e, type MyGameCard as f, type ReservationDetailArgs as g, cancelMyEventOrder as h, cancelMyGameCard as i, cancelMyPackageOrder as j, cancelMyReservation as k, createFlashSaleBooking as l, getFlashSale as m, getFlashSaleBookingOptions as n, getFlashSales as o, getMyCredits as p, getMyEventOrder as q, getMyEventOrders as r, getMyGameCards as s, getMyLoyalty as t, getMyMembershipDetail as u, getMyMemberships as v, getMyPasses as w, getMyReservationDetail as x, getMyReservations as y, previewEventOrderCancellation as z };
@@ -0,0 +1,165 @@
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 getMyGameCards<T = MyGameCard[]>(client: BowlosClient, args: BrandScoped): Promise<T>;
50
+ /** Outcome preview shared by all four cancel types. `bucket`/`hoursBeforeStart`/
51
+ * `forfeitCents` are inert (null/0) for game cards (no time policy). */
52
+ interface CancelPreview {
53
+ cancellable: boolean;
54
+ reason: string | null;
55
+ bucket: string | null;
56
+ hoursBeforeStart: number;
57
+ creditCents: number;
58
+ forfeitCents: number;
59
+ paidCents: number;
60
+ }
61
+ interface CancelResult {
62
+ id: string;
63
+ status: string;
64
+ creditCents: number;
65
+ bucket?: string | null;
66
+ hoursBeforeStart?: number;
67
+ forfeitCents?: number;
68
+ version?: number;
69
+ }
70
+ interface MyGameCard {
71
+ id: string;
72
+ displayId: string;
73
+ cardName: string;
74
+ status: "active" | "depleted" | "expired" | "cancelled" | "refunded";
75
+ totalGames: number;
76
+ remainingGames: number;
77
+ shoesIncluded: boolean;
78
+ purchasedAt: number;
79
+ expiresAt: number;
80
+ paidCents: number;
81
+ /** Precomputed unused-only rule; the per-card preview is the source of truth. */
82
+ cancellable: boolean;
83
+ }
84
+ type ReservationCancelArgs = {
85
+ brandId: string;
86
+ reservationId: string;
87
+ expectedVersion: number;
88
+ reason?: string;
89
+ /** Per-attempt key; safe to retry. */
90
+ idempotencyKey: string;
91
+ };
92
+ type OrderCancelArgs = {
93
+ brandId: string;
94
+ orderId: string;
95
+ reason?: string;
96
+ idempotencyKey: string;
97
+ };
98
+ type GameCardCancelArgs = {
99
+ brandId: string;
100
+ cardId: string;
101
+ reason?: string;
102
+ idempotencyKey: string;
103
+ };
104
+ declare function previewReservationCancellation<T = CancelPreview>(client: BowlosClient, args: {
105
+ brandId: string;
106
+ reservationId: string;
107
+ }): Promise<T>;
108
+ declare function previewEventOrderCancellation<T = CancelPreview>(client: BowlosClient, args: {
109
+ brandId: string;
110
+ orderId: string;
111
+ }): Promise<T>;
112
+ declare function previewPackageOrderCancellation<T = CancelPreview>(client: BowlosClient, args: {
113
+ brandId: string;
114
+ orderId: string;
115
+ }): Promise<T>;
116
+ declare function previewGameCardCancellation<T = CancelPreview>(client: BowlosClient, args: {
117
+ brandId: string;
118
+ cardId: string;
119
+ }): Promise<T>;
120
+ declare function cancelMyReservation<T = CancelResult>(client: BowlosClient, args: ReservationCancelArgs): Promise<T>;
121
+ declare function cancelMyEventOrder<T = CancelResult>(client: BowlosClient, args: OrderCancelArgs): Promise<T>;
122
+ declare function cancelMyPackageOrder<T = CancelResult>(client: BowlosClient, args: OrderCancelArgs): Promise<T>;
123
+ declare function cancelMyGameCard<T = CancelResult>(client: BowlosClient, args: GameCardCancelArgs): Promise<T>;
124
+ declare function getFlashSale<T = unknown>(client: BowlosClient, args: FlashSaleArgs): Promise<T>;
125
+ /** The public flash-sale index for a Brand (live + upcoming; no prices). Public. */
126
+ declare function getFlashSales<T = unknown>(client: BowlosClient, args: FlashSalesArgs): Promise<T>;
127
+ declare function getFlashSaleBookingOptions<T = unknown>(client: BowlosClient, args: FlashBookingOptionsArgs): Promise<T>;
128
+ type CreateFlashSaleBookingArgs = {
129
+ slug: string;
130
+ itemId: string;
131
+ dateISO: string;
132
+ startMinuteOfDay: number;
133
+ durationMinutes: number;
134
+ units: number;
135
+ /** Per-attempt key; replays return the original checkout. */
136
+ idempotencyKey: string;
137
+ };
138
+ interface FlashSaleBookingResult {
139
+ /** Handle for the rest of the checkout: mint the PaymentIntent with
140
+ * `createCheckoutPaymentIntent(client, { refToken })`, then poll
141
+ * `getCheckoutStatus(client, refToken)` to materialization. */
142
+ refToken: string;
143
+ /** The SALE-priced total the PaymentIntent charges (base at the flash
144
+ * price + tax + the Center fee). */
145
+ amountDueCents: number;
146
+ holdExpiresAt: number;
147
+ breakdown: {
148
+ baseSubtotalCents: number;
149
+ reservationFeeCents: number;
150
+ reservationFeeLabel: string | null;
151
+ taxAddedCents: number;
152
+ taxIncludedCents: number;
153
+ totalCents: number;
154
+ };
155
+ }
156
+ /**
157
+ * v0.22.1 — book a flash-sale reservation item at its SALE price (the flash
158
+ * analog of `eventOfferSlug`: the server binds the item's sale price, holds
159
+ * the inventory, and opens a checkout). Signed-in customers only. Pick the
160
+ * date/time from `getFlashSaleBookingOptions` — the purpose-built option
161
+ * list — never the regular booking calendar.
162
+ */
163
+ declare function createFlashSaleBooking(client: BowlosClient, args: CreateFlashSaleBookingArgs): Promise<FlashSaleBookingResult>;
164
+
165
+ export { previewGameCardCancellation as A, type BrandScoped as B, type CancelPreview as C, previewPackageOrderCancellation as D, type EventOrderDetailArgs as E, type FlashBookingOptionsArgs as F, type GameCardCancelArgs as G, previewReservationCancellation as H, type MembershipDetailArgs as M, type OrderCancelArgs as O, type ReservationCancelArgs as R, type CancelResult as a, type CreateFlashSaleBookingArgs as b, type FlashSaleArgs as c, type FlashSaleBookingResult as d, type FlashSalesArgs as e, type MyGameCard as f, type ReservationDetailArgs as g, cancelMyEventOrder as h, cancelMyGameCard as i, cancelMyPackageOrder as j, cancelMyReservation as k, createFlashSaleBooking as l, getFlashSale as m, getFlashSaleBookingOptions as n, getFlashSales as o, getMyCredits as p, getMyEventOrder as q, getMyEventOrders as r, getMyGameCards as s, getMyLoyalty as t, getMyMembershipDetail as u, getMyMemberships as v, getMyPasses as w, getMyReservationDetail as x, getMyReservations as y, previewEventOrderCancellation as z };
@@ -1,4 +1,4 @@
1
- import { createBowlosClient, BowlosApiError, BOWLOS_ERROR_CODES, createBooking, createCheckoutPaymentIntent, getCheckoutStatus, abandonCheckout } from './chunk-S5T4OCBY.js';
1
+ import { createBowlosClient, BowlosApiError, generateIdempotencyKey, BOWLOS_ERROR_CODES, createBooking, createCheckoutPaymentIntent, getCheckoutStatus, abandonCheckout } from './chunk-S5T4OCBY.js';
2
2
  import { createContext, useRef, useContext, useState, useCallback, useEffect } from 'react';
3
3
  import { jsx } from 'react/jsx-runtime';
4
4
 
@@ -102,8 +102,36 @@ function useBowlosQuery(name, args = {}, options = {}) {
102
102
  }, [enabled, refetch]);
103
103
  return { data, error, loading, refetch };
104
104
  }
105
-
106
- // src/hooks.tsx
105
+ function useBowlosMutation(name, options = {}) {
106
+ const client = useBowlosClient();
107
+ const auth = options.auth ?? false;
108
+ const [data, setData] = useState(null);
109
+ const [error, setError] = useState(null);
110
+ const [loading, setLoading] = useState(false);
111
+ const run = useCallback(
112
+ async (args) => {
113
+ setLoading(true);
114
+ setError(null);
115
+ try {
116
+ const result = await client.call(name, args, { auth });
117
+ setData(result);
118
+ return result;
119
+ } catch (e) {
120
+ if (e instanceof BowlosApiError) setError(e);
121
+ throw e;
122
+ } finally {
123
+ setLoading(false);
124
+ }
125
+ },
126
+ [client, name, auth]
127
+ );
128
+ const reset = useCallback(() => {
129
+ setData(null);
130
+ setError(null);
131
+ setLoading(false);
132
+ }, []);
133
+ return { run, data, error, loading, reset };
134
+ }
107
135
  function useAvailability(args, options) {
108
136
  return useBowlosQuery("checkAvailability", args, options);
109
137
  }
@@ -143,6 +171,55 @@ function useMyCredits(args, options) {
143
171
  function useMyPasses(args, options) {
144
172
  return useBowlosQuery("listMyPasses", args, { ...options, auth: true });
145
173
  }
174
+ function useMyGameCards(args, options) {
175
+ return useBowlosQuery("listMyGameCards", args, { ...options, auth: true });
176
+ }
177
+ function useReservationCancelPreview(args, options) {
178
+ return useBowlosQuery("previewMyCancellation", args, { ...options, auth: true });
179
+ }
180
+ function useEventOrderCancelPreview(args, options) {
181
+ return useBowlosQuery("previewMyEventOrderCancellation", args, { ...options, auth: true });
182
+ }
183
+ function usePackageOrderCancelPreview(args, options) {
184
+ return useBowlosQuery("previewMyPackageOrderCancellation", args, { ...options, auth: true });
185
+ }
186
+ function useGameCardCancelPreview(args, options) {
187
+ return useBowlosQuery("previewMyGameCardCancellation", args, { ...options, auth: true });
188
+ }
189
+ function useCancelMyReservation() {
190
+ const m = useBowlosMutation("cancelMyReservation", {
191
+ auth: true
192
+ });
193
+ const run = useCallback(
194
+ (args) => m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),
195
+ [m]
196
+ );
197
+ return { ...m, run };
198
+ }
199
+ function useCancelMyEventOrder() {
200
+ const m = useBowlosMutation("cancelMyEventOrder", { auth: true });
201
+ const run = useCallback(
202
+ (args) => m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),
203
+ [m]
204
+ );
205
+ return { ...m, run };
206
+ }
207
+ function useCancelMyPackageOrder() {
208
+ const m = useBowlosMutation("cancelMyPackageOrder", { auth: true });
209
+ const run = useCallback(
210
+ (args) => m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),
211
+ [m]
212
+ );
213
+ return { ...m, run };
214
+ }
215
+ function useCancelMyGameCard() {
216
+ const m = useBowlosMutation("cancelMyGameCard", { auth: true });
217
+ const run = useCallback(
218
+ (args) => m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),
219
+ [m]
220
+ );
221
+ return { ...m, run };
222
+ }
146
223
  function useFlashSale(args, options) {
147
224
  return useBowlosQuery("getPublicFlashSaleBySlug", args, { ...options, auth: true });
148
225
  }
@@ -365,6 +442,6 @@ function useBookingFlow() {
365
442
  };
366
443
  }
367
444
 
368
- export { BowlosProvider, useAccount, useAddons, useAvailability, useBookingFlow, useBookingPreview, useBowlosClient, useBowlosQuery, useCatalog, useCenterHours, useEventOffer, useEventOffers, useEventTicketPreview, useEvents, useFlashSale, useFlashSaleBookingOptions, useFlashSales, useGameCardPreview, useGameCards, useMembershipPreview, useMembershipSubscriptionPreview, useMyCredits, useMyEventOrder, useMyEventOrders, useMyLoyalty, useMyMembershipDetail, useMyMemberships, useMyPasses, useMyReservationDetail, useMyReservations, usePackage, usePackagePreview, usePackages, useProducts, usePublicMemberships, useStartTimes };
369
- //# sourceMappingURL=chunk-FV6SROO2.js.map
370
- //# sourceMappingURL=chunk-FV6SROO2.js.map
445
+ export { BowlosProvider, useAccount, useAddons, useAvailability, useBookingFlow, useBookingPreview, useBowlosClient, useBowlosMutation, useBowlosQuery, useCancelMyEventOrder, useCancelMyGameCard, useCancelMyPackageOrder, useCancelMyReservation, useCatalog, useCenterHours, useEventOffer, useEventOffers, useEventOrderCancelPreview, useEventTicketPreview, useEvents, useFlashSale, useFlashSaleBookingOptions, useFlashSales, useGameCardCancelPreview, useGameCardPreview, useGameCards, useMembershipPreview, useMembershipSubscriptionPreview, useMyCredits, useMyEventOrder, useMyEventOrders, useMyGameCards, useMyLoyalty, useMyMembershipDetail, useMyMemberships, useMyPasses, useMyReservationDetail, useMyReservations, usePackage, usePackageOrderCancelPreview, usePackagePreview, usePackages, useProducts, usePublicMemberships, useReservationCancelPreview, useStartTimes };
446
+ //# sourceMappingURL=chunk-CRETIPLS.js.map
447
+ //# sourceMappingURL=chunk-CRETIPLS.js.map