@bowlos/reservations 0.20.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/HEADLESS.md +205 -6
  2. package/README.md +24 -10
  3. package/dist/account-CO8xzUs_.d.ts +54 -0
  4. package/dist/account-SqT7et4C.d.cts +54 -0
  5. package/dist/catalog-BxyPJdBL.d.ts +160 -0
  6. package/dist/catalog-D1VoVaNe.d.cts +160 -0
  7. package/dist/{chunk-3GAXATYP.js → chunk-FV6SROO2.js} +22 -4
  8. package/dist/chunk-FV6SROO2.js.map +1 -0
  9. package/dist/{chunk-32FTBLXQ.js → chunk-S5T4OCBY.js} +25 -3
  10. package/dist/chunk-S5T4OCBY.js.map +1 -0
  11. package/dist/components.cjs +32 -91
  12. package/dist/components.cjs.map +1 -1
  13. package/dist/components.d.cts +36 -57
  14. package/dist/components.d.ts +36 -57
  15. package/dist/components.js +32 -79
  16. package/dist/components.js.map +1 -1
  17. package/dist/{data-ymW_rWbz.d.cts → data-BKlgn8Ln.d.cts} +72 -1
  18. package/dist/{data-ymW_rWbz.d.ts → data-BKlgn8Ln.d.ts} +72 -1
  19. package/dist/index.cjs +45 -0
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +4 -4
  22. package/dist/index.d.ts +4 -4
  23. package/dist/index.js +18 -3
  24. package/dist/index.js.map +1 -1
  25. package/dist/payments.d.cts +1 -1
  26. package/dist/payments.d.ts +1 -1
  27. package/dist/{react-Bh0z-Lnb.d.ts → react-B1uSOozS.d.ts} +2 -2
  28. package/dist/{react-DHvo_ZHf.d.cts → react-Bc_6yi9q.d.cts} +2 -2
  29. package/dist/react.cjs +73 -0
  30. package/dist/react.cjs.map +1 -1
  31. package/dist/react.d.cts +36 -6
  32. package/dist/react.d.ts +36 -6
  33. package/dist/react.js +37 -4
  34. package/dist/react.js.map +1 -1
  35. package/package.json +2 -2
  36. package/templates/center-site/package.json +1 -1
  37. package/dist/catalog-BGPCoIOm.d.ts +0 -93
  38. package/dist/catalog-eofYl46p.d.cts +0 -93
  39. package/dist/chunk-32FTBLXQ.js.map +0 -1
  40. package/dist/chunk-3GAXATYP.js.map +0 -1
  41. package/dist/errors-IIK7xibp.d.cts +0 -54
  42. package/dist/errors-IIK7xibp.d.ts +0 -54
package/dist/react.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import { U as UseQueryOptions, a as UseQueryResult } from './react-DHvo_ZHf.cjs';
2
- export { A as AccountStatus, B as BowlosProvider, b as BowlosProviderProps, c as UseAccountResult, u as useAccount, d as useBowlosClient, e as useBowlosQuery } from './react-DHvo_ZHf.cjs';
3
- import { O as PublicAddon, a as AvailabilityArgs, b as AvailabilityResult, e as BookingPreviewArgs, f as BookingQuote, n as GameCardPreviewResult, m as GameCardPreviewArgs, s as MembershipPreviewResult, r as MembershipPreviewArgs, y as MembershipSubscriptionPreviewResult, D as PackagePreviewResult, z as PackagePreviewArgs, S as StartTimesArgs, d as BookingHold, J as PaymentIntentInfo, k as CreateBookingArgs, i as CheckoutStatusResult, x as MembershipSubscriptionIntent, w as MembershipSubscriptionArgs, o as GameCardPurchaseArgs, t as MembershipPurchaseArgs, E as PackagePurchaseArgs } from './data-ymW_rWbz.cjs';
4
- import { C as CenterHoursArgs, b as CenterScoped, c as FlashSaleArgs, F as FlashBookingOptionsArgs, d as FlashSalesArgs, B as BrandCatalogArgs, a as BrandScoped, M as MembershipDetailArgs, R as ReservationDetailArgs, P as PackageDetailArgs } from './catalog-eofYl46p.cjs';
5
- import { a as BowlosApiError } from './errors-IIK7xibp.cjs';
1
+ import { U as UseQueryOptions, a as UseQueryResult } from './react-Bc_6yi9q.cjs';
2
+ export { A as AccountStatus, B as BowlosProvider, b as BowlosProviderProps, c as UseAccountResult, u as useAccount, d as useBowlosClient, e as useBowlosQuery } from './react-Bc_6yi9q.cjs';
3
+ 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
+ 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
 
@@ -25,6 +25,10 @@ declare function useStartTimes(args: StartTimesArgs, options?: UseQueryOptions):
25
25
  declare function useMyReservations<T = unknown>(args: BrandScoped, options?: UseQueryOptions): UseQueryResult<T>;
26
26
  /** One of the customer's reservations, by displayId. */
27
27
  declare function useMyReservationDetail<T = unknown>(args: ReservationDetailArgs, options?: UseQueryOptions): UseQueryResult<T>;
28
+ /** The signed-in customer's event ticket orders. */
29
+ declare function useMyEventOrders<T = unknown>(args: BrandScoped, options?: UseQueryOptions): UseQueryResult<T>;
30
+ /** One of the customer's event ticket orders. */
31
+ declare function useMyEventOrder<T = unknown>(args: EventOrderDetailArgs, options?: UseQueryOptions): UseQueryResult<T>;
28
32
  /** The customer's memberships. */
29
33
  declare function useMyMemberships<T = unknown>(args: BrandScoped, options?: UseQueryOptions): UseQueryResult<T>;
30
34
  /** One membership's detail. */
@@ -41,10 +45,24 @@ declare function useFlashSale<T = unknown>(args: FlashSaleArgs, options?: UseQue
41
45
  declare function useFlashSales<T = unknown>(args: FlashSalesArgs, options?: UseQueryOptions): UseQueryResult<T>;
42
46
  /** Per-start-hour options for a flash-sale reservation item (members only). */
43
47
  declare function useFlashSaleBookingOptions<T = unknown>(args: FlashBookingOptionsArgs, options?: UseQueryOptions): UseQueryResult<T>;
48
+ /**
49
+ * The canonical public catalog for a surface — every category grouped, with the
50
+ * Center admin's per-surface visibility already applied. Prefer this over the
51
+ * per-category hooks below when you want the full, visibility-aware catalog
52
+ * (it stays consistent with the white-label web + mobile surfaces). Anonymous.
53
+ */
54
+ declare function useCatalog<T = CatalogResult>(args: CatalogArgs, options?: UseQueryOptions): UseQueryResult<T>;
44
55
  /** Bookable products at a Center (each carries `attractionTypeKey`). */
45
56
  declare function useProducts<T = unknown>(args: CenterScoped, options?: UseQueryOptions): UseQueryResult<T>;
46
57
  /** Upcoming pricing events at a Center. */
47
58
  declare function useEvents<T = unknown>(args: CenterScoped, options?: UseQueryOptions): UseQueryResult<T>;
59
+ /** Sellable event offers at a Center. Use these for the product lineup and
60
+ * event landing pages; each row carries a slug and purchase mode. */
61
+ declare function useEventOffers<T = unknown>(args: CenterScoped, options?: UseQueryOptions): UseQueryResult<T>;
62
+ /** One sellable event offer by landing-page slug. */
63
+ declare function useEventOffer<T = unknown>(args: {
64
+ slug: string;
65
+ }, options?: UseQueryOptions): UseQueryResult<T>;
48
66
  /** Purchasable packages at a Brand. */
49
67
  declare function usePackages<T = unknown>(args: BrandCatalogArgs, options?: UseQueryOptions): UseQueryResult<T>;
50
68
  /** Full detail for one package (components, add-ons, allowed start times, …) —
@@ -70,6 +88,10 @@ declare function useGameCards<T = unknown>(args: BrandCatalogArgs, options?: Use
70
88
  * same engine as the PaymentIntent, so it never diverges from what the
71
89
  * customer is charged. */
72
90
  declare function useGameCardPreview<T = GameCardPreviewResult>(args: GameCardPreviewArgs, options?: UseQueryOptions): UseQueryResult<T>;
91
+ /** Itemized quote for a ticket-mode event offer — base tickets, tax lines,
92
+ * Center event fee, and authoritative grand total. Requires a signed-in
93
+ * customer so tax exemptions match the eventual charge. */
94
+ declare function useEventTicketPreview<T = EventTicketPreviewResult>(args: EventTicketPreviewArgs, options?: UseQueryOptions): UseQueryResult<T>;
73
95
  /** Itemized quote for a one-time membership purchase — dues, the one-time setup
74
96
  * fee, tax lines, the selling Center's booking fee, and the authoritative grand
75
97
  * total. Drives the headless **Review** step. Requires a signed-in customer (tax
@@ -163,6 +185,14 @@ declare function useGameCardPurchase(): UsePurchaseResult<GameCardPurchaseArgs>;
163
185
  * MUST be one of those slots or the create rejects with VALIDATION_FAILED.
164
186
  */
165
187
  declare function usePackagePurchase(): UsePurchaseResult<PackagePurchaseArgs>;
188
+ /**
189
+ * Buy tickets for a ticket-mode event offer. `start({ eventOfferId, quantity })`
190
+ * → render `<BowlosPaymentForm {...purchase.paymentIntent} onPaid={purchase.startPolling}>`
191
+ * → `status === "confirmed"` (`resultId` = the event order id). The charge
192
+ * lands on the operator's connected account and the order receipt is available
193
+ * through `useMyEventOrder` after confirmation.
194
+ */
195
+ declare function useEventTicketPurchase(): UsePurchaseResult<EventTicketPurchaseArgs>;
166
196
  /**
167
197
  * Buy a one-time membership. Same lifecycle as a game pass (no config) —
168
198
  * `start({ templateId })` → render
@@ -193,4 +223,4 @@ interface UseSubscriptionCheckoutResult {
193
223
  */
194
224
  declare function useMembershipSubscriptionCheckout(): UseSubscriptionCheckoutResult;
195
225
 
196
- export { type BookingFlowStatus, type BookingReservationRef, type PurchasePaymentIntent, type PurchaseStatus, type UseBookingFlowResult, type UsePurchaseResult, UseQueryOptions, UseQueryResult, type UseSubscriptionCheckoutResult, useAddons, useAvailability, useBookingFlow, useBookingPreview, useCenterHours, useEvents, useFlashSale, useFlashSaleBookingOptions, useFlashSales, useGameCardPreview, useGameCardPurchase, useGameCards, useMembershipPreview, useMembershipPurchase, useMembershipSubscriptionCheckout, useMembershipSubscriptionPreview, useMyCredits, useMyLoyalty, useMyMembershipDetail, useMyMemberships, useMyPasses, useMyReservationDetail, useMyReservations, usePackage, usePackagePreview, usePackagePurchase, usePackages, useProducts, usePublicMemberships, usePurchase, useStartTimes };
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 };
package/dist/react.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { U as UseQueryOptions, a as UseQueryResult } from './react-Bh0z-Lnb.js';
2
- export { A as AccountStatus, B as BowlosProvider, b as BowlosProviderProps, c as UseAccountResult, u as useAccount, d as useBowlosClient, e as useBowlosQuery } from './react-Bh0z-Lnb.js';
3
- import { O as PublicAddon, a as AvailabilityArgs, b as AvailabilityResult, e as BookingPreviewArgs, f as BookingQuote, n as GameCardPreviewResult, m as GameCardPreviewArgs, s as MembershipPreviewResult, r as MembershipPreviewArgs, y as MembershipSubscriptionPreviewResult, D as PackagePreviewResult, z as PackagePreviewArgs, S as StartTimesArgs, d as BookingHold, J as PaymentIntentInfo, k as CreateBookingArgs, i as CheckoutStatusResult, x as MembershipSubscriptionIntent, w as MembershipSubscriptionArgs, o as GameCardPurchaseArgs, t as MembershipPurchaseArgs, E as PackagePurchaseArgs } from './data-ymW_rWbz.js';
4
- import { C as CenterHoursArgs, b as CenterScoped, c as FlashSaleArgs, F as FlashBookingOptionsArgs, d as FlashSalesArgs, B as BrandCatalogArgs, a as BrandScoped, M as MembershipDetailArgs, R as ReservationDetailArgs, P as PackageDetailArgs } from './catalog-BGPCoIOm.js';
5
- import { a as BowlosApiError } from './errors-IIK7xibp.js';
1
+ import { U as UseQueryOptions, a as UseQueryResult } from './react-B1uSOozS.js';
2
+ export { A as AccountStatus, B as BowlosProvider, b as BowlosProviderProps, c as UseAccountResult, u as useAccount, d as useBowlosClient, e as useBowlosQuery } from './react-B1uSOozS.js';
3
+ 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
+ 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
 
@@ -25,6 +25,10 @@ declare function useStartTimes(args: StartTimesArgs, options?: UseQueryOptions):
25
25
  declare function useMyReservations<T = unknown>(args: BrandScoped, options?: UseQueryOptions): UseQueryResult<T>;
26
26
  /** One of the customer's reservations, by displayId. */
27
27
  declare function useMyReservationDetail<T = unknown>(args: ReservationDetailArgs, options?: UseQueryOptions): UseQueryResult<T>;
28
+ /** The signed-in customer's event ticket orders. */
29
+ declare function useMyEventOrders<T = unknown>(args: BrandScoped, options?: UseQueryOptions): UseQueryResult<T>;
30
+ /** One of the customer's event ticket orders. */
31
+ declare function useMyEventOrder<T = unknown>(args: EventOrderDetailArgs, options?: UseQueryOptions): UseQueryResult<T>;
28
32
  /** The customer's memberships. */
29
33
  declare function useMyMemberships<T = unknown>(args: BrandScoped, options?: UseQueryOptions): UseQueryResult<T>;
30
34
  /** One membership's detail. */
@@ -41,10 +45,24 @@ declare function useFlashSale<T = unknown>(args: FlashSaleArgs, options?: UseQue
41
45
  declare function useFlashSales<T = unknown>(args: FlashSalesArgs, options?: UseQueryOptions): UseQueryResult<T>;
42
46
  /** Per-start-hour options for a flash-sale reservation item (members only). */
43
47
  declare function useFlashSaleBookingOptions<T = unknown>(args: FlashBookingOptionsArgs, options?: UseQueryOptions): UseQueryResult<T>;
48
+ /**
49
+ * The canonical public catalog for a surface — every category grouped, with the
50
+ * Center admin's per-surface visibility already applied. Prefer this over the
51
+ * per-category hooks below when you want the full, visibility-aware catalog
52
+ * (it stays consistent with the white-label web + mobile surfaces). Anonymous.
53
+ */
54
+ declare function useCatalog<T = CatalogResult>(args: CatalogArgs, options?: UseQueryOptions): UseQueryResult<T>;
44
55
  /** Bookable products at a Center (each carries `attractionTypeKey`). */
45
56
  declare function useProducts<T = unknown>(args: CenterScoped, options?: UseQueryOptions): UseQueryResult<T>;
46
57
  /** Upcoming pricing events at a Center. */
47
58
  declare function useEvents<T = unknown>(args: CenterScoped, options?: UseQueryOptions): UseQueryResult<T>;
59
+ /** Sellable event offers at a Center. Use these for the product lineup and
60
+ * event landing pages; each row carries a slug and purchase mode. */
61
+ declare function useEventOffers<T = unknown>(args: CenterScoped, options?: UseQueryOptions): UseQueryResult<T>;
62
+ /** One sellable event offer by landing-page slug. */
63
+ declare function useEventOffer<T = unknown>(args: {
64
+ slug: string;
65
+ }, options?: UseQueryOptions): UseQueryResult<T>;
48
66
  /** Purchasable packages at a Brand. */
49
67
  declare function usePackages<T = unknown>(args: BrandCatalogArgs, options?: UseQueryOptions): UseQueryResult<T>;
50
68
  /** Full detail for one package (components, add-ons, allowed start times, …) —
@@ -70,6 +88,10 @@ declare function useGameCards<T = unknown>(args: BrandCatalogArgs, options?: Use
70
88
  * same engine as the PaymentIntent, so it never diverges from what the
71
89
  * customer is charged. */
72
90
  declare function useGameCardPreview<T = GameCardPreviewResult>(args: GameCardPreviewArgs, options?: UseQueryOptions): UseQueryResult<T>;
91
+ /** Itemized quote for a ticket-mode event offer — base tickets, tax lines,
92
+ * Center event fee, and authoritative grand total. Requires a signed-in
93
+ * customer so tax exemptions match the eventual charge. */
94
+ declare function useEventTicketPreview<T = EventTicketPreviewResult>(args: EventTicketPreviewArgs, options?: UseQueryOptions): UseQueryResult<T>;
73
95
  /** Itemized quote for a one-time membership purchase — dues, the one-time setup
74
96
  * fee, tax lines, the selling Center's booking fee, and the authoritative grand
75
97
  * total. Drives the headless **Review** step. Requires a signed-in customer (tax
@@ -163,6 +185,14 @@ declare function useGameCardPurchase(): UsePurchaseResult<GameCardPurchaseArgs>;
163
185
  * MUST be one of those slots or the create rejects with VALIDATION_FAILED.
164
186
  */
165
187
  declare function usePackagePurchase(): UsePurchaseResult<PackagePurchaseArgs>;
188
+ /**
189
+ * Buy tickets for a ticket-mode event offer. `start({ eventOfferId, quantity })`
190
+ * → render `<BowlosPaymentForm {...purchase.paymentIntent} onPaid={purchase.startPolling}>`
191
+ * → `status === "confirmed"` (`resultId` = the event order id). The charge
192
+ * lands on the operator's connected account and the order receipt is available
193
+ * through `useMyEventOrder` after confirmation.
194
+ */
195
+ declare function useEventTicketPurchase(): UsePurchaseResult<EventTicketPurchaseArgs>;
166
196
  /**
167
197
  * Buy a one-time membership. Same lifecycle as a game pass (no config) —
168
198
  * `start({ templateId })` → render
@@ -193,4 +223,4 @@ interface UseSubscriptionCheckoutResult {
193
223
  */
194
224
  declare function useMembershipSubscriptionCheckout(): UseSubscriptionCheckoutResult;
195
225
 
196
- export { type BookingFlowStatus, type BookingReservationRef, type PurchasePaymentIntent, type PurchaseStatus, type UseBookingFlowResult, type UsePurchaseResult, UseQueryOptions, UseQueryResult, type UseSubscriptionCheckoutResult, useAddons, useAvailability, useBookingFlow, useBookingPreview, useCenterHours, useEvents, useFlashSale, useFlashSaleBookingOptions, useFlashSales, useGameCardPreview, useGameCardPurchase, useGameCards, useMembershipPreview, useMembershipPurchase, useMembershipSubscriptionCheckout, useMembershipSubscriptionPreview, useMyCredits, useMyLoyalty, useMyMembershipDetail, useMyMemberships, useMyPasses, useMyReservationDetail, useMyReservations, usePackage, usePackagePreview, usePackagePurchase, usePackages, useProducts, usePublicMemberships, usePurchase, useStartTimes };
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 };
package/dist/react.js CHANGED
@@ -1,6 +1,6 @@
1
- import { useBowlosClient } from './chunk-3GAXATYP.js';
2
- export { BowlosProvider, useAccount, useAddons, useAvailability, useBookingFlow, useBookingPreview, useBowlosClient, useBowlosQuery, useCenterHours, useEvents, useFlashSale, useFlashSaleBookingOptions, useFlashSales, useGameCardPreview, useGameCards, useMembershipPreview, useMembershipSubscriptionPreview, useMyCredits, useMyLoyalty, useMyMembershipDetail, useMyMemberships, useMyPasses, useMyReservationDetail, useMyReservations, usePackage, usePackagePreview, usePackages, useProducts, usePublicMemberships, useStartTimes } from './chunk-3GAXATYP.js';
3
- import { BowlosApiError, getGameCardStatus, createGameCardOrder, getPackageStatus, createPackageOrder, getMembershipStatus, createMembershipOrder, createMembershipSubscriptionOrder } from './chunk-32FTBLXQ.js';
1
+ import { useBowlosClient } from './chunk-FV6SROO2.js';
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-FV6SROO2.js';
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
 
6
6
  var DEFAULT_POLL_MS = 2500;
@@ -149,6 +149,39 @@ function usePackagePurchase() {
149
149
  }
150
150
  });
151
151
  }
152
+ function useEventTicketPurchase() {
153
+ const client = useBowlosClient();
154
+ return usePurchase({
155
+ createIntent: async (args) => {
156
+ const r = await createEventTicketOrder(client, args);
157
+ return {
158
+ paymentIntent: {
159
+ paymentIntentId: r.paymentIntentId,
160
+ clientSecret: r.clientSecret,
161
+ amountCents: r.amountCents,
162
+ connectedAccountId: r.connectedAccountId,
163
+ customerSessionClientSecret: r.customerSessionClientSecret
164
+ },
165
+ refToken: r.orderId
166
+ };
167
+ },
168
+ pollStatus: (orderId) => getEventTicketStatus(client, orderId),
169
+ interpret: (s) => {
170
+ switch (s.status) {
171
+ case "paid":
172
+ return { done: true, terminal: "confirmed", id: s.orderId };
173
+ case "cancelled":
174
+ case "refunded":
175
+ return { done: true, terminal: "failed", id: null };
176
+ case "not_found":
177
+ return { done: true, terminal: "error", id: null };
178
+ case "pending_payment":
179
+ default:
180
+ return { done: false, terminal: null, id: null };
181
+ }
182
+ }
183
+ });
184
+ }
152
185
  function useMembershipPurchase() {
153
186
  const client = useBowlosClient();
154
187
  return usePurchase({
@@ -215,6 +248,6 @@ function useMembershipSubscriptionCheckout() {
215
248
  return { status, subscriptionIntent, error, start, reset };
216
249
  }
217
250
 
218
- export { useGameCardPurchase, useMembershipPurchase, useMembershipSubscriptionCheckout, usePackagePurchase, usePurchase };
251
+ export { useEventTicketPurchase, useGameCardPurchase, useMembershipPurchase, useMembershipSubscriptionCheckout, usePackagePurchase, usePurchase };
219
252
  //# sourceMappingURL=react.js.map
220
253
  //# sourceMappingURL=react.js.map
package/dist/react.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/use-purchase.tsx"],"names":[],"mappings":";;;;;AA0EA,IAAM,eAAA,GAAkB,IAAA;AAEjB,SAAS,YAA0B,MAAA,EAMd;AAC1B,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAI,SAAyB,MAAM,CAAA;AAC3D,EAAA,MAAM,CAAC,aAAA,EAAe,gBAAgB,CAAA,GAAI,SAAuC,IAAI,CAAA;AACrF,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,SAAwB,IAAI,CAAA;AAC5D,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAAgC,IAAI,CAAA;AAE9D,EAAA,MAAM,WAAA,GAAc,OAAsB,IAAI,CAAA;AAC9C,EAAA,MAAM,OAAA,GAAU,OAA8C,IAAI,CAAA;AAElE,EAAA,MAAM,MAA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AAA,GACT;AAEA,EAAA,MAAM,KAAA,GAAQ,YAAY,MAAM;AAC9B,IAAA,qBAAA,CAAsB,IAAI,CAAA;AAC1B,IAAA,QAAA,CAAS,IAAI,CAAA;AACb,IAAA,SAAA,CAAU,MAAM,CAAA;AAAA,EAClB,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO,EAAE,MAAA,EAAQ,kBAAA,EAAoB,KAAA,EAAO,OAAO,KAAA,EAAM;AAC3D","file":"react.js","sourcesContent":["\"use client\";\n/**\n * usePurchase — the headless buy state machine for game passes (packages +\n * memberships adopt it next). Mirrors `useBookingFlow`, minus the inventory\n * hold: the PaymentIntent IS the purchase.\n *\n * start(args) → mints the connected-account PaymentIntent → \"awaitingPayment\"\n * [render <BowlosPaymentForm {...paymentIntent}> and the customer pays]\n * startPolling() → polls the type's status endpoint → \"confirmed\" (+ resultId)\n *\n * Per-type wrappers (`useGameCardPurchase`, …) supply the create call + a status\n * interpreter that maps the type's status to the shared terminal states (D2/D5).\n */\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useBowlosClient } from \"./react\";\nimport { BowlosApiError } from \"./errors\";\nimport {\n createGameCardOrder,\n getGameCardStatus,\n createPackageOrder,\n getPackageStatus,\n createMembershipOrder,\n getMembershipStatus,\n createMembershipSubscriptionOrder,\n type GameCardPurchaseArgs,\n type GameCardStatusResult,\n type PackagePurchaseArgs,\n type PackageStatusResult,\n type MembershipPurchaseArgs,\n type MembershipStatusResult,\n type MembershipSubscriptionArgs,\n type MembershipSubscriptionIntent,\n} from \"./data\";\n\nexport type PurchaseStatus =\n | \"idle\"\n | \"creating\"\n | \"awaitingPayment\"\n | \"confirming\"\n | \"confirmed\"\n | \"failed\"\n | \"expired\"\n | \"error\";\n\n/** The connected-account payment to confirm with `<BowlosPaymentForm>`. */\nexport interface PurchasePaymentIntent {\n paymentIntentId: string;\n clientSecret: string;\n amountCents: number;\n connectedAccountId: string;\n customerSessionClientSecret: string;\n}\n\nexport interface UsePurchaseResult<Args> {\n status: PurchaseStatus;\n paymentIntent: PurchasePaymentIntent | null;\n /** The materialized id (game card / order / membership) once confirmed. */\n resultId: string | null;\n error: BowlosApiError | null;\n /** Mint the PaymentIntent → \"awaitingPayment\". */\n start: (args: Args) => Promise<void>;\n /** Call after `<BowlosPaymentForm>` confirms → begins polling to materialization. */\n startPolling: (intervalMs?: number) => void;\n stopPolling: () => void;\n reset: () => void;\n}\n\n/** A type-specific status mapped to the shared terminal states. */\ntype Interpreted = {\n done: boolean;\n terminal: \"confirmed\" | \"failed\" | \"expired\" | \"error\" | null;\n id: string | null;\n};\n\nconst DEFAULT_POLL_MS = 2500;\n\nexport function usePurchase<Args, Status>(config: {\n createIntent: (\n args: Args,\n ) => Promise<{ paymentIntent: PurchasePaymentIntent; refToken: string | null }>;\n pollStatus: (refToken: string) => Promise<Status>;\n interpret: (status: Status) => Interpreted;\n}): UsePurchaseResult<Args> {\n const [status, setStatus] = useState<PurchaseStatus>(\"idle\");\n const [paymentIntent, setPaymentIntent] = useState<PurchasePaymentIntent | null>(null);\n const [resultId, setResultId] = useState<string | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n\n const refTokenRef = useRef<string | null>(null);\n const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);\n // Latest config in a ref so the polling interval never captures a stale closure.\n const cfgRef = useRef(config);\n cfgRef.current = config;\n\n const stopPolling = useCallback(() => {\n if (pollRef.current !== null) {\n clearInterval(pollRef.current);\n pollRef.current = null;\n }\n }, []);\n useEffect(() => stopPolling, [stopPolling]);\n\n const reset = useCallback(() => {\n stopPolling();\n refTokenRef.current = null;\n setPaymentIntent(null);\n setResultId(null);\n setError(null);\n setStatus(\"idle\");\n }, [stopPolling]);\n\n const start = useCallback(\n async (args: Args) => {\n stopPolling();\n setError(null);\n setResultId(null);\n setPaymentIntent(null);\n setStatus(\"creating\");\n try {\n const { paymentIntent: pi, refToken } = await cfgRef.current.createIntent(args);\n refTokenRef.current = refToken;\n setPaymentIntent(pi);\n setStatus(\"awaitingPayment\");\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n setStatus(\"error\");\n }\n },\n [stopPolling],\n );\n\n const poll = useCallback(async () => {\n const rt = refTokenRef.current;\n if (!rt) return;\n try {\n const r = cfgRef.current.interpret(await cfgRef.current.pollStatus(rt));\n if (!r.done) return;\n stopPolling();\n if (r.terminal === \"confirmed\") {\n setResultId(r.id);\n setStatus(\"confirmed\");\n } else if (r.terminal === \"expired\") {\n setStatus(\"expired\");\n } else if (r.terminal === \"failed\") {\n setStatus(\"failed\");\n } else {\n setError(new BowlosApiError(\"NOT_FOUND\", \"Purchase not found.\", 404));\n setStatus(\"error\");\n }\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n }\n }, [stopPolling]);\n\n const startPolling = useCallback(\n (intervalMs: number = DEFAULT_POLL_MS) => {\n stopPolling();\n setStatus(\"confirming\");\n void poll();\n pollRef.current = setInterval(() => void poll(), intervalMs);\n },\n [poll, stopPolling],\n );\n\n return { status, paymentIntent, resultId, error, start, startPolling, stopPolling, reset };\n}\n\n/**\n * Buy a game pass. `start({ templateId })` → render\n * `<BowlosPaymentForm {...purchase.paymentIntent} onPaid={purchase.startPolling}>`\n * → `status === \"confirmed\"` (`resultId` = the new game card id).\n */\nexport function useGameCardPurchase(): UsePurchaseResult<GameCardPurchaseArgs> {\n const client = useBowlosClient();\n return usePurchase<GameCardPurchaseArgs, GameCardStatusResult>({\n createIntent: async (args) => {\n const r = await createGameCardOrder(client, args);\n return {\n paymentIntent: {\n paymentIntentId: r.paymentIntentId,\n clientSecret: r.clientSecret,\n amountCents: r.amountCents,\n connectedAccountId: r.connectedAccountId,\n customerSessionClientSecret: r.customerSessionClientSecret,\n },\n refToken: r.refToken,\n };\n },\n pollStatus: (refToken) => getGameCardStatus(client, refToken),\n interpret: (s) => {\n switch (s.status) {\n case \"paid_materialized\":\n return { done: true, terminal: \"confirmed\", id: s.gameCardId };\n case \"expired\":\n return { done: true, terminal: \"expired\", id: null };\n case \"payment_failed_retryable\":\n case \"abandoned\":\n return { done: true, terminal: \"failed\", id: null };\n case \"not_found\":\n return { done: true, terminal: \"error\", id: null };\n case \"pending_payment\":\n default:\n return { done: false, terminal: null, id: null };\n }\n },\n });\n}\n\n/**\n * Buy a package (birthday party, lane bundle, …). Unlike a game pass, a package\n * carries a configuration — `start()` takes the Center, date/time, quantity, and\n * any optional add-ons:\n *\n * start({ packageId, centerId, quantity, scheduledDate, scheduledStartMinute, optionalAddons })\n * → render `<BowlosPaymentForm {...purchase.paymentIntent} onPaid={purchase.startPolling}>`\n * → `status === \"confirmed\"` (`resultId` = the new package order id).\n *\n * The site owns the config UI (see HEADLESS.md → \"Buying a package\" for computing\n * the bookable start times from the package + Center hours). `scheduledStartMinute`\n * MUST be one of those slots or the create rejects with VALIDATION_FAILED.\n */\nexport function usePackagePurchase(): UsePurchaseResult<PackagePurchaseArgs> {\n const client = useBowlosClient();\n return usePurchase<PackagePurchaseArgs, PackageStatusResult>({\n createIntent: async (args) => {\n const r = await createPackageOrder(client, args);\n return {\n paymentIntent: {\n paymentIntentId: r.paymentIntentId,\n clientSecret: r.clientSecret,\n amountCents: r.amountCents,\n connectedAccountId: r.connectedAccountId,\n customerSessionClientSecret: r.customerSessionClientSecret,\n },\n // The order id is the poll handle (packages have no refToken).\n refToken: r.orderId,\n };\n },\n pollStatus: (orderId) => getPackageStatus(client, orderId),\n interpret: (s) => {\n switch (s.status) {\n case \"paid\":\n return { done: true, terminal: \"confirmed\", id: s.orderId };\n case \"cancelled\":\n case \"refunded\":\n return { done: true, terminal: \"failed\", id: null };\n case \"not_found\":\n return { done: true, terminal: \"error\", id: null };\n case \"pending_payment\":\n default:\n return { done: false, terminal: null, id: null };\n }\n },\n });\n}\n\n/**\n * Buy a one-time membership. Same lifecycle as a game pass (no config) —\n * `start({ templateId })` → render\n * `<BowlosPaymentForm {...purchase.paymentIntent} onPaid={purchase.startPolling}>`\n * → `status === \"confirmed\"` (`resultId` = the new membership id). The charge\n * lands on the operator's connected account.\n */\nexport function useMembershipPurchase(): UsePurchaseResult<MembershipPurchaseArgs> {\n const client = useBowlosClient();\n return usePurchase<MembershipPurchaseArgs, MembershipStatusResult>({\n createIntent: async (args) => {\n const r = await createMembershipOrder(client, args);\n return {\n paymentIntent: {\n paymentIntentId: r.paymentIntentId,\n clientSecret: r.clientSecret,\n amountCents: r.amountCents,\n connectedAccountId: r.connectedAccountId,\n customerSessionClientSecret: r.customerSessionClientSecret,\n },\n refToken: r.refToken,\n };\n },\n pollStatus: (refToken) => getMembershipStatus(client, refToken),\n interpret: (s) => {\n switch (s.status) {\n case \"paid_materialized\":\n return { done: true, terminal: \"confirmed\", id: s.membershipId };\n case \"expired\":\n return { done: true, terminal: \"expired\", id: null };\n case \"payment_failed_retryable\":\n case \"abandoned\":\n return { done: true, terminal: \"failed\", id: null };\n case \"not_found\":\n return { done: true, terminal: \"error\", id: null };\n case \"pending_payment\":\n default:\n return { done: false, terminal: null, id: null };\n }\n },\n });\n}\n\n/** State for `useMembershipSubscriptionCheckout`. A recurring subscription has no\n * refToken to poll — it materializes via webhook — so this is a leaner machine\n * than `usePurchase`: mint the first-invoice payment, confirm it, then re-query\n * `useMyMemberships` (which updates reactively once the webhook lands). */\nexport interface UseSubscriptionCheckoutResult {\n status: \"idle\" | \"creating\" | \"awaitingPayment\" | \"error\";\n subscriptionIntent: MembershipSubscriptionIntent | null;\n error: BowlosApiError | null;\n /** Mint the subscription + its first-invoice payment → \"awaitingPayment\". */\n start: (args: MembershipSubscriptionArgs) => Promise<void>;\n reset: () => void;\n}\n\n/**\n * Start a recurring membership subscription. `start({ templateId })` mints the\n * subscription + its first-invoice PaymentIntent on the operator's connected\n * account → render `<BowlosPaymentForm {...checkout.subscriptionIntent}>` to\n * confirm. There is **no poll**: once the customer pays, the subscription\n * materializes via webhook — re-query `useMyMemberships` to show the new\n * membership (the list updates reactively).\n */\nexport function useMembershipSubscriptionCheckout(): UseSubscriptionCheckoutResult {\n const client = useBowlosClient();\n const [status, setStatus] = useState<\"idle\" | \"creating\" | \"awaitingPayment\" | \"error\">(\n \"idle\",\n );\n const [subscriptionIntent, setSubscriptionIntent] =\n useState<MembershipSubscriptionIntent | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n\n const start = useCallback(\n async (args: MembershipSubscriptionArgs) => {\n setError(null);\n setSubscriptionIntent(null);\n setStatus(\"creating\");\n try {\n const intent = await createMembershipSubscriptionOrder(client, args);\n setSubscriptionIntent(intent);\n setStatus(\"awaitingPayment\");\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n setStatus(\"error\");\n }\n },\n [client],\n );\n\n const reset = useCallback(() => {\n setSubscriptionIntent(null);\n setError(null);\n setStatus(\"idle\");\n }, []);\n\n return { status, subscriptionIntent, error, start, reset };\n}\n"]}
1
+ {"version":3,"sources":["../src/use-purchase.tsx"],"names":[],"mappings":";;;;;AA8EA,IAAM,eAAA,GAAkB,IAAA;AAEjB,SAAS,YAA0B,MAAA,EAMd;AAC1B,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAI,SAAyB,MAAM,CAAA;AAC3D,EAAA,MAAM,CAAC,aAAA,EAAe,gBAAgB,CAAA,GAAI,SAAuC,IAAI,CAAA;AACrF,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,SAAwB,IAAI,CAAA;AAC5D,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAAgC,IAAI,CAAA;AAE9D,EAAA,MAAM,WAAA,GAAc,OAAsB,IAAI,CAAA;AAC9C,EAAA,MAAM,OAAA,GAAU,OAA8C,IAAI,CAAA;AAElE,EAAA,MAAM,MAAA,GAAS,OAAO,MAAM,CAAA;AAC5B,EAAA,MAAA,CAAO,OAAA,GAAU,MAAA;AAEjB,EAAA,MAAM,WAAA,GAAc,YAAY,MAAM;AACpC,IAAA,IAAI,OAAA,CAAQ,YAAY,IAAA,EAAM;AAC5B,MAAA,aAAA,CA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AA,EAAQ,kBAAA,EAAoB,KAAA,EAAO,OAAO,KAAA,EAAM;AAC3D","file":"react.js","sourcesContent":["\"use client\";\n/**\n * usePurchase — the headless buy state machine for game passes (packages +\n * memberships adopt it next). Mirrors `useBookingFlow`, minus the inventory\n * hold: the PaymentIntent IS the purchase.\n *\n * start(args) → mints the connected-account PaymentIntent → \"awaitingPayment\"\n * [render <BowlosPaymentForm {...paymentIntent}> and the customer pays]\n * startPolling() → polls the type's status endpoint → \"confirmed\" (+ resultId)\n *\n * Per-type wrappers (`useGameCardPurchase`, …) supply the create call + a status\n * interpreter that maps the type's status to the shared terminal states (D2/D5).\n */\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useBowlosClient } from \"./react\";\nimport { BowlosApiError } from \"./errors\";\nimport {\n createGameCardOrder,\n getGameCardStatus,\n createPackageOrder,\n getPackageStatus,\n createEventTicketOrder,\n getEventTicketStatus,\n createMembershipOrder,\n getMembershipStatus,\n createMembershipSubscriptionOrder,\n type GameCardPurchaseArgs,\n type GameCardStatusResult,\n type PackagePurchaseArgs,\n type PackageStatusResult,\n type EventTicketPurchaseArgs,\n type EventTicketStatusResult,\n type MembershipPurchaseArgs,\n type MembershipStatusResult,\n type MembershipSubscriptionArgs,\n type MembershipSubscriptionIntent,\n} from \"./data\";\n\nexport type PurchaseStatus =\n | \"idle\"\n | \"creating\"\n | \"awaitingPayment\"\n | \"confirming\"\n | \"confirmed\"\n | \"failed\"\n | \"expired\"\n | \"error\";\n\n/** The connected-account payment to confirm with `<BowlosPaymentForm>`. */\nexport interface PurchasePaymentIntent {\n paymentIntentId: string;\n clientSecret: string;\n amountCents: number;\n connectedAccountId: string;\n customerSessionClientSecret: string;\n}\n\nexport interface UsePurchaseResult<Args> {\n status: PurchaseStatus;\n paymentIntent: PurchasePaymentIntent | null;\n /** The materialized id (game card / order / membership) once confirmed. */\n resultId: string | null;\n error: BowlosApiError | null;\n /** Mint the PaymentIntent → \"awaitingPayment\". */\n start: (args: Args) => Promise<void>;\n /** Call after `<BowlosPaymentForm>` confirms → begins polling to materialization. */\n startPolling: (intervalMs?: number) => void;\n stopPolling: () => void;\n reset: () => void;\n}\n\n/** A type-specific status mapped to the shared terminal states. */\ntype Interpreted = {\n done: boolean;\n terminal: \"confirmed\" | \"failed\" | \"expired\" | \"error\" | null;\n id: string | null;\n};\n\nconst DEFAULT_POLL_MS = 2500;\n\nexport function usePurchase<Args, Status>(config: {\n createIntent: (\n args: Args,\n ) => Promise<{ paymentIntent: PurchasePaymentIntent; refToken: string | null }>;\n pollStatus: (refToken: string) => Promise<Status>;\n interpret: (status: Status) => Interpreted;\n}): UsePurchaseResult<Args> {\n const [status, setStatus] = useState<PurchaseStatus>(\"idle\");\n const [paymentIntent, setPaymentIntent] = useState<PurchasePaymentIntent | null>(null);\n const [resultId, setResultId] = useState<string | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n\n const refTokenRef = useRef<string | null>(null);\n const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);\n // Latest config in a ref so the polling interval never captures a stale closure.\n const cfgRef = useRef(config);\n cfgRef.current = config;\n\n const stopPolling = useCallback(() => {\n if (pollRef.current !== null) {\n clearInterval(pollRef.current);\n pollRef.current = null;\n }\n }, []);\n useEffect(() => stopPolling, [stopPolling]);\n\n const reset = useCallback(() => {\n stopPolling();\n refTokenRef.current = null;\n setPaymentIntent(null);\n setResultId(null);\n setError(null);\n setStatus(\"idle\");\n }, [stopPolling]);\n\n const start = useCallback(\n async (args: Args) => {\n stopPolling();\n setError(null);\n setResultId(null);\n setPaymentIntent(null);\n setStatus(\"creating\");\n try {\n const { paymentIntent: pi, refToken } = await cfgRef.current.createIntent(args);\n refTokenRef.current = refToken;\n setPaymentIntent(pi);\n setStatus(\"awaitingPayment\");\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n setStatus(\"error\");\n }\n },\n [stopPolling],\n );\n\n const poll = useCallback(async () => {\n const rt = refTokenRef.current;\n if (!rt) return;\n try {\n const r = cfgRef.current.interpret(await cfgRef.current.pollStatus(rt));\n if (!r.done) return;\n stopPolling();\n if (r.terminal === \"confirmed\") {\n setResultId(r.id);\n setStatus(\"confirmed\");\n } else if (r.terminal === \"expired\") {\n setStatus(\"expired\");\n } else if (r.terminal === \"failed\") {\n setStatus(\"failed\");\n } else {\n setError(new BowlosApiError(\"NOT_FOUND\", \"Purchase not found.\", 404));\n setStatus(\"error\");\n }\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n }\n }, [stopPolling]);\n\n const startPolling = useCallback(\n (intervalMs: number = DEFAULT_POLL_MS) => {\n stopPolling();\n setStatus(\"confirming\");\n void poll();\n pollRef.current = setInterval(() => void poll(), intervalMs);\n },\n [poll, stopPolling],\n );\n\n return { status, paymentIntent, resultId, error, start, startPolling, stopPolling, reset };\n}\n\n/**\n * Buy a game pass. `start({ templateId })` → render\n * `<BowlosPaymentForm {...purchase.paymentIntent} onPaid={purchase.startPolling}>`\n * → `status === \"confirmed\"` (`resultId` = the new game card id).\n */\nexport function useGameCardPurchase(): UsePurchaseResult<GameCardPurchaseArgs> {\n const client = useBowlosClient();\n return usePurchase<GameCardPurchaseArgs, GameCardStatusResult>({\n createIntent: async (args) => {\n const r = await createGameCardOrder(client, args);\n return {\n paymentIntent: {\n paymentIntentId: r.paymentIntentId,\n clientSecret: r.clientSecret,\n amountCents: r.amountCents,\n connectedAccountId: r.connectedAccountId,\n customerSessionClientSecret: r.customerSessionClientSecret,\n },\n refToken: r.refToken,\n };\n },\n pollStatus: (refToken) => getGameCardStatus(client, refToken),\n interpret: (s) => {\n switch (s.status) {\n case \"paid_materialized\":\n return { done: true, terminal: \"confirmed\", id: s.gameCardId };\n case \"expired\":\n return { done: true, terminal: \"expired\", id: null };\n case \"payment_failed_retryable\":\n case \"abandoned\":\n return { done: true, terminal: \"failed\", id: null };\n case \"not_found\":\n return { done: true, terminal: \"error\", id: null };\n case \"pending_payment\":\n default:\n return { done: false, terminal: null, id: null };\n }\n },\n });\n}\n\n/**\n * Buy a package (birthday party, lane bundle, …). Unlike a game pass, a package\n * carries a configuration — `start()` takes the Center, date/time, quantity, and\n * any optional add-ons:\n *\n * start({ packageId, centerId, quantity, scheduledDate, scheduledStartMinute, optionalAddons })\n * → render `<BowlosPaymentForm {...purchase.paymentIntent} onPaid={purchase.startPolling}>`\n * → `status === \"confirmed\"` (`resultId` = the new package order id).\n *\n * The site owns the config UI (see HEADLESS.md → \"Buying a package\" for computing\n * the bookable start times from the package + Center hours). `scheduledStartMinute`\n * MUST be one of those slots or the create rejects with VALIDATION_FAILED.\n */\nexport function usePackagePurchase(): UsePurchaseResult<PackagePurchaseArgs> {\n const client = useBowlosClient();\n return usePurchase<PackagePurchaseArgs, PackageStatusResult>({\n createIntent: async (args) => {\n const r = await createPackageOrder(client, args);\n return {\n paymentIntent: {\n paymentIntentId: r.paymentIntentId,\n clientSecret: r.clientSecret,\n amountCents: r.amountCents,\n connectedAccountId: r.connectedAccountId,\n customerSessionClientSecret: r.customerSessionClientSecret,\n },\n // The order id is the poll handle (packages have no refToken).\n refToken: r.orderId,\n };\n },\n pollStatus: (orderId) => getPackageStatus(client, orderId),\n interpret: (s) => {\n switch (s.status) {\n case \"paid\":\n return { done: true, terminal: \"confirmed\", id: s.orderId };\n case \"cancelled\":\n case \"refunded\":\n return { done: true, terminal: \"failed\", id: null };\n case \"not_found\":\n return { done: true, terminal: \"error\", id: null };\n case \"pending_payment\":\n default:\n return { done: false, terminal: null, id: null };\n }\n },\n });\n}\n\n/**\n * Buy tickets for a ticket-mode event offer. `start({ eventOfferId, quantity })`\n * → render `<BowlosPaymentForm {...purchase.paymentIntent} onPaid={purchase.startPolling}>`\n * → `status === \"confirmed\"` (`resultId` = the event order id). The charge\n * lands on the operator's connected account and the order receipt is available\n * through `useMyEventOrder` after confirmation.\n */\nexport function useEventTicketPurchase(): UsePurchaseResult<EventTicketPurchaseArgs> {\n const client = useBowlosClient();\n return usePurchase<EventTicketPurchaseArgs, EventTicketStatusResult>({\n createIntent: async (args) => {\n const r = await createEventTicketOrder(client, args);\n return {\n paymentIntent: {\n paymentIntentId: r.paymentIntentId,\n clientSecret: r.clientSecret,\n amountCents: r.amountCents,\n connectedAccountId: r.connectedAccountId,\n customerSessionClientSecret: r.customerSessionClientSecret,\n },\n refToken: r.orderId,\n };\n },\n pollStatus: (orderId) => getEventTicketStatus(client, orderId),\n interpret: (s) => {\n switch (s.status) {\n case \"paid\":\n return { done: true, terminal: \"confirmed\", id: s.orderId };\n case \"cancelled\":\n case \"refunded\":\n return { done: true, terminal: \"failed\", id: null };\n case \"not_found\":\n return { done: true, terminal: \"error\", id: null };\n case \"pending_payment\":\n default:\n return { done: false, terminal: null, id: null };\n }\n },\n });\n}\n\n/**\n * Buy a one-time membership. Same lifecycle as a game pass (no config) —\n * `start({ templateId })` → render\n * `<BowlosPaymentForm {...purchase.paymentIntent} onPaid={purchase.startPolling}>`\n * → `status === \"confirmed\"` (`resultId` = the new membership id). The charge\n * lands on the operator's connected account.\n */\nexport function useMembershipPurchase(): UsePurchaseResult<MembershipPurchaseArgs> {\n const client = useBowlosClient();\n return usePurchase<MembershipPurchaseArgs, MembershipStatusResult>({\n createIntent: async (args) => {\n const r = await createMembershipOrder(client, args);\n return {\n paymentIntent: {\n paymentIntentId: r.paymentIntentId,\n clientSecret: r.clientSecret,\n amountCents: r.amountCents,\n connectedAccountId: r.connectedAccountId,\n customerSessionClientSecret: r.customerSessionClientSecret,\n },\n refToken: r.refToken,\n };\n },\n pollStatus: (refToken) => getMembershipStatus(client, refToken),\n interpret: (s) => {\n switch (s.status) {\n case \"paid_materialized\":\n return { done: true, terminal: \"confirmed\", id: s.membershipId };\n case \"expired\":\n return { done: true, terminal: \"expired\", id: null };\n case \"payment_failed_retryable\":\n case \"abandoned\":\n return { done: true, terminal: \"failed\", id: null };\n case \"not_found\":\n return { done: true, terminal: \"error\", id: null };\n case \"pending_payment\":\n default:\n return { done: false, terminal: null, id: null };\n }\n },\n });\n}\n\n/** State for `useMembershipSubscriptionCheckout`. A recurring subscription has no\n * refToken to poll — it materializes via webhook — so this is a leaner machine\n * than `usePurchase`: mint the first-invoice payment, confirm it, then re-query\n * `useMyMemberships` (which updates reactively once the webhook lands). */\nexport interface UseSubscriptionCheckoutResult {\n status: \"idle\" | \"creating\" | \"awaitingPayment\" | \"error\";\n subscriptionIntent: MembershipSubscriptionIntent | null;\n error: BowlosApiError | null;\n /** Mint the subscription + its first-invoice payment → \"awaitingPayment\". */\n start: (args: MembershipSubscriptionArgs) => Promise<void>;\n reset: () => void;\n}\n\n/**\n * Start a recurring membership subscription. `start({ templateId })` mints the\n * subscription + its first-invoice PaymentIntent on the operator's connected\n * account → render `<BowlosPaymentForm {...checkout.subscriptionIntent}>` to\n * confirm. There is **no poll**: once the customer pays, the subscription\n * materializes via webhook — re-query `useMyMemberships` to show the new\n * membership (the list updates reactively).\n */\nexport function useMembershipSubscriptionCheckout(): UseSubscriptionCheckoutResult {\n const client = useBowlosClient();\n const [status, setStatus] = useState<\"idle\" | \"creating\" | \"awaitingPayment\" | \"error\">(\n \"idle\",\n );\n const [subscriptionIntent, setSubscriptionIntent] =\n useState<MembershipSubscriptionIntent | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n\n const start = useCallback(\n async (args: MembershipSubscriptionArgs) => {\n setError(null);\n setSubscriptionIntent(null);\n setStatus(\"creating\");\n try {\n const intent = await createMembershipSubscriptionOrder(client, args);\n setSubscriptionIntent(intent);\n setStatus(\"awaitingPayment\");\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n setStatus(\"error\");\n }\n },\n [client],\n );\n\n const reset = useCallback(() => {\n setSubscriptionIntent(null);\n setError(null);\n setStatus(\"idle\");\n }, []);\n\n return { status, subscriptionIntent, error, start, reset };\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bowlos/reservations",
3
- "version": "0.20.0",
4
- "description": "BowlOS Reservations SDK — 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.",
3
+ "version": "0.22.0",
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",
7
7
  "keywords": [
@@ -11,7 +11,7 @@
11
11
  "typecheck": "tsc --noEmit"
12
12
  },
13
13
  "dependencies": {
14
- "@bowlos/reservations": "^0.20.0",
14
+ "@bowlos/reservations": "^0.22.0",
15
15
  "@stripe/react-stripe-js": "6.3.0",
16
16
  "@stripe/stripe-js": "9.4.0",
17
17
  "next": "16.2.4",
@@ -1,93 +0,0 @@
1
- import { g as BowlosClient } from './data-ymW_rWbz.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 MembershipDetailArgs = {
23
- brandId: string;
24
- membershipId: string;
25
- };
26
- type FlashSaleArgs = {
27
- slug: string;
28
- };
29
- type FlashBookingOptionsArgs = {
30
- slug: string;
31
- itemId: string;
32
- };
33
- type FlashSalesArgs = {
34
- brandId: string;
35
- };
36
- declare function getMyReservations<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
37
- declare function getMyReservationDetail<T = unknown>(client: BowlosClient, args: ReservationDetailArgs): Promise<T>;
38
- declare function getMyMemberships<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
39
- declare function getMyMembershipDetail<T = unknown>(client: BowlosClient, args: MembershipDetailArgs): Promise<T>;
40
- declare function getMyLoyalty<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
41
- declare function getMyCredits<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
42
- declare function getMyPasses<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
43
- declare function getFlashSale<T = unknown>(client: BowlosClient, args: FlashSaleArgs): Promise<T>;
44
- /** The public flash-sale index for a Brand (live + upcoming; no prices). Public. */
45
- declare function getFlashSales<T = unknown>(client: BowlosClient, args: FlashSalesArgs): Promise<T>;
46
- declare function getFlashSaleBookingOptions<T = unknown>(client: BowlosClient, args: FlashBookingOptionsArgs): Promise<T>;
47
-
48
- /**
49
- * Public catalog reads for @bowlos/reservations — the "what can I book/buy here"
50
- * surface that powers `<BookingCatalog>`. All anonymous (no customer login).
51
- * Products + events + memberships are Center-scoped; packages + game cards are
52
- * Brand-scoped (with an optional Center filter). Results are generic (`<T>`);
53
- * the component types the display fields it needs.
54
- */
55
-
56
- type CenterScoped = {
57
- centerId: string;
58
- };
59
- type BrandCatalogArgs = {
60
- brandId: string;
61
- centerId?: string;
62
- };
63
- /** One package's full detail. `shareToken` reveals a hidden/unlisted package. */
64
- type PackageDetailArgs = {
65
- packageId: string;
66
- shareToken?: string;
67
- };
68
- /** Args for a Center's operating-hours window on a date, across attraction types. */
69
- type CenterHoursArgs = {
70
- centerId: string;
71
- attractionTypeKeys: string[];
72
- dateISO: string;
73
- };
74
- /** Bookable products at a Center (each carries its attraction + `attractionTypeKey`). */
75
- declare function listProducts<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
76
- /** Upcoming pricing events (NYE Bash, tournaments…) at a Center. */
77
- declare function listEvents<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
78
- /** Purchasable packages at a Brand. */
79
- declare function listPackages<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
80
- /** Full detail for one package — components, optional add-ons, allowed start
81
- * times, duration, and quantity bounds. Drives the headless package config UI
82
- * (see HEADLESS.md → "Buying a package"). */
83
- declare function getPackage<T = unknown>(client: BowlosClient, args: PackageDetailArgs): Promise<T>;
84
- /** A Center's combined open/close window (minutes-from-midnight) for the given
85
- * attraction types on a date — the intersection across types; `null` if closed.
86
- * Bound a package's start times with its component attraction-type keys. */
87
- declare function getCenterHours<T = unknown>(client: BowlosClient, args: CenterHoursArgs): Promise<T>;
88
- /** Purchasable memberships at a Center. */
89
- declare function listPublicMemberships<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
90
- /** Purchasable game cards / passes at a Brand. */
91
- declare function listGameCards<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
92
-
93
- export { type BrandCatalogArgs as B, type CenterHoursArgs as C, type FlashBookingOptionsArgs as F, type MembershipDetailArgs as M, type PackageDetailArgs as P, type ReservationDetailArgs as R, type BrandScoped as a, type CenterScoped as b, type FlashSaleArgs as c, type FlashSalesArgs as d, getFlashSale as e, getFlashSaleBookingOptions as f, getCenterHours as g, getFlashSales as h, getMyCredits as i, getMyLoyalty as j, getMyMembershipDetail as k, getMyMemberships as l, getMyPasses as m, getMyReservationDetail as n, getMyReservations as o, getPackage as p, listEvents as q, listGameCards as r, listPackages as s, listProducts as t, listPublicMemberships as u };
@@ -1,93 +0,0 @@
1
- import { g as BowlosClient } from './data-ymW_rWbz.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 MembershipDetailArgs = {
23
- brandId: string;
24
- membershipId: string;
25
- };
26
- type FlashSaleArgs = {
27
- slug: string;
28
- };
29
- type FlashBookingOptionsArgs = {
30
- slug: string;
31
- itemId: string;
32
- };
33
- type FlashSalesArgs = {
34
- brandId: string;
35
- };
36
- declare function getMyReservations<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
37
- declare function getMyReservationDetail<T = unknown>(client: BowlosClient, args: ReservationDetailArgs): Promise<T>;
38
- declare function getMyMemberships<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
39
- declare function getMyMembershipDetail<T = unknown>(client: BowlosClient, args: MembershipDetailArgs): Promise<T>;
40
- declare function getMyLoyalty<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
41
- declare function getMyCredits<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
42
- declare function getMyPasses<T = unknown>(client: BowlosClient, args: BrandScoped): Promise<T>;
43
- declare function getFlashSale<T = unknown>(client: BowlosClient, args: FlashSaleArgs): Promise<T>;
44
- /** The public flash-sale index for a Brand (live + upcoming; no prices). Public. */
45
- declare function getFlashSales<T = unknown>(client: BowlosClient, args: FlashSalesArgs): Promise<T>;
46
- declare function getFlashSaleBookingOptions<T = unknown>(client: BowlosClient, args: FlashBookingOptionsArgs): Promise<T>;
47
-
48
- /**
49
- * Public catalog reads for @bowlos/reservations — the "what can I book/buy here"
50
- * surface that powers `<BookingCatalog>`. All anonymous (no customer login).
51
- * Products + events + memberships are Center-scoped; packages + game cards are
52
- * Brand-scoped (with an optional Center filter). Results are generic (`<T>`);
53
- * the component types the display fields it needs.
54
- */
55
-
56
- type CenterScoped = {
57
- centerId: string;
58
- };
59
- type BrandCatalogArgs = {
60
- brandId: string;
61
- centerId?: string;
62
- };
63
- /** One package's full detail. `shareToken` reveals a hidden/unlisted package. */
64
- type PackageDetailArgs = {
65
- packageId: string;
66
- shareToken?: string;
67
- };
68
- /** Args for a Center's operating-hours window on a date, across attraction types. */
69
- type CenterHoursArgs = {
70
- centerId: string;
71
- attractionTypeKeys: string[];
72
- dateISO: string;
73
- };
74
- /** Bookable products at a Center (each carries its attraction + `attractionTypeKey`). */
75
- declare function listProducts<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
76
- /** Upcoming pricing events (NYE Bash, tournaments…) at a Center. */
77
- declare function listEvents<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
78
- /** Purchasable packages at a Brand. */
79
- declare function listPackages<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
80
- /** Full detail for one package — components, optional add-ons, allowed start
81
- * times, duration, and quantity bounds. Drives the headless package config UI
82
- * (see HEADLESS.md → "Buying a package"). */
83
- declare function getPackage<T = unknown>(client: BowlosClient, args: PackageDetailArgs): Promise<T>;
84
- /** A Center's combined open/close window (minutes-from-midnight) for the given
85
- * attraction types on a date — the intersection across types; `null` if closed.
86
- * Bound a package's start times with its component attraction-type keys. */
87
- declare function getCenterHours<T = unknown>(client: BowlosClient, args: CenterHoursArgs): Promise<T>;
88
- /** Purchasable memberships at a Center. */
89
- declare function listPublicMemberships<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
90
- /** Purchasable game cards / passes at a Brand. */
91
- declare function listGameCards<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
92
-
93
- export { type BrandCatalogArgs as B, type CenterHoursArgs as C, type FlashBookingOptionsArgs as F, type MembershipDetailArgs as M, type PackageDetailArgs as P, type ReservationDetailArgs as R, type BrandScoped as a, type CenterScoped as b, type FlashSaleArgs as c, type FlashSalesArgs as d, getFlashSale as e, getFlashSaleBookingOptions as f, getCenterHours as g, getFlashSales as h, getMyCredits as i, getMyLoyalty as j, getMyMembershipDetail as k, getMyMemberships as l, getMyPasses as m, getMyReservationDetail as n, getMyReservations as o, getPackage as p, listEvents as q, listGameCards as r, listPackages as s, listProducts as t, listPublicMemberships as u };