@bowlos/reservations 0.22.1 → 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 +82 -0
- package/README.md +8 -1
- package/dist/{account-Bm2XnaYS.d.ts → account-B9tDfXke.d.ts} +76 -1
- package/dist/{account-CSaBohMT.d.cts → account-C9SvfE3q.d.cts} +76 -1
- package/dist/{chunk-FV6SROO2.js → chunk-CRETIPLS.js} +83 -6
- package/dist/chunk-CRETIPLS.js.map +1 -0
- package/dist/components.cjs +32 -34
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +1 -1
- package/dist/index.cjs +36 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +28 -1
- package/dist/index.js.map +1 -1
- package/dist/{react-Bc_6yi9q.d.cts → react--BT8olOw.d.cts} +14 -1
- package/dist/{react-B1uSOozS.d.ts → react-BvuU4nzT.d.ts} +14 -1
- package/dist/react.cjs +185 -98
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +36 -9
- package/dist/react.d.ts +36 -9
- package/dist/react.js +2 -2
- package/package.json +1 -1
- package/templates/center-site/package.json +1 -1
- package/dist/chunk-FV6SROO2.js.map +0 -1
package/HEADLESS.md
CHANGED
|
@@ -243,6 +243,15 @@ const bookingArgs = {
|
|
|
243
243
|
Either way: it's the **platform** key scoped to `connectedAccountId`, and saved
|
|
244
244
|
cards require `customerSessionClientSecret`.
|
|
245
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
|
+
|
|
246
255
|
---
|
|
247
256
|
|
|
248
257
|
## Flow lifecycle, reset & error handling — required for a clean install
|
|
@@ -809,6 +818,77 @@ Public Catalog toggles. As of **v0.22.0** the drop-in `<BookingCatalog>` is
|
|
|
809
818
|
built on this same read — its `onSelect` hands off a `CatalogItem`, so the
|
|
810
819
|
drop-in and a headless site route identically (table above).
|
|
811
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
|
+
|
|
812
892
|
## Adopting changes by version
|
|
813
893
|
|
|
814
894
|
What each SDK release changed in `<BookingFlow>` and the headless steps to match.
|
|
@@ -835,5 +915,7 @@ Headless sites do **not** get these from a version bump — apply them by hand.
|
|
|
835
915
|
|
|
836
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. |
|
|
837
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
|
+
|
|
838
920
|
When you add the next release here, add its row **and** any new capability-map
|
|
839
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`,
|
|
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.
|
|
@@ -46,6 +46,81 @@ declare function getMyMembershipDetail<T = unknown>(client: BowlosClient, args:
|
|
|
46
46
|
declare function getMyLoyalty<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
47
47
|
declare function getMyCredits<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
48
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>;
|
|
49
124
|
declare function getFlashSale<T = unknown>(client: BowlosClient, args: FlashSaleArgs): Promise<T>;
|
|
50
125
|
/** The public flash-sale index for a Brand (live + upcoming; no prices). Public. */
|
|
51
126
|
declare function getFlashSales<T = unknown>(client: BowlosClient, args: FlashSalesArgs): Promise<T>;
|
|
@@ -87,4 +162,4 @@ interface FlashSaleBookingResult {
|
|
|
87
162
|
*/
|
|
88
163
|
declare function createFlashSaleBooking(client: BowlosClient, args: CreateFlashSaleBookingArgs): Promise<FlashSaleBookingResult>;
|
|
89
164
|
|
|
90
|
-
export { type BrandScoped as B, type
|
|
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 };
|
|
@@ -46,6 +46,81 @@ declare function getMyMembershipDetail<T = unknown>(client: BowlosClient, args:
|
|
|
46
46
|
declare function getMyLoyalty<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
47
47
|
declare function getMyCredits<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
48
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>;
|
|
49
124
|
declare function getFlashSale<T = unknown>(client: BowlosClient, args: FlashSaleArgs): Promise<T>;
|
|
50
125
|
/** The public flash-sale index for a Brand (live + upcoming; no prices). Public. */
|
|
51
126
|
declare function getFlashSales<T = unknown>(client: BowlosClient, args: FlashSalesArgs): Promise<T>;
|
|
@@ -87,4 +162,4 @@ interface FlashSaleBookingResult {
|
|
|
87
162
|
*/
|
|
88
163
|
declare function createFlashSaleBooking(client: BowlosClient, args: CreateFlashSaleBookingArgs): Promise<FlashSaleBookingResult>;
|
|
89
164
|
|
|
90
|
-
export { type BrandScoped as B, type
|
|
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
|
-
|
|
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-
|
|
370
|
-
//# sourceMappingURL=chunk-
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react.tsx","../src/hooks.tsx","../src/use-booking-flow.tsx"],"names":["useCallback","useState","useRef","useEffect"],"mappings":";;;;AAwBA,IAAM,aAAA,GAAgB,cAAmC,IAAI,CAAA;AAC7D,IAAM,cAAA,GAAiB,cAAuC,IAAI,CAAA;AAS3D,SAAS,cAAA,CAAe,EAAE,MAAA,EAAQ,MAAA,EAAQ,UAAS,EAAwB;AAChF,EAAA,MAAM,GAAA,GAAM,MAAA,CAA4B,MAAA,IAAU,IAAI,CAAA;AACtD,EAAA,IAAI,CAAC,IAAI,OAAA,EAAS;AAChB,IAAA,IAAI,CAAC,MAAA,EAAQ;AACX,MAAA,MAAM,IAAI,MAAM,0DAA0D,CAAA;AAAA,IAC5E;AACA,IAAA,GAAA,CAAI,OAAA,GAAU,mBAAmB,MAAM,CAAA;AAAA,EACzC;AACA,EAAA,MAAM,eAAe,GAAA,CAAI,OAAA;AAGzB,EAAA,MAAM,OAAA,GAAU,gBAAgB,YAAY,CAAA;AAC5C,EAAA,uBACE,GAAA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,UAAA,EAAW;AAChB,MAAA,OAAA,CAAQ,OAAA,GAAU,YAAY,MAAM;AAClC,QAAA,KAAK,UAAA,EAAW;AAAA,MAClB,GAAG,UAAU,CAAA;AAAA,IACf,CAAA;AAAA,IACA,CAAC,YAAY,WAAW;AAAA,GAC1B;AAEA,EAAA,MAAM,OAAA,GAAUA,YAAY,YAAY;AACtC,IAAA,WAAA,EAAY;AACZ,IAAA,MAAM,KAAK,WAAA,CAAY,OAAA;AACvB,IAAA,IAAI,EAAA,EAAI;AACN,MAAA,IAAI;AACF,QAAA,MAAM,eAAA,CAAoB,QAAQ,EAAE,CAAA;AAAA,MACtC,CAAA,CAAA,MAAQ;AAAA,MAER;AAAA,IACF;AACA,IAAA,SAAA,CAAU,WAAW,CAAA;AAAA,EACvB,CAAA,EAAG,CAAC,MAAA,EAAQ,WAAW,CAAC,CAAA;AAExB,EAAA,OAAO;AAAA,IACL,MAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,aAAA;AAAA,IACA,WAAA;AAAA,IACA,eAAA,EAAiB,IAAA,GAAO,IAAA,CAAK,eAAA,GAAkB,IAAA;AAAA,IAC/C,KAAA;AAAA,IACA,SAAA;AAAA,IACA,cAAA;AAAA,IACA,UAAA;AAAA,IACA,YAAA;AAAA,IACA,WAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACF;AACF","file":"chunk-CRETIPLS.js","sourcesContent":["/**\n * React layer for @bowlos/reservations.\n *\n * `<BowlosProvider>` holds one `BowlosClient`; `useAccount()` manages the\n * customer session (probe on mount, sign-in/up/link/out, current customer);\n * `useBowlosQuery()` is the generic read hook the typed data hooks\n * (`useAvailability`, `useBookingFlow`, …) will build on next.\n *\n * Lives in its own module so non-React consumers of the core never pull React.\n * (The `@bowlos/reservations/react` export subpath is wired with the publish build.)\n */\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport { BowlosClient, createBowlosClient } from \"./client\";\nimport { BowlosApiError } from \"./errors\";\nimport type { AuthState, BowlosClientConfig, Customer, LinkProfile } from \"./types\";\n\nconst BowlosContext = createContext<BowlosClient | null>(null);\nconst AccountContext = createContext<UseAccountResult | null>(null);\n\nexport interface BowlosProviderProps {\n /** A prebuilt client, or pass `config` to have one created and memoized. */\n client?: BowlosClient;\n config?: BowlosClientConfig;\n children: ReactNode;\n}\n\nexport function BowlosProvider({ client, config, children }: BowlosProviderProps) {\n const ref = useRef<BowlosClient | null>(client ?? null);\n if (!ref.current) {\n if (!config) {\n throw new Error(\"BowlosProvider requires either a `client` or a `config`.\");\n }\n ref.current = createBowlosClient(config);\n }\n const bowlosClient = ref.current as BowlosClient; // non-null after the guard above\n // Run the session machine ONCE here and share it via context, so every\n // useAccount() across the app sees the same session.\n const account = useAccountState(bowlosClient);\n return (\n <BowlosContext.Provider value={bowlosClient}>\n <AccountContext.Provider value={account}>{children}</AccountContext.Provider>\n </BowlosContext.Provider>\n );\n}\n\nexport function useBowlosClient(): BowlosClient {\n const client = useContext(BowlosContext);\n if (!client) {\n throw new Error(\"useBowlosClient must be used within a <BowlosProvider>.\");\n }\n return client;\n}\n\n// ── useAccount ──────────────────────────────────────────────────────────────\n\nexport type AccountStatus = \"loading\" | AuthState;\n\nexport interface UseAccountResult {\n status: AccountStatus;\n customer: Customer | null;\n error: BowlosApiError | null;\n signIn: (email: string, password: string) => Promise<void>;\n signUp: (email: string, password: string) => Promise<void>;\n link: (profile: LinkProfile) => Promise<void>;\n signOut: () => Promise<void>;\n refresh: () => Promise<void>;\n}\n\n/** The session state machine — runs ONCE inside `<BowlosProvider>` and is shared\n * via context. Probes once on mount; each action re-probes so `status`/`customer`\n * stay current. Consumers use `useAccount()`, never this directly. */\nfunction useAccountState(client: BowlosClient): UseAccountResult {\n const [status, setStatus] = useState<AccountStatus>(\"loading\");\n const [customer, setCustomer] = useState<Customer | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n\n const refresh = useCallback(async () => {\n try {\n const state = await client.probe();\n setStatus(state);\n setCustomer(state === \"linked\" ? await client.me() : null);\n setError(null);\n } catch (e) {\n setStatus(\"unauthenticated\");\n setCustomer(null);\n if (e instanceof BowlosApiError) setError(e);\n }\n }, [client]);\n\n useEffect(() => {\n void refresh();\n }, [refresh]);\n\n const run = useCallback(\n async (action: () => Promise<unknown>) => {\n setError(null);\n try {\n await action();\n await refresh();\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n throw e;\n }\n },\n [refresh],\n );\n\n const signIn = useCallback(\n (email: string, password: string) => run(() => client.signIn(email, password)),\n [client, run],\n );\n const signUp = useCallback(\n (email: string, password: string) => run(() => client.signUp(email, password)),\n [client, run],\n );\n const link = useCallback((profile: LinkProfile) => run(() => client.link(profile)), [client, run]);\n const signOut = useCallback(() => run(() => client.signOut()), [client, run]);\n\n return { status, customer, error, signIn, signUp, link, signOut, refresh };\n}\n\n/**\n * The customer session (state + actions), shared across the whole app. Every\n * call returns the SAME session — signing in or out anywhere updates the header,\n * the booking form, everywhere at once. Must be used within a `<BowlosProvider>`.\n */\nexport function useAccount(): UseAccountResult {\n const account = useContext(AccountContext);\n if (!account) {\n throw new Error(\"useAccount must be used within a <BowlosProvider>.\");\n }\n return account;\n}\n\n// ── useBowlosQuery ────────────────────────────────────────────────────────────\n\nexport interface UseQueryOptions {\n /** Send the customer bearer token (for session-scoped reads). */\n auth?: boolean;\n /** Skip fetching until true. Defaults to true. */\n enabled?: boolean;\n}\n\nexport interface UseQueryResult<T> {\n data: T | null;\n error: BowlosApiError | null;\n loading: boolean;\n refetch: () => Promise<void>;\n}\n\n/** Generic read hook over a gateway route. The typed data hooks\n * (`useAvailability`, etc.) will wrap this with route names + arg types. */\nexport function useBowlosQuery<T = unknown>(\n name: string,\n args: Record<string, unknown> = {},\n options: UseQueryOptions = {},\n): UseQueryResult<T> {\n const client = useBowlosClient();\n const auth = options.auth ?? false;\n const enabled = options.enabled ?? true;\n const [data, setData] = useState<T | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n const [loading, setLoading] = useState<boolean>(enabled);\n // Stabilize the args object across renders so the effect doesn't loop.\n const argsKey = JSON.stringify(args);\n\n const refetch = useCallback(async () => {\n setLoading(true);\n setError(null);\n try {\n const result = await client.call<T>(name, JSON.parse(argsKey) as Record<string, unknown>, {\n auth,\n });\n setData(result);\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n setData(null);\n } finally {\n setLoading(false);\n }\n }, [client, name, argsKey, auth]);\n\n useEffect(() => {\n if (enabled) void refetch();\n }, [enabled, refetch]);\n\n return { data, error, loading, refetch };\n}\n\n// ── useBowlosMutation ─────────────────────────────────────────────────────────\n\nexport interface UseMutationResult<TArgs, TData> {\n /** Fire the mutation. Resolves with the data, or throws BowlosApiError. */\n run: (args: TArgs) => Promise<TData>;\n data: TData | null;\n error: BowlosApiError | null;\n loading: boolean;\n reset: () => void;\n}\n\n/** Generic write hook over a gateway route. The typed mutation hooks\n * (`useCancelMyReservation`, etc.) wrap this with a route name + arg type. */\nexport function useBowlosMutation<TArgs extends Record<string, unknown>, TData = unknown>(\n name: string,\n options: { auth?: boolean } = {},\n): UseMutationResult<TArgs, TData> {\n const client = useBowlosClient();\n const auth = options.auth ?? false;\n const [data, setData] = useState<TData | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n const [loading, setLoading] = useState<boolean>(false);\n\n const run = useCallback(\n async (args: TArgs) => {\n setLoading(true);\n setError(null);\n try {\n const result = await client.call<TData>(name, args, { auth });\n setData(result);\n return result;\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n throw e;\n } finally {\n setLoading(false);\n }\n },\n [client, name, auth],\n );\n\n const reset = useCallback(() => {\n setData(null);\n setError(null);\n setLoading(false);\n }, []);\n\n return { run, data, error, loading, reset };\n}\n","/**\n * Typed React data hooks for the booking funnel, built on `useBowlosQuery`.\n * Same arg/result types as the framework-agnostic functions in `data.ts`.\n */\nimport { useCallback } from \"react\";\nimport {\n useBowlosQuery,\n useBowlosMutation,\n type UseQueryOptions,\n type UseQueryResult,\n type UseMutationResult,\n} from \"./react\";\nimport { generateIdempotencyKey } from \"./data\";\nimport type {\n CancelPreview,\n CancelResult,\n MyGameCard,\n ReservationCancelArgs,\n OrderCancelArgs,\n GameCardCancelArgs,\n} from \"./account\";\nimport type {\n AvailabilityArgs,\n AvailabilityResult,\n BookingPreviewArgs,\n BookingQuote,\n PublicAddon,\n StartTimesArgs,\n PackagePreviewArgs,\n PackagePreviewResult,\n GameCardPreviewArgs,\n GameCardPreviewResult,\n EventTicketPreviewArgs,\n EventTicketPreviewResult,\n MembershipPreviewArgs,\n MembershipPreviewResult,\n MembershipSubscriptionPreviewResult,\n} from \"./data\";\nimport type {\n BrandScoped,\n EventOrderDetailArgs,\n FlashBookingOptionsArgs,\n FlashSaleArgs,\n FlashSalesArgs,\n MembershipDetailArgs,\n ReservationDetailArgs,\n} from \"./account\";\nimport type {\n BrandCatalogArgs,\n CatalogArgs,\n CatalogResult,\n CenterScoped,\n PackageDetailArgs,\n CenterHoursArgs,\n} from \"./catalog\";\n\n/** Live free-unit availability for a product / date / time window. */\nexport function useAvailability(\n args: AvailabilityArgs,\n options?: UseQueryOptions,\n): UseQueryResult<AvailabilityResult> {\n return useBowlosQuery<AvailabilityResult>(\"checkAvailability\", args, options);\n}\n\n/** Authoritative price quote for the chosen booking inputs. */\nexport function useBookingPreview(\n args: BookingPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<BookingQuote> {\n return useBowlosQuery<BookingQuote>(\"bookingPreview\", args, options);\n}\n\n/** Bookable add-ons (shoe rental, upgrades…) for a product. */\nexport function useAddons(\n args: { productId: string },\n options?: UseQueryOptions,\n): UseQueryResult<PublicAddon[]> {\n return useBowlosQuery<PublicAddon[]>(\"listPublicAddons\", args, options);\n}\n\n/** Bookable start times (minute-of-day) for a product on a date. */\nexport function useStartTimes(\n args: StartTimesArgs,\n options?: UseQueryOptions,\n): UseQueryResult<number[]> {\n return useBowlosQuery<number[]>(\"availableStartTimes\", args, options);\n}\n\n// ── account (require a signed-in customer) ───────────────────────────────────\n// Results are generic (`<T = unknown>`) — parameterize with your own shape.\n\n/** The signed-in customer's reservations. */\nexport function useMyReservations<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyReservations\", args, { ...options, auth: true });\n}\n\n/** One of the customer's reservations, by displayId. */\nexport function useMyReservationDetail<T = unknown>(\n args: ReservationDetailArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getMyReservationDetail\", args, { ...options, auth: true });\n}\n\n/** The signed-in customer's event ticket orders. */\nexport function useMyEventOrders<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyEventOrders\", args, { ...options, auth: true });\n}\n\n/** One of the customer's event ticket orders. */\nexport function useMyEventOrder<T = unknown>(\n args: EventOrderDetailArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getMyEventOrder\", args, { ...options, auth: true });\n}\n\n/** The customer's memberships. */\nexport function useMyMemberships<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyMemberships\", args, { ...options, auth: true });\n}\n\n/** One membership's detail. */\nexport function useMyMembershipDetail<T = unknown>(\n args: MembershipDetailArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getMyMembershipDetail\", args, { ...options, auth: true });\n}\n\n/** Loyalty tier + points. */\nexport function useMyLoyalty<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getMyLoyalty\", args, { ...options, auth: true });\n}\n\n/** Account credit balance + ledger. */\nexport function useMyCredits<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyCredits\", args, { ...options, auth: true });\n}\n\n/** Issued wallet passes. */\nexport function useMyPasses<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyPasses\", args, { ...options, auth: true });\n}\n\n/** The customer's game cards for this Brand (with the unused-only `cancellable`\n * flag), so a headless site can list them + drive cancel. */\nexport function useMyGameCards<T = MyGameCard[]>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyGameCards\", args, { ...options, auth: true });\n}\n\n// ── self-serve cancel (v0.23.0): preview reads + cancel mutations ─────────────\n//\n// Per type: preview \"what you'll get back\" → confirm → cancel. The cancel hooks\n// generate a fresh idempotencyKey per attempt, so the caller never manages it.\n// Game cards cancel only while fully unused (locked rule) → full credit.\n\n/** Preview the credit for cancelling a reservation (advisory; cancel re-computes). */\nexport function useReservationCancelPreview<T = CancelPreview>(\n args: { brandId: string; reservationId: string },\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMyCancellation\", args, { ...options, auth: true });\n}\n/** Preview the credit for cancelling an event order. */\nexport function useEventOrderCancelPreview<T = CancelPreview>(\n args: { brandId: string; orderId: string },\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMyEventOrderCancellation\", args, { ...options, auth: true });\n}\n/** Preview the credit for cancelling a package order. */\nexport function usePackageOrderCancelPreview<T = CancelPreview>(\n args: { brandId: string; orderId: string },\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMyPackageOrderCancellation\", args, { ...options, auth: true });\n}\n/** Preview the credit for cancelling a game card (full credit only if unused). */\nexport function useGameCardCancelPreview<T = CancelPreview>(\n args: { brandId: string; cardId: string },\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMyGameCardCancellation\", args, { ...options, auth: true });\n}\n\n/** Cancel a reservation → store credit per policy. Pass the `version` from the\n * list/detail as `expectedVersion`; the hook supplies the idempotency key. */\nexport function useCancelMyReservation(): UseMutationResult<\n Omit<ReservationCancelArgs, \"idempotencyKey\">,\n CancelResult\n> {\n const m = useBowlosMutation<ReservationCancelArgs, CancelResult>(\"cancelMyReservation\", {\n auth: true,\n });\n const run = useCallback(\n (args: Omit<ReservationCancelArgs, \"idempotencyKey\">) =>\n m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),\n [m],\n );\n return { ...m, run };\n}\n/** Cancel an event order → store credit per policy. */\nexport function useCancelMyEventOrder(): UseMutationResult<\n Omit<OrderCancelArgs, \"idempotencyKey\">,\n CancelResult\n> {\n const m = useBowlosMutation<OrderCancelArgs, CancelResult>(\"cancelMyEventOrder\", { auth: true });\n const run = useCallback(\n (args: Omit<OrderCancelArgs, \"idempotencyKey\">) =>\n m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),\n [m],\n );\n return { ...m, run };\n}\n/** Cancel a package order → store credit per policy; releases the slot. */\nexport function useCancelMyPackageOrder(): UseMutationResult<\n Omit<OrderCancelArgs, \"idempotencyKey\">,\n CancelResult\n> {\n const m = useBowlosMutation<OrderCancelArgs, CancelResult>(\"cancelMyPackageOrder\", { auth: true });\n const run = useCallback(\n (args: Omit<OrderCancelArgs, \"idempotencyKey\">) =>\n m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),\n [m],\n );\n return { ...m, run };\n}\n/** Cancel a game card → full credit (unused cards only). */\nexport function useCancelMyGameCard(): UseMutationResult<\n Omit<GameCardCancelArgs, \"idempotencyKey\">,\n CancelResult\n> {\n const m = useBowlosMutation<GameCardCancelArgs, CancelResult>(\"cancelMyGameCard\", { auth: true });\n const run = useCallback(\n (args: Omit<GameCardCancelArgs, \"idempotencyKey\">) =>\n m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),\n [m],\n );\n return { ...m, run };\n}\n\n// ── flash sales (session-aware: members see prices) ──────────────────────────\n\n/** The public flash-sale page (members see prices; anonymous gets the locked view). */\nexport function useFlashSale<T = unknown>(\n args: FlashSaleArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getPublicFlashSaleBySlug\", args, { ...options, auth: true });\n}\n\n/** The public flash-sale index for a Brand (live + upcoming; no prices). Public. */\nexport function useFlashSales<T = unknown>(\n args: FlashSalesArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicFlashSales\", args, options);\n}\n\n/** Per-start-hour options for a flash-sale reservation item (members only). */\nexport function useFlashSaleBookingOptions<T = unknown>(\n args: FlashBookingOptionsArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getFlashSaleBookingOptions\", args, { ...options, auth: true });\n}\n\n// ── public catalog (anonymous; power `<BookingCatalog>`) ──────────────────────\n\n/**\n * The canonical public catalog for a surface — every category grouped, with the\n * Center admin's per-surface visibility already applied. Prefer this over the\n * per-category hooks below when you want the full, visibility-aware catalog\n * (it stays consistent with the white-label web + mobile surfaces). Anonymous.\n */\nexport function useCatalog<T = CatalogResult>(\n args: CatalogArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicCatalog\", args, options);\n}\n\n/** Bookable products at a Center (each carries `attractionTypeKey`). */\nexport function useProducts<T = unknown>(\n args: CenterScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicProducts\", args, options);\n}\n\n/** Upcoming pricing events at a Center. */\nexport function useEvents<T = unknown>(\n args: CenterScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicEvents\", args, options);\n}\n\n/** Sellable event offers at a Center. Use these for the product lineup and\n * event landing pages; each row carries a slug and purchase mode. */\nexport function useEventOffers<T = unknown>(\n args: CenterScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicEventOffers\", args, options);\n}\n\n/** One sellable event offer by landing-page slug. */\nexport function useEventOffer<T = unknown>(\n args: { slug: string },\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getPublicEventOffer\", args, options);\n}\n\n/** Purchasable packages at a Brand. */\nexport function usePackages<T = unknown>(\n args: BrandCatalogArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicPackages\", args, options);\n}\n\n/** Full detail for one package (components, add-ons, allowed start times, …) —\n * drives the headless package config UI before `usePackagePurchase`. */\nexport function usePackage<T = unknown>(\n args: PackageDetailArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getPublicPackage\", args, options);\n}\n\n/** A Center's open/close window for the given attraction types on a date — use\n * the package's component attraction-type keys to bound its bookable slots. */\nexport function useCenterHours<T = unknown>(\n args: CenterHoursArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getCenterOperatingHoursForTypes\", args, options);\n}\n\n/** Itemized quote for a package order — base, add-ons, tax lines, the selling\n * Center's booking fee, and the authoritative grand total. Drives the headless\n * **Review** step. Requires a signed-in customer (tax exemptions are applied),\n * and is computed by the same engine as the PaymentIntent, so it never diverges\n * from what the customer is charged. */\nexport function usePackagePreview<T = PackagePreviewResult>(\n args: PackagePreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewPackageOrder\", args, { ...options, auth: true });\n}\n\n/** Purchasable memberships at a Center. */\nexport function usePublicMemberships<T = unknown>(\n args: CenterScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicMemberships\", args, options);\n}\n\n/** Purchasable game cards / passes at a Brand. */\nexport function useGameCards<T = unknown>(\n args: BrandCatalogArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicGameCards\", args, options);\n}\n\n/** Itemized quote for a game-pass purchase — the base price, tax lines, the\n * selling Center's booking fee, and the authoritative grand total. Drives the\n * headless **Review** step. Requires a signed-in customer (tax exemptions are\n * applied + the home Center is resolved server-side), and is computed by the\n * same engine as the PaymentIntent, so it never diverges from what the\n * customer is charged. */\nexport function useGameCardPreview<T = GameCardPreviewResult>(\n args: GameCardPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewGameCardOrder\", args, { ...options, auth: true });\n}\n\n/** Itemized quote for a ticket-mode event offer — base tickets, tax lines,\n * Center event fee, and authoritative grand total. Requires a signed-in\n * customer so tax exemptions match the eventual charge. */\nexport function useEventTicketPreview<T = EventTicketPreviewResult>(\n args: EventTicketPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewEventTicketOrder\", args, { ...options, auth: true });\n}\n\n/** Itemized quote for a one-time membership purchase — dues, the one-time setup\n * fee, tax lines, the selling Center's booking fee, and the authoritative grand\n * total. Drives the headless **Review** step. Requires a signed-in customer (tax\n * exemptions are applied + the home Center is resolved server-side), and is\n * computed by the same engine as the PaymentIntent, so it never diverges from\n * what the customer is charged. */\nexport function useMembershipPreview<T = MembershipPreviewResult>(\n args: MembershipPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMembershipOrder\", args, { ...options, auth: true });\n}\n\n/** Itemized quote for a RECURRING membership subscription — the one-time Review\n * fields (\"Due today\") PLUS `recurringTotalCents` + `cadence` (\"Auto-renews\n * at\"). Drives the recurring **Review** step. Requires a signed-in customer, and\n * is computed by the same engine as the subscription's first invoice, so it\n * never diverges from what the customer is charged. */\nexport function useMembershipSubscriptionPreview<T = MembershipSubscriptionPreviewResult>(\n args: MembershipPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMembershipSubscriptionOrder\", args, {\n ...options,\n auth: true,\n });\n}\n","/**\n * useBookingFlow — the hold → pay → confirm state machine.\n *\n * Orchestrates the booking funnel and HANDS the Stripe (Connect) payment data\n * to the UI layer; it does NOT load Stripe.js. After `preparePayment()`, render\n * Stripe Elements from `paymentIntent` (initialize Stripe with\n * `connectedAccountId` + `clientSecret`), let the customer pay, then\n * `startPolling()` until the webhook materializes the booking\n * (`status: \"confirmed\"`).\n *\n * Flow:\n * startHold(args) → \"held\" (requiresPayment) | \"confirmed\" (credit covered)\n * preparePayment() → \"awaitingPayment\" (+ paymentIntent)\n * [consumer renders Stripe Elements + the customer pays]\n * startPolling() → \"confirmed\" | \"expired\" | \"failed\" | \"abandoned\"\n */\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useBowlosClient } from \"./react\";\nimport { BowlosApiError, BOWLOS_ERROR_CODES } from \"./errors\";\nimport {\n abandonCheckout as abandonCheckoutCall,\n createBooking as createBookingCall,\n createCheckoutPaymentIntent as createPaymentIntentCall,\n getCheckoutStatus as getCheckoutStatusCall,\n type BookingHold,\n type CheckoutStatusResult,\n type CreateBookingArgs,\n type PaymentIntentInfo,\n} from \"./data\";\n\nexport type BookingFlowStatus =\n | \"idle\"\n | \"holding\"\n | \"held\"\n | \"preparingPayment\"\n | \"awaitingPayment\"\n | \"confirmed\"\n | \"expired\"\n | \"failed\"\n | \"abandoned\"\n | \"error\";\n\nexport interface BookingReservationRef {\n reservationId: string | null;\n reservationDisplayId: string | null;\n}\n\nexport interface UseBookingFlowResult {\n status: BookingFlowStatus;\n hold: BookingHold | null;\n refToken: string | null;\n paymentIntent: PaymentIntentInfo | null;\n reservation: BookingReservationRef | null;\n requiresPayment: boolean | null;\n error: BowlosApiError | null;\n startHold: (args: CreateBookingArgs) => Promise<void>;\n preparePayment: () => Promise<PaymentIntentInfo | null>;\n pollStatus: () => Promise<CheckoutStatusResult | null>;\n startPolling: (intervalMs?: number) => void;\n stopPolling: () => void;\n abandon: () => Promise<void>;\n reset: () => void;\n}\n\nconst DEFAULT_POLL_MS = 2500;\n\nexport function useBookingFlow(): UseBookingFlowResult {\n const client = useBowlosClient();\n const [status, setStatus] = useState<BookingFlowStatus>(\"idle\");\n const [hold, setHold] = useState<BookingHold | null>(null);\n const [refToken, setRefToken] = useState<string | null>(null);\n const [paymentIntent, setPaymentIntent] = useState<PaymentIntentInfo | null>(null);\n const [reservation, setReservation] = useState<BookingReservationRef | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n\n // Mirror of refToken for the polling interval (avoids a stale closure).\n const refTokenRef = useRef<string | null>(null);\n const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);\n\n const stopPolling = useCallback(() => {\n if (pollRef.current !== null) {\n clearInterval(pollRef.current);\n pollRef.current = null;\n }\n }, []);\n\n useEffect(() => stopPolling, [stopPolling]); // clear the interval on unmount\n\n const reset = useCallback(() => {\n stopPolling();\n refTokenRef.current = null;\n setRefToken(null);\n setHold(null);\n setPaymentIntent(null);\n setReservation(null);\n setError(null);\n setStatus(\"idle\");\n }, [stopPolling]);\n\n const applyStatus = useCallback(\n (s: CheckoutStatusResult) => {\n switch (s.status) {\n case \"paid_materialized\":\n setReservation({\n reservationId: s.reservationId,\n reservationDisplayId: s.reservationDisplayId,\n });\n setStatus(\"confirmed\");\n stopPolling();\n break;\n case \"expired\":\n setStatus(\"expired\");\n stopPolling();\n break;\n case \"abandoned\":\n setStatus(\"abandoned\");\n stopPolling();\n break;\n case \"payment_failed_retryable\":\n setStatus(\"failed\");\n stopPolling();\n break;\n case \"not_found\":\n setError(new BowlosApiError(BOWLOS_ERROR_CODES.NOT_FOUND, \"Checkout not found.\", 404));\n setStatus(\"error\");\n stopPolling();\n break;\n case \"pending_payment\":\n default:\n break; // keep waiting\n }\n },\n [stopPolling],\n );\n\n const startHold = useCallback(\n async (args: CreateBookingArgs) => {\n stopPolling();\n setError(null);\n setPaymentIntent(null);\n setReservation(null);\n setStatus(\"holding\");\n try {\n const h = await createBookingCall(client, args);\n setHold(h);\n const rt = typeof h.checkoutRefToken === \"string\" ? h.checkoutRefToken : null;\n refTokenRef.current = rt;\n setRefToken(rt);\n if (!h.requiresPayment) {\n setReservation({\n reservationId: h.reservationId ?? null,\n reservationDisplayId: h.reservationDisplayId ?? null,\n });\n setStatus(\"confirmed\");\n } else if (rt) {\n setStatus(\"held\");\n } else {\n setError(\n new BowlosApiError(\n \"UNSUPPORTED_BOOKING_PATH\",\n \"This booking requires payment but no checkout hold was returned.\",\n 0,\n ),\n );\n setStatus(\"error\");\n }\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n setStatus(\"error\");\n }\n },\n [client, stopPolling],\n );\n\n const preparePayment = useCallback(async (): Promise<PaymentIntentInfo | null> => {\n const rt = refTokenRef.current;\n if (!rt) return null;\n setError(null);\n setStatus(\"preparingPayment\");\n try {\n const pi = await createPaymentIntentCall(client, rt);\n setPaymentIntent(pi);\n setStatus(\"awaitingPayment\");\n return pi;\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n setStatus(\"error\");\n return null;\n }\n }, [client]);\n\n const pollStatus = useCallback(async (): Promise<CheckoutStatusResult | null> => {\n const rt = refTokenRef.current;\n if (!rt) return null;\n try {\n const s = await getCheckoutStatusCall(client, rt);\n applyStatus(s);\n return s;\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n return null;\n }\n }, [client, applyStatus]);\n\n const startPolling = useCallback(\n (intervalMs: number = DEFAULT_POLL_MS) => {\n stopPolling();\n void pollStatus();\n pollRef.current = setInterval(() => {\n void pollStatus();\n }, intervalMs);\n },\n [pollStatus, stopPolling],\n );\n\n const abandon = useCallback(async () => {\n stopPolling();\n const rt = refTokenRef.current;\n if (rt) {\n try {\n await abandonCheckoutCall(client, rt);\n } catch {\n // best-effort: the hold also frees itself on its TTL\n }\n }\n setStatus(\"abandoned\");\n }, [client, stopPolling]);\n\n return {\n status,\n hold,\n refToken,\n paymentIntent,\n reservation,\n requiresPayment: hold ? hold.requiresPayment : null,\n error,\n startHold,\n preparePayment,\n pollStatus,\n startPolling,\n stopPolling,\n abandon,\n reset,\n };\n}\n"]}
|
package/dist/components.cjs
CHANGED
|
@@ -136,6 +136,38 @@ function useBowlosQuery(name, args = {}, options = {}) {
|
|
|
136
136
|
return { data, error, loading, refetch };
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
// src/data.ts
|
|
140
|
+
function availableUnitCount(availability) {
|
|
141
|
+
return Math.max(0, availability.totalUnits - availability.busyUnitIds.length);
|
|
142
|
+
}
|
|
143
|
+
function generateIdempotencyKey() {
|
|
144
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
145
|
+
return crypto.randomUUID();
|
|
146
|
+
}
|
|
147
|
+
return `idem_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
148
|
+
}
|
|
149
|
+
function createBooking(client, args) {
|
|
150
|
+
const idempotencyKey = args.idempotencyKey ?? generateIdempotencyKey();
|
|
151
|
+
return client.call(
|
|
152
|
+
"createAnonymousBooking",
|
|
153
|
+
{ ...args, idempotencyKey },
|
|
154
|
+
{ auth: true }
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
function createCheckoutPaymentIntent(client, refToken) {
|
|
158
|
+
return client.call(
|
|
159
|
+
"createCheckoutPaymentIntent",
|
|
160
|
+
{ refToken },
|
|
161
|
+
{ auth: true }
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
function getCheckoutStatus(client, refToken) {
|
|
165
|
+
return client.call("getCheckoutStatus", { refToken }, { auth: true });
|
|
166
|
+
}
|
|
167
|
+
function abandonCheckout(client, refToken) {
|
|
168
|
+
return client.call("abandonCheckout", { refToken }, { auth: true });
|
|
169
|
+
}
|
|
170
|
+
|
|
139
171
|
// src/hooks.tsx
|
|
140
172
|
function useAvailability(args, options) {
|
|
141
173
|
return useBowlosQuery("checkAvailability", args, options);
|
|
@@ -173,40 +205,6 @@ function useFlashSales(args, options) {
|
|
|
173
205
|
function useCatalog(args, options) {
|
|
174
206
|
return useBowlosQuery("listPublicCatalog", args, options);
|
|
175
207
|
}
|
|
176
|
-
|
|
177
|
-
// src/data.ts
|
|
178
|
-
function availableUnitCount(availability) {
|
|
179
|
-
return Math.max(0, availability.totalUnits - availability.busyUnitIds.length);
|
|
180
|
-
}
|
|
181
|
-
function generateIdempotencyKey() {
|
|
182
|
-
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
183
|
-
return crypto.randomUUID();
|
|
184
|
-
}
|
|
185
|
-
return `idem_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
186
|
-
}
|
|
187
|
-
function createBooking(client, args) {
|
|
188
|
-
const idempotencyKey = args.idempotencyKey ?? generateIdempotencyKey();
|
|
189
|
-
return client.call(
|
|
190
|
-
"createAnonymousBooking",
|
|
191
|
-
{ ...args, idempotencyKey },
|
|
192
|
-
{ auth: true }
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
function createCheckoutPaymentIntent(client, refToken) {
|
|
196
|
-
return client.call(
|
|
197
|
-
"createCheckoutPaymentIntent",
|
|
198
|
-
{ refToken },
|
|
199
|
-
{ auth: true }
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
function getCheckoutStatus(client, refToken) {
|
|
203
|
-
return client.call("getCheckoutStatus", { refToken }, { auth: true });
|
|
204
|
-
}
|
|
205
|
-
function abandonCheckout(client, refToken) {
|
|
206
|
-
return client.call("abandonCheckout", { refToken }, { auth: true });
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// src/use-booking-flow.tsx
|
|
210
208
|
var DEFAULT_POLL_MS = 2500;
|
|
211
209
|
function useBookingFlow() {
|
|
212
210
|
const client = useBowlosClient();
|