@bowlos/reservations 0.35.0 → 0.41.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/AGENTS.md +300 -0
- package/HEADLESS.md +716 -11
- package/README.md +363 -2
- package/dist/{data-qw8P3JW3.d.cts → account-DEX2Lr78.d.cts} +218 -3
- package/dist/{data-qw8P3JW3.d.ts → account-DEX2Lr78.d.ts} +218 -3
- package/dist/booking-change-4DGu-B08.d.ts +1282 -0
- package/dist/booking-change-aK6P37FZ.d.cts +1282 -0
- package/dist/{chunk-UN5E6UEZ.js → chunk-44WKP6MW.js} +38 -7
- package/dist/chunk-44WKP6MW.js.map +1 -0
- package/dist/{chunk-MMSVM3QS.js → chunk-BWJHRJN6.js} +75 -187
- package/dist/chunk-BWJHRJN6.js.map +1 -0
- package/dist/{chunk-Y3YSDO3H.js → chunk-FMFHNBDH.js} +56 -5
- package/dist/chunk-FMFHNBDH.js.map +1 -0
- package/dist/chunk-I37IJNYU.js +139 -0
- package/dist/chunk-I37IJNYU.js.map +1 -0
- package/dist/chunk-VJIS56OO.js +717 -0
- package/dist/chunk-VJIS56OO.js.map +1 -0
- package/dist/{chunk-SMPDCDMB.js → chunk-YAXBZJMI.js} +3 -3
- package/dist/chunk-YAXBZJMI.js.map +1 -0
- package/dist/cli.cjs +34 -6
- package/dist/cli.cjs.map +1 -1
- package/dist/components.cjs +1596 -4
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +208 -7
- package/dist/components.d.ts +208 -7
- package/dist/components.js +1046 -8
- package/dist/components.js.map +1 -1
- package/dist/index.cjs +299 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -5
- package/dist/index.d.ts +56 -5
- package/dist/index.js +77 -5
- package/dist/index.js.map +1 -1
- package/dist/payments.cjs +203 -0
- package/dist/payments.cjs.map +1 -1
- package/dist/payments.d.cts +16 -2
- package/dist/payments.d.ts +16 -2
- package/dist/payments.js +78 -2
- package/dist/payments.js.map +1 -1
- package/dist/{react-C2V1kXnO.d.ts → react-CrRciA7I.d.ts} +2 -2
- package/dist/{react-DtncBQ3b.d.cts → react-QJrsaOnN.d.cts} +2 -2
- package/dist/react.cjs +801 -30
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +150 -7
- package/dist/react.d.ts +150 -7
- package/dist/react.js +72 -4
- package/dist/react.js.map +1 -1
- package/package.json +10 -3
- package/templates/center-site/README.md +5 -0
- package/templates/center-site/app/account/game-cards/page.tsx +17 -0
- package/templates/center-site/app/account/layout.tsx +16 -0
- package/templates/center-site/app/account/memberships/[id]/page.tsx +23 -0
- package/templates/center-site/app/account/memberships/page.tsx +33 -0
- package/templates/center-site/app/account/orders/page.tsx +17 -0
- package/templates/center-site/app/account/page.tsx +14 -0
- package/templates/center-site/app/account/payment-methods/page.tsx +23 -0
- package/templates/center-site/app/account/privacy/page.tsx +17 -0
- package/templates/center-site/app/account/profile/page.tsx +45 -0
- package/templates/center-site/app/account/reservations/[displayId]/change/page.tsx +46 -0
- package/templates/center-site/app/account/reservations/[displayId]/page.tsx +41 -0
- package/templates/center-site/app/account/reservations/page.tsx +35 -0
- package/templates/center-site/app/account/security/page.tsx +17 -0
- package/templates/center-site/app/book/page.tsx +11 -23
- package/templates/center-site/app/catalog/page.tsx +21 -12
- package/templates/center-site/app/events/[slug]/page.tsx +130 -0
- package/templates/center-site/app/events/page.tsx +57 -0
- package/templates/center-site/app/pay/[token]/page.tsx +53 -0
- package/templates/center-site/app/site-header.tsx +1 -0
- package/templates/center-site/lib/reservation.ts +14 -0
- package/templates/center-site/package.json +1 -1
- package/templates/center-site/tsconfig.json +7 -9
- package/dist/account-BJ5UjC0r.d.ts +0 -165
- package/dist/account-QoFg8-i1.d.cts +0 -165
- package/dist/catalog-CGitz1PG.d.ts +0 -221
- package/dist/catalog-p9cwB6Qv.d.cts +0 -221
- package/dist/chunk-MMSVM3QS.js.map +0 -1
- package/dist/chunk-SMPDCDMB.js.map +0 -1
- package/dist/chunk-UN5E6UEZ.js.map +0 -1
- package/dist/chunk-Y3YSDO3H.js.map +0 -1
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import { g as BowlosClient } from './data-qw8P3JW3.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Error model for the BowlOS Reservations SDK.
|
|
5
|
-
*
|
|
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
|
-
*/
|
|
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";
|
|
33
|
-
};
|
|
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
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Public catalog reads for @bowlos/reservations — the "what can I book/buy here"
|
|
58
|
-
* surface that powers `<BookingCatalog>`. All anonymous (no customer login).
|
|
59
|
-
* Products + events + memberships are Center-scoped; packages + game cards are
|
|
60
|
-
* Brand-scoped (with an optional Center filter). Results are generic (`<T>`);
|
|
61
|
-
* the component types the display fields it needs.
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
type CenterScoped = {
|
|
65
|
-
centerId: string;
|
|
66
|
-
};
|
|
67
|
-
type BrandCatalogArgs = {
|
|
68
|
-
brandId: string;
|
|
69
|
-
centerId?: string;
|
|
70
|
-
};
|
|
71
|
-
/** Which public surface is asking — the backend applies that surface's
|
|
72
|
-
* per-category + per-offer visibility before returning. */
|
|
73
|
-
type PublicSurface = "sdk_custom_site" | "white_label_web" | "mobile_app";
|
|
74
|
-
type CatalogCategory = "bowling" | "other_attractions" | "events" | "packages" | "memberships" | "game_passes";
|
|
75
|
-
type CatalogActionType = "book_reservation" | "view_event" | "buy_ticket" | "buy_package" | "buy_membership" | "buy_game_pass";
|
|
76
|
-
type CatalogSourceTable = "products" | "event_offers" | "packages" | "membership_templates" | "game_card_templates";
|
|
77
|
-
/** A normalized, surface-agnostic catalog item. Route by `action.type`, using
|
|
78
|
-
* the IDs in `action.payload` (e.g. `productId`, `slug`, `packageId`,
|
|
79
|
-
* `templateId`). `priceLabel` is an indicative "from $X" only (null for
|
|
80
|
-
* products — show "See times & pricing"); the binding price comes from the
|
|
81
|
-
* per-category preview after login. */
|
|
82
|
-
interface CatalogItem {
|
|
83
|
-
id: string;
|
|
84
|
-
category: CatalogCategory;
|
|
85
|
-
sourceTable: CatalogSourceTable;
|
|
86
|
-
sourceId: string;
|
|
87
|
-
title: string;
|
|
88
|
-
subtitle?: string | null;
|
|
89
|
-
description?: string | null;
|
|
90
|
-
priceLabel?: string | null;
|
|
91
|
-
imageUrl?: string | null;
|
|
92
|
-
badgeLabel?: string | null;
|
|
93
|
-
action: {
|
|
94
|
-
type: CatalogActionType;
|
|
95
|
-
payload: Record<string, string>;
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
interface CatalogSection {
|
|
99
|
-
key: CatalogCategory;
|
|
100
|
-
label: string;
|
|
101
|
-
items: CatalogItem[];
|
|
102
|
-
}
|
|
103
|
-
interface CatalogResult {
|
|
104
|
-
sections: CatalogSection[];
|
|
105
|
-
/**
|
|
106
|
-
* Date-first booking (v0.24.0): the Center's default booking entry point.
|
|
107
|
-
* Open your funnel on this; let the customer toggle to the other. Optional —
|
|
108
|
-
* older gateways omit it (treat absent as `"product_first"`).
|
|
109
|
-
*/
|
|
110
|
-
bookingEntryDefault?: "product_first" | "date_first";
|
|
111
|
-
/** Center-local "today" (YYYY-MM-DD) — default + minimum for a date-first
|
|
112
|
-
* date picker, so you don't guess the Center's timezone. Optional. */
|
|
113
|
-
todayISO?: string;
|
|
114
|
-
/**
|
|
115
|
-
* Full Test Mode (2026-06-23): true when the operator has put this Center in
|
|
116
|
-
* test mode. Render a customer-facing "Maintenance mode" notice (use
|
|
117
|
-
* `<MaintenanceBanner>` or `useTestMode()`); normal customers' bookings are
|
|
118
|
-
* server-refused (`CENTER_IN_MAINTENANCE`) — only admin Test-Account customers
|
|
119
|
-
* transact. Absent on older gateways → false.
|
|
120
|
-
*/
|
|
121
|
-
maintenanceMode?: boolean;
|
|
122
|
-
}
|
|
123
|
-
/** Args for the canonical catalog read. `surface` selects which visibility
|
|
124
|
-
* rules the backend applies. */
|
|
125
|
-
type CatalogArgs = {
|
|
126
|
-
brandId: string;
|
|
127
|
-
centerId: string;
|
|
128
|
-
surface: PublicSurface;
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* The canonical public catalog for a surface — every active, public,
|
|
132
|
-
* bookable/sellable item grouped into the six first-class categories, with the
|
|
133
|
-
* Center admin's per-surface category + offer visibility already applied.
|
|
134
|
-
* Anonymous. This is the recommended way to list "everything bookable here":
|
|
135
|
-
* one call, all categories, visibility-aware, consistent with the white-label
|
|
136
|
-
* web + mobile surfaces.
|
|
137
|
-
*/
|
|
138
|
-
declare function listCatalog<T = CatalogResult>(client: BowlosClient, args: CatalogArgs): Promise<T>;
|
|
139
|
-
/** One package's full detail. `shareToken` reveals a hidden/unlisted package. */
|
|
140
|
-
type PackageDetailArgs = {
|
|
141
|
-
packageId: string;
|
|
142
|
-
shareToken?: string;
|
|
143
|
-
};
|
|
144
|
-
/** Args for a Center's operating-hours window on a date, across attraction types. */
|
|
145
|
-
type CenterHoursArgs = {
|
|
146
|
-
centerId: string;
|
|
147
|
-
attractionTypeKeys: string[];
|
|
148
|
-
dateISO: string;
|
|
149
|
-
};
|
|
150
|
-
/** Bookable products at a Center (each carries its attraction + `attractionTypeKey`). */
|
|
151
|
-
declare function listProducts<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
152
|
-
/** Upcoming pricing events (NYE Bash, tournaments…) at a Center. */
|
|
153
|
-
declare function listEvents<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
154
|
-
/** Sellable event offers at a Center. These are the public lineup + event
|
|
155
|
-
* landing-page records; use this instead of `listEvents` when routing a
|
|
156
|
-
* customer to an event purchase flow. */
|
|
157
|
-
declare function listEventOffers<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
158
|
-
/** One sellable event offer by landing-page slug. */
|
|
159
|
-
declare function getEventOffer<T = unknown>(client: BowlosClient, args: {
|
|
160
|
-
slug: string;
|
|
161
|
-
}): Promise<T>;
|
|
162
|
-
/** Purchasable packages at a Brand. */
|
|
163
|
-
declare function listPackages<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
|
|
164
|
-
/** Full detail for one package — components, optional add-ons, allowed start
|
|
165
|
-
* times, duration, and quantity bounds. Drives the headless package config UI
|
|
166
|
-
* (see HEADLESS.md → "Buying a package"). */
|
|
167
|
-
declare function getPackage<T = unknown>(client: BowlosClient, args: PackageDetailArgs): Promise<T>;
|
|
168
|
-
/** A Center's combined open/close window (minutes-from-midnight) for the given
|
|
169
|
-
* attraction types on a date — the intersection across types; `null` if closed.
|
|
170
|
-
* Bound a package's start times with its component attraction-type keys. */
|
|
171
|
-
declare function getCenterHours<T = unknown>(client: BowlosClient, args: CenterHoursArgs): Promise<T>;
|
|
172
|
-
/** Purchasable memberships at a Center. */
|
|
173
|
-
declare function listPublicMemberships<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
174
|
-
/** Purchasable game cards / passes at a Brand. */
|
|
175
|
-
declare function listGameCards<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
|
|
176
|
-
/** A pricing mode an attraction charges in. */
|
|
177
|
-
type RetailPricingMode = "per_unit_per_hour" | "per_person_per_hour" | "per_game";
|
|
178
|
-
/** One matrix row — a day-of-week + time band with per-mode rates. */
|
|
179
|
-
interface RetailWalkInRate {
|
|
180
|
-
dayOfWeek: number;
|
|
181
|
-
startMinuteOfDay: number;
|
|
182
|
-
endMinuteOfDay: number;
|
|
183
|
-
label: string | null;
|
|
184
|
-
rateUnitHourCents: number | null;
|
|
185
|
-
ratePersonHourCents: number | null;
|
|
186
|
-
rateGameCents: number | null;
|
|
187
|
-
}
|
|
188
|
-
/** Walk-in rates grouped by attraction. */
|
|
189
|
-
interface RetailAttraction {
|
|
190
|
-
attractionId: string;
|
|
191
|
-
name: string;
|
|
192
|
-
typeKey: string;
|
|
193
|
-
enabledModes: RetailPricingMode[];
|
|
194
|
-
unitLabelSingular: string;
|
|
195
|
-
unitLabelPlural: string;
|
|
196
|
-
walkInRates: RetailWalkInRate[];
|
|
197
|
-
}
|
|
198
|
-
/** A featured "website special" (an opted-in price plan). */
|
|
199
|
-
interface RetailSpecial {
|
|
200
|
-
planId: string;
|
|
201
|
-
name: string;
|
|
202
|
-
description: string;
|
|
203
|
-
priceCents: number | null;
|
|
204
|
-
attractionId: string;
|
|
205
|
-
attractionName: string;
|
|
206
|
-
/** Seasonal window (YYYY-MM-DD) when set — label/hide out of season. */
|
|
207
|
-
effectiveStartDate: string | null;
|
|
208
|
-
effectiveEndDate: string | null;
|
|
209
|
-
}
|
|
210
|
-
/** The full retail-pricing payload for a Center. */
|
|
211
|
-
interface RetailPricing {
|
|
212
|
-
centerName: string;
|
|
213
|
-
attractions: RetailAttraction[];
|
|
214
|
-
specials: RetailSpecial[];
|
|
215
|
-
}
|
|
216
|
-
/** A Center's public price list: walk-in (matrix) rates + website specials.
|
|
217
|
-
* Read-only, anonymous — drives a printed-menu-style pricing page that always
|
|
218
|
-
* matches the operator's live config. Not a booking surface. */
|
|
219
|
-
declare function listRetailPricing<T = RetailPricing>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
220
|
-
|
|
221
|
-
export { listPublicMemberships as A, BOWLOS_ERROR_CODES as B, type CatalogActionType as C, listRetailPricing as D, type PackageDetailArgs as P, type RetailAttraction as R, 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, type RetailPricing as n, type RetailPricingMode as o, type RetailSpecial as p, type RetailWalkInRate as q, getCenterHours as r, getEventOffer as s, getPackage as t, listCatalog as u, listEventOffers as v, listEvents as w, listGameCards as x, listPackages as y, listProducts as z };
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import { g as BowlosClient } from './data-qw8P3JW3.cjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Error model for the BowlOS Reservations SDK.
|
|
5
|
-
*
|
|
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
|
-
*/
|
|
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";
|
|
33
|
-
};
|
|
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
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Public catalog reads for @bowlos/reservations — the "what can I book/buy here"
|
|
58
|
-
* surface that powers `<BookingCatalog>`. All anonymous (no customer login).
|
|
59
|
-
* Products + events + memberships are Center-scoped; packages + game cards are
|
|
60
|
-
* Brand-scoped (with an optional Center filter). Results are generic (`<T>`);
|
|
61
|
-
* the component types the display fields it needs.
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
type CenterScoped = {
|
|
65
|
-
centerId: string;
|
|
66
|
-
};
|
|
67
|
-
type BrandCatalogArgs = {
|
|
68
|
-
brandId: string;
|
|
69
|
-
centerId?: string;
|
|
70
|
-
};
|
|
71
|
-
/** Which public surface is asking — the backend applies that surface's
|
|
72
|
-
* per-category + per-offer visibility before returning. */
|
|
73
|
-
type PublicSurface = "sdk_custom_site" | "white_label_web" | "mobile_app";
|
|
74
|
-
type CatalogCategory = "bowling" | "other_attractions" | "events" | "packages" | "memberships" | "game_passes";
|
|
75
|
-
type CatalogActionType = "book_reservation" | "view_event" | "buy_ticket" | "buy_package" | "buy_membership" | "buy_game_pass";
|
|
76
|
-
type CatalogSourceTable = "products" | "event_offers" | "packages" | "membership_templates" | "game_card_templates";
|
|
77
|
-
/** A normalized, surface-agnostic catalog item. Route by `action.type`, using
|
|
78
|
-
* the IDs in `action.payload` (e.g. `productId`, `slug`, `packageId`,
|
|
79
|
-
* `templateId`). `priceLabel` is an indicative "from $X" only (null for
|
|
80
|
-
* products — show "See times & pricing"); the binding price comes from the
|
|
81
|
-
* per-category preview after login. */
|
|
82
|
-
interface CatalogItem {
|
|
83
|
-
id: string;
|
|
84
|
-
category: CatalogCategory;
|
|
85
|
-
sourceTable: CatalogSourceTable;
|
|
86
|
-
sourceId: string;
|
|
87
|
-
title: string;
|
|
88
|
-
subtitle?: string | null;
|
|
89
|
-
description?: string | null;
|
|
90
|
-
priceLabel?: string | null;
|
|
91
|
-
imageUrl?: string | null;
|
|
92
|
-
badgeLabel?: string | null;
|
|
93
|
-
action: {
|
|
94
|
-
type: CatalogActionType;
|
|
95
|
-
payload: Record<string, string>;
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
interface CatalogSection {
|
|
99
|
-
key: CatalogCategory;
|
|
100
|
-
label: string;
|
|
101
|
-
items: CatalogItem[];
|
|
102
|
-
}
|
|
103
|
-
interface CatalogResult {
|
|
104
|
-
sections: CatalogSection[];
|
|
105
|
-
/**
|
|
106
|
-
* Date-first booking (v0.24.0): the Center's default booking entry point.
|
|
107
|
-
* Open your funnel on this; let the customer toggle to the other. Optional —
|
|
108
|
-
* older gateways omit it (treat absent as `"product_first"`).
|
|
109
|
-
*/
|
|
110
|
-
bookingEntryDefault?: "product_first" | "date_first";
|
|
111
|
-
/** Center-local "today" (YYYY-MM-DD) — default + minimum for a date-first
|
|
112
|
-
* date picker, so you don't guess the Center's timezone. Optional. */
|
|
113
|
-
todayISO?: string;
|
|
114
|
-
/**
|
|
115
|
-
* Full Test Mode (2026-06-23): true when the operator has put this Center in
|
|
116
|
-
* test mode. Render a customer-facing "Maintenance mode" notice (use
|
|
117
|
-
* `<MaintenanceBanner>` or `useTestMode()`); normal customers' bookings are
|
|
118
|
-
* server-refused (`CENTER_IN_MAINTENANCE`) — only admin Test-Account customers
|
|
119
|
-
* transact. Absent on older gateways → false.
|
|
120
|
-
*/
|
|
121
|
-
maintenanceMode?: boolean;
|
|
122
|
-
}
|
|
123
|
-
/** Args for the canonical catalog read. `surface` selects which visibility
|
|
124
|
-
* rules the backend applies. */
|
|
125
|
-
type CatalogArgs = {
|
|
126
|
-
brandId: string;
|
|
127
|
-
centerId: string;
|
|
128
|
-
surface: PublicSurface;
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* The canonical public catalog for a surface — every active, public,
|
|
132
|
-
* bookable/sellable item grouped into the six first-class categories, with the
|
|
133
|
-
* Center admin's per-surface category + offer visibility already applied.
|
|
134
|
-
* Anonymous. This is the recommended way to list "everything bookable here":
|
|
135
|
-
* one call, all categories, visibility-aware, consistent with the white-label
|
|
136
|
-
* web + mobile surfaces.
|
|
137
|
-
*/
|
|
138
|
-
declare function listCatalog<T = CatalogResult>(client: BowlosClient, args: CatalogArgs): Promise<T>;
|
|
139
|
-
/** One package's full detail. `shareToken` reveals a hidden/unlisted package. */
|
|
140
|
-
type PackageDetailArgs = {
|
|
141
|
-
packageId: string;
|
|
142
|
-
shareToken?: string;
|
|
143
|
-
};
|
|
144
|
-
/** Args for a Center's operating-hours window on a date, across attraction types. */
|
|
145
|
-
type CenterHoursArgs = {
|
|
146
|
-
centerId: string;
|
|
147
|
-
attractionTypeKeys: string[];
|
|
148
|
-
dateISO: string;
|
|
149
|
-
};
|
|
150
|
-
/** Bookable products at a Center (each carries its attraction + `attractionTypeKey`). */
|
|
151
|
-
declare function listProducts<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
152
|
-
/** Upcoming pricing events (NYE Bash, tournaments…) at a Center. */
|
|
153
|
-
declare function listEvents<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
154
|
-
/** Sellable event offers at a Center. These are the public lineup + event
|
|
155
|
-
* landing-page records; use this instead of `listEvents` when routing a
|
|
156
|
-
* customer to an event purchase flow. */
|
|
157
|
-
declare function listEventOffers<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
158
|
-
/** One sellable event offer by landing-page slug. */
|
|
159
|
-
declare function getEventOffer<T = unknown>(client: BowlosClient, args: {
|
|
160
|
-
slug: string;
|
|
161
|
-
}): Promise<T>;
|
|
162
|
-
/** Purchasable packages at a Brand. */
|
|
163
|
-
declare function listPackages<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
|
|
164
|
-
/** Full detail for one package — components, optional add-ons, allowed start
|
|
165
|
-
* times, duration, and quantity bounds. Drives the headless package config UI
|
|
166
|
-
* (see HEADLESS.md → "Buying a package"). */
|
|
167
|
-
declare function getPackage<T = unknown>(client: BowlosClient, args: PackageDetailArgs): Promise<T>;
|
|
168
|
-
/** A Center's combined open/close window (minutes-from-midnight) for the given
|
|
169
|
-
* attraction types on a date — the intersection across types; `null` if closed.
|
|
170
|
-
* Bound a package's start times with its component attraction-type keys. */
|
|
171
|
-
declare function getCenterHours<T = unknown>(client: BowlosClient, args: CenterHoursArgs): Promise<T>;
|
|
172
|
-
/** Purchasable memberships at a Center. */
|
|
173
|
-
declare function listPublicMemberships<T = unknown>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
174
|
-
/** Purchasable game cards / passes at a Brand. */
|
|
175
|
-
declare function listGameCards<T = unknown>(client: BowlosClient, args: BrandCatalogArgs): Promise<T>;
|
|
176
|
-
/** A pricing mode an attraction charges in. */
|
|
177
|
-
type RetailPricingMode = "per_unit_per_hour" | "per_person_per_hour" | "per_game";
|
|
178
|
-
/** One matrix row — a day-of-week + time band with per-mode rates. */
|
|
179
|
-
interface RetailWalkInRate {
|
|
180
|
-
dayOfWeek: number;
|
|
181
|
-
startMinuteOfDay: number;
|
|
182
|
-
endMinuteOfDay: number;
|
|
183
|
-
label: string | null;
|
|
184
|
-
rateUnitHourCents: number | null;
|
|
185
|
-
ratePersonHourCents: number | null;
|
|
186
|
-
rateGameCents: number | null;
|
|
187
|
-
}
|
|
188
|
-
/** Walk-in rates grouped by attraction. */
|
|
189
|
-
interface RetailAttraction {
|
|
190
|
-
attractionId: string;
|
|
191
|
-
name: string;
|
|
192
|
-
typeKey: string;
|
|
193
|
-
enabledModes: RetailPricingMode[];
|
|
194
|
-
unitLabelSingular: string;
|
|
195
|
-
unitLabelPlural: string;
|
|
196
|
-
walkInRates: RetailWalkInRate[];
|
|
197
|
-
}
|
|
198
|
-
/** A featured "website special" (an opted-in price plan). */
|
|
199
|
-
interface RetailSpecial {
|
|
200
|
-
planId: string;
|
|
201
|
-
name: string;
|
|
202
|
-
description: string;
|
|
203
|
-
priceCents: number | null;
|
|
204
|
-
attractionId: string;
|
|
205
|
-
attractionName: string;
|
|
206
|
-
/** Seasonal window (YYYY-MM-DD) when set — label/hide out of season. */
|
|
207
|
-
effectiveStartDate: string | null;
|
|
208
|
-
effectiveEndDate: string | null;
|
|
209
|
-
}
|
|
210
|
-
/** The full retail-pricing payload for a Center. */
|
|
211
|
-
interface RetailPricing {
|
|
212
|
-
centerName: string;
|
|
213
|
-
attractions: RetailAttraction[];
|
|
214
|
-
specials: RetailSpecial[];
|
|
215
|
-
}
|
|
216
|
-
/** A Center's public price list: walk-in (matrix) rates + website specials.
|
|
217
|
-
* Read-only, anonymous — drives a printed-menu-style pricing page that always
|
|
218
|
-
* matches the operator's live config. Not a booking surface. */
|
|
219
|
-
declare function listRetailPricing<T = RetailPricing>(client: BowlosClient, args: CenterScoped): Promise<T>;
|
|
220
|
-
|
|
221
|
-
export { listPublicMemberships as A, BOWLOS_ERROR_CODES as B, type CatalogActionType as C, listRetailPricing as D, type PackageDetailArgs as P, type RetailAttraction as R, 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, type RetailPricing as n, type RetailPricingMode as o, type RetailSpecial as p, type RetailWalkInRate as q, getCenterHours as r, getEventOffer as s, getPackage as t, listCatalog as u, listEventOffers as v, listEvents as w, listGameCards as x, listPackages as y, listProducts as z };
|
|
@@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AA,OAAO;AAAA,IACL,MAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,aAAA;AAAA,IACA,WAAA;AAAA,IACA,eAAA,EAAiB,IAAA,GAAO,IAAA,CAAK,eAAA,GAAkB,IAAA;AAAA,IAC/C,KAAA;AAAA,IACA,SAAA;AAAA,IACA,cAAA;AAAA,IACA,UAAA;AAAA,IACA,YAAA;AAAA,IACA,WAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACF;AACF","file":"chunk-MMSVM3QS.js","sourcesContent":["/**\n * React layer for @bowlos/reservations.\n *\n * `<BowlosProvider>` holds one `BowlosClient`; `useAccount()` manages the\n * customer session (probe on mount, sign-in/up/link/out, current customer);\n * `useBowlosQuery()` is the generic read hook the typed data hooks\n * (`useAvailability`, `useBookingFlow`, …) will build on next.\n *\n * Lives in its own module so non-React consumers of the core never pull React.\n * (The `@bowlos/reservations/react` export subpath is wired with the publish build.)\n */\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport { BowlosClient, createBowlosClient } from \"./client\";\nimport { BowlosApiError } from \"./errors\";\nimport type { AuthState, BowlosClientConfig, Customer, LinkProfile } from \"./types\";\n\nconst BowlosContext = createContext<BowlosClient | null>(null);\nconst AccountContext = createContext<UseAccountResult | null>(null);\n\nexport interface BowlosProviderProps {\n /** A prebuilt client, or pass `config` to have one created and memoized. */\n client?: BowlosClient;\n config?: BowlosClientConfig;\n children: ReactNode;\n}\n\nexport function BowlosProvider({ client, config, children }: BowlosProviderProps) {\n const ref = useRef<BowlosClient | null>(client ?? null);\n if (!ref.current) {\n if (!config) {\n throw new Error(\"BowlosProvider requires either a `client` or a `config`.\");\n }\n ref.current = createBowlosClient(config);\n }\n const bowlosClient = ref.current as BowlosClient; // non-null after the guard above\n // Run the session machine ONCE here and share it via context, so every\n // useAccount() across the app sees the same session.\n const account = useAccountState(bowlosClient);\n return (\n <BowlosContext.Provider value={bowlosClient}>\n <AccountContext.Provider value={account}>{children}</AccountContext.Provider>\n </BowlosContext.Provider>\n );\n}\n\nexport function useBowlosClient(): BowlosClient {\n const client = useContext(BowlosContext);\n if (!client) {\n throw new Error(\"useBowlosClient must be used within a <BowlosProvider>.\");\n }\n return client;\n}\n\n// ── useAccount ──────────────────────────────────────────────────────────────\n\nexport type AccountStatus = \"loading\" | AuthState;\n\nexport interface UseAccountResult {\n status: AccountStatus;\n customer: Customer | null;\n error: BowlosApiError | null;\n signIn: (email: string, password: string) => Promise<void>;\n /** Atomic sign-up (preferred): login + customer profile in one call. */\n register: (\n email: string,\n password: string,\n profile: Omit<LinkProfile, \"email\">,\n ) => Promise<void>;\n signUp: (email: string, password: string) => Promise<void>;\n link: (profile: LinkProfile) => Promise<void>;\n /** Forgot-password step 1: email a reset code (no session change). Always\n * resolves — the server never reveals whether the email has an account. */\n requestPasswordReset: (email: string) => Promise<void>;\n /** Forgot-password step 2: verify the code + set a new password. On success\n * the customer is signed in (status flips to linked). */\n resetPassword: (\n email: string,\n code: string,\n newPassword: string,\n ) => Promise<void>;\n signOut: () => Promise<void>;\n refresh: () => Promise<void>;\n}\n\n/** The session state machine — runs ONCE inside `<BowlosProvider>` and is shared\n * via context. Probes once on mount; each action re-probes so `status`/`customer`\n * stay current. Consumers use `useAccount()`, never this directly. */\nfunction useAccountState(client: BowlosClient): UseAccountResult {\n const [status, setStatus] = useState<AccountStatus>(\"loading\");\n const [customer, setCustomer] = useState<Customer | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n\n const refresh = useCallback(async () => {\n try {\n const state = await client.probe();\n setStatus(state);\n setCustomer(state === \"linked\" ? await client.me() : null);\n setError(null);\n } catch (e) {\n setStatus(\"unauthenticated\");\n setCustomer(null);\n if (e instanceof BowlosApiError) setError(e);\n }\n }, [client]);\n\n useEffect(() => {\n void refresh();\n }, [refresh]);\n\n const run = useCallback(\n async (action: () => Promise<unknown>) => {\n setError(null);\n try {\n await action();\n await refresh();\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n throw e;\n }\n },\n [refresh],\n );\n\n const signIn = useCallback(\n (email: string, password: string) => run(() => client.signIn(email, password)),\n [client, run],\n );\n const register = useCallback(\n (email: string, password: string, profile: Omit<LinkProfile, \"email\">) =>\n run(() => client.register(email, password, profile)),\n [client, run],\n );\n const signUp = useCallback(\n (email: string, password: string) => run(() => client.signUp(email, password)),\n [client, run],\n );\n const link = useCallback((profile: LinkProfile) => run(() => client.link(profile)), [client, run]);\n // Step 1 doesn't change the session, so it doesn't re-probe — just surfaces\n // errors. Step 2 signs the customer in, so it runs through `run` (re-probe).\n const requestPasswordReset = useCallback(\n async (email: string) => {\n setError(null);\n try {\n await client.requestPasswordReset(email);\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n throw e;\n }\n },\n [client],\n );\n const resetPassword = useCallback(\n (email: string, code: string, newPassword: string) =>\n run(() => client.resetPassword(email, code, newPassword)),\n [client, run],\n );\n const signOut = useCallback(() => run(() => client.signOut()), [client, run]);\n\n return {\n status,\n customer,\n error,\n signIn,\n register,\n signUp,\n link,\n requestPasswordReset,\n resetPassword,\n signOut,\n refresh,\n };\n}\n\n/**\n * The customer session (state + actions), shared across the whole app. Every\n * call returns the SAME session — signing in or out anywhere updates the header,\n * the booking form, everywhere at once. Must be used within a `<BowlosProvider>`.\n */\nexport function useAccount(): UseAccountResult {\n const account = useContext(AccountContext);\n if (!account) {\n throw new Error(\"useAccount must be used within a <BowlosProvider>.\");\n }\n return account;\n}\n\n// ── useBowlosQuery ────────────────────────────────────────────────────────────\n\nexport interface UseQueryOptions {\n /** Send the customer bearer token (for session-scoped reads). */\n auth?: boolean;\n /** Skip fetching until true. Defaults to true. */\n enabled?: boolean;\n}\n\nexport interface UseQueryResult<T> {\n data: T | null;\n error: BowlosApiError | null;\n loading: boolean;\n refetch: () => Promise<void>;\n}\n\n/** Generic read hook over a gateway route. The typed data hooks\n * (`useAvailability`, etc.) will wrap this with route names + arg types. */\nexport function useBowlosQuery<T = unknown>(\n name: string,\n args: Record<string, unknown> = {},\n options: UseQueryOptions = {},\n): UseQueryResult<T> {\n const client = useBowlosClient();\n const auth = options.auth ?? false;\n const enabled = options.enabled ?? true;\n const [data, setData] = useState<T | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n const [loading, setLoading] = useState<boolean>(enabled);\n // Stabilize the args object across renders so the effect doesn't loop.\n const argsKey = JSON.stringify(args);\n\n const refetch = useCallback(async () => {\n setLoading(true);\n setError(null);\n try {\n const result = await client.call<T>(name, JSON.parse(argsKey) as Record<string, unknown>, {\n auth,\n });\n setData(result);\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n setData(null);\n } finally {\n setLoading(false);\n }\n }, [client, name, argsKey, auth]);\n\n useEffect(() => {\n if (enabled) void refetch();\n }, [enabled, refetch]);\n\n return { data, error, loading, refetch };\n}\n\n// ── useBowlosMutation ─────────────────────────────────────────────────────────\n\nexport interface UseMutationResult<TArgs, TData> {\n /** Fire the mutation. Resolves with the data, or throws BowlosApiError. */\n run: (args: TArgs) => Promise<TData>;\n data: TData | null;\n error: BowlosApiError | null;\n loading: boolean;\n reset: () => void;\n}\n\n/** Generic write hook over a gateway route. The typed mutation hooks\n * (`useCancelMyReservation`, etc.) wrap this with a route name + arg type. */\nexport function useBowlosMutation<TArgs extends Record<string, unknown>, TData = unknown>(\n name: string,\n options: { auth?: boolean } = {},\n): UseMutationResult<TArgs, TData> {\n const client = useBowlosClient();\n const auth = options.auth ?? false;\n const [data, setData] = useState<TData | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n const [loading, setLoading] = useState<boolean>(false);\n\n const run = useCallback(\n async (args: TArgs) => {\n setLoading(true);\n setError(null);\n try {\n const result = await client.call<TData>(name, args, { auth });\n setData(result);\n return result;\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n throw e;\n } finally {\n setLoading(false);\n }\n },\n [client, name, auth],\n );\n\n const reset = useCallback(() => {\n setData(null);\n setError(null);\n setLoading(false);\n }, []);\n\n return { run, data, error, loading, reset };\n}\n","/**\n * Typed React data hooks for the booking funnel, built on `useBowlosQuery`.\n * Same arg/result types as the framework-agnostic functions in `data.ts`.\n */\nimport { useCallback } from \"react\";\nimport {\n useBowlosQuery,\n useBowlosMutation,\n type UseQueryOptions,\n type UseQueryResult,\n type UseMutationResult,\n} from \"./react\";\nimport { generateIdempotencyKey } from \"./data\";\nimport type {\n CancelPreview,\n CancelResult,\n MyGameCard,\n ReservationCancelArgs,\n OrderCancelArgs,\n GameCardCancelArgs,\n} from \"./account\";\nimport type {\n AvailabilityArgs,\n AvailabilityResult,\n BookingPreviewArgs,\n BookingQuote,\n PublicAddon,\n StartTimesArgs,\n PackagePreviewArgs,\n PackagePreviewResult,\n GameCardPreviewArgs,\n GameCardPreviewResult,\n EventTicketPreviewArgs,\n EventTicketPreviewResult,\n MembershipPreviewArgs,\n MembershipPreviewResult,\n MembershipSubscriptionPreviewResult,\n} from \"./data\";\nimport type {\n BrandScoped,\n EventOrderDetailArgs,\n FlashBookingOptionsArgs,\n FlashSaleArgs,\n FlashSalesArgs,\n MembershipDetailArgs,\n ReservationDetailArgs,\n} from \"./account\";\nimport type {\n BrandCatalogArgs,\n CatalogArgs,\n CatalogResult,\n CenterScoped,\n PackageDetailArgs,\n CenterHoursArgs,\n RetailPricing,\n} from \"./catalog\";\n\n/** Live available-unit (unoccupied) count for a product / date / time window. */\nexport function useAvailability(\n args: AvailabilityArgs,\n options?: UseQueryOptions,\n): UseQueryResult<AvailabilityResult> {\n return useBowlosQuery<AvailabilityResult>(\"checkAvailability\", args, options);\n}\n\n/** Authoritative price quote for the chosen booking inputs. */\nexport function useBookingPreview(\n args: BookingPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<BookingQuote> {\n return useBowlosQuery<BookingQuote>(\"bookingPreview\", args, options);\n}\n\n/** Bookable add-ons (shoe rental, upgrades…) for a product. */\nexport function useAddons(\n args: { productId: string },\n options?: UseQueryOptions,\n): UseQueryResult<PublicAddon[]> {\n return useBowlosQuery<PublicAddon[]>(\"listPublicAddons\", args, options);\n}\n\n/** Bookable start times (minute-of-day) for a product on a date. */\nexport function useStartTimes(\n args: StartTimesArgs,\n options?: UseQueryOptions,\n): UseQueryResult<number[]> {\n return useBowlosQuery<number[]>(\"availableStartTimes\", args, options);\n}\n\n// ── account (require a signed-in customer) ───────────────────────────────────\n// Results are generic (`<T = unknown>`) — parameterize with your own shape.\n\n/** The signed-in customer's reservations. */\nexport function useMyReservations<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyReservations\", args, { ...options, auth: true });\n}\n\n/** One of the customer's reservations, by displayId. */\nexport function useMyReservationDetail<T = unknown>(\n args: ReservationDetailArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getMyReservationDetail\", args, { ...options, auth: true });\n}\n\n/** The signed-in customer's event ticket orders. */\nexport function useMyEventOrders<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyEventOrders\", args, { ...options, auth: true });\n}\n\n/** One of the customer's event ticket orders. */\nexport function useMyEventOrder<T = unknown>(\n args: EventOrderDetailArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getMyEventOrder\", args, { ...options, auth: true });\n}\n\n/** The customer's memberships. */\nexport function useMyMemberships<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyMemberships\", args, { ...options, auth: true });\n}\n\n/** One membership's detail. */\nexport function useMyMembershipDetail<T = unknown>(\n args: MembershipDetailArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getMyMembershipDetail\", args, { ...options, auth: true });\n}\n\n/** Loyalty tier + points. */\nexport function useMyLoyalty<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getMyLoyalty\", args, { ...options, auth: true });\n}\n\n/** Account credit balance + ledger. */\nexport function useMyCredits<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyCredits\", args, { ...options, auth: true });\n}\n\n/** Issued wallet passes. */\nexport function useMyPasses<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyPasses\", args, { ...options, auth: true });\n}\n\n/** The customer's game cards for this Brand (with the unused-only `cancellable`\n * flag), so a headless site can list them + drive cancel. */\nexport function useMyGameCards<T = MyGameCard[]>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyGameCards\", args, { ...options, auth: true });\n}\n\n// ── self-serve cancel (v0.23.0): preview reads + cancel mutations ─────────────\n//\n// Per type: preview \"what you'll get back\" → confirm → cancel. The cancel hooks\n// generate a fresh idempotencyKey per attempt, so the caller never manages it.\n// Game cards cancel only while fully unused (locked rule) → full credit.\n\n/** Preview the credit for cancelling a reservation (advisory; cancel re-computes). */\nexport function useReservationCancelPreview<T = CancelPreview>(\n args: { brandId: string; reservationId: string },\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMyCancellation\", args, { ...options, auth: true });\n}\n/** Preview the credit for cancelling an event order. */\nexport function useEventOrderCancelPreview<T = CancelPreview>(\n args: { brandId: string; orderId: string },\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMyEventOrderCancellation\", args, { ...options, auth: true });\n}\n/** Preview the credit for cancelling a package order. */\nexport function usePackageOrderCancelPreview<T = CancelPreview>(\n args: { brandId: string; orderId: string },\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMyPackageOrderCancellation\", args, { ...options, auth: true });\n}\n/** Preview the credit for cancelling a game card (full credit only if unused). */\nexport function useGameCardCancelPreview<T = CancelPreview>(\n args: { brandId: string; cardId: string },\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMyGameCardCancellation\", args, { ...options, auth: true });\n}\n\n/** Cancel a reservation → store credit per policy. Pass the `version` from the\n * list/detail as `expectedVersion`; the hook supplies the idempotency key. */\nexport function useCancelMyReservation(): UseMutationResult<\n Omit<ReservationCancelArgs, \"idempotencyKey\">,\n CancelResult\n> {\n const m = useBowlosMutation<ReservationCancelArgs, CancelResult>(\"cancelMyReservation\", {\n auth: true,\n });\n const run = useCallback(\n (args: Omit<ReservationCancelArgs, \"idempotencyKey\">) =>\n m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),\n [m],\n );\n return { ...m, run };\n}\n/** Cancel an event order → store credit per policy. */\nexport function useCancelMyEventOrder(): UseMutationResult<\n Omit<OrderCancelArgs, \"idempotencyKey\">,\n CancelResult\n> {\n const m = useBowlosMutation<OrderCancelArgs, CancelResult>(\"cancelMyEventOrder\", { auth: true });\n const run = useCallback(\n (args: Omit<OrderCancelArgs, \"idempotencyKey\">) =>\n m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),\n [m],\n );\n return { ...m, run };\n}\n/** Cancel a package order → store credit per policy; releases the slot. */\nexport function useCancelMyPackageOrder(): UseMutationResult<\n Omit<OrderCancelArgs, \"idempotencyKey\">,\n CancelResult\n> {\n const m = useBowlosMutation<OrderCancelArgs, CancelResult>(\"cancelMyPackageOrder\", { auth: true });\n const run = useCallback(\n (args: Omit<OrderCancelArgs, \"idempotencyKey\">) =>\n m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),\n [m],\n );\n return { ...m, run };\n}\n/** Cancel a game card → full credit (unused cards only). */\nexport function useCancelMyGameCard(): UseMutationResult<\n Omit<GameCardCancelArgs, \"idempotencyKey\">,\n CancelResult\n> {\n const m = useBowlosMutation<GameCardCancelArgs, CancelResult>(\"cancelMyGameCard\", { auth: true });\n const run = useCallback(\n (args: Omit<GameCardCancelArgs, \"idempotencyKey\">) =>\n m.run({ ...args, idempotencyKey: generateIdempotencyKey() }),\n [m],\n );\n return { ...m, run };\n}\n\n// ── flash sales (session-aware: members see prices) ──────────────────────────\n\n/** The public flash-sale page (members see prices; anonymous gets the locked view). */\nexport function useFlashSale<T = unknown>(\n args: FlashSaleArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getPublicFlashSaleBySlug\", args, { ...options, auth: true });\n}\n\n/** The public flash-sale index for a Brand (live + upcoming; no prices). Public. */\nexport function useFlashSales<T = unknown>(\n args: FlashSalesArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicFlashSales\", args, options);\n}\n\n/** Per-start-hour options for a flash-sale reservation item (members only). */\nexport function useFlashSaleBookingOptions<T = unknown>(\n args: FlashBookingOptionsArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getFlashSaleBookingOptions\", args, { ...options, auth: true });\n}\n\n// ── public catalog (anonymous; power `<BookingCatalog>`) ──────────────────────\n\n/**\n * The canonical public catalog for a surface — every category grouped, with the\n * Center admin's per-surface visibility already applied. Prefer this over the\n * per-category hooks below when you want the full, visibility-aware catalog\n * (it stays consistent with the white-label web + mobile surfaces). Anonymous.\n */\nexport function useCatalog<T = CatalogResult>(\n args: CatalogArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicCatalog\", args, options);\n}\n\n/**\n * Full Test Mode (2026-06-23): is this Center in operator-enabled test mode?\n * Reads the same `listPublicCatalog` payload as `useCatalog`, so it's free when\n * you already render the catalog. Show `<MaintenanceBanner>` (or your own themed\n * notice) when `maintenanceMode` is true — normal-customer bookings are\n * server-refused in this state (`CENTER_IN_MAINTENANCE`); only admin\n * Test-Account customers transact.\n */\nexport function useTestMode(\n args: CatalogArgs,\n options?: UseQueryOptions,\n): { maintenanceMode: boolean; loading: boolean } {\n const res = useCatalog(args, options);\n return {\n maintenanceMode: res.data?.maintenanceMode === true,\n loading: res.loading,\n };\n}\n\n/** Bookable products at a Center (each carries `attractionTypeKey`). */\nexport function useProducts<T = unknown>(\n args: CenterScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicProducts\", args, options);\n}\n\n/** Upcoming pricing events at a Center. */\nexport function useEvents<T = unknown>(\n args: CenterScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicEvents\", args, options);\n}\n\n/** Sellable event offers at a Center. Use these for the product lineup and\n * event landing pages; each row carries a slug and purchase mode. */\nexport function useEventOffers<T = unknown>(\n args: CenterScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicEventOffers\", args, options);\n}\n\n/** One sellable event offer by landing-page slug. */\nexport function useEventOffer<T = unknown>(\n args: { slug: string },\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getPublicEventOffer\", args, options);\n}\n\n/** Purchasable packages at a Brand. */\nexport function usePackages<T = unknown>(\n args: BrandCatalogArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicPackages\", args, options);\n}\n\n/** Full detail for one package (components, add-ons, allowed start times, …) —\n * drives the headless package config UI before `usePackagePurchase`. */\nexport function usePackage<T = unknown>(\n args: PackageDetailArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getPublicPackage\", args, options);\n}\n\n/** A Center's public price list — walk-in (matrix) rates grouped by attraction\n * plus opted-in \"website specials\". Anonymous, read-only; drives a printed-\n * menu-style pricing page (or the reference `<PricingTable>`). Not a booking\n * surface — render-only. */\nexport function useRetailPricing<T = RetailPricing>(\n args: CenterScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listRetailPricing\", args, options);\n}\n\n/** A Center's open/close window for the given attraction types on a date — use\n * the package's component attraction-type keys to bound its bookable slots. */\nexport function useCenterHours<T = unknown>(\n args: CenterHoursArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getCenterOperatingHoursForTypes\", args, options);\n}\n\n/** Itemized quote for a package order — base, add-ons, tax lines, the selling\n * Center's booking fee, and the authoritative grand total. Drives the headless\n * **Review** step. Requires a signed-in customer (tax exemptions are applied),\n * and is computed by the same engine as the PaymentIntent, so it never diverges\n * from what the customer is charged. */\nexport function usePackagePreview<T = PackagePreviewResult>(\n args: PackagePreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewPackageOrder\", args, { ...options, auth: true });\n}\n\n/** Purchasable memberships at a Center. */\nexport function usePublicMemberships<T = unknown>(\n args: CenterScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicMemberships\", args, options);\n}\n\n/** Purchasable game cards / passes at a Brand. */\nexport function useGameCards<T = unknown>(\n args: BrandCatalogArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicGameCards\", args, options);\n}\n\n/** Itemized quote for a game-pass purchase — the base price, tax lines, the\n * selling Center's booking fee, and the authoritative grand total. Drives the\n * headless **Review** step. Requires a signed-in customer (tax exemptions are\n * applied + the home Center is resolved server-side), and is computed by the\n * same engine as the PaymentIntent, so it never diverges from what the\n * customer is charged. */\nexport function useGameCardPreview<T = GameCardPreviewResult>(\n args: GameCardPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewGameCardOrder\", args, { ...options, auth: true });\n}\n\n/** Itemized quote for a ticket-mode event offer — base tickets, tax lines,\n * Center event fee, and authoritative grand total. Requires a signed-in\n * customer so tax exemptions match the eventual charge. */\nexport function useEventTicketPreview<T = EventTicketPreviewResult>(\n args: EventTicketPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewEventTicketOrder\", args, { ...options, auth: true });\n}\n\n/** Itemized quote for a one-time membership purchase — dues, the one-time setup\n * fee, tax lines, the selling Center's booking fee, and the authoritative grand\n * total. Drives the headless **Review** step. Requires a signed-in customer (tax\n * exemptions are applied + the home Center is resolved server-side), and is\n * computed by the same engine as the PaymentIntent, so it never diverges from\n * what the customer is charged. */\nexport function useMembershipPreview<T = MembershipPreviewResult>(\n args: MembershipPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMembershipOrder\", args, { ...options, auth: true });\n}\n\n/** Itemized quote for a RECURRING membership subscription — the one-time Review\n * fields (\"Due today\") PLUS `recurringTotalCents` + `cadence` (\"Auto-renews\n * at\"). Drives the recurring **Review** step. Requires a signed-in customer, and\n * is computed by the same engine as the subscription's first invoice, so it\n * never diverges from what the customer is charged. */\nexport function useMembershipSubscriptionPreview<T = MembershipSubscriptionPreviewResult>(\n args: MembershipPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMembershipSubscriptionOrder\", args, {\n ...options,\n auth: true,\n });\n}\n","/**\n * useBookingFlow — the hold → pay → confirm state machine.\n *\n * Orchestrates the booking funnel and HANDS the Stripe (Connect) payment data\n * to the UI layer; it does NOT load Stripe.js. After `preparePayment()`, render\n * Stripe Elements from `paymentIntent` (initialize Stripe with\n * `connectedAccountId` + `clientSecret`), let the customer pay, then\n * `startPolling()` until the webhook materializes the booking\n * (`status: \"confirmed\"`).\n *\n * Flow:\n * startHold(args) → \"held\" (requiresPayment) | \"confirmed\" (credit covered)\n * preparePayment() → \"awaitingPayment\" (+ paymentIntent)\n * [consumer renders Stripe Elements + the customer pays]\n * startPolling() → \"confirmed\" | \"expired\" | \"failed\" | \"abandoned\"\n */\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { useBowlosClient } from \"./react\";\nimport { BowlosApiError, BOWLOS_ERROR_CODES } from \"./errors\";\nimport {\n abandonCheckout as abandonCheckoutCall,\n createBooking as createBookingCall,\n createCheckoutPaymentIntent as createPaymentIntentCall,\n getCheckoutStatus as getCheckoutStatusCall,\n type BookingHold,\n type CheckoutStatusResult,\n type CreateBookingArgs,\n type PaymentIntentInfo,\n} from \"./data\";\n\nexport type BookingFlowStatus =\n | \"idle\"\n | \"holding\"\n | \"held\"\n | \"preparingPayment\"\n | \"awaitingPayment\"\n | \"confirmed\"\n | \"expired\"\n | \"failed\"\n | \"abandoned\"\n | \"error\";\n\nexport interface BookingReservationRef {\n reservationId: string | null;\n reservationDisplayId: string | null;\n}\n\nexport interface UseBookingFlowResult {\n status: BookingFlowStatus;\n hold: BookingHold | null;\n refToken: string | null;\n paymentIntent: PaymentIntentInfo | null;\n reservation: BookingReservationRef | null;\n requiresPayment: boolean | null;\n error: BowlosApiError | null;\n startHold: (args: CreateBookingArgs) => Promise<void>;\n preparePayment: () => Promise<PaymentIntentInfo | null>;\n pollStatus: () => Promise<CheckoutStatusResult | null>;\n startPolling: (intervalMs?: number) => void;\n stopPolling: () => void;\n abandon: () => Promise<void>;\n reset: () => void;\n}\n\nconst DEFAULT_POLL_MS = 2500;\n\nexport function useBookingFlow(): UseBookingFlowResult {\n const client = useBowlosClient();\n const [status, setStatus] = useState<BookingFlowStatus>(\"idle\");\n const [hold, setHold] = useState<BookingHold | null>(null);\n const [refToken, setRefToken] = useState<string | null>(null);\n const [paymentIntent, setPaymentIntent] = useState<PaymentIntentInfo | null>(null);\n const [reservation, setReservation] = useState<BookingReservationRef | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n\n // Mirror of refToken for the polling interval (avoids a stale closure).\n const refTokenRef = useRef<string | null>(null);\n const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);\n\n const stopPolling = useCallback(() => {\n if (pollRef.current !== null) {\n clearInterval(pollRef.current);\n pollRef.current = null;\n }\n }, []);\n\n useEffect(() => stopPolling, [stopPolling]); // clear the interval on unmount\n\n const reset = useCallback(() => {\n stopPolling();\n refTokenRef.current = null;\n setRefToken(null);\n setHold(null);\n setPaymentIntent(null);\n setReservation(null);\n setError(null);\n setStatus(\"idle\");\n }, [stopPolling]);\n\n const applyStatus = useCallback(\n (s: CheckoutStatusResult) => {\n switch (s.status) {\n case \"paid_materialized\":\n setReservation({\n reservationId: s.reservationId,\n reservationDisplayId: s.reservationDisplayId,\n });\n setStatus(\"confirmed\");\n stopPolling();\n break;\n case \"expired\":\n setStatus(\"expired\");\n stopPolling();\n break;\n case \"abandoned\":\n setStatus(\"abandoned\");\n stopPolling();\n break;\n case \"payment_failed_retryable\":\n setStatus(\"failed\");\n stopPolling();\n break;\n case \"not_found\":\n setError(new BowlosApiError(BOWLOS_ERROR_CODES.NOT_FOUND, \"Checkout not found.\", 404));\n setStatus(\"error\");\n stopPolling();\n break;\n case \"pending_payment\":\n default:\n break; // keep waiting\n }\n },\n [stopPolling],\n );\n\n const startHold = useCallback(\n async (args: CreateBookingArgs) => {\n stopPolling();\n setError(null);\n setPaymentIntent(null);\n setReservation(null);\n setStatus(\"holding\");\n try {\n const h = await createBookingCall(client, args);\n setHold(h);\n const rt = typeof h.checkoutRefToken === \"string\" ? h.checkoutRefToken : null;\n refTokenRef.current = rt;\n setRefToken(rt);\n if (!h.requiresPayment) {\n setReservation({\n reservationId: h.reservationId ?? null,\n reservationDisplayId: h.reservationDisplayId ?? null,\n });\n setStatus(\"confirmed\");\n } else if (rt) {\n setStatus(\"held\");\n } else {\n setError(\n new BowlosApiError(\n \"UNSUPPORTED_BOOKING_PATH\",\n \"This booking requires payment but no checkout hold was returned.\",\n 0,\n ),\n );\n setStatus(\"error\");\n }\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n setStatus(\"error\");\n }\n },\n [client, stopPolling],\n );\n\n const preparePayment = useCallback(async (): Promise<PaymentIntentInfo | null> => {\n const rt = refTokenRef.current;\n if (!rt) return null;\n setError(null);\n setStatus(\"preparingPayment\");\n try {\n const pi = await createPaymentIntentCall(client, rt);\n setPaymentIntent(pi);\n setStatus(\"awaitingPayment\");\n return pi;\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n setStatus(\"error\");\n return null;\n }\n }, [client]);\n\n const pollStatus = useCallback(async (): Promise<CheckoutStatusResult | null> => {\n const rt = refTokenRef.current;\n if (!rt) return null;\n try {\n const s = await getCheckoutStatusCall(client, rt);\n applyStatus(s);\n return s;\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n return null;\n }\n }, [client, applyStatus]);\n\n const startPolling = useCallback(\n (intervalMs: number = DEFAULT_POLL_MS) => {\n stopPolling();\n void pollStatus();\n pollRef.current = setInterval(() => {\n void pollStatus();\n }, intervalMs);\n },\n [pollStatus, stopPolling],\n );\n\n const abandon = useCallback(async () => {\n stopPolling();\n const rt = refTokenRef.current;\n if (rt) {\n try {\n await abandonCheckoutCall(client, rt);\n } catch {\n // best-effort: the hold also frees itself on its TTL\n }\n }\n setStatus(\"abandoned\");\n }, [client, stopPolling]);\n\n return {\n status,\n hold,\n refToken,\n paymentIntent,\n reservation,\n requiresPayment: hold ? hold.requiresPayment : null,\n error,\n startHold,\n preparePayment,\n pollStatus,\n startPolling,\n stopPolling,\n abandon,\n reset,\n };\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../Users/bosummers/conductor/workspaces/bowlos/budapest/packages/shared/src/inquiry.ts"],"names":[],"mappings":";AAmCO,IAAM,aAAA,GAAyD;AAAA,EACpE,OAAA,EAAS;AAAA,IACP,KAAA,EAAO,SAAA;AAAA,IACP,MAAA,EAAQ;AAAA,MACN,EAAE,GAAA,EAAK,aAAA,EAAe,KAAA,EAAO,cAAA,EAAgB,UAAU,IAAA,EAAK;AAAA,MAC5D,EAAE,GAAA,EAAK,aAAA,EAAe,KAAA,EAAO,cAAA,EAAe;AAAA,MAC5C,EAAE,GAAA,EAAK,OAAA,EAAS,KAAA,EAAO,OAAA,EAA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AAM,UAAA,CAAW,MAAA,CAAO,MAAA,CAAO,IAAA,CAAK,MAAA,EAAQ,GAAA,EAAK,OAAA,CAAQ,MAAA,CAAO,OAAO,CAAC,CAAA;AACpF,EAAA,OAAO,KAAA,CAAM,KAAK,IAAI,UAAA,CAAW,GAAG,CAAC,CAAA,CAClC,IAAI,CAAC,CAAA,KAAM,EAAE,QAAA,CAAS,EAAE,EAAE,QAAA,CAAS,CAAA,EAAG,GAAG,CAAC,CAAA,CAC1C,KAAK,EAAE,CAAA;AACZ;AAgBA,eAAsB,eAAA,CAAgB,QAAgB,OAAA,EAAkC;AACtF,EAAA,OAAO,OAAA,CAAQ,QAAQ,OAAO,CAAA;AAChC","file":"chunk-SMPDCDMB.js","sourcesContent":["/**\n * Inquiry forms (\"No Dead Ends\" #3) — pure logic for the customer contact /\n * party-inquiry forms a center site posts into BowlOS. No DB, no Convex ctx.\n *\n * - the form-type registry (which fields each preset collects), so the SDK\n * and the gateway agree on the shape;\n * - formatInquiryBody: render submitted fields into the labeled block the\n * operator reads in the Inbox;\n * - validateInquiry: required fields + email + length caps;\n * - HMAC helpers: derive a per-center signing secret from the platform master\n * secret, and verify a signed webhook body (the spam gate — only a holder\n * of the center's secret can post). Mirrors mailgun_inbound's verify.\n *\n * Canonical home (shared by the convex backend + the @bowlos/reservations SDK).\n */\n\nexport type InquiryFormType = \"contact\" | \"event_party\";\n\nexport interface InquiryFieldDef {\n key: string;\n label: string;\n required?: boolean;\n}\n\ninterface InquiryFormDef {\n label: string;\n /** Ordered fields rendered in the inbox block. */\n fields: InquiryFieldDef[];\n}\n\n/**\n * The catalog of forms. Two presets at launch (more are additive). The field\n * ORDER here is the order shown in the inbox. `event_party` matches the party\n * inquiry shape (people count / date / time / notes).\n */\nexport const INQUIRY_FORMS: Record<InquiryFormType, InquiryFormDef> = {\n contact: {\n label: \"Contact\",\n fields: [\n { key: \"contactName\", label: \"Contact Name\", required: true },\n { key: \"companyName\", label: \"Company Name\" },\n { key: \"email\", label: \"Email\", required: true },\n { key: \"mobile\", label: \"Mobile\" },\n { key: \"message\", label: \"Message\", required: true },\n ],\n },\n event_party: {\n label: \"Party / event inquiry\",\n fields: [\n { key: \"contactName\", label: \"Contact Name\", required: true },\n { key: \"companyName\", label: \"Company Name\" },\n { key: \"email\", label: \"Email\", required: true },\n { key: \"mobile\", label: \"Mobile\" },\n { key: \"peopleCount\", label: \"People count\" },\n { key: \"date\", label: \"Date\" },\n { key: \"time\", label: \"Time\" },\n { key: \"notes\", label: \"Notes\" },\n ],\n },\n};\n\nexport function isInquiryFormType(v: unknown): v is InquiryFormType {\n return v === \"contact\" || v === \"event_party\";\n}\n\nconst MAX_FIELD_LEN = 5000;\n\n/**\n * Validate a submitted inquiry. Returns an error message, or null when valid.\n * Required fields must be non-empty; email must look like an email; every\n * value is length-capped (defense against a giant body).\n */\nexport function validateInquiry(\n formType: InquiryFormType,\n values: Record<string, unknown>,\n): string | null {\n const def = INQUIRY_FORMS[formType];\n for (const f of def.fields) {\n const raw = values[f.key];\n const val = typeof raw === \"string\" ? raw.trim() : \"\";\n if (f.required && !val) return `${f.label} is required.`;\n if (typeof raw === \"string\" && raw.length > MAX_FIELD_LEN) {\n return `${f.label} is too long.`;\n }\n }\n const email = typeof values.email === \"string\" ? values.email.trim() : \"\";\n if (!/^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$/.test(email)) {\n return \"A valid email is required.\";\n }\n return null;\n}\n\n/**\n * Render submitted fields as a labeled block for the Inbox message body, e.g.\n * Contact Name: John Smith\n * Company Name:\n * Email: johnsmith@email.com\n * People count: 60\n * Registry fields render first (in order, blanks included so the shape is\n * always recognizable); any extra submitted keys are appended verbatim.\n */\nexport function formatInquiryBody(\n formType: InquiryFormType,\n values: Record<string, unknown>,\n): string {\n const def = INQUIRY_FORMS[formType];\n const known = new Set(def.fields.map((f) => f.key));\n const extras = Object.keys(values).filter(\n (k) => !known.has(k) && k !== \"formType\",\n );\n const rows: Array<{ label: string; value: string }> = [\n ...def.fields.map((f) => ({\n label: f.label,\n value: typeof values[f.key] === \"string\" ? (values[f.key] as string).trim() : \"\",\n })),\n ...extras.map((k) => ({\n label: k,\n value: typeof values[k] === \"string\" ? (values[k] as string).trim() : String(values[k] ?? \"\"),\n })),\n ];\n const width = Math.max(...rows.map((r) => r.label.length)) + 1; // +1 for \":\"\n return rows\n .map((r) => `${(r.label + \":\").padEnd(width + 1)} ${r.value}`.trimEnd())\n .join(\"\\n\");\n}\n\n/** A short subject line for the conversation, e.g. \"Party / event inquiry — Jane\". */\nexport function inquirySubject(\n formType: InquiryFormType,\n values: Record<string, unknown>,\n): string {\n const name = typeof values.contactName === \"string\" ? values.contactName.trim() : \"\";\n const base = INQUIRY_FORMS[formType].label;\n return name ? `${base} — ${name}` : base;\n}\n\n// ─── HMAC signing (the spam gate) ──────────────────────────────────\n\nasync function hmacHex(secret: string, message: string): Promise<string> {\n const encoder = new TextEncoder();\n const key = await globalThis.crypto.subtle.importKey(\n \"raw\",\n encoder.encode(secret),\n { name: \"HMAC\", hash: \"SHA-256\" },\n false,\n [\"sign\"],\n );\n const sig = await globalThis.crypto.subtle.sign(\"HMAC\", key, encoder.encode(message));\n return Array.from(new Uint8Array(sig))\n .map((b) => b.toString(16).padStart(2, \"0\"))\n .join(\"\");\n}\n\n/**\n * Derive the per-center inquiry signing secret from the platform master secret.\n * BowlOS never stores per-center secrets — it recomputes this on demand, and\n * hands the same value to the center's server once (so its form route can sign).\n * Compromise of one is scoped to inbox spam for that one center.\n */\nexport async function deriveCenterInquirySecret(\n masterSecret: string,\n centerId: string,\n): Promise<string> {\n return hmacHex(masterSecret, `inquiry-secret:v1:${centerId}`);\n}\n\n/** HMAC-SHA256 of the raw request body with the center's secret, hex. */\nexport async function signInquiryBody(secret: string, rawBody: string): Promise<string> {\n return hmacHex(secret, rawBody);\n}\n\n/** Constant-time verify of a hex signature against the body. */\nexport async function verifyInquirySignature(\n secret: string,\n rawBody: string,\n signature: string,\n): Promise<boolean> {\n const expected = await hmacHex(secret, rawBody);\n if (!signature || signature.length !== expected.length) return false;\n let diff = 0;\n for (let i = 0; i < expected.length; i++) {\n diff |= expected.charCodeAt(i) ^ signature.charCodeAt(i);\n }\n return diff === 0;\n}\n"]}
|