@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 +128 -1
- package/README.md +8 -1
- package/dist/account-B9tDfXke.d.ts +165 -0
- package/dist/account-C9SvfE3q.d.cts +165 -0
- 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 +42 -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 +33 -1
- package/dist/index.js.map +1 -1
- package/dist/payments.cjs +9 -1
- package/dist/payments.cjs.map +1 -1
- package/dist/payments.js +9 -1
- package/dist/payments.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/account-CO8xzUs_.d.ts +0 -54
- package/dist/account-SqT7et4C.d.cts +0 -54
- package/dist/chunk-FV6SROO2.js.map +0 -1
package/dist/react.d.cts
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import { U as UseQueryOptions, a as UseQueryResult } from './react
|
|
2
|
-
export { A as AccountStatus, B as BowlosProvider,
|
|
1
|
+
import { U as UseQueryOptions, a as UseQueryResult, b as UseMutationResult } from './react--BT8olOw.cjs';
|
|
2
|
+
export { A as AccountStatus, B as BowlosProvider, c as BowlosProviderProps, d as UseAccountResult, u as useAccount, e as useBowlosClient, f as useBowlosMutation, g as useBowlosQuery } from './react--BT8olOw.cjs';
|
|
3
|
+
import { O as OrderCancelArgs, a as CancelResult, G as GameCardCancelArgs, R as ReservationCancelArgs, C as CancelPreview, c as FlashSaleArgs, F as FlashBookingOptionsArgs, e as FlashSalesArgs, B as BrandScoped, E as EventOrderDetailArgs, f as MyGameCard, M as MembershipDetailArgs, g as ReservationDetailArgs } from './account-C9SvfE3q.cjs';
|
|
3
4
|
import { V as PublicAddon, a as AvailabilityArgs, b as AvailabilityResult, e as BookingPreviewArgs, f as BookingQuote, n as EventTicketPreviewResult, m as EventTicketPreviewArgs, s as GameCardPreviewResult, r as GameCardPreviewArgs, x as MembershipPreviewResult, w as MembershipPreviewArgs, J as MembershipSubscriptionPreviewResult, N as PackagePreviewResult, K as PackagePreviewArgs, W as StartTimesArgs, d as BookingHold, S as PaymentIntentInfo, k as CreateBookingArgs, i as CheckoutStatusResult, I as MembershipSubscriptionIntent, H as MembershipSubscriptionArgs, o as EventTicketPurchaseArgs, t as GameCardPurchaseArgs, y as MembershipPurchaseArgs, O as PackagePurchaseArgs } from './data-BKlgn8Ln.cjs';
|
|
4
|
-
import { a as FlashSaleArgs, F as FlashBookingOptionsArgs, b as FlashSalesArgs, B as BrandScoped, E as EventOrderDetailArgs, M as MembershipDetailArgs, R as ReservationDetailArgs } from './account-SqT7et4C.cjs';
|
|
5
5
|
import { h as CatalogResult, e as CatalogArgs, k as CenterHoursArgs, l as CenterScoped, d as BrandCatalogArgs, P as PackageDetailArgs, a as BowlosApiError } from './catalog-D1VoVaNe.cjs';
|
|
6
6
|
import 'react/jsx-runtime';
|
|
7
7
|
import 'react';
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* Typed React data hooks for the booking funnel, built on `useBowlosQuery`.
|
|
11
|
-
* Same arg/result types as the framework-agnostic functions in `data.ts`.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
9
|
/** Live free-unit availability for a product / date / time window. */
|
|
15
10
|
declare function useAvailability(args: AvailabilityArgs, options?: UseQueryOptions): UseQueryResult<AvailabilityResult>;
|
|
16
11
|
/** Authoritative price quote for the chosen booking inputs. */
|
|
@@ -39,6 +34,38 @@ declare function useMyLoyalty<T = unknown>(args: BrandScoped, options?: UseQuery
|
|
|
39
34
|
declare function useMyCredits<T = unknown>(args: BrandScoped, options?: UseQueryOptions): UseQueryResult<T>;
|
|
40
35
|
/** Issued wallet passes. */
|
|
41
36
|
declare function useMyPasses<T = unknown>(args: BrandScoped, options?: UseQueryOptions): UseQueryResult<T>;
|
|
37
|
+
/** The customer's game cards for this Brand (with the unused-only `cancellable`
|
|
38
|
+
* flag), so a headless site can list them + drive cancel. */
|
|
39
|
+
declare function useMyGameCards<T = MyGameCard[]>(args: BrandScoped, options?: UseQueryOptions): UseQueryResult<T>;
|
|
40
|
+
/** Preview the credit for cancelling a reservation (advisory; cancel re-computes). */
|
|
41
|
+
declare function useReservationCancelPreview<T = CancelPreview>(args: {
|
|
42
|
+
brandId: string;
|
|
43
|
+
reservationId: string;
|
|
44
|
+
}, options?: UseQueryOptions): UseQueryResult<T>;
|
|
45
|
+
/** Preview the credit for cancelling an event order. */
|
|
46
|
+
declare function useEventOrderCancelPreview<T = CancelPreview>(args: {
|
|
47
|
+
brandId: string;
|
|
48
|
+
orderId: string;
|
|
49
|
+
}, options?: UseQueryOptions): UseQueryResult<T>;
|
|
50
|
+
/** Preview the credit for cancelling a package order. */
|
|
51
|
+
declare function usePackageOrderCancelPreview<T = CancelPreview>(args: {
|
|
52
|
+
brandId: string;
|
|
53
|
+
orderId: string;
|
|
54
|
+
}, options?: UseQueryOptions): UseQueryResult<T>;
|
|
55
|
+
/** Preview the credit for cancelling a game card (full credit only if unused). */
|
|
56
|
+
declare function useGameCardCancelPreview<T = CancelPreview>(args: {
|
|
57
|
+
brandId: string;
|
|
58
|
+
cardId: string;
|
|
59
|
+
}, options?: UseQueryOptions): UseQueryResult<T>;
|
|
60
|
+
/** Cancel a reservation → store credit per policy. Pass the `version` from the
|
|
61
|
+
* list/detail as `expectedVersion`; the hook supplies the idempotency key. */
|
|
62
|
+
declare function useCancelMyReservation(): UseMutationResult<Omit<ReservationCancelArgs, "idempotencyKey">, CancelResult>;
|
|
63
|
+
/** Cancel an event order → store credit per policy. */
|
|
64
|
+
declare function useCancelMyEventOrder(): UseMutationResult<Omit<OrderCancelArgs, "idempotencyKey">, CancelResult>;
|
|
65
|
+
/** Cancel a package order → store credit per policy; releases the slot. */
|
|
66
|
+
declare function useCancelMyPackageOrder(): UseMutationResult<Omit<OrderCancelArgs, "idempotencyKey">, CancelResult>;
|
|
67
|
+
/** Cancel a game card → full credit (unused cards only). */
|
|
68
|
+
declare function useCancelMyGameCard(): UseMutationResult<Omit<GameCardCancelArgs, "idempotencyKey">, CancelResult>;
|
|
42
69
|
/** The public flash-sale page (members see prices; anonymous gets the locked view). */
|
|
43
70
|
declare function useFlashSale<T = unknown>(args: FlashSaleArgs, options?: UseQueryOptions): UseQueryResult<T>;
|
|
44
71
|
/** The public flash-sale index for a Brand (live + upcoming; no prices). Public. */
|
|
@@ -223,4 +250,4 @@ interface UseSubscriptionCheckoutResult {
|
|
|
223
250
|
*/
|
|
224
251
|
declare function useMembershipSubscriptionCheckout(): UseSubscriptionCheckoutResult;
|
|
225
252
|
|
|
226
|
-
export { type BookingFlowStatus, type BookingReservationRef, type PurchasePaymentIntent, type PurchaseStatus, type UseBookingFlowResult, type UsePurchaseResult, UseQueryOptions, UseQueryResult, type UseSubscriptionCheckoutResult, useAddons, useAvailability, useBookingFlow, useBookingPreview, useCatalog, useCenterHours, useEventOffer, useEventOffers, useEventTicketPreview, useEventTicketPurchase, useEvents, useFlashSale, useFlashSaleBookingOptions, useFlashSales, useGameCardPreview, useGameCardPurchase, useGameCards, useMembershipPreview, useMembershipPurchase, useMembershipSubscriptionCheckout, useMembershipSubscriptionPreview, useMyCredits, useMyEventOrder, useMyEventOrders, useMyLoyalty, useMyMembershipDetail, useMyMemberships, useMyPasses, useMyReservationDetail, useMyReservations, usePackage, usePackagePreview, usePackagePurchase, usePackages, useProducts, usePublicMemberships, usePurchase, useStartTimes };
|
|
253
|
+
export { type BookingFlowStatus, type BookingReservationRef, type PurchasePaymentIntent, type PurchaseStatus, type UseBookingFlowResult, UseMutationResult, type UsePurchaseResult, UseQueryOptions, UseQueryResult, type UseSubscriptionCheckoutResult, useAddons, useAvailability, useBookingFlow, useBookingPreview, useCancelMyEventOrder, useCancelMyGameCard, useCancelMyPackageOrder, useCancelMyReservation, useCatalog, useCenterHours, useEventOffer, useEventOffers, useEventOrderCancelPreview, useEventTicketPreview, useEventTicketPurchase, useEvents, useFlashSale, useFlashSaleBookingOptions, useFlashSales, useGameCardCancelPreview, useGameCardPreview, useGameCardPurchase, useGameCards, useMembershipPreview, useMembershipPurchase, useMembershipSubscriptionCheckout, useMembershipSubscriptionPreview, useMyCredits, useMyEventOrder, useMyEventOrders, useMyGameCards, useMyLoyalty, useMyMembershipDetail, useMyMemberships, useMyPasses, useMyReservationDetail, useMyReservations, usePackage, usePackageOrderCancelPreview, usePackagePreview, usePackagePurchase, usePackages, useProducts, usePublicMemberships, usePurchase, useReservationCancelPreview, useStartTimes };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import { U as UseQueryOptions, a as UseQueryResult } from './react-
|
|
2
|
-
export { A as AccountStatus, B as BowlosProvider,
|
|
1
|
+
import { U as UseQueryOptions, a as UseQueryResult, b as UseMutationResult } from './react-BvuU4nzT.js';
|
|
2
|
+
export { A as AccountStatus, B as BowlosProvider, c as BowlosProviderProps, d as UseAccountResult, u as useAccount, e as useBowlosClient, f as useBowlosMutation, g as useBowlosQuery } from './react-BvuU4nzT.js';
|
|
3
|
+
import { O as OrderCancelArgs, a as CancelResult, G as GameCardCancelArgs, R as ReservationCancelArgs, C as CancelPreview, c as FlashSaleArgs, F as FlashBookingOptionsArgs, e as FlashSalesArgs, B as BrandScoped, E as EventOrderDetailArgs, f as MyGameCard, M as MembershipDetailArgs, g as ReservationDetailArgs } from './account-B9tDfXke.js';
|
|
3
4
|
import { V as PublicAddon, a as AvailabilityArgs, b as AvailabilityResult, e as BookingPreviewArgs, f as BookingQuote, n as EventTicketPreviewResult, m as EventTicketPreviewArgs, s as GameCardPreviewResult, r as GameCardPreviewArgs, x as MembershipPreviewResult, w as MembershipPreviewArgs, J as MembershipSubscriptionPreviewResult, N as PackagePreviewResult, K as PackagePreviewArgs, W as StartTimesArgs, d as BookingHold, S as PaymentIntentInfo, k as CreateBookingArgs, i as CheckoutStatusResult, I as MembershipSubscriptionIntent, H as MembershipSubscriptionArgs, o as EventTicketPurchaseArgs, t as GameCardPurchaseArgs, y as MembershipPurchaseArgs, O as PackagePurchaseArgs } from './data-BKlgn8Ln.js';
|
|
4
|
-
import { a as FlashSaleArgs, F as FlashBookingOptionsArgs, b as FlashSalesArgs, B as BrandScoped, E as EventOrderDetailArgs, M as MembershipDetailArgs, R as ReservationDetailArgs } from './account-CO8xzUs_.js';
|
|
5
5
|
import { h as CatalogResult, e as CatalogArgs, k as CenterHoursArgs, l as CenterScoped, d as BrandCatalogArgs, P as PackageDetailArgs, a as BowlosApiError } from './catalog-BxyPJdBL.js';
|
|
6
6
|
import 'react/jsx-runtime';
|
|
7
7
|
import 'react';
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* Typed React data hooks for the booking funnel, built on `useBowlosQuery`.
|
|
11
|
-
* Same arg/result types as the framework-agnostic functions in `data.ts`.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
9
|
/** Live free-unit availability for a product / date / time window. */
|
|
15
10
|
declare function useAvailability(args: AvailabilityArgs, options?: UseQueryOptions): UseQueryResult<AvailabilityResult>;
|
|
16
11
|
/** Authoritative price quote for the chosen booking inputs. */
|
|
@@ -39,6 +34,38 @@ declare function useMyLoyalty<T = unknown>(args: BrandScoped, options?: UseQuery
|
|
|
39
34
|
declare function useMyCredits<T = unknown>(args: BrandScoped, options?: UseQueryOptions): UseQueryResult<T>;
|
|
40
35
|
/** Issued wallet passes. */
|
|
41
36
|
declare function useMyPasses<T = unknown>(args: BrandScoped, options?: UseQueryOptions): UseQueryResult<T>;
|
|
37
|
+
/** The customer's game cards for this Brand (with the unused-only `cancellable`
|
|
38
|
+
* flag), so a headless site can list them + drive cancel. */
|
|
39
|
+
declare function useMyGameCards<T = MyGameCard[]>(args: BrandScoped, options?: UseQueryOptions): UseQueryResult<T>;
|
|
40
|
+
/** Preview the credit for cancelling a reservation (advisory; cancel re-computes). */
|
|
41
|
+
declare function useReservationCancelPreview<T = CancelPreview>(args: {
|
|
42
|
+
brandId: string;
|
|
43
|
+
reservationId: string;
|
|
44
|
+
}, options?: UseQueryOptions): UseQueryResult<T>;
|
|
45
|
+
/** Preview the credit for cancelling an event order. */
|
|
46
|
+
declare function useEventOrderCancelPreview<T = CancelPreview>(args: {
|
|
47
|
+
brandId: string;
|
|
48
|
+
orderId: string;
|
|
49
|
+
}, options?: UseQueryOptions): UseQueryResult<T>;
|
|
50
|
+
/** Preview the credit for cancelling a package order. */
|
|
51
|
+
declare function usePackageOrderCancelPreview<T = CancelPreview>(args: {
|
|
52
|
+
brandId: string;
|
|
53
|
+
orderId: string;
|
|
54
|
+
}, options?: UseQueryOptions): UseQueryResult<T>;
|
|
55
|
+
/** Preview the credit for cancelling a game card (full credit only if unused). */
|
|
56
|
+
declare function useGameCardCancelPreview<T = CancelPreview>(args: {
|
|
57
|
+
brandId: string;
|
|
58
|
+
cardId: string;
|
|
59
|
+
}, options?: UseQueryOptions): UseQueryResult<T>;
|
|
60
|
+
/** Cancel a reservation → store credit per policy. Pass the `version` from the
|
|
61
|
+
* list/detail as `expectedVersion`; the hook supplies the idempotency key. */
|
|
62
|
+
declare function useCancelMyReservation(): UseMutationResult<Omit<ReservationCancelArgs, "idempotencyKey">, CancelResult>;
|
|
63
|
+
/** Cancel an event order → store credit per policy. */
|
|
64
|
+
declare function useCancelMyEventOrder(): UseMutationResult<Omit<OrderCancelArgs, "idempotencyKey">, CancelResult>;
|
|
65
|
+
/** Cancel a package order → store credit per policy; releases the slot. */
|
|
66
|
+
declare function useCancelMyPackageOrder(): UseMutationResult<Omit<OrderCancelArgs, "idempotencyKey">, CancelResult>;
|
|
67
|
+
/** Cancel a game card → full credit (unused cards only). */
|
|
68
|
+
declare function useCancelMyGameCard(): UseMutationResult<Omit<GameCardCancelArgs, "idempotencyKey">, CancelResult>;
|
|
42
69
|
/** The public flash-sale page (members see prices; anonymous gets the locked view). */
|
|
43
70
|
declare function useFlashSale<T = unknown>(args: FlashSaleArgs, options?: UseQueryOptions): UseQueryResult<T>;
|
|
44
71
|
/** The public flash-sale index for a Brand (live + upcoming; no prices). Public. */
|
|
@@ -223,4 +250,4 @@ interface UseSubscriptionCheckoutResult {
|
|
|
223
250
|
*/
|
|
224
251
|
declare function useMembershipSubscriptionCheckout(): UseSubscriptionCheckoutResult;
|
|
225
252
|
|
|
226
|
-
export { type BookingFlowStatus, type BookingReservationRef, type PurchasePaymentIntent, type PurchaseStatus, type UseBookingFlowResult, type UsePurchaseResult, UseQueryOptions, UseQueryResult, type UseSubscriptionCheckoutResult, useAddons, useAvailability, useBookingFlow, useBookingPreview, useCatalog, useCenterHours, useEventOffer, useEventOffers, useEventTicketPreview, useEventTicketPurchase, useEvents, useFlashSale, useFlashSaleBookingOptions, useFlashSales, useGameCardPreview, useGameCardPurchase, useGameCards, useMembershipPreview, useMembershipPurchase, useMembershipSubscriptionCheckout, useMembershipSubscriptionPreview, useMyCredits, useMyEventOrder, useMyEventOrders, useMyLoyalty, useMyMembershipDetail, useMyMemberships, useMyPasses, useMyReservationDetail, useMyReservations, usePackage, usePackagePreview, usePackagePurchase, usePackages, useProducts, usePublicMemberships, usePurchase, useStartTimes };
|
|
253
|
+
export { type BookingFlowStatus, type BookingReservationRef, type PurchasePaymentIntent, type PurchaseStatus, type UseBookingFlowResult, UseMutationResult, type UsePurchaseResult, UseQueryOptions, UseQueryResult, type UseSubscriptionCheckoutResult, useAddons, useAvailability, useBookingFlow, useBookingPreview, useCancelMyEventOrder, useCancelMyGameCard, useCancelMyPackageOrder, useCancelMyReservation, useCatalog, useCenterHours, useEventOffer, useEventOffers, useEventOrderCancelPreview, useEventTicketPreview, useEventTicketPurchase, useEvents, useFlashSale, useFlashSaleBookingOptions, useFlashSales, useGameCardCancelPreview, useGameCardPreview, useGameCardPurchase, useGameCards, useMembershipPreview, useMembershipPurchase, useMembershipSubscriptionCheckout, useMembershipSubscriptionPreview, useMyCredits, useMyEventOrder, useMyEventOrders, useMyGameCards, useMyLoyalty, useMyMembershipDetail, useMyMemberships, useMyPasses, useMyReservationDetail, useMyReservations, usePackage, usePackageOrderCancelPreview, usePackagePreview, usePackagePurchase, usePackages, useProducts, usePublicMemberships, usePurchase, useReservationCancelPreview, useStartTimes };
|
package/dist/react.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useBowlosClient } from './chunk-
|
|
2
|
-
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 } from './chunk-
|
|
1
|
+
import { useBowlosClient } from './chunk-CRETIPLS.js';
|
|
2
|
+
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 } from './chunk-CRETIPLS.js';
|
|
3
3
|
import { BowlosApiError, getGameCardStatus, createGameCardOrder, getPackageStatus, createPackageOrder, getEventTicketStatus, createEventTicketOrder, getMembershipStatus, createMembershipOrder, createMembershipSubscriptionOrder } from './chunk-S5T4OCBY.js';
|
|
4
4
|
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
5
5
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bowlos/reservations",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "BowlOS Reservations SDK \u2014 headless client + React hooks for the Module 14 public API gateway. White-label booking, account, and flash-sale reads for third-party-hosted center sites.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "BowlOS",
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { g as BowlosClient } from './data-BKlgn8Ln.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Typed account + flash reads for @bowlos/reservations.
|
|
5
|
-
*
|
|
6
|
-
* Session-scoped account reads (require a signed-in customer) and the
|
|
7
|
-
* session-aware flash-sale reads. Args are typed precisely — every account read
|
|
8
|
-
* is brand-scoped. Results are generic (`<T = unknown>`): parameterize with your
|
|
9
|
-
* own shape, or read `unknown` and narrow. (The backend return shapes are rich
|
|
10
|
-
* and evolving; the SDK doesn't pin them here.) Each read has a framework-agnostic
|
|
11
|
-
* function here and a React hook in `hooks.tsx`.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/** Every account read is scoped to the customer's Brand. */
|
|
15
|
-
type BrandScoped = {
|
|
16
|
-
brandId: string;
|
|
17
|
-
};
|
|
18
|
-
type ReservationDetailArgs = {
|
|
19
|
-
brandId: string;
|
|
20
|
-
displayId: string;
|
|
21
|
-
};
|
|
22
|
-
type EventOrderDetailArgs = {
|
|
23
|
-
brandId: string;
|
|
24
|
-
orderId: string;
|
|
25
|
-
};
|
|
26
|
-
type MembershipDetailArgs = {
|
|
27
|
-
brandId: string;
|
|
28
|
-
membershipId: string;
|
|
29
|
-
};
|
|
30
|
-
type FlashSaleArgs = {
|
|
31
|
-
slug: string;
|
|
32
|
-
};
|
|
33
|
-
type FlashBookingOptionsArgs = {
|
|
34
|
-
slug: string;
|
|
35
|
-
itemId: string;
|
|
36
|
-
};
|
|
37
|
-
type FlashSalesArgs = {
|
|
38
|
-
brandId: string;
|
|
39
|
-
};
|
|
40
|
-
declare function getMyReservations<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
41
|
-
declare function getMyReservationDetail<T = unknown>(client: BowlosClient, args: ReservationDetailArgs): Promise<T>;
|
|
42
|
-
declare function getMyEventOrders<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
43
|
-
declare function getMyEventOrder<T = unknown>(client: BowlosClient, args: EventOrderDetailArgs): Promise<T>;
|
|
44
|
-
declare function getMyMemberships<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
45
|
-
declare function getMyMembershipDetail<T = unknown>(client: BowlosClient, args: MembershipDetailArgs): Promise<T>;
|
|
46
|
-
declare function getMyLoyalty<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
47
|
-
declare function getMyCredits<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
48
|
-
declare function getMyPasses<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
49
|
-
declare function getFlashSale<T = unknown>(client: BowlosClient, args: FlashSaleArgs): Promise<T>;
|
|
50
|
-
/** The public flash-sale index for a Brand (live + upcoming; no prices). Public. */
|
|
51
|
-
declare function getFlashSales<T = unknown>(client: BowlosClient, args: FlashSalesArgs): Promise<T>;
|
|
52
|
-
declare function getFlashSaleBookingOptions<T = unknown>(client: BowlosClient, args: FlashBookingOptionsArgs): Promise<T>;
|
|
53
|
-
|
|
54
|
-
export { type BrandScoped as B, type EventOrderDetailArgs as E, type FlashBookingOptionsArgs as F, type MembershipDetailArgs as M, type ReservationDetailArgs as R, type FlashSaleArgs as a, type FlashSalesArgs as b, getFlashSaleBookingOptions as c, getFlashSales as d, getMyCredits as e, getMyEventOrder as f, getFlashSale as g, getMyEventOrders as h, getMyLoyalty as i, getMyMembershipDetail as j, getMyMemberships as k, getMyPasses as l, getMyReservationDetail as m, getMyReservations as n };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { g as BowlosClient } from './data-BKlgn8Ln.cjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Typed account + flash reads for @bowlos/reservations.
|
|
5
|
-
*
|
|
6
|
-
* Session-scoped account reads (require a signed-in customer) and the
|
|
7
|
-
* session-aware flash-sale reads. Args are typed precisely — every account read
|
|
8
|
-
* is brand-scoped. Results are generic (`<T = unknown>`): parameterize with your
|
|
9
|
-
* own shape, or read `unknown` and narrow. (The backend return shapes are rich
|
|
10
|
-
* and evolving; the SDK doesn't pin them here.) Each read has a framework-agnostic
|
|
11
|
-
* function here and a React hook in `hooks.tsx`.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/** Every account read is scoped to the customer's Brand. */
|
|
15
|
-
type BrandScoped = {
|
|
16
|
-
brandId: string;
|
|
17
|
-
};
|
|
18
|
-
type ReservationDetailArgs = {
|
|
19
|
-
brandId: string;
|
|
20
|
-
displayId: string;
|
|
21
|
-
};
|
|
22
|
-
type EventOrderDetailArgs = {
|
|
23
|
-
brandId: string;
|
|
24
|
-
orderId: string;
|
|
25
|
-
};
|
|
26
|
-
type MembershipDetailArgs = {
|
|
27
|
-
brandId: string;
|
|
28
|
-
membershipId: string;
|
|
29
|
-
};
|
|
30
|
-
type FlashSaleArgs = {
|
|
31
|
-
slug: string;
|
|
32
|
-
};
|
|
33
|
-
type FlashBookingOptionsArgs = {
|
|
34
|
-
slug: string;
|
|
35
|
-
itemId: string;
|
|
36
|
-
};
|
|
37
|
-
type FlashSalesArgs = {
|
|
38
|
-
brandId: string;
|
|
39
|
-
};
|
|
40
|
-
declare function getMyReservations<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
41
|
-
declare function getMyReservationDetail<T = unknown>(client: BowlosClient, args: ReservationDetailArgs): Promise<T>;
|
|
42
|
-
declare function getMyEventOrders<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
43
|
-
declare function getMyEventOrder<T = unknown>(client: BowlosClient, args: EventOrderDetailArgs): Promise<T>;
|
|
44
|
-
declare function getMyMemberships<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
45
|
-
declare function getMyMembershipDetail<T = unknown>(client: BowlosClient, args: MembershipDetailArgs): Promise<T>;
|
|
46
|
-
declare function getMyLoyalty<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
47
|
-
declare function getMyCredits<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
48
|
-
declare function getMyPasses<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
|
|
49
|
-
declare function getFlashSale<T = unknown>(client: BowlosClient, args: FlashSaleArgs): Promise<T>;
|
|
50
|
-
/** The public flash-sale index for a Brand (live + upcoming; no prices). Public. */
|
|
51
|
-
declare function getFlashSales<T = unknown>(client: BowlosClient, args: FlashSalesArgs): Promise<T>;
|
|
52
|
-
declare function getFlashSaleBookingOptions<T = unknown>(client: BowlosClient, args: FlashBookingOptionsArgs): Promise<T>;
|
|
53
|
-
|
|
54
|
-
export { type BrandScoped as B, type EventOrderDetailArgs as E, type FlashBookingOptionsArgs as F, type MembershipDetailArgs as M, type ReservationDetailArgs as R, type FlashSaleArgs as a, type FlashSalesArgs as b, getFlashSaleBookingOptions as c, getFlashSales as d, getMyCredits as e, getMyEventOrder as f, getFlashSale as g, getMyEventOrders as h, getMyLoyalty as i, getMyMembershipDetail as j, getMyMemberships as k, getMyPasses as l, getMyReservationDetail as m, getMyReservations as n };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/react.tsx","../src/hooks.tsx","../src/use-booking-flow.tsx"],"names":["useState","useRef","useCallback","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,CAAC,aAAA,CAAc,QAAA,EAAd,EAAuB,KAAA,EAAO,YAAA,EAC7B,QAAA,kBAAA,GAAA,CAAC,cAAA,CAAe,QAAA,EAAf,EAAwB,KAAA,EAAO,OAAA,EAAU,UAAS,CAAA,EACrD,CAAA;AAEJ;AAEO,SAAS,eAAA,GAAgC;AAC9C,EAAA,MAAM,MAAA,GAAS,WAAW,aAAa,CAAA;AACvC,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,MAAM,IAAI,MAAM,yDAAyD,CAAA;AAAA,EAC3E;AACA,EAAA,OAAO,MAAA;AACT;AAoB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AA,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-FV6SROO2.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 * 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 { useBowlosQuery, type UseQueryOptions, type UseQueryResult } from \"./react\";\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// ── 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"]}
|