@bowlos/reservations 0.21.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.
- package/HEADLESS.md +5 -3
- package/README.md +23 -16
- package/dist/account-CO8xzUs_.d.ts +54 -0
- package/dist/account-SqT7et4C.d.cts +54 -0
- package/dist/{catalog-bpCn9klL.d.ts → catalog-BxyPJdBL.d.ts} +49 -47
- package/dist/{catalog-BuafmB8y.d.cts → catalog-D1VoVaNe.d.cts} +49 -47
- package/dist/components.cjs +32 -96
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +35 -62
- package/dist/components.d.ts +35 -62
- package/dist/components.js +31 -83
- package/dist/components.js.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/{react-BI2RKM5p.d.ts → react-B1uSOozS.d.ts} +1 -1
- package/dist/{react-D2mBw_-l.d.cts → react-Bc_6yi9q.d.cts} +1 -1
- package/dist/react.d.cts +4 -4
- package/dist/react.d.ts +4 -4
- package/package.json +2 -2
- package/templates/center-site/package.json +1 -1
- package/dist/errors-IIK7xibp.d.cts +0 -54
- package/dist/errors-IIK7xibp.d.ts +0 -54
package/HEADLESS.md
CHANGED
|
@@ -762,9 +762,9 @@ after login. The framework-agnostic twin is `listCatalog(client, args)`.
|
|
|
762
762
|
|
|
763
763
|
`useCatalog` keeps the SDK custom site consistent with the white-label web and
|
|
764
764
|
mobile surfaces (all three consume the same backend read) and honors the admin
|
|
765
|
-
Public Catalog toggles.
|
|
766
|
-
|
|
767
|
-
|
|
765
|
+
Public Catalog toggles. As of **v0.22.0** the drop-in `<BookingCatalog>` is
|
|
766
|
+
built on this same read — its `onSelect` hands off a `CatalogItem`, so the
|
|
767
|
+
drop-in and a headless site route identically (table above).
|
|
768
768
|
|
|
769
769
|
## Adopting changes by version
|
|
770
770
|
|
|
@@ -788,5 +788,7 @@ Headless sites do **not** get these from a version bump — apply them by hand.
|
|
|
788
788
|
| **0.20.0** | **Membership buy hooks (one-time + recurring)** — `useMembershipPreview` / `useMembershipPurchase` and `useMembershipSubscriptionPreview` / `useMembershipSubscriptionCheckout` | "Buying a one-time membership" + "Buying a recurring membership" sections. One-time mirrors the game-pass buy (`useMembershipPreview` → `useMembershipPurchase`, poll `resultId` = membership). Recurring: `useMembershipSubscriptionPreview` shows **Due today** (`grandTotalCents`) *and* **Auto-renews at** (`recurringTotalCents` / `cadence`), then `useMembershipSubscriptionCheckout` confirms the first invoice — **no refToken poll; re-query `useMyMemberships` after payment** (the subscription materializes via webhook). Route the catalog's `membership` pick in-app, not to the portal. (Charges the operator's connected account.) |
|
|
789
789
|
| **0.21.0** | **Sellable event offers + ticket receipts** *and* **canonical visibility-aware catalog** — headless adds `useEventOffers` / `useEventOffer`, `useEventTicketPreview`, `createEventTicketOrder`, `useEventTicketPurchase`, signed-in event-order account reads, **and** `useCatalog` / `listCatalog` (one read, six categories, per-surface admin visibility applied); a consolidated [Static purchase summary](#static-purchase-summary--tax--center-fee--setup-fee-every-category) field map | "Event offers in the catalog" + "The canonical catalog" sections. Route `event` picks to an event landing page by `slug`. For reservation-mode events, preselect the event date/window/add-ons and pass `eventOfferSlug: offer.slug` into preview + hold/create so the server applies the event plan and tax/fee policy. For ticket-mode events, route to the hosted tenant ticket checkout or mirror `previewEventTicket` → Review → `createEventTicketOrder` / `useEventTicketPurchase`. After pay, re-query `useMyEventOrders` / `useMyEventOrder`. Prefer `useCatalog({ brandId, centerId, surface })` over the per-category hooks for the full, admin-controlled catalog (route each `CatalogItem` by `action.type`). `<BookingCatalog>` is unchanged. |
|
|
790
790
|
|
|
791
|
+
| **0.22.0** | **BREAKING: `<BookingCatalog>` is visibility-aware** — rebuilt on `useCatalog`/`listPublicCatalog`; `onSelect` hands off a `CatalogItem` (was the per-kind `CatalogOffer` union); section labels come from the backend (override via `sectionLabels`); new optional `surface` prop (default `"sdk_custom_site"`) | Headless sites need no change — `useCatalog` is unchanged. Sites using the drop-in update `onSelect` to route by `item.action.type` + `item.action.payload` (the routing table in "The canonical catalog"), and drop any `CatalogOffer` imports (`CatalogItem`/`CatalogSection`/`CatalogResult` are exported from `/components` too). Offers an admin hides for `sdk_custom_site` stop rendering in the drop-in — audit the admin Public Catalog page if something "disappears". |
|
|
792
|
+
|
|
791
793
|
When you add the next release here, add its row **and** any new capability-map
|
|
792
794
|
section in the same PR.
|
package/README.md
CHANGED
|
@@ -195,11 +195,13 @@ import { BookingFlow, BowlosTheme } from "@bowlos/reservations/components";
|
|
|
195
195
|
```
|
|
196
196
|
|
|
197
197
|
**`<BookingCatalog brandId centerId onSelect>`** is the catalog landing — "what
|
|
198
|
-
would you like to book?"
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
`
|
|
198
|
+
would you like to book?" Since **v0.22.0** it renders the **canonical
|
|
199
|
+
visibility-aware catalog** (`useCatalog` / `listPublicCatalog`) — the same read
|
|
200
|
+
the white-label web and mobile surfaces use — so the Center admin's per-surface
|
|
201
|
+
Public Catalog toggles apply to the drop-in too. Each pick hands off a
|
|
202
|
+
`CatalogItem` via `onSelect`; route by `item.action.type` with the IDs in
|
|
203
|
+
`item.action.payload` (same routing table as a headless site — HEADLESS.md →
|
|
204
|
+
"The canonical catalog").
|
|
203
205
|
|
|
204
206
|
```tsx
|
|
205
207
|
import { BookingCatalog } from "@bowlos/reservations/components";
|
|
@@ -207,20 +209,25 @@ import { BookingCatalog } from "@bowlos/reservations/components";
|
|
|
207
209
|
<BookingCatalog
|
|
208
210
|
brandId="brand_…"
|
|
209
211
|
centerId="center_…"
|
|
210
|
-
onSelect={(
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
: router.push(`/
|
|
214
|
-
|
|
212
|
+
onSelect={(item) => {
|
|
213
|
+
const p = item.action.payload;
|
|
214
|
+
switch (item.action.type) {
|
|
215
|
+
case "book_reservation": return router.push(`/book?productId=${p.productId}`);
|
|
216
|
+
case "view_event":
|
|
217
|
+
case "buy_ticket": return router.push(`/events/${p.slug}`);
|
|
218
|
+
case "buy_package": return router.push(`/buy/package/${p.packageId}`);
|
|
219
|
+
case "buy_membership": return router.push(`/buy/membership/${p.templateId}`);
|
|
220
|
+
case "buy_game_pass": return router.push(`/buy/game-pass/${p.templateId}`);
|
|
221
|
+
}
|
|
222
|
+
}}
|
|
215
223
|
/>;
|
|
216
224
|
```
|
|
217
225
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
HEADLESS.md → "The canonical catalog".
|
|
226
|
+
> **Breaking (v0.22.0):** `onSelect` previously received a per-kind
|
|
227
|
+
> `CatalogOffer` union (`o.kind` / `o.id`); it now receives a `CatalogItem`.
|
|
228
|
+
> Section headings come from the backend (override with `sectionLabels`), and
|
|
229
|
+
> hidden categories/offers no longer render. Headless sites use the same data
|
|
230
|
+
> via `useCatalog({ brandId, centerId, surface })` / `listCatalog`.
|
|
224
231
|
|
|
225
232
|
The drop-in surfaces cover a center site end to end:
|
|
226
233
|
|
|
@@ -0,0 +1,54 @@
|
|
|
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 };
|
|
@@ -0,0 +1,54 @@
|
|
|
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,55 +1,57 @@
|
|
|
1
1
|
import { g as BowlosClient } from './data-BKlgn8Ln.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Error model for the BowlOS Reservations SDK.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
6
|
+
* Every failed gateway call surfaces as a single `BowlosApiError` carrying a
|
|
7
|
+
* stable `code` (string), the HTTP `status`, and — for rate limits — a
|
|
8
|
+
* `retryAfterSeconds`. The gateway normalizes the backend's two error
|
|
9
|
+
* conventions (thrown ConvexError + `{ ok:false }` envelopes) into one JSON
|
|
10
|
+
* shape; this class is the client-side mirror of that shape, so consumers
|
|
11
|
+
* branch on `error.code`, never on message text.
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
13
|
+
/** Stable error codes the gateway / backend can return. Open set — treat
|
|
14
|
+
* `code` as a string and match against these for known cases. */
|
|
15
|
+
declare const BOWLOS_ERROR_CODES: {
|
|
16
|
+
readonly API_KEY_MISSING: "API_KEY_MISSING";
|
|
17
|
+
readonly API_KEY_INVALID: "API_KEY_INVALID";
|
|
18
|
+
readonly ORIGIN_NOT_ALLOWED: "ORIGIN_NOT_ALLOWED";
|
|
19
|
+
readonly RATE_LIMITED: "RATE_LIMITED";
|
|
20
|
+
readonly INVALID_CREDENTIALS: "INVALID_CREDENTIALS";
|
|
21
|
+
readonly SIGNUP_FAILED: "SIGNUP_FAILED";
|
|
22
|
+
readonly VALIDATION_FAILED: "VALIDATION_FAILED";
|
|
23
|
+
readonly PERMISSION_DENIED: "PERMISSION_DENIED";
|
|
24
|
+
readonly SCOPE_REVOKED: "SCOPE_REVOKED";
|
|
25
|
+
readonly NOT_FOUND: "NOT_FOUND";
|
|
26
|
+
readonly VERSION_CONFLICT: "VERSION_CONFLICT";
|
|
27
|
+
readonly PRICING_SNAPSHOT_STALE: "PRICING_SNAPSHOT_STALE";
|
|
28
|
+
readonly PAYMENTS_NOT_CONNECTED: "PAYMENTS_NOT_CONNECTED";
|
|
29
|
+
readonly CONNECT_ACCOUNT_RESTRICTED: "CONNECT_ACCOUNT_RESTRICTED";
|
|
30
|
+
readonly CHECKOUT_EXPIRED: "CHECKOUT_EXPIRED";
|
|
31
|
+
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
32
|
+
readonly UNKNOWN: "ERROR";
|
|
29
33
|
};
|
|
30
|
-
type
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
declare function getFlashSales<T = unknown>(client: BowlosClient, args: FlashSalesArgs): Promise<T>;
|
|
52
|
-
declare function getFlashSaleBookingOptions<T = unknown>(client: BowlosClient, args: FlashBookingOptionsArgs): Promise<T>;
|
|
34
|
+
type BowlosErrorCode = (typeof BOWLOS_ERROR_CODES)[keyof typeof BOWLOS_ERROR_CODES] | (string & {});
|
|
35
|
+
interface BowlosApiErrorOptions {
|
|
36
|
+
retryAfterSeconds?: number;
|
|
37
|
+
cause?: unknown;
|
|
38
|
+
}
|
|
39
|
+
declare class BowlosApiError extends Error {
|
|
40
|
+
/** Stable, machine-readable code. Branch on this, not on `message`. */
|
|
41
|
+
readonly code: BowlosErrorCode;
|
|
42
|
+
/** HTTP status (0 for a network failure before any response). */
|
|
43
|
+
readonly status: number;
|
|
44
|
+
/** Seconds to wait before retrying — present only on `RATE_LIMITED`. */
|
|
45
|
+
readonly retryAfterSeconds?: number;
|
|
46
|
+
constructor(code: BowlosErrorCode, message: string, status: number, options?: BowlosApiErrorOptions);
|
|
47
|
+
/** Too many requests — caller should back off `retryAfterSeconds`. */
|
|
48
|
+
get isRateLimited(): boolean;
|
|
49
|
+
/** Bad/expired login. The session could not be established or has lapsed. */
|
|
50
|
+
get isAuthError(): boolean;
|
|
51
|
+
/** Wrong/missing API key or a disallowed origin — a site-config problem,
|
|
52
|
+
* not something the end customer can fix. */
|
|
53
|
+
get isConfigError(): boolean;
|
|
54
|
+
}
|
|
53
55
|
|
|
54
56
|
/**
|
|
55
57
|
* Public catalog reads for @bowlos/reservations — the "what can I book/buy here"
|
|
@@ -155,4 +157,4 @@ declare function listPublicMemberships<T = unknown>(client: BowlosClient, args:
|
|
|
155
157
|
/** Purchasable game cards / passes at a Brand. */
|
|
156
158
|
declare function listGameCards<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
|
|
157
159
|
|
|
158
|
-
export {
|
|
160
|
+
export { BOWLOS_ERROR_CODES as B, type CatalogActionType as C, type PackageDetailArgs as P, BowlosApiError as a, type BowlosApiErrorOptions as b, type BowlosErrorCode as c, type BrandCatalogArgs as d, type CatalogArgs as e, type CatalogCategory as f, type CatalogItem as g, type CatalogResult as h, type CatalogSection as i, type CatalogSourceTable as j, type CenterHoursArgs as k, type CenterScoped as l, type PublicSurface as m, getCenterHours as n, getEventOffer as o, getPackage as p, listCatalog as q, listEventOffers as r, listEvents as s, listGameCards as t, listPackages as u, listProducts as v, listPublicMemberships as w };
|
|
@@ -1,55 +1,57 @@
|
|
|
1
1
|
import { g as BowlosClient } from './data-BKlgn8Ln.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Error model for the BowlOS Reservations SDK.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
6
|
+
* Every failed gateway call surfaces as a single `BowlosApiError` carrying a
|
|
7
|
+
* stable `code` (string), the HTTP `status`, and — for rate limits — a
|
|
8
|
+
* `retryAfterSeconds`. The gateway normalizes the backend's two error
|
|
9
|
+
* conventions (thrown ConvexError + `{ ok:false }` envelopes) into one JSON
|
|
10
|
+
* shape; this class is the client-side mirror of that shape, so consumers
|
|
11
|
+
* branch on `error.code`, never on message text.
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
13
|
+
/** Stable error codes the gateway / backend can return. Open set — treat
|
|
14
|
+
* `code` as a string and match against these for known cases. */
|
|
15
|
+
declare const BOWLOS_ERROR_CODES: {
|
|
16
|
+
readonly API_KEY_MISSING: "API_KEY_MISSING";
|
|
17
|
+
readonly API_KEY_INVALID: "API_KEY_INVALID";
|
|
18
|
+
readonly ORIGIN_NOT_ALLOWED: "ORIGIN_NOT_ALLOWED";
|
|
19
|
+
readonly RATE_LIMITED: "RATE_LIMITED";
|
|
20
|
+
readonly INVALID_CREDENTIALS: "INVALID_CREDENTIALS";
|
|
21
|
+
readonly SIGNUP_FAILED: "SIGNUP_FAILED";
|
|
22
|
+
readonly VALIDATION_FAILED: "VALIDATION_FAILED";
|
|
23
|
+
readonly PERMISSION_DENIED: "PERMISSION_DENIED";
|
|
24
|
+
readonly SCOPE_REVOKED: "SCOPE_REVOKED";
|
|
25
|
+
readonly NOT_FOUND: "NOT_FOUND";
|
|
26
|
+
readonly VERSION_CONFLICT: "VERSION_CONFLICT";
|
|
27
|
+
readonly PRICING_SNAPSHOT_STALE: "PRICING_SNAPSHOT_STALE";
|
|
28
|
+
readonly PAYMENTS_NOT_CONNECTED: "PAYMENTS_NOT_CONNECTED";
|
|
29
|
+
readonly CONNECT_ACCOUNT_RESTRICTED: "CONNECT_ACCOUNT_RESTRICTED";
|
|
30
|
+
readonly CHECKOUT_EXPIRED: "CHECKOUT_EXPIRED";
|
|
31
|
+
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
32
|
+
readonly UNKNOWN: "ERROR";
|
|
29
33
|
};
|
|
30
|
-
type
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
declare function getFlashSales<T = unknown>(client: BowlosClient, args: FlashSalesArgs): Promise<T>;
|
|
52
|
-
declare function getFlashSaleBookingOptions<T = unknown>(client: BowlosClient, args: FlashBookingOptionsArgs): Promise<T>;
|
|
34
|
+
type BowlosErrorCode = (typeof BOWLOS_ERROR_CODES)[keyof typeof BOWLOS_ERROR_CODES] | (string & {});
|
|
35
|
+
interface BowlosApiErrorOptions {
|
|
36
|
+
retryAfterSeconds?: number;
|
|
37
|
+
cause?: unknown;
|
|
38
|
+
}
|
|
39
|
+
declare class BowlosApiError extends Error {
|
|
40
|
+
/** Stable, machine-readable code. Branch on this, not on `message`. */
|
|
41
|
+
readonly code: BowlosErrorCode;
|
|
42
|
+
/** HTTP status (0 for a network failure before any response). */
|
|
43
|
+
readonly status: number;
|
|
44
|
+
/** Seconds to wait before retrying — present only on `RATE_LIMITED`. */
|
|
45
|
+
readonly retryAfterSeconds?: number;
|
|
46
|
+
constructor(code: BowlosErrorCode, message: string, status: number, options?: BowlosApiErrorOptions);
|
|
47
|
+
/** Too many requests — caller should back off `retryAfterSeconds`. */
|
|
48
|
+
get isRateLimited(): boolean;
|
|
49
|
+
/** Bad/expired login. The session could not be established or has lapsed. */
|
|
50
|
+
get isAuthError(): boolean;
|
|
51
|
+
/** Wrong/missing API key or a disallowed origin — a site-config problem,
|
|
52
|
+
* not something the end customer can fix. */
|
|
53
|
+
get isConfigError(): boolean;
|
|
54
|
+
}
|
|
53
55
|
|
|
54
56
|
/**
|
|
55
57
|
* Public catalog reads for @bowlos/reservations — the "what can I book/buy here"
|
|
@@ -155,4 +157,4 @@ declare function listPublicMemberships<T = unknown>(client: BowlosClient, args:
|
|
|
155
157
|
/** Purchasable game cards / passes at a Brand. */
|
|
156
158
|
declare function listGameCards<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
|
|
157
159
|
|
|
158
|
-
export {
|
|
160
|
+
export { BOWLOS_ERROR_CODES as B, type CatalogActionType as C, type PackageDetailArgs as P, BowlosApiError as a, type BowlosApiErrorOptions as b, type BowlosErrorCode as c, type BrandCatalogArgs as d, type CatalogArgs as e, type CatalogCategory as f, type CatalogItem as g, type CatalogResult as h, type CatalogSection as i, type CatalogSourceTable as j, type CenterHoursArgs as k, type CenterScoped as l, type PublicSurface as m, getCenterHours as n, getEventOffer as o, getPackage as p, listCatalog as q, listEventOffers as r, listEvents as s, listGameCards as t, listPackages as u, listProducts as v, listPublicMemberships as w };
|
package/dist/components.cjs
CHANGED
|
@@ -170,20 +170,8 @@ function useFlashSale(args, options) {
|
|
|
170
170
|
function useFlashSales(args, options) {
|
|
171
171
|
return useBowlosQuery("listPublicFlashSales", args, options);
|
|
172
172
|
}
|
|
173
|
-
function
|
|
174
|
-
return useBowlosQuery("
|
|
175
|
-
}
|
|
176
|
-
function useEventOffers(args, options) {
|
|
177
|
-
return useBowlosQuery("listPublicEventOffers", args, options);
|
|
178
|
-
}
|
|
179
|
-
function usePackages(args, options) {
|
|
180
|
-
return useBowlosQuery("listPublicPackages", args, options);
|
|
181
|
-
}
|
|
182
|
-
function usePublicMemberships(args, options) {
|
|
183
|
-
return useBowlosQuery("listPublicMemberships", args, options);
|
|
184
|
-
}
|
|
185
|
-
function useGameCards(args, options) {
|
|
186
|
-
return useBowlosQuery("listPublicGameCards", args, options);
|
|
173
|
+
function useCatalog(args, options) {
|
|
174
|
+
return useBowlosQuery("listPublicCatalog", args, options);
|
|
187
175
|
}
|
|
188
176
|
|
|
189
177
|
// src/data.ts
|
|
@@ -1373,105 +1361,53 @@ var DEFAULT_LABELS7 = {
|
|
|
1373
1361
|
heading: "What would you like to book?",
|
|
1374
1362
|
loading: "Loading\u2026",
|
|
1375
1363
|
empty: "Nothing is available to book online right now.",
|
|
1376
|
-
|
|
1377
|
-
otherAttractions: "Other attractions",
|
|
1378
|
-
events: "Events",
|
|
1379
|
-
packages: "Packages",
|
|
1380
|
-
memberships: "Memberships",
|
|
1381
|
-
gamePasses: "Game passes",
|
|
1382
|
-
select: "Select",
|
|
1383
|
-
minutesAbbrev: "min",
|
|
1384
|
-
perMonth: "/mo"
|
|
1364
|
+
select: "Select"
|
|
1385
1365
|
};
|
|
1386
|
-
function BookingCatalog({
|
|
1366
|
+
function BookingCatalog({
|
|
1367
|
+
brandId,
|
|
1368
|
+
centerId,
|
|
1369
|
+
surface = "sdk_custom_site",
|
|
1370
|
+
onSelect,
|
|
1371
|
+
labels,
|
|
1372
|
+
sectionLabels,
|
|
1373
|
+
className
|
|
1374
|
+
}) {
|
|
1387
1375
|
const t = { ...DEFAULT_LABELS7, ...labels };
|
|
1388
1376
|
const s = styles();
|
|
1389
|
-
const
|
|
1390
|
-
const
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
const gameCards = useGameCards({ brandId, centerId });
|
|
1394
|
-
const reads = [products, events, packages, memberships, gameCards];
|
|
1395
|
-
const anyLoading = reads.some((r) => r.loading && !r.data);
|
|
1396
|
-
const productRows = products.data ?? [];
|
|
1397
|
-
const bowling = productRows.filter((p) => p.attractionTypeKey === "bowling").map((p) => ({ kind: "product", ...p }));
|
|
1398
|
-
const other = productRows.filter((p) => p.attractionTypeKey !== "bowling").map((p) => ({ kind: "product", ...p }));
|
|
1399
|
-
const eventOffers = (events.data ?? []).map((e) => ({
|
|
1400
|
-
kind: "event",
|
|
1401
|
-
id: e.id,
|
|
1402
|
-
slug: e.slug,
|
|
1403
|
-
name: e.title,
|
|
1404
|
-
date: e.date,
|
|
1405
|
-
description: e.subtitle ?? e.description,
|
|
1406
|
-
purchaseMode: e.purchaseMode,
|
|
1407
|
-
productId: e.productId,
|
|
1408
|
-
pricePlanId: e.pricePlanId,
|
|
1409
|
-
priceCents: e.priceCents
|
|
1410
|
-
}));
|
|
1411
|
-
const packageOffers = (packages.data ?? []).map((p) => ({
|
|
1412
|
-
kind: "package",
|
|
1413
|
-
id: p.id,
|
|
1414
|
-
name: p.name,
|
|
1415
|
-
priceCents: p.basePriceCents,
|
|
1416
|
-
description: p.description
|
|
1417
|
-
}));
|
|
1418
|
-
const membershipOffers = (memberships.data ?? []).map((m) => ({
|
|
1419
|
-
kind: "membership",
|
|
1420
|
-
id: m.id,
|
|
1421
|
-
name: m.name,
|
|
1422
|
-
priceCents: m.recurringPriceCents,
|
|
1423
|
-
description: m.description
|
|
1424
|
-
}));
|
|
1425
|
-
const gameCardOffers = (gameCards.data ?? []).map((g) => ({
|
|
1426
|
-
kind: "gamecard",
|
|
1427
|
-
id: g.id,
|
|
1428
|
-
name: g.name,
|
|
1429
|
-
priceCents: g.priceCents,
|
|
1430
|
-
description: g.description
|
|
1431
|
-
}));
|
|
1432
|
-
const sections = [
|
|
1433
|
-
{ title: t.bowling, offers: bowling },
|
|
1434
|
-
{ title: t.otherAttractions, offers: other },
|
|
1435
|
-
{ title: t.events, offers: eventOffers },
|
|
1436
|
-
{ title: t.packages, offers: packageOffers },
|
|
1437
|
-
{ title: t.memberships, offers: membershipOffers },
|
|
1438
|
-
{ title: t.gamePasses, offers: gameCardOffers }
|
|
1439
|
-
].filter((sec) => sec.offers.length > 0);
|
|
1377
|
+
const catalog = useCatalog({ brandId, centerId, surface });
|
|
1378
|
+
const sections = (catalog.data?.sections ?? []).filter(
|
|
1379
|
+
(sec) => sec.items.length > 0
|
|
1380
|
+
);
|
|
1440
1381
|
let body;
|
|
1441
|
-
if (
|
|
1382
|
+
if (catalog.loading && !catalog.data) {
|
|
1442
1383
|
body = /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.muted, children: t.loading });
|
|
1443
1384
|
} else if (sections.length === 0) {
|
|
1444
1385
|
body = /* @__PURE__ */ jsxRuntime.jsx("p", { style: s.muted, children: t.empty });
|
|
1445
1386
|
} else {
|
|
1446
1387
|
body = sections.map((sec) => /* @__PURE__ */ jsxRuntime.jsxs("section", { style: { marginTop: "0.5rem" }, children: [
|
|
1447
|
-
/* @__PURE__ */ jsxRuntime.jsx("h4", { style: s.sectionTitle, children: sec.
|
|
1448
|
-
sec.
|
|
1388
|
+
/* @__PURE__ */ jsxRuntime.jsx("h4", { style: s.sectionTitle, children: sectionLabels?.[sec.key] ?? sec.label }),
|
|
1389
|
+
sec.items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: s.listItem, children: [
|
|
1449
1390
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1450
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { style: s.listTitle, children:
|
|
1451
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { style: s.listMeta, children: subtitle
|
|
1391
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: s.listTitle, children: item.title }),
|
|
1392
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: s.listMeta, children: item.priceLabel ?? item.subtitle ?? "" })
|
|
1452
1393
|
] }),
|
|
1453
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1454
|
-
|
|
1455
|
-
|
|
1394
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1395
|
+
"button",
|
|
1396
|
+
{
|
|
1397
|
+
type: "button",
|
|
1398
|
+
style: s.primaryBtn,
|
|
1399
|
+
onClick: () => onSelect(item),
|
|
1400
|
+
children: t.select
|
|
1401
|
+
}
|
|
1402
|
+
)
|
|
1403
|
+
] }, item.id))
|
|
1404
|
+
] }, sec.key));
|
|
1456
1405
|
}
|
|
1457
1406
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, style: s.card, children: [
|
|
1458
1407
|
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: s.heading, children: t.heading }),
|
|
1459
1408
|
body
|
|
1460
1409
|
] });
|
|
1461
1410
|
}
|
|
1462
|
-
function subtitle(offer, t) {
|
|
1463
|
-
switch (offer.kind) {
|
|
1464
|
-
case "product":
|
|
1465
|
-
return `${offer.attractionName} \xB7 ${offer.durationMinutes} ${t.minutesAbbrev}`;
|
|
1466
|
-
case "event":
|
|
1467
|
-
return offer.priceCents !== null ? `${offer.date} \xB7 ${formatCents(offer.priceCents)}` : offer.date;
|
|
1468
|
-
case "membership":
|
|
1469
|
-
return `${formatCents(offer.priceCents)}${t.perMonth}`;
|
|
1470
|
-
case "package":
|
|
1471
|
-
case "gamecard":
|
|
1472
|
-
return formatCents(offer.priceCents);
|
|
1473
|
-
}
|
|
1474
|
-
}
|
|
1475
1411
|
|
|
1476
1412
|
exports.AccountDashboard = AccountDashboard;
|
|
1477
1413
|
exports.AccountMenu = AccountMenu;
|